syntaur 0.59.0 → 0.60.0

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 (62) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/dashboard/dist/assets/{_basePickBy-C6lAhnAx.js → _basePickBy-CuAo8UW0.js} +1 -1
  3. package/dashboard/dist/assets/{_baseUniq-R1BOuKZl.js → _baseUniq-4Xj4MGEd.js} +1 -1
  4. package/dashboard/dist/assets/{arc-Dz0Do3Uh.js → arc-D-cLsL4Z.js} +1 -1
  5. package/dashboard/dist/assets/{architectureDiagram-2XIMDMQ5-Z_QQXidZ.js → architectureDiagram-2XIMDMQ5-MFXpgrLd.js} +1 -1
  6. package/dashboard/dist/assets/{blockDiagram-WCTKOSBZ-DaQF4FJg.js → blockDiagram-WCTKOSBZ-C--nvhZ1.js} +1 -1
  7. package/dashboard/dist/assets/{c4Diagram-IC4MRINW-DFQIi8Hg.js → c4Diagram-IC4MRINW-Buf6Z0Mz.js} +1 -1
  8. package/dashboard/dist/assets/channel-HCmWgCw9.js +1 -0
  9. package/dashboard/dist/assets/{chunk-4BX2VUAB-wA9evSER.js → chunk-4BX2VUAB-BI-SnYdf.js} +1 -1
  10. package/dashboard/dist/assets/{chunk-55IACEB6-yAa2iSZz.js → chunk-55IACEB6-Bk-wRH9v.js} +1 -1
  11. package/dashboard/dist/assets/{chunk-FMBD7UC4-DO-rLF71.js → chunk-FMBD7UC4-BkrKPw8u.js} +1 -1
  12. package/dashboard/dist/assets/{chunk-JSJVCQXG-CIUXOtdm.js → chunk-JSJVCQXG-klefEqKn.js} +1 -1
  13. package/dashboard/dist/assets/{chunk-KX2RTZJC-DlZD-z67.js → chunk-KX2RTZJC-Cg2N1i9P.js} +1 -1
  14. package/dashboard/dist/assets/{chunk-NQ4KR5QH-Cmh5sSb8.js → chunk-NQ4KR5QH-wplW9rdD.js} +1 -1
  15. package/dashboard/dist/assets/{chunk-QZHKN3VN-VExXj9RO.js → chunk-QZHKN3VN-CszX6pq9.js} +1 -1
  16. package/dashboard/dist/assets/{chunk-WL4C6EOR-BfLQvF76.js → chunk-WL4C6EOR-CyLBEb4A.js} +1 -1
  17. package/dashboard/dist/assets/classDiagram-VBA2DB6C-DtqtjiBT.js +1 -0
  18. package/dashboard/dist/assets/classDiagram-v2-RAHNMMFH-DtqtjiBT.js +1 -0
  19. package/dashboard/dist/assets/clone-CDSahJag.js +1 -0
  20. package/dashboard/dist/assets/{cose-bilkent-S5V4N54A-TD9IoZqw.js → cose-bilkent-S5V4N54A-BPsMA7I5.js} +1 -1
  21. package/dashboard/dist/assets/{dagre-KLK3FWXG-D7xlqKRk.js → dagre-KLK3FWXG-iwgQVY1-.js} +1 -1
  22. package/dashboard/dist/assets/{diagram-E7M64L7V-CBbz63Qs.js → diagram-E7M64L7V-BnkjX2sn.js} +1 -1
  23. package/dashboard/dist/assets/{diagram-IFDJBPK2-DvfNpHmV.js → diagram-IFDJBPK2-BxuQhq0R.js} +1 -1
  24. package/dashboard/dist/assets/{diagram-P4PSJMXO-BHWEPD_W.js → diagram-P4PSJMXO-_sPQtDFF.js} +1 -1
  25. package/dashboard/dist/assets/{erDiagram-INFDFZHY-BppYZ06S.js → erDiagram-INFDFZHY-Xbs_F1mT.js} +1 -1
  26. package/dashboard/dist/assets/{flowDiagram-PKNHOUZH-C9jFGOb6.js → flowDiagram-PKNHOUZH-C4txvcVj.js} +1 -1
  27. package/dashboard/dist/assets/{ganttDiagram-A5KZAMGK-C78z0pY9.js → ganttDiagram-A5KZAMGK-BNfmrW_s.js} +1 -1
  28. package/dashboard/dist/assets/{gitGraphDiagram-K3NZZRJ6-CF5YmhOF.js → gitGraphDiagram-K3NZZRJ6-vNtati3x.js} +1 -1
  29. package/dashboard/dist/assets/{graph-CV9GaiRf.js → graph-BoTq5ZU0.js} +1 -1
  30. package/dashboard/dist/assets/{index-BeL-DOH-.css → index-Dw6mWdZZ.css} +1 -1
  31. package/dashboard/dist/assets/index-oQabaQT9.js +644 -0
  32. package/dashboard/dist/assets/{infoDiagram-LFFYTUFH-DNHH7wz7.js → infoDiagram-LFFYTUFH-BJw8hObN.js} +1 -1
  33. package/dashboard/dist/assets/{ishikawaDiagram-PHBUUO56-D2sULrxv.js → ishikawaDiagram-PHBUUO56--ofJ5_wH.js} +1 -1
  34. package/dashboard/dist/assets/{journeyDiagram-4ABVD52K-BQ9VeW2b.js → journeyDiagram-4ABVD52K-BrEpTfTe.js} +1 -1
  35. package/dashboard/dist/assets/{kanban-definition-K7BYSVSG-ChTe8ek_.js → kanban-definition-K7BYSVSG-CnwoQq2m.js} +1 -1
  36. package/dashboard/dist/assets/{layout-E7bYrwHj.js → layout-DUQcYnn8.js} +1 -1
  37. package/dashboard/dist/assets/{linear-BvPEjC0z.js → linear-tcsDRZ6Z.js} +1 -1
  38. package/dashboard/dist/assets/{mermaid.core-DN8nJG9M.js → mermaid.core-IuoVhjqY.js} +4 -4
  39. package/dashboard/dist/assets/{mindmap-definition-YRQLILUH-DhViA5Bq.js → mindmap-definition-YRQLILUH-BFmfPV07.js} +1 -1
  40. package/dashboard/dist/assets/{pieDiagram-SKSYHLDU-BuFJW745.js → pieDiagram-SKSYHLDU-HAnc0XBk.js} +1 -1
  41. package/dashboard/dist/assets/{quadrantDiagram-337W2JSQ-gZq_igmN.js → quadrantDiagram-337W2JSQ-V07MDab7.js} +1 -1
  42. package/dashboard/dist/assets/{requirementDiagram-Z7DCOOCP-D589PZrj.js → requirementDiagram-Z7DCOOCP-CaH7f5Jg.js} +1 -1
  43. package/dashboard/dist/assets/{sankeyDiagram-WA2Y5GQK-C5b1S_nc.js → sankeyDiagram-WA2Y5GQK-DlMUAnA2.js} +1 -1
  44. package/dashboard/dist/assets/{sequenceDiagram-2WXFIKYE-_fLMpns7.js → sequenceDiagram-2WXFIKYE-Vw15xOlT.js} +1 -1
  45. package/dashboard/dist/assets/{stateDiagram-RAJIS63D-3mdnJTGi.js → stateDiagram-RAJIS63D-ZNkeO5HO.js} +1 -1
  46. package/dashboard/dist/assets/stateDiagram-v2-FVOUBMTO-7-xErwgu.js +1 -0
  47. package/dashboard/dist/assets/{timeline-definition-YZTLITO2-Bm19QIv7.js → timeline-definition-YZTLITO2-CvOXGvQg.js} +1 -1
  48. package/dashboard/dist/assets/{treemap-KZPCXAKY-Ys0z--5_.js → treemap-KZPCXAKY-DkX_WNTB.js} +1 -1
  49. package/dashboard/dist/assets/{vennDiagram-LZ73GAT5-nhX7e2VS.js → vennDiagram-LZ73GAT5-0uKyUB2W.js} +1 -1
  50. package/dashboard/dist/assets/{xychartDiagram-JWTSCODW-GYhRTu71.js → xychartDiagram-JWTSCODW-CcPkniF6.js} +1 -1
  51. package/dashboard/dist/index.html +2 -2
  52. package/package.json +1 -1
  53. package/platforms/claude-code/.claude-plugin/plugin.json +1 -1
  54. package/platforms/codex/.codex-plugin/plugin.json +1 -1
  55. package/platforms/hermes/plugins/syntaur/__pycache__/__init__.cpython-312.pyc +0 -0
  56. package/platforms/hermes/plugins/syntaur/__pycache__/boundary.cpython-312.pyc +0 -0
  57. package/dashboard/dist/assets/channel-BmoI_zLR.js +0 -1
  58. package/dashboard/dist/assets/classDiagram-VBA2DB6C-B1r1U8OB.js +0 -1
  59. package/dashboard/dist/assets/classDiagram-v2-RAHNMMFH-B1r1U8OB.js +0 -1
  60. package/dashboard/dist/assets/clone-tJiyPHUq.js +0 -1
  61. package/dashboard/dist/assets/index-CoQP9UdN.js +0 -644
  62. package/dashboard/dist/assets/stateDiagram-v2-FVOUBMTO-DD9zPYAT.js +0 -1
@@ -0,0 +1,644 @@
1
+ var EI=Object.defineProperty;var TI=(e,t,n)=>t in e?EI(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var _x=(e,t,n)=>TI(e,typeof t!="symbol"?t+"":t,n);function RI(e,t){for(var n=0;n<t.length;n++){const r=t[n];if(typeof r!="string"&&!Array.isArray(r)){for(const o in r)if(o!=="default"&&!(o in e)){const i=Object.getOwnPropertyDescriptor(r,o);i&&Object.defineProperty(e,o,i.get?i:{enumerable:!0,get:()=>r[o]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))r(o);new MutationObserver(o=>{for(const i of o)if(i.type==="childList")for(const a of i.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&r(a)}).observe(document,{childList:!0,subtree:!0});function n(o){const i={};return o.integrity&&(i.integrity=o.integrity),o.referrerPolicy&&(i.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?i.credentials="include":o.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function r(o){if(o.ep)return;o.ep=!0;const i=n(o);fetch(o.href,i)}})();function wd(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function aae(e){if(Object.prototype.hasOwnProperty.call(e,"__esModule"))return e;var t=e.default;if(typeof t=="function"){var n=function r(){return this instanceof r?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};n.prototype=t.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(e).forEach(function(r){var o=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(n,r,o.get?o:{enumerable:!0,get:function(){return e[r]}})}),n}var Dx={exports:{}},lu={},$x={exports:{}},kt={};/**
2
+ * @license React
3
+ * react.production.min.js
4
+ *
5
+ * Copyright (c) Facebook, Inc. and its affiliates.
6
+ *
7
+ * This source code is licensed under the MIT license found in the
8
+ * LICENSE file in the root directory of this source tree.
9
+ */var Yk;function AI(){if(Yk)return kt;Yk=1;var e=Symbol.for("react.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),o=Symbol.for("react.profiler"),i=Symbol.for("react.provider"),a=Symbol.for("react.context"),l=Symbol.for("react.forward_ref"),d=Symbol.for("react.suspense"),f=Symbol.for("react.memo"),p=Symbol.for("react.lazy"),h=Symbol.iterator;function g(B){return B===null||typeof B!="object"?null:(B=h&&B[h]||B["@@iterator"],typeof B=="function"?B:null)}var y={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},k=Object.assign,w={};function b(B,G,H){this.props=B,this.context=G,this.refs=w,this.updater=H||y}b.prototype.isReactComponent={},b.prototype.setState=function(B,G){if(typeof B!="object"&&typeof B!="function"&&B!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,B,G,"setState")},b.prototype.forceUpdate=function(B){this.updater.enqueueForceUpdate(this,B,"forceUpdate")};function j(){}j.prototype=b.prototype;function N(B,G,H){this.props=B,this.context=G,this.refs=w,this.updater=H||y}var S=N.prototype=new j;S.constructor=N,k(S,b.prototype),S.isPureReactComponent=!0;var C=Array.isArray,D=Object.prototype.hasOwnProperty,T={current:null},R={key:!0,ref:!0,__self:!0,__source:!0};function $(B,G,H){var Q,te={},Z=null,ae=null;if(G!=null)for(Q in G.ref!==void 0&&(ae=G.ref),G.key!==void 0&&(Z=""+G.key),G)D.call(G,Q)&&!R.hasOwnProperty(Q)&&(te[Q]=G[Q]);var ne=arguments.length-2;if(ne===1)te.children=H;else if(1<ne){for(var ue=Array(ne),ye=0;ye<ne;ye++)ue[ye]=arguments[ye+2];te.children=ue}if(B&&B.defaultProps)for(Q in ne=B.defaultProps,ne)te[Q]===void 0&&(te[Q]=ne[Q]);return{$$typeof:e,type:B,key:Z,ref:ae,props:te,_owner:T.current}}function _(B,G){return{$$typeof:e,type:B.type,key:G,ref:B.ref,props:B.props,_owner:B._owner}}function U(B){return typeof B=="object"&&B!==null&&B.$$typeof===e}function I(B){var G={"=":"=0",":":"=2"};return"$"+B.replace(/[=:]/g,function(H){return G[H]})}var F=/\/+/g;function M(B,G){return typeof B=="object"&&B!==null&&B.key!=null?I(""+B.key):G.toString(36)}function A(B,G,H,Q,te){var Z=typeof B;(Z==="undefined"||Z==="boolean")&&(B=null);var ae=!1;if(B===null)ae=!0;else switch(Z){case"string":case"number":ae=!0;break;case"object":switch(B.$$typeof){case e:case t:ae=!0}}if(ae)return ae=B,te=te(ae),B=Q===""?"."+M(ae,0):Q,C(te)?(H="",B!=null&&(H=B.replace(F,"$&/")+"/"),A(te,G,H,"",function(ye){return ye})):te!=null&&(U(te)&&(te=_(te,H+(!te.key||ae&&ae.key===te.key?"":(""+te.key).replace(F,"$&/")+"/")+B)),G.push(te)),1;if(ae=0,Q=Q===""?".":Q+":",C(B))for(var ne=0;ne<B.length;ne++){Z=B[ne];var ue=Q+M(Z,ne);ae+=A(Z,G,H,ue,te)}else if(ue=g(B),typeof ue=="function")for(B=ue.call(B),ne=0;!(Z=B.next()).done;)Z=Z.value,ue=Q+M(Z,ne++),ae+=A(Z,G,H,ue,te);else if(Z==="object")throw G=String(B),Error("Objects are not valid as a React child (found: "+(G==="[object Object]"?"object with keys {"+Object.keys(B).join(", ")+"}":G)+"). If you meant to render a collection of children, use an array instead.");return ae}function L(B,G,H){if(B==null)return B;var Q=[],te=0;return A(B,Q,"","",function(Z){return G.call(H,Z,te++)}),Q}function z(B){if(B._status===-1){var G=B._result;G=G(),G.then(function(H){(B._status===0||B._status===-1)&&(B._status=1,B._result=H)},function(H){(B._status===0||B._status===-1)&&(B._status=2,B._result=H)}),B._status===-1&&(B._status=0,B._result=G)}if(B._status===1)return B._result.default;throw B._result}var W={current:null},V={transition:null},K={ReactCurrentDispatcher:W,ReactCurrentBatchConfig:V,ReactCurrentOwner:T};function O(){throw Error("act(...) is not supported in production builds of React.")}return kt.Children={map:L,forEach:function(B,G,H){L(B,function(){G.apply(this,arguments)},H)},count:function(B){var G=0;return L(B,function(){G++}),G},toArray:function(B){return L(B,function(G){return G})||[]},only:function(B){if(!U(B))throw Error("React.Children.only expected to receive a single React element child.");return B}},kt.Component=b,kt.Fragment=n,kt.Profiler=o,kt.PureComponent=N,kt.StrictMode=r,kt.Suspense=d,kt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=K,kt.act=O,kt.cloneElement=function(B,G,H){if(B==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+B+".");var Q=k({},B.props),te=B.key,Z=B.ref,ae=B._owner;if(G!=null){if(G.ref!==void 0&&(Z=G.ref,ae=T.current),G.key!==void 0&&(te=""+G.key),B.type&&B.type.defaultProps)var ne=B.type.defaultProps;for(ue in G)D.call(G,ue)&&!R.hasOwnProperty(ue)&&(Q[ue]=G[ue]===void 0&&ne!==void 0?ne[ue]:G[ue])}var ue=arguments.length-2;if(ue===1)Q.children=H;else if(1<ue){ne=Array(ue);for(var ye=0;ye<ue;ye++)ne[ye]=arguments[ye+2];Q.children=ne}return{$$typeof:e,type:B.type,key:te,ref:Z,props:Q,_owner:ae}},kt.createContext=function(B){return B={$$typeof:a,_currentValue:B,_currentValue2:B,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},B.Provider={$$typeof:i,_context:B},B.Consumer=B},kt.createElement=$,kt.createFactory=function(B){var G=$.bind(null,B);return G.type=B,G},kt.createRef=function(){return{current:null}},kt.forwardRef=function(B){return{$$typeof:l,render:B}},kt.isValidElement=U,kt.lazy=function(B){return{$$typeof:p,_payload:{_status:-1,_result:B},_init:z}},kt.memo=function(B,G){return{$$typeof:f,type:B,compare:G===void 0?null:G}},kt.startTransition=function(B){var G=V.transition;V.transition={};try{B()}finally{V.transition=G}},kt.unstable_act=O,kt.useCallback=function(B,G){return W.current.useCallback(B,G)},kt.useContext=function(B){return W.current.useContext(B)},kt.useDebugValue=function(){},kt.useDeferredValue=function(B){return W.current.useDeferredValue(B)},kt.useEffect=function(B,G){return W.current.useEffect(B,G)},kt.useId=function(){return W.current.useId()},kt.useImperativeHandle=function(B,G,H){return W.current.useImperativeHandle(B,G,H)},kt.useInsertionEffect=function(B,G){return W.current.useInsertionEffect(B,G)},kt.useLayoutEffect=function(B,G){return W.current.useLayoutEffect(B,G)},kt.useMemo=function(B,G){return W.current.useMemo(B,G)},kt.useReducer=function(B,G,H){return W.current.useReducer(B,G,H)},kt.useRef=function(B){return W.current.useRef(B)},kt.useState=function(B){return W.current.useState(B)},kt.useSyncExternalStore=function(B,G,H){return W.current.useSyncExternalStore(B,G,H)},kt.useTransition=function(){return W.current.useTransition()},kt.version="18.3.1",kt}var Xk;function jd(){return Xk||(Xk=1,$x.exports=AI()),$x.exports}/**
10
+ * @license React
11
+ * react-jsx-runtime.production.min.js
12
+ *
13
+ * Copyright (c) Facebook, Inc. and its affiliates.
14
+ *
15
+ * This source code is licensed under the MIT license found in the
16
+ * LICENSE file in the root directory of this source tree.
17
+ */var Qk;function PI(){if(Qk)return lu;Qk=1;var e=jd(),t=Symbol.for("react.element"),n=Symbol.for("react.fragment"),r=Object.prototype.hasOwnProperty,o=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,i={key:!0,ref:!0,__self:!0,__source:!0};function a(l,d,f){var p,h={},g=null,y=null;f!==void 0&&(g=""+f),d.key!==void 0&&(g=""+d.key),d.ref!==void 0&&(y=d.ref);for(p in d)r.call(d,p)&&!i.hasOwnProperty(p)&&(h[p]=d[p]);if(l&&l.defaultProps)for(p in d=l.defaultProps,d)h[p]===void 0&&(h[p]=d[p]);return{$$typeof:t,type:l,key:g,ref:y,props:h,_owner:o.current}}return lu.Fragment=n,lu.jsx=a,lu.jsxs=a,lu}var Jk;function _I(){return Jk||(Jk=1,Dx.exports=PI()),Dx.exports}var s=_I(),m=jd();const $t=wd(m),kE=RI({__proto__:null,default:$t},[m]);var Yf={},Ix={exports:{}},pr={},Mx={exports:{}},Lx={};/**
18
+ * @license React
19
+ * scheduler.production.min.js
20
+ *
21
+ * Copyright (c) Facebook, Inc. and its affiliates.
22
+ *
23
+ * This source code is licensed under the MIT license found in the
24
+ * LICENSE file in the root directory of this source tree.
25
+ */var Zk;function DI(){return Zk||(Zk=1,(function(e){function t(V,K){var O=V.length;V.push(K);e:for(;0<O;){var B=O-1>>>1,G=V[B];if(0<o(G,K))V[B]=K,V[O]=G,O=B;else break e}}function n(V){return V.length===0?null:V[0]}function r(V){if(V.length===0)return null;var K=V[0],O=V.pop();if(O!==K){V[0]=O;e:for(var B=0,G=V.length,H=G>>>1;B<H;){var Q=2*(B+1)-1,te=V[Q],Z=Q+1,ae=V[Z];if(0>o(te,O))Z<G&&0>o(ae,te)?(V[B]=ae,V[Z]=O,B=Z):(V[B]=te,V[Q]=O,B=Q);else if(Z<G&&0>o(ae,O))V[B]=ae,V[Z]=O,B=Z;else break e}}return K}function o(V,K){var O=V.sortIndex-K.sortIndex;return O!==0?O:V.id-K.id}if(typeof performance=="object"&&typeof performance.now=="function"){var i=performance;e.unstable_now=function(){return i.now()}}else{var a=Date,l=a.now();e.unstable_now=function(){return a.now()-l}}var d=[],f=[],p=1,h=null,g=3,y=!1,k=!1,w=!1,b=typeof setTimeout=="function"?setTimeout:null,j=typeof clearTimeout=="function"?clearTimeout:null,N=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function S(V){for(var K=n(f);K!==null;){if(K.callback===null)r(f);else if(K.startTime<=V)r(f),K.sortIndex=K.expirationTime,t(d,K);else break;K=n(f)}}function C(V){if(w=!1,S(V),!k)if(n(d)!==null)k=!0,z(D);else{var K=n(f);K!==null&&W(C,K.startTime-V)}}function D(V,K){k=!1,w&&(w=!1,j($),$=-1),y=!0;var O=g;try{for(S(K),h=n(d);h!==null&&(!(h.expirationTime>K)||V&&!I());){var B=h.callback;if(typeof B=="function"){h.callback=null,g=h.priorityLevel;var G=B(h.expirationTime<=K);K=e.unstable_now(),typeof G=="function"?h.callback=G:h===n(d)&&r(d),S(K)}else r(d);h=n(d)}if(h!==null)var H=!0;else{var Q=n(f);Q!==null&&W(C,Q.startTime-K),H=!1}return H}finally{h=null,g=O,y=!1}}var T=!1,R=null,$=-1,_=5,U=-1;function I(){return!(e.unstable_now()-U<_)}function F(){if(R!==null){var V=e.unstable_now();U=V;var K=!0;try{K=R(!0,V)}finally{K?M():(T=!1,R=null)}}else T=!1}var M;if(typeof N=="function")M=function(){N(F)};else if(typeof MessageChannel<"u"){var A=new MessageChannel,L=A.port2;A.port1.onmessage=F,M=function(){L.postMessage(null)}}else M=function(){b(F,0)};function z(V){R=V,T||(T=!0,M())}function W(V,K){$=b(function(){V(e.unstable_now())},K)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(V){V.callback=null},e.unstable_continueExecution=function(){k||y||(k=!0,z(D))},e.unstable_forceFrameRate=function(V){0>V||125<V?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):_=0<V?Math.floor(1e3/V):5},e.unstable_getCurrentPriorityLevel=function(){return g},e.unstable_getFirstCallbackNode=function(){return n(d)},e.unstable_next=function(V){switch(g){case 1:case 2:case 3:var K=3;break;default:K=g}var O=g;g=K;try{return V()}finally{g=O}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(V,K){switch(V){case 1:case 2:case 3:case 4:case 5:break;default:V=3}var O=g;g=V;try{return K()}finally{g=O}},e.unstable_scheduleCallback=function(V,K,O){var B=e.unstable_now();switch(typeof O=="object"&&O!==null?(O=O.delay,O=typeof O=="number"&&0<O?B+O:B):O=B,V){case 1:var G=-1;break;case 2:G=250;break;case 5:G=1073741823;break;case 4:G=1e4;break;default:G=5e3}return G=O+G,V={id:p++,callback:K,priorityLevel:V,startTime:O,expirationTime:G,sortIndex:-1},O>B?(V.sortIndex=O,t(f,V),n(d)===null&&V===n(f)&&(w?(j($),$=-1):w=!0,W(C,O-B))):(V.sortIndex=G,t(d,V),k||y||(k=!0,z(D))),V},e.unstable_shouldYield=I,e.unstable_wrapCallback=function(V){var K=g;return function(){var O=g;g=K;try{return V.apply(this,arguments)}finally{g=O}}}})(Lx)),Lx}var e1;function $I(){return e1||(e1=1,Mx.exports=DI()),Mx.exports}/**
26
+ * @license React
27
+ * react-dom.production.min.js
28
+ *
29
+ * Copyright (c) Facebook, Inc. and its affiliates.
30
+ *
31
+ * This source code is licensed under the MIT license found in the
32
+ * LICENSE file in the root directory of this source tree.
33
+ */var t1;function II(){if(t1)return pr;t1=1;var e=jd(),t=$I();function n(c){for(var u="https://reactjs.org/docs/error-decoder.html?invariant="+c,x=1;x<arguments.length;x++)u+="&args[]="+encodeURIComponent(arguments[x]);return"Minified React error #"+c+"; visit "+u+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var r=new Set,o={};function i(c,u){a(c,u),a(c+"Capture",u)}function a(c,u){for(o[c]=u,c=0;c<u.length;c++)r.add(u[c])}var l=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),d=Object.prototype.hasOwnProperty,f=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,p={},h={};function g(c){return d.call(h,c)?!0:d.call(p,c)?!1:f.test(c)?h[c]=!0:(p[c]=!0,!1)}function y(c,u,x,v){if(x!==null&&x.type===0)return!1;switch(typeof u){case"function":case"symbol":return!0;case"boolean":return v?!1:x!==null?!x.acceptsBooleans:(c=c.toLowerCase().slice(0,5),c!=="data-"&&c!=="aria-");default:return!1}}function k(c,u,x,v){if(u===null||typeof u>"u"||y(c,u,x,v))return!0;if(v)return!1;if(x!==null)switch(x.type){case 3:return!u;case 4:return u===!1;case 5:return isNaN(u);case 6:return isNaN(u)||1>u}return!1}function w(c,u,x,v,E,P,q){this.acceptsBooleans=u===2||u===3||u===4,this.attributeName=v,this.attributeNamespace=E,this.mustUseProperty=x,this.propertyName=c,this.type=u,this.sanitizeURL=P,this.removeEmptyString=q}var b={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(c){b[c]=new w(c,0,!1,c,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(c){var u=c[0];b[u]=new w(u,1,!1,c[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(c){b[c]=new w(c,2,!1,c.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(c){b[c]=new w(c,2,!1,c,null,!1,!1)}),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(c){b[c]=new w(c,3,!1,c.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(c){b[c]=new w(c,3,!0,c,null,!1,!1)}),["capture","download"].forEach(function(c){b[c]=new w(c,4,!1,c,null,!1,!1)}),["cols","rows","size","span"].forEach(function(c){b[c]=new w(c,6,!1,c,null,!1,!1)}),["rowSpan","start"].forEach(function(c){b[c]=new w(c,5,!1,c.toLowerCase(),null,!1,!1)});var j=/[\-:]([a-z])/g;function N(c){return c[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(c){var u=c.replace(j,N);b[u]=new w(u,1,!1,c,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(c){var u=c.replace(j,N);b[u]=new w(u,1,!1,c,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(c){var u=c.replace(j,N);b[u]=new w(u,1,!1,c,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(c){b[c]=new w(c,1,!1,c.toLowerCase(),null,!1,!1)}),b.xlinkHref=new w("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(c){b[c]=new w(c,1,!1,c.toLowerCase(),null,!0,!0)});function S(c,u,x,v){var E=b.hasOwnProperty(u)?b[u]:null;(E!==null?E.type!==0:v||!(2<u.length)||u[0]!=="o"&&u[0]!=="O"||u[1]!=="n"&&u[1]!=="N")&&(k(u,x,E,v)&&(x=null),v||E===null?g(u)&&(x===null?c.removeAttribute(u):c.setAttribute(u,""+x)):E.mustUseProperty?c[E.propertyName]=x===null?E.type===3?!1:"":x:(u=E.attributeName,v=E.attributeNamespace,x===null?c.removeAttribute(u):(E=E.type,x=E===3||E===4&&x===!0?"":""+x,v?c.setAttributeNS(v,u,x):c.setAttribute(u,x))))}var C=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,D=Symbol.for("react.element"),T=Symbol.for("react.portal"),R=Symbol.for("react.fragment"),$=Symbol.for("react.strict_mode"),_=Symbol.for("react.profiler"),U=Symbol.for("react.provider"),I=Symbol.for("react.context"),F=Symbol.for("react.forward_ref"),M=Symbol.for("react.suspense"),A=Symbol.for("react.suspense_list"),L=Symbol.for("react.memo"),z=Symbol.for("react.lazy"),W=Symbol.for("react.offscreen"),V=Symbol.iterator;function K(c){return c===null||typeof c!="object"?null:(c=V&&c[V]||c["@@iterator"],typeof c=="function"?c:null)}var O=Object.assign,B;function G(c){if(B===void 0)try{throw Error()}catch(x){var u=x.stack.trim().match(/\n( *(at )?)/);B=u&&u[1]||""}return`
34
+ `+B+c}var H=!1;function Q(c,u){if(!c||H)return"";H=!0;var x=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(u)if(u=function(){throw Error()},Object.defineProperty(u.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(u,[])}catch(me){var v=me}Reflect.construct(c,[],u)}else{try{u.call()}catch(me){v=me}c.call(u.prototype)}else{try{throw Error()}catch(me){v=me}c()}}catch(me){if(me&&v&&typeof me.stack=="string"){for(var E=me.stack.split(`
35
+ `),P=v.stack.split(`
36
+ `),q=E.length-1,J=P.length-1;1<=q&&0<=J&&E[q]!==P[J];)J--;for(;1<=q&&0<=J;q--,J--)if(E[q]!==P[J]){if(q!==1||J!==1)do if(q--,J--,0>J||E[q]!==P[J]){var re=`
37
+ `+E[q].replace(" at new "," at ");return c.displayName&&re.includes("<anonymous>")&&(re=re.replace("<anonymous>",c.displayName)),re}while(1<=q&&0<=J);break}}}finally{H=!1,Error.prepareStackTrace=x}return(c=c?c.displayName||c.name:"")?G(c):""}function te(c){switch(c.tag){case 5:return G(c.type);case 16:return G("Lazy");case 13:return G("Suspense");case 19:return G("SuspenseList");case 0:case 2:case 15:return c=Q(c.type,!1),c;case 11:return c=Q(c.type.render,!1),c;case 1:return c=Q(c.type,!0),c;default:return""}}function Z(c){if(c==null)return null;if(typeof c=="function")return c.displayName||c.name||null;if(typeof c=="string")return c;switch(c){case R:return"Fragment";case T:return"Portal";case _:return"Profiler";case $:return"StrictMode";case M:return"Suspense";case A:return"SuspenseList"}if(typeof c=="object")switch(c.$$typeof){case I:return(c.displayName||"Context")+".Consumer";case U:return(c._context.displayName||"Context")+".Provider";case F:var u=c.render;return c=c.displayName,c||(c=u.displayName||u.name||"",c=c!==""?"ForwardRef("+c+")":"ForwardRef"),c;case L:return u=c.displayName||null,u!==null?u:Z(c.type)||"Memo";case z:u=c._payload,c=c._init;try{return Z(c(u))}catch{}}return null}function ae(c){var u=c.type;switch(c.tag){case 24:return"Cache";case 9:return(u.displayName||"Context")+".Consumer";case 10:return(u._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return c=u.render,c=c.displayName||c.name||"",u.displayName||(c!==""?"ForwardRef("+c+")":"ForwardRef");case 7:return"Fragment";case 5:return u;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return Z(u);case 8:return u===$?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof u=="function")return u.displayName||u.name||null;if(typeof u=="string")return u}return null}function ne(c){switch(typeof c){case"boolean":case"number":case"string":case"undefined":return c;case"object":return c;default:return""}}function ue(c){var u=c.type;return(c=c.nodeName)&&c.toLowerCase()==="input"&&(u==="checkbox"||u==="radio")}function ye(c){var u=ue(c)?"checked":"value",x=Object.getOwnPropertyDescriptor(c.constructor.prototype,u),v=""+c[u];if(!c.hasOwnProperty(u)&&typeof x<"u"&&typeof x.get=="function"&&typeof x.set=="function"){var E=x.get,P=x.set;return Object.defineProperty(c,u,{configurable:!0,get:function(){return E.call(this)},set:function(q){v=""+q,P.call(this,q)}}),Object.defineProperty(c,u,{enumerable:x.enumerable}),{getValue:function(){return v},setValue:function(q){v=""+q},stopTracking:function(){c._valueTracker=null,delete c[u]}}}}function Ne(c){c._valueTracker||(c._valueTracker=ye(c))}function Re(c){if(!c)return!1;var u=c._valueTracker;if(!u)return!0;var x=u.getValue(),v="";return c&&(v=ue(c)?c.checked?"true":"false":c.value),c=v,c!==x?(u.setValue(c),!0):!1}function Se(c){if(c=c||(typeof document<"u"?document:void 0),typeof c>"u")return null;try{return c.activeElement||c.body}catch{return c.body}}function ze(c,u){var x=u.checked;return O({},u,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:x??c._wrapperState.initialChecked})}function oe(c,u){var x=u.defaultValue==null?"":u.defaultValue,v=u.checked!=null?u.checked:u.defaultChecked;x=ne(u.value!=null?u.value:x),c._wrapperState={initialChecked:v,initialValue:x,controlled:u.type==="checkbox"||u.type==="radio"?u.checked!=null:u.value!=null}}function we(c,u){u=u.checked,u!=null&&S(c,"checked",u,!1)}function ke(c,u){we(c,u);var x=ne(u.value),v=u.type;if(x!=null)v==="number"?(x===0&&c.value===""||c.value!=x)&&(c.value=""+x):c.value!==""+x&&(c.value=""+x);else if(v==="submit"||v==="reset"){c.removeAttribute("value");return}u.hasOwnProperty("value")?Ue(c,u.type,x):u.hasOwnProperty("defaultValue")&&Ue(c,u.type,ne(u.defaultValue)),u.checked==null&&u.defaultChecked!=null&&(c.defaultChecked=!!u.defaultChecked)}function $e(c,u,x){if(u.hasOwnProperty("value")||u.hasOwnProperty("defaultValue")){var v=u.type;if(!(v!=="submit"&&v!=="reset"||u.value!==void 0&&u.value!==null))return;u=""+c._wrapperState.initialValue,x||u===c.value||(c.value=u),c.defaultValue=u}x=c.name,x!==""&&(c.name=""),c.defaultChecked=!!c._wrapperState.initialChecked,x!==""&&(c.name=x)}function Ue(c,u,x){(u!=="number"||Se(c.ownerDocument)!==c)&&(x==null?c.defaultValue=""+c._wrapperState.initialValue:c.defaultValue!==""+x&&(c.defaultValue=""+x))}var nt=Array.isArray;function He(c,u,x,v){if(c=c.options,u){u={};for(var E=0;E<x.length;E++)u["$"+x[E]]=!0;for(x=0;x<c.length;x++)E=u.hasOwnProperty("$"+c[x].value),c[x].selected!==E&&(c[x].selected=E),E&&v&&(c[x].defaultSelected=!0)}else{for(x=""+ne(x),u=null,E=0;E<c.length;E++){if(c[E].value===x){c[E].selected=!0,v&&(c[E].defaultSelected=!0);return}u!==null||c[E].disabled||(u=c[E])}u!==null&&(u.selected=!0)}}function at(c,u){if(u.dangerouslySetInnerHTML!=null)throw Error(n(91));return O({},u,{value:void 0,defaultValue:void 0,children:""+c._wrapperState.initialValue})}function xt(c,u){var x=u.value;if(x==null){if(x=u.children,u=u.defaultValue,x!=null){if(u!=null)throw Error(n(92));if(nt(x)){if(1<x.length)throw Error(n(93));x=x[0]}u=x}u==null&&(u=""),x=u}c._wrapperState={initialValue:ne(x)}}function lt(c,u){var x=ne(u.value),v=ne(u.defaultValue);x!=null&&(x=""+x,x!==c.value&&(c.value=x),u.defaultValue==null&&c.defaultValue!==x&&(c.defaultValue=x)),v!=null&&(c.defaultValue=""+v)}function ot(c){var u=c.textContent;u===c._wrapperState.initialValue&&u!==""&&u!==null&&(c.value=u)}function le(c){switch(c){case"svg":return"http://www.w3.org/2000/svg";case"math":return"http://www.w3.org/1998/Math/MathML";default:return"http://www.w3.org/1999/xhtml"}}function xe(c,u){return c==null||c==="http://www.w3.org/1999/xhtml"?le(u):c==="http://www.w3.org/2000/svg"&&u==="foreignObject"?"http://www.w3.org/1999/xhtml":c}var Oe,We=(function(c){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(u,x,v,E){MSApp.execUnsafeLocalFunction(function(){return c(u,x,v,E)})}:c})(function(c,u){if(c.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in c)c.innerHTML=u;else{for(Oe=Oe||document.createElement("div"),Oe.innerHTML="<svg>"+u.valueOf().toString()+"</svg>",u=Oe.firstChild;c.firstChild;)c.removeChild(c.firstChild);for(;u.firstChild;)c.appendChild(u.firstChild)}});function Ge(c,u){if(u){var x=c.firstChild;if(x&&x===c.lastChild&&x.nodeType===3){x.nodeValue=u;return}}c.textContent=u}var ge={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},pe=["Webkit","ms","Moz","O"];Object.keys(ge).forEach(function(c){pe.forEach(function(u){u=u+c.charAt(0).toUpperCase()+c.substring(1),ge[u]=ge[c]})});function se(c,u,x){return u==null||typeof u=="boolean"||u===""?"":x||typeof u!="number"||u===0||ge.hasOwnProperty(c)&&ge[c]?(""+u).trim():u+"px"}function je(c,u){c=c.style;for(var x in u)if(u.hasOwnProperty(x)){var v=x.indexOf("--")===0,E=se(x,u[x],v);x==="float"&&(x="cssFloat"),v?c.setProperty(x,E):c[x]=E}}var Ae=O({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function qe(c,u){if(u){if(Ae[c]&&(u.children!=null||u.dangerouslySetInnerHTML!=null))throw Error(n(137,c));if(u.dangerouslySetInnerHTML!=null){if(u.children!=null)throw Error(n(60));if(typeof u.dangerouslySetInnerHTML!="object"||!("__html"in u.dangerouslySetInnerHTML))throw Error(n(61))}if(u.style!=null&&typeof u.style!="object")throw Error(n(62))}}function X(c,u){if(c.indexOf("-")===-1)return typeof u.is=="string";switch(c){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var ve=null;function Ve(c){return c=c.target||c.srcElement||window,c.correspondingUseElement&&(c=c.correspondingUseElement),c.nodeType===3?c.parentNode:c}var ft=null,et=null,yt=null;function mt(c){if(c=Kc(c)){if(typeof ft!="function")throw Error(n(280));var u=c.stateNode;u&&(u=uf(u),ft(c.stateNode,c.type,u))}}function he(c){et?yt?yt.push(c):yt=[c]:et=c}function Ee(){if(et){var c=et,u=yt;if(yt=et=null,mt(c),u)for(c=0;c<u.length;c++)mt(u[c])}}function Ye(c,u){return c(u)}function Nt(){}var Mt=!1;function Nn(c,u,x){if(Mt)return c(u,x);Mt=!0;try{return Ye(c,u,x)}finally{Mt=!1,(et!==null||yt!==null)&&(Nt(),Ee())}}function Ct(c,u){var x=c.stateNode;if(x===null)return null;var v=uf(x);if(v===null)return null;x=v[u];e:switch(u){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(v=!v.disabled)||(c=c.type,v=!(c==="button"||c==="input"||c==="select"||c==="textarea")),c=!v;break e;default:c=!1}if(c)return null;if(x&&typeof x!="function")throw Error(n(231,u,typeof x));return x}var Cn=!1;if(l)try{var Ft={};Object.defineProperty(Ft,"passive",{get:function(){Cn=!0}}),window.addEventListener("test",Ft,Ft),window.removeEventListener("test",Ft,Ft)}catch{Cn=!1}function En(c,u,x,v,E,P,q,J,re){var me=Array.prototype.slice.call(arguments,3);try{u.apply(x,me)}catch(_e){this.onError(_e)}}var en=!1,ce=null,Te=!1,st=null,Tn={onError:function(c){en=!0,ce=c}};function kr(c,u,x,v,E,P,q,J,re){en=!1,ce=null,En.apply(Tn,arguments)}function no(c,u,x,v,E,P,q,J,re){if(kr.apply(this,arguments),en){if(en){var me=ce;en=!1,ce=null}else throw Error(n(198));Te||(Te=!0,st=me)}}function bt(c){var u=c,x=c;if(c.alternate)for(;u.return;)u=u.return;else{c=u;do u=c,(u.flags&4098)!==0&&(x=u.return),c=u.return;while(c)}return u.tag===3?x:null}function Ai(c){if(c.tag===13){var u=c.memoizedState;if(u===null&&(c=c.alternate,c!==null&&(u=c.memoizedState)),u!==null)return u.dehydrated}return null}function _o(c){if(bt(c)!==c)throw Error(n(188))}function Pa(c){var u=c.alternate;if(!u){if(u=bt(c),u===null)throw Error(n(188));return u!==c?null:c}for(var x=c,v=u;;){var E=x.return;if(E===null)break;var P=E.alternate;if(P===null){if(v=E.return,v!==null){x=v;continue}break}if(E.child===P.child){for(P=E.child;P;){if(P===x)return _o(E),c;if(P===v)return _o(E),u;P=P.sibling}throw Error(n(188))}if(x.return!==v.return)x=E,v=P;else{for(var q=!1,J=E.child;J;){if(J===x){q=!0,x=E,v=P;break}if(J===v){q=!0,v=E,x=P;break}J=J.sibling}if(!q){for(J=P.child;J;){if(J===x){q=!0,x=P,v=E;break}if(J===v){q=!0,v=P,x=E;break}J=J.sibling}if(!q)throw Error(n(189))}}if(x.alternate!==v)throw Error(n(190))}if(x.tag!==3)throw Error(n(188));return x.stateNode.current===x?c:u}function tn(c){return c=Pa(c),c!==null?Do(c):null}function Do(c){if(c.tag===5||c.tag===6)return c;for(c=c.child;c!==null;){var u=Do(c);if(u!==null)return u;c=c.sibling}return null}var _a=t.unstable_scheduleCallback,Da=t.unstable_cancelCallback,Ac=t.unstable_shouldYield,$a=t.unstable_requestPaint,Bt=t.unstable_now,Pi=t.unstable_getCurrentPriorityLevel,ro=t.unstable_ImmediatePriority,$o=t.unstable_UserBlockingPriority,As=t.unstable_NormalPriority,Io=t.unstable_LowPriority,Ia=t.unstable_IdlePriority,Mo=null,nr=null;function ar(c){if(nr&&typeof nr.onCommitFiberRoot=="function")try{nr.onCommitFiberRoot(Mo,c,void 0,(c.current.flags&128)===128)}catch{}}var On=Math.clz32?Math.clz32:_c,Lo=Math.log,Pc=Math.LN2;function _c(c){return c>>>=0,c===0?32:31-(Lo(c)/Pc|0)|0}var Oo=64,Vn=4194304;function so(c){switch(c&-c){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return c&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return c&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return c}}function Vr(c,u){var x=c.pendingLanes;if(x===0)return 0;var v=0,E=c.suspendedLanes,P=c.pingedLanes,q=x&268435455;if(q!==0){var J=q&~E;J!==0?v=so(J):(P&=q,P!==0&&(v=so(P)))}else q=x&~E,q!==0?v=so(q):P!==0&&(v=so(P));if(v===0)return 0;if(u!==0&&u!==v&&(u&E)===0&&(E=v&-v,P=u&-u,E>=P||E===16&&(P&4194240)!==0))return u;if((v&4)!==0&&(v|=x&16),u=c.entangledLanes,u!==0)for(c=c.entanglements,u&=v;0<u;)x=31-On(u),E=1<<x,v|=c[x],u&=~E;return v}function Ma(c,u){switch(c){case 1:case 2:case 4:return u+250;case 8:case 16:case 32:case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return u+5e3;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return-1;case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function _i(c,u){for(var x=c.suspendedLanes,v=c.pingedLanes,E=c.expirationTimes,P=c.pendingLanes;0<P;){var q=31-On(P),J=1<<q,re=E[q];re===-1?((J&x)===0||(J&v)!==0)&&(E[q]=Ma(J,u)):re<=u&&(c.expiredLanes|=J),P&=~J}}function Fo(c){return c=c.pendingLanes&-1073741825,c!==0?c:c&1073741824?1073741824:0}function zo(){var c=Oo;return Oo<<=1,(Oo&4194240)===0&&(Oo=64),c}function Ps(c){for(var u=[],x=0;31>x;x++)u.push(c);return u}function zt(c,u,x){c.pendingLanes|=u,u!==536870912&&(c.suspendedLanes=0,c.pingedLanes=0),c=c.eventTimes,u=31-On(u),c[u]=x}function oo(c,u){var x=c.pendingLanes&~u;c.pendingLanes=u,c.suspendedLanes=0,c.pingedLanes=0,c.expiredLanes&=u,c.mutableReadLanes&=u,c.entangledLanes&=u,u=c.entanglements;var v=c.eventTimes;for(c=c.expirationTimes;0<x;){var E=31-On(x),P=1<<E;u[E]=0,v[E]=-1,c[E]=-1,x&=~P}}function _s(c,u){var x=c.entangledLanes|=u;for(c=c.entanglements;x;){var v=31-On(x),E=1<<v;E&u|c[v]&u&&(c[v]|=u),x&=~E}}var Lt=0;function Xd(c){return c&=-c,1<c?4<c?(c&268435455)!==0?16:536870912:4:1}var Dc,Di,$c,io,Ic,La=!1,Bo=[],Ds=null,$s=null,dn=null,$i=new Map,ao=new Map,Is=[],og="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset submit".split(" ");function Qd(c,u){switch(c){case"focusin":case"focusout":Ds=null;break;case"dragenter":case"dragleave":$s=null;break;case"mouseover":case"mouseout":dn=null;break;case"pointerover":case"pointerout":$i.delete(u.pointerId);break;case"gotpointercapture":case"lostpointercapture":ao.delete(u.pointerId)}}function Sr(c,u,x,v,E,P){return c===null||c.nativeEvent!==P?(c={blockedOn:u,domEventName:x,eventSystemFlags:v,nativeEvent:P,targetContainers:[E]},u!==null&&(u=Kc(u),u!==null&&Di(u)),c):(c.eventSystemFlags|=v,u=c.targetContainers,E!==null&&u.indexOf(E)===-1&&u.push(E),c)}function Y(c,u,x,v,E){switch(u){case"focusin":return Ds=Sr(Ds,c,u,x,v,E),!0;case"dragenter":return $s=Sr($s,c,u,x,v,E),!0;case"mouseover":return dn=Sr(dn,c,u,x,v,E),!0;case"pointerover":var P=E.pointerId;return $i.set(P,Sr($i.get(P)||null,c,u,x,v,E)),!0;case"gotpointercapture":return P=E.pointerId,ao.set(P,Sr(ao.get(P)||null,c,u,x,v,E)),!0}return!1}function ee(c){var u=Mi(c.target);if(u!==null){var x=bt(u);if(x!==null){if(u=x.tag,u===13){if(u=Ai(x),u!==null){c.blockedOn=u,Ic(c.priority,function(){$c(x)});return}}else if(u===3&&x.stateNode.current.memoizedState.isDehydrated){c.blockedOn=x.tag===3?x.stateNode.containerInfo:null;return}}}c.blockedOn=null}function be(c){if(c.blockedOn!==null)return!1;for(var u=c.targetContainers;0<u.length;){var x=Ho(c.domEventName,c.eventSystemFlags,u[0],c.nativeEvent);if(x===null){x=c.nativeEvent;var v=new x.constructor(x.type,x);ve=v,x.target.dispatchEvent(v),ve=null}else return u=Kc(x),u!==null&&Di(u),c.blockedOn=x,!1;u.shift()}return!0}function Be(c,u,x){be(c)&&x.delete(u)}function gt(){La=!1,Ds!==null&&be(Ds)&&(Ds=null),$s!==null&&be($s)&&($s=null),dn!==null&&be(dn)&&(dn=null),$i.forEach(Be),ao.forEach(Be)}function St(c,u){c.blockedOn===u&&(c.blockedOn=null,La||(La=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,gt)))}function Pt(c){function u(E){return St(E,c)}if(0<Bo.length){St(Bo[0],c);for(var x=1;x<Bo.length;x++){var v=Bo[x];v.blockedOn===c&&(v.blockedOn=null)}}for(Ds!==null&&St(Ds,c),$s!==null&&St($s,c),dn!==null&&St(dn,c),$i.forEach(u),ao.forEach(u),x=0;x<Is.length;x++)v=Is[x],v.blockedOn===c&&(v.blockedOn=null);for(;0<Is.length&&(x=Is[0],x.blockedOn===null);)ee(x),x.blockedOn===null&&Is.shift()}var Rn=C.ReactCurrentBatchConfig,Fn=!0;function An(c,u,x,v){var E=Lt,P=Rn.transition;Rn.transition=null;try{Lt=1,Uo(c,u,x,v)}finally{Lt=E,Rn.transition=P}}function Nr(c,u,x,v){var E=Lt,P=Rn.transition;Rn.transition=null;try{Lt=4,Uo(c,u,x,v)}finally{Lt=E,Rn.transition=P}}function Uo(c,u,x,v){if(Fn){var E=Ho(c,u,x,v);if(E===null)jg(c,u,v,Ii,x),Qd(c,v);else if(Y(E,c,u,x,v))v.stopPropagation();else if(Qd(c,v),u&4&&-1<og.indexOf(c)){for(;E!==null;){var P=Kc(E);if(P!==null&&Dc(P),P=Ho(c,u,x,v),P===null&&jg(c,u,v,Ii,x),P===E)break;E=P}E!==null&&v.stopPropagation()}else jg(c,u,v,null,x)}}var Ii=null;function Ho(c,u,x,v){if(Ii=null,c=Ve(v),c=Mi(c),c!==null)if(u=bt(c),u===null)c=null;else if(x=u.tag,x===13){if(c=Ai(u),c!==null)return c;c=null}else if(x===3){if(u.stateNode.current.memoizedState.isDehydrated)return u.tag===3?u.stateNode.containerInfo:null;c=null}else u!==c&&(c=null);return Ii=c,null}function os(c){switch(c){case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 1;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"toggle":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 4;case"message":switch(Pi()){case ro:return 1;case $o:return 4;case As:case Io:return 16;case Ia:return 536870912;default:return 16}default:return 16}}var Vo=null,ig=null,Jd=null;function M0(){if(Jd)return Jd;var c,u=ig,x=u.length,v,E="value"in Vo?Vo.value:Vo.textContent,P=E.length;for(c=0;c<x&&u[c]===E[c];c++);var q=x-c;for(v=1;v<=q&&u[x-v]===E[P-v];v++);return Jd=E.slice(c,1<v?1-v:void 0)}function Zd(c){var u=c.keyCode;return"charCode"in c?(c=c.charCode,c===0&&u===13&&(c=13)):c=u,c===10&&(c=13),32<=c||c===13?c:0}function ef(){return!0}function L0(){return!1}function Cr(c){function u(x,v,E,P,q){this._reactName=x,this._targetInst=E,this.type=v,this.nativeEvent=P,this.target=q,this.currentTarget=null;for(var J in c)c.hasOwnProperty(J)&&(x=c[J],this[J]=x?x(P):P[J]);return this.isDefaultPrevented=(P.defaultPrevented!=null?P.defaultPrevented:P.returnValue===!1)?ef:L0,this.isPropagationStopped=L0,this}return O(u.prototype,{preventDefault:function(){this.defaultPrevented=!0;var x=this.nativeEvent;x&&(x.preventDefault?x.preventDefault():typeof x.returnValue!="unknown"&&(x.returnValue=!1),this.isDefaultPrevented=ef)},stopPropagation:function(){var x=this.nativeEvent;x&&(x.stopPropagation?x.stopPropagation():typeof x.cancelBubble!="unknown"&&(x.cancelBubble=!0),this.isPropagationStopped=ef)},persist:function(){},isPersistent:ef}),u}var Oa={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(c){return c.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},ag=Cr(Oa),Mc=O({},Oa,{view:0,detail:0}),e$=Cr(Mc),lg,cg,Lc,tf=O({},Mc,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:dg,button:0,buttons:0,relatedTarget:function(c){return c.relatedTarget===void 0?c.fromElement===c.srcElement?c.toElement:c.fromElement:c.relatedTarget},movementX:function(c){return"movementX"in c?c.movementX:(c!==Lc&&(Lc&&c.type==="mousemove"?(lg=c.screenX-Lc.screenX,cg=c.screenY-Lc.screenY):cg=lg=0,Lc=c),lg)},movementY:function(c){return"movementY"in c?c.movementY:cg}}),O0=Cr(tf),t$=O({},tf,{dataTransfer:0}),n$=Cr(t$),r$=O({},Mc,{relatedTarget:0}),ug=Cr(r$),s$=O({},Oa,{animationName:0,elapsedTime:0,pseudoElement:0}),o$=Cr(s$),i$=O({},Oa,{clipboardData:function(c){return"clipboardData"in c?c.clipboardData:window.clipboardData}}),a$=Cr(i$),l$=O({},Oa,{data:0}),F0=Cr(l$),c$={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},u$={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},d$={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function f$(c){var u=this.nativeEvent;return u.getModifierState?u.getModifierState(c):(c=d$[c])?!!u[c]:!1}function dg(){return f$}var p$=O({},Mc,{key:function(c){if(c.key){var u=c$[c.key]||c.key;if(u!=="Unidentified")return u}return c.type==="keypress"?(c=Zd(c),c===13?"Enter":String.fromCharCode(c)):c.type==="keydown"||c.type==="keyup"?u$[c.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:dg,charCode:function(c){return c.type==="keypress"?Zd(c):0},keyCode:function(c){return c.type==="keydown"||c.type==="keyup"?c.keyCode:0},which:function(c){return c.type==="keypress"?Zd(c):c.type==="keydown"||c.type==="keyup"?c.keyCode:0}}),h$=Cr(p$),m$=O({},tf,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),z0=Cr(m$),g$=O({},Mc,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:dg}),x$=Cr(g$),y$=O({},Oa,{propertyName:0,elapsedTime:0,pseudoElement:0}),b$=Cr(y$),v$=O({},tf,{deltaX:function(c){return"deltaX"in c?c.deltaX:"wheelDeltaX"in c?-c.wheelDeltaX:0},deltaY:function(c){return"deltaY"in c?c.deltaY:"wheelDeltaY"in c?-c.wheelDeltaY:"wheelDelta"in c?-c.wheelDelta:0},deltaZ:0,deltaMode:0}),w$=Cr(v$),j$=[9,13,27,32],fg=l&&"CompositionEvent"in window,Oc=null;l&&"documentMode"in document&&(Oc=document.documentMode);var k$=l&&"TextEvent"in window&&!Oc,B0=l&&(!fg||Oc&&8<Oc&&11>=Oc),U0=" ",H0=!1;function V0(c,u){switch(c){case"keyup":return j$.indexOf(u.keyCode)!==-1;case"keydown":return u.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function W0(c){return c=c.detail,typeof c=="object"&&"data"in c?c.data:null}var Fa=!1;function S$(c,u){switch(c){case"compositionend":return W0(u);case"keypress":return u.which!==32?null:(H0=!0,U0);case"textInput":return c=u.data,c===U0&&H0?null:c;default:return null}}function N$(c,u){if(Fa)return c==="compositionend"||!fg&&V0(c,u)?(c=M0(),Jd=ig=Vo=null,Fa=!1,c):null;switch(c){case"paste":return null;case"keypress":if(!(u.ctrlKey||u.altKey||u.metaKey)||u.ctrlKey&&u.altKey){if(u.char&&1<u.char.length)return u.char;if(u.which)return String.fromCharCode(u.which)}return null;case"compositionend":return B0&&u.locale!=="ko"?null:u.data;default:return null}}var C$={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function q0(c){var u=c&&c.nodeName&&c.nodeName.toLowerCase();return u==="input"?!!C$[c.type]:u==="textarea"}function K0(c,u,x,v){he(v),u=af(u,"onChange"),0<u.length&&(x=new ag("onChange","change",null,x,v),c.push({event:x,listeners:u}))}var Fc=null,zc=null;function E$(c){dj(c,0)}function nf(c){var u=Va(c);if(Re(u))return c}function T$(c,u){if(c==="change")return u}var G0=!1;if(l){var pg;if(l){var hg="oninput"in document;if(!hg){var Y0=document.createElement("div");Y0.setAttribute("oninput","return;"),hg=typeof Y0.oninput=="function"}pg=hg}else pg=!1;G0=pg&&(!document.documentMode||9<document.documentMode)}function X0(){Fc&&(Fc.detachEvent("onpropertychange",Q0),zc=Fc=null)}function Q0(c){if(c.propertyName==="value"&&nf(zc)){var u=[];K0(u,zc,c,Ve(c)),Nn(E$,u)}}function R$(c,u,x){c==="focusin"?(X0(),Fc=u,zc=x,Fc.attachEvent("onpropertychange",Q0)):c==="focusout"&&X0()}function A$(c){if(c==="selectionchange"||c==="keyup"||c==="keydown")return nf(zc)}function P$(c,u){if(c==="click")return nf(u)}function _$(c,u){if(c==="input"||c==="change")return nf(u)}function D$(c,u){return c===u&&(c!==0||1/c===1/u)||c!==c&&u!==u}var is=typeof Object.is=="function"?Object.is:D$;function Bc(c,u){if(is(c,u))return!0;if(typeof c!="object"||c===null||typeof u!="object"||u===null)return!1;var x=Object.keys(c),v=Object.keys(u);if(x.length!==v.length)return!1;for(v=0;v<x.length;v++){var E=x[v];if(!d.call(u,E)||!is(c[E],u[E]))return!1}return!0}function J0(c){for(;c&&c.firstChild;)c=c.firstChild;return c}function Z0(c,u){var x=J0(c);c=0;for(var v;x;){if(x.nodeType===3){if(v=c+x.textContent.length,c<=u&&v>=u)return{node:x,offset:u-c};c=v}e:{for(;x;){if(x.nextSibling){x=x.nextSibling;break e}x=x.parentNode}x=void 0}x=J0(x)}}function ej(c,u){return c&&u?c===u?!0:c&&c.nodeType===3?!1:u&&u.nodeType===3?ej(c,u.parentNode):"contains"in c?c.contains(u):c.compareDocumentPosition?!!(c.compareDocumentPosition(u)&16):!1:!1}function tj(){for(var c=window,u=Se();u instanceof c.HTMLIFrameElement;){try{var x=typeof u.contentWindow.location.href=="string"}catch{x=!1}if(x)c=u.contentWindow;else break;u=Se(c.document)}return u}function mg(c){var u=c&&c.nodeName&&c.nodeName.toLowerCase();return u&&(u==="input"&&(c.type==="text"||c.type==="search"||c.type==="tel"||c.type==="url"||c.type==="password")||u==="textarea"||c.contentEditable==="true")}function $$(c){var u=tj(),x=c.focusedElem,v=c.selectionRange;if(u!==x&&x&&x.ownerDocument&&ej(x.ownerDocument.documentElement,x)){if(v!==null&&mg(x)){if(u=v.start,c=v.end,c===void 0&&(c=u),"selectionStart"in x)x.selectionStart=u,x.selectionEnd=Math.min(c,x.value.length);else if(c=(u=x.ownerDocument||document)&&u.defaultView||window,c.getSelection){c=c.getSelection();var E=x.textContent.length,P=Math.min(v.start,E);v=v.end===void 0?P:Math.min(v.end,E),!c.extend&&P>v&&(E=v,v=P,P=E),E=Z0(x,P);var q=Z0(x,v);E&&q&&(c.rangeCount!==1||c.anchorNode!==E.node||c.anchorOffset!==E.offset||c.focusNode!==q.node||c.focusOffset!==q.offset)&&(u=u.createRange(),u.setStart(E.node,E.offset),c.removeAllRanges(),P>v?(c.addRange(u),c.extend(q.node,q.offset)):(u.setEnd(q.node,q.offset),c.addRange(u)))}}for(u=[],c=x;c=c.parentNode;)c.nodeType===1&&u.push({element:c,left:c.scrollLeft,top:c.scrollTop});for(typeof x.focus=="function"&&x.focus(),x=0;x<u.length;x++)c=u[x],c.element.scrollLeft=c.left,c.element.scrollTop=c.top}}var I$=l&&"documentMode"in document&&11>=document.documentMode,za=null,gg=null,Uc=null,xg=!1;function nj(c,u,x){var v=x.window===x?x.document:x.nodeType===9?x:x.ownerDocument;xg||za==null||za!==Se(v)||(v=za,"selectionStart"in v&&mg(v)?v={start:v.selectionStart,end:v.selectionEnd}:(v=(v.ownerDocument&&v.ownerDocument.defaultView||window).getSelection(),v={anchorNode:v.anchorNode,anchorOffset:v.anchorOffset,focusNode:v.focusNode,focusOffset:v.focusOffset}),Uc&&Bc(Uc,v)||(Uc=v,v=af(gg,"onSelect"),0<v.length&&(u=new ag("onSelect","select",null,u,x),c.push({event:u,listeners:v}),u.target=za)))}function rf(c,u){var x={};return x[c.toLowerCase()]=u.toLowerCase(),x["Webkit"+c]="webkit"+u,x["Moz"+c]="moz"+u,x}var Ba={animationend:rf("Animation","AnimationEnd"),animationiteration:rf("Animation","AnimationIteration"),animationstart:rf("Animation","AnimationStart"),transitionend:rf("Transition","TransitionEnd")},yg={},rj={};l&&(rj=document.createElement("div").style,"AnimationEvent"in window||(delete Ba.animationend.animation,delete Ba.animationiteration.animation,delete Ba.animationstart.animation),"TransitionEvent"in window||delete Ba.transitionend.transition);function sf(c){if(yg[c])return yg[c];if(!Ba[c])return c;var u=Ba[c],x;for(x in u)if(u.hasOwnProperty(x)&&x in rj)return yg[c]=u[x];return c}var sj=sf("animationend"),oj=sf("animationiteration"),ij=sf("animationstart"),aj=sf("transitionend"),lj=new Map,cj="abort auxClick cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");function Wo(c,u){lj.set(c,u),i(u,[c])}for(var bg=0;bg<cj.length;bg++){var vg=cj[bg],M$=vg.toLowerCase(),L$=vg[0].toUpperCase()+vg.slice(1);Wo(M$,"on"+L$)}Wo(sj,"onAnimationEnd"),Wo(oj,"onAnimationIteration"),Wo(ij,"onAnimationStart"),Wo("dblclick","onDoubleClick"),Wo("focusin","onFocus"),Wo("focusout","onBlur"),Wo(aj,"onTransitionEnd"),a("onMouseEnter",["mouseout","mouseover"]),a("onMouseLeave",["mouseout","mouseover"]),a("onPointerEnter",["pointerout","pointerover"]),a("onPointerLeave",["pointerout","pointerover"]),i("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),i("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),i("onBeforeInput",["compositionend","keypress","textInput","paste"]),i("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),i("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),i("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Hc="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),O$=new Set("cancel close invalid load scroll toggle".split(" ").concat(Hc));function uj(c,u,x){var v=c.type||"unknown-event";c.currentTarget=x,no(v,u,void 0,c),c.currentTarget=null}function dj(c,u){u=(u&4)!==0;for(var x=0;x<c.length;x++){var v=c[x],E=v.event;v=v.listeners;e:{var P=void 0;if(u)for(var q=v.length-1;0<=q;q--){var J=v[q],re=J.instance,me=J.currentTarget;if(J=J.listener,re!==P&&E.isPropagationStopped())break e;uj(E,J,me),P=re}else for(q=0;q<v.length;q++){if(J=v[q],re=J.instance,me=J.currentTarget,J=J.listener,re!==P&&E.isPropagationStopped())break e;uj(E,J,me),P=re}}}if(Te)throw c=st,Te=!1,st=null,c}function Gt(c,u){var x=u[Tg];x===void 0&&(x=u[Tg]=new Set);var v=c+"__bubble";x.has(v)||(fj(u,c,2,!1),x.add(v))}function wg(c,u,x){var v=0;u&&(v|=4),fj(x,c,v,u)}var of="_reactListening"+Math.random().toString(36).slice(2);function Vc(c){if(!c[of]){c[of]=!0,r.forEach(function(x){x!=="selectionchange"&&(O$.has(x)||wg(x,!1,c),wg(x,!0,c))});var u=c.nodeType===9?c:c.ownerDocument;u===null||u[of]||(u[of]=!0,wg("selectionchange",!1,u))}}function fj(c,u,x,v){switch(os(u)){case 1:var E=An;break;case 4:E=Nr;break;default:E=Uo}x=E.bind(null,u,x,c),E=void 0,!Cn||u!=="touchstart"&&u!=="touchmove"&&u!=="wheel"||(E=!0),v?E!==void 0?c.addEventListener(u,x,{capture:!0,passive:E}):c.addEventListener(u,x,!0):E!==void 0?c.addEventListener(u,x,{passive:E}):c.addEventListener(u,x,!1)}function jg(c,u,x,v,E){var P=v;if((u&1)===0&&(u&2)===0&&v!==null)e:for(;;){if(v===null)return;var q=v.tag;if(q===3||q===4){var J=v.stateNode.containerInfo;if(J===E||J.nodeType===8&&J.parentNode===E)break;if(q===4)for(q=v.return;q!==null;){var re=q.tag;if((re===3||re===4)&&(re=q.stateNode.containerInfo,re===E||re.nodeType===8&&re.parentNode===E))return;q=q.return}for(;J!==null;){if(q=Mi(J),q===null)return;if(re=q.tag,re===5||re===6){v=P=q;continue e}J=J.parentNode}}v=v.return}Nn(function(){var me=P,_e=Ve(x),De=[];e:{var Pe=lj.get(c);if(Pe!==void 0){var Xe=ag,tt=c;switch(c){case"keypress":if(Zd(x)===0)break e;case"keydown":case"keyup":Xe=h$;break;case"focusin":tt="focus",Xe=ug;break;case"focusout":tt="blur",Xe=ug;break;case"beforeblur":case"afterblur":Xe=ug;break;case"click":if(x.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":Xe=O0;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":Xe=n$;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":Xe=x$;break;case sj:case oj:case ij:Xe=o$;break;case aj:Xe=b$;break;case"scroll":Xe=e$;break;case"wheel":Xe=w$;break;case"copy":case"cut":case"paste":Xe=a$;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":Xe=z0}var rt=(u&4)!==0,fn=!rt&&c==="scroll",de=rt?Pe!==null?Pe+"Capture":null:Pe;rt=[];for(var ie=me,fe;ie!==null;){fe=ie;var Fe=fe.stateNode;if(fe.tag===5&&Fe!==null&&(fe=Fe,de!==null&&(Fe=Ct(ie,de),Fe!=null&&rt.push(Wc(ie,Fe,fe)))),fn)break;ie=ie.return}0<rt.length&&(Pe=new Xe(Pe,tt,null,x,_e),De.push({event:Pe,listeners:rt}))}}if((u&7)===0){e:{if(Pe=c==="mouseover"||c==="pointerover",Xe=c==="mouseout"||c==="pointerout",Pe&&x!==ve&&(tt=x.relatedTarget||x.fromElement)&&(Mi(tt)||tt[lo]))break e;if((Xe||Pe)&&(Pe=_e.window===_e?_e:(Pe=_e.ownerDocument)?Pe.defaultView||Pe.parentWindow:window,Xe?(tt=x.relatedTarget||x.toElement,Xe=me,tt=tt?Mi(tt):null,tt!==null&&(fn=bt(tt),tt!==fn||tt.tag!==5&&tt.tag!==6)&&(tt=null)):(Xe=null,tt=me),Xe!==tt)){if(rt=O0,Fe="onMouseLeave",de="onMouseEnter",ie="mouse",(c==="pointerout"||c==="pointerover")&&(rt=z0,Fe="onPointerLeave",de="onPointerEnter",ie="pointer"),fn=Xe==null?Pe:Va(Xe),fe=tt==null?Pe:Va(tt),Pe=new rt(Fe,ie+"leave",Xe,x,_e),Pe.target=fn,Pe.relatedTarget=fe,Fe=null,Mi(_e)===me&&(rt=new rt(de,ie+"enter",tt,x,_e),rt.target=fe,rt.relatedTarget=fn,Fe=rt),fn=Fe,Xe&&tt)t:{for(rt=Xe,de=tt,ie=0,fe=rt;fe;fe=Ua(fe))ie++;for(fe=0,Fe=de;Fe;Fe=Ua(Fe))fe++;for(;0<ie-fe;)rt=Ua(rt),ie--;for(;0<fe-ie;)de=Ua(de),fe--;for(;ie--;){if(rt===de||de!==null&&rt===de.alternate)break t;rt=Ua(rt),de=Ua(de)}rt=null}else rt=null;Xe!==null&&pj(De,Pe,Xe,rt,!1),tt!==null&&fn!==null&&pj(De,fn,tt,rt,!0)}}e:{if(Pe=me?Va(me):window,Xe=Pe.nodeName&&Pe.nodeName.toLowerCase(),Xe==="select"||Xe==="input"&&Pe.type==="file")var it=T$;else if(q0(Pe))if(G0)it=_$;else{it=A$;var ut=R$}else(Xe=Pe.nodeName)&&Xe.toLowerCase()==="input"&&(Pe.type==="checkbox"||Pe.type==="radio")&&(it=P$);if(it&&(it=it(c,me))){K0(De,it,x,_e);break e}ut&&ut(c,Pe,me),c==="focusout"&&(ut=Pe._wrapperState)&&ut.controlled&&Pe.type==="number"&&Ue(Pe,"number",Pe.value)}switch(ut=me?Va(me):window,c){case"focusin":(q0(ut)||ut.contentEditable==="true")&&(za=ut,gg=me,Uc=null);break;case"focusout":Uc=gg=za=null;break;case"mousedown":xg=!0;break;case"contextmenu":case"mouseup":case"dragend":xg=!1,nj(De,x,_e);break;case"selectionchange":if(I$)break;case"keydown":case"keyup":nj(De,x,_e)}var dt;if(fg)e:{switch(c){case"compositionstart":var pt="onCompositionStart";break e;case"compositionend":pt="onCompositionEnd";break e;case"compositionupdate":pt="onCompositionUpdate";break e}pt=void 0}else Fa?V0(c,x)&&(pt="onCompositionEnd"):c==="keydown"&&x.keyCode===229&&(pt="onCompositionStart");pt&&(B0&&x.locale!=="ko"&&(Fa||pt!=="onCompositionStart"?pt==="onCompositionEnd"&&Fa&&(dt=M0()):(Vo=_e,ig="value"in Vo?Vo.value:Vo.textContent,Fa=!0)),ut=af(me,pt),0<ut.length&&(pt=new F0(pt,c,null,x,_e),De.push({event:pt,listeners:ut}),dt?pt.data=dt:(dt=W0(x),dt!==null&&(pt.data=dt)))),(dt=k$?S$(c,x):N$(c,x))&&(me=af(me,"onBeforeInput"),0<me.length&&(_e=new F0("onBeforeInput","beforeinput",null,x,_e),De.push({event:_e,listeners:me}),_e.data=dt))}dj(De,u)})}function Wc(c,u,x){return{instance:c,listener:u,currentTarget:x}}function af(c,u){for(var x=u+"Capture",v=[];c!==null;){var E=c,P=E.stateNode;E.tag===5&&P!==null&&(E=P,P=Ct(c,x),P!=null&&v.unshift(Wc(c,P,E)),P=Ct(c,u),P!=null&&v.push(Wc(c,P,E))),c=c.return}return v}function Ua(c){if(c===null)return null;do c=c.return;while(c&&c.tag!==5);return c||null}function pj(c,u,x,v,E){for(var P=u._reactName,q=[];x!==null&&x!==v;){var J=x,re=J.alternate,me=J.stateNode;if(re!==null&&re===v)break;J.tag===5&&me!==null&&(J=me,E?(re=Ct(x,P),re!=null&&q.unshift(Wc(x,re,J))):E||(re=Ct(x,P),re!=null&&q.push(Wc(x,re,J)))),x=x.return}q.length!==0&&c.push({event:u,listeners:q})}var F$=/\r\n?/g,z$=/\u0000|\uFFFD/g;function hj(c){return(typeof c=="string"?c:""+c).replace(F$,`
38
+ `).replace(z$,"")}function lf(c,u,x){if(u=hj(u),hj(c)!==u&&x)throw Error(n(425))}function cf(){}var kg=null,Sg=null;function Ng(c,u){return c==="textarea"||c==="noscript"||typeof u.children=="string"||typeof u.children=="number"||typeof u.dangerouslySetInnerHTML=="object"&&u.dangerouslySetInnerHTML!==null&&u.dangerouslySetInnerHTML.__html!=null}var Cg=typeof setTimeout=="function"?setTimeout:void 0,B$=typeof clearTimeout=="function"?clearTimeout:void 0,mj=typeof Promise=="function"?Promise:void 0,U$=typeof queueMicrotask=="function"?queueMicrotask:typeof mj<"u"?function(c){return mj.resolve(null).then(c).catch(H$)}:Cg;function H$(c){setTimeout(function(){throw c})}function Eg(c,u){var x=u,v=0;do{var E=x.nextSibling;if(c.removeChild(x),E&&E.nodeType===8)if(x=E.data,x==="/$"){if(v===0){c.removeChild(E),Pt(u);return}v--}else x!=="$"&&x!=="$?"&&x!=="$!"||v++;x=E}while(x);Pt(u)}function qo(c){for(;c!=null;c=c.nextSibling){var u=c.nodeType;if(u===1||u===3)break;if(u===8){if(u=c.data,u==="$"||u==="$!"||u==="$?")break;if(u==="/$")return null}}return c}function gj(c){c=c.previousSibling;for(var u=0;c;){if(c.nodeType===8){var x=c.data;if(x==="$"||x==="$!"||x==="$?"){if(u===0)return c;u--}else x==="/$"&&u++}c=c.previousSibling}return null}var Ha=Math.random().toString(36).slice(2),Ms="__reactFiber$"+Ha,qc="__reactProps$"+Ha,lo="__reactContainer$"+Ha,Tg="__reactEvents$"+Ha,V$="__reactListeners$"+Ha,W$="__reactHandles$"+Ha;function Mi(c){var u=c[Ms];if(u)return u;for(var x=c.parentNode;x;){if(u=x[lo]||x[Ms]){if(x=u.alternate,u.child!==null||x!==null&&x.child!==null)for(c=gj(c);c!==null;){if(x=c[Ms])return x;c=gj(c)}return u}c=x,x=c.parentNode}return null}function Kc(c){return c=c[Ms]||c[lo],!c||c.tag!==5&&c.tag!==6&&c.tag!==13&&c.tag!==3?null:c}function Va(c){if(c.tag===5||c.tag===6)return c.stateNode;throw Error(n(33))}function uf(c){return c[qc]||null}var Rg=[],Wa=-1;function Ko(c){return{current:c}}function Yt(c){0>Wa||(c.current=Rg[Wa],Rg[Wa]=null,Wa--)}function Wt(c,u){Wa++,Rg[Wa]=c.current,c.current=u}var Go={},Yn=Ko(Go),lr=Ko(!1),Li=Go;function qa(c,u){var x=c.type.contextTypes;if(!x)return Go;var v=c.stateNode;if(v&&v.__reactInternalMemoizedUnmaskedChildContext===u)return v.__reactInternalMemoizedMaskedChildContext;var E={},P;for(P in x)E[P]=u[P];return v&&(c=c.stateNode,c.__reactInternalMemoizedUnmaskedChildContext=u,c.__reactInternalMemoizedMaskedChildContext=E),E}function cr(c){return c=c.childContextTypes,c!=null}function df(){Yt(lr),Yt(Yn)}function xj(c,u,x){if(Yn.current!==Go)throw Error(n(168));Wt(Yn,u),Wt(lr,x)}function yj(c,u,x){var v=c.stateNode;if(u=u.childContextTypes,typeof v.getChildContext!="function")return x;v=v.getChildContext();for(var E in v)if(!(E in u))throw Error(n(108,ae(c)||"Unknown",E));return O({},x,v)}function ff(c){return c=(c=c.stateNode)&&c.__reactInternalMemoizedMergedChildContext||Go,Li=Yn.current,Wt(Yn,c),Wt(lr,lr.current),!0}function bj(c,u,x){var v=c.stateNode;if(!v)throw Error(n(169));x?(c=yj(c,u,Li),v.__reactInternalMemoizedMergedChildContext=c,Yt(lr),Yt(Yn),Wt(Yn,c)):Yt(lr),Wt(lr,x)}var co=null,pf=!1,Ag=!1;function vj(c){co===null?co=[c]:co.push(c)}function q$(c){pf=!0,vj(c)}function Yo(){if(!Ag&&co!==null){Ag=!0;var c=0,u=Lt;try{var x=co;for(Lt=1;c<x.length;c++){var v=x[c];do v=v(!0);while(v!==null)}co=null,pf=!1}catch(E){throw co!==null&&(co=co.slice(c+1)),_a(ro,Yo),E}finally{Lt=u,Ag=!1}}return null}var Ka=[],Ga=0,hf=null,mf=0,Wr=[],qr=0,Oi=null,uo=1,fo="";function Fi(c,u){Ka[Ga++]=mf,Ka[Ga++]=hf,hf=c,mf=u}function wj(c,u,x){Wr[qr++]=uo,Wr[qr++]=fo,Wr[qr++]=Oi,Oi=c;var v=uo;c=fo;var E=32-On(v)-1;v&=~(1<<E),x+=1;var P=32-On(u)+E;if(30<P){var q=E-E%5;P=(v&(1<<q)-1).toString(32),v>>=q,E-=q,uo=1<<32-On(u)+E|x<<E|v,fo=P+c}else uo=1<<P|x<<E|v,fo=c}function Pg(c){c.return!==null&&(Fi(c,1),wj(c,1,0))}function _g(c){for(;c===hf;)hf=Ka[--Ga],Ka[Ga]=null,mf=Ka[--Ga],Ka[Ga]=null;for(;c===Oi;)Oi=Wr[--qr],Wr[qr]=null,fo=Wr[--qr],Wr[qr]=null,uo=Wr[--qr],Wr[qr]=null}var Er=null,Tr=null,nn=!1,as=null;function jj(c,u){var x=Xr(5,null,null,0);x.elementType="DELETED",x.stateNode=u,x.return=c,u=c.deletions,u===null?(c.deletions=[x],c.flags|=16):u.push(x)}function kj(c,u){switch(c.tag){case 5:var x=c.type;return u=u.nodeType!==1||x.toLowerCase()!==u.nodeName.toLowerCase()?null:u,u!==null?(c.stateNode=u,Er=c,Tr=qo(u.firstChild),!0):!1;case 6:return u=c.pendingProps===""||u.nodeType!==3?null:u,u!==null?(c.stateNode=u,Er=c,Tr=null,!0):!1;case 13:return u=u.nodeType!==8?null:u,u!==null?(x=Oi!==null?{id:uo,overflow:fo}:null,c.memoizedState={dehydrated:u,treeContext:x,retryLane:1073741824},x=Xr(18,null,null,0),x.stateNode=u,x.return=c,c.child=x,Er=c,Tr=null,!0):!1;default:return!1}}function Dg(c){return(c.mode&1)!==0&&(c.flags&128)===0}function $g(c){if(nn){var u=Tr;if(u){var x=u;if(!kj(c,u)){if(Dg(c))throw Error(n(418));u=qo(x.nextSibling);var v=Er;u&&kj(c,u)?jj(v,x):(c.flags=c.flags&-4097|2,nn=!1,Er=c)}}else{if(Dg(c))throw Error(n(418));c.flags=c.flags&-4097|2,nn=!1,Er=c}}}function Sj(c){for(c=c.return;c!==null&&c.tag!==5&&c.tag!==3&&c.tag!==13;)c=c.return;Er=c}function gf(c){if(c!==Er)return!1;if(!nn)return Sj(c),nn=!0,!1;var u;if((u=c.tag!==3)&&!(u=c.tag!==5)&&(u=c.type,u=u!=="head"&&u!=="body"&&!Ng(c.type,c.memoizedProps)),u&&(u=Tr)){if(Dg(c))throw Nj(),Error(n(418));for(;u;)jj(c,u),u=qo(u.nextSibling)}if(Sj(c),c.tag===13){if(c=c.memoizedState,c=c!==null?c.dehydrated:null,!c)throw Error(n(317));e:{for(c=c.nextSibling,u=0;c;){if(c.nodeType===8){var x=c.data;if(x==="/$"){if(u===0){Tr=qo(c.nextSibling);break e}u--}else x!=="$"&&x!=="$!"&&x!=="$?"||u++}c=c.nextSibling}Tr=null}}else Tr=Er?qo(c.stateNode.nextSibling):null;return!0}function Nj(){for(var c=Tr;c;)c=qo(c.nextSibling)}function Ya(){Tr=Er=null,nn=!1}function Ig(c){as===null?as=[c]:as.push(c)}var K$=C.ReactCurrentBatchConfig;function Gc(c,u,x){if(c=x.ref,c!==null&&typeof c!="function"&&typeof c!="object"){if(x._owner){if(x=x._owner,x){if(x.tag!==1)throw Error(n(309));var v=x.stateNode}if(!v)throw Error(n(147,c));var E=v,P=""+c;return u!==null&&u.ref!==null&&typeof u.ref=="function"&&u.ref._stringRef===P?u.ref:(u=function(q){var J=E.refs;q===null?delete J[P]:J[P]=q},u._stringRef=P,u)}if(typeof c!="string")throw Error(n(284));if(!x._owner)throw Error(n(290,c))}return c}function xf(c,u){throw c=Object.prototype.toString.call(u),Error(n(31,c==="[object Object]"?"object with keys {"+Object.keys(u).join(", ")+"}":c))}function Cj(c){var u=c._init;return u(c._payload)}function Ej(c){function u(de,ie){if(c){var fe=de.deletions;fe===null?(de.deletions=[ie],de.flags|=16):fe.push(ie)}}function x(de,ie){if(!c)return null;for(;ie!==null;)u(de,ie),ie=ie.sibling;return null}function v(de,ie){for(de=new Map;ie!==null;)ie.key!==null?de.set(ie.key,ie):de.set(ie.index,ie),ie=ie.sibling;return de}function E(de,ie){return de=ri(de,ie),de.index=0,de.sibling=null,de}function P(de,ie,fe){return de.index=fe,c?(fe=de.alternate,fe!==null?(fe=fe.index,fe<ie?(de.flags|=2,ie):fe):(de.flags|=2,ie)):(de.flags|=1048576,ie)}function q(de){return c&&de.alternate===null&&(de.flags|=2),de}function J(de,ie,fe,Fe){return ie===null||ie.tag!==6?(ie=Cx(fe,de.mode,Fe),ie.return=de,ie):(ie=E(ie,fe),ie.return=de,ie)}function re(de,ie,fe,Fe){var it=fe.type;return it===R?_e(de,ie,fe.props.children,Fe,fe.key):ie!==null&&(ie.elementType===it||typeof it=="object"&&it!==null&&it.$$typeof===z&&Cj(it)===ie.type)?(Fe=E(ie,fe.props),Fe.ref=Gc(de,ie,fe),Fe.return=de,Fe):(Fe=Bf(fe.type,fe.key,fe.props,null,de.mode,Fe),Fe.ref=Gc(de,ie,fe),Fe.return=de,Fe)}function me(de,ie,fe,Fe){return ie===null||ie.tag!==4||ie.stateNode.containerInfo!==fe.containerInfo||ie.stateNode.implementation!==fe.implementation?(ie=Ex(fe,de.mode,Fe),ie.return=de,ie):(ie=E(ie,fe.children||[]),ie.return=de,ie)}function _e(de,ie,fe,Fe,it){return ie===null||ie.tag!==7?(ie=Ki(fe,de.mode,Fe,it),ie.return=de,ie):(ie=E(ie,fe),ie.return=de,ie)}function De(de,ie,fe){if(typeof ie=="string"&&ie!==""||typeof ie=="number")return ie=Cx(""+ie,de.mode,fe),ie.return=de,ie;if(typeof ie=="object"&&ie!==null){switch(ie.$$typeof){case D:return fe=Bf(ie.type,ie.key,ie.props,null,de.mode,fe),fe.ref=Gc(de,null,ie),fe.return=de,fe;case T:return ie=Ex(ie,de.mode,fe),ie.return=de,ie;case z:var Fe=ie._init;return De(de,Fe(ie._payload),fe)}if(nt(ie)||K(ie))return ie=Ki(ie,de.mode,fe,null),ie.return=de,ie;xf(de,ie)}return null}function Pe(de,ie,fe,Fe){var it=ie!==null?ie.key:null;if(typeof fe=="string"&&fe!==""||typeof fe=="number")return it!==null?null:J(de,ie,""+fe,Fe);if(typeof fe=="object"&&fe!==null){switch(fe.$$typeof){case D:return fe.key===it?re(de,ie,fe,Fe):null;case T:return fe.key===it?me(de,ie,fe,Fe):null;case z:return it=fe._init,Pe(de,ie,it(fe._payload),Fe)}if(nt(fe)||K(fe))return it!==null?null:_e(de,ie,fe,Fe,null);xf(de,fe)}return null}function Xe(de,ie,fe,Fe,it){if(typeof Fe=="string"&&Fe!==""||typeof Fe=="number")return de=de.get(fe)||null,J(ie,de,""+Fe,it);if(typeof Fe=="object"&&Fe!==null){switch(Fe.$$typeof){case D:return de=de.get(Fe.key===null?fe:Fe.key)||null,re(ie,de,Fe,it);case T:return de=de.get(Fe.key===null?fe:Fe.key)||null,me(ie,de,Fe,it);case z:var ut=Fe._init;return Xe(de,ie,fe,ut(Fe._payload),it)}if(nt(Fe)||K(Fe))return de=de.get(fe)||null,_e(ie,de,Fe,it,null);xf(ie,Fe)}return null}function tt(de,ie,fe,Fe){for(var it=null,ut=null,dt=ie,pt=ie=0,Un=null;dt!==null&&pt<fe.length;pt++){dt.index>pt?(Un=dt,dt=null):Un=dt.sibling;var Dt=Pe(de,dt,fe[pt],Fe);if(Dt===null){dt===null&&(dt=Un);break}c&&dt&&Dt.alternate===null&&u(de,dt),ie=P(Dt,ie,pt),ut===null?it=Dt:ut.sibling=Dt,ut=Dt,dt=Un}if(pt===fe.length)return x(de,dt),nn&&Fi(de,pt),it;if(dt===null){for(;pt<fe.length;pt++)dt=De(de,fe[pt],Fe),dt!==null&&(ie=P(dt,ie,pt),ut===null?it=dt:ut.sibling=dt,ut=dt);return nn&&Fi(de,pt),it}for(dt=v(de,dt);pt<fe.length;pt++)Un=Xe(dt,de,pt,fe[pt],Fe),Un!==null&&(c&&Un.alternate!==null&&dt.delete(Un.key===null?pt:Un.key),ie=P(Un,ie,pt),ut===null?it=Un:ut.sibling=Un,ut=Un);return c&&dt.forEach(function(si){return u(de,si)}),nn&&Fi(de,pt),it}function rt(de,ie,fe,Fe){var it=K(fe);if(typeof it!="function")throw Error(n(150));if(fe=it.call(fe),fe==null)throw Error(n(151));for(var ut=it=null,dt=ie,pt=ie=0,Un=null,Dt=fe.next();dt!==null&&!Dt.done;pt++,Dt=fe.next()){dt.index>pt?(Un=dt,dt=null):Un=dt.sibling;var si=Pe(de,dt,Dt.value,Fe);if(si===null){dt===null&&(dt=Un);break}c&&dt&&si.alternate===null&&u(de,dt),ie=P(si,ie,pt),ut===null?it=si:ut.sibling=si,ut=si,dt=Un}if(Dt.done)return x(de,dt),nn&&Fi(de,pt),it;if(dt===null){for(;!Dt.done;pt++,Dt=fe.next())Dt=De(de,Dt.value,Fe),Dt!==null&&(ie=P(Dt,ie,pt),ut===null?it=Dt:ut.sibling=Dt,ut=Dt);return nn&&Fi(de,pt),it}for(dt=v(de,dt);!Dt.done;pt++,Dt=fe.next())Dt=Xe(dt,de,pt,Dt.value,Fe),Dt!==null&&(c&&Dt.alternate!==null&&dt.delete(Dt.key===null?pt:Dt.key),ie=P(Dt,ie,pt),ut===null?it=Dt:ut.sibling=Dt,ut=Dt);return c&&dt.forEach(function(CI){return u(de,CI)}),nn&&Fi(de,pt),it}function fn(de,ie,fe,Fe){if(typeof fe=="object"&&fe!==null&&fe.type===R&&fe.key===null&&(fe=fe.props.children),typeof fe=="object"&&fe!==null){switch(fe.$$typeof){case D:e:{for(var it=fe.key,ut=ie;ut!==null;){if(ut.key===it){if(it=fe.type,it===R){if(ut.tag===7){x(de,ut.sibling),ie=E(ut,fe.props.children),ie.return=de,de=ie;break e}}else if(ut.elementType===it||typeof it=="object"&&it!==null&&it.$$typeof===z&&Cj(it)===ut.type){x(de,ut.sibling),ie=E(ut,fe.props),ie.ref=Gc(de,ut,fe),ie.return=de,de=ie;break e}x(de,ut);break}else u(de,ut);ut=ut.sibling}fe.type===R?(ie=Ki(fe.props.children,de.mode,Fe,fe.key),ie.return=de,de=ie):(Fe=Bf(fe.type,fe.key,fe.props,null,de.mode,Fe),Fe.ref=Gc(de,ie,fe),Fe.return=de,de=Fe)}return q(de);case T:e:{for(ut=fe.key;ie!==null;){if(ie.key===ut)if(ie.tag===4&&ie.stateNode.containerInfo===fe.containerInfo&&ie.stateNode.implementation===fe.implementation){x(de,ie.sibling),ie=E(ie,fe.children||[]),ie.return=de,de=ie;break e}else{x(de,ie);break}else u(de,ie);ie=ie.sibling}ie=Ex(fe,de.mode,Fe),ie.return=de,de=ie}return q(de);case z:return ut=fe._init,fn(de,ie,ut(fe._payload),Fe)}if(nt(fe))return tt(de,ie,fe,Fe);if(K(fe))return rt(de,ie,fe,Fe);xf(de,fe)}return typeof fe=="string"&&fe!==""||typeof fe=="number"?(fe=""+fe,ie!==null&&ie.tag===6?(x(de,ie.sibling),ie=E(ie,fe),ie.return=de,de=ie):(x(de,ie),ie=Cx(fe,de.mode,Fe),ie.return=de,de=ie),q(de)):x(de,ie)}return fn}var Xa=Ej(!0),Tj=Ej(!1),yf=Ko(null),bf=null,Qa=null,Mg=null;function Lg(){Mg=Qa=bf=null}function Og(c){var u=yf.current;Yt(yf),c._currentValue=u}function Fg(c,u,x){for(;c!==null;){var v=c.alternate;if((c.childLanes&u)!==u?(c.childLanes|=u,v!==null&&(v.childLanes|=u)):v!==null&&(v.childLanes&u)!==u&&(v.childLanes|=u),c===x)break;c=c.return}}function Ja(c,u){bf=c,Mg=Qa=null,c=c.dependencies,c!==null&&c.firstContext!==null&&((c.lanes&u)!==0&&(ur=!0),c.firstContext=null)}function Kr(c){var u=c._currentValue;if(Mg!==c)if(c={context:c,memoizedValue:u,next:null},Qa===null){if(bf===null)throw Error(n(308));Qa=c,bf.dependencies={lanes:0,firstContext:c}}else Qa=Qa.next=c;return u}var zi=null;function zg(c){zi===null?zi=[c]:zi.push(c)}function Rj(c,u,x,v){var E=u.interleaved;return E===null?(x.next=x,zg(u)):(x.next=E.next,E.next=x),u.interleaved=x,po(c,v)}function po(c,u){c.lanes|=u;var x=c.alternate;for(x!==null&&(x.lanes|=u),x=c,c=c.return;c!==null;)c.childLanes|=u,x=c.alternate,x!==null&&(x.childLanes|=u),x=c,c=c.return;return x.tag===3?x.stateNode:null}var Xo=!1;function Bg(c){c.updateQueue={baseState:c.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Aj(c,u){c=c.updateQueue,u.updateQueue===c&&(u.updateQueue={baseState:c.baseState,firstBaseUpdate:c.firstBaseUpdate,lastBaseUpdate:c.lastBaseUpdate,shared:c.shared,effects:c.effects})}function ho(c,u){return{eventTime:c,lane:u,tag:0,payload:null,callback:null,next:null}}function Qo(c,u,x){var v=c.updateQueue;if(v===null)return null;if(v=v.shared,(_t&2)!==0){var E=v.pending;return E===null?u.next=u:(u.next=E.next,E.next=u),v.pending=u,po(c,x)}return E=v.interleaved,E===null?(u.next=u,zg(v)):(u.next=E.next,E.next=u),v.interleaved=u,po(c,x)}function vf(c,u,x){if(u=u.updateQueue,u!==null&&(u=u.shared,(x&4194240)!==0)){var v=u.lanes;v&=c.pendingLanes,x|=v,u.lanes=x,_s(c,x)}}function Pj(c,u){var x=c.updateQueue,v=c.alternate;if(v!==null&&(v=v.updateQueue,x===v)){var E=null,P=null;if(x=x.firstBaseUpdate,x!==null){do{var q={eventTime:x.eventTime,lane:x.lane,tag:x.tag,payload:x.payload,callback:x.callback,next:null};P===null?E=P=q:P=P.next=q,x=x.next}while(x!==null);P===null?E=P=u:P=P.next=u}else E=P=u;x={baseState:v.baseState,firstBaseUpdate:E,lastBaseUpdate:P,shared:v.shared,effects:v.effects},c.updateQueue=x;return}c=x.lastBaseUpdate,c===null?x.firstBaseUpdate=u:c.next=u,x.lastBaseUpdate=u}function wf(c,u,x,v){var E=c.updateQueue;Xo=!1;var P=E.firstBaseUpdate,q=E.lastBaseUpdate,J=E.shared.pending;if(J!==null){E.shared.pending=null;var re=J,me=re.next;re.next=null,q===null?P=me:q.next=me,q=re;var _e=c.alternate;_e!==null&&(_e=_e.updateQueue,J=_e.lastBaseUpdate,J!==q&&(J===null?_e.firstBaseUpdate=me:J.next=me,_e.lastBaseUpdate=re))}if(P!==null){var De=E.baseState;q=0,_e=me=re=null,J=P;do{var Pe=J.lane,Xe=J.eventTime;if((v&Pe)===Pe){_e!==null&&(_e=_e.next={eventTime:Xe,lane:0,tag:J.tag,payload:J.payload,callback:J.callback,next:null});e:{var tt=c,rt=J;switch(Pe=u,Xe=x,rt.tag){case 1:if(tt=rt.payload,typeof tt=="function"){De=tt.call(Xe,De,Pe);break e}De=tt;break e;case 3:tt.flags=tt.flags&-65537|128;case 0:if(tt=rt.payload,Pe=typeof tt=="function"?tt.call(Xe,De,Pe):tt,Pe==null)break e;De=O({},De,Pe);break e;case 2:Xo=!0}}J.callback!==null&&J.lane!==0&&(c.flags|=64,Pe=E.effects,Pe===null?E.effects=[J]:Pe.push(J))}else Xe={eventTime:Xe,lane:Pe,tag:J.tag,payload:J.payload,callback:J.callback,next:null},_e===null?(me=_e=Xe,re=De):_e=_e.next=Xe,q|=Pe;if(J=J.next,J===null){if(J=E.shared.pending,J===null)break;Pe=J,J=Pe.next,Pe.next=null,E.lastBaseUpdate=Pe,E.shared.pending=null}}while(!0);if(_e===null&&(re=De),E.baseState=re,E.firstBaseUpdate=me,E.lastBaseUpdate=_e,u=E.shared.interleaved,u!==null){E=u;do q|=E.lane,E=E.next;while(E!==u)}else P===null&&(E.shared.lanes=0);Hi|=q,c.lanes=q,c.memoizedState=De}}function _j(c,u,x){if(c=u.effects,u.effects=null,c!==null)for(u=0;u<c.length;u++){var v=c[u],E=v.callback;if(E!==null){if(v.callback=null,v=x,typeof E!="function")throw Error(n(191,E));E.call(v)}}}var Yc={},Ls=Ko(Yc),Xc=Ko(Yc),Qc=Ko(Yc);function Bi(c){if(c===Yc)throw Error(n(174));return c}function Ug(c,u){switch(Wt(Qc,u),Wt(Xc,c),Wt(Ls,Yc),c=u.nodeType,c){case 9:case 11:u=(u=u.documentElement)?u.namespaceURI:xe(null,"");break;default:c=c===8?u.parentNode:u,u=c.namespaceURI||null,c=c.tagName,u=xe(u,c)}Yt(Ls),Wt(Ls,u)}function Za(){Yt(Ls),Yt(Xc),Yt(Qc)}function Dj(c){Bi(Qc.current);var u=Bi(Ls.current),x=xe(u,c.type);u!==x&&(Wt(Xc,c),Wt(Ls,x))}function Hg(c){Xc.current===c&&(Yt(Ls),Yt(Xc))}var an=Ko(0);function jf(c){for(var u=c;u!==null;){if(u.tag===13){var x=u.memoizedState;if(x!==null&&(x=x.dehydrated,x===null||x.data==="$?"||x.data==="$!"))return u}else if(u.tag===19&&u.memoizedProps.revealOrder!==void 0){if((u.flags&128)!==0)return u}else if(u.child!==null){u.child.return=u,u=u.child;continue}if(u===c)break;for(;u.sibling===null;){if(u.return===null||u.return===c)return null;u=u.return}u.sibling.return=u.return,u=u.sibling}return null}var Vg=[];function Wg(){for(var c=0;c<Vg.length;c++)Vg[c]._workInProgressVersionPrimary=null;Vg.length=0}var kf=C.ReactCurrentDispatcher,qg=C.ReactCurrentBatchConfig,Ui=0,ln=null,Pn=null,zn=null,Sf=!1,Jc=!1,Zc=0,G$=0;function Xn(){throw Error(n(321))}function Kg(c,u){if(u===null)return!1;for(var x=0;x<u.length&&x<c.length;x++)if(!is(c[x],u[x]))return!1;return!0}function Gg(c,u,x,v,E,P){if(Ui=P,ln=u,u.memoizedState=null,u.updateQueue=null,u.lanes=0,kf.current=c===null||c.memoizedState===null?J$:Z$,c=x(v,E),Jc){P=0;do{if(Jc=!1,Zc=0,25<=P)throw Error(n(301));P+=1,zn=Pn=null,u.updateQueue=null,kf.current=eI,c=x(v,E)}while(Jc)}if(kf.current=Ef,u=Pn!==null&&Pn.next!==null,Ui=0,zn=Pn=ln=null,Sf=!1,u)throw Error(n(300));return c}function Yg(){var c=Zc!==0;return Zc=0,c}function Os(){var c={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return zn===null?ln.memoizedState=zn=c:zn=zn.next=c,zn}function Gr(){if(Pn===null){var c=ln.alternate;c=c!==null?c.memoizedState:null}else c=Pn.next;var u=zn===null?ln.memoizedState:zn.next;if(u!==null)zn=u,Pn=c;else{if(c===null)throw Error(n(310));Pn=c,c={memoizedState:Pn.memoizedState,baseState:Pn.baseState,baseQueue:Pn.baseQueue,queue:Pn.queue,next:null},zn===null?ln.memoizedState=zn=c:zn=zn.next=c}return zn}function eu(c,u){return typeof u=="function"?u(c):u}function Xg(c){var u=Gr(),x=u.queue;if(x===null)throw Error(n(311));x.lastRenderedReducer=c;var v=Pn,E=v.baseQueue,P=x.pending;if(P!==null){if(E!==null){var q=E.next;E.next=P.next,P.next=q}v.baseQueue=E=P,x.pending=null}if(E!==null){P=E.next,v=v.baseState;var J=q=null,re=null,me=P;do{var _e=me.lane;if((Ui&_e)===_e)re!==null&&(re=re.next={lane:0,action:me.action,hasEagerState:me.hasEagerState,eagerState:me.eagerState,next:null}),v=me.hasEagerState?me.eagerState:c(v,me.action);else{var De={lane:_e,action:me.action,hasEagerState:me.hasEagerState,eagerState:me.eagerState,next:null};re===null?(J=re=De,q=v):re=re.next=De,ln.lanes|=_e,Hi|=_e}me=me.next}while(me!==null&&me!==P);re===null?q=v:re.next=J,is(v,u.memoizedState)||(ur=!0),u.memoizedState=v,u.baseState=q,u.baseQueue=re,x.lastRenderedState=v}if(c=x.interleaved,c!==null){E=c;do P=E.lane,ln.lanes|=P,Hi|=P,E=E.next;while(E!==c)}else E===null&&(x.lanes=0);return[u.memoizedState,x.dispatch]}function Qg(c){var u=Gr(),x=u.queue;if(x===null)throw Error(n(311));x.lastRenderedReducer=c;var v=x.dispatch,E=x.pending,P=u.memoizedState;if(E!==null){x.pending=null;var q=E=E.next;do P=c(P,q.action),q=q.next;while(q!==E);is(P,u.memoizedState)||(ur=!0),u.memoizedState=P,u.baseQueue===null&&(u.baseState=P),x.lastRenderedState=P}return[P,v]}function $j(){}function Ij(c,u){var x=ln,v=Gr(),E=u(),P=!is(v.memoizedState,E);if(P&&(v.memoizedState=E,ur=!0),v=v.queue,Jg(Oj.bind(null,x,v,c),[c]),v.getSnapshot!==u||P||zn!==null&&zn.memoizedState.tag&1){if(x.flags|=2048,tu(9,Lj.bind(null,x,v,E,u),void 0,null),Bn===null)throw Error(n(349));(Ui&30)!==0||Mj(x,u,E)}return E}function Mj(c,u,x){c.flags|=16384,c={getSnapshot:u,value:x},u=ln.updateQueue,u===null?(u={lastEffect:null,stores:null},ln.updateQueue=u,u.stores=[c]):(x=u.stores,x===null?u.stores=[c]:x.push(c))}function Lj(c,u,x,v){u.value=x,u.getSnapshot=v,Fj(u)&&zj(c)}function Oj(c,u,x){return x(function(){Fj(u)&&zj(c)})}function Fj(c){var u=c.getSnapshot;c=c.value;try{var x=u();return!is(c,x)}catch{return!0}}function zj(c){var u=po(c,1);u!==null&&ds(u,c,1,-1)}function Bj(c){var u=Os();return typeof c=="function"&&(c=c()),u.memoizedState=u.baseState=c,c={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:eu,lastRenderedState:c},u.queue=c,c=c.dispatch=Q$.bind(null,ln,c),[u.memoizedState,c]}function tu(c,u,x,v){return c={tag:c,create:u,destroy:x,deps:v,next:null},u=ln.updateQueue,u===null?(u={lastEffect:null,stores:null},ln.updateQueue=u,u.lastEffect=c.next=c):(x=u.lastEffect,x===null?u.lastEffect=c.next=c:(v=x.next,x.next=c,c.next=v,u.lastEffect=c)),c}function Uj(){return Gr().memoizedState}function Nf(c,u,x,v){var E=Os();ln.flags|=c,E.memoizedState=tu(1|u,x,void 0,v===void 0?null:v)}function Cf(c,u,x,v){var E=Gr();v=v===void 0?null:v;var P=void 0;if(Pn!==null){var q=Pn.memoizedState;if(P=q.destroy,v!==null&&Kg(v,q.deps)){E.memoizedState=tu(u,x,P,v);return}}ln.flags|=c,E.memoizedState=tu(1|u,x,P,v)}function Hj(c,u){return Nf(8390656,8,c,u)}function Jg(c,u){return Cf(2048,8,c,u)}function Vj(c,u){return Cf(4,2,c,u)}function Wj(c,u){return Cf(4,4,c,u)}function qj(c,u){if(typeof u=="function")return c=c(),u(c),function(){u(null)};if(u!=null)return c=c(),u.current=c,function(){u.current=null}}function Kj(c,u,x){return x=x!=null?x.concat([c]):null,Cf(4,4,qj.bind(null,u,c),x)}function Zg(){}function Gj(c,u){var x=Gr();u=u===void 0?null:u;var v=x.memoizedState;return v!==null&&u!==null&&Kg(u,v[1])?v[0]:(x.memoizedState=[c,u],c)}function Yj(c,u){var x=Gr();u=u===void 0?null:u;var v=x.memoizedState;return v!==null&&u!==null&&Kg(u,v[1])?v[0]:(c=c(),x.memoizedState=[c,u],c)}function Xj(c,u,x){return(Ui&21)===0?(c.baseState&&(c.baseState=!1,ur=!0),c.memoizedState=x):(is(x,u)||(x=zo(),ln.lanes|=x,Hi|=x,c.baseState=!0),u)}function Y$(c,u){var x=Lt;Lt=x!==0&&4>x?x:4,c(!0);var v=qg.transition;qg.transition={};try{c(!1),u()}finally{Lt=x,qg.transition=v}}function Qj(){return Gr().memoizedState}function X$(c,u,x){var v=ti(c);if(x={lane:v,action:x,hasEagerState:!1,eagerState:null,next:null},Jj(c))Zj(u,x);else if(x=Rj(c,u,x,v),x!==null){var E=sr();ds(x,c,v,E),ek(x,u,v)}}function Q$(c,u,x){var v=ti(c),E={lane:v,action:x,hasEagerState:!1,eagerState:null,next:null};if(Jj(c))Zj(u,E);else{var P=c.alternate;if(c.lanes===0&&(P===null||P.lanes===0)&&(P=u.lastRenderedReducer,P!==null))try{var q=u.lastRenderedState,J=P(q,x);if(E.hasEagerState=!0,E.eagerState=J,is(J,q)){var re=u.interleaved;re===null?(E.next=E,zg(u)):(E.next=re.next,re.next=E),u.interleaved=E;return}}catch{}finally{}x=Rj(c,u,E,v),x!==null&&(E=sr(),ds(x,c,v,E),ek(x,u,v))}}function Jj(c){var u=c.alternate;return c===ln||u!==null&&u===ln}function Zj(c,u){Jc=Sf=!0;var x=c.pending;x===null?u.next=u:(u.next=x.next,x.next=u),c.pending=u}function ek(c,u,x){if((x&4194240)!==0){var v=u.lanes;v&=c.pendingLanes,x|=v,u.lanes=x,_s(c,x)}}var Ef={readContext:Kr,useCallback:Xn,useContext:Xn,useEffect:Xn,useImperativeHandle:Xn,useInsertionEffect:Xn,useLayoutEffect:Xn,useMemo:Xn,useReducer:Xn,useRef:Xn,useState:Xn,useDebugValue:Xn,useDeferredValue:Xn,useTransition:Xn,useMutableSource:Xn,useSyncExternalStore:Xn,useId:Xn,unstable_isNewReconciler:!1},J$={readContext:Kr,useCallback:function(c,u){return Os().memoizedState=[c,u===void 0?null:u],c},useContext:Kr,useEffect:Hj,useImperativeHandle:function(c,u,x){return x=x!=null?x.concat([c]):null,Nf(4194308,4,qj.bind(null,u,c),x)},useLayoutEffect:function(c,u){return Nf(4194308,4,c,u)},useInsertionEffect:function(c,u){return Nf(4,2,c,u)},useMemo:function(c,u){var x=Os();return u=u===void 0?null:u,c=c(),x.memoizedState=[c,u],c},useReducer:function(c,u,x){var v=Os();return u=x!==void 0?x(u):u,v.memoizedState=v.baseState=u,c={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:c,lastRenderedState:u},v.queue=c,c=c.dispatch=X$.bind(null,ln,c),[v.memoizedState,c]},useRef:function(c){var u=Os();return c={current:c},u.memoizedState=c},useState:Bj,useDebugValue:Zg,useDeferredValue:function(c){return Os().memoizedState=c},useTransition:function(){var c=Bj(!1),u=c[0];return c=Y$.bind(null,c[1]),Os().memoizedState=c,[u,c]},useMutableSource:function(){},useSyncExternalStore:function(c,u,x){var v=ln,E=Os();if(nn){if(x===void 0)throw Error(n(407));x=x()}else{if(x=u(),Bn===null)throw Error(n(349));(Ui&30)!==0||Mj(v,u,x)}E.memoizedState=x;var P={value:x,getSnapshot:u};return E.queue=P,Hj(Oj.bind(null,v,P,c),[c]),v.flags|=2048,tu(9,Lj.bind(null,v,P,x,u),void 0,null),x},useId:function(){var c=Os(),u=Bn.identifierPrefix;if(nn){var x=fo,v=uo;x=(v&~(1<<32-On(v)-1)).toString(32)+x,u=":"+u+"R"+x,x=Zc++,0<x&&(u+="H"+x.toString(32)),u+=":"}else x=G$++,u=":"+u+"r"+x.toString(32)+":";return c.memoizedState=u},unstable_isNewReconciler:!1},Z$={readContext:Kr,useCallback:Gj,useContext:Kr,useEffect:Jg,useImperativeHandle:Kj,useInsertionEffect:Vj,useLayoutEffect:Wj,useMemo:Yj,useReducer:Xg,useRef:Uj,useState:function(){return Xg(eu)},useDebugValue:Zg,useDeferredValue:function(c){var u=Gr();return Xj(u,Pn.memoizedState,c)},useTransition:function(){var c=Xg(eu)[0],u=Gr().memoizedState;return[c,u]},useMutableSource:$j,useSyncExternalStore:Ij,useId:Qj,unstable_isNewReconciler:!1},eI={readContext:Kr,useCallback:Gj,useContext:Kr,useEffect:Jg,useImperativeHandle:Kj,useInsertionEffect:Vj,useLayoutEffect:Wj,useMemo:Yj,useReducer:Qg,useRef:Uj,useState:function(){return Qg(eu)},useDebugValue:Zg,useDeferredValue:function(c){var u=Gr();return Pn===null?u.memoizedState=c:Xj(u,Pn.memoizedState,c)},useTransition:function(){var c=Qg(eu)[0],u=Gr().memoizedState;return[c,u]},useMutableSource:$j,useSyncExternalStore:Ij,useId:Qj,unstable_isNewReconciler:!1};function ls(c,u){if(c&&c.defaultProps){u=O({},u),c=c.defaultProps;for(var x in c)u[x]===void 0&&(u[x]=c[x]);return u}return u}function ex(c,u,x,v){u=c.memoizedState,x=x(v,u),x=x==null?u:O({},u,x),c.memoizedState=x,c.lanes===0&&(c.updateQueue.baseState=x)}var Tf={isMounted:function(c){return(c=c._reactInternals)?bt(c)===c:!1},enqueueSetState:function(c,u,x){c=c._reactInternals;var v=sr(),E=ti(c),P=ho(v,E);P.payload=u,x!=null&&(P.callback=x),u=Qo(c,P,E),u!==null&&(ds(u,c,E,v),vf(u,c,E))},enqueueReplaceState:function(c,u,x){c=c._reactInternals;var v=sr(),E=ti(c),P=ho(v,E);P.tag=1,P.payload=u,x!=null&&(P.callback=x),u=Qo(c,P,E),u!==null&&(ds(u,c,E,v),vf(u,c,E))},enqueueForceUpdate:function(c,u){c=c._reactInternals;var x=sr(),v=ti(c),E=ho(x,v);E.tag=2,u!=null&&(E.callback=u),u=Qo(c,E,v),u!==null&&(ds(u,c,v,x),vf(u,c,v))}};function tk(c,u,x,v,E,P,q){return c=c.stateNode,typeof c.shouldComponentUpdate=="function"?c.shouldComponentUpdate(v,P,q):u.prototype&&u.prototype.isPureReactComponent?!Bc(x,v)||!Bc(E,P):!0}function nk(c,u,x){var v=!1,E=Go,P=u.contextType;return typeof P=="object"&&P!==null?P=Kr(P):(E=cr(u)?Li:Yn.current,v=u.contextTypes,P=(v=v!=null)?qa(c,E):Go),u=new u(x,P),c.memoizedState=u.state!==null&&u.state!==void 0?u.state:null,u.updater=Tf,c.stateNode=u,u._reactInternals=c,v&&(c=c.stateNode,c.__reactInternalMemoizedUnmaskedChildContext=E,c.__reactInternalMemoizedMaskedChildContext=P),u}function rk(c,u,x,v){c=u.state,typeof u.componentWillReceiveProps=="function"&&u.componentWillReceiveProps(x,v),typeof u.UNSAFE_componentWillReceiveProps=="function"&&u.UNSAFE_componentWillReceiveProps(x,v),u.state!==c&&Tf.enqueueReplaceState(u,u.state,null)}function tx(c,u,x,v){var E=c.stateNode;E.props=x,E.state=c.memoizedState,E.refs={},Bg(c);var P=u.contextType;typeof P=="object"&&P!==null?E.context=Kr(P):(P=cr(u)?Li:Yn.current,E.context=qa(c,P)),E.state=c.memoizedState,P=u.getDerivedStateFromProps,typeof P=="function"&&(ex(c,u,P,x),E.state=c.memoizedState),typeof u.getDerivedStateFromProps=="function"||typeof E.getSnapshotBeforeUpdate=="function"||typeof E.UNSAFE_componentWillMount!="function"&&typeof E.componentWillMount!="function"||(u=E.state,typeof E.componentWillMount=="function"&&E.componentWillMount(),typeof E.UNSAFE_componentWillMount=="function"&&E.UNSAFE_componentWillMount(),u!==E.state&&Tf.enqueueReplaceState(E,E.state,null),wf(c,x,E,v),E.state=c.memoizedState),typeof E.componentDidMount=="function"&&(c.flags|=4194308)}function el(c,u){try{var x="",v=u;do x+=te(v),v=v.return;while(v);var E=x}catch(P){E=`
39
+ Error generating stack: `+P.message+`
40
+ `+P.stack}return{value:c,source:u,stack:E,digest:null}}function nx(c,u,x){return{value:c,source:null,stack:x??null,digest:u??null}}function rx(c,u){try{console.error(u.value)}catch(x){setTimeout(function(){throw x})}}var tI=typeof WeakMap=="function"?WeakMap:Map;function sk(c,u,x){x=ho(-1,x),x.tag=3,x.payload={element:null};var v=u.value;return x.callback=function(){If||(If=!0,yx=v),rx(c,u)},x}function ok(c,u,x){x=ho(-1,x),x.tag=3;var v=c.type.getDerivedStateFromError;if(typeof v=="function"){var E=u.value;x.payload=function(){return v(E)},x.callback=function(){rx(c,u)}}var P=c.stateNode;return P!==null&&typeof P.componentDidCatch=="function"&&(x.callback=function(){rx(c,u),typeof v!="function"&&(Zo===null?Zo=new Set([this]):Zo.add(this));var q=u.stack;this.componentDidCatch(u.value,{componentStack:q!==null?q:""})}),x}function ik(c,u,x){var v=c.pingCache;if(v===null){v=c.pingCache=new tI;var E=new Set;v.set(u,E)}else E=v.get(u),E===void 0&&(E=new Set,v.set(u,E));E.has(x)||(E.add(x),c=mI.bind(null,c,u,x),u.then(c,c))}function ak(c){do{var u;if((u=c.tag===13)&&(u=c.memoizedState,u=u!==null?u.dehydrated!==null:!0),u)return c;c=c.return}while(c!==null);return null}function lk(c,u,x,v,E){return(c.mode&1)===0?(c===u?c.flags|=65536:(c.flags|=128,x.flags|=131072,x.flags&=-52805,x.tag===1&&(x.alternate===null?x.tag=17:(u=ho(-1,1),u.tag=2,Qo(x,u,1))),x.lanes|=1),c):(c.flags|=65536,c.lanes=E,c)}var nI=C.ReactCurrentOwner,ur=!1;function rr(c,u,x,v){u.child=c===null?Tj(u,null,x,v):Xa(u,c.child,x,v)}function ck(c,u,x,v,E){x=x.render;var P=u.ref;return Ja(u,E),v=Gg(c,u,x,v,P,E),x=Yg(),c!==null&&!ur?(u.updateQueue=c.updateQueue,u.flags&=-2053,c.lanes&=~E,mo(c,u,E)):(nn&&x&&Pg(u),u.flags|=1,rr(c,u,v,E),u.child)}function uk(c,u,x,v,E){if(c===null){var P=x.type;return typeof P=="function"&&!Nx(P)&&P.defaultProps===void 0&&x.compare===null&&x.defaultProps===void 0?(u.tag=15,u.type=P,dk(c,u,P,v,E)):(c=Bf(x.type,null,v,u,u.mode,E),c.ref=u.ref,c.return=u,u.child=c)}if(P=c.child,(c.lanes&E)===0){var q=P.memoizedProps;if(x=x.compare,x=x!==null?x:Bc,x(q,v)&&c.ref===u.ref)return mo(c,u,E)}return u.flags|=1,c=ri(P,v),c.ref=u.ref,c.return=u,u.child=c}function dk(c,u,x,v,E){if(c!==null){var P=c.memoizedProps;if(Bc(P,v)&&c.ref===u.ref)if(ur=!1,u.pendingProps=v=P,(c.lanes&E)!==0)(c.flags&131072)!==0&&(ur=!0);else return u.lanes=c.lanes,mo(c,u,E)}return sx(c,u,x,v,E)}function fk(c,u,x){var v=u.pendingProps,E=v.children,P=c!==null?c.memoizedState:null;if(v.mode==="hidden")if((u.mode&1)===0)u.memoizedState={baseLanes:0,cachePool:null,transitions:null},Wt(nl,Rr),Rr|=x;else{if((x&1073741824)===0)return c=P!==null?P.baseLanes|x:x,u.lanes=u.childLanes=1073741824,u.memoizedState={baseLanes:c,cachePool:null,transitions:null},u.updateQueue=null,Wt(nl,Rr),Rr|=c,null;u.memoizedState={baseLanes:0,cachePool:null,transitions:null},v=P!==null?P.baseLanes:x,Wt(nl,Rr),Rr|=v}else P!==null?(v=P.baseLanes|x,u.memoizedState=null):v=x,Wt(nl,Rr),Rr|=v;return rr(c,u,E,x),u.child}function pk(c,u){var x=u.ref;(c===null&&x!==null||c!==null&&c.ref!==x)&&(u.flags|=512,u.flags|=2097152)}function sx(c,u,x,v,E){var P=cr(x)?Li:Yn.current;return P=qa(u,P),Ja(u,E),x=Gg(c,u,x,v,P,E),v=Yg(),c!==null&&!ur?(u.updateQueue=c.updateQueue,u.flags&=-2053,c.lanes&=~E,mo(c,u,E)):(nn&&v&&Pg(u),u.flags|=1,rr(c,u,x,E),u.child)}function hk(c,u,x,v,E){if(cr(x)){var P=!0;ff(u)}else P=!1;if(Ja(u,E),u.stateNode===null)Af(c,u),nk(u,x,v),tx(u,x,v,E),v=!0;else if(c===null){var q=u.stateNode,J=u.memoizedProps;q.props=J;var re=q.context,me=x.contextType;typeof me=="object"&&me!==null?me=Kr(me):(me=cr(x)?Li:Yn.current,me=qa(u,me));var _e=x.getDerivedStateFromProps,De=typeof _e=="function"||typeof q.getSnapshotBeforeUpdate=="function";De||typeof q.UNSAFE_componentWillReceiveProps!="function"&&typeof q.componentWillReceiveProps!="function"||(J!==v||re!==me)&&rk(u,q,v,me),Xo=!1;var Pe=u.memoizedState;q.state=Pe,wf(u,v,q,E),re=u.memoizedState,J!==v||Pe!==re||lr.current||Xo?(typeof _e=="function"&&(ex(u,x,_e,v),re=u.memoizedState),(J=Xo||tk(u,x,J,v,Pe,re,me))?(De||typeof q.UNSAFE_componentWillMount!="function"&&typeof q.componentWillMount!="function"||(typeof q.componentWillMount=="function"&&q.componentWillMount(),typeof q.UNSAFE_componentWillMount=="function"&&q.UNSAFE_componentWillMount()),typeof q.componentDidMount=="function"&&(u.flags|=4194308)):(typeof q.componentDidMount=="function"&&(u.flags|=4194308),u.memoizedProps=v,u.memoizedState=re),q.props=v,q.state=re,q.context=me,v=J):(typeof q.componentDidMount=="function"&&(u.flags|=4194308),v=!1)}else{q=u.stateNode,Aj(c,u),J=u.memoizedProps,me=u.type===u.elementType?J:ls(u.type,J),q.props=me,De=u.pendingProps,Pe=q.context,re=x.contextType,typeof re=="object"&&re!==null?re=Kr(re):(re=cr(x)?Li:Yn.current,re=qa(u,re));var Xe=x.getDerivedStateFromProps;(_e=typeof Xe=="function"||typeof q.getSnapshotBeforeUpdate=="function")||typeof q.UNSAFE_componentWillReceiveProps!="function"&&typeof q.componentWillReceiveProps!="function"||(J!==De||Pe!==re)&&rk(u,q,v,re),Xo=!1,Pe=u.memoizedState,q.state=Pe,wf(u,v,q,E);var tt=u.memoizedState;J!==De||Pe!==tt||lr.current||Xo?(typeof Xe=="function"&&(ex(u,x,Xe,v),tt=u.memoizedState),(me=Xo||tk(u,x,me,v,Pe,tt,re)||!1)?(_e||typeof q.UNSAFE_componentWillUpdate!="function"&&typeof q.componentWillUpdate!="function"||(typeof q.componentWillUpdate=="function"&&q.componentWillUpdate(v,tt,re),typeof q.UNSAFE_componentWillUpdate=="function"&&q.UNSAFE_componentWillUpdate(v,tt,re)),typeof q.componentDidUpdate=="function"&&(u.flags|=4),typeof q.getSnapshotBeforeUpdate=="function"&&(u.flags|=1024)):(typeof q.componentDidUpdate!="function"||J===c.memoizedProps&&Pe===c.memoizedState||(u.flags|=4),typeof q.getSnapshotBeforeUpdate!="function"||J===c.memoizedProps&&Pe===c.memoizedState||(u.flags|=1024),u.memoizedProps=v,u.memoizedState=tt),q.props=v,q.state=tt,q.context=re,v=me):(typeof q.componentDidUpdate!="function"||J===c.memoizedProps&&Pe===c.memoizedState||(u.flags|=4),typeof q.getSnapshotBeforeUpdate!="function"||J===c.memoizedProps&&Pe===c.memoizedState||(u.flags|=1024),v=!1)}return ox(c,u,x,v,P,E)}function ox(c,u,x,v,E,P){pk(c,u);var q=(u.flags&128)!==0;if(!v&&!q)return E&&bj(u,x,!1),mo(c,u,P);v=u.stateNode,nI.current=u;var J=q&&typeof x.getDerivedStateFromError!="function"?null:v.render();return u.flags|=1,c!==null&&q?(u.child=Xa(u,c.child,null,P),u.child=Xa(u,null,J,P)):rr(c,u,J,P),u.memoizedState=v.state,E&&bj(u,x,!0),u.child}function mk(c){var u=c.stateNode;u.pendingContext?xj(c,u.pendingContext,u.pendingContext!==u.context):u.context&&xj(c,u.context,!1),Ug(c,u.containerInfo)}function gk(c,u,x,v,E){return Ya(),Ig(E),u.flags|=256,rr(c,u,x,v),u.child}var ix={dehydrated:null,treeContext:null,retryLane:0};function ax(c){return{baseLanes:c,cachePool:null,transitions:null}}function xk(c,u,x){var v=u.pendingProps,E=an.current,P=!1,q=(u.flags&128)!==0,J;if((J=q)||(J=c!==null&&c.memoizedState===null?!1:(E&2)!==0),J?(P=!0,u.flags&=-129):(c===null||c.memoizedState!==null)&&(E|=1),Wt(an,E&1),c===null)return $g(u),c=u.memoizedState,c!==null&&(c=c.dehydrated,c!==null)?((u.mode&1)===0?u.lanes=1:c.data==="$!"?u.lanes=8:u.lanes=1073741824,null):(q=v.children,c=v.fallback,P?(v=u.mode,P=u.child,q={mode:"hidden",children:q},(v&1)===0&&P!==null?(P.childLanes=0,P.pendingProps=q):P=Uf(q,v,0,null),c=Ki(c,v,x,null),P.return=u,c.return=u,P.sibling=c,u.child=P,u.child.memoizedState=ax(x),u.memoizedState=ix,c):lx(u,q));if(E=c.memoizedState,E!==null&&(J=E.dehydrated,J!==null))return rI(c,u,q,v,J,E,x);if(P){P=v.fallback,q=u.mode,E=c.child,J=E.sibling;var re={mode:"hidden",children:v.children};return(q&1)===0&&u.child!==E?(v=u.child,v.childLanes=0,v.pendingProps=re,u.deletions=null):(v=ri(E,re),v.subtreeFlags=E.subtreeFlags&14680064),J!==null?P=ri(J,P):(P=Ki(P,q,x,null),P.flags|=2),P.return=u,v.return=u,v.sibling=P,u.child=v,v=P,P=u.child,q=c.child.memoizedState,q=q===null?ax(x):{baseLanes:q.baseLanes|x,cachePool:null,transitions:q.transitions},P.memoizedState=q,P.childLanes=c.childLanes&~x,u.memoizedState=ix,v}return P=c.child,c=P.sibling,v=ri(P,{mode:"visible",children:v.children}),(u.mode&1)===0&&(v.lanes=x),v.return=u,v.sibling=null,c!==null&&(x=u.deletions,x===null?(u.deletions=[c],u.flags|=16):x.push(c)),u.child=v,u.memoizedState=null,v}function lx(c,u){return u=Uf({mode:"visible",children:u},c.mode,0,null),u.return=c,c.child=u}function Rf(c,u,x,v){return v!==null&&Ig(v),Xa(u,c.child,null,x),c=lx(u,u.pendingProps.children),c.flags|=2,u.memoizedState=null,c}function rI(c,u,x,v,E,P,q){if(x)return u.flags&256?(u.flags&=-257,v=nx(Error(n(422))),Rf(c,u,q,v)):u.memoizedState!==null?(u.child=c.child,u.flags|=128,null):(P=v.fallback,E=u.mode,v=Uf({mode:"visible",children:v.children},E,0,null),P=Ki(P,E,q,null),P.flags|=2,v.return=u,P.return=u,v.sibling=P,u.child=v,(u.mode&1)!==0&&Xa(u,c.child,null,q),u.child.memoizedState=ax(q),u.memoizedState=ix,P);if((u.mode&1)===0)return Rf(c,u,q,null);if(E.data==="$!"){if(v=E.nextSibling&&E.nextSibling.dataset,v)var J=v.dgst;return v=J,P=Error(n(419)),v=nx(P,v,void 0),Rf(c,u,q,v)}if(J=(q&c.childLanes)!==0,ur||J){if(v=Bn,v!==null){switch(q&-q){case 4:E=2;break;case 16:E=8;break;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:E=32;break;case 536870912:E=268435456;break;default:E=0}E=(E&(v.suspendedLanes|q))!==0?0:E,E!==0&&E!==P.retryLane&&(P.retryLane=E,po(c,E),ds(v,c,E,-1))}return Sx(),v=nx(Error(n(421))),Rf(c,u,q,v)}return E.data==="$?"?(u.flags|=128,u.child=c.child,u=gI.bind(null,c),E._reactRetry=u,null):(c=P.treeContext,Tr=qo(E.nextSibling),Er=u,nn=!0,as=null,c!==null&&(Wr[qr++]=uo,Wr[qr++]=fo,Wr[qr++]=Oi,uo=c.id,fo=c.overflow,Oi=u),u=lx(u,v.children),u.flags|=4096,u)}function yk(c,u,x){c.lanes|=u;var v=c.alternate;v!==null&&(v.lanes|=u),Fg(c.return,u,x)}function cx(c,u,x,v,E){var P=c.memoizedState;P===null?c.memoizedState={isBackwards:u,rendering:null,renderingStartTime:0,last:v,tail:x,tailMode:E}:(P.isBackwards=u,P.rendering=null,P.renderingStartTime=0,P.last=v,P.tail=x,P.tailMode=E)}function bk(c,u,x){var v=u.pendingProps,E=v.revealOrder,P=v.tail;if(rr(c,u,v.children,x),v=an.current,(v&2)!==0)v=v&1|2,u.flags|=128;else{if(c!==null&&(c.flags&128)!==0)e:for(c=u.child;c!==null;){if(c.tag===13)c.memoizedState!==null&&yk(c,x,u);else if(c.tag===19)yk(c,x,u);else if(c.child!==null){c.child.return=c,c=c.child;continue}if(c===u)break e;for(;c.sibling===null;){if(c.return===null||c.return===u)break e;c=c.return}c.sibling.return=c.return,c=c.sibling}v&=1}if(Wt(an,v),(u.mode&1)===0)u.memoizedState=null;else switch(E){case"forwards":for(x=u.child,E=null;x!==null;)c=x.alternate,c!==null&&jf(c)===null&&(E=x),x=x.sibling;x=E,x===null?(E=u.child,u.child=null):(E=x.sibling,x.sibling=null),cx(u,!1,E,x,P);break;case"backwards":for(x=null,E=u.child,u.child=null;E!==null;){if(c=E.alternate,c!==null&&jf(c)===null){u.child=E;break}c=E.sibling,E.sibling=x,x=E,E=c}cx(u,!0,x,null,P);break;case"together":cx(u,!1,null,null,void 0);break;default:u.memoizedState=null}return u.child}function Af(c,u){(u.mode&1)===0&&c!==null&&(c.alternate=null,u.alternate=null,u.flags|=2)}function mo(c,u,x){if(c!==null&&(u.dependencies=c.dependencies),Hi|=u.lanes,(x&u.childLanes)===0)return null;if(c!==null&&u.child!==c.child)throw Error(n(153));if(u.child!==null){for(c=u.child,x=ri(c,c.pendingProps),u.child=x,x.return=u;c.sibling!==null;)c=c.sibling,x=x.sibling=ri(c,c.pendingProps),x.return=u;x.sibling=null}return u.child}function sI(c,u,x){switch(u.tag){case 3:mk(u),Ya();break;case 5:Dj(u);break;case 1:cr(u.type)&&ff(u);break;case 4:Ug(u,u.stateNode.containerInfo);break;case 10:var v=u.type._context,E=u.memoizedProps.value;Wt(yf,v._currentValue),v._currentValue=E;break;case 13:if(v=u.memoizedState,v!==null)return v.dehydrated!==null?(Wt(an,an.current&1),u.flags|=128,null):(x&u.child.childLanes)!==0?xk(c,u,x):(Wt(an,an.current&1),c=mo(c,u,x),c!==null?c.sibling:null);Wt(an,an.current&1);break;case 19:if(v=(x&u.childLanes)!==0,(c.flags&128)!==0){if(v)return bk(c,u,x);u.flags|=128}if(E=u.memoizedState,E!==null&&(E.rendering=null,E.tail=null,E.lastEffect=null),Wt(an,an.current),v)break;return null;case 22:case 23:return u.lanes=0,fk(c,u,x)}return mo(c,u,x)}var vk,ux,wk,jk;vk=function(c,u){for(var x=u.child;x!==null;){if(x.tag===5||x.tag===6)c.appendChild(x.stateNode);else if(x.tag!==4&&x.child!==null){x.child.return=x,x=x.child;continue}if(x===u)break;for(;x.sibling===null;){if(x.return===null||x.return===u)return;x=x.return}x.sibling.return=x.return,x=x.sibling}},ux=function(){},wk=function(c,u,x,v){var E=c.memoizedProps;if(E!==v){c=u.stateNode,Bi(Ls.current);var P=null;switch(x){case"input":E=ze(c,E),v=ze(c,v),P=[];break;case"select":E=O({},E,{value:void 0}),v=O({},v,{value:void 0}),P=[];break;case"textarea":E=at(c,E),v=at(c,v),P=[];break;default:typeof E.onClick!="function"&&typeof v.onClick=="function"&&(c.onclick=cf)}qe(x,v);var q;x=null;for(me in E)if(!v.hasOwnProperty(me)&&E.hasOwnProperty(me)&&E[me]!=null)if(me==="style"){var J=E[me];for(q in J)J.hasOwnProperty(q)&&(x||(x={}),x[q]="")}else me!=="dangerouslySetInnerHTML"&&me!=="children"&&me!=="suppressContentEditableWarning"&&me!=="suppressHydrationWarning"&&me!=="autoFocus"&&(o.hasOwnProperty(me)?P||(P=[]):(P=P||[]).push(me,null));for(me in v){var re=v[me];if(J=E!=null?E[me]:void 0,v.hasOwnProperty(me)&&re!==J&&(re!=null||J!=null))if(me==="style")if(J){for(q in J)!J.hasOwnProperty(q)||re&&re.hasOwnProperty(q)||(x||(x={}),x[q]="");for(q in re)re.hasOwnProperty(q)&&J[q]!==re[q]&&(x||(x={}),x[q]=re[q])}else x||(P||(P=[]),P.push(me,x)),x=re;else me==="dangerouslySetInnerHTML"?(re=re?re.__html:void 0,J=J?J.__html:void 0,re!=null&&J!==re&&(P=P||[]).push(me,re)):me==="children"?typeof re!="string"&&typeof re!="number"||(P=P||[]).push(me,""+re):me!=="suppressContentEditableWarning"&&me!=="suppressHydrationWarning"&&(o.hasOwnProperty(me)?(re!=null&&me==="onScroll"&&Gt("scroll",c),P||J===re||(P=[])):(P=P||[]).push(me,re))}x&&(P=P||[]).push("style",x);var me=P;(u.updateQueue=me)&&(u.flags|=4)}},jk=function(c,u,x,v){x!==v&&(u.flags|=4)};function nu(c,u){if(!nn)switch(c.tailMode){case"hidden":u=c.tail;for(var x=null;u!==null;)u.alternate!==null&&(x=u),u=u.sibling;x===null?c.tail=null:x.sibling=null;break;case"collapsed":x=c.tail;for(var v=null;x!==null;)x.alternate!==null&&(v=x),x=x.sibling;v===null?u||c.tail===null?c.tail=null:c.tail.sibling=null:v.sibling=null}}function Qn(c){var u=c.alternate!==null&&c.alternate.child===c.child,x=0,v=0;if(u)for(var E=c.child;E!==null;)x|=E.lanes|E.childLanes,v|=E.subtreeFlags&14680064,v|=E.flags&14680064,E.return=c,E=E.sibling;else for(E=c.child;E!==null;)x|=E.lanes|E.childLanes,v|=E.subtreeFlags,v|=E.flags,E.return=c,E=E.sibling;return c.subtreeFlags|=v,c.childLanes=x,u}function oI(c,u,x){var v=u.pendingProps;switch(_g(u),u.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Qn(u),null;case 1:return cr(u.type)&&df(),Qn(u),null;case 3:return v=u.stateNode,Za(),Yt(lr),Yt(Yn),Wg(),v.pendingContext&&(v.context=v.pendingContext,v.pendingContext=null),(c===null||c.child===null)&&(gf(u)?u.flags|=4:c===null||c.memoizedState.isDehydrated&&(u.flags&256)===0||(u.flags|=1024,as!==null&&(wx(as),as=null))),ux(c,u),Qn(u),null;case 5:Hg(u);var E=Bi(Qc.current);if(x=u.type,c!==null&&u.stateNode!=null)wk(c,u,x,v,E),c.ref!==u.ref&&(u.flags|=512,u.flags|=2097152);else{if(!v){if(u.stateNode===null)throw Error(n(166));return Qn(u),null}if(c=Bi(Ls.current),gf(u)){v=u.stateNode,x=u.type;var P=u.memoizedProps;switch(v[Ms]=u,v[qc]=P,c=(u.mode&1)!==0,x){case"dialog":Gt("cancel",v),Gt("close",v);break;case"iframe":case"object":case"embed":Gt("load",v);break;case"video":case"audio":for(E=0;E<Hc.length;E++)Gt(Hc[E],v);break;case"source":Gt("error",v);break;case"img":case"image":case"link":Gt("error",v),Gt("load",v);break;case"details":Gt("toggle",v);break;case"input":oe(v,P),Gt("invalid",v);break;case"select":v._wrapperState={wasMultiple:!!P.multiple},Gt("invalid",v);break;case"textarea":xt(v,P),Gt("invalid",v)}qe(x,P),E=null;for(var q in P)if(P.hasOwnProperty(q)){var J=P[q];q==="children"?typeof J=="string"?v.textContent!==J&&(P.suppressHydrationWarning!==!0&&lf(v.textContent,J,c),E=["children",J]):typeof J=="number"&&v.textContent!==""+J&&(P.suppressHydrationWarning!==!0&&lf(v.textContent,J,c),E=["children",""+J]):o.hasOwnProperty(q)&&J!=null&&q==="onScroll"&&Gt("scroll",v)}switch(x){case"input":Ne(v),$e(v,P,!0);break;case"textarea":Ne(v),ot(v);break;case"select":case"option":break;default:typeof P.onClick=="function"&&(v.onclick=cf)}v=E,u.updateQueue=v,v!==null&&(u.flags|=4)}else{q=E.nodeType===9?E:E.ownerDocument,c==="http://www.w3.org/1999/xhtml"&&(c=le(x)),c==="http://www.w3.org/1999/xhtml"?x==="script"?(c=q.createElement("div"),c.innerHTML="<script><\/script>",c=c.removeChild(c.firstChild)):typeof v.is=="string"?c=q.createElement(x,{is:v.is}):(c=q.createElement(x),x==="select"&&(q=c,v.multiple?q.multiple=!0:v.size&&(q.size=v.size))):c=q.createElementNS(c,x),c[Ms]=u,c[qc]=v,vk(c,u,!1,!1),u.stateNode=c;e:{switch(q=X(x,v),x){case"dialog":Gt("cancel",c),Gt("close",c),E=v;break;case"iframe":case"object":case"embed":Gt("load",c),E=v;break;case"video":case"audio":for(E=0;E<Hc.length;E++)Gt(Hc[E],c);E=v;break;case"source":Gt("error",c),E=v;break;case"img":case"image":case"link":Gt("error",c),Gt("load",c),E=v;break;case"details":Gt("toggle",c),E=v;break;case"input":oe(c,v),E=ze(c,v),Gt("invalid",c);break;case"option":E=v;break;case"select":c._wrapperState={wasMultiple:!!v.multiple},E=O({},v,{value:void 0}),Gt("invalid",c);break;case"textarea":xt(c,v),E=at(c,v),Gt("invalid",c);break;default:E=v}qe(x,E),J=E;for(P in J)if(J.hasOwnProperty(P)){var re=J[P];P==="style"?je(c,re):P==="dangerouslySetInnerHTML"?(re=re?re.__html:void 0,re!=null&&We(c,re)):P==="children"?typeof re=="string"?(x!=="textarea"||re!=="")&&Ge(c,re):typeof re=="number"&&Ge(c,""+re):P!=="suppressContentEditableWarning"&&P!=="suppressHydrationWarning"&&P!=="autoFocus"&&(o.hasOwnProperty(P)?re!=null&&P==="onScroll"&&Gt("scroll",c):re!=null&&S(c,P,re,q))}switch(x){case"input":Ne(c),$e(c,v,!1);break;case"textarea":Ne(c),ot(c);break;case"option":v.value!=null&&c.setAttribute("value",""+ne(v.value));break;case"select":c.multiple=!!v.multiple,P=v.value,P!=null?He(c,!!v.multiple,P,!1):v.defaultValue!=null&&He(c,!!v.multiple,v.defaultValue,!0);break;default:typeof E.onClick=="function"&&(c.onclick=cf)}switch(x){case"button":case"input":case"select":case"textarea":v=!!v.autoFocus;break e;case"img":v=!0;break e;default:v=!1}}v&&(u.flags|=4)}u.ref!==null&&(u.flags|=512,u.flags|=2097152)}return Qn(u),null;case 6:if(c&&u.stateNode!=null)jk(c,u,c.memoizedProps,v);else{if(typeof v!="string"&&u.stateNode===null)throw Error(n(166));if(x=Bi(Qc.current),Bi(Ls.current),gf(u)){if(v=u.stateNode,x=u.memoizedProps,v[Ms]=u,(P=v.nodeValue!==x)&&(c=Er,c!==null))switch(c.tag){case 3:lf(v.nodeValue,x,(c.mode&1)!==0);break;case 5:c.memoizedProps.suppressHydrationWarning!==!0&&lf(v.nodeValue,x,(c.mode&1)!==0)}P&&(u.flags|=4)}else v=(x.nodeType===9?x:x.ownerDocument).createTextNode(v),v[Ms]=u,u.stateNode=v}return Qn(u),null;case 13:if(Yt(an),v=u.memoizedState,c===null||c.memoizedState!==null&&c.memoizedState.dehydrated!==null){if(nn&&Tr!==null&&(u.mode&1)!==0&&(u.flags&128)===0)Nj(),Ya(),u.flags|=98560,P=!1;else if(P=gf(u),v!==null&&v.dehydrated!==null){if(c===null){if(!P)throw Error(n(318));if(P=u.memoizedState,P=P!==null?P.dehydrated:null,!P)throw Error(n(317));P[Ms]=u}else Ya(),(u.flags&128)===0&&(u.memoizedState=null),u.flags|=4;Qn(u),P=!1}else as!==null&&(wx(as),as=null),P=!0;if(!P)return u.flags&65536?u:null}return(u.flags&128)!==0?(u.lanes=x,u):(v=v!==null,v!==(c!==null&&c.memoizedState!==null)&&v&&(u.child.flags|=8192,(u.mode&1)!==0&&(c===null||(an.current&1)!==0?_n===0&&(_n=3):Sx())),u.updateQueue!==null&&(u.flags|=4),Qn(u),null);case 4:return Za(),ux(c,u),c===null&&Vc(u.stateNode.containerInfo),Qn(u),null;case 10:return Og(u.type._context),Qn(u),null;case 17:return cr(u.type)&&df(),Qn(u),null;case 19:if(Yt(an),P=u.memoizedState,P===null)return Qn(u),null;if(v=(u.flags&128)!==0,q=P.rendering,q===null)if(v)nu(P,!1);else{if(_n!==0||c!==null&&(c.flags&128)!==0)for(c=u.child;c!==null;){if(q=jf(c),q!==null){for(u.flags|=128,nu(P,!1),v=q.updateQueue,v!==null&&(u.updateQueue=v,u.flags|=4),u.subtreeFlags=0,v=x,x=u.child;x!==null;)P=x,c=v,P.flags&=14680066,q=P.alternate,q===null?(P.childLanes=0,P.lanes=c,P.child=null,P.subtreeFlags=0,P.memoizedProps=null,P.memoizedState=null,P.updateQueue=null,P.dependencies=null,P.stateNode=null):(P.childLanes=q.childLanes,P.lanes=q.lanes,P.child=q.child,P.subtreeFlags=0,P.deletions=null,P.memoizedProps=q.memoizedProps,P.memoizedState=q.memoizedState,P.updateQueue=q.updateQueue,P.type=q.type,c=q.dependencies,P.dependencies=c===null?null:{lanes:c.lanes,firstContext:c.firstContext}),x=x.sibling;return Wt(an,an.current&1|2),u.child}c=c.sibling}P.tail!==null&&Bt()>rl&&(u.flags|=128,v=!0,nu(P,!1),u.lanes=4194304)}else{if(!v)if(c=jf(q),c!==null){if(u.flags|=128,v=!0,x=c.updateQueue,x!==null&&(u.updateQueue=x,u.flags|=4),nu(P,!0),P.tail===null&&P.tailMode==="hidden"&&!q.alternate&&!nn)return Qn(u),null}else 2*Bt()-P.renderingStartTime>rl&&x!==1073741824&&(u.flags|=128,v=!0,nu(P,!1),u.lanes=4194304);P.isBackwards?(q.sibling=u.child,u.child=q):(x=P.last,x!==null?x.sibling=q:u.child=q,P.last=q)}return P.tail!==null?(u=P.tail,P.rendering=u,P.tail=u.sibling,P.renderingStartTime=Bt(),u.sibling=null,x=an.current,Wt(an,v?x&1|2:x&1),u):(Qn(u),null);case 22:case 23:return kx(),v=u.memoizedState!==null,c!==null&&c.memoizedState!==null!==v&&(u.flags|=8192),v&&(u.mode&1)!==0?(Rr&1073741824)!==0&&(Qn(u),u.subtreeFlags&6&&(u.flags|=8192)):Qn(u),null;case 24:return null;case 25:return null}throw Error(n(156,u.tag))}function iI(c,u){switch(_g(u),u.tag){case 1:return cr(u.type)&&df(),c=u.flags,c&65536?(u.flags=c&-65537|128,u):null;case 3:return Za(),Yt(lr),Yt(Yn),Wg(),c=u.flags,(c&65536)!==0&&(c&128)===0?(u.flags=c&-65537|128,u):null;case 5:return Hg(u),null;case 13:if(Yt(an),c=u.memoizedState,c!==null&&c.dehydrated!==null){if(u.alternate===null)throw Error(n(340));Ya()}return c=u.flags,c&65536?(u.flags=c&-65537|128,u):null;case 19:return Yt(an),null;case 4:return Za(),null;case 10:return Og(u.type._context),null;case 22:case 23:return kx(),null;case 24:return null;default:return null}}var Pf=!1,Jn=!1,aI=typeof WeakSet=="function"?WeakSet:Set,Je=null;function tl(c,u){var x=c.ref;if(x!==null)if(typeof x=="function")try{x(null)}catch(v){un(c,u,v)}else x.current=null}function dx(c,u,x){try{x()}catch(v){un(c,u,v)}}var kk=!1;function lI(c,u){if(kg=Fn,c=tj(),mg(c)){if("selectionStart"in c)var x={start:c.selectionStart,end:c.selectionEnd};else e:{x=(x=c.ownerDocument)&&x.defaultView||window;var v=x.getSelection&&x.getSelection();if(v&&v.rangeCount!==0){x=v.anchorNode;var E=v.anchorOffset,P=v.focusNode;v=v.focusOffset;try{x.nodeType,P.nodeType}catch{x=null;break e}var q=0,J=-1,re=-1,me=0,_e=0,De=c,Pe=null;t:for(;;){for(var Xe;De!==x||E!==0&&De.nodeType!==3||(J=q+E),De!==P||v!==0&&De.nodeType!==3||(re=q+v),De.nodeType===3&&(q+=De.nodeValue.length),(Xe=De.firstChild)!==null;)Pe=De,De=Xe;for(;;){if(De===c)break t;if(Pe===x&&++me===E&&(J=q),Pe===P&&++_e===v&&(re=q),(Xe=De.nextSibling)!==null)break;De=Pe,Pe=De.parentNode}De=Xe}x=J===-1||re===-1?null:{start:J,end:re}}else x=null}x=x||{start:0,end:0}}else x=null;for(Sg={focusedElem:c,selectionRange:x},Fn=!1,Je=u;Je!==null;)if(u=Je,c=u.child,(u.subtreeFlags&1028)!==0&&c!==null)c.return=u,Je=c;else for(;Je!==null;){u=Je;try{var tt=u.alternate;if((u.flags&1024)!==0)switch(u.tag){case 0:case 11:case 15:break;case 1:if(tt!==null){var rt=tt.memoizedProps,fn=tt.memoizedState,de=u.stateNode,ie=de.getSnapshotBeforeUpdate(u.elementType===u.type?rt:ls(u.type,rt),fn);de.__reactInternalSnapshotBeforeUpdate=ie}break;case 3:var fe=u.stateNode.containerInfo;fe.nodeType===1?fe.textContent="":fe.nodeType===9&&fe.documentElement&&fe.removeChild(fe.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(n(163))}}catch(Fe){un(u,u.return,Fe)}if(c=u.sibling,c!==null){c.return=u.return,Je=c;break}Je=u.return}return tt=kk,kk=!1,tt}function ru(c,u,x){var v=u.updateQueue;if(v=v!==null?v.lastEffect:null,v!==null){var E=v=v.next;do{if((E.tag&c)===c){var P=E.destroy;E.destroy=void 0,P!==void 0&&dx(u,x,P)}E=E.next}while(E!==v)}}function _f(c,u){if(u=u.updateQueue,u=u!==null?u.lastEffect:null,u!==null){var x=u=u.next;do{if((x.tag&c)===c){var v=x.create;x.destroy=v()}x=x.next}while(x!==u)}}function fx(c){var u=c.ref;if(u!==null){var x=c.stateNode;switch(c.tag){case 5:c=x;break;default:c=x}typeof u=="function"?u(c):u.current=c}}function Sk(c){var u=c.alternate;u!==null&&(c.alternate=null,Sk(u)),c.child=null,c.deletions=null,c.sibling=null,c.tag===5&&(u=c.stateNode,u!==null&&(delete u[Ms],delete u[qc],delete u[Tg],delete u[V$],delete u[W$])),c.stateNode=null,c.return=null,c.dependencies=null,c.memoizedProps=null,c.memoizedState=null,c.pendingProps=null,c.stateNode=null,c.updateQueue=null}function Nk(c){return c.tag===5||c.tag===3||c.tag===4}function Ck(c){e:for(;;){for(;c.sibling===null;){if(c.return===null||Nk(c.return))return null;c=c.return}for(c.sibling.return=c.return,c=c.sibling;c.tag!==5&&c.tag!==6&&c.tag!==18;){if(c.flags&2||c.child===null||c.tag===4)continue e;c.child.return=c,c=c.child}if(!(c.flags&2))return c.stateNode}}function px(c,u,x){var v=c.tag;if(v===5||v===6)c=c.stateNode,u?x.nodeType===8?x.parentNode.insertBefore(c,u):x.insertBefore(c,u):(x.nodeType===8?(u=x.parentNode,u.insertBefore(c,x)):(u=x,u.appendChild(c)),x=x._reactRootContainer,x!=null||u.onclick!==null||(u.onclick=cf));else if(v!==4&&(c=c.child,c!==null))for(px(c,u,x),c=c.sibling;c!==null;)px(c,u,x),c=c.sibling}function hx(c,u,x){var v=c.tag;if(v===5||v===6)c=c.stateNode,u?x.insertBefore(c,u):x.appendChild(c);else if(v!==4&&(c=c.child,c!==null))for(hx(c,u,x),c=c.sibling;c!==null;)hx(c,u,x),c=c.sibling}var Wn=null,cs=!1;function Jo(c,u,x){for(x=x.child;x!==null;)Ek(c,u,x),x=x.sibling}function Ek(c,u,x){if(nr&&typeof nr.onCommitFiberUnmount=="function")try{nr.onCommitFiberUnmount(Mo,x)}catch{}switch(x.tag){case 5:Jn||tl(x,u);case 6:var v=Wn,E=cs;Wn=null,Jo(c,u,x),Wn=v,cs=E,Wn!==null&&(cs?(c=Wn,x=x.stateNode,c.nodeType===8?c.parentNode.removeChild(x):c.removeChild(x)):Wn.removeChild(x.stateNode));break;case 18:Wn!==null&&(cs?(c=Wn,x=x.stateNode,c.nodeType===8?Eg(c.parentNode,x):c.nodeType===1&&Eg(c,x),Pt(c)):Eg(Wn,x.stateNode));break;case 4:v=Wn,E=cs,Wn=x.stateNode.containerInfo,cs=!0,Jo(c,u,x),Wn=v,cs=E;break;case 0:case 11:case 14:case 15:if(!Jn&&(v=x.updateQueue,v!==null&&(v=v.lastEffect,v!==null))){E=v=v.next;do{var P=E,q=P.destroy;P=P.tag,q!==void 0&&((P&2)!==0||(P&4)!==0)&&dx(x,u,q),E=E.next}while(E!==v)}Jo(c,u,x);break;case 1:if(!Jn&&(tl(x,u),v=x.stateNode,typeof v.componentWillUnmount=="function"))try{v.props=x.memoizedProps,v.state=x.memoizedState,v.componentWillUnmount()}catch(J){un(x,u,J)}Jo(c,u,x);break;case 21:Jo(c,u,x);break;case 22:x.mode&1?(Jn=(v=Jn)||x.memoizedState!==null,Jo(c,u,x),Jn=v):Jo(c,u,x);break;default:Jo(c,u,x)}}function Tk(c){var u=c.updateQueue;if(u!==null){c.updateQueue=null;var x=c.stateNode;x===null&&(x=c.stateNode=new aI),u.forEach(function(v){var E=xI.bind(null,c,v);x.has(v)||(x.add(v),v.then(E,E))})}}function us(c,u){var x=u.deletions;if(x!==null)for(var v=0;v<x.length;v++){var E=x[v];try{var P=c,q=u,J=q;e:for(;J!==null;){switch(J.tag){case 5:Wn=J.stateNode,cs=!1;break e;case 3:Wn=J.stateNode.containerInfo,cs=!0;break e;case 4:Wn=J.stateNode.containerInfo,cs=!0;break e}J=J.return}if(Wn===null)throw Error(n(160));Ek(P,q,E),Wn=null,cs=!1;var re=E.alternate;re!==null&&(re.return=null),E.return=null}catch(me){un(E,u,me)}}if(u.subtreeFlags&12854)for(u=u.child;u!==null;)Rk(u,c),u=u.sibling}function Rk(c,u){var x=c.alternate,v=c.flags;switch(c.tag){case 0:case 11:case 14:case 15:if(us(u,c),Fs(c),v&4){try{ru(3,c,c.return),_f(3,c)}catch(rt){un(c,c.return,rt)}try{ru(5,c,c.return)}catch(rt){un(c,c.return,rt)}}break;case 1:us(u,c),Fs(c),v&512&&x!==null&&tl(x,x.return);break;case 5:if(us(u,c),Fs(c),v&512&&x!==null&&tl(x,x.return),c.flags&32){var E=c.stateNode;try{Ge(E,"")}catch(rt){un(c,c.return,rt)}}if(v&4&&(E=c.stateNode,E!=null)){var P=c.memoizedProps,q=x!==null?x.memoizedProps:P,J=c.type,re=c.updateQueue;if(c.updateQueue=null,re!==null)try{J==="input"&&P.type==="radio"&&P.name!=null&&we(E,P),X(J,q);var me=X(J,P);for(q=0;q<re.length;q+=2){var _e=re[q],De=re[q+1];_e==="style"?je(E,De):_e==="dangerouslySetInnerHTML"?We(E,De):_e==="children"?Ge(E,De):S(E,_e,De,me)}switch(J){case"input":ke(E,P);break;case"textarea":lt(E,P);break;case"select":var Pe=E._wrapperState.wasMultiple;E._wrapperState.wasMultiple=!!P.multiple;var Xe=P.value;Xe!=null?He(E,!!P.multiple,Xe,!1):Pe!==!!P.multiple&&(P.defaultValue!=null?He(E,!!P.multiple,P.defaultValue,!0):He(E,!!P.multiple,P.multiple?[]:"",!1))}E[qc]=P}catch(rt){un(c,c.return,rt)}}break;case 6:if(us(u,c),Fs(c),v&4){if(c.stateNode===null)throw Error(n(162));E=c.stateNode,P=c.memoizedProps;try{E.nodeValue=P}catch(rt){un(c,c.return,rt)}}break;case 3:if(us(u,c),Fs(c),v&4&&x!==null&&x.memoizedState.isDehydrated)try{Pt(u.containerInfo)}catch(rt){un(c,c.return,rt)}break;case 4:us(u,c),Fs(c);break;case 13:us(u,c),Fs(c),E=c.child,E.flags&8192&&(P=E.memoizedState!==null,E.stateNode.isHidden=P,!P||E.alternate!==null&&E.alternate.memoizedState!==null||(xx=Bt())),v&4&&Tk(c);break;case 22:if(_e=x!==null&&x.memoizedState!==null,c.mode&1?(Jn=(me=Jn)||_e,us(u,c),Jn=me):us(u,c),Fs(c),v&8192){if(me=c.memoizedState!==null,(c.stateNode.isHidden=me)&&!_e&&(c.mode&1)!==0)for(Je=c,_e=c.child;_e!==null;){for(De=Je=_e;Je!==null;){switch(Pe=Je,Xe=Pe.child,Pe.tag){case 0:case 11:case 14:case 15:ru(4,Pe,Pe.return);break;case 1:tl(Pe,Pe.return);var tt=Pe.stateNode;if(typeof tt.componentWillUnmount=="function"){v=Pe,x=Pe.return;try{u=v,tt.props=u.memoizedProps,tt.state=u.memoizedState,tt.componentWillUnmount()}catch(rt){un(v,x,rt)}}break;case 5:tl(Pe,Pe.return);break;case 22:if(Pe.memoizedState!==null){_k(De);continue}}Xe!==null?(Xe.return=Pe,Je=Xe):_k(De)}_e=_e.sibling}e:for(_e=null,De=c;;){if(De.tag===5){if(_e===null){_e=De;try{E=De.stateNode,me?(P=E.style,typeof P.setProperty=="function"?P.setProperty("display","none","important"):P.display="none"):(J=De.stateNode,re=De.memoizedProps.style,q=re!=null&&re.hasOwnProperty("display")?re.display:null,J.style.display=se("display",q))}catch(rt){un(c,c.return,rt)}}}else if(De.tag===6){if(_e===null)try{De.stateNode.nodeValue=me?"":De.memoizedProps}catch(rt){un(c,c.return,rt)}}else if((De.tag!==22&&De.tag!==23||De.memoizedState===null||De===c)&&De.child!==null){De.child.return=De,De=De.child;continue}if(De===c)break e;for(;De.sibling===null;){if(De.return===null||De.return===c)break e;_e===De&&(_e=null),De=De.return}_e===De&&(_e=null),De.sibling.return=De.return,De=De.sibling}}break;case 19:us(u,c),Fs(c),v&4&&Tk(c);break;case 21:break;default:us(u,c),Fs(c)}}function Fs(c){var u=c.flags;if(u&2){try{e:{for(var x=c.return;x!==null;){if(Nk(x)){var v=x;break e}x=x.return}throw Error(n(160))}switch(v.tag){case 5:var E=v.stateNode;v.flags&32&&(Ge(E,""),v.flags&=-33);var P=Ck(c);hx(c,P,E);break;case 3:case 4:var q=v.stateNode.containerInfo,J=Ck(c);px(c,J,q);break;default:throw Error(n(161))}}catch(re){un(c,c.return,re)}c.flags&=-3}u&4096&&(c.flags&=-4097)}function cI(c,u,x){Je=c,Ak(c)}function Ak(c,u,x){for(var v=(c.mode&1)!==0;Je!==null;){var E=Je,P=E.child;if(E.tag===22&&v){var q=E.memoizedState!==null||Pf;if(!q){var J=E.alternate,re=J!==null&&J.memoizedState!==null||Jn;J=Pf;var me=Jn;if(Pf=q,(Jn=re)&&!me)for(Je=E;Je!==null;)q=Je,re=q.child,q.tag===22&&q.memoizedState!==null?Dk(E):re!==null?(re.return=q,Je=re):Dk(E);for(;P!==null;)Je=P,Ak(P),P=P.sibling;Je=E,Pf=J,Jn=me}Pk(c)}else(E.subtreeFlags&8772)!==0&&P!==null?(P.return=E,Je=P):Pk(c)}}function Pk(c){for(;Je!==null;){var u=Je;if((u.flags&8772)!==0){var x=u.alternate;try{if((u.flags&8772)!==0)switch(u.tag){case 0:case 11:case 15:Jn||_f(5,u);break;case 1:var v=u.stateNode;if(u.flags&4&&!Jn)if(x===null)v.componentDidMount();else{var E=u.elementType===u.type?x.memoizedProps:ls(u.type,x.memoizedProps);v.componentDidUpdate(E,x.memoizedState,v.__reactInternalSnapshotBeforeUpdate)}var P=u.updateQueue;P!==null&&_j(u,P,v);break;case 3:var q=u.updateQueue;if(q!==null){if(x=null,u.child!==null)switch(u.child.tag){case 5:x=u.child.stateNode;break;case 1:x=u.child.stateNode}_j(u,q,x)}break;case 5:var J=u.stateNode;if(x===null&&u.flags&4){x=J;var re=u.memoizedProps;switch(u.type){case"button":case"input":case"select":case"textarea":re.autoFocus&&x.focus();break;case"img":re.src&&(x.src=re.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(u.memoizedState===null){var me=u.alternate;if(me!==null){var _e=me.memoizedState;if(_e!==null){var De=_e.dehydrated;De!==null&&Pt(De)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(n(163))}Jn||u.flags&512&&fx(u)}catch(Pe){un(u,u.return,Pe)}}if(u===c){Je=null;break}if(x=u.sibling,x!==null){x.return=u.return,Je=x;break}Je=u.return}}function _k(c){for(;Je!==null;){var u=Je;if(u===c){Je=null;break}var x=u.sibling;if(x!==null){x.return=u.return,Je=x;break}Je=u.return}}function Dk(c){for(;Je!==null;){var u=Je;try{switch(u.tag){case 0:case 11:case 15:var x=u.return;try{_f(4,u)}catch(re){un(u,x,re)}break;case 1:var v=u.stateNode;if(typeof v.componentDidMount=="function"){var E=u.return;try{v.componentDidMount()}catch(re){un(u,E,re)}}var P=u.return;try{fx(u)}catch(re){un(u,P,re)}break;case 5:var q=u.return;try{fx(u)}catch(re){un(u,q,re)}}}catch(re){un(u,u.return,re)}if(u===c){Je=null;break}var J=u.sibling;if(J!==null){J.return=u.return,Je=J;break}Je=u.return}}var uI=Math.ceil,Df=C.ReactCurrentDispatcher,mx=C.ReactCurrentOwner,Yr=C.ReactCurrentBatchConfig,_t=0,Bn=null,hn=null,qn=0,Rr=0,nl=Ko(0),_n=0,su=null,Hi=0,$f=0,gx=0,ou=null,dr=null,xx=0,rl=1/0,go=null,If=!1,yx=null,Zo=null,Mf=!1,ei=null,Lf=0,iu=0,bx=null,Of=-1,Ff=0;function sr(){return(_t&6)!==0?Bt():Of!==-1?Of:Of=Bt()}function ti(c){return(c.mode&1)===0?1:(_t&2)!==0&&qn!==0?qn&-qn:K$.transition!==null?(Ff===0&&(Ff=zo()),Ff):(c=Lt,c!==0||(c=window.event,c=c===void 0?16:os(c.type)),c)}function ds(c,u,x,v){if(50<iu)throw iu=0,bx=null,Error(n(185));zt(c,x,v),((_t&2)===0||c!==Bn)&&(c===Bn&&((_t&2)===0&&($f|=x),_n===4&&ni(c,qn)),fr(c,v),x===1&&_t===0&&(u.mode&1)===0&&(rl=Bt()+500,pf&&Yo()))}function fr(c,u){var x=c.callbackNode;_i(c,u);var v=Vr(c,c===Bn?qn:0);if(v===0)x!==null&&Da(x),c.callbackNode=null,c.callbackPriority=0;else if(u=v&-v,c.callbackPriority!==u){if(x!=null&&Da(x),u===1)c.tag===0?q$(Ik.bind(null,c)):vj(Ik.bind(null,c)),U$(function(){(_t&6)===0&&Yo()}),x=null;else{switch(Xd(v)){case 1:x=ro;break;case 4:x=$o;break;case 16:x=As;break;case 536870912:x=Ia;break;default:x=As}x=Hk(x,$k.bind(null,c))}c.callbackPriority=u,c.callbackNode=x}}function $k(c,u){if(Of=-1,Ff=0,(_t&6)!==0)throw Error(n(327));var x=c.callbackNode;if(sl()&&c.callbackNode!==x)return null;var v=Vr(c,c===Bn?qn:0);if(v===0)return null;if((v&30)!==0||(v&c.expiredLanes)!==0||u)u=zf(c,v);else{u=v;var E=_t;_t|=2;var P=Lk();(Bn!==c||qn!==u)&&(go=null,rl=Bt()+500,Wi(c,u));do try{pI();break}catch(J){Mk(c,J)}while(!0);Lg(),Df.current=P,_t=E,hn!==null?u=0:(Bn=null,qn=0,u=_n)}if(u!==0){if(u===2&&(E=Fo(c),E!==0&&(v=E,u=vx(c,E))),u===1)throw x=su,Wi(c,0),ni(c,v),fr(c,Bt()),x;if(u===6)ni(c,v);else{if(E=c.current.alternate,(v&30)===0&&!dI(E)&&(u=zf(c,v),u===2&&(P=Fo(c),P!==0&&(v=P,u=vx(c,P))),u===1))throw x=su,Wi(c,0),ni(c,v),fr(c,Bt()),x;switch(c.finishedWork=E,c.finishedLanes=v,u){case 0:case 1:throw Error(n(345));case 2:qi(c,dr,go);break;case 3:if(ni(c,v),(v&130023424)===v&&(u=xx+500-Bt(),10<u)){if(Vr(c,0)!==0)break;if(E=c.suspendedLanes,(E&v)!==v){sr(),c.pingedLanes|=c.suspendedLanes&E;break}c.timeoutHandle=Cg(qi.bind(null,c,dr,go),u);break}qi(c,dr,go);break;case 4:if(ni(c,v),(v&4194240)===v)break;for(u=c.eventTimes,E=-1;0<v;){var q=31-On(v);P=1<<q,q=u[q],q>E&&(E=q),v&=~P}if(v=E,v=Bt()-v,v=(120>v?120:480>v?480:1080>v?1080:1920>v?1920:3e3>v?3e3:4320>v?4320:1960*uI(v/1960))-v,10<v){c.timeoutHandle=Cg(qi.bind(null,c,dr,go),v);break}qi(c,dr,go);break;case 5:qi(c,dr,go);break;default:throw Error(n(329))}}}return fr(c,Bt()),c.callbackNode===x?$k.bind(null,c):null}function vx(c,u){var x=ou;return c.current.memoizedState.isDehydrated&&(Wi(c,u).flags|=256),c=zf(c,u),c!==2&&(u=dr,dr=x,u!==null&&wx(u)),c}function wx(c){dr===null?dr=c:dr.push.apply(dr,c)}function dI(c){for(var u=c;;){if(u.flags&16384){var x=u.updateQueue;if(x!==null&&(x=x.stores,x!==null))for(var v=0;v<x.length;v++){var E=x[v],P=E.getSnapshot;E=E.value;try{if(!is(P(),E))return!1}catch{return!1}}}if(x=u.child,u.subtreeFlags&16384&&x!==null)x.return=u,u=x;else{if(u===c)break;for(;u.sibling===null;){if(u.return===null||u.return===c)return!0;u=u.return}u.sibling.return=u.return,u=u.sibling}}return!0}function ni(c,u){for(u&=~gx,u&=~$f,c.suspendedLanes|=u,c.pingedLanes&=~u,c=c.expirationTimes;0<u;){var x=31-On(u),v=1<<x;c[x]=-1,u&=~v}}function Ik(c){if((_t&6)!==0)throw Error(n(327));sl();var u=Vr(c,0);if((u&1)===0)return fr(c,Bt()),null;var x=zf(c,u);if(c.tag!==0&&x===2){var v=Fo(c);v!==0&&(u=v,x=vx(c,v))}if(x===1)throw x=su,Wi(c,0),ni(c,u),fr(c,Bt()),x;if(x===6)throw Error(n(345));return c.finishedWork=c.current.alternate,c.finishedLanes=u,qi(c,dr,go),fr(c,Bt()),null}function jx(c,u){var x=_t;_t|=1;try{return c(u)}finally{_t=x,_t===0&&(rl=Bt()+500,pf&&Yo())}}function Vi(c){ei!==null&&ei.tag===0&&(_t&6)===0&&sl();var u=_t;_t|=1;var x=Yr.transition,v=Lt;try{if(Yr.transition=null,Lt=1,c)return c()}finally{Lt=v,Yr.transition=x,_t=u,(_t&6)===0&&Yo()}}function kx(){Rr=nl.current,Yt(nl)}function Wi(c,u){c.finishedWork=null,c.finishedLanes=0;var x=c.timeoutHandle;if(x!==-1&&(c.timeoutHandle=-1,B$(x)),hn!==null)for(x=hn.return;x!==null;){var v=x;switch(_g(v),v.tag){case 1:v=v.type.childContextTypes,v!=null&&df();break;case 3:Za(),Yt(lr),Yt(Yn),Wg();break;case 5:Hg(v);break;case 4:Za();break;case 13:Yt(an);break;case 19:Yt(an);break;case 10:Og(v.type._context);break;case 22:case 23:kx()}x=x.return}if(Bn=c,hn=c=ri(c.current,null),qn=Rr=u,_n=0,su=null,gx=$f=Hi=0,dr=ou=null,zi!==null){for(u=0;u<zi.length;u++)if(x=zi[u],v=x.interleaved,v!==null){x.interleaved=null;var E=v.next,P=x.pending;if(P!==null){var q=P.next;P.next=E,v.next=q}x.pending=v}zi=null}return c}function Mk(c,u){do{var x=hn;try{if(Lg(),kf.current=Ef,Sf){for(var v=ln.memoizedState;v!==null;){var E=v.queue;E!==null&&(E.pending=null),v=v.next}Sf=!1}if(Ui=0,zn=Pn=ln=null,Jc=!1,Zc=0,mx.current=null,x===null||x.return===null){_n=1,su=u,hn=null;break}e:{var P=c,q=x.return,J=x,re=u;if(u=qn,J.flags|=32768,re!==null&&typeof re=="object"&&typeof re.then=="function"){var me=re,_e=J,De=_e.tag;if((_e.mode&1)===0&&(De===0||De===11||De===15)){var Pe=_e.alternate;Pe?(_e.updateQueue=Pe.updateQueue,_e.memoizedState=Pe.memoizedState,_e.lanes=Pe.lanes):(_e.updateQueue=null,_e.memoizedState=null)}var Xe=ak(q);if(Xe!==null){Xe.flags&=-257,lk(Xe,q,J,P,u),Xe.mode&1&&ik(P,me,u),u=Xe,re=me;var tt=u.updateQueue;if(tt===null){var rt=new Set;rt.add(re),u.updateQueue=rt}else tt.add(re);break e}else{if((u&1)===0){ik(P,me,u),Sx();break e}re=Error(n(426))}}else if(nn&&J.mode&1){var fn=ak(q);if(fn!==null){(fn.flags&65536)===0&&(fn.flags|=256),lk(fn,q,J,P,u),Ig(el(re,J));break e}}P=re=el(re,J),_n!==4&&(_n=2),ou===null?ou=[P]:ou.push(P),P=q;do{switch(P.tag){case 3:P.flags|=65536,u&=-u,P.lanes|=u;var de=sk(P,re,u);Pj(P,de);break e;case 1:J=re;var ie=P.type,fe=P.stateNode;if((P.flags&128)===0&&(typeof ie.getDerivedStateFromError=="function"||fe!==null&&typeof fe.componentDidCatch=="function"&&(Zo===null||!Zo.has(fe)))){P.flags|=65536,u&=-u,P.lanes|=u;var Fe=ok(P,J,u);Pj(P,Fe);break e}}P=P.return}while(P!==null)}Fk(x)}catch(it){u=it,hn===x&&x!==null&&(hn=x=x.return);continue}break}while(!0)}function Lk(){var c=Df.current;return Df.current=Ef,c===null?Ef:c}function Sx(){(_n===0||_n===3||_n===2)&&(_n=4),Bn===null||(Hi&268435455)===0&&($f&268435455)===0||ni(Bn,qn)}function zf(c,u){var x=_t;_t|=2;var v=Lk();(Bn!==c||qn!==u)&&(go=null,Wi(c,u));do try{fI();break}catch(E){Mk(c,E)}while(!0);if(Lg(),_t=x,Df.current=v,hn!==null)throw Error(n(261));return Bn=null,qn=0,_n}function fI(){for(;hn!==null;)Ok(hn)}function pI(){for(;hn!==null&&!Ac();)Ok(hn)}function Ok(c){var u=Uk(c.alternate,c,Rr);c.memoizedProps=c.pendingProps,u===null?Fk(c):hn=u,mx.current=null}function Fk(c){var u=c;do{var x=u.alternate;if(c=u.return,(u.flags&32768)===0){if(x=oI(x,u,Rr),x!==null){hn=x;return}}else{if(x=iI(x,u),x!==null){x.flags&=32767,hn=x;return}if(c!==null)c.flags|=32768,c.subtreeFlags=0,c.deletions=null;else{_n=6,hn=null;return}}if(u=u.sibling,u!==null){hn=u;return}hn=u=c}while(u!==null);_n===0&&(_n=5)}function qi(c,u,x){var v=Lt,E=Yr.transition;try{Yr.transition=null,Lt=1,hI(c,u,x,v)}finally{Yr.transition=E,Lt=v}return null}function hI(c,u,x,v){do sl();while(ei!==null);if((_t&6)!==0)throw Error(n(327));x=c.finishedWork;var E=c.finishedLanes;if(x===null)return null;if(c.finishedWork=null,c.finishedLanes=0,x===c.current)throw Error(n(177));c.callbackNode=null,c.callbackPriority=0;var P=x.lanes|x.childLanes;if(oo(c,P),c===Bn&&(hn=Bn=null,qn=0),(x.subtreeFlags&2064)===0&&(x.flags&2064)===0||Mf||(Mf=!0,Hk(As,function(){return sl(),null})),P=(x.flags&15990)!==0,(x.subtreeFlags&15990)!==0||P){P=Yr.transition,Yr.transition=null;var q=Lt;Lt=1;var J=_t;_t|=4,mx.current=null,lI(c,x),Rk(x,c),$$(Sg),Fn=!!kg,Sg=kg=null,c.current=x,cI(x),$a(),_t=J,Lt=q,Yr.transition=P}else c.current=x;if(Mf&&(Mf=!1,ei=c,Lf=E),P=c.pendingLanes,P===0&&(Zo=null),ar(x.stateNode),fr(c,Bt()),u!==null)for(v=c.onRecoverableError,x=0;x<u.length;x++)E=u[x],v(E.value,{componentStack:E.stack,digest:E.digest});if(If)throw If=!1,c=yx,yx=null,c;return(Lf&1)!==0&&c.tag!==0&&sl(),P=c.pendingLanes,(P&1)!==0?c===bx?iu++:(iu=0,bx=c):iu=0,Yo(),null}function sl(){if(ei!==null){var c=Xd(Lf),u=Yr.transition,x=Lt;try{if(Yr.transition=null,Lt=16>c?16:c,ei===null)var v=!1;else{if(c=ei,ei=null,Lf=0,(_t&6)!==0)throw Error(n(331));var E=_t;for(_t|=4,Je=c.current;Je!==null;){var P=Je,q=P.child;if((Je.flags&16)!==0){var J=P.deletions;if(J!==null){for(var re=0;re<J.length;re++){var me=J[re];for(Je=me;Je!==null;){var _e=Je;switch(_e.tag){case 0:case 11:case 15:ru(8,_e,P)}var De=_e.child;if(De!==null)De.return=_e,Je=De;else for(;Je!==null;){_e=Je;var Pe=_e.sibling,Xe=_e.return;if(Sk(_e),_e===me){Je=null;break}if(Pe!==null){Pe.return=Xe,Je=Pe;break}Je=Xe}}}var tt=P.alternate;if(tt!==null){var rt=tt.child;if(rt!==null){tt.child=null;do{var fn=rt.sibling;rt.sibling=null,rt=fn}while(rt!==null)}}Je=P}}if((P.subtreeFlags&2064)!==0&&q!==null)q.return=P,Je=q;else e:for(;Je!==null;){if(P=Je,(P.flags&2048)!==0)switch(P.tag){case 0:case 11:case 15:ru(9,P,P.return)}var de=P.sibling;if(de!==null){de.return=P.return,Je=de;break e}Je=P.return}}var ie=c.current;for(Je=ie;Je!==null;){q=Je;var fe=q.child;if((q.subtreeFlags&2064)!==0&&fe!==null)fe.return=q,Je=fe;else e:for(q=ie;Je!==null;){if(J=Je,(J.flags&2048)!==0)try{switch(J.tag){case 0:case 11:case 15:_f(9,J)}}catch(it){un(J,J.return,it)}if(J===q){Je=null;break e}var Fe=J.sibling;if(Fe!==null){Fe.return=J.return,Je=Fe;break e}Je=J.return}}if(_t=E,Yo(),nr&&typeof nr.onPostCommitFiberRoot=="function")try{nr.onPostCommitFiberRoot(Mo,c)}catch{}v=!0}return v}finally{Lt=x,Yr.transition=u}}return!1}function zk(c,u,x){u=el(x,u),u=sk(c,u,1),c=Qo(c,u,1),u=sr(),c!==null&&(zt(c,1,u),fr(c,u))}function un(c,u,x){if(c.tag===3)zk(c,c,x);else for(;u!==null;){if(u.tag===3){zk(u,c,x);break}else if(u.tag===1){var v=u.stateNode;if(typeof u.type.getDerivedStateFromError=="function"||typeof v.componentDidCatch=="function"&&(Zo===null||!Zo.has(v))){c=el(x,c),c=ok(u,c,1),u=Qo(u,c,1),c=sr(),u!==null&&(zt(u,1,c),fr(u,c));break}}u=u.return}}function mI(c,u,x){var v=c.pingCache;v!==null&&v.delete(u),u=sr(),c.pingedLanes|=c.suspendedLanes&x,Bn===c&&(qn&x)===x&&(_n===4||_n===3&&(qn&130023424)===qn&&500>Bt()-xx?Wi(c,0):gx|=x),fr(c,u)}function Bk(c,u){u===0&&((c.mode&1)===0?u=1:(u=Vn,Vn<<=1,(Vn&130023424)===0&&(Vn=4194304)));var x=sr();c=po(c,u),c!==null&&(zt(c,u,x),fr(c,x))}function gI(c){var u=c.memoizedState,x=0;u!==null&&(x=u.retryLane),Bk(c,x)}function xI(c,u){var x=0;switch(c.tag){case 13:var v=c.stateNode,E=c.memoizedState;E!==null&&(x=E.retryLane);break;case 19:v=c.stateNode;break;default:throw Error(n(314))}v!==null&&v.delete(u),Bk(c,x)}var Uk;Uk=function(c,u,x){if(c!==null)if(c.memoizedProps!==u.pendingProps||lr.current)ur=!0;else{if((c.lanes&x)===0&&(u.flags&128)===0)return ur=!1,sI(c,u,x);ur=(c.flags&131072)!==0}else ur=!1,nn&&(u.flags&1048576)!==0&&wj(u,mf,u.index);switch(u.lanes=0,u.tag){case 2:var v=u.type;Af(c,u),c=u.pendingProps;var E=qa(u,Yn.current);Ja(u,x),E=Gg(null,u,v,c,E,x);var P=Yg();return u.flags|=1,typeof E=="object"&&E!==null&&typeof E.render=="function"&&E.$$typeof===void 0?(u.tag=1,u.memoizedState=null,u.updateQueue=null,cr(v)?(P=!0,ff(u)):P=!1,u.memoizedState=E.state!==null&&E.state!==void 0?E.state:null,Bg(u),E.updater=Tf,u.stateNode=E,E._reactInternals=u,tx(u,v,c,x),u=ox(null,u,v,!0,P,x)):(u.tag=0,nn&&P&&Pg(u),rr(null,u,E,x),u=u.child),u;case 16:v=u.elementType;e:{switch(Af(c,u),c=u.pendingProps,E=v._init,v=E(v._payload),u.type=v,E=u.tag=bI(v),c=ls(v,c),E){case 0:u=sx(null,u,v,c,x);break e;case 1:u=hk(null,u,v,c,x);break e;case 11:u=ck(null,u,v,c,x);break e;case 14:u=uk(null,u,v,ls(v.type,c),x);break e}throw Error(n(306,v,""))}return u;case 0:return v=u.type,E=u.pendingProps,E=u.elementType===v?E:ls(v,E),sx(c,u,v,E,x);case 1:return v=u.type,E=u.pendingProps,E=u.elementType===v?E:ls(v,E),hk(c,u,v,E,x);case 3:e:{if(mk(u),c===null)throw Error(n(387));v=u.pendingProps,P=u.memoizedState,E=P.element,Aj(c,u),wf(u,v,null,x);var q=u.memoizedState;if(v=q.element,P.isDehydrated)if(P={element:v,isDehydrated:!1,cache:q.cache,pendingSuspenseBoundaries:q.pendingSuspenseBoundaries,transitions:q.transitions},u.updateQueue.baseState=P,u.memoizedState=P,u.flags&256){E=el(Error(n(423)),u),u=gk(c,u,v,x,E);break e}else if(v!==E){E=el(Error(n(424)),u),u=gk(c,u,v,x,E);break e}else for(Tr=qo(u.stateNode.containerInfo.firstChild),Er=u,nn=!0,as=null,x=Tj(u,null,v,x),u.child=x;x;)x.flags=x.flags&-3|4096,x=x.sibling;else{if(Ya(),v===E){u=mo(c,u,x);break e}rr(c,u,v,x)}u=u.child}return u;case 5:return Dj(u),c===null&&$g(u),v=u.type,E=u.pendingProps,P=c!==null?c.memoizedProps:null,q=E.children,Ng(v,E)?q=null:P!==null&&Ng(v,P)&&(u.flags|=32),pk(c,u),rr(c,u,q,x),u.child;case 6:return c===null&&$g(u),null;case 13:return xk(c,u,x);case 4:return Ug(u,u.stateNode.containerInfo),v=u.pendingProps,c===null?u.child=Xa(u,null,v,x):rr(c,u,v,x),u.child;case 11:return v=u.type,E=u.pendingProps,E=u.elementType===v?E:ls(v,E),ck(c,u,v,E,x);case 7:return rr(c,u,u.pendingProps,x),u.child;case 8:return rr(c,u,u.pendingProps.children,x),u.child;case 12:return rr(c,u,u.pendingProps.children,x),u.child;case 10:e:{if(v=u.type._context,E=u.pendingProps,P=u.memoizedProps,q=E.value,Wt(yf,v._currentValue),v._currentValue=q,P!==null)if(is(P.value,q)){if(P.children===E.children&&!lr.current){u=mo(c,u,x);break e}}else for(P=u.child,P!==null&&(P.return=u);P!==null;){var J=P.dependencies;if(J!==null){q=P.child;for(var re=J.firstContext;re!==null;){if(re.context===v){if(P.tag===1){re=ho(-1,x&-x),re.tag=2;var me=P.updateQueue;if(me!==null){me=me.shared;var _e=me.pending;_e===null?re.next=re:(re.next=_e.next,_e.next=re),me.pending=re}}P.lanes|=x,re=P.alternate,re!==null&&(re.lanes|=x),Fg(P.return,x,u),J.lanes|=x;break}re=re.next}}else if(P.tag===10)q=P.type===u.type?null:P.child;else if(P.tag===18){if(q=P.return,q===null)throw Error(n(341));q.lanes|=x,J=q.alternate,J!==null&&(J.lanes|=x),Fg(q,x,u),q=P.sibling}else q=P.child;if(q!==null)q.return=P;else for(q=P;q!==null;){if(q===u){q=null;break}if(P=q.sibling,P!==null){P.return=q.return,q=P;break}q=q.return}P=q}rr(c,u,E.children,x),u=u.child}return u;case 9:return E=u.type,v=u.pendingProps.children,Ja(u,x),E=Kr(E),v=v(E),u.flags|=1,rr(c,u,v,x),u.child;case 14:return v=u.type,E=ls(v,u.pendingProps),E=ls(v.type,E),uk(c,u,v,E,x);case 15:return dk(c,u,u.type,u.pendingProps,x);case 17:return v=u.type,E=u.pendingProps,E=u.elementType===v?E:ls(v,E),Af(c,u),u.tag=1,cr(v)?(c=!0,ff(u)):c=!1,Ja(u,x),nk(u,v,E),tx(u,v,E,x),ox(null,u,v,!0,c,x);case 19:return bk(c,u,x);case 22:return fk(c,u,x)}throw Error(n(156,u.tag))};function Hk(c,u){return _a(c,u)}function yI(c,u,x,v){this.tag=c,this.key=x,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=u,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=v,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Xr(c,u,x,v){return new yI(c,u,x,v)}function Nx(c){return c=c.prototype,!(!c||!c.isReactComponent)}function bI(c){if(typeof c=="function")return Nx(c)?1:0;if(c!=null){if(c=c.$$typeof,c===F)return 11;if(c===L)return 14}return 2}function ri(c,u){var x=c.alternate;return x===null?(x=Xr(c.tag,u,c.key,c.mode),x.elementType=c.elementType,x.type=c.type,x.stateNode=c.stateNode,x.alternate=c,c.alternate=x):(x.pendingProps=u,x.type=c.type,x.flags=0,x.subtreeFlags=0,x.deletions=null),x.flags=c.flags&14680064,x.childLanes=c.childLanes,x.lanes=c.lanes,x.child=c.child,x.memoizedProps=c.memoizedProps,x.memoizedState=c.memoizedState,x.updateQueue=c.updateQueue,u=c.dependencies,x.dependencies=u===null?null:{lanes:u.lanes,firstContext:u.firstContext},x.sibling=c.sibling,x.index=c.index,x.ref=c.ref,x}function Bf(c,u,x,v,E,P){var q=2;if(v=c,typeof c=="function")Nx(c)&&(q=1);else if(typeof c=="string")q=5;else e:switch(c){case R:return Ki(x.children,E,P,u);case $:q=8,E|=8;break;case _:return c=Xr(12,x,u,E|2),c.elementType=_,c.lanes=P,c;case M:return c=Xr(13,x,u,E),c.elementType=M,c.lanes=P,c;case A:return c=Xr(19,x,u,E),c.elementType=A,c.lanes=P,c;case W:return Uf(x,E,P,u);default:if(typeof c=="object"&&c!==null)switch(c.$$typeof){case U:q=10;break e;case I:q=9;break e;case F:q=11;break e;case L:q=14;break e;case z:q=16,v=null;break e}throw Error(n(130,c==null?c:typeof c,""))}return u=Xr(q,x,u,E),u.elementType=c,u.type=v,u.lanes=P,u}function Ki(c,u,x,v){return c=Xr(7,c,v,u),c.lanes=x,c}function Uf(c,u,x,v){return c=Xr(22,c,v,u),c.elementType=W,c.lanes=x,c.stateNode={isHidden:!1},c}function Cx(c,u,x){return c=Xr(6,c,null,u),c.lanes=x,c}function Ex(c,u,x){return u=Xr(4,c.children!==null?c.children:[],c.key,u),u.lanes=x,u.stateNode={containerInfo:c.containerInfo,pendingChildren:null,implementation:c.implementation},u}function vI(c,u,x,v,E){this.tag=u,this.containerInfo=c,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Ps(0),this.expirationTimes=Ps(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Ps(0),this.identifierPrefix=v,this.onRecoverableError=E,this.mutableSourceEagerHydrationData=null}function Tx(c,u,x,v,E,P,q,J,re){return c=new vI(c,u,x,J,re),u===1?(u=1,P===!0&&(u|=8)):u=0,P=Xr(3,null,null,u),c.current=P,P.stateNode=c,P.memoizedState={element:v,isDehydrated:x,cache:null,transitions:null,pendingSuspenseBoundaries:null},Bg(P),c}function wI(c,u,x){var v=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:T,key:v==null?null:""+v,children:c,containerInfo:u,implementation:x}}function Vk(c){if(!c)return Go;c=c._reactInternals;e:{if(bt(c)!==c||c.tag!==1)throw Error(n(170));var u=c;do{switch(u.tag){case 3:u=u.stateNode.context;break e;case 1:if(cr(u.type)){u=u.stateNode.__reactInternalMemoizedMergedChildContext;break e}}u=u.return}while(u!==null);throw Error(n(171))}if(c.tag===1){var x=c.type;if(cr(x))return yj(c,x,u)}return u}function Wk(c,u,x,v,E,P,q,J,re){return c=Tx(x,v,!0,c,E,P,q,J,re),c.context=Vk(null),x=c.current,v=sr(),E=ti(x),P=ho(v,E),P.callback=u??null,Qo(x,P,E),c.current.lanes=E,zt(c,E,v),fr(c,v),c}function Hf(c,u,x,v){var E=u.current,P=sr(),q=ti(E);return x=Vk(x),u.context===null?u.context=x:u.pendingContext=x,u=ho(P,q),u.payload={element:c},v=v===void 0?null:v,v!==null&&(u.callback=v),c=Qo(E,u,q),c!==null&&(ds(c,E,q,P),vf(c,E,q)),q}function Vf(c){if(c=c.current,!c.child)return null;switch(c.child.tag){case 5:return c.child.stateNode;default:return c.child.stateNode}}function qk(c,u){if(c=c.memoizedState,c!==null&&c.dehydrated!==null){var x=c.retryLane;c.retryLane=x!==0&&x<u?x:u}}function Rx(c,u){qk(c,u),(c=c.alternate)&&qk(c,u)}function jI(){return null}var Kk=typeof reportError=="function"?reportError:function(c){console.error(c)};function Ax(c){this._internalRoot=c}Wf.prototype.render=Ax.prototype.render=function(c){var u=this._internalRoot;if(u===null)throw Error(n(409));Hf(c,u,null,null)},Wf.prototype.unmount=Ax.prototype.unmount=function(){var c=this._internalRoot;if(c!==null){this._internalRoot=null;var u=c.containerInfo;Vi(function(){Hf(null,c,null,null)}),u[lo]=null}};function Wf(c){this._internalRoot=c}Wf.prototype.unstable_scheduleHydration=function(c){if(c){var u=io();c={blockedOn:null,target:c,priority:u};for(var x=0;x<Is.length&&u!==0&&u<Is[x].priority;x++);Is.splice(x,0,c),x===0&&ee(c)}};function Px(c){return!(!c||c.nodeType!==1&&c.nodeType!==9&&c.nodeType!==11)}function qf(c){return!(!c||c.nodeType!==1&&c.nodeType!==9&&c.nodeType!==11&&(c.nodeType!==8||c.nodeValue!==" react-mount-point-unstable "))}function Gk(){}function kI(c,u,x,v,E){if(E){if(typeof v=="function"){var P=v;v=function(){var me=Vf(q);P.call(me)}}var q=Wk(u,v,c,0,null,!1,!1,"",Gk);return c._reactRootContainer=q,c[lo]=q.current,Vc(c.nodeType===8?c.parentNode:c),Vi(),q}for(;E=c.lastChild;)c.removeChild(E);if(typeof v=="function"){var J=v;v=function(){var me=Vf(re);J.call(me)}}var re=Tx(c,0,!1,null,null,!1,!1,"",Gk);return c._reactRootContainer=re,c[lo]=re.current,Vc(c.nodeType===8?c.parentNode:c),Vi(function(){Hf(u,re,x,v)}),re}function Kf(c,u,x,v,E){var P=x._reactRootContainer;if(P){var q=P;if(typeof E=="function"){var J=E;E=function(){var re=Vf(q);J.call(re)}}Hf(u,q,c,E)}else q=kI(x,u,c,E,v);return Vf(q)}Dc=function(c){switch(c.tag){case 3:var u=c.stateNode;if(u.current.memoizedState.isDehydrated){var x=so(u.pendingLanes);x!==0&&(_s(u,x|1),fr(u,Bt()),(_t&6)===0&&(rl=Bt()+500,Yo()))}break;case 13:Vi(function(){var v=po(c,1);if(v!==null){var E=sr();ds(v,c,1,E)}}),Rx(c,1)}},Di=function(c){if(c.tag===13){var u=po(c,134217728);if(u!==null){var x=sr();ds(u,c,134217728,x)}Rx(c,134217728)}},$c=function(c){if(c.tag===13){var u=ti(c),x=po(c,u);if(x!==null){var v=sr();ds(x,c,u,v)}Rx(c,u)}},io=function(){return Lt},Ic=function(c,u){var x=Lt;try{return Lt=c,u()}finally{Lt=x}},ft=function(c,u,x){switch(u){case"input":if(ke(c,x),u=x.name,x.type==="radio"&&u!=null){for(x=c;x.parentNode;)x=x.parentNode;for(x=x.querySelectorAll("input[name="+JSON.stringify(""+u)+'][type="radio"]'),u=0;u<x.length;u++){var v=x[u];if(v!==c&&v.form===c.form){var E=uf(v);if(!E)throw Error(n(90));Re(v),ke(v,E)}}}break;case"textarea":lt(c,x);break;case"select":u=x.value,u!=null&&He(c,!!x.multiple,u,!1)}},Ye=jx,Nt=Vi;var SI={usingClientEntryPoint:!1,Events:[Kc,Va,uf,he,Ee,jx]},au={findFiberByHostInstance:Mi,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},NI={bundleType:au.bundleType,version:au.version,rendererPackageName:au.rendererPackageName,rendererConfig:au.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:C.ReactCurrentDispatcher,findHostInstanceByFiber:function(c){return c=tn(c),c===null?null:c.stateNode},findFiberByHostInstance:au.findFiberByHostInstance||jI,findHostInstancesForRefresh:null,scheduleRefresh:null,scheduleRoot:null,setRefreshHandler:null,getCurrentFiber:null,reconcilerVersion:"18.3.1-next-f1338f8080-20240426"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var Gf=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Gf.isDisabled&&Gf.supportsFiber)try{Mo=Gf.inject(NI),nr=Gf}catch{}}return pr.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=SI,pr.createPortal=function(c,u){var x=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!Px(u))throw Error(n(200));return wI(c,u,null,x)},pr.createRoot=function(c,u){if(!Px(c))throw Error(n(299));var x=!1,v="",E=Kk;return u!=null&&(u.unstable_strictMode===!0&&(x=!0),u.identifierPrefix!==void 0&&(v=u.identifierPrefix),u.onRecoverableError!==void 0&&(E=u.onRecoverableError)),u=Tx(c,1,!1,null,null,x,!1,v,E),c[lo]=u.current,Vc(c.nodeType===8?c.parentNode:c),new Ax(u)},pr.findDOMNode=function(c){if(c==null)return null;if(c.nodeType===1)return c;var u=c._reactInternals;if(u===void 0)throw typeof c.render=="function"?Error(n(188)):(c=Object.keys(c).join(","),Error(n(268,c)));return c=tn(u),c=c===null?null:c.stateNode,c},pr.flushSync=function(c){return Vi(c)},pr.hydrate=function(c,u,x){if(!qf(u))throw Error(n(200));return Kf(null,c,u,!0,x)},pr.hydrateRoot=function(c,u,x){if(!Px(c))throw Error(n(405));var v=x!=null&&x.hydratedSources||null,E=!1,P="",q=Kk;if(x!=null&&(x.unstable_strictMode===!0&&(E=!0),x.identifierPrefix!==void 0&&(P=x.identifierPrefix),x.onRecoverableError!==void 0&&(q=x.onRecoverableError)),u=Wk(u,null,c,1,x??null,E,!1,P,q),c[lo]=u.current,Vc(c),v)for(c=0;c<v.length;c++)x=v[c],E=x._getVersion,E=E(x._source),u.mutableSourceEagerHydrationData==null?u.mutableSourceEagerHydrationData=[x,E]:u.mutableSourceEagerHydrationData.push(x,E);return new Wf(u)},pr.render=function(c,u,x){if(!qf(u))throw Error(n(200));return Kf(null,c,u,!1,x)},pr.unmountComponentAtNode=function(c){if(!qf(c))throw Error(n(40));return c._reactRootContainer?(Vi(function(){Kf(null,null,c,!1,function(){c._reactRootContainer=null,c[lo]=null})}),!0):!1},pr.unstable_batchedUpdates=jx,pr.unstable_renderSubtreeIntoContainer=function(c,u,x,v){if(!qf(x))throw Error(n(200));if(c==null||c._reactInternals===void 0)throw Error(n(38));return Kf(c,u,x,!1,v)},pr.version="18.3.1-next-f1338f8080-20240426",pr}var n1;function SE(){if(n1)return Ix.exports;n1=1;function e(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}return e(),Ix.exports=II(),Ix.exports}var r1;function MI(){if(r1)return Yf;r1=1;var e=SE();return Yf.createRoot=e.createRoot,Yf.hydrateRoot=e.hydrateRoot,Yf}var LI=MI();/**
41
+ * react-router v7.13.1
42
+ *
43
+ * Copyright (c) Remix Software Inc.
44
+ *
45
+ * This source code is licensed under the MIT license found in the
46
+ * LICENSE.md file in the root directory of this source tree.
47
+ *
48
+ * @license MIT
49
+ */var s1="popstate";function o1(e){return typeof e=="object"&&e!=null&&"pathname"in e&&"search"in e&&"hash"in e&&"state"in e&&"key"in e}function OI(e={}){function t(r,o){var f;let i=(f=o.state)==null?void 0:f.masked,{pathname:a,search:l,hash:d}=i||r.location;return ib("",{pathname:a,search:l,hash:d},o.state&&o.state.usr||null,o.state&&o.state.key||"default",i?{pathname:r.location.pathname,search:r.location.search,hash:r.location.hash}:void 0)}function n(r,o){return typeof o=="string"?o:Gu(o)}return zI(t,n,null,e)}function cn(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function xs(e,t){if(!e){typeof console<"u"&&console.warn(t);try{throw new Error(t)}catch{}}}function FI(){return Math.random().toString(36).substring(2,10)}function i1(e,t){return{usr:e.state,key:e.key,idx:t,masked:e.unstable_mask?{pathname:e.pathname,search:e.search,hash:e.hash}:void 0}}function ib(e,t,n=null,r,o){return{pathname:typeof e=="string"?e:e.pathname,search:"",hash:"",...typeof t=="string"?lc(t):t,state:n,key:t&&t.key||r||FI(),unstable_mask:o}}function Gu({pathname:e="/",search:t="",hash:n=""}){return t&&t!=="?"&&(e+=t.charAt(0)==="?"?t:"?"+t),n&&n!=="#"&&(e+=n.charAt(0)==="#"?n:"#"+n),e}function lc(e){let t={};if(e){let n=e.indexOf("#");n>=0&&(t.hash=e.substring(n),e=e.substring(0,n));let r=e.indexOf("?");r>=0&&(t.search=e.substring(r),e=e.substring(0,r)),e&&(t.pathname=e)}return t}function zI(e,t,n,r={}){let{window:o=document.defaultView,v5Compat:i=!1}=r,a=o.history,l="POP",d=null,f=p();f==null&&(f=0,a.replaceState({...a.state,idx:f},""));function p(){return(a.state||{idx:null}).idx}function h(){l="POP";let b=p(),j=b==null?null:b-f;f=b,d&&d({action:l,location:w.location,delta:j})}function g(b,j){l="PUSH";let N=o1(b)?b:ib(w.location,b,j);f=p()+1;let S=i1(N,f),C=w.createHref(N.unstable_mask||N);try{a.pushState(S,"",C)}catch(D){if(D instanceof DOMException&&D.name==="DataCloneError")throw D;o.location.assign(C)}i&&d&&d({action:l,location:w.location,delta:1})}function y(b,j){l="REPLACE";let N=o1(b)?b:ib(w.location,b,j);f=p();let S=i1(N,f),C=w.createHref(N.unstable_mask||N);a.replaceState(S,"",C),i&&d&&d({action:l,location:w.location,delta:0})}function k(b){return BI(b)}let w={get action(){return l},get location(){return e(o,a)},listen(b){if(d)throw new Error("A history only accepts one active listener");return o.addEventListener(s1,h),d=b,()=>{o.removeEventListener(s1,h),d=null}},createHref(b){return t(o,b)},createURL:k,encodeLocation(b){let j=k(b);return{pathname:j.pathname,search:j.search,hash:j.hash}},push:g,replace:y,go(b){return a.go(b)}};return w}function BI(e,t=!1){let n="http://localhost";typeof window<"u"&&(n=window.location.origin!=="null"?window.location.origin:window.location.href),cn(n,"No window.location.(origin|href) available to create URL");let r=typeof e=="string"?e:Gu(e);return r=r.replace(/ $/,"%20"),!t&&r.startsWith("//")&&(r=n+r),new URL(r,n)}function NE(e,t,n="/"){return UI(e,t,n,!1)}function UI(e,t,n,r){let o=typeof t=="string"?lc(t):t,i=No(o.pathname||"/",n);if(i==null)return null;let a=CE(e);HI(a);let l=null;for(let d=0;l==null&&d<a.length;++d){let f=eM(i);l=JI(a[d],f,r)}return l}function CE(e,t=[],n=[],r="",o=!1){let i=(a,l,d=o,f)=>{let p={relativePath:f===void 0?a.path||"":f,caseSensitive:a.caseSensitive===!0,childrenIndex:l,route:a};if(p.relativePath.startsWith("/")){if(!p.relativePath.startsWith(r)&&d)return;cn(p.relativePath.startsWith(r),`Absolute route path "${p.relativePath}" nested under path "${r}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),p.relativePath=p.relativePath.slice(r.length)}let h=Ks([r,p.relativePath]),g=n.concat(p);a.children&&a.children.length>0&&(cn(a.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${h}".`),CE(a.children,t,g,h,d)),!(a.path==null&&!a.index)&&t.push({path:h,score:XI(h,a.index),routesMeta:g})};return e.forEach((a,l)=>{var d;if(a.path===""||!((d=a.path)!=null&&d.includes("?")))i(a,l);else for(let f of EE(a.path))i(a,l,!0,f)}),t}function EE(e){let t=e.split("/");if(t.length===0)return[];let[n,...r]=t,o=n.endsWith("?"),i=n.replace(/\?$/,"");if(r.length===0)return o?[i,""]:[i];let a=EE(r.join("/")),l=[];return l.push(...a.map(d=>d===""?i:[i,d].join("/"))),o&&l.push(...a),l.map(d=>e.startsWith("/")&&d===""?"/":d)}function HI(e){e.sort((t,n)=>t.score!==n.score?n.score-t.score:QI(t.routesMeta.map(r=>r.childrenIndex),n.routesMeta.map(r=>r.childrenIndex)))}var VI=/^:[\w-]+$/,WI=3,qI=2,KI=1,GI=10,YI=-2,a1=e=>e==="*";function XI(e,t){let n=e.split("/"),r=n.length;return n.some(a1)&&(r+=YI),t&&(r+=qI),n.filter(o=>!a1(o)).reduce((o,i)=>o+(VI.test(i)?WI:i===""?KI:GI),r)}function QI(e,t){return e.length===t.length&&e.slice(0,-1).every((r,o)=>r===t[o])?e[e.length-1]-t[t.length-1]:0}function JI(e,t,n=!1){let{routesMeta:r}=e,o={},i="/",a=[];for(let l=0;l<r.length;++l){let d=r[l],f=l===r.length-1,p=i==="/"?t:t.slice(i.length)||"/",h=Xp({path:d.relativePath,caseSensitive:d.caseSensitive,end:f},p),g=d.route;if(!h&&f&&n&&!r[r.length-1].route.index&&(h=Xp({path:d.relativePath,caseSensitive:d.caseSensitive,end:!1},p)),!h)return null;Object.assign(o,h.params),a.push({params:o,pathname:Ks([i,h.pathname]),pathnameBase:sM(Ks([i,h.pathnameBase])),route:g}),h.pathnameBase!=="/"&&(i=Ks([i,h.pathnameBase]))}return a}function Xp(e,t){typeof e=="string"&&(e={path:e,caseSensitive:!1,end:!0});let[n,r]=ZI(e.path,e.caseSensitive,e.end),o=t.match(n);if(!o)return null;let i=o[0],a=i.replace(/(.)\/+$/,"$1"),l=o.slice(1);return{params:r.reduce((f,{paramName:p,isOptional:h},g)=>{if(p==="*"){let k=l[g]||"";a=i.slice(0,i.length-k.length).replace(/(.)\/+$/,"$1")}const y=l[g];return h&&!y?f[p]=void 0:f[p]=(y||"").replace(/%2F/g,"/"),f},{}),pathname:i,pathnameBase:a,pattern:e}}function ZI(e,t=!1,n=!0){xs(e==="*"||!e.endsWith("*")||e.endsWith("/*"),`Route path "${e}" will be treated as if it were "${e.replace(/\*$/,"/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${e.replace(/\*$/,"/*")}".`);let r=[],o="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(a,l,d,f,p)=>{if(r.push({paramName:l,isOptional:d!=null}),d){let h=p.charAt(f+a.length);return h&&h!=="/"?"/([^\\/]*)":"(?:/([^\\/]*))?"}return"/([^\\/]+)"}).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return e.endsWith("*")?(r.push({paramName:"*"}),o+=e==="*"||e==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):n?o+="\\/*$":e!==""&&e!=="/"&&(o+="(?:(?=\\/|$))"),[new RegExp(o,t?void 0:"i"),r]}function eM(e){try{return e.split("/").map(t=>decodeURIComponent(t).replace(/\//g,"%2F")).join("/")}catch(t){return xs(!1,`The URL path "${e}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${t}).`),e}}function No(e,t){if(t==="/")return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let n=t.endsWith("/")?t.length-1:t.length,r=e.charAt(n);return r&&r!=="/"?null:e.slice(n)||"/"}var tM=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;function nM(e,t="/"){let{pathname:n,search:r="",hash:o=""}=typeof e=="string"?lc(e):e,i;return n?(n=n.replace(/\/\/+/g,"/"),n.startsWith("/")?i=l1(n.substring(1),"/"):i=l1(n,t)):i=t,{pathname:i,search:oM(r),hash:iM(o)}}function l1(e,t){let n=t.replace(/\/+$/,"").split("/");return e.split("/").forEach(o=>{o===".."?n.length>1&&n.pop():o!=="."&&n.push(o)}),n.length>1?n.join("/"):"/"}function Ox(e,t,n,r){return`Cannot include a '${e}' character in a manually specified \`to.${t}\` field [${JSON.stringify(r)}]. Please separate it out to the \`to.${n}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`}function rM(e){return e.filter((t,n)=>n===0||t.route.path&&t.route.path.length>0)}function TE(e){let t=rM(e);return t.map((n,r)=>r===t.length-1?n.pathname:n.pathnameBase)}function jv(e,t,n,r=!1){let o;typeof e=="string"?o=lc(e):(o={...e},cn(!o.pathname||!o.pathname.includes("?"),Ox("?","pathname","search",o)),cn(!o.pathname||!o.pathname.includes("#"),Ox("#","pathname","hash",o)),cn(!o.search||!o.search.includes("#"),Ox("#","search","hash",o)));let i=e===""||o.pathname==="",a=i?"/":o.pathname,l;if(a==null)l=n;else{let h=t.length-1;if(!r&&a.startsWith("..")){let g=a.split("/");for(;g[0]==="..";)g.shift(),h-=1;o.pathname=g.join("/")}l=h>=0?t[h]:"/"}let d=nM(o,l),f=a&&a!=="/"&&a.endsWith("/"),p=(i||a===".")&&n.endsWith("/");return!d.pathname.endsWith("/")&&(f||p)&&(d.pathname+="/"),d}var Ks=e=>e.join("/").replace(/\/\/+/g,"/"),sM=e=>e.replace(/\/+$/,"").replace(/^\/*/,"/"),oM=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,iM=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e,aM=class{constructor(e,t,n,r=!1){this.status=e,this.statusText=t||"",this.internal=r,n instanceof Error?(this.data=n.toString(),this.error=n):this.data=n}};function lM(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}function cM(e){return e.map(t=>t.route.path).filter(Boolean).join("/").replace(/\/\/*/g,"/")||"/"}var RE=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function AE(e,t){let n=e;if(typeof n!="string"||!tM.test(n))return{absoluteURL:void 0,isExternal:!1,to:n};let r=n,o=!1;if(RE)try{let i=new URL(window.location.href),a=n.startsWith("//")?new URL(i.protocol+n):new URL(n),l=No(a.pathname,t);a.origin===i.origin&&l!=null?n=l+a.search+a.hash:o=!0}catch{xs(!1,`<Link to="${n}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}return{absoluteURL:r,isExternal:o,to:n}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");var PE=["POST","PUT","PATCH","DELETE"];new Set(PE);var uM=["GET",...PE];new Set(uM);var cc=m.createContext(null);cc.displayName="DataRouter";var zh=m.createContext(null);zh.displayName="DataRouterState";var dM=m.createContext(!1),_E=m.createContext({isTransitioning:!1});_E.displayName="ViewTransition";var fM=m.createContext(new Map);fM.displayName="Fetchers";var pM=m.createContext(null);pM.displayName="Await";var ts=m.createContext(null);ts.displayName="Navigation";var kd=m.createContext(null);kd.displayName="Location";var Ss=m.createContext({outlet:null,matches:[],isDataRoute:!1});Ss.displayName="Route";var kv=m.createContext(null);kv.displayName="RouteError";var DE="REACT_ROUTER_ERROR",hM="REDIRECT",mM="ROUTE_ERROR_RESPONSE";function gM(e){if(e.startsWith(`${DE}:${hM}:{`))try{let t=JSON.parse(e.slice(28));if(typeof t=="object"&&t&&typeof t.status=="number"&&typeof t.statusText=="string"&&typeof t.location=="string"&&typeof t.reloadDocument=="boolean"&&typeof t.replace=="boolean")return t}catch{}}function xM(e){if(e.startsWith(`${DE}:${mM}:{`))try{let t=JSON.parse(e.slice(40));if(typeof t=="object"&&t&&typeof t.status=="number"&&typeof t.statusText=="string")return new aM(t.status,t.statusText,t.data)}catch{}}function yM(e,{relative:t}={}){cn(Sd(),"useHref() may be used only in the context of a <Router> component.");let{basename:n,navigator:r}=m.useContext(ts),{hash:o,pathname:i,search:a}=Nd(e,{relative:t}),l=i;return n!=="/"&&(l=i==="/"?n:Ks([n,i])),r.createHref({pathname:l,search:a,hash:o})}function Sd(){return m.useContext(kd)!=null}function or(){return cn(Sd(),"useLocation() may be used only in the context of a <Router> component."),m.useContext(kd).location}var $E="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function IE(e){m.useContext(ts).static||m.useLayoutEffect(e)}function Ht(){let{isDataRoute:e}=m.useContext(Ss);return e?DM():bM()}function bM(){cn(Sd(),"useNavigate() may be used only in the context of a <Router> component.");let e=m.useContext(cc),{basename:t,navigator:n}=m.useContext(ts),{matches:r}=m.useContext(Ss),{pathname:o}=or(),i=JSON.stringify(TE(r)),a=m.useRef(!1);return IE(()=>{a.current=!0}),m.useCallback((d,f={})=>{if(xs(a.current,$E),!a.current)return;if(typeof d=="number"){n.go(d);return}let p=jv(d,JSON.parse(i),o,f.relative==="path");e==null&&t!=="/"&&(p.pathname=p.pathname==="/"?t:Ks([t,p.pathname])),(f.replace?n.replace:n.push)(p,f.state,f)},[t,n,i,o,e])}var vM=m.createContext(null);function wM(e){let t=m.useContext(Ss).outlet;return m.useMemo(()=>t&&m.createElement(vM.Provider,{value:e},t),[t,e])}function Vt(){let{matches:e}=m.useContext(Ss),t=e[e.length-1];return t?t.params:{}}function Nd(e,{relative:t}={}){let{matches:n}=m.useContext(Ss),{pathname:r}=or(),o=JSON.stringify(TE(n));return m.useMemo(()=>jv(e,JSON.parse(o),r,t==="path"),[e,o,r,t])}function jM(e,t){return ME(e,t)}function ME(e,t,n){var b;cn(Sd(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:r}=m.useContext(ts),{matches:o}=m.useContext(Ss),i=o[o.length-1],a=i?i.params:{},l=i?i.pathname:"/",d=i?i.pathnameBase:"/",f=i&&i.route;{let j=f&&f.path||"";OE(l,!f||j.endsWith("*")||j.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${l}" (under <Route path="${j}">) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render.
50
+
51
+ Please change the parent <Route path="${j}"> to <Route path="${j==="/"?"*":`${j}/*`}">.`)}let p=or(),h;if(t){let j=typeof t=="string"?lc(t):t;cn(d==="/"||((b=j.pathname)==null?void 0:b.startsWith(d)),`When overriding the location using \`<Routes location>\` or \`useRoutes(routes, location)\`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "${d}" but pathname "${j.pathname}" was given in the \`location\` prop.`),h=j}else h=p;let g=h.pathname||"/",y=g;if(d!=="/"){let j=d.replace(/^\//,"").split("/");y="/"+g.replace(/^\//,"").split("/").slice(j.length).join("/")}let k=NE(e,{pathname:y});xs(f||k!=null,`No routes matched location "${h.pathname}${h.search}${h.hash}" `),xs(k==null||k[k.length-1].route.element!==void 0||k[k.length-1].route.Component!==void 0||k[k.length-1].route.lazy!==void 0,`Matched leaf route at location "${h.pathname}${h.search}${h.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`);let w=EM(k&&k.map(j=>Object.assign({},j,{params:Object.assign({},a,j.params),pathname:Ks([d,r.encodeLocation?r.encodeLocation(j.pathname.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:j.pathname]),pathnameBase:j.pathnameBase==="/"?d:Ks([d,r.encodeLocation?r.encodeLocation(j.pathnameBase.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:j.pathnameBase])})),o,n);return t&&w?m.createElement(kd.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",unstable_mask:void 0,...h},navigationType:"POP"}},w):w}function kM(){let e=_M(),t=lM(e)?`${e.status} ${e.statusText}`:e instanceof Error?e.message:JSON.stringify(e),n=e instanceof Error?e.stack:null,r="rgba(200,200,200, 0.5)",o={padding:"0.5rem",backgroundColor:r},i={padding:"2px 4px",backgroundColor:r},a=null;return console.error("Error handled by React Router default ErrorBoundary:",e),a=m.createElement(m.Fragment,null,m.createElement("p",null,"💿 Hey developer 👋"),m.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",m.createElement("code",{style:i},"ErrorBoundary")," or"," ",m.createElement("code",{style:i},"errorElement")," prop on your route.")),m.createElement(m.Fragment,null,m.createElement("h2",null,"Unexpected Application Error!"),m.createElement("h3",{style:{fontStyle:"italic"}},t),n?m.createElement("pre",{style:o},n):null,a)}var SM=m.createElement(kM,null),LE=class extends m.Component{constructor(e){super(e),this.state={location:e.location,revalidation:e.revalidation,error:e.error}}static getDerivedStateFromError(e){return{error:e}}static getDerivedStateFromProps(e,t){return t.location!==e.location||t.revalidation!=="idle"&&e.revalidation==="idle"?{error:e.error,location:e.location,revalidation:e.revalidation}:{error:e.error!==void 0?e.error:t.error,location:t.location,revalidation:e.revalidation||t.revalidation}}componentDidCatch(e,t){this.props.onError?this.props.onError(e,t):console.error("React Router caught the following error during render",e)}render(){let e=this.state.error;if(this.context&&typeof e=="object"&&e&&"digest"in e&&typeof e.digest=="string"){const n=xM(e.digest);n&&(e=n)}let t=e!==void 0?m.createElement(Ss.Provider,{value:this.props.routeContext},m.createElement(kv.Provider,{value:e,children:this.props.component})):this.props.children;return this.context?m.createElement(NM,{error:e},t):t}};LE.contextType=dM;var Fx=new WeakMap;function NM({children:e,error:t}){let{basename:n}=m.useContext(ts);if(typeof t=="object"&&t&&"digest"in t&&typeof t.digest=="string"){let r=gM(t.digest);if(r){let o=Fx.get(t);if(o)throw o;let i=AE(r.location,n);if(RE&&!Fx.get(t))if(i.isExternal||r.reloadDocument)window.location.href=i.absoluteURL||i.to;else{const a=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(i.to,{replace:r.replace}));throw Fx.set(t,a),a}return m.createElement("meta",{httpEquiv:"refresh",content:`0;url=${i.absoluteURL||i.to}`})}}return e}function CM({routeContext:e,match:t,children:n}){let r=m.useContext(cc);return r&&r.static&&r.staticContext&&(t.route.errorElement||t.route.ErrorBoundary)&&(r.staticContext._deepestRenderedBoundaryId=t.route.id),m.createElement(Ss.Provider,{value:e},n)}function EM(e,t=[],n){let r=n==null?void 0:n.state;if(e==null){if(!r)return null;if(r.errors)e=r.matches;else if(t.length===0&&!r.initialized&&r.matches.length>0)e=r.matches;else return null}let o=e,i=r==null?void 0:r.errors;if(i!=null){let p=o.findIndex(h=>h.route.id&&(i==null?void 0:i[h.route.id])!==void 0);cn(p>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(i).join(",")}`),o=o.slice(0,Math.min(o.length,p+1))}let a=!1,l=-1;if(n&&r){a=r.renderFallback;for(let p=0;p<o.length;p++){let h=o[p];if((h.route.HydrateFallback||h.route.hydrateFallbackElement)&&(l=p),h.route.id){let{loaderData:g,errors:y}=r,k=h.route.loader&&!g.hasOwnProperty(h.route.id)&&(!y||y[h.route.id]===void 0);if(h.route.lazy||k){n.isStatic&&(a=!0),l>=0?o=o.slice(0,l+1):o=[o[0]];break}}}}let d=n==null?void 0:n.onError,f=r&&d?(p,h)=>{var g,y;d(p,{location:r.location,params:((y=(g=r.matches)==null?void 0:g[0])==null?void 0:y.params)??{},unstable_pattern:cM(r.matches),errorInfo:h})}:void 0;return o.reduceRight((p,h,g)=>{let y,k=!1,w=null,b=null;r&&(y=i&&h.route.id?i[h.route.id]:void 0,w=h.route.errorElement||SM,a&&(l<0&&g===0?(OE("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),k=!0,b=null):l===g&&(k=!0,b=h.route.hydrateFallbackElement||null)));let j=t.concat(o.slice(0,g+1)),N=()=>{let S;return y?S=w:k?S=b:h.route.Component?S=m.createElement(h.route.Component,null):h.route.element?S=h.route.element:S=p,m.createElement(CM,{match:h,routeContext:{outlet:p,matches:j,isDataRoute:r!=null},children:S})};return r&&(h.route.ErrorBoundary||h.route.errorElement||g===0)?m.createElement(LE,{location:r.location,revalidation:r.revalidation,component:w,error:y,children:N(),routeContext:{outlet:null,matches:j,isDataRoute:!0},onError:f}):N()},null)}function Sv(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function TM(e){let t=m.useContext(cc);return cn(t,Sv(e)),t}function RM(e){let t=m.useContext(zh);return cn(t,Sv(e)),t}function AM(e){let t=m.useContext(Ss);return cn(t,Sv(e)),t}function Nv(e){let t=AM(e),n=t.matches[t.matches.length-1];return cn(n.route.id,`${e} can only be used on routes that contain a unique "id"`),n.route.id}function PM(){return Nv("useRouteId")}function _M(){var r;let e=m.useContext(kv),t=RM("useRouteError"),n=Nv("useRouteError");return e!==void 0?e:(r=t.errors)==null?void 0:r[n]}function DM(){let{router:e}=TM("useNavigate"),t=Nv("useNavigate"),n=m.useRef(!1);return IE(()=>{n.current=!0}),m.useCallback(async(o,i={})=>{xs(n.current,$E),n.current&&(typeof o=="number"?await e.navigate(o):await e.navigate(o,{fromRouteId:t,...i}))},[e,t])}var c1={};function OE(e,t,n){!t&&!c1[e]&&(c1[e]=!0,xs(!1,n))}m.memo($M);function $M({routes:e,future:t,state:n,isStatic:r,onError:o}){return ME(e,void 0,{state:n,isStatic:r,onError:o})}function IM(e){return wM(e.context)}function Ze(e){cn(!1,"A <Route> is only ever to be used as the child of <Routes> element, never rendered directly. Please wrap your <Route> in a <Routes>.")}function MM({basename:e="/",children:t=null,location:n,navigationType:r="POP",navigator:o,static:i=!1,unstable_useTransitions:a}){cn(!Sd(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let l=e.replace(/^\/*/,"/"),d=m.useMemo(()=>({basename:l,navigator:o,static:i,unstable_useTransitions:a,future:{}}),[l,o,i,a]);typeof n=="string"&&(n=lc(n));let{pathname:f="/",search:p="",hash:h="",state:g=null,key:y="default",unstable_mask:k}=n,w=m.useMemo(()=>{let b=No(f,l);return b==null?null:{location:{pathname:b,search:p,hash:h,state:g,key:y,unstable_mask:k},navigationType:r}},[l,f,p,h,g,y,r,k]);return xs(w!=null,`<Router basename="${l}"> is not able to match the URL "${f}${p}${h}" because it does not start with the basename, so the <Router> won't render anything.`),w==null?null:m.createElement(ts.Provider,{value:d},m.createElement(kd.Provider,{children:t,value:w}))}function LM({children:e,location:t}){return jM(ab(e),t)}function ab(e,t=[]){let n=[];return m.Children.forEach(e,(r,o)=>{if(!m.isValidElement(r))return;let i=[...t,o];if(r.type===m.Fragment){n.push.apply(n,ab(r.props.children,i));return}cn(r.type===Ze,`[${typeof r.type=="string"?r.type:r.type.name}] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>`),cn(!r.props.index||!r.props.children,"An index route cannot have child routes.");let a={id:r.props.id||i.join("-"),caseSensitive:r.props.caseSensitive,element:r.props.element,Component:r.props.Component,index:r.props.index,path:r.props.path,middleware:r.props.middleware,loader:r.props.loader,action:r.props.action,hydrateFallbackElement:r.props.hydrateFallbackElement,HydrateFallback:r.props.HydrateFallback,errorElement:r.props.errorElement,ErrorBoundary:r.props.ErrorBoundary,hasErrorBoundary:r.props.hasErrorBoundary===!0||r.props.ErrorBoundary!=null||r.props.errorElement!=null,shouldRevalidate:r.props.shouldRevalidate,handle:r.props.handle,lazy:r.props.lazy};r.props.children&&(a.children=ab(r.props.children,i)),n.push(a)}),n}var Cp="get",Ep="application/x-www-form-urlencoded";function Bh(e){return typeof HTMLElement<"u"&&e instanceof HTMLElement}function OM(e){return Bh(e)&&e.tagName.toLowerCase()==="button"}function FM(e){return Bh(e)&&e.tagName.toLowerCase()==="form"}function zM(e){return Bh(e)&&e.tagName.toLowerCase()==="input"}function BM(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function UM(e,t){return e.button===0&&(!t||t==="_self")&&!BM(e)}function lb(e=""){return new URLSearchParams(typeof e=="string"||Array.isArray(e)||e instanceof URLSearchParams?e:Object.keys(e).reduce((t,n)=>{let r=e[n];return t.concat(Array.isArray(r)?r.map(o=>[n,o]):[[n,r]])},[]))}function HM(e,t){let n=lb(e);return t&&t.forEach((r,o)=>{n.has(o)||t.getAll(o).forEach(i=>{n.append(o,i)})}),n}var Xf=null;function VM(){if(Xf===null)try{new FormData(document.createElement("form"),0),Xf=!1}catch{Xf=!0}return Xf}var WM=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function zx(e){return e!=null&&!WM.has(e)?(xs(!1,`"${e}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${Ep}"`),null):e}function qM(e,t){let n,r,o,i,a;if(FM(e)){let l=e.getAttribute("action");r=l?No(l,t):null,n=e.getAttribute("method")||Cp,o=zx(e.getAttribute("enctype"))||Ep,i=new FormData(e)}else if(OM(e)||zM(e)&&(e.type==="submit"||e.type==="image")){let l=e.form;if(l==null)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');let d=e.getAttribute("formaction")||l.getAttribute("action");if(r=d?No(d,t):null,n=e.getAttribute("formmethod")||l.getAttribute("method")||Cp,o=zx(e.getAttribute("formenctype"))||zx(l.getAttribute("enctype"))||Ep,i=new FormData(l,e),!VM()){let{name:f,type:p,value:h}=e;if(p==="image"){let g=f?`${f}.`:"";i.append(`${g}x`,"0"),i.append(`${g}y`,"0")}else f&&i.append(f,h)}}else{if(Bh(e))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');n=Cp,r=null,o=Ep,a=e}return i&&o==="text/plain"&&(a=i,i=void 0),{action:r,method:n.toLowerCase(),encType:o,formData:i,body:a}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function Cv(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function KM(e,t,n,r){let o=typeof e=="string"?new URL(e,typeof window>"u"?"server://singlefetch/":window.location.origin):e;return n?o.pathname.endsWith("/")?o.pathname=`${o.pathname}_.${r}`:o.pathname=`${o.pathname}.${r}`:o.pathname==="/"?o.pathname=`_root.${r}`:t&&No(o.pathname,t)==="/"?o.pathname=`${t.replace(/\/$/,"")}/_root.${r}`:o.pathname=`${o.pathname.replace(/\/$/,"")}.${r}`,o}async function GM(e,t){if(e.id in t)return t[e.id];try{let n=await import(e.module);return t[e.id]=n,n}catch(n){return console.error(`Error loading route module \`${e.module}\`, reloading page...`),console.error(n),window.__reactRouterContext&&window.__reactRouterContext.isSpaMode,window.location.reload(),new Promise(()=>{})}}function YM(e){return e==null?!1:e.href==null?e.rel==="preload"&&typeof e.imageSrcSet=="string"&&typeof e.imageSizes=="string":typeof e.rel=="string"&&typeof e.href=="string"}async function XM(e,t,n){let r=await Promise.all(e.map(async o=>{let i=t.routes[o.route.id];if(i){let a=await GM(i,n);return a.links?a.links():[]}return[]}));return eL(r.flat(1).filter(YM).filter(o=>o.rel==="stylesheet"||o.rel==="preload").map(o=>o.rel==="stylesheet"?{...o,rel:"prefetch",as:"style"}:{...o,rel:"prefetch"}))}function u1(e,t,n,r,o,i){let a=(d,f)=>n[f]?d.route.id!==n[f].route.id:!0,l=(d,f)=>{var p;return n[f].pathname!==d.pathname||((p=n[f].route.path)==null?void 0:p.endsWith("*"))&&n[f].params["*"]!==d.params["*"]};return i==="assets"?t.filter((d,f)=>a(d,f)||l(d,f)):i==="data"?t.filter((d,f)=>{var h;let p=r.routes[d.route.id];if(!p||!p.hasLoader)return!1;if(a(d,f)||l(d,f))return!0;if(d.route.shouldRevalidate){let g=d.route.shouldRevalidate({currentUrl:new URL(o.pathname+o.search+o.hash,window.origin),currentParams:((h=n[0])==null?void 0:h.params)||{},nextUrl:new URL(e,window.origin),nextParams:d.params,defaultShouldRevalidate:!0});if(typeof g=="boolean")return g}return!0}):[]}function QM(e,t,{includeHydrateFallback:n}={}){return JM(e.map(r=>{let o=t.routes[r.route.id];if(!o)return[];let i=[o.module];return o.clientActionModule&&(i=i.concat(o.clientActionModule)),o.clientLoaderModule&&(i=i.concat(o.clientLoaderModule)),n&&o.hydrateFallbackModule&&(i=i.concat(o.hydrateFallbackModule)),o.imports&&(i=i.concat(o.imports)),i}).flat(1))}function JM(e){return[...new Set(e)]}function ZM(e){let t={},n=Object.keys(e).sort();for(let r of n)t[r]=e[r];return t}function eL(e,t){let n=new Set;return new Set(t),e.reduce((r,o)=>{let i=JSON.stringify(ZM(o));return n.has(i)||(n.add(i),r.push({key:i,link:o})),r},[])}function FE(){let e=m.useContext(cc);return Cv(e,"You must render this element inside a <DataRouterContext.Provider> element"),e}function tL(){let e=m.useContext(zh);return Cv(e,"You must render this element inside a <DataRouterStateContext.Provider> element"),e}var Ev=m.createContext(void 0);Ev.displayName="FrameworkContext";function zE(){let e=m.useContext(Ev);return Cv(e,"You must render this element inside a <HydratedRouter> element"),e}function nL(e,t){let n=m.useContext(Ev),[r,o]=m.useState(!1),[i,a]=m.useState(!1),{onFocus:l,onBlur:d,onMouseEnter:f,onMouseLeave:p,onTouchStart:h}=t,g=m.useRef(null);m.useEffect(()=>{if(e==="render"&&a(!0),e==="viewport"){let w=j=>{j.forEach(N=>{a(N.isIntersecting)})},b=new IntersectionObserver(w,{threshold:.5});return g.current&&b.observe(g.current),()=>{b.disconnect()}}},[e]),m.useEffect(()=>{if(r){let w=setTimeout(()=>{a(!0)},100);return()=>{clearTimeout(w)}}},[r]);let y=()=>{o(!0)},k=()=>{o(!1),a(!1)};return n?e!=="intent"?[i,g,{}]:[i,g,{onFocus:cu(l,y),onBlur:cu(d,k),onMouseEnter:cu(f,y),onMouseLeave:cu(p,k),onTouchStart:cu(h,y)}]:[!1,g,{}]}function cu(e,t){return n=>{e&&e(n),n.defaultPrevented||t(n)}}function rL({page:e,...t}){let{router:n}=FE(),r=m.useMemo(()=>NE(n.routes,e,n.basename),[n.routes,e,n.basename]);return r?m.createElement(oL,{page:e,matches:r,...t}):null}function sL(e){let{manifest:t,routeModules:n}=zE(),[r,o]=m.useState([]);return m.useEffect(()=>{let i=!1;return XM(e,t,n).then(a=>{i||o(a)}),()=>{i=!0}},[e,t,n]),r}function oL({page:e,matches:t,...n}){let r=or(),{future:o,manifest:i,routeModules:a}=zE(),{basename:l}=FE(),{loaderData:d,matches:f}=tL(),p=m.useMemo(()=>u1(e,t,f,i,r,"data"),[e,t,f,i,r]),h=m.useMemo(()=>u1(e,t,f,i,r,"assets"),[e,t,f,i,r]),g=m.useMemo(()=>{if(e===r.pathname+r.search+r.hash)return[];let w=new Set,b=!1;if(t.forEach(N=>{var C;let S=i.routes[N.route.id];!S||!S.hasLoader||(!p.some(D=>D.route.id===N.route.id)&&N.route.id in d&&((C=a[N.route.id])!=null&&C.shouldRevalidate)||S.hasClientLoader?b=!0:w.add(N.route.id))}),w.size===0)return[];let j=KM(e,l,o.unstable_trailingSlashAwareDataRequests,"data");return b&&w.size>0&&j.searchParams.set("_routes",t.filter(N=>w.has(N.route.id)).map(N=>N.route.id).join(",")),[j.pathname+j.search]},[l,o.unstable_trailingSlashAwareDataRequests,d,r,i,p,t,e,a]),y=m.useMemo(()=>QM(h,i),[h,i]),k=sL(h);return m.createElement(m.Fragment,null,g.map(w=>m.createElement("link",{key:w,rel:"prefetch",as:"fetch",href:w,...n})),y.map(w=>m.createElement("link",{key:w,rel:"modulepreload",href:w,...n})),k.map(({key:w,link:b})=>m.createElement("link",{key:w,nonce:n.nonce,...b,crossOrigin:b.crossOrigin??n.crossOrigin})))}function iL(...e){return t=>{e.forEach(n=>{typeof n=="function"?n(t):n!=null&&(n.current=t)})}}var aL=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{aL&&(window.__reactRouterVersion="7.13.1")}catch{}function lL({basename:e,children:t,unstable_useTransitions:n,window:r}){let o=m.useRef();o.current==null&&(o.current=OI({window:r,v5Compat:!0}));let i=o.current,[a,l]=m.useState({action:i.action,location:i.location}),d=m.useCallback(f=>{n===!1?l(f):m.startTransition(()=>l(f))},[n]);return m.useLayoutEffect(()=>i.listen(d),[i,d]),m.createElement(MM,{basename:e,children:t,location:a.location,navigationType:a.action,navigator:i,unstable_useTransitions:n})}var BE=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Ie=m.forwardRef(function({onClick:t,discover:n="render",prefetch:r="none",relative:o,reloadDocument:i,replace:a,unstable_mask:l,state:d,target:f,to:p,preventScrollReset:h,viewTransition:g,unstable_defaultShouldRevalidate:y,...k},w){let{basename:b,navigator:j,unstable_useTransitions:N}=m.useContext(ts),S=typeof p=="string"&&BE.test(p),C=AE(p,b);p=C.to;let D=yM(p,{relative:o}),T=or(),R=null;if(l){let L=jv(l,[],T.unstable_mask?T.unstable_mask.pathname:"/",!0);b!=="/"&&(L.pathname=L.pathname==="/"?b:Ks([b,L.pathname])),R=j.createHref(L)}let[$,_,U]=nL(r,k),I=fL(p,{replace:a,unstable_mask:l,state:d,target:f,preventScrollReset:h,relative:o,viewTransition:g,unstable_defaultShouldRevalidate:y,unstable_useTransitions:N});function F(L){t&&t(L),L.defaultPrevented||I(L)}let M=!(C.isExternal||i),A=m.createElement("a",{...k,...U,href:(M?R:void 0)||C.absoluteURL||D,onClick:M?F:t,ref:iL(w,_),target:f,"data-discover":!S&&n==="render"?"true":void 0});return $&&!S?m.createElement(m.Fragment,null,A,m.createElement(rL,{page:D})):A});Ie.displayName="Link";var cL=m.forwardRef(function({"aria-current":t="page",caseSensitive:n=!1,className:r="",end:o=!1,style:i,to:a,viewTransition:l,children:d,...f},p){let h=Nd(a,{relative:f.relative}),g=or(),y=m.useContext(zh),{navigator:k,basename:w}=m.useContext(ts),b=y!=null&&xL(h)&&l===!0,j=k.encodeLocation?k.encodeLocation(h).pathname:h.pathname,N=g.pathname,S=y&&y.navigation&&y.navigation.location?y.navigation.location.pathname:null;n||(N=N.toLowerCase(),S=S?S.toLowerCase():null,j=j.toLowerCase()),S&&w&&(S=No(S,w)||S);const C=j!=="/"&&j.endsWith("/")?j.length-1:j.length;let D=N===j||!o&&N.startsWith(j)&&N.charAt(C)==="/",T=S!=null&&(S===j||!o&&S.startsWith(j)&&S.charAt(j.length)==="/"),R={isActive:D,isPending:T,isTransitioning:b},$=D?t:void 0,_;typeof r=="function"?_=r(R):_=[r,D?"active":null,T?"pending":null,b?"transitioning":null].filter(Boolean).join(" ");let U=typeof i=="function"?i(R):i;return m.createElement(Ie,{...f,"aria-current":$,className:_,ref:p,style:U,to:a,viewTransition:l},typeof d=="function"?d(R):d)});cL.displayName="NavLink";var uL=m.forwardRef(({discover:e="render",fetcherKey:t,navigate:n,reloadDocument:r,replace:o,state:i,method:a=Cp,action:l,onSubmit:d,relative:f,preventScrollReset:p,viewTransition:h,unstable_defaultShouldRevalidate:g,...y},k)=>{let{unstable_useTransitions:w}=m.useContext(ts),b=mL(),j=gL(l,{relative:f}),N=a.toLowerCase()==="get"?"get":"post",S=typeof l=="string"&&BE.test(l),C=D=>{if(d&&d(D),D.defaultPrevented)return;D.preventDefault();let T=D.nativeEvent.submitter,R=(T==null?void 0:T.getAttribute("formmethod"))||a,$=()=>b(T||D.currentTarget,{fetcherKey:t,method:R,navigate:n,replace:o,state:i,relative:f,preventScrollReset:p,viewTransition:h,unstable_defaultShouldRevalidate:g});w&&n!==!1?m.startTransition(()=>$()):$()};return m.createElement("form",{ref:k,method:N,action:j,onSubmit:r?d:C,...y,"data-discover":!S&&e==="render"?"true":void 0})});uL.displayName="Form";function dL(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function UE(e){let t=m.useContext(cc);return cn(t,dL(e)),t}function fL(e,{target:t,replace:n,unstable_mask:r,state:o,preventScrollReset:i,relative:a,viewTransition:l,unstable_defaultShouldRevalidate:d,unstable_useTransitions:f}={}){let p=Ht(),h=or(),g=Nd(e,{relative:a});return m.useCallback(y=>{if(UM(y,t)){y.preventDefault();let k=n!==void 0?n:Gu(h)===Gu(g),w=()=>p(e,{replace:k,unstable_mask:r,state:o,preventScrollReset:i,relative:a,viewTransition:l,unstable_defaultShouldRevalidate:d});f?m.startTransition(()=>w()):w()}},[h,p,g,n,r,o,t,e,i,a,l,d,f])}function Ns(e){xs(typeof URLSearchParams<"u","You cannot use the `useSearchParams` hook in a browser that does not support the URLSearchParams API. If you need to support Internet Explorer 11, we recommend you load a polyfill such as https://github.com/ungap/url-search-params.");let t=m.useRef(lb(e)),n=m.useRef(!1),r=or(),o=m.useMemo(()=>HM(r.search,n.current?null:t.current),[r.search]),i=Ht(),a=m.useCallback((l,d)=>{const f=lb(typeof l=="function"?l(new URLSearchParams(o)):l);n.current=!0,i("?"+f,d)},[i,o]);return[o,a]}var pL=0,hL=()=>`__${String(++pL)}__`;function mL(){let{router:e}=UE("useSubmit"),{basename:t}=m.useContext(ts),n=PM(),r=e.fetch,o=e.navigate;return m.useCallback(async(i,a={})=>{let{action:l,method:d,encType:f,formData:p,body:h}=qM(i,t);if(a.navigate===!1){let g=a.fetcherKey||hL();await r(g,n,a.action||l,{unstable_defaultShouldRevalidate:a.unstable_defaultShouldRevalidate,preventScrollReset:a.preventScrollReset,formData:p,body:h,formMethod:a.method||d,formEncType:a.encType||f,flushSync:a.flushSync})}else await o(a.action||l,{unstable_defaultShouldRevalidate:a.unstable_defaultShouldRevalidate,preventScrollReset:a.preventScrollReset,formData:p,body:h,formMethod:a.method||d,formEncType:a.encType||f,replace:a.replace,state:a.state,fromRouteId:n,flushSync:a.flushSync,viewTransition:a.viewTransition})},[r,o,t,n])}function gL(e,{relative:t}={}){let{basename:n}=m.useContext(ts),r=m.useContext(Ss);cn(r,"useFormAction must be used inside a RouteContext");let[o]=r.matches.slice(-1),i={...Nd(e||".",{relative:t})},a=or();if(e==null){i.search=a.search;let l=new URLSearchParams(i.search),d=l.getAll("index");if(d.some(p=>p==="")){l.delete("index"),d.filter(h=>h).forEach(h=>l.append("index",h));let p=l.toString();i.search=p?`?${p}`:""}}return(!e||e===".")&&o.route.index&&(i.search=i.search?i.search.replace(/^\?/,"?index&"):"?index"),n!=="/"&&(i.pathname=i.pathname==="/"?n:Ks([n,i.pathname])),Gu(i)}function xL(e,{relative:t}={}){let n=m.useContext(_E);cn(n!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:r}=UE("useViewTransitionState"),o=Nd(e,{relative:t});if(!n.isTransitioning)return!1;let i=No(n.currentLocation.pathname,r)||n.currentLocation.pathname,a=No(n.nextLocation.pathname,r)||n.nextLocation.pathname;return Xp(o.pathname,a)!=null||Xp(o.pathname,i)!=null}var vo=SE();const yL=wd(vo);/**
52
+ * @license lucide-react v0.460.0 - ISC
53
+ *
54
+ * This source code is licensed under the ISC license.
55
+ * See the LICENSE file in the root directory of this source tree.
56
+ */const bL=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),HE=(...e)=>e.filter((t,n,r)=>!!t&&t.trim()!==""&&r.indexOf(t)===n).join(" ").trim();/**
57
+ * @license lucide-react v0.460.0 - ISC
58
+ *
59
+ * This source code is licensed under the ISC license.
60
+ * See the LICENSE file in the root directory of this source tree.
61
+ */var vL={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/**
62
+ * @license lucide-react v0.460.0 - ISC
63
+ *
64
+ * This source code is licensed under the ISC license.
65
+ * See the LICENSE file in the root directory of this source tree.
66
+ */const wL=m.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:o="",children:i,iconNode:a,...l},d)=>m.createElement("svg",{ref:d,...vL,width:t,height:t,stroke:e,strokeWidth:r?Number(n)*24/Number(t):n,className:HE("lucide",o),...l},[...a.map(([f,p])=>m.createElement(f,p)),...Array.isArray(i)?i:[i]]));/**
67
+ * @license lucide-react v0.460.0 - ISC
68
+ *
69
+ * This source code is licensed under the ISC license.
70
+ * See the LICENSE file in the root directory of this source tree.
71
+ */const Me=(e,t)=>{const n=m.forwardRef(({className:r,...o},i)=>m.createElement(wL,{ref:i,iconNode:t,className:HE(`lucide-${bL(e)}`,r),...o}));return n.displayName=`${e}`,n};/**
72
+ * @license lucide-react v0.460.0 - ISC
73
+ *
74
+ * This source code is licensed under the ISC license.
75
+ * See the LICENSE file in the root directory of this source tree.
76
+ */const Uh=Me("Activity",[["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"}]]);/**
77
+ * @license lucide-react v0.460.0 - ISC
78
+ *
79
+ * This source code is licensed under the ISC license.
80
+ * See the LICENSE file in the root directory of this source tree.
81
+ */const Qp=Me("ArchiveRestore",[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h2",key:"tvwodi"}],["path",{d:"M20 8v11a2 2 0 0 1-2 2h-2",key:"1gkqxj"}],["path",{d:"m9 15 3-3 3 3",key:"1pd0qc"}],["path",{d:"M12 12v9",key:"192myk"}]]);/**
82
+ * @license lucide-react v0.460.0 - ISC
83
+ *
84
+ * This source code is licensed under the ISC license.
85
+ * See the LICENSE file in the root directory of this source tree.
86
+ */const Hh=Me("Archive",[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8",key:"1s80jp"}],["path",{d:"M10 12h4",key:"a56b0p"}]]);/**
87
+ * @license lucide-react v0.460.0 - ISC
88
+ *
89
+ * This source code is licensed under the ISC license.
90
+ * See the LICENSE file in the root directory of this source tree.
91
+ */const Jp=Me("ArrowLeft",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]);/**
92
+ * @license lucide-react v0.460.0 - ISC
93
+ *
94
+ * This source code is licensed under the ISC license.
95
+ * See the LICENSE file in the root directory of this source tree.
96
+ */const Vh=Me("ArrowRightLeft",[["path",{d:"m16 3 4 4-4 4",key:"1x1c3m"}],["path",{d:"M20 7H4",key:"zbl0bi"}],["path",{d:"m8 21-4-4 4-4",key:"h9nckh"}],["path",{d:"M4 17h16",key:"g4d7ey"}]]);/**
97
+ * @license lucide-react v0.460.0 - ISC
98
+ *
99
+ * This source code is licensed under the ISC license.
100
+ * See the LICENSE file in the root directory of this source tree.
101
+ */const VE=Me("ArrowRight",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]);/**
102
+ * @license lucide-react v0.460.0 - ISC
103
+ *
104
+ * This source code is licensed under the ISC license.
105
+ * See the LICENSE file in the root directory of this source tree.
106
+ */const Zp=Me("ArrowUpRight",[["path",{d:"M7 7h10v10",key:"1tivn9"}],["path",{d:"M7 17 17 7",key:"1vkiza"}]]);/**
107
+ * @license lucide-react v0.460.0 - ISC
108
+ *
109
+ * This source code is licensed under the ISC license.
110
+ * See the LICENSE file in the root directory of this source tree.
111
+ */const jL=Me("Ban",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m4.9 4.9 14.2 14.2",key:"1m5liu"}]]);/**
112
+ * @license lucide-react v0.460.0 - ISC
113
+ *
114
+ * This source code is licensed under the ISC license.
115
+ * See the LICENSE file in the root directory of this source tree.
116
+ */const kL=Me("BookOpenText",[["path",{d:"M12 7v14",key:"1akyts"}],["path",{d:"M16 12h2",key:"7q9ll5"}],["path",{d:"M16 8h2",key:"msurwy"}],["path",{d:"M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z",key:"ruj8y"}],["path",{d:"M6 12h2",key:"32wvfc"}],["path",{d:"M6 8h2",key:"30oboj"}]]);/**
117
+ * @license lucide-react v0.460.0 - ISC
118
+ *
119
+ * This source code is licensed under the ISC license.
120
+ * See the LICENSE file in the root directory of this source tree.
121
+ */const WE=Me("BookOpen",[["path",{d:"M12 7v14",key:"1akyts"}],["path",{d:"M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z",key:"ruj8y"}]]);/**
122
+ * @license lucide-react v0.460.0 - ISC
123
+ *
124
+ * This source code is licensed under the ISC license.
125
+ * See the LICENSE file in the root directory of this source tree.
126
+ */const Tv=Me("Boxes",[["path",{d:"M2.97 12.92A2 2 0 0 0 2 14.63v3.24a2 2 0 0 0 .97 1.71l3 1.8a2 2 0 0 0 2.06 0L12 19v-5.5l-5-3-4.03 2.42Z",key:"lc1i9w"}],["path",{d:"m7 16.5-4.74-2.85",key:"1o9zyk"}],["path",{d:"m7 16.5 5-3",key:"va8pkn"}],["path",{d:"M7 16.5v5.17",key:"jnp8gn"}],["path",{d:"M12 13.5V19l3.97 2.38a2 2 0 0 0 2.06 0l3-1.8a2 2 0 0 0 .97-1.71v-3.24a2 2 0 0 0-.97-1.71L17 10.5l-5 3Z",key:"8zsnat"}],["path",{d:"m17 16.5-5-3",key:"8arw3v"}],["path",{d:"m17 16.5 4.74-2.85",key:"8rfmw"}],["path",{d:"M17 16.5v5.17",key:"k6z78m"}],["path",{d:"M7.97 4.42A2 2 0 0 0 7 6.13v4.37l5 3 5-3V6.13a2 2 0 0 0-.97-1.71l-3-1.8a2 2 0 0 0-2.06 0l-3 1.8Z",key:"1xygjf"}],["path",{d:"M12 8 7.26 5.15",key:"1vbdud"}],["path",{d:"m12 8 4.74-2.85",key:"3rx089"}],["path",{d:"M12 13.5V8",key:"1io7kd"}]]);/**
127
+ * @license lucide-react v0.460.0 - ISC
128
+ *
129
+ * This source code is licensed under the ISC license.
130
+ * See the LICENSE file in the root directory of this source tree.
131
+ */const SL=Me("Brain",[["path",{d:"M12 5a3 3 0 1 0-5.997.125 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588A4 4 0 1 0 12 18Z",key:"l5xja"}],["path",{d:"M12 5a3 3 0 1 1 5.997.125 4 4 0 0 1 2.526 5.77 4 4 0 0 1-.556 6.588A4 4 0 1 1 12 18Z",key:"ep3f8r"}],["path",{d:"M15 13a4.5 4.5 0 0 1-3-4 4.5 4.5 0 0 1-3 4",key:"1p4c4q"}],["path",{d:"M17.599 6.5a3 3 0 0 0 .399-1.375",key:"tmeiqw"}],["path",{d:"M6.003 5.125A3 3 0 0 0 6.401 6.5",key:"105sqy"}],["path",{d:"M3.477 10.896a4 4 0 0 1 .585-.396",key:"ql3yin"}],["path",{d:"M19.938 10.5a4 4 0 0 1 .585.396",key:"1qfode"}],["path",{d:"M6 18a4 4 0 0 1-1.967-.516",key:"2e4loj"}],["path",{d:"M19.967 17.484A4 4 0 0 1 18 18",key:"159ez6"}]]);/**
132
+ * @license lucide-react v0.460.0 - ISC
133
+ *
134
+ * This source code is licensed under the ISC license.
135
+ * See the LICENSE file in the root directory of this source tree.
136
+ */const qE=Me("CalendarClock",[["path",{d:"M21 7.5V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h3.5",key:"1osxxc"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M3 10h5",key:"r794hk"}],["path",{d:"M17.5 17.5 16 16.3V14",key:"akvzfd"}],["circle",{cx:"16",cy:"16",r:"6",key:"qoo3c4"}]]);/**
137
+ * @license lucide-react v0.460.0 - ISC
138
+ *
139
+ * This source code is licensed under the ISC license.
140
+ * See the LICENSE file in the root directory of this source tree.
141
+ */const zr=Me("Check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);/**
142
+ * @license lucide-react v0.460.0 - ISC
143
+ *
144
+ * This source code is licensed under the ISC license.
145
+ * See the LICENSE file in the root directory of this source tree.
146
+ */const vr=Me("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);/**
147
+ * @license lucide-react v0.460.0 - ISC
148
+ *
149
+ * This source code is licensed under the ISC license.
150
+ * See the LICENSE file in the root directory of this source tree.
151
+ */const NL=Me("ChevronLeft",[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]]);/**
152
+ * @license lucide-react v0.460.0 - ISC
153
+ *
154
+ * This source code is licensed under the ISC license.
155
+ * See the LICENSE file in the root directory of this source tree.
156
+ */const KE=Me("ChevronRight",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);/**
157
+ * @license lucide-react v0.460.0 - ISC
158
+ *
159
+ * This source code is licensed under the ISC license.
160
+ * See the LICENSE file in the root directory of this source tree.
161
+ */const GE=Me("ChevronUp",[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]]);/**
162
+ * @license lucide-react v0.460.0 - ISC
163
+ *
164
+ * This source code is licensed under the ISC license.
165
+ * See the LICENSE file in the root directory of this source tree.
166
+ */const eh=Me("CircleAlert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]);/**
167
+ * @license lucide-react v0.460.0 - ISC
168
+ *
169
+ * This source code is licensed under the ISC license.
170
+ * See the LICENSE file in the root directory of this source tree.
171
+ */const Rv=Me("CircleCheck",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);/**
172
+ * @license lucide-react v0.460.0 - ISC
173
+ *
174
+ * This source code is licensed under the ISC license.
175
+ * See the LICENSE file in the root directory of this source tree.
176
+ */const cb=Me("CircleDot",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]]);/**
177
+ * @license lucide-react v0.460.0 - ISC
178
+ *
179
+ * This source code is licensed under the ISC license.
180
+ * See the LICENSE file in the root directory of this source tree.
181
+ */const CL=Me("CircleHelp",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);/**
182
+ * @license lucide-react v0.460.0 - ISC
183
+ *
184
+ * This source code is licensed under the ISC license.
185
+ * See the LICENSE file in the root directory of this source tree.
186
+ */const EL=Me("CircleStop",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["rect",{x:"9",y:"9",width:"6",height:"6",rx:"1",key:"1ssd4o"}]]);/**
187
+ * @license lucide-react v0.460.0 - ISC
188
+ *
189
+ * This source code is licensed under the ISC license.
190
+ * See the LICENSE file in the root directory of this source tree.
191
+ */const TL=Me("Circle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);/**
192
+ * @license lucide-react v0.460.0 - ISC
193
+ *
194
+ * This source code is licensed under the ISC license.
195
+ * See the LICENSE file in the root directory of this source tree.
196
+ */const RL=Me("Clock3",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16.5 12",key:"1aq6pp"}]]);/**
197
+ * @license lucide-react v0.460.0 - ISC
198
+ *
199
+ * This source code is licensed under the ISC license.
200
+ * See the LICENSE file in the root directory of this source tree.
201
+ */const AL=Me("Clock",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]]);/**
202
+ * @license lucide-react v0.460.0 - ISC
203
+ *
204
+ * This source code is licensed under the ISC license.
205
+ * See the LICENSE file in the root directory of this source tree.
206
+ */const PL=Me("Cloud",[["path",{d:"M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z",key:"p7xjir"}]]);/**
207
+ * @license lucide-react v0.460.0 - ISC
208
+ *
209
+ * This source code is licensed under the ISC license.
210
+ * See the LICENSE file in the root directory of this source tree.
211
+ */const _L=Me("CodeXml",[["path",{d:"m18 16 4-4-4-4",key:"1inbqp"}],["path",{d:"m6 8-4 4 4 4",key:"15zrgr"}],["path",{d:"m14.5 4-5 16",key:"e7oirm"}]]);/**
212
+ * @license lucide-react v0.460.0 - ISC
213
+ *
214
+ * This source code is licensed under the ISC license.
215
+ * See the LICENSE file in the root directory of this source tree.
216
+ */const Wh=Me("Coins",[["circle",{cx:"8",cy:"8",r:"6",key:"3yglwk"}],["path",{d:"M18.09 10.37A6 6 0 1 1 10.34 18",key:"t5s6rm"}],["path",{d:"M7 6h1v4",key:"1obek4"}],["path",{d:"m16.71 13.88.7.71-2.82 2.82",key:"1rbuyh"}]]);/**
217
+ * @license lucide-react v0.460.0 - ISC
218
+ *
219
+ * This source code is licensed under the ISC license.
220
+ * See the LICENSE file in the root directory of this source tree.
221
+ */const DL=Me("Columns3",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"M15 3v18",key:"14nvp0"}]]);/**
222
+ * @license lucide-react v0.460.0 - ISC
223
+ *
224
+ * This source code is licensed under the ISC license.
225
+ * See the LICENSE file in the root directory of this source tree.
226
+ */const YE=Me("Compass",[["path",{d:"m16.24 7.76-1.804 5.411a2 2 0 0 1-1.265 1.265L7.76 16.24l1.804-5.411a2 2 0 0 1 1.265-1.265z",key:"9ktpf1"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);/**
227
+ * @license lucide-react v0.460.0 - ISC
228
+ *
229
+ * This source code is licensed under the ISC license.
230
+ * See the LICENSE file in the root directory of this source tree.
231
+ */const th=Me("Copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);/**
232
+ * @license lucide-react v0.460.0 - ISC
233
+ *
234
+ * This source code is licensed under the ISC license.
235
+ * See the LICENSE file in the root directory of this source tree.
236
+ */const $L=Me("Download",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"7 10 12 15 17 10",key:"2ggqvy"}],["line",{x1:"12",x2:"12",y1:"15",y2:"3",key:"1vk2je"}]]);/**
237
+ * @license lucide-react v0.460.0 - ISC
238
+ *
239
+ * This source code is licensed under the ISC license.
240
+ * See the LICENSE file in the root directory of this source tree.
241
+ */const IL=Me("Ellipsis",[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}]]);/**
242
+ * @license lucide-react v0.460.0 - ISC
243
+ *
244
+ * This source code is licensed under the ISC license.
245
+ * See the LICENSE file in the root directory of this source tree.
246
+ */const uc=Me("ExternalLink",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]);/**
247
+ * @license lucide-react v0.460.0 - ISC
248
+ *
249
+ * This source code is licensed under the ISC license.
250
+ * See the LICENSE file in the root directory of this source tree.
251
+ */const d1=Me("Eye",[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);/**
252
+ * @license lucide-react v0.460.0 - ISC
253
+ *
254
+ * This source code is licensed under the ISC license.
255
+ * See the LICENSE file in the root directory of this source tree.
256
+ */const ML=Me("FileCode2",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"m5 12-3 3 3 3",key:"oke12k"}],["path",{d:"m9 18 3-3-3-3",key:"112psh"}]]);/**
257
+ * @license lucide-react v0.460.0 - ISC
258
+ *
259
+ * This source code is licensed under the ISC license.
260
+ * See the LICENSE file in the root directory of this source tree.
261
+ */const LL=Me("FilePenLine",[["path",{d:"m18 5-2.414-2.414A2 2 0 0 0 14.172 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2",key:"142zxg"}],["path",{d:"M21.378 12.626a1 1 0 0 0-3.004-3.004l-4.01 4.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z",key:"2t3380"}],["path",{d:"M8 18h1",key:"13wk12"}]]);/**
262
+ * @license lucide-react v0.460.0 - ISC
263
+ *
264
+ * This source code is licensed under the ISC license.
265
+ * See the LICENSE file in the root directory of this source tree.
266
+ */const XE=Me("FileText",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]]);/**
267
+ * @license lucide-react v0.460.0 - ISC
268
+ *
269
+ * This source code is licensed under the ISC license.
270
+ * See the LICENSE file in the root directory of this source tree.
271
+ */const OL=Me("FilterX",[["path",{d:"M13.013 3H2l8 9.46V19l4 2v-8.54l.9-1.055",key:"1fi1da"}],["path",{d:"m22 3-5 5",key:"12jva0"}],["path",{d:"m17 3 5 5",key:"k36vhe"}]]);/**
272
+ * @license lucide-react v0.460.0 - ISC
273
+ *
274
+ * This source code is licensed under the ISC license.
275
+ * See the LICENSE file in the root directory of this source tree.
276
+ */const FL=Me("Flag",[["path",{d:"M4 15s1-1 4-1 5 2 8 2 4-1 4-1V3s-1 1-4 1-5-2-8-2-4 1-4 1z",key:"i9b6wo"}],["line",{x1:"4",x2:"4",y1:"22",y2:"15",key:"1cm3nv"}]]);/**
277
+ * @license lucide-react v0.460.0 - ISC
278
+ *
279
+ * This source code is licensed under the ISC license.
280
+ * See the LICENSE file in the root directory of this source tree.
281
+ */const Av=Me("FolderKanban",[["path",{d:"M4 20h16a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.93a2 2 0 0 1-1.66-.9l-.82-1.2A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13c0 1.1.9 2 2 2Z",key:"1fr9dc"}],["path",{d:"M8 10v4",key:"tgpxqk"}],["path",{d:"M12 10v2",key:"hh53o1"}],["path",{d:"M16 10v6",key:"1d6xys"}]]);/**
282
+ * @license lucide-react v0.460.0 - ISC
283
+ *
284
+ * This source code is licensed under the ISC license.
285
+ * See the LICENSE file in the root directory of this source tree.
286
+ */const zL=Me("GitBranchPlus",[["path",{d:"M6 3v12",key:"qpgusn"}],["path",{d:"M18 9a3 3 0 1 0 0-6 3 3 0 0 0 0 6z",key:"1d02ji"}],["path",{d:"M6 21a3 3 0 1 0 0-6 3 3 0 0 0 0 6z",key:"chk6ph"}],["path",{d:"M15 6a9 9 0 0 0-9 9",key:"or332x"}],["path",{d:"M18 15v6",key:"9wciyi"}],["path",{d:"M21 18h-6",key:"139f0c"}]]);/**
287
+ * @license lucide-react v0.460.0 - ISC
288
+ *
289
+ * This source code is licensed under the ISC license.
290
+ * See the LICENSE file in the root directory of this source tree.
291
+ */const Pv=Me("GitBranch",[["line",{x1:"6",x2:"6",y1:"3",y2:"15",key:"17qcm7"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M18 9a9 9 0 0 1-9 9",key:"n2h4wq"}]]);/**
292
+ * @license lucide-react v0.460.0 - ISC
293
+ *
294
+ * This source code is licensed under the ISC license.
295
+ * See the LICENSE file in the root directory of this source tree.
296
+ */const BL=Me("GitFork",[["circle",{cx:"12",cy:"18",r:"3",key:"1mpf1b"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["path",{d:"M18 9v2c0 .6-.4 1-1 1H7c-.6 0-1-.4-1-1V9",key:"1uq4wg"}],["path",{d:"M12 12v3",key:"158kv8"}]]);/**
297
+ * @license lucide-react v0.460.0 - ISC
298
+ *
299
+ * This source code is licensed under the ISC license.
300
+ * See the LICENSE file in the root directory of this source tree.
301
+ */const dc=Me("GripVertical",[["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}],["circle",{cx:"9",cy:"5",r:"1",key:"hp0tcf"}],["circle",{cx:"9",cy:"19",r:"1",key:"fkjjf6"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["circle",{cx:"15",cy:"19",r:"1",key:"f4zoj3"}]]);/**
302
+ * @license lucide-react v0.460.0 - ISC
303
+ *
304
+ * This source code is licensed under the ISC license.
305
+ * See the LICENSE file in the root directory of this source tree.
306
+ */const UL=Me("Hammer",[["path",{d:"m15 12-8.373 8.373a1 1 0 1 1-3-3L12 9",key:"eefl8a"}],["path",{d:"m18 15 4-4",key:"16gjal"}],["path",{d:"m21.5 11.5-1.914-1.914A2 2 0 0 1 19 8.172V7l-2.26-2.26a6 6 0 0 0-4.202-1.756L9 2.96l.92.82A6.18 6.18 0 0 1 12 8.4V10l2 2h1.172a2 2 0 0 1 1.414.586L18.5 14.5",key:"b7pghm"}]]);/**
307
+ * @license lucide-react v0.460.0 - ISC
308
+ *
309
+ * This source code is licensed under the ISC license.
310
+ * See the LICENSE file in the root directory of this source tree.
311
+ */const HL=Me("Hash",[["line",{x1:"4",x2:"20",y1:"9",y2:"9",key:"4lhtct"}],["line",{x1:"4",x2:"20",y1:"15",y2:"15",key:"vyu0kd"}],["line",{x1:"10",x2:"8",y1:"3",y2:"21",key:"1ggp8o"}],["line",{x1:"16",x2:"14",y1:"3",y2:"21",key:"weycgp"}]]);/**
312
+ * @license lucide-react v0.460.0 - ISC
313
+ *
314
+ * This source code is licensed under the ISC license.
315
+ * See the LICENSE file in the root directory of this source tree.
316
+ */const _v=Me("Info",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]]);/**
317
+ * @license lucide-react v0.460.0 - ISC
318
+ *
319
+ * This source code is licensed under the ISC license.
320
+ * See the LICENSE file in the root directory of this source tree.
321
+ */const ub=Me("Keyboard",[["path",{d:"M10 8h.01",key:"1r9ogq"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M14 8h.01",key:"1primd"}],["path",{d:"M16 12h.01",key:"1l6xoz"}],["path",{d:"M18 8h.01",key:"emo2bl"}],["path",{d:"M6 8h.01",key:"x9i8wu"}],["path",{d:"M7 16h10",key:"wp8him"}],["path",{d:"M8 12h.01",key:"czm47f"}],["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}]]);/**
322
+ * @license lucide-react v0.460.0 - ISC
323
+ *
324
+ * This source code is licensed under the ISC license.
325
+ * See the LICENSE file in the root directory of this source tree.
326
+ */const VL=Me("LayoutGrid",[["rect",{width:"7",height:"7",x:"3",y:"3",rx:"1",key:"1g98yp"}],["rect",{width:"7",height:"7",x:"14",y:"3",rx:"1",key:"6d4xhi"}],["rect",{width:"7",height:"7",x:"14",y:"14",rx:"1",key:"nxv5o0"}],["rect",{width:"7",height:"7",x:"3",y:"14",rx:"1",key:"1bb6yr"}]]);/**
327
+ * @license lucide-react v0.460.0 - ISC
328
+ *
329
+ * This source code is licensed under the ISC license.
330
+ * See the LICENSE file in the root directory of this source tree.
331
+ */const QE=Me("LayoutTemplate",[["rect",{width:"18",height:"7",x:"3",y:"3",rx:"1",key:"f1a2em"}],["rect",{width:"9",height:"7",x:"3",y:"14",rx:"1",key:"jqznyg"}],["rect",{width:"5",height:"7",x:"16",y:"14",rx:"1",key:"q5h2i8"}]]);/**
332
+ * @license lucide-react v0.460.0 - ISC
333
+ *
334
+ * This source code is licensed under the ISC license.
335
+ * See the LICENSE file in the root directory of this source tree.
336
+ */const WL=Me("Library",[["path",{d:"m16 6 4 14",key:"ji33uf"}],["path",{d:"M12 6v14",key:"1n7gus"}],["path",{d:"M8 8v12",key:"1gg7y9"}],["path",{d:"M4 4v16",key:"6qkkli"}]]);/**
337
+ * @license lucide-react v0.460.0 - ISC
338
+ *
339
+ * This source code is licensed under the ISC license.
340
+ * See the LICENSE file in the root directory of this source tree.
341
+ */const qL=Me("LifeBuoy",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m4.93 4.93 4.24 4.24",key:"1ymg45"}],["path",{d:"m14.83 9.17 4.24-4.24",key:"1cb5xl"}],["path",{d:"m14.83 14.83 4.24 4.24",key:"q42g0n"}],["path",{d:"m9.17 14.83-4.24 4.24",key:"bqpfvv"}],["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}]]);/**
342
+ * @license lucide-react v0.460.0 - ISC
343
+ *
344
+ * This source code is licensed under the ISC license.
345
+ * See the LICENSE file in the root directory of this source tree.
346
+ */const KL=Me("Link",[["path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71",key:"1cjeqo"}],["path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71",key:"19qd67"}]]);/**
347
+ * @license lucide-react v0.460.0 - ISC
348
+ *
349
+ * This source code is licensed under the ISC license.
350
+ * See the LICENSE file in the root directory of this source tree.
351
+ */const GL=Me("ListTodo",[["rect",{x:"3",y:"5",width:"6",height:"6",rx:"1",key:"1defrl"}],["path",{d:"m3 17 2 2 4-4",key:"1jhpwq"}],["path",{d:"M13 6h8",key:"15sg57"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 18h8",key:"oe0vm4"}]]);/**
352
+ * @license lucide-react v0.460.0 - ISC
353
+ *
354
+ * This source code is licensed under the ISC license.
355
+ * See the LICENSE file in the root directory of this source tree.
356
+ */const YL=Me("ListTree",[["path",{d:"M21 12h-8",key:"1bmf0i"}],["path",{d:"M21 6H8",key:"1pqkrb"}],["path",{d:"M21 18h-8",key:"1tm79t"}],["path",{d:"M3 6v4c0 1.1.9 2 2 2h3",key:"1ywdgy"}],["path",{d:"M3 10v6c0 1.1.9 2 2 2h3",key:"2wc746"}]]);/**
357
+ * @license lucide-react v0.460.0 - ISC
358
+ *
359
+ * This source code is licensed under the ISC license.
360
+ * See the LICENSE file in the root directory of this source tree.
361
+ */const Dv=Me("LoaderCircle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);/**
362
+ * @license lucide-react v0.460.0 - ISC
363
+ *
364
+ * This source code is licensed under the ISC license.
365
+ * See the LICENSE file in the root directory of this source tree.
366
+ */const XL=Me("Maximize2",[["polyline",{points:"15 3 21 3 21 9",key:"mznyad"}],["polyline",{points:"9 21 3 21 3 15",key:"1avn1i"}],["line",{x1:"21",x2:"14",y1:"3",y2:"10",key:"ota7mn"}],["line",{x1:"3",x2:"10",y1:"21",y2:"14",key:"1atl0r"}]]);/**
367
+ * @license lucide-react v0.460.0 - ISC
368
+ *
369
+ * This source code is licensed under the ISC license.
370
+ * See the LICENSE file in the root directory of this source tree.
371
+ */const QL=Me("Menu",[["line",{x1:"4",x2:"20",y1:"12",y2:"12",key:"1e0a9i"}],["line",{x1:"4",x2:"20",y1:"6",y2:"6",key:"1owob3"}],["line",{x1:"4",x2:"20",y1:"18",y2:"18",key:"yk5zj1"}]]);/**
372
+ * @license lucide-react v0.460.0 - ISC
373
+ *
374
+ * This source code is licensed under the ISC license.
375
+ * See the LICENSE file in the root directory of this source tree.
376
+ */const $v=Me("Monitor",[["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["line",{x1:"8",x2:"16",y1:"21",y2:"21",key:"1svkeh"}],["line",{x1:"12",x2:"12",y1:"17",y2:"21",key:"vw1qmm"}]]);/**
377
+ * @license lucide-react v0.460.0 - ISC
378
+ *
379
+ * This source code is licensed under the ISC license.
380
+ * See the LICENSE file in the root directory of this source tree.
381
+ */const JL=Me("MoonStar",[["path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9",key:"4ay0iu"}],["path",{d:"M20 3v4",key:"1olli1"}],["path",{d:"M22 5h-4",key:"1gvqau"}]]);/**
382
+ * @license lucide-react v0.460.0 - ISC
383
+ *
384
+ * This source code is licensed under the ISC license.
385
+ * See the LICENSE file in the root directory of this source tree.
386
+ */const Bx=Me("NotebookPen",[["path",{d:"M13.4 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-7.4",key:"re6nr2"}],["path",{d:"M2 6h4",key:"aawbzj"}],["path",{d:"M2 10h4",key:"l0bgd4"}],["path",{d:"M2 14h4",key:"1gsvsf"}],["path",{d:"M2 18h4",key:"1bu2t1"}],["path",{d:"M21.378 5.626a1 1 0 1 0-3.004-3.004l-5.01 5.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z",key:"pqwjuv"}]]);/**
387
+ * @license lucide-react v0.460.0 - ISC
388
+ *
389
+ * This source code is licensed under the ISC license.
390
+ * See the LICENSE file in the root directory of this source tree.
391
+ */const JE=Me("Paperclip",[["path",{d:"m21.44 11.05-9.19 9.19a6 6 0 0 1-8.49-8.49l8.57-8.57A4 4 0 1 1 18 8.84l-8.59 8.57a2 2 0 0 1-2.83-2.83l8.49-8.48",key:"1u3ebp"}]]);/**
392
+ * @license lucide-react v0.460.0 - ISC
393
+ *
394
+ * This source code is licensed under the ISC license.
395
+ * See the LICENSE file in the root directory of this source tree.
396
+ */const fc=Me("Pencil",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]]);/**
397
+ * @license lucide-react v0.460.0 - ISC
398
+ *
399
+ * This source code is licensed under the ISC license.
400
+ * See the LICENSE file in the root directory of this source tree.
401
+ */const ZL=Me("Play",[["polygon",{points:"6 3 20 12 6 21 6 3",key:"1oa8hb"}]]);/**
402
+ * @license lucide-react v0.460.0 - ISC
403
+ *
404
+ * This source code is licensed under the ISC license.
405
+ * See the LICENSE file in the root directory of this source tree.
406
+ */const It=Me("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);/**
407
+ * @license lucide-react v0.460.0 - ISC
408
+ *
409
+ * This source code is licensed under the ISC license.
410
+ * See the LICENSE file in the root directory of this source tree.
411
+ */const ZE=Me("RefreshCw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]]);/**
412
+ * @license lucide-react v0.460.0 - ISC
413
+ *
414
+ * This source code is licensed under the ISC license.
415
+ * See the LICENSE file in the root directory of this source tree.
416
+ */const e4=Me("Replace",[["path",{d:"M14 4a2 2 0 0 1 2-2",key:"1w2hp7"}],["path",{d:"M16 10a2 2 0 0 1-2-2",key:"shjach"}],["path",{d:"M20 2a2 2 0 0 1 2 2",key:"188mtx"}],["path",{d:"M22 8a2 2 0 0 1-2 2",key:"ddf4tu"}],["path",{d:"m3 7 3 3 3-3",key:"x25e72"}],["path",{d:"M6 10V5a3 3 0 0 1 3-3h1",key:"3y3t5z"}],["rect",{x:"2",y:"14",width:"8",height:"8",rx:"2",key:"4rksxw"}]]);/**
417
+ * @license lucide-react v0.460.0 - ISC
418
+ *
419
+ * This source code is licensed under the ISC license.
420
+ * See the LICENSE file in the root directory of this source tree.
421
+ */const t4=Me("Reply",[["polyline",{points:"9 17 4 12 9 7",key:"hvgpf2"}],["path",{d:"M20 18v-2a4 4 0 0 0-4-4H4",key:"5vmcpk"}]]);/**
422
+ * @license lucide-react v0.460.0 - ISC
423
+ *
424
+ * This source code is licensed under the ISC license.
425
+ * See the LICENSE file in the root directory of this source tree.
426
+ */const Qs=Me("RotateCcw",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]]);/**
427
+ * @license lucide-react v0.460.0 - ISC
428
+ *
429
+ * This source code is licensed under the ISC license.
430
+ * See the LICENSE file in the root directory of this source tree.
431
+ */const qh=Me("Save",[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]]);/**
432
+ * @license lucide-react v0.460.0 - ISC
433
+ *
434
+ * This source code is licensed under the ISC license.
435
+ * See the LICENSE file in the root directory of this source tree.
436
+ */const n4=Me("SearchCheck",[["path",{d:"m8 11 2 2 4-4",key:"1sed1v"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]);/**
437
+ * @license lucide-react v0.460.0 - ISC
438
+ *
439
+ * This source code is licensed under the ISC license.
440
+ * See the LICENSE file in the root directory of this source tree.
441
+ */const Si=Me("Search",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]);/**
442
+ * @license lucide-react v0.460.0 - ISC
443
+ *
444
+ * This source code is licensed under the ISC license.
445
+ * See the LICENSE file in the root directory of this source tree.
446
+ */const r4=Me("SendToBack",[["rect",{x:"14",y:"14",width:"8",height:"8",rx:"2",key:"1b0bso"}],["rect",{x:"2",y:"2",width:"8",height:"8",rx:"2",key:"1x09vl"}],["path",{d:"M7 14v1a2 2 0 0 0 2 2h1",key:"pao6x6"}],["path",{d:"M14 7h1a2 2 0 0 1 2 2v1",key:"19tdru"}]]);/**
447
+ * @license lucide-react v0.460.0 - ISC
448
+ *
449
+ * This source code is licensed under the ISC license.
450
+ * See the LICENSE file in the root directory of this source tree.
451
+ */const s4=Me("ServerOff",[["path",{d:"M7 2h13a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2h-5",key:"bt2siv"}],["path",{d:"M10 10 2.5 2.5C2 2 2 2.5 2 5v3a2 2 0 0 0 2 2h6z",key:"1hjrv1"}],["path",{d:"M22 17v-1a2 2 0 0 0-2-2h-1",key:"1iynyr"}],["path",{d:"M4 14a2 2 0 0 0-2 2v4a2 2 0 0 0 2 2h16.5l1-.5.5.5-8-8H4z",key:"161ggg"}],["path",{d:"M6 18h.01",key:"uhywen"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);/**
452
+ * @license lucide-react v0.460.0 - ISC
453
+ *
454
+ * This source code is licensed under the ISC license.
455
+ * See the LICENSE file in the root directory of this source tree.
456
+ */const o4=Me("Settings2",[["path",{d:"M20 7h-9",key:"3s1dr2"}],["path",{d:"M14 17H5",key:"gfn3mx"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}],["circle",{cx:"7",cy:"7",r:"3",key:"dfmy0x"}]]);/**
457
+ * @license lucide-react v0.460.0 - ISC
458
+ *
459
+ * This source code is licensed under the ISC license.
460
+ * See the LICENSE file in the root directory of this source tree.
461
+ */const i4=Me("Settings",[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);/**
462
+ * @license lucide-react v0.460.0 - ISC
463
+ *
464
+ * This source code is licensed under the ISC license.
465
+ * See the LICENSE file in the root directory of this source tree.
466
+ */const a4=Me("ShieldAlert",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M12 16h.01",key:"1drbdi"}]]);/**
467
+ * @license lucide-react v0.460.0 - ISC
468
+ *
469
+ * This source code is licensed under the ISC license.
470
+ * See the LICENSE file in the root directory of this source tree.
471
+ */const gs=Me("SquareCheckBig",[["path",{d:"M21 10.5V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h12.5",key:"1uzm8b"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]]);/**
472
+ * @license lucide-react v0.460.0 - ISC
473
+ *
474
+ * This source code is licensed under the ISC license.
475
+ * See the LICENSE file in the root directory of this source tree.
476
+ */const Ux=Me("SquarePen",[["path",{d:"M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7",key:"1m0v6g"}],["path",{d:"M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z",key:"ohrbg2"}]]);/**
477
+ * @license lucide-react v0.460.0 - ISC
478
+ *
479
+ * This source code is licensed under the ISC license.
480
+ * See the LICENSE file in the root directory of this source tree.
481
+ */const f1=Me("SquareTerminal",[["path",{d:"m7 11 2-2-2-2",key:"1lz0vl"}],["path",{d:"M11 13h4",key:"1p7l4v"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}]]);/**
482
+ * @license lucide-react v0.460.0 - ISC
483
+ *
484
+ * This source code is licensed under the ISC license.
485
+ * See the LICENSE file in the root directory of this source tree.
486
+ */const Iv=Me("Square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);/**
487
+ * @license lucide-react v0.460.0 - ISC
488
+ *
489
+ * This source code is licensed under the ISC license.
490
+ * See the LICENSE file in the root directory of this source tree.
491
+ */const l4=Me("SunMedium",[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 3v1",key:"1asbbs"}],["path",{d:"M12 20v1",key:"1wcdkc"}],["path",{d:"M3 12h1",key:"lp3yf2"}],["path",{d:"M20 12h1",key:"1vloll"}],["path",{d:"m18.364 5.636-.707.707",key:"1hakh0"}],["path",{d:"m6.343 17.657-.707.707",key:"18m9nf"}],["path",{d:"m5.636 5.636.707.707",key:"1xv1c5"}],["path",{d:"m17.657 17.657.707.707",key:"vl76zb"}]]);/**
492
+ * @license lucide-react v0.460.0 - ISC
493
+ *
494
+ * This source code is licensed under the ISC license.
495
+ * See the LICENSE file in the root directory of this source tree.
496
+ */const e2=Me("Tag",[["path",{d:"M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z",key:"vktsd0"}],["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}]]);/**
497
+ * @license lucide-react v0.460.0 - ISC
498
+ *
499
+ * This source code is licensed under the ISC license.
500
+ * See the LICENSE file in the root directory of this source tree.
501
+ */const Al=Me("Terminal",[["polyline",{points:"4 17 10 11 4 5",key:"akl6gq"}],["line",{x1:"12",x2:"20",y1:"19",y2:"19",key:"q2wloq"}]]);/**
502
+ * @license lucide-react v0.460.0 - ISC
503
+ *
504
+ * This source code is licensed under the ISC license.
505
+ * See the LICENSE file in the root directory of this source tree.
506
+ */const bn=Me("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]]);/**
507
+ * @license lucide-react v0.460.0 - ISC
508
+ *
509
+ * This source code is licensed under the ISC license.
510
+ * See the LICENSE file in the root directory of this source tree.
511
+ */const Kh=Me("TriangleAlert",[["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"}]]);/**
512
+ * @license lucide-react v0.460.0 - ISC
513
+ *
514
+ * This source code is licensed under the ISC license.
515
+ * See the LICENSE file in the root directory of this source tree.
516
+ */const c4=Me("Type",[["polyline",{points:"4 7 4 4 20 4 20 7",key:"1nosan"}],["line",{x1:"9",x2:"15",y1:"20",y2:"20",key:"swin9y"}],["line",{x1:"12",x2:"12",y1:"4",y2:"20",key:"1tx1rr"}]]);/**
517
+ * @license lucide-react v0.460.0 - ISC
518
+ *
519
+ * This source code is licensed under the ISC license.
520
+ * See the LICENSE file in the root directory of this source tree.
521
+ */const u4=Me("Upload",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"17 8 12 3 7 8",key:"t8dd8p"}],["line",{x1:"12",x2:"12",y1:"3",y2:"15",key:"widbto"}]]);/**
522
+ * @license lucide-react v0.460.0 - ISC
523
+ *
524
+ * This source code is licensed under the ISC license.
525
+ * See the LICENSE file in the root directory of this source tree.
526
+ */const d4=Me("Workflow",[["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"}]]);/**
527
+ * @license lucide-react v0.460.0 - ISC
528
+ *
529
+ * This source code is licensed under the ISC license.
530
+ * See the LICENSE file in the root directory of this source tree.
531
+ */const Cd=Me("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);function t2(e){var t,n,r="";if(typeof e=="string"||typeof e=="number")r+=e;else if(typeof e=="object")if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(n=t2(e[t]))&&(r&&(r+=" "),r+=n)}else for(n in e)e[n]&&(r&&(r+=" "),r+=n);return r}function f4(){for(var e,t,n=0,r="",o=arguments.length;n<o;n++)(e=arguments[n])&&(t=t2(e))&&(r&&(r+=" "),r+=t);return r}const Mv="-",p4=e=>{const t=m4(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:a=>{const l=a.split(Mv);return l[0]===""&&l.length!==1&&l.shift(),n2(l,t)||h4(a)},getConflictingClassGroupIds:(a,l)=>{const d=n[a]||[];return l&&r[a]?[...d,...r[a]]:d}}},n2=(e,t)=>{var a;if(e.length===0)return t.classGroupId;const n=e[0],r=t.nextPart.get(n),o=r?n2(e.slice(1),r):void 0;if(o)return o;if(t.validators.length===0)return;const i=e.join(Mv);return(a=t.validators.find(({validator:l})=>l(i)))==null?void 0:a.classGroupId},p1=/^\[(.+)\]$/,h4=e=>{if(p1.test(e)){const t=p1.exec(e)[1],n=t==null?void 0:t.substring(0,t.indexOf(":"));if(n)return"arbitrary.."+n}},m4=e=>{const{theme:t,prefix:n}=e,r={nextPart:new Map,validators:[]};return x4(Object.entries(e.classGroups),n).forEach(([i,a])=>{db(a,r,i,t)}),r},db=(e,t,n,r)=>{e.forEach(o=>{if(typeof o=="string"){const i=o===""?t:h1(t,o);i.classGroupId=n;return}if(typeof o=="function"){if(g4(o)){db(o(r),t,n,r);return}t.validators.push({validator:o,classGroupId:n});return}Object.entries(o).forEach(([i,a])=>{db(a,h1(t,i),n,r)})})},h1=(e,t)=>{let n=e;return t.split(Mv).forEach(r=>{n.nextPart.has(r)||n.nextPart.set(r,{nextPart:new Map,validators:[]}),n=n.nextPart.get(r)}),n},g4=e=>e.isThemeGetter,x4=(e,t)=>t?e.map(([n,r])=>{const o=r.map(i=>typeof i=="string"?t+i:typeof i=="object"?Object.fromEntries(Object.entries(i).map(([a,l])=>[t+a,l])):i);return[n,o]}):e,y4=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,n=new Map,r=new Map;const o=(i,a)=>{n.set(i,a),t++,t>e&&(t=0,r=n,n=new Map)};return{get(i){let a=n.get(i);if(a!==void 0)return a;if((a=r.get(i))!==void 0)return o(i,a),a},set(i,a){n.has(i)?n.set(i,a):o(i,a)}}},r2="!",b4=e=>{const{separator:t,experimentalParseClassName:n}=e,r=t.length===1,o=t[0],i=t.length,a=l=>{const d=[];let f=0,p=0,h;for(let b=0;b<l.length;b++){let j=l[b];if(f===0){if(j===o&&(r||l.slice(b,b+i)===t)){d.push(l.slice(p,b)),p=b+i;continue}if(j==="/"){h=b;continue}}j==="["?f++:j==="]"&&f--}const g=d.length===0?l:l.substring(p),y=g.startsWith(r2),k=y?g.substring(1):g,w=h&&h>p?h-p:void 0;return{modifiers:d,hasImportantModifier:y,baseClassName:k,maybePostfixModifierPosition:w}};return n?l=>n({className:l,parseClassName:a}):a},v4=e=>{if(e.length<=1)return e;const t=[];let n=[];return e.forEach(r=>{r[0]==="["?(t.push(...n.sort(),r),n=[]):n.push(r)}),t.push(...n.sort()),t},w4=e=>({cache:y4(e.cacheSize),parseClassName:b4(e),...p4(e)}),j4=/\s+/,k4=(e,t)=>{const{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:o}=t,i=[],a=e.trim().split(j4);let l="";for(let d=a.length-1;d>=0;d-=1){const f=a[d],{modifiers:p,hasImportantModifier:h,baseClassName:g,maybePostfixModifierPosition:y}=n(f);let k=!!y,w=r(k?g.substring(0,y):g);if(!w){if(!k){l=f+(l.length>0?" "+l:l);continue}if(w=r(g),!w){l=f+(l.length>0?" "+l:l);continue}k=!1}const b=v4(p).join(":"),j=h?b+r2:b,N=j+w;if(i.includes(N))continue;i.push(N);const S=o(w,k);for(let C=0;C<S.length;++C){const D=S[C];i.push(j+D)}l=f+(l.length>0?" "+l:l)}return l};function S4(){let e=0,t,n,r="";for(;e<arguments.length;)(t=arguments[e++])&&(n=s2(t))&&(r&&(r+=" "),r+=n);return r}const s2=e=>{if(typeof e=="string")return e;let t,n="";for(let r=0;r<e.length;r++)e[r]&&(t=s2(e[r]))&&(n&&(n+=" "),n+=t);return n};function N4(e,...t){let n,r,o,i=a;function a(d){const f=t.reduce((p,h)=>h(p),e());return n=w4(f),r=n.cache.get,o=n.cache.set,i=l,l(d)}function l(d){const f=r(d);if(f)return f;const p=k4(d,n);return o(d,p),p}return function(){return i(S4.apply(null,arguments))}}const Xt=e=>{const t=n=>n[e]||[];return t.isThemeGetter=!0,t},o2=/^\[(?:([a-z-]+):)?(.+)\]$/i,C4=/^\d+\/\d+$/,E4=new Set(["px","full","screen"]),T4=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,R4=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,A4=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,P4=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,_4=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,xo=e=>Pl(e)||E4.has(e)||C4.test(e),oi=e=>pc(e,"length",z4),Pl=e=>!!e&&!Number.isNaN(Number(e)),Hx=e=>pc(e,"number",Pl),uu=e=>!!e&&Number.isInteger(Number(e)),D4=e=>e.endsWith("%")&&Pl(e.slice(0,-1)),vt=e=>o2.test(e),ii=e=>T4.test(e),$4=new Set(["length","size","percentage"]),I4=e=>pc(e,$4,i2),M4=e=>pc(e,"position",i2),L4=new Set(["image","url"]),O4=e=>pc(e,L4,U4),F4=e=>pc(e,"",B4),du=()=>!0,pc=(e,t,n)=>{const r=o2.exec(e);return r?r[1]?typeof t=="string"?r[1]===t:t.has(r[1]):n(r[2]):!1},z4=e=>R4.test(e)&&!A4.test(e),i2=()=>!1,B4=e=>P4.test(e),U4=e=>_4.test(e),H4=()=>{const e=Xt("colors"),t=Xt("spacing"),n=Xt("blur"),r=Xt("brightness"),o=Xt("borderColor"),i=Xt("borderRadius"),a=Xt("borderSpacing"),l=Xt("borderWidth"),d=Xt("contrast"),f=Xt("grayscale"),p=Xt("hueRotate"),h=Xt("invert"),g=Xt("gap"),y=Xt("gradientColorStops"),k=Xt("gradientColorStopPositions"),w=Xt("inset"),b=Xt("margin"),j=Xt("opacity"),N=Xt("padding"),S=Xt("saturate"),C=Xt("scale"),D=Xt("sepia"),T=Xt("skew"),R=Xt("space"),$=Xt("translate"),_=()=>["auto","contain","none"],U=()=>["auto","hidden","clip","visible","scroll"],I=()=>["auto",vt,t],F=()=>[vt,t],M=()=>["",xo,oi],A=()=>["auto",Pl,vt],L=()=>["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"],z=()=>["solid","dashed","dotted","double","none"],W=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],V=()=>["start","end","center","between","around","evenly","stretch"],K=()=>["","0",vt],O=()=>["auto","avoid","all","avoid-page","page","left","right","column"],B=()=>[Pl,vt];return{cacheSize:500,separator:":",theme:{colors:[du],spacing:[xo,oi],blur:["none","",ii,vt],brightness:B(),borderColor:[e],borderRadius:["none","","full",ii,vt],borderSpacing:F(),borderWidth:M(),contrast:B(),grayscale:K(),hueRotate:B(),invert:K(),gap:F(),gradientColorStops:[e],gradientColorStopPositions:[D4,oi],inset:I(),margin:I(),opacity:B(),padding:F(),saturate:B(),scale:B(),sepia:K(),skew:B(),space:F(),translate:F()},classGroups:{aspect:[{aspect:["auto","square","video",vt]}],container:["container"],columns:[{columns:[ii]}],"break-after":[{"break-after":O()}],"break-before":[{"break-before":O()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:[...L(),vt]}],overflow:[{overflow:U()}],"overflow-x":[{"overflow-x":U()}],"overflow-y":[{"overflow-y":U()}],overscroll:[{overscroll:_()}],"overscroll-x":[{"overscroll-x":_()}],"overscroll-y":[{"overscroll-y":_()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:[w]}],"inset-x":[{"inset-x":[w]}],"inset-y":[{"inset-y":[w]}],start:[{start:[w]}],end:[{end:[w]}],top:[{top:[w]}],right:[{right:[w]}],bottom:[{bottom:[w]}],left:[{left:[w]}],visibility:["visible","invisible","collapse"],z:[{z:["auto",uu,vt]}],basis:[{basis:I()}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["wrap","wrap-reverse","nowrap"]}],flex:[{flex:["1","auto","initial","none",vt]}],grow:[{grow:K()}],shrink:[{shrink:K()}],order:[{order:["first","last","none",uu,vt]}],"grid-cols":[{"grid-cols":[du]}],"col-start-end":[{col:["auto",{span:["full",uu,vt]},vt]}],"col-start":[{"col-start":A()}],"col-end":[{"col-end":A()}],"grid-rows":[{"grid-rows":[du]}],"row-start-end":[{row:["auto",{span:[uu,vt]},vt]}],"row-start":[{"row-start":A()}],"row-end":[{"row-end":A()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":["auto","min","max","fr",vt]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",vt]}],gap:[{gap:[g]}],"gap-x":[{"gap-x":[g]}],"gap-y":[{"gap-y":[g]}],"justify-content":[{justify:["normal",...V()]}],"justify-items":[{"justify-items":["start","end","center","stretch"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch"]}],"align-content":[{content:["normal",...V(),"baseline"]}],"align-items":[{items:["start","end","center","baseline","stretch"]}],"align-self":[{self:["auto","start","end","center","stretch","baseline"]}],"place-content":[{"place-content":[...V(),"baseline"]}],"place-items":[{"place-items":["start","end","center","baseline","stretch"]}],"place-self":[{"place-self":["auto","start","end","center","stretch"]}],p:[{p:[N]}],px:[{px:[N]}],py:[{py:[N]}],ps:[{ps:[N]}],pe:[{pe:[N]}],pt:[{pt:[N]}],pr:[{pr:[N]}],pb:[{pb:[N]}],pl:[{pl:[N]}],m:[{m:[b]}],mx:[{mx:[b]}],my:[{my:[b]}],ms:[{ms:[b]}],me:[{me:[b]}],mt:[{mt:[b]}],mr:[{mr:[b]}],mb:[{mb:[b]}],ml:[{ml:[b]}],"space-x":[{"space-x":[R]}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":[R]}],"space-y-reverse":["space-y-reverse"],w:[{w:["auto","min","max","fit","svw","lvw","dvw",vt,t]}],"min-w":[{"min-w":[vt,t,"min","max","fit"]}],"max-w":[{"max-w":[vt,t,"none","full","min","max","fit","prose",{screen:[ii]},ii]}],h:[{h:[vt,t,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[vt,t,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[vt,t,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[vt,t,"auto","min","max","fit"]}],"font-size":[{text:["base",ii,oi]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",Hx]}],"font-family":[{font:[du]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:["tighter","tight","normal","wide","wider","widest",vt]}],"line-clamp":[{"line-clamp":["none",Pl,Hx]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",xo,vt]}],"list-image":[{"list-image":["none",vt]}],"list-style-type":[{list:["none","disc","decimal",vt]}],"list-style-position":[{list:["inside","outside"]}],"placeholder-color":[{placeholder:[e]}],"placeholder-opacity":[{"placeholder-opacity":[j]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"text-color":[{text:[e]}],"text-opacity":[{"text-opacity":[j]}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...z(),"wavy"]}],"text-decoration-thickness":[{decoration:["auto","from-font",xo,oi]}],"underline-offset":[{"underline-offset":["auto",xo,vt]}],"text-decoration-color":[{decoration:[e]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:F()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",vt]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",vt]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-opacity":[{"bg-opacity":[j]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:[...L(),M4]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",I4]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},O4]}],"bg-color":[{bg:[e]}],"gradient-from-pos":[{from:[k]}],"gradient-via-pos":[{via:[k]}],"gradient-to-pos":[{to:[k]}],"gradient-from":[{from:[y]}],"gradient-via":[{via:[y]}],"gradient-to":[{to:[y]}],rounded:[{rounded:[i]}],"rounded-s":[{"rounded-s":[i]}],"rounded-e":[{"rounded-e":[i]}],"rounded-t":[{"rounded-t":[i]}],"rounded-r":[{"rounded-r":[i]}],"rounded-b":[{"rounded-b":[i]}],"rounded-l":[{"rounded-l":[i]}],"rounded-ss":[{"rounded-ss":[i]}],"rounded-se":[{"rounded-se":[i]}],"rounded-ee":[{"rounded-ee":[i]}],"rounded-es":[{"rounded-es":[i]}],"rounded-tl":[{"rounded-tl":[i]}],"rounded-tr":[{"rounded-tr":[i]}],"rounded-br":[{"rounded-br":[i]}],"rounded-bl":[{"rounded-bl":[i]}],"border-w":[{border:[l]}],"border-w-x":[{"border-x":[l]}],"border-w-y":[{"border-y":[l]}],"border-w-s":[{"border-s":[l]}],"border-w-e":[{"border-e":[l]}],"border-w-t":[{"border-t":[l]}],"border-w-r":[{"border-r":[l]}],"border-w-b":[{"border-b":[l]}],"border-w-l":[{"border-l":[l]}],"border-opacity":[{"border-opacity":[j]}],"border-style":[{border:[...z(),"hidden"]}],"divide-x":[{"divide-x":[l]}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":[l]}],"divide-y-reverse":["divide-y-reverse"],"divide-opacity":[{"divide-opacity":[j]}],"divide-style":[{divide:z()}],"border-color":[{border:[o]}],"border-color-x":[{"border-x":[o]}],"border-color-y":[{"border-y":[o]}],"border-color-s":[{"border-s":[o]}],"border-color-e":[{"border-e":[o]}],"border-color-t":[{"border-t":[o]}],"border-color-r":[{"border-r":[o]}],"border-color-b":[{"border-b":[o]}],"border-color-l":[{"border-l":[o]}],"divide-color":[{divide:[o]}],"outline-style":[{outline:["",...z()]}],"outline-offset":[{"outline-offset":[xo,vt]}],"outline-w":[{outline:[xo,oi]}],"outline-color":[{outline:[e]}],"ring-w":[{ring:M()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:[e]}],"ring-opacity":[{"ring-opacity":[j]}],"ring-offset-w":[{"ring-offset":[xo,oi]}],"ring-offset-color":[{"ring-offset":[e]}],shadow:[{shadow:["","inner","none",ii,F4]}],"shadow-color":[{shadow:[du]}],opacity:[{opacity:[j]}],"mix-blend":[{"mix-blend":[...W(),"plus-lighter","plus-darker"]}],"bg-blend":[{"bg-blend":W()}],filter:[{filter:["","none"]}],blur:[{blur:[n]}],brightness:[{brightness:[r]}],contrast:[{contrast:[d]}],"drop-shadow":[{"drop-shadow":["","none",ii,vt]}],grayscale:[{grayscale:[f]}],"hue-rotate":[{"hue-rotate":[p]}],invert:[{invert:[h]}],saturate:[{saturate:[S]}],sepia:[{sepia:[D]}],"backdrop-filter":[{"backdrop-filter":["","none"]}],"backdrop-blur":[{"backdrop-blur":[n]}],"backdrop-brightness":[{"backdrop-brightness":[r]}],"backdrop-contrast":[{"backdrop-contrast":[d]}],"backdrop-grayscale":[{"backdrop-grayscale":[f]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[p]}],"backdrop-invert":[{"backdrop-invert":[h]}],"backdrop-opacity":[{"backdrop-opacity":[j]}],"backdrop-saturate":[{"backdrop-saturate":[S]}],"backdrop-sepia":[{"backdrop-sepia":[D]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":[a]}],"border-spacing-x":[{"border-spacing-x":[a]}],"border-spacing-y":[{"border-spacing-y":[a]}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["none","all","","colors","opacity","shadow","transform",vt]}],duration:[{duration:B()}],ease:[{ease:["linear","in","out","in-out",vt]}],delay:[{delay:B()}],animate:[{animate:["none","spin","ping","pulse","bounce",vt]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[C]}],"scale-x":[{"scale-x":[C]}],"scale-y":[{"scale-y":[C]}],rotate:[{rotate:[uu,vt]}],"translate-x":[{"translate-x":[$]}],"translate-y":[{"translate-y":[$]}],"skew-x":[{"skew-x":[T]}],"skew-y":[{"skew-y":[T]}],"transform-origin":[{origin:["center","top","top-right","right","bottom-right","bottom","bottom-left","left","top-left",vt]}],accent:[{accent:["auto",e]}],appearance:[{appearance:["none","auto"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",vt]}],"caret-color":[{caret:[e]}],"pointer-events":[{"pointer-events":["none","auto"]}],resize:[{resize:["none","y","x",""]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":F()}],"scroll-mx":[{"scroll-mx":F()}],"scroll-my":[{"scroll-my":F()}],"scroll-ms":[{"scroll-ms":F()}],"scroll-me":[{"scroll-me":F()}],"scroll-mt":[{"scroll-mt":F()}],"scroll-mr":[{"scroll-mr":F()}],"scroll-mb":[{"scroll-mb":F()}],"scroll-ml":[{"scroll-ml":F()}],"scroll-p":[{"scroll-p":F()}],"scroll-px":[{"scroll-px":F()}],"scroll-py":[{"scroll-py":F()}],"scroll-ps":[{"scroll-ps":F()}],"scroll-pe":[{"scroll-pe":F()}],"scroll-pt":[{"scroll-pt":F()}],"scroll-pr":[{"scroll-pr":F()}],"scroll-pb":[{"scroll-pb":F()}],"scroll-pl":[{"scroll-pl":F()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",vt]}],fill:[{fill:[e,"none"]}],"stroke-w":[{stroke:[xo,oi,Hx]}],stroke:[{stroke:[e,"none"]}],sr:["sr-only","not-sr-only"],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-s","border-color-e","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]}}},V4=N4(H4);function Ce(...e){return V4(f4(e))}function Gn(e){if(!e)return"—";const t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleDateString(void 0,{month:"short",day:"numeric",year:"numeric"})}function es(e){if(!e)return"—";const t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleString(void 0,{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"})}function a2(e){if(!e)return"—";const t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleDateString(void 0,{month:"short",day:"numeric"})}function l2(e){if(!e)return"—";const t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleString(void 0,{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"})}function c2(e){if(!e)return"—";const t=new Date(e);if(Number.isNaN(t.getTime()))return e;const n=Math.floor((Date.now()-t.getTime())/1e3);if(n<60)return"just now";const r=Math.floor(n/60);if(r<60)return`${r}m ago`;const o=Math.floor(r/60);return o<24?`${o}h ago`:`${Math.floor(o/24)}d ago`}function Wl(e){return e.toLocaleString("en-US")}function ql(e){if(!Number.isFinite(e))return"$0.00";const t=e!==0&&Math.abs(e)<1?4:2;return e.toLocaleString("en-US",{style:"currency",currency:"USD",minimumFractionDigits:2,maximumFractionDigits:t})}function W4(e){if(!e)return"—";const t=/^(\d{4})-(\d{2})-(\d{2})$/.exec(e);if(!t)return e;const[,n,r,o]=t,i=new Date(Number(n),Number(r)-1,Number(o));return Number.isNaN(i.getTime())?e:i.toLocaleDateString(void 0,{month:"short",day:"numeric",year:"numeric"})}function Dn(e){return e.split(/[_\s-]+/).filter(Boolean).map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ")}function u2(e){return!e||e==="/"?"/":e.endsWith("/")?e.slice(0,-1):e}function q4(e){let t=u2(e);const n=t.match(/^\/w\/[^/]+(\/.*)?$/);return n&&(t=n[1]||"/"),t==="/"?"/":t.startsWith("/archive")?"/archive":t.startsWith("/projects")?/^\/projects\/[^/]+\/assignments\//.test(t)?"/assignments":"/projects":t.startsWith("/assignments")?"/assignments":t.startsWith("/servers")?"/servers":t.startsWith("/inventories")?"/inventories":t.startsWith("/usage")?"/usage":t.startsWith("/agent-sessions")?"/agent-sessions":t.startsWith("/playbooks")?"/playbooks":t.startsWith("/memories")?"/memories":t.startsWith("/resources")?"/resources":t.startsWith("/todos")?"/todos":t.startsWith("/views")?"/views":t.startsWith("/help")?"/help":t.startsWith("/settings")?"/settings":t.startsWith("/workflow")?"/workflow":null}function d2(e,t){return q4(e)===t}function f2(e){let n=u2(e).split("/").filter(Boolean);const r=[];let o="Overview",i=null,a="";if(n[0]==="w"&&n[1]&&(a=`/w/${n[1]}`,r.push({label:Dn(n[1]),path:`${a}/projects`}),n=n.slice(2)),n.length===0)return{title:o,breadcrumbs:r,projectSlug:i};if(n[0]==="projects"){if(r.push({label:"Projects",path:`${a}/projects`}),o="Projects",n[1]&&(i=n[1],r.push({label:Dn(n[1]),path:`${a}/projects/${n[1]}`}),o=Dn(n[1])),n[2]==="edit")o="Edit Project";else if(n[2]==="create"&&n[3]==="assignment")o="Create Assignment";else if(n[2]==="assignments"&&n[3])r.push({label:Dn(n[3]),path:`${a}/projects/${n[1]}/assignments/${n[3]}`}),o=Dn(n[3]),n[4]==="edit"?o="Edit Assignment":n[4]==="plan"&&n[5]==="edit"?o="Edit Plan":n[4]==="scratchpad"&&n[5]==="edit"?o="Edit Scratchpad":n[4]==="handoff"&&n[5]==="edit"?o="Append Handoff":n[4]==="decision-record"&&n[5]==="edit"&&(o="Append Decision");else if((n[2]==="memories"||n[2]==="resources")&&n[3]){const l=n[2]==="memories"?"Memories":"Resources",d=n[2]==="memories"?"/memories":"/resources";r.push({label:l,path:d}),r.push({label:Dn(n[3]),path:`${a}/projects/${n[1]}/${n[2]}/${n[3]}`}),o=Dn(n[3]),n[4]==="edit"&&(o=n[2]==="memories"?"Edit Memory":"Edit Resource")}}else n[0]==="servers"?(o="Servers",r.push({label:"Servers",path:`${a}/servers`})):n[0]==="inventories"?(o="Inventories",r.push({label:"Inventories",path:`${a}/inventories`})):n[0]==="usage"?(o="Usage",r.push({label:"Usage",path:`${a}/usage`})):n[0]==="agent-sessions"?(o="Agent Sessions",r.push({label:"Agent Sessions",path:`${a}/agent-sessions`})):n[0]==="assignments"?(o="Assignments",r.push({label:"Assignments",path:`${a}/assignments`})):n[0]==="archive"?(o="Archive",r.push({label:"Archive",path:"/archive"})):n[0]==="playbooks"?(r.push({label:"Playbooks",path:"/playbooks"}),o="Playbooks",n[1]==="create"?o="Create Playbook":n[1]&&n[2]==="edit"?(r.push({label:Dn(n[1]),path:`/playbooks/${n[1]}`}),o="Edit Playbook"):n[1]&&(r.push({label:Dn(n[1]),path:`/playbooks/${n[1]}`}),o=Dn(n[1]))):n[0]==="memories"?(r.push({label:"Memories",path:"/memories"}),o="Memories",n[1]==="new"&&(o="New Memory")):n[0]==="resources"?(r.push({label:"Resources",path:"/resources"}),o="Resources",n[1]==="new"&&(o="New Resource")):n[0]==="todos"?(o="Todos",r.push({label:"Todos",path:`${a}/todos`})):n[0]==="views"?(o="Saved Views",r.push({label:"Saved Views",path:`${a}/views`}),n[1]&&(o="View")):n[0]==="help"?(o="Help",r.push({label:"Help",path:"/help"})):n[0]==="settings"?(o="Settings",r.push({label:"Settings",path:"/settings"})):n[0]==="workflow"?(o="Workflow",r.push({label:"Workflow",path:"/workflow"})):n[0]==="create"&&n[1]==="project"&&(o="Create Project",r.push({label:"Create Project",path:`${a}/create/project`}));return{title:o,breadcrumbs:r,projectSlug:i}}function m1({items:e,onNavigate:t}){const n=or();return s.jsx("nav",{className:"space-y-1",children:e.map(r=>{const o=r.icon,i=d2(n.pathname,r.to)&&!n.pathname.startsWith("/w/");return s.jsxs(Ie,{to:r.to,onClick:t,className:Ce("flex items-center gap-3 rounded-md px-3 py-2 text-sm font-medium transition",i?"bg-foreground text-background shadow-sm":"text-muted-foreground hover:bg-background/80 hover:text-foreground"),children:[s.jsx(o,{className:"h-4 w-4"}),s.jsx("span",{children:r.label})]},r.to)})})}const p2=[{slug:"default",label:"Syntaur",description:"Brand purple, warm yellow, coral & teal accents.",swatches:{primary:"oklch(70% 0.18 290)",secondary:"oklch(80% 0.14 75)",coral:"oklch(72% 0.17 15)",teal:"oklch(72% 0.14 185)",amber:"oklch(82% 0.16 75)"}},{slug:"ocean",label:"Midnight",description:"Deep indigo-blue with cyan accents. Inspired by One Dark Pro.",swatches:{primary:"oklch(70% 0.16 240)",secondary:"oklch(78% 0.13 200)",coral:"oklch(72% 0.18 350)",teal:"oklch(78% 0.14 195)",amber:"oklch(84% 0.15 90)"}},{slug:"forest",label:"Verdant",description:"Saturated emerald and pine on a dark olive base.",swatches:{primary:"oklch(72% 0.17 145)",secondary:"oklch(80% 0.13 110)",coral:"oklch(72% 0.17 25)",teal:"oklch(75% 0.13 175)",amber:"oklch(82% 0.16 95)"}},{slug:"sunset",label:"Ember",description:"Warm sepia surfaces with copper and amber accents.",swatches:{primary:"oklch(72% 0.18 35)",secondary:"oklch(80% 0.16 60)",coral:"oklch(72% 0.19 15)",teal:"oklch(72% 0.12 180)",amber:"oklch(86% 0.17 70)"}}],K4=p2.map(e=>e.slug),nh="default";function h2(e){return typeof e=="string"&&K4.includes(e)}const m2={preset:nh,custom:!1};let Tu=null,ol=null;function Lv(e){if(!e||typeof e!="object")return m2;const t=e;return{preset:h2(t.preset)?t.preset:nh,custom:t.custom===!0}}function G4(){return Tu?Promise.resolve(Tu):ol||(ol=fetch("/api/config/theme").then(e=>{if(!e.ok)throw new Error(`HTTP ${e.status}`);return e.json()}).then(e=>{const t=Lv(e);return Tu=t,ol=null,t}).catch(()=>(ol=null,m2)),ol)}async function Y4(e){const t=await fetch("/api/config/theme",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({preset:e})});if(!t.ok){const r=await t.json().catch(()=>({error:`HTTP ${t.status}`}));throw new Error(r.error??"Failed to save theme")}const n=Lv(await t.json());return Tu=n,n}async function X4(){const e=await fetch("/api/config/theme",{method:"DELETE"});if(!e.ok)throw new Error(`HTTP ${e.status}`);const t=Lv(await e.json());return Tu=t,t}const fb="syntaur-theme",Tp="syntaur-preset",g2=m.createContext(null);function pb(){try{const e=window.localStorage.getItem(fb);return e==="light"||e==="dark"?e:null}catch{return null}}function x2(){try{const e=window.localStorage.getItem(Tp);return h2(e)?e:nh}catch{return nh}}function y2(){return typeof window>"u"||!window.matchMedia?"light":window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function b2(e){document.documentElement.classList.toggle("dark",e==="dark")}function v2(e){document.documentElement.dataset.theme=e}function Q4(){typeof document>"u"||(b2(pb()??y2()),v2(x2()))}function J4({children:e}){const[t,n]=m.useState(()=>pb()),[r,o]=m.useState(()=>pb()??y2()),[i,a]=m.useState(()=>x2());m.useEffect(()=>{b2(r)},[r]),m.useEffect(()=>{v2(i)},[i]),m.useEffect(()=>{let p=!1;return G4().then(h=>{if(!p&&h.preset!==i){a(h.preset);try{window.localStorage.setItem(Tp,h.preset)}catch{}}}),()=>{p=!0}},[]),m.useEffect(()=>{if(!window.matchMedia)return;const p=window.matchMedia("(prefers-color-scheme: dark)"),h=()=>{t||o(p.matches?"dark":"light")};return h(),p.addEventListener("change",h),()=>{p.removeEventListener("change",h)}},[t]);async function l(p){a(p);try{window.localStorage.setItem(Tp,p)}catch{}await Y4(p)}async function d(){const p=await X4();a(p.preset);try{window.localStorage.setItem(Tp,p.preset)}catch{}}const f={resolvedTheme:r,explicitTheme:t,setTheme:p=>{window.localStorage.setItem(fb,p),n(p),o(p)},toggleTheme:()=>{const p=r==="dark"?"light":"dark";window.localStorage.setItem(fb,p),n(p),o(p)},preset:i,setPreset:l,resetPreset:d};return s.jsx(g2.Provider,{value:f,children:e})}function Ov(){const e=m.useContext(g2);if(!e)throw new Error("useTheme must be used within ThemeProvider");return e}const Z4=2e3,Ru=new Set;let mr=null,sa=null,Rp=!1;function eO(){return`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/ws`}let tO=eO;function nO(){sa&&clearTimeout(sa),sa=setTimeout(()=>{sa=null,w2()},Z4)}function w2(){mr&&(mr.readyState===WebSocket.OPEN||mr.readyState===WebSocket.CONNECTING)||(Rp=!1,mr=new WebSocket(tO()),mr.onmessage=e=>{try{const t=JSON.parse(e.data);for(const n of Ru)n(t)}catch{}},mr.onclose=()=>{if(mr=null,Rp||Ru.size===0){Rp=!1;return}nO()},mr.onerror=()=>{mr==null||mr.close()})}function rO(e){return Ru.add(e),w2(),()=>{Ru.delete(e),Ru.size===0&&(sa&&(clearTimeout(sa),sa=null),mr&&(Rp=!0,mr.close(),mr=null))}}function hc(e){const t=m.useRef(e);t.current=e,m.useEffect(()=>rO(o=>t.current(o)),[])}const Gh=["7d","30d","90d","all","custom"],j2="30d",sO=/^\d{4}-\d{2}-\d{2}$/,Ed=["project","workspace","model","tool"],oO={"7d":7,"30d":30,"90d":90};function Au(e){if(typeof e!="string"||!sO.test(e))return!1;const[t,n,r]=e.split("-").map(Number);if(n<1||n>12||r<1||r>31)return!1;const o=new Date(Date.UTC(t,n-1,r));return o.getUTCFullYear()===t&&o.getUTCMonth()===n-1&&o.getUTCDate()===r}function g1(e){const t=e.getUTCFullYear(),n=String(e.getUTCMonth()+1).padStart(2,"0"),r=String(e.getUTCDate()).padStart(2,"0");return`${t}-${n}-${r}`}function iO(e,t){return new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()+t))}function aO(e,t=new Date){const n=e.window??j2;if(n==="all")return{};if(n==="custom"){const o={};return e.since&&(o.since=e.since),e.until&&(o.until=e.until),o}const r=new Date(Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate()));return{since:g1(iO(r,-(oO[n]-1))),until:g1(r)}}function lO(e){const t=[];if(!e||typeof e!="object"||Array.isArray(e))return{ok:!1,errors:["filters must be an object"]};const n=e;n.window!==void 0&&!Gh.includes(n.window)&&t.push(`invalid window: ${String(n.window)}`);for(const r of["since","until"])n[r]!==void 0&&!Au(n[r])&&t.push(`invalid ${r}: ${String(n[r])} (expected YYYY-MM-DD)`);for(const r of Ed)n[r]!==void 0&&(typeof n[r]!="string"||n[r].length===0)&&t.push(`invalid ${r}: must be a non-empty string`);return Au(n.since)&&Au(n.until)&&n.since>n.until&&t.push("since must be on or before until"),{ok:t.length===0,errors:t}}function Td(e){const t={};if(!e||typeof e!="object"||Array.isArray(e))return t;const n=e;typeof n.window=="string"&&Gh.includes(n.window)&&(t.window=n.window),Au(n.since)&&(t.since=n.since),Au(n.until)&&(t.until=n.until);for(const r of Ed)typeof n[r]=="string"&&n[r].length>0&&(t[r]=n[r]);return t.window!=="custom"&&(delete t.since,delete t.until),t}function hb(e){const t=Td(e),n=new URLSearchParams;t.window&&n.set("window",t.window),t.window==="custom"&&(t.since&&n.set("since",t.since),t.until&&n.set("until",t.until));for(const r of Ed)t[r]&&n.set(r,t[r]);return n}function cO(e){const t={};for(const n of["window","since","until",...Ed]){const r=e.get(n);r!==null&&(t[n]=r)}return Td(t)}function k2(e,t=new Date){const n=Td(e),{since:r,until:o}=aO(n,t),i=new URLSearchParams;r&&i.set("since",r),o&&i.set("until",o);for(const a of Ed)n[a]&&i.set(a,n[a]);return i}const uO={"7d":"Last 7 days","30d":"Last 30 days","90d":"Last 90 days",all:"All time",custom:"Custom range"};function x1(e){const t=Td(e),n=t.window??j2,r=[];return r.push(n==="custom"?`${t.since??"…"} → ${t.until??"…"}`:uO[n]),t.workspace&&r.push(`workspace: ${t.workspace}`),t.project&&r.push(`project: ${t.project}`),t.model&&r.push(`model: ${t.model}`),t.tool&&r.push(`tool: ${t.tool}`),r.join(" · ")}function Zt(e,t,n=!0,r=!1){const[o,i]=m.useState(null),[a,l]=m.useState(!0),[d,f]=m.useState(null),[p,h]=m.useState(0),g=n?e:null,y=m.useCallback(()=>{h(w=>w+1)},[]),k=m.useRef(g);return r&&k.current!==g&&(k.current=g,i(null),f(null)),m.useEffect(()=>{if(!g){l(!1),i(null);return}let w=!1;return l(!0),f(null),fetch(g).then(async b=>{if(!b.ok){const j=await b.json().catch(()=>null);throw new Error((j==null?void 0:j.error)||`HTTP ${b.status}`)}return b.json()}).then(b=>{w||(i(b),l(!1))}).catch(b=>{w||(f(b.message),l(!1))}),()=>{w=!0}},[g,p]),hc(w=>{!t||!g||((w.type==="project-updated"||w.type==="assignment-updated")&&y(),w.type==="servers-updated"&&t==="servers"&&y(),w.type==="agent-sessions-updated"&&(t==="agent-sessions"||t==="overview")&&y(),w.type==="playbooks-updated"&&t==="playbooks"&&y(),w.type==="leases-updated"&&t==="inventories"&&y())}),{data:o,loading:a,error:d,refetch:y}}function Zs(e=!0){return Zt("/api/projects","projects",e)}function Sa(){return Zt("/api/workspaces","projects")}function pn(){const{workspace:e}=Vt();return e?`/w/${e}`:""}function dO(e={}){const t=new URLSearchParams;typeof e.staleLimit=="number"&&Number.isFinite(e.staleLimit)&&t.set("staleLimit",String(e.staleLimit)),typeof e.staleOffset=="number"&&Number.isFinite(e.staleOffset)&&t.set("staleOffset",String(e.staleOffset));const n=t.toString(),r=n?`/api/overview?${n}`:"/api/overview";return Zt(r,"overview")}function Yh(e=!0){return Zt("/api/assignments","assignments",e)}function fO(e=!0){return Zt("/api/archived","assignments",e)}function S2(){return Zt("/api/help")}function N2(e){const t=e?`/api/projects/${e}`:null;return Zt(t,"project")}function pO(e,t){const n=e&&t?`/api/projects/${e}/assignments/${t}`:null;return Zt(n,"assignment")}function hO(e){const t=e?`/api/assignments/${e}`:null;return Zt(t,"assignment")}function C2(e){return Zt(e)}function Fv(e=!0){return Zt("/api/servers","servers",e)}function E2(){return Zt("/api/leases","inventories")}function Xh(){return Zt("/api/agent-sessions","agent-sessions")}function mO(e,t){const n=e&&t?`/api/agent-sessions/${e}?assignment=${t}`:null;return Zt(n,"agent-sessions")}function gO(e){const t=e?`/api/assignments/${e}/sessions`:null;return Zt(t,"agent-sessions")}function xO(e,t){const n=e&&t?`/api/usage/projects/${encodeURIComponent(e)}/assignments/${encodeURIComponent(t)}`:null;return Zt(n,void 0,!0,!0)}function yO(e){const t=e?`/api/usage/standalone/${encodeURIComponent(e)}`:null;return Zt(t,void 0,!0,!0)}function zv(e=!0){return Zt("/api/playbooks","playbooks",e)}function bO(e){const t=k2(e).toString(),n=t?`/api/usage?${t}`:"/api/usage";return Zt(n,void 0,!0,!0)}function T2(e=!0){return Zt("/api/usage/facets",void 0,e)}function vO(e){const t=e?`/api/playbooks/${e}`:null;return Zt(t,"playbooks")}function wO(){return Zt("/api/memories","project")}function jO(e,t){const n=e&&t?`/api/projects/${e}/memories/${t}`:null;return Zt(n,"project")}function kO(){return Zt("/api/resources","project")}function SO(e,t){const n=e&&t?`/api/projects/${e}/resources/${t}`:null;return Zt(n,"project")}const Qh=["new-workspace","new-project","new-todo","new-assignment"];function NO(e){return typeof e=="string"&&Qh.includes(e)}const CO=["mod+k","mod+shift+k","?","escape","enter","shift+t","g","g o","g m","g a","g t","g s","g !","g ,","j","k","o","a","e","/","r","p","h","d","s","[","]"],EO=["mod","ctrl","alt","shift"];function xr(e){if(typeof e!="string")return"";const t=e.trim();if(!t)return"";if(/\s/.test(t)&&!t.includes("+"))return t.split(/\s+/).map(xr).filter(l=>l.length>0).join(" ");const n=t.split("+").map(l=>l.trim()).filter(l=>l.length>0);if(n.length===0)return"";if(n.length===1)return n[0].toLowerCase();const r=n[n.length-1].toLowerCase(),o=n.slice(0,-1).map(l=>l.toLowerCase()),i=new Set,a=[];for(const l of EO)o.includes(l)&&!i.has(l)&&(a.push(l),i.add(l));for(const l of o)i.has(l)||(a.push(l),i.add(l));return[...a,r].join("+")}function TO(e){const t=xr(e);return t?CO.includes(t):!1}const RO={"new-workspace":xr("Mod+Shift+Alt+w"),"new-project":xr("Mod+Shift+Alt+p"),"new-todo":xr("Mod+Shift+Alt+t"),"new-assignment":xr("Mod+Shift+Alt+a")};function AO(e){const t={...RO};for(const n of Qh){const r=e[n];typeof r=="string"&&r.length>0&&(t[n]=r)}return t}function na(){if(typeof navigator>"u")return!1;const e=navigator.platform||"",t=navigator.userAgent||"";return/Mac|iPhone|iPad|iPod/.test(e)||/Mac OS X/.test(t)}function PO(e){const t=e.split("+").map(o=>o.trim()),n=t[t.length-1]??"",r=new Set(t.slice(0,-1).map(o=>o.toLowerCase()));return{key:n.toLowerCase(),mod:r.has("mod"),shift:r.has("shift"),alt:r.has("alt"),ctrl:r.has("ctrl")}}function Qf(e,t){const n=PO(t);if(e.key.toLowerCase()!==n.key)return!1;const o=na()?e.metaKey:e.ctrlKey;return!(n.mod&&!o||!n.mod&&!n.ctrl&&o||n.ctrl&&!e.ctrlKey||n.shift&&!e.shiftKey||!n.shift&&!(n.key.length===1&&!/^[a-z0-9]$/.test(n.key))&&e.shiftKey||n.alt&&!e.altKey||!n.alt&&e.altKey)}function R2(e){const t=[],n=na()?e.metaKey:e.ctrlKey;n&&t.push("mod"),e.ctrlKey&&!n&&t.push("ctrl"),e.altKey&&t.push("alt");const r=e.key;let o;r===" "||r==="Spacebar"?o="space":(r.length,o=r.toLowerCase());const i=o.length===1&&/^[a-z0-9]$/.test(o);e.shiftKey&&i&&t.push("shift");const a=[...t,o].join("+");return xr(a)}function Gs(e){return e.split("+").map(n=>{const r=n.toLowerCase();return r==="mod"?na()?"⌘":"Ctrl":r==="shift"?na()?"⇧":"Shift":r==="alt"?na()?"⌥":"Alt":r==="ctrl"?na()?"⌃":"Ctrl":r==="enter"?"↵":r==="escape"?"Esc":r==="arrowup"?"↑":r==="arrowdown"?"↓":n.length===1?n.toUpperCase():n}).join(na()?"":"+")}function _O(e){const[t,n]=m.useState(null),[r,o]=m.useState(!0),[i,a]=m.useState(null),l=m.useCallback(async()=>{try{const d=await fetch(`/api/todos/${encodeURIComponent(e)}`);if(!d.ok)throw new Error(`HTTP ${d.status}`);n(await d.json()),a(null)}catch(d){a(d instanceof Error?d.message:"Failed to fetch todos")}finally{o(!1)}},[e]);return m.useEffect(()=>{l()},[l]),hc(d=>{d.type==="todos-updated"&&!d.projectSlug&&l()}),{data:t,loading:r,error:i,refetch:l}}function A2(e=!0){const[t,n]=m.useState(null),[r,o]=m.useState(!0),[i,a]=m.useState(null),l=m.useCallback(async()=>{try{const d=await fetch("/api/todos");if(!d.ok)throw new Error(`HTTP ${d.status}`);n(await d.json()),a(null)}catch(d){a(d instanceof Error?d.message:"Failed to fetch todos")}finally{o(!1)}},[]);return m.useEffect(()=>{if(!e){o(!1);return}l()},[l,e]),hc(d=>{e&&d.type==="todos-updated"&&!d.projectSlug&&l()}),{data:t,loading:r,error:i,refetch:l}}async function Bv(e,t,n){await Ni(`/api/todos/${encodeURIComponent(e)}`,{description:t,tags:n})}async function P2(e,t,n){await Ni(`/api/todos/${encodeURIComponent(e)}/${t}/complete`,{summary:"Completed."})}async function _2(e,t,n){await Ni(`/api/todos/${encodeURIComponent(e)}/${t}/block`,{reason:n})}async function D2(e,t,n){await Ni(`/api/todos/${encodeURIComponent(e)}/${t}/start`,{session:n})}async function $2(e,t){await Ni(`/api/todos/${encodeURIComponent(e)}/${t}/reopen`,{})}async function I2(e,t){await DO(`/api/todos/${encodeURIComponent(e)}/${t}`)}async function M2(e,t,n){const r=await fetch(`/api/todos/${encodeURIComponent(e)}/${t}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({description:n})});if(!r.ok)throw new Error(await r.text().catch(()=>"")||`HTTP ${r.status}`)}function Uv(e,t,n){return`/api/todos/${encodeURIComponent(e)}/${t}/attachments/${encodeURIComponent(n)}`}async function L2(e,t,n){for(const r of n){const o=await fetch(`/api/todos/${encodeURIComponent(e)}/${t}/attachments`,{method:"POST",headers:{"Content-Type":"application/octet-stream","x-attachment-filename":encodeURIComponent(r.name||"file"),"x-attachment-mime":r.type||"application/octet-stream"},body:r});if(!o.ok)throw new Error(await o.text().catch(()=>"")||`HTTP ${o.status}`)}}async function O2(e,t,n){const r=await fetch(Uv(e,t,n),{method:"DELETE"});if(!r.ok)throw new Error(await r.text().catch(()=>"")||`HTTP ${r.status}`)}async function Ni(e,t){const n=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!n.ok){const r=await n.text().catch(()=>"");let o=null;try{o=r?JSON.parse(r):null}catch{}const i=(o==null?void 0:o.error)||r||`HTTP ${n.status}`,a=new Error(i);throw a.status=n.status,a}return n.json().catch(()=>({}))}async function DO(e){const t=await fetch(e,{method:"DELETE"});if(!t.ok){const n=await t.text().catch(()=>"");let r=null;try{r=n?JSON.parse(n):null}catch{}const o=(r==null?void 0:r.error)||n||`HTTP ${t.status}`,i=new Error(o);throw i.status=t.status,i}}async function $O(e,t){return await Ni(`/api/todos/${encodeURIComponent(e)}/promote`,t)}async function IO(e){return await Ni("/api/todos/promote-bulk",e)}async function MO(e,t,n){await Ni(`/api/todos/${encodeURIComponent(e)}/${t}/move`,{to:n})}const Jh=["assignment","project","todo","server","playbook"],ua={defaultScope:"all",aliases:{a:"assignment",p:"project",t:"todo",s:"server",pb:"playbook"},externalIds:!0},F2=["kind","status","tag","tags","assignee","type","project","externalid","jira","title","search"],mb="all",z2=/^[a-z][a-z0-9]*$/;function Hv(e){return typeof e=="string"&&Jh.includes(e)}function LO(e){return e==="all"||Hv(e)}function OO(e){if(!e||typeof e!="object")return zO();const t=e,n=LO(t.defaultScope)?t.defaultScope:ua.defaultScope,r=typeof t.externalIds=="boolean"?t.externalIds:ua.externalIds;let o;if(t.aliases&&typeof t.aliases=="object"){o={};for(const[i,a]of Object.entries(t.aliases))z2.test(i)&&i!==mb&&!F2.includes(i)&&Hv(a)&&(o[i]=a)}else o={...ua.aliases};return{defaultScope:n,aliases:o,externalIds:r}}function FO(e){if(!e||typeof e!="object")return{ok:!1,errors:["aliases must be an object"]};const t=[];for(const[n,r]of Object.entries(e))z2.test(n)||t.push(`alias key "${n}" must be lowercase and match [a-z][a-z0-9]*`),n===mb&&t.push(`alias key "${mb}" is reserved (the "search everything" escape)`),F2.includes(n)&&t.push(`alias key "${n}" collides with the reserved field name "${n}"`),Hv(r)||t.push(`alias "${n}" must map to one of: ${Jh.join(", ")}`);return t.length===0?{ok:!0}:{ok:!1,errors:t}}function zO(){return{defaultScope:ua.defaultScope,aliases:{...ua.aliases},externalIds:ua.externalIds}}const Vv={search:ua,custom:!1};let jl=null,il=null,rh=0;const gb=new Set;function B2(e){jl=e;for(const t of gb)t(e)}function Wv(e){if(!e||typeof e!="object")return Vv;const t=e;return{search:OO(t.search),custom:t.custom===!0}}function BO(){if(jl)return Promise.resolve(jl);if(il)return il;const e=++rh;return il=fetch("/api/config/search").then(t=>{if(!t.ok)throw new Error(`HTTP ${t.status}`);return t.json()}).then(t=>{il=null;const n=Wv(t);return e!==rh?jl??n:(jl=n,n)}).catch(()=>(il=null,Vv)),il}function qv(){const[e,t]=m.useState(()=>jl??Vv);return m.useEffect(()=>{let n=!1;return BO().then(r=>{n||t(r)}),gb.add(t),()=>{n=!0,gb.delete(t)}},[]),e}async function UO(e){var r;++rh;const t=await fetch("/api/config/search",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!t.ok){const o=await t.json().catch(()=>null);throw new Error(((r=o==null?void 0:o.errors)==null?void 0:r.join("; "))??(o==null?void 0:o.error)??`HTTP ${t.status}`)}const n=Wv(await t.json());return B2(n),n}async function HO(){++rh;const e=await fetch("/api/config/search",{method:"DELETE"});if(!e.ok){const n=await e.json().catch(()=>null);throw new Error((n==null?void 0:n.error)??`HTTP ${e.status}`)}const t=Wv(await e.json());return B2(t),t}const VO=new Set(["/projects","/assignments","/servers","/todos"]);function Ap(e,t){return VO.has(e)?`${t}${e}`:e}const WO=[{id:"page-overview",title:"Overview",basePath:"/",keywords:["home","dashboard"]},{id:"page-projects",title:"Projects",basePath:"/projects",keywords:[]},{id:"page-assignments",title:"Assignments",basePath:"/assignments",keywords:[]},{id:"page-todos",title:"Todos",basePath:"/todos",keywords:["tasks"]},{id:"page-servers",title:"Servers",basePath:"/servers",keywords:["sessions"]},{id:"page-playbooks",title:"Playbooks",basePath:"/playbooks",keywords:[]},{id:"page-memories",title:"Memories",basePath:"/memories",keywords:["knowledge","learnings"]},{id:"page-resources",title:"Resources",basePath:"/resources",keywords:["knowledge","reference"]},{id:"page-workflow",title:"Workflow",basePath:"/workflow",keywords:["statuses","transitions","derive","facts"]},{id:"page-settings",title:"Settings",basePath:"/settings",keywords:[]},{id:"page-help",title:"Help",basePath:"/help",keywords:["shortcuts"]}];function qO(e){if(!(e!=null&&e.length))return[];const t=[];for(const n of e)n.id&&(t.push(n.id),n.system&&t.push(`${n.system}:${n.id}`));return t}function KO(e){const t=[],n=e.externalIds!==!1,r=i=>n?qO(i):[],o=i=>n?i:void 0;for(const i of WO)t.push({type:"page",id:i.id,title:i.title,keywords:[...i.keywords],route:Ap(i.basePath,e.wsPrefix)});for(const i of e.projects??[]){const a=i.workspace?`/w/${i.workspace}`:"";t.push({type:"project",id:`project-${i.slug}`,title:i.title,subtitle:i.slug,keywords:[...i.tags??[],...r(i.externalIds)],route:`${a}/projects/${i.slug}`,tags:i.tags,project:i.slug,externalIds:o(i.externalIds)}),t.push({type:"todo",id:`project-todos-${i.slug}`,title:`${i.title} todos`,subtitle:`${i.slug} · project`,keywords:[...i.tags??[],"project","todos"],route:`${a}/projects/${i.slug}?tab=todos`})}for(const i of e.assignments??[]){const a=i.projectWorkspace?`/w/${i.projectWorkspace}`:"";t.push({type:"assignment",id:i.projectSlug===null?`assignment-standalone-${i.id}`:`assignment-${i.projectSlug}-${i.slug}`,title:i.title,subtitle:`${i.projectTitle} · ${i.status}`,keywords:[i.projectSlug??"standalone",i.assignee??"",...r(i.externalIds)].filter(l=>!!l),route:i.projectSlug===null?`/assignments/${i.id}`:`${a}/projects/${i.projectSlug}/assignments/${i.slug}`,status:i.status,tags:i.tags,assignee:i.assignee,assignmentType:i.type,project:i.projectSlug,externalIds:o(i.externalIds)})}for(const i of e.playbooks??[])t.push({type:"playbook",id:`playbook-${i.slug}`,title:i.name,subtitle:i.description,keywords:i.tags,route:`/playbooks/${i.slug}`,tags:i.tags});for(const i of e.servers??[])t.push({type:"server",id:`server-${i.name}`,title:i.name,subtitle:i.alive?"alive":"dead",route:`${Ap("/servers",e.wsPrefix)}#server-${encodeURIComponent(i.name)}`});for(const i of e.todos??[]){const a=i.workspace&&i.workspace!=="_ungrouped"?`/w/${i.workspace}`:e.wsPrefix,l=Ap("/todos",a);t.push({type:"todo",id:`todo-${i.id}`,title:i.description,subtitle:i.status,keywords:i.tags,route:`${l}?focus=${encodeURIComponent(i.id)}`,status:i.status,tags:i.tags})}return t}function Pr(e){return e.toLowerCase().trim().replace(/[^a-z0-9\s-]/g,"").replace(/\s+/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")}function Pp(e){return/^[a-z0-9]+(-[a-z0-9]+)*$/.test(e)}async function GO(e,t,n){const r=t?"disable":"enable",o=await fetch(`/api/playbooks/${encodeURIComponent(e)}/${r}`,{method:"POST"});if(!o.ok){const i=await o.json().catch(()=>({}));throw new Error(i.error||`Failed to ${r} playbook`)}n()}async function Vx(e,t){const n=await fetch(`/api/todos/${encodeURIComponent(e)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({description:t})});if(!n.ok){const r=await n.json().catch(()=>({}));throw new Error(r.error||`Failed to create todo (HTTP ${n.status})`)}}async function y1(){const e=await fetch("/api/workspaces");if(!e.ok)throw new Error(`Failed to load workspaces (HTTP ${e.status})`);const t=await e.json();return{workspaces:Array.isArray(t.workspaces)?t.workspaces:[],hasUngrouped:t.hasUngrouped===!0}}async function b1(){const e=await fetch("/api/projects");if(!e.ok)throw new Error(`Failed to load projects (HTTP ${e.status})`);const t=await e.json();return Array.isArray(t)?t:[]}async function Wx(e){const t=await fetch(e);if(!t.ok)throw new Error(`Failed to load template (HTTP ${t.status})`);const n=await t.json();if(!n.content)throw new Error("Template returned no content");return n.content}function Gi(e,t,n){const r=e.match(/^(---\n)([\s\S]*?)(\n---)/);if(!r)return`---
532
+ ${t}: ${JSON.stringify(n)}
533
+ ---
534
+ ${e}`;const o=r[1],i=r[2],a=r[3],l=e.slice(r[0].length),d=JSON.stringify(n),f=new RegExp(`^${t}:\\s*.*$`,"m");let p;return f.test(i)?p=i.replace(f,`${t}: ${d}`):p=`${i}
535
+ ${t}: ${d}`,`${o}${p}${a}${l}`}const YO=/^[a-z0-9][a-z0-9-]*$/;function XO(e){const{playbooks:t,projectSlug:n,currentProjectTitle:r,currentProjectWorkspace:o,wsPrefix:i,refetchPlaybooks:a,navigate:l,toggleTheme:d}=e,f=[];if(f.push({id:"new-workspace",title:"New Workspace",subtitle:"Create a Syntaur workspace",group:"Create",keywords:["new","create","workspace"],bindableKind:"new-workspace",flow:{steps:[{kind:"text",id:"name",label:"Workspace name",placeholder:"lowercase, hyphenated (e.g. acme-app)",required:!0,pattern:{regex:YO,message:"Use lowercase letters, digits, and hyphens (e.g. acme-app). Must start with a letter or digit."}}],submit:async(p,h)=>{const g=(p.name??"").trim();if(!g)throw new Error("Name is required");const y=await fetch("/api/workspaces",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:g})});if(!y.ok){const k=await y.json().catch(()=>({}));throw new Error(k.error||`Failed to create workspace (HTTP ${y.status})`)}h.navigate(`/w/${g}/projects`)}}}),f.push({id:"new-project",title:"New Project",subtitle:"Create a project (pick workspace)",group:"Create",keywords:["new","create","project"],bindableKind:"new-project",flow:{steps:[{kind:"picker",id:"workspace",label:"Workspace",emptyMessage:'No workspaces yet — create one with "New Workspace"',loadOptions:async()=>{const{workspaces:p,hasUngrouped:h}=await y1(),g=[{value:"_ungrouped",label:"Ungrouped",hint:"no workspace"}];for(const y of p)g.push({value:y,label:y,hint:"workspace"});return g}},{kind:"text",id:"title",label:"Project title",placeholder:"e.g. Marketing site rebuild",required:!0}],submit:async(p,h)=>{const g=(p.workspace??"").trim(),y=(p.title??"").trim();if(!y)throw new Error("Title is required");const k=Pr(y);if(!k)throw new Error("Title must contain at least one alphanumeric character");let w=await Wx("/api/templates/project");w=Gi(w,"slug",k),w=Gi(w,"title",y),g&&g!=="_ungrouped"&&(w=Gi(w,"workspace",g));const b=await fetch("/api/projects",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:w})}),j=await b.json().catch(()=>({}));if(!b.ok)throw new Error(j.error||`Failed to create project (HTTP ${b.status})`);const N=g&&g!=="_ungrouped"?`/w/${g}/projects/${j.slug??k}`:`/projects/${j.slug??k}`;h.navigate(N)}}}),f.push({id:"new-todo",title:"New Todo",subtitle:"Pick scope (global / workspace / project)",group:"Create",keywords:["new","create","todo","task"],bindableKind:"new-todo",flow:{steps:[{kind:"picker",id:"scope",label:"Scope",loadOptions:async()=>{const[{workspaces:p},h]=await Promise.all([y1(),b1()]),g=[{value:"_ungrouped",label:"Global",hint:"no workspace"}];for(const y of p)g.push({value:y,label:y,hint:"workspace"});for(const y of h){const k=y.workspace??"_ungrouped";g.push({value:k,label:`${y.title}`,hint:`project · ${y.workspace??"ungrouped"}`})}return g}},{kind:"text",id:"description",label:"Description",placeholder:"Describe the todo…",required:!0}],submit:async p=>{const h=(p.scope??"_ungrouped").trim()||"_ungrouped",g=(p.description??"").trim();if(!g)throw new Error("Description is required");await Bv(h,g)}}}),f.push({id:"new-assignment",title:"New Assignment",subtitle:"Pick standalone or a project",group:"Create",keywords:["new","create","assignment"],bindableKind:"new-assignment",flow:{steps:[{kind:"picker",id:"project",label:"Project",loadOptions:async()=>{const p=await b1(),h=[{value:"_standalone",label:"Standalone",hint:"one-off / not in a project"}];for(const g of p)h.push({value:g.slug,label:g.title,hint:g.workspace?`workspace · ${g.workspace}`:"ungrouped"});return h}},{kind:"text",id:"title",label:"Assignment title",placeholder:"What needs to get done?",required:!0}],submit:async(p,h)=>{var S;const g=(p.project??"_standalone").trim()||"_standalone",y=(p.title??"").trim();if(!y)throw new Error("Title is required");const k=Pr(y);if(!k)throw new Error("Title must contain at least one alphanumeric character");if(g==="_standalone"){let C=await Wx("/api/templates/assignment?standalone=1");C=Gi(C,"slug",k),C=Gi(C,"title",y);const D=await fetch("/api/assignments",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:C})}),T=await D.json().catch(()=>({}));if(!D.ok)throw new Error(T.error||`Failed to create assignment (HTTP ${D.status})`);const R=((S=T==null?void 0:T.assignment)==null?void 0:S.id)??(T==null?void 0:T.id);R?h.navigate(`/assignments/${R}`):h.navigate("/assignments");return}let w=await Wx("/api/templates/assignment");w=Gi(w,"slug",k),w=Gi(w,"title",y);const b=await fetch(`/api/projects/${encodeURIComponent(g)}/assignments`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:w})}),j=await b.json().catch(()=>({}));if(!b.ok)throw new Error(j.error||`Failed to create assignment (HTTP ${b.status})`);const N=j.slug??k;h.navigate(`/projects/${g}/assignments/${N}`)}}}),f.push({id:"create-project-route",title:"New Project (advanced editor)",subtitle:"Open the markdown editor",group:"Create",keywords:["new","create","project","advanced","editor"],run:()=>l(`${i}/create/project`)}),f.push({id:"create-standalone-assignment",title:"New Standalone Assignment (editor)",subtitle:"Open the markdown editor",group:"Create",keywords:["new","create","assignment","standalone","one-off","editor"],run:()=>l(`${i}/assignments/new`)}),n&&f.push({id:`create-assignment-in-${n}`,title:`New Assignment in ${r??n}`,subtitle:n,group:"Create",keywords:["new","create","assignment",n],run:()=>l(`${i}/projects/${n}/create/assignment`)}),f.push({id:"create-playbook",title:"New Playbook",group:"Create",keywords:["new","create","playbook"],run:()=>l("/playbooks/create")}),f.push({id:"create-todo-global",title:"New Todo (global, quick)",subtitle:"Ungrouped, single-step",group:"Create",keywords:["new","create","todo","global","ungrouped","quick"],requiresInput:{placeholder:"Describe the todo…",runWithInput:async p=>{const h=p.trim();h&&await Vx("_ungrouped",h)}}}),i){const p=i.replace(/^\/w\//,"");f.push({id:`create-todo-workspace-${p}`,title:`New Todo in workspace ${p}`,subtitle:p,group:"Create",keywords:["new","create","todo","workspace",p],requiresInput:{placeholder:`Describe the todo for workspace ${p}…`,runWithInput:async h=>{const g=h.trim();g&&await Vx(p,g)}}})}n&&o&&f.push({id:`create-todo-project-${n}`,title:`New Todo in project ${r??n}`,subtitle:`${n} · workspace ${o}`,group:"Create",keywords:["new","create","todo","project",n,o],requiresInput:{placeholder:`Describe the todo for project ${r??n}…`,runWithInput:async p=>{const h=p.trim();h&&await Vx(o,h)}}});for(const p of t)f.push({id:`toggle-playbook-${p.slug}`,title:`Toggle Playbook: ${p.name}`,subtitle:p.enabled?"enabled":"disabled",group:"Toggle",keywords:["toggle","playbook",p.slug,...p.tags??[]],run:()=>GO(p.slug,p.enabled,a)});return f.push({id:"toggle-theme",title:"Toggle theme",subtitle:"Light / dark",group:"Theme",keywords:["theme","toggle","light","dark","appearance"],run:()=>d()}),f}const QO=["low","medium","high","critical"],Zh={status:{kind:"enum"},priority:{kind:"ordinal",order:QO},type:{kind:"enum"},assignee:{kind:"string",noneSentinel:!0},project:{kind:"string",noneSentinel:!0},tag:{kind:"list",get:e=>e.tags},tags:{kind:"list"},archived:{kind:"bool"},title:{kind:"substring"},search:{kind:"substring",get:e=>e.searchText??e.title},created:{kind:"timestamp"},updated:{kind:"timestamp"},completedat:{kind:"timestamp",get:e=>e.completedAt},statusage:{kind:"duration",get:e=>e.statusAge},phase:{kind:"enum"},disposition:{kind:"enum"},phaseage:{kind:"duration",get:e=>e.phaseAge},hasrealobjective:{kind:"bool",get:e=>e.hasRealObjective},acrealtotal:{kind:"number",get:e=>e.acRealTotal},acrealchecked:{kind:"number",get:e=>e.acRealChecked},acallchecked:{kind:"bool",get:e=>e.acAllChecked},planexists:{kind:"bool",get:e=>e.planExists},planapproved:{kind:"bool",get:e=>e.planApproved},workspaceset:{kind:"bool",get:e=>e.workspaceSet},implementationstarted:{kind:"bool",get:e=>e.implementationStarted},depssatisfied:{kind:"bool",get:e=>e.depsSatisfied},unresolvedquestions:{kind:"number",get:e=>e.unresolvedQuestions},progressstaledays:{kind:"duration",get:e=>e.progressStaleDays},blocked:{kind:"bool"},parked:{kind:"bool"},reviewrequested:{kind:"bool",get:e=>e.reviewRequested},pinned:{kind:"bool"}};function JO(e,t){return e[t.toLowerCase()]??null}function _r(e,t,n){return e.get?e.get(n):n[t]??n[t.toLowerCase()]}class Dr extends Error{constructor(t){super(t.map(n=>`${n.message} (at ${n.pos})`).join("; ")),this.errors=t,this.name="CompileError"}}function U2(e){const[t,n,r]=e.split("-").map(a=>parseInt(a,10)),o=new Date(t,n-1,r).getTime(),i=new Date(t,n-1,r+1).getTime();return[o,i]}function xb(e){if(typeof e=="number")return Number.isFinite(e)?e:null;if(typeof e=="string"&&e.length>0){const t=Date.parse(e);return Number.isNaN(t)?null:t}return null}function Pu(e){if(typeof e=="number")return Number.isFinite(e)?e:null;if(typeof e=="string"&&e.trim()!==""){const t=Number(e);return Number.isFinite(t)?t:null}return null}function qx(e,t){return typeof e=="string"&&e.toLowerCase()===t.toLowerCase()}function ZO(e){return e==null||e===""}function _p(e,t,n,r){switch(e.kind){case"enum":case"string":return e.noneSentinel&&n.raw.toLowerCase()==="none"?o=>ZO(_r(e,t,o)):o=>qx(_r(e,t,o),n.raw);case"substring":return o=>{const i=_r(e,t,o);return typeof i=="string"&&i.toLowerCase().includes(n.raw.toLowerCase())};case"bool":{const o=n.raw.toLowerCase();if(o!=="true"&&o!=="false")throw new Dr([{pos:n.pos,message:`Field "${t}" is boolean — use ${t}:true or ${t}:false`}]);const i=o==="true";return a=>{const l=_r(e,t,a),d=typeof l=="boolean"?l:l==="true"?!0:l==="false"||l===null||l===void 0||l===""?!1:null;return d!==null&&d===i}}case"number":{const o=n.num??Pu(n.raw);if(o===null)throw new Dr([{pos:n.pos,message:`Field "${t}" is numeric — "${n.raw}" is not a number`}]);return i=>Pu(_r(e,t,i))===o}case"ordinal":return o=>qx(_r(e,t,o),n.raw);case"list":return o=>{const i=_r(e,t,o);return Array.isArray(i)&&i.some(a=>qx(a,n.raw))};case"timestamp":{if(n.type==="date"){const[o,i]=U2(n.raw);return a=>{const l=xb(_r(e,t,a));return l!==null&&l>=o&&l<i}}throw new Dr([{pos:n.pos,message:`Field "${t}" is a timestamp — use a comparison (e.g. ${t} > -36h) or an absolute date (${t}:2026-06-01)`}])}case"duration":throw new Dr([{pos:r,message:`Field "${t}" is a duration — use a comparison (e.g. ${t} > 3d)`}])}}function e5(e,t,n,r){const o=(i,a)=>{switch(n){case"<":return i<a;case">":return i>a;case"<=":return i<=a;case">=":return i>=a;case"=":return i===a;case"!=":return i!==a;default:return!1}};switch(e.kind){case"number":{const i=r.num??Pu(r.raw);if(i===null)throw new Dr([{pos:r.pos,message:`"${r.raw}" is not a number (field "${t}")`}]);return a=>{const l=Pu(_r(e,t,a));return l!==null&&o(l,i)}}case"ordinal":{const i=e.order??[],a=i.findIndex(l=>l.toLowerCase()===r.raw.toLowerCase());if(a<0)throw new Dr([{pos:r.pos,message:`"${r.raw}" is not a valid ${t} (expected one of: ${i.join(", ")})`}]);return l=>{const d=_r(e,t,l),f=typeof d=="string"?i.findIndex(p=>p.toLowerCase()===d.toLowerCase()):-1;return f>=0&&o(f,a)}}case"timestamp":{if(r.type==="duration"){const a=(r.sign===0?-1:r.sign??-1)*(r.num??0);return(l,d)=>{const f=xb(_r(e,t,l));return f!==null&&o(f,d.now+a)}}if(r.type==="date"){const[i,a]=U2(r.raw);return l=>{const d=xb(_r(e,t,l));if(d===null)return!1;switch(n){case"<":return d<i;case"<=":return d<a;case">":return d>=a;case">=":return d>=i;case"=":return d>=i&&d<a;case"!=":return d<i||d>=a;default:return!1}}}throw new Dr([{pos:r.pos,message:`Compare timestamp field "${t}" to a duration (e.g. -36h) or a date (YYYY-MM-DD)`}])}case"duration":{if(r.type!=="duration")throw new Dr([{pos:r.pos,message:`Compare duration field "${t}" to a duration literal (e.g. 3d)`}]);const i=r.num??0;return a=>{const l=Pu(_r(e,t,a));return l!==null&&o(l,i)}}case"enum":case"string":case"substring":case"list":{if(n==="=")return _p(e,t,r,r.pos);if(n==="!="){const i=_p(e,t,r,r.pos);return(a,l)=>!i(a,l)}throw new Dr([{pos:r.pos,message:`Field "${t}" does not support ordering comparisons (use ":" or "=").`}])}case"bool":{if(n==="="||n==="!="){const i=_p(e,t,r,r.pos);return n==="="?i:(a,l)=>!i(a,l)}throw new Dr([{pos:r.pos,message:`Field "${t}" is boolean — use ${t}:true / ${t}:false`}])}}}function t5(e,t){const n=JO(t,e.field);if(!n)throw new Dr([{pos:e.pos,message:`Unknown field "${e.field}"`}]);if(e.op===":"){const r=e.values.map(o=>_p(n,e.field,o,e.pos));return r.length===1?r[0]:(o,i)=>r.some(a=>a(o,i))}return e5(n,e.field,e.op,e.values[0])}function _u(e,t){switch(e.kind){case"all":return()=>!0;case"atom":return t5(e,t);case"not":{const n=_u(e.child,t);return(r,o)=>!n(r,o)}case"and":{const n=e.children.map(r=>_u(r,t));return(r,o)=>n.every(i=>i(r,o))}case"or":{const n=e.children.map(r=>_u(r,t));return(r,o)=>n.some(i=>i(r,o))}}}class ra extends Error{constructor(t,n){super(n),this.pos=t,this.name="LexError"}}const n5={h:36e5,d:864e5,w:7*864e5,m:30*864e5,mo:30*864e5,y:365*864e5},r5=/[A-Za-z_]/,s5=/[A-Za-z0-9_-]/,o5=/^\d{4}-\d{2}-\d{2}/;function em(e){const t=[];let n=0;const r=(o,i)=>{let a=n;for(;a<e.length&&/\d/.test(e[a]);)a++;const l=e.slice(n,a);let d="";for(;a<e.length&&/[a-z]/i.test(e[a]);)d+=e[a],a++;if(n=a,d.length>0){const f=n5[d.toLowerCase()];if(f===void 0)throw new ra(o,`Unknown duration unit "${d}" (expected h, d, w, m, mo, or y)`);return{type:"DURATION",text:e.slice(o,a),pos:o,num:parseInt(l,10)*f,sign:i}}return i!==0?{type:"NUMBER",text:e.slice(o,a),pos:o,num:i*parseInt(l,10)}:{type:"NUMBER",text:l,pos:o,num:parseInt(l,10)}};for(;n<e.length;){const o=e[n],i=n;if(o===" "||o===" "||o===`
536
+ `||o==="\r"){n++;continue}if(o==="("){t.push({type:"LPAREN",text:o,pos:i}),n++;continue}if(o===")"){t.push({type:"RPAREN",text:o,pos:i}),n++;continue}if(o===","){t.push({type:"COMMA",text:o,pos:i}),n++;continue}if(o===":"){t.push({type:"COLON",text:o,pos:i}),n++;continue}if(o==="*"){t.push({type:"STAR",text:o,pos:i}),n++;continue}if(o==="<"||o===">"){e[n+1]==="="?(t.push({type:"OP",text:o+"=",pos:i}),n+=2):(t.push({type:"OP",text:o,pos:i}),n++);continue}if(o==="!"){if(e[n+1]==="="){t.push({type:"OP",text:"!=",pos:i}),n+=2;continue}throw new ra(i,'Unexpected "!" (did you mean "!="?)')}if(o==="="){n+=e[n+1]==="="?2:1,t.push({type:"OP",text:"=",pos:i});continue}if(o==='"'||o==="'"){const a=o;let l=n+1,d="";for(;l<e.length&&e[l]!==a;)e[l]==="\\"&&l+1<e.length?(d+=e[l+1],l+=2):(d+=e[l],l++);if(l>=e.length)throw new ra(i,"Unterminated string literal");t.push({type:"STRING",text:d,pos:i}),n=l+1;continue}if(o==="-"||o==="+"){if(/\d/.test(e[n+1]??"")){const a=o==="-"?-1:1;n++,t.push(r(i,a));continue}if(o==="-"){t.push({type:"MINUS",text:"-",pos:i}),n++;continue}throw new ra(i,'Unexpected "+"')}if(/\d/.test(o)){const a=e.slice(n).match(o5);if(a){t.push({type:"DATE",text:a[0],pos:i}),n+=a[0].length;continue}t.push(r(i,0));continue}if(r5.test(o)){let a=n+1;for(;a<e.length&&s5.test(e[a]);)a++;const l=e.slice(n,a),d=l.toLowerCase();d==="and"?t.push({type:"AND",text:l,pos:i}):d==="or"?t.push({type:"OR",text:l,pos:i}):d==="not"?t.push({type:"NOT",text:l,pos:i}):t.push({type:"IDENT",text:l,pos:i}),n=a;continue}throw new ra(i,`Unexpected character "${o}"`)}return t.push({type:"EOF",text:"",pos:e.length}),t}class Xi extends Error{constructor(t,n){super(n),this.pos=t,this.name="ParseError"}}const i5=new Set(["IDENT","STRING","NUMBER","DATE","DURATION"]),a5=new Set(["IDENT","NOT","MINUS","LPAREN","STAR"]);class l5{constructor(t){_x(this,"pos",0);this.tokens=t}peek(){return this.tokens[this.pos]}next(){return this.tokens[this.pos++]}expect(t,n){const r=this.peek();if(r.type!==t)throw new Xi(r.pos,`Expected ${n}, got "${r.text||r.type}"`);return this.next()}parseQuery(){if(this.peek().type==="EOF")return{kind:"all"};const t=this.orExpr(),n=this.peek();if(n.type!=="EOF")throw new Xi(n.pos,`Unexpected "${n.text}" — unbalanced parentheses or stray token`);return t}orExpr(){const t=[this.andExpr()];for(;this.peek().type==="OR";)this.next(),t.push(this.andExpr());return t.length===1?t[0]:{kind:"or",children:t}}andExpr(){const t=[this.unary()];for(;;){const n=this.peek();if(n.type==="AND")this.next(),t.push(this.unary());else if(a5.has(n.type))t.push(this.unary());else break}return t.length===1?t[0]:{kind:"and",children:t}}unary(){const t=this.peek();if(t.type==="NOT")return this.next(),{kind:"not",child:this.unary()};if(t.type==="MINUS"){this.next();const n=this.peek();if(n.type!=="IDENT")throw new Xi(n.pos,'Expected a field atom after "-" negation');return{kind:"not",child:this.atom()}}return this.primary()}primary(){const t=this.peek();if(t.type==="LPAREN"){this.next();const n=this.orExpr();return this.expect("RPAREN",'")"'),n}if(t.type==="STAR")return this.next(),{kind:"all"};if(t.type==="IDENT")return this.atom();throw new Xi(t.pos,`Expected a field, "(", "*", or NOT — got "${t.text||"end of query"}"`)}atom(){const t=this.expect("IDENT","a field name"),n=this.peek();if(n.type==="COLON"){this.next();const r=this.valueOrList();return{kind:"atom",field:t.text,op:":",values:r,pos:t.pos}}if(n.type==="OP"){this.next();const r=this.value();return{kind:"atom",field:t.text,op:n.text,values:[r],pos:t.pos}}throw new Xi(n.pos,`Expected ":" or a comparison operator after field "${t.text}"`)}valueOrList(){if(this.peek().type==="LPAREN"){this.next();const t=[this.value()];for(;this.peek().type==="COMMA";)this.next(),t.push(this.value());return this.expect("RPAREN",'")" to close the value list'),t}return[this.value()]}value(){const t=this.peek();if(!i5.has(t.type))throw new Xi(t.pos,`Expected a value, got "${t.text||t.type}"`);switch(this.next(),t.type){case"STRING":return{type:"string",raw:t.text,pos:t.pos};case"NUMBER":return{type:"number",raw:t.text,num:t.num,pos:t.pos};case"DATE":return{type:"date",raw:t.text,pos:t.pos};case"DURATION":return{type:"duration",raw:t.text,num:t.num,sign:t.sign??0,pos:t.pos};default:return{type:"word",raw:t.text,pos:t.pos}}}}function tm(e){try{const t=em(e);return{ast:new l5(t).parseQuery(),errors:[]}}catch(t){if(t instanceof ra||t instanceof Xi)return{ast:null,errors:[{pos:t.pos,message:t.message}]};throw t}}function Kl(e,t=Zh){const n=tm(e);if(!n.ast)return{query:null,errors:n.errors};try{return{query:{predicate:_u(n.ast,t),ast:n.ast},errors:[]}}catch(r){if(r instanceof Dr)return{query:null,errors:r.errors};throw r}}function rn(e,t,{checkForDefaultPrevented:n=!0}={}){return function(o){if(e==null||e(o),n===!1||!o.defaultPrevented)return t==null?void 0:t(o)}}function v1(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function nm(...e){return t=>{let n=!1;const r=e.map(o=>{const i=v1(o,t);return!n&&typeof i=="function"&&(n=!0),i});if(n)return()=>{for(let o=0;o<r.length;o++){const i=r[o];typeof i=="function"?i():v1(e[o],null)}}}}function Zn(...e){return m.useCallback(nm(...e),e)}function c5(e,t){const n=m.createContext(t),r=i=>{const{children:a,...l}=i,d=m.useMemo(()=>l,Object.values(l));return s.jsx(n.Provider,{value:d,children:a})};r.displayName=e+"Provider";function o(i){const a=m.useContext(n);if(a)return a;if(t!==void 0)return t;throw new Error(`\`${i}\` must be used within \`${e}\``)}return[r,o]}function Na(e,t=[]){let n=[];function r(i,a){const l=m.createContext(a),d=n.length;n=[...n,a];const f=h=>{var j;const{scope:g,children:y,...k}=h,w=((j=g==null?void 0:g[e])==null?void 0:j[d])||l,b=m.useMemo(()=>k,Object.values(k));return s.jsx(w.Provider,{value:b,children:y})};f.displayName=i+"Provider";function p(h,g){var w;const y=((w=g==null?void 0:g[e])==null?void 0:w[d])||l,k=m.useContext(y);if(k)return k;if(a!==void 0)return a;throw new Error(`\`${h}\` must be used within \`${i}\``)}return[f,p]}const o=()=>{const i=n.map(a=>m.createContext(a));return function(l){const d=(l==null?void 0:l[e])||i;return m.useMemo(()=>({[`__scope${e}`]:{...l,[e]:d}}),[l,d])}};return o.scopeName=e,[r,u5(o,...t)]}function u5(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(i){const a=r.reduce((l,{useScope:d,scopeName:f})=>{const h=d(i)[`__scope${f}`];return{...l,...h}},{});return m.useMemo(()=>({[`__scope${t.scopeName}`]:a}),[a])}};return n.scopeName=t.scopeName,n}var bi=globalThis!=null&&globalThis.document?m.useLayoutEffect:()=>{},d5=kE[" useId ".trim().toString()]||(()=>{}),f5=0;function _l(e){const[t,n]=m.useState(d5());return bi(()=>{n(r=>r??String(f5++))},[e]),e||(t?`radix-${t}`:"")}var p5=kE[" useInsertionEffect ".trim().toString()]||bi;function rm({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[o,i,a]=h5({defaultProp:t,onChange:n}),l=e!==void 0,d=l?e:o;{const p=m.useRef(e!==void 0);m.useEffect(()=>{const h=p.current;h!==l&&console.warn(`${r} is changing from ${h?"controlled":"uncontrolled"} to ${l?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),p.current=l},[l,r])}const f=m.useCallback(p=>{var h;if(l){const g=m5(p)?p(e):p;g!==e&&((h=a.current)==null||h.call(a,g))}else i(p)},[l,e,i,a]);return[d,f]}function h5({defaultProp:e,onChange:t}){const[n,r]=m.useState(e),o=m.useRef(n),i=m.useRef(t);return p5(()=>{i.current=t},[t]),m.useEffect(()=>{var a;o.current!==n&&((a=i.current)==null||a.call(i,n),o.current=n)},[n,o]),[n,r,i]}function m5(e){return typeof e=="function"}function g5(e){const t=x5(e),n=m.forwardRef((r,o)=>{const{children:i,...a}=r,l=m.Children.toArray(i),d=l.find(b5);if(d){const f=d.props.children,p=l.map(h=>h===d?m.Children.count(f)>1?m.Children.only(null):m.isValidElement(f)?f.props.children:null:h);return s.jsx(t,{...a,ref:o,children:m.isValidElement(f)?m.cloneElement(f,void 0,p):null})}return s.jsx(t,{...a,ref:o,children:i})});return n.displayName=`${e}.Slot`,n}function x5(e){const t=m.forwardRef((n,r)=>{const{children:o,...i}=n;if(m.isValidElement(o)){const a=w5(o),l=v5(i,o.props);return o.type!==m.Fragment&&(l.ref=r?nm(r,a):a),m.cloneElement(o,l)}return m.Children.count(o)>1?m.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var y5=Symbol("radix.slottable");function b5(e){return m.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===y5}function v5(e,t){const n={...t};for(const r in t){const o=e[r],i=t[r];/^on[A-Z]/.test(r)?o&&i?n[r]=(...l)=>{const d=i(...l);return o(...l),d}:o&&(n[r]=o):r==="style"?n[r]={...o,...i}:r==="className"&&(n[r]=[o,i].filter(Boolean).join(" "))}return{...e,...n}}function w5(e){var r,o;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(o=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var j5=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],wn=j5.reduce((e,t)=>{const n=g5(`Primitive.${t}`),r=m.forwardRef((o,i)=>{const{asChild:a,...l}=o,d=a?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),s.jsx(d,{...l,ref:i})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function k5(e,t){e&&vo.flushSync(()=>e.dispatchEvent(t))}function ga(e){const t=m.useRef(e);return m.useEffect(()=>{t.current=e}),m.useMemo(()=>(...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[])}function S5(e,t=globalThis==null?void 0:globalThis.document){const n=ga(e);m.useEffect(()=>{const r=o=>{o.key==="Escape"&&n(o)};return t.addEventListener("keydown",r,{capture:!0}),()=>t.removeEventListener("keydown",r,{capture:!0})},[n,t])}var N5="DismissableLayer",yb="dismissableLayer.update",C5="dismissableLayer.pointerDownOutside",E5="dismissableLayer.focusOutside",w1,H2=m.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Kv=m.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:i,onInteractOutside:a,onDismiss:l,...d}=e,f=m.useContext(H2),[p,h]=m.useState(null),g=(p==null?void 0:p.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,y]=m.useState({}),k=Zn(t,R=>h(R)),w=Array.from(f.layers),[b]=[...f.layersWithOutsidePointerEventsDisabled].slice(-1),j=w.indexOf(b),N=p?w.indexOf(p):-1,S=f.layersWithOutsidePointerEventsDisabled.size>0,C=N>=j,D=A5(R=>{const $=R.target,_=[...f.branches].some(U=>U.contains($));!C||_||(o==null||o(R),a==null||a(R),R.defaultPrevented||l==null||l())},g),T=P5(R=>{const $=R.target;[...f.branches].some(U=>U.contains($))||(i==null||i(R),a==null||a(R),R.defaultPrevented||l==null||l())},g);return S5(R=>{N===f.layers.size-1&&(r==null||r(R),!R.defaultPrevented&&l&&(R.preventDefault(),l()))},g),m.useEffect(()=>{if(p)return n&&(f.layersWithOutsidePointerEventsDisabled.size===0&&(w1=g.body.style.pointerEvents,g.body.style.pointerEvents="none"),f.layersWithOutsidePointerEventsDisabled.add(p)),f.layers.add(p),j1(),()=>{n&&f.layersWithOutsidePointerEventsDisabled.size===1&&(g.body.style.pointerEvents=w1)}},[p,g,n,f]),m.useEffect(()=>()=>{p&&(f.layers.delete(p),f.layersWithOutsidePointerEventsDisabled.delete(p),j1())},[p,f]),m.useEffect(()=>{const R=()=>y({});return document.addEventListener(yb,R),()=>document.removeEventListener(yb,R)},[]),s.jsx(wn.div,{...d,ref:k,style:{pointerEvents:S?C?"auto":"none":void 0,...e.style},onFocusCapture:rn(e.onFocusCapture,T.onFocusCapture),onBlurCapture:rn(e.onBlurCapture,T.onBlurCapture),onPointerDownCapture:rn(e.onPointerDownCapture,D.onPointerDownCapture)})});Kv.displayName=N5;var T5="DismissableLayerBranch",R5=m.forwardRef((e,t)=>{const n=m.useContext(H2),r=m.useRef(null),o=Zn(t,r);return m.useEffect(()=>{const i=r.current;if(i)return n.branches.add(i),()=>{n.branches.delete(i)}},[n.branches]),s.jsx(wn.div,{...e,ref:o})});R5.displayName=T5;function A5(e,t=globalThis==null?void 0:globalThis.document){const n=ga(e),r=m.useRef(!1),o=m.useRef(()=>{});return m.useEffect(()=>{const i=l=>{if(l.target&&!r.current){let d=function(){V2(C5,n,f,{discrete:!0})};const f={originalEvent:l};l.pointerType==="touch"?(t.removeEventListener("click",o.current),o.current=d,t.addEventListener("click",o.current,{once:!0})):d()}else t.removeEventListener("click",o.current);r.current=!1},a=window.setTimeout(()=>{t.addEventListener("pointerdown",i)},0);return()=>{window.clearTimeout(a),t.removeEventListener("pointerdown",i),t.removeEventListener("click",o.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}function P5(e,t=globalThis==null?void 0:globalThis.document){const n=ga(e),r=m.useRef(!1);return m.useEffect(()=>{const o=i=>{i.target&&!r.current&&V2(E5,n,{originalEvent:i},{discrete:!1})};return t.addEventListener("focusin",o),()=>t.removeEventListener("focusin",o)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function j1(){const e=new CustomEvent(yb);document.dispatchEvent(e)}function V2(e,t,n,{discrete:r}){const o=n.originalEvent.target,i=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&o.addEventListener(e,t,{once:!0}),r?k5(o,i):o.dispatchEvent(i)}var Kx="focusScope.autoFocusOnMount",Gx="focusScope.autoFocusOnUnmount",k1={bubbles:!1,cancelable:!0},_5="FocusScope",W2=m.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:i,...a}=e,[l,d]=m.useState(null),f=ga(o),p=ga(i),h=m.useRef(null),g=Zn(t,w=>d(w)),y=m.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;m.useEffect(()=>{if(r){let w=function(S){if(y.paused||!l)return;const C=S.target;l.contains(C)?h.current=C:pi(h.current,{select:!0})},b=function(S){if(y.paused||!l)return;const C=S.relatedTarget;C!==null&&(l.contains(C)||pi(h.current,{select:!0}))},j=function(S){if(document.activeElement===document.body)for(const D of S)D.removedNodes.length>0&&pi(l)};document.addEventListener("focusin",w),document.addEventListener("focusout",b);const N=new MutationObserver(j);return l&&N.observe(l,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",w),document.removeEventListener("focusout",b),N.disconnect()}}},[r,l,y.paused]),m.useEffect(()=>{if(l){N1.add(y);const w=document.activeElement;if(!l.contains(w)){const j=new CustomEvent(Kx,k1);l.addEventListener(Kx,f),l.dispatchEvent(j),j.defaultPrevented||(D5(O5(q2(l)),{select:!0}),document.activeElement===w&&pi(l))}return()=>{l.removeEventListener(Kx,f),setTimeout(()=>{const j=new CustomEvent(Gx,k1);l.addEventListener(Gx,p),l.dispatchEvent(j),j.defaultPrevented||pi(w??document.body,{select:!0}),l.removeEventListener(Gx,p),N1.remove(y)},0)}}},[l,f,p,y]);const k=m.useCallback(w=>{if(!n&&!r||y.paused)return;const b=w.key==="Tab"&&!w.altKey&&!w.ctrlKey&&!w.metaKey,j=document.activeElement;if(b&&j){const N=w.currentTarget,[S,C]=$5(N);S&&C?!w.shiftKey&&j===C?(w.preventDefault(),n&&pi(S,{select:!0})):w.shiftKey&&j===S&&(w.preventDefault(),n&&pi(C,{select:!0})):j===N&&w.preventDefault()}},[n,r,y.paused]);return s.jsx(wn.div,{tabIndex:-1,...a,ref:g,onKeyDown:k})});W2.displayName=_5;function D5(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(pi(r,{select:t}),document.activeElement!==n)return}function $5(e){const t=q2(e),n=S1(t,e),r=S1(t.reverse(),e);return[n,r]}function q2(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const o=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||o?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function S1(e,t){for(const n of e)if(!I5(n,{upTo:t}))return n}function I5(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function M5(e){return e instanceof HTMLInputElement&&"select"in e}function pi(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&M5(e)&&t&&e.select()}}var N1=L5();function L5(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=C1(e,t),e.unshift(t)},remove(t){var n;e=C1(e,t),(n=e[0])==null||n.resume()}}}function C1(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function O5(e){return e.filter(t=>t.tagName!=="A")}var F5="Portal",Gv=m.forwardRef((e,t)=>{var l;const{container:n,...r}=e,[o,i]=m.useState(!1);bi(()=>i(!0),[]);const a=n||o&&((l=globalThis==null?void 0:globalThis.document)==null?void 0:l.body);return a?yL.createPortal(s.jsx(wn.div,{...r,ref:t}),a):null});Gv.displayName=F5;function z5(e,t){return m.useReducer((n,r)=>t[n][r]??n,e)}var Ca=e=>{const{present:t,children:n}=e,r=B5(t),o=typeof n=="function"?n({present:r.isPresent}):m.Children.only(n),i=Zn(r.ref,U5(o));return typeof n=="function"||r.isPresent?m.cloneElement(o,{ref:i}):null};Ca.displayName="Presence";function B5(e){const[t,n]=m.useState(),r=m.useRef(null),o=m.useRef(e),i=m.useRef("none"),a=e?"mounted":"unmounted",[l,d]=z5(a,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return m.useEffect(()=>{const f=Jf(r.current);i.current=l==="mounted"?f:"none"},[l]),bi(()=>{const f=r.current,p=o.current;if(p!==e){const g=i.current,y=Jf(f);e?d("MOUNT"):y==="none"||(f==null?void 0:f.display)==="none"?d("UNMOUNT"):d(p&&g!==y?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,d]),bi(()=>{if(t){let f;const p=t.ownerDocument.defaultView??window,h=y=>{const w=Jf(r.current).includes(CSS.escape(y.animationName));if(y.target===t&&w&&(d("ANIMATION_END"),!o.current)){const b=t.style.animationFillMode;t.style.animationFillMode="forwards",f=p.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=b)})}},g=y=>{y.target===t&&(i.current=Jf(r.current))};return t.addEventListener("animationstart",g),t.addEventListener("animationcancel",h),t.addEventListener("animationend",h),()=>{p.clearTimeout(f),t.removeEventListener("animationstart",g),t.removeEventListener("animationcancel",h),t.removeEventListener("animationend",h)}}else d("ANIMATION_END")},[t,d]),{isPresent:["mounted","unmountSuspended"].includes(l),ref:m.useCallback(f=>{r.current=f?getComputedStyle(f):null,n(f)},[])}}function Jf(e){return(e==null?void 0:e.animationName)||"none"}function U5(e){var r,o;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(o=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var Yx=0;function H5(){m.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??E1()),document.body.insertAdjacentElement("beforeend",e[1]??E1()),Yx++,()=>{Yx===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),Yx--}},[])}function E1(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var Hs=function(){return Hs=Object.assign||function(t){for(var n,r=1,o=arguments.length;r<o;r++){n=arguments[r];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t},Hs.apply(this,arguments)};function K2(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]]);return n}function V5(e,t,n){if(n||arguments.length===2)for(var r=0,o=t.length,i;r<o;r++)(i||!(r in t))&&(i||(i=Array.prototype.slice.call(t,0,r)),i[r]=t[r]);return e.concat(i||Array.prototype.slice.call(t))}var Dp="right-scroll-bar-position",$p="width-before-scroll-bar",W5="with-scroll-bars-hidden",q5="--removed-body-scroll-bar-size";function Xx(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function K5(e,t){var n=m.useState(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(r){var o=n.value;o!==r&&(n.value=r,n.callback(r,o))}}}})[0];return n.callback=t,n.facade}var G5=typeof window<"u"?m.useLayoutEffect:m.useEffect,T1=new WeakMap;function Y5(e,t){var n=K5(null,function(r){return e.forEach(function(o){return Xx(o,r)})});return G5(function(){var r=T1.get(n);if(r){var o=new Set(r),i=new Set(e),a=n.current;o.forEach(function(l){i.has(l)||Xx(l,null)}),i.forEach(function(l){o.has(l)||Xx(l,a)})}T1.set(n,e)},[e]),n}function X5(e){return e}function Q5(e,t){t===void 0&&(t=X5);var n=[],r=!1,o={read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(i){var a=t(i,r);return n.push(a),function(){n=n.filter(function(l){return l!==a})}},assignSyncMedium:function(i){for(r=!0;n.length;){var a=n;n=[],a.forEach(i)}n={push:function(l){return i(l)},filter:function(){return n}}},assignMedium:function(i){r=!0;var a=[];if(n.length){var l=n;n=[],l.forEach(i),a=n}var d=function(){var p=a;a=[],p.forEach(i)},f=function(){return Promise.resolve().then(d)};f(),n={push:function(p){a.push(p),f()},filter:function(p){return a=a.filter(p),n}}}};return o}function J5(e){e===void 0&&(e={});var t=Q5(null);return t.options=Hs({async:!0,ssr:!1},e),t}var G2=function(e){var t=e.sideCar,n=K2(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw new Error("Sidecar medium not found");return m.createElement(r,Hs({},n))};G2.isSideCarExport=!0;function Z5(e,t){return e.useMedium(t),G2}var Y2=J5(),Qx=function(){},sm=m.forwardRef(function(e,t){var n=m.useRef(null),r=m.useState({onScrollCapture:Qx,onWheelCapture:Qx,onTouchMoveCapture:Qx}),o=r[0],i=r[1],a=e.forwardProps,l=e.children,d=e.className,f=e.removeScrollBar,p=e.enabled,h=e.shards,g=e.sideCar,y=e.noRelative,k=e.noIsolation,w=e.inert,b=e.allowPinchZoom,j=e.as,N=j===void 0?"div":j,S=e.gapMode,C=K2(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),D=g,T=Y5([n,t]),R=Hs(Hs({},C),o);return m.createElement(m.Fragment,null,p&&m.createElement(D,{sideCar:Y2,removeScrollBar:f,shards:h,noRelative:y,noIsolation:k,inert:w,setCallbacks:i,allowPinchZoom:!!b,lockRef:n,gapMode:S}),a?m.cloneElement(m.Children.only(l),Hs(Hs({},R),{ref:T})):m.createElement(N,Hs({},R,{className:d,ref:T}),l))});sm.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};sm.classNames={fullWidth:$p,zeroRight:Dp};var eF=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function tF(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=eF();return t&&e.setAttribute("nonce",t),e}function nF(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function rF(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var sF=function(){var e=0,t=null;return{add:function(n){e==0&&(t=tF())&&(nF(t,n),rF(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},oF=function(){var e=sF();return function(t,n){m.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},X2=function(){var e=oF(),t=function(n){var r=n.styles,o=n.dynamic;return e(r,o),null};return t},iF={left:0,top:0,right:0,gap:0},Jx=function(e){return parseInt(e||"",10)||0},aF=function(e){var t=window.getComputedStyle(document.body),n=t[e==="padding"?"paddingLeft":"marginLeft"],r=t[e==="padding"?"paddingTop":"marginTop"],o=t[e==="padding"?"paddingRight":"marginRight"];return[Jx(n),Jx(r),Jx(o)]},lF=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return iF;var t=aF(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},cF=X2(),Dl="data-scroll-locked",uF=function(e,t,n,r){var o=e.left,i=e.top,a=e.right,l=e.gap;return n===void 0&&(n="margin"),`
537
+ .`.concat(W5,` {
538
+ overflow: hidden `).concat(r,`;
539
+ padding-right: `).concat(l,"px ").concat(r,`;
540
+ }
541
+ body[`).concat(Dl,`] {
542
+ overflow: hidden `).concat(r,`;
543
+ overscroll-behavior: contain;
544
+ `).concat([t&&"position: relative ".concat(r,";"),n==="margin"&&`
545
+ padding-left: `.concat(o,`px;
546
+ padding-top: `).concat(i,`px;
547
+ padding-right: `).concat(a,`px;
548
+ margin-left:0;
549
+ margin-top:0;
550
+ margin-right: `).concat(l,"px ").concat(r,`;
551
+ `),n==="padding"&&"padding-right: ".concat(l,"px ").concat(r,";")].filter(Boolean).join(""),`
552
+ }
553
+
554
+ .`).concat(Dp,` {
555
+ right: `).concat(l,"px ").concat(r,`;
556
+ }
557
+
558
+ .`).concat($p,` {
559
+ margin-right: `).concat(l,"px ").concat(r,`;
560
+ }
561
+
562
+ .`).concat(Dp," .").concat(Dp,` {
563
+ right: 0 `).concat(r,`;
564
+ }
565
+
566
+ .`).concat($p," .").concat($p,` {
567
+ margin-right: 0 `).concat(r,`;
568
+ }
569
+
570
+ body[`).concat(Dl,`] {
571
+ `).concat(q5,": ").concat(l,`px;
572
+ }
573
+ `)},R1=function(){var e=parseInt(document.body.getAttribute(Dl)||"0",10);return isFinite(e)?e:0},dF=function(){m.useEffect(function(){return document.body.setAttribute(Dl,(R1()+1).toString()),function(){var e=R1()-1;e<=0?document.body.removeAttribute(Dl):document.body.setAttribute(Dl,e.toString())}},[])},fF=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,o=r===void 0?"margin":r;dF();var i=m.useMemo(function(){return lF(o)},[o]);return m.createElement(cF,{styles:uF(i,!t,o,n?"":"!important")})},bb=!1;if(typeof window<"u")try{var Zf=Object.defineProperty({},"passive",{get:function(){return bb=!0,!0}});window.addEventListener("test",Zf,Zf),window.removeEventListener("test",Zf,Zf)}catch{bb=!1}var al=bb?{passive:!1}:!1,pF=function(e){return e.tagName==="TEXTAREA"},Q2=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!pF(e)&&n[t]==="visible")},hF=function(e){return Q2(e,"overflowY")},mF=function(e){return Q2(e,"overflowX")},A1=function(e,t){var n=t.ownerDocument,r=t;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var o=J2(e,r);if(o){var i=Z2(e,r),a=i[1],l=i[2];if(a>l)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},gF=function(e){var t=e.scrollTop,n=e.scrollHeight,r=e.clientHeight;return[t,n,r]},xF=function(e){var t=e.scrollLeft,n=e.scrollWidth,r=e.clientWidth;return[t,n,r]},J2=function(e,t){return e==="v"?hF(t):mF(t)},Z2=function(e,t){return e==="v"?gF(t):xF(t)},yF=function(e,t){return e==="h"&&t==="rtl"?-1:1},bF=function(e,t,n,r,o){var i=yF(e,window.getComputedStyle(t).direction),a=i*r,l=n.target,d=t.contains(l),f=!1,p=a>0,h=0,g=0;do{if(!l)break;var y=Z2(e,l),k=y[0],w=y[1],b=y[2],j=w-b-i*k;(k||j)&&J2(e,l)&&(h+=j,g+=k);var N=l.parentNode;l=N&&N.nodeType===Node.DOCUMENT_FRAGMENT_NODE?N.host:N}while(!d&&l!==document.body||d&&(t.contains(l)||t===l));return(p&&Math.abs(h)<1||!p&&Math.abs(g)<1)&&(f=!0),f},ep=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},P1=function(e){return[e.deltaX,e.deltaY]},_1=function(e){return e&&"current"in e?e.current:e},vF=function(e,t){return e[0]===t[0]&&e[1]===t[1]},wF=function(e){return`
574
+ .block-interactivity-`.concat(e,` {pointer-events: none;}
575
+ .allow-interactivity-`).concat(e,` {pointer-events: all;}
576
+ `)},jF=0,ll=[];function kF(e){var t=m.useRef([]),n=m.useRef([0,0]),r=m.useRef(),o=m.useState(jF++)[0],i=m.useState(X2)[0],a=m.useRef(e);m.useEffect(function(){a.current=e},[e]),m.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(o));var w=V5([e.lockRef.current],(e.shards||[]).map(_1),!0).filter(Boolean);return w.forEach(function(b){return b.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),w.forEach(function(b){return b.classList.remove("allow-interactivity-".concat(o))})}}},[e.inert,e.lockRef.current,e.shards]);var l=m.useCallback(function(w,b){if("touches"in w&&w.touches.length===2||w.type==="wheel"&&w.ctrlKey)return!a.current.allowPinchZoom;var j=ep(w),N=n.current,S="deltaX"in w?w.deltaX:N[0]-j[0],C="deltaY"in w?w.deltaY:N[1]-j[1],D,T=w.target,R=Math.abs(S)>Math.abs(C)?"h":"v";if("touches"in w&&R==="h"&&T.type==="range")return!1;var $=window.getSelection(),_=$&&$.anchorNode,U=_?_===T||_.contains(T):!1;if(U)return!1;var I=A1(R,T);if(!I)return!0;if(I?D=R:(D=R==="v"?"h":"v",I=A1(R,T)),!I)return!1;if(!r.current&&"changedTouches"in w&&(S||C)&&(r.current=D),!D)return!0;var F=r.current||D;return bF(F,b,w,F==="h"?S:C)},[]),d=m.useCallback(function(w){var b=w;if(!(!ll.length||ll[ll.length-1]!==i)){var j="deltaY"in b?P1(b):ep(b),N=t.current.filter(function(D){return D.name===b.type&&(D.target===b.target||b.target===D.shadowParent)&&vF(D.delta,j)})[0];if(N&&N.should){b.cancelable&&b.preventDefault();return}if(!N){var S=(a.current.shards||[]).map(_1).filter(Boolean).filter(function(D){return D.contains(b.target)}),C=S.length>0?l(b,S[0]):!a.current.noIsolation;C&&b.cancelable&&b.preventDefault()}}},[]),f=m.useCallback(function(w,b,j,N){var S={name:w,delta:b,target:j,should:N,shadowParent:SF(j)};t.current.push(S),setTimeout(function(){t.current=t.current.filter(function(C){return C!==S})},1)},[]),p=m.useCallback(function(w){n.current=ep(w),r.current=void 0},[]),h=m.useCallback(function(w){f(w.type,P1(w),w.target,l(w,e.lockRef.current))},[]),g=m.useCallback(function(w){f(w.type,ep(w),w.target,l(w,e.lockRef.current))},[]);m.useEffect(function(){return ll.push(i),e.setCallbacks({onScrollCapture:h,onWheelCapture:h,onTouchMoveCapture:g}),document.addEventListener("wheel",d,al),document.addEventListener("touchmove",d,al),document.addEventListener("touchstart",p,al),function(){ll=ll.filter(function(w){return w!==i}),document.removeEventListener("wheel",d,al),document.removeEventListener("touchmove",d,al),document.removeEventListener("touchstart",p,al)}},[]);var y=e.removeScrollBar,k=e.inert;return m.createElement(m.Fragment,null,k?m.createElement(i,{styles:wF(o)}):null,y?m.createElement(fF,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function SF(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const NF=Z5(Y2,kF);var eT=m.forwardRef(function(e,t){return m.createElement(sm,Hs({},e,{ref:t,sideCar:NF}))});eT.classNames=sm.classNames;var CF=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},cl=new WeakMap,tp=new WeakMap,np={},Zx=0,tT=function(e){return e&&(e.host||tT(e.parentNode))},EF=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=tT(n);return r&&e.contains(r)?r:(console.error("aria-hidden",n,"in not contained inside",e,". Doing nothing"),null)}).filter(function(n){return!!n})},TF=function(e,t,n,r){var o=EF(t,Array.isArray(e)?e:[e]);np[n]||(np[n]=new WeakMap);var i=np[n],a=[],l=new Set,d=new Set(o),f=function(h){!h||l.has(h)||(l.add(h),f(h.parentNode))};o.forEach(f);var p=function(h){!h||d.has(h)||Array.prototype.forEach.call(h.children,function(g){if(l.has(g))p(g);else try{var y=g.getAttribute(r),k=y!==null&&y!=="false",w=(cl.get(g)||0)+1,b=(i.get(g)||0)+1;cl.set(g,w),i.set(g,b),a.push(g),w===1&&k&&tp.set(g,!0),b===1&&g.setAttribute(n,"true"),k||g.setAttribute(r,"true")}catch(j){console.error("aria-hidden: cannot operate on ",g,j)}})};return p(t),l.clear(),Zx++,function(){a.forEach(function(h){var g=cl.get(h)-1,y=i.get(h)-1;cl.set(h,g),i.set(h,y),g||(tp.has(h)||h.removeAttribute(r),tp.delete(h)),y||h.removeAttribute(n)}),Zx--,Zx||(cl=new WeakMap,cl=new WeakMap,tp=new WeakMap,np={})}},RF=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),o=CF(e);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live], script"))),TF(r,o,n,"aria-hidden")):function(){return null}};function AF(e){const t=PF(e),n=m.forwardRef((r,o)=>{const{children:i,...a}=r,l=m.Children.toArray(i),d=l.find(DF);if(d){const f=d.props.children,p=l.map(h=>h===d?m.Children.count(f)>1?m.Children.only(null):m.isValidElement(f)?f.props.children:null:h);return s.jsx(t,{...a,ref:o,children:m.isValidElement(f)?m.cloneElement(f,void 0,p):null})}return s.jsx(t,{...a,ref:o,children:i})});return n.displayName=`${e}.Slot`,n}function PF(e){const t=m.forwardRef((n,r)=>{const{children:o,...i}=n;if(m.isValidElement(o)){const a=IF(o),l=$F(i,o.props);return o.type!==m.Fragment&&(l.ref=r?nm(r,a):a),m.cloneElement(o,l)}return m.Children.count(o)>1?m.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var _F=Symbol("radix.slottable");function DF(e){return m.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===_F}function $F(e,t){const n={...t};for(const r in t){const o=e[r],i=t[r];/^on[A-Z]/.test(r)?o&&i?n[r]=(...l)=>{const d=i(...l);return o(...l),d}:o&&(n[r]=o):r==="style"?n[r]={...o,...i}:r==="className"&&(n[r]=[o,i].filter(Boolean).join(" "))}return{...e,...n}}function IF(e){var r,o;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(o=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var om="Dialog",[nT,rT]=Na(om),[MF,Cs]=nT(om),sT=e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:o,onOpenChange:i,modal:a=!0}=e,l=m.useRef(null),d=m.useRef(null),[f,p]=rm({prop:r,defaultProp:o??!1,onChange:i,caller:om});return s.jsx(MF,{scope:t,triggerRef:l,contentRef:d,contentId:_l(),titleId:_l(),descriptionId:_l(),open:f,onOpenChange:p,onOpenToggle:m.useCallback(()=>p(h=>!h),[p]),modal:a,children:n})};sT.displayName=om;var oT="DialogTrigger",iT=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Cs(oT,n),i=Zn(t,o.triggerRef);return s.jsx(wn.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":Qv(o.open),...r,ref:i,onClick:rn(e.onClick,o.onOpenToggle)})});iT.displayName=oT;var Yv="DialogPortal",[LF,aT]=nT(Yv,{forceMount:void 0}),lT=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:o}=e,i=Cs(Yv,t);return s.jsx(LF,{scope:t,forceMount:n,children:m.Children.map(r,a=>s.jsx(Ca,{present:n||i.open,children:s.jsx(Gv,{asChild:!0,container:o,children:a})}))})};lT.displayName=Yv;var sh="DialogOverlay",cT=m.forwardRef((e,t)=>{const n=aT(sh,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,i=Cs(sh,e.__scopeDialog);return i.modal?s.jsx(Ca,{present:r||i.open,children:s.jsx(FF,{...o,ref:t})}):null});cT.displayName=sh;var OF=AF("DialogOverlay.RemoveScroll"),FF=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Cs(sh,n);return s.jsx(eT,{as:OF,allowPinchZoom:!0,shards:[o.contentRef],children:s.jsx(wn.div,{"data-state":Qv(o.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),xa="DialogContent",uT=m.forwardRef((e,t)=>{const n=aT(xa,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,i=Cs(xa,e.__scopeDialog);return s.jsx(Ca,{present:r||i.open,children:i.modal?s.jsx(zF,{...o,ref:t}):s.jsx(BF,{...o,ref:t})})});uT.displayName=xa;var zF=m.forwardRef((e,t)=>{const n=Cs(xa,e.__scopeDialog),r=m.useRef(null),o=Zn(t,n.contentRef,r);return m.useEffect(()=>{const i=r.current;if(i)return RF(i)},[]),s.jsx(dT,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:rn(e.onCloseAutoFocus,i=>{var a;i.preventDefault(),(a=n.triggerRef.current)==null||a.focus()}),onPointerDownOutside:rn(e.onPointerDownOutside,i=>{const a=i.detail.originalEvent,l=a.button===0&&a.ctrlKey===!0;(a.button===2||l)&&i.preventDefault()}),onFocusOutside:rn(e.onFocusOutside,i=>i.preventDefault())})}),BF=m.forwardRef((e,t)=>{const n=Cs(xa,e.__scopeDialog),r=m.useRef(!1),o=m.useRef(!1);return s.jsx(dT,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:i=>{var a,l;(a=e.onCloseAutoFocus)==null||a.call(e,i),i.defaultPrevented||(r.current||(l=n.triggerRef.current)==null||l.focus(),i.preventDefault()),r.current=!1,o.current=!1},onInteractOutside:i=>{var d,f;(d=e.onInteractOutside)==null||d.call(e,i),i.defaultPrevented||(r.current=!0,i.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const a=i.target;((f=n.triggerRef.current)==null?void 0:f.contains(a))&&i.preventDefault(),i.detail.originalEvent.type==="focusin"&&o.current&&i.preventDefault()}})}),dT=m.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:i,...a}=e,l=Cs(xa,n),d=m.useRef(null),f=Zn(t,d);return H5(),s.jsxs(s.Fragment,{children:[s.jsx(W2,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:i,children:s.jsx(Kv,{role:"dialog",id:l.contentId,"aria-describedby":l.descriptionId,"aria-labelledby":l.titleId,"data-state":Qv(l.open),...a,ref:f,onDismiss:()=>l.onOpenChange(!1)})}),s.jsxs(s.Fragment,{children:[s.jsx(HF,{titleId:l.titleId}),s.jsx(WF,{contentRef:d,descriptionId:l.descriptionId})]})]})}),Xv="DialogTitle",fT=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Cs(Xv,n);return s.jsx(wn.h2,{id:o.titleId,...r,ref:t})});fT.displayName=Xv;var pT="DialogDescription",hT=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Cs(pT,n);return s.jsx(wn.p,{id:o.descriptionId,...r,ref:t})});hT.displayName=pT;var mT="DialogClose",gT=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Cs(mT,n);return s.jsx(wn.button,{type:"button",...r,ref:t,onClick:rn(e.onClick,()=>o.onOpenChange(!1))})});gT.displayName=mT;function Qv(e){return e?"open":"closed"}var xT="DialogTitleWarning",[UF,yT]=c5(xT,{contentName:xa,titleName:Xv,docsSlug:"dialog"}),HF=({titleId:e})=>{const t=yT(xT),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
577
+
578
+ If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
579
+
580
+ For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return m.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},VF="DialogDescriptionWarning",WF=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${yT(VF).contentName}}.`;return m.useEffect(()=>{var i;const o=(i=e.current)==null?void 0:i.getAttribute("aria-describedby");t&&o&&(document.getElementById(t)||console.warn(r))},[r,e,t]),null},bT=sT,vT=iT,wT=lT,Jv=cT,Zv=uT,ew=fT,tw=hT,nw=gT;const Ln=bT,qF=vT,KF=wT,jT=nw,kT=m.forwardRef(({className:e,...t},n)=>s.jsx(Jv,{ref:n,className:Ce("fixed inset-0 z-50 bg-background/80 backdrop-blur-sm",e),...t}));kT.displayName=Jv.displayName;const jn=m.forwardRef(({className:e,children:t,...n},r)=>s.jsxs(KF,{children:[s.jsx(kT,{}),s.jsx(Zv,{ref:r,className:Ce("chrome-card fixed left-1/2 top-1/2 z-50 grid w-[calc(100%-2rem)] max-w-lg -translate-x-1/2 -translate-y-1/2 gap-4 !p-6 outline-none",e),...n,children:t})]}));jn.displayName=Zv.displayName;function er({className:e,...t}){return s.jsx("div",{className:Ce("flex flex-col space-y-2 text-left",e),...t})}function Ur({className:e,...t}){return s.jsx("div",{className:Ce("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",e),...t})}const kn=m.forwardRef(({className:e,...t},n)=>s.jsx(ew,{ref:n,className:Ce("text-lg font-semibold tracking-tight text-foreground",e),...t}));kn.displayName=ew.displayName;const ns=m.forwardRef(({className:e,...t},n)=>s.jsx(tw,{ref:n,className:Ce("text-sm leading-6 text-muted-foreground",e),...t}));ns.displayName=tw.displayName;const GF=-1,YF=-40;function ey(e,t){if(e.length===0)return 0;if(t.length===0)return-1/0;let n=0,r=0,o=-2,i=0;for(let a=0;a<e.length;a++){const l=e[a];let d=!1;for(;r<t.length;)if(t[r]===l){if(n+=100,r===o+1&&(n+=20),r===0)n+=30;else{const f=t[r-1];(f===" "||f==="-"||f==="_"||f==="/")&&(n+=15)}i>0&&(n+=Math.max(YF,i*GF)),o=r,i=0,r++,d=!0;break}else i++,r++;if(!d)return-1/0}return n}const D1={page:0,project:1,assignment:2,playbook:3,server:4,todo:5};function rw(e,t,n=50){const r=e.toLowerCase();if(!r)return t.slice(0,n).map(a=>({...a,score:0}));const i=t.map(a=>{var h;const l=ey(r,a.title.toLowerCase())*1,d=a.subtitle?ey(r,a.subtitle.toLowerCase())*.5:-1/0,f=(h=a.keywords)!=null&&h.length?ey(r,a.keywords.join(" ").toLowerCase())*.3:-1/0,p=Math.max(l,d,f);return{...a,score:p}}).filter(a=>a.score>-1/0);return i.sort((a,l)=>l.score!==a.score?l.score-a.score:a.title.length!==l.title.length?a.title.length-l.title.length:a.title!==l.title?a.title<l.title?-1:1:(D1[a.type]??99)-(D1[l.type]??99)),i.slice(0,n)}const XF={a:"assignment",p:"project",t:"todo",s:"server",pb:"playbook"},$1=Symbol("absent");function rp(e){return e.replace(/\s+/g," ").trim()}const I1=new Set(["IDENT","STRING","NUMBER","DATE","DURATION"]);function QF(e){const t=e.externalIds;return Array.isArray(t)?t.map(n=>n&&typeof n=="object"?`${n.system}:${n.id}`:"").join(" "):""}function JF(e){const t=e.externalIds;return Array.isArray(t)?t.filter(n=>{const r=n==null?void 0:n.system;return typeof r=="string"&&r.toLowerCase()==="jira"}).map(n=>String(n.id)).join(" "):""}const Yu={kind:{kind:"enum",get:e=>e.type},status:{kind:"enum"},tag:{kind:"list",get:e=>e.tags},tags:{kind:"list"},assignee:{kind:"string",noneSentinel:!0,get:e=>"assignee"in e?e.assignee:$1},type:{kind:"enum",get:e=>e.assignmentType},project:{kind:"string",noneSentinel:!0,get:e=>"project"in e?e.project:$1},externalid:{kind:"substring",get:QF},jira:{kind:"substring",get:JF},title:{kind:"substring"},search:{kind:"substring",get:e=>e.searchText??e.title}};function ZF(e,t=XF,n){const r=(n==null?void 0:n.defaultScope)??"all",o=e.match(/^\s*all:\s*/i),i=o!==null,a=i?e.slice(o[0].length):e,l=t6(a,t),d={aqlExpr:l.aqlExpr,fuzzy:l.fuzzy};if(r!=="all"&&!i&&e.trim()!==""&&!e6(l.aqlExpr)){const f=`kind:${r}`;d.aqlExpr=l.aqlExpr?l.explicit?`${f} (${l.aqlExpr})`:`${f} ${l.aqlExpr}`:f}return d}function e6(e){if(!e)return!1;let t;try{t=em(e)}catch{return!1}for(let n=0;n<t.length-1;n++)if(t[n].type==="IDENT"&&t[n].text.toLowerCase()==="kind"&&t[n+1].type==="COLON")return!0;return!1}function t6(e,t){let n;try{n=em(e)}catch(h){if(h instanceof ra)return{aqlExpr:"",fuzzy:rp(e),explicit:!1};throw h}const r=n.length,o=(h,g)=>e.slice(n[h].pos,g<r?n[g].pos:e.length);let i=!1;for(let h=0;h<r;h++){const g=n[h];if(g.type==="OR"||g.type==="LPAREN"&&(h===0||n[h-1].type!=="COLON")){i=!0;break}}if(i){const h=rp(s6(e,n,r,t));return Kl(h,Yu).query?{aqlExpr:h,fuzzy:"",explicit:!0}:{aqlExpr:"",fuzzy:rp(e),explicit:!0}}const a=[],l=[];let d=0,f=0;const p=h=>{if(h>f){const g=rp(o(f,h));g&&l.push(g)}};for(;d<r-1;){const h=n6(n,d,t);if(h){p(d),a.push(h.atom),d=h.end,f=d;continue}const g=r6(n,d,r);if(g!==null){const y=o(d,g).trim();if(Kl(y,Yu).query){p(d),a.push(y),d=g,f=d;continue}d=g;continue}d++}return p(r-1),{aqlExpr:a.join(" "),fuzzy:l.join(" "),explicit:!1}}function n6(e,t,n){var l;let r=t,o="";e[r].type==="MINUS"?(o="-",r++):e[r].type==="NOT"&&(o="NOT ",r++);const i=e[r];if(!i||i.type!=="IDENT")return null;const a=n[i.text.toLowerCase()];return!a||((l=e[r+1])==null?void 0:l.type)!=="COLON"?null:{atom:`${o}kind:${a}`,end:r+2}}function r6(e,t,n){let r=t;(e[r].type==="MINUS"||e[r].type==="NOT")&&r++;const o=e[r];if(!o||o.type!=="IDENT"||!Object.prototype.hasOwnProperty.call(Yu,o.text.toLowerCase()))return null;const i=e[r+1];if(!i)return null;if(i.type==="COLON"){const a=e[r+2];if(!a)return null;if(a.type==="LPAREN"){let l=0;for(let d=r+2;d<n;d++)if(e[d].type==="LPAREN")l++;else if(e[d].type==="RPAREN"){if(l--,l===0)return d+1}else if(e[d].type==="EOF")return null;return null}return I1.has(a.type)?r+3:null}if(i.type==="OP"){const a=e[r+2];return a&&I1.has(a.type)?r+3:null}return null}function s6(e,t,n,r){var a;let o="",i=0;for(let l=0;l<n;l++){const d=t[l];d.type==="IDENT"&&Object.prototype.hasOwnProperty.call(r,d.text.toLowerCase())&&((a=t[l+1])==null?void 0:a.type)==="COLON"&&(o+=e.slice(i,d.pos)+`kind:${r[d.text.toLowerCase()]} `,i=t[l+1].pos+1)}return o+=e.slice(i),o}const sw=["kanban","list","table"],ST=["title","status","priority","assignee","dependencies","created","updated"],o6=["asc","desc"],i6=["comfortable","compact"],a6=["none","status","type","priority","assignee","project"],l6=["last_24h","last_7d","last_30d","last_90d","older_7d","older_30d"];function Ke(e){const t=e===void 0?[]:Array.isArray(e)?e:[e],n=[];for(const r of t){if(typeof r!="string")continue;const o=r.trim();!o||o==="all"||n.includes(o)||n.push(o)}return n}function c6(e,t){const n=Ke(e),r=Ke(t);return n.length===r.length&&n.every(o=>r.includes(o))}const u6={defaultView:"kanban",sortField:"updated",sortDirection:"desc",density:"comfortable",grouping:"none",filters:{status:"all",type:"all",priority:"all",assignee:"all",project:"all",activity:"all"}},Xu={version:1,global:u6,projects:{}};function ty(e){return e==="table"?"table":"kanban"}function d6(e,t){return t?{...e,...t}:{...e}}function NT(e,t){const n=e.global;if(t===null)return n;const r=e.projects[t];return r?{defaultView:r.defaultView??n.defaultView,sortField:r.sortField??n.sortField,sortDirection:r.sortDirection??n.sortDirection,density:n.density,grouping:r.grouping??n.grouping,filters:d6(n.filters,r.filters)}:n}const f6=/^[A-Za-z_][A-Za-z0-9_-]*$/,p6=new Set(["and","or","not"]);function ow(e){return f6.test(e)&&!p6.has(e.toLowerCase())?e:CT(e)}function CT(e){return`"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`}const ET="__unassigned__",TT="__standalone__",h6={last_24h:"24h",last_7d:"7d",last_30d:"30d",last_90d:"90d",older_7d:"7d",older_30d:"30d"};function m6(e){return e.startsWith("older_")?"<":">="}const iw=["status","type","priority","assignee","project","tags"],g6=["created","updated"];function x6(e){var i;const t={};for(const a of iw){const l=Ke(e[a]);l.length&&(t[a]=l)}const n=(i=e.search)==null?void 0:i.trim();n&&(t.search=n);let r=e.activity&&e.activity!=="all"?e.activity:void 0;const o=e.dateRange;if(o){const a=y6(o);if(a)r||(r=a);else{const l=b6(o);l&&(t.dateRange=l)}}return r&&(t.activity=r),t}function y6(e){return e.field!=="updated"||!e.preset?null:e.preset==="older_7d"?"stale":e.preset==="last_7d"?"fresh":null}function b6(e){if(e.preset)return{field:e.field,preset:e.preset};const t=e.from&&e.from.length>0?e.from:void 0,n=e.to&&e.to.length>0?e.to:void 0;if(!t&&!n)return null;const r={field:e.field};return t&&(r.from=t),n&&(r.to=n),r}function Du(e){const t=x6(e),n=[];for(const r of iw){const o=t[r]??[];o.length&&n.push(v6(r,o))}return t.search&&n.push(`search:${CT(t.search)}`),t.activity==="stale"?n.push("updated < -7d"):t.activity==="fresh"&&n.push("updated >= -7d"),t.dateRange&&n.push(...j6(t.dateRange)),n.join(" AND ")}function v6(e,t){const n=t.map(r=>w6(e,r));return n.length===1?`${e}:${n[0]}`:`${e}:(${n.join(", ")})`}function w6(e,t){return e==="assignee"&&t===ET||e==="project"&&t===TT?"none":ow(t)}function j6(e){if(e.preset)return[`${e.field} ${m6(e.preset)} -${h6[e.preset]}`];const t=[];return e.from&&t.push(`${e.field} >= ${e.from}`),e.to&&t.push(`${e.field} <= ${e.to}`),t}function $u(e){const t=tm(e);if(!t.ast)return null;const n=k6(t.ast);if(n===null)return null;const r={},o=new Set,i=new Map;for(const a of n){const l=S6(a);if(!l)return null;switch(l.kind){case"value":{if(o.has(l.field))return null;o.add(l.field),r[l.field]=l.values;break}case"search":{if(o.has("search"))return null;o.add("search"),r.search=l.text;break}case"activity":{if(o.has("activity"))return null;o.add("activity"),r.activity=l.activity;break}case"datePreset":{const d=`date:${l.field}`;if(o.has(d)||i.has(l.field))return null;o.add(d),r.dateRange={field:l.field,preset:l.preset};break}case"dateBound":{const d=`date:${l.field}`;if(o.has(d))return null;const f=i.get(l.field)??{};if(l.bound==="from"){if(f.from!==void 0)return null;f.from=l.date}else{if(f.to!==void 0)return null;f.to=l.date}i.set(l.field,f);break}}}if(i.size>1)return null;for(const[a,l]of i){if(r.dateRange)return null;const d={field:a};l.from!==void 0&&(d.from=l.from),l.to!==void 0&&(d.to=l.to),r.dateRange=d}return r}function k6(e){if(e.kind==="all")return[];if(e.kind==="atom")return[e];if(e.kind==="and"){const t=[];for(const n of e.children){if(n.kind!=="atom")return null;t.push(n)}return t}return null}function S6(e){const t=e.field.toLowerCase();if(e.op===":"){if(iw.includes(t)){const o=t,i=[];for(const a of e.values){const l=R6(o,a);if(l===null)return null;i.push(l)}return i.length===0?null:{kind:"value",field:o,values:i}}return t==="search"?e.values.length!==1?null:{kind:"search",text:e.values[0].raw}:null}if(!g6.includes(t))return null;const n=t;if(e.values.length!==1)return null;const r=e.values[0];return r.type==="duration"?N6(n,e.op,r):r.type==="date"?e.op===">="?{kind:"dateBound",field:n,bound:"from",date:r.raw}:e.op==="<="?{kind:"dateBound",field:n,bound:"to",date:r.raw}:null:null}function N6(e,t,n){if(n.sign!==-1)return null;const r=C6(n.raw);if(e==="updated"){if(t==="<"&&r==="7d")return{kind:"activity",activity:"stale"};if(t===">="&&r==="7d")return{kind:"activity",activity:"fresh"}}const o=T6(t,r);return o?{kind:"datePreset",field:e,preset:o}:null}function C6(e){return e.replace(/^[-+]/,"")}const E6={">=":{"24h":"last_24h","7d":"last_7d","30d":"last_30d","90d":"last_90d"},"<":{"7d":"older_7d","30d":"older_30d"}};function T6(e,t){return e!==">="&&e!=="<"?null:E6[e][t]??null}function R6(e,t){const n=t.raw;return e==="assignee"&&n.toLowerCase()==="none"?ET:e==="project"&&n.toLowerCase()==="none"?TT:n}const A6=new Set(["status","type","tag","assignee","externalid"]),ny=new Set(["IDENT","STRING","NUMBER","DATE","DURATION","STAR"]),M1=8;function P6(e,t,n){var k,w,b,j,N;let r;try{r=em(e)}catch{return[]}const o=r.length,i=S=>{const C=S+1<o?r[S+1].pos:e.length;return r[S].pos+e.slice(r[S].pos,C).replace(/\s+$/,"").length};let a=-1;for(let S=0;S<o-1;S++)if(t>r[S].pos&&t<=i(S)){a=S;break}let l=a>=0?a-1:-1;if(a<0)for(let S=0;S<o-1&&i(S)<=t;S++)l=S;let d=null,f=null,p="";if(a>=0&&r[a].type==="COLON"&&((k=r[a-1])==null?void 0:k.type)==="IDENT"?(d=r[a-1].text.toLowerCase(),f=[t,t]):a>=0&&ny.has(r[a].type)&&((w=r[a-1])==null?void 0:w.type)==="COLON"&&((b=r[a-2])==null?void 0:b.type)==="IDENT"?(d=r[a-2].text.toLowerCase(),f=[r[a].pos,i(a)],p=r[a].text):a<0&&l>=0&&r[l].type==="COLON"&&((j=r[l-1])==null?void 0:j.type)==="IDENT"&&(d=r[l-1].text.toLowerCase(),f=[t,t]),d!==null){if(!A6.has(d))return[];const S=n.values[d]??[],C=p.toLowerCase(),D=[];for(const T of S)if(!(C&&!T.toLowerCase().startsWith(C))&&T.toLowerCase()!==C&&(D.push({label:T,insert:ow(T),replace:f,kind:"value"}),D.length>=M1))break;return D}if(a>=0&&!ny.has(r[a].type))return[];if(a>=0&&r[a].type==="IDENT"&&((N=r[a+1])==null?void 0:N.type)==="COLON")return[];if(l>=0){const S=r[l].type;if(!(S==="AND"||S==="OR"||S==="NOT"||S==="MINUS"||S==="LPAREN"||S==="RPAREN"||ny.has(S)))return[]}const h=(a>=0?r[a].text:"").toLowerCase(),g=a>=0?[r[a].pos,i(a)]:[t,t],y=[];for(const[S,C]of Object.entries(n.aliases))h&&!S.toLowerCase().startsWith(h)||y.push({label:`${S}: (${C})`,insert:`${S}:`,replace:g,kind:"prefix"});for(const S of n.fields)h&&!S.toLowerCase().startsWith(h)||y.push({label:`${S}:`,insert:`${S}:`,replace:g,kind:"field"});return y.slice(0,M1)}const Ip={phaseLadder:[{phase:"draft",when:"*",next:"Fill in the objective and acceptance criteria"},{phase:"ready_for_planning",when:"hasRealObjective:true AND acRealTotal > 0",next:"Write a plan and get it approved"},{phase:"ready_to_implement",when:"planApproved:true",next:"Start implementing"},{phase:"in_progress",when:"planApproved:true AND implementationStarted:true",next:"Finish acceptance criteria, then request review"},{phase:"review",when:"acAllChecked:true OR reviewRequested:true",next:"Complete, or address review feedback"}],disposition:[{when:"parked:true",is:"parked"},{when:"blocked:true",is:"blocked"},{when:null,is:"active"}],headline:{terminal:"passthrough",parked:"parked",blocked:"blocked",active:"phase"}};function _6(e,t,n=()=>null){const r=[],o=new Set(t.statuses.map(l=>l.id));e.phaseLadder.length===0&&r.push("phaseLadder must have at least one rung");for(const l of e.phaseLadder){o.has(l.phase)||r.push(`phaseLadder rung "${l.phase}" is not a defined status id`);const d=l.when==="*"?null:n(l.when);d&&r.push(`phaseLadder rung "${l.phase}": invalid condition — ${d}`)}const i=new Set(["active","blocked","parked"]);for(const l of e.disposition)if(i.has(l.is)||r.push(`disposition "${l.is}" is not valid (expected active, blocked, or parked — terminal is never a rule)`),l.when!==null){const d=n(l.when);d&&r.push(`disposition rule "${l.is}": invalid condition — ${d}`)}const a=e.disposition.map((l,d)=>l.when===null?d:-1).filter(l=>l>=0);a.length===0?r.push("disposition rules must end with an `else:` arm (a rule with when: null)"):a.length>1?r.push("disposition rules must have exactly one `else:` arm (when: null)"):a[0]!==e.disposition.length-1&&r.push("the `else:` arm (when: null) must be the LAST disposition rule — rules after it are unreachable");for(const l of["parked","blocked"])o.has(e.headline[l])||r.push(`headline.${l} → "${e.headline[l]}" is not a defined status id (add the definition or run migrate-derive)`);return r}const RT={statuses:[{id:"pending",label:"Pending"},{id:"in_progress",label:"In Progress"},{id:"blocked",label:"Blocked"},{id:"review",label:"Review"},{id:"completed",label:"Completed"},{id:"failed",label:"Failed"}],order:["pending","in_progress","blocked","review","completed","failed"],transitions:[],transitionsCustom:!1,custom:!1,derive:Ip,deriveCustom:!1,knownCommands:[],factDeclarations:[],rawFacts:[]};let Iu=null,Qi=null;function D6(){return Iu?Promise.resolve(Iu):Qi||(Qi=fetch("/api/config/statuses").then(e=>{if(!e.ok)throw new Error(`HTTP ${e.status}`);return e.json()}).then(e=>(Iu=e,Qi=null,e)).catch(()=>(Qi=null,RT)),Qi)}function Es(){const[e,t]=m.useState(()=>Iu??RT);return m.useEffect(()=>{D6().then(t)},[]),e}function L1(){Iu=null,Qi=null}function So(e,t){const n=e.statuses.find(r=>r.id===t);return(n==null?void 0:n.label)??t.replace(/_/g," ").replace(/\b\w/g,r=>r.toUpperCase())}const AT={definitions:[{id:"feature",label:"Feature"},{id:"bug",label:"Bug"},{id:"refactor",label:"Refactor"},{id:"research",label:"Research"},{id:"chore",label:"Chore"}],default:"feature",custom:!1};let Mp=null,ul=null;function $6(){return Mp?Promise.resolve(Mp):ul||(ul=fetch("/api/config/types").then(e=>{if(!e.ok)throw new Error(`HTTP ${e.status}`);return e.json()}).then(e=>(Mp=e,ul=null,e)).catch(()=>(ul=null,AT)),ul)}function Rd(){const[e,t]=m.useState(()=>Mp??AT);return m.useEffect(()=>{$6().then(t)},[]),e}function $l(e,t){if(!t)return"—";const n=e.definitions.find(r=>r.id===t);return(n==null?void 0:n.label)??t.replace(/_/g," ").replace(/\b\w/g,r=>r.toUpperCase())}function I6(e,t){return t?e.definitions.find(n=>n.id===t)??null:null}const M6={page:"Page",project:"Project",assignment:"Assignment",playbook:"Playbook",server:"Server",todo:"Todo"};function L6({entries:e}){const{paletteOpen:t,closePalette:n}=Ci(),r=Ht(),[o,i]=m.useState(""),[a,l]=m.useState(0),[d,f]=m.useState(0),[p,h]=m.useState(!0),[g,y]=m.useState(0),k=m.useRef(null),w=m.useRef(null),{search:b}=qv(),j=Es(),N=Rd(),{aqlExpr:S,fuzzy:C}=m.useMemo(()=>ZF(o,b.aliases,{defaultScope:b.defaultScope}),[o,b.aliases,b.defaultScope]),D=m.useMemo(()=>{const F=new Set,M=new Set,A=new Set;for(const z of e){for(const W of z.tags??[])F.add(W);z.assignee&&M.add(z.assignee);for(const W of z.externalIds??[])W.id&&(A.add(W.id),W.system&&A.add(`${W.system}:${W.id}`))}const L=Object.keys(Yu);return{aliases:b.aliases,fields:b.externalIds?L:L.filter(z=>z!=="jira"&&z!=="externalid"),values:{status:j.statuses.map(z=>z.id),type:N.definitions.map(z=>z.id),tag:[...F],assignee:[...M],externalid:b.externalIds?[...A]:[]}}},[e,b.aliases,b.externalIds,j.statuses,N.definitions]),T=m.useMemo(()=>P6(o,d,D),[o,d,D]),R=p&&T.length>0&&o.trim()!=="",$=m.useMemo(()=>{let F=e,M=C;if(S){const A=Kl(S,Yu);if(A.query){const L=Date.now(),{predicate:z}=A.query;F=e.filter(W=>z(W,{now:L}))}else M=o}return rw(M,F,50)},[e,S,C,o]);m.useEffect(()=>{l(0)},[o,t]),m.useEffect(()=>{y(0)},[T]),m.useEffect(()=>{t||(i(""),f(0),h(!0))},[t]),m.useEffect(()=>{var M;const F=(M=k.current)==null?void 0:M.querySelector(`[data-palette-idx="${a}"]`);F==null||F.scrollIntoView({block:"nearest"})},[a]);function _(F){r(F.route),n()}function U(F){const M=o.slice(0,F.replace[0])+F.insert+o.slice(F.replace[1]),A=F.replace[0]+F.insert.length;i(M),f(A),requestAnimationFrame(()=>{const L=w.current;L&&(L.focus(),L.setSelectionRange(A,A))})}function I(F){if(R){if(F.key==="Tab"||F.key==="ArrowRight"&&d>=o.length){F.preventDefault();const M=T[g];M&&U(M);return}if(F.key==="ArrowDown"){F.preventDefault(),y(M=>Math.min(T.length-1,M+1));return}if(F.key==="ArrowUp"){F.preventDefault(),y(M=>Math.max(0,M-1));return}if(F.key==="Enter"){F.preventDefault();const M=$[a];M&&_(M);return}return}if(F.key==="ArrowDown")F.preventDefault(),l(M=>Math.min($.length-1,M+1));else if(F.key==="ArrowUp")F.preventDefault(),l(M=>Math.max(0,M-1));else if(F.key==="Enter"){F.preventDefault();const M=$[a];M&&_(M)}}return s.jsx(Ln,{open:t,onOpenChange:F=>F?null:n(),children:s.jsxs(jn,{className:"max-w-xl p-0 gap-0",onEscapeKeyDown:F=>{R&&(F.preventDefault(),h(!1))},children:[s.jsx(kn,{className:"sr-only",children:"Command palette"}),s.jsxs("div",{className:"relative",children:[s.jsx("input",{ref:w,autoFocus:!0,type:"text",value:o,onChange:F=>{i(F.target.value),f(F.target.selectionStart??F.target.value.length),h(!0)},onSelect:F=>f(F.currentTarget.selectionStart??0),onKeyDown:I,placeholder:"Search… try a: p: jira:PROJ-123 tag:backend",className:"w-full rounded-t-xl border-0 border-b border-border/70 bg-transparent px-4 py-3 text-sm text-foreground outline-none focus:border-primary"}),R?s.jsx("div",{className:"absolute left-0 right-0 top-full z-50 max-h-64 overflow-y-auto border-b border-border/70 bg-background shadow-lg",children:T.map((F,M)=>{const A=M===g;return s.jsxs("button",{type:"button",onMouseDown:L=>{L.preventDefault(),U(F)},onMouseEnter:()=>y(M),className:`flex w-full items-center justify-between gap-3 px-4 py-1.5 text-left text-sm ${A?"bg-accent text-accent-foreground":"text-foreground"}`,children:[s.jsx("code",{className:"truncate",children:F.label}),s.jsx("span",{className:"shrink-0 text-[10px] uppercase tracking-wide text-muted-foreground",children:F.kind})]},`${F.kind}-${F.insert}-${M}`)})}):null]}),S?s.jsxs("div",{className:"border-b border-border/70 px-4 py-1.5 text-[11px] text-muted-foreground",children:[s.jsx("span",{className:"font-medium",children:"Filtering"})," ",s.jsx("code",{className:"text-foreground",children:S}),C?s.jsxs("span",{children:[" · ranking “",C,"”"]}):null]}):o.trim()===""?s.jsxs("div",{className:"border-b border-border/70 px-4 py-1.5 text-[11px] text-muted-foreground",children:[s.jsx("span",{className:"font-medium",children:"Prefixes"})," ",Object.keys(b.aliases).map(F=>s.jsxs("code",{className:"mr-1",children:[F,":"]},F))," · ",s.jsx("code",{children:"status:"})," ",s.jsx("code",{children:"tag:"})," ",s.jsx("code",{children:"assignee:"})," ",s.jsx("code",{children:"type:"})," ",b.externalIds?s.jsx("code",{children:"jira:"}):null]}):null,s.jsx("div",{ref:k,className:"max-h-[60vh] overflow-y-auto p-1",children:$.length===0?s.jsx("div",{className:"px-4 py-6 text-center text-sm text-muted-foreground",children:"No matches"}):$.map((F,M)=>{const A=M===a;return s.jsxs("button",{type:"button","data-palette-idx":M,onClick:()=>_(F),onMouseEnter:()=>l(M),className:`flex w-full items-center gap-3 rounded-md px-3 py-2 text-left text-sm transition-colors ${A?"bg-accent text-accent-foreground":"hover:bg-accent/50 text-foreground"}`,children:[s.jsx("span",{className:"shrink-0 rounded border border-border/70 bg-background/60 px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-muted-foreground",children:M6[F.type]??F.type}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:F.title}),F.subtitle?s.jsx("span",{className:"shrink-0 truncate text-xs text-muted-foreground",children:F.subtitle}):null]},F.id)})}),s.jsxs("div",{className:"flex items-center justify-between border-t border-border/70 px-3 py-2 text-[11px] text-muted-foreground",children:[s.jsx("span",{children:R?"⇥/→ accept · ↑↓ suggestions · Esc close":"↑↓ navigate · ↵ open · Esc close"}),s.jsxs("span",{children:[$.length," result",$.length===1?"":"s"]})]})]})})}function O6({label:e,onBack:t,disabled:n,stepCounter:r}){return s.jsxs("div",{className:"flex items-center gap-2 border-b border-border/70 px-3 py-2",children:[s.jsxs("button",{type:"button",onClick:t,disabled:n,className:"inline-flex h-7 items-center gap-1 rounded border border-border/70 bg-background/60 px-2 text-[11px] text-muted-foreground transition-colors hover:bg-accent/40 hover:text-foreground disabled:opacity-50","aria-label":"Back",children:[s.jsx(NL,{className:"h-3.5 w-3.5","aria-hidden":"true"}),s.jsx("span",{children:"Back"})]}),s.jsx("span",{className:"text-[11px] font-medium uppercase tracking-wide text-muted-foreground",children:e}),r?s.jsxs("span",{className:"ml-auto text-[10px] text-muted-foreground/80",children:["step ",r.current," of ",r.total]}):null]})}function F6({step:e,initialValue:t,disabled:n,onSubmit:r}){const[o,i]=m.useState(t??""),[a,l]=m.useState(!1),d=m.useRef(null);m.useEffect(()=>{var k;(k=d.current)==null||k.focus()},[]);const f=o.trim(),p=e.required!==!1,h=e.pattern&&f.length>0&&!e.pattern.regex.test(f),g=!n&&(!p||f.length>0)&&!h;function y(k){if(k.key==="Enter"){if(k.preventDefault(),!g){l(!0);return}r(f)}}return s.jsxs(s.Fragment,{children:[s.jsx("input",{ref:d,type:"text",value:o,onChange:k=>{i(k.target.value),l(!1)},onKeyDown:y,placeholder:e.placeholder,disabled:n,className:"w-full border-0 border-b border-border/70 bg-transparent px-4 py-3 text-sm text-foreground outline-none focus:border-primary disabled:opacity-60"}),a&&e.pattern&&h?s.jsx("div",{className:"border-b border-border/70 bg-destructive/10 px-4 py-2 text-xs text-destructive",children:e.pattern.message}):null]})}function z6({step:e,disabled:t,onSubmit:n}){const[r,o]=m.useState({phase:"loading"}),[i,a]=m.useState(""),[l,d]=m.useState(0),[f,p]=m.useState(0),h=m.useRef(null),g=m.useRef(null);m.useEffect(()=>{var w;(w=h.current)==null||w.focus()},[]),m.useEffect(()=>{let w=!1;return o({phase:"loading"}),Promise.resolve().then(()=>e.loadOptions()).then(b=>{w||o({phase:"loaded",options:b})}).catch(b=>{if(w)return;const j=b instanceof Error?b.message:"Failed to load options";o({phase:"error",message:j})}),()=>{w=!0}},[e,f]);const y=m.useMemo(()=>{if(r.phase!=="loaded")return[];const w=r.options.map(b=>({type:"option",title:b.label,subtitle:b.hint,keywords:[b.value],option:b}));return rw(i,w,100)},[r,i]);m.useEffect(()=>{d(0)},[y.length]),m.useEffect(()=>{var b;const w=(b=g.current)==null?void 0:b.querySelector(`[data-picker-idx="${l}"]`);w==null||w.scrollIntoView({block:"nearest"})},[l]);function k(w){if(r.phase==="loaded"){if(w.key==="ArrowDown")w.preventDefault(),d(b=>Math.min(y.length-1,b+1));else if(w.key==="ArrowUp")w.preventDefault(),d(b=>Math.max(0,b-1));else if(w.key==="Enter"){w.preventDefault();const b=y[l];b&&n(b.option.value)}}}return s.jsxs(s.Fragment,{children:[s.jsx("input",{ref:h,type:"text",value:i,onChange:w=>a(w.target.value),onKeyDown:k,placeholder:`Filter ${e.label.toLowerCase()}…`,disabled:t||r.phase==="loading",className:"w-full border-0 border-b border-border/70 bg-transparent px-4 py-3 text-sm text-foreground outline-none focus:border-primary disabled:opacity-60"}),s.jsx("div",{ref:g,className:"max-h-[60vh] min-h-[120px] overflow-y-auto p-1",children:r.phase==="loading"?s.jsx("div",{className:"px-4 py-6 text-center text-sm text-muted-foreground",children:"Loading…"}):r.phase==="error"?s.jsxs("div",{className:"px-4 py-4 text-sm",children:[s.jsxs("div",{className:"mb-2 text-destructive",children:["Failed to load: ",r.message]}),s.jsx("button",{type:"button",onClick:()=>p(w=>w+1),className:"rounded border border-border/70 bg-background/60 px-2 py-1 text-xs text-foreground hover:bg-accent/40",children:"Retry"})]}):y.length===0?s.jsx("div",{className:"px-4 py-6 text-center text-sm text-muted-foreground",children:r.options.length===0?e.emptyMessage??"No options available":"No matches"}):y.map((w,b)=>{const j=b===l;return s.jsxs("button",{type:"button","data-picker-idx":b,onClick:()=>n(w.option.value),onMouseEnter:()=>d(b),disabled:t,className:`flex w-full items-center gap-3 rounded-md px-3 py-2 text-left text-sm transition-colors disabled:opacity-60 ${j?"bg-accent text-accent-foreground":"hover:bg-accent/50 text-foreground"}`,children:[s.jsx("span",{className:"min-w-0 flex-1 truncate",children:w.option.label}),w.option.hint?s.jsx("span",{className:"shrink-0 truncate text-xs text-muted-foreground",children:w.option.hint}):null]},w.option.value)})})]})}function B6({entries:e}){var Q,te;const t=Ht(),{actionsPaletteOpen:n,closeActionsPalette:r,customBindings:o,bindAction:i,findConflict:a,pendingActionKind:l,consumePendingActionKind:d}=Ci(),[f,p]=m.useState(""),[h,g]=m.useState(0),[y,k]=m.useState(null),[w,b]=m.useState(""),[j,N]=m.useState(null),[S,C]=m.useState(null),[D,T]=m.useState(!1),[R,$]=m.useState(null),_=m.useRef(null),U=m.useMemo(()=>e.map(Z=>({type:Z.group.toLowerCase(),title:Z.title,subtitle:Z.subtitle,keywords:Z.keywords,action:Z})),[e]),I=m.useMemo(()=>rw(f,U,50),[f,U]);m.useEffect(()=>{g(0)},[f,n]),m.useEffect(()=>{n||(p(""),k(null),b(""),N(null),C(null),T(!1),$(null))},[n]),m.useEffect(()=>{if(!n||!l)return;const Z=d();if(!Z)return;const ae=e.find(ne=>ne.bindableKind===Z);ae&&F(ae)},[n,l]),m.useEffect(()=>{var ae;const Z=(ae=_.current)==null?void 0:ae.querySelector(`[data-palette-idx="${h}"]`);Z==null||Z.scrollIntoView({block:"nearest"})},[h]);async function F(Z){if(!D){if(Z.flow&&Z.flow.steps.length>0){N({action:Z,stepIndex:0,values:{}}),$(null);return}if(Z.requiresInput){k(Z),b(""),$(null);return}if(Z.run){T(!0),$(null);try{await Z.run(),r()}catch(ae){$(ae instanceof Error?ae.message:"Action failed")}finally{T(!1)}}}}async function M(Z){if(!j)return;const ae=j.action.flow.steps[j.stepIndex],ne={...j.values,[ae.id]:Z};if(j.stepIndex+1<j.action.flow.steps.length){N({action:j.action,stepIndex:j.stepIndex+1,values:ne});return}T(!0),$(null);try{await j.action.flow.submit(ne,{navigate:t}),r()}catch(ue){$(ue instanceof Error?ue.message:"Action failed")}finally{T(!1)}}function A(){if(j&&!D){if(j.stepIndex===0){N(null),$(null);return}N({action:j.action,stepIndex:j.stepIndex-1,values:j.values}),$(null)}}async function L(){if(D||!(y!=null&&y.requiresInput))return;const Z=w.trim();if(Z){T(!0),$(null);try{await y.requiresInput.runWithInput(Z),r()}catch(ae){$(ae instanceof Error?ae.message:"Action failed")}finally{T(!1)}}}function z(Z){if(Z.key==="ArrowDown")Z.preventDefault(),g(ae=>Math.min(I.length-1,ae+1));else if(Z.key==="ArrowUp")Z.preventDefault(),g(ae=>Math.max(0,ae-1));else if(Z.key==="Enter"&&(Z.metaKey||Z.ctrlKey)){Z.preventDefault();const ae=I[h];ae!=null&&ae.action.bindableKind&&C({action:ae.action,combo:null,conflict:null,saving:!1,error:null})}else if(Z.key==="Enter"){Z.preventDefault();const ae=I[h];ae&&F(ae.action)}}function W(Z){Z.key==="Enter"?(Z.preventDefault(),L()):Z.key==="Escape"&&(Z.preventDefault(),k(null),b(""))}function V(Z){if(!S||Z.key==="Escape"||Z.key==="Enter"&&!S.combo)return;if(Z.key==="Enter"&&S.combo){Z.preventDefault(),Z.stopPropagation(),K();return}Z.preventDefault(),Z.stopPropagation();const ae=R2(Z.nativeEvent);if(!ae)return;const ne=a(ae,S.action.bindableKind);C({...S,combo:ae,conflict:ne,error:null})}async function K(){var Z;if(!(!S||!S.combo||!S.action.bindableKind)){if((Z=S.conflict)!=null&&Z.description){C({...S,error:`Reserved: ${S.conflict.description}`});return}C({...S,saving:!0,error:null});try{await i(S.action.bindableKind,S.combo),C(null)}catch(ae){C({...S,saving:!1,error:ae instanceof Error?ae.message:"Failed to save binding"})}}}const O=y!==null,B=j!==null,G=S!==null,H=j?j.action.flow.steps[j.stepIndex]:null;return s.jsx(Ln,{open:n,onOpenChange:Z=>Z?null:r(),children:s.jsxs(jn,{className:"max-w-xl p-0 gap-0",onEscapeKeyDown:Z=>{if(!D){if(G){Z.preventDefault(),C(null);return}if(B){Z.preventDefault(),A();return}O&&(Z.preventDefault(),k(null),b(""),$(null))}},children:[s.jsx(kn,{className:"sr-only",children:"Actions palette"}),G&&S?s.jsxs("div",{onKeyDown:V,tabIndex:-1,autoFocus:!0,children:[s.jsxs("div",{className:"flex items-center gap-2 border-b border-border/70 px-4 py-3",children:[s.jsx(ub,{className:"h-4 w-4 text-muted-foreground","aria-hidden":"true"}),s.jsxs("span",{className:"text-sm text-foreground",children:["Bind hotkey for ",S.action.title]})]}),s.jsx("div",{className:"px-4 py-6 text-center",children:S.combo?s.jsxs("div",{className:"space-y-3",children:[s.jsx("div",{className:"text-2xl font-semibold tracking-wide text-foreground",children:Gs(S.combo)}),(Q=S.conflict)!=null&&Q.description?s.jsxs("div",{className:"text-sm text-destructive",children:["Reserved: ",S.conflict.description," (cannot bind)"]}):(te=S.conflict)!=null&&te.kind?s.jsxs("div",{className:"text-sm text-amber-500 dark:text-amber-400",children:['Already bound to "',S.conflict.kind,'". Press Enter to overwrite.']}):s.jsx("div",{className:"text-sm text-muted-foreground",children:"Press Enter to save, or another key to retry."}),S.error?s.jsx("div",{className:"text-sm text-destructive",children:S.error}):null]}):s.jsx("div",{className:"text-sm text-muted-foreground",children:"Press the key combination you want to bind…"})}),s.jsxs("div",{className:"flex items-center justify-between border-t border-border/70 px-3 py-2 text-[11px] text-muted-foreground",children:[s.jsx("span",{children:"any key records · Enter saves · Esc cancels"}),s.jsx("span",{children:S.saving?"Saving…":""})]}),s.jsx("button",{type:"button",className:"sr-only",onClick:()=>void K(),"data-bind-confirm":!0}),s.jsx("input",{type:"hidden",onKeyDown:Z=>{Z.key==="Enter"&&K()}})]}):B&&H&&j?s.jsxs(s.Fragment,{children:[s.jsx(O6,{label:`${j.action.title} · ${H.label}`,onBack:A,disabled:D,stepCounter:{current:j.stepIndex+1,total:j.action.flow.steps.length}}),H.kind==="text"?s.jsx(F6,{step:H,initialValue:j.values[H.id],disabled:D,onSubmit:M}):s.jsx(z6,{step:H,disabled:D,onSubmit:M}),R?s.jsx("div",{className:"border-t border-border/70 bg-destructive/10 px-4 py-2 text-xs text-destructive",children:R}):null,s.jsxs("div",{className:"flex items-center justify-between border-t border-border/70 px-3 py-2 text-[11px] text-muted-foreground",children:[s.jsx("span",{children:"↵ next · ← back · Esc back"}),s.jsx("span",{children:D?"Running…":""})]})]}):O?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex items-center gap-2 border-b border-border/70 px-4 py-3",children:[s.jsx("span",{className:"shrink-0 rounded border border-border/70 bg-background/60 px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-muted-foreground",children:y.group}),s.jsx("span",{className:"min-w-0 flex-1 truncate text-sm text-foreground",children:y.title})]}),s.jsx("input",{autoFocus:!0,type:"text",value:w,onChange:Z=>b(Z.target.value),onKeyDown:W,placeholder:y.requiresInput.placeholder,disabled:D,className:"w-full border-0 border-b border-border/70 bg-transparent px-4 py-3 text-sm text-foreground outline-none focus:border-primary disabled:opacity-60"}),R?s.jsx("div",{className:"border-b border-border/70 bg-destructive/10 px-4 py-2 text-xs text-destructive",children:R}):null,s.jsxs("div",{className:"flex items-center justify-between border-t border-border/70 px-3 py-2 text-[11px] text-muted-foreground",children:[s.jsxs("span",{children:["↵"," submit ","·"," Esc back"]}),s.jsx("span",{children:D?"Running…":""})]})]}):s.jsxs(s.Fragment,{children:[s.jsx("input",{autoFocus:!0,type:"text",value:f,onChange:Z=>p(Z.target.value),onKeyDown:z,placeholder:"Run an action: new project, new todo, toggle…",disabled:D,className:"w-full rounded-t-xl border-0 border-b border-border/70 bg-transparent px-4 py-3 text-sm text-foreground outline-none focus:border-primary disabled:opacity-60"}),R?s.jsx("div",{className:"border-b border-border/70 bg-destructive/10 px-4 py-2 text-xs text-destructive",children:R}):null,s.jsx("div",{ref:_,className:"max-h-[60vh] overflow-y-auto p-1",children:I.length===0?s.jsx("div",{className:"px-4 py-6 text-center text-sm text-muted-foreground",children:f?"No matches":"Start typing to search actions"}):I.map((Z,ae)=>{const ne=ae===h,ue=Z.action.bindableKind,ye=ue?o[ue]:void 0;return s.jsxs("button",{type:"button","data-palette-idx":ae,onClick:()=>F(Z.action),onMouseEnter:()=>g(ae),disabled:D,className:`group flex w-full items-center gap-3 rounded-md px-3 py-2 text-left text-sm transition-colors disabled:opacity-60 ${ne?"bg-accent text-accent-foreground":"hover:bg-accent/50 text-foreground"}`,children:[s.jsx("span",{className:"shrink-0 rounded border border-border/70 bg-background/60 px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-muted-foreground",children:Z.action.group}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:Z.action.title}),Z.action.subtitle?s.jsx("span",{className:"shrink-0 truncate text-xs text-muted-foreground",children:Z.action.subtitle}):null,ye?s.jsx("span",{className:"shrink-0 rounded border border-border/70 bg-background/60 px-1.5 py-0.5 text-[10px] font-medium tracking-wide text-foreground",children:Gs(ye)}):null,ue?s.jsx("span",{role:"button",tabIndex:-1,"aria-label":"Bind hotkey",onClick:Ne=>{Ne.preventDefault(),Ne.stopPropagation(),C({action:Z.action,combo:null,conflict:null,saving:!1,error:null})},className:`shrink-0 inline-flex h-6 w-6 items-center justify-center rounded border border-border/70 bg-background/60 text-muted-foreground transition-opacity hover:text-foreground ${ne?"opacity-100":"opacity-0 group-hover:opacity-100"}`,children:s.jsx(ub,{className:"h-3.5 w-3.5","aria-hidden":"true"})}):null]},Z.action.id)})}),s.jsxs("div",{className:"flex items-center justify-between border-t border-border/70 px-3 py-2 text-[11px] text-muted-foreground",children:[s.jsxs("span",{children:["↑↓"," navigate ","·"," ","↵"," run ","·"," ⌘↵ bind ","·"," Esc close"]}),s.jsx("span",{children:D?"Running…":`${I.length} action${I.length===1?"":"s"}`})]})]})]})})}const U6=[{combo:"mod+k",description:"Open command palette",scope:"global"},{combo:"mod+shift+k",description:"Open actions palette",scope:"global"},{combo:"?",description:"Show keyboard shortcuts",scope:"global"},{combo:"escape",description:"Close dialog or cancel",scope:"global"},{combo:"enter",description:"Activate selected item",scope:"global"},{combo:"shift+t",description:"Toggle light/dark theme",scope:"global"},{combo:"g",description:"Start navigation chord",scope:"global"},{combo:"g o",description:"Go to Overview",scope:"global"},{combo:"g m",description:"Go to Projects",scope:"global"},{combo:"g a",description:"Go to Assignments",scope:"global"},{combo:"g t",description:"Go to Todos",scope:"global"},{combo:"g s",description:"Go to Servers",scope:"global"},{combo:"g !",description:"Go to Attention",scope:"global"},{combo:"g ,",description:"Go to Settings",scope:"global"},{combo:"j",description:"Move selection down",scope:"list"},{combo:"k",description:"Move selection up",scope:"list"},{combo:"o",description:"Open selected item",scope:"list"},{combo:"a",description:"New assignment in project",scope:"project"},{combo:"e",description:"Edit project / assignment",scope:"project|assignment"},{combo:"/",description:"Focus search",scope:"assignments-board"},{combo:"r",description:"Refresh board",scope:"assignments-board"},{combo:"p",description:"Edit plan",scope:"assignment"},{combo:"h",description:"Append handoff",scope:"assignment"},{combo:"d",description:"Append decision record",scope:"assignment"},{combo:"s",description:"Edit scratchpad",scope:"assignment"},{combo:"[",description:"Previous assignment",scope:"assignment"},{combo:"]",description:"Next assignment",scope:"assignment"}];function H6(e){const t=xr(e);return t?U6.find(n=>n.combo===t)??null:null}const fu={"new-workspace":"New Workspace","new-project":"New Project","new-todo":"New Todo","new-assignment":"New Assignment"},V6={global:"Global","list:overview":"Overview","list:projects":"Projects list","list:assignments":"Assignments list","list:todos":"Todos list",assignment:"Assignment detail",project:"Project detail"},W6=["global","list:overview","list:projects","list:assignments","list:todos","project","assignment"];function O1(e){if(e.includes(" ")){const[t,n]=e.split(" ");return`${Gs(t)} then ${Gs(n)}`}return Gs(e)}function q6(){const{cheatsheetOpen:e,closeCheatsheet:t,listBindings:n,customBindings:r,actionEntries:o}=Ci(),i=m.useMemo(()=>{const d=new Set;for(const f of Object.values(r))typeof f=="string"&&f&&d.add(xr(f));return d},[r]),a=m.useMemo(()=>{if(!e)return new Map;const d=n(),f=new Map;for(const p of d){if(i.has(xr(p.keys)))continue;const h=f.get(p.scope)??[];h.push({keys:p.keys,description:p.description}),f.set(p.scope,h)}return f},[e,n,i]),l=m.useMemo(()=>{const d=[];for(const[f,p]of Object.entries(r)){if(!p)continue;const h=o.find(g=>g.bindableKind===f);d.push({kind:f,combo:p,title:h?h.title:f})}return d},[r,o]);return s.jsx(Ln,{open:e,onOpenChange:d=>d?null:t(),children:s.jsxs(jn,{className:"max-w-2xl",children:[s.jsx(kn,{children:"Keyboard shortcuts"}),s.jsxs(ns,{children:["Press Esc to close. ",Gs("Mod+k")," opens the command palette. Press g twice to restart the chord timer."]}),s.jsxs("div",{className:"mt-2 max-h-[60vh] space-y-4 overflow-y-auto pr-1",children:[W6.map(d=>{const f=a.get(d);return!f||f.length===0?null:s.jsxs("section",{children:[s.jsx("h3",{className:"mb-2 text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:V6[d]}),s.jsx("ul",{className:"space-y-1",children:f.map((p,h)=>s.jsxs("li",{className:"flex items-center justify-between gap-3 rounded-md border border-border/40 bg-background/60 px-3 py-1.5 text-sm",children:[s.jsx("span",{className:"text-foreground",children:p.description}),s.jsx("kbd",{className:"shrink-0 rounded border border-border/70 bg-muted px-2 py-0.5 font-mono text-xs text-muted-foreground",children:O1(p.keys)})]},`${d}-${p.keys}-${h}`))})]},d)}),l.length>0?s.jsxs("section",{children:[s.jsx("h3",{className:"mb-2 text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:"Custom bindings"}),s.jsx("ul",{className:"space-y-1",children:l.map(d=>s.jsxs("li",{className:"flex items-center justify-between gap-3 rounded-md border border-border/40 bg-background/60 px-3 py-1.5 text-sm",children:[s.jsx("span",{className:"text-foreground",children:d.title}),s.jsx("kbd",{className:"shrink-0 rounded border border-border/70 bg-muted px-2 py-0.5 font-mono text-xs text-muted-foreground",children:O1(d.combo)})]},`custom-${d.kind}`))})]}):null]})]})})}const aw={bindings:{},custom:!1};let Mu=null,dl=null;const vb=new Set;function PT(e){Mu=e;for(const t of vb)t(e)}function lw(e){if(!e||typeof e!="object")return aw;const t=e,n={};if(t.bindings&&typeof t.bindings=="object"&&!Array.isArray(t.bindings))for(const[r,o]of Object.entries(t.bindings)){if(!NO(r)||typeof o!="string"||o.trim()==="")continue;const i=xr(o);i&&(n[r]=i)}return{bindings:n,custom:t.custom===!0}}function K6(){return Mu?Promise.resolve(Mu):dl||(dl=fetch("/api/config/hotkeys").then(e=>{if(!e.ok)throw new Error(`HTTP ${e.status}`);return e.json()}).then(e=>{const t=lw(e);return Mu=t,dl=null,t}).catch(()=>(dl=null,aw)),dl)}function G6(){const[e,t]=m.useState(()=>Mu??aw);return m.useEffect(()=>{let n=!1;return K6().then(r=>{n||t(r)}),vb.add(t),()=>{n=!0,vb.delete(t)}},[]),e}async function F1(e){const t={};for(const o of Qh){const i=e[o];if(typeof i!="string")continue;const a=xr(i);a&&(t[o]=a)}const n=await fetch("/api/config/hotkeys",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({bindings:t})});if(!n.ok){const o=await n.json().catch(()=>({error:`HTTP ${n.status}`}));throw new Error(o.error??"Failed to save hotkey bindings")}const r=lw(await n.json());return PT(r),r}async function Y6(){const e=await fetch("/api/config/hotkeys",{method:"DELETE"});if(!e.ok)throw new Error(`HTTP ${e.status}`);const t=lw(await e.json());return PT(t),t}const z1=1500;function X6(e){const t=e.match(/^\/w\/([^/]+)(?:\/|$)/);return t?`/w/${t[1]}`:""}const _T=m.createContext(null);function Q6({children:e}){const{toggleTheme:t}=Ov(),n=or(),r=Ht(),o=X6(n.pathname),[i,a]=m.useState(!1),l=Zs(i),d=Yh(i),f=zv(i),p=Fv(i),h=A2(i),{search:g}=qv(),y=m.useMemo(()=>{var at,xt,lt,ot;const we=l.data??[],ke=((at=d.data)==null?void 0:at.assignments)??[],$e=((xt=f.data)==null?void 0:xt.playbooks)??[],Ue=((lt=p.data)==null?void 0:lt.sessions)??[],He=(((ot=h.data)==null?void 0:ot.workspaces)??[]).flatMap(le=>le.items.map(xe=>({...xe,workspace:le.workspace})));return KO({projects:we,assignments:ke,playbooks:$e,servers:Ue,todos:He,wsPrefix:o,externalIds:g.externalIds})},[l.data,d.data,f.data,p.data,h.data,o,g.externalIds]),w=m.useMemo(()=>f2(n.pathname),[n.pathname]).projectSlug,b=m.useMemo(()=>{var we;return w?((we=l.data)==null?void 0:we.find(ke=>ke.slug===w))??null:null},[l.data,w]),j=(b==null?void 0:b.title)??null,N=(b==null?void 0:b.workspace)??null,S=m.useMemo(()=>{var we;return XO({playbooks:((we=f.data)==null?void 0:we.playbooks)??[],projectSlug:w,currentProjectTitle:j,currentProjectWorkspace:N,wsPrefix:o,refetchPlaybooks:f.refetch,navigate:r,toggleTheme:t})},[f.data,f.refetch,w,j,N,o,r,t]),C=m.useRef(new Map),D=m.useRef(["global"]),T=m.useRef({phase:"idle"}),R=m.useRef(null),$=m.useRef(1),[_,U]=m.useState(!1),[I,F]=m.useState(!1),[M,A]=m.useState(!1),[L,z]=m.useState(null);m.useEffect(()=>{(_||M)&&a(!0)},[_,M]);const{bindings:W}=G6(),V=m.useMemo(()=>AO(W),[W]),K=m.useCallback(we=>{const ke=$.current++;return C.current.set(ke,{...we,id:ke}),ke},[]),O=m.useCallback(we=>{C.current.delete(we)},[]),B=m.useCallback(we=>{D.current.push(we)},[]),G=m.useCallback(we=>{const ke=D.current;for(let $e=ke.length-1;$e>=0;$e--)if(ke[$e]===we){ke.splice($e,1);return}},[]),H=m.useCallback(()=>U(!0),[]),Q=m.useCallback(()=>U(!1),[]),te=m.useCallback(()=>F(!0),[]),Z=m.useCallback(()=>F(!1),[]),ae=m.useCallback(()=>A(!0),[]),ne=m.useCallback(()=>{A(!1),z(null)},[]),ue=m.useCallback(()=>Array.from(C.current.values()),[]),ye=m.useCallback(()=>{let we=null;return z(ke=>(we=ke,null)),we},[]),Ne=m.useCallback(we=>{z(we),A(!0)},[]),Re=m.useCallback((we,ke)=>{const $e=xr(we);if(!$e)return null;if(TO($e)){const Ue=H6($e);return{description:(Ue==null?void 0:Ue.description)??"Reserved built-in shortcut"}}for(const[Ue,nt]of Object.entries(V))if(!(ke&&Ue===ke)&&nt===$e)return{kind:Ue};return null},[V]),Se=m.useCallback(async(we,ke)=>{const $e=xr(ke);if(!$e)throw new Error("Empty combo");const Ue=Re($e,we);if(Ue){const He=Ue.description?`Reserved: ${Ue.description}`:`Already bound to "${Ue.kind}"`;throw new Error(He)}const nt={...W,[we]:$e};return await F1(nt),$e},[W,Re]),ze=m.useCallback(async we=>{if(!W[we])return;const ke={...W};delete ke[we],await F1(ke)},[W]);m.useEffect(()=>{T.current={phase:"idle"},R.current!==null&&(window.clearTimeout(R.current),R.current=null)},[n.pathname]),m.useEffect(()=>{function we(He){if(!(He instanceof HTMLElement))return!1;const at=He.tagName;return!!(at==="INPUT"||at==="TEXTAREA"||at==="SELECT"||He.isContentEditable||He.closest('[role="combobox"], [role="textbox"]'))}function ke(){return!!(document.querySelector('[role="dialog"][data-state="open"]')||document.querySelector('[role="alertdialog"][data-state="open"]'))}function $e(){const He=D.current;return He[He.length-1]??"global"}function Ue(He){return He.scope==="global"?!0:He.scope===$e()}function nt(He){const at=Qf(He,"Mod+k"),xt=Qf(He,"Mod+Shift+k"),lt=He.key==="Escape",ot=at||xt||lt;if(ke()&&!ot||we(He.target)&&!ot)return;const le=T.current;if(le.phase==="awaiting-second")if(Date.now()-le.startedAt>z1)T.current={phase:"idle"},R.current!==null&&(window.clearTimeout(R.current),R.current=null);else{const We=Array.from(C.current.values());for(const Ge of We){if(!Ue(Ge))continue;const ge=Ge.keys.split(" ");if(!(ge.length!==2||ge[0]!=="g")&&Qf(He,ge[1])&&!(Ge.when&&!Ge.when())){He.preventDefault(),T.current={phase:"idle"},R.current!==null&&(window.clearTimeout(R.current),R.current=null),Ge.handler(He);return}}T.current={phase:"idle"},R.current!==null&&(window.clearTimeout(R.current),R.current=null)}const xe=Array.from(C.current.values());for(const Oe of xe){if(!Ue(Oe))continue;const We=Oe.keys.split(" ");if(We.length===1&&Qf(He,We[0])&&!(Oe.when&&!Oe.when())){He.preventDefault(),Oe.handler(He);return}}He.key==="g"&&!He.metaKey&&!He.ctrlKey&&!He.altKey&&!He.shiftKey&&Array.from(C.current.values()).some(We=>Ue(We)&&We.keys.startsWith("g "))&&(He.preventDefault(),T.current={phase:"awaiting-second",startedAt:Date.now()},R.current!==null&&window.clearTimeout(R.current),R.current=window.setTimeout(()=>{T.current={phase:"idle"},R.current=null},z1))}return window.addEventListener("keydown",nt),()=>{window.removeEventListener("keydown",nt),R.current!==null&&(window.clearTimeout(R.current),R.current=null)}},[]),m.useEffect(()=>{const we=K({keys:"Shift+t",handler:()=>t(),scope:"global",description:"Toggle light/dark theme"});return()=>O(we)},[K,O,t]),m.useEffect(()=>{const we=K({keys:"?",scope:"global",description:"Show keyboard shortcuts",handler:()=>te()});return()=>O(we)},[K,O,te]),m.useEffect(()=>{const we=K({keys:"Mod+k",scope:"global",description:"Open command palette",handler:()=>{if(_){Q();return}document.querySelector('[role="dialog"][data-state="open"], [role="alertdialog"][data-state="open"]')||H()}});return()=>O(we)},[K,O,H,Q,_]),m.useEffect(()=>{const we=K({keys:"Mod+Shift+k",scope:"global",description:"Open actions palette",handler:()=>{if(M){ne();return}document.querySelector('[role="dialog"][data-state="open"], [role="alertdialog"][data-state="open"]')||ae()}});return()=>O(we)},[K,O,ae,ne,M]),m.useEffect(()=>{const ke=[{suffix:"o",basePath:"/",desc:"Go to Overview"},{suffix:"m",basePath:"/projects",desc:"Go to Projects"},{suffix:"a",basePath:"/assignments",desc:"Go to Assignments"},{suffix:"t",basePath:"/todos",desc:"Go to Todos"},{suffix:"s",basePath:"/servers",desc:"Go to Servers"},{suffix:",",basePath:"/settings",desc:"Go to Settings"}].map($e=>K({keys:`g ${$e.suffix}`,scope:"global",description:$e.desc,handler:()=>r(Ap($e.basePath,o))}));return()=>ke.forEach(O)},[K,O,r,o]),m.useEffect(()=>{const we=[];for(const[ke,$e]of Object.entries(V)){if(!$e)continue;const Ue=S.find(He=>He.bindableKind===ke),nt=Ue?`Custom: ${Ue.title}`:`Custom: ${ke}`;we.push(K({keys:$e,scope:"global",description:nt,handler:()=>{z(ke),A(!0)}}))}return()=>we.forEach(O)},[K,O,V,S]);const oe=m.useMemo(()=>({register:K,unregister:O,pushScope:B,popScope:G,openPalette:H,closePalette:Q,paletteOpen:_,openCheatsheet:te,closeCheatsheet:Z,cheatsheetOpen:I,openActionsPalette:ae,closeActionsPalette:ne,actionsPaletteOpen:M,listBindings:ue,wsPrefix:o,paletteEntries:y,actionEntries:S,userBindings:W,customBindings:V,bindAction:Se,unbindAction:ze,findConflict:Re,openActionsPaletteWithAction:Ne,pendingActionKind:L,consumePendingActionKind:ye}),[K,O,B,G,H,Q,_,te,Z,I,ae,ne,M,ue,o,y,S,W,V,Se,ze,Re,Ne,L,ye]);return s.jsxs(_T.Provider,{value:oe,children:[e,s.jsx(L6,{entries:y}),s.jsx(B6,{entries:S}),s.jsx(q6,{})]})}function Ci(){const e=m.useContext(_T);if(!e)throw new Error("useHotkeyContext must be used within HotkeyProvider");return e}function Jt({keys:e,handler:t,scope:n="global",description:r,when:o,enabled:i=!0}){const{register:a,unregister:l}=Ci(),d=m.useRef(t),f=m.useRef(o);m.useEffect(()=>{d.current=t,f.current=o},[t,o]),m.useEffect(()=>{if(!i)return;const p=a({keys:e,handler:h=>d.current(h),scope:n,description:r,when:f.current?()=>f.current():void 0});return()=>l(p)},[a,l,e,n,r,i])}function Ei(e){const{pushScope:t,popScope:n}=Ci();m.useEffect(()=>(t(e),()=>n(e)),[t,n,e])}function Ad(e,t){const[n,r]=m.useState(e.length===0?-1:0),o=or();m.useEffect(()=>{r(e.length===0?-1:0)},[o.pathname]),m.useEffect(()=>{r(a=>e.length===0?-1:Math.min(Math.max(0,a),e.length-1))},[e.length]),m.useEffect(()=>{if(document.querySelectorAll("[data-hotkey-row-index]").forEach(l=>{const d=Number(l.getAttribute("data-hotkey-row-index"));l.setAttribute("data-hotkey-selected",d===n?"true":"false")}),n>=0){const l=document.querySelector(`[data-hotkey-row-index="${n}"]`);l==null||l.scrollIntoView({block:"nearest"})}},[n,e.length]),Jt({keys:"j",scope:t.scope,description:"Select next row",handler:()=>r(a=>e.length===0?-1:Math.min(e.length-1,a<0?0:a+1))}),Jt({keys:"k",scope:t.scope,description:"Select previous row",handler:()=>r(a=>e.length===0?-1:Math.max(0,a<0?0:a-1))}),Jt({keys:"Enter",scope:t.scope,description:"Open selected row",handler:()=>{n>=0&&n<e.length&&t.onOpen(e[n],n)}}),Jt({keys:"o",scope:t.scope,description:"Open selected row",enabled:t.bindO??!0,handler:()=>{n>=0&&n<e.length&&t.onOpen(e[n],n)}});const i=m.useCallback(a=>({"data-hotkey-row-index":a,"data-hotkey-selected":a===n?"true":"false"}),[n]);return{selectedIndex:n,hotkeyRowProps:i}}function J6({title:e,breadcrumbs:t,projectSlug:n,onOpenMobileNav:r}){const o=pn(),{resolvedTheme:i,toggleTheme:a}=Ov(),{openPalette:l}=Ci();return s.jsx("header",{className:"sticky top-0 z-30 border-b border-border/70 bg-background/70 backdrop-blur",children:s.jsxs("div",{className:"flex flex-wrap items-center gap-2 px-4 py-2.5 lg:px-6",children:[s.jsx("button",{type:"button",onClick:r,className:"inline-flex h-8 w-8 items-center justify-center rounded-md border border-border/70 bg-card/80 text-foreground lg:hidden","aria-label":"Open navigation",children:s.jsx(QL,{className:"h-4 w-4"})}),s.jsx("div",{className:"min-w-0 flex-1",children:s.jsxs("div",{className:"flex items-center gap-2",children:[t.length>1?s.jsxs("nav",{className:"flex items-center gap-1.5 text-xs font-medium uppercase tracking-[0.1em] text-muted-foreground",children:[t.slice(0,-1).map((d,f)=>s.jsxs("span",{className:"flex items-center gap-1.5",children:[f>0?s.jsx("span",{children:"/"}):null,s.jsx(Ie,{to:d.path,className:"hover:text-foreground",children:d.label})]},d.path)),s.jsx("span",{children:"/"})]}):null,s.jsx("h1",{className:"min-w-0 truncate text-base font-semibold text-foreground",children:e})]})}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("button",{type:"button",onClick:l,className:"shell-action","aria-label":"Open command palette",children:[s.jsx(Si,{className:"h-4 w-4"}),s.jsx("span",{className:"hidden sm:inline font-mono text-xs",children:Gs("Mod+k")})]}),s.jsx(Ie,{className:"shell-action hidden sm:inline-flex",to:"/help",children:"Help"}),s.jsxs(Ie,{className:"shell-action",to:`${o}/create/project`,"aria-label":"New Project",children:[s.jsx(It,{className:"h-4 w-4"}),s.jsx("span",{className:"hidden sm:inline",children:"New Project"})]}),n?s.jsxs(Ie,{className:"shell-action",to:`${o}/projects/${n}/create/assignment`,"aria-label":"New Assignment",children:[s.jsx(It,{className:"h-4 w-4"}),s.jsx("span",{className:"hidden sm:inline",children:"New Assignment"})]}):null,s.jsxs("button",{type:"button",onClick:a,className:"shell-action","aria-label":"Toggle theme",children:[i==="dark"?s.jsx(l4,{className:"h-4 w-4"}):s.jsx(JL,{className:"h-4 w-4"}),s.jsx("span",{className:"hidden sm:inline",children:i==="dark"?"Light":"Dark"})]})]})]})})}const Z6=4e3;function wr(){const[e,t]=m.useState(null),n=m.useRef(null),r=m.useCallback(()=>{n.current!==null&&(clearTimeout(n.current),n.current=null),t(null)},[]),o=m.useCallback((i,a="error")=>{n.current!==null&&clearTimeout(n.current),t({id:Date.now()+Math.random(),message:i,kind:a}),n.current=setTimeout(()=>{t(null),n.current=null},Z6)},[]);return m.useEffect(()=>()=>{n.current!==null&&clearTimeout(n.current)},[]),{toast:e,showToast:o,dismissToast:r}}function Hr({toast:e,onDismiss:t}){if(!e)return null;const n=e.kind==="error";return s.jsx("div",{className:"pointer-events-none fixed bottom-4 right-4 z-50 flex max-w-sm",role:"status","aria-live":"polite",children:s.jsx("button",{type:"button",onClick:t,className:Ce("syntaur-toast pointer-events-auto rounded-md border px-4 py-3 text-sm font-medium shadow-lg transition",n?"border-error-foreground/30 bg-error text-error-foreground hover:opacity-90":"border-success-foreground/30 bg-success text-success-foreground hover:opacity-90"),children:e.message},e.id)})}const oh="_ungrouped",ez=256;function tz(e){if(!Array.isArray(e))return[];const t=new Set,n=[];for(const r of e){if(typeof r!="string")continue;const o=r.trim();o.length!==0&&(o.length>ez||/[\r\n]/.test(o)||t.has(o)||(t.add(o),n.push(o)))}return n}function nz(e,t){if(t.length===0)return[...e];const n=new Set(t);return e.filter(r=>!n.has(r))}function rz(e,t){return t.includes(e)}const cw={hidden:[],custom:!1};let wo=null,Ji=null,Qu=0;const wb=new Set;function DT(e){wo=e;for(const t of wb)t(e)}function uw(e){if(!e||typeof e!="object")return cw;const t=e;return{hidden:tz(t.hidden),custom:t.custom===!0}}function sz(){if(wo)return Promise.resolve({value:wo,ok:!0});if(Ji)return Ji;const e=++Qu;return Ji=fetch("/api/config/workspace-visibility").then(t=>{if(!t.ok)throw new Error(`HTTP ${t.status}`);return t.json()}).then(t=>{Ji=null;const n=uw(t);return e!==Qu?{value:wo??n,ok:!0}:(wo=n,{value:n,ok:!0})}).catch(()=>(Ji=null,{value:cw,ok:!1})),Ji}function $T(){const[e,t]=m.useState(()=>wo??cw),[n,r]=m.useState(()=>wo===null),[o,i]=m.useState(!1),[a,l]=m.useState(0);m.useEffect(()=>{let f=!1;return r(wo===null),sz().then(p=>{f||(t(p.value),r(!1),i(!p.ok))}),wb.add(t),()=>{f=!0,wb.delete(t)}},[a]);function d(){oz(),l(f=>f+1)}return{...e,loading:n,error:o,reload:d}}function oz(){wo=null,Ji=null,++Qu}async function iz(e){++Qu;const t=await fetch("/api/config/workspace-visibility",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({hidden:e})});if(!t.ok){const r=await t.json().catch(()=>null);throw new Error((r==null?void 0:r.error)??`HTTP ${t.status}`)}const n=uw(await t.json());return DT(n),n}async function az(){++Qu;const e=await fetch("/api/config/workspace-visibility",{method:"DELETE"});if(!e.ok){const n=await e.json().catch(()=>null);throw new Error((n==null?void 0:n.error)??`HTTP ${e.status}`)}const t=uw(await e.json());return DT(t),t}var lz=Symbol("radix.slottable");function cz(e){const t=({children:n})=>s.jsx(s.Fragment,{children:n});return t.displayName=`${e}.Slottable`,t.__radixId=lz,t}var IT="AlertDialog",[uz]=Na(IT,[rT]),Ro=rT(),MT=e=>{const{__scopeAlertDialog:t,...n}=e,r=Ro(t);return s.jsx(bT,{...r,...n,modal:!0})};MT.displayName=IT;var dz="AlertDialogTrigger",fz=m.forwardRef((e,t)=>{const{__scopeAlertDialog:n,...r}=e,o=Ro(n);return s.jsx(vT,{...o,...r,ref:t})});fz.displayName=dz;var pz="AlertDialogPortal",LT=e=>{const{__scopeAlertDialog:t,...n}=e,r=Ro(t);return s.jsx(wT,{...r,...n})};LT.displayName=pz;var hz="AlertDialogOverlay",OT=m.forwardRef((e,t)=>{const{__scopeAlertDialog:n,...r}=e,o=Ro(n);return s.jsx(Jv,{...o,...r,ref:t})});OT.displayName=hz;var Il="AlertDialogContent",[mz,gz]=uz(Il),xz=cz("AlertDialogContent"),FT=m.forwardRef((e,t)=>{const{__scopeAlertDialog:n,children:r,...o}=e,i=Ro(n),a=m.useRef(null),l=Zn(t,a),d=m.useRef(null);return s.jsx(UF,{contentName:Il,titleName:zT,docsSlug:"alert-dialog",children:s.jsx(mz,{scope:n,cancelRef:d,children:s.jsxs(Zv,{role:"alertdialog",...i,...o,ref:l,onOpenAutoFocus:rn(o.onOpenAutoFocus,f=>{var p;f.preventDefault(),(p=d.current)==null||p.focus({preventScroll:!0})}),onPointerDownOutside:f=>f.preventDefault(),onInteractOutside:f=>f.preventDefault(),children:[s.jsx(xz,{children:r}),s.jsx(bz,{contentRef:a})]})})})});FT.displayName=Il;var zT="AlertDialogTitle",BT=m.forwardRef((e,t)=>{const{__scopeAlertDialog:n,...r}=e,o=Ro(n);return s.jsx(ew,{...o,...r,ref:t})});BT.displayName=zT;var UT="AlertDialogDescription",HT=m.forwardRef((e,t)=>{const{__scopeAlertDialog:n,...r}=e,o=Ro(n);return s.jsx(tw,{...o,...r,ref:t})});HT.displayName=UT;var yz="AlertDialogAction",VT=m.forwardRef((e,t)=>{const{__scopeAlertDialog:n,...r}=e,o=Ro(n);return s.jsx(nw,{...o,...r,ref:t})});VT.displayName=yz;var WT="AlertDialogCancel",qT=m.forwardRef((e,t)=>{const{__scopeAlertDialog:n,...r}=e,{cancelRef:o}=gz(WT,n),i=Ro(n),a=Zn(t,o);return s.jsx(nw,{...i,...r,ref:a})});qT.displayName=WT;var bz=({contentRef:e})=>{const t=`\`${Il}\` requires a description for the component to be accessible for screen reader users.
581
+
582
+ You can add a description to the \`${Il}\` by passing a \`${UT}\` component as a child, which also benefits sighted users by adding visible context to the dialog.
583
+
584
+ Alternatively, you can use your own component as a description by assigning it an \`id\` and passing the same value to the \`aria-describedby\` prop in \`${Il}\`. If the description is confusing or duplicative for sighted users, you can use the \`@radix-ui/react-visually-hidden\` primitive as a wrapper around your description component.
585
+
586
+ For more information, see https://radix-ui.com/primitives/docs/components/alert-dialog`;return m.useEffect(()=>{var r;document.getElementById((r=e.current)==null?void 0:r.getAttribute("aria-describedby"))||console.warn(t)},[t,e]),null},vz=MT,wz=LT,KT=OT,GT=FT,YT=VT,XT=qT,QT=BT,JT=HT;const kl=vz,jz=wz,ZT=m.forwardRef(({className:e,...t},n)=>s.jsx(KT,{ref:n,className:Ce("fixed inset-0 z-50 bg-background/80 backdrop-blur-sm",e),...t}));ZT.displayName=KT.displayName;const oa=m.forwardRef(({className:e,...t},n)=>s.jsxs(jz,{children:[s.jsx(ZT,{}),s.jsx(GT,{ref:n,className:Ce("chrome-card fixed left-1/2 top-1/2 z-50 grid w-[calc(100%-2rem)] max-w-lg -translate-x-1/2 -translate-y-1/2 gap-4 !p-6 outline-none",e),...t})]}));oa.displayName=GT.displayName;function Sl({className:e,...t}){return s.jsx("div",{className:Ce("flex flex-col space-y-2 text-left",e),...t})}function Nl({className:e,...t}){return s.jsx("div",{className:Ce("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",e),...t})}const ia=m.forwardRef(({className:e,...t},n)=>s.jsx(QT,{ref:n,className:Ce("text-lg font-semibold tracking-tight text-foreground",e),...t}));ia.displayName=QT.displayName;const aa=m.forwardRef(({className:e,...t},n)=>s.jsx(JT,{ref:n,className:Ce("text-sm leading-6 text-muted-foreground",e),...t}));aa.displayName=JT.displayName;const gi=m.forwardRef(({className:e,...t},n)=>s.jsx(YT,{ref:n,className:Ce(e),...t}));gi.displayName=YT.displayName;const Ju=m.forwardRef(({className:e,...t},n)=>s.jsx(XT,{ref:n,className:Ce(e),...t}));Ju.displayName=XT.displayName;const kz=[{to:"/",label:"Overview",icon:YE},{to:"/playbooks",label:"Playbooks",icon:WE},{to:"/memories",label:"Memories",icon:SL},{to:"/resources",label:"Resources",icon:WL},{to:"/inventories",label:"Inventories",icon:Tv},{to:"/schedules",label:"Schedules",icon:qE},{to:"/usage",label:"Usage",icon:Wh},{to:"/todos",label:"Todos",icon:gs},{to:"/views",label:"Saved Views",icon:QE},{to:"/archive",label:"Archive",icon:Hh}],Sz=[{suffix:"/projects",label:"Projects",icon:Av},{suffix:"/assignments",label:"Assignments",icon:GL},{suffix:"/servers",label:"Servers",icon:$v},{suffix:"/agent-sessions",label:"Agent Sessions",icon:Uh}],Nz=[{to:"/help",label:"Help",icon:qL},{to:"/workflow",label:"Workflow",icon:d4},{to:"/settings",label:"Settings",icon:i4}];function Cz({title:e,breadcrumbs:t,projectSlug:n,workspace:r,children:o}){const[i,a]=m.useState(!1);return Jt({keys:"Escape",scope:"global",description:"Close mobile navigation",enabled:i,handler:()=>a(!1)}),s.jsx("div",{className:"min-h-screen bg-background",children:s.jsxs("div",{className:"relative grid min-h-screen lg:grid-cols-[240px_minmax(0,1fr)]",children:[s.jsx("aside",{className:"hidden max-h-screen sticky top-0 overflow-y-auto border-r border-border/70 bg-sidebar px-4 py-4 lg:flex lg:flex-col",children:s.jsx(B1,{activeWorkspace:r})}),i?s.jsx("div",{className:"fixed inset-0 z-40 bg-overlay/40 lg:hidden",children:s.jsxs("div",{className:"h-full max-w-xs border-r border-border/70 bg-sidebar p-4 shadow-2xl",children:[s.jsxs("div",{className:"mb-4 flex items-center justify-between",children:[s.jsx(Ie,{to:"/",className:"text-lg font-semibold text-foreground",onClick:()=>a(!1),children:"Syntaur"}),s.jsx("button",{type:"button",onClick:()=>a(!1),className:"inline-flex h-9 w-9 items-center justify-center rounded-md border border-border/70 bg-background/80","aria-label":"Close navigation",children:s.jsx(Cd,{className:"h-4 w-4"})})]}),s.jsx(B1,{activeWorkspace:r,onNavigate:()=>a(!1)})]})}):null,s.jsxs("div",{className:"min-w-0",children:[s.jsx(J6,{title:e,breadcrumbs:t,projectSlug:n,onOpenMobileNav:()=>a(!0)}),s.jsx("main",{className:"mx-auto w-full max-w-[1480px] px-4 py-4 lg:px-6 lg:py-5",children:o})]})]})})}function B1({activeWorkspace:e,onNavigate:t}){const{data:n}=Sa(),r=(n==null?void 0:n.workspaces)??[],o=(n==null?void 0:n.hasUngrouped)??!1,{hidden:i}=$T(),a=or(),[l,d]=m.useState(new Set),[f,p]=m.useState(!1),[h,g]=m.useState(""),[y,k]=m.useState(null),[w,b]=m.useState(null),[j,N]=m.useState(null),[S,C]=m.useState(!1),D=Ht(),{toast:T,showToast:R,dismissToast:$}=wr();function _(M){d(A=>{const L=new Set(A);return L.has(M)?L.delete(M):L.add(M),L})}const U=nz([...r,...o?[oh]:[]],i);async function I(M){if(w){C(!0);try{const A=`/api/workspaces/${encodeURIComponent(w)}${M?"?cascade=true":""}`,L=await fetch(A,{method:"DELETE"});if(L.status===409){const z=await L.json().catch(()=>({}));N((z==null?void 0:z.blockedBy)??{projects:[],standalones:[]});return}if(!L.ok){const z=await L.json().catch(()=>({}));throw new Error(z.error||"Failed to delete workspace")}b(null),N(null)}catch(A){console.error(A),alert(A instanceof Error?A.message:"Failed to delete workspace")}finally{C(!1)}}}async function F(M,A){try{if(M.type==="project"){const L=await fetch(`/api/projects/${encodeURIComponent(M.id)}/move-workspace`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({workspace:A})});if(!L.ok){const z=await L.json().catch(()=>({}));throw new Error(z.error||"Failed to move project")}return}if(M.type==="standalone-assignment"){const L=await fetch(`/api/assignments/${encodeURIComponent(M.id)}/move-workspace`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({workspaceGroup:A})});if(!L.ok){const z=await L.json().catch(()=>({}));throw new Error(z.error||"Failed to move assignment")}return}if(M.type==="project-assignment"){alert("Assignments inherit workspace from their project — drag the project (or move it) to change workspaces.");return}}catch(L){console.error(L),alert(L instanceof Error?L.message:"Failed to move item")}}return s.jsxs("div",{className:"flex h-full flex-col gap-3",children:[s.jsx(Hr,{toast:T,onDismiss:$}),s.jsx("div",{className:"space-y-3",children:s.jsxs(Ie,{to:"/",className:"inline-flex items-center gap-3",onClick:t,children:[s.jsx("span",{className:"inline-flex h-8 w-8 items-center justify-center rounded-lg bg-card text-foreground shadow-sm ring-1 ring-border/60",children:s.jsxs("svg",{viewBox:"0 0 43 51","aria-label":"Syntaur",role:"img",className:"h-4 w-auto",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:[s.jsx("path",{d:"M13 2C13 0.89543 13.8954 0 15 0H41C42.1046 0 43 0.895431 43 2V12C43 13.1046 42.1046 14 41 14H13V2Z"}),s.jsx("path",{d:"M0 15C0 13.8954 0.895431 13 2 13H14V25C14 26.1046 13.1046 27 12 27H2C0.89543 27 0 26.1046 0 25V15Z"}),s.jsx("path",{d:"M30 49C30 50.1046 29.1046 51 28 51L2 51C0.89543 51 0 50.1046 0 49L0 39C0 37.8954 0.895431 37 2 37L30 37L30 49Z"}),s.jsx("path",{d:"M42.9646 36C42.9646 37.1046 42.0692 38 40.9646 38H28.9646V26C28.9646 24.8954 29.86 24 30.9646 24H40.9646C42.0692 24 42.9646 24.8954 42.9646 26V36Z"})]})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-sm font-semibold text-foreground",children:"Syntaur"}),s.jsx("p",{className:"text-xs text-muted-foreground/60",children:"Local-first project control"})]})]})}),s.jsx(m1,{items:kz,onNavigate:t}),s.jsx("div",{className:"border-t border-border/40"}),s.jsxs("div",{className:"flex-1 space-y-1 overflow-y-auto",children:[U.length===0&&!f&&s.jsx("p",{className:"px-3 py-2 text-xs text-muted-foreground/60",children:"No workspaces yet"}),U.map(M=>{const A=M==="_ungrouped",L=A?"Ungrouped":Dn(M),z=A?"/w/_ungrouped":`/w/${M}`,W=l.has(M),V=e===M||e===null&&A&&a.pathname.startsWith("/w/_ungrouped"),K=y===M;return s.jsxs("div",{className:`rounded-md transition ${K?"bg-accent/40 ring-1 ring-ring/40":""}`,onDragOver:O=>{O.dataTransfer.types.includes("application/json")&&(O.preventDefault(),O.dataTransfer.dropEffect="move",k(M))},onDragLeave:O=>{O.currentTarget.contains(O.relatedTarget)||k(B=>B===M?null:B)},onDrop:async O=>{try{const B=O.dataTransfer.getData("application/json");if(!B)return;O.preventDefault();let G;try{G=JSON.parse(B)}catch{return}if(!(G!=null&&G.type)||!(G!=null&&G.id))return;await F(G,A?null:M)}finally{k(null)}},children:[s.jsxs("div",{className:"group flex items-center",children:[s.jsxs("button",{type:"button",onClick:()=>_(M),className:`flex flex-1 items-center gap-2 rounded-md px-3 py-1.5 text-xs font-semibold uppercase tracking-wider transition ${V?"text-foreground":"text-muted-foreground/70 hover:text-muted-foreground"}`,children:[s.jsx(vr,{className:`h-3 w-3 transition-transform ${W?"-rotate-90":""}`}),L]}),A?null:s.jsx("button",{type:"button",onClick:O=>{O.stopPropagation(),b(M),N(null)},title:`Delete workspace "${M}"`,"aria-label":`Delete workspace "${M}"`,className:"mr-1 flex h-6 w-6 items-center justify-center rounded text-muted-foreground/60 opacity-0 transition hover:bg-destructive/10 hover:text-destructive focus-visible:opacity-100 group-hover:opacity-100",children:s.jsx(bn,{className:"h-3 w-3"})})]}),!W&&s.jsx("nav",{className:"ml-2 space-y-0.5",children:Sz.map(O=>{const B=`${z}${O.suffix}`,G=d2(a.pathname,O.suffix)&&a.pathname.startsWith(z),H=O.icon;return s.jsxs(Ie,{to:B,onClick:t,className:`flex items-center gap-3 rounded-md px-3 py-1.5 text-sm font-medium transition ${G?"bg-foreground text-background shadow-sm":"text-muted-foreground hover:bg-background/80 hover:text-foreground"}`,children:[s.jsx(H,{className:"h-4 w-4"}),s.jsx("span",{children:O.label})]},B)})})]},M)}),f?s.jsx("form",{className:"px-3 py-1.5",onSubmit:async M=>{M.preventDefault();const A=h.trim().toLowerCase().replace(/[^a-z0-9-]/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"");if(A){p(!1),g("");try{const L=await fetch("/api/workspaces",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:A})});if(!L.ok){const z=await L.json().catch(()=>null);R((z==null?void 0:z.error)||`HTTP ${L.status}`,"error");return}t==null||t(),D(`/w/${A}/projects`)}catch(L){R(L instanceof Error?L.message:"Failed to create workspace","error")}}},children:s.jsx("input",{autoFocus:!0,type:"text",value:h,onChange:M=>g(M.target.value),onKeyDown:M=>{M.key==="Escape"&&(p(!1),g(""))},onBlur:()=>{h.trim()||(p(!1),g(""))},placeholder:"workspace-name",className:"w-full rounded-md border border-border/60 bg-background/80 px-2 py-1 text-xs text-foreground placeholder:text-muted-foreground/50 focus:border-foreground/40 focus:outline-none"})}):s.jsxs("button",{type:"button",onClick:()=>p(!0),className:"flex w-full items-center gap-2 rounded-md px-3 py-1.5 text-xs font-medium text-muted-foreground/60 transition hover:text-muted-foreground",children:[s.jsx(It,{className:"h-3 w-3"}),"New Workspace"]})]}),s.jsx("div",{className:"border-t border-border/40"}),s.jsx(m1,{items:Nz,onNavigate:t}),s.jsx(kl,{open:w!==null,onOpenChange:M=>{S||M||(b(null),N(null))},children:s.jsxs(oa,{children:[s.jsxs(Sl,{children:[s.jsx(ia,{children:j?"Workspace has references":"Delete workspace?"}),s.jsx(aa,{children:j?s.jsxs(s.Fragment,{children:["The workspace ",s.jsx("code",{className:"rounded bg-muted px-1 py-0.5",children:w})," is still referenced by:"]}):s.jsxs(s.Fragment,{children:["Remove the workspace ",s.jsx("code",{className:"rounded bg-muted px-1 py-0.5",children:w})," from the registry. This does not affect projects or standalones unless you choose to cascade."]})})]}),j?s.jsxs("div",{className:"space-y-2 text-sm",children:[j.projects.length>0?s.jsxs("div",{children:[s.jsxs("p",{className:"font-medium text-foreground",children:["Projects (",j.projects.length,")"]}),s.jsx("ul",{className:"mt-1 list-disc pl-5 text-muted-foreground",children:j.projects.map(M=>s.jsx("li",{children:s.jsx(Ie,{to:`/projects/${M}`,className:"hover:underline",children:M})},M))})]}):null,j.standalones.length>0?s.jsxs("div",{children:[s.jsxs("p",{className:"font-medium text-foreground",children:["Standalones (",j.standalones.length,")"]}),s.jsx("ul",{className:"mt-1 list-disc pl-5 text-muted-foreground",children:j.standalones.map(M=>s.jsx("li",{children:s.jsx(Ie,{to:`/assignments/${M}`,className:"hover:underline",children:M})},M))})]}):null,s.jsxs("p",{className:"text-xs text-muted-foreground",children:['Choose "Clear references and delete" to set ',s.jsx("code",{children:"workspace:"})," / ",s.jsx("code",{children:"workspaceGroup:"})," to ",s.jsx("code",{children:"null"})," on each, then remove the workspace."]})]}):null,s.jsxs(Nl,{children:[s.jsx(Ju,{disabled:S,className:"shell-action mt-0 disabled:cursor-not-allowed disabled:opacity-50",children:"Cancel"}),j?s.jsx(gi,{disabled:S,onClick:M=>{M.preventDefault(),I(!0)},className:"shell-action mt-0 border-destructive/80 bg-destructive text-destructive-foreground hover:bg-destructive/90 disabled:cursor-not-allowed disabled:opacity-50",children:S?"Working…":"Clear references and delete"}):s.jsx(gi,{disabled:S,onClick:M=>{M.preventDefault(),I(!1)},className:"shell-action mt-0 border-destructive/80 bg-destructive text-destructive-foreground hover:bg-destructive/90 disabled:cursor-not-allowed disabled:opacity-50",children:S?"Working…":"Delete"})]})]})})]})}function Ez(){const e=or(),{workspace:t}=Vt(),{title:n,breadcrumbs:r,projectSlug:o}=f2(e.pathname);return s.jsx(Cz,{title:n,breadcrumbs:r,projectSlug:o,workspace:t??null,children:s.jsx(IM,{})})}function Tz(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return m.useMemo(()=>r=>{t.forEach(o=>o(r))},t)}const im=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function mc(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function dw(e){return"nodeType"in e}function ir(e){var t,n;return e?mc(e)?e:dw(e)&&(t=(n=e.ownerDocument)==null?void 0:n.defaultView)!=null?t:window:window}function fw(e){const{Document:t}=ir(e);return e instanceof t}function Pd(e){return mc(e)?!1:e instanceof ir(e).HTMLElement}function eR(e){return e instanceof ir(e).SVGElement}function gc(e){return e?mc(e)?e.document:dw(e)?fw(e)?e:Pd(e)||eR(e)?e.ownerDocument:document:document:document}const ys=im?m.useLayoutEffect:m.useEffect;function am(e){const t=m.useRef(e);return ys(()=>{t.current=e}),m.useCallback(function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return t.current==null?void 0:t.current(...r)},[])}function Rz(){const e=m.useRef(null),t=m.useCallback((r,o)=>{e.current=setInterval(r,o)},[]),n=m.useCallback(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[]);return[t,n]}function Zu(e,t){t===void 0&&(t=[e]);const n=m.useRef(e);return ys(()=>{n.current!==e&&(n.current=e)},t),n}function _d(e,t){const n=m.useRef();return m.useMemo(()=>{const r=e(n.current);return n.current=r,r},[...t])}function ih(e){const t=am(e),n=m.useRef(null),r=m.useCallback(o=>{o!==n.current&&(t==null||t(o,n.current)),n.current=o},[]);return[n,r]}function ah(e){const t=m.useRef();return m.useEffect(()=>{t.current=e},[e]),t.current}let ry={};function Dd(e,t){return m.useMemo(()=>{if(t)return t;const n=ry[e]==null?0:ry[e]+1;return ry[e]=n,e+"-"+n},[e,t])}function tR(e){return function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];return r.reduce((i,a)=>{const l=Object.entries(a);for(const[d,f]of l){const p=i[d];p!=null&&(i[d]=p+e*f)}return i},{...t})}}const Ml=tR(1),ed=tR(-1);function Az(e){return"clientX"in e&&"clientY"in e}function lm(e){if(!e)return!1;const{KeyboardEvent:t}=ir(e.target);return t&&e instanceof t}function Pz(e){if(!e)return!1;const{TouchEvent:t}=ir(e.target);return t&&e instanceof t}function lh(e){if(Pz(e)){if(e.touches&&e.touches.length){const{clientX:t,clientY:n}=e.touches[0];return{x:t,y:n}}else if(e.changedTouches&&e.changedTouches.length){const{clientX:t,clientY:n}=e.changedTouches[0];return{x:t,y:n}}}return Az(e)?{x:e.clientX,y:e.clientY}:null}const bs=Object.freeze({Translate:{toString(e){if(!e)return;const{x:t,y:n}=e;return"translate3d("+(t?Math.round(t):0)+"px, "+(n?Math.round(n):0)+"px, 0)"}},Scale:{toString(e){if(!e)return;const{scaleX:t,scaleY:n}=e;return"scaleX("+t+") scaleY("+n+")"}},Transform:{toString(e){if(e)return[bs.Translate.toString(e),bs.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:t,duration:n,easing:r}=e;return t+" "+n+"ms "+r}}}),U1="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function _z(e){return e.matches(U1)?e:e.querySelector(U1)}const Dz={display:"none"};function $z(e){let{id:t,value:n}=e;return $t.createElement("div",{id:t,style:Dz},n)}function Iz(e){let{id:t,announcement:n,ariaLiveType:r="assertive"}=e;const o={position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"};return $t.createElement("div",{id:t,style:o,role:"status","aria-live":r,"aria-atomic":!0},n)}function Mz(){const[e,t]=m.useState("");return{announce:m.useCallback(r=>{r!=null&&t(r)},[]),announcement:e}}const nR=m.createContext(null);function Lz(e){const t=m.useContext(nR);m.useEffect(()=>{if(!t)throw new Error("useDndMonitor must be used within a children of <DndContext>");return t(e)},[e,t])}function Oz(){const[e]=m.useState(()=>new Set),t=m.useCallback(r=>(e.add(r),()=>e.delete(r)),[e]);return[m.useCallback(r=>{let{type:o,event:i}=r;e.forEach(a=>{var l;return(l=a[o])==null?void 0:l.call(a,i)})},[e]),t]}const Fz={draggable:`
587
+ To pick up a draggable item, press the space bar.
588
+ While dragging, use the arrow keys to move the item.
589
+ Press space again to drop the item in its new position, or press escape to cancel.
590
+ `},zz={onDragStart(e){let{active:t}=e;return"Picked up draggable item "+t.id+"."},onDragOver(e){let{active:t,over:n}=e;return n?"Draggable item "+t.id+" was moved over droppable area "+n.id+".":"Draggable item "+t.id+" is no longer over a droppable area."},onDragEnd(e){let{active:t,over:n}=e;return n?"Draggable item "+t.id+" was dropped over droppable area "+n.id:"Draggable item "+t.id+" was dropped."},onDragCancel(e){let{active:t}=e;return"Dragging was cancelled. Draggable item "+t.id+" was dropped."}};function Bz(e){let{announcements:t=zz,container:n,hiddenTextDescribedById:r,screenReaderInstructions:o=Fz}=e;const{announce:i,announcement:a}=Mz(),l=Dd("DndLiveRegion"),[d,f]=m.useState(!1);if(m.useEffect(()=>{f(!0)},[]),Lz(m.useMemo(()=>({onDragStart(h){let{active:g}=h;i(t.onDragStart({active:g}))},onDragMove(h){let{active:g,over:y}=h;t.onDragMove&&i(t.onDragMove({active:g,over:y}))},onDragOver(h){let{active:g,over:y}=h;i(t.onDragOver({active:g,over:y}))},onDragEnd(h){let{active:g,over:y}=h;i(t.onDragEnd({active:g,over:y}))},onDragCancel(h){let{active:g,over:y}=h;i(t.onDragCancel({active:g,over:y}))}}),[i,t])),!d)return null;const p=$t.createElement($t.Fragment,null,$t.createElement($z,{id:r,value:o.draggable}),$t.createElement(Iz,{id:l,announcement:a}));return n?vo.createPortal(p,n):p}var $n;(function(e){e.DragStart="dragStart",e.DragMove="dragMove",e.DragEnd="dragEnd",e.DragCancel="dragCancel",e.DragOver="dragOver",e.RegisterDroppable="registerDroppable",e.SetDroppableDisabled="setDroppableDisabled",e.UnregisterDroppable="unregisterDroppable"})($n||($n={}));function ch(){}function vi(e,t){return m.useMemo(()=>({sensor:e,options:t??{}}),[e,t])}function cm(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return m.useMemo(()=>[...t].filter(r=>r!=null),[...t])}const vs=Object.freeze({x:0,y:0});function rR(e,t){return Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))}function Uz(e,t){const n=lh(e);if(!n)return"0 0";const r={x:(n.x-t.left)/t.width*100,y:(n.y-t.top)/t.height*100};return r.x+"% "+r.y+"%"}function sR(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return n-r}function Hz(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return r-n}function H1(e){let{left:t,top:n,height:r,width:o}=e;return[{x:t,y:n},{x:t+o,y:n},{x:t,y:n+r},{x:t+o,y:n+r}]}function oR(e,t){if(!e||e.length===0)return null;const[n]=e;return n[t]}function V1(e,t,n){return t===void 0&&(t=e.left),n===void 0&&(n=e.top),{x:t+e.width*.5,y:n+e.height*.5}}const um=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e;const o=V1(t,t.left,t.top),i=[];for(const a of r){const{id:l}=a,d=n.get(l);if(d){const f=rR(V1(d),o);i.push({id:l,data:{droppableContainer:a,value:f}})}}return i.sort(sR)},Vz=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e;const o=H1(t),i=[];for(const a of r){const{id:l}=a,d=n.get(l);if(d){const f=H1(d),p=o.reduce((g,y,k)=>g+rR(f[k],y),0),h=Number((p/4).toFixed(4));i.push({id:l,data:{droppableContainer:a,value:h}})}}return i.sort(sR)};function Wz(e,t){const n=Math.max(t.top,e.top),r=Math.max(t.left,e.left),o=Math.min(t.left+t.width,e.left+e.width),i=Math.min(t.top+t.height,e.top+e.height),a=o-r,l=i-n;if(r<o&&n<i){const d=t.width*t.height,f=e.width*e.height,p=a*l,h=p/(d+f-p);return Number(h.toFixed(4))}return 0}const qz=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e;const o=[];for(const i of r){const{id:a}=i,l=n.get(a);if(l){const d=Wz(l,t);d>0&&o.push({id:a,data:{droppableContainer:i,value:d}})}}return o.sort(Hz)};function Kz(e,t,n){return{...e,scaleX:t&&n?t.width/n.width:1,scaleY:t&&n?t.height/n.height:1}}function iR(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:vs}function Gz(e){return function(n){for(var r=arguments.length,o=new Array(r>1?r-1:0),i=1;i<r;i++)o[i-1]=arguments[i];return o.reduce((a,l)=>({...a,top:a.top+e*l.y,bottom:a.bottom+e*l.y,left:a.left+e*l.x,right:a.right+e*l.x}),{...n})}}const Yz=Gz(1);function aR(e){if(e.startsWith("matrix3d(")){const t=e.slice(9,-1).split(/, /);return{x:+t[12],y:+t[13],scaleX:+t[0],scaleY:+t[5]}}else if(e.startsWith("matrix(")){const t=e.slice(7,-1).split(/, /);return{x:+t[4],y:+t[5],scaleX:+t[0],scaleY:+t[3]}}return null}function Xz(e,t,n){const r=aR(t);if(!r)return e;const{scaleX:o,scaleY:i,x:a,y:l}=r,d=e.left-a-(1-o)*parseFloat(n),f=e.top-l-(1-i)*parseFloat(n.slice(n.indexOf(" ")+1)),p=o?e.width/o:e.width,h=i?e.height/i:e.height;return{width:p,height:h,top:f,right:d+p,bottom:f+h,left:d}}const Qz={ignoreTransform:!1};function xc(e,t){t===void 0&&(t=Qz);let n=e.getBoundingClientRect();if(t.ignoreTransform){const{transform:f,transformOrigin:p}=ir(e).getComputedStyle(e);f&&(n=Xz(n,f,p))}const{top:r,left:o,width:i,height:a,bottom:l,right:d}=n;return{top:r,left:o,width:i,height:a,bottom:l,right:d}}function W1(e){return xc(e,{ignoreTransform:!0})}function Jz(e){const t=e.innerWidth,n=e.innerHeight;return{top:0,left:0,right:t,bottom:n,width:t,height:n}}function Zz(e,t){return t===void 0&&(t=ir(e).getComputedStyle(e)),t.position==="fixed"}function eB(e,t){t===void 0&&(t=ir(e).getComputedStyle(e));const n=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(o=>{const i=t[o];return typeof i=="string"?n.test(i):!1})}function dm(e,t){const n=[];function r(o){if(t!=null&&n.length>=t||!o)return n;if(fw(o)&&o.scrollingElement!=null&&!n.includes(o.scrollingElement))return n.push(o.scrollingElement),n;if(!Pd(o)||eR(o)||n.includes(o))return n;const i=ir(e).getComputedStyle(o);return o!==e&&eB(o,i)&&n.push(o),Zz(o,i)?n:r(o.parentNode)}return e?r(e):n}function lR(e){const[t]=dm(e,1);return t??null}function sy(e){return!im||!e?null:mc(e)?e:dw(e)?fw(e)||e===gc(e).scrollingElement?window:Pd(e)?e:null:null}function cR(e){return mc(e)?e.scrollX:e.scrollLeft}function uR(e){return mc(e)?e.scrollY:e.scrollTop}function jb(e){return{x:cR(e),y:uR(e)}}var Hn;(function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"})(Hn||(Hn={}));function dR(e){return!im||!e?!1:e===document.scrollingElement}function fR(e){const t={x:0,y:0},n=dR(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},r={x:e.scrollWidth-n.width,y:e.scrollHeight-n.height},o=e.scrollTop<=t.y,i=e.scrollLeft<=t.x,a=e.scrollTop>=r.y,l=e.scrollLeft>=r.x;return{isTop:o,isLeft:i,isBottom:a,isRight:l,maxScroll:r,minScroll:t}}const tB={x:.2,y:.2};function nB(e,t,n,r,o){let{top:i,left:a,right:l,bottom:d}=n;r===void 0&&(r=10),o===void 0&&(o=tB);const{isTop:f,isBottom:p,isLeft:h,isRight:g}=fR(e),y={x:0,y:0},k={x:0,y:0},w={height:t.height*o.y,width:t.width*o.x};return!f&&i<=t.top+w.height?(y.y=Hn.Backward,k.y=r*Math.abs((t.top+w.height-i)/w.height)):!p&&d>=t.bottom-w.height&&(y.y=Hn.Forward,k.y=r*Math.abs((t.bottom-w.height-d)/w.height)),!g&&l>=t.right-w.width?(y.x=Hn.Forward,k.x=r*Math.abs((t.right-w.width-l)/w.width)):!h&&a<=t.left+w.width&&(y.x=Hn.Backward,k.x=r*Math.abs((t.left+w.width-a)/w.width)),{direction:y,speed:k}}function rB(e){if(e===document.scrollingElement){const{innerWidth:i,innerHeight:a}=window;return{top:0,left:0,right:i,bottom:a,width:i,height:a}}const{top:t,left:n,right:r,bottom:o}=e.getBoundingClientRect();return{top:t,left:n,right:r,bottom:o,width:e.clientWidth,height:e.clientHeight}}function pR(e){return e.reduce((t,n)=>Ml(t,jb(n)),vs)}function sB(e){return e.reduce((t,n)=>t+cR(n),0)}function oB(e){return e.reduce((t,n)=>t+uR(n),0)}function hR(e,t){if(t===void 0&&(t=xc),!e)return;const{top:n,left:r,bottom:o,right:i}=t(e);lR(e)&&(o<=0||i<=0||n>=window.innerHeight||r>=window.innerWidth)&&e.scrollIntoView({block:"center",inline:"center"})}const iB=[["x",["left","right"],sB],["y",["top","bottom"],oB]];class pw{constructor(t,n){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;const r=dm(n),o=pR(r);this.rect={...t},this.width=t.width,this.height=t.height;for(const[i,a,l]of iB)for(const d of a)Object.defineProperty(this,d,{get:()=>{const f=l(r),p=o[i]-f;return this.rect[d]+p},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class Lu{constructor(t){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(n=>{var r;return(r=this.target)==null?void 0:r.removeEventListener(...n)})},this.target=t}add(t,n,r){var o;(o=this.target)==null||o.addEventListener(t,n,r),this.listeners.push([t,n,r])}}function aB(e){const{EventTarget:t}=ir(e);return e instanceof t?e:gc(e)}function oy(e,t){const n=Math.abs(e.x),r=Math.abs(e.y);return typeof t=="number"?Math.sqrt(n**2+r**2)>t:"x"in t&&"y"in t?n>t.x&&r>t.y:"x"in t?n>t.x:"y"in t?r>t.y:!1}var Qr;(function(e){e.Click="click",e.DragStart="dragstart",e.Keydown="keydown",e.ContextMenu="contextmenu",e.Resize="resize",e.SelectionChange="selectionchange",e.VisibilityChange="visibilitychange"})(Qr||(Qr={}));function q1(e){e.preventDefault()}function lB(e){e.stopPropagation()}var Et;(function(e){e.Space="Space",e.Down="ArrowDown",e.Right="ArrowRight",e.Left="ArrowLeft",e.Up="ArrowUp",e.Esc="Escape",e.Enter="Enter",e.Tab="Tab"})(Et||(Et={}));const mR={start:[Et.Space,Et.Enter],cancel:[Et.Esc],end:[Et.Space,Et.Enter,Et.Tab]},cB=(e,t)=>{let{currentCoordinates:n}=t;switch(e.code){case Et.Right:return{...n,x:n.x+25};case Et.Left:return{...n,x:n.x-25};case Et.Down:return{...n,y:n.y+25};case Et.Up:return{...n,y:n.y-25}}};class yc{constructor(t){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=t;const{event:{target:n}}=t;this.props=t,this.listeners=new Lu(gc(n)),this.windowListeners=new Lu(ir(n)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(Qr.Resize,this.handleCancel),this.windowListeners.add(Qr.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(Qr.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:t,onStart:n}=this.props,r=t.node.current;r&&hR(r),n(vs)}handleKeyDown(t){if(lm(t)){const{active:n,context:r,options:o}=this.props,{keyboardCodes:i=mR,coordinateGetter:a=cB,scrollBehavior:l="smooth"}=o,{code:d}=t;if(i.end.includes(d)){this.handleEnd(t);return}if(i.cancel.includes(d)){this.handleCancel(t);return}const{collisionRect:f}=r.current,p=f?{x:f.left,y:f.top}:vs;this.referenceCoordinates||(this.referenceCoordinates=p);const h=a(t,{active:n,context:r.current,currentCoordinates:p});if(h){const g=ed(h,p),y={x:0,y:0},{scrollableAncestors:k}=r.current;for(const w of k){const b=t.code,{isTop:j,isRight:N,isLeft:S,isBottom:C,maxScroll:D,minScroll:T}=fR(w),R=rB(w),$={x:Math.min(b===Et.Right?R.right-R.width/2:R.right,Math.max(b===Et.Right?R.left:R.left+R.width/2,h.x)),y:Math.min(b===Et.Down?R.bottom-R.height/2:R.bottom,Math.max(b===Et.Down?R.top:R.top+R.height/2,h.y))},_=b===Et.Right&&!N||b===Et.Left&&!S,U=b===Et.Down&&!C||b===Et.Up&&!j;if(_&&$.x!==h.x){const I=w.scrollLeft+g.x,F=b===Et.Right&&I<=D.x||b===Et.Left&&I>=T.x;if(F&&!g.y){w.scrollTo({left:I,behavior:l});return}F?y.x=w.scrollLeft-I:y.x=b===Et.Right?w.scrollLeft-D.x:w.scrollLeft-T.x,y.x&&w.scrollBy({left:-y.x,behavior:l});break}else if(U&&$.y!==h.y){const I=w.scrollTop+g.y,F=b===Et.Down&&I<=D.y||b===Et.Up&&I>=T.y;if(F&&!g.x){w.scrollTo({top:I,behavior:l});return}F?y.y=w.scrollTop-I:y.y=b===Et.Down?w.scrollTop-D.y:w.scrollTop-T.y,y.y&&w.scrollBy({top:-y.y,behavior:l});break}}this.handleMove(t,Ml(ed(h,this.referenceCoordinates),y))}}}handleMove(t,n){const{onMove:r}=this.props;t.preventDefault(),r(n)}handleEnd(t){const{onEnd:n}=this.props;t.preventDefault(),this.detach(),n()}handleCancel(t){const{onCancel:n}=this.props;t.preventDefault(),this.detach(),n()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}yc.activators=[{eventName:"onKeyDown",handler:(e,t,n)=>{let{keyboardCodes:r=mR,onActivation:o}=t,{active:i}=n;const{code:a}=e.nativeEvent;if(r.start.includes(a)){const l=i.activatorNode.current;return l&&e.target!==l?!1:(e.preventDefault(),o==null||o({event:e.nativeEvent}),!0)}return!1}}];function K1(e){return!!(e&&"distance"in e)}function G1(e){return!!(e&&"delay"in e)}class hw{constructor(t,n,r){var o;r===void 0&&(r=aB(t.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=t,this.events=n;const{event:i}=t,{target:a}=i;this.props=t,this.events=n,this.document=gc(a),this.documentListeners=new Lu(this.document),this.listeners=new Lu(r),this.windowListeners=new Lu(ir(a)),this.initialCoordinates=(o=lh(i))!=null?o:vs,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){const{events:t,props:{options:{activationConstraint:n,bypassActivationConstraint:r}}}=this;if(this.listeners.add(t.move.name,this.handleMove,{passive:!1}),this.listeners.add(t.end.name,this.handleEnd),t.cancel&&this.listeners.add(t.cancel.name,this.handleCancel),this.windowListeners.add(Qr.Resize,this.handleCancel),this.windowListeners.add(Qr.DragStart,q1),this.windowListeners.add(Qr.VisibilityChange,this.handleCancel),this.windowListeners.add(Qr.ContextMenu,q1),this.documentListeners.add(Qr.Keydown,this.handleKeydown),n){if(r!=null&&r({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(G1(n)){this.timeoutId=setTimeout(this.handleStart,n.delay),this.handlePending(n);return}if(K1(n)){this.handlePending(n);return}}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(t,n){const{active:r,onPending:o}=this.props;o(r,t,this.initialCoordinates,n)}handleStart(){const{initialCoordinates:t}=this,{onStart:n}=this.props;t&&(this.activated=!0,this.documentListeners.add(Qr.Click,lB,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(Qr.SelectionChange,this.removeTextSelection),n(t))}handleMove(t){var n;const{activated:r,initialCoordinates:o,props:i}=this,{onMove:a,options:{activationConstraint:l}}=i;if(!o)return;const d=(n=lh(t))!=null?n:vs,f=ed(o,d);if(!r&&l){if(K1(l)){if(l.tolerance!=null&&oy(f,l.tolerance))return this.handleCancel();if(oy(f,l.distance))return this.handleStart()}if(G1(l)&&oy(f,l.tolerance))return this.handleCancel();this.handlePending(l,f);return}t.cancelable&&t.preventDefault(),a(d)}handleEnd(){const{onAbort:t,onEnd:n}=this.props;this.detach(),this.activated||t(this.props.active),n()}handleCancel(){const{onAbort:t,onCancel:n}=this.props;this.detach(),this.activated||t(this.props.active),n()}handleKeydown(t){t.code===Et.Esc&&this.handleCancel()}removeTextSelection(){var t;(t=this.document.getSelection())==null||t.removeAllRanges()}}const uB={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class bc extends hw{constructor(t){const{event:n}=t,r=gc(n.target);super(t,uB,r)}}bc.activators=[{eventName:"onPointerDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return!n.isPrimary||n.button!==0?!1:(r==null||r({event:n}),!0)}}];const dB={move:{name:"mousemove"},end:{name:"mouseup"}};var kb;(function(e){e[e.RightClick=2]="RightClick"})(kb||(kb={}));class fB extends hw{constructor(t){super(t,dB,gc(t.event.target))}}fB.activators=[{eventName:"onMouseDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return n.button===kb.RightClick?!1:(r==null||r({event:n}),!0)}}];const iy={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class pB extends hw{constructor(t){super(t,iy)}static setup(){return window.addEventListener(iy.move.name,t,{capture:!1,passive:!1}),function(){window.removeEventListener(iy.move.name,t)};function t(){}}}pB.activators=[{eventName:"onTouchStart",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;const{touches:o}=n;return o.length>1?!1:(r==null||r({event:n}),!0)}}];var Ou;(function(e){e[e.Pointer=0]="Pointer",e[e.DraggableRect=1]="DraggableRect"})(Ou||(Ou={}));var uh;(function(e){e[e.TreeOrder=0]="TreeOrder",e[e.ReversedTreeOrder=1]="ReversedTreeOrder"})(uh||(uh={}));function hB(e){let{acceleration:t,activator:n=Ou.Pointer,canScroll:r,draggingRect:o,enabled:i,interval:a=5,order:l=uh.TreeOrder,pointerCoordinates:d,scrollableAncestors:f,scrollableAncestorRects:p,delta:h,threshold:g}=e;const y=gB({delta:h,disabled:!i}),[k,w]=Rz(),b=m.useRef({x:0,y:0}),j=m.useRef({x:0,y:0}),N=m.useMemo(()=>{switch(n){case Ou.Pointer:return d?{top:d.y,bottom:d.y,left:d.x,right:d.x}:null;case Ou.DraggableRect:return o}},[n,o,d]),S=m.useRef(null),C=m.useCallback(()=>{const T=S.current;if(!T)return;const R=b.current.x*j.current.x,$=b.current.y*j.current.y;T.scrollBy(R,$)},[]),D=m.useMemo(()=>l===uh.TreeOrder?[...f].reverse():f,[l,f]);m.useEffect(()=>{if(!i||!f.length||!N){w();return}for(const T of D){if((r==null?void 0:r(T))===!1)continue;const R=f.indexOf(T),$=p[R];if(!$)continue;const{direction:_,speed:U}=nB(T,$,N,t,g);for(const I of["x","y"])y[I][_[I]]||(U[I]=0,_[I]=0);if(U.x>0||U.y>0){w(),S.current=T,k(C,a),b.current=U,j.current=_;return}}b.current={x:0,y:0},j.current={x:0,y:0},w()},[t,C,r,w,i,a,JSON.stringify(N),JSON.stringify(y),k,f,D,p,JSON.stringify(g)])}const mB={x:{[Hn.Backward]:!1,[Hn.Forward]:!1},y:{[Hn.Backward]:!1,[Hn.Forward]:!1}};function gB(e){let{delta:t,disabled:n}=e;const r=ah(t);return _d(o=>{if(n||!r||!o)return mB;const i={x:Math.sign(t.x-r.x),y:Math.sign(t.y-r.y)};return{x:{[Hn.Backward]:o.x[Hn.Backward]||i.x===-1,[Hn.Forward]:o.x[Hn.Forward]||i.x===1},y:{[Hn.Backward]:o.y[Hn.Backward]||i.y===-1,[Hn.Forward]:o.y[Hn.Forward]||i.y===1}}},[n,t,r])}function xB(e,t){const n=t!=null?e.get(t):void 0,r=n?n.node.current:null;return _d(o=>{var i;return t==null?null:(i=r??o)!=null?i:null},[r,t])}function yB(e,t){return m.useMemo(()=>e.reduce((n,r)=>{const{sensor:o}=r,i=o.activators.map(a=>({eventName:a.eventName,handler:t(a.handler,r)}));return[...n,...i]},[]),[e,t])}var td;(function(e){e[e.Always=0]="Always",e[e.BeforeDragging=1]="BeforeDragging",e[e.WhileDragging=2]="WhileDragging"})(td||(td={}));var Sb;(function(e){e.Optimized="optimized"})(Sb||(Sb={}));const Y1=new Map;function bB(e,t){let{dragging:n,dependencies:r,config:o}=t;const[i,a]=m.useState(null),{frequency:l,measure:d,strategy:f}=o,p=m.useRef(e),h=b(),g=Zu(h),y=m.useCallback(function(j){j===void 0&&(j=[]),!g.current&&a(N=>N===null?j:N.concat(j.filter(S=>!N.includes(S))))},[g]),k=m.useRef(null),w=_d(j=>{if(h&&!n)return Y1;if(!j||j===Y1||p.current!==e||i!=null){const N=new Map;for(let S of e){if(!S)continue;if(i&&i.length>0&&!i.includes(S.id)&&S.rect.current){N.set(S.id,S.rect.current);continue}const C=S.node.current,D=C?new pw(d(C),C):null;S.rect.current=D,D&&N.set(S.id,D)}return N}return j},[e,i,n,h,d]);return m.useEffect(()=>{p.current=e},[e]),m.useEffect(()=>{h||y()},[n,h]),m.useEffect(()=>{i&&i.length>0&&a(null)},[JSON.stringify(i)]),m.useEffect(()=>{h||typeof l!="number"||k.current!==null||(k.current=setTimeout(()=>{y(),k.current=null},l))},[l,h,y,...r]),{droppableRects:w,measureDroppableContainers:y,measuringScheduled:i!=null};function b(){switch(f){case td.Always:return!1;case td.BeforeDragging:return n;default:return!n}}}function mw(e,t){return _d(n=>e?n||(typeof t=="function"?t(e):e):null,[t,e])}function vB(e,t){return mw(e,t)}function wB(e){let{callback:t,disabled:n}=e;const r=am(t),o=m.useMemo(()=>{if(n||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:i}=window;return new i(r)},[r,n]);return m.useEffect(()=>()=>o==null?void 0:o.disconnect(),[o]),o}function fm(e){let{callback:t,disabled:n}=e;const r=am(t),o=m.useMemo(()=>{if(n||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:i}=window;return new i(r)},[n]);return m.useEffect(()=>()=>o==null?void 0:o.disconnect(),[o]),o}function jB(e){return new pw(xc(e),e)}function X1(e,t,n){t===void 0&&(t=jB);const[r,o]=m.useState(null);function i(){o(d=>{if(!e)return null;if(e.isConnected===!1){var f;return(f=d??n)!=null?f:null}const p=t(e);return JSON.stringify(d)===JSON.stringify(p)?d:p})}const a=wB({callback(d){if(e)for(const f of d){const{type:p,target:h}=f;if(p==="childList"&&h instanceof HTMLElement&&h.contains(e)){i();break}}}}),l=fm({callback:i});return ys(()=>{i(),e?(l==null||l.observe(e),a==null||a.observe(document.body,{childList:!0,subtree:!0})):(l==null||l.disconnect(),a==null||a.disconnect())},[e]),r}function kB(e){const t=mw(e);return iR(e,t)}const Q1=[];function SB(e){const t=m.useRef(e),n=_d(r=>e?r&&r!==Q1&&e&&t.current&&e.parentNode===t.current.parentNode?r:dm(e):Q1,[e]);return m.useEffect(()=>{t.current=e},[e]),n}function NB(e){const[t,n]=m.useState(null),r=m.useRef(e),o=m.useCallback(i=>{const a=sy(i.target);a&&n(l=>l?(l.set(a,jb(a)),new Map(l)):null)},[]);return m.useEffect(()=>{const i=r.current;if(e!==i){a(i);const l=e.map(d=>{const f=sy(d);return f?(f.addEventListener("scroll",o,{passive:!0}),[f,jb(f)]):null}).filter(d=>d!=null);n(l.length?new Map(l):null),r.current=e}return()=>{a(e),a(i)};function a(l){l.forEach(d=>{const f=sy(d);f==null||f.removeEventListener("scroll",o)})}},[o,e]),m.useMemo(()=>e.length?t?Array.from(t.values()).reduce((i,a)=>Ml(i,a),vs):pR(e):vs,[e,t])}function J1(e,t){t===void 0&&(t=[]);const n=m.useRef(null);return m.useEffect(()=>{n.current=null},t),m.useEffect(()=>{const r=e!==vs;r&&!n.current&&(n.current=e),!r&&n.current&&(n.current=null)},[e]),n.current?ed(e,n.current):vs}function CB(e){m.useEffect(()=>{if(!im)return;const t=e.map(n=>{let{sensor:r}=n;return r.setup==null?void 0:r.setup()});return()=>{for(const n of t)n==null||n()}},e.map(t=>{let{sensor:n}=t;return n}))}function EB(e,t){return m.useMemo(()=>e.reduce((n,r)=>{let{eventName:o,handler:i}=r;return n[o]=a=>{i(a,t)},n},{}),[e,t])}function gR(e){return m.useMemo(()=>e?Jz(e):null,[e])}const Z1=[];function TB(e,t){t===void 0&&(t=xc);const[n]=e,r=gR(n?ir(n):null),[o,i]=m.useState(Z1);function a(){i(()=>e.length?e.map(d=>dR(d)?r:new pw(t(d),d)):Z1)}const l=fm({callback:a});return ys(()=>{l==null||l.disconnect(),a(),e.forEach(d=>l==null?void 0:l.observe(d))},[e]),o}function xR(e){if(!e)return null;if(e.children.length>1)return e;const t=e.children[0];return Pd(t)?t:e}function RB(e){let{measure:t}=e;const[n,r]=m.useState(null),o=m.useCallback(f=>{for(const{target:p}of f)if(Pd(p)){r(h=>{const g=t(p);return h?{...h,width:g.width,height:g.height}:g});break}},[t]),i=fm({callback:o}),a=m.useCallback(f=>{const p=xR(f);i==null||i.disconnect(),p&&(i==null||i.observe(p)),r(p?t(p):null)},[t,i]),[l,d]=ih(a);return m.useMemo(()=>({nodeRef:l,rect:n,setRef:d}),[n,l,d])}const AB=[{sensor:bc,options:{}},{sensor:yc,options:{}}],PB={current:{}},Lp={draggable:{measure:W1},droppable:{measure:W1,strategy:td.WhileDragging,frequency:Sb.Optimized},dragOverlay:{measure:xc}};class Fu extends Map{get(t){var n;return t!=null&&(n=super.get(t))!=null?n:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(t=>{let{disabled:n}=t;return!n})}getNodeFor(t){var n,r;return(n=(r=this.get(t))==null?void 0:r.node.current)!=null?n:void 0}}const _B={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new Fu,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:ch},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:Lp,measureDroppableContainers:ch,windowRect:null,measuringScheduled:!1},yR={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:ch,draggableNodes:new Map,over:null,measureDroppableContainers:ch},$d=m.createContext(yR),bR=m.createContext(_B);function DB(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new Fu}}}function $B(e,t){switch(t.type){case $n.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case $n.DragMove:return e.draggable.active==null?e:{...e,draggable:{...e.draggable,translate:{x:t.coordinates.x-e.draggable.initialCoordinates.x,y:t.coordinates.y-e.draggable.initialCoordinates.y}}};case $n.DragEnd:case $n.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case $n.RegisterDroppable:{const{element:n}=t,{id:r}=n,o=new Fu(e.droppable.containers);return o.set(r,n),{...e,droppable:{...e.droppable,containers:o}}}case $n.SetDroppableDisabled:{const{id:n,key:r,disabled:o}=t,i=e.droppable.containers.get(n);if(!i||r!==i.key)return e;const a=new Fu(e.droppable.containers);return a.set(n,{...i,disabled:o}),{...e,droppable:{...e.droppable,containers:a}}}case $n.UnregisterDroppable:{const{id:n,key:r}=t,o=e.droppable.containers.get(n);if(!o||r!==o.key)return e;const i=new Fu(e.droppable.containers);return i.delete(n),{...e,droppable:{...e.droppable,containers:i}}}default:return e}}function IB(e){let{disabled:t}=e;const{active:n,activatorEvent:r,draggableNodes:o}=m.useContext($d),i=ah(r),a=ah(n==null?void 0:n.id);return m.useEffect(()=>{if(!t&&!r&&i&&a!=null){if(!lm(i)||document.activeElement===i.target)return;const l=o.get(a);if(!l)return;const{activatorNode:d,node:f}=l;if(!d.current&&!f.current)return;requestAnimationFrame(()=>{for(const p of[d.current,f.current]){if(!p)continue;const h=_z(p);if(h){h.focus();break}}})}},[r,t,o,a,i]),null}function vR(e,t){let{transform:n,...r}=t;return e!=null&&e.length?e.reduce((o,i)=>i({transform:o,...r}),n):n}function MB(e){return m.useMemo(()=>({draggable:{...Lp.draggable,...e==null?void 0:e.draggable},droppable:{...Lp.droppable,...e==null?void 0:e.droppable},dragOverlay:{...Lp.dragOverlay,...e==null?void 0:e.dragOverlay}}),[e==null?void 0:e.draggable,e==null?void 0:e.droppable,e==null?void 0:e.dragOverlay])}function LB(e){let{activeNode:t,measure:n,initialRect:r,config:o=!0}=e;const i=m.useRef(!1),{x:a,y:l}=typeof o=="boolean"?{x:o,y:o}:o;ys(()=>{if(!a&&!l||!t){i.current=!1;return}if(i.current||!r)return;const f=t==null?void 0:t.node.current;if(!f||f.isConnected===!1)return;const p=n(f),h=iR(p,r);if(a||(h.x=0),l||(h.y=0),i.current=!0,Math.abs(h.x)>0||Math.abs(h.y)>0){const g=lR(f);g&&g.scrollBy({top:h.y,left:h.x})}},[t,a,l,r,n])}const pm=m.createContext({...vs,scaleX:1,scaleY:1});var hi;(function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized"})(hi||(hi={}));const hm=m.memo(function(t){var n,r,o,i;let{id:a,accessibility:l,autoScroll:d=!0,children:f,sensors:p=AB,collisionDetection:h=qz,measuring:g,modifiers:y,...k}=t;const w=m.useReducer($B,void 0,DB),[b,j]=w,[N,S]=Oz(),[C,D]=m.useState(hi.Uninitialized),T=C===hi.Initialized,{draggable:{active:R,nodes:$,translate:_},droppable:{containers:U}}=b,I=R!=null?$.get(R):null,F=m.useRef({initial:null,translated:null}),M=m.useMemo(()=>{var yt;return R!=null?{id:R,data:(yt=I==null?void 0:I.data)!=null?yt:PB,rect:F}:null},[R,I]),A=m.useRef(null),[L,z]=m.useState(null),[W,V]=m.useState(null),K=Zu(k,Object.values(k)),O=Dd("DndDescribedBy",a),B=m.useMemo(()=>U.getEnabled(),[U]),G=MB(g),{droppableRects:H,measureDroppableContainers:Q,measuringScheduled:te}=bB(B,{dragging:T,dependencies:[_.x,_.y],config:G.droppable}),Z=xB($,R),ae=m.useMemo(()=>W?lh(W):null,[W]),ne=et(),ue=vB(Z,G.draggable.measure);LB({activeNode:R!=null?$.get(R):null,config:ne.layoutShiftCompensation,initialRect:ue,measure:G.draggable.measure});const ye=X1(Z,G.draggable.measure,ue),Ne=X1(Z?Z.parentElement:null),Re=m.useRef({activatorEvent:null,active:null,activeNode:Z,collisionRect:null,collisions:null,droppableRects:H,draggableNodes:$,draggingNode:null,draggingNodeRect:null,droppableContainers:U,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),Se=U.getNodeFor((n=Re.current.over)==null?void 0:n.id),ze=RB({measure:G.dragOverlay.measure}),oe=(r=ze.nodeRef.current)!=null?r:Z,we=T?(o=ze.rect)!=null?o:ye:null,ke=!!(ze.nodeRef.current&&ze.rect),$e=kB(ke?null:ye),Ue=gR(oe?ir(oe):null),nt=SB(T?Se??Z:null),He=TB(nt),at=vR(y,{transform:{x:_.x-$e.x,y:_.y-$e.y,scaleX:1,scaleY:1},activatorEvent:W,active:M,activeNodeRect:ye,containerNodeRect:Ne,draggingNodeRect:we,over:Re.current.over,overlayNodeRect:ze.rect,scrollableAncestors:nt,scrollableAncestorRects:He,windowRect:Ue}),xt=ae?Ml(ae,_):null,lt=NB(nt),ot=J1(lt),le=J1(lt,[ye]),xe=Ml(at,ot),Oe=we?Yz(we,at):null,We=M&&Oe?h({active:M,collisionRect:Oe,droppableRects:H,droppableContainers:B,pointerCoordinates:xt}):null,Ge=oR(We,"id"),[ge,pe]=m.useState(null),se=ke?at:Ml(at,le),je=Kz(se,(i=ge==null?void 0:ge.rect)!=null?i:null,ye),Ae=m.useRef(null),qe=m.useCallback((yt,mt)=>{let{sensor:he,options:Ee}=mt;if(A.current==null)return;const Ye=$.get(A.current);if(!Ye)return;const Nt=yt.nativeEvent,Mt=new he({active:A.current,activeNode:Ye,event:Nt,options:Ee,context:Re,onAbort(Ct){if(!$.get(Ct))return;const{onDragAbort:Ft}=K.current,En={id:Ct};Ft==null||Ft(En),N({type:"onDragAbort",event:En})},onPending(Ct,Cn,Ft,En){if(!$.get(Ct))return;const{onDragPending:ce}=K.current,Te={id:Ct,constraint:Cn,initialCoordinates:Ft,offset:En};ce==null||ce(Te),N({type:"onDragPending",event:Te})},onStart(Ct){const Cn=A.current;if(Cn==null)return;const Ft=$.get(Cn);if(!Ft)return;const{onDragStart:En}=K.current,en={activatorEvent:Nt,active:{id:Cn,data:Ft.data,rect:F}};vo.unstable_batchedUpdates(()=>{En==null||En(en),D(hi.Initializing),j({type:$n.DragStart,initialCoordinates:Ct,active:Cn}),N({type:"onDragStart",event:en}),z(Ae.current),V(Nt)})},onMove(Ct){j({type:$n.DragMove,coordinates:Ct})},onEnd:Nn($n.DragEnd),onCancel:Nn($n.DragCancel)});Ae.current=Mt;function Nn(Ct){return async function(){const{active:Ft,collisions:En,over:en,scrollAdjustedTranslate:ce}=Re.current;let Te=null;if(Ft&&ce){const{cancelDrop:st}=K.current;Te={activatorEvent:Nt,active:Ft,collisions:En,delta:ce,over:en},Ct===$n.DragEnd&&typeof st=="function"&&await Promise.resolve(st(Te))&&(Ct=$n.DragCancel)}A.current=null,vo.unstable_batchedUpdates(()=>{j({type:Ct}),D(hi.Uninitialized),pe(null),z(null),V(null),Ae.current=null;const st=Ct===$n.DragEnd?"onDragEnd":"onDragCancel";if(Te){const Tn=K.current[st];Tn==null||Tn(Te),N({type:st,event:Te})}})}}},[$]),X=m.useCallback((yt,mt)=>(he,Ee)=>{const Ye=he.nativeEvent,Nt=$.get(Ee);if(A.current!==null||!Nt||Ye.dndKit||Ye.defaultPrevented)return;const Mt={active:Nt};yt(he,mt.options,Mt)===!0&&(Ye.dndKit={capturedBy:mt.sensor},A.current=Ee,qe(he,mt))},[$,qe]),ve=yB(p,X);CB(p),ys(()=>{ye&&C===hi.Initializing&&D(hi.Initialized)},[ye,C]),m.useEffect(()=>{const{onDragMove:yt}=K.current,{active:mt,activatorEvent:he,collisions:Ee,over:Ye}=Re.current;if(!mt||!he)return;const Nt={active:mt,activatorEvent:he,collisions:Ee,delta:{x:xe.x,y:xe.y},over:Ye};vo.unstable_batchedUpdates(()=>{yt==null||yt(Nt),N({type:"onDragMove",event:Nt})})},[xe.x,xe.y]),m.useEffect(()=>{const{active:yt,activatorEvent:mt,collisions:he,droppableContainers:Ee,scrollAdjustedTranslate:Ye}=Re.current;if(!yt||A.current==null||!mt||!Ye)return;const{onDragOver:Nt}=K.current,Mt=Ee.get(Ge),Nn=Mt&&Mt.rect.current?{id:Mt.id,rect:Mt.rect.current,data:Mt.data,disabled:Mt.disabled}:null,Ct={active:yt,activatorEvent:mt,collisions:he,delta:{x:Ye.x,y:Ye.y},over:Nn};vo.unstable_batchedUpdates(()=>{pe(Nn),Nt==null||Nt(Ct),N({type:"onDragOver",event:Ct})})},[Ge]),ys(()=>{Re.current={activatorEvent:W,active:M,activeNode:Z,collisionRect:Oe,collisions:We,droppableRects:H,draggableNodes:$,draggingNode:oe,draggingNodeRect:we,droppableContainers:U,over:ge,scrollableAncestors:nt,scrollAdjustedTranslate:xe},F.current={initial:we,translated:Oe}},[M,Z,We,Oe,$,oe,we,H,U,ge,nt,xe]),hB({...ne,delta:_,draggingRect:Oe,pointerCoordinates:xt,scrollableAncestors:nt,scrollableAncestorRects:He});const Ve=m.useMemo(()=>({active:M,activeNode:Z,activeNodeRect:ye,activatorEvent:W,collisions:We,containerNodeRect:Ne,dragOverlay:ze,draggableNodes:$,droppableContainers:U,droppableRects:H,over:ge,measureDroppableContainers:Q,scrollableAncestors:nt,scrollableAncestorRects:He,measuringConfiguration:G,measuringScheduled:te,windowRect:Ue}),[M,Z,ye,W,We,Ne,ze,$,U,H,ge,Q,nt,He,G,te,Ue]),ft=m.useMemo(()=>({activatorEvent:W,activators:ve,active:M,activeNodeRect:ye,ariaDescribedById:{draggable:O},dispatch:j,draggableNodes:$,over:ge,measureDroppableContainers:Q}),[W,ve,M,ye,j,O,$,ge,Q]);return $t.createElement(nR.Provider,{value:S},$t.createElement($d.Provider,{value:ft},$t.createElement(bR.Provider,{value:Ve},$t.createElement(pm.Provider,{value:je},f)),$t.createElement(IB,{disabled:(l==null?void 0:l.restoreFocus)===!1})),$t.createElement(Bz,{...l,hiddenTextDescribedById:O}));function et(){const yt=(L==null?void 0:L.autoScrollEnabled)===!1,mt=typeof d=="object"?d.enabled===!1:d===!1,he=T&&!yt&&!mt;return typeof d=="object"?{...d,enabled:he}:{enabled:he}}}),OB=m.createContext(null),eS="button",FB="Draggable";function zB(e){let{id:t,data:n,disabled:r=!1,attributes:o}=e;const i=Dd(FB),{activators:a,activatorEvent:l,active:d,activeNodeRect:f,ariaDescribedById:p,draggableNodes:h,over:g}=m.useContext($d),{role:y=eS,roleDescription:k="draggable",tabIndex:w=0}=o??{},b=(d==null?void 0:d.id)===t,j=m.useContext(b?pm:OB),[N,S]=ih(),[C,D]=ih(),T=EB(a,t),R=Zu(n);ys(()=>(h.set(t,{id:t,key:i,node:N,activatorNode:C,data:R}),()=>{const _=h.get(t);_&&_.key===i&&h.delete(t)}),[h,t]);const $=m.useMemo(()=>({role:y,tabIndex:w,"aria-disabled":r,"aria-pressed":b&&y===eS?!0:void 0,"aria-roledescription":k,"aria-describedby":p.draggable}),[r,y,w,b,k,p.draggable]);return{active:d,activatorEvent:l,activeNodeRect:f,attributes:$,isDragging:b,listeners:r?void 0:T,node:N,over:g,setNodeRef:S,setActivatorNodeRef:D,transform:j}}function wR(){return m.useContext(bR)}const BB="Droppable",UB={timeout:25};function HB(e){let{data:t,disabled:n=!1,id:r,resizeObserverConfig:o}=e;const i=Dd(BB),{active:a,dispatch:l,over:d,measureDroppableContainers:f}=m.useContext($d),p=m.useRef({disabled:n}),h=m.useRef(!1),g=m.useRef(null),y=m.useRef(null),{disabled:k,updateMeasurementsFor:w,timeout:b}={...UB,...o},j=Zu(w??r),N=m.useCallback(()=>{if(!h.current){h.current=!0;return}y.current!=null&&clearTimeout(y.current),y.current=setTimeout(()=>{f(Array.isArray(j.current)?j.current:[j.current]),y.current=null},b)},[b]),S=fm({callback:N,disabled:k||!a}),C=m.useCallback(($,_)=>{S&&(_&&(S.unobserve(_),h.current=!1),$&&S.observe($))},[S]),[D,T]=ih(C),R=Zu(t);return m.useEffect(()=>{!S||!D.current||(S.disconnect(),h.current=!1,S.observe(D.current))},[D,S]),m.useEffect(()=>(l({type:$n.RegisterDroppable,element:{id:r,key:i,disabled:n,node:D,rect:g,data:R}}),()=>l({type:$n.UnregisterDroppable,key:i,id:r})),[r]),m.useEffect(()=>{n!==p.current.disabled&&(l({type:$n.SetDroppableDisabled,id:r,key:i,disabled:n}),p.current.disabled=n)},[r,i,n,l]),{active:a,rect:g,isOver:(d==null?void 0:d.id)===r,node:D,over:d,setNodeRef:T}}function VB(e){let{animation:t,children:n}=e;const[r,o]=m.useState(null),[i,a]=m.useState(null),l=ah(n);return!n&&!r&&l&&o(l),ys(()=>{if(!i)return;const d=r==null?void 0:r.key,f=r==null?void 0:r.props.id;if(d==null||f==null){o(null);return}Promise.resolve(t(f,i)).then(()=>{o(null)})},[t,r,i]),$t.createElement($t.Fragment,null,n,r?m.cloneElement(r,{ref:a}):null)}const WB={x:0,y:0,scaleX:1,scaleY:1};function qB(e){let{children:t}=e;return $t.createElement($d.Provider,{value:yR},$t.createElement(pm.Provider,{value:WB},t))}const KB={position:"fixed",touchAction:"none"},GB=e=>lm(e)?"transform 250ms ease":void 0,YB=m.forwardRef((e,t)=>{let{as:n,activatorEvent:r,adjustScale:o,children:i,className:a,rect:l,style:d,transform:f,transition:p=GB}=e;if(!l)return null;const h=o?f:{...f,scaleX:1,scaleY:1},g={...KB,width:l.width,height:l.height,top:l.top,left:l.left,transform:bs.Transform.toString(h),transformOrigin:o&&r?Uz(r,l):void 0,transition:typeof p=="function"?p(r):p,...d};return $t.createElement(n,{className:a,style:g,ref:t},i)}),XB=e=>t=>{let{active:n,dragOverlay:r}=t;const o={},{styles:i,className:a}=e;if(i!=null&&i.active)for(const[l,d]of Object.entries(i.active))d!==void 0&&(o[l]=n.node.style.getPropertyValue(l),n.node.style.setProperty(l,d));if(i!=null&&i.dragOverlay)for(const[l,d]of Object.entries(i.dragOverlay))d!==void 0&&r.node.style.setProperty(l,d);return a!=null&&a.active&&n.node.classList.add(a.active),a!=null&&a.dragOverlay&&r.node.classList.add(a.dragOverlay),function(){for(const[d,f]of Object.entries(o))n.node.style.setProperty(d,f);a!=null&&a.active&&n.node.classList.remove(a.active)}},QB=e=>{let{transform:{initial:t,final:n}}=e;return[{transform:bs.Transform.toString(t)},{transform:bs.Transform.toString(n)}]},JB={duration:250,easing:"ease",keyframes:QB,sideEffects:XB({styles:{active:{opacity:"0"}}})};function ZB(e){let{config:t,draggableNodes:n,droppableContainers:r,measuringConfiguration:o}=e;return am((i,a)=>{if(t===null)return;const l=n.get(i);if(!l)return;const d=l.node.current;if(!d)return;const f=xR(a);if(!f)return;const{transform:p}=ir(a).getComputedStyle(a),h=aR(p);if(!h)return;const g=typeof t=="function"?t:e8(t);return hR(d,o.draggable.measure),g({active:{id:i,data:l.data,node:d,rect:o.draggable.measure(d)},draggableNodes:n,dragOverlay:{node:a,rect:o.dragOverlay.measure(f)},droppableContainers:r,measuringConfiguration:o,transform:h})})}function e8(e){const{duration:t,easing:n,sideEffects:r,keyframes:o}={...JB,...e};return i=>{let{active:a,dragOverlay:l,transform:d,...f}=i;if(!t)return;const p={x:l.rect.left-a.rect.left,y:l.rect.top-a.rect.top},h={scaleX:d.scaleX!==1?a.rect.width*d.scaleX/l.rect.width:1,scaleY:d.scaleY!==1?a.rect.height*d.scaleY/l.rect.height:1},g={x:d.x-p.x,y:d.y-p.y,...h},y=o({...f,active:a,dragOverlay:l,transform:{initial:d,final:g}}),[k]=y,w=y[y.length-1];if(JSON.stringify(k)===JSON.stringify(w))return;const b=r==null?void 0:r({active:a,dragOverlay:l,...f}),j=l.node.animate(y,{duration:t,easing:n,fill:"forwards"});return new Promise(N=>{j.onfinish=()=>{b==null||b(),N()}})}}let tS=0;function t8(e){return m.useMemo(()=>{if(e!=null)return tS++,tS},[e])}const n8=$t.memo(e=>{let{adjustScale:t=!1,children:n,dropAnimation:r,style:o,transition:i,modifiers:a,wrapperElement:l="div",className:d,zIndex:f=999}=e;const{activatorEvent:p,active:h,activeNodeRect:g,containerNodeRect:y,draggableNodes:k,droppableContainers:w,dragOverlay:b,over:j,measuringConfiguration:N,scrollableAncestors:S,scrollableAncestorRects:C,windowRect:D}=wR(),T=m.useContext(pm),R=t8(h==null?void 0:h.id),$=vR(a,{activatorEvent:p,active:h,activeNodeRect:g,containerNodeRect:y,draggingNodeRect:b.rect,over:j,overlayNodeRect:b.rect,scrollableAncestors:S,scrollableAncestorRects:C,transform:T,windowRect:D}),_=mw(g),U=ZB({config:r,draggableNodes:k,droppableContainers:w,measuringConfiguration:N}),I=_?b.setRef:void 0;return $t.createElement(qB,null,$t.createElement(VB,{animation:U},h&&R?$t.createElement(YB,{key:R,id:h.id,ref:I,as:l,activatorEvent:p,adjustScale:t,className:d,transition:i,rect:_,style:{zIndex:f,...o},transform:$},n):null))});function vc(e,t,n){const r=e.slice();return r.splice(n<0?r.length+n:n,0,r.splice(t,1)[0]),r}function r8(e,t){return e.reduce((n,r,o)=>{const i=t.get(r);return i&&(n[o]=i),n},Array(e.length))}function sp(e){return e!==null&&e>=0}function s8(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function o8(e){return typeof e=="boolean"?{draggable:e,droppable:e}:e}const gw=e=>{let{rects:t,activeIndex:n,overIndex:r,index:o}=e;const i=vc(t,r,n),a=t[o],l=i[o];return!l||!a?null:{x:l.left-a.left,y:l.top-a.top,scaleX:l.width/a.width,scaleY:l.height/a.height}},op={scaleX:1,scaleY:1},xw=e=>{var t;let{activeIndex:n,activeNodeRect:r,index:o,rects:i,overIndex:a}=e;const l=(t=i[n])!=null?t:r;if(!l)return null;if(o===n){const f=i[a];return f?{x:0,y:n<a?f.top+f.height-(l.top+l.height):f.top-l.top,...op}:null}const d=i8(i,o,n);return o>n&&o<=a?{x:0,y:-l.height-d,...op}:o<n&&o>=a?{x:0,y:l.height+d,...op}:{x:0,y:0,...op}};function i8(e,t,n){const r=e[t],o=e[t-1],i=e[t+1];return r?n<t?o?r.top-(o.top+o.height):i?i.top-(r.top+r.height):0:i?i.top-(r.top+r.height):o?r.top-(o.top+o.height):0:0}const jR="Sortable",kR=$t.createContext({activeIndex:-1,containerId:jR,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:gw,disabled:{draggable:!1,droppable:!1}});function mm(e){let{children:t,id:n,items:r,strategy:o=gw,disabled:i=!1}=e;const{active:a,dragOverlay:l,droppableRects:d,over:f,measureDroppableContainers:p}=wR(),h=Dd(jR,n),g=l.rect!==null,y=m.useMemo(()=>r.map(T=>typeof T=="object"&&"id"in T?T.id:T),[r]),k=a!=null,w=a?y.indexOf(a.id):-1,b=f?y.indexOf(f.id):-1,j=m.useRef(y),N=!s8(y,j.current),S=b!==-1&&w===-1||N,C=o8(i);ys(()=>{N&&k&&p(y)},[N,y,k,p]),m.useEffect(()=>{j.current=y},[y]);const D=m.useMemo(()=>({activeIndex:w,containerId:h,disabled:C,disableTransforms:S,items:y,overIndex:b,useDragOverlay:g,sortedRects:r8(y,d),strategy:o}),[w,h,C.draggable,C.droppable,S,y,b,d,g,o]);return $t.createElement(kR.Provider,{value:D},t)}const a8=e=>{let{id:t,items:n,activeIndex:r,overIndex:o}=e;return vc(n,r,o).indexOf(t)},l8=e=>{let{containerId:t,isSorting:n,wasDragging:r,index:o,items:i,newIndex:a,previousItems:l,previousContainerId:d,transition:f}=e;return!f||!r||l!==i&&o===a?!1:n?!0:a!==o&&t===d},c8={duration:200,easing:"ease"},SR="transform",u8=bs.Transition.toString({property:SR,duration:0,easing:"linear"}),d8={roleDescription:"sortable"};function f8(e){let{disabled:t,index:n,node:r,rect:o}=e;const[i,a]=m.useState(null),l=m.useRef(n);return ys(()=>{if(!t&&n!==l.current&&r.current){const d=o.current;if(d){const f=xc(r.current,{ignoreTransform:!0}),p={x:d.left-f.left,y:d.top-f.top,scaleX:d.width/f.width,scaleY:d.height/f.height};(p.x||p.y)&&a(p)}}n!==l.current&&(l.current=n)},[t,n,r,o]),m.useEffect(()=>{i&&a(null)},[i]),i}function gm(e){let{animateLayoutChanges:t=l8,attributes:n,disabled:r,data:o,getNewIndex:i=a8,id:a,strategy:l,resizeObserverConfig:d,transition:f=c8}=e;const{items:p,containerId:h,activeIndex:g,disabled:y,disableTransforms:k,sortedRects:w,overIndex:b,useDragOverlay:j,strategy:N}=m.useContext(kR),S=p8(r,y),C=p.indexOf(a),D=m.useMemo(()=>({sortable:{containerId:h,index:C,items:p},...o}),[h,o,C,p]),T=m.useMemo(()=>p.slice(p.indexOf(a)),[p,a]),{rect:R,node:$,isOver:_,setNodeRef:U}=HB({id:a,data:D,disabled:S.droppable,resizeObserverConfig:{updateMeasurementsFor:T,...d}}),{active:I,activatorEvent:F,activeNodeRect:M,attributes:A,setNodeRef:L,listeners:z,isDragging:W,over:V,setActivatorNodeRef:K,transform:O}=zB({id:a,data:D,attributes:{...d8,...n},disabled:S.draggable}),B=Tz(U,L),G=!!I,H=G&&!k&&sp(g)&&sp(b),Q=!j&&W,te=Q&&H?O:null,ae=H?te??(l??N)({rects:w,activeNodeRect:M,activeIndex:g,overIndex:b,index:C}):null,ne=sp(g)&&sp(b)?i({id:a,items:p,activeIndex:g,overIndex:b}):C,ue=I==null?void 0:I.id,ye=m.useRef({activeId:ue,items:p,newIndex:ne,containerId:h}),Ne=p!==ye.current.items,Re=t({active:I,containerId:h,isDragging:W,isSorting:G,id:a,index:C,items:p,newIndex:ye.current.newIndex,previousItems:ye.current.items,previousContainerId:ye.current.containerId,transition:f,wasDragging:ye.current.activeId!=null}),Se=f8({disabled:!Re,index:C,node:$,rect:R});return m.useEffect(()=>{G&&ye.current.newIndex!==ne&&(ye.current.newIndex=ne),h!==ye.current.containerId&&(ye.current.containerId=h),p!==ye.current.items&&(ye.current.items=p)},[G,ne,h,p]),m.useEffect(()=>{if(ue===ye.current.activeId)return;if(ue!=null&&ye.current.activeId==null){ye.current.activeId=ue;return}const oe=setTimeout(()=>{ye.current.activeId=ue},50);return()=>clearTimeout(oe)},[ue]),{active:I,activeIndex:g,attributes:A,data:D,rect:R,index:C,newIndex:ne,items:p,isOver:_,isSorting:G,isDragging:W,listeners:z,node:$,overIndex:b,over:V,setNodeRef:B,setActivatorNodeRef:K,setDroppableNodeRef:U,setDraggableNodeRef:L,transform:Se??ae,transition:ze()};function ze(){if(Se||Ne&&ye.current.newIndex===C)return u8;if(!(Q&&!lm(F)||!f)&&(G||Re))return bs.Transition.toString({...f,property:SR})}}function p8(e,t){var n,r;return typeof e=="boolean"?{draggable:e,droppable:!1}:{draggable:(n=e==null?void 0:e.draggable)!=null?n:t.draggable,droppable:(r=e==null?void 0:e.droppable)!=null?r:t.droppable}}function dh(e){if(!e)return!1;const t=e.data.current;return!!(t&&"sortable"in t&&typeof t.sortable=="object"&&"containerId"in t.sortable&&"items"in t.sortable&&"index"in t.sortable)}const h8=[Et.Down,Et.Right,Et.Up,Et.Left],NR=(e,t)=>{let{context:{active:n,collisionRect:r,droppableRects:o,droppableContainers:i,over:a,scrollableAncestors:l}}=t;if(h8.includes(e.code)){if(e.preventDefault(),!n||!r)return;const d=[];i.getEnabled().forEach(h=>{if(!h||h!=null&&h.disabled)return;const g=o.get(h.id);if(g)switch(e.code){case Et.Down:r.top<g.top&&d.push(h);break;case Et.Up:r.top>g.top&&d.push(h);break;case Et.Left:r.left>g.left&&d.push(h);break;case Et.Right:r.left<g.left&&d.push(h);break}});const f=Vz({collisionRect:r,droppableRects:o,droppableContainers:d});let p=oR(f,"id");if(p===(a==null?void 0:a.id)&&f.length>1&&(p=f[1].id),p!=null){const h=i.get(n.id),g=i.get(p),y=g?o.get(g.id):null,k=g==null?void 0:g.node.current;if(k&&y&&h&&g){const b=dm(k).some((T,R)=>l[R]!==T),j=CR(h,g),N=m8(h,g),S=b||!j?{x:0,y:0}:{x:N?r.width-y.width:0,y:N?r.height-y.height:0},C={x:y.left,y:y.top};return S.x&&S.y?C:ed(C,S)}}}};function CR(e,t){return!dh(e)||!dh(t)?!1:e.data.current.sortable.containerId===t.data.current.sortable.containerId}function m8(e,t){return!dh(e)||!dh(t)||!CR(e,t)?!1:e.data.current.sortable.index<t.data.current.sortable.index}function jt({label:e="Loading dashboard data…"}){return s.jsx("div",{className:"flex min-h-[240px] items-center justify-center",children:s.jsx("div",{className:"chrome-card !px-4 !py-3",children:s.jsx("p",{className:"text-sm text-muted-foreground",children:e})})})}function Rt({title:e="Something went wrong",error:t,action:n}){return s.jsx("div",{className:"rounded-lg border border-error-foreground/30 bg-error px-4 py-5",children:s.jsxs("div",{className:"space-y-2",children:[s.jsx("h3",{className:"text-lg font-semibold text-error-foreground",children:e}),s.jsx("p",{className:"text-sm leading-6 text-error-foreground/90",children:t}),n?s.jsx("div",{className:"pt-2",children:n}):null]})})}function Op({command:e,description:t,example:n}){return s.jsxs("div",{className:"rounded-lg border border-border/70 bg-code px-3 py-3 text-code-foreground shadow-sm",children:[s.jsx("code",{className:"block overflow-x-auto font-mono text-sm",children:e}),t?s.jsx("p",{className:"mt-2 text-sm text-code-foreground/80",children:t}):null,n?s.jsx("p",{className:"mt-2 font-mono text-xs text-code-foreground/60",children:n}):null]})}function Qe({title:e,description:t,children:n,className:r,actions:o}){return s.jsxs("section",{className:Ce("surface-panel space-y-3",r),children:[e||o?s.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[s.jsxs("div",{className:"space-y-1",children:[e?s.jsx("h2",{className:"text-lg font-semibold text-foreground",children:e}):null,t?s.jsx("p",{className:"text-sm text-muted-foreground",children:t}):null]}),o]}):null,n]})}function g8({help:e,compact:t=!1}){const n=t?(e==null?void 0:e.firstProjectChecklist.slice(0,3))??[]:(e==null?void 0:e.firstProjectChecklist)??[];return s.jsx(Qe,{title:t?"Getting Started Refresher":"Getting Started",description:t?"A fast reminder of the real flow for creating and running work in Syntaur.":"A first-run checklist that maps to the current CLI and dashboard flow.",actions:s.jsx(Ie,{className:"text-sm font-semibold text-primary hover:underline",to:"/help",children:"Open full help"}),children:s.jsx("div",{className:"space-y-3",children:n.map((r,o)=>s.jsx("div",{className:"rounded-md border border-border/60 bg-background/80 p-3",children:s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx("span",{className:"inline-flex h-5 w-5 items-center justify-center rounded-full bg-foreground text-xs font-semibold text-background",children:o+1}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("h3",{className:"font-semibold text-foreground",children:r.title}),s.jsx("p",{className:"text-sm leading-6 text-muted-foreground",children:r.detail}),r.command?s.jsx(Op,{command:r.command.command,example:r.command.example}):null]})]})},r.title))})})}const ay={review:"{total} items ready for your review","review.singular":"Review {title}",ready_to_implement:"{total} plans ready to implement — start with {title}","ready_to_implement.singular":"Start implementing {title}",ready_for_planning:"{total} assignments ready to plan — start with {title}","ready_for_planning.singular":"Plan {title}",in_progress:"Resume {title} ({total} in progress)","in_progress.singular":"Resume {title}",draft:"Shape your {total} drafts — start with {title}","draft.singular":"Shape {title}",blocked:"Unblock {title} ({total} blocked)","blocked.singular":"Unblock {title}",stale:"Triage {total} stale items","stale.singular":"Triage {title} — sitting stale",clean:"You’re all clear. Nothing needs you right now."},da={emptyStateCleanTitle:"You’re all clear",emptyStateCleanCTA:"Browse projects",recentSessionsEmptyTitle:"No recent sessions",recentSessionsEmptyHint:"Use /grab-assignment or `syntaur track-session` to register one.",recentSessionsCopyPathLabel:"Copy path",recentSessionsCopyPathDisabled:"Session has no path",recentSessionsCopyFallbackHint:"Press ⌘C to copy"};function x8(e,t){return e.replace(/\{(\w+)\}/g,(n,r)=>String(t[r]??`{${r}}`))}function y8({hero:e,itemsById:t}){const n=pn();if(e.kind==="clean")return s.jsxs("section",{"aria-labelledby":"overview-hero-title",className:"rounded-xl border border-border/60 bg-background/60 p-6 shadow-sm",children:[s.jsx("p",{className:"eyebrow",children:da.emptyStateCleanTitle}),s.jsx("h2",{id:"overview-hero-title",className:"mt-2 text-2xl font-semibold tracking-tight text-foreground",children:ay.clean}),s.jsx("p",{className:"mt-3 text-sm text-muted-foreground",children:"When work shows up — a draft, a review, a stale row — it’ll surface here."}),s.jsx("div",{className:"mt-4",children:s.jsx(Ie,{to:`${n}/projects`,className:"shell-action shell-action--cta",children:da.emptyStateCleanCTA})})]});const r=e.itemId?t[e.itemId]:void 0,o=(r==null?void 0:r.assignmentTitle)??"",i=ay[e.copyKey]??ay[e.kind],a=x8(i,{total:e.total,title:o}),l=r?b8(r,n):`${n}/assignments`;return s.jsxs("section",{"aria-labelledby":"overview-hero-title",className:"rounded-xl border border-primary/20 bg-primary/5 p-6 shadow-sm",children:[s.jsx("p",{className:"eyebrow",children:"Top priority"}),s.jsx("h2",{id:"overview-hero-title",className:"mt-2 text-2xl font-semibold tracking-tight text-foreground",children:a}),r?s.jsxs("p",{className:"mt-2 text-sm text-muted-foreground",children:["In ",s.jsx("span",{className:"font-medium text-foreground",children:r.projectTitle??"Standalone"})," ","· status ",s.jsx("span",{className:"font-medium text-foreground",children:r.status})]}):null,s.jsx("div",{className:"mt-4",children:s.jsxs(Ie,{to:l,className:"shell-action shell-action--cta",children:["Open ",o||"assignment"]})})]})}function b8(e,t){return e.projectSlug?`${t}${e.href}`:e.href}const ly=["title","status","priority","assignee","dependencies","created","updated"],nd=24,ER=60;function v8(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;const t=e;return Number.isInteger(t.w)&&t.w>=1&&t.w<=nd&&Number.isInteger(t.h)&&t.h>=1&&t.h<=ER}const w8={status:"all",priority:"all",assignee:"all",project:"all",activity:"all"},nS="2026-05-21T00:00:00Z";function cy(e,t,n){return{id:e,name:t,workspace:null,entityType:"assignment",config:{viewMode:"list",filters:{...w8,...n},sortField:"updated",sortDirection:"desc",listSectionVisibility:{collapsed:[]},kanbanColumnVisibility:{hidden:[]},tableColumnVisibility:{hidden:[]}},createdAt:nS,updatedAt:nS}}const xi={version:1,views:[cy("default-recently-updated","Recently updated",{}),cy("default-high-priority","High priority",{priority:"high"}),cy("default-stale","Stale",{activity:"stale"})],dashboard:{version:1,slots:[{id:"slot-0",widget:{kind:"agent-sessions"}},{id:"slot-1",widget:{kind:"saved-view",viewId:"default-recently-updated"}},{id:"slot-2",widget:{kind:"saved-view",viewId:"default-high-priority"}},{id:"slot-3",widget:{kind:"saved-view",viewId:"default-stale"}},{id:"slot-4",widget:{kind:"inventories"}}]}};function TR(e,t){const n=Ke(e.filters.project),r=n.length===0||n.length===1&&n[0]===t,o=e.filters.activity,i=typeof e.filters.search=="string"&&e.filters.search.trim().length>0,a=e.filters.query,l=typeof a=="string"&&a.trim().length>0&&$u(a)===null;return r&&(!o||o==="all")&&!i&&!l}function RR(e,t){switch(t.kind){case"global":return e.workspace===null;case"workspace":return e.workspace===t.workspace||e.workspace===null;case"project":return e.workspace===t.workspace||e.workspace===null?TR(e.config,t.slug):!1}}const AR=`syntaur.savedViews.cache.v${xi.version}`;let Ll=j8(),Zi=null,yw=null;const Nb=new Set,fh=new Set;let PR=0;function _R(){return++PR}function Cb(e){return e===PR}function j8(){if(typeof window>"u"||!window.localStorage)return null;try{const e=window.localStorage.getItem(AR);if(!e)return null;const t=JSON.parse(e);return t.version!==xi.version?null:t}catch{return null}}function k8(e){if(!(typeof window>"u"||!window.localStorage))try{window.localStorage.setItem(AR,JSON.stringify(e))}catch{}}function DR(e){Ll=e,yw=null,k8(e);for(const t of Nb)t(e);for(const t of fh)t(null)}function S8(e){yw=e;for(const t of fh)t(e)}function $R(e){if(!e||typeof e!="object")return xi;const t=e;return t.version!==xi.version||!Array.isArray(t.views)||!t.dashboard?xi:t}function rS(){if(Zi)return Zi;const e=_R();return Zi=fetch("/api/saved-views").then(t=>{if(!t.ok)throw new Error(`HTTP ${t.status}`);return t.json()}).then(t=>{const n=$R(t);return Cb(e)&&DR(n),Zi=null,Ll??n}).catch(t=>{const n=t instanceof Error?t:new Error(String(t));return Cb(e)&&S8(n),Zi=null,Ll??xi}),Zi}function bw(){const[e,t]=m.useState(()=>Ll??xi),[n,r]=m.useState(()=>Ll===null),[o,i]=m.useState(!1),[a,l]=m.useState(()=>yw);return m.useEffect(()=>{let f=!1;Ll===null&&r(!0),rS().then(g=>{f||(t(g),r(!1),i(!0))});const p=g=>{f||(t(g),r(!1),i(!0),l(null))},h=g=>{f||(l(g),r(!1),i(!0))};return Nb.add(p),fh.add(h),()=>{f=!0,Nb.delete(p),fh.delete(h)}},[]),{file:e,loading:n,ready:o,error:a,refetch:()=>{Zi=null,r(!0),l(null),i(!1),rS()}}}function Id(){const{file:e,loading:t}=bw();return{views:e.views,loading:t}}function IR(){const{file:e,loading:t}=bw();return{layout:e.dashboard,loading:t}}function wi(e){const{file:t,loading:n,ready:r,error:o,refetch:i}=bw();return e?{view:t.views.find(l=>l.id===e)??null,loading:n,ready:r,error:o,refetch:i}:{view:null,loading:!1,ready:!0,error:null,refetch:i}}async function xm(e,t,n){const r=_R(),o=await fetch(t,{method:e,headers:n!==void 0?{"Content-Type":"application/json"}:void 0,body:n!==void 0?JSON.stringify(n):void 0});if(!o.ok){const a=await o.json().catch(()=>({error:`HTTP ${o.status}`}));throw new Error(a.error??`HTTP ${o.status}`)}const i=$R(await o.json());return Cb(r)&&DR(i),i}function Gl(e){return xm("POST","/api/saved-views",e)}function ph(e,t){return xm("PATCH",`/api/saved-views/${encodeURIComponent(e)}`,t)}function N8(e){return xm("DELETE",`/api/saved-views/${encodeURIComponent(e)}`)}function Eb(e){return xm("PUT","/api/dashboard",{slots:e})}const C8=["top","right","bottom","left"],ji=Math.min,$r=Math.max,hh=Math.round,ip=Math.floor,Ys=e=>({x:e,y:e}),E8={left:"right",right:"left",bottom:"top",top:"bottom"};function Tb(e,t,n){return $r(e,ji(t,n))}function Co(e,t){return typeof e=="function"?e(t):e}function Eo(e){return e.split("-")[0]}function wc(e){return e.split("-")[1]}function vw(e){return e==="x"?"y":"x"}function ww(e){return e==="y"?"height":"width"}function Ws(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function jw(e){return vw(Ws(e))}function T8(e,t,n){n===void 0&&(n=!1);const r=wc(e),o=jw(e),i=ww(o);let a=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[i]>t.floating[i]&&(a=mh(a)),[a,mh(a)]}function R8(e){const t=mh(e);return[Rb(e),t,Rb(t)]}function Rb(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const sS=["left","right"],oS=["right","left"],A8=["top","bottom"],P8=["bottom","top"];function _8(e,t,n){switch(e){case"top":case"bottom":return n?t?oS:sS:t?sS:oS;case"left":case"right":return t?A8:P8;default:return[]}}function D8(e,t,n,r){const o=wc(e);let i=_8(Eo(e),n==="start",r);return o&&(i=i.map(a=>a+"-"+o),t&&(i=i.concat(i.map(Rb)))),i}function mh(e){const t=Eo(e);return E8[t]+e.slice(t.length)}function $8(e){return{top:0,right:0,bottom:0,left:0,...e}}function MR(e){return typeof e!="number"?$8(e):{top:e,right:e,bottom:e,left:e}}function gh(e){const{x:t,y:n,width:r,height:o}=e;return{width:r,height:o,top:n,left:t,right:t+r,bottom:n+o,x:t,y:n}}function iS(e,t,n){let{reference:r,floating:o}=e;const i=Ws(t),a=jw(t),l=ww(a),d=Eo(t),f=i==="y",p=r.x+r.width/2-o.width/2,h=r.y+r.height/2-o.height/2,g=r[l]/2-o[l]/2;let y;switch(d){case"top":y={x:p,y:r.y-o.height};break;case"bottom":y={x:p,y:r.y+r.height};break;case"right":y={x:r.x+r.width,y:h};break;case"left":y={x:r.x-o.width,y:h};break;default:y={x:r.x,y:r.y}}switch(wc(t)){case"start":y[a]-=g*(n&&f?-1:1);break;case"end":y[a]+=g*(n&&f?-1:1);break}return y}async function I8(e,t){var n;t===void 0&&(t={});const{x:r,y:o,platform:i,rects:a,elements:l,strategy:d}=e,{boundary:f="clippingAncestors",rootBoundary:p="viewport",elementContext:h="floating",altBoundary:g=!1,padding:y=0}=Co(t,e),k=MR(y),b=l[g?h==="floating"?"reference":"floating":h],j=gh(await i.getClippingRect({element:(n=await(i.isElement==null?void 0:i.isElement(b)))==null||n?b:b.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(l.floating)),boundary:f,rootBoundary:p,strategy:d})),N=h==="floating"?{x:r,y:o,width:a.floating.width,height:a.floating.height}:a.reference,S=await(i.getOffsetParent==null?void 0:i.getOffsetParent(l.floating)),C=await(i.isElement==null?void 0:i.isElement(S))?await(i.getScale==null?void 0:i.getScale(S))||{x:1,y:1}:{x:1,y:1},D=gh(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:N,offsetParent:S,strategy:d}):N);return{top:(j.top-D.top+k.top)/C.y,bottom:(D.bottom-j.bottom+k.bottom)/C.y,left:(j.left-D.left+k.left)/C.x,right:(D.right-j.right+k.right)/C.x}}const M8=50,L8=async(e,t,n)=>{const{placement:r="bottom",strategy:o="absolute",middleware:i=[],platform:a}=n,l=a.detectOverflow?a:{...a,detectOverflow:I8},d=await(a.isRTL==null?void 0:a.isRTL(t));let f=await a.getElementRects({reference:e,floating:t,strategy:o}),{x:p,y:h}=iS(f,r,d),g=r,y=0;const k={};for(let w=0;w<i.length;w++){const b=i[w];if(!b)continue;const{name:j,fn:N}=b,{x:S,y:C,data:D,reset:T}=await N({x:p,y:h,initialPlacement:r,placement:g,strategy:o,middlewareData:k,rects:f,platform:l,elements:{reference:e,floating:t}});p=S??p,h=C??h,k[j]={...k[j],...D},T&&y<M8&&(y++,typeof T=="object"&&(T.placement&&(g=T.placement),T.rects&&(f=T.rects===!0?await a.getElementRects({reference:e,floating:t,strategy:o}):T.rects),{x:p,y:h}=iS(f,g,d)),w=-1)}return{x:p,y:h,placement:g,strategy:o,middlewareData:k}},O8=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:o,rects:i,platform:a,elements:l,middlewareData:d}=t,{element:f,padding:p=0}=Co(e,t)||{};if(f==null)return{};const h=MR(p),g={x:n,y:r},y=jw(o),k=ww(y),w=await a.getDimensions(f),b=y==="y",j=b?"top":"left",N=b?"bottom":"right",S=b?"clientHeight":"clientWidth",C=i.reference[k]+i.reference[y]-g[y]-i.floating[k],D=g[y]-i.reference[y],T=await(a.getOffsetParent==null?void 0:a.getOffsetParent(f));let R=T?T[S]:0;(!R||!await(a.isElement==null?void 0:a.isElement(T)))&&(R=l.floating[S]||i.floating[k]);const $=C/2-D/2,_=R/2-w[k]/2-1,U=ji(h[j],_),I=ji(h[N],_),F=U,M=R-w[k]-I,A=R/2-w[k]/2+$,L=Tb(F,A,M),z=!d.arrow&&wc(o)!=null&&A!==L&&i.reference[k]/2-(A<F?U:I)-w[k]/2<0,W=z?A<F?A-F:A-M:0;return{[y]:g[y]+W,data:{[y]:L,centerOffset:A-L-W,...z&&{alignmentOffset:W}},reset:z}}}),F8=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:o,middlewareData:i,rects:a,initialPlacement:l,platform:d,elements:f}=t,{mainAxis:p=!0,crossAxis:h=!0,fallbackPlacements:g,fallbackStrategy:y="bestFit",fallbackAxisSideDirection:k="none",flipAlignment:w=!0,...b}=Co(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};const j=Eo(o),N=Ws(l),S=Eo(l)===l,C=await(d.isRTL==null?void 0:d.isRTL(f.floating)),D=g||(S||!w?[mh(l)]:R8(l)),T=k!=="none";!g&&T&&D.push(...D8(l,w,k,C));const R=[l,...D],$=await d.detectOverflow(t,b),_=[];let U=((r=i.flip)==null?void 0:r.overflows)||[];if(p&&_.push($[j]),h){const A=T8(o,a,C);_.push($[A[0]],$[A[1]])}if(U=[...U,{placement:o,overflows:_}],!_.every(A=>A<=0)){var I,F;const A=(((I=i.flip)==null?void 0:I.index)||0)+1,L=R[A];if(L&&(!(h==="alignment"?N!==Ws(L):!1)||U.every(V=>Ws(V.placement)===N?V.overflows[0]>0:!0)))return{data:{index:A,overflows:U},reset:{placement:L}};let z=(F=U.filter(W=>W.overflows[0]<=0).sort((W,V)=>W.overflows[1]-V.overflows[1])[0])==null?void 0:F.placement;if(!z)switch(y){case"bestFit":{var M;const W=(M=U.filter(V=>{if(T){const K=Ws(V.placement);return K===N||K==="y"}return!0}).map(V=>[V.placement,V.overflows.filter(K=>K>0).reduce((K,O)=>K+O,0)]).sort((V,K)=>V[1]-K[1])[0])==null?void 0:M[0];W&&(z=W);break}case"initialPlacement":z=l;break}if(o!==z)return{reset:{placement:z}}}return{}}}};function aS(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function lS(e){return C8.some(t=>e[t]>=0)}const z8=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n,platform:r}=t,{strategy:o="referenceHidden",...i}=Co(e,t);switch(o){case"referenceHidden":{const a=await r.detectOverflow(t,{...i,elementContext:"reference"}),l=aS(a,n.reference);return{data:{referenceHiddenOffsets:l,referenceHidden:lS(l)}}}case"escaped":{const a=await r.detectOverflow(t,{...i,altBoundary:!0}),l=aS(a,n.floating);return{data:{escapedOffsets:l,escaped:lS(l)}}}default:return{}}}}},LR=new Set(["left","top"]);async function B8(e,t){const{placement:n,platform:r,elements:o}=e,i=await(r.isRTL==null?void 0:r.isRTL(o.floating)),a=Eo(n),l=wc(n),d=Ws(n)==="y",f=LR.has(a)?-1:1,p=i&&d?-1:1,h=Co(t,e);let{mainAxis:g,crossAxis:y,alignmentAxis:k}=typeof h=="number"?{mainAxis:h,crossAxis:0,alignmentAxis:null}:{mainAxis:h.mainAxis||0,crossAxis:h.crossAxis||0,alignmentAxis:h.alignmentAxis};return l&&typeof k=="number"&&(y=l==="end"?k*-1:k),d?{x:y*p,y:g*f}:{x:g*f,y:y*p}}const U8=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:o,y:i,placement:a,middlewareData:l}=t,d=await B8(t,e);return a===((n=l.offset)==null?void 0:n.placement)&&(r=l.arrow)!=null&&r.alignmentOffset?{}:{x:o+d.x,y:i+d.y,data:{...d,placement:a}}}}},H8=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:o,platform:i}=t,{mainAxis:a=!0,crossAxis:l=!1,limiter:d={fn:j=>{let{x:N,y:S}=j;return{x:N,y:S}}},...f}=Co(e,t),p={x:n,y:r},h=await i.detectOverflow(t,f),g=Ws(Eo(o)),y=vw(g);let k=p[y],w=p[g];if(a){const j=y==="y"?"top":"left",N=y==="y"?"bottom":"right",S=k+h[j],C=k-h[N];k=Tb(S,k,C)}if(l){const j=g==="y"?"top":"left",N=g==="y"?"bottom":"right",S=w+h[j],C=w-h[N];w=Tb(S,w,C)}const b=d.fn({...t,[y]:k,[g]:w});return{...b,data:{x:b.x-n,y:b.y-r,enabled:{[y]:a,[g]:l}}}}}},V8=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:o,rects:i,middlewareData:a}=t,{offset:l=0,mainAxis:d=!0,crossAxis:f=!0}=Co(e,t),p={x:n,y:r},h=Ws(o),g=vw(h);let y=p[g],k=p[h];const w=Co(l,t),b=typeof w=="number"?{mainAxis:w,crossAxis:0}:{mainAxis:0,crossAxis:0,...w};if(d){const S=g==="y"?"height":"width",C=i.reference[g]-i.floating[S]+b.mainAxis,D=i.reference[g]+i.reference[S]-b.mainAxis;y<C?y=C:y>D&&(y=D)}if(f){var j,N;const S=g==="y"?"width":"height",C=LR.has(Eo(o)),D=i.reference[h]-i.floating[S]+(C&&((j=a.offset)==null?void 0:j[h])||0)+(C?0:b.crossAxis),T=i.reference[h]+i.reference[S]+(C?0:((N=a.offset)==null?void 0:N[h])||0)-(C?b.crossAxis:0);k<D?k=D:k>T&&(k=T)}return{[g]:y,[h]:k}}}},W8=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,r;const{placement:o,rects:i,platform:a,elements:l}=t,{apply:d=()=>{},...f}=Co(e,t),p=await a.detectOverflow(t,f),h=Eo(o),g=wc(o),y=Ws(o)==="y",{width:k,height:w}=i.floating;let b,j;h==="top"||h==="bottom"?(b=h,j=g===(await(a.isRTL==null?void 0:a.isRTL(l.floating))?"start":"end")?"left":"right"):(j=h,b=g==="end"?"top":"bottom");const N=w-p.top-p.bottom,S=k-p.left-p.right,C=ji(w-p[b],N),D=ji(k-p[j],S),T=!t.middlewareData.shift;let R=C,$=D;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&($=S),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(R=N),T&&!g){const U=$r(p.left,0),I=$r(p.right,0),F=$r(p.top,0),M=$r(p.bottom,0);y?$=k-2*(U!==0||I!==0?U+I:$r(p.left,p.right)):R=w-2*(F!==0||M!==0?F+M:$r(p.top,p.bottom))}await d({...t,availableWidth:$,availableHeight:R});const _=await a.getDimensions(l.floating);return k!==_.width||w!==_.height?{reset:{rects:!0}}:{}}}};function ym(){return typeof window<"u"}function jc(e){return OR(e)?(e.nodeName||"").toLowerCase():"#document"}function Fr(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function eo(e){var t;return(t=(OR(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function OR(e){return ym()?e instanceof Node||e instanceof Fr(e).Node:!1}function ws(e){return ym()?e instanceof Element||e instanceof Fr(e).Element:!1}function Ao(e){return ym()?e instanceof HTMLElement||e instanceof Fr(e).HTMLElement:!1}function cS(e){return!ym()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Fr(e).ShadowRoot}function Md(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=js(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&o!=="inline"&&o!=="contents"}function q8(e){return/^(table|td|th)$/.test(jc(e))}function bm(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const K8=/transform|translate|scale|rotate|perspective|filter/,G8=/paint|layout|strict|content/,Yi=e=>!!e&&e!=="none";let uy;function kw(e){const t=ws(e)?js(e):e;return Yi(t.transform)||Yi(t.translate)||Yi(t.scale)||Yi(t.rotate)||Yi(t.perspective)||!Sw()&&(Yi(t.backdropFilter)||Yi(t.filter))||K8.test(t.willChange||"")||G8.test(t.contain||"")}function Y8(e){let t=ki(e);for(;Ao(t)&&!Yl(t);){if(kw(t))return t;if(bm(t))return null;t=ki(t)}return null}function Sw(){return uy==null&&(uy=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),uy}function Yl(e){return/^(html|body|#document)$/.test(jc(e))}function js(e){return Fr(e).getComputedStyle(e)}function vm(e){return ws(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function ki(e){if(jc(e)==="html")return e;const t=e.assignedSlot||e.parentNode||cS(e)&&e.host||eo(e);return cS(t)?t.host:t}function FR(e){const t=ki(e);return Yl(t)?e.ownerDocument?e.ownerDocument.body:e.body:Ao(t)&&Md(t)?t:FR(t)}function rd(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=FR(e),i=o===((r=e.ownerDocument)==null?void 0:r.body),a=Fr(o);if(i){const l=Ab(a);return t.concat(a,a.visualViewport||[],Md(o)?o:[],l&&n?rd(l):[])}else return t.concat(o,rd(o,[],n))}function Ab(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function zR(e){const t=js(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=Ao(e),i=o?e.offsetWidth:n,a=o?e.offsetHeight:r,l=hh(n)!==i||hh(r)!==a;return l&&(n=i,r=a),{width:n,height:r,$:l}}function Nw(e){return ws(e)?e:e.contextElement}function Ol(e){const t=Nw(e);if(!Ao(t))return Ys(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:i}=zR(t);let a=(i?hh(n.width):n.width)/r,l=(i?hh(n.height):n.height)/o;return(!a||!Number.isFinite(a))&&(a=1),(!l||!Number.isFinite(l))&&(l=1),{x:a,y:l}}const X8=Ys(0);function BR(e){const t=Fr(e);return!Sw()||!t.visualViewport?X8:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Q8(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==Fr(e)?!1:t}function ya(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),i=Nw(e);let a=Ys(1);t&&(r?ws(r)&&(a=Ol(r)):a=Ol(e));const l=Q8(i,n,r)?BR(i):Ys(0);let d=(o.left+l.x)/a.x,f=(o.top+l.y)/a.y,p=o.width/a.x,h=o.height/a.y;if(i){const g=Fr(i),y=r&&ws(r)?Fr(r):r;let k=g,w=Ab(k);for(;w&&r&&y!==k;){const b=Ol(w),j=w.getBoundingClientRect(),N=js(w),S=j.left+(w.clientLeft+parseFloat(N.paddingLeft))*b.x,C=j.top+(w.clientTop+parseFloat(N.paddingTop))*b.y;d*=b.x,f*=b.y,p*=b.x,h*=b.y,d+=S,f+=C,k=Fr(w),w=Ab(k)}}return gh({width:p,height:h,x:d,y:f})}function wm(e,t){const n=vm(e).scrollLeft;return t?t.left+n:ya(eo(e)).left+n}function UR(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-wm(e,n),o=n.top+t.scrollTop;return{x:r,y:o}}function J8(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const i=o==="fixed",a=eo(r),l=t?bm(t.floating):!1;if(r===a||l&&i)return n;let d={scrollLeft:0,scrollTop:0},f=Ys(1);const p=Ys(0),h=Ao(r);if((h||!h&&!i)&&((jc(r)!=="body"||Md(a))&&(d=vm(r)),h)){const y=ya(r);f=Ol(r),p.x=y.x+r.clientLeft,p.y=y.y+r.clientTop}const g=a&&!h&&!i?UR(a,d):Ys(0);return{width:n.width*f.x,height:n.height*f.y,x:n.x*f.x-d.scrollLeft*f.x+p.x+g.x,y:n.y*f.y-d.scrollTop*f.y+p.y+g.y}}function Z8(e){return Array.from(e.getClientRects())}function e7(e){const t=eo(e),n=vm(e),r=e.ownerDocument.body,o=$r(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),i=$r(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let a=-n.scrollLeft+wm(e);const l=-n.scrollTop;return js(r).direction==="rtl"&&(a+=$r(t.clientWidth,r.clientWidth)-o),{width:o,height:i,x:a,y:l}}const uS=25;function t7(e,t){const n=Fr(e),r=eo(e),o=n.visualViewport;let i=r.clientWidth,a=r.clientHeight,l=0,d=0;if(o){i=o.width,a=o.height;const p=Sw();(!p||p&&t==="fixed")&&(l=o.offsetLeft,d=o.offsetTop)}const f=wm(r);if(f<=0){const p=r.ownerDocument,h=p.body,g=getComputedStyle(h),y=p.compatMode==="CSS1Compat"&&parseFloat(g.marginLeft)+parseFloat(g.marginRight)||0,k=Math.abs(r.clientWidth-h.clientWidth-y);k<=uS&&(i-=k)}else f<=uS&&(i+=f);return{width:i,height:a,x:l,y:d}}function n7(e,t){const n=ya(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,i=Ao(e)?Ol(e):Ys(1),a=e.clientWidth*i.x,l=e.clientHeight*i.y,d=o*i.x,f=r*i.y;return{width:a,height:l,x:d,y:f}}function dS(e,t,n){let r;if(t==="viewport")r=t7(e,n);else if(t==="document")r=e7(eo(e));else if(ws(t))r=n7(t,n);else{const o=BR(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return gh(r)}function HR(e,t){const n=ki(e);return n===t||!ws(n)||Yl(n)?!1:js(n).position==="fixed"||HR(n,t)}function r7(e,t){const n=t.get(e);if(n)return n;let r=rd(e,[],!1).filter(l=>ws(l)&&jc(l)!=="body"),o=null;const i=js(e).position==="fixed";let a=i?ki(e):e;for(;ws(a)&&!Yl(a);){const l=js(a),d=kw(a);!d&&l.position==="fixed"&&(o=null),(i?!d&&!o:!d&&l.position==="static"&&!!o&&(o.position==="absolute"||o.position==="fixed")||Md(a)&&!d&&HR(e,a))?r=r.filter(p=>p!==a):o=l,a=ki(a)}return t.set(e,r),r}function s7(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const a=[...n==="clippingAncestors"?bm(t)?[]:r7(t,this._c):[].concat(n),r],l=dS(t,a[0],o);let d=l.top,f=l.right,p=l.bottom,h=l.left;for(let g=1;g<a.length;g++){const y=dS(t,a[g],o);d=$r(y.top,d),f=ji(y.right,f),p=ji(y.bottom,p),h=$r(y.left,h)}return{width:f-h,height:p-d,x:h,y:d}}function o7(e){const{width:t,height:n}=zR(e);return{width:t,height:n}}function i7(e,t,n){const r=Ao(t),o=eo(t),i=n==="fixed",a=ya(e,!0,i,t);let l={scrollLeft:0,scrollTop:0};const d=Ys(0);function f(){d.x=wm(o)}if(r||!r&&!i)if((jc(t)!=="body"||Md(o))&&(l=vm(t)),r){const y=ya(t,!0,i,t);d.x=y.x+t.clientLeft,d.y=y.y+t.clientTop}else o&&f();i&&!r&&o&&f();const p=o&&!r&&!i?UR(o,l):Ys(0),h=a.left+l.scrollLeft-d.x-p.x,g=a.top+l.scrollTop-d.y-p.y;return{x:h,y:g,width:a.width,height:a.height}}function dy(e){return js(e).position==="static"}function fS(e,t){if(!Ao(e)||js(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return eo(e)===n&&(n=n.ownerDocument.body),n}function VR(e,t){const n=Fr(e);if(bm(e))return n;if(!Ao(e)){let o=ki(e);for(;o&&!Yl(o);){if(ws(o)&&!dy(o))return o;o=ki(o)}return n}let r=fS(e,t);for(;r&&q8(r)&&dy(r);)r=fS(r,t);return r&&Yl(r)&&dy(r)&&!kw(r)?n:r||Y8(e)||n}const a7=async function(e){const t=this.getOffsetParent||VR,n=this.getDimensions,r=await n(e.floating);return{reference:i7(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function l7(e){return js(e).direction==="rtl"}const c7={convertOffsetParentRelativeRectToViewportRelativeRect:J8,getDocumentElement:eo,getClippingRect:s7,getOffsetParent:VR,getElementRects:a7,getClientRects:Z8,getDimensions:o7,getScale:Ol,isElement:ws,isRTL:l7};function WR(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function u7(e,t){let n=null,r;const o=eo(e);function i(){var l;clearTimeout(r),(l=n)==null||l.disconnect(),n=null}function a(l,d){l===void 0&&(l=!1),d===void 0&&(d=1),i();const f=e.getBoundingClientRect(),{left:p,top:h,width:g,height:y}=f;if(l||t(),!g||!y)return;const k=ip(h),w=ip(o.clientWidth-(p+g)),b=ip(o.clientHeight-(h+y)),j=ip(p),S={rootMargin:-k+"px "+-w+"px "+-b+"px "+-j+"px",threshold:$r(0,ji(1,d))||1};let C=!0;function D(T){const R=T[0].intersectionRatio;if(R!==d){if(!C)return a();R?a(!1,R):r=setTimeout(()=>{a(!1,1e-7)},1e3)}R===1&&!WR(f,e.getBoundingClientRect())&&a(),C=!1}try{n=new IntersectionObserver(D,{...S,root:o.ownerDocument})}catch{n=new IntersectionObserver(D,S)}n.observe(e)}return a(!0),i}function d7(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:o=!0,ancestorResize:i=!0,elementResize:a=typeof ResizeObserver=="function",layoutShift:l=typeof IntersectionObserver=="function",animationFrame:d=!1}=r,f=Nw(e),p=o||i?[...f?rd(f):[],...t?rd(t):[]]:[];p.forEach(j=>{o&&j.addEventListener("scroll",n,{passive:!0}),i&&j.addEventListener("resize",n)});const h=f&&l?u7(f,n):null;let g=-1,y=null;a&&(y=new ResizeObserver(j=>{let[N]=j;N&&N.target===f&&y&&t&&(y.unobserve(t),cancelAnimationFrame(g),g=requestAnimationFrame(()=>{var S;(S=y)==null||S.observe(t)})),n()}),f&&!d&&y.observe(f),t&&y.observe(t));let k,w=d?ya(e):null;d&&b();function b(){const j=ya(e);w&&!WR(w,j)&&n(),w=j,k=requestAnimationFrame(b)}return n(),()=>{var j;p.forEach(N=>{o&&N.removeEventListener("scroll",n),i&&N.removeEventListener("resize",n)}),h==null||h(),(j=y)==null||j.disconnect(),y=null,d&&cancelAnimationFrame(k)}}const f7=U8,p7=H8,h7=F8,m7=W8,g7=z8,pS=O8,x7=V8,y7=(e,t,n)=>{const r=new Map,o={platform:c7,...n},i={...o.platform,_c:r};return L8(e,t,{...o,platform:i})};var b7=typeof document<"u",v7=function(){},Fp=b7?m.useLayoutEffect:v7;function xh(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,r,o;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!xh(e[r],t[r]))return!1;return!0}if(o=Object.keys(e),n=o.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,o[r]))return!1;for(r=n;r--!==0;){const i=o[r];if(!(i==="_owner"&&e.$$typeof)&&!xh(e[i],t[i]))return!1}return!0}return e!==e&&t!==t}function qR(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function hS(e,t){const n=qR(e);return Math.round(t*n)/n}function fy(e){const t=m.useRef(e);return Fp(()=>{t.current=e}),t}function w7(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:o,elements:{reference:i,floating:a}={},transform:l=!0,whileElementsMounted:d,open:f}=e,[p,h]=m.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[g,y]=m.useState(r);xh(g,r)||y(r);const[k,w]=m.useState(null),[b,j]=m.useState(null),N=m.useCallback(V=>{V!==T.current&&(T.current=V,w(V))},[]),S=m.useCallback(V=>{V!==R.current&&(R.current=V,j(V))},[]),C=i||k,D=a||b,T=m.useRef(null),R=m.useRef(null),$=m.useRef(p),_=d!=null,U=fy(d),I=fy(o),F=fy(f),M=m.useCallback(()=>{if(!T.current||!R.current)return;const V={placement:t,strategy:n,middleware:g};I.current&&(V.platform=I.current),y7(T.current,R.current,V).then(K=>{const O={...K,isPositioned:F.current!==!1};A.current&&!xh($.current,O)&&($.current=O,vo.flushSync(()=>{h(O)}))})},[g,t,n,I,F]);Fp(()=>{f===!1&&$.current.isPositioned&&($.current.isPositioned=!1,h(V=>({...V,isPositioned:!1})))},[f]);const A=m.useRef(!1);Fp(()=>(A.current=!0,()=>{A.current=!1}),[]),Fp(()=>{if(C&&(T.current=C),D&&(R.current=D),C&&D){if(U.current)return U.current(C,D,M);M()}},[C,D,M,U,_]);const L=m.useMemo(()=>({reference:T,floating:R,setReference:N,setFloating:S}),[N,S]),z=m.useMemo(()=>({reference:C,floating:D}),[C,D]),W=m.useMemo(()=>{const V={position:n,left:0,top:0};if(!z.floating)return V;const K=hS(z.floating,p.x),O=hS(z.floating,p.y);return l?{...V,transform:"translate("+K+"px, "+O+"px)",...qR(z.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:K,top:O}},[n,l,z.floating,p.x,p.y]);return m.useMemo(()=>({...p,update:M,refs:L,elements:z,floatingStyles:W}),[p,M,L,z,W])}const j7=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:r,padding:o}=typeof e=="function"?e(n):e;return r&&t(r)?r.current!=null?pS({element:r.current,padding:o}).fn(n):{}:r?pS({element:r,padding:o}).fn(n):{}}}},k7=(e,t)=>{const n=f7(e);return{name:n.name,fn:n.fn,options:[e,t]}},S7=(e,t)=>{const n=p7(e);return{name:n.name,fn:n.fn,options:[e,t]}},N7=(e,t)=>({fn:x7(e).fn,options:[e,t]}),C7=(e,t)=>{const n=h7(e);return{name:n.name,fn:n.fn,options:[e,t]}},E7=(e,t)=>{const n=m7(e);return{name:n.name,fn:n.fn,options:[e,t]}},T7=(e,t)=>{const n=g7(e);return{name:n.name,fn:n.fn,options:[e,t]}},R7=(e,t)=>{const n=j7(e);return{name:n.name,fn:n.fn,options:[e,t]}};var A7="Arrow",KR=m.forwardRef((e,t)=>{const{children:n,width:r=10,height:o=5,...i}=e;return s.jsx(wn.svg,{...i,ref:t,width:r,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:s.jsx("polygon",{points:"0,0 30,0 15,10"})})});KR.displayName=A7;var P7=KR;function _7(e){const[t,n]=m.useState(void 0);return bi(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;const i=o[0];let a,l;if("borderBoxSize"in i){const d=i.borderBoxSize,f=Array.isArray(d)?d[0]:d;a=f.inlineSize,l=f.blockSize}else a=e.offsetWidth,l=e.offsetHeight;n({width:a,height:l})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}var Cw="Popper",[GR,YR]=Na(Cw),[D7,XR]=GR(Cw),QR=e=>{const{__scopePopper:t,children:n}=e,[r,o]=m.useState(null);return s.jsx(D7,{scope:t,anchor:r,onAnchorChange:o,children:n})};QR.displayName=Cw;var JR="PopperAnchor",ZR=m.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,i=XR(JR,n),a=m.useRef(null),l=Zn(t,a),d=m.useRef(null);return m.useEffect(()=>{const f=d.current;d.current=(r==null?void 0:r.current)||a.current,f!==d.current&&i.onAnchorChange(d.current)}),r?null:s.jsx(wn.div,{...o,ref:l})});ZR.displayName=JR;var Ew="PopperContent",[$7,I7]=GR(Ew),eA=m.forwardRef((e,t)=>{var ae,ne,ue,ye,Ne,Re;const{__scopePopper:n,side:r="bottom",sideOffset:o=0,align:i="center",alignOffset:a=0,arrowPadding:l=0,avoidCollisions:d=!0,collisionBoundary:f=[],collisionPadding:p=0,sticky:h="partial",hideWhenDetached:g=!1,updatePositionStrategy:y="optimized",onPlaced:k,...w}=e,b=XR(Ew,n),[j,N]=m.useState(null),S=Zn(t,Se=>N(Se)),[C,D]=m.useState(null),T=_7(C),R=(T==null?void 0:T.width)??0,$=(T==null?void 0:T.height)??0,_=r+(i!=="center"?"-"+i:""),U=typeof p=="number"?p:{top:0,right:0,bottom:0,left:0,...p},I=Array.isArray(f)?f:[f],F=I.length>0,M={padding:U,boundary:I.filter(L7),altBoundary:F},{refs:A,floatingStyles:L,placement:z,isPositioned:W,middlewareData:V}=w7({strategy:"fixed",placement:_,whileElementsMounted:(...Se)=>d7(...Se,{animationFrame:y==="always"}),elements:{reference:b.anchor},middleware:[k7({mainAxis:o+$,alignmentAxis:a}),d&&S7({mainAxis:!0,crossAxis:!1,limiter:h==="partial"?N7():void 0,...M}),d&&C7({...M}),E7({...M,apply:({elements:Se,rects:ze,availableWidth:oe,availableHeight:we})=>{const{width:ke,height:$e}=ze.reference,Ue=Se.floating.style;Ue.setProperty("--radix-popper-available-width",`${oe}px`),Ue.setProperty("--radix-popper-available-height",`${we}px`),Ue.setProperty("--radix-popper-anchor-width",`${ke}px`),Ue.setProperty("--radix-popper-anchor-height",`${$e}px`)}}),C&&R7({element:C,padding:l}),O7({arrowWidth:R,arrowHeight:$}),g&&T7({strategy:"referenceHidden",...M})]}),[K,O]=rA(z),B=ga(k);bi(()=>{W&&(B==null||B())},[W,B]);const G=(ae=V.arrow)==null?void 0:ae.x,H=(ne=V.arrow)==null?void 0:ne.y,Q=((ue=V.arrow)==null?void 0:ue.centerOffset)!==0,[te,Z]=m.useState();return bi(()=>{j&&Z(window.getComputedStyle(j).zIndex)},[j]),s.jsx("div",{ref:A.setFloating,"data-radix-popper-content-wrapper":"",style:{...L,transform:W?L.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:te,"--radix-popper-transform-origin":[(ye=V.transformOrigin)==null?void 0:ye.x,(Ne=V.transformOrigin)==null?void 0:Ne.y].join(" "),...((Re=V.hide)==null?void 0:Re.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:s.jsx($7,{scope:n,placedSide:K,onArrowChange:D,arrowX:G,arrowY:H,shouldHideArrow:Q,children:s.jsx(wn.div,{"data-side":K,"data-align":O,...w,ref:S,style:{...w.style,animation:W?void 0:"none"}})})})});eA.displayName=Ew;var tA="PopperArrow",M7={top:"bottom",right:"left",bottom:"top",left:"right"},nA=m.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,i=I7(tA,r),a=M7[i.placedSide];return s.jsx("span",{ref:i.onArrowChange,style:{position:"absolute",left:i.arrowX,top:i.arrowY,[a]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[i.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[i.placedSide],visibility:i.shouldHideArrow?"hidden":void 0},children:s.jsx(P7,{...o,ref:n,style:{...o.style,display:"block"}})})});nA.displayName=tA;function L7(e){return e!==null}var O7=e=>({name:"transformOrigin",options:e,fn(t){var b,j,N;const{placement:n,rects:r,middlewareData:o}=t,a=((b=o.arrow)==null?void 0:b.centerOffset)!==0,l=a?0:e.arrowWidth,d=a?0:e.arrowHeight,[f,p]=rA(n),h={start:"0%",center:"50%",end:"100%"}[p],g=(((j=o.arrow)==null?void 0:j.x)??0)+l/2,y=(((N=o.arrow)==null?void 0:N.y)??0)+d/2;let k="",w="";return f==="bottom"?(k=a?h:`${g}px`,w=`${-d}px`):f==="top"?(k=a?h:`${g}px`,w=`${r.floating.height+d}px`):f==="right"?(k=`${-d}px`,w=a?h:`${y}px`):f==="left"&&(k=`${r.floating.width+d}px`,w=a?h:`${y}px`),{data:{x:k,y:w}}}});function rA(e){const[t,n="center"]=e.split("-");return[t,n]}var F7=QR,z7=ZR,B7=eA,U7=nA,H7=Symbol("radix.slottable");function V7(e){const t=({children:n})=>s.jsx(s.Fragment,{children:n});return t.displayName=`${e}.Slottable`,t.__radixId=H7,t}var W7=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),q7="VisuallyHidden",sA=m.forwardRef((e,t)=>s.jsx(wn.span,{...e,ref:t,style:{...W7,...e.style}}));sA.displayName=q7;var K7=sA,[jm]=Na("Tooltip",[YR]),km=YR(),oA="TooltipProvider",G7=700,Pb="tooltip.open",[Y7,Tw]=jm(oA),iA=e=>{const{__scopeTooltip:t,delayDuration:n=G7,skipDelayDuration:r=300,disableHoverableContent:o=!1,children:i}=e,a=m.useRef(!0),l=m.useRef(!1),d=m.useRef(0);return m.useEffect(()=>{const f=d.current;return()=>window.clearTimeout(f)},[]),s.jsx(Y7,{scope:t,isOpenDelayedRef:a,delayDuration:n,onOpen:m.useCallback(()=>{window.clearTimeout(d.current),a.current=!1},[]),onClose:m.useCallback(()=>{window.clearTimeout(d.current),d.current=window.setTimeout(()=>a.current=!0,r)},[r]),isPointerInTransitRef:l,onPointerInTransitChange:m.useCallback(f=>{l.current=f},[]),disableHoverableContent:o,children:i})};iA.displayName=oA;var sd="Tooltip",[X7,Ld]=jm(sd),aA=e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:o,onOpenChange:i,disableHoverableContent:a,delayDuration:l}=e,d=Tw(sd,e.__scopeTooltip),f=km(t),[p,h]=m.useState(null),g=_l(),y=m.useRef(0),k=a??d.disableHoverableContent,w=l??d.delayDuration,b=m.useRef(!1),[j,N]=rm({prop:r,defaultProp:o??!1,onChange:R=>{R?(d.onOpen(),document.dispatchEvent(new CustomEvent(Pb))):d.onClose(),i==null||i(R)},caller:sd}),S=m.useMemo(()=>j?b.current?"delayed-open":"instant-open":"closed",[j]),C=m.useCallback(()=>{window.clearTimeout(y.current),y.current=0,b.current=!1,N(!0)},[N]),D=m.useCallback(()=>{window.clearTimeout(y.current),y.current=0,N(!1)},[N]),T=m.useCallback(()=>{window.clearTimeout(y.current),y.current=window.setTimeout(()=>{b.current=!0,N(!0),y.current=0},w)},[w,N]);return m.useEffect(()=>()=>{y.current&&(window.clearTimeout(y.current),y.current=0)},[]),s.jsx(F7,{...f,children:s.jsx(X7,{scope:t,contentId:g,open:j,stateAttribute:S,trigger:p,onTriggerChange:h,onTriggerEnter:m.useCallback(()=>{d.isOpenDelayedRef.current?T():C()},[d.isOpenDelayedRef,T,C]),onTriggerLeave:m.useCallback(()=>{k?D():(window.clearTimeout(y.current),y.current=0)},[D,k]),onOpen:C,onClose:D,disableHoverableContent:k,children:n})})};aA.displayName=sd;var _b="TooltipTrigger",lA=m.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=Ld(_b,n),i=Tw(_b,n),a=km(n),l=m.useRef(null),d=Zn(t,l,o.onTriggerChange),f=m.useRef(!1),p=m.useRef(!1),h=m.useCallback(()=>f.current=!1,[]);return m.useEffect(()=>()=>document.removeEventListener("pointerup",h),[h]),s.jsx(z7,{asChild:!0,...a,children:s.jsx(wn.button,{"aria-describedby":o.open?o.contentId:void 0,"data-state":o.stateAttribute,...r,ref:d,onPointerMove:rn(e.onPointerMove,g=>{g.pointerType!=="touch"&&!p.current&&!i.isPointerInTransitRef.current&&(o.onTriggerEnter(),p.current=!0)}),onPointerLeave:rn(e.onPointerLeave,()=>{o.onTriggerLeave(),p.current=!1}),onPointerDown:rn(e.onPointerDown,()=>{o.open&&o.onClose(),f.current=!0,document.addEventListener("pointerup",h,{once:!0})}),onFocus:rn(e.onFocus,()=>{f.current||o.onOpen()}),onBlur:rn(e.onBlur,o.onClose),onClick:rn(e.onClick,o.onClose)})})});lA.displayName=_b;var Rw="TooltipPortal",[Q7,J7]=jm(Rw,{forceMount:void 0}),cA=e=>{const{__scopeTooltip:t,forceMount:n,children:r,container:o}=e,i=Ld(Rw,t);return s.jsx(Q7,{scope:t,forceMount:n,children:s.jsx(Ca,{present:n||i.open,children:s.jsx(Gv,{asChild:!0,container:o,children:r})})})};cA.displayName=Rw;var Xl="TooltipContent",uA=m.forwardRef((e,t)=>{const n=J7(Xl,e.__scopeTooltip),{forceMount:r=n.forceMount,side:o="top",...i}=e,a=Ld(Xl,e.__scopeTooltip);return s.jsx(Ca,{present:r||a.open,children:a.disableHoverableContent?s.jsx(dA,{side:o,...i,ref:t}):s.jsx(Z7,{side:o,...i,ref:t})})}),Z7=m.forwardRef((e,t)=>{const n=Ld(Xl,e.__scopeTooltip),r=Tw(Xl,e.__scopeTooltip),o=m.useRef(null),i=Zn(t,o),[a,l]=m.useState(null),{trigger:d,onClose:f}=n,p=o.current,{onPointerInTransitChange:h}=r,g=m.useCallback(()=>{l(null),h(!1)},[h]),y=m.useCallback((k,w)=>{const b=k.currentTarget,j={x:k.clientX,y:k.clientY},N=sU(j,b.getBoundingClientRect()),S=oU(j,N),C=iU(w.getBoundingClientRect()),D=lU([...S,...C]);l(D),h(!0)},[h]);return m.useEffect(()=>()=>g(),[g]),m.useEffect(()=>{if(d&&p){const k=b=>y(b,p),w=b=>y(b,d);return d.addEventListener("pointerleave",k),p.addEventListener("pointerleave",w),()=>{d.removeEventListener("pointerleave",k),p.removeEventListener("pointerleave",w)}}},[d,p,y,g]),m.useEffect(()=>{if(a){const k=w=>{const b=w.target,j={x:w.clientX,y:w.clientY},N=(d==null?void 0:d.contains(b))||(p==null?void 0:p.contains(b)),S=!aU(j,a);N?g():S&&(g(),f())};return document.addEventListener("pointermove",k),()=>document.removeEventListener("pointermove",k)}},[d,p,a,f,g]),s.jsx(dA,{...e,ref:i})}),[eU,tU]=jm(sd,{isInside:!1}),nU=V7("TooltipContent"),dA=m.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":o,onEscapeKeyDown:i,onPointerDownOutside:a,...l}=e,d=Ld(Xl,n),f=km(n),{onClose:p}=d;return m.useEffect(()=>(document.addEventListener(Pb,p),()=>document.removeEventListener(Pb,p)),[p]),m.useEffect(()=>{if(d.trigger){const h=g=>{const y=g.target;y!=null&&y.contains(d.trigger)&&p()};return window.addEventListener("scroll",h,{capture:!0}),()=>window.removeEventListener("scroll",h,{capture:!0})}},[d.trigger,p]),s.jsx(Kv,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:i,onPointerDownOutside:a,onFocusOutside:h=>h.preventDefault(),onDismiss:p,children:s.jsxs(B7,{"data-state":d.stateAttribute,...f,...l,ref:t,style:{...l.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[s.jsx(nU,{children:r}),s.jsx(eU,{scope:n,isInside:!0,children:s.jsx(K7,{id:d.contentId,role:"tooltip",children:o||r})})]})})});uA.displayName=Xl;var fA="TooltipArrow",rU=m.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=km(n);return tU(fA,n).isInside?null:s.jsx(U7,{...o,...r,ref:t})});rU.displayName=fA;function sU(e,t){const n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),o=Math.abs(t.right-e.x),i=Math.abs(t.left-e.x);switch(Math.min(n,r,o,i)){case i:return"left";case o:return"right";case n:return"top";case r:return"bottom";default:throw new Error("unreachable")}}function oU(e,t,n=5){const r=[];switch(t){case"top":r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case"bottom":r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case"left":r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case"right":r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}function iU(e){const{top:t,right:n,bottom:r,left:o}=e;return[{x:o,y:t},{x:n,y:t},{x:n,y:r},{x:o,y:r}]}function aU(e,t){const{x:n,y:r}=e;let o=!1;for(let i=0,a=t.length-1;i<t.length;a=i++){const l=t[i],d=t[a],f=l.x,p=l.y,h=d.x,g=d.y;p>r!=g>r&&n<(h-f)*(r-p)/(g-p)+f&&(o=!o)}return o}function lU(e){const t=e.slice();return t.sort((n,r)=>n.x<r.x?-1:n.x>r.x?1:n.y<r.y?-1:n.y>r.y?1:0),cU(t)}function cU(e){if(e.length<=1)return e.slice();const t=[];for(let r=0;r<e.length;r++){const o=e[r];for(;t.length>=2;){const i=t[t.length-1],a=t[t.length-2];if((i.x-a.x)*(o.y-a.y)>=(i.y-a.y)*(o.x-a.x))t.pop();else break}t.push(o)}t.pop();const n=[];for(let r=e.length-1;r>=0;r--){const o=e[r];for(;n.length>=2;){const i=n[n.length-1],a=n[n.length-2];if((i.x-a.x)*(o.y-a.y)>=(i.y-a.y)*(o.x-a.x))n.pop();else break}n.push(o)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var uU=iA,dU=aA,fU=lA,pU=cA,pA=uA;const fa=uU,Ir=dU,Mr=fU,gr=m.forwardRef(({className:e,sideOffset:t=4,...n},r)=>s.jsx(pU,{children:s.jsx(pA,{ref:r,sideOffset:t,className:Ce("z-50 overflow-hidden rounded-md border border-border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...n})}));gr.displayName=pA.displayName;function Aw({items:e,align:t="end"}){const[n,r]=m.useState(!1),[o,i]=m.useState(null),a=m.useRef(null);if(m.useEffect(()=>{if(!n){i(null);return}function d(p){a.current&&!a.current.contains(p.target)&&r(!1)}function f(p){p.key==="Escape"&&r(!1)}return document.addEventListener("mousedown",d),document.addEventListener("keydown",f),()=>{document.removeEventListener("mousedown",d),document.removeEventListener("keydown",f)}},[n]),e.length===0)return null;function l(d,f){const p=d.icon,h=Ce("flex w-full items-center gap-2 px-3 py-1.5 text-sm text-left transition",f&&"pl-8",d.disabled?"opacity-50 cursor-not-allowed":d.destructive?"text-destructive hover:bg-destructive/10":"hover:bg-foreground/5"),g=f?d.active?s.jsx(zr,{className:"h-4 w-4 shrink-0","aria-hidden":"true"}):s.jsx("span",{className:"h-4 w-4 shrink-0","aria-hidden":"true"}):p?s.jsx(p,{className:"h-4 w-4 shrink-0"}):null,y=s.jsxs(s.Fragment,{children:[g,s.jsx("span",{className:"block min-w-0 truncate",children:d.label})]});if(d.disabled){const k=s.jsx("span",{tabIndex:0,className:"inline-block w-full outline-none focus-visible:ring-1 focus-visible:ring-ring",children:s.jsx("button",{type:"button",disabled:!0,className:h,children:y})});return d.disabledReason?s.jsxs(Ir,{children:[s.jsx(Mr,{asChild:!0,children:k}),s.jsx(gr,{side:"left",children:d.disabledReason})]},d.key):s.jsx("div",{children:k},d.key)}return d.href?s.jsx(Ie,{to:d.href,className:h,onClick:()=>r(!1),children:y},d.key):s.jsx("button",{type:"button",className:h,onClick:()=>{var k;(k=d.onSelect)==null||k.call(d),r(!1)},children:y},d.key)}return s.jsxs("div",{className:"relative",ref:a,children:[s.jsx("button",{type:"button",onClick:()=>r(d=>!d),className:"shell-action",title:"More actions","aria-label":"More actions","aria-haspopup":"true","aria-expanded":n,children:s.jsx(IL,{className:"h-4 w-4"})}),n&&s.jsx("div",{className:Ce("absolute top-full mt-1 z-30 min-w-[220px] rounded-md border border-border/70 bg-background shadow-lg py-1",t==="end"?"right-0":"left-0"),children:s.jsx(fa,{delayDuration:200,children:e.map(d=>{if(d.submenu&&d.submenu.length>0){const f=d.icon,p=o===d.key;return s.jsxs("div",{children:[s.jsxs("button",{type:"button",className:Ce("flex w-full items-center gap-2 px-3 py-1.5 text-sm text-left transition hover:bg-foreground/5"),"aria-expanded":p,onClick:()=>i(p?null:d.key),children:[f?s.jsx(f,{className:"h-4 w-4 shrink-0"}):null,s.jsx("span",{className:"block min-w-0 flex-1 truncate",children:d.label}),p?s.jsx(vr,{className:"h-4 w-4 shrink-0 text-muted-foreground","aria-hidden":"true"}):s.jsx(KE,{className:"h-4 w-4 shrink-0 text-muted-foreground","aria-hidden":"true"})]}),p?d.submenu.map(h=>l(h,!0)):null]},d.key)}return l(d,!1)})})})]})}function mS(e){const t=Date.parse(e);return Number.isNaN(t)?!1:Date.now()-t>10080*60*1e3}const hU={last_24h:1440*60*1e3,last_7d:10080*60*1e3,last_30d:720*60*60*1e3,last_90d:2160*60*60*1e3,older_7d:10080*60*1e3,older_30d:720*60*60*1e3};function mU(e){const[t,n,r]=e.split("-").map(Number);return new Date(t,n-1,r,0,0,0,0).getTime()}function gU(e){const[t,n,r]=e.split("-").map(Number);return new Date(t,n-1,r,23,59,59,999).getTime()}function xU(e,t,n=Date.now()){if(!t)return!0;const r=t.field==="created"?e.created??e.updated:e.updated,o=Date.parse(r);if(Number.isNaN(o))return!1;if(t.preset){const l=hU[t.preset];return l===void 0?!0:t.preset.startsWith("older_")?n-o>l:o>=n-l&&o<=n}const i=t.from&&t.from.length>0?t.from:void 0,a=t.to&&t.to.length>0?t.to:void 0;return!i&&!a?!0:!(i&&o<mU(i)||a&&o>gU(a))}function yU(e,t,n={}){const{workspace:r,search:o,includeArchived:i}=n;if(e.archived===!0&&!i)return!1;const a=Ke(t.status),l=Ke(t.priority),d=Ke(t.type),f=Ke(t.assignee),p=Ke(t.project),h=Ke(t.tags),{activity:g}=t;if(r){if(r==="_ungrouped"){if(e.projectWorkspace!=null)return!1}else if(e.projectWorkspace!==r)return!1}if(a.length&&!a.includes(e.status)||l.length&&!l.includes(e.priority)||d.length&&!d.includes(e.type??"")||g==="stale"&&!mS(e.updated)||g==="fresh"&&mS(e.updated))return!1;if(f.length){const y=e.assignee??"__unassigned__";if(!f.includes(y))return!1}if(p.length&&!p.some(k=>k==="__standalone__"?e.projectSlug==null:e.projectSlug===k))return!1;if(h.length){const y=e.tags??[];if(!h.some(k=>y.includes(k)))return!1}if(!xU(e,t.dateRange))return!1;if(o){const y=o.trim().toLowerCase();if(y&&!`${e.title??""} ${e.slug??""} ${e.projectTitle??"standalone"} ${e.projectSlug??""}`.toLowerCase().includes(y))return!1}return!0}function od(e){return e.projectSlug===null?`/assignments/${e.id}`:`${e.projectWorkspace?`/w/${e.projectWorkspace}`:""}/projects/${e.projectSlug}/assignments/${e.slug}`}const gS={critical:0,high:1,medium:2,low:3};function ap(e){return Date.parse(e??"")||0}function Od(e,t,n){return[...e].sort((o,i)=>{let a=0;switch(t){case"title":a=o.title.localeCompare(i.title);break;case"status":a=o.status.localeCompare(i.status);break;case"priority":a=(gS[o.priority]??99)-(gS[i.priority]??99);break;case"assignee":a=(o.assignee??"").localeCompare(i.assignee??"");break;case"dependencies":a=o.dependsOn.length-i.dependsOn.length;break;case"created":a=ap(o.created)-ap(i.created);break;case"updated":a=ap(o.updated)-ap(i.updated);break}return n==="asc"?a:-a})}function bU(e){const t=`${e.title??""} ${e.slug??""} ${e.projectTitle??"standalone"} ${e.projectSlug??""}`;return{...e.facts??{},status:e.status,phase:e.phase,disposition:e.disposition,priority:e.priority,type:e.type,assignee:e.assignee,project:e.projectSlug,tags:e.tags,archived:e.archived,title:e.title,created:e.created,updated:e.updated,completedAt:e.completedAt,statusAge:e.statusAge,phaseAge:e.phaseAge,searchText:t}}function hA(e,t,n={}){const{workspace:r,includeArchived:o=!1,now:i=Date.now()}=n,a={now:i};return e.filter(l=>{if(l.archived===!0&&!o)return!1;if(r){if(r==="_ungrouped"){if(l.projectWorkspace!=null)return!1}else if(l.projectWorkspace!==r)return!1}if(!t)return!0;const d=bU(l);return t.predicate(d,a)})}const Sm={hasrealobjective:{kind:"bool",get:e=>e.hasRealObjective},acrealtotal:{kind:"number",get:e=>e.acRealTotal},acrealchecked:{kind:"number",get:e=>e.acRealChecked},acallchecked:{kind:"bool",get:e=>e.acAllChecked},planexists:{kind:"bool",get:e=>e.planExists},planapproved:{kind:"bool",get:e=>e.planApproved},workspaceset:{kind:"bool",get:e=>e.workspaceSet},implementationstarted:{kind:"bool",get:e=>e.implementationStarted},depssatisfied:{kind:"bool",get:e=>e.depsSatisfied},unresolvedquestions:{kind:"number",get:e=>e.unresolvedQuestions},blocked:{kind:"bool"},parked:{kind:"bool"},reviewrequested:{kind:"bool",get:e=>e.reviewRequested},pinned:{kind:"bool"}};function Nm(e){const t=e.name,n={fact:t,approved:`${t}Approved`,changesRequested:`${t}ChangesRequested`,by:`${t}By`,approvedBy:`${t}ApprovedBy`},r=e.type==="attestation"?[n.fact,n.approved,n.changesRequested,n.by,n.approvedBy].map(o=>o.toLowerCase()):[n.fact.toLowerCase()];return{storageKey:t,exports:n,registryKeys:r}}function vU(e){const t=[];for(const n of e??[]){if(!n||typeof n.name!="string")continue;const r=n.name.trim();if(!/^[a-z][a-zA-Z0-9]*$/.test(r))continue;const o=(n.type??"").trim();if(o==="bool"||o==="number")t.push({name:r,type:o});else if(o==="attestation"){const i=(n.binds??"none").toString().trim()||"none";(i==="plan"||i==="commit"||i==="none")&&t.push({name:r,type:"attestation",binds:i})}}return t}function Db(e){const t=[],n=new Map;for(const r of Object.keys(Sm))n.set(r,"built-in");for(const r of Object.keys(Zh))n.set(r,"built-in");for(const r of e??[]){const o=((r==null?void 0:r.name)??"").trim();if(!/^[a-z][a-zA-Z0-9]*$/.test(o)){t.push(`fact "${(r==null?void 0:r.name)??""}": invalid name — must match /^[a-z][a-zA-Z0-9]*$/`);continue}const i=(r.type??"").trim();if(i!=="bool"&&i!=="number"&&i!=="attestation"){t.push(`fact "${o}": invalid type "${r.type??""}" — expected bool, number, or attestation`);continue}if(i==="attestation"){const f=(r.binds??"none").toString().trim()||"none";if(f!=="plan"&&f!=="commit"&&f!=="none"){t.push(`fact "${o}": invalid binds "${r.binds}" — expected plan, commit, or none`);continue}}const l=Nm(i==="attestation"?{name:o,type:i}:{name:o,type:i}).registryKeys,d=l.find(f=>n.has(f));if(d!==void 0){const f=n.get(d);f==="built-in"?t.push(`fact "${o}": exported field "${d}" collides with a built-in field`):f===o?t.push(`fact "${o}": duplicate declaration (a fact named "${o}" is already declared)`):t.push(`fact "${o}": exported field "${d}" collides with fact "${f}"`);continue}for(const f of l)n.set(f,o)}return t}function wU(e){const t=new Set([...Object.keys(Sm),...Object.keys(Zh)]),n=[];for(const r of e){const o=Nm(r).registryKeys;if(!o.some(i=>t.has(i))){for(const i of o)t.add(i);n.push(r)}}return n}function mA(e,t){const n=Nm(t);t.type==="attestation"?(e[n.exports.fact.toLowerCase()]={kind:"bool",get:r=>r[n.exports.fact]},e[n.exports.approved.toLowerCase()]={kind:"bool",get:r=>r[n.exports.approved]},e[n.exports.changesRequested.toLowerCase()]={kind:"bool",get:r=>r[n.exports.changesRequested]},e[n.exports.by.toLowerCase()]={kind:"list",get:r=>r[n.exports.by]},e[n.exports.approvedBy.toLowerCase()]={kind:"list",get:r=>r[n.exports.approvedBy]}):e[n.exports.fact.toLowerCase()]={kind:t.type,get:r=>r[n.exports.fact]}}function Pw(e){const t={...Sm};for(const n of e)mA(t,n);return t}function gA(e){const t={...Zh};for(const n of e)mA(t,n);return t}function xA(e){const t=["status","priority","type","assignee","project","tag","tags","archived","title","search","created","updated","completedAt","statusAge","phase","disposition","phaseAge","hasRealObjective","acRealTotal","acRealChecked","acAllChecked","planExists","planApproved","workspaceSet","implementationStarted","depsSatisfied","unresolvedQuestions","progressStaleDays","blocked","parked","reviewRequested","pinned"],n=[];for(const r of e){const o=Nm(r);r.type==="attestation"?n.push(o.exports.fact,o.exports.approved,o.exports.changesRequested,o.exports.by,o.exports.approvedBy):n.push(o.exports.fact)}return[...t,...n]}function Tt({title:e,description:t,actions:n}){return s.jsx("div",{className:"rounded-lg border border-dashed border-border bg-muted/40 px-4 py-6 text-center",children:s.jsxs("div",{className:"mx-auto max-w-xl space-y-2",children:[s.jsx("h3",{className:"text-base font-semibold text-foreground",children:e}),s.jsx("p",{className:"text-sm leading-6 text-muted-foreground",children:t}),n?s.jsx("div",{className:"flex flex-wrap justify-center gap-3 pt-2",children:n}):null]})})}const Ql='a, button, input, select, textarea, [contenteditable="true"], [role="button"], [data-no-drag]';function Cm({columns:e,items:t,getItemId:n,getColumnId:r,renderCard:o,canDrop:i,onMove:a,getExternalDragData:l,onCardContextMenu:d,emptyMessage:f="No cards in this column.",hiddenColumnIds:p,onHideColumn:h,compact:g=!1,dragDisabled:y=!1,boundedColumns:k=!1}){const w=k&&!g,b=m.useMemo(()=>new Set(p??[]),[p]),j=m.useMemo(()=>e.filter(z=>!b.has(z.id)),[e,b]),N=m.useMemo(()=>e.filter(z=>b.has(z.id)),[e,b]),[S,C]=m.useState(null),[D,T]=m.useState(null),R=m.useRef(null),$=m.useMemo(()=>new Map(t.map(z=>[n(z),z])),[n,t]),_=m.useMemo(()=>j.map(z=>({column:z,items:t.filter(W=>r(W)===z.id)})),[j,r,t]),U=S?$.get(S)??null:null;function I(z){if(!U)return{allowed:!1};const W=r(U);return(i==null?void 0:i({item:U,fromColumnId:W,toColumnId:z}))??{allowed:!0}}function F(){C(null),T(null)}function M(z,W,V){if(y)return;const K=(l==null?void 0:l(W))??null;!a&&!K||(z.dataTransfer.effectAllowed="move",z.dataTransfer.setData("text/plain",V),K&&z.dataTransfer.setData("application/json",JSON.stringify(K)),a&&C(V))}function A(z,W,V){y||!a||!U||!I(W).allowed||(z.preventDefault(),z.dataTransfer.dropEffect="move",T(O=>(O==null?void 0:O.columnId)===W&&O.index===V?O:{columnId:W,index:V}))}async function L(z,W,V){var H;if(z.preventDefault(),y||!a||!U){F();return}const K=r(U),B=(((H=_.find(Q=>Q.column.id===K))==null?void 0:H.items)??[]).findIndex(Q=>n(Q)===n(U));if(!I(W).allowed||B<0){F();return}if(K===W&&(V===B||V===B+1)){F();return}try{await a({item:U,fromColumnId:K,toColumnId:W,fromIndex:B,toIndex:V})}finally{F()}}return s.jsxs("div",{className:"relative overflow-x-auto pb-2",style:{scrollbarColor:"oklch(var(--border)) transparent",scrollbarWidth:"thin"},children:[N.length>0&&h?s.jsxs("div",{className:"mb-2 flex flex-wrap items-center gap-2 text-xs text-muted-foreground",children:[s.jsx("span",{children:"Hidden:"}),N.map(z=>s.jsxs("button",{type:"button",onClick:()=>h(z.id),className:"rounded-full border border-dashed border-border/60 px-2 py-0.5 hover:border-border hover:text-foreground",title:`Restore "${z.title}" column`,children:[z.title," ×"]},z.id))]}):null,s.jsx("div",{className:Ce("grid min-w-max grid-flow-col items-start gap-4",g?"auto-cols-[minmax(240px,280px)]":"auto-cols-[minmax(300px,360px)]"),children:_.map(({column:z,items:W})=>{const V=I(z.id),K=(D==null?void 0:D.columnId)===z.id;return s.jsxs("section",{className:Ce("flex flex-col rounded-lg border border-border/60 bg-card/85 shadow-sm",g?"min-h-[200px] p-2":"min-h-[320px] p-3",w?"max-h-[70vh]":"",U&&!V.allowed?"border-dashed opacity-65":"",U&&V.allowed?"border-primary/30 bg-accent/30":"",K?"ring-2 ring-ring/30":""),title:U&&!V.allowed?V.reason:void 0,children:[s.jsxs("div",{className:"mb-3 flex items-start justify-between gap-3",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsx("h2",{className:Ce("font-semibold uppercase tracking-[0.16em] text-muted-foreground",g?"text-xs":"text-sm"),children:z.title}),z.description&&!g?s.jsx("p",{className:"text-sm leading-6 text-muted-foreground",children:z.description}):null]}),s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("span",{className:"rounded-full border border-border/60 bg-background/80 px-2.5 py-1 text-xs font-semibold text-foreground",children:W.length}),h?s.jsx("button",{type:"button",onClick:()=>h(z.id),className:"rounded-full border border-transparent px-1.5 py-0.5 text-xs text-muted-foreground hover:border-border hover:text-foreground",title:`Hide "${z.title}" column`,"aria-label":`Hide column ${z.title}`,children:"×"}):null]})]}),s.jsxs("div",{className:Ce("flex flex-1 flex-col gap-3",w?"min-h-0 overflow-y-auto pr-1":""),onDragOver:O=>A(O,z.id,W.length),onDrop:O=>L(O,z.id,W.length),children:[W.length===0?y?s.jsx("div",{className:"flex min-h-[128px] items-center justify-center rounded-lg border border-border/60 bg-background/50 px-4 text-center text-sm text-muted-foreground",children:typeof f=="function"?f(z):f}):s.jsx(jU,{active:(D==null?void 0:D.columnId)===z.id&&D.index===0,disabled:!!U&&!V.allowed,children:typeof f=="function"?f(z):f}):null,W.map((O,B)=>{const G=n(O),H=S===G;return s.jsxs(m.Fragment,{children:[s.jsx("div",{className:Ce("h-2 rounded-full transition",(D==null?void 0:D.columnId)===z.id&&D.index===B?"bg-primary/70":"bg-transparent"),onDragOver:Q=>A(Q,z.id,B),onDrop:Q=>L(Q,z.id,B)}),s.jsx("div",{draggable:!y&&!!(a||l),onMouseDown:Q=>{R.current=Q.target},onDragStart:Q=>{const te=R.current;if(te!=null&&te.closest(Ql)){Q.preventDefault();return}M(Q,O,G)},onDragEnd:F,onContextMenu:Q=>{if(!d)return;const te=Q.target;te!=null&&te.closest(Ql)||d(O,Q)},className:Ce("transition",!y&&(a||l)?"cursor-grab active:cursor-grabbing":"",H?"scale-[0.98] opacity-50":""),children:o(O,{dragging:H})})]},G)}),W.length>0&&!y?s.jsx("div",{className:Ce("mt-1 rounded-md border border-dashed px-3 py-2 text-center text-xs text-muted-foreground transition",(D==null?void 0:D.columnId)===z.id&&D.index===W.length?"border-primary/50 bg-primary/10 text-foreground":"border-border/60",U&&!V.allowed?"opacity-40":""),children:"Drop here to place at the end"}):null]})]},z.id)})})]})}function jU({active:e,disabled:t,children:n}){return s.jsx("div",{className:Ce("flex min-h-[128px] items-center justify-center rounded-lg border border-dashed px-4 text-center text-sm text-muted-foreground transition",e?"border-primary/60 bg-primary/10 text-foreground":"border-border/60 bg-background/50",t?"opacity-45":""),children:n})}const jo="border-status-pending-foreground/30 bg-status-pending text-status-pending-foreground",Fl="border-status-in-progress-foreground/30 bg-status-in-progress text-status-in-progress-foreground",yA="border-status-blocked-foreground/30 bg-status-blocked text-status-blocked-foreground",$b="border-status-review-foreground/30 bg-status-review text-status-review-foreground",bA="border-status-completed-foreground/30 bg-status-completed text-status-completed-foreground",vA="border-status-failed-foreground/30 bg-status-failed text-status-failed-foreground",wA="border-status-archived-foreground/30 bg-status-archived text-status-archived-foreground",zp=jo,kU={draft:jo,pending:jo,ready_for_planning:jo,ready_to_implement:Fl,in_progress:Fl,blocked:yA,review:$b,code_review:$b,completed:bA,failed:vA,active:Fl,stopped:jo,archived:wA};function SU(e){return kU[e]??zp}const NU={slate:zp,gray:zp,grey:zp};function jA(e){return e.replace(/_/g," ").replace(/\b\w/g,t=>t.toUpperCase())}function CU(e){let t=e.trim().replace(/^#/,"");return t.length===3&&(t=t.split("").map(n=>n+n).join("")),t.length!==6||/[^0-9a-fA-F]/.test(t)?null:{r:parseInt(t.slice(0,2),16),g:parseInt(t.slice(2,4),16),b:parseInt(t.slice(4,6),16)}}function EU(e,t){const n=t==null?void 0:t.trim();if(n)if(n.startsWith("#")){const r=CU(n);if(r){const{r:o,g:i,b:a}=r;return{className:"",style:{backgroundColor:`rgba(${o}, ${i}, ${a}, 0.15)`,borderColor:`rgba(${o}, ${i}, ${a}, 0.4)`,color:n}}}}else{const r=NU[n.toLowerCase()];if(r)return{className:r}}return{className:SU(e)}}function id(e,t){const n=e.find(i=>i.id===t),{className:r,style:o}=EU(t,n==null?void 0:n.color);return{label:(n==null?void 0:n.label)??jA(t),className:r,style:o,iconName:n==null?void 0:n.icon}}function Ib(e){return e?!!e.terminal||e.id==="completed"||e.id==="failed":!1}function kA(e){const t=new Map(e.statuses.map(a=>[a.id,a])),n=e.order.length>0?e.order:e.statuses.map(a=>a.id),r=new Set,o=[],i=(a,l)=>{r.has(a)||(r.add(a),o.push({id:a,label:(l==null?void 0:l.label)??jA(a),terminal:Ib(l??{id:a})}))};for(const a of n)i(a,t.get(a));for(const a of e.statuses)i(a.id,a);return o}const SA={draft:{label:"Draft",description:"Just-created stub; not yet shaped.",className:jo,icon:fc},pending:{label:"Pending",description:"Waiting to start or waiting on dependencies.",className:jo,icon:RL},ready_for_planning:{label:"Ready for Planning",description:"Objective and acceptance criteria written; awaiting a plan.",className:jo,icon:YE},ready_to_implement:{label:"Ready to Implement",description:"Plan written and approved; ready to start coding.",className:Fl,icon:ZL},in_progress:{label:"In Progress",description:"Actively being worked on.",className:Fl,icon:Dv},blocked:{label:"Blocked",description:"Blocked by an explicit obstacle that needs intervention.",className:yA,icon:eh},review:{label:"Review",description:"Ready for inspection or approval.",className:$b,icon:n4},completed:{label:"Completed",description:"Finished successfully.",className:bA,icon:Rv},failed:{label:"Failed",description:"Could not be completed as planned.",className:vA,icon:eh},active:{label:"Active",description:"The project has active or review work in flight.",className:Fl,icon:cb},stopped:{label:"Stopped",description:"Session ended without completing.",className:jo,icon:EL},archived:{label:"Archived",description:"Hidden from normal views; restorable from the Archive page.",className:wA,icon:cb}},NA="inline-flex items-center gap-1.5 whitespace-nowrap rounded-full border px-2.5 py-0.5 text-xs font-medium tracking-normal shadow-[inset_0_0_0_1px_oklch(100%_0_0_/_0)] dark:shadow-[inset_0_0_0_1px_oklch(100%_0_0_/_0.04)]";function Mb(e){var t;return((t=SA[e])==null?void 0:t.icon)??cb}function vn({status:e,className:t,showIcon:n=!0,progress:r}){var y;const o=Es(),i=id(o.statuses,e),a=Mb(e),l=i.label,d=((y=o.statuses.find(k=>k.id===e))==null?void 0:y.description)??Fd(e),f=r&&r.total>0,p=f?Math.min(1,Math.max(0,r.checked/r.total)):0,h=f?`${l} — ${d} (${r.checked}/${r.total} criteria)`:`${l} — ${d}`,g=n?f?s.jsxs("span",{className:"relative inline-flex h-3.5 w-3.5 shrink-0 items-center justify-center",children:[s.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"absolute inset-0 h-full w-full -rotate-90",children:[s.jsx("circle",{cx:"8",cy:"8",r:"7",fill:"none",stroke:"currentColor",strokeOpacity:"0.25",strokeWidth:"1.5"}),s.jsx("circle",{cx:"8",cy:"8",r:"7",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeDasharray:2*Math.PI*7,strokeDashoffset:2*Math.PI*7*(1-p)})]}),s.jsx(a,{className:"h-2.5 w-2.5"})]}):s.jsx(a,{className:"h-3.5 w-3.5 shrink-0"}):null;return s.jsxs("span",{title:h,className:Ce(NA,i.className,t),style:i.style,children:[g,s.jsx("span",{className:"min-w-0 truncate",children:l})]})}function Fd(e){var t;return((t=SA[e])==null?void 0:t.description)??`Status: ${e}`}function Ea({type:e,className:t,compact:n=!1}){const r=Rd();if(!e)return null;const o=I6(r,e),i=(o==null?void 0:o.label)??e.replace(/_/g," ").replace(/\b\w/g,l=>l.toUpperCase()),a=o!=null&&o.color?{backgroundColor:`color-mix(in oklch, ${o.color} 18%, transparent)`,borderColor:`color-mix(in oklch, ${o.color} 50%, transparent)`,color:o.color}:void 0;return s.jsx("span",{title:(o==null?void 0:o.description)??`Type: ${i}`,style:a,className:Ce("inline-flex items-center whitespace-nowrap rounded-full border text-xs capitalize",n?"px-2 py-0.5":"px-2.5 py-1",!a&&"border-border/60 text-muted-foreground",t),children:i})}async function zd(e){if(navigator.clipboard&&typeof navigator.clipboard.writeText=="function")try{return await navigator.clipboard.writeText(e),!0}catch{}return TU(e)}function TU(e){try{const t=document.createElement("textarea");t.value=e,t.setAttribute("readonly",""),t.style.position="fixed",t.style.top="0",t.style.left="0",t.style.opacity="0",t.style.pointerEvents="none",document.body.appendChild(t),t.select(),t.setSelectionRange(0,t.value.length);const n=document.execCommand("copy");return document.body.removeChild(t),n}catch{return!1}}function Zr({value:e,label:t,disabled:n=!1,disabledReason:r,onError:o}){const[i,a]=m.useState(!1);async function l(){n||(await zd(e)?(a(!0),setTimeout(()=>a(!1),1500)):o==null||o(new Error("Copy to clipboard failed in this context.")))}return n?s.jsx("button",{type:"button",disabled:!0,"aria-disabled":"true",className:"cursor-not-allowed text-muted-foreground/50",title:r??"Copy unavailable","aria-label":t??"Copy",children:s.jsx(th,{className:"h-3 w-3","aria-hidden":"true"})}):s.jsx("button",{type:"button",onClick:l,className:"text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 rounded",title:i?"Copied!":t??`Copy: ${e}`,"aria-label":t??"Copy",children:i?s.jsx(zr,{className:"h-3 w-3 text-status-completed-foreground","aria-hidden":"true"}):s.jsx(th,{className:"h-3 w-3","aria-hidden":"true"})})}function RU(e){return e.projectSlug===null?`/assignments/${e.id}`:`${e.projectWorkspace?`/w/${e.projectWorkspace}`:""}/projects/${e.projectSlug}/assignments/${e.slug}`}function AU({items:e,statusOrder:t,sortField:n,sortDirection:r,listSectionVisibility:o,compact:i=!1}){const a=Es(),[l,d]=m.useState(()=>new Set(o.collapsed));m.useEffect(()=>{d(new Set(o.collapsed))},[o]);const f=p=>{d(h=>{const g=new Set(h);return g.has(p)?g.delete(p):g.add(p),g})};return s.jsx("div",{className:Ce("space-y-2",i?"space-y-1.5":"space-y-3"),children:t.map(p=>{const h=Od(e.filter(k=>k.status===p),n,r);if(h.length===0)return null;const g=!l.has(p),y=So(a,p);return s.jsxs("div",{className:"rounded-lg border border-border/60 bg-card/90",children:[s.jsxs("button",{type:"button",onClick:()=>f(p),className:Ce("flex w-full items-center gap-2 text-left",i?"px-3 py-2 text-xs":"px-4 py-3 text-sm"),children:[s.jsx(vr,{className:Ce("text-muted-foreground transition-transform",i?"h-3.5 w-3.5":"h-4 w-4",g?"":"-rotate-90")}),s.jsx("span",{className:"font-semibold text-foreground",children:y}),s.jsx("span",{className:Ce("rounded-full border border-border/60 text-muted-foreground",i?"px-1.5 py-0 text-[10px]":"px-2 py-0.5 text-xs"),children:h.length})]}),g&&s.jsx("ul",{className:Ce("divide-y divide-border/40 border-t border-border/40",i?"text-xs":"text-sm"),children:h.map(k=>{const w=RU(k);return s.jsx("li",{children:s.jsxs(Ie,{to:w,className:Ce("flex items-center gap-3 hover:bg-muted/40",i?"px-3 py-1.5":"px-4 py-2.5"),children:[s.jsx("span",{className:"min-w-0 flex-1 truncate font-medium text-foreground",children:k.title}),k.projectTitle?s.jsx("span",{className:"hidden truncate text-muted-foreground sm:inline",children:k.projectTitle}):null,s.jsx("span",{className:"shrink-0 text-muted-foreground",children:Gn(k.updated)})]})},`${k.projectSlug??"standalone"}:${k.id}`)})})]},p)})})}function PU(e){return e.projectSlug===null?`/assignments/${e.id}`:`${e.projectWorkspace?`/w/${e.projectWorkspace}`:""}/projects/${e.projectSlug}/assignments/${e.slug}`}function _U({items:e,sortField:t,sortDirection:n,tableColumnVisibility:r,compact:o=!1}){const i=new Set(r.hidden);i.delete("title");const a=p=>!i.has(p),l=Od(e,t,n),d=o?"py-2 pr-3":"py-3 pr-4",f=o?"text-xs":"text-sm";return s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:Ce("w-full text-left",f),children:[s.jsx("thead",{children:s.jsxs("tr",{className:"border-b border-border/60 text-muted-foreground",children:[a("title")?s.jsx("th",{className:Ce("font-medium",d),children:"Assignment"}):null,a("status")?s.jsx("th",{className:Ce("font-medium",d),children:"Status"}):null,a("priority")?s.jsx("th",{className:Ce("font-medium",d),children:"Priority"}):null,a("assignee")?s.jsx("th",{className:Ce("font-medium",d),children:"Assignee"}):null,a("dependencies")?s.jsx("th",{className:Ce("font-medium",d),children:"Dependencies"}):null,a("created")?s.jsx("th",{className:Ce("font-medium",d),children:"Created"}):null,a("updated")?s.jsx("th",{className:Ce("font-medium",d),children:"Updated"}):null]})}),s.jsx("tbody",{children:l.map(p=>{const h=PU(p),g=`${p.projectSlug??"standalone"}:${p.id}`;return s.jsxs("tr",{className:"border-b border-border/50 last:border-0",children:[a("title")?s.jsxs("td",{className:d,children:[s.jsx(Ie,{to:h,className:"font-semibold text-foreground hover:text-primary",children:p.title}),p.projectTitle?s.jsx("p",{className:"mt-0.5 text-xs text-muted-foreground",children:p.projectTitle}):null]}):null,a("status")?s.jsx("td",{className:d,children:s.jsx(vn,{status:p.status,className:"max-w-[150px]"})}):null,a("priority")?s.jsx("td",{className:Ce("capitalize text-muted-foreground",d),children:p.priority}):null,a("assignee")?s.jsx("td",{className:Ce("text-muted-foreground",d),children:p.assignee??"Unassigned"}):null,a("dependencies")?s.jsx("td",{className:Ce("text-muted-foreground",d),children:p.dependsOn.length}):null,a("created")?s.jsx("td",{className:Ce("text-muted-foreground",d),children:Gn(p.created)}):null,a("updated")?s.jsx("td",{className:Ce("text-muted-foreground",d),children:Gn(p.updated)}):null]},g)})})]})})}function CA({view:e,compact:t,emptyDescription:n}){const{data:r,loading:o,error:i}=Yh(),a=Es(),l=m.useMemo(()=>a.order.map(p=>({id:p,title:So(a,p),description:Fd(p)})),[a]),d=m.useMemo(()=>gA(a.factDeclarations),[a.factDeclarations]),f=m.useMemo(()=>{if(!r)return[];const p=e.config.filters.query??Du(e.config.filters);let h=null;p.trim()!==""&&(h=Kl(p,d).query);const g=hA(r.assignments,h,{workspace:e.workspace});return Od(g,e.config.sortField,e.config.sortDirection)},[r,e,d]);if(o&&!r)return s.jsx(jt,{label:"Loading assignments…"});if(i)return s.jsxs("div",{className:"rounded-lg border border-border/60 bg-card/85 px-4 py-3 text-sm",children:[s.jsx("p",{className:"font-medium text-foreground",children:"Couldn't load assignments"}),s.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:i})]});if(f.length===0)return s.jsx(Tt,{title:"No assignments match this view.",description:n??"Adjust the view's filters to surface different work."});switch(e.config.viewMode){case"kanban":return s.jsx(Cm,{compact:t,dragDisabled:!0,columns:l,items:f,getItemId:p=>p.slug||p.id,getColumnId:p=>p.status,hiddenColumnIds:e.config.kanbanColumnVisibility.hidden,renderCard:p=>t?s.jsx(DU,{item:p}):s.jsx($U,{item:p})});case"list":return s.jsx(AU,{items:f,statusOrder:a.order,sortField:e.config.sortField,sortDirection:e.config.sortDirection,listSectionVisibility:e.config.listSectionVisibility,compact:t});case"table":return s.jsx(_U,{items:f,sortField:e.config.sortField,sortDirection:e.config.sortDirection,tableColumnVisibility:e.config.tableColumnVisibility,compact:t})}}function DU({item:e}){const t=od(e);return s.jsxs("div",{className:Ce("rounded-md border border-border/60 bg-background/85 p-2 shadow-sm"),children:[s.jsxs("div",{className:"flex items-start justify-between gap-2",children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx(Ie,{to:t,className:"block truncate text-sm font-semibold text-foreground hover:text-primary",children:e.title}),s.jsx("p",{className:"truncate text-xs text-muted-foreground",children:e.projectTitle??"Standalone"})]}),s.jsx(vn,{status:e.status,className:"max-w-[150px]"})]}),s.jsxs("div",{className:"mt-2 flex items-center justify-between gap-2 text-[10px] uppercase tracking-[0.08em] text-muted-foreground",children:[s.jsx("span",{className:"truncate",children:e.assignee??"Unassigned"}),s.jsx("span",{className:"shrink-0",children:Gn(e.updated)})]}),e.id?s.jsxs("p",{className:"mt-1 inline-flex items-center gap-1 font-mono text-[10px] text-muted-foreground/70",children:[e.id.slice(0,8),s.jsx(Zr,{value:e.id})]}):null]})}function $U({item:e}){const t=od(e);return s.jsxs("div",{className:"rounded-lg border border-border/60 bg-background/85 p-3 shadow-sm",children:[s.jsxs("div",{className:"flex items-start justify-between gap-2",children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx(Ie,{to:t,className:"block truncate text-sm font-semibold text-foreground hover:text-primary",children:e.title}),s.jsx("p",{className:"truncate text-xs text-muted-foreground",children:e.projectTitle??"Standalone"})]}),s.jsx(vn,{status:e.status,className:"max-w-[150px]"})]}),s.jsxs("div",{className:"mt-2 flex items-center justify-between gap-2",children:[s.jsx(Ea,{type:e.type,compact:!0}),s.jsx("span",{className:"text-xs capitalize text-muted-foreground",children:e.priority})]}),s.jsxs("div",{className:"mt-2 flex items-center justify-between gap-2 text-[11px] text-muted-foreground",children:[s.jsx("span",{className:"truncate",children:e.assignee??"Unassigned"}),s.jsx("span",{className:"shrink-0",children:Gn(e.updated)})]})]})}function IU({viewId:e,onPickAnother:t}){const{view:n,loading:r,error:o,refetch:i}=wi(e);return r?s.jsx(jt,{label:"Loading view…"}):o?s.jsxs("div",{className:"rounded-lg border border-border/60 bg-card/85 px-4 py-3 text-sm",children:[s.jsx("p",{className:"font-medium text-foreground",children:"Couldn't load view"}),s.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:o.message}),s.jsx("button",{type:"button",onClick:()=>i(),className:"shell-action mt-3",children:"Retry"})]}):n?s.jsx(CA,{view:n,compact:!0,emptyDescription:"Adjust the view's filters to surface different work, or pick another widget for this slot."}):s.jsxs("div",{className:"rounded-lg border border-border/60 bg-card/85 px-4 py-3 text-sm",children:[s.jsx("p",{className:"font-medium text-foreground",children:"View no longer exists"}),s.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"The saved view this slot was bound to has been deleted."}),s.jsx("button",{type:"button",onClick:t,className:"shell-action mt-3",children:"Pick another widget"})]})}function EA({sessions:e}){return s.jsxs("aside",{"aria-labelledby":"overview-sessions-title",className:"rounded-xl border border-border/60 bg-background/60 shadow-sm",children:[s.jsx("header",{className:"border-b border-border/40 px-4 py-3",children:s.jsx("h3",{id:"overview-sessions-title",className:"text-sm font-semibold text-foreground",children:"Recent Sessions"})}),e.length===0?s.jsxs("div",{className:"px-4 py-6 text-sm",children:[s.jsx("p",{className:"font-medium text-foreground",children:da.recentSessionsEmptyTitle}),s.jsx("p",{className:"mt-1 text-muted-foreground",children:da.recentSessionsEmptyHint})]}):s.jsx("ul",{className:"divide-y divide-border/40",children:e.map(t=>s.jsx("li",{children:s.jsx(MU,{session:t})},t.sessionId))})]})}function MU({session:e}){const t=pn(),[n,r]=m.useState(!1),o=LU(e,t),i=OU(e),a=!e.path;return s.jsxs("div",{className:"flex items-start gap-3 px-4 py-3",children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx(Ie,{to:o,className:"block text-sm font-medium text-foreground hover:text-primary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring rounded-sm",children:e.agent}),s.jsxs("p",{className:"text-xs text-muted-foreground",children:[i," · ",c2(e.started)]}),n&&e.path?s.jsxs("div",{className:"mt-1 space-y-0.5",children:[s.jsx("code",{className:"block w-full select-all rounded bg-muted/40 px-1.5 py-0.5 text-xs text-foreground",children:e.path}),s.jsx("p",{className:"text-[10px] text-muted-foreground",children:da.recentSessionsCopyFallbackHint})]}):null]}),s.jsx(Zr,{value:e.path,label:da.recentSessionsCopyPathLabel,disabled:a,disabledReason:da.recentSessionsCopyPathDisabled,onError:()=>r(!0)})]})}function LU(e,t){return e.projectSlug&&e.assignmentSlug?`${t}/projects/${e.projectSlug}/assignments/${e.assignmentSlug}`:(!e.projectSlug&&e.assignmentSlug,"/agent-sessions")}function OU(e){return e.assignmentSlug&&e.projectSlug?`${e.projectSlug}/${e.assignmentSlug}`:e.assignmentSlug?`standalone/${e.assignmentSlug}`:"standalone"}const FU={last_24h:1440*60*1e3,last_7d:10080*60*1e3,last_30d:720*60*60*1e3,last_90d:2160*60*60*1e3,older_7d:10080*60*1e3,older_30d:720*60*60*1e3};function ea(e){if(!e)return 0;const t=Date.parse(e);return Number.isNaN(t)?0:t}function zU(e,t,n=Date.now()){const r=ea(e);if(t.preset){const a=FU[t.preset];return a?t.preset.startsWith("older_")?r<n-a:r>=n-a:!0}const o=t.from?Date.parse(`${t.from}T00:00:00.000Z`):null,i=t.to?Date.parse(`${t.to}T23:59:59.999Z`):null;return!(o!==null&&Number.isFinite(o)&&r<o||i!==null&&Number.isFinite(i)&&r>i)}function BU(e,t,n=Date.now()){const{dateRange:r,project:o,agent:i,sessionStatus:a}=t,l=new Set(o??[]),d=new Set(i??[]),f=new Set(a??[]);return e.filter(p=>{if(r&&!zU(p.started,r,n))return!1;if(l.size>0){const h=p.projectSlug??"__standalone__";if(!l.has(h))return!1}if(d.size>0&&!Array.from(d).some(g=>g.toLowerCase()===p.agent.toLowerCase()))return!1;if(f.size>0){let h=!1;for(const g of f){switch(g){case"active":p.status==="active"&&(h=!0);break;case"ended":(p.status==="completed"||p.status==="stopped")&&(h=!0);break;case"tracked":h=!0;break}if(h)break}if(!h)return!1}return!0})}function UU(e,t,n){return[...e].sort((o,i)=>{let a=0;switch(t){case"started":a=ea(o.started)-ea(i.started);break;case"lastActivity":a=ea(o.updatedAt)-ea(i.updatedAt);break;case"projectName":{const l=o.projectSlug??"",d=i.projectSlug??"";a=l.localeCompare(d);break}case"agentName":a=o.agent.localeCompare(i.agent);break;default:a=ea(o.started)-ea(i.started);break}return n==="asc"?a:-a})}function HU(e,t){return t==null||Number.isNaN(t)||t<=0?e:e.slice(0,t)}function VU({view:e,emptyDescription:t}){const{data:n,loading:r,error:o}=Xh(),i=m.useMemo(()=>{if(!n)return[];const a=n.sessions??[],{config:l}=e,d=l.filters,f={dateRange:d.dateRange?{...d.dateRange,field:"started"}:void 0,project:Ke(d.project),agent:Ke(d.agent),sessionStatus:Ke(d.sessionStatus),limit:l.limit};let p=BU(a,f);return p=UU(p,l.sortField,l.sortDirection),p=HU(p,l.limit),p},[n,e]);return r&&!n?s.jsx(jt,{label:"Loading sessions…"}):o?s.jsxs("div",{className:"rounded-lg border border-border/60 bg-card/85 px-4 py-3 text-sm",children:[s.jsx("p",{className:"font-medium text-foreground",children:"Couldn't load sessions"}),s.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:o})]}):i.length===0?s.jsx(Tt,{title:"No sessions match this view.",description:t??"Adjust the view's filters to surface different sessions."}):s.jsx(EA,{sessions:i})}function WU({activeViewId:e,onSelectView:t,onCreateNew:n}){const{views:r,loading:o}=Id(),[i,a]=m.useState(!1),l=m.useRef(null),d=m.useMemo(()=>r.filter(h=>h.entityType==="session"),[r]);m.useEffect(()=>{if(!i)return;function h(y){l.current&&!l.current.contains(y.target)&&a(!1)}function g(y){y.key==="Escape"&&a(!1)}return document.addEventListener("mousedown",h),document.addEventListener("keydown",g),()=>{document.removeEventListener("mousedown",h),document.removeEventListener("keydown",g)}},[i]);const f=e?r.find(h=>h.id===e)??null:null,p=o?"Session views…":f?f.name:"Session views";return s.jsxs("div",{className:"relative",ref:l,children:[s.jsxs("button",{type:"button",disabled:o,onClick:()=>a(h=>!h),className:"inline-flex items-center gap-1.5 rounded-md border border-border/60 bg-background/60 px-2.5 py-1.5 text-xs font-medium text-foreground hover:bg-background disabled:opacity-50","aria-haspopup":"true","aria-expanded":i,title:"Session views",children:[s.jsx("span",{className:"max-w-[160px] truncate",children:p}),s.jsx(vr,{className:"h-3.5 w-3.5","aria-hidden":"true"})]}),i&&s.jsxs("div",{className:"absolute right-0 top-full z-30 mt-1 min-w-[240px] rounded-md border border-border/70 bg-background shadow-lg py-1",children:[s.jsxs("button",{type:"button",onClick:()=>{a(!1),t(null)},className:Ce("flex w-full items-center gap-2 px-3 py-1.5 text-left text-sm transition hover:bg-foreground/5",!e&&"font-semibold text-foreground"),children:[s.jsx("span",{className:"inline-flex h-4 w-4 shrink-0 items-center justify-center",children:e?null:s.jsx(zr,{className:"h-3.5 w-3.5","aria-hidden":"true"})}),s.jsx("span",{children:"All sessions"})]}),d.length>0&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"my-1 border-t border-border/40"}),d.map(h=>{const g=h.id===e;return s.jsxs("button",{type:"button",onClick:()=>{a(!1),t(h.id)},className:Ce("flex w-full items-center gap-2 px-3 py-1.5 text-left text-sm transition hover:bg-foreground/5",g&&"font-semibold text-foreground"),children:[s.jsx("span",{className:"inline-flex h-4 w-4 shrink-0 items-center justify-center",children:g?s.jsx(zr,{className:"h-3.5 w-3.5","aria-hidden":"true"}):null}),s.jsx("span",{className:"truncate",children:h.name})]},h.id)})]}),s.jsx("div",{className:"my-1 border-t border-border/40"}),s.jsxs("button",{type:"button",onClick:()=>{a(!1),n()},className:"flex w-full items-center gap-2 px-3 py-1.5 text-left text-sm transition hover:bg-foreground/5 text-muted-foreground",children:[s.jsx(It,{className:"h-3.5 w-3.5 shrink-0","aria-hidden":"true"}),s.jsx("span",{children:"Create new view…"})]})]})]})}const qU={__unassigned__:"Unassigned",__standalone__:"No project"};function yn({options:e,value:t,onChange:n,allLabel:r="Any",className:o,disabled:i,ariaLabel:a}){const[l,d]=m.useState(!1),f=m.useRef(null),p=m.useRef(null),h=m.useRef([]),g=m.useMemo(()=>{const N=new Set(e.map(C=>C.value)),S=t.filter(C=>!N.has(C)).map(C=>({value:C,label:qU[C]??C}));return[...e,...S]},[e,t]),y=m.useMemo(()=>new Set(t),[t]);m.useEffect(()=>{if(!l)return;function N(S){f.current&&!f.current.contains(S.target)&&d(!1)}return document.addEventListener("mousedown",N),()=>document.removeEventListener("mousedown",N)},[l]),m.useEffect(()=>{var N;l&&((N=h.current[0])==null||N.focus())},[l]);const k=m.useMemo(()=>{if(t.length===0)return r;if(t.length===1){const N=g.find(S=>S.value===t[0]);return N?N.label:t[0]}return`${t.length} selected`},[t,g,r]);function w(N){n(y.has(N)?t.filter(S=>S!==N):[...t,N])}function b(N){var C;const S=Math.max(0,Math.min(N,g.length-1));(C=h.current[S])==null||C.focus()}function j(N){var T;const S=h.current,C=document.activeElement,D=S.findIndex(R=>R===C);N.key==="ArrowDown"?(N.preventDefault(),b(D<0?0:D+1)):N.key==="ArrowUp"?(N.preventDefault(),b(D<0?g.length-1:D-1)):N.key==="Home"?(N.preventDefault(),b(0)):N.key==="End"?(N.preventDefault(),b(g.length-1)):N.key==="Escape"&&(N.preventDefault(),d(!1),(T=p.current)==null||T.focus())}return s.jsxs("div",{className:"relative",ref:f,children:[s.jsxs("button",{type:"button",ref:p,disabled:i,"aria-haspopup":"menu","aria-expanded":l,"aria-label":a,onClick:()=>d(N=>!N),onKeyDown:N=>{!l&&(N.key==="ArrowDown"||N.key==="ArrowUp")&&(N.preventDefault(),d(!0))},className:Ce("editor-input inline-flex items-center justify-between gap-1.5 text-left",t.length>0&&"border-foreground/40 text-foreground",o),children:[s.jsx("span",{className:"truncate",children:k}),s.jsx(vr,{className:"h-3.5 w-3.5 shrink-0 opacity-60","aria-hidden":"true"})]}),l?s.jsxs("div",{role:"menu","aria-label":a,onKeyDown:j,className:"absolute left-0 top-full z-30 mt-1 max-h-72 min-w-[200px] overflow-auto rounded-md border border-border/70 bg-background py-1 shadow-lg",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2 px-2 pb-1",children:[s.jsx("button",{type:"button",role:"menuitem",className:"text-xs text-muted-foreground hover:text-foreground disabled:opacity-40",disabled:t.length===g.length,onClick:()=>n(g.map(N=>N.value)),children:"Select all"}),s.jsx("button",{type:"button",role:"menuitem",className:"text-xs text-muted-foreground hover:text-foreground disabled:opacity-40",disabled:t.length===0,onClick:()=>n([]),children:"Clear"})]}),g.length===0?s.jsx("p",{className:"px-3 py-1.5 text-xs text-muted-foreground",children:"No options"}):g.map((N,S)=>{const C=y.has(N.value);return s.jsxs("button",{ref:D=>{h.current[S]=D},type:"button",role:"menuitemcheckbox","aria-checked":C,tabIndex:-1,onClick:()=>w(N.value),className:Ce("flex w-full items-center gap-2 px-3 py-1.5 text-left text-sm transition hover:bg-foreground/5",C?"text-foreground":"text-muted-foreground"),children:[s.jsx("span",{className:Ce("flex h-4 w-4 shrink-0 items-center justify-center rounded border",C?"border-foreground bg-foreground text-background":"border-border/70"),"aria-hidden":"true",children:C?s.jsx(zr,{className:"h-3 w-3"}):null}),s.jsx("span",{className:"truncate",children:N.label})]},N.value)})]}):null]})}const xS={last_24h:"Last 24 hours",last_7d:"Last 7 days",last_30d:"Last 30 days",last_90d:"Last 90 days",older_7d:"Older than 7 days",older_30d:"Older than 30 days"},KU=["updated","created"];function Em({value:e,onChange:t,className:n,ariaLabel:r="Date range filter"}){const[o,i]=m.useState(!1),a=m.useRef(null),l=(e==null?void 0:e.field)??"updated",d=!!(e&&!e.preset&&(e.from||e.to)),[f,p]=m.useState(d);m.useEffect(()=>p(d),[d]),m.useEffect(()=>{if(!o)return;function j(S){a.current&&!a.current.contains(S.target)&&i(!1)}function N(S){S.key==="Escape"&&i(!1)}return document.addEventListener("mousedown",j),document.addEventListener("keydown",N),()=>{document.removeEventListener("mousedown",j),document.removeEventListener("keydown",N)}},[o]);const h=!!(e&&(e.preset||e.from||e.to)),g=m.useMemo(()=>!h||!e?"Any date":e.preset?`${l}: ${xS[e.preset]??e.preset}`:`${l}: ${e.from||"…"} → ${e.to||"…"}`,[h,e,l]);function y(j){t(e?{...e,field:j}:{field:j,preset:"",from:"",to:""})}function k(j){p(!1),t({field:l,preset:j,from:"",to:""})}function w(){p(!1),t(null)}function b(j,N){const S={field:l,preset:"",from:(e==null?void 0:e.from)??"",to:(e==null?void 0:e.to)??""};t({...S,[j]:N})}return s.jsxs("div",{className:"relative",ref:a,children:[s.jsxs("button",{type:"button","aria-haspopup":"dialog","aria-expanded":o,"aria-label":r,onClick:()=>i(j=>!j),className:Ce("editor-input inline-flex items-center justify-between gap-1.5 text-left",h&&"border-foreground/40 text-foreground",n),children:[s.jsx("span",{className:"truncate",children:g}),s.jsx(vr,{className:"h-3.5 w-3.5 shrink-0 opacity-60","aria-hidden":"true"})]}),o?s.jsxs("div",{className:"absolute left-0 top-full z-30 mt-1 w-64 rounded-md border border-border/70 bg-background p-2 shadow-lg",children:[s.jsx("div",{className:"mb-2 inline-flex rounded-md border border-border/60 bg-background/80 p-0.5",children:KU.map(j=>s.jsx("button",{type:"button","aria-pressed":l===j,onClick:()=>y(j),className:Ce("rounded-sm px-2.5 py-1 text-xs font-medium capitalize transition",l===j?"bg-foreground text-background":"text-muted-foreground hover:text-foreground"),children:j},j))}),s.jsxs("div",{className:"space-y-0.5",children:[s.jsx(py,{label:"Any date",selected:!h,onClick:w}),l6.map(j=>s.jsx(py,{label:xS[j],selected:(e==null?void 0:e.preset)===j,onClick:()=>k(j)},j)),s.jsx(py,{label:"Custom range…",selected:f,onClick:()=>{p(!0),t({field:l,preset:"",from:(e==null?void 0:e.from)??"",to:(e==null?void 0:e.to)??""})}})]}),f?s.jsxs("div",{className:"mt-2 space-y-1.5 border-t border-border/60 pt-2",children:[s.jsxs("label",{className:"flex items-center justify-between gap-2 text-xs text-muted-foreground",children:["From",s.jsx("input",{type:"date",value:(e==null?void 0:e.from)??"",max:(e==null?void 0:e.to)||void 0,onChange:j=>b("from",j.target.value),className:"editor-input w-40"})]}),s.jsxs("label",{className:"flex items-center justify-between gap-2 text-xs text-muted-foreground",children:["To",s.jsx("input",{type:"date",value:(e==null?void 0:e.to)??"",min:(e==null?void 0:e.from)||void 0,onChange:j=>b("to",j.target.value),className:"editor-input w-40"})]})]}):null]}):null]})}function py({label:e,selected:t,onClick:n}){return s.jsxs("button",{type:"button",onClick:n,className:Ce("flex w-full items-center justify-between gap-2 rounded px-2 py-1.5 text-left text-sm transition hover:bg-foreground/5",t?"text-foreground":"text-muted-foreground"),children:[s.jsx("span",{children:e}),t?s.jsx(zr,{className:"h-3.5 w-3.5 shrink-0","aria-hidden":"true"}):null]})}const GU=new Set(["status","type","priority","assignee","project","tags","activity","dateRange","search","query","sessionStatus","agent"]);function YU(e,t){const n={};for(const[r,o]of Object.entries(e))GU.has(r)||(n[r]=o);return{...n,...t}}function yh(e,t,n){return{...e,viewMode:t.viewMode,filters:YU(e.filters,t.filters),sortField:t.sortField,sortDirection:t.sortDirection,limit:t.limit,listSectionVisibility:{collapsed:[...n.listSectionVisibility.collapsed]},kanbanColumnVisibility:{hidden:[...n.kanbanColumnVisibility.hidden]},tableColumnVisibility:{hidden:[...n.tableColumnVisibility.hidden]}}}function XU(e,t){var g,y;const n={},r=Ke(e.status);r.length&&(n.status=r);const o=Ke(e.type);o.length&&(n.type=o);const i=Ke(e.priority);i.length&&(n.priority=i);const a=Ke(e.assignee);a.length&&(n.assignee=a);const l=Ke(e.tags);if(l.length&&(n.tags=l),t&&t!=="all")n.project=[t];else{const k=Ke(e.project);k.length&&(n.project=k)}e.activity&&e.activity!=="all"&&(n.activity=e.activity);const d=Ke(e.sessionStatus);d.length&&(n.sessionStatus=d);const f=Ke(e.agent);f.length&&(n.agent=f),e.dateRange&&(n.dateRange=e.dateRange);const p=(g=e.search)==null?void 0:g.trim();p&&(n.search=p);const h=(y=e.query)==null?void 0:y.trim();return h&&(n.query=h),n}function Jl(e){const t={viewMode:e.state.viewMode,filters:XU(e.state.filters,e.context.projectSlug),sortField:e.state.sortField,sortDirection:e.state.sortDirection,listSectionVisibility:{collapsed:[...e.state.listSectionVisibility.collapsed]},kanbanColumnVisibility:{hidden:[...e.state.kanbanColumnVisibility.hidden]},tableColumnVisibility:{hidden:[...e.state.tableColumnVisibility.hidden]}};return{name:e.name.trim(),workspace:e.context.workspace,config:t}}const fl={viewMode:"kanban",sortField:"updated",sortDirection:"desc"},lp={sortField:"started",sortDirection:"desc"};function TA(e,t){const{config:n}=Jl({name:"",context:{workspace:t,projectSlug:null},state:{viewMode:e.viewMode,filters:e.filters,sortField:e.sortField,sortDirection:e.sortDirection,listSectionVisibility:{collapsed:[]},kanbanColumnVisibility:{hidden:[]},tableColumnVisibility:{hidden:[]}}}),r={...n};return e.limit!==void 0&&e.limit>0&&(r.limit=e.limit),{workspace:t,config:r}}function _w(e,t){const{config:n}=Jl({name:"",context:{workspace:t,projectSlug:null},state:{viewMode:"list",filters:e.filters,sortField:e.sortField,sortDirection:e.sortDirection,listSectionVisibility:{collapsed:[]},kanbanColumnVisibility:{hidden:[]},tableColumnVisibility:{hidden:[]}}}),r={...n};return e.limit!==void 0&&e.limit>0&&(r.limit=e.limit),{workspace:t,config:r}}function pa(e){if(!e)return;if(e.preset)return{field:e.field,preset:e.preset};const t=e.from&&e.from.length>0?e.from:void 0,n=e.to&&e.to.length>0?e.to:void 0;if(!t&&!n)return;const r={field:e.field};return t&&(r.from=t),n&&(r.to=n),r}function Tm(e){return e?{field:e.field,preset:e.preset??"",from:e.from??"",to:e.to??""}:null}function RA(e,t){var r,o,i,a,l,d,f,p,h,g,y,k,w,b,j;const{config:n}=e;if((r=t.setViewMode)==null||r.call(t,n.viewMode),(o=t.setStatusFilter)==null||o.call(t,Ke(n.filters.status)),(i=t.setTypeFilter)==null||i.call(t,Ke(n.filters.type)),(a=t.setPriorityFilter)==null||a.call(t,Ke(n.filters.priority)),(l=t.setAssigneeFilter)==null||l.call(t,Ke(n.filters.assignee)),(d=t.setProjectFilter)==null||d.call(t,Ke(n.filters.project)),(f=t.setTagsFilter)==null||f.call(t,Ke(n.filters.tags)),(p=t.setDateRange)==null||p.call(t,Tm(n.filters.dateRange)),(h=t.setSearch)==null||h.call(t,n.filters.search??""),(g=t.setQuery)==null||g.call(t,n.filters.query??Du(n.filters)),t.setActivityFilter){const N=n.filters.activity??"all";t.setActivityFilter(N==="fresh"||N==="stale"?N:"all")}(y=t.setSortField)==null||y.call(t,n.sortField),(k=t.setSortDirection)==null||k.call(t,n.sortDirection),(w=t.setListSectionVisibility)==null||w.call(t,{collapsed:[...n.listSectionVisibility.collapsed]}),(b=t.setKanbanColumnVisibility)==null||b.call(t,{hidden:[...n.kanbanColumnVisibility.hidden]}),(j=t.setTableColumnVisibility)==null||j.call(t,{hidden:[...n.tableColumnVisibility.hidden]})}function Bp(e){return e?`/w/${e}/views`:"/views"}function AA(e){return`${Bp(e.workspace)}/${encodeURIComponent(e.id)}`}function PA(e){const t=e.workspace?`/w/${e.workspace}`:"",n=Ke(e.config.filters.project);return n.length===1&&n[0]!=="__standalone__"&&TR(e.config,n[0])?`${t}/projects/${n[0]}?tab=assignments&loadView=${encodeURIComponent(e.id)}`:`${t}/assignments?loadView=${encodeURIComponent(e.id)}`}const QU=["critical","high","medium","low"],JU={last_24h:"last 24 hours",last_7d:"last 7 days",last_30d:"last 30 days",last_90d:"last 90 days",older_7d:"older than 7 days",older_30d:"older than 30 days"};function ZU(e){if(e.preset)return`${e.field} ${JU[e.preset]??e.preset}`;const t=e.from??"…",n=e.to??"…";return`${e.field} ${t}→${n}`}function _A(e){var o,i;const t=(o=e.query)==null?void 0:o.trim();if(t&&$u(t)===null)return`query: ${t}`;const n=[];for(const a of["status","priority","type","assignee","project","tags"]){const l=Ke(e[a]);l.length&&n.push(`${a}=${l.join(", ")}`)}e.activity&&e.activity!=="all"&&n.push(`activity=${e.activity}`),e.dateRange&&n.push(ZU(e.dateRange));const r=(i=e.search)==null?void 0:i.trim();return r&&n.push(`search="${r}"`),n.join(" · ")||"no filters"}const yS=80,eH=["started","lastActivity","projectName","agentName"],tH={started:"Start time",lastActivity:"Last updated",projectName:"Project",agentName:"Agent"},nH=[{value:"active",label:"Active"},{value:"ended",label:"Ended"},{value:"tracked",label:"Tracked"},{value:"untracked",label:"Untracked"}];function DA({open:e,onOpenChange:t,initialView:n,onSubmit:r}){const o=!!n,{data:i}=Zs(),{data:a}=Xh(),[l,d]=m.useState(""),[f,p]=m.useState([]),[h,g]=m.useState([]),[y,k]=m.useState([]),[w,b]=m.useState(null),[j,N]=m.useState(lp.sortField),[S,C]=m.useState(lp.sortDirection),[D,T]=m.useState(""),[R,$]=m.useState(!1),[_,U]=m.useState(null);function I(){p([]),g([]),k([]),b(null),N(lp.sortField),C(lp.sortDirection),T("")}m.useEffect(()=>{if(e)if(U(null),$(!1),n){const V=n.config.filters;d(n.name),p(Ke(V.project)),g(Ke(V.agent)),k(Ke(V.sessionStatus)),b(Tm(V.dateRange)),N(n.config.sortField),C(n.config.sortDirection),T(n.config.limit!==void 0?String(n.config.limit):"")}else d(""),I()},[e,n]);const F=m.useMemo(()=>[{value:"__standalone__",label:"No project"},...(i??[]).map(K=>({value:K.slug,label:K.title}))],[i]),M=m.useMemo(()=>{const V=new Set;for(const K of(a==null?void 0:a.sessions)??[])K.agent&&V.add(K.agent);return Array.from(V).sort().map(K=>({value:K,label:K}))},[a]),A=l.trim(),L=A.length>0&&A.length<=yS,z=D.trim()===""?void 0:parseInt(D.trim(),10),W=D.trim()===""||Number.isFinite(z)&&z!==void 0&&z>0&&z<=500;return s.jsx(Ln,{open:e,onOpenChange:t,children:s.jsx(jn,{className:"max-w-lg",children:s.jsxs("form",{className:"space-y-4",onSubmit:async V=>{if(V.preventDefault(),!L||!W||R)return;$(!0),U(null);const K=pa(w),O=K?{...K,field:"started"}:void 0,B={filters:{project:f,agent:h,sessionStatus:y,dateRange:O},sortField:j,sortDirection:S,limit:z};try{await r(A,B)}catch(G){U(G instanceof Error?G.message:String(G)),$(!1)}},children:[s.jsx(er,{children:s.jsx(kn,{children:o?"Edit session view":"Create session view"})}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{className:"block text-xs font-medium text-muted-foreground",htmlFor:"create-session-view-name",children:"Name"}),s.jsx("input",{id:"create-session-view-name",type:"text",value:l,autoFocus:!0,required:!0,maxLength:yS,onChange:V=>d(V.target.value),placeholder:"View name",className:"w-full rounded-md border border-border/70 bg-background px-3 py-2 text-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"})]}),s.jsxs("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2",children:[s.jsx(pl,{label:"Date range (session start)",children:s.jsx(Em,{className:"w-full",value:w,onChange:b})}),s.jsx(pl,{label:"Project",children:s.jsx(yn,{ariaLabel:"Project filter",className:"w-full",allLabel:"All projects",options:F,value:f,onChange:p})}),s.jsx(pl,{label:"Agent",children:s.jsx(yn,{ariaLabel:"Agent filter",className:"w-full",allLabel:"All agents",options:M,value:h,onChange:g})}),s.jsx(pl,{label:"Session status",children:s.jsx(yn,{ariaLabel:"Session status filter",className:"w-full",allLabel:"All statuses",options:nH,value:y,onChange:k})}),s.jsx(pl,{label:"Sort by",className:"sm:col-span-2",children:s.jsxs("div",{className:"flex gap-2",children:[s.jsx("select",{value:j,onChange:V=>N(V.target.value),className:"editor-input w-full",children:eH.map(V=>s.jsx("option",{value:V,children:tH[V]??V},V))}),s.jsx("button",{type:"button",onClick:()=>C(V=>V==="asc"?"desc":"asc"),className:"shell-action shrink-0",title:S==="asc"?"Ascending":"Descending",children:S==="asc"?"Asc":"Desc"})]})}),s.jsxs(pl,{label:"Max results",className:"sm:col-span-2",children:[s.jsx("input",{type:"number",min:1,max:500,value:D,onChange:V=>T(V.target.value),placeholder:"No limit",className:"editor-input w-full"}),W?null:s.jsx("p",{className:"mt-1 text-xs text-error-foreground",children:"Limit must be between 1 and 500"})]})]}),_?s.jsx("p",{className:"text-xs text-error-foreground",role:"alert",children:_}):null,s.jsxs(Ur,{className:"sm:justify-between",children:[s.jsx("button",{type:"button",onClick:I,className:"shell-action",disabled:R,children:"Clear all"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("button",{type:"button",onClick:()=>t(!1),className:"shell-action",disabled:R,children:"Cancel"}),s.jsx("button",{type:"submit",disabled:!L||!W||R,className:"shell-action shell-action--cta disabled:opacity-50",children:R?"Saving…":o?"Save changes":"Create view"})]})]})]})})})}function pl({label:e,className:t,children:n}){return s.jsxs("label",{className:`space-y-1 ${t??""}`,children:[s.jsx("span",{className:"block text-xs font-medium text-muted-foreground",children:e}),n]})}function hy({title:e,message:t,onPickAnother:n}){return s.jsxs("div",{className:"rounded-lg border border-border/60 bg-card/85 px-4 py-3 text-sm",children:[s.jsx("p",{className:"font-medium text-foreground",children:e}),s.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:t}),n?s.jsx("button",{type:"button",onClick:n,className:"shell-action mt-3",children:"Pick another widget"}):null]})}function rH({viewId:e,slotId:t,onPickAnother:n}){const{data:r,loading:o,error:i}=Xh(),{view:a,loading:l,ready:d}=wi(e??null),{layout:f}=IR(),{showToast:p}=wr(),[h,g]=m.useState(!1),y=m.useCallback(async b=>{if(!t)return;const j=f.slots.map(N=>N.id===t?{...N,widget:b?{kind:"agent-sessions",viewId:b}:{kind:"agent-sessions"}}:N);try{await Eb(j)}catch(N){p(N instanceof Error?N.message:"Failed to update widget")}},[f,t,p]);async function k(b,j){const{workspace:N,config:S}=_w(j,null);try{const D=(await Gl({name:b,workspace:N,config:S,entityType:"session"})).views.find(T=>T.name===b&&T.entityType==="session");D&&await y(D.id),g(!1),p(`Created session view "${b}"`)}catch(C){throw p(C instanceof Error?C.message:"Failed to create session view"),C}}let w;return e?l&&!d?w=s.jsx(jt,{label:"Loading view…"}):a?a.entityType!=="session"?w=s.jsx(hy,{title:"Wrong view type",message:"This widget is bound to an assignment view. Choose a session view above, or pick a different widget.",onPickAnother:n}):w=s.jsx(VU,{view:a,emptyDescription:"Adjust the view's filters to surface different sessions, or pick another widget for this slot."}):w=s.jsx(hy,{title:"View no longer exists",message:"The saved view this widget was bound to has been deleted. Pick another session view above, or choose a different widget.",onPickAnother:n}):o&&!r?w=s.jsx(jt,{label:"Loading sessions…"}):i?w=s.jsx(hy,{title:"Couldn't load sessions",message:i}):w=s.jsx(EA,{sessions:(r==null?void 0:r.sessions)??[]}),s.jsxs("div",{className:"space-y-2",children:[t?s.jsx("div",{className:"flex items-center justify-between gap-2",children:s.jsx(WU,{activeViewId:e??null,onSelectView:b=>void y(b),onCreateNew:()=>g(!0)})}):null,w,s.jsx(DA,{open:h,onOpenChange:g,workspace:null,onSubmit:k})]})}const sH=5;function oH(){const{data:e,loading:t,error:n}=E2();if(t&&!e)return s.jsx(jt,{label:"Loading inventories…"});if(n)return s.jsxs("div",{className:"rounded-lg border border-border/60 bg-card/85 px-4 py-3 text-sm text-muted-foreground",children:[s.jsx("p",{className:"font-medium text-foreground",children:"Couldn't load inventories"}),s.jsx("p",{className:"mt-1 text-xs",children:n})]});const o=((e==null?void 0:e.inventories)??[]).slice(0,sH);return s.jsxs("aside",{"aria-labelledby":"overview-inventories-title",className:"rounded-xl border border-border/60 bg-background/60 shadow-sm",children:[s.jsxs("header",{className:"flex items-center justify-between border-b border-border/40 px-4 py-3",children:[s.jsx("h3",{id:"overview-inventories-title",className:"text-sm font-semibold text-foreground",children:"Inventories"}),s.jsx(Ie,{to:"/inventories",className:"text-xs text-muted-foreground hover:text-foreground",children:"View all →"})]}),o.length===0?s.jsxs("div",{className:"px-4 py-6 text-sm",children:[s.jsx("p",{className:"font-medium text-foreground",children:"No inventories yet."}),s.jsx("p",{className:"mt-1 text-muted-foreground",children:"Create one to track leased resources across agents."})]}):s.jsx("ul",{className:"divide-y divide-border/40",children:o.map(i=>{const a=i.inventory,l=i.active_leases.length,d=i.members.length,f=a.display_name??a.slug;return s.jsx("li",{children:s.jsxs(Ie,{to:`/inventories/${encodeURIComponent(a.slug)}`,className:"flex items-center gap-3 px-4 py-2.5 text-sm hover:bg-muted/40",children:[s.jsx("span",{className:"min-w-0 flex-1 truncate font-medium text-foreground",children:f}),s.jsxs("span",{className:"shrink-0 text-xs text-muted-foreground",children:[l,"/",d," leased"]})]})},a.slug)})})]})}function iH(e){let t=0,n=0;for(const r of e.daily)t+=r.total_tokens,n+=r.total_cost;return{tokens:t,cost:n}}function bS({filters:e,metric:t}){const n=e??{},{data:r,loading:o,error:i}=bO(n),a=t==="cost"?"Spend":"Token Usage",l=`/usage?${hb(n).toString()}`;let d;if(o&&!r)d=s.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading…"});else if(i&&!r)d=s.jsxs("div",{className:"text-sm",children:[s.jsx("p",{className:"font-medium text-foreground",children:"Couldn't load usage"}),s.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:i})]});else if(!r||r.daily.length===0)d=s.jsx("p",{className:"text-sm text-muted-foreground",children:"No usage for these filters."});else{const{tokens:f,cost:p}=iH(r),h=t==="cost"?{label:"Total spend",value:ql(p)}:{label:"Total tokens",value:Wl(f)},g=t==="cost"?{label:"Tokens",value:Wl(f)}:{label:"Spend",value:ql(p)};d=s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsx(vS,{label:h.label,value:h.value,emphasize:!0}),s.jsx(vS,{label:g.label,value:g.value})]})}return s.jsxs("aside",{className:"rounded-xl border border-border/60 bg-background/60 shadow-sm",children:[s.jsxs("header",{className:"flex items-center justify-between gap-2 border-b border-border/40 px-4 py-3",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("h3",{className:"text-sm font-semibold text-foreground",children:a}),s.jsx("p",{className:"truncate text-xs text-muted-foreground",title:x1(n),children:x1(n)})]}),s.jsx(Ie,{to:l,className:"shrink-0 text-xs text-muted-foreground hover:text-foreground",children:"View all →"})]}),s.jsx("div",{className:"px-4 py-4",children:d})]})}function vS({label:e,value:t,emphasize:n}){return s.jsxs("div",{className:"space-y-0.5",children:[s.jsx("p",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:e}),s.jsx("p",{className:n?"text-2xl font-semibold tabular-nums text-foreground":"text-lg font-semibold tabular-nums text-foreground",children:t})]})}const aH={"7d":"7 days","30d":"30 days","90d":"90 days",all:"All time",custom:"Custom"};function lH(e){return e.kind==="token-usage"||e.kind==="spend"?e.filters??{}:{}}const hl="bg-background border border-border rounded px-2 py-1 text-sm text-foreground";function wS({config:e,open:t,onSave:n,onCancel:r}){const o=e.kind==="spend"?"Configure Spend":"Configure Token Usage",{data:i}=Zs(),{data:a}=Sa(),{data:l}=T2(t),[d,f]=m.useState("30d"),[p,h]=m.useState(""),[g,y]=m.useState(""),[k,w]=m.useState(""),[b,j]=m.useState(""),[N,S]=m.useState(""),[C,D]=m.useState(""),[T,R]=m.useState(!1),[$,_]=m.useState(null);m.useEffect(()=>{if(!t)return;const L=lH(e);f(L.window??"30d"),h(L.since??""),y(L.until??""),w(L.project??""),j(L.workspace??""),S(L.model??""),D(L.tool??""),R(!1),_(null)},[t,e]);function U(){return Td({window:d,since:d==="custom"?p:void 0,until:d==="custom"?g:void 0,project:k||void 0,workspace:b||void 0,model:N||void 0,tool:C||void 0})}async function I(L){if(L.preventDefault(),T)return;const z=U(),W=lO(z);if(!W.ok){_(W.errors.join("; "));return}R(!0),_(null);const V=e.kind==="token-usage"?{kind:"token-usage",filters:z}:e.kind==="spend"?{kind:"spend",filters:z}:e;try{await n(V)}catch(K){_(K instanceof Error?K.message:String(K)),R(!1)}}const F=(i==null?void 0:i.map(L=>L.slug))??[],M=(a==null?void 0:a.workspaces)??[],A=(a==null?void 0:a.hasUngrouped)??!1;return s.jsx(Ln,{open:t,onOpenChange:L=>{L||r()},children:s.jsx(jn,{className:"max-w-md",children:s.jsxs("form",{onSubmit:I,children:[s.jsx(er,{children:s.jsx(kn,{children:o})}),s.jsxs("div",{className:"space-y-4 py-2",children:[s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("span",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"Window"}),s.jsx("div",{className:"flex flex-wrap gap-1.5",children:Gh.map(L=>s.jsx("button",{type:"button",onClick:()=>f(L),className:"rounded px-2.5 py-1 text-sm border "+(L===d?"border-primary bg-primary/10 text-foreground":"border-border text-muted-foreground hover:text-foreground"),children:aH[L]},L))})]}),d==="custom"?s.jsxs("div",{className:"flex gap-3",children:[s.jsxs("label",{className:"flex flex-1 flex-col gap-1 text-sm",children:[s.jsx("span",{className:"text-muted-foreground",children:"Since"}),s.jsx("input",{type:"date",value:p,onChange:L=>h(L.target.value),className:hl})]}),s.jsxs("label",{className:"flex flex-1 flex-col gap-1 text-sm",children:[s.jsx("span",{className:"text-muted-foreground",children:"Until"}),s.jsx("input",{type:"date",value:g,onChange:L=>y(L.target.value),className:hl})]})]}):null,s.jsxs("label",{className:"flex flex-col gap-1 text-sm",children:[s.jsx("span",{className:"text-muted-foreground",children:"Workspace"}),s.jsxs("select",{value:b,onChange:L=>{j(L.target.value),L.target.value&&w("")},className:hl,children:[s.jsx("option",{value:"",children:"All workspaces"}),A?s.jsx("option",{value:"_ungrouped",children:"(ungrouped)"}):null,M.map(L=>s.jsx("option",{value:L,children:L},L))]})]}),s.jsxs("label",{className:"flex flex-col gap-1 text-sm",children:[s.jsx("span",{className:"text-muted-foreground",children:"Project"}),s.jsxs("select",{value:k,onChange:L=>{w(L.target.value),L.target.value&&j("")},className:hl,children:[s.jsx("option",{value:"",children:"All projects"}),F.map(L=>s.jsx("option",{value:L,children:L},L))]})]}),s.jsxs("div",{className:"flex gap-3",children:[s.jsxs("label",{className:"flex flex-1 flex-col gap-1 text-sm",children:[s.jsx("span",{className:"text-muted-foreground",children:"Model"}),s.jsxs("select",{value:N,onChange:L=>S(L.target.value),className:hl,children:[s.jsx("option",{value:"",children:"All models"}),((l==null?void 0:l.models)??[]).map(L=>s.jsx("option",{value:L,children:L},L))]})]}),s.jsxs("label",{className:"flex flex-1 flex-col gap-1 text-sm",children:[s.jsx("span",{className:"text-muted-foreground",children:"Tool"}),s.jsxs("select",{value:C,onChange:L=>D(L.target.value),className:hl,children:[s.jsx("option",{value:"",children:"All tools"}),((l==null?void 0:l.tools)??[]).map(L=>s.jsx("option",{value:L,children:L},L))]})]})]}),$?s.jsx("p",{className:"text-xs text-destructive",role:"alert",children:$}):null]}),s.jsxs(Ur,{className:"sm:justify-between",children:[s.jsx("button",{type:"button",onClick:r,disabled:T,className:"shell-action",children:"Cancel"}),s.jsx("button",{type:"submit",disabled:T,className:"shell-action shell-action--cta",children:T?"Saving…":"Save"})]})]})})})}const Dw={"saved-view":{title:"Saved view",icon:QE,render:(e,t)=>e.kind!=="saved-view"?null:m.createElement(IU,{viewId:e.viewId,onPickAnother:t.onPickAnother})},"agent-sessions":{title:"Agent sessions",icon:Uh,render:(e,t)=>e.kind!=="agent-sessions"?null:m.createElement(rH,{viewId:e.viewId,slotId:t.slotId,onPickAnother:t.onPickAnother})},inventories:{title:"Inventories",icon:Tv,render:()=>m.createElement(oH)},"token-usage":{title:"Token Usage",icon:HL,render:e=>e.kind!=="token-usage"?null:m.createElement(bS,{filters:e.filters,metric:"tokens"}),ConfigEditor:wS},spend:{title:"Spend",icon:Wh,render:e=>e.kind!=="spend"?null:m.createElement(bS,{filters:e.filters,metric:"cost"}),ConfigEditor:wS}},$A=50,Lb=16,cH=2,la=6,bh=11,Ob={w:6,h:2};function Up(e,t,n){return Math.min(Math.max(e,t),n)}const uH=[{minWidth:1280,columns:24},{minWidth:1024,columns:16},{minWidth:768,columns:12},{minWidth:640,columns:6},{minWidth:0,columns:1}];function dH(e){if(!Number.isFinite(e)||e<0)return 1;for(const t of uH)if(e>=t.minWidth)return t.columns;return 1}function Hp(e,t){return t<=0?1:Up(Math.round(e/nd*t),1,t)}function Fb(e){if(v8(e))return e;switch(e){case"small":return{w:8,h:la};case"wide":return{w:16,h:la};case"tall":return{w:8,h:bh};case"large":return{w:16,h:bh};default:return{w:8,h:la}}}function fH(e,t){return t>0?Math.round(e/t):0}function pH(e,t=$A){return Math.round(e/t)}const hH=[{label:"Third",w:8,h:la},{label:"Half",w:12,h:la},{label:"Two-thirds",w:16,h:la},{label:"Full",w:24,h:la},{label:"Half tall",w:12,h:bh},{label:"Full tall",w:24,h:bh}];function mH({slot:e,activeColumns:t,colWidthPx:n,onReplace:r,onRemove:o,onRemoveSlot:i,onResize:a,onConfigChange:l}){const[d,f]=m.useState(!1),[p,h]=m.useState(null),g=m.useRef(null),{attributes:y,listeners:k,setNodeRef:w,setActivatorNodeRef:b,transform:j,transition:N,isDragging:S}=gm({id:e.id}),C=Fb(e.size),D=p?p.renderW:Hp(C.w,t),T=p?p.h:C.h,R={transform:bs.Translate.toString(j),transition:N,zIndex:S?50:void 0,position:S?"relative":void 0,gridColumn:`span ${D}`,gridRow:`span ${T}`};function $(z){g.current=null;try{z.currentTarget.releasePointerCapture(z.pointerId)}catch{}h(null)}function _(z){return{onPointerDown:W=>{if(g.current)return;W.preventDefault(),W.stopPropagation(),W.currentTarget.setPointerCapture(W.pointerId);const V=Hp(C.w,t);g.current={pointerId:W.pointerId,startX:W.clientX,startY:W.clientY,startRenderW:V,startH:C.h,axis:z,lastRenderW:V,lastH:C.h},h({renderW:V,h:C.h})},onPointerMove:W=>{const V=g.current;if(!V||W.pointerId!==V.pointerId)return;let K=V.startRenderW,O=V.startH;(V.axis==="w"||V.axis==="both")&&(K=Up(V.startRenderW+fH(W.clientX-V.startX,n),1,t)),(V.axis==="h"||V.axis==="both")&&(O=Up(V.startH+pH(W.clientY-V.startY),cH,ER)),V.lastRenderW=K,V.lastH=O,h({renderW:K,h:O})},onPointerUp:W=>{const V=g.current;if(!V||W.pointerId!==V.pointerId)return;const K=Fb(e.size),B={w:V.axis==="h"?K.w:Up(Math.round(V.lastRenderW/t*nd),1,nd),h:V.lastH};$(W),(B.w!==K.w||B.h!==K.h)&&a(B)},onPointerCancel:W=>{const V=g.current;V&&W.pointerId===V.pointerId&&$(W)},onLostPointerCapture:W=>{const V=g.current;V&&W.pointerId===V.pointerId&&$(W)}}}const U="absolute z-10 touch-none rounded-sm bg-transparent transition hover:bg-primary/30",I=s.jsxs(s.Fragment,{children:[t>1?s.jsx("div",{"aria-hidden":"true",className:Ce(U,"right-0 top-0 h-full w-1.5 cursor-ew-resize"),..._("w")}):null,s.jsx("div",{"aria-hidden":"true",className:Ce(U,"bottom-0 left-0 h-1.5 w-full cursor-ns-resize"),..._("h")}),t>1?s.jsx("div",{"aria-hidden":"true",className:Ce(U,"bottom-0 right-0 h-3 w-3 cursor-nwse-resize"),..._("both")}):null]}),F=s.jsx("button",{ref:b,...y,...k,type:"button","aria-label":"Drag to reorder widget",className:"touch-none cursor-grab text-muted-foreground/40 transition hover:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 active:cursor-grabbing",children:s.jsx(dc,{className:"h-4 w-4","aria-hidden":"true"})});if(e.widget===null)return s.jsxs("div",{ref:w,style:{...R,gridColumn:`span ${Hp(Ob.w,t)}`,gridRow:`span ${Ob.h}`},className:Ce("relative flex items-center justify-center rounded-lg border border-dashed border-border bg-card/40 p-3 shadow-sm transition-colors hover:border-primary/40 hover:bg-card/60",S&&"opacity-0"),children:[s.jsx("div",{className:"absolute left-2 top-2",children:F}),s.jsx("button",{type:"button","aria-label":"Remove slot",onClick:i,onPointerDown:z=>z.stopPropagation(),className:"absolute right-2 top-2 z-10 text-muted-foreground/50 transition hover:text-destructive",children:s.jsx(bn,{className:"h-4 w-4"})}),s.jsxs("button",{type:"button",onClick:r,className:"shell-action inline-flex items-center gap-2",children:[s.jsx(It,{className:"h-4 w-4"}),"Add widget"]})]});const M=Dw[e.widget.kind];if(!M)return s.jsxs("div",{ref:w,style:R,className:Ce("relative overflow-auto rounded-lg border border-border/60 bg-card/85 p-3 shadow-sm",S&&"opacity-0"),children:[s.jsxs("div",{className:"flex items-start gap-2",children:[F,s.jsxs("div",{className:"flex-1 rounded-md border border-border/60 bg-background/60 px-3 py-2 text-sm text-muted-foreground",children:["Unknown widget kind: ",e.widget.kind]})]}),I]});const A=M.icon,L=M.ConfigEditor;return s.jsxs("div",{ref:w,style:R,className:Ce("relative overflow-auto rounded-lg border border-border/60 bg-card/85 p-3 shadow-sm",S&&"opacity-0"),children:[s.jsxs("header",{className:"mb-2 flex items-center justify-between gap-2",children:[s.jsxs("div",{className:"flex min-w-0 items-center gap-2 text-xs uppercase tracking-[0.12em] text-muted-foreground",children:[F,s.jsx(A,{className:"h-3.5 w-3.5","aria-hidden":"true"}),s.jsx("span",{className:"truncate",children:s.jsx(xH,{slot:e,fallback:M.title})})]}),s.jsx(Aw,{items:[{key:"replace",label:"Replace…",icon:e4,onSelect:r},...M.ConfigEditor?[{key:"configure",label:"Configure…",icon:o4,onSelect:()=>f(!0)}]:[],{key:"size",label:"Size",icon:XL,submenu:hH.map(z=>({key:`size-${z.label}`,label:z.label,active:C.w===z.w&&C.h===z.h,onSelect:()=>a({w:z.w,h:z.h})}))},{key:"remove",label:"Remove",icon:bn,destructive:!0,onSelect:o}]})]}),s.jsx("div",{children:M.render(e.widget,{slotId:e.id,onPickAnother:r})}),L?s.jsx(L,{config:e.widget,open:d,onSave:async z=>{await l(z),f(!1)},onCancel:()=>f(!1)}):null,I]})}function gH({slot:e,activeColumns:t,colWidthPx:n}){const r=e.widget?Dw[e.widget.kind]:null,o=r==null?void 0:r.icon,i=e.widget===null?"Empty widget slot":(r==null?void 0:r.title)??`Unknown widget kind: ${e.widget.kind}`,a=e.widget===null?Ob:Fb(e.size),l=Hp(a.w,t),d=n>0?l*n+(l-1)*Lb:void 0;return s.jsx("div",{"aria-hidden":"true",className:"min-w-[200px] rounded-lg border border-border/70 bg-card/95 p-3 shadow-xl ring-1 ring-foreground/10",style:{width:d?`${Math.max(d,200)}px`:void 0},children:s.jsxs("div",{className:"flex items-center gap-2 text-xs uppercase tracking-[0.12em] text-muted-foreground",children:[s.jsx(dc,{className:"h-4 w-4","aria-hidden":"true"}),o?s.jsx(o,{className:"h-3.5 w-3.5","aria-hidden":"true"}):null,s.jsx("span",{className:"min-w-0 flex-1 truncate",children:i})]})})}function xH({slot:e,fallback:t}){var o,i;const n=((o=e.widget)==null?void 0:o.kind)==="saved-view"?e.widget.viewId:null,{view:r}=wi(n);return((i=e.widget)==null?void 0:i.kind)==="saved-view"&&r?s.jsx(s.Fragment,{children:r.name}):s.jsx(s.Fragment,{children:t})}const yH=["agent-sessions","inventories","token-usage","spend"];function bH({open:e,onOpenChange:t,onSelect:n}){const{views:r,loading:o}=Id();function i(a){n(a),t(!1)}return s.jsx(Ln,{open:e,onOpenChange:t,children:s.jsxs(jn,{className:"max-w-xl",children:[s.jsxs(er,{children:[s.jsx(kn,{children:"Add a widget"}),s.jsx(ns,{children:"Choose a built-in widget, an assignment view, or a session view."})]}),s.jsxs("section",{className:"space-y-2",children:[s.jsx("h3",{className:"text-xs font-semibold uppercase tracking-[0.12em] text-muted-foreground",children:"Built-in widgets"}),s.jsx("ul",{className:"divide-y divide-border/40 rounded-md border border-border/60",children:yH.map(a=>{const l=Dw[a],d=l.icon;return s.jsx("li",{children:s.jsxs("button",{type:"button",onClick:()=>i({kind:a}),className:"flex w-full items-center gap-3 px-3 py-2.5 text-left text-sm hover:bg-muted/40",children:[s.jsx(d,{className:"h-4 w-4 text-muted-foreground","aria-hidden":"true"}),s.jsx("span",{className:"font-medium text-foreground",children:l.title})]})},a)})})]}),s.jsxs("section",{className:"space-y-2",children:[s.jsx("h3",{className:"text-xs font-semibold uppercase tracking-[0.12em] text-muted-foreground",children:"Saved views"}),o?s.jsx("div",{className:"rounded-md border border-border/60 px-3 py-4 text-sm text-muted-foreground",children:"Loading saved views…"}):r.length===0?s.jsxs("div",{className:"rounded-md border border-border/60 px-3 py-4 text-sm",children:[s.jsx("p",{className:"font-medium text-foreground",children:"No saved views yet"}),s.jsxs("p",{className:"mt-1 text-xs text-muted-foreground",children:["Save a view from the assignments page first."," ",s.jsx(Ie,{to:"/views",className:"text-foreground underline hover:opacity-80",children:"Manage views →"})]})]}):s.jsxs("div",{className:"space-y-3",children:[r.some(a=>a.entityType!=="session")&&s.jsxs("div",{children:[s.jsx("h4",{className:"mb-1 px-3 text-[10px] font-semibold uppercase tracking-wider text-muted-foreground",children:"Assignments"}),s.jsx("ul",{className:"divide-y divide-border/40 rounded-md border border-border/60",children:r.filter(a=>a.entityType!=="session").map(a=>s.jsx("li",{children:s.jsxs("button",{type:"button",onClick:()=>i({kind:"saved-view",viewId:a.id}),className:"flex w-full items-center gap-3 px-3 py-2.5 text-left text-sm hover:bg-muted/40",children:[s.jsx("span",{className:"min-w-0 flex-1 truncate font-medium text-foreground",children:a.name}),a.workspace!==null?s.jsx("span",{className:"shrink-0 rounded-full border border-border/60 px-2 py-0.5 text-[10px] text-muted-foreground",title:`Scoped to workspace: ${a.workspace}`,children:a.workspace}):null,s.jsx("span",{className:"shrink-0 rounded-full border border-border/60 px-2 py-0.5 text-[10px] capitalize text-muted-foreground",children:a.config.viewMode})]})},a.id))})]}),r.some(a=>a.entityType==="session")&&s.jsxs("div",{children:[s.jsx("h4",{className:"mb-1 px-3 text-[10px] font-semibold uppercase tracking-wider text-muted-foreground",children:"Sessions"}),s.jsx("ul",{className:"divide-y divide-border/40 rounded-md border border-border/60",children:r.filter(a=>a.entityType==="session").map(a=>s.jsx("li",{children:s.jsxs("button",{type:"button",onClick:()=>i({kind:"agent-sessions",viewId:a.id}),className:"flex w-full items-center gap-3 px-3 py-2.5 text-left text-sm hover:bg-muted/40",children:[s.jsx("span",{className:"min-w-0 flex-1 truncate font-medium text-foreground",children:a.name}),a.workspace!==null?s.jsx("span",{className:"shrink-0 rounded-full border border-border/60 px-2 py-0.5 text-[10px] text-muted-foreground",title:`Scoped to workspace: ${a.workspace}`,children:a.workspace}):null]})},a.id))})]})]}),!o&&r.some(a=>a.workspace!==null)?s.jsx("p",{className:"text-[11px] text-muted-foreground",children:"Workspace-scoped views on the global Overview will only show items from that workspace."}):null]})]})})}const vH=(e,{currentCoordinates:t,context:n})=>{var h;const r=e.code==="ArrowRight"||e.code==="ArrowDown"?1:e.code==="ArrowLeft"||e.code==="ArrowUp"?-1:0;if(r===0)return;e.preventDefault();const o=n.over??n.active,i=(h=o==null?void 0:o.data.current)==null?void 0:h.sortable,a=i==null?void 0:i.items;if(!o||!a)return t;const l=a.indexOf(o.id);if(l===-1)return t;const d=a[l+r],f=d===void 0?null:n.droppableRects.get(d),p=n.collisionRect;return!f||!p?t:{x:f.left+(f.width-p.width)/2,y:f.top+(f.height-p.height)/2}};function wH(e){const t=new Set(e.map(o=>o.id));let n=-1;for(const o of t){const i=/^slot-(\d+)$/.exec(o);if(i){const a=parseInt(i[1],10);a>n&&(n=a)}}let r=n+1;for(;t.has(`slot-${r}`);)r++;return`slot-${r}`}function jH(e,t){const n={id:wH(e),widget:null};return[...e,n]}function kH(e,t){return e.filter(n=>n.id!==t)}function SH(){const{data:e,error:t,refetch:n}=dO(),{data:r}=S2(),{layout:o}=IR(),[i,a]=m.useState(!1),[l,d]=m.useState(null),[f,p]=m.useState(null),[h,g]=m.useState(o.slots),[y,k]=m.useState(null),w=m.useRef(null),[b,j]=m.useState(nd),[N,S]=m.useState(0);m.useEffect(()=>{const W=w.current;if(!W)return;const V=new ResizeObserver(K=>{for(const O of K){const B=O.contentRect.width,G=dH(B),H=G>0?(B-(G-1)*Lb)/G:0;j(G),S(H)}});return V.observe(W),()=>V.disconnect()},[]),m.useEffect(()=>{g(o.slots)},[o.slots]);const C=cm(vi(bc,{activationConstraint:{distance:8}}),vi(yc,{coordinateGetter:vH}));Ei("list:overview"),Jt({keys:"r",description:"Refresh",scope:"list:overview",handler:()=>{n()}});const D=m.useCallback(W=>{d(W),a(!0)},[]),T=m.useCallback(async(W,V)=>{p(null),g(W);try{await Eb(W)}catch(K){g(V),p(K instanceof Error?K.message:String(K))}},[]),R=m.useCallback(W=>{if(l===null)return;const V=h.map((K,O)=>O===l?{...K,widget:W}:K);d(null),T(V,h)},[h,l,T]),$=m.useCallback(W=>{const V=h.map((K,O)=>O===W?{...K,widget:null,size:void 0}:K);T(V,h)},[h,T]),_=m.useCallback(W=>{const V=kH(h,W);T(V,h)},[h,T]),U=m.useCallback(()=>{const W=jH(h);T(W,h)},[h,T]),I=m.useCallback((W,V)=>{const K=h.map((O,B)=>B===W?{...O,size:V}:O);T(K,h)},[h,T]),F=m.useCallback(W=>{const{active:V,over:K}=W;if(k(null),!K||V.id===K.id)return;const O=h.findIndex(H=>H.id===V.id),B=h.findIndex(H=>H.id===K.id);if(O===-1||B===-1)return;const G=vc(h,O,B);T(G,h)},[h,T]),M=m.useCallback(W=>{k(String(W.active.id))},[]),A=h.find(W=>W.id===y)??null,L=m.useCallback(async(W,V)=>{const K=h,O=h.map((B,G)=>G===W?{...B,widget:V}:B);p(null),g(O);try{await Eb(O)}catch(B){g(K);const G=B instanceof Error?B.message:String(B);throw p(G),B instanceof Error?B:new Error(G)}},[h]),z={};if(e)for(const W of Object.keys(e.segments))for(const V of e.segments[W].items)z[V.id]=V;return s.jsxs("div",{className:"space-y-6",children:[s.jsxs("header",{className:"space-y-2",children:[s.jsx("p",{className:"eyebrow",children:"Workspace Overview"}),s.jsx("h1",{className:"text-4xl font-semibold tracking-display text-foreground md:text-5xl",children:"What needs you today"})]}),e?s.jsx(y8,{hero:e.hero,itemsById:z}):t?s.jsx(Rt,{error:t}):s.jsx(jt,{label:"Loading overview…"}),e!=null&&e.firstRun?s.jsx(g8,{help:r}):null,f?s.jsxs("div",{className:"rounded-md border border-destructive/30 bg-destructive/5 px-3 py-2 text-sm text-destructive",children:["Couldn't save dashboard layout: ",f]}):null,s.jsxs(hm,{sensors:C,collisionDetection:um,onDragStart:M,onDragCancel:()=>k(null),onDragEnd:F,children:[s.jsx(mm,{items:h.map(W=>W.id),strategy:gw,children:s.jsx("div",{ref:w,style:{display:"grid",gridTemplateColumns:`repeat(${b}, minmax(0, 1fr))`,gridAutoRows:`${$A}px`,gridAutoFlow:"dense",gap:`${Lb}px`},children:h.map((W,V)=>s.jsx(mH,{slot:W,index:V,activeColumns:b,colWidthPx:N,onReplace:()=>D(V),onRemove:()=>$(V),onRemoveSlot:()=>_(W.id),onResize:K=>I(V,K),onConfigChange:K=>L(V,K)},W.id))})}),s.jsx(n8,{dropAnimation:null,children:A?s.jsx(gH,{slot:A,activeColumns:b,colWidthPx:N}):null})]}),s.jsxs("button",{type:"button",onClick:U,className:"shell-action inline-flex items-center gap-2",children:[s.jsx(It,{className:"h-4 w-4"}),"Add slot"]}),e!=null&&e.serverStats?s.jsxs("p",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[s.jsx($v,{className:"h-3 w-3","aria-hidden":"true"}),s.jsxs("span",{children:["● ",e.serverStats.totalPorts," ports ·"," ",e.serverStats.deadSessions>0?`${e.serverStats.deadSessions} dead`:"all healthy"]})]}):null,s.jsx(bH,{open:i,onOpenChange:W=>{a(W),W||d(null)},onSelect:R})]})}function NH({term:e,description:t}){return s.jsx("span",{title:t,className:"cursor-help rounded-full border border-border/70 bg-background/80 px-2.5 py-1 text-xs font-medium text-foreground underline decoration-dotted underline-offset-4",children:e})}function CH(){const{data:e,loading:t,error:n}=S2(),{openCheatsheet:r}=Ci();return t?s.jsx(jt,{label:"Loading help…"}):n||!e?s.jsx(Rt,{error:n||"Help content is unavailable."}):s.jsxs("div",{className:"space-y-5",children:[s.jsx(Qe,{title:"Keyboard Shortcuts",description:"Navigate the dashboard without reaching for the mouse.",children:s.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[s.jsx("button",{type:"button",onClick:r,className:"inline-flex items-center gap-2 rounded-md border border-border/70 bg-background/80 px-3 py-1.5 text-sm font-medium text-foreground hover:bg-accent",children:"Open shortcuts cheatsheet"}),s.jsxs("span",{className:"text-xs text-muted-foreground",children:["or press ",s.jsx("kbd",{className:"rounded border border-border/70 bg-muted px-1.5 py-0.5 font-mono text-[11px]",children:"?"})," ","anywhere. ",Gs("Mod+k")," opens the command palette."]})]})}),s.jsx(Qe,{title:"What Syntaur Is",description:e.whatIsSyntaur.summary,children:s.jsx("div",{className:"grid gap-3 md:grid-cols-3",children:e.whatIsSyntaur.bullets.map(o=>s.jsx("div",{className:"rounded-md border border-border/60 bg-background/80 p-3 text-sm leading-6 text-muted-foreground",children:o},o))})}),s.jsx(Qe,{title:"Getting Started",children:s.jsx("div",{className:"space-y-3",children:e.workflow.map((o,i)=>s.jsx("div",{className:"rounded-md border border-border/60 bg-background/80 p-3",children:s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx("span",{className:"inline-flex h-5 w-5 items-center justify-center rounded-full bg-foreground text-xs font-semibold text-background",children:i+1}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("h3",{className:"font-semibold text-foreground",children:o.title}),s.jsx("p",{className:"text-sm leading-6 text-muted-foreground",children:o.detail}),o.command?s.jsx(Op,{command:o.command.command,description:o.command.description,example:o.command.example}):null,o.href?s.jsx(Ie,{className:"inline-flex text-sm font-semibold text-primary hover:underline",to:o.href,children:"Open the related surface"}):null]})]})},o.title))})}),s.jsxs("div",{className:"grid gap-3 xl:grid-cols-2",children:[s.jsxs(Qe,{title:"Core Concepts",children:[s.jsx("div",{className:"flex flex-wrap gap-2",children:e.coreConcepts.map(o=>s.jsx(NH,{term:o.term,description:o.description},o.term))}),s.jsx("div",{className:"grid gap-3 pt-2",children:e.coreConcepts.map(o=>s.jsxs("div",{className:"rounded-md border border-border/60 bg-background/80 p-3",children:[s.jsx("h3",{className:"font-semibold text-foreground",children:o.term}),s.jsx("p",{className:"mt-2 text-sm leading-6 text-muted-foreground",children:o.description})]},o.term))})]}),s.jsx(Qe,{title:"Status Guide",children:s.jsx("div",{className:"space-y-3",children:e.statusGuide.map(o=>s.jsxs("div",{className:"rounded-md border border-border/60 bg-background/80 p-3",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[s.jsx(vn,{status:o.status}),s.jsx("p",{className:"font-semibold text-foreground",children:o.meaning})]}),s.jsx("p",{className:"mt-3 text-sm leading-6 text-muted-foreground",children:o.useWhen})]},o.status))})})]}),s.jsxs("div",{className:"grid gap-3 xl:grid-cols-2",children:[s.jsx(Qe,{title:"Ownership And File Rules",children:s.jsx("div",{className:"space-y-3",children:e.ownershipRules.map(o=>s.jsxs("div",{className:"rounded-md border border-border/60 bg-background/80 p-3",children:[s.jsx("h3",{className:"font-semibold text-foreground",children:o.label}),s.jsx("p",{className:"mt-2 text-sm leading-6 text-muted-foreground",children:o.description}),s.jsx("div",{className:"mt-3 flex flex-wrap gap-2",children:o.files.map(i=>s.jsx("span",{className:"rounded-full border border-border/60 bg-card/90 px-2.5 py-1 font-mono text-xs text-foreground",children:i},i))})]},o.label))})}),s.jsx(Qe,{title:"How To Navigate The Dashboard",children:s.jsx("div",{className:"space-y-3",children:e.navigation.map(o=>s.jsxs("div",{className:"rounded-md border border-border/60 bg-background/80 p-3",children:[s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[s.jsx("h3",{className:"font-semibold text-foreground",children:o.label}),s.jsx(Ie,{className:"text-sm font-semibold text-primary hover:underline",to:o.href,children:"Open"})]}),s.jsx("p",{className:"mt-2 text-sm leading-6 text-muted-foreground",children:o.description})]},o.label))})})]}),s.jsx(Qe,{title:"CLI Quick Reference",children:s.jsx("div",{className:"grid gap-3 xl:grid-cols-2",children:e.commands.map(o=>s.jsx(Op,{command:o.command,description:o.description,example:o.example},o.command))})}),s.jsxs("div",{className:"grid gap-3 xl:grid-cols-2",children:[s.jsx(Qe,{title:"FAQ",children:s.jsx("div",{className:"space-y-3",children:e.faq.map(o=>s.jsxs("div",{className:"rounded-md border border-border/60 bg-background/80 p-3",children:[s.jsx("h3",{className:"font-semibold text-foreground",children:o.question}),s.jsx("p",{className:"mt-2 text-sm leading-6 text-muted-foreground",children:o.answer})]},o.question))})}),s.jsx(Qe,{title:"First Project Checklist",children:s.jsx("div",{className:"space-y-3",children:e.firstProjectChecklist.map((o,i)=>s.jsx("div",{className:"rounded-md border border-border/60 bg-background/80 p-3",children:s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx("span",{className:"inline-flex h-5 w-5 items-center justify-center rounded-full bg-foreground text-xs font-semibold text-background",children:i+1}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("h3",{className:"font-semibold text-foreground",children:o.title}),s.jsx("p",{className:"text-sm leading-6 text-muted-foreground",children:o.detail}),o.command?s.jsx(Op,{command:o.command.command,example:o.command.example}):null,o.href?s.jsx(Ie,{className:"inline-flex text-sm font-semibold text-primary hover:underline",to:o.href,children:"Open the related surface"}):null]})]})},o.title))})})]})]})}function $w({children:e}){return s.jsx("div",{className:"chrome-card flex flex-col gap-2 !p-2.5 md:flex-row md:flex-wrap md:items-center",children:e})}const Rm=m.forwardRef(({value:e,onChange:t,placeholder:n="Search"},r)=>s.jsxs("label",{className:"relative flex min-w-[220px] flex-1 items-center",children:[s.jsx(Si,{className:"pointer-events-none absolute left-3 h-4 w-4 text-muted-foreground"}),s.jsx("input",{ref:r,value:e,onChange:o=>t(o.target.value),placeholder:n,className:"h-9 w-full rounded-md border border-border/60 bg-background/90 pl-9 pr-3 text-sm text-foreground outline-none transition focus:border-primary focus:ring-2 focus:ring-ring/30"})]}));Rm.displayName="SearchInput";function Am({value:e,options:t,onChange:n}){return s.jsx("div",{className:"inline-flex rounded-md border border-border/60 bg-background/80 p-1",children:t.map(r=>s.jsx("button",{type:"button","aria-pressed":e===r.value,onClick:()=>n(r.value),className:Ce("rounded-sm px-2.5 py-1.5 text-sm font-medium transition",e===r.value?"bg-foreground text-background":"text-muted-foreground hover:text-foreground"),children:r.label},r.value))})}const EH={completed:"bg-status-completed-foreground",in_progress:"bg-status-in-progress-foreground",review:"bg-status-review-foreground",blocked:"bg-status-blocked-foreground",failed:"bg-status-failed-foreground",pending:"bg-status-pending-foreground"},jS=["bg-primary","bg-secondary","bg-accent-coral","bg-accent-teal","bg-accent-amber"];function vh({progress:e,className:t,showLegend:n=!1}){const r=Es(),i=m.useMemo(()=>{let a=0;const l=Object.keys(e).filter(f=>f!=="total");return(r.order.length>0?[...r.order,...l.filter(f=>!r.order.includes(f))]:l).map(f=>({key:f,className:EH[f]??jS[a++%jS.length]}))},[r.order,e]).filter(a=>(e[a.key]??0)>0);return s.jsxs("div",{className:Ce("space-y-2",t),children:[s.jsx("div",{className:"flex h-1.5 w-full overflow-hidden rounded-lg border border-border/70 bg-muted/60",children:e.total===0?s.jsx("div",{className:"h-full w-full bg-muted"}):i.map(a=>s.jsx("div",{className:a.className,style:{width:`${(e[a.key]??0)/e.total*100}%`},title:`${Dn(a.key)}: ${e[a.key]??0}`},a.key))}),n?i.length>0?s.jsx("div",{className:"flex flex-wrap gap-2 text-xs text-muted-foreground",children:i.map(a=>s.jsxs("span",{className:"inline-flex items-center gap-2 rounded-full border border-border/60 bg-background/80 px-2 py-1",children:[s.jsx("span",{className:Ce("h-2 w-2 rounded-full",a.className)}),s.jsx("span",{children:Dn(a.key)}),s.jsx("span",{className:"font-medium text-foreground",children:e[a.key]??0})]},a.key))}):s.jsx("p",{className:"text-xs text-muted-foreground/70",children:"No assignments yet"}):null]})}const TH=["pending","active","blocked","failed","completed"],Iw=TH,RH=["draft","pending","ready_for_planning","ready_to_implement","in_progress","blocked","review","completed","failed"];function IA(e){return e&&e.length>0?e:[...RH]}function AH(e,t,n){if(t<0||t>=e.length)return e;const r=[...e],[o]=r.splice(t,1),i=t<n?n-1:n;return r.splice(Math.max(0,Math.min(i,r.length)),0,o),r}const PH=220,cp=8;function MA({anchor:e,items:t,onClose:n}){const r=m.useRef(null),[o,i]=m.useState(null);return m.useLayoutEffect(()=>{if(!e){i(null);return}const a=r.current,l=(a==null?void 0:a.offsetWidth)??PH,d=(a==null?void 0:a.offsetHeight)??0,f=Math.max(cp,window.innerWidth-l-cp),p=Math.max(cp,window.innerHeight-d-cp);i({left:Math.min(e.x,f),top:Math.min(e.y,p)})},[e]),m.useEffect(()=>{if(!e)return;function a(f){r.current&&!r.current.contains(f.target)&&n()}function l(f){f.key==="Escape"&&n()}function d(){n()}return document.addEventListener("mousedown",a),document.addEventListener("keydown",l),document.addEventListener("contextmenu",a),window.addEventListener("scroll",d,!0),()=>{document.removeEventListener("mousedown",a),document.removeEventListener("keydown",l),document.removeEventListener("contextmenu",a),window.removeEventListener("scroll",d,!0)}},[e,n]),!e||t.length===0?null:s.jsx("div",{ref:r,role:"menu",className:"fixed z-50 min-w-[220px] rounded-md border border-border/70 bg-background py-1 shadow-lg",style:{left:(o==null?void 0:o.left)??e.x,top:(o==null?void 0:o.top)??e.y,visibility:o?"visible":"hidden"},children:s.jsx(fa,{delayDuration:200,children:t.map(a=>{const l=a.icon,d=Ce("flex w-full items-center gap-2 px-3 py-1.5 text-left text-sm transition",a.disabled?"cursor-not-allowed opacity-50":a.destructive?"text-destructive hover:bg-destructive/10":"hover:bg-foreground/5"),f=s.jsxs(s.Fragment,{children:[l?s.jsx(l,{className:"h-4 w-4 shrink-0"}):null,s.jsx("span",{className:"block min-w-0 truncate",children:a.label})]});if(a.disabled){const p=s.jsx("span",{tabIndex:0,className:"inline-block w-full outline-none focus-visible:ring-1 focus-visible:ring-ring",children:s.jsx("button",{type:"button",disabled:!0,className:d,children:f})});return a.disabledReason?s.jsxs(Ir,{children:[s.jsx(Mr,{asChild:!0,children:p}),s.jsx(gr,{side:"left",children:a.disabledReason})]},a.key):s.jsx("div",{children:p},a.key)}return a.href?s.jsx(Ie,{to:a.href,className:d,onClick:()=>n(),children:f},a.key):s.jsx("button",{type:"button",className:d,onClick:()=>{var p;(p=a.onSelect)==null||p.call(a),n()},children:f},a.key)})})})}const _H="__ungrouped__";function Mw({open:e,onOpenChange:t,currentWorkspace:n,onSubmit:r,title:o="Move to workspace",description:i="Pick the workspace this item should belong to."}){const{data:a,loading:l}=Sa(),[d,f]=m.useState(n),[p,h]=m.useState(!1),[g,y]=m.useState(null);m.useEffect(()=>{e&&(f(n),y(null))},[e,n]);const k=m.useMemo(()=>[...((a==null?void 0:a.workspaces)??[]).map(N=>({key:N,label:N,value:N})),{key:_H,label:"Ungrouped",value:null}],[a]),w=!p&&d!==n;async function b(){if(w){h(!0),y(null);try{await r(d),t(!1)}catch(j){y(j instanceof Error?j.message:"Failed to move item")}finally{h(!1)}}}return s.jsx(Ln,{open:e,onOpenChange:j=>p?void 0:t(j),children:s.jsxs(jn,{children:[s.jsxs(er,{children:[s.jsx(kn,{children:o}),s.jsx(ns,{children:i})]}),s.jsx("div",{className:"my-2 max-h-[320px] overflow-y-auto rounded-md border border-border/60",children:l&&k.length===0?s.jsxs("div",{className:"flex items-center gap-2 px-3 py-3 text-sm text-muted-foreground",children:[s.jsx(Dv,{className:"h-4 w-4 animate-spin"})," Loading workspaces…"]}):k.map(j=>{const N=j.value===n,S=j.value===d;return s.jsxs("button",{type:"button",disabled:N||p,onClick:()=>f(j.value),className:Ce("flex w-full items-center justify-between px-3 py-2 text-left text-sm transition",N?"cursor-not-allowed bg-foreground/5 text-muted-foreground":S?"bg-accent/40 text-foreground":"hover:bg-foreground/5"),children:[s.jsxs("span",{className:Ce("block min-w-0 truncate",j.value===null?"italic text-muted-foreground":""),children:[j.label,N?s.jsx("span",{className:"ml-2 text-xs",children:"(current)"}):null]}),S?s.jsx(zr,{className:"h-4 w-4 text-foreground"}):null]},j.key)})}),g?s.jsx("p",{className:"text-sm text-destructive",role:"alert",children:g}):null,s.jsxs(Ur,{children:[s.jsx("button",{type:"button",onClick:()=>t(!1),disabled:p,className:"shell-action mt-0 disabled:cursor-not-allowed disabled:opacity-50",children:"Cancel"}),s.jsx("button",{type:"button",onClick:b,disabled:!w,className:"shell-action mt-0 shell-action--cta disabled:cursor-not-allowed disabled:opacity-50",children:p?"Moving…":"Move"})]})]})})}function kS(){const{workspace:e}=Vt(),t=pn(),n=Ht(),{data:r,loading:o,error:i,refetch:a}=Zs(),{toast:l,showToast:d,dismissToast:f}=wr(),p=m.useRef(null);Ei("list:projects");const[h,g]=m.useState(""),[y,k]=m.useState("all"),[w,b]=m.useState("all"),[j,N]=m.useState("updated"),[S,C]=Ns(),D=S.get("view"),T=D==="table"||D==="kanban"?D:"cards",R=B=>{C(G=>{const H=new URLSearchParams(G);return B==="cards"?H.delete("view"):H.set("view",B),H})},[$,_]=m.useState({}),[U,I]=m.useState(null),[F,M]=m.useState(null),A=m.useMemo(()=>r?r.filter(B=>{if(e){if(e==="_ungrouped"){if(B.workspace!==null)return!1}else if(B.workspace!==e)return!1}return y!=="all"&&B.status!==y||w!=="all"&&!B.tags.includes(w)?!1:h.trim()?`${B.title} ${B.tags.join(" ")} ${B.slug}`.toLowerCase().includes(h.toLowerCase()):!0}).sort((B,G)=>$H(B,G,j)):[],[r,h,y,w,j,e]),L=A.map(B=>`${B.slug}:${B.status}`).join("|");m.useEffect(()=>{_(IH(A))},[L,j]);const z=m.useMemo(()=>{const B=new Map(A.map(G=>[G.slug,G]));return Iw.flatMap(G=>($[G]??A.filter(Q=>Q.status===G).map(Q=>Q.slug)).map(Q=>B.get(Q)).filter(Q=>!!Q))},[A,$]),{visibleItems:W,visibleIndexByKey:V}=m.useMemo(()=>{const B=T==="kanban"?z:A,G=new Map;return B.forEach((H,Q)=>G.set(H.slug,Q)),{visibleItems:B,visibleIndexByKey:G}},[T,A,z]),{hotkeyRowProps:K}=Ad(W,{scope:"list:projects",onOpen:B=>n(`${t}/projects/${B.slug}`)});if(Jt({keys:"/",scope:"list:projects",description:"Focus filter",handler:()=>{var B;return(B=p.current)==null?void 0:B.focus()}}),Jt({keys:"r",scope:"list:projects",description:"Refresh",handler:()=>a()}),o)return s.jsx(jt,{label:"Loading projects…"});if(i||!r)return s.jsx(Rt,{error:i||"Project list is unavailable."});const O=Array.from(new Set(r.flatMap(B=>B.tags))).sort();return s.jsxs("div",{className:"space-y-5",children:[s.jsx(Hr,{toast:l,onDismiss:f}),s.jsxs($w,{children:[s.jsx(Rm,{ref:p,value:h,onChange:g,placeholder:"Search by project title or tag"}),s.jsxs("select",{value:y,onChange:B=>k(B.target.value),className:"editor-input max-w-[180px]",children:[s.jsx("option",{value:"all",children:"All statuses"}),s.jsx("option",{value:"pending",children:"Pending"}),s.jsx("option",{value:"active",children:"Active"}),s.jsx("option",{value:"blocked",children:"Blocked"}),s.jsx("option",{value:"failed",children:"Failed"}),s.jsx("option",{value:"completed",children:"Completed"})]}),s.jsxs("select",{value:w,onChange:B=>b(B.target.value),className:"editor-input max-w-[180px]",children:[s.jsx("option",{value:"all",children:"All tags"}),O.map(B=>s.jsx("option",{value:B,children:B},B))]}),s.jsxs("select",{value:j,onChange:B=>N(B.target.value),className:"editor-input max-w-[180px]",children:[s.jsx("option",{value:"updated",children:"Sort: Updated"}),s.jsx("option",{value:"created",children:"Sort: Created"}),s.jsx("option",{value:"title",children:"Sort: Title"}),s.jsx("option",{value:"attention",children:"Sort: Attention"})]}),s.jsx(Am,{value:T,onChange:B=>R(B),options:[{value:"cards",label:"Cards"},{value:"table",label:"Table"},{value:"kanban",label:"Kanban"}]})]}),A.length===0?r.length===0?s.jsxs("div",{className:"rounded-frame border border-border/60 bg-card px-6 py-16 text-center",children:[s.jsx("p",{className:"eyebrow mx-auto justify-center",children:"Start here"}),s.jsx("h2",{className:"mx-auto mt-4 max-w-2xl text-3xl font-semibold tracking-display text-foreground md:text-4xl",children:"The task manager built for agents, by agents"}),s.jsx("p",{className:"mx-auto mt-3 max-w-xl text-sm leading-6 text-muted-foreground",children:"A project groups assignments, resources, and memories under one objective. Markdown stays authoritative — the dashboard is just a view."}),s.jsxs("div",{className:"mt-6 flex flex-wrap justify-center gap-3",children:[s.jsx(Ie,{className:"shell-action shell-action--solid",to:`${t}/create/project`,children:"Create your first project"}),s.jsx(Ie,{className:"shell-action",to:"/help",children:"Read the spec"})]})]}):s.jsx(Tt,{title:"No projects match these filters",description:"Adjust the current search and filters or create a new project.",actions:s.jsx(Ie,{className:"shell-action shell-action--solid",to:`${t}/create/project`,children:"Create Project"})}):T==="cards"?s.jsx("div",{className:"grid gap-3 lg:grid-cols-2 2xl:grid-cols-3",children:A.map((B,G)=>s.jsxs(Ie,{to:`${t}/projects/${B.slug}`,className:"block rounded-lg border border-border/60 bg-card/90 p-3 shadow-sm transition hover:border-primary/40 hover:shadow-md",...K(G),children:[s.jsxs("div",{className:"flex items-start justify-between gap-3",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsx("h2",{className:"text-lg font-semibold text-foreground",children:B.title}),s.jsxs("p",{className:"text-sm text-muted-foreground",children:["Updated ",Gn(B.updated)]})]}),s.jsx(vn,{status:B.status})]}),s.jsxs("div",{className:"mt-4 space-y-3",children:[s.jsx(vh,{progress:B.progress,showLegend:!0}),s.jsx("div",{className:"flex flex-wrap gap-2",children:B.tags.map(H=>s.jsx("span",{className:"rounded-full border border-border/60 bg-background/80 px-2.5 py-1 text-xs text-foreground",children:H},H))}),s.jsxs("div",{className:"grid grid-cols-2 gap-3 text-sm",children:[s.jsxs("div",{className:"rounded-md border border-border/60 bg-background/80 p-3",children:[s.jsx("p",{className:"text-muted-foreground",children:"Needs attention"}),s.jsx("p",{className:"mt-1 font-semibold text-foreground",children:B.needsAttention.blockedCount+B.needsAttention.failedCount})]}),s.jsxs("div",{className:"rounded-md border border-border/60 bg-background/80 p-3",children:[s.jsx("p",{className:"text-muted-foreground",children:"Assignments"}),s.jsx("p",{className:"mt-1 font-semibold text-foreground",children:B.progress.total})]})]})]})]},B.slug))}):T==="table"?s.jsx(Qe,{title:`${A.length} project${A.length===1?"":"s"}`,children:s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"w-full min-w-[760px] text-left text-sm",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"border-b border-border/60 text-muted-foreground",children:[s.jsx("th",{className:"pb-3 font-medium",children:"Project"}),s.jsx("th",{className:"pb-3 font-medium",children:"Status"}),s.jsx("th",{className:"pb-3 font-medium",children:"Progress"}),s.jsx("th",{className:"pb-3 font-medium",children:"Attention"}),s.jsx("th",{className:"pb-3 font-medium",children:"Updated"})]})}),s.jsx("tbody",{children:A.map((B,G)=>s.jsxs("tr",{className:"border-b border-border/50 last:border-0",...K(G),children:[s.jsxs("td",{className:"py-4 pr-4",children:[s.jsx(Ie,{to:`${t}/projects/${B.slug}`,className:"font-semibold text-foreground hover:text-primary",children:B.title}),s.jsx("div",{className:"mt-1 flex flex-wrap gap-2",children:B.tags.map(H=>s.jsx("span",{className:"rounded-full border border-border/60 px-2 py-0.5 text-xs text-muted-foreground",children:H},H))})]}),s.jsx("td",{className:"py-4 pr-4",children:s.jsx(vn,{status:B.status})}),s.jsx("td",{className:"py-4 pr-4",children:s.jsx("div",{className:"min-w-[220px]",children:s.jsx(vh,{progress:B.progress})})}),s.jsx("td",{className:"py-4 pr-4 text-muted-foreground",children:B.needsAttention.blockedCount+B.needsAttention.failedCount}),s.jsx("td",{className:"py-4 text-muted-foreground",children:Gn(B.updated)})]},B.slug))})]})})}):s.jsx(Cm,{columns:SS,items:z,getItemId:B=>B.slug,getColumnId:B=>B.status,canDrop:({fromColumnId:B,toColumnId:G})=>({allowed:!0,reason:B===G?void 0:"This will set a manual status override on the project."}),onMove:async({item:B,fromColumnId:G,toColumnId:H,fromIndex:Q,toIndex:te})=>{var Z;if(G===H){const ae=$[G]??A.filter(ne=>ne.status===G).map(ne=>ne.slug);_(ne=>({...ne,[G]:AH(ae,Q,te)}));return}try{const ae=await fetch(`/api/projects/${B.slug}/status-override`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({status:H})});if(!ae.ok){const ue=await ae.json().catch(()=>null);d((ue==null?void 0:ue.error)||`HTTP ${ae.status}`,"error");return}a();const ne=((Z=SS.find(ue=>ue.id===H))==null?void 0:Z.title)??H;d(`Moved "${B.title}" to ${ne}`,"success")}catch(ae){d(ae instanceof Error?ae.message:"Failed to move project","error")}},getExternalDragData:B=>({type:"project",id:B.slug}),onCardContextMenu:(B,G)=>{G.preventDefault(),I({project:B,anchor:{x:G.clientX,y:G.clientY}})},emptyMessage:B=>`No ${B.title.toLowerCase()} projects.`,renderCard:(B,{dragging:G})=>{const H=V.get(B.slug)??-1;return s.jsx("div",{...H>=0?K(H):{},children:s.jsx(MH,{project:B,dragging:G})})}}),s.jsx(MA,{anchor:(U==null?void 0:U.anchor)??null,items:U?[{key:"edit",label:"Edit",icon:fc,onSelect:()=>n(`${t}/projects/${U.project.slug}`)},{key:"move",label:"Move to workspace…",icon:Vh,onSelect:()=>M(U.project)}]:[],onClose:()=>I(null)}),s.jsx(Mw,{open:F!==null,onOpenChange:B=>{B||M(null)},currentWorkspace:(F==null?void 0:F.workspace)??null,title:"Move project to workspace",onSubmit:async B=>{if(!F)return;const G=await fetch(`/api/projects/${encodeURIComponent(F.slug)}/move-workspace`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({workspace:B})});if(!G.ok){const H=await G.json().catch(()=>({}));throw new Error(H.error||"Failed to move project")}a()}}),s.jsx("div",{className:"rounded-lg border border-border/60 bg-card/80 p-3 text-sm text-muted-foreground",children:s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx(_v,{className:"mt-0.5 h-4 w-4"}),s.jsxs("p",{children:["Project status is derived from assignment state by default.",T==="kanban"?" Drag projects between columns or use":" Use"," the status override on the project detail page to set a manual status."]})]})})]})}const DH={pending:"Pending",active:"Active",blocked:"Blocked",failed:"Failed",completed:"Completed"},SS=Iw.map(e=>({id:e,title:DH[e],description:Fd(e)}));function $H(e,t,n){switch(n){case"created":return t.created.localeCompare(e.created);case"title":return e.title.localeCompare(t.title);case"attention":return NS(t)-NS(e);case"updated":default:return t.updated.localeCompare(e.updated)}}function NS(e){return e.needsAttention.failedCount*10+e.needsAttention.blockedCount*5+e.needsAttention.openQuestions}function IH(e){return Object.fromEntries(Iw.map(t=>[t,e.filter(n=>n.status===t).map(n=>n.slug)]))}function MH({project:e,dragging:t}){const n=pn();return s.jsxs("div",{className:"rounded-lg border border-border/60 bg-background/85 p-3 shadow-sm",children:[s.jsxs("div",{className:"flex items-start justify-between gap-3",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsx(Ie,{to:`${n}/projects/${e.slug}`,className:"text-base font-semibold text-foreground hover:text-primary",children:e.title}),s.jsxs("p",{className:"text-sm text-muted-foreground",children:["Updated ",Gn(e.updated)]})]}),s.jsx(vn,{status:e.status})]}),s.jsx("div",{className:"mt-4",children:s.jsx(vh,{progress:e.progress})}),s.jsxs("div",{className:"mt-4 flex flex-wrap gap-2",children:[e.tags.map(r=>s.jsx("span",{className:"rounded-full border border-border/60 bg-background/80 px-2.5 py-1 text-xs text-foreground",children:r},r)),s.jsxs("span",{className:"rounded-full border border-border/60 px-2.5 py-1 text-xs text-muted-foreground",children:[e.progress.total," assignments"]}),s.jsxs("span",{className:"rounded-full border border-border/60 px-2.5 py-1 text-xs text-muted-foreground",children:[e.needsAttention.blockedCount+e.needsAttention.failedCount," needs attention"]})]}),s.jsx("div",{className:"mt-4 text-xs uppercase tracking-[0.08em] text-muted-foreground",children:t?"Reordering within status":"Derived project lane"})]})}function wh({title:e,description:t,actions:n,className:r}){return s.jsxs("div",{className:Ce("flex flex-col gap-3 lg:flex-row lg:items-end lg:justify-between",r),children:[s.jsxs("div",{className:"space-y-1",children:[e?s.jsx("h1",{className:"text-xl font-semibold tracking-tight text-foreground sm:text-2xl",children:e}):null,t?s.jsx("p",{className:"max-w-3xl text-sm leading-5 text-muted-foreground",children:t}):null]}),n?s.jsx("div",{className:"flex flex-wrap items-center gap-3",children:n}):null]})}function LH(){return s.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full border border-status-archived-foreground/30 bg-status-archived px-2 py-0.5 text-xs font-medium text-status-archived-foreground",children:[s.jsx(Hh,{className:"h-3 w-3"}),"Archived"]})}function CS(e){return e.projectSlug?`/projects/${e.projectSlug}/assignments/${e.slug}`:`/assignments/${e.id}`}function OH(){const{data:e,loading:t,error:n,refetch:r}=fO(),[o,i]=m.useState(null),[a,l]=m.useState(null),[d,f]=m.useState({}),{toast:p,showToast:h,dismissToast:g}=wr();async function y(S,C,D){i(C),l(null);try{const T=await fetch(S,{method:"POST",headers:{"Content-Type":"application/json"}});if(!T.ok){const R=await T.json().catch(()=>null);throw new Error((R==null?void 0:R.error)||`HTTP ${T.status}`)}r(),h(D,"success")}catch(T){l(T instanceof Error?T.message:"Restore failed")}finally{i(null)}}function k(S){return y(`/api/projects/${S.slug}/unarchive`,`project:${S.slug}`,"Project restored")}function w(S){const C=S.projectSlug?`/api/projects/${S.projectSlug}/assignments/${S.slug}/unarchive`:`/api/assignments/${S.id}/unarchive`;return y(C,`assignment:${S.id}`,"Assignment restored")}if(t)return s.jsx(jt,{label:"Loading archived content…"});if(n)return s.jsx(Rt,{error:n});const b=(e==null?void 0:e.projects)??[],j=(e==null?void 0:e.assignments)??[],N=b.length===0&&j.length===0;return s.jsxs("div",{className:"space-y-6",children:[s.jsx(Hr,{toast:p,onDismiss:g}),s.jsx(wh,{title:"Archive",description:"Archived projects and individually-archived assignments. Restoring a project also brings back its cascade-hidden assignments; assignments archived on their own stay archived until restored here."}),a?s.jsx("div",{className:"rounded border border-status-failed-foreground/30 bg-status-failed px-3 py-2 text-sm text-status-failed-foreground",children:a}):null,N?s.jsx(Tt,{title:"Nothing archived",description:"Archived projects and assignments will appear here, ready to restore."}):s.jsxs(s.Fragment,{children:[b.length>0&&s.jsx(Qe,{title:"Archived Projects",description:"Restoring a project unhides every cascade-hidden assignment; individually-archived children stay archived.",children:s.jsx("ul",{className:"divide-y divide-border",children:b.map(S=>{const C=d[S.slug]??!1;return s.jsxs("li",{className:"py-3",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[s.jsxs("button",{type:"button",onClick:()=>f(D=>({...D,[S.slug]:!C})),className:"inline-flex items-center gap-1.5 text-left text-sm font-medium text-foreground hover:text-foreground/80","aria-expanded":C,children:[C?s.jsx(vr,{className:"h-4 w-4"}):s.jsx(KE,{className:"h-4 w-4"}),s.jsx(Av,{className:"h-4 w-4 text-muted-foreground"}),S.title,s.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",S.assignments.length," assignment",S.assignments.length===1?"":"s",")"]})]}),s.jsxs("span",{className:"text-xs text-muted-foreground",children:["Archived ",S.archivedAt?es(S.archivedAt):"with no timestamp",S.archivedReason?` · ${S.archivedReason}`:""]}),s.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[s.jsx(Ie,{to:`/projects/${S.slug}`,className:"rounded border border-border px-2 py-1 text-xs text-muted-foreground hover:border-foreground/40 hover:text-foreground",children:"Open"}),s.jsxs("button",{type:"button",onClick:()=>k(S),disabled:o===`project:${S.slug}`,className:"inline-flex items-center gap-1.5 rounded border border-border px-2 py-1 text-xs text-muted-foreground hover:border-foreground/40 hover:text-foreground disabled:opacity-50",children:[s.jsx(Qp,{className:"h-3 w-3"}),"Restore"]})]})]}),C&&S.assignments.length>0&&s.jsx("ul",{className:"mt-2 space-y-1 pl-9",children:S.assignments.map(D=>s.jsxs("li",{className:"flex flex-wrap items-center gap-2 text-sm",children:[s.jsx(Ie,{to:CS(D),className:"text-foreground hover:text-foreground/80",children:D.title}),s.jsx(vn,{status:D.status,showIcon:!1}),s.jsx("span",{className:"text-xs text-muted-foreground",children:D.archived?"Archived individually — stays archived after restore":"Hidden via project — returns on restore"})]},D.id))})]},S.slug)})})}),j.length>0&&s.jsx(Qe,{title:"Archived Assignments",description:"Individually-archived assignments whose project is still active.",children:s.jsx("ul",{className:"divide-y divide-border",children:j.map(S=>s.jsxs("li",{className:"flex flex-wrap items-center gap-3 py-3",children:[s.jsx(Ie,{to:CS(S),className:"text-sm font-medium text-foreground hover:text-foreground/80",children:S.title}),s.jsx(vn,{status:S.status,showIcon:!1}),s.jsx(LH,{}),s.jsxs("span",{className:"text-xs text-muted-foreground",children:[S.projectTitle??"Standalone"," · Archived"," ",S.archivedAt?es(S.archivedAt):"with no timestamp",S.archivedReason?` · ${S.archivedReason}`:""]}),s.jsxs("button",{type:"button",onClick:()=>w(S),disabled:o===`assignment:${S.id}`,className:"ml-auto inline-flex items-center gap-1.5 rounded border border-border px-2 py-1 text-xs text-muted-foreground hover:border-foreground/40 hover:text-foreground disabled:opacity-50",children:[s.jsx(Qp,{className:"h-3 w-3"}),"Restore"]})]},S.id))})})]})]})}const ES="inline-flex max-w-[14rem] items-center gap-1 whitespace-nowrap rounded-full border px-2 py-0.5 text-[11px] font-semibold tracking-wide border-border/60 text-muted-foreground",TS="block min-w-0 truncate";function Lw({externalIds:e,className:t}){return e.length===0?null:s.jsx("span",{className:Ce("flex flex-wrap items-center gap-1.5",t),children:e.map((n,r)=>{const o=`${n.system}:${n.id}`,i=`${n.system}:${n.id}:${r}`;return n.url!=null&&n.url.length>0?s.jsxs("a",{href:n.url??void 0,target:"_blank",rel:"noopener noreferrer",className:Ce(ES,"transition-colors hover:text-foreground hover:border-foreground/40"),title:`Open ${o} in ${n.system}`,children:[s.jsx("span",{className:TS,children:o}),s.jsx(uc,{className:"h-2.5 w-2.5 shrink-0"})]},i):s.jsx("span",{className:ES,title:o,children:s.jsx("span",{className:TS,children:o})},i)})})}const FH={default:"chrome-card",info:"rounded-lg border border-primary/30 bg-primary/5 p-3 dark:border-primary/40 dark:bg-primary/10",warn:"rounded-lg border border-warning-foreground/30 bg-warning p-3",danger:"rounded-lg border border-error-foreground/30 bg-error p-3",success:"rounded-lg border border-success-foreground/30 bg-success p-3"};function Kn({label:e,value:t,description:n,icon:r,tone:o="default",to:i}){const a=s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex items-start justify-between gap-4",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsx("p",{className:"text-xs font-semibold uppercase tracking-[0.1em] text-muted-foreground",children:e}),s.jsx("p",{className:"text-2xl font-semibold text-foreground",children:t})]}),r?s.jsx("span",{className:"rounded-md border border-border/60 bg-background/80 p-1.5 text-muted-foreground",children:s.jsx(r,{className:"h-5 w-5"})}):null]}),n?s.jsx("p",{className:"mt-2 text-sm leading-5 text-muted-foreground",children:n}):null]}),f=Ce(FH[(t===0||t==="0")&&(o==="warn"||o==="danger")?"default":o],i?"block transition hover:-translate-y-0.5 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/40":"");return i?s.jsx(Ie,{to:i,className:f,children:a}):s.jsx("article",{className:f,children:a})}function RS(e){const t=zH(e),n=m.forwardRef((r,o)=>{const{children:i,...a}=r,l=m.Children.toArray(i),d=l.find(UH);if(d){const f=d.props.children,p=l.map(h=>h===d?m.Children.count(f)>1?m.Children.only(null):m.isValidElement(f)?f.props.children:null:h);return s.jsx(t,{...a,ref:o,children:m.isValidElement(f)?m.cloneElement(f,void 0,p):null})}return s.jsx(t,{...a,ref:o,children:i})});return n.displayName=`${e}.Slot`,n}function zH(e){const t=m.forwardRef((n,r)=>{const{children:o,...i}=n;if(m.isValidElement(o)){const a=VH(o),l=HH(i,o.props);return o.type!==m.Fragment&&(l.ref=r?nm(r,a):a),m.cloneElement(o,l)}return m.Children.count(o)>1?m.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var BH=Symbol("radix.slottable");function UH(e){return m.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===BH}function HH(e,t){const n={...t};for(const r in t){const o=e[r],i=t[r];/^on[A-Z]/.test(r)?o&&i?n[r]=(...l)=>{const d=i(...l);return o(...l),d}:o&&(n[r]=o):r==="style"?n[r]={...o,...i}:r==="className"&&(n[r]=[o,i].filter(Boolean).join(" "))}return{...e,...n}}function VH(e){var r,o;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(o=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}function WH(e){const t=e+"CollectionProvider",[n,r]=Na(t),[o,i]=n(t,{collectionRef:{current:null},itemMap:new Map}),a=w=>{const{scope:b,children:j}=w,N=$t.useRef(null),S=$t.useRef(new Map).current;return s.jsx(o,{scope:b,itemMap:S,collectionRef:N,children:j})};a.displayName=t;const l=e+"CollectionSlot",d=RS(l),f=$t.forwardRef((w,b)=>{const{scope:j,children:N}=w,S=i(l,j),C=Zn(b,S.collectionRef);return s.jsx(d,{ref:C,children:N})});f.displayName=l;const p=e+"CollectionItemSlot",h="data-radix-collection-item",g=RS(p),y=$t.forwardRef((w,b)=>{const{scope:j,children:N,...S}=w,C=$t.useRef(null),D=Zn(b,C),T=i(p,j);return $t.useEffect(()=>(T.itemMap.set(C,{ref:C,...S}),()=>void T.itemMap.delete(C))),s.jsx(g,{[h]:"",ref:D,children:N})});y.displayName=p;function k(w){const b=i(e+"CollectionConsumer",w);return $t.useCallback(()=>{const N=b.collectionRef.current;if(!N)return[];const S=Array.from(N.querySelectorAll(`[${h}]`));return Array.from(b.itemMap.values()).sort((T,R)=>S.indexOf(T.ref.current)-S.indexOf(R.ref.current))},[b.collectionRef,b.itemMap])}return[{Provider:a,Slot:f,ItemSlot:y},k,r]}var qH=m.createContext(void 0);function LA(e){const t=m.useContext(qH);return e||t||"ltr"}var my="rovingFocusGroup.onEntryFocus",KH={bubbles:!1,cancelable:!0},Bd="RovingFocusGroup",[zb,OA,GH]=WH(Bd),[YH,FA]=Na(Bd,[GH]),[XH,QH]=YH(Bd),zA=m.forwardRef((e,t)=>s.jsx(zb.Provider,{scope:e.__scopeRovingFocusGroup,children:s.jsx(zb.Slot,{scope:e.__scopeRovingFocusGroup,children:s.jsx(JH,{...e,ref:t})})}));zA.displayName=Bd;var JH=m.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:o=!1,dir:i,currentTabStopId:a,defaultCurrentTabStopId:l,onCurrentTabStopIdChange:d,onEntryFocus:f,preventScrollOnEntryFocus:p=!1,...h}=e,g=m.useRef(null),y=Zn(t,g),k=LA(i),[w,b]=rm({prop:a,defaultProp:l??null,onChange:d,caller:Bd}),[j,N]=m.useState(!1),S=ga(f),C=OA(n),D=m.useRef(!1),[T,R]=m.useState(0);return m.useEffect(()=>{const $=g.current;if($)return $.addEventListener(my,S),()=>$.removeEventListener(my,S)},[S]),s.jsx(XH,{scope:n,orientation:r,dir:k,loop:o,currentTabStopId:w,onItemFocus:m.useCallback($=>b($),[b]),onItemShiftTab:m.useCallback(()=>N(!0),[]),onFocusableItemAdd:m.useCallback(()=>R($=>$+1),[]),onFocusableItemRemove:m.useCallback(()=>R($=>$-1),[]),children:s.jsx(wn.div,{tabIndex:j||T===0?-1:0,"data-orientation":r,...h,ref:y,style:{outline:"none",...e.style},onMouseDown:rn(e.onMouseDown,()=>{D.current=!0}),onFocus:rn(e.onFocus,$=>{const _=!D.current;if($.target===$.currentTarget&&_&&!j){const U=new CustomEvent(my,KH);if($.currentTarget.dispatchEvent(U),!U.defaultPrevented){const I=C().filter(z=>z.focusable),F=I.find(z=>z.active),M=I.find(z=>z.id===w),L=[F,M,...I].filter(Boolean).map(z=>z.ref.current);HA(L,p)}}D.current=!1}),onBlur:rn(e.onBlur,()=>N(!1))})})}),BA="RovingFocusGroupItem",UA=m.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:i,children:a,...l}=e,d=_l(),f=i||d,p=QH(BA,n),h=p.currentTabStopId===f,g=OA(n),{onFocusableItemAdd:y,onFocusableItemRemove:k,currentTabStopId:w}=p;return m.useEffect(()=>{if(r)return y(),()=>k()},[r,y,k]),s.jsx(zb.ItemSlot,{scope:n,id:f,focusable:r,active:o,children:s.jsx(wn.span,{tabIndex:h?0:-1,"data-orientation":p.orientation,...l,ref:t,onMouseDown:rn(e.onMouseDown,b=>{r?p.onItemFocus(f):b.preventDefault()}),onFocus:rn(e.onFocus,()=>p.onItemFocus(f)),onKeyDown:rn(e.onKeyDown,b=>{if(b.key==="Tab"&&b.shiftKey){p.onItemShiftTab();return}if(b.target!==b.currentTarget)return;const j=t9(b,p.orientation,p.dir);if(j!==void 0){if(b.metaKey||b.ctrlKey||b.altKey||b.shiftKey)return;b.preventDefault();let S=g().filter(C=>C.focusable).map(C=>C.ref.current);if(j==="last")S.reverse();else if(j==="prev"||j==="next"){j==="prev"&&S.reverse();const C=S.indexOf(b.currentTarget);S=p.loop?n9(S,C+1):S.slice(C+1)}setTimeout(()=>HA(S))}}),children:typeof a=="function"?a({isCurrentTabStop:h,hasTabStop:w!=null}):a})})});UA.displayName=BA;var ZH={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function e9(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function t9(e,t,n){const r=e9(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return ZH[r]}function HA(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function n9(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var r9=zA,s9=UA,Pm="Tabs",[o9]=Na(Pm,[FA]),VA=FA(),[i9,Ow]=o9(Pm),WA=m.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,onValueChange:o,defaultValue:i,orientation:a="horizontal",dir:l,activationMode:d="automatic",...f}=e,p=LA(l),[h,g]=rm({prop:r,onChange:o,defaultProp:i??"",caller:Pm});return s.jsx(i9,{scope:n,baseId:_l(),value:h,onValueChange:g,orientation:a,dir:p,activationMode:d,children:s.jsx(wn.div,{dir:p,"data-orientation":a,...f,ref:t})})});WA.displayName=Pm;var qA="TabsList",KA=m.forwardRef((e,t)=>{const{__scopeTabs:n,loop:r=!0,...o}=e,i=Ow(qA,n),a=VA(n);return s.jsx(r9,{asChild:!0,...a,orientation:i.orientation,dir:i.dir,loop:r,children:s.jsx(wn.div,{role:"tablist","aria-orientation":i.orientation,...o,ref:t})})});KA.displayName=qA;var GA="TabsTrigger",YA=m.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,disabled:o=!1,...i}=e,a=Ow(GA,n),l=VA(n),d=JA(a.baseId,r),f=ZA(a.baseId,r),p=r===a.value;return s.jsx(s9,{asChild:!0,...l,focusable:!o,active:p,children:s.jsx(wn.button,{type:"button",role:"tab","aria-selected":p,"aria-controls":f,"data-state":p?"active":"inactive","data-disabled":o?"":void 0,disabled:o,id:d,...i,ref:t,onMouseDown:rn(e.onMouseDown,h=>{!o&&h.button===0&&h.ctrlKey===!1?a.onValueChange(r):h.preventDefault()}),onKeyDown:rn(e.onKeyDown,h=>{[" ","Enter"].includes(h.key)&&a.onValueChange(r)}),onFocus:rn(e.onFocus,()=>{const h=a.activationMode!=="manual";!p&&!o&&h&&a.onValueChange(r)})})})});YA.displayName=GA;var XA="TabsContent",QA=m.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,forceMount:o,children:i,...a}=e,l=Ow(XA,n),d=JA(l.baseId,r),f=ZA(l.baseId,r),p=r===l.value,h=m.useRef(p);return m.useEffect(()=>{const g=requestAnimationFrame(()=>h.current=!1);return()=>cancelAnimationFrame(g)},[]),s.jsx(Ca,{present:o||p,children:({present:g})=>s.jsx(wn.div,{"data-state":p?"active":"inactive","data-orientation":l.orientation,role:"tabpanel","aria-labelledby":d,hidden:!g,id:f,tabIndex:0,...a,ref:t,style:{...e.style,animationDuration:h.current?"0s":void 0},children:g&&i})})});QA.displayName=XA;function JA(e,t){return`${e}-trigger-${t}`}function ZA(e,t){return`${e}-content-${t}`}var eP=WA,tP=KA,Bb=YA,Ub=QA;function _m({value:e,onValueChange:t,items:n,className:r}){return s.jsxs(eP,{value:e,onValueChange:t,className:r,children:[s.jsx(tP,{className:"scrollbar-none flex gap-2 overflow-x-auto rounded-md border border-border/70 bg-card/80 p-1",children:n.map(o=>s.jsxs(Bb,{value:o.value,className:Ce("inline-flex items-center gap-2 rounded-sm px-3 py-1.5 text-sm font-medium text-muted-foreground transition","data-[state=active]:bg-foreground data-[state=active]:text-background"),children:[s.jsx("span",{children:o.label}),typeof o.count=="number"?s.jsx("span",{className:"rounded-full bg-background/20 px-2 py-0.5 text-xs data-[state=active]:bg-background/20",children:o.count}):null,o.problemCount&&o.problemCount>0?s.jsx("span",{className:"rounded-full bg-destructive/15 px-2 py-0.5 text-xs text-destructive","aria-label":`${o.problemCount} ${o.problemCount===1?"error":"errors"}`,title:`${o.problemCount} ${o.problemCount===1?"error":"errors"}`,children:o.problemCount}):null]},o.value))}),n.map(o=>s.jsx(Ub,{value:o.value,className:"pt-3",children:o.content},o.value))]})}const a9="modulepreload",l9=function(e){return"/"+e},AS={},c9=function(t,n,r){let o=Promise.resolve();if(n&&n.length>0){let a=function(f){return Promise.all(f.map(p=>Promise.resolve(p).then(h=>({status:"fulfilled",value:h}),h=>({status:"rejected",reason:h}))))};document.getElementsByTagName("link");const l=document.querySelector("meta[property=csp-nonce]"),d=(l==null?void 0:l.nonce)||(l==null?void 0:l.getAttribute("nonce"));o=a(n.map(f=>{if(f=l9(f),f in AS)return;AS[f]=!0;const p=f.endsWith(".css"),h=p?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${f}"]${h}`))return;const g=document.createElement("link");if(g.rel=p?"stylesheet":a9,p||(g.as="script"),g.crossOrigin="",g.href=f,d&&g.setAttribute("nonce",d),document.head.appendChild(g),p)return new Promise((y,k)=>{g.addEventListener("load",y),g.addEventListener("error",()=>k(new Error(`Unable to preload CSS for ${f}`)))})}))}function i(a){const l=new Event("vite:preloadError",{cancelable:!0});if(l.payload=a,window.dispatchEvent(l),!l.defaultPrevented)throw a}return o.then(a=>{for(const l of a||[])l.status==="rejected"&&i(l.reason);return t().catch(i)})};function u9({definition:e,className:t,nodeRoutes:n={}}){const r=m.useRef(null),[o,i]=m.useState(null),[a,l]=m.useState(!0),d=Ht(),f=document.documentElement.classList.contains("dark")?"dark":"default";return m.useEffect(()=>{let p=!1;async function h(){if(r.current)try{const g=(await c9(async()=>{const{default:w}=await import("./mermaid.core-IuoVhjqY.js").then(b=>b.bs);return{default:w}},[])).default;if(g.initialize({startOnLoad:!1,theme:"base",themeVariables:d9(f==="dark")}),p)return;const y=`mermaid-${Date.now()}`,{svg:k}=await g.render(y,e);if(p||!r.current)return;r.current.innerHTML=k,f9(r.current,n,d),l(!1)}catch(g){p||(i(g instanceof Error?g.message:"Failed to render graph"),l(!1))}}return l(!0),i(null),h(),()=>{p=!0}},[e,d,n,f]),o?s.jsxs("div",{className:Ce("rounded-lg border border-border bg-card p-4",t),children:[s.jsxs("p",{className:"text-sm text-error-foreground",children:["Failed to render dependency graph: ",o]}),s.jsx("pre",{className:"mt-2 text-xs text-muted-foreground overflow-auto",children:e})]}):s.jsxs("div",{className:Ce("rounded-lg border border-border bg-card p-4",t),children:[a&&s.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading graph..."}),s.jsx("div",{ref:r,className:"overflow-auto"})]})}function d9(e){const t=document.documentElement,n=h=>{const g=getComputedStyle(t).getPropertyValue(h).trim();return g?`oklch(${g})`:""},r=n("--card"),o=n("--card-foreground"),i=n("--border"),a=n("--primary"),l=n("--primary-foreground"),d=n("--muted"),f=n("--muted-foreground"),p=n("--secondary");return{background:r,primaryColor:r,primaryTextColor:o,primaryBorderColor:i,secondaryColor:d,secondaryTextColor:o,secondaryBorderColor:i,tertiaryColor:d,tertiaryTextColor:f,tertiaryBorderColor:i,lineColor:e?f:i,textColor:o,mainBkg:r,nodeBkg:r,nodeTextColor:o,nodeBorder:i,clusterBkg:d,clusterBorder:i,edgeLabelBackground:r,titleColor:o,activeTaskBkgColor:a,activeTaskBorderColor:a,altBackground:d,labelColor:o,errorBkgColor:p,errorTextColor:l}}function f9(e,t,n){var r;for(const o of e.querySelectorAll(".node")){const i=((r=o.textContent)==null?void 0:r.replace(/\s+/g," ").trim())??"",a=t[i];if(!a)continue;o.style.cursor="pointer",o.setAttribute("role","link"),o.setAttribute("tabindex","0"),o.setAttribute("aria-label",`Open ${i}`);const l=()=>n(a);o.addEventListener("click",l),o.addEventListener("keydown",d=>{(d.key==="Enter"||d.key===" ")&&(d.preventDefault(),l())})}}function p9(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const h9=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,m9=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,g9={};function PS(e,t){return(g9.jsx?m9:h9).test(e)}const x9=/[ \t\n\f\r]/g;function y9(e){return typeof e=="object"?e.type==="text"?_S(e.value):!1:_S(e)}function _S(e){return e.replace(x9,"")===""}class Ud{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}}Ud.prototype.normal={};Ud.prototype.property={};Ud.prototype.space=void 0;function nP(e,t){const n={},r={};for(const o of e)Object.assign(n,o.property),Object.assign(r,o.normal);return new Ud(n,r,t)}function Hb(e){return e.toLowerCase()}class jr{constructor(t,n){this.attribute=n,this.property=t}}jr.prototype.attribute="";jr.prototype.booleanish=!1;jr.prototype.boolean=!1;jr.prototype.commaOrSpaceSeparated=!1;jr.prototype.commaSeparated=!1;jr.prototype.defined=!1;jr.prototype.mustUseProperty=!1;jr.prototype.number=!1;jr.prototype.overloadedBoolean=!1;jr.prototype.property="";jr.prototype.spaceSeparated=!1;jr.prototype.space=void 0;let b9=0;const wt=Ta(),gn=Ta(),Vb=Ta(),Le=Ta(),qt=Ta(),zl=Ta(),Ar=Ta();function Ta(){return 2**++b9}const Wb=Object.freeze(Object.defineProperty({__proto__:null,boolean:wt,booleanish:gn,commaOrSpaceSeparated:Ar,commaSeparated:zl,number:Le,overloadedBoolean:Vb,spaceSeparated:qt},Symbol.toStringTag,{value:"Module"})),gy=Object.keys(Wb);class Fw extends jr{constructor(t,n,r,o){let i=-1;if(super(t,n),DS(this,"space",o),typeof r=="number")for(;++i<gy.length;){const a=gy[i];DS(this,gy[i],(r&Wb[a])===Wb[a])}}}Fw.prototype.defined=!0;function DS(e,t,n){n&&(e[t]=n)}function kc(e){const t={},n={};for(const[r,o]of Object.entries(e.properties)){const i=new Fw(r,e.transform(e.attributes||{},r),o,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(i.mustUseProperty=!0),t[r]=i,n[Hb(r)]=r,n[Hb(i.attribute)]=r}return new Ud(t,n,e.space)}const rP=kc({properties:{ariaActiveDescendant:null,ariaAtomic:gn,ariaAutoComplete:null,ariaBusy:gn,ariaChecked:gn,ariaColCount:Le,ariaColIndex:Le,ariaColSpan:Le,ariaControls:qt,ariaCurrent:null,ariaDescribedBy:qt,ariaDetails:null,ariaDisabled:gn,ariaDropEffect:qt,ariaErrorMessage:null,ariaExpanded:gn,ariaFlowTo:qt,ariaGrabbed:gn,ariaHasPopup:null,ariaHidden:gn,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:qt,ariaLevel:Le,ariaLive:null,ariaModal:gn,ariaMultiLine:gn,ariaMultiSelectable:gn,ariaOrientation:null,ariaOwns:qt,ariaPlaceholder:null,ariaPosInSet:Le,ariaPressed:gn,ariaReadOnly:gn,ariaRelevant:null,ariaRequired:gn,ariaRoleDescription:qt,ariaRowCount:Le,ariaRowIndex:Le,ariaRowSpan:Le,ariaSelected:gn,ariaSetSize:Le,ariaSort:null,ariaValueMax:Le,ariaValueMin:Le,ariaValueNow:Le,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function sP(e,t){return t in e?e[t]:t}function oP(e,t){return sP(e,t.toLowerCase())}const v9=kc({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:zl,acceptCharset:qt,accessKey:qt,action:null,allow:null,allowFullScreen:wt,allowPaymentRequest:wt,allowUserMedia:wt,alt:null,as:null,async:wt,autoCapitalize:null,autoComplete:qt,autoFocus:wt,autoPlay:wt,blocking:qt,capture:null,charSet:null,checked:wt,cite:null,className:qt,cols:Le,colSpan:null,content:null,contentEditable:gn,controls:wt,controlsList:qt,coords:Le|zl,crossOrigin:null,data:null,dateTime:null,decoding:null,default:wt,defer:wt,dir:null,dirName:null,disabled:wt,download:Vb,draggable:gn,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:wt,formTarget:null,headers:qt,height:Le,hidden:Vb,high:Le,href:null,hrefLang:null,htmlFor:qt,httpEquiv:qt,id:null,imageSizes:null,imageSrcSet:null,inert:wt,inputMode:null,integrity:null,is:null,isMap:wt,itemId:null,itemProp:qt,itemRef:qt,itemScope:wt,itemType:qt,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:wt,low:Le,manifest:null,max:null,maxLength:Le,media:null,method:null,min:null,minLength:Le,multiple:wt,muted:wt,name:null,nonce:null,noModule:wt,noValidate:wt,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:wt,optimum:Le,pattern:null,ping:qt,placeholder:null,playsInline:wt,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:wt,referrerPolicy:null,rel:qt,required:wt,reversed:wt,rows:Le,rowSpan:Le,sandbox:qt,scope:null,scoped:wt,seamless:wt,selected:wt,shadowRootClonable:wt,shadowRootDelegatesFocus:wt,shadowRootMode:null,shape:null,size:Le,sizes:null,slot:null,span:Le,spellCheck:gn,src:null,srcDoc:null,srcLang:null,srcSet:null,start:Le,step:null,style:null,tabIndex:Le,target:null,title:null,translate:null,type:null,typeMustMatch:wt,useMap:null,value:gn,width:Le,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:qt,axis:null,background:null,bgColor:null,border:Le,borderColor:null,bottomMargin:Le,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:wt,declare:wt,event:null,face:null,frame:null,frameBorder:null,hSpace:Le,leftMargin:Le,link:null,longDesc:null,lowSrc:null,marginHeight:Le,marginWidth:Le,noResize:wt,noHref:wt,noShade:wt,noWrap:wt,object:null,profile:null,prompt:null,rev:null,rightMargin:Le,rules:null,scheme:null,scrolling:gn,standby:null,summary:null,text:null,topMargin:Le,valueType:null,version:null,vAlign:null,vLink:null,vSpace:Le,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:wt,disableRemotePlayback:wt,prefix:null,property:null,results:Le,security:null,unselectable:null},space:"html",transform:oP}),w9=kc({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:Ar,accentHeight:Le,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:Le,amplitude:Le,arabicForm:null,ascent:Le,attributeName:null,attributeType:null,azimuth:Le,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:Le,by:null,calcMode:null,capHeight:Le,className:qt,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:Le,diffuseConstant:Le,direction:null,display:null,dur:null,divisor:Le,dominantBaseline:null,download:wt,dx:null,dy:null,edgeMode:null,editable:null,elevation:Le,enableBackground:null,end:null,event:null,exponent:Le,externalResourcesRequired:null,fill:null,fillOpacity:Le,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:zl,g2:zl,glyphName:zl,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:Le,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:Le,horizOriginX:Le,horizOriginY:Le,id:null,ideographic:Le,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:Le,k:Le,k1:Le,k2:Le,k3:Le,k4:Le,kernelMatrix:Ar,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:Le,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:Le,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:Le,overlineThickness:Le,paintOrder:null,panose1:null,path:null,pathLength:Le,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:qt,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:Le,pointsAtY:Le,pointsAtZ:Le,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:Ar,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:Ar,rev:Ar,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:Ar,requiredFeatures:Ar,requiredFonts:Ar,requiredFormats:Ar,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:Le,specularExponent:Le,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:Le,strikethroughThickness:Le,string:null,stroke:null,strokeDashArray:Ar,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:Le,strokeOpacity:Le,strokeWidth:null,style:null,surfaceScale:Le,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:Ar,tabIndex:Le,tableValues:null,target:null,targetX:Le,targetY:Le,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:Ar,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:Le,underlineThickness:Le,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:Le,values:null,vAlphabetic:Le,vMathematical:Le,vectorEffect:null,vHanging:Le,vIdeographic:Le,version:null,vertAdvY:Le,vertOriginX:Le,vertOriginY:Le,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:Le,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:sP}),iP=kc({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,t){return"xlink:"+t.slice(5).toLowerCase()}}),aP=kc({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:oP}),lP=kc({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),j9={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"},k9=/[A-Z]/g,$S=/-[a-z]/g,S9=/^data[-\w.:]+$/i;function N9(e,t){const n=Hb(t);let r=t,o=jr;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&S9.test(t)){if(t.charAt(4)==="-"){const i=t.slice(5).replace($S,E9);r="data"+i.charAt(0).toUpperCase()+i.slice(1)}else{const i=t.slice(4);if(!$S.test(i)){let a=i.replace(k9,C9);a.charAt(0)!=="-"&&(a="-"+a),t="data"+a}}o=Fw}return new o(r,t)}function C9(e){return"-"+e.toLowerCase()}function E9(e){return e.charAt(1).toUpperCase()}const T9=nP([rP,v9,iP,aP,lP],"html"),zw=nP([rP,w9,iP,aP,lP],"svg");function R9(e){return e.join(" ").trim()}var ml={},xy,IS;function A9(){if(IS)return xy;IS=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,t=/\n/g,n=/^\s*/,r=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,o=/^:\s*/,i=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,a=/^[;\s]*/,l=/^\s+|\s+$/g,d=`
591
+ `,f="/",p="*",h="",g="comment",y="declaration";function k(b,j){if(typeof b!="string")throw new TypeError("First argument must be a string");if(!b)return[];j=j||{};var N=1,S=1;function C(A){var L=A.match(t);L&&(N+=L.length);var z=A.lastIndexOf(d);S=~z?A.length-z:S+A.length}function D(){var A={line:N,column:S};return function(L){return L.position=new T(A),_(),L}}function T(A){this.start=A,this.end={line:N,column:S},this.source=j.source}T.prototype.content=b;function R(A){var L=new Error(j.source+":"+N+":"+S+": "+A);if(L.reason=A,L.filename=j.source,L.line=N,L.column=S,L.source=b,!j.silent)throw L}function $(A){var L=A.exec(b);if(L){var z=L[0];return C(z),b=b.slice(z.length),L}}function _(){$(n)}function U(A){var L;for(A=A||[];L=I();)L!==!1&&A.push(L);return A}function I(){var A=D();if(!(f!=b.charAt(0)||p!=b.charAt(1))){for(var L=2;h!=b.charAt(L)&&(p!=b.charAt(L)||f!=b.charAt(L+1));)++L;if(L+=2,h===b.charAt(L-1))return R("End of comment missing");var z=b.slice(2,L-2);return S+=2,C(z),b=b.slice(L),S+=2,A({type:g,comment:z})}}function F(){var A=D(),L=$(r);if(L){if(I(),!$(o))return R("property missing ':'");var z=$(i),W=A({type:y,property:w(L[0].replace(e,h)),value:z?w(z[0].replace(e,h)):h});return $(a),W}}function M(){var A=[];U(A);for(var L;L=F();)L!==!1&&(A.push(L),U(A));return A}return _(),M()}function w(b){return b?b.replace(l,h):h}return xy=k,xy}var MS;function P9(){if(MS)return ml;MS=1;var e=ml&&ml.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(ml,"__esModule",{value:!0}),ml.default=n;const t=e(A9());function n(r,o){let i=null;if(!r||typeof r!="string")return i;const a=(0,t.default)(r),l=typeof o=="function";return a.forEach(d=>{if(d.type!=="declaration")return;const{property:f,value:p}=d;l?o(f,p,d):p&&(i=i||{},i[f]=p)}),i}return ml}var pu={},LS;function _9(){if(LS)return pu;LS=1,Object.defineProperty(pu,"__esModule",{value:!0}),pu.camelCase=void 0;var e=/^--[a-zA-Z0-9_-]+$/,t=/-([a-z])/g,n=/^[^-]+$/,r=/^-(webkit|moz|ms|o|khtml)-/,o=/^-(ms)-/,i=function(f){return!f||n.test(f)||e.test(f)},a=function(f,p){return p.toUpperCase()},l=function(f,p){return"".concat(p,"-")},d=function(f,p){return p===void 0&&(p={}),i(f)?f:(f=f.toLowerCase(),p.reactCompat?f=f.replace(o,l):f=f.replace(r,l),f.replace(t,a))};return pu.camelCase=d,pu}var hu,OS;function D9(){if(OS)return hu;OS=1;var e=hu&&hu.__importDefault||function(o){return o&&o.__esModule?o:{default:o}},t=e(P9()),n=_9();function r(o,i){var a={};return!o||typeof o!="string"||(0,t.default)(o,function(l,d){l&&d&&(a[(0,n.camelCase)(l,i)]=d)}),a}return r.default=r,hu=r,hu}var $9=D9();const I9=wd($9),cP=uP("end"),Bw=uP("start");function uP(e){return t;function t(n){const r=n&&n.position&&n.position[e]||{};if(typeof r.line=="number"&&r.line>0&&typeof r.column=="number"&&r.column>0)return{line:r.line,column:r.column,offset:typeof r.offset=="number"&&r.offset>-1?r.offset:void 0}}}function M9(e){const t=Bw(e),n=cP(e);if(t&&n)return{start:t,end:n}}function zu(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?FS(e.position):"start"in e||"end"in e?FS(e):"line"in e||"column"in e?qb(e):""}function qb(e){return zS(e&&e.line)+":"+zS(e&&e.column)}function FS(e){return qb(e&&e.start)+"-"+qb(e&&e.end)}function zS(e){return e&&typeof e=="number"?e:1}class tr extends Error{constructor(t,n,r){super(),typeof n=="string"&&(r=n,n=void 0);let o="",i={},a=!1;if(n&&("line"in n&&"column"in n?i={place:n}:"start"in n&&"end"in n?i={place:n}:"type"in n?i={ancestors:[n],place:n.position}:i={...n}),typeof t=="string"?o=t:!i.cause&&t&&(a=!0,o=t.message,i.cause=t),!i.ruleId&&!i.source&&typeof r=="string"){const d=r.indexOf(":");d===-1?i.ruleId=r:(i.source=r.slice(0,d),i.ruleId=r.slice(d+1))}if(!i.place&&i.ancestors&&i.ancestors){const d=i.ancestors[i.ancestors.length-1];d&&(i.place=d.position)}const l=i.place&&"start"in i.place?i.place.start:i.place;this.ancestors=i.ancestors||void 0,this.cause=i.cause||void 0,this.column=l?l.column:void 0,this.fatal=void 0,this.file="",this.message=o,this.line=l?l.line:void 0,this.name=zu(i.place)||"1:1",this.place=i.place||void 0,this.reason=this.message,this.ruleId=i.ruleId||void 0,this.source=i.source||void 0,this.stack=a&&i.cause&&typeof i.cause.stack=="string"?i.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}tr.prototype.file="";tr.prototype.name="";tr.prototype.reason="";tr.prototype.message="";tr.prototype.stack="";tr.prototype.column=void 0;tr.prototype.line=void 0;tr.prototype.ancestors=void 0;tr.prototype.cause=void 0;tr.prototype.fatal=void 0;tr.prototype.place=void 0;tr.prototype.ruleId=void 0;tr.prototype.source=void 0;const Uw={}.hasOwnProperty,L9=new Map,O9=/[A-Z]/g,F9=new Set(["table","tbody","thead","tfoot","tr"]),z9=new Set(["td","th"]),dP="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function B9(e,t){if(!t||t.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const n=t.filePath||void 0;let r;if(t.development){if(typeof t.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");r=Y9(n,t.jsxDEV)}else{if(typeof t.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof t.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");r=G9(n,t.jsx,t.jsxs)}const o={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:r,elementAttributeNameCase:t.elementAttributeNameCase||"react",evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space==="svg"?zw:T9,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},i=fP(o,e,void 0);return i&&typeof i!="string"?i:o.create(e,o.Fragment,{children:i||void 0},void 0)}function fP(e,t,n){if(t.type==="element")return U9(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return H9(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return W9(e,t,n);if(t.type==="mdxjsEsm")return V9(e,t);if(t.type==="root")return q9(e,t,n);if(t.type==="text")return K9(e,t)}function U9(e,t,n){const r=e.schema;let o=r;t.tagName.toLowerCase()==="svg"&&r.space==="html"&&(o=zw,e.schema=o),e.ancestors.push(t);const i=hP(e,t.tagName,!1),a=X9(e,t);let l=Vw(e,t);return F9.has(t.tagName)&&(l=l.filter(function(d){return typeof d=="string"?!y9(d):!0})),pP(e,a,i,t),Hw(a,l),e.ancestors.pop(),e.schema=r,e.create(t,i,a,n)}function H9(e,t){if(t.data&&t.data.estree&&e.evaluater){const r=t.data.estree.body[0];return r.type,e.evaluater.evaluateExpression(r.expression)}ad(e,t.position)}function V9(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);ad(e,t.position)}function W9(e,t,n){const r=e.schema;let o=r;t.name==="svg"&&r.space==="html"&&(o=zw,e.schema=o),e.ancestors.push(t);const i=t.name===null?e.Fragment:hP(e,t.name,!0),a=Q9(e,t),l=Vw(e,t);return pP(e,a,i,t),Hw(a,l),e.ancestors.pop(),e.schema=r,e.create(t,i,a,n)}function q9(e,t,n){const r={};return Hw(r,Vw(e,t)),e.create(t,e.Fragment,r,n)}function K9(e,t){return t.value}function pP(e,t,n,r){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=r)}function Hw(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function G9(e,t,n){return r;function r(o,i,a,l){const f=Array.isArray(a.children)?n:t;return l?f(i,a,l):f(i,a)}}function Y9(e,t){return n;function n(r,o,i,a){const l=Array.isArray(i.children),d=Bw(r);return t(o,i,a,l,{columnNumber:d?d.column-1:void 0,fileName:e,lineNumber:d?d.line:void 0},void 0)}}function X9(e,t){const n={};let r,o;for(o in t.properties)if(o!=="children"&&Uw.call(t.properties,o)){const i=J9(e,o,t.properties[o]);if(i){const[a,l]=i;e.tableCellAlignToStyle&&a==="align"&&typeof l=="string"&&z9.has(t.tagName)?r=l:n[a]=l}}if(r){const i=n.style||(n.style={});i[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=r}return n}function Q9(e,t){const n={};for(const r of t.attributes)if(r.type==="mdxJsxExpressionAttribute")if(r.data&&r.data.estree&&e.evaluater){const i=r.data.estree.body[0];i.type;const a=i.expression;a.type;const l=a.properties[0];l.type,Object.assign(n,e.evaluater.evaluateExpression(l.argument))}else ad(e,t.position);else{const o=r.name;let i;if(r.value&&typeof r.value=="object")if(r.value.data&&r.value.data.estree&&e.evaluater){const l=r.value.data.estree.body[0];l.type,i=e.evaluater.evaluateExpression(l.expression)}else ad(e,t.position);else i=r.value===null?!0:r.value;n[o]=i}return n}function Vw(e,t){const n=[];let r=-1;const o=e.passKeys?new Map:L9;for(;++r<t.children.length;){const i=t.children[r];let a;if(e.passKeys){const d=i.type==="element"?i.tagName:i.type==="mdxJsxFlowElement"||i.type==="mdxJsxTextElement"?i.name:void 0;if(d){const f=o.get(d)||0;a=d+"-"+f,o.set(d,f+1)}}const l=fP(e,i,a);l!==void 0&&n.push(l)}return n}function J9(e,t,n){const r=N9(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?p9(n):R9(n)),r.property==="style"){let o=typeof n=="object"?n:Z9(e,String(n));return e.stylePropertyNameCase==="css"&&(o=eV(o)),["style",o]}return[e.elementAttributeNameCase==="react"&&r.space?j9[r.property]||r.property:r.attribute,n]}}function Z9(e,t){try{return I9(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const r=n,o=new tr("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:r,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw o.file=e.filePath||void 0,o.url=dP+"#cannot-parse-style-attribute",o}}function hP(e,t,n){let r;if(!n)r={type:"Literal",value:t};else if(t.includes(".")){const o=t.split(".");let i=-1,a;for(;++i<o.length;){const l=PS(o[i])?{type:"Identifier",name:o[i]}:{type:"Literal",value:o[i]};a=a?{type:"MemberExpression",object:a,property:l,computed:!!(i&&l.type==="Literal"),optional:!1}:l}r=a}else r=PS(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(r.type==="Literal"){const o=r.value;return Uw.call(e.components,o)?e.components[o]:o}if(e.evaluater)return e.evaluater.evaluateExpression(r);ad(e)}function ad(e,t){const n=new tr("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw n.file=e.filePath||void 0,n.url=dP+"#cannot-handle-mdx-estrees-without-createevaluater",n}function eV(e){const t={};let n;for(n in e)Uw.call(e,n)&&(t[tV(n)]=e[n]);return t}function tV(e){let t=e.replace(O9,nV);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function nV(e){return"-"+e.toLowerCase()}const yy={action:["form"],cite:["blockquote","del","ins","q"],data:["object"],formAction:["button","input"],href:["a","area","base","link"],icon:["menuitem"],itemId:null,manifest:["html"],ping:["a","area"],poster:["video"],src:["audio","embed","iframe","img","input","script","source","track","video"]},rV={};function sV(e,t){const n=rV,r=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,o=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return mP(e,r,o)}function mP(e,t,n){if(oV(e)){if("value"in e)return e.type==="html"&&!n?"":e.value;if(t&&"alt"in e&&e.alt)return e.alt;if("children"in e)return BS(e.children,t,n)}return Array.isArray(e)?BS(e,t,n):""}function BS(e,t,n){const r=[];let o=-1;for(;++o<e.length;)r[o]=mP(e[o],t,n);return r.join("")}function oV(e){return!!(e&&typeof e=="object")}const US=document.createElement("i");function Ww(e){const t="&"+e+";";US.innerHTML=t;const n=US.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}function Js(e,t,n,r){const o=e.length;let i=0,a;if(t<0?t=-t>o?0:o+t:t=t>o?o:t,n=n>0?n:0,r.length<1e4)a=Array.from(r),a.unshift(t,n),e.splice(...a);else for(n&&e.splice(t,n);i<r.length;)a=r.slice(i,i+1e4),a.unshift(t,0),e.splice(...a),i+=1e4,t+=1e4}function Jr(e,t){return e.length>0?(Js(e,e.length,0,t),e):t}const HS={}.hasOwnProperty;function iV(e){const t={};let n=-1;for(;++n<e.length;)aV(t,e[n]);return t}function aV(e,t){let n;for(n in t){const o=(HS.call(e,n)?e[n]:void 0)||(e[n]={}),i=t[n];let a;if(i)for(a in i){HS.call(o,a)||(o[a]=[]);const l=i[a];lV(o[a],Array.isArray(l)?l:l?[l]:[])}}}function lV(e,t){let n=-1;const r=[];for(;++n<t.length;)(t[n].add==="after"?e:r).push(t[n]);Js(e,0,0,r)}function gP(e,t){const n=Number.parseInt(e,t);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)===65535||(n&65535)===65534||n>1114111?"�":String.fromCodePoint(n)}function Bl(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const Vs=Ti(/[A-Za-z]/),Or=Ti(/[\dA-Za-z]/),cV=Ti(/[#-'*+\--9=?A-Z^-~]/);function Kb(e){return e!==null&&(e<32||e===127)}const Gb=Ti(/\d/),uV=Ti(/[\dA-Fa-f]/),dV=Ti(/[!-/:-@[-`{-~]/);function ht(e){return e!==null&&e<-2}function br(e){return e!==null&&(e<0||e===32)}function Ot(e){return e===-2||e===-1||e===32}const fV=Ti(new RegExp("\\p{P}|\\p{S}","u")),pV=Ti(/\s/);function Ti(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function Sc(e){const t=[];let n=-1,r=0,o=0;for(;++n<e.length;){const i=e.charCodeAt(n);let a="";if(i===37&&Or(e.charCodeAt(n+1))&&Or(e.charCodeAt(n+2)))o=2;else if(i<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(i))||(a=String.fromCharCode(i));else if(i>55295&&i<57344){const l=e.charCodeAt(n+1);i<56320&&l>56319&&l<57344?(a=String.fromCharCode(i,l),o=1):a="�"}else a=String.fromCharCode(i);a&&(t.push(e.slice(r,n),encodeURIComponent(a)),r=n+o+1,a=""),o&&(n+=o,o=0)}return t.join("")+e.slice(r)}function Kt(e,t,n,r){const o=r?r-1:Number.POSITIVE_INFINITY;let i=0;return a;function a(d){return Ot(d)?(e.enter(n),l(d)):t(d)}function l(d){return Ot(d)&&i++<o?(e.consume(d),l):(e.exit(n),t(d))}}const hV={tokenize:mV};function mV(e){const t=e.attempt(this.parser.constructs.contentInitial,r,o);let n;return t;function r(l){if(l===null){e.consume(l);return}return e.enter("lineEnding"),e.consume(l),e.exit("lineEnding"),Kt(e,t,"linePrefix")}function o(l){return e.enter("paragraph"),i(l)}function i(l){const d=e.enter("chunkText",{contentType:"text",previous:n});return n&&(n.next=d),n=d,a(l)}function a(l){if(l===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(l);return}return ht(l)?(e.consume(l),e.exit("chunkText"),i):(e.consume(l),a)}}const gV={tokenize:xV},VS={tokenize:yV};function xV(e){const t=this,n=[];let r=0,o,i,a;return l;function l(S){if(r<n.length){const C=n[r];return t.containerState=C[1],e.attempt(C[0].continuation,d,f)(S)}return f(S)}function d(S){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,o&&N();const C=t.events.length;let D=C,T;for(;D--;)if(t.events[D][0]==="exit"&&t.events[D][1].type==="chunkFlow"){T=t.events[D][1].end;break}j(r);let R=C;for(;R<t.events.length;)t.events[R][1].end={...T},R++;return Js(t.events,D+1,0,t.events.slice(C)),t.events.length=R,f(S)}return l(S)}function f(S){if(r===n.length){if(!o)return g(S);if(o.currentConstruct&&o.currentConstruct.concrete)return k(S);t.interrupt=!!(o.currentConstruct&&!o._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(VS,p,h)(S)}function p(S){return o&&N(),j(r),g(S)}function h(S){return t.parser.lazy[t.now().line]=r!==n.length,a=t.now().offset,k(S)}function g(S){return t.containerState={},e.attempt(VS,y,k)(S)}function y(S){return r++,n.push([t.currentConstruct,t.containerState]),g(S)}function k(S){if(S===null){o&&N(),j(0),e.consume(S);return}return o=o||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:o,contentType:"flow",previous:i}),w(S)}function w(S){if(S===null){b(e.exit("chunkFlow"),!0),j(0),e.consume(S);return}return ht(S)?(e.consume(S),b(e.exit("chunkFlow")),r=0,t.interrupt=void 0,l):(e.consume(S),w)}function b(S,C){const D=t.sliceStream(S);if(C&&D.push(null),S.previous=i,i&&(i.next=S),i=S,o.defineSkip(S.start),o.write(D),t.parser.lazy[S.start.line]){let T=o.events.length;for(;T--;)if(o.events[T][1].start.offset<a&&(!o.events[T][1].end||o.events[T][1].end.offset>a))return;const R=t.events.length;let $=R,_,U;for(;$--;)if(t.events[$][0]==="exit"&&t.events[$][1].type==="chunkFlow"){if(_){U=t.events[$][1].end;break}_=!0}for(j(r),T=R;T<t.events.length;)t.events[T][1].end={...U},T++;Js(t.events,$+1,0,t.events.slice(R)),t.events.length=T}}function j(S){let C=n.length;for(;C-- >S;){const D=n[C];t.containerState=D[1],D[0].exit.call(t,e)}n.length=S}function N(){o.write([null]),i=void 0,o=void 0,t.containerState._closeFlow=void 0}}function yV(e,t,n){return Kt(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function WS(e){if(e===null||br(e)||pV(e))return 1;if(fV(e))return 2}function qw(e,t,n){const r=[];let o=-1;for(;++o<e.length;){const i=e[o].resolveAll;i&&!r.includes(i)&&(t=i(t,n),r.push(i))}return t}const Yb={name:"attention",resolveAll:bV,tokenize:vV};function bV(e,t){let n=-1,r,o,i,a,l,d,f,p;for(;++n<e.length;)if(e[n][0]==="enter"&&e[n][1].type==="attentionSequence"&&e[n][1]._close){for(r=n;r--;)if(e[r][0]==="exit"&&e[r][1].type==="attentionSequence"&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[r][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;d=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;const h={...e[r][1].end},g={...e[n][1].start};qS(h,-d),qS(g,d),a={type:d>1?"strongSequence":"emphasisSequence",start:h,end:{...e[r][1].end}},l={type:d>1?"strongSequence":"emphasisSequence",start:{...e[n][1].start},end:g},i={type:d>1?"strongText":"emphasisText",start:{...e[r][1].end},end:{...e[n][1].start}},o={type:d>1?"strong":"emphasis",start:{...a.start},end:{...l.end}},e[r][1].end={...a.start},e[n][1].start={...l.end},f=[],e[r][1].end.offset-e[r][1].start.offset&&(f=Jr(f,[["enter",e[r][1],t],["exit",e[r][1],t]])),f=Jr(f,[["enter",o,t],["enter",a,t],["exit",a,t],["enter",i,t]]),f=Jr(f,qw(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),f=Jr(f,[["exit",i,t],["enter",l,t],["exit",l,t],["exit",o,t]]),e[n][1].end.offset-e[n][1].start.offset?(p=2,f=Jr(f,[["enter",e[n][1],t],["exit",e[n][1],t]])):p=0,Js(e,r-1,n-r+3,f),n=r+f.length-p-2;break}}for(n=-1;++n<e.length;)e[n][1].type==="attentionSequence"&&(e[n][1].type="data");return e}function vV(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,o=WS(r);let i;return a;function a(d){return i=d,e.enter("attentionSequence"),l(d)}function l(d){if(d===i)return e.consume(d),l;const f=e.exit("attentionSequence"),p=WS(d),h=!p||p===2&&o||n.includes(d),g=!o||o===2&&p||n.includes(r);return f._open=!!(i===42?h:h&&(o||!g)),f._close=!!(i===42?g:g&&(p||!h)),t(d)}}function qS(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const wV={name:"autolink",tokenize:jV};function jV(e,t,n){let r=0;return o;function o(y){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(y),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),i}function i(y){return Vs(y)?(e.consume(y),a):y===64?n(y):f(y)}function a(y){return y===43||y===45||y===46||Or(y)?(r=1,l(y)):f(y)}function l(y){return y===58?(e.consume(y),r=0,d):(y===43||y===45||y===46||Or(y))&&r++<32?(e.consume(y),l):(r=0,f(y))}function d(y){return y===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(y),e.exit("autolinkMarker"),e.exit("autolink"),t):y===null||y===32||y===60||Kb(y)?n(y):(e.consume(y),d)}function f(y){return y===64?(e.consume(y),p):cV(y)?(e.consume(y),f):n(y)}function p(y){return Or(y)?h(y):n(y)}function h(y){return y===46?(e.consume(y),r=0,p):y===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(y),e.exit("autolinkMarker"),e.exit("autolink"),t):g(y)}function g(y){if((y===45||Or(y))&&r++<63){const k=y===45?g:h;return e.consume(y),k}return n(y)}}const Dm={partial:!0,tokenize:kV};function kV(e,t,n){return r;function r(i){return Ot(i)?Kt(e,o,"linePrefix")(i):o(i)}function o(i){return i===null||ht(i)?t(i):n(i)}}const xP={continuation:{tokenize:NV},exit:CV,name:"blockQuote",tokenize:SV};function SV(e,t,n){const r=this;return o;function o(a){if(a===62){const l=r.containerState;return l.open||(e.enter("blockQuote",{_container:!0}),l.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(a),e.exit("blockQuoteMarker"),i}return n(a)}function i(a){return Ot(a)?(e.enter("blockQuotePrefixWhitespace"),e.consume(a),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(a))}}function NV(e,t,n){const r=this;return o;function o(a){return Ot(a)?Kt(e,i,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(a):i(a)}function i(a){return e.attempt(xP,t,n)(a)}}function CV(e){e.exit("blockQuote")}const yP={name:"characterEscape",tokenize:EV};function EV(e,t,n){return r;function r(i){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(i),e.exit("escapeMarker"),o}function o(i){return dV(i)?(e.enter("characterEscapeValue"),e.consume(i),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(i)}}const bP={name:"characterReference",tokenize:TV};function TV(e,t,n){const r=this;let o=0,i,a;return l;function l(h){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(h),e.exit("characterReferenceMarker"),d}function d(h){return h===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(h),e.exit("characterReferenceMarkerNumeric"),f):(e.enter("characterReferenceValue"),i=31,a=Or,p(h))}function f(h){return h===88||h===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(h),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),i=6,a=uV,p):(e.enter("characterReferenceValue"),i=7,a=Gb,p(h))}function p(h){if(h===59&&o){const g=e.exit("characterReferenceValue");return a===Or&&!Ww(r.sliceSerialize(g))?n(h):(e.enter("characterReferenceMarker"),e.consume(h),e.exit("characterReferenceMarker"),e.exit("characterReference"),t)}return a(h)&&o++<i?(e.consume(h),p):n(h)}}const KS={partial:!0,tokenize:AV},GS={concrete:!0,name:"codeFenced",tokenize:RV};function RV(e,t,n){const r=this,o={partial:!0,tokenize:D};let i=0,a=0,l;return d;function d(T){return f(T)}function f(T){const R=r.events[r.events.length-1];return i=R&&R[1].type==="linePrefix"?R[2].sliceSerialize(R[1],!0).length:0,l=T,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),p(T)}function p(T){return T===l?(a++,e.consume(T),p):a<3?n(T):(e.exit("codeFencedFenceSequence"),Ot(T)?Kt(e,h,"whitespace")(T):h(T))}function h(T){return T===null||ht(T)?(e.exit("codeFencedFence"),r.interrupt?t(T):e.check(KS,w,C)(T)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),g(T))}function g(T){return T===null||ht(T)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),h(T)):Ot(T)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),Kt(e,y,"whitespace")(T)):T===96&&T===l?n(T):(e.consume(T),g)}function y(T){return T===null||ht(T)?h(T):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),k(T))}function k(T){return T===null||ht(T)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),h(T)):T===96&&T===l?n(T):(e.consume(T),k)}function w(T){return e.attempt(o,C,b)(T)}function b(T){return e.enter("lineEnding"),e.consume(T),e.exit("lineEnding"),j}function j(T){return i>0&&Ot(T)?Kt(e,N,"linePrefix",i+1)(T):N(T)}function N(T){return T===null||ht(T)?e.check(KS,w,C)(T):(e.enter("codeFlowValue"),S(T))}function S(T){return T===null||ht(T)?(e.exit("codeFlowValue"),N(T)):(e.consume(T),S)}function C(T){return e.exit("codeFenced"),t(T)}function D(T,R,$){let _=0;return U;function U(L){return T.enter("lineEnding"),T.consume(L),T.exit("lineEnding"),I}function I(L){return T.enter("codeFencedFence"),Ot(L)?Kt(T,F,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(L):F(L)}function F(L){return L===l?(T.enter("codeFencedFenceSequence"),M(L)):$(L)}function M(L){return L===l?(_++,T.consume(L),M):_>=a?(T.exit("codeFencedFenceSequence"),Ot(L)?Kt(T,A,"whitespace")(L):A(L)):$(L)}function A(L){return L===null||ht(L)?(T.exit("codeFencedFence"),R(L)):$(L)}}}function AV(e,t,n){const r=this;return o;function o(a){return a===null?n(a):(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),i)}function i(a){return r.parser.lazy[r.now().line]?n(a):t(a)}}const by={name:"codeIndented",tokenize:_V},PV={partial:!0,tokenize:DV};function _V(e,t,n){const r=this;return o;function o(f){return e.enter("codeIndented"),Kt(e,i,"linePrefix",5)(f)}function i(f){const p=r.events[r.events.length-1];return p&&p[1].type==="linePrefix"&&p[2].sliceSerialize(p[1],!0).length>=4?a(f):n(f)}function a(f){return f===null?d(f):ht(f)?e.attempt(PV,a,d)(f):(e.enter("codeFlowValue"),l(f))}function l(f){return f===null||ht(f)?(e.exit("codeFlowValue"),a(f)):(e.consume(f),l)}function d(f){return e.exit("codeIndented"),t(f)}}function DV(e,t,n){const r=this;return o;function o(a){return r.parser.lazy[r.now().line]?n(a):ht(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),o):Kt(e,i,"linePrefix",5)(a)}function i(a){const l=r.events[r.events.length-1];return l&&l[1].type==="linePrefix"&&l[2].sliceSerialize(l[1],!0).length>=4?t(a):ht(a)?o(a):n(a)}}const $V={name:"codeText",previous:MV,resolve:IV,tokenize:LV};function IV(e){let t=e.length-4,n=3,r,o;if((e[n][1].type==="lineEnding"||e[n][1].type==="space")&&(e[t][1].type==="lineEnding"||e[t][1].type==="space")){for(r=n;++r<t;)if(e[r][1].type==="codeTextData"){e[n][1].type="codeTextPadding",e[t][1].type="codeTextPadding",n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)o===void 0?r!==t&&e[r][1].type!=="lineEnding"&&(o=r):(r===t||e[r][1].type==="lineEnding")&&(e[o][1].type="codeTextData",r!==o+2&&(e[o][1].end=e[r-1][1].end,e.splice(o+2,r-o-2),t-=r-o-2,r=o+2),o=void 0);return e}function MV(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function LV(e,t,n){let r=0,o,i;return a;function a(h){return e.enter("codeText"),e.enter("codeTextSequence"),l(h)}function l(h){return h===96?(e.consume(h),r++,l):(e.exit("codeTextSequence"),d(h))}function d(h){return h===null?n(h):h===32?(e.enter("space"),e.consume(h),e.exit("space"),d):h===96?(i=e.enter("codeTextSequence"),o=0,p(h)):ht(h)?(e.enter("lineEnding"),e.consume(h),e.exit("lineEnding"),d):(e.enter("codeTextData"),f(h))}function f(h){return h===null||h===32||h===96||ht(h)?(e.exit("codeTextData"),d(h)):(e.consume(h),f)}function p(h){return h===96?(e.consume(h),o++,p):o===r?(e.exit("codeTextSequence"),e.exit("codeText"),t(h)):(i.type="codeTextData",f(h))}}class OV{constructor(t){this.left=t?[...t]:[],this.right=[]}get(t){if(t<0||t>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+t+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return t<this.left.length?this.left[t]:this.right[this.right.length-t+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(t,n){const r=n??Number.POSITIVE_INFINITY;return r<this.left.length?this.left.slice(t,r):t>this.left.length?this.right.slice(this.right.length-r+this.left.length,this.right.length-t+this.left.length).reverse():this.left.slice(t).concat(this.right.slice(this.right.length-r+this.left.length).reverse())}splice(t,n,r){const o=n||0;this.setCursor(Math.trunc(t));const i=this.right.splice(this.right.length-o,Number.POSITIVE_INFINITY);return r&&mu(this.left,r),i.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(t){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(t)}pushMany(t){this.setCursor(Number.POSITIVE_INFINITY),mu(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),mu(this.right,t.reverse())}setCursor(t){if(!(t===this.left.length||t>this.left.length&&this.right.length===0||t<0&&this.left.length===0))if(t<this.left.length){const n=this.left.splice(t,Number.POSITIVE_INFINITY);mu(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);mu(this.left,n.reverse())}}}function mu(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function vP(e){const t={};let n=-1,r,o,i,a,l,d,f;const p=new OV(e);for(;++n<p.length;){for(;n in t;)n=t[n];if(r=p.get(n),n&&r[1].type==="chunkFlow"&&p.get(n-1)[1].type==="listItemPrefix"&&(d=r[1]._tokenizer.events,i=0,i<d.length&&d[i][1].type==="lineEndingBlank"&&(i+=2),i<d.length&&d[i][1].type==="content"))for(;++i<d.length&&d[i][1].type!=="content";)d[i][1].type==="chunkText"&&(d[i][1]._isInFirstContentOfListItem=!0,i++);if(r[0]==="enter")r[1].contentType&&(Object.assign(t,FV(p,n)),n=t[n],f=!0);else if(r[1]._container){for(i=n,o=void 0;i--;)if(a=p.get(i),a[1].type==="lineEnding"||a[1].type==="lineEndingBlank")a[0]==="enter"&&(o&&(p.get(o)[1].type="lineEndingBlank"),a[1].type="lineEnding",o=i);else if(!(a[1].type==="linePrefix"||a[1].type==="listItemIndent"))break;o&&(r[1].end={...p.get(o)[1].start},l=p.slice(o,n),l.unshift(r),p.splice(o,n-o+1,l))}}return Js(e,0,Number.POSITIVE_INFINITY,p.slice(0)),!f}function FV(e,t){const n=e.get(t)[1],r=e.get(t)[2];let o=t-1;const i=[];let a=n._tokenizer;a||(a=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(a._contentTypeTextTrailing=!0));const l=a.events,d=[],f={};let p,h,g=-1,y=n,k=0,w=0;const b=[w];for(;y;){for(;e.get(++o)[1]!==y;);i.push(o),y._tokenizer||(p=r.sliceStream(y),y.next||p.push(null),h&&a.defineSkip(y.start),y._isInFirstContentOfListItem&&(a._gfmTasklistFirstContentOfListItem=!0),a.write(p),y._isInFirstContentOfListItem&&(a._gfmTasklistFirstContentOfListItem=void 0)),h=y,y=y.next}for(y=n;++g<l.length;)l[g][0]==="exit"&&l[g-1][0]==="enter"&&l[g][1].type===l[g-1][1].type&&l[g][1].start.line!==l[g][1].end.line&&(w=g+1,b.push(w),y._tokenizer=void 0,y.previous=void 0,y=y.next);for(a.events=[],y?(y._tokenizer=void 0,y.previous=void 0):b.pop(),g=b.length;g--;){const j=l.slice(b[g],b[g+1]),N=i.pop();d.push([N,N+j.length-1]),e.splice(N,2,j)}for(d.reverse(),g=-1;++g<d.length;)f[k+d[g][0]]=k+d[g][1],k+=d[g][1]-d[g][0]-1;return f}const zV={resolve:UV,tokenize:HV},BV={partial:!0,tokenize:VV};function UV(e){return vP(e),e}function HV(e,t){let n;return r;function r(l){return e.enter("content"),n=e.enter("chunkContent",{contentType:"content"}),o(l)}function o(l){return l===null?i(l):ht(l)?e.check(BV,a,i)(l):(e.consume(l),o)}function i(l){return e.exit("chunkContent"),e.exit("content"),t(l)}function a(l){return e.consume(l),e.exit("chunkContent"),n.next=e.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,o}}function VV(e,t,n){const r=this;return o;function o(a){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),Kt(e,i,"linePrefix")}function i(a){if(a===null||ht(a))return n(a);const l=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes("codeIndented")&&l&&l[1].type==="linePrefix"&&l[2].sliceSerialize(l[1],!0).length>=4?t(a):e.interrupt(r.parser.constructs.flow,n,t)(a)}}function wP(e,t,n,r,o,i,a,l,d){const f=d||Number.POSITIVE_INFINITY;let p=0;return h;function h(j){return j===60?(e.enter(r),e.enter(o),e.enter(i),e.consume(j),e.exit(i),g):j===null||j===32||j===41||Kb(j)?n(j):(e.enter(r),e.enter(a),e.enter(l),e.enter("chunkString",{contentType:"string"}),w(j))}function g(j){return j===62?(e.enter(i),e.consume(j),e.exit(i),e.exit(o),e.exit(r),t):(e.enter(l),e.enter("chunkString",{contentType:"string"}),y(j))}function y(j){return j===62?(e.exit("chunkString"),e.exit(l),g(j)):j===null||j===60||ht(j)?n(j):(e.consume(j),j===92?k:y)}function k(j){return j===60||j===62||j===92?(e.consume(j),y):y(j)}function w(j){return!p&&(j===null||j===41||br(j))?(e.exit("chunkString"),e.exit(l),e.exit(a),e.exit(r),t(j)):p<f&&j===40?(e.consume(j),p++,w):j===41?(e.consume(j),p--,w):j===null||j===32||j===40||Kb(j)?n(j):(e.consume(j),j===92?b:w)}function b(j){return j===40||j===41||j===92?(e.consume(j),w):w(j)}}function jP(e,t,n,r,o,i){const a=this;let l=0,d;return f;function f(y){return e.enter(r),e.enter(o),e.consume(y),e.exit(o),e.enter(i),p}function p(y){return l>999||y===null||y===91||y===93&&!d||y===94&&!l&&"_hiddenFootnoteSupport"in a.parser.constructs?n(y):y===93?(e.exit(i),e.enter(o),e.consume(y),e.exit(o),e.exit(r),t):ht(y)?(e.enter("lineEnding"),e.consume(y),e.exit("lineEnding"),p):(e.enter("chunkString",{contentType:"string"}),h(y))}function h(y){return y===null||y===91||y===93||ht(y)||l++>999?(e.exit("chunkString"),p(y)):(e.consume(y),d||(d=!Ot(y)),y===92?g:h)}function g(y){return y===91||y===92||y===93?(e.consume(y),l++,h):h(y)}}function kP(e,t,n,r,o,i){let a;return l;function l(g){return g===34||g===39||g===40?(e.enter(r),e.enter(o),e.consume(g),e.exit(o),a=g===40?41:g,d):n(g)}function d(g){return g===a?(e.enter(o),e.consume(g),e.exit(o),e.exit(r),t):(e.enter(i),f(g))}function f(g){return g===a?(e.exit(i),d(a)):g===null?n(g):ht(g)?(e.enter("lineEnding"),e.consume(g),e.exit("lineEnding"),Kt(e,f,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),p(g))}function p(g){return g===a||g===null||ht(g)?(e.exit("chunkString"),f(g)):(e.consume(g),g===92?h:p)}function h(g){return g===a||g===92?(e.consume(g),p):p(g)}}function Bu(e,t){let n;return r;function r(o){return ht(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),n=!0,r):Ot(o)?Kt(e,r,n?"linePrefix":"lineSuffix")(o):t(o)}}const WV={name:"definition",tokenize:KV},qV={partial:!0,tokenize:GV};function KV(e,t,n){const r=this;let o;return i;function i(y){return e.enter("definition"),a(y)}function a(y){return jP.call(r,e,l,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(y)}function l(y){return o=Bl(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),y===58?(e.enter("definitionMarker"),e.consume(y),e.exit("definitionMarker"),d):n(y)}function d(y){return br(y)?Bu(e,f)(y):f(y)}function f(y){return wP(e,p,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(y)}function p(y){return e.attempt(qV,h,h)(y)}function h(y){return Ot(y)?Kt(e,g,"whitespace")(y):g(y)}function g(y){return y===null||ht(y)?(e.exit("definition"),r.parser.defined.push(o),t(y)):n(y)}}function GV(e,t,n){return r;function r(l){return br(l)?Bu(e,o)(l):n(l)}function o(l){return kP(e,i,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(l)}function i(l){return Ot(l)?Kt(e,a,"whitespace")(l):a(l)}function a(l){return l===null||ht(l)?t(l):n(l)}}const YV={name:"hardBreakEscape",tokenize:XV};function XV(e,t,n){return r;function r(i){return e.enter("hardBreakEscape"),e.consume(i),o}function o(i){return ht(i)?(e.exit("hardBreakEscape"),t(i)):n(i)}}const QV={name:"headingAtx",resolve:JV,tokenize:ZV};function JV(e,t){let n=e.length-2,r=3,o,i;return e[r][1].type==="whitespace"&&(r+=2),n-2>r&&e[n][1].type==="whitespace"&&(n-=2),e[n][1].type==="atxHeadingSequence"&&(r===n-1||n-4>r&&e[n-2][1].type==="whitespace")&&(n-=r+1===n?2:4),n>r&&(o={type:"atxHeadingText",start:e[r][1].start,end:e[n][1].end},i={type:"chunkText",start:e[r][1].start,end:e[n][1].end,contentType:"text"},Js(e,r,n-r+1,[["enter",o,t],["enter",i,t],["exit",i,t],["exit",o,t]])),e}function ZV(e,t,n){let r=0;return o;function o(p){return e.enter("atxHeading"),i(p)}function i(p){return e.enter("atxHeadingSequence"),a(p)}function a(p){return p===35&&r++<6?(e.consume(p),a):p===null||br(p)?(e.exit("atxHeadingSequence"),l(p)):n(p)}function l(p){return p===35?(e.enter("atxHeadingSequence"),d(p)):p===null||ht(p)?(e.exit("atxHeading"),t(p)):Ot(p)?Kt(e,l,"whitespace")(p):(e.enter("atxHeadingText"),f(p))}function d(p){return p===35?(e.consume(p),d):(e.exit("atxHeadingSequence"),l(p))}function f(p){return p===null||p===35||br(p)?(e.exit("atxHeadingText"),l(p)):(e.consume(p),f)}}const eW=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],YS=["pre","script","style","textarea"],tW={concrete:!0,name:"htmlFlow",resolveTo:sW,tokenize:oW},nW={partial:!0,tokenize:aW},rW={partial:!0,tokenize:iW};function sW(e){let t=e.length;for(;t--&&!(e[t][0]==="enter"&&e[t][1].type==="htmlFlow"););return t>1&&e[t-2][1].type==="linePrefix"&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function oW(e,t,n){const r=this;let o,i,a,l,d;return f;function f(H){return p(H)}function p(H){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(H),h}function h(H){return H===33?(e.consume(H),g):H===47?(e.consume(H),i=!0,w):H===63?(e.consume(H),o=3,r.interrupt?t:O):Vs(H)?(e.consume(H),a=String.fromCharCode(H),b):n(H)}function g(H){return H===45?(e.consume(H),o=2,y):H===91?(e.consume(H),o=5,l=0,k):Vs(H)?(e.consume(H),o=4,r.interrupt?t:O):n(H)}function y(H){return H===45?(e.consume(H),r.interrupt?t:O):n(H)}function k(H){const Q="CDATA[";return H===Q.charCodeAt(l++)?(e.consume(H),l===Q.length?r.interrupt?t:F:k):n(H)}function w(H){return Vs(H)?(e.consume(H),a=String.fromCharCode(H),b):n(H)}function b(H){if(H===null||H===47||H===62||br(H)){const Q=H===47,te=a.toLowerCase();return!Q&&!i&&YS.includes(te)?(o=1,r.interrupt?t(H):F(H)):eW.includes(a.toLowerCase())?(o=6,Q?(e.consume(H),j):r.interrupt?t(H):F(H)):(o=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(H):i?N(H):S(H))}return H===45||Or(H)?(e.consume(H),a+=String.fromCharCode(H),b):n(H)}function j(H){return H===62?(e.consume(H),r.interrupt?t:F):n(H)}function N(H){return Ot(H)?(e.consume(H),N):U(H)}function S(H){return H===47?(e.consume(H),U):H===58||H===95||Vs(H)?(e.consume(H),C):Ot(H)?(e.consume(H),S):U(H)}function C(H){return H===45||H===46||H===58||H===95||Or(H)?(e.consume(H),C):D(H)}function D(H){return H===61?(e.consume(H),T):Ot(H)?(e.consume(H),D):S(H)}function T(H){return H===null||H===60||H===61||H===62||H===96?n(H):H===34||H===39?(e.consume(H),d=H,R):Ot(H)?(e.consume(H),T):$(H)}function R(H){return H===d?(e.consume(H),d=null,_):H===null||ht(H)?n(H):(e.consume(H),R)}function $(H){return H===null||H===34||H===39||H===47||H===60||H===61||H===62||H===96||br(H)?D(H):(e.consume(H),$)}function _(H){return H===47||H===62||Ot(H)?S(H):n(H)}function U(H){return H===62?(e.consume(H),I):n(H)}function I(H){return H===null||ht(H)?F(H):Ot(H)?(e.consume(H),I):n(H)}function F(H){return H===45&&o===2?(e.consume(H),z):H===60&&o===1?(e.consume(H),W):H===62&&o===4?(e.consume(H),B):H===63&&o===3?(e.consume(H),O):H===93&&o===5?(e.consume(H),K):ht(H)&&(o===6||o===7)?(e.exit("htmlFlowData"),e.check(nW,G,M)(H)):H===null||ht(H)?(e.exit("htmlFlowData"),M(H)):(e.consume(H),F)}function M(H){return e.check(rW,A,G)(H)}function A(H){return e.enter("lineEnding"),e.consume(H),e.exit("lineEnding"),L}function L(H){return H===null||ht(H)?M(H):(e.enter("htmlFlowData"),F(H))}function z(H){return H===45?(e.consume(H),O):F(H)}function W(H){return H===47?(e.consume(H),a="",V):F(H)}function V(H){if(H===62){const Q=a.toLowerCase();return YS.includes(Q)?(e.consume(H),B):F(H)}return Vs(H)&&a.length<8?(e.consume(H),a+=String.fromCharCode(H),V):F(H)}function K(H){return H===93?(e.consume(H),O):F(H)}function O(H){return H===62?(e.consume(H),B):H===45&&o===2?(e.consume(H),O):F(H)}function B(H){return H===null||ht(H)?(e.exit("htmlFlowData"),G(H)):(e.consume(H),B)}function G(H){return e.exit("htmlFlow"),t(H)}}function iW(e,t,n){const r=this;return o;function o(a){return ht(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),i):n(a)}function i(a){return r.parser.lazy[r.now().line]?n(a):t(a)}}function aW(e,t,n){return r;function r(o){return e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),e.attempt(Dm,t,n)}}const lW={name:"htmlText",tokenize:cW};function cW(e,t,n){const r=this;let o,i,a;return l;function l(O){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(O),d}function d(O){return O===33?(e.consume(O),f):O===47?(e.consume(O),D):O===63?(e.consume(O),S):Vs(O)?(e.consume(O),$):n(O)}function f(O){return O===45?(e.consume(O),p):O===91?(e.consume(O),i=0,k):Vs(O)?(e.consume(O),N):n(O)}function p(O){return O===45?(e.consume(O),y):n(O)}function h(O){return O===null?n(O):O===45?(e.consume(O),g):ht(O)?(a=h,W(O)):(e.consume(O),h)}function g(O){return O===45?(e.consume(O),y):h(O)}function y(O){return O===62?z(O):O===45?g(O):h(O)}function k(O){const B="CDATA[";return O===B.charCodeAt(i++)?(e.consume(O),i===B.length?w:k):n(O)}function w(O){return O===null?n(O):O===93?(e.consume(O),b):ht(O)?(a=w,W(O)):(e.consume(O),w)}function b(O){return O===93?(e.consume(O),j):w(O)}function j(O){return O===62?z(O):O===93?(e.consume(O),j):w(O)}function N(O){return O===null||O===62?z(O):ht(O)?(a=N,W(O)):(e.consume(O),N)}function S(O){return O===null?n(O):O===63?(e.consume(O),C):ht(O)?(a=S,W(O)):(e.consume(O),S)}function C(O){return O===62?z(O):S(O)}function D(O){return Vs(O)?(e.consume(O),T):n(O)}function T(O){return O===45||Or(O)?(e.consume(O),T):R(O)}function R(O){return ht(O)?(a=R,W(O)):Ot(O)?(e.consume(O),R):z(O)}function $(O){return O===45||Or(O)?(e.consume(O),$):O===47||O===62||br(O)?_(O):n(O)}function _(O){return O===47?(e.consume(O),z):O===58||O===95||Vs(O)?(e.consume(O),U):ht(O)?(a=_,W(O)):Ot(O)?(e.consume(O),_):z(O)}function U(O){return O===45||O===46||O===58||O===95||Or(O)?(e.consume(O),U):I(O)}function I(O){return O===61?(e.consume(O),F):ht(O)?(a=I,W(O)):Ot(O)?(e.consume(O),I):_(O)}function F(O){return O===null||O===60||O===61||O===62||O===96?n(O):O===34||O===39?(e.consume(O),o=O,M):ht(O)?(a=F,W(O)):Ot(O)?(e.consume(O),F):(e.consume(O),A)}function M(O){return O===o?(e.consume(O),o=void 0,L):O===null?n(O):ht(O)?(a=M,W(O)):(e.consume(O),M)}function A(O){return O===null||O===34||O===39||O===60||O===61||O===96?n(O):O===47||O===62||br(O)?_(O):(e.consume(O),A)}function L(O){return O===47||O===62||br(O)?_(O):n(O)}function z(O){return O===62?(e.consume(O),e.exit("htmlTextData"),e.exit("htmlText"),t):n(O)}function W(O){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(O),e.exit("lineEnding"),V}function V(O){return Ot(O)?Kt(e,K,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(O):K(O)}function K(O){return e.enter("htmlTextData"),a(O)}}const Kw={name:"labelEnd",resolveAll:pW,resolveTo:hW,tokenize:mW},uW={tokenize:gW},dW={tokenize:xW},fW={tokenize:yW};function pW(e){let t=-1;const n=[];for(;++t<e.length;){const r=e[t][1];if(n.push(e[t]),r.type==="labelImage"||r.type==="labelLink"||r.type==="labelEnd"){const o=r.type==="labelImage"?4:2;r.type="data",t+=o}}return e.length!==n.length&&Js(e,0,e.length,n),e}function hW(e,t){let n=e.length,r=0,o,i,a,l;for(;n--;)if(o=e[n][1],i){if(o.type==="link"||o.type==="labelLink"&&o._inactive)break;e[n][0]==="enter"&&o.type==="labelLink"&&(o._inactive=!0)}else if(a){if(e[n][0]==="enter"&&(o.type==="labelImage"||o.type==="labelLink")&&!o._balanced&&(i=n,o.type!=="labelLink")){r=2;break}}else o.type==="labelEnd"&&(a=n);const d={type:e[i][1].type==="labelLink"?"link":"image",start:{...e[i][1].start},end:{...e[e.length-1][1].end}},f={type:"label",start:{...e[i][1].start},end:{...e[a][1].end}},p={type:"labelText",start:{...e[i+r+2][1].end},end:{...e[a-2][1].start}};return l=[["enter",d,t],["enter",f,t]],l=Jr(l,e.slice(i+1,i+r+3)),l=Jr(l,[["enter",p,t]]),l=Jr(l,qw(t.parser.constructs.insideSpan.null,e.slice(i+r+4,a-3),t)),l=Jr(l,[["exit",p,t],e[a-2],e[a-1],["exit",f,t]]),l=Jr(l,e.slice(a+1)),l=Jr(l,[["exit",d,t]]),Js(e,i,e.length,l),e}function mW(e,t,n){const r=this;let o=r.events.length,i,a;for(;o--;)if((r.events[o][1].type==="labelImage"||r.events[o][1].type==="labelLink")&&!r.events[o][1]._balanced){i=r.events[o][1];break}return l;function l(g){return i?i._inactive?h(g):(a=r.parser.defined.includes(Bl(r.sliceSerialize({start:i.end,end:r.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(g),e.exit("labelMarker"),e.exit("labelEnd"),d):n(g)}function d(g){return g===40?e.attempt(uW,p,a?p:h)(g):g===91?e.attempt(dW,p,a?f:h)(g):a?p(g):h(g)}function f(g){return e.attempt(fW,p,h)(g)}function p(g){return t(g)}function h(g){return i._balanced=!0,n(g)}}function gW(e,t,n){return r;function r(h){return e.enter("resource"),e.enter("resourceMarker"),e.consume(h),e.exit("resourceMarker"),o}function o(h){return br(h)?Bu(e,i)(h):i(h)}function i(h){return h===41?p(h):wP(e,a,l,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(h)}function a(h){return br(h)?Bu(e,d)(h):p(h)}function l(h){return n(h)}function d(h){return h===34||h===39||h===40?kP(e,f,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(h):p(h)}function f(h){return br(h)?Bu(e,p)(h):p(h)}function p(h){return h===41?(e.enter("resourceMarker"),e.consume(h),e.exit("resourceMarker"),e.exit("resource"),t):n(h)}}function xW(e,t,n){const r=this;return o;function o(l){return jP.call(r,e,i,a,"reference","referenceMarker","referenceString")(l)}function i(l){return r.parser.defined.includes(Bl(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(l):n(l)}function a(l){return n(l)}}function yW(e,t,n){return r;function r(i){return e.enter("reference"),e.enter("referenceMarker"),e.consume(i),e.exit("referenceMarker"),o}function o(i){return i===93?(e.enter("referenceMarker"),e.consume(i),e.exit("referenceMarker"),e.exit("reference"),t):n(i)}}const bW={name:"labelStartImage",resolveAll:Kw.resolveAll,tokenize:vW};function vW(e,t,n){const r=this;return o;function o(l){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(l),e.exit("labelImageMarker"),i}function i(l){return l===91?(e.enter("labelMarker"),e.consume(l),e.exit("labelMarker"),e.exit("labelImage"),a):n(l)}function a(l){return l===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(l):t(l)}}const wW={name:"labelStartLink",resolveAll:Kw.resolveAll,tokenize:jW};function jW(e,t,n){const r=this;return o;function o(a){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(a),e.exit("labelMarker"),e.exit("labelLink"),i}function i(a){return a===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(a):t(a)}}const vy={name:"lineEnding",tokenize:kW};function kW(e,t){return n;function n(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),Kt(e,t,"linePrefix")}}const Vp={name:"thematicBreak",tokenize:SW};function SW(e,t,n){let r=0,o;return i;function i(f){return e.enter("thematicBreak"),a(f)}function a(f){return o=f,l(f)}function l(f){return f===o?(e.enter("thematicBreakSequence"),d(f)):r>=3&&(f===null||ht(f))?(e.exit("thematicBreak"),t(f)):n(f)}function d(f){return f===o?(e.consume(f),r++,d):(e.exit("thematicBreakSequence"),Ot(f)?Kt(e,l,"whitespace")(f):l(f))}}const hr={continuation:{tokenize:TW},exit:AW,name:"list",tokenize:EW},NW={partial:!0,tokenize:PW},CW={partial:!0,tokenize:RW};function EW(e,t,n){const r=this,o=r.events[r.events.length-1];let i=o&&o[1].type==="linePrefix"?o[2].sliceSerialize(o[1],!0).length:0,a=0;return l;function l(y){const k=r.containerState.type||(y===42||y===43||y===45?"listUnordered":"listOrdered");if(k==="listUnordered"?!r.containerState.marker||y===r.containerState.marker:Gb(y)){if(r.containerState.type||(r.containerState.type=k,e.enter(k,{_container:!0})),k==="listUnordered")return e.enter("listItemPrefix"),y===42||y===45?e.check(Vp,n,f)(y):f(y);if(!r.interrupt||y===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),d(y)}return n(y)}function d(y){return Gb(y)&&++a<10?(e.consume(y),d):(!r.interrupt||a<2)&&(r.containerState.marker?y===r.containerState.marker:y===41||y===46)?(e.exit("listItemValue"),f(y)):n(y)}function f(y){return e.enter("listItemMarker"),e.consume(y),e.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||y,e.check(Dm,r.interrupt?n:p,e.attempt(NW,g,h))}function p(y){return r.containerState.initialBlankLine=!0,i++,g(y)}function h(y){return Ot(y)?(e.enter("listItemPrefixWhitespace"),e.consume(y),e.exit("listItemPrefixWhitespace"),g):n(y)}function g(y){return r.containerState.size=i+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(y)}}function TW(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(Dm,o,i);function o(l){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,Kt(e,t,"listItemIndent",r.containerState.size+1)(l)}function i(l){return r.containerState.furtherBlankLines||!Ot(l)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,a(l)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(CW,t,a)(l))}function a(l){return r.containerState._closeFlow=!0,r.interrupt=void 0,Kt(e,e.attempt(hr,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(l)}}function RW(e,t,n){const r=this;return Kt(e,o,"listItemIndent",r.containerState.size+1);function o(i){const a=r.events[r.events.length-1];return a&&a[1].type==="listItemIndent"&&a[2].sliceSerialize(a[1],!0).length===r.containerState.size?t(i):n(i)}}function AW(e){e.exit(this.containerState.type)}function PW(e,t,n){const r=this;return Kt(e,o,"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function o(i){const a=r.events[r.events.length-1];return!Ot(i)&&a&&a[1].type==="listItemPrefixWhitespace"?t(i):n(i)}}const XS={name:"setextUnderline",resolveTo:_W,tokenize:DW};function _W(e,t){let n=e.length,r,o,i;for(;n--;)if(e[n][0]==="enter"){if(e[n][1].type==="content"){r=n;break}e[n][1].type==="paragraph"&&(o=n)}else e[n][1].type==="content"&&e.splice(n,1),!i&&e[n][1].type==="definition"&&(i=n);const a={type:"setextHeading",start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[o][1].type="setextHeadingText",i?(e.splice(o,0,["enter",a,t]),e.splice(i+1,0,["exit",e[r][1],t]),e[r][1].end={...e[i][1].end}):e[r][1]=a,e.push(["exit",a,t]),e}function DW(e,t,n){const r=this;let o;return i;function i(f){let p=r.events.length,h;for(;p--;)if(r.events[p][1].type!=="lineEnding"&&r.events[p][1].type!=="linePrefix"&&r.events[p][1].type!=="content"){h=r.events[p][1].type==="paragraph";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||h)?(e.enter("setextHeadingLine"),o=f,a(f)):n(f)}function a(f){return e.enter("setextHeadingLineSequence"),l(f)}function l(f){return f===o?(e.consume(f),l):(e.exit("setextHeadingLineSequence"),Ot(f)?Kt(e,d,"lineSuffix")(f):d(f))}function d(f){return f===null||ht(f)?(e.exit("setextHeadingLine"),t(f)):n(f)}}const $W={tokenize:IW};function IW(e){const t=this,n=e.attempt(Dm,r,e.attempt(this.parser.constructs.flowInitial,o,Kt(e,e.attempt(this.parser.constructs.flow,o,e.attempt(zV,o)),"linePrefix")));return n;function r(i){if(i===null){e.consume(i);return}return e.enter("lineEndingBlank"),e.consume(i),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n}function o(i){if(i===null){e.consume(i);return}return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),t.currentConstruct=void 0,n}}const MW={resolveAll:NP()},LW=SP("string"),OW=SP("text");function SP(e){return{resolveAll:NP(e==="text"?FW:void 0),tokenize:t};function t(n){const r=this,o=this.parser.constructs[e],i=n.attempt(o,a,l);return a;function a(p){return f(p)?i(p):l(p)}function l(p){if(p===null){n.consume(p);return}return n.enter("data"),n.consume(p),d}function d(p){return f(p)?(n.exit("data"),i(p)):(n.consume(p),d)}function f(p){if(p===null)return!0;const h=o[p];let g=-1;if(h)for(;++g<h.length;){const y=h[g];if(!y.previous||y.previous.call(r,r.previous))return!0}return!1}}}function NP(e){return t;function t(n,r){let o=-1,i;for(;++o<=n.length;)i===void 0?n[o]&&n[o][1].type==="data"&&(i=o,o++):(!n[o]||n[o][1].type!=="data")&&(o!==i+2&&(n[i][1].end=n[o-1][1].end,n.splice(i+2,o-i-2),o=i+2),i=void 0);return e?e(n,r):n}}function FW(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type==="lineEnding")&&e[n-1][1].type==="data"){const r=e[n-1][1],o=t.sliceStream(r);let i=o.length,a=-1,l=0,d;for(;i--;){const f=o[i];if(typeof f=="string"){for(a=f.length;f.charCodeAt(a-1)===32;)l++,a--;if(a)break;a=-1}else if(f===-2)d=!0,l++;else if(f!==-1){i++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(l=0),l){const f={type:n===e.length||d||l<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:i?a:r.start._bufferIndex+a,_index:r.start._index+i,line:r.end.line,column:r.end.column-l,offset:r.end.offset-l},end:{...r.end}};r.end={...f.start},r.start.offset===r.end.offset?Object.assign(r,f):(e.splice(n,0,["enter",f,t],["exit",f,t]),n+=2)}n++}return e}const zW={42:hr,43:hr,45:hr,48:hr,49:hr,50:hr,51:hr,52:hr,53:hr,54:hr,55:hr,56:hr,57:hr,62:xP},BW={91:WV},UW={[-2]:by,[-1]:by,32:by},HW={35:QV,42:Vp,45:[XS,Vp],60:tW,61:XS,95:Vp,96:GS,126:GS},VW={38:bP,92:yP},WW={[-5]:vy,[-4]:vy,[-3]:vy,33:bW,38:bP,42:Yb,60:[wV,lW],91:wW,92:[YV,yP],93:Kw,95:Yb,96:$V},qW={null:[Yb,MW]},KW={null:[42,95]},GW={null:[]},YW=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:KW,contentInitial:BW,disable:GW,document:zW,flow:HW,flowInitial:UW,insideSpan:qW,string:VW,text:WW},Symbol.toStringTag,{value:"Module"}));function XW(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0};const o={},i=[];let a=[],l=[];const d={attempt:R(D),check:R(T),consume:N,enter:S,exit:C,interrupt:R(T,{interrupt:!0})},f={code:null,containerState:{},defineSkip:w,events:[],now:k,parser:e,previous:null,sliceSerialize:g,sliceStream:y,write:h};let p=t.tokenize.call(f,d);return t.resolveAll&&i.push(t),f;function h(I){return a=Jr(a,I),b(),a[a.length-1]!==null?[]:($(t,0),f.events=qw(i,f.events,f),f.events)}function g(I,F){return JW(y(I),F)}function y(I){return QW(a,I)}function k(){const{_bufferIndex:I,_index:F,line:M,column:A,offset:L}=r;return{_bufferIndex:I,_index:F,line:M,column:A,offset:L}}function w(I){o[I.line]=I.column,U()}function b(){let I;for(;r._index<a.length;){const F=a[r._index];if(typeof F=="string")for(I=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===I&&r._bufferIndex<F.length;)j(F.charCodeAt(r._bufferIndex));else j(F)}}function j(I){p=p(I)}function N(I){ht(I)?(r.line++,r.column=1,r.offset+=I===-3?2:1,U()):I!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===a[r._index].length&&(r._bufferIndex=-1,r._index++)),f.previous=I}function S(I,F){const M=F||{};return M.type=I,M.start=k(),f.events.push(["enter",M,f]),l.push(M),M}function C(I){const F=l.pop();return F.end=k(),f.events.push(["exit",F,f]),F}function D(I,F){$(I,F.from)}function T(I,F){F.restore()}function R(I,F){return M;function M(A,L,z){let W,V,K,O;return Array.isArray(A)?G(A):"tokenize"in A?G([A]):B(A);function B(Z){return ae;function ae(ne){const ue=ne!==null&&Z[ne],ye=ne!==null&&Z.null,Ne=[...Array.isArray(ue)?ue:ue?[ue]:[],...Array.isArray(ye)?ye:ye?[ye]:[]];return G(Ne)(ne)}}function G(Z){return W=Z,V=0,Z.length===0?z:H(Z[V])}function H(Z){return ae;function ae(ne){return O=_(),K=Z,Z.partial||(f.currentConstruct=Z),Z.name&&f.parser.constructs.disable.null.includes(Z.name)?te():Z.tokenize.call(F?Object.assign(Object.create(f),F):f,d,Q,te)(ne)}}function Q(Z){return I(K,O),L}function te(Z){return O.restore(),++V<W.length?H(W[V]):z}}}function $(I,F){I.resolveAll&&!i.includes(I)&&i.push(I),I.resolve&&Js(f.events,F,f.events.length-F,I.resolve(f.events.slice(F),f)),I.resolveTo&&(f.events=I.resolveTo(f.events,f))}function _(){const I=k(),F=f.previous,M=f.currentConstruct,A=f.events.length,L=Array.from(l);return{from:A,restore:z};function z(){r=I,f.previous=F,f.currentConstruct=M,f.events.length=A,l=L,U()}}function U(){r.line in o&&r.column<2&&(r.column=o[r.line],r.offset+=o[r.line]-1)}}function QW(e,t){const n=t.start._index,r=t.start._bufferIndex,o=t.end._index,i=t.end._bufferIndex;let a;if(n===o)a=[e[n].slice(r,i)];else{if(a=e.slice(n,o),r>-1){const l=a[0];typeof l=="string"?a[0]=l.slice(r):a.shift()}i>0&&a.push(e[o].slice(0,i))}return a}function JW(e,t){let n=-1;const r=[];let o;for(;++n<e.length;){const i=e[n];let a;if(typeof i=="string")a=i;else switch(i){case-5:{a="\r";break}case-4:{a=`
592
+ `;break}case-3:{a=`\r
593
+ `;break}case-2:{a=t?" ":" ";break}case-1:{if(!t&&o)continue;a=" ";break}default:a=String.fromCharCode(i)}o=i===-2,r.push(a)}return r.join("")}function ZW(e){const r={constructs:iV([YW,...(e||{}).extensions||[]]),content:o(hV),defined:[],document:o(gV),flow:o($W),lazy:{},string:o(LW),text:o(OW)};return r;function o(i){return a;function a(l){return XW(r,i,l)}}}function eq(e){for(;!vP(e););return e}const QS=/[\0\t\n\r]/g;function tq(){let e=1,t="",n=!0,r;return o;function o(i,a,l){const d=[];let f,p,h,g,y;for(i=t+(typeof i=="string"?i.toString():new TextDecoder(a||void 0).decode(i)),h=0,t="",n&&(i.charCodeAt(0)===65279&&h++,n=void 0);h<i.length;){if(QS.lastIndex=h,f=QS.exec(i),g=f&&f.index!==void 0?f.index:i.length,y=i.charCodeAt(g),!f){t=i.slice(h);break}if(y===10&&h===g&&r)d.push(-3),r=void 0;else switch(r&&(d.push(-5),r=void 0),h<g&&(d.push(i.slice(h,g)),e+=g-h),y){case 0:{d.push(65533),e++;break}case 9:{for(p=Math.ceil(e/4)*4,d.push(-2);e++<p;)d.push(-1);break}case 10:{d.push(-4),e=1;break}default:r=!0,e=1}h=g+1}return l&&(r&&d.push(-5),t&&d.push(t),d.push(null)),d}}const nq=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function rq(e){return e.replace(nq,sq)}function sq(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){const o=n.charCodeAt(1),i=o===120||o===88;return gP(n.slice(i?2:1),i?16:10)}return Ww(n)||e}const CP={}.hasOwnProperty;function oq(e,t,n){return t&&typeof t=="object"&&(n=t,t=void 0),iq(n)(eq(ZW(n).document().write(tq()(e,t,!0))))}function iq(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:i(Ue),autolinkProtocol:_,autolinkEmail:_,atxHeading:i(oe),blockQuote:i(ye),characterEscape:_,characterReference:_,codeFenced:i(Ne),codeFencedFenceInfo:a,codeFencedFenceMeta:a,codeIndented:i(Ne,a),codeText:i(Re,a),codeTextData:_,data:_,codeFlowValue:_,definition:i(Se),definitionDestinationString:a,definitionLabelString:a,definitionTitleString:a,emphasis:i(ze),hardBreakEscape:i(we),hardBreakTrailing:i(we),htmlFlow:i(ke,a),htmlFlowData:_,htmlText:i(ke,a),htmlTextData:_,image:i($e),label:a,link:i(Ue),listItem:i(He),listItemValue:g,listOrdered:i(nt,h),listUnordered:i(nt),paragraph:i(at),reference:H,referenceString:a,resourceDestinationString:a,resourceTitleString:a,setextHeading:i(oe),strong:i(xt),thematicBreak:i(ot)},exit:{atxHeading:d(),atxHeadingSequence:D,autolink:d(),autolinkEmail:ue,autolinkProtocol:ne,blockQuote:d(),characterEscapeValue:U,characterReferenceMarkerHexadecimal:te,characterReferenceMarkerNumeric:te,characterReferenceValue:Z,characterReference:ae,codeFenced:d(b),codeFencedFence:w,codeFencedFenceInfo:y,codeFencedFenceMeta:k,codeFlowValue:U,codeIndented:d(j),codeText:d(L),codeTextData:U,data:U,definition:d(),definitionDestinationString:C,definitionLabelString:N,definitionTitleString:S,emphasis:d(),hardBreakEscape:d(F),hardBreakTrailing:d(F),htmlFlow:d(M),htmlFlowData:U,htmlText:d(A),htmlTextData:U,image:d(W),label:K,labelText:V,lineEnding:I,link:d(z),listItem:d(),listOrdered:d(),listUnordered:d(),paragraph:d(),referenceString:Q,resourceDestinationString:O,resourceTitleString:B,resource:G,setextHeading:d($),setextHeadingLineSequence:R,setextHeadingText:T,strong:d(),thematicBreak:d()}};EP(t,(e||{}).mdastExtensions||[]);const n={};return r;function r(le){let xe={type:"root",children:[]};const Oe={stack:[xe],tokenStack:[],config:t,enter:l,exit:f,buffer:a,resume:p,data:n},We=[];let Ge=-1;for(;++Ge<le.length;)if(le[Ge][1].type==="listOrdered"||le[Ge][1].type==="listUnordered")if(le[Ge][0]==="enter")We.push(Ge);else{const ge=We.pop();Ge=o(le,ge,Ge)}for(Ge=-1;++Ge<le.length;){const ge=t[le[Ge][0]];CP.call(ge,le[Ge][1].type)&&ge[le[Ge][1].type].call(Object.assign({sliceSerialize:le[Ge][2].sliceSerialize},Oe),le[Ge][1])}if(Oe.tokenStack.length>0){const ge=Oe.tokenStack[Oe.tokenStack.length-1];(ge[1]||JS).call(Oe,void 0,ge[0])}for(xe.position={start:ai(le.length>0?le[0][1].start:{line:1,column:1,offset:0}),end:ai(le.length>0?le[le.length-2][1].end:{line:1,column:1,offset:0})},Ge=-1;++Ge<t.transforms.length;)xe=t.transforms[Ge](xe)||xe;return xe}function o(le,xe,Oe){let We=xe-1,Ge=-1,ge=!1,pe,se,je,Ae;for(;++We<=Oe;){const qe=le[We];switch(qe[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{qe[0]==="enter"?Ge++:Ge--,Ae=void 0;break}case"lineEndingBlank":{qe[0]==="enter"&&(pe&&!Ae&&!Ge&&!je&&(je=We),Ae=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:Ae=void 0}if(!Ge&&qe[0]==="enter"&&qe[1].type==="listItemPrefix"||Ge===-1&&qe[0]==="exit"&&(qe[1].type==="listUnordered"||qe[1].type==="listOrdered")){if(pe){let X=We;for(se=void 0;X--;){const ve=le[X];if(ve[1].type==="lineEnding"||ve[1].type==="lineEndingBlank"){if(ve[0]==="exit")continue;se&&(le[se][1].type="lineEndingBlank",ge=!0),ve[1].type="lineEnding",se=X}else if(!(ve[1].type==="linePrefix"||ve[1].type==="blockQuotePrefix"||ve[1].type==="blockQuotePrefixWhitespace"||ve[1].type==="blockQuoteMarker"||ve[1].type==="listItemIndent"))break}je&&(!se||je<se)&&(pe._spread=!0),pe.end=Object.assign({},se?le[se][1].start:qe[1].end),le.splice(se||We,0,["exit",pe,qe[2]]),We++,Oe++}if(qe[1].type==="listItemPrefix"){const X={type:"listItem",_spread:!1,start:Object.assign({},qe[1].start),end:void 0};pe=X,le.splice(We,0,["enter",X,qe[2]]),We++,Oe++,je=void 0,Ae=!0}}}return le[xe][1]._spread=ge,Oe}function i(le,xe){return Oe;function Oe(We){l.call(this,le(We),We),xe&&xe.call(this,We)}}function a(){this.stack.push({type:"fragment",children:[]})}function l(le,xe,Oe){this.stack[this.stack.length-1].children.push(le),this.stack.push(le),this.tokenStack.push([xe,Oe||void 0]),le.position={start:ai(xe.start),end:void 0}}function d(le){return xe;function xe(Oe){le&&le.call(this,Oe),f.call(this,Oe)}}function f(le,xe){const Oe=this.stack.pop(),We=this.tokenStack.pop();if(We)We[0].type!==le.type&&(xe?xe.call(this,le,We[0]):(We[1]||JS).call(this,le,We[0]));else throw new Error("Cannot close `"+le.type+"` ("+zu({start:le.start,end:le.end})+"): it’s not open");Oe.position.end=ai(le.end)}function p(){return sV(this.stack.pop())}function h(){this.data.expectingFirstListItemValue=!0}function g(le){if(this.data.expectingFirstListItemValue){const xe=this.stack[this.stack.length-2];xe.start=Number.parseInt(this.sliceSerialize(le),10),this.data.expectingFirstListItemValue=void 0}}function y(){const le=this.resume(),xe=this.stack[this.stack.length-1];xe.lang=le}function k(){const le=this.resume(),xe=this.stack[this.stack.length-1];xe.meta=le}function w(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function b(){const le=this.resume(),xe=this.stack[this.stack.length-1];xe.value=le.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function j(){const le=this.resume(),xe=this.stack[this.stack.length-1];xe.value=le.replace(/(\r?\n|\r)$/g,"")}function N(le){const xe=this.resume(),Oe=this.stack[this.stack.length-1];Oe.label=xe,Oe.identifier=Bl(this.sliceSerialize(le)).toLowerCase()}function S(){const le=this.resume(),xe=this.stack[this.stack.length-1];xe.title=le}function C(){const le=this.resume(),xe=this.stack[this.stack.length-1];xe.url=le}function D(le){const xe=this.stack[this.stack.length-1];if(!xe.depth){const Oe=this.sliceSerialize(le).length;xe.depth=Oe}}function T(){this.data.setextHeadingSlurpLineEnding=!0}function R(le){const xe=this.stack[this.stack.length-1];xe.depth=this.sliceSerialize(le).codePointAt(0)===61?1:2}function $(){this.data.setextHeadingSlurpLineEnding=void 0}function _(le){const Oe=this.stack[this.stack.length-1].children;let We=Oe[Oe.length-1];(!We||We.type!=="text")&&(We=lt(),We.position={start:ai(le.start),end:void 0},Oe.push(We)),this.stack.push(We)}function U(le){const xe=this.stack.pop();xe.value+=this.sliceSerialize(le),xe.position.end=ai(le.end)}function I(le){const xe=this.stack[this.stack.length-1];if(this.data.atHardBreak){const Oe=xe.children[xe.children.length-1];Oe.position.end=ai(le.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(xe.type)&&(_.call(this,le),U.call(this,le))}function F(){this.data.atHardBreak=!0}function M(){const le=this.resume(),xe=this.stack[this.stack.length-1];xe.value=le}function A(){const le=this.resume(),xe=this.stack[this.stack.length-1];xe.value=le}function L(){const le=this.resume(),xe=this.stack[this.stack.length-1];xe.value=le}function z(){const le=this.stack[this.stack.length-1];if(this.data.inReference){const xe=this.data.referenceType||"shortcut";le.type+="Reference",le.referenceType=xe,delete le.url,delete le.title}else delete le.identifier,delete le.label;this.data.referenceType=void 0}function W(){const le=this.stack[this.stack.length-1];if(this.data.inReference){const xe=this.data.referenceType||"shortcut";le.type+="Reference",le.referenceType=xe,delete le.url,delete le.title}else delete le.identifier,delete le.label;this.data.referenceType=void 0}function V(le){const xe=this.sliceSerialize(le),Oe=this.stack[this.stack.length-2];Oe.label=rq(xe),Oe.identifier=Bl(xe).toLowerCase()}function K(){const le=this.stack[this.stack.length-1],xe=this.resume(),Oe=this.stack[this.stack.length-1];if(this.data.inReference=!0,Oe.type==="link"){const We=le.children;Oe.children=We}else Oe.alt=xe}function O(){const le=this.resume(),xe=this.stack[this.stack.length-1];xe.url=le}function B(){const le=this.resume(),xe=this.stack[this.stack.length-1];xe.title=le}function G(){this.data.inReference=void 0}function H(){this.data.referenceType="collapsed"}function Q(le){const xe=this.resume(),Oe=this.stack[this.stack.length-1];Oe.label=xe,Oe.identifier=Bl(this.sliceSerialize(le)).toLowerCase(),this.data.referenceType="full"}function te(le){this.data.characterReferenceType=le.type}function Z(le){const xe=this.sliceSerialize(le),Oe=this.data.characterReferenceType;let We;Oe?(We=gP(xe,Oe==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):We=Ww(xe);const Ge=this.stack[this.stack.length-1];Ge.value+=We}function ae(le){const xe=this.stack.pop();xe.position.end=ai(le.end)}function ne(le){U.call(this,le);const xe=this.stack[this.stack.length-1];xe.url=this.sliceSerialize(le)}function ue(le){U.call(this,le);const xe=this.stack[this.stack.length-1];xe.url="mailto:"+this.sliceSerialize(le)}function ye(){return{type:"blockquote",children:[]}}function Ne(){return{type:"code",lang:null,meta:null,value:""}}function Re(){return{type:"inlineCode",value:""}}function Se(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function ze(){return{type:"emphasis",children:[]}}function oe(){return{type:"heading",depth:0,children:[]}}function we(){return{type:"break"}}function ke(){return{type:"html",value:""}}function $e(){return{type:"image",title:null,url:"",alt:null}}function Ue(){return{type:"link",title:null,url:"",children:[]}}function nt(le){return{type:"list",ordered:le.type==="listOrdered",start:null,spread:le._spread,children:[]}}function He(le){return{type:"listItem",spread:le._spread,checked:null,children:[]}}function at(){return{type:"paragraph",children:[]}}function xt(){return{type:"strong",children:[]}}function lt(){return{type:"text",value:""}}function ot(){return{type:"thematicBreak"}}}function ai(e){return{line:e.line,column:e.column,offset:e.offset}}function EP(e,t){let n=-1;for(;++n<t.length;){const r=t[n];Array.isArray(r)?EP(e,r):aq(e,r)}}function aq(e,t){let n;for(n in t)if(CP.call(t,n))switch(n){case"canContainEols":{const r=t[n];r&&e[n].push(...r);break}case"transforms":{const r=t[n];r&&e[n].push(...r);break}case"enter":case"exit":{const r=t[n];r&&Object.assign(e[n],r);break}}}function JS(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+zu({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+zu({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+zu({start:t.start,end:t.end})+") is still open")}function lq(e){const t=this;t.parser=n;function n(r){return oq(r,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function cq(e,t){const n={type:"element",tagName:"blockquote",properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)}function uq(e,t){const n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:`
594
+ `}]}function dq(e,t){const n=t.value?t.value+`
595
+ `:"",r={},o=t.lang?t.lang.split(/\s+/):[];o.length>0&&(r.className=["language-"+o[0]]);let i={type:"element",tagName:"code",properties:r,children:[{type:"text",value:n}]};return t.meta&&(i.data={meta:t.meta}),e.patch(t,i),i=e.applyData(t,i),i={type:"element",tagName:"pre",properties:{},children:[i]},e.patch(t,i),i}function fq(e,t){const n={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function pq(e,t){const n={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function hq(e,t){const n=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",r=String(t.identifier).toUpperCase(),o=Sc(r.toLowerCase()),i=e.footnoteOrder.indexOf(r);let a,l=e.footnoteCounts.get(r);l===void 0?(l=0,e.footnoteOrder.push(r),a=e.footnoteOrder.length):a=i+1,l+=1,e.footnoteCounts.set(r,l);const d={type:"element",tagName:"a",properties:{href:"#"+n+"fn-"+o,id:n+"fnref-"+o+(l>1?"-"+l:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(a)}]};e.patch(t,d);const f={type:"element",tagName:"sup",properties:{},children:[d]};return e.patch(t,f),e.applyData(t,f)}function mq(e,t){const n={type:"element",tagName:"h"+t.depth,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function gq(e,t){if(e.options.allowDangerousHtml){const n={type:"raw",value:t.value};return e.patch(t,n),e.applyData(t,n)}}function TP(e,t){const n=t.referenceType;let r="]";if(n==="collapsed"?r+="[]":n==="full"&&(r+="["+(t.label||t.identifier)+"]"),t.type==="imageReference")return[{type:"text",value:"!["+t.alt+r}];const o=e.all(t),i=o[0];i&&i.type==="text"?i.value="["+i.value:o.unshift({type:"text",value:"["});const a=o[o.length-1];return a&&a.type==="text"?a.value+=r:o.push({type:"text",value:r}),o}function xq(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return TP(e,t);const o={src:Sc(r.url||""),alt:t.alt};r.title!==null&&r.title!==void 0&&(o.title=r.title);const i={type:"element",tagName:"img",properties:o,children:[]};return e.patch(t,i),e.applyData(t,i)}function yq(e,t){const n={src:Sc(t.url)};t.alt!==null&&t.alt!==void 0&&(n.alt=t.alt),t.title!==null&&t.title!==void 0&&(n.title=t.title);const r={type:"element",tagName:"img",properties:n,children:[]};return e.patch(t,r),e.applyData(t,r)}function bq(e,t){const n={type:"text",value:t.value.replace(/\r?\n|\r/g," ")};e.patch(t,n);const r={type:"element",tagName:"code",properties:{},children:[n]};return e.patch(t,r),e.applyData(t,r)}function vq(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return TP(e,t);const o={href:Sc(r.url||"")};r.title!==null&&r.title!==void 0&&(o.title=r.title);const i={type:"element",tagName:"a",properties:o,children:e.all(t)};return e.patch(t,i),e.applyData(t,i)}function wq(e,t){const n={href:Sc(t.url)};t.title!==null&&t.title!==void 0&&(n.title=t.title);const r={type:"element",tagName:"a",properties:n,children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function jq(e,t,n){const r=e.all(t),o=n?kq(n):RP(t),i={},a=[];if(typeof t.checked=="boolean"){const p=r[0];let h;p&&p.type==="element"&&p.tagName==="p"?h=p:(h={type:"element",tagName:"p",properties:{},children:[]},r.unshift(h)),h.children.length>0&&h.children.unshift({type:"text",value:" "}),h.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:t.checked,disabled:!0},children:[]}),i.className=["task-list-item"]}let l=-1;for(;++l<r.length;){const p=r[l];(o||l!==0||p.type!=="element"||p.tagName!=="p")&&a.push({type:"text",value:`
596
+ `}),p.type==="element"&&p.tagName==="p"&&!o?a.push(...p.children):a.push(p)}const d=r[r.length-1];d&&(o||d.type!=="element"||d.tagName!=="p")&&a.push({type:"text",value:`
597
+ `});const f={type:"element",tagName:"li",properties:i,children:a};return e.patch(t,f),e.applyData(t,f)}function kq(e){let t=!1;if(e.type==="list"){t=e.spread||!1;const n=e.children;let r=-1;for(;!t&&++r<n.length;)t=RP(n[r])}return t}function RP(e){const t=e.spread;return t??e.children.length>1}function Sq(e,t){const n={},r=e.all(t);let o=-1;for(typeof t.start=="number"&&t.start!==1&&(n.start=t.start);++o<r.length;){const a=r[o];if(a.type==="element"&&a.tagName==="li"&&a.properties&&Array.isArray(a.properties.className)&&a.properties.className.includes("task-list-item")){n.className=["contains-task-list"];break}}const i={type:"element",tagName:t.ordered?"ol":"ul",properties:n,children:e.wrap(r,!0)};return e.patch(t,i),e.applyData(t,i)}function Nq(e,t){const n={type:"element",tagName:"p",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function Cq(e,t){const n={type:"root",children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)}function Eq(e,t){const n={type:"element",tagName:"strong",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function Tq(e,t){const n=e.all(t),r=n.shift(),o=[];if(r){const a={type:"element",tagName:"thead",properties:{},children:e.wrap([r],!0)};e.patch(t.children[0],a),o.push(a)}if(n.length>0){const a={type:"element",tagName:"tbody",properties:{},children:e.wrap(n,!0)},l=Bw(t.children[1]),d=cP(t.children[t.children.length-1]);l&&d&&(a.position={start:l,end:d}),o.push(a)}const i={type:"element",tagName:"table",properties:{},children:e.wrap(o,!0)};return e.patch(t,i),e.applyData(t,i)}function Rq(e,t,n){const r=n?n.children:void 0,i=(r?r.indexOf(t):1)===0?"th":"td",a=n&&n.type==="table"?n.align:void 0,l=a?a.length:t.children.length;let d=-1;const f=[];for(;++d<l;){const h=t.children[d],g={},y=a?a[d]:void 0;y&&(g.align=y);let k={type:"element",tagName:i,properties:g,children:[]};h&&(k.children=e.all(h),e.patch(h,k),k=e.applyData(h,k)),f.push(k)}const p={type:"element",tagName:"tr",properties:{},children:e.wrap(f,!0)};return e.patch(t,p),e.applyData(t,p)}function Aq(e,t){const n={type:"element",tagName:"td",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}const ZS=9,eN=32;function Pq(e){const t=String(e),n=/\r?\n|\r/g;let r=n.exec(t),o=0;const i=[];for(;r;)i.push(tN(t.slice(o,r.index),o>0,!0),r[0]),o=r.index+r[0].length,r=n.exec(t);return i.push(tN(t.slice(o),o>0,!1)),i.join("")}function tN(e,t,n){let r=0,o=e.length;if(t){let i=e.codePointAt(r);for(;i===ZS||i===eN;)r++,i=e.codePointAt(r)}if(n){let i=e.codePointAt(o-1);for(;i===ZS||i===eN;)o--,i=e.codePointAt(o-1)}return o>r?e.slice(r,o):""}function _q(e,t){const n={type:"text",value:Pq(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function Dq(e,t){const n={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}const $q={blockquote:cq,break:uq,code:dq,delete:fq,emphasis:pq,footnoteReference:hq,heading:mq,html:gq,imageReference:xq,image:yq,inlineCode:bq,linkReference:vq,link:wq,listItem:jq,list:Sq,paragraph:Nq,root:Cq,strong:Eq,table:Tq,tableCell:Aq,tableRow:Rq,text:_q,thematicBreak:Dq,toml:up,yaml:up,definition:up,footnoteDefinition:up};function up(){}const AP=-1,$m=0,Uu=1,jh=2,Gw=3,Yw=4,Xw=5,Qw=6,PP=7,_P=8,nN=typeof self=="object"?self:globalThis,Iq=(e,t)=>{const n=(o,i)=>(e.set(i,o),o),r=o=>{if(e.has(o))return e.get(o);const[i,a]=t[o];switch(i){case $m:case AP:return n(a,o);case Uu:{const l=n([],o);for(const d of a)l.push(r(d));return l}case jh:{const l=n({},o);for(const[d,f]of a)l[r(d)]=r(f);return l}case Gw:return n(new Date(a),o);case Yw:{const{source:l,flags:d}=a;return n(new RegExp(l,d),o)}case Xw:{const l=n(new Map,o);for(const[d,f]of a)l.set(r(d),r(f));return l}case Qw:{const l=n(new Set,o);for(const d of a)l.add(r(d));return l}case PP:{const{name:l,message:d}=a;return n(new nN[l](d),o)}case _P:return n(BigInt(a),o);case"BigInt":return n(Object(BigInt(a)),o);case"ArrayBuffer":return n(new Uint8Array(a).buffer,a);case"DataView":{const{buffer:l}=new Uint8Array(a);return n(new DataView(l),a)}}return n(new nN[i](a),o)};return r},rN=e=>Iq(new Map,e)(0),gl="",{toString:Mq}={},{keys:Lq}=Object,gu=e=>{const t=typeof e;if(t!=="object"||!e)return[$m,t];const n=Mq.call(e).slice(8,-1);switch(n){case"Array":return[Uu,gl];case"Object":return[jh,gl];case"Date":return[Gw,gl];case"RegExp":return[Yw,gl];case"Map":return[Xw,gl];case"Set":return[Qw,gl];case"DataView":return[Uu,n]}return n.includes("Array")?[Uu,n]:n.includes("Error")?[PP,n]:[jh,n]},dp=([e,t])=>e===$m&&(t==="function"||t==="symbol"),Oq=(e,t,n,r)=>{const o=(a,l)=>{const d=r.push(a)-1;return n.set(l,d),d},i=a=>{if(n.has(a))return n.get(a);let[l,d]=gu(a);switch(l){case $m:{let p=a;switch(d){case"bigint":l=_P,p=a.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+d);p=null;break;case"undefined":return o([AP],a)}return o([l,p],a)}case Uu:{if(d){let g=a;return d==="DataView"?g=new Uint8Array(a.buffer):d==="ArrayBuffer"&&(g=new Uint8Array(a)),o([d,[...g]],a)}const p=[],h=o([l,p],a);for(const g of a)p.push(i(g));return h}case jh:{if(d)switch(d){case"BigInt":return o([d,a.toString()],a);case"Boolean":case"Number":case"String":return o([d,a.valueOf()],a)}if(t&&"toJSON"in a)return i(a.toJSON());const p=[],h=o([l,p],a);for(const g of Lq(a))(e||!dp(gu(a[g])))&&p.push([i(g),i(a[g])]);return h}case Gw:return o([l,a.toISOString()],a);case Yw:{const{source:p,flags:h}=a;return o([l,{source:p,flags:h}],a)}case Xw:{const p=[],h=o([l,p],a);for(const[g,y]of a)(e||!(dp(gu(g))||dp(gu(y))))&&p.push([i(g),i(y)]);return h}case Qw:{const p=[],h=o([l,p],a);for(const g of a)(e||!dp(gu(g)))&&p.push(i(g));return h}}const{message:f}=a;return o([l,{name:d,message:f}],a)};return i},sN=(e,{json:t,lossy:n}={})=>{const r=[];return Oq(!(t||n),!!t,new Map,r)(e),r},kh=typeof structuredClone=="function"?(e,t)=>t&&("json"in t||"lossy"in t)?rN(sN(e,t)):structuredClone(e):(e,t)=>rN(sN(e,t));function Fq(e,t){const n=[{type:"text",value:"↩"}];return t>1&&n.push({type:"element",tagName:"sup",properties:{},children:[{type:"text",value:String(t)}]}),n}function zq(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}function Bq(e){const t=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",n=e.options.footnoteBackContent||Fq,r=e.options.footnoteBackLabel||zq,o=e.options.footnoteLabel||"Footnotes",i=e.options.footnoteLabelTagName||"h2",a=e.options.footnoteLabelProperties||{className:["sr-only"]},l=[];let d=-1;for(;++d<e.footnoteOrder.length;){const f=e.footnoteById.get(e.footnoteOrder[d]);if(!f)continue;const p=e.all(f),h=String(f.identifier).toUpperCase(),g=Sc(h.toLowerCase());let y=0;const k=[],w=e.footnoteCounts.get(h);for(;w!==void 0&&++y<=w;){k.length>0&&k.push({type:"text",value:" "});let N=typeof n=="string"?n:n(d,y);typeof N=="string"&&(N={type:"text",value:N}),k.push({type:"element",tagName:"a",properties:{href:"#"+t+"fnref-"+g+(y>1?"-"+y:""),dataFootnoteBackref:"",ariaLabel:typeof r=="string"?r:r(d,y),className:["data-footnote-backref"]},children:Array.isArray(N)?N:[N]})}const b=p[p.length-1];if(b&&b.type==="element"&&b.tagName==="p"){const N=b.children[b.children.length-1];N&&N.type==="text"?N.value+=" ":b.children.push({type:"text",value:" "}),b.children.push(...k)}else p.push(...k);const j={type:"element",tagName:"li",properties:{id:t+"fn-"+g},children:e.wrap(p,!0)};e.patch(f,j),l.push(j)}if(l.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:i,properties:{...kh(a),id:"footnote-label"},children:[{type:"text",value:o}]},{type:"text",value:`
598
+ `},{type:"element",tagName:"ol",properties:{},children:e.wrap(l,!0)},{type:"text",value:`
599
+ `}]}}const DP=(function(e){if(e==null)return Wq;if(typeof e=="function")return Im(e);if(typeof e=="object")return Array.isArray(e)?Uq(e):Hq(e);if(typeof e=="string")return Vq(e);throw new Error("Expected function, string, or object as test")});function Uq(e){const t=[];let n=-1;for(;++n<e.length;)t[n]=DP(e[n]);return Im(r);function r(...o){let i=-1;for(;++i<t.length;)if(t[i].apply(this,o))return!0;return!1}}function Hq(e){const t=e;return Im(n);function n(r){const o=r;let i;for(i in e)if(o[i]!==t[i])return!1;return!0}}function Vq(e){return Im(t);function t(n){return n&&n.type===e}}function Im(e){return t;function t(n,r,o){return!!(qq(n)&&e.call(this,n,typeof r=="number"?r:void 0,o||void 0))}}function Wq(){return!0}function qq(e){return e!==null&&typeof e=="object"&&"type"in e}const $P=[],Kq=!0,oN=!1,Gq="skip";function Yq(e,t,n,r){let o;typeof t=="function"&&typeof n!="function"?(r=n,n=t):o=t;const i=DP(o),a=r?-1:1;l(e,void 0,[])();function l(d,f,p){const h=d&&typeof d=="object"?d:{};if(typeof h.type=="string"){const y=typeof h.tagName=="string"?h.tagName:typeof h.name=="string"?h.name:void 0;Object.defineProperty(g,"name",{value:"node ("+(d.type+(y?"<"+y+">":""))+")"})}return g;function g(){let y=$P,k,w,b;if((!t||i(d,f,p[p.length-1]||void 0))&&(y=Xq(n(d,p)),y[0]===oN))return y;if("children"in d&&d.children){const j=d;if(j.children&&y[0]!==Gq)for(w=(r?j.children.length:-1)+a,b=p.concat(j);w>-1&&w<j.children.length;){const N=j.children[w];if(k=l(N,w,b)(),k[0]===oN)return k;w=typeof k[1]=="number"?k[1]:w+a}}return y}}}function Xq(e){return Array.isArray(e)?e:typeof e=="number"?[Kq,e]:e==null?$P:[e]}function IP(e,t,n,r){let o,i,a;typeof t=="function"&&typeof n!="function"?(i=void 0,a=t,o=n):(i=t,a=n,o=r),Yq(e,i,l,o);function l(d,f){const p=f[f.length-1],h=p?p.children.indexOf(d):void 0;return a(d,h,p)}}const Xb={}.hasOwnProperty,Qq={};function Jq(e,t){const n=t||Qq,r=new Map,o=new Map,i=new Map,a={...$q,...n.handlers},l={all:f,applyData:eK,definitionById:r,footnoteById:o,footnoteCounts:i,footnoteOrder:[],handlers:a,one:d,options:n,patch:Zq,wrap:nK};return IP(e,function(p){if(p.type==="definition"||p.type==="footnoteDefinition"){const h=p.type==="definition"?r:o,g=String(p.identifier).toUpperCase();h.has(g)||h.set(g,p)}}),l;function d(p,h){const g=p.type,y=l.handlers[g];if(Xb.call(l.handlers,g)&&y)return y(l,p,h);if(l.options.passThrough&&l.options.passThrough.includes(g)){if("children"in p){const{children:w,...b}=p,j=kh(b);return j.children=l.all(p),j}return kh(p)}return(l.options.unknownHandler||tK)(l,p,h)}function f(p){const h=[];if("children"in p){const g=p.children;let y=-1;for(;++y<g.length;){const k=l.one(g[y],p);if(k){if(y&&g[y-1].type==="break"&&(!Array.isArray(k)&&k.type==="text"&&(k.value=iN(k.value)),!Array.isArray(k)&&k.type==="element")){const w=k.children[0];w&&w.type==="text"&&(w.value=iN(w.value))}Array.isArray(k)?h.push(...k):h.push(k)}}}return h}}function Zq(e,t){e.position&&(t.position=M9(e))}function eK(e,t){let n=t;if(e&&e.data){const r=e.data.hName,o=e.data.hChildren,i=e.data.hProperties;if(typeof r=="string")if(n.type==="element")n.tagName=r;else{const a="children"in n?n.children:[n];n={type:"element",tagName:r,properties:{},children:a}}n.type==="element"&&i&&Object.assign(n.properties,kh(i)),"children"in n&&n.children&&o!==null&&o!==void 0&&(n.children=o)}return n}function tK(e,t){const n=t.data||{},r="value"in t&&!(Xb.call(n,"hProperties")||Xb.call(n,"hChildren"))?{type:"text",value:t.value}:{type:"element",tagName:"div",properties:{},children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function nK(e,t){const n=[];let r=-1;for(t&&n.push({type:"text",value:`
600
+ `});++r<e.length;)r&&n.push({type:"text",value:`
601
+ `}),n.push(e[r]);return t&&e.length>0&&n.push({type:"text",value:`
602
+ `}),n}function iN(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function aN(e,t){const n=Jq(e,t),r=n.one(e,void 0),o=Bq(n),i=Array.isArray(r)?{type:"root",children:r}:r||{type:"root",children:[]};return o&&i.children.push({type:"text",value:`
603
+ `},o),i}function rK(e,t){return e&&"run"in e?async function(n,r){const o=aN(n,{file:r,...t});await e.run(o,r)}:function(n,r){return aN(n,{file:r,...e||t})}}function lN(e){if(e)throw e}var wy,cN;function sK(){if(cN)return wy;cN=1;var e=Object.prototype.hasOwnProperty,t=Object.prototype.toString,n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,o=function(f){return typeof Array.isArray=="function"?Array.isArray(f):t.call(f)==="[object Array]"},i=function(f){if(!f||t.call(f)!=="[object Object]")return!1;var p=e.call(f,"constructor"),h=f.constructor&&f.constructor.prototype&&e.call(f.constructor.prototype,"isPrototypeOf");if(f.constructor&&!p&&!h)return!1;var g;for(g in f);return typeof g>"u"||e.call(f,g)},a=function(f,p){n&&p.name==="__proto__"?n(f,p.name,{enumerable:!0,configurable:!0,value:p.newValue,writable:!0}):f[p.name]=p.newValue},l=function(f,p){if(p==="__proto__")if(e.call(f,p)){if(r)return r(f,p).value}else return;return f[p]};return wy=function d(){var f,p,h,g,y,k,w=arguments[0],b=1,j=arguments.length,N=!1;for(typeof w=="boolean"&&(N=w,w=arguments[1]||{},b=2),(w==null||typeof w!="object"&&typeof w!="function")&&(w={});b<j;++b)if(f=arguments[b],f!=null)for(p in f)h=l(w,p),g=l(f,p),w!==g&&(N&&g&&(i(g)||(y=o(g)))?(y?(y=!1,k=h&&o(h)?h:[]):k=h&&i(h)?h:{},a(w,{name:p,newValue:d(N,k,g)})):typeof g<"u"&&a(w,{name:p,newValue:g}));return w},wy}var oK=sK();const jy=wd(oK);function Qb(e){if(typeof e!="object"||e===null)return!1;const t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function iK(){const e=[],t={run:n,use:r};return t;function n(...o){let i=-1;const a=o.pop();if(typeof a!="function")throw new TypeError("Expected function as last argument, not "+a);l(null,...o);function l(d,...f){const p=e[++i];let h=-1;if(d){a(d);return}for(;++h<o.length;)(f[h]===null||f[h]===void 0)&&(f[h]=o[h]);o=f,p?aK(p,l)(...f):a(null,...f)}}function r(o){if(typeof o!="function")throw new TypeError("Expected `middelware` to be a function, not "+o);return e.push(o),t}}function aK(e,t){let n;return r;function r(...a){const l=e.length>a.length;let d;l&&a.push(o);try{d=e.apply(this,a)}catch(f){const p=f;if(l&&n)throw p;return o(p)}l||(d&&d.then&&typeof d.then=="function"?d.then(i,o):d instanceof Error?o(d):i(d))}function o(a,...l){n||(n=!0,t(a,...l))}function i(a){o(null,a)}}const Bs={basename:lK,dirname:cK,extname:uK,join:dK,sep:"/"};function lK(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');Hd(e);let n=0,r=-1,o=e.length,i;if(t===void 0||t.length===0||t.length>e.length){for(;o--;)if(e.codePointAt(o)===47){if(i){n=o+1;break}}else r<0&&(i=!0,r=o+1);return r<0?"":e.slice(n,r)}if(t===e)return"";let a=-1,l=t.length-1;for(;o--;)if(e.codePointAt(o)===47){if(i){n=o+1;break}}else a<0&&(i=!0,a=o+1),l>-1&&(e.codePointAt(o)===t.codePointAt(l--)?l<0&&(r=o):(l=-1,r=a));return n===r?r=a:r<0&&(r=e.length),e.slice(n,r)}function cK(e){if(Hd(e),e.length===0)return".";let t=-1,n=e.length,r;for(;--n;)if(e.codePointAt(n)===47){if(r){t=n;break}}else r||(r=!0);return t<0?e.codePointAt(0)===47?"/":".":t===1&&e.codePointAt(0)===47?"//":e.slice(0,t)}function uK(e){Hd(e);let t=e.length,n=-1,r=0,o=-1,i=0,a;for(;t--;){const l=e.codePointAt(t);if(l===47){if(a){r=t+1;break}continue}n<0&&(a=!0,n=t+1),l===46?o<0?o=t:i!==1&&(i=1):o>-1&&(i=-1)}return o<0||n<0||i===0||i===1&&o===n-1&&o===r+1?"":e.slice(o,n)}function dK(...e){let t=-1,n;for(;++t<e.length;)Hd(e[t]),e[t]&&(n=n===void 0?e[t]:n+"/"+e[t]);return n===void 0?".":fK(n)}function fK(e){Hd(e);const t=e.codePointAt(0)===47;let n=pK(e,!t);return n.length===0&&!t&&(n="."),n.length>0&&e.codePointAt(e.length-1)===47&&(n+="/"),t?"/"+n:n}function pK(e,t){let n="",r=0,o=-1,i=0,a=-1,l,d;for(;++a<=e.length;){if(a<e.length)l=e.codePointAt(a);else{if(l===47)break;l=47}if(l===47){if(!(o===a-1||i===1))if(o!==a-1&&i===2){if(n.length<2||r!==2||n.codePointAt(n.length-1)!==46||n.codePointAt(n.length-2)!==46){if(n.length>2){if(d=n.lastIndexOf("/"),d!==n.length-1){d<0?(n="",r=0):(n=n.slice(0,d),r=n.length-1-n.lastIndexOf("/")),o=a,i=0;continue}}else if(n.length>0){n="",r=0,o=a,i=0;continue}}t&&(n=n.length>0?n+"/..":"..",r=2)}else n.length>0?n+="/"+e.slice(o+1,a):n=e.slice(o+1,a),r=a-o-1;o=a,i=0}else l===46&&i>-1?i++:i=-1}return n}function Hd(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const hK={cwd:mK};function mK(){return"/"}function Jb(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function gK(e){if(typeof e=="string")e=new URL(e);else if(!Jb(e)){const t=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code="ERR_INVALID_ARG_TYPE",t}if(e.protocol!=="file:"){const t=new TypeError("The URL must be of scheme file");throw t.code="ERR_INVALID_URL_SCHEME",t}return xK(e)}function xK(e){if(e.hostname!==""){const r=new TypeError('File URL host must be "localhost" or empty on darwin');throw r.code="ERR_INVALID_FILE_URL_HOST",r}const t=e.pathname;let n=-1;for(;++n<t.length;)if(t.codePointAt(n)===37&&t.codePointAt(n+1)===50){const r=t.codePointAt(n+2);if(r===70||r===102){const o=new TypeError("File URL path must not include encoded / characters");throw o.code="ERR_INVALID_FILE_URL_PATH",o}}return decodeURIComponent(t)}const ky=["history","path","basename","stem","extname","dirname"];class MP{constructor(t){let n;t?Jb(t)?n={path:t}:typeof t=="string"||yK(t)?n={value:t}:n=t:n={},this.cwd="cwd"in n?"":hK.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let r=-1;for(;++r<ky.length;){const i=ky[r];i in n&&n[i]!==void 0&&n[i]!==null&&(this[i]=i==="history"?[...n[i]]:n[i])}let o;for(o in n)ky.includes(o)||(this[o]=n[o])}get basename(){return typeof this.path=="string"?Bs.basename(this.path):void 0}set basename(t){Ny(t,"basename"),Sy(t,"basename"),this.path=Bs.join(this.dirname||"",t)}get dirname(){return typeof this.path=="string"?Bs.dirname(this.path):void 0}set dirname(t){uN(this.basename,"dirname"),this.path=Bs.join(t||"",this.basename)}get extname(){return typeof this.path=="string"?Bs.extname(this.path):void 0}set extname(t){if(Sy(t,"extname"),uN(this.dirname,"extname"),t){if(t.codePointAt(0)!==46)throw new Error("`extname` must start with `.`");if(t.includes(".",1))throw new Error("`extname` cannot contain multiple dots")}this.path=Bs.join(this.dirname,this.stem+(t||""))}get path(){return this.history[this.history.length-1]}set path(t){Jb(t)&&(t=gK(t)),Ny(t,"path"),this.path!==t&&this.history.push(t)}get stem(){return typeof this.path=="string"?Bs.basename(this.path,this.extname):void 0}set stem(t){Ny(t,"stem"),Sy(t,"stem"),this.path=Bs.join(this.dirname||"",t+(this.extname||""))}fail(t,n,r){const o=this.message(t,n,r);throw o.fatal=!0,o}info(t,n,r){const o=this.message(t,n,r);return o.fatal=void 0,o}message(t,n,r){const o=new tr(t,n,r);return this.path&&(o.name=this.path+":"+o.name,o.file=this.path),o.fatal=!1,this.messages.push(o),o}toString(t){return this.value===void 0?"":typeof this.value=="string"?this.value:new TextDecoder(t||void 0).decode(this.value)}}function Sy(e,t){if(e&&e.includes(Bs.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+Bs.sep+"`")}function Ny(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function uN(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}function yK(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const bK=(function(e){const r=this.constructor.prototype,o=r[e],i=function(){return o.apply(i,arguments)};return Object.setPrototypeOf(i,r),i}),vK={}.hasOwnProperty;class Jw extends bK{constructor(){super("copy"),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=iK()}copy(){const t=new Jw;let n=-1;for(;++n<this.attachers.length;){const r=this.attachers[n];t.use(...r)}return t.data(jy(!0,{},this.namespace)),t}data(t,n){return typeof t=="string"?arguments.length===2?(Ty("data",this.frozen),this.namespace[t]=n,this):vK.call(this.namespace,t)&&this.namespace[t]||void 0:t?(Ty("data",this.frozen),this.namespace=t,this):this.namespace}freeze(){if(this.frozen)return this;const t=this;for(;++this.freezeIndex<this.attachers.length;){const[n,...r]=this.attachers[this.freezeIndex];if(r[0]===!1)continue;r[0]===!0&&(r[0]=void 0);const o=n.call(t,...r);typeof o=="function"&&this.transformers.use(o)}return this.frozen=!0,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(t){this.freeze();const n=fp(t),r=this.parser||this.Parser;return Cy("parse",r),r(String(n),n)}process(t,n){const r=this;return this.freeze(),Cy("process",this.parser||this.Parser),Ey("process",this.compiler||this.Compiler),n?o(void 0,n):new Promise(o);function o(i,a){const l=fp(t),d=r.parse(l);r.run(d,l,function(p,h,g){if(p||!h||!g)return f(p);const y=h,k=r.stringify(y,g);kK(k)?g.value=k:g.result=k,f(p,g)});function f(p,h){p||!h?a(p):i?i(h):n(void 0,h)}}}processSync(t){let n=!1,r;return this.freeze(),Cy("processSync",this.parser||this.Parser),Ey("processSync",this.compiler||this.Compiler),this.process(t,o),fN("processSync","process",n),r;function o(i,a){n=!0,lN(i),r=a}}run(t,n,r){dN(t),this.freeze();const o=this.transformers;return!r&&typeof n=="function"&&(r=n,n=void 0),r?i(void 0,r):new Promise(i);function i(a,l){const d=fp(n);o.run(t,d,f);function f(p,h,g){const y=h||t;p?l(p):a?a(y):r(void 0,y,g)}}}runSync(t,n){let r=!1,o;return this.run(t,n,i),fN("runSync","run",r),o;function i(a,l){lN(a),o=l,r=!0}}stringify(t,n){this.freeze();const r=fp(n),o=this.compiler||this.Compiler;return Ey("stringify",o),dN(t),o(t,r)}use(t,...n){const r=this.attachers,o=this.namespace;if(Ty("use",this.frozen),t!=null)if(typeof t=="function")d(t,n);else if(typeof t=="object")Array.isArray(t)?l(t):a(t);else throw new TypeError("Expected usable value, not `"+t+"`");return this;function i(f){if(typeof f=="function")d(f,[]);else if(typeof f=="object")if(Array.isArray(f)){const[p,...h]=f;d(p,h)}else a(f);else throw new TypeError("Expected usable value, not `"+f+"`")}function a(f){if(!("plugins"in f)&&!("settings"in f))throw new Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");l(f.plugins),f.settings&&(o.settings=jy(!0,o.settings,f.settings))}function l(f){let p=-1;if(f!=null)if(Array.isArray(f))for(;++p<f.length;){const h=f[p];i(h)}else throw new TypeError("Expected a list of plugins, not `"+f+"`")}function d(f,p){let h=-1,g=-1;for(;++h<r.length;)if(r[h][0]===f){g=h;break}if(g===-1)r.push([f,...p]);else if(p.length>0){let[y,...k]=p;const w=r[g][1];Qb(w)&&Qb(y)&&(y=jy(!0,w,y)),r[g]=[f,y,...k]}}}}const wK=new Jw().freeze();function Cy(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function Ey(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function Ty(e,t){if(t)throw new Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function dN(e){if(!Qb(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function fN(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function fp(e){return jK(e)?e:new MP(e)}function jK(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function kK(e){return typeof e=="string"||SK(e)}function SK(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const NK="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",pN=[],hN={allowDangerousHtml:!0},CK=/^(https?|ircs?|mailto|xmpp)$/i,EK=[{from:"astPlugins",id:"remove-buggy-html-in-markdown-parser"},{from:"allowDangerousHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"allowNode",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowElement"},{from:"allowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowedElements"},{from:"disallowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"disallowedElements"},{from:"escapeHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"includeElementIndex",id:"#remove-includeelementindex"},{from:"includeNodeIndex",id:"change-includenodeindex-to-includeelementindex"},{from:"linkTarget",id:"remove-linktarget"},{from:"plugins",id:"change-plugins-to-remarkplugins",to:"remarkPlugins"},{from:"rawSourcePos",id:"#remove-rawsourcepos"},{from:"renderers",id:"change-renderers-to-components",to:"components"},{from:"source",id:"change-source-to-children",to:"children"},{from:"sourcePos",id:"#remove-sourcepos"},{from:"transformImageUri",id:"#add-urltransform",to:"urlTransform"},{from:"transformLinkUri",id:"#add-urltransform",to:"urlTransform"}];function TK(e){const t=RK(e),n=AK(e);return PK(t.runSync(t.parse(n),n),e)}function RK(e){const t=e.rehypePlugins||pN,n=e.remarkPlugins||pN,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...hN}:hN;return wK().use(lq).use(n).use(rK,r).use(t)}function AK(e){const t=e.children||"",n=new MP;return typeof t=="string"&&(n.value=t),n}function PK(e,t){const n=t.allowedElements,r=t.allowElement,o=t.components,i=t.disallowedElements,a=t.skipHtml,l=t.unwrapDisallowed,d=t.urlTransform||_K;for(const p of EK)Object.hasOwn(t,p.from)&&(""+p.from+(p.to?"use `"+p.to+"` instead":"remove it")+NK+p.id,void 0);return t.className&&(e={type:"element",tagName:"div",properties:{className:t.className},children:e.type==="root"?e.children:[e]}),IP(e,f),B9(e,{Fragment:s.Fragment,components:o,ignoreInvalidStyle:!0,jsx:s.jsx,jsxs:s.jsxs,passKeys:!0,passNode:!0});function f(p,h,g){if(p.type==="raw"&&g&&typeof h=="number")return a?g.children.splice(h,1):g.children[h]={type:"text",value:p.value},h;if(p.type==="element"){let y;for(y in yy)if(Object.hasOwn(yy,y)&&Object.hasOwn(p.properties,y)){const k=p.properties[y],w=yy[y];(w===null||w.includes(p.tagName))&&(p.properties[y]=d(String(k||""),y,p))}}if(p.type==="element"){let y=n?!n.includes(p.tagName):i?i.includes(p.tagName):!1;if(!y&&r&&typeof h=="number"&&(y=!r(p,h,g)),y&&g&&typeof h=="number")return l&&p.children?g.children.splice(h,1,...p.children):g.children.splice(h,1),h}}}function _K(e){const t=e.indexOf(":"),n=e.indexOf("?"),r=e.indexOf("#"),o=e.indexOf("/");return t===-1||o!==-1&&t>o||n!==-1&&t>n||r!==-1&&t>r||CK.test(e.slice(0,t))?e:""}function xn({content:e,className:t,emptyState:n="No markdown content yet."}){const r=e.replace(/<!--[\s\S]*?-->/g,"");return r.trim()?s.jsx("div",{className:Ce("prose-syntaur max-w-none",t),children:s.jsx(TK,{children:r})}):s.jsx("div",{className:"rounded-md border border-dashed border-border/80 bg-muted/30 px-3 py-4 text-sm text-muted-foreground",children:n})}function rs(e){return`/api/projects/${encodeURIComponent(e)}/todos`}function DK(e){const[t,n]=m.useState(null),[r,o]=m.useState(!0),[i,a]=m.useState(null),l=m.useCallback(async()=>{if(e)try{const d=await fetch(rs(e));if(!d.ok)throw new Error(`HTTP ${d.status}`);n(await d.json()),a(null)}catch(d){a(d instanceof Error?d.message:"Failed to fetch todos")}finally{o(!1)}},[e]);return m.useEffect(()=>{l()},[l]),hc(d=>{d.type==="todos-updated"&&d.projectSlug===e&&l()}),{data:t,loading:r,error:i,refetch:l}}async function $K(e,t,n){await Ra(rs(e),{description:t,tags:n})}async function IK(e,t,n){await Ra(`${rs(e)}/${t}/complete`,{summary:"Completed."})}async function MK(e,t,n){await Ra(`${rs(e)}/${t}/block`,{reason:n})}async function LK(e,t,n){await Ra(`${rs(e)}/${t}/start`,{session:n})}async function OK(e,t){await Ra(`${rs(e)}/${t}/reopen`,{})}async function FK(e,t){await HK(`${rs(e)}/${t}`)}async function zK(e,t,n){const r=await fetch(`${rs(e)}/${t}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({description:n})});if(!r.ok)throw new Error(await r.text().catch(()=>"")||`HTTP ${r.status}`)}function LP(e,t,n){return`${rs(e)}/${t}/attachments/${encodeURIComponent(n)}`}async function BK(e,t,n){for(const r of n){const o=await fetch(`${rs(e)}/${t}/attachments`,{method:"POST",headers:{"Content-Type":"application/octet-stream","x-attachment-filename":encodeURIComponent(r.name||"file"),"x-attachment-mime":r.type||"application/octet-stream"},body:r});if(!o.ok)throw new Error(await o.text().catch(()=>"")||`HTTP ${o.status}`)}}async function UK(e,t,n){const r=await fetch(LP(e,t,n),{method:"DELETE"});if(!r.ok)throw new Error(await r.text().catch(()=>"")||`HTTP ${r.status}`)}async function Ra(e,t){const n=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!n.ok){const r=await n.text().catch(()=>"");let o=null;try{o=r?JSON.parse(r):null}catch{}const i=(o==null?void 0:o.error)||r||`HTTP ${n.status}`,a=new Error(i);throw a.status=n.status,a}return n.json().catch(()=>({}))}async function HK(e){const t=await fetch(e,{method:"DELETE"});if(!t.ok){const n=await t.text().catch(()=>"");let r=null;try{r=n?JSON.parse(n):null}catch{}const o=(r==null?void 0:r.error)||n||`HTTP ${t.status}`,i=new Error(o);throw i.status=t.status,i}}async function VK(e,t){return await Ra(`${rs(e)}/promote`,t)}async function WK(e,t,n){await Ra(`${rs(e)}/${t}/move`,{to:n})}const mN=[{value:"open",icon:"○",label:"Open",color:"text-muted-foreground"},{value:"in_progress",icon:"◉",label:"In Progress",color:"text-status-in-progress-foreground"},{value:"completed",icon:"✓",label:"Completed",color:"text-status-completed-foreground"},{value:"blocked",icon:"✕",label:"Blocked",color:"text-status-blocked-foreground"}];function OP({status:e,onChange:t}){const[n,r]=m.useState(!1),o=m.useRef(null);m.useEffect(()=>{if(!n)return;function a(l){o.current&&!o.current.contains(l.target)&&r(!1)}return document.addEventListener("mousedown",a),()=>document.removeEventListener("mousedown",a)},[n]);const i=mN.find(a=>a.value===e);return s.jsxs("div",{className:"relative",ref:o,onClick:a=>a.stopPropagation(),children:[s.jsx("button",{onClick:()=>r(!n),className:`text-lg leading-none ${i.color} hover:opacity-70 transition`,title:i.label,children:i.icon}),n&&s.jsx("div",{className:"absolute left-0 top-full mt-1 z-20 min-w-[140px] rounded-md border border-border/70 bg-background shadow-lg py-1",children:mN.filter(a=>a.value!==e).map(a=>s.jsxs("button",{onClick:()=>{t(a.value),r(!1)},className:`flex w-full items-center gap-2 px-3 py-1.5 text-sm hover:bg-foreground/5 transition ${a.color}`,children:[s.jsx("span",{className:"text-base leading-none",children:a.icon}),s.jsx("span",{children:a.label})]},a.value))})]})}function FP({item:e,copiedId:t,selected:n,editing:r,onBeginEdit:o,onEndEdit:i,onPatchDescription:a,onAddAttachments:l,onDeleteAttachment:d,attachmentUrl:f,onToggleSelected:p,onMoveOne:h,onStatusChange:g,onCopyId:y,onDelete:k,hotkeyRowProps:w,onDragOrigin:b,onDragStart:j,onDragEnd:N,isDragging:S}){return s.jsxs("div",{draggable:!0,"data-todo-id":e.id,...w??{},onMouseDown:b,onDragStart:C=>j(C,e.id),onDragEnd:N,className:`surface-panel flex items-start gap-3 px-3 py-2 cursor-grab active:cursor-grabbing hover:bg-foreground/[0.03] transition ${S?"opacity-50 shadow-lg":""}`,children:[s.jsx("input",{type:"checkbox","data-no-drag":!0,"aria-label":`Select todo ${e.id}`,title:"Select",checked:n,onChange:C=>p(e.id,C),onClick:C=>C.stopPropagation(),className:"mt-1 h-4 w-4 shrink-0 cursor-pointer accent-foreground"}),s.jsx("span",{className:"mt-0.5 self-stretch w-px bg-border/60","aria-hidden":"true"}),s.jsx("div",{className:"mt-0.5 shrink-0",children:s.jsx(OP,{status:e.status,onChange:C=>g(e.id,C)})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-baseline flex-wrap gap-x-2",children:[s.jsx(zP,{description:e.description,status:e.status,editing:r,onBeginEdit:()=>o(e.id),onEndEdit:i,onSave:C=>a(e.id,C)}),e.tags.length>0&&s.jsx("span",{className:"text-xs text-muted-foreground",children:e.tags.map(C=>`#${C}`).join(" ")}),e.session&&s.jsxs("span",{className:"text-xs text-info-foreground/70 font-mono",children:["session:",e.session.slice(0,8)]}),s.jsx(XK,{item:e})]}),s.jsx(BP,{item:e,attachmentUrl:f,onAdd:C=>l(e.id,C),onDelete:C=>d(e.id,C)})]}),t===e.id?s.jsxs("span",{className:"text-xs text-status-completed-foreground flex items-center gap-1",children:[s.jsx(zr,{className:"h-3 w-3"})," Copied to clipboard"]}):s.jsxs(s.Fragment,{children:[s.jsxs("button",{"data-no-drag":!0,className:"text-xs text-muted-foreground/60 font-mono hover:text-foreground transition",onClick:C=>y(C,e.id),children:["t:",e.id]}),s.jsx("button",{"data-no-drag":!0,className:"text-muted-foreground/40 hover:text-foreground transition",title:"Copy ID",onClick:C=>y(C,e.id),children:s.jsx(th,{className:"h-3 w-3"})}),s.jsx("button",{"data-no-drag":!0,className:"text-muted-foreground/40 hover:text-foreground transition",title:"Move to...",onClick:C=>h(e.id,C),children:s.jsx(Vh,{className:"h-3 w-3"})}),s.jsx("button",{"data-no-drag":!0,className:"text-muted-foreground/40 hover:text-destructive transition",title:"Delete todo",onClick:C=>k(C,e.id,e.description),children:s.jsx(bn,{className:"h-3 w-3"})})]})]})}function zP({description:e,status:t,editing:n,onBeginEdit:r,onEndEdit:o,onSave:i}){return n?s.jsx(qK,{initialValue:e,onSave:i,onExit:o}):s.jsx("button",{type:"button","data-no-drag":!0,onClick:a=>{a.stopPropagation(),r()},title:"Click to edit",className:Ce("text-left text-sm rounded-sm transition hover:text-primary focus:outline-none focus-visible:ring-2 focus-visible:ring-ring/40",t==="completed"?"line-through text-muted-foreground":"text-foreground"),children:e})}function qK({initialValue:e,onSave:t,onExit:n}){const r=m.useRef(e),[o,i]=m.useState(e),[a,l]=m.useState(!1),[d,f]=m.useState(!1),p=m.useRef(null),h=m.useRef(!1);m.useEffect(()=>{const w=p.current;w&&(w.focus(),w.select())},[]);const g=m.useCallback(()=>{var w;f(!0),window.setTimeout(()=>f(!1),260),(w=p.current)==null||w.focus()},[]),y=m.useCallback(async()=>{var b;if(h.current)return;const w=o.trim();if(w.length===0){g();return}if(w===r.current){n();return}h.current=!0,l(!0);try{await t(w),n()}catch{l(!1),h.current=!1,(b=p.current)==null||b.focus()}},[o,n,t,g]);function k(w){w.key==="Enter"?(w.preventDefault(),y()):w.key==="Escape"&&(w.preventDefault(),h.current=!0,n())}return s.jsx("input",{ref:p,type:"text","data-no-drag":!0,disabled:a,value:o,onClick:w=>w.stopPropagation(),onChange:w=>i(w.target.value),onKeyDown:k,onBlur:()=>void y(),className:Ce("w-full rounded-sm border border-border bg-background px-1.5 py-0.5 text-sm text-foreground outline-none transition focus:border-ring focus:ring-1 focus:ring-ring",d&&"syntaur-input-shake",a&&"opacity-70")})}function KK(e){return e.startsWith("image/")&&e!=="image/svg+xml"}function GK(e){const t=e.clipboardData,n=[];if(t.files&&t.files.length&&n.push(...Array.from(t.files)),!n.length&&t.items){for(const r of Array.from(t.items))if(r.kind==="file"){const o=r.getAsFile();o&&n.push(o)}}return n}function BP({item:e,attachmentUrl:t,onAdd:n,onDelete:r}){const o=e.attachments??[],[i,a]=m.useState(!1),[l,d]=m.useState(!1),f=m.useRef(null),p=m.useRef(null);m.useEffect(()=>{var g;i&&((g=p.current)==null||g.focus())},[i]);const h=m.useCallback(async g=>{if(g.length){d(!0);try{await n(g),a(!1)}finally{d(!1)}}},[n]);return s.jsxs("div",{className:"mt-1","data-no-drag":!0,onClick:g=>g.stopPropagation(),children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[o.map(g=>s.jsx(YK,{att:g,url:t(e.id,g.id),onDelete:()=>void r(g.id)},g.id)),s.jsxs("button",{type:"button","data-no-drag":!0,title:"Attach files",onClick:()=>a(g=>!g),className:"inline-flex items-center gap-1 rounded-md border border-border/60 px-1.5 py-0.5 text-xs text-muted-foreground hover:text-foreground hover:border-border transition",children:[s.jsx(JE,{className:"h-3 w-3"}),o.length===0?"Attach":""]})]}),i&&s.jsxs("div",{ref:p,"data-no-drag":!0,tabIndex:0,role:"button","aria-label":"Add attachments: drop, paste, or click",onPaste:g=>{const y=GK(g);y.length&&(g.preventDefault(),h(y))},onDragOver:g=>{Array.from(g.dataTransfer.types).includes("Files")&&g.preventDefault()},onDrop:g=>{const y=Array.from(g.dataTransfer.files);y.length&&(g.preventDefault(),h(y))},onClick:()=>{var g;return(g=f.current)==null?void 0:g.click()},className:"mt-1 cursor-pointer rounded-md border border-dashed border-border/70 px-3 py-2 text-xs text-muted-foreground hover:border-border focus:outline-none focus:ring-2 focus:ring-ring/40",children:[l?"Uploading…":"Drop, paste (⌘V / Ctrl+V), or click to add files",s.jsx("input",{ref:f,type:"file",multiple:!0,className:"hidden",onChange:g=>{const y=Array.from(g.target.files??[]);g.target.value="",h(y)}})]})]})}function YK({att:e,url:t,onDelete:n}){return s.jsxs("span",{className:"inline-flex items-center gap-1 rounded-md border border-border/60 bg-background px-1.5 py-0.5 text-xs",children:[KK(e.mime)?s.jsx("a",{href:t,target:"_blank",rel:"noopener noreferrer",title:e.filename,children:s.jsx("img",{src:t,alt:e.filename,className:"h-6 w-6 rounded object-cover"})}):s.jsxs("a",{href:t,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-foreground hover:text-primary",children:[s.jsx(JE,{className:"h-3 w-3"}),s.jsx("span",{className:"block max-w-[160px] truncate",children:e.filename})]}),s.jsx("button",{type:"button",title:"Remove attachment",onClick:n,className:"text-muted-foreground/60 hover:text-destructive transition",children:s.jsx(Cd,{className:"h-3 w-3"})})]})}function XK({item:e}){return!(e.branch||e.planDir||e.worktreePath||e.createdAt||e.updatedAt)?null:s.jsxs("span",{className:"inline-flex items-center gap-1 align-middle",children:[e.branch?s.jsx(fa,{delayDuration:120,children:s.jsxs(Ir,{children:[s.jsx(Mr,{asChild:!0,children:s.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full border border-info-foreground/30 bg-info/30 px-1.5 py-0.5 text-[10px] font-mono text-info-foreground",children:[s.jsx(Pv,{className:"h-2.5 w-2.5"}),s.jsx("span",{className:"block min-w-0 max-w-[120px] truncate",children:e.branch})]})}),s.jsx(gr,{children:e.branch})]})}):null,e.planDir?s.jsx(fa,{delayDuration:120,children:s.jsxs(Ir,{children:[s.jsx(Mr,{asChild:!0,children:s.jsx("button",{type:"button","data-no-drag":!0,onClick:n=>{n.stopPropagation(),zd(e.planDir)},className:"inline-flex items-center rounded-full border border-status-completed-foreground/40 bg-status-completed/30 p-1 text-status-completed-foreground hover:bg-status-completed/50","aria-label":"Copy plan directory path",children:s.jsx(XE,{className:"h-2.5 w-2.5"})})}),s.jsxs(gr,{children:["Plan: ",e.planDir]})]})}):null,e.worktreePath||e.createdAt||e.updatedAt?s.jsx(fa,{delayDuration:120,children:s.jsxs(Ir,{children:[s.jsx(Mr,{asChild:!0,children:s.jsx("span",{className:"text-[10px] text-muted-foreground/60 cursor-default",children:"·"})}),s.jsx(gr,{children:s.jsxs("div",{className:"space-y-0.5 text-xs font-mono",children:[e.worktreePath?s.jsxs("div",{children:["worktree: ",e.worktreePath]}):null,e.createdAt?s.jsxs("div",{children:["created: ",e.createdAt]}):null,e.updatedAt?s.jsxs("div",{children:["updated: ",e.updatedAt]}):null]})})]})}):null]})}const UP="__one_off__";function Zw({open:e,selectedIds:t,scope:n,onOpenChange:r,onDone:o,defaultProject:i,defaultTitle:a,allowOneOff:l=!0}){const[d,f]=m.useState("new"),[p,h]=m.useState(!1),[g,y]=m.useState(null),[k,w]=m.useState(null),[b,j]=m.useState(null),[N,S]=m.useState(""),[C,D]=m.useState(""),[T,R]=m.useState(""),[$,_]=m.useState(""),[U,I]=m.useState(""),[F,M]=m.useState(""),[A,L]=m.useState(null),[z,W]=m.useState(!1),V=t.length>1;m.useEffect(()=>{if(!e){f("new"),y(null),S(""),D(""),R(""),_(""),I(""),M(""),L(null);return}S(i??""),D(a??"");let Q=!1;return(async()=>{try{const te=await fetch("/api/projects");if(!te.ok)throw new Error(`HTTP ${te.status}`);const Z=await te.json();Q||w(Z.filter(ae=>!ae.archived))}catch(te){Q||j(te instanceof Error?te.message:String(te))}})(),()=>{Q=!0}},[e,i,a]),m.useEffect(()=>{if(!U){L(null);return}let Q=!1;return W(!0),(async()=>{try{const te=await fetch(`/api/projects/${encodeURIComponent(U)}/assignments`);if(!te.ok)throw new Error(`HTTP ${te.status}`);const Z=await te.json();Q||L(Z)}catch{Q||L([])}finally{Q||W(!1)}})(),()=>{Q=!0}},[U]);const K=m.useMemo(()=>k??[],[k]);async function O(Q){if(Q.preventDefault(),!N){y('Pick a target project (or "One-off").');return}if(V&&!C.trim()){y("Title is required when promoting multiple todos.");return}const te=N===UP?{oneOff:!0}:{project:N};if(n.kind==="aggregate"){const ae={groups:n.groups,mode:"new-assignment",target:te,title:C.trim()||void 0,type:T.trim()||void 0,priority:$||void 0};await H(ae);return}const Z={todoIds:t,mode:"new-assignment",target:te,title:C.trim()||void 0,type:T.trim()||void 0,priority:$||void 0};await G(Z)}async function B(Q){if(Q.preventDefault(),n.kind==="aggregate"){y("Existing-assignment mode does not support cross-workspace selections yet.");return}if(!U||!F){y("Pick both project and assignment.");return}const te={todoIds:t,mode:"to-assignment",target:{assignment:`${U}/${F}`}};await G(te)}async function G(Q){h(!0),y(null);try{let te;if(n.kind==="workspace")te=await $O(n.workspace,Q);else if(n.kind==="project")te=await VK(n.projectId,Q);else throw new Error("Aggregate scope requires runBulkMutation.");o(te),r(!1)}catch(te){y(te instanceof Error?te.message:String(te))}finally{h(!1)}}async function H(Q){h(!0),y(null);try{const te=await IO(Q);o(te),r(!1)}catch(te){y(te instanceof Error?te.message:String(te))}finally{h(!1)}}return s.jsx(Ln,{open:e,onOpenChange:Q=>p?void 0:r(Q),children:s.jsxs(jn,{className:"max-w-xl",children:[s.jsxs(er,{children:[s.jsxs(kn,{children:["Promote ",t.length," todo",t.length===1?"":"s"]}),s.jsxs(ns,{children:["Convert the selected todo",t.length===1?"":"s"," to a new or existing assignment. Source todo",t.length===1?"":"s"," will be marked ",s.jsx("strong",{children:"in progress"})," and linked to the new assignment (auto-completed when the assignment closes)."]})]}),s.jsxs(eP,{value:d,onValueChange:Q=>f(Q),children:[s.jsxs(tP,{className:"flex gap-2 rounded-md border border-border/70 bg-card/80 p-1 mb-4",children:[s.jsx(Bb,{value:"new",className:Ce("inline-flex items-center gap-2 rounded-sm px-3 py-1.5 text-sm font-medium text-muted-foreground transition","data-[state=active]:bg-foreground data-[state=active]:text-background"),children:"New assignment"}),s.jsx(Bb,{value:"existing",className:Ce("inline-flex items-center gap-2 rounded-sm px-3 py-1.5 text-sm font-medium text-muted-foreground transition","data-[state=active]:bg-foreground data-[state=active]:text-background"),children:"Existing assignment"})]}),s.jsx(Ub,{value:"new",children:s.jsxs("form",{onSubmit:O,className:"space-y-4",children:[s.jsx(xl,{label:"Target project",children:s.jsx(gN,{value:N,onChange:S,projects:K,error:b,disabled:p,allowOneOff:l})}),s.jsx(xl,{label:V?"Title (required)":"Title (defaults to first todo)",children:s.jsx("input",{type:"text",value:C,onChange:Q=>D(Q.target.value),disabled:p,className:"editor-input bg-background/95 font-sans"})}),s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsx(xl,{label:"Type",children:s.jsx("input",{type:"text",value:T,onChange:Q=>R(Q.target.value),placeholder:"feature",disabled:p,className:"editor-input bg-background/95 font-sans"})}),s.jsx(xl,{label:"Priority",children:s.jsxs("select",{value:$,onChange:Q=>_(Q.target.value),disabled:p,className:"editor-input bg-background/95 font-sans",children:[s.jsx("option",{value:"",children:"—"}),s.jsx("option",{value:"low",children:"low"}),s.jsx("option",{value:"medium",children:"medium"}),s.jsx("option",{value:"high",children:"high"}),s.jsx("option",{value:"critical",children:"critical"})]})})]}),g?s.jsx(xN,{message:g}):null,s.jsx(yN,{onCancel:()=>r(!1),submitting:p,submitLabel:"Promote"})]})}),s.jsx(Ub,{value:"existing",children:s.jsxs("form",{onSubmit:B,className:"space-y-4",children:[s.jsx(xl,{label:"Project",children:s.jsx(gN,{value:U,onChange:Q=>{I(Q),M("")},projects:K,error:b,disabled:p})}),s.jsx(xl,{label:z?"Assignment (loading...)":"Assignment",children:s.jsxs("select",{value:F,onChange:Q=>M(Q.target.value),disabled:p||!U||z,className:"editor-input bg-background/95 font-sans",children:[s.jsx("option",{value:"",children:U?"Select assignment...":"Pick a project first"}),(A??[]).map(Q=>s.jsxs("option",{value:Q.slug,children:[Q.title," (",Q.status,")"]},Q.slug))]})}),g?s.jsx(xN,{message:g}):null,s.jsx(yN,{onCancel:()=>r(!1),submitting:p,submitLabel:"Promote"})]})})]})]})})}function xl({label:e,children:t}){return s.jsxs("label",{className:"block space-y-1.5",children:[s.jsx("span",{className:"block text-xs font-medium uppercase tracking-[0.08em] text-muted-foreground",children:e}),t]})}function gN({value:e,onChange:t,projects:n,error:r,disabled:o,allowOneOff:i}){return r?s.jsxs("div",{className:"text-sm text-destructive",children:["Failed to load projects: ",r]}):s.jsxs("select",{value:e,onChange:a=>t(a.target.value),disabled:o,className:"editor-input bg-background/95 font-sans",children:[s.jsx("option",{value:"",children:"Select project..."}),i?s.jsx("option",{value:UP,children:"One-off (no project)"}):null,n.map(a=>s.jsxs("option",{value:a.slug,children:[a.title," (",a.slug,")"]},a.slug))]})}function xN({message:e}){return s.jsx("div",{className:"rounded-md border border-destructive/50 bg-destructive/10 px-3 py-2 text-sm text-destructive",children:e})}function yN({onCancel:e,submitting:t,submitLabel:n}){return s.jsxs(Ur,{children:[s.jsx("button",{type:"button",onClick:e,disabled:t,className:"shell-action disabled:cursor-not-allowed disabled:opacity-50",children:"Cancel"}),s.jsx("button",{type:"submit",disabled:t,className:"shell-action shell-action--cta disabled:cursor-not-allowed disabled:opacity-50",children:t?"Submitting...":n})]})}function HP({open:e,selectedIds:t,scope:n,onOpenChange:r,onDone:o}){const[i,a]=m.useState("project"),[l,d]=m.useState(""),[f,p]=m.useState(""),[h,g]=m.useState(!1),[y,k]=m.useState(null),[w,b]=m.useState(null),[j,N]=m.useState(null);m.useEffect(()=>{if(!e){a("project"),d(""),p(""),k(null),b(null);return}let R=!1;return(async()=>{try{const $=await fetch("/api/projects");if(!$.ok)throw new Error(`HTTP ${$.status}`);const _=await $.json();R||N(_.filter(U=>!U.archived))}catch($){R||b($ instanceof Error?$.message:String($))}})(),()=>{R=!0}},[e]);const S=m.useMemo(()=>j?n.kind==="project"?j.filter(R=>R.slug!==n.projectId):j:[],[j,n]);function C(){if(i==="global")return{global:!0};if(i==="workspace"){const R=l.trim();return R?{workspace:R}:"Workspace name is required."}return f?{project:f}:"Pick a target project."}async function D(R,$){try{return n.kind==="workspace"?await MO(n.workspace,R,$):await WK(n.projectId,R,$),{ok:!0}}catch(_){return{ok:!1,error:_ instanceof Error?_.message:String(_)}}}async function T(R){R.preventDefault(),b(null);const $=C();if(typeof $=="string"){b($);return}g(!0),k(null);const _=[],U=[];for(const I of t){const F=await D(I,$);F.ok?_.push(I):U.push({id:I,error:F.error})}g(!1),o(),U.length===0?r(!1):k({succeeded:_,failed:U})}return s.jsx(Ln,{open:e,onOpenChange:R=>h?void 0:r(R),children:s.jsx(jn,{className:"max-w-xl",children:s.jsxs("form",{onSubmit:T,className:"space-y-4",children:[s.jsxs(er,{children:[s.jsxs(kn,{children:["Move ",t.length," todo",t.length===1?"":"s"]}),s.jsxs(ns,{children:["Move the selected todo",t.length===1?"":"s"," to a different scope. id, tags, branch, timestamps, and plan dir are preserved."]})]}),s.jsxs("fieldset",{className:"space-y-2",disabled:h,children:[s.jsx("legend",{className:"block text-xs font-medium uppercase tracking-[0.08em] text-muted-foreground mb-1",children:"Target scope"}),s.jsx(Ry,{kind:"project",checked:i==="project",onChange:()=>a("project"),label:"Project"}),s.jsx(Ry,{kind:"workspace",checked:i==="workspace",onChange:()=>a("workspace"),label:"Workspace"}),s.jsx(Ry,{kind:"global",checked:i==="global",onChange:()=>a("global"),label:"Global"})]}),i==="project"?s.jsx(bN,{label:"Target project",children:s.jsxs("select",{value:f,onChange:R=>p(R.target.value),disabled:h,className:"editor-textarea w-full bg-background/95 font-sans",children:[s.jsx("option",{value:"",children:"Select project..."}),S.map(R=>s.jsxs("option",{value:R.slug,children:[R.title," (",R.slug,")"]},R.slug))]})}):null,i==="workspace"?s.jsx(bN,{label:"Target workspace name",children:s.jsx("input",{type:"text",value:l,onChange:R=>d(R.target.value),disabled:h,placeholder:"e.g. syntaur",className:"editor-textarea w-full bg-background/95 font-sans"})}):null,w?s.jsx(QK,{message:w}):null,y?s.jsxs("div",{className:"rounded-md border border-warning-foreground/30 bg-warning px-3 py-2 text-sm text-warning-foreground space-y-1",children:[s.jsxs("div",{className:"font-medium",children:["Moved ",y.succeeded.length," of ",t.length,"; ",y.failed.length," failed."]}),s.jsx("ul",{className:"text-xs space-y-0.5",children:y.failed.map(R=>s.jsxs("li",{children:["[t:",R.id,"] ",R.error]},R.id))})]}):null,s.jsxs(Ur,{children:[s.jsx("button",{type:"button",onClick:()=>r(!1),disabled:h,className:"shell-action disabled:cursor-not-allowed disabled:opacity-50",children:y?"Close":"Cancel"}),y===null?s.jsx("button",{type:"submit",disabled:h,className:"shell-action shell-action--cta disabled:cursor-not-allowed disabled:opacity-50",children:h?"Moving...":"Move"}):null]})]})})})}function bN({label:e,children:t}){return s.jsxs("label",{className:"block space-y-1.5",children:[s.jsx("span",{className:"block text-xs font-medium uppercase tracking-[0.08em] text-muted-foreground",children:e}),t]})}function Ry({kind:e,checked:t,onChange:n,label:r}){return s.jsxs("label",{className:"flex items-center gap-2 text-sm cursor-pointer",children:[s.jsx("input",{type:"radio",name:"move-target-kind",value:e,checked:t,onChange:n}),s.jsx("span",{children:r})]})}function QK({message:e}){return s.jsx("div",{className:"rounded-md border border-destructive/50 bg-destructive/10 px-3 py-2 text-sm text-destructive",children:e})}function e0({label:e,count:t,expanded:n,onToggle:r,isDropTarget:o=!1,onDragOver:i,onDragLeave:a,onDrop:l,children:d}){return s.jsxs("div",{className:Ce("rounded-lg border border-border/60 bg-card/40 transition",o&&"ring-2 ring-ring/30"),onDragOver:i,onDragLeave:a,onDrop:l,children:[s.jsxs("button",{type:"button",onClick:r,"aria-expanded":n,className:"flex w-full items-center gap-2 px-3 py-2.5 text-left",children:[s.jsx(vr,{className:Ce("h-4 w-4 text-muted-foreground transition-transform",!n&&"-rotate-90")}),s.jsx("span",{className:"font-semibold text-foreground",children:e}),s.jsx("span",{className:"rounded-full border border-border/60 px-2 py-0.5 text-xs text-muted-foreground",children:t})]}),n&&s.jsx("div",{className:"space-y-1 px-2 pb-2",children:d})]})}const VP=[{id:"open-blocked",label:"Open / Blocked",statuses:["open","blocked"],dropStatus:"open",defaultCollapsed:!1},{id:"in-progress",label:"In Progress",statuses:["in_progress"],dropStatus:"in_progress",defaultCollapsed:!1},{id:"done",label:"Done",statuses:["completed"],dropStatus:"completed",defaultCollapsed:!0}];function Mm(e){switch(e){case"in_progress":return"in-progress";case"completed":return"done";case"open":case"blocked":default:return"open-blocked"}}function t0(e){const t={"open-blocked":[],"in-progress":[],done:[]};for(const n of e)t[Mm(n.status)].push(n);return VP.map(n=>({config:n,items:t[n.id]}))}const WP="syntaur.todos.sections.collapsed.v1",vN=Object.fromEntries(VP.map(e=>[e.id,e.defaultCollapsed]));function Ay(){if(typeof window>"u"||!window.localStorage)return{};try{const e=window.localStorage.getItem(WP);if(!e)return{};const t=JSON.parse(e);return t&&typeof t=="object"?t:{}}catch{return{}}}function JK(e){if(!(typeof window>"u"||!window.localStorage))try{window.localStorage.setItem(WP,JSON.stringify(e))}catch{}}function n0(e){const[t,n]=m.useState(()=>Ay()[e]??{});m.useEffect(()=>{n(Ay()[e]??{})},[e]);const r=m.useCallback(i=>t[i]??vN[i],[t]),o=m.useCallback(i=>{const a=Ay(),l=a[e]??{},d=l[i]??vN[i],f={...l,[i]:!d};a[e]=f,JK(a),n(f)},[e]);return{isCollapsed:r,toggle:o}}function ZK({projectId:e}){const{data:t,loading:n,error:r,refetch:o}=DK(e),{toast:i,showToast:a,dismissToast:l}=wr(),[d,f]=m.useState(""),[p,h]=m.useState(""),[g,y]=m.useState(""),[k,w]=m.useState(""),[b,j]=m.useState(null),[N,S]=m.useState(null),[C,D]=m.useState(new Set),[T,R]=m.useState(!1),[$,_]=m.useState(!1),[U,I]=m.useState(null),F=m.useRef(null);Ei("list:todos");const M=n0("project:"+e),[A,L]=m.useState(null),[z,W]=m.useState(null),V=m.useRef(null);async function K(ge,pe){ge.stopPropagation(),await zd(pe)&&(j(pe),setTimeout(()=>j(se=>se===pe?null:se),1500))}const O=m.useMemo(()=>{if(!(t!=null&&t.items))return[];const ge=new Set;for(const pe of t.items)for(const se of pe.tags)ge.add(se);return Array.from(ge).sort()},[t]),B=m.useMemo(()=>{if(!(t!=null&&t.items))return[];let ge=t.items;if(d.trim()){const pe=d.toLowerCase();ge=ge.filter(se=>se.description.toLowerCase().includes(pe)||se.tags.some(je=>je.toLowerCase().includes(pe))||se.id.includes(pe))}return p&&(ge=ge.filter(pe=>pe.status===p)),g&&(ge=ge.filter(pe=>pe.tags.includes(g))),ge},[t,d,p,g]);m.useEffect(()=>{D(new Set)},[d,p,g,e]);const G=m.useMemo(()=>B.filter(ge=>C.has(ge.id)).length,[B,C]),H=B.length>0&&G===B.length,Q=G>0&&!H;function te(ge){D(pe=>{const se=new Set(pe);return se.has(ge)?se.delete(ge):se.add(ge),se})}function Z(){D(ge=>{const pe=new Set(ge);if(H)for(const se of B)pe.delete(se.id);else for(const se of B)pe.add(se.id);return pe})}function ae(){D(new Set)}const ne=U?[U]:Array.from(C);function ue(){D(new Set),I(null),o()}function ye(){D(new Set),o()}function Ne(ge){a(ge instanceof Error?ge.message:"Action failed","error")}async function Re(){if(k.trim())try{await $K(e,k.trim()),w(""),o()}catch(ge){Ne(ge)}}async function Se(ge,pe,se){if(ge.stopPropagation(),!!window.confirm(`Delete "${se}"? This can't be undone.`))try{await FK(e,pe),o()}catch(je){Ne(je)}}async function ze(ge,pe){try{switch(pe){case"open":await OK(e,ge);break;case"in_progress":await LK(e,ge);break;case"completed":await IK(e,ge);break;case"blocked":await MK(e,ge);break}o()}catch(se){Ne(se)}}async function oe(ge,pe){try{await zK(e,ge,pe),o()}catch(se){throw Ne(se),se}}async function we(ge,pe){try{await BK(e,ge,pe),o()}catch(se){Ne(se)}}async function ke(ge,pe){try{await UK(e,ge,pe),o()}catch(se){Ne(se)}}const $e=t0(B),Ue=$e.filter(ge=>!M.isCollapsed(ge.config.id)).flatMap(ge=>ge.items),{hotkeyRowProps:nt}=Ad(Ue,{scope:"list:todos",bindO:!1,onOpen:ge=>S(ge.id)});Jt({keys:"/",scope:"list:todos",description:"Focus filter",handler:()=>{var ge;return(ge=F.current)==null?void 0:ge.focus()}}),Jt({keys:"r",scope:"list:todos",description:"Refresh",handler:()=>o()});const[He,at]=Ns(),xt=He.get("focus");m.useEffect(()=>{if(!xt||!(t!=null&&t.items))return;const ge=t.items.find(se=>se.id===xt);if(!ge)return;const pe=Mm(ge.status);M.isCollapsed(pe)&&M.toggle(pe)},[xt,t==null?void 0:t.items]),m.useEffect(()=>{if(!xt)return;const ge=document.querySelector(`[data-todo-id="${window.CSS.escape(xt)}"]`);if(!ge)return;ge.scrollIntoView({block:"nearest"}),ge.classList.add("ring-2","ring-primary/60");const pe=window.setTimeout(()=>{ge.classList.remove("ring-2","ring-primary/60"),at(se=>{const je=new URLSearchParams(se);return je.delete("focus"),je},{replace:!0})},1500);return()=>window.clearTimeout(pe)},[xt,Ue.length,at]);const lt=A?(t==null?void 0:t.items.find(ge=>ge.id===A))??null:null;function ot(ge,pe){const se=V.current;if(se!=null&&se.closest(Ql)){ge.preventDefault();return}ge.dataTransfer.effectAllowed="move",ge.dataTransfer.setData("text/plain",pe),L(pe)}function le(){L(null),W(null)}function xe(ge,pe){!lt||pe.statuses.includes(lt.status)||(ge.preventDefault(),ge.dataTransfer.dropEffect="move",W(pe.id))}function Oe(ge,pe){z===pe.id&&!ge.currentTarget.contains(ge.relatedTarget)&&W(null)}function We(ge,pe){ge.preventDefault();const se=lt;le(),!(!se||pe.statuses.includes(se.status))&&ze(se.id,pe.dropStatus)}if(n)return s.jsx(jt,{label:"Loading todos..."});if(r)return s.jsx(Rt,{error:r});const Ge=(t==null?void 0:t.counts)||{open:0,in_progress:0,blocked:0,total:0};return s.jsxs("div",{className:"space-y-4",children:[s.jsx(Hr,{toast:i,onDismiss:l}),s.jsxs("div",{className:"grid gap-3 grid-cols-[repeat(auto-fill,minmax(140px,1fr))]",children:[s.jsx(Kn,{label:"Open",value:Ge.open,icon:gs}),s.jsx(Kn,{label:"In Progress",value:Ge.in_progress,icon:gs,tone:"info"}),s.jsx(Kn,{label:"Blocked",value:Ge.blocked,icon:Kh,tone:"warn"}),s.jsx(Kn,{label:"Total",value:Ge.total,icon:gs})]}),s.jsx("div",{className:"surface-panel p-3",children:s.jsxs("div",{className:"flex gap-2",children:[s.jsx("input",{type:"text",placeholder:"Add a todo...",value:k,onChange:ge=>w(ge.target.value),onKeyDown:ge=>ge.key==="Enter"&&Re(),className:"h-9 flex-1 rounded-md border border-border/70 bg-background px-3 text-sm text-foreground placeholder:text-muted-foreground/60 focus:border-foreground/30 focus:outline-none"}),s.jsxs("button",{onClick:Re,disabled:!k.trim(),className:"inline-flex h-9 items-center gap-1.5 rounded-md bg-foreground px-3 text-sm font-medium text-background transition hover:bg-foreground/90 disabled:opacity-40",children:[s.jsx(It,{className:"h-4 w-4"}),"Add"]})]})}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsxs("div",{className:"relative flex-1 max-w-sm",children:[s.jsx(Si,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),s.jsx("input",{ref:F,type:"text",placeholder:"Search...",value:d,onChange:ge=>f(ge.target.value),className:"h-9 w-full rounded-md border border-border/70 bg-background pl-9 pr-3 text-sm text-foreground placeholder:text-muted-foreground/60 focus:border-foreground/30 focus:outline-none"})]}),s.jsxs("select",{value:p,onChange:ge=>h(ge.target.value),className:"h-9 rounded-md border border-border/70 bg-background px-2 text-sm text-foreground focus:border-foreground/30 focus:outline-none",children:[s.jsx("option",{value:"",children:"All statuses"}),s.jsx("option",{value:"open",children:"Open"}),s.jsx("option",{value:"in_progress",children:"In Progress"}),s.jsx("option",{value:"completed",children:"Completed"}),s.jsx("option",{value:"blocked",children:"Blocked"})]}),O.length>0&&s.jsxs("select",{value:g,onChange:ge=>y(ge.target.value),className:"h-9 rounded-md border border-border/70 bg-background px-2 text-sm text-foreground focus:border-foreground/30 focus:outline-none",children:[s.jsx("option",{value:"",children:"All tags"}),O.map(ge=>s.jsxs("option",{value:ge,children:["#",ge]},ge))]})]}),C.size>0?s.jsxs("div",{className:"surface-panel flex items-center justify-between gap-3 px-3 py-2",children:[s.jsxs("span",{className:"text-sm font-medium",children:[C.size," selected"]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("button",{type:"button",onClick:()=>R(!0),className:"shell-action shell-action--cta",children:"Promote selected"}),s.jsx("button",{type:"button",onClick:()=>{I(null),_(!0)},className:"shell-action",children:"Move to…"}),s.jsx("button",{type:"button",onClick:ae,className:"text-xs text-muted-foreground hover:text-foreground",children:"Clear"})]})]}):null,B.length>0&&s.jsxs("div",{className:"flex items-center gap-3 px-3 py-1 text-xs text-muted-foreground",children:[s.jsx("input",{type:"checkbox","aria-label":"Select all visible todos",checked:H,ref:ge=>{ge&&(ge.indeterminate=Q)},onChange:Z,className:"h-4 w-4 cursor-pointer accent-foreground"}),s.jsxs("span",{children:["Select all in current filter (",B.length,")"]})]}),s.jsx("div",{className:"space-y-3",children:(()=>{let ge=-1;return $e.map(({config:pe,items:se})=>{const je=!M.isCollapsed(pe.id);return s.jsx(e0,{label:pe.label,count:se.length,expanded:je,onToggle:()=>M.toggle(pe.id),isDropTarget:z===pe.id,onDragOver:Ae=>xe(Ae,pe),onDragLeave:Ae=>Oe(Ae,pe),onDrop:Ae=>We(Ae,pe),children:je&&se.map(Ae=>(ge+=1,s.jsx(FP,{item:Ae,copiedId:b,selected:C.has(Ae.id),editing:N===Ae.id,onBeginEdit:qe=>S(qe),onEndEdit:()=>S(null),onPatchDescription:oe,onAddAttachments:we,onDeleteAttachment:ke,attachmentUrl:(qe,X)=>LP(e,qe,X),onToggleSelected:qe=>te(qe),onMoveOne:(qe,X)=>{X.stopPropagation(),I(qe),_(!0)},onStatusChange:ze,onCopyId:K,onDelete:Se,hotkeyRowProps:nt(ge),onDragOrigin:qe=>{V.current=qe.target},onDragStart:ot,onDragEnd:le,isDragging:A===Ae.id},Ae.id)))},pe.id)})})()}),s.jsx(Zw,{open:T,selectedIds:Array.from(C),scope:{kind:"project",projectId:e},onOpenChange:R,onDone:ye}),s.jsx(HP,{open:$,selectedIds:ne,scope:{kind:"project",projectId:e},onOpenChange:ge=>{_(ge),ge||I(null)},onDone:ue})]})}const eG={title:"Assignment",status:"Status",priority:"Priority",assignee:"Assignee",dependencies:"Dependencies",created:"Created",updated:"Updated"},wN=new Set(["title"]);function qP({visibility:e,onChange:t}){const[n,r]=m.useState(!1);function o(a){if(wN.has(a))return;const d=e.hidden.includes(a)?e.hidden.filter(f=>f!==a):[...e.hidden,a];t({hidden:d})}const i=e.hidden.length;return s.jsxs(Ln,{open:n,onOpenChange:r,children:[s.jsx(qF,{asChild:!0,children:s.jsxs("button",{type:"button",className:"inline-flex items-center gap-1.5 rounded-md border border-border/60 bg-background/60 px-2.5 py-1.5 text-xs font-medium text-foreground hover:bg-background",title:"Show or hide table columns",children:[s.jsx(DL,{className:"h-3.5 w-3.5","aria-hidden":"true"}),s.jsxs("span",{children:["Columns",i>0?` (${ly.length-i}/${ly.length})`:""]})]})}),s.jsxs(jn,{className:"max-w-sm",children:[s.jsx(er,{children:s.jsx(kn,{children:"Columns"})}),s.jsx("div",{className:"space-y-2",children:ly.map(a=>{const l=e.hidden.includes(a),d=wN.has(a);return s.jsxs("label",{className:`flex items-center gap-2 rounded-md px-2 py-1.5 text-sm ${d?"opacity-60":"cursor-pointer hover:bg-background/80"}`,children:[s.jsx("input",{type:"checkbox",checked:!l,onChange:()=>o(a),disabled:d,className:"h-4 w-4 rounded border-border accent-foreground"}),s.jsx("span",{children:eG[a]}),d?s.jsx("span",{className:"ml-auto text-xs text-muted-foreground",children:"always shown"}):null]},a)})})]})]})}const Ul={...Xu,custom:!1},KP=`view-prefs.cache.v${Xu.version}`;let ld=tG(),yl=null;const cd=new Set;let GP=0;function r0(){return++GP}function s0(e){return e===GP}function tG(){if(typeof window>"u"||!window.localStorage)return null;try{const e=window.localStorage.getItem(KP);if(!e)return null;const t=JSON.parse(e);return t.version!==Xu.version?null:t}catch{return null}}function nG(e){if(!(typeof window>"u"||!window.localStorage))try{window.localStorage.setItem(KP,JSON.stringify(e))}catch{}}function o0(e){ld=e,nG(e);for(const t of cd)t(e)}function i0(e){if(!e||typeof e!="object")return Ul;const t=e;return t.version!==Xu.version||!t.global||!t.projects?Ul:{version:Xu.version,global:t.global,projects:t.projects,custom:t.custom===!0}}function a0(){if(yl)return yl;const e=r0();return yl=fetch("/api/view-prefs").then(t=>{if(!t.ok)throw new Error(`HTTP ${t.status}`);return t.json()}).then(t=>{const n=i0(t);return s0(e)&&o0(n),yl=null,ld??n}).catch(()=>(yl=null,ld??Ul)),yl}function YP(e){const[t,n]=m.useState(()=>ld??Ul);return m.useEffect(()=>{let r=!1;return a0().then(o=>{r||n(o)}),cd.add(n),()=>{r=!0,cd.delete(n)}},[]),NT(t,e??null)}function rG(){const[e,t]=m.useState(()=>ld??Ul);return m.useEffect(()=>{let n=!1;return a0().then(r=>{n||t(r)}),cd.add(t),()=>{n=!0,cd.delete(t)}},[]),e}async function XP(e){const t=r0(),n=await fetch("/api/view-prefs",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!n.ok){const o=await n.json().catch(()=>({error:`HTTP ${n.status}`}));throw new Error(o.error??"Failed to save view-prefs")}const r=i0(await n.json());return s0(t)&&o0(r),r}function QP(e){return XP({global:e})}function JP(e,t){return XP({projects:{[e]:t}})}async function sG(){const e=r0(),t=await fetch("/api/view-prefs",{method:"DELETE"});if(!t.ok)throw new Error(`HTTP ${t.status}`);const n=i0(await t.json());return s0(e)&&o0(n),n}const jN=80;function ZP({open:e,onOpenChange:t,initialName:n="",onSubmit:r,title:o="Save view"}){const[i,a]=m.useState(n),[l,d]=m.useState(!1),[f,p]=m.useState(null);m.useEffect(()=>{e&&(a(n),p(null),d(!1))},[e,n]);const h=i.trim(),g=h.length>0&&h.length<=jN;return s.jsx(Ln,{open:e,onOpenChange:t,children:s.jsx(jn,{className:"max-w-md",children:s.jsxs("form",{className:"space-y-4",onSubmit:async y=>{if(y.preventDefault(),!(!g||l)){d(!0),p(null);try{await r(h)}catch(k){p(k instanceof Error?k.message:String(k)),d(!1)}}},children:[s.jsx(er,{children:s.jsx(kn,{children:o})}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("input",{type:"text",value:i,autoFocus:!0,required:!0,maxLength:jN,onChange:y=>a(y.target.value),placeholder:"View name",className:"w-full rounded-md border border-border/70 bg-background px-3 py-2 text-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"}),f?s.jsx("p",{className:"text-xs text-error-foreground",role:"alert",children:f}):null]}),s.jsxs(Ur,{children:[s.jsx("button",{type:"button",onClick:()=>t(!1),className:"shell-action",disabled:l,children:"Cancel"}),s.jsx("button",{type:"submit",disabled:!g||l,className:"shell-action shell-action--cta disabled:opacity-50",children:l?"Saving…":"Save"})]})]})})})}function e_({scope:e,loadedViewId:t,onApply:n,onOpenSaveDialog:r}){const{views:o,loading:i}=Id(),[a,l]=m.useState(!1),d=m.useRef(null);m.useEffect(()=>{if(!a)return;function g(k){d.current&&!d.current.contains(k.target)&&l(!1)}function y(k){k.key==="Escape"&&l(!1)}return document.addEventListener("mousedown",g),document.addEventListener("keydown",y),()=>{document.removeEventListener("mousedown",g),document.removeEventListener("keydown",y)}},[a]);const f=m.useMemo(()=>o.filter(g=>RR(g,e)),[o,e]),p=t?o.find(g=>g.id===t)??null:null,h=i?"Saved views…":p?p.name:"Saved views";return s.jsxs("div",{className:"relative",ref:d,children:[s.jsxs("button",{type:"button",disabled:i,onClick:()=>l(g=>!g),className:"inline-flex items-center gap-1.5 rounded-md border border-border/60 bg-background/60 px-2.5 py-1.5 text-xs font-medium text-foreground hover:bg-background disabled:opacity-50","aria-haspopup":"true","aria-expanded":a,title:"Saved views",children:[s.jsx("span",{className:"max-w-[160px] truncate",children:h}),s.jsx(vr,{className:"h-3.5 w-3.5","aria-hidden":"true"})]}),a&&s.jsx("div",{className:"absolute right-0 top-full z-30 mt-1 min-w-[240px] rounded-md border border-border/70 bg-background shadow-lg py-1",children:f.length===0?s.jsxs("div",{className:"px-3 py-3 text-sm text-muted-foreground",children:[s.jsx("p",{className:"mb-2",children:"No saved views yet — Save the current view to start."}),s.jsx("button",{type:"button",onClick:()=>{l(!1),r()},className:"shell-action w-full justify-center",children:"Save current view"})]}):f.map(g=>{const y=g.id===t;return s.jsxs("button",{type:"button",onClick:()=>{l(!1),n(g)},className:Ce("flex w-full items-center gap-2 px-3 py-1.5 text-left text-sm transition hover:bg-foreground/5",y&&"font-semibold text-foreground"),children:[s.jsx("span",{className:"inline-flex h-4 w-4 shrink-0 items-center justify-center",children:y?s.jsx(zr,{className:"h-3.5 w-3.5","aria-hidden":"true"}):null}),s.jsx("span",{className:"truncate",children:g.name})]},g.id)})})]})}const oG=new Set(["overview","assignments","todos","dependencies","knowledge"]),kN="__unknown_type__";function SN(){const{slug:e,workspace:t}=Vt(),n=pn(),r=Ht();Ei("project"),Jt({keys:"a",scope:"project",description:"Create assignment",handler:()=>r(`${n}/projects/${e}/create/assignment`)}),Jt({keys:"e",scope:"project",description:"Edit project",handler:()=>r(`${n}/projects/${e}/edit`)});const{data:o,loading:i,error:a,refetch:l}=N2(e),d=Es(),f=Rd(),{data:p}=Sa(),[h,g]=Ns(),y=h.get("tab"),k=y&&oG.has(y)?y:"overview";function w(ce){g(Te=>{const st=new URLSearchParams(Te);return ce==="overview"?st.delete("tab"):st.set("tab",ce),st},{replace:!0})}const b=e?`p:${e}`:null,j=YP(b),[N,S]=m.useState(()=>ty(j.defaultView)),[C,D]=m.useState(()=>Ke(j.filters.status)),[T,R]=m.useState(()=>Ke(j.filters.assignee)),[$,_]=m.useState(()=>Ke(j.filters.priority)),[U,I]=m.useState(()=>Ke(j.filters.type)),[F,M]=m.useState(()=>Ke(j.filters.tags)),[A,L]=m.useState(null),[z,W]=m.useState(()=>j.grouping),[V,K]=m.useState(()=>j.sortField),[O,B]=m.useState(()=>j.sortDirection),[G,H]=m.useState(()=>({collapsed:[]})),[Q,te]=m.useState(()=>({hidden:[]})),[Z,ae]=m.useState(()=>({hidden:[]})),[ne,ue]=m.useState(null),[ye,Ne]=m.useState(!1),[Re,Se]=m.useState(!1),{toast:ze,showToast:oe,dismissToast:we}=wr(),ke={kind:"project",slug:e??"",workspace:t??null},$e=h.get("loadView"),{view:Ue,loading:nt,error:He}=wi($e),{view:at,loading:xt,error:lt}=wi(ne),ot=m.useRef(null);m.useEffect(()=>{ne&&!xt&&!lt&&!at&&ue(null)},[at,lt,ne,xt]),m.useEffect(()=>{ue(null),ot.current=null,L(null)},[e,t]),m.useEffect(()=>{S(ty(j.defaultView)),D(Ke(j.filters.status)),R(Ke(j.filters.assignee)),_(Ke(j.filters.priority)),I(Ke(j.filters.type)),M(Ke(j.filters.tags)),W(j.grouping),K(j.sortField),B(j.sortDirection)},[e,j.defaultView,j.filters.status,j.filters.assignee,j.filters.priority,j.filters.type,j.filters.tags,j.grouping,j.sortField,j.sortDirection]);const le=m.useCallback(ce=>{b&&JP(b,ce).catch(Te=>{console.warn("Failed to persist project view prefs:",Te)})},[b]),xe=m.useCallback(ce=>{S(ce),le({defaultView:ce})},[le]),Oe=m.useCallback(ce=>{D(ce),le({filters:{status:ce}})},[le]),We=m.useCallback(ce=>{R(ce),le({filters:{assignee:ce}})},[le]),Ge=m.useCallback(ce=>{_(ce),le({filters:{priority:ce}})},[le]),ge=m.useCallback(ce=>{I(ce),le({filters:{type:ce}})},[le]),pe=m.useCallback(ce=>{M(ce),le({filters:{tags:ce}})},[le]),se=m.useCallback(ce=>{W(ce),le({grouping:ce})},[le]),je=m.useCallback(ce=>{K(ce),le({sortField:ce})},[le]),Ae=m.useCallback(ce=>{B(ce),le({sortDirection:ce})},[le]),qe=m.useCallback(()=>({viewMode:N,filters:{status:C,priority:$,type:U,assignee:T,tags:F,project:"all",activity:"all",dateRange:pa(A)},sortField:V,sortDirection:O,listSectionVisibility:G,kanbanColumnVisibility:Q,tableColumnVisibility:Z}),[N,C,$,U,T,F,A,V,O,G,Q,Z]),X=m.useCallback(ce=>{RA(ce,{setViewMode:Te=>S(ty(Te)),setStatusFilter:Oe,setPriorityFilter:Ge,setTypeFilter:ge,setAssigneeFilter:We,setTagsFilter:pe,setDateRange:L,setSortField:je,setSortDirection:Ae,setListSectionVisibility:H,setKanbanColumnVisibility:te,setTableColumnVisibility:ae}),ue(ce.id)},[Oe,Ge,ge,We,pe,je,Ae]),ve=m.useCallback(ce=>{X(ce),ot.current=ce.id,g(Te=>{const st=new URLSearchParams(Te);return st.set("loadView",ce.id),st},{replace:!0})},[X,g]),Ve=m.useCallback(async ce=>{try{const Te=Jl({name:ce,context:{workspace:t??null,projectSlug:e??null},state:qe()}),st=await Gl(Te),Tn=st.views[st.views.length-1];ue((Tn==null?void 0:Tn.id)??null),Tn&&(ot.current=Tn.id,g(kr=>{const no=new URLSearchParams(kr);return no.set("loadView",Tn.id),no},{replace:!0})),Ne(!1),Se(!1),oe(`Saved view "${ce}"`,"success")}catch(Te){throw oe(Te instanceof Error?Te.message:"Failed to save view","error"),Te}},[qe,g,oe,e,t]),ft=m.useCallback(async()=>{if(!(!ne||!at))try{const ce=Ke(at.config.filters.project)[0]??null,Te=Jl({name:at.name,context:{workspace:t??null,projectSlug:ce},state:qe()}),st=yh(at.config,Te.config,Te.config);await ph(ne,{config:st}),oe("View updated","success")}catch(ce){oe(ce instanceof Error?ce.message:"Failed to update view","error")}},[qe,at,ne,oe,t]);m.useEffect(()=>{if(!$e){ot.current=null;return}if(ot.current!==$e&&(ne&&ne!==$e&&ue(null),!nt)){if(He){oe("Couldn't load saved view — try again","error");return}if(Ue){if(ot.current=$e,!RR(Ue,{kind:"project",slug:e??"",workspace:t??null})){r(PA(Ue),{replace:!0});return}X(Ue),g(ce=>{const Te=new URLSearchParams(ce);return Te.delete("loadView"),Te},{replace:!0});return}ot.current=$e,oe("Saved view no longer exists","error"),g(ce=>{const Te=new URLSearchParams(ce);return Te.delete("loadView"),Te},{replace:!0})}},[$e,Ue,nt,He,ne,X,g,oe,r,e,t]);function et(ce){V===ce?Ae(O==="asc"?"desc":"asc"):(je(ce),Ae("asc"))}const yt=m.useMemo(()=>o?Object.fromEntries(o.assignments.flatMap(ce=>{const Te=`${n}/projects/${o.slug}/assignments/${ce.slug}`;return[[ce.slug,Te],[ce.title,Te]]})):{},[o]),[mt,he]=m.useState(!1);async function Ee(ce){he(!0);try{const Te=await fetch(`/api/projects/${e}/status-override`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({status:ce})});if(!Te.ok){const st=await Te.json().catch(()=>null);oe((st==null?void 0:st.error)||`HTTP ${Te.status}`,"error");return}l(),oe(ce?"Status override set":"Status override cleared","success")}catch(Te){oe(Te instanceof Error?Te.message:"Failed to update status","error")}finally{he(!1)}}async function Ye(ce){he(!0);try{const Te=await fetch(`/api/projects/${e}/${ce?"archive":"unarchive"}`,{method:"POST",headers:{"Content-Type":"application/json"}});if(!Te.ok){const st=await Te.json().catch(()=>null);oe((st==null?void 0:st.error)||`HTTP ${Te.status}`,"error");return}l(),oe(ce?"Project archived":"Project restored","success")}catch(Te){oe(Te instanceof Error?Te.message:"Failed to update archive state","error")}finally{he(!1)}}async function Nt(ce){he(!0);try{const Te=await fetch(`/api/projects/${e}/move-workspace`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({workspace:ce})});if(!Te.ok){const st=await Te.json().catch(()=>null);oe((st==null?void 0:st.error)||`HTTP ${Te.status}`,"error");return}l(),oe(ce?`Moved to "${ce}"`:"Moved to ungrouped","success")}catch(Te){oe(Te instanceof Error?Te.message:"Failed to move workspace","error")}finally{he(!1)}}if(i)return s.jsx(jt,{label:"Loading project workspace…"});if(a||!o)return s.jsx(Rt,{error:a||"Project not found."});const Mt=(()=>{const ce=new Set;for(const st of o.assignments)st.assignee&&ce.add(st.assignee);const Te=[{value:"__unassigned__",label:"Unassigned"}];for(const st of Array.from(ce).sort())Te.push({value:st,label:st});return Te})(),Nn=Array.from(new Set(o.assignments.flatMap(ce=>ce.tags??[]))).sort().map(ce=>({value:ce,label:ce})),Ct=o.assignments.filter(ce=>yU(ce,{status:C,priority:$,type:U,assignee:T,tags:F,dateRange:pa(A)})),Cn=Od(Ct,V,O),Ft=new Set(f.definitions.map(ce=>ce.id)),En=z==="type"?[...f.definitions.map(ce=>({id:ce.id,title:$l(f,ce.id),description:ce.description})),...Ct.some(ce=>!ce.type||!Ft.has(ce.type))?[{id:kN,title:"Other",description:"Assignments with no recognized type."}]:[]]:IA(d.order).map(ce=>({id:ce,title:So(d,ce),description:Fd(ce)}));function en({field:ce,children:Te}){const st=V===ce;return s.jsx("th",{className:"pb-3 font-medium",children:s.jsxs("button",{type:"button",onClick:()=>et(ce),className:"inline-flex items-center gap-1 hover:text-foreground",children:[Te,st?O==="asc"?s.jsx(GE,{className:"h-3 w-3"}):s.jsx(vr,{className:"h-3 w-3"}):null]})})}return s.jsxs("div",{className:"space-y-5","data-density":j.density,children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[s.jsx(vn,{status:o.status}),o.statusOverride&&s.jsx("button",{type:"button",className:"shell-action border-warning-foreground/40 text-warning-foreground disabled:cursor-not-allowed disabled:opacity-50",onClick:()=>Ee(null),disabled:mt,title:"Clear manual status override and return to derived status",children:"Clear Override"}),s.jsxs("select",{className:"shell-action appearance-none bg-transparent text-sm disabled:cursor-not-allowed disabled:opacity-50",value:"",disabled:mt,onChange:ce=>{ce.target.value&&Ee(ce.target.value)},title:"Override project status",children:[s.jsx("option",{value:"",children:"Set Status…"}),d.statuses.map(ce=>s.jsx("option",{value:ce.id,children:ce.label},ce.id)),s.jsx("option",{value:"active",children:"Active"})]}),s.jsx("button",{type:"button",className:"shell-action disabled:cursor-not-allowed disabled:opacity-50",onClick:()=>Ye(!o.archived),disabled:mt,title:o.archived?"Restore this project and its cascade-hidden assignments":"Archive this project (hides it and its assignments from normal views)",children:o.archived?"Restore":"Archive"}),p&&p.workspaces.length>0&&s.jsxs("select",{className:"shell-action appearance-none bg-transparent text-sm disabled:cursor-not-allowed disabled:opacity-50",value:"",disabled:mt,onChange:ce=>{ce.target.value==="_ungrouped"?Nt(null):ce.target.value&&Nt(ce.target.value)},title:"Move project to a different workspace",children:[s.jsx("option",{value:"",children:"Move to Workspace…"}),p.workspaces.filter(ce=>ce!==o.workspace).map(ce=>s.jsx("option",{value:ce,children:ce},ce)),o.workspace&&s.jsx("option",{value:"_ungrouped",children:"Ungrouped"})]}),s.jsxs(Ie,{className:"shell-action",to:`${n}/projects/${o.slug}/edit`,children:[s.jsx(Ux,{className:"h-4 w-4"}),s.jsx("span",{children:"Edit Project"})]}),s.jsx(Lw,{externalIds:o.externalIds}),s.jsxs("span",{className:"text-xs text-muted-foreground",children:["Created ",Gn(o.created),". Last source update ",es(o.updated),"."]})]}),s.jsxs("div",{className:"grid gap-3 grid-cols-2 sm:grid-cols-3 xl:grid-cols-5",children:[s.jsx(Kn,{label:"Assignments",value:o.progress.total}),s.jsx(Kn,{label:"In Progress",value:o.progress.in_progress??0,tone:"info"}),s.jsx(Kn,{label:"Review",value:o.progress.review??0,tone:"info"}),s.jsx(Kn,{label:"Blocked",value:o.progress.blocked??0,tone:"warn"}),s.jsx(Kn,{label:"Completed",value:o.progress.completed??0,tone:"success"})]}),s.jsxs("div",{className:"grid gap-4 xl:grid-cols-[minmax(0,1fr)_300px]",children:[s.jsx("div",{className:"space-y-4",children:s.jsx(_m,{value:k,onValueChange:w,items:[{value:"overview",label:"Overview",content:s.jsx("div",{className:"space-y-5",children:s.jsx(Qe,{title:"Project Overview",children:o.body&&o.body.trim()?s.jsx(xn,{content:o.body}):s.jsx(Tt,{title:"No overview yet",description:"Add a short summary so collaborators and agents know what this project is about.",actions:s.jsxs(Ie,{className:"shell-action shell-action--cta",to:`${n}/projects/${o.slug}/edit`,children:[s.jsx(Ux,{className:"h-4 w-4"}),s.jsx("span",{children:"Add overview"})]})})})})},{value:"assignments",label:"Assignments",count:o.assignments.filter(ce=>!ce.archived).length,content:s.jsx("div",{className:"space-y-5",children:s.jsx(Qe,{title:"Assignment Queue",description:"Board and table views over the source assignment files.",actions:s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsx(yn,{ariaLabel:"Status filter",className:"max-w-[170px]",allLabel:"All statuses",options:d.statuses.map(ce=>({value:ce.id,label:ce.label})),value:C,onChange:Oe}),s.jsx(yn,{ariaLabel:"Assignee filter",className:"max-w-[170px]",allLabel:"All assignees",options:Mt,value:T,onChange:We}),s.jsx(yn,{ariaLabel:"Priority filter",className:"max-w-[170px]",allLabel:"All priorities",options:[{value:"critical",label:"Critical"},{value:"high",label:"High"},{value:"medium",label:"Medium"},{value:"low",label:"Low"}],value:$,onChange:Ge}),s.jsx(yn,{ariaLabel:"Type filter",className:"max-w-[170px]",allLabel:"All types",options:f.definitions.map(ce=>({value:ce.id,label:$l(f,ce.id)})),value:U,onChange:ge}),s.jsx(yn,{ariaLabel:"Tags filter",className:"max-w-[170px]",allLabel:"Any tags",options:Nn,value:F,onChange:pe}),s.jsx(Em,{className:"max-w-[190px]",value:A,onChange:L}),N==="kanban"&&s.jsxs("select",{value:z==="type"?"type":"status",onChange:ce=>se(ce.target.value),className:"editor-input max-w-[170px]",title:"Group kanban by",children:[s.jsx("option",{value:"status",children:"Group: Status"}),s.jsx("option",{value:"type",children:"Group: Type"})]}),s.jsx(Am,{value:N,onChange:ce=>xe(ce),options:[{value:"kanban",label:"Kanban"},{value:"table",label:"Table"}]}),s.jsx(e_,{scope:ke,loadedViewId:ne,onApply:ve,onOpenSaveDialog:()=>{Se(!1),Ne(!0)}}),s.jsx("button",{type:"button",onClick:()=>{at?ft():(Se(!1),Ne(!0))},className:"inline-flex items-center gap-1.5 rounded-md border border-border/60 bg-background/60 px-2.5 py-1.5 text-xs font-medium text-foreground hover:bg-background",title:at?`Update ${at.name}`:"Save current view",children:at?`Update '${at.name}'`:"Save view"}),at?s.jsx("button",{type:"button",onClick:()=>{Se(!0),Ne(!0)},className:"inline-flex items-center gap-1.5 rounded-md border border-border/60 bg-background/60 px-2.5 py-1.5 text-xs font-medium text-foreground hover:bg-background",title:"Save as new view",children:"Save as new…"}):null]}),children:Ct.length===0?s.jsx(Tt,{title:"No assignments match these filters",description:"Clear the current filters or create a new assignment for this project.",actions:s.jsx(Ie,{className:"shell-action shell-action--cta",to:`${n}/projects/${o.slug}/create/assignment`,children:"Create Assignment"})}):N==="kanban"?s.jsx(Cm,{columns:En,items:Cn,getItemId:ce=>ce.slug,getColumnId:ce=>z==="type"?ce.type&&Ft.has(ce.type)?ce.type:kN:ce.status,dragDisabled:!0,boundedColumns:!0,renderCard:ce=>s.jsx(iG,{projectSlug:o.slug,assignment:ce}),emptyMessage:ce=>`No ${ce.title.toLowerCase()} assignments.`,hiddenColumnIds:Q.hidden,onHideColumn:ce=>te(Te=>({hidden:Te.hidden.includes(ce)?Te.hidden.filter(Tn=>Tn!==ce):[...Te.hidden,ce]}))}):(()=>{const ce=new Set(Z.hidden),Te=st=>st==="title"||!ce.has(st);return s.jsxs("div",{className:"overflow-x-auto",children:[s.jsx("div",{className:"mb-3 flex items-center justify-end",children:s.jsx(qP,{visibility:Z,onChange:ae})}),s.jsxs("table",{className:"w-full min-w-[720px] text-left text-sm",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"border-b border-border/60 text-muted-foreground",children:[Te("title")?s.jsx(en,{field:"title",children:"Assignment"}):null,Te("status")?s.jsx(en,{field:"status",children:"Status"}):null,s.jsx("th",{className:"pb-3 font-medium",children:"Type"}),Te("priority")?s.jsx(en,{field:"priority",children:"Priority"}):null,Te("assignee")?s.jsx(en,{field:"assignee",children:"Assignee"}):null,Te("dependencies")?s.jsx(en,{field:"dependencies",children:"Dependencies"}):null,Te("created")?s.jsx(en,{field:"created",children:"Created"}):null,Te("updated")?s.jsx(en,{field:"updated",children:"Updated"}):null]})}),s.jsx("tbody",{children:Cn.map(st=>s.jsxs("tr",{className:"border-b border-border/50 last:border-0",children:[Te("title")?s.jsx("td",{className:"py-4",children:s.jsx(Ie,{to:`${n}/projects/${o.slug}/assignments/${st.slug}`,className:"font-semibold text-foreground hover:text-primary",children:st.title})}):null,Te("status")?s.jsx("td",{className:"py-4",children:s.jsx(vn,{status:st.status,className:"max-w-[150px]"})}):null,s.jsx("td",{className:"py-4",children:s.jsx(Ea,{type:st.type,compact:!0})}),Te("priority")?s.jsx("td",{className:"py-4 capitalize text-muted-foreground",children:st.priority}):null,Te("assignee")?s.jsx("td",{className:"py-4 text-muted-foreground",children:st.assignee??"—"}):null,Te("dependencies")?s.jsx("td",{className:"py-4 text-muted-foreground",children:st.dependsOn.length}):null,Te("created")?s.jsx("td",{className:"py-4 text-muted-foreground",children:Gn(st.created)}):null,Te("updated")?s.jsx("td",{className:"py-4 text-muted-foreground",children:Gn(st.updated)}):null]},st.slug))})]})]})})()})})},{value:"todos",label:"Todos",content:s.jsx(ZK,{projectId:o.slug})},{value:"dependencies",label:"Dependencies",content:o.dependencyGraph?s.jsx(Qe,{title:"Dependency Graph",description:"Rendered from the derived graph when available, with a source-based fallback.",children:s.jsx(u9,{definition:o.dependencyGraph,nodeRoutes:yt})}):s.jsx(Tt,{title:"No dependency graph yet",description:"Dependencies appear here once assignments declare dependsOn relationships."})},{value:"knowledge",label:"Knowledge",content:s.jsxs("div",{className:"grid gap-3 lg:grid-cols-2",children:[s.jsx(Qe,{title:"Resources",description:"Shared project references.",actions:s.jsxs(Ie,{className:"shell-action",to:`/resources/new?project=${o.slug}`,children:[s.jsx(It,{className:"h-4 w-4"}),s.jsx("span",{children:"New Resource"})]}),children:o.resources.length===0?s.jsx(Tt,{title:"No resources yet",description:"Resources live at the project level and stay available to every assignment."}):s.jsx("div",{className:"space-y-3",children:o.resources.map(ce=>s.jsxs(Ie,{to:`/projects/${o.slug}/resources/${ce.slug}`,className:"block rounded-md border border-border/60 bg-background/80 p-3 transition hover:border-primary/40",children:[s.jsx("h3",{className:"font-semibold text-foreground",children:ce.name}),s.jsxs("p",{className:"mt-2 text-sm text-muted-foreground",children:[ce.category," · ",ce.source]})]},ce.slug))})}),s.jsx(Qe,{title:"Memories",description:"Learnings and patterns captured during the project.",actions:s.jsxs(Ie,{className:"shell-action",to:`/memories/new?project=${o.slug}`,children:[s.jsx(It,{className:"h-4 w-4"}),s.jsx("span",{children:"New Memory"})]}),children:o.memories.length===0?s.jsx(Tt,{title:"No memories yet",description:"Memories capture patterns discovered during execution so later assignments can reuse them."}):s.jsx("div",{className:"space-y-3",children:o.memories.map(ce=>s.jsxs(Ie,{to:`/projects/${o.slug}/memories/${ce.slug}`,className:"block rounded-md border border-border/60 bg-background/80 p-3 transition hover:border-primary/40",children:[s.jsx("h3",{className:"font-semibold text-foreground",children:ce.name}),s.jsxs("p",{className:"mt-2 text-sm text-muted-foreground",children:[ce.scope," · ",ce.source]})]},ce.slug))})})]})}]})}),s.jsxs("div",{className:"space-y-5",children:[s.jsx(Qe,{title:"Progress Summary",children:s.jsx(vh,{progress:o.progress,showLegend:!0})}),s.jsx(Qe,{title:"Attention",children:(()=>{const ce=[{label:"Blocked",count:o.needsAttention.blockedCount,alert:!0},{label:"Failed",count:o.needsAttention.failedCount,alert:!0},{label:"Unanswered questions",count:o.needsAttention.openQuestions,alert:!1}].filter(Te=>Te.count>0);return ce.length===0?s.jsx("p",{className:"text-sm text-muted-foreground",children:"Nothing needs attention."}):s.jsx("dl",{className:"space-y-3 text-sm",children:ce.map(Te=>s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("dt",{className:"text-muted-foreground",children:Te.label}),s.jsx("dd",{className:`font-semibold ${Te.alert?"text-warning-foreground":"text-foreground"}`,children:Te.count})]},Te.label))})})()}),s.jsx(Qe,{title:"Quick Links",children:s.jsxs("div",{className:"space-y-2 text-sm",children:[s.jsxs(Ie,{className:"flex items-center gap-2 text-primary hover:underline",to:`${n}/projects/${o.slug}/edit`,children:[s.jsx(Ux,{className:"h-4 w-4"}),"Edit project source"]}),s.jsxs(Ie,{className:"flex items-center gap-2 text-primary hover:underline",to:`${n}/projects/${o.slug}/create/assignment`,children:[s.jsx(It,{className:"h-4 w-4"}),"Create assignment"]}),s.jsxs(Ie,{className:"flex items-center gap-2 text-primary hover:underline",to:"/help",children:[s.jsx(kL,{className:"h-4 w-4"}),"Review project rules"]}),s.jsxs("button",{type:"button",onClick:()=>w("dependencies"),className:"flex items-center gap-2 text-primary hover:underline",children:[s.jsx(Pv,{className:"h-4 w-4"}),"Jump to dependencies"]})]})}),o.archived?s.jsxs(Qe,{title:"Archive Metadata",children:[s.jsxs("p",{className:"text-sm leading-6 text-muted-foreground",children:["Archived ",o.archivedAt?es(o.archivedAt):"with no timestamp recorded","."]}),o.archivedReason?s.jsx("p",{className:"mt-2 text-sm leading-6 text-muted-foreground",children:o.archivedReason}):null]}):null]})]}),s.jsx(Hr,{toast:ze,onDismiss:we}),s.jsx(ZP,{open:ye,onOpenChange:ce=>{Ne(ce),ce||Se(!1)},initialName:Re&&at?`${at.name} (copy)`:"",title:Re?"Save as new view":"Save view",onSubmit:Ve})]})}function iG({projectSlug:e,assignment:t}){const n=pn();return s.jsxs(Ie,{to:`${n}/projects/${e}/assignments/${t.slug}`,className:"vp-card block rounded-lg border border-border/60 bg-background/80 p-3 transition hover:border-primary/40",children:[s.jsxs("div",{className:"flex items-start justify-between gap-3",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsx("h3",{className:"font-semibold text-foreground",children:t.title}),s.jsxs("p",{className:"inline-flex items-center gap-1.5 font-mono text-xs text-muted-foreground/70",title:t.id,children:[t.id.slice(0,8),s.jsx("span",{onClick:r=>{r.preventDefault(),r.stopPropagation()},children:s.jsx(Zr,{value:t.id})})]}),s.jsxs("p",{className:"text-sm text-muted-foreground",children:["Updated ",Gn(t.updated)]})]}),s.jsx(vn,{status:t.status,className:"max-w-[150px]"})]}),s.jsxs("div",{className:"mt-4 flex flex-wrap gap-2",children:[s.jsx(Ea,{type:t.type}),s.jsx("span",{className:"rounded-full border border-border/60 px-2.5 py-1 text-xs capitalize text-muted-foreground",children:t.priority}),s.jsx("span",{className:"rounded-full border border-border/60 px-2.5 py-1 text-xs text-muted-foreground",children:t.assignee??"Unassigned"}),s.jsxs("span",{className:"rounded-full border border-border/60 px-2.5 py-1 text-xs text-muted-foreground",children:[t.dependsOn.length," dependencies"]})]})]})}function t_({sessionId:e,disabled:t=!1,disabledReason:n,onError:r,onNotice:o}){const[i,a]=m.useState(!1),[l,d]=m.useState(!1);async function f(){var h;if(t||l)return;d(!0);const p=(async()=>{const g=await fetch(`/api/launch/command?session=${encodeURIComponent(e)}&mode=resume`);if(!g.ok){const k=await g.json().catch(()=>null);throw new Error((k==null?void 0:k.error)??`HTTP ${g.status}`)}const y=await g.json().catch(()=>null);if(!y||typeof y.command!="string")throw new Error("Malformed response from launch command endpoint");return{command:y.command,fallbackWarning:typeof y.fallbackWarning=="string"&&y.fallbackWarning?y.fallbackWarning:void 0}})();try{const g=typeof((h=navigator.clipboard)==null?void 0:h.write)=="function"&&typeof ClipboardItem<"u";let y;if(g)await navigator.clipboard.write([new ClipboardItem({"text/plain":p.then(k=>new Blob([k.command],{type:"text/plain"}))})]),y=(await p).fallbackWarning;else{const k=await p;if(!navigator.clipboard||typeof navigator.clipboard.writeText!="function")throw new Error("Clipboard API is unavailable in this context.");await navigator.clipboard.writeText(k.command),y=k.fallbackWarning}a(!0),setTimeout(()=>a(!1),1500),y&&(o==null||o(y))}catch(g){let y=g instanceof Error?g:new Error(String(g));try{await p}catch(k){y=k instanceof Error?k:new Error(String(k))}r==null||r(y)}finally{d(!1)}}return t?s.jsx("button",{type:"button",disabled:!0,"aria-disabled":"true",className:"cursor-not-allowed text-muted-foreground/50",title:n??"Copy launch command unavailable","aria-label":"Copy launch command",children:s.jsx(f1,{className:"h-3 w-3","aria-hidden":"true"})}):s.jsx("button",{type:"button",onClick:f,disabled:l,className:"text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 rounded disabled:cursor-wait",title:i?"Copied!":"Copy launch command (cd + resume)","aria-label":"Copy launch command",children:i?s.jsx(zr,{className:"h-3 w-3 text-status-completed-foreground","aria-hidden":"true"}):s.jsx(f1,{className:"h-3 w-3","aria-hidden":"true"})})}function xu(e,t,n,r,o){let i=`syntaur://open?${e.kind}=${encodeURIComponent(e.id)}`;return e.kind==="session"&&t&&(i+=`&mode=${encodeURIComponent(t)}`),n&&(i+=`&terminal=${encodeURIComponent(n)}`),r&&e.kind==="assignment"&&(i+=`&agent=${encodeURIComponent(r)}`),o!==void 0&&e.kind==="assignment"&&(i+=`&prompt=${encodeURIComponent(o)}`),i}function aG(e){return e.kind==="session"?{method:"POST",url:`/api/agent-sessions/${encodeURIComponent(e.id)}/worktree/recreate`}:e.projectSlug&&e.assignmentSlug?{method:"POST",url:`/api/projects/${encodeURIComponent(e.projectSlug)}/assignments/${encodeURIComponent(e.assignmentSlug)}/worktree/recreate`}:{method:"POST",url:`/api/assignments/${encodeURIComponent(e.id)}/worktree/recreate`}}function lG(e){if(!e.trim())return"Branch name is required.";if(/\s/.test(e))return"Branch name cannot contain whitespace.";if(/[\x00-\x1F\x7F~^:?*[\\]/.test(e))return"Branch name cannot contain any of: ~ ^ : ? * [ \\ or control characters.";if(e.startsWith("-"))return'Branch name cannot start with "-".';if(e.startsWith("/")||e.endsWith("/"))return'Branch name cannot start or end with "/".';if(e.endsWith("."))return'Branch name cannot end with ".".';if(e.includes(".."))return'Branch name cannot contain "..".';if(e.includes("@{"))return'Branch name cannot contain "@{".';if(e==="@")return'Branch name cannot be "@".';for(const t of e.split("/")){if(!t)return'Branch name cannot contain empty path segments (e.g. "a//b").';if(t.startsWith("."))return'Branch name segments cannot start with ".".';if(t.endsWith(".lock"))return'Branch name segments cannot end with ".lock".'}return null}async function n_(e,t,n,r){const o=await fetch(`/api/projects/${e}/assignments/${t}/transitions/${n.command}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r?{reason:r}:{})}),i=await o.json().catch(()=>null);if(!o.ok)throw new Error((i==null?void 0:i.error)||`HTTP ${o.status}`);return i.assignment}async function r_(e,t,n){const r=await fetch(`/api/projects/${e}/assignments/${t}/status-override`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({status:n})}),o=await r.json().catch(()=>null);if(!r.ok)throw new Error((o==null?void 0:o.error)||`HTTP ${r.status}`);return o.assignment}async function cG(e,t){const n=await fetch(`/api/projects/${e}/assignments/${t}`,{method:"DELETE"}),r=await n.json().catch(()=>null);if(!n.ok)throw new Error((r==null?void 0:r.error)||`HTTP ${n.status}`)}function s_(e){return e.requiresReason||e.command==="block"}async function uG(e,t,n){const r=await fetch(`/api/assignments/${e}/transitions/${t.command}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n?{reason:n}:{})}),o=await r.json().catch(()=>null);if(!r.ok)throw new Error((o==null?void 0:o.error)||`HTTP ${r.status}`);return o.assignment}async function dG(e,t){const n=await fetch(`/api/assignments/${e}/status-override`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({status:t})}),r=await n.json().catch(()=>null);if(!n.ok)throw new Error((r==null?void 0:r.error)||`HTTP ${n.status}`);return r.assignment}async function fG(e){const t=await fetch(`/api/projects/${e.projectSlug}/assignments/${e.assignmentSlug}/title`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:e.title})}),n=await t.json().catch(()=>null);if(!t.ok)throw new Error((n==null?void 0:n.error)||`HTTP ${t.status}`);return n.assignment}async function pG(e){const t=await fetch(`/api/assignments/${e.id}/title`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:e.title})}),n=await t.json().catch(()=>null);if(!t.ok)throw new Error((n==null?void 0:n.error)||`HTTP ${t.status}`);return n.assignment}class l0 extends Error{constructor(t,n){super(t),this.stderr=n,this.name="CreateWorktreeError"}}async function c0(e){const t=await e.json().catch(()=>null);return new l0((t==null?void 0:t.error)||`HTTP ${e.status}`,t==null?void 0:t.stderr)}async function hG(e){const t=await fetch(`/api/projects/${e}/repository-candidates`),n=await t.json().catch(()=>null);if(!t.ok)throw new Error((n==null?void 0:n.error)||`HTTP ${t.status}`);return n.candidates}async function mG(e){const t=await fetch(`/api/assignments/${e}/repository-candidates`),n=await t.json().catch(()=>null);if(!t.ok)throw new Error((n==null?void 0:n.error)||`HTTP ${t.status}`);return n.candidates}async function gG(e,t,n){const r=await fetch(`/api/projects/${e}/assignments/${t}/worktree`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!r.ok)throw await c0(r);return(await r.json()).assignment}async function xG(e,t){const n=await fetch(`/api/assignments/${e}/worktree`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!n.ok)throw await c0(n);return(await n.json()).assignment}async function yG(e){const{url:t}=aG(e),n=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:"{}"});if(!n.ok)throw await c0(n);return await n.json()}async function Lm(e){const t=await e.json().catch(()=>null);if(!e.ok)throw new Error((t==null?void 0:t.error)||`HTTP ${e.status}`);return t}async function bG(e,t,n){const r=await fetch(`/api/projects/${e}/assignments/${t}/repository-branches?repo=${encodeURIComponent(n)}`);return Lm(r)}async function vG(e,t){const n=await fetch(`/api/assignments/${e}/repository-branches?repo=${encodeURIComponent(t)}`);return Lm(n)}async function wG(e,t){const n=await fetch(`/api/projects/${e}/assignments/${t}/source-assignments`);return(await Lm(n)).sourceAssignments}async function jG(e){const t=await fetch(`/api/assignments/${e}/source-assignments`);return(await Lm(t)).sourceAssignments}function o_(){const[e,t]=m.useState(!1),[n,r]=m.useState(null),[o,i]=m.useState(null),[a,l]=m.useState(null),[d,f]=m.useState(null),[p,h]=m.useState(null),[g,y]=m.useState(!1),[k,w]=m.useState(null),[b,j]=m.useState(null);async function N(T,R,$,_){if(!e){t(!0);try{const U=await fetch("/api/launch/preflight",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({target:{kind:T.kind,id:T.id}})});if(!U.ok){window.location.href=xu(T,R,void 0,$,_);return}const I=await U.json();if(I.ok){window.location.href=xu(T,R,void 0,$,_);return}if(I.reason==="workspace-path-invalid"){I.recreate?(f(I.recreate),h({target:T,mode:R,agentId:$,prompt:_})):l(I.message);return}r(I),i({target:T,mode:R,agentId:$,prompt:_})}catch(U){console.warn("preflight failed, firing without override:",U),window.location.href=xu(T,R,void 0,$,_)}finally{t(!1)}}}function S(){!n||!o||(window.location.href=xu(o.target,o.mode,n.suggestedFallback,o.agentId,o.prompt),r(null),i(null))}async function C(){if(!(!d||!p||g)){y(!0),w(null);try{const T=await yG({kind:d.kind,id:d.id,projectSlug:d.projectSlug,assignmentSlug:d.assignmentSlug}),{target:R,mode:$,agentId:_,prompt:U}=p;f(null),h(null),window.location.href=xu(R,$,void 0,_,U),!T.exact&&!T.alreadyExisted&&j(`Recreated from ${T.baseUsed} — the original branch couldn't be restored exactly, but the directory is back and your agent is opening.`)}catch(T){w(T instanceof l0&&T.stderr?`${T.message}
604
+ ${T.stderr}`:T instanceof Error?T.message:String(T))}finally{y(!1)}}}const D=s.jsxs(s.Fragment,{children:[s.jsx(kl,{open:n!==null,onOpenChange:T=>!T&&(r(null),i(null)),children:s.jsxs(oa,{children:[s.jsxs(Sl,{children:[s.jsxs(ia,{children:[n==null?void 0:n.terminal," is not installed"]}),s.jsxs(aa,{children:[(n==null?void 0:n.terminal)==="cmux"?s.jsxs(s.Fragment,{children:["To use cmux, install ",s.jsx("strong",{children:"cmux.app"})," into"," ",s.jsx("code",{children:"/Applications"}),"."," "]}):null,"Open in ",s.jsx("strong",{children:n==null?void 0:n.suggestedFallback})," instead? You can change the default in"," ",s.jsx(Ie,{to:"/settings",className:"underline hover:text-foreground",onClick:()=>{r(null),i(null)},children:"Settings"}),"."]})]}),s.jsxs(Nl,{children:[s.jsx(Ju,{className:"shell-action mt-0",children:"Cancel"}),s.jsxs(gi,{className:"shell-action mt-0 shell-action--cta",onClick:T=>{T.preventDefault(),S()},children:["Open in ",n==null?void 0:n.suggestedFallback]})]})]})}),s.jsx(kl,{open:a!==null,onOpenChange:T=>!T&&l(null),children:s.jsxs(oa,{children:[s.jsxs(Sl,{children:[s.jsx(ia,{children:"Can't open in agent"}),s.jsxs(aa,{children:[a," Set a valid worktree or repository, then try again."]})]}),s.jsx(Nl,{children:s.jsx(gi,{className:"shell-action mt-0 shell-action--cta",onClick:()=>l(null),children:"OK"})})]})}),s.jsx(kl,{open:d!==null,onOpenChange:T=>{!T&&!g&&(f(null),h(null),w(null))},children:s.jsxs(oa,{children:[s.jsxs(Sl,{children:[s.jsx(ia,{children:"Worktree was deleted"}),s.jsxs(aa,{children:["The worktree at ",s.jsx("code",{children:d==null?void 0:d.deletedPath})," no longer exists. Recreate it",d!=null&&d.branch?s.jsxs(s.Fragment,{children:[" ","on branch ",s.jsx("code",{children:d.branch})]}):null," ","so this can open?"]})]}),k&&s.jsx("pre",{className:"max-h-40 overflow-auto whitespace-pre-wrap rounded bg-muted p-2 text-xs text-destructive",children:k}),s.jsxs(Nl,{children:[s.jsx(Ju,{className:"shell-action mt-0",disabled:g,children:"No"}),s.jsx(gi,{className:"shell-action mt-0 shell-action--cta",disabled:g,onClick:T=>{T.preventDefault(),C()},children:g?"Recreating…":"Yes, recreate"})]})]})}),s.jsx(kl,{open:b!==null,onOpenChange:T=>!T&&j(null),children:s.jsxs(oa,{children:[s.jsxs(Sl,{children:[s.jsx(ia,{children:"Worktree recreated"}),s.jsx(aa,{children:b})]}),s.jsx(Nl,{children:s.jsx(gi,{className:"shell-action mt-0 shell-action--cta",onClick:()=>j(null),children:"OK"})})]})})]});return{open:N,pending:e,dialogs:D}}function i_({session:e,onMarkStopped:t}){const n=o_(),r={kind:"session",id:e.sessionId},o="size-3.5",i=Ce("shell-action","inline-flex items-center justify-center px-2 py-1 text-xs","disabled:cursor-not-allowed disabled:opacity-50"),a="inline-flex outline-none focus-visible:ring-1 focus-visible:ring-ring rounded-sm",l=!e.resumeSupported&&!e.forkSupported;return s.jsxs(s.Fragment,{children:[s.jsx(fa,{delayDuration:200,children:s.jsxs("div",{className:"inline-flex items-center gap-1",children:[l&&s.jsxs(Ir,{children:[s.jsx(Mr,{asChild:!0,children:s.jsx("span",{tabIndex:0,className:a,children:s.jsxs("button",{type:"button",disabled:!0,"aria-disabled":!0,className:i,children:[s.jsx(Al,{className:o}),s.jsx("span",{children:"Reopen"})]})})}),s.jsx(gr,{side:"top",children:"Reopen unavailable — this agent has no resume/fork command configured"})]}),e.resumeSupported&&(e.isLive?s.jsxs(Ir,{children:[s.jsx(Mr,{asChild:!0,children:s.jsx("span",{tabIndex:0,className:a,children:s.jsxs("button",{type:"button",disabled:!0,"aria-disabled":!0,className:i,children:[s.jsx(Al,{className:o}),s.jsx("span",{children:"Resume"})]})})}),s.jsx(gr,{side:"top",children:"Session appears active — fork instead to avoid transcript corruption"})]}):s.jsxs(Ir,{children:[s.jsx(Mr,{asChild:!0,children:s.jsxs("button",{type:"button",className:i,disabled:n.pending,onClick:()=>void n.open(r,"resume"),children:[s.jsx(Al,{className:o}),s.jsx("span",{children:"Resume"})]})}),s.jsx(gr,{side:"top",children:"Continue this session in its agent (same session id, same transcript)"})]})),e.forkSupported&&s.jsxs(Ir,{children:[s.jsx(Mr,{asChild:!0,children:s.jsxs("button",{type:"button",className:i,disabled:n.pending,onClick:()=>void n.open(r,"fork"),children:[s.jsx(BL,{className:o}),s.jsx("span",{children:"Fork"})]})}),s.jsx(gr,{side:"top",children:"Branch a new session from this point — safe even when the original is still running"})]}),e.status==="active"&&s.jsxs(Ir,{children:[s.jsx(Mr,{asChild:!0,children:s.jsxs("button",{type:"button",className:i,onClick:()=>t(e.sessionId),children:[s.jsx(Iv,{className:o}),s.jsx("span",{children:"Mark stopped"})]})}),s.jsx(gr,{side:"top",children:e.resumeSupported?"Tell the dashboard this session has ended so Resume re-enables":"Tell the dashboard this session has ended"})]})]})}),n.dialogs]})}async function kG(e){const t=await fetch(`/api/agent-sessions/${encodeURIComponent(e)}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({status:"stopped"})});if(!t.ok)throw new Error(await t.text().catch(()=>"")||`HTTP ${t.status}`)}function a_({sessions:e,loading:t,error:n,onError:r,onNotice:o}){return t&&!e?null:n&&!e?s.jsx(Qe,{title:"Agent Sessions",children:s.jsx(Tt,{title:"Couldn't load sessions",description:n})}):!e||e.length===0?s.jsx(Qe,{title:"Agent Sessions",children:s.jsx(Tt,{title:"No agent sessions yet",description:"Sessions appear here when an agent registers one via /grab-assignment or syntaur track-session."})}):s.jsx(Qe,{title:"Agent Sessions",children:s.jsx("div",{className:"space-y-2",children:e.map(i=>s.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1 text-sm",children:[s.jsxs("span",{className:"flex items-center gap-1.5",children:[s.jsx(Uh,{className:"h-3 w-3 shrink-0 text-muted-foreground"}),s.jsx("span",{className:"font-medium text-foreground",children:i.agent}),s.jsxs("span",{className:"inline-flex items-center gap-1.5 font-mono text-xs text-muted-foreground",title:i.sessionId,children:[i.sessionId.slice(0,8),s.jsx(Zr,{value:i.sessionId,onError:r}),s.jsx(t_,{sessionId:i.sessionId,disabled:!i.resumeSupported,disabledReason:"Resume not supported for this agent",onError:r,onNotice:o})]})]}),s.jsxs("span",{className:"flex items-center gap-2",children:[s.jsx(vn,{status:i.status}),s.jsx("span",{className:"text-xs text-muted-foreground",children:es(i.started)})]}),s.jsx(i_,{session:i,onMarkStopped:a=>kG(a).catch(l=>r==null?void 0:r(l instanceof Error?l:new Error(String(l))))})]},i.sessionId))})})}const Py="Cost / Usage";function l_({summary:e,error:t}){return t&&!e?s.jsx(Qe,{title:Py,children:s.jsx(Tt,{title:"Couldn't load usage",description:t})}):e?e.lastEventDay===null?s.jsx(Qe,{title:Py,children:s.jsx(Tt,{title:"No usage recorded yet",description:"Cost and token totals appear here once the usage collector records activity for this assignment."})}):s.jsx(Qe,{title:Py,children:s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsx(NN,{label:"Total cost",value:ql(e.totalCost)}),s.jsx(NN,{label:"Total tokens",value:Wl(e.totalTokens)})]}),e.byModel.length>1?s.jsxs("div",{className:"space-y-1.5 border-t border-border pt-3",children:[s.jsx("p",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"By model"}),s.jsx("div",{className:"space-y-1",children:e.byModel.map(n=>s.jsxs("div",{className:"flex items-center justify-between gap-2 text-sm",children:[s.jsxs("span",{className:"flex min-w-0 items-center gap-1.5",children:[s.jsx(Wh,{className:"h-3 w-3 shrink-0 text-muted-foreground"}),s.jsx("span",{className:"truncate font-mono text-xs text-foreground",title:n.model,children:n.model})]}),s.jsxs("span",{className:"shrink-0 text-xs text-muted-foreground",children:[Wl(n.totalTokens)," · ",ql(n.totalCost)]})]},n.model))})]}):null,s.jsxs("p",{className:"text-xs text-muted-foreground",children:["Last usage recorded ",W4(e.lastEventDay)]})]})}):null}function NN({label:e,value:t}){return s.jsxs("div",{className:"space-y-0.5",children:[s.jsx("p",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:e}),s.jsx("p",{className:"text-lg font-semibold tabular-nums text-foreground",children:t})]})}function c_({open:e,action:t,assignmentTitle:n,loading:r=!1,onConfirm:o,onOpenChange:i}){const[a,l]=m.useState("");m.useEffect(()=>{e||l("")},[e,t==null?void 0:t.command]);const d=m.useMemo(()=>t&&t.command==="block"?"Blocked Reason":"Reason",[t]);if(!t)return null;const f=`${t.label} "${n}"`,p=r?"Applying...":t.label,h=a.trim()||void 0;return s.jsx(Ln,{open:e,onOpenChange:g=>r?void 0:i(g),children:s.jsx(jn,{className:"max-w-xl",children:s.jsxs("form",{className:"space-y-5",onSubmit:g=>{g.preventDefault(),o(h)},children:[s.jsxs(er,{children:[s.jsx(kn,{children:f}),s.jsx(ns,{children:t.description})]}),t.warning?s.jsx("div",{className:"rounded-lg border border-warning-foreground/30 bg-warning px-4 py-3 text-sm text-warning-foreground",children:t.warning}):null,s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{className:"block text-xs font-medium uppercase tracking-[0.08em] text-muted-foreground",children:d}),s.jsx("textarea",{value:a,onChange:g=>l(g.target.value),autoFocus:!0,rows:4,disabled:r,placeholder:"Optional context for why this assignment is blocked.",className:"editor-textarea min-h-[120px] bg-background/95 font-sans"}),s.jsx("p",{className:"text-xs text-muted-foreground",children:"Leave this blank to continue without a written reason."})]}),s.jsxs(Ur,{children:[s.jsx("button",{type:"button",onClick:()=>i(!1),disabled:r,className:"shell-action disabled:cursor-not-allowed disabled:opacity-50",children:"Cancel"}),s.jsx("button",{type:"submit",disabled:r,className:"shell-action shell-action--cta disabled:cursor-not-allowed disabled:opacity-50",children:p})]})]})})})}function Ri({open:e,title:t,description:n,confirmLabel:r,cancelLabel:o="Cancel",loading:i=!1,destructive:a=!1,onConfirm:l,onOpenChange:d}){return s.jsx(kl,{open:e,onOpenChange:f=>i?void 0:d(f),children:s.jsxs(oa,{children:[s.jsxs(Sl,{children:[s.jsx(ia,{children:t}),s.jsx(aa,{children:n})]}),s.jsxs(Nl,{children:[s.jsx(Ju,{disabled:i,className:"shell-action mt-0 disabled:cursor-not-allowed disabled:opacity-50",children:o}),s.jsx(gi,{disabled:i,className:`shell-action mt-0 disabled:cursor-not-allowed disabled:opacity-50 ${a?"border-destructive/80 bg-destructive text-destructive-foreground hover:bg-destructive/90":"shell-action--cta"}`,onClick:f=>{f.preventDefault(),l()},children:i?"Working...":r})]})]})})}const SG=/^[a-z0-9][a-z0-9_-]*$/,u_=["first","last","none"];class d_ extends Error{constructor(n,r){super(n);_x(this,"fieldErrors");this.name="AgentsConfigError",this.fieldErrors=r}}const u0={agents:[],custom:!1};let Cl=null,bl=null,Sh=0;const Zb=new Set;function f_(e){Cl=e;for(const t of Zb)t(e)}function NG(e){if(!e||typeof e!="object"||Array.isArray(e))return null;const t=e;if(typeof t.id!="string"||t.id.length===0||typeof t.label!="string"||typeof t.command!="string")return null;const n={id:t.id,label:t.label,command:t.command};return Array.isArray(t.args)&&t.args.every(r=>typeof r=="string")&&(n.args=t.args),typeof t.promptArgPosition=="string"&&u_.includes(t.promptArgPosition)&&(n.promptArgPosition=t.promptArgPosition),typeof t.resolveFromShellAliases=="boolean"&&(n.resolveFromShellAliases=t.resolveFromShellAliases),typeof t.default=="boolean"&&(n.default=t.default),typeof t.model=="string"&&(n.model=t.model),typeof t.playbook=="string"&&(n.playbook=t.playbook),typeof t.launchPrompt=="string"&&(n.launchPrompt=t.launchPrompt),n}function d0(e){if(!e||typeof e!="object")return u0;const t=e,n=Array.isArray(t.agents)?t.agents:[],r=[];for(const o of n){const i=NG(o);i&&r.push(i)}return{agents:r,custom:t.custom===!0}}function CG(){if(Cl)return Promise.resolve(Cl);if(bl)return bl;const e=++Sh;return bl=fetch("/api/config/agents").then(t=>{if(!t.ok)throw new Error(`HTTP ${t.status}`);return t.json()}).then(t=>{bl=null;const n=d0(t);return e!==Sh?Cl??n:(Cl=n,n)}).catch(()=>(bl=null,u0)),bl}function p_(){const[e,t]=m.useState(()=>Cl??u0);return m.useEffect(()=>{let n=!1;return CG().then(r=>{n||t(r)}),Zb.add(t),()=>{n=!0,Zb.delete(t)}},[]),e}async function h_(e){const t=await e.json().catch(()=>null),n=(t==null?void 0:t.error)??`HTTP ${e.status}`;return new d_(n,t==null?void 0:t.fieldErrors)}async function EG(e){++Sh;const t=await fetch("/api/config/agents",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({agents:e})});if(!t.ok)throw await h_(t);const n=d0(await t.json());return f_(n),n}async function TG(){++Sh;const e=await fetch("/api/config/agents",{method:"DELETE"});if(!e.ok)throw await h_(e);const t=d0(await e.json());return f_(t),t}const CN=/[A-Za-z0-9_-]/,RG=/^[a-z0-9]+(-[a-z0-9]+)*$/,EN=/(^|\s)@([A-Za-z0-9_-]+)/g,ev="assignment";function m_(e,t){const n=Math.max(0,Math.min(t,e.length));let r=n;for(;r>0&&CN.test(e[r-1]);)r--;const o=r-1;if(o<0||e[o]!=="@"||o>0&&!/\s/.test(e[o-1]))return null;let i=n;for(;i<e.length&&CN.test(e[i]);)i++;return{start:o,end:i,partial:e.slice(o+1,n)}}function g_(e,t){const n=[ev,...t.filter(a=>a!==ev)],r=e.toLowerCase();if(r==="")return n;const o=[],i=[];for(const a of n){const l=a.toLowerCase();l.startsWith(r)?o.push(a):l.includes(r)&&i.push(a)}return[...o,...i]}function x_(e,t,n){const r=`@${n}`;return{text:e.slice(0,t.start)+r+e.slice(t.end),caret:t.start+r.length}}function y_(e,t){const n=t instanceof Set?t:new Set(t),r=[];EN.lastIndex=0;let o;for(;(o=EN.exec(e))!==null;){const i=o[2];i!==ev&&(RG.test(i)?n.has(i)||r.push(`Playbook "${i}" is not installed — "@${i}" will be left as literal text.`):r.push(`"@${i}" is not a valid playbook token — it will be left as literal text.`))}return r}const TN=2e3;function AG({open:e,assignmentId:t,agentId:n,onConfirm:r,onOpenChange:o}){const[i,a]=m.useState(""),[l,d]=m.useState([]),[f,p]=m.useState(!1),[h,g]=m.useState(null),[y,k]=m.useState(0),[w,b]=m.useState(0),[j,N]=m.useState(!1),S=m.useRef(null);m.useEffect(()=>{if(!e)return;let A=!1;p(!0),g(null),N(!1);const L=new URLSearchParams({assignment:t});return n&&L.set("agent",n),fetch(`/api/launch/prompt?${L.toString()}`).then(async z=>{if(!z.ok){const W=await z.json().catch(()=>null);throw new Error((W==null?void 0:W.error)??`HTTP ${z.status}`)}return await z.json()}).then(z=>{A||(a(z.template??""),d(z.knownPlaybookSlugs??[]),k((z.template??"").length))}).catch(z=>{A||g(z instanceof Error?z.message:String(z))}).finally(()=>{A||p(!1)}),()=>{A=!0}},[e,t,n]);const C=m_(i,y),D=C?g_(C.partial,l):[],T=e&&!f&&!j&&D.length>0,R=y_(i,l),$=i.length>TN;function _(A){a(A.target.value),k(A.target.selectionStart??A.target.value.length),b(0),N(!1)}function U(A){k(A.currentTarget.selectionStart??i.length),b(0)}function I(A){if(!C||!A)return;const L=x_(i,C,A);a(L.text),k(L.caret),b(0),N(!0),requestAnimationFrame(()=>{const z=S.current;z&&(z.focus(),z.setSelectionRange(L.caret,L.caret))})}function F(A){T&&(A.key==="ArrowDown"?(A.preventDefault(),b(L=>Math.min(L+1,D.length-1))):A.key==="ArrowUp"?(A.preventDefault(),b(L=>Math.max(L-1,0))):(A.key==="Enter"||A.key==="Tab")&&(A.preventDefault(),I(D[w])))}function M(){$||f||(r(i),o(!1))}return s.jsx(Ln,{open:e,onOpenChange:o,children:s.jsxs(jn,{onEscapeKeyDown:A=>{T&&(A.preventDefault(),N(!0))},children:[s.jsxs(er,{children:[s.jsx(kn,{children:"Edit launch prompt"}),s.jsxs(ns,{children:["The first message the agent starts with. ",s.jsx("code",{children:"@assignment"})," and"," ",s.jsx("code",{children:"@<playbook>"})," tokens resolve at launch. This edit applies to this launch only."]})]}),h?s.jsxs("p",{className:"text-sm text-error-foreground",children:["Couldn't load the prompt: ",h]}):s.jsxs("div",{className:"relative",children:[s.jsx("textarea",{ref:S,value:i,disabled:f,rows:4,spellCheck:!1,placeholder:f?"Loading…":"@assignment Run @<playbook> end-to-end.",onChange:_,onKeyDown:F,onKeyUp:U,onClick:U,className:Ce("w-full rounded-md border border-border/60 bg-background/90 p-3 font-mono text-sm text-foreground outline-none transition focus:border-primary focus:ring-2 focus:ring-ring/30 min-h-[80px] resize-y",$&&"border-error-foreground")}),T&&s.jsx("ul",{role:"listbox",className:"absolute left-0 right-0 top-full z-30 mt-1 max-h-48 overflow-auto rounded-md border border-border/70 bg-background py-1 shadow-lg",children:D.map((A,L)=>s.jsx("li",{children:s.jsxs("button",{type:"button",role:"option","aria-selected":L===w,onMouseDown:z=>{z.preventDefault(),I(A)},className:Ce("flex w-full items-center gap-2 px-2.5 py-1.5 text-left font-mono text-sm transition-colors hover:bg-accent",L===w&&"bg-accent"),children:[s.jsx("span",{className:"text-muted-foreground",children:"@"}),s.jsx("span",{className:"truncate",children:A})]})},A))})]}),R.length>0&&!h&&s.jsx("ul",{className:"space-y-0.5 text-[11px] text-error-foreground",children:R.map(A=>s.jsx("li",{children:A},A))}),$&&s.jsxs("p",{className:"text-[11px] text-error-foreground",children:["Too long — keep it under ",TN," characters (",i.length,")."]}),s.jsxs(Ur,{children:[s.jsx("button",{type:"button",className:"shell-action mt-0",onClick:()=>o(!1),children:"Cancel"}),s.jsx("button",{type:"button",className:"shell-action mt-0 shell-action--cta",disabled:f||$||h!==null,onClick:M,children:"Launch"})]})]})})}function b_({target:e,worktreePath:t=null,repository:n=null,size:r="default",title:o}){const i=e.kind==="assignment"&&!t&&!n,a=o_(),[l,d]=m.useState(null),p=p_().agents,[h,g]=m.useState(null);m.useEffect(()=>{p.length!==0&&g(R=>R&&p.some(_=>_.id===R)?R:(p.find(_=>_.default)??p[0]).id)},[p]);const y=e.kind==="assignment"&&p.length>1,k=p.find(R=>R.id===h)??null,w=m.useRef(null),[b,j]=m.useState(!1);m.useEffect(()=>{if(!b)return;function R(_){w.current&&!w.current.contains(_.target)&&j(!1)}function $(_){_.key==="Escape"&&j(!1)}return document.addEventListener("mousedown",R),document.addEventListener("keydown",$),()=>{document.removeEventListener("mousedown",R),document.removeEventListener("keydown",$)}},[b]);function N(R){var $,_;if(e.kind==="assignment"){const U=p.find(F=>F.id===R)??p.find(F=>F.default)??p[0];!!(($=U==null?void 0:U.launchPrompt)!=null&&$.trim())||!!((_=U==null?void 0:U.playbook)!=null&&_.trim())?a.open(e,void 0,R):d({agentId:R})}else a.open(e,void 0,R)}const S=e.kind==="assignment"?"Open this assignment in your configured terminal + agent":"Resume this session in its agent",C="Set a workspace path first — see the Workspace Before Code playbook",D=Ce("shell-action",r==="compact"&&"inline-flex items-center justify-center px-2 py-1 text-xs","disabled:cursor-not-allowed disabled:opacity-50");if(i)return s.jsxs("button",{type:"button",disabled:!0,title:C,className:D,"aria-disabled":!0,children:[s.jsx(Al,{className:"size-3.5"}),s.jsx("span",{children:"Open in agent"})]});const T=e.kind==="session"?"Open":"Open in agent";return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"relative inline-flex",ref:w,children:[s.jsxs("div",{className:"inline-flex items-stretch",children:[s.jsxs("button",{type:"button",onClick:()=>N(h??void 0),disabled:a.pending,title:(o??S)+(y&&k?` (${k.label})`:""),className:Ce(D,y&&"rounded-r-none"),children:[s.jsx(Al,{className:"size-3.5"}),s.jsx("span",{children:T})]}),y&&s.jsx("button",{type:"button",onClick:()=>j(R=>!R),disabled:a.pending,"aria-haspopup":"menu","aria-expanded":b,"aria-label":"Choose which agent to launch",title:"Choose which agent to launch",className:Ce(D,"-ml-px rounded-l-none",r==="compact"?"px-1":"px-1.5"),children:s.jsx(vr,{className:Ce("size-3.5 opacity-70 transition-transform",b&&"rotate-180")})})]}),b&&y&&s.jsxs("div",{role:"menu","aria-label":"Open with agent",className:"absolute right-0 top-full z-30 mt-1 min-w-[180px] overflow-hidden rounded-md border border-border/70 bg-background py-1 shadow-lg",children:[s.jsx("div",{className:"px-2.5 pb-1 pt-0.5 text-[10px] font-medium uppercase tracking-wide text-muted-foreground/70",children:"Open with agent"}),p.map(R=>s.jsxs("button",{type:"button",role:"menuitemradio","aria-checked":R.id===h,onClick:()=>{g(R.id),j(!1),N(R.id)},className:"flex w-full items-center gap-2 px-2.5 py-1.5 text-left text-sm text-foreground transition-colors hover:bg-accent",children:[s.jsx(zr,{className:Ce("size-3.5 shrink-0",R.id===h?"opacity-100":"opacity-0")}),s.jsx("span",{className:"truncate",children:R.label}),R.default&&s.jsx("span",{className:"ml-auto text-[10px] text-muted-foreground/60",children:"default"})]},R.id))]})]}),a.dialogs,e.kind==="assignment"&&l&&s.jsx(AG,{open:!0,assignmentId:e.id,agentId:l.agentId,onConfirm:R=>{a.open(e,void 0,l.agentId,R)},onOpenChange:R=>{R||d(null)}})]})}const _y="w-full rounded-md border border-border/70 bg-background px-3 py-2 text-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50";function v_({projectSlug:e,assignmentSlug:t,assignmentId:n,defaultBranch:r,defaultParentBranch:o="main",onCreated:i}){const a=e&&t?{kind:"project-nested",projectSlug:e,assignmentSlug:t}:{kind:"standalone",assignmentId:n},[l,d]=m.useState(!1),[f,p]=m.useState("new-branch"),[h,g]=m.useState(null),[y,k]=m.useState(null),[w,b]=m.useState(""),[j,N]=m.useState(!1),[S,C]=m.useState(""),[D,T]=m.useState([]),[R,$]=m.useState(!1),[_,U]=m.useState(null),[I,F]=m.useState(""),[M,A]=m.useState(null),[L,z]=m.useState(null),[W,V]=m.useState(""),[K,O]=m.useState(r),[B,G]=m.useState(!1),[H,Q]=m.useState(null);m.useEffect(()=>{if(!l)return;let oe=!1;return p("new-branch"),g(null),k(null),b(""),N(!1),C(""),T([]),$(!1),U(null),F(""),A(null),z(null),V(""),O(r),Q(null),(a.kind==="project-nested"?hG(a.projectSlug):mG(a.assignmentId)).then($e=>{if(!oe)if(g($e),$e.length===0)N(!0);else{const Ue=$e.find(He=>He.source==="project"),nt=$e.find(He=>He.source==="sibling");b((Ue==null?void 0:Ue.path)??(nt==null?void 0:nt.path)??$e[0].path)}}).catch($e=>{oe||(k($e.message),g([]),N(!0))}),(a.kind==="project-nested"?wG(a.projectSlug,a.assignmentSlug):jG(a.assignmentId)).then($e=>{oe||A($e)}).catch($e=>{oe||(z($e.message),A([]))}),()=>{oe=!0}},[l,r,o,e,t,n]);const te=f==="branch-off"?(M??[]).find(oe=>oe.id===W)??null:null,Z=f==="branch-off"?(te==null?void 0:te.repository)??"":j?S.trim():w;m.useEffect(()=>{if(!l||f!=="new-branch")return;if(!Z){T([]),U(null),$(!1),F("");return}let oe=!1;return $(!0),U(null),F(""),(a.kind==="project-nested"?bG(a.projectSlug,a.assignmentSlug,Z):vG(a.assignmentId,Z)).then(ke=>{if(oe)return;T(ke.branches);const $e=(ke.defaultBranch&&ke.branches.includes(ke.defaultBranch)?ke.defaultBranch:ke.branches.includes(o)?o:ke.branches[0])??"";F($e),$(!1)}).catch(ke=>{oe||(T([]),U(ke.message),$(!1))}),()=>{oe=!0}},[l,f,Z,o,e,t,n]);const ae=lG(K.trim()),ne=m.useMemo(()=>!Z||!K.trim()?"":`${Z.replace(/\/+$/,"")}/.worktrees/${K.trim()}`,[Z,K]),ue=h!==null&&h.length===0,ye=M!==null&&M.length===0,Ne=oe=>{oe!==f&&(p(oe),V(""),Q(null),oe==="branch-off"&&(F(""),T([]),U(null),$(!1)))},Re=oe=>{V(oe);const we=(M??[]).find(ke=>ke.id===oe);F((we==null?void 0:we.branch)??"")},Se=B||ae!==null||!Z||!I.trim()||(f==="new-branch"?h===null||R:M===null||!W),ze=async()=>{G(!0),Q(null);try{const oe={repository:Z,branch:K.trim(),parentBranch:I.trim()};a.kind==="project-nested"?await gG(a.projectSlug,a.assignmentSlug,oe):await xG(a.assignmentId,oe),d(!1),i()}catch(oe){oe instanceof l0?Q({message:oe.message,stderr:oe.stderr}):oe instanceof Error?Q({message:oe.message}):Q({message:String(oe)})}finally{G(!1)}};return s.jsxs(Ln,{open:l,onOpenChange:oe=>B?void 0:d(oe),children:[s.jsxs("button",{type:"button",className:"shell-action inline-flex items-center gap-1.5",onClick:()=>d(!0),children:[s.jsx(zL,{className:"h-3.5 w-3.5","aria-hidden":"true"}),s.jsx("span",{children:"Create worktree"})]}),s.jsxs(jn,{children:[s.jsxs(er,{children:[s.jsx(kn,{children:"Create worktree"}),s.jsxs(ns,{children:["Creates a git worktree at ",s.jsx("code",{children:"<repo>/.worktrees/<branch>"})," and records the workspace fields on this assignment's frontmatter."]})]}),s.jsxs("div",{className:"grid gap-4 text-sm",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-1 rounded-md border border-border/70 p-1",children:[s.jsx("button",{type:"button",disabled:B,onClick:()=>Ne("new-branch"),className:`rounded px-2 py-1.5 text-xs font-medium transition-colors disabled:cursor-not-allowed ${f==="new-branch"?"bg-foreground text-background":"text-muted-foreground hover:bg-muted"}`,children:"New branch from repo"}),s.jsx("button",{type:"button",disabled:B,onClick:()=>Ne("branch-off"),className:`rounded px-2 py-1.5 text-xs font-medium transition-colors disabled:cursor-not-allowed ${f==="branch-off"?"bg-foreground text-background":"text-muted-foreground hover:bg-muted"}`,children:"Branch off another assignment"})]}),f==="new-branch"?s.jsxs(s.Fragment,{children:[ue?s.jsxs("div",{className:"rounded-md border border-warning-foreground/30 bg-warning px-3 py-2 text-xs text-warning-foreground",children:["No repositories configured for this project. Enter a repo path below, or add a"," ",s.jsx("code",{children:"repositories:"})," list to ",s.jsx("code",{children:"project.md"}),"."]}):null,y?s.jsxs("div",{className:"rounded-md border border-error-foreground/30 bg-error px-3 py-2 text-xs text-error-foreground",children:["Could not load repository candidates: ",y]}):null,s.jsxs("label",{className:"grid gap-1",children:[s.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"Repository"}),s.jsx("select",{className:_y,value:w,onChange:oe=>b(oe.target.value),disabled:B||h===null||j,children:(h??[]).map(oe=>s.jsxs("option",{value:oe.path,children:[oe.path,oe.source==="project"?" (project)":oe.sourceAssignmentSlug?` (sibling — ${oe.sourceAssignmentSlug})`:" (sibling)"]},`${oe.source}:${oe.path}`))}),ue?null:s.jsx("button",{type:"button",className:"justify-self-start text-[11px] text-muted-foreground underline underline-offset-2 hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",disabled:B,onClick:()=>N(oe=>!oe),children:j?"Use a listed repository":"Enter a custom repository path (advanced)"}),j?s.jsx("input",{className:"mt-1 w-full rounded-md border border-border/70 bg-background px-3 py-2 text-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",type:"text",placeholder:"/absolute/path/to/repo",value:S,onChange:oe=>C(oe.target.value),disabled:B}):null]}),s.jsxs("label",{className:"grid gap-1",children:[s.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"Parent branch"}),s.jsx("select",{className:_y,value:I,onChange:oe=>F(oe.target.value),disabled:B||R||D.length===0,children:R?s.jsx("option",{value:"",children:"Loading branches…"}):D.length===0?s.jsx("option",{value:"",children:_?"Could not load branches":Z?"No branches found":"— pick a repository —"}):D.map(oe=>s.jsx("option",{value:oe,children:oe},oe))}),_?s.jsxs("span",{className:"text-[11px] text-error-foreground",children:["Could not load branches: ",_]}):null]})]}):s.jsxs(s.Fragment,{children:[L?s.jsxs("div",{className:"rounded-md border border-error-foreground/30 bg-error px-3 py-2 text-xs text-error-foreground",children:["Could not load assignments: ",L]}):null,ye?s.jsx("div",{className:"rounded-md border border-warning-foreground/30 bg-warning px-3 py-2 text-xs text-warning-foreground",children:"No other assignments with a configured workspace to branch off. Create a worktree for one first, or use “New branch from repo”."}):s.jsxs("label",{className:"grid gap-1",children:[s.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"Source assignment"}),s.jsxs("select",{className:_y,value:W,onChange:oe=>Re(oe.target.value),disabled:B||M===null,children:[s.jsx("option",{value:"",children:"— select an assignment —"}),(M??[]).map(oe=>s.jsxs("option",{value:oe.id,children:[oe.title," (",oe.branch,")"]},oe.id))]})]}),te?s.jsxs("div",{className:"grid gap-2 rounded-md border border-border/70 bg-muted/40 px-3 py-2 text-xs",children:[s.jsxs("div",{className:"grid gap-0.5",children:[s.jsx("span",{className:"font-medium text-muted-foreground",children:"Repository (from source)"}),s.jsx("code",{className:"break-all",children:te.repository})]}),s.jsxs("div",{className:"grid gap-0.5",children:[s.jsx("span",{className:"font-medium text-muted-foreground",children:"Parent branch (from source)"}),s.jsx("code",{children:te.branch})]})]}):null]}),s.jsxs("label",{className:"grid gap-1",children:[s.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"New branch name"}),s.jsx("input",{className:"w-full rounded-md border border-border/70 bg-background px-3 py-2 text-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",type:"text",value:K,onChange:oe=>O(oe.target.value),disabled:B}),ae?s.jsx("span",{className:"text-[11px] text-error-foreground",children:ae}):null]}),s.jsxs("div",{className:"grid gap-1",children:[s.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"Worktree path"}),s.jsx("code",{className:"rounded-md border border-border bg-muted px-2 py-1 text-xs break-all",children:ne||s.jsx("span",{className:"opacity-60",children:"— pick a repo & branch —"})})]}),H?s.jsxs("div",{className:"rounded-md border border-error-foreground/30 bg-error px-3 py-2 text-xs text-error-foreground",children:[s.jsx("div",{className:"font-medium",children:H.message}),H.stderr?s.jsx("pre",{className:"mt-2 whitespace-pre-wrap text-[11px] opacity-90",children:H.stderr}):null]}):null]}),s.jsxs(Ur,{children:[s.jsx(jT,{disabled:B,className:"shell-action mt-0 disabled:cursor-not-allowed disabled:opacity-50",children:"Cancel"}),s.jsx("button",{type:"button",disabled:Se,onClick:()=>void ze(),className:"shell-action mt-0 shell-action--cta disabled:cursor-not-allowed disabled:opacity-50",children:B?"Working…":"Create worktree"})]})]})]})}function PG(e){const t=e.split(`
605
+ `),n=t.findIndex(a=>/^##\s+Acceptance Criteria\s*$/i.test(a.trim()));if(n===-1)return{acceptanceCriteria:[],summaryBody:e};let r=t.length;for(let a=n+1;a<t.length;a+=1)if(/^#{1,2}\s+\S/.test(t[a].trim())){r=a;break}const o=t.slice(n+1,r).map(a=>a.match(/^\s*[-*]\s+\[( |x|X)\]\s+(.*)$/)).filter(a=>!!a).map(a=>({checked:a[1].toLowerCase()==="x",text:a[2].trim()})),i=[...t.slice(0,n),...t.slice(r)].join(`
606
+ `).replace(/\n{3,}/g,`
607
+
608
+ `).trim();return{acceptanceCriteria:o,summaryBody:i}}function _G(e){const t=e.split(`
609
+ `),n=t.findIndex(a=>/^##\s+Todos\s*$/i.test(a.trim()));if(n===-1)return{hasSection:!1,todosMarkdown:"",remaining:e};let r=t.length;for(let a=n+1;a<t.length;a+=1)if(/^#{1,2}\s+\S/.test(t[a].trim())){r=a;break}const o=t.slice(n+1,r).join(`
610
+ `).replace(/<!--[\s\S]*?-->/g,"").replace(/\n{3,}/g,`
611
+
612
+ `).trim(),i=[...t.slice(0,n),...t.slice(r)].join(`
613
+ `).replace(/\n{3,}/g,`
614
+
615
+ `).trim();return{hasSection:!0,todosMarkdown:o,remaining:i}}function DG({projectSlug:e,dependencies:t,blockedReason:n}){const[r,o]=m.useState(!1);if(t.length===0)return null;const i=t.filter(l=>l.status!=="completed"&&l.status!=="review"),a=i.length===0;return a&&!r?s.jsxs("button",{type:"button",onClick:()=>o(!0),className:"flex w-full items-center gap-2 rounded-lg border border-success-foreground/30 bg-success/70 px-4 py-2.5 text-left transition hover:bg-success",children:[s.jsx(Rv,{className:"h-4 w-4 shrink-0 text-success-foreground"}),s.jsxs("span",{className:"text-sm font-medium text-success-foreground",children:["All ",t.length," ",t.length===1?"dependency":"dependencies"," resolved"]}),s.jsx(vr,{className:"ml-auto h-4 w-4 text-success-foreground"})]}):s.jsxs("div",{className:"space-y-3",children:[i.length>0&&s.jsxs("div",{className:"flex items-start gap-3 rounded-lg border border-warning-foreground/30 bg-warning px-4 py-3",children:[s.jsx(eh,{className:"mt-0.5 h-4 w-4 shrink-0 text-warning-foreground"}),s.jsxs("div",{className:"text-sm text-warning-foreground",children:[s.jsxs("strong",{children:[i.length," ",i.length===1?"dependency is":"dependencies are"," not yet completed."]}),n&&s.jsxs("p",{className:"mt-1 text-warning-foreground/80",children:["Blocked reason: ",n]})]})]}),s.jsx(Qe,{title:"Dependencies",description:`${t.length-i.length} of ${t.length} resolved`,actions:a?s.jsx("button",{type:"button",onClick:()=>o(!1),className:"text-xs text-muted-foreground hover:text-foreground",children:"Collapse"}):void 0,children:s.jsx("div",{className:"divide-y divide-border/40",children:t.map(l=>s.jsxs(Ie,{to:`/projects/${e}/assignments/${l.slug}`,className:"flex items-center gap-3 px-1 py-2.5 transition hover:bg-muted/40 first:pt-0 last:pb-0",children:[s.jsx(vn,{status:l.status}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("p",{className:"truncate text-sm font-medium text-foreground",children:l.title}),s.jsx("p",{className:"truncate text-xs text-muted-foreground",children:l.slug})]}),l.assignee&&s.jsx("span",{className:"hidden text-xs text-muted-foreground sm:inline",children:l.assignee}),s.jsx(Zp,{className:"h-4 w-4 shrink-0 text-muted-foreground"})]},l.slug))})})]})}function $G({links:e}){const t=pn();if(e.length===0)return null;const n=e.filter(o=>!o.isReverse),r=e.filter(o=>o.isReverse);return s.jsx(Qe,{title:"Linked Assignments",description:`${e.length} ${e.length===1?"link":"links"}`,children:s.jsxs("div",{className:"divide-y divide-border/40",children:[n.map(o=>s.jsxs(Ie,{to:`${t}/projects/${o.projectSlug}/assignments/${o.assignmentSlug}`,className:"flex items-center gap-3 px-1 py-2.5 transition hover:bg-muted/40 first:pt-0 last:pb-0",children:[s.jsx(VE,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),s.jsx(vn,{status:o.status}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("p",{className:"truncate text-sm font-medium text-foreground",children:o.title}),s.jsx("p",{className:"truncate text-xs text-muted-foreground",children:o.slug})]}),s.jsx(Zp,{className:"h-4 w-4 shrink-0 text-muted-foreground"})]},`fwd-${o.slug}`)),r.map(o=>s.jsxs(Ie,{to:`${t}/projects/${o.projectSlug}/assignments/${o.assignmentSlug}`,className:"flex items-center gap-3 px-1 py-2.5 transition hover:bg-muted/40 first:pt-0 last:pb-0",children:[s.jsx(Jp,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),s.jsx(vn,{status:o.status}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("p",{className:"truncate text-sm font-medium text-foreground",children:o.title}),s.jsx("p",{className:"truncate text-xs text-muted-foreground",children:o.slug})]}),s.jsx(Zp,{className:"h-4 w-4 shrink-0 text-muted-foreground"})]},`rev-${o.slug}`))]})})}function IG(e){const t=new Map;for(const r of e)t.set(r.id,{entry:r,replies:[]});const n=[];for(const r of e){const o=t.get(r.id);r.replyTo&&t.has(r.replyTo)?t.get(r.replyTo).replies.push(o):n.push(o)}return n}function MG(e,t){return e===null?`/api/assignments/${encodeURIComponent(t)}/comments`:`/api/projects/${encodeURIComponent(e)}/assignments/${encodeURIComponent(t)}/comments`}function w_({projectSlug:e,assignmentSlug:t,entries:n}){const[r,o]=m.useState(n);m.useEffect(()=>{o(n)},[n]);const i=m.useMemo(()=>IG(r),[r]),[a,l]=m.useState(""),[d,f]=m.useState("note"),[p,h]=m.useState(!1),[g,y]=m.useState(null);async function k(b){var S;if(b.preventDefault(),!a.trim())return;h(!0),y(null);const j=`tmp-${Date.now()}`,N={id:j,timestamp:new Date().toISOString(),author:"human",type:d,body:a,resolved:d==="question"?!1:void 0};o(C=>[...C,N]);try{const C=await fetch(MG(e,t),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({body:a,type:d})});if(!C.ok){const R=await C.text();throw new Error(R||`HTTP ${C.status}`)}const D=await C.json().catch(()=>null),T=(S=D==null?void 0:D.comment)==null?void 0:S.id;o(R=>R.map($=>$.id===j?{...$,id:T??$.id}:$)),l(""),window.dispatchEvent(new CustomEvent("syntaur-refresh"))}catch(C){y(C instanceof Error?C.message:String(C)),o(D=>D.filter(T=>T.id!==j))}finally{h(!1)}}async function w(b,j){o(N=>N.map(S=>S.id===b?{...S,resolved:j}:S));try{const N=e===null?`/api/assignments/${encodeURIComponent(t)}/comments/${encodeURIComponent(b)}/resolved`:`/api/projects/${encodeURIComponent(e)}/assignments/${encodeURIComponent(t)}/comments/${encodeURIComponent(b)}/resolved`,S=await fetch(N,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({resolved:j})});if(!S.ok)throw new Error(`HTTP ${S.status}`);window.dispatchEvent(new CustomEvent("syntaur-refresh"))}catch(N){y(N instanceof Error?N.message:String(N)),o(S=>S.map(C=>C.id===b?{...C,resolved:!j}:C))}}return s.jsx(Qe,{title:"Comments",description:"Threaded questions, notes, and feedback. Questions can be resolved once answered.",children:s.jsxs("div",{className:"space-y-4",children:[i.map(b=>s.jsx(j_,{node:b,onToggleResolved:w,depth:0},b.entry.id)),s.jsxs("form",{onSubmit:k,className:"mt-6 space-y-2 border-t border-border pt-4",children:[s.jsx("label",{className:"block text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"Add comment"}),s.jsx("textarea",{value:a,onChange:b=>l(b.target.value),className:"w-full rounded border border-border bg-background p-2 text-sm",rows:3,placeholder:"Ask a question, leave a note, or give feedback…"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("select",{value:d,onChange:b=>f(b.target.value),className:"rounded border border-border bg-background px-2 py-1 text-xs",children:[s.jsx("option",{value:"note",children:"note"}),s.jsx("option",{value:"question",children:"question"}),s.jsx("option",{value:"feedback",children:"feedback"})]}),s.jsx("button",{type:"submit",disabled:p||!a.trim(),className:"shell-action",children:p?"Posting…":"Post comment"}),g?s.jsx("span",{className:"text-xs text-error-foreground",children:g}):null]})]})]})})}function j_({node:e,depth:t,onToggleResolved:n}){const{entry:r,replies:o}=e,i=r.type==="question";return s.jsxs("div",{className:Ce("space-y-2",t>0&&"ml-4 border-l border-border pl-4"),children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-xs text-muted-foreground",children:[s.jsx("span",{className:"font-mono",children:r.id}),s.jsx("span",{children:"·"}),s.jsx("span",{children:r.timestamp}),s.jsx("span",{children:"·"}),s.jsx("span",{className:"font-medium text-foreground",children:r.author}),s.jsx("span",{children:"·"}),s.jsx("span",{className:Ce("rounded px-1.5 py-0.5 font-mono text-[10px] uppercase",i&&"bg-warning text-warning-foreground",r.type==="feedback"&&"bg-info text-info-foreground",r.type==="note"&&"bg-muted text-muted-foreground"),children:r.type}),i?s.jsxs("button",{type:"button",onClick:()=>n(r.id,!r.resolved),className:Ce("inline-flex items-center gap-1 rounded px-1.5 py-0.5 text-[10px] font-medium",r.resolved?"bg-success text-success-foreground hover:bg-success/80":"bg-muted text-muted-foreground hover:bg-muted/80"),title:r.resolved?"Mark unresolved":"Mark resolved",children:[r.resolved?s.jsx(Rv,{className:"h-3 w-3"}):s.jsx(TL,{className:"h-3 w-3"}),r.resolved?"resolved":"open"]}):null,r.replyTo?s.jsxs("span",{className:"inline-flex items-center gap-1 text-muted-foreground",children:[s.jsx(t4,{className:"h-3 w-3"}),r.replyTo]}):null]}),s.jsx(xn,{content:r.body}),o.length>0?s.jsx("div",{className:"space-y-2",children:o.map(a=>s.jsx(j_,{node:a,depth:t+1,onToggleResolved:n},a.entry.id))}):null]})}const LG=["review","complete","shape","plan-ready","implement","unblock","start","block","fail","reopen"];function RN(){var je,Ae,qe,X,ve,Ve,ft,et,yt,mt;const{slug:e,aslug:t}=Vt(),n=Ht(),r=pn(),[o,i]=Ns(),[a,l]=m.useState(null),{toast:d,showToast:f,dismissToast:p}=wr(),[h,g]=m.useState(null),[y,k]=m.useState(null),[w,b]=m.useState(null),[j,N]=m.useState(null),[S,C]=m.useState({}),[D,T]=m.useState(!1),[R,$]=m.useState(!1),[_,U]=m.useState(0),I=o.get("tab")??"summary",F=Es(),{data:M,loading:A,error:L,refetch:z}=pO(e,t),{data:W}=N2(e),{data:V}=Fv(),{data:K,loading:O,error:B}=mO(e,t),{data:G,loading:H,error:Q}=xO(e,t),te=m.useMemo(()=>{if(!M||!W)return[];const he=new Map(W.assignments.map(Ee=>[Ee.slug,Ee]));return M.dependsOn.map(Ee=>{const Ye=he.get(Ee);return{slug:Ee,title:(Ye==null?void 0:Ye.title)??Ee,status:(Ye==null?void 0:Ye.status)??"pending",priority:(Ye==null?void 0:Ye.priority)??"medium",assignee:(Ye==null?void 0:Ye.assignee)??null}})},[M,W]),Z=te.filter(he=>he.status!=="completed"&&he.status!=="review");Ei("assignment");const ae=m.useMemo(()=>((W==null?void 0:W.assignments)??[]).map(he=>he.slug),[W]),ne=t?ae.indexOf(t):-1,ue=ne>0?ae[ne-1]:null,ye=ne>=0&&ne<ae.length-1?ae[ne+1]:null,Ne=`${r}/projects/${e}/assignments/${t}`;Jt({keys:"e",scope:"assignment",description:"Edit assignment",handler:()=>n(`${Ne}/edit`)}),Jt({keys:"p",scope:"assignment",description:"Edit plan",handler:()=>n(`${Ne}/plan/edit`)}),Jt({keys:"h",scope:"assignment",description:"Append handoff",handler:()=>n(`${Ne}/handoff/edit`)}),Jt({keys:"d",scope:"assignment",description:"Append decision record",handler:()=>n(`${Ne}/decision-record/edit`)}),Jt({keys:"s",scope:"assignment",description:"Edit scratchpad",handler:()=>n(`${Ne}/scratchpad/edit`)}),Jt({keys:"[",scope:"assignment",description:"Previous assignment in project",enabled:!!ue,handler:()=>ue&&n(`${r}/projects/${e}/assignments/${ue}`)}),Jt({keys:"]",scope:"assignment",description:"Next assignment in project",enabled:!!ye,handler:()=>ye&&n(`${r}/projects/${e}/assignments/${ye}`)});const Re=m.useMemo(()=>M?PG(M.body):{acceptanceCriteria:[],summaryBody:""},[M]);m.useEffect(()=>{C({})},[M]);const Se=m.useMemo(()=>_G(Re.summaryBody),[Re.summaryBody]),ze=Re.acceptanceCriteria,oe=ze.filter(he=>he.checked).length,we=ze.length>0&&oe===ze.length,ke=m.useRef(we),$e=m.useRef(!1);if(m.useEffect(()=>{if(M){if(!$e.current){ke.current=we,$e.current=!0;return}we&&!ke.current&&U(he=>he+1),ke.current=we}},[we,M]),A)return s.jsx(jt,{label:"Loading assignment workspace…"});if(L||!M||!e||!t)return s.jsx(Rt,{error:L||"Assignment not found."});const Ue=e,nt=t,He=ze.length>0?{checked:oe,total:ze.length}:void 0,at=M.availableTransitions??[],xt=at.filter(he=>!he.disabled&&he.targetStatus!==M.status),lt=LG.map(he=>xt.find(Ee=>Ee.command===he)).find(Boolean)??xt[0]??null,ot=[];if(V!=null&&V.sessions)for(const he of V.sessions)for(const Ee of he.windows)for(const Ye of Ee.panes)((je=Ye.assignment)==null?void 0:je.project)===e&&((Ae=Ye.assignment)==null?void 0:Ae.slug)===t&&ot.push({sessionName:he.name,command:Ye.command,urls:Ye.urls});async function le(he){l(null);try{await r_(Ue,nt,he),z()}catch(Ee){l(Ee.message)}}async function xe(he){l(null);try{const Ee=await fetch(`/api/projects/${Ue}/assignments/${nt}/${he?"archive":"unarchive"}`,{method:"POST",headers:{"Content-Type":"application/json"}});if(!Ee.ok){const Ye=await Ee.json().catch(()=>null);throw new Error((Ye==null?void 0:Ye.error)||`HTTP ${Ee.status}`)}z(),f(he?"Assignment archived":"Assignment restored","success")}catch(Ee){l(Ee.message)}}async function Oe(){$(!0);try{await cG(Ue,nt),n(`${r}/projects/${Ue}`)}catch(he){l(he.message),$(!1),T(!1)}}async function We(he,Ee){l(null),g(he.command);try{return await n_(Ue,nt,he,Ee),z(),!0}catch(Ye){return l(Ye.message),!1}finally{g(null)}}function Ge(he){if(s_(he)){k(he);return}We(he)}async function ge(he,Ee){b(null),N(he),C(Ye=>({...Ye,[he]:Ee}));try{const Ye=await fetch(`/api/projects/${Ue}/assignments/${nt}/acceptance-criteria/${he}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({checked:Ee})}),Nt=await Ye.json();if(!Ye.ok)throw new Error(Nt.error||`HTTP ${Ye.status}`);z()}catch(Ye){C(Mt=>{const Nn={...Mt};return delete Nn[he],Nn});const Nt=Ye.message;b(Nt),f(Nt||"Failed to update acceptance criterion","error")}finally{N(null)}}const pe=[...xt.filter(he=>he!==lt).map(he=>({key:`transition-${he.command}`,label:he.label,onSelect:()=>Ge(he),disabled:h===he.command})),...at.filter(he=>he.disabled||he.targetStatus===M.status).map(he=>({key:`transition-${he.command}`,label:he.label,disabled:!0,disabledReason:he.targetStatus===M.status?`Already ${M.status.replace(/_/g," ")}`:he.disabledReason??he.warning??he.description})),...F.statuses.map(he=>({key:`override-${he.id}`,label:`Override → ${he.label}`,onSelect:()=>le(he.id),disabled:he.id===M.status,disabledReason:he.id===M.status?"Already in this status":void 0})),{key:"edit-assignment",label:"Edit assignment source",icon:LL,href:`${r}/projects/${e}/assignments/${t}/edit`},{key:"edit-plan",label:"Edit plan",icon:r4,href:`${r}/projects/${e}/assignments/${t}/plan/edit`},{key:"edit-scratchpad",label:"Edit scratchpad",icon:Bx,href:`${r}/projects/${e}/assignments/${t}/scratchpad/edit`},{key:"append-handoff",label:"Append handoff",icon:Zp,href:`${r}/projects/${e}/assignments/${t}/handoff/edit`},{key:"append-decision",label:"Append decision",icon:UL,href:`${r}/projects/${e}/assignments/${t}/decision-record/edit`},{key:M.archived?"unarchive":"archive",label:M.archived?"Restore assignment":"Archive assignment",icon:M.archived?Qp:Hh,onSelect:()=>xe(!M.archived)},{key:"delete",label:"Delete assignment",icon:bn,destructive:!0,onSelect:()=>T(!0)}],se=(lt==null?void 0:lt.command)==="review";return s.jsxs("div",{className:"space-y-5",children:[s.jsx(Hr,{toast:d,onDismiss:p}),s.jsxs("div",{className:"sticky top-12 z-20 rounded-lg border border-border/60 bg-card/90 p-3 shadow-sm backdrop-blur",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[s.jsx(vn,{status:M.status,progress:He}),M.phase&&M.phase!==M.status&&s.jsxs("span",{className:"rounded-full border border-border/60 px-2 py-0.5 text-[11px] text-muted-foreground",title:"Phase dimension — how far along the work is, independent of blockage",children:["phase: ",M.phase]}),M.disposition&&M.disposition!=="active"&&s.jsx("span",{className:"rounded-full border border-warning-foreground/40 px-2 py-0.5 text-[11px] text-warning-foreground",title:"Disposition dimension — orthogonal to phase",children:M.disposition}),s.jsx(Ea,{type:M.type}),s.jsx("h1",{className:"text-lg font-semibold text-foreground",children:M.title}),s.jsxs("span",{className:"text-xs text-muted-foreground",children:["Updated ",c2(M.updated)]}),Z.length>0&&s.jsxs("span",{className:"text-xs text-warning-foreground",children:["⚠ ",Z.length," unmet dep",Z.length===1?"":"s"]}),s.jsx(Lw,{externalIds:M.externalIds}),s.jsxs("span",{className:"ml-auto flex items-center gap-2",children:[s.jsx(b_,{target:{kind:"assignment",id:M.id},worktreePath:((qe=M.workspace)==null?void 0:qe.worktreePath)??null,repository:((X=M.workspace)==null?void 0:X.repository)??null}),!((ve=M.workspace)!=null&&ve.worktreePath)&&e&&t&&s.jsx(v_,{projectSlug:e,assignmentSlug:t,defaultBranch:`syntaur/${e}/${t}`,onCreated:()=>z()}),lt&&s.jsx("button",{type:"button",title:lt.warning||lt.description,disabled:h===lt.command,onClick:()=>Ge(lt),className:Ce("shell-action disabled:cursor-not-allowed disabled:opacity-50",lt.warning&&"border-warning-foreground/40",se&&_>0&&"send-to-review-glow"),children:s.jsx("span",{children:h===lt.command?"Working…":lt.label})},se?`review-${_}`:lt.command),s.jsx(Aw,{items:pe,align:"end"})]})]}),a?s.jsx("p",{className:"mt-4 rounded-md border border-error-foreground/30 bg-error px-4 py-3 text-sm text-error-foreground",children:a}):null,M.blockedReason?s.jsxs("div",{className:"mt-4 rounded-md border border-warning-foreground/30 bg-warning px-4 py-3 text-sm text-warning-foreground",children:[s.jsx("strong",{children:"Blocked reason:"})," ",M.blockedReason]}):null,M.override&&M.derived&&M.derived.derivedStatus!==M.status?s.jsxs("div",{className:"mt-4 rounded-md border border-warning-foreground/30 bg-warning px-4 py-3 text-sm text-warning-foreground",children:[s.jsxs("strong",{children:["Pinned to ",M.status]})," by ",M.override.source,M.override.reason?s.jsxs(s.Fragment,{children:[" — “",M.override.reason,"”"]}):null," · ","would otherwise be ",s.jsx("strong",{children:M.derived.derivedStatus})]}):null,(Ve=M.derived)!=null&&Ve.nextAction?s.jsxs("p",{className:"mt-3 text-xs text-muted-foreground",children:[s.jsx("span",{className:"font-medium text-foreground",children:"Next:"})," ",M.derived.nextAction]}):null]}),M.derived&&(Object.keys(M.derived.customFacts??{}).length>0||(M.derived.attestations??[]).length>0)?s.jsx(Qe,{title:"Facts",description:"Custom asserted facts and review attestations, materialized server-side.",children:s.jsxs("div",{className:"space-y-3",children:[Object.keys(M.derived.customFacts??{}).length>0&&s.jsx("div",{className:"flex flex-wrap items-center gap-2",children:Object.entries(M.derived.customFacts??{}).map(([he,Ee])=>s.jsxs("span",{className:"rounded-full border border-border/60 px-2 py-0.5 text-[11px] text-muted-foreground",children:[he,": ",s.jsx("span",{className:"font-medium text-foreground",children:String(Ee)})]},he))}),(M.derived.attestations??[]).map(he=>s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsx("span",{className:"text-[11px] font-medium text-foreground",children:he.fact}),s.jsxs("span",{className:"text-[11px] text-muted-foreground",children:["(",he.binds,")"]}),he.records.length===0?s.jsx("span",{className:"text-[11px] text-muted-foreground",children:"— no attestations yet"}):he.records.map(Ee=>s.jsxs("span",{title:`${Ee.verdict}${Ee.note?` — ${Ee.note}`:""}${Ee.stale?" (stale — revision moved)":""} · ${Ee.at}`,className:Ce("rounded-full border px-2 py-0.5 text-[11px]",Ee.stale?"border-border/40 text-muted-foreground line-through":Ee.verdict==="approved"?"border-success-foreground/40 text-success-foreground":"border-warning-foreground/40 text-warning-foreground"),children:[Ee.actor,": ",Ee.verdict==="approved"?"approved":"changes",Ee.stale?" (stale)":""]},Ee.actor))]},he.fact))]})}):null,te.length>0&&s.jsx(DG,{projectSlug:e,dependencies:te,blockedReason:M.blockedReason}),M.enrichedLinks&&M.enrichedLinks.length>0&&s.jsx($G,{links:M.enrichedLinks}),M.referencedBy&&M.referencedBy.length>0&&s.jsx(Qe,{title:"Referenced by",description:"Other assignments whose Todos, progress, comments, or handoffs link to this one.",children:s.jsx("ul",{className:"space-y-2",children:M.referencedBy.map(he=>{const Ee=he.sourceProjectSlug===null?`/assignments/${he.sourceId}`:`${r}/projects/${he.sourceProjectSlug}/assignments/${he.sourceSlug}`;return s.jsxs("li",{className:"flex items-center gap-2 text-sm",children:[s.jsx(Ie,{to:Ee,className:"text-foreground hover:text-primary",children:he.sourceTitle}),s.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",he.mentions," mention",he.mentions===1?"":"s",")"]}),he.sourceProjectSlug===null?s.jsx("span",{className:"rounded bg-muted px-1.5 py-0.5 font-mono text-[10px] uppercase text-muted-foreground",children:"Standalone"}):null]},he.sourceId)})})}),s.jsxs("div",{className:"grid gap-4 lg:grid-cols-[minmax(0,1fr)_280px]",children:[s.jsx("div",{className:"space-y-4",children:s.jsx(_m,{value:I,onValueChange:he=>i({tab:he}),items:[{value:"summary",label:"Summary",content:s.jsxs("div",{className:"space-y-5",children:[Re.acceptanceCriteria.length>0?s.jsx(Qe,{title:"Acceptance Criteria",description:"These checkboxes update the source assignment markdown.",children:s.jsxs("div",{className:"space-y-3",children:[w?s.jsx("p",{className:"rounded-md border border-error-foreground/30 bg-error px-4 py-3 text-sm text-error-foreground",children:w}):null,Re.acceptanceCriteria.map((he,Ee)=>{const Ye=j!==null,Nt=Ee in S?S[Ee]:he.checked;return s.jsxs("label",{className:"flex items-start gap-3 rounded-md border border-border/60 bg-background/80 px-3 py-3",children:[s.jsx("input",{type:"checkbox",checked:Nt,disabled:Ye,onChange:Mt=>ge(Ee,Mt.target.checked),className:"mt-1 h-4 w-4 rounded border-border text-primary"}),s.jsx("span",{className:"criterion-label text-sm leading-6","data-checked":Nt,children:he.text})]},`${Ee}-${he.text}`)})]})}):null,Se.hasSection?s.jsx(Qe,{title:"Todos",description:"Checklist of work items from assignment.md. Links point to plan files.",children:s.jsx(xn,{content:Se.todosMarkdown,emptyState:"No todos yet."})}):null,s.jsx(Qe,{title:"Assignment Summary",children:s.jsx(xn,{content:Se.remaining,emptyState:Re.acceptanceCriteria.length>0||Se.hasSection?"No additional summary markdown beyond the acceptance criteria and todos.":"This assignment does not have summary markdown yet."})})]})},{value:"plan",label:"Plan",count:M.plan?1:0,content:M.plan?s.jsx("div",{className:"space-y-5",children:s.jsxs(Qe,{title:"Plan",description:"Shows plan.md only. Versioned plans (plan-v2.md, ...) linked from the Todos section are not yet rendered here — open them from the filesystem.",actions:s.jsxs(Ie,{className:"shell-action",to:`${r}/projects/${e}/assignments/${t}/plan/edit`,children:[s.jsx(Bx,{className:"h-4 w-4"}),s.jsx("span",{children:"Edit Plan"})]}),children:[s.jsx("div",{className:"mb-4",children:s.jsx(vn,{status:M.plan.status})}),s.jsx(xn,{content:M.plan.body,emptyState:"No plan content yet."})]})}):s.jsx(Tt,{title:"No plan yet",description:"Plan files are optional and versioned. Run /plan-assignment to create plan.md (or plan-v2.md, ...) and link it from the Todos section."})},{value:"scratchpad",label:"Scratchpad",count:M.scratchpad?1:0,content:M.scratchpad?s.jsx(Qe,{title:"Scratchpad",actions:s.jsxs(Ie,{className:"shell-action",to:`${r}/projects/${e}/assignments/${t}/scratchpad/edit`,children:[s.jsx(Bx,{className:"h-4 w-4"}),s.jsx("span",{children:"Edit Scratchpad"})]}),children:s.jsx(xn,{content:M.scratchpad.body,emptyState:"Scratchpad is empty."})}):s.jsx(Tt,{title:"No scratchpad yet",description:"Scratchpad notes appear here when you use the Edit Scratchpad action."})},{value:"handoff",label:"Handoff",count:((ft=M.handoff)==null?void 0:ft.handoffCount)??0,content:s.jsx("div",{className:"space-y-5",children:M.handoff?s.jsx(Qe,{children:s.jsx(xn,{content:M.handoff.body,emptyState:"No handoff history yet."})}):s.jsx(Tt,{title:"No handoff log yet",description:"Handoffs appear here when an agent runs /complete-assignment or you append one manually."})})},{value:"progress",label:"Progress",count:((et=M.progress)==null?void 0:et.entryCount)??0,content:s.jsx("div",{className:"space-y-5",children:M.progress&&M.progress.entries.length>0?s.jsx(Qe,{title:"Progress",description:"Reverse-chronological log of work done on this assignment. Agents append entries via progress.md.",children:s.jsx("ol",{className:"space-y-4",children:M.progress.entries.map((he,Ee)=>s.jsxs("li",{className:"border-l-2 border-border pl-3",children:[s.jsx("div",{className:"text-xs font-mono text-muted-foreground",children:he.timestamp}),s.jsx(xn,{content:he.body})]},`${he.timestamp}-${Ee}`))})}):s.jsx(Tt,{title:"No progress entries yet",description:"Progress entries appear here as the agent appends them to progress.md."})})},{value:"comments",label:"Comments",count:((yt=M.comments)==null?void 0:yt.entryCount)??0,content:s.jsx("div",{className:"space-y-5",children:M.comments&&M.comments.entries.length>0?s.jsx(w_,{projectSlug:e,assignmentSlug:t,entries:M.comments.entries}):s.jsx(Tt,{title:"No comments yet",description:"Comments appear here when agents or humans post via `syntaur comment` or the dashboard."})})},{value:"decisions",label:"Decisions",count:((mt=M.decisionRecord)==null?void 0:mt.decisionCount)??0,content:s.jsx("div",{className:"space-y-5",children:M.decisionRecord?s.jsx(Qe,{children:s.jsx(xn,{content:M.decisionRecord.body,emptyState:"No decision history yet."})}):s.jsx(Tt,{title:"No decision record yet",description:"Decision records appear here when you append one via the Append Decision action."})})}]})}),s.jsxs("div",{className:"min-w-0 space-y-5",children:[s.jsx(Qe,{title:"Details",children:s.jsxs("dl",{className:"space-y-3 text-sm",children:[s.jsx(li,{label:"ID",value:M.id,copyable:!0}),s.jsx(li,{label:"Priority",value:M.priority}),M.assignee&&s.jsx(li,{label:"Assignee",value:M.assignee}),s.jsx(li,{label:"Updated",value:`${l2(M.updated)} · Created ${a2(M.created)}`}),M.workspace.repository&&s.jsx(li,{label:"Repository",value:M.workspace.repository,copyable:!0}),M.workspace.worktreePath&&s.jsx(li,{label:"Worktree",value:M.workspace.worktreePath,copyable:!0}),M.workspace.branch&&s.jsx(li,{label:"Branch",value:M.workspace.branch,copyable:!0}),M.workspace.parentBranch&&s.jsx(li,{label:"Parent branch",value:M.workspace.parentBranch,copyable:!0}),M.externalIds.map((he,Ee)=>s.jsx(OG,{entry:he},`${he.system}:${he.id}:${Ee}`))]})}),ot.length>0&&s.jsx(Qe,{title:"Servers",children:s.jsx("div",{className:"space-y-2",children:ot.map((he,Ee)=>s.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-2 text-sm",children:[s.jsx("span",{className:"min-w-0 max-w-full truncate rounded bg-muted/60 px-1.5 py-0.5 font-mono text-xs",title:he.command,children:he.command}),s.jsx("span",{className:"min-w-0 max-w-full truncate text-xs text-muted-foreground",title:he.sessionName,children:he.sessionName}),he.urls.map(Ye=>s.jsxs("a",{href:Ye,target:"_blank",rel:"noopener noreferrer",title:Ye,className:"inline-flex min-w-0 max-w-full items-center gap-1 rounded border border-primary/30 bg-primary/5 px-1.5 py-0.5 text-xs font-medium text-primary hover:bg-primary/10 dark:border-primary/40 dark:bg-primary/10 dark:hover:bg-primary/20",children:[s.jsx("span",{className:"min-w-0 truncate",children:Ye.replace("http://localhost:",":")}),s.jsx(uc,{className:"h-2.5 w-2.5 shrink-0"})]},Ye))]},Ee))})}),s.jsx(a_,{sessions:K==null?void 0:K.sessions,loading:O,error:B,onError:he=>f(he.message,"error"),onNotice:he=>f(he,"success")}),s.jsx(l_,{summary:G==null?void 0:G.summary,loading:H,error:Q})]})]}),s.jsx(c_,{open:y!==null,action:y,assignmentTitle:M.title,loading:h===(y==null?void 0:y.command),onOpenChange:he=>{he||k(null)},onConfirm:async he=>{if(!y)return;await We(y,he)&&k(null)}}),s.jsx(Ri,{open:D,title:"Delete assignment?",description:`This will permanently delete "${M.title}" and all its files (plan, scratchpad, handoff, decision record). This cannot be undone.`,confirmLabel:"Delete Assignment",destructive:!0,loading:R,onOpenChange:he=>{he||T(!1)},onConfirm:Oe})]})}function li({label:e,value:t,copyable:n}){return s.jsxs("div",{className:"flex items-start justify-between gap-3",children:[s.jsx("dt",{className:"text-muted-foreground",children:e}),s.jsxs("dd",{className:"flex items-center gap-1.5 max-w-[60%] text-right text-foreground break-all",children:[s.jsx("span",{className:"block min-w-0 truncate",title:t,children:t}),n&&t!=="—"&&s.jsx(Zr,{value:t})]})]})}function OG({entry:e}){const t=e.url!=null&&e.url.length>0;return s.jsxs("div",{className:"flex items-start justify-between gap-3",children:[s.jsx("dt",{className:"text-muted-foreground",children:e.system}),s.jsx("dd",{className:"flex items-center gap-1.5 max-w-[60%] text-right text-foreground break-all",children:t?s.jsxs("a",{href:e.url??void 0,target:"_blank",rel:"noopener noreferrer","aria-label":`Open ${e.system}:${e.id} in ${e.system}`,className:"flex items-center gap-1.5 min-w-0 text-primary hover:underline",children:[s.jsx("span",{className:"truncate min-w-0",title:e.id,children:e.id}),s.jsx(uc,{className:"h-2.5 w-2.5 shrink-0"})]}):s.jsx("span",{className:"truncate min-w-0",title:e.id,children:e.id})})]})}function FG(){var T,R,$,_,U,I,F,M;const{id:e}=Vt(),[t,n]=Ns(),r=t.get("tab")??"summary",{data:o,loading:i,error:a,refetch:l}=hO(e),{data:d,loading:f,error:p}=gO(e),{data:h,loading:g,error:y}=yO(o==null?void 0:o.slug),[k,w]=m.useState(!1),[b,j]=m.useState(null),{toast:N,showToast:S,dismissToast:C}=wr();async function D(A){if(e){j(null);try{const L=await fetch(`/api/assignments/${e}/${A?"archive":"unarchive"}`,{method:"POST",headers:{"Content-Type":"application/json"}});if(!L.ok){const z=await L.json().catch(()=>null);throw new Error((z==null?void 0:z.error)||`HTTP ${L.status}`)}l(),S(A?"Assignment archived":"Assignment restored","success")}catch(L){j(L instanceof Error?L.message:"Archive failed")}}}return i?s.jsx(jt,{}):a?s.jsx(Rt,{error:a}):o?s.jsxs("div",{className:"space-y-6",children:[s.jsx(Hr,{toast:N,onDismiss:C}),s.jsxs("header",{className:"space-y-2",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[s.jsx(vn,{status:o.status}),s.jsx(Ea,{type:o.type}),s.jsx("span",{className:"text-xs font-mono text-muted-foreground",children:o.id}),s.jsx(Lw,{externalIds:o.externalIds}),s.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[s.jsx(b_,{target:{kind:"assignment",id:o.id},worktreePath:((T=o.workspace)==null?void 0:T.worktreePath)??null,repository:((R=o.workspace)==null?void 0:R.repository)??null,size:"compact"}),!(($=o.workspace)!=null&&$.worktreePath)&&s.jsx(v_,{assignmentId:o.id,defaultBranch:`syntaur/${o.slug}`,onCreated:()=>l()}),s.jsxs("button",{type:"button",onClick:()=>w(!0),className:"inline-flex items-center gap-1.5 rounded border border-border px-2 py-1 text-xs text-muted-foreground hover:border-foreground/40 hover:text-foreground",children:[s.jsx(Vh,{className:"h-3 w-3"}),"Move to workspace…"]}),s.jsx(Ie,{to:`/assignments/${o.id}/edit`,className:"rounded border border-border px-2 py-1 text-xs text-muted-foreground hover:border-foreground/40 hover:text-foreground",children:"Edit"}),s.jsxs("button",{type:"button",onClick:()=>D(!o.archived),className:"inline-flex items-center gap-1.5 rounded border border-border px-2 py-1 text-xs text-muted-foreground hover:border-foreground/40 hover:text-foreground",title:o.archived?"Restore this assignment":"Archive this assignment",children:[o.archived?s.jsx(Qp,{className:"h-3 w-3"}):s.jsx(Hh,{className:"h-3 w-3"}),o.archived?"Restore":"Archive"]})]})]}),s.jsx("h1",{className:"text-2xl font-semibold text-foreground",children:o.title}),o.blockedReason?s.jsxs("p",{className:"text-sm text-warning-foreground",children:["Blocked: ",o.blockedReason]}):null,b?s.jsx("p",{className:"text-sm text-status-failed-foreground",children:b}):null]}),o.referencedBy&&o.referencedBy.length>0?s.jsx(Qe,{title:"Referenced by",description:"Other assignments whose bodies link to this one.",children:s.jsx("ul",{className:"space-y-2",children:o.referencedBy.map(A=>s.jsxs("li",{className:"flex items-center gap-2 text-sm",children:[s.jsx(Ie,{to:A.sourceProjectSlug===null?`/assignments/${A.sourceId}`:`/projects/${A.sourceProjectSlug}/assignments/${A.sourceSlug}`,className:"text-foreground hover:text-primary",children:A.sourceTitle}),s.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",A.mentions," mention",A.mentions===1?"":"s",")"]})]},A.sourceId))})}):null,s.jsxs("div",{className:"grid gap-4 lg:grid-cols-[minmax(0,1fr)_280px]",children:[s.jsx("div",{className:"space-y-4",children:s.jsx(_m,{value:r,onValueChange:A=>n({tab:A}),items:[{value:"summary",label:"Summary",content:s.jsx("div",{className:"space-y-5",children:s.jsx(Qe,{title:"Assignment",children:s.jsx(xn,{content:o.body,emptyState:"This assignment does not have summary markdown yet."})})})},{value:"progress",label:"Progress",count:((_=o.progress)==null?void 0:_.entryCount)??0,content:s.jsx("div",{className:"space-y-5",children:o.progress&&o.progress.entries.length>0?s.jsx(Qe,{title:"Progress",description:"Reverse-chronological log of work done on this assignment.",children:s.jsx("ol",{className:"space-y-4",children:o.progress.entries.map((A,L)=>s.jsxs("li",{className:"border-l-2 border-border pl-3",children:[s.jsx("div",{className:"text-xs font-mono text-muted-foreground",children:A.timestamp}),s.jsx(xn,{content:A.body})]},`${A.timestamp}-${L}`))})}):s.jsx(Tt,{title:"No progress entries yet",description:"Progress entries appear here as the agent appends them to progress.md."})})},{value:"comments",label:"Comments",count:((U=o.comments)==null?void 0:U.entryCount)??0,content:s.jsx("div",{className:"space-y-5",children:s.jsx(w_,{projectSlug:null,assignmentSlug:o.id,entries:((I=o.comments)==null?void 0:I.entries)??[]})})},{value:"plan",label:"Plan",content:s.jsx("div",{className:"space-y-5",children:o.plan?s.jsxs(Qe,{children:[s.jsx(xn,{content:o.plan.body,emptyState:"Plan file exists but is empty."}),s.jsx("div",{className:"mt-3 flex justify-end",children:s.jsx(Ie,{to:`/assignments/${o.id}/plan/edit`,className:"rounded border border-border px-2 py-1 text-xs text-muted-foreground hover:border-foreground/40 hover:text-foreground",children:"Edit plan"})})]}):s.jsx(Tt,{title:"No plan file yet",description:"Create one via the CLI or `/plan-assignment`."})})},{value:"scratchpad",label:"Scratchpad",content:s.jsx("div",{className:"space-y-5",children:o.scratchpad?s.jsxs(Qe,{children:[s.jsx(xn,{content:o.scratchpad.body,emptyState:"Scratchpad is empty."}),s.jsx("div",{className:"mt-3 flex justify-end",children:s.jsx(Ie,{to:`/assignments/${o.id}/scratchpad/edit`,className:"rounded border border-border px-2 py-1 text-xs text-muted-foreground hover:border-foreground/40 hover:text-foreground",children:"Edit scratchpad"})})]}):s.jsx(Tt,{title:"No scratchpad yet",description:"Scratchpad is scaffolded at assignment creation time."})})},{value:"handoff",label:"Handoff",count:((F=o.handoff)==null?void 0:F.handoffCount)??0,content:s.jsx("div",{className:"space-y-5",children:o.handoff?s.jsxs(Qe,{children:[s.jsx(xn,{content:o.handoff.body,emptyState:"No handoff history yet."}),s.jsx("div",{className:"mt-3 flex justify-end",children:s.jsx(Ie,{to:`/assignments/${o.id}/handoff/edit`,className:"rounded border border-border px-2 py-1 text-xs text-muted-foreground hover:border-foreground/40 hover:text-foreground",children:"Append handoff"})})]}):s.jsx(Tt,{title:"No handoff log yet",description:"Handoffs appear here when an agent appends one."})})},{value:"decisions",label:"Decisions",count:((M=o.decisionRecord)==null?void 0:M.decisionCount)??0,content:s.jsx("div",{className:"space-y-5",children:o.decisionRecord?s.jsxs(Qe,{children:[s.jsx(xn,{content:o.decisionRecord.body,emptyState:"No decision history yet."}),s.jsx("div",{className:"mt-3 flex justify-end",children:s.jsx(Ie,{to:`/assignments/${o.id}/decision-record/edit`,className:"rounded border border-border px-2 py-1 text-xs text-muted-foreground hover:border-foreground/40 hover:text-foreground",children:"Append decision"})})]}):s.jsx(Tt,{title:"No decision record yet",description:"Decision records appear here once appended."})})}]})}),s.jsxs("div",{className:"min-w-0 space-y-5",children:[s.jsx(Qe,{title:"Details",children:s.jsxs("dl",{className:"space-y-3 text-sm",children:[s.jsx(ci,{label:"ID",value:o.id,copyable:!0}),s.jsx(ci,{label:"Priority",value:o.priority}),o.assignee&&s.jsx(ci,{label:"Assignee",value:o.assignee}),s.jsx(ci,{label:"Updated",value:`${l2(o.updated)} · Created ${a2(o.created)}`}),o.workspace.repository&&s.jsx(ci,{label:"Repository",value:o.workspace.repository,copyable:!0}),o.workspace.worktreePath&&s.jsx(ci,{label:"Worktree",value:o.workspace.worktreePath,copyable:!0}),o.workspace.branch&&s.jsx(ci,{label:"Branch",value:o.workspace.branch,copyable:!0}),o.workspace.parentBranch&&s.jsx(ci,{label:"Parent branch",value:o.workspace.parentBranch,copyable:!0}),o.externalIds.map((A,L)=>s.jsx(zG,{entry:A},`${A.system}:${A.id}:${L}`))]})}),s.jsx(a_,{sessions:d==null?void 0:d.sessions,loading:f,error:p,onError:A=>S(A.message,"error"),onNotice:A=>S(A,"success")}),s.jsx(l_,{summary:h==null?void 0:h.summary,loading:g,error:y})]})]}),s.jsx(Mw,{open:k,onOpenChange:w,currentWorkspace:o.projectWorkspace,title:"Move assignment to workspace",description:"Standalone assignments belong to a project-workspace via the workspaceGroup frontmatter field.",onSubmit:async A=>{const L=await fetch(`/api/assignments/${encodeURIComponent(o.id)}/move-workspace`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({workspaceGroup:A})});if(!L.ok){const z=await L.json().catch(()=>({}));throw new Error(z.error||"Failed to move assignment")}l()}})]}):s.jsx(Rt,{error:"Assignment not found"})}function ci({label:e,value:t,copyable:n}){return s.jsxs("div",{className:"flex items-start justify-between gap-3",children:[s.jsx("dt",{className:"text-muted-foreground",children:e}),s.jsxs("dd",{className:"flex items-center gap-1.5 max-w-[60%] text-right text-foreground break-all",children:[s.jsx("span",{className:"truncate",title:t,children:t}),n&&t!=="—"&&s.jsx(Zr,{value:t})]})]})}function zG({entry:e}){const t=e.url!=null&&e.url.length>0;return s.jsxs("div",{className:"flex items-start justify-between gap-3",children:[s.jsx("dt",{className:"text-muted-foreground",children:e.system}),s.jsx("dd",{className:"flex items-center gap-1.5 max-w-[60%] text-right text-foreground break-all",children:t?s.jsxs("a",{href:e.url??void 0,target:"_blank",rel:"noopener noreferrer","aria-label":`Open ${e.system}:${e.id} in ${e.system}`,className:"flex items-center gap-1.5 min-w-0 text-primary hover:underline",children:[s.jsx("span",{className:"truncate min-w-0",title:e.id,children:e.id}),s.jsx(uc,{className:"h-2.5 w-2.5 shrink-0"})]}):s.jsx("span",{className:"truncate min-w-0",title:e.id,children:e.id})})]})}function BG({currentStatus:e,availableTransitions:t,onSelect:n,overrideTargets:r,onOverride:o,disabled:i=!1,className:a}){const[l,d]=m.useState(!1),[f,p]=m.useState(null),[h,g]=m.useState(0),y=m.useRef(null),k=m.useRef(null),w=m.useId(),b=Es(),j=id(b.statuses,e),N=Mb(e),S=r??[],C=t.length+S.length,D=m.useCallback(I=>{d(!1),I&&requestAnimationFrame(()=>{var F;(F=y.current)==null||F.focus()})},[]),T=m.useCallback(()=>{var F;const I=(F=y.current)==null?void 0:F.getBoundingClientRect();I&&p({top:I.top,left:I.left,width:I.width,bottom:I.bottom})},[]);m.useLayoutEffect(()=>{l&&T()},[l,T]),m.useEffect(()=>{if(!l)return;const I=()=>T();return window.addEventListener("scroll",I,!0),window.addEventListener("resize",I),()=>{window.removeEventListener("scroll",I,!0),window.removeEventListener("resize",I)}},[l,T]),m.useEffect(()=>{if(!l)return;const I=F=>{var A,L;const M=F.target;M&&((A=k.current)!=null&&A.contains(M)||(L=y.current)!=null&&L.contains(M)||D(!1))};return document.addEventListener("mousedown",I),()=>document.removeEventListener("mousedown",I)},[l,D]),m.useEffect(()=>{l&&g(0)},[l,C]);function R(I){return!I.disabled&&I.id!==e}function $(I){if(I<t.length){const M=t[I];M&&(n(M),D(!0));return}const F=S[I-t.length];F&&R(F)&&(o==null||o(F.id),D(!0))}function _(I){(I.key==="Enter"||I.key===" "||I.key==="ArrowDown")&&(I.preventDefault(),d(!0))}function U(I){if(C===0){I.key==="Escape"&&(I.preventDefault(),D(!0));return}I.key==="ArrowDown"?(I.preventDefault(),g(F=>(F+1)%C)):I.key==="ArrowUp"?(I.preventDefault(),g(F=>(F-1+C)%C)):I.key==="Home"?(I.preventDefault(),g(0)):I.key==="End"?(I.preventDefault(),g(C-1)):I.key==="Enter"?(I.preventDefault(),$(h)):I.key==="Escape"&&(I.preventDefault(),D(!0))}return s.jsxs(s.Fragment,{children:[s.jsxs("button",{ref:y,type:"button","data-no-drag":!0,disabled:i,"aria-haspopup":"menu","aria-expanded":l,"aria-controls":l?w:void 0,onClick:()=>{i||d(I=>!I)},onKeyDown:_,title:`Status: ${j.label}. Click to change.`,style:j.style,className:Ce(NA,j.className,a,"cursor-pointer transition hover:brightness-95 focus:outline-none focus-visible:ring-2 focus-visible:ring-ring/40",i&&"cursor-not-allowed opacity-60"),children:[s.jsx(N,{className:"h-3.5 w-3.5 shrink-0"}),s.jsx("span",{className:"min-w-0 truncate",children:j.label})]}),l&&f&&typeof document<"u"?vo.createPortal(s.jsx("div",{ref:k,id:w,role:"menu",tabIndex:-1,autoFocus:!0,onKeyDown:U,style:{position:"fixed",top:f.bottom+6,left:f.left,minWidth:Math.max(f.width,180),zIndex:60},className:"rounded-md border border-border/70 bg-popover py-1 text-sm text-popover-foreground shadow-lg",children:C===0?s.jsx("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:"No status changes available from this status."}):s.jsxs(s.Fragment,{children:[t.map((I,F)=>{const M=Mb(I.targetStatus),A=F===h;return s.jsxs("button",{type:"button",role:"menuitem","data-no-drag":!0,onMouseEnter:()=>g(F),onClick:()=>$(F),title:I.warning||I.description,className:Ce("flex w-full flex-col items-stretch gap-0.5 px-3 py-1.5 text-left text-sm transition",A?"bg-foreground/5":"hover:bg-foreground/5"),children:[s.jsxs("span",{className:"flex items-center justify-between gap-2",children:[s.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[s.jsx(M,{className:"h-3.5 w-3.5 flex-shrink-0 text-muted-foreground"}),s.jsx("span",{className:"truncate",children:I.label})]}),s.jsx("span",{className:"text-[10px] uppercase tracking-wide text-muted-foreground",children:So(b,I.targetStatus)})]}),I.warning?s.jsx("span",{className:"text-[11px] leading-snug text-warning-foreground",children:I.warning}):null]},`${I.command}:${I.targetStatus}`)}),S.length>0&&t.length>0?s.jsx("div",{className:"my-1 border-t border-border/60",role:"separator"}):null,S.map((I,F)=>{const M=t.length+F,A=M===h,L=!R(I),z=id(b.statuses,I.id);return s.jsx("button",{type:"button",role:"menuitem","data-no-drag":!0,disabled:L,onMouseEnter:()=>g(M),onClick:()=>$(M),title:L?I.disabledReason??(I.id===e?"Already in this status":void 0):`Set status to ${I.label}`,className:Ce("flex w-full items-center justify-between gap-2 px-3 py-1.5 text-left text-sm transition",L?"cursor-not-allowed text-muted-foreground/60":A?"bg-foreground/5":"hover:bg-foreground/5"),children:s.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[s.jsx("span",{"aria-hidden":"true",className:Ce("h-2.5 w-2.5 flex-shrink-0 rounded-full border border-border/40",z.style?void 0:z.className),style:z.style?{backgroundColor:z.style.color}:void 0}),s.jsxs("span",{className:"truncate",children:["Override → ",I.label]})]})},`override-${I.id}`)})]})}),document.body):null]})}function k_({title:e,detailHref:t,onSave:n,disabled:r=!1}){const[o,i]=m.useState(!1);return o?s.jsx(UG,{initialTitle:e,disabled:r,onSave:n,onExit:()=>i(!1)}):s.jsxs("div",{className:"group flex items-baseline gap-1.5",children:[s.jsx("button",{type:"button","data-no-drag":!0,disabled:r,onClick:()=>{r||i(!0)},className:Ce("text-left text-base font-semibold text-foreground transition hover:text-primary focus:outline-none focus-visible:ring-2 focus-visible:ring-ring/40 rounded-sm",r&&"cursor-not-allowed opacity-60"),title:"Click to rename",children:e}),s.jsx(Ie,{to:t,"data-no-drag":!0,"aria-label":"Open detail page",title:"Open detail page",onClick:a=>a.stopPropagation(),className:"text-muted-foreground opacity-0 transition group-hover:opacity-100 focus:opacity-100 focus:outline-none focus-visible:ring-2 focus-visible:ring-ring/40 rounded-sm",children:s.jsx(uc,{className:"h-3.5 w-3.5"})})]})}function UG({initialTitle:e,disabled:t,onSave:n,onExit:r}){const o=m.useRef(e),[i,a]=m.useState(e),[l,d]=m.useState(!1),[f,p]=m.useState(!1),h=m.useRef(null),g=m.useRef(!1);m.useEffect(()=>{const b=h.current;b&&(b.focus(),b.select())},[]);const y=m.useCallback(()=>{var b;p(!0),window.setTimeout(()=>p(!1),260),(b=h.current)==null||b.focus()},[]),k=m.useCallback(async()=>{if(g.current)return;const b=i.trim();if(b.length===0){y();return}if(b===o.current){r();return}g.current=!0,d(!0);try{await n(b)}catch{}finally{d(!1),r()}},[i,r,n,y]);function w(b){b.key==="Enter"?(b.preventDefault(),k()):b.key==="Escape"&&(b.preventDefault(),g.current=!0,r())}return s.jsx("input",{ref:h,type:"text","data-no-drag":!0,disabled:t||l,value:i,onChange:b=>a(b.target.value),onKeyDown:w,onBlur:()=>void k(),className:Ce("w-full rounded-sm border border-border bg-background px-1.5 py-0.5 text-base font-semibold text-foreground outline-none transition focus:border-ring focus:ring-1 focus:ring-ring",f&&"syntaur-input-shake",l&&"opacity-70")})}function S_(e){const t=Ht(),n=m.useRef(null),r=m.useRef(!1),o=m.useCallback(()=>{const a=n.current,l=!!(a!=null&&a.querySelector('[aria-expanded="true"]')),d=!!document.querySelector('[role="menu"]'),f=document.activeElement,p=!!(f&&(a!=null&&a.contains(f))&&(f.tagName==="INPUT"||f.tagName==="TEXTAREA"));r.current=l||d||p},[]),i=m.useCallback(a=>{if(r.current)return;const l=a.target;!l||l.closest(Ql)||t(e)},[t,e]);return{containerRef:n,onMouseDown:o,onClick:i}}const AN=/[A-Za-z0-9_-]/;function PN(e,t){const n=Math.max(0,Math.min(t,e.length)),r=HG(e,n);if(r)return r;let o=n;for(;o>0&&AN.test(e[o-1]);)o--;let i=n;for(;i<e.length&&AN.test(e[i]);)i++;const a=e.slice(o,n),l=e.slice(0,o),d=l.match(/([A-Za-z_][A-Za-z0-9_-]*)\s*(:|>=|<=|!=|=|>|<)\s*$/);if(d)return{kind:"value",field:d[1].toLowerCase(),partial:a,tokenStart:o,tokenEnd:i};const f=l.match(/([A-Za-z_][A-Za-z0-9_-]*)\s*:\s*\([^)]*,\s*$/);return f?{kind:"value",field:f[1].toLowerCase(),partial:a,tokenStart:o,tokenEnd:i}:{kind:"field",partial:a,tokenStart:o,tokenEnd:i}}function HG(e,t){let n=-1;for(let d=t-1;d>=0;d--)if(e[d]==='"'&&(d===0||e[d-1]!=="\\")){n=d;break}if(n<0)return null;for(let d=n+1;d<t;d++)if(e[d]==='"'&&e[d-1]!=="\\")return null;let r=t;for(;r<e.length&&!(e[r]==='"'&&e[r-1]!=="\\");)r++;const o=e.slice(n+1,t),a=e.slice(0,n).match(/([A-Za-z_][A-Za-z0-9_-]*)\s*(:|>=|<=|!=|=|>|<)\s*$/);return{kind:"value",field:a?a[1].toLowerCase():"",partial:o,tokenStart:n,tokenEnd:r<e.length?r+1:r}}function VG(e,t){const n=xA(t),r=e.toLowerCase();if(r==="")return n;const o=[],i=[];for(const a of n){const l=a.toLowerCase();l.startsWith(r)?o.push(a):l.includes(r)&&i.push(a)}return[...o,...i]}function WG(e,t,n,r){const o=e.toLowerCase();let i=[];switch(o){case"status":i=[...n.statuses];break;case"priority":i=[...n.priorities];break;case"type":i=[...n.types];break;case"assignee":i=["none",...n.assignees];break;case"project":i=["none",...n.projects];break;case"tag":case"tags":i=[...n.tags];break;case"archived":case"pinned":case"blocked":case"parked":i=["true","false"];break;default:{const l=r[o];(l==null?void 0:l.kind)==="bool"&&(i=["true","false"]);break}}if(!i.length)return[];const a=t.toLowerCase();return a===""?i:i.filter(l=>l.toLowerCase().startsWith(a))}function qG(e,t,n){let r;return t.kind==="field"?r=`${n}:`:r=ow(n),{text:e.slice(0,t.tokenStart)+r+e.slice(t.tokenEnd),caret:t.tokenStart+r.length}}const KG=180;function GG(e,t){const[n,r]=m.useState(e);return m.useEffect(()=>{const o=setTimeout(()=>r(e),t);return()=>clearTimeout(o)},[e,t]),n}function YG({value:e,onChange:t,onCompiled:n,registry:r,declarations:o,valueSources:i,placeholder:a="AQL query (e.g. status:active AND priority:high)",className:l}){const d=m.useRef(null),f=m.useRef(null),p=GG(e,KG),[h,g]=m.useState([]),[y,k]=m.useState([]),[w,b]=m.useState("field"),[j,N]=m.useState(-1),[S,C]=m.useState(!1),D=m.useRef(e.length);m.useEffect(()=>{if(p.trim()===""){g([]),n==null||n(null);return}const A=Kl(p,r);A.errors.length>0?(g(A.errors),n==null||n(null)):(g([]),n==null||n(A.query))},[p,r,n]);const T=m.useCallback((A,L)=>{const z=PN(A,L);if(!z){k([]),C(!1);return}if(z.kind==="field"){const W=VG(z.partial,o);k(W),b("field"),C(W.length>0)}else{const W=WG(z.field,z.partial,i,r);k(W),b("value"),C(W.length>0)}N(-1)},[o,i,r]),R=m.useCallback(A=>{const L=A.target.value,z=A.target.selectionStart??L.length;D.current=z,t(L),T(L,z)},[t,T]),$=m.useCallback(A=>{const L=d.current,z=(L==null?void 0:L.selectionStart)??D.current,W=PN(e,z);if(!W)return;const{text:V,caret:K}=qG(e,W,A);t(V),C(!1),k([]),requestAnimationFrame(()=>{d.current&&(d.current.focus(),d.current.setSelectionRange(K,K),D.current=K)})},[e,t]),_=m.useCallback(A=>{if(!(!S||y.length===0))switch(A.key){case"ArrowDown":A.preventDefault(),N(L=>Math.min(L+1,y.length-1));break;case"ArrowUp":A.preventDefault(),N(L=>Math.max(L-1,-1));break;case"Enter":case"Tab":j>=0&&(A.preventDefault(),$(y[j]));break;case"Escape":C(!1),k([]);break}},[S,y,j,$]),U=m.useRef(null),I=m.useCallback(()=>{U.current=setTimeout(()=>C(!1),120)},[]);m.useEffect(()=>()=>{U.current!==null&&clearTimeout(U.current)},[]);const F=m.useCallback(()=>{var L;const A=((L=d.current)==null?void 0:L.selectionStart)??e.length;T(e,A)},[e,T]);m.useEffect(()=>{var A,L;S&&((L=(A=f.current)==null?void 0:A.querySelector('[aria-selected="true"]'))==null||L.scrollIntoView({block:"nearest"}))},[j,S]);const M=h.length>0&&p.trim()!=="";return s.jsxs("div",{className:`relative flex flex-col gap-1 ${l??""}`,children:[s.jsx("input",{ref:d,type:"text",value:e,onChange:R,onKeyDown:_,onBlur:I,onFocus:F,placeholder:a,"aria-label":"AQL query input","aria-expanded":S,"aria-haspopup":"listbox","aria-autocomplete":"list",autoComplete:"off",spellCheck:!1,className:["h-9 w-full rounded-md border bg-background px-3 py-1.5 font-mono text-sm text-foreground outline-none transition",M?"border-destructive focus:border-destructive focus:ring-2 focus:ring-destructive/30":"border-border/60 focus:border-primary focus:ring-2 focus:ring-ring/30"].join(" ")}),S&&y.length>0&&s.jsx("ul",{ref:f,role:"listbox","aria-label":w==="field"?"Field suggestions":"Value suggestions",className:"absolute top-full z-50 mt-1 max-h-56 w-full overflow-y-auto rounded-md border border-border bg-popover py-1 shadow-md",children:y.map((A,L)=>s.jsx("li",{role:"option","aria-selected":L===j,onMouseDown:z=>{z.preventDefault(),$(A)},className:["cursor-pointer px-3 py-1.5 font-mono text-sm",L===j?"bg-accent text-accent-foreground":"text-foreground hover:bg-accent/50"].join(" "),children:A},A))}),M&&s.jsx("ul",{className:"space-y-0.5",role:"status","aria-live":"polite",children:h.map((A,L)=>s.jsxs("li",{className:"font-mono text-xs text-destructive",children:["at ",A.pos,": ",A.message]},L))})]})}const _N=sw;function pp(e){return e==="1"?"stale":e==="0"?"fresh":"all"}function XG(e,t){return e.toString()===t.toString()}function DN(){const{workspace:e}=Vt(),t=pn(),n=Ht(),r=m.useRef(null);Ei("list:assignments");const{data:o,loading:i,error:a,refetch:l}=Yh(),d=Es(),f=Rd(),[p,h]=Ns(),g=e?`w:${e}`:null,y=YP(g),k=m.useRef(void 0),w=m.useMemo(()=>IA(d.order),[d]),b=m.useMemo(()=>{const Y={};for(const ee of w)Y[ee]=So(d,ee);return Y},[w,d]),j=m.useMemo(()=>w.map(Y=>({id:Y,title:b[Y]??Y,description:Fd(Y)})),[w,b]),N=m.useMemo(()=>f.definitions.map(Y=>({id:Y.id,title:$l(f,Y.id),description:Y.description})),[f]),S="__unknown_type__",C=m.useMemo(()=>new Set(["all",...w]),[w]),D=p.get("view"),T=p.get("status"),R=p.get("stale"),$=D&&_N.includes(D)?D:"kanban";function _(Y){if(!Y)return[];const ee=[];for(const be of Y.split(",")){const Be=be.trim();!Be||Be==="all"||!C.has(Be)||ee.includes(Be)||ee.push(Be)}return ee}const U=m.useCallback(Y=>{h(ee=>{const be=new URLSearchParams(ee);return Y==="kanban"?be.delete("view"):be.set("view",Y),be})},[h]),[I,F]=m.useState(""),[M,A]=m.useState(()=>_(T)),[L,z]=m.useState(()=>Ke(y.filters.priority)),[W,V]=m.useState(()=>Ke(y.filters.type)),[K,O]=m.useState(()=>Ke(y.filters.assignee)),[B,G]=m.useState(()=>Ke(y.filters.project)),[H,Q]=m.useState(()=>Ke(y.filters.tags)),[te,Z]=m.useState(null),[ae,ne]=m.useState(()=>pp(R)),[ue,ye]=m.useState(()=>Du({status:_(T),priority:Ke(y.filters.priority),type:Ke(y.filters.type),assignee:Ke(y.filters.assignee),project:Ke(y.filters.project),tags:Ke(y.filters.tags),activity:pp(R)})),[Ne,Re]=m.useState(()=>y.sortField),[Se,ze]=m.useState(()=>y.sortDirection),[oe,we]=m.useState(()=>({hidden:[]})),[ke,$e]=m.useState(()=>({hidden:[]})),[Ue,nt]=m.useState(()=>y.grouping),He=Ue==="type"?"type":"status",[at,xt]=m.useState(()=>new Set),[lt,ot]=m.useState([]),{toast:le,showToast:xe,dismissToast:Oe}=wr(),[We,Ge]=m.useState(null),[ge,pe]=m.useState(null),[se,je]=m.useState(null),[Ae,qe]=m.useState(null),[X,ve]=m.useState(null),[Ve,ft]=m.useState(null),[et,yt]=m.useState(null),[mt,he]=m.useState(null),[Ee,Ye]=m.useState(null),[Nt,Mt]=m.useState(!1),[Nn,Ct]=m.useState(!1),Cn=e?{kind:"workspace",workspace:e}:{kind:"global"},Ft=p.get("loadView"),{view:En,loading:en,error:ce}=wi(Ft),{view:Te,loading:st,error:Tn}=wi(Ee),kr=m.useRef(null);m.useEffect(()=>{ot((o==null?void 0:o.assignments)??[])},[o]),m.useEffect(()=>{Ee&&!st&&!Tn&&!Te&&Ye(null)},[Te,Tn,Ee,st]),m.useEffect(()=>{Ye(null),kr.current=null,Z(null),F("")},[e]);const no=m.useRef({status:T,stale:R});m.useEffect(()=>{const Y=_(T),ee=pp(R);c6(Y,M)||A(Y),ee!==ae&&ne(ee);const be=no.current,Be=be.status!==T||be.stale!==R;no.current={status:T,stale:R},Be&&tn({status:Y,activity:ee})},[ae,R,M,T]),m.useEffect(()=>{k.current===g&&h(Y=>{const ee=new URLSearchParams(Y);return M.length===0?ee.delete("status"):ee.set("status",M.join(",")),ae==="all"?ee.delete("stale"):ae==="stale"?ee.set("stale","1"):ee.set("stale","0"),XG(Y,ee)?Y:ee})},[ae,g,h,M]),m.useEffect(()=>{z(Ke(y.filters.priority)),V(Ke(y.filters.type)),O(Ke(y.filters.assignee)),G(Ke(y.filters.project)),Q(Ke(y.filters.tags)),Re(y.sortField),ze(y.sortDirection),nt(y.grouping)},[y.filters.priority,y.filters.type,y.filters.assignee,y.filters.project,y.filters.tags,y.sortField,y.sortDirection,y.grouping]),m.useEffect(()=>{if(k.current===g)return;let Y=!1;return a0().then(ee=>{if(Y||k.current===g)return;const be=NT(ee,g),Be=be.defaultView,gt=Ke(be.filters.status),St=be.filters.activity??"all",Pt=new URLSearchParams(window.location.search);let Rn=!1;const Fn=new URLSearchParams(Pt);Pt.get("view")===null&&Be!=="kanban"&&_N.includes(Be)&&(Fn.set("view",Be),Rn=!0),Pt.get("status")===null&&gt.length>0&&(Fn.set("status",gt.join(",")),A(gt),Rn=!0),Pt.get("stale")===null&&St!=="all"&&(Fn.set("stale",St==="stale"?"1":"0"),ne(St),Rn=!0),Rn&&h(Fn,{replace:!0});const An=_(Fn.get("status")),Nr=Fn.get("stale")===null?St:pp(Fn.get("stale"));ye(Du({status:An,priority:Ke(be.filters.priority),type:Ke(be.filters.type),assignee:Ke(be.filters.assignee),project:Ke(be.filters.project),tags:Ke(be.filters.tags),activity:Nr==="fresh"||Nr==="stale"?Nr:"all"})),queueMicrotask(()=>{k.current=g})}),()=>{Y=!0}},[g]);const bt=m.useCallback(Y=>{(g===null?QP(Y):JP(g,Y)).catch(be=>{console.warn("Failed to persist view prefs:",be)})},[g]),Ai=m.useCallback(Y=>{U(Y),bt({defaultView:Y})},[U,bt]),_o=m.useRef(null);_o.current={status:M,priority:L,type:W,assignee:K,project:B,tags:H,activity:ae,dateRange:te,search:I};const Pa=m.useCallback((Y={})=>{const ee=_o.current;return{status:ee.status,priority:ee.priority,type:ee.type,assignee:ee.assignee,project:ee.project,tags:ee.tags,activity:ee.activity,dateRange:pa(ee.dateRange),search:ee.search,...Y}},[]),tn=m.useCallback((Y={})=>{ye(Du(Pa(Y)))},[Pa]),Do=m.useCallback(Y=>{A(Y),bt({filters:{status:Y}}),tn({status:Y})},[bt,tn]),_a=m.useCallback(Y=>{z(Y),bt({filters:{priority:Y}}),tn({priority:Y})},[bt,tn]),Da=m.useCallback(Y=>{V(Y),bt({filters:{type:Y}}),tn({type:Y})},[bt,tn]),Ac=m.useCallback(Y=>{O(Y),bt({filters:{assignee:Y}}),tn({assignee:Y})},[bt,tn]),$a=m.useCallback(Y=>{G(Y),bt({filters:{project:Y}}),tn({project:Y})},[bt,tn]),Bt=m.useCallback(Y=>{Q(Y),bt({filters:{tags:Y}}),tn({tags:Y})},[bt,tn]),Pi=m.useCallback(Y=>{ne(Y),bt({filters:{activity:Y}}),tn({activity:Y})},[bt,tn]),ro=m.useCallback(Y=>{F(Y),tn({search:Y})},[tn]),$o=m.useCallback(Y=>{Z(Y),tn({dateRange:pa(Y)})},[tn]),As=m.useCallback(Y=>{Re(Y),bt({sortField:Y})},[bt]),Io=m.useCallback(Y=>{ze(Y),bt({sortDirection:Y})},[bt]),Ia=m.useCallback(Y=>{nt(Y),bt({grouping:Y})},[bt]),Mo=m.useCallback(()=>{ro(""),Do([]),Bt([]),$o(null),Pi("all")},[ro,Do,Bt,$o,Pi]),nr=m.useCallback(Y=>{ye(Y);const ee=$u(Y);ee&&(A(Ke(ee.status)),z(Ke(ee.priority)),V(Ke(ee.type)),O(Ke(ee.assignee)),G(Ke(ee.project)),Q(Ke(ee.tags)),F(ee.search??""),ne(ee.activity&&ee.activity!=="all"?ee.activity:"all"),Z(Tm(ee.dateRange)))},[]),ar=m.useMemo(()=>$u(ue)!==null,[ue]),On=m.useCallback(()=>{const ee=$u(ue)!==null?{status:M,priority:L,type:W,assignee:K,project:B,tags:H,activity:ae,dateRange:pa(te),search:I}:{};return{viewMode:$,filters:{...ee,query:ue},sortField:Ne,sortDirection:Se,listSectionVisibility:{collapsed:[...at]},kanbanColumnVisibility:oe,tableColumnVisibility:ke}},[$,ue,M,L,W,K,B,H,ae,te,I,Ne,Se,at,oe,ke]),Lo=m.useCallback(Y=>{RA(Y,{setViewMode:U,setQuery:ye,setStatusFilter:ee=>{A(ee),bt({filters:{status:ee}})},setPriorityFilter:ee=>{z(ee),bt({filters:{priority:ee}})},setTypeFilter:ee=>{V(ee),bt({filters:{type:ee}})},setAssigneeFilter:ee=>{O(ee),bt({filters:{assignee:ee}})},setProjectFilter:ee=>{G(ee),bt({filters:{project:ee}})},setTagsFilter:ee=>{Q(ee),bt({filters:{tags:ee}})},setActivityFilter:ee=>{ne(ee),bt({filters:{activity:ee}})},setDateRange:Z,setSearch:F,setSortField:As,setSortDirection:Io,setListSectionVisibility:ee=>xt(new Set(ee.collapsed)),setKanbanColumnVisibility:we,setTableColumnVisibility:$e}),Ye(Y.id)},[U,bt,As,Io]),Pc=m.useCallback(Y=>{Lo(Y),kr.current=Y.id,h(ee=>{const be=new URLSearchParams(ee);return be.set("loadView",Y.id),be},{replace:!0})},[Lo,h]),_c=m.useCallback(async Y=>{try{const ee=Jl({name:Y,context:{workspace:e??null,projectSlug:null},state:On()}),be=await Gl(ee),Be=be.views[be.views.length-1];Ye((Be==null?void 0:Be.id)??null),Be&&(kr.current=Be.id,h(gt=>{const St=new URLSearchParams(gt);return St.set("loadView",Be.id),St},{replace:!0})),Mt(!1),Ct(!1),xe(`Saved view "${Y}"`,"success")}catch(ee){throw xe(ee instanceof Error?ee.message:"Failed to save view","error"),ee}},[On,h,xe,e]),Oo=m.useCallback(async()=>{if(!(!Ee||!Te))try{const Y=Jl({name:Te.name,context:{workspace:e??null,projectSlug:null},state:On()}),ee=yh(Te.config,Y.config,Y.config);await ph(Ee,{config:ee}),xe("View updated","success")}catch(Y){xe(Y instanceof Error?Y.message:"Failed to update view","error")}},[On,Te,Ee,xe,e]);m.useEffect(()=>{if(!Ft){kr.current=null;return}if(kr.current!==Ft&&(Ee&&Ee!==Ft&&Ye(null),!en)){if(ce){xe("Couldn't load saved view — try again","error");return}if(En){kr.current=Ft,Lo(En),h(Y=>{const ee=new URLSearchParams(Y);return ee.delete("loadView"),ee},{replace:!0});return}kr.current=Ft,xe("Saved view no longer exists","error"),h(Y=>{const ee=new URLSearchParams(Y);return ee.delete("loadView"),ee},{replace:!0})}},[Ft,En,en,ce,Ee,Lo,h,xe]);const Vn=m.useMemo(()=>lt.filter(Y=>e?e==="_ungrouped"?Y.projectWorkspace===null:Y.projectWorkspace===e:!0),[lt,e]),so=m.useMemo(()=>Array.from(new Set(Vn.map(Y=>Y.status))).sort(),[Vn]),Vr=m.useMemo(()=>Array.from(new Set(Vn.map(Y=>Y.priority))).sort(),[Vn]),Ma=m.useMemo(()=>Array.from(new Set(Vn.map(Y=>Y.assignee??"__unassigned__"))).sort(),[Vn]),_i=m.useMemo(()=>Array.from(new Map(Vn.filter(Y=>Y.projectSlug!==null).map(Y=>[Y.projectSlug,Y.projectTitle]))).sort(([,Y],[,ee])=>Y.localeCompare(ee)),[Vn]),Fo=m.useMemo(()=>Array.from(new Set(Vn.flatMap(Y=>Y.tags??[]))).sort(),[Vn]),zo=m.useMemo(()=>gA(d.factDeclarations),[d.factDeclarations]),Ps=m.useMemo(()=>ue.trim()===""?null:Kl(ue,zo).query,[ue,zo]),zt=m.useMemo(()=>hA(lt,Ps,{workspace:e}),[lt,Ps,e]),oo=m.useMemo(()=>Od(zt,Ne,Se),[zt,Ne,Se]),_s=m.useMemo(()=>{if(Ue==="none")return[{id:"__all__",label:"All assignments",items:zt}];if(Ue==="type"){const Y=f.definitions.map(Be=>({id:Be.id,label:$l(f,Be.id),items:zt.filter(gt=>gt.type===Be.id)})),ee=new Set(f.definitions.map(Be=>Be.id)),be=zt.filter(Be=>!Be.type||!ee.has(Be.type));return be.length>0&&Y.push({id:S,label:"Other",items:be}),Y}if(Ue==="priority")return["critical","high","medium","low"].map(ee=>({id:ee,label:ee.charAt(0).toUpperCase()+ee.slice(1),items:zt.filter(be=>be.priority===ee)}));if(Ue==="assignee")return Array.from(new Set(zt.map(ee=>ee.assignee??"__unassigned__"))).sort().map(ee=>({id:ee,label:ee==="__unassigned__"?"Unassigned":ee,items:zt.filter(be=>(be.assignee??"__unassigned__")===ee)}));if(Ue==="project"){const Y=new Map;for(const ee of zt){const be=ee.projectSlug??"__standalone__",Be=ee.projectTitle??"Standalone";Y.has(be)||Y.set(be,Be)}return Array.from(Y.entries()).sort(([,ee],[,be])=>ee.localeCompare(be)).map(([ee,be])=>({id:ee,label:be,items:zt.filter(Be=>(Be.projectSlug??"__standalone__")===ee)}))}return w.map(Y=>({id:Y,label:b[Y]??Y,items:zt.filter(ee=>ee.status===Y)}))},[Ue,zt,f,w,b]),Lt=m.useMemo(()=>{const Y=new Set(f.definitions.map(be=>be.id));return zt.some(be=>!be.type||!Y.has(be.type))?[...N,{id:S,title:"Other",description:"Assignments with no recognized type."}]:N},[N,f,zt]),{visibleItems:Xd,visibleIndexByKey:Dc}=m.useMemo(()=>{let Y;if($==="table")Y=oo;else if($==="kanban"){const be=new Set(f.definitions.map(Be=>Be.id));He==="type"?Y=[...f.definitions.flatMap(Be=>zt.filter(gt=>gt.type===Be.id)),...zt.filter(Be=>!Be.type||!be.has(Be.type))]:Y=w.flatMap(Be=>zt.filter(gt=>gt.status===Be))}else Y=_s.flatMap(be=>be.items);const ee=new Map;return Y.forEach((be,Be)=>ee.set(mn(be),Be)),{visibleItems:Y,visibleIndexByKey:ee}},[$,oo,_s,He,f,zt,w]),{hotkeyRowProps:Di}=Ad(Xd,{scope:"list:assignments",onOpen:Y=>{if(Y.projectSlug===null){n(`/assignments/${Y.id}`);return}const ee=Y.projectWorkspace?`/w/${Y.projectWorkspace}`:t;n(`${ee}/projects/${Y.projectSlug}/assignments/${Y.slug}`)}});if(Jt({keys:"/",scope:"list:assignments",description:"Focus filter",handler:()=>{var Y;return(Y=r.current)==null?void 0:Y.focus()}}),Jt({keys:"r",scope:"list:assignments",description:"Refresh",handler:()=>l()}),i)return s.jsx(jt,{label:"Loading assignments board…"});if(a||!o)return s.jsx(Rt,{error:a||"Assignments board is unavailable."});async function $c({item:Y,toColumnId:ee,action:be,reason:Be}){if(!be){const St=d.statuses.find(Pt=>Pt.id===ee);if(Ib(St??{id:ee}))return xe(`Reach “${So(d,ee)}” through its complete/fail transition.`,"error"),!1}Ge(mn(Y));const gt=lt;ot(St=>St.map(Pt=>mn(Pt)===mn(Y)?{...Pt,status:ee,blockedReason:ee==="blocked"?Be??Pt.blockedReason:null}:Pt));try{const St=Y.projectSlug===null?be?await uG(Y.id,be,Be):await dG(Y.id,ee):be?await n_(Y.projectSlug,Y.slug,be,Be):await r_(Y.projectSlug,Y.slug,ee);return ot(Pt=>Pt.map(Rn=>mn(Rn)===mn(Y)?{...Rn,status:St.status,blockedReason:St.blockedReason,availableTransitions:St.availableTransitions,updated:St.updated}:Rn)),l(),xe(`Moved to ${So(d,St.status)}`,"success"),!0}catch(St){return ot(gt),xe(St.message,"error"),!1}finally{Ge(null)}}async function io({item:Y,toColumnId:ee,action:be}){if(Y.status===ee)return;const Be=be??yu(Y,ee);if(Be!=null&&Be.disabled){xe(Be.disabledReason||`Cannot move this assignment to ${ee}.`,"error");return}if(Be&&s_(Be)){qe({item:Y,toColumnId:ee,action:Be});return}await $c({item:Y,toColumnId:ee,action:Be})}function Ic(Y){return kA(d).map(ee=>ee.id===Y.status?{id:ee.id,label:ee.label,disabled:!0,disabledReason:"Already in this status"}:ee.terminal&&!Y.availableTransitions.find(Be=>Be.targetStatus===ee.id&&!Be.disabled)?{id:ee.id,label:ee.label,disabled:!0,disabledReason:`Reach ${ee.label} via its transition when available`}:{id:ee.id,label:ee.label})}function La(Y,ee){io({item:Y,toColumnId:ee})}async function Bo(Y,ee){if(ee===Y.title)return;const be=mn(Y),Be=lt;ot(gt=>gt.map(St=>mn(St)===be?{...St,title:ee}:St)),Ge(be);try{const gt=Y.projectSlug===null?await pG({id:Y.id,title:ee}):await fG({projectSlug:Y.projectSlug,assignmentSlug:Y.slug,title:ee});ot(St=>St.map(Pt=>mn(Pt)===be?{...Pt,title:gt.title,updated:gt.updated}:Pt)),l()}catch(gt){throw ot(Be),xe(gt.message,"error"),gt}finally{Ge(null)}}function Ds(Y){xt(ee=>{const be=new Set(ee);return be.has(Y)?be.delete(Y):be.add(Y),be})}function $s(Y){Ne===Y?Io(Se==="asc"?"desc":"asc"):(As(Y),Io("asc"))}const dn=ge?lt.find(Y=>mn(Y)===ge)??null:null;function $i(Y,ee){Y.dataTransfer.effectAllowed="move",Y.dataTransfer.setData("text/plain",ee),pe(ee)}function ao(){pe(null),je(null)}function Is(Y,ee){if(!dn)return;const be=yu(dn,ee);dn.status===ee||be!=null&&be.disabled||(Y.preventDefault(),Y.dataTransfer.dropEffect="move",je(ee))}function og(Y,ee){se===ee&&!Y.currentTarget.contains(Y.relatedTarget)&&je(null)}function Qd(Y,ee){if(Y.preventDefault(),!dn||dn.status===ee){ao();return}ao(),io({item:dn,toColumnId:ee})}function Sr({field:Y,children:ee}){const be=Ne===Y;return s.jsx("th",{className:"pb-3 font-medium",children:s.jsxs("button",{type:"button",onClick:()=>$s(Y),className:"inline-flex items-center gap-1 hover:text-foreground",children:[ee,be?Se==="asc"?s.jsx(GE,{className:"h-3 w-3"}):s.jsx(vr,{className:"h-3 w-3"}):null]})})}return s.jsxs("div",{className:"space-y-5","data-density":y.density,children:[s.jsx("div",{className:"flex items-center justify-end",children:s.jsxs(Ie,{to:`${t}/assignments/new`,className:"inline-flex h-9 items-center gap-2 rounded-md bg-foreground px-3 text-sm font-medium text-background transition hover:bg-foreground/90",children:[s.jsx(It,{className:"h-4 w-4"}),"New Assignment"]})}),s.jsxs($w,{children:[s.jsx(YG,{className:"w-full md:min-w-[320px] md:flex-1",value:ue,onChange:nr,registry:zo,declarations:d.factDeclarations,valueSources:{statuses:d.order,priorities:Vr,types:f.definitions.map(Y=>Y.id),assignees:Ma.filter(Y=>Y!=="__unassigned__"),projects:_i.map(([Y])=>Y),tags:Fo}}),ar?null:s.jsx("span",{className:"inline-flex items-center rounded-md border border-amber-500/40 bg-amber-500/10 px-2 py-1 text-xs font-medium text-amber-700 dark:text-amber-300",title:"This query uses features the chips can't represent (OR / NOT / grouping / advanced fields). Edit it in the query box; the chips are read-only until it becomes chip-representable again.",children:"advanced query — edit in the box"}),s.jsx(Rm,{ref:r,value:I,onChange:ar?ro:()=>{},placeholder:"Search assignments or projects"}),s.jsx(yn,{ariaLabel:"Status filter",className:"max-w-[180px]",allLabel:"All statuses",disabled:!ar,options:so.map(Y=>({value:Y,label:b[Y]??Y})),value:M,onChange:Do}),s.jsx(yn,{ariaLabel:"Priority filter",className:"max-w-[180px]",allLabel:"All priorities",disabled:!ar,options:Vr.map(Y=>({value:Y,label:Y[0].toUpperCase()+Y.slice(1)})),value:L,onChange:_a}),s.jsx(yn,{ariaLabel:"Type filter",className:"max-w-[180px]",allLabel:"All types",disabled:!ar,options:f.definitions.map(Y=>({value:Y.id,label:$l(f,Y.id)})),value:W,onChange:Da}),s.jsx(yn,{ariaLabel:"Assignee filter",className:"max-w-[180px]",allLabel:"All assignees",disabled:!ar,options:[{value:"__unassigned__",label:"Unassigned"},...Ma.filter(Y=>Y!=="__unassigned__").map(Y=>({value:Y,label:Y}))],value:K,onChange:Ac}),s.jsx(yn,{ariaLabel:"Project filter",className:"max-w-[180px]",allLabel:"All projects",disabled:!ar,options:[{value:"__standalone__",label:"Standalone"},..._i.map(([Y,ee])=>({value:Y,label:ee}))],value:B,onChange:$a}),s.jsx(yn,{ariaLabel:"Tags filter",className:"max-w-[180px]",allLabel:"Any tags",disabled:!ar,options:Fo.map(Y=>({value:Y,label:Y})),value:H,onChange:Bt}),s.jsx(Em,{className:"max-w-[200px]",value:te,onChange:ar?$o:()=>{}}),s.jsxs("select",{value:ae,disabled:!ar,onChange:Y=>Pi(Y.target.value),className:"editor-input max-w-[180px]","aria-label":"Filter by activity",title:"Filter by activity",children:[s.jsx("option",{value:"all",children:"All activity"}),s.jsx("option",{value:"stale",children:"Stale only"}),s.jsx("option",{value:"fresh",children:"Fresh only"})]}),s.jsx("select",{value:$==="kanban"?He:Ue,onChange:Y=>Ia(Y.target.value),className:"editor-input max-w-[180px]",title:"Group by",children:a6.map(Y=>{const ee=$==="kanban"&&Y!=="status"&&Y!=="type",be=Y==="none"?"No grouping":`Group: ${Y.charAt(0).toUpperCase()+Y.slice(1)}`;return s.jsx("option",{value:Y,disabled:ee,children:ee?`${be} (list only)`:be},Y)})}),s.jsx(Am,{value:$,onChange:Y=>Ai(Y),options:[{value:"table",label:"Table"},{value:"list",label:"List"},{value:"kanban",label:"Kanban"}]}),$==="table"?s.jsx(qP,{visibility:ke,onChange:$e}):null,s.jsx(e_,{scope:Cn,loadedViewId:Ee,onApply:Pc,onOpenSaveDialog:()=>{Ct(!1),Mt(!0)}}),s.jsx("button",{type:"button",onClick:()=>{Te?Oo():(Ct(!1),Mt(!0))},className:"inline-flex items-center gap-1.5 rounded-md border border-border/60 bg-background/60 px-2.5 py-1.5 text-xs font-medium text-foreground hover:bg-background",title:Te?`Update ${Te.name}`:"Save current view",children:Te?`Update '${Te.name}'`:"Save view"}),Te?s.jsx("button",{type:"button",onClick:()=>{Ct(!0),Mt(!0)},className:"inline-flex items-center gap-1.5 rounded-md border border-border/60 bg-background/60 px-2.5 py-1.5 text-xs font-medium text-foreground hover:bg-background",title:"Save as new view",children:"Save as new…"}):null]}),o.assignments.length===0?s.jsx(Tt,{title:"No assignments yet",description:"Assignments appear here once projects contain concrete work items.",actions:s.jsxs(Ie,{className:"shell-action shell-action--cta",to:`${t}/projects`,children:[s.jsx(Av,{className:"h-4 w-4"}),s.jsx("span",{children:"Browse Projects"})]})}):zt.length===0?s.jsx(Tt,{title:"No assignments match these filters",description:"Adjust the search term or filters to show assignments across all projects again.",actions:s.jsxs("button",{type:"button",onClick:Mo,className:"shell-action shell-action--cta",children:[s.jsx(OL,{className:"h-4 w-4"}),s.jsx("span",{children:"Clear all filters"})]})}):$==="table"?(()=>{const Y=new Set(ke.hidden),ee=be=>be==="title"||!Y.has(be);return s.jsx(Qe,{title:`${oo.length} assignment${oo.length===1?"":"s"}`,children:s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"w-full min-w-[760px] text-left text-sm",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"border-b border-border/60 text-muted-foreground",children:[ee("title")?s.jsx(Sr,{field:"title",children:"Assignment"}):null,ee("status")?s.jsx(Sr,{field:"status",children:"Status"}):null,s.jsx("th",{className:"py-2 pr-4 text-xs font-medium uppercase tracking-wider",children:"Type"}),ee("priority")?s.jsx(Sr,{field:"priority",children:"Priority"}):null,ee("assignee")?s.jsx(Sr,{field:"assignee",children:"Assignee"}):null,ee("dependencies")?s.jsx(Sr,{field:"dependencies",children:"Dependencies"}):null,ee("created")?s.jsx(Sr,{field:"created",children:"Created"}):null,ee("updated")?s.jsx(Sr,{field:"updated",children:"Updated"}):null]})}),s.jsx("tbody",{children:oo.map((be,Be)=>s.jsxs(JG,{detailHref:od(be),className:"cursor-pointer border-b border-border/50 transition hover:bg-muted/40 last:border-0",...Di(Be),children:[ee("title")?s.jsxs("td",{className:"py-4 pr-4",children:[s.jsx(k_,{title:be.title,detailHref:od(be),onSave:gt=>Bo(be,gt),disabled:We===mn(be)}),s.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:be.projectTitle??s.jsx("span",{className:"rounded bg-muted px-1.5 py-0.5 font-mono text-[10px] uppercase text-muted-foreground",children:"Standalone"})}),s.jsxs("p",{className:"mt-0.5 inline-flex items-center gap-1.5 font-mono text-xs text-muted-foreground/70",title:be.id,children:[be.id.slice(0,8),s.jsx(Zr,{value:be.id})]})]}):null,ee("status")?s.jsx("td",{className:"py-4 pr-4",children:s.jsx("select",{value:be.status,disabled:We===mn(be),onChange:gt=>io({item:be,toColumnId:gt.target.value}),className:Ce("appearance-none rounded-full border px-2.5 py-0.5 text-xs font-semibold tracking-wide outline-none","cursor-pointer bg-[length:12px] bg-[right_6px_center] bg-no-repeat pr-6",`bg-[url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='currentColor'%3E%3Cpath fill-rule='evenodd' d='M5.23 7.21a.75.75 0 011.06.02L10 11.168l3.71-3.938a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z'/%3E%3C/svg%3E")]`,id(d.statuses,be.status).className,We===mn(be)&&"animate-pulse opacity-60"),style:id(d.statuses,be.status).style,children:w.map(gt=>{const St=be.status===gt,Pt=St?void 0:yu(be,gt),Rn=d.statuses.find(Uo=>Uo.id===gt),Fn=!St&&Ib(Rn??{id:gt})&&!Pt,An=((Pt==null?void 0:Pt.disabled)??!1)||Fn,Nr=Fn?`Reach ${b[gt]??gt} via its transition when available`:(Pt==null?void 0:Pt.disabledReason)??void 0;return s.jsx("option",{value:gt,disabled:An,title:An?Nr:void 0,children:b[gt]},gt)})})}):null,s.jsx("td",{className:"py-4 pr-4",children:s.jsx(Ea,{type:be.type,compact:!0})}),ee("priority")?s.jsx("td",{className:"py-4 pr-4 capitalize text-muted-foreground",children:be.priority}):null,ee("assignee")?s.jsx("td",{className:"py-4 pr-4 text-muted-foreground",children:be.assignee??"Unassigned"}):null,ee("dependencies")?s.jsx("td",{className:"py-4 pr-4 text-muted-foreground",children:be.dependsOn.length}):null,ee("created")?s.jsx("td",{className:"py-4 pr-4 text-muted-foreground",children:Gn(be.created)}):null,ee("updated")?s.jsx("td",{className:"py-4 text-muted-foreground",children:Gn(be.updated)}):null]},mn(be)))})]})})})})():$==="list"?s.jsx("div",{className:"space-y-3",children:_s.map(({id:Y,label:ee,items:be})=>{var Fn;if(be.length===0&&!(dn&&Ue==="status"))return null;const Be=!at.has(Y),gt=Ue==="status",St=gt&&dn?dn.status!==Y&&!((Fn=yu(dn,Y))!=null&&Fn.disabled):!1,Pt=gt&&dn?dn.status!==Y&&!St:!1,Rn=gt&&se===Y;return s.jsxs("div",{className:Ce("rounded-lg border border-border/60 bg-card/90 transition",Rn&&St&&"ring-2 ring-ring/30",Pt&&"border-dashed opacity-65"),onDragOver:gt?An=>Is(An,Y):void 0,onDragLeave:gt?An=>og(An,Y):void 0,onDrop:gt?An=>Qd(An,Y):void 0,children:[s.jsxs("button",{type:"button",onClick:()=>Ds(Y),className:"flex w-full items-center gap-2 px-4 py-3 text-left",children:[s.jsx(vr,{className:`h-4 w-4 text-muted-foreground transition-transform ${Be?"":"-rotate-90"}`}),s.jsx("span",{className:"font-semibold text-foreground",children:ee}),s.jsx("span",{className:"rounded-full border border-border/60 px-2 py-0.5 text-xs text-muted-foreground",children:be.length})]}),Be&&be.length>0&&s.jsx("div",{className:"space-y-3 px-4 pb-4",children:be.map(An=>{const Nr=mn(An),Uo=ge===Nr,Ii=Dc.get(Nr)??-1,Ho=gt;return s.jsx("div",{draggable:Ho,onDragStart:Ho?os=>$i(os,Nr):void 0,onDragEnd:Ho?ao:void 0,...Ii>=0?Di(Ii):{},className:Ce("transition",Ho&&"cursor-grab active:cursor-grabbing",Uo&&"scale-[0.98] opacity-50"),children:s.jsx($N,{assignment:An,dragging:Uo,transitioning:We===Nr,onPillSelect:os=>void io({item:An,toColumnId:os.targetStatus,action:os}),overrideTargets:Ic(An),onOverride:os=>La(An,os),onRenameTitle:os=>Bo(An,os)})},Nr)})})]},Y)})}):s.jsx(Cm,{columns:He==="type"?Lt:j,items:zt,getItemId:mn,getColumnId:Y=>He==="type"?Y.type&&f.definitions.some(ee=>ee.id===Y.type)?Y.type:S:Y.status,canDrop:({item:Y,fromColumnId:ee,toColumnId:be})=>{if(ee===be)return{allowed:!0};const Be=yu(Y,be);return Be!=null&&Be.disabled?{allowed:!1,reason:Be.disabledReason||Be.description}:{allowed:!0,reason:Be?Be.warning||Be.description:`Move to ${be} (direct status change).`}},onMove:He==="type"?void 0:({item:Y,toColumnId:ee})=>io({item:Y,toColumnId:ee}),dragDisabled:He==="type",getExternalDragData:Y=>Y.projectSlug===null?{type:"standalone-assignment",id:Y.id}:{type:"project-assignment",id:Y.id},onCardContextMenu:(Y,ee)=>{ee.preventDefault(),ve({item:Y,anchor:{x:ee.clientX,y:ee.clientY}})},emptyMessage:Y=>`No ${Y.title.toLowerCase()} assignments.`,hiddenColumnIds:oe.hidden,onHideColumn:Y=>we(ee=>({hidden:ee.hidden.includes(Y)?ee.hidden.filter(Be=>Be!==Y):[...ee.hidden,Y]})),renderCard:(Y,{dragging:ee})=>{const be=Dc.get(mn(Y))??-1;return s.jsx("div",{...be>=0?Di(be):{},children:s.jsx($N,{assignment:Y,dragging:ee,transitioning:We===mn(Y),onPillSelect:Be=>void io({item:Y,toColumnId:Be.targetStatus,action:Be}),overrideTargets:Ic(Y),onOverride:Be=>La(Y,Be),onRenameTitle:Be=>Bo(Y,Be)})})}}),s.jsx(Hr,{toast:le,onDismiss:Oe}),s.jsx(ZP,{open:Nt,onOpenChange:Y=>{Mt(Y),Y||Ct(!1)},initialName:Nn&&Te?`${Te.name} (copy)`:"",title:Nn?"Save as new view":"Save view",onSubmit:_c}),s.jsx(c_,{open:Ae!==null,action:(Ae==null?void 0:Ae.action)??null,assignmentTitle:(Ae==null?void 0:Ae.item.title)??"Assignment",loading:We===(Ae?mn(Ae.item):null),onOpenChange:Y=>{Y||qe(null)},onConfirm:async Y=>{if(!Ae)return;const ee=Ae;await $c({item:ee.item,toColumnId:ee.toColumnId,action:ee.action,reason:Y})&&qe(null)}}),s.jsx(MA,{anchor:(X==null?void 0:X.anchor)??null,items:X?QG(X.item,{onEdit:()=>{const Y=X.item,ee=Y.projectSlug===null?`/assignments/${Y.id}`:`${Y.projectWorkspace?`/w/${Y.projectWorkspace}`:t}/projects/${Y.projectSlug}/assignments/${Y.slug}`;n(ee)},onDelete:()=>ft(X.item),onMove:()=>he(X.item)}):[],onClose:()=>ve(null)}),s.jsx(Ri,{open:Ve!==null,title:"Delete assignment?",description:Ve?`"${Ve.title}" will be permanently removed. This cannot be undone.`:"",confirmLabel:"Delete",destructive:!0,loading:et!==null,onOpenChange:Y=>{!Y&&et===null&&ft(null)},onConfirm:async()=>{if(!Ve||Ve.projectSlug===null){ft(null);return}const Y=mn(Ve);yt(Y);try{const ee=await fetch(`/api/projects/${encodeURIComponent(Ve.projectSlug)}/assignments/${encodeURIComponent(Ve.slug)}`,{method:"DELETE"});if(!ee.ok){const be=await ee.json().catch(()=>({}));throw new Error(be.error||"Failed to delete assignment")}ft(null),l(),xe("Assignment deleted","success")}catch(ee){xe(ee instanceof Error?ee.message:"Failed to delete assignment","error")}finally{yt(null)}}}),s.jsx(Mw,{open:mt!==null,onOpenChange:Y=>{Y||he(null)},currentWorkspace:(mt==null?void 0:mt.projectWorkspace)??null,title:"Move assignment to workspace",description:"Standalone assignments belong to a project-workspace via the workspaceGroup frontmatter field.",onSubmit:async Y=>{if(!mt)return;const ee=await fetch(`/api/assignments/${encodeURIComponent(mt.id)}/move-workspace`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({workspaceGroup:Y})});if(!ee.ok){const be=await ee.json().catch(()=>({}));throw new Error(be.error||"Failed to move assignment")}l()}})]})}function QG(e,t){const n=[{key:"edit",label:"Edit",icon:fc,onSelect:t.onEdit}];return e.projectSlug!==null?n.push({key:"delete",label:"Delete",icon:bn,destructive:!0,onSelect:t.onDelete}):n.push({key:"move",label:"Move to workspace…",icon:Vh,onSelect:t.onMove}),n}function JG({detailHref:e,children:t,className:n,...r}){const o=S_(e);return s.jsx("tr",{...r,ref:o.containerRef,className:n,onMouseDown:o.onMouseDown,onClick:o.onClick,children:t})}function $N({assignment:e,dragging:t,transitioning:n,onPillSelect:r,overrideTargets:o,onOverride:i,onRenameTitle:a}){var p;const l=od(e),d=!!(r&&a),f=S_(l);return s.jsxs("div",{ref:d?f.containerRef:void 0,className:Ce("vp-card rounded-lg border border-border/60 bg-background/85 p-3 shadow-sm",d&&"cursor-pointer"),onMouseDown:d?f.onMouseDown:void 0,onClick:d?f.onClick:void 0,children:[s.jsxs("div",{className:"flex items-start justify-between gap-3",children:[s.jsxs("div",{className:"min-w-0 flex-1 space-y-1",children:[d?s.jsx(k_,{title:e.title,detailHref:l,onSave:a,disabled:n}):s.jsx(Ie,{to:l,className:"text-base font-semibold text-foreground hover:text-primary",children:e.title}),s.jsx("p",{className:"text-sm text-muted-foreground",children:e.projectTitle??s.jsx("span",{className:"rounded bg-muted px-1.5 py-0.5 font-mono text-[10px] uppercase text-muted-foreground",children:"Standalone"})}),s.jsxs("p",{className:"inline-flex items-center gap-1.5 font-mono text-xs text-muted-foreground/70",title:e.id??"",children:[(p=e.id)==null?void 0:p.slice(0,8),e.id&&s.jsx(Zr,{value:e.id})]})]}),d?s.jsx(BG,{currentStatus:e.status,availableTransitions:e.availableTransitions,onSelect:r,overrideTargets:o,onOverride:i,disabled:n,className:"max-w-[150px]"}):s.jsx(vn,{status:e.status,className:"max-w-[150px]"})]}),e.blockedReason?s.jsx("p",{className:"mt-3 rounded-md border border-warning-foreground/30 bg-warning px-3 py-2 text-sm text-warning-foreground",children:e.blockedReason}):null,s.jsxs("div",{className:"mt-4 flex flex-wrap gap-2",children:[s.jsx(Ea,{type:e.type}),s.jsx("span",{className:"rounded-full border border-border/60 px-2.5 py-1 text-xs capitalize text-muted-foreground",children:e.priority}),s.jsx("span",{className:"rounded-full border border-border/60 px-2.5 py-1 text-xs text-muted-foreground",children:e.assignee??"Unassigned"}),e.dependsOn.length>0?s.jsxs("span",{className:"rounded-full border border-border/60 px-2.5 py-1 text-xs text-muted-foreground",children:[e.dependsOn.length," ",e.dependsOn.length===1?"dependency":"dependencies"]}):null]}),s.jsxs("div",{className:"mt-4 flex items-center justify-between gap-3 text-xs uppercase tracking-[0.08em] text-muted-foreground",children:[s.jsx("span",{children:n?"Updating":t?"Dragging":"Source-first"}),s.jsx("span",{children:Gn(e.updated)})]})]})}function yu(e,t){return e.availableTransitions.find(n=>n.targetStatus===t)}function mn(e){return e.id||e.slug||"unknown"}function ss(e){const t=e.match(/^---\n([\s\S]*?)\n---\n?/);if(!t)return{order:[],blocks:new Map,body:e};const n=t[1],r=e.slice(t[0].length),o=n.split(`
616
+ `),i=[],a=new Map;let l=null,d=[];const f=()=>{l&&(i.push(l),a.set(l,d))};for(const p of o){const h=p.match(/^([A-Za-z_][A-Za-z0-9_-]*):/);if(h&&!p.startsWith(" ")){f(),l=h[1],d=[p];continue}l&&d.push(p)}return f(),{order:i,blocks:a,body:r}}function Nc(e){return`---
617
+ ${e.order.map(n=>e.blocks.get(n)).filter(n=>!!n).flat().join(`
618
+ `)}
619
+ ---
620
+
621
+ ${e.body.replace(/^\n+/,"")}`}const ZG=/[:#{}[\],&*?|>!%@`]/;function tv(e){return e.length>=2&&e.startsWith('"')&&e.endsWith('"')?e.slice(1,-1).replace(/\\(["\\])/g,"$1"):e.length>=2&&e.startsWith("'")&&e.endsWith("'")?e.slice(1,-1).replace(/''/g,"'"):e}function N_(e){return ZG.test(e)||/^\s|\s$/.test(e)||/^["']|["']$/.test(e)?`"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`:e}function In(e,t){const n=e.blocks.get(t);if(!(n!=null&&n[0]))return"";const r=n[0].match(/^[^:]+:\s*(.*)$/);if(!r)return"";const o=r[1].trim();return o==="null"?"":tv(o)}function eY(e,t){return In(e,t)==="true"}function tY(e){const t=[];let n="",r=null;for(let o=0;o<e.length;o+=1){const i=e[o];if(r){n+=i,i==="\\"&&r==='"'&&o+1<e.length?(n+=e[o+1],o+=1):i===r&&(r=null);continue}if(i==='"'||i==="'"){r=i,n+=i;continue}if(i===","){t.push(n),n="";continue}n+=i}return t.push(n),t}function Hu(e,t){const n=e.blocks.get(t);if(!(n!=null&&n.length))return[];if(n[0].trim().endsWith("[]"))return[];const o=n[0].match(/^[^:]+:\s*\[(.*)\]\s*$/);return o?tY(o[1]).map(i=>tv(i.trim())).filter(i=>i.length>0):n.slice(1).map(i=>i.trim()).filter(i=>i.startsWith("- ")).map(i=>tv(i.slice(2).trim()))}function nY(e){return typeof e=="boolean"?e?"true":"false":e===null||e===""?"null":N_(e)}function Mn(e,t,n){e.blocks.has(t)||e.order.push(t),e.blocks.set(t,[`${t}: ${nY(n)}`])}function Vu(e,t,n){if(e.blocks.has(t)||e.order.push(t),n.length===0){e.blocks.set(t,[`${t}: []`]);return}e.blocks.set(t,[`${t}:`,...n.map(r=>` - ${N_(r)}`)])}function Wu(e){return e.split(",").map(t=>t.trim()).filter(Boolean)}function Om(e){const t=ss(e);return{title:In(t,"title"),slug:In(t,"slug"),workspace:In(t,"workspace"),archived:eY(t,"archived"),archivedAt:In(t,"archivedAt"),archivedReason:In(t,"archivedReason"),tags:Hu(t,"tags").join(", "),body:t.body}}function rY(e,t){const n=ss(e),r={...Om(e),...t};return Mn(n,"title",r.title),Mn(n,"slug",r.slug),Mn(n,"workspace",r.workspace||null),Mn(n,"archived",r.archived),Mn(n,"archivedAt",r.archivedAt||null),Mn(n,"archivedReason",r.archivedReason||null),Vu(n,"tags",Wu(r.tags)),n.body=r.body,Nc(n)}function Fm(e){const t=ss(e);return{title:In(t,"title"),slug:In(t,"slug"),status:In(t,"status"),priority:In(t,"priority")||"medium",assignee:In(t,"assignee"),dependsOn:Hu(t,"dependsOn").join(", "),links:Hu(t,"links").join(", "),blockedReason:In(t,"blockedReason"),tags:Hu(t,"tags").join(", "),body:t.body}}function sY(e,t){const n=ss(e),r={...Fm(e),...t};return Mn(n,"title",r.title),Mn(n,"slug",r.slug),Mn(n,"status",r.status),Mn(n,"priority",r.priority),Mn(n,"assignee",r.assignee||null),Vu(n,"dependsOn",Wu(r.dependsOn)),Vu(n,"links",Wu(r.links)),Mn(n,"blockedReason",r.blockedReason||null),Vu(n,"tags",Wu(r.tags)),n.body=r.body,Nc(n)}function zm(e){const t=ss(e);return{assignment:In(t,"assignment"),status:In(t,"status"),body:t.body}}function oY(e,t){const n=ss(e),r={...zm(e),...t};return Mn(n,"assignment",r.assignment),Mn(n,"status",r.status),n.body=r.body,Nc(n)}function Bm(e){const t=ss(e);return{assignment:In(t,"assignment"),body:t.body}}function iY(e,t){const n=ss(e),r={...Bm(e),...t};return Mn(n,"assignment",r.assignment),n.body=r.body,Nc(n)}function Um(e){const t=ss(e);return{name:In(t,"name"),slug:In(t,"slug"),description:In(t,"description"),whenToUse:In(t,"when_to_use"),tags:Hu(t,"tags").join(", "),body:t.body}}function aY(e,t){const n=ss(e),r={...Um(e),...t};return Mn(n,"name",r.name),Mn(n,"slug",r.slug),Mn(n,"description",r.description||null),Mn(n,"when_to_use",r.whenToUse||null),Vu(n,"tags",Wu(r.tags)),n.body=r.body,Nc(n)}function f0(e){return{body:ss(e).body}}function C_(e){return f0(e)}function E_(e,t){const n=ss(e);return t.body!==void 0&&(n.body=t.body),Nc(n)}function lY(e,t){return E_(e,t)}function Qt(e,t,n){switch(e){case"project":return rY(t,n);case"assignment":return sY(t,n);case"plan":return oY(t,n);case"scratchpad":return iY(t,n);case"playbook":return aY(t,n);case"memory":return E_(t,n);case"resource":return lY(t,n);default:return t}}function Cc({initialContent:e,documentType:t,mode:n="edit",onSave:r,saving:o,error:i,title:a,description:l,onCancel:d,helpTitle:f,helpBody:p,allowSlugEdit:h=!1}){const[g,y]=m.useState(e),[k,w]=m.useState(!1),[b,j]=m.useState("edit");m.useEffect(()=>{y(e)},[e]);const N=fY(t,g),S=g!==e,C=dY(t,g),D=S?"Unsaved changes":n==="create"?"Draft":"Saved",T=t!=="memory"&&t!=="resource";return s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"rounded-lg border border-border/70 bg-card/90 p-3 shadow-sm",children:[s.jsxs("div",{className:"flex flex-col gap-4 lg:flex-row lg:items-start lg:justify-between",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("h1",{className:"text-lg font-semibold text-foreground",children:a}),s.jsx("span",{className:"rounded-full border border-border/70 bg-background/80 px-2.5 py-1 text-xs font-medium text-muted-foreground",children:D})]}),l?s.jsx("p",{className:"max-w-3xl text-sm leading-6 text-muted-foreground",children:l}):null]}),s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsxs("button",{type:"button",onClick:d,className:"shell-action",children:[s.jsx(Jp,{className:"h-4 w-4"}),s.jsx("span",{children:"Back"})]}),T?s.jsxs("button",{type:"button",onClick:()=>w(R=>!R),className:"shell-action",children:[s.jsx(ML,{className:"h-4 w-4"}),s.jsx("span",{children:k?"Structured":"Raw Markdown"})]}):null,s.jsxs("button",{type:"button",onClick:()=>r(g),disabled:o||N.length>0,className:"inline-flex items-center gap-2 rounded-md bg-foreground px-4 py-2 text-sm font-semibold text-background transition hover:opacity-90 disabled:cursor-not-allowed disabled:opacity-50",children:[s.jsx(qh,{className:"h-4 w-4"}),s.jsx("span",{children:o?"Saving…":"Save"})]})]})]}),i?s.jsx("p",{className:"mt-4 rounded-md border border-error-foreground/30 bg-error px-4 py-3 text-sm text-error-foreground",children:i}):null,N.length>0?s.jsx("div",{className:"mt-4 rounded-md border border-warning-foreground/30 bg-warning px-4 py-3 text-sm text-warning-foreground",children:s.jsx("ul",{className:"space-y-1",children:N.map(R=>s.jsx("li",{children:R},R))})}):null]}),s.jsxs("div",{className:"flex items-center gap-2 md:hidden",children:[s.jsx("button",{type:"button",onClick:()=>j("edit"),className:`shell-action ${b==="edit"?"shell-action--cta":""}`,children:"Edit"}),s.jsxs("button",{type:"button",onClick:()=>j("preview"),className:`shell-action ${b==="preview"?"shell-action--cta":""}`,children:[s.jsx(d1,{className:"h-4 w-4"}),"Preview"]})]}),s.jsxs("div",{className:"grid gap-3 xl:grid-cols-[minmax(0,1.2fr)_minmax(320px,0.8fr)]",children:[s.jsx("div",{className:b==="preview"?"hidden md:block":"",children:s.jsx("div",{className:"surface-panel space-y-3",children:k?s.jsx("textarea",{value:g,onChange:R=>y(R.target.value),className:"min-h-[720px] w-full rounded-md border border-border/70 bg-background/90 p-4 font-mono text-sm text-foreground outline-none transition focus:border-primary focus:ring-2 focus:ring-ring/30",spellCheck:!1}):s.jsx(cY,{documentType:t,content:g,onChange:y,allowSlugEdit:h})})}),s.jsx("div",{className:b==="edit"?"hidden md:block":"",children:s.jsxs("div",{className:"surface-panel sticky top-16 space-y-4",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(d1,{className:"h-4 w-4 text-muted-foreground"}),s.jsx("h2",{className:"text-lg font-semibold text-foreground",children:"Preview"})]}),s.jsx(xn,{content:C,emptyState:"Write markdown body content to preview it here."})]})})]})]})}function cY({documentType:e,content:t,onChange:n,allowSlugEdit:r}){const o=Es();if(e==="project"){const a=Om(t);return s.jsxs("div",{className:"space-y-3",children:[s.jsxs(bu,{children:[s.jsx(Ut,{label:"Project title",children:s.jsx("input",{value:a.title,onChange:l=>{const d=l.target.value,f={title:d};r&&(a.slug===Pr(a.title)||!a.slug.trim())&&(f.slug=Pr(d)),n(Qt(e,t,f))},className:"editor-input"})}),s.jsx(Ut,{label:"Slug",children:s.jsxs("div",{className:"space-y-2",children:[s.jsx("input",{value:a.slug,disabled:!r,onChange:l=>n(Qt(e,t,{slug:Pr(l.target.value)})),className:`editor-input ${r?"":"editor-input-disabled"}`}),s.jsx("p",{className:"text-xs leading-5 text-muted-foreground",children:r?"The slug becomes the folder name and URL. It is auto-generated from the title until you change it, and it cannot be renamed after creation.":"The slug is the folder name and URL-safe identifier. It is locked after creation so links and file paths stay stable."})]})}),s.jsx(Ut,{label:"Tags",children:s.jsx("input",{value:a.tags,onChange:l=>n(Qt(e,t,{tags:l.target.value})),placeholder:"Comma-separated tags",className:"editor-input"})}),s.jsx(uY,{value:a.workspace,onChange:l=>n(Qt(e,t,{workspace:l}))})]}),s.jsx(Ut,{label:"Project body",children:s.jsx("textarea",{value:a.body,onChange:l=>n(Qt(e,t,{body:l.target.value})),className:"editor-textarea",spellCheck:!1})})]})}if(e==="assignment"){const a=Fm(t),l=kA(o),d=!l.some(f=>f.id===a.status);return s.jsxs("div",{className:"space-y-3",children:[s.jsxs(bu,{children:[s.jsx(Ut,{label:"Assignment title",children:s.jsx("input",{value:a.title,onChange:f=>{const p=f.target.value,h={title:p};r&&(a.slug===Pr(a.title)||!a.slug.trim())&&(h.slug=Pr(p)),n(Qt(e,t,h))},className:"editor-input"})}),s.jsx(Ut,{label:"Slug",children:s.jsxs("div",{className:"space-y-2",children:[s.jsx("input",{value:a.slug,disabled:!r,onChange:f=>n(Qt(e,t,{slug:Pr(f.target.value)})),className:`editor-input ${r?"":"editor-input-disabled"}`}),s.jsx("p",{className:"text-xs leading-5 text-muted-foreground",children:r?"The slug becomes the assignment folder name and URL. It is auto-generated from the title until you change it, and it cannot be renamed after creation.":"The slug is locked after creation because assignment paths and dependency references use it as a stable identifier."})]})}),s.jsx(Ut,{label:"Status",children:s.jsxs("select",{value:a.status,onChange:f=>n(Qt(e,t,{status:f.target.value})),className:"editor-input",children:[d?s.jsx("option",{value:a.status,children:So(o,a.status)}):null,l.map(f=>s.jsx("option",{value:f.id,children:f.label},f.id))]})}),s.jsx(Ut,{label:"Priority",children:s.jsxs("select",{value:a.priority,onChange:f=>n(Qt(e,t,{priority:f.target.value})),className:"editor-input",children:[s.jsx("option",{value:"low",children:"Low"}),s.jsx("option",{value:"medium",children:"Medium"}),s.jsx("option",{value:"high",children:"High"}),s.jsx("option",{value:"critical",children:"Critical"})]})}),s.jsx(Ut,{label:"Assignee",children:s.jsx("input",{value:a.assignee,onChange:f=>n(Qt(e,t,{assignee:f.target.value})),placeholder:"Agent name",className:"editor-input"})}),s.jsx(Ut,{label:"Depends on",className:"md:col-span-2",children:s.jsx("input",{value:a.dependsOn,onChange:f=>n(Qt(e,t,{dependsOn:f.target.value})),placeholder:"Comma-separated assignment slugs",className:"editor-input"})}),s.jsx(Ut,{label:"Links",className:"md:col-span-2",children:s.jsx("input",{value:a.links,onChange:f=>n(Qt(e,t,{links:f.target.value})),placeholder:"Comma-separated: projectSlug/assignmentSlug",className:"editor-input"})}),s.jsx(Ut,{label:"Blocked reason",className:"md:col-span-2",children:s.jsx("input",{value:a.blockedReason,onChange:f=>n(Qt(e,t,{blockedReason:f.target.value})),placeholder:"Read-only unless the assignment is actually blocked",className:"editor-input"})}),s.jsx(Ut,{label:"Tags",className:"md:col-span-2",children:s.jsx("input",{value:a.tags,onChange:f=>n(Qt(e,t,{tags:f.target.value})),placeholder:"Comma-separated tags",className:"editor-input"})})]}),s.jsx(Ut,{label:"Assignment body",children:s.jsx("textarea",{value:a.body,onChange:f=>n(Qt(e,t,{body:f.target.value})),className:"editor-textarea",spellCheck:!1})})]})}if(e==="plan"){const a=zm(t);return s.jsxs("div",{className:"space-y-3",children:[s.jsxs(bu,{children:[s.jsx(Ut,{label:"Assignment",children:s.jsx("input",{value:a.assignment,disabled:!0,className:"editor-input editor-input-disabled"})}),s.jsx(Ut,{label:"Plan status",children:s.jsxs("select",{value:a.status,onChange:l=>n(Qt(e,t,{status:l.target.value})),className:"editor-input",children:[s.jsx("option",{value:"draft",children:"Draft"}),s.jsx("option",{value:"approved",children:"Approved"}),s.jsx("option",{value:"in_progress",children:"In Progress"}),s.jsx("option",{value:"completed",children:"Completed"})]})})]}),s.jsx(Ut,{label:"Plan body",children:s.jsx("textarea",{value:a.body,onChange:l=>n(Qt(e,t,{body:l.target.value})),className:"editor-textarea",spellCheck:!1})})]})}if(e==="scratchpad"){const a=Bm(t);return s.jsxs("div",{className:"space-y-3",children:[s.jsx(bu,{children:s.jsx(Ut,{label:"Assignment",children:s.jsx("input",{value:a.assignment,disabled:!0,className:"editor-input editor-input-disabled"})})}),s.jsx(Ut,{label:"Scratchpad body",children:s.jsx("textarea",{value:a.body,onChange:l=>n(Qt(e,t,{body:l.target.value})),className:"editor-textarea",spellCheck:!1})})]})}if(e==="memory"||e==="resource"){const a=e==="memory"?f0(t):C_(t),l=e==="memory"?"Memory body":"Resource body";return s.jsxs("div",{className:"space-y-3",children:[s.jsx(Ut,{label:l,children:s.jsx("textarea",{value:a.body,onChange:d=>n(Qt(e,t,{body:d.target.value})),className:"editor-textarea",spellCheck:!1})}),s.jsx("p",{className:"text-xs text-muted-foreground/80",children:"Frontmatter (name, scope/category, source, related assignments, tags) is preserved server-side on save."})]})}const i=Um(t);return s.jsxs("div",{className:"space-y-3",children:[s.jsxs(bu,{children:[s.jsx(Ut,{label:"Playbook name",children:s.jsx("input",{value:i.name,onChange:a=>{const l=a.target.value,d={name:l};r&&(i.slug===Pr(i.name)||!i.slug.trim())&&(d.slug=Pr(l)),n(Qt(e,t,d))},className:"editor-input"})}),s.jsx(Ut,{label:"Slug",children:s.jsxs("div",{className:"space-y-2",children:[s.jsx("input",{value:i.slug,disabled:!r,onChange:a=>n(Qt(e,t,{slug:Pr(a.target.value)})),className:`editor-input ${r?"":"editor-input-disabled"}`}),s.jsx("p",{className:"text-xs leading-5 text-muted-foreground",children:r?"The slug becomes the filename. It is auto-generated from the name until you change it.":"The slug is locked after creation because it is the filename."})]})}),s.jsx(Ut,{label:"Description",className:"md:col-span-2",children:s.jsx("input",{value:i.description,onChange:a=>n(Qt(e,t,{description:a.target.value})),placeholder:"One-line description of what this playbook does",className:"editor-input"})}),s.jsx(Ut,{label:"Tags",className:"md:col-span-2",children:s.jsx("input",{value:i.tags,onChange:a=>n(Qt(e,t,{tags:a.target.value})),placeholder:"Comma-separated tags",className:"editor-input"})}),s.jsx(Ut,{label:"When to use",className:"md:col-span-2",children:s.jsx("input",{value:i.whenToUse,onChange:a=>n(Qt(e,t,{whenToUse:a.target.value})),placeholder:"Describe when agents should apply this playbook",className:"editor-input"})})]}),s.jsx(Ut,{label:"Playbook rules",children:s.jsx("textarea",{value:i.body,onChange:a=>n(Qt(e,t,{body:a.target.value})),className:"editor-textarea",spellCheck:!1})})]})}function bu({children:e}){return s.jsx("div",{className:"grid gap-4 md:grid-cols-2",children:e})}function Ut({label:e,children:t,className:n}){return s.jsxs("label",{className:`block space-y-2 ${n??""}`,children:[s.jsx("span",{className:"text-sm font-medium text-foreground",children:e}),t]})}function uY({value:e,onChange:t}){const{data:n}=Sa(),r=(n==null?void 0:n.workspaces)??[];return s.jsx(Ut,{label:"Workspace",children:s.jsxs("select",{value:e,onChange:o=>t(o.target.value),className:"editor-input",children:[s.jsx("option",{value:"",children:"Ungrouped"}),r.map(o=>s.jsx("option",{value:o,children:o},o))]})})}function dY(e,t){switch(e){case"project":return Om(t).body;case"assignment":return Fm(t).body;case"plan":return zm(t).body;case"scratchpad":return Bm(t).body;case"playbook":return Um(t).body;case"memory":return f0(t).body;case"resource":return C_(t).body}}function fY(e,t){switch(e){case"project":{const n=Om(t);return[n.title.trim()?null:"Project title is required.",n.slug.trim()?null:"Project slug is required.",n.slug.trim()&&!Pp(n.slug)?"Project slug must be lowercase letters, numbers, and hyphens only.":null].filter(r=>!!r)}case"assignment":{const n=Fm(t);return[n.title.trim()?null:"Assignment title is required.",n.slug.trim()?null:"Assignment slug is required.",n.slug.trim()&&!Pp(n.slug)?"Assignment slug must be lowercase letters, numbers, and hyphens only.":null].filter(r=>!!r)}case"plan":return zm(t).assignment.trim()?[]:["Plan assignment is required."];case"scratchpad":return Bm(t).assignment.trim()?[]:["Scratchpad assignment is required."];case"playbook":{const n=Um(t);return[n.name.trim()?null:"Playbook name is required.",n.slug.trim()?null:"Playbook slug is required.",n.slug.trim()&&!Pp(n.slug)?"Playbook slug must be lowercase letters, numbers, and hyphens only.":null].filter(r=>!!r)}case"memory":case"resource":return[]}}function IN(){const e=Ht(),{workspace:t}=Vt(),n=pn(),[r,o]=m.useState(null),[i,a]=m.useState(!0),[l,d]=m.useState(!1),[f,p]=m.useState(null);m.useEffect(()=>{fetch("/api/templates/project").then(g=>g.json()).then(g=>{let y=g.content;t&&t!=="_ungrouped"&&(y=y.replace(/^(tags: \[\])$/m,`$1
622
+ workspace: ${t}`)),o(y),a(!1)}).catch(g=>{p(g.message),a(!1)})},[t]);async function h(g){d(!0),p(null);try{const y=await fetch("/api/projects",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:g})}),k=await y.json();if(!y.ok){p(k.error||`HTTP ${y.status}`),d(!1);return}e(`${n}/projects/${k.slug}`)}catch(y){p(y.message),d(!1);return}d(!1)}return i?s.jsx(jt,{label:"Loading project template…"}):f&&!r?s.jsx(Rt,{error:f}):s.jsx(Cc,{initialContent:r||"",documentType:"project",mode:"create",onSave:h,saving:l,error:f,title:"Create Project",description:"Projects hold the high-level objective, shared context, and human-authored overview. Put execution details in assignments instead of overloading project.md.",onCancel:()=>e(`${n}/projects`),helpTitle:"Project editing rules",helpBody:"Use this form for project intent, slug, tags, and overview content. If you ever need less common metadata, raw markdown mode still exposes the full file.",allowSlugEdit:!0})}function MN(){const{slug:e}=Vt(),t=pn(),n=Ht(),[r,o]=m.useState(null),[i,a]=m.useState(!0),[l,d]=m.useState(!1),[f,p]=m.useState(null);m.useEffect(()=>{fetch("/api/templates/assignment").then(g=>g.json()).then(g=>{o(g.content),a(!1)}).catch(g=>{p(g.message),a(!1)})},[]);async function h(g){if(!e){p("Project slug is required.");return}d(!0),p(null);try{const y=await fetch(`/api/projects/${e}/assignments`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:g})}),k=await y.json();if(!y.ok){p(k.error||`HTTP ${y.status}`),d(!1);return}n(`${t}/projects/${e}/assignments/${k.slug}`)}catch(y){p(y.message),d(!1);return}d(!1)}return i?s.jsx(jt,{label:"Loading assignment template…"}):f&&!r?s.jsx(Rt,{error:f}):s.jsx(Cc,{initialContent:r||"",documentType:"assignment",mode:"create",onSave:h,saving:l,error:f,title:"Create Assignment",description:"Assignments are the execution unit. Declare dependencies here, keep status pending until work starts, and use blocked later only for runtime obstacles.",onCancel:()=>n(e?`${t}/projects/${e}`:`${t}/projects`),helpTitle:"Assignment editing rules",helpBody:"Use structured fields for priority, assignee, dependencies, and tags. Status can be changed through lifecycle actions, kanban drag, or the status override.",allowSlugEdit:!0})}function LN(){const{workspace:e}=Vt(),t=pn(),n=Ht(),[r,o]=m.useState(null),[i,a]=m.useState(!0),[l,d]=m.useState(!1),[f,p]=m.useState(null);m.useEffect(()=>{const g=new URLSearchParams({standalone:"1"});e&&g.set("workspace",e),fetch(`/api/templates/assignment?${g.toString()}`).then(y=>y.json()).then(y=>{o(y.content),a(!1)}).catch(y=>{p(y.message),a(!1)})},[e]);async function h(g){var y;d(!0),p(null);try{const k=await fetch("/api/assignments",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:g})}),w=await k.json();if(!k.ok){p(w.error||`HTTP ${k.status}`),d(!1);return}const b=(y=w==null?void 0:w.assignment)==null?void 0:y.id;if(!b){p("Server did not return the new assignment id."),d(!1);return}n(`/assignments/${b}`)}catch(k){p(k.message),d(!1);return}d(!1)}return i?s.jsx(jt,{label:"Loading assignment template…"}):f&&!r?s.jsx(Rt,{error:f}):s.jsx(Cc,{initialContent:r||"",documentType:"assignment",mode:"create",onSave:h,saving:l,error:f,title:"Create Standalone Assignment",description:e?`Standalone assignments live outside any project. This one will be tagged with workspaceGroup: ${e} so it appears in this workspace's views.`:"Standalone assignments live outside any project. Add a workspaceGroup to make them appear in workspace-filtered views.",onCancel:()=>n(`${t}/assignments`),helpTitle:"Standalone assignment editing rules",helpBody:"No project field is needed (it must remain null). Use workspaceGroup to group with other workspace work. Status, priority, and tags work the same as project-nested assignments.",allowSlugEdit:!0})}function Ec({loadUrl:e,saveUrl:t,redirectTo:n,title:r,description:o,documentType:i,helpTitle:a,helpBody:l}){const d=Ht(),{data:f,loading:p,error:h}=C2(e),[g,y]=m.useState(!1),[k,w]=m.useState(null);async function b(j){y(!0),w(null);try{const N=await fetch(t,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:j})}),S=await N.json();if(!N.ok){w(S.error||`HTTP ${N.status}`),y(!1);return}d(n)}catch(N){w(N.message),y(!1);return}y(!1)}return p?s.jsx(jt,{label:`Loading ${r.toLowerCase()}…`}):h||!f?s.jsx(Rt,{error:h||`${r} is unavailable.`}):s.jsx(Cc,{initialContent:f.content,documentType:i,onSave:b,saving:g,error:k,title:r,description:o,onCancel:()=>d(n),helpTitle:a,helpBody:l})}function ON(){const{slug:e}=Vt(),t=pn(),n=e??"";return s.jsx(Ec,{loadUrl:`/api/projects/${n}/edit`,saveUrl:`/api/projects/${n}`,redirectTo:`${t}/projects/${n}`,title:"Edit Project",description:"Project edits change the human-authored source document. The structured form stays focused on title, slug, tags, and overview content.",documentType:"project",helpTitle:"Editable vs derived project fields",helpBody:"Project status remains derived from assignment state. If you need less common frontmatter fields, switch to raw markdown mode instead of expanding the structured form."})}function Dy(){const{slug:e,aslug:t,id:n}=Vt(),r=pn(),o=!!n,i=o?`/api/assignments/${n}/edit`:`/api/projects/${e}/assignments/${t}/edit`,a=o?`/api/assignments/${n}`:`/api/projects/${e}/assignments/${t}`,l=o?`/assignments/${n}`:`${r}/projects/${e}/assignments/${t}`;return s.jsx(Ec,{loadUrl:i,saveUrl:a,redirectTo:l,title:"Edit Assignment",description:"Edit assignment fields including status, priority, assignee, dependencies, and body.",documentType:"assignment",helpTitle:"Assignment editing",helpBody:"All fields are editable. Status can also be changed through lifecycle actions or kanban drag."})}function $y(){const{slug:e,aslug:t,id:n}=Vt(),r=pn(),o=!!n,i=o?`/api/assignments/${n}/plan/edit`:`/api/projects/${e}/assignments/${t}/plan/edit`,a=o?`/api/assignments/${n}/plan`:`/api/projects/${e}/assignments/${t}/plan`,l=o?`/assignments/${n}?tab=plan`:`${r}/projects/${e}/assignments/${t}?tab=plan`;return s.jsx(Ec,{loadUrl:i,saveUrl:a,redirectTo:l,title:"Edit Plan",description:"Plans are separate from assignment status, so keep implementation steps here instead of overloading the assignment body.",documentType:"plan",helpTitle:"Plan status is separate",helpBody:"Plan status tracks the plan document itself. It does not replace the assignment lifecycle state."})}function Iy(){const{slug:e,aslug:t,id:n}=Vt(),r=pn(),o=!!n,i=o?`/api/assignments/${n}/scratchpad/edit`:`/api/projects/${e}/assignments/${t}/scratchpad/edit`,a=o?`/api/assignments/${n}/scratchpad`:`/api/projects/${e}/assignments/${t}/scratchpad`,l=o?`/assignments/${n}?tab=scratchpad`:`${r}/projects/${e}/assignments/${t}?tab=scratchpad`;return s.jsx(Ec,{loadUrl:i,saveUrl:a,redirectTo:l,title:"Edit Scratchpad",description:"Scratchpad is the assignment’s working memory surface for notes, experiments, and temporary context.",documentType:"scratchpad",helpTitle:"Scratchpad usage",helpBody:"Scratchpad is for transient notes. Keep canonical objective and lifecycle data in assignment.md and any active plan files (plan.md, plan-v2.md, ...)."})}function T_({loadUrl:e,saveUrl:t,redirectTo:n,title:r,description:o,helpTitle:i,helpBody:a}){const l=Ht(),{data:d,loading:f,error:p}=C2(e),[h,g]=m.useState(""),[y,k]=m.useState(""),[w,b]=m.useState(!1),[j,N]=m.useState(null);async function S(){b(!0),N(null);try{const C=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:h,body:y})}),D=await C.json();if(!C.ok){N(D.error||`HTTP ${C.status}`),b(!1);return}l(n)}catch(C){N(C.message),b(!1);return}b(!1)}return f?s.jsx(jt,{label:`Loading ${r.toLowerCase()}…`}):p||!d?s.jsx(Rt,{error:p||`${r} is unavailable.`}):s.jsxs("div",{className:"space-y-4",children:[s.jsx(Qe,{title:r,description:o,children:s.jsxs("div",{className:"space-y-4",children:[s.jsxs("label",{className:"block space-y-2",children:[s.jsx("span",{className:"text-sm font-medium text-foreground",children:"Entry title"}),s.jsx("input",{value:h,onChange:C=>g(C.target.value),placeholder:"Optional title",className:"editor-input"})]}),s.jsxs("label",{className:"block space-y-2",children:[s.jsx("span",{className:"text-sm font-medium text-foreground",children:"Entry body"}),s.jsx("textarea",{value:y,onChange:C=>k(C.target.value),className:"editor-textarea",spellCheck:!1})]}),j?s.jsx("p",{className:"rounded-md border border-error-foreground/30 bg-error px-4 py-3 text-sm text-error-foreground",children:j}):null,s.jsxs("div",{className:"flex flex-wrap gap-2",children:[s.jsx("button",{type:"button",onClick:()=>l(n),className:"shell-action",children:"Cancel"}),s.jsx("button",{type:"button",onClick:S,disabled:w||!y.trim(),className:"shell-action shell-action--cta disabled:cursor-not-allowed disabled:opacity-50",children:w?"Appending…":"Append Entry"})]})]})}),s.jsx(Qe,{title:"Current Document",children:s.jsx(xn,{content:d.content.replace(/^---[\s\S]*?---\n?/,""),emptyState:"No existing content."})})]})}function My(){const{slug:e,aslug:t,id:n}=Vt(),r=pn(),o=!!n,i=o?`/api/assignments/${n}/handoff/edit`:`/api/projects/${e}/assignments/${t}/handoff/edit`,a=o?`/api/assignments/${n}/handoff/entries`:`/api/projects/${e}/assignments/${t}/handoff/entries`,l=o?`/assignments/${n}?tab=handoff`:`${r}/projects/${e}/assignments/${t}?tab=handoff`;return s.jsx(T_,{loadUrl:i,saveUrl:a,redirectTo:l,title:"Append Handoff Entry",description:"Add a new handoff without rewriting previous history.",helpTitle:"Append-only handoff history",helpBody:"Handoff log entries preserve the baton-passing trail between sessions and agents. Add a new entry instead of editing older ones."})}function Ly(){const{slug:e,aslug:t,id:n}=Vt(),r=pn(),o=!!n,i=o?`/api/assignments/${n}/decision-record/edit`:`/api/projects/${e}/assignments/${t}/decision-record/edit`,a=o?`/api/assignments/${n}/decision-record/entries`:`/api/projects/${e}/assignments/${t}/decision-record/entries`,l=o?`/assignments/${n}?tab=decisions`:`${r}/projects/${e}/assignments/${t}?tab=decisions`;return s.jsx(T_,{loadUrl:i,saveUrl:a,redirectTo:l,title:"Append Decision Entry",description:"Record a new decision and rationale without editing prior entries.",helpTitle:"Append-only decision history",helpBody:"Decision records should accumulate over time so the implementation rationale remains auditable and reviewable."})}function FN(){const{workspace:e}=Vt(),{data:t}=Zs(),{data:n,loading:r,error:o,refetch:i}=Fv(),{toast:a,showToast:l,dismissToast:d}=wr(),[f,p]=m.useState(!1),[h,g]=m.useState(""),[y,k]=m.useState(!1),[w,b]=m.useState(null),[j,N]=m.useState(!1),S=or();m.useEffect(()=>{const _=S.hash.match(/^#server-(.+)/);if(!_)return;const U=decodeURIComponent(_[1]),I=document.querySelector(`[data-server-name="${window.CSS.escape(U)}"]`);if(!I)return;I.scrollIntoView({block:"nearest"}),I.classList.add("ring-2","ring-primary/60");const F=window.setTimeout(()=>I.classList.remove("ring-2","ring-primary/60"),1500);return()=>window.clearTimeout(F)},[S.hash,n]);const C=(()=>{if(!e||!n)return(n==null?void 0:n.sessions)??[];if(!t)return[];const _=new Set(t.filter(U=>e==="_ungrouped"?U.workspace===null:U.workspace===e).map(U=>U.slug));return n.sessions.filter(U=>U.windows.some(I=>I.panes.some(F=>F.assignment&&F.assignment.project!==null&&_.has(F.assignment.project))))})();async function D(_){if(_.preventDefault(),!!h.trim())try{const U=await fetch("/api/servers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:h.trim()})});if(!U.ok){const I=await U.json().catch(()=>null);l((I==null?void 0:I.error)||`HTTP ${U.status}`,"error");return}g(""),p(!1),i(),l(`Tracking "${h.trim()}"`,"success")}catch(U){l(U instanceof Error?U.message:"Failed to register session","error")}}async function T(){k(!0);try{const _=await fetch("/api/servers/refresh",{method:"POST"});if(!_.ok){const U=await _.json().catch(()=>null);l((U==null?void 0:U.error)||`HTTP ${_.status}`,"error");return}i()}catch(_){l(_ instanceof Error?_.message:"Failed to refresh sessions","error")}finally{k(!1)}}async function R(_){N(!0);try{const U=await fetch(`/api/servers/${encodeURIComponent(_)}`,{method:"DELETE"});if(!U.ok){const I=await U.json().catch(()=>null);l((I==null?void 0:I.error)||`HTTP ${U.status}`,"error");return}b(null),i(),l(`Stopped tracking "${_}"`,"success")}catch(U){l(U instanceof Error?U.message:"Failed to remove session","error")}finally{N(!1)}}async function $(_){try{const U=await fetch(`/api/servers/${encodeURIComponent(_)}/refresh`,{method:"POST"});if(!U.ok){const I=await U.json().catch(()=>null);l((I==null?void 0:I.error)||`HTTP ${U.status}`,"error");return}i()}catch(U){l(U instanceof Error?U.message:"Failed to refresh session","error")}}return r?s.jsx(jt,{label:"Loading servers…"}):o?s.jsx(Rt,{error:o}):n?n.tmuxAvailable?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[f?s.jsxs("form",{onSubmit:D,className:"flex items-center gap-2",children:[s.jsx("input",{type:"text",value:h,onChange:_=>g(_.target.value),placeholder:"tmux session name",className:"editor-input text-sm",autoFocus:!0}),s.jsx("button",{type:"submit",className:"shell-action",children:"Add"}),s.jsx("button",{type:"button",className:"shell-action",onClick:()=>p(!1),children:"Cancel"})]}):s.jsxs("button",{className:"shell-action",onClick:()=>p(!0),children:[s.jsx(It,{className:"h-3.5 w-3.5"}),"Track Session"]}),s.jsxs("button",{className:"shell-action",onClick:T,disabled:y,children:[s.jsx(ZE,{className:`h-3.5 w-3.5 ${y?"animate-spin":""}`}),"Refresh All"]})]}),C.length===0?s.jsx(Tt,{title:"No sessions tracked",description:"Register a tmux session to start tracking your dev servers."}):s.jsx("div",{className:"mt-4 space-y-4",children:C.map(_=>s.jsx(pY,{session:_,onRefresh:()=>$(_.name),onRemove:()=>b(_.name),onRefetch:i},_.name))}),s.jsx(Ri,{open:w!==null,title:"Stop tracking session?",description:`Remove "${w??""}" from tracked servers. This does not stop the tmux session itself.`,confirmLabel:"Stop Tracking",destructive:!0,loading:j,onOpenChange:_=>{!_&&!j&&b(null)},onConfirm:async()=>{w&&await R(w)}}),s.jsx(Hr,{toast:a,onDismiss:d})]}):s.jsx(s.Fragment,{children:s.jsxs("div",{className:"surface-panel mt-4 flex flex-col items-center gap-3 py-12 text-center",children:[s.jsx(Al,{className:"h-10 w-10 text-muted-foreground/40"}),s.jsx("p",{className:"text-sm font-medium text-foreground",children:"tmux is not installed"}),s.jsxs("p",{className:"max-w-md text-sm text-muted-foreground",children:["Server tracking requires tmux. Install it with ",s.jsx("code",{className:"rounded bg-muted px-1.5 py-0.5 text-xs",children:"brew install tmux"})," to get started."]})]})}):null}function pY({session:e,onRefresh:t,onRemove:n,onRefetch:r}){return s.jsxs("div",{className:"surface-panel","data-server-name":e.name,children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx($v,{className:"h-4 w-4 text-muted-foreground"}),s.jsx("span",{className:"text-sm font-semibold text-foreground",children:e.name}),s.jsx("span",{className:`inline-flex items-center rounded-full px-2 py-0.5 text-xs font-medium ${e.alive?"border border-success-foreground/30 bg-success text-success-foreground":"border border-error-foreground/30 bg-error text-error-foreground"}`,children:e.alive?"alive":"dead"}),s.jsxs("span",{className:"text-xs text-muted-foreground",children:["Last refreshed: ",new Date(e.lastRefreshed).toLocaleString()]})]}),s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("button",{className:"shell-action",onClick:t,title:"Refresh",children:s.jsx(ZE,{className:"h-3.5 w-3.5"})}),s.jsx("button",{className:"shell-action",onClick:n,title:"Remove",children:s.jsx(bn,{className:"h-3.5 w-3.5"})})]})]}),e.alive&&e.windows.length>0&&s.jsx("div",{className:"mt-3 space-y-3",children:e.windows.map(o=>s.jsxs("div",{children:[s.jsxs("p",{className:"mb-1.5 text-xs font-medium uppercase tracking-wider text-muted-foreground",children:["Window ",o.index,": ",o.name]}),s.jsx("div",{className:"space-y-1.5",children:o.panes.map(i=>s.jsx(hY,{pane:i,sessionName:e.name,windowIndex:o.index,onRefetch:r},`${o.index}:${i.index}`))})]},o.index))}),!e.alive&&s.jsxs("div",{className:"mt-3 flex items-center gap-2 text-sm text-muted-foreground",children:[s.jsx(s4,{className:"h-4 w-4"}),s.jsx("span",{children:e.kind==="process"?"Process no longer running":"Session no longer exists"})]})]})}function hY({pane:e,sessionName:t,windowIndex:n,onRefetch:r}){const o=pn(),i=e.cwd.replace(/^\/Users\/[^/]+/,"~");return s.jsxs("div",{className:"flex items-center gap-3 rounded-md border border-border/40 bg-background/60 px-3 py-2 text-sm",children:[s.jsxs("span",{className:"shrink-0 font-mono text-xs text-muted-foreground/60",children:[":",e.index]}),s.jsx("span",{className:"shrink-0 rounded bg-muted/60 px-1.5 py-0.5 font-mono text-xs",children:e.command}),s.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1.5 text-xs text-muted-foreground",children:[s.jsx("span",{className:"block min-w-0 truncate",title:e.cwd,children:i}),s.jsx(Zr,{value:e.cwd})]}),e.branch&&s.jsxs("span",{className:"flex shrink-0 items-center gap-1 text-xs text-muted-foreground",children:[s.jsx(Pv,{className:"h-3 w-3"}),e.branch,e.worktree&&s.jsx("span",{className:"rounded bg-status-in-progress px-1 py-0.5 text-[10px] font-medium text-status-in-progress-foreground",children:"worktree"})]}),e.ports.length>0&&s.jsx("div",{className:"flex shrink-0 items-center gap-1.5",children:e.urls.map(a=>s.jsxs("a",{href:a,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 rounded border border-primary/30 bg-primary/5 px-1.5 py-0.5 text-xs font-medium text-primary hover:bg-primary/10 dark:border-primary/40 dark:bg-primary/10 dark:hover:bg-primary/20",children:[a.replace("http://localhost:",":"),s.jsx(uc,{className:"h-2.5 w-2.5"})]},a))}),s.jsx("div",{className:"ml-auto shrink-0",children:e.assignment?s.jsxs(Ie,{to:e.assignment.project===null?`/assignments/${e.assignment.slug}`:`${o}/projects/${e.assignment.project}/assignments/${e.assignment.slug}`,className:"inline-flex items-center gap-1 rounded border border-primary/30 bg-primary/10 px-1.5 py-0.5 text-xs font-medium text-primary hover:bg-primary/20",children:[s.jsx(KL,{className:"h-2.5 w-2.5"}),e.assignment.title,e.assignment.project===null?s.jsx("span",{className:"ml-1 rounded bg-muted px-1 py-0.5 text-[9px] uppercase tracking-wide text-muted-foreground",children:"Standalone"}):null]}):s.jsx("span",{className:"text-xs text-muted-foreground/40",children:"unlinked"})})]})}function R_(e){return e<60?`${e}s`:e<3600?`${Math.round(e/60)}m`:e<86400?`${Math.round(e/3600)}h`:`${Math.round(e/86400)}d`}function mY(e,t){const n=Date.parse(e),r=Math.floor((n-t)/1e3);return Number.isNaN(r)?"–":r<=0?"expired":R_(r)}function gY(e){switch(e){case"idle":return"bg-green-500/15 text-green-400 border-green-500/30";case"leased":return"bg-amber-500/15 text-amber-400 border-amber-500/30";case"retired":return"bg-zinc-500/15 text-zinc-400 border-zinc-500/30"}}function xY(e){if(!e)return null;try{return JSON.parse(e)}catch{return null}}function zN(){const{data:e,loading:t,error:n,refetch:r}=E2(),[o,i]=m.useState(()=>Date.now()),[a,l]=m.useState(null),[d,f]=m.useState(!1);if(m.useEffect(()=>{const h=window.setInterval(()=>i(Date.now()),1e3);return()=>window.clearInterval(h)},[]),t)return s.jsx(jt,{label:"Loading inventories…"});if(n)return s.jsx(Rt,{title:"Could not load inventories",error:n,action:s.jsx("button",{type:"button",onClick:r,className:"rounded border px-3 py-1 text-sm",children:"Retry"})});if(!e||e.inventories.length===0)return s.jsx(Tt,{title:"No inventories yet",description:"Create one with `syntaur lease create-inventory <slug> --kind <kind>`, then add members with `syntaur lease member add <slug> <id>`."});async function p(){if(a){f(!0);try{const h=await fetch(`/api/leases/${encodeURIComponent(a.slug)}/force-release/${encodeURIComponent(a.lease.lease_id)}`,{method:"POST"});if(!h.ok){const g=await h.json().catch(()=>null);throw new Error((g==null?void 0:g.error)??`HTTP ${h.status}`)}r(),l(null)}catch(h){window.alert(h instanceof Error?`Force release failed: ${h.message}`:"Force release failed")}finally{f(!1)}}}return s.jsxs("div",{className:"space-y-6",children:[s.jsx("div",{className:"flex items-start justify-between",children:s.jsxs("div",{children:[s.jsx("h1",{className:"text-2xl font-semibold",children:"Inventories"}),s.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:"Claimable shared resources (dev envs, test DBs, named locks, …). Global in v1 — the same set appears on every workspace."})]})}),s.jsx("div",{className:"grid gap-4",children:e.inventories.map(h=>s.jsx(yY,{detail:h,now:o,onForceRelease:g=>l({slug:h.inventory.slug,lease:g})},h.inventory.slug))}),s.jsx(Ri,{open:a!==null,title:"Force release this lease?",description:a?`This will revoke lease ${a.lease.lease_id} and (if it's still the current holder) free member ${a.lease.member_id}. Any agent still using this lease will see a stale-lease error on its next CLI call.`:"",confirmLabel:"Force release",destructive:!0,loading:d,onConfirm:p,onOpenChange:h=>{h||l(null)}})]})}function yY({detail:e,now:t,onForceRelease:n}){const{inventory:r,members:o,active_leases:i}=e,a=o.filter(d=>d.status==="idle").length,l=o.filter(d=>d.status==="leased").length;return s.jsxs("div",{className:"rounded-lg border bg-card p-4",children:[s.jsxs("div",{className:"flex items-start justify-between",children:[s.jsxs("div",{children:[s.jsxs("h2",{className:"text-lg font-semibold",children:[s.jsx(Tv,{className:"mr-2 inline h-4 w-4 text-muted-foreground"}),r.display_name??r.slug]}),s.jsxs("p",{className:"mt-0.5 text-xs text-muted-foreground",children:[s.jsx("code",{className:"font-mono",children:r.slug})," · kind=",r.kind," · default TTL=",R_(r.default_ttl_s)]})]}),s.jsx("div",{className:"text-right text-xs text-muted-foreground",children:s.jsxs("div",{children:[a," idle · ",l," leased · ",o.length," total"]})})]}),s.jsx("div",{className:"mt-4 grid gap-2 sm:grid-cols-2 lg:grid-cols-3",children:o.map(d=>s.jsx(bY,{member:d},d.member_id))}),i.length>0&&s.jsxs("div",{className:"mt-4",children:[s.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:"Active leases"}),s.jsx("div",{className:"mt-2 space-y-2",children:i.map(d=>s.jsx(vY,{lease:d,now:t,onForceRelease:()=>n(d)},d.lease_id))})]})]})}function bY({member:e}){const t=xY(e.metadata_json);return s.jsxs("div",{className:"rounded-md border bg-muted/40 px-3 py-2 text-sm",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"font-mono",children:e.member_id}),s.jsx("span",{className:`rounded border px-1.5 py-0.5 text-xs ${gY(e.status)}`,children:e.status})]}),t&&s.jsx("div",{className:"mt-1 text-xs text-muted-foreground",children:Object.entries(t).map(([n,r])=>s.jsxs("div",{className:"truncate",children:[s.jsx("span",{className:"font-mono",children:n}),"=",s.jsx("span",{className:"font-mono",children:String(r)})]},n))})]})}function vY({lease:e,now:t,onForceRelease:n}){return s.jsxs("div",{className:"flex items-center justify-between rounded border bg-muted/20 px-3 py-2 text-sm",children:[s.jsx("div",{className:"min-w-0 flex-1",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("span",{className:"font-mono text-xs text-muted-foreground",children:[e.lease_id.slice(0,8),"…"]}),s.jsx("span",{className:"font-mono",children:e.member_id}),e.requested_for&&s.jsxs("span",{className:"text-xs text-muted-foreground",children:["for ",e.requested_for]})]})}),s.jsxs("div",{className:"ml-3 flex items-center gap-3",children:[s.jsxs("span",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[s.jsx(AL,{className:"h-3 w-3"}),mY(e.expires_at,t)]}),s.jsxs("button",{type:"button",onClick:n,className:"flex items-center gap-1 rounded border border-destructive/40 px-2 py-1 text-xs text-destructive hover:bg-destructive/10",children:[s.jsx(a4,{className:"h-3 w-3"}),"Force release"]})]})]})}function wY(e){switch(e.kind){case"at":return`at ${e.at}`;case"in":return`in ${Math.round((e.durationMs??0)/1e3)}s`;case"cron":return`cron ${e.expr}${e.tz?` (${e.tz})`:""}`;case"after-reset":return`after ${e.provider} reset`;case"when-status":return`when ${e.assignmentId??"this"} → ${e.status}`;case"when-plan-lands":return`when ${e.assignmentId??"this"} plan lands`;default:return e.kind}}async function jY(){const e=await fetch("/api/schedules");if(!e.ok)throw new Error(`HTTP ${e.status}`);return(await e.json()).schedules}async function kY(e){const t=await fetch("/api/schedules",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),n=await t.json().catch(()=>null);if(!t.ok)throw new Error((n==null?void 0:n.error)??`HTTP ${t.status}`);return n.schedule}async function SY(e){const t=await fetch(`/api/schedules/${encodeURIComponent(e)}/cancel`,{method:"POST"});if(!t.ok){const n=await t.json().catch(()=>null);throw new Error((n==null?void 0:n.error)??`HTTP ${t.status}`)}}function NY(){const[e,t]=m.useState(null),[n,r]=m.useState(!0),[o,i]=m.useState(null),a=m.useCallback(async()=>{try{t(await jY()),i(null)}catch(l){i(l instanceof Error?l.message:"Failed to fetch schedules")}finally{r(!1)}},[]);return m.useEffect(()=>{a()},[a]),hc(l=>{l.type==="schedules-updated"&&a()}),{data:e,loading:n,error:o,refetch:a}}const CY=[{value:"cron",label:"Cron expression"},{value:"at",label:"At a timestamp"},{value:"in",label:"After a delay"},{value:"after-reset",label:"After quota reset"},{value:"when-status",label:"When assignment reaches status"},{value:"when-plan-lands",label:"When plan lands"}];function EY({open:e,onOpenChange:t,onCreated:n}){const[r,o]=m.useState(""),[i,a]=m.useState("claude"),[l,d]=m.useState("cron"),[f,p]=m.useState(!0),[h,g]=m.useState(""),[y,k]=m.useState(""),[w,b]=m.useState("0 3 * * *"),[j,N]=m.useState(""),[S,C]=m.useState(""),[D,T]=m.useState("5"),[R,$]=m.useState("claude"),[_,U]=m.useState(""),[I,F]=m.useState("rolling-5h"),[M,A]=m.useState("ready_to_implement"),[L,z]=m.useState(""),[W,V]=m.useState(!1),[K,O]=m.useState(null);function B(){switch(l){case"cron":return{kind:l,expr:w,...j?{tz:j}:{}};case"at":return{kind:l,at:S};case"in":return{kind:l,durationMs:Math.round(Number(D)*36e5),anchorIso:new Date().toISOString()};case"after-reset":return{kind:l,provider:R,anchor:{windowStartIso:_||new Date().toISOString(),windowKind:I}};case"when-status":return{kind:l,status:M,...L?{assignmentId:L}:{}};case"when-plan-lands":return{kind:l,...L?{assignmentId:L}:{}}}}async function G(){V(!0),O(null);try{const te={assignmentId:r.trim(),agentId:i.trim(),trigger:B(),unattended:f,terminalPreference:h.trim()||null,promptTemplate:y.trim()||null};if(!te.assignmentId)throw new Error("Assignment id is required");await kY(te),n(),t(!1)}catch(te){O(te instanceof Error?te.message:"Create failed")}finally{V(!1)}}const H="w-full rounded border bg-background px-2 py-1 text-sm",Q="block text-xs font-medium text-muted-foreground";return s.jsx(Ln,{open:e,onOpenChange:t,children:s.jsxs(jn,{className:"max-h-[90vh] overflow-y-auto",children:[s.jsxs(er,{className:"flex-row items-center justify-between space-y-0",children:[s.jsx(kn,{children:"New schedule"}),s.jsx(jT,{className:"text-muted-foreground transition hover:text-foreground","aria-label":"Close",children:s.jsx(Cd,{className:"h-4 w-4"})})]}),s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{children:[s.jsx("label",{className:Q,children:"Assignment id / slug"}),s.jsx("input",{className:H,value:r,onChange:te=>o(te.target.value),placeholder:"scheduled-agents"})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsxs("div",{children:[s.jsx("label",{className:Q,children:"Agent"}),s.jsx("input",{className:H,value:i,onChange:te=>a(te.target.value)})]}),s.jsxs("div",{children:[s.jsx("label",{className:Q,children:"Terminal (optional)"}),s.jsx("input",{className:H,value:h,onChange:te=>g(te.target.value),placeholder:"default"})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:Q,children:"Trigger"}),s.jsx("select",{className:H,value:l,onChange:te=>d(te.target.value),children:CY.map(te=>s.jsx("option",{value:te.value,children:te.label},te.value))})]}),l==="cron"&&s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsxs("div",{children:[s.jsx("label",{className:Q,children:"Cron expr"}),s.jsx("input",{className:H,value:w,onChange:te=>b(te.target.value)})]}),s.jsxs("div",{children:[s.jsx("label",{className:Q,children:"Timezone (optional)"}),s.jsx("input",{className:H,value:j,onChange:te=>N(te.target.value),placeholder:"local"})]})]}),l==="at"&&s.jsxs("div",{children:[s.jsx("label",{className:Q,children:"ISO timestamp"}),s.jsx("input",{className:H,value:S,onChange:te=>C(te.target.value),placeholder:"2026-06-16T03:00:00Z"})]}),l==="in"&&s.jsxs("div",{children:[s.jsx("label",{className:Q,children:"Delay (hours)"}),s.jsx("input",{className:H,type:"number",value:D,onChange:te=>T(te.target.value)})]}),l==="after-reset"&&s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsxs("div",{children:[s.jsx("label",{className:Q,children:"Provider"}),s.jsxs("select",{className:H,value:R,onChange:te=>$(te.target.value),children:[s.jsx("option",{value:"claude",children:"claude"}),s.jsx("option",{value:"codex",children:"codex"})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:Q,children:"Window kind"}),s.jsxs("select",{className:H,value:I,onChange:te=>F(te.target.value),children:[s.jsx("option",{value:"rolling-5h",children:"rolling-5h"}),s.jsx("option",{value:"weekly",children:"weekly"})]})]}),s.jsxs("div",{className:"col-span-2",children:[s.jsx("label",{className:Q,children:"Window start (optional ISO)"}),s.jsx("input",{className:H,value:_,onChange:te=>U(te.target.value),placeholder:"now"})]})]}),l==="when-status"&&s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsxs("div",{children:[s.jsx("label",{className:Q,children:"Status"}),s.jsx("input",{className:H,value:M,onChange:te=>A(te.target.value)})]}),s.jsxs("div",{children:[s.jsx("label",{className:Q,children:"Watch assignment (optional)"}),s.jsx("input",{className:H,value:L,onChange:te=>z(te.target.value),placeholder:"this assignment"})]})]}),l==="when-plan-lands"&&s.jsxs("div",{children:[s.jsx("label",{className:Q,children:"Watch assignment (optional)"}),s.jsx("input",{className:H,value:L,onChange:te=>z(te.target.value),placeholder:"this assignment"})]}),s.jsxs("div",{children:[s.jsx("label",{className:Q,children:"Prompt template (optional)"}),s.jsx("input",{className:H,value:y,onChange:te=>k(te.target.value),placeholder:"plan @assignment"})]}),s.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[s.jsx("input",{type:"checkbox",checked:f,onChange:te=>p(te.target.checked)}),"Unattended (hard limits + kill switch apply)"]}),K&&s.jsx("p",{className:"text-sm text-destructive",children:K})]}),s.jsxs("div",{className:"mt-5 flex justify-end gap-2",children:[s.jsx("button",{type:"button",onClick:()=>t(!1),className:"rounded border px-3 py-1 text-sm",children:"Cancel"}),s.jsx("button",{type:"button",onClick:G,disabled:W,className:"rounded bg-primary px-3 py-1 text-sm text-primary-foreground disabled:opacity-50",children:W?"Creating…":"Create"})]})]})})}const TY=new Set(["completed","failed","launch_failed","cancelled","killed"]);function RY(e){return e==="running"?"bg-green-500/15 text-green-400 border-green-500/30":e==="eligible"?"bg-blue-500/15 text-blue-400 border-blue-500/30":e==="held"?"bg-amber-500/15 text-amber-400 border-amber-500/30":e==="launch_failed"||e==="failed"||e==="killed"?"bg-red-500/15 text-red-400 border-red-500/30":"bg-zinc-500/15 text-zinc-400 border-zinc-500/30"}function AY(){const{data:e,loading:t,error:n,refetch:r}=NY(),[o,i]=m.useState(!1);if(t)return s.jsx(jt,{label:"Loading schedules…"});if(n)return s.jsx(Rt,{title:"Could not load schedules",error:n,action:s.jsx("button",{type:"button",onClick:r,className:"rounded border px-3 py-1 text-sm",children:"Retry"})});async function a(l){try{await SY(l.id),r()}catch(d){window.alert(d instanceof Error?`Cancel failed: ${d.message}`:"Cancel failed")}}return s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"flex items-start justify-between",children:[s.jsxs("div",{children:[s.jsx("h1",{className:"text-2xl font-semibold",children:"Schedules"}),s.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:"Run work on an assignment unattended — on a clock, after a quota reset, or when an assignment reaches a status. The scheduler tick is the sole authority; this page calls the same CLI verbs."})]}),s.jsxs("button",{type:"button",onClick:()=>i(!0),className:"flex items-center gap-1 rounded bg-primary px-3 py-1.5 text-sm text-primary-foreground",children:[s.jsx(It,{className:"h-4 w-4"}),"New schedule"]})]}),!e||e.length===0?s.jsx(Tt,{title:"No schedules yet",description:"Create one above, or with `syntaur schedule create --assignment <id> --cron '0 3 * * *'`."}):s.jsx("div",{className:"grid gap-2",children:e.map(l=>s.jsxs("div",{className:"flex items-center justify-between rounded-lg border bg-card p-3",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(qE,{className:"h-4 w-4 text-muted-foreground"}),s.jsx("span",{className:"font-mono text-sm",children:l.assignmentId}),s.jsx("span",{className:`rounded border px-1.5 py-0.5 text-xs ${RY(l.attempt.state)}`,children:l.attempt.state}),!l.unattended&&s.jsx("span",{className:"text-xs text-muted-foreground",children:"interactive"})]}),s.jsxs("div",{className:"mt-0.5 text-xs text-muted-foreground",children:[wY(l.trigger)," · agent ",s.jsx("code",{className:"font-mono",children:l.agentId}),l.attempt.lastError&&s.jsxs("span",{className:"text-destructive",children:[" · ",l.attempt.lastError]})]})]}),!TY.has(l.attempt.state)&&s.jsxs("button",{type:"button",onClick:()=>a(l),className:"flex items-center gap-1 rounded border border-destructive/40 px-2 py-1 text-xs text-destructive hover:bg-destructive/10",children:[s.jsx(jL,{className:"h-3 w-3"}),"Cancel"]})]},l.id))}),s.jsx(EY,{open:o,onOpenChange:i,onCreated:r})]})}const PY={"7d":"7 days","30d":"30 days","90d":"90 days",all:"All time",custom:"Custom"},ui="rounded-md border border-border/60 bg-background px-2 py-1 text-sm text-foreground focus:border-primary focus:outline-none focus:ring-2 focus:ring-ring/30";function BN(){const[e,t]=Ns(),n=cO(e),r=n.window??"30d",o=e.get("groupBy")==="assignment"?"assignment":"project",{data:i}=Zs(),{data:a}=Sa(),{data:l}=T2(),[d,f]=m.useState(null),[p,h]=m.useState(!0),[g,y]=m.useState(null),[k,w]=m.useState(0);m.useEffect(()=>{if(!e.get("window")){const N=hb({window:"30d",...n});o==="assignment"&&N.set("groupBy","assignment"),t(N,{replace:!0})}},[]);const b=k2({window:r,...n}).toString();m.useEffect(()=>{const N=new AbortController;h(!0),y(null);const S=b?`/api/usage?${b}&groupBy=${o}`:`/api/usage?groupBy=${o}`;return fetch(S,{signal:N.signal}).then(async C=>{if(!C.ok){const D=await C.json().catch(()=>({}));throw new Error(D.error??`HTTP ${C.status}`)}return C.json()}).then(C=>{f(C),h(!1)}).catch(C=>{C instanceof Error&&C.name==="AbortError"||(y(C instanceof Error?C.message:String(C)),h(!1))}),()=>N.abort()},[b,o,k]);function j(N,S=o){const C=hb(N);S==="assignment"&&C.set("groupBy","assignment"),t(C)}return s.jsxs("div",{className:"p-6 max-w-7xl mx-auto",children:[s.jsxs("header",{className:"flex items-center gap-3 mb-6",children:[s.jsx(Wh,{className:"w-6 h-6 text-primary"}),s.jsx("h1",{className:"text-2xl font-semibold text-foreground",children:"Token usage"})]}),s.jsxs("div",{className:"flex flex-wrap gap-4 items-end mb-6 p-4 rounded-lg bg-card border border-border/60",children:[s.jsxs("label",{className:"flex flex-col gap-1 text-sm",children:[s.jsx("span",{className:"text-muted-foreground",children:"Window"}),s.jsx("select",{value:r,onChange:N=>j({...n,window:N.target.value}),className:ui,children:Gh.map(N=>s.jsx("option",{value:N,children:PY[N]},N))})]}),r==="custom"?s.jsxs(s.Fragment,{children:[s.jsxs("label",{className:"flex flex-col gap-1 text-sm",children:[s.jsx("span",{className:"text-muted-foreground",children:"Since"}),s.jsx("input",{type:"date",value:n.since??"",onChange:N=>j({...n,window:"custom",since:N.target.value||void 0}),className:ui})]}),s.jsxs("label",{className:"flex flex-col gap-1 text-sm",children:[s.jsx("span",{className:"text-muted-foreground",children:"Until"}),s.jsx("input",{type:"date",value:n.until??"",onChange:N=>j({...n,window:"custom",until:N.target.value||void 0}),className:ui})]})]}):null,s.jsxs("label",{className:"flex flex-col gap-1 text-sm",children:[s.jsx("span",{className:"text-muted-foreground",children:"Workspace"}),s.jsxs("select",{value:n.workspace??"",onChange:N=>j({...n,workspace:N.target.value||void 0,project:void 0}),className:ui,children:[s.jsx("option",{value:"",children:"All"}),a!=null&&a.hasUngrouped?s.jsx("option",{value:"_ungrouped",children:"(ungrouped)"}):null,((a==null?void 0:a.workspaces)??[]).map(N=>s.jsx("option",{value:N,children:N},N))]})]}),s.jsxs("label",{className:"flex flex-col gap-1 text-sm",children:[s.jsx("span",{className:"text-muted-foreground",children:"Project"}),s.jsxs("select",{value:n.project??"",onChange:N=>j({...n,project:N.target.value||void 0,workspace:void 0}),className:ui,children:[s.jsx("option",{value:"",children:"All"}),(i??[]).map(N=>s.jsx("option",{value:N.slug,children:N.slug},N.slug))]})]}),s.jsxs("label",{className:"flex flex-col gap-1 text-sm",children:[s.jsx("span",{className:"text-muted-foreground",children:"Model"}),s.jsxs("select",{value:n.model??"",onChange:N=>j({...n,model:N.target.value||void 0}),className:ui,children:[s.jsx("option",{value:"",children:"All"}),((l==null?void 0:l.models)??[]).map(N=>s.jsx("option",{value:N,children:N},N))]})]}),s.jsxs("label",{className:"flex flex-col gap-1 text-sm",children:[s.jsx("span",{className:"text-muted-foreground",children:"Tool"}),s.jsxs("select",{value:n.tool??"",onChange:N=>j({...n,tool:N.target.value||void 0}),className:ui,children:[s.jsx("option",{value:"",children:"All"}),((l==null?void 0:l.tools)??[]).map(N=>s.jsx("option",{value:N,children:N},N))]})]}),s.jsxs("label",{className:"flex flex-col gap-1 text-sm",children:[s.jsx("span",{className:"text-muted-foreground",children:"Group by"}),s.jsxs("select",{value:o,onChange:N=>j(n,N.target.value),className:ui,children:[s.jsx("option",{value:"project",children:"Project"}),s.jsx("option",{value:"assignment",children:"Assignment"})]})]})]}),p&&s.jsx(jt,{label:"Loading usage…"}),g&&s.jsx(Rt,{error:g,action:s.jsx("button",{type:"button",className:"shell-action",onClick:()=>w(N=>N+1),children:"Retry"})}),d&&!p&&!g&&s.jsxs(s.Fragment,{children:[s.jsxs("section",{className:"mb-8",children:[s.jsx("h2",{className:"text-lg font-medium mb-2",children:"Summary"}),d.summary.length===0?s.jsxs("p",{className:"text-muted-foreground text-sm",children:["No usage data for these filters. Run"," ",s.jsx("code",{className:"bg-muted px-1 py-0.5 rounded text-primary",children:"syntaur usage"})," ","to ingest the latest ccusage data."]}):s.jsxs("table",{className:"w-full text-sm border border-border/60 rounded overflow-hidden",children:[s.jsx("thead",{className:"bg-muted/50 text-muted-foreground",children:s.jsxs("tr",{children:[s.jsx("th",{className:"text-left px-3 py-2",children:"Project"}),o==="assignment"&&s.jsx("th",{className:"text-left px-3 py-2",children:"Assignment"}),s.jsx("th",{className:"text-right px-3 py-2",children:"Tokens"}),s.jsx("th",{className:"text-right px-3 py-2",children:"Cost"}),s.jsx("th",{className:"text-left px-3 py-2",children:"Last event"})]})}),s.jsx("tbody",{children:d.summary.map((N,S)=>s.jsxs("tr",{className:"border-t border-border/60",children:[s.jsx("td",{className:"px-3 py-2",children:N.projectSlug||"(unattributed)"}),o==="assignment"&&s.jsx("td",{className:"px-3 py-2",children:N.assignmentSlug||"(unattributed)"}),s.jsx("td",{className:"px-3 py-2 text-right tabular-nums",children:Wl(N.totalTokens)}),s.jsx("td",{className:"px-3 py-2 text-right tabular-nums",children:ql(N.totalCost)}),s.jsx("td",{className:"px-3 py-2 text-muted-foreground",children:N.lastEventDay})]},S))})]})]}),s.jsxs("section",{children:[s.jsx("h2",{className:"text-lg font-medium mb-2",children:"Daily breakdown"}),d.daily.length===0?s.jsx("p",{className:"text-muted-foreground text-sm",children:"No daily rows."}):s.jsxs("table",{className:"w-full text-sm border border-border/60 rounded overflow-hidden",children:[s.jsx("thead",{className:"bg-muted/50 text-muted-foreground",children:s.jsxs("tr",{children:[s.jsx("th",{className:"text-left px-3 py-2",children:"Day"}),s.jsx("th",{className:"text-left px-3 py-2",children:"Tool"}),s.jsx("th",{className:"text-left px-3 py-2",children:"Model"}),s.jsx("th",{className:"text-left px-3 py-2",children:"Project"}),s.jsx("th",{className:"text-left px-3 py-2",children:"Assignment"}),s.jsx("th",{className:"text-right px-3 py-2",children:"Tokens"}),s.jsx("th",{className:"text-right px-3 py-2",children:"Cost"})]})}),s.jsx("tbody",{children:d.daily.map((N,S)=>s.jsxs("tr",{className:"border-t border-border/60",children:[s.jsx("td",{className:"px-3 py-2 tabular-nums",children:N.day}),s.jsx("td",{className:"px-3 py-2 text-muted-foreground",children:N.tool}),s.jsx("td",{className:"px-3 py-2 text-muted-foreground",children:N.model}),s.jsx("td",{className:"px-3 py-2",children:N.project_slug||"–"}),s.jsx("td",{className:"px-3 py-2",children:N.assignment_slug||"–"}),s.jsx("td",{className:"px-3 py-2 text-right tabular-nums",children:Wl(N.total_tokens)}),s.jsx("td",{className:"px-3 py-2 text-right tabular-nums",children:ql(N.total_cost)})]},S))})]})]})]})]})}function UN(){const{workspace:e}=Vt(),{data:t}=Zs(),{data:n,loading:r,error:o}=Xh(),[i,a]=m.useState(""),[l,d]=m.useState(""),[f,p]=m.useState(""),[h,g]=m.useState("started_desc"),[y,k]=m.useState(0),[w,b]=m.useState(new Set),[j,N]=m.useState(!1),[S,C]=m.useState(null),[D,T]=m.useState(null),R=(n==null?void 0:n.sessions.some(A=>A.status==="active"))??!1;m.useEffect(()=>{if(!R)return;const A=window.setInterval(()=>k(L=>L+1),3e4);return()=>window.clearInterval(A)},[R]),m.useEffect(()=>{b(A=>{if(A.size===0)return A;const L=new Set((n==null?void 0:n.sessions.map(W=>W.sessionId))??[]),z=new Set([...A].filter(W=>L.has(W)));return z.size===A.size?A:z})},[n]);const $=m.useMemo(()=>{if(!n)return[];if(e&&!t)return[];const A=i.trim().toLowerCase();return[...n.sessions.filter(z=>{var K;if(e&&t){const O=((K=t.find(B=>B.slug===z.projectSlug))==null?void 0:K.workspace)??null;if(e==="_ungrouped"){if(O!==null)return!1}else if(O!==e)return!1}const W=DY(z.started);return l&&(!W||W<l)||f&&(!W||W>f)?!1:A?[z.projectSlug??"",z.assignmentSlug??"",z.agent,z.sessionId,z.path,z.description??"",z.transcriptPath??""].join(" ").toLowerCase().includes(A):!0})].sort((z,W)=>$Y(z,W,h))},[n,i,h,l,f,y,e,t]);function _(A){b(L=>{const z=new Set(L);return z.has(A)?z.delete(A):z.add(A),z})}function U(){w.size===$.length&&$.length>0?b(new Set):b(new Set($.map(A=>A.sessionId)))}async function I(A){C(null),N(!0);try{const L=await fetch("/api/agent-sessions",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionIds:A})}),z=await L.json().catch(()=>null);if(!L.ok)throw new Error((z==null?void 0:z.error)||`HTTP ${L.status}`);b(W=>new Set([...W].filter(V=>!A.includes(V)))),T(null)}catch(L){C(L.message)}finally{N(!1)}}async function F(A){try{const L=await fetch(`/api/agent-sessions/${encodeURIComponent(A)}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({status:"stopped"})});if(!L.ok){const z=await L.json().catch(()=>null);C((z==null?void 0:z.error)||`Failed to mark session stopped: HTTP ${L.status}`)}}catch(L){C(L.message)}}if(r)return s.jsx(jt,{label:"Loading agent sessions..."});if(o)return s.jsx(Rt,{error:o});if(!n)return null;const M=n.sessions.length>0;return s.jsxs(s.Fragment,{children:[s.jsxs($w,{children:[s.jsx(Rm,{value:i,onChange:a,placeholder:"Search project, assignment, agent, session ID, path, or description"}),s.jsxs("label",{className:"flex min-w-[150px] flex-col gap-1 text-xs font-medium uppercase tracking-[0.08em] text-muted-foreground",children:["Started From",s.jsx("input",{type:"date",value:l,onChange:A=>d(A.target.value),className:"editor-input min-w-[150px]"})]}),s.jsxs("label",{className:"flex min-w-[150px] flex-col gap-1 text-xs font-medium uppercase tracking-[0.08em] text-muted-foreground",children:["Started To",s.jsx("input",{type:"date",value:f,onChange:A=>p(A.target.value),className:"editor-input min-w-[150px]"})]}),s.jsxs("select",{value:h,onChange:A=>g(A.target.value),className:"editor-input max-w-[200px]",children:[s.jsx("option",{value:"started_desc",children:"Newest first"}),s.jsx("option",{value:"started_asc",children:"Oldest first"}),s.jsx("option",{value:"assignment_asc",children:"Assignment A-Z"}),s.jsx("option",{value:"agent_asc",children:"Agent A-Z"})]})]}),S?s.jsx("div",{className:"mt-4 rounded-md border border-error-foreground/30 bg-error px-4 py-3 text-sm text-error-foreground",children:S}):null,w.size>0&&s.jsxs("div",{className:"mt-4 flex items-center gap-3 rounded border border-border/40 bg-muted/30 px-4 py-2 text-sm",children:[s.jsxs("span",{className:"text-muted-foreground",children:[w.size," session",w.size!==1?"s":""," selected"]}),s.jsxs("button",{className:"shell-action text-destructive",onClick:()=>T({sessionIds:[...w],title:`Delete ${w.size} selected session${w.size===1?"":"s"}?`,description:"This removes the selected agent session records from the dashboard. This cannot be undone.",confirmLabel:w.size===1?"Delete Session":"Delete Sessions"}),disabled:j,children:[s.jsx(bn,{className:"mr-1 inline h-3.5 w-3.5"}),"Delete Selected"]}),s.jsx("button",{className:"shell-action",onClick:()=>b(new Set),children:"Clear Selection"})]}),M?$.length===0?s.jsx(Tt,{title:"No agent sessions match these filters",description:"Adjust the status, search term, date range, or sorting controls to show sessions again."}):s.jsx("div",{className:"surface-panel mt-4 overflow-x-auto",children:s.jsxs("table",{className:"w-full min-w-[1280px] table-fixed text-sm",children:[s.jsxs("colgroup",{children:[s.jsx("col",{style:{width:"32px"}}),s.jsx("col",{style:{width:"140px"}}),s.jsx("col",{style:{width:"160px"}}),s.jsx("col",{style:{width:"200px"}}),s.jsx("col",{style:{width:"110px"}}),s.jsx("col",{style:{width:"130px"}}),s.jsx("col",{style:{width:"140px"}}),s.jsx("col",{style:{width:"200px"}}),s.jsx("col",{style:{width:"200px"}}),s.jsx("col",{style:{width:"40px"}})]}),s.jsx("thead",{children:s.jsxs("tr",{className:"border-b border-border/40 text-left text-xs uppercase tracking-wider text-muted-foreground",children:[s.jsx("th",{className:"pb-2 pr-3",children:s.jsx("button",{onClick:U,className:"text-muted-foreground hover:text-foreground",children:w.size===$.length&&$.length>0?s.jsx(gs,{className:"h-4 w-4"}):s.jsx(Iv,{className:"h-4 w-4"})})}),s.jsx("th",{className:"pb-2 pr-3",children:"Project"}),s.jsx("th",{className:"pb-2 pr-3",children:"Assignment"}),s.jsx("th",{className:"pb-2 pr-3",children:"Description"}),s.jsx("th",{className:"pb-2 pr-3",children:"Agent"}),s.jsx("th",{className:"pb-2 pr-3",children:"Session ID"}),s.jsx("th",{className:"pb-2 pr-3",children:"Started"}),s.jsx("th",{className:"pb-2 pr-3",children:"Path"}),s.jsx("th",{className:"pb-2 pr-3",children:"Transcript"}),s.jsx("th",{className:"pb-2"})]})}),s.jsx("tbody",{children:$.map(A=>s.jsx(_Y,{session:A,selected:w.has(A.sessionId),onToggle:()=>_(A.sessionId),onDelete:()=>T({sessionIds:[A.sessionId],title:`Delete session ${A.sessionId.slice(0,8)}...?`,description:`Remove this ${A.agent} session record${A.assignmentSlug?` for ${A.assignmentSlug}`:""}. This cannot be undone.`,confirmLabel:"Delete Session"}),onMarkStopped:F,onCopyError:C},A.sessionId))})]})}):s.jsx(Tt,{title:"No agent sessions",description:"No agent sessions have been registered yet. Use /grab-assignment or syntaur track-session to register one."}),s.jsx(Ri,{open:D!==null,title:(D==null?void 0:D.title)??"Delete session?",description:(D==null?void 0:D.description)??"",confirmLabel:(D==null?void 0:D.confirmLabel)??"Delete",destructive:!0,loading:j,onOpenChange:A=>{A||T(null)},onConfirm:async()=>{D&&await I(D.sessionIds)}})]})}function _Y({session:e,selected:t,onToggle:n,onDelete:r,onMarkStopped:o,onCopyError:i}){const a=pn(),l=e.sessionId.length>12?e.sessionId.slice(0,8)+"...":e.sessionId,d=e.path?e.path.replace(/^\/Users\/[^/]+/,"~"):"—",f=e.transcriptPath?e.transcriptPath.replace(/^\/Users\/[^/]+/,"~"):"—";return s.jsxs("tr",{className:"border-b border-border/20 last:border-0",children:[s.jsx("td",{className:"py-2 pr-3",children:s.jsx("button",{onClick:n,className:"text-muted-foreground hover:text-foreground",children:t?s.jsx(gs,{className:"h-4 w-4"}):s.jsx(Iv,{className:"h-4 w-4"})})}),s.jsx("td",{className:"py-2 pr-3",children:e.projectSlug?s.jsx(Ie,{to:`${a}/projects/${e.projectSlug}`,className:"block truncate text-primary hover:underline",title:Dn(e.projectSlug),children:Dn(e.projectSlug)}):e.assignmentSlug?s.jsx("span",{className:"rounded bg-muted px-1.5 py-0.5 text-[10px] font-mono uppercase tracking-wide text-muted-foreground",children:"Standalone"}):s.jsx("span",{className:"text-muted-foreground",children:"—"})}),s.jsx("td",{className:"py-2 pr-3",children:e.projectSlug&&e.assignmentSlug?s.jsx(Ie,{to:`${a}/projects/${e.projectSlug}/assignments/${e.assignmentSlug}`,className:"block truncate text-primary hover:underline",title:Dn(e.assignmentSlug),children:Dn(e.assignmentSlug)}):e.assignmentSlug?s.jsx(Ie,{to:`/assignments/${e.assignmentSlug}`,className:"block truncate font-mono text-primary hover:underline",title:e.assignmentSlug,children:e.assignmentSlug}):s.jsx("span",{className:"text-muted-foreground",children:"—"})}),s.jsx("td",{className:"py-2 pr-3",children:e.description?s.jsx("div",{className:"truncate text-xs text-muted-foreground",title:e.description,children:e.description}):s.jsx("span",{className:"text-muted-foreground",children:"—"})}),s.jsx("td",{className:"py-2 pr-3",children:s.jsxs("span",{className:"flex min-w-0 items-center gap-1.5",children:[s.jsx(Uh,{className:"h-3 w-3 shrink-0 text-muted-foreground"}),s.jsx("span",{className:"block min-w-0 truncate",children:e.agent})]})}),s.jsx("td",{className:"py-2 pr-3",children:s.jsxs("span",{className:"flex min-w-0 items-center gap-1.5",children:[s.jsx("span",{className:"block min-w-0 truncate font-mono text-xs text-muted-foreground",title:e.sessionId,children:l}),s.jsx(Zr,{value:e.sessionId}),s.jsx(t_,{sessionId:e.sessionId,disabled:!e.resumeSupported,disabledReason:"Resume not supported for this agent",onError:p=>i(p.message),onNotice:p=>i(p)})]})}),s.jsx("td",{className:"py-2 pr-3 text-xs text-muted-foreground",children:s.jsx("span",{className:"truncate block",children:es(e.started)})}),s.jsx("td",{className:"py-2 pr-3",children:s.jsxs("span",{className:"flex min-w-0 items-center gap-1.5",children:[s.jsx("span",{className:"block min-w-0 truncate text-xs text-muted-foreground",title:e.path,children:d}),e.path&&s.jsx(Zr,{value:e.path})]})}),s.jsx("td",{className:"py-2 pr-3",children:e.transcriptPath?s.jsxs("span",{className:"flex min-w-0 items-center gap-1.5",children:[s.jsx("span",{className:"block min-w-0 truncate font-mono text-xs text-muted-foreground",title:e.transcriptPath,children:f}),s.jsx(Zr,{value:e.transcriptPath})]}):s.jsx("span",{className:"text-muted-foreground",children:"—"})}),s.jsx("td",{className:"py-2",children:s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx(i_,{session:e,onMarkStopped:o}),s.jsx("button",{onClick:r,className:"text-muted-foreground hover:text-destructive",title:"Delete session",children:s.jsx(bn,{className:"h-3.5 w-3.5"})})]})})]})}function DY(e){const t=new Date(e);if(Number.isNaN(t.getTime()))return null;const n=t.getFullYear(),r=String(t.getMonth()+1).padStart(2,"0"),o=String(t.getDate()).padStart(2,"0");return`${n}-${r}-${o}`}function hp(e){const t=Date.parse(e.started),n=e.ended?Date.parse(e.ended):Date.now();return Number.isNaN(t)||Number.isNaN(n)?0:Math.max(0,Math.floor((n-t)/6e4))}function $Y(e,t,n){switch(n){case"started_asc":return e.started.localeCompare(t.started);case"started_desc":return t.started.localeCompare(e.started);case"duration_asc":return hp(e)-hp(t);case"duration_desc":return hp(t)-hp(e);case"assignment_asc":return(e.assignmentSlug??"").localeCompare(t.assignmentSlug??"")||(e.projectSlug??"").localeCompare(t.projectSlug??"");case"agent_asc":return e.agent.localeCompare(t.agent)||(e.assignmentSlug??"").localeCompare(t.assignmentSlug??"");default:return 0}}function IY(){const{data:e,loading:t,error:n,refetch:r}=zv(),[o,i]=m.useState(""),[a,l]=m.useState(null),[d,f]=m.useState(null),[p,h]=m.useState(null),g=m.useMemo(()=>{if(!(e!=null&&e.playbooks))return[];if(!o.trim())return e.playbooks;const w=o.toLowerCase();return e.playbooks.filter(b=>b.name.toLowerCase().includes(w)||b.description.toLowerCase().includes(w)||b.slug.toLowerCase().includes(w)||b.tags.some(j=>j.toLowerCase().includes(w)))},[e,o]);async function y(w,b,j){if(w.preventDefault(),w.stopPropagation(),!a){l(b);try{const N=j?"disable":"enable",S=await fetch(`/api/playbooks/${encodeURIComponent(b)}/${N}`,{method:"POST"});if(!S.ok){const C=await S.json().catch(()=>({}));throw new Error(C.error||`Failed to ${N} playbook`)}r()}catch(N){console.error(N),alert(N instanceof Error?N.message:"Failed to update playbook")}finally{l(null)}}}async function k(){if(d){h(d.slug);try{const w=await fetch(`/api/playbooks/${encodeURIComponent(d.slug)}`,{method:"DELETE"});if(!w.ok){const b=await w.json().catch(()=>({}));throw new Error(b.error||"Failed to delete playbook")}f(null),r()}catch(w){console.error(w),alert(w instanceof Error?w.message:"Failed to delete playbook")}finally{h(null)}}}return t?s.jsx(jt,{label:"Loading playbooks..."}):n?s.jsx(Rt,{error:n}):s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex items-center justify-between gap-4",children:[s.jsxs("div",{className:"relative flex-1 max-w-sm",children:[s.jsx(Si,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),s.jsx("input",{type:"text",placeholder:"Search playbooks...",value:o,onChange:w=>i(w.target.value),className:"h-9 w-full rounded-md border border-border/70 bg-background pl-9 pr-3 text-sm text-foreground placeholder:text-muted-foreground/60 focus:border-foreground/30 focus:outline-none"})]}),s.jsxs(Ie,{to:"/playbooks/create",className:"inline-flex h-9 items-center gap-2 rounded-md bg-foreground px-3 text-sm font-medium text-background transition hover:bg-foreground/90",children:[s.jsx(It,{className:"h-4 w-4"}),"Create Playbook"]})]}),s.jsxs(Ie,{to:"/playbooks/manifest",className:"surface-panel group flex items-center gap-3 p-3 transition hover:border-foreground/20",children:[s.jsx(XE,{className:"h-5 w-5 shrink-0 text-muted-foreground"}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("h3",{className:"text-sm font-semibold text-foreground group-hover:underline",children:"Playbook Manifest"}),s.jsx("span",{className:"rounded-full border border-border/60 bg-muted/50 px-2 py-0.5 text-[10px] text-muted-foreground",children:"auto-generated"})]}),s.jsxs("p",{className:"mt-0.5 text-xs text-muted-foreground",children:["Index of all playbooks with descriptions. Include ",s.jsx("code",{className:"rounded bg-muted px-1 py-0.5 text-[11px]",children:"~/.syntaur/playbooks/manifest.md"})," in your CLAUDE.md for agent context."]})]})]}),g.length===0?s.jsx(Tt,{title:"No playbooks found",description:(e==null?void 0:e.playbooks.length)===0?"Playbooks define rules and workflows for how agents should operate. Create your first one to get started.":"No playbooks match your search.",actions:(e==null?void 0:e.playbooks.length)===0?s.jsxs(Ie,{to:"/playbooks/create",className:"inline-flex items-center gap-2 rounded-md bg-foreground px-3 py-2 text-sm font-medium text-background transition hover:bg-foreground/90",children:[s.jsx(It,{className:"h-4 w-4"}),"Create Playbook"]}):void 0}):s.jsx("div",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3",children:g.map(w=>{const b=a===w.slug,j=[{key:"delete",label:"Delete",icon:bn,destructive:!0,onSelect:()=>f({slug:w.slug,name:w.name})}];return s.jsxs("div",{className:`surface-panel relative flex flex-col gap-2 p-4 transition hover:border-foreground/20 ${w.enabled?"":"opacity-75"}`,children:[s.jsx("div",{className:"absolute right-3 top-3 z-10",children:s.jsx(Aw,{items:j})}),s.jsxs(Ie,{to:`/playbooks/${w.slug}`,className:"group flex flex-col gap-2",children:[s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx(WE,{className:"mt-0.5 h-4 w-4 shrink-0 text-muted-foreground"}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("h3",{className:"text-sm font-semibold text-foreground group-hover:underline",children:w.name}),w.description?s.jsx("p",{className:"mt-1 text-xs leading-5 text-muted-foreground line-clamp-2",children:w.description}):null]})]}),s.jsx("div",{className:"flex items-center gap-2 pt-1 pr-20",children:s.jsxs("div",{className:"flex flex-wrap gap-1",children:[w.tags.slice(0,3).map(N=>s.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full border border-border/60 bg-muted/50 px-2 py-0.5 text-[10px] text-muted-foreground",children:[s.jsx(e2,{className:"h-2.5 w-2.5"}),N]},N)),w.tags.length>3?s.jsxs("span",{className:"text-[10px] text-muted-foreground/60",children:["+",w.tags.length-3]}):null]})})]}),s.jsx("button",{type:"button",role:"switch","aria-checked":w.enabled,"aria-label":w.enabled?"Disable playbook":"Enable playbook",onClick:N=>y(N,w.slug,w.enabled),disabled:b,className:`absolute bottom-3 right-3 z-10 inline-flex h-5 w-9 items-center rounded-full border opacity-100 transition disabled:opacity-50 ${w.enabled?"border-status-completed-foreground/60 bg-status-completed-foreground/80":"border-foreground/40 bg-foreground/15"}`,children:s.jsx("span",{className:`block h-4 w-4 rounded-full shadow-sm transition-transform ${w.enabled?"translate-x-[18px] bg-background":"translate-x-[2px] bg-foreground/70"}`})})]},w.slug)})}),s.jsx(Ri,{open:d!==null,title:"Delete playbook?",description:d?`"${d.name}" will be removed from disk and the playbook manifest will be regenerated. This cannot be undone.`:"",confirmLabel:"Delete",destructive:!0,loading:p!==null,onConfirm:k,onOpenChange:w=>{w||f(null)}})]})}function MY(){const{slug:e}=Vt(),t=Ht(),{data:n,loading:r,error:o,refetch:i}=vO(e),[a,l]=m.useState(!1),[d,f]=m.useState(!1),[p,h]=m.useState(!1),[g,y]=m.useState(!1),[k,w]=m.useState(""),[b,j]=m.useState(!1),[N,S]=m.useState(null),C=e==="manifest";m.useEffect(()=>{g&&(w(e??""),S(null))},[g,e]);const D=Pr(k),T=D.length>0&&Pp(D)&&D!=="manifest",R=D!==e;async function $(){if(!(!e||!T||!R)){j(!0),S(null);try{const I=await fetch(`/api/playbooks/${encodeURIComponent(e)}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({newSlug:D})});if(!I.ok){const F=await I.json().catch(()=>({}));throw new Error(F.error||"Failed to rename playbook")}y(!1),t(`/playbooks/${D}`)}catch(I){S(I instanceof Error?I.message:"Failed to rename playbook")}finally{j(!1)}}}async function _(){if(e){f(!0);try{(await fetch(`/api/playbooks/${e}`,{method:"DELETE"})).ok&&t("/playbooks")}finally{f(!1)}}}async function U(){if(!(!e||!n)){h(!0);try{const I=n.enabled?"disable":"enable",F=await fetch(`/api/playbooks/${encodeURIComponent(e)}/${I}`,{method:"POST"});if(!F.ok){const M=await F.json().catch(()=>({}));throw new Error(M.error||`Failed to ${I} playbook`)}i()}catch(I){console.error(I),alert(I instanceof Error?I.message:"Failed to update playbook")}finally{h(!1)}}}return r?s.jsx(jt,{label:"Loading playbook..."}):o?s.jsx(Rt,{error:o}):n?s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"flex items-start justify-between gap-4",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("h2",{className:"text-lg font-semibold text-foreground",children:C?"Playbook Manifest":n.name}),C?s.jsx("span",{className:"rounded-full border border-border/60 bg-muted/50 px-2 py-0.5 text-xs text-muted-foreground",children:"auto-generated"}):null]}),!C&&n.description?s.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:n.description}):null,C?s.jsxs("p",{className:"mt-1 text-sm text-muted-foreground",children:["This file is rebuilt automatically when playbooks are added or removed. Include"," ",s.jsx("code",{className:"rounded bg-muted px-1 py-0.5 text-xs",children:"~/.syntaur/playbooks/manifest.md"})," ","in your CLAUDE.md for agent context."]}):null,!C&&n.whenToUse?s.jsxs("p",{className:"mt-2 text-sm text-muted-foreground italic",children:["When to use: ",n.whenToUse]}):null,s.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-3 text-xs text-muted-foreground",children:[s.jsxs("span",{children:["Created ",es(n.created)]}),s.jsxs("span",{children:["Updated ",es(n.updated)]})]}),n.tags.length>0?s.jsx("div",{className:"mt-2 flex flex-wrap gap-1.5",children:n.tags.map(I=>s.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full border border-border/60 bg-muted/50 px-2 py-0.5 text-xs text-muted-foreground",children:[s.jsx(e2,{className:"h-3 w-3"}),I]},I))}):null]}),C?null:s.jsxs("div",{className:"flex shrink-0 items-center gap-3",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:n.enabled?"Enabled":"Disabled"}),s.jsx("button",{type:"button",role:"switch","aria-checked":n.enabled,"aria-label":n.enabled?"Disable playbook":"Enable playbook",onClick:U,disabled:p,className:`inline-flex h-5 w-9 items-center rounded-full border transition disabled:opacity-50 ${n.enabled?"border-status-completed-foreground/60 bg-status-completed-foreground/80":"border-foreground/40 bg-foreground/15"}`,children:s.jsx("span",{className:`block h-4 w-4 rounded-full shadow-sm transition-transform ${n.enabled?"translate-x-[18px] bg-background":"translate-x-[2px] bg-foreground/70"}`})})]}),s.jsxs(Ie,{to:`/playbooks/${e}/edit`,className:"inline-flex h-8 items-center gap-1.5 rounded-md border border-border/70 bg-background px-3 text-xs font-medium text-foreground transition hover:bg-muted",children:[s.jsx(fc,{className:"h-3 w-3"}),"Edit"]}),s.jsxs("button",{type:"button",onClick:()=>y(!0),className:"inline-flex h-8 items-center gap-1.5 rounded-md border border-border/70 bg-background px-3 text-xs font-medium text-foreground transition hover:bg-muted",children:[s.jsx(c4,{className:"h-3 w-3"}),"Rename"]}),a?s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("button",{type:"button",onClick:_,disabled:d,className:"inline-flex h-8 items-center gap-1.5 rounded-md bg-destructive px-3 text-xs font-medium text-destructive-foreground transition hover:bg-destructive/90 disabled:opacity-50",children:d?"Deleting...":"Confirm"}),s.jsx("button",{type:"button",onClick:()=>l(!1),className:"inline-flex h-8 items-center rounded-md border border-border/70 bg-background px-3 text-xs font-medium text-foreground transition hover:bg-muted",children:"Cancel"})]}):s.jsxs("button",{type:"button",onClick:()=>l(!0),className:"inline-flex h-8 items-center gap-1.5 rounded-md border border-border/70 bg-background px-3 text-xs font-medium text-destructive transition hover:bg-destructive/10",children:[s.jsx(bn,{className:"h-3 w-3"}),"Delete"]})]})]}),s.jsx("div",{className:"surface-panel p-4",children:s.jsx(xn,{content:n.body})}),s.jsx(Ln,{open:g,onOpenChange:I=>b?void 0:y(I),children:s.jsxs(jn,{children:[s.jsxs(er,{children:[s.jsx(kn,{children:"Rename playbook"}),s.jsx(ns,{children:"The slug changes both the file name and the canonical slug stored in frontmatter. The URL will update on save."})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{htmlFor:"rename-slug-input",className:"block text-xs font-medium text-muted-foreground",children:"New slug"}),s.jsx("input",{id:"rename-slug-input",type:"text",autoFocus:!0,value:k,onChange:I=>w(I.target.value),disabled:b,className:"h-9 w-full rounded-md border border-border/70 bg-background px-3 text-sm text-foreground focus:border-foreground/40 focus:outline-none",placeholder:"my-new-slug"}),k&&D!==k?s.jsxs("p",{className:"text-xs text-muted-foreground",children:["Will be normalized to ",s.jsx("code",{className:"rounded bg-muted px-1 py-0.5",children:D||"—"})]}):null,k&&!T?s.jsx("p",{className:"text-xs text-destructive",children:'Slugs must be lowercase, hyphen-separated, with no special characters, and cannot be "manifest".'}):null]}),N?s.jsx("p",{className:"text-sm text-destructive",role:"alert",children:N}):null,s.jsxs(Ur,{children:[s.jsx("button",{type:"button",onClick:()=>y(!1),disabled:b,className:"shell-action mt-0 disabled:cursor-not-allowed disabled:opacity-50",children:"Cancel"}),s.jsx("button",{type:"button",onClick:$,disabled:b||!T||!R,className:"shell-action mt-0 shell-action--cta disabled:cursor-not-allowed disabled:opacity-50",children:b?"Renaming…":"Rename"})]})]})})]}):null}function LY(){const e=Ht(),[t,n]=m.useState(null),[r,o]=m.useState(!0),[i,a]=m.useState(!1),[l,d]=m.useState(null);m.useEffect(()=>{fetch("/api/playbooks/template/new").then(p=>p.json()).then(p=>{n(p.content),o(!1)}).catch(p=>{d(p.message),o(!1)})},[]);async function f(p){a(!0),d(null);try{const h=await fetch("/api/playbooks",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:p})}),g=await h.json();if(!h.ok){d(g.error||`HTTP ${h.status}`),a(!1);return}e(`/playbooks/${g.slug}`)}catch(h){d(h.message),a(!1);return}a(!1)}return r?s.jsx(jt,{label:"Loading playbook template..."}):l&&!t?s.jsx(Rt,{error:l}):s.jsx(Cc,{initialContent:t||"",documentType:"playbook",mode:"create",onSave:f,saving:i,error:l,title:"Create Playbook",description:"Playbooks define rules and workflows for how agents should operate. Keep them short, imperative, and focused on a single concern.",onCancel:()=>e("/playbooks"),allowSlugEdit:!0})}function OY(){const{slug:e}=Vt(),t=Ht(),[n,r]=m.useState(null),[o,i]=m.useState(!0),[a,l]=m.useState(!1),[d,f]=m.useState(null);m.useEffect(()=>{e&&fetch(`/api/playbooks/${e}/edit`).then(h=>h.json()).then(h=>{r(h.content),i(!1)}).catch(h=>{f(h.message),i(!1)})},[e]);async function p(h){if(e){l(!0),f(null);try{const g=await fetch(`/api/playbooks/${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:h})}),y=await g.json();if(!g.ok){f(y.error||`HTTP ${g.status}`),l(!1);return}t(`/playbooks/${e}`)}catch(g){f(g.message),l(!1);return}l(!1)}}return o?s.jsx(jt,{label:"Loading playbook..."}):d&&!n?s.jsx(Rt,{error:d}):s.jsx(Cc,{initialContent:n||"",documentType:"playbook",mode:"edit",onSave:p,saving:a,error:d,title:"Edit Playbook",onCancel:()=>t(`/playbooks/${e}`)})}function FY(){const{data:e,loading:t,error:n}=wO(),[r,o]=m.useState(""),[i,a]=m.useState("all"),[l,d]=m.useState("all"),[f,p]=m.useState("all"),h=(e==null?void 0:e.memories)??[],g=m.useMemo(()=>Array.from(new Set(h.map(b=>b.projectSlug))).sort(),[h]),y=m.useMemo(()=>Array.from(new Set(h.map(b=>b.scope).filter(Boolean))).sort(),[h]),k=m.useMemo(()=>Array.from(new Set(h.map(b=>b.source).filter(Boolean))).sort(),[h]),w=m.useMemo(()=>h.filter(b=>{if(i!=="all"&&b.projectSlug!==i||l!=="all"&&b.scope!==l||f!=="all"&&b.source!==f)return!1;if(r.trim()){const j=r.toLowerCase();if(!b.name.toLowerCase().includes(j)&&!b.slug.toLowerCase().includes(j)&&!b.projectTitle.toLowerCase().includes(j))return!1}return!0}),[h,r,i,l,f]);return t?s.jsx(jt,{label:"Loading memories…"}):n?s.jsx(Rt,{error:n}):s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsxs("div",{className:"relative",children:[s.jsx(Si,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),s.jsx("input",{type:"text",placeholder:"Search memories…",value:r,onChange:b=>o(b.target.value),className:"h-9 w-64 rounded-md border border-border/70 bg-background pl-9 pr-3 text-sm text-foreground placeholder:text-muted-foreground/60 focus:border-foreground/30 focus:outline-none"})]}),s.jsxs("select",{value:i,onChange:b=>a(b.target.value),className:"editor-input max-w-[170px]",children:[s.jsx("option",{value:"all",children:"All projects"}),g.map(b=>s.jsx("option",{value:b,children:b},b))]}),s.jsxs("select",{value:l,onChange:b=>d(b.target.value),className:"editor-input max-w-[140px]",children:[s.jsx("option",{value:"all",children:"All scopes"}),y.map(b=>s.jsx("option",{value:b,children:b},b))]}),s.jsxs("select",{value:f,onChange:b=>p(b.target.value),className:"editor-input max-w-[140px]",children:[s.jsx("option",{value:"all",children:"All sources"}),k.map(b=>s.jsx("option",{value:b,children:b},b))]})]}),s.jsxs(Ie,{to:"/memories/new",className:"inline-flex h-9 items-center gap-2 rounded-md bg-foreground px-3 text-sm font-medium text-background transition hover:bg-foreground/90",children:[s.jsx(It,{className:"h-4 w-4"}),"New Memory"]})]}),w.length===0?s.jsx(Tt,{title:h.length===0?"No memories yet":"No memories match these filters",description:h.length===0?"Memories capture patterns and learnings discovered while working in a project. Agents create them via /create-memory or you can add one manually.":"Clear the current filters or create a new memory.",actions:h.length===0?s.jsxs(Ie,{to:"/memories/new",className:"inline-flex items-center gap-2 rounded-md bg-foreground px-3 py-2 text-sm font-medium text-background transition hover:bg-foreground/90",children:[s.jsx(It,{className:"h-4 w-4"}),"New Memory"]}):void 0}):s.jsx("div",{className:"surface-panel overflow-x-auto",children:s.jsxs("table",{className:"w-full min-w-[820px] text-left text-sm",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"border-b border-border/60 text-muted-foreground",children:[s.jsx("th",{className:"px-3 pb-3 pt-3 font-medium",children:"Name"}),s.jsx("th",{className:"px-3 pb-3 pt-3 font-medium",children:"Project"}),s.jsx("th",{className:"px-3 pb-3 pt-3 font-medium",children:"Scope"}),s.jsx("th",{className:"px-3 pb-3 pt-3 font-medium",children:"Source"}),s.jsx("th",{className:"px-3 pb-3 pt-3 font-medium",children:"# Related"}),s.jsx("th",{className:"px-3 pb-3 pt-3 font-medium",children:"Updated"})]})}),s.jsx("tbody",{children:w.map(b=>s.jsxs("tr",{className:"border-b border-border/50 last:border-0",children:[s.jsx("td",{className:"px-3 py-3",children:s.jsx(Ie,{to:`/projects/${b.projectSlug}/memories/${b.slug}`,className:"font-semibold text-foreground hover:text-primary",children:b.name||b.slug})}),s.jsx("td",{className:"px-3 py-3 text-muted-foreground",children:s.jsx(Ie,{to:`/projects/${b.projectSlug}`,className:"hover:text-foreground hover:underline",children:b.projectTitle})}),s.jsx("td",{className:"px-3 py-3 text-muted-foreground",children:b.scope||"—"}),s.jsx("td",{className:"px-3 py-3 text-muted-foreground",children:b.source||"—"}),s.jsx("td",{className:"px-3 py-3 text-muted-foreground",children:b.relatedAssignments.length}),s.jsx("td",{className:"px-3 py-3 text-muted-foreground",children:Gn(b.updated)})]},`${b.projectSlug}/${b.slug}`))})]})})]})}function zY(){const{slug:e,itemSlug:t}=Vt(),n=Ht(),{data:r,loading:o,error:i}=jO(e,t),[a,l]=m.useState(!1),[d,f]=m.useState(!1);async function p(){if(!(!e||!t)){f(!0);try{(await fetch(`/api/projects/${e}/memories/${t}`,{method:"DELETE"})).ok&&n("/memories")}finally{f(!1)}}}return o?s.jsx(jt,{label:"Loading memory…"}):i?s.jsx(Rt,{error:i}):r?s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"flex items-start justify-between gap-4",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("h2",{className:"text-lg font-semibold text-foreground",children:r.name||r.slug}),s.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-2 text-xs text-muted-foreground",children:[s.jsx(Ie,{to:`/projects/${r.projectSlug}`,className:"rounded-full border border-border/60 bg-muted/50 px-2 py-0.5 hover:text-foreground",children:r.projectTitle}),r.scope?s.jsxs("span",{className:"rounded-full border border-border/60 bg-muted/50 px-2 py-0.5",children:["Scope: ",r.scope]}):null,r.source?s.jsxs("span",{className:"rounded-full border border-border/60 bg-muted/50 px-2 py-0.5",children:["Source: ",r.source]}):null,r.sourceAssignment?s.jsxs("span",{className:"rounded-full border border-border/60 bg-muted/50 px-2 py-0.5",children:["From: ",r.sourceAssignment]}):null,s.jsxs("span",{className:"rounded-full border border-border/60 bg-muted/50 px-2 py-0.5",children:[r.relatedAssignments.length," related"]})]}),s.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-3 text-xs text-muted-foreground",children:[s.jsxs("span",{children:["Created ",es(r.created)]}),s.jsxs("span",{children:["Updated ",es(r.updated)]})]}),r.tags&&r.tags.length>0?s.jsx("div",{className:"mt-2 flex flex-wrap gap-1.5",children:r.tags.map(h=>s.jsx("span",{className:"inline-flex items-center rounded-full border border-border/60 bg-muted/50 px-2 py-0.5 text-xs text-muted-foreground",children:h},h))}):null]}),s.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[s.jsxs(Ie,{to:`/projects/${e}/memories/${t}/edit`,className:"inline-flex h-8 items-center gap-1.5 rounded-md border border-border/70 bg-background px-3 text-xs font-medium text-foreground transition hover:bg-muted",children:[s.jsx(fc,{className:"h-3 w-3"}),"Edit"]}),a?s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("button",{type:"button",onClick:p,disabled:d,className:"inline-flex h-8 items-center gap-1.5 rounded-md bg-destructive px-3 text-xs font-medium text-destructive-foreground transition hover:bg-destructive/90 disabled:opacity-50",children:d?"Deleting…":"Confirm"}),s.jsx("button",{type:"button",onClick:()=>l(!1),className:"inline-flex h-8 items-center rounded-md border border-border/70 bg-background px-3 text-xs font-medium text-foreground transition hover:bg-muted",children:"Cancel"})]}):s.jsxs("button",{type:"button",onClick:()=>l(!0),className:"inline-flex h-8 items-center gap-1.5 rounded-md border border-border/70 bg-background px-3 text-xs font-medium text-destructive transition hover:bg-destructive/10",children:[s.jsx(bn,{className:"h-3 w-3"}),"Delete"]})]})]}),s.jsx("div",{className:"surface-panel p-4",children:s.jsx(xn,{content:r.body})})]}):null}function BY(){const e=Ht(),[t]=Ns(),n=t.get("project"),{data:r,loading:o,error:i}=Zs(),[a,l]=m.useState(n??""),[d,f]=m.useState(""),[p,h]=m.useState(""),[g,y]=m.useState(!1),[k,w]=m.useState(null);m.useEffect(()=>{!a&&r&&r.length>0&&l(n??r[0].slug)},[r,n,a]);async function b(j){if(j.preventDefault(),!(!a||!d.trim())){y(!0),w(null);try{const N=await fetch(`/api/projects/${a}/memories`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:d.trim(),body:p||void 0})}),S=await N.json();if(!N.ok){w(S.error||`HTTP ${N.status}`),y(!1);return}e(`/projects/${S.projectSlug}/memories/${S.slug}`)}catch(N){w(N.message),y(!1)}}}return o?s.jsx(jt,{label:"Loading projects…"}):i?s.jsx(Rt,{error:i}):!r||r.length===0?s.jsx(Rt,{error:"You need at least one project before you can create a memory. Create a project from the sidebar."}):s.jsxs("form",{onSubmit:b,className:"space-y-5",children:[s.jsxs("div",{children:[s.jsx("h2",{className:"text-lg font-semibold text-foreground",children:"New Memory"}),s.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:"Memories capture patterns and learnings discovered during work in a project. They are available to every assignment in that project."})]}),s.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("label",{htmlFor:"project",className:"block text-sm font-medium text-foreground",children:"Project"}),s.jsx("select",{id:"project",value:a,onChange:j=>l(j.target.value),className:"editor-input",required:!0,children:r.map(j=>s.jsx("option",{value:j.slug,children:j.title},j.slug))})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("label",{htmlFor:"name",className:"block text-sm font-medium text-foreground",children:"Name"}),s.jsx("input",{id:"name",type:"text",value:d,onChange:j=>f(j.target.value),placeholder:"e.g. PostgreSQL connection pooling",className:"editor-input",required:!0,autoFocus:!0}),s.jsx("p",{className:"text-xs text-muted-foreground/80",children:"The slug is auto-derived from the name. Letters, digits, and hyphens."})]})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("label",{htmlFor:"body",className:"block text-sm font-medium text-foreground",children:"Body"}),s.jsx("textarea",{id:"body",value:p,onChange:j=>h(j.target.value),rows:14,placeholder:"Write the memory body in markdown. Leave blank to start from a template.",className:"editor-input font-mono text-sm"})]}),k?s.jsx("div",{className:"rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm text-destructive",children:k}):null,s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("button",{type:"submit",disabled:g||!d.trim()||!a,className:"inline-flex h-9 items-center rounded-md bg-foreground px-3 text-sm font-medium text-background transition hover:bg-foreground/90 disabled:opacity-50",children:g?"Creating…":"Create Memory"}),s.jsx("button",{type:"button",onClick:()=>e("/memories"),className:"inline-flex h-9 items-center rounded-md border border-border/70 bg-background px-3 text-sm font-medium text-foreground transition hover:bg-muted",children:"Cancel"})]})]})}function UY(){const{slug:e,itemSlug:t}=Vt();return s.jsx(Ec,{loadUrl:`/api/projects/${e}/memories/${t}/edit`,saveUrl:`/api/projects/${e}/memories/${t}`,redirectTo:`/projects/${e}/memories/${t}`,title:"Edit Memory",description:"Edit the body. The frontmatter (name, scope, source, related assignments) is preserved unchanged on save.",documentType:"memory",helpTitle:"Memory editing",helpBody:"Memory edits are body-only. Frontmatter changes from the editor are ignored server-side; the file's existing frontmatter is preserved and `updated` is bumped automatically."})}function HY(){const{data:e,loading:t,error:n}=kO(),[r,o]=m.useState(""),[i,a]=m.useState("all"),[l,d]=m.useState("all"),[f,p]=m.useState("all"),h=(e==null?void 0:e.resources)??[],g=m.useMemo(()=>Array.from(new Set(h.map(b=>b.projectSlug))).sort(),[h]),y=m.useMemo(()=>Array.from(new Set(h.map(b=>b.category).filter(Boolean))).sort(),[h]),k=m.useMemo(()=>Array.from(new Set(h.map(b=>b.source).filter(Boolean))).sort(),[h]),w=m.useMemo(()=>h.filter(b=>{if(i!=="all"&&b.projectSlug!==i||l!=="all"&&b.category!==l||f!=="all"&&b.source!==f)return!1;if(r.trim()){const j=r.toLowerCase();if(!b.name.toLowerCase().includes(j)&&!b.slug.toLowerCase().includes(j)&&!b.projectTitle.toLowerCase().includes(j))return!1}return!0}),[h,r,i,l,f]);return t?s.jsx(jt,{label:"Loading resources…"}):n?s.jsx(Rt,{error:n}):s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsxs("div",{className:"relative",children:[s.jsx(Si,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),s.jsx("input",{type:"text",placeholder:"Search resources…",value:r,onChange:b=>o(b.target.value),className:"h-9 w-64 rounded-md border border-border/70 bg-background pl-9 pr-3 text-sm text-foreground placeholder:text-muted-foreground/60 focus:border-foreground/30 focus:outline-none"})]}),s.jsxs("select",{value:i,onChange:b=>a(b.target.value),className:"editor-input max-w-[170px]",children:[s.jsx("option",{value:"all",children:"All projects"}),g.map(b=>s.jsx("option",{value:b,children:b},b))]}),s.jsxs("select",{value:l,onChange:b=>d(b.target.value),className:"editor-input max-w-[160px]",children:[s.jsx("option",{value:"all",children:"All categories"}),y.map(b=>s.jsx("option",{value:b,children:b},b))]}),s.jsxs("select",{value:f,onChange:b=>p(b.target.value),className:"editor-input max-w-[140px]",children:[s.jsx("option",{value:"all",children:"All sources"}),k.map(b=>s.jsx("option",{value:b,children:b},b))]})]}),s.jsxs(Ie,{to:"/resources/new",className:"inline-flex h-9 items-center gap-2 rounded-md bg-foreground px-3 text-sm font-medium text-background transition hover:bg-foreground/90",children:[s.jsx(It,{className:"h-4 w-4"}),"New Resource"]})]}),w.length===0?s.jsx(Tt,{title:h.length===0?"No resources yet":"No resources match these filters",description:h.length===0?"Resources are reference materials shared across a project — specs, requirements, links, or any reference content.":"Clear the current filters or create a new resource.",actions:h.length===0?s.jsxs(Ie,{to:"/resources/new",className:"inline-flex items-center gap-2 rounded-md bg-foreground px-3 py-2 text-sm font-medium text-background transition hover:bg-foreground/90",children:[s.jsx(It,{className:"h-4 w-4"}),"New Resource"]}):void 0}):s.jsx("div",{className:"surface-panel overflow-x-auto",children:s.jsxs("table",{className:"w-full min-w-[820px] text-left text-sm",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"border-b border-border/60 text-muted-foreground",children:[s.jsx("th",{className:"px-3 pb-3 pt-3 font-medium",children:"Name"}),s.jsx("th",{className:"px-3 pb-3 pt-3 font-medium",children:"Project"}),s.jsx("th",{className:"px-3 pb-3 pt-3 font-medium",children:"Category"}),s.jsx("th",{className:"px-3 pb-3 pt-3 font-medium",children:"Source"}),s.jsx("th",{className:"px-3 pb-3 pt-3 font-medium",children:"# Related"}),s.jsx("th",{className:"px-3 pb-3 pt-3 font-medium",children:"Updated"})]})}),s.jsx("tbody",{children:w.map(b=>s.jsxs("tr",{className:"border-b border-border/50 last:border-0",children:[s.jsx("td",{className:"px-3 py-3",children:s.jsx(Ie,{to:`/projects/${b.projectSlug}/resources/${b.slug}`,className:"font-semibold text-foreground hover:text-primary",children:b.name||b.slug})}),s.jsx("td",{className:"px-3 py-3 text-muted-foreground",children:s.jsx(Ie,{to:`/projects/${b.projectSlug}`,className:"hover:text-foreground hover:underline",children:b.projectTitle})}),s.jsx("td",{className:"px-3 py-3 text-muted-foreground",children:b.category||"—"}),s.jsx("td",{className:"px-3 py-3 text-muted-foreground",children:b.source||"—"}),s.jsx("td",{className:"px-3 py-3 text-muted-foreground",children:b.relatedAssignments.length}),s.jsx("td",{className:"px-3 py-3 text-muted-foreground",children:Gn(b.updated)})]},`${b.projectSlug}/${b.slug}`))})]})})]})}function VY(){const{slug:e,itemSlug:t}=Vt(),n=Ht(),{data:r,loading:o,error:i}=SO(e,t),[a,l]=m.useState(!1),[d,f]=m.useState(!1);async function p(){if(!(!e||!t)){f(!0);try{(await fetch(`/api/projects/${e}/resources/${t}`,{method:"DELETE"})).ok&&n("/resources")}finally{f(!1)}}}return o?s.jsx(jt,{label:"Loading resource…"}):i?s.jsx(Rt,{error:i}):r?s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"flex items-start justify-between gap-4",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("h2",{className:"text-lg font-semibold text-foreground",children:r.name||r.slug}),s.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-2 text-xs text-muted-foreground",children:[s.jsx(Ie,{to:`/projects/${r.projectSlug}`,className:"rounded-full border border-border/60 bg-muted/50 px-2 py-0.5 hover:text-foreground",children:r.projectTitle}),r.category?s.jsxs("span",{className:"rounded-full border border-border/60 bg-muted/50 px-2 py-0.5",children:["Category: ",r.category]}):null,r.source?s.jsxs("span",{className:"rounded-full border border-border/60 bg-muted/50 px-2 py-0.5",children:["Source: ",r.source]}):null,s.jsxs("span",{className:"rounded-full border border-border/60 bg-muted/50 px-2 py-0.5",children:[r.relatedAssignments.length," related"]})]}),s.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-3 text-xs text-muted-foreground",children:[s.jsxs("span",{children:["Created ",es(r.created)]}),s.jsxs("span",{children:["Updated ",es(r.updated)]})]})]}),s.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[s.jsxs(Ie,{to:`/projects/${e}/resources/${t}/edit`,className:"inline-flex h-8 items-center gap-1.5 rounded-md border border-border/70 bg-background px-3 text-xs font-medium text-foreground transition hover:bg-muted",children:[s.jsx(fc,{className:"h-3 w-3"}),"Edit"]}),a?s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("button",{type:"button",onClick:p,disabled:d,className:"inline-flex h-8 items-center gap-1.5 rounded-md bg-destructive px-3 text-xs font-medium text-destructive-foreground transition hover:bg-destructive/90 disabled:opacity-50",children:d?"Deleting…":"Confirm"}),s.jsx("button",{type:"button",onClick:()=>l(!1),className:"inline-flex h-8 items-center rounded-md border border-border/70 bg-background px-3 text-xs font-medium text-foreground transition hover:bg-muted",children:"Cancel"})]}):s.jsxs("button",{type:"button",onClick:()=>l(!0),className:"inline-flex h-8 items-center gap-1.5 rounded-md border border-border/70 bg-background px-3 text-xs font-medium text-destructive transition hover:bg-destructive/10",children:[s.jsx(bn,{className:"h-3 w-3"}),"Delete"]})]})]}),s.jsx("div",{className:"surface-panel p-4",children:s.jsx(xn,{content:r.body})})]}):null}function WY(){const e=Ht(),[t]=Ns(),n=t.get("project"),{data:r,loading:o,error:i}=Zs(),[a,l]=m.useState(n??""),[d,f]=m.useState(""),[p,h]=m.useState(""),[g,y]=m.useState(!1),[k,w]=m.useState(null);m.useEffect(()=>{!a&&r&&r.length>0&&l(n??r[0].slug)},[r,n,a]);async function b(j){if(j.preventDefault(),!(!a||!d.trim())){y(!0),w(null);try{const N=await fetch(`/api/projects/${a}/resources`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:d.trim(),body:p||void 0})}),S=await N.json();if(!N.ok){w(S.error||`HTTP ${N.status}`),y(!1);return}e(`/projects/${S.projectSlug}/resources/${S.slug}`)}catch(N){w(N.message),y(!1)}}}return o?s.jsx(jt,{label:"Loading projects…"}):i?s.jsx(Rt,{error:i}):!r||r.length===0?s.jsx(Rt,{error:"You need at least one project before you can create a resource. Create a project from the sidebar."}):s.jsxs("form",{onSubmit:b,className:"space-y-5",children:[s.jsxs("div",{children:[s.jsx("h2",{className:"text-lg font-semibold text-foreground",children:"New Resource"}),s.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:"Resources are reference material — specs, requirements, links — shared across every assignment in a project."})]}),s.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("label",{htmlFor:"project",className:"block text-sm font-medium text-foreground",children:"Project"}),s.jsx("select",{id:"project",value:a,onChange:j=>l(j.target.value),className:"editor-input",required:!0,children:r.map(j=>s.jsx("option",{value:j.slug,children:j.title},j.slug))})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("label",{htmlFor:"name",className:"block text-sm font-medium text-foreground",children:"Name"}),s.jsx("input",{id:"name",type:"text",value:d,onChange:j=>f(j.target.value),placeholder:"e.g. Auth Requirements",className:"editor-input",required:!0,autoFocus:!0}),s.jsx("p",{className:"text-xs text-muted-foreground/80",children:"The slug is auto-derived from the name. Letters, digits, and hyphens."})]})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("label",{htmlFor:"body",className:"block text-sm font-medium text-foreground",children:"Body"}),s.jsx("textarea",{id:"body",value:p,onChange:j=>h(j.target.value),rows:14,placeholder:"Write the resource body in markdown. Leave blank to start from a template.",className:"editor-input font-mono text-sm"})]}),k?s.jsx("div",{className:"rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm text-destructive",children:k}):null,s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("button",{type:"submit",disabled:g||!d.trim()||!a,className:"inline-flex h-9 items-center rounded-md bg-foreground px-3 text-sm font-medium text-background transition hover:bg-foreground/90 disabled:opacity-50",children:g?"Creating…":"Create Resource"}),s.jsx("button",{type:"button",onClick:()=>e("/resources"),className:"inline-flex h-9 items-center rounded-md border border-border/70 bg-background px-3 text-sm font-medium text-foreground transition hover:bg-muted",children:"Cancel"})]})]})}function qY(){const{slug:e,itemSlug:t}=Vt();return s.jsx(Ec,{loadUrl:`/api/projects/${e}/resources/${t}/edit`,saveUrl:`/api/projects/${e}/resources/${t}`,redirectTo:`/projects/${e}/resources/${t}`,title:"Edit Resource",description:"Edit the body. The frontmatter (name, category, source, related assignments) is preserved unchanged on save.",documentType:"resource",helpTitle:"Resource editing",helpBody:"Resource edits are body-only. Frontmatter changes from the editor are ignored server-side; the file's existing frontmatter is preserved and `updated` is bumped automatically."})}const nv=["projects","playbooks","todos","servers","config"];function KY(e){const t=new Set;for(const n of e.split(",").map(r=>r.trim()))nv.includes(n)&&t.add(n);return t}function HN(e){if(!e)return"never";try{return new Date(e).toLocaleString()}catch{return e}}function GY(){const[e,t]=m.useState(!0),[n,r]=m.useState(null),[o,i]=m.useState(""),[a,l]=m.useState(new Set(nv)),[d,f]=m.useState(!1),[p,h]=m.useState(!1),[g,y]=m.useState(null),[k,w]=m.useState(null),b=m.useCallback(async()=>{try{const T=await fetch("/api/backup");if(!T.ok)throw new Error(`HTTP ${T.status}`);const R=await T.json();r(R),i(R.repo??""),l(KY(R.categories)),f(!1)}catch(T){w({type:"error",message:`Failed to load backup config: ${T instanceof Error?T.message:String(T)}`})}finally{t(!1)}},[]);m.useEffect(()=>{b()},[b]);function j(T){l(R=>{const $=new Set(R);return $.has(T)?$.delete(T):$.add(T),$}),f(!0)}async function N(){h(!0),w(null);try{const T=Array.from(a),R=await fetch("/api/backup/config",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({repo:o.trim()||null,categories:T})}),$=await R.json();if(!R.ok)throw new Error($.error||`HTTP ${R.status}`);r($),f(!1),w({type:"success",message:"Backup configuration saved."})}catch(T){w({type:"error",message:`Save failed: ${T instanceof Error?T.message:String(T)}`})}finally{h(!1)}}async function S(){y("push"),w(null);try{const T=await fetch("/api/backup/push",{method:"POST"}),R=await T.json();if(!T.ok||R.success===!1)throw new Error(R.error||R.message||`HTTP ${T.status}`);w({type:"success",message:R.message||"Backup complete."}),await b()}catch(T){w({type:"error",message:`Backup failed: ${T instanceof Error?T.message:String(T)}`})}finally{y(null)}}async function C(){if(window.confirm("Restore will overwrite local files for the selected categories with the contents of the GitHub repo. This cannot be undone. Continue?")){y("pull"),w(null);try{const R=await fetch("/api/backup/pull",{method:"POST"}),$=await R.json();if(!R.ok||$.success===!1)throw new Error($.error||$.message||`HTTP ${R.status}`);w({type:"success",message:$.message||"Restore complete."}),await b()}catch(R){w({type:"error",message:`Restore failed: ${R instanceof Error?R.message:String(R)}`})}finally{y(null)}}}if(e)return s.jsx(Qe,{title:"GitHub Backup",description:"Back up Syntaur files to a GitHub repository",children:s.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading..."})});const D=!!o.trim()&&a.size>0&&!g&&!d;return s.jsx(Qe,{title:"GitHub Backup",description:"Back up Syntaur files to a GitHub repository and restore from it",children:s.jsxs("div",{className:"space-y-4",children:[k&&s.jsx("div",{className:`rounded-lg border px-4 py-2 text-sm ${k.type==="success"?"border-success-foreground/30 bg-success text-success-foreground":"border-error-foreground/30 bg-error text-error-foreground"}`,children:k.message}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{className:"text-xs font-medium uppercase tracking-wider text-muted-foreground",children:"Repository URL"}),s.jsx("input",{type:"text",value:o,onChange:T=>{i(T.target.value),f(!0)},placeholder:"git@github.com:you/syntaur-backup.git",className:"editor-input w-full text-sm"}),s.jsxs("p",{className:"text-xs text-muted-foreground",children:["SSH or HTTPS URL. Requires ",s.jsx("code",{className:"rounded bg-muted px-1",children:"git"})," installed and credentials configured locally."]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{className:"text-xs font-medium uppercase tracking-wider text-muted-foreground",children:"Categories to back up"}),s.jsx("div",{className:"flex flex-wrap gap-2",children:nv.map(T=>{const R=a.has(T);return s.jsxs("button",{type:"button",onClick:()=>j(T),className:`shell-action text-xs ${R?"bg-primary/10 text-primary hover:bg-primary/20":"bg-muted/30 text-muted-foreground hover:bg-muted/60"}`,children:[s.jsx("span",{className:`mr-1 inline-block h-2 w-2 rounded-full ${R?"bg-primary":"bg-muted-foreground/40"}`}),T]},T)})})]}),s.jsxs("div",{className:"grid grid-cols-1 gap-2 text-xs text-muted-foreground sm:grid-cols-2",children:[s.jsxs("div",{children:[s.jsx("span",{className:"font-medium text-foreground",children:"Last backup: "}),HN((n==null?void 0:n.lastBackup)??null)]}),s.jsxs("div",{children:[s.jsx("span",{className:"font-medium text-foreground",children:"Last restore: "}),HN((n==null?void 0:n.lastRestore)??null)]}),(n==null?void 0:n.locked)&&s.jsx("div",{className:"sm:col-span-2 text-warning-foreground",children:"⚠ A backup operation is in progress or the lock file is stale."})]}),s.jsxs("div",{className:"flex flex-wrap items-center gap-3 pt-2",children:[s.jsxs("button",{className:"shell-action bg-primary/10 text-primary hover:bg-primary/20",onClick:N,disabled:p||!d,children:[s.jsx(qh,{className:"h-3.5 w-3.5"}),p?"Saving...":"Save Config"]}),s.jsxs("button",{className:"shell-action",onClick:S,disabled:!D,title:D?"Back up now":d?"Save config first":"Set repo and pick categories",children:[s.jsx(u4,{className:"h-3.5 w-3.5"}),g==="push"?"Backing up...":"Back Up Now"]}),s.jsxs("button",{className:"shell-action",onClick:C,disabled:!D,title:D?"Restore from backup":d?"Save config first":"Set repo and pick categories",children:[s.jsx($L,{className:"h-3.5 w-3.5"}),g==="pull"?"Restoring...":"Restore"]}),d&&s.jsx("span",{className:"text-xs text-muted-foreground",children:"Unsaved changes"})]}),s.jsxs("p",{className:"flex items-start gap-2 rounded-md border border-border/40 bg-muted/20 p-3 text-xs text-muted-foreground",children:[s.jsx(PL,{className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),s.jsxs("span",{children:["Restore never overwrites ",s.jsx("code",{className:"rounded bg-muted px-1",children:"config.md"})," (would clobber backup settings). The agent sessions database is not backed up — only markdown files."]})]})]})})}function YY(){const{customBindings:e,userBindings:t,actionEntries:n,findConflict:r,bindAction:o,unbindAction:i}=Ci(),[a,l]=m.useState(null),[d,f]=m.useState(null),[p,h]=m.useState(!1),g=Object.values(t).some(S=>typeof S=="string"&&S.length>0);function y(S,C){f({type:S,message:C}),setTimeout(()=>f(null),2500)}function k(S){l({kind:S,combo:null,conflict:null,saving:!1,error:null})}function w(S){if(!a||S.key==="Escape")return;if(S.key==="Enter"&&a.combo){S.preventDefault(),b();return}if(S.key==="Enter")return;S.preventDefault(),S.stopPropagation();const C=R2(S.nativeEvent);if(!C)return;const D=r(C,a.kind);l({...a,combo:C,conflict:D,error:null})}async function b(){var S;if(a!=null&&a.combo){if((S=a.conflict)!=null&&S.description){l({...a,error:`Reserved: ${a.conflict.description}`});return}l({...a,saving:!0,error:null});try{await o(a.kind,a.combo),l(null),y("success",`Bound ${fu[a.kind]}`)}catch(C){l({...a,saving:!1,error:C instanceof Error?C.message:"Failed to save"})}}}async function j(S){try{await i(S),y("success",`Cleared ${fu[S]} binding`)}catch(C){y("error",C instanceof Error?C.message:"Failed to clear binding")}}async function N(){if(!p){h(!0);try{await Y6(),y("success","All hotkey bindings cleared")}catch(S){y("error",S instanceof Error?S.message:"Failed to reset bindings")}finally{h(!1)}}}return s.jsxs(Qe,{title:"Hotkey Bindings",description:"Each canonical create action ships with a default hotkey that fires the action without opening the palette. Override any of them below — Clear restores the default.",actions:g?s.jsxs("button",{className:"shell-action text-xs",onClick:()=>void N(),disabled:p,children:[s.jsx(Qs,{className:"h-3 w-3"}),"Restore defaults"]}):void 0,children:[d?s.jsx("div",{className:`mb-3 rounded-md border px-3 py-1.5 text-xs ${d.type==="success"?"border-success-foreground/30 bg-success text-success-foreground":"border-error-foreground/30 bg-error text-error-foreground"}`,children:d.message}):null,s.jsx("ul",{className:"space-y-2",children:Qh.map(S=>{var $,_;const C=n.find(U=>U.bindableKind===S),D=e[S],T=typeof t[S]=="string"&&!!t[S],R=(a==null?void 0:a.kind)===S;return s.jsxs("li",{className:"flex flex-wrap items-center gap-3 rounded-md border border-border/40 bg-background/60 px-3 py-2",children:[s.jsx(ub,{className:"h-4 w-4 text-muted-foreground","aria-hidden":"true"}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("div",{className:"text-sm text-foreground",children:(C==null?void 0:C.title)??fu[S]}),C!=null&&C.subtitle?s.jsx("div",{className:"text-xs text-muted-foreground",children:C.subtitle}):null]}),D?s.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[s.jsx("kbd",{className:"rounded border border-border/70 bg-muted px-2 py-0.5 font-mono text-xs text-foreground",children:Gs(D)}),s.jsx("span",{className:`text-[10px] uppercase tracking-wide ${T?"text-primary":"text-muted-foreground"}`,children:T?"custom":"default"})]}):s.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:"unbound"}),s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("button",{type:"button",className:"shell-action text-xs",onClick:()=>k(S),children:D?"Rebind":"Bind"}),T?s.jsxs("button",{type:"button",className:"shell-action text-xs",onClick:()=>void j(S),"aria-label":`Restore default ${fu[S]} binding`,children:[s.jsx(Cd,{className:"h-3 w-3"}),"Restore default"]}):null]}),R?s.jsx("div",{className:"mt-2 w-full rounded-md border border-primary/40 bg-primary/5 px-3 py-3 text-center outline-none",tabIndex:0,autoFocus:!0,onKeyDown:w,onBlur:()=>{(a==null?void 0:a.kind)===S&&!a.saving&&l(null)},children:a!=null&&a.combo?s.jsxs("div",{className:"space-y-2",children:[s.jsx("div",{className:"text-base font-semibold tracking-wide text-foreground",children:Gs(a.combo)}),($=a.conflict)!=null&&$.description?s.jsxs("div",{className:"text-xs text-destructive",children:["Reserved: ",a.conflict.description]}):(_=a.conflict)!=null&&_.kind?s.jsxs("div",{className:"text-xs text-amber-500 dark:text-amber-400",children:['Already bound to "',fu[a.conflict.kind],'". Press Enter to overwrite.']}):s.jsx("div",{className:"text-xs text-muted-foreground",children:"Press Enter to save, Esc to cancel, any other key to retry."}),a.error?s.jsx("div",{className:"text-xs text-destructive",children:a.error}):null]}):s.jsx("div",{className:"text-xs text-muted-foreground",children:"Press the key combination you want to bind…"})}):null]},S)})})]})}const XY={kanban:"Kanban",list:"List",table:"Table"},QY={comfortable:"Comfortable",compact:"Compact"},JY={title:"Title",status:"Status",priority:"Priority",assignee:"Assignee",dependencies:"Dependencies",created:"Created",updated:"Updated"},ZY={asc:"Ascending",desc:"Descending"};function eX(){const e=rG(),t=e.global,[n,r]=m.useState(!1),[o,i]=m.useState(null);function a(f,p){i({type:f,message:p}),setTimeout(()=>i(null),2e3)}async function l(f,p){if(t[f]!==p){r(!0);try{await QP({[f]:p}),a("success","Saved")}catch(h){a("error",h instanceof Error?h.message:"Failed to save")}finally{r(!1)}}}async function d(){if(e.custom){r(!0);try{await sG(),a("success","Reset to defaults")}catch(f){a("error",f instanceof Error?f.message:"Failed to reset")}finally{r(!1)}}}return s.jsxs(Qe,{title:"View defaults",description:"Defaults for the assignments board, list, and table views. Per-project overrides are saved automatically as you use them.",actions:e.custom?s.jsxs("button",{type:"button",className:"shell-action text-xs",onClick:d,disabled:n,children:[s.jsx(Qs,{className:"h-3 w-3"}),"Reset"]}):void 0,children:[o&&s.jsx("div",{className:`mb-3 rounded-md border px-3 py-1.5 text-xs ${o.type==="success"?"border-success-foreground/30 bg-success text-success-foreground":"border-error-foreground/30 bg-error text-error-foreground"}`,children:o.message}),s.jsxs("dl",{className:"grid grid-cols-1 gap-4 sm:grid-cols-2",children:[s.jsxs("div",{children:[s.jsx("dt",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"Default view"}),s.jsx("dd",{className:"mt-1.5 inline-flex rounded-md border border-border/60 p-0.5",children:sw.map(f=>s.jsx("button",{type:"button",onClick:()=>l("defaultView",f),disabled:n,"aria-pressed":t.defaultView===f,className:`px-3 py-1 text-xs ${t.defaultView===f?"rounded bg-foreground text-background":"text-muted-foreground hover:text-foreground"}`,children:XY[f]},f))})]}),s.jsxs("div",{children:[s.jsx("dt",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"Density"}),s.jsx("dd",{className:"mt-1.5 inline-flex rounded-md border border-border/60 p-0.5",children:i6.map(f=>s.jsx("button",{type:"button",onClick:()=>l("density",f),disabled:n,"aria-pressed":t.density===f,className:`px-3 py-1 text-xs ${t.density===f?"rounded bg-foreground text-background":"text-muted-foreground hover:text-foreground"}`,children:QY[f]},f))})]}),s.jsxs("div",{children:[s.jsx("dt",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"Sort by"}),s.jsx("dd",{className:"mt-1.5",children:s.jsx("select",{value:t.sortField,onChange:f=>l("sortField",f.target.value),disabled:n,className:"editor-input max-w-[220px]",children:ST.map(f=>s.jsx("option",{value:f,children:JY[f]??f},f))})})]}),s.jsxs("div",{children:[s.jsx("dt",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"Direction"}),s.jsx("dd",{className:"mt-1.5 inline-flex rounded-md border border-border/60 p-0.5",children:o6.map(f=>s.jsx("button",{type:"button",onClick:()=>l("sortDirection",f),disabled:n,"aria-pressed":t.sortDirection===f,className:`px-3 py-1 text-xs ${t.sortDirection===f?"rounded bg-foreground text-background":"text-muted-foreground hover:text-foreground"}`,children:ZY[f]},f))})]})]})]})}function tX({value:e,onChange:t,knownSlugs:n,rows:r=2,placeholder:o,className:i,wrapperClassName:a,singleLine:l,"aria-label":d}){const[f,p]=m.useState(0),[h,g]=m.useState(0),[y,k]=m.useState(!1),w=m.useRef(null),b=m_(e,f),j=b?g_(b.partial,n):[],N=!y&&j.length>0,S=Math.min(h,Math.max(0,j.length-1)),C=_=>l?_.replace(/[\r\n]+/g," "):_;function D(_){t(C(_.target.value)),p(_.target.selectionStart??_.target.value.length),g(0),k(!1)}function T(_){p(_.currentTarget.selectionStart??e.length)}function R(_){if(!b||!_)return;const U=x_(e,b,_);t(C(U.text)),p(U.caret),g(0),k(!0),requestAnimationFrame(()=>{const I=w.current;I&&(I.focus(),I.setSelectionRange(U.caret,U.caret))})}function $(_){N&&(_.key==="ArrowDown"?(_.preventDefault(),g(U=>Math.min(U+1,j.length-1))):_.key==="ArrowUp"?(_.preventDefault(),g(U=>Math.max(U-1,0))):_.key==="Enter"||_.key==="Tab"?(_.preventDefault(),R(j[S])):_.key==="Escape"&&(_.preventDefault(),k(!0)))}return s.jsxs("div",{className:Ce("relative",a),children:[s.jsx("textarea",{ref:w,value:e,rows:r,placeholder:o,"aria-label":d,onChange:D,onKeyDown:$,onKeyUp:T,onClick:T,className:i}),N&&s.jsx("ul",{role:"listbox",className:"absolute left-0 right-0 top-full z-30 mt-1 max-h-48 overflow-auto rounded-md border border-border/70 bg-background py-1 shadow-lg",children:j.map((_,U)=>s.jsx("li",{children:s.jsxs("button",{type:"button",role:"option","aria-selected":U===S,onMouseDown:I=>{I.preventDefault(),R(_)},className:Ce("flex w-full items-center gap-2 px-2.5 py-1.5 text-left font-mono text-sm transition-colors hover:bg-accent",U===S&&"bg-accent"),children:[s.jsx("span",{className:"text-muted-foreground",children:"@"}),s.jsx("span",{className:"truncate",children:_})]})},_))})]})}const nX={first:"first",last:"last",none:"none"};function A_(){return`row_${Math.random().toString(36).slice(2,10)}_${Date.now().toString(36)}`}function vu(e){return e.map(t=>({rowKey:A_(),id:t.id,originalId:t.id,isNew:!1,idEditable:!1,autoSlugFromLabel:!1,label:t.label,command:t.command,argsText:t.args?t.args.join(" "):"",promptArgPosition:t.promptArgPosition??"first",resolveFromShellAliases:t.resolveFromShellAliases??!1,default:t.default??!1,model:t.model??"",playbook:t.playbook??"",launchPrompt:t.launchPrompt??"",fieldErrors:{}}))}function rX(e){return e.map(t=>{const n={id:t.id,label:t.label,command:t.command},r=t.argsText.split(/[,\s]+/).filter(Boolean);return r.length>0&&(n.args=r),t.promptArgPosition!=="first"&&(n.promptArgPosition=t.promptArgPosition),t.resolveFromShellAliases&&(n.resolveFromShellAliases=!0),t.default&&(n.default=!0),t.model.trim()&&(n.model=t.model.trim()),t.playbook.trim()&&(n.playbook=t.playbook.trim()),t.launchPrompt.trim()&&(n.launchPrompt=t.launchPrompt),n})}function sX(e){if(e.length===0)return e;let t=-1;for(let n=0;n<e.length;n++)if(e[n].default){t=n;break}return e.map((n,r)=>({...n,default:t===-1?r===0:r===t}))}function oX(e,t){return!t||t.length===0?e:e.map((n,r)=>{const o={};for(const i of t){if(i.index!==void 0){i.index===r&&(o[i.field]=i.message);continue}if(i.id!==void 0){i.id===n.id&&(o[i.field]=i.message);continue}o[i.field]=i.message}return{...n,fieldErrors:o}})}function iX(e){return e.map(t=>Object.keys(t.fieldErrors).length===0?t:{...t,fieldErrors:{}})}function aX(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++){const r=e[n],o=t[n];if(r.id!==o.id||r.label!==o.label||r.command!==o.command||r.argsText!==o.argsText||r.promptArgPosition!==o.promptArgPosition||r.resolveFromShellAliases!==o.resolveFromShellAliases||r.default!==o.default||r.model!==o.model||r.playbook!==o.playbook||r.launchPrompt!==o.launchPrompt)return!1}return!0}function lX({row:e,index:t,canRemove:n,playbooks:r,onPatch:o,onSetDefault:i,onRemove:a}){const{attributes:l,listeners:d,setNodeRef:f,setActivatorNodeRef:p,transform:h,transition:g,isDragging:y}=gm({id:e.rowKey}),k={transform:bs.Transform.toString(h),transition:g,zIndex:y?50:void 0,position:y?"relative":void 0};function w(C){const D={label:C};if(e.autoSlugFromLabel){const T=Pr(C);T&&SG.test(T)?D.id=T:D.id=`agent-${t+1}`}o(D)}function b(C){o({id:C,autoSlugFromLabel:!1})}const j=C=>e.fieldErrors[C]?"border-error-foreground/60":"",N=m.useMemo(()=>r.map(C=>C.slug),[r]),S=m.useMemo(()=>y_(e.launchPrompt,N),[e.launchPrompt,N]);return s.jsxs("div",{ref:f,style:k,className:`surface-panel space-y-2 px-3 py-2 ${y?"opacity-60 shadow-lg":""}`,children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("button",{ref:p,...l,...d,type:"button","aria-label":"Drag to reorder",className:"cursor-grab active:cursor-grabbing text-muted-foreground/40 hover:text-muted-foreground transition touch-none",children:s.jsx(dc,{className:"h-4 w-4"})}),s.jsxs("label",{className:"inline-flex items-center gap-1.5 text-xs text-muted-foreground",children:[s.jsx("input",{type:"radio",name:"agents-default",checked:e.default,onChange:i,className:"h-3 w-3 cursor-pointer accent-foreground"}),"Default"]}),s.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[s.jsx("span",{className:"text-[10px] font-mono uppercase tracking-wide text-muted-foreground/70",children:"id"}),e.idEditable?s.jsx("input",{type:"text",value:e.id,onChange:C=>b(C.target.value),className:`editor-input w-32 font-mono text-xs ${j("id")}`,"aria-label":"Agent id"}):s.jsx("span",{className:"font-mono text-xs text-muted-foreground",children:e.id}),s.jsx("button",{type:"button",onClick:a,disabled:!n,"aria-label":"Remove agent",className:"rounded p-1 text-muted-foreground/60 transition hover:bg-foreground/[0.04] hover:text-foreground disabled:cursor-not-allowed disabled:opacity-30",children:s.jsx(bn,{className:"h-3.5 w-3.5"})})]})]}),e.fieldErrors.id&&s.jsx("p",{className:"ml-7 text-[11px] text-error-foreground",children:e.fieldErrors.id}),s.jsxs("div",{className:"ml-7 grid grid-cols-1 gap-2 sm:grid-cols-2",children:[s.jsxs("div",{children:[s.jsx("label",{className:"text-[11px] uppercase tracking-wide text-muted-foreground/80",children:"Label"}),s.jsx("input",{type:"text",value:e.label,onChange:C=>w(C.target.value),className:`editor-input mt-0.5 w-full ${j("label")}`}),e.fieldErrors.label&&s.jsx("p",{className:"mt-0.5 text-[11px] text-error-foreground",children:e.fieldErrors.label})]}),s.jsxs("div",{children:[s.jsx("label",{className:"text-[11px] uppercase tracking-wide text-muted-foreground/80",children:"Command"}),s.jsx("input",{type:"text",value:e.command,placeholder:"claude or /usr/local/bin/claude",onChange:C=>o({command:C.target.value}),className:`editor-input mt-0.5 w-full font-mono ${j("command")}`}),e.fieldErrors.command&&s.jsx("p",{className:"mt-0.5 text-[11px] text-error-foreground",children:e.fieldErrors.command})]}),s.jsxs("div",{children:[s.jsx("label",{className:"text-[11px] uppercase tracking-wide text-muted-foreground/80",children:"Args (comma- or space-separated)"}),s.jsx("input",{type:"text",value:e.argsText,placeholder:"--dangerously-skip-permissions",onChange:C=>o({argsText:C.target.value}),className:`editor-input mt-0.5 w-full font-mono ${j("args")}`}),e.fieldErrors.args&&s.jsx("p",{className:"mt-0.5 text-[11px] text-error-foreground",children:e.fieldErrors.args})]}),s.jsxs("div",{children:[s.jsx("label",{className:"text-[11px] uppercase tracking-wide text-muted-foreground/80",children:"Prompt arg position"}),s.jsx("select",{value:e.promptArgPosition,onChange:C=>o({promptArgPosition:C.target.value}),className:`editor-input mt-0.5 w-full ${j("promptArgPosition")}`,children:u_.map(C=>s.jsx("option",{value:C,children:nX[C]},C))}),e.fieldErrors.promptArgPosition&&s.jsx("p",{className:"mt-0.5 text-[11px] text-error-foreground",children:e.fieldErrors.promptArgPosition})]}),s.jsxs("div",{children:[s.jsx("label",{className:"text-[11px] uppercase tracking-wide text-muted-foreground/80",children:"Model"}),s.jsx("input",{type:"text",value:e.model,placeholder:"opus (optional)",onChange:C=>o({model:C.target.value}),className:`editor-input mt-0.5 w-full font-mono ${j("model")}`}),e.fieldErrors.model&&s.jsx("p",{className:"mt-0.5 text-[11px] text-error-foreground",children:e.fieldErrors.model})]}),s.jsxs("div",{className:"col-span-full",children:[s.jsx("label",{className:"text-[11px] uppercase tracking-wide text-muted-foreground/80",children:"Launch prompt"}),s.jsx(tX,{value:e.launchPrompt,onChange:C=>o({launchPrompt:C}),knownSlugs:N,singleLine:!0,rows:5,placeholder:"@assignment Run @<playbook> end-to-end. (optional)",wrapperClassName:"mt-0.5",className:`editor-input w-full resize-y font-mono leading-relaxed min-h-[6rem] ${j("launchPrompt")}`,"aria-label":"Launch prompt"}),e.fieldErrors.launchPrompt&&s.jsx("p",{className:"mt-0.5 text-[11px] text-error-foreground",children:e.fieldErrors.launchPrompt}),S.length>0&&!e.fieldErrors.launchPrompt&&s.jsx("ul",{className:"mt-0.5 space-y-0.5 text-[11px] text-error-foreground",children:S.map(C=>s.jsx("li",{children:C},C))})]}),s.jsxs("label",{className:"col-span-full inline-flex items-center gap-1.5 text-xs text-muted-foreground",children:[s.jsx("input",{type:"checkbox",checked:e.resolveFromShellAliases,onChange:C=>o({resolveFromShellAliases:C.target.checked}),className:"h-3.5 w-3.5 cursor-pointer accent-foreground"}),"Resolve from shell aliases (look up ",s.jsx("code",{className:"font-mono",children:"command"})," in your interactive shell before launching)"]})]})]})}function cX(){const e=p_(),t=zv(),n=m.useMemo(()=>{var $;return((($=t.data)==null?void 0:$.playbooks)??[]).filter(_=>_.enabled).map(_=>({slug:_.slug,name:_.name}))},[t.data]),[r,o]=m.useState(()=>vu(e.agents)),[i,a]=m.useState(()=>vu(e.agents)),[l,d]=m.useState(!1),[f,p]=m.useState(null),[h,g]=m.useState(null);m.useEffect(()=>{const $=vu(e.agents);o($),a($),p(null)},[e.agents]);const y=m.useMemo(()=>!aX(r,i),[r,i]),k=cm(vi(bc,{activationConstraint:{distance:8}}),vi(yc));function w($,_){g({type:$,message:_}),setTimeout(()=>g(null),2500)}function b($,_){o(U=>U.map(I=>I.rowKey===$?{...I,..._,fieldErrors:uX(I.fieldErrors,_)}:I))}function j($){o(_=>_.map(U=>({...U,default:U.rowKey===$})))}function N(){o($=>{const _=new Set($.map(L=>L.id)),U="new-agent";let I=U,F=1;for(;_.has(I);)F+=1,I=`${U}-${F}`;const M=F===1?"New Agent":`New Agent ${F}`,A={rowKey:A_(),id:I,originalId:null,isNew:!0,idEditable:!0,autoSlugFromLabel:!0,label:M,command:"",argsText:"",promptArgPosition:"first",resolveFromShellAliases:!0,default:!1,model:"",playbook:"",launchPrompt:"",fieldErrors:{}};return[...$,A]})}function S($){o(_=>_.filter(U=>U.rowKey!==$))}async function C(){d(!0),p(null);try{const $=sX(r),_=rX($),U=await EG(_),I=vu(U.agents);o(I),a(I),w("success","Agents saved")}catch($){if($ instanceof d_)p($.message),o(_=>oX(iX(_),$.fieldErrors)),w("error",$.message);else{const _=$ instanceof Error?$.message:"Failed to save";p(_),w("error",_)}}finally{d(!1)}}function D(){o(i),p(null)}async function T(){if(e.custom&&window.confirm("Reset agents to built-in defaults? Any custom agents will be deleted from your config.")){d(!0),p(null);try{const $=await TG(),_=vu($.agents);o(_),a(_),w("success","Reset to defaults")}catch($){const _=$ instanceof Error?$.message:"Failed to reset";p(_),w("error",_)}finally{d(!1)}}}function R($){const{active:_,over:U}=$;!U||_.id===U.id||o(I=>{const F=I.findIndex(A=>A.rowKey===_.id),M=I.findIndex(A=>A.rowKey===U.id);return F===-1||M===-1?I:vc(I,F,M)})}return s.jsxs(Qe,{title:"Agents",description:"Configure which agents the dashboard and 'Open in agent' actions can launch. The default agent is used when no other one is specified.",actions:e.custom?s.jsxs("button",{type:"button",className:"shell-action text-xs",onClick:T,disabled:l,children:[s.jsx(Qs,{className:"h-3 w-3"}),"Reset"]}):void 0,children:[!e.custom&&s.jsxs("div",{className:"flex items-start gap-2 rounded-md border border-border/60 bg-foreground/[0.02] px-3 py-2 text-xs text-muted-foreground",children:[s.jsx(_v,{className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),s.jsxs("span",{children:["Using built-in defaults — first save will write your own list to"," ",s.jsx("code",{className:"font-mono",children:"~/.syntaur/config.md"}),"."]})]}),h&&s.jsx("div",{className:`rounded-md border px-3 py-1.5 text-xs ${h.type==="success"?"border-success-foreground/30 bg-success text-success-foreground":"border-error-foreground/30 bg-error text-error-foreground"}`,children:h.message}),f&&(!h||h.type!=="error")&&s.jsx("div",{className:"rounded-md border border-error-foreground/30 bg-error px-3 py-1.5 text-xs text-error-foreground",children:f}),s.jsx(hm,{sensors:k,collisionDetection:um,onDragEnd:R,children:s.jsx(mm,{items:r.map($=>$.rowKey),strategy:xw,children:s.jsx("div",{className:"space-y-2",children:r.map(($,_)=>s.jsx(lX,{row:$,index:_,canRemove:r.length>1,playbooks:n,onPatch:U=>b($.rowKey,U),onSetDefault:()=>j($.rowKey),onRemove:()=>S($.rowKey)},$.rowKey))})})}),s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[s.jsxs("button",{type:"button",onClick:N,disabled:l,className:"shell-action text-xs",children:[s.jsx(It,{className:"h-3 w-3"}),"Add agent"]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("button",{type:"button",onClick:D,disabled:!y||l,className:"shell-action text-xs",children:"Discard"}),s.jsxs("button",{type:"button",onClick:C,disabled:!y||l,className:"shell-action text-xs",children:[s.jsx(qh,{className:"h-3 w-3"}),"Save"]})]})]})]})}function uX(e,t){if(Object.keys(e).length===0)return e;const n={...e};return"id"in t&&delete n.id,"label"in t&&delete n.label,"command"in t&&delete n.command,"argsText"in t&&delete n.args,"promptArgPosition"in t&&delete n.promptArgPosition,"resolveFromShellAliases"in t&&delete n.resolveFromShellAliases,"default"in t&&delete n.default,"model"in t&&delete n.model,"playbook"in t&&delete n.playbook,"launchPrompt"in t&&delete n.launchPrompt,n}const P_=["terminal-app","iterm","ghostty","alacritty","warp","kitty","cmux"],Nh={terminal:"terminal-app",custom:!1};let El=null,vl=null,Ch=0;const rv=new Set;function __(e){El=e;for(const t of rv)t(e)}function p0(e){if(!e||typeof e!="object")return Nh;const t=e;return{terminal:typeof t.terminal=="string"&&P_.includes(t.terminal)?t.terminal:Nh.terminal,custom:t.custom===!0}}function dX(){if(El)return Promise.resolve(El);if(vl)return vl;const e=++Ch;return vl=fetch("/api/config/terminal").then(t=>{if(!t.ok)throw new Error(`HTTP ${t.status}`);return t.json()}).then(t=>{vl=null;const n=p0(t);return e!==Ch?El??n:(El=n,n)}).catch(()=>(vl=null,Nh)),vl}function fX(){const[e,t]=m.useState(()=>El??Nh);return m.useEffect(()=>{let n=!1;return dX().then(r=>{n||t(r)}),rv.add(t),()=>{n=!0,rv.delete(t)}},[]),e}async function pX(e){++Ch;const t=await fetch("/api/config/terminal",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({terminal:e})});if(!t.ok){const r=await t.json().catch(()=>null);throw new Error((r==null?void 0:r.error)??`HTTP ${t.status}`)}const n=p0(await t.json());return __(n),n}async function hX(){++Ch;const e=await fetch("/api/config/terminal",{method:"DELETE"});if(!e.ok){const n=await e.json().catch(()=>null);throw new Error((n==null?void 0:n.error)??`HTTP ${e.status}`)}const t=p0(await e.json());return __(t),t}const mp={"terminal-app":"Terminal (macOS built-in)",iterm:"iTerm2",ghostty:"Ghostty",alacritty:"Alacritty",warp:"Warp",kitty:"kitty",cmux:"cmux"};function mX(){const{terminal:e,custom:t}=fX(),[n,r]=m.useState(!1),[o,i]=m.useState(null);function a(f){i(f),setTimeout(()=>i(null),2500)}async function l(f){if(!(f===e&&t)){r(!0);try{await pX(f),a({type:"success",message:`Terminal set to ${mp[f]}.`})}catch(p){a({type:"error",message:p instanceof Error?p.message:"Save failed."})}finally{r(!1)}}}async function d(){r(!0);try{const f=await hX();a({type:"success",message:`Reset to OS default (${mp[f.terminal]}).`})}catch(f){a({type:"error",message:f instanceof Error?f.message:"Reset failed."})}finally{r(!1)}}return s.jsxs(Qe,{title:"Terminal",description:`Which terminal "Open in agent" launches. Defaults to the OS choice (currently ${mp[e]}) when unset.`,actions:t?s.jsxs("button",{className:"shell-action text-xs",onClick:d,disabled:n,type:"button",children:[s.jsx(Qs,{className:"h-3 w-3"}),"Reset to OS default"]}):void 0,children:[o&&s.jsx("div",{className:`mb-3 rounded-md border px-3 py-1.5 text-xs ${o.type==="success"?"border-success-foreground/30 bg-success text-success-foreground":"border-error-foreground/30 bg-error text-error-foreground"}`,children:o.message}),s.jsxs("label",{className:"block text-sm",children:[s.jsx("span",{className:"mb-1.5 block text-xs font-medium text-muted-foreground",children:"Launch in"}),s.jsx("select",{value:e,onChange:f=>l(f.target.value),disabled:n,className:"w-full max-w-sm rounded-md border border-border/60 bg-background px-3 py-1.5 text-sm focus:border-primary focus:outline-none focus:ring-2 focus:ring-primary/30 disabled:opacity-60",children:P_.map(f=>s.jsx("option",{value:f,children:mp[f]},f))})]})]})}const VN={all:"Everything",assignment:"Assignments",project:"Projects",todo:"Todos",server:"Servers",playbook:"Playbooks"},gX=["all",...Jh];function Oy(e){return Object.entries(e).map(([t,n])=>({prefix:t,kind:n}))}function xX(e){const t=[],n={},r=new Set;for(const{prefix:i,kind:a}of e){const l=i.trim();if(l===""){t.push("An alias prefix is empty.");continue}if(r.has(l)){t.push(`Duplicate prefix "${l}".`);continue}r.add(l),n[l]=a}const o=FO(n);return o.ok||t.push(...o.errors),{map:n,errors:t}}function yX(){const{search:e,custom:t}=qv(),[n,r]=m.useState(e.defaultScope),[o,i]=m.useState(e.externalIds),[a,l]=m.useState(()=>Oy(e.aliases)),[d,f]=m.useState(!1),[p,h]=m.useState(!1),[g,y]=m.useState(null),k=JSON.stringify(e);m.useEffect(()=>{d||(r(e.defaultScope),i(e.externalIds),l(Oy(e.aliases)))},[k]);const{map:w,errors:b}=xX(a);function j(_){y(_),setTimeout(()=>y(null),2500)}function N(){l(_=>[..._,{prefix:"",kind:"assignment"}]),f(!0)}function S(_){l(U=>U.filter((I,F)=>F!==_)),f(!0)}function C(_,U){l(I=>I.map((F,M)=>M===_?{...F,...U}:F)),f(!0)}function D(_){r(_.defaultScope),i(_.externalIds),l(Oy(_.aliases)),f(!1)}async function T(){if(!(b.length>0)){h(!0);try{const _=await UO({defaultScope:n,aliases:w,externalIds:o});D(_.search),j({type:"success",message:"Search settings saved."})}catch(_){j({type:"error",message:_ instanceof Error?_.message:"Save failed."})}finally{h(!1)}}}async function R(){h(!0);try{const _=await HO();D(_.search),j({type:"success",message:"Reset to defaults."})}catch(_){j({type:"error",message:_ instanceof Error?_.message:"Reset failed."})}finally{h(!1)}}const $=d&&b.length===0&&!p;return s.jsxs(Qe,{title:"Search",description:"Customize the Cmd+K command palette: default scope, type-alias prefixes, and external-ID indexing.",actions:t?s.jsxs("button",{className:"shell-action text-xs",onClick:R,disabled:p,type:"button",children:[s.jsx(Qs,{className:"h-3 w-3"}),"Reset to defaults"]}):void 0,children:[g&&s.jsx("div",{className:`mb-3 rounded-md border px-3 py-1.5 text-xs ${g.type==="success"?"border-success-foreground/30 bg-success text-success-foreground":"border-error-foreground/30 bg-error text-error-foreground"}`,children:g.message}),s.jsxs("div",{className:"space-y-5",children:[s.jsxs("label",{className:"block text-sm",children:[s.jsx("span",{className:"mb-1.5 block text-xs font-medium text-muted-foreground",children:"Default scope"}),s.jsx("select",{value:n,onChange:_=>{r(_.target.value),f(!0)},disabled:p,className:"w-full max-w-sm rounded-md border border-border/60 bg-background px-3 py-1.5 text-sm focus:border-primary focus:outline-none focus:ring-2 focus:ring-primary/30 disabled:opacity-60",children:gX.map(_=>s.jsx("option",{value:_,children:VN[_]},_))}),s.jsxs("span",{className:"mt-1 block text-xs text-muted-foreground",children:["Searches with no type prefix are limited to this. An ",s.jsx("code",{children:"all:"})," prefix (or empty box) always searches everything."]})]}),s.jsxs("div",{className:"text-sm",children:[s.jsx("span",{className:"mb-1.5 block text-xs font-medium text-muted-foreground",children:"Type-alias prefixes"}),s.jsx("div",{className:"space-y-2",children:a.map((_,U)=>s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"text",value:_.prefix,onChange:I=>C(U,{prefix:I.target.value}),placeholder:"prefix",disabled:p,spellCheck:!1,className:"w-24 rounded-md border border-border/60 bg-background px-2 py-1 text-sm focus:border-primary focus:outline-none focus:ring-2 focus:ring-primary/30 disabled:opacity-60"}),s.jsx("span",{className:"text-muted-foreground",children:"→"}),s.jsx("select",{value:_.kind,onChange:I=>C(U,{kind:I.target.value}),disabled:p,className:"rounded-md border border-border/60 bg-background px-2 py-1 text-sm focus:border-primary focus:outline-none focus:ring-2 focus:ring-primary/30 disabled:opacity-60",children:Jh.map(I=>s.jsx("option",{value:I,children:VN[I]},I))}),s.jsx("button",{type:"button",onClick:()=>S(U),disabled:p,"aria-label":`Remove alias ${_.prefix}`,className:"rounded-md p-1 text-muted-foreground hover:bg-muted hover:text-foreground disabled:opacity-60",children:s.jsx(Cd,{className:"h-3.5 w-3.5"})})]},U))}),s.jsxs("button",{type:"button",onClick:N,disabled:p,className:"mt-2 inline-flex items-center gap-1 text-xs text-primary hover:underline disabled:opacity-60",children:[s.jsx(It,{className:"h-3 w-3"}),"Add alias"]})]}),s.jsxs("label",{className:"flex items-start gap-2 text-sm",children:[s.jsx("input",{type:"checkbox",checked:o,onChange:_=>{i(_.target.checked),f(!0)},disabled:p,className:"mt-0.5"}),s.jsxs("span",{children:[s.jsx("span",{className:"font-medium",children:"Index external IDs"}),s.jsxs("span",{className:"mt-0.5 block text-xs text-muted-foreground",children:["Fold external IDs (e.g. Jira keys) into search and enable"," ",s.jsx("code",{children:"jira:"}),"/",s.jsx("code",{children:"externalid:"})," and bare-ID matching."]})]})]}),d&&b.length>0&&s.jsx("ul",{className:"space-y-1 text-xs text-error-foreground",children:b.map((_,U)=>s.jsx("li",{children:_},U))}),s.jsx("div",{children:s.jsx("button",{type:"button",onClick:T,disabled:!$,className:"rounded-md bg-primary px-3 py-1.5 text-sm font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50",children:p?"Saving…":"Save search settings"})})]})]})}function wu(e){return e===oh?"Ungrouped":e}function bX(){const{data:e,loading:t,error:n,refetch:r}=Sa(),{hidden:o,custom:i,loading:a,error:l,reload:d}=$T(),[f,p]=m.useState(!1),[h,g]=m.useState(null);function y(j){g(j),setTimeout(()=>g(null),2500)}const k=e?[...e.workspaces,...e.hasUngrouped?[oh]:[]]:[];async function w(j,N){const S=N?o.filter(C=>C!==j):[...o,j];p(!0);try{await iz(S),y({type:"success",message:N?`Showing "${wu(j)}" in the left nav.`:`Hiding "${wu(j)}" from the left nav.`})}catch(C){y({type:"error",message:C instanceof Error?C.message:"Save failed."})}finally{p(!1)}}async function b(){p(!0);try{await az(),y({type:"success",message:"All workspaces shown in the left nav."})}catch(j){y({type:"error",message:j instanceof Error?j.message:"Reset failed."})}finally{p(!1)}}return s.jsxs(Qe,{title:"Workspace visibility",description:"Choose which workspaces appear in the left nav. Hidden workspaces stay fully reachable by direct URL — this only controls the sidebar.",actions:i?s.jsxs("button",{className:"shell-action text-xs",onClick:b,disabled:f,type:"button",children:[s.jsx(Qs,{className:"h-3 w-3"}),"Show all"]}):void 0,children:[h&&s.jsx("div",{className:`mb-3 rounded-md border px-3 py-1.5 text-xs ${h.type==="success"?"border-success-foreground/30 bg-success text-success-foreground":"border-error-foreground/30 bg-error text-error-foreground"}`,children:h.message}),t||a?s.jsx("div",{className:"text-sm text-muted-foreground",children:"Loading workspaces…"}):n||l?s.jsxs("div",{className:"flex items-center gap-3 text-sm text-error-foreground",children:[s.jsx("span",{children:n?"Failed to load workspaces.":"Failed to load the visibility preference."}),s.jsxs("button",{type:"button",className:"shell-action text-xs",onClick:()=>{n&&r(),l&&d()},children:[s.jsx(Qs,{className:"h-3 w-3"}),"Retry"]})]}):k.length===0?s.jsx("div",{className:"text-sm text-muted-foreground",children:"No workspaces yet."}):s.jsx("ul",{className:"flex flex-col divide-y divide-border/40",children:k.map(j=>{const N=!rz(j,o);return s.jsxs("li",{className:"flex items-center justify-between gap-3 py-2",children:[s.jsxs("span",{className:"truncate text-sm",title:wu(j),children:[wu(j),j===oh&&s.jsx("span",{className:"ml-2 text-xs text-muted-foreground",children:"(standalone, ungrouped)"})]}),s.jsx("button",{type:"button",role:"switch","aria-checked":N,"aria-label":`Show "${wu(j)}" in the left nav`,onClick:()=>w(j,!N),disabled:f,className:`relative inline-flex h-5 w-9 shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-60 ${N?"bg-primary":"bg-muted"}`,children:s.jsx("span",{className:`pointer-events-none inline-block h-4 w-4 rounded-full bg-background shadow-sm ring-0 transition-transform ${N?"translate-x-4":"translate-x-0"}`})})]},j)})})]})}function vX(){const{preset:e,setPreset:t,resetPreset:n}=Ov(),[r,o]=m.useState(!1),[i,a]=m.useState(null);async function l(f){if(!(f===e||r)){o(!0),a(null);try{await t(f),a({type:"success",message:"Theme updated"}),setTimeout(()=>a(null),2e3)}catch(p){a({type:"error",message:p instanceof Error?p.message:"Failed to save theme"})}finally{o(!1)}}}async function d(){o(!0),a(null);try{await n(),a({type:"success",message:"Theme reset to default"}),setTimeout(()=>a(null),2e3)}catch(f){a({type:"error",message:f instanceof Error?f.message:"Failed to reset theme"})}finally{o(!1)}}return s.jsxs("div",{className:"space-y-6",children:[s.jsxs(Qe,{title:"Theme",description:"Pick a color theme for the dashboard. The default is the Syntaur brand.",actions:e!=="default"?s.jsxs("button",{className:"shell-action text-xs",onClick:d,disabled:r,children:[s.jsx(Qs,{className:"h-3 w-3"}),"Reset"]}):void 0,children:[i&&s.jsx("div",{className:`mb-3 rounded-md border px-3 py-1.5 text-xs ${i.type==="success"?"border-success-foreground/30 bg-success text-success-foreground":"border-error-foreground/30 bg-error text-error-foreground"}`,children:i.message}),s.jsx("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-4",children:p2.map(f=>{const p=f.slug===e;return s.jsxs("button",{type:"button",onClick:()=>l(f.slug),disabled:r,"aria-pressed":p,className:`group relative flex flex-col gap-2 rounded-lg border bg-card/95 p-3 text-left transition disabled:opacity-60 ${p?"border-primary ring-2 ring-primary/40":"border-border/60 hover:border-primary/40"}`,children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("span",{className:"h-5 w-5 rounded-full ring-1 ring-border/60",style:{background:f.swatches.primary}}),s.jsx("span",{className:"h-5 w-5 rounded-full ring-1 ring-border/60",style:{background:f.swatches.secondary}}),s.jsx("span",{className:"h-5 w-5 rounded-full ring-1 ring-border/60",style:{background:f.swatches.coral}}),s.jsx("span",{className:"h-5 w-5 rounded-full ring-1 ring-border/60",style:{background:f.swatches.teal}}),s.jsx("span",{className:"h-5 w-5 rounded-full ring-1 ring-border/60",style:{background:f.swatches.amber}}),p&&s.jsx("span",{className:"ml-auto inline-flex h-5 w-5 items-center justify-center rounded-full bg-primary text-primary-foreground",children:s.jsx(zr,{className:"h-3 w-3"})})]}),s.jsxs("div",{children:[s.jsx("div",{className:"text-sm font-medium text-foreground",children:f.label}),s.jsx("div",{className:"text-xs text-muted-foreground",children:f.description})]})]},f.slug)})})]}),s.jsx(YY,{}),s.jsx(mX,{}),s.jsx(yX,{}),s.jsx(bX,{}),s.jsx(cX,{}),s.jsx(eX,{}),s.jsx(GY,{})]})}function wX({open:e,affected:t,remaining:n,ruleReferences:r,headlineReferences:o,onResolve:i,onCancel:a}){var D,T;const[l,d]=m.useState(n.length>0?"remap":"delete"),[f,p]=m.useState(((D=n[0])==null?void 0:D.id)??""),[h,g]=m.useState(((T=n[0])==null?void 0:T.id)??""),[y,k]=m.useState(!1),w=t.count>0;m.useEffect(()=>{var R,$;e&&(d(n.length>0?"remap":"delete"),p(((R=n[0])==null?void 0:R.id)??""),g((($=n[0])==null?void 0:$.id)??""),k(!1))},[e,n]);const b=!o||h!==""&&h!==t.id,j=l==="remap"&&n.length>0&&f!==""&&f!==t.id||l==="delete"&&(!w||y)&&b;function N(){j&&(l==="remap"?i({id:t.id,mode:"remap",target:f},f):i({id:t.id,mode:"delete"},o?h:""))}const S=t.assignments.slice(0,10),C=t.count-S.length;return s.jsx(Ln,{open:e,onOpenChange:R=>R?void 0:a(),children:s.jsxs(jn,{className:"max-w-xl",children:[s.jsxs(er,{children:[s.jsxs(kn,{children:['Delete status "',t.label,'"',w?` — ${t.count} assignment${t.count===1?"":"s"} reference it`:""]}),s.jsx(ns,{children:w?"Choose how to resolve the affected assignments before this status is removed from the workflow.":"No assignments use this status, but workflow rules reference it. Choose how to resolve them."})]}),w&&s.jsx("div",{className:"rounded-md border border-border/60 bg-background/80 p-3",children:s.jsxs("ul",{className:"space-y-1 text-sm",children:[S.map(R=>s.jsx("li",{children:s.jsx("span",{className:"font-mono text-xs text-muted-foreground",children:R.display})},`${R.projectSlug??"standalone"}/${R.assignmentSlug}`)),C>0&&s.jsxs("li",{className:"text-xs italic text-muted-foreground",children:["+",C," more not shown"]})]})}),r.length>0&&s.jsxs("div",{className:"rounded-md border border-amber-500/40 bg-amber-500/5 p-3",children:[s.jsx("p",{className:"mb-1 text-xs font-medium text-foreground",children:"Workflow rules referencing this status:"}),s.jsx("ul",{className:"space-y-0.5 font-mono text-xs text-muted-foreground",children:r.map((R,$)=>s.jsxs("li",{children:[s.jsx("span",{className:"text-foreground",children:R.section}),s.jsx("span",{className:"mx-1",children:"·"}),R.detail]},$))}),s.jsx("p",{className:"mt-2 text-xs text-muted-foreground",children:l==="remap"?"These will be remapped to the target status.":"Ladder rungs and transitions referencing this status will be removed"+(o?"; headline rules must be remapped below.":".")})]}),s.jsxs("div",{className:"space-y-3",children:[s.jsxs("label",{className:"flex items-start gap-2 cursor-pointer",children:[s.jsx("input",{type:"radio",name:"status-delete-mode",checked:l==="remap",onChange:()=>d("remap"),disabled:n.length===0,className:"mt-1"}),s.jsxs("span",{className:"flex-1",children:[s.jsx("span",{className:"block text-sm font-medium",children:w?"Remap to another status":"Remap rules to another status"}),s.jsxs("select",{value:f,onChange:R=>p(R.target.value),onClick:()=>d("remap"),disabled:l!=="remap"||n.length===0,className:"mt-2 block w-full rounded-md border border-border/60 bg-background px-2 py-1 text-sm",children:[n.length===0&&s.jsx("option",{value:"",children:"(no other statuses)"}),n.map(R=>s.jsxs("option",{value:R.id,children:[R.label," (",R.id,")"]},R.id))]}),n.length===0&&s.jsx("span",{className:"block text-xs text-muted-foreground mt-1",children:"No other saved statuses to remap to. Add another status first, or use Delete."})]})]}),s.jsxs("label",{className:"flex items-start gap-2 cursor-pointer",children:[s.jsx("input",{type:"radio",name:"status-delete-mode",checked:l==="delete",onChange:()=>d("delete"),className:"mt-1"}),s.jsxs("span",{className:"flex-1",children:[s.jsx("span",{className:"block text-sm font-medium text-error-foreground",children:w?"Delete these assignments":"Drop the referencing rules"}),s.jsx("span",{className:"block text-xs text-muted-foreground mt-1",children:w?`Permanently removes ${t.count} assignment${t.count===1?"":"s"} from disk. This cannot be undone.`:"Ladder rungs and transitions referencing this status are removed."}),l==="delete"&&o&&s.jsxs("span",{className:"mt-2 block",children:[s.jsx("span",{className:"block text-xs font-medium",children:"Remap headline rules to"}),s.jsxs("select",{value:h,onChange:R=>g(R.target.value),disabled:n.length===0,className:"mt-1 block w-full rounded-md border border-border/60 bg-background px-2 py-1 text-sm",children:[n.length===0&&s.jsx("option",{value:"",children:"(no other statuses)"}),n.map(R=>s.jsxs("option",{value:R.id,children:[R.label," (",R.id,")"]},R.id))]}),s.jsx("span",{className:"mt-1 block text-xs text-muted-foreground",children:"The headline projection cannot reference a deleted status, so it must point somewhere."})]}),l==="delete"&&w&&s.jsxs("label",{className:"mt-2 flex items-center gap-2 cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:y,onChange:R=>k(R.target.checked)}),s.jsxs("span",{className:"text-xs",children:["I understand this will permanently delete ",t.count," assignment",t.count===1?"":"s","."]})]})]})]})]}),s.jsxs(Ur,{children:[s.jsx("button",{type:"button",onClick:a,className:"shell-action",children:"Cancel"}),s.jsx("button",{type:"button",onClick:N,disabled:!j,className:`shell-action ${l==="delete"?"bg-error text-error-foreground hover:opacity-90":"shell-action--cta"} disabled:cursor-not-allowed disabled:opacity-50`,children:l==="remap"?w?`Remap ${t.count} → ${f||"..."}`:`Remap rules → ${f||"..."}`:w?`Delete ${t.count}`:"Drop rules"})]})]})})}function jX({open:e,references:t,onConfirm:n,onCancel:r}){return s.jsx(Ln,{open:e,onOpenChange:o=>o?void 0:r(),children:s.jsxs(jn,{className:"max-w-xl",children:[s.jsxs(er,{children:[s.jsx(kn,{children:"Delete fact — referenced by derive rules"}),s.jsx(ns,{children:"Removing this fact will break the following derive conditions. The doctor check will flag them as invalid until they are fixed."})]}),s.jsx("div",{className:"rounded-md border border-border/60 bg-background/80 p-3",children:s.jsx("ul",{className:"space-y-2 text-sm",children:t.map((o,i)=>s.jsxs("li",{className:"font-mono text-xs text-muted-foreground",children:[s.jsx("span",{className:"text-foreground",children:o.location}),s.jsx("span",{className:"mx-1",children:"·"}),s.jsx("span",{children:o.when})]},i))})}),s.jsxs(Ur,{children:[s.jsx("button",{type:"button",onClick:r,className:"shell-action",children:"Cancel"}),s.jsx("button",{type:"button",onClick:n,className:"shell-action bg-error text-error-foreground hover:opacity-90",children:"Confirm delete — rules will become invalid"})]})]})})}function kX({value:e,onChange:t,ariaLabel:n}){const r=n??"Pick a color",o=n?`${n} (hex)`:"Color hex value";return s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"color",value:e||"#64748b",onChange:i=>t(i.target.value),className:"h-7 w-7 shrink-0 cursor-pointer rounded-md border border-border/60 bg-transparent p-0.5",title:"Pick a color","aria-label":r}),s.jsx("input",{type:"text",value:e,onChange:i=>t(i.target.value),placeholder:"#64748b",className:"editor-input w-[5.5rem] font-mono text-xs","aria-label":o})]})}function SX({row:e,isSaved:t,onUpdate:n,onRemove:r}){const{attributes:o,listeners:i,setNodeRef:a,setActivatorNodeRef:l,transform:d,transition:f,isDragging:p}=gm({id:e.rowKey}),h={transform:bs.Transform.toString(d),transition:f,zIndex:p?50:void 0,position:p?"relative":void 0};return s.jsxs("div",{ref:a,style:h,className:`surface-panel flex flex-wrap items-center gap-3 px-3 py-2 ${p?"opacity-60 shadow-lg":""}`,children:[s.jsx("button",{ref:l,...o,...i,type:"button","aria-label":"Drag to reorder",className:"cursor-grab active:cursor-grabbing text-muted-foreground/40 hover:text-muted-foreground transition touch-none",children:s.jsx(dc,{className:"h-4 w-4"})}),s.jsx("div",{className:"min-w-[8rem] flex-1",children:t?s.jsxs(Ir,{children:[s.jsx(Mr,{asChild:!0,children:s.jsx("input",{type:"text",value:e.id,readOnly:!0,"aria-label":"Status ID",className:"editor-input w-full text-sm cursor-not-allowed opacity-60"})}),s.jsx(gr,{className:"max-w-xs text-xs font-normal normal-case tracking-normal",children:"To rename a saved status, delete the row and create a new one (this triggers the orphan-resolution flow if assignments still reference it)."})]}):s.jsx("input",{type:"text",value:e.id,onChange:g=>n("id",g.target.value),"aria-label":"Status ID",className:"editor-input w-full text-sm"})}),s.jsx("div",{className:"min-w-[8rem] flex-1",children:s.jsx("input",{type:"text",value:e.label,onChange:g=>n("label",g.target.value),"aria-label":"Status label",className:"editor-input w-full text-sm"})}),s.jsx("div",{className:"min-w-[10rem] flex-1",children:s.jsx("input",{type:"text",value:e.description,onChange:g=>n("description",g.target.value),"aria-label":"Status description",placeholder:"description (optional)",className:"editor-input w-full text-sm"})}),s.jsx(kX,{value:e.color,onChange:g=>n("color",g),ariaLabel:`Color for ${e.label||e.id}`}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs(Ir,{children:[s.jsx(Mr,{asChild:!0,children:s.jsx("span",{className:"cursor-help text-xs text-muted-foreground underline decoration-dotted underline-offset-4",children:"Done"})}),s.jsx(gr,{className:"max-w-xs text-xs font-normal normal-case tracking-normal",children:'When enabled, assignments in this status count as finished — they fill the "done" portion of progress bars and satisfy dependency requirements.'})]}),s.jsx("button",{type:"button",role:"switch","aria-checked":e.terminal,"aria-label":`Done state for ${e.label||e.id}`,onClick:()=>n("terminal",!e.terminal),className:`relative inline-flex h-5 w-9 shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-offset-2 focus-visible:ring-offset-background ${e.terminal?"bg-primary":"bg-muted"}`,children:s.jsx("span",{className:`pointer-events-none inline-block h-4 w-4 rounded-full bg-background shadow-sm ring-0 transition-transform ${e.terminal?"translate-x-4":"translate-x-0"}`})})]}),s.jsx("button",{type:"button",className:"inline-flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground hover:bg-muted hover:text-foreground",onClick:r,title:"Remove status","aria-label":`Remove status ${e.id}`,children:s.jsx(bn,{className:"h-3.5 w-3.5"})})]})}function NX({statuses:e,savedStatusIds:t,onUpdate:n,onAdd:r,onRemove:o,onReorder:i}){const a=cm(vi(bc,{activationConstraint:{distance:8}}),vi(yc,{coordinateGetter:NR}));function l(d){const{active:f,over:p}=d;if(!p||f.id===p.id)return;const h=e.findIndex(y=>y.rowKey===f.id),g=e.findIndex(y=>y.rowKey===p.id);h===-1||g===-1||i(vc(e,h,g))}return s.jsx(Qe,{title:"Status Definitions",description:"Define the statuses assignments can have. Drag rows to set the display order used by Kanban columns, progress bars, and dropdowns.",actions:s.jsxs("button",{className:"shell-action text-xs",onClick:r,children:[s.jsx(It,{className:"h-3 w-3"}),"Add Status"]}),children:s.jsx(hm,{sensors:a,collisionDetection:um,onDragEnd:l,children:s.jsx(mm,{items:e.map(d=>d.rowKey),strategy:xw,children:s.jsx("div",{className:"space-y-2",children:e.map((d,f)=>s.jsx(SX,{row:d,isSaved:t.has(d.id),onUpdate:(p,h)=>n(f,p,h),onRemove:()=>o(f)},d.rowKey))})})})})}function CX(e){const t=Array.from(e.pendingResolutions.values()),r={statuses:e.statuses.map(o=>({id:o.id,label:o.label,...o.description?{description:o.description}:{},...o.color?{color:o.color}:{},...o.terminal?{terminal:!0}:{}})),order:e.order,resolutions:t};return e.transitions!==void 0&&(r.transitions=e.transitions),e.derive!==void 0&&(r.derive=e.derive),e.facts!==void 0&&(r.facts=e.facts),e.factRemovalAcks&&e.factRemovalAcks.length>0&&(r.factRemovalAcks=e.factRemovalAcks),{body:r,resolutions:t}}function EX(e,t,n){const r=[];t.phaseLadder.forEach((o,i)=>{o.phase===e&&r.push({section:"phaseLadder",detail:`phaseLadder rung ${i} ("${o.phase}")`})}),t.headline.parked===e&&r.push({section:"headline",detail:"headline.parked"}),t.headline.blocked===e&&r.push({section:"headline",detail:"headline.blocked"});for(const o of n)(o.from===e||o.to===e)&&r.push({section:"transitions",detail:`transition ${o.from} --${o.command}--> ${o.to}`});return r}function TX(e,t){return t.headline.parked===e||t.headline.blocked===e}function RX(e,t,n){return{phaseLadder:e.phaseLadder.map(r=>r.phase===t?{...r,phase:n}:r),disposition:e.disposition,headline:{parked:e.headline.parked===t?n:e.headline.parked,blocked:e.headline.blocked===t?n:e.headline.blocked}}}function AX(e,t,n){return e.map(r=>({...r,from:r.from===t?n:r.from,to:r.to===t?n:r.to}))}function PX(e,t,n){return{phaseLadder:e.phaseLadder.filter(r=>r.phase!==t),disposition:e.disposition,headline:{parked:e.headline.parked===t?n:e.headline.parked,blocked:e.headline.blocked===t?n:e.headline.blocked}}}function _X(e,t){return e.filter(n=>n.from!==t&&n.to!==t)}function DX(e,t){const n=new Map;t.forEach((o,i)=>{n.has(o)||n.set(o,i)});const r=t.length;return e.map((o,i)=>({s:o,originalIndex:i,r:n.get(o.id)??r})).sort((o,i)=>o.r-i.r||o.originalIndex-i.originalIndex).map(o=>o.s)}function WN(e,t){const n=new Map;for(const[r,o]of e.entries())t.has(o.id)||o.mode==="remap"&&!t.has(o.target)||n.set(r,o);return n}function D_(){return`row_${Math.random().toString(36).slice(2,10)}_${Date.now().toString(36)}`}function $X(e){const t=e.statuses.map(n=>({rowKey:D_(),id:n.id,label:n.label,description:n.description??"",color:n.color??"",terminal:n.terminal??!1}));return DX(t,e.order)}function IX(e){return Db(e)}function qN(e){const t=new Map;for(const n of e)t.set(n,(t.get(n)??0)+1);return t}function MX(e){const t=new Map;for(let n=0;n<e.length;n++){const r=qN(Db(e.slice(0,n))),o=qN(Db(e.slice(0,n+1)));for(const[i,a]of o.entries()){const l=r.get(i)??0;if(a>l){t.set(n,i);break}}}return t}const LX=[{value:"bool",label:"bool"},{value:"number",label:"number"},{value:"attestation",label:"attestation"}],OX=[{value:"plan",label:"plan"},{value:"commit",label:"commit"},{value:"none",label:"none"}];function FX(){return{name:"",type:"bool",binds:null}}function zX({rows:e,onChange:t,saving:n}){const r=MX(e),o=m.useCallback(()=>{t([...e,FX()])},[e,t]),i=m.useCallback((l,d,f)=>{t(e.map((p,h)=>h===l?{...p,[d]:f}:p))},[e,t]),a=m.useCallback(l=>{t(e.filter((d,f)=>f!==l))},[e,t]);return s.jsxs(Qe,{title:"Facts",description:"Declare custom facts and attestation fields for derive rules and the fact vocabulary.",children:[s.jsxs("p",{className:"mb-3 text-xs text-muted-foreground",children:["Names must match ",s.jsx("code",{className:"font-mono",children:"^[a-z][a-zA-Z0-9]*"})," — start with a lowercase letter, then letters or numbers only (no spaces, hyphens, or underscores)."]}),s.jsxs("div",{className:"space-y-2",children:[e.length===0&&s.jsx("p",{className:"text-sm text-muted-foreground italic",children:"No custom facts declared."}),e.map((l,d)=>{const f=r.get(d),p=l.type==="attestation";return s.jsxs("div",{className:`rounded-md border p-2 ${f?"border-error-foreground/40 bg-error/5":"border-border/60 bg-background/80"}`,children:[s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsxs("div",{className:"flex-1 grid grid-cols-1 sm:grid-cols-3 gap-2",children:[s.jsx("input",{type:"text",value:l.name,onChange:h=>i(d,"name",h.target.value),placeholder:"factName",disabled:n,className:"w-full rounded-md border border-border/60 bg-background px-2 py-1 text-sm font-mono focus:border-primary focus:outline-none focus:ring-2 focus:ring-primary/30 disabled:opacity-60"}),s.jsx("select",{value:l.type,onChange:h=>{const g=h.target.value;t(e.map((y,k)=>k===d?{...y,type:g,binds:g==="attestation"?y.binds:null}:y))},disabled:n,className:"w-full rounded-md border border-border/60 bg-background px-2 py-1 text-sm focus:border-primary focus:outline-none focus:ring-2 focus:ring-primary/30 disabled:opacity-60",children:LX.map(h=>s.jsx("option",{value:h.value,children:h.label},h.value))}),p?s.jsx("select",{value:l.binds??"none",onChange:h=>i(d,"binds",h.target.value),disabled:n,className:"w-full rounded-md border border-border/60 bg-background px-2 py-1 text-sm focus:border-primary focus:outline-none focus:ring-2 focus:ring-primary/30 disabled:opacity-60",children:OX.map(h=>s.jsx("option",{value:h.value,children:h.label},h.value))}):s.jsx("span",{className:"text-sm text-muted-foreground py-1",children:"—"})]}),f&&s.jsxs(Ir,{children:[s.jsx(Mr,{asChild:!0,children:s.jsx("span",{className:"mt-1 inline-flex text-error-foreground","aria-label":"Invalid fact",children:s.jsx(eh,{className:"h-3.5 w-3.5 flex-shrink-0"})})}),s.jsx(gr,{className:"max-w-xs text-xs font-normal normal-case tracking-normal",children:f})]}),s.jsx("button",{type:"button",onClick:()=>a(d),disabled:n,className:"mt-0.5 shell-action text-xs text-muted-foreground hover:text-error disabled:opacity-50",title:"Delete",children:s.jsx(bn,{className:"h-3.5 w-3.5"})})]}),f&&s.jsx("p",{className:"mt-1 text-xs text-error-foreground",children:f})]},d)})]}),s.jsxs("button",{type:"button",onClick:o,disabled:n,className:"mt-2 shell-action text-xs inline-flex items-center gap-1 disabled:opacity-50",children:[s.jsx(It,{className:"h-3.5 w-3.5"}),"Add fact"]})]})}function $_(e,t=Sm){var r,o;if(e==="*")return null;const n=tm(e);if(!n.ast)return((r=n.errors[0])==null?void 0:r.message)??"unparseable condition";try{return _u(n.ast,t),null}catch(i){if(i instanceof Dr)return((o=i.errors[0])==null?void 0:o.message)??"invalid condition";throw i}}function Fy(e){if(e.values.length!==1)return null;const t=e.values[0];return{field:e.field,op:e.op,value:t.raw,valueType:t.type}}function BX(e){if(e.kind==="atom"){const t=Fy(e);return t?{outerJoin:"AND",groups:[{join:"AND",comparisons:[t]}]}:null}if(e.kind==="and"||e.kind==="or"){const t=e.kind==="and"?"AND":"OR",n=e.kind==="and"?"or":"and",r=e.kind==="and"?"OR":"AND",o=[];for(const i of e.children)if(i.kind==="atom"){const a=Fy(i);if(!a)return null;o.push({join:r,comparisons:[a]})}else if(i.kind===n){const a=[];for(const l of i.children){if(l.kind!=="atom")return null;const d=Fy(l);if(!d)return null;a.push(d)}o.push({join:r,comparisons:a})}else return null;return{outerJoin:t,groups:o}}return null}function KN(e){const t=e.trim();if(t===""||t==="*")return null;const n=tm(t);return n.ast?BX(n.ast):null}const UX=/^[A-Za-z_][A-Za-z0-9_-]*$/;function HX(e){return e===""||!UX.test(e)||/^(and|or|not)$/i.test(e)}function VX(e){return`"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`}function WX(e){return e.valueType==="number"||e.valueType==="date"||e.valueType==="duration"?e.value:HX(e.value)?VX(e.value):e.value}function qX(e){const t=WX(e);return e.op===":"?`${e.field}:${t}`:`${e.field} ${e.op} ${t}`}function KX(e){return e.groups.map(n=>{const r=n.comparisons.map(qX).join(` ${n.join} `);return n.comparisons.length>1?`(${r})`:r}).join(` ${e.outerJoin} `)}function GX(e,t){return e.trim()==="*"?null:e.trim()===""?"condition is empty":$_(e,t)}function YX(e){return wU(vU(e))}function XX(e){const t=Pw(e),n=[];for(const r of xA(e)){const o=t[r.toLowerCase()];o&&n.push({name:r,kind:o.kind})}return n}function I_(e){switch(e){case"bool":return"word";case"number":case"ordinal":case"duration":case"timestamp":return"number";default:return"string"}}function sv(e){switch(e){case"bool":return[":"];case"number":case"ordinal":case"duration":case"timestamp":return[":","=","!=","<","<=",">",">="];default:return[":","!="]}}function ju(e){const t=e[0];return{outerJoin:"AND",groups:[{join:"AND",comparisons:[t?{field:t.name,op:sv(t.kind)[0],value:t.kind==="bool"?"true":"",valueType:I_(t.kind)}:{field:"",op:":",value:""}]}]}}function M_({value:e,onChange:t,fieldOptions:n,registry:r,disabled:o}){const i=m.useMemo(()=>KN(e),[e]),a=e.trim()===""||i!==null,[l,d]=m.useState(a?"builder":"raw"),[f,p]=m.useState(()=>i??ju(n)),h=m.useRef(e);m.useEffect(()=>{if(e===h.current)return;const T=KN(e);T&&p(T),!(e.trim()===""||T)&&l==="builder"&&d("raw"),h.current=e},[e]);const g=GX(e,r);function y(T){h.current=T,t(T)}function k(T){p(T),y(KX(T))}function w(T){k({outerJoin:T,groups:f.groups.map(R=>({...R,join:T==="AND"?"OR":"AND"}))})}function b(T,R,$){const _=f.groups.map((U,I)=>I===T?{...U,comparisons:U.comparisons.map((F,M)=>M===R?{...F,...$}:F)}:U);k({...f,groups:_})}function j(T){const R=ju(n).groups[0].comparisons[0],$=f.groups.map((_,U)=>U===T?{..._,comparisons:[..._.comparisons,{...R}]}:_);k({...f,groups:$})}function N(T,R){let $=f.groups.map((_,U)=>U===T?{..._,comparisons:_.comparisons.filter((I,F)=>F!==R)}:_);$=$.filter(_=>_.comparisons.length>0),$.length===0&&($=ju(n).groups),k({...f,groups:$})}function S(){const T=f.outerJoin==="AND"?"OR":"AND";k({...f,groups:[...f.groups,{join:T,comparisons:[ju(n).groups[0].comparisons[0]]}]})}function C(){if(l==="builder"){d("raw");return}a&&(p(i??ju(n)),d("builder"))}const D="rounded-md border border-border/60 bg-background px-2 py-1 text-sm focus:border-primary focus:outline-none focus:ring-2 focus:ring-primary/30 disabled:opacity-60";return s.jsxs("div",{className:"space-y-1.5",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsx("span",{className:"text-xs text-muted-foreground",children:"Condition"}),s.jsxs("button",{type:"button",onClick:C,disabled:o||l==="raw"&&!a,title:l==="raw"&&!a?"Condition too complex for the builder — edit as raw AQL":l==="builder"?"Switch to raw AQL":"Switch to builder",className:"shell-action text-xs inline-flex items-center gap-1 disabled:opacity-50",children:[l==="builder"?s.jsx(_L,{className:"h-3 w-3"}):s.jsx(YL,{className:"h-3 w-3"}),l==="builder"?"Raw AQL":"Builder"]})]}),l==="raw"?s.jsx("input",{type:"text",list:"aql-field-names",value:e,onChange:T=>y(T.target.value),disabled:o,placeholder:"e.g. planApproved:true AND implementationStarted:true",className:`${D} w-full font-mono`}):s.jsxs("div",{className:"space-y-2",children:[f.groups.map((T,R)=>s.jsxs("div",{children:[R>0&&s.jsxs("div",{className:"my-1 flex items-center gap-2",children:[s.jsx("span",{className:"h-px flex-1 bg-border/60"}),s.jsx("button",{type:"button",onClick:()=>w(f.outerJoin==="AND"?"OR":"AND"),disabled:o,className:"shell-action text-[10px] uppercase tracking-wide",children:f.outerJoin}),s.jsx("span",{className:"h-px flex-1 bg-border/60"})]}),s.jsxs("div",{className:"rounded-md border border-border/50 bg-background/60 p-2 space-y-1.5",children:[T.comparisons.map(($,_)=>{const U=n.find(M=>M.name===$.field),I=(U==null?void 0:U.kind)??"string",F=sv(I);return s.jsxs("div",{className:"flex items-center gap-1.5",children:[_>0&&s.jsx("span",{className:"w-9 shrink-0 text-[10px] uppercase tracking-wide text-muted-foreground",children:T.join}),s.jsxs("select",{value:$.field,onChange:M=>{const A=n.find(W=>W.name===M.target.value),L=(A==null?void 0:A.kind)??"string",z=sv(L);b(R,_,{field:M.target.value,op:z.includes($.op)?$.op:z[0],value:L==="bool"?"true":$.value,valueType:I_(L)})},disabled:o,className:`${D} font-mono`,children:[n.length===0&&s.jsx("option",{value:"",children:"(no fields)"}),!n.some(M=>M.name===$.field)&&$.field!==""&&s.jsx("option",{value:$.field,children:$.field}),n.map(M=>s.jsx("option",{value:M.name,children:M.name},M.name))]}),s.jsx("select",{value:$.op,onChange:M=>b(R,_,{op:M.target.value}),disabled:o,className:`${D} font-mono`,children:F.map(M=>s.jsx("option",{value:M,children:M},M))}),I==="bool"?s.jsxs("select",{value:$.value||"true",onChange:M=>b(R,_,{value:M.target.value}),disabled:o,className:`${D} font-mono`,children:[s.jsx("option",{value:"true",children:"true"}),s.jsx("option",{value:"false",children:"false"})]}):s.jsx("input",{type:"text",value:$.value,onChange:M=>b(R,_,{value:M.target.value}),disabled:o,placeholder:"value",className:`${D} w-24 font-mono`}),s.jsx("button",{type:"button",onClick:()=>N(R,_),disabled:o,className:"ml-auto inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:bg-muted hover:text-foreground","aria-label":"Remove condition",children:s.jsx(bn,{className:"h-3.5 w-3.5"})})]},_)}),s.jsxs("button",{type:"button",onClick:()=>j(R),disabled:o,className:"shell-action text-xs inline-flex items-center gap-1",children:[s.jsx(It,{className:"h-3 w-3"}),T.join," condition"]})]})]},R)),s.jsxs("button",{type:"button",onClick:S,disabled:o,className:"shell-action text-xs inline-flex items-center gap-1",children:[s.jsx(It,{className:"h-3 w-3"}),f.outerJoin," group"]})]}),s.jsx("datalist",{id:"aql-field-names",children:n.map(T=>s.jsx("option",{value:T.name},T.name))}),s.jsx("p",{className:"font-mono text-[11px] text-muted-foreground truncate",title:e,children:e.trim()===""?s.jsx("span",{className:"italic",children:"empty condition"}):e}),g&&s.jsx("p",{className:"text-xs text-error-foreground",children:g})]})}let GN=0;function Eh(){return GN+=1,`dr_${GN}_${Math.random().toString(36).slice(2,8)}`}function zy(e){const t=[...e.disposition].sort((n,r)=>n.when===null&&r.when!==null?1:n.when!==null&&r.when===null?-1:0);return{phaseLadder:e.phaseLadder.map(n=>({rowKey:Eh(),phase:n.phase,when:n.when,next:n.next??""})),disposition:t.map(n=>({rowKey:Eh(),when:n.when,is:n.is})),headline:{parked:e.headline.parked,blocked:e.headline.blocked}}}function ov(e){const t=e.phaseLadder.map(r=>r.next.trim()?{phase:r.phase,when:r.when,next:r.next.trim()}:{phase:r.phase,when:r.when}),n=e.disposition.map(r=>({when:r.when,is:r.is}));return{phaseLadder:t,disposition:n,headline:{terminal:"passthrough",active:"phase",parked:e.headline.parked,blocked:e.headline.blocked}}}function QX(e){return e.findIndex(t=>t.when.trim()==="*")}function L_(e,t,n){return _6(e,{statuses:t},r=>$_(r,n))}const YN=["active","blocked","parked"];function JX({value:e,deriveCustom:t,statuses:n,acceptedFacts:r,onChange:o,onReset:i,disabled:a}){const l=m.useMemo(()=>Pw(r),[r]),d=m.useMemo(()=>XX(r),[r]),f=cm(vi(bc,{activationConstraint:{distance:8}}),vi(yc,{coordinateGetter:NR})),p=m.useMemo(()=>{try{return L_(ov(e),n,l)}catch{return["derive rules are malformed"]}},[e,n,l]),h=QX(e.phaseLadder),g=h>=0?e.phaseLadder[h]:null,y=e.phaseLadder.filter((_,U)=>U!==h);function k(_,U){o({...e,phaseLadder:[..._?[_]:[],...U]})}function w(_,U){const I=e.phaseLadder.map(F=>F.rowKey===_?{...F,...U}:F);o({...e,phaseLadder:I})}function b(){var U;const _={rowKey:Eh(),phase:((U=n[0])==null?void 0:U.id)??"",when:"",next:""};k(g,[...y,_])}function j(_){o({...e,phaseLadder:e.phaseLadder.filter(U=>U.rowKey!==_)})}function N(_){const{active:U,over:I}=_;if(!I||U.id===I.id)return;const F=y.findIndex(A=>A.rowKey===U.id),M=y.findIndex(A=>A.rowKey===I.id);F===-1||M===-1||k(g,vc(y,F,M))}function S(_,U){o({...e,disposition:e.disposition.map(I=>I.rowKey===_?{...I,...U}:I)})}function C(){const _={rowKey:Eh(),when:"",is:"active"},U=e.disposition.findIndex(F=>F.when===null),I=[...e.disposition];U>=0?I.splice(U,0,_):I.push(_),o({...e,disposition:I})}function D(_){o({...e,disposition:e.disposition.filter(U=>U.rowKey!==_)})}function T(_,U){o({...e,headline:{...e.headline,[_]:U}})}const R="rounded-md border border-border/60 bg-background px-2 py-1 text-sm focus:border-primary focus:outline-none focus:ring-2 focus:ring-primary/30 disabled:opacity-60";function $(_,U,I){return s.jsxs("select",{value:_,onChange:F=>U(F.target.value),disabled:a,"aria-label":I,className:`${R} font-mono`,children:[!n.some(F=>F.id===_)&&_!==""&&s.jsx("option",{value:_,children:_}),n.map(F=>s.jsxs("option",{value:F.id,children:[F.label," (",F.id,")"]},F.id))]})}return s.jsxs(Qe,{title:"Derive Rules",description:"The phase ladder, disposition rules, and headline projection that map facts to a status. Highest matching rung wins — drag to reorder priority.",actions:t?s.jsxs("button",{type:"button",className:"shell-action text-xs inline-flex items-center gap-1",onClick:i,disabled:a,children:[s.jsx(Qs,{className:"h-3 w-3"}),"Reset to default rules"]}):void 0,children:[!t&&s.jsx("div",{className:"mb-3 rounded-md border border-border/60 bg-muted/30 px-3 py-1.5 text-xs text-muted-foreground",children:"Using built-in derive rules. Editing anything below switches to a custom configuration."}),p.length>0&&s.jsxs("div",{className:"mb-3 rounded-md border border-error-foreground/30 bg-error/10 px-3 py-2 text-xs text-error-foreground",children:[s.jsx("p",{className:"font-medium",children:"These derive rules won't save until fixed:"}),s.jsx("ul",{className:"mt-1 list-disc pl-4 space-y-0.5",children:p.map((_,U)=>s.jsx("li",{children:_},U))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("h4",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:"Phase ladder"}),g&&s.jsxs("div",{className:"surface-panel flex flex-wrap items-start gap-3 px-3 py-2 opacity-90",children:[s.jsx("span",{className:"mt-1 text-muted-foreground/40",children:s.jsx(dc,{className:"h-4 w-4 opacity-30"})}),s.jsxs("div",{className:"min-w-[10rem] flex-1 space-y-1",children:[s.jsx("label",{className:"text-xs text-muted-foreground",children:"Phase (catch-all, lowest priority)"}),$(g.phase,_=>w(g.rowKey,{phase:_}),"Catch-all phase"),s.jsx("span",{className:"ml-2 rounded bg-muted px-1.5 py-0.5 text-[10px] text-muted-foreground",children:"matches everything"})]}),s.jsxs("div",{className:"min-w-[12rem] flex-1",children:[s.jsx("label",{className:"text-xs text-muted-foreground",children:"Next action"}),s.jsx("input",{type:"text",value:g.next,onChange:_=>w(g.rowKey,{next:_.target.value}),disabled:a,className:`${R} w-full`})]})]}),s.jsx(hm,{sensors:f,collisionDetection:um,onDragEnd:N,children:s.jsx(mm,{items:y.map(_=>_.rowKey),strategy:xw,children:s.jsx("div",{className:"space-y-2",children:y.map(_=>s.jsx(ZX,{rung:_,disabled:a,statusSelect:$,fieldOptions:d,registry:l,onUpdate:U=>w(_.rowKey,U),onRemove:()=>j(_.rowKey)},_.rowKey))})})}),s.jsxs("button",{type:"button",onClick:b,disabled:a,className:"shell-action text-xs inline-flex items-center gap-1",children:[s.jsx(It,{className:"h-3 w-3"}),"Add rung"]})]}),s.jsxs("div",{className:"mt-5 space-y-2",children:[s.jsx("h4",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:"Disposition (first match wins)"}),s.jsx("div",{className:"space-y-2",children:e.disposition.map(_=>_.when===null?s.jsxs("div",{className:"surface-panel flex items-center gap-3 px-3 py-2",children:[s.jsx("span",{className:"rounded bg-muted px-1.5 py-0.5 text-[10px] uppercase tracking-wide text-muted-foreground",children:"otherwise"}),s.jsx("span",{className:"text-sm text-muted-foreground",children:"is"}),s.jsx("select",{value:_.is,onChange:U=>S(_.rowKey,{is:U.target.value}),disabled:a,className:`${R} font-mono`,children:YN.map(U=>s.jsx("option",{value:U,children:U},U))})]},_.rowKey):s.jsxs("div",{className:"surface-panel flex flex-wrap items-start gap-3 px-3 py-2",children:[s.jsx("div",{className:"min-w-[14rem] flex-1",children:s.jsx(M_,{value:_.when,onChange:U=>S(_.rowKey,{when:U}),fieldOptions:d,registry:l,disabled:a})}),s.jsxs("div",{className:"flex items-center gap-2 pt-5",children:[s.jsx("span",{className:"text-sm text-muted-foreground",children:"is"}),s.jsx("select",{value:_.is,onChange:U=>S(_.rowKey,{is:U.target.value}),disabled:a,className:`${R} font-mono`,children:YN.map(U=>s.jsx("option",{value:U,children:U},U))}),s.jsx("button",{type:"button",onClick:()=>D(_.rowKey),disabled:a,className:"inline-flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground hover:bg-muted hover:text-foreground","aria-label":"Remove disposition rule",children:s.jsx(bn,{className:"h-3.5 w-3.5"})})]})]},_.rowKey))}),s.jsxs("button",{type:"button",onClick:C,disabled:a,className:"shell-action text-xs inline-flex items-center gap-1",children:[s.jsx(It,{className:"h-3 w-3"}),"Add disposition rule"]})]}),s.jsxs("div",{className:"mt-5 space-y-2",children:[s.jsx("h4",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:"Headline projection"}),s.jsxs("div",{className:"surface-panel grid grid-cols-1 gap-3 px-3 py-2 sm:grid-cols-2",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsx("label",{className:"text-xs text-muted-foreground",children:"When parked, show"}),$(e.headline.parked,_=>T("parked",_),"Parked headline status")]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx("label",{className:"text-xs text-muted-foreground",children:"When blocked, show"}),$(e.headline.blocked,_=>T("blocked",_),"Blocked headline status")]}),s.jsxs("div",{className:"text-xs text-muted-foreground",children:["Terminal statuses: ",s.jsx("span",{className:"font-mono",children:"passthrough"})]}),s.jsxs("div",{className:"text-xs text-muted-foreground",children:["Active: ",s.jsx("span",{className:"font-mono",children:"phase"})]})]})]})]})}function ZX({rung:e,disabled:t,statusSelect:n,fieldOptions:r,registry:o,onUpdate:i,onRemove:a}){const{attributes:l,listeners:d,setNodeRef:f,setActivatorNodeRef:p,transform:h,transition:g,isDragging:y}=gm({id:e.rowKey}),k={transform:bs.Transform.toString(h),transition:g,zIndex:y?50:void 0,position:y?"relative":void 0};return s.jsxs("div",{ref:f,style:k,className:`surface-panel flex flex-wrap items-start gap-3 px-3 py-2 ${y?"opacity-60 shadow-lg":""}`,children:[s.jsx("button",{ref:p,...l,...d,type:"button","aria-label":"Drag to reorder rung",className:"mt-1 cursor-grab active:cursor-grabbing text-muted-foreground/40 hover:text-muted-foreground transition touch-none",children:s.jsx(dc,{className:"h-4 w-4"})}),s.jsxs("div",{className:"min-w-[10rem] space-y-1",children:[s.jsx("label",{className:"text-xs text-muted-foreground",children:"Phase"}),n(e.phase,w=>i({phase:w}),"Rung phase")]}),s.jsx("div",{className:"min-w-[14rem] flex-1",children:s.jsx(M_,{value:e.when,onChange:w=>i({when:w}),fieldOptions:r,registry:o,disabled:t})}),s.jsxs("div",{className:"min-w-[12rem] flex-1 space-y-1",children:[s.jsx("label",{className:"text-xs text-muted-foreground",children:"Next action"}),s.jsx("input",{type:"text",value:e.next,onChange:w=>i({next:w.target.value}),disabled:t,className:"w-full rounded-md border border-border/60 bg-background px-2 py-1 text-sm focus:border-primary focus:outline-none focus:ring-2 focus:ring-primary/30 disabled:opacity-60"})]}),s.jsx("button",{type:"button",onClick:a,disabled:t,className:"mt-5 inline-flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground hover:bg-muted hover:text-foreground","aria-label":"Remove rung",children:s.jsx(bn,{className:"h-3.5 w-3.5"})})]})}const eQ=new Map([["pending:start","in_progress"],["pending:block","blocked"],["draft:shape","ready_for_planning"],["draft:start","in_progress"],["ready_for_planning:plan-ready","ready_to_implement"],["ready_for_planning:start","in_progress"],["ready_to_implement:implement","in_progress"],["in_progress:block","blocked"],["in_progress:review","review"],["in_progress:complete","completed"],["in_progress:fail","failed"],["blocked:unblock","in_progress"],["review:start","in_progress"],["review:complete","completed"],["review:fail","failed"],["completed:reopen","in_progress"],["failed:reopen","in_progress"]]);let XN=0;function O_(){return XN+=1,`tr_${XN}_${Math.random().toString(36).slice(2,8)}`}function tQ(e){return{rowKey:O_(),from:e.from,command:e.command,to:e.to,label:e.label??"",description:e.description??"",requiresReason:e.requiresReason??!1}}function iv(e){return e.map(tQ)}function nQ(e){const t={from:e.from,command:e.command,to:e.to};return e.label.trim()&&(t.label=e.label.trim()),e.description.trim()&&(t.description=e.description.trim()),e.requiresReason&&(t.requiresReason=!0),t}function rQ(e){return e.map(nQ)}function F_(){const e=[];for(const[t,n]of eQ){const r=t.indexOf(":");e.push({from:t.slice(0,r),command:t.slice(r+1),to:n})}return e}function sQ(e,t){return e.filter(n=>t.has(n.from)&&t.has(n.to))}function z_(e,t){const n=[];for(const r of e)t.has(r.from)||n.push(`transition ${r.from} --${r.command}--> ${r.to}: "${r.from}" is not a defined status`),t.has(r.to)||n.push(`transition ${r.from} --${r.command}--> ${r.to}: "${r.to}" is not a defined status`);return n}function oQ(e,t){var i;const n=(i=t[0])==null?void 0:i.id,r=new Set;for(const a of e)a.to&&r.add(a.to);const o=new Set;for(const a of t)a.id!==n&&(r.has(a.id)||o.add(a.id));return o}function QN(e,t){const n=new Set(t.map(l=>l.id)),r=oQ(e,t),o=[],i=new Set;for(const l of t)i.has(l.id)||(i.add(l.id),o.push({id:l.id,label:l.label,color:l.color,terminal:l.terminal??!1,orphan:r.has(l.id),missing:!1}));for(const l of e)for(const d of[l.from,l.to])d&&!i.has(d)&&(i.add(d),o.push({id:d,label:d,terminal:!1,orphan:!1,missing:!0}));const a=e.map(l=>({rowKey:l.rowKey,from:l.from,to:l.to,command:l.command,label:l.label,requiresReason:l.requiresReason,undefinedRef:!n.has(l.from)||!n.has(l.to)}));return{nodes:o,edges:a}}function Sn(e){if(typeof e=="string"||typeof e=="number")return""+e;let t="";if(Array.isArray(e))for(let n=0,r;n<e.length;n++)(r=Sn(e[n]))!==""&&(t+=(t&&" ")+r);else for(let n in e)e[n]&&(t+=(t&&" ")+n);return t}var iQ={value:()=>{}};function Hm(){for(var e=0,t=arguments.length,n={},r;e<t;++e){if(!(r=arguments[e]+"")||r in n||/[\s.]/.test(r))throw new Error("illegal type: "+r);n[r]=[]}return new Wp(n)}function Wp(e){this._=e}function aQ(e,t){return e.trim().split(/^|\s+/).map(function(n){var r="",o=n.indexOf(".");if(o>=0&&(r=n.slice(o+1),n=n.slice(0,o)),n&&!t.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:r}})}Wp.prototype=Hm.prototype={constructor:Wp,on:function(e,t){var n=this._,r=aQ(e+"",n),o,i=-1,a=r.length;if(arguments.length<2){for(;++i<a;)if((o=(e=r[i]).type)&&(o=lQ(n[o],e.name)))return o;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++i<a;)if(o=(e=r[i]).type)n[o]=JN(n[o],e.name,t);else if(t==null)for(o in n)n[o]=JN(n[o],e.name,null);return this},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new Wp(e)},call:function(e,t){if((o=arguments.length-2)>0)for(var n=new Array(o),r=0,o,i;r<o;++r)n[r]=arguments[r+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(i=this._[e],r=0,o=i.length;r<o;++r)i[r].value.apply(t,n)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var r=this._[e],o=0,i=r.length;o<i;++o)r[o].value.apply(t,n)}};function lQ(e,t){for(var n=0,r=e.length,o;n<r;++n)if((o=e[n]).name===t)return o.value}function JN(e,t,n){for(var r=0,o=e.length;r<o;++r)if(e[r].name===t){e[r]=iQ,e=e.slice(0,r).concat(e.slice(r+1));break}return n!=null&&e.push({name:t,value:n}),e}var av="http://www.w3.org/1999/xhtml";const ZN={svg:"http://www.w3.org/2000/svg",xhtml:av,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function Vm(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),ZN.hasOwnProperty(t)?{space:ZN[t],local:e}:e}function cQ(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===av&&t.documentElement.namespaceURI===av?t.createElement(e):t.createElementNS(n,e)}}function uQ(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function B_(e){var t=Vm(e);return(t.local?uQ:cQ)(t)}function dQ(){}function h0(e){return e==null?dQ:function(){return this.querySelector(e)}}function fQ(e){typeof e!="function"&&(e=h0(e));for(var t=this._groups,n=t.length,r=new Array(n),o=0;o<n;++o)for(var i=t[o],a=i.length,l=r[o]=new Array(a),d,f,p=0;p<a;++p)(d=i[p])&&(f=e.call(d,d.__data__,p,i))&&("__data__"in d&&(f.__data__=d.__data__),l[p]=f);return new Br(r,this._parents)}function pQ(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function hQ(){return[]}function U_(e){return e==null?hQ:function(){return this.querySelectorAll(e)}}function mQ(e){return function(){return pQ(e.apply(this,arguments))}}function gQ(e){typeof e=="function"?e=mQ(e):e=U_(e);for(var t=this._groups,n=t.length,r=[],o=[],i=0;i<n;++i)for(var a=t[i],l=a.length,d,f=0;f<l;++f)(d=a[f])&&(r.push(e.call(d,d.__data__,f,a)),o.push(d));return new Br(r,o)}function H_(e){return function(){return this.matches(e)}}function V_(e){return function(t){return t.matches(e)}}var xQ=Array.prototype.find;function yQ(e){return function(){return xQ.call(this.children,e)}}function bQ(){return this.firstElementChild}function vQ(e){return this.select(e==null?bQ:yQ(typeof e=="function"?e:V_(e)))}var wQ=Array.prototype.filter;function jQ(){return Array.from(this.children)}function kQ(e){return function(){return wQ.call(this.children,e)}}function SQ(e){return this.selectAll(e==null?jQ:kQ(typeof e=="function"?e:V_(e)))}function NQ(e){typeof e!="function"&&(e=H_(e));for(var t=this._groups,n=t.length,r=new Array(n),o=0;o<n;++o)for(var i=t[o],a=i.length,l=r[o]=[],d,f=0;f<a;++f)(d=i[f])&&e.call(d,d.__data__,f,i)&&l.push(d);return new Br(r,this._parents)}function W_(e){return new Array(e.length)}function CQ(){return new Br(this._enter||this._groups.map(W_),this._parents)}function Th(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}Th.prototype={constructor:Th,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,t){return this._parent.insertBefore(e,t)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}};function EQ(e){return function(){return e}}function TQ(e,t,n,r,o,i){for(var a=0,l,d=t.length,f=i.length;a<f;++a)(l=t[a])?(l.__data__=i[a],r[a]=l):n[a]=new Th(e,i[a]);for(;a<d;++a)(l=t[a])&&(o[a]=l)}function RQ(e,t,n,r,o,i,a){var l,d,f=new Map,p=t.length,h=i.length,g=new Array(p),y;for(l=0;l<p;++l)(d=t[l])&&(g[l]=y=a.call(d,d.__data__,l,t)+"",f.has(y)?o[l]=d:f.set(y,d));for(l=0;l<h;++l)y=a.call(e,i[l],l,i)+"",(d=f.get(y))?(r[l]=d,d.__data__=i[l],f.delete(y)):n[l]=new Th(e,i[l]);for(l=0;l<p;++l)(d=t[l])&&f.get(g[l])===d&&(o[l]=d)}function AQ(e){return e.__data__}function PQ(e,t){if(!arguments.length)return Array.from(this,AQ);var n=t?RQ:TQ,r=this._parents,o=this._groups;typeof e!="function"&&(e=EQ(e));for(var i=o.length,a=new Array(i),l=new Array(i),d=new Array(i),f=0;f<i;++f){var p=r[f],h=o[f],g=h.length,y=_Q(e.call(p,p&&p.__data__,f,r)),k=y.length,w=l[f]=new Array(k),b=a[f]=new Array(k),j=d[f]=new Array(g);n(p,h,w,b,j,y,t);for(var N=0,S=0,C,D;N<k;++N)if(C=w[N]){for(N>=S&&(S=N+1);!(D=b[S])&&++S<k;);C._next=D||null}}return a=new Br(a,r),a._enter=l,a._exit=d,a}function _Q(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function DQ(){return new Br(this._exit||this._groups.map(W_),this._parents)}function $Q(e,t,n){var r=this.enter(),o=this,i=this.exit();return typeof e=="function"?(r=e(r),r&&(r=r.selection())):r=r.append(e+""),t!=null&&(o=t(o),o&&(o=o.selection())),n==null?i.remove():n(i),r&&o?r.merge(o).order():o}function IQ(e){for(var t=e.selection?e.selection():e,n=this._groups,r=t._groups,o=n.length,i=r.length,a=Math.min(o,i),l=new Array(o),d=0;d<a;++d)for(var f=n[d],p=r[d],h=f.length,g=l[d]=new Array(h),y,k=0;k<h;++k)(y=f[k]||p[k])&&(g[k]=y);for(;d<o;++d)l[d]=n[d];return new Br(l,this._parents)}function MQ(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var r=e[t],o=r.length-1,i=r[o],a;--o>=0;)(a=r[o])&&(i&&a.compareDocumentPosition(i)^4&&i.parentNode.insertBefore(a,i),i=a);return this}function LQ(e){e||(e=OQ);function t(h,g){return h&&g?e(h.__data__,g.__data__):!h-!g}for(var n=this._groups,r=n.length,o=new Array(r),i=0;i<r;++i){for(var a=n[i],l=a.length,d=o[i]=new Array(l),f,p=0;p<l;++p)(f=a[p])&&(d[p]=f);d.sort(t)}return new Br(o,this._parents).order()}function OQ(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function FQ(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function zQ(){return Array.from(this)}function BQ(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],o=0,i=r.length;o<i;++o){var a=r[o];if(a)return a}return null}function UQ(){let e=0;for(const t of this)++e;return e}function HQ(){return!this.node()}function VQ(e){for(var t=this._groups,n=0,r=t.length;n<r;++n)for(var o=t[n],i=0,a=o.length,l;i<a;++i)(l=o[i])&&e.call(l,l.__data__,i,o);return this}function WQ(e){return function(){this.removeAttribute(e)}}function qQ(e){return function(){this.removeAttributeNS(e.space,e.local)}}function KQ(e,t){return function(){this.setAttribute(e,t)}}function GQ(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function YQ(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function XQ(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,n)}}function QQ(e,t){var n=Vm(e);if(arguments.length<2){var r=this.node();return n.local?r.getAttributeNS(n.space,n.local):r.getAttribute(n)}return this.each((t==null?n.local?qQ:WQ:typeof t=="function"?n.local?XQ:YQ:n.local?GQ:KQ)(n,t))}function q_(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function JQ(e){return function(){this.style.removeProperty(e)}}function ZQ(e,t,n){return function(){this.style.setProperty(e,t,n)}}function eJ(e,t,n){return function(){var r=t.apply(this,arguments);r==null?this.style.removeProperty(e):this.style.setProperty(e,r,n)}}function tJ(e,t,n){return arguments.length>1?this.each((t==null?JQ:typeof t=="function"?eJ:ZQ)(e,t,n??"")):Zl(this.node(),e)}function Zl(e,t){return e.style.getPropertyValue(t)||q_(e).getComputedStyle(e,null).getPropertyValue(t)}function nJ(e){return function(){delete this[e]}}function rJ(e,t){return function(){this[e]=t}}function sJ(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function oJ(e,t){return arguments.length>1?this.each((t==null?nJ:typeof t=="function"?sJ:rJ)(e,t)):this.node()[e]}function K_(e){return e.trim().split(/^|\s+/)}function m0(e){return e.classList||new G_(e)}function G_(e){this._node=e,this._names=K_(e.getAttribute("class")||"")}G_.prototype={add:function(e){var t=this._names.indexOf(e);t<0&&(this._names.push(e),this._node.setAttribute("class",this._names.join(" ")))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(e){return this._names.indexOf(e)>=0}};function Y_(e,t){for(var n=m0(e),r=-1,o=t.length;++r<o;)n.add(t[r])}function X_(e,t){for(var n=m0(e),r=-1,o=t.length;++r<o;)n.remove(t[r])}function iJ(e){return function(){Y_(this,e)}}function aJ(e){return function(){X_(this,e)}}function lJ(e,t){return function(){(t.apply(this,arguments)?Y_:X_)(this,e)}}function cJ(e,t){var n=K_(e+"");if(arguments.length<2){for(var r=m0(this.node()),o=-1,i=n.length;++o<i;)if(!r.contains(n[o]))return!1;return!0}return this.each((typeof t=="function"?lJ:t?iJ:aJ)(n,t))}function uJ(){this.textContent=""}function dJ(e){return function(){this.textContent=e}}function fJ(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function pJ(e){return arguments.length?this.each(e==null?uJ:(typeof e=="function"?fJ:dJ)(e)):this.node().textContent}function hJ(){this.innerHTML=""}function mJ(e){return function(){this.innerHTML=e}}function gJ(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function xJ(e){return arguments.length?this.each(e==null?hJ:(typeof e=="function"?gJ:mJ)(e)):this.node().innerHTML}function yJ(){this.nextSibling&&this.parentNode.appendChild(this)}function bJ(){return this.each(yJ)}function vJ(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function wJ(){return this.each(vJ)}function jJ(e){var t=typeof e=="function"?e:B_(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function kJ(){return null}function SJ(e,t){var n=typeof e=="function"?e:B_(e),r=t==null?kJ:typeof t=="function"?t:h0(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})}function NJ(){var e=this.parentNode;e&&e.removeChild(this)}function CJ(){return this.each(NJ)}function EJ(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function TJ(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function RJ(e){return this.select(e?TJ:EJ)}function AJ(e){return arguments.length?this.property("__data__",e):this.node().__data__}function PJ(e){return function(t){e.call(this,t,this.__data__)}}function _J(e){return e.trim().split(/^|\s+/).map(function(t){var n="",r=t.indexOf(".");return r>=0&&(n=t.slice(r+1),t=t.slice(0,r)),{type:t,name:n}})}function DJ(e){return function(){var t=this.__on;if(t){for(var n=0,r=-1,o=t.length,i;n<o;++n)i=t[n],(!e.type||i.type===e.type)&&i.name===e.name?this.removeEventListener(i.type,i.listener,i.options):t[++r]=i;++r?t.length=r:delete this.__on}}}function $J(e,t,n){return function(){var r=this.__on,o,i=PJ(t);if(r){for(var a=0,l=r.length;a<l;++a)if((o=r[a]).type===e.type&&o.name===e.name){this.removeEventListener(o.type,o.listener,o.options),this.addEventListener(o.type,o.listener=i,o.options=n),o.value=t;return}}this.addEventListener(e.type,i,n),o={type:e.type,name:e.name,value:t,listener:i,options:n},r?r.push(o):this.__on=[o]}}function IJ(e,t,n){var r=_J(e+""),o,i=r.length,a;if(arguments.length<2){var l=this.node().__on;if(l){for(var d=0,f=l.length,p;d<f;++d)for(o=0,p=l[d];o<i;++o)if((a=r[o]).type===p.type&&a.name===p.name)return p.value}return}for(l=t?$J:DJ,o=0;o<i;++o)this.each(l(r[o],t,n));return this}function Q_(e,t,n){var r=q_(e),o=r.CustomEvent;typeof o=="function"?o=new o(t,n):(o=r.document.createEvent("Event"),n?(o.initEvent(t,n.bubbles,n.cancelable),o.detail=n.detail):o.initEvent(t,!1,!1)),e.dispatchEvent(o)}function MJ(e,t){return function(){return Q_(this,e,t)}}function LJ(e,t){return function(){return Q_(this,e,t.apply(this,arguments))}}function OJ(e,t){return this.each((typeof t=="function"?LJ:MJ)(e,t))}function*FJ(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],o=0,i=r.length,a;o<i;++o)(a=r[o])&&(yield a)}var J_=[null];function Br(e,t){this._groups=e,this._parents=t}function Vd(){return new Br([[document.documentElement]],J_)}function zJ(){return this}Br.prototype=Vd.prototype={constructor:Br,select:fQ,selectAll:gQ,selectChild:vQ,selectChildren:SQ,filter:NQ,data:PQ,enter:CQ,exit:DQ,join:$Q,merge:IQ,selection:zJ,order:MQ,sort:LQ,call:FQ,nodes:zQ,node:BQ,size:UQ,empty:HQ,each:VQ,attr:QQ,style:tJ,property:oJ,classed:cJ,text:pJ,html:xJ,raise:bJ,lower:wJ,append:jJ,insert:SJ,remove:CJ,clone:RJ,datum:AJ,on:IJ,dispatch:OJ,[Symbol.iterator]:FJ};function Lr(e){return typeof e=="string"?new Br([[document.querySelector(e)]],[document.documentElement]):new Br([[e]],J_)}function BJ(e){let t;for(;t=e.sourceEvent;)e=t;return e}function fs(e,t){if(e=BJ(e),t===void 0&&(t=e.currentTarget),t){var n=t.ownerSVGElement||t;if(n.createSVGPoint){var r=n.createSVGPoint();return r.x=e.clientX,r.y=e.clientY,r=r.matrixTransform(t.getScreenCTM().inverse()),[r.x,r.y]}if(t.getBoundingClientRect){var o=t.getBoundingClientRect();return[e.clientX-o.left-t.clientLeft,e.clientY-o.top-t.clientTop]}}return[e.pageX,e.pageY]}const UJ={passive:!1},ud={capture:!0,passive:!1};function By(e){e.stopImmediatePropagation()}function Hl(e){e.preventDefault(),e.stopImmediatePropagation()}function Z_(e){var t=e.document.documentElement,n=Lr(e).on("dragstart.drag",Hl,ud);"onselectstart"in t?n.on("selectstart.drag",Hl,ud):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function e3(e,t){var n=e.document.documentElement,r=Lr(e).on("dragstart.drag",null);t&&(r.on("click.drag",Hl,ud),setTimeout(function(){r.on("click.drag",null)},0)),"onselectstart"in n?r.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}const gp=e=>()=>e;function lv(e,{sourceEvent:t,subject:n,target:r,identifier:o,active:i,x:a,y:l,dx:d,dy:f,dispatch:p}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:r,enumerable:!0,configurable:!0},identifier:{value:o,enumerable:!0,configurable:!0},active:{value:i,enumerable:!0,configurable:!0},x:{value:a,enumerable:!0,configurable:!0},y:{value:l,enumerable:!0,configurable:!0},dx:{value:d,enumerable:!0,configurable:!0},dy:{value:f,enumerable:!0,configurable:!0},_:{value:p}})}lv.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function HJ(e){return!e.ctrlKey&&!e.button}function VJ(){return this.parentNode}function WJ(e,t){return t??{x:e.x,y:e.y}}function qJ(){return navigator.maxTouchPoints||"ontouchstart"in this}function t3(){var e=HJ,t=VJ,n=WJ,r=qJ,o={},i=Hm("start","drag","end"),a=0,l,d,f,p,h=0;function g(C){C.on("mousedown.drag",y).filter(r).on("touchstart.drag",b).on("touchmove.drag",j,UJ).on("touchend.drag touchcancel.drag",N).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function y(C,D){if(!(p||!e.call(this,C,D))){var T=S(this,t.call(this,C,D),C,D,"mouse");T&&(Lr(C.view).on("mousemove.drag",k,ud).on("mouseup.drag",w,ud),Z_(C.view),By(C),f=!1,l=C.clientX,d=C.clientY,T("start",C))}}function k(C){if(Hl(C),!f){var D=C.clientX-l,T=C.clientY-d;f=D*D+T*T>h}o.mouse("drag",C)}function w(C){Lr(C.view).on("mousemove.drag mouseup.drag",null),e3(C.view,f),Hl(C),o.mouse("end",C)}function b(C,D){if(e.call(this,C,D)){var T=C.changedTouches,R=t.call(this,C,D),$=T.length,_,U;for(_=0;_<$;++_)(U=S(this,R,C,D,T[_].identifier,T[_]))&&(By(C),U("start",C,T[_]))}}function j(C){var D=C.changedTouches,T=D.length,R,$;for(R=0;R<T;++R)($=o[D[R].identifier])&&(Hl(C),$("drag",C,D[R]))}function N(C){var D=C.changedTouches,T=D.length,R,$;for(p&&clearTimeout(p),p=setTimeout(function(){p=null},500),R=0;R<T;++R)($=o[D[R].identifier])&&(By(C),$("end",C,D[R]))}function S(C,D,T,R,$,_){var U=i.copy(),I=fs(_||T,D),F,M,A;if((A=n.call(C,new lv("beforestart",{sourceEvent:T,target:g,identifier:$,active:a,x:I[0],y:I[1],dx:0,dy:0,dispatch:U}),R))!=null)return F=A.x-I[0]||0,M=A.y-I[1]||0,function L(z,W,V){var K=I,O;switch(z){case"start":o[$]=L,O=a++;break;case"end":delete o[$],--a;case"drag":I=fs(V||W,D),O=a;break}U.call(z,C,new lv(z,{sourceEvent:W,subject:A,target:g,identifier:$,active:O,x:I[0]+F,y:I[1]+M,dx:I[0]-K[0],dy:I[1]-K[1],dispatch:U}),R)}}return g.filter=function(C){return arguments.length?(e=typeof C=="function"?C:gp(!!C),g):e},g.container=function(C){return arguments.length?(t=typeof C=="function"?C:gp(C),g):t},g.subject=function(C){return arguments.length?(n=typeof C=="function"?C:gp(C),g):n},g.touchable=function(C){return arguments.length?(r=typeof C=="function"?C:gp(!!C),g):r},g.on=function(){var C=i.on.apply(i,arguments);return C===i?g:C},g.clickDistance=function(C){return arguments.length?(h=(C=+C)*C,g):Math.sqrt(h)},g}function g0(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function n3(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function Wd(){}var dd=.7,Rh=1/dd,Vl="\\s*([+-]?\\d+)\\s*",fd="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Xs="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",KJ=/^#([0-9a-f]{3,8})$/,GJ=new RegExp(`^rgb\\(${Vl},${Vl},${Vl}\\)$`),YJ=new RegExp(`^rgb\\(${Xs},${Xs},${Xs}\\)$`),XJ=new RegExp(`^rgba\\(${Vl},${Vl},${Vl},${fd}\\)$`),QJ=new RegExp(`^rgba\\(${Xs},${Xs},${Xs},${fd}\\)$`),JJ=new RegExp(`^hsl\\(${fd},${Xs},${Xs}\\)$`),ZJ=new RegExp(`^hsla\\(${fd},${Xs},${Xs},${fd}\\)$`),eC={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};g0(Wd,ba,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:tC,formatHex:tC,formatHex8:eZ,formatHsl:tZ,formatRgb:nC,toString:nC});function tC(){return this.rgb().formatHex()}function eZ(){return this.rgb().formatHex8()}function tZ(){return r3(this).formatHsl()}function nC(){return this.rgb().formatRgb()}function ba(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=KJ.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?rC(t):n===3?new yr(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?xp(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?xp(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=GJ.exec(e))?new yr(t[1],t[2],t[3],1):(t=YJ.exec(e))?new yr(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=XJ.exec(e))?xp(t[1],t[2],t[3],t[4]):(t=QJ.exec(e))?xp(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=JJ.exec(e))?iC(t[1],t[2]/100,t[3]/100,1):(t=ZJ.exec(e))?iC(t[1],t[2]/100,t[3]/100,t[4]):eC.hasOwnProperty(e)?rC(eC[e]):e==="transparent"?new yr(NaN,NaN,NaN,0):null}function rC(e){return new yr(e>>16&255,e>>8&255,e&255,1)}function xp(e,t,n,r){return r<=0&&(e=t=n=NaN),new yr(e,t,n,r)}function nZ(e){return e instanceof Wd||(e=ba(e)),e?(e=e.rgb(),new yr(e.r,e.g,e.b,e.opacity)):new yr}function cv(e,t,n,r){return arguments.length===1?nZ(e):new yr(e,t,n,r??1)}function yr(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}g0(yr,cv,n3(Wd,{brighter(e){return e=e==null?Rh:Math.pow(Rh,e),new yr(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?dd:Math.pow(dd,e),new yr(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new yr(ha(this.r),ha(this.g),ha(this.b),Ah(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:sC,formatHex:sC,formatHex8:rZ,formatRgb:oC,toString:oC}));function sC(){return`#${ca(this.r)}${ca(this.g)}${ca(this.b)}`}function rZ(){return`#${ca(this.r)}${ca(this.g)}${ca(this.b)}${ca((isNaN(this.opacity)?1:this.opacity)*255)}`}function oC(){const e=Ah(this.opacity);return`${e===1?"rgb(":"rgba("}${ha(this.r)}, ${ha(this.g)}, ${ha(this.b)}${e===1?")":`, ${e})`}`}function Ah(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function ha(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function ca(e){return e=ha(e),(e<16?"0":"")+e.toString(16)}function iC(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new ps(e,t,n,r)}function r3(e){if(e instanceof ps)return new ps(e.h,e.s,e.l,e.opacity);if(e instanceof Wd||(e=ba(e)),!e)return new ps;if(e instanceof ps)return e;e=e.rgb();var t=e.r/255,n=e.g/255,r=e.b/255,o=Math.min(t,n,r),i=Math.max(t,n,r),a=NaN,l=i-o,d=(i+o)/2;return l?(t===i?a=(n-r)/l+(n<r)*6:n===i?a=(r-t)/l+2:a=(t-n)/l+4,l/=d<.5?i+o:2-i-o,a*=60):l=d>0&&d<1?0:a,new ps(a,l,d,e.opacity)}function sZ(e,t,n,r){return arguments.length===1?r3(e):new ps(e,t,n,r??1)}function ps(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}g0(ps,sZ,n3(Wd,{brighter(e){return e=e==null?Rh:Math.pow(Rh,e),new ps(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?dd:Math.pow(dd,e),new ps(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*t,o=2*n-r;return new yr(Uy(e>=240?e-240:e+120,o,r),Uy(e,o,r),Uy(e<120?e+240:e-120,o,r),this.opacity)},clamp(){return new ps(aC(this.h),yp(this.s),yp(this.l),Ah(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const e=Ah(this.opacity);return`${e===1?"hsl(":"hsla("}${aC(this.h)}, ${yp(this.s)*100}%, ${yp(this.l)*100}%${e===1?")":`, ${e})`}`}}));function aC(e){return e=(e||0)%360,e<0?e+360:e}function yp(e){return Math.max(0,Math.min(1,e||0))}function Uy(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}const Wm=e=>()=>e;function s3(e,t){return function(n){return e+n*t}}function oZ(e,t,n){return e=Math.pow(e,n),t=Math.pow(t,n)-e,n=1/n,function(r){return Math.pow(e+r*t,n)}}function lae(e,t){var n=t-e;return n?s3(e,n>180||n<-180?n-360*Math.round(n/360):n):Wm(isNaN(e)?t:e)}function iZ(e){return(e=+e)==1?o3:function(t,n){return n-t?oZ(t,n,e):Wm(isNaN(t)?n:t)}}function o3(e,t){var n=t-e;return n?s3(e,n):Wm(isNaN(e)?t:e)}const Ph=(function e(t){var n=iZ(t);function r(o,i){var a=n((o=cv(o)).r,(i=cv(i)).r),l=n(o.g,i.g),d=n(o.b,i.b),f=o3(o.opacity,i.opacity);return function(p){return o.r=a(p),o.g=l(p),o.b=d(p),o.opacity=f(p),o+""}}return r.gamma=e,r})(1);function aZ(e,t){t||(t=[]);var n=e?Math.min(t.length,e.length):0,r=t.slice(),o;return function(i){for(o=0;o<n;++o)r[o]=e[o]*(1-i)+t[o]*i;return r}}function lZ(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function cZ(e,t){var n=t?t.length:0,r=e?Math.min(n,e.length):0,o=new Array(r),i=new Array(n),a;for(a=0;a<r;++a)o[a]=qu(e[a],t[a]);for(;a<n;++a)i[a]=t[a];return function(l){for(a=0;a<r;++a)i[a]=o[a](l);return i}}function uZ(e,t){var n=new Date;return e=+e,t=+t,function(r){return n.setTime(e*(1-r)+t*r),n}}function Us(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}function dZ(e,t){var n={},r={},o;(e===null||typeof e!="object")&&(e={}),(t===null||typeof t!="object")&&(t={});for(o in t)o in e?n[o]=qu(e[o],t[o]):r[o]=t[o];return function(i){for(o in n)r[o]=n[o](i);return r}}var uv=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Hy=new RegExp(uv.source,"g");function fZ(e){return function(){return e}}function pZ(e){return function(t){return e(t)+""}}function i3(e,t){var n=uv.lastIndex=Hy.lastIndex=0,r,o,i,a=-1,l=[],d=[];for(e=e+"",t=t+"";(r=uv.exec(e))&&(o=Hy.exec(t));)(i=o.index)>n&&(i=t.slice(n,i),l[a]?l[a]+=i:l[++a]=i),(r=r[0])===(o=o[0])?l[a]?l[a]+=o:l[++a]=o:(l[++a]=null,d.push({i:a,x:Us(r,o)})),n=Hy.lastIndex;return n<t.length&&(i=t.slice(n),l[a]?l[a]+=i:l[++a]=i),l.length<2?d[0]?pZ(d[0].x):fZ(t):(t=d.length,function(f){for(var p=0,h;p<t;++p)l[(h=d[p]).i]=h.x(f);return l.join("")})}function qu(e,t){var n=typeof t,r;return t==null||n==="boolean"?Wm(t):(n==="number"?Us:n==="string"?(r=ba(t))?(t=r,Ph):i3:t instanceof ba?Ph:t instanceof Date?uZ:lZ(t)?aZ:Array.isArray(t)?cZ:typeof t.valueOf!="function"&&typeof t.toString!="function"||isNaN(t)?dZ:Us)(e,t)}var lC=180/Math.PI,dv={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function a3(e,t,n,r,o,i){var a,l,d;return(a=Math.sqrt(e*e+t*t))&&(e/=a,t/=a),(d=e*n+t*r)&&(n-=e*d,r-=t*d),(l=Math.sqrt(n*n+r*r))&&(n/=l,r/=l,d/=l),e*r<t*n&&(e=-e,t=-t,d=-d,a=-a),{translateX:o,translateY:i,rotate:Math.atan2(t,e)*lC,skewX:Math.atan(d)*lC,scaleX:a,scaleY:l}}var bp;function hZ(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?dv:a3(t.a,t.b,t.c,t.d,t.e,t.f)}function mZ(e){return e==null||(bp||(bp=document.createElementNS("http://www.w3.org/2000/svg","g")),bp.setAttribute("transform",e),!(e=bp.transform.baseVal.consolidate()))?dv:(e=e.matrix,a3(e.a,e.b,e.c,e.d,e.e,e.f))}function l3(e,t,n,r){function o(f){return f.length?f.pop()+" ":""}function i(f,p,h,g,y,k){if(f!==h||p!==g){var w=y.push("translate(",null,t,null,n);k.push({i:w-4,x:Us(f,h)},{i:w-2,x:Us(p,g)})}else(h||g)&&y.push("translate("+h+t+g+n)}function a(f,p,h,g){f!==p?(f-p>180?p+=360:p-f>180&&(f+=360),g.push({i:h.push(o(h)+"rotate(",null,r)-2,x:Us(f,p)})):p&&h.push(o(h)+"rotate("+p+r)}function l(f,p,h,g){f!==p?g.push({i:h.push(o(h)+"skewX(",null,r)-2,x:Us(f,p)}):p&&h.push(o(h)+"skewX("+p+r)}function d(f,p,h,g,y,k){if(f!==h||p!==g){var w=y.push(o(y)+"scale(",null,",",null,")");k.push({i:w-4,x:Us(f,h)},{i:w-2,x:Us(p,g)})}else(h!==1||g!==1)&&y.push(o(y)+"scale("+h+","+g+")")}return function(f,p){var h=[],g=[];return f=e(f),p=e(p),i(f.translateX,f.translateY,p.translateX,p.translateY,h,g),a(f.rotate,p.rotate,h,g),l(f.skewX,p.skewX,h,g),d(f.scaleX,f.scaleY,p.scaleX,p.scaleY,h,g),f=p=null,function(y){for(var k=-1,w=g.length,b;++k<w;)h[(b=g[k]).i]=b.x(y);return h.join("")}}}var gZ=l3(hZ,"px, ","px)","deg)"),xZ=l3(mZ,", ",")",")"),yZ=1e-12;function cC(e){return((e=Math.exp(e))+1/e)/2}function bZ(e){return((e=Math.exp(e))-1/e)/2}function vZ(e){return((e=Math.exp(2*e))-1)/(e+1)}const qp=(function e(t,n,r){function o(i,a){var l=i[0],d=i[1],f=i[2],p=a[0],h=a[1],g=a[2],y=p-l,k=h-d,w=y*y+k*k,b,j;if(w<yZ)j=Math.log(g/f)/t,b=function(R){return[l+R*y,d+R*k,f*Math.exp(t*R*j)]};else{var N=Math.sqrt(w),S=(g*g-f*f+r*w)/(2*f*n*N),C=(g*g-f*f-r*w)/(2*g*n*N),D=Math.log(Math.sqrt(S*S+1)-S),T=Math.log(Math.sqrt(C*C+1)-C);j=(T-D)/t,b=function(R){var $=R*j,_=cC(D),U=f/(n*N)*(_*vZ(t*$+D)-bZ(D));return[l+U*y,d+U*k,f*_/cC(t*$+D)]}}return b.duration=j*1e3*t/Math.SQRT2,b}return o.rho=function(i){var a=Math.max(.001,+i),l=a*a,d=l*l;return e(a,l,d)},o})(Math.SQRT2,2,4);var ec=0,Nu=0,ku=0,c3=1e3,_h,Cu,Dh=0,va=0,qm=0,pd=typeof performance=="object"&&performance.now?performance:Date,u3=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function x0(){return va||(u3(wZ),va=pd.now()+qm)}function wZ(){va=0}function $h(){this._call=this._time=this._next=null}$h.prototype=d3.prototype={constructor:$h,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?x0():+n)+(t==null?0:+t),!this._next&&Cu!==this&&(Cu?Cu._next=this:_h=this,Cu=this),this._call=e,this._time=n,fv()},stop:function(){this._call&&(this._call=null,this._time=1/0,fv())}};function d3(e,t,n){var r=new $h;return r.restart(e,t,n),r}function jZ(){x0(),++ec;for(var e=_h,t;e;)(t=va-e._time)>=0&&e._call.call(void 0,t),e=e._next;--ec}function uC(){va=(Dh=pd.now())+qm,ec=Nu=0;try{jZ()}finally{ec=0,SZ(),va=0}}function kZ(){var e=pd.now(),t=e-Dh;t>c3&&(qm-=t,Dh=e)}function SZ(){for(var e,t=_h,n,r=1/0;t;)t._call?(r>t._time&&(r=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:_h=n);Cu=e,fv(r)}function fv(e){if(!ec){Nu&&(Nu=clearTimeout(Nu));var t=e-va;t>24?(e<1/0&&(Nu=setTimeout(uC,e-pd.now()-qm)),ku&&(ku=clearInterval(ku))):(ku||(Dh=pd.now(),ku=setInterval(kZ,c3)),ec=1,u3(uC))}}function dC(e,t,n){var r=new $h;return t=t==null?0:+t,r.restart(o=>{r.stop(),e(o+t)},t,n),r}var NZ=Hm("start","end","cancel","interrupt"),CZ=[],f3=0,fC=1,pv=2,Kp=3,pC=4,hv=5,Gp=6;function Km(e,t,n,r,o,i){var a=e.__transition;if(!a)e.__transition={};else if(n in a)return;EZ(e,n,{name:t,index:r,group:o,on:NZ,tween:CZ,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:f3})}function y0(e,t){var n=Ts(e,t);if(n.state>f3)throw new Error("too late; already scheduled");return n}function to(e,t){var n=Ts(e,t);if(n.state>Kp)throw new Error("too late; already running");return n}function Ts(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function EZ(e,t,n){var r=e.__transition,o;r[t]=n,n.timer=d3(i,0,n.time);function i(f){n.state=fC,n.timer.restart(a,n.delay,n.time),n.delay<=f&&a(f-n.delay)}function a(f){var p,h,g,y;if(n.state!==fC)return d();for(p in r)if(y=r[p],y.name===n.name){if(y.state===Kp)return dC(a);y.state===pC?(y.state=Gp,y.timer.stop(),y.on.call("interrupt",e,e.__data__,y.index,y.group),delete r[p]):+p<t&&(y.state=Gp,y.timer.stop(),y.on.call("cancel",e,e.__data__,y.index,y.group),delete r[p])}if(dC(function(){n.state===Kp&&(n.state=pC,n.timer.restart(l,n.delay,n.time),l(f))}),n.state=pv,n.on.call("start",e,e.__data__,n.index,n.group),n.state===pv){for(n.state=Kp,o=new Array(g=n.tween.length),p=0,h=-1;p<g;++p)(y=n.tween[p].value.call(e,e.__data__,n.index,n.group))&&(o[++h]=y);o.length=h+1}}function l(f){for(var p=f<n.duration?n.ease.call(null,f/n.duration):(n.timer.restart(d),n.state=hv,1),h=-1,g=o.length;++h<g;)o[h].call(e,p);n.state===hv&&(n.on.call("end",e,e.__data__,n.index,n.group),d())}function d(){n.state=Gp,n.timer.stop(),delete r[t];for(var f in r)return;delete e.__transition}}function Yp(e,t){var n=e.__transition,r,o,i=!0,a;if(n){t=t==null?null:t+"";for(a in n){if((r=n[a]).name!==t){i=!1;continue}o=r.state>pv&&r.state<hv,r.state=Gp,r.timer.stop(),r.on.call(o?"interrupt":"cancel",e,e.__data__,r.index,r.group),delete n[a]}i&&delete e.__transition}}function TZ(e){return this.each(function(){Yp(this,e)})}function RZ(e,t){var n,r;return function(){var o=to(this,e),i=o.tween;if(i!==n){r=n=i;for(var a=0,l=r.length;a<l;++a)if(r[a].name===t){r=r.slice(),r.splice(a,1);break}}o.tween=r}}function AZ(e,t,n){var r,o;if(typeof n!="function")throw new Error;return function(){var i=to(this,e),a=i.tween;if(a!==r){o=(r=a).slice();for(var l={name:t,value:n},d=0,f=o.length;d<f;++d)if(o[d].name===t){o[d]=l;break}d===f&&o.push(l)}i.tween=o}}function PZ(e,t){var n=this._id;if(e+="",arguments.length<2){for(var r=Ts(this.node(),n).tween,o=0,i=r.length,a;o<i;++o)if((a=r[o]).name===e)return a.value;return null}return this.each((t==null?RZ:AZ)(n,e,t))}function b0(e,t,n){var r=e._id;return e.each(function(){var o=to(this,r);(o.value||(o.value={}))[t]=n.apply(this,arguments)}),function(o){return Ts(o,r).value[t]}}function p3(e,t){var n;return(typeof t=="number"?Us:t instanceof ba?Ph:(n=ba(t))?(t=n,Ph):i3)(e,t)}function _Z(e){return function(){this.removeAttribute(e)}}function DZ(e){return function(){this.removeAttributeNS(e.space,e.local)}}function $Z(e,t,n){var r,o=n+"",i;return function(){var a=this.getAttribute(e);return a===o?null:a===r?i:i=t(r=a,n)}}function IZ(e,t,n){var r,o=n+"",i;return function(){var a=this.getAttributeNS(e.space,e.local);return a===o?null:a===r?i:i=t(r=a,n)}}function MZ(e,t,n){var r,o,i;return function(){var a,l=n(this),d;return l==null?void this.removeAttribute(e):(a=this.getAttribute(e),d=l+"",a===d?null:a===r&&d===o?i:(o=d,i=t(r=a,l)))}}function LZ(e,t,n){var r,o,i;return function(){var a,l=n(this),d;return l==null?void this.removeAttributeNS(e.space,e.local):(a=this.getAttributeNS(e.space,e.local),d=l+"",a===d?null:a===r&&d===o?i:(o=d,i=t(r=a,l)))}}function OZ(e,t){var n=Vm(e),r=n==="transform"?xZ:p3;return this.attrTween(e,typeof t=="function"?(n.local?LZ:MZ)(n,r,b0(this,"attr."+e,t)):t==null?(n.local?DZ:_Z)(n):(n.local?IZ:$Z)(n,r,t))}function FZ(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function zZ(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function BZ(e,t){var n,r;function o(){var i=t.apply(this,arguments);return i!==r&&(n=(r=i)&&zZ(e,i)),n}return o._value=t,o}function UZ(e,t){var n,r;function o(){var i=t.apply(this,arguments);return i!==r&&(n=(r=i)&&FZ(e,i)),n}return o._value=t,o}function HZ(e,t){var n="attr."+e;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(t==null)return this.tween(n,null);if(typeof t!="function")throw new Error;var r=Vm(e);return this.tween(n,(r.local?BZ:UZ)(r,t))}function VZ(e,t){return function(){y0(this,e).delay=+t.apply(this,arguments)}}function WZ(e,t){return t=+t,function(){y0(this,e).delay=t}}function qZ(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?VZ:WZ)(t,e)):Ts(this.node(),t).delay}function KZ(e,t){return function(){to(this,e).duration=+t.apply(this,arguments)}}function GZ(e,t){return t=+t,function(){to(this,e).duration=t}}function YZ(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?KZ:GZ)(t,e)):Ts(this.node(),t).duration}function XZ(e,t){if(typeof t!="function")throw new Error;return function(){to(this,e).ease=t}}function QZ(e){var t=this._id;return arguments.length?this.each(XZ(t,e)):Ts(this.node(),t).ease}function JZ(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;to(this,e).ease=n}}function ZZ(e){if(typeof e!="function")throw new Error;return this.each(JZ(this._id,e))}function eee(e){typeof e!="function"&&(e=H_(e));for(var t=this._groups,n=t.length,r=new Array(n),o=0;o<n;++o)for(var i=t[o],a=i.length,l=r[o]=[],d,f=0;f<a;++f)(d=i[f])&&e.call(d,d.__data__,f,i)&&l.push(d);return new To(r,this._parents,this._name,this._id)}function tee(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,n=e._groups,r=t.length,o=n.length,i=Math.min(r,o),a=new Array(r),l=0;l<i;++l)for(var d=t[l],f=n[l],p=d.length,h=a[l]=new Array(p),g,y=0;y<p;++y)(g=d[y]||f[y])&&(h[y]=g);for(;l<r;++l)a[l]=t[l];return new To(a,this._parents,this._name,this._id)}function nee(e){return(e+"").trim().split(/^|\s+/).every(function(t){var n=t.indexOf(".");return n>=0&&(t=t.slice(0,n)),!t||t==="start"})}function ree(e,t,n){var r,o,i=nee(t)?y0:to;return function(){var a=i(this,e),l=a.on;l!==r&&(o=(r=l).copy()).on(t,n),a.on=o}}function see(e,t){var n=this._id;return arguments.length<2?Ts(this.node(),n).on.on(e):this.each(ree(n,e,t))}function oee(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function iee(){return this.on("end.remove",oee(this._id))}function aee(e){var t=this._name,n=this._id;typeof e!="function"&&(e=h0(e));for(var r=this._groups,o=r.length,i=new Array(o),a=0;a<o;++a)for(var l=r[a],d=l.length,f=i[a]=new Array(d),p,h,g=0;g<d;++g)(p=l[g])&&(h=e.call(p,p.__data__,g,l))&&("__data__"in p&&(h.__data__=p.__data__),f[g]=h,Km(f[g],t,n,g,f,Ts(p,n)));return new To(i,this._parents,t,n)}function lee(e){var t=this._name,n=this._id;typeof e!="function"&&(e=U_(e));for(var r=this._groups,o=r.length,i=[],a=[],l=0;l<o;++l)for(var d=r[l],f=d.length,p,h=0;h<f;++h)if(p=d[h]){for(var g=e.call(p,p.__data__,h,d),y,k=Ts(p,n),w=0,b=g.length;w<b;++w)(y=g[w])&&Km(y,t,n,w,g,k);i.push(g),a.push(p)}return new To(i,a,t,n)}var cee=Vd.prototype.constructor;function uee(){return new cee(this._groups,this._parents)}function dee(e,t){var n,r,o;return function(){var i=Zl(this,e),a=(this.style.removeProperty(e),Zl(this,e));return i===a?null:i===n&&a===r?o:o=t(n=i,r=a)}}function h3(e){return function(){this.style.removeProperty(e)}}function fee(e,t,n){var r,o=n+"",i;return function(){var a=Zl(this,e);return a===o?null:a===r?i:i=t(r=a,n)}}function pee(e,t,n){var r,o,i;return function(){var a=Zl(this,e),l=n(this),d=l+"";return l==null&&(d=l=(this.style.removeProperty(e),Zl(this,e))),a===d?null:a===r&&d===o?i:(o=d,i=t(r=a,l))}}function hee(e,t){var n,r,o,i="style."+t,a="end."+i,l;return function(){var d=to(this,e),f=d.on,p=d.value[i]==null?l||(l=h3(t)):void 0;(f!==n||o!==p)&&(r=(n=f).copy()).on(a,o=p),d.on=r}}function mee(e,t,n){var r=(e+="")=="transform"?gZ:p3;return t==null?this.styleTween(e,dee(e,r)).on("end.style."+e,h3(e)):typeof t=="function"?this.styleTween(e,pee(e,r,b0(this,"style."+e,t))).each(hee(this._id,e)):this.styleTween(e,fee(e,r,t),n).on("end.style."+e,null)}function gee(e,t,n){return function(r){this.style.setProperty(e,t.call(this,r),n)}}function xee(e,t,n){var r,o;function i(){var a=t.apply(this,arguments);return a!==o&&(r=(o=a)&&gee(e,a,n)),r}return i._value=t,i}function yee(e,t,n){var r="style."+(e+="");if(arguments.length<2)return(r=this.tween(r))&&r._value;if(t==null)return this.tween(r,null);if(typeof t!="function")throw new Error;return this.tween(r,xee(e,t,n??""))}function bee(e){return function(){this.textContent=e}}function vee(e){return function(){var t=e(this);this.textContent=t??""}}function wee(e){return this.tween("text",typeof e=="function"?vee(b0(this,"text",e)):bee(e==null?"":e+""))}function jee(e){return function(t){this.textContent=e.call(this,t)}}function kee(e){var t,n;function r(){var o=e.apply(this,arguments);return o!==n&&(t=(n=o)&&jee(o)),t}return r._value=e,r}function See(e){var t="text";if(arguments.length<1)return(t=this.tween(t))&&t._value;if(e==null)return this.tween(t,null);if(typeof e!="function")throw new Error;return this.tween(t,kee(e))}function Nee(){for(var e=this._name,t=this._id,n=m3(),r=this._groups,o=r.length,i=0;i<o;++i)for(var a=r[i],l=a.length,d,f=0;f<l;++f)if(d=a[f]){var p=Ts(d,t);Km(d,e,n,f,a,{time:p.time+p.delay+p.duration,delay:0,duration:p.duration,ease:p.ease})}return new To(r,this._parents,e,n)}function Cee(){var e,t,n=this,r=n._id,o=n.size();return new Promise(function(i,a){var l={value:a},d={value:function(){--o===0&&i()}};n.each(function(){var f=to(this,r),p=f.on;p!==e&&(t=(e=p).copy(),t._.cancel.push(l),t._.interrupt.push(l),t._.end.push(d)),f.on=t}),o===0&&i()})}var Eee=0;function To(e,t,n,r){this._groups=e,this._parents=t,this._name=n,this._id=r}function m3(){return++Eee}var yo=Vd.prototype;To.prototype={constructor:To,select:aee,selectAll:lee,selectChild:yo.selectChild,selectChildren:yo.selectChildren,filter:eee,merge:tee,selection:uee,transition:Nee,call:yo.call,nodes:yo.nodes,node:yo.node,size:yo.size,empty:yo.empty,each:yo.each,on:see,attr:OZ,attrTween:HZ,style:mee,styleTween:yee,text:wee,textTween:See,remove:iee,tween:PZ,delay:qZ,duration:YZ,ease:QZ,easeVarying:ZZ,end:Cee,[Symbol.iterator]:yo[Symbol.iterator]};function Tee(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var Ree={time:null,delay:0,duration:250,ease:Tee};function Aee(e,t){for(var n;!(n=e.__transition)||!(n=n[t]);)if(!(e=e.parentNode))throw new Error(`transition ${t} not found`);return n}function Pee(e){var t,n;e instanceof To?(t=e._id,e=e._name):(t=m3(),(n=Ree).time=x0(),e=e==null?null:e+"");for(var r=this._groups,o=r.length,i=0;i<o;++i)for(var a=r[i],l=a.length,d,f=0;f<l;++f)(d=a[f])&&Km(d,e,t,f,a,n||Aee(d,t));return new To(r,this._parents,e,t)}Vd.prototype.interrupt=TZ;Vd.prototype.transition=Pee;const vp=e=>()=>e;function _ee(e,{sourceEvent:t,target:n,transform:r,dispatch:o}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:r,enumerable:!0,configurable:!0},_:{value:o}})}function ko(e,t,n){this.k=e,this.x=t,this.y=n}ko.prototype={constructor:ko,scale:function(e){return e===1?this:new ko(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new ko(this.k,this.x+this.k*e,this.y+this.k*t)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var Gm=new ko(1,0,0);g3.prototype=ko.prototype;function g3(e){for(;!e.__zoom;)if(!(e=e.parentNode))return Gm;return e.__zoom}function Vy(e){e.stopImmediatePropagation()}function Su(e){e.preventDefault(),e.stopImmediatePropagation()}function Dee(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function $ee(){var e=this;return e instanceof SVGElement?(e=e.ownerSVGElement||e,e.hasAttribute("viewBox")?(e=e.viewBox.baseVal,[[e.x,e.y],[e.x+e.width,e.y+e.height]]):[[0,0],[e.width.baseVal.value,e.height.baseVal.value]]):[[0,0],[e.clientWidth,e.clientHeight]]}function hC(){return this.__zoom||Gm}function Iee(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function Mee(){return navigator.maxTouchPoints||"ontouchstart"in this}function Lee(e,t,n){var r=e.invertX(t[0][0])-n[0][0],o=e.invertX(t[1][0])-n[1][0],i=e.invertY(t[0][1])-n[0][1],a=e.invertY(t[1][1])-n[1][1];return e.translate(o>r?(r+o)/2:Math.min(0,r)||Math.max(0,o),a>i?(i+a)/2:Math.min(0,i)||Math.max(0,a))}function x3(){var e=Dee,t=$ee,n=Lee,r=Iee,o=Mee,i=[0,1/0],a=[[-1/0,-1/0],[1/0,1/0]],l=250,d=qp,f=Hm("start","zoom","end"),p,h,g,y=500,k=150,w=0,b=10;function j(A){A.property("__zoom",hC).on("wheel.zoom",$,{passive:!1}).on("mousedown.zoom",_).on("dblclick.zoom",U).filter(o).on("touchstart.zoom",I).on("touchmove.zoom",F).on("touchend.zoom touchcancel.zoom",M).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}j.transform=function(A,L,z,W){var V=A.selection?A.selection():A;V.property("__zoom",hC),A!==V?D(A,L,z,W):V.interrupt().each(function(){T(this,arguments).event(W).start().zoom(null,typeof L=="function"?L.apply(this,arguments):L).end()})},j.scaleBy=function(A,L,z,W){j.scaleTo(A,function(){var V=this.__zoom.k,K=typeof L=="function"?L.apply(this,arguments):L;return V*K},z,W)},j.scaleTo=function(A,L,z,W){j.transform(A,function(){var V=t.apply(this,arguments),K=this.__zoom,O=z==null?C(V):typeof z=="function"?z.apply(this,arguments):z,B=K.invert(O),G=typeof L=="function"?L.apply(this,arguments):L;return n(S(N(K,G),O,B),V,a)},z,W)},j.translateBy=function(A,L,z,W){j.transform(A,function(){return n(this.__zoom.translate(typeof L=="function"?L.apply(this,arguments):L,typeof z=="function"?z.apply(this,arguments):z),t.apply(this,arguments),a)},null,W)},j.translateTo=function(A,L,z,W,V){j.transform(A,function(){var K=t.apply(this,arguments),O=this.__zoom,B=W==null?C(K):typeof W=="function"?W.apply(this,arguments):W;return n(Gm.translate(B[0],B[1]).scale(O.k).translate(typeof L=="function"?-L.apply(this,arguments):-L,typeof z=="function"?-z.apply(this,arguments):-z),K,a)},W,V)};function N(A,L){return L=Math.max(i[0],Math.min(i[1],L)),L===A.k?A:new ko(L,A.x,A.y)}function S(A,L,z){var W=L[0]-z[0]*A.k,V=L[1]-z[1]*A.k;return W===A.x&&V===A.y?A:new ko(A.k,W,V)}function C(A){return[(+A[0][0]+ +A[1][0])/2,(+A[0][1]+ +A[1][1])/2]}function D(A,L,z,W){A.on("start.zoom",function(){T(this,arguments).event(W).start()}).on("interrupt.zoom end.zoom",function(){T(this,arguments).event(W).end()}).tween("zoom",function(){var V=this,K=arguments,O=T(V,K).event(W),B=t.apply(V,K),G=z==null?C(B):typeof z=="function"?z.apply(V,K):z,H=Math.max(B[1][0]-B[0][0],B[1][1]-B[0][1]),Q=V.__zoom,te=typeof L=="function"?L.apply(V,K):L,Z=d(Q.invert(G).concat(H/Q.k),te.invert(G).concat(H/te.k));return function(ae){if(ae===1)ae=te;else{var ne=Z(ae),ue=H/ne[2];ae=new ko(ue,G[0]-ne[0]*ue,G[1]-ne[1]*ue)}O.zoom(null,ae)}})}function T(A,L,z){return!z&&A.__zooming||new R(A,L)}function R(A,L){this.that=A,this.args=L,this.active=0,this.sourceEvent=null,this.extent=t.apply(A,L),this.taps=0}R.prototype={event:function(A){return A&&(this.sourceEvent=A),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(A,L){return this.mouse&&A!=="mouse"&&(this.mouse[1]=L.invert(this.mouse[0])),this.touch0&&A!=="touch"&&(this.touch0[1]=L.invert(this.touch0[0])),this.touch1&&A!=="touch"&&(this.touch1[1]=L.invert(this.touch1[0])),this.that.__zoom=L,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(A){var L=Lr(this.that).datum();f.call(A,this.that,new _ee(A,{sourceEvent:this.sourceEvent,target:j,transform:this.that.__zoom,dispatch:f}),L)}};function $(A,...L){if(!e.apply(this,arguments))return;var z=T(this,L).event(A),W=this.__zoom,V=Math.max(i[0],Math.min(i[1],W.k*Math.pow(2,r.apply(this,arguments)))),K=fs(A);if(z.wheel)(z.mouse[0][0]!==K[0]||z.mouse[0][1]!==K[1])&&(z.mouse[1]=W.invert(z.mouse[0]=K)),clearTimeout(z.wheel);else{if(W.k===V)return;z.mouse=[K,W.invert(K)],Yp(this),z.start()}Su(A),z.wheel=setTimeout(O,k),z.zoom("mouse",n(S(N(W,V),z.mouse[0],z.mouse[1]),z.extent,a));function O(){z.wheel=null,z.end()}}function _(A,...L){if(g||!e.apply(this,arguments))return;var z=A.currentTarget,W=T(this,L,!0).event(A),V=Lr(A.view).on("mousemove.zoom",G,!0).on("mouseup.zoom",H,!0),K=fs(A,z),O=A.clientX,B=A.clientY;Z_(A.view),Vy(A),W.mouse=[K,this.__zoom.invert(K)],Yp(this),W.start();function G(Q){if(Su(Q),!W.moved){var te=Q.clientX-O,Z=Q.clientY-B;W.moved=te*te+Z*Z>w}W.event(Q).zoom("mouse",n(S(W.that.__zoom,W.mouse[0]=fs(Q,z),W.mouse[1]),W.extent,a))}function H(Q){V.on("mousemove.zoom mouseup.zoom",null),e3(Q.view,W.moved),Su(Q),W.event(Q).end()}}function U(A,...L){if(e.apply(this,arguments)){var z=this.__zoom,W=fs(A.changedTouches?A.changedTouches[0]:A,this),V=z.invert(W),K=z.k*(A.shiftKey?.5:2),O=n(S(N(z,K),W,V),t.apply(this,L),a);Su(A),l>0?Lr(this).transition().duration(l).call(D,O,W,A):Lr(this).call(j.transform,O,W,A)}}function I(A,...L){if(e.apply(this,arguments)){var z=A.touches,W=z.length,V=T(this,L,A.changedTouches.length===W).event(A),K,O,B,G;for(Vy(A),O=0;O<W;++O)B=z[O],G=fs(B,this),G=[G,this.__zoom.invert(G),B.identifier],V.touch0?!V.touch1&&V.touch0[2]!==G[2]&&(V.touch1=G,V.taps=0):(V.touch0=G,K=!0,V.taps=1+!!p);p&&(p=clearTimeout(p)),K&&(V.taps<2&&(h=G[0],p=setTimeout(function(){p=null},y)),Yp(this),V.start())}}function F(A,...L){if(this.__zooming){var z=T(this,L).event(A),W=A.changedTouches,V=W.length,K,O,B,G;for(Su(A),K=0;K<V;++K)O=W[K],B=fs(O,this),z.touch0&&z.touch0[2]===O.identifier?z.touch0[0]=B:z.touch1&&z.touch1[2]===O.identifier&&(z.touch1[0]=B);if(O=z.that.__zoom,z.touch1){var H=z.touch0[0],Q=z.touch0[1],te=z.touch1[0],Z=z.touch1[1],ae=(ae=te[0]-H[0])*ae+(ae=te[1]-H[1])*ae,ne=(ne=Z[0]-Q[0])*ne+(ne=Z[1]-Q[1])*ne;O=N(O,Math.sqrt(ae/ne)),B=[(H[0]+te[0])/2,(H[1]+te[1])/2],G=[(Q[0]+Z[0])/2,(Q[1]+Z[1])/2]}else if(z.touch0)B=z.touch0[0],G=z.touch0[1];else return;z.zoom("touch",n(S(O,B,G),z.extent,a))}}function M(A,...L){if(this.__zooming){var z=T(this,L).event(A),W=A.changedTouches,V=W.length,K,O;for(Vy(A),g&&clearTimeout(g),g=setTimeout(function(){g=null},y),K=0;K<V;++K)O=W[K],z.touch0&&z.touch0[2]===O.identifier?delete z.touch0:z.touch1&&z.touch1[2]===O.identifier&&delete z.touch1;if(z.touch1&&!z.touch0&&(z.touch0=z.touch1,delete z.touch1),z.touch0)z.touch0[1]=this.__zoom.invert(z.touch0[0]);else if(z.end(),z.taps===2&&(O=fs(O,this),Math.hypot(h[0]-O[0],h[1]-O[1])<b)){var B=Lr(this).on("dblclick.zoom");B&&B.apply(this,arguments)}}}return j.wheelDelta=function(A){return arguments.length?(r=typeof A=="function"?A:vp(+A),j):r},j.filter=function(A){return arguments.length?(e=typeof A=="function"?A:vp(!!A),j):e},j.touchable=function(A){return arguments.length?(o=typeof A=="function"?A:vp(!!A),j):o},j.extent=function(A){return arguments.length?(t=typeof A=="function"?A:vp([[+A[0][0],+A[0][1]],[+A[1][0],+A[1][1]]]),j):t},j.scaleExtent=function(A){return arguments.length?(i[0]=+A[0],i[1]=+A[1],j):[i[0],i[1]]},j.translateExtent=function(A){return arguments.length?(a[0][0]=+A[0][0],a[1][0]=+A[1][0],a[0][1]=+A[0][1],a[1][1]=+A[1][1],j):[[a[0][0],a[0][1]],[a[1][0],a[1][1]]]},j.constrain=function(A){return arguments.length?(n=A,j):n},j.duration=function(A){return arguments.length?(l=+A,j):l},j.interpolate=function(A){return arguments.length?(d=A,j):d},j.on=function(){var A=f.on.apply(f,arguments);return A===f?j:A},j.clickDistance=function(A){return arguments.length?(w=(A=+A)*A,j):Math.sqrt(w)},j.tapDistance=function(A){return arguments.length?(b=+A,j):b},j}const ks={error001:(e="react")=>`Seems like you have not used zustand provider as an ancestor. Help: https://${e}flow.dev/error#001`,error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:e=>`Node type "${e}" not found. Using fallback type "default".`,error004:()=>"The parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:e=>`The old edge with id=${e} does not exist.`,error009:e=>`Marker type "${e}" doesn't exist.`,error008:(e,{id:t,sourceHandle:n,targetHandle:r})=>`Couldn't create edge for ${e} handle id: "${e==="source"?n:r}", edge id: ${t}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:e=>`Edge type "${e}" not found. Using fallback type "default".`,error012:e=>`Node with id "${e}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(e="react")=>`It seems that you haven't loaded the styles. Please import '@xyflow/${e}/dist/style.css' or base.css to make sure everything is working properly.`,error014:()=>"useNodeConnections: No node ID found. Call useNodeConnections inside a custom Node or provide a node ID.",error015:()=>"It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs.",error016:e=>`Edge with id "${e}" does not exist, it may have been removed. This can happen when an edge is deleted before the "onEdgeClick" handler is called.`},hd=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],y3=["Enter"," ","Escape"],b3={"node.a11yDescription.default":"Press enter or space to select a node. Press delete to remove it and escape to cancel.","node.a11yDescription.keyboardDisabled":"Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.","node.a11yDescription.ariaLiveMessage":({direction:e,x:t,y:n})=>`Moved selected node ${e}. New position, x: ${t}, y: ${n}`,"edge.a11yDescription.default":"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.","controls.ariaLabel":"Control Panel","controls.zoomIn.ariaLabel":"Zoom In","controls.zoomOut.ariaLabel":"Zoom Out","controls.fitView.ariaLabel":"Fit View","controls.interactive.ariaLabel":"Toggle Interactivity","minimap.ariaLabel":"Mini Map","handle.ariaLabel":"Handle"};var tc;(function(e){e.Strict="strict",e.Loose="loose"})(tc||(tc={}));var ma;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(ma||(ma={}));var md;(function(e){e.Partial="partial",e.Full="full"})(md||(md={}));const v3={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var mi;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(mi||(mi={}));var gd;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(gd||(gd={}));var ct;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(ct||(ct={}));const mC={[ct.Left]:ct.Right,[ct.Right]:ct.Left,[ct.Top]:ct.Bottom,[ct.Bottom]:ct.Top};function w3(e){return e===null?null:e?"valid":"invalid"}const j3=e=>"id"in e&&"source"in e&&"target"in e,Oee=e=>"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),v0=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),qd=(e,t=[0,0])=>{const{width:n,height:r}=Po(e),o=e.origin??t,i=n*o[0],a=r*o[1];return{x:e.position.x-i,y:e.position.y-a}},Fee=(e,t={nodeOrigin:[0,0]})=>{if(e.length===0)return{x:0,y:0,width:0,height:0};const n=e.reduce((r,o)=>{const i=typeof o=="string";let a=!t.nodeLookup&&!i?o:void 0;t.nodeLookup&&(a=i?t.nodeLookup.get(o):v0(o)?o:t.nodeLookup.get(o.id));const l=a?Ih(a,t.nodeOrigin):{x:0,y:0,x2:0,y2:0};return Ym(r,l)},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return Xm(n)},Kd=(e,t={})=>{let n={x:1/0,y:1/0,x2:-1/0,y2:-1/0},r=!1;return e.forEach(o=>{(t.filter===void 0||t.filter(o))&&(n=Ym(n,Ih(o)),r=!0)}),r?Xm(n):{x:0,y:0,width:0,height:0}},w0=(e,t,[n,r,o]=[0,0,1],i=!1,a=!1)=>{const l={...Tc(t,[n,r,o]),width:t.width/o,height:t.height/o},d=[];for(const f of e.values()){const{measured:p,selectable:h=!0,hidden:g=!1}=f;if(a&&!h||g)continue;const y=p.width??f.width??f.initialWidth??null,k=p.height??f.height??f.initialHeight??null,w=xd(l,rc(f)),b=(y??0)*(k??0),j=i&&w>0;(!f.internals.handleBounds||j||w>=b||f.dragging)&&d.push(f)}return d},zee=(e,t)=>{const n=new Set;return e.forEach(r=>{n.add(r.id)}),t.filter(r=>n.has(r.source)||n.has(r.target))};function Bee(e,t){const n=new Map,r=t!=null&&t.nodes?new Set(t.nodes.map(o=>o.id)):null;return e.forEach(o=>{o.measured.width&&o.measured.height&&((t==null?void 0:t.includeHiddenNodes)||!o.hidden)&&(!r||r.has(o.id))&&n.set(o.id,o)}),n}async function Uee({nodes:e,width:t,height:n,panZoom:r,minZoom:o,maxZoom:i},a){if(e.size===0)return!0;const l=Bee(e,a),d=Kd(l),f=k0(d,t,n,(a==null?void 0:a.minZoom)??o,(a==null?void 0:a.maxZoom)??i,(a==null?void 0:a.padding)??.1);return await r.setViewport(f,{duration:a==null?void 0:a.duration,ease:a==null?void 0:a.ease,interpolate:a==null?void 0:a.interpolate}),!0}function k3({nodeId:e,nextPosition:t,nodeLookup:n,nodeOrigin:r=[0,0],nodeExtent:o,onError:i}){const a=n.get(e),l=a.parentId?n.get(a.parentId):void 0,{x:d,y:f}=l?l.internals.positionAbsolute:{x:0,y:0},p=a.origin??r;let h=a.extent||o;if(a.extent==="parent"&&!a.expandParent)if(!l)i==null||i("005",ks.error005());else{const y=l.measured.width,k=l.measured.height;y&&k&&(h=[[d,f],[d+y,f+k]])}else l&&ja(a.extent)&&(h=[[a.extent[0][0]+d,a.extent[0][1]+f],[a.extent[1][0]+d,a.extent[1][1]+f]]);const g=ja(h)?wa(t,h,a.measured):t;return(a.measured.width===void 0||a.measured.height===void 0)&&(i==null||i("015",ks.error015())),{position:{x:g.x-d+(a.measured.width??0)*p[0],y:g.y-f+(a.measured.height??0)*p[1]},positionAbsolute:g}}async function Hee({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:r,onBeforeDelete:o}){const i=new Set(e.map(g=>g.id)),a=[];for(const g of n){if(g.deletable===!1)continue;const y=i.has(g.id),k=!y&&g.parentId&&a.find(w=>w.id===g.parentId);(y||k)&&a.push(g)}const l=new Set(t.map(g=>g.id)),d=r.filter(g=>g.deletable!==!1),p=zee(a,d);for(const g of d)l.has(g.id)&&!p.find(k=>k.id===g.id)&&p.push(g);if(!o)return{edges:p,nodes:a};const h=await o({nodes:a,edges:p});return typeof h=="boolean"?h?{edges:p,nodes:a}:{edges:[],nodes:[]}:h}const nc=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),wa=(e={x:0,y:0},t,n)=>({x:nc(e.x,t[0][0],t[1][0]-((n==null?void 0:n.width)??0)),y:nc(e.y,t[0][1],t[1][1]-((n==null?void 0:n.height)??0))});function S3(e,t,n){const{width:r,height:o}=Po(n),{x:i,y:a}=n.internals.positionAbsolute;return wa(e,[[i,a],[i+r,a+o]],t)}const gC=(e,t,n)=>e<t?nc(Math.abs(e-t),1,t)/t:e>n?-nc(Math.abs(e-n),1,t)/t:0,j0=(e,t,n=15,r=40)=>{const o=gC(e.x,r,t.width-r)*n,i=gC(e.y,r,t.height-r)*n;return[o,i]},Ym=(e,t)=>({x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x2,t.x2),y2:Math.max(e.y2,t.y2)}),mv=({x:e,y:t,width:n,height:r})=>({x:e,y:t,x2:e+n,y2:t+r}),Xm=({x:e,y:t,x2:n,y2:r})=>({x:e,y:t,width:n-e,height:r-t}),rc=(e,t=[0,0])=>{var o,i;const{x:n,y:r}=v0(e)?e.internals.positionAbsolute:qd(e,t);return{x:n,y:r,width:((o=e.measured)==null?void 0:o.width)??e.width??e.initialWidth??0,height:((i=e.measured)==null?void 0:i.height)??e.height??e.initialHeight??0}},Ih=(e,t=[0,0])=>{var o,i;const{x:n,y:r}=v0(e)?e.internals.positionAbsolute:qd(e,t);return{x:n,y:r,x2:n+(((o=e.measured)==null?void 0:o.width)??e.width??e.initialWidth??0),y2:r+(((i=e.measured)==null?void 0:i.height)??e.height??e.initialHeight??0)}},N3=(e,t)=>Xm(Ym(mv(e),mv(t))),xd=(e,t)=>{const n=Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x)),r=Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y));return Math.ceil(n*r)},xC=e=>hs(e.width)&&hs(e.height)&&hs(e.x)&&hs(e.y),hs=e=>!isNaN(e)&&isFinite(e),C3=(e,t)=>(n,r)=>{},Gd=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),Tc=({x:e,y:t},[n,r,o],i=!1,a=[1,1])=>{const l={x:(e-n)/o,y:(t-r)/o};return i?Gd(l,a):l},sc=({x:e,y:t},[n,r,o])=>({x:e*o+n,y:t*o+r});function wl(e,t){if(typeof e=="number")return Math.floor((t-t/(1+e))*.5);if(typeof e=="string"&&e.endsWith("px")){const n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(n)}if(typeof e=="string"&&e.endsWith("%")){const n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(t*n*.01)}return console.error(`The padding value "${e}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function Vee(e,t,n){if(typeof e=="string"||typeof e=="number"){const r=wl(e,n),o=wl(e,t);return{top:r,right:o,bottom:r,left:o,x:o*2,y:r*2}}if(typeof e=="object"){const r=wl(e.top??e.y??0,n),o=wl(e.bottom??e.y??0,n),i=wl(e.left??e.x??0,t),a=wl(e.right??e.x??0,t);return{top:r,right:a,bottom:o,left:i,x:i+a,y:r+o}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function Wee(e,t,n,r,o,i){const{x:a,y:l}=sc(e,[t,n,r]),{x:d,y:f}=sc({x:e.x+e.width,y:e.y+e.height},[t,n,r]),p=o-d,h=i-f;return{left:Math.floor(a),top:Math.floor(l),right:Math.floor(p),bottom:Math.floor(h)}}const k0=(e,t,n,r,o,i)=>{const a=Vee(i,t,n),l=(t-a.x)/e.width,d=(n-a.y)/e.height,f=Math.min(l,d),p=nc(f,r,o),h=e.x+e.width/2,g=e.y+e.height/2,y=t/2-h*p,k=n/2-g*p,w=Wee(e,y,k,p,t,n),b={left:Math.min(w.left-a.left,0),top:Math.min(w.top-a.top,0),right:Math.min(w.right-a.right,0),bottom:Math.min(w.bottom-a.bottom,0)};return{x:y-b.left+b.right,y:k-b.top+b.bottom,zoom:p}},yd=()=>{var e;return typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)==null?void 0:e.indexOf("Mac"))>=0};function ja(e){return e!=null&&e!=="parent"}function Po(e){var t,n;return{width:((t=e.measured)==null?void 0:t.width)??e.width??e.initialWidth??0,height:((n=e.measured)==null?void 0:n.height)??e.height??e.initialHeight??0}}function E3(e){var t,n;return(((t=e.measured)==null?void 0:t.width)??e.width??e.initialWidth)!==void 0&&(((n=e.measured)==null?void 0:n.height)??e.height??e.initialHeight)!==void 0}function T3(e,t={width:0,height:0},n,r,o){const i={...e},a=r.get(n);if(a){const l=a.origin||o;i.x+=a.internals.positionAbsolute.x-(t.width??0)*l[0],i.y+=a.internals.positionAbsolute.y-(t.height??0)*l[1]}return i}function yC(e,t){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function qee(){let e,t;return{promise:new Promise((r,o)=>{e=r,t=o}),resolve:e,reject:t}}function Kee(e){return{...b3,...e||{}}}function Ku(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:r,containerBounds:o}){const{x:i,y:a}=ms(e),l=Tc({x:i-((o==null?void 0:o.left)??0),y:a-((o==null?void 0:o.top)??0)},r),{x:d,y:f}=n?Gd(l,t):l;return{xSnapped:d,ySnapped:f,...l}}const S0=e=>({width:e.offsetWidth,height:e.offsetHeight}),R3=e=>{var t;return((t=e==null?void 0:e.getRootNode)==null?void 0:t.call(e))||(window==null?void 0:window.document)},Gee=["INPUT","SELECT","TEXTAREA"];function A3(e){var r,o;const t=((o=(r=e.composedPath)==null?void 0:r.call(e))==null?void 0:o[0])||e.target;return(t==null?void 0:t.nodeType)!==1?!1:Gee.includes(t.nodeName)||t.hasAttribute("contenteditable")||!!t.closest(".nokey")}const P3=e=>"clientX"in e,ms=(e,t)=>{var i,a;const n=P3(e),r=n?e.clientX:(i=e.touches)==null?void 0:i[0].clientX,o=n?e.clientY:(a=e.touches)==null?void 0:a[0].clientY;return{x:r-((t==null?void 0:t.left)??0),y:o-((t==null?void 0:t.top)??0)}},bC=(e,t,n,r,o)=>{const i=t.querySelectorAll(`.${e}`);return!i||!i.length?null:Array.from(i).map(a=>{const l=a.getBoundingClientRect();return{id:a.getAttribute("data-handleid"),type:e,nodeId:o,position:a.getAttribute("data-handlepos"),x:(l.left-n.left)/r,y:(l.top-n.top)/r,...S0(a)}})};function _3({sourceX:e,sourceY:t,targetX:n,targetY:r,sourceControlX:o,sourceControlY:i,targetControlX:a,targetControlY:l}){const d=e*.125+o*.375+a*.375+n*.125,f=t*.125+i*.375+l*.375+r*.125,p=Math.abs(d-e),h=Math.abs(f-t);return[d,f,p,h]}function wp(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function vC({pos:e,x1:t,y1:n,x2:r,y2:o,c:i}){switch(e){case ct.Left:return[t-wp(t-r,i),n];case ct.Right:return[t+wp(r-t,i),n];case ct.Top:return[t,n-wp(n-o,i)];case ct.Bottom:return[t,n+wp(o-n,i)]}}function D3({sourceX:e,sourceY:t,sourcePosition:n=ct.Bottom,targetX:r,targetY:o,targetPosition:i=ct.Top,curvature:a=.25}){const[l,d]=vC({pos:n,x1:e,y1:t,x2:r,y2:o,c:a}),[f,p]=vC({pos:i,x1:r,y1:o,x2:e,y2:t,c:a}),[h,g,y,k]=_3({sourceX:e,sourceY:t,targetX:r,targetY:o,sourceControlX:l,sourceControlY:d,targetControlX:f,targetControlY:p});return[`M${e},${t} C${l},${d} ${f},${p} ${r},${o}`,h,g,y,k]}function $3({sourceX:e,sourceY:t,targetX:n,targetY:r}){const o=Math.abs(n-e)/2,i=n<e?n+o:n-o,a=Math.abs(r-t)/2,l=r<t?r+a:r-a;return[i,l,o,a]}function Yee({sourceNode:e,targetNode:t,selected:n=!1,zIndex:r=0,elevateOnSelect:o=!1,zIndexMode:i="basic"}){if(i==="manual")return r;const a=o&&n?r+1e3:r,l=Math.max(e.parentId||o&&e.selected?e.internals.z:0,t.parentId||o&&t.selected?t.internals.z:0);return a+l}function Xee({sourceNode:e,targetNode:t,width:n,height:r,transform:o}){const i=Ym(Ih(e),Ih(t));i.x===i.x2&&(i.x2+=1),i.y===i.y2&&(i.y2+=1);const a={x:-o[0]/o[2],y:-o[1]/o[2],width:n/o[2],height:r/o[2]};return xd(a,Xm(i))>0}const Qee=({source:e,sourceHandle:t,target:n,targetHandle:r})=>`xy-edge__${e}${t||""}-${n}${r||""}`,Jee=(e,t)=>t.some(n=>n.source===e.source&&n.target===e.target&&(n.sourceHandle===e.sourceHandle||!n.sourceHandle&&!e.sourceHandle)&&(n.targetHandle===e.targetHandle||!n.targetHandle&&!e.targetHandle)),Zee=(e,t,n={})=>{var i;if(!e.source||!e.target)return(i=n.onError)==null||i.call(n,"006",ks.error006()),t;const r=n.getEdgeId||Qee;let o;return j3(e)?o={...e}:o={...e,id:r(e)},Jee(o,t)?t:(o.sourceHandle===null&&delete o.sourceHandle,o.targetHandle===null&&delete o.targetHandle,t.concat(o))};function I3({sourceX:e,sourceY:t,targetX:n,targetY:r}){const[o,i,a,l]=$3({sourceX:e,sourceY:t,targetX:n,targetY:r});return[`M ${e},${t}L ${n},${r}`,o,i,a,l]}const wC={[ct.Left]:{x:-1,y:0},[ct.Right]:{x:1,y:0},[ct.Top]:{x:0,y:-1},[ct.Bottom]:{x:0,y:1}},ete=({source:e,sourcePosition:t=ct.Bottom,target:n})=>t===ct.Left||t===ct.Right?e.x<n.x?{x:1,y:0}:{x:-1,y:0}:e.y<n.y?{x:0,y:1}:{x:0,y:-1},jC=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function tte({source:e,sourcePosition:t=ct.Bottom,target:n,targetPosition:r=ct.Top,center:o,offset:i,stepPosition:a}){const l=wC[t],d=wC[r],f={x:e.x+l.x*i,y:e.y+l.y*i},p={x:n.x+d.x*i,y:n.y+d.y*i},h=ete({source:f,sourcePosition:t,target:p}),g=h.x!==0?"x":"y",y=h[g];let k=[],w,b;const j={x:0,y:0},N={x:0,y:0},[,,S,C]=$3({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(l[g]*d[g]===-1){g==="x"?(w=o.x??f.x+(p.x-f.x)*a,b=o.y??(f.y+p.y)/2):(w=o.x??(f.x+p.x)/2,b=o.y??f.y+(p.y-f.y)*a);const $=[{x:w,y:f.y},{x:w,y:p.y}],_=[{x:f.x,y:b},{x:p.x,y:b}];l[g]===y?k=g==="x"?$:_:k=g==="x"?_:$}else{const $=[{x:f.x,y:p.y}],_=[{x:p.x,y:f.y}];if(g==="x"?k=l.x===y?_:$:k=l.y===y?$:_,t===r){const A=Math.abs(e[g]-n[g]);if(A<=i){const L=Math.min(i-1,i-A);l[g]===y?j[g]=(f[g]>e[g]?-1:1)*L:N[g]=(p[g]>n[g]?-1:1)*L}}if(t!==r){const A=g==="x"?"y":"x",L=l[g]===d[A],z=f[A]>p[A],W=f[A]<p[A];(l[g]===1&&(!L&&z||L&&W)||l[g]!==1&&(!L&&W||L&&z))&&(k=g==="x"?$:_)}const U={x:f.x+j.x,y:f.y+j.y},I={x:p.x+N.x,y:p.y+N.y},F=Math.max(Math.abs(U.x-k[0].x),Math.abs(I.x-k[0].x)),M=Math.max(Math.abs(U.y-k[0].y),Math.abs(I.y-k[0].y));F>=M?(w=(U.x+I.x)/2,b=k[0].y):(w=k[0].x,b=(U.y+I.y)/2)}const D={x:f.x+j.x,y:f.y+j.y},T={x:p.x+N.x,y:p.y+N.y};return[[e,...D.x!==k[0].x||D.y!==k[0].y?[D]:[],...k,...T.x!==k[k.length-1].x||T.y!==k[k.length-1].y?[T]:[],n],w,b,S,C]}function nte(e,t,n,r){const o=Math.min(jC(e,t)/2,jC(t,n)/2,r),{x:i,y:a}=t;if(e.x===i&&i===n.x||e.y===a&&a===n.y)return`L${i} ${a}`;if(e.y===a){const f=e.x<n.x?-1:1,p=e.y<n.y?1:-1;return`L ${i+o*f},${a}Q ${i},${a} ${i},${a+o*p}`}const l=e.x<n.x?1:-1,d=e.y<n.y?-1:1;return`L ${i},${a+o*d}Q ${i},${a} ${i+o*l},${a}`}function gv({sourceX:e,sourceY:t,sourcePosition:n=ct.Bottom,targetX:r,targetY:o,targetPosition:i=ct.Top,borderRadius:a=5,centerX:l,centerY:d,offset:f=20,stepPosition:p=.5}){const[h,g,y,k,w]=tte({source:{x:e,y:t},sourcePosition:n,target:{x:r,y:o},targetPosition:i,center:{x:l,y:d},offset:f,stepPosition:p});let b=`M${h[0].x} ${h[0].y}`;for(let j=1;j<h.length-1;j++)b+=nte(h[j-1],h[j],h[j+1],a);return b+=`L${h[h.length-1].x} ${h[h.length-1].y}`,[b,g,y,k,w]}function kC(e){var t;return e&&!!(e.internals.handleBounds||(t=e.handles)!=null&&t.length)&&!!(e.measured.width||e.width||e.initialWidth)}function rte(e){var h;const{sourceNode:t,targetNode:n}=e;if(!kC(t)||!kC(n))return null;const r=t.internals.handleBounds||SC(t.handles),o=n.internals.handleBounds||SC(n.handles),i=NC((r==null?void 0:r.source)??[],e.sourceHandle),a=NC(e.connectionMode===tc.Strict?(o==null?void 0:o.target)??[]:((o==null?void 0:o.target)??[]).concat((o==null?void 0:o.source)??[]),e.targetHandle);if(!i||!a)return(h=e.onError)==null||h.call(e,"008",ks.error008(i?"target":"source",{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;const l=(i==null?void 0:i.position)||ct.Bottom,d=(a==null?void 0:a.position)||ct.Top,f=ka(t,i,l),p=ka(n,a,d);return{sourceX:f.x,sourceY:f.y,targetX:p.x,targetY:p.y,sourcePosition:l,targetPosition:d}}function SC(e){if(!e)return null;const t=[],n=[];for(const r of e)r.width=r.width??1,r.height=r.height??1,r.type==="source"?t.push(r):r.type==="target"&&n.push(r);return{source:t,target:n}}function ka(e,t,n=ct.Left,r=!1){const o=((t==null?void 0:t.x)??0)+e.internals.positionAbsolute.x,i=((t==null?void 0:t.y)??0)+e.internals.positionAbsolute.y,{width:a,height:l}=t??Po(e);if(r)return{x:o+a/2,y:i+l/2};switch((t==null?void 0:t.position)??n){case ct.Top:return{x:o+a/2,y:i};case ct.Right:return{x:o+a,y:i+l/2};case ct.Bottom:return{x:o+a/2,y:i+l};case ct.Left:return{x:o,y:i+l/2}}}function NC(e,t){return e&&(t?e.find(n=>n.id===t):e[0])||null}function xv(e,t){return e?typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(r=>`${r}=${e[r]}`).join("&")}`:""}function ste(e,{id:t,defaultColor:n,defaultMarkerStart:r,defaultMarkerEnd:o}){const i=new Set;return e.reduce((a,l)=>([l.markerStart||r,l.markerEnd||o].forEach(d=>{if(d&&typeof d=="object"){const f=xv(d,t);i.has(f)||(a.push({id:f,color:d.color||n,...d}),i.add(f))}}),a),[]).sort((a,l)=>a.id.localeCompare(l.id))}const M3=1e3,ote=10,N0={nodeOrigin:[0,0],nodeExtent:hd,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},ite={...N0,checkEquality:!0};function C0(e,t){const n={...e};for(const r in t)t[r]!==void 0&&(n[r]=t[r]);return n}function ate(e,t,n){const r=C0(N0,n);for(const o of e.values())if(o.parentId)T0(o,e,t,r);else{const i=qd(o,r.nodeOrigin),a=ja(o.extent)?o.extent:r.nodeExtent,l=wa(i,a,Po(o));o.internals.positionAbsolute=l}}function lte(e,t){if(!e.handles)return e.measured?t==null?void 0:t.internals.handleBounds:void 0;const n=[],r=[];for(const o of e.handles){const i={id:o.id,width:o.width??1,height:o.height??1,nodeId:e.id,x:o.x,y:o.y,position:o.position,type:o.type};o.type==="source"?n.push(i):o.type==="target"&&r.push(i)}return{source:n,target:r}}function E0(e){return e==="manual"}function yv(e,t,n,r={}){var p,h;const o=C0(ite,r),i={i:0},a=new Map(t),l=o!=null&&o.elevateNodesOnSelect&&!E0(o.zIndexMode)?M3:0;let d=e.length>0,f=!1;t.clear(),n.clear();for(const g of e){let y=a.get(g.id);if(o.checkEquality&&g===(y==null?void 0:y.internals.userNode))t.set(g.id,y);else{const k=qd(g,o.nodeOrigin),w=ja(g.extent)?g.extent:o.nodeExtent,b=wa(k,w,Po(g));y={...o.defaults,...g,measured:{width:(p=g.measured)==null?void 0:p.width,height:(h=g.measured)==null?void 0:h.height},internals:{positionAbsolute:b,handleBounds:lte(g,y),z:L3(g,l,o.zIndexMode),userNode:g}},t.set(g.id,y)}(y.measured===void 0||y.measured.width===void 0||y.measured.height===void 0)&&!y.hidden&&(d=!1),g.parentId&&T0(y,t,n,r,i),f||(f=g.selected??!1)}return{nodesInitialized:d,hasSelectedNodes:f}}function cte(e,t){if(!e.parentId)return;const n=t.get(e.parentId);n?n.set(e.id,e):t.set(e.parentId,new Map([[e.id,e]]))}function T0(e,t,n,r,o){const{elevateNodesOnSelect:i,nodeOrigin:a,nodeExtent:l,zIndexMode:d}=C0(N0,r),f=e.parentId,p=t.get(f);if(!p){console.warn(`Parent node ${f} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}cte(e,n),o&&!p.parentId&&p.internals.rootParentIndex===void 0&&d==="auto"&&(p.internals.rootParentIndex=++o.i,p.internals.z=p.internals.z+o.i*ote),o&&p.internals.rootParentIndex!==void 0&&(o.i=p.internals.rootParentIndex);const h=i&&!E0(d)?M3:0,{x:g,y,z:k}=ute(e,p,a,l,h,d),{positionAbsolute:w}=e.internals,b=g!==w.x||y!==w.y;(b||k!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:b?{x:g,y}:w,z:k}})}function L3(e,t,n){const r=hs(e.zIndex)?e.zIndex:0;return E0(n)?r:r+(e.selected?t:0)}function ute(e,t,n,r,o,i){const{x:a,y:l}=t.internals.positionAbsolute,d=Po(e),f=qd(e,n),p=ja(e.extent)?wa(f,e.extent,d):f;let h=wa({x:a+p.x,y:l+p.y},r,d);e.extent==="parent"&&(h=S3(h,d,t));const g=L3(e,o,i),y=t.internals.z??0;return{x:h.x,y:h.y,z:y>=g?y+1:g}}function R0(e,t,n,r=[0,0]){var a;const o=[],i=new Map;for(const l of e){const d=t.get(l.parentId);if(!d)continue;const f=((a=i.get(l.parentId))==null?void 0:a.expandedRect)??rc(d),p=N3(f,l.rect);i.set(l.parentId,{expandedRect:p,parent:d})}return i.size>0&&i.forEach(({expandedRect:l,parent:d},f)=>{var S;const p=d.internals.positionAbsolute,h=Po(d),g=d.origin??r,y=l.x<p.x?Math.round(Math.abs(p.x-l.x)):0,k=l.y<p.y?Math.round(Math.abs(p.y-l.y)):0,w=Math.max(h.width,Math.round(l.width)),b=Math.max(h.height,Math.round(l.height)),j=(w-h.width)*g[0],N=(b-h.height)*g[1];(y>0||k>0||j||N)&&(o.push({id:f,type:"position",position:{x:d.position.x-y+j,y:d.position.y-k+N}}),(S=n.get(f))==null||S.forEach(C=>{e.some(D=>D.id===C.id)||o.push({id:C.id,type:"position",position:{x:C.position.x+y,y:C.position.y+k}})})),(h.width<l.width||h.height<l.height||y||k)&&o.push({id:f,type:"dimensions",setAttributes:!0,dimensions:{width:w+(y?g[0]*y-j:0),height:b+(k?g[1]*k-N:0)}})}),o}function dte(e,t,n,r,o,i,a){const l=r==null?void 0:r.querySelector(".xyflow__viewport");let d=!1;if(!l)return{changes:[],updatedInternals:d};const f=[],p=window.getComputedStyle(l),{m22:h}=new window.DOMMatrixReadOnly(p.transform),g=[];for(const y of e.values()){const k=t.get(y.id);if(!k)continue;if(k.hidden){t.set(k.id,{...k,internals:{...k.internals,handleBounds:void 0}}),d=!0;continue}const w=S0(y.nodeElement),b=k.measured.width!==w.width||k.measured.height!==w.height;if(!!(w.width&&w.height&&(b||!k.internals.handleBounds||y.force))){const N=y.nodeElement.getBoundingClientRect(),S=ja(k.extent)?k.extent:i;let{positionAbsolute:C}=k.internals;k.parentId&&k.extent==="parent"?C=S3(C,w,t.get(k.parentId)):S&&(C=wa(C,S,w));const D={...k,measured:w,internals:{...k.internals,positionAbsolute:C,handleBounds:{source:bC("source",y.nodeElement,N,h,k.id),target:bC("target",y.nodeElement,N,h,k.id)}}};t.set(k.id,D),k.parentId&&T0(D,t,n,{nodeOrigin:o,zIndexMode:a}),d=!0,b&&(f.push({id:k.id,type:"dimensions",dimensions:w}),k.expandParent&&k.parentId&&g.push({id:k.id,parentId:k.parentId,rect:rc(D,o)}))}}if(g.length>0){const y=R0(g,t,n,o);f.push(...y)}return{changes:f,updatedInternals:d}}async function fte({delta:e,panZoom:t,transform:n,translateExtent:r,width:o,height:i}){if(!t||!e.x&&!e.y)return!1;const a=await t.setViewportConstrained({x:n[0]+e.x,y:n[1]+e.y,zoom:n[2]},[[0,0],[o,i]],r);return!!a&&(a.x!==n[0]||a.y!==n[1]||a.k!==n[2])}function CC(e,t,n,r,o,i){let a=o;const l=r.get(a)||new Map;r.set(a,l.set(n,t)),a=`${o}-${e}`;const d=r.get(a)||new Map;if(r.set(a,d.set(n,t)),i){a=`${o}-${e}-${i}`;const f=r.get(a)||new Map;r.set(a,f.set(n,t))}}function O3(e,t,n){e.clear(),t.clear();for(const r of n){const{source:o,target:i,sourceHandle:a=null,targetHandle:l=null}=r,d={edgeId:r.id,source:o,target:i,sourceHandle:a,targetHandle:l},f=`${o}-${a}--${i}-${l}`,p=`${i}-${l}--${o}-${a}`;CC("source",d,p,e,o,a),CC("target",d,f,e,i,l),t.set(r.id,r)}}function F3(e,t){if(!e.parentId)return!1;const n=t.get(e.parentId);return n?n.selected?!0:F3(n,t):!1}function EC(e,t,n){var o;let r=e;do{if((o=r==null?void 0:r.matches)!=null&&o.call(r,t))return!0;if(r===n)return!1;r=r==null?void 0:r.parentElement}while(r);return!1}function pte(e,t,n,r){const o=new Map;for(const[i,a]of e)if((a.selected||a.id===r)&&(!a.parentId||!F3(a,e))&&(a.draggable||t&&typeof a.draggable>"u")){const l=e.get(i);l&&o.set(i,{id:i,position:l.position||{x:0,y:0},distance:{x:n.x-l.internals.positionAbsolute.x,y:n.y-l.internals.positionAbsolute.y},extent:l.extent,parentId:l.parentId,origin:l.origin,expandParent:l.expandParent,internals:{positionAbsolute:l.internals.positionAbsolute||{x:0,y:0}},measured:{width:l.measured.width??0,height:l.measured.height??0}})}return o}function Wy({nodeId:e,dragItems:t,nodeLookup:n,dragging:r=!0}){var a,l,d;const o=[];for(const[f,p]of t){const h=(a=n.get(f))==null?void 0:a.internals.userNode;h&&o.push({...h,position:p.position,dragging:r})}if(!e)return[o[0],o];const i=(l=n.get(e))==null?void 0:l.internals.userNode;return[i?{...i,position:((d=t.get(e))==null?void 0:d.position)||i.position,dragging:r}:o[0],o]}function hte({dragItems:e,snapGrid:t,x:n,y:r}){const o=e.values().next().value;if(!o)return null;const i={x:n-o.distance.x,y:r-o.distance.y},a=Gd(i,t);return{x:a.x-i.x,y:a.y-i.y}}function mte({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:r,onDragStop:o}){let i={x:null,y:null},a=0,l=new Map,d=!1,f={x:0,y:0},p=null,h=!1,g=null,y=!1,k=!1,w=null;function b({noDragClassName:N,handleSelector:S,domNode:C,isSelectable:D,nodeId:T,nodeClickDistance:R=0}){g=Lr(C);function $({x:F,y:M}){const{nodeLookup:A,nodeExtent:L,snapGrid:z,snapToGrid:W,nodeOrigin:V,onNodeDrag:K,onSelectionDrag:O,onError:B,updateNodePositions:G}=t();i={x:F,y:M};let H=!1;const Q=l.size>1,te=Q&&L?mv(Kd(l)):null,Z=Q&&W?hte({dragItems:l,snapGrid:z,x:F,y:M}):null;for(const[ae,ne]of l){if(!A.has(ae))continue;let ue={x:F-ne.distance.x,y:M-ne.distance.y};W&&(ue=Z?{x:Math.round(ue.x+Z.x),y:Math.round(ue.y+Z.y)}:Gd(ue,z));let ye=null;if(Q&&L&&!ne.extent&&te){const{positionAbsolute:Se}=ne.internals,ze=Se.x-te.x+L[0][0],oe=Se.x+ne.measured.width-te.x2+L[1][0],we=Se.y-te.y+L[0][1],ke=Se.y+ne.measured.height-te.y2+L[1][1];ye=[[ze,we],[oe,ke]]}const{position:Ne,positionAbsolute:Re}=k3({nodeId:ae,nextPosition:ue,nodeLookup:A,nodeExtent:ye||L,nodeOrigin:V,onError:B});H=H||ne.position.x!==Ne.x||ne.position.y!==Ne.y,ne.position=Ne,ne.internals.positionAbsolute=Re}if(k=k||H,!!H&&(G(l,!0),w&&(r||K||!T&&O))){const[ae,ne]=Wy({nodeId:T,dragItems:l,nodeLookup:A});r==null||r(w,l,ae,ne),K==null||K(w,ae,ne),T||O==null||O(w,ne)}}async function _(){if(!p)return;const{transform:F,panBy:M,autoPanSpeed:A,autoPanOnNodeDrag:L}=t();if(!L){d=!1,cancelAnimationFrame(a);return}const[z,W]=j0(f,p,A);(z!==0||W!==0)&&(i.x=(i.x??0)-z/F[2],i.y=(i.y??0)-W/F[2],await M({x:z,y:W})&&$(i)),a=requestAnimationFrame(_)}function U(F){var Q;const{nodeLookup:M,multiSelectionActive:A,nodesDraggable:L,transform:z,snapGrid:W,snapToGrid:V,selectNodesOnDrag:K,onNodeDragStart:O,onSelectionDragStart:B,unselectNodesAndEdges:G}=t();h=!0,(!K||!D)&&!A&&T&&((Q=M.get(T))!=null&&Q.selected||G()),D&&K&&T&&(e==null||e(T));const H=Ku(F.sourceEvent,{transform:z,snapGrid:W,snapToGrid:V,containerBounds:p});if(i=H,l=pte(M,L,H,T),l.size>0&&(n||O||!T&&B)){const[te,Z]=Wy({nodeId:T,dragItems:l,nodeLookup:M});n==null||n(F.sourceEvent,l,te,Z),O==null||O(F.sourceEvent,te,Z),T||B==null||B(F.sourceEvent,Z)}}const I=t3().clickDistance(R).on("start",F=>{const{domNode:M,nodeDragThreshold:A,transform:L,snapGrid:z,snapToGrid:W}=t();p=(M==null?void 0:M.getBoundingClientRect())||null,y=!1,k=!1,w=F.sourceEvent,A===0&&U(F),i=Ku(F.sourceEvent,{transform:L,snapGrid:z,snapToGrid:W,containerBounds:p}),f=ms(F.sourceEvent,p)}).on("drag",F=>{const{autoPanOnNodeDrag:M,transform:A,snapGrid:L,snapToGrid:z,nodeDragThreshold:W,nodeLookup:V}=t(),K=Ku(F.sourceEvent,{transform:A,snapGrid:L,snapToGrid:z,containerBounds:p});if(w=F.sourceEvent,(F.sourceEvent.type==="touchmove"&&F.sourceEvent.touches.length>1||T&&!V.has(T))&&(y=!0),!y){if(!d&&M&&h&&(d=!0,_()),!h){const O=ms(F.sourceEvent,p),B=O.x-f.x,G=O.y-f.y;Math.sqrt(B*B+G*G)>W&&U(F)}(i.x!==K.xSnapped||i.y!==K.ySnapped)&&l&&h&&(f=ms(F.sourceEvent,p),$(K))}}).on("end",F=>{if(!h||y){y&&l.size>0&&t().updateNodePositions(l,!1);return}if(d=!1,h=!1,cancelAnimationFrame(a),l.size>0){const{nodeLookup:M,updateNodePositions:A,onNodeDragStop:L,onSelectionDragStop:z}=t();if(k&&(A(l,!1),k=!1),o||L||!T&&z){const[W,V]=Wy({nodeId:T,dragItems:l,nodeLookup:M,dragging:!1});o==null||o(F.sourceEvent,l,W,V),L==null||L(F.sourceEvent,W,V),T||z==null||z(F.sourceEvent,V)}}}).filter(F=>{const M=F.target;return!F.button&&(!N||!EC(M,`.${N}`,C))&&(!S||EC(M,S,C))});g.call(I)}function j(){g==null||g.on(".drag",null)}return{update:b,destroy:j}}function gte(e,t,n){const r=[],o={x:e.x-n,y:e.y-n,width:n*2,height:n*2};for(const i of t.values())xd(o,rc(i))>0&&r.push(i);return r}const xte=250;function yte(e,t,n,r){var l,d;let o=[],i=1/0;const a=gte(e,n,t+xte);for(const f of a){const p=[...((l=f.internals.handleBounds)==null?void 0:l.source)??[],...((d=f.internals.handleBounds)==null?void 0:d.target)??[]];for(const h of p){if(r.nodeId===h.nodeId&&r.type===h.type&&r.id===h.id)continue;const{x:g,y}=ka(f,h,h.position,!0),k=Math.sqrt(Math.pow(g-e.x,2)+Math.pow(y-e.y,2));k>t||(k<i?(o=[{...h,x:g,y}],i=k):k===i&&o.push({...h,x:g,y}))}}if(!o.length)return null;if(o.length>1){const f=r.type==="source"?"target":"source";return o.find(p=>p.type===f)??o[0]}return o[0]}function z3(e,t,n,r,o,i=!1){var f,p,h;const a=r.get(e);if(!a)return null;const l=o==="strict"?(f=a.internals.handleBounds)==null?void 0:f[t]:[...((p=a.internals.handleBounds)==null?void 0:p.source)??[],...((h=a.internals.handleBounds)==null?void 0:h.target)??[]],d=(n?l==null?void 0:l.find(g=>g.id===n):l==null?void 0:l[0])??null;return d&&i?{...d,...ka(a,d,d.position,!0)}:d}function B3(e,t){return e||(t!=null&&t.classList.contains("target")?"target":t!=null&&t.classList.contains("source")?"source":null)}function bte(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}const U3=()=>!0;function vte(e,{connectionMode:t,connectionRadius:n,handleId:r,nodeId:o,edgeUpdaterType:i,isTarget:a,domNode:l,nodeLookup:d,lib:f,autoPanOnConnect:p,flowId:h,panBy:g,cancelConnection:y,onConnectStart:k,onConnect:w,onConnectEnd:b,isValidConnection:j=U3,onReconnectEnd:N,updateConnection:S,getTransform:C,getFromHandle:D,autoPanSpeed:T,dragThreshold:R=1,handleDomNode:$}){const _=R3(e.target);let U=0,I;const{x:F,y:M}=ms(e),A=B3(i,$),L=l==null?void 0:l.getBoundingClientRect();let z=!1;if(!L||!A)return;const W=z3(o,A,r,d,t);if(!W)return;let V=ms(e,L),K=!1,O=null,B=!1,G=null;function H(){if(!p||!L)return;const[Ne,Re]=j0(V,L,T);g({x:Ne,y:Re}),U=requestAnimationFrame(H)}const Q={...W,nodeId:o,type:A,position:W.position},te=d.get(o);let ae={inProgress:!0,isValid:null,from:ka(te,Q,ct.Left,!0),fromHandle:Q,fromPosition:Q.position,fromNode:te,to:V,toHandle:null,toPosition:mC[Q.position],toNode:null,pointer:V};function ne(){z=!0,S(ae),k==null||k(e,{nodeId:o,handleId:r,handleType:A})}R===0&&ne();function ue(Ne){if(!z){const{x:ke,y:$e}=ms(Ne),Ue=ke-F,nt=$e-M;if(!(Ue*Ue+nt*nt>R*R))return;ne()}if(!D()||!Q){ye(Ne);return}const Re=C();V=ms(Ne,L),I=yte(Tc(V,Re,!1,[1,1]),n,d,Q),K||(H(),K=!0);const Se=H3(Ne,{handle:I,connectionMode:t,fromNodeId:o,fromHandleId:r,fromType:a?"target":"source",isValidConnection:j,doc:_,lib:f,flowId:h,nodeLookup:d});G=Se.handleDomNode,O=Se.connection,B=bte(!!I,Se.isValid);const ze=d.get(o),oe=ze?ka(ze,Q,ct.Left,!0):ae.from,we={...ae,from:oe,isValid:B,to:Se.toHandle&&B?sc({x:Se.toHandle.x,y:Se.toHandle.y},Re):V,toHandle:Se.toHandle,toPosition:B&&Se.toHandle?Se.toHandle.position:mC[Q.position],toNode:Se.toHandle?d.get(Se.toHandle.nodeId):null,pointer:V};S(we),ae=we}function ye(Ne){if(!("touches"in Ne&&Ne.touches.length>0)){if(z){(I||G)&&O&&B&&(w==null||w(O));const{inProgress:Re,...Se}=ae,ze={...Se,toPosition:ae.toHandle?ae.toPosition:null};b==null||b(Ne,ze),i&&(N==null||N(Ne,ze))}y(),cancelAnimationFrame(U),K=!1,B=!1,O=null,G=null,_.removeEventListener("mousemove",ue),_.removeEventListener("mouseup",ye),_.removeEventListener("touchmove",ue),_.removeEventListener("touchend",ye)}}_.addEventListener("mousemove",ue),_.addEventListener("mouseup",ye),_.addEventListener("touchmove",ue),_.addEventListener("touchend",ye)}function H3(e,{handle:t,connectionMode:n,fromNodeId:r,fromHandleId:o,fromType:i,doc:a,lib:l,flowId:d,isValidConnection:f=U3,nodeLookup:p}){const h=i==="target",g=t?a.querySelector(`.${l}-flow__handle[data-id="${d}-${t==null?void 0:t.nodeId}-${t==null?void 0:t.id}-${t==null?void 0:t.type}"]`):null,{x:y,y:k}=ms(e),w=a.elementFromPoint(y,k),b=w!=null&&w.classList.contains(`${l}-flow__handle`)?w:g,j={handleDomNode:b,isValid:!1,connection:null,toHandle:null};if(b){const N=B3(void 0,b),S=b.getAttribute("data-nodeid"),C=b.getAttribute("data-handleid"),D=b.classList.contains("connectable"),T=b.classList.contains("connectableend");if(!S||!N)return j;const R={source:h?S:r,sourceHandle:h?C:o,target:h?r:S,targetHandle:h?o:C};j.connection=R;const _=D&&T&&(n===tc.Strict?h&&N==="source"||!h&&N==="target":S!==r||C!==o);j.isValid=_&&f(R),j.toHandle=z3(S,N,C,p,n,!0)}return j}const bv={onPointerDown:vte,isValid:H3};function wte({domNode:e,panZoom:t,getTransform:n,getViewScale:r}){const o=Lr(e);function i({translateExtent:l,width:d,height:f,zoomStep:p=1,pannable:h=!0,zoomable:g=!0,inversePan:y=!1}){const k=S=>{if(S.sourceEvent.type!=="wheel"||!t)return;const C=n(),D=S.sourceEvent.ctrlKey&&yd()?10:1,T=-S.sourceEvent.deltaY*(S.sourceEvent.deltaMode===1?.05:S.sourceEvent.deltaMode?1:.002)*p,R=C[2]*Math.pow(2,T*D);t.scaleTo(R)};let w=[0,0];const b=S=>{(S.sourceEvent.type==="mousedown"||S.sourceEvent.type==="touchstart")&&(w=[S.sourceEvent.clientX??S.sourceEvent.touches[0].clientX,S.sourceEvent.clientY??S.sourceEvent.touches[0].clientY])},j=S=>{const C=n();if(S.sourceEvent.type!=="mousemove"&&S.sourceEvent.type!=="touchmove"||!t)return;const D=[S.sourceEvent.clientX??S.sourceEvent.touches[0].clientX,S.sourceEvent.clientY??S.sourceEvent.touches[0].clientY],T=[D[0]-w[0],D[1]-w[1]];w=D;const R=r()*Math.max(C[2],Math.log(C[2]))*(y?-1:1),$={x:C[0]-T[0]*R,y:C[1]-T[1]*R},_=[[0,0],[d,f]];t.setViewportConstrained({x:$.x,y:$.y,zoom:C[2]},_,l)},N=x3().on("start",b).on("zoom",h?j:null).on("zoom.wheel",g?k:null);o.call(N,{})}function a(){o.on("zoom",null)}return{update:i,destroy:a,pointer:fs}}const Qm=e=>({x:e.x,y:e.y,zoom:e.k}),qy=({x:e,y:t,zoom:n})=>Gm.translate(e,t).scale(n),Tl=(e,t)=>e.target.closest(`.${t}`),V3=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),jte=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,Ky=(e,t=0,n=jte,r=()=>{})=>{const o=typeof t=="number"&&t>0;return o||r(),o?e.transition().duration(t).ease(n).on("end",r):e},W3=e=>{const t=e.ctrlKey&&yd()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function kte({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:r,panOnScrollMode:o,panOnScrollSpeed:i,zoomOnPinch:a,onPanZoomStart:l,onPanZoom:d,onPanZoomEnd:f}){return p=>{if(Tl(p,t))return p.ctrlKey&&p.preventDefault(),!1;p.preventDefault(),p.stopImmediatePropagation();const h=n.property("__zoom").k||1;if(p.ctrlKey&&a){const b=fs(p),j=W3(p),N=h*Math.pow(2,j);r.scaleTo(n,N,b,p);return}const g=p.deltaMode===1?20:1;let y=o===ma.Vertical?0:p.deltaX*g,k=o===ma.Horizontal?0:p.deltaY*g;!yd()&&p.shiftKey&&o!==ma.Vertical&&(y=p.deltaY*g,k=0),r.translateBy(n,-(y/h)*i,-(k/h)*i,{internal:!0});const w=Qm(n.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling?(d==null||d(p,w),e.panScrollTimeout=setTimeout(()=>{f==null||f(p,w),e.isPanScrolling=!1},150)):(e.isPanScrolling=!0,l==null||l(p,w))}}function Ste({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(r,o){const i=r.type==="wheel",a=!t&&i&&!r.ctrlKey,l=Tl(r,e);if(r.ctrlKey&&i&&l&&r.preventDefault(),a||l)return null;r.preventDefault(),n.call(this,r,o)}}function Nte({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return r=>{var i,a,l;if((i=r.sourceEvent)!=null&&i.internal)return;const o=Qm(r.transform);e.mouseButton=((a=r.sourceEvent)==null?void 0:a.button)||0,e.isZoomingOrPanning=!0,e.prevViewport=o,((l=r.sourceEvent)==null?void 0:l.type)==="mousedown"&&t(!0),n&&(n==null||n(r.sourceEvent,o))}}function Cte({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:r,onPanZoom:o}){return i=>{var a,l;e.usedRightMouseButton=!!(n&&V3(t,e.mouseButton??0)),(a=i.sourceEvent)!=null&&a.sync||r([i.transform.x,i.transform.y,i.transform.k]),o&&!((l=i.sourceEvent)!=null&&l.internal)&&(o==null||o(i.sourceEvent,Qm(i.transform)))}}function Ete({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:r,onPanZoomEnd:o,onPaneContextMenu:i}){return a=>{var l;if(!((l=a.sourceEvent)!=null&&l.internal)&&(e.isZoomingOrPanning=!1,i&&V3(t,e.mouseButton??0)&&!e.usedRightMouseButton&&a.sourceEvent&&i(a.sourceEvent),e.usedRightMouseButton=!1,r(!1),o)){const d=Qm(a.transform);e.prevViewport=d,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{o==null||o(a.sourceEvent,d)},n?150:0)}}}function Tte({zoomActivationKeyPressed:e,zoomOnScroll:t,zoomOnPinch:n,panOnDrag:r,panOnScroll:o,zoomOnDoubleClick:i,userSelectionActive:a,noWheelClassName:l,noPanClassName:d,lib:f,connectionInProgress:p}){return h=>{var b;const g=e||t,y=n&&h.ctrlKey,k=h.type==="wheel";if(h.button===1&&h.type==="mousedown"&&(Tl(h,`${f}-flow__node`)||Tl(h,`${f}-flow__edge`)))return!0;if(!r&&!g&&!o&&!i&&!n||a||p&&!k||Tl(h,l)&&k||Tl(h,d)&&(!k||o&&k&&!e)||!n&&h.ctrlKey&&k)return!1;if(!n&&h.type==="touchstart"&&((b=h.touches)==null?void 0:b.length)>1)return h.preventDefault(),!1;if(!g&&!o&&!y&&k||!r&&(h.type==="mousedown"||h.type==="touchstart")||Array.isArray(r)&&!r.includes(h.button)&&h.type==="mousedown")return!1;const w=Array.isArray(r)&&r.includes(h.button)||!h.button||h.button<=1;return(!h.ctrlKey||k)&&w}}function Rte({domNode:e,minZoom:t,maxZoom:n,translateExtent:r,viewport:o,onPanZoom:i,onPanZoomStart:a,onPanZoomEnd:l,onDraggingChange:d}){const f={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},p=e.getBoundingClientRect(),h=x3().scaleExtent([t,n]).translateExtent(r),g=Lr(e).call(h);N({x:o.x,y:o.y,zoom:nc(o.zoom,t,n)},[[0,0],[p.width,p.height]],r);const y=g.on("wheel.zoom"),k=g.on("dblclick.zoom");h.wheelDelta(W3);async function w(I,F){return g?new Promise(M=>{h==null||h.interpolate((F==null?void 0:F.interpolate)==="linear"?qu:qp).transform(Ky(g,F==null?void 0:F.duration,F==null?void 0:F.ease,()=>M(!0)),I)}):!1}function b({noWheelClassName:I,noPanClassName:F,onPaneContextMenu:M,userSelectionActive:A,panOnScroll:L,panOnDrag:z,panOnScrollMode:W,panOnScrollSpeed:V,preventScrolling:K,zoomOnPinch:O,zoomOnScroll:B,zoomOnDoubleClick:G,zoomActivationKeyPressed:H,lib:Q,onTransformChange:te,connectionInProgress:Z,paneClickDistance:ae,selectionOnDrag:ne}){A&&!f.isZoomingOrPanning&&j();const ue=L&&!H&&!A;h.clickDistance(ne?1/0:!hs(ae)||ae<0?0:ae);const ye=ue?kte({zoomPanValues:f,noWheelClassName:I,d3Selection:g,d3Zoom:h,panOnScrollMode:W,panOnScrollSpeed:V,zoomOnPinch:O,onPanZoomStart:a,onPanZoom:i,onPanZoomEnd:l}):Ste({noWheelClassName:I,preventScrolling:K,d3ZoomHandler:y});g.on("wheel.zoom",ye,{passive:!1});const Ne=Nte({zoomPanValues:f,onDraggingChange:d,onPanZoomStart:a});h.on("start",Ne);const Re=Cte({zoomPanValues:f,panOnDrag:z,onPaneContextMenu:!!M,onPanZoom:i,onTransformChange:te});h.on("zoom",Re);const Se=Ete({zoomPanValues:f,panOnDrag:z,panOnScroll:L,onPaneContextMenu:M,onPanZoomEnd:l,onDraggingChange:d});h.on("end",Se);const ze=Tte({zoomActivationKeyPressed:H,panOnDrag:z,zoomOnScroll:B,panOnScroll:L,zoomOnDoubleClick:G,zoomOnPinch:O,userSelectionActive:A,noPanClassName:F,noWheelClassName:I,lib:Q,connectionInProgress:Z});h.filter(ze),G?g.on("dblclick.zoom",k):g.on("dblclick.zoom",null)}function j(){h.on("zoom",null)}async function N(I,F,M){const A=qy(I),L=h==null?void 0:h.constrain()(A,F,M);return L&&await w(L),L}async function S(I,F){const M=qy(I);return await w(M,F),M}function C(I){if(g){const F=qy(I),M=g.property("__zoom");(M.k!==I.zoom||M.x!==I.x||M.y!==I.y)&&(h==null||h.transform(g,F,null,{sync:!0}))}}function D(){const I=g?g3(g.node()):{x:0,y:0,k:1};return{x:I.x,y:I.y,zoom:I.k}}async function T(I,F){return g?new Promise(M=>{h==null||h.interpolate((F==null?void 0:F.interpolate)==="linear"?qu:qp).scaleTo(Ky(g,F==null?void 0:F.duration,F==null?void 0:F.ease,()=>M(!0)),I)}):!1}async function R(I,F){return g?new Promise(M=>{h==null||h.interpolate((F==null?void 0:F.interpolate)==="linear"?qu:qp).scaleBy(Ky(g,F==null?void 0:F.duration,F==null?void 0:F.ease,()=>M(!0)),I)}):!1}function $(I){h==null||h.scaleExtent(I)}function _(I){h==null||h.translateExtent(I)}function U(I){const F=!hs(I)||I<0?0:I;h==null||h.clickDistance(F)}return{update:b,destroy:j,setViewport:S,setViewportConstrained:N,getViewport:D,scaleTo:T,scaleBy:R,setScaleExtent:$,setTranslateExtent:_,syncViewport:C,setClickDistance:U}}var oc;(function(e){e.Line="line",e.Handle="handle"})(oc||(oc={}));function Ate({width:e,prevWidth:t,height:n,prevHeight:r,affectsX:o,affectsY:i}){const a=e-t,l=n-r,d=[a>0?1:a<0?-1:0,l>0?1:l<0?-1:0];return a&&o&&(d[0]=d[0]*-1),l&&i&&(d[1]=d[1]*-1),d}function TC(e){const t=e.includes("right")||e.includes("left"),n=e.includes("bottom")||e.includes("top"),r=e.includes("left"),o=e.includes("top");return{isHorizontal:t,isVertical:n,affectsX:r,affectsY:o}}function di(e,t){return Math.max(0,t-e)}function fi(e,t){return Math.max(0,e-t)}function jp(e,t,n){return Math.max(0,t-e,e-n)}function RC(e,t){return e?!t:t}function Pte(e,t,n,r,o,i,a,l){let{affectsX:d,affectsY:f}=t;const{isHorizontal:p,isVertical:h}=t,g=p&&h,{xSnapped:y,ySnapped:k}=n,{minWidth:w,maxWidth:b,minHeight:j,maxHeight:N}=r,{x:S,y:C,width:D,height:T,aspectRatio:R}=e;let $=Math.floor(p?y-e.pointerX:0),_=Math.floor(h?k-e.pointerY:0);const U=D+(d?-$:$),I=T+(f?-_:_),F=-i[0]*D,M=-i[1]*T;let A=jp(U,w,b),L=jp(I,j,N);if(a){let V=0,K=0;d&&$<0?V=di(S+$+F,a[0][0]):!d&&$>0&&(V=fi(S+U+F,a[1][0])),f&&_<0?K=di(C+_+M,a[0][1]):!f&&_>0&&(K=fi(C+I+M,a[1][1])),A=Math.max(A,V),L=Math.max(L,K)}if(l){let V=0,K=0;d&&$>0?V=fi(S+$,l[0][0]):!d&&$<0&&(V=di(S+U,l[1][0])),f&&_>0?K=fi(C+_,l[0][1]):!f&&_<0&&(K=di(C+I,l[1][1])),A=Math.max(A,V),L=Math.max(L,K)}if(o){if(p){const V=jp(U/R,j,N)*R;if(A=Math.max(A,V),a){let K=0;!d&&!f||d&&!f&&g?K=fi(C+M+U/R,a[1][1])*R:K=di(C+M+(d?$:-$)/R,a[0][1])*R,A=Math.max(A,K)}if(l){let K=0;!d&&!f||d&&!f&&g?K=di(C+U/R,l[1][1])*R:K=fi(C+(d?$:-$)/R,l[0][1])*R,A=Math.max(A,K)}}if(h){const V=jp(I*R,w,b)/R;if(L=Math.max(L,V),a){let K=0;!d&&!f||f&&!d&&g?K=fi(S+I*R+F,a[1][0])/R:K=di(S+(f?_:-_)*R+F,a[0][0])/R,L=Math.max(L,K)}if(l){let K=0;!d&&!f||f&&!d&&g?K=di(S+I*R,l[1][0])/R:K=fi(S+(f?_:-_)*R,l[0][0])/R,L=Math.max(L,K)}}}_=_+(_<0?L:-L),$=$+($<0?A:-A),o&&(g?U>I*R?_=(RC(d,f)?-$:$)/R:$=(RC(d,f)?-_:_)*R:p?(_=$/R,f=d):($=_*R,d=f));const z=d?S+$:S,W=f?C+_:C;return{width:D+(d?-$:$),height:T+(f?-_:_),x:i[0]*$*(d?-1:1)+z,y:i[1]*_*(f?-1:1)+W}}const q3={width:0,height:0,x:0,y:0},_te={...q3,pointerX:0,pointerY:0,aspectRatio:1};function Dte(e,t,n){const r=t.position.x+e.position.x,o=t.position.y+e.position.y,i=e.measured.width??0,a=e.measured.height??0,l=n[0]*i,d=n[1]*a;return[[r-l,o-d],[r+i-l,o+a-d]]}function $te({domNode:e,nodeId:t,getStoreItems:n,onChange:r,onEnd:o}){const i=Lr(e);let a={controlDirection:TC("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function l({controlPosition:f,boundaries:p,keepAspectRatio:h,resizeDirection:g,onResizeStart:y,onResize:k,onResizeEnd:w,shouldResize:b}){let j={...q3},N={..._te};a={boundaries:p,resizeDirection:g,keepAspectRatio:h,controlDirection:TC(f)};let S,C=null,D=[],T,R,$,_=!1;const U=t3().on("start",I=>{const{nodeLookup:F,transform:M,snapGrid:A,snapToGrid:L,nodeOrigin:z,paneDomNode:W}=n();if(S=F.get(t),!S)return;C=(W==null?void 0:W.getBoundingClientRect())??null;const{xSnapped:V,ySnapped:K}=Ku(I.sourceEvent,{transform:M,snapGrid:A,snapToGrid:L,containerBounds:C});j={width:S.measured.width??0,height:S.measured.height??0,x:S.position.x??0,y:S.position.y??0},N={...j,pointerX:V,pointerY:K,aspectRatio:j.width/j.height},T=void 0,R=ja(S.extent)?S.extent:void 0,S.parentId&&(S.extent==="parent"||S.expandParent)&&(T=F.get(S.parentId)),T&&S.extent==="parent"&&(R=[[0,0],[T.measured.width,T.measured.height]]),D=[],$=void 0;for(const[O,B]of F)if(B.parentId===t&&(D.push({id:O,position:{...B.position},extent:B.extent}),B.extent==="parent"||B.expandParent)){const G=Dte(B,S,B.origin??z);$?$=[[Math.min(G[0][0],$[0][0]),Math.min(G[0][1],$[0][1])],[Math.max(G[1][0],$[1][0]),Math.max(G[1][1],$[1][1])]]:$=G}y==null||y(I,{...j})}).on("drag",I=>{const{transform:F,snapGrid:M,snapToGrid:A,nodeOrigin:L}=n(),z=Ku(I.sourceEvent,{transform:F,snapGrid:M,snapToGrid:A,containerBounds:C}),W=[];if(!S)return;const{x:V,y:K,width:O,height:B}=j,G={},H=S.origin??L,{width:Q,height:te,x:Z,y:ae}=Pte(N,a.controlDirection,z,a.boundaries,a.keepAspectRatio,H,R,$),ne=Q!==O,ue=te!==B,ye=Z!==V&&ne,Ne=ae!==K&&ue;if(!ye&&!Ne&&!ne&&!ue)return;if((ye||Ne||H[0]===1||H[1]===1)&&(G.x=ye?Z:j.x,G.y=Ne?ae:j.y,j.x=G.x,j.y=G.y,D.length>0)){const oe=Z-V,we=ae-K;for(const ke of D)ke.position={x:ke.position.x-oe+H[0]*(Q-O),y:ke.position.y-we+H[1]*(te-B)},W.push(ke)}if((ne||ue)&&(G.width=ne&&(!a.resizeDirection||a.resizeDirection==="horizontal")?Q:j.width,G.height=ue&&(!a.resizeDirection||a.resizeDirection==="vertical")?te:j.height,j.width=G.width,j.height=G.height),T&&S.expandParent){const oe=H[0]*(G.width??0);G.x&&G.x<oe&&(j.x=oe,N.x=N.x-(G.x-oe));const we=H[1]*(G.height??0);G.y&&G.y<we&&(j.y=we,N.y=N.y-(G.y-we))}const Re=Ate({width:j.width,prevWidth:O,height:j.height,prevHeight:B,affectsX:a.controlDirection.affectsX,affectsY:a.controlDirection.affectsY}),Se={...j,direction:Re};(b==null?void 0:b(I,Se))!==!1&&(_=!0,k==null||k(I,Se),r(G,W))}).on("end",I=>{_&&(w==null||w(I,{...j}),o==null||o({...j}),_=!1)});i.call(U)}function d(){i.on(".drag",null)}return{update:l,destroy:d}}var Gy={exports:{}},Yy={},Xy={exports:{}},Qy={};/**
623
+ * @license React
624
+ * use-sync-external-store-shim.production.js
625
+ *
626
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
627
+ *
628
+ * This source code is licensed under the MIT license found in the
629
+ * LICENSE file in the root directory of this source tree.
630
+ */var AC;function Ite(){if(AC)return Qy;AC=1;var e=jd();function t(h,g){return h===g&&(h!==0||1/h===1/g)||h!==h&&g!==g}var n=typeof Object.is=="function"?Object.is:t,r=e.useState,o=e.useEffect,i=e.useLayoutEffect,a=e.useDebugValue;function l(h,g){var y=g(),k=r({inst:{value:y,getSnapshot:g}}),w=k[0].inst,b=k[1];return i(function(){w.value=y,w.getSnapshot=g,d(w)&&b({inst:w})},[h,y,g]),o(function(){return d(w)&&b({inst:w}),h(function(){d(w)&&b({inst:w})})},[h]),a(y),y}function d(h){var g=h.getSnapshot;h=h.value;try{var y=g();return!n(h,y)}catch{return!0}}function f(h,g){return g()}var p=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?f:l;return Qy.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:p,Qy}var PC;function Mte(){return PC||(PC=1,Xy.exports=Ite()),Xy.exports}/**
631
+ * @license React
632
+ * use-sync-external-store-shim/with-selector.production.js
633
+ *
634
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
635
+ *
636
+ * This source code is licensed under the MIT license found in the
637
+ * LICENSE file in the root directory of this source tree.
638
+ */var _C;function Lte(){if(_C)return Yy;_C=1;var e=jd(),t=Mte();function n(f,p){return f===p&&(f!==0||1/f===1/p)||f!==f&&p!==p}var r=typeof Object.is=="function"?Object.is:n,o=t.useSyncExternalStore,i=e.useRef,a=e.useEffect,l=e.useMemo,d=e.useDebugValue;return Yy.useSyncExternalStoreWithSelector=function(f,p,h,g,y){var k=i(null);if(k.current===null){var w={hasValue:!1,value:null};k.current=w}else w=k.current;k=l(function(){function j(T){if(!N){if(N=!0,S=T,T=g(T),y!==void 0&&w.hasValue){var R=w.value;if(y(R,T))return C=R}return C=T}if(R=C,r(S,T))return R;var $=g(T);return y!==void 0&&y(R,$)?(S=T,R):(S=T,C=$)}var N=!1,S,C,D=h===void 0?null:h;return[function(){return j(p())},D===null?void 0:function(){return j(D())}]},[p,h,g,y]);var b=o(f,k[0],k[1]);return a(function(){w.hasValue=!0,w.value=b},[b]),d(b),b},Yy}var DC;function Ote(){return DC||(DC=1,Gy.exports=Lte()),Gy.exports}var Fte=Ote();const zte=wd(Fte),Bte={},$C=e=>{let t;const n=new Set,r=(p,h)=>{const g=typeof p=="function"?p(t):p;if(!Object.is(g,t)){const y=t;t=h??(typeof g!="object"||g===null)?g:Object.assign({},t,g),n.forEach(k=>k(t,y))}},o=()=>t,d={setState:r,getState:o,getInitialState:()=>f,subscribe:p=>(n.add(p),()=>n.delete(p)),destroy:()=>{(Bte?"production":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),n.clear()}},f=t=e(r,o,d);return d},Ute=e=>e?$C(e):$C,{useDebugValue:Hte}=$t,{useSyncExternalStoreWithSelector:Vte}=zte,Wte=e=>e;function K3(e,t=Wte,n){const r=Vte(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return Hte(r),r}const IC=(e,t)=>{const n=Ute(e),r=(o,i=t)=>K3(n,o,i);return Object.assign(r,n),r},qte=(e,t)=>e?IC(e,t):IC;function sn(e,t){if(Object.is(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(const[r,o]of e)if(!Object.is(o,t.get(r)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(const r of e)if(!t.has(r))return!1;return!0}const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(const r of n)if(!Object.prototype.hasOwnProperty.call(t,r)||!Object.is(e[r],t[r]))return!1;return!0}const Jm=m.createContext(null),Kte=Jm.Provider,G3=ks.error001("react");function At(e,t){const n=m.useContext(Jm);if(n===null)throw new Error(G3);return K3(n,e,t)}function on(){const e=m.useContext(Jm);if(e===null)throw new Error(G3);return m.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}const MC={display:"none"},Gte={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},Y3="react-flow__node-desc",X3="react-flow__edge-desc",Yte="react-flow__aria-live",Xte=e=>e.ariaLiveMessage,Qte=e=>e.ariaLabelConfig;function Jte({rfId:e}){const t=At(Xte);return s.jsx("div",{id:`${Yte}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:Gte,children:t})}function Zte({rfId:e,disableKeyboardA11y:t}){const n=At(Qte);return s.jsxs(s.Fragment,{children:[s.jsx("div",{id:`${Y3}-${e}`,style:MC,children:t?n["node.a11yDescription.default"]:n["node.a11yDescription.keyboardDisabled"]}),s.jsx("div",{id:`${X3}-${e}`,style:MC,children:n["edge.a11yDescription.default"]}),!t&&s.jsx(Jte,{rfId:e})]})}const Yd=m.forwardRef(({position:e="top-left",children:t,className:n,style:r,...o},i)=>{const a=`${e}`.split("-");return s.jsx("div",{className:Sn(["react-flow__panel",n,...a]),style:r,ref:i,...o,children:t})});Yd.displayName="Panel";function ene({proOptions:e,position:t="bottom-right"}){return e!=null&&e.hideAttribution?null:s.jsx(Yd,{position:t,className:"react-flow__attribution","data-message":"Please only hide this attribution when you are subscribed to React Flow Pro: https://pro.reactflow.dev",children:s.jsx("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}const tne=e=>{const t=[],n=[];for(const[,r]of e.nodeLookup)r.selected&&t.push(r.internals.userNode);for(const[,r]of e.edgeLookup)r.selected&&n.push(r);return{selectedNodes:t,selectedEdges:n}},kp=e=>e.id;function nne(e,t){return sn(e.selectedNodes.map(kp),t.selectedNodes.map(kp))&&sn(e.selectedEdges.map(kp),t.selectedEdges.map(kp))}function rne({onSelectionChange:e}){const t=on(),{selectedNodes:n,selectedEdges:r}=At(tne,nne);return m.useEffect(()=>{const o={nodes:n,edges:r};e==null||e(o),t.getState().onSelectionChangeHandlers.forEach(i=>i(o))},[n,r,e]),null}const sne=e=>!!e.onSelectionChangeHandlers;function one({onSelectionChange:e}){const t=At(sne);return e||t?s.jsx(rne,{onSelectionChange:e}):null}const Q3=[0,0],ine={x:0,y:0,zoom:1},ane=["nodes","edges","defaultNodes","defaultEdges","onConnect","onConnectStart","onConnectEnd","onClickConnectStart","onClickConnectEnd","nodesDraggable","autoPanOnNodeFocus","nodesConnectable","nodesFocusable","edgesFocusable","edgesReconnectable","elevateNodesOnSelect","elevateEdgesOnSelect","minZoom","maxZoom","nodeExtent","onNodesChange","onEdgesChange","elementsSelectable","connectionMode","snapGrid","snapToGrid","translateExtent","connectOnClick","defaultEdgeOptions","fitView","fitViewOptions","onNodesDelete","onEdgesDelete","onDelete","onNodeDrag","onNodeDragStart","onNodeDragStop","onSelectionDrag","onSelectionDragStart","onSelectionDragStop","onMoveStart","onMove","onMoveEnd","noPanClassName","nodeOrigin","autoPanOnConnect","autoPanOnNodeDrag","onError","connectionRadius","isValidConnection","selectNodesOnDrag","nodeDragThreshold","connectionDragThreshold","onBeforeDelete","debug","autoPanSpeed","ariaLabelConfig","zIndexMode"],LC=[...ane,"rfId"],lne=e=>({setNodes:e.setNodes,setEdges:e.setEdges,setMinZoom:e.setMinZoom,setMaxZoom:e.setMaxZoom,setTranslateExtent:e.setTranslateExtent,setNodeExtent:e.setNodeExtent,reset:e.reset,setDefaultNodesAndEdges:e.setDefaultNodesAndEdges}),OC={translateExtent:hd,nodeOrigin:Q3,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function cne(e){const{setNodes:t,setEdges:n,setMinZoom:r,setMaxZoom:o,setTranslateExtent:i,setNodeExtent:a,reset:l,setDefaultNodesAndEdges:d}=At(lne,sn),f=on();m.useEffect(()=>(d(e.defaultNodes,e.defaultEdges),()=>{p.current=OC,l()}),[]);const p=m.useRef(OC);return m.useEffect(()=>{for(const h of LC){const g=e[h],y=p.current[h];g!==y&&(typeof e[h]>"u"||(h==="nodes"?t(g):h==="edges"?n(g):h==="minZoom"?r(g):h==="maxZoom"?o(g):h==="translateExtent"?i(g):h==="nodeExtent"?a(g):h==="ariaLabelConfig"?f.setState({ariaLabelConfig:Kee(g)}):h==="fitView"?f.setState({fitViewQueued:g}):h==="fitViewOptions"?f.setState({fitViewOptions:g}):f.setState({[h]:g})))}p.current=e},LC.map(h=>e[h])),null}function FC(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function une(e){var r;const[t,n]=m.useState(e==="system"?null:e);return m.useEffect(()=>{if(e!=="system"){n(e);return}const o=FC(),i=()=>n(o!=null&&o.matches?"dark":"light");return i(),o==null||o.addEventListener("change",i),()=>{o==null||o.removeEventListener("change",i)}},[e]),t!==null?t:(r=FC())!=null&&r.matches?"dark":"light"}const zC=typeof document<"u"?document:null;function bd(e=null,t={target:zC,actInsideInputWithModifier:!0}){const[n,r]=m.useState(!1),o=m.useRef(!1),i=m.useRef(new Set([])),[a,l]=m.useMemo(()=>{if(e!==null){const f=(Array.isArray(e)?e:[e]).filter(h=>typeof h=="string").map(h=>h.replace("+",`
639
+ `).replace(`
640
+
641
+ `,`
642
+ +`).split(`
643
+ `)),p=f.reduce((h,g)=>h.concat(...g),[]);return[f,p]}return[[],[]]},[e]);return m.useEffect(()=>{const d=(t==null?void 0:t.target)??zC,f=(t==null?void 0:t.actInsideInputWithModifier)??!0;if(e!==null){const p=y=>{var b,j;if(o.current=y.ctrlKey||y.metaKey||y.shiftKey||y.altKey,(!o.current||o.current&&!f)&&A3(y))return!1;const w=UC(y.code,l);if(i.current.add(y[w]),BC(a,i.current,!1)){const N=((j=(b=y.composedPath)==null?void 0:b.call(y))==null?void 0:j[0])||y.target,S=(N==null?void 0:N.nodeName)==="BUTTON"||(N==null?void 0:N.nodeName)==="A";t.preventDefault!==!1&&(o.current||!S)&&y.preventDefault(),r(!0)}},h=y=>{const k=UC(y.code,l);BC(a,i.current,!0)?(r(!1),i.current.clear()):i.current.delete(y[k]),y.key==="Meta"&&i.current.clear(),o.current=!1},g=()=>{i.current.clear(),r(!1)};return d==null||d.addEventListener("keydown",p),d==null||d.addEventListener("keyup",h),window.addEventListener("blur",g),window.addEventListener("contextmenu",g),()=>{d==null||d.removeEventListener("keydown",p),d==null||d.removeEventListener("keyup",h),window.removeEventListener("blur",g),window.removeEventListener("contextmenu",g)}}},[e,r]),n}function BC(e,t,n){return e.filter(r=>n||r.length===t.size).some(r=>r.every(o=>t.has(o)))}function UC(e,t){return t.includes(e)?"code":"key"}const dne=()=>{const e=on();return m.useMemo(()=>({zoomIn:async t=>{const{panZoom:n}=e.getState();return n?n.scaleBy(1.2,t):!1},zoomOut:async t=>{const{panZoom:n}=e.getState();return n?n.scaleBy(1/1.2,t):!1},zoomTo:async(t,n)=>{const{panZoom:r}=e.getState();return r?r.scaleTo(t,n):!1},getZoom:()=>e.getState().transform[2],setViewport:async(t,n)=>{const{transform:[r,o,i],panZoom:a}=e.getState();return a?(await a.setViewport({x:t.x??r,y:t.y??o,zoom:t.zoom??i},n),!0):!1},getViewport:()=>{const[t,n,r]=e.getState().transform;return{x:t,y:n,zoom:r}},setCenter:async(t,n,r)=>e.getState().setCenter(t,n,r),fitBounds:async(t,n)=>{const{width:r,height:o,minZoom:i,maxZoom:a,panZoom:l}=e.getState(),d=k0(t,r,o,i,a,(n==null?void 0:n.padding)??.1);return l?(await l.setViewport(d,{duration:n==null?void 0:n.duration,ease:n==null?void 0:n.ease,interpolate:n==null?void 0:n.interpolate}),!0):!1},screenToFlowPosition:(t,n={})=>{const{transform:r,snapGrid:o,snapToGrid:i,domNode:a}=e.getState();if(!a)return t;const{x:l,y:d}=a.getBoundingClientRect(),f={x:t.x-l,y:t.y-d},p=n.snapGrid??o,h=n.snapToGrid??i;return Tc(f,r,h,p)},flowToScreenPosition:t=>{const{transform:n,domNode:r}=e.getState();if(!r)return t;const{x:o,y:i}=r.getBoundingClientRect(),a=sc(t,n);return{x:a.x+o,y:a.y+i}}}),[])};function J3(e,t){const n=[],r=new Map,o=[];for(const i of e)if(i.type==="add"){o.push(i);continue}else if(i.type==="remove"||i.type==="replace")r.set(i.id,[i]);else{const a=r.get(i.id);a?a.push(i):r.set(i.id,[i])}for(const i of t){const a=r.get(i.id);if(!a){n.push(i);continue}if(a[0].type==="remove")continue;if(a[0].type==="replace"){n.push({...a[0].item});continue}const l={...i};for(const d of a)fne(d,l);n.push(l)}return o.length&&o.forEach(i=>{i.index!==void 0?n.splice(i.index,0,{...i.item}):n.push({...i.item})}),n}function fne(e,t){switch(e.type){case"select":{t.selected=e.selected;break}case"position":{typeof e.position<"u"&&(t.position=e.position),typeof e.dragging<"u"&&(t.dragging=e.dragging);break}case"dimensions":{typeof e.dimensions<"u"&&(t.measured={...e.dimensions},e.setAttributes&&((e.setAttributes===!0||e.setAttributes==="width")&&(t.width=e.dimensions.width),(e.setAttributes===!0||e.setAttributes==="height")&&(t.height=e.dimensions.height))),typeof e.resizing=="boolean"&&(t.resizing=e.resizing);break}}}function Z3(e,t){return J3(e,t)}function eD(e,t){return J3(e,t)}function ta(e,t){return{id:e,type:"select",selected:t}}function Rl(e,t=new Set,n=!1){const r=[];for(const[o,i]of e){const a=t.has(o);!(i.selected===void 0&&!a)&&i.selected!==a&&(n&&(i.selected=a),r.push(ta(i.id,a)))}return r}function HC({items:e=[],lookup:t}){var o;const n=[],r=new Map(e.map(i=>[i.id,i]));for(const[i,a]of e.entries()){const l=t.get(a.id),d=((o=l==null?void 0:l.internals)==null?void 0:o.userNode)??l;d!==void 0&&d!==a&&n.push({id:a.id,item:a,type:"replace"}),d===void 0&&n.push({item:a,type:"add",index:i})}for(const[i]of t)r.get(i)===void 0&&n.push({id:i,type:"remove"});return n}function VC(e){return{id:e.id,type:"remove"}}const pne=C3();function hne(e,t,n={}){return Zee(e,t,{...n,onError:n.onError??pne})}const WC=e=>Oee(e),mne=e=>j3(e);function tD(e){return m.forwardRef(e)}const gne=typeof window<"u"?m.useLayoutEffect:m.useEffect;function qC(e){const[t,n]=m.useState(BigInt(0)),[r]=m.useState(()=>xne(()=>n(o=>o+BigInt(1))));return gne(()=>{const o=r.get();o.length&&(e(o),r.reset())},[t]),r}function xne(e){let t=[];return{get:()=>t,reset:()=>{t=[]},push:n=>{t.push(n),e()}}}const nD=m.createContext(null);function yne({children:e}){const t=on(),n=m.useCallback(l=>{const{nodes:d=[],setNodes:f,hasDefaultNodes:p,onNodesChange:h,nodeLookup:g,fitViewQueued:y,onNodesChangeMiddlewareMap:k}=t.getState();let w=d;for(const j of l)w=typeof j=="function"?j(w):j;let b=HC({items:w,lookup:g});for(const j of k.values())b=j(b);p&&f(w),b.length>0?h==null||h(b):y&&window.requestAnimationFrame(()=>{const{fitViewQueued:j,nodes:N,setNodes:S}=t.getState();j&&S(N)})},[]),r=qC(n),o=m.useCallback(l=>{const{edges:d=[],setEdges:f,hasDefaultEdges:p,onEdgesChange:h,edgeLookup:g}=t.getState();let y=d;for(const k of l)y=typeof k=="function"?k(y):k;p?f(y):h&&h(HC({items:y,lookup:g}))},[]),i=qC(o),a=m.useMemo(()=>({nodeQueue:r,edgeQueue:i}),[]);return s.jsx(nD.Provider,{value:a,children:e})}function bne(){const e=m.useContext(nD);if(!e)throw new Error("useBatchContext must be used within a BatchProvider");return e}const vne=e=>!!e.panZoom;function Zm(){const e=dne(),t=on(),n=bne(),r=At(vne),o=m.useMemo(()=>{const i=h=>t.getState().nodeLookup.get(h),a=h=>{n.nodeQueue.push(h)},l=h=>{n.edgeQueue.push(h)},d=h=>{var j,N;const{nodeLookup:g,nodeOrigin:y}=t.getState(),k=WC(h)?h:g.get(h.id),w=k.parentId?T3(k.position,k.measured,k.parentId,g,y):k.position,b={...k,position:w,width:((j=k.measured)==null?void 0:j.width)??k.width,height:((N=k.measured)==null?void 0:N.height)??k.height};return rc(b)},f=(h,g,y={replace:!1})=>{a(k=>k.map(w=>{if(w.id===h){const b=typeof g=="function"?g(w):g;return y.replace&&WC(b)?b:{...w,...b}}return w}))},p=(h,g,y={replace:!1})=>{l(k=>k.map(w=>{if(w.id===h){const b=typeof g=="function"?g(w):g;return y.replace&&mne(b)?b:{...w,...b}}return w}))};return{getNodes:()=>t.getState().nodes.map(h=>({...h})),getNode:h=>{var g;return(g=i(h))==null?void 0:g.internals.userNode},getInternalNode:i,getEdges:()=>{const{edges:h=[]}=t.getState();return h.map(g=>({...g}))},getEdge:h=>t.getState().edgeLookup.get(h),setNodes:a,setEdges:l,addNodes:h=>{const g=Array.isArray(h)?h:[h];n.nodeQueue.push(y=>[...y,...g])},addEdges:h=>{const g=Array.isArray(h)?h:[h];n.edgeQueue.push(y=>[...y,...g])},toObject:()=>{const{nodes:h=[],edges:g=[],transform:y}=t.getState(),[k,w,b]=y;return{nodes:h.map(j=>({...j})),edges:g.map(j=>({...j})),viewport:{x:k,y:w,zoom:b}}},deleteElements:async({nodes:h=[],edges:g=[]})=>{const{nodes:y,edges:k,onNodesDelete:w,onEdgesDelete:b,triggerNodeChanges:j,triggerEdgeChanges:N,onDelete:S,onBeforeDelete:C}=t.getState(),{nodes:D,edges:T}=await Hee({nodesToRemove:h,edgesToRemove:g,nodes:y,edges:k,onBeforeDelete:C}),R=T.length>0,$=D.length>0;if(R){const _=T.map(VC);b==null||b(T),N(_)}if($){const _=D.map(VC);w==null||w(D),j(_)}return($||R)&&(S==null||S({nodes:D,edges:T})),{deletedNodes:D,deletedEdges:T}},getIntersectingNodes:(h,g=!0,y)=>{const k=xC(h),w=k?h:d(h),b=y!==void 0;return w?(y||t.getState().nodes).filter(j=>{const N=t.getState().nodeLookup.get(j.id);if(N&&!k&&(j.id===h.id||!N.internals.positionAbsolute))return!1;const S=rc(b?j:N),C=xd(S,w);return g&&C>0||C>=S.width*S.height||C>=w.width*w.height}):[]},isNodeIntersecting:(h,g,y=!0)=>{const w=xC(h)?h:d(h);if(!w)return!1;const b=xd(w,g);return y&&b>0||b>=g.width*g.height||b>=w.width*w.height},updateNode:f,updateNodeData:(h,g,y={replace:!1})=>{f(h,k=>{const w=typeof g=="function"?g(k):g;return y.replace?{...k,data:w}:{...k,data:{...k.data,...w}}},y)},updateEdge:p,updateEdgeData:(h,g,y={replace:!1})=>{p(h,k=>{const w=typeof g=="function"?g(k):g;return y.replace?{...k,data:w}:{...k,data:{...k.data,...w}}},y)},getNodesBounds:h=>{const{nodeLookup:g,nodeOrigin:y}=t.getState();return Fee(h,{nodeLookup:g,nodeOrigin:y})},getHandleConnections:({type:h,id:g,nodeId:y})=>{var k;return Array.from(((k=t.getState().connectionLookup.get(`${y}-${h}${g?`-${g}`:""}`))==null?void 0:k.values())??[])},getNodeConnections:({type:h,handleId:g,nodeId:y})=>{var k;return Array.from(((k=t.getState().connectionLookup.get(`${y}${h?g?`-${h}-${g}`:`-${h}`:""}`))==null?void 0:k.values())??[])},fitView:async h=>{const g=t.getState().fitViewResolver??qee();return t.setState({fitViewQueued:!0,fitViewOptions:h,fitViewResolver:g}),n.nodeQueue.push(y=>[...y]),g.promise}}},[]);return m.useMemo(()=>({...o,...e,viewportInitialized:r}),[r])}const KC=e=>e.selected,wne=typeof window<"u"?window:void 0;function jne({deleteKeyCode:e,multiSelectionKeyCode:t}){const n=on(),{deleteElements:r}=Zm(),o=bd(e,{actInsideInputWithModifier:!1}),i=bd(t,{target:wne});m.useEffect(()=>{if(o){const{edges:a,nodes:l}=n.getState();r({nodes:l.filter(KC),edges:a.filter(KC)}),n.setState({nodesSelectionActive:!1})}},[o]),m.useEffect(()=>{n.setState({multiSelectionActive:i})},[i])}function kne(e){const t=on();m.useEffect(()=>{const n=()=>{var o,i,a,l;if(!e.current||!(((i=(o=e.current).checkVisibility)==null?void 0:i.call(o))??!0))return!1;const r=S0(e.current);(r.height===0||r.width===0)&&((l=(a=t.getState()).onError)==null||l.call(a,"004",ks.error004())),t.setState({width:r.width||500,height:r.height||500})};if(e.current){n(),window.addEventListener("resize",n);const r=new ResizeObserver(()=>n());return r.observe(e.current),()=>{window.removeEventListener("resize",n),r&&e.current&&r.unobserve(e.current)}}},[])}const eg={position:"absolute",width:"100%",height:"100%",top:0,left:0},Sne=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function Nne({onPaneContextMenu:e,zoomOnScroll:t=!0,zoomOnPinch:n=!0,panOnScroll:r=!1,panOnScrollSpeed:o=.5,panOnScrollMode:i=ma.Free,zoomOnDoubleClick:a=!0,panOnDrag:l=!0,defaultViewport:d,translateExtent:f,minZoom:p,maxZoom:h,zoomActivationKeyCode:g,preventScrolling:y=!0,children:k,noWheelClassName:w,noPanClassName:b,onViewportChange:j,isControlledViewport:N,paneClickDistance:S,selectionOnDrag:C}){const D=on(),T=m.useRef(null),{userSelectionActive:R,lib:$,connectionInProgress:_}=At(Sne,sn),U=bd(g),I=m.useRef();kne(T);const F=m.useCallback(M=>{j==null||j({x:M[0],y:M[1],zoom:M[2]}),N||D.setState({transform:M})},[j,N]);return m.useEffect(()=>{if(T.current){I.current=Rte({domNode:T.current,minZoom:p,maxZoom:h,translateExtent:f,viewport:d,onDraggingChange:z=>D.setState(W=>W.paneDragging===z?W:{paneDragging:z}),onPanZoomStart:(z,W)=>{const{onViewportChangeStart:V,onMoveStart:K}=D.getState();K==null||K(z,W),V==null||V(W)},onPanZoom:(z,W)=>{const{onViewportChange:V,onMove:K}=D.getState();K==null||K(z,W),V==null||V(W)},onPanZoomEnd:(z,W)=>{const{onViewportChangeEnd:V,onMoveEnd:K}=D.getState();K==null||K(z,W),V==null||V(W)}});const{x:M,y:A,zoom:L}=I.current.getViewport();return D.setState({panZoom:I.current,transform:[M,A,L],domNode:T.current.closest(".react-flow")}),()=>{var z;(z=I.current)==null||z.destroy()}}},[]),m.useEffect(()=>{var M;(M=I.current)==null||M.update({onPaneContextMenu:e,zoomOnScroll:t,zoomOnPinch:n,panOnScroll:r,panOnScrollSpeed:o,panOnScrollMode:i,zoomOnDoubleClick:a,panOnDrag:l,zoomActivationKeyPressed:U,preventScrolling:y,noPanClassName:b,userSelectionActive:R,noWheelClassName:w,lib:$,onTransformChange:F,connectionInProgress:_,selectionOnDrag:C,paneClickDistance:S})},[e,t,n,r,o,i,a,l,U,y,b,R,w,$,F,_,C,S]),s.jsx("div",{className:"react-flow__renderer",ref:T,style:eg,children:k})}const Cne=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function Ene(){const{userSelectionActive:e,userSelectionRect:t}=At(Cne,sn);return e&&t?s.jsx("div",{className:"react-flow__selection react-flow__container",style:{width:t.width,height:t.height,transform:`translate(${t.x}px, ${t.y}px)`}}):null}const Jy=(e,t)=>n=>{n.target===t.current&&(e==null||e(n))},Tne=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,connectionInProgress:e.connection.inProgress,dragging:e.paneDragging,panBy:e.panBy,autoPanSpeed:e.autoPanSpeed});function Rne({isSelecting:e,selectionKeyPressed:t,selectionMode:n=md.Full,panOnDrag:r,autoPanOnSelection:o,paneClickDistance:i,selectionOnDrag:a,onSelectionStart:l,onSelectionEnd:d,onPaneClick:f,onPaneContextMenu:p,onPaneScroll:h,onPaneMouseEnter:g,onPaneMouseMove:y,onPaneMouseLeave:k,children:w}){const b=m.useRef(0),j=on(),{userSelectionActive:N,elementsSelectable:S,dragging:C,connectionInProgress:D,panBy:T,autoPanSpeed:R}=At(Tne,sn),$=S&&(e||N),_=m.useRef(null),U=m.useRef(),I=m.useRef(new Set),F=m.useRef(new Set),M=m.useRef(!1),A=m.useRef({x:0,y:0}),L=m.useRef(!1),z=ne=>{if(M.current||D){M.current=!1;return}f==null||f(ne),j.getState().resetSelectedElements(),j.setState({nodesSelectionActive:!1})},W=ne=>{if(Array.isArray(r)&&(r!=null&&r.includes(2))){ne.preventDefault();return}p==null||p(ne)},V=h?ne=>h(ne):void 0,K=ne=>{M.current&&(ne.stopPropagation(),M.current=!1)},O=ne=>{var ke,$e;const{domNode:ue,transform:ye}=j.getState();if(U.current=ue==null?void 0:ue.getBoundingClientRect(),!U.current)return;const Ne=ne.target===_.current;if(!Ne&&!!ne.target.closest(".nokey")||!e||!(a&&Ne||t)||ne.button!==0||!ne.isPrimary)return;($e=(ke=ne.target)==null?void 0:ke.setPointerCapture)==null||$e.call(ke,ne.pointerId),M.current=!1;const{x:ze,y:oe}=ms(ne.nativeEvent,U.current),we=Tc({x:ze,y:oe},ye);j.setState({userSelectionRect:{width:0,height:0,startX:we.x,startY:we.y,x:ze,y:oe}}),Ne||(ne.stopPropagation(),ne.preventDefault())};function B(ne,ue){const{userSelectionRect:ye}=j.getState();if(!ye)return;const{transform:Ne,nodeLookup:Re,edgeLookup:Se,connectionLookup:ze,triggerNodeChanges:oe,triggerEdgeChanges:we,defaultEdgeOptions:ke}=j.getState(),$e={x:ye.startX,y:ye.startY},{x:Ue,y:nt}=sc($e,Ne),He={startX:$e.x,startY:$e.y,x:ne<Ue?ne:Ue,y:ue<nt?ue:nt,width:Math.abs(ne-Ue),height:Math.abs(ue-nt)},at=I.current,xt=F.current;I.current=new Set(w0(Re,He,Ne,n===md.Partial,!0).map(ot=>ot.id)),F.current=new Set;const lt=(ke==null?void 0:ke.selectable)??!0;for(const ot of I.current){const le=ze.get(ot);if(le)for(const{edgeId:xe}of le.values()){const Oe=Se.get(xe);Oe&&(Oe.selectable??lt)&&F.current.add(xe)}}if(!yC(at,I.current)){const ot=Rl(Re,I.current,!0);oe(ot)}if(!yC(xt,F.current)){const ot=Rl(Se,F.current);we(ot)}j.setState({userSelectionRect:He,userSelectionActive:!0,nodesSelectionActive:!1})}function G(){if(!o||!U.current)return;const[ne,ue]=j0(A.current,U.current,R);T({x:ne,y:ue}).then(ye=>{if(!M.current||!ye){b.current=requestAnimationFrame(G);return}const{x:Ne,y:Re}=A.current;B(Ne,Re),b.current=requestAnimationFrame(G)})}const H=()=>{cancelAnimationFrame(b.current),b.current=0,L.current=!1};m.useEffect(()=>()=>H(),[]);const Q=ne=>{const{userSelectionRect:ue,transform:ye,resetSelectedElements:Ne}=j.getState();if(!U.current||!ue)return;const{x:Re,y:Se}=ms(ne.nativeEvent,U.current);A.current={x:Re,y:Se};const ze=sc({x:ue.startX,y:ue.startY},ye);if(!M.current){const oe=t?0:i;if(Math.hypot(Re-ze.x,Se-ze.y)<=oe)return;Ne(),l==null||l(ne)}M.current=!0,L.current||(G(),L.current=!0),B(Re,Se)},te=ne=>{var ue,ye;ne.button===0&&((ye=(ue=ne.target)==null?void 0:ue.releasePointerCapture)==null||ye.call(ue,ne.pointerId),!N&&ne.target===_.current&&j.getState().userSelectionRect&&(z==null||z(ne)),j.setState({userSelectionActive:!1,userSelectionRect:null}),M.current&&(d==null||d(ne),j.setState({nodesSelectionActive:I.current.size>0})),H())},Z=ne=>{var ue,ye;(ye=(ue=ne.target)==null?void 0:ue.releasePointerCapture)==null||ye.call(ue,ne.pointerId),H()},ae=r===!0||Array.isArray(r)&&r.includes(0);return s.jsxs("div",{className:Sn(["react-flow__pane",{draggable:ae,dragging:C,selection:e}]),onClick:$?void 0:Jy(z,_),onContextMenu:Jy(W,_),onWheel:Jy(V,_),onPointerEnter:$?void 0:g,onPointerMove:$?Q:y,onPointerUp:$?te:void 0,onPointerCancel:$?Z:void 0,onPointerDownCapture:$?O:void 0,onClickCapture:$?K:void 0,onPointerLeave:k,ref:_,style:eg,children:[w,s.jsx(Ene,{})]})}function vv({id:e,store:t,unselect:n=!1,nodeRef:r}){const{addSelectedNodes:o,unselectNodesAndEdges:i,multiSelectionActive:a,nodeLookup:l,onError:d}=t.getState(),f=l.get(e);if(!f){d==null||d("012",ks.error012(e));return}t.setState({nodesSelectionActive:!1}),f.selected?(n||f.selected&&a)&&(i({nodes:[f],edges:[]}),requestAnimationFrame(()=>{var p;return(p=r==null?void 0:r.current)==null?void 0:p.blur()})):o([e])}function rD({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:r,nodeId:o,isSelectable:i,nodeClickDistance:a}){const l=on(),[d,f]=m.useState(!1),p=m.useRef();return m.useEffect(()=>{p.current=mte({getStoreItems:()=>l.getState(),onNodeMouseDown:h=>{vv({id:h,store:l,nodeRef:e})},onDragStart:()=>{f(!0)},onDragStop:()=>{f(!1)}})},[]),m.useEffect(()=>{if(!(t||!e.current||!p.current))return p.current.update({noDragClassName:n,handleSelector:r,domNode:e.current,isSelectable:i,nodeId:o,nodeClickDistance:a}),()=>{var h;(h=p.current)==null||h.destroy()}},[n,r,t,i,e,o,a]),d}const Ane=e=>t=>t.selected&&(t.draggable||e&&typeof t.draggable>"u");function sD(){const e=on();return m.useCallback(n=>{const{nodeExtent:r,snapToGrid:o,snapGrid:i,nodesDraggable:a,onError:l,updateNodePositions:d,nodeLookup:f,nodeOrigin:p}=e.getState(),h=new Map,g=Ane(a),y=o?i[0]:5,k=o?i[1]:5,w=n.direction.x*y*n.factor,b=n.direction.y*k*n.factor;for(const[,j]of f){if(!g(j))continue;let N={x:j.internals.positionAbsolute.x+w,y:j.internals.positionAbsolute.y+b};o&&(N=Gd(N,i));const{position:S,positionAbsolute:C}=k3({nodeId:j.id,nextPosition:N,nodeLookup:f,nodeExtent:r,nodeOrigin:p,onError:l});j.position=S,j.internals.positionAbsolute=C,h.set(j.id,j)}d(h)},[])}const A0=m.createContext(null),Pne=A0.Provider;A0.Consumer;const oD=()=>m.useContext(A0),_ne=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),Dne=(e,t,n)=>r=>{const{connectionClickStartHandle:o,connectionMode:i,connection:a}=r,{fromHandle:l,toHandle:d,isValid:f}=a,p=(d==null?void 0:d.nodeId)===e&&(d==null?void 0:d.id)===t&&(d==null?void 0:d.type)===n;return{connectingFrom:(l==null?void 0:l.nodeId)===e&&(l==null?void 0:l.id)===t&&(l==null?void 0:l.type)===n,connectingTo:p,clickConnecting:(o==null?void 0:o.nodeId)===e&&(o==null?void 0:o.id)===t&&(o==null?void 0:o.type)===n,isPossibleEndHandle:i===tc.Strict?(l==null?void 0:l.type)!==n:e!==(l==null?void 0:l.nodeId)||t!==(l==null?void 0:l.id),connectionInProcess:!!l,clickConnectionInProcess:!!o,valid:p&&f}};function $ne({type:e="source",position:t=ct.Top,isValidConnection:n,isConnectable:r=!0,isConnectableStart:o=!0,isConnectableEnd:i=!0,id:a,onConnect:l,children:d,className:f,onMouseDown:p,onTouchStart:h,...g},y){var L,z;const k=a||null,w=e==="target",b=on(),j=oD(),{connectOnClick:N,noPanClassName:S,rfId:C}=At(_ne,sn),{connectingFrom:D,connectingTo:T,clickConnecting:R,isPossibleEndHandle:$,connectionInProcess:_,clickConnectionInProcess:U,valid:I}=At(Dne(j,k,e),sn);j||(z=(L=b.getState()).onError)==null||z.call(L,"010",ks.error010());const F=W=>{const{defaultEdgeOptions:V,onConnect:K,hasDefaultEdges:O}=b.getState(),B={...V,...W};if(O){const{edges:G,setEdges:H,onError:Q}=b.getState();H(hne(B,G,{onError:Q}))}K==null||K(B),l==null||l(B)},M=W=>{if(!j)return;const V=P3(W.nativeEvent);if(o&&(V&&W.button===0||!V)){const K=b.getState();bv.onPointerDown(W.nativeEvent,{handleDomNode:W.currentTarget,autoPanOnConnect:K.autoPanOnConnect,connectionMode:K.connectionMode,connectionRadius:K.connectionRadius,domNode:K.domNode,nodeLookup:K.nodeLookup,lib:K.lib,isTarget:w,handleId:k,nodeId:j,flowId:K.rfId,panBy:K.panBy,cancelConnection:K.cancelConnection,onConnectStart:K.onConnectStart,onConnectEnd:(...O)=>{var B,G;return(G=(B=b.getState()).onConnectEnd)==null?void 0:G.call(B,...O)},updateConnection:K.updateConnection,onConnect:F,isValidConnection:n||((...O)=>{var B,G;return((G=(B=b.getState()).isValidConnection)==null?void 0:G.call(B,...O))??!0}),getTransform:()=>b.getState().transform,getFromHandle:()=>b.getState().connection.fromHandle,autoPanSpeed:K.autoPanSpeed,dragThreshold:K.connectionDragThreshold})}V?p==null||p(W):h==null||h(W)},A=W=>{const{onClickConnectStart:V,onClickConnectEnd:K,connectionClickStartHandle:O,connectionMode:B,isValidConnection:G,lib:H,rfId:Q,nodeLookup:te,connection:Z}=b.getState();if(!j||!O&&!o)return;if(!O){V==null||V(W.nativeEvent,{nodeId:j,handleId:k,handleType:e}),b.setState({connectionClickStartHandle:{nodeId:j,type:e,id:k}});return}const ae=R3(W.target),ne=n||G,{connection:ue,isValid:ye}=bv.isValid(W.nativeEvent,{handle:{nodeId:j,id:k,type:e},connectionMode:B,fromNodeId:O.nodeId,fromHandleId:O.id||null,fromType:O.type,isValidConnection:ne,flowId:Q,doc:ae,lib:H,nodeLookup:te});ye&&ue&&F(ue);const Ne=structuredClone(Z);delete Ne.inProgress,Ne.toPosition=Ne.toHandle?Ne.toHandle.position:null,K==null||K(W,Ne),b.setState({connectionClickStartHandle:null})};return s.jsx("div",{"data-handleid":k,"data-nodeid":j,"data-handlepos":t,"data-id":`${C}-${j}-${k}-${e}`,className:Sn(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",S,f,{source:!w,target:w,connectable:r,connectablestart:o,connectableend:i,clickconnecting:R,connectingfrom:D,connectingto:T,valid:I,connectionindicator:r&&(!_||$)&&(_||U?i:o)}]),onMouseDown:M,onTouchStart:M,onClick:N?A:void 0,ref:y,...g,children:d})}const ic=m.memo(tD($ne));function Ine({data:e,isConnectable:t,sourcePosition:n=ct.Bottom}){return s.jsxs(s.Fragment,{children:[e==null?void 0:e.label,s.jsx(ic,{type:"source",position:n,isConnectable:t})]})}function Mne({data:e,isConnectable:t,targetPosition:n=ct.Top,sourcePosition:r=ct.Bottom}){return s.jsxs(s.Fragment,{children:[s.jsx(ic,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label,s.jsx(ic,{type:"source",position:r,isConnectable:t})]})}function Lne(){return null}function One({data:e,isConnectable:t,targetPosition:n=ct.Top}){return s.jsxs(s.Fragment,{children:[s.jsx(ic,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label]})}const Mh={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},GC={input:Ine,default:Mne,output:One,group:Lne};function Fne(e){var t,n,r,o;return e.internals.handleBounds===void 0?{width:e.width??e.initialWidth??((t=e.style)==null?void 0:t.width),height:e.height??e.initialHeight??((n=e.style)==null?void 0:n.height)}:{width:e.width??((r=e.style)==null?void 0:r.width),height:e.height??((o=e.style)==null?void 0:o.height)}}const zne=e=>{const{width:t,height:n,x:r,y:o}=Kd(e.nodeLookup,{filter:i=>!!i.selected});return{width:hs(t)?t:null,height:hs(n)?n:null,userSelectionActive:e.userSelectionActive,transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]}) translate(${r}px,${o}px)`}};function Bne({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){const r=on(),{width:o,height:i,transformString:a,userSelectionActive:l}=At(zne,sn),d=sD(),f=m.useRef(null);m.useEffect(()=>{var y;n||(y=f.current)==null||y.focus({preventScroll:!0})},[n]);const p=!l&&o!==null&&i!==null;if(rD({nodeRef:f,disabled:!p}),!p)return null;const h=e?y=>{const k=r.getState().nodes.filter(w=>w.selected);e(y,k)}:void 0,g=y=>{Object.prototype.hasOwnProperty.call(Mh,y.key)&&(y.preventDefault(),d({direction:Mh[y.key],factor:y.shiftKey?4:1}))};return s.jsx("div",{className:Sn(["react-flow__nodesselection","react-flow__container",t]),style:{transform:a},children:s.jsx("div",{ref:f,className:"react-flow__nodesselection-rect",onContextMenu:h,tabIndex:n?void 0:-1,onKeyDown:n?void 0:g,style:{width:o,height:i}})})}const YC=typeof window<"u"?window:void 0,Une=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function iD({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:o,onPaneContextMenu:i,onPaneScroll:a,paneClickDistance:l,deleteKeyCode:d,selectionKeyCode:f,selectionOnDrag:p,selectionMode:h,onSelectionStart:g,onSelectionEnd:y,multiSelectionKeyCode:k,panActivationKeyCode:w,zoomActivationKeyCode:b,elementsSelectable:j,zoomOnScroll:N,zoomOnPinch:S,panOnScroll:C,panOnScrollSpeed:D,panOnScrollMode:T,zoomOnDoubleClick:R,panOnDrag:$,autoPanOnSelection:_,defaultViewport:U,translateExtent:I,minZoom:F,maxZoom:M,preventScrolling:A,onSelectionContextMenu:L,noWheelClassName:z,noPanClassName:W,disableKeyboardA11y:V,onViewportChange:K,isControlledViewport:O}){const{nodesSelectionActive:B,userSelectionActive:G}=At(Une,sn),H=bd(f,{target:YC}),Q=bd(w,{target:YC}),te=Q||$,Z=Q||C,ae=p&&te!==!0,ne=H||G||ae;return jne({deleteKeyCode:d,multiSelectionKeyCode:k}),s.jsx(Nne,{onPaneContextMenu:i,elementsSelectable:j,zoomOnScroll:N,zoomOnPinch:S,panOnScroll:Z,panOnScrollSpeed:D,panOnScrollMode:T,zoomOnDoubleClick:R,panOnDrag:!H&&te,defaultViewport:U,translateExtent:I,minZoom:F,maxZoom:M,zoomActivationKeyCode:b,preventScrolling:A,noWheelClassName:z,noPanClassName:W,onViewportChange:K,isControlledViewport:O,paneClickDistance:l,selectionOnDrag:ae,children:s.jsxs(Rne,{onSelectionStart:g,onSelectionEnd:y,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:o,onPaneContextMenu:i,onPaneScroll:a,panOnDrag:te,autoPanOnSelection:_,isSelecting:!!ne,selectionMode:h,selectionKeyPressed:H,paneClickDistance:l,selectionOnDrag:ae,children:[e,B&&s.jsx(Bne,{onSelectionContextMenu:L,noPanClassName:W,disableKeyboardA11y:V})]})})}iD.displayName="FlowRenderer";const Hne=m.memo(iD),Vne=e=>t=>e?w0(t.nodeLookup,{x:0,y:0,width:t.width,height:t.height},t.transform,!0).map(n=>n.id):Array.from(t.nodeLookup.keys());function Wne(e){return At(m.useCallback(Vne(e),[e]),sn)}const qne=e=>e.updateNodeInternals;function Kne(){const e=At(qne),[t]=m.useState(()=>typeof ResizeObserver>"u"?null:new ResizeObserver(n=>{const r=new Map;n.forEach(o=>{const i=o.target.getAttribute("data-id");r.set(i,{id:i,nodeElement:o.target,force:!0})}),e(r)}));return m.useEffect(()=>()=>{t==null||t.disconnect()},[t]),t}function Gne({node:e,nodeType:t,hasDimensions:n,resizeObserver:r}){const o=on(),i=m.useRef(null),a=m.useRef(null),l=m.useRef(e.sourcePosition),d=m.useRef(e.targetPosition),f=m.useRef(t),p=n&&!!e.internals.handleBounds;return m.useEffect(()=>{i.current&&!e.hidden&&(!p||a.current!==i.current)&&(a.current&&(r==null||r.unobserve(a.current)),r==null||r.observe(i.current),a.current=i.current)},[p,e.hidden]),m.useEffect(()=>()=>{a.current&&(r==null||r.unobserve(a.current),a.current=null)},[]),m.useEffect(()=>{if(i.current){const h=f.current!==t,g=l.current!==e.sourcePosition,y=d.current!==e.targetPosition;(h||g||y)&&(f.current=t,l.current=e.sourcePosition,d.current=e.targetPosition,o.getState().updateNodeInternals(new Map([[e.id,{id:e.id,nodeElement:i.current,force:!0}]])))}},[e.id,t,e.sourcePosition,e.targetPosition]),i}function Yne({id:e,onClick:t,onMouseEnter:n,onMouseMove:r,onMouseLeave:o,onContextMenu:i,onDoubleClick:a,nodesDraggable:l,elementsSelectable:d,nodesConnectable:f,nodesFocusable:p,resizeObserver:h,noDragClassName:g,noPanClassName:y,disableKeyboardA11y:k,rfId:w,nodeTypes:b,nodeClickDistance:j,onError:N}){const{node:S,internals:C,isParent:D}=At(ne=>{const ue=ne.nodeLookup.get(e),ye=ne.parentLookup.has(e);return{node:ue,internals:ue.internals,isParent:ye}},sn);let T=S.type||"default",R=(b==null?void 0:b[T])||GC[T];R===void 0&&(N==null||N("003",ks.error003(T)),T="default",R=(b==null?void 0:b.default)||GC.default);const $=!!(S.draggable||l&&typeof S.draggable>"u"),_=!!(S.selectable||d&&typeof S.selectable>"u"),U=!!(S.connectable||f&&typeof S.connectable>"u"),I=!!(S.focusable||p&&typeof S.focusable>"u"),F=on(),M=E3(S),A=Gne({node:S,nodeType:T,hasDimensions:M,resizeObserver:h}),L=rD({nodeRef:A,disabled:S.hidden||!$,noDragClassName:g,handleSelector:S.dragHandle,nodeId:e,isSelectable:_,nodeClickDistance:j}),z=sD();if(S.hidden)return null;const W=Po(S),V=Fne(S),K=_||$||t||n||r||o,O=n?ne=>n(ne,{...C.userNode}):void 0,B=r?ne=>r(ne,{...C.userNode}):void 0,G=o?ne=>o(ne,{...C.userNode}):void 0,H=i?ne=>i(ne,{...C.userNode}):void 0,Q=a?ne=>a(ne,{...C.userNode}):void 0,te=ne=>{const{selectNodesOnDrag:ue,nodeDragThreshold:ye}=F.getState();_&&(!ue||!$||ye>0)&&vv({id:e,store:F,nodeRef:A}),t&&t(ne,{...C.userNode})},Z=ne=>{if(!(A3(ne.nativeEvent)||k)){if(y3.includes(ne.key)&&_){const ue=ne.key==="Escape";vv({id:e,store:F,unselect:ue,nodeRef:A})}else if($&&S.selected&&Object.prototype.hasOwnProperty.call(Mh,ne.key)){ne.preventDefault();const{ariaLabelConfig:ue}=F.getState();F.setState({ariaLiveMessage:ue["node.a11yDescription.ariaLiveMessage"]({direction:ne.key.replace("Arrow","").toLowerCase(),x:~~C.positionAbsolute.x,y:~~C.positionAbsolute.y})}),z({direction:Mh[ne.key],factor:ne.shiftKey?4:1})}}},ae=()=>{var ze;if(k||!((ze=A.current)!=null&&ze.matches(":focus-visible")))return;const{transform:ne,width:ue,height:ye,autoPanOnNodeFocus:Ne,setCenter:Re}=F.getState();if(!Ne)return;w0(new Map([[e,S]]),{x:0,y:0,width:ue,height:ye},ne,!0).length>0||Re(S.position.x+W.width/2,S.position.y+W.height/2,{zoom:ne[2]})};return s.jsx("div",{className:Sn(["react-flow__node",`react-flow__node-${T}`,{[y]:$},S.className,{selected:S.selected,selectable:_,parent:D,draggable:$,dragging:L}]),ref:A,style:{zIndex:C.z,transform:`translate(${C.positionAbsolute.x}px,${C.positionAbsolute.y}px)`,pointerEvents:K?"all":"none",visibility:M?"visible":"hidden",...S.style,...V},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:O,onMouseMove:B,onMouseLeave:G,onContextMenu:H,onClick:te,onDoubleClick:Q,onKeyDown:I?Z:void 0,tabIndex:I?0:void 0,onFocus:I?ae:void 0,role:S.ariaRole??(I?"group":void 0),"aria-roledescription":"node","aria-describedby":k?void 0:`${Y3}-${w}`,"aria-label":S.ariaLabel,...S.domAttributes,children:s.jsx(Pne,{value:e,children:s.jsx(R,{id:e,data:S.data,type:T,positionAbsoluteX:C.positionAbsolute.x,positionAbsoluteY:C.positionAbsolute.y,selected:S.selected??!1,selectable:_,draggable:$,deletable:S.deletable??!0,isConnectable:U,sourcePosition:S.sourcePosition,targetPosition:S.targetPosition,dragging:L,dragHandle:S.dragHandle,zIndex:C.z,parentId:S.parentId,...W})})})}var Xne=m.memo(Yne);const Qne=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function aD(e){const{nodesDraggable:t,nodesConnectable:n,nodesFocusable:r,elementsSelectable:o,onError:i}=At(Qne,sn),a=Wne(e.onlyRenderVisibleElements),l=Kne();return s.jsx("div",{className:"react-flow__nodes",style:eg,children:a.map(d=>s.jsx(Xne,{id:d,nodeTypes:e.nodeTypes,nodeExtent:e.nodeExtent,onClick:e.onNodeClick,onMouseEnter:e.onNodeMouseEnter,onMouseMove:e.onNodeMouseMove,onMouseLeave:e.onNodeMouseLeave,onContextMenu:e.onNodeContextMenu,onDoubleClick:e.onNodeDoubleClick,noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,resizeObserver:l,nodesDraggable:t,nodesConnectable:n,nodesFocusable:r,elementsSelectable:o,nodeClickDistance:e.nodeClickDistance,onError:i},d))})}aD.displayName="NodeRenderer";const Jne=m.memo(aD);function Zne(e){return At(m.useCallback(n=>{if(!e)return n.edges.map(o=>o.id);const r=[];if(n.width&&n.height)for(const o of n.edges){const i=n.nodeLookup.get(o.source),a=n.nodeLookup.get(o.target);i&&a&&Xee({sourceNode:i,targetNode:a,width:n.width,height:n.height,transform:n.transform})&&r.push(o.id)}return r},[e]),sn)}const ere=({color:e="none",strokeWidth:t=1})=>{const n={strokeWidth:t,...e&&{stroke:e}};return s.jsx("polyline",{className:"arrow",style:n,strokeLinecap:"round",fill:"none",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4"})},tre=({color:e="none",strokeWidth:t=1})=>{const n={strokeWidth:t,...e&&{stroke:e,fill:e}};return s.jsx("polyline",{className:"arrowclosed",style:n,strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})},XC={[gd.Arrow]:ere,[gd.ArrowClosed]:tre};function nre(e){const t=on();return m.useMemo(()=>{var o,i;return Object.prototype.hasOwnProperty.call(XC,e)?XC[e]:((i=(o=t.getState()).onError)==null||i.call(o,"009",ks.error009(e)),null)},[e])}const rre=({id:e,type:t,color:n,width:r=12.5,height:o=12.5,markerUnits:i="strokeWidth",strokeWidth:a,orient:l="auto-start-reverse"})=>{const d=nre(t);return d?s.jsx("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${r}`,markerHeight:`${o}`,viewBox:"-10 -10 20 20",markerUnits:i,orient:l,refX:"0",refY:"0",children:s.jsx(d,{color:n,strokeWidth:a})}):null},lD=({defaultColor:e,rfId:t})=>{const n=At(i=>i.edges),r=At(i=>i.defaultEdgeOptions),o=m.useMemo(()=>ste(n,{id:t,defaultColor:e,defaultMarkerStart:r==null?void 0:r.markerStart,defaultMarkerEnd:r==null?void 0:r.markerEnd}),[n,r,t,e]);return o.length?s.jsx("svg",{className:"react-flow__marker","aria-hidden":"true",children:s.jsx("defs",{children:o.map(i=>s.jsx(rre,{id:i.id,type:i.type,color:i.color,width:i.width,height:i.height,markerUnits:i.markerUnits,strokeWidth:i.strokeWidth,orient:i.orient},i.id))})}):null};lD.displayName="MarkerDefinitions";var sre=m.memo(lD);function cD({x:e,y:t,label:n,labelStyle:r,labelShowBg:o=!0,labelBgStyle:i,labelBgPadding:a=[2,4],labelBgBorderRadius:l=2,children:d,className:f,...p}){const[h,g]=m.useState({x:1,y:0,width:0,height:0}),y=Sn(["react-flow__edge-textwrapper",f]),k=m.useRef(null);return m.useEffect(()=>{if(k.current){const w=k.current.getBBox();g({x:w.x,y:w.y,width:w.width,height:w.height})}},[n]),n?s.jsxs("g",{transform:`translate(${e-h.width/2} ${t-h.height/2})`,className:y,visibility:h.width?"visible":"hidden",...p,children:[o&&s.jsx("rect",{width:h.width+2*a[0],x:-a[0],y:-a[1],height:h.height+2*a[1],className:"react-flow__edge-textbg",style:i,rx:l,ry:l}),s.jsx("text",{className:"react-flow__edge-text",y:h.height/2,dy:"0.3em",ref:k,style:r,children:n}),d]}):null}cD.displayName="EdgeText";const ore=m.memo(cD);function tg({path:e,labelX:t,labelY:n,label:r,labelStyle:o,labelShowBg:i,labelBgStyle:a,labelBgPadding:l,labelBgBorderRadius:d,interactionWidth:f=20,...p}){return s.jsxs(s.Fragment,{children:[s.jsx("path",{...p,d:e,fill:"none",className:Sn(["react-flow__edge-path",p.className])}),f?s.jsx("path",{d:e,fill:"none",strokeOpacity:0,strokeWidth:f,className:"react-flow__edge-interaction"}):null,r&&hs(t)&&hs(n)?s.jsx(ore,{x:t,y:n,label:r,labelStyle:o,labelShowBg:i,labelBgStyle:a,labelBgPadding:l,labelBgBorderRadius:d}):null]})}function QC({pos:e,x1:t,y1:n,x2:r,y2:o}){return e===ct.Left||e===ct.Right?[.5*(t+r),n]:[t,.5*(n+o)]}function uD({sourceX:e,sourceY:t,sourcePosition:n=ct.Bottom,targetX:r,targetY:o,targetPosition:i=ct.Top}){const[a,l]=QC({pos:n,x1:e,y1:t,x2:r,y2:o}),[d,f]=QC({pos:i,x1:r,y1:o,x2:e,y2:t}),[p,h,g,y]=_3({sourceX:e,sourceY:t,targetX:r,targetY:o,sourceControlX:a,sourceControlY:l,targetControlX:d,targetControlY:f});return[`M${e},${t} C${a},${l} ${d},${f} ${r},${o}`,p,h,g,y]}function dD(e){return m.memo(({id:t,sourceX:n,sourceY:r,targetX:o,targetY:i,sourcePosition:a,targetPosition:l,label:d,labelStyle:f,labelShowBg:p,labelBgStyle:h,labelBgPadding:g,labelBgBorderRadius:y,style:k,markerEnd:w,markerStart:b,interactionWidth:j})=>{const[N,S,C]=uD({sourceX:n,sourceY:r,sourcePosition:a,targetX:o,targetY:i,targetPosition:l}),D=e.isInternal?void 0:t;return s.jsx(tg,{id:D,path:N,labelX:S,labelY:C,label:d,labelStyle:f,labelShowBg:p,labelBgStyle:h,labelBgPadding:g,labelBgBorderRadius:y,style:k,markerEnd:w,markerStart:b,interactionWidth:j})})}const ire=dD({isInternal:!1}),fD=dD({isInternal:!0});ire.displayName="SimpleBezierEdge";fD.displayName="SimpleBezierEdgeInternal";function pD(e){return m.memo(({id:t,sourceX:n,sourceY:r,targetX:o,targetY:i,label:a,labelStyle:l,labelShowBg:d,labelBgStyle:f,labelBgPadding:p,labelBgBorderRadius:h,style:g,sourcePosition:y=ct.Bottom,targetPosition:k=ct.Top,markerEnd:w,markerStart:b,pathOptions:j,interactionWidth:N})=>{const[S,C,D]=gv({sourceX:n,sourceY:r,sourcePosition:y,targetX:o,targetY:i,targetPosition:k,borderRadius:j==null?void 0:j.borderRadius,offset:j==null?void 0:j.offset,stepPosition:j==null?void 0:j.stepPosition}),T=e.isInternal?void 0:t;return s.jsx(tg,{id:T,path:S,labelX:C,labelY:D,label:a,labelStyle:l,labelShowBg:d,labelBgStyle:f,labelBgPadding:p,labelBgBorderRadius:h,style:g,markerEnd:w,markerStart:b,interactionWidth:N})})}const hD=pD({isInternal:!1}),mD=pD({isInternal:!0});hD.displayName="SmoothStepEdge";mD.displayName="SmoothStepEdgeInternal";function gD(e){return m.memo(({id:t,...n})=>{var o;const r=e.isInternal?void 0:t;return s.jsx(hD,{...n,id:r,pathOptions:m.useMemo(()=>{var i;return{borderRadius:0,offset:(i=n.pathOptions)==null?void 0:i.offset}},[(o=n.pathOptions)==null?void 0:o.offset])})})}const are=gD({isInternal:!1}),xD=gD({isInternal:!0});are.displayName="StepEdge";xD.displayName="StepEdgeInternal";function yD(e){return m.memo(({id:t,sourceX:n,sourceY:r,targetX:o,targetY:i,label:a,labelStyle:l,labelShowBg:d,labelBgStyle:f,labelBgPadding:p,labelBgBorderRadius:h,style:g,markerEnd:y,markerStart:k,interactionWidth:w})=>{const[b,j,N]=I3({sourceX:n,sourceY:r,targetX:o,targetY:i}),S=e.isInternal?void 0:t;return s.jsx(tg,{id:S,path:b,labelX:j,labelY:N,label:a,labelStyle:l,labelShowBg:d,labelBgStyle:f,labelBgPadding:p,labelBgBorderRadius:h,style:g,markerEnd:y,markerStart:k,interactionWidth:w})})}const lre=yD({isInternal:!1}),bD=yD({isInternal:!0});lre.displayName="StraightEdge";bD.displayName="StraightEdgeInternal";function vD(e){return m.memo(({id:t,sourceX:n,sourceY:r,targetX:o,targetY:i,sourcePosition:a=ct.Bottom,targetPosition:l=ct.Top,label:d,labelStyle:f,labelShowBg:p,labelBgStyle:h,labelBgPadding:g,labelBgBorderRadius:y,style:k,markerEnd:w,markerStart:b,pathOptions:j,interactionWidth:N})=>{const[S,C,D]=D3({sourceX:n,sourceY:r,sourcePosition:a,targetX:o,targetY:i,targetPosition:l,curvature:j==null?void 0:j.curvature}),T=e.isInternal?void 0:t;return s.jsx(tg,{id:T,path:S,labelX:C,labelY:D,label:d,labelStyle:f,labelShowBg:p,labelBgStyle:h,labelBgPadding:g,labelBgBorderRadius:y,style:k,markerEnd:w,markerStart:b,interactionWidth:N})})}const cre=vD({isInternal:!1}),wD=vD({isInternal:!0});cre.displayName="BezierEdge";wD.displayName="BezierEdgeInternal";const JC={default:wD,straight:bD,step:xD,smoothstep:mD,simplebezier:fD},ZC={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null},ure=(e,t,n)=>n===ct.Left?e-t:n===ct.Right?e+t:e,dre=(e,t,n)=>n===ct.Top?e-t:n===ct.Bottom?e+t:e,eE="react-flow__edgeupdater";function tE({position:e,centerX:t,centerY:n,radius:r=10,onMouseDown:o,onMouseEnter:i,onMouseOut:a,type:l}){return s.jsx("circle",{onMouseDown:o,onMouseEnter:i,onMouseOut:a,className:Sn([eE,`${eE}-${l}`]),cx:ure(t,r,e),cy:dre(n,r,e),r,stroke:"transparent",fill:"transparent"})}function fre({isReconnectable:e,reconnectRadius:t,edge:n,sourceX:r,sourceY:o,targetX:i,targetY:a,sourcePosition:l,targetPosition:d,onReconnect:f,onReconnectStart:p,onReconnectEnd:h,setReconnecting:g,setUpdateHover:y}){const k=on(),w=(C,D)=>{if(C.button!==0)return;const{autoPanOnConnect:T,domNode:R,connectionMode:$,connectionRadius:_,lib:U,onConnectStart:I,cancelConnection:F,nodeLookup:M,rfId:A,panBy:L,updateConnection:z}=k.getState(),W=D.type==="target",V=(B,G)=>{g(!1),h==null||h(B,n,D.type,G)},K=B=>f==null?void 0:f(n,B),O=(B,G)=>{g(!0),p==null||p(C,n,D.type),I==null||I(B,G)};bv.onPointerDown(C.nativeEvent,{autoPanOnConnect:T,connectionMode:$,connectionRadius:_,domNode:R,handleId:D.id,nodeId:D.nodeId,nodeLookup:M,isTarget:W,edgeUpdaterType:D.type,lib:U,flowId:A,cancelConnection:F,panBy:L,isValidConnection:(...B)=>{var G,H;return((H=(G=k.getState()).isValidConnection)==null?void 0:H.call(G,...B))??!0},onConnect:K,onConnectStart:O,onConnectEnd:(...B)=>{var G,H;return(H=(G=k.getState()).onConnectEnd)==null?void 0:H.call(G,...B)},onReconnectEnd:V,updateConnection:z,getTransform:()=>k.getState().transform,getFromHandle:()=>k.getState().connection.fromHandle,dragThreshold:k.getState().connectionDragThreshold,handleDomNode:C.currentTarget})},b=C=>w(C,{nodeId:n.target,id:n.targetHandle??null,type:"target"}),j=C=>w(C,{nodeId:n.source,id:n.sourceHandle??null,type:"source"}),N=()=>y(!0),S=()=>y(!1);return s.jsxs(s.Fragment,{children:[(e===!0||e==="source")&&s.jsx(tE,{position:l,centerX:r,centerY:o,radius:t,onMouseDown:b,onMouseEnter:N,onMouseOut:S,type:"source"}),(e===!0||e==="target")&&s.jsx(tE,{position:d,centerX:i,centerY:a,radius:t,onMouseDown:j,onMouseEnter:N,onMouseOut:S,type:"target"})]})}function pre({id:e,edgesFocusable:t,edgesReconnectable:n,elementsSelectable:r,onClick:o,onDoubleClick:i,onContextMenu:a,onMouseEnter:l,onMouseMove:d,onMouseLeave:f,reconnectRadius:p,onReconnect:h,onReconnectStart:g,onReconnectEnd:y,rfId:k,edgeTypes:w,noPanClassName:b,onError:j,disableKeyboardA11y:N}){let S=At(Re=>Re.edgeLookup.get(e));const C=At(Re=>Re.defaultEdgeOptions);S=C?{...C,...S}:S;let D=S.type||"default",T=(w==null?void 0:w[D])||JC[D];T===void 0&&(j==null||j("011",ks.error011(D)),D="default",T=(w==null?void 0:w.default)||JC.default);const R=!!(S.focusable||t&&typeof S.focusable>"u"),$=typeof h<"u"&&(S.reconnectable||n&&typeof S.reconnectable>"u"),_=!!(S.selectable||r&&typeof S.selectable>"u"),U=m.useRef(null),[I,F]=m.useState(!1),[M,A]=m.useState(!1),L=on(),{zIndex:z,sourceX:W,sourceY:V,targetX:K,targetY:O,sourcePosition:B,targetPosition:G}=At(m.useCallback(Re=>{const Se=Re.nodeLookup.get(S.source),ze=Re.nodeLookup.get(S.target);if(!Se||!ze)return{zIndex:S.zIndex,...ZC};const oe=rte({id:e,sourceNode:Se,targetNode:ze,sourceHandle:S.sourceHandle||null,targetHandle:S.targetHandle||null,connectionMode:Re.connectionMode,onError:j});return{zIndex:Yee({selected:S.selected,zIndex:S.zIndex,sourceNode:Se,targetNode:ze,elevateOnSelect:Re.elevateEdgesOnSelect,zIndexMode:Re.zIndexMode}),...oe||ZC}},[S.source,S.target,S.sourceHandle,S.targetHandle,S.selected,S.zIndex]),sn),H=m.useMemo(()=>S.markerStart?`url('#${xv(S.markerStart,k)}')`:void 0,[S.markerStart,k]),Q=m.useMemo(()=>S.markerEnd?`url('#${xv(S.markerEnd,k)}')`:void 0,[S.markerEnd,k]);if(S.hidden||W===null||V===null||K===null||O===null)return null;const te=Re=>{var we;const{addSelectedEdges:Se,unselectNodesAndEdges:ze,multiSelectionActive:oe}=L.getState();_&&(L.setState({nodesSelectionActive:!1}),S.selected&&oe?(ze({nodes:[],edges:[S]}),(we=U.current)==null||we.blur()):Se([e])),o&&o(Re,S)},Z=i?Re=>{i(Re,{...S})}:void 0,ae=a?Re=>{a(Re,{...S})}:void 0,ne=l?Re=>{l(Re,{...S})}:void 0,ue=d?Re=>{d(Re,{...S})}:void 0,ye=f?Re=>{f(Re,{...S})}:void 0,Ne=Re=>{var Se;if(!N&&y3.includes(Re.key)&&_){const{unselectNodesAndEdges:ze,addSelectedEdges:oe}=L.getState();Re.key==="Escape"?((Se=U.current)==null||Se.blur(),ze({edges:[S]})):oe([e])}};return s.jsx("svg",{style:{zIndex:z},children:s.jsxs("g",{className:Sn(["react-flow__edge",`react-flow__edge-${D}`,S.className,b,{selected:S.selected,animated:S.animated,inactive:!_&&!o,updating:I,selectable:_}]),onClick:te,onDoubleClick:Z,onContextMenu:ae,onMouseEnter:ne,onMouseMove:ue,onMouseLeave:ye,onKeyDown:R?Ne:void 0,tabIndex:R?0:void 0,role:S.ariaRole??(R?"group":"img"),"aria-roledescription":"edge","data-id":e,"data-testid":`rf__edge-${e}`,"aria-label":S.ariaLabel===null?void 0:S.ariaLabel||`Edge from ${S.source} to ${S.target}`,"aria-describedby":R?`${X3}-${k}`:void 0,ref:U,...S.domAttributes,children:[!M&&s.jsx(T,{id:e,source:S.source,target:S.target,type:S.type,selected:S.selected,animated:S.animated,selectable:_,deletable:S.deletable??!0,label:S.label,labelStyle:S.labelStyle,labelShowBg:S.labelShowBg,labelBgStyle:S.labelBgStyle,labelBgPadding:S.labelBgPadding,labelBgBorderRadius:S.labelBgBorderRadius,sourceX:W,sourceY:V,targetX:K,targetY:O,sourcePosition:B,targetPosition:G,data:S.data,style:S.style,sourceHandleId:S.sourceHandle,targetHandleId:S.targetHandle,markerStart:H,markerEnd:Q,pathOptions:"pathOptions"in S?S.pathOptions:void 0,interactionWidth:S.interactionWidth}),$&&s.jsx(fre,{edge:S,isReconnectable:$,reconnectRadius:p,onReconnect:h,onReconnectStart:g,onReconnectEnd:y,sourceX:W,sourceY:V,targetX:K,targetY:O,sourcePosition:B,targetPosition:G,setUpdateHover:F,setReconnecting:A})]})})}var hre=m.memo(pre);const mre=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function jD({defaultMarkerColor:e,onlyRenderVisibleElements:t,rfId:n,edgeTypes:r,noPanClassName:o,onReconnect:i,onEdgeContextMenu:a,onEdgeMouseEnter:l,onEdgeMouseMove:d,onEdgeMouseLeave:f,onEdgeClick:p,reconnectRadius:h,onEdgeDoubleClick:g,onReconnectStart:y,onReconnectEnd:k,disableKeyboardA11y:w}){const{edgesFocusable:b,edgesReconnectable:j,elementsSelectable:N,onError:S}=At(mre,sn),C=Zne(t);return s.jsxs("div",{className:"react-flow__edges",children:[s.jsx(sre,{defaultColor:e,rfId:n}),C.map(D=>s.jsx(hre,{id:D,edgesFocusable:b,edgesReconnectable:j,elementsSelectable:N,noPanClassName:o,onReconnect:i,onContextMenu:a,onMouseEnter:l,onMouseMove:d,onMouseLeave:f,onClick:p,reconnectRadius:h,onDoubleClick:g,onReconnectStart:y,onReconnectEnd:k,rfId:n,onError:S,edgeTypes:r,disableKeyboardA11y:w},D))]})}jD.displayName="EdgeRenderer";const gre=m.memo(jD),xre=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function yre({children:e}){const t=At(xre);return s.jsx("div",{className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:t},children:e})}function bre(e){const t=Zm(),n=m.useRef(!1);m.useEffect(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}const vre=e=>{var t;return(t=e.panZoom)==null?void 0:t.syncViewport};function wre(e){const t=At(vre),n=on();return m.useEffect(()=>{e&&(t==null||t(e),n.setState({transform:[e.x,e.y,e.zoom]}))},[e,t]),null}function jre(e){return e.connection.inProgress?{...e.connection,to:Tc(e.connection.to,e.transform)}:{...e.connection}}function kre(e){return jre}function Sre(e){const t=kre();return At(t,sn)}const Nre=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function Cre({containerStyle:e,style:t,type:n,component:r}){const{nodesConnectable:o,width:i,height:a,isValid:l,inProgress:d}=At(Nre,sn);return!(i&&o&&d)?null:s.jsx("svg",{style:e,width:i,height:a,className:"react-flow__connectionline react-flow__container",children:s.jsx("g",{className:Sn(["react-flow__connection",w3(l)]),children:s.jsx(kD,{style:t,type:n,CustomComponent:r,isValid:l})})})}const kD=({style:e,type:t=mi.Bezier,CustomComponent:n,isValid:r})=>{const{inProgress:o,from:i,fromNode:a,fromHandle:l,fromPosition:d,to:f,toNode:p,toHandle:h,toPosition:g,pointer:y}=Sre();if(!o)return;if(n)return s.jsx(n,{connectionLineType:t,connectionLineStyle:e,fromNode:a,fromHandle:l,fromX:i.x,fromY:i.y,toX:f.x,toY:f.y,fromPosition:d,toPosition:g,connectionStatus:w3(r),toNode:p,toHandle:h,pointer:y});let k="";const w={sourceX:i.x,sourceY:i.y,sourcePosition:d,targetX:f.x,targetY:f.y,targetPosition:g};switch(t){case mi.Bezier:[k]=D3(w);break;case mi.SimpleBezier:[k]=uD(w);break;case mi.Step:[k]=gv({...w,borderRadius:0});break;case mi.SmoothStep:[k]=gv(w);break;default:[k]=I3(w)}return s.jsx("path",{d:k,fill:"none",className:"react-flow__connection-path",style:e})};kD.displayName="ConnectionLine";const Ere={};function nE(e=Ere){m.useRef(e),on(),m.useEffect(()=>{},[e])}function Tre(){on(),m.useRef(!1),m.useEffect(()=>{},[])}function SD({nodeTypes:e,edgeTypes:t,onInit:n,onNodeClick:r,onEdgeClick:o,onNodeDoubleClick:i,onEdgeDoubleClick:a,onNodeMouseEnter:l,onNodeMouseMove:d,onNodeMouseLeave:f,onNodeContextMenu:p,onSelectionContextMenu:h,onSelectionStart:g,onSelectionEnd:y,connectionLineType:k,connectionLineStyle:w,connectionLineComponent:b,connectionLineContainerStyle:j,selectionKeyCode:N,selectionOnDrag:S,selectionMode:C,multiSelectionKeyCode:D,panActivationKeyCode:T,zoomActivationKeyCode:R,deleteKeyCode:$,onlyRenderVisibleElements:_,elementsSelectable:U,defaultViewport:I,translateExtent:F,minZoom:M,maxZoom:A,preventScrolling:L,defaultMarkerColor:z,zoomOnScroll:W,zoomOnPinch:V,panOnScroll:K,panOnScrollSpeed:O,panOnScrollMode:B,zoomOnDoubleClick:G,panOnDrag:H,autoPanOnSelection:Q,onPaneClick:te,onPaneMouseEnter:Z,onPaneMouseMove:ae,onPaneMouseLeave:ne,onPaneScroll:ue,onPaneContextMenu:ye,paneClickDistance:Ne,nodeClickDistance:Re,onEdgeContextMenu:Se,onEdgeMouseEnter:ze,onEdgeMouseMove:oe,onEdgeMouseLeave:we,reconnectRadius:ke,onReconnect:$e,onReconnectStart:Ue,onReconnectEnd:nt,noDragClassName:He,noWheelClassName:at,noPanClassName:xt,disableKeyboardA11y:lt,nodeExtent:ot,rfId:le,viewport:xe,onViewportChange:Oe}){return nE(e),nE(t),Tre(),bre(n),wre(xe),s.jsx(Hne,{onPaneClick:te,onPaneMouseEnter:Z,onPaneMouseMove:ae,onPaneMouseLeave:ne,onPaneContextMenu:ye,onPaneScroll:ue,paneClickDistance:Ne,deleteKeyCode:$,selectionKeyCode:N,selectionOnDrag:S,selectionMode:C,onSelectionStart:g,onSelectionEnd:y,multiSelectionKeyCode:D,panActivationKeyCode:T,zoomActivationKeyCode:R,elementsSelectable:U,zoomOnScroll:W,zoomOnPinch:V,zoomOnDoubleClick:G,panOnScroll:K,panOnScrollSpeed:O,panOnScrollMode:B,panOnDrag:H,autoPanOnSelection:Q,defaultViewport:I,translateExtent:F,minZoom:M,maxZoom:A,onSelectionContextMenu:h,preventScrolling:L,noDragClassName:He,noWheelClassName:at,noPanClassName:xt,disableKeyboardA11y:lt,onViewportChange:Oe,isControlledViewport:!!xe,children:s.jsxs(yre,{children:[s.jsx(gre,{edgeTypes:t,onEdgeClick:o,onEdgeDoubleClick:a,onReconnect:$e,onReconnectStart:Ue,onReconnectEnd:nt,onlyRenderVisibleElements:_,onEdgeContextMenu:Se,onEdgeMouseEnter:ze,onEdgeMouseMove:oe,onEdgeMouseLeave:we,reconnectRadius:ke,defaultMarkerColor:z,noPanClassName:xt,disableKeyboardA11y:lt,rfId:le}),s.jsx(Cre,{style:w,type:k,component:b,containerStyle:j}),s.jsx("div",{className:"react-flow__edgelabel-renderer"}),s.jsx(Jne,{nodeTypes:e,onNodeClick:r,onNodeDoubleClick:i,onNodeMouseEnter:l,onNodeMouseMove:d,onNodeMouseLeave:f,onNodeContextMenu:p,nodeClickDistance:Re,onlyRenderVisibleElements:_,noPanClassName:xt,noDragClassName:He,disableKeyboardA11y:lt,nodeExtent:ot,rfId:le}),s.jsx("div",{className:"react-flow__viewport-portal"})]})})}SD.displayName="GraphView";const Rre=m.memo(SD),Are=C3(),rE=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:o,height:i,fitView:a,fitViewOptions:l,minZoom:d=.5,maxZoom:f=2,nodeOrigin:p,nodeExtent:h,zIndexMode:g="basic"}={})=>{const y=new Map,k=new Map,w=new Map,b=new Map,j=r??t??[],N=n??e??[],S=p??[0,0],C=h??hd;O3(w,b,j);const{nodesInitialized:D}=yv(N,y,k,{nodeOrigin:S,nodeExtent:C,zIndexMode:g});let T=[0,0,1];if(a&&o&&i){const R=Kd(y,{filter:I=>!!((I.width||I.initialWidth)&&(I.height||I.initialHeight))}),{x:$,y:_,zoom:U}=k0(R,o,i,d,f,(l==null?void 0:l.padding)??.1);T=[$,_,U]}return{rfId:"1",width:o??0,height:i??0,transform:T,nodes:N,nodesInitialized:D,nodeLookup:y,parentLookup:k,edges:j,edgeLookup:b,connectionLookup:w,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:n!==void 0,hasDefaultEdges:r!==void 0,panZoom:null,minZoom:d,maxZoom:f,translateExtent:hd,nodeExtent:C,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:tc.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:S,nodeDragThreshold:1,connectionDragThreshold:1,snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesReconnectable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,elevateEdgesOnSelect:!0,selectNodesOnDrag:!0,multiSelectionActive:!1,fitViewQueued:a??!1,fitViewOptions:l,fitViewResolver:null,connection:{...v3},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:Are,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:b3,zIndexMode:g,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},Pre=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:o,height:i,fitView:a,fitViewOptions:l,minZoom:d,maxZoom:f,nodeOrigin:p,nodeExtent:h,zIndexMode:g})=>qte((y,k)=>{async function w(){const{nodeLookup:b,panZoom:j,fitViewOptions:N,fitViewResolver:S,width:C,height:D,minZoom:T,maxZoom:R}=k();j&&(await Uee({nodes:b,width:C,height:D,panZoom:j,minZoom:T,maxZoom:R},N),S==null||S.resolve(!0),y({fitViewResolver:null}))}return{...rE({nodes:e,edges:t,width:o,height:i,fitView:a,fitViewOptions:l,minZoom:d,maxZoom:f,nodeOrigin:p,nodeExtent:h,defaultNodes:n,defaultEdges:r,zIndexMode:g}),setNodes:b=>{const{nodeLookup:j,parentLookup:N,nodeOrigin:S,elevateNodesOnSelect:C,fitViewQueued:D,zIndexMode:T,nodesSelectionActive:R}=k(),{nodesInitialized:$,hasSelectedNodes:_}=yv(b,j,N,{nodeOrigin:S,nodeExtent:h,elevateNodesOnSelect:C,checkEquality:!0,zIndexMode:T}),U=R&&_;D&&$?(w(),y({nodes:b,nodesInitialized:$,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:U})):y({nodes:b,nodesInitialized:$,nodesSelectionActive:U})},setEdges:b=>{const{connectionLookup:j,edgeLookup:N}=k();O3(j,N,b),y({edges:b})},setDefaultNodesAndEdges:(b,j)=>{if(b){const{setNodes:N}=k();N(b),y({hasDefaultNodes:!0})}if(j){const{setEdges:N}=k();N(j),y({hasDefaultEdges:!0})}},updateNodeInternals:b=>{const{triggerNodeChanges:j,nodeLookup:N,parentLookup:S,domNode:C,nodeOrigin:D,nodeExtent:T,debug:R,fitViewQueued:$,zIndexMode:_}=k(),{changes:U,updatedInternals:I}=dte(b,N,S,C,D,T,_);I&&(ate(N,S,{nodeOrigin:D,nodeExtent:T,zIndexMode:_}),$?(w(),y({fitViewQueued:!1,fitViewOptions:void 0})):y({}),(U==null?void 0:U.length)>0&&(R&&console.log("React Flow: trigger node changes",U),j==null||j(U)))},updateNodePositions:(b,j=!1)=>{const N=[];let S=[];const{nodeLookup:C,triggerNodeChanges:D,connection:T,updateConnection:R,onNodesChangeMiddlewareMap:$}=k();for(const[_,U]of b){const I=C.get(_),F=!!(I!=null&&I.expandParent&&(I!=null&&I.parentId)&&(U!=null&&U.position)),M={id:_,type:"position",position:F?{x:Math.max(0,U.position.x),y:Math.max(0,U.position.y)}:U.position,dragging:j};if(I&&T.inProgress&&T.fromNode.id===I.id){const A=ka(I,T.fromHandle,ct.Left,!0);R({...T,from:A})}F&&I.parentId&&N.push({id:_,parentId:I.parentId,rect:{...U.internals.positionAbsolute,width:U.measured.width??0,height:U.measured.height??0}}),S.push(M)}if(N.length>0){const{parentLookup:_,nodeOrigin:U}=k(),I=R0(N,C,_,U);S.push(...I)}for(const _ of $.values())S=_(S);D(S)},triggerNodeChanges:b=>{const{onNodesChange:j,setNodes:N,nodes:S,hasDefaultNodes:C,debug:D}=k();if(b!=null&&b.length){if(C){const T=Z3(b,S);N(T)}D&&console.log("React Flow: trigger node changes",b),j==null||j(b)}},triggerEdgeChanges:b=>{const{onEdgesChange:j,setEdges:N,edges:S,hasDefaultEdges:C,debug:D}=k();if(b!=null&&b.length){if(C){const T=eD(b,S);N(T)}D&&console.log("React Flow: trigger edge changes",b),j==null||j(b)}},addSelectedNodes:b=>{const{multiSelectionActive:j,edgeLookup:N,nodeLookup:S,triggerNodeChanges:C,triggerEdgeChanges:D}=k();if(j){const T=b.map(R=>ta(R,!0));C(T);return}C(Rl(S,new Set([...b]),!0)),D(Rl(N))},addSelectedEdges:b=>{const{multiSelectionActive:j,edgeLookup:N,nodeLookup:S,triggerNodeChanges:C,triggerEdgeChanges:D}=k();if(j){const T=b.map(R=>ta(R,!0));D(T);return}D(Rl(N,new Set([...b]))),C(Rl(S,new Set,!0))},unselectNodesAndEdges:({nodes:b,edges:j}={})=>{const{edges:N,nodes:S,nodeLookup:C,triggerNodeChanges:D,triggerEdgeChanges:T}=k(),R=b||S,$=j||N,_=[];for(const I of R){if(!I.selected)continue;const F=C.get(I.id);F&&(F.selected=!1),_.push(ta(I.id,!1))}const U=[];for(const I of $)I.selected&&U.push(ta(I.id,!1));D(_),T(U)},setMinZoom:b=>{const{panZoom:j,maxZoom:N}=k();j==null||j.setScaleExtent([b,N]),y({minZoom:b})},setMaxZoom:b=>{const{panZoom:j,minZoom:N}=k();j==null||j.setScaleExtent([N,b]),y({maxZoom:b})},setTranslateExtent:b=>{var j;(j=k().panZoom)==null||j.setTranslateExtent(b),y({translateExtent:b})},resetSelectedElements:()=>{const{edges:b,nodes:j,triggerNodeChanges:N,triggerEdgeChanges:S,elementsSelectable:C}=k();if(!C)return;const D=j.reduce((R,$)=>$.selected?[...R,ta($.id,!1)]:R,[]),T=b.reduce((R,$)=>$.selected?[...R,ta($.id,!1)]:R,[]);N(D),S(T)},setNodeExtent:b=>{const{nodes:j,nodeLookup:N,parentLookup:S,nodeOrigin:C,elevateNodesOnSelect:D,nodeExtent:T,zIndexMode:R}=k();b[0][0]===T[0][0]&&b[0][1]===T[0][1]&&b[1][0]===T[1][0]&&b[1][1]===T[1][1]||(yv(j,N,S,{nodeOrigin:C,nodeExtent:b,elevateNodesOnSelect:D,checkEquality:!1,zIndexMode:R}),y({nodeExtent:b}))},panBy:b=>{const{transform:j,width:N,height:S,panZoom:C,translateExtent:D}=k();return fte({delta:b,panZoom:C,transform:j,translateExtent:D,width:N,height:S})},setCenter:async(b,j,N)=>{const{width:S,height:C,maxZoom:D,panZoom:T}=k();if(!T)return!1;const R=typeof(N==null?void 0:N.zoom)<"u"?N.zoom:D;return await T.setViewport({x:S/2-b*R,y:C/2-j*R,zoom:R},{duration:N==null?void 0:N.duration,ease:N==null?void 0:N.ease,interpolate:N==null?void 0:N.interpolate}),!0},cancelConnection:()=>{y({connection:{...v3}})},updateConnection:b=>{y({connection:b})},reset:()=>y({...rE()})}},Object.is);function _re({initialNodes:e,initialEdges:t,defaultNodes:n,defaultEdges:r,initialWidth:o,initialHeight:i,initialMinZoom:a,initialMaxZoom:l,initialFitViewOptions:d,fitView:f,nodeOrigin:p,nodeExtent:h,zIndexMode:g,children:y}){const[k]=m.useState(()=>Pre({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:o,height:i,fitView:f,minZoom:a,maxZoom:l,fitViewOptions:d,nodeOrigin:p,nodeExtent:h,zIndexMode:g}));return s.jsx(Kte,{value:k,children:s.jsx(yne,{children:y})})}function Dre({children:e,nodes:t,edges:n,defaultNodes:r,defaultEdges:o,width:i,height:a,fitView:l,fitViewOptions:d,minZoom:f,maxZoom:p,nodeOrigin:h,nodeExtent:g,zIndexMode:y}){return m.useContext(Jm)?s.jsx(s.Fragment,{children:e}):s.jsx(_re,{initialNodes:t,initialEdges:n,defaultNodes:r,defaultEdges:o,initialWidth:i,initialHeight:a,fitView:l,initialFitViewOptions:d,initialMinZoom:f,initialMaxZoom:p,nodeOrigin:h,nodeExtent:g,zIndexMode:y,children:e})}const $re={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function Ire({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,className:o,nodeTypes:i,edgeTypes:a,onNodeClick:l,onEdgeClick:d,onInit:f,onMove:p,onMoveStart:h,onMoveEnd:g,onConnect:y,onConnectStart:k,onConnectEnd:w,onClickConnectStart:b,onClickConnectEnd:j,onNodeMouseEnter:N,onNodeMouseMove:S,onNodeMouseLeave:C,onNodeContextMenu:D,onNodeDoubleClick:T,onNodeDragStart:R,onNodeDrag:$,onNodeDragStop:_,onNodesDelete:U,onEdgesDelete:I,onDelete:F,onSelectionChange:M,onSelectionDragStart:A,onSelectionDrag:L,onSelectionDragStop:z,onSelectionContextMenu:W,onSelectionStart:V,onSelectionEnd:K,onBeforeDelete:O,connectionMode:B,connectionLineType:G=mi.Bezier,connectionLineStyle:H,connectionLineComponent:Q,connectionLineContainerStyle:te,deleteKeyCode:Z="Backspace",selectionKeyCode:ae="Shift",selectionOnDrag:ne=!1,selectionMode:ue=md.Full,panActivationKeyCode:ye="Space",multiSelectionKeyCode:Ne=yd()?"Meta":"Control",zoomActivationKeyCode:Re=yd()?"Meta":"Control",snapToGrid:Se,snapGrid:ze,onlyRenderVisibleElements:oe=!1,selectNodesOnDrag:we,nodesDraggable:ke,autoPanOnNodeFocus:$e,nodesConnectable:Ue,nodesFocusable:nt,nodeOrigin:He=Q3,edgesFocusable:at,edgesReconnectable:xt,elementsSelectable:lt=!0,defaultViewport:ot=ine,minZoom:le=.5,maxZoom:xe=2,translateExtent:Oe=hd,preventScrolling:We=!0,nodeExtent:Ge,defaultMarkerColor:ge="#b1b1b7",zoomOnScroll:pe=!0,zoomOnPinch:se=!0,panOnScroll:je=!1,panOnScrollSpeed:Ae=.5,panOnScrollMode:qe=ma.Free,zoomOnDoubleClick:X=!0,panOnDrag:ve=!0,onPaneClick:Ve,onPaneMouseEnter:ft,onPaneMouseMove:et,onPaneMouseLeave:yt,onPaneScroll:mt,onPaneContextMenu:he,paneClickDistance:Ee=1,nodeClickDistance:Ye=0,children:Nt,onReconnect:Mt,onReconnectStart:Nn,onReconnectEnd:Ct,onEdgeContextMenu:Cn,onEdgeDoubleClick:Ft,onEdgeMouseEnter:En,onEdgeMouseMove:en,onEdgeMouseLeave:ce,reconnectRadius:Te=10,onNodesChange:st,onEdgesChange:Tn,noDragClassName:kr="nodrag",noWheelClassName:no="nowheel",noPanClassName:bt="nopan",fitView:Ai,fitViewOptions:_o,connectOnClick:Pa,attributionPosition:tn,proOptions:Do,defaultEdgeOptions:_a,elevateNodesOnSelect:Da=!0,elevateEdgesOnSelect:Ac=!1,disableKeyboardA11y:$a=!1,autoPanOnConnect:Bt,autoPanOnNodeDrag:Pi,autoPanOnSelection:ro=!0,autoPanSpeed:$o,connectionRadius:As,isValidConnection:Io,onError:Ia,style:Mo,id:nr,nodeDragThreshold:ar,connectionDragThreshold:On,viewport:Lo,onViewportChange:Pc,width:_c,height:Oo,colorMode:Vn="light",debug:so,onScroll:Vr,ariaLabelConfig:Ma,zIndexMode:_i="basic",...Fo},zo){const Ps=nr||"1",zt=une(Vn),oo=m.useCallback(_s=>{_s.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),Vr==null||Vr(_s)},[Vr]);return s.jsx("div",{"data-testid":"rf__wrapper",...Fo,onScroll:oo,style:{...Mo,...$re},ref:zo,className:Sn(["react-flow",o,zt]),id:nr,role:"application",children:s.jsxs(Dre,{nodes:e,edges:t,width:_c,height:Oo,fitView:Ai,fitViewOptions:_o,minZoom:le,maxZoom:xe,nodeOrigin:He,nodeExtent:Ge,zIndexMode:_i,children:[s.jsx(cne,{nodes:e,edges:t,defaultNodes:n,defaultEdges:r,onConnect:y,onConnectStart:k,onConnectEnd:w,onClickConnectStart:b,onClickConnectEnd:j,nodesDraggable:ke,autoPanOnNodeFocus:$e,nodesConnectable:Ue,nodesFocusable:nt,edgesFocusable:at,edgesReconnectable:xt,elementsSelectable:lt,elevateNodesOnSelect:Da,elevateEdgesOnSelect:Ac,minZoom:le,maxZoom:xe,nodeExtent:Ge,onNodesChange:st,onEdgesChange:Tn,snapToGrid:Se,snapGrid:ze,connectionMode:B,translateExtent:Oe,connectOnClick:Pa,defaultEdgeOptions:_a,fitView:Ai,fitViewOptions:_o,onNodesDelete:U,onEdgesDelete:I,onDelete:F,onNodeDragStart:R,onNodeDrag:$,onNodeDragStop:_,onSelectionDrag:L,onSelectionDragStart:A,onSelectionDragStop:z,onMove:p,onMoveStart:h,onMoveEnd:g,noPanClassName:bt,nodeOrigin:He,rfId:Ps,autoPanOnConnect:Bt,autoPanOnNodeDrag:Pi,autoPanSpeed:$o,onError:Ia,connectionRadius:As,isValidConnection:Io,selectNodesOnDrag:we,nodeDragThreshold:ar,connectionDragThreshold:On,onBeforeDelete:O,debug:so,ariaLabelConfig:Ma,zIndexMode:_i}),s.jsx(Rre,{onInit:f,onNodeClick:l,onEdgeClick:d,onNodeMouseEnter:N,onNodeMouseMove:S,onNodeMouseLeave:C,onNodeContextMenu:D,onNodeDoubleClick:T,nodeTypes:i,edgeTypes:a,connectionLineType:G,connectionLineStyle:H,connectionLineComponent:Q,connectionLineContainerStyle:te,selectionKeyCode:ae,selectionOnDrag:ne,selectionMode:ue,deleteKeyCode:Z,multiSelectionKeyCode:Ne,panActivationKeyCode:ye,zoomActivationKeyCode:Re,onlyRenderVisibleElements:oe,defaultViewport:ot,translateExtent:Oe,minZoom:le,maxZoom:xe,preventScrolling:We,zoomOnScroll:pe,zoomOnPinch:se,zoomOnDoubleClick:X,panOnScroll:je,panOnScrollSpeed:Ae,panOnScrollMode:qe,panOnDrag:ve,autoPanOnSelection:ro,onPaneClick:Ve,onPaneMouseEnter:ft,onPaneMouseMove:et,onPaneMouseLeave:yt,onPaneScroll:mt,onPaneContextMenu:he,paneClickDistance:Ee,nodeClickDistance:Ye,onSelectionContextMenu:W,onSelectionStart:V,onSelectionEnd:K,onReconnect:Mt,onReconnectStart:Nn,onReconnectEnd:Ct,onEdgeContextMenu:Cn,onEdgeDoubleClick:Ft,onEdgeMouseEnter:En,onEdgeMouseMove:en,onEdgeMouseLeave:ce,reconnectRadius:Te,defaultMarkerColor:ge,noDragClassName:kr,noWheelClassName:no,noPanClassName:bt,rfId:Ps,disableKeyboardA11y:$a,nodeExtent:Ge,viewport:Lo,onViewportChange:Pc}),s.jsx(one,{onSelectionChange:M}),Nt,s.jsx(ene,{proOptions:Do,position:tn}),s.jsx(Zte,{rfId:Ps,disableKeyboardA11y:$a})]})})}var Mre=tD(Ire);function Lre(e){const[t,n]=m.useState(e),r=m.useCallback(o=>n(i=>Z3(o,i)),[]);return[t,n,r]}function Ore(e){const[t,n]=m.useState(e),r=m.useCallback(o=>n(i=>eD(o,i)),[]);return[t,n,r]}function Fre({dimensions:e,lineWidth:t,variant:n,className:r}){return s.jsx("path",{strokeWidth:t,d:`M${e[0]/2} 0 V${e[1]} M0 ${e[1]/2} H${e[0]}`,className:Sn(["react-flow__background-pattern",n,r])})}function zre({radius:e,className:t}){return s.jsx("circle",{cx:e,cy:e,r:e,className:Sn(["react-flow__background-pattern","dots",t])})}var yi;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(yi||(yi={}));const Bre={[yi.Dots]:1,[yi.Lines]:1,[yi.Cross]:6},Ure=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function ND({id:e,variant:t=yi.Dots,gap:n=20,size:r,lineWidth:o=1,offset:i=0,color:a,bgColor:l,style:d,className:f,patternClassName:p}){const h=m.useRef(null),{transform:g,patternId:y}=At(Ure,sn),k=r||Bre[t],w=t===yi.Dots,b=t===yi.Cross,j=Array.isArray(n)?n:[n,n],N=[j[0]*g[2]||1,j[1]*g[2]||1],S=k*g[2],C=Array.isArray(i)?i:[i,i],D=b?[S,S]:N,T=[C[0]*g[2]||1+D[0]/2,C[1]*g[2]||1+D[1]/2],R=`${y}${e||""}`;return s.jsxs("svg",{className:Sn(["react-flow__background",f]),style:{...d,...eg,"--xy-background-color-props":l,"--xy-background-pattern-color-props":a},ref:h,"data-testid":"rf__background",children:[s.jsx("pattern",{id:R,x:g[0]%N[0],y:g[1]%N[1],width:N[0],height:N[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${T[0]},-${T[1]})`,children:w?s.jsx(zre,{radius:S/2,className:p}):s.jsx(Fre,{dimensions:D,lineWidth:o,variant:t,className:p})}),s.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${R})`})]})}ND.displayName="Background";const Hre=m.memo(ND);function Vre(){return s.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:s.jsx("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function Wre(){return s.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:s.jsx("path",{d:"M0 0h32v4.2H0z"})})}function qre(){return s.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:s.jsx("path",{d:"M3.692 4.63c0-.53.4-.938.939-.938h5.215V0H4.708C2.13 0 0 2.054 0 4.63v5.216h3.692V4.631zM27.354 0h-5.2v3.692h5.17c.53 0 .984.4.984.939v5.215H32V4.631A4.624 4.624 0 0027.354 0zm.954 24.83c0 .532-.4.94-.939.94h-5.215v3.768h5.215c2.577 0 4.631-2.13 4.631-4.707v-5.139h-3.692v5.139zm-23.677.94c-.531 0-.939-.4-.939-.94v-5.138H0v5.139c0 2.577 2.13 4.707 4.708 4.707h5.138V25.77H4.631z"})})}function Kre(){return s.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:s.jsx("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0 8 0 4.571 3.429 4.571 7.619v3.048H3.048A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047zm4.724-13.866H7.467V7.619c0-2.59 2.133-4.724 4.723-4.724 2.591 0 4.724 2.133 4.724 4.724v3.048z"})})}function Gre(){return s.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:s.jsx("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0c-4.114 1.828-1.37 2.133.305 2.438 1.676.305 4.42 2.59 4.42 5.181v3.048H3.047A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047z"})})}function Sp({children:e,className:t,...n}){return s.jsx("button",{type:"button",className:Sn(["react-flow__controls-button",t]),...n,children:e})}const Yre=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function CD({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:r=!0,fitViewOptions:o,onZoomIn:i,onZoomOut:a,onFitView:l,onInteractiveChange:d,className:f,children:p,position:h="bottom-left",orientation:g="vertical","aria-label":y}){const k=on(),{isInteractive:w,minZoomReached:b,maxZoomReached:j,ariaLabelConfig:N}=At(Yre,sn),{zoomIn:S,zoomOut:C,fitView:D}=Zm(),T=()=>{S(),i==null||i()},R=()=>{C(),a==null||a()},$=()=>{D(o),l==null||l()},_=()=>{k.setState({nodesDraggable:!w,nodesConnectable:!w,elementsSelectable:!w}),d==null||d(!w)},U=g==="horizontal"?"horizontal":"vertical";return s.jsxs(Yd,{className:Sn(["react-flow__controls",U,f]),position:h,style:e,"data-testid":"rf__controls","aria-label":y??N["controls.ariaLabel"],children:[t&&s.jsxs(s.Fragment,{children:[s.jsx(Sp,{onClick:T,className:"react-flow__controls-zoomin",title:N["controls.zoomIn.ariaLabel"],"aria-label":N["controls.zoomIn.ariaLabel"],disabled:j,children:s.jsx(Vre,{})}),s.jsx(Sp,{onClick:R,className:"react-flow__controls-zoomout",title:N["controls.zoomOut.ariaLabel"],"aria-label":N["controls.zoomOut.ariaLabel"],disabled:b,children:s.jsx(Wre,{})})]}),n&&s.jsx(Sp,{className:"react-flow__controls-fitview",onClick:$,title:N["controls.fitView.ariaLabel"],"aria-label":N["controls.fitView.ariaLabel"],children:s.jsx(qre,{})}),r&&s.jsx(Sp,{className:"react-flow__controls-interactive",onClick:_,title:N["controls.interactive.ariaLabel"],"aria-label":N["controls.interactive.ariaLabel"],children:w?s.jsx(Gre,{}):s.jsx(Kre,{})}),p]})}CD.displayName="Controls";const Xre=m.memo(CD);function Qre({id:e,x:t,y:n,width:r,height:o,style:i,color:a,strokeColor:l,strokeWidth:d,className:f,borderRadius:p,shapeRendering:h,selected:g,onClick:y}){const{background:k,backgroundColor:w}=i||{},b=a||k||w;return s.jsx("rect",{className:Sn(["react-flow__minimap-node",{selected:g},f]),x:t,y:n,rx:p,ry:p,width:r,height:o,style:{fill:b,stroke:l,strokeWidth:d},shapeRendering:h,onClick:y?j=>y(j,e):void 0})}const Jre=m.memo(Qre),Zre=e=>e.nodes.map(t=>t.id),Zy=e=>e instanceof Function?e:()=>e;function ese({nodeStrokeColor:e,nodeColor:t,nodeClassName:n="",nodeBorderRadius:r=5,nodeStrokeWidth:o,nodeComponent:i=Jre,onClick:a}){const l=At(Zre,sn),d=Zy(t),f=Zy(e),p=Zy(n),h=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return s.jsx(s.Fragment,{children:l.map(g=>s.jsx(nse,{id:g,nodeColorFunc:d,nodeStrokeColorFunc:f,nodeClassNameFunc:p,nodeBorderRadius:r,nodeStrokeWidth:o,NodeComponent:i,onClick:a,shapeRendering:h},g))})}function tse({id:e,nodeColorFunc:t,nodeStrokeColorFunc:n,nodeClassNameFunc:r,nodeBorderRadius:o,nodeStrokeWidth:i,shapeRendering:a,NodeComponent:l,onClick:d}){const{node:f,x:p,y:h,width:g,height:y}=At(k=>{const w=k.nodeLookup.get(e);if(!w)return{node:void 0,x:0,y:0,width:0,height:0};const b=w.internals.userNode,{x:j,y:N}=w.internals.positionAbsolute,{width:S,height:C}=Po(b);return{node:b,x:j,y:N,width:S,height:C}},sn);return!f||f.hidden||!E3(f)?null:s.jsx(l,{x:p,y:h,width:g,height:y,style:f.style,selected:!!f.selected,className:r(f),color:t(f),borderRadius:o,strokeColor:n(f),strokeWidth:i,shapeRendering:a,onClick:d,id:f.id})}const nse=m.memo(tse);var rse=m.memo(ese);const sse=200,ose=150,ise=e=>!e.hidden,ase=e=>{const t={x:-e.transform[0]/e.transform[2],y:-e.transform[1]/e.transform[2],width:e.width/e.transform[2],height:e.height/e.transform[2]};return{viewBB:t,boundingRect:e.nodeLookup.size>0?N3(Kd(e.nodeLookup,{filter:ise}),t):t,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},lse="react-flow__minimap-desc";function ED({style:e,className:t,nodeStrokeColor:n,nodeColor:r,nodeClassName:o="",nodeBorderRadius:i=5,nodeStrokeWidth:a,nodeComponent:l,bgColor:d,maskColor:f,maskStrokeColor:p,maskStrokeWidth:h,position:g="bottom-right",onClick:y,onNodeClick:k,pannable:w=!1,zoomable:b=!1,ariaLabel:j,inversePan:N,zoomStep:S=1,offsetScale:C=5}){const D=on(),T=m.useRef(null),{boundingRect:R,viewBB:$,rfId:_,panZoom:U,translateExtent:I,flowWidth:F,flowHeight:M,ariaLabelConfig:A}=At(ase,sn),L=(e==null?void 0:e.width)??sse,z=(e==null?void 0:e.height)??ose,W=R.width/L,V=R.height/z,K=Math.max(W,V),O=K*L,B=K*z,G=C*K,H=R.x-(O-R.width)/2-G,Q=R.y-(B-R.height)/2-G,te=O+G*2,Z=B+G*2,ae=`${lse}-${_}`,ne=m.useRef(0),ue=m.useRef();ne.current=K,m.useEffect(()=>{if(T.current&&U)return ue.current=wte({domNode:T.current,panZoom:U,getTransform:()=>D.getState().transform,getViewScale:()=>ne.current}),()=>{var Se;(Se=ue.current)==null||Se.destroy()}},[U]),m.useEffect(()=>{var Se;(Se=ue.current)==null||Se.update({translateExtent:I,width:F,height:M,inversePan:N,pannable:w,zoomStep:S,zoomable:b})},[w,b,N,S,I,F,M]);const ye=y?Se=>{var we;const[ze,oe]=((we=ue.current)==null?void 0:we.pointer(Se))||[0,0];y(Se,{x:ze,y:oe})}:void 0,Ne=k?m.useCallback((Se,ze)=>{const oe=D.getState().nodeLookup.get(ze).internals.userNode;k(Se,oe)},[]):void 0,Re=j??A["minimap.ariaLabel"];return s.jsx(Yd,{position:g,style:{...e,"--xy-minimap-background-color-props":typeof d=="string"?d:void 0,"--xy-minimap-mask-background-color-props":typeof f=="string"?f:void 0,"--xy-minimap-mask-stroke-color-props":typeof p=="string"?p:void 0,"--xy-minimap-mask-stroke-width-props":typeof h=="number"?h*K:void 0,"--xy-minimap-node-background-color-props":typeof r=="string"?r:void 0,"--xy-minimap-node-stroke-color-props":typeof n=="string"?n:void 0,"--xy-minimap-node-stroke-width-props":typeof a=="number"?a:void 0},className:Sn(["react-flow__minimap",t]),"data-testid":"rf__minimap",children:s.jsxs("svg",{width:L,height:z,viewBox:`${H} ${Q} ${te} ${Z}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":ae,ref:T,onClick:ye,children:[Re&&s.jsx("title",{id:ae,children:Re}),s.jsx(rse,{onClick:Ne,nodeColor:r,nodeStrokeColor:n,nodeBorderRadius:i,nodeClassName:o,nodeStrokeWidth:a,nodeComponent:l}),s.jsx("path",{className:"react-flow__minimap-mask",d:`M${H-G},${Q-G}h${te+G*2}v${Z+G*2}h${-te-G*2}z
644
+ M${$.x},${$.y}h${$.width}v${$.height}h${-$.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}ED.displayName="MiniMap";m.memo(ED);const cse=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,use={[oc.Line]:"right",[oc.Handle]:"bottom-right"};function dse({nodeId:e,position:t,variant:n=oc.Handle,className:r,style:o=void 0,children:i,color:a,minWidth:l=10,minHeight:d=10,maxWidth:f=Number.MAX_VALUE,maxHeight:p=Number.MAX_VALUE,keepAspectRatio:h=!1,resizeDirection:g,autoScale:y=!0,shouldResize:k,onResizeStart:w,onResize:b,onResizeEnd:j}){const N=oD(),S=typeof e=="string"?e:N,C=on(),D=m.useRef(null),T=n===oc.Handle,R=At(m.useCallback(cse(T&&y),[T,y]),sn),$=m.useRef(null),_=t??use[n];m.useEffect(()=>{if(!(!D.current||!S))return $.current||($.current=$te({domNode:D.current,nodeId:S,getStoreItems:()=>{const{nodeLookup:I,transform:F,snapGrid:M,snapToGrid:A,nodeOrigin:L,domNode:z}=C.getState();return{nodeLookup:I,transform:F,snapGrid:M,snapToGrid:A,nodeOrigin:L,paneDomNode:z}},onChange:(I,F)=>{const{triggerNodeChanges:M,nodeLookup:A,parentLookup:L,nodeOrigin:z}=C.getState(),W=[],V={x:I.x,y:I.y},K=A.get(S);if(K&&K.expandParent&&K.parentId){const O=K.origin??z,B=I.width??K.measured.width??0,G=I.height??K.measured.height??0,H={id:K.id,parentId:K.parentId,rect:{width:B,height:G,...T3({x:I.x??K.position.x,y:I.y??K.position.y},{width:B,height:G},K.parentId,A,O)}},Q=R0([H],A,L,z);W.push(...Q),V.x=I.x?Math.max(O[0]*B,I.x):void 0,V.y=I.y?Math.max(O[1]*G,I.y):void 0}if(V.x!==void 0&&V.y!==void 0){const O={id:S,type:"position",position:{...V}};W.push(O)}if(I.width!==void 0&&I.height!==void 0){const B={id:S,type:"dimensions",resizing:!0,setAttributes:g?g==="horizontal"?"width":"height":!0,dimensions:{width:I.width,height:I.height}};W.push(B)}for(const O of F){const B={...O,type:"position"};W.push(B)}M(W)},onEnd:({width:I,height:F})=>{const M={id:S,type:"dimensions",resizing:!1,dimensions:{width:I,height:F}};C.getState().triggerNodeChanges([M])}})),$.current.update({controlPosition:_,boundaries:{minWidth:l,minHeight:d,maxWidth:f,maxHeight:p},keepAspectRatio:h,resizeDirection:g,onResizeStart:w,onResize:b,onResizeEnd:j,shouldResize:k}),()=>{var I;(I=$.current)==null||I.destroy()}},[_,l,d,f,p,h,w,b,j,k]);const U=_.split("-");return s.jsx("div",{className:Sn(["react-flow__resize-control","nodrag",...U,n,r]),ref:D,style:{...o,scale:R,...a&&{[T?"backgroundColor":"borderColor"]:a}},children:i})}m.memo(dse);var TD=Object.defineProperty,fse=(e,t,n)=>t in e?TD(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,pse=(e,t)=>{for(var n in t)TD(e,n,{get:t[n],enumerable:!0})},hse=(e,t,n)=>fse(e,t+"",n),RD={};pse(RD,{Graph:()=>Rs,alg:()=>P0,json:()=>PD,version:()=>xse});var mse=Object.defineProperty,AD=(e,t)=>{for(var n in t)mse(e,n,{get:t[n],enumerable:!0})},Rs=class{constructor(e){this._isDirected=!0,this._isMultigraph=!1,this._isCompound=!1,this._nodes={},this._in={},this._preds={},this._out={},this._sucs={},this._edgeObjs={},this._edgeLabels={},this._nodeCount=0,this._edgeCount=0,this._defaultNodeLabelFn=()=>{},this._defaultEdgeLabelFn=()=>{},e&&(this._isDirected="directed"in e?e.directed:!0,this._isMultigraph="multigraph"in e?e.multigraph:!1,this._isCompound="compound"in e?e.compound:!1),this._isCompound&&(this._parent={},this._children={},this._children["\0"]={})}isDirected(){return this._isDirected}isMultigraph(){return this._isMultigraph}isCompound(){return this._isCompound}setGraph(e){return this._label=e,this}graph(){return this._label}setDefaultNodeLabel(e){return typeof e!="function"?this._defaultNodeLabelFn=()=>e:this._defaultNodeLabelFn=e,this}nodeCount(){return this._nodeCount}nodes(){return Object.keys(this._nodes)}sources(){return this.nodes().filter(e=>Object.keys(this._in[e]).length===0)}sinks(){return this.nodes().filter(e=>Object.keys(this._out[e]).length===0)}setNodes(e,t){return e.forEach(n=>{t!==void 0?this.setNode(n,t):this.setNode(n)}),this}setNode(e,t){return e in this._nodes?(arguments.length>1&&(this._nodes[e]=t),this):(this._nodes[e]=arguments.length>1?t:this._defaultNodeLabelFn(e),this._isCompound&&(this._parent[e]="\0",this._children[e]={},this._children["\0"][e]=!0),this._in[e]={},this._preds[e]={},this._out[e]={},this._sucs[e]={},++this._nodeCount,this)}node(e){return this._nodes[e]}hasNode(e){return e in this._nodes}removeNode(e){if(e in this._nodes){let t=n=>this.removeEdge(this._edgeObjs[n]);delete this._nodes[e],this._isCompound&&(this._removeFromParentsChildList(e),delete this._parent[e],this.children(e).forEach(n=>{this.setParent(n)}),delete this._children[e]),Object.keys(this._in[e]).forEach(t),delete this._in[e],delete this._preds[e],Object.keys(this._out[e]).forEach(t),delete this._out[e],delete this._sucs[e],--this._nodeCount}return this}setParent(e,t){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(t===void 0)t="\0";else{t+="";for(let n=t;n!==void 0;n=this.parent(n))if(n===e)throw new Error("Setting "+t+" as parent of "+e+" would create a cycle");this.setNode(t)}return this.setNode(e),this._removeFromParentsChildList(e),this._parent[e]=t,this._children[t][e]=!0,this}parent(e){if(this._isCompound){let t=this._parent[e];if(t!=="\0")return t}}children(e="\0"){if(this._isCompound){let t=this._children[e];if(t)return Object.keys(t)}else{if(e==="\0")return this.nodes();if(this.hasNode(e))return[]}return[]}predecessors(e){let t=this._preds[e];if(t)return Object.keys(t)}successors(e){let t=this._sucs[e];if(t)return Object.keys(t)}neighbors(e){let t=this.predecessors(e);if(t){let n=new Set(t);for(let r of this.successors(e))n.add(r);return Array.from(n.values())}}isLeaf(e){let t;return this.isDirected()?t=this.successors(e):t=this.neighbors(e),t.length===0}filterNodes(e){let t=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});t.setGraph(this.graph()),Object.entries(this._nodes).forEach(([o,i])=>{e(o)&&t.setNode(o,i)}),Object.values(this._edgeObjs).forEach(o=>{t.hasNode(o.v)&&t.hasNode(o.w)&&t.setEdge(o,this.edge(o))});let n={},r=o=>{let i=this.parent(o);return!i||t.hasNode(i)?(n[o]=i??void 0,i??void 0):i in n?n[i]:r(i)};return this._isCompound&&t.nodes().forEach(o=>t.setParent(o,r(o))),t}setDefaultEdgeLabel(e){return typeof e!="function"?this._defaultEdgeLabelFn=()=>e:this._defaultEdgeLabelFn=e,this}edgeCount(){return this._edgeCount}edges(){return Object.values(this._edgeObjs)}setPath(e,t){return e.reduce((n,r)=>(t!==void 0?this.setEdge(n,r,t):this.setEdge(n,r),r)),this}setEdge(e,t,n,r){let o,i,a,l,d=!1;typeof e=="object"&&e!==null&&"v"in e?(o=e.v,i=e.w,a=e.name,arguments.length===2&&(l=t,d=!0)):(o=e,i=t,a=r,arguments.length>2&&(l=n,d=!0)),o=""+o,i=""+i,a!==void 0&&(a=""+a);let f=Eu(this._isDirected,o,i,a);if(f in this._edgeLabels)return d&&(this._edgeLabels[f]=l),this;if(a!==void 0&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(o),this.setNode(i),this._edgeLabels[f]=d?l:this._defaultEdgeLabelFn(o,i,a);let p=gse(this._isDirected,o,i,a);return o=p.v,i=p.w,Object.freeze(p),this._edgeObjs[f]=p,sE(this._preds[i],o),sE(this._sucs[o],i),this._in[i][f]=p,this._out[o][f]=p,this._edgeCount++,this}edge(e,t,n){let r=arguments.length===1?eb(this._isDirected,e):Eu(this._isDirected,e,t,n);return this._edgeLabels[r]}edgeAsObj(e,t,n){let r=arguments.length===1?this.edge(e):this.edge(e,t,n);return typeof r!="object"?{label:r}:r}hasEdge(e,t,n){return(arguments.length===1?eb(this._isDirected,e):Eu(this._isDirected,e,t,n))in this._edgeLabels}removeEdge(e,t,n){let r=arguments.length===1?eb(this._isDirected,e):Eu(this._isDirected,e,t,n),o=this._edgeObjs[r];if(o){let i=o.v,a=o.w;delete this._edgeLabels[r],delete this._edgeObjs[r],oE(this._preds[a],i),oE(this._sucs[i],a),delete this._in[a][r],delete this._out[i][r],this._edgeCount--}return this}inEdges(e,t){return this.isDirected()?this.filterEdges(this._in[e],e,t):this.nodeEdges(e,t)}outEdges(e,t){return this.isDirected()?this.filterEdges(this._out[e],e,t):this.nodeEdges(e,t)}nodeEdges(e,t){if(e in this._nodes)return this.filterEdges({...this._in[e],...this._out[e]},e,t)}_removeFromParentsChildList(e){delete this._children[this._parent[e]][e]}filterEdges(e,t,n){if(!e)return;let r=Object.values(e);return n?r.filter(o=>o.v===t&&o.w===n||o.v===n&&o.w===t):r}};function sE(e,t){e[t]?e[t]++:e[t]=1}function oE(e,t){e[t]!==void 0&&!--e[t]&&delete e[t]}function Eu(e,t,n,r){let o=""+t,i=""+n;if(!e&&o>i){let a=o;o=i,i=a}return o+""+i+""+(r===void 0?"\0":r)}function gse(e,t,n,r){let o=""+t,i=""+n;if(!e&&o>i){let l=o;o=i,i=l}let a={v:o,w:i};return r&&(a.name=r),a}function eb(e,t){return Eu(e,t.v,t.w,t.name)}var xse="4.0.1",PD={};AD(PD,{read:()=>wse,write:()=>yse});function yse(e){let t={options:{directed:e.isDirected(),multigraph:e.isMultigraph(),compound:e.isCompound()},nodes:bse(e),edges:vse(e)},n=e.graph();return n!==void 0&&(t.value=structuredClone(n)),t}function bse(e){return e.nodes().map(t=>{let n=e.node(t),r=e.parent(t),o={v:t};return n!==void 0&&(o.value=n),r!==void 0&&(o.parent=r),o})}function vse(e){return e.edges().map(t=>{let n=e.edge(t),r={v:t.v,w:t.w};return t.name!==void 0&&(r.name=t.name),n!==void 0&&(r.value=n),r})}function wse(e){let t=new Rs(e.options);return e.value!==void 0&&t.setGraph(e.value),e.nodes.forEach(n=>{t.setNode(n.v,n.value),n.parent&&t.setParent(n.v,n.parent)}),e.edges.forEach(n=>{t.setEdge({v:n.v,w:n.w,name:n.name},n.value)}),t}var P0={};AD(P0,{CycleException:()=>Oh,bellmanFord:()=>_D,components:()=>Sse,dijkstra:()=>Lh,dijkstraAll:()=>Ese,findCycles:()=>Tse,floydWarshall:()=>Ase,isAcyclic:()=>_se,postorder:()=>$se,preorder:()=>Ise,prim:()=>Mse,shortestPaths:()=>Lse,tarjan:()=>$D,topsort:()=>ID});var jse=()=>1;function _D(e,t,n,r){return kse(e,String(t),n||jse,r||function(o){return e.outEdges(o)})}function kse(e,t,n,r){let o={},i,a=0,l=e.nodes(),d=function(h){let g=n(h);o[h.v].distance+g<o[h.w].distance&&(o[h.w]={distance:o[h.v].distance+g,predecessor:h.v},i=!0)},f=function(){l.forEach(function(h){r(h).forEach(function(g){let y=g.v===h?g.v:g.w,k=y===g.v?g.w:g.v;d({v:y,w:k})})})};l.forEach(function(h){let g=h===t?0:Number.POSITIVE_INFINITY;o[h]={distance:g,predecessor:""}});let p=l.length;for(let h=1;h<p&&(i=!1,a++,f(),!!i);h++);if(a===p-1&&(i=!1,f(),i))throw new Error("The graph contains a negative weight cycle");return o}function Sse(e){let t={},n=[],r;function o(i){i in t||(t[i]=!0,r.push(i),e.successors(i).forEach(o),e.predecessors(i).forEach(o))}return e.nodes().forEach(function(i){r=[],o(i),r.length&&n.push(r)}),n}var DD=class{constructor(){this._arr=[],this._keyIndices={}}size(){return this._arr.length}keys(){return this._arr.map(e=>e.key)}has(e){return e in this._keyIndices}priority(e){let t=this._keyIndices[e];if(t!==void 0)return this._arr[t].priority}min(){if(this.size()===0)throw new Error("Queue underflow");return this._arr[0].key}add(e,t){let n=this._keyIndices,r=String(e);if(!(r in n)){let o=this._arr,i=o.length;return n[r]=i,o.push({key:r,priority:t}),this._decrease(i),!0}return!1}removeMin(){this._swap(0,this._arr.length-1);let e=this._arr.pop();return delete this._keyIndices[e.key],this._heapify(0),e.key}decrease(e,t){let n=this._keyIndices[e];if(n===void 0)throw new Error(`Key not found: ${e}`);let r=this._arr[n].priority;if(t>r)throw new Error(`New priority is greater than current priority. Key: ${e} Old: ${r} New: ${t}`);this._arr[n].priority=t,this._decrease(n)}_heapify(e){let t=this._arr,n=2*e,r=n+1,o=e;n<t.length&&(o=t[n].priority<t[o].priority?n:o,r<t.length&&(o=t[r].priority<t[o].priority?r:o),o!==e&&(this._swap(e,o),this._heapify(o)))}_decrease(e){let t=this._arr,n=t[e].priority,r;for(;e!==0&&(r=e>>1,!(t[r].priority<n));)this._swap(e,r),e=r}_swap(e,t){let n=this._arr,r=this._keyIndices,o=n[e],i=n[t];n[e]=i,n[t]=o,r[i.key]=e,r[o.key]=t}},Nse=()=>1;function Lh(e,t,n,r){let o=function(i){return e.outEdges(i)};return Cse(e,String(t),n||Nse,r||o)}function Cse(e,t,n,r){let o={},i=new DD,a,l,d=function(f){let p=f.v!==a?f.v:f.w,h=o[p],g=n(f),y=l.distance+g;if(g<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+f+" Weight: "+g);y<h.distance&&(h.distance=y,h.predecessor=a,i.decrease(p,y))};for(e.nodes().forEach(function(f){let p=f===t?0:Number.POSITIVE_INFINITY;o[f]={distance:p,predecessor:""},i.add(f,p)});i.size()>0&&(a=i.removeMin(),l=o[a],l.distance!==Number.POSITIVE_INFINITY);)r(a).forEach(d);return o}function Ese(e,t,n){return e.nodes().reduce(function(r,o){return r[o]=Lh(e,o,t,n),r},{})}function $D(e){let t=0,n=[],r={},o=[];function i(a){let l=r[a]={onStack:!0,lowlink:t,index:t++};if(n.push(a),e.successors(a).forEach(function(d){d in r?r[d].onStack&&(l.lowlink=Math.min(l.lowlink,r[d].index)):(i(d),l.lowlink=Math.min(l.lowlink,r[d].lowlink))}),l.lowlink===l.index){let d=[],f;do f=n.pop(),r[f].onStack=!1,d.push(f);while(a!==f);o.push(d)}}return e.nodes().forEach(function(a){a in r||i(a)}),o}function Tse(e){return $D(e).filter(function(t){return t.length>1||t.length===1&&e.hasEdge(t[0],t[0])})}var Rse=()=>1;function Ase(e,t,n){return Pse(e,t||Rse,n||function(r){return e.outEdges(r)})}function Pse(e,t,n){let r={},o=e.nodes();return o.forEach(function(i){r[i]={},r[i][i]={distance:0,predecessor:""},o.forEach(function(a){i!==a&&(r[i][a]={distance:Number.POSITIVE_INFINITY,predecessor:""})}),n(i).forEach(function(a){let l=a.v===i?a.w:a.v,d=t(a);r[i][l]={distance:d,predecessor:i}})}),o.forEach(function(i){let a=r[i];o.forEach(function(l){let d=r[l];o.forEach(function(f){let p=d[i],h=a[f],g=d[f],y=p.distance+h.distance;y<g.distance&&(g.distance=y,g.predecessor=h.predecessor)})})}),r}var Oh=class extends Error{constructor(...e){super(...e)}};function ID(e){let t={},n={},r=[];function o(i){if(i in n)throw new Oh;i in t||(n[i]=!0,t[i]=!0,e.predecessors(i).forEach(o),delete n[i],r.push(i))}if(e.sinks().forEach(o),Object.keys(t).length!==e.nodeCount())throw new Oh;return r}function _se(e){try{ID(e)}catch(t){if(t instanceof Oh)return!1;throw t}return!0}function Dse(e,t,n,r,o){Array.isArray(t)||(t=[t]);let i=(l=>{var d;return(d=e.isDirected()?e.successors(l):e.neighbors(l))!=null?d:[]}),a={};return t.forEach(function(l){if(!e.hasNode(l))throw new Error("Graph does not have node: "+l);o=MD(e,l,n==="post",a,i,r,o)}),o}function MD(e,t,n,r,o,i,a){return t in r||(r[t]=!0,n||(a=i(a,t)),o(t).forEach(function(l){a=MD(e,l,n,r,o,i,a)}),n&&(a=i(a,t))),a}function LD(e,t,n){return Dse(e,t,n,function(r,o){return r.push(o),r},[])}function $se(e,t){return LD(e,t,"post")}function Ise(e,t){return LD(e,t,"pre")}function Mse(e,t){let n=new Rs,r={},o=new DD,i;function a(d){let f=d.v===i?d.w:d.v,p=o.priority(f);if(p!==void 0){let h=t(d);h<p&&(r[f]=i,o.decrease(f,h))}}if(e.nodeCount()===0)return n;e.nodes().forEach(function(d){o.add(d,Number.POSITIVE_INFINITY),n.setNode(d)}),o.decrease(e.nodes()[0],0);let l=!1;for(;o.size()>0;){if(i=o.removeMin(),i in r)n.setEdge(i,r[i]);else{if(l)throw new Error("Input graph is not connected: "+e);l=!0}e.nodeEdges(i).forEach(a)}return n}function Lse(e,t,n,r){return Ose(e,t,n,r??(o=>{let i=e.outEdges(o);return i??[]}))}function Ose(e,t,n,r){if(n===void 0)return Lh(e,t,n,r);let o=!1,i=e.nodes();for(let a=0;a<i.length;a++){let l=r(i[a]);for(let d=0;d<l.length;d++){let f=l[d],p=f.v===i[a]?f.v:f.w,h=p===f.v?f.w:f.v;n({v:p,w:h})<0&&(o=!0)}if(o)return _D(e,t,n,r)}return Lh(e,t,n,r)}function Rc(e,t,n,r){let o=r;for(;e.hasNode(o);)o=_0(r);return n.dummy=t,e.setNode(o,n),o}function Fse(e){let t=new Rs().setGraph(e.graph());return e.nodes().forEach(n=>t.setNode(n,e.node(n))),e.edges().forEach(n=>{let r=t.edge(n.v,n.w)||{weight:0,minlen:1},o=e.edge(n);t.setEdge(n.v,n.w,{weight:r.weight+o.weight,minlen:Math.max(r.minlen,o.minlen)})}),t}function OD(e){let t=new Rs({multigraph:e.isMultigraph()}).setGraph(e.graph());return e.nodes().forEach(n=>{e.children(n).length||t.setNode(n,e.node(n))}),e.edges().forEach(n=>{t.setEdge(n,e.edge(n))}),t}function iE(e,t){let n=e.x,r=e.y,o=t.x-n,i=t.y-r,a=e.width/2,l=e.height/2;if(!o&&!i)throw new Error("Not possible to find intersection inside of the rectangle");let d,f;return Math.abs(i)*a>Math.abs(o)*l?(i<0&&(l=-l),d=l*o/i,f=l):(o<0&&(a=-a),d=a,f=a*i/o),{x:n+d,y:r+f}}function ng(e){let t=vd(zD(e)+1).map(()=>[]);return e.nodes().forEach(n=>{let r=e.node(n),o=r.rank;o!==void 0&&(t[o]||(t[o]=[]),t[o][r.order]=n)}),t}function zse(e){let t=e.nodes().map(r=>{let o=e.node(r).rank;return o===void 0?Number.MAX_VALUE:o}),n=qs(Math.min,t);e.nodes().forEach(r=>{let o=e.node(r);Object.hasOwn(o,"rank")&&(o.rank-=n)})}function Bse(e){let t=e.nodes().map(a=>e.node(a).rank).filter(a=>a!==void 0),n=qs(Math.min,t),r=[];e.nodes().forEach(a=>{let l=e.node(a).rank-n;r[l]||(r[l]=[]),r[l].push(a)});let o=0,i=e.graph().nodeRankFactor;Array.from(r).forEach((a,l)=>{a===void 0&&l%i!==0?--o:a!==void 0&&o&&a.forEach(d=>e.node(d).rank+=o)})}function aE(e,t,n,r){let o={width:0,height:0};return arguments.length>=4&&(o.rank=n,o.order=r),Rc(e,"border",o,t)}function Use(e,t=FD){let n=[];for(let r=0;r<e.length;r+=t){let o=e.slice(r,r+t);n.push(o)}return n}var FD=65535;function qs(e,t){if(t.length>FD){let n=Use(t);return e(...n.map(r=>e(...r)))}else return e(...t)}function zD(e){let t=e.nodes().map(n=>{let r=e.node(n).rank;return r===void 0?Number.MIN_VALUE:r});return qs(Math.max,t)}function Hse(e,t){let n={lhs:[],rhs:[]};return e.forEach(r=>{t(r)?n.lhs.push(r):n.rhs.push(r)}),n}function Vse(e,t){let n=Date.now();try{return t()}finally{console.log(e+" time: "+(Date.now()-n)+"ms")}}function Wse(e,t){return t()}var qse=0;function _0(e){let t=++qse;return e+(""+t)}function vd(e,t,n=1){t==null&&(t=e,e=0);let r=i=>i<t;n<0&&(r=i=>t<i);let o=[];for(let i=e;r(i);i+=n)o.push(i);return o}function Fh(e,t){let n={};for(let r of t)e[r]!==void 0&&(n[r]=e[r]);return n}function rg(e,t){let n;return typeof t=="string"?n=r=>r[t]:n=t,Object.entries(e).reduce((r,[o,i])=>(r[o]=n(i,o),r),{})}function Kse(e,t){return e.reduce((n,r,o)=>(n[r]=t[o],n),{})}var sg="\0",Gse=class{constructor(){hse(this,"_sentinel");let e={};e._next=e._prev=e,this._sentinel=e}dequeue(){let e=this._sentinel,t=e._prev;if(t!==e)return lE(t),t}enqueue(e){let t=this._sentinel;e._prev&&e._next&&lE(e),e._next=t._next,t._next._prev=e,t._next=e,e._prev=t}toString(){let e=[],t=this._sentinel,n=t._prev;for(;n!==t;)e.push(JSON.stringify(n,Yse)),n=n._prev;return"["+e.join(", ")+"]"}};function lE(e){e._prev._next=e._next,e._next._prev=e._prev,delete e._next,delete e._prev}function Yse(e,t){if(e!=="_next"&&e!=="_prev")return t}var Xse=Gse,Qse=()=>1;function Jse(e,t){if(e.nodeCount()<=1)return[];let n=eoe(e,t||Qse);return Zse(n.graph,n.buckets,n.zeroIdx).flatMap(r=>e.outEdges(r.v,r.w)||[])}function Zse(e,t,n){var r;let o=[],i=t[t.length-1],a=t[0],l;for(;e.nodeCount();){for(;l=a.dequeue();)tb(e,t,n,l);for(;l=i.dequeue();)tb(e,t,n,l);if(e.nodeCount()){for(let d=t.length-2;d>0;--d)if(l=(r=t[d])==null?void 0:r.dequeue(),l){o=o.concat(tb(e,t,n,l,!0)||[]);break}}}return o}function tb(e,t,n,r,o){let i=[],a=o?i:void 0;return(e.inEdges(r.v)||[]).forEach(l=>{let d=e.edge(l),f=e.node(l.v);o&&i.push({v:l.v,w:l.w}),f.out-=d,wv(t,n,f)}),(e.outEdges(r.v)||[]).forEach(l=>{let d=e.edge(l),f=l.w,p=e.node(f);p.in-=d,wv(t,n,p)}),e.removeNode(r.v),a}function eoe(e,t){let n=new Rs,r=0,o=0;e.nodes().forEach(l=>{n.setNode(l,{v:l,in:0,out:0})}),e.edges().forEach(l=>{let d=n.edge(l.v,l.w)||0,f=t(l),p=d+f;n.setEdge(l.v,l.w,p);let h=n.node(l.v),g=n.node(l.w);o=Math.max(o,h.out+=f),r=Math.max(r,g.in+=f)});let i=toe(o+r+3).map(()=>new Xse),a=r+1;return n.nodes().forEach(l=>{wv(i,a,n.node(l))}),{graph:n,buckets:i,zeroIdx:a}}function wv(e,t,n){var r,o,i;n.out?n.in?(i=e[n.out-n.in+t])==null||i.enqueue(n):(o=e[e.length-1])==null||o.enqueue(n):(r=e[0])==null||r.enqueue(n)}function toe(e){let t=[];for(let n=0;n<e;n++)t.push(n);return t}function noe(e){(e.graph().acyclicer==="greedy"?Jse(e,t(e)):roe(e)).forEach(n=>{let r=e.edge(n);e.removeEdge(n),r.forwardName=n.name,r.reversed=!0,e.setEdge(n.w,n.v,r,_0("rev"))});function t(n){return r=>n.edge(r).weight}}function roe(e){let t=[],n={},r={};function o(i){Object.hasOwn(r,i)||(r[i]=!0,n[i]=!0,e.outEdges(i).forEach(a=>{Object.hasOwn(n,a.w)?t.push(a):o(a.w)}),delete n[i])}return e.nodes().forEach(o),t}function soe(e){e.edges().forEach(t=>{let n=e.edge(t);if(n.reversed){e.removeEdge(t);let r=n.forwardName;delete n.reversed,delete n.forwardName,e.setEdge(t.w,t.v,n,r)}})}function ooe(e){e.graph().dummyChains=[],e.edges().forEach(t=>ioe(e,t))}function ioe(e,t){let n=t.v,r=e.node(n).rank,o=t.w,i=e.node(o).rank,a=t.name,l=e.edge(t),d=l.labelRank;if(i===r+1)return;e.removeEdge(t);let f,p,h;for(h=0,++r;r<i;++h,++r)l.points=[],p={width:0,height:0,edgeLabel:l,edgeObj:t,rank:r},f=Rc(e,"edge",p,"_d"),r===d&&(p.width=l.width,p.height=l.height,p.dummy="edge-label",p.labelpos=l.labelpos),e.setEdge(n,f,{weight:l.weight},a),h===0&&e.graph().dummyChains.push(f),n=f;e.setEdge(n,o,{weight:l.weight},a)}function aoe(e){e.graph().dummyChains.forEach(t=>{let n=e.node(t),r=n.edgeLabel,o;for(e.setEdge(n.edgeObj,r);n.dummy;)o=e.successors(t)[0],e.removeNode(t),r.points.push({x:n.x,y:n.y}),n.dummy==="edge-label"&&(r.x=n.x,r.y=n.y,r.width=n.width,r.height=n.height),t=o,n=e.node(t)})}function D0(e){let t={};function n(r){let o=e.node(r);if(Object.hasOwn(t,r))return o.rank;t[r]=!0;let i=e.outEdges(r),a=i?i.map(d=>d==null?Number.POSITIVE_INFINITY:n(d.w)-e.edge(d).minlen):[],l=qs(Math.min,a);return l===Number.POSITIVE_INFINITY&&(l=0),o.rank=l}e.sources().forEach(n)}function ac(e,t){return e.node(t.w).rank-e.node(t.v).rank-e.edge(t).minlen}var BD=loe;function loe(e){let t=new Rs({directed:!1}),n=e.nodes();if(n.length===0)throw new Error("Graph must have at least one node");let r=n[0],o=e.nodeCount();t.setNode(r,{});let i,a;for(;coe(t,e)<o&&(i=uoe(t,e),!!i);)a=t.hasNode(i.v)?ac(e,i):-ac(e,i),doe(t,e,a);return t}function coe(e,t){function n(r){let o=t.nodeEdges(r);o&&o.forEach(i=>{let a=i.v,l=r===a?i.w:a;!e.hasNode(l)&&!ac(t,i)&&(e.setNode(l,{}),e.setEdge(r,l,{}),n(l))})}return e.nodes().forEach(n),e.nodeCount()}function uoe(e,t){return t.edges().reduce((n,r)=>{let o=Number.POSITIVE_INFINITY;return e.hasNode(r.v)!==e.hasNode(r.w)&&(o=ac(t,r)),o<n[0]?[o,r]:n},[Number.POSITIVE_INFINITY,null])[1]}function doe(e,t,n){e.nodes().forEach(r=>t.node(r).rank+=n)}var{preorder:foe,postorder:poe}=P0,hoe=Aa;Aa.initLowLimValues=I0;Aa.initCutValues=$0;Aa.calcCutValue=UD;Aa.leaveEdge=VD;Aa.enterEdge=WD;Aa.exchangeEdges=qD;function Aa(e){e=Fse(e),D0(e);let t=BD(e);I0(t),$0(t,e);let n,r;for(;n=VD(t);)r=WD(t,e,n),qD(t,e,n,r)}function $0(e,t){let n=poe(e,e.nodes());n=n.slice(0,n.length-1),n.forEach(r=>moe(e,t,r))}function moe(e,t,n){let r=e.node(n).parent,o=e.edge(n,r);o.cutvalue=UD(e,t,n)}function UD(e,t,n){let r=e.node(n).parent,o=!0,i=t.edge(n,r),a=0;i||(o=!1,i=t.edge(r,n)),a=i.weight;let l=t.nodeEdges(n);return l&&l.forEach(d=>{let f=d.v===n,p=f?d.w:d.v;if(p!==r){let h=f===o,g=t.edge(d).weight;if(a+=h?g:-g,xoe(e,n,p)){let y=e.edge(n,p).cutvalue;a+=h?-y:y}}}),a}function I0(e,t){arguments.length<2&&(t=e.nodes()[0]),HD(e,{},1,t)}function HD(e,t,n,r,o){let i=n,a=e.node(r);t[r]=!0;let l=e.neighbors(r);return l&&l.forEach(d=>{Object.hasOwn(t,d)||(n=HD(e,t,n,d,r))}),a.low=i,a.lim=n++,o?a.parent=o:delete a.parent,n}function VD(e){return e.edges().find(t=>e.edge(t).cutvalue<0)}function WD(e,t,n){let r=n.v,o=n.w;t.hasEdge(r,o)||(r=n.w,o=n.v);let i=e.node(r),a=e.node(o),l=i,d=!1;return i.lim>a.lim&&(l=a,d=!0),t.edges().filter(f=>d===cE(e,e.node(f.v),l)&&d!==cE(e,e.node(f.w),l)).reduce((f,p)=>ac(t,p)<ac(t,f)?p:f)}function qD(e,t,n,r){let o=n.v,i=n.w;e.removeEdge(o,i),e.setEdge(r.v,r.w,{}),I0(e),$0(e,t),goe(e,t)}function goe(e,t){let n=e.nodes().find(o=>!e.node(o).parent);if(!n)return;let r=foe(e,[n]);r=r.slice(1),r.forEach(o=>{let i=e.node(o).parent,a=t.edge(o,i),l=!1;a||(a=t.edge(i,o),l=!0),t.node(o).rank=t.node(i).rank+(l?a.minlen:-a.minlen)})}function xoe(e,t,n){return e.hasEdge(t,n)}function cE(e,t,n){return n.low<=t.lim&&t.lim<=n.lim}var yoe=boe;function boe(e){let t=e.graph().ranker;if(typeof t=="function")return t(e);switch(t){case"network-simplex":uE(e);break;case"tight-tree":woe(e);break;case"longest-path":voe(e);break;case"none":break;default:uE(e)}}var voe=D0;function woe(e){D0(e),BD(e)}function uE(e){hoe(e)}var joe=koe;function koe(e){let t=Noe(e);e.graph().dummyChains.forEach(n=>{let r=e.node(n),o=r.edgeObj,i=Soe(e,t,o.v,o.w),a=i.path,l=i.lca,d=0,f=a[d],p=!0;for(;n!==o.w;){if(r=e.node(n),p){for(;(f=a[d])!==l&&e.node(f).maxRank<r.rank;)d++;f===l&&(p=!1)}if(!p){for(;d<a.length-1&&e.node(a[d+1]).minRank<=r.rank;)d++;f=a[d]}f!==void 0&&e.setParent(n,f),n=e.successors(n)[0]}})}function Soe(e,t,n,r){let o=[],i=[],a=Math.min(t[n].low,t[r].low),l=Math.max(t[n].lim,t[r].lim),d;d=n;do d=e.parent(d),o.push(d);while(d&&(t[d].low>a||l>t[d].lim));let f=d,p=r;for(;(p=e.parent(p))!==f;)i.push(p);return{path:o.concat(i.reverse()),lca:f}}function Noe(e){let t={},n=0;function r(o){let i=n;e.children(o).forEach(r),t[o]={low:i,lim:n++}}return e.children(sg).forEach(r),t}function Coe(e){let t=Rc(e,"root",{},"_root"),n=Eoe(e),r=Object.values(n),o=qs(Math.max,r)-1,i=2*o+1;e.graph().nestingRoot=t,e.edges().forEach(l=>e.edge(l).minlen*=i);let a=Toe(e)+1;e.children(sg).forEach(l=>KD(e,t,i,a,o,n,l)),e.graph().nodeRankFactor=i}function KD(e,t,n,r,o,i,a){var l;let d=e.children(a);if(!d.length){a!==t&&e.setEdge(t,a,{weight:0,minlen:n});return}let f=aE(e,"_bt"),p=aE(e,"_bb"),h=e.node(a);e.setParent(f,a),h.borderTop=f,e.setParent(p,a),h.borderBottom=p,d.forEach(g=>{var y;KD(e,t,n,r,o,i,g);let k=e.node(g),w=k.borderTop?k.borderTop:g,b=k.borderBottom?k.borderBottom:g,j=k.borderTop?r:2*r,N=w!==b?1:o-((y=i[a])!=null?y:0)+1;e.setEdge(f,w,{weight:j,minlen:N,nestingEdge:!0}),e.setEdge(b,p,{weight:j,minlen:N,nestingEdge:!0})}),e.parent(a)||e.setEdge(t,f,{weight:0,minlen:o+((l=i[a])!=null?l:0)})}function Eoe(e){let t={};function n(r,o){let i=e.children(r);i&&i.length&&i.forEach(a=>n(a,o+1)),t[r]=o}return e.children(sg).forEach(r=>n(r,1)),t}function Toe(e){return e.edges().reduce((t,n)=>t+e.edge(n).weight,0)}function Roe(e){let t=e.graph();e.removeNode(t.nestingRoot),delete t.nestingRoot,e.edges().forEach(n=>{e.edge(n).nestingEdge&&e.removeEdge(n)})}var Aoe=Poe;function Poe(e){function t(n){let r=e.children(n),o=e.node(n);if(r.length&&r.forEach(t),Object.hasOwn(o,"minRank")){o.borderLeft=[],o.borderRight=[];for(let i=o.minRank,a=o.maxRank+1;i<a;++i)dE(e,"borderLeft","_bl",n,o,i),dE(e,"borderRight","_br",n,o,i)}}e.children(sg).forEach(t)}function dE(e,t,n,r,o,i){let a={width:0,height:0,rank:i,borderType:t},l=o[t][i-1],d=Rc(e,"border",a,n);o[t][i]=d,e.setParent(d,r),l&&e.setEdge(l,d,{weight:1})}function _oe(e){var t;let n=(t=e.graph().rankdir)==null?void 0:t.toLowerCase();(n==="lr"||n==="rl")&&GD(e)}function Doe(e){var t;let n=(t=e.graph().rankdir)==null?void 0:t.toLowerCase();(n==="bt"||n==="rl")&&$oe(e),(n==="lr"||n==="rl")&&(Ioe(e),GD(e))}function GD(e){e.nodes().forEach(t=>fE(e.node(t))),e.edges().forEach(t=>fE(e.edge(t)))}function fE(e){let t=e.width;e.width=e.height,e.height=t}function $oe(e){e.nodes().forEach(t=>nb(e.node(t))),e.edges().forEach(t=>{var n;let r=e.edge(t);(n=r.points)==null||n.forEach(nb),Object.hasOwn(r,"y")&&nb(r)})}function nb(e){e.y=-e.y}function Ioe(e){e.nodes().forEach(t=>rb(e.node(t))),e.edges().forEach(t=>{var n;let r=e.edge(t);(n=r.points)==null||n.forEach(rb),Object.hasOwn(r,"x")&&rb(r)})}function rb(e){let t=e.x;e.x=e.y,e.y=t}function Moe(e){let t={},n=e.nodes().filter(l=>!e.children(l).length),r=n.map(l=>e.node(l).rank),o=qs(Math.max,r),i=vd(o+1).map(()=>[]);function a(l){if(t[l])return;t[l]=!0;let d=e.node(l);i[d.rank].push(l);let f=e.successors(l);f&&f.forEach(a)}return n.sort((l,d)=>e.node(l).rank-e.node(d).rank).forEach(a),i}function Loe(e,t){let n=0;for(let r=1;r<t.length;++r)n+=Ooe(e,t[r-1],t[r]);return n}function Ooe(e,t,n){let r=Kse(n,n.map((f,p)=>p)),o=t.flatMap(f=>{let p=e.outEdges(f);return p?p.map(h=>({pos:r[h.w],weight:e.edge(h).weight})).sort((h,g)=>h.pos-g.pos):[]}),i=1;for(;i<n.length;)i<<=1;let a=2*i-1;i-=1;let l=new Array(a).fill(0),d=0;return o.forEach(f=>{let p=f.pos+i;l[p]+=f.weight;let h=0;for(;p>0;)p%2&&(h+=l[p+1]),p=p-1>>1,l[p]+=f.weight;d+=f.weight*h}),d}function Foe(e,t=[]){return t.map(n=>{let r=e.inEdges(n);if(!r||!r.length)return{v:n};{let o=r.reduce((i,a)=>{let l=e.edge(a),d=e.node(a.v);return{sum:i.sum+l.weight*d.order,weight:i.weight+l.weight}},{sum:0,weight:0});return{v:n,barycenter:o.sum/o.weight,weight:o.weight}}})}function zoe(e,t){let n={};e.forEach((o,i)=>{let a={indegree:0,in:[],out:[],vs:[o.v],i};o.barycenter!==void 0&&(a.barycenter=o.barycenter,a.weight=o.weight),n[o.v]=a}),t.edges().forEach(o=>{let i=n[o.v],a=n[o.w];i!==void 0&&a!==void 0&&(a.indegree++,i.out.push(a))});let r=Object.values(n).filter(o=>!o.indegree);return Boe(r)}function Boe(e){let t=[];function n(o){return i=>{i.merged||(i.barycenter===void 0||o.barycenter===void 0||i.barycenter>=o.barycenter)&&Uoe(o,i)}}function r(o){return i=>{i.in.push(o),--i.indegree===0&&e.push(i)}}for(;e.length;){let o=e.pop();t.push(o),o.in.reverse().forEach(n(o)),o.out.forEach(r(o))}return t.filter(o=>!o.merged).map(o=>Fh(o,["vs","i","barycenter","weight"]))}function Uoe(e,t){let n=0,r=0;e.weight&&(n+=e.barycenter*e.weight,r+=e.weight),t.weight&&(n+=t.barycenter*t.weight,r+=t.weight),e.vs=t.vs.concat(e.vs),e.barycenter=n/r,e.weight=r,e.i=Math.min(t.i,e.i),t.merged=!0}function Hoe(e,t){let n=Hse(e,p=>Object.hasOwn(p,"barycenter")),r=n.lhs,o=n.rhs.sort((p,h)=>h.i-p.i),i=[],a=0,l=0,d=0;r.sort(Voe(!!t)),d=pE(i,o,d),r.forEach(p=>{d+=p.vs.length,i.push(p.vs),a+=p.barycenter*p.weight,l+=p.weight,d=pE(i,o,d)});let f={vs:i.flat(1)};return l&&(f.barycenter=a/l,f.weight=l),f}function pE(e,t,n){let r;for(;t.length&&(r=t[t.length-1]).i<=n;)t.pop(),e.push(r.vs),n++;return n}function Voe(e){return(t,n)=>t.barycenter<n.barycenter?-1:t.barycenter>n.barycenter?1:e?n.i-t.i:t.i-n.i}function YD(e,t,n,r){let o=e.children(t),i=e.node(t),a=i?i.borderLeft:void 0,l=i?i.borderRight:void 0,d={};a&&(o=o.filter(g=>g!==a&&g!==l));let f=Foe(e,o);f.forEach(g=>{if(e.children(g.v).length){let y=YD(e,g.v,n,r);d[g.v]=y,Object.hasOwn(y,"barycenter")&&qoe(g,y)}});let p=zoe(f,n);Woe(p,d);let h=Hoe(p,r);if(a&&l){h.vs=[a,h.vs,l].flat(1);let g=e.predecessors(a);if(g&&g.length){let y=e.node(g[0]),k=e.predecessors(l),w=e.node(k[0]);Object.hasOwn(h,"barycenter")||(h.barycenter=0,h.weight=0),h.barycenter=(h.barycenter*h.weight+y.order+w.order)/(h.weight+2),h.weight+=2}}return h}function Woe(e,t){e.forEach(n=>{n.vs=n.vs.flatMap(r=>t[r]?t[r].vs:r)})}function qoe(e,t){e.barycenter!==void 0?(e.barycenter=(e.barycenter*e.weight+t.barycenter*t.weight)/(e.weight+t.weight),e.weight+=t.weight):(e.barycenter=t.barycenter,e.weight=t.weight)}function Koe(e,t,n,r){r||(r=e.nodes());let o=Goe(e),i=new Rs({compound:!0}).setGraph({root:o}).setDefaultNodeLabel(a=>e.node(a));return r.forEach(a=>{let l=e.node(a),d=e.parent(a);if(l.rank===t||l.minRank<=t&&t<=l.maxRank){i.setNode(a),i.setParent(a,d||o);let f=e[n](a);f&&f.forEach(p=>{let h=p.v===a?p.w:p.v,g=i.edge(h,a),y=g!==void 0?g.weight:0;i.setEdge(h,a,{weight:e.edge(p).weight+y})}),Object.hasOwn(l,"minRank")&&i.setNode(a,{borderLeft:l.borderLeft[t],borderRight:l.borderRight[t]})}}),i}function Goe(e){let t;for(;e.hasNode(t=_0("_root")););return t}function Yoe(e,t,n){let r={},o;n.forEach(i=>{let a=e.parent(i),l,d;for(;a;){if(l=e.parent(a),l?(d=r[l],r[l]=a):(d=o,o=a),d&&d!==a){t.setEdge(d,a);return}a=l}})}function XD(e,t={}){if(typeof t.customOrder=="function"){t.customOrder(e,XD);return}let n=zD(e),r=hE(e,vd(1,n+1),"inEdges"),o=hE(e,vd(n-1,-1,-1),"outEdges"),i=Moe(e);if(mE(e,i),t.disableOptimalOrderHeuristic)return;let a=Number.POSITIVE_INFINITY,l,d=t.constraints||[];for(let f=0,p=0;p<4;++f,++p){Xoe(f%2?r:o,f%4>=2,d),i=ng(e);let h=Loe(e,i);h<a?(p=0,l=Object.assign({},i),a=h):h===a&&(l=structuredClone(i))}mE(e,l)}function hE(e,t,n){let r=new Map,o=(i,a)=>{r.has(i)||r.set(i,[]),r.get(i).push(a)};for(let i of e.nodes()){let a=e.node(i);if(typeof a.rank=="number"&&o(a.rank,i),typeof a.minRank=="number"&&typeof a.maxRank=="number")for(let l=a.minRank;l<=a.maxRank;l++)l!==a.rank&&o(l,i)}return t.map(function(i){return Koe(e,i,n,r.get(i)||[])})}function Xoe(e,t,n){let r=new Rs;e.forEach(function(o){n.forEach(l=>r.setEdge(l.left,l.right));let i=o.graph().root,a=YD(o,i,r,t);a.vs.forEach((l,d)=>o.node(l).order=d),Yoe(o,r,a.vs)})}function mE(e,t){Object.values(t).forEach(n=>n.forEach((r,o)=>e.node(r).order=o))}function Qoe(e,t){let n={};function r(o,i){let a=0,l=0,d=o.length,f=i[i.length-1];return i.forEach((p,h)=>{let g=Zoe(e,p),y=g?e.node(g).order:d;(g||p===f)&&(i.slice(l,h+1).forEach(k=>{let w=e.predecessors(k);w&&w.forEach(b=>{let j=e.node(b),N=j.order;(N<a||y<N)&&!(j.dummy&&e.node(k).dummy)&&QD(n,b,k)})}),l=h+1,a=y)}),i}return t.length&&t.reduce(r),n}function Joe(e,t){let n={};function r(i,a,l,d,f){vd(a,l).forEach(p=>{let h=i[p];if(h!==void 0&&e.node(h).dummy){let g=e.predecessors(h);g&&g.forEach(y=>{if(y===void 0)return;let k=e.node(y);k.dummy&&(k.order<d||k.order>f)&&QD(n,y,h)})}})}function o(i,a){let l=-1,d=-1,f=0;return a.forEach((p,h)=>{if(e.node(p).dummy==="border"){let g=e.predecessors(p);if(g&&g.length){let y=g[0];if(y===void 0)return;d=e.node(y).order,r(a,f,h,l,d),f=h,l=d}}r(a,f,a.length,d,i.length)}),a}return t.length&&t.reduce(o),n}function Zoe(e,t){if(e.node(t).dummy){let n=e.predecessors(t);if(n)return n.find(r=>e.node(r).dummy)}}function QD(e,t,n){if(t>n){let o=t;t=n,n=o}let r=e[t];r||(e[t]=r={}),r[n]=!0}function eie(e,t,n){if(t>n){let o=t;t=n,n=o}let r=e[t];return r!==void 0&&Object.hasOwn(r,n)}function tie(e,t,n,r){let o={},i={},a={};return t.forEach(l=>{l.forEach((d,f)=>{o[d]=d,i[d]=d,a[d]=f})}),t.forEach(l=>{let d=-1;l.forEach(f=>{let p=r(f);if(p&&p.length){let h=p.sort((y,k)=>{let w=a[y],b=a[k];return(w!==void 0?w:0)-(b!==void 0?b:0)}),g=(h.length-1)/2;for(let y=Math.floor(g),k=Math.ceil(g);y<=k;++y){let w=h[y];if(w===void 0)continue;let b=a[w];if(b!==void 0&&i[f]===f&&d<b&&!eie(n,f,w)){let j=o[w];j!==void 0&&(i[w]=f,i[f]=o[f]=j,d=b)}}}})}),{root:o,align:i}}function nie(e,t,n,r,o=!1){let i={},a=rie(e,t,n,o),l=o?"borderLeft":"borderRight";function d(y,k){let w=a.nodes().slice(),b={},j=w.pop();for(;j;){if(b[j])y(j);else{b[j]=!0,w.push(j);for(let N of k(j))w.push(N)}j=w.pop()}}function f(y){let k=a.inEdges(y);k?i[y]=k.reduce((w,b)=>{var j;let N=(j=i[b.v])!=null?j:0,S=a.edge(b);return Math.max(w,N+(S!==void 0?S:0))},0):i[y]=0}function p(y){let k=a.outEdges(y),w=Number.POSITIVE_INFINITY;k&&(w=k.reduce((j,N)=>{let S=i[N.w],C=a.edge(N);return Math.min(j,(S!==void 0?S:0)-(C!==void 0?C:0))},Number.POSITIVE_INFINITY));let b=e.node(y);w!==Number.POSITIVE_INFINITY&&b.borderType!==l&&(i[y]=Math.max(i[y]!==void 0?i[y]:0,w))}function h(y){return a.predecessors(y)||[]}function g(y){return a.successors(y)||[]}return d(f,h),d(p,g),Object.keys(r).forEach(y=>{var k;let w=n[y];w!==void 0&&(i[y]=(k=i[w])!=null?k:0)}),i}function rie(e,t,n,r){let o=new Rs,i=e.graph(),a=lie(i.nodesep,i.edgesep,r);return t.forEach(l=>{let d;l.forEach(f=>{let p=n[f];if(p!==void 0){if(o.setNode(p),d!==void 0){let h=n[d];if(h!==void 0){let g=o.edge(h,p);o.setEdge(h,p,Math.max(a(e,f,d),g||0))}}d=f}})}),o}function sie(e,t){return Object.values(t).reduce((n,r)=>{let o=Number.NEGATIVE_INFINITY,i=Number.POSITIVE_INFINITY;Object.entries(r).forEach(([l,d])=>{let f=cie(e,l)/2;o=Math.max(d+f,o),i=Math.min(d-f,i)});let a=o-i;return a<n[0]&&(n=[a,r]),n},[Number.POSITIVE_INFINITY,null])[1]}function oie(e,t){let n=Object.values(t),r=qs(Math.min,n),o=qs(Math.max,n);["u","d"].forEach(i=>{["l","r"].forEach(a=>{let l=i+a,d=e[l];if(!d||d===t)return;let f=Object.values(d),p=r-qs(Math.min,f);a!=="l"&&(p=o-qs(Math.max,f)),p&&(e[l]=rg(d,h=>h+p))})})}function iie(e,t=void 0){let n=e.ul;return n?rg(n,(r,o)=>{var i,a;if(t){let d=t.toLowerCase(),f=e[d];if(f&&f[o]!==void 0)return f[o]}let l=Object.values(e).map(d=>{let f=d[o];return f!==void 0?f:0}).sort((d,f)=>d-f);return(((i=l[1])!=null?i:0)+((a=l[2])!=null?a:0))/2}):{}}function aie(e){let t=ng(e),n=Object.assign(Qoe(e,t),Joe(e,t)),r={},o;["u","d"].forEach(a=>{o=a==="u"?t:Object.values(t).reverse(),["l","r"].forEach(l=>{l==="r"&&(o=o.map(p=>Object.values(p).reverse()));let d=tie(e,o,n,p=>(a==="u"?e.predecessors(p):e.successors(p))||[]),f=nie(e,o,d.root,d.align,l==="r");l==="r"&&(f=rg(f,p=>-p)),r[a+l]=f})});let i=sie(e,r);return oie(r,i),iie(r,e.graph().align)}function lie(e,t,n){return(r,o,i)=>{let a=r.node(o),l=r.node(i),d=0,f;if(d+=a.width/2,Object.hasOwn(a,"labelpos"))switch(a.labelpos.toLowerCase()){case"l":f=-a.width/2;break;case"r":f=a.width/2;break}if(f&&(d+=n?f:-f),f=void 0,d+=(a.dummy?t:e)/2,d+=(l.dummy?t:e)/2,d+=l.width/2,Object.hasOwn(l,"labelpos"))switch(l.labelpos.toLowerCase()){case"l":f=l.width/2;break;case"r":f=-l.width/2;break}return f&&(d+=n?f:-f),d}}function cie(e,t){return e.node(t).width}function uie(e){e=OD(e),die(e),Object.entries(aie(e)).forEach(([t,n])=>e.node(t).x=n)}function die(e){let t=ng(e),n=e.graph(),r=n.ranksep,o=n.rankalign,i=0;t.forEach(a=>{let l=a.reduce((d,f)=>{var p;let h=(p=e.node(f).height)!=null?p:0;return d>h?d:h},0);a.forEach(d=>{let f=e.node(d);o==="top"?f.y=i+f.height/2:o==="bottom"?f.y=i+l-f.height/2:f.y=i+l/2}),i+=l+r})}function fie(e,t={}){let n=t.debugTiming?Vse:Wse;return n("layout",()=>{let r=n(" buildLayoutGraph",()=>jie(e));return n(" runLayout",()=>pie(r,n,t)),n(" updateInputGraph",()=>hie(e,r)),r})}function pie(e,t,n){t(" makeSpaceForEdgeLabels",()=>kie(e)),t(" removeSelfEdges",()=>_ie(e)),t(" acyclic",()=>noe(e)),t(" nestingGraph.run",()=>Coe(e)),t(" rank",()=>yoe(OD(e))),t(" injectEdgeLabelProxies",()=>Sie(e)),t(" removeEmptyRanks",()=>Bse(e)),t(" nestingGraph.cleanup",()=>Roe(e)),t(" normalizeRanks",()=>zse(e)),t(" assignRankMinMax",()=>Nie(e)),t(" removeEdgeLabelProxies",()=>Cie(e)),t(" normalize.run",()=>ooe(e)),t(" parentDummyChains",()=>joe(e)),t(" addBorderSegments",()=>Aoe(e)),t(" order",()=>XD(e,n)),t(" insertSelfEdges",()=>Die(e)),t(" adjustCoordinateSystem",()=>_oe(e)),t(" position",()=>uie(e)),t(" positionSelfEdges",()=>$ie(e)),t(" removeBorderNodes",()=>Pie(e)),t(" normalize.undo",()=>aoe(e)),t(" fixupEdgeLabelCoords",()=>Rie(e)),t(" undoCoordinateSystem",()=>Doe(e)),t(" translateGraph",()=>Eie(e)),t(" assignNodeIntersects",()=>Tie(e)),t(" reversePoints",()=>Aie(e)),t(" acyclic.undo",()=>soe(e))}function hie(e,t){e.nodes().forEach(n=>{let r=e.node(n),o=t.node(n);r&&(r.x=o.x,r.y=o.y,r.order=o.order,r.rank=o.rank,t.children(n).length&&(r.width=o.width,r.height=o.height))}),e.edges().forEach(n=>{let r=e.edge(n),o=t.edge(n);r.points=o.points,Object.hasOwn(o,"x")&&(r.x=o.x,r.y=o.y)}),e.graph().width=t.graph().width,e.graph().height=t.graph().height}var mie=["nodesep","edgesep","ranksep","marginx","marginy"],gie={ranksep:50,edgesep:20,nodesep:50,rankdir:"TB",rankalign:"center"},xie=["acyclicer","ranker","rankdir","align","rankalign"],yie=["width","height","rank"],gE={width:0,height:0},bie=["minlen","weight","width","height","labeloffset"],vie={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},wie=["labelpos"];function jie(e){let t=new Rs({multigraph:!0,compound:!0}),n=ob(e.graph());return t.setGraph(Object.assign({},gie,sb(n,mie),Fh(n,xie))),e.nodes().forEach(r=>{let o=ob(e.node(r)),i=sb(o,yie);Object.keys(gE).forEach(l=>{i[l]===void 0&&(i[l]=gE[l])}),t.setNode(r,i);let a=e.parent(r);a!==void 0&&t.setParent(r,a)}),e.edges().forEach(r=>{let o=ob(e.edge(r));t.setEdge(r,Object.assign({},vie,sb(o,bie),Fh(o,wie)))}),t}function kie(e){let t=e.graph();t.ranksep/=2,e.edges().forEach(n=>{let r=e.edge(n);r.minlen*=2,r.labelpos.toLowerCase()!=="c"&&(t.rankdir==="TB"||t.rankdir==="BT"?r.width+=r.labeloffset:r.height+=r.labeloffset)})}function Sie(e){e.edges().forEach(t=>{let n=e.edge(t);if(n.width&&n.height){let r=e.node(t.v),o={rank:(e.node(t.w).rank-r.rank)/2+r.rank,e:t};Rc(e,"edge-proxy",o,"_ep")}})}function Nie(e){let t=0;e.nodes().forEach(n=>{let r=e.node(n);r.borderTop&&(r.minRank=e.node(r.borderTop).rank,r.maxRank=e.node(r.borderBottom).rank,t=Math.max(t,r.maxRank))}),e.graph().maxRank=t}function Cie(e){e.nodes().forEach(t=>{let n=e.node(t);if(n.dummy==="edge-proxy"){let r=n;e.edge(r.e).labelRank=n.rank,e.removeNode(t)}})}function Eie(e){let t=Number.POSITIVE_INFINITY,n=0,r=Number.POSITIVE_INFINITY,o=0,i=e.graph(),a=i.marginx||0,l=i.marginy||0;function d(f){let p=f.x,h=f.y,g=f.width,y=f.height;t=Math.min(t,p-g/2),n=Math.max(n,p+g/2),r=Math.min(r,h-y/2),o=Math.max(o,h+y/2)}e.nodes().forEach(f=>d(e.node(f))),e.edges().forEach(f=>{let p=e.edge(f);Object.hasOwn(p,"x")&&d(p)}),t-=a,r-=l,e.nodes().forEach(f=>{let p=e.node(f);p.x-=t,p.y-=r}),e.edges().forEach(f=>{let p=e.edge(f);p.points.forEach(h=>{h.x-=t,h.y-=r}),Object.hasOwn(p,"x")&&(p.x-=t),Object.hasOwn(p,"y")&&(p.y-=r)}),i.width=n-t+a,i.height=o-r+l}function Tie(e){e.edges().forEach(t=>{let n=e.edge(t),r=e.node(t.v),o=e.node(t.w),i,a;n.points?(i=n.points[0],a=n.points[n.points.length-1]):(n.points=[],i=o,a=r),n.points.unshift(iE(r,i)),n.points.push(iE(o,a))})}function Rie(e){e.edges().forEach(t=>{let n=e.edge(t);if(Object.hasOwn(n,"x"))switch((n.labelpos==="l"||n.labelpos==="r")&&(n.width-=n.labeloffset),n.labelpos){case"l":n.x-=n.width/2+n.labeloffset;break;case"r":n.x+=n.width/2+n.labeloffset;break}})}function Aie(e){e.edges().forEach(t=>{let n=e.edge(t);n.reversed&&n.points.reverse()})}function Pie(e){e.nodes().forEach(t=>{if(e.children(t).length){let n=e.node(t),r=e.node(n.borderTop),o=e.node(n.borderBottom),i=e.node(n.borderLeft[n.borderLeft.length-1]),a=e.node(n.borderRight[n.borderRight.length-1]);n.width=Math.abs(a.x-i.x),n.height=Math.abs(o.y-r.y),n.x=i.x+n.width/2,n.y=r.y+n.height/2}}),e.nodes().forEach(t=>{e.node(t).dummy==="border"&&e.removeNode(t)})}function _ie(e){e.edges().forEach(t=>{if(t.v===t.w){let n=e.node(t.v);n.selfEdges||(n.selfEdges=[]),n.selfEdges.push({e:t,label:e.edge(t)}),e.removeEdge(t)}})}function Die(e){ng(e).forEach(t=>{let n=0;t.forEach((r,o)=>{let i=e.node(r);i.order=o+n,(i.selfEdges||[]).forEach(a=>{Rc(e,"selfedge",{width:a.label.width,height:a.label.height,rank:i.rank,order:o+ ++n,e:a.e,label:a.label},"_se")}),delete i.selfEdges})})}function $ie(e){e.nodes().forEach(t=>{let n=e.node(t);if(n.dummy==="selfedge"){let r=n,o=e.node(r.e.v),i=o.x+o.width/2,a=o.y,l=n.x-i,d=o.height/2;e.setEdge(r.e,r.label),e.removeNode(t),r.label.points=[{x:i+2*l/3,y:a-d},{x:i+5*l/6,y:a-d},{x:i+l,y:a},{x:i+5*l/6,y:a+d},{x:i+2*l/3,y:a+d}],r.label.x=n.x,r.label.y=n.y}})}function sb(e,t){return rg(Fh(e,t),Number)}function ob(e){let t={};return e&&Object.entries(e).forEach(([n,r])=>{typeof n=="string"&&(n=n.toLowerCase()),t[n]=r}),t}/*! For license information please see dagre.esm.js.LEGAL.txt */function Iie(e,t,n={}){const r=new Map;if(e.length===0)return r;const o=n.nodeWidth??150,i=n.nodeHeight??64,a=new RD.Graph;a.setGraph({rankdir:n.direction??"LR",nodesep:40,ranksep:90}),a.setDefaultEdgeLabel(()=>({}));const l=new Set;for(const d of e)l.add(d.id),a.setNode(d.id,{width:o,height:i});for(const d of t)l.has(d.from)&&l.has(d.to)&&a.setEdge(d.from,d.to);fie(a);for(const d of l){const f=a.node(d);f&&r.set(d,{x:f.x-o/2,y:f.y-i/2})}return r}function Mie({data:e,selected:t}){const{label:n,statusId:r,color:o,terminal:i,orphan:a,missing:l}=e;return s.jsxs("div",{className:Ce("min-w-[120px] rounded-md border px-3 py-2 text-xs shadow-sm transition-colors",l?"border-dashed border-error-foreground/60 bg-error/10 text-error-foreground":a?"border-warning-foreground/70 bg-warning/10":"border-border/70 bg-card",t&&"ring-2 ring-primary/50"),children:[s.jsx(ic,{type:"target",position:ct.Left,className:"!h-2 !w-2 !bg-muted-foreground"}),s.jsxs("div",{className:"flex items-center gap-1.5",children:[!l&&s.jsx("span",{className:"inline-block h-2.5 w-2.5 shrink-0 rounded-full border border-border/50",style:o?{backgroundColor:o}:void 0}),s.jsx("span",{className:"font-medium text-foreground",children:n}),l&&s.jsx(CL,{className:"h-3 w-3 shrink-0","aria-label":"Undefined status"}),a&&!l&&s.jsx(Kh,{className:"h-3 w-3 shrink-0 text-warning-foreground","aria-label":"Orphan status"})]}),s.jsxs("div",{className:"mt-0.5 flex items-center gap-1 font-mono text-[10px] text-muted-foreground",children:[s.jsx("span",{children:r}),i&&s.jsxs("span",{className:"inline-flex items-center gap-0.5 text-muted-foreground",title:"Terminal status",children:[s.jsx(FL,{className:"h-2.5 w-2.5"})," terminal"]})]}),l&&s.jsx("div",{className:"mt-1 text-[10px] font-medium",children:"undefined status"}),a&&!l&&s.jsx("div",{className:"mt-1 text-[10px] text-warning-foreground",children:"no incoming edge"}),s.jsx(ic,{type:"source",position:ct.Right,className:"!h-2 !w-2 !bg-muted-foreground"})]})}const Lie={status:Mie},Oie="oklch(var(--muted-foreground))",Fie="oklch(var(--primary))",zie="oklch(var(--error-foreground))";function Bie({onRelayout:e}){const{fitView:t}=Zm();return s.jsx(Yd,{position:"top-right",children:s.jsxs("button",{type:"button",onClick:()=>{e(),requestAnimationFrame(()=>t({padding:.2}))},className:"shell-action inline-flex items-center gap-1 text-xs",title:"Reset node positions to the automatic layout",children:[s.jsx(VL,{className:"h-3 w-3"}),"Re-layout"]})})}function xE({nodes:e,edges:t,selectedRowKey:n,editable:r,onSelectEdge:o,onCreateEdge:i,onDeleteEdge:a}){const[l,d,f]=Lre([]),[p,h]=Ore([]),g=m.useRef(new Map),[y,k]=m.useState(0),w=m.useMemo(()=>JSON.stringify(e.map(R=>[R.id,R.label,R.color??"",R.terminal,R.orphan,R.missing])),[e]);m.useEffect(()=>{const R=Iie(e,t,{direction:"LR"}),$=new Set(e.map(_=>_.id));for(const _ of g.current.keys())$.has(_)||g.current.delete(_);d(e.map(_=>{let U=g.current.get(_.id);return U||(U=R.get(_.id)??{x:0,y:0},g.current.set(_.id,U)),{id:_.id,type:"status",position:U,data:{label:_.label,statusId:_.id,color:_.color,terminal:_.terminal,orphan:_.orphan,missing:_.missing},draggable:!0,deletable:!1}}))},[w,y,d]);const b=m.useCallback(()=>{g.current.clear(),k(R=>R+1)},[]),j=m.useMemo(()=>t.map(R=>`${R.rowKey}:${R.from}>${R.to}:${R.command}:${R.requiresReason?1:0}:${R.undefinedRef?1:0}`).join("|"),[t]);m.useEffect(()=>{h(t.map(R=>{const $=R.rowKey===n,_=R.undefinedRef?zie:$?Fie:Oie;return{id:R.rowKey,source:R.from,target:R.to,label:R.requiresReason?`${R.command} (reason)`:R.command,selected:$,deletable:r,markerEnd:{type:gd.ArrowClosed,color:_},style:{stroke:_,strokeWidth:$?2.5:1.5},labelStyle:{fill:"oklch(var(--foreground))",fontSize:11,fontFamily:"ui-monospace, monospace"},labelBgStyle:{fill:"oklch(var(--card))"},labelBgPadding:[4,2],labelBgBorderRadius:4}}))},[j,n,r,h]);const N=m.useCallback(R=>{for(const $ of R)$.type==="position"&&$.position&&g.current.set($.id,$.position);f(R)},[f]),S=m.useCallback(R=>{r&&R.source&&R.target&&i(R.source,R.target)},[r,i]),C=m.useCallback(R=>{if(r)for(const $ of R)a($.id)},[r,a]),D=m.useCallback((R,$)=>o($.id),[o]),T=m.useCallback(({edges:R})=>{R.length===1&&o(R[0].id)},[o]);return s.jsx("div",{className:"h-[460px] w-full overflow-hidden rounded-md border border-border/60 bg-background",children:s.jsxs(Mre,{nodes:l,edges:p,nodeTypes:Lie,onNodesChange:N,onConnect:S,onEdgesDelete:C,onEdgeClick:D,onSelectionChange:T,nodesConnectable:r,deleteKeyCode:r?["Backspace","Delete"]:null,elementsSelectable:!0,fitView:!0,fitViewOptions:{padding:.2},proOptions:{hideAttribution:!1},children:[s.jsx(Hre,{gap:16}),s.jsx(Xre,{showInteractive:!1}),s.jsx(Bie,{onRelayout:b})]})})}const Np="rounded-md border border-border/60 bg-background px-2 py-1 text-sm focus:border-primary focus:outline-none focus:ring-2 focus:ring-primary/30 disabled:opacity-60";function Uie({transition:e,statuses:t,knownCommands:n,onChange:r,onDelete:o,disabled:i}){const a=m.useRef(null);if(m.useEffect(()=>{var y;e&&!i&&((y=a.current)==null||y.focus())},[e==null?void 0:e.rowKey]),!e)return s.jsx("div",{className:"surface-panel flex h-full min-h-[120px] items-center justify-center px-4 py-6 text-center text-xs text-muted-foreground",children:"Select a transition edge to edit it, or use “Add transition”."});const l=e,d=new Set(t.map(y=>y.id)),f=!d.has(l.from),p=!d.has(l.to);function h(y){r({...l,...y})}function g(y,k,w,b){const j=d.has(y);return s.jsxs("select",{ref:b,value:y,onChange:N=>k(N.target.value),disabled:i,"aria-label":w,className:`${Np} w-full font-mono`,children:[!j&&y!==""&&s.jsxs("option",{value:y,children:[y," (undefined)"]}),y===""&&s.jsx("option",{value:"",children:"Select a status…"}),t.map(N=>s.jsxs("option",{value:N.id,children:[N.label," (",N.id,")"]},N.id))]})}return s.jsxs("div",{className:"surface-panel space-y-3 px-4 py-3",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("h4",{className:"text-sm font-semibold text-foreground",children:"Edit transition"}),s.jsxs("button",{type:"button",onClick:()=>o(l.rowKey),disabled:i,className:"inline-flex items-center gap-1 rounded-md px-2 py-1 text-xs text-error-foreground hover:bg-error/10","aria-label":"Delete transition",children:[s.jsx(bn,{className:"h-3.5 w-3.5"}),"Delete"]})]}),s.jsxs("label",{className:"block space-y-1",children:[s.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"From status"}),g(l.from,y=>h({from:y}),"From status",a),f&&s.jsxs("span",{className:"block text-[11px] text-error-foreground",children:["“",l.from,"” is not a defined status"]})]}),s.jsxs("label",{className:"block space-y-1",children:[s.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"Command"}),s.jsx("input",{type:"text",list:"transition-inspector-commands",value:l.command,onChange:y=>h({command:y.target.value}),disabled:i,placeholder:"command",className:`${Np} w-full font-mono`})]}),s.jsxs("label",{className:"block space-y-1",children:[s.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"To status"}),g(l.to,y=>h({to:y}),"To status"),p&&s.jsxs("span",{className:"block text-[11px] text-error-foreground",children:["“",l.to,"” is not a defined status"]})]}),s.jsxs("label",{className:"block space-y-1",children:[s.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"Label (optional)"}),s.jsx("input",{type:"text",value:l.label,onChange:y=>h({label:y.target.value}),disabled:i,placeholder:"label",className:`${Np} w-full`})]}),s.jsxs("label",{className:"block space-y-1",children:[s.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"Description (optional)"}),s.jsx("textarea",{value:l.description,onChange:y=>h({description:y.target.value}),disabled:i,placeholder:"description",rows:2,className:`${Np} w-full resize-y`})]}),s.jsxs("label",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[s.jsx("button",{type:"button",role:"switch","aria-checked":l.requiresReason,"aria-label":"Requires reason",onClick:()=>h({requiresReason:!l.requiresReason}),disabled:i,className:`relative inline-flex h-5 w-9 shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors ${l.requiresReason?"bg-primary":"bg-muted"}`,children:s.jsx("span",{className:`pointer-events-none inline-block h-4 w-4 rounded-full bg-background shadow-sm transition-transform ${l.requiresReason?"translate-x-4":"translate-x-0"}`})}),"Requires a reason"]}),s.jsx("datalist",{id:"transition-inspector-commands",children:n.map(y=>s.jsx("option",{value:y},y))})]})}function yE(){return s.jsxs("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-1 text-[11px] text-muted-foreground",children:[s.jsxs("span",{className:"inline-flex items-center gap-1",children:[s.jsx("span",{className:"inline-block h-2.5 w-4 rounded",style:{backgroundColor:"oklch(var(--error-foreground))"}}),"references an undefined status"]}),s.jsxs("span",{className:"inline-flex items-center gap-1",children:[s.jsx("span",{className:"inline-block h-2.5 w-2.5 rounded-full border-2 border-dashed border-error-foreground/70"}),"ghost (undefined) status"]}),s.jsxs("span",{className:"inline-flex items-center gap-1",children:[s.jsx("span",{className:"inline-block h-2.5 w-2.5 rounded-sm border border-warning-foreground/70 bg-warning/10"}),"orphan status (no incoming edge)"]})]})}function Hie({value:e,customizing:t,statuses:n,knownCommands:r,onChange:o,onCustomize:i,disabled:a}){var S;const l=m.useMemo(()=>new Set(n.map(C=>C.id)),[n]),[d,f]=m.useState(null),p=m.useMemo(()=>iv(F_()),[]),h=m.useMemo(()=>QN(p,n),[p,n]);if(!t&&e.length===0)return s.jsxs(Qe,{title:"Transitions",description:"Which commands move an assignment between statuses, as a state-machine graph. Showing the built-in defaults.",actions:s.jsx("button",{type:"button",onClick:i,disabled:a,className:"shell-action text-xs",children:"Customize defaults"}),children:[s.jsx(yE,{}),s.jsx(xE,{nodes:h.nodes,edges:h.edges,selectedRowKey:null,editable:!1,onSelectEdge:()=>{},onCreateEdge:()=>{},onDeleteEdge:()=>{}})]});const g=z_(e,l),y=QN(e,n),k=e.find(C=>C.rowKey===d)??null;function w(C){o(e.map(D=>D.rowKey===C.rowKey?C:D))}function b(C){o(e.filter(D=>D.rowKey!==C)),d===C&&f(null)}function j(C,D){const T={rowKey:O_(),from:C,command:r[0]??"",to:D,label:"",description:"",requiresReason:!1};o([...e,T]),f(T.rowKey)}const N=((S=n[0])==null?void 0:S.id)??"";return s.jsxs(Qe,{title:"Transitions",description:"Statuses are nodes; commands are labeled directed edges. Drag node-to-node to add a transition, or use “Add transition”, then edit it in the panel.",actions:s.jsxs("button",{type:"button",onClick:()=>j(N,N),disabled:a||n.length===0,className:"shell-action text-xs inline-flex items-center gap-1 disabled:opacity-50",children:[s.jsx(It,{className:"h-3 w-3"}),"Add transition"]}),children:[g.length>0&&s.jsxs("div",{className:"mb-3 rounded-md border border-error-foreground/30 bg-error/10 px-3 py-2 text-xs text-error-foreground",children:[s.jsx("p",{className:"font-medium",children:"These transitions won't save until fixed:"}),s.jsx("ul",{className:"mt-1 list-disc space-y-0.5 pl-4",children:g.map((C,D)=>s.jsx("li",{children:C},D))})]}),s.jsx(yE,{}),s.jsxs("div",{className:"flex flex-col gap-3 lg:flex-row",children:[s.jsx("div",{className:"min-w-0 flex-1",children:s.jsx(xE,{nodes:y.nodes,edges:y.edges,selectedRowKey:d,editable:!a,onSelectEdge:f,onCreateEdge:j,onDeleteEdge:b})}),s.jsx("div",{className:"w-full shrink-0 lg:w-80",children:s.jsx(Uie,{transition:k,statuses:n,knownCommands:r,onChange:w,onDelete:b,disabled:a})})]})]})}function Vie(e){const t=[];e.transitions>0&&t.push({tab:"Transitions",count:e.transitions}),e.derive>0&&t.push({tab:"Derive Rules",count:e.derive}),e.facts>0&&t.push({tab:"Facts",count:e.facts});const n=e.transitions+e.derive+e.facts,r=n===0?"Unsaved changes":`Fix errors in ${t.map(o=>o.tab).join(", ")} to save`;return{total:n,offending:t,message:r}}function Wie(){var ge;const[e,t]=m.useState(!0),[n,r]=m.useState(null),[o,i]=m.useState(!1),[a,l]=m.useState([]),[d,f]=m.useState(!1),[p,h]=m.useState(null),[g,y]=m.useState(!1),[k,w]=m.useState(new Set),[b,j]=m.useState(new Map),[N,S]=m.useState({open:!1}),[C,D]=m.useState([]),[T,R]=m.useState([]),[$,_]=m.useState({open:!1}),[U,I]=m.useState(()=>zy(Ip)),[F,M]=m.useState(!1),[A,L]=m.useState(!1),[z,W]=m.useState(!1),[V,K]=m.useState([]),[O,B]=m.useState(!1),[G,H]=m.useState([]),[Q,te]=m.useState("statuses"),Z=m.useCallback(pe=>{const se=$X(pe);l(se),i(pe.custom),w(new Set(se.map(je=>je.id))),j(new Map),D(pe.rawFacts??[]),R([]),I(zy(pe.derive??Ip)),M(pe.deriveCustom??!1),L(!1),W(!1),K(iv(pe.transitions??[])),B(pe.transitionsCustom??!1),H(pe.knownCommands??[]),y(!1)},[]),ae=m.useCallback(async()=>{try{const pe=await fetch("/api/config/statuses");if(!pe.ok)throw new Error(`HTTP ${pe.status}`);const se=await pe.json();Z(se),r(null)}catch(pe){r(pe instanceof Error?pe.message:"Failed to load config")}finally{t(!1)}},[Z]);m.useEffect(()=>{ae()},[ae]);function ne(){setTimeout(()=>h(null),3e3)}const ue=m.useMemo(()=>a.map(pe=>({id:pe.id,label:pe.label,color:pe.color,terminal:pe.terminal})),[a]),ye=m.useMemo(()=>new Set(a.map(pe=>pe.id)),[a]),Ne=m.useMemo(()=>YX(C),[C]),Re=m.useMemo(()=>Pw(Ne),[Ne]),Se=m.useMemo(()=>IX(C),[C]),ze=m.useMemo(()=>{try{return L_(ov(U),a,Re)}catch{return["derive rules are malformed"]}},[U,a,Re]),oe=m.useMemo(()=>O?z_(V,ye):[],[V,O,ye]),we=Se.length+ze.length+oe.length,ke=m.useCallback(pe=>{D(pe),y(!0)},[]),$e=m.useCallback(pe=>{I(pe),L(!0),W(!1),M(!0),y(!0)},[]),Ue=m.useCallback(()=>{I(zy(Ip)),W(!0),L(!0),M(!1),y(!0)},[]),nt=m.useCallback(pe=>{K(pe),y(!0)},[]),He=m.useCallback(()=>{K(pe=>pe.length>0?pe:iv(sQ(F_(),ye))),B(!0),y(!0)},[ye]);async function at(pe=T){f(!0),h(null);try{const{body:se}=CX({statuses:a,order:a.map(X=>X.id),pendingResolutions:b,facts:C,factRemovalAcks:pe,derive:z?null:A?ov(U):void 0,transitions:O?rQ(V):void 0}),je=await fetch("/api/config/statuses",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(se)});if(!je.ok){const X=await je.json().catch(()=>null);if(je.status===409&&(X==null?void 0:X.error)==="unresolved-fact-references"&&X.references){_({open:!0,references:X.references}),f(!1);return}if((X==null?void 0:X.error)==="invalid-derive")throw new Error(`Invalid derive rules: ${(X.problems??[]).join("; ")}`);if((X==null?void 0:X.error)==="invalid-transitions")throw new Error(`Invalid transitions: ${(X.problems??[]).join("; ")}`);if((X==null?void 0:X.error)==="invalid-facts")throw new Error(`Invalid facts: ${(X.problems??[]).join("; ")}`);if(je.status===409&&(X==null?void 0:X.error)==="unresolved-orphans"){const ve=Array.isArray(X.unresolved)?X.unresolved.map(Ve=>Ve.id).join(", "):"";throw new Error(`Cannot save — these statuses have assignments that need a resolution: ${ve}. Click the trash icon on each row to choose remap or delete.`)}if(je.status===409&&(X==null?void 0:X.error)==="concurrent-edit"){const ve=X.applied?` (${X.applied.remapped} remapped, ${X.applied.deleted} deleted before the conflict)`:"";h({type:"error",message:`Concurrent edit detected${ve}: ${X.cause??"an assignment moved to a still-dropped status during save"}. Refreshing — please re-resolve.`}),await ae();return}if(je.status===500&&(X==null?void 0:X.error)==="config-write-failed"&&(X!=null&&X.applied)){const{remapped:ve,deleted:Ve}=X.applied,ft=X.message?`: ${X.message}`:"";h({type:"error",message:`Resolutions applied (${ve} remapped, ${Ve} deleted) but the status config write failed${ft}. Click Save again to retry.`}),await ae();return}throw(X==null?void 0:X.error)==="invalid-remap-target"?new Error(`Invalid remap target (${X.reason}): ${X.id} → ${X.target}.`):(X==null?void 0:X.error)==="duplicate-resolution-ids"?new Error(`Duplicate resolution ids: ${(X.ids??[]).join(", ")}`):(X==null?void 0:X.error)==="stale-resolution"?new Error(`Stale resolution for id "${X.id??"?"}".`):(X==null?void 0:X.error)==="malformed-resolutions"?new Error(`Malformed resolutions: ${X.message??"unknown"}`):(X==null?void 0:X.error)==="remap-write-failed"||(X==null?void 0:X.error)==="delete-failed"||(X==null?void 0:X.error)==="scan-failed"?new Error(`${X.error}: ${X.cause??"unknown"}`):new Error((X==null?void 0:X.error)??`Save failed (HTTP ${je.status})`)}const Ae=await je.json();Z(Ae),L1();const qe=Ae.applied?` (${Ae.applied.remapped} remapped, ${Ae.applied.deleted} deleted)`:"";h({type:"success",message:`Status config saved${qe}`}),ne()}catch(se){h({type:"error",message:se instanceof Error?se.message:"Save failed"})}finally{f(!1)}}async function xt(){f(!0),h(null);try{const pe=await fetch("/api/config/statuses",{method:"DELETE"});if(!pe.ok)throw new Error("Reset failed");const se=await pe.json();Z(se),L1(),h({type:"success",message:"Reset to defaults"}),ne()}catch(pe){h({type:"error",message:pe instanceof Error?pe.message:"Reset failed"})}finally{f(!1)}}function lt(pe,se,je){l(Ae=>{const qe=[...Ae];return qe[pe]={...qe[pe],[se]:je},qe}),y(!0)}function ot(){const pe=`status_${a.length+1}`;l(se=>[...se,{rowKey:D_(),id:pe,label:"New Status",description:"",color:"",terminal:!1}]),y(!0)}function le(pe){l(se=>{const je=se.filter(qe=>qe.id!==pe),Ae=new Set(je.map(qe=>qe.id));return j(qe=>WN(qe,Ae)),je}),y(!0)}async function xe(pe){const se=a[pe].id,je=EX(se,U,V),Ae=TX(se,U);if(!k.has(se)){if(je.length===0){le(se);return}S({open:!0,affected:{id:se,count:0,truncated:!1,assignments:[]},pendingId:se,ruleReferences:je,headlineReferences:Ae});return}try{const qe=await fetch(`/api/config/statuses/affected/${encodeURIComponent(se)}`);if(!qe.ok)throw new Error(`HTTP ${qe.status}`);const X=await qe.json();if(X.count===0&&je.length===0){le(se);return}S({open:!0,affected:X,pendingId:se,ruleReferences:je,headlineReferences:Ae})}catch(qe){h({type:"error",message:`Could not check affected assignments for "${se}": ${qe instanceof Error?qe.message:String(qe)}`})}}function Oe(pe,se){if(!N.open)return;const{pendingId:je,affected:Ae,ruleReferences:qe}=N;if(je!==pe.id){S({open:!1});return}if(!a.some(X=>X.id===je)){h({type:"error",message:`Row for "${je}" was already removed — modal action ignored.`}),S({open:!1});return}pe.mode==="remap"?(I(X=>RX(X,je,se)),K(X=>AX(X,je,se))):(I(X=>PX(X,je,se)),K(X=>_X(X,je))),qe.some(X=>X.section!=="transitions")&&(L(!0),M(!0)),l(X=>{const ve=X.filter(ft=>ft.id!==je),Ve=new Set(ve.map(ft=>ft.id));return j(ft=>{const et=WN(ft,Ve),yt=new Map(et);return Ae.count>0&&yt.set(je,pe),yt}),ve}),y(!0),S({open:!1})}function We(){if(!$.open)return;const pe=$.references.map(je=>je.factName),se=Array.from(new Set([...T,...pe]));R(se),_({open:!1}),at(se)}function Ge(){S({open:!1})}return e?s.jsx(jt,{label:"Loading workflow..."}):n?s.jsx(Rt,{error:n}):s.jsx(fa,{children:s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:`flex items-center justify-between rounded-lg border px-4 py-3 text-sm ${o?"border-primary/30 bg-primary/5 text-primary":"border-border/60 bg-muted/30 text-muted-foreground"}`,children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(_v,{className:"h-4 w-4"}),o?"Using custom status configuration from ~/.syntaur/config.md":"Using default status configuration"]}),s.jsxs("button",{className:"shell-action text-xs",onClick:xt,disabled:d||!o&&!g,children:[s.jsx(Qs,{className:"h-3 w-3"}),"Reset to Defaults"]})]}),p&&s.jsx("div",{className:`rounded-lg border px-4 py-2 text-sm ${p.type==="success"?"border-success-foreground/30 bg-success text-success-foreground":"border-error-foreground/30 bg-error text-error-foreground"}`,children:p.message}),s.jsx(_m,{value:Q,onValueChange:te,items:[{value:"statuses",label:"Statuses",content:s.jsx(NX,{statuses:a,savedStatusIds:k,onUpdate:lt,onAdd:ot,onRemove:xe,onReorder:pe=>{l(pe),y(!0)}})},{value:"transitions",label:"Transitions",problemCount:oe.length,content:s.jsx(Hie,{value:V,customizing:O,statuses:ue,knownCommands:G,onChange:nt,onCustomize:He,disabled:d})},{value:"derive",label:"Derive Rules",problemCount:ze.length,content:s.jsx(JX,{value:U,deriveCustom:F,statuses:ue,acceptedFacts:Ne,onChange:$e,onReset:Ue,disabled:d})},{value:"facts",label:"Facts",problemCount:Se.length,content:s.jsx(zX,{rows:C,onChange:ke,saving:d})}]}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsxs("button",{className:"shell-action bg-primary/10 text-primary hover:bg-primary/20 disabled:opacity-50",onClick:()=>void at(),disabled:d||!g||we>0,children:[s.jsx(qh,{className:"h-3.5 w-3.5"}),d?"Saving...":"Save Configuration"]}),g&&s.jsxs(s.Fragment,{children:[s.jsx("button",{className:"shell-action text-xs",onClick:()=>{t(!0),ae()},disabled:d,children:"Discard Changes"}),s.jsx("span",{className:"text-xs text-muted-foreground",children:Vie({transitions:oe.length,derive:ze.length,facts:Se.length}).message})]})]}),N.open&&s.jsx(wX,{open:N.open,affected:{...N.affected,label:((ge=a.find(pe=>pe.id===N.affected.id))==null?void 0:ge.label)??N.affected.id},remaining:a.filter(pe=>pe.id!==N.affected.id&&k.has(pe.id)).map(pe=>({id:pe.id,label:pe.label})),ruleReferences:N.ruleReferences,headlineReferences:N.headlineReferences,onResolve:Oe,onCancel:Ge}),s.jsx(jX,{open:$.open,references:$.open?$.references:[],onConfirm:We,onCancel:()=>{_({open:!1}),f(!1)}})]})})}const bo=e=>`${e.workspace}::${e.id}`;function bE(e){if(e.includes("/")){const[t,n]=e.split("/");return`/projects/${t}/assignments/${n}`}return`/assignments/${e}`}function qie(){var qe;const{data:e,loading:t,error:n,refetch:r}=A2(),{toast:o,showToast:i,dismissToast:a}=wr(),l=Ht(),[d,f]=m.useState(""),p=m.useRef(null);Ei("list:todos");const[h,g]=m.useState(""),[y,k]=m.useState(""),[w,b]=m.useState(""),[j,N]=m.useState("_global"),[S,C]=m.useState(null),[D,T]=m.useState(null),[R,$]=m.useState(new Set),[_,U]=m.useState(!1),I=m.useRef(null),[F,M]=m.useState(null),A=n0("all"),[L,z]=m.useState(null),[W,V]=m.useState(null),K=m.useRef(null);m.useEffect(()=>{let X=!1;return(async()=>{try{const ve=await fetch("/api/projects");if(!ve.ok)return;const Ve=await ve.json();X||M(Ve.filter(ft=>!ft.archived))}catch{}})(),()=>{X=!0}},[]);async function O(X,ve){X.stopPropagation(),await zd(ve)&&(C(ve),setTimeout(()=>C(Ve=>Ve===ve?null:Ve),1500))}const B=m.useMemo(()=>{if(!(e!=null&&e.workspaces))return[];const X=[];for(const ve of e.workspaces)for(const Ve of ve.items)X.push({...Ve,workspace:ve.workspace});return X},[e]),G=m.useMemo(()=>{const X=new Set;for(const ve of B)for(const Ve of ve.tags)X.add(Ve);return Array.from(X).sort()},[B]),H=m.useMemo(()=>{let X=B;if(d.trim()){const ve=d.toLowerCase();X=X.filter(Ve=>Ve.description.toLowerCase().includes(ve)||Ve.tags.some(ft=>ft.toLowerCase().includes(ve))||Ve.id.includes(ve))}return h&&(X=X.filter(ve=>ve.status===h)),y&&(X=X.filter(ve=>ve.tags.includes(y))),X},[B,d,h,y]);m.useEffect(()=>{$(new Set),I.current=null},[d,h,y]);const Q=m.useMemo(()=>H.filter(X=>R.has(bo(X))),[H,R]),te=H.length>0&&Q.length===H.length,Z=Q.length>0&&!te,ae=m.useMemo(()=>{if(Q.length===0)return null;const X=new Set(Q.map(ve=>ve.workspace));return X.size===1?[...X][0]:null},[Q]),ne=m.useMemo(()=>{if(!ae||!F)return;const X=F.filter(ve=>ve.workspace===ae);return X.length===1?X[0].slug:void 0},[ae,F]),ue=((qe=Q[0])==null?void 0:qe.description)??"",ye=m.useMemo(()=>{if(ae)return null;const X=new Map;for(const ve of Q)X.has(ve.workspace)||X.set(ve.workspace,[]),X.get(ve.workspace).push(ve.id);return Array.from(X,([ve,Ve])=>({workspace:ve,todoIds:Ve}))},[Q,ae]),Ne=ae?{kind:"workspace",workspace:ae}:{kind:"aggregate",groups:ye??[]};function Re(X,ve,Ve){const ft=bo(X),et=!!(Ve&&"shiftKey"in Ve&&Ve.shiftKey),yt=I.current?ot.findIndex(mt=>bo(mt)===I.current):-1;if(et&&yt!==-1){const mt=Math.min(yt,ve),he=Math.max(yt,ve);$(Ee=>{const Ye=new Set(Ee);for(let Nt=mt;Nt<=he;Nt++){const Mt=ot[Nt];Mt&&Ye.add(bo(Mt))}return Ye})}else $(mt=>{const he=new Set(mt);return he.has(ft)?he.delete(ft):he.add(ft),he});I.current=ft}function Se(){$(X=>{const ve=new Set(X);if(te)for(const Ve of H)ve.delete(bo(Ve));else for(const Ve of H)ve.add(bo(Ve));return ve})}function ze(){$(new Set),I.current=null}function oe(X){ze(),r(),X!=null&&X.assignmentRef&&l(bE(X.assignmentRef))}const we=m.useMemo(()=>{if(!(e!=null&&e.workspaces))return{open:0,in_progress:0,completed:0,blocked:0,total:0};const X={open:0,in_progress:0,completed:0,blocked:0,total:0};for(const ve of e.workspaces)X.open+=ve.counts.open,X.in_progress+=ve.counts.in_progress,X.completed+=ve.counts.completed,X.blocked+=ve.counts.blocked,X.total+=ve.counts.total;return X},[e]);function ke(X){i(X instanceof Error?X.message:"Action failed","error")}async function $e(){if(w.trim())try{await Bv(j,w.trim()),b(""),r(),i("Todo added","success")}catch(X){ke(X)}}async function Ue(X,ve,Ve){try{switch(Ve){case"open":await $2(X,ve);break;case"in_progress":await D2(X,ve);break;case"completed":await P2(X,ve);break;case"blocked":await _2(X,ve);break}r(),i("Todo updated","success")}catch(ft){ke(ft)}}async function nt(X,ve){try{await I2(X,ve),r(),i("Todo deleted","success")}catch(Ve){ke(Ve)}}async function He(X,ve,Ve){try{await M2(X,ve,Ve),r(),i("Todo updated","success")}catch(ft){throw ke(ft),ft}}async function at(X,ve,Ve){try{await L2(X,ve,Ve),r(),i(Ve.length===1?"Attachment added":`${Ve.length} attachments added`,"success")}catch(ft){ke(ft)}}async function xt(X,ve,Ve){try{await O2(X,ve,Ve),r(),i("Attachment removed","success")}catch(ft){ke(ft)}}const lt=t0(H),ot=lt.filter(X=>!A.isCollapsed(X.config.id)).flatMap(X=>X.items),{hotkeyRowProps:le}=Ad(ot,{scope:"list:todos",bindO:!1,onOpen:X=>T(bo(X))});Jt({keys:"/",scope:"list:todos",description:"Focus filter",handler:()=>{var X;return(X=p.current)==null?void 0:X.focus()}}),Jt({keys:"r",scope:"list:todos",description:"Refresh",handler:()=>r()});const[xe,Oe]=Ns(),We=xe.get("focus");m.useEffect(()=>{if(!We)return;const X=B.find(Ve=>Ve.id===We);if(!X)return;const ve=Mm(X.status);A.isCollapsed(ve)&&A.toggle(ve)},[We,B]),m.useEffect(()=>{if(!We)return;const X=document.querySelector(`[data-todo-id="${CSS.escape(We)}"]`);if(!X)return;X.scrollIntoView({block:"nearest"}),X.classList.add("ring-2","ring-primary/60");const ve=window.setTimeout(()=>{X.classList.remove("ring-2","ring-primary/60"),Oe(Ve=>{const ft=new URLSearchParams(Ve);return ft.delete("focus"),ft})},1500);return()=>window.clearTimeout(ve)},[We,ot.length,Oe]);const Ge=L?H.find(X=>bo(X)===L)??null:null;function ge(X,ve){const Ve=K.current;if(Ve!=null&&Ve.closest(Ql)){X.preventDefault();return}X.dataTransfer.effectAllowed="move",X.dataTransfer.setData("text/plain",ve),z(ve)}function pe(){z(null),V(null)}function se(X,ve){!Ge||ve.statuses.includes(Ge.status)||(X.preventDefault(),X.dataTransfer.dropEffect="move",V(ve.id))}function je(X,ve){W===ve.id&&!X.currentTarget.contains(X.relatedTarget)&&V(null)}function Ae(X,ve){X.preventDefault();const Ve=Ge;pe(),!(!Ve||ve.statuses.includes(Ve.status))&&Ue(Ve.workspace,Ve.id,ve.dropStatus)}return t?s.jsx(jt,{label:"Loading todos..."}):n?s.jsx(Rt,{error:n}):s.jsxs("div",{className:"space-y-4",children:[s.jsx(Hr,{toast:o,onDismiss:a}),s.jsxs("div",{className:"grid gap-3 grid-cols-[repeat(auto-fill,minmax(140px,1fr))]",children:[s.jsx(Kn,{label:"Open",value:we.open,icon:gs}),s.jsx(Kn,{label:"In Progress",value:we.in_progress,icon:Dv,tone:"info"}),s.jsx(Kn,{label:"Blocked",value:we.blocked,icon:Kh,tone:"warn"}),s.jsx(Kn,{label:"Completed",value:we.completed,icon:gs,tone:"default"})]}),s.jsx("div",{className:"surface-panel p-3",children:s.jsxs("div",{className:"flex gap-2",children:[s.jsxs("select",{value:j,onChange:X=>N(X.target.value),className:"h-9 rounded-md border border-border/70 bg-background px-2 text-sm text-foreground focus:border-foreground/30 focus:outline-none",children:[s.jsx("option",{value:"_global",children:"Global"}),e==null?void 0:e.workspaces.filter(X=>X.workspace!=="_global").map(X=>s.jsx("option",{value:X.workspace,children:X.workspace},X.workspace))]}),s.jsx("input",{type:"text",placeholder:"Add a todo...",value:w,onChange:X=>b(X.target.value),onKeyDown:X=>X.key==="Enter"&&$e(),className:"h-9 flex-1 rounded-md border border-border/70 bg-background px-3 text-sm text-foreground placeholder:text-muted-foreground/60 focus:border-foreground/30 focus:outline-none"}),s.jsxs("button",{onClick:$e,disabled:!w.trim(),className:"inline-flex h-9 items-center gap-1.5 rounded-md bg-foreground px-3 text-sm font-medium text-background transition hover:bg-foreground/90 disabled:opacity-40",children:[s.jsx(It,{className:"h-4 w-4"}),"Add"]})]})}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsxs("div",{className:"relative flex-1 max-w-sm",children:[s.jsx(Si,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),s.jsx("input",{ref:p,type:"text",placeholder:"Search todos...",value:d,onChange:X=>f(X.target.value),className:"h-9 w-full rounded-md border border-border/70 bg-background pl-9 pr-3 text-sm text-foreground placeholder:text-muted-foreground/60 focus:border-foreground/30 focus:outline-none"})]}),s.jsxs("select",{value:h,onChange:X=>g(X.target.value),className:"h-9 rounded-md border border-border/70 bg-background px-2 text-sm text-foreground focus:border-foreground/30 focus:outline-none",children:[s.jsx("option",{value:"",children:"All statuses"}),s.jsx("option",{value:"open",children:"Open"}),s.jsx("option",{value:"in_progress",children:"In Progress"}),s.jsx("option",{value:"completed",children:"Completed"}),s.jsx("option",{value:"blocked",children:"Blocked"})]}),G.length>0&&s.jsxs("select",{value:y,onChange:X=>k(X.target.value),className:"h-9 rounded-md border border-border/70 bg-background px-2 text-sm text-foreground focus:border-foreground/30 focus:outline-none",children:[s.jsx("option",{value:"",children:"All tags"}),G.map(X=>s.jsxs("option",{value:X,children:["#",X]},X))]})]}),Q.length>0?s.jsxs("div",{className:"surface-panel flex items-center justify-between gap-3 px-3 py-2",children:[s.jsxs("span",{className:"text-sm font-medium",children:[Q.length," selected",ae?s.jsxs("span",{className:"ml-2 text-xs text-muted-foreground",children:["(from ",s.jsx("strong",{children:ae}),")"]}):s.jsxs("span",{className:"ml-2 text-xs text-muted-foreground",children:["across ",new Set(Q.map(X=>X.workspace)).size," workspaces"]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("button",{type:"button",onClick:()=>U(!0),className:"shell-action shell-action--cta",children:"Promote to assignment"}),s.jsx("button",{type:"button",onClick:ze,className:"text-xs text-muted-foreground hover:text-foreground",children:"Clear"})]})]}):null,H.length>0&&s.jsxs("div",{className:"flex items-center gap-3 px-3 py-1 text-xs text-muted-foreground",children:[s.jsx("input",{type:"checkbox","aria-label":"Select all visible todos",checked:te,ref:X=>{X&&(X.indeterminate=Z)},onChange:Se,className:"h-4 w-4 cursor-pointer accent-foreground"}),s.jsxs("span",{children:["Select all in current filter (",H.length,")"]}),s.jsx("span",{className:"text-muted-foreground/60",children:"— shift-click for range select"})]}),s.jsx("div",{className:"space-y-3",children:(()=>{let X=-1;return lt.map(({config:ve,items:Ve})=>{const ft=!A.isCollapsed(ve.id);return s.jsx(e0,{label:ve.label,count:Ve.length,expanded:ft,onToggle:()=>A.toggle(ve.id),isDropTarget:W===ve.id,onDragOver:et=>se(et,ve),onDragLeave:et=>je(et,ve),onDrop:et=>Ae(et,ve),children:ft&&Ve.map(et=>{X+=1;const yt=X,mt=bo(et),he=R.has(mt);return s.jsxs("div",{draggable:!0,"data-todo-id":et.id,...le(yt),onMouseDown:Ee=>{K.current=Ee.target},onDragStart:Ee=>ge(Ee,mt),onDragEnd:pe,className:`surface-panel flex items-start gap-3 px-3 py-2 group cursor-grab active:cursor-grabbing hover:bg-foreground/[0.03] transition ${he?"ring-1 ring-foreground/20":""} ${L===mt?"opacity-50 shadow-lg":""}`,children:[s.jsx("input",{type:"checkbox","data-no-drag":!0,"aria-label":`Select todo ${et.id}`,title:"Select",checked:he,onChange:()=>{},onClick:Ee=>{Ee.stopPropagation(),Re(et,yt,Ee)},className:"mt-1 h-4 w-4 shrink-0 cursor-pointer accent-foreground"}),s.jsx("span",{className:"mt-0.5 self-stretch w-px bg-border/60","aria-hidden":"true"}),s.jsx("div",{className:"mt-0.5 shrink-0",children:s.jsx(OP,{status:et.status,onChange:Ee=>Ue(et.workspace,et.id,Ee)})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-baseline flex-wrap gap-x-2",children:[s.jsx(zP,{description:et.description,status:et.status,editing:D===mt,onBeginEdit:()=>T(mt),onEndEdit:()=>T(null),onSave:Ee=>He(et.workspace,et.id,Ee)}),et.tags.length>0&&s.jsx("span",{className:"text-xs text-muted-foreground",children:et.tags.map(Ee=>`#${Ee}`).join(" ")}),et.linkedAssignmentRef?s.jsxs(Ie,{to:bE(et.linkedAssignmentRef),"data-no-drag":!0,className:"inline-flex items-center gap-0.5 rounded-full border border-status-completed-foreground/40 bg-status-completed/30 px-1.5 py-0.5 text-[10px] font-mono text-status-completed-foreground hover:bg-status-completed/50",onClick:Ee=>Ee.stopPropagation(),children:[s.jsx(VE,{className:"h-2.5 w-2.5"}),et.linkedAssignmentRef.includes("/")?et.linkedAssignmentRef:`oneoff:${et.linkedAssignmentRef.slice(0,8)}`]}):null]}),s.jsx(BP,{item:et,attachmentUrl:(Ee,Ye)=>Uv(et.workspace,Ee,Ye),onAdd:Ee=>at(et.workspace,et.id,Ee),onDelete:Ee=>xt(et.workspace,et.id,Ee)})]}),s.jsx("span",{className:"text-xs text-muted-foreground/60 font-mono",children:et.workspace!=="_global"&&s.jsx(Ie,{to:`/w/${et.workspace}/todos`,className:"hover:text-foreground transition mr-2",onClick:Ee=>Ee.stopPropagation(),children:et.workspace})}),S===et.id?s.jsxs("span",{className:"text-xs text-status-completed-foreground flex items-center gap-1",children:[s.jsx(zr,{className:"h-3 w-3"})," Copied to clipboard"]}):s.jsxs(s.Fragment,{children:[s.jsxs("button",{className:"text-xs text-muted-foreground/60 font-mono hover:text-foreground transition",onClick:Ee=>O(Ee,et.id),children:["t:",et.id]}),s.jsx("button",{className:"text-muted-foreground/40 hover:text-foreground transition",title:"Copy ID",onClick:Ee=>O(Ee,et.id),children:s.jsx(th,{className:"h-3 w-3"})})]}),s.jsx("button",{onClick:Ee=>{Ee.stopPropagation(),nt(et.workspace,et.id)},className:"text-xs text-muted-foreground/40 hover:text-destructive transition opacity-0 group-hover:opacity-100",children:"delete"})]},`${et.workspace}-${et.id}`)})},ve.id)})})()}),s.jsx(Zw,{open:_,selectedIds:Q.map(X=>X.id),scope:Ne,onOpenChange:U,onDone:oe,defaultProject:ne,defaultTitle:ue,allowOneOff:!0})]})}const Kie={open:{icon:"○",cls:"text-muted-foreground",label:"Open"},in_progress:{icon:"◉",cls:"text-status-in-progress-foreground",label:"In progress"},blocked:{icon:"✕",cls:"text-status-blocked-foreground",label:"Blocked"},completed:{icon:"✓",cls:"text-status-completed-foreground",label:"Completed"},mixed:{icon:"◐",cls:"text-muted-foreground",label:"Mixed"}};function Gie({bundle:e}){const t=Kie[e.derivedStatus.status],{counts:n}=e.derivedStatus;return s.jsxs("div",{className:"border rounded-md p-3 mb-2 bg-card",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("span",{className:`text-lg leading-none ${t.cls}`,title:t.label,children:t.icon}),s.jsxs("span",{className:"font-mono text-sm text-muted-foreground",children:["b:",e.id]}),e.slug&&s.jsx("span",{className:"font-medium",children:e.slug}),s.jsxs("span",{className:"ml-auto text-sm text-muted-foreground",children:[n.completed,"/",n.total," done"]})]}),s.jsxs("div",{className:"mt-2 grid gap-1 text-sm",children:[e.branch&&s.jsxs("div",{className:"text-muted-foreground",children:[s.jsx("span",{className:"font-medium",children:"Branch:"})," ",s.jsx("code",{className:"font-mono",children:e.branch})]}),e.worktreePath&&s.jsxs("div",{className:"text-muted-foreground truncate",children:[s.jsx("span",{className:"font-medium",children:"Worktree:"})," ",s.jsx("code",{className:"font-mono",children:e.worktreePath})]}),e.planDir&&s.jsxs("div",{className:"text-muted-foreground truncate",children:[s.jsx("span",{className:"font-medium",children:"Plan:"})," ",s.jsx("code",{className:"font-mono",children:e.planDir})]})]}),s.jsx("ul",{className:"mt-2 ml-6 text-sm list-disc",children:e.members.map(r=>s.jsxs("li",{className:r.status==="completed"?"line-through text-muted-foreground":"",children:[s.jsxs("span",{className:"font-mono text-xs text-muted-foreground mr-2",children:["t:",r.id]}),r.description]},r.id))})]})}function Yie({bundles:e,title:t="Bundles"}){return e.length===0?null:s.jsxs("section",{className:"mb-6",children:[s.jsxs("h3",{className:"text-sm font-medium text-muted-foreground mb-2",children:[t," (",e.length,")"]}),e.map(n=>s.jsx(Gie,{bundle:n},n.id))]})}function Xie(e){const[t,n]=m.useState(null),[r,o]=m.useState(!0),[i,a]=m.useState(null),l=m.useCallback(async()=>{try{const d=await fetch(`/api/bundles/${encodeURIComponent(e)}`);if(!d.ok)throw new Error(`HTTP ${d.status}`);n(await d.json()),a(null)}catch(d){a(d instanceof Error?d.message:"Failed to fetch bundles")}finally{o(!1)}},[e]);return m.useEffect(()=>{l()},[l]),hc(d=>{d.type==="todos-updated"&&!d.projectSlug&&l()}),{data:t,loading:r,error:i,refetch:l}}function Qie(){const{workspace:e}=Vt(),t=e||"_global",{data:n,loading:r,error:o,refetch:i}=_O(t),{toast:a,showToast:l,dismissToast:d}=wr(),{data:f}=Xie(t),[p,h]=m.useState(""),[g,y]=m.useState(""),[k,w]=m.useState(""),[b,j]=m.useState(""),[N,S]=m.useState(null),[C,D]=m.useState(null),[T,R]=m.useState(new Set),[$,_]=m.useState(!1),[U,I]=m.useState(!1),[F,M]=m.useState(null),A=m.useRef(null);Ei("list:todos");const L=n0("workspace:"+t),[z,W]=m.useState(null),[V,K]=m.useState(null),O=m.useRef(null);async function B(se,je){se.stopPropagation(),await zd(je)&&(S(je),setTimeout(()=>S(Ae=>Ae===je?null:Ae),1500))}const G=m.useMemo(()=>{if(!(n!=null&&n.items))return[];const se=new Set;for(const je of n.items)for(const Ae of je.tags)se.add(Ae);return Array.from(se).sort()},[n]),H=m.useMemo(()=>{if(!(n!=null&&n.items))return[];let se=n.items;if(p.trim()){const je=p.toLowerCase();se=se.filter(Ae=>Ae.description.toLowerCase().includes(je)||Ae.tags.some(qe=>qe.toLowerCase().includes(je))||Ae.id.includes(je))}return g&&(se=se.filter(je=>je.status===g)),k&&(se=se.filter(je=>je.tags.includes(k))),se},[n,p,g,k]);m.useEffect(()=>{R(new Set)},[p,g,k,t]);const Q=m.useMemo(()=>H.filter(se=>T.has(se.id)).length,[H,T]),te=H.length>0&&Q===H.length,Z=Q>0&&!te;function ae(se){R(je=>{const Ae=new Set(je);return Ae.has(se)?Ae.delete(se):Ae.add(se),Ae})}function ne(){R(se=>{const je=new Set(se);if(te)for(const Ae of H)je.delete(Ae.id);else for(const Ae of H)je.add(Ae.id);return je})}function ue(){R(new Set)}const ye=F?[F]:Array.from(T);function Ne(){R(new Set),M(null),i()}function Re(){R(new Set),i()}function Se(se){l(se instanceof Error?se.message:"Action failed","error")}async function ze(){if(b.trim())try{await Bv(t,b.trim()),j(""),i()}catch(se){Se(se)}}async function oe(se,je,Ae){if(se.stopPropagation(),!!window.confirm(`Delete "${Ae}"? This can't be undone.`))try{await I2(t,je),i()}catch(qe){Se(qe)}}async function we(se,je){try{switch(je){case"open":await $2(t,se);break;case"in_progress":await D2(t,se);break;case"completed":await P2(t,se);break;case"blocked":await _2(t,se);break}i()}catch(Ae){Se(Ae)}}async function ke(se,je){try{await M2(t,se,je),i()}catch(Ae){throw Se(Ae),Ae}}async function $e(se,je){try{await L2(t,se,je),i()}catch(Ae){Se(Ae)}}async function Ue(se,je){try{await O2(t,se,je),i()}catch(Ae){Se(Ae)}}const nt=t0(H),He=nt.filter(se=>!L.isCollapsed(se.config.id)).flatMap(se=>se.items),{hotkeyRowProps:at}=Ad(He,{scope:"list:todos",bindO:!1,onOpen:se=>D(se.id)});Jt({keys:"/",scope:"list:todos",description:"Focus filter",handler:()=>{var se;return(se=A.current)==null?void 0:se.focus()}}),Jt({keys:"r",scope:"list:todos",description:"Refresh",handler:()=>i()});const[xt,lt]=Ns(),ot=xt.get("focus");m.useEffect(()=>{if(!ot||!(n!=null&&n.items))return;const se=n.items.find(Ae=>Ae.id===ot);if(!se)return;const je=Mm(se.status);L.isCollapsed(je)&&L.toggle(je)},[ot,n==null?void 0:n.items]),m.useEffect(()=>{if(!ot)return;const se=document.querySelector(`[data-todo-id="${window.CSS.escape(ot)}"]`);if(!se)return;se.scrollIntoView({block:"nearest"}),se.classList.add("ring-2","ring-primary/60");const je=window.setTimeout(()=>{se.classList.remove("ring-2","ring-primary/60"),lt(Ae=>{const qe=new URLSearchParams(Ae);return qe.delete("focus"),qe})},1500);return()=>window.clearTimeout(je)},[ot,He.length,lt]);const le=z?(n==null?void 0:n.items.find(se=>se.id===z))??null:null;function xe(se,je){const Ae=O.current;if(Ae!=null&&Ae.closest(Ql)){se.preventDefault();return}se.dataTransfer.effectAllowed="move",se.dataTransfer.setData("text/plain",je),W(je)}function Oe(){W(null),K(null)}function We(se,je){!le||je.statuses.includes(le.status)||(se.preventDefault(),se.dataTransfer.dropEffect="move",K(je.id))}function Ge(se,je){V===je.id&&!se.currentTarget.contains(se.relatedTarget)&&K(null)}function ge(se,je){se.preventDefault();const Ae=le;Oe(),!(!Ae||je.statuses.includes(Ae.status))&&we(Ae.id,je.dropStatus)}if(r)return s.jsx(jt,{label:"Loading todos..."});if(o)return s.jsx(Rt,{error:o});const pe=(n==null?void 0:n.counts)||{open:0,in_progress:0,blocked:0,total:0};return s.jsxs("div",{className:"space-y-4",children:[s.jsx(Hr,{toast:a,onDismiss:d}),s.jsxs("div",{className:"grid gap-3 grid-cols-[repeat(auto-fill,minmax(140px,1fr))]",children:[s.jsx(Kn,{label:"Open",value:pe.open,icon:gs}),s.jsx(Kn,{label:"In Progress",value:pe.in_progress,icon:gs,tone:"info"}),s.jsx(Kn,{label:"Blocked",value:pe.blocked,icon:Kh,tone:"warn"}),s.jsx(Kn,{label:"Total",value:pe.total,icon:gs})]}),f&&s.jsx(Yie,{bundles:f.bundles}),s.jsx("div",{className:"surface-panel p-3",children:s.jsxs("div",{className:"flex gap-2",children:[s.jsx("input",{type:"text",placeholder:"Add a todo...",value:b,onChange:se=>j(se.target.value),onKeyDown:se=>se.key==="Enter"&&ze(),className:"h-9 flex-1 rounded-md border border-border/70 bg-background px-3 text-sm text-foreground placeholder:text-muted-foreground/60 focus:border-foreground/30 focus:outline-none"}),s.jsxs("button",{onClick:ze,disabled:!b.trim(),className:"inline-flex h-9 items-center gap-1.5 rounded-md bg-foreground px-3 text-sm font-medium text-background transition hover:bg-foreground/90 disabled:opacity-40",children:[s.jsx(It,{className:"h-4 w-4"}),"Add"]})]})}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsxs("div",{className:"relative flex-1 max-w-sm",children:[s.jsx(Si,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),s.jsx("input",{ref:A,type:"text",placeholder:"Search...",value:p,onChange:se=>h(se.target.value),className:"h-9 w-full rounded-md border border-border/70 bg-background pl-9 pr-3 text-sm text-foreground placeholder:text-muted-foreground/60 focus:border-foreground/30 focus:outline-none"})]}),s.jsxs("select",{value:g,onChange:se=>y(se.target.value),className:"h-9 rounded-md border border-border/70 bg-background px-2 text-sm text-foreground focus:border-foreground/30 focus:outline-none",children:[s.jsx("option",{value:"",children:"All statuses"}),s.jsx("option",{value:"open",children:"Open"}),s.jsx("option",{value:"in_progress",children:"In Progress"}),s.jsx("option",{value:"completed",children:"Completed"}),s.jsx("option",{value:"blocked",children:"Blocked"})]}),G.length>0&&s.jsxs("select",{value:k,onChange:se=>w(se.target.value),className:"h-9 rounded-md border border-border/70 bg-background px-2 text-sm text-foreground focus:border-foreground/30 focus:outline-none",children:[s.jsx("option",{value:"",children:"All tags"}),G.map(se=>s.jsxs("option",{value:se,children:["#",se]},se))]})]}),T.size>0?s.jsxs("div",{className:"surface-panel flex items-center justify-between gap-3 px-3 py-2",children:[s.jsxs("span",{className:"text-sm font-medium",children:[T.size," selected"]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("button",{type:"button",onClick:()=>_(!0),className:"shell-action shell-action--cta",children:"Promote selected"}),s.jsx("button",{type:"button",onClick:()=>{M(null),I(!0)},className:"shell-action",children:"Move to…"}),s.jsx("button",{type:"button",onClick:ue,className:"text-xs text-muted-foreground hover:text-foreground",children:"Clear"})]})]}):null,H.length>0&&s.jsxs("div",{className:"flex items-center gap-3 px-3 py-1 text-xs text-muted-foreground",children:[s.jsx("input",{type:"checkbox","aria-label":"Select all visible todos",checked:te,ref:se=>{se&&(se.indeterminate=Z)},onChange:ne,className:"h-4 w-4 cursor-pointer accent-foreground"}),s.jsxs("span",{children:["Select all in current filter (",H.length,")"]})]}),s.jsx("div",{className:"space-y-3",children:(()=>{let se=-1;return nt.map(({config:je,items:Ae})=>{const qe=!L.isCollapsed(je.id);return s.jsx(e0,{label:je.label,count:Ae.length,expanded:qe,onToggle:()=>L.toggle(je.id),isDropTarget:V===je.id,onDragOver:X=>We(X,je),onDragLeave:X=>Ge(X,je),onDrop:X=>ge(X,je),children:qe&&Ae.map(X=>(se+=1,s.jsx(FP,{item:X,copiedId:N,selected:T.has(X.id),editing:C===X.id,onBeginEdit:ve=>D(ve),onEndEdit:()=>D(null),onPatchDescription:ke,onAddAttachments:$e,onDeleteAttachment:Ue,attachmentUrl:(ve,Ve)=>Uv(t,ve,Ve),onToggleSelected:ve=>ae(ve),onMoveOne:(ve,Ve)=>{Ve.stopPropagation(),M(ve),I(!0)},onStatusChange:we,onCopyId:B,onDelete:oe,hotkeyRowProps:at(se),onDragOrigin:ve=>{O.current=ve.target},onDragStart:xe,onDragEnd:Oe,isDragging:z===X.id},X.id)))},je.id)})})()}),s.jsx(Zw,{open:$,selectedIds:Array.from(T),scope:{kind:"workspace",workspace:t},onOpenChange:_,onDone:Re}),s.jsx(HP,{open:U,selectedIds:ye,scope:{kind:"workspace",workspace:t},onOpenChange:se=>{I(se),se||M(null)},onDone:Ne})]})}function JD(){const{views:e}=Id();async function t(i,a,l){const d=e.find(h=>h.id===i.id)??i,f=TA(l,d.workspace).config,p=yh(d.config,f,d.config);await ph(i.id,{name:a,config:p})}async function n(i,a,l){const d=e.find(h=>h.id===i.id)??i,f=_w(l,d.workspace).config,p=yh(d.config,f,d.config);await ph(i.id,{name:a,config:p})}async function r(i){await Gl({name:`${i.name} (copy)`,workspace:i.workspace,config:i.config,entityType:i.entityType})}async function o(i){await N8(i.id)}return{submitEdit:t,submitEditSession:n,duplicate:r,remove:o}}const vE=80,Jie={kanban:"Kanban",list:"List",table:"Table"},Zie={title:"Title",status:"Status",priority:"Priority",assignee:"Assignee",dependencies:"Dependencies",created:"Created",updated:"Updated"};function ZD({open:e,onOpenChange:t,workspace:n,initialView:r,onSubmit:o}){const i=!!r,a=Es(),l=Rd(),{data:d}=Zs(),{data:f}=Yh(),[p,h]=m.useState(""),[g,y]=m.useState(fl.viewMode),[k,w]=m.useState([]),[b,j]=m.useState([]),[N,S]=m.useState([]),[C,D]=m.useState([]),[T,R]=m.useState([]),[$,_]=m.useState([]),[U,I]=m.useState("all"),[F,M]=m.useState(null),[A,L]=m.useState(""),[z,W]=m.useState(fl.sortField),[V,K]=m.useState(fl.sortDirection),[O,B]=m.useState(!1),[G,H]=m.useState(null);function Q(){y(fl.viewMode),w([]),j([]),S([]),D([]),R([]),_([]),I("all"),M(null),L(""),W(fl.sortField),K(fl.sortDirection)}m.useEffect(()=>{if(e)if(H(null),B(!1),r){const oe=r.config.filters;h(r.name),y(r.config.viewMode),w(Ke(oe.status)),j(Ke(oe.priority)),S(Ke(oe.type)),D(Ke(oe.project)),R(Ke(oe.assignee)),_(Ke(oe.tags)),I(oe.activity??"all"),M(Tm(oe.dateRange)),L(oe.search??""),W(r.config.sortField),K(r.config.sortDirection)}else h(""),Q()},[e,r]);const te=oe=>we=>oe?oe==="_ungrouped"?we.projectWorkspace===null:we.projectWorkspace===oe:!0,Z=m.useMemo(()=>{const oe=ke=>n?n==="_ungrouped"?ke.workspace===null:ke.workspace===n:!0,we=(d??[]).filter(oe);return[{value:"__standalone__",label:"No project"},...we.map(ke=>({value:ke.slug,label:ke.title}))]},[d,n]),ae=m.useMemo(()=>{const oe=new Set,we=te(n);for(const $e of(f==null?void 0:f.assignments)??[])we($e)&&$e.assignee&&oe.add($e.assignee);const ke=[{value:"__unassigned__",label:"Unassigned"}];for(const $e of Array.from(oe).sort())ke.push({value:$e,label:$e});return ke},[f,n]),ne=m.useMemo(()=>{const oe=new Set,we=te(n);for(const ke of(f==null?void 0:f.assignments)??[])if(we(ke))for(const $e of ke.tags??[])oe.add($e);return Array.from(oe).sort().map(ke=>({value:ke,label:ke}))},[f,n]),ue=m.useMemo(()=>a.order.map(oe=>({value:oe,label:So(a,oe)})),[a]),ye=m.useMemo(()=>QU.map(oe=>({value:oe,label:oe[0].toUpperCase()+oe.slice(1)})),[]),Ne=m.useMemo(()=>l.definitions.map(oe=>({value:oe.id,label:$l(l,oe.id)})),[l]),Re=sw.map(oe=>({value:oe,label:Jie[oe]})),Se=p.trim(),ze=Se.length>0&&Se.length<=vE;return s.jsx(Ln,{open:e,onOpenChange:t,children:s.jsx(jn,{className:"max-w-lg",children:s.jsxs("form",{className:"space-y-4",onSubmit:async oe=>{if(oe.preventDefault(),!ze||O)return;B(!0),H(null);const we={viewMode:g,filters:{status:k,priority:b,type:N,project:C,assignee:T,tags:$,activity:U,dateRange:pa(F),search:A},sortField:z,sortDirection:V};try{await o(Se,we)}catch(ke){H(ke instanceof Error?ke.message:String(ke)),B(!1)}},children:[s.jsx(er,{children:s.jsx(kn,{children:i?"Edit view":"Create view"})}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{className:"block text-xs font-medium text-muted-foreground",htmlFor:"create-view-name",children:"Name"}),s.jsx("input",{id:"create-view-name",type:"text",value:p,autoFocus:!0,required:!0,maxLength:vE,onChange:oe=>h(oe.target.value),placeholder:"View name",className:"w-full rounded-md border border-border/70 bg-background px-3 py-2 text-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("span",{className:"block text-xs font-medium text-muted-foreground",children:"View mode"}),s.jsx(Am,{value:g,onChange:oe=>y(oe),options:Re})]}),s.jsxs("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2",children:[s.jsx(zs,{label:"Status",children:s.jsx(yn,{ariaLabel:"Status filter",className:"w-full",allLabel:"All statuses",options:ue,value:k,onChange:w})}),s.jsx(zs,{label:"Priority",children:s.jsx(yn,{ariaLabel:"Priority filter",className:"w-full",allLabel:"All priorities",options:ye,value:b,onChange:j})}),s.jsx(zs,{label:"Type",children:s.jsx(yn,{ariaLabel:"Type filter",className:"w-full",allLabel:"All types",options:Ne,value:N,onChange:S})}),s.jsx(zs,{label:"Project",children:s.jsx(yn,{ariaLabel:"Project filter",className:"w-full",allLabel:"All projects",options:Z,value:C,onChange:D})}),s.jsx(zs,{label:"Assignee",children:s.jsx(yn,{ariaLabel:"Assignee filter",className:"w-full",allLabel:"All assignees",options:ae,value:T,onChange:R})}),s.jsx(zs,{label:"Tags",children:s.jsx(yn,{ariaLabel:"Tags filter",className:"w-full",allLabel:"Any tags",options:ne,value:$,onChange:_})}),s.jsx(zs,{label:"Activity",children:s.jsxs("select",{value:U,onChange:oe=>I(oe.target.value),className:"editor-input w-full",children:[s.jsx("option",{value:"all",children:"All activity"}),s.jsx("option",{value:"stale",children:"Stale only"}),s.jsx("option",{value:"fresh",children:"Fresh only"})]})}),s.jsx(zs,{label:"Date range",children:s.jsx(Em,{className:"w-full",value:F,onChange:M})}),s.jsx(zs,{label:"Search",className:"sm:col-span-2",children:s.jsx("input",{type:"text",value:A,onChange:oe=>L(oe.target.value),placeholder:"Title / slug / project contains…",className:"editor-input w-full"})}),s.jsx(zs,{label:"Sort by",className:"sm:col-span-2",children:s.jsxs("div",{className:"flex gap-2",children:[s.jsx("select",{value:z,onChange:oe=>W(oe.target.value),className:"editor-input w-full",children:ST.map(oe=>s.jsx("option",{value:oe,children:Zie[oe]??oe},oe))}),s.jsx("button",{type:"button",onClick:()=>K(oe=>oe==="asc"?"desc":"asc"),className:"shell-action shrink-0",title:V==="asc"?"Ascending":"Descending",children:V==="asc"?"Asc":"Desc"})]})})]}),G?s.jsx("p",{className:"text-xs text-error-foreground",role:"alert",children:G}):null,s.jsxs(Ur,{className:"sm:justify-between",children:[s.jsx("button",{type:"button",onClick:Q,className:"shell-action",disabled:O,children:"Clear all"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("button",{type:"button",onClick:()=>t(!1),className:"shell-action",disabled:O,children:"Cancel"}),s.jsx("button",{type:"submit",disabled:!ze||O,className:"shell-action shell-action--cta disabled:opacity-50",children:O?"Saving…":i?"Save changes":"Create view"})]})]})]})})})}function zs({label:e,className:t,children:n}){return s.jsxs("label",{className:`space-y-1 ${t??""}`,children:[s.jsx("span",{className:"block text-xs font-medium text-muted-foreground",children:e}),n]})}const eae={kanban:"Kanban",list:"List",table:"Table"},tae={assignment:"Assignment",session:"Session"},nae={assignment:"bg-muted text-muted-foreground",session:"bg-primary/10 text-primary"};function wE(){const{workspace:e}=Vt(),{views:t,loading:n}=Id(),{submitEdit:r,submitEditSession:o,duplicate:i,remove:a}=JD(),{toast:l,showToast:d,dismissToast:f}=wr(),[p,h]=m.useState(null),[g,y]=m.useState(!1),[k,w]=m.useState(!1),[b,j]=m.useState(!1),[N,S]=m.useState(null);async function C(M,A){const{workspace:L,config:z}=TA(A,e??null);try{await Gl({name:M,workspace:L,config:z}),w(!1),d(`Created view "${M}"`)}catch(W){throw d(W instanceof Error?W.message:"Failed to create saved view"),W}}async function D(M,A){const{workspace:L,config:z}=_w(A,e??null);try{await Gl({name:M,workspace:L,config:z,entityType:"session"}),j(!1),d(`Created session view "${M}"`)}catch(W){throw d(W instanceof Error?W.message:"Failed to create session view"),W}}async function T(M,A,L){try{await r(M,A,L),S(null),d(`Updated view "${A}"`)}catch(z){throw d(z instanceof Error?z.message:"Failed to update saved view"),z}}async function R(M,A,L){try{await o(M,A,L),S(null),d(`Updated session view "${A}"`)}catch(z){throw d(z instanceof Error?z.message:"Failed to update session view"),z}}async function $(M){try{await i(M),d(`Duplicated "${M.name}"`)}catch(A){d(A instanceof Error?A.message:"Failed to duplicate saved view")}}async function _(){if(p){y(!0);try{await a(p),h(null)}catch(M){d(M instanceof Error?M.message:"Failed to delete saved view")}finally{y(!1)}}}const U=s.jsxs("button",{type:"button",onClick:()=>w(!0),className:"shell-action inline-flex items-center gap-1.5 shell-action--cta",children:[s.jsx(It,{className:"h-4 w-4"}),"Create view"]}),I=s.jsxs("button",{type:"button",onClick:()=>j(!0),className:"shell-action inline-flex items-center gap-1.5",children:[s.jsx(It,{className:"h-4 w-4"}),"Create session view"]}),F=(N==null?void 0:N.entityType)==="session";return s.jsxs("div",{className:"space-y-4",children:[s.jsx(wh,{title:"Saved Views",description:"Create a view here, or open, edit, and reuse views captured from any board.",actions:s.jsxs("div",{className:"flex items-center gap-2",children:[I,U]})}),n?s.jsx(jt,{label:"Loading saved views…"}):t.length===0?s.jsx(Tt,{title:"No saved views yet",description:"Create your first view here, or capture one from any assignments board.",actions:s.jsxs("div",{className:"flex items-center gap-2",children:[I,U]})}):s.jsx(Qe,{children:s.jsx("ul",{className:"divide-y divide-border/60",children:t.map(M=>s.jsx(rae,{view:M,onRequestDelete:()=>h(M),onRequestEdit:()=>S(M),onRequestDuplicate:()=>void $(M)},M.id))})}),s.jsx(ZD,{open:k||!F&&N!==null,onOpenChange:M=>{M||(w(!1),F||S(null))},workspace:N&&!F?N.workspace:e??null,initialView:N&&!F?N:null,onSubmit:N&&!F?(M,A)=>T(N,M,A):C}),s.jsx(DA,{open:b||F&&N!==null,onOpenChange:M=>{M||(j(!1),F&&S(null))},workspace:N&&F?N.workspace:e??null,initialView:N&&F?N:null,onSubmit:N&&F?(M,A)=>R(N,M,A):D}),s.jsx(Ri,{open:p!==null,title:"Delete saved view?",description:p?`Delete '${p.name}'? Any Overview widgets referencing this view will become empty.`:"",confirmLabel:"Delete",loading:g,destructive:!0,onConfirm:_,onOpenChange:M=>{!M&&!g&&h(null)}}),s.jsx(Hr,{toast:l,onDismiss:f})]})}function rae({view:e,onRequestDelete:t,onRequestEdit:n,onRequestDuplicate:r}){const o=Ht(),i=()=>o(AA(e)),a=_A(e.config.filters),l=e.workspace?Dn(e.workspace):null,d=e.entityType??"assignment",f=d==="session",p=f?`limit: ${e.config.limit??"none"} · sort: ${e.config.sortField} ${e.config.sortDirection}`:null;return s.jsxs("li",{className:"flex flex-wrap items-center gap-3 py-3",children:[s.jsxs("div",{className:"min-w-0 flex-1 space-y-1",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("button",{type:"button",onClick:i,className:"truncate text-left text-sm font-semibold text-foreground hover:text-primary",title:"Open view",children:e.name}),s.jsx("span",{className:`inline-flex shrink-0 items-center rounded-full border border-border/70 px-2 py-0.5 text-xs font-medium ${nae[d]??"bg-muted text-muted-foreground"}`,children:tae[d]??d}),!f&&s.jsx("span",{className:"inline-flex shrink-0 items-center rounded-full border border-border/70 bg-muted px-2 py-0.5 text-xs font-medium text-muted-foreground",children:eae[e.config.viewMode]}),l?s.jsx("span",{className:"inline-flex shrink-0 items-center rounded-full border border-border/70 bg-muted/60 px-2 py-0.5 text-xs text-muted-foreground",children:l}):null]}),s.jsxs("p",{className:"truncate text-xs text-muted-foreground",children:[a,p?` · ${p}`:""]})]}),s.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[s.jsx("button",{type:"button",onClick:i,className:"shell-action",children:"Open"}),s.jsx("button",{type:"button",onClick:n,className:"shell-action",children:"Edit"}),s.jsx("button",{type:"button",onClick:r,className:"shell-action",children:"Duplicate"}),s.jsx("button",{type:"button",onClick:t,className:"shell-action border-destructive/40 text-destructive hover:bg-destructive/10",children:"Delete"})]})]})}const sae={kanban:"Kanban",list:"List",table:"Table"};function jE(){const{id:e,workspace:t}=Vt(),n=Ht(),{view:r,ready:o,error:i,refetch:a}=wi(e),{submitEdit:l,duplicate:d,remove:f}=JD(),{toast:p,showToast:h,dismissToast:g}=wr(),[y,k]=m.useState(!1),[w,b]=m.useState(!1),[j,N]=m.useState(!1);if(m.useEffect(()=>{!o||!r||(t??null)!==(r.workspace??null)&&n(AA(r),{replace:!0})},[o,r,t,n]),!o)return s.jsx(jt,{label:"Loading view…"});if(i)return s.jsxs("div",{className:"rounded-lg border border-border/60 bg-card/85 px-4 py-6 text-sm",children:[s.jsx("p",{className:"font-medium text-foreground",children:"Couldn't load view"}),s.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:i.message}),s.jsx("button",{type:"button",onClick:()=>a(),className:"shell-action mt-3",children:"Retry"})]});if(!r)return s.jsxs("div",{className:"space-y-3",children:[s.jsx(wh,{title:"View not found",description:"This saved view no longer exists."}),s.jsxs(Ie,{to:Bp(t??null),className:"shell-action inline-flex items-center gap-1.5",children:[s.jsx(Jp,{className:"h-4 w-4"})," Back to Saved Views"]})]});const S=r.workspace?Dn(r.workspace):null;async function C(R,$){const _=r;try{await l(_,R,$),k(!1),h(`Updated view "${R}"`)}catch(U){throw h(U instanceof Error?U.message:"Failed to update saved view"),U}}async function D(){const R=r;try{await d(R),h(`Duplicated "${R.name}"`)}catch($){h($ instanceof Error?$.message:"Failed to duplicate saved view")}}async function T(){const R=r;N(!0);try{await f(R),b(!1),n(Bp(R.workspace))}catch($){h($ instanceof Error?$.message:"Failed to delete saved view")}finally{N(!1)}}return s.jsxs("div",{className:"space-y-4",children:[s.jsxs(Ie,{to:Bp(r.workspace),className:"inline-flex items-center gap-1.5 text-sm text-muted-foreground hover:text-foreground",children:[s.jsx(Jp,{className:"h-4 w-4"})," Saved Views"]}),s.jsx(wh,{title:r.name,description:_A(r.config.filters),actions:s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"inline-flex shrink-0 items-center rounded-full border border-border/70 bg-muted px-2 py-0.5 text-xs font-medium text-muted-foreground",children:sae[r.config.viewMode]}),S?s.jsx("span",{className:"inline-flex shrink-0 items-center rounded-full border border-border/70 bg-muted/60 px-2 py-0.5 text-xs text-muted-foreground",children:S}):null,s.jsx("button",{type:"button",onClick:()=>k(!0),className:"shell-action",children:"Edit"}),s.jsx("button",{type:"button",onClick:()=>void D(),className:"shell-action",children:"Duplicate"}),s.jsx("button",{type:"button",onClick:()=>n(PA(r)),className:"shell-action",children:"Open on board"}),s.jsx("button",{type:"button",onClick:()=>b(!0),className:"shell-action border-destructive/40 text-destructive hover:bg-destructive/10",children:"Delete"})]})}),s.jsx(CA,{view:r}),y?s.jsx(ZD,{open:y,onOpenChange:k,workspace:r.workspace,initialView:r,onSubmit:C}):null,s.jsx(Ri,{open:w,title:"Delete saved view?",description:`Delete '${r.name}'? Any Overview widgets referencing this view will become empty.`,confirmLabel:"Delete",loading:j,destructive:!0,onConfirm:T,onOpenChange:R=>{!R&&!j&&b(!1)}}),s.jsx(Hr,{toast:p,onDismiss:g})]})}function oae(){return s.jsx(lL,{children:s.jsx(Q6,{children:s.jsx(LM,{children:s.jsxs(Ze,{element:s.jsx(Ez,{}),children:[s.jsx(Ze,{path:"/",element:s.jsx(SH,{})}),s.jsx(Ze,{path:"/projects",element:s.jsx(kS,{})}),s.jsx(Ze,{path:"/archive",element:s.jsx(OH,{})}),s.jsx(Ze,{path:"/assignments",element:s.jsx(DN,{})}),s.jsx(Ze,{path:"/assignments/new",element:s.jsx(LN,{})}),s.jsx(Ze,{path:"/assignments/:id",element:s.jsx(FG,{})}),s.jsx(Ze,{path:"/assignments/:id/edit",element:s.jsx(Dy,{})}),s.jsx(Ze,{path:"/assignments/:id/plan/edit",element:s.jsx($y,{})}),s.jsx(Ze,{path:"/assignments/:id/scratchpad/edit",element:s.jsx(Iy,{})}),s.jsx(Ze,{path:"/assignments/:id/handoff/edit",element:s.jsx(My,{})}),s.jsx(Ze,{path:"/assignments/:id/decision-record/edit",element:s.jsx(Ly,{})}),s.jsx(Ze,{path:"/servers",element:s.jsx(FN,{})}),s.jsx(Ze,{path:"/inventories",element:s.jsx(zN,{})}),s.jsx(Ze,{path:"/schedules",element:s.jsx(AY,{})}),s.jsx(Ze,{path:"/usage",element:s.jsx(BN,{})}),s.jsx(Ze,{path:"/agent-sessions",element:s.jsx(UN,{})}),s.jsx(Ze,{path:"/playbooks",element:s.jsx(IY,{})}),s.jsx(Ze,{path:"/playbooks/create",element:s.jsx(LY,{})}),s.jsx(Ze,{path:"/playbooks/:slug",element:s.jsx(MY,{})}),s.jsx(Ze,{path:"/playbooks/:slug/edit",element:s.jsx(OY,{})}),s.jsx(Ze,{path:"/memories",element:s.jsx(FY,{})}),s.jsx(Ze,{path:"/memories/new",element:s.jsx(BY,{})}),s.jsx(Ze,{path:"/projects/:slug/memories/:itemSlug",element:s.jsx(zY,{})}),s.jsx(Ze,{path:"/projects/:slug/memories/:itemSlug/edit",element:s.jsx(UY,{})}),s.jsx(Ze,{path:"/resources",element:s.jsx(HY,{})}),s.jsx(Ze,{path:"/resources/new",element:s.jsx(WY,{})}),s.jsx(Ze,{path:"/projects/:slug/resources/:itemSlug",element:s.jsx(VY,{})}),s.jsx(Ze,{path:"/projects/:slug/resources/:itemSlug/edit",element:s.jsx(qY,{})}),s.jsx(Ze,{path:"/todos",element:s.jsx(qie,{})}),s.jsx(Ze,{path:"/views",element:s.jsx(wE,{})}),s.jsx(Ze,{path:"/views/:id",element:s.jsx(jE,{})}),s.jsx(Ze,{path:"/help",element:s.jsx(CH,{})}),s.jsx(Ze,{path:"/settings",element:s.jsx(vX,{})}),s.jsx(Ze,{path:"/workflow",element:s.jsx(Wie,{})}),s.jsx(Ze,{path:"/create/project",element:s.jsx(IN,{})}),s.jsx(Ze,{path:"/projects/:slug",element:s.jsx(SN,{})}),s.jsx(Ze,{path:"/projects/:slug/edit",element:s.jsx(ON,{})}),s.jsx(Ze,{path:"/projects/:slug/create/assignment",element:s.jsx(MN,{})}),s.jsx(Ze,{path:"/projects/:slug/assignments/:aslug",element:s.jsx(RN,{})}),s.jsx(Ze,{path:"/projects/:slug/assignments/:aslug/edit",element:s.jsx(Dy,{})}),s.jsx(Ze,{path:"/projects/:slug/assignments/:aslug/plan/edit",element:s.jsx($y,{})}),s.jsx(Ze,{path:"/projects/:slug/assignments/:aslug/scratchpad/edit",element:s.jsx(Iy,{})}),s.jsx(Ze,{path:"/projects/:slug/assignments/:aslug/handoff/edit",element:s.jsx(My,{})}),s.jsx(Ze,{path:"/projects/:slug/assignments/:aslug/decision-record/edit",element:s.jsx(Ly,{})}),s.jsx(Ze,{path:"/w/:workspace/projects",element:s.jsx(kS,{})}),s.jsx(Ze,{path:"/w/:workspace/assignments",element:s.jsx(DN,{})}),s.jsx(Ze,{path:"/w/:workspace/assignments/new",element:s.jsx(LN,{})}),s.jsx(Ze,{path:"/w/:workspace/servers",element:s.jsx(FN,{})}),s.jsx(Ze,{path:"/w/:workspace/inventories",element:s.jsx(zN,{})}),s.jsx(Ze,{path:"/w/:workspace/usage",element:s.jsx(BN,{})}),s.jsx(Ze,{path:"/w/:workspace/agent-sessions",element:s.jsx(UN,{})}),s.jsx(Ze,{path:"/w/:workspace/todos",element:s.jsx(Qie,{})}),s.jsx(Ze,{path:"/w/:workspace/views",element:s.jsx(wE,{})}),s.jsx(Ze,{path:"/w/:workspace/views/:id",element:s.jsx(jE,{})}),s.jsx(Ze,{path:"/w/:workspace/create/project",element:s.jsx(IN,{})}),s.jsx(Ze,{path:"/w/:workspace/projects/:slug",element:s.jsx(SN,{})}),s.jsx(Ze,{path:"/w/:workspace/projects/:slug/edit",element:s.jsx(ON,{})}),s.jsx(Ze,{path:"/w/:workspace/projects/:slug/create/assignment",element:s.jsx(MN,{})}),s.jsx(Ze,{path:"/w/:workspace/projects/:slug/assignments/:aslug",element:s.jsx(RN,{})}),s.jsx(Ze,{path:"/w/:workspace/projects/:slug/assignments/:aslug/edit",element:s.jsx(Dy,{})}),s.jsx(Ze,{path:"/w/:workspace/projects/:slug/assignments/:aslug/plan/edit",element:s.jsx($y,{})}),s.jsx(Ze,{path:"/w/:workspace/projects/:slug/assignments/:aslug/scratchpad/edit",element:s.jsx(Iy,{})}),s.jsx(Ze,{path:"/w/:workspace/projects/:slug/assignments/:aslug/handoff/edit",element:s.jsx(My,{})}),s.jsx(Ze,{path:"/w/:workspace/projects/:slug/assignments/:aslug/decision-record/edit",element:s.jsx(Ly,{})})]})})})})}Q4();LI.createRoot(document.getElementById("root")).render(s.jsx(m.StrictMode,{children:s.jsx(J4,{children:s.jsx(oae,{})})}));export{Wd as C,yr as R,c9 as _,qu as a,aae as b,g0 as d,n3 as e,wd as g,lae as h,Us as i,o3 as n,nZ as r,Lr as s};