@knowsuchagency/fulcrum 3.3.0 → 3.4.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.
|
@@ -134,7 +134,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
134
134
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var s,a=!0,o=!1;return{s:function(){n=n.call(e)},n:function(){var u=n.next();return a=u.done,u},e:function(u){o=!0,s=u},f:function(){try{a||n.return==null||n.return()}finally{if(o)throw s}}}}function d1t(e,t){if(e){if(typeof e=="string")return Hle(e,t);var n={}.toString.call(e).slice(8,-1);return n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set"?Array.from(e):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Hle(e,t):void 0}}function Hle(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function H4(e){return e.slice(0).reverse()}function f1t(e){var t=e.typeKey,n=e.defaultDropEffect,r=new WeakMap,i="data-drop-target-for-".concat(t),s="[".concat(i,"]");function a(m){return r.set(m.element,m),function(){return r.delete(m.element)}}function o(m){var b=G2(oAe(m.element,{attribute:i,value:"true"}),a(m));return Vy(b)}function l(m){var b,y,v,_,w=m.source,C=m.target,T=m.input,k=m.result,S=k===void 0?[]:k;if(C==null)return S;if(!(C instanceof Element))return C instanceof Node?l({source:w,target:C.parentElement,input:T,result:S}):S;var A=C.closest(s);if(A==null)return S;var R=r.get(A);if(R==null)return S;var I={input:T,source:w,element:R.element};if(R.canDrop&&!R.canDrop(I))return l({source:w,target:R.element.parentElement,input:T,result:S});var D=(b=(y=R.getData)===null||y===void 0?void 0:y.call(R,I))!==null&&b!==void 0?b:{},P=(v=(_=R.getDropEffect)===null||_===void 0?void 0:_.call(R,I))!==null&&v!==void 0?v:n,j={data:D,element:R.element,dropEffect:P,isActiveDueToStickiness:!1};return l({source:w,target:R.element.parentElement,input:T,result:[].concat(sAe(S),[j])})}function u(m){var b=m.eventName,y=m.payload,v=z4(y.location.current.dropTargets),_;try{for(v.s();!(_=v.n()).done;){var w,C=_.value,T=r.get(C.element),k=em(em({},y),{},{self:C});T==null||(w=T[b])===null||w===void 0||w.call(T,k)}}catch(S){v.e(S)}finally{v.f()}}var d={onGenerateDragPreview:u,onDrag:u,onDragStart:u,onDrop:u,onDropTargetChange:function(b){var y=b.payload,v=new Set(y.location.current.dropTargets.map(function(U){return U.element})),_=new Set,w=z4(y.location.previous.dropTargets),C;try{for(w.s();!(C=w.n()).done;){var T,k=C.value;_.add(k.element);var S=r.get(k.element),A=v.has(k.element),R=em(em({},y),{},{self:k});if(S==null||(T=S.onDropTargetChange)===null||T===void 0||T.call(S,R),!A){var I;S==null||(I=S.onDragLeave)===null||I===void 0||I.call(S,R)}}}catch(U){w.e(U)}finally{w.f()}var D=z4(y.location.current.dropTargets),P;try{for(D.s();!(P=D.n()).done;){var j,B,L=P.value;if(!_.has(L.element)){var M=em(em({},y),{},{self:L}),$=r.get(L.element);$==null||(j=$.onDropTargetChange)===null||j===void 0||j.call($,M),$==null||(B=$.onDragEnter)===null||B===void 0||B.call($,M)}}}catch(U){D.e(U)}finally{D.f()}}};function f(m){d[m.eventName](m)}function h(m){var b=m.source,y=m.target,v=m.input,_=m.current,w=l({source:b,target:y,input:v});if(w.length>=_.length)return w;for(var C=H4(_),T=H4(w),k=[],S=0;S<C.length;S++){var A,R=C[S],I=T[S];if(I!=null){k.push(I);continue}var D=k[S-1],P=C[S-1];if(D?.element!==P?.element)break;var j=r.get(R.element);if(!j)break;var B={input:v,source:b,element:j.element};if(j.canDrop&&!j.canDrop(B)||!((A=j.getIsSticky)!==null&&A!==void 0&&A.call(j,B)))break;k.push(em(em({},R),{},{isActiveDueToStickiness:!0}))}return H4(k)}return{dropTargetForConsumers:o,getIsOver:h,dispatchEvent:f}}function h1t(e,t){var n=typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=p1t(e))||t){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(u){throw u},f:i}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
135
135
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var s,a=!0,o=!1;return{s:function(){n=n.call(e)},n:function(){var u=n.next();return a=u.done,u},e:function(u){o=!0,s=u},f:function(){try{a||n.return==null||n.return()}finally{if(o)throw s}}}}function p1t(e,t){if(e){if(typeof e=="string")return Vle(e,t);var n={}.toString.call(e).slice(8,-1);return n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set"?Array.from(e):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Vle(e,t):void 0}}function Vle(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function Wle(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function m1t(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?Wle(Object(n),!0).forEach(function(r){W2(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Wle(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function g1t(){var e=new Set,t=null;function n(s){t&&(!s.canMonitor||s.canMonitor(t.canMonitorArgs))&&t.active.add(s)}function r(s){var a=m1t({},s);e.add(a),n(a);function o(){e.delete(a),t&&t.active.delete(a)}return Vy(o)}function i(s){var a=s.eventName,o=s.payload;if(a==="onGenerateDragPreview"){t={canMonitorArgs:{initial:o.location.initial,source:o.source},active:new Set};var l=h1t(e),u;try{for(l.s();!(u=l.n()).done;){var d=u.value;n(d)}}catch(v){l.e(v)}finally{l.f()}}if(t){for(var f=Array.from(t.active),h=0,m=f;h<m.length;h++){var b=m[h];if(t.active.has(b)){var y;(y=b[a])===null||y===void 0||y.call(b,o)}}a==="onDrop"&&(t.active.clear(),t=null)}}return{dispatchEvent:i,monitorForConsumers:r}}function b1t(e){var t=e.typeKey,n=e.mount,r=e.dispatchEventToSource,i=e.onPostDispatch,s=e.defaultDropEffect,a=g1t(),o=f1t({typeKey:t,defaultDropEffect:s});function l(f){r?.(f),o.dispatchEvent(f),a.dispatchEvent(f),i?.(f)}function u(f){var h=f.event,m=f.dragType;Ule.start({event:h,dragType:m,getDropTargetsOver:o.getIsOver,dispatchEvent:l})}function d(){function f(){var h={canStart:Ule.canStart,start:u};return n(h)}return c1t({typeKey:t,mount:f})}return{registerUsage:d,dropTarget:o.dropTargetForConsumers,monitor:a.monitorForConsumers}}var lAe=Vy(function(){return navigator.userAgent.toLocaleLowerCase().includes("android")}),y1t="pdnd:android-fallback",qle="text/plain",v1t="text/uri-list",x1t="application/vnd.pdnd",cR=new WeakMap;function _1t(e){return cR.set(e.element,e),function(){cR.delete(e.element)}}var Gle=Gxt(),dZ=b1t({typeKey:"element",defaultDropEffect:"move",mount:function(t){return G2(Gle.bindEvents(),yx.bind(document,{type:"dragstart",listener:function(r){var i,s,a,o,l,u;if(t.canStart(r)&&!r.defaultPrevented&&r.dataTransfer){var d=r.target;if(d instanceof HTMLElement){var f=cR.get(d);if(f){var h=Fw(r),m={element:f.element,dragHandle:(i=f.dragHandle)!==null&&i!==void 0?i:null,input:h};if(f.canDrag&&!f.canDrag(m)){r.preventDefault();return}if(f.dragHandle){var b=rAe({x:h.clientX,y:h.clientY});if(!f.dragHandle.contains(b)){r.preventDefault();return}}var y=(s=(a=f.getInitialDataForExternal)===null||a===void 0?void 0:a.call(f,m))!==null&&s!==void 0?s:null;if(y)for(var v=0,_=Object.entries(y);v<_.length;v++){var w=JTe(_[v],2),C=w[0],T=w[1];r.dataTransfer.setData(C,T??"")}lAe()&&!r.dataTransfer.types.includes(qle)&&!r.dataTransfer.types.includes(v1t)&&r.dataTransfer.setData(qle,y1t),r.dataTransfer.setData(x1t,"");var k={element:f.element,dragHandle:(o=f.dragHandle)!==null&&o!==void 0?o:null,data:(l=(u=f.getInitialData)===null||u===void 0?void 0:u.call(f,m))!==null&&l!==void 0?l:{}},S={type:"element",payload:k,startedFrom:"internal"};t.start({event:r,dragType:S})}}}}}))},dispatchEventToSource:function(t){var n,r,i=t.eventName,s=t.payload;(n=cR.get(s.source.element))===null||n===void 0||(r=n[i])===null||r===void 0||r.call(n,s)},onPostDispatch:Gle.getOnPostDispatch()}),XD=dZ.dropTarget,uAe=dZ.monitor;function cAe(e){var t=G2(dZ.registerUsage(),_1t(e),oAe(e.element,{attribute:"draggable",value:"true"}));return Vy(t)}function Kle(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function Yle(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?Kle(Object(n),!0).forEach(function(r){W2(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Kle(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}var S1t={top:function(t,n){return Math.abs(n.y-t.top)},right:function(t,n){return Math.abs(t.right-n.x)},bottom:function(t,n){return Math.abs(t.bottom-n.y)},left:function(t,n){return Math.abs(n.x-t.left)}},dAe=Symbol("closestEdge");function fAe(e,t){var n,r,i=t.element,s=t.input,a=t.allowedEdges,o={x:s.clientX,y:s.clientY},l=i.getBoundingClientRect(),u=a.map(function(f){return{edge:f,value:S1t[f](l,o)}}),d=(n=(r=u.sort(function(f,h){return f.value-h.value})[0])===null||r===void 0?void 0:r.edge)!==null&&n!==void 0?n:null;return Yle(Yle({},e),{},W2({},dAe,d))}function M0(e){var t;return(t=e[dAe])!==null&&t!==void 0?t:null}function w1t({tab:e,isActive:t,canClose:n,onSelect:r,onClose:i,onEdit:s,onReorder:a}){const o=x.useRef(null),[l,u]=x.useState(!1),[d,f]=x.useState(null),h=x.useRef(!1);x.useEffect(()=>{const y=o.current;if(!(!y||!a))return G2(cAe({element:y,getInitialData:()=>({type:"terminal-tab",tabId:e.id,position:e.position}),onDragStart:()=>{u(!0),h.current=!0},onDrop:()=>{u(!1)}}),XD({element:y,getData:({input:v,element:_})=>{const w={type:"terminal-tab",tabId:e.id,position:e.position};return fAe(w,{input:v,element:_,allowedEdges:["left","right"]})},canDrop:({source:v})=>v.data.type==="terminal-tab"&&v.data.tabId!==e.id,onDragEnter:({self:v})=>{f(M0(v.data))},onDrag:({self:v})=>{f(M0(v.data))},onDragLeave:()=>{f(null)},onDrop:({source:v,self:_})=>{f(null);const w=M0(_.data),C=v.data.tabId,T=e.position;let k;w==="left"?k=T:k=T+1,a(C,k)}}))},[e.id,e.position,a]);const m=()=>{h.current=!1},b=()=>{h.current||r(),h.current=!1};return c.jsxs("button",{ref:o,onPointerDown:m,onClick:b,onDoubleClick:s,onContextMenu:y=>{y.preventDefault(),s()},className:Pe("group relative flex items-center gap-1.5 rounded-md px-3 py-1.5 text-xs transition-colors max-sm:px-2 max-sm:py-1",t?"bg-background text-foreground":"text-muted-foreground hover:text-foreground","after:absolute after:inset-x-0 after:bottom-0 after:h-0.5 after:bg-foreground after:transition-opacity",t?"after:opacity-100":"after:opacity-0",l&&"opacity-50",a&&"cursor-grab active:cursor-grabbing"),title:e.directory?`${e.name}
|
|
136
136
|
${e.directory}`:e.name,children:[d&&c.jsx("div",{className:Pe("absolute top-0 bottom-0 w-0.5 bg-primary z-10",d==="left"&&"-left-1",d==="right"&&"-right-1")}),e.directory&&c.jsx(J,{icon:$a,size:12,strokeWidth:2,className:"shrink-0 opacity-60"}),e.name,n&&c.jsx("button",{onClick:y=>{y.stopPropagation(),i()},onPointerDown:y=>y.stopPropagation(),className:"ml-1 rounded opacity-0 hover:bg-muted group-hover:opacity-100",children:c.jsx(J,{icon:jn,size:12,strokeWidth:2})})]})}function E1t({tabs:e,activeTabId:t,onTabSelect:n,onTabClose:r,onTabCreate:i,onTabEdit:s,onTabReorder:a}){const o=x.useRef(null),l=x.useRef(null),[u,d]=x.useState(!1),[f,h]=x.useState(!1),[m,b]=x.useState(!0),y=x.useCallback(()=>{const w=o.current;if(!w)return;const{scrollLeft:C,scrollWidth:T,clientWidth:k}=w;d(C>0),h(C+k<T-1)},[]);x.useEffect(()=>{const w=l.current,C=o.current;if(!w||!C)return;const T=new IntersectionObserver(([k])=>{b(k.isIntersecting)},{root:C,threshold:.9});return T.observe(w),()=>T.disconnect()},[]),x.useEffect(()=>{const w=o.current;if(!w)return;y(),w.addEventListener("scroll",y);const C=new ResizeObserver(y);return C.observe(w),()=>{w.removeEventListener("scroll",y),C.disconnect()}},[y]),x.useEffect(()=>{y()},[e,y]);const v=x.useCallback(()=>{o.current?.scrollTo({left:0,behavior:"smooth"})},[]),_=x.useCallback(()=>{const w=o.current;w&&w.scrollTo({left:w.scrollWidth,behavior:"smooth"})},[]);return c.jsxs("div",{className:"flex items-center",children:[u&&c.jsx(Ce,{variant:"ghost",size:"icon-xs",onClick:v,className:"shrink-0",children:c.jsx(J,{icon:yf,size:14,strokeWidth:2})}),c.jsxs("div",{ref:o,className:"flex min-w-0 flex-1 items-center gap-1 overflow-x-auto scrollbar-none",children:[e.map(w=>c.jsx(w1t,{tab:w,isActive:w.id===t,canClose:e.length>1,onSelect:()=>n(w.id),onClose:()=>r(w.id),onEdit:()=>s(w),onReorder:a},w.id)),c.jsx("span",{ref:l,children:c.jsx(Ce,{variant:"ghost",size:"icon-xs",onClick:i,className:"shrink-0",children:c.jsx(J,{icon:J0,size:14,strokeWidth:2})})})]}),f&&c.jsx(Ce,{variant:"ghost",size:"icon-xs",onClick:_,className:"shrink-0",children:c.jsx(J,{icon:hu,size:14,strokeWidth:2})}),!m&&c.jsx(Ce,{variant:"ghost",size:"icon-xs",onClick:i,className:"shrink-0",children:c.jsx(J,{icon:J0,size:14,strokeWidth:2})})]})}function C1t({tab:e,open:t,onOpenChange:n,onSave:r,onCreate:i,defaultName:s=""}){const{t:a}=Dt("terminals"),[o,l]=x.useState(""),[u,d]=x.useState(null),[f,h]=x.useState(!1),m=!e&&i;x.useEffect(()=>{t&&(e?(l(e.name),d(e.directory??null)):(l(s),d(null)))},[t,e,s]);const b=()=>{if(m){i(o.trim(),u??void 0),n(!1);return}if(!e)return;const C={};o.trim()&&o.trim()!==e.name&&(C.name=o.trim()),u!==(e.directory??null)&&(C.directory=u),Object.keys(C).length>0&&r(e.id,C),n(!1)},y=C=>{C.key==="Enter"&&(C.preventDefault(),b())},v=()=>{d(null)},_=C=>{d(C)},w=u?u.split("/").pop():null;return c.jsxs(c.Fragment,{children:[c.jsx(Va,{open:t,onOpenChange:n,children:c.jsxs(Wa,{className:"sm:max-w-md",children:[c.jsx(Po,{children:c.jsx(jo,{children:a(m?"newTab.title":"editTab.title")})}),c.jsxs($h,{className:"mt-4",children:[c.jsxs(Gn,{children:[c.jsx(Kn,{htmlFor:"tabName",children:a("editTab.name")}),c.jsx(kt,{id:"tabName",value:o,onChange:C=>l(C.target.value),onKeyDown:y,placeholder:a("editTab.namePlaceholder"),autoFocus:!0})]}),c.jsxs(Gn,{children:[c.jsx(Kn,{children:a("editTab.directory")}),c.jsxs("div",{className:"flex gap-2",children:[c.jsxs(Ce,{type:"button",variant:"outline",className:"flex-1 justify-start font-normal",onClick:()=>h(!0),children:[c.jsx(J,{icon:$a,size:14,strokeWidth:2,className:"mr-2 shrink-0"}),w?c.jsx("span",{className:"truncate font-mono text-xs",children:u}):c.jsx("span",{className:"text-muted-foreground",children:a("editTab.directoryPlaceholder")})]}),u&&c.jsx(Ce,{type:"button",variant:"ghost",size:"icon",onClick:v,title:a("editTab.clearDirectory"),children:c.jsx(J,{icon:jn,size:14,strokeWidth:2})})]})]})]}),c.jsxs(a2,{className:"mt-4",children:[c.jsx(s2,{render:c.jsx(Ce,{variant:"outline",type:"button"}),children:a("editTab.cancel")}),c.jsx(Ce,{onClick:b,disabled:!o.trim(),children:a(m?"newTab.create":"editTab.save")})]})]})}),c.jsx(bh,{open:f,onOpenChange:h,onSelect:_,initialPath:u??void 0})]})}function fZ({value:e,onChange:t,options:n,allLabel:r,showInbox:i=!0}){const{t:s}=Dt("tasks"),[a,o]=x.useState(!1),[l,u]=x.useState(""),d=x.useRef(null),{data:f=[]}=_u(),{data:h=[]}=Oc(),m=n??f.map(S=>({id:S.id,name:S.name,count:S.taskCount})),b=!!n,y=x.useMemo(()=>{if(b)return 0;const S=new Set,A=new Set;for(const R of f)for(const I of R.repositories)S.add(I.id),A.add(I.path);return h.filter(R=>!R.projectId&&(!R.repositoryId||!S.has(R.repositoryId))&&(!R.repoPath||!A.has(R.repoPath))).length},[h,f,b]),v=m.filter(S=>S.name.toLowerCase().includes(l.toLowerCase()));x.useEffect(()=>{a&&setTimeout(()=>d.current?.focus(),0)},[a]);const _=S=>{t(S),o(!1)},w=S=>{S.stopPropagation(),t(null)},C=e?m.find(S=>S.id===e):null,T=e==="inbox"?"Inbox":C?.name??null,k=r??s("allProjects");return c.jsxs(pW,{open:a,onOpenChange:o,children:[c.jsxs(mW,{render:c.jsx(Ce,{variant:"outline",size:"sm",className:Pe("shrink-0 gap-1.5 h-7 px-2",e&&"pr-1")}),children:[c.jsx(J,{icon:P3,size:12,strokeWidth:2,className:"text-muted-foreground"}),e?c.jsxs(c.Fragment,{children:[c.jsxs(jr,{variant:"secondary",className:"h-5 px-1.5 text-[10px] gap-0.5",children:[T,e==="inbox"?` (${y})`:C?.count!==void 0?` (${C.count})`:""]}),c.jsx("button",{onClick:w,className:"ml-0.5 p-0.5 hover:text-destructive transition-colors",children:c.jsx(J,{icon:jn,size:12})})]}):c.jsxs(c.Fragment,{children:[c.jsx("span",{className:"text-xs",children:k}),c.jsx(J,{icon:Do,size:12,strokeWidth:2,className:"text-muted-foreground"})]})]}),c.jsxs(gW,{align:"start",className:"w-56 p-0",children:[c.jsx("div",{className:"p-2 border-b",children:c.jsx(kt,{ref:d,value:l,onChange:S=>u(S.target.value),placeholder:s("searchProjects"),className:"h-7 text-xs"})}),c.jsxs("div",{className:"max-h-48 overflow-y-auto py-1",children:[c.jsxs("button",{className:Pe("w-full px-3 py-1.5 text-left text-xs hover:bg-accent flex items-center gap-2",!e&&"bg-accent"),onClick:()=>_(null),children:[c.jsx("span",{className:"w-3.5 shrink-0",children:!e&&c.jsx(J,{icon:cr,size:14,className:"text-primary"})}),c.jsx("span",{className:"flex-1 truncate",children:k})]}),v.map(S=>{const A=e===S.id;return c.jsxs("button",{className:Pe("w-full px-3 py-1.5 text-left text-xs hover:bg-accent flex items-center gap-2",A&&"bg-accent"),onClick:()=>_(S.id),children:[c.jsx("span",{className:"w-3.5 shrink-0",children:A&&c.jsx(J,{icon:cr,size:14,className:"text-primary"})}),c.jsx("span",{className:"flex-1 truncate",children:S.name}),S.count!==void 0&&c.jsx("span",{className:"text-muted-foreground text-[10px]",children:S.count})]},S.id)}),!b&&i&&"inbox".includes(l.toLowerCase())&&c.jsxs("button",{className:Pe("w-full px-3 py-1.5 text-left text-xs hover:bg-accent flex items-center gap-2",e==="inbox"&&"bg-accent"),onClick:()=>_("inbox"),children:[c.jsx("span",{className:"w-3.5 shrink-0",children:e==="inbox"&&c.jsx(J,{icon:cr,size:14,className:"text-primary"})}),c.jsx("span",{className:"flex-1 truncate",children:"Inbox"}),c.jsx("span",{className:"text-muted-foreground text-[10px]",children:y})]}),v.length===0&&(b||!"inbox".includes(l.toLowerCase()))&&c.jsx("div",{className:"px-3 py-2 text-xs text-muted-foreground text-center",children:s("noProjectsFound")})]})]})]})}function V4(e){return{id:e.id,name:e.name,cwd:e.cwd,status:e.status,exitCode:e.exitCode??void 0,cols:e.cols,rows:e.rows,createdAt:e.createdAt,tabId:e.tabId??void 0,positionInTab:e.positionInTab}}function k1t(e,t){return{id:e.id,name:e.name,layout:"single",position:t,directory:e.directory??void 0}}const zo="all-tasks",Ta="all-repos",Xle=["IN_PROGRESS","IN_REVIEW"],Zle="fulcrum:lastTerminalTab",T1t=Iy(function(){const{t}=Dt("terminals"),n=ji(),{tab:r,project:i,repoIds:s}=VC({from:"/terminals/"}),{terminals:a,tabs:o,connected:l,createTerminal:u,destroyTerminal:d,renameTerminal:f,assignTerminalToTab:h,createTab:m,updateTab:b,deleteTab:y,reorderTab:v,attachXterm:_,resizeTerminal:w,setupImagePaste:C,writeToTerminal:T,sendInputToTerminal:k,newTerminalIds:S,pendingTabCreation:A,lastCreatedTabId:R}=aCe(),[I,D]=x.useState(null),{getFocusedTerminal:P,selectedRepositoryIds:j,setSelectedRepositories:B,isLoading:L}=fCe(),M=x.useMemo(()=>o.map(Se=>Se.id),[o]),$=r&&(M.includes(r)||r===zo||r===Ta),U=$?r:o[0]?.id??null,W=x.useCallback(Se=>{n({to:"/terminals",search:{tab:Se,project:Se===zo?i:void 0,repoIds:Se===Ta?s:void 0},replace:!0})},[n,i,s]),Y=x.useCallback(Se=>{n({to:"/terminals",search:Oe=>({...Oe,project:Se}),replace:!0})},[n]),G=Ry();x.useEffect(()=>ax(()=>({lastCreatedTabId:G.lastCreatedTabId,pendingTabCreation:G.pendingTabCreation}),({lastCreatedTabId:Oe})=>{Oe&&(Xt.terminal.info("MobX reaction: lastCreatedTabId changed",{tabId:Oe}),W(Oe),setTimeout(()=>{G.clearLastCreatedTabId(),Re.current++;const Qe=`Terminal ${Re.current}`;Xt.terminal.debug("Creating terminal in new tab",{tabId:Oe,name:Qe}),u({name:Qe,cols:80,rows:24,tabId:Oe,positionInTab:0})},150))},{fireImmediately:!0}),[G,W,u]),x.useEffect(()=>{if(Xt.terminal.debug("Redirect effect running",{tabsLength:o.length,isValidTab:$,pendingTabCreation:A,lastCreatedTabId:R}),o.length!==0&&!(A||R)&&!$){const Se=localStorage.getItem(Zle),Oe=Se&&(o.some(Qe=>Qe.id===Se)||Se===zo||Se===Ta)?Se:o[0].id;Xt.terminal.debug("Redirecting to tab",{targetTab:Oe}),n({to:"/terminals",search:{tab:Oe},replace:!0})}},[o,$,R,A,n]),x.useEffect(()=>{U&&localStorage.setItem(Zle,U)},[U]);const{data:q=[],status:X}=Oc(),{data:z=[]}=sg(),{data:Q=[]}=_u(),ee=x.useMemo(()=>{const Se=new Map;for(const Oe of z)Se.set(Oe.path,Oe.id);return Se},[z]),ne=x.useMemo(()=>new Set(q.filter(Se=>Xle.includes(Se.status)&&Se.worktreePath).map(Se=>Se.worktreePath)),[q]),ae=x.useMemo(()=>new Set(q.filter(Se=>Se.worktreePath).map(Se=>Se.worktreePath)),[q]),fe=x.useMemo(()=>{const Se=new Map;for(const Oe of q)Oe.worktreePath&&Oe.repoPath&&Oe.repoName&&Oe.baseBranch&&Se.set(Oe.worktreePath,{taskId:Oe.id,repoId:ee.get(Oe.repoPath),repoName:Oe.repoName,title:Oe.title,repoPath:Oe.repoPath,worktreePath:Oe.worktreePath,baseBranch:Oe.baseBranch,branch:Oe.branch,prUrl:Oe.prUrl,pinned:Oe.pinned});return Se},[q,ee]),re=x.useMemo(()=>{const Se=new Map;for(const Oe of Q)Se.set(Oe.id,Oe.name);return Se},[Q]),de=x.useMemo(()=>{const Se=new Map;for(const Oe of Q)if(Oe.repositories)for(const Qe of Oe.repositories)Se.set(Qe.id,Oe.id);return Se},[Q]),he=x.useMemo(()=>{const Se=new Map;for(const Oe of Q)if(Oe.repositories)for(const Qe of Oe.repositories)Se.set(Qe.path,Oe.id);return Se},[Q]),ce=x.useCallback(Se=>Se.projectId?Se.projectId:Se.repositoryId?de.get(Se.repositoryId)??null:Se.repoPath?he.get(Se.repoPath)??null:null,[de,he]),ye=x.useMemo(()=>{const Se=new Set;for(const Qe of q)if(Xle.includes(Qe.status)){const It=ce(Qe);It&&Se.add(It)}const Oe=[];for(const Qe of Se){const It=re.get(Qe)??Qe;Oe.push({id:Qe,name:It})}return Oe.sort((Qe,It)=>Qe.name.localeCompare(It.name)),Oe},[q,re,ce]),be=i,ue=x.useMemo(()=>{const Se=new Map;for(const Oe of z)Se.set(Oe.path,Oe.id);return Se},[z]),Ae=x.useMemo(()=>{const Se=new Map;for(const Oe of z)Se.set(Oe.path,{repoId:Oe.id,repoName:Oe.displayName,repoPath:Oe.path});return Se},[z]),le=x.useMemo(()=>s?.split(",").filter(Boolean)??[],[s]),ke=x.useMemo(()=>{const Se=new Set(z.map(Oe=>Oe.id));return le.filter(Oe=>Se.has(Oe))},[le,z]),[Fe,ze]=x.useState(null),ve=x.useRef(0),je=400,we=x.useCallback((Se,Oe)=>{Xt.projectTerminals.info("toggleRepoFilter called",{repoId:Se,checked:Oe});const Qe=s?.split(",").filter(Boolean)??[];if(Oe&&Qe.length>=6)return;Oe&&(Xt.projectTerminals.info("Setting loadingRepoId",{repoId:Se}),ve.current=Date.now(),ze(Se));const It=Oe?[...Qe,Se]:Qe.filter(_t=>_t!==Se);n({to:"/terminals",search:_t=>({..._t,repoIds:It.length>0?It.join(","):void 0}),replace:!0})},[n,s]),Le=x.useRef(!1);x.useEffect(()=>{if(U!==Ta){Le.current=!1;return}if(L||Le.current||s||j.length===0)return;const Se=new Set(z.map(Qe=>Qe.id)),Oe=j.filter(Qe=>Se.has(Qe));Oe.length!==0&&(Le.current=!0,n({to:"/terminals",search:Qe=>({...Qe,repoIds:Oe.join(",")}),replace:!0}))},[U,s,j,z,n,L]),x.useEffect(()=>{if(U!==Ta||L||!s&&!Le.current&&j.length>0)return;const Se=le.join(","),Oe=j.join(",");Se!==Oe&&B(le)},[U,le,j,B,L,s]),x.useEffect(()=>{if(U===Ta&&l){Xt.projectTerminals.debug("Auto-create effect running",{selectedRepoIds:le,terminalCount:a.length,terminalCwds:a.map(Se=>Se.cwd)});for(const Se of le){const Oe=z.find(_t=>_t.id===Se);if(!Oe?.path)continue;const Qe=Oe.path;if(a.find(_t=>_t.cwd===Qe&&!_t.tabId)){Xt.projectTerminals.debug("Terminal already exists for repo",{repoId:Se,repoPath:Qe});continue}Xt.projectTerminals.info("Creating terminal for repo",{repoId:Se,repoPath:Qe}),u({name:Oe.displayName,cwd:Qe,cols:80,rows:24})}}},[U,le,z,a,l,u]);const qe=x.useRef(new Map),Re=x.useRef(0),Ie=x.useRef(!1),se=x.useRef(!1),Ge=x.useMemo(()=>U===zo?a.filter(Se=>Se.cwd&&ne.has(Se.cwd)).filter(Se=>{if(!be)return!0;const Oe=q.find(It=>It.worktreePath===Se.cwd);return Oe?ce(Oe)===be:!1}).sort((Se,Oe)=>{const Qe=q.find(_t=>_t.worktreePath===Se.cwd),It=q.find(_t=>_t.worktreePath===Oe.cwd);return!Qe||!It?0:new Date(It.createdAt).getTime()-new Date(Qe.createdAt).getTime()}).map(V4):U===Ta?le.length===0?[]:a.filter(Se=>Se.cwd&&!Se.tabId&&ue.has(Se.cwd)).filter(Se=>{const Oe=ue.get(Se.cwd);return Oe&&le.includes(Oe)}).map(V4):a.filter(Se=>Se.tabId===U).sort((Se,Oe)=>Se.positionInTab-Oe.positionInTab).map(V4),[U,a,ne,be,q,ue,le,ce]);x.useEffect(()=>{if(!Fe)return;const Se=z.find(It=>It.id===Fe);if(!Se?.path)return;const Oe=Se.path,Qe=Ge.some(It=>It.cwd===Oe);if(Xt.projectTerminals.debug("Clear loading effect",{loadingRepoId:Fe,repoPath:Oe,hasTerminal:Qe,visibleTerminalCwds:Ge.map(It=>It.cwd)}),Qe){const It=Date.now()-ve.current,_t=je-It;if(_t>0){const rn=setTimeout(()=>{Xt.projectTerminals.info("Clearing loadingRepoId after delay",{loadingRepoId:Fe}),ze(null)},_t);return()=>clearTimeout(rn)}Xt.projectTerminals.info("Clearing loadingRepoId",{loadingRepoId:Fe}),ze(null)}},[Fe,z,Ge]);const ut=x.useCallback(()=>{if(Xt.terminal.info("handleTerminalAdd called",{activeTabId:U,connected:l,pendingTerminalCreate:Ie.current,terminalCount:a.length}),Ie.current){Xt.terminal.debug("Skipping terminal creation, already pending");return}Ie.current=!0,Re.current++;const Se=`Terminal ${Re.current}`,Oe=a.filter(It=>It.tabId===U),Qe=Oe.length;Xt.terminal.info("Creating terminal",{name:Se,tabId:U,positionInTab:Qe,terminalsInTabCount:Oe.length}),u({name:Se,cols:80,rows:24,tabId:U??void 0,positionInTab:Qe}),setTimeout(()=>{Ie.current=!1},500)},[u,U,a,l]);x.useEffect(()=>{if(X!=="success"){Xt.terminalsView.debug("Tab assignment effect skipped",{tasksStatus:X});return}for(const Se of a)Se.cwd&&ae.has(Se.cwd)&&Se.tabId&&(Xt.terminalsView.debug("Removing task terminal from regular tab",{terminalId:Se.id,name:Se.name,cwd:Se.cwd,tabId:Se.tabId}),h(Se.id,null))},[a,ae,h,X]);const mt=x.useCallback(Se=>{const Oe=qe.current.get(Se);Oe&&(Oe(),qe.current.delete(Se)),d(Se,{force:!0,reason:"user_closed"})},[d]),Ke=x.useCallback((Se,Oe)=>{const Qe=_(Se,Oe);qe.current.set(Se,Qe),S.has(Se)&&setTimeout(()=>{Oe.focus()},50)},[_,S]),lt=x.useCallback((Se,Oe,Qe)=>{w(Se,Oe,Qe)},[w]),Ve=x.useCallback((Se,Oe)=>{f(Se,Oe)},[f]),Ct=x.useCallback(()=>{if(se.current){Xt.terminal.debug("Skipping tab creation, already pending");return}se.current=!0;const Se=`Tab ${o.length+1}`;Xt.terminal.debug("Quick creating tab",{name:Se}),m(Se,void 0,void 0),setTimeout(()=>{se.current=!1},500)},[m,o.length]),Ne=x.useCallback((Se,Oe)=>{Xt.terminal.debug("Reordering tab",{tabId:Se,newPosition:Oe}),v(Se,Oe)},[v]),Ue=x.useCallback((Se,Oe)=>{if(se.current){Xt.terminal.debug("Skipping tab creation, already pending");return}se.current=!0,Xt.terminal.debug("Creating tab",{name:Se,directory:Oe}),m(Se,void 0,Oe),setTimeout(()=>{se.current=!1},500)},[m]),st=x.useCallback(Se=>{const Oe=a.filter(Qe=>Qe.tabId===Se);for(const Qe of Oe){const It=qe.current.get(Qe.id);It&&(It(),qe.current.delete(Qe.id))}y(Se)},[a,y]),et=o.map(k1t),pt=x.useCallback(Se=>{D(Se)},[]),wt=x.useCallback((Se,Oe)=>{b(Se,Oe)},[b]),Et=U===zo||U===Ta;return ro("meta+d",ut,{enabled:!Et&&l,allowInTerminal:!0,deps:[ut,Et,l]}),ro("meta+w",()=>{if(U&&!Et){const Se=P(U);Se&&mt(Se)}},{enabled:!Et,allowInTerminal:!0,deps:[U,Et,P,mt]}),c.jsxs("div",{className:"flex h-full max-w-full flex-col overflow-hidden",children:[c.jsxs("div",{className:"film-grain relative sticky top-0 z-10 flex shrink-0 items-center justify-between border-b border-border px-2 py-1",style:{background:"var(--gradient-header)"},children:[c.jsxs("div",{className:"flex min-w-0 flex-1 items-center",children:[c.jsxs("button",{onClick:()=>W(zo),className:Pe("relative flex shrink-0 items-center gap-1.5 rounded-md px-3 py-1.5 text-xs font-medium transition-colors max-sm:px-2",U===zo?"bg-primary/10 text-primary":"text-muted-foreground hover:text-primary hover:bg-primary/5","after:absolute after:inset-x-0 after:bottom-0 after:h-0.5 after:bg-primary after:transition-opacity",U===zo?"after:opacity-100":"after:opacity-0"),children:[c.jsx(J,{icon:B3,size:12,strokeWidth:2}),c.jsx("span",{className:"max-sm:hidden",children:t("taskTerminals")})]}),c.jsxs("button",{onClick:()=>W(Ta),className:Pe("relative flex shrink-0 items-center gap-1.5 rounded-md px-3 py-1.5 text-xs font-medium transition-colors max-sm:px-2",U===Ta?"bg-primary/10 text-primary":"text-muted-foreground hover:text-primary hover:bg-primary/5","after:absolute after:inset-x-0 after:bottom-0 after:h-0.5 after:bg-primary after:transition-opacity",U===Ta?"after:opacity-100":"after:opacity-0"),children:[c.jsx(J,{icon:Yd,size:12,strokeWidth:2}),c.jsx("span",{className:"max-sm:hidden",children:t("repoTerminals")})]}),c.jsx("div",{className:"mx-2 h-4 w-px shrink-0 bg-border"}),c.jsx("div",{className:"min-w-0 flex-1",children:c.jsx(E1t,{tabs:et,activeTabId:U??"",onTabSelect:W,onTabClose:st,onTabCreate:Ct,onTabEdit:pt,onTabReorder:Ne})})]}),c.jsxs("div",{className:"flex shrink-0 items-center gap-3 max-sm:gap-1",children:[U===zo&&ye.length>1&&c.jsx(fZ,{value:be??null,onChange:Se=>Y(Se??void 0),options:ye,allLabel:t("allProjects")}),U===Ta&&z.length>0&&c.jsxs(nf,{children:[c.jsxs(rf,{render:c.jsx(Ce,{variant:"outline",size:"sm",className:"max-sm:w-auto"}),children:[Fe?c.jsx(J,{icon:Rt,size:12,strokeWidth:2,className:"animate-spin text-muted-foreground"}):c.jsx(J,{icon:P3,size:12,strokeWidth:2,className:"text-muted-foreground"}),c.jsx("span",{children:ke.length===0?t("selectRepos"):t("reposSelected",{count:ke.length})})]}),c.jsx(sf,{className:"w-64",align:"end",children:c.jsxs("div",{className:"p-2 space-y-2",children:[c.jsx("div",{className:"text-sm font-medium mb-2",children:t("filterByRepo")}),z.map(Se=>{const Oe=le.includes(Se.id),Qe=Fe===Se.id,It=Fe!==null||!Oe&&le.length>=6;return c.jsxs("div",{className:"flex items-center gap-2",children:[Qe?c.jsx(J,{icon:Rt,size:16,strokeWidth:2,className:"animate-spin text-muted-foreground"}):c.jsx(Ci,{id:`repo-filter-${Se.id}`,checked:Oe,disabled:It,onCheckedChange:_t=>we(Se.id,_t===!0)}),c.jsx(Kr,{htmlFor:`repo-filter-${Se.id}`,className:`text-sm ${It?"text-muted-foreground cursor-not-allowed":"cursor-pointer"}`,children:Se.displayName})]},Se.id)}),ke.length>0&&!Fe&&c.jsx(Ce,{variant:"ghost",size:"sm",className:"w-full mt-2",onClick:()=>n({to:"/terminals",search:Se=>({...Se,repoIds:void 0}),replace:!0}),children:t("clearFilter")})]})})]}),c.jsxs(Ce,{variant:"outline",size:"sm",onClick:ut,disabled:!l||U===zo||U===Ta,className:"max-sm:px-2 border-transparent text-primary",children:[c.jsx(J,{icon:U1e,size:14,strokeWidth:2,"data-slot":"icon"}),c.jsx("span",{className:"max-sm:hidden",children:t("newTerminal")})]})]})]}),c.jsx("div",{className:"min-w-0 flex-1 overflow-hidden",children:c.jsx(Dxt,{terminals:Ge,onTerminalClose:U===zo||U===Ta?void 0:mt,onTerminalAdd:l&&U!==zo&&U!==Ta?ut:void 0,onTerminalReady:Ke,onTerminalResize:lt,onTerminalRename:U===zo||U===Ta?void 0:Ve,setupImagePaste:C,writeToTerminal:T,sendInputToTerminal:k,taskInfoByCwd:U===zo?fe:void 0,repoInfoByCwd:U===Ta?Ae:void 0,emptyMessage:U===Ta?t("emptyRepos"):U===zo?t("emptyTasks"):void 0})}),c.jsx(C1t,{tab:I,open:I!==null,onOpenChange:Se=>{Se||D(null)},onSave:wt,onCreate:Ue,defaultName:`Tab ${o.length+1}`})]})}),A1t=js("/terminals/")({component:T1t,validateSearch:e=>({tab:typeof e.tab=="string"?e.tab:void 0,project:typeof e.project=="string"?e.project:void 0,repoIds:typeof e.repoIds=="string"?e.repoIds:void 0})});function N1t(){return{x:0,y:0}}function O1t(e){var t=e.render,n=e.nativeSetDragImage,r=e.getOffset,i=r===void 0?N1t:r,s=document.createElement("div");Object.assign(s.style,{position:"fixed",top:0,left:0,zIndex:iAe,pointerEvents:"none"}),document.body.append(s);var a=t({container:s});queueMicrotask(function(){var u=i({container:s});if(q2()){var d=s.getBoundingClientRect();if(d.width===0)return;s.style.left="-".concat(d.width-1e-4,"px")}n?.(s,u.x,u.y)});function o(){l(),a?.(),document.body.removeChild(s)}var l=uAe({onDragStart:o,onDrop:o})}var R1t=Vy(function(){return q2()&&"ontouchend"in document}),I1t=function(t){var n=t.container,r=n.getBoundingClientRect();return{x:r.width/2,y:r.height/2}};function D1t(e){return function(n){var r=n.container;if(R1t()||lAe())return I1t({container:r});Object.assign(r.style,{borderInlineStart:"".concat(e.x," solid transparent"),borderTop:"".concat(e.y," solid transparent")});var i=window.getComputedStyle(r);if(i.direction==="rtl"){var s=r.getBoundingClientRect();return{x:s.width,y:0}}return{x:0,y:0}}}function Gi({className:e,size:t="default",...n}){return c.jsx("div",{"data-slot":"card","data-size":t,className:Pe("film-grain relative ring-foreground/10 text-card-foreground gap-4 overflow-hidden rounded-lg py-4 text-xs/relaxed ring-1 has-[>img:first-child]:pt-0 data-[size=sm]:gap-3 data-[size=sm]:py-3 *:[img:first-child]:rounded-t-lg *:[img:last-child]:rounded-b-lg group/card flex flex-col",e),style:{background:"var(--gradient-card)"},...n})}function K2({className:e,...t}){return c.jsx("div",{"data-slot":"card-header",className:Pe("gap-1 rounded-t-lg px-4 group-data-[size=sm]/card:px-3 [.border-b]:pb-4 group-data-[size=sm]/card:[.border-b]:pb-3 group/card-header @container/card-header grid auto-rows-min items-start has-data-[slot=card-action]:grid-cols-[1fr_auto] has-data-[slot=card-description]:grid-rows-[auto_auto]",e),...t})}function Y2({className:e,...t}){return c.jsx("div",{"data-slot":"card-title",className:Pe("text-sm font-medium",e),...t})}function P1t({className:e,...t}){return c.jsx("div",{"data-slot":"card-description",className:Pe("text-muted-foreground text-xs/relaxed",e),...t})}function za({className:e,...t}){return c.jsx("div",{"data-slot":"card-content",className:Pe("px-4 group-data-[size=sm]/card:px-3",e),...t})}const hAe=x.createContext(null);function j1t({children:e}){const[t,n]=x.useState(null);return c.jsx(hAe.Provider,{value:{activeTask:t,setActiveTask:n},children:e})}function pAe(){const e=x.useContext(hAe);if(!e)throw new Error("useDrag must be used within DragProvider");return e}const mAe=x.createContext(null);function L1t({children:e}){const[t,n]=x.useState(new Set),[r,i]=x.useState(null),s=x.useCallback(u=>{n(d=>{const f=new Set(d);return f.has(u)?f.delete(u):f.add(u),f}),i(u)},[]),a=x.useCallback((u,d)=>{if(!r){n(new Set([u])),i(u);return}const f=d.indexOf(r),h=d.indexOf(u);if(f===-1||h===-1){n(new Set([u])),i(u);return}const[m,b]=f<h?[f,h]:[h,f],y=d.slice(m,b+1);n(v=>{const _=new Set(v);for(const w of y)_.add(w);return _})},[r]),o=x.useCallback(()=>{n(new Set),i(null)},[]),l=x.useCallback(u=>t.has(u),[t]);return c.jsx(mAe.Provider,{value:{selectedIds:t,lastSelectedId:r,toggleSelection:s,selectRange:a,clearSelection:o,isSelected:l},children:e})}function hZ(){const e=x.useContext(mAe);if(!e)throw new Error("useSelection must be used within a SelectionProvider");return e}function pZ(e){const t=new Date;if(!e){const r=t.getFullYear(),i=String(t.getMonth()+1).padStart(2,"0"),s=String(t.getDate()).padStart(2,"0");return`${r}-${i}-${s}`}return new Intl.DateTimeFormat("en-CA",{timeZone:e,year:"numeric",month:"2-digit",day:"2-digit"}).format(t)}function M1t(e,t,n){if(!e||n==="DONE"||n==="CANCELED")return!1;const r=pZ(t);return e<r}function F1t(e,t,n){if(!e||n==="DONE"||n==="CANCELED")return!1;const r=pZ(t);return e===r}function mZ(){const{data:e}=X3();return x.useMemo(()=>pZ(e),[e])}function ZD(e,t){const{data:n}=X3();return x.useMemo(()=>M1t(e,n,t),[e,n,t])}function gAe(e,t){const{data:n}=X3();return x.useMemo(()=>F1t(e,n,t),[e,n,t])}function bAe({task:e,isDragPreview:t,isBlocked:n,isBlocking:r}){const{setActiveTask:i}=pAe(),{isSelected:s,toggleSelection:a}=hZ(),o=ji(),{data:l}=sg(),u=s(e.id),d=x.useRef(null),[f,h]=x.useState(!1),[m,b]=x.useState(null),[y,v]=x.useState(null),_=!!(e.worktreePath||e.repositoryId),w=!!e.worktreePath,C=!e.worktreePath&&!!e.repositoryId,T=C?l?.find(P=>P.id===e.repositoryId):null,k=ZD(e.dueDate,e.status),S=gAe(e.dueDate,e.status),A=x.useRef(!1);x.useEffect(()=>{const P=d.current;if(!(!P||t))return G2(cAe({element:P,getInitialData:()=>({type:"task",taskId:e.id,status:e.status}),onGenerateDragPreview:({nativeSetDragImage:j})=>{O1t({nativeSetDragImage:j,getOffset:D1t({x:"16px",y:"8px"}),render:({container:B})=>{v(B)}})},onDragStart:()=>{h(!0),i(e),A.current=!0},onDrop:()=>{h(!1),i(null),v(null)}}),XD({element:P,getData:({input:j,element:B})=>{const L={type:"task",taskId:e.id,status:e.status};return fAe(L,{input:j,element:B,allowedEdges:["top","bottom"]})},canDrop:({source:j})=>j.data.taskId!==e.id,onDragEnter:({self:j})=>{b(M0(j.data))},onDrag:({self:j})=>{b(M0(j.data))},onDragLeave:()=>{b(null)},onDrop:()=>{b(null)}}))},[e,t,i]);const R=()=>{A.current=!1},I=()=>{if(A.current){A.current=!1;return}o(w?{to:"/tasks/$taskId",params:{taskId:e.id}}:{to:"/tasks",search:P=>({...P,task:e.id}),replace:!0}),A.current=!1},D=c.jsxs("div",{className:"group/card relative",children:[!t&&c.jsx("div",{className:Pe("absolute left-2 top-2 z-20 transition-opacity duration-150",u?"opacity-100":"opacity-0 group-hover/card:opacity-100"),onPointerDown:P=>P.stopPropagation(),children:c.jsx(Ci,{checked:u,onCheckedChange:()=>a(e.id)})}),c.jsxs(Gi,{ref:t?void 0:d,onPointerDown:R,onClick:I,className:Pe("relative cursor-grab active:cursor-grabbing","transition-all duration-200 ease-out","hover:shadow-md hover:scale-[1.02] hover:-translate-y-0.5",f&&"opacity-50",u&&"ring-2 ring-primary bg-primary/5"),children:[m&&c.jsx("div",{className:Pe("absolute left-0 right-0 h-0.5 bg-primary z-10",m==="top"&&"-top-1",m==="bottom"&&"-bottom-1")}),c.jsx(K2,{className:Pe("p-3 pb-1 flex flex-row items-start justify-between gap-2",!t&&"pl-8"),children:c.jsx(Y2,{className:"text-sm font-medium leading-tight flex-1",children:e.title})}),c.jsxs(za,{className:Pe("p-3 pt-1",!t&&"pl-8"),children:[e.description&&c.jsx("p",{className:"line-clamp-2 text-xs text-muted-foreground",children:e.description}),e.tags.length>0&&c.jsxs("div",{className:"mt-2 flex items-center gap-1 flex-wrap",children:[e.tags.slice(0,3).map(P=>c.jsx("span",{className:"rounded-full border border-border bg-card px-1.5 py-0.5 text-[10px] font-medium",children:P},P)),e.tags.length>3&&c.jsxs("span",{className:"text-[10px] text-muted-foreground",children:["+",e.tags.length-3]})]}),c.jsxs("div",{className:Pe("flex items-center gap-1 text-xs text-muted-foreground/70 flex-wrap",e.tags.length>0?"mt-1.5":"mt-2"),children:[n&&c.jsxs(c.Fragment,{children:[c.jsxs("span",{className:"inline-flex items-center gap-0.5 whitespace-nowrap text-destructive font-medium",children:[c.jsx(J,{icon:BBe,size:12,strokeWidth:2}),c.jsx("span",{children:"Blocked"})]}),c.jsx("span",{className:"text-muted-foreground/30",children:"•"})]}),r&&c.jsxs(c.Fragment,{children:[c.jsxs("span",{className:"inline-flex items-center gap-0.5 whitespace-nowrap text-accent font-medium",children:[c.jsx(J,{icon:Pr,size:12,strokeWidth:2}),c.jsx("span",{children:"Blocking"})]}),c.jsx("span",{className:"text-muted-foreground/30",children:"•"})]}),w&&c.jsxs("span",{className:"inline-flex items-center gap-1 whitespace-nowrap",children:[c.jsx(J,{icon:Yd,size:12,strokeWidth:2}),c.jsx("span",{className:"truncate max-w-24",children:e.repoName}),e.prUrl&&c.jsxs(c.Fragment,{children:[c.jsx("span",{className:"text-muted-foreground/30",children:"•"}),c.jsx(J,{icon:pc,size:12,strokeWidth:2,className:"text-foreground"})]})]}),C&&T&&c.jsxs("span",{className:"inline-flex items-center gap-1 whitespace-nowrap",children:[c.jsx(J,{icon:Yd,size:12,strokeWidth:2}),c.jsx("span",{className:"truncate max-w-24",children:T.displayName})]}),e.dueDate&&c.jsxs(c.Fragment,{children:[_&&c.jsx("span",{className:"text-muted-foreground/30",children:"•"}),c.jsxs("span",{className:Pe("inline-flex items-center gap-1 whitespace-nowrap",k?"text-destructive":S?"text-amber-600 dark:text-amber-500":""),children:[c.jsx(J,{icon:ng,size:12,strokeWidth:2}),c.jsx("span",{children:new Date(e.dueDate+"T00:00:00").toLocaleDateString("en-US",{month:"short",day:"numeric"})})]})]}),!_&&!n&&!r&&e.tags.length===0&&!e.dueDate&&c.jsx("span",{className:"italic",children:"Non-code task"})]})]})]})]});return c.jsxs(c.Fragment,{children:[D,y&&Ti.createPortal(c.jsx("div",{className:"w-72 max-w-[90vw]",children:c.jsx(bAe,{task:e,isDragPreview:!0})}),y)]})}const B1t={TO_DO:"border-t-status-todo",IN_PROGRESS:"border-t-status-in-progress",IN_REVIEW:"border-t-status-in-review",DONE:"border-t-status-done",CANCELED:"border-t-status-canceled"};function Qle({status:e,tasks:t,isMobile:n,blockedTaskIds:r,blockingTaskIds:i}){const{t:s}=Dt("common"),a=x.useRef(null),[o,l]=x.useState(!1),u=[...t].sort((d,f)=>{const h=d.dueDate?new Date(d.dueDate).getTime():null,m=f.dueDate?new Date(f.dueDate).getTime():null;return h!==null&&m===null?-1:h===null&&m!==null?1:h!==null&&m!==null&&h!==m?h-m:new Date(f.updatedAt).getTime()-new Date(d.updatedAt).getTime()});return x.useEffect(()=>{const d=a.current;if(d)return XD({element:d,getData:()=>({type:"column",status:e}),canDrop:({source:f})=>f.data.type==="task",onDragEnter:()=>l(!0),onDragLeave:()=>l(!1),onDrop:()=>l(!1)})},[e]),c.jsxs("div",{ref:a,className:Pe("flex flex-col rounded-lg border border-t-4 bg-card",n?"h-full w-full":"h-full w-72 min-w-52 flex-shrink",B1t[e],o&&"ring-2 ring-primary ring-offset-2 ring-offset-background"),children:[!n&&c.jsxs("div",{className:"flex items-center justify-between border-b border-border px-3 py-2",children:[c.jsx("h3",{className:"text-sm font-medium",children:s(`statuses.${e}`)}),c.jsx("span",{className:"flex h-5 min-w-5 items-center justify-center rounded-full bg-muted px-1.5 text-xs font-medium",children:t.length})]}),c.jsx(ap,{className:"min-h-0 flex-1",children:c.jsx("div",{className:"flex flex-col gap-2 p-2",children:u.map(d=>c.jsx(bAe,{task:d,isBlocked:r?.has(d.id),isBlocking:i?.has(d.id)},d.id))})})]})}function $1t(){const{selectedIds:e,clearSelection:t}=hZ(),n=DVe(),{data:r=[]}=Oc(),[i,s]=x.useState(!0),a=e.size,{pinnedCount:o,unpinnedWithWorktreeCount:l}=x.useMemo(()=>{const f=r.filter(h=>e.has(h.id));return{pinnedCount:f.filter(h=>h.pinned).length,unpinnedWithWorktreeCount:f.filter(h=>!h.pinned&&h.worktreePath).length}},[r,e]),u=l>0,d=()=>{n.mutate({ids:Array.from(e),deleteLinkedWorktrees:i},{onSuccess:()=>{t()}})};return a===0?null:c.jsx("div",{className:Pe("fixed bottom-4 left-1/2 z-40 -translate-x-1/2 rounded-lg border bg-background/95 shadow-lg backdrop-blur-sm","animate-in slide-in-from-bottom-2 duration-200"),children:c.jsxs("div",{className:"flex items-center gap-4 px-4 py-2.5",children:[c.jsxs("span",{className:"text-sm text-muted-foreground",children:[a," task",a!==1?"s":""," selected"]}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(Ce,{variant:"ghost",size:"sm",onClick:t,children:"Clear"}),c.jsxs(xc,{children:[c.jsx(ZTe,{render:c.jsx(Ce,{variant:"destructive",size:"sm",disabled:n.isPending}),children:n.isPending?"Deleting...":"Delete"}),c.jsxs(_c,{children:[c.jsxs(Sc,{children:[c.jsxs(Ec,{children:["Delete ",a," Task",a!==1?"s":""]}),c.jsxs(Cc,{children:["This will permanently delete ",a," task",a!==1?"s":"",". This action cannot be undone."]}),o>0&&c.jsxs("p",{className:"flex items-center gap-1.5 text-sm text-primary",children:[c.jsx(J,{icon:TO,size:14,strokeWidth:2}),o," pinned worktree",o!==1?"s":""," will be preserved"]})]}),u&&c.jsxs("div",{className:"flex items-center gap-2 py-2",children:[c.jsx(Ci,{id:"bulk-delete-worktrees",checked:i,onCheckedChange:f=>s(f===!0)}),c.jsx("label",{htmlFor:"bulk-delete-worktrees",className:"cursor-pointer text-sm",children:"Also delete linked worktrees"})]}),c.jsxs(wc,{children:[c.jsx(kc,{children:"Cancel"}),c.jsx(hg,{onClick:d,variant:"destructive",disabled:n.isPending,children:n.isPending?"Deleting...":"Delete"})]})]})]})]})]})})}function yAe({taskId:e,links:t}){const[n,r]=x.useState(!1),[i,s]=x.useState(""),[a,o]=x.useState(""),l=TSe(),u=PVe(),d=()=>{const m=i.trim();if(m){try{new URL(m)}catch{rt.error("Invalid URL",{description:"Please enter a valid URL including the scheme (e.g., https://)"});return}l.mutate({taskId:e,url:m,label:a.trim()||void 0},{onSuccess:()=>{s(""),o(""),r(!1)}})}},f=m=>{u.mutate({taskId:e,linkId:m})},h=m=>{m.key==="Enter"?(m.preventDefault(),d()):m.key==="Escape"&&(r(!1),s(""),o(""))};return c.jsxs("div",{className:"space-y-2",children:[t.length>0&&c.jsx("div",{className:"space-y-1.5",children:t.map(m=>c.jsxs("div",{className:"flex items-center gap-2 group",children:[c.jsxs("button",{type:"button",onClick:()=>kl(m.url),className:"flex items-center gap-2 text-sm text-primary hover:underline flex-1 min-w-0",children:[c.jsx(J,{icon:ky,size:14,className:"shrink-0"}),c.jsx("span",{className:"truncate",children:m.label||m.url})]}),c.jsx("button",{type:"button",onClick:()=>f(m.id),className:"opacity-0 group-hover:opacity-100 text-muted-foreground hover:text-destructive transition-opacity",title:"Remove link",children:c.jsx(J,{icon:ma,size:14})})]},m.id))}),n?c.jsxs("div",{className:"space-y-2 pt-1",children:[c.jsx(kt,{type:"url",value:i,onChange:m=>s(m.target.value),onKeyDown:h,placeholder:"https://...",className:"h-8 text-sm",autoFocus:!0}),c.jsx(kt,{type:"text",value:a,onChange:m=>o(m.target.value),onKeyDown:h,placeholder:"Label (optional)",className:"h-8 text-sm"}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx(Ce,{size:"sm",className:"h-7",onClick:d,disabled:!i.trim()||l.isPending,children:"Add"}),c.jsx(Ce,{variant:"outline",size:"sm",className:"h-7",onClick:()=>{r(!1),s(""),o("")},children:"Cancel"})]})]}):c.jsxs("button",{type:"button",onClick:()=>r(!0),className:"flex items-center gap-1.5 text-sm text-muted-foreground hover:text-foreground transition-colors",children:[c.jsx(J,{icon:mu,size:14}),c.jsx("span",{children:"Add link"})]})]})}const Jle={TO_DO:"bg-status-todo/20 text-status-todo",IN_PROGRESS:"bg-status-in-progress/20 text-status-in-progress",IN_REVIEW:"bg-status-in-review/20 text-status-in-review",DONE:"bg-status-done/20 text-status-done",CANCELED:"bg-status-canceled/20 text-status-canceled"};function eue({title:e,icon:t,count:n,items:r,isAdding:i,onStartAdding:s,onCancelAdding:a,onAdd:o,onRemove:l,filteredTasks:u,searchQuery:d,onSearchChange:f,inputRef:h,addButtonLabel:m,emptyLabel:b}){return c.jsxs("div",{className:"flex-1 min-w-0",children:[c.jsxs("div",{className:"flex items-center gap-1.5 text-xs font-medium text-muted-foreground mb-2",children:[c.jsx(J,{icon:t,size:12}),c.jsx("span",{children:e}),n>0&&c.jsxs("span",{className:"text-warning",children:["(",n,")"]})]}),c.jsx("div",{className:"rounded-md border bg-muted/30 min-h-[60px]",children:c.jsxs("div",{className:"p-1.5 space-y-1",children:[r.length>0?r.map(y=>c.jsxs("div",{className:"flex items-center gap-2 rounded bg-background px-2 py-1.5 group",children:[c.jsx("span",{className:Pe("shrink-0 rounded px-1.5 py-0.5 text-[10px] font-medium",Jle[y.status]),children:y.status.replace("_"," ")}),c.jsx("span",{className:"flex-1 truncate text-xs",children:y.title}),c.jsx("button",{type:"button",onClick:()=>l(y),className:"shrink-0 text-muted-foreground hover:text-foreground opacity-0 group-hover:opacity-100 transition-opacity",children:c.jsx(J,{icon:jn,size:12})})]},y.id)):!i&&c.jsx("div",{className:"text-xs text-muted-foreground italic px-2 py-1.5",children:b}),i&&c.jsxs("div",{className:"space-y-1",children:[c.jsxs("div",{className:"flex items-center gap-1.5",children:[c.jsx(kt,{ref:h,value:d,onChange:y=>f(y.target.value),placeholder:"Search tasks...",className:"h-7 text-xs",onKeyDown:y=>{y.key==="Escape"&&a()}}),c.jsx(Ce,{variant:"ghost",size:"icon-xs",onClick:a,children:c.jsx(J,{icon:jn,size:12})})]}),u.length>0&&c.jsx("div",{className:"max-h-32 overflow-y-auto rounded border bg-background",children:u.map(y=>c.jsxs("button",{type:"button",className:"w-full px-2 py-1.5 text-left text-xs hover:bg-muted flex items-center gap-2",onClick:()=>o(y.id),children:[c.jsx("span",{className:Pe("shrink-0 rounded px-1.5 py-0.5 text-[10px] font-medium",Jle[y.status]),children:y.status.replace("_"," ")}),c.jsx("span",{className:"truncate",children:y.title})]},y.id))}),d&&u.length===0&&c.jsx("div",{className:"text-xs text-muted-foreground px-2 py-1",children:"No tasks found"})]})]})}),!i&&c.jsxs(Ce,{variant:"ghost",size:"sm",className:"mt-1.5 h-7 text-xs text-muted-foreground hover:text-foreground w-full justify-start",onClick:s,children:[c.jsx(J,{icon:mu,size:12,className:"mr-1.5"}),m]})]})}function vAe({taskId:e}){const{data:t=[]}=Oc(),{data:n,isLoading:r}=jVe(e),i=LVe(),s=MVe(),[a,o]=x.useState(""),[l,u]=x.useState(!1),[d,f]=x.useState(!1),h=x.useRef(null),m=x.useRef(null);x.useEffect(()=>{l&&h.current&&h.current.focus()},[l]),x.useEffect(()=>{d&&m.current&&m.current.focus()},[d]);const b=x.useMemo(()=>{const k=new Set([e]);if(n){for(const S of n.blockedBy)k.add(S.id);for(const S of n.blocking)k.add(S.id)}return k},[e,n]),y=x.useMemo(()=>{const k=a.toLowerCase().trim(),S=new Set(["DONE","CANCELED"]);return t.filter(A=>!b.has(A.id)).filter(A=>k?A.title.toLowerCase().includes(k)||A.description?.toLowerCase().includes(k):!0).sort((A,R)=>{const I=S.has(A.status),D=S.has(R.status);return I!==D?I?1:-1:new Date(R.updatedAt).getTime()-new Date(A.updatedAt).getTime()}).slice(0,10)},[t,b,a]),v=k=>{i.mutate({taskId:e,dependsOnTaskId:k},{onSuccess:()=>{o(""),u(!1)}})},_=k=>{i.mutate({taskId:k,dependsOnTaskId:e},{onSuccess:()=>{o(""),f(!1)}})},w=k=>{s.mutate({taskId:e,dependencyId:k.dependencyId})};if(r)return c.jsx("div",{className:"text-sm text-muted-foreground",children:"Loading dependencies..."});const C=n?.blockedBy??[],T=n?.blocking??[];return c.jsxs("div",{className:"grid gap-4 grid-cols-1 sm:grid-cols-2",children:[c.jsx(eue,{title:"Blocked by",icon:tg,count:C.length,items:C,isAdding:l,onStartAdding:()=>{f(!1),o(""),u(!0)},onCancelAdding:()=>{o(""),u(!1)},onAdd:v,onRemove:w,filteredTasks:y,searchQuery:a,onSearchChange:o,inputRef:h,addButtonLabel:"Add blocker",emptyLabel:"No blockers"}),c.jsx(eue,{title:"Blocking",icon:Do,count:T.length,items:T,isAdding:d,onStartAdding:()=>{u(!1),o(""),f(!0)},onCancelAdding:()=>{o(""),f(!1)},onAdd:_,onRemove:w,filteredTasks:y,searchQuery:a,onSearchChange:o,inputRef:m,addButtonLabel:"Add blocked task",emptyLabel:"Not blocking any"})]})}function U1t(e){return e==="application/pdf"?J1e:e.startsWith("image/")?q1e:W1e}function z1t(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/1024/1024).toFixed(1)} MB`}function xAe({taskId:e}){const{data:t=[],isLoading:n}=MKe(e),r=Ewe(),i=FKe(),s=x.useRef(null),[a,o]=x.useState(!1),[l,u]=x.useState(null),d=x.useCallback(async v=>{if(!(!v||v.length===0)){u(null);for(const _ of Array.from(v))try{await r.mutateAsync({taskId:e,file:_})}catch(w){u(w instanceof Error?w.message:"Upload failed")}}},[e,r]),f=x.useCallback(v=>{v.preventDefault(),v.stopPropagation(),o(!0)},[]),h=x.useCallback(v=>{v.preventDefault(),v.stopPropagation(),o(!1)},[]),m=x.useCallback(v=>{v.preventDefault(),v.stopPropagation(),o(!1),d(v.dataTransfer.files)},[d]),b=async v=>{try{await i.mutateAsync({taskId:e,attachmentId:v.id})}catch{}},y=v=>{const _=BKe(e,v.id);window.open(_,"_blank")};return n?c.jsx("div",{className:"text-xs text-muted-foreground",children:"Loading attachments..."}):c.jsxs("div",{className:"space-y-3",children:[c.jsxs("div",{className:Pe("border-2 border-dashed rounded-lg p-4 text-center transition-colors cursor-pointer",a?"border-primary bg-primary/5":"border-muted-foreground/25 hover:border-muted-foreground/50"),onDragOver:f,onDragLeave:h,onDrop:m,onClick:()=>s.current?.click(),children:[c.jsx("input",{ref:s,type:"file",multiple:!0,className:"hidden",onChange:v=>d(v.target.files),accept:".pdf,.png,.jpg,.jpeg,.gif,.webp,.svg,.txt,.md,.doc,.docx,.xls,.xlsx,.csv"}),c.jsx(J,{icon:s_e,size:20,className:"mx-auto text-muted-foreground mb-1"}),c.jsx("p",{className:"text-xs text-muted-foreground",children:r.isPending?"Uploading...":"Drop files here or click to upload"}),c.jsx("p",{className:"text-[10px] text-muted-foreground/70 mt-0.5",children:"PDF, images, documents, spreadsheets (max 50MB)"})]}),l&&c.jsx("p",{className:"text-xs text-destructive",children:l}),t.length>0&&c.jsx("div",{className:"space-y-1.5",children:t.map(v=>{const _=U1t(v.mimeType);return c.jsxs("div",{className:"flex items-center gap-2 p-2 rounded border bg-card hover:bg-accent/50 transition-colors group",children:[c.jsx(J,{icon:_,size:16,className:"text-muted-foreground shrink-0"}),c.jsxs("div",{className:"flex-1 min-w-0",children:[c.jsx("p",{className:"text-xs font-medium truncate",children:v.filename}),c.jsx("p",{className:"text-[10px] text-muted-foreground",children:z1t(v.size)})]}),c.jsxs("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[c.jsx(Ce,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",onClick:()=>y(v),title:"Download",children:c.jsx(J,{icon:YBe,size:14})}),c.jsx(Ce,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 text-destructive hover:text-destructive",onClick:()=>b(v),disabled:i.isPending,title:"Delete",children:c.jsx(J,{icon:ma,size:14})})]})]},v.id)})}),t.length===0&&!n&&c.jsx("p",{className:"text-xs text-muted-foreground italic",children:"No attachments"})]})}function H1t(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}function V1t(e){const t=e.trim().split(/\s+/).slice(0,4).join(" "),n=H1t(t);if(!n)return"";const r=Math.random().toString(36).substring(2,6);return`${n}-${r}`}function W1t({task:e,open:t,onOpenChange:n}){const r=ji(),i=At(),[s,a]=x.useState(!1),[o,l]=x.useState(!1),[u,d]=x.useState(""),[f,h]=x.useState(""),[m,b]=x.useState(""),[y,v]=x.useState(""),[_,w]=x.useState("default"),[C,T]=x.useState("claude"),[k,S]=x.useState(null),[A,R]=x.useState("browse"),[I,D]=x.useState(""),[P,j]=x.useState(null),[B,L]=x.useState(!1),[M,$]=x.useState(null),{data:U}=ISe(),{data:W}=q3(),{data:Y}=p2(),{data:G}=x1(),{data:q}=sg(),{data:X}=_u(),{data:z,isLoading:Q}=tW(u||null),ee=k?q?.find(ye=>ye.id===k):null,ne=x.useMemo(()=>!k||!X?null:X.find(ye=>ye.repositories.some(be=>be.id===k))??null,[k,X]),ae=x.useMemo(()=>{if(!q)return[];if(ee&&I===ee.displayName||!I.trim())return q;const ye=I.toLowerCase();return q.filter(be=>be.displayName.toLowerCase().includes(ye)||be.path.toLowerCase().includes(ye))},[q,I,ee]);x.useEffect(()=>{t&&v(V1t(e.title))},[t,e.title]),x.useEffect(()=>{q&&q.length>0?R("saved"):R("browse")},[q]),x.useEffect(()=>{if(t){const ye=q&&q.length>0?q[0]:null,be=ye&&X?X.find(ue=>ue.repositories.some(Ae=>Ae.id===ye.id)):null;if(ye?.defaultAgent?T(ye.defaultAgent):be?.defaultAgent?T(be.defaultAgent):Y&&T(Y),ye?.opencodeModel?$(ye.opencodeModel):be?.opencodeModel?$(be.opencodeModel):$(G||null),q&&q.length>0){const ue=q[0];S(ue.id),d(ue.path),D(ue.displayName),R("saved")}e.description?.trim()?w("plan"):w("default")}},[t,q,X,Y,G,e.description]),x.useEffect(()=>{h(z?z.defaultBranch||z.branches[0]||"main":"")},[z,u]);const fe=async ye=>{j(null),L(!0);try{if(!(await RSe(ye)).isGitRepo){j("Selected folder is not a git repository"),L(!1);return}d(ye);const ue=q?.find(Ae=>Ae.path===ye);S(ue?ue.id:null)}catch(be){j(be instanceof Error?be.message:"Validation failed")}finally{L(!1)}},re=async ye=>{if(ye.preventDefault(),!!u){l(!0);try{const be=u.split("/").pop()||"repo",ue=m.trim()||y,Ae=`${U}/${ue}`,le=C==="claude"?ee?.claudeOptions??ne?.claudeOptions:ee?.opencodeOptions??ne?.opencodeOptions;await ct(`/api/tasks/${e.id}/initialize-worktree`,{method:"POST",body:JSON.stringify({agent:C,aiMode:_,repoPath:u,repoName:be,baseBranch:f||"main",branch:ue,worktreePath:Ae,copyFiles:ee?.copyFiles||void 0,startupScript:ee?.startupScript||void 0,agentOptions:le||void 0,opencodeModel:C==="opencode"?M:void 0})}),i.invalidateQueries({queryKey:["tasks"]}),i.invalidateQueries({queryKey:["tasks",e.id]}),n(!1);const ke=e.description?.trim()?{aiMode:_,description:e.description.trim(),focusTerminal:!0}:{aiMode:_,focusTerminal:!0};r({to:"/tasks/$taskId",params:{taskId:e.id},state:ke,replace:!0})}catch(be){rt.error("Failed to initialize worktree task",{description:be instanceof Error?be.message:String(be)})}finally{l(!1)}}},de=m.trim()||y,he=de?`${U}/${de}`:"",ce=!o&&!!u;return c.jsxs(c.Fragment,{children:[c.jsx(Va,{open:t,onOpenChange:n,children:c.jsx(Wa,{className:"sm:max-w-md max-h-[80dvh] flex flex-col overflow-hidden",children:c.jsxs("form",{onSubmit:re,className:"flex flex-col min-h-0 flex-1",children:[c.jsxs(Po,{className:"shrink-0",children:[c.jsx(jo,{children:"Initialize as Worktree Task"}),c.jsxs(rg,{children:['Create a git worktree and start a coding session for "',e.title,'"']})]}),c.jsxs($h,{className:"mt-4 pb-4 overflow-y-auto min-h-0 flex-1",children:[c.jsxs(Gn,{children:[c.jsx(Kn,{children:"AI Mode"}),c.jsxs(JV,{value:[_],onValueChange:ye=>{const be=Array.isArray(ye)?ye[0]:ye;be&&w(be)},className:"w-full",variant:"outline",children:[c.jsx(nx,{value:"plan",className:"flex-1",children:"Plan"}),c.jsx(nx,{value:"default",className:"flex-1",children:"Execute"})]})]}),c.jsxs(Gn,{children:[c.jsx(Kn,{children:"Agent"}),c.jsxs(Vr,{value:C,onValueChange:ye=>T(ye),children:[c.jsx(qr,{className:"w-full",children:c.jsx(Wr,{})}),c.jsx(Gr,{children:Object.keys(Ua).map(ye=>c.jsx(Kt,{value:ye,children:Ua[ye]},ye))})]})]}),C==="opencode"&&c.jsxs(Gn,{children:[c.jsx(Kn,{children:"OpenCode Model"}),c.jsx(Bb,{value:M,onChange:$,placeholder:"Select model..."})]}),c.jsxs(Gn,{children:[c.jsx(Kn,{children:"Repository"}),c.jsxs(Jo,{value:A,onValueChange:ye=>{R(ye),j(null)},children:[c.jsxs(el,{children:[c.jsx(Bn,{value:"saved",disabled:!q?.length,children:"Saved"}),c.jsx(Bn,{value:"browse",children:"Browse"})]}),c.jsx(Un,{value:"saved",className:"mt-2",children:c.jsxs(c2,{value:k||"",onValueChange:ye=>{const be=q?.find(ue=>ue.id===ye);be&&(S(ye),d(be.path),D(be.displayName),j(null),be.defaultAgent&&T(be.defaultAgent),$(be.opencodeModel??G??null))},inputValue:I,onInputValueChange:D,itemToStringLabel:ye=>q?.find(be=>be.id===ye)?.displayName||"",children:[c.jsx(d2,{placeholder:"Search repositories...",className:"w-full"}),c.jsx(f2,{children:c.jsxs(h2,{children:[c.jsx(W3,{children:"No repositories found"}),ae.map(ye=>c.jsx(tx,{value:ye.id,children:ye.displayName},ye.id))]})})]})}),c.jsx(Un,{value:"browse",className:"mt-2",children:c.jsxs(Ce,{type:"button",variant:"outline",className:"w-full justify-start font-normal",onClick:()=>a(!0),disabled:B,children:[c.jsx(J,{icon:$a,size:14,strokeWidth:2,className:"mr-2"}),B?c.jsx("span",{className:"text-muted-foreground",children:"Validating..."}):u&&!k?c.jsx("span",{className:"truncate",children:u}):c.jsx("span",{className:"text-muted-foreground",children:"Select folder..."})]})})]}),P&&c.jsx("p",{className:"text-sm text-destructive",children:P}),u&&!P&&c.jsx(es,{className:"font-mono text-xs truncate",children:u})]}),c.jsxs(Gn,{children:[c.jsx(Kn,{children:"Base Branch"}),c.jsxs(Vr,{value:f,onValueChange:ye=>h(ye??""),disabled:!u||Q,children:[c.jsx(qr,{className:"w-full",children:c.jsx(Wr,{children:f||c.jsx("span",{className:"text-muted-foreground",children:u?Q?"Loading branches...":"Select branch":"Select repository first"})})}),c.jsx(Gr,{children:z?.branches.map(ye=>c.jsxs(Kt,{value:ye,children:[ye,ye===z.current&&c.jsx("span",{className:"text-muted-foreground ml-2",children:"(current)"})]},ye))})]})]}),c.jsxs(Gn,{children:[c.jsx(Kn,{children:"Branch Name"}),c.jsx(kt,{value:m,onChange:ye=>b(ye.target.value),placeholder:y||"Enter branch name"}),he&&c.jsxs(es,{children:["Worktree: ",he]}),!m.trim()&&y&&c.jsxs(es,{children:["Auto-generated: ",y]})]})]}),c.jsxs(a2,{className:"mt-4 shrink-0",children:[c.jsx(s2,{render:c.jsx(Ce,{variant:"outline",type:"button"}),children:"Cancel"}),c.jsx(Ce,{type:"submit",disabled:!ce,children:o?"Initializing...":"Initialize & Open"})]})]})})}),c.jsx(bh,{open:s,onOpenChange:a,onSelect:fe,initialPath:W||void 0})]})}function q1t({task:e,compact:t}){const{data:n}=sg(),{data:r}=p2(),i=b1(),[s,a]=x.useState(!!e.repositoryId),[o,l]=x.useState(e.repositoryId||null),[u,d]=x.useState(""),[f,h]=x.useState(e.agent||r||"claude"),[m,b]=x.useState(e.baseBranch||""),[y,v]=x.useState(!1),_=o?n?.find(j=>j.id===o):null,{data:w,isLoading:C}=tW(_?.path||null);x.useEffect(()=>{w&&!m&&b(w.defaultBranch||w.branches[0]||"main")},[w,m]),x.useEffect(()=>{_&&!u&&d(_.displayName)},[_,u]);const T=x.useMemo(()=>{if(!n)return[];if(_&&u===_.displayName||!u.trim())return n;const j=u.toLowerCase();return n.filter(B=>B.displayName.toLowerCase().includes(j)||B.path.toLowerCase().includes(j))},[n,u,_]),k=j=>{a(j),j||(l(null),d(""),b(""),i.mutate({taskId:e.id,updates:{repositoryId:null,baseBranch:null}}))},S=j=>{if(!j)return;const B=n?.find(L=>L.id===j);if(B){l(j),d(B.displayName);const L=B.defaultAgent||r||"claude";h(L),i.mutate({taskId:e.id,updates:{repositoryId:j,agent:L}})}},A=j=>{h(j),i.mutate({taskId:e.id,updates:{agent:j}})},R=j=>{j&&(b(j),i.mutate({taskId:e.id,updates:{baseBranch:j}}))},I=t?"p-3":"p-4",D=t?"mb-2":"mb-3",P=t?"text-xs":"text-sm";return c.jsxs("div",{className:`rounded-lg border bg-card ${I}`,children:[c.jsxs("div",{className:`flex items-center justify-between ${D}`,children:[c.jsx("h2",{className:`${P} font-medium text-muted-foreground`,children:"Worktree Task"}),c.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[c.jsx("span",{className:"text-xs text-muted-foreground",children:s?"Enabled":"Disabled"}),c.jsx(Dr,{checked:s,onCheckedChange:k,size:"sm"})]})]}),s&&c.jsxs("div",{className:"space-y-3",children:[c.jsxs("div",{children:[c.jsx("label",{className:"text-xs font-medium text-muted-foreground mb-1.5 block",children:"Repository"}),c.jsxs(c2,{value:o||"",onValueChange:S,inputValue:u,onInputValueChange:d,filter:null,itemToStringLabel:j=>n?.find(B=>B.id===j)?.displayName||"",children:[c.jsx(d2,{placeholder:"Search repositories...",className:"w-full"}),c.jsx(f2,{children:c.jsxs(h2,{children:[T.length===0&&c.jsx("div",{className:"text-muted-foreground w-full flex justify-center py-2 text-center text-xs/relaxed",children:"No repositories found"}),T.map(j=>c.jsx(tx,{value:j.id,children:j.displayName},j.id))]})})]}),_&&c.jsx("p",{className:"text-xs text-muted-foreground mt-1 font-mono truncate",children:_.path})]}),o&&c.jsxs("div",{children:[c.jsx("label",{className:"text-xs font-medium text-muted-foreground mb-1.5 block",children:"Agent"}),c.jsxs(Vr,{value:f,onValueChange:j=>A(j),children:[c.jsx(qr,{className:"w-full",children:c.jsx(Wr,{})}),c.jsx(Gr,{children:Object.keys(Ua).map(j=>c.jsx(Kt,{value:j,children:Ua[j]},j))})]})]}),o&&c.jsxs("div",{children:[c.jsx("label",{className:"text-xs font-medium text-muted-foreground mb-1.5 block",children:"Base Branch"}),c.jsxs(Vr,{value:m,onValueChange:R,disabled:C,children:[c.jsx(qr,{className:"w-full",children:c.jsx(Wr,{children:m||c.jsx("span",{className:"text-muted-foreground",children:C?"Loading branches...":"Select branch"})})}),c.jsx(Gr,{children:w?.branches.map(j=>c.jsxs(Kt,{value:j,children:[j,j===w.current&&c.jsx("span",{className:"text-muted-foreground ml-2",children:"(current)"})]},j))})]})]}),o&&c.jsx(Ce,{onClick:()=>v(!0),className:"w-full",size:t?"sm":"default",children:"Initialize Task"})]}),!s&&c.jsx("p",{className:`text-muted-foreground italic ${t?"text-xs":"text-sm"}`,children:"Enable to associate a repository and create a worktree when work starts."}),c.jsx(W1t,{task:e,open:y,onOpenChange:v})]})}const tue={TO_DO:"To Do",IN_PROGRESS:"In Progress",IN_REVIEW:"In Review",DONE:"Done",CANCELED:"Canceled"},G1t={TO_DO:"bg-status-todo/20 text-status-todo",IN_PROGRESS:"bg-status-in-progress/20 text-status-in-progress",IN_REVIEW:"bg-status-in-review/20 text-status-in-review",DONE:"bg-status-done/20 text-status-done",CANCELED:"bg-status-canceled/20 text-status-canceled"};function _Ae({task:e,onDeleted:t,compact:n}){const r=b1(),i=NSe(),s=OSe(),{data:a}=_u(),[o,l]=x.useState(!1),[u,d]=x.useState(!1),[f,h]=x.useState(e.title),[m,b]=x.useState(!1),[y,v]=x.useState(e.description||""),[_,w]=x.useState(!1),[C,T]=x.useState(e.notes||""),[k,S]=x.useState(""),[A,R]=x.useState(new Set),[I,D]=x.useState(e.prUrl||""),[P,j]=x.useState(!1),[B,L]=x.useState(""),[M,$]=x.useState(!1),U=x.useRef(null),W=x.useMemo(()=>{if(!a)return[];if(!B.trim())return a;const le=B.toLowerCase();return a.filter(ke=>ke.name.toLowerCase().includes(le))},[a,B]);x.useEffect(()=>{const le=ke=>{U.current&&!U.current.contains(ke.target)&&($(!1),L(""))};return document.addEventListener("mousedown",le),()=>document.removeEventListener("mousedown",le)},[]);const Y=le=>{r.mutate({taskId:e.id,updates:{status:le}})},G=()=>{f.trim()&&f!==e.title&&r.mutate({taskId:e.id,updates:{title:f.trim()}}),d(!1)},q=()=>{y!==(e.description||"")&&r.mutate({taskId:e.id,updates:{description:y||null}}),b(!1)},X=()=>{C!==(e.notes||"")&&r.mutate({taskId:e.id,updates:{notes:C||null}}),w(!1)},z=le=>{r.mutate({taskId:e.id,updates:{dueDate:le}})},Q=()=>{const le=k.trim();le&&!e.tags.includes(le)&&(i.mutate({taskId:e.id,tag:le}),S(""))},ee=le=>{R(ke=>new Set(ke).add(le)),s.mutate({taskId:e.id,tag:le})},ne=le=>{le.key==="Enter"&&(le.preventDefault(),Q())},ae=()=>{const le=I.trim();le!==(e.prUrl||"")&&r.mutate({taskId:e.id,updates:{prUrl:le||null}}),j(!1)},fe=le=>{le.key==="Enter"?(le.preventDefault(),ae()):le.key==="Escape"&&(D(e.prUrl||""),j(!1))},re=le=>{r.mutate({taskId:e.id,updates:{projectId:le}}),$(!1),L("")},de=a?.find(le=>le.id===e.projectId),he=ZD(e.dueDate,e.status),ce=n?"p-3":"p-4",ye=n?"mb-2":"mb-3",be=n?"text-xs":"text-sm",ue=n?"gap-3":"gap-4",Ae=n?"space-y-4":"space-y-6";return c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"shrink-0 border-b border-border bg-background px-4 py-3",children:c.jsxs("div",{className:"flex items-center justify-between gap-4",children:[c.jsx("div",{className:"flex-1 min-w-0",children:u?c.jsx(kt,{value:f,onChange:le=>h(le.target.value),onBlur:G,onKeyDown:le=>{le.key==="Enter"&&G(),le.key==="Escape"&&(h(e.title),d(!1))},className:n?"text-base font-semibold":"text-lg font-semibold",autoFocus:!0}):c.jsx("h1",{className:`${n?"text-base":"text-lg"} font-semibold cursor-pointer hover:text-primary`,onClick:()=>d(!0),children:e.title})}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsxs(nf,{children:[c.jsx(rf,{render:c.jsx("button",{type:"button",className:`rounded-full ${n?"px-2.5 py-0.5 text-xs":"px-3 py-1 text-sm"} font-medium ${G1t[e.status]}`}),children:tue[e.status]}),c.jsx(sf,{align:"end",children:c.jsx(xU,{value:e.status,onValueChange:Y,children:Object.entries(tue).map(([le,ke])=>c.jsx(_U,{value:le,children:ke},le))})})]}),c.jsx(Ce,{variant:"ghost",size:"icon-sm",className:"text-muted-foreground hover:text-destructive",onClick:()=>l(!0),children:c.jsx(J,{icon:ma,size:n?14:16,strokeWidth:2})})]})]})}),c.jsx("div",{className:`flex-1 overflow-auto ${n?"p-4":"p-6"}`,children:c.jsxs("div",{className:`${n?"":"mx-auto max-w-3xl"} ${Ae}`,children:[c.jsxs("div",{className:`rounded-lg border bg-card ${ce}`,children:[c.jsxs("div",{className:`flex items-center justify-between ${ye}`,children:[c.jsx("h2",{className:`${be} font-medium text-muted-foreground`,children:"Description"}),!m&&c.jsx(Ce,{variant:"ghost",size:"sm",onClick:()=>b(!0),className:n?"text-xs h-6":"text-xs",children:"Edit"})]}),m?c.jsxs("div",{className:"space-y-2",children:[c.jsx(BV,{value:y,onValueChange:v,placeholder:"Add a description...",rows:n?4:6}),c.jsxs("div",{className:"flex justify-end gap-2",children:[c.jsx(Ce,{variant:"outline",size:"sm",onClick:()=>{v(e.description||""),b(!1)},children:"Cancel"}),c.jsx(Ce,{size:"sm",onClick:q,children:"Save"})]})]}):c.jsx("div",{className:"prose prose-sm dark:prose-invert max-w-none",children:e.description?c.jsx("p",{className:`whitespace-pre-wrap ${n?"text-sm":""}`,children:e.description}):c.jsx("p",{className:`text-muted-foreground italic ${n?"text-sm":""}`,children:"No description"})})]}),c.jsxs("div",{className:`grid ${ue} sm:grid-cols-2`,children:[c.jsxs("div",{className:`rounded-lg border bg-card ${ce}`,children:[c.jsx("h2",{className:`${be} font-medium text-muted-foreground ${ye}`,children:"Tags"}),c.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[e.tags.map(le=>{const ke=A.has(le);return c.jsxs("span",{className:`inline-flex items-center gap-1 rounded-full border border-border bg-card ${n?"px-2 py-0.5":"px-2.5 py-1"} text-xs font-medium`,children:[le,c.jsx("button",{type:"button",onClick:()=>ee(le),disabled:ke,className:"text-muted-foreground hover:text-foreground disabled:opacity-50",children:c.jsx(J,{icon:ke?Rt:jn,size:10,className:ke?"animate-spin":""})})]},le)}),c.jsx("input",{type:"text",value:k,onChange:le=>S(le.target.value),onKeyDown:ne,onBlur:Q,placeholder:e.tags.length===0?"Add tag...":"+",className:"w-16 bg-transparent text-xs outline-none placeholder:text-muted-foreground"})]})]}),c.jsxs("div",{className:`rounded-lg border bg-card ${ce}`,children:[c.jsx("h2",{className:`${be} font-medium text-muted-foreground ${ye}`,children:"Due Date"}),c.jsx(bW,{value:e.dueDate,onChange:z,isOverdue:!!he})]}),c.jsxs("div",{className:`rounded-lg border bg-card ${ce} sm:col-span-2`,children:[c.jsx("h2",{className:`${be} font-medium text-muted-foreground ${ye}`,children:"Project"}),c.jsxs("div",{className:"relative",ref:U,children:[M?c.jsx("input",{type:"text",value:B,onChange:le=>L(le.target.value),onKeyDown:le=>{le.key==="Escape"&&($(!1),L(""))},placeholder:"Search projects...",className:"w-full rounded-md border border-input bg-background px-3 py-2 text-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",autoFocus:!0}):c.jsxs("button",{type:"button",onClick:()=>$(!0),className:"flex items-center gap-2 text-sm hover:text-primary",children:[c.jsx(J,{icon:$a,size:14,strokeWidth:2,className:"text-muted-foreground"}),c.jsx("span",{className:de?"":"text-muted-foreground italic",children:de?.name??"No project"})]}),M&&c.jsxs("div",{className:"absolute top-full left-0 right-0 mt-1 bg-popover border rounded-md shadow-lg z-50 max-h-48 overflow-y-auto",children:[c.jsxs("button",{type:"button",className:Pe("w-full px-3 py-2 text-left text-sm hover:bg-accent flex items-center justify-between",!e.projectId&&"bg-accent"),onClick:()=>re(null),children:[c.jsx("span",{className:"text-muted-foreground",children:"No project"}),!e.projectId&&c.jsx(J,{icon:r_e,size:14,className:"text-primary"})]}),W.map(le=>c.jsxs("button",{type:"button",className:Pe("w-full px-3 py-2 text-left text-sm hover:bg-accent flex items-center justify-between",e.projectId===le.id&&"bg-accent"),onClick:()=>re(le.id),children:[c.jsx("span",{children:le.name}),c.jsxs("span",{className:"text-xs text-muted-foreground",children:[le.taskCount??0," tasks"]})]},le.id)),W.length===0&&B&&c.jsx("div",{className:"px-3 py-2 text-sm text-muted-foreground",children:"No projects found"})]})]})]})]}),c.jsxs("div",{className:`rounded-lg border bg-card ${ce}`,children:[c.jsxs("div",{className:`flex items-center justify-between ${ye}`,children:[c.jsx("h2",{className:`${be} font-medium text-muted-foreground`,children:"Pull Request"}),!P&&e.prUrl&&c.jsx(Ce,{variant:"ghost",size:"sm",onClick:()=>j(!0),className:n?"text-xs h-6":"text-xs",children:"Edit"})]}),P?c.jsxs("div",{className:"flex gap-2",children:[c.jsx(kt,{value:I,onChange:le=>D(le.target.value),onKeyDown:fe,placeholder:"https://github.com/owner/repo/pull/123",className:"flex-1",autoFocus:!0}),c.jsx(Ce,{size:"sm",onClick:ae,children:"Save"})]}):e.prUrl?c.jsxs("button",{onClick:()=>kl(e.prUrl),className:"flex items-center gap-2 text-sm text-primary hover:underline",children:[c.jsx(J,{icon:pc,size:14,strokeWidth:2}),c.jsxs("span",{children:["#",e.prUrl.match(/\/pull\/(\d+)/)?.[1]??"PR"]}),c.jsx(J,{icon:G1e,size:12,strokeWidth:2,className:"text-muted-foreground"})]}):c.jsx(Ce,{variant:"outline",size:"sm",onClick:()=>j(!0),className:n?"text-xs h-6":"text-xs",children:"Link PR"})]}),c.jsxs("div",{className:`rounded-lg border bg-card ${ce}`,children:[c.jsx("h2",{className:`${be} font-medium text-muted-foreground ${ye}`,children:"Dependencies"}),c.jsx(vAe,{taskId:e.id})]}),c.jsxs("div",{className:`rounded-lg border bg-card ${ce}`,children:[c.jsx("h2",{className:`${be} font-medium text-muted-foreground ${ye}`,children:"Links"}),c.jsx(yAe,{taskId:e.id,links:e.links||[]})]}),c.jsxs("div",{className:`rounded-lg border bg-card ${ce}`,children:[c.jsxs("div",{className:`flex items-center justify-between ${ye}`,children:[c.jsx("h2",{className:`${be} font-medium text-muted-foreground`,children:"Notes"}),!_&&c.jsx(Ce,{variant:"ghost",size:"sm",onClick:()=>w(!0),className:n?"text-xs h-6":"text-xs",children:"Edit"})]}),_?c.jsxs("div",{className:"space-y-2",children:[c.jsx("textarea",{value:C,onChange:le=>T(le.target.value),placeholder:"Add notes...",rows:n?3:4,className:"w-full rounded-md border border-input bg-background px-3 py-2 text-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring resize-none",autoFocus:!0}),c.jsxs("div",{className:"flex justify-end gap-2",children:[c.jsx(Ce,{variant:"outline",size:"sm",onClick:()=>{T(e.notes||""),w(!1)},children:"Cancel"}),c.jsx(Ce,{size:"sm",onClick:X,children:"Save"})]})]}):c.jsx("div",{className:"prose prose-sm dark:prose-invert max-w-none",children:e.notes?c.jsx("p",{className:`whitespace-pre-wrap ${n?"text-sm":""}`,children:e.notes}):c.jsx("p",{className:`text-muted-foreground italic ${n?"text-sm":""}`,children:"No notes"})})]}),c.jsxs("div",{className:`rounded-lg border bg-card ${ce}`,children:[c.jsx("h2",{className:`${be} font-medium text-muted-foreground ${ye}`,children:"Attachments"}),c.jsx(xAe,{taskId:e.id})]}),!e.worktreePath&&c.jsx(q1t,{task:e,compact:n})]})}),c.jsx(YD,{task:e,open:o,onOpenChange:l,onDeleted:t})]})}function X2({task:e,open:t,onOpenChange:n}){const r=()=>{n(!1)};return c.jsx(Va,{open:t,onOpenChange:n,children:c.jsx(Wa,{className:"sm:max-w-2xl max-h-[85vh] overflow-y-auto p-0",showCloseButton:!1,children:c.jsx(_Ae,{task:e,onDeleted:r,compact:!0})})})}const W4=["TO_DO","IN_PROGRESS","IN_REVIEW","DONE","CANCELED"];function K1t({status:e}){const{t}=Dt("common"),n=x.useRef(null),[r,i]=x.useState(!1);return x.useEffect(()=>{const s=n.current;if(s)return XD({element:s,getData:()=>({type:"column",status:e}),canDrop:({source:a})=>a.data.type==="task",onDragEnter:()=>i(!0),onDragLeave:()=>i(!1),onDrop:()=>i(!1)})},[e]),c.jsx("div",{ref:n,className:Pe("flex-1 rounded-lg border-2 border-dashed px-3 py-2 text-center text-xs font-medium transition-colors",r?"border-primary bg-primary/10 text-primary":"border-muted-foreground/30 text-muted-foreground"),children:t(`statuses.${e}`)})}function Y1t({projectFilter:e,searchQuery:t,tagsFilter:n,selectedTaskId:r}){const{t:i}=Dt("common"),s=ji(),{data:a=[],isLoading:o}=Oc(),{data:l=[]}=_u(),{data:u}=ASe(),d=RVe(),{activeTask:f}=pAe(),{clearSelection:h,selectedIds:m}=hZ(),[b,y]=x.useState("IN_PROGRESS"),v=x.useMemo(()=>r?a.find(P=>P.id===r)??null:null,[r,a]),_=v&&!v.worktreePath,w=x.useCallback(P=>{P||s({to:"/tasks",search:j=>({...j,task:void 0}),replace:!0})},[s]),{blockedTaskIds:C,blockingTaskIds:T}=x.useMemo(()=>{if(!u)return{blockedTaskIds:new Set,blockingTaskIds:new Set};const P=new Set,j=new Set,B=new Map(u.nodes.map(L=>[L.id,L.status]));for(const L of u.edges){const M=B.get(L.source);M&&M!=="DONE"&&M!=="CANCELED"&&(P.add(L.target),j.add(L.source))}return{blockedTaskIds:P,blockingTaskIds:j}},[u]);x.useEffect(()=>{const P=j=>{j.key==="Escape"&&m.size>0&&h()};return window.addEventListener("keydown",P),()=>window.removeEventListener("keydown",P)},[h,m.size]);const{projectRepoIds:k,projectRepoPaths:S}=x.useMemo(()=>{const P=new Set,j=new Set;for(const B of l)for(const L of B.repositories)P.add(L.id),j.add(L.path);return{projectRepoIds:P,projectRepoPaths:j}},[l]),{selectedProjectRepoIds:A,selectedProjectRepoPaths:R}=x.useMemo(()=>{if(!e||e==="inbox")return{selectedProjectRepoIds:new Set,selectedProjectRepoPaths:new Set};const P=l.find(j=>j.id===e);return P?{selectedProjectRepoIds:new Set(P.repositories.map(j=>j.id)),selectedProjectRepoPaths:new Set(P.repositories.map(j=>j.path))}:{selectedProjectRepoIds:new Set,selectedProjectRepoPaths:new Set}},[e,l]),I=x.useMemo(()=>{let P=a;return e==="inbox"?P=P.filter(j=>!j.projectId&&(!j.repositoryId||!k.has(j.repositoryId))&&(!j.repoPath||!S.has(j.repoPath))):e&&(P=P.filter(j=>j.projectId===e||j.repositoryId&&A.has(j.repositoryId)||j.repoPath&&R.has(j.repoPath))),n&&n.length>0&&(P=P.filter(j=>j.tags.some(B=>n.includes(B)))),t?.trim()?P=P.map(j=>({task:j,score:Math.max(Sl(j.title,t),Sl(j.description||"",t),Sl(j.branch||"",t),Sl(j.prUrl||"",t),Sl(j.tags.join(" "),t))})).filter(({score:j})=>j>0).sort((j,B)=>B.score-j.score).map(({task:j})=>j):P=[...P].sort((j,B)=>{const L=j.dueDate?new Date(j.dueDate).getTime():null,M=B.dueDate?new Date(B.dueDate).getTime():null;return L!==null&&M===null?-1:L===null&&M!==null?1:L!==null&&M!==null&&L!==M?L-M:new Date(B.updatedAt).getTime()-new Date(j.updatedAt).getTime()}),P},[a,e,t,n,k,S,A,R]),D=x.useMemo(()=>{const P={TO_DO:0,IN_PROGRESS:0,IN_REVIEW:0,DONE:0,CANCELED:0};for(const j of I)P[j.status]++;return P},[I]);return x.useEffect(()=>uAe({canMonitor:({source:P})=>P.data.type==="task",onDrop:({source:P,location:j})=>{const B=j.current.dropTargets;if(B.length===0)return;const L=P.data.taskId,M=I.find(G=>G.id===L);if(!M)return;const $=B[0],U=$.data,W=G=>{const q=!!(M.repositoryId||M.repoPath);return M.status==="TO_DO"&&G==="IN_PROGRESS"&&q},Y=G=>{if(W(G))return()=>{s({to:"/tasks/$taskId",params:{taskId:L},state:{focusTerminal:!0}})}};if(U.type==="column"){const G=U.status;if(G!==M.status){const q=I.filter(X=>X.status===G);d.mutate({taskId:L,status:G,position:q.length},{onSuccess:Y(G)})}}else if(U.type==="task"){const G=M0($.data),q=U.status,X=I.filter(ee=>ee.status===q).sort((ee,ne)=>ee.position-ne.position),z=X.findIndex(ee=>ee.id===U.taskId);let Q=z;G==="bottom"&&(Q=z+1),M.status===q&&X.findIndex(ne=>ne.id===L)<z&&(Q=Math.max(0,Q-1)),(M.status!==q||Q!==M.position)&&d.mutate({taskId:L,status:q,position:Q},{onSuccess:Y(q)})}}}),[I,d,s]),o?c.jsx("div",{className:"flex h-full items-center justify-center",children:c.jsx("p",{className:"text-muted-foreground",children:"Loading tasks..."})}):c.jsxs("div",{className:"flex h-full flex-col",children:[c.jsx("div",{className:"border-b bg-background lg:hidden",children:c.jsx(Jo,{value:b,onValueChange:P=>y(P),children:c.jsx(el,{variant:"line",className:"w-full justify-start px-4",children:W4.map(P=>c.jsxs(Bn,{value:P,className:"gap-1.5",children:[c.jsx("span",{className:"truncate",children:i(`statuses.${P}`)}),c.jsx("span",{className:"text-muted-foreground",children:D[P]})]},P))})})}),c.jsx("div",{className:"hidden h-full justify-center gap-4 overflow-x-auto p-4 lg:flex",children:W4.map(P=>c.jsx(Qle,{status:P,tasks:I.filter(j=>j.status===P),blockedTaskIds:C,blockingTaskIds:T},P))}),c.jsx("div",{className:"flex-1 overflow-y-auto p-4 lg:hidden",children:c.jsx(Qle,{status:b,tasks:I.filter(P=>P.status===b),isMobile:!0,blockedTaskIds:C,blockingTaskIds:T})}),f&&c.jsx("div",{className:"fixed inset-x-0 bottom-0 flex gap-2 border-t bg-background/95 p-4 backdrop-blur-sm lg:hidden",children:W4.filter(P=>P!==b).map(P=>c.jsx(K1t,{status:P},P))}),c.jsx($1t,{}),_&&v&&c.jsx(X2,{task:v,open:!0,onOpenChange:w})]})}function X1t(e){return c.jsx(L1t,{children:c.jsx(j1t,{children:c.jsx(Y1t,{...e})})})}function bo(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=bo(e[n]))!==""&&(t+=(t&&" ")+r);else for(let n in e)e[n]&&(t+=(t&&" ")+n);return t}const Z1t={},nue=e=>{let t;const n=new Set,r=(d,f)=>{const h=typeof d=="function"?d(t):d;if(!Object.is(h,t)){const m=t;t=f??(typeof h!="object"||h===null)?h:Object.assign({},t,h),n.forEach(b=>b(t,m))}},i=()=>t,l={setState:r,getState:i,getInitialState:()=>u,subscribe:d=>(n.add(d),()=>n.delete(d)),destroy:()=>{(Z1t?"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()}},u=t=e(r,i,l);return l},Q1t=e=>e?nue(e):nue,{useDebugValue:J1t}=Z,{useSyncExternalStoreWithSelector:e_t}=r4e,t_t=e=>e;function SAe(e,t=t_t,n){const r=e_t(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return J1t(r),r}const rue=(e,t)=>{const n=Q1t(e),r=(i,s=t)=>SAe(n,i,s);return Object.assign(r,n),r},n_t=(e,t)=>e?rue(e,t):rue;function Ha(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,i]of e)if(!Object.is(i,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}var r_t={value:()=>{}};function QD(){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 WN(n)}function WN(e){this._=e}function i_t(e,t){return e.trim().split(/^|\s+/).map(function(n){var r="",i=n.indexOf(".");if(i>=0&&(r=n.slice(i+1),n=n.slice(0,i)),n&&!t.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:r}})}WN.prototype=QD.prototype={constructor:WN,on:function(e,t){var n=this._,r=i_t(e+"",n),i,s=-1,a=r.length;if(arguments.length<2){for(;++s<a;)if((i=(e=r[s]).type)&&(i=s_t(n[i],e.name)))return i;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++s<a;)if(i=(e=r[s]).type)n[i]=iue(n[i],e.name,t);else if(t==null)for(i in n)n[i]=iue(n[i],e.name,null);return this},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new WN(e)},call:function(e,t){if((i=arguments.length-2)>0)for(var n=new Array(i),r=0,i,s;r<i;++r)n[r]=arguments[r+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(s=this._[e],r=0,i=s.length;r<i;++r)s[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],i=0,s=r.length;i<s;++i)r[i].value.apply(t,n)}};function s_t(e,t){for(var n=0,r=e.length,i;n<r;++n)if((i=e[n]).name===t)return i.value}function iue(e,t,n){for(var r=0,i=e.length;r<i;++r)if(e[r].name===t){e[r]=r_t,e=e.slice(0,r).concat(e.slice(r+1));break}return n!=null&&e.push({name:t,value:n}),e}var kU="http://www.w3.org/1999/xhtml";const sue={svg:"http://www.w3.org/2000/svg",xhtml:kU,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function JD(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),sue.hasOwnProperty(t)?{space:sue[t],local:e}:e}function a_t(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===kU&&t.documentElement.namespaceURI===kU?t.createElement(e):t.createElementNS(n,e)}}function o_t(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function wAe(e){var t=JD(e);return(t.local?o_t:a_t)(t)}function l_t(){}function gZ(e){return e==null?l_t:function(){return this.querySelector(e)}}function u_t(e){typeof e!="function"&&(e=gZ(e));for(var t=this._groups,n=t.length,r=new Array(n),i=0;i<n;++i)for(var s=t[i],a=s.length,o=r[i]=new Array(a),l,u,d=0;d<a;++d)(l=s[d])&&(u=e.call(l,l.__data__,d,s))&&("__data__"in l&&(u.__data__=l.__data__),o[d]=u);return new vu(r,this._parents)}function c_t(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function d_t(){return[]}function EAe(e){return e==null?d_t:function(){return this.querySelectorAll(e)}}function f_t(e){return function(){return c_t(e.apply(this,arguments))}}function h_t(e){typeof e=="function"?e=f_t(e):e=EAe(e);for(var t=this._groups,n=t.length,r=[],i=[],s=0;s<n;++s)for(var a=t[s],o=a.length,l,u=0;u<o;++u)(l=a[u])&&(r.push(e.call(l,l.__data__,u,a)),i.push(l));return new vu(r,i)}function CAe(e){return function(){return this.matches(e)}}function kAe(e){return function(t){return t.matches(e)}}var p_t=Array.prototype.find;function m_t(e){return function(){return p_t.call(this.children,e)}}function g_t(){return this.firstElementChild}function b_t(e){return this.select(e==null?g_t:m_t(typeof e=="function"?e:kAe(e)))}var y_t=Array.prototype.filter;function v_t(){return Array.from(this.children)}function x_t(e){return function(){return y_t.call(this.children,e)}}function __t(e){return this.selectAll(e==null?v_t:x_t(typeof e=="function"?e:kAe(e)))}function S_t(e){typeof e!="function"&&(e=CAe(e));for(var t=this._groups,n=t.length,r=new Array(n),i=0;i<n;++i)for(var s=t[i],a=s.length,o=r[i]=[],l,u=0;u<a;++u)(l=s[u])&&e.call(l,l.__data__,u,s)&&o.push(l);return new vu(r,this._parents)}function TAe(e){return new Array(e.length)}function w_t(){return new vu(this._enter||this._groups.map(TAe),this._parents)}function dR(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}dR.prototype={constructor:dR,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 E_t(e){return function(){return e}}function C_t(e,t,n,r,i,s){for(var a=0,o,l=t.length,u=s.length;a<u;++a)(o=t[a])?(o.__data__=s[a],r[a]=o):n[a]=new dR(e,s[a]);for(;a<l;++a)(o=t[a])&&(i[a]=o)}function k_t(e,t,n,r,i,s,a){var o,l,u=new Map,d=t.length,f=s.length,h=new Array(d),m;for(o=0;o<d;++o)(l=t[o])&&(h[o]=m=a.call(l,l.__data__,o,t)+"",u.has(m)?i[o]=l:u.set(m,l));for(o=0;o<f;++o)m=a.call(e,s[o],o,s)+"",(l=u.get(m))?(r[o]=l,l.__data__=s[o],u.delete(m)):n[o]=new dR(e,s[o]);for(o=0;o<d;++o)(l=t[o])&&u.get(h[o])===l&&(i[o]=l)}function T_t(e){return e.__data__}function A_t(e,t){if(!arguments.length)return Array.from(this,T_t);var n=t?k_t:C_t,r=this._parents,i=this._groups;typeof e!="function"&&(e=E_t(e));for(var s=i.length,a=new Array(s),o=new Array(s),l=new Array(s),u=0;u<s;++u){var d=r[u],f=i[u],h=f.length,m=N_t(e.call(d,d&&d.__data__,u,r)),b=m.length,y=o[u]=new Array(b),v=a[u]=new Array(b),_=l[u]=new Array(h);n(d,f,y,v,_,m,t);for(var w=0,C=0,T,k;w<b;++w)if(T=y[w]){for(w>=C&&(C=w+1);!(k=v[C])&&++C<b;);T._next=k||null}}return a=new vu(a,r),a._enter=o,a._exit=l,a}function N_t(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function O_t(){return new vu(this._exit||this._groups.map(TAe),this._parents)}function R_t(e,t,n){var r=this.enter(),i=this,s=this.exit();return typeof e=="function"?(r=e(r),r&&(r=r.selection())):r=r.append(e+""),t!=null&&(i=t(i),i&&(i=i.selection())),n==null?s.remove():n(s),r&&i?r.merge(i).order():i}function I_t(e){for(var t=e.selection?e.selection():e,n=this._groups,r=t._groups,i=n.length,s=r.length,a=Math.min(i,s),o=new Array(i),l=0;l<a;++l)for(var u=n[l],d=r[l],f=u.length,h=o[l]=new Array(f),m,b=0;b<f;++b)(m=u[b]||d[b])&&(h[b]=m);for(;l<i;++l)o[l]=n[l];return new vu(o,this._parents)}function D_t(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var r=e[t],i=r.length-1,s=r[i],a;--i>=0;)(a=r[i])&&(s&&a.compareDocumentPosition(s)^4&&s.parentNode.insertBefore(a,s),s=a);return this}function P_t(e){e||(e=j_t);function t(f,h){return f&&h?e(f.__data__,h.__data__):!f-!h}for(var n=this._groups,r=n.length,i=new Array(r),s=0;s<r;++s){for(var a=n[s],o=a.length,l=i[s]=new Array(o),u,d=0;d<o;++d)(u=a[d])&&(l[d]=u);l.sort(t)}return new vu(i,this._parents).order()}function j_t(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function L_t(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function M_t(){return Array.from(this)}function F_t(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],i=0,s=r.length;i<s;++i){var a=r[i];if(a)return a}return null}function B_t(){let e=0;for(const t of this)++e;return e}function $_t(){return!this.node()}function U_t(e){for(var t=this._groups,n=0,r=t.length;n<r;++n)for(var i=t[n],s=0,a=i.length,o;s<a;++s)(o=i[s])&&e.call(o,o.__data__,s,i);return this}function z_t(e){return function(){this.removeAttribute(e)}}function H_t(e){return function(){this.removeAttributeNS(e.space,e.local)}}function V_t(e,t){return function(){this.setAttribute(e,t)}}function W_t(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function q_t(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function G_t(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 K_t(e,t){var n=JD(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?H_t:z_t:typeof t=="function"?n.local?G_t:q_t:n.local?W_t:V_t)(n,t))}function AAe(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function Y_t(e){return function(){this.style.removeProperty(e)}}function X_t(e,t,n){return function(){this.style.setProperty(e,t,n)}}function Z_t(e,t,n){return function(){var r=t.apply(this,arguments);r==null?this.style.removeProperty(e):this.style.setProperty(e,r,n)}}function Q_t(e,t,n){return arguments.length>1?this.each((t==null?Y_t:typeof t=="function"?Z_t:X_t)(e,t,n??"")):vx(this.node(),e)}function vx(e,t){return e.style.getPropertyValue(t)||AAe(e).getComputedStyle(e,null).getPropertyValue(t)}function J_t(e){return function(){delete this[e]}}function eSt(e,t){return function(){this[e]=t}}function tSt(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function nSt(e,t){return arguments.length>1?this.each((t==null?J_t:typeof t=="function"?tSt:eSt)(e,t)):this.node()[e]}function NAe(e){return e.trim().split(/^|\s+/)}function bZ(e){return e.classList||new OAe(e)}function OAe(e){this._node=e,this._names=NAe(e.getAttribute("class")||"")}OAe.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 RAe(e,t){for(var n=bZ(e),r=-1,i=t.length;++r<i;)n.add(t[r])}function IAe(e,t){for(var n=bZ(e),r=-1,i=t.length;++r<i;)n.remove(t[r])}function rSt(e){return function(){RAe(this,e)}}function iSt(e){return function(){IAe(this,e)}}function sSt(e,t){return function(){(t.apply(this,arguments)?RAe:IAe)(this,e)}}function aSt(e,t){var n=NAe(e+"");if(arguments.length<2){for(var r=bZ(this.node()),i=-1,s=n.length;++i<s;)if(!r.contains(n[i]))return!1;return!0}return this.each((typeof t=="function"?sSt:t?rSt:iSt)(n,t))}function oSt(){this.textContent=""}function lSt(e){return function(){this.textContent=e}}function uSt(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function cSt(e){return arguments.length?this.each(e==null?oSt:(typeof e=="function"?uSt:lSt)(e)):this.node().textContent}function dSt(){this.innerHTML=""}function fSt(e){return function(){this.innerHTML=e}}function hSt(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function pSt(e){return arguments.length?this.each(e==null?dSt:(typeof e=="function"?hSt:fSt)(e)):this.node().innerHTML}function mSt(){this.nextSibling&&this.parentNode.appendChild(this)}function gSt(){return this.each(mSt)}function bSt(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function ySt(){return this.each(bSt)}function vSt(e){var t=typeof e=="function"?e:wAe(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function xSt(){return null}function _St(e,t){var n=typeof e=="function"?e:wAe(e),r=t==null?xSt:typeof t=="function"?t:gZ(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})}function SSt(){var e=this.parentNode;e&&e.removeChild(this)}function wSt(){return this.each(SSt)}function ESt(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function CSt(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function kSt(e){return this.select(e?CSt:ESt)}function TSt(e){return arguments.length?this.property("__data__",e):this.node().__data__}function ASt(e){return function(t){e.call(this,t,this.__data__)}}function NSt(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 OSt(e){return function(){var t=this.__on;if(t){for(var n=0,r=-1,i=t.length,s;n<i;++n)s=t[n],(!e.type||s.type===e.type)&&s.name===e.name?this.removeEventListener(s.type,s.listener,s.options):t[++r]=s;++r?t.length=r:delete this.__on}}}function RSt(e,t,n){return function(){var r=this.__on,i,s=ASt(t);if(r){for(var a=0,o=r.length;a<o;++a)if((i=r[a]).type===e.type&&i.name===e.name){this.removeEventListener(i.type,i.listener,i.options),this.addEventListener(i.type,i.listener=s,i.options=n),i.value=t;return}}this.addEventListener(e.type,s,n),i={type:e.type,name:e.name,value:t,listener:s,options:n},r?r.push(i):this.__on=[i]}}function ISt(e,t,n){var r=NSt(e+""),i,s=r.length,a;if(arguments.length<2){var o=this.node().__on;if(o){for(var l=0,u=o.length,d;l<u;++l)for(i=0,d=o[l];i<s;++i)if((a=r[i]).type===d.type&&a.name===d.name)return d.value}return}for(o=t?RSt:OSt,i=0;i<s;++i)this.each(o(r[i],t,n));return this}function DAe(e,t,n){var r=AAe(e),i=r.CustomEvent;typeof i=="function"?i=new i(t,n):(i=r.document.createEvent("Event"),n?(i.initEvent(t,n.bubbles,n.cancelable),i.detail=n.detail):i.initEvent(t,!1,!1)),e.dispatchEvent(i)}function DSt(e,t){return function(){return DAe(this,e,t)}}function PSt(e,t){return function(){return DAe(this,e,t.apply(this,arguments))}}function jSt(e,t){return this.each((typeof t=="function"?PSt:DSt)(e,t))}function*LSt(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],i=0,s=r.length,a;i<s;++i)(a=r[i])&&(yield a)}var PAe=[null];function vu(e,t){this._groups=e,this._parents=t}function Z2(){return new vu([[document.documentElement]],PAe)}function MSt(){return this}vu.prototype=Z2.prototype={constructor:vu,select:u_t,selectAll:h_t,selectChild:b_t,selectChildren:__t,filter:S_t,data:A_t,enter:w_t,exit:O_t,join:R_t,merge:I_t,selection:MSt,order:D_t,sort:P_t,call:L_t,nodes:M_t,node:F_t,size:B_t,empty:$_t,each:U_t,attr:K_t,style:Q_t,property:nSt,classed:aSt,text:cSt,html:pSt,raise:gSt,lower:ySt,append:vSt,insert:_St,remove:wSt,clone:kSt,datum:TSt,on:ISt,dispatch:jSt,[Symbol.iterator]:LSt};function rc(e){return typeof e=="string"?new vu([[document.querySelector(e)]],[document.documentElement]):new vu([[e]],PAe)}function FSt(e){let t;for(;t=e.sourceEvent;)e=t;return e}function Kc(e,t){if(e=FSt(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 i=t.getBoundingClientRect();return[e.clientX-i.left-t.clientLeft,e.clientY-i.top-t.clientTop]}}return[e.pageX,e.pageY]}const BSt={passive:!1},zE={capture:!0,passive:!1};function q4(e){e.stopImmediatePropagation()}function F0(e){e.preventDefault(),e.stopImmediatePropagation()}function jAe(e){var t=e.document.documentElement,n=rc(e).on("dragstart.drag",F0,zE);"onselectstart"in t?n.on("selectstart.drag",F0,zE):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function LAe(e,t){var n=e.document.documentElement,r=rc(e).on("dragstart.drag",null);t&&(r.on("click.drag",F0,zE),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 LA=e=>()=>e;function TU(e,{sourceEvent:t,subject:n,target:r,identifier:i,active:s,x:a,y:o,dx:l,dy:u,dispatch:d}){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:i,enumerable:!0,configurable:!0},active:{value:s,enumerable:!0,configurable:!0},x:{value:a,enumerable:!0,configurable:!0},y:{value:o,enumerable:!0,configurable:!0},dx:{value:l,enumerable:!0,configurable:!0},dy:{value:u,enumerable:!0,configurable:!0},_:{value:d}})}TU.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function $St(e){return!e.ctrlKey&&!e.button}function USt(){return this.parentNode}function zSt(e,t){return t??{x:e.x,y:e.y}}function HSt(){return navigator.maxTouchPoints||"ontouchstart"in this}function VSt(){var e=$St,t=USt,n=zSt,r=HSt,i={},s=QD("start","drag","end"),a=0,o,l,u,d,f=0;function h(T){T.on("mousedown.drag",m).filter(r).on("touchstart.drag",v).on("touchmove.drag",_,BSt).on("touchend.drag touchcancel.drag",w).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function m(T,k){if(!(d||!e.call(this,T,k))){var S=C(this,t.call(this,T,k),T,k,"mouse");S&&(rc(T.view).on("mousemove.drag",b,zE).on("mouseup.drag",y,zE),jAe(T.view),q4(T),u=!1,o=T.clientX,l=T.clientY,S("start",T))}}function b(T){if(F0(T),!u){var k=T.clientX-o,S=T.clientY-l;u=k*k+S*S>f}i.mouse("drag",T)}function y(T){rc(T.view).on("mousemove.drag mouseup.drag",null),LAe(T.view,u),F0(T),i.mouse("end",T)}function v(T,k){if(e.call(this,T,k)){var S=T.changedTouches,A=t.call(this,T,k),R=S.length,I,D;for(I=0;I<R;++I)(D=C(this,A,T,k,S[I].identifier,S[I]))&&(q4(T),D("start",T,S[I]))}}function _(T){var k=T.changedTouches,S=k.length,A,R;for(A=0;A<S;++A)(R=i[k[A].identifier])&&(F0(T),R("drag",T,k[A]))}function w(T){var k=T.changedTouches,S=k.length,A,R;for(d&&clearTimeout(d),d=setTimeout(function(){d=null},500),A=0;A<S;++A)(R=i[k[A].identifier])&&(q4(T),R("end",T,k[A]))}function C(T,k,S,A,R,I){var D=s.copy(),P=Kc(I||S,k),j,B,L;if((L=n.call(T,new TU("beforestart",{sourceEvent:S,target:h,identifier:R,active:a,x:P[0],y:P[1],dx:0,dy:0,dispatch:D}),A))!=null)return j=L.x-P[0]||0,B=L.y-P[1]||0,function M($,U,W){var Y=P,G;switch($){case"start":i[R]=M,G=a++;break;case"end":delete i[R],--a;case"drag":P=Kc(W||U,k),G=a;break}D.call($,T,new TU($,{sourceEvent:U,subject:L,target:h,identifier:R,active:G,x:P[0]+j,y:P[1]+B,dx:P[0]-Y[0],dy:P[1]-Y[1],dispatch:D}),A)}}return h.filter=function(T){return arguments.length?(e=typeof T=="function"?T:LA(!!T),h):e},h.container=function(T){return arguments.length?(t=typeof T=="function"?T:LA(T),h):t},h.subject=function(T){return arguments.length?(n=typeof T=="function"?T:LA(T),h):n},h.touchable=function(T){return arguments.length?(r=typeof T=="function"?T:LA(!!T),h):r},h.on=function(){var T=s.on.apply(s,arguments);return T===s?h:T},h.clickDistance=function(T){return arguments.length?(f=(T=+T)*T,h):Math.sqrt(f)},h}function yZ(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function MAe(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function Q2(){}var HE=.7,fR=1/HE,B0="\\s*([+-]?\\d+)\\s*",VE="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",pf="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",WSt=/^#([0-9a-f]{3,8})$/,qSt=new RegExp(`^rgb\\(${B0},${B0},${B0}\\)$`),GSt=new RegExp(`^rgb\\(${pf},${pf},${pf}\\)$`),KSt=new RegExp(`^rgba\\(${B0},${B0},${B0},${VE}\\)$`),YSt=new RegExp(`^rgba\\(${pf},${pf},${pf},${VE}\\)$`),XSt=new RegExp(`^hsl\\(${VE},${pf},${pf}\\)$`),ZSt=new RegExp(`^hsla\\(${VE},${pf},${pf},${VE}\\)$`),aue={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};yZ(Q2,py,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:oue,formatHex:oue,formatHex8:QSt,formatHsl:JSt,formatRgb:lue,toString:lue});function oue(){return this.rgb().formatHex()}function QSt(){return this.rgb().formatHex8()}function JSt(){return FAe(this).formatHsl()}function lue(){return this.rgb().formatRgb()}function py(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=WSt.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?uue(t):n===3?new Tl(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?MA(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?MA(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=qSt.exec(e))?new Tl(t[1],t[2],t[3],1):(t=GSt.exec(e))?new Tl(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=KSt.exec(e))?MA(t[1],t[2],t[3],t[4]):(t=YSt.exec(e))?MA(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=XSt.exec(e))?fue(t[1],t[2]/100,t[3]/100,1):(t=ZSt.exec(e))?fue(t[1],t[2]/100,t[3]/100,t[4]):aue.hasOwnProperty(e)?uue(aue[e]):e==="transparent"?new Tl(NaN,NaN,NaN,0):null}function uue(e){return new Tl(e>>16&255,e>>8&255,e&255,1)}function MA(e,t,n,r){return r<=0&&(e=t=n=NaN),new Tl(e,t,n,r)}function ewt(e){return e instanceof Q2||(e=py(e)),e?(e=e.rgb(),new Tl(e.r,e.g,e.b,e.opacity)):new Tl}function AU(e,t,n,r){return arguments.length===1?ewt(e):new Tl(e,t,n,r??1)}function Tl(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}yZ(Tl,AU,MAe(Q2,{brighter(e){return e=e==null?fR:Math.pow(fR,e),new Tl(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?HE:Math.pow(HE,e),new Tl(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new Tl(Gb(this.r),Gb(this.g),Gb(this.b),hR(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:cue,formatHex:cue,formatHex8:twt,formatRgb:due,toString:due}));function cue(){return`#${Cb(this.r)}${Cb(this.g)}${Cb(this.b)}`}function twt(){return`#${Cb(this.r)}${Cb(this.g)}${Cb(this.b)}${Cb((isNaN(this.opacity)?1:this.opacity)*255)}`}function due(){const e=hR(this.opacity);return`${e===1?"rgb(":"rgba("}${Gb(this.r)}, ${Gb(this.g)}, ${Gb(this.b)}${e===1?")":`, ${e})`}`}function hR(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Gb(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Cb(e){return e=Gb(e),(e<16?"0":"")+e.toString(16)}function fue(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new ed(e,t,n,r)}function FAe(e){if(e instanceof ed)return new ed(e.h,e.s,e.l,e.opacity);if(e instanceof Q2||(e=py(e)),!e)return new ed;if(e instanceof ed)return e;e=e.rgb();var t=e.r/255,n=e.g/255,r=e.b/255,i=Math.min(t,n,r),s=Math.max(t,n,r),a=NaN,o=s-i,l=(s+i)/2;return o?(t===s?a=(n-r)/o+(n<r)*6:n===s?a=(r-t)/o+2:a=(t-n)/o+4,o/=l<.5?s+i:2-s-i,a*=60):o=l>0&&l<1?0:a,new ed(a,o,l,e.opacity)}function nwt(e,t,n,r){return arguments.length===1?FAe(e):new ed(e,t,n,r??1)}function ed(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}yZ(ed,nwt,MAe(Q2,{brighter(e){return e=e==null?fR:Math.pow(fR,e),new ed(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?HE:Math.pow(HE,e),new ed(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,i=2*n-r;return new Tl(G4(e>=240?e-240:e+120,i,r),G4(e,i,r),G4(e<120?e+240:e-120,i,r),this.opacity)},clamp(){return new ed(hue(this.h),FA(this.s),FA(this.l),hR(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=hR(this.opacity);return`${e===1?"hsl(":"hsla("}${hue(this.h)}, ${FA(this.s)*100}%, ${FA(this.l)*100}%${e===1?")":`, ${e})`}`}}));function hue(e){return e=(e||0)%360,e<0?e+360:e}function FA(e){return Math.max(0,Math.min(1,e||0))}function G4(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 vZ=e=>()=>e;function rwt(e,t){return function(n){return e+n*t}}function iwt(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 swt(e){return(e=+e)==1?BAe:function(t,n){return n-t?iwt(t,n,e):vZ(isNaN(t)?n:t)}}function BAe(e,t){var n=t-e;return n?rwt(e,n):vZ(isNaN(e)?t:e)}const pR=(function e(t){var n=swt(t);function r(i,s){var a=n((i=AU(i)).r,(s=AU(s)).r),o=n(i.g,s.g),l=n(i.b,s.b),u=BAe(i.opacity,s.opacity);return function(d){return i.r=a(d),i.g=o(d),i.b=l(d),i.opacity=u(d),i+""}}return r.gamma=e,r})(1);function awt(e,t){t||(t=[]);var n=e?Math.min(t.length,e.length):0,r=t.slice(),i;return function(s){for(i=0;i<n;++i)r[i]=e[i]*(1-s)+t[i]*s;return r}}function owt(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function lwt(e,t){var n=t?t.length:0,r=e?Math.min(n,e.length):0,i=new Array(r),s=new Array(n),a;for(a=0;a<r;++a)i[a]=z1(e[a],t[a]);for(;a<n;++a)s[a]=t[a];return function(o){for(a=0;a<r;++a)s[a]=i[a](o);return s}}function uwt(e,t){var n=new Date;return e=+e,t=+t,function(r){return n.setTime(e*(1-r)+t*r),n}}function Zc(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}function cwt(e,t){var n={},r={},i;(e===null||typeof e!="object")&&(e={}),(t===null||typeof t!="object")&&(t={});for(i in t)i in e?n[i]=z1(e[i],t[i]):r[i]=t[i];return function(s){for(i in n)r[i]=n[i](s);return r}}var NU=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,K4=new RegExp(NU.source,"g");function dwt(e){return function(){return e}}function fwt(e){return function(t){return e(t)+""}}function $Ae(e,t){var n=NU.lastIndex=K4.lastIndex=0,r,i,s,a=-1,o=[],l=[];for(e=e+"",t=t+"";(r=NU.exec(e))&&(i=K4.exec(t));)(s=i.index)>n&&(s=t.slice(n,s),o[a]?o[a]+=s:o[++a]=s),(r=r[0])===(i=i[0])?o[a]?o[a]+=i:o[++a]=i:(o[++a]=null,l.push({i:a,x:Zc(r,i)})),n=K4.lastIndex;return n<t.length&&(s=t.slice(n),o[a]?o[a]+=s:o[++a]=s),o.length<2?l[0]?fwt(l[0].x):dwt(t):(t=l.length,function(u){for(var d=0,f;d<t;++d)o[(f=l[d]).i]=f.x(u);return o.join("")})}function z1(e,t){var n=typeof t,r;return t==null||n==="boolean"?vZ(t):(n==="number"?Zc:n==="string"?(r=py(t))?(t=r,pR):$Ae:t instanceof py?pR:t instanceof Date?uwt:owt(t)?awt:Array.isArray(t)?lwt:typeof t.valueOf!="function"&&typeof t.toString!="function"||isNaN(t)?cwt:Zc)(e,t)}function xZ(e,t){return e=+e,t=+t,function(n){return Math.round(e*(1-n)+t*n)}}var pue=180/Math.PI,OU={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function UAe(e,t,n,r,i,s){var a,o,l;return(a=Math.sqrt(e*e+t*t))&&(e/=a,t/=a),(l=e*n+t*r)&&(n-=e*l,r-=t*l),(o=Math.sqrt(n*n+r*r))&&(n/=o,r/=o,l/=o),e*r<t*n&&(e=-e,t=-t,l=-l,a=-a),{translateX:i,translateY:s,rotate:Math.atan2(t,e)*pue,skewX:Math.atan(l)*pue,scaleX:a,scaleY:o}}var BA;function hwt(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?OU:UAe(t.a,t.b,t.c,t.d,t.e,t.f)}function pwt(e){return e==null||(BA||(BA=document.createElementNS("http://www.w3.org/2000/svg","g")),BA.setAttribute("transform",e),!(e=BA.transform.baseVal.consolidate()))?OU:(e=e.matrix,UAe(e.a,e.b,e.c,e.d,e.e,e.f))}function zAe(e,t,n,r){function i(u){return u.length?u.pop()+" ":""}function s(u,d,f,h,m,b){if(u!==f||d!==h){var y=m.push("translate(",null,t,null,n);b.push({i:y-4,x:Zc(u,f)},{i:y-2,x:Zc(d,h)})}else(f||h)&&m.push("translate("+f+t+h+n)}function a(u,d,f,h){u!==d?(u-d>180?d+=360:d-u>180&&(u+=360),h.push({i:f.push(i(f)+"rotate(",null,r)-2,x:Zc(u,d)})):d&&f.push(i(f)+"rotate("+d+r)}function o(u,d,f,h){u!==d?h.push({i:f.push(i(f)+"skewX(",null,r)-2,x:Zc(u,d)}):d&&f.push(i(f)+"skewX("+d+r)}function l(u,d,f,h,m,b){if(u!==f||d!==h){var y=m.push(i(m)+"scale(",null,",",null,")");b.push({i:y-4,x:Zc(u,f)},{i:y-2,x:Zc(d,h)})}else(f!==1||h!==1)&&m.push(i(m)+"scale("+f+","+h+")")}return function(u,d){var f=[],h=[];return u=e(u),d=e(d),s(u.translateX,u.translateY,d.translateX,d.translateY,f,h),a(u.rotate,d.rotate,f,h),o(u.skewX,d.skewX,f,h),l(u.scaleX,u.scaleY,d.scaleX,d.scaleY,f,h),u=d=null,function(m){for(var b=-1,y=h.length,v;++b<y;)f[(v=h[b]).i]=v.x(m);return f.join("")}}}var mwt=zAe(hwt,"px, ","px)","deg)"),gwt=zAe(pwt,", ",")",")"),bwt=1e-12;function mue(e){return((e=Math.exp(e))+1/e)/2}function ywt(e){return((e=Math.exp(e))-1/e)/2}function vwt(e){return((e=Math.exp(2*e))-1)/(e+1)}const xwt=(function e(t,n,r){function i(s,a){var o=s[0],l=s[1],u=s[2],d=a[0],f=a[1],h=a[2],m=d-o,b=f-l,y=m*m+b*b,v,_;if(y<bwt)_=Math.log(h/u)/t,v=function(A){return[o+A*m,l+A*b,u*Math.exp(t*A*_)]};else{var w=Math.sqrt(y),C=(h*h-u*u+r*y)/(2*u*n*w),T=(h*h-u*u-r*y)/(2*h*n*w),k=Math.log(Math.sqrt(C*C+1)-C),S=Math.log(Math.sqrt(T*T+1)-T);_=(S-k)/t,v=function(A){var R=A*_,I=mue(k),D=u/(n*w)*(I*vwt(t*R+k)-ywt(k));return[o+D*m,l+D*b,u*I/mue(t*R+k)]}}return v.duration=_*1e3*t/Math.SQRT2,v}return i.rho=function(s){var a=Math.max(.001,+s),o=a*a,l=o*o;return e(a,o,l)},i})(Math.SQRT2,2,4);function _wt(e,t){t===void 0&&(t=e,e=z1);for(var n=0,r=t.length-1,i=t[0],s=new Array(r<0?0:r);n<r;)s[n]=e(i,i=t[++n]);return function(a){var o=Math.max(0,Math.min(r-1,Math.floor(a*=r)));return s[o](a-o)}}var xx=0,ow=0,IS=0,HAe=1e3,mR,lw,gR=0,my=0,e5=0,WE=typeof performance=="object"&&performance.now?performance:Date,VAe=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function _Z(){return my||(VAe(Swt),my=WE.now()+e5)}function Swt(){my=0}function bR(){this._call=this._time=this._next=null}bR.prototype=WAe.prototype={constructor:bR,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?_Z():+n)+(t==null?0:+t),!this._next&&lw!==this&&(lw?lw._next=this:mR=this,lw=this),this._call=e,this._time=n,RU()},stop:function(){this._call&&(this._call=null,this._time=1/0,RU())}};function WAe(e,t,n){var r=new bR;return r.restart(e,t,n),r}function wwt(){_Z(),++xx;for(var e=mR,t;e;)(t=my-e._time)>=0&&e._call.call(void 0,t),e=e._next;--xx}function gue(){my=(gR=WE.now())+e5,xx=ow=0;try{wwt()}finally{xx=0,Cwt(),my=0}}function Ewt(){var e=WE.now(),t=e-gR;t>HAe&&(e5-=t,gR=e)}function Cwt(){for(var e,t=mR,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:mR=n);lw=e,RU(r)}function RU(e){if(!xx){ow&&(ow=clearTimeout(ow));var t=e-my;t>24?(e<1/0&&(ow=setTimeout(gue,e-WE.now()-e5)),IS&&(IS=clearInterval(IS))):(IS||(gR=WE.now(),IS=setInterval(Ewt,HAe)),xx=1,VAe(gue))}}function bue(e,t,n){var r=new bR;return t=t==null?0:+t,r.restart(i=>{r.stop(),e(i+t)},t,n),r}var kwt=QD("start","end","cancel","interrupt"),Twt=[],qAe=0,yue=1,IU=2,qN=3,vue=4,DU=5,GN=6;function t5(e,t,n,r,i,s){var a=e.__transition;if(!a)e.__transition={};else if(n in a)return;Awt(e,n,{name:t,index:r,group:i,on:kwt,tween:Twt,time:s.time,delay:s.delay,duration:s.duration,ease:s.ease,timer:null,state:qAe})}function SZ(e,t){var n=_d(e,t);if(n.state>qAe)throw new Error("too late; already scheduled");return n}function Mf(e,t){var n=_d(e,t);if(n.state>qN)throw new Error("too late; already running");return n}function _d(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function Awt(e,t,n){var r=e.__transition,i;r[t]=n,n.timer=WAe(s,0,n.time);function s(u){n.state=yue,n.timer.restart(a,n.delay,n.time),n.delay<=u&&a(u-n.delay)}function a(u){var d,f,h,m;if(n.state!==yue)return l();for(d in r)if(m=r[d],m.name===n.name){if(m.state===qN)return bue(a);m.state===vue?(m.state=GN,m.timer.stop(),m.on.call("interrupt",e,e.__data__,m.index,m.group),delete r[d]):+d<t&&(m.state=GN,m.timer.stop(),m.on.call("cancel",e,e.__data__,m.index,m.group),delete r[d])}if(bue(function(){n.state===qN&&(n.state=vue,n.timer.restart(o,n.delay,n.time),o(u))}),n.state=IU,n.on.call("start",e,e.__data__,n.index,n.group),n.state===IU){for(n.state=qN,i=new Array(h=n.tween.length),d=0,f=-1;d<h;++d)(m=n.tween[d].value.call(e,e.__data__,n.index,n.group))&&(i[++f]=m);i.length=f+1}}function o(u){for(var d=u<n.duration?n.ease.call(null,u/n.duration):(n.timer.restart(l),n.state=DU,1),f=-1,h=i.length;++f<h;)i[f].call(e,d);n.state===DU&&(n.on.call("end",e,e.__data__,n.index,n.group),l())}function l(){n.state=GN,n.timer.stop(),delete r[t];for(var u in r)return;delete e.__transition}}function KN(e,t){var n=e.__transition,r,i,s=!0,a;if(n){t=t==null?null:t+"";for(a in n){if((r=n[a]).name!==t){s=!1;continue}i=r.state>IU&&r.state<DU,r.state=GN,r.timer.stop(),r.on.call(i?"interrupt":"cancel",e,e.__data__,r.index,r.group),delete n[a]}s&&delete e.__transition}}function Nwt(e){return this.each(function(){KN(this,e)})}function Owt(e,t){var n,r;return function(){var i=Mf(this,e),s=i.tween;if(s!==n){r=n=s;for(var a=0,o=r.length;a<o;++a)if(r[a].name===t){r=r.slice(),r.splice(a,1);break}}i.tween=r}}function Rwt(e,t,n){var r,i;if(typeof n!="function")throw new Error;return function(){var s=Mf(this,e),a=s.tween;if(a!==r){i=(r=a).slice();for(var o={name:t,value:n},l=0,u=i.length;l<u;++l)if(i[l].name===t){i[l]=o;break}l===u&&i.push(o)}s.tween=i}}function Iwt(e,t){var n=this._id;if(e+="",arguments.length<2){for(var r=_d(this.node(),n).tween,i=0,s=r.length,a;i<s;++i)if((a=r[i]).name===e)return a.value;return null}return this.each((t==null?Owt:Rwt)(n,e,t))}function wZ(e,t,n){var r=e._id;return e.each(function(){var i=Mf(this,r);(i.value||(i.value={}))[t]=n.apply(this,arguments)}),function(i){return _d(i,r).value[t]}}function GAe(e,t){var n;return(typeof t=="number"?Zc:t instanceof py?pR:(n=py(t))?(t=n,pR):$Ae)(e,t)}function Dwt(e){return function(){this.removeAttribute(e)}}function Pwt(e){return function(){this.removeAttributeNS(e.space,e.local)}}function jwt(e,t,n){var r,i=n+"",s;return function(){var a=this.getAttribute(e);return a===i?null:a===r?s:s=t(r=a,n)}}function Lwt(e,t,n){var r,i=n+"",s;return function(){var a=this.getAttributeNS(e.space,e.local);return a===i?null:a===r?s:s=t(r=a,n)}}function Mwt(e,t,n){var r,i,s;return function(){var a,o=n(this),l;return o==null?void this.removeAttribute(e):(a=this.getAttribute(e),l=o+"",a===l?null:a===r&&l===i?s:(i=l,s=t(r=a,o)))}}function Fwt(e,t,n){var r,i,s;return function(){var a,o=n(this),l;return o==null?void this.removeAttributeNS(e.space,e.local):(a=this.getAttributeNS(e.space,e.local),l=o+"",a===l?null:a===r&&l===i?s:(i=l,s=t(r=a,o)))}}function Bwt(e,t){var n=JD(e),r=n==="transform"?gwt:GAe;return this.attrTween(e,typeof t=="function"?(n.local?Fwt:Mwt)(n,r,wZ(this,"attr."+e,t)):t==null?(n.local?Pwt:Dwt)(n):(n.local?Lwt:jwt)(n,r,t))}function $wt(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function Uwt(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function zwt(e,t){var n,r;function i(){var s=t.apply(this,arguments);return s!==r&&(n=(r=s)&&Uwt(e,s)),n}return i._value=t,i}function Hwt(e,t){var n,r;function i(){var s=t.apply(this,arguments);return s!==r&&(n=(r=s)&&$wt(e,s)),n}return i._value=t,i}function Vwt(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=JD(e);return this.tween(n,(r.local?zwt:Hwt)(r,t))}function Wwt(e,t){return function(){SZ(this,e).delay=+t.apply(this,arguments)}}function qwt(e,t){return t=+t,function(){SZ(this,e).delay=t}}function Gwt(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?Wwt:qwt)(t,e)):_d(this.node(),t).delay}function Kwt(e,t){return function(){Mf(this,e).duration=+t.apply(this,arguments)}}function Ywt(e,t){return t=+t,function(){Mf(this,e).duration=t}}function Xwt(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?Kwt:Ywt)(t,e)):_d(this.node(),t).duration}function Zwt(e,t){if(typeof t!="function")throw new Error;return function(){Mf(this,e).ease=t}}function Qwt(e){var t=this._id;return arguments.length?this.each(Zwt(t,e)):_d(this.node(),t).ease}function Jwt(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;Mf(this,e).ease=n}}function eEt(e){if(typeof e!="function")throw new Error;return this.each(Jwt(this._id,e))}function tEt(e){typeof e!="function"&&(e=CAe(e));for(var t=this._groups,n=t.length,r=new Array(n),i=0;i<n;++i)for(var s=t[i],a=s.length,o=r[i]=[],l,u=0;u<a;++u)(l=s[u])&&e.call(l,l.__data__,u,s)&&o.push(l);return new qh(r,this._parents,this._name,this._id)}function nEt(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,n=e._groups,r=t.length,i=n.length,s=Math.min(r,i),a=new Array(r),o=0;o<s;++o)for(var l=t[o],u=n[o],d=l.length,f=a[o]=new Array(d),h,m=0;m<d;++m)(h=l[m]||u[m])&&(f[m]=h);for(;o<r;++o)a[o]=t[o];return new qh(a,this._parents,this._name,this._id)}function rEt(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 iEt(e,t,n){var r,i,s=rEt(t)?SZ:Mf;return function(){var a=s(this,e),o=a.on;o!==r&&(i=(r=o).copy()).on(t,n),a.on=i}}function sEt(e,t){var n=this._id;return arguments.length<2?_d(this.node(),n).on.on(e):this.each(iEt(n,e,t))}function aEt(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function oEt(){return this.on("end.remove",aEt(this._id))}function lEt(e){var t=this._name,n=this._id;typeof e!="function"&&(e=gZ(e));for(var r=this._groups,i=r.length,s=new Array(i),a=0;a<i;++a)for(var o=r[a],l=o.length,u=s[a]=new Array(l),d,f,h=0;h<l;++h)(d=o[h])&&(f=e.call(d,d.__data__,h,o))&&("__data__"in d&&(f.__data__=d.__data__),u[h]=f,t5(u[h],t,n,h,u,_d(d,n)));return new qh(s,this._parents,t,n)}function uEt(e){var t=this._name,n=this._id;typeof e!="function"&&(e=EAe(e));for(var r=this._groups,i=r.length,s=[],a=[],o=0;o<i;++o)for(var l=r[o],u=l.length,d,f=0;f<u;++f)if(d=l[f]){for(var h=e.call(d,d.__data__,f,l),m,b=_d(d,n),y=0,v=h.length;y<v;++y)(m=h[y])&&t5(m,t,n,y,h,b);s.push(h),a.push(d)}return new qh(s,a,t,n)}var cEt=Z2.prototype.constructor;function dEt(){return new cEt(this._groups,this._parents)}function fEt(e,t){var n,r,i;return function(){var s=vx(this,e),a=(this.style.removeProperty(e),vx(this,e));return s===a?null:s===n&&a===r?i:i=t(n=s,r=a)}}function KAe(e){return function(){this.style.removeProperty(e)}}function hEt(e,t,n){var r,i=n+"",s;return function(){var a=vx(this,e);return a===i?null:a===r?s:s=t(r=a,n)}}function pEt(e,t,n){var r,i,s;return function(){var a=vx(this,e),o=n(this),l=o+"";return o==null&&(l=o=(this.style.removeProperty(e),vx(this,e))),a===l?null:a===r&&l===i?s:(i=l,s=t(r=a,o))}}function mEt(e,t){var n,r,i,s="style."+t,a="end."+s,o;return function(){var l=Mf(this,e),u=l.on,d=l.value[s]==null?o||(o=KAe(t)):void 0;(u!==n||i!==d)&&(r=(n=u).copy()).on(a,i=d),l.on=r}}function gEt(e,t,n){var r=(e+="")=="transform"?mwt:GAe;return t==null?this.styleTween(e,fEt(e,r)).on("end.style."+e,KAe(e)):typeof t=="function"?this.styleTween(e,pEt(e,r,wZ(this,"style."+e,t))).each(mEt(this._id,e)):this.styleTween(e,hEt(e,r,t),n).on("end.style."+e,null)}function bEt(e,t,n){return function(r){this.style.setProperty(e,t.call(this,r),n)}}function yEt(e,t,n){var r,i;function s(){var a=t.apply(this,arguments);return a!==i&&(r=(i=a)&&bEt(e,a,n)),r}return s._value=t,s}function vEt(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,yEt(e,t,n??""))}function xEt(e){return function(){this.textContent=e}}function _Et(e){return function(){var t=e(this);this.textContent=t??""}}function SEt(e){return this.tween("text",typeof e=="function"?_Et(wZ(this,"text",e)):xEt(e==null?"":e+""))}function wEt(e){return function(t){this.textContent=e.call(this,t)}}function EEt(e){var t,n;function r(){var i=e.apply(this,arguments);return i!==n&&(t=(n=i)&&wEt(i)),t}return r._value=e,r}function CEt(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,EEt(e))}function kEt(){for(var e=this._name,t=this._id,n=YAe(),r=this._groups,i=r.length,s=0;s<i;++s)for(var a=r[s],o=a.length,l,u=0;u<o;++u)if(l=a[u]){var d=_d(l,t);t5(l,e,n,u,a,{time:d.time+d.delay+d.duration,delay:0,duration:d.duration,ease:d.ease})}return new qh(r,this._parents,e,n)}function TEt(){var e,t,n=this,r=n._id,i=n.size();return new Promise(function(s,a){var o={value:a},l={value:function(){--i===0&&s()}};n.each(function(){var u=Mf(this,r),d=u.on;d!==e&&(t=(e=d).copy(),t._.cancel.push(o),t._.interrupt.push(o),t._.end.push(l)),u.on=t}),i===0&&s()})}var AEt=0;function qh(e,t,n,r){this._groups=e,this._parents=t,this._name=n,this._id=r}function YAe(){return++AEt}var lh=Z2.prototype;qh.prototype={constructor:qh,select:lEt,selectAll:uEt,selectChild:lh.selectChild,selectChildren:lh.selectChildren,filter:tEt,merge:nEt,selection:dEt,transition:kEt,call:lh.call,nodes:lh.nodes,node:lh.node,size:lh.size,empty:lh.empty,each:lh.each,on:sEt,attr:Bwt,attrTween:Vwt,style:gEt,styleTween:vEt,text:SEt,textTween:CEt,remove:oEt,tween:Iwt,delay:Gwt,duration:Xwt,ease:Qwt,easeVarying:eEt,end:TEt,[Symbol.iterator]:lh[Symbol.iterator]};function NEt(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var OEt={time:null,delay:0,duration:250,ease:NEt};function REt(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 IEt(e){var t,n;e instanceof qh?(t=e._id,e=e._name):(t=YAe(),(n=OEt).time=_Z(),e=e==null?null:e+"");for(var r=this._groups,i=r.length,s=0;s<i;++s)for(var a=r[s],o=a.length,l,u=0;u<o;++u)(l=a[u])&&t5(l,e,t,u,a,n||REt(l,t));return new qh(r,this._parents,e,t)}Z2.prototype.interrupt=Nwt;Z2.prototype.transition=IEt;const $A=e=>()=>e;function DEt(e,{sourceEvent:t,target:n,transform:r,dispatch:i}){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:i}})}function _h(e,t,n){this.k=e,this.x=t,this.y=n}_h.prototype={constructor:_h,scale:function(e){return e===1?this:new _h(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new _h(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 Rh=new _h(1,0,0);_h.prototype;function Y4(e){e.stopImmediatePropagation()}function DS(e){e.preventDefault(),e.stopImmediatePropagation()}function PEt(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function jEt(){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 xue(){return this.__zoom||Rh}function LEt(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function MEt(){return navigator.maxTouchPoints||"ontouchstart"in this}function FEt(e,t,n){var r=e.invertX(t[0][0])-n[0][0],i=e.invertX(t[1][0])-n[1][0],s=e.invertY(t[0][1])-n[0][1],a=e.invertY(t[1][1])-n[1][1];return e.translate(i>r?(r+i)/2:Math.min(0,r)||Math.max(0,i),a>s?(s+a)/2:Math.min(0,s)||Math.max(0,a))}function XAe(){var e=PEt,t=jEt,n=FEt,r=LEt,i=MEt,s=[0,1/0],a=[[-1/0,-1/0],[1/0,1/0]],o=250,l=xwt,u=QD("start","zoom","end"),d,f,h,m=500,b=150,y=0,v=10;function _(L){L.property("__zoom",xue).on("wheel.zoom",R,{passive:!1}).on("mousedown.zoom",I).on("dblclick.zoom",D).filter(i).on("touchstart.zoom",P).on("touchmove.zoom",j).on("touchend.zoom touchcancel.zoom",B).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}_.transform=function(L,M,$,U){var W=L.selection?L.selection():L;W.property("__zoom",xue),L!==W?k(L,M,$,U):W.interrupt().each(function(){S(this,arguments).event(U).start().zoom(null,typeof M=="function"?M.apply(this,arguments):M).end()})},_.scaleBy=function(L,M,$,U){_.scaleTo(L,function(){var W=this.__zoom.k,Y=typeof M=="function"?M.apply(this,arguments):M;return W*Y},$,U)},_.scaleTo=function(L,M,$,U){_.transform(L,function(){var W=t.apply(this,arguments),Y=this.__zoom,G=$==null?T(W):typeof $=="function"?$.apply(this,arguments):$,q=Y.invert(G),X=typeof M=="function"?M.apply(this,arguments):M;return n(C(w(Y,X),G,q),W,a)},$,U)},_.translateBy=function(L,M,$,U){_.transform(L,function(){return n(this.__zoom.translate(typeof M=="function"?M.apply(this,arguments):M,typeof $=="function"?$.apply(this,arguments):$),t.apply(this,arguments),a)},null,U)},_.translateTo=function(L,M,$,U,W){_.transform(L,function(){var Y=t.apply(this,arguments),G=this.__zoom,q=U==null?T(Y):typeof U=="function"?U.apply(this,arguments):U;return n(Rh.translate(q[0],q[1]).scale(G.k).translate(typeof M=="function"?-M.apply(this,arguments):-M,typeof $=="function"?-$.apply(this,arguments):-$),Y,a)},U,W)};function w(L,M){return M=Math.max(s[0],Math.min(s[1],M)),M===L.k?L:new _h(M,L.x,L.y)}function C(L,M,$){var U=M[0]-$[0]*L.k,W=M[1]-$[1]*L.k;return U===L.x&&W===L.y?L:new _h(L.k,U,W)}function T(L){return[(+L[0][0]+ +L[1][0])/2,(+L[0][1]+ +L[1][1])/2]}function k(L,M,$,U){L.on("start.zoom",function(){S(this,arguments).event(U).start()}).on("interrupt.zoom end.zoom",function(){S(this,arguments).event(U).end()}).tween("zoom",function(){var W=this,Y=arguments,G=S(W,Y).event(U),q=t.apply(W,Y),X=$==null?T(q):typeof $=="function"?$.apply(W,Y):$,z=Math.max(q[1][0]-q[0][0],q[1][1]-q[0][1]),Q=W.__zoom,ee=typeof M=="function"?M.apply(W,Y):M,ne=l(Q.invert(X).concat(z/Q.k),ee.invert(X).concat(z/ee.k));return function(ae){if(ae===1)ae=ee;else{var fe=ne(ae),re=z/fe[2];ae=new _h(re,X[0]-fe[0]*re,X[1]-fe[1]*re)}G.zoom(null,ae)}})}function S(L,M,$){return!$&&L.__zooming||new A(L,M)}function A(L,M){this.that=L,this.args=M,this.active=0,this.sourceEvent=null,this.extent=t.apply(L,M),this.taps=0}A.prototype={event:function(L){return L&&(this.sourceEvent=L),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(L,M){return this.mouse&&L!=="mouse"&&(this.mouse[1]=M.invert(this.mouse[0])),this.touch0&&L!=="touch"&&(this.touch0[1]=M.invert(this.touch0[0])),this.touch1&&L!=="touch"&&(this.touch1[1]=M.invert(this.touch1[0])),this.that.__zoom=M,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(L){var M=rc(this.that).datum();u.call(L,this.that,new DEt(L,{sourceEvent:this.sourceEvent,target:_,transform:this.that.__zoom,dispatch:u}),M)}};function R(L,...M){if(!e.apply(this,arguments))return;var $=S(this,M).event(L),U=this.__zoom,W=Math.max(s[0],Math.min(s[1],U.k*Math.pow(2,r.apply(this,arguments)))),Y=Kc(L);if($.wheel)($.mouse[0][0]!==Y[0]||$.mouse[0][1]!==Y[1])&&($.mouse[1]=U.invert($.mouse[0]=Y)),clearTimeout($.wheel);else{if(U.k===W)return;$.mouse=[Y,U.invert(Y)],KN(this),$.start()}DS(L),$.wheel=setTimeout(G,b),$.zoom("mouse",n(C(w(U,W),$.mouse[0],$.mouse[1]),$.extent,a));function G(){$.wheel=null,$.end()}}function I(L,...M){if(h||!e.apply(this,arguments))return;var $=L.currentTarget,U=S(this,M,!0).event(L),W=rc(L.view).on("mousemove.zoom",X,!0).on("mouseup.zoom",z,!0),Y=Kc(L,$),G=L.clientX,q=L.clientY;jAe(L.view),Y4(L),U.mouse=[Y,this.__zoom.invert(Y)],KN(this),U.start();function X(Q){if(DS(Q),!U.moved){var ee=Q.clientX-G,ne=Q.clientY-q;U.moved=ee*ee+ne*ne>y}U.event(Q).zoom("mouse",n(C(U.that.__zoom,U.mouse[0]=Kc(Q,$),U.mouse[1]),U.extent,a))}function z(Q){W.on("mousemove.zoom mouseup.zoom",null),LAe(Q.view,U.moved),DS(Q),U.event(Q).end()}}function D(L,...M){if(e.apply(this,arguments)){var $=this.__zoom,U=Kc(L.changedTouches?L.changedTouches[0]:L,this),W=$.invert(U),Y=$.k*(L.shiftKey?.5:2),G=n(C(w($,Y),U,W),t.apply(this,M),a);DS(L),o>0?rc(this).transition().duration(o).call(k,G,U,L):rc(this).call(_.transform,G,U,L)}}function P(L,...M){if(e.apply(this,arguments)){var $=L.touches,U=$.length,W=S(this,M,L.changedTouches.length===U).event(L),Y,G,q,X;for(Y4(L),G=0;G<U;++G)q=$[G],X=Kc(q,this),X=[X,this.__zoom.invert(X),q.identifier],W.touch0?!W.touch1&&W.touch0[2]!==X[2]&&(W.touch1=X,W.taps=0):(W.touch0=X,Y=!0,W.taps=1+!!d);d&&(d=clearTimeout(d)),Y&&(W.taps<2&&(f=X[0],d=setTimeout(function(){d=null},m)),KN(this),W.start())}}function j(L,...M){if(this.__zooming){var $=S(this,M).event(L),U=L.changedTouches,W=U.length,Y,G,q,X;for(DS(L),Y=0;Y<W;++Y)G=U[Y],q=Kc(G,this),$.touch0&&$.touch0[2]===G.identifier?$.touch0[0]=q:$.touch1&&$.touch1[2]===G.identifier&&($.touch1[0]=q);if(G=$.that.__zoom,$.touch1){var z=$.touch0[0],Q=$.touch0[1],ee=$.touch1[0],ne=$.touch1[1],ae=(ae=ee[0]-z[0])*ae+(ae=ee[1]-z[1])*ae,fe=(fe=ne[0]-Q[0])*fe+(fe=ne[1]-Q[1])*fe;G=w(G,Math.sqrt(ae/fe)),q=[(z[0]+ee[0])/2,(z[1]+ee[1])/2],X=[(Q[0]+ne[0])/2,(Q[1]+ne[1])/2]}else if($.touch0)q=$.touch0[0],X=$.touch0[1];else return;$.zoom("touch",n(C(G,q,X),$.extent,a))}}function B(L,...M){if(this.__zooming){var $=S(this,M).event(L),U=L.changedTouches,W=U.length,Y,G;for(Y4(L),h&&clearTimeout(h),h=setTimeout(function(){h=null},m),Y=0;Y<W;++Y)G=U[Y],$.touch0&&$.touch0[2]===G.identifier?delete $.touch0:$.touch1&&$.touch1[2]===G.identifier&&delete $.touch1;if($.touch1&&!$.touch0&&($.touch0=$.touch1,delete $.touch1),$.touch0)$.touch0[1]=this.__zoom.invert($.touch0[0]);else if($.end(),$.taps===2&&(G=Kc(G,this),Math.hypot(f[0]-G[0],f[1]-G[1])<v)){var q=rc(this).on("dblclick.zoom");q&&q.apply(this,arguments)}}}return _.wheelDelta=function(L){return arguments.length?(r=typeof L=="function"?L:$A(+L),_):r},_.filter=function(L){return arguments.length?(e=typeof L=="function"?L:$A(!!L),_):e},_.touchable=function(L){return arguments.length?(i=typeof L=="function"?L:$A(!!L),_):i},_.extent=function(L){return arguments.length?(t=typeof L=="function"?L:$A([[+L[0][0],+L[0][1]],[+L[1][0],+L[1][1]]]),_):t},_.scaleExtent=function(L){return arguments.length?(s[0]=+L[0],s[1]=+L[1],_):[s[0],s[1]]},_.translateExtent=function(L){return arguments.length?(a[0][0]=+L[0][0],a[1][0]=+L[1][0],a[0][1]=+L[0][1],a[1][1]=+L[1][1],_):[[a[0][0],a[0][1]],[a[1][0],a[1][1]]]},_.constrain=function(L){return arguments.length?(n=L,_):n},_.duration=function(L){return arguments.length?(o=+L,_):o},_.interpolate=function(L){return arguments.length?(l=L,_):l},_.on=function(){var L=u.on.apply(u,arguments);return L===u?_:L},_.clickDistance=function(L){return arguments.length?(y=(L=+L)*L,_):Math.sqrt(y)},_.tapDistance=function(L){return arguments.length?(v=+L,_):v},_}const n5=x.createContext(null),BEt=n5.Provider,Gh={error001:()=>"[React Flow]: Seems like you have not used zustand provider as an ancestor. Help: https://reactflow.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 React Flow 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,t)=>`Couldn't create edge for ${e?"target":"source"} handle id: "${e?t.targetHandle:t.sourceHandle}", edge id: ${t.id}.`,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.`},ZAe=Gh.error001();function Pi(e,t){const n=x.useContext(n5);if(n===null)throw new Error(ZAe);return SAe(n,e,t)}const ya=()=>{const e=x.useContext(n5);if(e===null)throw new Error(ZAe);return x.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe,destroy:e.destroy}),[e])},$Et=e=>e.userSelectionActive?"none":"all";function EZ({position:e,children:t,className:n,style:r,...i}){const s=Pi($Et),a=`${e}`.split("-");return Z.createElement("div",{className:bo(["react-flow__panel",n,...a]),style:{...r,pointerEvents:s},...i},t)}function UEt({proOptions:e,position:t="bottom-right"}){return e?.hideAttribution?null:Z.createElement(EZ,{position:t,className:"react-flow__attribution","data-message":"Please only hide this attribution when you are subscribed to React Flow Pro: https://reactflow.dev/pro"},Z.createElement("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution"},"React Flow"))}const zEt=({x:e,y:t,label:n,labelStyle:r={},labelShowBg:i=!0,labelBgStyle:s={},labelBgPadding:a=[2,4],labelBgBorderRadius:o=2,children:l,className:u,...d})=>{const f=x.useRef(null),[h,m]=x.useState({x:0,y:0,width:0,height:0}),b=bo(["react-flow__edge-textwrapper",u]);return x.useEffect(()=>{if(f.current){const y=f.current.getBBox();m({x:y.x,y:y.y,width:y.width,height:y.height})}},[n]),typeof n>"u"||!n?null:Z.createElement("g",{transform:`translate(${e-h.width/2} ${t-h.height/2})`,className:b,visibility:h.width?"visible":"hidden",...d},i&&Z.createElement("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:s,rx:o,ry:o}),Z.createElement("text",{className:"react-flow__edge-text",y:h.height/2,dy:"0.3em",ref:f,style:r},n),l)};var HEt=x.memo(zEt);const CZ=e=>({width:e.offsetWidth,height:e.offsetHeight}),_x=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),kZ=(e={x:0,y:0},t)=>({x:_x(e.x,t[0][0],t[1][0]),y:_x(e.y,t[0][1],t[1][1])}),_ue=(e,t,n)=>e<t?_x(Math.abs(e-t),1,50)/50:e>n?-_x(Math.abs(e-n),1,50)/50:0,QAe=(e,t)=>{const n=_ue(e.x,35,t.width-35)*20,r=_ue(e.y,35,t.height-35)*20;return[n,r]},JAe=e=>e.getRootNode?.()||window?.document,eNe=(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)}),qE=({x:e,y:t,width:n,height:r})=>({x:e,y:t,x2:e+n,y2:t+r}),tNe=({x:e,y:t,x2:n,y2:r})=>({x:e,y:t,width:n-e,height:r-t}),Sue=e=>({...e.positionAbsolute||{x:0,y:0},width:e.width||0,height:e.height||0}),VEt=(e,t)=>tNe(eNe(qE(e),qE(t))),PU=(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)},WEt=e=>uc(e.width)&&uc(e.height)&&uc(e.x)&&uc(e.y),uc=e=>!isNaN(e)&&isFinite(e),Cs=Symbol.for("internals"),nNe=["Enter"," ","Escape"],qEt=(e,t)=>{},GEt=e=>"nativeEvent"in e;function jU(e){const n=(GEt(e)?e.nativeEvent:e).composedPath?.()?.[0]||e.target;return["INPUT","SELECT","TEXTAREA"].includes(n?.nodeName)||n?.hasAttribute("contenteditable")||!!n?.closest(".nokey")}const rNe=e=>"clientX"in e,Mm=(e,t)=>{const n=rNe(e),r=n?e.clientX:e.touches?.[0].clientX,i=n?e.clientY:e.touches?.[0].clientY;return{x:r-(t?.left??0),y:i-(t?.top??0)}},yR=()=>typeof navigator<"u"&&navigator?.userAgent?.indexOf("Mac")>=0,J2=({id:e,path:t,labelX:n,labelY:r,label:i,labelStyle:s,labelShowBg:a,labelBgStyle:o,labelBgPadding:l,labelBgBorderRadius:u,style:d,markerEnd:f,markerStart:h,interactionWidth:m=20})=>Z.createElement(Z.Fragment,null,Z.createElement("path",{id:e,style:d,d:t,fill:"none",className:"react-flow__edge-path",markerEnd:f,markerStart:h}),m&&Z.createElement("path",{d:t,fill:"none",strokeOpacity:0,strokeWidth:m,className:"react-flow__edge-interaction"}),i&&uc(n)&&uc(r)?Z.createElement(HEt,{x:n,y:r,label:i,labelStyle:s,labelShowBg:a,labelBgStyle:o,labelBgPadding:l,labelBgBorderRadius:u}):null);J2.displayName="BaseEdge";function PS(e,t,n){return n===void 0?n:r=>{const i=t().edges.find(s=>s.id===e);i&&n(r,{...i})}}function iNe({sourceX:e,sourceY:t,targetX:n,targetY:r}){const i=Math.abs(n-e)/2,s=n<e?n+i:n-i,a=Math.abs(r-t)/2,o=r<t?r+a:r-a;return[s,o,i,a]}function sNe({sourceX:e,sourceY:t,targetX:n,targetY:r,sourceControlX:i,sourceControlY:s,targetControlX:a,targetControlY:o}){const l=e*.125+i*.375+a*.375+n*.125,u=t*.125+s*.375+o*.375+r*.125,d=Math.abs(l-e),f=Math.abs(u-t);return[l,u,d,f]}var gy;(function(e){e.Strict="strict",e.Loose="loose"})(gy||(gy={}));var kb;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(kb||(kb={}));var GE;(function(e){e.Partial="partial",e.Full="full"})(GE||(GE={}));var fm;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(fm||(fm={}));var KE;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(KE||(KE={}));var wn;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(wn||(wn={}));function wue({pos:e,x1:t,y1:n,x2:r,y2:i}){return e===wn.Left||e===wn.Right?[.5*(t+r),n]:[t,.5*(n+i)]}function aNe({sourceX:e,sourceY:t,sourcePosition:n=wn.Bottom,targetX:r,targetY:i,targetPosition:s=wn.Top}){const[a,o]=wue({pos:n,x1:e,y1:t,x2:r,y2:i}),[l,u]=wue({pos:s,x1:r,y1:i,x2:e,y2:t}),[d,f,h,m]=sNe({sourceX:e,sourceY:t,targetX:r,targetY:i,sourceControlX:a,sourceControlY:o,targetControlX:l,targetControlY:u});return[`M${e},${t} C${a},${o} ${l},${u} ${r},${i}`,d,f,h,m]}const TZ=x.memo(({sourceX:e,sourceY:t,targetX:n,targetY:r,sourcePosition:i=wn.Bottom,targetPosition:s=wn.Top,label:a,labelStyle:o,labelShowBg:l,labelBgStyle:u,labelBgPadding:d,labelBgBorderRadius:f,style:h,markerEnd:m,markerStart:b,interactionWidth:y})=>{const[v,_,w]=aNe({sourceX:e,sourceY:t,sourcePosition:i,targetX:n,targetY:r,targetPosition:s});return Z.createElement(J2,{path:v,labelX:_,labelY:w,label:a,labelStyle:o,labelShowBg:l,labelBgStyle:u,labelBgPadding:d,labelBgBorderRadius:f,style:h,markerEnd:m,markerStart:b,interactionWidth:y})});TZ.displayName="SimpleBezierEdge";const Eue={[wn.Left]:{x:-1,y:0},[wn.Right]:{x:1,y:0},[wn.Top]:{x:0,y:-1},[wn.Bottom]:{x:0,y:1}},KEt=({source:e,sourcePosition:t=wn.Bottom,target:n})=>t===wn.Left||t===wn.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},Cue=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function YEt({source:e,sourcePosition:t=wn.Bottom,target:n,targetPosition:r=wn.Top,center:i,offset:s}){const a=Eue[t],o=Eue[r],l={x:e.x+a.x*s,y:e.y+a.y*s},u={x:n.x+o.x*s,y:n.y+o.y*s},d=KEt({source:l,sourcePosition:t,target:u}),f=d.x!==0?"x":"y",h=d[f];let m=[],b,y;const v={x:0,y:0},_={x:0,y:0},[w,C,T,k]=iNe({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(a[f]*o[f]===-1){b=i.x??w,y=i.y??C;const A=[{x:b,y:l.y},{x:b,y:u.y}],R=[{x:l.x,y},{x:u.x,y}];a[f]===h?m=f==="x"?A:R:m=f==="x"?R:A}else{const A=[{x:l.x,y:u.y}],R=[{x:u.x,y:l.y}];if(f==="x"?m=a.x===h?R:A:m=a.y===h?A:R,t===r){const B=Math.abs(e[f]-n[f]);if(B<=s){const L=Math.min(s-1,s-B);a[f]===h?v[f]=(l[f]>e[f]?-1:1)*L:_[f]=(u[f]>n[f]?-1:1)*L}}if(t!==r){const B=f==="x"?"y":"x",L=a[f]===o[B],M=l[B]>u[B],$=l[B]<u[B];(a[f]===1&&(!L&&M||L&&$)||a[f]!==1&&(!L&&$||L&&M))&&(m=f==="x"?A:R)}const I={x:l.x+v.x,y:l.y+v.y},D={x:u.x+_.x,y:u.y+_.y},P=Math.max(Math.abs(I.x-m[0].x),Math.abs(D.x-m[0].x)),j=Math.max(Math.abs(I.y-m[0].y),Math.abs(D.y-m[0].y));P>=j?(b=(I.x+D.x)/2,y=m[0].y):(b=m[0].x,y=(I.y+D.y)/2)}return[[e,{x:l.x+v.x,y:l.y+v.y},...m,{x:u.x+_.x,y:u.y+_.y},n],b,y,T,k]}function XEt(e,t,n,r){const i=Math.min(Cue(e,t)/2,Cue(t,n)/2,r),{x:s,y:a}=t;if(e.x===s&&s===n.x||e.y===a&&a===n.y)return`L${s} ${a}`;if(e.y===a){const u=e.x<n.x?-1:1,d=e.y<n.y?1:-1;return`L ${s+i*u},${a}Q ${s},${a} ${s},${a+i*d}`}const o=e.x<n.x?1:-1,l=e.y<n.y?-1:1;return`L ${s},${a+i*l}Q ${s},${a} ${s+i*o},${a}`}function LU({sourceX:e,sourceY:t,sourcePosition:n=wn.Bottom,targetX:r,targetY:i,targetPosition:s=wn.Top,borderRadius:a=5,centerX:o,centerY:l,offset:u=20}){const[d,f,h,m,b]=YEt({source:{x:e,y:t},sourcePosition:n,target:{x:r,y:i},targetPosition:s,center:{x:o,y:l},offset:u});return[d.reduce((v,_,w)=>{let C="";return w>0&&w<d.length-1?C=XEt(d[w-1],_,d[w+1],a):C=`${w===0?"M":"L"}${_.x} ${_.y}`,v+=C,v},""),f,h,m,b]}const r5=x.memo(({sourceX:e,sourceY:t,targetX:n,targetY:r,label:i,labelStyle:s,labelShowBg:a,labelBgStyle:o,labelBgPadding:l,labelBgBorderRadius:u,style:d,sourcePosition:f=wn.Bottom,targetPosition:h=wn.Top,markerEnd:m,markerStart:b,pathOptions:y,interactionWidth:v})=>{const[_,w,C]=LU({sourceX:e,sourceY:t,sourcePosition:f,targetX:n,targetY:r,targetPosition:h,borderRadius:y?.borderRadius,offset:y?.offset});return Z.createElement(J2,{path:_,labelX:w,labelY:C,label:i,labelStyle:s,labelShowBg:a,labelBgStyle:o,labelBgPadding:l,labelBgBorderRadius:u,style:d,markerEnd:m,markerStart:b,interactionWidth:v})});r5.displayName="SmoothStepEdge";const AZ=x.memo(e=>Z.createElement(r5,{...e,pathOptions:x.useMemo(()=>({borderRadius:0,offset:e.pathOptions?.offset}),[e.pathOptions?.offset])}));AZ.displayName="StepEdge";function ZEt({sourceX:e,sourceY:t,targetX:n,targetY:r}){const[i,s,a,o]=iNe({sourceX:e,sourceY:t,targetX:n,targetY:r});return[`M ${e},${t}L ${n},${r}`,i,s,a,o]}const NZ=x.memo(({sourceX:e,sourceY:t,targetX:n,targetY:r,label:i,labelStyle:s,labelShowBg:a,labelBgStyle:o,labelBgPadding:l,labelBgBorderRadius:u,style:d,markerEnd:f,markerStart:h,interactionWidth:m})=>{const[b,y,v]=ZEt({sourceX:e,sourceY:t,targetX:n,targetY:r});return Z.createElement(J2,{path:b,labelX:y,labelY:v,label:i,labelStyle:s,labelShowBg:a,labelBgStyle:o,labelBgPadding:l,labelBgBorderRadius:u,style:d,markerEnd:f,markerStart:h,interactionWidth:m})});NZ.displayName="StraightEdge";function UA(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function kue({pos:e,x1:t,y1:n,x2:r,y2:i,c:s}){switch(e){case wn.Left:return[t-UA(t-r,s),n];case wn.Right:return[t+UA(r-t,s),n];case wn.Top:return[t,n-UA(n-i,s)];case wn.Bottom:return[t,n+UA(i-n,s)]}}function oNe({sourceX:e,sourceY:t,sourcePosition:n=wn.Bottom,targetX:r,targetY:i,targetPosition:s=wn.Top,curvature:a=.25}){const[o,l]=kue({pos:n,x1:e,y1:t,x2:r,y2:i,c:a}),[u,d]=kue({pos:s,x1:r,y1:i,x2:e,y2:t,c:a}),[f,h,m,b]=sNe({sourceX:e,sourceY:t,targetX:r,targetY:i,sourceControlX:o,sourceControlY:l,targetControlX:u,targetControlY:d});return[`M${e},${t} C${o},${l} ${u},${d} ${r},${i}`,f,h,m,b]}const vR=x.memo(({sourceX:e,sourceY:t,targetX:n,targetY:r,sourcePosition:i=wn.Bottom,targetPosition:s=wn.Top,label:a,labelStyle:o,labelShowBg:l,labelBgStyle:u,labelBgPadding:d,labelBgBorderRadius:f,style:h,markerEnd:m,markerStart:b,pathOptions:y,interactionWidth:v})=>{const[_,w,C]=oNe({sourceX:e,sourceY:t,sourcePosition:i,targetX:n,targetY:r,targetPosition:s,curvature:y?.curvature});return Z.createElement(J2,{path:_,labelX:w,labelY:C,label:a,labelStyle:o,labelShowBg:l,labelBgStyle:u,labelBgPadding:d,labelBgBorderRadius:f,style:h,markerEnd:m,markerStart:b,interactionWidth:v})});vR.displayName="BezierEdge";const OZ=x.createContext(null),QEt=OZ.Provider;OZ.Consumer;const JEt=()=>x.useContext(OZ),eCt=e=>"id"in e&&"source"in e&&"target"in e,tCt=({source:e,sourceHandle:t,target:n,targetHandle:r})=>`reactflow__edge-${e}${t||""}-${n}${r||""}`,MU=(e,t)=>typeof e>"u"?"":typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(r=>`${r}=${e[r]}`).join("&")}`,nCt=(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)),rCt=(e,t)=>{if(!e.source||!e.target)return t;let n;return eCt(e)?n={...e}:n={...e,id:tCt(e)},nCt(n,t)?t:t.concat(n)},FU=({x:e,y:t},[n,r,i],s,[a,o])=>{const l={x:(e-n)/i,y:(t-r)/i};return s?{x:a*Math.round(l.x/a),y:o*Math.round(l.y/o)}:l},lNe=({x:e,y:t},[n,r,i])=>({x:e*i+n,y:t*i+r}),Kb=(e,t=[0,0])=>{if(!e)return{x:0,y:0,positionAbsolute:{x:0,y:0}};const n=(e.width??0)*t[0],r=(e.height??0)*t[1],i={x:e.position.x-n,y:e.position.y-r};return{...i,positionAbsolute:e.positionAbsolute?{x:e.positionAbsolute.x-n,y:e.positionAbsolute.y-r}:i}},i5=(e,t=[0,0])=>{if(e.length===0)return{x:0,y:0,width:0,height:0};const n=e.reduce((r,i)=>{const{x:s,y:a}=Kb(i,t).positionAbsolute;return eNe(r,qE({x:s,y:a,width:i.width||0,height:i.height||0}))},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return tNe(n)},uNe=(e,t,[n,r,i]=[0,0,1],s=!1,a=!1,o=[0,0])=>{const l={x:(t.x-n)/i,y:(t.y-r)/i,width:t.width/i,height:t.height/i},u=[];return e.forEach(d=>{const{width:f,height:h,selectable:m=!0,hidden:b=!1}=d;if(a&&!m||b)return!1;const{positionAbsolute:y}=Kb(d,o),v={x:y.x,y:y.y,width:f||0,height:h||0},_=PU(l,v),w=typeof f>"u"||typeof h>"u"||f===null||h===null,C=s&&_>0,T=(f||0)*(h||0);(w||C||_>=T||d.dragging)&&u.push(d)}),u},cNe=(e,t)=>{const n=e.map(r=>r.id);return t.filter(r=>n.includes(r.source)||n.includes(r.target))},dNe=(e,t,n,r,i,s=.1)=>{const a=t/(e.width*(1+s)),o=n/(e.height*(1+s)),l=Math.min(a,o),u=_x(l,r,i),d=e.x+e.width/2,f=e.y+e.height/2,h=t/2-d*u,m=n/2-f*u;return{x:h,y:m,zoom:u}},sb=(e,t=0)=>e.transition().duration(t);function Tue(e,t,n,r){return(t[n]||[]).reduce((i,s)=>(`${e.id}-${s.id}-${n}`!==r&&i.push({id:s.id||null,type:n,nodeId:e.id,x:(e.positionAbsolute?.x??0)+s.x+s.width/2,y:(e.positionAbsolute?.y??0)+s.y+s.height/2}),i),[])}function iCt(e,t,n,r,i,s){const{x:a,y:o}=Mm(e),u=t.elementsFromPoint(a,o).find(b=>b.classList.contains("react-flow__handle"));if(u){const b=u.getAttribute("data-nodeid");if(b){const y=RZ(void 0,u),v=u.getAttribute("data-handleid"),_=s({nodeId:b,id:v,type:y});if(_){const w=i.find(C=>C.nodeId===b&&C.type===y&&C.id===v);return{handle:{id:v,type:y,nodeId:b,x:w?.x||n.x,y:w?.y||n.y},validHandleResult:_}}}}let d=[],f=1/0;if(i.forEach(b=>{const y=Math.sqrt((b.x-n.x)**2+(b.y-n.y)**2);if(y<=r){const v=s(b);y<=f&&(y<f?d=[{handle:b,validHandleResult:v}]:y===f&&d.push({handle:b,validHandleResult:v}),f=y)}}),!d.length)return{handle:null,validHandleResult:fNe()};if(d.length===1)return d[0];const h=d.some(({validHandleResult:b})=>b.isValid),m=d.some(({handle:b})=>b.type==="target");return d.find(({handle:b,validHandleResult:y})=>m?b.type==="target":h?y.isValid:!0)||d[0]}const sCt={source:null,target:null,sourceHandle:null,targetHandle:null},fNe=()=>({handleDomNode:null,isValid:!1,connection:sCt,endHandle:null});function hNe(e,t,n,r,i,s,a){const o=i==="target",l=a.querySelector(`.react-flow__handle[data-id="${e?.nodeId}-${e?.id}-${e?.type}"]`),u={...fNe(),handleDomNode:l};if(l){const d=RZ(void 0,l),f=l.getAttribute("data-nodeid"),h=l.getAttribute("data-handleid"),m=l.classList.contains("connectable"),b=l.classList.contains("connectableend"),y={source:o?f:n,sourceHandle:o?h:r,target:o?n:f,targetHandle:o?r:h};u.connection=y,m&&b&&(t===gy.Strict?o&&d==="source"||!o&&d==="target":f!==n||h!==r)&&(u.endHandle={nodeId:f,handleId:h,type:d},u.isValid=s(y))}return u}function aCt({nodes:e,nodeId:t,handleId:n,handleType:r}){return e.reduce((i,s)=>{if(s[Cs]){const{handleBounds:a}=s[Cs];let o=[],l=[];a&&(o=Tue(s,a,"source",`${t}-${n}-${r}`),l=Tue(s,a,"target",`${t}-${n}-${r}`)),i.push(...o,...l)}return i},[])}function RZ(e,t){return e||(t?.classList.contains("target")?"target":t?.classList.contains("source")?"source":null)}function X4(e){e?.classList.remove("valid","connecting","react-flow__handle-valid","react-flow__handle-connecting")}function oCt(e,t){let n=null;return t?n="valid":e&&!t&&(n="invalid"),n}function pNe({event:e,handleId:t,nodeId:n,onConnect:r,isTarget:i,getState:s,setState:a,isValidConnection:o,edgeUpdaterType:l,onReconnectEnd:u}){const d=JAe(e.target),{connectionMode:f,domNode:h,autoPanOnConnect:m,connectionRadius:b,onConnectStart:y,panBy:v,getNodes:_,cancelConnection:w}=s();let C=0,T;const{x:k,y:S}=Mm(e),A=d?.elementFromPoint(k,S),R=RZ(l,A),I=h?.getBoundingClientRect();if(!I||!R)return;let D,P=Mm(e,I),j=!1,B=null,L=!1,M=null;const $=aCt({nodes:_(),nodeId:n,handleId:t,handleType:R}),U=()=>{if(!m)return;const[G,q]=QAe(P,I);v({x:G,y:q}),C=requestAnimationFrame(U)};a({connectionPosition:P,connectionStatus:null,connectionNodeId:n,connectionHandleId:t,connectionHandleType:R,connectionStartHandle:{nodeId:n,handleId:t,type:R},connectionEndHandle:null}),y?.(e,{nodeId:n,handleId:t,handleType:R});function W(G){const{transform:q}=s();P=Mm(G,I);const{handle:X,validHandleResult:z}=iCt(G,d,FU(P,q,!1,[1,1]),b,$,Q=>hNe(Q,f,n,t,i?"target":"source",o,d));if(T=X,j||(U(),j=!0),M=z.handleDomNode,B=z.connection,L=z.isValid,a({connectionPosition:T&&L?lNe({x:T.x,y:T.y},q):P,connectionStatus:oCt(!!T,L),connectionEndHandle:z.endHandle}),!T&&!L&&!M)return X4(D);B.source!==B.target&&M&&(X4(D),D=M,M.classList.add("connecting","react-flow__handle-connecting"),M.classList.toggle("valid",L),M.classList.toggle("react-flow__handle-valid",L))}function Y(G){(T||M)&&B&&L&&r?.(B),s().onConnectEnd?.(G),l&&u?.(G),X4(D),w(),cancelAnimationFrame(C),j=!1,L=!1,B=null,M=null,d.removeEventListener("mousemove",W),d.removeEventListener("mouseup",Y),d.removeEventListener("touchmove",W),d.removeEventListener("touchend",Y)}d.addEventListener("mousemove",W),d.addEventListener("mouseup",Y),d.addEventListener("touchmove",W),d.addEventListener("touchend",Y)}const Aue=()=>!0,lCt=e=>({connectionStartHandle:e.connectionStartHandle,connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName}),uCt=(e,t,n)=>r=>{const{connectionStartHandle:i,connectionEndHandle:s,connectionClickStartHandle:a}=r;return{connecting:i?.nodeId===e&&i?.handleId===t&&i?.type===n||s?.nodeId===e&&s?.handleId===t&&s?.type===n,clickConnecting:a?.nodeId===e&&a?.handleId===t&&a?.type===n}},mNe=x.forwardRef(({type:e="source",position:t=wn.Top,isValidConnection:n,isConnectable:r=!0,isConnectableStart:i=!0,isConnectableEnd:s=!0,id:a,onConnect:o,children:l,className:u,onMouseDown:d,onTouchStart:f,...h},m)=>{const b=a||null,y=e==="target",v=ya(),_=JEt(),{connectOnClick:w,noPanClassName:C}=Pi(lCt,Ha),{connecting:T,clickConnecting:k}=Pi(uCt(_,b,e),Ha);_||v.getState().onError?.("010",Gh.error010());const S=I=>{const{defaultEdgeOptions:D,onConnect:P,hasDefaultEdges:j}=v.getState(),B={...D,...I};if(j){const{edges:L,setEdges:M}=v.getState();M(rCt(B,L))}P?.(B),o?.(B)},A=I=>{if(!_)return;const D=rNe(I);i&&(D&&I.button===0||!D)&&pNe({event:I,handleId:b,nodeId:_,onConnect:S,isTarget:y,getState:v.getState,setState:v.setState,isValidConnection:n||v.getState().isValidConnection||Aue}),D?d?.(I):f?.(I)},R=I=>{const{onClickConnectStart:D,onClickConnectEnd:P,connectionClickStartHandle:j,connectionMode:B,isValidConnection:L}=v.getState();if(!_||!j&&!i)return;if(!j){D?.(I,{nodeId:_,handleId:b,handleType:e}),v.setState({connectionClickStartHandle:{nodeId:_,type:e,handleId:b}});return}const M=JAe(I.target),$=n||L||Aue,{connection:U,isValid:W}=hNe({nodeId:_,id:b,type:e},B,j.nodeId,j.handleId||null,j.type,$,M);W&&S(U),P?.(I),v.setState({connectionClickStartHandle:null})};return Z.createElement("div",{"data-handleid":b,"data-nodeid":_,"data-handlepos":t,"data-id":`${_}-${b}-${e}`,className:bo(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",C,u,{source:!y,target:y,connectable:r,connectablestart:i,connectableend:s,connecting:k,connectionindicator:r&&(i&&!T||s&&T)}]),onMouseDown:A,onTouchStart:A,onClick:w?R:void 0,ref:m,...h},l)});mNe.displayName="Handle";var Sx=x.memo(mNe);const gNe=({data:e,isConnectable:t,targetPosition:n=wn.Top,sourcePosition:r=wn.Bottom})=>Z.createElement(Z.Fragment,null,Z.createElement(Sx,{type:"target",position:n,isConnectable:t}),e?.label,Z.createElement(Sx,{type:"source",position:r,isConnectable:t}));gNe.displayName="DefaultNode";var BU=x.memo(gNe);const bNe=({data:e,isConnectable:t,sourcePosition:n=wn.Bottom})=>Z.createElement(Z.Fragment,null,e?.label,Z.createElement(Sx,{type:"source",position:n,isConnectable:t}));bNe.displayName="InputNode";var yNe=x.memo(bNe);const vNe=({data:e,isConnectable:t,targetPosition:n=wn.Top})=>Z.createElement(Z.Fragment,null,Z.createElement(Sx,{type:"target",position:n,isConnectable:t}),e?.label);vNe.displayName="OutputNode";var xNe=x.memo(vNe);const IZ=()=>null;IZ.displayName="GroupNode";const cCt=e=>({selectedNodes:e.getNodes().filter(t=>t.selected),selectedEdges:e.edges.filter(t=>t.selected).map(t=>({...t}))}),zA=e=>e.id;function dCt(e,t){return Ha(e.selectedNodes.map(zA),t.selectedNodes.map(zA))&&Ha(e.selectedEdges.map(zA),t.selectedEdges.map(zA))}const _Ne=x.memo(({onSelectionChange:e})=>{const t=ya(),{selectedNodes:n,selectedEdges:r}=Pi(cCt,dCt);return x.useEffect(()=>{const i={nodes:n,edges:r};e?.(i),t.getState().onSelectionChange.forEach(s=>s(i))},[n,r,e]),null});_Ne.displayName="SelectionListener";const fCt=e=>!!e.onSelectionChange;function hCt({onSelectionChange:e}){const t=Pi(fCt);return e||t?Z.createElement(_Ne,{onSelectionChange:e}):null}const pCt=e=>({setNodes:e.setNodes,setEdges:e.setEdges,setDefaultNodesAndEdges:e.setDefaultNodesAndEdges,setMinZoom:e.setMinZoom,setMaxZoom:e.setMaxZoom,setTranslateExtent:e.setTranslateExtent,setNodeExtent:e.setNodeExtent,reset:e.reset});function Yv(e,t){x.useEffect(()=>{typeof e<"u"&&t(e)},[e])}function lr(e,t,n){x.useEffect(()=>{typeof t<"u"&&n({[e]:t})},[t])}const mCt=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,onConnect:i,onConnectStart:s,onConnectEnd:a,onClickConnectStart:o,onClickConnectEnd:l,nodesDraggable:u,nodesConnectable:d,nodesFocusable:f,edgesFocusable:h,edgesUpdatable:m,elevateNodesOnSelect:b,minZoom:y,maxZoom:v,nodeExtent:_,onNodesChange:w,onEdgesChange:C,elementsSelectable:T,connectionMode:k,snapGrid:S,snapToGrid:A,translateExtent:R,connectOnClick:I,defaultEdgeOptions:D,fitView:P,fitViewOptions:j,onNodesDelete:B,onEdgesDelete:L,onNodeDrag:M,onNodeDragStart:$,onNodeDragStop:U,onSelectionDrag:W,onSelectionDragStart:Y,onSelectionDragStop:G,noPanClassName:q,nodeOrigin:X,rfId:z,autoPanOnConnect:Q,autoPanOnNodeDrag:ee,onError:ne,connectionRadius:ae,isValidConnection:fe,nodeDragThreshold:re})=>{const{setNodes:de,setEdges:he,setDefaultNodesAndEdges:ce,setMinZoom:ye,setMaxZoom:be,setTranslateExtent:ue,setNodeExtent:Ae,reset:le}=Pi(pCt,Ha),ke=ya();return x.useEffect(()=>{const Fe=r?.map(ze=>({...ze,...D}));return ce(n,Fe),()=>{le()}},[]),lr("defaultEdgeOptions",D,ke.setState),lr("connectionMode",k,ke.setState),lr("onConnect",i,ke.setState),lr("onConnectStart",s,ke.setState),lr("onConnectEnd",a,ke.setState),lr("onClickConnectStart",o,ke.setState),lr("onClickConnectEnd",l,ke.setState),lr("nodesDraggable",u,ke.setState),lr("nodesConnectable",d,ke.setState),lr("nodesFocusable",f,ke.setState),lr("edgesFocusable",h,ke.setState),lr("edgesUpdatable",m,ke.setState),lr("elementsSelectable",T,ke.setState),lr("elevateNodesOnSelect",b,ke.setState),lr("snapToGrid",A,ke.setState),lr("snapGrid",S,ke.setState),lr("onNodesChange",w,ke.setState),lr("onEdgesChange",C,ke.setState),lr("connectOnClick",I,ke.setState),lr("fitViewOnInit",P,ke.setState),lr("fitViewOnInitOptions",j,ke.setState),lr("onNodesDelete",B,ke.setState),lr("onEdgesDelete",L,ke.setState),lr("onNodeDrag",M,ke.setState),lr("onNodeDragStart",$,ke.setState),lr("onNodeDragStop",U,ke.setState),lr("onSelectionDrag",W,ke.setState),lr("onSelectionDragStart",Y,ke.setState),lr("onSelectionDragStop",G,ke.setState),lr("noPanClassName",q,ke.setState),lr("nodeOrigin",X,ke.setState),lr("rfId",z,ke.setState),lr("autoPanOnConnect",Q,ke.setState),lr("autoPanOnNodeDrag",ee,ke.setState),lr("onError",ne,ke.setState),lr("connectionRadius",ae,ke.setState),lr("isValidConnection",fe,ke.setState),lr("nodeDragThreshold",re,ke.setState),Yv(e,de),Yv(t,he),Yv(y,ye),Yv(v,be),Yv(R,ue),Yv(_,Ae),null},Nue={display:"none"},gCt={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},SNe="react-flow__node-desc",wNe="react-flow__edge-desc",bCt="react-flow__aria-live",yCt=e=>e.ariaLiveMessage;function vCt({rfId:e}){const t=Pi(yCt);return Z.createElement("div",{id:`${bCt}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:gCt},t)}function xCt({rfId:e,disableKeyboardA11y:t}){return Z.createElement(Z.Fragment,null,Z.createElement("div",{id:`${SNe}-${e}`,style:Nue},"Press enter or space to select a node.",!t&&"You can then use the arrow keys to move the node around."," Press delete to remove it and escape to cancel."," "),Z.createElement("div",{id:`${wNe}-${e}`,style:Nue},"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel."),!t&&Z.createElement(vCt,{rfId:e}))}var YE=(e=null,t={actInsideInputWithModifier:!0})=>{const[n,r]=x.useState(!1),i=x.useRef(!1),s=x.useRef(new Set([])),[a,o]=x.useMemo(()=>{if(e!==null){const u=(Array.isArray(e)?e:[e]).filter(f=>typeof f=="string").map(f=>f.split("+")),d=u.reduce((f,h)=>f.concat(...h),[]);return[u,d]}return[[],[]]},[e]);return x.useEffect(()=>{const l=typeof document<"u"?document:null,u=t?.target||l;if(e!==null){const d=m=>{if(i.current=m.ctrlKey||m.metaKey||m.shiftKey,(!i.current||i.current&&!t.actInsideInputWithModifier)&&jU(m))return!1;const y=Rue(m.code,o);s.current.add(m[y]),Oue(a,s.current,!1)&&(m.preventDefault(),r(!0))},f=m=>{if((!i.current||i.current&&!t.actInsideInputWithModifier)&&jU(m))return!1;const y=Rue(m.code,o);Oue(a,s.current,!0)?(r(!1),s.current.clear()):s.current.delete(m[y]),m.key==="Meta"&&s.current.clear(),i.current=!1},h=()=>{s.current.clear(),r(!1)};return u?.addEventListener("keydown",d),u?.addEventListener("keyup",f),window.addEventListener("blur",h),()=>{u?.removeEventListener("keydown",d),u?.removeEventListener("keyup",f),window.removeEventListener("blur",h)}}},[e,r]),n};function Oue(e,t,n){return e.filter(r=>n||r.length===t.size).some(r=>r.every(i=>t.has(i)))}function Rue(e,t){return t.includes(e)?"code":"key"}function ENe(e,t,n,r){const i=e.parentNode||e.parentId;if(!i)return n;const s=t.get(i),a=Kb(s,r);return ENe(s,t,{x:(n.x??0)+a.x,y:(n.y??0)+a.y,z:(s[Cs]?.z??0)>(n.z??0)?s[Cs]?.z??0:n.z??0},r)}function CNe(e,t,n){e.forEach(r=>{const i=r.parentNode||r.parentId;if(i&&!e.has(i))throw new Error(`Parent node ${i} not found`);if(i||n?.[r.id]){const{x:s,y:a,z:o}=ENe(r,e,{...r.position,z:r[Cs]?.z??0},t);r.positionAbsolute={x:s,y:a},r[Cs].z=o,n?.[r.id]&&(r[Cs].isParent=!0)}})}function Z4(e,t,n,r){const i=new Map,s={},a=r?1e3:0;return e.forEach(o=>{const l=(uc(o.zIndex)?o.zIndex:0)+(o.selected?a:0),u=t.get(o.id),d={...o,positionAbsolute:{x:o.position.x,y:o.position.y}},f=o.parentNode||o.parentId;f&&(s[f]=!0);const h=u?.type&&u?.type!==o.type;Object.defineProperty(d,Cs,{enumerable:!1,value:{handleBounds:h?void 0:u?.[Cs]?.handleBounds,z:l}}),i.set(o.id,d)}),CNe(i,n,s),i}function kNe(e,t={}){const{getNodes:n,width:r,height:i,minZoom:s,maxZoom:a,d3Zoom:o,d3Selection:l,fitViewOnInitDone:u,fitViewOnInit:d,nodeOrigin:f}=e(),h=t.initial&&!u&&d;if(o&&l&&(h||!t.initial)){const b=n().filter(v=>{const _=t.includeHiddenNodes?v.width&&v.height:!v.hidden;return t.nodes?.length?_&&t.nodes.some(w=>w.id===v.id):_}),y=b.every(v=>v.width&&v.height);if(b.length>0&&y){const v=i5(b,f),{x:_,y:w,zoom:C}=dNe(v,r,i,t.minZoom??s,t.maxZoom??a,t.padding??.1),T=Rh.translate(_,w).scale(C);return typeof t.duration=="number"&&t.duration>0?o.transform(sb(l,t.duration),T):o.transform(l,T),!0}}return!1}function _Ct(e,t){return e.forEach(n=>{const r=t.get(n.id);r&&t.set(r.id,{...r,[Cs]:r[Cs],selected:n.selected})}),new Map(t)}function SCt(e,t){return t.map(n=>{const r=e.find(i=>i.id===n.id);return r&&(n.selected=r.selected),n})}function HA({changedNodes:e,changedEdges:t,get:n,set:r}){const{nodeInternals:i,edges:s,onNodesChange:a,onEdgesChange:o,hasDefaultNodes:l,hasDefaultEdges:u}=n();e?.length&&(l&&r({nodeInternals:_Ct(e,i)}),a?.(e)),t?.length&&(u&&r({edges:SCt(t,s)}),o?.(t))}const Xv=()=>{},wCt={zoomIn:Xv,zoomOut:Xv,zoomTo:Xv,getZoom:()=>1,setViewport:Xv,getViewport:()=>({x:0,y:0,zoom:1}),fitView:()=>!1,setCenter:Xv,fitBounds:Xv,project:e=>e,screenToFlowPosition:e=>e,flowToScreenPosition:e=>e,viewportInitialized:!1},ECt=e=>({d3Zoom:e.d3Zoom,d3Selection:e.d3Selection}),CCt=()=>{const e=ya(),{d3Zoom:t,d3Selection:n}=Pi(ECt,Ha);return x.useMemo(()=>n&&t?{zoomIn:i=>t.scaleBy(sb(n,i?.duration),1.2),zoomOut:i=>t.scaleBy(sb(n,i?.duration),1/1.2),zoomTo:(i,s)=>t.scaleTo(sb(n,s?.duration),i),getZoom:()=>e.getState().transform[2],setViewport:(i,s)=>{const[a,o,l]=e.getState().transform,u=Rh.translate(i.x??a,i.y??o).scale(i.zoom??l);t.transform(sb(n,s?.duration),u)},getViewport:()=>{const[i,s,a]=e.getState().transform;return{x:i,y:s,zoom:a}},fitView:i=>kNe(e.getState,i),setCenter:(i,s,a)=>{const{width:o,height:l,maxZoom:u}=e.getState(),d=typeof a?.zoom<"u"?a.zoom:u,f=o/2-i*d,h=l/2-s*d,m=Rh.translate(f,h).scale(d);t.transform(sb(n,a?.duration),m)},fitBounds:(i,s)=>{const{width:a,height:o,minZoom:l,maxZoom:u}=e.getState(),{x:d,y:f,zoom:h}=dNe(i,a,o,l,u,s?.padding??.1),m=Rh.translate(d,f).scale(h);t.transform(sb(n,s?.duration),m)},project:i=>{const{transform:s,snapToGrid:a,snapGrid:o}=e.getState();return console.warn("[DEPRECATED] `project` is deprecated. Instead use `screenToFlowPosition`. There is no need to subtract the react flow bounds anymore! https://reactflow.dev/api-reference/types/react-flow-instance#screen-to-flow-position"),FU(i,s,a,o)},screenToFlowPosition:i=>{const{transform:s,snapToGrid:a,snapGrid:o,domNode:l}=e.getState();if(!l)return i;const{x:u,y:d}=l.getBoundingClientRect(),f={x:i.x-u,y:i.y-d};return FU(f,s,a,o)},flowToScreenPosition:i=>{const{transform:s,domNode:a}=e.getState();if(!a)return i;const{x:o,y:l}=a.getBoundingClientRect(),u=lNe(i,s);return{x:u.x+o,y:u.y+l}},viewportInitialized:!0}:wCt,[t,n])};function DZ(){const e=CCt(),t=ya(),n=x.useCallback(()=>t.getState().getNodes().map(y=>({...y})),[]),r=x.useCallback(y=>t.getState().nodeInternals.get(y),[]),i=x.useCallback(()=>{const{edges:y=[]}=t.getState();return y.map(v=>({...v}))},[]),s=x.useCallback(y=>{const{edges:v=[]}=t.getState();return v.find(_=>_.id===y)},[]),a=x.useCallback(y=>{const{getNodes:v,setNodes:_,hasDefaultNodes:w,onNodesChange:C}=t.getState(),T=v(),k=typeof y=="function"?y(T):y;if(w)_(k);else if(C){const S=k.length===0?T.map(A=>({type:"remove",id:A.id})):k.map(A=>({item:A,type:"reset"}));C(S)}},[]),o=x.useCallback(y=>{const{edges:v=[],setEdges:_,hasDefaultEdges:w,onEdgesChange:C}=t.getState(),T=typeof y=="function"?y(v):y;if(w)_(T);else if(C){const k=T.length===0?v.map(S=>({type:"remove",id:S.id})):T.map(S=>({item:S,type:"reset"}));C(k)}},[]),l=x.useCallback(y=>{const v=Array.isArray(y)?y:[y],{getNodes:_,setNodes:w,hasDefaultNodes:C,onNodesChange:T}=t.getState();if(C){const S=[..._(),...v];w(S)}else if(T){const k=v.map(S=>({item:S,type:"add"}));T(k)}},[]),u=x.useCallback(y=>{const v=Array.isArray(y)?y:[y],{edges:_=[],setEdges:w,hasDefaultEdges:C,onEdgesChange:T}=t.getState();if(C)w([..._,...v]);else if(T){const k=v.map(S=>({item:S,type:"add"}));T(k)}},[]),d=x.useCallback(()=>{const{getNodes:y,edges:v=[],transform:_}=t.getState(),[w,C,T]=_;return{nodes:y().map(k=>({...k})),edges:v.map(k=>({...k})),viewport:{x:w,y:C,zoom:T}}},[]),f=x.useCallback(({nodes:y,edges:v})=>{const{nodeInternals:_,getNodes:w,edges:C,hasDefaultNodes:T,hasDefaultEdges:k,onNodesDelete:S,onEdgesDelete:A,onNodesChange:R,onEdgesChange:I}=t.getState(),D=(y||[]).map(M=>M.id),P=(v||[]).map(M=>M.id),j=w().reduce((M,$)=>{const U=$.parentNode||$.parentId,W=!D.includes($.id)&&U&&M.find(G=>G.id===U);return(typeof $.deletable!="boolean"||$.deletable)&&(D.includes($.id)||W)&&M.push($),M},[]),B=C.filter(M=>typeof M.deletable=="boolean"?M.deletable:!0),L=B.filter(M=>P.includes(M.id));if(j||L){const M=cNe(j,B),$=[...L,...M],U=$.reduce((W,Y)=>(W.includes(Y.id)||W.push(Y.id),W),[]);if((k||T)&&(k&&t.setState({edges:C.filter(W=>!U.includes(W.id))}),T&&(j.forEach(W=>{_.delete(W.id)}),t.setState({nodeInternals:new Map(_)}))),U.length>0&&(A?.($),I&&I(U.map(W=>({id:W,type:"remove"})))),j.length>0&&(S?.(j),R)){const W=j.map(Y=>({id:Y.id,type:"remove"}));R(W)}}},[]),h=x.useCallback(y=>{const v=WEt(y),_=v?null:t.getState().nodeInternals.get(y.id);return!v&&!_?[null,null,v]:[v?y:Sue(_),_,v]},[]),m=x.useCallback((y,v=!0,_)=>{const[w,C,T]=h(y);return w?(_||t.getState().getNodes()).filter(k=>{if(!T&&(k.id===C.id||!k.positionAbsolute))return!1;const S=Sue(k),A=PU(S,w);return v&&A>0||A>=w.width*w.height}):[]},[]),b=x.useCallback((y,v,_=!0)=>{const[w]=h(y);if(!w)return!1;const C=PU(w,v);return _&&C>0||C>=w.width*w.height},[]);return x.useMemo(()=>({...e,getNodes:n,getNode:r,getEdges:i,getEdge:s,setNodes:a,setEdges:o,addNodes:l,addEdges:u,toObject:d,deleteElements:f,getIntersectingNodes:m,isNodeIntersecting:b}),[e,n,r,i,s,a,o,l,u,d,f,m,b])}const kCt={actInsideInputWithModifier:!1};var TCt=({deleteKeyCode:e,multiSelectionKeyCode:t})=>{const n=ya(),{deleteElements:r}=DZ(),i=YE(e,kCt),s=YE(t);x.useEffect(()=>{if(i){const{edges:a,getNodes:o}=n.getState(),l=o().filter(d=>d.selected),u=a.filter(d=>d.selected);r({nodes:l,edges:u}),n.setState({nodesSelectionActive:!1})}},[i]),x.useEffect(()=>{n.setState({multiSelectionActive:s})},[s])};function ACt(e){const t=ya();x.useEffect(()=>{let n;const r=()=>{if(!e.current)return;const i=CZ(e.current);(i.height===0||i.width===0)&&t.getState().onError?.("004",Gh.error004()),t.setState({width:i.width||500,height:i.height||500})};return r(),window.addEventListener("resize",r),e.current&&(n=new ResizeObserver(()=>r()),n.observe(e.current)),()=>{window.removeEventListener("resize",r),n&&e.current&&n.unobserve(e.current)}},[])}const PZ={position:"absolute",width:"100%",height:"100%",top:0,left:0},NCt=(e,t)=>e.x!==t.x||e.y!==t.y||e.zoom!==t.k,VA=e=>({x:e.x,y:e.y,zoom:e.k}),Zv=(e,t)=>e.target.closest(`.${t}`),Iue=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),Due=e=>{const t=e.ctrlKey&&yR()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t},OCt=e=>({d3Zoom:e.d3Zoom,d3Selection:e.d3Selection,d3ZoomHandler:e.d3ZoomHandler,userSelectionActive:e.userSelectionActive}),RCt=({onMove:e,onMoveStart:t,onMoveEnd:n,onPaneContextMenu:r,zoomOnScroll:i=!0,zoomOnPinch:s=!0,panOnScroll:a=!1,panOnScrollSpeed:o=.5,panOnScrollMode:l=kb.Free,zoomOnDoubleClick:u=!0,elementsSelectable:d,panOnDrag:f=!0,defaultViewport:h,translateExtent:m,minZoom:b,maxZoom:y,zoomActivationKeyCode:v,preventScrolling:_=!0,children:w,noWheelClassName:C,noPanClassName:T})=>{const k=x.useRef(),S=ya(),A=x.useRef(!1),R=x.useRef(!1),I=x.useRef(null),D=x.useRef({x:0,y:0,zoom:0}),{d3Zoom:P,d3Selection:j,d3ZoomHandler:B,userSelectionActive:L}=Pi(OCt,Ha),M=YE(v),$=x.useRef(0),U=x.useRef(!1),W=x.useRef();return ACt(I),x.useEffect(()=>{if(I.current){const Y=I.current.getBoundingClientRect(),G=XAe().scaleExtent([b,y]).translateExtent(m),q=rc(I.current).call(G),X=Rh.translate(h.x,h.y).scale(_x(h.zoom,b,y)),z=[[0,0],[Y.width,Y.height]],Q=G.constrain()(X,z,m);G.transform(q,Q),G.wheelDelta(Due),S.setState({d3Zoom:G,d3Selection:q,d3ZoomHandler:q.on("wheel.zoom"),transform:[Q.x,Q.y,Q.k],domNode:I.current.closest(".react-flow")})}},[]),x.useEffect(()=>{j&&P&&(a&&!M&&!L?j.on("wheel.zoom",Y=>{if(Zv(Y,C))return!1;Y.preventDefault(),Y.stopImmediatePropagation();const G=j.property("__zoom").k||1;if(Y.ctrlKey&&s){const fe=Kc(Y),re=Due(Y),de=G*Math.pow(2,re);P.scaleTo(j,de,fe,Y);return}const q=Y.deltaMode===1?20:1;let X=l===kb.Vertical?0:Y.deltaX*q,z=l===kb.Horizontal?0:Y.deltaY*q;!yR()&&Y.shiftKey&&l!==kb.Vertical&&(X=Y.deltaY*q,z=0),P.translateBy(j,-(X/G)*o,-(z/G)*o,{internal:!0});const Q=VA(j.property("__zoom")),{onViewportChangeStart:ee,onViewportChange:ne,onViewportChangeEnd:ae}=S.getState();clearTimeout(W.current),U.current||(U.current=!0,t?.(Y,Q),ee?.(Q)),U.current&&(e?.(Y,Q),ne?.(Q),W.current=setTimeout(()=>{n?.(Y,Q),ae?.(Q),U.current=!1},150))},{passive:!1}):typeof B<"u"&&j.on("wheel.zoom",function(Y,G){if(!_&&Y.type==="wheel"&&!Y.ctrlKey||Zv(Y,C))return null;Y.preventDefault(),B.call(this,Y,G)},{passive:!1}))},[L,a,l,j,P,B,M,s,_,C,t,e,n]),x.useEffect(()=>{P&&P.on("start",Y=>{if(!Y.sourceEvent||Y.sourceEvent.internal)return null;$.current=Y.sourceEvent?.button;const{onViewportChangeStart:G}=S.getState(),q=VA(Y.transform);A.current=!0,D.current=q,Y.sourceEvent?.type==="mousedown"&&S.setState({paneDragging:!0}),G?.(q),t?.(Y.sourceEvent,q)})},[P,t]),x.useEffect(()=>{P&&(L&&!A.current?P.on("zoom",null):L||P.on("zoom",Y=>{const{onViewportChange:G}=S.getState();if(S.setState({transform:[Y.transform.x,Y.transform.y,Y.transform.k]}),R.current=!!(r&&Iue(f,$.current??0)),(e||G)&&!Y.sourceEvent?.internal){const q=VA(Y.transform);G?.(q),e?.(Y.sourceEvent,q)}}))},[L,P,e,f,r]),x.useEffect(()=>{P&&P.on("end",Y=>{if(!Y.sourceEvent||Y.sourceEvent.internal)return null;const{onViewportChangeEnd:G}=S.getState();if(A.current=!1,S.setState({paneDragging:!1}),r&&Iue(f,$.current??0)&&!R.current&&r(Y.sourceEvent),R.current=!1,(n||G)&&NCt(D.current,Y.transform)){const q=VA(Y.transform);D.current=q,clearTimeout(k.current),k.current=setTimeout(()=>{G?.(q),n?.(Y.sourceEvent,q)},a?150:0)}})},[P,a,f,n,r]),x.useEffect(()=>{P&&P.filter(Y=>{const G=M||i,q=s&&Y.ctrlKey;if((f===!0||Array.isArray(f)&&f.includes(1))&&Y.button===1&&Y.type==="mousedown"&&(Zv(Y,"react-flow__node")||Zv(Y,"react-flow__edge")))return!0;if(!f&&!G&&!a&&!u&&!s||L||!u&&Y.type==="dblclick"||Zv(Y,C)&&Y.type==="wheel"||Zv(Y,T)&&(Y.type!=="wheel"||a&&Y.type==="wheel"&&!M)||!s&&Y.ctrlKey&&Y.type==="wheel"||!G&&!a&&!q&&Y.type==="wheel"||!f&&(Y.type==="mousedown"||Y.type==="touchstart")||Array.isArray(f)&&!f.includes(Y.button)&&Y.type==="mousedown")return!1;const X=Array.isArray(f)&&f.includes(Y.button)||!Y.button||Y.button<=1;return(!Y.ctrlKey||Y.type==="wheel")&&X})},[L,P,i,s,a,u,f,d,M]),Z.createElement("div",{className:"react-flow__renderer",ref:I,style:PZ},w)},ICt=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function DCt(){const{userSelectionActive:e,userSelectionRect:t}=Pi(ICt,Ha);return e&&t?Z.createElement("div",{className:"react-flow__selection react-flow__container",style:{width:t.width,height:t.height,transform:`translate(${t.x}px, ${t.y}px)`}}):null}function Pue(e,t){const n=t.parentNode||t.parentId,r=e.find(i=>i.id===n);if(r){const i=t.position.x+t.width-r.width,s=t.position.y+t.height-r.height;if(i>0||s>0||t.position.x<0||t.position.y<0){if(r.style={...r.style},r.style.width=r.style.width??r.width,r.style.height=r.style.height??r.height,i>0&&(r.style.width+=i),s>0&&(r.style.height+=s),t.position.x<0){const a=Math.abs(t.position.x);r.position.x=r.position.x-a,r.style.width+=a,t.position.x=0}if(t.position.y<0){const a=Math.abs(t.position.y);r.position.y=r.position.y-a,r.style.height+=a,t.position.y=0}r.width=r.style.width,r.height=r.style.height}}}function TNe(e,t){if(e.some(r=>r.type==="reset"))return e.filter(r=>r.type==="reset").map(r=>r.item);const n=e.filter(r=>r.type==="add").map(r=>r.item);return t.reduce((r,i)=>{const s=e.filter(o=>o.id===i.id);if(s.length===0)return r.push(i),r;const a={...i};for(const o of s)if(o)switch(o.type){case"select":{a.selected=o.selected;break}case"position":{typeof o.position<"u"&&(a.position=o.position),typeof o.positionAbsolute<"u"&&(a.positionAbsolute=o.positionAbsolute),typeof o.dragging<"u"&&(a.dragging=o.dragging),a.expandParent&&Pue(r,a);break}case"dimensions":{typeof o.dimensions<"u"&&(a.width=o.dimensions.width,a.height=o.dimensions.height),typeof o.updateStyle<"u"&&(a.style={...a.style||{},...o.dimensions}),typeof o.resizing=="boolean"&&(a.resizing=o.resizing),a.expandParent&&Pue(r,a);break}case"remove":return r}return r.push(a),r},n)}function ANe(e,t){return TNe(e,t)}function PCt(e,t){return TNe(e,t)}const lm=(e,t)=>({id:e,type:"select",selected:t});function x0(e,t){return e.reduce((n,r)=>{const i=t.includes(r.id);return!r.selected&&i?(r.selected=!0,n.push(lm(r.id,!0))):r.selected&&!i&&(r.selected=!1,n.push(lm(r.id,!1))),n},[])}const Q4=(e,t)=>n=>{n.target===t.current&&e?.(n)},jCt=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,dragging:e.paneDragging}),NNe=x.memo(({isSelecting:e,selectionMode:t=GE.Full,panOnDrag:n,onSelectionStart:r,onSelectionEnd:i,onPaneClick:s,onPaneContextMenu:a,onPaneScroll:o,onPaneMouseEnter:l,onPaneMouseMove:u,onPaneMouseLeave:d,children:f})=>{const h=x.useRef(null),m=ya(),b=x.useRef(0),y=x.useRef(0),v=x.useRef(),{userSelectionActive:_,elementsSelectable:w,dragging:C}=Pi(jCt,Ha),T=()=>{m.setState({userSelectionActive:!1,userSelectionRect:null}),b.current=0,y.current=0},k=B=>{s?.(B),m.getState().resetSelectedElements(),m.setState({nodesSelectionActive:!1})},S=B=>{if(Array.isArray(n)&&n?.includes(2)){B.preventDefault();return}a?.(B)},A=o?B=>o(B):void 0,R=B=>{const{resetSelectedElements:L,domNode:M}=m.getState();if(v.current=M?.getBoundingClientRect(),!w||!e||B.button!==0||B.target!==h.current||!v.current)return;const{x:$,y:U}=Mm(B,v.current);L(),m.setState({userSelectionRect:{width:0,height:0,startX:$,startY:U,x:$,y:U}}),r?.(B)},I=B=>{const{userSelectionRect:L,nodeInternals:M,edges:$,transform:U,onNodesChange:W,onEdgesChange:Y,nodeOrigin:G,getNodes:q}=m.getState();if(!e||!v.current||!L)return;m.setState({userSelectionActive:!0,nodesSelectionActive:!1});const X=Mm(B,v.current),z=L.startX??0,Q=L.startY??0,ee={...L,x:X.x<z?X.x:z,y:X.y<Q?X.y:Q,width:Math.abs(X.x-z),height:Math.abs(X.y-Q)},ne=q(),ae=uNe(M,ee,U,t===GE.Partial,!0,G),fe=cNe(ae,$).map(de=>de.id),re=ae.map(de=>de.id);if(b.current!==re.length){b.current=re.length;const de=x0(ne,re);de.length&&W?.(de)}if(y.current!==fe.length){y.current=fe.length;const de=x0($,fe);de.length&&Y?.(de)}m.setState({userSelectionRect:ee})},D=B=>{if(B.button!==0)return;const{userSelectionRect:L}=m.getState();!_&&L&&B.target===h.current&&k?.(B),m.setState({nodesSelectionActive:b.current>0}),T(),i?.(B)},P=B=>{_&&(m.setState({nodesSelectionActive:b.current>0}),i?.(B)),T()},j=w&&(e||_);return Z.createElement("div",{className:bo(["react-flow__pane",{dragging:C,selection:e}]),onClick:j?void 0:Q4(k,h),onContextMenu:Q4(S,h),onWheel:Q4(A,h),onMouseEnter:j?void 0:l,onMouseDown:j?R:void 0,onMouseMove:j?I:u,onMouseUp:j?D:void 0,onMouseLeave:j?P:d,ref:h,style:PZ},f,Z.createElement(DCt,null))});NNe.displayName="Pane";function ONe(e,t){const n=e.parentNode||e.parentId;if(!n)return!1;const r=t.get(n);return r?r.selected?!0:ONe(r,t):!1}function jue(e,t,n){let r=e;do{if(r?.matches(t))return!0;if(r===n.current)return!1;r=r.parentElement}while(r);return!1}function LCt(e,t,n,r){return Array.from(e.values()).filter(i=>(i.selected||i.id===r)&&(!i.parentNode||i.parentId||!ONe(i,e))&&(i.draggable||t&&typeof i.draggable>"u")).map(i=>({id:i.id,position:i.position||{x:0,y:0},positionAbsolute:i.positionAbsolute||{x:0,y:0},distance:{x:n.x-(i.positionAbsolute?.x??0),y:n.y-(i.positionAbsolute?.y??0)},delta:{x:0,y:0},extent:i.extent,parentNode:i.parentNode||i.parentId,parentId:i.parentNode||i.parentId,width:i.width,height:i.height,expandParent:i.expandParent}))}function MCt(e,t){return!t||t==="parent"?t:[t[0],[t[1][0]-(e.width||0),t[1][1]-(e.height||0)]]}function RNe(e,t,n,r,i=[0,0],s){const a=MCt(e,e.extent||r);let o=a;const l=e.parentNode||e.parentId;if(e.extent==="parent"&&!e.expandParent)if(l&&e.width&&e.height){const f=n.get(l),{x:h,y:m}=Kb(f,i).positionAbsolute;o=f&&uc(h)&&uc(m)&&uc(f.width)&&uc(f.height)?[[h+e.width*i[0],m+e.height*i[1]],[h+f.width-e.width+e.width*i[0],m+f.height-e.height+e.height*i[1]]]:o}else s?.("005",Gh.error005()),o=a;else if(e.extent&&l&&e.extent!=="parent"){const f=n.get(l),{x:h,y:m}=Kb(f,i).positionAbsolute;o=[[e.extent[0][0]+h,e.extent[0][1]+m],[e.extent[1][0]+h,e.extent[1][1]+m]]}let u={x:0,y:0};if(l){const f=n.get(l);u=Kb(f,i).positionAbsolute}const d=o&&o!=="parent"?kZ(t,o):t;return{position:{x:d.x-u.x,y:d.y-u.y},positionAbsolute:d}}function J4({nodeId:e,dragItems:t,nodeInternals:n}){const r=t.map(i=>({...n.get(i.id),position:i.position,positionAbsolute:i.positionAbsolute}));return[e?r.find(i=>i.id===e):r[0],r]}const Lue=(e,t,n,r)=>{const i=t.querySelectorAll(e);if(!i||!i.length)return null;const s=Array.from(i),a=t.getBoundingClientRect(),o={x:a.width*r[0],y:a.height*r[1]};return s.map(l=>{const u=l.getBoundingClientRect();return{id:l.getAttribute("data-handleid"),position:l.getAttribute("data-handlepos"),x:(u.left-a.left-o.x)/n,y:(u.top-a.top-o.y)/n,...CZ(l)}})};function jS(e,t,n){return n===void 0?n:r=>{const i=t().nodeInternals.get(e);i&&n(r,{...i})}}function $U({id:e,store:t,unselect:n=!1,nodeRef:r}){const{addSelectedNodes:i,unselectNodesAndEdges:s,multiSelectionActive:a,nodeInternals:o,onError:l}=t.getState(),u=o.get(e);if(!u){l?.("012",Gh.error012(e));return}t.setState({nodesSelectionActive:!1}),u.selected?(n||u.selected&&a)&&(s({nodes:[u],edges:[]}),requestAnimationFrame(()=>r?.current?.blur())):i([e])}function FCt(){const e=ya();return x.useCallback(({sourceEvent:n})=>{const{transform:r,snapGrid:i,snapToGrid:s}=e.getState(),a=n.touches?n.touches[0].clientX:n.clientX,o=n.touches?n.touches[0].clientY:n.clientY,l={x:(a-r[0])/r[2],y:(o-r[1])/r[2]};return{xSnapped:s?i[0]*Math.round(l.x/i[0]):l.x,ySnapped:s?i[1]*Math.round(l.y/i[1]):l.y,...l}},[])}function e6(e){return(t,n,r)=>e?.(t,r)}function INe({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:r,nodeId:i,isSelectable:s,selectNodesOnDrag:a}){const o=ya(),[l,u]=x.useState(!1),d=x.useRef([]),f=x.useRef({x:null,y:null}),h=x.useRef(0),m=x.useRef(null),b=x.useRef({x:0,y:0}),y=x.useRef(null),v=x.useRef(!1),_=x.useRef(!1),w=x.useRef(!1),C=FCt();return x.useEffect(()=>{if(e?.current){const T=rc(e.current),k=({x:R,y:I})=>{const{nodeInternals:D,onNodeDrag:P,onSelectionDrag:j,updateNodePositions:B,nodeExtent:L,snapGrid:M,snapToGrid:$,nodeOrigin:U,onError:W}=o.getState();f.current={x:R,y:I};let Y=!1,G={x:0,y:0,x2:0,y2:0};if(d.current.length>1&&L){const X=i5(d.current,U);G=qE(X)}if(d.current=d.current.map(X=>{const z={x:R-X.distance.x,y:I-X.distance.y};$&&(z.x=M[0]*Math.round(z.x/M[0]),z.y=M[1]*Math.round(z.y/M[1]));const Q=[[L[0][0],L[0][1]],[L[1][0],L[1][1]]];d.current.length>1&&L&&!X.extent&&(Q[0][0]=X.positionAbsolute.x-G.x+L[0][0],Q[1][0]=X.positionAbsolute.x+(X.width??0)-G.x2+L[1][0],Q[0][1]=X.positionAbsolute.y-G.y+L[0][1],Q[1][1]=X.positionAbsolute.y+(X.height??0)-G.y2+L[1][1]);const ee=RNe(X,z,D,Q,U,W);return Y=Y||X.position.x!==ee.position.x||X.position.y!==ee.position.y,X.position=ee.position,X.positionAbsolute=ee.positionAbsolute,X}),!Y)return;B(d.current,!0,!0),u(!0);const q=i?P:e6(j);if(q&&y.current){const[X,z]=J4({nodeId:i,dragItems:d.current,nodeInternals:D});q(y.current,X,z)}},S=()=>{if(!m.current)return;const[R,I]=QAe(b.current,m.current);if(R!==0||I!==0){const{transform:D,panBy:P}=o.getState();f.current.x=(f.current.x??0)-R/D[2],f.current.y=(f.current.y??0)-I/D[2],P({x:R,y:I})&&k(f.current)}h.current=requestAnimationFrame(S)},A=R=>{const{nodeInternals:I,multiSelectionActive:D,nodesDraggable:P,unselectNodesAndEdges:j,onNodeDragStart:B,onSelectionDragStart:L}=o.getState();_.current=!0;const M=i?B:e6(L);(!a||!s)&&!D&&i&&(I.get(i)?.selected||j()),i&&s&&a&&$U({id:i,store:o,nodeRef:e});const $=C(R);if(f.current=$,d.current=LCt(I,P,$,i),M&&d.current){const[U,W]=J4({nodeId:i,dragItems:d.current,nodeInternals:I});M(R.sourceEvent,U,W)}};if(t)T.on(".drag",null);else{const R=VSt().on("start",I=>{const{domNode:D,nodeDragThreshold:P}=o.getState();P===0&&A(I),w.current=!1;const j=C(I);f.current=j,m.current=D?.getBoundingClientRect()||null,b.current=Mm(I.sourceEvent,m.current)}).on("drag",I=>{const D=C(I),{autoPanOnNodeDrag:P,nodeDragThreshold:j}=o.getState();if(I.sourceEvent.type==="touchmove"&&I.sourceEvent.touches.length>1&&(w.current=!0),!w.current){if(!v.current&&_.current&&P&&(v.current=!0,S()),!_.current){const B=D.xSnapped-(f?.current?.x??0),L=D.ySnapped-(f?.current?.y??0);Math.sqrt(B*B+L*L)>j&&A(I)}(f.current.x!==D.xSnapped||f.current.y!==D.ySnapped)&&d.current&&_.current&&(y.current=I.sourceEvent,b.current=Mm(I.sourceEvent,m.current),k(D))}}).on("end",I=>{if(!(!_.current||w.current)&&(u(!1),v.current=!1,_.current=!1,cancelAnimationFrame(h.current),d.current)){const{updateNodePositions:D,nodeInternals:P,onNodeDragStop:j,onSelectionDragStop:B}=o.getState(),L=i?j:e6(B);if(D(d.current,!1,!1),L){const[M,$]=J4({nodeId:i,dragItems:d.current,nodeInternals:P});L(I.sourceEvent,M,$)}}}).filter(I=>{const D=I.target;return!I.button&&(!n||!jue(D,`.${n}`,e))&&(!r||jue(D,r,e))});return T.call(R),()=>{T.on(".drag",null)}}}},[e,t,n,r,s,o,i,a,C]),l}function DNe(){const e=ya();return x.useCallback(n=>{const{nodeInternals:r,nodeExtent:i,updateNodePositions:s,getNodes:a,snapToGrid:o,snapGrid:l,onError:u,nodesDraggable:d}=e.getState(),f=a().filter(w=>w.selected&&(w.draggable||d&&typeof w.draggable>"u")),h=o?l[0]:5,m=o?l[1]:5,b=n.isShiftPressed?4:1,y=n.x*h*b,v=n.y*m*b,_=f.map(w=>{if(w.positionAbsolute){const C={x:w.positionAbsolute.x+y,y:w.positionAbsolute.y+v};o&&(C.x=l[0]*Math.round(C.x/l[0]),C.y=l[1]*Math.round(C.y/l[1]));const{positionAbsolute:T,position:k}=RNe(w,C,r,i,void 0,u);w.position=k,w.positionAbsolute=T}return w});s(_,!0,!1)},[])}const $0={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}};var LS=e=>{const t=({id:n,type:r,data:i,xPos:s,yPos:a,xPosOrigin:o,yPosOrigin:l,selected:u,onClick:d,onMouseEnter:f,onMouseMove:h,onMouseLeave:m,onContextMenu:b,onDoubleClick:y,style:v,className:_,isDraggable:w,isSelectable:C,isConnectable:T,isFocusable:k,selectNodesOnDrag:S,sourcePosition:A,targetPosition:R,hidden:I,resizeObserver:D,dragHandle:P,zIndex:j,isParent:B,noDragClassName:L,noPanClassName:M,initialized:$,disableKeyboardA11y:U,ariaLabel:W,rfId:Y,hasHandleBounds:G})=>{const q=ya(),X=x.useRef(null),z=x.useRef(null),Q=x.useRef(A),ee=x.useRef(R),ne=x.useRef(r),ae=C||w||d||f||h||m,fe=DNe(),re=jS(n,q.getState,f),de=jS(n,q.getState,h),he=jS(n,q.getState,m),ce=jS(n,q.getState,b),ye=jS(n,q.getState,y),be=le=>{const{nodeDragThreshold:ke}=q.getState();if(C&&(!S||!w||ke>0)&&$U({id:n,store:q,nodeRef:X}),d){const Fe=q.getState().nodeInternals.get(n);Fe&&d(le,{...Fe})}},ue=le=>{if(!jU(le)&&!U)if(nNe.includes(le.key)&&C){const ke=le.key==="Escape";$U({id:n,store:q,unselect:ke,nodeRef:X})}else w&&u&&Object.prototype.hasOwnProperty.call($0,le.key)&&(q.setState({ariaLiveMessage:`Moved selected node ${le.key.replace("Arrow","").toLowerCase()}. New position, x: ${~~s}, y: ${~~a}`}),fe({x:$0[le.key].x,y:$0[le.key].y,isShiftPressed:le.shiftKey}))};x.useEffect(()=>()=>{z.current&&(D?.unobserve(z.current),z.current=null)},[]),x.useEffect(()=>{if(X.current&&!I){const le=X.current;(!$||!G||z.current!==le)&&(z.current&&D?.unobserve(z.current),D?.observe(le),z.current=le)}},[I,$,G]),x.useEffect(()=>{const le=ne.current!==r,ke=Q.current!==A,Fe=ee.current!==R;X.current&&(le||ke||Fe)&&(le&&(ne.current=r),ke&&(Q.current=A),Fe&&(ee.current=R),q.getState().updateNodeDimensions([{id:n,nodeElement:X.current,forceUpdate:!0}]))},[n,r,A,R]);const Ae=INe({nodeRef:X,disabled:I||!w,noDragClassName:L,handleSelector:P,nodeId:n,isSelectable:C,selectNodesOnDrag:S});return I?null:Z.createElement("div",{className:bo(["react-flow__node",`react-flow__node-${r}`,{[M]:w},_,{selected:u,selectable:C,parent:B,dragging:Ae}]),ref:X,style:{zIndex:j,transform:`translate(${o}px,${l}px)`,pointerEvents:ae?"all":"none",visibility:$?"visible":"hidden",...v},"data-id":n,"data-testid":`rf__node-${n}`,onMouseEnter:re,onMouseMove:de,onMouseLeave:he,onContextMenu:ce,onClick:be,onDoubleClick:ye,onKeyDown:k?ue:void 0,tabIndex:k?0:void 0,role:k?"button":void 0,"aria-describedby":U?void 0:`${SNe}-${Y}`,"aria-label":W},Z.createElement(QEt,{value:n},Z.createElement(e,{id:n,data:i,type:r,xPos:s,yPos:a,selected:u,isConnectable:T,sourcePosition:A,targetPosition:R,dragging:Ae,dragHandle:P,zIndex:j})))};return t.displayName="NodeWrapper",x.memo(t)};const BCt=e=>{const t=e.getNodes().filter(n=>n.selected);return{...i5(t,e.nodeOrigin),transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`,userSelectionActive:e.userSelectionActive}};function $Ct({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){const r=ya(),{width:i,height:s,x:a,y:o,transformString:l,userSelectionActive:u}=Pi(BCt,Ha),d=DNe(),f=x.useRef(null);if(x.useEffect(()=>{n||f.current?.focus({preventScroll:!0})},[n]),INe({nodeRef:f}),u||!i||!s)return null;const h=e?b=>{const y=r.getState().getNodes().filter(v=>v.selected);e(b,y)}:void 0,m=b=>{Object.prototype.hasOwnProperty.call($0,b.key)&&d({x:$0[b.key].x,y:$0[b.key].y,isShiftPressed:b.shiftKey})};return Z.createElement("div",{className:bo(["react-flow__nodesselection","react-flow__container",t]),style:{transform:l}},Z.createElement("div",{ref:f,className:"react-flow__nodesselection-rect",onContextMenu:h,tabIndex:n?void 0:-1,onKeyDown:n?void 0:m,style:{width:i,height:s,top:o,left:a}}))}var UCt=x.memo($Ct);const zCt=e=>e.nodesSelectionActive,PNe=({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:i,onPaneContextMenu:s,onPaneScroll:a,deleteKeyCode:o,onMove:l,onMoveStart:u,onMoveEnd:d,selectionKeyCode:f,selectionOnDrag:h,selectionMode:m,onSelectionStart:b,onSelectionEnd:y,multiSelectionKeyCode:v,panActivationKeyCode:_,zoomActivationKeyCode:w,elementsSelectable:C,zoomOnScroll:T,zoomOnPinch:k,panOnScroll:S,panOnScrollSpeed:A,panOnScrollMode:R,zoomOnDoubleClick:I,panOnDrag:D,defaultViewport:P,translateExtent:j,minZoom:B,maxZoom:L,preventScrolling:M,onSelectionContextMenu:$,noWheelClassName:U,noPanClassName:W,disableKeyboardA11y:Y})=>{const G=Pi(zCt),q=YE(f),X=YE(_),z=X||D,Q=X||S,ee=q||h&&z!==!0;return TCt({deleteKeyCode:o,multiSelectionKeyCode:v}),Z.createElement(RCt,{onMove:l,onMoveStart:u,onMoveEnd:d,onPaneContextMenu:s,elementsSelectable:C,zoomOnScroll:T,zoomOnPinch:k,panOnScroll:Q,panOnScrollSpeed:A,panOnScrollMode:R,zoomOnDoubleClick:I,panOnDrag:!q&&z,defaultViewport:P,translateExtent:j,minZoom:B,maxZoom:L,zoomActivationKeyCode:w,preventScrolling:M,noWheelClassName:U,noPanClassName:W},Z.createElement(NNe,{onSelectionStart:b,onSelectionEnd:y,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:i,onPaneContextMenu:s,onPaneScroll:a,panOnDrag:z,isSelecting:!!ee,selectionMode:m},e,G&&Z.createElement(UCt,{onSelectionContextMenu:$,noPanClassName:W,disableKeyboardA11y:Y})))};PNe.displayName="FlowRenderer";var HCt=x.memo(PNe);function VCt(e){return Pi(x.useCallback(n=>e?uNe(n.nodeInternals,{x:0,y:0,width:n.width,height:n.height},n.transform,!0):n.getNodes(),[e]))}function WCt(e){const t={input:LS(e.input||yNe),default:LS(e.default||BU),output:LS(e.output||xNe),group:LS(e.group||IZ)},n={},r=Object.keys(e).filter(i=>!["input","default","output","group"].includes(i)).reduce((i,s)=>(i[s]=LS(e[s]||BU),i),n);return{...t,...r}}const qCt=({x:e,y:t,width:n,height:r,origin:i})=>!n||!r?{x:e,y:t}:i[0]<0||i[1]<0||i[0]>1||i[1]>1?{x:e,y:t}:{x:e-n*i[0],y:t-r*i[1]},GCt=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,updateNodeDimensions:e.updateNodeDimensions,onError:e.onError}),jNe=e=>{const{nodesDraggable:t,nodesConnectable:n,nodesFocusable:r,elementsSelectable:i,updateNodeDimensions:s,onError:a}=Pi(GCt,Ha),o=VCt(e.onlyRenderVisibleElements),l=x.useRef(),u=x.useMemo(()=>{if(typeof ResizeObserver>"u")return null;const d=new ResizeObserver(f=>{const h=f.map(m=>({id:m.target.getAttribute("data-id"),nodeElement:m.target,forceUpdate:!0}));s(h)});return l.current=d,d},[]);return x.useEffect(()=>()=>{l?.current?.disconnect()},[]),Z.createElement("div",{className:"react-flow__nodes",style:PZ},o.map(d=>{let f=d.type||"default";e.nodeTypes[f]||(a?.("003",Gh.error003(f)),f="default");const h=e.nodeTypes[f]||e.nodeTypes.default,m=!!(d.draggable||t&&typeof d.draggable>"u"),b=!!(d.selectable||i&&typeof d.selectable>"u"),y=!!(d.connectable||n&&typeof d.connectable>"u"),v=!!(d.focusable||r&&typeof d.focusable>"u"),_=e.nodeExtent?kZ(d.positionAbsolute,e.nodeExtent):d.positionAbsolute,w=_?.x??0,C=_?.y??0,T=qCt({x:w,y:C,width:d.width??0,height:d.height??0,origin:e.nodeOrigin});return Z.createElement(h,{key:d.id,id:d.id,className:d.className,style:d.style,type:f,data:d.data,sourcePosition:d.sourcePosition||wn.Bottom,targetPosition:d.targetPosition||wn.Top,hidden:d.hidden,xPos:w,yPos:C,xPosOrigin:T.x,yPosOrigin:T.y,selectNodesOnDrag:e.selectNodesOnDrag,onClick:e.onNodeClick,onMouseEnter:e.onNodeMouseEnter,onMouseMove:e.onNodeMouseMove,onMouseLeave:e.onNodeMouseLeave,onContextMenu:e.onNodeContextMenu,onDoubleClick:e.onNodeDoubleClick,selected:!!d.selected,isDraggable:m,isSelectable:b,isConnectable:y,isFocusable:v,resizeObserver:u,dragHandle:d.dragHandle,zIndex:d[Cs]?.z??0,isParent:!!d[Cs]?.isParent,noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,initialized:!!d.width&&!!d.height,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,ariaLabel:d.ariaLabel,hasHandleBounds:!!d[Cs]?.handleBounds})}))};jNe.displayName="NodeRenderer";var KCt=x.memo(jNe);const YCt=(e,t,n)=>n===wn.Left?e-t:n===wn.Right?e+t:e,XCt=(e,t,n)=>n===wn.Top?e-t:n===wn.Bottom?e+t:e,Mue="react-flow__edgeupdater",Fue=({position:e,centerX:t,centerY:n,radius:r=10,onMouseDown:i,onMouseEnter:s,onMouseOut:a,type:o})=>Z.createElement("circle",{onMouseDown:i,onMouseEnter:s,onMouseOut:a,className:bo([Mue,`${Mue}-${o}`]),cx:YCt(t,r,e),cy:XCt(n,r,e),r,stroke:"transparent",fill:"transparent"}),ZCt=()=>!0;var Qv=e=>{const t=({id:n,className:r,type:i,data:s,onClick:a,onEdgeDoubleClick:o,selected:l,animated:u,label:d,labelStyle:f,labelShowBg:h,labelBgStyle:m,labelBgPadding:b,labelBgBorderRadius:y,style:v,source:_,target:w,sourceX:C,sourceY:T,targetX:k,targetY:S,sourcePosition:A,targetPosition:R,elementsSelectable:I,hidden:D,sourceHandleId:P,targetHandleId:j,onContextMenu:B,onMouseEnter:L,onMouseMove:M,onMouseLeave:$,reconnectRadius:U,onReconnect:W,onReconnectStart:Y,onReconnectEnd:G,markerEnd:q,markerStart:X,rfId:z,ariaLabel:Q,isFocusable:ee,isReconnectable:ne,pathOptions:ae,interactionWidth:fe,disableKeyboardA11y:re})=>{const de=x.useRef(null),[he,ce]=x.useState(!1),[ye,be]=x.useState(!1),ue=ya(),Ae=x.useMemo(()=>`url('#${MU(X,z)}')`,[X,z]),le=x.useMemo(()=>`url('#${MU(q,z)}')`,[q,z]);if(D)return null;const ke=mt=>{const{edges:Ke,addSelectedEdges:lt,unselectNodesAndEdges:Ve,multiSelectionActive:Ct}=ue.getState(),Ne=Ke.find(Ue=>Ue.id===n);Ne&&(I&&(ue.setState({nodesSelectionActive:!1}),Ne.selected&&Ct?(Ve({nodes:[],edges:[Ne]}),de.current?.blur()):lt([n])),a&&a(mt,Ne))},Fe=PS(n,ue.getState,o),ze=PS(n,ue.getState,B),ve=PS(n,ue.getState,L),je=PS(n,ue.getState,M),we=PS(n,ue.getState,$),Le=(mt,Ke)=>{if(mt.button!==0)return;const{edges:lt,isValidConnection:Ve}=ue.getState(),Ct=Ke?w:_,Ne=(Ke?j:P)||null,Ue=Ke?"target":"source",st=Ve||ZCt,et=Ke,pt=lt.find(Se=>Se.id===n);be(!0),Y?.(mt,pt,Ue);const wt=Se=>{be(!1),G?.(Se,pt,Ue)};pNe({event:mt,handleId:Ne,nodeId:Ct,onConnect:Se=>W?.(pt,Se),isTarget:et,getState:ue.getState,setState:ue.setState,isValidConnection:st,edgeUpdaterType:Ue,onReconnectEnd:wt})},qe=mt=>Le(mt,!0),Re=mt=>Le(mt,!1),Ie=()=>ce(!0),se=()=>ce(!1),Ge=!I&&!a,ut=mt=>{if(!re&&nNe.includes(mt.key)&&I){const{unselectNodesAndEdges:Ke,addSelectedEdges:lt,edges:Ve}=ue.getState();mt.key==="Escape"?(de.current?.blur(),Ke({edges:[Ve.find(Ne=>Ne.id===n)]})):lt([n])}};return Z.createElement("g",{className:bo(["react-flow__edge",`react-flow__edge-${i}`,r,{selected:l,animated:u,inactive:Ge,updating:he}]),onClick:ke,onDoubleClick:Fe,onContextMenu:ze,onMouseEnter:ve,onMouseMove:je,onMouseLeave:we,onKeyDown:ee?ut:void 0,tabIndex:ee?0:void 0,role:ee?"button":"img","data-testid":`rf__edge-${n}`,"aria-label":Q===null?void 0:Q||`Edge from ${_} to ${w}`,"aria-describedby":ee?`${wNe}-${z}`:void 0,ref:de},!ye&&Z.createElement(e,{id:n,source:_,target:w,selected:l,animated:u,label:d,labelStyle:f,labelShowBg:h,labelBgStyle:m,labelBgPadding:b,labelBgBorderRadius:y,data:s,style:v,sourceX:C,sourceY:T,targetX:k,targetY:S,sourcePosition:A,targetPosition:R,sourceHandleId:P,targetHandleId:j,markerStart:Ae,markerEnd:le,pathOptions:ae,interactionWidth:fe}),ne&&Z.createElement(Z.Fragment,null,(ne==="source"||ne===!0)&&Z.createElement(Fue,{position:A,centerX:C,centerY:T,radius:U,onMouseDown:qe,onMouseEnter:Ie,onMouseOut:se,type:"source"}),(ne==="target"||ne===!0)&&Z.createElement(Fue,{position:R,centerX:k,centerY:S,radius:U,onMouseDown:Re,onMouseEnter:Ie,onMouseOut:se,type:"target"})))};return t.displayName="EdgeWrapper",x.memo(t)};function QCt(e){const t={default:Qv(e.default||vR),straight:Qv(e.bezier||NZ),step:Qv(e.step||AZ),smoothstep:Qv(e.step||r5),simplebezier:Qv(e.simplebezier||TZ)},n={},r=Object.keys(e).filter(i=>!["default","bezier"].includes(i)).reduce((i,s)=>(i[s]=Qv(e[s]||vR),i),n);return{...t,...r}}function Bue(e,t,n=null){const r=(n?.x||0)+t.x,i=(n?.y||0)+t.y,s=n?.width||t.width,a=n?.height||t.height;switch(e){case wn.Top:return{x:r+s/2,y:i};case wn.Right:return{x:r+s,y:i+a/2};case wn.Bottom:return{x:r+s/2,y:i+a};case wn.Left:return{x:r,y:i+a/2}}}function $ue(e,t){return e?e.length===1||!t?e[0]:t&&e.find(n=>n.id===t)||null:null}const JCt=(e,t,n,r,i,s)=>{const a=Bue(n,e,t),o=Bue(s,r,i);return{sourceX:a.x,sourceY:a.y,targetX:o.x,targetY:o.y}};function e2t({sourcePos:e,targetPos:t,sourceWidth:n,sourceHeight:r,targetWidth:i,targetHeight:s,width:a,height:o,transform:l}){const u={x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x+n,t.x+i),y2:Math.max(e.y+r,t.y+s)};u.x===u.x2&&(u.x2+=1),u.y===u.y2&&(u.y2+=1);const d=qE({x:(0-l[0])/l[2],y:(0-l[1])/l[2],width:a/l[2],height:o/l[2]}),f=Math.max(0,Math.min(d.x2,u.x2)-Math.max(d.x,u.x)),h=Math.max(0,Math.min(d.y2,u.y2)-Math.max(d.y,u.y));return Math.ceil(f*h)>0}function Uue(e){const t=e?.[Cs]?.handleBounds||null,n=t&&e?.width&&e?.height&&typeof e?.positionAbsolute?.x<"u"&&typeof e?.positionAbsolute?.y<"u";return[{x:e?.positionAbsolute?.x||0,y:e?.positionAbsolute?.y||0,width:e?.width||0,height:e?.height||0},t,!!n]}const t2t=[{level:0,isMaxLevel:!0,edges:[]}];function n2t(e,t,n=!1){let r=-1;const i=e.reduce((a,o)=>{const l=uc(o.zIndex);let u=l?o.zIndex:0;if(n){const d=t.get(o.target),f=t.get(o.source),h=o.selected||d?.selected||f?.selected,m=Math.max(f?.[Cs]?.z||0,d?.[Cs]?.z||0,1e3);u=(l?o.zIndex:0)+(h?m:0)}return a[u]?a[u].push(o):a[u]=[o],r=u>r?u:r,a},{}),s=Object.entries(i).map(([a,o])=>{const l=+a;return{edges:o,level:l,isMaxLevel:l===r}});return s.length===0?t2t:s}function r2t(e,t,n){const r=Pi(x.useCallback(i=>e?i.edges.filter(s=>{const a=t.get(s.source),o=t.get(s.target);return a?.width&&a?.height&&o?.width&&o?.height&&e2t({sourcePos:a.positionAbsolute||{x:0,y:0},targetPos:o.positionAbsolute||{x:0,y:0},sourceWidth:a.width,sourceHeight:a.height,targetWidth:o.width,targetHeight:o.height,width:i.width,height:i.height,transform:i.transform})}):i.edges,[e,t]));return n2t(r,t,n)}const i2t=({color:e="none",strokeWidth:t=1})=>Z.createElement("polyline",{style:{stroke:e,strokeWidth:t},strokeLinecap:"round",strokeLinejoin:"round",fill:"none",points:"-5,-4 0,0 -5,4"}),s2t=({color:e="none",strokeWidth:t=1})=>Z.createElement("polyline",{style:{stroke:e,fill:e,strokeWidth:t},strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"}),zue={[KE.Arrow]:i2t,[KE.ArrowClosed]:s2t};function a2t(e){const t=ya();return x.useMemo(()=>Object.prototype.hasOwnProperty.call(zue,e)?zue[e]:(t.getState().onError?.("009",Gh.error009(e)),null),[e])}const o2t=({id:e,type:t,color:n,width:r=12.5,height:i=12.5,markerUnits:s="strokeWidth",strokeWidth:a,orient:o="auto-start-reverse"})=>{const l=a2t(t);return l?Z.createElement("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${r}`,markerHeight:`${i}`,viewBox:"-10 -10 20 20",markerUnits:s,orient:o,refX:"0",refY:"0"},Z.createElement(l,{color:n,strokeWidth:a})):null},l2t=({defaultColor:e,rfId:t})=>n=>{const r=[];return n.edges.reduce((i,s)=>([s.markerStart,s.markerEnd].forEach(a=>{if(a&&typeof a=="object"){const o=MU(a,t);r.includes(o)||(i.push({id:o,color:a.color||e,...a}),r.push(o))}}),i),[]).sort((i,s)=>i.id.localeCompare(s.id))},LNe=({defaultColor:e,rfId:t})=>{const n=Pi(x.useCallback(l2t({defaultColor:e,rfId:t}),[e,t]),(r,i)=>!(r.length!==i.length||r.some((s,a)=>s.id!==i[a].id)));return Z.createElement("defs",null,n.map(r=>Z.createElement(o2t,{id:r.id,key:r.id,type:r.type,color:r.color,width:r.width,height:r.height,markerUnits:r.markerUnits,strokeWidth:r.strokeWidth,orient:r.orient})))};LNe.displayName="MarkerDefinitions";var u2t=x.memo(LNe);const c2t=e=>({nodesConnectable:e.nodesConnectable,edgesFocusable:e.edgesFocusable,edgesUpdatable:e.edgesUpdatable,elementsSelectable:e.elementsSelectable,width:e.width,height:e.height,connectionMode:e.connectionMode,nodeInternals:e.nodeInternals,onError:e.onError}),MNe=({defaultMarkerColor:e,onlyRenderVisibleElements:t,elevateEdgesOnSelect:n,rfId:r,edgeTypes:i,noPanClassName:s,onEdgeContextMenu:a,onEdgeMouseEnter:o,onEdgeMouseMove:l,onEdgeMouseLeave:u,onEdgeClick:d,onEdgeDoubleClick:f,onReconnect:h,onReconnectStart:m,onReconnectEnd:b,reconnectRadius:y,children:v,disableKeyboardA11y:_})=>{const{edgesFocusable:w,edgesUpdatable:C,elementsSelectable:T,width:k,height:S,connectionMode:A,nodeInternals:R,onError:I}=Pi(c2t,Ha),D=r2t(t,R,n);return k?Z.createElement(Z.Fragment,null,D.map(({level:P,edges:j,isMaxLevel:B})=>Z.createElement("svg",{key:P,style:{zIndex:P},width:k,height:S,className:"react-flow__edges react-flow__container"},B&&Z.createElement(u2t,{defaultColor:e,rfId:r}),Z.createElement("g",null,j.map(L=>{const[M,$,U]=Uue(R.get(L.source)),[W,Y,G]=Uue(R.get(L.target));if(!U||!G)return null;let q=L.type||"default";i[q]||(I?.("011",Gh.error011(q)),q="default");const X=i[q]||i.default,z=A===gy.Strict?Y.target:(Y.target??[]).concat(Y.source??[]),Q=$ue($.source,L.sourceHandle),ee=$ue(z,L.targetHandle),ne=Q?.position||wn.Bottom,ae=ee?.position||wn.Top,fe=!!(L.focusable||w&&typeof L.focusable>"u"),re=L.reconnectable||L.updatable,de=typeof h<"u"&&(re||C&&typeof re>"u");if(!Q||!ee)return I?.("008",Gh.error008(Q,L)),null;const{sourceX:he,sourceY:ce,targetX:ye,targetY:be}=JCt(M,Q,ne,W,ee,ae);return Z.createElement(X,{key:L.id,id:L.id,className:bo([L.className,s]),type:q,data:L.data,selected:!!L.selected,animated:!!L.animated,hidden:!!L.hidden,label:L.label,labelStyle:L.labelStyle,labelShowBg:L.labelShowBg,labelBgStyle:L.labelBgStyle,labelBgPadding:L.labelBgPadding,labelBgBorderRadius:L.labelBgBorderRadius,style:L.style,source:L.source,target:L.target,sourceHandleId:L.sourceHandle,targetHandleId:L.targetHandle,markerEnd:L.markerEnd,markerStart:L.markerStart,sourceX:he,sourceY:ce,targetX:ye,targetY:be,sourcePosition:ne,targetPosition:ae,elementsSelectable:T,onContextMenu:a,onMouseEnter:o,onMouseMove:l,onMouseLeave:u,onClick:d,onEdgeDoubleClick:f,onReconnect:h,onReconnectStart:m,onReconnectEnd:b,reconnectRadius:y,rfId:r,ariaLabel:L.ariaLabel,isFocusable:fe,isReconnectable:de,pathOptions:"pathOptions"in L?L.pathOptions:void 0,interactionWidth:L.interactionWidth,disableKeyboardA11y:_})})))),v):null};MNe.displayName="EdgeRenderer";var d2t=x.memo(MNe);const f2t=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function h2t({children:e}){const t=Pi(f2t);return Z.createElement("div",{className:"react-flow__viewport react-flow__container",style:{transform:t}},e)}function p2t(e){const t=DZ(),n=x.useRef(!1);x.useEffect(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}const m2t={[wn.Left]:wn.Right,[wn.Right]:wn.Left,[wn.Top]:wn.Bottom,[wn.Bottom]:wn.Top},FNe=({nodeId:e,handleType:t,style:n,type:r=fm.Bezier,CustomComponent:i,connectionStatus:s})=>{const{fromNode:a,handleId:o,toX:l,toY:u,connectionMode:d}=Pi(x.useCallback(S=>({fromNode:S.nodeInternals.get(e),handleId:S.connectionHandleId,toX:(S.connectionPosition.x-S.transform[0])/S.transform[2],toY:(S.connectionPosition.y-S.transform[1])/S.transform[2],connectionMode:S.connectionMode}),[e]),Ha),f=a?.[Cs]?.handleBounds;let h=f?.[t];if(d===gy.Loose&&(h=h||f?.[t==="source"?"target":"source"]),!a||!h)return null;const m=o?h.find(S=>S.id===o):h[0],b=m?m.x+m.width/2:(a.width??0)/2,y=m?m.y+m.height/2:a.height??0,v=(a.positionAbsolute?.x??0)+b,_=(a.positionAbsolute?.y??0)+y,w=m?.position,C=w?m2t[w]:null;if(!w||!C)return null;if(i)return Z.createElement(i,{connectionLineType:r,connectionLineStyle:n,fromNode:a,fromHandle:m,fromX:v,fromY:_,toX:l,toY:u,fromPosition:w,toPosition:C,connectionStatus:s});let T="";const k={sourceX:v,sourceY:_,sourcePosition:w,targetX:l,targetY:u,targetPosition:C};return r===fm.Bezier?[T]=oNe(k):r===fm.Step?[T]=LU({...k,borderRadius:0}):r===fm.SmoothStep?[T]=LU(k):r===fm.SimpleBezier?[T]=aNe(k):T=`M${v},${_} ${l},${u}`,Z.createElement("path",{d:T,fill:"none",className:"react-flow__connection-path",style:n})};FNe.displayName="ConnectionLine";const g2t=e=>({nodeId:e.connectionNodeId,handleType:e.connectionHandleType,nodesConnectable:e.nodesConnectable,connectionStatus:e.connectionStatus,width:e.width,height:e.height});function b2t({containerStyle:e,style:t,type:n,component:r}){const{nodeId:i,handleType:s,nodesConnectable:a,width:o,height:l,connectionStatus:u}=Pi(g2t,Ha);return!(i&&s&&o&&a)?null:Z.createElement("svg",{style:e,width:o,height:l,className:"react-flow__edges react-flow__connectionline react-flow__container"},Z.createElement("g",{className:bo(["react-flow__connection",u])},Z.createElement(FNe,{nodeId:i,handleType:s,style:t,type:n,CustomComponent:r,connectionStatus:u})))}function Hue(e,t){return x.useRef(null),ya(),x.useMemo(()=>t(e),[e])}const BNe=({nodeTypes:e,edgeTypes:t,onMove:n,onMoveStart:r,onMoveEnd:i,onInit:s,onNodeClick:a,onEdgeClick:o,onNodeDoubleClick:l,onEdgeDoubleClick:u,onNodeMouseEnter:d,onNodeMouseMove:f,onNodeMouseLeave:h,onNodeContextMenu:m,onSelectionContextMenu:b,onSelectionStart:y,onSelectionEnd:v,connectionLineType:_,connectionLineStyle:w,connectionLineComponent:C,connectionLineContainerStyle:T,selectionKeyCode:k,selectionOnDrag:S,selectionMode:A,multiSelectionKeyCode:R,panActivationKeyCode:I,zoomActivationKeyCode:D,deleteKeyCode:P,onlyRenderVisibleElements:j,elementsSelectable:B,selectNodesOnDrag:L,defaultViewport:M,translateExtent:$,minZoom:U,maxZoom:W,preventScrolling:Y,defaultMarkerColor:G,zoomOnScroll:q,zoomOnPinch:X,panOnScroll:z,panOnScrollSpeed:Q,panOnScrollMode:ee,zoomOnDoubleClick:ne,panOnDrag:ae,onPaneClick:fe,onPaneMouseEnter:re,onPaneMouseMove:de,onPaneMouseLeave:he,onPaneScroll:ce,onPaneContextMenu:ye,onEdgeContextMenu:be,onEdgeMouseEnter:ue,onEdgeMouseMove:Ae,onEdgeMouseLeave:le,onReconnect:ke,onReconnectStart:Fe,onReconnectEnd:ze,reconnectRadius:ve,noDragClassName:je,noWheelClassName:we,noPanClassName:Le,elevateEdgesOnSelect:qe,disableKeyboardA11y:Re,nodeOrigin:Ie,nodeExtent:se,rfId:Ge})=>{const ut=Hue(e,WCt),mt=Hue(t,QCt);return p2t(s),Z.createElement(HCt,{onPaneClick:fe,onPaneMouseEnter:re,onPaneMouseMove:de,onPaneMouseLeave:he,onPaneContextMenu:ye,onPaneScroll:ce,deleteKeyCode:P,selectionKeyCode:k,selectionOnDrag:S,selectionMode:A,onSelectionStart:y,onSelectionEnd:v,multiSelectionKeyCode:R,panActivationKeyCode:I,zoomActivationKeyCode:D,elementsSelectable:B,onMove:n,onMoveStart:r,onMoveEnd:i,zoomOnScroll:q,zoomOnPinch:X,zoomOnDoubleClick:ne,panOnScroll:z,panOnScrollSpeed:Q,panOnScrollMode:ee,panOnDrag:ae,defaultViewport:M,translateExtent:$,minZoom:U,maxZoom:W,onSelectionContextMenu:b,preventScrolling:Y,noDragClassName:je,noWheelClassName:we,noPanClassName:Le,disableKeyboardA11y:Re},Z.createElement(h2t,null,Z.createElement(d2t,{edgeTypes:mt,onEdgeClick:o,onEdgeDoubleClick:u,onlyRenderVisibleElements:j,onEdgeContextMenu:be,onEdgeMouseEnter:ue,onEdgeMouseMove:Ae,onEdgeMouseLeave:le,onReconnect:ke,onReconnectStart:Fe,onReconnectEnd:ze,reconnectRadius:ve,defaultMarkerColor:G,noPanClassName:Le,elevateEdgesOnSelect:!!qe,disableKeyboardA11y:Re,rfId:Ge},Z.createElement(b2t,{style:w,type:_,component:C,containerStyle:T})),Z.createElement("div",{className:"react-flow__edgelabel-renderer"}),Z.createElement(KCt,{nodeTypes:ut,onNodeClick:a,onNodeDoubleClick:l,onNodeMouseEnter:d,onNodeMouseMove:f,onNodeMouseLeave:h,onNodeContextMenu:m,selectNodesOnDrag:L,onlyRenderVisibleElements:j,noPanClassName:Le,noDragClassName:je,disableKeyboardA11y:Re,nodeOrigin:Ie,nodeExtent:se,rfId:Ge})))};BNe.displayName="GraphView";var y2t=x.memo(BNe);const UU=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],tm={rfId:"1",width:0,height:0,transform:[0,0,1],nodeInternals:new Map,edges:[],onNodesChange:null,onEdgesChange:null,hasDefaultNodes:!1,hasDefaultEdges:!1,d3Zoom:null,d3Selection:null,d3ZoomHandler:void 0,minZoom:.5,maxZoom:2,translateExtent:UU,nodeExtent:UU,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionNodeId:null,connectionHandleId:null,connectionHandleType:"source",connectionPosition:{x:0,y:0},connectionStatus:null,connectionMode:gy.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:[0,0],nodeDragThreshold:0,snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesUpdatable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,fitViewOnInit:!1,fitViewOnInitDone:!1,fitViewOnInitOptions:void 0,onSelectionChange:[],multiSelectionActive:!1,connectionStartHandle:null,connectionEndHandle:null,connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,connectionRadius:20,onError:qEt,isValidConnection:void 0},v2t=()=>n_t((e,t)=>({...tm,setNodes:n=>{const{nodeInternals:r,nodeOrigin:i,elevateNodesOnSelect:s}=t();e({nodeInternals:Z4(n,r,i,s)})},getNodes:()=>Array.from(t().nodeInternals.values()),setEdges:n=>{const{defaultEdgeOptions:r={}}=t();e({edges:n.map(i=>({...r,...i}))})},setDefaultNodesAndEdges:(n,r)=>{const i=typeof n<"u",s=typeof r<"u",a=i?Z4(n,new Map,t().nodeOrigin,t().elevateNodesOnSelect):new Map;e({nodeInternals:a,edges:s?r:[],hasDefaultNodes:i,hasDefaultEdges:s})},updateNodeDimensions:n=>{const{onNodesChange:r,nodeInternals:i,fitViewOnInit:s,fitViewOnInitDone:a,fitViewOnInitOptions:o,domNode:l,nodeOrigin:u}=t(),d=l?.querySelector(".react-flow__viewport");if(!d)return;const f=window.getComputedStyle(d),{m22:h}=new window.DOMMatrixReadOnly(f.transform),m=n.reduce((y,v)=>{const _=i.get(v.id);if(_?.hidden)i.set(_.id,{..._,[Cs]:{..._[Cs],handleBounds:void 0}});else if(_){const w=CZ(v.nodeElement);w.width&&w.height&&(_.width!==w.width||_.height!==w.height||v.forceUpdate)&&(i.set(_.id,{..._,[Cs]:{..._[Cs],handleBounds:{source:Lue(".source",v.nodeElement,h,u),target:Lue(".target",v.nodeElement,h,u)}},...w}),y.push({id:_.id,type:"dimensions",dimensions:w}))}return y},[]);CNe(i,u);const b=a||s&&!a&&kNe(t,{initial:!0,...o});e({nodeInternals:new Map(i),fitViewOnInitDone:b}),m?.length>0&&r?.(m)},updateNodePositions:(n,r=!0,i=!1)=>{const{triggerNodeChanges:s}=t(),a=n.map(o=>{const l={id:o.id,type:"position",dragging:i};return r&&(l.positionAbsolute=o.positionAbsolute,l.position=o.position),l});s(a)},triggerNodeChanges:n=>{const{onNodesChange:r,nodeInternals:i,hasDefaultNodes:s,nodeOrigin:a,getNodes:o,elevateNodesOnSelect:l}=t();if(n?.length){if(s){const u=ANe(n,o()),d=Z4(u,i,a,l);e({nodeInternals:d})}r?.(n)}},addSelectedNodes:n=>{const{multiSelectionActive:r,edges:i,getNodes:s}=t();let a,o=null;r?a=n.map(l=>lm(l,!0)):(a=x0(s(),n),o=x0(i,[])),HA({changedNodes:a,changedEdges:o,get:t,set:e})},addSelectedEdges:n=>{const{multiSelectionActive:r,edges:i,getNodes:s}=t();let a,o=null;r?a=n.map(l=>lm(l,!0)):(a=x0(i,n),o=x0(s(),[])),HA({changedNodes:o,changedEdges:a,get:t,set:e})},unselectNodesAndEdges:({nodes:n,edges:r}={})=>{const{edges:i,getNodes:s}=t(),a=n||s(),o=r||i,l=a.map(d=>(d.selected=!1,lm(d.id,!1))),u=o.map(d=>lm(d.id,!1));HA({changedNodes:l,changedEdges:u,get:t,set:e})},setMinZoom:n=>{const{d3Zoom:r,maxZoom:i}=t();r?.scaleExtent([n,i]),e({minZoom:n})},setMaxZoom:n=>{const{d3Zoom:r,minZoom:i}=t();r?.scaleExtent([i,n]),e({maxZoom:n})},setTranslateExtent:n=>{t().d3Zoom?.translateExtent(n),e({translateExtent:n})},resetSelectedElements:()=>{const{edges:n,getNodes:r}=t(),s=r().filter(o=>o.selected).map(o=>lm(o.id,!1)),a=n.filter(o=>o.selected).map(o=>lm(o.id,!1));HA({changedNodes:s,changedEdges:a,get:t,set:e})},setNodeExtent:n=>{const{nodeInternals:r}=t();r.forEach(i=>{i.positionAbsolute=kZ(i.position,n)}),e({nodeExtent:n,nodeInternals:new Map(r)})},panBy:n=>{const{transform:r,width:i,height:s,d3Zoom:a,d3Selection:o,translateExtent:l}=t();if(!a||!o||!n.x&&!n.y)return!1;const u=Rh.translate(r[0]+n.x,r[1]+n.y).scale(r[2]),d=[[0,0],[i,s]],f=a?.constrain()(u,d,l);return a.transform(o,f),r[0]!==f.x||r[1]!==f.y||r[2]!==f.k},cancelConnection:()=>e({connectionNodeId:tm.connectionNodeId,connectionHandleId:tm.connectionHandleId,connectionHandleType:tm.connectionHandleType,connectionStatus:tm.connectionStatus,connectionStartHandle:tm.connectionStartHandle,connectionEndHandle:tm.connectionEndHandle}),reset:()=>e({...tm})}),Object.is),$Ne=({children:e})=>{const t=x.useRef(null);return t.current||(t.current=v2t()),Z.createElement(BEt,{value:t.current},e)};$Ne.displayName="ReactFlowProvider";const UNe=({children:e})=>x.useContext(n5)?Z.createElement(Z.Fragment,null,e):Z.createElement($Ne,null,e);UNe.displayName="ReactFlowWrapper";const x2t={input:yNe,default:BU,output:xNe,group:IZ},_2t={default:vR,straight:NZ,step:AZ,smoothstep:r5,simplebezier:TZ},S2t=[0,0],w2t=[15,15],E2t={x:0,y:0,zoom:1},C2t={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0},zNe=x.forwardRef(({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,className:i,nodeTypes:s=x2t,edgeTypes:a=_2t,onNodeClick:o,onEdgeClick:l,onInit:u,onMove:d,onMoveStart:f,onMoveEnd:h,onConnect:m,onConnectStart:b,onConnectEnd:y,onClickConnectStart:v,onClickConnectEnd:_,onNodeMouseEnter:w,onNodeMouseMove:C,onNodeMouseLeave:T,onNodeContextMenu:k,onNodeDoubleClick:S,onNodeDragStart:A,onNodeDrag:R,onNodeDragStop:I,onNodesDelete:D,onEdgesDelete:P,onSelectionChange:j,onSelectionDragStart:B,onSelectionDrag:L,onSelectionDragStop:M,onSelectionContextMenu:$,onSelectionStart:U,onSelectionEnd:W,connectionMode:Y=gy.Strict,connectionLineType:G=fm.Bezier,connectionLineStyle:q,connectionLineComponent:X,connectionLineContainerStyle:z,deleteKeyCode:Q="Backspace",selectionKeyCode:ee="Shift",selectionOnDrag:ne=!1,selectionMode:ae=GE.Full,panActivationKeyCode:fe="Space",multiSelectionKeyCode:re=yR()?"Meta":"Control",zoomActivationKeyCode:de=yR()?"Meta":"Control",snapToGrid:he=!1,snapGrid:ce=w2t,onlyRenderVisibleElements:ye=!1,selectNodesOnDrag:be=!0,nodesDraggable:ue,nodesConnectable:Ae,nodesFocusable:le,nodeOrigin:ke=S2t,edgesFocusable:Fe,edgesUpdatable:ze,elementsSelectable:ve,defaultViewport:je=E2t,minZoom:we=.5,maxZoom:Le=2,translateExtent:qe=UU,preventScrolling:Re=!0,nodeExtent:Ie,defaultMarkerColor:se="#b1b1b7",zoomOnScroll:Ge=!0,zoomOnPinch:ut=!0,panOnScroll:mt=!1,panOnScrollSpeed:Ke=.5,panOnScrollMode:lt=kb.Free,zoomOnDoubleClick:Ve=!0,panOnDrag:Ct=!0,onPaneClick:Ne,onPaneMouseEnter:Ue,onPaneMouseMove:st,onPaneMouseLeave:et,onPaneScroll:pt,onPaneContextMenu:wt,children:Et,onEdgeContextMenu:Se,onEdgeDoubleClick:Oe,onEdgeMouseEnter:Qe,onEdgeMouseMove:It,onEdgeMouseLeave:_t,onEdgeUpdate:rn,onEdgeUpdateStart:an,onEdgeUpdateEnd:vn,onReconnect:zt,onReconnectStart:sn,onReconnectEnd:Ln,reconnectRadius:vr=10,edgeUpdaterRadius:Mr=10,onNodesChange:oi,onEdgesChange:gs,noDragClassName:xi="nodrag",noWheelClassName:dr="nowheel",noPanClassName:fr="nopan",fitView:Fi=!1,fitViewOptions:Ai,connectOnClick:Ki=!0,attributionPosition:vo,proOptions:Yi,defaultEdgeOptions:tt,elevateNodesOnSelect:Mn=!0,elevateEdgesOnSelect:An=!1,disableKeyboardA11y:Fr=!1,autoPanOnConnect:ss=!0,autoPanOnNodeDrag:li=!0,connectionRadius:kr=20,isValidConnection:ei,onError:hr,style:Br,id:Xi,nodeDragThreshold:Fo,...Gt},it)=>{const Wt=Xi||"1";return Z.createElement("div",{...Gt,style:{...Br,...C2t},ref:it,className:bo(["react-flow",i]),"data-testid":"rf__wrapper",id:Xi},Z.createElement(UNe,null,Z.createElement(y2t,{onInit:u,onMove:d,onMoveStart:f,onMoveEnd:h,onNodeClick:o,onEdgeClick:l,onNodeMouseEnter:w,onNodeMouseMove:C,onNodeMouseLeave:T,onNodeContextMenu:k,onNodeDoubleClick:S,nodeTypes:s,edgeTypes:a,connectionLineType:G,connectionLineStyle:q,connectionLineComponent:X,connectionLineContainerStyle:z,selectionKeyCode:ee,selectionOnDrag:ne,selectionMode:ae,deleteKeyCode:Q,multiSelectionKeyCode:re,panActivationKeyCode:fe,zoomActivationKeyCode:de,onlyRenderVisibleElements:ye,selectNodesOnDrag:be,defaultViewport:je,translateExtent:qe,minZoom:we,maxZoom:Le,preventScrolling:Re,zoomOnScroll:Ge,zoomOnPinch:ut,zoomOnDoubleClick:Ve,panOnScroll:mt,panOnScrollSpeed:Ke,panOnScrollMode:lt,panOnDrag:Ct,onPaneClick:Ne,onPaneMouseEnter:Ue,onPaneMouseMove:st,onPaneMouseLeave:et,onPaneScroll:pt,onPaneContextMenu:wt,onSelectionContextMenu:$,onSelectionStart:U,onSelectionEnd:W,onEdgeContextMenu:Se,onEdgeDoubleClick:Oe,onEdgeMouseEnter:Qe,onEdgeMouseMove:It,onEdgeMouseLeave:_t,onReconnect:zt??rn,onReconnectStart:sn??an,onReconnectEnd:Ln??vn,reconnectRadius:vr??Mr,defaultMarkerColor:se,noDragClassName:xi,noWheelClassName:dr,noPanClassName:fr,elevateEdgesOnSelect:An,rfId:Wt,disableKeyboardA11y:Fr,nodeOrigin:ke,nodeExtent:Ie}),Z.createElement(mCt,{nodes:e,edges:t,defaultNodes:n,defaultEdges:r,onConnect:m,onConnectStart:b,onConnectEnd:y,onClickConnectStart:v,onClickConnectEnd:_,nodesDraggable:ue,nodesConnectable:Ae,nodesFocusable:le,edgesFocusable:Fe,edgesUpdatable:ze,elementsSelectable:ve,elevateNodesOnSelect:Mn,minZoom:we,maxZoom:Le,nodeExtent:Ie,onNodesChange:oi,onEdgesChange:gs,snapToGrid:he,snapGrid:ce,connectionMode:Y,translateExtent:qe,connectOnClick:Ki,defaultEdgeOptions:tt,fitView:Fi,fitViewOptions:Ai,onNodesDelete:D,onEdgesDelete:P,onNodeDragStart:A,onNodeDrag:R,onNodeDragStop:I,onSelectionDrag:L,onSelectionDragStart:B,onSelectionDragStop:M,noPanClassName:fr,nodeOrigin:ke,rfId:Wt,autoPanOnConnect:ss,autoPanOnNodeDrag:li,onError:hr,connectionRadius:kr,isValidConnection:ei,nodeDragThreshold:Fo}),Z.createElement(hCt,{onSelectionChange:j}),Et,Z.createElement(UEt,{proOptions:Yi,position:vo}),Z.createElement(xCt,{rfId:Wt,disableKeyboardA11y:Fr})))});zNe.displayName="ReactFlow";function HNe(e){return t=>{const[n,r]=x.useState(t),i=x.useCallback(s=>r(a=>e(s,a)),[]);return[n,r,i]}}const k2t=HNe(ANe),T2t=HNe(PCt),VNe=({id:e,x:t,y:n,width:r,height:i,style:s,color:a,strokeColor:o,strokeWidth:l,className:u,borderRadius:d,shapeRendering:f,onClick:h,selected:m})=>{const{background:b,backgroundColor:y}=s||{},v=a||b||y;return Z.createElement("rect",{className:bo(["react-flow__minimap-node",{selected:m},u]),x:t,y:n,rx:d,ry:d,width:r,height:i,fill:v,stroke:o,strokeWidth:l,shapeRendering:f,onClick:h?_=>h(_,e):void 0})};VNe.displayName="MiniMapNode";var A2t=x.memo(VNe);const N2t=e=>e.nodeOrigin,O2t=e=>e.getNodes().filter(t=>!t.hidden&&t.width&&t.height),t6=e=>e instanceof Function?e:()=>e;function R2t({nodeStrokeColor:e="transparent",nodeColor:t="#e2e2e2",nodeClassName:n="",nodeBorderRadius:r=5,nodeStrokeWidth:i=2,nodeComponent:s=A2t,onClick:a}){const o=Pi(O2t,Ha),l=Pi(N2t),u=t6(t),d=t6(e),f=t6(n),h=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return Z.createElement(Z.Fragment,null,o.map(m=>{const{x:b,y}=Kb(m,l).positionAbsolute;return Z.createElement(s,{key:m.id,x:b,y,width:m.width,height:m.height,style:m.style,selected:m.selected,className:f(m),color:u(m),borderRadius:r,strokeColor:d(m),strokeWidth:i,shapeRendering:h,onClick:a,id:m.id})}))}var I2t=x.memo(R2t);const D2t=200,P2t=150,j2t=e=>{const t=e.getNodes(),n={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:n,boundingRect:t.length>0?VEt(i5(t,e.nodeOrigin),n):n,rfId:e.rfId}},L2t="react-flow__minimap-desc";function WNe({style:e,className:t,nodeStrokeColor:n="transparent",nodeColor:r="#e2e2e2",nodeClassName:i="",nodeBorderRadius:s=5,nodeStrokeWidth:a=2,nodeComponent:o,maskColor:l="rgb(240, 240, 240, 0.6)",maskStrokeColor:u="none",maskStrokeWidth:d=1,position:f="bottom-right",onClick:h,onNodeClick:m,pannable:b=!1,zoomable:y=!1,ariaLabel:v="React Flow mini map",inversePan:_=!1,zoomStep:w=10,offsetScale:C=5}){const T=ya(),k=x.useRef(null),{boundingRect:S,viewBB:A,rfId:R}=Pi(j2t,Ha),I=e?.width??D2t,D=e?.height??P2t,P=S.width/I,j=S.height/D,B=Math.max(P,j),L=B*I,M=B*D,$=C*B,U=S.x-(L-S.width)/2-$,W=S.y-(M-S.height)/2-$,Y=L+$*2,G=M+$*2,q=`${L2t}-${R}`,X=x.useRef(0);X.current=B,x.useEffect(()=>{if(k.current){const ee=rc(k.current),ne=re=>{const{transform:de,d3Selection:he,d3Zoom:ce}=T.getState();if(re.sourceEvent.type!=="wheel"||!he||!ce)return;const ye=-re.sourceEvent.deltaY*(re.sourceEvent.deltaMode===1?.05:re.sourceEvent.deltaMode?1:.002)*w,be=de[2]*Math.pow(2,ye);ce.scaleTo(he,be)},ae=re=>{const{transform:de,d3Selection:he,d3Zoom:ce,translateExtent:ye,width:be,height:ue}=T.getState();if(re.sourceEvent.type!=="mousemove"||!he||!ce)return;const Ae=X.current*Math.max(1,de[2])*(_?-1:1),le={x:de[0]-re.sourceEvent.movementX*Ae,y:de[1]-re.sourceEvent.movementY*Ae},ke=[[0,0],[be,ue]],Fe=Rh.translate(le.x,le.y).scale(de[2]),ze=ce.constrain()(Fe,ke,ye);ce.transform(he,ze)},fe=XAe().on("zoom",b?ae:null).on("zoom.wheel",y?ne:null);return ee.call(fe),()=>{ee.on("zoom",null)}}},[b,y,_,w]);const z=h?ee=>{const ne=Kc(ee);h(ee,{x:ne[0],y:ne[1]})}:void 0,Q=m?(ee,ne)=>{const ae=T.getState().nodeInternals.get(ne);m(ee,ae)}:void 0;return Z.createElement(EZ,{position:f,style:e,className:bo(["react-flow__minimap",t]),"data-testid":"rf__minimap"},Z.createElement("svg",{width:I,height:D,viewBox:`${U} ${W} ${Y} ${G}`,role:"img","aria-labelledby":q,ref:k,onClick:z},v&&Z.createElement("title",{id:q},v),Z.createElement(I2t,{onClick:Q,nodeColor:r,nodeStrokeColor:n,nodeBorderRadius:s,nodeClassName:i,nodeStrokeWidth:a,nodeComponent:o}),Z.createElement("path",{className:"react-flow__minimap-mask",d:`M${U-$},${W-$}h${Y+$*2}v${G+$*2}h${-Y-$*2}z
|
|
137
|
-
M${A.x},${A.y}h${A.width}v${A.height}h${-A.width}z`,fill:l,fillRule:"evenodd",stroke:u,strokeWidth:d,pointerEvents:"none"})))}WNe.displayName="MiniMap";var M2t=x.memo(WNe);function F2t(){return Z.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32"},Z.createElement("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"}))}function B2t(){return Z.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5"},Z.createElement("path",{d:"M0 0h32v4.2H0z"}))}function $2t(){return Z.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30"},Z.createElement("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 U2t(){return Z.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32"},Z.createElement("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 z2t(){return Z.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32"},Z.createElement("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"}))}const uw=({children:e,className:t,...n})=>Z.createElement("button",{type:"button",className:bo(["react-flow__controls-button",t]),...n},e);uw.displayName="ControlButton";const H2t=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom}),qNe=({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:r=!0,fitViewOptions:i,onZoomIn:s,onZoomOut:a,onFitView:o,onInteractiveChange:l,className:u,children:d,position:f="bottom-left"})=>{const h=ya(),[m,b]=x.useState(!1),{isInteractive:y,minZoomReached:v,maxZoomReached:_}=Pi(H2t,Ha),{zoomIn:w,zoomOut:C,fitView:T}=DZ();if(x.useEffect(()=>{b(!0)},[]),!m)return null;const k=()=>{w(),s?.()},S=()=>{C(),a?.()},A=()=>{T(i),o?.()},R=()=>{h.setState({nodesDraggable:!y,nodesConnectable:!y,elementsSelectable:!y}),l?.(!y)};return Z.createElement(EZ,{className:bo(["react-flow__controls",u]),position:f,style:e,"data-testid":"rf__controls"},t&&Z.createElement(Z.Fragment,null,Z.createElement(uw,{onClick:k,className:"react-flow__controls-zoomin",title:"zoom in","aria-label":"zoom in",disabled:_},Z.createElement(F2t,null)),Z.createElement(uw,{onClick:S,className:"react-flow__controls-zoomout",title:"zoom out","aria-label":"zoom out",disabled:v},Z.createElement(B2t,null))),n&&Z.createElement(uw,{className:"react-flow__controls-fitview",onClick:A,title:"fit view","aria-label":"fit view"},Z.createElement($2t,null)),r&&Z.createElement(uw,{className:"react-flow__controls-interactive",onClick:R,title:"toggle interactivity","aria-label":"toggle interactivity"},y?Z.createElement(z2t,null):Z.createElement(U2t,null)),d)};qNe.displayName="Controls";var V2t=x.memo(qNe),od;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(od||(od={}));function W2t({color:e,dimensions:t,lineWidth:n}){return Z.createElement("path",{stroke:e,strokeWidth:n,d:`M${t[0]/2} 0 V${t[1]} M0 ${t[1]/2} H${t[0]}`})}function q2t({color:e,radius:t}){return Z.createElement("circle",{cx:t,cy:t,r:t,fill:e})}const G2t={[od.Dots]:"#91919a",[od.Lines]:"#eee",[od.Cross]:"#e2e2e2"},K2t={[od.Dots]:1,[od.Lines]:1,[od.Cross]:6},Y2t=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function GNe({id:e,variant:t=od.Dots,gap:n=20,size:r,lineWidth:i=1,offset:s=2,color:a,style:o,className:l}){const u=x.useRef(null),{transform:d,patternId:f}=Pi(Y2t,Ha),h=a||G2t[t],m=r||K2t[t],b=t===od.Dots,y=t===od.Cross,v=Array.isArray(n)?n:[n,n],_=[v[0]*d[2]||1,v[1]*d[2]||1],w=m*d[2],C=y?[w,w]:_,T=b?[w/s,w/s]:[C[0]/s,C[1]/s];return Z.createElement("svg",{className:bo(["react-flow__background",l]),style:{...o,position:"absolute",width:"100%",height:"100%",top:0,left:0},ref:u,"data-testid":"rf__background"},Z.createElement("pattern",{id:f+e,x:d[0]%_[0],y:d[1]%_[1],width:_[0],height:_[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${T[0]},-${T[1]})`},b?Z.createElement(q2t,{color:h,radius:w/s}):Z.createElement(W2t,{dimensions:C,color:h,lineWidth:i})),Z.createElement("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${f+e})`}))}GNe.displayName="Background";var X2t=x.memo(GNe),n6,Vue;function jZ(){if(Vue)return n6;Vue=1;var e="\0",t="\0",n="";class r{_isDirected=!0;_isMultigraph=!1;_isCompound=!1;_label;_defaultNodeLabelFn=()=>{};_defaultEdgeLabelFn=()=>{};_nodes={};_in={};_preds={};_out={};_sucs={};_edgeObjs={};_edgeLabels={};_nodeCount=0;_edgeCount=0;_parent;_children;constructor(d){d&&(this._isDirected=Object.hasOwn(d,"directed")?d.directed:!0,this._isMultigraph=Object.hasOwn(d,"multigraph")?d.multigraph:!1,this._isCompound=Object.hasOwn(d,"compound")?d.compound:!1),this._isCompound&&(this._parent={},this._children={},this._children[t]={})}isDirected(){return this._isDirected}isMultigraph(){return this._isMultigraph}isCompound(){return this._isCompound}setGraph(d){return this._label=d,this}graph(){return this._label}setDefaultNodeLabel(d){return this._defaultNodeLabelFn=d,typeof d!="function"&&(this._defaultNodeLabelFn=()=>d),this}nodeCount(){return this._nodeCount}nodes(){return Object.keys(this._nodes)}sources(){var d=this;return this.nodes().filter(f=>Object.keys(d._in[f]).length===0)}sinks(){var d=this;return this.nodes().filter(f=>Object.keys(d._out[f]).length===0)}setNodes(d,f){var h=arguments,m=this;return d.forEach(function(b){h.length>1?m.setNode(b,f):m.setNode(b)}),this}setNode(d,f){return Object.hasOwn(this._nodes,d)?(arguments.length>1&&(this._nodes[d]=f),this):(this._nodes[d]=arguments.length>1?f:this._defaultNodeLabelFn(d),this._isCompound&&(this._parent[d]=t,this._children[d]={},this._children[t][d]=!0),this._in[d]={},this._preds[d]={},this._out[d]={},this._sucs[d]={},++this._nodeCount,this)}node(d){return this._nodes[d]}hasNode(d){return Object.hasOwn(this._nodes,d)}removeNode(d){var f=this;if(Object.hasOwn(this._nodes,d)){var h=m=>f.removeEdge(f._edgeObjs[m]);delete this._nodes[d],this._isCompound&&(this._removeFromParentsChildList(d),delete this._parent[d],this.children(d).forEach(function(m){f.setParent(m)}),delete this._children[d]),Object.keys(this._in[d]).forEach(h),delete this._in[d],delete this._preds[d],Object.keys(this._out[d]).forEach(h),delete this._out[d],delete this._sucs[d],--this._nodeCount}return this}setParent(d,f){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(f===void 0)f=t;else{f+="";for(var h=f;h!==void 0;h=this.parent(h))if(h===d)throw new Error("Setting "+f+" as parent of "+d+" would create a cycle");this.setNode(f)}return this.setNode(d),this._removeFromParentsChildList(d),this._parent[d]=f,this._children[f][d]=!0,this}_removeFromParentsChildList(d){delete this._children[this._parent[d]][d]}parent(d){if(this._isCompound){var f=this._parent[d];if(f!==t)return f}}children(d=t){if(this._isCompound){var f=this._children[d];if(f)return Object.keys(f)}else{if(d===t)return this.nodes();if(this.hasNode(d))return[]}}predecessors(d){var f=this._preds[d];if(f)return Object.keys(f)}successors(d){var f=this._sucs[d];if(f)return Object.keys(f)}neighbors(d){var f=this.predecessors(d);if(f){const m=new Set(f);for(var h of this.successors(d))m.add(h);return Array.from(m.values())}}isLeaf(d){var f;return this.isDirected()?f=this.successors(d):f=this.neighbors(d),f.length===0}filterNodes(d){var f=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});f.setGraph(this.graph());var h=this;Object.entries(this._nodes).forEach(function([y,v]){d(y)&&f.setNode(y,v)}),Object.values(this._edgeObjs).forEach(function(y){f.hasNode(y.v)&&f.hasNode(y.w)&&f.setEdge(y,h.edge(y))});var m={};function b(y){var v=h.parent(y);return v===void 0||f.hasNode(v)?(m[y]=v,v):v in m?m[v]:b(v)}return this._isCompound&&f.nodes().forEach(y=>f.setParent(y,b(y))),f}setDefaultEdgeLabel(d){return this._defaultEdgeLabelFn=d,typeof d!="function"&&(this._defaultEdgeLabelFn=()=>d),this}edgeCount(){return this._edgeCount}edges(){return Object.values(this._edgeObjs)}setPath(d,f){var h=this,m=arguments;return d.reduce(function(b,y){return m.length>1?h.setEdge(b,y,f):h.setEdge(b,y),y}),this}setEdge(){var d,f,h,m,b=!1,y=arguments[0];typeof y=="object"&&y!==null&&"v"in y?(d=y.v,f=y.w,h=y.name,arguments.length===2&&(m=arguments[1],b=!0)):(d=y,f=arguments[1],h=arguments[3],arguments.length>2&&(m=arguments[2],b=!0)),d=""+d,f=""+f,h!==void 0&&(h=""+h);var v=a(this._isDirected,d,f,h);if(Object.hasOwn(this._edgeLabels,v))return b&&(this._edgeLabels[v]=m),this;if(h!==void 0&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(d),this.setNode(f),this._edgeLabels[v]=b?m:this._defaultEdgeLabelFn(d,f,h);var _=o(this._isDirected,d,f,h);return d=_.v,f=_.w,Object.freeze(_),this._edgeObjs[v]=_,i(this._preds[f],d),i(this._sucs[d],f),this._in[f][v]=_,this._out[d][v]=_,this._edgeCount++,this}edge(d,f,h){var m=arguments.length===1?l(this._isDirected,arguments[0]):a(this._isDirected,d,f,h);return this._edgeLabels[m]}edgeAsObj(){const d=this.edge(...arguments);return typeof d!="object"?{label:d}:d}hasEdge(d,f,h){var m=arguments.length===1?l(this._isDirected,arguments[0]):a(this._isDirected,d,f,h);return Object.hasOwn(this._edgeLabels,m)}removeEdge(d,f,h){var m=arguments.length===1?l(this._isDirected,arguments[0]):a(this._isDirected,d,f,h),b=this._edgeObjs[m];return b&&(d=b.v,f=b.w,delete this._edgeLabels[m],delete this._edgeObjs[m],s(this._preds[f],d),s(this._sucs[d],f),delete this._in[f][m],delete this._out[d][m],this._edgeCount--),this}inEdges(d,f){var h=this._in[d];if(h){var m=Object.values(h);return f?m.filter(b=>b.v===f):m}}outEdges(d,f){var h=this._out[d];if(h){var m=Object.values(h);return f?m.filter(b=>b.w===f):m}}nodeEdges(d,f){var h=this.inEdges(d,f);if(h)return h.concat(this.outEdges(d,f))}}function i(u,d){u[d]?u[d]++:u[d]=1}function s(u,d){--u[d]||delete u[d]}function a(u,d,f,h){var m=""+d,b=""+f;if(!u&&m>b){var y=m;m=b,b=y}return m+n+b+n+(h===void 0?e:h)}function o(u,d,f,h){var m=""+d,b=""+f;if(!u&&m>b){var y=m;m=b,b=y}var v={v:m,w:b};return h&&(v.name=h),v}function l(u,d){return a(u,d.v,d.w,d.name)}return n6=r,n6}var r6,Wue;function Z2t(){return Wue||(Wue=1,r6="2.2.4"),r6}var i6,que;function Q2t(){return que||(que=1,i6={Graph:jZ(),version:Z2t()}),i6}var s6,Gue;function J2t(){if(Gue)return s6;Gue=1;var e=jZ();s6={write:t,read:i};function t(s){var a={options:{directed:s.isDirected(),multigraph:s.isMultigraph(),compound:s.isCompound()},nodes:n(s),edges:r(s)};return s.graph()!==void 0&&(a.value=structuredClone(s.graph())),a}function n(s){return s.nodes().map(function(a){var o=s.node(a),l=s.parent(a),u={v:a};return o!==void 0&&(u.value=o),l!==void 0&&(u.parent=l),u})}function r(s){return s.edges().map(function(a){var o=s.edge(a),l={v:a.v,w:a.w};return a.name!==void 0&&(l.name=a.name),o!==void 0&&(l.value=o),l})}function i(s){var a=new e(s.options).setGraph(s.value);return s.nodes.forEach(function(o){a.setNode(o.v,o.value),o.parent&&a.setParent(o.v,o.parent)}),s.edges.forEach(function(o){a.setEdge({v:o.v,w:o.w,name:o.name},o.value)}),a}return s6}var a6,Kue;function ekt(){if(Kue)return a6;Kue=1,a6=e;function e(t){var n={},r=[],i;function s(a){Object.hasOwn(n,a)||(n[a]=!0,i.push(a),t.successors(a).forEach(s),t.predecessors(a).forEach(s))}return t.nodes().forEach(function(a){i=[],s(a),i.length&&r.push(i)}),r}return a6}var o6,Yue;function KNe(){if(Yue)return o6;Yue=1;class e{_arr=[];_keyIndices={};size(){return this._arr.length}keys(){return this._arr.map(function(n){return n.key})}has(n){return Object.hasOwn(this._keyIndices,n)}priority(n){var r=this._keyIndices[n];if(r!==void 0)return this._arr[r].priority}min(){if(this.size()===0)throw new Error("Queue underflow");return this._arr[0].key}add(n,r){var i=this._keyIndices;if(n=String(n),!Object.hasOwn(i,n)){var s=this._arr,a=s.length;return i[n]=a,s.push({key:n,priority:r}),this._decrease(a),!0}return!1}removeMin(){this._swap(0,this._arr.length-1);var n=this._arr.pop();return delete this._keyIndices[n.key],this._heapify(0),n.key}decrease(n,r){var i=this._keyIndices[n];if(r>this._arr[i].priority)throw new Error("New priority is greater than current priority. Key: "+n+" Old: "+this._arr[i].priority+" New: "+r);this._arr[i].priority=r,this._decrease(i)}_heapify(n){var r=this._arr,i=2*n,s=i+1,a=n;i<r.length&&(a=r[i].priority<r[a].priority?i:a,s<r.length&&(a=r[s].priority<r[a].priority?s:a),a!==n&&(this._swap(n,a),this._heapify(a)))}_decrease(n){for(var r=this._arr,i=r[n].priority,s;n!==0&&(s=n>>1,!(r[s].priority<i));)this._swap(n,s),n=s}_swap(n,r){var i=this._arr,s=this._keyIndices,a=i[n],o=i[r];i[n]=o,i[r]=a,s[o.key]=n,s[a.key]=r}}return o6=e,o6}var l6,Xue;function YNe(){if(Xue)return l6;Xue=1;var e=KNe();l6=n;var t=()=>1;function n(i,s,a,o){return r(i,String(s),a||t,o||function(l){return i.outEdges(l)})}function r(i,s,a,o){var l={},u=new e,d,f,h=function(m){var b=m.v!==d?m.v:m.w,y=l[b],v=a(m),_=f.distance+v;if(v<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+m+" Weight: "+v);_<y.distance&&(y.distance=_,y.predecessor=d,u.decrease(b,_))};for(i.nodes().forEach(function(m){var b=m===s?0:Number.POSITIVE_INFINITY;l[m]={distance:b},u.add(m,b)});u.size()>0&&(d=u.removeMin(),f=l[d],f.distance!==Number.POSITIVE_INFINITY);)o(d).forEach(h);return l}return l6}var u6,Zue;function tkt(){if(Zue)return u6;Zue=1;var e=YNe();u6=t;function t(n,r,i){return n.nodes().reduce(function(s,a){return s[a]=e(n,a,r,i),s},{})}return u6}var c6,Que;function XNe(){if(Que)return c6;Que=1,c6=e;function e(t){var n=0,r=[],i={},s=[];function a(o){var l=i[o]={onStack:!0,lowlink:n,index:n++};if(r.push(o),t.successors(o).forEach(function(f){Object.hasOwn(i,f)?i[f].onStack&&(l.lowlink=Math.min(l.lowlink,i[f].index)):(a(f),l.lowlink=Math.min(l.lowlink,i[f].lowlink))}),l.lowlink===l.index){var u=[],d;do d=r.pop(),i[d].onStack=!1,u.push(d);while(o!==d);s.push(u)}}return t.nodes().forEach(function(o){Object.hasOwn(i,o)||a(o)}),s}return c6}var d6,Jue;function nkt(){if(Jue)return d6;Jue=1;var e=XNe();d6=t;function t(n){return e(n).filter(function(r){return r.length>1||r.length===1&&n.hasEdge(r[0],r[0])})}return d6}var f6,ece;function rkt(){if(ece)return f6;ece=1,f6=t;var e=()=>1;function t(r,i,s){return n(r,i||e,s||function(a){return r.outEdges(a)})}function n(r,i,s){var a={},o=r.nodes();return o.forEach(function(l){a[l]={},a[l][l]={distance:0},o.forEach(function(u){l!==u&&(a[l][u]={distance:Number.POSITIVE_INFINITY})}),s(l).forEach(function(u){var d=u.v===l?u.w:u.v,f=i(u);a[l][d]={distance:f,predecessor:l}})}),o.forEach(function(l){var u=a[l];o.forEach(function(d){var f=a[d];o.forEach(function(h){var m=f[l],b=u[h],y=f[h],v=m.distance+b.distance;v<y.distance&&(y.distance=v,y.predecessor=b.predecessor)})})}),a}return f6}var h6,tce;function ZNe(){if(tce)return h6;tce=1;function e(n){var r={},i={},s=[];function a(o){if(Object.hasOwn(i,o))throw new t;Object.hasOwn(r,o)||(i[o]=!0,r[o]=!0,n.predecessors(o).forEach(a),delete i[o],s.push(o))}if(n.sinks().forEach(a),Object.keys(r).length!==n.nodeCount())throw new t;return s}class t extends Error{constructor(){super(...arguments)}}return h6=e,e.CycleException=t,h6}var p6,nce;function ikt(){if(nce)return p6;nce=1;var e=ZNe();p6=t;function t(n){try{e(n)}catch(r){if(r instanceof e.CycleException)return!1;throw r}return!0}return p6}var m6,rce;function QNe(){if(rce)return m6;rce=1,m6=e;function e(i,s,a){Array.isArray(s)||(s=[s]);var o=i.isDirected()?f=>i.successors(f):f=>i.neighbors(f),l=a==="post"?t:n,u=[],d={};return s.forEach(f=>{if(!i.hasNode(f))throw new Error("Graph does not have node: "+f);l(f,o,d,u)}),u}function t(i,s,a,o){for(var l=[[i,!1]];l.length>0;){var u=l.pop();u[1]?o.push(u[0]):Object.hasOwn(a,u[0])||(a[u[0]]=!0,l.push([u[0],!0]),r(s(u[0]),d=>l.push([d,!1])))}}function n(i,s,a,o){for(var l=[i];l.length>0;){var u=l.pop();Object.hasOwn(a,u)||(a[u]=!0,o.push(u),r(s(u),d=>l.push(d)))}}function r(i,s){for(var a=i.length;a--;)s(i[a],a,i);return i}return m6}var g6,ice;function skt(){if(ice)return g6;ice=1;var e=QNe();g6=t;function t(n,r){return e(n,r,"post")}return g6}var b6,sce;function akt(){if(sce)return b6;sce=1;var e=QNe();b6=t;function t(n,r){return e(n,r,"pre")}return b6}var y6,ace;function okt(){if(ace)return y6;ace=1;var e=jZ(),t=KNe();y6=n;function n(r,i){var s=new e,a={},o=new t,l;function u(f){var h=f.v===l?f.w:f.v,m=o.priority(h);if(m!==void 0){var b=i(f);b<m&&(a[h]=l,o.decrease(h,b))}}if(r.nodeCount()===0)return s;r.nodes().forEach(function(f){o.add(f,Number.POSITIVE_INFINITY),s.setNode(f)}),o.decrease(r.nodes()[0],0);for(var d=!1;o.size()>0;){if(l=o.removeMin(),Object.hasOwn(a,l))s.setEdge(l,a[l]);else{if(d)throw new Error("Input graph is not connected: "+r);d=!0}r.nodeEdges(l).forEach(u)}return s}return y6}var v6,oce;function lkt(){return oce||(oce=1,v6={components:ekt(),dijkstra:YNe(),dijkstraAll:tkt(),findCycles:nkt(),floydWarshall:rkt(),isAcyclic:ikt(),postorder:skt(),preorder:akt(),prim:okt(),tarjan:XNe(),topsort:ZNe()}),v6}var x6,lce;function hd(){if(lce)return x6;lce=1;var e=Q2t();return x6={Graph:e.Graph,json:J2t(),alg:lkt(),version:e.version},x6}var _6,uce;function ukt(){if(uce)return _6;uce=1;class e{constructor(){let i={};i._next=i._prev=i,this._sentinel=i}dequeue(){let i=this._sentinel,s=i._prev;if(s!==i)return t(s),s}enqueue(i){let s=this._sentinel;i._prev&&i._next&&t(i),i._next=s._next,s._next._prev=i,s._next=i,i._prev=s}toString(){let i=[],s=this._sentinel,a=s._prev;for(;a!==s;)i.push(JSON.stringify(a,n)),a=a._prev;return"["+i.join(", ")+"]"}}function t(r){r._prev._next=r._next,r._next._prev=r._prev,delete r._next,delete r._prev}function n(r,i){if(r!=="_next"&&r!=="_prev")return i}return _6=e,_6}var S6,cce;function ckt(){if(cce)return S6;cce=1;let e=hd().Graph,t=ukt();S6=r;let n=()=>1;function r(u,d){if(u.nodeCount()<=1)return[];let f=a(u,d||n);return i(f.graph,f.buckets,f.zeroIdx).flatMap(m=>u.outEdges(m.v,m.w))}function i(u,d,f){let h=[],m=d[d.length-1],b=d[0],y;for(;u.nodeCount();){for(;y=b.dequeue();)s(u,d,f,y);for(;y=m.dequeue();)s(u,d,f,y);if(u.nodeCount()){for(let v=d.length-2;v>0;--v)if(y=d[v].dequeue(),y){h=h.concat(s(u,d,f,y,!0));break}}}return h}function s(u,d,f,h,m){let b=m?[]:void 0;return u.inEdges(h.v).forEach(y=>{let v=u.edge(y),_=u.node(y.v);m&&b.push({v:y.v,w:y.w}),_.out-=v,o(d,f,_)}),u.outEdges(h.v).forEach(y=>{let v=u.edge(y),_=y.w,w=u.node(_);w.in-=v,o(d,f,w)}),u.removeNode(h.v),b}function a(u,d){let f=new e,h=0,m=0;u.nodes().forEach(v=>{f.setNode(v,{v,in:0,out:0})}),u.edges().forEach(v=>{let _=f.edge(v.v,v.w)||0,w=d(v),C=_+w;f.setEdge(v.v,v.w,C),m=Math.max(m,f.node(v.v).out+=w),h=Math.max(h,f.node(v.w).in+=w)});let b=l(m+h+3).map(()=>new t),y=h+1;return f.nodes().forEach(v=>{o(b,y,f.node(v))}),{graph:f,buckets:b,zeroIdx:y}}function o(u,d,f){f.out?f.in?u[f.out-f.in+d].enqueue(f):u[u.length-1].enqueue(f):u[0].enqueue(f)}function l(u){const d=[];for(let f=0;f<u;f++)d.push(f);return d}return S6}var w6,dce;function Ys(){if(dce)return w6;dce=1;let e=hd().Graph;w6={addBorderNode:d,addDummyNode:t,applyWithChunking:m,asNonCompoundGraph:r,buildLayerMatrix:o,intersectRect:a,mapValues:S,maxRank:b,normalizeRanks:l,notime:_,partition:y,pick:k,predecessorWeights:s,range:T,removeEmptyRanks:u,simplify:n,successorWeights:i,time:v,uniqueId:C,zipObject:A};function t(R,I,D,P){for(var j=P;R.hasNode(j);)j=C(P);return D.dummy=I,R.setNode(j,D),j}function n(R){let I=new e().setGraph(R.graph());return R.nodes().forEach(D=>I.setNode(D,R.node(D))),R.edges().forEach(D=>{let P=I.edge(D.v,D.w)||{weight:0,minlen:1},j=R.edge(D);I.setEdge(D.v,D.w,{weight:P.weight+j.weight,minlen:Math.max(P.minlen,j.minlen)})}),I}function r(R){let I=new e({multigraph:R.isMultigraph()}).setGraph(R.graph());return R.nodes().forEach(D=>{R.children(D).length||I.setNode(D,R.node(D))}),R.edges().forEach(D=>{I.setEdge(D,R.edge(D))}),I}function i(R){let I=R.nodes().map(D=>{let P={};return R.outEdges(D).forEach(j=>{P[j.w]=(P[j.w]||0)+R.edge(j).weight}),P});return A(R.nodes(),I)}function s(R){let I=R.nodes().map(D=>{let P={};return R.inEdges(D).forEach(j=>{P[j.v]=(P[j.v]||0)+R.edge(j).weight}),P});return A(R.nodes(),I)}function a(R,I){let D=R.x,P=R.y,j=I.x-D,B=I.y-P,L=R.width/2,M=R.height/2;if(!j&&!B)throw new Error("Not possible to find intersection inside of the rectangle");let $,U;return Math.abs(B)*L>Math.abs(j)*M?(B<0&&(M=-M),$=M*j/B,U=M):(j<0&&(L=-L),$=L,U=L*B/j),{x:D+$,y:P+U}}function o(R){let I=T(b(R)+1).map(()=>[]);return R.nodes().forEach(D=>{let P=R.node(D),j=P.rank;j!==void 0&&(I[j][P.order]=D)}),I}function l(R){let I=R.nodes().map(P=>{let j=R.node(P).rank;return j===void 0?Number.MAX_VALUE:j}),D=m(Math.min,I);R.nodes().forEach(P=>{let j=R.node(P);Object.hasOwn(j,"rank")&&(j.rank-=D)})}function u(R){let I=R.nodes().map(L=>R.node(L).rank),D=m(Math.min,I),P=[];R.nodes().forEach(L=>{let M=R.node(L).rank-D;P[M]||(P[M]=[]),P[M].push(L)});let j=0,B=R.graph().nodeRankFactor;Array.from(P).forEach((L,M)=>{L===void 0&&M%B!==0?--j:L!==void 0&&j&&L.forEach($=>R.node($).rank+=j)})}function d(R,I,D,P){let j={width:0,height:0};return arguments.length>=4&&(j.rank=D,j.order=P),t(R,"border",j,I)}function f(R,I=h){const D=[];for(let P=0;P<R.length;P+=I){const j=R.slice(P,P+I);D.push(j)}return D}const h=65535;function m(R,I){if(I.length>h){const D=f(I);return R.apply(null,D.map(P=>R.apply(null,P)))}else return R.apply(null,I)}function b(R){const D=R.nodes().map(P=>{let j=R.node(P).rank;return j===void 0?Number.MIN_VALUE:j});return m(Math.max,D)}function y(R,I){let D={lhs:[],rhs:[]};return R.forEach(P=>{I(P)?D.lhs.push(P):D.rhs.push(P)}),D}function v(R,I){let D=Date.now();try{return I()}finally{console.log(R+" time: "+(Date.now()-D)+"ms")}}function _(R,I){return I()}let w=0;function C(R){var I=++w;return R+(""+I)}function T(R,I,D=1){I==null&&(I=R,R=0);let P=B=>B<I;D<0&&(P=B=>I<B);const j=[];for(let B=R;P(B);B+=D)j.push(B);return j}function k(R,I){const D={};for(const P of I)R[P]!==void 0&&(D[P]=R[P]);return D}function S(R,I){let D=I;return typeof I=="string"&&(D=P=>P[I]),Object.entries(R).reduce((P,[j,B])=>(P[j]=D(B,j),P),{})}function A(R,I){return R.reduce((D,P,j)=>(D[P]=I[j],D),{})}return w6}var E6,fce;function dkt(){if(fce)return E6;fce=1;let e=ckt(),t=Ys().uniqueId;E6={run:n,undo:i};function n(s){(s.graph().acyclicer==="greedy"?e(s,o(s)):r(s)).forEach(l=>{let u=s.edge(l);s.removeEdge(l),u.forwardName=l.name,u.reversed=!0,s.setEdge(l.w,l.v,u,t("rev"))});function o(l){return u=>l.edge(u).weight}}function r(s){let a=[],o={},l={};function u(d){Object.hasOwn(l,d)||(l[d]=!0,o[d]=!0,s.outEdges(d).forEach(f=>{Object.hasOwn(o,f.w)?a.push(f):u(f.w)}),delete o[d])}return s.nodes().forEach(u),a}function i(s){s.edges().forEach(a=>{let o=s.edge(a);if(o.reversed){s.removeEdge(a);let l=o.forwardName;delete o.reversed,delete o.forwardName,s.setEdge(a.w,a.v,o,l)}})}return E6}var C6,hce;function fkt(){if(hce)return C6;hce=1;let e=Ys();C6={run:t,undo:r};function t(i){i.graph().dummyChains=[],i.edges().forEach(s=>n(i,s))}function n(i,s){let a=s.v,o=i.node(a).rank,l=s.w,u=i.node(l).rank,d=s.name,f=i.edge(s),h=f.labelRank;if(u===o+1)return;i.removeEdge(s);let m,b,y;for(y=0,++o;o<u;++y,++o)f.points=[],b={width:0,height:0,edgeLabel:f,edgeObj:s,rank:o},m=e.addDummyNode(i,"edge",b,"_d"),o===h&&(b.width=f.width,b.height=f.height,b.dummy="edge-label",b.labelpos=f.labelpos),i.setEdge(a,m,{weight:f.weight},d),y===0&&i.graph().dummyChains.push(m),a=m;i.setEdge(a,l,{weight:f.weight},d)}function r(i){i.graph().dummyChains.forEach(s=>{let a=i.node(s),o=a.edgeLabel,l;for(i.setEdge(a.edgeObj,o);a.dummy;)l=i.successors(s)[0],i.removeNode(s),o.points.push({x:a.x,y:a.y}),a.dummy==="edge-label"&&(o.x=a.x,o.y=a.y,o.width=a.width,o.height=a.height),s=l,a=i.node(s)})}return C6}var k6,pce;function xR(){if(pce)return k6;pce=1;const{applyWithChunking:e}=Ys();k6={longestPath:t,slack:n};function t(r){var i={};function s(a){var o=r.node(a);if(Object.hasOwn(i,a))return o.rank;i[a]=!0;let l=r.outEdges(a).map(d=>d==null?Number.POSITIVE_INFINITY:s(d.w)-r.edge(d).minlen);var u=e(Math.min,l);return u===Number.POSITIVE_INFINITY&&(u=0),o.rank=u}r.sources().forEach(s)}function n(r,i){return r.node(i.w).rank-r.node(i.v).rank-r.edge(i).minlen}return k6}var T6,mce;function JNe(){if(mce)return T6;mce=1;var e=hd().Graph,t=xR().slack;T6=n;function n(a){var o=new e({directed:!1}),l=a.nodes()[0],u=a.nodeCount();o.setNode(l,{});for(var d,f;r(o,a)<u;)d=i(o,a),f=o.hasNode(d.v)?t(a,d):-t(a,d),s(o,a,f);return o}function r(a,o){function l(u){o.nodeEdges(u).forEach(d=>{var f=d.v,h=u===f?d.w:f;!a.hasNode(h)&&!t(o,d)&&(a.setNode(h,{}),a.setEdge(u,h,{}),l(h))})}return a.nodes().forEach(l),a.nodeCount()}function i(a,o){return o.edges().reduce((u,d)=>{let f=Number.POSITIVE_INFINITY;return a.hasNode(d.v)!==a.hasNode(d.w)&&(f=t(o,d)),f<u[0]?[f,d]:u},[Number.POSITIVE_INFINITY,null])[1]}function s(a,o,l){a.nodes().forEach(u=>o.node(u).rank+=l)}return T6}var A6,gce;function hkt(){if(gce)return A6;gce=1;var e=JNe(),t=xR().slack,n=xR().longestPath,r=hd().alg.preorder,i=hd().alg.postorder,s=Ys().simplify;A6=a,a.initLowLimValues=d,a.initCutValues=o,a.calcCutValue=u,a.leaveEdge=h,a.enterEdge=m,a.exchangeEdges=b;function a(w){w=s(w),n(w);var C=e(w);d(C),o(C,w);for(var T,k;T=h(C);)k=m(C,w,T),b(C,w,T,k)}function o(w,C){var T=i(w,w.nodes());T=T.slice(0,T.length-1),T.forEach(k=>l(w,C,k))}function l(w,C,T){var k=w.node(T),S=k.parent;w.edge(T,S).cutvalue=u(w,C,T)}function u(w,C,T){var k=w.node(T),S=k.parent,A=!0,R=C.edge(T,S),I=0;return R||(A=!1,R=C.edge(S,T)),I=R.weight,C.nodeEdges(T).forEach(D=>{var P=D.v===T,j=P?D.w:D.v;if(j!==S){var B=P===A,L=C.edge(D).weight;if(I+=B?L:-L,v(w,T,j)){var M=w.edge(T,j).cutvalue;I+=B?-M:M}}}),I}function d(w,C){arguments.length<2&&(C=w.nodes()[0]),f(w,{},1,C)}function f(w,C,T,k,S){var A=T,R=w.node(k);return C[k]=!0,w.neighbors(k).forEach(I=>{Object.hasOwn(C,I)||(T=f(w,C,T,I,k))}),R.low=A,R.lim=T++,S?R.parent=S:delete R.parent,T}function h(w){return w.edges().find(C=>w.edge(C).cutvalue<0)}function m(w,C,T){var k=T.v,S=T.w;C.hasEdge(k,S)||(k=T.w,S=T.v);var A=w.node(k),R=w.node(S),I=A,D=!1;A.lim>R.lim&&(I=R,D=!0);var P=C.edges().filter(j=>D===_(w,w.node(j.v),I)&&D!==_(w,w.node(j.w),I));return P.reduce((j,B)=>t(C,B)<t(C,j)?B:j)}function b(w,C,T,k){var S=T.v,A=T.w;w.removeEdge(S,A),w.setEdge(k.v,k.w,{}),d(w),o(w,C),y(w,C)}function y(w,C){var T=w.nodes().find(S=>!C.node(S).parent),k=r(w,T);k=k.slice(1),k.forEach(S=>{var A=w.node(S).parent,R=C.edge(S,A),I=!1;R||(R=C.edge(A,S),I=!0),C.node(S).rank=C.node(A).rank+(I?R.minlen:-R.minlen)})}function v(w,C,T){return w.hasEdge(C,T)}function _(w,C,T){return T.low<=C.lim&&C.lim<=T.lim}return A6}var N6,bce;function pkt(){if(bce)return N6;bce=1;var e=xR(),t=e.longestPath,n=JNe(),r=hkt();N6=i;function i(l){var u=l.graph().ranker;if(u instanceof Function)return u(l);switch(l.graph().ranker){case"network-simplex":o(l);break;case"tight-tree":a(l);break;case"longest-path":s(l);break;case"none":break;default:o(l)}}var s=t;function a(l){t(l),n(l)}function o(l){r(l)}return N6}var O6,yce;function mkt(){if(yce)return O6;yce=1,O6=e;function e(r){let i=n(r);r.graph().dummyChains.forEach(s=>{let a=r.node(s),o=a.edgeObj,l=t(r,i,o.v,o.w),u=l.path,d=l.lca,f=0,h=u[f],m=!0;for(;s!==o.w;){if(a=r.node(s),m){for(;(h=u[f])!==d&&r.node(h).maxRank<a.rank;)f++;h===d&&(m=!1)}if(!m){for(;f<u.length-1&&r.node(h=u[f+1]).minRank<=a.rank;)f++;h=u[f]}r.setParent(s,h),s=r.successors(s)[0]}})}function t(r,i,s,a){let o=[],l=[],u=Math.min(i[s].low,i[a].low),d=Math.max(i[s].lim,i[a].lim),f,h;f=s;do f=r.parent(f),o.push(f);while(f&&(i[f].low>u||d>i[f].lim));for(h=f,f=a;(f=r.parent(f))!==h;)l.push(f);return{path:o.concat(l.reverse()),lca:h}}function n(r){let i={},s=0;function a(o){let l=s;r.children(o).forEach(a),i[o]={low:l,lim:s++}}return r.children().forEach(a),i}return O6}var R6,vce;function gkt(){if(vce)return R6;vce=1;let e=Ys();R6={run:t,cleanup:s};function t(a){let o=e.addDummyNode(a,"root",{},"_root"),l=r(a),u=Object.values(l),d=e.applyWithChunking(Math.max,u)-1,f=2*d+1;a.graph().nestingRoot=o,a.edges().forEach(m=>a.edge(m).minlen*=f);let h=i(a)+1;a.children().forEach(m=>n(a,o,f,h,d,l,m)),a.graph().nodeRankFactor=f}function n(a,o,l,u,d,f,h){let m=a.children(h);if(!m.length){h!==o&&a.setEdge(o,h,{weight:0,minlen:l});return}let b=e.addBorderNode(a,"_bt"),y=e.addBorderNode(a,"_bb"),v=a.node(h);a.setParent(b,h),v.borderTop=b,a.setParent(y,h),v.borderBottom=y,m.forEach(_=>{n(a,o,l,u,d,f,_);let w=a.node(_),C=w.borderTop?w.borderTop:_,T=w.borderBottom?w.borderBottom:_,k=w.borderTop?u:2*u,S=C!==T?1:d-f[h]+1;a.setEdge(b,C,{weight:k,minlen:S,nestingEdge:!0}),a.setEdge(T,y,{weight:k,minlen:S,nestingEdge:!0})}),a.parent(h)||a.setEdge(o,b,{weight:0,minlen:d+f[h]})}function r(a){var o={};function l(u,d){var f=a.children(u);f&&f.length&&f.forEach(h=>l(h,d+1)),o[u]=d}return a.children().forEach(u=>l(u,1)),o}function i(a){return a.edges().reduce((o,l)=>o+a.edge(l).weight,0)}function s(a){var o=a.graph();a.removeNode(o.nestingRoot),delete o.nestingRoot,a.edges().forEach(l=>{var u=a.edge(l);u.nestingEdge&&a.removeEdge(l)})}return R6}var I6,xce;function bkt(){if(xce)return I6;xce=1;let e=Ys();I6=t;function t(r){function i(s){let a=r.children(s),o=r.node(s);if(a.length&&a.forEach(i),Object.hasOwn(o,"minRank")){o.borderLeft=[],o.borderRight=[];for(let l=o.minRank,u=o.maxRank+1;l<u;++l)n(r,"borderLeft","_bl",s,o,l),n(r,"borderRight","_br",s,o,l)}}r.children().forEach(i)}function n(r,i,s,a,o,l){let u={width:0,height:0,rank:l,borderType:i},d=o[i][l-1],f=e.addDummyNode(r,"border",u,s);o[i][l]=f,r.setParent(f,a),d&&r.setEdge(d,f,{weight:1})}return I6}var D6,_ce;function ykt(){if(_ce)return D6;_ce=1,D6={adjust:e,undo:t};function e(l){let u=l.graph().rankdir.toLowerCase();(u==="lr"||u==="rl")&&n(l)}function t(l){let u=l.graph().rankdir.toLowerCase();(u==="bt"||u==="rl")&&i(l),(u==="lr"||u==="rl")&&(a(l),n(l))}function n(l){l.nodes().forEach(u=>r(l.node(u))),l.edges().forEach(u=>r(l.edge(u)))}function r(l){let u=l.width;l.width=l.height,l.height=u}function i(l){l.nodes().forEach(u=>s(l.node(u))),l.edges().forEach(u=>{let d=l.edge(u);d.points.forEach(s),Object.hasOwn(d,"y")&&s(d)})}function s(l){l.y=-l.y}function a(l){l.nodes().forEach(u=>o(l.node(u))),l.edges().forEach(u=>{let d=l.edge(u);d.points.forEach(o),Object.hasOwn(d,"x")&&o(d)})}function o(l){let u=l.x;l.x=l.y,l.y=u}return D6}var P6,Sce;function vkt(){if(Sce)return P6;Sce=1;let e=Ys();P6=t;function t(n){let r={},i=n.nodes().filter(d=>!n.children(d).length),s=i.map(d=>n.node(d).rank),a=e.applyWithChunking(Math.max,s),o=e.range(a+1).map(()=>[]);function l(d){if(r[d])return;r[d]=!0;let f=n.node(d);o[f.rank].push(d),n.successors(d).forEach(l)}return i.sort((d,f)=>n.node(d).rank-n.node(f).rank).forEach(l),o}return P6}var j6,wce;function xkt(){if(wce)return j6;wce=1;let e=Ys().zipObject;j6=t;function t(r,i){let s=0;for(let a=1;a<i.length;++a)s+=n(r,i[a-1],i[a]);return s}function n(r,i,s){let a=e(s,s.map((h,m)=>m)),o=i.flatMap(h=>r.outEdges(h).map(m=>({pos:a[m.w],weight:r.edge(m).weight})).sort((m,b)=>m.pos-b.pos)),l=1;for(;l<s.length;)l<<=1;let u=2*l-1;l-=1;let d=new Array(u).fill(0),f=0;return o.forEach(h=>{let m=h.pos+l;d[m]+=h.weight;let b=0;for(;m>0;)m%2&&(b+=d[m+1]),m=m-1>>1,d[m]+=h.weight;f+=h.weight*b}),f}return j6}var L6,Ece;function _kt(){if(Ece)return L6;Ece=1,L6=e;function e(t,n=[]){return n.map(r=>{let i=t.inEdges(r);if(i.length){let s=i.reduce((a,o)=>{let l=t.edge(o),u=t.node(o.v);return{sum:a.sum+l.weight*u.order,weight:a.weight+l.weight}},{sum:0,weight:0});return{v:r,barycenter:s.sum/s.weight,weight:s.weight}}else return{v:r}})}return L6}var M6,Cce;function Skt(){if(Cce)return M6;Cce=1;let e=Ys();M6=t;function t(i,s){let a={};i.forEach((l,u)=>{let d=a[l.v]={indegree:0,in:[],out:[],vs:[l.v],i:u};l.barycenter!==void 0&&(d.barycenter=l.barycenter,d.weight=l.weight)}),s.edges().forEach(l=>{let u=a[l.v],d=a[l.w];u!==void 0&&d!==void 0&&(d.indegree++,u.out.push(a[l.w]))});let o=Object.values(a).filter(l=>!l.indegree);return n(o)}function n(i){let s=[];function a(l){return u=>{u.merged||(u.barycenter===void 0||l.barycenter===void 0||u.barycenter>=l.barycenter)&&r(l,u)}}function o(l){return u=>{u.in.push(l),--u.indegree===0&&i.push(u)}}for(;i.length;){let l=i.pop();s.push(l),l.in.reverse().forEach(a(l)),l.out.forEach(o(l))}return s.filter(l=>!l.merged).map(l=>e.pick(l,["vs","i","barycenter","weight"]))}function r(i,s){let a=0,o=0;i.weight&&(a+=i.barycenter*i.weight,o+=i.weight),s.weight&&(a+=s.barycenter*s.weight,o+=s.weight),i.vs=s.vs.concat(i.vs),i.barycenter=a/o,i.weight=o,i.i=Math.min(s.i,i.i),s.merged=!0}return M6}var F6,kce;function wkt(){if(kce)return F6;kce=1;let e=Ys();F6=t;function t(i,s){let a=e.partition(i,b=>Object.hasOwn(b,"barycenter")),o=a.lhs,l=a.rhs.sort((b,y)=>y.i-b.i),u=[],d=0,f=0,h=0;o.sort(r(!!s)),h=n(u,l,h),o.forEach(b=>{h+=b.vs.length,u.push(b.vs),d+=b.barycenter*b.weight,f+=b.weight,h=n(u,l,h)});let m={vs:u.flat(!0)};return f&&(m.barycenter=d/f,m.weight=f),m}function n(i,s,a){let o;for(;s.length&&(o=s[s.length-1]).i<=a;)s.pop(),i.push(o.vs),a++;return a}function r(i){return(s,a)=>s.barycenter<a.barycenter?-1:s.barycenter>a.barycenter?1:i?a.i-s.i:s.i-a.i}return F6}var B6,Tce;function Ekt(){if(Tce)return B6;Tce=1;let e=_kt(),t=Skt(),n=wkt();B6=r;function r(a,o,l,u){let d=a.children(o),f=a.node(o),h=f?f.borderLeft:void 0,m=f?f.borderRight:void 0,b={};h&&(d=d.filter(w=>w!==h&&w!==m));let y=e(a,d);y.forEach(w=>{if(a.children(w.v).length){let C=r(a,w.v,l,u);b[w.v]=C,Object.hasOwn(C,"barycenter")&&s(w,C)}});let v=t(y,l);i(v,b);let _=n(v,u);if(h&&(_.vs=[h,_.vs,m].flat(!0),a.predecessors(h).length)){let w=a.node(a.predecessors(h)[0]),C=a.node(a.predecessors(m)[0]);Object.hasOwn(_,"barycenter")||(_.barycenter=0,_.weight=0),_.barycenter=(_.barycenter*_.weight+w.order+C.order)/(_.weight+2),_.weight+=2}return _}function i(a,o){a.forEach(l=>{l.vs=l.vs.flatMap(u=>o[u]?o[u].vs:u)})}function s(a,o){a.barycenter!==void 0?(a.barycenter=(a.barycenter*a.weight+o.barycenter*o.weight)/(a.weight+o.weight),a.weight+=o.weight):(a.barycenter=o.barycenter,a.weight=o.weight)}return B6}var $6,Ace;function Ckt(){if(Ace)return $6;Ace=1;let e=hd().Graph,t=Ys();$6=n;function n(i,s,a,o){o||(o=i.nodes());let l=r(i),u=new e({compound:!0}).setGraph({root:l}).setDefaultNodeLabel(d=>i.node(d));return o.forEach(d=>{let f=i.node(d),h=i.parent(d);(f.rank===s||f.minRank<=s&&s<=f.maxRank)&&(u.setNode(d),u.setParent(d,h||l),i[a](d).forEach(m=>{let b=m.v===d?m.w:m.v,y=u.edge(b,d),v=y!==void 0?y.weight:0;u.setEdge(b,d,{weight:i.edge(m).weight+v})}),Object.hasOwn(f,"minRank")&&u.setNode(d,{borderLeft:f.borderLeft[s],borderRight:f.borderRight[s]}))}),u}function r(i){for(var s;i.hasNode(s=t.uniqueId("_root")););return s}return $6}var U6,Nce;function kkt(){if(Nce)return U6;Nce=1,U6=e;function e(t,n,r){let i={},s;r.forEach(a=>{let o=t.parent(a),l,u;for(;o;){if(l=t.parent(o),l?(u=i[l],i[l]=o):(u=s,s=o),u&&u!==o){n.setEdge(u,o);return}o=l}})}return U6}var z6,Oce;function Tkt(){if(Oce)return z6;Oce=1;let e=vkt(),t=xkt(),n=Ekt(),r=Ckt(),i=kkt(),s=hd().Graph,a=Ys();z6=o;function o(f,h){if(h&&typeof h.customOrder=="function"){h.customOrder(f,o);return}let m=a.maxRank(f),b=l(f,a.range(1,m+1),"inEdges"),y=l(f,a.range(m-1,-1,-1),"outEdges"),v=e(f);if(d(f,v),h&&h.disableOptimalOrderHeuristic)return;let _=Number.POSITIVE_INFINITY,w;for(let C=0,T=0;T<4;++C,++T){u(C%2?b:y,C%4>=2),v=a.buildLayerMatrix(f);let k=t(f,v);k<_&&(T=0,w=Object.assign({},v),_=k)}d(f,w)}function l(f,h,m){const b=new Map,y=(v,_)=>{b.has(v)||b.set(v,[]),b.get(v).push(_)};for(const v of f.nodes()){const _=f.node(v);if(typeof _.rank=="number"&&y(_.rank,v),typeof _.minRank=="number"&&typeof _.maxRank=="number")for(let w=_.minRank;w<=_.maxRank;w++)w!==_.rank&&y(w,v)}return h.map(function(v){return r(f,v,m,b.get(v)||[])})}function u(f,h){let m=new s;f.forEach(function(b){let y=b.graph().root,v=n(b,y,m,h);v.vs.forEach((_,w)=>b.node(_).order=w),i(b,m,v.vs)})}function d(f,h){Object.values(h).forEach(m=>m.forEach((b,y)=>f.node(b).order=y))}return z6}var H6,Rce;function Akt(){if(Rce)return H6;Rce=1;let e=hd().Graph,t=Ys();H6={positionX:m,findType1Conflicts:n,findType2Conflicts:r,addConflict:s,hasConflict:a,verticalAlignment:o,horizontalCompaction:l,alignCoordinates:f,findSmallestWidthAlignment:d,balance:h};function n(v,_){let w={};function C(T,k){let S=0,A=0,R=T.length,I=k[k.length-1];return k.forEach((D,P)=>{let j=i(v,D),B=j?v.node(j).order:R;(j||D===I)&&(k.slice(A,P+1).forEach(L=>{v.predecessors(L).forEach(M=>{let $=v.node(M),U=$.order;(U<S||B<U)&&!($.dummy&&v.node(L).dummy)&&s(w,M,L)})}),A=P+1,S=B)}),k}return _.length&&_.reduce(C),w}function r(v,_){let w={};function C(k,S,A,R,I){let D;t.range(S,A).forEach(P=>{D=k[P],v.node(D).dummy&&v.predecessors(D).forEach(j=>{let B=v.node(j);B.dummy&&(B.order<R||B.order>I)&&s(w,j,D)})})}function T(k,S){let A=-1,R,I=0;return S.forEach((D,P)=>{if(v.node(D).dummy==="border"){let j=v.predecessors(D);j.length&&(R=v.node(j[0]).order,C(S,I,P,A,R),I=P,A=R)}C(S,I,S.length,R,k.length)}),S}return _.length&&_.reduce(T),w}function i(v,_){if(v.node(_).dummy)return v.predecessors(_).find(w=>v.node(w).dummy)}function s(v,_,w){if(_>w){let T=_;_=w,w=T}let C=v[_];C||(v[_]=C={}),C[w]=!0}function a(v,_,w){if(_>w){let C=_;_=w,w=C}return!!v[_]&&Object.hasOwn(v[_],w)}function o(v,_,w,C){let T={},k={},S={};return _.forEach(A=>{A.forEach((R,I)=>{T[R]=R,k[R]=R,S[R]=I})}),_.forEach(A=>{let R=-1;A.forEach(I=>{let D=C(I);if(D.length){D=D.sort((j,B)=>S[j]-S[B]);let P=(D.length-1)/2;for(let j=Math.floor(P),B=Math.ceil(P);j<=B;++j){let L=D[j];k[I]===I&&R<S[L]&&!a(w,I,L)&&(k[L]=I,k[I]=T[I]=T[L],R=S[L])}}})}),{root:T,align:k}}function l(v,_,w,C,T){let k={},S=u(v,_,w,T),A=T?"borderLeft":"borderRight";function R(P,j){let B=S.nodes(),L=B.pop(),M={};for(;L;)M[L]?P(L):(M[L]=!0,B.push(L),B=B.concat(j(L))),L=B.pop()}function I(P){k[P]=S.inEdges(P).reduce((j,B)=>Math.max(j,k[B.v]+S.edge(B)),0)}function D(P){let j=S.outEdges(P).reduce((L,M)=>Math.min(L,k[M.w]-S.edge(M)),Number.POSITIVE_INFINITY),B=v.node(P);j!==Number.POSITIVE_INFINITY&&B.borderType!==A&&(k[P]=Math.max(k[P],j))}return R(I,S.predecessors.bind(S)),R(D,S.successors.bind(S)),Object.keys(C).forEach(P=>k[P]=k[w[P]]),k}function u(v,_,w,C){let T=new e,k=v.graph(),S=b(k.nodesep,k.edgesep,C);return _.forEach(A=>{let R;A.forEach(I=>{let D=w[I];if(T.setNode(D),R){var P=w[R],j=T.edge(P,D);T.setEdge(P,D,Math.max(S(v,I,R),j||0))}R=I})}),T}function d(v,_){return Object.values(_).reduce((w,C)=>{let T=Number.NEGATIVE_INFINITY,k=Number.POSITIVE_INFINITY;Object.entries(C).forEach(([A,R])=>{let I=y(v,A)/2;T=Math.max(R+I,T),k=Math.min(R-I,k)});const S=T-k;return S<w[0]&&(w=[S,C]),w},[Number.POSITIVE_INFINITY,null])[1]}function f(v,_){let w=Object.values(_),C=t.applyWithChunking(Math.min,w),T=t.applyWithChunking(Math.max,w);["u","d"].forEach(k=>{["l","r"].forEach(S=>{let A=k+S,R=v[A];if(R===_)return;let I=Object.values(R),D=C-t.applyWithChunking(Math.min,I);S!=="l"&&(D=T-t.applyWithChunking(Math.max,I)),D&&(v[A]=t.mapValues(R,P=>P+D))})})}function h(v,_){return t.mapValues(v.ul,(w,C)=>{if(_)return v[_.toLowerCase()][C];{let T=Object.values(v).map(k=>k[C]).sort((k,S)=>k-S);return(T[1]+T[2])/2}})}function m(v){let _=t.buildLayerMatrix(v),w=Object.assign(n(v,_),r(v,_)),C={},T;["u","d"].forEach(S=>{T=S==="u"?_:Object.values(_).reverse(),["l","r"].forEach(A=>{A==="r"&&(T=T.map(P=>Object.values(P).reverse()));let R=(S==="u"?v.predecessors:v.successors).bind(v),I=o(v,T,w,R),D=l(v,T,I.root,I.align,A==="r");A==="r"&&(D=t.mapValues(D,P=>-P)),C[S+A]=D})});let k=d(v,C);return f(C,k),h(C,v.graph().align)}function b(v,_,w){return(C,T,k)=>{let S=C.node(T),A=C.node(k),R=0,I;if(R+=S.width/2,Object.hasOwn(S,"labelpos"))switch(S.labelpos.toLowerCase()){case"l":I=-S.width/2;break;case"r":I=S.width/2;break}if(I&&(R+=w?I:-I),I=0,R+=(S.dummy?_:v)/2,R+=(A.dummy?_:v)/2,R+=A.width/2,Object.hasOwn(A,"labelpos"))switch(A.labelpos.toLowerCase()){case"l":I=A.width/2;break;case"r":I=-A.width/2;break}return I&&(R+=w?I:-I),I=0,R}}function y(v,_){return v.node(_).width}return H6}var V6,Ice;function Nkt(){if(Ice)return V6;Ice=1;let e=Ys(),t=Akt().positionX;V6=n;function n(i){i=e.asNonCompoundGraph(i),r(i),Object.entries(t(i)).forEach(([s,a])=>i.node(s).x=a)}function r(i){let s=e.buildLayerMatrix(i),a=i.graph().ranksep,o=0;s.forEach(l=>{const u=l.reduce((d,f)=>{const h=i.node(f).height;return d>h?d:h},0);l.forEach(d=>i.node(d).y=o+u/2),o+=u+a})}return V6}var W6,Dce;function Okt(){if(Dce)return W6;Dce=1;let e=dkt(),t=fkt(),n=pkt(),r=Ys().normalizeRanks,i=mkt(),s=Ys().removeEmptyRanks,a=gkt(),o=bkt(),l=ykt(),u=Tkt(),d=Nkt(),f=Ys(),h=hd().Graph;W6=m;function m(z,Q){let ee=Q&&Q.debugTiming?f.time:f.notime;ee("layout",()=>{let ne=ee(" buildLayoutGraph",()=>R(z));ee(" runLayout",()=>b(ne,ee,Q)),ee(" updateInputGraph",()=>y(z,ne))})}function b(z,Q,ee){Q(" makeSpaceForEdgeLabels",()=>I(z)),Q(" removeSelfEdges",()=>W(z)),Q(" acyclic",()=>e.run(z)),Q(" nestingGraph.run",()=>a.run(z)),Q(" rank",()=>n(f.asNonCompoundGraph(z))),Q(" injectEdgeLabelProxies",()=>D(z)),Q(" removeEmptyRanks",()=>s(z)),Q(" nestingGraph.cleanup",()=>a.cleanup(z)),Q(" normalizeRanks",()=>r(z)),Q(" assignRankMinMax",()=>P(z)),Q(" removeEdgeLabelProxies",()=>j(z)),Q(" normalize.run",()=>t.run(z)),Q(" parentDummyChains",()=>i(z)),Q(" addBorderSegments",()=>o(z)),Q(" order",()=>u(z,ee)),Q(" insertSelfEdges",()=>Y(z)),Q(" adjustCoordinateSystem",()=>l.adjust(z)),Q(" position",()=>d(z)),Q(" positionSelfEdges",()=>G(z)),Q(" removeBorderNodes",()=>U(z)),Q(" normalize.undo",()=>t.undo(z)),Q(" fixupEdgeLabelCoords",()=>M(z)),Q(" undoCoordinateSystem",()=>l.undo(z)),Q(" translateGraph",()=>B(z)),Q(" assignNodeIntersects",()=>L(z)),Q(" reversePoints",()=>$(z)),Q(" acyclic.undo",()=>e.undo(z))}function y(z,Q){z.nodes().forEach(ee=>{let ne=z.node(ee),ae=Q.node(ee);ne&&(ne.x=ae.x,ne.y=ae.y,ne.rank=ae.rank,Q.children(ee).length&&(ne.width=ae.width,ne.height=ae.height))}),z.edges().forEach(ee=>{let ne=z.edge(ee),ae=Q.edge(ee);ne.points=ae.points,Object.hasOwn(ae,"x")&&(ne.x=ae.x,ne.y=ae.y)}),z.graph().width=Q.graph().width,z.graph().height=Q.graph().height}let v=["nodesep","edgesep","ranksep","marginx","marginy"],_={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},w=["acyclicer","ranker","rankdir","align"],C=["width","height","rank"],T={width:0,height:0},k=["minlen","weight","width","height","labeloffset"],S={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},A=["labelpos"];function R(z){let Q=new h({multigraph:!0,compound:!0}),ee=X(z.graph());return Q.setGraph(Object.assign({},_,q(ee,v),f.pick(ee,w))),z.nodes().forEach(ne=>{let ae=X(z.node(ne));const fe=q(ae,C);Object.keys(T).forEach(re=>{fe[re]===void 0&&(fe[re]=T[re])}),Q.setNode(ne,fe),Q.setParent(ne,z.parent(ne))}),z.edges().forEach(ne=>{let ae=X(z.edge(ne));Q.setEdge(ne,Object.assign({},S,q(ae,k),f.pick(ae,A)))}),Q}function I(z){let Q=z.graph();Q.ranksep/=2,z.edges().forEach(ee=>{let ne=z.edge(ee);ne.minlen*=2,ne.labelpos.toLowerCase()!=="c"&&(Q.rankdir==="TB"||Q.rankdir==="BT"?ne.width+=ne.labeloffset:ne.height+=ne.labeloffset)})}function D(z){z.edges().forEach(Q=>{let ee=z.edge(Q);if(ee.width&&ee.height){let ne=z.node(Q.v),fe={rank:(z.node(Q.w).rank-ne.rank)/2+ne.rank,e:Q};f.addDummyNode(z,"edge-proxy",fe,"_ep")}})}function P(z){let Q=0;z.nodes().forEach(ee=>{let ne=z.node(ee);ne.borderTop&&(ne.minRank=z.node(ne.borderTop).rank,ne.maxRank=z.node(ne.borderBottom).rank,Q=Math.max(Q,ne.maxRank))}),z.graph().maxRank=Q}function j(z){z.nodes().forEach(Q=>{let ee=z.node(Q);ee.dummy==="edge-proxy"&&(z.edge(ee.e).labelRank=ee.rank,z.removeNode(Q))})}function B(z){let Q=Number.POSITIVE_INFINITY,ee=0,ne=Number.POSITIVE_INFINITY,ae=0,fe=z.graph(),re=fe.marginx||0,de=fe.marginy||0;function he(ce){let ye=ce.x,be=ce.y,ue=ce.width,Ae=ce.height;Q=Math.min(Q,ye-ue/2),ee=Math.max(ee,ye+ue/2),ne=Math.min(ne,be-Ae/2),ae=Math.max(ae,be+Ae/2)}z.nodes().forEach(ce=>he(z.node(ce))),z.edges().forEach(ce=>{let ye=z.edge(ce);Object.hasOwn(ye,"x")&&he(ye)}),Q-=re,ne-=de,z.nodes().forEach(ce=>{let ye=z.node(ce);ye.x-=Q,ye.y-=ne}),z.edges().forEach(ce=>{let ye=z.edge(ce);ye.points.forEach(be=>{be.x-=Q,be.y-=ne}),Object.hasOwn(ye,"x")&&(ye.x-=Q),Object.hasOwn(ye,"y")&&(ye.y-=ne)}),fe.width=ee-Q+re,fe.height=ae-ne+de}function L(z){z.edges().forEach(Q=>{let ee=z.edge(Q),ne=z.node(Q.v),ae=z.node(Q.w),fe,re;ee.points?(fe=ee.points[0],re=ee.points[ee.points.length-1]):(ee.points=[],fe=ae,re=ne),ee.points.unshift(f.intersectRect(ne,fe)),ee.points.push(f.intersectRect(ae,re))})}function M(z){z.edges().forEach(Q=>{let ee=z.edge(Q);if(Object.hasOwn(ee,"x"))switch((ee.labelpos==="l"||ee.labelpos==="r")&&(ee.width-=ee.labeloffset),ee.labelpos){case"l":ee.x-=ee.width/2+ee.labeloffset;break;case"r":ee.x+=ee.width/2+ee.labeloffset;break}})}function $(z){z.edges().forEach(Q=>{let ee=z.edge(Q);ee.reversed&&ee.points.reverse()})}function U(z){z.nodes().forEach(Q=>{if(z.children(Q).length){let ee=z.node(Q),ne=z.node(ee.borderTop),ae=z.node(ee.borderBottom),fe=z.node(ee.borderLeft[ee.borderLeft.length-1]),re=z.node(ee.borderRight[ee.borderRight.length-1]);ee.width=Math.abs(re.x-fe.x),ee.height=Math.abs(ae.y-ne.y),ee.x=fe.x+ee.width/2,ee.y=ne.y+ee.height/2}}),z.nodes().forEach(Q=>{z.node(Q).dummy==="border"&&z.removeNode(Q)})}function W(z){z.edges().forEach(Q=>{if(Q.v===Q.w){var ee=z.node(Q.v);ee.selfEdges||(ee.selfEdges=[]),ee.selfEdges.push({e:Q,label:z.edge(Q)}),z.removeEdge(Q)}})}function Y(z){var Q=f.buildLayerMatrix(z);Q.forEach(ee=>{var ne=0;ee.forEach((ae,fe)=>{var re=z.node(ae);re.order=fe+ne,(re.selfEdges||[]).forEach(de=>{f.addDummyNode(z,"selfedge",{width:de.label.width,height:de.label.height,rank:re.rank,order:fe+ ++ne,e:de.e,label:de.label},"_se")}),delete re.selfEdges})})}function G(z){z.nodes().forEach(Q=>{var ee=z.node(Q);if(ee.dummy==="selfedge"){var ne=z.node(ee.e.v),ae=ne.x+ne.width/2,fe=ne.y,re=ee.x-ae,de=ne.height/2;z.setEdge(ee.e,ee.label),z.removeNode(Q),ee.label.points=[{x:ae+2*re/3,y:fe-de},{x:ae+5*re/6,y:fe-de},{x:ae+re,y:fe},{x:ae+5*re/6,y:fe+de},{x:ae+2*re/3,y:fe+de}],ee.label.x=ee.x,ee.label.y=ee.y}})}function q(z,Q){return f.mapValues(f.pick(z,Q),Number)}function X(z){var Q={};return z&&Object.entries(z).forEach(([ee,ne])=>{typeof ee=="string"&&(ee=ee.toLowerCase()),Q[ee]=ne}),Q}return W6}var q6,Pce;function Rkt(){if(Pce)return q6;Pce=1;let e=Ys(),t=hd().Graph;q6={debugOrdering:n};function n(r){let i=e.buildLayerMatrix(r),s=new t({compound:!0,multigraph:!0}).setGraph({});return r.nodes().forEach(a=>{s.setNode(a,{label:a}),s.setParent(a,"layer"+r.node(a).rank)}),r.edges().forEach(a=>s.setEdge(a.v,a.w,{},a.name)),i.forEach((a,o)=>{let l="layer"+o;s.setNode(l,{rank:"same"}),a.reduce((u,d)=>(s.setEdge(u,d,{style:"invis"}),d))}),s}return q6}var G6,jce;function Ikt(){return jce||(jce=1,G6="1.1.8"),G6}var K6,Lce;function Dkt(){return Lce||(Lce=1,K6={graphlib:hd(),layout:Okt(),debug:Rkt(),util:{time:Ys().time,notime:Ys().notime},version:Ikt()}),K6}var Pkt=Dkt();const Mce=Yn(Pkt),eOe={TO_DO:{bg:"#f3f4f6",border:"#6b7280",text:"#374151"},IN_PROGRESS:{bg:"#e5e7eb",border:"#8d909b",text:"#374151"},IN_REVIEW:{bg:"#fef3c7",border:"#e08d3c",text:"#92400e"},DONE:{bg:"#d1fae5",border:"#0d5c63",text:"#065f46"},CANCELED:{bg:"#fee2e2",border:"#dd403a",text:"#991b1b"}};function jkt({data:e}){const{task:t,projectName:n,isBlocked:r,direction:i}=e,s=eOe[t.status],a=ZD(t.dueDate,t.status),o=gAe(t.dueDate,t.status),l=i==="LR"?wn.Left:wn.Top,u=i==="LR"?wn.Right:wn.Bottom;return c.jsxs("div",{className:"rounded-lg shadow-md px-3 py-2 min-w-[180px] max-w-[240px] cursor-pointer transition-shadow hover:shadow-lg",style:{backgroundColor:s.bg,borderWidth:2,borderStyle:"solid",borderColor:a?"#dd403a":s.border,opacity:r?.7:1},children:[c.jsx(Sx,{type:"target",position:l,className:"!bg-gray-400 !w-2 !h-2"}),c.jsxs("div",{className:"flex flex-col gap-1",children:[n&&c.jsx("div",{className:"text-[10px] text-gray-500 font-medium truncate",children:n}),c.jsx("div",{className:"font-medium text-sm leading-tight line-clamp-2",style:{color:s.text},children:t.title}),c.jsxs("div",{className:"flex items-center gap-1 flex-wrap",children:[c.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded-full font-medium",style:{backgroundColor:s.border+"20",color:s.border},children:t.status.replace("_"," ")}),r&&c.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded-full font-medium bg-red-100 text-red-700",children:"BLOCKED"}),a&&c.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded-full font-medium bg-red-100 text-red-700",children:"OVERDUE"})]}),t.tags.length>0&&c.jsxs("div",{className:"flex gap-1 flex-wrap mt-0.5",children:[t.tags.slice(0,3).map(d=>c.jsx("span",{className:"text-[9px] px-1 py-0.5 rounded bg-gray-200 text-gray-600",children:d},d)),t.tags.length>3&&c.jsxs("span",{className:"text-[9px] px-1 py-0.5 rounded bg-gray-200 text-gray-600",children:["+",t.tags.length-3]})]}),t.dueDate&&c.jsxs("div",{className:"text-[10px] mt-0.5",style:{color:a?"#dd403a":o?"#d97706":"#6b7280"},children:["Due: ",new Date(t.dueDate).toLocaleDateString()]})]}),c.jsx(Sx,{type:"source",position:u,className:"!bg-gray-400 !w-2 !h-2"})]})}const Lkt={task:jkt};function Mkt(e,t,n="TB"){const r=new Mce.graphlib.Graph;r.setDefaultEdgeLabel(()=>({}));const i=200,s=80;return r.setGraph({rankdir:n,nodesep:50,ranksep:80,marginx:20,marginy:20}),e.forEach(o=>{r.setNode(o.id,{width:i,height:s})}),t.forEach(o=>{r.setEdge(o.source,o.target)}),Mce.layout(r),{nodes:e.map(o=>{const l=r.node(o.id);return{...o,position:{x:l.x-i/2,y:l.y-s/2}}}),edges:t}}const Fce=768;function Fkt({className:e,projectFilter:t,tagsFilter:n}){const r=ji(),{data:i,isLoading:s}=ASe(),{data:a=[]}=Oc(),{data:o=[]}=_u(),[l,u]=x.useState(null),[d,f]=x.useState(!1),h=x.useMemo(()=>l?a.find(W=>W.id===l)??null:null,[l,a]),m=x.useMemo(()=>new Map(a.map(W=>[W.id,W])),[a]),{projectRepoIds:b,projectRepoPaths:y}=x.useMemo(()=>{const W=new Set,Y=new Set;for(const G of o)for(const q of G.repositories)W.add(q.id),Y.add(q.path);return{projectRepoIds:W,projectRepoPaths:Y}},[o]),{selectedProjectRepoIds:v,selectedProjectRepoPaths:_}=x.useMemo(()=>{if(!t||t==="inbox")return{selectedProjectRepoIds:new Set,selectedProjectRepoPaths:new Set};const W=o.find(Y=>Y.id===t);return W?{selectedProjectRepoIds:new Set(W.repositories.map(Y=>Y.id)),selectedProjectRepoPaths:new Set(W.repositories.map(Y=>Y.path))}:{selectedProjectRepoIds:new Set,selectedProjectRepoPaths:new Set}},[t,o]),[w,C]=x.useState(()=>typeof window<"u"?window.innerWidth<Fce:!1);x.useEffect(()=>{const W=()=>{C(window.innerWidth<Fce)};return window.addEventListener("resize",W),()=>window.removeEventListener("resize",W)},[]);const T=w?"TB":"LR",k=x.useMemo(()=>{if(!i)return new Set;const W=new Set,Y=new Set(["DONE","CANCELED"]);for(const G of i.edges){const q=i.nodes.find(X=>X.id===G.source);q&&!Y.has(q.status)&&W.add(G.target)}return W},[i]),S=x.useMemo(()=>{if(!i)return new Set;const W=new Set,Y=new Set(["DONE","CANCELED"]);for(const G of i.edges){const q=i.nodes.find(X=>X.id===G.source);q&&!Y.has(q.status)&&W.add(G.source)}return W},[i]),A=x.useCallback(W=>{const Y=m.get(W.id);return Y?t==="inbox"?!Y.projectId&&(!Y.repositoryId||!b.has(Y.repositoryId))&&(!Y.repoPath||!y.has(Y.repoPath)):t?Y.projectId===t||!!Y.repositoryId&&v.has(Y.repositoryId)||!!Y.repoPath&&_.has(Y.repoPath):!0:!0},[t,b,y,v,_,m]),R=x.useCallback(W=>!n||n.length===0?!0:W.tags.some(Y=>n.includes(Y)),[n]),{initialNodes:I,initialEdges:D}=x.useMemo(()=>{if(!i)return{initialNodes:[],initialEdges:[]};const W=new Set;for(const ae of i.nodes)A(ae)&&R(ae)&&W.add(ae.id);const Y=new Set;for(const ae of i.edges){const fe=W.has(ae.source),re=W.has(ae.target);(fe||re)&&(Y.add(ae.source),Y.add(ae.target))}if(!(t||n&&n.length>0))for(const ae of i.edges)Y.add(ae.source),Y.add(ae.target);const q=i.nodes.filter(ae=>Y.has(ae.id)),X=i.edges.filter(ae=>Y.has(ae.source)&&Y.has(ae.target)),z=new Map(o.map(ae=>[ae.id,ae.name])),Q=q.map(ae=>({id:ae.id,type:"task",position:{x:0,y:0},data:{task:ae,projectName:ae.projectId?z.get(ae.projectId)??null:null,isBlocked:k.has(ae.id),isBlocking:S.has(ae.id),direction:T}})),ee=X.map(ae=>({id:ae.id,source:ae.source,target:ae.target,type:"smoothstep",animated:!0,markerEnd:{type:KE.ArrowClosed,width:15,height:15,color:"#6b7280"},style:{stroke:"#6b7280",strokeWidth:2}})),ne=Mkt(Q,ee,T);return{initialNodes:ne.nodes,initialEdges:ne.edges}},[i,k,S,T,A,R,t,n,o]),[P,j,B]=k2t(I),[L,M,$]=T2t(D);x.useEffect(()=>{(I.length>0||D.length>0)&&(j(I),M(D))},[I,D,j,M]);const U=x.useCallback((W,Y)=>{const G=m.get(Y.id);G&&(G.worktreePath?r({to:"/tasks/$taskId",params:{taskId:Y.id}}):(u(G.id),f(!0)))},[r,m]);return s?c.jsx("div",{className:`flex items-center justify-center h-full ${e}`,children:c.jsx("span",{className:"text-muted-foreground",children:"Loading dependency graph..."})}):!i||i.nodes.length===0?c.jsx("div",{className:`flex items-center justify-center h-full ${e}`,children:c.jsx("span",{className:"text-muted-foreground",children:"No tasks found"})}):i.edges.length===0?c.jsxs("div",{className:`flex flex-col items-center justify-center h-full gap-2 ${e}`,children:[c.jsx("span",{className:"text-muted-foreground",children:"No dependencies defined"}),c.jsx("span",{className:"text-sm text-muted-foreground/70",children:"Add dependencies between tasks to see the graph"})]}):c.jsxs(c.Fragment,{children:[c.jsx("div",{className:`h-full relative ${e}`,children:c.jsxs(zNe,{nodes:P,edges:L,onNodesChange:B,onEdgesChange:$,onNodeClick:U,nodeTypes:Lkt,fitView:!0,fitViewOptions:{padding:.2},minZoom:.1,maxZoom:2,defaultEdgeOptions:{type:"smoothstep"},proOptions:{hideAttribution:!0},children:[c.jsx(X2t,{color:"#e5e7eb",gap:20,size:1}),c.jsx(V2t,{showInteractive:!1}),c.jsx(M2t,{nodeColor:W=>{const Y=W.data;return eOe[Y.task.status].border},maskColor:"rgba(0, 0, 0, 0.1)",className:"!bg-background/80"})]})}),h&&!h.worktreePath&&c.jsx(X2,{task:h,open:d,onOpenChange:W=>{f(W),W||u(null)}})]})}function tOe({value:e,onChange:t}){const{t:n}=Dt("tasks"),[r,i]=x.useState(!1),[s,a]=x.useState(""),o=x.useRef(null),{data:l=[]}=FVe(),u=l.filter(m=>m.name.toLowerCase().includes(s.toLowerCase()));x.useEffect(()=>{r&&setTimeout(()=>o.current?.focus(),0)},[r]);const d=m=>{e.includes(m)?t(e.filter(b=>b!==m)):t([...e,m])},f=(m,b)=>{b.stopPropagation(),t(e.filter(y=>y!==m))},h=m=>{m.stopPropagation(),t([])};return c.jsxs(pW,{open:r,onOpenChange:i,children:[c.jsxs(mW,{render:c.jsx(Ce,{variant:"outline",size:"sm",className:Pe("shrink-0 gap-1.5 h-7 px-2",e.length>0&&"pr-1")}),children:[c.jsx(J,{icon:g$e,size:12,strokeWidth:2,className:"text-muted-foreground"}),e.length===0?c.jsxs(c.Fragment,{children:[c.jsx("span",{className:"text-xs",children:n("allTags")}),c.jsx(J,{icon:Do,size:12,strokeWidth:2,className:"text-muted-foreground"})]}):c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"flex items-center gap-1",children:[e.slice(0,2).map(m=>c.jsxs(jr,{variant:"secondary",className:"h-5 px-1.5 text-[10px] gap-0.5",children:[m,c.jsx("button",{onClick:b=>f(m,b),className:"hover:text-destructive transition-colors",children:c.jsx(J,{icon:jn,size:10})})]},m)),e.length>2&&c.jsxs(jr,{variant:"secondary",className:"h-5 px-1.5 text-[10px]",children:["+",e.length-2]})]}),c.jsx("button",{onClick:h,className:"ml-0.5 p-0.5 hover:text-destructive transition-colors",children:c.jsx(J,{icon:jn,size:12})})]})]}),c.jsxs(gW,{align:"start",className:"w-56 p-0",children:[c.jsx("div",{className:"p-2 border-b",children:c.jsx(kt,{ref:o,value:s,onChange:m=>a(m.target.value),placeholder:n("searchTags"),className:"h-7 text-xs"})}),c.jsx("div",{className:"max-h-48 overflow-y-auto py-1",children:u.length===0?c.jsx("div",{className:"px-3 py-2 text-xs text-muted-foreground text-center",children:n("noTagsFound")}):u.map(m=>{const b=e.includes(m.name);return c.jsxs("button",{className:Pe("w-full px-3 py-1.5 text-left text-xs hover:bg-accent flex items-center gap-2",b&&"bg-accent/50"),onClick:()=>d(m.name),children:[c.jsx(Ci,{checked:b,className:"pointer-events-none"}),c.jsx("span",{className:"flex-1 truncate",children:m.name}),c.jsx("span",{className:"text-muted-foreground text-[10px]",children:m.taskCount})]},m.id)})}),e.length>0&&c.jsx("div",{className:"p-2 border-t",children:c.jsx(Ce,{variant:"ghost",size:"sm",className:"w-full h-7 text-xs",onClick:()=>{t([]),i(!1)},children:n("clearTags")})})]})]})}const nOe=js("/tasks/")({component:Bkt,validateSearch:e=>({project:typeof e.project=="string"?e.project:void 0,tags:typeof e.tags=="string"?e.tags:void 0,view:e.view==="graph"?"graph":void 0,task:typeof e.task=="string"?e.task:void 0})});function Bkt(){const{t:e}=Dt("tasks"),{project:t,tags:n,view:r="kanban",task:i}=nOe.useSearch(),s=ji(),[a,o]=x.useState(""),l=x.useMemo(()=>n?n.split(",").filter(Boolean):[],[n]),u=x.useCallback(h=>{s({to:"/tasks",search:m=>({...m,project:h||void 0}),replace:!0})},[s]),d=x.useCallback(h=>{s({to:"/tasks",search:m=>({...m,tags:h.length>0?h.join(","):void 0}),replace:!0})},[s]),f=x.useCallback(h=>{s({to:"/tasks",search:m=>({...m,view:h==="kanban"?void 0:h}),replace:!0})},[s]);return c.jsxs("div",{className:"flex h-full flex-col",children:[c.jsxs("div",{className:"film-grain relative flex shrink-0 items-center gap-2 border-b border-border px-4 py-2",style:{background:"var(--gradient-header)"},children:[r==="kanban"&&c.jsxs("div",{className:"relative shrink-0",children:[c.jsx(J,{icon:np,size:12,strokeWidth:2,className:"absolute left-2 top-1/2 -translate-y-1/2 text-muted-foreground"}),c.jsx(kt,{value:a,onChange:h=>o(h.target.value),placeholder:e("searchPlaceholder"),className:"h-7 w-48 pl-7 text-xs"})]}),c.jsxs("div",{className:"hidden sm:contents",children:[c.jsx(fZ,{value:t??null,onChange:u}),c.jsx(tOe,{value:l,onChange:d})]}),c.jsx("div",{className:"flex-1"}),c.jsxs(JV,{value:[r],onValueChange:h=>{const m=Array.isArray(h)?h[0]:h;m&&f(m)},size:"sm",variant:"outline",children:[c.jsx(nx,{value:"kanban","aria-label":"Kanban view",children:c.jsx(J,{icon:kO,size:14,strokeWidth:2})}),c.jsx(nx,{value:"graph","aria-label":"Dependency graph",children:c.jsx(J,{icon:t$e,size:14,strokeWidth:2})})]})]}),c.jsxs("div",{className:"flex-1 overflow-hidden",children:[r==="kanban"&&c.jsx(X1t,{projectFilter:t??null,searchQuery:a,tagsFilter:l,selectedTaskId:i}),r==="graph"&&c.jsx(Fkt,{projectFilter:t??null,tagsFilter:l})]})]})}function $kt(e,t,{checkForDefaultPrevented:n=!0}={}){return function(i){if(e?.(i),n===!1||!i.defaultPrevented)return t?.(i)}}function Ukt(e,t=[]){let n=[];function r(s,a){const o=x.createContext(a),l=n.length;n=[...n,a];const u=f=>{const{scope:h,children:m,...b}=f,y=h?.[e]?.[l]||o,v=x.useMemo(()=>b,Object.values(b));return c.jsx(y.Provider,{value:v,children:m})};u.displayName=s+"Provider";function d(f,h){const m=h?.[e]?.[l]||o,b=x.useContext(m);if(b)return b;if(a!==void 0)return a;throw new Error(`\`${f}\` must be used within \`${s}\``)}return[u,d]}const i=()=>{const s=n.map(a=>x.createContext(a));return function(o){const l=o?.[e]||s;return x.useMemo(()=>({[`__scope${e}`]:{...o,[e]:l}}),[o,l])}};return i.scopeName=e,[r,zkt(i,...t)]}function zkt(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(i=>({useScope:i(),scopeName:i.scopeName}));return function(s){const a=r.reduce((o,{useScope:l,scopeName:u})=>{const f=l(s)[`__scope${u}`];return{...o,...f}},{});return x.useMemo(()=>({[`__scope${t.scopeName}`]:a}),[a])}};return n.scopeName=t.scopeName,n}var XE=globalThis?.document?x.useLayoutEffect:()=>{},Hkt=e3[" useInsertionEffect ".trim().toString()]||XE;function Vkt({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[i,s,a]=Wkt({defaultProp:t,onChange:n}),o=e!==void 0,l=o?e:i;{const d=x.useRef(e!==void 0);x.useEffect(()=>{const f=d.current;f!==o&&console.warn(`${r} is changing from ${f?"controlled":"uncontrolled"} to ${o?"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.`),d.current=o},[o,r])}const u=x.useCallback(d=>{if(o){const f=qkt(d)?d(e):d;f!==e&&a.current?.(f)}else s(d)},[o,e,s,a]);return[l,u]}function Wkt({defaultProp:e,onChange:t}){const[n,r]=x.useState(e),i=x.useRef(n),s=x.useRef(t);return Hkt(()=>{s.current=t},[t]),x.useEffect(()=>{i.current!==n&&(s.current?.(n),i.current=n)},[n,i]),[n,r,s]}function qkt(e){return typeof e=="function"}function Bce(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function rOe(...e){return t=>{let n=!1;const r=e.map(i=>{const s=Bce(i,t);return!n&&typeof s=="function"&&(n=!0),s});if(n)return()=>{for(let i=0;i<r.length;i++){const s=r[i];typeof s=="function"?s():Bce(e[i],null)}}}}function iOe(...e){return x.useCallback(rOe(...e),e)}function Gkt(e){const t=Kkt(e),n=x.forwardRef((r,i)=>{const{children:s,...a}=r,o=x.Children.toArray(s),l=o.find(Xkt);if(l){const u=l.props.children,d=o.map(f=>f===l?x.Children.count(u)>1?x.Children.only(null):x.isValidElement(u)?u.props.children:null:f);return c.jsx(t,{...a,ref:i,children:x.isValidElement(u)?x.cloneElement(u,void 0,d):null})}return c.jsx(t,{...a,ref:i,children:s})});return n.displayName=`${e}.Slot`,n}function Kkt(e){const t=x.forwardRef((n,r)=>{const{children:i,...s}=n;if(x.isValidElement(i)){const a=Qkt(i),o=Zkt(s,i.props);return i.type!==x.Fragment&&(o.ref=r?rOe(r,a):a),x.cloneElement(i,o)}return x.Children.count(i)>1?x.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var Ykt=Symbol("radix.slottable");function Xkt(e){return x.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===Ykt}function Zkt(e,t){const n={...t};for(const r in t){const i=e[r],s=t[r];/^on[A-Z]/.test(r)?i&&s?n[r]=(...o)=>{const l=s(...o);return i(...o),l}:i&&(n[r]=i):r==="style"?n[r]={...i,...s}:r==="className"&&(n[r]=[i,s].filter(Boolean).join(" "))}return{...e,...n}}function Qkt(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var Jkt=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],LZ=Jkt.reduce((e,t)=>{const n=Gkt(`Primitive.${t}`),r=x.forwardRef((i,s)=>{const{asChild:a,...o}=i,l=a?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),c.jsx(l,{...o,ref:s})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function eTt(e,t){return x.useReducer((n,r)=>t[n][r]??n,e)}var sOe=e=>{const{present:t,children:n}=e,r=tTt(t),i=typeof n=="function"?n({present:r.isPresent}):x.Children.only(n),s=iOe(r.ref,nTt(i));return typeof n=="function"||r.isPresent?x.cloneElement(i,{ref:s}):null};sOe.displayName="Presence";function tTt(e){const[t,n]=x.useState(),r=x.useRef(null),i=x.useRef(e),s=x.useRef("none"),a=e?"mounted":"unmounted",[o,l]=eTt(a,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return x.useEffect(()=>{const u=WA(r.current);s.current=o==="mounted"?u:"none"},[o]),XE(()=>{const u=r.current,d=i.current;if(d!==e){const h=s.current,m=WA(u);e?l("MOUNT"):m==="none"||u?.display==="none"?l("UNMOUNT"):l(d&&h!==m?"ANIMATION_OUT":"UNMOUNT"),i.current=e}},[e,l]),XE(()=>{if(t){let u;const d=t.ownerDocument.defaultView??window,f=m=>{const y=WA(r.current).includes(CSS.escape(m.animationName));if(m.target===t&&y&&(l("ANIMATION_END"),!i.current)){const v=t.style.animationFillMode;t.style.animationFillMode="forwards",u=d.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=v)})}},h=m=>{m.target===t&&(s.current=WA(r.current))};return t.addEventListener("animationstart",h),t.addEventListener("animationcancel",f),t.addEventListener("animationend",f),()=>{d.clearTimeout(u),t.removeEventListener("animationstart",h),t.removeEventListener("animationcancel",f),t.removeEventListener("animationend",f)}}else l("ANIMATION_END")},[t,l]),{isPresent:["mounted","unmountSuspended"].includes(o),ref:x.useCallback(u=>{r.current=u?getComputedStyle(u):null,n(u)},[])}}function WA(e){return e?.animationName||"none"}function nTt(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var rTt=e3[" useId ".trim().toString()]||(()=>{}),iTt=0;function sTt(e){const[t,n]=x.useState(rTt());return XE(()=>{n(r=>r??String(iTt++))},[e]),e||(t?`radix-${t}`:"")}var s5="Collapsible",[aTt]=Ukt(s5),[oTt,MZ]=aTt(s5),aOe=x.forwardRef((e,t)=>{const{__scopeCollapsible:n,open:r,defaultOpen:i,disabled:s,onOpenChange:a,...o}=e,[l,u]=Vkt({prop:r,defaultProp:i??!1,onChange:a,caller:s5});return c.jsx(oTt,{scope:n,disabled:s,contentId:sTt(),open:l,onOpenToggle:x.useCallback(()=>u(d=>!d),[u]),children:c.jsx(LZ.div,{"data-state":BZ(l),"data-disabled":s?"":void 0,...o,ref:t})})});aOe.displayName=s5;var oOe="CollapsibleTrigger",lOe=x.forwardRef((e,t)=>{const{__scopeCollapsible:n,...r}=e,i=MZ(oOe,n);return c.jsx(LZ.button,{type:"button","aria-controls":i.contentId,"aria-expanded":i.open||!1,"data-state":BZ(i.open),"data-disabled":i.disabled?"":void 0,disabled:i.disabled,...r,ref:t,onClick:$kt(e.onClick,i.onOpenToggle)})});lOe.displayName=oOe;var FZ="CollapsibleContent",uOe=x.forwardRef((e,t)=>{const{forceMount:n,...r}=e,i=MZ(FZ,e.__scopeCollapsible);return c.jsx(sOe,{present:n||i.open,children:({present:s})=>c.jsx(lTt,{...r,ref:t,present:s})})});uOe.displayName=FZ;var lTt=x.forwardRef((e,t)=>{const{__scopeCollapsible:n,present:r,children:i,...s}=e,a=MZ(FZ,n),[o,l]=x.useState(r),u=x.useRef(null),d=iOe(t,u),f=x.useRef(0),h=f.current,m=x.useRef(0),b=m.current,y=a.open||o,v=x.useRef(y),_=x.useRef(void 0);return x.useEffect(()=>{const w=requestAnimationFrame(()=>v.current=!1);return()=>cancelAnimationFrame(w)},[]),XE(()=>{const w=u.current;if(w){_.current=_.current||{transitionDuration:w.style.transitionDuration,animationName:w.style.animationName},w.style.transitionDuration="0s",w.style.animationName="none";const C=w.getBoundingClientRect();f.current=C.height,m.current=C.width,v.current||(w.style.transitionDuration=_.current.transitionDuration,w.style.animationName=_.current.animationName),l(r)}},[a.open,r]),c.jsx(LZ.div,{"data-state":BZ(a.open),"data-disabled":a.disabled?"":void 0,id:a.contentId,hidden:!y,...s,ref:d,style:{"--radix-collapsible-content-height":h?`${h}px`:void 0,"--radix-collapsible-content-width":b?`${b}px`:void 0,...e.style},children:y&&i})});function BZ(e){return e?"open":"closed"}var uTt=aOe;const pg=uTt,mg=lOe;function gg({className:e,...t}){return c.jsx(uOe,{className:Pe("overflow-hidden data-[state=closed]:animate-collapsible-up data-[state=open]:animate-collapsible-down",e),...t})}const hi="/api/messaging";function cTt(){return Qt({queryKey:["messaging","whatsapp"],queryFn:async()=>{const e=await fetch(`${hi}/whatsapp`);if(!e.ok)throw new Error("Failed to fetch WhatsApp status");return await e.json()},refetchInterval:5e3})}function dTt(){const e=At();return St({mutationFn:async()=>{const t=await fetch(`${hi}/whatsapp/enable`,{method:"POST"});if(!t.ok)throw new Error("Failed to enable WhatsApp");return await t.json()},onSuccess:()=>{e.invalidateQueries({queryKey:["messaging"]})}})}function fTt(){const e=At();return St({mutationFn:async()=>{const t=await fetch(`${hi}/whatsapp/disable`,{method:"POST"});if(!t.ok)throw new Error("Failed to disable WhatsApp");return await t.json()},onSuccess:()=>{e.invalidateQueries({queryKey:["messaging"]})}})}function hTt(){const e=At();return St({mutationFn:async()=>{const t=await fetch(`${hi}/whatsapp/auth`,{method:"POST"});if(!t.ok)throw new Error("Failed to request WhatsApp auth");return await t.json()},onSuccess:()=>{e.invalidateQueries({queryKey:["messaging","whatsapp"]})}})}function pTt(){const e=At();return St({mutationFn:async()=>{const t=await fetch(`${hi}/whatsapp/disconnect`,{method:"POST"});if(!t.ok)throw new Error("Failed to disconnect WhatsApp");return await t.json()},onSuccess:()=>{e.invalidateQueries({queryKey:["messaging"]})}})}function mTt(){return Qt({queryKey:["messaging","whatsapp","sessions"],queryFn:async()=>{const e=await fetch(`${hi}/whatsapp/sessions`);if(!e.ok)throw new Error("Failed to fetch WhatsApp sessions");return(await e.json()).sessions}})}function gTt(){return Qt({queryKey:["messaging","discord"],queryFn:async()=>{const e=await fetch(`${hi}/discord`);if(!e.ok)throw new Error("Failed to fetch Discord status");return await e.json()},refetchInterval:5e3})}function bTt(){const e=At();return St({mutationFn:async t=>{const n=await fetch(`${hi}/discord/configure`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({botToken:t})});if(!n.ok){const r=await n.json();throw new Error(r.error||"Failed to configure Discord")}return await n.json()},onSuccess:()=>{e.invalidateQueries({queryKey:["messaging"]})}})}function yTt(){const e=At();return St({mutationFn:async()=>{const t=await fetch(`${hi}/discord/enable`,{method:"POST"});if(!t.ok){const n=await t.json();throw new Error(n.error||"Failed to enable Discord")}return await t.json()},onSuccess:()=>{e.invalidateQueries({queryKey:["messaging"]})}})}function vTt(){const e=At();return St({mutationFn:async()=>{const t=await fetch(`${hi}/discord/disable`,{method:"POST"});if(!t.ok)throw new Error("Failed to disable Discord");return await t.json()},onSuccess:()=>{e.invalidateQueries({queryKey:["messaging"]})}})}function xTt(){const e=At();return St({mutationFn:async()=>{const t=await fetch(`${hi}/discord/disconnect`,{method:"POST"});if(!t.ok)throw new Error("Failed to disconnect Discord");return await t.json()},onSuccess:()=>{e.invalidateQueries({queryKey:["messaging"]})}})}function _Tt(){return Qt({queryKey:["messaging","discord","sessions"],queryFn:async()=>{const e=await fetch(`${hi}/discord/sessions`);if(!e.ok)throw new Error("Failed to fetch Discord sessions");return(await e.json()).sessions}})}function STt(){return Qt({queryKey:["messaging","telegram"],queryFn:async()=>{const e=await fetch(`${hi}/telegram`);if(!e.ok)throw new Error("Failed to fetch Telegram status");return await e.json()},refetchInterval:5e3})}function wTt(){const e=At();return St({mutationFn:async t=>{const n=await fetch(`${hi}/telegram/configure`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({botToken:t})});if(!n.ok){const r=await n.json();throw new Error(r.error||"Failed to configure Telegram")}return await n.json()},onSuccess:()=>{e.invalidateQueries({queryKey:["messaging"]})}})}function ETt(){const e=At();return St({mutationFn:async()=>{const t=await fetch(`${hi}/telegram/enable`,{method:"POST"});if(!t.ok){const n=await t.json();throw new Error(n.error||"Failed to enable Telegram")}return await t.json()},onSuccess:()=>{e.invalidateQueries({queryKey:["messaging"]})}})}function CTt(){const e=At();return St({mutationFn:async()=>{const t=await fetch(`${hi}/telegram/disable`,{method:"POST"});if(!t.ok)throw new Error("Failed to disable Telegram");return await t.json()},onSuccess:()=>{e.invalidateQueries({queryKey:["messaging"]})}})}function kTt(){const e=At();return St({mutationFn:async()=>{const t=await fetch(`${hi}/telegram/disconnect`,{method:"POST"});if(!t.ok)throw new Error("Failed to disconnect Telegram");return await t.json()},onSuccess:()=>{e.invalidateQueries({queryKey:["messaging"]})}})}function TTt(){return Qt({queryKey:["messaging","telegram","sessions"],queryFn:async()=>{const e=await fetch(`${hi}/telegram/sessions`);if(!e.ok)throw new Error("Failed to fetch Telegram sessions");return(await e.json()).sessions}})}function ATt(){return Qt({queryKey:["messaging","slack"],queryFn:async()=>{const e=await fetch(`${hi}/slack`);if(!e.ok)throw new Error("Failed to fetch Slack status");return await e.json()},refetchInterval:5e3})}function NTt(){const e=At();return St({mutationFn:async t=>{const n=await fetch(`${hi}/slack/configure`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!n.ok){const r=await n.json();throw new Error(r.error||"Failed to configure Slack")}return await n.json()},onSuccess:()=>{e.invalidateQueries({queryKey:["messaging"]})}})}function OTt(){const e=At();return St({mutationFn:async()=>{const t=await fetch(`${hi}/slack/enable`,{method:"POST"});if(!t.ok){const n=await t.json();throw new Error(n.error||"Failed to enable Slack")}return await t.json()},onSuccess:()=>{e.invalidateQueries({queryKey:["messaging"]})}})}function RTt(){const e=At();return St({mutationFn:async()=>{const t=await fetch(`${hi}/slack/disable`,{method:"POST"});if(!t.ok)throw new Error("Failed to disable Slack");return await t.json()},onSuccess:()=>{e.invalidateQueries({queryKey:["messaging"]})}})}function ITt(){const e=At();return St({mutationFn:async()=>{const t=await fetch(`${hi}/slack/disconnect`,{method:"POST"});if(!t.ok)throw new Error("Failed to disconnect Slack");return await t.json()},onSuccess:()=>{e.invalidateQueries({queryKey:["messaging"]})}})}function DTt(){return Qt({queryKey:["messaging","slack","sessions"],queryFn:async()=>{const e=await fetch(`${hi}/slack/sessions`);if(!e.ok)throw new Error("Failed to fetch Slack sessions");return(await e.json()).sessions}})}function PTt(){return Qt({queryKey:["messaging","email"],queryFn:async()=>{const e=await fetch(`${hi}/email`);if(!e.ok)throw new Error("Failed to fetch email status");return await e.json()},refetchInterval:5e3})}function jTt(){const e=At();return St({mutationFn:async t=>{const n=await fetch(`${hi}/email/configure`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!n.ok){const r=await n.json();throw new Error(r.error||"Failed to configure email")}return await n.json()},onSuccess:()=>{e.invalidateQueries({queryKey:["messaging"]})}})}function LTt(){return St({mutationFn:async e=>{const t=await fetch(`${hi}/email/test`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!t.ok){const n=await t.json();throw new Error(n.error||"Failed to test email credentials")}return await t.json()}})}function MTt(){const e=At();return St({mutationFn:async()=>{const t=await fetch(`${hi}/email/enable`,{method:"POST"});if(!t.ok){const n=await t.json();throw new Error(n.error||"Failed to enable email")}return await t.json()},onSuccess:()=>{e.invalidateQueries({queryKey:["messaging"]})}})}function FTt(){const e=At();return St({mutationFn:async()=>{const t=await fetch(`${hi}/email/disable`,{method:"POST"});if(!t.ok)throw new Error("Failed to disable email");return await t.json()},onSuccess:()=>{e.invalidateQueries({queryKey:["messaging"]})}})}function BTt({isLoading:e=!1}){const{data:t,refetch:n}=cTt(),{data:r}=mTt(),i=dTt(),s=fTt(),a=hTt(),o=pTt(),[l,u]=x.useState(null),d=t?.status==="connected",f=t?.status==="connecting",h=t?.status==="qr_pending",m=t?.enabled??!1,b=async T=>{try{if(T){await i.mutateAsync();const k=await a.mutateAsync();u(k.qrDataUrl)}else await s.mutateAsync(),u(null);n()}catch{rt.error(T?"Failed to enable WhatsApp":"Failed to disable WhatsApp")}},y=async()=>{try{const T=await a.mutateAsync();u(T.qrDataUrl)}catch{rt.error("Failed to generate QR code")}},v=async()=>{try{await o.mutateAsync(),u(null),rt.success("WhatsApp disconnected")}catch{rt.error("Failed to disconnect WhatsApp")}},_=()=>d?c.jsx(J,{icon:cr,size:14,strokeWidth:2,className:"text-green-500"}):f||h?c.jsx(J,{icon:Rt,size:14,strokeWidth:2,className:"animate-spin text-yellow-500"}):c.jsx(J,{icon:jn,size:14,strokeWidth:2,className:"text-muted-foreground"}),w=()=>d?t?.displayName?`Connected as ${t.displayName}`:"Connected":f?"Connecting...":h?"Scan QR code":"Disconnected",C=i.isPending||s.isPending||a.isPending||o.isPending;return c.jsxs("div",{className:"space-y-4",children:[c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[c.jsx("label",{className:"text-sm text-muted-foreground sm:w-40 sm:shrink-0",children:"WhatsApp"}),c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx(Dr,{checked:m,onCheckedChange:b,disabled:e||C}),c.jsxs("span",{className:"flex items-center gap-2 text-sm",children:[_(),c.jsx("span",{className:"text-muted-foreground",children:w()})]})]})]}),m&&(l||h)&&!d&&c.jsxs("div",{className:"ml-4 sm:ml-44",children:[c.jsx("div",{className:"rounded-lg border border-border bg-white p-4 inline-block",children:l?c.jsx("img",{src:l,alt:"WhatsApp QR Code",className:"w-48 h-48"}):c.jsx("div",{className:"w-48 h-48 flex items-center justify-center",children:c.jsx(J,{icon:Rt,size:32,strokeWidth:2,className:"animate-spin text-muted-foreground"})})}),c.jsx("p",{className:"mt-2 text-xs text-muted-foreground",children:"Scan this QR code with WhatsApp on your phone"}),c.jsxs(Ce,{variant:"ghost",size:"sm",onClick:y,disabled:C,className:"mt-2",children:[c.jsx(J,{icon:tp,size:14,strokeWidth:2,className:"mr-2"}),"Refresh QR"]})]}),m&&d&&c.jsxs("div",{className:"ml-4 sm:ml-44 space-y-3",children:[c.jsxs(Ce,{variant:"outline",size:"sm",onClick:v,disabled:C,children:[c.jsx(J,{icon:L3,size:14,strokeWidth:2,className:"mr-2"}),"Disconnect"]}),r&&r.length>0&&c.jsxs("div",{className:"mt-4",children:[c.jsx("h4",{className:"text-sm font-medium text-muted-foreground mb-2",children:"Active Conversations"}),c.jsx("div",{className:"space-y-1",children:r.map(T=>c.jsxs("div",{className:"text-xs text-muted-foreground flex items-center gap-2",children:[c.jsx("span",{className:"font-mono",children:T.channelUserId}),T.channelUserName&&c.jsxs("span",{children:["(",T.channelUserName,")"]}),c.jsxs("span",{className:"text-muted-foreground/60",children:["Last: ",new Date(T.lastMessageAt).toLocaleString()]})]},T.id))})]})]}),c.jsx("p",{className:"ml-4 sm:ml-44 text-xs text-muted-foreground",children:"Connect WhatsApp to chat with the AI assistant via your phone. Send any message to start a conversation, or use /reset to start fresh."})]})}function $Tt({isLoading:e=!1}){const{data:t,refetch:n}=gTt(),{data:r}=_Tt(),i=bTt(),s=yTt(),a=vTt(),o=xTt(),l=!!t?.config?.botToken,[u,d]=x.useState(""),[f,h]=x.useState(!1),m=t?.status==="connected",b=t?.status==="connecting",y=async k=>{try{k?l?(await s.mutateAsync(),n()):h(!0):(await a.mutateAsync(),h(!1),d(""),n())}catch{rt.error("Failed to toggle Discord")}},v=async()=>{if(!u.trim()){rt.error("Please enter a bot token");return}try{await i.mutateAsync(u.trim()),h(!1),d(""),rt.success("Discord configuration saved"),n()}catch(k){rt.error(k instanceof Error?k.message:"Failed to connect Discord")}},_=async()=>{try{await o.mutateAsync(),rt.success("Discord disconnected")}catch{rt.error("Failed to disconnect Discord")}},w=()=>m?c.jsx(J,{icon:cr,size:14,strokeWidth:2,className:"text-green-500"}):b?c.jsx(J,{icon:Rt,size:14,strokeWidth:2,className:"animate-spin text-yellow-500"}):c.jsx(J,{icon:jn,size:14,strokeWidth:2,className:"text-muted-foreground"}),C=()=>m?t?.displayName?`Connected as ${t.displayName}`:"Connected":b?"Connecting...":"Disconnected",T=i.isPending||s.isPending||a.isPending||o.isPending;return c.jsxs("div",{className:"space-y-4",children:[c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[c.jsx("label",{className:"text-sm text-muted-foreground sm:w-40 sm:shrink-0",children:"Discord"}),c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx(Dr,{checked:m||b||f,onCheckedChange:y,disabled:e||T}),c.jsxs("span",{className:"flex items-center gap-2 text-sm",children:[w(),c.jsx("span",{className:"text-muted-foreground",children:C()})]})]})]}),f&&!m&&c.jsxs("div",{className:"ml-4 sm:ml-44 space-y-3",children:[c.jsxs("div",{className:"space-y-2",children:[c.jsx("label",{className:"block text-xs text-muted-foreground",children:"Bot Token"}),c.jsx(kt,{type:"password",placeholder:"Enter your Discord bot token",value:u,onChange:k=>d(k.target.value),className:"max-w-md font-mono text-sm"})]}),c.jsxs("div",{className:"flex gap-2",children:[c.jsxs(Ce,{size:"sm",onClick:v,disabled:T||!u.trim(),children:[i.isPending?c.jsx(J,{icon:Rt,size:14,strokeWidth:2,className:"mr-2 animate-spin"}):null,"Connect"]}),c.jsx(Ce,{variant:"ghost",size:"sm",onClick:()=>{h(!1),d("")},disabled:T,children:"Cancel"})]})]}),m&&c.jsxs("div",{className:"ml-4 sm:ml-44 space-y-3",children:[c.jsxs(Ce,{variant:"outline",size:"sm",onClick:_,disabled:T,children:[c.jsx(J,{icon:L3,size:14,strokeWidth:2,className:"mr-2"}),"Disconnect"]}),r&&r.length>0&&c.jsxs("div",{className:"mt-4",children:[c.jsx("h4",{className:"text-sm font-medium text-muted-foreground mb-2",children:"Active Conversations"}),c.jsx("div",{className:"space-y-1",children:r.map(k=>c.jsxs("div",{className:"text-xs text-muted-foreground flex items-center gap-2",children:[c.jsx("span",{className:"font-mono",children:k.channelUserId}),k.channelUserName&&c.jsxs("span",{children:["(",k.channelUserName,")"]}),c.jsxs("span",{className:"text-muted-foreground/60",children:["Last: ",new Date(k.lastMessageAt).toLocaleString()]})]},k.id))})]})]}),c.jsxs("details",{className:"ml-4 sm:ml-44 text-sm text-muted-foreground",children:[c.jsx("summary",{className:"cursor-pointer hover:text-foreground",children:"Setup instructions"}),c.jsxs("ol",{className:"mt-2 ml-4 space-y-1 list-decimal",children:[c.jsxs("li",{children:["Go to the"," ",c.jsx("a",{href:"https://discord.com/developers/applications",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"Discord Developer Portal"})]}),c.jsxs("li",{children:["Create a new application and click ",c.jsx("strong",{children:"Bot"})," in the sidebar"]}),c.jsxs("li",{children:["Click ",c.jsx("strong",{children:"Reset Token"})," to generate a bot token, then copy it"]}),c.jsxs("li",{children:["Enable ",c.jsx("strong",{children:"Message Content Intent"})," under Privileged Gateway Intents"]}),c.jsxs("li",{children:["Go to ",c.jsx("strong",{children:"OAuth2 → URL Generator"})," in the sidebar"]}),c.jsxs("li",{children:["Select both ",c.jsx("strong",{children:"bot"})," and ",c.jsx("strong",{children:"applications.commands"})," scopes"]}),c.jsx("li",{children:"Copy the generated URL and open it to add the bot (slash commands need re-auth)"}),c.jsx("li",{children:"Paste the bot token above and click Connect"}),c.jsx("li",{children:"DM the bot in Discord to chat with the AI assistant"})]})]})]})}function UTt({isLoading:e=!1}){const{data:t,refetch:n}=STt(),{data:r}=TTt(),i=wTt(),s=ETt(),a=CTt(),o=kTt(),l=!!t?.config?.botToken,[u,d]=x.useState(""),[f,h]=x.useState(!1),m=t?.status==="connected",b=t?.status==="connecting",y=async k=>{try{k?l?(await s.mutateAsync(),n()):h(!0):(await a.mutateAsync(),h(!1),d(""),n())}catch{rt.error("Failed to toggle Telegram")}},v=async()=>{if(!u.trim()){rt.error("Please enter a bot token");return}try{await i.mutateAsync(u.trim()),h(!1),d(""),rt.success("Telegram configuration saved"),n()}catch(k){rt.error(k instanceof Error?k.message:"Failed to connect Telegram")}},_=async()=>{try{await o.mutateAsync(),rt.success("Telegram disconnected")}catch{rt.error("Failed to disconnect Telegram")}},w=()=>m?c.jsx(J,{icon:cr,size:14,strokeWidth:2,className:"text-green-500"}):b?c.jsx(J,{icon:Rt,size:14,strokeWidth:2,className:"animate-spin text-yellow-500"}):c.jsx(J,{icon:jn,size:14,strokeWidth:2,className:"text-muted-foreground"}),C=()=>m?t?.displayName?`Connected as ${t.displayName}`:"Connected":b?"Connecting...":"Disconnected",T=i.isPending||s.isPending||a.isPending||o.isPending;return c.jsxs("div",{className:"space-y-4",children:[c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[c.jsx("label",{className:"text-sm text-muted-foreground sm:w-40 sm:shrink-0",children:"Telegram"}),c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx(Dr,{checked:m||b||f,onCheckedChange:y,disabled:e||T}),c.jsxs("span",{className:"flex items-center gap-2 text-sm",children:[w(),c.jsx("span",{className:"text-muted-foreground",children:C()})]})]})]}),f&&!m&&c.jsxs("div",{className:"ml-4 sm:ml-44 space-y-3",children:[c.jsxs("div",{className:"space-y-2",children:[c.jsx("label",{className:"block text-xs text-muted-foreground",children:"Bot Token"}),c.jsx(kt,{type:"password",placeholder:"Enter your Telegram bot token",value:u,onChange:k=>d(k.target.value),className:"max-w-md font-mono text-sm"})]}),c.jsxs("div",{className:"flex gap-2",children:[c.jsxs(Ce,{size:"sm",onClick:v,disabled:T||!u.trim(),children:[i.isPending?c.jsx(J,{icon:Rt,size:14,strokeWidth:2,className:"mr-2 animate-spin"}):null,"Connect"]}),c.jsx(Ce,{variant:"ghost",size:"sm",onClick:()=>{h(!1),d("")},disabled:T,children:"Cancel"})]})]}),m&&c.jsxs("div",{className:"ml-4 sm:ml-44 space-y-3",children:[c.jsxs(Ce,{variant:"outline",size:"sm",onClick:_,disabled:T,children:[c.jsx(J,{icon:L3,size:14,strokeWidth:2,className:"mr-2"}),"Disconnect"]}),r&&r.length>0&&c.jsxs("div",{className:"mt-4",children:[c.jsx("h4",{className:"text-sm font-medium text-muted-foreground mb-2",children:"Active Conversations"}),c.jsx("div",{className:"space-y-1",children:r.map(k=>c.jsxs("div",{className:"text-xs text-muted-foreground flex items-center gap-2",children:[c.jsx("span",{className:"font-mono",children:k.channelUserId}),k.channelUserName&&c.jsxs("span",{children:["(",k.channelUserName,")"]}),c.jsxs("span",{className:"text-muted-foreground/60",children:["Last: ",new Date(k.lastMessageAt).toLocaleString()]})]},k.id))})]})]}),c.jsxs("details",{className:"ml-4 sm:ml-44 text-sm text-muted-foreground",children:[c.jsx("summary",{className:"cursor-pointer hover:text-foreground",children:"Setup instructions"}),c.jsxs("ol",{className:"mt-2 ml-4 space-y-1 list-decimal",children:[c.jsxs("li",{children:["Open Telegram and message"," ",c.jsx("a",{href:"https://t.me/BotFather",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"@BotFather"})]}),c.jsxs("li",{children:["Send ",c.jsx("code",{className:"bg-muted px-1 rounded",children:"/newbot"})," and follow the prompts"]}),c.jsx("li",{children:"Copy the bot token provided by BotFather"}),c.jsx("li",{children:"Paste the token above and click Connect"}),c.jsx("li",{children:"Find your new bot in Telegram and start a chat"})]})]})]})}function zTt({isLoading:e=!1}){const{data:t,refetch:n}=ATt(),{data:r}=DTt(),i=NTt(),s=OTt(),a=RTt(),o=ITt(),l=!!(t?.config?.botToken&&t?.config?.appToken),[u,d]=x.useState(""),[f,h]=x.useState(""),[m,b]=x.useState(!1),y=t?.status==="connected",v=t?.status==="connecting",_=async A=>{try{A?l?(await s.mutateAsync(),n()):b(!0):(await a.mutateAsync(),b(!1),d(""),h(""),n())}catch{rt.error("Failed to toggle Slack")}},w=async()=>{if(!u.trim()){rt.error("Please enter a bot token");return}if(!f.trim()){rt.error("Please enter an app token");return}try{await i.mutateAsync({botToken:u.trim(),appToken:f.trim()}),b(!1),d(""),h(""),rt.success("Slack configuration saved"),n()}catch(A){rt.error(A instanceof Error?A.message:"Failed to connect Slack")}},C=async()=>{try{await o.mutateAsync(),rt.success("Slack disconnected")}catch{rt.error("Failed to disconnect Slack")}},T=()=>y?c.jsx(J,{icon:cr,size:14,strokeWidth:2,className:"text-green-500"}):v?c.jsx(J,{icon:Rt,size:14,strokeWidth:2,className:"animate-spin text-yellow-500"}):c.jsx(J,{icon:jn,size:14,strokeWidth:2,className:"text-muted-foreground"}),k=()=>y?t?.displayName?`Connected as ${t.displayName}`:"Connected":v?"Connecting...":"Disconnected",S=i.isPending||s.isPending||a.isPending||o.isPending;return c.jsxs("div",{className:"space-y-4",children:[c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[c.jsx("label",{className:"text-sm text-muted-foreground sm:w-40 sm:shrink-0",children:"Slack"}),c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx(Dr,{checked:y||v||m,onCheckedChange:_,disabled:e||S}),c.jsxs("span",{className:"flex items-center gap-2 text-sm",children:[T(),c.jsx("span",{className:"text-muted-foreground",children:k()})]})]})]}),m&&!y&&c.jsxs("div",{className:"ml-4 sm:ml-44 space-y-3",children:[c.jsxs("div",{className:"space-y-2",children:[c.jsx("label",{className:"block text-xs text-muted-foreground",children:"Bot Token (xoxb-...)"}),c.jsx(kt,{type:"password",placeholder:"xoxb-your-bot-token",value:u,onChange:A=>d(A.target.value),className:"max-w-md font-mono text-sm"})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsx("label",{className:"block text-xs text-muted-foreground",children:"App Token (xapp-...)"}),c.jsx(kt,{type:"password",placeholder:"xapp-your-app-token",value:f,onChange:A=>h(A.target.value),className:"max-w-md font-mono text-sm"})]}),c.jsxs("div",{className:"flex gap-2",children:[c.jsxs(Ce,{size:"sm",onClick:w,disabled:S||!u.trim()||!f.trim(),children:[i.isPending?c.jsx(J,{icon:Rt,size:14,strokeWidth:2,className:"mr-2 animate-spin"}):null,"Connect"]}),c.jsx(Ce,{variant:"ghost",size:"sm",onClick:()=>{b(!1),d(""),h("")},disabled:S,children:"Cancel"})]})]}),y&&c.jsxs("div",{className:"ml-4 sm:ml-44 space-y-3",children:[c.jsxs(Ce,{variant:"outline",size:"sm",onClick:C,disabled:S,children:[c.jsx(J,{icon:L3,size:14,strokeWidth:2,className:"mr-2"}),"Disconnect"]}),r&&r.length>0&&c.jsxs("div",{className:"mt-4",children:[c.jsx("h4",{className:"text-sm font-medium text-muted-foreground mb-2",children:"Active Conversations"}),c.jsx("div",{className:"space-y-1",children:r.map(A=>c.jsxs("div",{className:"text-xs text-muted-foreground flex items-center gap-2",children:[c.jsx("span",{className:"font-mono",children:A.channelUserId}),A.channelUserName&&c.jsxs("span",{children:["(",A.channelUserName,")"]}),c.jsxs("span",{className:"text-muted-foreground/60",children:["Last: ",new Date(A.lastMessageAt).toLocaleString()]})]},A.id))})]})]}),c.jsxs("details",{className:"ml-4 sm:ml-44 text-sm text-muted-foreground",children:[c.jsx("summary",{className:"cursor-pointer hover:text-foreground",children:"Setup instructions"}),c.jsxs("ol",{className:"mt-2 ml-4 space-y-1 list-decimal",children:[c.jsxs("li",{children:["Go to"," ",c.jsx("a",{href:"https://api.slack.com/apps",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"api.slack.com/apps"})," ","and create a new app"]}),c.jsxs("li",{children:["Under ",c.jsx("strong",{children:"Socket Mode"}),", enable it and create an App Token (xapp-...)"]}),c.jsxs("li",{children:["Under ",c.jsx("strong",{children:"OAuth & Permissions"}),", add these ",c.jsx("strong",{children:"Bot Token Scopes"}),":"," ",c.jsx("code",{className:"bg-muted px-1 rounded text-xs",children:"chat:write"}),","," ",c.jsx("code",{className:"bg-muted px-1 rounded text-xs",children:"commands"}),","," ",c.jsx("code",{className:"bg-muted px-1 rounded text-xs",children:"im:history"}),","," ",c.jsx("code",{className:"bg-muted px-1 rounded text-xs",children:"im:read"}),","," ",c.jsx("code",{className:"bg-muted px-1 rounded text-xs",children:"im:write"}),","," ",c.jsx("code",{className:"bg-muted px-1 rounded text-xs",children:"users:read"})]}),c.jsx("li",{children:"Install the app to your workspace to get the Bot Token (xoxb-...)"}),c.jsxs("li",{children:["Under ",c.jsx("strong",{children:"Event Subscriptions"}),", subscribe to ",c.jsx("code",{className:"bg-muted px-1 rounded text-xs",children:"message.im"})]}),c.jsxs("li",{children:["Under ",c.jsx("strong",{children:"Slash Commands"}),", create these commands:"," ",c.jsx("code",{className:"bg-muted px-1 rounded text-xs",children:"/reset"}),","," ",c.jsx("code",{className:"bg-muted px-1 rounded text-xs",children:"/help"}),","," ",c.jsx("code",{className:"bg-muted px-1 rounded text-xs",children:"/info"})," ",c.jsx("span",{className:"text-muted-foreground/60",children:"(/status is reserved by Slack)"})]}),c.jsxs("li",{children:["Under ",c.jsx("strong",{children:"App Home"}),", enable ",c.jsx("strong",{children:"Messages Tab"})," and check ",c.jsx("em",{children:'"Allow users to send Slash commands and messages from the messages tab"'})]}),c.jsx("li",{children:"Paste both tokens above and click Connect"}),c.jsx("li",{children:"DM the bot in Slack to chat with the AI assistant"})]})]})]})}const Y6=nu(),dp="";function a5(){return Qt({queryKey:["google","accounts"],queryFn:()=>ct(`${dp}/api/google/accounts`).then(e=>e.accounts)})}function cOe(){const e=At();return St({mutationFn:({id:t,...n})=>ct(`${dp}/api/google/accounts/${t}`,{method:"PATCH",body:JSON.stringify(n)}),onSuccess:()=>{e.invalidateQueries({queryKey:["google"]})}})}function HTt(){const e=At();return St({mutationFn:t=>ct(`${dp}/api/google/accounts/${t}`,{method:"DELETE"}),onSuccess:()=>{e.invalidateQueries({queryKey:["google"]}),e.invalidateQueries({queryKey:["caldav"]})}})}function VTt(){const e=At();return St({mutationFn:t=>ct(`${dp}/api/google/accounts/${t}/enable-calendar`,{method:"POST"}),onSuccess:()=>{e.invalidateQueries({queryKey:["google"]}),e.invalidateQueries({queryKey:["caldav"]})}})}function WTt(){const e=At();return St({mutationFn:t=>ct(`${dp}/api/google/accounts/${t}/disable-calendar`,{method:"POST"}),onSuccess:()=>{e.invalidateQueries({queryKey:["google"]}),e.invalidateQueries({queryKey:["caldav"]})}})}function qTt(){const e=At();return St({mutationFn:t=>ct(`${dp}/api/google/accounts/${t}/sync`,{method:"POST"}),onSuccess:()=>{e.invalidateQueries({queryKey:["google"]}),e.invalidateQueries({queryKey:["caldav"]})}})}function GTt(){const e=At();return St({mutationFn:t=>ct(`${dp}/api/google/accounts/${t}/enable-gmail`,{method:"POST"}),onSuccess:()=>{e.invalidateQueries({queryKey:["google"]})}})}function KTt(){const e=At();return St({mutationFn:t=>ct(`${dp}/api/google/accounts/${t}/disable-gmail`,{method:"POST"}),onSuccess:()=>{e.invalidateQueries({queryKey:["google"]})}})}function YTt(){return St({mutationFn:async e=>{const t=new URLSearchParams;e.accountName&&t.set("accountName",e.accountName),e.accountId&&t.set("accountId",e.accountId),t.set("origin",window.location.origin);const n=`${dp}/api/google/oauth/authorize?${t.toString()}`;Y6.info("Requesting OAuth authorize URL",{origin:window.location.origin,href:window.location.href,fetchUrl:n,accountName:e.accountName,accountId:e.accountId});const r=await ct(n);try{const i=new URL(r.authUrl);Y6.info("Got OAuth auth URL from server",{authUrl:r.authUrl,redirect_uri:i.searchParams.get("redirect_uri"),client_id:i.searchParams.get("client_id"),scope:i.searchParams.get("scope"),state:i.searchParams.get("state")})}catch{Y6.info("Got OAuth auth URL from server (unparseable)",{authUrl:r.authUrl})}return r}})}const $ce={"gmail.com":{imap:{host:"imap.gmail.com",port:993,secure:!0},note:"Requires an App Password. Go to Google Account > Security > 2-Step Verification > App passwords."},"googlemail.com":{imap:{host:"imap.gmail.com",port:993,secure:!0},note:"Requires an App Password. Go to Google Account > Security > 2-Step Verification > App passwords."},"outlook.com":{imap:{host:"outlook.office365.com",port:993,secure:!0}},"hotmail.com":{imap:{host:"outlook.office365.com",port:993,secure:!0}},"live.com":{imap:{host:"outlook.office365.com",port:993,secure:!0}},"yahoo.com":{imap:{host:"imap.mail.yahoo.com",port:993,secure:!0}},"icloud.com":{imap:{host:"imap.mail.me.com",port:993,secure:!0},note:"Requires an App-Specific Password from appleid.apple.com."}};function Uce(e){const t=e.split("@")[1]?.toLowerCase();return t&&$ce[t]?{...$ce[t],isKnown:!0}:{imap:{host:`imap.${t||"example.com"}`,port:993,secure:!0},isKnown:!1}}function XTt({isLoading:e=!1}){const{t}=Dt("settings"),[n,r]=x.useState("gmail");return c.jsxs("div",{className:"space-y-4",children:[c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[c.jsx("label",{className:"text-sm text-muted-foreground sm:w-40 sm:shrink-0",children:t("imap.emailBackend","Email Backend")}),c.jsxs("div",{className:"flex gap-1 rounded-lg border p-0.5",children:[c.jsx("button",{type:"button",onClick:()=>r("gmail"),className:`rounded-md px-3 py-1 text-sm transition-colors ${n==="gmail"?"bg-destructive text-destructive-foreground":"text-muted-foreground hover:text-foreground"}`,children:t("google.gmail","Gmail API")}),c.jsx("button",{type:"button",onClick:()=>r("imap"),className:`rounded-md px-3 py-1 text-sm transition-colors ${n==="imap"?"bg-destructive text-destructive-foreground":"text-muted-foreground hover:text-foreground"}`,children:"IMAP"})]})]}),n==="imap"?c.jsx(ZTt,{isLoading:e}):c.jsx(QTt,{})]})}function ZTt({isLoading:e=!1}){const{t}=Dt("settings"),{data:n,refetch:r}=PTt(),i=jTt(),s=LTt(),a=MTt(),o=FTt(),l=!!n?.config?.imap?.host,[u,d]=x.useState(""),[f,h]=x.useState(""),[m,b]=x.useState(!1),[y,v]=x.useState(""),[_,w]=x.useState(993),[C,T]=x.useState(!0),[k,S]=x.useState(""),[A,R]=x.useState(""),[I,D]=x.useState(30),[P,j]=x.useState(null),B=n?.status==="connected",L=n?.status==="connecting",M=n?.enabled??!1,$=Uce(u);x.useEffect(()=>{if(n?.config){const ne=n.config;d(ne.imap?.user||""),h(ne.imap?.password||""),v(ne.imap?.host||""),w(ne.imap?.port||993),T(ne.imap?.secure??!0),S(ne.imap?.user||""),R(ne.imap?.password||""),D(ne.pollIntervalSeconds||30);const ae=Uce(ne.imap?.user||"");ne.imap?.host&&ne.imap.host!==ae.imap.host&&b(!0)}},[n?.config]);const U=()=>m?{imap:{host:y,port:_,secure:C,user:k,password:A},pollIntervalSeconds:I}:{imap:{...$.imap,user:u,password:f},pollIntervalSeconds:I},W=async()=>{const ne=U();j(null);try{const ae=await s.mutateAsync(ne);j(ae),ae.success?rt.success("Connection test successful"):rt.error(ae.error||"Connection test failed")}catch{rt.error("Failed to test credentials")}},Y=async()=>{const ne=U();try{await i.mutateAsync(ne),rt.success("Email configured successfully"),h(""),r()}catch{rt.error("Failed to configure email")}},G=async()=>{try{await a.mutateAsync()&&(rt.success("Email enabled"),r())}catch(ne){rt.error(ne instanceof Error?ne.message:"Failed to enable email")}},q=async()=>{try{await o.mutateAsync(),rt.success("Email disabled"),r()}catch{rt.error("Failed to disable email")}},X=async ne=>{ne?l&&await G():await q()},z=i.isPending||s.isPending||a.isPending||o.isPending,Q=()=>B?c.jsx(J,{icon:cr,size:14,strokeWidth:2,className:"text-green-500"}):L?c.jsx(J,{icon:Rt,size:14,strokeWidth:2,className:"animate-spin text-yellow-500"}):c.jsx(J,{icon:jn,size:14,strokeWidth:2,className:"text-muted-foreground"}),ee=()=>B?n?.displayName?`Connected as ${n.displayName}`:"Connected":L?"Connecting...":n?.status==="credentials_required"?"Credentials required":"Disconnected";return c.jsxs("div",{className:"space-y-4",children:[c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[c.jsx("label",{className:"text-sm text-muted-foreground sm:w-40 sm:shrink-0",children:t("imap.label","IMAP Feed")}),c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx(Dr,{checked:M,onCheckedChange:X,disabled:e||z}),c.jsxs("span",{className:"flex items-center gap-2 text-sm",children:[Q(),c.jsx("span",{className:"text-muted-foreground",children:ee()})]})]})]}),!B&&c.jsxs("div",{className:"ml-4 sm:ml-44 space-y-4 max-w-md",children:[!m&&c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"space-y-2",children:[c.jsx(Kr,{htmlFor:"email",children:"Email Address"}),c.jsx(kt,{id:"email",type:"email",placeholder:"assistant@example.com",value:u,onChange:ne=>d(ne.target.value)}),$.note&&u.includes("@")&&c.jsxs("p",{className:"text-xs text-muted-foreground flex items-start gap-1",children:[c.jsx(J,{icon:Pr,size:14,strokeWidth:2,className:"shrink-0 mt-0.5 text-yellow-500"}),$.note]})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsx(Kr,{htmlFor:"password",children:u.includes("@gmail.com")||u.includes("@icloud.com")?"App Password":"Password"}),c.jsx(kt,{id:"password",type:"password",placeholder:"Password",value:f,onChange:ne=>h(ne.target.value)})]}),u.includes("@")&&c.jsxs("div",{className:"text-xs text-muted-foreground",children:[c.jsxs("span",{children:["IMAP: ",$.imap.host,":",$.imap.port]}),!$.isKnown&&c.jsx("span",{className:"ml-2 text-yellow-600",children:"(auto-detected)"})]})]}),c.jsx("div",{className:"pt-2",children:c.jsx("button",{type:"button",onClick:()=>b(!m),className:"text-xs text-muted-foreground hover:text-foreground",children:m?"- Hide advanced settings":"+ Show advanced settings"})}),m&&c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"border-t border-border pt-4",children:[c.jsx("h4",{className:"text-sm font-medium mb-3",children:"IMAP Settings (Incoming)"}),c.jsxs("div",{className:"space-y-3",children:[c.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[c.jsxs("div",{className:"col-span-2 space-y-2",children:[c.jsx(Kr,{htmlFor:"imapHost",children:"Host"}),c.jsx(kt,{id:"imapHost",placeholder:"imap.gmail.com",value:y,onChange:ne=>v(ne.target.value)})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsx(Kr,{htmlFor:"imapPort",children:"Port"}),c.jsx(kt,{id:"imapPort",type:"number",value:_||$.imap.port,onChange:ne=>w(parseInt(ne.target.value)||993)})]}),c.jsxs("div",{className:"flex items-end gap-2 pb-1",children:[c.jsx(Dr,{id:"imapSecure",checked:C,onCheckedChange:T}),c.jsx(Kr,{htmlFor:"imapSecure",children:"SSL/TLS"})]})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsx(Kr,{htmlFor:"imapUser",children:"Username"}),c.jsx(kt,{id:"imapUser",placeholder:"you@gmail.com",value:k,onChange:ne=>S(ne.target.value)})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsx(Kr,{htmlFor:"imapPassword",children:"Password"}),c.jsx(kt,{id:"imapPassword",type:"password",placeholder:"IMAP password or app password",value:A,onChange:ne=>R(ne.target.value)})]})]})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsx(Kr,{htmlFor:"pollInterval",children:"Check for new emails every"}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(kt,{id:"pollInterval",type:"number",className:"w-20",min:10,max:300,value:I,onChange:ne=>D(parseInt(ne.target.value)||30)}),c.jsx("span",{className:"text-sm text-muted-foreground",children:"seconds"})]})]})]}),P&&c.jsxs("div",{className:`p-3 rounded-lg text-sm ${P.success?"bg-green-500/10 text-green-600":"bg-red-500/10 text-red-600"}`,children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(J,{icon:P.success?cr:jn,size:16,strokeWidth:2}),c.jsx("span",{children:P.success?"Connection successful":"Connection failed"})]}),!P.success&&P.error&&c.jsx("p",{className:"mt-1 text-xs",children:P.error}),c.jsx("div",{className:"mt-2 text-xs space-y-1",children:c.jsxs("p",{children:["IMAP: ",P.imapOk?"OK":"Failed"]})})]}),c.jsxs("div",{className:"flex gap-2",children:[c.jsxs(Ce,{variant:"outline",size:"sm",onClick:W,disabled:z||(m?!y||!k||!A:!u||!f),children:[s.isPending?c.jsx(J,{icon:Rt,size:14,strokeWidth:2,className:"mr-2 animate-spin"}):c.jsx(J,{icon:nm,size:14,strokeWidth:2,className:"mr-2"}),"Test Connection"]}),c.jsxs(Ce,{size:"sm",onClick:Y,disabled:z||(m?!y||!k||!A:!u||!f),children:[i.isPending?c.jsx(J,{icon:Rt,size:14,strokeWidth:2,className:"mr-2 animate-spin"}):null,"Save & Enable"]})]})]}),M&&B&&c.jsx("div",{className:"ml-4 sm:ml-44 space-y-3",children:c.jsx(Ce,{variant:"outline",size:"sm",onClick:q,disabled:z,children:t("imap.disableButton","Disable Email")})}),c.jsx("p",{className:"ml-4 sm:ml-44 text-xs text-muted-foreground",children:t("imap.description","Monitor an IMAP mailbox as a read-only feed. Incoming emails appear in the messaging timeline but no replies are sent.")})]})}function QTt(){const{t:e}=Dt("settings"),{data:t}=a5(),n=GTt(),r=KTt(),i=Cr(qt.EMAIL_POLL_INTERVAL),s=rW(),[a,o]=x.useState(30);x.useEffect(()=>{i.data?.value!=null&&o(Number(i.data.value)||30)},[i.data?.value]);const l=()=>{const f=Math.max(5,Math.min(3600,a||30));o(f),s.mutate({key:qt.EMAIL_POLL_INTERVAL,value:f})},u=async(f,h)=>{try{h?(await n.mutateAsync(f),rt.success(e("google.gmailEnabled","Gmail enabled"))):(await r.mutateAsync(f),rt.success(e("google.gmailDisabled","Gmail disabled")))}catch(m){rt.error(String(m))}},d=t?.some(f=>f.gmailEnabled);return!t||t.length===0?c.jsx("div",{className:"space-y-2 ml-4 sm:ml-44",children:c.jsxs("p",{className:"text-sm text-muted-foreground",children:[e("google.noAccountsGmail","No Google accounts connected.")," ",c.jsx(ai,{to:"/settings",search:{tab:void 0},className:"text-accent underline underline-offset-2",children:e("google.addInGeneral","Add one in General settings")})]})}):c.jsxs("div",{className:"space-y-4",children:[t.map(f=>c.jsx(JTt,{account:f,onToggle:u},f.id)),d&&c.jsxs("div",{className:"flex items-center gap-2 ml-4",children:[c.jsx(Kr,{htmlFor:"gmailPollInterval",children:e("imap.checkEvery","Check for new emails every")}),c.jsx(kt,{id:"gmailPollInterval",type:"number",min:5,max:3600,value:a,onChange:f=>o(parseInt(f.target.value)||30),onBlur:l,onKeyDown:f=>{f.key==="Enter"&&f.currentTarget.blur()},className:"w-20 h-8"}),c.jsx("span",{className:"text-sm text-muted-foreground",children:e("imap.seconds","seconds")})]}),c.jsx("p",{className:"text-xs text-muted-foreground",children:e("google.gmailDescription","Gmail API uses OAuth2 — no app passwords needed. Drafts are created for human review before sending.")})]})}function JTt({account:e,onToggle:t}){const{t:n}=Dt("settings"),r=cOe(),[i,s]=x.useState(e.sendAsEmail??e.email??""),a=async()=>{const o=i.trim(),l=e.sendAsEmail??e.email??"";if(o!==l)try{await r.mutateAsync({id:e.id,sendAsEmail:o||null}),rt.success(n("google.sendAsUpdated","Send-as address updated"))}catch(u){rt.error(String(u))}};return c.jsxs("div",{className:"border rounded-lg p-4 space-y-3",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx("span",{className:"font-medium text-sm",children:e.name}),e.email&&c.jsx("span",{className:"text-xs text-muted-foreground ml-2",children:e.email})]}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("span",{className:"text-xs text-muted-foreground",children:n("google.monitorInbox","Monitor inbox")}),c.jsx(Dr,{checked:e.gmailEnabled??!1,onCheckedChange:o=>t(e.id,o)})]})]}),e.gmailEnabled&&c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("label",{className:"text-xs text-muted-foreground shrink-0",children:n("google.sendAs","Send as")}),c.jsx(kt,{value:i,onChange:o=>s(o.target.value),onBlur:a,onKeyDown:o=>{o.key==="Enter"&&o.currentTarget.blur()},placeholder:e.email??n("google.sendAsPlaceholder","you@gmail.com"),className:"h-8 text-xs max-w-xs"}),c.jsx("span",{className:"text-xs text-muted-foreground",children:n("google.draftsOnly","(drafts only)")})]}),e.lastGmailSyncError&&c.jsxs("div",{className:"flex items-start gap-1.5",children:[c.jsx(J,{icon:Pr,className:"h-3.5 w-3.5 text-destructive mt-0.5"}),c.jsx("p",{className:"text-xs text-destructive",children:e.lastGmailSyncError})]})]})}const va="";function eAt(){return Qt({queryKey:["caldav","status"],queryFn:()=>ct(`${va}/api/caldav/status`),refetchInterval:3e4})}function dOe(){return Qt({queryKey:["caldav","accounts"],queryFn:()=>ct(`${va}/api/caldav/accounts`)})}function tAt(){const e=At();return St({mutationFn:t=>ct(`${va}/api/caldav/accounts`,{method:"POST",body:JSON.stringify(t)}),onSuccess:()=>{e.invalidateQueries({queryKey:["caldav"]})}})}function nAt(){const e=At();return St({mutationFn:t=>ct(`${va}/api/caldav/accounts/google`,{method:"POST",body:JSON.stringify(t)}),onSuccess:()=>{e.invalidateQueries({queryKey:["caldav"]})}})}function rAt(){const e=At();return St({mutationFn:({id:t,...n})=>ct(`${va}/api/caldav/accounts/${t}`,{method:"PATCH",body:JSON.stringify(n)}),onSuccess:()=>{e.invalidateQueries({queryKey:["caldav"]})}})}function iAt(){const e=At();return St({mutationFn:t=>ct(`${va}/api/caldav/accounts/${t}`,{method:"DELETE"}),onSuccess:()=>{e.invalidateQueries({queryKey:["caldav"]})}})}function sAt(){const e=At();return St({mutationFn:t=>ct(`${va}/api/caldav/accounts/${t}/enable`,{method:"POST"}),onSuccess:()=>{e.invalidateQueries({queryKey:["caldav"]})}})}function aAt(){const e=At();return St({mutationFn:t=>ct(`${va}/api/caldav/accounts/${t}/disable`,{method:"POST"}),onSuccess:()=>{e.invalidateQueries({queryKey:["caldav"]})}})}function oAt(){const e=At();return St({mutationFn:t=>ct(`${va}/api/caldav/accounts/${t}/sync`,{method:"POST"}),onSuccess:()=>{e.invalidateQueries({queryKey:["caldav"]})}})}function lAt(){return St({mutationFn:e=>ct(`${va}/api/caldav/accounts/${e}/oauth/authorize`)})}function uAt(){return Qt({queryKey:["caldav","copy-rules"],queryFn:()=>ct(`${va}/api/caldav/copy-rules`)})}function cAt(){const e=At();return St({mutationFn:t=>ct(`${va}/api/caldav/copy-rules`,{method:"POST",body:JSON.stringify(t)}),onSuccess:()=>{e.invalidateQueries({queryKey:["caldav","copy-rules"]})}})}function dAt(){const e=At();return St({mutationFn:({id:t,...n})=>ct(`${va}/api/caldav/copy-rules/${t}`,{method:"PATCH",body:JSON.stringify(n)}),onSuccess:()=>{e.invalidateQueries({queryKey:["caldav","copy-rules"]})}})}function fAt(){const e=At();return St({mutationFn:t=>ct(`${va}/api/caldav/copy-rules/${t}`,{method:"DELETE"}),onSuccess:()=>{e.invalidateQueries({queryKey:["caldav","copy-rules"]})}})}function hAt(){const e=At();return St({mutationFn:t=>ct(`${va}/api/caldav/copy-rules/${t}/execute`,{method:"POST"}),onSuccess:()=>{e.invalidateQueries({queryKey:["caldav"]})}})}function $Z(){return Qt({queryKey:["caldav","calendars"],queryFn:()=>ct(`${va}/api/caldav/calendars`)})}function pAt(){const e=At();return St({mutationFn:()=>ct(`${va}/api/caldav/enable`,{method:"POST"}),onSuccess:()=>{e.invalidateQueries({queryKey:["caldav"]}),e.invalidateQueries({queryKey:["config","caldav.enabled"]})}})}function mAt(){const e=At();return St({mutationFn:()=>ct(`${va}/api/caldav/disable`,{method:"POST"}),onSuccess:()=>{e.invalidateQueries({queryKey:["caldav"]}),e.invalidateQueries({queryKey:["config","caldav.enabled"]})}})}function fOe(e,t){return Qt({queryKey:["caldav","events",e,t],queryFn:()=>ct(`${va}/api/caldav/events?from=${e}&to=${t}`),enabled:!!e&&!!t})}function gAt({isLoading:e=!1}){const{t}=Dt("settings"),{data:n,refetch:r}=eAt(),{data:i}=dOe(),s=tAt(),a=nAt(),o=iAt(),l=sAt(),u=aAt(),d=oAt(),f=lAt(),h=rAt(),m=pAt(),b=mAt(),y=nW(),[v,_]=x.useState(!1),[w,C]=x.useState(null),[T,k]=x.useState(""),[S,A]=x.useState("google"),[R,I]=x.useState(""),[D,P]=x.useState(""),[j,B]=x.useState(""),[L,M]=x.useState(""),[$,U]=x.useState("15"),[W,Y]=x.useState(""),[G,q]=x.useState(""),[X,z]=x.useState(""),[Q,ee]=x.useState("15"),[ne,ae]=x.useState(!1),[fe,re]=x.useState(null),de=x.useRef(null),he=n?.connected===!0||(n?.accounts??[]).length>0;x.useEffect(()=>(ne&&fe&&(de.current=setInterval(()=>{r()},2e3)),ne&&fe&&n?.accounts&&n.accounts.find(je=>je.id===fe)?.connected&&(ae(!1),re(null),_(!1),Y(""),q(""),z(""),rt.success(t("caldav.configured"))),()=>{de.current&&(clearInterval(de.current),de.current=null)}),[ne,fe,n?.accounts,r,t]);const ce=async ve=>{try{ve?await m.mutateAsync():await b.mutateAsync(),r()}catch{rt.error(t("caldav.toggleFailed"))}},ye=async ve=>{try{await d.mutateAsync(ve),rt.success(t("caldav.syncComplete")),r()}catch(je){rt.error(je instanceof Error?je.message:t("caldav.syncFailed"))}},be=async(ve,je)=>{try{je?await u.mutateAsync(ve):await l.mutateAsync(ve),r()}catch{rt.error(t("caldav.toggleFailed"))}},ue=async ve=>{try{await o.mutateAsync(ve),rt.success(t("caldav.disconnected")),r()}catch{rt.error(t("caldav.disconnectFailed"))}},Ae=async()=>{if(!D.trim()||!j.trim()||!L.trim()){rt.error(t("caldav.fillRequired"));return}try{await s.mutateAsync({name:R.trim()||j.trim(),serverUrl:D.trim(),username:j.trim(),password:L.trim(),syncIntervalMinutes:parseInt($,10)||15}),_(!1),I(""),P(""),B(""),M(""),U("15"),rt.success(t("caldav.configured")),r()}catch(ve){rt.error(ve instanceof Error?ve.message:t("caldav.configureFailed"))}},le=async()=>{if(!G.trim()||!X.trim()){rt.error(t("caldav.googleFillRequired"));return}try{const ve=await a.mutateAsync({name:W.trim()||"Google Calendar",googleClientId:G.trim(),googleClientSecret:X.trim(),syncIntervalMinutes:parseInt(Q,10)||15}),{authUrl:je}=await f.mutateAsync(ve.id);window.open(je,"_blank","noopener"),rt.info(t("caldav.googleAuthStarted")),re(ve.id),ae(!0)}catch(ve){rt.error(ve instanceof Error?ve.message:t("caldav.configureFailed"))}},ke=()=>{_(!1),ae(!1),re(null),I(""),P(""),B(""),M(""),U("15"),Y(""),q(""),z(""),ee("15")},Fe=s.isPending||a.isPending||f.isPending||h.isPending||o.isPending||l.isPending||u.isPending||d.isPending||m.isPending||b.isPending,ze=n?.accounts??[];return c.jsxs("div",{className:"space-y-4",children:[c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[c.jsx("label",{className:"text-sm text-muted-foreground sm:w-40 sm:shrink-0",children:t("caldav.label")}),c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx(Dr,{checked:he,onCheckedChange:ce,disabled:e||Fe}),m.isPending&&c.jsxs("span",{className:"flex items-center gap-2 text-sm",children:[c.jsx(J,{icon:Rt,size:14,strokeWidth:2,className:"animate-spin text-yellow-500"}),c.jsx("span",{className:"text-muted-foreground",children:t("caldav.statusConnecting")})]})]})]}),ze.length>0&&c.jsx("div",{className:"ml-4 sm:ml-44 space-y-2",children:ze.map(ve=>{const we=i?.find(Le=>Le.id===ve.id)?.authType??"basic";return c.jsxs("div",{className:"flex items-center gap-3 rounded-md border px-3 py-2",children:[c.jsx("div",{className:"shrink-0",children:ve.syncing?c.jsx(J,{icon:Rt,size:14,strokeWidth:2,className:"animate-spin text-yellow-500"}):ve.lastError?c.jsx(J,{icon:jn,size:14,strokeWidth:2,className:"text-red-500"}):ve.connected?c.jsx(J,{icon:cr,size:14,strokeWidth:2,className:"text-green-500"}):c.jsx("span",{className:"inline-block h-3.5 w-3.5 rounded-full border border-muted-foreground/40"})}),c.jsxs("div",{className:"flex-1 min-w-0",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[w===ve.id?c.jsx(kt,{autoFocus:!0,value:T,onChange:Le=>k(Le.target.value),onFocus:Le=>Le.target.select(),onKeyDown:Le=>{Le.key==="Enter"?Le.currentTarget.blur():Le.key==="Escape"&&(C(null),k(""))},onBlur:()=>{const Le=T.trim();Le&&Le!==ve.name&&h.mutate({id:ve.id,name:Le},{onSuccess:()=>r()}),C(null),k("")},className:"h-6 w-48 text-sm font-medium px-1.5 py-0"}):c.jsx("span",{className:"text-sm font-medium truncate cursor-pointer hover:underline",onClick:()=>{C(ve.id),k(ve.name)},children:ve.name}),c.jsx("span",{className:"shrink-0 rounded bg-muted px-1.5 py-0.5 text-[10px] font-medium uppercase text-muted-foreground",children:we==="google-oauth"?"Google":"Basic"})]}),c.jsx("div",{className:"text-xs text-muted-foreground",children:ve.connected?`${ve.calendarCount} calendar${ve.calendarCount!==1?"s":""}`:ve.lastError?ve.lastError:ve.enabled?t("caldav.statusConnecting"):t("caldav.disabled")??"Disabled"})]}),c.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[c.jsx(Ce,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>ye(ve.id),disabled:Fe||ve.syncing||!ve.enabled,title:t("caldav.syncButton"),children:c.jsx(J,{icon:tp,size:14,strokeWidth:2,className:ve.syncing?"animate-spin":""})}),c.jsx(Dr,{checked:ve.enabled,onCheckedChange:()=>be(ve.id,ve.enabled),disabled:Fe,className:"scale-75"}),c.jsx(Ce,{variant:"ghost",size:"icon",className:"h-7 w-7 text-destructive hover:text-destructive",onClick:()=>ue(ve.id),disabled:Fe,title:t("caldav.deleteAccount")??"Delete",children:c.jsx(J,{icon:ma,size:14,strokeWidth:2})})]})]},ve.id)})}),!v&&c.jsx("div",{className:"ml-4 sm:ml-44",children:c.jsxs(Ce,{variant:"outline",size:"sm",onClick:()=>_(!0),disabled:Fe,children:[c.jsx(J,{icon:mu,size:14,strokeWidth:2,className:"mr-2"}),t("caldav.addAccount")]})}),v&&c.jsx("div",{className:"ml-4 sm:ml-44",children:c.jsxs(Jo,{value:S,onValueChange:A,children:[c.jsxs(el,{children:[c.jsx(Bn,{value:"google",children:t("caldav.tabGoogle")}),c.jsx(Bn,{value:"basic",children:t("caldav.tabBasic")})]}),c.jsx(Un,{value:"basic",children:c.jsxs("div",{className:"space-y-3 pt-2",children:[c.jsxs("div",{className:"space-y-2",children:[c.jsx("label",{className:"block text-xs text-muted-foreground",children:t("caldav.accountName")}),c.jsx(kt,{type:"text",placeholder:t("caldav.accountNamePlaceholder")??"My CalDAV Server",value:R,onChange:ve=>I(ve.target.value),className:"max-w-md text-sm"})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsx("label",{className:"block text-xs text-muted-foreground",children:t("caldav.serverUrl")}),c.jsx(kt,{type:"url",placeholder:t("caldav.serverUrlPlaceholder"),value:D,onChange:ve=>P(ve.target.value),className:"max-w-md font-mono text-sm"})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsx("label",{className:"block text-xs text-muted-foreground",children:t("caldav.username")}),c.jsx(kt,{type:"text",placeholder:t("caldav.usernamePlaceholder"),value:j,onChange:ve=>B(ve.target.value),className:"max-w-md text-sm"})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsx("label",{className:"block text-xs text-muted-foreground",children:t("caldav.password")}),c.jsx(kt,{type:"password",placeholder:t("caldav.passwordPlaceholder"),value:L,onChange:ve=>M(ve.target.value),className:"max-w-md font-mono text-sm"})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsx("label",{className:"block text-xs text-muted-foreground",children:t("caldav.syncInterval")}),c.jsx(kt,{type:"number",min:1,max:1440,value:$,onChange:ve=>U(ve.target.value),className:"w-24 text-sm"})]}),c.jsxs("div",{className:"flex gap-2",children:[c.jsxs(Ce,{size:"sm",onClick:Ae,disabled:Fe||!D.trim()||!j.trim()||!L.trim(),children:[s.isPending?c.jsx(J,{icon:Rt,size:14,strokeWidth:2,className:"mr-2 animate-spin"}):null,t("caldav.connectButton")]}),c.jsx(Ce,{variant:"ghost",size:"sm",onClick:ke,disabled:Fe,children:t("caldav.cancelButton")})]})]})}),c.jsx(Un,{value:"google",children:c.jsxs("div",{className:"space-y-3 pt-2",children:[c.jsxs("div",{className:"space-y-2",children:[c.jsx("label",{className:"block text-xs text-muted-foreground",children:t("caldav.accountName")}),c.jsx(kt,{type:"text",placeholder:t("caldav.googleAccountNamePlaceholder")??"Google Calendar",value:W,onChange:ve=>Y(ve.target.value),className:"max-w-md text-sm"})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsx("label",{className:"block text-xs text-muted-foreground",children:t("caldav.googleClientId")}),c.jsx(kt,{type:"text",placeholder:t("caldav.googleClientIdPlaceholder"),value:G,onChange:ve=>q(ve.target.value),className:"max-w-md font-mono text-sm"})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsx("label",{className:"block text-xs text-muted-foreground",children:t("caldav.googleClientSecret")}),c.jsx(kt,{type:"password",placeholder:t("caldav.googleClientSecretPlaceholder"),value:X,onChange:ve=>z(ve.target.value),className:"max-w-md font-mono text-sm"})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsx("label",{className:"block text-xs text-muted-foreground",children:t("caldav.syncInterval")}),c.jsx(kt,{type:"number",min:1,max:1440,value:Q,onChange:ve=>ee(ve.target.value),className:"w-24 text-sm"})]}),c.jsxs("div",{className:"flex gap-2",children:[c.jsxs(Ce,{size:"sm",onClick:le,disabled:Fe||ne||!G.trim()||!X.trim(),children:[a.isPending||f.isPending||ne?c.jsx(J,{icon:Rt,size:14,strokeWidth:2,className:"mr-2 animate-spin"}):null,t("caldav.connectGoogleButton")]}),c.jsx(Ce,{variant:"ghost",size:"sm",onClick:ke,disabled:Fe,children:t("caldav.cancelButton")})]}),c.jsxs("details",{className:"text-xs text-muted-foreground max-w-lg",children:[c.jsx("summary",{className:"cursor-pointer hover:text-foreground font-medium",children:t("caldav.googleSetupHelp")}),c.jsxs("ol",{className:"mt-2 space-y-1.5 list-none pl-0",children:[c.jsx("li",{children:t("caldav.googleStep1")}),c.jsx("li",{children:t("caldav.googleStep2")}),c.jsx("li",{children:t("caldav.googleStep3")}),c.jsx("li",{children:t("caldav.googleStep4")}),c.jsx("li",{children:t("caldav.googleStep5")}),c.jsx("li",{className:"pl-4 font-mono text-[11px] bg-muted/50 rounded px-2 py-1 w-fit",children:t("caldav.googleCallbackNote",{callbackUrl:`http://${window.location.hostname}:${y.data}/api/caldav/oauth/callback`})}),c.jsx("li",{children:t("caldav.googleStep6")})]})]})]})})]})}),c.jsxs("details",{className:"ml-4 sm:ml-44 text-sm text-muted-foreground",children:[c.jsx("summary",{className:"cursor-pointer hover:text-foreground",children:t("caldav.setupInstructions")}),c.jsxs("div",{className:"mt-2 space-y-2 text-xs",children:[c.jsx("p",{children:t("caldav.helpIntro")}),c.jsxs("ul",{className:"ml-4 list-disc space-y-1",children:[c.jsxs("li",{children:[c.jsx("strong",{children:"Nextcloud:"})," https://cloud.example.com/remote.php/dav"]}),c.jsxs("li",{children:[c.jsx("strong",{children:"Radicale:"})," http://localhost:5232"]}),c.jsxs("li",{children:[c.jsx("strong",{children:"Baikal:"})," https://baikal.example.com/dav.php"]}),c.jsxs("li",{children:[c.jsx("strong",{children:"iCloud:"})," https://caldav.icloud.com (use app-specific password)"]}),c.jsxs("li",{children:[c.jsx("strong",{children:"Google:"})," Use the Google Calendar tab with OAuth2"]})]}),c.jsx("p",{children:t("caldav.helpNote")})]})]})]})}function bAt({clientId:e,onClientIdChange:t,clientIdSaved:n,clientSecret:r,onClientSecretChange:i,clientSecretSaved:s,isLoading:a,onSaveCredentials:o}){const{t:l}=Dt("settings"),{data:u,refetch:d}=a5(),f=HTt(),h=YTt(),m=cOe(),[b,y]=x.useState(!1),[v,_]=x.useState(""),[w,C]=x.useState(!1),[T,k]=x.useState(null),[S,A]=x.useState(""),[R,I]=x.useState(!1),D=x.useRef(null),P=async()=>{if(!v.trim()){rt.error(l("google.nameRequired","Account name is required"));return}try{C(!0);const L=window.open("about:blank","_blank","width=600,height=700");try{await o?.();const M=await h.mutateAsync({accountName:v.trim()});L&&!L.closed?L.location.href=M.authUrl:window.location.href=M.authUrl}catch(M){throw L?.close(),M}D.current=setInterval(async()=>{const M=u?.length??0;await d(),((await d()).data?.length??0)>M&&(clearInterval(D.current),D.current=null,C(!1),y(!1),_(""),rt.success(l("google.accountAdded","Google account connected")))},2e3),setTimeout(()=>{D.current&&(clearInterval(D.current),D.current=null,C(!1))},12e4)}catch(L){C(!1),rt.error(String(L))}},j=async L=>{try{await f.mutateAsync(L),rt.success(l("google.accountDeleted","Google account deleted"))}catch(M){rt.error(String(M))}},B=async L=>{try{await m.mutateAsync({id:L,name:S}),k(null),rt.success(l("common.saved","Saved"))}catch(M){rt.error(String(M))}};return c.jsxs("div",{className:"space-y-4",children:[c.jsxs(pg,{open:R,onOpenChange:I,children:[c.jsxs(mg,{className:"flex items-center gap-1.5 text-xs text-muted-foreground hover:text-foreground transition-colors",children:[c.jsx(J,{icon:R?Do:hu,size:12,strokeWidth:2}),l("google.setupGuideTitle","How to set up Google OAuth credentials")]}),c.jsx(gg,{children:c.jsxs("ol",{className:"mt-2 ml-4 space-y-1.5 text-xs text-muted-foreground list-decimal list-outside",children:[c.jsx("li",{children:c.jsx(oS,{i18nKey:"google.setupGuideStep1",ns:"settings",defaults:"Go to <link>Google Cloud Console</link>",components:{link:c.jsx("a",{href:"https://console.cloud.google.com/",target:"_blank",rel:"noopener noreferrer",className:"text-accent underline underline-offset-2"})}})}),c.jsx("li",{children:l("google.setupGuideStep2","Create a new project (or select an existing one)")}),c.jsx("li",{children:c.jsx(oS,{i18nKey:"google.setupGuideStep3",ns:"settings",defaults:"Enable the <strong>Google Calendar API</strong> and <strong>Gmail API</strong>",components:{strong:c.jsx("strong",{className:"text-foreground"})}})}),c.jsx("li",{children:c.jsx(oS,{i18nKey:"google.setupGuideStep4",ns:"settings",defaults:"Go to <strong>APIs & Services \\u2192 Credentials</strong>",components:{strong:c.jsx("strong",{className:"text-foreground"})}})}),c.jsx("li",{children:c.jsx(oS,{i18nKey:"google.setupGuideStep5",ns:"settings",defaults:"Create an <strong>OAuth 2.0 Client ID</strong> (type: Web application)",components:{strong:c.jsx("strong",{className:"text-foreground"})}})}),c.jsx("li",{children:c.jsx(oS,{i18nKey:"google.setupGuideStep6",ns:"settings",defaults:"Add authorized redirect URI: <code>{{redirectUri}}</code>",values:{redirectUri:`${window.location.origin}/api/google/oauth/callback`},components:{code:c.jsx("code",{className:"bg-muted px-1 py-0.5 rounded text-[10px]"})}})}),c.jsx("li",{children:l("google.setupGuideStep7","Copy the Client ID and Client Secret into the fields below")})]})})]}),c.jsxs("div",{className:"space-y-4",children:[c.jsxs("div",{className:"space-y-1",children:[c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[c.jsx("label",{className:"text-sm text-muted-foreground sm:w-20 sm:shrink-0",children:l("fields.google.clientId","Google ID")}),c.jsx("div",{className:"flex flex-1 items-center gap-2",children:c.jsxs("div",{className:"relative flex-1",children:[c.jsx(kt,{value:e,onChange:L=>t(L.target.value),placeholder:"your-app.apps.googleusercontent.com",disabled:a,className:"flex-1 pr-8 font-mono text-sm"}),n&&c.jsx("div",{className:"absolute right-2 top-1/2 -translate-y-1/2 text-green-500",children:c.jsx(J,{icon:cr,size:14,strokeWidth:2})})]})})]}),c.jsx("p",{className:"text-xs text-muted-foreground sm:ml-20 sm:pl-2",children:l("fields.google.clientIdDescription","OAuth Client ID from Google Cloud Console")})]}),c.jsxs("div",{className:"space-y-1",children:[c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[c.jsx("label",{className:"text-sm text-muted-foreground sm:w-20 sm:shrink-0",children:l("fields.google.clientSecret","Google Secret")}),c.jsx("div",{className:"flex flex-1 items-center gap-2",children:c.jsxs("div",{className:"relative flex-1",children:[c.jsx(kt,{type:"password",value:r,onChange:L=>i(L.target.value),placeholder:l("caldav.googleClientSecretPlaceholder"),disabled:a,className:"flex-1 pr-8 font-mono text-sm"}),s&&c.jsx("div",{className:"absolute right-2 top-1/2 -translate-y-1/2 text-green-500",children:c.jsx(J,{icon:cr,size:14,strokeWidth:2})})]})})]}),c.jsx("p",{className:"text-xs text-muted-foreground sm:ml-20 sm:pl-2",children:l("fields.google.clientSecretDescription","OAuth Client Secret for Google Calendar & Gmail")})]})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("h3",{className:"text-sm font-medium",children:l("google.title","Google Accounts")}),c.jsxs(Ce,{variant:"outline",size:"sm",onClick:()=>y(!b),children:[c.jsx(J,{icon:mu,className:"mr-1 h-3.5 w-3.5"}),l("google.addAccount","Add Google Account")]})]}),b&&c.jsxs("div",{className:"border rounded-lg p-4 space-y-3",children:[c.jsxs("div",{children:[c.jsx("label",{className:"text-xs text-muted-foreground",children:l("google.accountName","Account Name")}),c.jsx(kt,{value:v,onChange:L=>_(L.target.value),placeholder:"My Google Account",className:"mt-1"})]}),c.jsx("p",{className:"text-xs text-muted-foreground",children:l("google.oauthNote","You will be redirected to Google to authorize access to Calendar and Gmail.")}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx(Ce,{onClick:P,disabled:w||!v.trim(),size:"sm",children:w?c.jsxs(c.Fragment,{children:[c.jsx(J,{icon:Rt,className:"mr-1 h-3.5 w-3.5 animate-spin"}),l("google.connecting","Connecting...")]}):l("google.connect","Connect with Google")}),c.jsx(Ce,{variant:"ghost",size:"sm",onClick:()=>{y(!1),_(""),C(!1),D.current&&(clearInterval(D.current),D.current=null)},children:l("common:buttons.cancel","Cancel")})]})]}),(!u||u.length===0)&&!b&&c.jsx("p",{className:"text-sm text-muted-foreground",children:l("google.noAccounts","No Google accounts configured.")}),u?.map(L=>c.jsx("div",{className:"border rounded-lg p-4",children:c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("div",{className:"flex-1",children:T===L.id?c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(kt,{value:S,onChange:M=>A(M.target.value),className:"h-7 text-sm",autoFocus:!0,onKeyDown:M=>{M.key==="Enter"&&B(L.id),M.key==="Escape"&&k(null)}}),c.jsx(Ce,{variant:"ghost",size:"sm",onClick:()=>B(L.id),children:c.jsx(J,{icon:cr,className:"h-3.5 w-3.5"})}),c.jsx(Ce,{variant:"ghost",size:"sm",onClick:()=>k(null),children:c.jsx(J,{icon:jn,className:"h-3.5 w-3.5"})})]}):c.jsxs("div",{className:"cursor-pointer",onClick:()=>{k(L.id),A(L.name)},children:[c.jsx("span",{className:"font-medium text-sm",children:L.name}),L.email&&c.jsx("span",{className:"text-xs text-muted-foreground ml-2",children:L.email})]})}),c.jsx(Ce,{variant:"ghost",size:"sm",onClick:()=>j(L.id),title:l("google.delete","Delete"),children:c.jsx(J,{icon:ma,className:"h-3.5 w-3.5 text-destructive"})})]})},L.id))]})}function yAt(){const{t:e}=Dt("settings"),{data:t}=a5(),n=VTt(),r=WTt(),i=qTt(),s=async(o,l)=>{try{l?(await n.mutateAsync(o),rt.success(e("google.calendarEnabled","Calendar sync enabled"))):(await r.mutateAsync(o),rt.success(e("google.calendarDisabled","Calendar sync disabled")))}catch(u){rt.error(String(u))}},a=async o=>{try{await i.mutateAsync(o),rt.success(e("google.syncComplete","Calendar sync complete"))}catch(l){rt.error(String(l))}};return!t||t.length===0?c.jsxs("div",{className:"space-y-2",children:[c.jsx("h3",{className:"text-sm font-medium",children:e("google.calendarSync","Calendar Sync")}),c.jsxs("p",{className:"text-sm text-muted-foreground",children:[e("google.noAccountsCalendar","No Google accounts connected.")," ",c.jsx(ai,{to:"/settings",search:{tab:void 0},className:"text-accent underline underline-offset-2",children:e("google.addInGeneral","Add one in General settings")})]})]}):c.jsxs("div",{className:"space-y-4",children:[c.jsx("h3",{className:"text-sm font-medium",children:e("google.calendarSync","Calendar Sync")}),t.map(o=>c.jsxs("div",{className:"border rounded-lg p-4 space-y-3",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx("span",{className:"font-medium text-sm",children:o.name}),o.email&&c.jsx("span",{className:"text-xs text-muted-foreground ml-2",children:o.email})]}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(Ce,{variant:"ghost",size:"sm",onClick:()=>a(o.id),disabled:!o.calendarEnabled||i.isPending,title:e("google.sync","Sync"),children:c.jsx(J,{icon:i.isPending?Rt:tp,className:`h-3.5 w-3.5 ${i.isPending?"animate-spin":""}`})}),c.jsx(Dr,{checked:o.calendarEnabled??!1,onCheckedChange:l=>s(o.id,l)})]})]}),o.lastCalendarSyncError&&c.jsx("p",{className:"text-xs text-destructive",children:o.lastCalendarSyncError}),o.lastCalendarSyncAt&&!o.lastCalendarSyncError&&c.jsxs("p",{className:"text-xs text-muted-foreground",children:[e("google.lastSync","Last sync"),":"," ",new Date(o.lastCalendarSyncAt).toLocaleString()]})]},o.id))]})}function vAt({isLoading:e=!1}){const{t}=Dt("settings"),{data:n}=$Z(),{data:r}=dOe(),{data:i}=uAt(),s=cAt(),a=dAt(),o=fAt(),l=hAt(),[u,d]=x.useState(!1),[f,h]=x.useState(""),[m,b]=x.useState(""),[y,v]=x.useState(null);if(!n||n.length<2)return null;const _=new Map((r??[]).map(I=>[I.id,I])),w=new Map;for(const I of n){const D=I.accountId??"unknown";w.has(D)||w.set(D,[]),w.get(D).push(I)}const C=I=>n.find(P=>P.id===I)?.displayName??I,T=async()=>{if(!f||!m){rt.error(t("caldav.copyRulesSelectBoth"));return}if(f===m){rt.error(t("caldav.copyRulesSameCalendar"));return}try{await s.mutateAsync({sourceCalendarId:f,destCalendarId:m}),d(!1),h(""),b(""),rt.success(t("caldav.copyRuleCreated"))}catch(I){rt.error(I instanceof Error?I.message:t("caldav.copyRuleCreateFailed"))}},k=async(I,D)=>{try{await a.mutateAsync({id:I,enabled:D})}catch(P){rt.error(P instanceof Error?P.message:t("caldav.copyRuleUpdateFailed"))}},S=async I=>{try{await o.mutateAsync(I),rt.success(t("caldav.copyRuleDeleted"))}catch(D){rt.error(D instanceof Error?D.message:t("caldav.copyRuleDeleteFailed"))}},A=async I=>{v(I);try{const D=await l.mutateAsync(I);rt.success(t("caldav.copyRuleExecuted",{created:D.created,updated:D.updated}))}catch(D){rt.error(D instanceof Error?D.message:t("caldav.copyRuleExecuteFailed"))}finally{v(null)}},R=(I,D,P)=>c.jsxs("select",{id:P,value:I,onChange:j=>D(j.target.value),className:"h-9 rounded-md border border-input bg-background px-3 py-1 text-sm shadow-sm focus:outline-none focus:ring-1 focus:ring-ring",children:[c.jsx("option",{value:"",children:t("caldav.copyRulesSelectCalendar")}),Array.from(w.entries()).map(([j,B])=>{const M=_.get(j)?.name??j;return c.jsx("optgroup",{label:M,children:B.map($=>c.jsx("option",{value:$.id,children:$.displayName??$.id},$.id))},j)})]});return c.jsxs("div",{className:"space-y-4",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("h3",{className:"text-sm font-medium",children:t("caldav.copyRules")}),!u&&c.jsxs(Ce,{variant:"outline",size:"sm",onClick:()=>d(!0),disabled:e,children:[c.jsx(J,{icon:mu,size:14,strokeWidth:2,className:"mr-1.5"}),t("caldav.addRule")]})]}),u&&c.jsxs("div",{className:"rounded-md border border-border p-3 space-y-3",children:[c.jsxs("div",{className:"flex flex-wrap items-end gap-3",children:[c.jsxs("div",{className:"space-y-1",children:[c.jsx("label",{htmlFor:"source-calendar",className:"text-xs text-muted-foreground",children:t("caldav.copyRulesSource")}),R(f,h,"source-calendar")]}),c.jsx("span",{className:"pb-2 text-sm text-muted-foreground",children:"→"}),c.jsxs("div",{className:"space-y-1",children:[c.jsx("label",{htmlFor:"dest-calendar",className:"text-xs text-muted-foreground",children:t("caldav.copyRulesDest")}),R(m,b,"dest-calendar")]})]}),c.jsxs("div",{className:"flex gap-2",children:[c.jsxs(Ce,{size:"sm",onClick:T,disabled:s.isPending||!f||!m,children:[s.isPending&&c.jsx(J,{icon:Rt,size:14,strokeWidth:2,className:"mr-1.5 animate-spin"}),t("caldav.addRule")]}),c.jsx(Ce,{variant:"ghost",size:"sm",onClick:()=>{d(!1),h(""),b("")},disabled:s.isPending,children:t("caldav.cancelButton")})]})]}),i&&i.length>0?c.jsx("div",{className:"space-y-2",children:i.map(I=>{const D=y===I.id;return c.jsxs("div",{className:"flex items-center gap-3 rounded-md border border-border px-3 py-2",children:[c.jsx(Dr,{checked:I.enabled!==!1,onCheckedChange:P=>k(I.id,P),disabled:a.isPending}),c.jsxs("div",{className:"flex-1 min-w-0",children:[c.jsxs("span",{className:"text-sm",children:[C(I.sourceCalendarId),c.jsx("span",{className:"mx-1.5 text-muted-foreground",children:"→"}),C(I.destCalendarId)]}),I.lastExecutedAt&&c.jsx("p",{className:"text-xs text-muted-foreground",children:t("caldav.copyRulesLastRun",{time:new Date(I.lastExecutedAt).toLocaleString()})})]}),c.jsx(Ce,{variant:"outline",size:"sm",onClick:()=>A(I.id),disabled:D||e,title:t("caldav.copyRulesRunNow"),children:D?c.jsx(J,{icon:Rt,size:14,strokeWidth:2,className:"animate-spin"}):c.jsx(J,{icon:Q0,size:14,strokeWidth:2})}),c.jsx(Ce,{variant:"ghost",size:"sm",onClick:()=>S(I.id),disabled:o.isPending||e,title:t("caldav.copyRulesDelete"),children:c.jsx(J,{icon:ma,size:14,strokeWidth:2,className:"text-destructive"})})]},I.id)})}):c.jsx("p",{className:"text-xs text-muted-foreground",children:t("caldav.copyRulesEmpty")})]})}const xAt=["general","ai","messaging","calendar"],zU=js("/settings/")({component:_At,validateSearch:e=>({tab:xAt.includes(e.tab)?e.tab:void 0})});function yl({title:e,children:t}){return c.jsxs("div",{className:"film-grain relative rounded-lg border border-border p-4 pt-6",style:{background:"var(--gradient-card)"},children:[c.jsx("span",{className:"absolute -top-2.5 left-3 rounded bg-card px-2 text-xs font-medium text-muted-foreground",children:e}),t]})}function _At(){const{t:e}=Dt("settings"),{t}=Dt("common"),{tab:n}=zU.useSearch(),r=zU.useNavigate(),i=n||"general",s=Be=>{const Pt=Be;r({search:bs=>({...bs,tab:Pt==="general"?void 0:Pt}),replace:!0})},{data:a,isLoading:o}=nW(),{data:l,isLoading:u}=q3(),{data:d,isLoading:f}=G3(),{data:h,isLoading:m}=K3(),{data:b,isLoading:y}=Y3(),{data:v,isLoading:_}=GVe(),{data:w}=KVe(),{data:C}=YVe(),{data:T,isLoading:k}=p2(),{data:S,isLoading:A}=x1(),{data:R,isLoading:I}=DSe(),{data:D,isLoading:P}=PSe(),{data:j,isLoading:B}=jSe(),{data:L}=XVe(),{data:M,isLoading:$}=dWe(),{data:U,isLoading:W}=pWe(),{data:Y,isLoading:G}=rCe(),q=AQe(),{data:X}=gWe(),z=bWe(),{savedLanguage:Q,changeLanguage:ee}=sCe(),{theme:ne,syncClaudeCode:ae,changeTheme:fe}=dCe(),{data:re}=JVe(),{data:de}=eWe(),{data:he,isLoading:ce}=LSe(),{data:ye,isLoading:be}=MSe(),{data:ue,isLoading:Ae}=X3(),{data:le,isLoading:ke}=FSe(),{data:Fe,isLoading:ze}=BSe(),{data:ve,isLoading:je}=tWe(),{data:we}=nWe(),{data:Le}=rWe(),{data:qe,isLoading:Re}=iWe(),{data:Ie,isLoading:se}=sWe(),{data:Ge,isLoading:ut}=aWe(),{data:mt,isLoading:Ke}=oWe(),{data:lt,isLoading:Ve}=lWe(),{data:Ct,isLoading:Ne}=uWe(),{installed:Ue}=eD(),{version:st}=yWe(),{data:et,isLoading:pt}=xWe(),wt=_We(),Et=SWe(),Se=rW(),Oe=cWe(),Qe=fWe(),It=mWe(),_t=hWe(),an=(a5().data??[]).filter(Be=>Be.gmailEnabled),vn=At(),[zt,sn]=x.useState(""),[Ln,vr]=x.useState(""),[Mr,oi]=x.useState("vscode"),[gs,xi]=x.useState(""),[dr,fr]=x.useState(""),[Fi,Ai]=x.useState(""),[Ki,vo]=x.useState(""),[Yi,tt]=x.useState(""),[Mn,An]=x.useState("claude"),[Fr,ss]=x.useState(null),[li,kr]=x.useState("build"),[ei,hr]=x.useState("plan"),[Br,Xi]=x.useState(!0),[Fo,Gt]=x.useState(""),[it,Wt]=x.useState(!1),[Xn,Bi]=x.useState(!1),[In,As]=x.useState(!0),[wu,Ya]=x.useState(!0),[Sa,Eu]=x.useState(!0),[$i,Ns]=x.useState(!1),[as,Lc]=x.useState(!1),[Mc,Td]=x.useState(""),[Xa,Uf]=x.useState(!1),[Vt,dn]=x.useState(""),[On,$r]=x.useState(!1),[Rr,_n]=x.useState(""),[xo,Bo]=x.useState(""),[wa,Za]=x.useState(!1),[Cu,yp]=x.useState(!1),[ul,N]=x.useState(!1),[H,te]=x.useState(""),[oe,_e]=x.useState(!1),[He,Xe]=x.useState(!1),[Tt,Lt]=x.useState(!1),[Cn,Fn]=x.useState(""),[Ur,Zi]=x.useState("glm-4.5-air"),[cl,ku]=x.useState("glm-4.7"),[os,Qa]=x.useState("glm-4.7"),[Ea,vp]=x.useState(""),[xp,Qy]=x.useState(""),[zf,_p]=x.useState(!1),[Hf,d_]=x.useState("light-ansi"),[Jy,mk]=x.useState("dark-ansi"),[ev,tv]=x.useState("worktree"),[nv,gk]=x.useState(!0),[f_,bk]=x.useState(null),[Ad,h_]=x.useState("claude"),[rv,yk]=x.useState("sonnet"),[iv,vk]=x.useState("haiku"),[Tu,xk]=x.useState(null),[sv,_k]=x.useState(null),[kg,Sk]=x.useState("~/.fulcrum/documents"),[Tg,wk]=x.useState(!1),[av,Ek]=x.useState("09:00"),[ov,Ck]=x.useState(""),[lv,kk]=x.useState("18:00"),[Sp,wp]=x.useState(""),[p_,uv]=x.useState(!1),[m_,cv]=x.useState(!1),[g_,b_]=x.useState(!1),Fc=x.useRef(null);x.useEffect(()=>{a!==void 0&&sn(String(a)),l!==void 0&&vr(l),d!==void 0&&oi(d),h!==void 0&&xi(h),b!==void 0&&fr(String(b)),v!==void 0&&Ai(v),w!==void 0&&vo(w),C!==void 0&&tt(C),T!==void 0&&An(T),S!==void 0&&ss(S),R!==void 0&&kr(R),D!==void 0&&hr(D),j!==void 0&&Xi(j),L!==void 0&&Gt(L??"")},[a,l,d,h,b,v,w,C,T,S,R,D,j,L]),x.useEffect(()=>{M&&(As(M.enabled),Ya(M.toast?.enabled??!0),Eu(M.desktop?.enabled??!0),Ns(M.sound?.enabled??!1),cv(!!M.sound?.customSoundFile),Lc(M.slack?.enabled??!1),Td(M.slack?.webhookUrl??""),Uf(M.discord?.enabled??!1),dn(M.discord?.webhookUrl??""),$r(M.pushover?.enabled??!1),_n(M.pushover?.appToken??""),Bo(M.pushover?.userKey??""),Za(M.whatsapp?.enabled??!1),yp(M.telegram?.enabled??!1),N(M.gmail?.enabled??!1),te(M.gmail?.googleAccountId??""),_e(M.slack?.useMessagingChannel??!1),Xe(M.discord?.useMessagingChannel??!1))},[M]),x.useEffect(()=>{U&&(Lt(U.enabled),Fn(U.apiKey??""),Zi(U.haikuModel),ku(U.sonnetModel),Qa(U.opusModel))},[U]),x.useEffect(()=>{Y?.cloudflareApiToken!==void 0&&vp(Y.cloudflareApiToken??""),Y?.cloudflareAccountId!==void 0&&Qy(Y.cloudflareAccountId??"")},[Y]),x.useEffect(()=>{ae!==void 0&&_p(ae),re!==void 0&&d_(re),de!==void 0&&mk(de)},[ae,re,de]),x.useEffect(()=>{he!==void 0&&tv(he),ye!==void 0&&gk(ye)},[he,ye]),x.useEffect(()=>{ue!==void 0&&bk(ue)},[ue]),x.useEffect(()=>{le!==void 0&&h_(le),Fe!==void 0&&yk(Fe),ve!==void 0&&vk(ve),we!==void 0&&xk(we),Le!==void 0&&_k(Le),qe!==void 0&&Sk(qe)},[le,Fe,ve,we,Le,qe]),x.useEffect(()=>{Ie!==void 0&&wk(Ie),Ge!==void 0&&Ek(Ge),mt!==void 0&&Ck(mt),lt!==void 0&&kk(lt),Ct!==void 0&&wp(Ct)},[Ie,Ge,mt,lt,Ct]);const en=o||u||f||m||y||_||k||A||I||P||B||$||W||G||ce||be||Ae||ke||ze||je||Re||se||ut||Ke||Ve||Ne,Tk=U&&(Tt!==U.enabled||Cn!==(U.apiKey??"")||Ur!==U.haikuModel||cl!==U.sonnetModel||os!==U.opusModel),Ak=zf!==(ae??!1)||Hf!==re||Jy!==de,y_=ev!==he||nv!==ye,v_=f_!==ue,Ep=Ad!==le||rv!==Fe||iv!==ve||Tu!==we||sv!==Le||kg!==qe,Cp=Tg!==Ie||av!==Ge||ov!==mt||lv!==lt||Sp!==Ct,Nk=(()=>{const Be=Y?.cloudflareApiToken??"",Pt=Y?.cloudflareAccountId??"",bs=Ea!==Be&&!Ea.match(/^•+$/),Ca=xp!==Pt&&!xp.match(/^•+$/);return bs||Ca})(),Ag=M&&(In!==M.enabled||wu!==(M.toast?.enabled??!0)||Sa!==(M.desktop?.enabled??!0)||$i!==(M.sound?.enabled??!1)||as!==(M.slack?.enabled??!1)||Mc!==(M.slack?.webhookUrl??"")||oe!==(M.slack?.useMessagingChannel??!1)||Xa!==(M.discord?.enabled??!1)||Vt!==(M.discord?.webhookUrl??"")||He!==(M.discord?.useMessagingChannel??!1)||On!==(M.pushover?.enabled??!1)||Rr!==(M.pushover?.appToken??"")||xo!==(M.pushover?.userKey??"")||wa!==(M.whatsapp?.enabled??!1)||Cu!==(M.telegram?.enabled??!1)||ul!==(M.gmail?.enabled??!1)||H!==(M.gmail?.googleAccountId??"")),Ok=Mr!==d||gs!==h||dr!==String(b),Rk=Mn!==T||Fr!==(S??null)||li!==R||ei!==D||Br!==j||Fo!==(L??""),x_=zt!==String(a)||Ln!==l||Fi!==v||Ki!==w||Yi!==C||Rk||Ok||Ag||Tk||Ak||Nk||y_||v_||Ep||Cp,__=async()=>{const Be=[];Ki!==w&&Be.push(Se.mutateAsync({key:qt.GOOGLE_CLIENT_ID,value:Ki||null})),Yi!==C&&Be.push(Se.mutateAsync({key:qt.GOOGLE_CLIENT_SECRET,value:Yi||null})),Be.length>0&&await Promise.all(Be)},Ik=async()=>{const Be=[];if(zt!==String(a)){const Pt=parseInt(zt,10);!isNaN(Pt)&&Pt>=1&&Pt<=65535&&Be.push(new Promise(bs=>{Se.mutate({key:qt.PORT,value:Pt},{onSettled:bs})}))}if(Ln!==l&&Be.push(new Promise(Pt=>{Se.mutate({key:qt.DEFAULT_GIT_REPOS_DIR,value:Ln},{onSettled:Pt})})),Mr!==d&&Be.push(new Promise(Pt=>{Se.mutate({key:qt.EDITOR_APP,value:Mr},{onSettled:Pt})})),gs!==h&&Be.push(new Promise(Pt=>{Se.mutate({key:qt.EDITOR_HOST,value:gs},{onSettled:Pt})})),dr!==String(b)){const Pt=parseInt(dr,10);!isNaN(Pt)&&Pt>=1&&Pt<=65535&&Be.push(new Promise(bs=>{Se.mutate({key:qt.EDITOR_SSH_PORT,value:Pt},{onSettled:bs})}))}if(Fi!==v&&Be.push(new Promise(Pt=>{Se.mutate({key:qt.GITHUB_PAT,value:Fi},{onSettled:Pt})})),Ki!==w&&Be.push(new Promise(Pt=>{Se.mutate({key:qt.GOOGLE_CLIENT_ID,value:Ki||null},{onSettled:Pt})})),Yi!==C&&Be.push(new Promise(Pt=>{Se.mutate({key:qt.GOOGLE_CLIENT_SECRET,value:Yi||null},{onSettled:Pt})})),Mn!==T&&Be.push(new Promise(Pt=>{Se.mutate({key:qt.DEFAULT_AGENT,value:Mn},{onSettled:Pt})})),Fr!==(S??null)&&Be.push(new Promise(Pt=>{Se.mutate({key:qt.OPENCODE_MODEL,value:Fr},{onSettled:Pt})})),li!==R&&Be.push(new Promise(Pt=>{Se.mutate({key:qt.OPENCODE_DEFAULT_AGENT,value:li},{onSettled:Pt})})),ei!==D&&Be.push(new Promise(Pt=>{Se.mutate({key:qt.OPENCODE_PLAN_AGENT,value:ei},{onSettled:Pt})})),Br!==j&&Be.push(new Promise(Pt=>{Se.mutate({key:qt.AGENT_AUTO_SCROLL_TO_BOTTOM,value:Br},{onSettled:Pt})})),Fo!==(L??"")&&Be.push(new Promise(Pt=>{Se.mutate({key:qt.CLAUDE_CODE_PATH,value:Fo||null},{onSettled:Pt})})),Ag&&Be.push(new Promise(Pt=>{Qe.mutate({enabled:In,toast:{enabled:wu},desktop:{enabled:Sa},sound:{enabled:$i},slack:{enabled:as,webhookUrl:Mc,useMessagingChannel:oe},discord:{enabled:Xa,webhookUrl:Vt,useMessagingChannel:He},pushover:{enabled:On,appToken:Rr,userKey:xo},whatsapp:{enabled:wa},telegram:{enabled:Cu},gmail:{enabled:ul,googleAccountId:H||void 0},_updatedAt:M?._updatedAt},{onSettled:Pt,onError:bs=>{bs instanceof $Se&&(rt.warning(e("notifications.conflictWarning")||"Settings changed elsewhere - refreshing"),vn.invalidateQueries({queryKey:["config","notifications"]}))}})})),Tk&&Be.push(new Promise(Pt=>{It.mutate({enabled:Tt,apiKey:Cn||null,haikuModel:Ur,sonnetModel:cl,opusModel:os},{onSettled:Pt})})),Ak&&(zf!==(ae??!1)&&Be.push(new Promise(Pt=>{Se.mutate({key:qt.SYNC_CLAUDE_CODE_THEME,value:zf},{onSettled:Pt})})),Hf!==re&&Be.push(new Promise(Pt=>{Se.mutate({key:qt.CLAUDE_CODE_LIGHT_THEME,value:Hf},{onSettled:Pt})})),Jy!==de&&Be.push(new Promise(Pt=>{Se.mutate({key:qt.CLAUDE_CODE_DARK_THEME,value:Jy},{onSettled:Pt})}))),y_&&(ev!==he&&Be.push(new Promise(Pt=>{Se.mutate({key:qt.DEFAULT_TASK_TYPE,value:ev},{onSettled:Pt})})),nv!==ye&&Be.push(new Promise(Pt=>{Se.mutate({key:qt.START_WORKTREE_TASKS_IMMEDIATELY,value:nv},{onSettled:Pt})}))),v_&&Be.push(new Promise(Pt=>{Se.mutate({key:qt.TIMEZONE,value:f_},{onSettled:Pt})})),Ep&&(Ad!==le&&Be.push(new Promise(Pt=>{Se.mutate({key:qt.ASSISTANT_PROVIDER,value:Ad},{onSettled:Pt})})),rv!==Fe&&Be.push(new Promise(Pt=>{Se.mutate({key:qt.ASSISTANT_MODEL,value:rv},{onSettled:Pt})})),iv!==ve&&Be.push(new Promise(Pt=>{Se.mutate({key:qt.ASSISTANT_OBSERVER_MODEL,value:iv},{onSettled:Pt})})),Tu!==we&&Be.push(new Promise(Pt=>{Se.mutate({key:qt.ASSISTANT_OBSERVER_PROVIDER,value:Tu},{onSettled:Pt})})),sv!==Le&&Be.push(new Promise(Pt=>{Se.mutate({key:qt.ASSISTANT_OBSERVER_OPENCODE_MODEL,value:sv},{onSettled:Pt})})),kg!==qe&&Be.push(new Promise(Pt=>{Se.mutate({key:qt.ASSISTANT_DOCUMENTS_DIR,value:kg},{onSettled:Pt})}))),Cp&&(Tg!==Ie&&Be.push(new Promise(Pt=>{Se.mutate({key:qt.ASSISTANT_RITUALS_ENABLED,value:Tg},{onSettled:Pt})})),av!==Ge&&Be.push(new Promise(Pt=>{Se.mutate({key:qt.ASSISTANT_MORNING_RITUAL_TIME,value:av},{onSettled:Pt})})),ov!==mt&&Be.push(new Promise(Pt=>{Se.mutate({key:qt.ASSISTANT_MORNING_RITUAL_PROMPT,value:ov},{onSettled:Pt})})),lv!==lt&&Be.push(new Promise(Pt=>{Se.mutate({key:qt.ASSISTANT_EVENING_RITUAL_TIME,value:lv},{onSettled:Pt})})),Sp!==Ct&&Be.push(new Promise(Pt=>{Se.mutate({key:qt.ASSISTANT_EVENING_RITUAL_PROMPT,value:Sp},{onSettled:Pt})}))),Nk){const Pt=Y?.cloudflareApiToken??"",bs=Y?.cloudflareAccountId??"",Ca={};Ea!==Pt&&!Ea.match(/^•+$/)&&(Ca.cloudflareApiToken=Ea||null),xp!==bs&&!xp.match(/^•+$/)&&(Ca.cloudflareAccountId=xp||null),Object.keys(Ca).length>0&&Be.push(new Promise(Au=>{q.mutate(Ca,{onSettled:Au})}))}await Promise.all(Be),Bi(!0),setTimeout(()=>Bi(!1),2e3)},Dk=()=>{Oe.mutate(qt.PORT,{onSuccess:Be=>{Be.value!==null&&sn(String(Be.value))}})},Pk=()=>{Oe.mutate(qt.DEFAULT_GIT_REPOS_DIR,{onSuccess:Be=>{Be.value&&vr(String(Be.value))}})},iP=()=>{Oe.mutate(qt.EDITOR_APP,{onSuccess:Be=>{Be.value!==null&&Be.value!==void 0&&oi(Be.value)}})},sP=()=>{Oe.mutate(qt.EDITOR_HOST,{onSuccess:Be=>{xi(Be.value!==null&&Be.value!==void 0?String(Be.value):"")}})},aP=()=>{Oe.mutate(qt.EDITOR_SSH_PORT,{onSuccess:Be=>{Be.value!==null&&Be.value!==void 0&&fr(String(Be.value))}})},oP=()=>{Oe.mutate(qt.GITHUB_PAT,{onSuccess:Be=>{Ai(Be.value!==null&&Be.value!==void 0?String(Be.value):"")}})},lP=()=>{Oe.mutate(qt.DEFAULT_AGENT,{onSuccess:Be=>{An(Be.value??"claude")}})},$o=()=>{Oe.mutate(qt.OPENCODE_MODEL,{onSuccess:Be=>{ss(Be.value!==null&&Be.value!==void 0?String(Be.value):null)}})},Ng=()=>{Oe.mutate(qt.OPENCODE_DEFAULT_AGENT,{onSuccess:Be=>{kr(Be.value??"build")}})},jk=()=>{Oe.mutate(qt.OPENCODE_PLAN_AGENT,{onSuccess:Be=>{hr(Be.value??"plan")}})},Nd=async Be=>{_t.mutate(Be,{onSuccess:Pt=>{Pt.success?rt.success(e("notifications.testSuccess",{channel:Be})):rt.error(e("notifications.testFailed",{channel:Be,error:Pt.error}))},onError:Pt=>{rt.error(e("notifications.testFailed",{channel:Be,error:Pt.message}))}})},Lk=async Be=>{const Pt=Be.target.files?.[0];if(Pt){b_(!0);try{const bs=new FormData;bs.append("file",Pt);const Ca=await fetch("/api/uploads/sound",{method:"POST",body:bs});if(!Ca.ok){const Au=await Ca.json();throw new Error(Au.error||"Upload failed")}cv(!0),rt.success(e("notifications.soundUploaded"))}catch(bs){rt.error(e("notifications.soundUploadFailed",{error:bs instanceof Error?bs.message:"Unknown error"}))}finally{b_(!1),Fc.current&&(Fc.current.value="")}}},Mk=async()=>{try{if(!(await fetch("/api/uploads/sound",{method:"DELETE"})).ok)throw new Error("Delete failed");cv(!1),rt.success(e("notifications.soundDeleted"))}catch{rt.error(e("notifications.soundDeleteFailed"))}},S_=()=>{Et.mutate(void 0,{onSuccess:()=>{rt.info(e("version.updateStarted"))},onError:()=>{rt.error(e("version.updateFailed"))}})};return c.jsxs("div",{className:"flex h-full flex-col",children:[c.jsx("div",{className:"flex-1 overflow-hidden",children:c.jsxs(Jo,{value:i,onValueChange:s,className:"flex h-full flex-col",children:[c.jsxs("div",{className:"film-grain relative flex shrink-0 items-center border-b border-border px-4",style:{background:"var(--gradient-header)"},children:[c.jsxs(el,{className:"justify-start gap-1 bg-transparent rounded-none h-10",children:[c.jsxs(Bn,{value:"general",className:"gap-1.5 data-[state=active]:bg-muted",children:[c.jsx(J,{icon:AO,size:14,strokeWidth:2}),c.jsx("span",{className:"max-sm:hidden",children:e("tabs.general")})]}),c.jsxs(Bn,{value:"ai",className:"gap-1.5 data-[state=active]:bg-muted",children:[c.jsx(J,{icon:L1e,size:14,strokeWidth:2}),c.jsx("span",{className:"max-sm:hidden",children:e("tabs.ai")})]}),c.jsxs(Bn,{value:"messaging",className:"gap-1.5 data-[state=active]:bg-muted",children:[c.jsx(J,{icon:M3,size:14,strokeWidth:2}),c.jsx("span",{className:"max-sm:hidden",children:e("tabs.messaging")})]}),c.jsxs(Bn,{value:"calendar",className:"gap-1.5 data-[state=active]:bg-muted",children:[c.jsx(J,{icon:ng,size:14,strokeWidth:2}),c.jsx("span",{className:"max-sm:hidden",children:e("tabs.calendar")})]})]}),c.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[st&&c.jsxs("span",{className:"text-xs font-mono text-muted-foreground",children:["v",st]}),c.jsx(Ce,{variant:"ghost",size:"icon",className:"h-6 w-6 text-muted-foreground hover:text-foreground",onClick:()=>wt.mutate(),disabled:pt||wt.isPending,title:e("version.refresh"),"aria-label":e("version.refresh"),children:c.jsx(J,{icon:tp,size:14,strokeWidth:2,className:wt.isPending?"animate-spin":""})}),pt&&c.jsxs("div",{className:"flex h-6 items-center gap-1.5 rounded-full bg-muted/50 px-2.5 text-xs text-muted-foreground",children:[c.jsx(J,{icon:Rt,size:12,strokeWidth:2,className:"animate-spin"}),c.jsx("span",{children:e("version.checkingForUpdates")})]}),et?.updateAvailable&&et.latestVersion&&c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsxs("span",{className:"flex h-6 items-center gap-1.5 rounded-full bg-primary/10 px-2.5 text-xs font-medium text-primary border border-primary/20",children:[c.jsx(J,{icon:Oie,size:12,strokeWidth:2.5}),e("version.updateAvailable",{version:et.latestVersion})]}),c.jsx(Ce,{size:"sm",className:"h-6 gap-1.5 px-2.5 text-xs",disabled:Et.isPending||Et.isSuccess,onClick:S_,children:Et.isPending?c.jsxs(c.Fragment,{children:[c.jsx(J,{icon:Rt,size:12,strokeWidth:2,className:"animate-spin"}),e("version.updating")]}):c.jsxs(c.Fragment,{children:[c.jsx(J,{icon:Oie,size:12,strokeWidth:2}),e("version.update")]})}),c.jsx(Ce,{variant:"outline",size:"sm",className:"h-6 gap-1.5 px-2.5 text-xs",onClick:()=>{et.releaseUrl&&window.open(et.releaseUrl,"_blank")},children:e("version.viewRelease")})]}),!pt&&et&&!et.updateAvailable&&c.jsxs("span",{className:"flex h-6 items-center gap-1.5 rounded-full bg-green-500/10 px-2.5 text-xs font-medium text-green-600 dark:text-green-400 border border-green-500/20",children:[c.jsx(J,{icon:cr,size:12,strokeWidth:2.5}),e("version.upToDate")]})]})]}),c.jsx(Un,{value:"general",className:"flex-1 overflow-auto p-6",children:c.jsxs("div",{className:"mx-auto max-w-5xl space-y-4",children:[c.jsx(yl,{title:e("sections.appearance"),children:c.jsxs("div",{className:"space-y-4",children:[c.jsxs("div",{className:"space-y-1",children:[c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[c.jsx("label",{className:"text-sm text-muted-foreground sm:w-32 sm:shrink-0",children:e("fields.language.label")}),c.jsxs(Vr,{value:Q??"auto",onValueChange:Be=>ee(Be==="auto"?null:Be),children:[c.jsx(qr,{className:"w-40",children:c.jsx(Wr,{})}),c.jsxs(Gr,{children:[c.jsx(Kt,{value:"auto",children:e("fields.language.options.auto")}),c.jsx(Kt,{value:"en",children:e("fields.language.options.en")}),c.jsx(Kt,{value:"zh",children:e("fields.language.options.zh")})]})]})]}),c.jsx("p",{className:"text-xs text-muted-foreground sm:ml-32 sm:pl-2",children:e("fields.language.description")})]}),c.jsxs("div",{className:"space-y-1",children:[c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[c.jsx("label",{className:"text-sm text-muted-foreground sm:w-32 sm:shrink-0",children:e("fields.theme.label")}),c.jsxs(Vr,{value:ne??"system",onValueChange:Be=>fe(Be),children:[c.jsx(qr,{className:"w-40",children:c.jsx(Wr,{})}),c.jsxs(Gr,{children:[c.jsx(Kt,{value:"system",children:e("fields.theme.options.system")}),c.jsx(Kt,{value:"light",children:e("fields.theme.options.light")}),c.jsx(Kt,{value:"dark",children:e("fields.theme.options.dark")})]})]})]}),c.jsx("p",{className:"text-xs text-muted-foreground sm:ml-32 sm:pl-2",children:e("fields.theme.description")})]}),c.jsxs("div",{className:"space-y-1",children:[c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[c.jsx("label",{className:"text-sm text-muted-foreground sm:w-32 sm:shrink-0",children:e("fields.timezone.label")}),c.jsxs(Vr,{value:f_??"auto",onValueChange:Be=>bk(Be==="auto"?null:Be),children:[c.jsx(qr,{className:"w-56",children:c.jsx(Wr,{})}),c.jsxs(Gr,{children:[c.jsx(Kt,{value:"auto",children:e("fields.timezone.options.auto")}),c.jsx(Kt,{value:"America/New_York",children:"America/New_York (EST/EDT)"}),c.jsx(Kt,{value:"America/Chicago",children:"America/Chicago (CST/CDT)"}),c.jsx(Kt,{value:"America/Denver",children:"America/Denver (MST/MDT)"}),c.jsx(Kt,{value:"America/Los_Angeles",children:"America/Los_Angeles (PST/PDT)"}),c.jsx(Kt,{value:"America/Anchorage",children:"America/Anchorage (AKST/AKDT)"}),c.jsx(Kt,{value:"Pacific/Honolulu",children:"Pacific/Honolulu (HST)"}),c.jsx(Kt,{value:"Europe/London",children:"Europe/London (GMT/BST)"}),c.jsx(Kt,{value:"Europe/Paris",children:"Europe/Paris (CET/CEST)"}),c.jsx(Kt,{value:"Europe/Berlin",children:"Europe/Berlin (CET/CEST)"}),c.jsx(Kt,{value:"Asia/Tokyo",children:"Asia/Tokyo (JST)"}),c.jsx(Kt,{value:"Asia/Shanghai",children:"Asia/Shanghai (CST)"}),c.jsx(Kt,{value:"Asia/Singapore",children:"Asia/Singapore (SGT)"}),c.jsx(Kt,{value:"Australia/Sydney",children:"Australia/Sydney (AEST/AEDT)"}),c.jsx(Kt,{value:"Pacific/Auckland",children:"Pacific/Auckland (NZST/NZDT)"}),c.jsx(Kt,{value:"UTC",children:"UTC"})]})]})]}),c.jsx("p",{className:"text-xs text-muted-foreground sm:ml-32 sm:pl-2",children:e("fields.timezone.description")})]}),c.jsxs("div",{className:"space-y-1",children:[c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[c.jsx("label",{className:"text-sm text-muted-foreground sm:w-32 sm:shrink-0",children:e("fields.syncClaudeTheme.label")}),c.jsx(Dr,{checked:zf,onCheckedChange:_p})]}),c.jsx("p",{className:"text-xs text-muted-foreground sm:ml-32 sm:pl-2",children:e("fields.syncClaudeTheme.description")})]}),zf&&c.jsxs("div",{className:"space-y-3 border-t border-border pt-4 sm:ml-32 sm:pl-2",children:[c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[c.jsx("label",{className:"text-sm text-muted-foreground sm:w-24 sm:shrink-0",children:e("fields.claudeCodeTheme.light")}),c.jsxs(Vr,{value:Hf,onValueChange:Be=>d_(Be),children:[c.jsx(qr,{className:"w-40",children:c.jsx(Wr,{})}),c.jsx(Gr,{children:Zie.filter(Be=>Be.startsWith("light")).map(Be=>c.jsx(Kt,{value:Be,children:e(`fields.claudeCodeTheme.options.${Be}`)},Be))})]})]}),c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[c.jsx("label",{className:"text-sm text-muted-foreground sm:w-24 sm:shrink-0",children:e("fields.claudeCodeTheme.dark")}),c.jsxs(Vr,{value:Jy,onValueChange:Be=>mk(Be),children:[c.jsx(qr,{className:"w-40",children:c.jsx(Wr,{})}),c.jsx(Gr,{children:Zie.filter(Be=>Be.startsWith("dark")).map(Be=>c.jsx(Kt,{value:Be,children:e(`fields.claudeCodeTheme.options.${Be}`)},Be))})]})]})]})]})}),c.jsxs("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-2",children:[c.jsx(yl,{title:e("sections.editor"),children:c.jsxs("div",{className:"space-y-4",children:[c.jsxs("div",{className:"space-y-1",children:[c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[c.jsx("label",{className:"text-sm text-muted-foreground sm:w-20 sm:shrink-0",children:e("fields.editor.app.label")}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsxs(Vr,{value:Mr,onValueChange:Be=>oi(Be),children:[c.jsx(qr,{className:"w-32",children:c.jsx(Wr,{})}),c.jsxs(Gr,{children:[c.jsx(Kt,{value:"vscode",children:"VS Code"}),c.jsx(Kt,{value:"cursor",children:"Cursor"}),c.jsx(Kt,{value:"windsurf",children:"Windsurf"}),c.jsx(Kt,{value:"zed",children:"Zed"}),c.jsx(Kt,{value:"antigravity",children:"Antigravity"})]})]}),c.jsx(Ce,{variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-foreground",onClick:iP,disabled:en||Oe.isPending,title:t("buttons.reset"),children:c.jsx(J,{icon:Pd,size:14,strokeWidth:2})})]})]}),c.jsx("p",{className:"text-xs text-muted-foreground sm:ml-20 sm:pl-2",children:e("fields.editor.app.description")})]}),c.jsxs("div",{className:"space-y-1",children:[c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[c.jsx("label",{className:"text-sm text-muted-foreground sm:w-20 sm:shrink-0",children:e("fields.editor.host.label")}),c.jsxs("div",{className:"flex flex-1 items-center gap-2",children:[c.jsx(kt,{value:gs,onChange:Be=>xi(Be.target.value),placeholder:e("fields.editor.host.placeholder"),disabled:en,className:"flex-1 font-mono text-sm"}),c.jsx(Ce,{variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-foreground",onClick:sP,disabled:en||Oe.isPending,title:t("buttons.reset"),children:c.jsx(J,{icon:Pd,size:14,strokeWidth:2})})]})]}),c.jsx("p",{className:"text-xs text-muted-foreground sm:ml-20 sm:pl-2",children:e("fields.editor.host.description")})]}),c.jsxs("div",{className:"space-y-1",children:[c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[c.jsx("label",{className:"text-sm text-muted-foreground sm:w-20 sm:shrink-0",children:e("fields.editor.sshPort.label")}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(kt,{type:"number",min:1,max:65535,value:dr,onChange:Be=>fr(Be.target.value),placeholder:"22",disabled:en,className:"w-20 font-mono text-sm"}),c.jsx(Ce,{variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-foreground",onClick:aP,disabled:en||Oe.isPending,title:t("buttons.reset"),children:c.jsx(J,{icon:Pd,size:14,strokeWidth:2})})]})]}),c.jsx("p",{className:"text-xs text-muted-foreground sm:ml-20 sm:pl-2",children:e("fields.editor.sshPort.description")})]})]})}),c.jsx(yl,{title:e("sections.integrations"),children:c.jsxs("div",{className:"space-y-4",children:[c.jsxs("div",{className:"space-y-1",children:[c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[c.jsx("label",{className:"text-sm text-muted-foreground sm:w-20 sm:shrink-0",children:e("fields.github.label")}),c.jsxs("div",{className:"flex flex-1 items-center gap-2",children:[c.jsxs("div",{className:"relative flex-1",children:[c.jsx(kt,{type:"password",value:Fi,onChange:Be=>Ai(Be.target.value),placeholder:"ghp_...",disabled:en,className:"flex-1 pr-8 font-mono text-sm"}),!!v&&c.jsx("div",{className:"absolute right-2 top-1/2 -translate-y-1/2 text-green-500",children:c.jsx(J,{icon:cr,size:14,strokeWidth:2})})]}),c.jsx(Ce,{variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-foreground",onClick:oP,disabled:en||Oe.isPending,title:t("buttons.reset"),children:c.jsx(J,{icon:Pd,size:14,strokeWidth:2})})]})]}),c.jsx("p",{className:"text-xs text-muted-foreground sm:ml-20 sm:pl-2",children:e("fields.github.description")})]}),c.jsxs("div",{className:"space-y-1",children:[c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[c.jsx("label",{className:"text-sm text-muted-foreground sm:w-20 sm:shrink-0",children:e("fields.cloudflare.label")}),c.jsx("div",{className:"flex flex-1 items-center gap-2",children:c.jsxs("div",{className:"relative flex-1",children:[c.jsx(kt,{type:"password",value:Ea,onChange:Be=>vp(Be.target.value),placeholder:e("fields.cloudflare.placeholder"),disabled:en,className:"flex-1 pr-8 font-mono text-sm"}),!!Y?.cloudflareApiToken&&c.jsx("div",{className:"absolute right-2 top-1/2 -translate-y-1/2 text-green-500",children:c.jsx(J,{icon:cr,size:14,strokeWidth:2})})]})})]}),c.jsx("p",{className:"text-xs text-muted-foreground sm:ml-20 sm:pl-2",children:e("fields.cloudflare.description")})]}),c.jsxs("div",{className:"space-y-1",children:[c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[c.jsx("label",{className:"text-sm text-muted-foreground sm:w-20 sm:shrink-0",children:"Account ID"}),c.jsx("div",{className:"flex flex-1 items-center gap-2",children:c.jsxs("div",{className:"relative flex-1",children:[c.jsx(kt,{type:"password",value:xp,onChange:Be=>Qy(Be.target.value),placeholder:"CF Account ID",disabled:en,className:"flex-1 pr-8 font-mono text-sm"}),!!Y?.cloudflareAccountId&&c.jsx("div",{className:"absolute right-2 top-1/2 -translate-y-1/2 text-green-500",children:c.jsx(J,{icon:cr,size:14,strokeWidth:2})})]})})]}),c.jsxs("p",{className:"text-xs text-muted-foreground sm:ml-20 sm:pl-2",children:["Required for Cloudflare Tunnel. Find in your dashboard URL: dash.cloudflare.com/","<account_id>","/..."]})]}),c.jsx(bAt,{clientId:Ki,onClientIdChange:vo,clientIdSaved:!!w,clientSecret:Yi,onClientSecretChange:tt,clientSecretSaved:!!C,isLoading:en,onSaveCredentials:__})]})})]}),c.jsx(yl,{title:e("sections.tasks"),children:c.jsxs("div",{className:"space-y-4",children:[c.jsxs("div",{className:"space-y-1",children:[c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[c.jsx("label",{className:"text-sm text-muted-foreground sm:w-32 sm:shrink-0",children:e("fields.tasks.defaultType.label")}),c.jsxs(Vr,{value:ev,onValueChange:Be=>tv(Be),children:[c.jsx(qr,{className:"w-40",children:c.jsx(Wr,{})}),c.jsxs(Gr,{children:[c.jsx(Kt,{value:"worktree",children:e("fields.tasks.defaultType.options.worktree")}),c.jsx(Kt,{value:"non-worktree",children:e("fields.tasks.defaultType.options.nonWorktree")})]})]})]}),c.jsx("p",{className:"text-xs text-muted-foreground sm:ml-32 sm:pl-2",children:e("fields.tasks.defaultType.description")})]}),c.jsxs("div",{className:"space-y-1",children:[c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[c.jsx("label",{className:"text-sm text-muted-foreground sm:w-32 sm:shrink-0",children:e("fields.tasks.startImmediately.label")}),c.jsx(Dr,{checked:nv,onCheckedChange:gk,disabled:en})]}),c.jsx("p",{className:"text-xs text-muted-foreground sm:ml-32 sm:pl-2",children:e("fields.tasks.startImmediately.description")})]})]})}),c.jsx(yl,{title:e("sections.server"),children:c.jsxs("div",{className:"space-y-1",children:[c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[c.jsx("label",{className:"text-sm text-muted-foreground sm:w-32 sm:shrink-0",children:e("fields.port.label")}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(kt,{type:"number",min:1,max:65535,value:zt,onChange:Be=>sn(Be.target.value),placeholder:"7777",disabled:en,className:"w-24 font-mono text-sm"}),c.jsx(Ce,{variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-foreground",onClick:Dk,disabled:en||Oe.isPending,title:t("buttons.reset"),children:c.jsx(J,{icon:Pd,size:14,strokeWidth:2})})]})]}),c.jsx("p",{className:"text-xs text-muted-foreground sm:ml-32 sm:pl-2",children:e("fields.port.description")})]})}),c.jsx(yl,{title:e("sections.paths"),children:c.jsxs("div",{className:"space-y-1",children:[c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[c.jsx("label",{className:"text-sm text-muted-foreground sm:w-32 sm:shrink-0",children:e("fields.gitReposDir.label")}),c.jsxs("div",{className:"flex flex-1 items-center gap-2",children:[c.jsx(kt,{value:Ln,onChange:Be=>vr(Be.target.value),placeholder:"~/projects",disabled:en,className:"flex-1 font-mono text-sm"}),c.jsx(Ce,{variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-foreground",onClick:()=>Wt(!0),disabled:en,title:t("buttons.browse"),children:c.jsx(J,{icon:$a,size:14,strokeWidth:2})}),c.jsx(Ce,{variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-foreground",onClick:Pk,disabled:en||Oe.isPending,title:t("buttons.reset"),children:c.jsx(J,{icon:Pd,size:14,strokeWidth:2})})]})]}),c.jsx("p",{className:"text-xs text-muted-foreground sm:ml-32 sm:pl-2",children:e("fields.gitReposDir.description")})]})}),X?.enabled&&c.jsx(yl,{title:e("sections.developer"),children:c.jsx("div",{className:"space-y-1",children:c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between",children:[c.jsx("div",{className:"flex-1",children:c.jsx("p",{className:"text-sm text-muted-foreground",children:e("developer.restartDescription")})}),c.jsxs(Ce,{variant:"outline",size:"sm",onClick:()=>{const Be=X?.startedAt;uv(!0),z.mutate(void 0,{onSuccess:()=>{(async()=>{for(let Ca=0;Ca<120;Ca++){await new Promise(Au=>setTimeout(Au,500));try{const Au=await fetch("/api/config/developer-mode");if(Au.ok&&(await Au.json()).startedAt!==Be){window.location.reload();return}}catch{}}uv(!1),rt.error(e("developer.restartFailed"),{description:e("developer.checkLogs")})})()},onError:Pt=>{uv(!1),rt.error(e("developer.restartFailed"),{description:Pt.message})}})},disabled:z.isPending||p_,className:"shrink-0 gap-2",children:[(z.isPending||p_)&&c.jsx(J,{icon:Rt,size:14,strokeWidth:2,className:"animate-spin"}),e(p_?"developer.restarting":"developer.restartButton")]})]})})})]})}),c.jsx(Un,{value:"ai",className:"flex-1 overflow-auto p-6",children:c.jsxs("div",{className:"mx-auto max-w-5xl space-y-4",children:[c.jsxs(yl,{title:e("sections.agent"),children:[c.jsxs("div",{className:"space-y-4",children:[c.jsxs("div",{className:"space-y-1",children:[c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[c.jsx("label",{className:"text-sm text-muted-foreground sm:w-32 sm:shrink-0",children:e("fields.agent.default.label")}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsxs(Vr,{value:Mn,onValueChange:Be=>An(Be),children:[c.jsx(qr,{className:"w-40",children:c.jsx(Wr,{})}),c.jsx(Gr,{children:Object.keys(Ua).map(Be=>c.jsx(Kt,{value:Be,children:Ua[Be]},Be))})]}),c.jsx(Ce,{variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-foreground",onClick:lP,disabled:en||Oe.isPending,title:t("buttons.reset"),children:c.jsx(J,{icon:Pd,size:14,strokeWidth:2})})]})]}),c.jsx("p",{className:"text-xs text-muted-foreground sm:ml-32 sm:pl-2",children:e("fields.agent.default.description")})]}),c.jsxs("div",{className:"space-y-1",children:[c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[c.jsx("label",{className:"text-sm text-muted-foreground sm:w-32 sm:shrink-0",children:e("fields.agent.opencodeModel.label")}),c.jsxs("div",{className:"flex flex-1 items-center gap-2",children:[c.jsx(Bb,{value:Fr,onChange:ss,placeholder:e("fields.agent.opencodeModel.placeholder"),className:"w-64"}),c.jsx(Ce,{variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-foreground",onClick:$o,disabled:en||Oe.isPending,title:t("buttons.reset"),children:c.jsx(J,{icon:Pd,size:14,strokeWidth:2})})]})]}),c.jsx("p",{className:"text-xs text-muted-foreground sm:ml-32 sm:pl-2",children:e("fields.agent.opencodeModel.description")})]})]}),c.jsxs(pg,{className:"mt-4 space-y-1",children:[c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-start",children:[c.jsxs(mg,{className:"group flex cursor-pointer items-center gap-1.5 text-left text-sm text-muted-foreground transition-colors hover:text-foreground sm:w-32 sm:shrink-0",children:[c.jsx(J,{icon:Do,size:12,strokeWidth:2,className:"shrink-0 transition-transform duration-200 group-data-[state=open]:rotate-180"}),c.jsx("span",{children:e("fields.agent.advancedAgentNames.label")})]}),c.jsx("p",{className:"text-xs text-muted-foreground sm:pt-0.5",children:e("fields.agent.advancedAgentNames.description")})]}),c.jsxs(gg,{className:"space-y-4 pt-2 sm:ml-32 sm:pl-2",children:[c.jsxs("div",{className:"flex items-start gap-2 rounded-md border border-amber-500/20 bg-amber-500/10 p-3",children:[c.jsx(J,{icon:Pr,size:16,strokeWidth:2,className:"mt-0.5 shrink-0 text-amber-600 dark:text-amber-400"}),c.jsx("p",{className:"text-xs text-amber-600 dark:text-amber-400",children:e("fields.agent.advancedAgentNames.warning")})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[c.jsx("label",{className:"text-sm text-muted-foreground sm:w-32 sm:shrink-0",children:e("fields.agent.opencodeDefaultAgent.label")}),c.jsxs("div",{className:"flex flex-1 items-center gap-2",children:[c.jsx(kt,{value:li??"build",onChange:Be=>kr(Be.target.value),placeholder:"build",disabled:en,className:"font-mono text-sm"}),c.jsx(Ce,{variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-foreground",onClick:Ng,disabled:en||Oe.isPending,title:t("buttons.reset"),children:c.jsx(J,{icon:Pd,size:14,strokeWidth:2})})]})]}),c.jsx("p",{className:"text-xs text-muted-foreground sm:ml-32 sm:pl-2",children:e("fields.agent.opencodeDefaultAgent.description")})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[c.jsx("label",{className:"text-sm text-muted-foreground sm:w-32 sm:shrink-0",children:e("fields.agent.opencodePlanAgent.label")}),c.jsxs("div",{className:"flex flex-1 items-center gap-2",children:[c.jsx(kt,{value:ei??"plan",onChange:Be=>hr(Be.target.value),placeholder:"plan",disabled:en,className:"font-mono text-sm"}),c.jsx(Ce,{variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-foreground",onClick:jk,disabled:en||Oe.isPending,title:t("buttons.reset"),children:c.jsx(J,{icon:Pd,size:14,strokeWidth:2})})]})]}),c.jsx("p",{className:"text-xs text-muted-foreground sm:ml-32 sm:pl-2",children:e("fields.agent.opencodePlanAgent.description")})]})]})]}),c.jsxs("div",{className:"mt-4 space-y-1 border-t border-border pt-4",children:[c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[c.jsx("label",{className:"text-sm text-muted-foreground sm:w-32 sm:shrink-0",children:e("fields.agent.autoScrollToBottom.label")}),c.jsx(Dr,{checked:Br,onCheckedChange:Xi,disabled:en})]}),c.jsx("p",{className:"text-xs text-muted-foreground sm:ml-32 sm:pl-2",children:e("fields.agent.autoScrollToBottom.description")})]}),c.jsxs("div",{className:"mt-4 space-y-1 border-t border-border pt-4",children:[c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[c.jsx("label",{className:"text-sm text-muted-foreground sm:w-32 sm:shrink-0",children:e("fields.agent.claudeCodePath.label")}),c.jsx(kt,{value:Fo,onChange:Be=>Gt(Be.target.value),placeholder:e("fields.agent.claudeCodePath.placeholder"),className:"flex-1",disabled:en})]}),c.jsx("p",{className:"text-xs text-muted-foreground sm:ml-32 sm:pl-2",children:e("fields.agent.claudeCodePath.description")})]})]}),c.jsx(yl,{title:e("sections.assistant"),children:c.jsxs("div",{className:"space-y-4",children:[c.jsxs("div",{className:"grid gap-4 md:grid-cols-2 md:gap-x-8",children:[c.jsxs("div",{className:"space-y-4",children:[c.jsxs("div",{className:"space-y-1",children:[c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[c.jsx("label",{className:"text-sm text-muted-foreground sm:w-32 sm:shrink-0",children:e("fields.assistant.provider.label")}),c.jsxs(Vr,{value:Ad,onValueChange:Be=>h_(Be),children:[c.jsx(qr,{className:"w-48",children:c.jsx(Wr,{})}),c.jsxs(Gr,{children:[c.jsx(Kt,{value:"claude",children:"Claude"}),Ue&&c.jsx(Kt,{value:"opencode",children:"OpenCode"})]})]})]}),c.jsx("p",{className:"text-xs text-muted-foreground sm:ml-32 sm:pl-2",children:e("fields.assistant.provider.description")})]}),Ad==="claude"&&c.jsxs("div",{className:"space-y-1",children:[c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[c.jsx("label",{className:"text-sm text-muted-foreground sm:w-32 sm:shrink-0",children:e("fields.assistant.model.label")}),c.jsxs(Vr,{value:rv,onValueChange:Be=>yk(Be),children:[c.jsx(qr,{className:"w-48",children:c.jsx(Wr,{})}),c.jsx(Gr,{children:Qie.map(Be=>c.jsx(Kt,{value:Be,children:e(`fields.assistant.model.options.${Be}`)},Be))})]})]}),c.jsx("p",{className:"text-xs text-muted-foreground sm:ml-32 sm:pl-2",children:e("fields.assistant.model.description")})]}),Ad==="opencode"&&c.jsxs("div",{className:"space-y-1",children:[c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[c.jsx("label",{className:"text-sm text-muted-foreground sm:w-32 sm:shrink-0",children:e("fields.assistant.opencodeModel.label")}),c.jsx(Bb,{value:S,onChange:Be=>{Se.mutate({key:qt.OPENCODE_MODEL,value:Be})},placeholder:e("fields.assistant.opencodeModel.placeholder"),className:"w-64"})]}),c.jsx("p",{className:"text-xs text-muted-foreground sm:ml-32 sm:pl-2",children:e("fields.assistant.opencodeModel.description")})]})]}),c.jsxs("div",{className:"space-y-4",children:[c.jsxs("div",{className:"space-y-1",children:[c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[c.jsx("label",{className:"text-sm text-muted-foreground sm:w-32 sm:shrink-0",children:e("fields.assistant.observerProvider.label")}),c.jsxs(Vr,{value:Tu??"same-as-main",onValueChange:Be=>xk(Be==="same-as-main"?null:Be),children:[c.jsx(qr,{className:"w-48",children:c.jsx(Wr,{})}),c.jsxs(Gr,{children:[c.jsx(Kt,{value:"same-as-main",children:e("fields.assistant.observerProvider.options.default")}),c.jsx(Kt,{value:"claude",children:"Claude"}),Ue&&c.jsx(Kt,{value:"opencode",children:"OpenCode"})]})]})]}),c.jsx("p",{className:"text-xs text-muted-foreground sm:ml-32 sm:pl-2",children:e("fields.assistant.observerProvider.description")})]}),(Tu==="claude"||Tu===null&&Ad==="claude")&&c.jsxs("div",{className:"space-y-1",children:[c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[c.jsx("label",{className:"text-sm text-muted-foreground sm:w-32 sm:shrink-0",children:e("fields.assistant.observerModel.label")}),c.jsxs(Vr,{value:iv,onValueChange:Be=>vk(Be),children:[c.jsx(qr,{className:"w-48",children:c.jsx(Wr,{})}),c.jsx(Gr,{children:Qie.map(Be=>c.jsx(Kt,{value:Be,children:e(`fields.assistant.observerModel.options.${Be}`)},Be))})]})]}),c.jsx("p",{className:"text-xs text-muted-foreground sm:ml-32 sm:pl-2",children:e("fields.assistant.observerModel.description")})]}),(Tu==="opencode"||Tu===null&&Ad==="opencode")&&Ue&&c.jsxs("div",{className:"space-y-1",children:[c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[c.jsx("label",{className:"text-sm text-muted-foreground sm:w-32 sm:shrink-0",children:e("fields.assistant.observerOpencodeModel.label")}),c.jsx(Bb,{value:sv,onChange:Be=>_k(Be),placeholder:e("fields.assistant.observerOpencodeModel.placeholder"),className:"w-64"})]}),c.jsx("p",{className:"text-xs text-muted-foreground sm:ml-32 sm:pl-2",children:e("fields.assistant.observerOpencodeModel.description")})]})]})]}),c.jsxs("div",{className:"space-y-1",children:[c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[c.jsx("label",{className:"text-sm text-muted-foreground sm:w-32 sm:shrink-0",children:e("fields.assistant.customInstructions.label")}),c.jsx(ai,{to:"/assistant",search:{tab:"memory"},children:c.jsx(Ce,{variant:"outline",size:"sm",children:e("fields.assistant.customInstructions.openMemoryFile")})})]}),c.jsx("p",{className:"text-xs text-muted-foreground sm:ml-32 sm:pl-2",children:e("fields.assistant.customInstructions.memoryDescription")})]}),c.jsxs("div",{className:"space-y-1",children:[c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[c.jsx("label",{className:"text-sm text-muted-foreground sm:w-32 sm:shrink-0",children:e("fields.assistant.documentsDir.label")}),c.jsx(kt,{value:kg,onChange:Be=>Sk(Be.target.value),placeholder:"~/.fulcrum/documents",disabled:en,className:"w-64 font-mono text-sm"})]}),c.jsx("p",{className:"text-xs text-muted-foreground sm:ml-32 sm:pl-2",children:e("fields.assistant.documentsDir.description")})]}),c.jsxs("div",{className:"border-t border-border pt-4 space-y-1",children:[c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[c.jsx("label",{className:"text-sm text-muted-foreground sm:w-32 sm:shrink-0",children:e("concierge.rituals")}),c.jsx(Dr,{checked:Tg,onCheckedChange:wk,disabled:en})]}),c.jsx("p",{className:"text-xs text-muted-foreground sm:ml-32 sm:pl-2",children:e("concierge.ritualsDescription")})]}),Tg&&c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"space-y-3",children:[c.jsxs("div",{className:"space-y-1",children:[c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[c.jsx("label",{className:"text-sm text-muted-foreground sm:w-32 sm:shrink-0",children:e("concierge.morningRitual")}),c.jsx(kt,{type:"time",value:av,onChange:Be=>Ek(Be.target.value),disabled:en,className:"w-32"})]}),c.jsx("p",{className:"text-xs text-muted-foreground sm:ml-32 sm:pl-2",children:e("concierge.morningRitualDescription")})]}),c.jsx("div",{className:"sm:ml-32 sm:pl-2",children:c.jsx(dd,{value:ov,onChange:Be=>Ck(Be.target.value),placeholder:e("concierge.morningRitualPromptPlaceholder"),disabled:en,className:"min-h-[80px] text-sm"})})]}),c.jsxs("div",{className:"space-y-3",children:[c.jsxs("div",{className:"space-y-1",children:[c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[c.jsx("label",{className:"text-sm text-muted-foreground sm:w-32 sm:shrink-0",children:e("concierge.eveningRitual")}),c.jsx(kt,{type:"time",value:lv,onChange:Be=>kk(Be.target.value),disabled:en,className:"w-32"})]}),c.jsx("p",{className:"text-xs text-muted-foreground sm:ml-32 sm:pl-2",children:e("concierge.eveningRitualDescription")})]}),c.jsx("div",{className:"sm:ml-32 sm:pl-2",children:c.jsx(dd,{value:Sp,onChange:Be=>wp(Be.target.value),placeholder:e("concierge.eveningRitualPromptPlaceholder"),disabled:en,className:"min-h-[80px] text-sm"})})]})]})]})}),c.jsx(yl,{title:e("sections.zai"),children:c.jsxs("div",{className:"space-y-4",children:[c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[c.jsx("label",{className:"text-sm text-muted-foreground sm:w-20 sm:shrink-0",children:e("fields.zai.enable")}),c.jsx(Dr,{checked:Tt,onCheckedChange:Lt,disabled:en})]}),Tt&&c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"space-y-1",children:[c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[c.jsx("label",{className:"text-sm text-muted-foreground sm:w-20 sm:shrink-0",children:e("fields.zai.apiKey")}),c.jsxs("div",{className:"relative flex-1",children:[c.jsx(kt,{type:"password",value:Cn,onChange:Be=>Fn(Be.target.value),placeholder:"zai_...",disabled:en,className:"flex-1 pr-8 font-mono text-sm"}),!!U?.apiKey&&c.jsx("div",{className:"absolute right-2 top-1/2 -translate-y-1/2 text-green-500",children:c.jsx(J,{icon:cr,size:14,strokeWidth:2})})]})]}),c.jsx("p",{className:"text-xs text-muted-foreground sm:ml-20 sm:pl-2",children:e("fields.zai.description")})]}),c.jsxs("div",{className:"space-y-3 border-t border-border pt-4",children:[c.jsx("p",{className:"text-xs font-medium text-muted-foreground",children:e("fields.zai.modelMappings")}),c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[c.jsx("label",{className:"text-sm text-muted-foreground sm:w-20 sm:shrink-0",children:e("fields.zai.haiku")}),c.jsx(kt,{value:Ur,onChange:Be=>Zi(Be.target.value),placeholder:"glm-4.5-air",disabled:en,className:"flex-1 font-mono text-sm"})]}),c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[c.jsx("label",{className:"text-sm text-muted-foreground sm:w-20 sm:shrink-0",children:e("fields.zai.sonnet")}),c.jsx(kt,{value:cl,onChange:Be=>ku(Be.target.value),placeholder:"glm-4.7",disabled:en,className:"flex-1 font-mono text-sm"})]}),c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[c.jsx("label",{className:"text-sm text-muted-foreground sm:w-20 sm:shrink-0",children:e("fields.zai.opus")}),c.jsx(kt,{value:os,onChange:Be=>Qa(Be.target.value),placeholder:"glm-4.7",disabled:en,className:"flex-1 font-mono text-sm"})]})]})]})]})})]})}),c.jsx(Un,{value:"messaging",className:"flex-1 overflow-auto p-6",children:c.jsxs("div",{className:"mx-auto max-w-5xl space-y-4",children:[c.jsx(yl,{title:e("sections.notifications"),children:c.jsxs("div",{className:"space-y-4",children:[c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[c.jsx("label",{className:"text-sm text-muted-foreground sm:w-40 sm:shrink-0",children:e("notifications.enable")}),c.jsx(Dr,{checked:In,onCheckedChange:As,disabled:en})]}),c.jsxs("div",{className:"space-y-2 pl-4",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(Dr,{checked:wu,onCheckedChange:Ya,disabled:en||!In}),c.jsx("label",{className:"text-sm text-muted-foreground",children:e("notifications.toast")})]}),c.jsx("p",{className:"ml-10 text-xs text-muted-foreground",children:e("notifications.toastDescription")})]}),c.jsxs("div",{className:"space-y-2 pl-4",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(Dr,{checked:Sa,onCheckedChange:Eu,disabled:en||!In}),c.jsx("label",{className:"text-sm text-muted-foreground",children:e("notifications.desktop")})]}),c.jsx("p",{className:"ml-10 text-xs text-muted-foreground",children:e("notifications.desktopDescription")})]}),c.jsxs("div",{className:"space-y-2 pl-4",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(Dr,{checked:$i,onCheckedChange:Ns,disabled:en||!In}),c.jsx("label",{className:"text-sm text-muted-foreground",children:e("notifications.sound")}),c.jsxs("div",{className:"ml-auto flex items-center gap-1",children:[c.jsx("input",{ref:Fc,type:"file",accept:"audio/mpeg,audio/mp3,audio/wav,audio/ogg",className:"hidden",onChange:Lk}),c.jsx(Ce,{variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-foreground",onClick:()=>Fc.current?.click(),disabled:en||!In||!$i||g_,title:e("notifications.uploadSound"),children:g_?c.jsx(J,{icon:Rt,size:14,strokeWidth:2,className:"animate-spin"}):c.jsx(J,{icon:y$e,size:14,strokeWidth:2})}),m_&&c.jsx(Ce,{variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-destructive",onClick:Mk,disabled:en||!In||!$i,title:e("notifications.deleteSound"),children:c.jsx(J,{icon:ma,size:14,strokeWidth:2})}),c.jsx(Ce,{variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-foreground",onClick:()=>Nd("sound"),disabled:en||!In||!$i||_t.isPending,title:e("notifications.testSound"),children:_t.isPending?c.jsx(J,{icon:Rt,size:14,strokeWidth:2,className:"animate-spin"}):c.jsx(J,{icon:nm,size:14,strokeWidth:2})})]})]}),m_&&c.jsx("p",{className:"ml-10 text-xs text-muted-foreground",children:e("notifications.customSoundActive")})]}),c.jsxs("div",{className:"space-y-2 pl-4",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(Dr,{checked:as,onCheckedChange:Lc,disabled:en||!In}),c.jsx("label",{className:"text-sm text-muted-foreground",children:e("notifications.slack")}),c.jsx(Ce,{variant:"ghost",size:"icon",className:"ml-auto h-8 w-8 text-muted-foreground hover:text-foreground",onClick:()=>Nd("slack"),disabled:en||!In||!as||!Mc&&!oe||_t.isPending,title:e("notifications.slack"),children:_t.isPending?c.jsx(J,{icon:Rt,size:14,strokeWidth:2,className:"animate-spin"}):c.jsx(J,{icon:nm,size:14,strokeWidth:2})})]}),as&&c.jsxs("div",{className:"ml-6 space-y-2",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(Dr,{checked:oe,onCheckedChange:_e,disabled:en||!In||!as}),c.jsx("label",{className:"text-xs text-muted-foreground",children:e("notifications.useMessagingChannel")||"Use messaging channel"})]}),!oe&&c.jsxs("div",{className:"relative",children:[c.jsx(kt,{type:"password",value:Mc,onChange:Be=>Td(Be.target.value),placeholder:"https://hooks.slack.com/services/...",disabled:en||!In,className:"flex-1 pr-8 font-mono text-sm"}),!!M?.slack?.webhookUrl&&c.jsx("div",{className:"absolute right-2 top-1/2 -translate-y-1/2 text-green-500",children:c.jsx(J,{icon:cr,size:14,strokeWidth:2})})]}),oe&&c.jsx("p",{className:"text-xs text-muted-foreground",children:e("notifications.messagingChannelNote")||"Sends via connected Slack messaging channel"})]})]}),c.jsxs("div",{className:"space-y-2 pl-4",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(Dr,{checked:Xa,onCheckedChange:Uf,disabled:en||!In}),c.jsx("label",{className:"text-sm text-muted-foreground",children:e("notifications.discord")}),c.jsx(Ce,{variant:"ghost",size:"icon",className:"ml-auto h-8 w-8 text-muted-foreground hover:text-foreground",onClick:()=>Nd("discord"),disabled:en||!In||!Xa||!Vt&&!He||_t.isPending,title:e("notifications.discord"),children:_t.isPending?c.jsx(J,{icon:Rt,size:14,strokeWidth:2,className:"animate-spin"}):c.jsx(J,{icon:nm,size:14,strokeWidth:2})})]}),Xa&&c.jsxs("div",{className:"ml-6 space-y-2",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(Dr,{checked:He,onCheckedChange:Xe,disabled:en||!In||!Xa}),c.jsx("label",{className:"text-xs text-muted-foreground",children:e("notifications.useMessagingChannel")||"Use messaging channel"})]}),!He&&c.jsxs("div",{className:"relative",children:[c.jsx(kt,{type:"password",value:Vt,onChange:Be=>dn(Be.target.value),placeholder:"https://discord.com/api/webhooks/...",disabled:en||!In,className:"flex-1 pr-8 font-mono text-sm"}),!!M?.discord?.webhookUrl&&c.jsx("div",{className:"absolute right-2 top-1/2 -translate-y-1/2 text-green-500",children:c.jsx(J,{icon:cr,size:14,strokeWidth:2})})]}),He&&c.jsx("p",{className:"text-xs text-muted-foreground",children:e("notifications.messagingChannelNote")||"Sends via connected Discord messaging channel"})]})]}),c.jsxs("div",{className:"space-y-2 pl-4",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(Dr,{checked:On,onCheckedChange:$r,disabled:en||!In}),c.jsx("label",{className:"text-sm text-muted-foreground",children:e("notifications.pushover")}),c.jsx(Ce,{variant:"ghost",size:"icon",className:"ml-auto h-8 w-8 text-muted-foreground hover:text-foreground",onClick:()=>Nd("pushover"),disabled:en||!In||!On||!Rr||!xo||_t.isPending,title:e("notifications.pushover"),children:_t.isPending?c.jsx(J,{icon:Rt,size:14,strokeWidth:2,className:"animate-spin"}):c.jsx(J,{icon:nm,size:14,strokeWidth:2})})]}),On&&c.jsxs("div",{className:"ml-6 space-y-2",children:[c.jsxs("div",{className:"relative",children:[c.jsx(kt,{type:"password",value:Rr,onChange:Be=>_n(Be.target.value),placeholder:e("notifications.appToken"),disabled:en||!In,className:"flex-1 pr-8 font-mono text-sm"}),!!M?.pushover?.appToken&&c.jsx("div",{className:"absolute right-2 top-1/2 -translate-y-1/2 text-green-500",children:c.jsx(J,{icon:cr,size:14,strokeWidth:2})})]}),c.jsxs("div",{className:"relative",children:[c.jsx(kt,{type:"password",value:xo,onChange:Be=>Bo(Be.target.value),placeholder:e("notifications.userKey"),disabled:en||!In,className:"flex-1 pr-8 font-mono text-sm"}),!!M?.pushover?.userKey&&c.jsx("div",{className:"absolute right-2 top-1/2 -translate-y-1/2 text-green-500",children:c.jsx(J,{icon:cr,size:14,strokeWidth:2})})]})]})]}),c.jsxs("div",{className:"space-y-2 pl-4",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(Dr,{checked:wa,onCheckedChange:Za,disabled:en||!In}),c.jsx("label",{className:"text-sm text-muted-foreground",children:e("notifications.whatsapp")||"WhatsApp"}),c.jsx(Ce,{variant:"ghost",size:"icon",className:"ml-auto h-8 w-8 text-muted-foreground hover:text-foreground",onClick:()=>Nd("whatsapp"),disabled:en||!In||!wa||_t.isPending,title:e("notifications.whatsapp")||"WhatsApp",children:_t.isPending?c.jsx(J,{icon:Rt,size:14,strokeWidth:2,className:"animate-spin"}):c.jsx(J,{icon:nm,size:14,strokeWidth:2})})]}),wa&&c.jsx("p",{className:"ml-10 text-xs text-muted-foreground",children:e("notifications.messagingChannelRequired")||"Requires connected WhatsApp messaging channel"})]}),c.jsxs("div",{className:"space-y-2 pl-4",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(Dr,{checked:Cu,onCheckedChange:yp,disabled:en||!In}),c.jsx("label",{className:"text-sm text-muted-foreground",children:e("notifications.telegram")||"Telegram"}),c.jsx(Ce,{variant:"ghost",size:"icon",className:"ml-auto h-8 w-8 text-muted-foreground hover:text-foreground",onClick:()=>Nd("telegram"),disabled:en||!In||!Cu||_t.isPending,title:e("notifications.telegram")||"Telegram",children:_t.isPending?c.jsx(J,{icon:Rt,size:14,strokeWidth:2,className:"animate-spin"}):c.jsx(J,{icon:nm,size:14,strokeWidth:2})})]}),Cu&&c.jsx("p",{className:"ml-10 text-xs text-muted-foreground",children:e("notifications.messagingChannelRequired")||"Requires connected Telegram messaging channel"})]}),c.jsxs("div",{className:"space-y-2 pl-4",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(Dr,{checked:ul,onCheckedChange:N,disabled:en||!In}),c.jsx("label",{className:"text-sm text-muted-foreground",children:e("notifications.gmail")}),c.jsx(Ce,{variant:"ghost",size:"icon",className:"ml-auto h-8 w-8 text-muted-foreground hover:text-foreground",onClick:()=>Nd("gmail"),disabled:en||!In||!ul||_t.isPending,title:e("notifications.gmail"),children:_t.isPending?c.jsx(J,{icon:Rt,size:14,strokeWidth:2,className:"animate-spin"}):c.jsx(J,{icon:nm,size:14,strokeWidth:2})})]}),ul&&c.jsxs("div",{className:"ml-10 space-y-2",children:[c.jsx("p",{className:"text-xs text-muted-foreground",children:e("notifications.gmailDescription")}),an.length>1&&c.jsxs(Vr,{value:H||"auto",onValueChange:Be=>te(!Be||Be==="auto"?"":Be),children:[c.jsx(qr,{className:"h-8 w-60",children:c.jsx(Wr,{})}),c.jsxs(Gr,{children:[c.jsx(Kt,{value:"auto",children:e("notifications.gmailAutoResolve")}),an.map(Be=>c.jsx(Kt,{value:Be.id,children:Be.email||Be.name},Be.id))]})]}),an.length===0&&c.jsx("p",{className:"text-xs text-destructive",children:e("notifications.gmailNoAccounts")})]})]})]})}),c.jsx(yl,{title:"Channels",children:c.jsxs("div",{className:"space-y-8",children:[c.jsx("div",{className:"rounded-lg border border-border p-4",children:c.jsx(XTt,{isLoading:en})}),c.jsx(BTt,{isLoading:en}),c.jsx($Tt,{isLoading:en}),c.jsx(UTt,{isLoading:en}),c.jsx(zTt,{isLoading:en})]})})]})}),c.jsx(Un,{value:"calendar",className:"flex-1 overflow-auto p-6",children:c.jsxs("div",{className:"mx-auto max-w-5xl space-y-4",children:[c.jsx(yl,{title:e("sections.googleCalendar","Google Calendar"),children:c.jsx(yAt,{})}),c.jsxs(yl,{title:e("sections.caldav"),children:[c.jsx(gAt,{isLoading:en}),c.jsx(vAt,{isLoading:en})]})]})})]})}),c.jsx("div",{className:"shrink-0 border-t border-border bg-background px-6 py-3",children:c.jsx("div",{className:"mx-auto flex max-w-5xl items-center justify-start",children:c.jsxs("div",{className:"flex items-center gap-2",children:[Xn&&c.jsxs("span",{className:"flex items-center gap-1 text-xs text-accent",children:[c.jsx(J,{icon:cr,size:12,strokeWidth:2}),t("status.saved")]}),c.jsx(Ce,{size:"sm",onClick:Ik,disabled:!x_||en||Se.isPending||Qe.isPending||It.isPending||q.isPending,children:t("buttons.save")})]})})}),c.jsx(bh,{open:it,onOpenChange:Wt,onSelect:Be=>vr(Be),initialPath:Ln||void 0})]})}const o5="";function SAt(){return Qt({queryKey:["github-user"],queryFn:async()=>{const e=await fetch(`${o5}/api/github/user`);return e.ok?e.json():null},staleTime:600*1e3,retry:!1})}function wAt(){return Qt({queryKey:["github-orgs"],queryFn:async()=>{const e=await fetch(`${o5}/api/github/orgs`);return e.ok?e.json():[]},staleTime:600*1e3})}function EAt(e,t,n){return Qt({queryKey:["github-issues",e,t,n],queryFn:async()=>{const r=new URLSearchParams({filter:e});t&&r.set("fulcrumReposOnly","true"),n&&r.set("org",n);const i=await fetch(`${o5}/api/github/issues?${r}`);if(!i.ok)throw new Error("Failed to fetch issues");return i.json()},staleTime:300*1e3})}function CAt(e,t,n){return Qt({queryKey:["github-prs",e,t,n],queryFn:async()=>{const r=new URLSearchParams({filter:e});t&&r.set("fulcrumReposOnly","true"),n&&r.set("org",n);const i=await fetch(`${o5}/api/github/prs?${r}`);if(!i.ok)throw new Error("Failed to fetch PRs");return i.json()},staleTime:300*1e3})}function kAt({filter:e,fulcrumReposOnly:t,org:n}){const{t:r}=Dt("review"),{t:i}=Dt("common"),{data:s,isLoading:a,error:o}=EAt(e,t,n);if(a)return c.jsx("div",{className:"flex h-48 items-center justify-center",children:c.jsx(J,{icon:Rt,size:24,className:"animate-spin text-muted-foreground"})});if(o)return c.jsxs("div",{className:"flex h-48 flex-col items-center justify-center gap-2 text-muted-foreground",children:[c.jsx(J,{icon:Pr,size:24}),c.jsx("p",{className:"text-sm",children:r("issues.failedToLoad")}),c.jsx("p",{className:"text-xs",children:o.message})]});const l={assigned:"issues.empty.assigned",created:"issues.empty.created",mentioned:"issues.empty.mentioned"};return s?.length?c.jsxs("div",{className:"space-y-4",children:[c.jsx("div",{className:"text-xs text-muted-foreground",children:i(s.length===1?"results.one":"results.other",{count:s.length})}),c.jsx("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4",children:s.map(u=>c.jsx(TAt,{issue:u},u.id))})]}):c.jsxs("div",{className:"flex h-48 flex-col items-center justify-center gap-2 text-muted-foreground",children:[c.jsx(J,{icon:cr,size:24}),c.jsx("p",{className:"text-sm",children:r(l[e])})]})}function TAt({issue:e}){return c.jsx(Gi,{className:"transition-colors hover:border-border/80",children:c.jsx(za,{className:"py-4",children:c.jsxs("a",{href:e.htmlUrl,target:"_blank",rel:"noopener noreferrer",className:"block space-y-2",children:[c.jsx("div",{className:"flex items-start gap-2",children:c.jsx("span",{className:"line-clamp-2 text-sm font-medium",children:e.title})}),c.jsx("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:c.jsxs("span",{className:"font-mono",children:[e.repository.fullName,"#",e.number]})}),e.labels.length>0&&c.jsxs("div",{className:"flex flex-wrap gap-1",children:[e.labels.slice(0,3).map(t=>c.jsx(jr,{className:"text-xs",style:{backgroundColor:`#${t.color}20`,color:`#${t.color}`,borderColor:`#${t.color}40`},children:t.name},t.name)),e.labels.length>3&&c.jsxs(jr,{variant:"secondary",className:"text-xs",children:["+",e.labels.length-3]})]})]})})})}function AAt({filter:e,fulcrumReposOnly:t,org:n}){const{t:r}=Dt("review"),{t:i}=Dt("common"),{data:s,isLoading:a,error:o}=CAt(e,t,n);if(a)return c.jsx("div",{className:"flex h-48 items-center justify-center",children:c.jsx(J,{icon:Rt,size:24,className:"animate-spin text-muted-foreground"})});if(o)return c.jsxs("div",{className:"flex h-48 flex-col items-center justify-center gap-2 text-muted-foreground",children:[c.jsx(J,{icon:Pr,size:24}),c.jsx("p",{className:"text-sm",children:r("prs.failedToLoad")}),c.jsx("p",{className:"text-xs",children:o.message})]});const l={all:"prs.empty.all",created:"prs.empty.created",assigned:"prs.empty.assigned",review_requested:"prs.empty.reviewRequested",mentioned:"prs.empty.mentioned"};return s?.length?c.jsxs("div",{className:"space-y-4",children:[c.jsx("div",{className:"text-xs text-muted-foreground",children:i(s.length===1?"results.one":"results.other",{count:s.length})}),c.jsx("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4",children:s.map(u=>c.jsx(NAt,{pr:u},u.id))})]}):c.jsxs("div",{className:"flex h-48 flex-col items-center justify-center gap-2 text-muted-foreground",children:[c.jsx(J,{icon:cr,size:24}),c.jsx("p",{className:"text-sm",children:r(l[e])})]})}function NAt({pr:e}){const{t}=Dt("review");return c.jsx(Gi,{className:"transition-colors hover:border-border/80",children:c.jsx(za,{className:"py-4",children:c.jsxs("a",{href:e.htmlUrl,target:"_blank",rel:"noopener noreferrer",className:"block space-y-2",children:[c.jsx("div",{className:"flex items-start gap-2",children:c.jsx("span",{className:"line-clamp-2 text-sm font-medium",children:e.title})}),c.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[c.jsxs("span",{className:"font-mono",children:[e.repository.fullName,"#",e.number]}),e.draft&&c.jsx(jr,{variant:"secondary",className:Pe("text-xs","bg-muted-foreground/20 text-muted-foreground"),children:t("prs.draft")})]}),c.jsxs("div",{className:"flex items-center gap-2",children:[e.author.avatarUrl&&c.jsx("img",{src:e.author.avatarUrl,alt:e.author.login,className:"h-4 w-4 rounded-full"}),c.jsx("span",{className:"text-xs text-muted-foreground",children:e.author.login})]}),e.labels.length>0&&c.jsxs("div",{className:"flex flex-wrap gap-1",children:[e.labels.slice(0,3).map(n=>c.jsx(jr,{className:"text-xs",style:{backgroundColor:`#${n.color}20`,color:`#${n.color}`,borderColor:`#${n.color}40`},children:n.name},n.name)),e.labels.length>3&&c.jsxs(jr,{variant:"secondary",className:"text-xs",children:["+",e.labels.length-3]})]})]})})})}const OAt=js("/review/")({component:RAt});function RAt(){const{t:e}=Dt("review"),[t,n]=x.useState("prs"),[r,i]=x.useState("review_requested"),[s,a]=x.useState("assigned"),[o,l]=x.useState(!1),[u,d]=x.useState(""),{data:f,isLoading:h}=SAt(),{data:m=[]}=wAt();return!h&&!f?c.jsxs("div",{className:"flex h-full flex-col",children:[c.jsx("div",{className:"film-grain relative flex shrink-0 items-center border-b border-border px-4 py-2",style:{background:"var(--gradient-header)"}}),c.jsx("div",{className:"flex flex-1 items-center justify-center p-8",children:c.jsxs("div",{className:"max-w-md space-y-4 text-center",children:[c.jsx("div",{className:"mx-auto flex h-12 w-12 items-center justify-center rounded-full bg-muted",children:c.jsx(J,{icon:s$e,size:24,className:"text-muted-foreground"})}),c.jsx("h2",{className:"text-lg font-medium",children:e("github.tokenRequired")}),c.jsx("p",{className:"text-sm text-muted-foreground",children:e("github.tokenDescription")}),c.jsxs("div",{className:"rounded-lg border border-border bg-muted/50 p-4 text-left",children:[c.jsx("p",{className:"mb-2 text-xs font-medium text-muted-foreground",children:e("github.requiredScopes")}),c.jsxs("ul",{className:"space-y-1 text-xs text-muted-foreground",children:[c.jsxs("li",{children:["• ",c.jsx("code",{className:"rounded bg-muted px-1",children:"repo"})," ",e("github.scopes.repo")]}),c.jsxs("li",{children:["• ",c.jsx("code",{className:"rounded bg-muted px-1",children:"read:user"})," ",e("github.scopes.readUser")]}),c.jsxs("li",{children:["• ",c.jsx("code",{className:"rounded bg-muted px-1",children:"read:org"})," ",e("github.scopes.readOrg")]})]})]}),c.jsxs("div",{className:"flex flex-col gap-2",children:[c.jsx("a",{href:"https://github.com/settings/tokens/new?scopes=repo,read:user,read:org&description=Fulcrum",target:"_blank",rel:"noopener noreferrer",children:c.jsxs(Ce,{variant:"outline",size:"sm",className:"w-full",children:[c.jsx(J,{icon:a$e,size:14,"data-slot":"icon"}),e("github.generateToken")]})}),c.jsx(ai,{to:"/settings",children:c.jsx(Ce,{size:"sm",className:"w-full",children:e("github.goToSettings")})})]})]})})]}):c.jsx("div",{className:"flex h-full flex-col",children:c.jsxs(Jo,{value:t,onValueChange:b=>n(b),className:"flex flex-1 flex-col overflow-hidden",children:[c.jsxs("div",{className:"film-grain relative flex shrink-0 flex-col border-b border-border sm:flex-row sm:items-center sm:justify-between",style:{background:"var(--gradient-header)"},children:[c.jsxs("div",{className:"flex items-center justify-between px-4 py-1 max-sm:px-2",children:[c.jsxs(el,{variant:"line",children:[c.jsx(Bn,{value:"prs",children:e("tabs.pullRequests")}),c.jsx(Bn,{value:"issues",children:e("tabs.issues")})]}),c.jsx("label",{className:"flex cursor-pointer items-center gap-2 text-xs sm:hidden",title:e("filters.fulcrumReposOnly"),children:c.jsx(Dr,{checked:o,onCheckedChange:l,disabled:!!u})})]}),c.jsxs("div",{className:"flex items-center gap-2 border-t border-border px-4 py-1.5 sm:gap-4 sm:border-t-0 sm:px-4 sm:py-1",children:[t==="prs"?c.jsxs(Vr,{value:r,onValueChange:b=>i(b),children:[c.jsx(qr,{size:"sm",className:"flex-1 sm:flex-initial",children:c.jsx(Wr,{})}),c.jsxs(Gr,{children:[c.jsx(Kt,{value:"created",children:e("filters.pr.created")}),c.jsx(Kt,{value:"assigned",children:e("filters.pr.assigned")}),c.jsx(Kt,{value:"review_requested",children:e("filters.pr.reviewRequested")}),c.jsx(Kt,{value:"mentioned",children:e("filters.pr.mentioned")})]})]}):c.jsxs(Vr,{value:s,onValueChange:b=>a(b),children:[c.jsx(qr,{size:"sm",className:"flex-1 sm:flex-initial",children:c.jsx(Wr,{})}),c.jsxs(Gr,{children:[c.jsx(Kt,{value:"assigned",children:e("filters.issue.assigned")}),c.jsx(Kt,{value:"created",children:e("filters.issue.created")}),c.jsx(Kt,{value:"mentioned",children:e("filters.issue.mentioned")})]})]}),c.jsxs(Vr,{value:u,onValueChange:b=>d(b||""),children:[c.jsx(qr,{size:"sm",className:"flex-1 sm:flex-initial",children:c.jsx(Wr,{children:u||e("filters.allOrgs")})}),c.jsxs(Gr,{children:[c.jsx(Kt,{value:"",children:e("filters.allOrganizations")}),m.map(b=>c.jsx(Kt,{value:b.login,children:b.login},b.login))]})]}),c.jsxs("label",{className:"hidden cursor-pointer items-center gap-2 text-xs sm:flex",title:e("filters.fulcrumReposOnly"),children:[c.jsx(Dr,{checked:o,onCheckedChange:l,disabled:!!u}),c.jsx("span",{className:"text-muted-foreground",children:e("filters.fulcrumReposOnly")})]})]})]}),c.jsx(Un,{value:"prs",className:"flex-1 overflow-auto p-4",children:c.jsx(AAt,{filter:r,fulcrumReposOnly:o,org:u||void 0})}),c.jsx(Un,{value:"issues",className:"flex-1 overflow-auto p-4",children:c.jsx(kAt,{filter:s,fulcrumReposOnly:o,org:u||void 0})})]})})}const IAt=js("/repositories/")({beforeLoad:()=>{throw zm({to:"/projects",search:{tab:"repositories"}})},component:()=>null});function DAt({open:e,onOpenChange:t,onCreated:n}){const{t:r}=Dt("projects"),i=ji(),s=HSe(),[a,o]=x.useState(""),[l,u]=x.useState(""),[d,f]=x.useState([]),[h,m]=x.useState(""),[b,y]=x.useState(!1),[v,_]=x.useState(null),w=x.useRef(null),{data:C=[]}=eW(h),T=C.filter(j=>!d.includes(j.name)),k=C.find(j=>j.name.toLowerCase()===h.toLowerCase()),S=h.trim()&&!k&&!d.includes(h.trim());x.useEffect(()=>{e&&(o(""),u(""),f([]),m(""),_(null),y(!1))},[e]),x.useEffect(()=>{const j=B=>{w.current&&!w.current.contains(B.target)&&y(!1)};return document.addEventListener("mousedown",j),()=>document.removeEventListener("mousedown",j)},[]);const A=j=>{const B=j.trim();B&&!d.includes(B)&&f([...d,B]),m(""),y(!1)},R=j=>{f(d.filter(B=>B!==j))},I=j=>{j.key==="Enter"&&h.trim()?(j.preventDefault(),k&&!d.includes(k.name)?A(k.name):S&&A(h.trim())):j.key==="Escape"?(y(!1),m("")):j.key==="Backspace"&&!h&&d.length>0&&f(d.slice(0,-1))},D=async()=>{_(null);const j=a.trim();if(j)try{const B=await s.mutateAsync({name:j,description:l.trim()||void 0,tags:d.length>0?d:void 0});t(!1),n?n(B):i({to:"/projects/$projectId",params:{projectId:B.id}})}catch(B){_(B instanceof Error?B.message:"Failed to create project")}},P=j=>{j.key==="Enter"&&!j.shiftKey&&a.trim()&&(j.preventDefault(),D())};return c.jsx(Va,{open:e,onOpenChange:t,children:c.jsxs(Wa,{className:"sm:max-w-md",children:[c.jsx(Po,{children:c.jsx(jo,{children:r("newProjectButton")})}),c.jsxs("div",{className:"space-y-4 py-2",children:[c.jsxs("div",{className:"space-y-2",children:[c.jsx(Kr,{htmlFor:"project-name",children:r("newProject.projectName")}),c.jsx(kt,{id:"project-name",value:a,onChange:j=>o(j.target.value),onKeyDown:P,placeholder:r("newProject.projectNamePlaceholder"),disabled:s.isPending,autoFocus:!0})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsx(Kr,{htmlFor:"project-description",children:r("newProject.description")}),c.jsx(dd,{id:"project-description",value:l,onChange:j=>u(j.target.value),placeholder:r("newProject.descriptionPlaceholder"),disabled:s.isPending,rows:3})]}),c.jsxs("div",{className:"space-y-2",ref:w,children:[c.jsx(Kr,{children:"Tags"}),d.length>0&&c.jsx("div",{className:"flex flex-wrap gap-1.5 mb-2",children:d.map(j=>c.jsxs(jr,{variant:"default",className:"pr-1 gap-1",children:[j,c.jsx("button",{type:"button",onClick:()=>R(j),className:"ml-0.5 hover:text-destructive transition-colors",children:c.jsx(J,{icon:jn,size:10})})]},j))}),c.jsxs("div",{className:"relative",children:[c.jsx(kt,{value:h,onChange:j=>{m(j.target.value),y(!0)},onFocus:()=>y(!0),onKeyDown:I,placeholder:"Add tags...",disabled:s.isPending}),b&&(h||T.length>0)&&c.jsxs("div",{className:"absolute top-full left-0 right-0 mt-1 bg-popover border rounded-md shadow-lg z-50 max-h-48 overflow-y-auto",children:[T.map(j=>c.jsxs("button",{type:"button",className:"w-full px-3 py-2 text-left text-sm hover:bg-accent flex items-center justify-between",onClick:()=>A(j.name),children:[c.jsx("span",{children:j.name}),c.jsxs("span",{className:"text-xs text-muted-foreground",children:[j.taskCount+j.projectCount," uses"]})]},j.id)),S&&c.jsxs("button",{type:"button",className:Pe("w-full px-3 py-2 text-left text-sm hover:bg-accent flex items-center gap-2",T.length>0&&"border-t"),onClick:()=>A(h.trim()),children:[c.jsx(J,{icon:mu,size:14}),c.jsxs("span",{children:['Create "',h.trim(),'"']})]}),!S&&T.length===0&&h&&c.jsx("div",{className:"px-3 py-2 text-sm text-muted-foreground",children:"No matching tags"})]})]})]}),v&&c.jsxs("div",{className:"flex items-start gap-2 rounded-md bg-destructive/10 px-3 py-2 text-xs text-destructive",children:[c.jsx(J,{icon:Pr,size:14,strokeWidth:2,className:"mt-0.5 shrink-0"}),c.jsx("span",{children:v})]})]}),c.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[c.jsx(Ce,{variant:"outline",onClick:()=>t(!1),disabled:s.isPending,children:r("newProject.cancel")}),c.jsx(Ce,{onClick:D,disabled:!a.trim()||s.isPending,children:s.isPending?c.jsxs(c.Fragment,{children:[c.jsx(J,{icon:Rt,size:16,strokeWidth:2,className:"animate-spin"}),r("newProject.creating")]}):r("newProject.create")})]})]})})}const PAt="";function jAt(e){return Qt({queryKey:["copier-questions",e],queryFn:()=>ct(`${PAt}/api/copier/questions?source=${encodeURIComponent(e)}`),enabled:!!e,staleTime:300*1e3,retry:!1})}function LAt(){const{data:e,...t}=sg();return{...t,data:e?.filter(n=>n.isCopierTemplate)??[]}}function X6(e){return e.startsWith("git@")||e.startsWith("https://")||e.startsWith("http://")||e.startsWith("gh:")||e.startsWith("gl:")||e.startsWith("bb:")}function MAt(e){const t=e.replace(/\.git$/,"");if(t.startsWith("git@")){const n=t.match(/:([^/]+\/)?([^/]+)$/);if(n)return n[2]}else if(t.startsWith("gh:")||t.startsWith("gl:")||t.startsWith("bb:")){const n=t.split("/");if(n.length>0)return n[n.length-1]}else{const n=t.split("/");if(n.length>0)return n[n.length-1]}return t}function hOe({open:e,onOpenChange:t,projectId:n,initialTab:r="clone"}){const{t:i}=Dt("repositories"),s=At(),{data:a}=q3(),{data:o}=_u(),l=VSe(),u=NWe(),d=OWe(),f=HSe(),[h,m]=x.useState(null),[b,y]=x.useState(""),[v,_]=x.useState(null),[w,C]=x.useState(!1),[T,k]=x.useState(""),S=n??h,[A,R]=x.useState(r),[I,D]=x.useState(""),[P,j]=x.useState(""),[B,L]=x.useState(""),[M,$]=x.useState(null),[U,W]=x.useState(!1),[Y,G]=x.useState(""),[q,X]=x.useState(null),[z,Q]=x.useState(!1),[ee,ne]=x.useState(""),[ae,fe]=x.useState(null),[re,de]=x.useState(new Set),[he,ce]=x.useState(null),[ye,be]=x.useState(!1),[ue,Ae]=x.useState(""),[le,ke]=x.useState(""),[Fe,ze]=x.useState({}),[ve,je]=x.useState(""),[we,Le]=x.useState(""),[qe,Re]=x.useState(null),[Ie,se]=x.useState(!0),[Ge,ut]=x.useState(!1),[mt,Ke]=x.useState(new Set),[lt,Ve]=x.useState({open:!1,conflict:null,pendingAction:null}),{data:Ct}=LAt(),Ne=ue||le,{data:Ue,isLoading:st,error:et}=jAt(A==="template"&&Ne?Ne:null);x.useEffect(()=>{e&&(R(r),m(null),y(""),_(null),C(!1),k(""),D(""),j(""),L(""),$(null),G(""),X(null),ne(""),fe(null),de(new Set),ce(null),Ae(""),ke(""),ze({}),je(a||""),Le(""),Re(null),se(!0),Ke(new Set))},[e,r,a]);const pt=x.useMemo(()=>I.trim()?MAt(I.trim()):null,[I]);x.useEffect(()=>{pt&&!B&&L(pt)},[pt,B]);const wt=P.trim()||a||"",Et=ee.trim()||a||"",Se=x.useMemo(()=>{if(!I.trim()||!wt)return null;const tt=B.trim()||pt||"";return tt?`${wt}/${tt}`:null},[I,wt,B,pt]),Oe=x.useMemo(()=>ae?.filter(tt=>!tt.hasProject)??[],[ae]),Qe=l.isPending&&A==="clone",It=l.isPending&&A==="local",_t=u.isPending||d.isPending,rn=l.isPending&&A==="template",an=x.useMemo(()=>{if(!o)return[];if(!b.trim())return o;const tt=b.toLowerCase();return o.filter(Mn=>Mn.name.toLowerCase().includes(tt))},[o,b]),vn=o?.find(tt=>tt.id===h),zt=async()=>{if(T.trim()){_(null);try{const tt=await f.mutateAsync({name:T.trim()});m(tt.id),C(!1),k("")}catch(tt){_(tt instanceof Error?tt.message:"Failed to create project")}}};x.useEffect(()=>{Ue?.questions&&ze(tt=>{const Mn={...tt};for(const An of Ue.questions)Mn[An.name]===void 0&&An.default!==void 0&&(Mn[An.name]=An.default);return Mn})},[Ue]),x.useEffect(()=>{a&&!ve&&je(a)},[a,ve]);const sn=Ue?.questions.filter(tt=>{if(tt.default!==void 0&&!(typeof tt.default=="string"&&tt.default.includes("{{")))return!1;const An=Fe[tt.name];return An==null||An===""})??[],Ln=Ne&&we.trim()&&ve.trim()&&!st&&sn.length===0,vr=async(tt=!1)=>{if(!S){_("Please select a project first");return}$(null),_(null);const Mn=I.trim();if(!(!Mn||!X6(Mn)))try{await l.mutateAsync({projectId:S,url:Mn,targetDir:P.trim()||void 0,folderName:B.trim()||void 0,moveFromProject:tt}),t(!1)}catch(An){const Fr=An;Fr.conflict?.conflictProject?Ve({open:!0,conflict:Fr.conflict,pendingAction:()=>vr(!0)}):$(Fr.message||i("addModal.cloneFailed"))}},Mr=async(tt=!1)=>{if(!S){_("Please select a project first");return}X(null),_(null);const Mn=Y.trim();if(Mn)try{await l.mutateAsync({projectId:S,path:Mn,moveFromProject:tt}),t(!1)}catch(An){const Fr=An;Fr.conflict?.conflictProject?Ve({open:!0,conflict:Fr.conflict,pendingAction:()=>Mr(!0)}):X(Fr.message||i("addModal.createFailed"))}},oi=()=>{ce(null),fe(null),de(new Set),u.mutate(Et||void 0,{onSuccess:tt=>{fe(tt.repositories);const Mn=tt.repositories.filter(An=>!An.hasProject);de(new Set(Mn.map(An=>An.path)))},onError:tt=>{ce(tt instanceof Error?tt.message:i("bulkAdd.scanFailed"))}})},gs=tt=>{de(Mn=>{const An=new Set(Mn);return An.has(tt)?An.delete(tt):An.add(tt),An})},xi=()=>{de(new Set(Oe.map(tt=>tt.path)))},dr=()=>{de(new Set)},fr=async()=>{if(!S){_("Please select a project first");return}if(re.size===0)return;ce(null),_(null);let tt=0,Mn=0;for(const An of re)try{await l.mutateAsync({projectId:S,path:An}),tt++}catch{Mn++}Mn>0?ce(`Added ${tt} repositories, ${Mn} failed`):t(!1)},Fi=!!ue||Ie,Ai=async()=>{if(!S){_("Please select a project first");return}Re(null),_(null);try{await ct("/api/copier/create",{method:"POST",body:JSON.stringify({templateSource:Ne,outputPath:ve,answers:Fe,projectName:we,trust:Fi,existingProjectId:S})}),await Promise.all([s.invalidateQueries({queryKey:["projects"]}),s.invalidateQueries({queryKey:["repositories"]})]),t(!1)}catch(tt){Re(tt instanceof Error?tt.message:"Failed to create from template")}},Ki=tt=>{const Mn=Fe[tt.name],An=li=>ze(kr=>({...kr,[tt.name]:li})),ss=tt.default===void 0||typeof tt.default=="string"&&tt.default.includes("{{")?`${tt.name} *`:tt.name;switch(tt.type){case"bool":return c.jsxs(Gn,{children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(Ci,{checked:Mn,onCheckedChange:An}),c.jsx(Kn,{className:"cursor-pointer",children:ss})]}),tt.help&&c.jsx(es,{children:tt.help})]},tt.name);case"int":case"float":return c.jsxs(Gn,{children:[c.jsx(Kn,{children:ss}),c.jsx(kt,{type:"number",value:Mn,onChange:li=>An(tt.type==="int"?parseInt(li.target.value):parseFloat(li.target.value)),step:tt.type==="float"?"any":1}),tt.help&&c.jsx(es,{children:tt.help})]},tt.name);default:{if(tt.choices&&tt.choices.length>0)return c.jsxs(Gn,{children:[c.jsx(Kn,{children:ss}),c.jsxs(Vr,{value:String(Mn??""),onValueChange:An,children:[c.jsx(qr,{className:"w-full",children:c.jsx(Wr,{})}),c.jsx(Gr,{children:tt.choices.map(hr=>c.jsx(Kt,{value:String(hr.value),children:hr.label},String(hr.value)))})]}),tt.help&&c.jsx(es,{children:tt.help})]},tt.name);const li=tt.type==="yaml"||tt.type==="json",kr=tt.name.toLowerCase().includes("password"),ei=mt.has(tt.name);return c.jsxs(Gn,{children:[c.jsx(Kn,{children:ss}),li?c.jsx(dd,{value:String(Mn??""),onChange:hr=>An(hr.target.value),rows:4}):kr?c.jsxs("div",{className:"relative",children:[c.jsx(kt,{type:ei?"text":"password",value:String(Mn??""),onChange:hr=>An(hr.target.value),className:"pr-8"}),c.jsx("button",{type:"button",className:"absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",onClick:()=>{Ke(hr=>{const Br=new Set(hr);return Br.has(tt.name)?Br.delete(tt.name):Br.add(tt.name),Br})},children:c.jsx(J,{icon:ei?a_e:PV,size:14,strokeWidth:2})})]}):c.jsx(kt,{value:String(Mn??""),onChange:hr=>An(hr.target.value)}),tt.help&&c.jsx(es,{children:tt.help})]},tt.name)}}},vo=()=>{t(!1)},Yi=()=>n?null:c.jsxs("div",{className:"space-y-2 border-t border-border pt-4",children:[c.jsx(Kr,{children:"Add to Project"}),w?c.jsxs("div",{className:"flex gap-2",children:[c.jsx(kt,{value:T,onChange:tt=>k(tt.target.value),placeholder:"New project name...",autoFocus:!0,onKeyDown:tt=>{tt.key==="Enter"?(tt.preventDefault(),zt()):tt.key==="Escape"&&(C(!1),k(""))},disabled:f.isPending}),c.jsx(Ce,{size:"sm",onClick:zt,disabled:!T.trim()||f.isPending,children:f.isPending?c.jsx(J,{icon:Rt,size:14,strokeWidth:2,className:"animate-spin"}):"Create"}),c.jsx(Ce,{size:"sm",variant:"outline",onClick:()=>{C(!1),k("")},disabled:f.isPending,children:"Cancel"})]}):c.jsxs(c2,{value:h,onValueChange:tt=>{m(tt),_(null)},children:[c.jsx(d2,{placeholder:vn?.name||"Select a project...",value:b,onChange:tt=>y(tt.target.value),className:"w-full"}),c.jsxs(f2,{children:[c.jsxs(h2,{children:[c.jsx(W3,{children:"No projects found"}),an.map(tt=>c.jsx(tx,{value:tt.id,children:tt.name},tt.id))]}),c.jsx("div",{className:"border-t p-1",children:c.jsxs("button",{type:"button",className:"flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-xs hover:bg-accent hover:text-accent-foreground",onClick:()=>{C(!0),y("")},children:[c.jsx(J,{icon:mu,size:14,strokeWidth:2}),"Create new project"]})})]})]}),v&&c.jsxs("div",{className:"flex items-center gap-2 text-xs text-destructive",children:[c.jsx(J,{icon:Pr,size:12,strokeWidth:2}),v]})]});return c.jsxs(c.Fragment,{children:[c.jsx(Va,{open:e,onOpenChange:t,children:c.jsxs(Wa,{className:"sm:max-w-2xl max-h-[80dvh] flex flex-col overflow-hidden",children:[c.jsx(Po,{className:"shrink-0",children:c.jsx(jo,{children:i("addRepository")})}),c.jsx("div",{className:"flex-1 overflow-y-auto min-h-0 px-1",children:c.jsx("div",{className:"space-y-4",children:c.jsxs(Jo,{value:A,onValueChange:R,children:[c.jsxs(el,{className:"w-full",children:[c.jsx(Bn,{value:"clone",className:"flex-1",children:"Clone"}),c.jsx(Bn,{value:"local",className:"flex-1",children:"Local"}),c.jsx(Bn,{value:"scan",className:"flex-1",children:i("addModal.tabs.scan")}),c.jsx(Bn,{value:"template",className:"flex-1",children:i("addModal.tabs.template")})]}),c.jsxs(Un,{value:"clone",className:"space-y-4 pt-4",children:[c.jsxs("div",{className:"space-y-2",children:[c.jsx(Kr,{children:"Git URL"}),c.jsxs("div",{className:"relative",children:[c.jsx(kt,{value:I,onChange:tt=>{D(tt.target.value),$(null),X6(tt.target.value.trim())||L("")},placeholder:"https://github.com/user/repo.git",disabled:Qe,className:"pr-8"}),I&&c.jsx("div",{className:"absolute right-2 top-1/2 -translate-y-1/2",children:c.jsx(J,{icon:ky,size:14,strokeWidth:2,className:"text-muted-foreground"})})]})]}),I.trim()&&c.jsxs("div",{className:"space-y-3 rounded-md border border-border bg-muted/30 p-3",children:[c.jsx("div",{className:"text-xs font-medium text-muted-foreground",children:"Clone Options"}),c.jsxs("div",{className:"space-y-1",children:[c.jsx(Kr,{className:"text-xs",children:"Clone to directory"}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx(kt,{value:P,onChange:tt=>j(tt.target.value),placeholder:a||"~/",disabled:Qe,className:"flex-1 text-xs"}),c.jsx(Ce,{type:"button",variant:"outline",size:"sm",onClick:()=>W(!0),disabled:Qe,children:"Browse"})]})]}),c.jsxs("div",{className:"space-y-1",children:[c.jsx(Kr,{className:"text-xs",children:"Folder name"}),c.jsx(kt,{value:B,onChange:tt=>L(tt.target.value),placeholder:pt||"",disabled:Qe,className:"text-xs"})]}),Se&&c.jsxs("div",{className:"rounded-md bg-background px-3 py-2 text-xs text-muted-foreground",children:["Will clone to: ",c.jsx("span",{className:"font-mono",children:Se})]})]}),Qe&&c.jsxs("div",{className:"flex items-center justify-center gap-2 py-2 text-sm text-muted-foreground",children:[c.jsx(J,{icon:Rt,size:16,strokeWidth:2,className:"animate-spin"}),"Cloning repository..."]}),M&&c.jsxs("div",{className:"flex items-start gap-2 rounded-md bg-destructive/10 px-3 py-2 text-xs text-destructive",children:[c.jsx(J,{icon:Pr,size:14,strokeWidth:2,className:"mt-0.5 shrink-0"}),c.jsx("span",{children:M})]}),Yi(),c.jsxs("div",{className:"flex justify-end gap-2",children:[c.jsx(Ce,{variant:"outline",onClick:vo,disabled:Qe,children:i("addModal.cancel")}),c.jsx(Ce,{onClick:()=>vr(!1),disabled:!I.trim()||!X6(I.trim())||Qe||!S,children:Qe?c.jsxs(c.Fragment,{children:[c.jsx(J,{icon:Rt,size:16,strokeWidth:2,className:"animate-spin"}),"Cloning..."]}):"Clone & Add"})]})]}),c.jsxs(Un,{value:"local",className:"space-y-4 pt-4",children:[c.jsxs("div",{className:"space-y-2",children:[c.jsx(Kr,{children:"Repository path"}),c.jsxs("div",{className:"flex gap-2",children:[c.jsxs("div",{className:"relative flex-1",children:[c.jsx(kt,{value:Y,onChange:tt=>{G(tt.target.value),X(null)},placeholder:"~/code/my-repo",disabled:It,className:"pr-8"}),Y&&c.jsx("div",{className:"absolute right-2 top-1/2 -translate-y-1/2",children:c.jsx(J,{icon:$a,size:14,strokeWidth:2,className:"text-muted-foreground"})})]}),c.jsx(Ce,{type:"button",variant:"outline",size:"sm",onClick:()=>Q(!0),disabled:It,children:"Browse"})]})]}),It&&c.jsxs("div",{className:"flex items-center justify-center gap-2 py-2 text-sm text-muted-foreground",children:[c.jsx(J,{icon:Rt,size:16,strokeWidth:2,className:"animate-spin"}),"Adding repository..."]}),q&&c.jsxs("div",{className:"flex items-start gap-2 rounded-md bg-destructive/10 px-3 py-2 text-xs text-destructive",children:[c.jsx(J,{icon:Pr,size:14,strokeWidth:2,className:"mt-0.5 shrink-0"}),c.jsx("span",{children:q})]}),Yi(),c.jsxs("div",{className:"flex justify-end gap-2",children:[c.jsx(Ce,{variant:"outline",onClick:vo,disabled:It,children:i("addModal.cancel")}),c.jsx(Ce,{onClick:()=>Mr(!1),disabled:!Y.trim()||It||!S,children:It?c.jsxs(c.Fragment,{children:[c.jsx(J,{icon:Rt,size:16,strokeWidth:2,className:"animate-spin"}),"Adding..."]}):i("addModal.add")})]})]}),c.jsxs(Un,{value:"scan",className:"space-y-4 pt-4",children:[c.jsxs("div",{className:"space-y-2",children:[c.jsx(Kr,{children:i("bulkAdd.directoryLabel")}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx(kt,{value:ee,onChange:tt=>{ne(tt.target.value),ce(null),fe(null)},placeholder:a||i("bulkAdd.directoryPlaceholder"),disabled:_t,className:"flex-1"}),c.jsx(Ce,{type:"button",variant:"outline",size:"sm",onClick:()=>be(!0),disabled:_t,children:i("bulkAdd.browse")}),c.jsxs(Ce,{type:"button",size:"sm",onClick:oi,disabled:_t||!Et,children:[u.isPending?c.jsx(J,{icon:Rt,size:16,strokeWidth:2,className:"animate-spin"}):c.jsx(J,{icon:np,size:16,strokeWidth:2}),i("bulkAdd.scan")]})]})]}),ae!==null&&c.jsxs("div",{className:"space-y-2",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx(Kr,{className:"text-xs",children:i("bulkAdd.foundRepos",{count:ae.length})}),Oe.length>0&&c.jsxs("div",{className:"flex gap-2 text-xs",children:[c.jsx("button",{type:"button",className:"text-primary hover:underline",onClick:xi,disabled:_t,children:i("bulkAdd.selectAll")}),c.jsx("span",{className:"text-muted-foreground",children:"/"}),c.jsx("button",{type:"button",className:"text-primary hover:underline",onClick:dr,disabled:_t,children:i("bulkAdd.selectNone")})]})]}),ae.length===0?c.jsx("div",{className:"rounded-md bg-muted/50 px-3 py-4 text-center text-sm text-muted-foreground",children:i("bulkAdd.noReposFound")}):c.jsx("div",{className:"max-h-64 overflow-y-auto rounded-md border",children:ae.map(tt=>c.jsxs("div",{className:`flex items-center gap-3 border-b px-3 py-2 last:border-b-0 ${tt.hasProject?"bg-muted/30 opacity-60":""}`,children:[c.jsx(Ci,{checked:re.has(tt.path),onCheckedChange:()=>gs(tt.path),disabled:tt.hasProject||_t}),c.jsx(J,{icon:tt.hasProject?gu:$a,size:16,strokeWidth:2,className:tt.hasProject?"text-green-500":"text-muted-foreground"}),c.jsxs("div",{className:"min-w-0 flex-1",children:[c.jsx("div",{className:"truncate text-sm font-medium",children:tt.name}),c.jsx("div",{className:"truncate text-xs text-muted-foreground",children:tt.path})]}),tt.hasProject&&c.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:i("bulkAdd.alreadyAdded")})]},tt.path))})]}),l.isPending&&A==="scan"&&c.jsxs("div",{className:"flex items-center justify-center gap-2 py-2 text-sm text-muted-foreground",children:[c.jsx(J,{icon:Rt,size:16,strokeWidth:2,className:"animate-spin"}),i("bulkAdd.adding")]}),he&&c.jsxs("div",{className:"flex items-start gap-2 rounded-md bg-destructive/10 px-3 py-2 text-xs text-destructive",children:[c.jsx(J,{icon:Pr,size:14,strokeWidth:2,className:"mt-0.5 shrink-0"}),c.jsx("span",{children:he})]}),Yi(),re.size>0&&c.jsx(Ce,{onClick:fr,disabled:re.size===0||_t||l.isPending||!S,className:"w-full",children:i("bulkAdd.addSelected",{count:re.size})})]}),c.jsxs(Un,{value:"template",className:"space-y-4 pt-4",children:[c.jsxs("div",{className:"space-y-1",children:[c.jsx("div",{className:"text-xs font-medium text-muted-foreground",children:i("newProject.steps.template.sectionTitle")}),c.jsxs("div",{className:"text-xs text-muted-foreground",children:[i("newProject.steps.template.sectionDescription")," ",c.jsx("a",{href:"https://copier.readthedocs.io/",target:"_blank",rel:"noopener noreferrer",className:"underline hover:opacity-80",children:i("newProject.steps.template.learnMore")})]})]}),c.jsxs($h,{children:[c.jsxs(Gn,{children:[c.jsx(Kn,{children:i("newProject.steps.template.savedTemplates")}),c.jsxs("div",{className:"flex gap-2",children:[c.jsxs(Vr,{value:ue,onValueChange:tt=>{Ae(tt??""),ke(""),ze({})},children:[c.jsx(qr,{className:"w-full",children:c.jsx(Wr,{children:ue?Ct?.find(tt=>tt.id===ue)?.displayName:c.jsx("span",{className:"text-muted-foreground",children:i("newProject.steps.template.selectTemplate")})})}),c.jsx(Gr,{children:Ct?.map(tt=>c.jsx(Kt,{value:tt.id,children:tt.displayName},tt.id))})]}),ue&&c.jsx(Ce,{type:"button",variant:"ghost",size:"sm",onClick:()=>{Ae(""),ze({})},disabled:rn,className:"text-muted-foreground hover:text-foreground",children:"Clear"})]})]}),!ue&&c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"text-center text-muted-foreground text-xs py-1",children:i("newProject.steps.template.or")}),c.jsxs(Gn,{children:[c.jsx(Kn,{children:i("newProject.steps.template.customUrl")}),c.jsx(kt,{value:le,onChange:tt=>{ke(tt.target.value),Ae(""),ze({})},placeholder:"https://github.com/user/template or /path/to/template",disabled:rn})]})]})]}),Ne&&c.jsxs("div",{className:"space-y-3 rounded-md border border-border bg-muted/30 p-3",children:[c.jsx("div",{className:"text-xs font-medium text-muted-foreground",children:i("newProject.steps.questions.title")}),st&&c.jsx("div",{className:"flex items-center justify-center py-4",children:c.jsx(J,{icon:Rt,size:20,strokeWidth:2,className:"animate-spin text-muted-foreground"})}),et&&c.jsx("div",{className:"text-destructive text-sm py-2",children:et.message}),Ue&&c.jsx($h,{children:Ue.questions.length===0?c.jsx("div",{className:"text-muted-foreground text-sm py-2",children:i("newProject.steps.questions.noQuestions")}):Ue.questions.map(Ki)})]}),Ne&&!st&&c.jsxs("div",{className:"space-y-3 rounded-md border border-border bg-muted/30 p-3",children:[c.jsx("div",{className:"text-xs font-medium text-muted-foreground",children:i("newProject.steps.output.title")}),c.jsxs(Gn,{children:[c.jsx(Kn,{children:i("newProject.steps.output.projectName")}),c.jsx(kt,{value:we,onChange:tt=>Le(tt.target.value),placeholder:"my-new-project",disabled:rn})]}),c.jsxs(Gn,{children:[c.jsx(Kn,{children:i("newProject.steps.output.outputDirectory")}),c.jsxs(Ce,{type:"button",variant:"outline",className:"w-full justify-start font-normal",onClick:()=>ut(!0),disabled:rn,children:[c.jsx(J,{icon:$a,size:14,strokeWidth:2,className:"mr-2"}),ve||i("newProject.steps.output.selectDirectory")]})]}),we&&ve&&c.jsxs(es,{className:"font-mono text-xs",children:[i("newProject.steps.output.willCreate"),": ",ve,"/",we]})]}),rn&&c.jsxs("div",{className:"flex items-center justify-center gap-2 py-2 text-sm text-muted-foreground",children:[c.jsx(J,{icon:Rt,size:16,strokeWidth:2,className:"animate-spin"}),i("newProject.steps.creating.inProgress")]}),qe&&c.jsxs("div",{className:"flex items-start gap-2 rounded-md bg-destructive/10 px-3 py-2 text-xs text-destructive",children:[c.jsx(J,{icon:Pr,size:14,strokeWidth:2,className:"mt-0.5 shrink-0"}),c.jsx("span",{children:qe})]}),Yi(),c.jsxs("div",{className:"flex items-center justify-between pt-2",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(Ci,{id:"trust-template",checked:Ie,onCheckedChange:tt=>se(tt===!0),disabled:rn}),c.jsx("label",{htmlFor:"trust-template",className:"text-xs text-muted-foreground cursor-pointer",children:i("newProject.steps.output.trust")})]}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx(Ce,{variant:"outline",onClick:vo,disabled:rn,children:i("addModal.cancel")}),c.jsx(Ce,{onClick:Ai,disabled:!Ln||rn||!S,children:"Create & Add"})]})]})]})]})})})]})}),c.jsx(xc,{open:lt.open,onOpenChange:tt=>{tt||Ve({open:!1,conflict:null,pendingAction:null})},children:c.jsxs(_c,{children:[c.jsxs(Sc,{children:[c.jsx(Ec,{children:"Repository Already Assigned"}),c.jsxs(Cc,{children:['This repository is already in project "',lt.conflict?.conflictProject?.name,'". Would you like to move it to this project instead?']})]}),c.jsxs(wc,{children:[c.jsx(kc,{children:"Cancel"}),c.jsx(hg,{onClick:()=>{lt.pendingAction?.(),Ve({open:!1,conflict:null,pendingAction:null})},children:"Move to This Project"})]})]})}),c.jsx(bh,{open:U,onOpenChange:W,onSelect:tt=>{j(tt),W(!1)},initialPath:wt||void 0}),c.jsx(bh,{open:z,onOpenChange:Q,onSelect:tt=>{G(tt),Q(!1)},initialPath:a||void 0}),c.jsx(bh,{open:ye,onOpenChange:be,onSelect:tt=>{ne(tt),be(!1),fe(null),de(new Set)},initialPath:Et||void 0}),c.jsx(bh,{open:Ge,onOpenChange:ut,onSelect:tt=>{je(tt),ut(!1)},initialPath:ve||a||void 0})]})}const FAt=js("/projects/")({component:UAt});function BAt({project:e,onAddRepo:t,onDeleteClick:n}){const{t:r}=Dt("projects"),i=e.repositories.length>0?e.repositories.length:e.repositoryId?1:0;return c.jsxs(Gi,{className:"h-full group transition-colors hover:border-foreground/20",children:[c.jsx(ai,{to:"/projects/$projectId",params:{projectId:e.id},className:"block",children:c.jsxs(za,{className:"flex flex-col items-start gap-3 py-4",children:[c.jsx("span",{className:"truncate font-medium group-hover:text-primary transition-colors",children:e.name}),e.description&&c.jsx("p",{className:"text-xs text-muted-foreground line-clamp-2",children:e.description}),e.tags&&e.tags.length>0&&c.jsxs("div",{className:"flex flex-wrap gap-1",children:[e.tags.slice(0,3).map(s=>c.jsx(jr,{variant:"default",className:"text-[10px] px-1.5 py-0",style:s.color?{backgroundColor:s.color,color:"#fff"}:void 0,children:s.name},s.id)),e.tags.length>3&&c.jsxs(jr,{variant:"default",className:"text-[10px] px-1.5 py-0",children:["+",e.tags.length-3]})]}),c.jsxs("div",{className:"flex items-center gap-3 text-xs text-muted-foreground",children:[c.jsxs("div",{className:"flex items-center gap-1.5",children:[c.jsx(J,{icon:$a,size:14,strokeWidth:2,className:"shrink-0 -translate-y-px"}),c.jsxs("span",{children:[i," ",i===1?"repository":"repositories"]})]}),c.jsxs("div",{className:"flex items-center gap-1.5",children:[c.jsx(J,{icon:B3,size:14,strokeWidth:2,className:"shrink-0 -translate-y-px"}),c.jsxs("span",{children:[e.taskCount??0," active ",e.taskCount===1?"task":"tasks"]})]})]})]})}),c.jsx(za,{className:"flex flex-col items-start pt-0 pb-4",children:c.jsxs("div",{className:"flex flex-wrap gap-1",children:[c.jsxs(Ce,{variant:"outline",size:"sm",onClick:t,className:"text-muted-foreground hover:text-foreground",children:[c.jsx(J,{icon:HB,size:14,strokeWidth:2,"data-slot":"icon"}),c.jsx("span",{className:"max-sm:hidden",children:r("linkRepo")})]}),c.jsxs(Ce,{variant:"outline",size:"sm",onClick:n,className:"text-muted-foreground hover:text-destructive",title:r("delete.button"),children:[c.jsx(J,{icon:ma,size:14,strokeWidth:2,"data-slot":"icon"}),c.jsx("span",{className:"max-sm:hidden",children:r("delete.button")})]})]})})]})}function $At({project:e,open:t,onOpenChange:n,onDelete:r}){const{t:i}=Dt("projects"),[s,a]=x.useState(!1),[o,l]=x.useState(!1),[u,d]=x.useState(!1),f=async()=>{d(!0);try{await r(s,o),n(!1)}finally{d(!1)}};return c.jsx(xc,{open:t,onOpenChange:n,children:c.jsxs(_c,{children:[c.jsxs(Sc,{children:[c.jsx(Ec,{children:i("delete.title")}),c.jsx(Cc,{children:i("delete.description",{name:e?.name})})]}),c.jsxs("div",{className:"space-y-3 py-2",children:[e&&e.repositories.length>0&&c.jsx("div",{className:"rounded-md bg-amber-500/10 px-3 py-2 text-sm text-amber-600",children:i("delete.reposWarning",{count:e.repositories.length})}),e?.repository&&c.jsxs("div",{className:"flex items-center space-x-2",children:[c.jsx(Ci,{id:"deleteDirectory",checked:s,onCheckedChange:h=>a(h===!0)}),c.jsx(Kr,{htmlFor:"deleteDirectory",className:"text-sm",children:i("delete.alsoDeleteDirectory")})]}),e?.app&&c.jsxs("div",{className:"flex items-center space-x-2",children:[c.jsx(Ci,{id:"deleteApp",checked:o,onCheckedChange:h=>l(h===!0)}),c.jsx(Kr,{htmlFor:"deleteApp",className:"text-sm",children:i("delete.alsoDeleteApp")})]})]}),c.jsxs(wc,{children:[c.jsx(kc,{disabled:u,children:"Cancel"}),c.jsx(hg,{onClick:f,disabled:u,className:"bg-destructive hover:bg-destructive/90",children:i(u?"delete.deleting":"delete.button")})]})]})})}function UAt(){const{t:e}=Dt("projects"),t=ji(),{data:n,isLoading:r,error:i}=_u(),s=qSe(),[a,o]=x.useState(null),[l,u]=x.useState(!1),[d,f]=x.useState(!1),[h,m]=x.useState(""),b=x.useMemo(()=>n?h?.trim()?n.map(v=>({project:v,score:Math.max(Sl(v.name,h),Sl(v.repository?.path??"",h),Sl(v.repository?.displayName??"",h))})).filter(({score:v})=>v>0).sort((v,_)=>_.score-v.score).map(({project:v})=>v):n:[],[n,h]),y=async(v,_)=>{a&&await s.mutateAsync({id:a.id,deleteDirectory:v,deleteApp:_})};return c.jsxs("div",{className:"flex h-full flex-col",children:[c.jsxs("div",{className:"film-grain relative flex shrink-0 items-center gap-2 border-b border-border px-4 py-2",style:{background:"var(--gradient-header)"},children:[c.jsxs("div",{className:"relative min-w-0 flex-1 sm:max-w-64 sm:flex-none",children:[c.jsx(J,{icon:np,size:12,strokeWidth:2,className:"absolute left-2 top-1/2 -translate-y-1/2 text-muted-foreground"}),c.jsx(kt,{value:h,onChange:v=>m(v.target.value),placeholder:e("searchPlaceholder"),className:"w-full pl-6"})]}),c.jsx("div",{className:"hidden sm:block flex-1"}),c.jsxs(Ce,{size:"sm",variant:"outline",onClick:()=>f(!0),children:[c.jsx(J,{icon:VB,size:16,strokeWidth:2,"data-slot":"icon"}),c.jsx("span",{className:"max-sm:hidden",children:e("addRepo")})]}),c.jsxs(Ce,{size:"sm",onClick:()=>u(!0),children:[c.jsx(J,{icon:Q1e,size:16,strokeWidth:2,"data-slot":"icon"}),c.jsx("span",{className:"max-sm:hidden",children:e("newProjectButton")})]})]}),c.jsxs("div",{className:"flex-1 overflow-auto p-4",children:[r&&c.jsx("div",{className:"flex items-center justify-center py-12",children:c.jsx(J,{icon:Rt,size:24,strokeWidth:2,className:"animate-spin text-muted-foreground"})}),i&&c.jsxs("div",{className:"flex items-center gap-3 py-6 text-destructive",children:[c.jsx(J,{icon:Pr,size:20,strokeWidth:2}),c.jsx("span",{className:"text-sm",children:e("error.failedToLoad",{message:i.message})})]}),!r&&!i&&n?.length===0&&c.jsx("div",{className:"py-12 text-muted-foreground",children:c.jsx("p",{className:"text-sm",children:e("empty.noProjects")})}),!r&&!i&&n&&n.length>0&&b.length===0&&c.jsx("div",{className:"py-12 text-muted-foreground",children:c.jsx("p",{className:"text-sm",children:e("empty.noMatches")})}),c.jsx("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4",children:b.map(v=>c.jsx(BAt,{project:v,onAddRepo:()=>t({to:"/projects/$projectId",params:{projectId:v.id},search:{addRepo:!0}}),onDeleteClick:()=>o(v)},v.id))})]}),c.jsx($At,{project:a,open:a!==null,onOpenChange:v=>!v&&o(null),onDelete:y}),c.jsx(DAt,{open:l,onOpenChange:u}),c.jsx(hOe,{open:d,onOpenChange:f})]})}var Z6,zce;function al(){if(zce)return Z6;zce=1;var e=Array.isArray;return Z6=e,Z6}var Q6,Hce;function pOe(){if(Hce)return Q6;Hce=1;var e=typeof $T=="object"&&$T&&$T.Object===Object&&$T;return Q6=e,Q6}var J6,Vce;function Sd(){if(Vce)return J6;Vce=1;var e=pOe(),t=typeof self=="object"&&self&&self.Object===Object&&self,n=e||t||Function("return this")();return J6=n,J6}var eM,Wce;function H1(){if(Wce)return eM;Wce=1;var e=Sd(),t=e.Symbol;return eM=t,eM}var tM,qce;function zAt(){if(qce)return tM;qce=1;var e=H1(),t=Object.prototype,n=t.hasOwnProperty,r=t.toString,i=e?e.toStringTag:void 0;function s(a){var o=n.call(a,i),l=a[i];try{a[i]=void 0;var u=!0}catch{}var d=r.call(a);return u&&(o?a[i]=l:delete a[i]),d}return tM=s,tM}var nM,Gce;function HAt(){if(Gce)return nM;Gce=1;var e=Object.prototype,t=e.toString;function n(r){return t.call(r)}return nM=n,nM}var rM,Kce;function fp(){if(Kce)return rM;Kce=1;var e=H1(),t=zAt(),n=HAt(),r="[object Null]",i="[object Undefined]",s=e?e.toStringTag:void 0;function a(o){return o==null?o===void 0?i:r:s&&s in Object(o)?t(o):n(o)}return rM=a,rM}var iM,Yce;function wd(){if(Yce)return iM;Yce=1;function e(t){return t!=null&&typeof t=="object"}return iM=e,iM}var sM,Xce;function V1(){if(Xce)return sM;Xce=1;var e=fp(),t=wd(),n="[object Symbol]";function r(i){return typeof i=="symbol"||t(i)&&e(i)==n}return sM=r,sM}var aM,Zce;function UZ(){if(Zce)return aM;Zce=1;var e=al(),t=V1(),n=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,r=/^\w*$/;function i(s,a){if(e(s))return!1;var o=typeof s;return o=="number"||o=="symbol"||o=="boolean"||s==null||t(s)?!0:r.test(s)||!n.test(s)||a!=null&&s in Object(a)}return aM=i,aM}var oM,Qce;function Ed(){if(Qce)return oM;Qce=1;function e(t){var n=typeof t;return t!=null&&(n=="object"||n=="function")}return oM=e,oM}var lM,Jce;function zZ(){if(Jce)return lM;Jce=1;var e=fp(),t=Ed(),n="[object AsyncFunction]",r="[object Function]",i="[object GeneratorFunction]",s="[object Proxy]";function a(o){if(!t(o))return!1;var l=e(o);return l==r||l==i||l==n||l==s}return lM=a,lM}var uM,ede;function VAt(){if(ede)return uM;ede=1;var e=Sd(),t=e["__core-js_shared__"];return uM=t,uM}var cM,tde;function WAt(){if(tde)return cM;tde=1;var e=VAt(),t=(function(){var r=/[^.]+$/.exec(e&&e.keys&&e.keys.IE_PROTO||"");return r?"Symbol(src)_1."+r:""})();function n(r){return!!t&&t in r}return cM=n,cM}var dM,nde;function mOe(){if(nde)return dM;nde=1;var e=Function.prototype,t=e.toString;function n(r){if(r!=null){try{return t.call(r)}catch{}try{return r+""}catch{}}return""}return dM=n,dM}var fM,rde;function qAt(){if(rde)return fM;rde=1;var e=zZ(),t=WAt(),n=Ed(),r=mOe(),i=/[\\^$.*+?()[\]{}|]/g,s=/^\[object .+?Constructor\]$/,a=Function.prototype,o=Object.prototype,l=a.toString,u=o.hasOwnProperty,d=RegExp("^"+l.call(u).replace(i,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function f(h){if(!n(h)||t(h))return!1;var m=e(h)?d:s;return m.test(r(h))}return fM=f,fM}var hM,ide;function GAt(){if(ide)return hM;ide=1;function e(t,n){return t?.[n]}return hM=e,hM}var pM,sde;function Wy(){if(sde)return pM;sde=1;var e=qAt(),t=GAt();function n(r,i){var s=t(r,i);return e(s)?s:void 0}return pM=n,pM}var mM,ade;function l5(){if(ade)return mM;ade=1;var e=Wy(),t=e(Object,"create");return mM=t,mM}var gM,ode;function KAt(){if(ode)return gM;ode=1;var e=l5();function t(){this.__data__=e?e(null):{},this.size=0}return gM=t,gM}var bM,lde;function YAt(){if(lde)return bM;lde=1;function e(t){var n=this.has(t)&&delete this.__data__[t];return this.size-=n?1:0,n}return bM=e,bM}var yM,ude;function XAt(){if(ude)return yM;ude=1;var e=l5(),t="__lodash_hash_undefined__",n=Object.prototype,r=n.hasOwnProperty;function i(s){var a=this.__data__;if(e){var o=a[s];return o===t?void 0:o}return r.call(a,s)?a[s]:void 0}return yM=i,yM}var vM,cde;function ZAt(){if(cde)return vM;cde=1;var e=l5(),t=Object.prototype,n=t.hasOwnProperty;function r(i){var s=this.__data__;return e?s[i]!==void 0:n.call(s,i)}return vM=r,vM}var xM,dde;function QAt(){if(dde)return xM;dde=1;var e=l5(),t="__lodash_hash_undefined__";function n(r,i){var s=this.__data__;return this.size+=this.has(r)?0:1,s[r]=e&&i===void 0?t:i,this}return xM=n,xM}var _M,fde;function JAt(){if(fde)return _M;fde=1;var e=KAt(),t=YAt(),n=XAt(),r=ZAt(),i=QAt();function s(a){var o=-1,l=a==null?0:a.length;for(this.clear();++o<l;){var u=a[o];this.set(u[0],u[1])}}return s.prototype.clear=e,s.prototype.delete=t,s.prototype.get=n,s.prototype.has=r,s.prototype.set=i,_M=s,_M}var SM,hde;function eNt(){if(hde)return SM;hde=1;function e(){this.__data__=[],this.size=0}return SM=e,SM}var wM,pde;function u5(){if(pde)return wM;pde=1;function e(t,n){return t===n||t!==t&&n!==n}return wM=e,wM}var EM,mde;function c5(){if(mde)return EM;mde=1;var e=u5();function t(n,r){for(var i=n.length;i--;)if(e(n[i][0],r))return i;return-1}return EM=t,EM}var CM,gde;function tNt(){if(gde)return CM;gde=1;var e=c5(),t=Array.prototype,n=t.splice;function r(i){var s=this.__data__,a=e(s,i);if(a<0)return!1;var o=s.length-1;return a==o?s.pop():n.call(s,a,1),--this.size,!0}return CM=r,CM}var kM,bde;function nNt(){if(bde)return kM;bde=1;var e=c5();function t(n){var r=this.__data__,i=e(r,n);return i<0?void 0:r[i][1]}return kM=t,kM}var TM,yde;function rNt(){if(yde)return TM;yde=1;var e=c5();function t(n){return e(this.__data__,n)>-1}return TM=t,TM}var AM,vde;function iNt(){if(vde)return AM;vde=1;var e=c5();function t(n,r){var i=this.__data__,s=e(i,n);return s<0?(++this.size,i.push([n,r])):i[s][1]=r,this}return AM=t,AM}var NM,xde;function d5(){if(xde)return NM;xde=1;var e=eNt(),t=tNt(),n=nNt(),r=rNt(),i=iNt();function s(a){var o=-1,l=a==null?0:a.length;for(this.clear();++o<l;){var u=a[o];this.set(u[0],u[1])}}return s.prototype.clear=e,s.prototype.delete=t,s.prototype.get=n,s.prototype.has=r,s.prototype.set=i,NM=s,NM}var OM,_de;function HZ(){if(_de)return OM;_de=1;var e=Wy(),t=Sd(),n=e(t,"Map");return OM=n,OM}var RM,Sde;function sNt(){if(Sde)return RM;Sde=1;var e=JAt(),t=d5(),n=HZ();function r(){this.size=0,this.__data__={hash:new e,map:new(n||t),string:new e}}return RM=r,RM}var IM,wde;function aNt(){if(wde)return IM;wde=1;function e(t){var n=typeof t;return n=="string"||n=="number"||n=="symbol"||n=="boolean"?t!=="__proto__":t===null}return IM=e,IM}var DM,Ede;function f5(){if(Ede)return DM;Ede=1;var e=aNt();function t(n,r){var i=n.__data__;return e(r)?i[typeof r=="string"?"string":"hash"]:i.map}return DM=t,DM}var PM,Cde;function oNt(){if(Cde)return PM;Cde=1;var e=f5();function t(n){var r=e(this,n).delete(n);return this.size-=r?1:0,r}return PM=t,PM}var jM,kde;function lNt(){if(kde)return jM;kde=1;var e=f5();function t(n){return e(this,n).get(n)}return jM=t,jM}var LM,Tde;function uNt(){if(Tde)return LM;Tde=1;var e=f5();function t(n){return e(this,n).has(n)}return LM=t,LM}var MM,Ade;function cNt(){if(Ade)return MM;Ade=1;var e=f5();function t(n,r){var i=e(this,n),s=i.size;return i.set(n,r),this.size+=i.size==s?0:1,this}return MM=t,MM}var FM,Nde;function VZ(){if(Nde)return FM;Nde=1;var e=sNt(),t=oNt(),n=lNt(),r=uNt(),i=cNt();function s(a){var o=-1,l=a==null?0:a.length;for(this.clear();++o<l;){var u=a[o];this.set(u[0],u[1])}}return s.prototype.clear=e,s.prototype.delete=t,s.prototype.get=n,s.prototype.has=r,s.prototype.set=i,FM=s,FM}var BM,Ode;function gOe(){if(Ode)return BM;Ode=1;var e=VZ(),t="Expected a function";function n(r,i){if(typeof r!="function"||i!=null&&typeof i!="function")throw new TypeError(t);var s=function(){var a=arguments,o=i?i.apply(this,a):a[0],l=s.cache;if(l.has(o))return l.get(o);var u=r.apply(this,a);return s.cache=l.set(o,u)||l,u};return s.cache=new(n.Cache||e),s}return n.Cache=e,BM=n,BM}var $M,Rde;function dNt(){if(Rde)return $M;Rde=1;var e=gOe(),t=500;function n(r){var i=e(r,function(a){return s.size===t&&s.clear(),a}),s=i.cache;return i}return $M=n,$M}var UM,Ide;function fNt(){if(Ide)return UM;Ide=1;var e=dNt(),t=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,n=/\\(\\)?/g,r=e(function(i){var s=[];return i.charCodeAt(0)===46&&s.push(""),i.replace(t,function(a,o,l,u){s.push(l?u.replace(n,"$1"):o||a)}),s});return UM=r,UM}var zM,Dde;function h5(){if(Dde)return zM;Dde=1;function e(t,n){for(var r=-1,i=t==null?0:t.length,s=Array(i);++r<i;)s[r]=n(t[r],r,t);return s}return zM=e,zM}var HM,Pde;function hNt(){if(Pde)return HM;Pde=1;var e=H1(),t=h5(),n=al(),r=V1(),i=e?e.prototype:void 0,s=i?i.toString:void 0;function a(o){if(typeof o=="string")return o;if(n(o))return t(o,a)+"";if(r(o))return s?s.call(o):"";var l=o+"";return l=="0"&&1/o==-1/0?"-0":l}return HM=a,HM}var VM,jde;function bOe(){if(jde)return VM;jde=1;var e=hNt();function t(n){return n==null?"":e(n)}return VM=t,VM}var WM,Lde;function p5(){if(Lde)return WM;Lde=1;var e=al(),t=UZ(),n=fNt(),r=bOe();function i(s,a){return e(s)?s:t(s,a)?[s]:n(r(s))}return WM=i,WM}var qM,Mde;function ek(){if(Mde)return qM;Mde=1;var e=V1();function t(n){if(typeof n=="string"||e(n))return n;var r=n+"";return r=="0"&&1/n==-1/0?"-0":r}return qM=t,qM}var GM,Fde;function m5(){if(Fde)return GM;Fde=1;var e=p5(),t=ek();function n(r,i){i=e(i,r);for(var s=0,a=i.length;r!=null&&s<a;)r=r[t(i[s++])];return s&&s==a?r:void 0}return GM=n,GM}var KM,Bde;function yOe(){if(Bde)return KM;Bde=1;var e=m5();function t(n,r,i){var s=n==null?void 0:e(n,r);return s===void 0?i:s}return KM=t,KM}var pNt=yOe();const Fa=Yn(pNt);var YM,$de;function mNt(){if($de)return YM;$de=1;function e(t){return t==null}return YM=e,YM}var gNt=mNt();const Nn=Yn(gNt);var XM,Ude;function bNt(){if(Ude)return XM;Ude=1;var e=fp(),t=al(),n=wd(),r="[object String]";function i(s){return typeof s=="string"||!t(s)&&n(s)&&e(s)==r}return XM=i,XM}var yNt=bNt();const Gm=Yn(yNt);var vNt=zZ();const cn=Yn(vNt);var xNt=Ed();const W1=Yn(xNt);var ZM={exports:{}},ri={};var zde;function _Nt(){if(zde)return ri;zde=1;var e=Symbol.for("react.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),s=Symbol.for("react.provider"),a=Symbol.for("react.context"),o=Symbol.for("react.server_context"),l=Symbol.for("react.forward_ref"),u=Symbol.for("react.suspense"),d=Symbol.for("react.suspense_list"),f=Symbol.for("react.memo"),h=Symbol.for("react.lazy"),m=Symbol.for("react.offscreen"),b;b=Symbol.for("react.module.reference");function y(v){if(typeof v=="object"&&v!==null){var _=v.$$typeof;switch(_){case e:switch(v=v.type,v){case n:case i:case r:case u:case d:return v;default:switch(v=v&&v.$$typeof,v){case o:case a:case l:case h:case f:case s:return v;default:return _}}case t:return _}}}return ri.ContextConsumer=a,ri.ContextProvider=s,ri.Element=e,ri.ForwardRef=l,ri.Fragment=n,ri.Lazy=h,ri.Memo=f,ri.Portal=t,ri.Profiler=i,ri.StrictMode=r,ri.Suspense=u,ri.SuspenseList=d,ri.isAsyncMode=function(){return!1},ri.isConcurrentMode=function(){return!1},ri.isContextConsumer=function(v){return y(v)===a},ri.isContextProvider=function(v){return y(v)===s},ri.isElement=function(v){return typeof v=="object"&&v!==null&&v.$$typeof===e},ri.isForwardRef=function(v){return y(v)===l},ri.isFragment=function(v){return y(v)===n},ri.isLazy=function(v){return y(v)===h},ri.isMemo=function(v){return y(v)===f},ri.isPortal=function(v){return y(v)===t},ri.isProfiler=function(v){return y(v)===i},ri.isStrictMode=function(v){return y(v)===r},ri.isSuspense=function(v){return y(v)===u},ri.isSuspenseList=function(v){return y(v)===d},ri.isValidElementType=function(v){return typeof v=="string"||typeof v=="function"||v===n||v===i||v===r||v===u||v===d||v===m||typeof v=="object"&&v!==null&&(v.$$typeof===h||v.$$typeof===f||v.$$typeof===s||v.$$typeof===a||v.$$typeof===l||v.$$typeof===b||v.getModuleId!==void 0)},ri.typeOf=y,ri}var Hde;function SNt(){return Hde||(Hde=1,ZM.exports=_Nt()),ZM.exports}var wNt=SNt(),QM,Vde;function vOe(){if(Vde)return QM;Vde=1;var e=fp(),t=wd(),n="[object Number]";function r(i){return typeof i=="number"||t(i)&&e(i)==n}return QM=r,QM}var JM,Wde;function ENt(){if(Wde)return JM;Wde=1;var e=vOe();function t(n){return e(n)&&n!=+n}return JM=t,JM}var CNt=ENt();const bg=Yn(CNt);var kNt=vOe();const xOe=Yn(kNt);var Ba=function(t){return t===0?0:t>0?1:-1},Tb=function(t){return Gm(t)&&t.indexOf("%")===t.length-1},Bt=function(t){return xOe(t)&&!bg(t)},TNt=function(t){return Nn(t)},fa=function(t){return Bt(t)||Gm(t)},ANt=0,hp=function(t){var n=++ANt;return"".concat(t||"").concat(n)},Zo=function(t,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1;if(!Bt(t)&&!Gm(t))return r;var s;if(Tb(t)){var a=t.indexOf("%");s=n*parseFloat(t.slice(0,a))/100}else s=+t;return bg(s)&&(s=r),i&&s>n&&(s=n),s},hm=function(t){if(!t)return null;var n=Object.keys(t);return n&&n.length?t[n[0]]:null},NNt=function(t){if(!Array.isArray(t))return!1;for(var n=t.length,r={},i=0;i<n;i++)if(!r[t[i]])r[t[i]]=!0;else return!0;return!1},nr=function(t,n){return Bt(t)&&Bt(n)?function(r){return t+r*(n-t)}:function(){return n}};function _R(e,t,n){return!e||!e.length?null:e.find(function(r){return r&&(typeof t=="function"?t(r):Fa(r,t))===n})}var ONt=function(t){if(!t||!t.length)return null;for(var n=t.length,r=0,i=0,s=0,a=0,o=1/0,l=-1/0,u=0,d=0,f=0;f<n;f++)u=t[f].cx||0,d=t[f].cy||0,r+=u,i+=d,s+=u*d,a+=u*u,o=Math.min(o,u),l=Math.max(l,u);var h=n*a!==r*r?(n*s-r*i)/(n*a-r*r):0;return{xmin:o,xmax:l,a:h,b:(i-h*r)/n}},RNt=function(t,n){return Bt(t)&&Bt(n)?t-n:Gm(t)&&Gm(n)?t.localeCompare(n):t instanceof Date&&n instanceof Date?t.getTime()-n.getTime():String(t).localeCompare(String(n))};function Yb(e,t){for(var n in e)if({}.hasOwnProperty.call(e,n)&&(!{}.hasOwnProperty.call(t,n)||e[n]!==t[n]))return!1;for(var r in t)if({}.hasOwnProperty.call(t,r)&&!{}.hasOwnProperty.call(e,r))return!1;return!0}function HU(e){"@babel/helpers - typeof";return HU=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},HU(e)}var INt=["viewBox","children"],DNt=["aria-activedescendant","aria-atomic","aria-autocomplete","aria-busy","aria-checked","aria-colcount","aria-colindex","aria-colspan","aria-controls","aria-current","aria-describedby","aria-details","aria-disabled","aria-errormessage","aria-expanded","aria-flowto","aria-haspopup","aria-hidden","aria-invalid","aria-keyshortcuts","aria-label","aria-labelledby","aria-level","aria-live","aria-modal","aria-multiline","aria-multiselectable","aria-orientation","aria-owns","aria-placeholder","aria-posinset","aria-pressed","aria-readonly","aria-relevant","aria-required","aria-roledescription","aria-rowcount","aria-rowindex","aria-rowspan","aria-selected","aria-setsize","aria-sort","aria-valuemax","aria-valuemin","aria-valuenow","aria-valuetext","className","color","height","id","lang","max","media","method","min","name","style","target","width","role","tabIndex","accentHeight","accumulate","additive","alignmentBaseline","allowReorder","alphabetic","amplitude","arabicForm","ascent","attributeName","attributeType","autoReverse","azimuth","baseFrequency","baselineShift","baseProfile","bbox","begin","bias","by","calcMode","capHeight","clip","clipPath","clipPathUnits","clipRule","colorInterpolation","colorInterpolationFilters","colorProfile","colorRendering","contentScriptType","contentStyleType","cursor","cx","cy","d","decelerate","descent","diffuseConstant","direction","display","divisor","dominantBaseline","dur","dx","dy","edgeMode","elevation","enableBackground","end","exponent","externalResourcesRequired","fill","fillOpacity","fillRule","filter","filterRes","filterUnits","floodColor","floodOpacity","focusable","fontFamily","fontSize","fontSizeAdjust","fontStretch","fontStyle","fontVariant","fontWeight","format","from","fx","fy","g1","g2","glyphName","glyphOrientationHorizontal","glyphOrientationVertical","glyphRef","gradientTransform","gradientUnits","hanging","horizAdvX","horizOriginX","href","ideographic","imageRendering","in2","in","intercept","k1","k2","k3","k4","k","kernelMatrix","kernelUnitLength","kerning","keyPoints","keySplines","keyTimes","lengthAdjust","letterSpacing","lightingColor","limitingConeAngle","local","markerEnd","markerHeight","markerMid","markerStart","markerUnits","markerWidth","mask","maskContentUnits","maskUnits","mathematical","mode","numOctaves","offset","opacity","operator","order","orient","orientation","origin","overflow","overlinePosition","overlineThickness","paintOrder","panose1","pathLength","patternContentUnits","patternTransform","patternUnits","pointerEvents","pointsAtX","pointsAtY","pointsAtZ","preserveAlpha","preserveAspectRatio","primitiveUnits","r","radius","refX","refY","renderingIntent","repeatCount","repeatDur","requiredExtensions","requiredFeatures","restart","result","rotate","rx","ry","seed","shapeRendering","slope","spacing","specularConstant","specularExponent","speed","spreadMethod","startOffset","stdDeviation","stemh","stemv","stitchTiles","stopColor","stopOpacity","strikethroughPosition","strikethroughThickness","string","stroke","strokeDasharray","strokeDashoffset","strokeLinecap","strokeLinejoin","strokeMiterlimit","strokeOpacity","strokeWidth","surfaceScale","systemLanguage","tableValues","targetX","targetY","textAnchor","textDecoration","textLength","textRendering","to","transform","u1","u2","underlinePosition","underlineThickness","unicode","unicodeBidi","unicodeRange","unitsPerEm","vAlphabetic","values","vectorEffect","version","vertAdvY","vertOriginX","vertOriginY","vHanging","vIdeographic","viewTarget","visibility","vMathematical","widths","wordSpacing","writingMode","x1","x2","x","xChannelSelector","xHeight","xlinkActuate","xlinkArcrole","xlinkHref","xlinkRole","xlinkShow","xlinkTitle","xlinkType","xmlBase","xmlLang","xmlns","xmlnsXlink","xmlSpace","y1","y2","y","yChannelSelector","z","zoomAndPan","ref","key","angle"],qde=["points","pathLength"],e8={svg:INt,polygon:qde,polyline:qde},WZ=["dangerouslySetInnerHTML","onCopy","onCopyCapture","onCut","onCutCapture","onPaste","onPasteCapture","onCompositionEnd","onCompositionEndCapture","onCompositionStart","onCompositionStartCapture","onCompositionUpdate","onCompositionUpdateCapture","onFocus","onFocusCapture","onBlur","onBlurCapture","onChange","onChangeCapture","onBeforeInput","onBeforeInputCapture","onInput","onInputCapture","onReset","onResetCapture","onSubmit","onSubmitCapture","onInvalid","onInvalidCapture","onLoad","onLoadCapture","onError","onErrorCapture","onKeyDown","onKeyDownCapture","onKeyPress","onKeyPressCapture","onKeyUp","onKeyUpCapture","onAbort","onAbortCapture","onCanPlay","onCanPlayCapture","onCanPlayThrough","onCanPlayThroughCapture","onDurationChange","onDurationChangeCapture","onEmptied","onEmptiedCapture","onEncrypted","onEncryptedCapture","onEnded","onEndedCapture","onLoadedData","onLoadedDataCapture","onLoadedMetadata","onLoadedMetadataCapture","onLoadStart","onLoadStartCapture","onPause","onPauseCapture","onPlay","onPlayCapture","onPlaying","onPlayingCapture","onProgress","onProgressCapture","onRateChange","onRateChangeCapture","onSeeked","onSeekedCapture","onSeeking","onSeekingCapture","onStalled","onStalledCapture","onSuspend","onSuspendCapture","onTimeUpdate","onTimeUpdateCapture","onVolumeChange","onVolumeChangeCapture","onWaiting","onWaitingCapture","onAuxClick","onAuxClickCapture","onClick","onClickCapture","onContextMenu","onContextMenuCapture","onDoubleClick","onDoubleClickCapture","onDrag","onDragCapture","onDragEnd","onDragEndCapture","onDragEnter","onDragEnterCapture","onDragExit","onDragExitCapture","onDragLeave","onDragLeaveCapture","onDragOver","onDragOverCapture","onDragStart","onDragStartCapture","onDrop","onDropCapture","onMouseDown","onMouseDownCapture","onMouseEnter","onMouseLeave","onMouseMove","onMouseMoveCapture","onMouseOut","onMouseOutCapture","onMouseOver","onMouseOverCapture","onMouseUp","onMouseUpCapture","onSelect","onSelectCapture","onTouchCancel","onTouchCancelCapture","onTouchEnd","onTouchEndCapture","onTouchMove","onTouchMoveCapture","onTouchStart","onTouchStartCapture","onPointerDown","onPointerDownCapture","onPointerMove","onPointerMoveCapture","onPointerUp","onPointerUpCapture","onPointerCancel","onPointerCancelCapture","onPointerEnter","onPointerEnterCapture","onPointerLeave","onPointerLeaveCapture","onPointerOver","onPointerOverCapture","onPointerOut","onPointerOutCapture","onGotPointerCapture","onGotPointerCaptureCapture","onLostPointerCapture","onLostPointerCaptureCapture","onScroll","onScrollCapture","onWheel","onWheelCapture","onAnimationStart","onAnimationStartCapture","onAnimationEnd","onAnimationEndCapture","onAnimationIteration","onAnimationIterationCapture","onTransitionEnd","onTransitionEndCapture"],SR=function(t,n){if(!t||typeof t=="function"||typeof t=="boolean")return null;var r=t;if(x.isValidElement(t)&&(r=t.props),!W1(r))return null;var i={};return Object.keys(r).forEach(function(s){WZ.includes(s)&&(i[s]=n||function(a){return r[s](r,a)})}),i},PNt=function(t,n,r){return function(i){return t(n,r,i),null}},pd=function(t,n,r){if(!W1(t)||HU(t)!=="object")return null;var i=null;return Object.keys(t).forEach(function(s){var a=t[s];WZ.includes(s)&&typeof a=="function"&&(i||(i={}),i[s]=PNt(a,n,r))}),i},jNt=["children"],LNt=["children"];function Gde(e,t){if(e==null)return{};var n=MNt(e,t),r,i;if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(i=0;i<s.length;i++)r=s[i],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}function MNt(e,t){if(e==null)return{};var n={};for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r)){if(t.indexOf(r)>=0)continue;n[r]=e[r]}return n}function VU(e){"@babel/helpers - typeof";return VU=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},VU(e)}var Kde={click:"onClick",mousedown:"onMouseDown",mouseup:"onMouseUp",mouseover:"onMouseOver",mousemove:"onMouseMove",mouseout:"onMouseOut",mouseenter:"onMouseEnter",mouseleave:"onMouseLeave",touchcancel:"onTouchCancel",touchend:"onTouchEnd",touchmove:"onTouchMove",touchstart:"onTouchStart",contextmenu:"onContextMenu",dblclick:"onDoubleClick"},Ih=function(t){return typeof t=="string"?t:t?t.displayName||t.name||"Component":""},Yde=null,t8=null,g5=function e(t){if(t===Yde&&Array.isArray(t8))return t8;var n=[];return x.Children.forEach(t,function(r){Nn(r)||(wNt.isFragment(r)?n=n.concat(e(r.props.children)):n.push(r))}),t8=n,Yde=t,n};function lo(e,t){var n=[],r=[];return Array.isArray(t)?r=t.map(function(i){return Ih(i)}):r=[Ih(t)],g5(e).forEach(function(i){var s=Fa(i,"type.displayName")||Fa(i,"type.name");r.indexOf(s)!==-1&&n.push(i)}),n}function Ws(e,t){var n=lo(e,t);return n&&n[0]}var wR=function(t){if(!t||!t.props)return!1;var n=t.props,r=n.width,i=n.height;return!(!Bt(r)||r<=0||!Bt(i)||i<=0)},FNt=["a","altGlyph","altGlyphDef","altGlyphItem","animate","animateColor","animateMotion","animateTransform","circle","clipPath","color-profile","cursor","defs","desc","ellipse","feBlend","feColormatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence","filter","font","font-face","font-face-format","font-face-name","font-face-url","foreignObject","g","glyph","glyphRef","hkern","image","line","lineGradient","marker","mask","metadata","missing-glyph","mpath","path","pattern","polygon","polyline","radialGradient","rect","script","set","stop","style","svg","switch","symbol","text","textPath","title","tref","tspan","use","view","vkern"],_Oe=function(t){return t&&t.type&&Gm(t.type)&&FNt.indexOf(t.type)>=0},SOe=function(t){return t&&VU(t)==="object"&&"clipDot"in t},BNt=function(t,n,r,i){var s,a=(s=e8?.[i])!==null&&s!==void 0?s:[];return n.startsWith("data-")||!cn(t)&&(i&&a.includes(n)||DNt.includes(n))||r&&WZ.includes(n)},wOe=function(t){var n=[];return g5(t).forEach(function(r){_Oe(r)&&n.push(r)}),n},Zt=function(t,n,r){if(!t||typeof t=="function"||typeof t=="boolean")return null;var i=t;if(x.isValidElement(t)&&(i=t.props),!W1(i))return null;var s={};return Object.keys(i).forEach(function(a){var o;BNt((o=i)===null||o===void 0?void 0:o[a],a,n,r)&&(s[a]=i[a])}),s},WU=function e(t,n){if(t===n)return!0;var r=x.Children.count(t);if(r!==x.Children.count(n))return!1;if(r===0)return!0;if(r===1)return Xde(Array.isArray(t)?t[0]:t,Array.isArray(n)?n[0]:n);for(var i=0;i<r;i++){var s=t[i],a=n[i];if(Array.isArray(s)||Array.isArray(a)){if(!e(s,a))return!1}else if(!Xde(s,a))return!1}return!0},Xde=function(t,n){if(Nn(t)&&Nn(n))return!0;if(!Nn(t)&&!Nn(n)){var r=t.props||{},i=r.children,s=Gde(r,jNt),a=n.props||{},o=a.children,l=Gde(a,LNt);return i&&o?Yb(s,l)&&WU(i,o):!i&&!o?Yb(s,l):!1}return!1},Zde=function(t,n){var r=[],i={};return g5(t).forEach(function(s,a){if(_Oe(s))r.push(s);else if(s){var o=Ih(s.type),l=n[o]||{},u=l.handler,d=l.once;if(u&&(!d||!i[o])){var f=u(s,o,a);r.push(f),i[o]=!0}}}),r},$Nt=function(t){var n=t&&t.type;return n&&Kde[n]?Kde[n]:null},UNt=function(t,n){return g5(n).indexOf(t)},zNt=["children","width","height","viewBox","className","style","title","desc"];function qU(){return qU=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},qU.apply(this,arguments)}function HNt(e,t){if(e==null)return{};var n=VNt(e,t),r,i;if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(i=0;i<s.length;i++)r=s[i],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}function VNt(e,t){if(e==null)return{};var n={};for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r)){if(t.indexOf(r)>=0)continue;n[r]=e[r]}return n}function ZE(e){var t=e.children,n=e.width,r=e.height,i=e.viewBox,s=e.className,a=e.style,o=e.title,l=e.desc,u=HNt(e,zNt),d=i||{width:n,height:r,x:0,y:0},f=Tn("recharts-surface",s);return Z.createElement("svg",qU({},Zt(u,!0,"svg"),{className:f,width:n,height:r,style:a,viewBox:"".concat(d.x," ").concat(d.y," ").concat(d.width," ").concat(d.height)}),Z.createElement("title",null,o),Z.createElement("desc",null,l),t)}var WNt=["children","className"];function GU(){return GU=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},GU.apply(this,arguments)}function qNt(e,t){if(e==null)return{};var n=GNt(e,t),r,i;if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(i=0;i<s.length;i++)r=s[i],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}function GNt(e,t){if(e==null)return{};var n={};for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r)){if(t.indexOf(r)>=0)continue;n[r]=e[r]}return n}var Sn=Z.forwardRef(function(e,t){var n=e.children,r=e.className,i=qNt(e,WNt),s=Tn("recharts-layer",r);return Z.createElement("g",GU({className:s},Zt(i,!0),{ref:t}),n)}),ld=function(t,n){for(var r=arguments.length,i=new Array(r>2?r-2:0),s=2;s<r;s++)i[s-2]=arguments[s]},n8,Qde;function EOe(){if(Qde)return n8;Qde=1;function e(t,n,r){var i=-1,s=t.length;n<0&&(n=-n>s?0:s+n),r=r>s?s:r,r<0&&(r+=s),s=n>r?0:r-n>>>0,n>>>=0;for(var a=Array(s);++i<s;)a[i]=t[i+n];return a}return n8=e,n8}var r8,Jde;function KNt(){if(Jde)return r8;Jde=1;var e=EOe();function t(n,r,i){var s=n.length;return i=i===void 0?s:i,!r&&i>=s?n:e(n,r,i)}return r8=t,r8}var i8,efe;function COe(){if(efe)return i8;efe=1;var e="\\ud800-\\udfff",t="\\u0300-\\u036f",n="\\ufe20-\\ufe2f",r="\\u20d0-\\u20ff",i=t+n+r,s="\\ufe0e\\ufe0f",a="\\u200d",o=RegExp("["+a+e+i+s+"]");function l(u){return o.test(u)}return i8=l,i8}var s8,tfe;function YNt(){if(tfe)return s8;tfe=1;function e(t){return t.split("")}return s8=e,s8}var a8,nfe;function XNt(){if(nfe)return a8;nfe=1;var e="\\ud800-\\udfff",t="\\u0300-\\u036f",n="\\ufe20-\\ufe2f",r="\\u20d0-\\u20ff",i=t+n+r,s="\\ufe0e\\ufe0f",a="["+e+"]",o="["+i+"]",l="\\ud83c[\\udffb-\\udfff]",u="(?:"+o+"|"+l+")",d="[^"+e+"]",f="(?:\\ud83c[\\udde6-\\uddff]){2}",h="[\\ud800-\\udbff][\\udc00-\\udfff]",m="\\u200d",b=u+"?",y="["+s+"]?",v="(?:"+m+"(?:"+[d,f,h].join("|")+")"+y+b+")*",_=y+b+v,w="(?:"+[d+o+"?",o,f,h,a].join("|")+")",C=RegExp(l+"(?="+l+")|"+w+_,"g");function T(k){return k.match(C)||[]}return a8=T,a8}var o8,rfe;function ZNt(){if(rfe)return o8;rfe=1;var e=YNt(),t=COe(),n=XNt();function r(i){return t(i)?n(i):e(i)}return o8=r,o8}var l8,ife;function QNt(){if(ife)return l8;ife=1;var e=KNt(),t=COe(),n=ZNt(),r=bOe();function i(s){return function(a){a=r(a);var o=t(a)?n(a):void 0,l=o?o[0]:a.charAt(0),u=o?e(o,1).join(""):a.slice(1);return l[s]()+u}}return l8=i,l8}var u8,sfe;function JNt(){if(sfe)return u8;sfe=1;var e=QNt(),t=e("toUpperCase");return u8=t,u8}var eOt=JNt();const b5=Yn(eOt);function Di(e){return function(){return e}}const kOe=Math.cos,ER=Math.sin,Cd=Math.sqrt,CR=Math.PI,y5=2*CR,KU=Math.PI,YU=2*KU,ab=1e-6,tOt=YU-ab;function TOe(e){this._+=e[0];for(let t=1,n=e.length;t<n;++t)this._+=arguments[t]+e[t]}function nOt(e){let t=Math.floor(e);if(!(t>=0))throw new Error(`invalid digits: ${e}`);if(t>15)return TOe;const n=10**t;return function(r){this._+=r[0];for(let i=1,s=r.length;i<s;++i)this._+=Math.round(arguments[i]*n)/n+r[i]}}class rOt{constructor(t){this._x0=this._y0=this._x1=this._y1=null,this._="",this._append=t==null?TOe:nOt(t)}moveTo(t,n){this._append`M${this._x0=this._x1=+t},${this._y0=this._y1=+n}`}closePath(){this._x1!==null&&(this._x1=this._x0,this._y1=this._y0,this._append`Z`)}lineTo(t,n){this._append`L${this._x1=+t},${this._y1=+n}`}quadraticCurveTo(t,n,r,i){this._append`Q${+t},${+n},${this._x1=+r},${this._y1=+i}`}bezierCurveTo(t,n,r,i,s,a){this._append`C${+t},${+n},${+r},${+i},${this._x1=+s},${this._y1=+a}`}arcTo(t,n,r,i,s){if(t=+t,n=+n,r=+r,i=+i,s=+s,s<0)throw new Error(`negative radius: ${s}`);let a=this._x1,o=this._y1,l=r-t,u=i-n,d=a-t,f=o-n,h=d*d+f*f;if(this._x1===null)this._append`M${this._x1=t},${this._y1=n}`;else if(h>ab)if(!(Math.abs(f*l-u*d)>ab)||!s)this._append`L${this._x1=t},${this._y1=n}`;else{let m=r-a,b=i-o,y=l*l+u*u,v=m*m+b*b,_=Math.sqrt(y),w=Math.sqrt(h),C=s*Math.tan((KU-Math.acos((y+h-v)/(2*_*w)))/2),T=C/w,k=C/_;Math.abs(T-1)>ab&&this._append`L${t+T*d},${n+T*f}`,this._append`A${s},${s},0,0,${+(f*m>d*b)},${this._x1=t+k*l},${this._y1=n+k*u}`}}arc(t,n,r,i,s,a){if(t=+t,n=+n,r=+r,a=!!a,r<0)throw new Error(`negative radius: ${r}`);let o=r*Math.cos(i),l=r*Math.sin(i),u=t+o,d=n+l,f=1^a,h=a?i-s:s-i;this._x1===null?this._append`M${u},${d}`:(Math.abs(this._x1-u)>ab||Math.abs(this._y1-d)>ab)&&this._append`L${u},${d}`,r&&(h<0&&(h=h%YU+YU),h>tOt?this._append`A${r},${r},0,1,${f},${t-o},${n-l}A${r},${r},0,1,${f},${this._x1=u},${this._y1=d}`:h>ab&&this._append`A${r},${r},0,${+(h>=KU)},${f},${this._x1=t+r*Math.cos(s)},${this._y1=n+r*Math.sin(s)}`)}rect(t,n,r,i){this._append`M${this._x0=this._x1=+t},${this._y0=this._y1=+n}h${r=+r}v${+i}h${-r}Z`}toString(){return this._}}function qZ(e){let t=3;return e.digits=function(n){if(!arguments.length)return t;if(n==null)t=null;else{const r=Math.floor(n);if(!(r>=0))throw new RangeError(`invalid digits: ${n}`);t=r}return e},()=>new rOt(t)}function GZ(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function AOe(e){this._context=e}AOe.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._point=0},lineEnd:function(){(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;default:this._context.lineTo(e,t);break}}};function v5(e){return new AOe(e)}function NOe(e){return e[0]}function OOe(e){return e[1]}function ROe(e,t){var n=Di(!0),r=null,i=v5,s=null,a=qZ(o);e=typeof e=="function"?e:e===void 0?NOe:Di(e),t=typeof t=="function"?t:t===void 0?OOe:Di(t);function o(l){var u,d=(l=GZ(l)).length,f,h=!1,m;for(r==null&&(s=i(m=a())),u=0;u<=d;++u)!(u<d&&n(f=l[u],u,l))===h&&((h=!h)?s.lineStart():s.lineEnd()),h&&s.point(+e(f,u,l),+t(f,u,l));if(m)return s=null,m+""||null}return o.x=function(l){return arguments.length?(e=typeof l=="function"?l:Di(+l),o):e},o.y=function(l){return arguments.length?(t=typeof l=="function"?l:Di(+l),o):t},o.defined=function(l){return arguments.length?(n=typeof l=="function"?l:Di(!!l),o):n},o.curve=function(l){return arguments.length?(i=l,r!=null&&(s=i(r)),o):i},o.context=function(l){return arguments.length?(l==null?r=s=null:s=i(r=l),o):r},o}function qA(e,t,n){var r=null,i=Di(!0),s=null,a=v5,o=null,l=qZ(u);e=typeof e=="function"?e:e===void 0?NOe:Di(+e),t=typeof t=="function"?t:Di(t===void 0?0:+t),n=typeof n=="function"?n:n===void 0?OOe:Di(+n);function u(f){var h,m,b,y=(f=GZ(f)).length,v,_=!1,w,C=new Array(y),T=new Array(y);for(s==null&&(o=a(w=l())),h=0;h<=y;++h){if(!(h<y&&i(v=f[h],h,f))===_)if(_=!_)m=h,o.areaStart(),o.lineStart();else{for(o.lineEnd(),o.lineStart(),b=h-1;b>=m;--b)o.point(C[b],T[b]);o.lineEnd(),o.areaEnd()}_&&(C[h]=+e(v,h,f),T[h]=+t(v,h,f),o.point(r?+r(v,h,f):C[h],n?+n(v,h,f):T[h]))}if(w)return o=null,w+""||null}function d(){return ROe().defined(i).curve(a).context(s)}return u.x=function(f){return arguments.length?(e=typeof f=="function"?f:Di(+f),r=null,u):e},u.x0=function(f){return arguments.length?(e=typeof f=="function"?f:Di(+f),u):e},u.x1=function(f){return arguments.length?(r=f==null?null:typeof f=="function"?f:Di(+f),u):r},u.y=function(f){return arguments.length?(t=typeof f=="function"?f:Di(+f),n=null,u):t},u.y0=function(f){return arguments.length?(t=typeof f=="function"?f:Di(+f),u):t},u.y1=function(f){return arguments.length?(n=f==null?null:typeof f=="function"?f:Di(+f),u):n},u.lineX0=u.lineY0=function(){return d().x(e).y(t)},u.lineY1=function(){return d().x(e).y(n)},u.lineX1=function(){return d().x(r).y(t)},u.defined=function(f){return arguments.length?(i=typeof f=="function"?f:Di(!!f),u):i},u.curve=function(f){return arguments.length?(a=f,s!=null&&(o=a(s)),u):a},u.context=function(f){return arguments.length?(f==null?s=o=null:o=a(s=f),u):s},u}class IOe{constructor(t,n){this._context=t,this._x=n}areaStart(){this._line=0}areaEnd(){this._line=NaN}lineStart(){this._point=0}lineEnd(){(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line}point(t,n){switch(t=+t,n=+n,this._point){case 0:{this._point=1,this._line?this._context.lineTo(t,n):this._context.moveTo(t,n);break}case 1:this._point=2;default:{this._x?this._context.bezierCurveTo(this._x0=(this._x0+t)/2,this._y0,this._x0,n,t,n):this._context.bezierCurveTo(this._x0,this._y0=(this._y0+n)/2,t,this._y0,t,n);break}}this._x0=t,this._y0=n}}function iOt(e){return new IOe(e,!0)}function sOt(e){return new IOe(e,!1)}const KZ={draw(e,t){const n=Cd(t/CR);e.moveTo(n,0),e.arc(0,0,n,0,y5)}},aOt={draw(e,t){const n=Cd(t/5)/2;e.moveTo(-3*n,-n),e.lineTo(-n,-n),e.lineTo(-n,-3*n),e.lineTo(n,-3*n),e.lineTo(n,-n),e.lineTo(3*n,-n),e.lineTo(3*n,n),e.lineTo(n,n),e.lineTo(n,3*n),e.lineTo(-n,3*n),e.lineTo(-n,n),e.lineTo(-3*n,n),e.closePath()}},DOe=Cd(1/3),oOt=DOe*2,lOt={draw(e,t){const n=Cd(t/oOt),r=n*DOe;e.moveTo(0,-n),e.lineTo(r,0),e.lineTo(0,n),e.lineTo(-r,0),e.closePath()}},uOt={draw(e,t){const n=Cd(t),r=-n/2;e.rect(r,r,n,n)}},cOt=.8908130915292852,POe=ER(CR/10)/ER(7*CR/10),dOt=ER(y5/10)*POe,fOt=-kOe(y5/10)*POe,hOt={draw(e,t){const n=Cd(t*cOt),r=dOt*n,i=fOt*n;e.moveTo(0,-n),e.lineTo(r,i);for(let s=1;s<5;++s){const a=y5*s/5,o=kOe(a),l=ER(a);e.lineTo(l*n,-o*n),e.lineTo(o*r-l*i,l*r+o*i)}e.closePath()}},c8=Cd(3),pOt={draw(e,t){const n=-Cd(t/(c8*3));e.moveTo(0,n*2),e.lineTo(-c8*n,-n),e.lineTo(c8*n,-n),e.closePath()}},Fu=-.5,Bu=Cd(3)/2,XU=1/Cd(12),mOt=(XU/2+1)*3,gOt={draw(e,t){const n=Cd(t/mOt),r=n/2,i=n*XU,s=r,a=n*XU+n,o=-s,l=a;e.moveTo(r,i),e.lineTo(s,a),e.lineTo(o,l),e.lineTo(Fu*r-Bu*i,Bu*r+Fu*i),e.lineTo(Fu*s-Bu*a,Bu*s+Fu*a),e.lineTo(Fu*o-Bu*l,Bu*o+Fu*l),e.lineTo(Fu*r+Bu*i,Fu*i-Bu*r),e.lineTo(Fu*s+Bu*a,Fu*a-Bu*s),e.lineTo(Fu*o+Bu*l,Fu*l-Bu*o),e.closePath()}};function bOt(e,t){let n=null,r=qZ(i);e=typeof e=="function"?e:Di(e||KZ),t=typeof t=="function"?t:Di(t===void 0?64:+t);function i(){let s;if(n||(n=s=r()),e.apply(this,arguments).draw(n,+t.apply(this,arguments)),s)return n=null,s+""||null}return i.type=function(s){return arguments.length?(e=typeof s=="function"?s:Di(s),i):e},i.size=function(s){return arguments.length?(t=typeof s=="function"?s:Di(+s),i):t},i.context=function(s){return arguments.length?(n=s??null,i):n},i}function kR(){}function TR(e,t,n){e._context.bezierCurveTo((2*e._x0+e._x1)/3,(2*e._y0+e._y1)/3,(e._x0+2*e._x1)/3,(e._y0+2*e._y1)/3,(e._x0+4*e._x1+t)/6,(e._y0+4*e._y1+n)/6)}function jOe(e){this._context=e}jOe.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=NaN,this._point=0},lineEnd:function(){switch(this._point){case 3:TR(this,this._x1,this._y1);case 2:this._context.lineTo(this._x1,this._y1);break}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;break;case 2:this._point=3,this._context.lineTo((5*this._x0+this._x1)/6,(5*this._y0+this._y1)/6);default:TR(this,e,t);break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t}};function yOt(e){return new jOe(e)}function LOe(e){this._context=e}LOe.prototype={areaStart:kR,areaEnd:kR,lineStart:function(){this._x0=this._x1=this._x2=this._x3=this._x4=this._y0=this._y1=this._y2=this._y3=this._y4=NaN,this._point=0},lineEnd:function(){switch(this._point){case 1:{this._context.moveTo(this._x2,this._y2),this._context.closePath();break}case 2:{this._context.moveTo((this._x2+2*this._x3)/3,(this._y2+2*this._y3)/3),this._context.lineTo((this._x3+2*this._x2)/3,(this._y3+2*this._y2)/3),this._context.closePath();break}case 3:{this.point(this._x2,this._y2),this.point(this._x3,this._y3),this.point(this._x4,this._y4);break}}},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._x2=e,this._y2=t;break;case 1:this._point=2,this._x3=e,this._y3=t;break;case 2:this._point=3,this._x4=e,this._y4=t,this._context.moveTo((this._x0+4*this._x1+e)/6,(this._y0+4*this._y1+t)/6);break;default:TR(this,e,t);break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t}};function vOt(e){return new LOe(e)}function MOe(e){this._context=e}MOe.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=NaN,this._point=0},lineEnd:function(){(this._line||this._line!==0&&this._point===3)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1;break;case 1:this._point=2;break;case 2:this._point=3;var n=(this._x0+4*this._x1+e)/6,r=(this._y0+4*this._y1+t)/6;this._line?this._context.lineTo(n,r):this._context.moveTo(n,r);break;case 3:this._point=4;default:TR(this,e,t);break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t}};function xOt(e){return new MOe(e)}function FOe(e){this._context=e}FOe.prototype={areaStart:kR,areaEnd:kR,lineStart:function(){this._point=0},lineEnd:function(){this._point&&this._context.closePath()},point:function(e,t){e=+e,t=+t,this._point?this._context.lineTo(e,t):(this._point=1,this._context.moveTo(e,t))}};function _Ot(e){return new FOe(e)}function afe(e){return e<0?-1:1}function ofe(e,t,n){var r=e._x1-e._x0,i=t-e._x1,s=(e._y1-e._y0)/(r||i<0&&-0),a=(n-e._y1)/(i||r<0&&-0),o=(s*i+a*r)/(r+i);return(afe(s)+afe(a))*Math.min(Math.abs(s),Math.abs(a),.5*Math.abs(o))||0}function lfe(e,t){var n=e._x1-e._x0;return n?(3*(e._y1-e._y0)/n-t)/2:t}function d8(e,t,n){var r=e._x0,i=e._y0,s=e._x1,a=e._y1,o=(s-r)/3;e._context.bezierCurveTo(r+o,i+o*t,s-o,a-o*n,s,a)}function AR(e){this._context=e}AR.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=this._t0=NaN,this._point=0},lineEnd:function(){switch(this._point){case 2:this._context.lineTo(this._x1,this._y1);break;case 3:d8(this,this._t0,lfe(this,this._t0));break}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){var n=NaN;if(e=+e,t=+t,!(e===this._x1&&t===this._y1)){switch(this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;break;case 2:this._point=3,d8(this,lfe(this,n=ofe(this,e,t)),n);break;default:d8(this,this._t0,n=ofe(this,e,t));break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t,this._t0=n}}};function BOe(e){this._context=new $Oe(e)}(BOe.prototype=Object.create(AR.prototype)).point=function(e,t){AR.prototype.point.call(this,t,e)};function $Oe(e){this._context=e}$Oe.prototype={moveTo:function(e,t){this._context.moveTo(t,e)},closePath:function(){this._context.closePath()},lineTo:function(e,t){this._context.lineTo(t,e)},bezierCurveTo:function(e,t,n,r,i,s){this._context.bezierCurveTo(t,e,r,n,s,i)}};function SOt(e){return new AR(e)}function wOt(e){return new BOe(e)}function UOe(e){this._context=e}UOe.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x=[],this._y=[]},lineEnd:function(){var e=this._x,t=this._y,n=e.length;if(n)if(this._line?this._context.lineTo(e[0],t[0]):this._context.moveTo(e[0],t[0]),n===2)this._context.lineTo(e[1],t[1]);else for(var r=ufe(e),i=ufe(t),s=0,a=1;a<n;++s,++a)this._context.bezierCurveTo(r[0][s],i[0][s],r[1][s],i[1][s],e[a],t[a]);(this._line||this._line!==0&&n===1)&&this._context.closePath(),this._line=1-this._line,this._x=this._y=null},point:function(e,t){this._x.push(+e),this._y.push(+t)}};function ufe(e){var t,n=e.length-1,r,i=new Array(n),s=new Array(n),a=new Array(n);for(i[0]=0,s[0]=2,a[0]=e[0]+2*e[1],t=1;t<n-1;++t)i[t]=1,s[t]=4,a[t]=4*e[t]+2*e[t+1];for(i[n-1]=2,s[n-1]=7,a[n-1]=8*e[n-1]+e[n],t=1;t<n;++t)r=i[t]/s[t-1],s[t]-=r,a[t]-=r*a[t-1];for(i[n-1]=a[n-1]/s[n-1],t=n-2;t>=0;--t)i[t]=(a[t]-i[t+1])/s[t];for(s[n-1]=(e[n]+i[n-1])/2,t=0;t<n-1;++t)s[t]=2*e[t+1]-i[t+1];return[i,s]}function EOt(e){return new UOe(e)}function x5(e,t){this._context=e,this._t=t}x5.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x=this._y=NaN,this._point=0},lineEnd:function(){0<this._t&&this._t<1&&this._point===2&&this._context.lineTo(this._x,this._y),(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line>=0&&(this._t=1-this._t,this._line=1-this._line)},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;default:{if(this._t<=0)this._context.lineTo(this._x,t),this._context.lineTo(e,t);else{var n=this._x*(1-this._t)+e*this._t;this._context.lineTo(n,this._y),this._context.lineTo(n,t)}break}}this._x=e,this._y=t}};function COt(e){return new x5(e,.5)}function kOt(e){return new x5(e,0)}function TOt(e){return new x5(e,1)}function wx(e,t){if((a=e.length)>1)for(var n=1,r,i,s=e[t[0]],a,o=s.length;n<a;++n)for(i=s,s=e[t[n]],r=0;r<o;++r)s[r][1]+=s[r][0]=isNaN(i[r][1])?i[r][0]:i[r][1]}function ZU(e){for(var t=e.length,n=new Array(t);--t>=0;)n[t]=t;return n}function AOt(e,t){return e[t]}function NOt(e){const t=[];return t.key=e,t}function OOt(){var e=Di([]),t=ZU,n=wx,r=AOt;function i(s){var a=Array.from(e.apply(this,arguments),NOt),o,l=a.length,u=-1,d;for(const f of s)for(o=0,++u;o<l;++o)(a[o][u]=[0,+r(f,a[o].key,u,s)]).data=f;for(o=0,d=GZ(t(a));o<l;++o)a[d[o]].index=o;return n(a,d),a}return i.keys=function(s){return arguments.length?(e=typeof s=="function"?s:Di(Array.from(s)),i):e},i.value=function(s){return arguments.length?(r=typeof s=="function"?s:Di(+s),i):r},i.order=function(s){return arguments.length?(t=s==null?ZU:typeof s=="function"?s:Di(Array.from(s)),i):t},i.offset=function(s){return arguments.length?(n=s??wx,i):n},i}function ROt(e,t){if((r=e.length)>0){for(var n,r,i=0,s=e[0].length,a;i<s;++i){for(a=n=0;n<r;++n)a+=e[n][i][1]||0;if(a)for(n=0;n<r;++n)e[n][i][1]/=a}wx(e,t)}}function IOt(e,t){if((i=e.length)>0){for(var n=0,r=e[t[0]],i,s=r.length;n<s;++n){for(var a=0,o=0;a<i;++a)o+=e[a][n][1]||0;r[n][1]+=r[n][0]=-o/2}wx(e,t)}}function DOt(e,t){if(!(!((a=e.length)>0)||!((s=(i=e[t[0]]).length)>0))){for(var n=0,r=1,i,s,a;r<s;++r){for(var o=0,l=0,u=0;o<a;++o){for(var d=e[t[o]],f=d[r][1]||0,h=d[r-1][1]||0,m=(f-h)/2,b=0;b<o;++b){var y=e[t[b]],v=y[r][1]||0,_=y[r-1][1]||0;m+=v-_}l+=f,u+=m*f}i[r-1][1]+=i[r-1][0]=n,l&&(n-=u/l)}i[r-1][1]+=i[r-1][0]=n,wx(e,t)}}function QE(e){"@babel/helpers - typeof";return QE=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},QE(e)}var POt=["type","size","sizeType"];function QU(){return QU=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},QU.apply(this,arguments)}function cfe(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function dfe(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?cfe(Object(n),!0).forEach(function(r){jOt(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):cfe(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function jOt(e,t,n){return t=LOt(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function LOt(e){var t=MOt(e,"string");return QE(t)=="symbol"?t:t+""}function MOt(e,t){if(QE(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(QE(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function FOt(e,t){if(e==null)return{};var n=BOt(e,t),r,i;if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(i=0;i<s.length;i++)r=s[i],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}function BOt(e,t){if(e==null)return{};var n={};for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r)){if(t.indexOf(r)>=0)continue;n[r]=e[r]}return n}var zOe={symbolCircle:KZ,symbolCross:aOt,symbolDiamond:lOt,symbolSquare:uOt,symbolStar:hOt,symbolTriangle:pOt,symbolWye:gOt},$Ot=Math.PI/180,UOt=function(t){var n="symbol".concat(b5(t));return zOe[n]||KZ},zOt=function(t,n,r){if(n==="area")return t;switch(r){case"cross":return 5*t*t/9;case"diamond":return .5*t*t/Math.sqrt(3);case"square":return t*t;case"star":{var i=18*$Ot;return 1.25*t*t*(Math.tan(i)-Math.tan(i*2)*Math.pow(Math.tan(i),2))}case"triangle":return Math.sqrt(3)*t*t/4;case"wye":return(21-10*Math.sqrt(3))*t*t/8;default:return Math.PI*t*t/4}},HOt=function(t,n){zOe["symbol".concat(b5(t))]=n},tk=function(t){var n=t.type,r=n===void 0?"circle":n,i=t.size,s=i===void 0?64:i,a=t.sizeType,o=a===void 0?"area":a,l=FOt(t,POt),u=dfe(dfe({},l),{},{type:r,size:s,sizeType:o}),d=function(){var v=UOt(r),_=bOt().type(v).size(zOt(s,o,r));return _()},f=u.className,h=u.cx,m=u.cy,b=Zt(u,!0);return h===+h&&m===+m&&s===+s?Z.createElement("path",QU({},b,{className:Tn("recharts-symbols",f),transform:"translate(".concat(h,", ").concat(m,")"),d:d()})):null};tk.registerSymbol=HOt;function Ex(e){"@babel/helpers - typeof";return Ex=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Ex(e)}function JU(){return JU=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},JU.apply(this,arguments)}function ffe(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function VOt(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?ffe(Object(n),!0).forEach(function(r){JE(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ffe(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function WOt(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function qOt(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,VOe(r.key),r)}}function GOt(e,t,n){return t&&qOt(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function KOt(e,t,n){return t=NR(t),YOt(e,HOe()?Reflect.construct(t,n||[],NR(e).constructor):t.apply(e,n))}function YOt(e,t){if(t&&(Ex(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return XOt(e)}function XOt(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function HOe(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(HOe=function(){return!!e})()}function NR(e){return NR=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},NR(e)}function ZOt(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&ez(e,t)}function ez(e,t){return ez=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,i){return r.__proto__=i,r},ez(e,t)}function JE(e,t,n){return t=VOe(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function VOe(e){var t=QOt(e,"string");return Ex(t)=="symbol"?t:t+""}function QOt(e,t){if(Ex(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(Ex(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}var $u=32,YZ=(function(e){function t(){return WOt(this,t),KOt(this,t,arguments)}return ZOt(t,e),GOt(t,[{key:"renderIcon",value:function(r){var i=this.props.inactiveColor,s=$u/2,a=$u/6,o=$u/3,l=r.inactive?i:r.color;if(r.type==="plainline")return Z.createElement("line",{strokeWidth:4,fill:"none",stroke:l,strokeDasharray:r.payload.strokeDasharray,x1:0,y1:s,x2:$u,y2:s,className:"recharts-legend-icon"});if(r.type==="line")return Z.createElement("path",{strokeWidth:4,fill:"none",stroke:l,d:"M0,".concat(s,"h").concat(o,`
|
|
137
|
+
M${A.x},${A.y}h${A.width}v${A.height}h${-A.width}z`,fill:l,fillRule:"evenodd",stroke:u,strokeWidth:d,pointerEvents:"none"})))}WNe.displayName="MiniMap";var M2t=x.memo(WNe);function F2t(){return Z.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32"},Z.createElement("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"}))}function B2t(){return Z.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5"},Z.createElement("path",{d:"M0 0h32v4.2H0z"}))}function $2t(){return Z.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30"},Z.createElement("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 U2t(){return Z.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32"},Z.createElement("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 z2t(){return Z.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32"},Z.createElement("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"}))}const uw=({children:e,className:t,...n})=>Z.createElement("button",{type:"button",className:bo(["react-flow__controls-button",t]),...n},e);uw.displayName="ControlButton";const H2t=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom}),qNe=({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:r=!0,fitViewOptions:i,onZoomIn:s,onZoomOut:a,onFitView:o,onInteractiveChange:l,className:u,children:d,position:f="bottom-left"})=>{const h=ya(),[m,b]=x.useState(!1),{isInteractive:y,minZoomReached:v,maxZoomReached:_}=Pi(H2t,Ha),{zoomIn:w,zoomOut:C,fitView:T}=DZ();if(x.useEffect(()=>{b(!0)},[]),!m)return null;const k=()=>{w(),s?.()},S=()=>{C(),a?.()},A=()=>{T(i),o?.()},R=()=>{h.setState({nodesDraggable:!y,nodesConnectable:!y,elementsSelectable:!y}),l?.(!y)};return Z.createElement(EZ,{className:bo(["react-flow__controls",u]),position:f,style:e,"data-testid":"rf__controls"},t&&Z.createElement(Z.Fragment,null,Z.createElement(uw,{onClick:k,className:"react-flow__controls-zoomin",title:"zoom in","aria-label":"zoom in",disabled:_},Z.createElement(F2t,null)),Z.createElement(uw,{onClick:S,className:"react-flow__controls-zoomout",title:"zoom out","aria-label":"zoom out",disabled:v},Z.createElement(B2t,null))),n&&Z.createElement(uw,{className:"react-flow__controls-fitview",onClick:A,title:"fit view","aria-label":"fit view"},Z.createElement($2t,null)),r&&Z.createElement(uw,{className:"react-flow__controls-interactive",onClick:R,title:"toggle interactivity","aria-label":"toggle interactivity"},y?Z.createElement(z2t,null):Z.createElement(U2t,null)),d)};qNe.displayName="Controls";var V2t=x.memo(qNe),od;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(od||(od={}));function W2t({color:e,dimensions:t,lineWidth:n}){return Z.createElement("path",{stroke:e,strokeWidth:n,d:`M${t[0]/2} 0 V${t[1]} M0 ${t[1]/2} H${t[0]}`})}function q2t({color:e,radius:t}){return Z.createElement("circle",{cx:t,cy:t,r:t,fill:e})}const G2t={[od.Dots]:"#91919a",[od.Lines]:"#eee",[od.Cross]:"#e2e2e2"},K2t={[od.Dots]:1,[od.Lines]:1,[od.Cross]:6},Y2t=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function GNe({id:e,variant:t=od.Dots,gap:n=20,size:r,lineWidth:i=1,offset:s=2,color:a,style:o,className:l}){const u=x.useRef(null),{transform:d,patternId:f}=Pi(Y2t,Ha),h=a||G2t[t],m=r||K2t[t],b=t===od.Dots,y=t===od.Cross,v=Array.isArray(n)?n:[n,n],_=[v[0]*d[2]||1,v[1]*d[2]||1],w=m*d[2],C=y?[w,w]:_,T=b?[w/s,w/s]:[C[0]/s,C[1]/s];return Z.createElement("svg",{className:bo(["react-flow__background",l]),style:{...o,position:"absolute",width:"100%",height:"100%",top:0,left:0},ref:u,"data-testid":"rf__background"},Z.createElement("pattern",{id:f+e,x:d[0]%_[0],y:d[1]%_[1],width:_[0],height:_[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${T[0]},-${T[1]})`},b?Z.createElement(q2t,{color:h,radius:w/s}):Z.createElement(W2t,{dimensions:C,color:h,lineWidth:i})),Z.createElement("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${f+e})`}))}GNe.displayName="Background";var X2t=x.memo(GNe),n6,Vue;function jZ(){if(Vue)return n6;Vue=1;var e="\0",t="\0",n="";class r{_isDirected=!0;_isMultigraph=!1;_isCompound=!1;_label;_defaultNodeLabelFn=()=>{};_defaultEdgeLabelFn=()=>{};_nodes={};_in={};_preds={};_out={};_sucs={};_edgeObjs={};_edgeLabels={};_nodeCount=0;_edgeCount=0;_parent;_children;constructor(d){d&&(this._isDirected=Object.hasOwn(d,"directed")?d.directed:!0,this._isMultigraph=Object.hasOwn(d,"multigraph")?d.multigraph:!1,this._isCompound=Object.hasOwn(d,"compound")?d.compound:!1),this._isCompound&&(this._parent={},this._children={},this._children[t]={})}isDirected(){return this._isDirected}isMultigraph(){return this._isMultigraph}isCompound(){return this._isCompound}setGraph(d){return this._label=d,this}graph(){return this._label}setDefaultNodeLabel(d){return this._defaultNodeLabelFn=d,typeof d!="function"&&(this._defaultNodeLabelFn=()=>d),this}nodeCount(){return this._nodeCount}nodes(){return Object.keys(this._nodes)}sources(){var d=this;return this.nodes().filter(f=>Object.keys(d._in[f]).length===0)}sinks(){var d=this;return this.nodes().filter(f=>Object.keys(d._out[f]).length===0)}setNodes(d,f){var h=arguments,m=this;return d.forEach(function(b){h.length>1?m.setNode(b,f):m.setNode(b)}),this}setNode(d,f){return Object.hasOwn(this._nodes,d)?(arguments.length>1&&(this._nodes[d]=f),this):(this._nodes[d]=arguments.length>1?f:this._defaultNodeLabelFn(d),this._isCompound&&(this._parent[d]=t,this._children[d]={},this._children[t][d]=!0),this._in[d]={},this._preds[d]={},this._out[d]={},this._sucs[d]={},++this._nodeCount,this)}node(d){return this._nodes[d]}hasNode(d){return Object.hasOwn(this._nodes,d)}removeNode(d){var f=this;if(Object.hasOwn(this._nodes,d)){var h=m=>f.removeEdge(f._edgeObjs[m]);delete this._nodes[d],this._isCompound&&(this._removeFromParentsChildList(d),delete this._parent[d],this.children(d).forEach(function(m){f.setParent(m)}),delete this._children[d]),Object.keys(this._in[d]).forEach(h),delete this._in[d],delete this._preds[d],Object.keys(this._out[d]).forEach(h),delete this._out[d],delete this._sucs[d],--this._nodeCount}return this}setParent(d,f){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(f===void 0)f=t;else{f+="";for(var h=f;h!==void 0;h=this.parent(h))if(h===d)throw new Error("Setting "+f+" as parent of "+d+" would create a cycle");this.setNode(f)}return this.setNode(d),this._removeFromParentsChildList(d),this._parent[d]=f,this._children[f][d]=!0,this}_removeFromParentsChildList(d){delete this._children[this._parent[d]][d]}parent(d){if(this._isCompound){var f=this._parent[d];if(f!==t)return f}}children(d=t){if(this._isCompound){var f=this._children[d];if(f)return Object.keys(f)}else{if(d===t)return this.nodes();if(this.hasNode(d))return[]}}predecessors(d){var f=this._preds[d];if(f)return Object.keys(f)}successors(d){var f=this._sucs[d];if(f)return Object.keys(f)}neighbors(d){var f=this.predecessors(d);if(f){const m=new Set(f);for(var h of this.successors(d))m.add(h);return Array.from(m.values())}}isLeaf(d){var f;return this.isDirected()?f=this.successors(d):f=this.neighbors(d),f.length===0}filterNodes(d){var f=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});f.setGraph(this.graph());var h=this;Object.entries(this._nodes).forEach(function([y,v]){d(y)&&f.setNode(y,v)}),Object.values(this._edgeObjs).forEach(function(y){f.hasNode(y.v)&&f.hasNode(y.w)&&f.setEdge(y,h.edge(y))});var m={};function b(y){var v=h.parent(y);return v===void 0||f.hasNode(v)?(m[y]=v,v):v in m?m[v]:b(v)}return this._isCompound&&f.nodes().forEach(y=>f.setParent(y,b(y))),f}setDefaultEdgeLabel(d){return this._defaultEdgeLabelFn=d,typeof d!="function"&&(this._defaultEdgeLabelFn=()=>d),this}edgeCount(){return this._edgeCount}edges(){return Object.values(this._edgeObjs)}setPath(d,f){var h=this,m=arguments;return d.reduce(function(b,y){return m.length>1?h.setEdge(b,y,f):h.setEdge(b,y),y}),this}setEdge(){var d,f,h,m,b=!1,y=arguments[0];typeof y=="object"&&y!==null&&"v"in y?(d=y.v,f=y.w,h=y.name,arguments.length===2&&(m=arguments[1],b=!0)):(d=y,f=arguments[1],h=arguments[3],arguments.length>2&&(m=arguments[2],b=!0)),d=""+d,f=""+f,h!==void 0&&(h=""+h);var v=a(this._isDirected,d,f,h);if(Object.hasOwn(this._edgeLabels,v))return b&&(this._edgeLabels[v]=m),this;if(h!==void 0&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(d),this.setNode(f),this._edgeLabels[v]=b?m:this._defaultEdgeLabelFn(d,f,h);var _=o(this._isDirected,d,f,h);return d=_.v,f=_.w,Object.freeze(_),this._edgeObjs[v]=_,i(this._preds[f],d),i(this._sucs[d],f),this._in[f][v]=_,this._out[d][v]=_,this._edgeCount++,this}edge(d,f,h){var m=arguments.length===1?l(this._isDirected,arguments[0]):a(this._isDirected,d,f,h);return this._edgeLabels[m]}edgeAsObj(){const d=this.edge(...arguments);return typeof d!="object"?{label:d}:d}hasEdge(d,f,h){var m=arguments.length===1?l(this._isDirected,arguments[0]):a(this._isDirected,d,f,h);return Object.hasOwn(this._edgeLabels,m)}removeEdge(d,f,h){var m=arguments.length===1?l(this._isDirected,arguments[0]):a(this._isDirected,d,f,h),b=this._edgeObjs[m];return b&&(d=b.v,f=b.w,delete this._edgeLabels[m],delete this._edgeObjs[m],s(this._preds[f],d),s(this._sucs[d],f),delete this._in[f][m],delete this._out[d][m],this._edgeCount--),this}inEdges(d,f){var h=this._in[d];if(h){var m=Object.values(h);return f?m.filter(b=>b.v===f):m}}outEdges(d,f){var h=this._out[d];if(h){var m=Object.values(h);return f?m.filter(b=>b.w===f):m}}nodeEdges(d,f){var h=this.inEdges(d,f);if(h)return h.concat(this.outEdges(d,f))}}function i(u,d){u[d]?u[d]++:u[d]=1}function s(u,d){--u[d]||delete u[d]}function a(u,d,f,h){var m=""+d,b=""+f;if(!u&&m>b){var y=m;m=b,b=y}return m+n+b+n+(h===void 0?e:h)}function o(u,d,f,h){var m=""+d,b=""+f;if(!u&&m>b){var y=m;m=b,b=y}var v={v:m,w:b};return h&&(v.name=h),v}function l(u,d){return a(u,d.v,d.w,d.name)}return n6=r,n6}var r6,Wue;function Z2t(){return Wue||(Wue=1,r6="2.2.4"),r6}var i6,que;function Q2t(){return que||(que=1,i6={Graph:jZ(),version:Z2t()}),i6}var s6,Gue;function J2t(){if(Gue)return s6;Gue=1;var e=jZ();s6={write:t,read:i};function t(s){var a={options:{directed:s.isDirected(),multigraph:s.isMultigraph(),compound:s.isCompound()},nodes:n(s),edges:r(s)};return s.graph()!==void 0&&(a.value=structuredClone(s.graph())),a}function n(s){return s.nodes().map(function(a){var o=s.node(a),l=s.parent(a),u={v:a};return o!==void 0&&(u.value=o),l!==void 0&&(u.parent=l),u})}function r(s){return s.edges().map(function(a){var o=s.edge(a),l={v:a.v,w:a.w};return a.name!==void 0&&(l.name=a.name),o!==void 0&&(l.value=o),l})}function i(s){var a=new e(s.options).setGraph(s.value);return s.nodes.forEach(function(o){a.setNode(o.v,o.value),o.parent&&a.setParent(o.v,o.parent)}),s.edges.forEach(function(o){a.setEdge({v:o.v,w:o.w,name:o.name},o.value)}),a}return s6}var a6,Kue;function ekt(){if(Kue)return a6;Kue=1,a6=e;function e(t){var n={},r=[],i;function s(a){Object.hasOwn(n,a)||(n[a]=!0,i.push(a),t.successors(a).forEach(s),t.predecessors(a).forEach(s))}return t.nodes().forEach(function(a){i=[],s(a),i.length&&r.push(i)}),r}return a6}var o6,Yue;function KNe(){if(Yue)return o6;Yue=1;class e{_arr=[];_keyIndices={};size(){return this._arr.length}keys(){return this._arr.map(function(n){return n.key})}has(n){return Object.hasOwn(this._keyIndices,n)}priority(n){var r=this._keyIndices[n];if(r!==void 0)return this._arr[r].priority}min(){if(this.size()===0)throw new Error("Queue underflow");return this._arr[0].key}add(n,r){var i=this._keyIndices;if(n=String(n),!Object.hasOwn(i,n)){var s=this._arr,a=s.length;return i[n]=a,s.push({key:n,priority:r}),this._decrease(a),!0}return!1}removeMin(){this._swap(0,this._arr.length-1);var n=this._arr.pop();return delete this._keyIndices[n.key],this._heapify(0),n.key}decrease(n,r){var i=this._keyIndices[n];if(r>this._arr[i].priority)throw new Error("New priority is greater than current priority. Key: "+n+" Old: "+this._arr[i].priority+" New: "+r);this._arr[i].priority=r,this._decrease(i)}_heapify(n){var r=this._arr,i=2*n,s=i+1,a=n;i<r.length&&(a=r[i].priority<r[a].priority?i:a,s<r.length&&(a=r[s].priority<r[a].priority?s:a),a!==n&&(this._swap(n,a),this._heapify(a)))}_decrease(n){for(var r=this._arr,i=r[n].priority,s;n!==0&&(s=n>>1,!(r[s].priority<i));)this._swap(n,s),n=s}_swap(n,r){var i=this._arr,s=this._keyIndices,a=i[n],o=i[r];i[n]=o,i[r]=a,s[o.key]=n,s[a.key]=r}}return o6=e,o6}var l6,Xue;function YNe(){if(Xue)return l6;Xue=1;var e=KNe();l6=n;var t=()=>1;function n(i,s,a,o){return r(i,String(s),a||t,o||function(l){return i.outEdges(l)})}function r(i,s,a,o){var l={},u=new e,d,f,h=function(m){var b=m.v!==d?m.v:m.w,y=l[b],v=a(m),_=f.distance+v;if(v<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+m+" Weight: "+v);_<y.distance&&(y.distance=_,y.predecessor=d,u.decrease(b,_))};for(i.nodes().forEach(function(m){var b=m===s?0:Number.POSITIVE_INFINITY;l[m]={distance:b},u.add(m,b)});u.size()>0&&(d=u.removeMin(),f=l[d],f.distance!==Number.POSITIVE_INFINITY);)o(d).forEach(h);return l}return l6}var u6,Zue;function tkt(){if(Zue)return u6;Zue=1;var e=YNe();u6=t;function t(n,r,i){return n.nodes().reduce(function(s,a){return s[a]=e(n,a,r,i),s},{})}return u6}var c6,Que;function XNe(){if(Que)return c6;Que=1,c6=e;function e(t){var n=0,r=[],i={},s=[];function a(o){var l=i[o]={onStack:!0,lowlink:n,index:n++};if(r.push(o),t.successors(o).forEach(function(f){Object.hasOwn(i,f)?i[f].onStack&&(l.lowlink=Math.min(l.lowlink,i[f].index)):(a(f),l.lowlink=Math.min(l.lowlink,i[f].lowlink))}),l.lowlink===l.index){var u=[],d;do d=r.pop(),i[d].onStack=!1,u.push(d);while(o!==d);s.push(u)}}return t.nodes().forEach(function(o){Object.hasOwn(i,o)||a(o)}),s}return c6}var d6,Jue;function nkt(){if(Jue)return d6;Jue=1;var e=XNe();d6=t;function t(n){return e(n).filter(function(r){return r.length>1||r.length===1&&n.hasEdge(r[0],r[0])})}return d6}var f6,ece;function rkt(){if(ece)return f6;ece=1,f6=t;var e=()=>1;function t(r,i,s){return n(r,i||e,s||function(a){return r.outEdges(a)})}function n(r,i,s){var a={},o=r.nodes();return o.forEach(function(l){a[l]={},a[l][l]={distance:0},o.forEach(function(u){l!==u&&(a[l][u]={distance:Number.POSITIVE_INFINITY})}),s(l).forEach(function(u){var d=u.v===l?u.w:u.v,f=i(u);a[l][d]={distance:f,predecessor:l}})}),o.forEach(function(l){var u=a[l];o.forEach(function(d){var f=a[d];o.forEach(function(h){var m=f[l],b=u[h],y=f[h],v=m.distance+b.distance;v<y.distance&&(y.distance=v,y.predecessor=b.predecessor)})})}),a}return f6}var h6,tce;function ZNe(){if(tce)return h6;tce=1;function e(n){var r={},i={},s=[];function a(o){if(Object.hasOwn(i,o))throw new t;Object.hasOwn(r,o)||(i[o]=!0,r[o]=!0,n.predecessors(o).forEach(a),delete i[o],s.push(o))}if(n.sinks().forEach(a),Object.keys(r).length!==n.nodeCount())throw new t;return s}class t extends Error{constructor(){super(...arguments)}}return h6=e,e.CycleException=t,h6}var p6,nce;function ikt(){if(nce)return p6;nce=1;var e=ZNe();p6=t;function t(n){try{e(n)}catch(r){if(r instanceof e.CycleException)return!1;throw r}return!0}return p6}var m6,rce;function QNe(){if(rce)return m6;rce=1,m6=e;function e(i,s,a){Array.isArray(s)||(s=[s]);var o=i.isDirected()?f=>i.successors(f):f=>i.neighbors(f),l=a==="post"?t:n,u=[],d={};return s.forEach(f=>{if(!i.hasNode(f))throw new Error("Graph does not have node: "+f);l(f,o,d,u)}),u}function t(i,s,a,o){for(var l=[[i,!1]];l.length>0;){var u=l.pop();u[1]?o.push(u[0]):Object.hasOwn(a,u[0])||(a[u[0]]=!0,l.push([u[0],!0]),r(s(u[0]),d=>l.push([d,!1])))}}function n(i,s,a,o){for(var l=[i];l.length>0;){var u=l.pop();Object.hasOwn(a,u)||(a[u]=!0,o.push(u),r(s(u),d=>l.push(d)))}}function r(i,s){for(var a=i.length;a--;)s(i[a],a,i);return i}return m6}var g6,ice;function skt(){if(ice)return g6;ice=1;var e=QNe();g6=t;function t(n,r){return e(n,r,"post")}return g6}var b6,sce;function akt(){if(sce)return b6;sce=1;var e=QNe();b6=t;function t(n,r){return e(n,r,"pre")}return b6}var y6,ace;function okt(){if(ace)return y6;ace=1;var e=jZ(),t=KNe();y6=n;function n(r,i){var s=new e,a={},o=new t,l;function u(f){var h=f.v===l?f.w:f.v,m=o.priority(h);if(m!==void 0){var b=i(f);b<m&&(a[h]=l,o.decrease(h,b))}}if(r.nodeCount()===0)return s;r.nodes().forEach(function(f){o.add(f,Number.POSITIVE_INFINITY),s.setNode(f)}),o.decrease(r.nodes()[0],0);for(var d=!1;o.size()>0;){if(l=o.removeMin(),Object.hasOwn(a,l))s.setEdge(l,a[l]);else{if(d)throw new Error("Input graph is not connected: "+r);d=!0}r.nodeEdges(l).forEach(u)}return s}return y6}var v6,oce;function lkt(){return oce||(oce=1,v6={components:ekt(),dijkstra:YNe(),dijkstraAll:tkt(),findCycles:nkt(),floydWarshall:rkt(),isAcyclic:ikt(),postorder:skt(),preorder:akt(),prim:okt(),tarjan:XNe(),topsort:ZNe()}),v6}var x6,lce;function hd(){if(lce)return x6;lce=1;var e=Q2t();return x6={Graph:e.Graph,json:J2t(),alg:lkt(),version:e.version},x6}var _6,uce;function ukt(){if(uce)return _6;uce=1;class e{constructor(){let i={};i._next=i._prev=i,this._sentinel=i}dequeue(){let i=this._sentinel,s=i._prev;if(s!==i)return t(s),s}enqueue(i){let s=this._sentinel;i._prev&&i._next&&t(i),i._next=s._next,s._next._prev=i,s._next=i,i._prev=s}toString(){let i=[],s=this._sentinel,a=s._prev;for(;a!==s;)i.push(JSON.stringify(a,n)),a=a._prev;return"["+i.join(", ")+"]"}}function t(r){r._prev._next=r._next,r._next._prev=r._prev,delete r._next,delete r._prev}function n(r,i){if(r!=="_next"&&r!=="_prev")return i}return _6=e,_6}var S6,cce;function ckt(){if(cce)return S6;cce=1;let e=hd().Graph,t=ukt();S6=r;let n=()=>1;function r(u,d){if(u.nodeCount()<=1)return[];let f=a(u,d||n);return i(f.graph,f.buckets,f.zeroIdx).flatMap(m=>u.outEdges(m.v,m.w))}function i(u,d,f){let h=[],m=d[d.length-1],b=d[0],y;for(;u.nodeCount();){for(;y=b.dequeue();)s(u,d,f,y);for(;y=m.dequeue();)s(u,d,f,y);if(u.nodeCount()){for(let v=d.length-2;v>0;--v)if(y=d[v].dequeue(),y){h=h.concat(s(u,d,f,y,!0));break}}}return h}function s(u,d,f,h,m){let b=m?[]:void 0;return u.inEdges(h.v).forEach(y=>{let v=u.edge(y),_=u.node(y.v);m&&b.push({v:y.v,w:y.w}),_.out-=v,o(d,f,_)}),u.outEdges(h.v).forEach(y=>{let v=u.edge(y),_=y.w,w=u.node(_);w.in-=v,o(d,f,w)}),u.removeNode(h.v),b}function a(u,d){let f=new e,h=0,m=0;u.nodes().forEach(v=>{f.setNode(v,{v,in:0,out:0})}),u.edges().forEach(v=>{let _=f.edge(v.v,v.w)||0,w=d(v),C=_+w;f.setEdge(v.v,v.w,C),m=Math.max(m,f.node(v.v).out+=w),h=Math.max(h,f.node(v.w).in+=w)});let b=l(m+h+3).map(()=>new t),y=h+1;return f.nodes().forEach(v=>{o(b,y,f.node(v))}),{graph:f,buckets:b,zeroIdx:y}}function o(u,d,f){f.out?f.in?u[f.out-f.in+d].enqueue(f):u[u.length-1].enqueue(f):u[0].enqueue(f)}function l(u){const d=[];for(let f=0;f<u;f++)d.push(f);return d}return S6}var w6,dce;function Ys(){if(dce)return w6;dce=1;let e=hd().Graph;w6={addBorderNode:d,addDummyNode:t,applyWithChunking:m,asNonCompoundGraph:r,buildLayerMatrix:o,intersectRect:a,mapValues:S,maxRank:b,normalizeRanks:l,notime:_,partition:y,pick:k,predecessorWeights:s,range:T,removeEmptyRanks:u,simplify:n,successorWeights:i,time:v,uniqueId:C,zipObject:A};function t(R,I,D,P){for(var j=P;R.hasNode(j);)j=C(P);return D.dummy=I,R.setNode(j,D),j}function n(R){let I=new e().setGraph(R.graph());return R.nodes().forEach(D=>I.setNode(D,R.node(D))),R.edges().forEach(D=>{let P=I.edge(D.v,D.w)||{weight:0,minlen:1},j=R.edge(D);I.setEdge(D.v,D.w,{weight:P.weight+j.weight,minlen:Math.max(P.minlen,j.minlen)})}),I}function r(R){let I=new e({multigraph:R.isMultigraph()}).setGraph(R.graph());return R.nodes().forEach(D=>{R.children(D).length||I.setNode(D,R.node(D))}),R.edges().forEach(D=>{I.setEdge(D,R.edge(D))}),I}function i(R){let I=R.nodes().map(D=>{let P={};return R.outEdges(D).forEach(j=>{P[j.w]=(P[j.w]||0)+R.edge(j).weight}),P});return A(R.nodes(),I)}function s(R){let I=R.nodes().map(D=>{let P={};return R.inEdges(D).forEach(j=>{P[j.v]=(P[j.v]||0)+R.edge(j).weight}),P});return A(R.nodes(),I)}function a(R,I){let D=R.x,P=R.y,j=I.x-D,B=I.y-P,L=R.width/2,M=R.height/2;if(!j&&!B)throw new Error("Not possible to find intersection inside of the rectangle");let $,U;return Math.abs(B)*L>Math.abs(j)*M?(B<0&&(M=-M),$=M*j/B,U=M):(j<0&&(L=-L),$=L,U=L*B/j),{x:D+$,y:P+U}}function o(R){let I=T(b(R)+1).map(()=>[]);return R.nodes().forEach(D=>{let P=R.node(D),j=P.rank;j!==void 0&&(I[j][P.order]=D)}),I}function l(R){let I=R.nodes().map(P=>{let j=R.node(P).rank;return j===void 0?Number.MAX_VALUE:j}),D=m(Math.min,I);R.nodes().forEach(P=>{let j=R.node(P);Object.hasOwn(j,"rank")&&(j.rank-=D)})}function u(R){let I=R.nodes().map(L=>R.node(L).rank),D=m(Math.min,I),P=[];R.nodes().forEach(L=>{let M=R.node(L).rank-D;P[M]||(P[M]=[]),P[M].push(L)});let j=0,B=R.graph().nodeRankFactor;Array.from(P).forEach((L,M)=>{L===void 0&&M%B!==0?--j:L!==void 0&&j&&L.forEach($=>R.node($).rank+=j)})}function d(R,I,D,P){let j={width:0,height:0};return arguments.length>=4&&(j.rank=D,j.order=P),t(R,"border",j,I)}function f(R,I=h){const D=[];for(let P=0;P<R.length;P+=I){const j=R.slice(P,P+I);D.push(j)}return D}const h=65535;function m(R,I){if(I.length>h){const D=f(I);return R.apply(null,D.map(P=>R.apply(null,P)))}else return R.apply(null,I)}function b(R){const D=R.nodes().map(P=>{let j=R.node(P).rank;return j===void 0?Number.MIN_VALUE:j});return m(Math.max,D)}function y(R,I){let D={lhs:[],rhs:[]};return R.forEach(P=>{I(P)?D.lhs.push(P):D.rhs.push(P)}),D}function v(R,I){let D=Date.now();try{return I()}finally{console.log(R+" time: "+(Date.now()-D)+"ms")}}function _(R,I){return I()}let w=0;function C(R){var I=++w;return R+(""+I)}function T(R,I,D=1){I==null&&(I=R,R=0);let P=B=>B<I;D<0&&(P=B=>I<B);const j=[];for(let B=R;P(B);B+=D)j.push(B);return j}function k(R,I){const D={};for(const P of I)R[P]!==void 0&&(D[P]=R[P]);return D}function S(R,I){let D=I;return typeof I=="string"&&(D=P=>P[I]),Object.entries(R).reduce((P,[j,B])=>(P[j]=D(B,j),P),{})}function A(R,I){return R.reduce((D,P,j)=>(D[P]=I[j],D),{})}return w6}var E6,fce;function dkt(){if(fce)return E6;fce=1;let e=ckt(),t=Ys().uniqueId;E6={run:n,undo:i};function n(s){(s.graph().acyclicer==="greedy"?e(s,o(s)):r(s)).forEach(l=>{let u=s.edge(l);s.removeEdge(l),u.forwardName=l.name,u.reversed=!0,s.setEdge(l.w,l.v,u,t("rev"))});function o(l){return u=>l.edge(u).weight}}function r(s){let a=[],o={},l={};function u(d){Object.hasOwn(l,d)||(l[d]=!0,o[d]=!0,s.outEdges(d).forEach(f=>{Object.hasOwn(o,f.w)?a.push(f):u(f.w)}),delete o[d])}return s.nodes().forEach(u),a}function i(s){s.edges().forEach(a=>{let o=s.edge(a);if(o.reversed){s.removeEdge(a);let l=o.forwardName;delete o.reversed,delete o.forwardName,s.setEdge(a.w,a.v,o,l)}})}return E6}var C6,hce;function fkt(){if(hce)return C6;hce=1;let e=Ys();C6={run:t,undo:r};function t(i){i.graph().dummyChains=[],i.edges().forEach(s=>n(i,s))}function n(i,s){let a=s.v,o=i.node(a).rank,l=s.w,u=i.node(l).rank,d=s.name,f=i.edge(s),h=f.labelRank;if(u===o+1)return;i.removeEdge(s);let m,b,y;for(y=0,++o;o<u;++y,++o)f.points=[],b={width:0,height:0,edgeLabel:f,edgeObj:s,rank:o},m=e.addDummyNode(i,"edge",b,"_d"),o===h&&(b.width=f.width,b.height=f.height,b.dummy="edge-label",b.labelpos=f.labelpos),i.setEdge(a,m,{weight:f.weight},d),y===0&&i.graph().dummyChains.push(m),a=m;i.setEdge(a,l,{weight:f.weight},d)}function r(i){i.graph().dummyChains.forEach(s=>{let a=i.node(s),o=a.edgeLabel,l;for(i.setEdge(a.edgeObj,o);a.dummy;)l=i.successors(s)[0],i.removeNode(s),o.points.push({x:a.x,y:a.y}),a.dummy==="edge-label"&&(o.x=a.x,o.y=a.y,o.width=a.width,o.height=a.height),s=l,a=i.node(s)})}return C6}var k6,pce;function xR(){if(pce)return k6;pce=1;const{applyWithChunking:e}=Ys();k6={longestPath:t,slack:n};function t(r){var i={};function s(a){var o=r.node(a);if(Object.hasOwn(i,a))return o.rank;i[a]=!0;let l=r.outEdges(a).map(d=>d==null?Number.POSITIVE_INFINITY:s(d.w)-r.edge(d).minlen);var u=e(Math.min,l);return u===Number.POSITIVE_INFINITY&&(u=0),o.rank=u}r.sources().forEach(s)}function n(r,i){return r.node(i.w).rank-r.node(i.v).rank-r.edge(i).minlen}return k6}var T6,mce;function JNe(){if(mce)return T6;mce=1;var e=hd().Graph,t=xR().slack;T6=n;function n(a){var o=new e({directed:!1}),l=a.nodes()[0],u=a.nodeCount();o.setNode(l,{});for(var d,f;r(o,a)<u;)d=i(o,a),f=o.hasNode(d.v)?t(a,d):-t(a,d),s(o,a,f);return o}function r(a,o){function l(u){o.nodeEdges(u).forEach(d=>{var f=d.v,h=u===f?d.w:f;!a.hasNode(h)&&!t(o,d)&&(a.setNode(h,{}),a.setEdge(u,h,{}),l(h))})}return a.nodes().forEach(l),a.nodeCount()}function i(a,o){return o.edges().reduce((u,d)=>{let f=Number.POSITIVE_INFINITY;return a.hasNode(d.v)!==a.hasNode(d.w)&&(f=t(o,d)),f<u[0]?[f,d]:u},[Number.POSITIVE_INFINITY,null])[1]}function s(a,o,l){a.nodes().forEach(u=>o.node(u).rank+=l)}return T6}var A6,gce;function hkt(){if(gce)return A6;gce=1;var e=JNe(),t=xR().slack,n=xR().longestPath,r=hd().alg.preorder,i=hd().alg.postorder,s=Ys().simplify;A6=a,a.initLowLimValues=d,a.initCutValues=o,a.calcCutValue=u,a.leaveEdge=h,a.enterEdge=m,a.exchangeEdges=b;function a(w){w=s(w),n(w);var C=e(w);d(C),o(C,w);for(var T,k;T=h(C);)k=m(C,w,T),b(C,w,T,k)}function o(w,C){var T=i(w,w.nodes());T=T.slice(0,T.length-1),T.forEach(k=>l(w,C,k))}function l(w,C,T){var k=w.node(T),S=k.parent;w.edge(T,S).cutvalue=u(w,C,T)}function u(w,C,T){var k=w.node(T),S=k.parent,A=!0,R=C.edge(T,S),I=0;return R||(A=!1,R=C.edge(S,T)),I=R.weight,C.nodeEdges(T).forEach(D=>{var P=D.v===T,j=P?D.w:D.v;if(j!==S){var B=P===A,L=C.edge(D).weight;if(I+=B?L:-L,v(w,T,j)){var M=w.edge(T,j).cutvalue;I+=B?-M:M}}}),I}function d(w,C){arguments.length<2&&(C=w.nodes()[0]),f(w,{},1,C)}function f(w,C,T,k,S){var A=T,R=w.node(k);return C[k]=!0,w.neighbors(k).forEach(I=>{Object.hasOwn(C,I)||(T=f(w,C,T,I,k))}),R.low=A,R.lim=T++,S?R.parent=S:delete R.parent,T}function h(w){return w.edges().find(C=>w.edge(C).cutvalue<0)}function m(w,C,T){var k=T.v,S=T.w;C.hasEdge(k,S)||(k=T.w,S=T.v);var A=w.node(k),R=w.node(S),I=A,D=!1;A.lim>R.lim&&(I=R,D=!0);var P=C.edges().filter(j=>D===_(w,w.node(j.v),I)&&D!==_(w,w.node(j.w),I));return P.reduce((j,B)=>t(C,B)<t(C,j)?B:j)}function b(w,C,T,k){var S=T.v,A=T.w;w.removeEdge(S,A),w.setEdge(k.v,k.w,{}),d(w),o(w,C),y(w,C)}function y(w,C){var T=w.nodes().find(S=>!C.node(S).parent),k=r(w,T);k=k.slice(1),k.forEach(S=>{var A=w.node(S).parent,R=C.edge(S,A),I=!1;R||(R=C.edge(A,S),I=!0),C.node(S).rank=C.node(A).rank+(I?R.minlen:-R.minlen)})}function v(w,C,T){return w.hasEdge(C,T)}function _(w,C,T){return T.low<=C.lim&&C.lim<=T.lim}return A6}var N6,bce;function pkt(){if(bce)return N6;bce=1;var e=xR(),t=e.longestPath,n=JNe(),r=hkt();N6=i;function i(l){var u=l.graph().ranker;if(u instanceof Function)return u(l);switch(l.graph().ranker){case"network-simplex":o(l);break;case"tight-tree":a(l);break;case"longest-path":s(l);break;case"none":break;default:o(l)}}var s=t;function a(l){t(l),n(l)}function o(l){r(l)}return N6}var O6,yce;function mkt(){if(yce)return O6;yce=1,O6=e;function e(r){let i=n(r);r.graph().dummyChains.forEach(s=>{let a=r.node(s),o=a.edgeObj,l=t(r,i,o.v,o.w),u=l.path,d=l.lca,f=0,h=u[f],m=!0;for(;s!==o.w;){if(a=r.node(s),m){for(;(h=u[f])!==d&&r.node(h).maxRank<a.rank;)f++;h===d&&(m=!1)}if(!m){for(;f<u.length-1&&r.node(h=u[f+1]).minRank<=a.rank;)f++;h=u[f]}r.setParent(s,h),s=r.successors(s)[0]}})}function t(r,i,s,a){let o=[],l=[],u=Math.min(i[s].low,i[a].low),d=Math.max(i[s].lim,i[a].lim),f,h;f=s;do f=r.parent(f),o.push(f);while(f&&(i[f].low>u||d>i[f].lim));for(h=f,f=a;(f=r.parent(f))!==h;)l.push(f);return{path:o.concat(l.reverse()),lca:h}}function n(r){let i={},s=0;function a(o){let l=s;r.children(o).forEach(a),i[o]={low:l,lim:s++}}return r.children().forEach(a),i}return O6}var R6,vce;function gkt(){if(vce)return R6;vce=1;let e=Ys();R6={run:t,cleanup:s};function t(a){let o=e.addDummyNode(a,"root",{},"_root"),l=r(a),u=Object.values(l),d=e.applyWithChunking(Math.max,u)-1,f=2*d+1;a.graph().nestingRoot=o,a.edges().forEach(m=>a.edge(m).minlen*=f);let h=i(a)+1;a.children().forEach(m=>n(a,o,f,h,d,l,m)),a.graph().nodeRankFactor=f}function n(a,o,l,u,d,f,h){let m=a.children(h);if(!m.length){h!==o&&a.setEdge(o,h,{weight:0,minlen:l});return}let b=e.addBorderNode(a,"_bt"),y=e.addBorderNode(a,"_bb"),v=a.node(h);a.setParent(b,h),v.borderTop=b,a.setParent(y,h),v.borderBottom=y,m.forEach(_=>{n(a,o,l,u,d,f,_);let w=a.node(_),C=w.borderTop?w.borderTop:_,T=w.borderBottom?w.borderBottom:_,k=w.borderTop?u:2*u,S=C!==T?1:d-f[h]+1;a.setEdge(b,C,{weight:k,minlen:S,nestingEdge:!0}),a.setEdge(T,y,{weight:k,minlen:S,nestingEdge:!0})}),a.parent(h)||a.setEdge(o,b,{weight:0,minlen:d+f[h]})}function r(a){var o={};function l(u,d){var f=a.children(u);f&&f.length&&f.forEach(h=>l(h,d+1)),o[u]=d}return a.children().forEach(u=>l(u,1)),o}function i(a){return a.edges().reduce((o,l)=>o+a.edge(l).weight,0)}function s(a){var o=a.graph();a.removeNode(o.nestingRoot),delete o.nestingRoot,a.edges().forEach(l=>{var u=a.edge(l);u.nestingEdge&&a.removeEdge(l)})}return R6}var I6,xce;function bkt(){if(xce)return I6;xce=1;let e=Ys();I6=t;function t(r){function i(s){let a=r.children(s),o=r.node(s);if(a.length&&a.forEach(i),Object.hasOwn(o,"minRank")){o.borderLeft=[],o.borderRight=[];for(let l=o.minRank,u=o.maxRank+1;l<u;++l)n(r,"borderLeft","_bl",s,o,l),n(r,"borderRight","_br",s,o,l)}}r.children().forEach(i)}function n(r,i,s,a,o,l){let u={width:0,height:0,rank:l,borderType:i},d=o[i][l-1],f=e.addDummyNode(r,"border",u,s);o[i][l]=f,r.setParent(f,a),d&&r.setEdge(d,f,{weight:1})}return I6}var D6,_ce;function ykt(){if(_ce)return D6;_ce=1,D6={adjust:e,undo:t};function e(l){let u=l.graph().rankdir.toLowerCase();(u==="lr"||u==="rl")&&n(l)}function t(l){let u=l.graph().rankdir.toLowerCase();(u==="bt"||u==="rl")&&i(l),(u==="lr"||u==="rl")&&(a(l),n(l))}function n(l){l.nodes().forEach(u=>r(l.node(u))),l.edges().forEach(u=>r(l.edge(u)))}function r(l){let u=l.width;l.width=l.height,l.height=u}function i(l){l.nodes().forEach(u=>s(l.node(u))),l.edges().forEach(u=>{let d=l.edge(u);d.points.forEach(s),Object.hasOwn(d,"y")&&s(d)})}function s(l){l.y=-l.y}function a(l){l.nodes().forEach(u=>o(l.node(u))),l.edges().forEach(u=>{let d=l.edge(u);d.points.forEach(o),Object.hasOwn(d,"x")&&o(d)})}function o(l){let u=l.x;l.x=l.y,l.y=u}return D6}var P6,Sce;function vkt(){if(Sce)return P6;Sce=1;let e=Ys();P6=t;function t(n){let r={},i=n.nodes().filter(d=>!n.children(d).length),s=i.map(d=>n.node(d).rank),a=e.applyWithChunking(Math.max,s),o=e.range(a+1).map(()=>[]);function l(d){if(r[d])return;r[d]=!0;let f=n.node(d);o[f.rank].push(d),n.successors(d).forEach(l)}return i.sort((d,f)=>n.node(d).rank-n.node(f).rank).forEach(l),o}return P6}var j6,wce;function xkt(){if(wce)return j6;wce=1;let e=Ys().zipObject;j6=t;function t(r,i){let s=0;for(let a=1;a<i.length;++a)s+=n(r,i[a-1],i[a]);return s}function n(r,i,s){let a=e(s,s.map((h,m)=>m)),o=i.flatMap(h=>r.outEdges(h).map(m=>({pos:a[m.w],weight:r.edge(m).weight})).sort((m,b)=>m.pos-b.pos)),l=1;for(;l<s.length;)l<<=1;let u=2*l-1;l-=1;let d=new Array(u).fill(0),f=0;return o.forEach(h=>{let m=h.pos+l;d[m]+=h.weight;let b=0;for(;m>0;)m%2&&(b+=d[m+1]),m=m-1>>1,d[m]+=h.weight;f+=h.weight*b}),f}return j6}var L6,Ece;function _kt(){if(Ece)return L6;Ece=1,L6=e;function e(t,n=[]){return n.map(r=>{let i=t.inEdges(r);if(i.length){let s=i.reduce((a,o)=>{let l=t.edge(o),u=t.node(o.v);return{sum:a.sum+l.weight*u.order,weight:a.weight+l.weight}},{sum:0,weight:0});return{v:r,barycenter:s.sum/s.weight,weight:s.weight}}else return{v:r}})}return L6}var M6,Cce;function Skt(){if(Cce)return M6;Cce=1;let e=Ys();M6=t;function t(i,s){let a={};i.forEach((l,u)=>{let d=a[l.v]={indegree:0,in:[],out:[],vs:[l.v],i:u};l.barycenter!==void 0&&(d.barycenter=l.barycenter,d.weight=l.weight)}),s.edges().forEach(l=>{let u=a[l.v],d=a[l.w];u!==void 0&&d!==void 0&&(d.indegree++,u.out.push(a[l.w]))});let o=Object.values(a).filter(l=>!l.indegree);return n(o)}function n(i){let s=[];function a(l){return u=>{u.merged||(u.barycenter===void 0||l.barycenter===void 0||u.barycenter>=l.barycenter)&&r(l,u)}}function o(l){return u=>{u.in.push(l),--u.indegree===0&&i.push(u)}}for(;i.length;){let l=i.pop();s.push(l),l.in.reverse().forEach(a(l)),l.out.forEach(o(l))}return s.filter(l=>!l.merged).map(l=>e.pick(l,["vs","i","barycenter","weight"]))}function r(i,s){let a=0,o=0;i.weight&&(a+=i.barycenter*i.weight,o+=i.weight),s.weight&&(a+=s.barycenter*s.weight,o+=s.weight),i.vs=s.vs.concat(i.vs),i.barycenter=a/o,i.weight=o,i.i=Math.min(s.i,i.i),s.merged=!0}return M6}var F6,kce;function wkt(){if(kce)return F6;kce=1;let e=Ys();F6=t;function t(i,s){let a=e.partition(i,b=>Object.hasOwn(b,"barycenter")),o=a.lhs,l=a.rhs.sort((b,y)=>y.i-b.i),u=[],d=0,f=0,h=0;o.sort(r(!!s)),h=n(u,l,h),o.forEach(b=>{h+=b.vs.length,u.push(b.vs),d+=b.barycenter*b.weight,f+=b.weight,h=n(u,l,h)});let m={vs:u.flat(!0)};return f&&(m.barycenter=d/f,m.weight=f),m}function n(i,s,a){let o;for(;s.length&&(o=s[s.length-1]).i<=a;)s.pop(),i.push(o.vs),a++;return a}function r(i){return(s,a)=>s.barycenter<a.barycenter?-1:s.barycenter>a.barycenter?1:i?a.i-s.i:s.i-a.i}return F6}var B6,Tce;function Ekt(){if(Tce)return B6;Tce=1;let e=_kt(),t=Skt(),n=wkt();B6=r;function r(a,o,l,u){let d=a.children(o),f=a.node(o),h=f?f.borderLeft:void 0,m=f?f.borderRight:void 0,b={};h&&(d=d.filter(w=>w!==h&&w!==m));let y=e(a,d);y.forEach(w=>{if(a.children(w.v).length){let C=r(a,w.v,l,u);b[w.v]=C,Object.hasOwn(C,"barycenter")&&s(w,C)}});let v=t(y,l);i(v,b);let _=n(v,u);if(h&&(_.vs=[h,_.vs,m].flat(!0),a.predecessors(h).length)){let w=a.node(a.predecessors(h)[0]),C=a.node(a.predecessors(m)[0]);Object.hasOwn(_,"barycenter")||(_.barycenter=0,_.weight=0),_.barycenter=(_.barycenter*_.weight+w.order+C.order)/(_.weight+2),_.weight+=2}return _}function i(a,o){a.forEach(l=>{l.vs=l.vs.flatMap(u=>o[u]?o[u].vs:u)})}function s(a,o){a.barycenter!==void 0?(a.barycenter=(a.barycenter*a.weight+o.barycenter*o.weight)/(a.weight+o.weight),a.weight+=o.weight):(a.barycenter=o.barycenter,a.weight=o.weight)}return B6}var $6,Ace;function Ckt(){if(Ace)return $6;Ace=1;let e=hd().Graph,t=Ys();$6=n;function n(i,s,a,o){o||(o=i.nodes());let l=r(i),u=new e({compound:!0}).setGraph({root:l}).setDefaultNodeLabel(d=>i.node(d));return o.forEach(d=>{let f=i.node(d),h=i.parent(d);(f.rank===s||f.minRank<=s&&s<=f.maxRank)&&(u.setNode(d),u.setParent(d,h||l),i[a](d).forEach(m=>{let b=m.v===d?m.w:m.v,y=u.edge(b,d),v=y!==void 0?y.weight:0;u.setEdge(b,d,{weight:i.edge(m).weight+v})}),Object.hasOwn(f,"minRank")&&u.setNode(d,{borderLeft:f.borderLeft[s],borderRight:f.borderRight[s]}))}),u}function r(i){for(var s;i.hasNode(s=t.uniqueId("_root")););return s}return $6}var U6,Nce;function kkt(){if(Nce)return U6;Nce=1,U6=e;function e(t,n,r){let i={},s;r.forEach(a=>{let o=t.parent(a),l,u;for(;o;){if(l=t.parent(o),l?(u=i[l],i[l]=o):(u=s,s=o),u&&u!==o){n.setEdge(u,o);return}o=l}})}return U6}var z6,Oce;function Tkt(){if(Oce)return z6;Oce=1;let e=vkt(),t=xkt(),n=Ekt(),r=Ckt(),i=kkt(),s=hd().Graph,a=Ys();z6=o;function o(f,h){if(h&&typeof h.customOrder=="function"){h.customOrder(f,o);return}let m=a.maxRank(f),b=l(f,a.range(1,m+1),"inEdges"),y=l(f,a.range(m-1,-1,-1),"outEdges"),v=e(f);if(d(f,v),h&&h.disableOptimalOrderHeuristic)return;let _=Number.POSITIVE_INFINITY,w;for(let C=0,T=0;T<4;++C,++T){u(C%2?b:y,C%4>=2),v=a.buildLayerMatrix(f);let k=t(f,v);k<_&&(T=0,w=Object.assign({},v),_=k)}d(f,w)}function l(f,h,m){const b=new Map,y=(v,_)=>{b.has(v)||b.set(v,[]),b.get(v).push(_)};for(const v of f.nodes()){const _=f.node(v);if(typeof _.rank=="number"&&y(_.rank,v),typeof _.minRank=="number"&&typeof _.maxRank=="number")for(let w=_.minRank;w<=_.maxRank;w++)w!==_.rank&&y(w,v)}return h.map(function(v){return r(f,v,m,b.get(v)||[])})}function u(f,h){let m=new s;f.forEach(function(b){let y=b.graph().root,v=n(b,y,m,h);v.vs.forEach((_,w)=>b.node(_).order=w),i(b,m,v.vs)})}function d(f,h){Object.values(h).forEach(m=>m.forEach((b,y)=>f.node(b).order=y))}return z6}var H6,Rce;function Akt(){if(Rce)return H6;Rce=1;let e=hd().Graph,t=Ys();H6={positionX:m,findType1Conflicts:n,findType2Conflicts:r,addConflict:s,hasConflict:a,verticalAlignment:o,horizontalCompaction:l,alignCoordinates:f,findSmallestWidthAlignment:d,balance:h};function n(v,_){let w={};function C(T,k){let S=0,A=0,R=T.length,I=k[k.length-1];return k.forEach((D,P)=>{let j=i(v,D),B=j?v.node(j).order:R;(j||D===I)&&(k.slice(A,P+1).forEach(L=>{v.predecessors(L).forEach(M=>{let $=v.node(M),U=$.order;(U<S||B<U)&&!($.dummy&&v.node(L).dummy)&&s(w,M,L)})}),A=P+1,S=B)}),k}return _.length&&_.reduce(C),w}function r(v,_){let w={};function C(k,S,A,R,I){let D;t.range(S,A).forEach(P=>{D=k[P],v.node(D).dummy&&v.predecessors(D).forEach(j=>{let B=v.node(j);B.dummy&&(B.order<R||B.order>I)&&s(w,j,D)})})}function T(k,S){let A=-1,R,I=0;return S.forEach((D,P)=>{if(v.node(D).dummy==="border"){let j=v.predecessors(D);j.length&&(R=v.node(j[0]).order,C(S,I,P,A,R),I=P,A=R)}C(S,I,S.length,R,k.length)}),S}return _.length&&_.reduce(T),w}function i(v,_){if(v.node(_).dummy)return v.predecessors(_).find(w=>v.node(w).dummy)}function s(v,_,w){if(_>w){let T=_;_=w,w=T}let C=v[_];C||(v[_]=C={}),C[w]=!0}function a(v,_,w){if(_>w){let C=_;_=w,w=C}return!!v[_]&&Object.hasOwn(v[_],w)}function o(v,_,w,C){let T={},k={},S={};return _.forEach(A=>{A.forEach((R,I)=>{T[R]=R,k[R]=R,S[R]=I})}),_.forEach(A=>{let R=-1;A.forEach(I=>{let D=C(I);if(D.length){D=D.sort((j,B)=>S[j]-S[B]);let P=(D.length-1)/2;for(let j=Math.floor(P),B=Math.ceil(P);j<=B;++j){let L=D[j];k[I]===I&&R<S[L]&&!a(w,I,L)&&(k[L]=I,k[I]=T[I]=T[L],R=S[L])}}})}),{root:T,align:k}}function l(v,_,w,C,T){let k={},S=u(v,_,w,T),A=T?"borderLeft":"borderRight";function R(P,j){let B=S.nodes(),L=B.pop(),M={};for(;L;)M[L]?P(L):(M[L]=!0,B.push(L),B=B.concat(j(L))),L=B.pop()}function I(P){k[P]=S.inEdges(P).reduce((j,B)=>Math.max(j,k[B.v]+S.edge(B)),0)}function D(P){let j=S.outEdges(P).reduce((L,M)=>Math.min(L,k[M.w]-S.edge(M)),Number.POSITIVE_INFINITY),B=v.node(P);j!==Number.POSITIVE_INFINITY&&B.borderType!==A&&(k[P]=Math.max(k[P],j))}return R(I,S.predecessors.bind(S)),R(D,S.successors.bind(S)),Object.keys(C).forEach(P=>k[P]=k[w[P]]),k}function u(v,_,w,C){let T=new e,k=v.graph(),S=b(k.nodesep,k.edgesep,C);return _.forEach(A=>{let R;A.forEach(I=>{let D=w[I];if(T.setNode(D),R){var P=w[R],j=T.edge(P,D);T.setEdge(P,D,Math.max(S(v,I,R),j||0))}R=I})}),T}function d(v,_){return Object.values(_).reduce((w,C)=>{let T=Number.NEGATIVE_INFINITY,k=Number.POSITIVE_INFINITY;Object.entries(C).forEach(([A,R])=>{let I=y(v,A)/2;T=Math.max(R+I,T),k=Math.min(R-I,k)});const S=T-k;return S<w[0]&&(w=[S,C]),w},[Number.POSITIVE_INFINITY,null])[1]}function f(v,_){let w=Object.values(_),C=t.applyWithChunking(Math.min,w),T=t.applyWithChunking(Math.max,w);["u","d"].forEach(k=>{["l","r"].forEach(S=>{let A=k+S,R=v[A];if(R===_)return;let I=Object.values(R),D=C-t.applyWithChunking(Math.min,I);S!=="l"&&(D=T-t.applyWithChunking(Math.max,I)),D&&(v[A]=t.mapValues(R,P=>P+D))})})}function h(v,_){return t.mapValues(v.ul,(w,C)=>{if(_)return v[_.toLowerCase()][C];{let T=Object.values(v).map(k=>k[C]).sort((k,S)=>k-S);return(T[1]+T[2])/2}})}function m(v){let _=t.buildLayerMatrix(v),w=Object.assign(n(v,_),r(v,_)),C={},T;["u","d"].forEach(S=>{T=S==="u"?_:Object.values(_).reverse(),["l","r"].forEach(A=>{A==="r"&&(T=T.map(P=>Object.values(P).reverse()));let R=(S==="u"?v.predecessors:v.successors).bind(v),I=o(v,T,w,R),D=l(v,T,I.root,I.align,A==="r");A==="r"&&(D=t.mapValues(D,P=>-P)),C[S+A]=D})});let k=d(v,C);return f(C,k),h(C,v.graph().align)}function b(v,_,w){return(C,T,k)=>{let S=C.node(T),A=C.node(k),R=0,I;if(R+=S.width/2,Object.hasOwn(S,"labelpos"))switch(S.labelpos.toLowerCase()){case"l":I=-S.width/2;break;case"r":I=S.width/2;break}if(I&&(R+=w?I:-I),I=0,R+=(S.dummy?_:v)/2,R+=(A.dummy?_:v)/2,R+=A.width/2,Object.hasOwn(A,"labelpos"))switch(A.labelpos.toLowerCase()){case"l":I=A.width/2;break;case"r":I=-A.width/2;break}return I&&(R+=w?I:-I),I=0,R}}function y(v,_){return v.node(_).width}return H6}var V6,Ice;function Nkt(){if(Ice)return V6;Ice=1;let e=Ys(),t=Akt().positionX;V6=n;function n(i){i=e.asNonCompoundGraph(i),r(i),Object.entries(t(i)).forEach(([s,a])=>i.node(s).x=a)}function r(i){let s=e.buildLayerMatrix(i),a=i.graph().ranksep,o=0;s.forEach(l=>{const u=l.reduce((d,f)=>{const h=i.node(f).height;return d>h?d:h},0);l.forEach(d=>i.node(d).y=o+u/2),o+=u+a})}return V6}var W6,Dce;function Okt(){if(Dce)return W6;Dce=1;let e=dkt(),t=fkt(),n=pkt(),r=Ys().normalizeRanks,i=mkt(),s=Ys().removeEmptyRanks,a=gkt(),o=bkt(),l=ykt(),u=Tkt(),d=Nkt(),f=Ys(),h=hd().Graph;W6=m;function m(z,Q){let ee=Q&&Q.debugTiming?f.time:f.notime;ee("layout",()=>{let ne=ee(" buildLayoutGraph",()=>R(z));ee(" runLayout",()=>b(ne,ee,Q)),ee(" updateInputGraph",()=>y(z,ne))})}function b(z,Q,ee){Q(" makeSpaceForEdgeLabels",()=>I(z)),Q(" removeSelfEdges",()=>W(z)),Q(" acyclic",()=>e.run(z)),Q(" nestingGraph.run",()=>a.run(z)),Q(" rank",()=>n(f.asNonCompoundGraph(z))),Q(" injectEdgeLabelProxies",()=>D(z)),Q(" removeEmptyRanks",()=>s(z)),Q(" nestingGraph.cleanup",()=>a.cleanup(z)),Q(" normalizeRanks",()=>r(z)),Q(" assignRankMinMax",()=>P(z)),Q(" removeEdgeLabelProxies",()=>j(z)),Q(" normalize.run",()=>t.run(z)),Q(" parentDummyChains",()=>i(z)),Q(" addBorderSegments",()=>o(z)),Q(" order",()=>u(z,ee)),Q(" insertSelfEdges",()=>Y(z)),Q(" adjustCoordinateSystem",()=>l.adjust(z)),Q(" position",()=>d(z)),Q(" positionSelfEdges",()=>G(z)),Q(" removeBorderNodes",()=>U(z)),Q(" normalize.undo",()=>t.undo(z)),Q(" fixupEdgeLabelCoords",()=>M(z)),Q(" undoCoordinateSystem",()=>l.undo(z)),Q(" translateGraph",()=>B(z)),Q(" assignNodeIntersects",()=>L(z)),Q(" reversePoints",()=>$(z)),Q(" acyclic.undo",()=>e.undo(z))}function y(z,Q){z.nodes().forEach(ee=>{let ne=z.node(ee),ae=Q.node(ee);ne&&(ne.x=ae.x,ne.y=ae.y,ne.rank=ae.rank,Q.children(ee).length&&(ne.width=ae.width,ne.height=ae.height))}),z.edges().forEach(ee=>{let ne=z.edge(ee),ae=Q.edge(ee);ne.points=ae.points,Object.hasOwn(ae,"x")&&(ne.x=ae.x,ne.y=ae.y)}),z.graph().width=Q.graph().width,z.graph().height=Q.graph().height}let v=["nodesep","edgesep","ranksep","marginx","marginy"],_={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},w=["acyclicer","ranker","rankdir","align"],C=["width","height","rank"],T={width:0,height:0},k=["minlen","weight","width","height","labeloffset"],S={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},A=["labelpos"];function R(z){let Q=new h({multigraph:!0,compound:!0}),ee=X(z.graph());return Q.setGraph(Object.assign({},_,q(ee,v),f.pick(ee,w))),z.nodes().forEach(ne=>{let ae=X(z.node(ne));const fe=q(ae,C);Object.keys(T).forEach(re=>{fe[re]===void 0&&(fe[re]=T[re])}),Q.setNode(ne,fe),Q.setParent(ne,z.parent(ne))}),z.edges().forEach(ne=>{let ae=X(z.edge(ne));Q.setEdge(ne,Object.assign({},S,q(ae,k),f.pick(ae,A)))}),Q}function I(z){let Q=z.graph();Q.ranksep/=2,z.edges().forEach(ee=>{let ne=z.edge(ee);ne.minlen*=2,ne.labelpos.toLowerCase()!=="c"&&(Q.rankdir==="TB"||Q.rankdir==="BT"?ne.width+=ne.labeloffset:ne.height+=ne.labeloffset)})}function D(z){z.edges().forEach(Q=>{let ee=z.edge(Q);if(ee.width&&ee.height){let ne=z.node(Q.v),fe={rank:(z.node(Q.w).rank-ne.rank)/2+ne.rank,e:Q};f.addDummyNode(z,"edge-proxy",fe,"_ep")}})}function P(z){let Q=0;z.nodes().forEach(ee=>{let ne=z.node(ee);ne.borderTop&&(ne.minRank=z.node(ne.borderTop).rank,ne.maxRank=z.node(ne.borderBottom).rank,Q=Math.max(Q,ne.maxRank))}),z.graph().maxRank=Q}function j(z){z.nodes().forEach(Q=>{let ee=z.node(Q);ee.dummy==="edge-proxy"&&(z.edge(ee.e).labelRank=ee.rank,z.removeNode(Q))})}function B(z){let Q=Number.POSITIVE_INFINITY,ee=0,ne=Number.POSITIVE_INFINITY,ae=0,fe=z.graph(),re=fe.marginx||0,de=fe.marginy||0;function he(ce){let ye=ce.x,be=ce.y,ue=ce.width,Ae=ce.height;Q=Math.min(Q,ye-ue/2),ee=Math.max(ee,ye+ue/2),ne=Math.min(ne,be-Ae/2),ae=Math.max(ae,be+Ae/2)}z.nodes().forEach(ce=>he(z.node(ce))),z.edges().forEach(ce=>{let ye=z.edge(ce);Object.hasOwn(ye,"x")&&he(ye)}),Q-=re,ne-=de,z.nodes().forEach(ce=>{let ye=z.node(ce);ye.x-=Q,ye.y-=ne}),z.edges().forEach(ce=>{let ye=z.edge(ce);ye.points.forEach(be=>{be.x-=Q,be.y-=ne}),Object.hasOwn(ye,"x")&&(ye.x-=Q),Object.hasOwn(ye,"y")&&(ye.y-=ne)}),fe.width=ee-Q+re,fe.height=ae-ne+de}function L(z){z.edges().forEach(Q=>{let ee=z.edge(Q),ne=z.node(Q.v),ae=z.node(Q.w),fe,re;ee.points?(fe=ee.points[0],re=ee.points[ee.points.length-1]):(ee.points=[],fe=ae,re=ne),ee.points.unshift(f.intersectRect(ne,fe)),ee.points.push(f.intersectRect(ae,re))})}function M(z){z.edges().forEach(Q=>{let ee=z.edge(Q);if(Object.hasOwn(ee,"x"))switch((ee.labelpos==="l"||ee.labelpos==="r")&&(ee.width-=ee.labeloffset),ee.labelpos){case"l":ee.x-=ee.width/2+ee.labeloffset;break;case"r":ee.x+=ee.width/2+ee.labeloffset;break}})}function $(z){z.edges().forEach(Q=>{let ee=z.edge(Q);ee.reversed&&ee.points.reverse()})}function U(z){z.nodes().forEach(Q=>{if(z.children(Q).length){let ee=z.node(Q),ne=z.node(ee.borderTop),ae=z.node(ee.borderBottom),fe=z.node(ee.borderLeft[ee.borderLeft.length-1]),re=z.node(ee.borderRight[ee.borderRight.length-1]);ee.width=Math.abs(re.x-fe.x),ee.height=Math.abs(ae.y-ne.y),ee.x=fe.x+ee.width/2,ee.y=ne.y+ee.height/2}}),z.nodes().forEach(Q=>{z.node(Q).dummy==="border"&&z.removeNode(Q)})}function W(z){z.edges().forEach(Q=>{if(Q.v===Q.w){var ee=z.node(Q.v);ee.selfEdges||(ee.selfEdges=[]),ee.selfEdges.push({e:Q,label:z.edge(Q)}),z.removeEdge(Q)}})}function Y(z){var Q=f.buildLayerMatrix(z);Q.forEach(ee=>{var ne=0;ee.forEach((ae,fe)=>{var re=z.node(ae);re.order=fe+ne,(re.selfEdges||[]).forEach(de=>{f.addDummyNode(z,"selfedge",{width:de.label.width,height:de.label.height,rank:re.rank,order:fe+ ++ne,e:de.e,label:de.label},"_se")}),delete re.selfEdges})})}function G(z){z.nodes().forEach(Q=>{var ee=z.node(Q);if(ee.dummy==="selfedge"){var ne=z.node(ee.e.v),ae=ne.x+ne.width/2,fe=ne.y,re=ee.x-ae,de=ne.height/2;z.setEdge(ee.e,ee.label),z.removeNode(Q),ee.label.points=[{x:ae+2*re/3,y:fe-de},{x:ae+5*re/6,y:fe-de},{x:ae+re,y:fe},{x:ae+5*re/6,y:fe+de},{x:ae+2*re/3,y:fe+de}],ee.label.x=ee.x,ee.label.y=ee.y}})}function q(z,Q){return f.mapValues(f.pick(z,Q),Number)}function X(z){var Q={};return z&&Object.entries(z).forEach(([ee,ne])=>{typeof ee=="string"&&(ee=ee.toLowerCase()),Q[ee]=ne}),Q}return W6}var q6,Pce;function Rkt(){if(Pce)return q6;Pce=1;let e=Ys(),t=hd().Graph;q6={debugOrdering:n};function n(r){let i=e.buildLayerMatrix(r),s=new t({compound:!0,multigraph:!0}).setGraph({});return r.nodes().forEach(a=>{s.setNode(a,{label:a}),s.setParent(a,"layer"+r.node(a).rank)}),r.edges().forEach(a=>s.setEdge(a.v,a.w,{},a.name)),i.forEach((a,o)=>{let l="layer"+o;s.setNode(l,{rank:"same"}),a.reduce((u,d)=>(s.setEdge(u,d,{style:"invis"}),d))}),s}return q6}var G6,jce;function Ikt(){return jce||(jce=1,G6="1.1.8"),G6}var K6,Lce;function Dkt(){return Lce||(Lce=1,K6={graphlib:hd(),layout:Okt(),debug:Rkt(),util:{time:Ys().time,notime:Ys().notime},version:Ikt()}),K6}var Pkt=Dkt();const Mce=Yn(Pkt),eOe={TO_DO:{bg:"#f3f4f6",border:"#6b7280",text:"#374151"},IN_PROGRESS:{bg:"#e5e7eb",border:"#8d909b",text:"#374151"},IN_REVIEW:{bg:"#fef3c7",border:"#e08d3c",text:"#92400e"},DONE:{bg:"#d1fae5",border:"#0d5c63",text:"#065f46"},CANCELED:{bg:"#fee2e2",border:"#dd403a",text:"#991b1b"}};function jkt({data:e}){const{task:t,projectName:n,isBlocked:r,direction:i}=e,s=eOe[t.status],a=ZD(t.dueDate,t.status),o=gAe(t.dueDate,t.status),l=i==="LR"?wn.Left:wn.Top,u=i==="LR"?wn.Right:wn.Bottom;return c.jsxs("div",{className:"rounded-lg shadow-md px-3 py-2 min-w-[180px] max-w-[240px] cursor-pointer transition-shadow hover:shadow-lg",style:{backgroundColor:s.bg,borderWidth:2,borderStyle:"solid",borderColor:a?"#dd403a":s.border,opacity:r?.7:1},children:[c.jsx(Sx,{type:"target",position:l,className:"!bg-gray-400 !w-2 !h-2"}),c.jsxs("div",{className:"flex flex-col gap-1",children:[n&&c.jsx("div",{className:"text-[10px] text-gray-500 font-medium truncate",children:n}),c.jsx("div",{className:"font-medium text-sm leading-tight line-clamp-2",style:{color:s.text},children:t.title}),c.jsxs("div",{className:"flex items-center gap-1 flex-wrap",children:[c.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded-full font-medium",style:{backgroundColor:s.border+"20",color:s.border},children:t.status.replace("_"," ")}),r&&c.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded-full font-medium bg-red-100 text-red-700",children:"BLOCKED"}),a&&c.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded-full font-medium bg-red-100 text-red-700",children:"OVERDUE"})]}),t.tags.length>0&&c.jsxs("div",{className:"flex gap-1 flex-wrap mt-0.5",children:[t.tags.slice(0,3).map(d=>c.jsx("span",{className:"text-[9px] px-1 py-0.5 rounded bg-gray-200 text-gray-600",children:d},d)),t.tags.length>3&&c.jsxs("span",{className:"text-[9px] px-1 py-0.5 rounded bg-gray-200 text-gray-600",children:["+",t.tags.length-3]})]}),t.dueDate&&c.jsxs("div",{className:"text-[10px] mt-0.5",style:{color:a?"#dd403a":o?"#d97706":"#6b7280"},children:["Due: ",new Date(t.dueDate).toLocaleDateString()]})]}),c.jsx(Sx,{type:"source",position:u,className:"!bg-gray-400 !w-2 !h-2"})]})}const Lkt={task:jkt};function Mkt(e,t,n="TB"){const r=new Mce.graphlib.Graph;r.setDefaultEdgeLabel(()=>({}));const i=200,s=80;return r.setGraph({rankdir:n,nodesep:50,ranksep:80,marginx:20,marginy:20}),e.forEach(o=>{r.setNode(o.id,{width:i,height:s})}),t.forEach(o=>{r.setEdge(o.source,o.target)}),Mce.layout(r),{nodes:e.map(o=>{const l=r.node(o.id);return{...o,position:{x:l.x-i/2,y:l.y-s/2}}}),edges:t}}const Fce=768;function Fkt({className:e,projectFilter:t,tagsFilter:n}){const r=ji(),{data:i,isLoading:s}=ASe(),{data:a=[]}=Oc(),{data:o=[]}=_u(),[l,u]=x.useState(null),[d,f]=x.useState(!1),h=x.useMemo(()=>l?a.find(W=>W.id===l)??null:null,[l,a]),m=x.useMemo(()=>new Map(a.map(W=>[W.id,W])),[a]),{projectRepoIds:b,projectRepoPaths:y}=x.useMemo(()=>{const W=new Set,Y=new Set;for(const G of o)for(const q of G.repositories)W.add(q.id),Y.add(q.path);return{projectRepoIds:W,projectRepoPaths:Y}},[o]),{selectedProjectRepoIds:v,selectedProjectRepoPaths:_}=x.useMemo(()=>{if(!t||t==="inbox")return{selectedProjectRepoIds:new Set,selectedProjectRepoPaths:new Set};const W=o.find(Y=>Y.id===t);return W?{selectedProjectRepoIds:new Set(W.repositories.map(Y=>Y.id)),selectedProjectRepoPaths:new Set(W.repositories.map(Y=>Y.path))}:{selectedProjectRepoIds:new Set,selectedProjectRepoPaths:new Set}},[t,o]),[w,C]=x.useState(()=>typeof window<"u"?window.innerWidth<Fce:!1);x.useEffect(()=>{const W=()=>{C(window.innerWidth<Fce)};return window.addEventListener("resize",W),()=>window.removeEventListener("resize",W)},[]);const T=w?"TB":"LR",k=x.useMemo(()=>{if(!i)return new Set;const W=new Set,Y=new Set(["DONE","CANCELED"]);for(const G of i.edges){const q=i.nodes.find(X=>X.id===G.source);q&&!Y.has(q.status)&&W.add(G.target)}return W},[i]),S=x.useMemo(()=>{if(!i)return new Set;const W=new Set,Y=new Set(["DONE","CANCELED"]);for(const G of i.edges){const q=i.nodes.find(X=>X.id===G.source);q&&!Y.has(q.status)&&W.add(G.source)}return W},[i]),A=x.useCallback(W=>{const Y=m.get(W.id);return Y?t==="inbox"?!Y.projectId&&(!Y.repositoryId||!b.has(Y.repositoryId))&&(!Y.repoPath||!y.has(Y.repoPath)):t?Y.projectId===t||!!Y.repositoryId&&v.has(Y.repositoryId)||!!Y.repoPath&&_.has(Y.repoPath):!0:!0},[t,b,y,v,_,m]),R=x.useCallback(W=>!n||n.length===0?!0:W.tags.some(Y=>n.includes(Y)),[n]),{initialNodes:I,initialEdges:D}=x.useMemo(()=>{if(!i)return{initialNodes:[],initialEdges:[]};const W=new Set;for(const ae of i.nodes)A(ae)&&R(ae)&&W.add(ae.id);const Y=new Set;for(const ae of i.edges){const fe=W.has(ae.source),re=W.has(ae.target);(fe||re)&&(Y.add(ae.source),Y.add(ae.target))}if(!(t||n&&n.length>0))for(const ae of i.edges)Y.add(ae.source),Y.add(ae.target);const q=i.nodes.filter(ae=>Y.has(ae.id)),X=i.edges.filter(ae=>Y.has(ae.source)&&Y.has(ae.target)),z=new Map(o.map(ae=>[ae.id,ae.name])),Q=q.map(ae=>({id:ae.id,type:"task",position:{x:0,y:0},data:{task:ae,projectName:ae.projectId?z.get(ae.projectId)??null:null,isBlocked:k.has(ae.id),isBlocking:S.has(ae.id),direction:T}})),ee=X.map(ae=>({id:ae.id,source:ae.source,target:ae.target,type:"smoothstep",animated:!0,markerEnd:{type:KE.ArrowClosed,width:15,height:15,color:"#6b7280"},style:{stroke:"#6b7280",strokeWidth:2}})),ne=Mkt(Q,ee,T);return{initialNodes:ne.nodes,initialEdges:ne.edges}},[i,k,S,T,A,R,t,n,o]),[P,j,B]=k2t(I),[L,M,$]=T2t(D);x.useEffect(()=>{(I.length>0||D.length>0)&&(j(I),M(D))},[I,D,j,M]);const U=x.useCallback((W,Y)=>{const G=m.get(Y.id);G&&(G.worktreePath?r({to:"/tasks/$taskId",params:{taskId:Y.id}}):(u(G.id),f(!0)))},[r,m]);return s?c.jsx("div",{className:`flex items-center justify-center h-full ${e}`,children:c.jsx("span",{className:"text-muted-foreground",children:"Loading dependency graph..."})}):!i||i.nodes.length===0?c.jsx("div",{className:`flex items-center justify-center h-full ${e}`,children:c.jsx("span",{className:"text-muted-foreground",children:"No tasks found"})}):i.edges.length===0?c.jsxs("div",{className:`flex flex-col items-center justify-center h-full gap-2 ${e}`,children:[c.jsx("span",{className:"text-muted-foreground",children:"No dependencies defined"}),c.jsx("span",{className:"text-sm text-muted-foreground/70",children:"Add dependencies between tasks to see the graph"})]}):c.jsxs(c.Fragment,{children:[c.jsx("div",{className:`h-full relative ${e}`,children:c.jsxs(zNe,{nodes:P,edges:L,onNodesChange:B,onEdgesChange:$,onNodeClick:U,nodeTypes:Lkt,fitView:!0,fitViewOptions:{padding:.2},minZoom:.1,maxZoom:2,defaultEdgeOptions:{type:"smoothstep"},proOptions:{hideAttribution:!0},children:[c.jsx(X2t,{color:"#e5e7eb",gap:20,size:1}),c.jsx(V2t,{showInteractive:!1}),c.jsx(M2t,{nodeColor:W=>{const Y=W.data;return eOe[Y.task.status].border},maskColor:"rgba(0, 0, 0, 0.1)",className:"!bg-background/80"})]})}),h&&!h.worktreePath&&c.jsx(X2,{task:h,open:d,onOpenChange:W=>{f(W),W||u(null)}})]})}function tOe({value:e,onChange:t}){const{t:n}=Dt("tasks"),[r,i]=x.useState(!1),[s,a]=x.useState(""),o=x.useRef(null),{data:l=[]}=FVe(),u=l.filter(m=>m.name.toLowerCase().includes(s.toLowerCase()));x.useEffect(()=>{r&&setTimeout(()=>o.current?.focus(),0)},[r]);const d=m=>{e.includes(m)?t(e.filter(b=>b!==m)):t([...e,m])},f=(m,b)=>{b.stopPropagation(),t(e.filter(y=>y!==m))},h=m=>{m.stopPropagation(),t([])};return c.jsxs(pW,{open:r,onOpenChange:i,children:[c.jsxs(mW,{render:c.jsx(Ce,{variant:"outline",size:"sm",className:Pe("shrink-0 gap-1.5 h-7 px-2",e.length>0&&"pr-1")}),children:[c.jsx(J,{icon:g$e,size:12,strokeWidth:2,className:"text-muted-foreground"}),e.length===0?c.jsxs(c.Fragment,{children:[c.jsx("span",{className:"text-xs",children:n("allTags")}),c.jsx(J,{icon:Do,size:12,strokeWidth:2,className:"text-muted-foreground"})]}):c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"flex items-center gap-1",children:[e.slice(0,2).map(m=>c.jsxs(jr,{variant:"secondary",className:"h-5 px-1.5 text-[10px] gap-0.5",children:[m,c.jsx("button",{onClick:b=>f(m,b),className:"hover:text-destructive transition-colors",children:c.jsx(J,{icon:jn,size:10})})]},m)),e.length>2&&c.jsxs(jr,{variant:"secondary",className:"h-5 px-1.5 text-[10px]",children:["+",e.length-2]})]}),c.jsx("button",{onClick:h,className:"ml-0.5 p-0.5 hover:text-destructive transition-colors",children:c.jsx(J,{icon:jn,size:12})})]})]}),c.jsxs(gW,{align:"start",className:"w-56 p-0",children:[c.jsx("div",{className:"p-2 border-b",children:c.jsx(kt,{ref:o,value:s,onChange:m=>a(m.target.value),placeholder:n("searchTags"),className:"h-7 text-xs"})}),c.jsx("div",{className:"max-h-48 overflow-y-auto py-1",children:u.length===0?c.jsx("div",{className:"px-3 py-2 text-xs text-muted-foreground text-center",children:n("noTagsFound")}):u.map(m=>{const b=e.includes(m.name);return c.jsxs("button",{className:Pe("w-full px-3 py-1.5 text-left text-xs hover:bg-accent flex items-center gap-2",b&&"bg-accent/50"),onClick:()=>d(m.name),children:[c.jsx(Ci,{checked:b,className:"pointer-events-none"}),c.jsx("span",{className:"flex-1 truncate",children:m.name}),c.jsx("span",{className:"text-muted-foreground text-[10px]",children:m.taskCount})]},m.id)})}),e.length>0&&c.jsx("div",{className:"p-2 border-t",children:c.jsx(Ce,{variant:"ghost",size:"sm",className:"w-full h-7 text-xs",onClick:()=>{t([]),i(!1)},children:n("clearTags")})})]})]})}const nOe=js("/tasks/")({component:Bkt,validateSearch:e=>({project:typeof e.project=="string"?e.project:void 0,tags:typeof e.tags=="string"?e.tags:void 0,view:e.view==="graph"?"graph":void 0,task:typeof e.task=="string"?e.task:void 0})});function Bkt(){const{t:e}=Dt("tasks"),{project:t,tags:n,view:r="kanban",task:i}=nOe.useSearch(),s=ji(),[a,o]=x.useState(""),l=x.useMemo(()=>n?n.split(",").filter(Boolean):[],[n]),u=x.useCallback(h=>{s({to:"/tasks",search:m=>({...m,project:h||void 0}),replace:!0})},[s]),d=x.useCallback(h=>{s({to:"/tasks",search:m=>({...m,tags:h.length>0?h.join(","):void 0}),replace:!0})},[s]),f=x.useCallback(h=>{s({to:"/tasks",search:m=>({...m,view:h==="kanban"?void 0:h}),replace:!0})},[s]);return c.jsxs("div",{className:"flex h-full flex-col",children:[c.jsxs("div",{className:"film-grain relative flex shrink-0 items-center gap-2 border-b border-border px-4 py-2",style:{background:"var(--gradient-header)"},children:[r==="kanban"&&c.jsxs("div",{className:"relative shrink-0",children:[c.jsx(J,{icon:np,size:12,strokeWidth:2,className:"absolute left-2 top-1/2 -translate-y-1/2 text-muted-foreground"}),c.jsx(kt,{value:a,onChange:h=>o(h.target.value),placeholder:e("searchPlaceholder"),className:"h-7 w-48 pl-7 text-xs"})]}),c.jsxs("div",{className:"hidden sm:contents",children:[c.jsx(fZ,{value:t??null,onChange:u}),c.jsx(tOe,{value:l,onChange:d})]}),c.jsx("div",{className:"flex-1"}),c.jsxs(JV,{value:[r],onValueChange:h=>{const m=Array.isArray(h)?h[0]:h;m&&f(m)},size:"sm",variant:"outline",children:[c.jsx(nx,{value:"kanban","aria-label":"Kanban view",children:c.jsx(J,{icon:kO,size:14,strokeWidth:2})}),c.jsx(nx,{value:"graph","aria-label":"Dependency graph",children:c.jsx(J,{icon:t$e,size:14,strokeWidth:2})})]})]}),c.jsxs("div",{className:"flex-1 overflow-hidden",children:[r==="kanban"&&c.jsx(X1t,{projectFilter:t??null,searchQuery:a,tagsFilter:l,selectedTaskId:i}),r==="graph"&&c.jsx(Fkt,{projectFilter:t??null,tagsFilter:l})]})]})}function $kt(e,t,{checkForDefaultPrevented:n=!0}={}){return function(i){if(e?.(i),n===!1||!i.defaultPrevented)return t?.(i)}}function Ukt(e,t=[]){let n=[];function r(s,a){const o=x.createContext(a),l=n.length;n=[...n,a];const u=f=>{const{scope:h,children:m,...b}=f,y=h?.[e]?.[l]||o,v=x.useMemo(()=>b,Object.values(b));return c.jsx(y.Provider,{value:v,children:m})};u.displayName=s+"Provider";function d(f,h){const m=h?.[e]?.[l]||o,b=x.useContext(m);if(b)return b;if(a!==void 0)return a;throw new Error(`\`${f}\` must be used within \`${s}\``)}return[u,d]}const i=()=>{const s=n.map(a=>x.createContext(a));return function(o){const l=o?.[e]||s;return x.useMemo(()=>({[`__scope${e}`]:{...o,[e]:l}}),[o,l])}};return i.scopeName=e,[r,zkt(i,...t)]}function zkt(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(i=>({useScope:i(),scopeName:i.scopeName}));return function(s){const a=r.reduce((o,{useScope:l,scopeName:u})=>{const f=l(s)[`__scope${u}`];return{...o,...f}},{});return x.useMemo(()=>({[`__scope${t.scopeName}`]:a}),[a])}};return n.scopeName=t.scopeName,n}var XE=globalThis?.document?x.useLayoutEffect:()=>{},Hkt=e3[" useInsertionEffect ".trim().toString()]||XE;function Vkt({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[i,s,a]=Wkt({defaultProp:t,onChange:n}),o=e!==void 0,l=o?e:i;{const d=x.useRef(e!==void 0);x.useEffect(()=>{const f=d.current;f!==o&&console.warn(`${r} is changing from ${f?"controlled":"uncontrolled"} to ${o?"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.`),d.current=o},[o,r])}const u=x.useCallback(d=>{if(o){const f=qkt(d)?d(e):d;f!==e&&a.current?.(f)}else s(d)},[o,e,s,a]);return[l,u]}function Wkt({defaultProp:e,onChange:t}){const[n,r]=x.useState(e),i=x.useRef(n),s=x.useRef(t);return Hkt(()=>{s.current=t},[t]),x.useEffect(()=>{i.current!==n&&(s.current?.(n),i.current=n)},[n,i]),[n,r,s]}function qkt(e){return typeof e=="function"}function Bce(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function rOe(...e){return t=>{let n=!1;const r=e.map(i=>{const s=Bce(i,t);return!n&&typeof s=="function"&&(n=!0),s});if(n)return()=>{for(let i=0;i<r.length;i++){const s=r[i];typeof s=="function"?s():Bce(e[i],null)}}}}function iOe(...e){return x.useCallback(rOe(...e),e)}function Gkt(e){const t=Kkt(e),n=x.forwardRef((r,i)=>{const{children:s,...a}=r,o=x.Children.toArray(s),l=o.find(Xkt);if(l){const u=l.props.children,d=o.map(f=>f===l?x.Children.count(u)>1?x.Children.only(null):x.isValidElement(u)?u.props.children:null:f);return c.jsx(t,{...a,ref:i,children:x.isValidElement(u)?x.cloneElement(u,void 0,d):null})}return c.jsx(t,{...a,ref:i,children:s})});return n.displayName=`${e}.Slot`,n}function Kkt(e){const t=x.forwardRef((n,r)=>{const{children:i,...s}=n;if(x.isValidElement(i)){const a=Qkt(i),o=Zkt(s,i.props);return i.type!==x.Fragment&&(o.ref=r?rOe(r,a):a),x.cloneElement(i,o)}return x.Children.count(i)>1?x.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var Ykt=Symbol("radix.slottable");function Xkt(e){return x.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===Ykt}function Zkt(e,t){const n={...t};for(const r in t){const i=e[r],s=t[r];/^on[A-Z]/.test(r)?i&&s?n[r]=(...o)=>{const l=s(...o);return i(...o),l}:i&&(n[r]=i):r==="style"?n[r]={...i,...s}:r==="className"&&(n[r]=[i,s].filter(Boolean).join(" "))}return{...e,...n}}function Qkt(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var Jkt=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],LZ=Jkt.reduce((e,t)=>{const n=Gkt(`Primitive.${t}`),r=x.forwardRef((i,s)=>{const{asChild:a,...o}=i,l=a?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),c.jsx(l,{...o,ref:s})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function eTt(e,t){return x.useReducer((n,r)=>t[n][r]??n,e)}var sOe=e=>{const{present:t,children:n}=e,r=tTt(t),i=typeof n=="function"?n({present:r.isPresent}):x.Children.only(n),s=iOe(r.ref,nTt(i));return typeof n=="function"||r.isPresent?x.cloneElement(i,{ref:s}):null};sOe.displayName="Presence";function tTt(e){const[t,n]=x.useState(),r=x.useRef(null),i=x.useRef(e),s=x.useRef("none"),a=e?"mounted":"unmounted",[o,l]=eTt(a,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return x.useEffect(()=>{const u=WA(r.current);s.current=o==="mounted"?u:"none"},[o]),XE(()=>{const u=r.current,d=i.current;if(d!==e){const h=s.current,m=WA(u);e?l("MOUNT"):m==="none"||u?.display==="none"?l("UNMOUNT"):l(d&&h!==m?"ANIMATION_OUT":"UNMOUNT"),i.current=e}},[e,l]),XE(()=>{if(t){let u;const d=t.ownerDocument.defaultView??window,f=m=>{const y=WA(r.current).includes(CSS.escape(m.animationName));if(m.target===t&&y&&(l("ANIMATION_END"),!i.current)){const v=t.style.animationFillMode;t.style.animationFillMode="forwards",u=d.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=v)})}},h=m=>{m.target===t&&(s.current=WA(r.current))};return t.addEventListener("animationstart",h),t.addEventListener("animationcancel",f),t.addEventListener("animationend",f),()=>{d.clearTimeout(u),t.removeEventListener("animationstart",h),t.removeEventListener("animationcancel",f),t.removeEventListener("animationend",f)}}else l("ANIMATION_END")},[t,l]),{isPresent:["mounted","unmountSuspended"].includes(o),ref:x.useCallback(u=>{r.current=u?getComputedStyle(u):null,n(u)},[])}}function WA(e){return e?.animationName||"none"}function nTt(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var rTt=e3[" useId ".trim().toString()]||(()=>{}),iTt=0;function sTt(e){const[t,n]=x.useState(rTt());return XE(()=>{n(r=>r??String(iTt++))},[e]),e||(t?`radix-${t}`:"")}var s5="Collapsible",[aTt]=Ukt(s5),[oTt,MZ]=aTt(s5),aOe=x.forwardRef((e,t)=>{const{__scopeCollapsible:n,open:r,defaultOpen:i,disabled:s,onOpenChange:a,...o}=e,[l,u]=Vkt({prop:r,defaultProp:i??!1,onChange:a,caller:s5});return c.jsx(oTt,{scope:n,disabled:s,contentId:sTt(),open:l,onOpenToggle:x.useCallback(()=>u(d=>!d),[u]),children:c.jsx(LZ.div,{"data-state":BZ(l),"data-disabled":s?"":void 0,...o,ref:t})})});aOe.displayName=s5;var oOe="CollapsibleTrigger",lOe=x.forwardRef((e,t)=>{const{__scopeCollapsible:n,...r}=e,i=MZ(oOe,n);return c.jsx(LZ.button,{type:"button","aria-controls":i.contentId,"aria-expanded":i.open||!1,"data-state":BZ(i.open),"data-disabled":i.disabled?"":void 0,disabled:i.disabled,...r,ref:t,onClick:$kt(e.onClick,i.onOpenToggle)})});lOe.displayName=oOe;var FZ="CollapsibleContent",uOe=x.forwardRef((e,t)=>{const{forceMount:n,...r}=e,i=MZ(FZ,e.__scopeCollapsible);return c.jsx(sOe,{present:n||i.open,children:({present:s})=>c.jsx(lTt,{...r,ref:t,present:s})})});uOe.displayName=FZ;var lTt=x.forwardRef((e,t)=>{const{__scopeCollapsible:n,present:r,children:i,...s}=e,a=MZ(FZ,n),[o,l]=x.useState(r),u=x.useRef(null),d=iOe(t,u),f=x.useRef(0),h=f.current,m=x.useRef(0),b=m.current,y=a.open||o,v=x.useRef(y),_=x.useRef(void 0);return x.useEffect(()=>{const w=requestAnimationFrame(()=>v.current=!1);return()=>cancelAnimationFrame(w)},[]),XE(()=>{const w=u.current;if(w){_.current=_.current||{transitionDuration:w.style.transitionDuration,animationName:w.style.animationName},w.style.transitionDuration="0s",w.style.animationName="none";const C=w.getBoundingClientRect();f.current=C.height,m.current=C.width,v.current||(w.style.transitionDuration=_.current.transitionDuration,w.style.animationName=_.current.animationName),l(r)}},[a.open,r]),c.jsx(LZ.div,{"data-state":BZ(a.open),"data-disabled":a.disabled?"":void 0,id:a.contentId,hidden:!y,...s,ref:d,style:{"--radix-collapsible-content-height":h?`${h}px`:void 0,"--radix-collapsible-content-width":b?`${b}px`:void 0,...e.style},children:y&&i})});function BZ(e){return e?"open":"closed"}var uTt=aOe;const pg=uTt,mg=lOe;function gg({className:e,...t}){return c.jsx(uOe,{className:Pe("overflow-hidden data-[state=closed]:animate-collapsible-up data-[state=open]:animate-collapsible-down",e),...t})}const hi="/api/messaging";function cTt(){return Qt({queryKey:["messaging","whatsapp"],queryFn:async()=>{const e=await fetch(`${hi}/whatsapp`);if(!e.ok)throw new Error("Failed to fetch WhatsApp status");return await e.json()},refetchInterval:5e3})}function dTt(){const e=At();return St({mutationFn:async()=>{const t=await fetch(`${hi}/whatsapp/enable`,{method:"POST"});if(!t.ok)throw new Error("Failed to enable WhatsApp");return await t.json()},onSuccess:()=>{e.invalidateQueries({queryKey:["messaging"]})}})}function fTt(){const e=At();return St({mutationFn:async()=>{const t=await fetch(`${hi}/whatsapp/disable`,{method:"POST"});if(!t.ok)throw new Error("Failed to disable WhatsApp");return await t.json()},onSuccess:()=>{e.invalidateQueries({queryKey:["messaging"]})}})}function hTt(){const e=At();return St({mutationFn:async()=>{const t=await fetch(`${hi}/whatsapp/auth`,{method:"POST"});if(!t.ok)throw new Error("Failed to request WhatsApp auth");return await t.json()},onSuccess:()=>{e.invalidateQueries({queryKey:["messaging","whatsapp"]})}})}function pTt(){const e=At();return St({mutationFn:async()=>{const t=await fetch(`${hi}/whatsapp/disconnect`,{method:"POST"});if(!t.ok)throw new Error("Failed to disconnect WhatsApp");return await t.json()},onSuccess:()=>{e.invalidateQueries({queryKey:["messaging"]})}})}function mTt(){return Qt({queryKey:["messaging","whatsapp","sessions"],queryFn:async()=>{const e=await fetch(`${hi}/whatsapp/sessions`);if(!e.ok)throw new Error("Failed to fetch WhatsApp sessions");return(await e.json()).sessions}})}function gTt(){return Qt({queryKey:["messaging","discord"],queryFn:async()=>{const e=await fetch(`${hi}/discord`);if(!e.ok)throw new Error("Failed to fetch Discord status");return await e.json()},refetchInterval:5e3})}function bTt(){const e=At();return St({mutationFn:async t=>{const n=await fetch(`${hi}/discord/configure`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({botToken:t})});if(!n.ok){const r=await n.json();throw new Error(r.error||"Failed to configure Discord")}return await n.json()},onSuccess:()=>{e.invalidateQueries({queryKey:["messaging"]})}})}function yTt(){const e=At();return St({mutationFn:async()=>{const t=await fetch(`${hi}/discord/enable`,{method:"POST"});if(!t.ok){const n=await t.json();throw new Error(n.error||"Failed to enable Discord")}return await t.json()},onSuccess:()=>{e.invalidateQueries({queryKey:["messaging"]})}})}function vTt(){const e=At();return St({mutationFn:async()=>{const t=await fetch(`${hi}/discord/disable`,{method:"POST"});if(!t.ok)throw new Error("Failed to disable Discord");return await t.json()},onSuccess:()=>{e.invalidateQueries({queryKey:["messaging"]})}})}function xTt(){const e=At();return St({mutationFn:async()=>{const t=await fetch(`${hi}/discord/disconnect`,{method:"POST"});if(!t.ok)throw new Error("Failed to disconnect Discord");return await t.json()},onSuccess:()=>{e.invalidateQueries({queryKey:["messaging"]})}})}function _Tt(){return Qt({queryKey:["messaging","discord","sessions"],queryFn:async()=>{const e=await fetch(`${hi}/discord/sessions`);if(!e.ok)throw new Error("Failed to fetch Discord sessions");return(await e.json()).sessions}})}function STt(){return Qt({queryKey:["messaging","telegram"],queryFn:async()=>{const e=await fetch(`${hi}/telegram`);if(!e.ok)throw new Error("Failed to fetch Telegram status");return await e.json()},refetchInterval:5e3})}function wTt(){const e=At();return St({mutationFn:async t=>{const n=await fetch(`${hi}/telegram/configure`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({botToken:t})});if(!n.ok){const r=await n.json();throw new Error(r.error||"Failed to configure Telegram")}return await n.json()},onSuccess:()=>{e.invalidateQueries({queryKey:["messaging"]})}})}function ETt(){const e=At();return St({mutationFn:async()=>{const t=await fetch(`${hi}/telegram/enable`,{method:"POST"});if(!t.ok){const n=await t.json();throw new Error(n.error||"Failed to enable Telegram")}return await t.json()},onSuccess:()=>{e.invalidateQueries({queryKey:["messaging"]})}})}function CTt(){const e=At();return St({mutationFn:async()=>{const t=await fetch(`${hi}/telegram/disable`,{method:"POST"});if(!t.ok)throw new Error("Failed to disable Telegram");return await t.json()},onSuccess:()=>{e.invalidateQueries({queryKey:["messaging"]})}})}function kTt(){const e=At();return St({mutationFn:async()=>{const t=await fetch(`${hi}/telegram/disconnect`,{method:"POST"});if(!t.ok)throw new Error("Failed to disconnect Telegram");return await t.json()},onSuccess:()=>{e.invalidateQueries({queryKey:["messaging"]})}})}function TTt(){return Qt({queryKey:["messaging","telegram","sessions"],queryFn:async()=>{const e=await fetch(`${hi}/telegram/sessions`);if(!e.ok)throw new Error("Failed to fetch Telegram sessions");return(await e.json()).sessions}})}function ATt(){return Qt({queryKey:["messaging","slack"],queryFn:async()=>{const e=await fetch(`${hi}/slack`);if(!e.ok)throw new Error("Failed to fetch Slack status");return await e.json()},refetchInterval:5e3})}function NTt(){const e=At();return St({mutationFn:async t=>{const n=await fetch(`${hi}/slack/configure`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!n.ok){const r=await n.json();throw new Error(r.error||"Failed to configure Slack")}return await n.json()},onSuccess:()=>{e.invalidateQueries({queryKey:["messaging"]})}})}function OTt(){const e=At();return St({mutationFn:async()=>{const t=await fetch(`${hi}/slack/enable`,{method:"POST"});if(!t.ok){const n=await t.json();throw new Error(n.error||"Failed to enable Slack")}return await t.json()},onSuccess:()=>{e.invalidateQueries({queryKey:["messaging"]})}})}function RTt(){const e=At();return St({mutationFn:async()=>{const t=await fetch(`${hi}/slack/disable`,{method:"POST"});if(!t.ok)throw new Error("Failed to disable Slack");return await t.json()},onSuccess:()=>{e.invalidateQueries({queryKey:["messaging"]})}})}function ITt(){const e=At();return St({mutationFn:async()=>{const t=await fetch(`${hi}/slack/disconnect`,{method:"POST"});if(!t.ok)throw new Error("Failed to disconnect Slack");return await t.json()},onSuccess:()=>{e.invalidateQueries({queryKey:["messaging"]})}})}function DTt(){return Qt({queryKey:["messaging","slack","sessions"],queryFn:async()=>{const e=await fetch(`${hi}/slack/sessions`);if(!e.ok)throw new Error("Failed to fetch Slack sessions");return(await e.json()).sessions}})}function PTt(){return Qt({queryKey:["messaging","email"],queryFn:async()=>{const e=await fetch(`${hi}/email`);if(!e.ok)throw new Error("Failed to fetch email status");return await e.json()},refetchInterval:5e3})}function jTt(){const e=At();return St({mutationFn:async t=>{const n=await fetch(`${hi}/email/configure`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!n.ok){const r=await n.json();throw new Error(r.error||"Failed to configure email")}return await n.json()},onSuccess:()=>{e.invalidateQueries({queryKey:["messaging"]})}})}function LTt(){return St({mutationFn:async e=>{const t=await fetch(`${hi}/email/test`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!t.ok){const n=await t.json();throw new Error(n.error||"Failed to test email credentials")}return await t.json()}})}function MTt(){const e=At();return St({mutationFn:async()=>{const t=await fetch(`${hi}/email/enable`,{method:"POST"});if(!t.ok){const n=await t.json();throw new Error(n.error||"Failed to enable email")}return await t.json()},onSuccess:()=>{e.invalidateQueries({queryKey:["messaging"]})}})}function FTt(){const e=At();return St({mutationFn:async()=>{const t=await fetch(`${hi}/email/disable`,{method:"POST"});if(!t.ok)throw new Error("Failed to disable email");return await t.json()},onSuccess:()=>{e.invalidateQueries({queryKey:["messaging"]})}})}function BTt({isLoading:e=!1}){const{data:t,refetch:n}=cTt(),{data:r}=mTt(),i=dTt(),s=fTt(),a=hTt(),o=pTt(),[l,u]=x.useState(null),d=t?.status==="connected",f=t?.status==="connecting",h=t?.status==="qr_pending",m=t?.enabled??!1,b=async T=>{try{if(T){await i.mutateAsync();const k=await a.mutateAsync();u(k.qrDataUrl)}else await s.mutateAsync(),u(null);n()}catch{rt.error(T?"Failed to enable WhatsApp":"Failed to disable WhatsApp")}},y=async()=>{try{const T=await a.mutateAsync();u(T.qrDataUrl)}catch{rt.error("Failed to generate QR code")}},v=async()=>{try{await o.mutateAsync(),u(null),rt.success("WhatsApp disconnected")}catch{rt.error("Failed to disconnect WhatsApp")}},_=()=>d?c.jsx(J,{icon:cr,size:14,strokeWidth:2,className:"text-green-500"}):f||h?c.jsx(J,{icon:Rt,size:14,strokeWidth:2,className:"animate-spin text-yellow-500"}):c.jsx(J,{icon:jn,size:14,strokeWidth:2,className:"text-muted-foreground"}),w=()=>d?t?.displayName?`Connected as ${t.displayName}`:"Connected":f?"Connecting...":h?"Scan QR code":"Disconnected",C=i.isPending||s.isPending||a.isPending||o.isPending;return c.jsxs("div",{className:"space-y-4",children:[c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[c.jsx("label",{className:"text-sm text-muted-foreground sm:w-40 sm:shrink-0",children:"WhatsApp"}),c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx(Dr,{checked:m,onCheckedChange:b,disabled:e||C}),c.jsxs("span",{className:"flex items-center gap-2 text-sm",children:[_(),c.jsx("span",{className:"text-muted-foreground",children:w()})]})]})]}),m&&(l||h)&&!d&&c.jsxs("div",{className:"ml-4 sm:ml-44",children:[c.jsx("div",{className:"rounded-lg border border-border bg-white p-4 inline-block",children:l?c.jsx("img",{src:l,alt:"WhatsApp QR Code",className:"w-48 h-48"}):c.jsx("div",{className:"w-48 h-48 flex items-center justify-center",children:c.jsx(J,{icon:Rt,size:32,strokeWidth:2,className:"animate-spin text-muted-foreground"})})}),c.jsx("p",{className:"mt-2 text-xs text-muted-foreground",children:"Scan this QR code with WhatsApp on your phone"}),c.jsxs(Ce,{variant:"ghost",size:"sm",onClick:y,disabled:C,className:"mt-2",children:[c.jsx(J,{icon:tp,size:14,strokeWidth:2,className:"mr-2"}),"Refresh QR"]})]}),m&&d&&c.jsxs("div",{className:"ml-4 sm:ml-44 space-y-3",children:[c.jsxs(Ce,{variant:"outline",size:"sm",onClick:v,disabled:C,children:[c.jsx(J,{icon:L3,size:14,strokeWidth:2,className:"mr-2"}),"Disconnect"]}),r&&r.length>0&&c.jsxs("div",{className:"mt-4",children:[c.jsx("h4",{className:"text-sm font-medium text-muted-foreground mb-2",children:"Active Conversations"}),c.jsx("div",{className:"space-y-1",children:r.map(T=>c.jsxs("div",{className:"text-xs text-muted-foreground flex items-center gap-2",children:[c.jsx("span",{className:"font-mono",children:T.channelUserId}),T.channelUserName&&c.jsxs("span",{children:["(",T.channelUserName,")"]}),c.jsxs("span",{className:"text-muted-foreground/60",children:["Last: ",new Date(T.lastMessageAt).toLocaleString()]})]},T.id))})]})]}),c.jsx("p",{className:"ml-4 sm:ml-44 text-xs text-muted-foreground",children:"Connect WhatsApp to chat with the AI assistant via your phone. Send any message to start a conversation, or use /reset to start fresh."})]})}function $Tt({isLoading:e=!1}){const{data:t,refetch:n}=gTt(),{data:r}=_Tt(),i=bTt(),s=yTt(),a=vTt(),o=xTt(),l=!!t?.config?.botToken,[u,d]=x.useState(""),[f,h]=x.useState(!1),m=t?.status==="connected",b=t?.status==="connecting",y=async k=>{try{k?l?(await s.mutateAsync(),n()):h(!0):(await a.mutateAsync(),h(!1),d(""),n())}catch{rt.error("Failed to toggle Discord")}},v=async()=>{if(!u.trim()){rt.error("Please enter a bot token");return}try{await i.mutateAsync(u.trim()),h(!1),d(""),rt.success("Discord configuration saved"),n()}catch(k){rt.error(k instanceof Error?k.message:"Failed to connect Discord")}},_=async()=>{try{await o.mutateAsync(),rt.success("Discord disconnected")}catch{rt.error("Failed to disconnect Discord")}},w=()=>m?c.jsx(J,{icon:cr,size:14,strokeWidth:2,className:"text-green-500"}):b?c.jsx(J,{icon:Rt,size:14,strokeWidth:2,className:"animate-spin text-yellow-500"}):c.jsx(J,{icon:jn,size:14,strokeWidth:2,className:"text-muted-foreground"}),C=()=>m?t?.displayName?`Connected as ${t.displayName}`:"Connected":b?"Connecting...":"Disconnected",T=i.isPending||s.isPending||a.isPending||o.isPending;return c.jsxs("div",{className:"space-y-4",children:[c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[c.jsx("label",{className:"text-sm text-muted-foreground sm:w-40 sm:shrink-0",children:"Discord"}),c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx(Dr,{checked:m||b||f,onCheckedChange:y,disabled:e||T}),c.jsxs("span",{className:"flex items-center gap-2 text-sm",children:[w(),c.jsx("span",{className:"text-muted-foreground",children:C()})]})]})]}),f&&!m&&c.jsxs("div",{className:"ml-4 sm:ml-44 space-y-3",children:[c.jsxs("div",{className:"space-y-2",children:[c.jsx("label",{className:"block text-xs text-muted-foreground",children:"Bot Token"}),c.jsx(kt,{type:"password",placeholder:"Enter your Discord bot token",value:u,onChange:k=>d(k.target.value),className:"max-w-md font-mono text-sm"})]}),c.jsxs("div",{className:"flex gap-2",children:[c.jsxs(Ce,{size:"sm",onClick:v,disabled:T||!u.trim(),children:[i.isPending?c.jsx(J,{icon:Rt,size:14,strokeWidth:2,className:"mr-2 animate-spin"}):null,"Connect"]}),c.jsx(Ce,{variant:"ghost",size:"sm",onClick:()=>{h(!1),d("")},disabled:T,children:"Cancel"})]})]}),m&&c.jsxs("div",{className:"ml-4 sm:ml-44 space-y-3",children:[c.jsxs(Ce,{variant:"outline",size:"sm",onClick:_,disabled:T,children:[c.jsx(J,{icon:L3,size:14,strokeWidth:2,className:"mr-2"}),"Disconnect"]}),r&&r.length>0&&c.jsxs("div",{className:"mt-4",children:[c.jsx("h4",{className:"text-sm font-medium text-muted-foreground mb-2",children:"Active Conversations"}),c.jsx("div",{className:"space-y-1",children:r.map(k=>c.jsxs("div",{className:"text-xs text-muted-foreground flex items-center gap-2",children:[c.jsx("span",{className:"font-mono",children:k.channelUserId}),k.channelUserName&&c.jsxs("span",{children:["(",k.channelUserName,")"]}),c.jsxs("span",{className:"text-muted-foreground/60",children:["Last: ",new Date(k.lastMessageAt).toLocaleString()]})]},k.id))})]})]}),c.jsxs("details",{className:"ml-4 sm:ml-44 text-sm text-muted-foreground",children:[c.jsx("summary",{className:"cursor-pointer hover:text-foreground",children:"Setup instructions"}),c.jsxs("ol",{className:"mt-2 ml-4 space-y-1 list-decimal",children:[c.jsxs("li",{children:["Go to the"," ",c.jsx("a",{href:"https://discord.com/developers/applications",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"Discord Developer Portal"})]}),c.jsxs("li",{children:["Create a new application and click ",c.jsx("strong",{children:"Bot"})," in the sidebar"]}),c.jsxs("li",{children:["Click ",c.jsx("strong",{children:"Reset Token"})," to generate a bot token, then copy it"]}),c.jsxs("li",{children:["Enable ",c.jsx("strong",{children:"Message Content Intent"})," under Privileged Gateway Intents"]}),c.jsxs("li",{children:["Go to ",c.jsx("strong",{children:"OAuth2 → URL Generator"})," in the sidebar"]}),c.jsxs("li",{children:["Select both ",c.jsx("strong",{children:"bot"})," and ",c.jsx("strong",{children:"applications.commands"})," scopes"]}),c.jsx("li",{children:"Copy the generated URL and open it to add the bot (slash commands need re-auth)"}),c.jsx("li",{children:"Paste the bot token above and click Connect"}),c.jsx("li",{children:"DM the bot in Discord to chat with the AI assistant"})]})]})]})}function UTt({isLoading:e=!1}){const{data:t,refetch:n}=STt(),{data:r}=TTt(),i=wTt(),s=ETt(),a=CTt(),o=kTt(),l=!!t?.config?.botToken,[u,d]=x.useState(""),[f,h]=x.useState(!1),m=t?.status==="connected",b=t?.status==="connecting",y=async k=>{try{k?l?(await s.mutateAsync(),n()):h(!0):(await a.mutateAsync(),h(!1),d(""),n())}catch{rt.error("Failed to toggle Telegram")}},v=async()=>{if(!u.trim()){rt.error("Please enter a bot token");return}try{await i.mutateAsync(u.trim()),h(!1),d(""),rt.success("Telegram configuration saved"),n()}catch(k){rt.error(k instanceof Error?k.message:"Failed to connect Telegram")}},_=async()=>{try{await o.mutateAsync(),rt.success("Telegram disconnected")}catch{rt.error("Failed to disconnect Telegram")}},w=()=>m?c.jsx(J,{icon:cr,size:14,strokeWidth:2,className:"text-green-500"}):b?c.jsx(J,{icon:Rt,size:14,strokeWidth:2,className:"animate-spin text-yellow-500"}):c.jsx(J,{icon:jn,size:14,strokeWidth:2,className:"text-muted-foreground"}),C=()=>m?t?.displayName?`Connected as ${t.displayName}`:"Connected":b?"Connecting...":"Disconnected",T=i.isPending||s.isPending||a.isPending||o.isPending;return c.jsxs("div",{className:"space-y-4",children:[c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[c.jsx("label",{className:"text-sm text-muted-foreground sm:w-40 sm:shrink-0",children:"Telegram"}),c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx(Dr,{checked:m||b||f,onCheckedChange:y,disabled:e||T}),c.jsxs("span",{className:"flex items-center gap-2 text-sm",children:[w(),c.jsx("span",{className:"text-muted-foreground",children:C()})]})]})]}),f&&!m&&c.jsxs("div",{className:"ml-4 sm:ml-44 space-y-3",children:[c.jsxs("div",{className:"space-y-2",children:[c.jsx("label",{className:"block text-xs text-muted-foreground",children:"Bot Token"}),c.jsx(kt,{type:"password",placeholder:"Enter your Telegram bot token",value:u,onChange:k=>d(k.target.value),className:"max-w-md font-mono text-sm"})]}),c.jsxs("div",{className:"flex gap-2",children:[c.jsxs(Ce,{size:"sm",onClick:v,disabled:T||!u.trim(),children:[i.isPending?c.jsx(J,{icon:Rt,size:14,strokeWidth:2,className:"mr-2 animate-spin"}):null,"Connect"]}),c.jsx(Ce,{variant:"ghost",size:"sm",onClick:()=>{h(!1),d("")},disabled:T,children:"Cancel"})]})]}),m&&c.jsxs("div",{className:"ml-4 sm:ml-44 space-y-3",children:[c.jsxs(Ce,{variant:"outline",size:"sm",onClick:_,disabled:T,children:[c.jsx(J,{icon:L3,size:14,strokeWidth:2,className:"mr-2"}),"Disconnect"]}),r&&r.length>0&&c.jsxs("div",{className:"mt-4",children:[c.jsx("h4",{className:"text-sm font-medium text-muted-foreground mb-2",children:"Active Conversations"}),c.jsx("div",{className:"space-y-1",children:r.map(k=>c.jsxs("div",{className:"text-xs text-muted-foreground flex items-center gap-2",children:[c.jsx("span",{className:"font-mono",children:k.channelUserId}),k.channelUserName&&c.jsxs("span",{children:["(",k.channelUserName,")"]}),c.jsxs("span",{className:"text-muted-foreground/60",children:["Last: ",new Date(k.lastMessageAt).toLocaleString()]})]},k.id))})]})]}),c.jsxs("details",{className:"ml-4 sm:ml-44 text-sm text-muted-foreground",children:[c.jsx("summary",{className:"cursor-pointer hover:text-foreground",children:"Setup instructions"}),c.jsxs("ol",{className:"mt-2 ml-4 space-y-1 list-decimal",children:[c.jsxs("li",{children:["Open Telegram and message"," ",c.jsx("a",{href:"https://t.me/BotFather",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"@BotFather"})]}),c.jsxs("li",{children:["Send ",c.jsx("code",{className:"bg-muted px-1 rounded",children:"/newbot"})," and follow the prompts"]}),c.jsx("li",{children:"Copy the bot token provided by BotFather"}),c.jsx("li",{children:"Paste the token above and click Connect"}),c.jsx("li",{children:"Find your new bot in Telegram and start a chat"})]})]})]})}function zTt({isLoading:e=!1}){const{data:t,refetch:n}=ATt(),{data:r}=DTt(),i=NTt(),s=OTt(),a=RTt(),o=ITt(),l=!!(t?.config?.botToken&&t?.config?.appToken),[u,d]=x.useState(""),[f,h]=x.useState(""),[m,b]=x.useState(!1),y=t?.status==="connected",v=t?.status==="connecting",_=async A=>{try{A?l?(await s.mutateAsync(),n()):b(!0):(await a.mutateAsync(),b(!1),d(""),h(""),n())}catch{rt.error("Failed to toggle Slack")}},w=async()=>{if(!u.trim()){rt.error("Please enter a bot token");return}if(!f.trim()){rt.error("Please enter an app token");return}try{await i.mutateAsync({botToken:u.trim(),appToken:f.trim()}),b(!1),d(""),h(""),rt.success("Slack configuration saved"),n()}catch(A){rt.error(A instanceof Error?A.message:"Failed to connect Slack")}},C=async()=>{try{await o.mutateAsync(),rt.success("Slack disconnected")}catch{rt.error("Failed to disconnect Slack")}},T=()=>y?c.jsx(J,{icon:cr,size:14,strokeWidth:2,className:"text-green-500"}):v?c.jsx(J,{icon:Rt,size:14,strokeWidth:2,className:"animate-spin text-yellow-500"}):c.jsx(J,{icon:jn,size:14,strokeWidth:2,className:"text-muted-foreground"}),k=()=>y?t?.displayName?`Connected as ${t.displayName}`:"Connected":v?"Connecting...":"Disconnected",S=i.isPending||s.isPending||a.isPending||o.isPending;return c.jsxs("div",{className:"space-y-4",children:[c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[c.jsx("label",{className:"text-sm text-muted-foreground sm:w-40 sm:shrink-0",children:"Slack"}),c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx(Dr,{checked:y||v||m,onCheckedChange:_,disabled:e||S}),c.jsxs("span",{className:"flex items-center gap-2 text-sm",children:[T(),c.jsx("span",{className:"text-muted-foreground",children:k()})]})]})]}),m&&!y&&c.jsxs("div",{className:"ml-4 sm:ml-44 space-y-3",children:[c.jsxs("div",{className:"space-y-2",children:[c.jsx("label",{className:"block text-xs text-muted-foreground",children:"Bot Token (xoxb-...)"}),c.jsx(kt,{type:"password",placeholder:"xoxb-your-bot-token",value:u,onChange:A=>d(A.target.value),className:"max-w-md font-mono text-sm"})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsx("label",{className:"block text-xs text-muted-foreground",children:"App Token (xapp-...)"}),c.jsx(kt,{type:"password",placeholder:"xapp-your-app-token",value:f,onChange:A=>h(A.target.value),className:"max-w-md font-mono text-sm"})]}),c.jsxs("div",{className:"flex gap-2",children:[c.jsxs(Ce,{size:"sm",onClick:w,disabled:S||!u.trim()||!f.trim(),children:[i.isPending?c.jsx(J,{icon:Rt,size:14,strokeWidth:2,className:"mr-2 animate-spin"}):null,"Connect"]}),c.jsx(Ce,{variant:"ghost",size:"sm",onClick:()=>{b(!1),d(""),h("")},disabled:S,children:"Cancel"})]})]}),y&&c.jsxs("div",{className:"ml-4 sm:ml-44 space-y-3",children:[c.jsxs(Ce,{variant:"outline",size:"sm",onClick:C,disabled:S,children:[c.jsx(J,{icon:L3,size:14,strokeWidth:2,className:"mr-2"}),"Disconnect"]}),r&&r.length>0&&c.jsxs("div",{className:"mt-4",children:[c.jsx("h4",{className:"text-sm font-medium text-muted-foreground mb-2",children:"Active Conversations"}),c.jsx("div",{className:"space-y-1",children:r.map(A=>c.jsxs("div",{className:"text-xs text-muted-foreground flex items-center gap-2",children:[c.jsx("span",{className:"font-mono",children:A.channelUserId}),A.channelUserName&&c.jsxs("span",{children:["(",A.channelUserName,")"]}),c.jsxs("span",{className:"text-muted-foreground/60",children:["Last: ",new Date(A.lastMessageAt).toLocaleString()]})]},A.id))})]})]}),c.jsxs("details",{className:"ml-4 sm:ml-44 text-sm text-muted-foreground",children:[c.jsx("summary",{className:"cursor-pointer hover:text-foreground",children:"Setup instructions"}),c.jsxs("ol",{className:"mt-2 ml-4 space-y-1 list-decimal",children:[c.jsxs("li",{children:["Go to"," ",c.jsx("a",{href:"https://api.slack.com/apps",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"api.slack.com/apps"})," ","and create a new app"]}),c.jsxs("li",{children:["Under ",c.jsx("strong",{children:"Socket Mode"}),", enable it and create an App Token (xapp-...)"]}),c.jsxs("li",{children:["Under ",c.jsx("strong",{children:"OAuth & Permissions"}),", add these ",c.jsx("strong",{children:"Bot Token Scopes"}),":"," ",c.jsx("code",{className:"bg-muted px-1 rounded text-xs",children:"chat:write"}),","," ",c.jsx("code",{className:"bg-muted px-1 rounded text-xs",children:"commands"}),","," ",c.jsx("code",{className:"bg-muted px-1 rounded text-xs",children:"files:read"}),","," ",c.jsx("code",{className:"bg-muted px-1 rounded text-xs",children:"files:write"}),","," ",c.jsx("code",{className:"bg-muted px-1 rounded text-xs",children:"im:history"}),","," ",c.jsx("code",{className:"bg-muted px-1 rounded text-xs",children:"im:read"}),","," ",c.jsx("code",{className:"bg-muted px-1 rounded text-xs",children:"im:write"}),","," ",c.jsx("code",{className:"bg-muted px-1 rounded text-xs",children:"users:read"})]}),c.jsx("li",{children:"Install the app to your workspace to get the Bot Token (xoxb-...)"}),c.jsxs("li",{children:["Under ",c.jsx("strong",{children:"Event Subscriptions"}),", subscribe to ",c.jsx("code",{className:"bg-muted px-1 rounded text-xs",children:"message.im"})]}),c.jsxs("li",{children:["Under ",c.jsx("strong",{children:"Slash Commands"}),", create these commands:"," ",c.jsx("code",{className:"bg-muted px-1 rounded text-xs",children:"/reset"}),","," ",c.jsx("code",{className:"bg-muted px-1 rounded text-xs",children:"/help"}),","," ",c.jsx("code",{className:"bg-muted px-1 rounded text-xs",children:"/info"})," ",c.jsx("span",{className:"text-muted-foreground/60",children:"(/status is reserved by Slack)"})]}),c.jsxs("li",{children:["Under ",c.jsx("strong",{children:"App Home"}),", enable ",c.jsx("strong",{children:"Messages Tab"})," and check ",c.jsx("em",{children:'"Allow users to send Slash commands and messages from the messages tab"'})]}),c.jsx("li",{children:"Paste both tokens above and click Connect"}),c.jsx("li",{children:"DM the bot in Slack to chat with the AI assistant"})]})]})]})}const Y6=nu(),dp="";function a5(){return Qt({queryKey:["google","accounts"],queryFn:()=>ct(`${dp}/api/google/accounts`).then(e=>e.accounts)})}function cOe(){const e=At();return St({mutationFn:({id:t,...n})=>ct(`${dp}/api/google/accounts/${t}`,{method:"PATCH",body:JSON.stringify(n)}),onSuccess:()=>{e.invalidateQueries({queryKey:["google"]})}})}function HTt(){const e=At();return St({mutationFn:t=>ct(`${dp}/api/google/accounts/${t}`,{method:"DELETE"}),onSuccess:()=>{e.invalidateQueries({queryKey:["google"]}),e.invalidateQueries({queryKey:["caldav"]})}})}function VTt(){const e=At();return St({mutationFn:t=>ct(`${dp}/api/google/accounts/${t}/enable-calendar`,{method:"POST"}),onSuccess:()=>{e.invalidateQueries({queryKey:["google"]}),e.invalidateQueries({queryKey:["caldav"]})}})}function WTt(){const e=At();return St({mutationFn:t=>ct(`${dp}/api/google/accounts/${t}/disable-calendar`,{method:"POST"}),onSuccess:()=>{e.invalidateQueries({queryKey:["google"]}),e.invalidateQueries({queryKey:["caldav"]})}})}function qTt(){const e=At();return St({mutationFn:t=>ct(`${dp}/api/google/accounts/${t}/sync`,{method:"POST"}),onSuccess:()=>{e.invalidateQueries({queryKey:["google"]}),e.invalidateQueries({queryKey:["caldav"]})}})}function GTt(){const e=At();return St({mutationFn:t=>ct(`${dp}/api/google/accounts/${t}/enable-gmail`,{method:"POST"}),onSuccess:()=>{e.invalidateQueries({queryKey:["google"]})}})}function KTt(){const e=At();return St({mutationFn:t=>ct(`${dp}/api/google/accounts/${t}/disable-gmail`,{method:"POST"}),onSuccess:()=>{e.invalidateQueries({queryKey:["google"]})}})}function YTt(){return St({mutationFn:async e=>{const t=new URLSearchParams;e.accountName&&t.set("accountName",e.accountName),e.accountId&&t.set("accountId",e.accountId),t.set("origin",window.location.origin);const n=`${dp}/api/google/oauth/authorize?${t.toString()}`;Y6.info("Requesting OAuth authorize URL",{origin:window.location.origin,href:window.location.href,fetchUrl:n,accountName:e.accountName,accountId:e.accountId});const r=await ct(n);try{const i=new URL(r.authUrl);Y6.info("Got OAuth auth URL from server",{authUrl:r.authUrl,redirect_uri:i.searchParams.get("redirect_uri"),client_id:i.searchParams.get("client_id"),scope:i.searchParams.get("scope"),state:i.searchParams.get("state")})}catch{Y6.info("Got OAuth auth URL from server (unparseable)",{authUrl:r.authUrl})}return r}})}const $ce={"gmail.com":{imap:{host:"imap.gmail.com",port:993,secure:!0},note:"Requires an App Password. Go to Google Account > Security > 2-Step Verification > App passwords."},"googlemail.com":{imap:{host:"imap.gmail.com",port:993,secure:!0},note:"Requires an App Password. Go to Google Account > Security > 2-Step Verification > App passwords."},"outlook.com":{imap:{host:"outlook.office365.com",port:993,secure:!0}},"hotmail.com":{imap:{host:"outlook.office365.com",port:993,secure:!0}},"live.com":{imap:{host:"outlook.office365.com",port:993,secure:!0}},"yahoo.com":{imap:{host:"imap.mail.yahoo.com",port:993,secure:!0}},"icloud.com":{imap:{host:"imap.mail.me.com",port:993,secure:!0},note:"Requires an App-Specific Password from appleid.apple.com."}};function Uce(e){const t=e.split("@")[1]?.toLowerCase();return t&&$ce[t]?{...$ce[t],isKnown:!0}:{imap:{host:`imap.${t||"example.com"}`,port:993,secure:!0},isKnown:!1}}function XTt({isLoading:e=!1}){const{t}=Dt("settings"),[n,r]=x.useState("gmail");return c.jsxs("div",{className:"space-y-4",children:[c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[c.jsx("label",{className:"text-sm text-muted-foreground sm:w-40 sm:shrink-0",children:t("imap.emailBackend","Email Backend")}),c.jsxs("div",{className:"flex gap-1 rounded-lg border p-0.5",children:[c.jsx("button",{type:"button",onClick:()=>r("gmail"),className:`rounded-md px-3 py-1 text-sm transition-colors ${n==="gmail"?"bg-destructive text-destructive-foreground":"text-muted-foreground hover:text-foreground"}`,children:t("google.gmail","Gmail API")}),c.jsx("button",{type:"button",onClick:()=>r("imap"),className:`rounded-md px-3 py-1 text-sm transition-colors ${n==="imap"?"bg-destructive text-destructive-foreground":"text-muted-foreground hover:text-foreground"}`,children:"IMAP"})]})]}),n==="imap"?c.jsx(ZTt,{isLoading:e}):c.jsx(QTt,{})]})}function ZTt({isLoading:e=!1}){const{t}=Dt("settings"),{data:n,refetch:r}=PTt(),i=jTt(),s=LTt(),a=MTt(),o=FTt(),l=!!n?.config?.imap?.host,[u,d]=x.useState(""),[f,h]=x.useState(""),[m,b]=x.useState(!1),[y,v]=x.useState(""),[_,w]=x.useState(993),[C,T]=x.useState(!0),[k,S]=x.useState(""),[A,R]=x.useState(""),[I,D]=x.useState(30),[P,j]=x.useState(null),B=n?.status==="connected",L=n?.status==="connecting",M=n?.enabled??!1,$=Uce(u);x.useEffect(()=>{if(n?.config){const ne=n.config;d(ne.imap?.user||""),h(ne.imap?.password||""),v(ne.imap?.host||""),w(ne.imap?.port||993),T(ne.imap?.secure??!0),S(ne.imap?.user||""),R(ne.imap?.password||""),D(ne.pollIntervalSeconds||30);const ae=Uce(ne.imap?.user||"");ne.imap?.host&&ne.imap.host!==ae.imap.host&&b(!0)}},[n?.config]);const U=()=>m?{imap:{host:y,port:_,secure:C,user:k,password:A},pollIntervalSeconds:I}:{imap:{...$.imap,user:u,password:f},pollIntervalSeconds:I},W=async()=>{const ne=U();j(null);try{const ae=await s.mutateAsync(ne);j(ae),ae.success?rt.success("Connection test successful"):rt.error(ae.error||"Connection test failed")}catch{rt.error("Failed to test credentials")}},Y=async()=>{const ne=U();try{await i.mutateAsync(ne),rt.success("Email configured successfully"),h(""),r()}catch{rt.error("Failed to configure email")}},G=async()=>{try{await a.mutateAsync()&&(rt.success("Email enabled"),r())}catch(ne){rt.error(ne instanceof Error?ne.message:"Failed to enable email")}},q=async()=>{try{await o.mutateAsync(),rt.success("Email disabled"),r()}catch{rt.error("Failed to disable email")}},X=async ne=>{ne?l&&await G():await q()},z=i.isPending||s.isPending||a.isPending||o.isPending,Q=()=>B?c.jsx(J,{icon:cr,size:14,strokeWidth:2,className:"text-green-500"}):L?c.jsx(J,{icon:Rt,size:14,strokeWidth:2,className:"animate-spin text-yellow-500"}):c.jsx(J,{icon:jn,size:14,strokeWidth:2,className:"text-muted-foreground"}),ee=()=>B?n?.displayName?`Connected as ${n.displayName}`:"Connected":L?"Connecting...":n?.status==="credentials_required"?"Credentials required":"Disconnected";return c.jsxs("div",{className:"space-y-4",children:[c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[c.jsx("label",{className:"text-sm text-muted-foreground sm:w-40 sm:shrink-0",children:t("imap.label","IMAP Feed")}),c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx(Dr,{checked:M,onCheckedChange:X,disabled:e||z}),c.jsxs("span",{className:"flex items-center gap-2 text-sm",children:[Q(),c.jsx("span",{className:"text-muted-foreground",children:ee()})]})]})]}),!B&&c.jsxs("div",{className:"ml-4 sm:ml-44 space-y-4 max-w-md",children:[!m&&c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"space-y-2",children:[c.jsx(Kr,{htmlFor:"email",children:"Email Address"}),c.jsx(kt,{id:"email",type:"email",placeholder:"assistant@example.com",value:u,onChange:ne=>d(ne.target.value)}),$.note&&u.includes("@")&&c.jsxs("p",{className:"text-xs text-muted-foreground flex items-start gap-1",children:[c.jsx(J,{icon:Pr,size:14,strokeWidth:2,className:"shrink-0 mt-0.5 text-yellow-500"}),$.note]})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsx(Kr,{htmlFor:"password",children:u.includes("@gmail.com")||u.includes("@icloud.com")?"App Password":"Password"}),c.jsx(kt,{id:"password",type:"password",placeholder:"Password",value:f,onChange:ne=>h(ne.target.value)})]}),u.includes("@")&&c.jsxs("div",{className:"text-xs text-muted-foreground",children:[c.jsxs("span",{children:["IMAP: ",$.imap.host,":",$.imap.port]}),!$.isKnown&&c.jsx("span",{className:"ml-2 text-yellow-600",children:"(auto-detected)"})]})]}),c.jsx("div",{className:"pt-2",children:c.jsx("button",{type:"button",onClick:()=>b(!m),className:"text-xs text-muted-foreground hover:text-foreground",children:m?"- Hide advanced settings":"+ Show advanced settings"})}),m&&c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"border-t border-border pt-4",children:[c.jsx("h4",{className:"text-sm font-medium mb-3",children:"IMAP Settings (Incoming)"}),c.jsxs("div",{className:"space-y-3",children:[c.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[c.jsxs("div",{className:"col-span-2 space-y-2",children:[c.jsx(Kr,{htmlFor:"imapHost",children:"Host"}),c.jsx(kt,{id:"imapHost",placeholder:"imap.gmail.com",value:y,onChange:ne=>v(ne.target.value)})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsx(Kr,{htmlFor:"imapPort",children:"Port"}),c.jsx(kt,{id:"imapPort",type:"number",value:_||$.imap.port,onChange:ne=>w(parseInt(ne.target.value)||993)})]}),c.jsxs("div",{className:"flex items-end gap-2 pb-1",children:[c.jsx(Dr,{id:"imapSecure",checked:C,onCheckedChange:T}),c.jsx(Kr,{htmlFor:"imapSecure",children:"SSL/TLS"})]})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsx(Kr,{htmlFor:"imapUser",children:"Username"}),c.jsx(kt,{id:"imapUser",placeholder:"you@gmail.com",value:k,onChange:ne=>S(ne.target.value)})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsx(Kr,{htmlFor:"imapPassword",children:"Password"}),c.jsx(kt,{id:"imapPassword",type:"password",placeholder:"IMAP password or app password",value:A,onChange:ne=>R(ne.target.value)})]})]})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsx(Kr,{htmlFor:"pollInterval",children:"Check for new emails every"}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(kt,{id:"pollInterval",type:"number",className:"w-20",min:10,max:300,value:I,onChange:ne=>D(parseInt(ne.target.value)||30)}),c.jsx("span",{className:"text-sm text-muted-foreground",children:"seconds"})]})]})]}),P&&c.jsxs("div",{className:`p-3 rounded-lg text-sm ${P.success?"bg-green-500/10 text-green-600":"bg-red-500/10 text-red-600"}`,children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(J,{icon:P.success?cr:jn,size:16,strokeWidth:2}),c.jsx("span",{children:P.success?"Connection successful":"Connection failed"})]}),!P.success&&P.error&&c.jsx("p",{className:"mt-1 text-xs",children:P.error}),c.jsx("div",{className:"mt-2 text-xs space-y-1",children:c.jsxs("p",{children:["IMAP: ",P.imapOk?"OK":"Failed"]})})]}),c.jsxs("div",{className:"flex gap-2",children:[c.jsxs(Ce,{variant:"outline",size:"sm",onClick:W,disabled:z||(m?!y||!k||!A:!u||!f),children:[s.isPending?c.jsx(J,{icon:Rt,size:14,strokeWidth:2,className:"mr-2 animate-spin"}):c.jsx(J,{icon:nm,size:14,strokeWidth:2,className:"mr-2"}),"Test Connection"]}),c.jsxs(Ce,{size:"sm",onClick:Y,disabled:z||(m?!y||!k||!A:!u||!f),children:[i.isPending?c.jsx(J,{icon:Rt,size:14,strokeWidth:2,className:"mr-2 animate-spin"}):null,"Save & Enable"]})]})]}),M&&B&&c.jsx("div",{className:"ml-4 sm:ml-44 space-y-3",children:c.jsx(Ce,{variant:"outline",size:"sm",onClick:q,disabled:z,children:t("imap.disableButton","Disable Email")})}),c.jsx("p",{className:"ml-4 sm:ml-44 text-xs text-muted-foreground",children:t("imap.description","Monitor an IMAP mailbox as a read-only feed. Incoming emails appear in the messaging timeline but no replies are sent.")})]})}function QTt(){const{t:e}=Dt("settings"),{data:t}=a5(),n=GTt(),r=KTt(),i=Cr(qt.EMAIL_POLL_INTERVAL),s=rW(),[a,o]=x.useState(30);x.useEffect(()=>{i.data?.value!=null&&o(Number(i.data.value)||30)},[i.data?.value]);const l=()=>{const f=Math.max(5,Math.min(3600,a||30));o(f),s.mutate({key:qt.EMAIL_POLL_INTERVAL,value:f})},u=async(f,h)=>{try{h?(await n.mutateAsync(f),rt.success(e("google.gmailEnabled","Gmail enabled"))):(await r.mutateAsync(f),rt.success(e("google.gmailDisabled","Gmail disabled")))}catch(m){rt.error(String(m))}},d=t?.some(f=>f.gmailEnabled);return!t||t.length===0?c.jsx("div",{className:"space-y-2 ml-4 sm:ml-44",children:c.jsxs("p",{className:"text-sm text-muted-foreground",children:[e("google.noAccountsGmail","No Google accounts connected.")," ",c.jsx(ai,{to:"/settings",search:{tab:void 0},className:"text-accent underline underline-offset-2",children:e("google.addInGeneral","Add one in General settings")})]})}):c.jsxs("div",{className:"space-y-4",children:[t.map(f=>c.jsx(JTt,{account:f,onToggle:u},f.id)),d&&c.jsxs("div",{className:"flex items-center gap-2 ml-4",children:[c.jsx(Kr,{htmlFor:"gmailPollInterval",children:e("imap.checkEvery","Check for new emails every")}),c.jsx(kt,{id:"gmailPollInterval",type:"number",min:5,max:3600,value:a,onChange:f=>o(parseInt(f.target.value)||30),onBlur:l,onKeyDown:f=>{f.key==="Enter"&&f.currentTarget.blur()},className:"w-20 h-8"}),c.jsx("span",{className:"text-sm text-muted-foreground",children:e("imap.seconds","seconds")})]}),c.jsx("p",{className:"text-xs text-muted-foreground",children:e("google.gmailDescription","Gmail API uses OAuth2 — no app passwords needed. Drafts are created for human review before sending.")})]})}function JTt({account:e,onToggle:t}){const{t:n}=Dt("settings"),r=cOe(),[i,s]=x.useState(e.sendAsEmail??e.email??""),a=async()=>{const o=i.trim(),l=e.sendAsEmail??e.email??"";if(o!==l)try{await r.mutateAsync({id:e.id,sendAsEmail:o||null}),rt.success(n("google.sendAsUpdated","Send-as address updated"))}catch(u){rt.error(String(u))}};return c.jsxs("div",{className:"border rounded-lg p-4 space-y-3",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx("span",{className:"font-medium text-sm",children:e.name}),e.email&&c.jsx("span",{className:"text-xs text-muted-foreground ml-2",children:e.email})]}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("span",{className:"text-xs text-muted-foreground",children:n("google.monitorInbox","Monitor inbox")}),c.jsx(Dr,{checked:e.gmailEnabled??!1,onCheckedChange:o=>t(e.id,o)})]})]}),e.gmailEnabled&&c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("label",{className:"text-xs text-muted-foreground shrink-0",children:n("google.sendAs","Send as")}),c.jsx(kt,{value:i,onChange:o=>s(o.target.value),onBlur:a,onKeyDown:o=>{o.key==="Enter"&&o.currentTarget.blur()},placeholder:e.email??n("google.sendAsPlaceholder","you@gmail.com"),className:"h-8 text-xs max-w-xs"}),c.jsx("span",{className:"text-xs text-muted-foreground",children:n("google.draftsOnly","(drafts only)")})]}),e.lastGmailSyncError&&c.jsxs("div",{className:"flex items-start gap-1.5",children:[c.jsx(J,{icon:Pr,className:"h-3.5 w-3.5 text-destructive mt-0.5"}),c.jsx("p",{className:"text-xs text-destructive",children:e.lastGmailSyncError})]})]})}const va="";function eAt(){return Qt({queryKey:["caldav","status"],queryFn:()=>ct(`${va}/api/caldav/status`),refetchInterval:3e4})}function dOe(){return Qt({queryKey:["caldav","accounts"],queryFn:()=>ct(`${va}/api/caldav/accounts`)})}function tAt(){const e=At();return St({mutationFn:t=>ct(`${va}/api/caldav/accounts`,{method:"POST",body:JSON.stringify(t)}),onSuccess:()=>{e.invalidateQueries({queryKey:["caldav"]})}})}function nAt(){const e=At();return St({mutationFn:t=>ct(`${va}/api/caldav/accounts/google`,{method:"POST",body:JSON.stringify(t)}),onSuccess:()=>{e.invalidateQueries({queryKey:["caldav"]})}})}function rAt(){const e=At();return St({mutationFn:({id:t,...n})=>ct(`${va}/api/caldav/accounts/${t}`,{method:"PATCH",body:JSON.stringify(n)}),onSuccess:()=>{e.invalidateQueries({queryKey:["caldav"]})}})}function iAt(){const e=At();return St({mutationFn:t=>ct(`${va}/api/caldav/accounts/${t}`,{method:"DELETE"}),onSuccess:()=>{e.invalidateQueries({queryKey:["caldav"]})}})}function sAt(){const e=At();return St({mutationFn:t=>ct(`${va}/api/caldav/accounts/${t}/enable`,{method:"POST"}),onSuccess:()=>{e.invalidateQueries({queryKey:["caldav"]})}})}function aAt(){const e=At();return St({mutationFn:t=>ct(`${va}/api/caldav/accounts/${t}/disable`,{method:"POST"}),onSuccess:()=>{e.invalidateQueries({queryKey:["caldav"]})}})}function oAt(){const e=At();return St({mutationFn:t=>ct(`${va}/api/caldav/accounts/${t}/sync`,{method:"POST"}),onSuccess:()=>{e.invalidateQueries({queryKey:["caldav"]})}})}function lAt(){return St({mutationFn:e=>ct(`${va}/api/caldav/accounts/${e}/oauth/authorize`)})}function uAt(){return Qt({queryKey:["caldav","copy-rules"],queryFn:()=>ct(`${va}/api/caldav/copy-rules`)})}function cAt(){const e=At();return St({mutationFn:t=>ct(`${va}/api/caldav/copy-rules`,{method:"POST",body:JSON.stringify(t)}),onSuccess:()=>{e.invalidateQueries({queryKey:["caldav","copy-rules"]})}})}function dAt(){const e=At();return St({mutationFn:({id:t,...n})=>ct(`${va}/api/caldav/copy-rules/${t}`,{method:"PATCH",body:JSON.stringify(n)}),onSuccess:()=>{e.invalidateQueries({queryKey:["caldav","copy-rules"]})}})}function fAt(){const e=At();return St({mutationFn:t=>ct(`${va}/api/caldav/copy-rules/${t}`,{method:"DELETE"}),onSuccess:()=>{e.invalidateQueries({queryKey:["caldav","copy-rules"]})}})}function hAt(){const e=At();return St({mutationFn:t=>ct(`${va}/api/caldav/copy-rules/${t}/execute`,{method:"POST"}),onSuccess:()=>{e.invalidateQueries({queryKey:["caldav"]})}})}function $Z(){return Qt({queryKey:["caldav","calendars"],queryFn:()=>ct(`${va}/api/caldav/calendars`)})}function pAt(){const e=At();return St({mutationFn:()=>ct(`${va}/api/caldav/enable`,{method:"POST"}),onSuccess:()=>{e.invalidateQueries({queryKey:["caldav"]}),e.invalidateQueries({queryKey:["config","caldav.enabled"]})}})}function mAt(){const e=At();return St({mutationFn:()=>ct(`${va}/api/caldav/disable`,{method:"POST"}),onSuccess:()=>{e.invalidateQueries({queryKey:["caldav"]}),e.invalidateQueries({queryKey:["config","caldav.enabled"]})}})}function fOe(e,t){return Qt({queryKey:["caldav","events",e,t],queryFn:()=>ct(`${va}/api/caldav/events?from=${e}&to=${t}`),enabled:!!e&&!!t})}function gAt({isLoading:e=!1}){const{t}=Dt("settings"),{data:n,refetch:r}=eAt(),{data:i}=dOe(),s=tAt(),a=nAt(),o=iAt(),l=sAt(),u=aAt(),d=oAt(),f=lAt(),h=rAt(),m=pAt(),b=mAt(),y=nW(),[v,_]=x.useState(!1),[w,C]=x.useState(null),[T,k]=x.useState(""),[S,A]=x.useState("google"),[R,I]=x.useState(""),[D,P]=x.useState(""),[j,B]=x.useState(""),[L,M]=x.useState(""),[$,U]=x.useState("15"),[W,Y]=x.useState(""),[G,q]=x.useState(""),[X,z]=x.useState(""),[Q,ee]=x.useState("15"),[ne,ae]=x.useState(!1),[fe,re]=x.useState(null),de=x.useRef(null),he=n?.connected===!0||(n?.accounts??[]).length>0;x.useEffect(()=>(ne&&fe&&(de.current=setInterval(()=>{r()},2e3)),ne&&fe&&n?.accounts&&n.accounts.find(je=>je.id===fe)?.connected&&(ae(!1),re(null),_(!1),Y(""),q(""),z(""),rt.success(t("caldav.configured"))),()=>{de.current&&(clearInterval(de.current),de.current=null)}),[ne,fe,n?.accounts,r,t]);const ce=async ve=>{try{ve?await m.mutateAsync():await b.mutateAsync(),r()}catch{rt.error(t("caldav.toggleFailed"))}},ye=async ve=>{try{await d.mutateAsync(ve),rt.success(t("caldav.syncComplete")),r()}catch(je){rt.error(je instanceof Error?je.message:t("caldav.syncFailed"))}},be=async(ve,je)=>{try{je?await u.mutateAsync(ve):await l.mutateAsync(ve),r()}catch{rt.error(t("caldav.toggleFailed"))}},ue=async ve=>{try{await o.mutateAsync(ve),rt.success(t("caldav.disconnected")),r()}catch{rt.error(t("caldav.disconnectFailed"))}},Ae=async()=>{if(!D.trim()||!j.trim()||!L.trim()){rt.error(t("caldav.fillRequired"));return}try{await s.mutateAsync({name:R.trim()||j.trim(),serverUrl:D.trim(),username:j.trim(),password:L.trim(),syncIntervalMinutes:parseInt($,10)||15}),_(!1),I(""),P(""),B(""),M(""),U("15"),rt.success(t("caldav.configured")),r()}catch(ve){rt.error(ve instanceof Error?ve.message:t("caldav.configureFailed"))}},le=async()=>{if(!G.trim()||!X.trim()){rt.error(t("caldav.googleFillRequired"));return}try{const ve=await a.mutateAsync({name:W.trim()||"Google Calendar",googleClientId:G.trim(),googleClientSecret:X.trim(),syncIntervalMinutes:parseInt(Q,10)||15}),{authUrl:je}=await f.mutateAsync(ve.id);window.open(je,"_blank","noopener"),rt.info(t("caldav.googleAuthStarted")),re(ve.id),ae(!0)}catch(ve){rt.error(ve instanceof Error?ve.message:t("caldav.configureFailed"))}},ke=()=>{_(!1),ae(!1),re(null),I(""),P(""),B(""),M(""),U("15"),Y(""),q(""),z(""),ee("15")},Fe=s.isPending||a.isPending||f.isPending||h.isPending||o.isPending||l.isPending||u.isPending||d.isPending||m.isPending||b.isPending,ze=n?.accounts??[];return c.jsxs("div",{className:"space-y-4",children:[c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[c.jsx("label",{className:"text-sm text-muted-foreground sm:w-40 sm:shrink-0",children:t("caldav.label")}),c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx(Dr,{checked:he,onCheckedChange:ce,disabled:e||Fe}),m.isPending&&c.jsxs("span",{className:"flex items-center gap-2 text-sm",children:[c.jsx(J,{icon:Rt,size:14,strokeWidth:2,className:"animate-spin text-yellow-500"}),c.jsx("span",{className:"text-muted-foreground",children:t("caldav.statusConnecting")})]})]})]}),ze.length>0&&c.jsx("div",{className:"ml-4 sm:ml-44 space-y-2",children:ze.map(ve=>{const we=i?.find(Le=>Le.id===ve.id)?.authType??"basic";return c.jsxs("div",{className:"flex items-center gap-3 rounded-md border px-3 py-2",children:[c.jsx("div",{className:"shrink-0",children:ve.syncing?c.jsx(J,{icon:Rt,size:14,strokeWidth:2,className:"animate-spin text-yellow-500"}):ve.lastError?c.jsx(J,{icon:jn,size:14,strokeWidth:2,className:"text-red-500"}):ve.connected?c.jsx(J,{icon:cr,size:14,strokeWidth:2,className:"text-green-500"}):c.jsx("span",{className:"inline-block h-3.5 w-3.5 rounded-full border border-muted-foreground/40"})}),c.jsxs("div",{className:"flex-1 min-w-0",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[w===ve.id?c.jsx(kt,{autoFocus:!0,value:T,onChange:Le=>k(Le.target.value),onFocus:Le=>Le.target.select(),onKeyDown:Le=>{Le.key==="Enter"?Le.currentTarget.blur():Le.key==="Escape"&&(C(null),k(""))},onBlur:()=>{const Le=T.trim();Le&&Le!==ve.name&&h.mutate({id:ve.id,name:Le},{onSuccess:()=>r()}),C(null),k("")},className:"h-6 w-48 text-sm font-medium px-1.5 py-0"}):c.jsx("span",{className:"text-sm font-medium truncate cursor-pointer hover:underline",onClick:()=>{C(ve.id),k(ve.name)},children:ve.name}),c.jsx("span",{className:"shrink-0 rounded bg-muted px-1.5 py-0.5 text-[10px] font-medium uppercase text-muted-foreground",children:we==="google-oauth"?"Google":"Basic"})]}),c.jsx("div",{className:"text-xs text-muted-foreground",children:ve.connected?`${ve.calendarCount} calendar${ve.calendarCount!==1?"s":""}`:ve.lastError?ve.lastError:ve.enabled?t("caldav.statusConnecting"):t("caldav.disabled")??"Disabled"})]}),c.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[c.jsx(Ce,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>ye(ve.id),disabled:Fe||ve.syncing||!ve.enabled,title:t("caldav.syncButton"),children:c.jsx(J,{icon:tp,size:14,strokeWidth:2,className:ve.syncing?"animate-spin":""})}),c.jsx(Dr,{checked:ve.enabled,onCheckedChange:()=>be(ve.id,ve.enabled),disabled:Fe,className:"scale-75"}),c.jsx(Ce,{variant:"ghost",size:"icon",className:"h-7 w-7 text-destructive hover:text-destructive",onClick:()=>ue(ve.id),disabled:Fe,title:t("caldav.deleteAccount")??"Delete",children:c.jsx(J,{icon:ma,size:14,strokeWidth:2})})]})]},ve.id)})}),!v&&c.jsx("div",{className:"ml-4 sm:ml-44",children:c.jsxs(Ce,{variant:"outline",size:"sm",onClick:()=>_(!0),disabled:Fe,children:[c.jsx(J,{icon:mu,size:14,strokeWidth:2,className:"mr-2"}),t("caldav.addAccount")]})}),v&&c.jsx("div",{className:"ml-4 sm:ml-44",children:c.jsxs(Jo,{value:S,onValueChange:A,children:[c.jsxs(el,{children:[c.jsx(Bn,{value:"google",children:t("caldav.tabGoogle")}),c.jsx(Bn,{value:"basic",children:t("caldav.tabBasic")})]}),c.jsx(Un,{value:"basic",children:c.jsxs("div",{className:"space-y-3 pt-2",children:[c.jsxs("div",{className:"space-y-2",children:[c.jsx("label",{className:"block text-xs text-muted-foreground",children:t("caldav.accountName")}),c.jsx(kt,{type:"text",placeholder:t("caldav.accountNamePlaceholder")??"My CalDAV Server",value:R,onChange:ve=>I(ve.target.value),className:"max-w-md text-sm"})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsx("label",{className:"block text-xs text-muted-foreground",children:t("caldav.serverUrl")}),c.jsx(kt,{type:"url",placeholder:t("caldav.serverUrlPlaceholder"),value:D,onChange:ve=>P(ve.target.value),className:"max-w-md font-mono text-sm"})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsx("label",{className:"block text-xs text-muted-foreground",children:t("caldav.username")}),c.jsx(kt,{type:"text",placeholder:t("caldav.usernamePlaceholder"),value:j,onChange:ve=>B(ve.target.value),className:"max-w-md text-sm"})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsx("label",{className:"block text-xs text-muted-foreground",children:t("caldav.password")}),c.jsx(kt,{type:"password",placeholder:t("caldav.passwordPlaceholder"),value:L,onChange:ve=>M(ve.target.value),className:"max-w-md font-mono text-sm"})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsx("label",{className:"block text-xs text-muted-foreground",children:t("caldav.syncInterval")}),c.jsx(kt,{type:"number",min:1,max:1440,value:$,onChange:ve=>U(ve.target.value),className:"w-24 text-sm"})]}),c.jsxs("div",{className:"flex gap-2",children:[c.jsxs(Ce,{size:"sm",onClick:Ae,disabled:Fe||!D.trim()||!j.trim()||!L.trim(),children:[s.isPending?c.jsx(J,{icon:Rt,size:14,strokeWidth:2,className:"mr-2 animate-spin"}):null,t("caldav.connectButton")]}),c.jsx(Ce,{variant:"ghost",size:"sm",onClick:ke,disabled:Fe,children:t("caldav.cancelButton")})]})]})}),c.jsx(Un,{value:"google",children:c.jsxs("div",{className:"space-y-3 pt-2",children:[c.jsxs("div",{className:"space-y-2",children:[c.jsx("label",{className:"block text-xs text-muted-foreground",children:t("caldav.accountName")}),c.jsx(kt,{type:"text",placeholder:t("caldav.googleAccountNamePlaceholder")??"Google Calendar",value:W,onChange:ve=>Y(ve.target.value),className:"max-w-md text-sm"})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsx("label",{className:"block text-xs text-muted-foreground",children:t("caldav.googleClientId")}),c.jsx(kt,{type:"text",placeholder:t("caldav.googleClientIdPlaceholder"),value:G,onChange:ve=>q(ve.target.value),className:"max-w-md font-mono text-sm"})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsx("label",{className:"block text-xs text-muted-foreground",children:t("caldav.googleClientSecret")}),c.jsx(kt,{type:"password",placeholder:t("caldav.googleClientSecretPlaceholder"),value:X,onChange:ve=>z(ve.target.value),className:"max-w-md font-mono text-sm"})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsx("label",{className:"block text-xs text-muted-foreground",children:t("caldav.syncInterval")}),c.jsx(kt,{type:"number",min:1,max:1440,value:Q,onChange:ve=>ee(ve.target.value),className:"w-24 text-sm"})]}),c.jsxs("div",{className:"flex gap-2",children:[c.jsxs(Ce,{size:"sm",onClick:le,disabled:Fe||ne||!G.trim()||!X.trim(),children:[a.isPending||f.isPending||ne?c.jsx(J,{icon:Rt,size:14,strokeWidth:2,className:"mr-2 animate-spin"}):null,t("caldav.connectGoogleButton")]}),c.jsx(Ce,{variant:"ghost",size:"sm",onClick:ke,disabled:Fe,children:t("caldav.cancelButton")})]}),c.jsxs("details",{className:"text-xs text-muted-foreground max-w-lg",children:[c.jsx("summary",{className:"cursor-pointer hover:text-foreground font-medium",children:t("caldav.googleSetupHelp")}),c.jsxs("ol",{className:"mt-2 space-y-1.5 list-none pl-0",children:[c.jsx("li",{children:t("caldav.googleStep1")}),c.jsx("li",{children:t("caldav.googleStep2")}),c.jsx("li",{children:t("caldav.googleStep3")}),c.jsx("li",{children:t("caldav.googleStep4")}),c.jsx("li",{children:t("caldav.googleStep5")}),c.jsx("li",{className:"pl-4 font-mono text-[11px] bg-muted/50 rounded px-2 py-1 w-fit",children:t("caldav.googleCallbackNote",{callbackUrl:`http://${window.location.hostname}:${y.data}/api/caldav/oauth/callback`})}),c.jsx("li",{children:t("caldav.googleStep6")})]})]})]})})]})}),c.jsxs("details",{className:"ml-4 sm:ml-44 text-sm text-muted-foreground",children:[c.jsx("summary",{className:"cursor-pointer hover:text-foreground",children:t("caldav.setupInstructions")}),c.jsxs("div",{className:"mt-2 space-y-2 text-xs",children:[c.jsx("p",{children:t("caldav.helpIntro")}),c.jsxs("ul",{className:"ml-4 list-disc space-y-1",children:[c.jsxs("li",{children:[c.jsx("strong",{children:"Nextcloud:"})," https://cloud.example.com/remote.php/dav"]}),c.jsxs("li",{children:[c.jsx("strong",{children:"Radicale:"})," http://localhost:5232"]}),c.jsxs("li",{children:[c.jsx("strong",{children:"Baikal:"})," https://baikal.example.com/dav.php"]}),c.jsxs("li",{children:[c.jsx("strong",{children:"iCloud:"})," https://caldav.icloud.com (use app-specific password)"]}),c.jsxs("li",{children:[c.jsx("strong",{children:"Google:"})," Use the Google Calendar tab with OAuth2"]})]}),c.jsx("p",{children:t("caldav.helpNote")})]})]})]})}function bAt({clientId:e,onClientIdChange:t,clientIdSaved:n,clientSecret:r,onClientSecretChange:i,clientSecretSaved:s,isLoading:a,onSaveCredentials:o}){const{t:l}=Dt("settings"),{data:u,refetch:d}=a5(),f=HTt(),h=YTt(),m=cOe(),[b,y]=x.useState(!1),[v,_]=x.useState(""),[w,C]=x.useState(!1),[T,k]=x.useState(null),[S,A]=x.useState(""),[R,I]=x.useState(!1),D=x.useRef(null),P=async()=>{if(!v.trim()){rt.error(l("google.nameRequired","Account name is required"));return}try{C(!0);const L=window.open("about:blank","_blank","width=600,height=700");try{await o?.();const M=await h.mutateAsync({accountName:v.trim()});L&&!L.closed?L.location.href=M.authUrl:window.location.href=M.authUrl}catch(M){throw L?.close(),M}D.current=setInterval(async()=>{const M=u?.length??0;await d(),((await d()).data?.length??0)>M&&(clearInterval(D.current),D.current=null,C(!1),y(!1),_(""),rt.success(l("google.accountAdded","Google account connected")))},2e3),setTimeout(()=>{D.current&&(clearInterval(D.current),D.current=null,C(!1))},12e4)}catch(L){C(!1),rt.error(String(L))}},j=async L=>{try{await f.mutateAsync(L),rt.success(l("google.accountDeleted","Google account deleted"))}catch(M){rt.error(String(M))}},B=async L=>{try{await m.mutateAsync({id:L,name:S}),k(null),rt.success(l("common.saved","Saved"))}catch(M){rt.error(String(M))}};return c.jsxs("div",{className:"space-y-4",children:[c.jsxs(pg,{open:R,onOpenChange:I,children:[c.jsxs(mg,{className:"flex items-center gap-1.5 text-xs text-muted-foreground hover:text-foreground transition-colors",children:[c.jsx(J,{icon:R?Do:hu,size:12,strokeWidth:2}),l("google.setupGuideTitle","How to set up Google OAuth credentials")]}),c.jsx(gg,{children:c.jsxs("ol",{className:"mt-2 ml-4 space-y-1.5 text-xs text-muted-foreground list-decimal list-outside",children:[c.jsx("li",{children:c.jsx(oS,{i18nKey:"google.setupGuideStep1",ns:"settings",defaults:"Go to <link>Google Cloud Console</link>",components:{link:c.jsx("a",{href:"https://console.cloud.google.com/",target:"_blank",rel:"noopener noreferrer",className:"text-accent underline underline-offset-2"})}})}),c.jsx("li",{children:l("google.setupGuideStep2","Create a new project (or select an existing one)")}),c.jsx("li",{children:c.jsx(oS,{i18nKey:"google.setupGuideStep3",ns:"settings",defaults:"Enable the <strong>Google Calendar API</strong> and <strong>Gmail API</strong>",components:{strong:c.jsx("strong",{className:"text-foreground"})}})}),c.jsx("li",{children:c.jsx(oS,{i18nKey:"google.setupGuideStep4",ns:"settings",defaults:"Go to <strong>APIs & Services \\u2192 Credentials</strong>",components:{strong:c.jsx("strong",{className:"text-foreground"})}})}),c.jsx("li",{children:c.jsx(oS,{i18nKey:"google.setupGuideStep5",ns:"settings",defaults:"Create an <strong>OAuth 2.0 Client ID</strong> (type: Web application)",components:{strong:c.jsx("strong",{className:"text-foreground"})}})}),c.jsx("li",{children:c.jsx(oS,{i18nKey:"google.setupGuideStep6",ns:"settings",defaults:"Add authorized redirect URI: <code>{{redirectUri}}</code>",values:{redirectUri:`${window.location.origin}/api/google/oauth/callback`},components:{code:c.jsx("code",{className:"bg-muted px-1 py-0.5 rounded text-[10px]"})}})}),c.jsx("li",{children:l("google.setupGuideStep7","Copy the Client ID and Client Secret into the fields below")})]})})]}),c.jsxs("div",{className:"space-y-4",children:[c.jsxs("div",{className:"space-y-1",children:[c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[c.jsx("label",{className:"text-sm text-muted-foreground sm:w-20 sm:shrink-0",children:l("fields.google.clientId","Google ID")}),c.jsx("div",{className:"flex flex-1 items-center gap-2",children:c.jsxs("div",{className:"relative flex-1",children:[c.jsx(kt,{value:e,onChange:L=>t(L.target.value),placeholder:"your-app.apps.googleusercontent.com",disabled:a,className:"flex-1 pr-8 font-mono text-sm"}),n&&c.jsx("div",{className:"absolute right-2 top-1/2 -translate-y-1/2 text-green-500",children:c.jsx(J,{icon:cr,size:14,strokeWidth:2})})]})})]}),c.jsx("p",{className:"text-xs text-muted-foreground sm:ml-20 sm:pl-2",children:l("fields.google.clientIdDescription","OAuth Client ID from Google Cloud Console")})]}),c.jsxs("div",{className:"space-y-1",children:[c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[c.jsx("label",{className:"text-sm text-muted-foreground sm:w-20 sm:shrink-0",children:l("fields.google.clientSecret","Google Secret")}),c.jsx("div",{className:"flex flex-1 items-center gap-2",children:c.jsxs("div",{className:"relative flex-1",children:[c.jsx(kt,{type:"password",value:r,onChange:L=>i(L.target.value),placeholder:l("caldav.googleClientSecretPlaceholder"),disabled:a,className:"flex-1 pr-8 font-mono text-sm"}),s&&c.jsx("div",{className:"absolute right-2 top-1/2 -translate-y-1/2 text-green-500",children:c.jsx(J,{icon:cr,size:14,strokeWidth:2})})]})})]}),c.jsx("p",{className:"text-xs text-muted-foreground sm:ml-20 sm:pl-2",children:l("fields.google.clientSecretDescription","OAuth Client Secret for Google Calendar & Gmail")})]})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("h3",{className:"text-sm font-medium",children:l("google.title","Google Accounts")}),c.jsxs(Ce,{variant:"outline",size:"sm",onClick:()=>y(!b),children:[c.jsx(J,{icon:mu,className:"mr-1 h-3.5 w-3.5"}),l("google.addAccount","Add Google Account")]})]}),b&&c.jsxs("div",{className:"border rounded-lg p-4 space-y-3",children:[c.jsxs("div",{children:[c.jsx("label",{className:"text-xs text-muted-foreground",children:l("google.accountName","Account Name")}),c.jsx(kt,{value:v,onChange:L=>_(L.target.value),placeholder:"My Google Account",className:"mt-1"})]}),c.jsx("p",{className:"text-xs text-muted-foreground",children:l("google.oauthNote","You will be redirected to Google to authorize access to Calendar and Gmail.")}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx(Ce,{onClick:P,disabled:w||!v.trim(),size:"sm",children:w?c.jsxs(c.Fragment,{children:[c.jsx(J,{icon:Rt,className:"mr-1 h-3.5 w-3.5 animate-spin"}),l("google.connecting","Connecting...")]}):l("google.connect","Connect with Google")}),c.jsx(Ce,{variant:"ghost",size:"sm",onClick:()=>{y(!1),_(""),C(!1),D.current&&(clearInterval(D.current),D.current=null)},children:l("common:buttons.cancel","Cancel")})]})]}),(!u||u.length===0)&&!b&&c.jsx("p",{className:"text-sm text-muted-foreground",children:l("google.noAccounts","No Google accounts configured.")}),u?.map(L=>c.jsx("div",{className:"border rounded-lg p-4",children:c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("div",{className:"flex-1",children:T===L.id?c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(kt,{value:S,onChange:M=>A(M.target.value),className:"h-7 text-sm",autoFocus:!0,onKeyDown:M=>{M.key==="Enter"&&B(L.id),M.key==="Escape"&&k(null)}}),c.jsx(Ce,{variant:"ghost",size:"sm",onClick:()=>B(L.id),children:c.jsx(J,{icon:cr,className:"h-3.5 w-3.5"})}),c.jsx(Ce,{variant:"ghost",size:"sm",onClick:()=>k(null),children:c.jsx(J,{icon:jn,className:"h-3.5 w-3.5"})})]}):c.jsxs("div",{className:"cursor-pointer",onClick:()=>{k(L.id),A(L.name)},children:[c.jsx("span",{className:"font-medium text-sm",children:L.name}),L.email&&c.jsx("span",{className:"text-xs text-muted-foreground ml-2",children:L.email})]})}),c.jsx(Ce,{variant:"ghost",size:"sm",onClick:()=>j(L.id),title:l("google.delete","Delete"),children:c.jsx(J,{icon:ma,className:"h-3.5 w-3.5 text-destructive"})})]})},L.id))]})}function yAt(){const{t:e}=Dt("settings"),{data:t}=a5(),n=VTt(),r=WTt(),i=qTt(),s=async(o,l)=>{try{l?(await n.mutateAsync(o),rt.success(e("google.calendarEnabled","Calendar sync enabled"))):(await r.mutateAsync(o),rt.success(e("google.calendarDisabled","Calendar sync disabled")))}catch(u){rt.error(String(u))}},a=async o=>{try{await i.mutateAsync(o),rt.success(e("google.syncComplete","Calendar sync complete"))}catch(l){rt.error(String(l))}};return!t||t.length===0?c.jsxs("div",{className:"space-y-2",children:[c.jsx("h3",{className:"text-sm font-medium",children:e("google.calendarSync","Calendar Sync")}),c.jsxs("p",{className:"text-sm text-muted-foreground",children:[e("google.noAccountsCalendar","No Google accounts connected.")," ",c.jsx(ai,{to:"/settings",search:{tab:void 0},className:"text-accent underline underline-offset-2",children:e("google.addInGeneral","Add one in General settings")})]})]}):c.jsxs("div",{className:"space-y-4",children:[c.jsx("h3",{className:"text-sm font-medium",children:e("google.calendarSync","Calendar Sync")}),t.map(o=>c.jsxs("div",{className:"border rounded-lg p-4 space-y-3",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx("span",{className:"font-medium text-sm",children:o.name}),o.email&&c.jsx("span",{className:"text-xs text-muted-foreground ml-2",children:o.email})]}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(Ce,{variant:"ghost",size:"sm",onClick:()=>a(o.id),disabled:!o.calendarEnabled||i.isPending,title:e("google.sync","Sync"),children:c.jsx(J,{icon:i.isPending?Rt:tp,className:`h-3.5 w-3.5 ${i.isPending?"animate-spin":""}`})}),c.jsx(Dr,{checked:o.calendarEnabled??!1,onCheckedChange:l=>s(o.id,l)})]})]}),o.lastCalendarSyncError&&c.jsx("p",{className:"text-xs text-destructive",children:o.lastCalendarSyncError}),o.lastCalendarSyncAt&&!o.lastCalendarSyncError&&c.jsxs("p",{className:"text-xs text-muted-foreground",children:[e("google.lastSync","Last sync"),":"," ",new Date(o.lastCalendarSyncAt).toLocaleString()]})]},o.id))]})}function vAt({isLoading:e=!1}){const{t}=Dt("settings"),{data:n}=$Z(),{data:r}=dOe(),{data:i}=uAt(),s=cAt(),a=dAt(),o=fAt(),l=hAt(),[u,d]=x.useState(!1),[f,h]=x.useState(""),[m,b]=x.useState(""),[y,v]=x.useState(null);if(!n||n.length<2)return null;const _=new Map((r??[]).map(I=>[I.id,I])),w=new Map;for(const I of n){const D=I.accountId??"unknown";w.has(D)||w.set(D,[]),w.get(D).push(I)}const C=I=>n.find(P=>P.id===I)?.displayName??I,T=async()=>{if(!f||!m){rt.error(t("caldav.copyRulesSelectBoth"));return}if(f===m){rt.error(t("caldav.copyRulesSameCalendar"));return}try{await s.mutateAsync({sourceCalendarId:f,destCalendarId:m}),d(!1),h(""),b(""),rt.success(t("caldav.copyRuleCreated"))}catch(I){rt.error(I instanceof Error?I.message:t("caldav.copyRuleCreateFailed"))}},k=async(I,D)=>{try{await a.mutateAsync({id:I,enabled:D})}catch(P){rt.error(P instanceof Error?P.message:t("caldav.copyRuleUpdateFailed"))}},S=async I=>{try{await o.mutateAsync(I),rt.success(t("caldav.copyRuleDeleted"))}catch(D){rt.error(D instanceof Error?D.message:t("caldav.copyRuleDeleteFailed"))}},A=async I=>{v(I);try{const D=await l.mutateAsync(I);rt.success(t("caldav.copyRuleExecuted",{created:D.created,updated:D.updated}))}catch(D){rt.error(D instanceof Error?D.message:t("caldav.copyRuleExecuteFailed"))}finally{v(null)}},R=(I,D,P)=>c.jsxs("select",{id:P,value:I,onChange:j=>D(j.target.value),className:"h-9 rounded-md border border-input bg-background px-3 py-1 text-sm shadow-sm focus:outline-none focus:ring-1 focus:ring-ring",children:[c.jsx("option",{value:"",children:t("caldav.copyRulesSelectCalendar")}),Array.from(w.entries()).map(([j,B])=>{const M=_.get(j)?.name??j;return c.jsx("optgroup",{label:M,children:B.map($=>c.jsx("option",{value:$.id,children:$.displayName??$.id},$.id))},j)})]});return c.jsxs("div",{className:"space-y-4",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("h3",{className:"text-sm font-medium",children:t("caldav.copyRules")}),!u&&c.jsxs(Ce,{variant:"outline",size:"sm",onClick:()=>d(!0),disabled:e,children:[c.jsx(J,{icon:mu,size:14,strokeWidth:2,className:"mr-1.5"}),t("caldav.addRule")]})]}),u&&c.jsxs("div",{className:"rounded-md border border-border p-3 space-y-3",children:[c.jsxs("div",{className:"flex flex-wrap items-end gap-3",children:[c.jsxs("div",{className:"space-y-1",children:[c.jsx("label",{htmlFor:"source-calendar",className:"text-xs text-muted-foreground",children:t("caldav.copyRulesSource")}),R(f,h,"source-calendar")]}),c.jsx("span",{className:"pb-2 text-sm text-muted-foreground",children:"→"}),c.jsxs("div",{className:"space-y-1",children:[c.jsx("label",{htmlFor:"dest-calendar",className:"text-xs text-muted-foreground",children:t("caldav.copyRulesDest")}),R(m,b,"dest-calendar")]})]}),c.jsxs("div",{className:"flex gap-2",children:[c.jsxs(Ce,{size:"sm",onClick:T,disabled:s.isPending||!f||!m,children:[s.isPending&&c.jsx(J,{icon:Rt,size:14,strokeWidth:2,className:"mr-1.5 animate-spin"}),t("caldav.addRule")]}),c.jsx(Ce,{variant:"ghost",size:"sm",onClick:()=>{d(!1),h(""),b("")},disabled:s.isPending,children:t("caldav.cancelButton")})]})]}),i&&i.length>0?c.jsx("div",{className:"space-y-2",children:i.map(I=>{const D=y===I.id;return c.jsxs("div",{className:"flex items-center gap-3 rounded-md border border-border px-3 py-2",children:[c.jsx(Dr,{checked:I.enabled!==!1,onCheckedChange:P=>k(I.id,P),disabled:a.isPending}),c.jsxs("div",{className:"flex-1 min-w-0",children:[c.jsxs("span",{className:"text-sm",children:[C(I.sourceCalendarId),c.jsx("span",{className:"mx-1.5 text-muted-foreground",children:"→"}),C(I.destCalendarId)]}),I.lastExecutedAt&&c.jsx("p",{className:"text-xs text-muted-foreground",children:t("caldav.copyRulesLastRun",{time:new Date(I.lastExecutedAt).toLocaleString()})})]}),c.jsx(Ce,{variant:"outline",size:"sm",onClick:()=>A(I.id),disabled:D||e,title:t("caldav.copyRulesRunNow"),children:D?c.jsx(J,{icon:Rt,size:14,strokeWidth:2,className:"animate-spin"}):c.jsx(J,{icon:Q0,size:14,strokeWidth:2})}),c.jsx(Ce,{variant:"ghost",size:"sm",onClick:()=>S(I.id),disabled:o.isPending||e,title:t("caldav.copyRulesDelete"),children:c.jsx(J,{icon:ma,size:14,strokeWidth:2,className:"text-destructive"})})]},I.id)})}):c.jsx("p",{className:"text-xs text-muted-foreground",children:t("caldav.copyRulesEmpty")})]})}const xAt=["general","ai","messaging","calendar"],zU=js("/settings/")({component:_At,validateSearch:e=>({tab:xAt.includes(e.tab)?e.tab:void 0})});function yl({title:e,children:t}){return c.jsxs("div",{className:"film-grain relative rounded-lg border border-border p-4 pt-6",style:{background:"var(--gradient-card)"},children:[c.jsx("span",{className:"absolute -top-2.5 left-3 rounded bg-card px-2 text-xs font-medium text-muted-foreground",children:e}),t]})}function _At(){const{t:e}=Dt("settings"),{t}=Dt("common"),{tab:n}=zU.useSearch(),r=zU.useNavigate(),i=n||"general",s=Be=>{const Pt=Be;r({search:bs=>({...bs,tab:Pt==="general"?void 0:Pt}),replace:!0})},{data:a,isLoading:o}=nW(),{data:l,isLoading:u}=q3(),{data:d,isLoading:f}=G3(),{data:h,isLoading:m}=K3(),{data:b,isLoading:y}=Y3(),{data:v,isLoading:_}=GVe(),{data:w}=KVe(),{data:C}=YVe(),{data:T,isLoading:k}=p2(),{data:S,isLoading:A}=x1(),{data:R,isLoading:I}=DSe(),{data:D,isLoading:P}=PSe(),{data:j,isLoading:B}=jSe(),{data:L}=XVe(),{data:M,isLoading:$}=dWe(),{data:U,isLoading:W}=pWe(),{data:Y,isLoading:G}=rCe(),q=AQe(),{data:X}=gWe(),z=bWe(),{savedLanguage:Q,changeLanguage:ee}=sCe(),{theme:ne,syncClaudeCode:ae,changeTheme:fe}=dCe(),{data:re}=JVe(),{data:de}=eWe(),{data:he,isLoading:ce}=LSe(),{data:ye,isLoading:be}=MSe(),{data:ue,isLoading:Ae}=X3(),{data:le,isLoading:ke}=FSe(),{data:Fe,isLoading:ze}=BSe(),{data:ve,isLoading:je}=tWe(),{data:we}=nWe(),{data:Le}=rWe(),{data:qe,isLoading:Re}=iWe(),{data:Ie,isLoading:se}=sWe(),{data:Ge,isLoading:ut}=aWe(),{data:mt,isLoading:Ke}=oWe(),{data:lt,isLoading:Ve}=lWe(),{data:Ct,isLoading:Ne}=uWe(),{installed:Ue}=eD(),{version:st}=yWe(),{data:et,isLoading:pt}=xWe(),wt=_We(),Et=SWe(),Se=rW(),Oe=cWe(),Qe=fWe(),It=mWe(),_t=hWe(),an=(a5().data??[]).filter(Be=>Be.gmailEnabled),vn=At(),[zt,sn]=x.useState(""),[Ln,vr]=x.useState(""),[Mr,oi]=x.useState("vscode"),[gs,xi]=x.useState(""),[dr,fr]=x.useState(""),[Fi,Ai]=x.useState(""),[Ki,vo]=x.useState(""),[Yi,tt]=x.useState(""),[Mn,An]=x.useState("claude"),[Fr,ss]=x.useState(null),[li,kr]=x.useState("build"),[ei,hr]=x.useState("plan"),[Br,Xi]=x.useState(!0),[Fo,Gt]=x.useState(""),[it,Wt]=x.useState(!1),[Xn,Bi]=x.useState(!1),[In,As]=x.useState(!0),[wu,Ya]=x.useState(!0),[Sa,Eu]=x.useState(!0),[$i,Ns]=x.useState(!1),[as,Lc]=x.useState(!1),[Mc,Td]=x.useState(""),[Xa,Uf]=x.useState(!1),[Vt,dn]=x.useState(""),[On,$r]=x.useState(!1),[Rr,_n]=x.useState(""),[xo,Bo]=x.useState(""),[wa,Za]=x.useState(!1),[Cu,yp]=x.useState(!1),[ul,N]=x.useState(!1),[H,te]=x.useState(""),[oe,_e]=x.useState(!1),[He,Xe]=x.useState(!1),[Tt,Lt]=x.useState(!1),[Cn,Fn]=x.useState(""),[Ur,Zi]=x.useState("glm-4.5-air"),[cl,ku]=x.useState("glm-4.7"),[os,Qa]=x.useState("glm-4.7"),[Ea,vp]=x.useState(""),[xp,Qy]=x.useState(""),[zf,_p]=x.useState(!1),[Hf,d_]=x.useState("light-ansi"),[Jy,mk]=x.useState("dark-ansi"),[ev,tv]=x.useState("worktree"),[nv,gk]=x.useState(!0),[f_,bk]=x.useState(null),[Ad,h_]=x.useState("claude"),[rv,yk]=x.useState("sonnet"),[iv,vk]=x.useState("haiku"),[Tu,xk]=x.useState(null),[sv,_k]=x.useState(null),[kg,Sk]=x.useState("~/.fulcrum/documents"),[Tg,wk]=x.useState(!1),[av,Ek]=x.useState("09:00"),[ov,Ck]=x.useState(""),[lv,kk]=x.useState("18:00"),[Sp,wp]=x.useState(""),[p_,uv]=x.useState(!1),[m_,cv]=x.useState(!1),[g_,b_]=x.useState(!1),Fc=x.useRef(null);x.useEffect(()=>{a!==void 0&&sn(String(a)),l!==void 0&&vr(l),d!==void 0&&oi(d),h!==void 0&&xi(h),b!==void 0&&fr(String(b)),v!==void 0&&Ai(v),w!==void 0&&vo(w),C!==void 0&&tt(C),T!==void 0&&An(T),S!==void 0&&ss(S),R!==void 0&&kr(R),D!==void 0&&hr(D),j!==void 0&&Xi(j),L!==void 0&&Gt(L??"")},[a,l,d,h,b,v,w,C,T,S,R,D,j,L]),x.useEffect(()=>{M&&(As(M.enabled),Ya(M.toast?.enabled??!0),Eu(M.desktop?.enabled??!0),Ns(M.sound?.enabled??!1),cv(!!M.sound?.customSoundFile),Lc(M.slack?.enabled??!1),Td(M.slack?.webhookUrl??""),Uf(M.discord?.enabled??!1),dn(M.discord?.webhookUrl??""),$r(M.pushover?.enabled??!1),_n(M.pushover?.appToken??""),Bo(M.pushover?.userKey??""),Za(M.whatsapp?.enabled??!1),yp(M.telegram?.enabled??!1),N(M.gmail?.enabled??!1),te(M.gmail?.googleAccountId??""),_e(M.slack?.useMessagingChannel??!1),Xe(M.discord?.useMessagingChannel??!1))},[M]),x.useEffect(()=>{U&&(Lt(U.enabled),Fn(U.apiKey??""),Zi(U.haikuModel),ku(U.sonnetModel),Qa(U.opusModel))},[U]),x.useEffect(()=>{Y?.cloudflareApiToken!==void 0&&vp(Y.cloudflareApiToken??""),Y?.cloudflareAccountId!==void 0&&Qy(Y.cloudflareAccountId??"")},[Y]),x.useEffect(()=>{ae!==void 0&&_p(ae),re!==void 0&&d_(re),de!==void 0&&mk(de)},[ae,re,de]),x.useEffect(()=>{he!==void 0&&tv(he),ye!==void 0&&gk(ye)},[he,ye]),x.useEffect(()=>{ue!==void 0&&bk(ue)},[ue]),x.useEffect(()=>{le!==void 0&&h_(le),Fe!==void 0&&yk(Fe),ve!==void 0&&vk(ve),we!==void 0&&xk(we),Le!==void 0&&_k(Le),qe!==void 0&&Sk(qe)},[le,Fe,ve,we,Le,qe]),x.useEffect(()=>{Ie!==void 0&&wk(Ie),Ge!==void 0&&Ek(Ge),mt!==void 0&&Ck(mt),lt!==void 0&&kk(lt),Ct!==void 0&&wp(Ct)},[Ie,Ge,mt,lt,Ct]);const en=o||u||f||m||y||_||k||A||I||P||B||$||W||G||ce||be||Ae||ke||ze||je||Re||se||ut||Ke||Ve||Ne,Tk=U&&(Tt!==U.enabled||Cn!==(U.apiKey??"")||Ur!==U.haikuModel||cl!==U.sonnetModel||os!==U.opusModel),Ak=zf!==(ae??!1)||Hf!==re||Jy!==de,y_=ev!==he||nv!==ye,v_=f_!==ue,Ep=Ad!==le||rv!==Fe||iv!==ve||Tu!==we||sv!==Le||kg!==qe,Cp=Tg!==Ie||av!==Ge||ov!==mt||lv!==lt||Sp!==Ct,Nk=(()=>{const Be=Y?.cloudflareApiToken??"",Pt=Y?.cloudflareAccountId??"",bs=Ea!==Be&&!Ea.match(/^•+$/),Ca=xp!==Pt&&!xp.match(/^•+$/);return bs||Ca})(),Ag=M&&(In!==M.enabled||wu!==(M.toast?.enabled??!0)||Sa!==(M.desktop?.enabled??!0)||$i!==(M.sound?.enabled??!1)||as!==(M.slack?.enabled??!1)||Mc!==(M.slack?.webhookUrl??"")||oe!==(M.slack?.useMessagingChannel??!1)||Xa!==(M.discord?.enabled??!1)||Vt!==(M.discord?.webhookUrl??"")||He!==(M.discord?.useMessagingChannel??!1)||On!==(M.pushover?.enabled??!1)||Rr!==(M.pushover?.appToken??"")||xo!==(M.pushover?.userKey??"")||wa!==(M.whatsapp?.enabled??!1)||Cu!==(M.telegram?.enabled??!1)||ul!==(M.gmail?.enabled??!1)||H!==(M.gmail?.googleAccountId??"")),Ok=Mr!==d||gs!==h||dr!==String(b),Rk=Mn!==T||Fr!==(S??null)||li!==R||ei!==D||Br!==j||Fo!==(L??""),x_=zt!==String(a)||Ln!==l||Fi!==v||Ki!==w||Yi!==C||Rk||Ok||Ag||Tk||Ak||Nk||y_||v_||Ep||Cp,__=async()=>{const Be=[];Ki!==w&&Be.push(Se.mutateAsync({key:qt.GOOGLE_CLIENT_ID,value:Ki||null})),Yi!==C&&Be.push(Se.mutateAsync({key:qt.GOOGLE_CLIENT_SECRET,value:Yi||null})),Be.length>0&&await Promise.all(Be)},Ik=async()=>{const Be=[];if(zt!==String(a)){const Pt=parseInt(zt,10);!isNaN(Pt)&&Pt>=1&&Pt<=65535&&Be.push(new Promise(bs=>{Se.mutate({key:qt.PORT,value:Pt},{onSettled:bs})}))}if(Ln!==l&&Be.push(new Promise(Pt=>{Se.mutate({key:qt.DEFAULT_GIT_REPOS_DIR,value:Ln},{onSettled:Pt})})),Mr!==d&&Be.push(new Promise(Pt=>{Se.mutate({key:qt.EDITOR_APP,value:Mr},{onSettled:Pt})})),gs!==h&&Be.push(new Promise(Pt=>{Se.mutate({key:qt.EDITOR_HOST,value:gs},{onSettled:Pt})})),dr!==String(b)){const Pt=parseInt(dr,10);!isNaN(Pt)&&Pt>=1&&Pt<=65535&&Be.push(new Promise(bs=>{Se.mutate({key:qt.EDITOR_SSH_PORT,value:Pt},{onSettled:bs})}))}if(Fi!==v&&Be.push(new Promise(Pt=>{Se.mutate({key:qt.GITHUB_PAT,value:Fi},{onSettled:Pt})})),Ki!==w&&Be.push(new Promise(Pt=>{Se.mutate({key:qt.GOOGLE_CLIENT_ID,value:Ki||null},{onSettled:Pt})})),Yi!==C&&Be.push(new Promise(Pt=>{Se.mutate({key:qt.GOOGLE_CLIENT_SECRET,value:Yi||null},{onSettled:Pt})})),Mn!==T&&Be.push(new Promise(Pt=>{Se.mutate({key:qt.DEFAULT_AGENT,value:Mn},{onSettled:Pt})})),Fr!==(S??null)&&Be.push(new Promise(Pt=>{Se.mutate({key:qt.OPENCODE_MODEL,value:Fr},{onSettled:Pt})})),li!==R&&Be.push(new Promise(Pt=>{Se.mutate({key:qt.OPENCODE_DEFAULT_AGENT,value:li},{onSettled:Pt})})),ei!==D&&Be.push(new Promise(Pt=>{Se.mutate({key:qt.OPENCODE_PLAN_AGENT,value:ei},{onSettled:Pt})})),Br!==j&&Be.push(new Promise(Pt=>{Se.mutate({key:qt.AGENT_AUTO_SCROLL_TO_BOTTOM,value:Br},{onSettled:Pt})})),Fo!==(L??"")&&Be.push(new Promise(Pt=>{Se.mutate({key:qt.CLAUDE_CODE_PATH,value:Fo||null},{onSettled:Pt})})),Ag&&Be.push(new Promise(Pt=>{Qe.mutate({enabled:In,toast:{enabled:wu},desktop:{enabled:Sa},sound:{enabled:$i},slack:{enabled:as,webhookUrl:Mc,useMessagingChannel:oe},discord:{enabled:Xa,webhookUrl:Vt,useMessagingChannel:He},pushover:{enabled:On,appToken:Rr,userKey:xo},whatsapp:{enabled:wa},telegram:{enabled:Cu},gmail:{enabled:ul,googleAccountId:H||void 0},_updatedAt:M?._updatedAt},{onSettled:Pt,onError:bs=>{bs instanceof $Se&&(rt.warning(e("notifications.conflictWarning")||"Settings changed elsewhere - refreshing"),vn.invalidateQueries({queryKey:["config","notifications"]}))}})})),Tk&&Be.push(new Promise(Pt=>{It.mutate({enabled:Tt,apiKey:Cn||null,haikuModel:Ur,sonnetModel:cl,opusModel:os},{onSettled:Pt})})),Ak&&(zf!==(ae??!1)&&Be.push(new Promise(Pt=>{Se.mutate({key:qt.SYNC_CLAUDE_CODE_THEME,value:zf},{onSettled:Pt})})),Hf!==re&&Be.push(new Promise(Pt=>{Se.mutate({key:qt.CLAUDE_CODE_LIGHT_THEME,value:Hf},{onSettled:Pt})})),Jy!==de&&Be.push(new Promise(Pt=>{Se.mutate({key:qt.CLAUDE_CODE_DARK_THEME,value:Jy},{onSettled:Pt})}))),y_&&(ev!==he&&Be.push(new Promise(Pt=>{Se.mutate({key:qt.DEFAULT_TASK_TYPE,value:ev},{onSettled:Pt})})),nv!==ye&&Be.push(new Promise(Pt=>{Se.mutate({key:qt.START_WORKTREE_TASKS_IMMEDIATELY,value:nv},{onSettled:Pt})}))),v_&&Be.push(new Promise(Pt=>{Se.mutate({key:qt.TIMEZONE,value:f_},{onSettled:Pt})})),Ep&&(Ad!==le&&Be.push(new Promise(Pt=>{Se.mutate({key:qt.ASSISTANT_PROVIDER,value:Ad},{onSettled:Pt})})),rv!==Fe&&Be.push(new Promise(Pt=>{Se.mutate({key:qt.ASSISTANT_MODEL,value:rv},{onSettled:Pt})})),iv!==ve&&Be.push(new Promise(Pt=>{Se.mutate({key:qt.ASSISTANT_OBSERVER_MODEL,value:iv},{onSettled:Pt})})),Tu!==we&&Be.push(new Promise(Pt=>{Se.mutate({key:qt.ASSISTANT_OBSERVER_PROVIDER,value:Tu},{onSettled:Pt})})),sv!==Le&&Be.push(new Promise(Pt=>{Se.mutate({key:qt.ASSISTANT_OBSERVER_OPENCODE_MODEL,value:sv},{onSettled:Pt})})),kg!==qe&&Be.push(new Promise(Pt=>{Se.mutate({key:qt.ASSISTANT_DOCUMENTS_DIR,value:kg},{onSettled:Pt})}))),Cp&&(Tg!==Ie&&Be.push(new Promise(Pt=>{Se.mutate({key:qt.ASSISTANT_RITUALS_ENABLED,value:Tg},{onSettled:Pt})})),av!==Ge&&Be.push(new Promise(Pt=>{Se.mutate({key:qt.ASSISTANT_MORNING_RITUAL_TIME,value:av},{onSettled:Pt})})),ov!==mt&&Be.push(new Promise(Pt=>{Se.mutate({key:qt.ASSISTANT_MORNING_RITUAL_PROMPT,value:ov},{onSettled:Pt})})),lv!==lt&&Be.push(new Promise(Pt=>{Se.mutate({key:qt.ASSISTANT_EVENING_RITUAL_TIME,value:lv},{onSettled:Pt})})),Sp!==Ct&&Be.push(new Promise(Pt=>{Se.mutate({key:qt.ASSISTANT_EVENING_RITUAL_PROMPT,value:Sp},{onSettled:Pt})}))),Nk){const Pt=Y?.cloudflareApiToken??"",bs=Y?.cloudflareAccountId??"",Ca={};Ea!==Pt&&!Ea.match(/^•+$/)&&(Ca.cloudflareApiToken=Ea||null),xp!==bs&&!xp.match(/^•+$/)&&(Ca.cloudflareAccountId=xp||null),Object.keys(Ca).length>0&&Be.push(new Promise(Au=>{q.mutate(Ca,{onSettled:Au})}))}await Promise.all(Be),Bi(!0),setTimeout(()=>Bi(!1),2e3)},Dk=()=>{Oe.mutate(qt.PORT,{onSuccess:Be=>{Be.value!==null&&sn(String(Be.value))}})},Pk=()=>{Oe.mutate(qt.DEFAULT_GIT_REPOS_DIR,{onSuccess:Be=>{Be.value&&vr(String(Be.value))}})},iP=()=>{Oe.mutate(qt.EDITOR_APP,{onSuccess:Be=>{Be.value!==null&&Be.value!==void 0&&oi(Be.value)}})},sP=()=>{Oe.mutate(qt.EDITOR_HOST,{onSuccess:Be=>{xi(Be.value!==null&&Be.value!==void 0?String(Be.value):"")}})},aP=()=>{Oe.mutate(qt.EDITOR_SSH_PORT,{onSuccess:Be=>{Be.value!==null&&Be.value!==void 0&&fr(String(Be.value))}})},oP=()=>{Oe.mutate(qt.GITHUB_PAT,{onSuccess:Be=>{Ai(Be.value!==null&&Be.value!==void 0?String(Be.value):"")}})},lP=()=>{Oe.mutate(qt.DEFAULT_AGENT,{onSuccess:Be=>{An(Be.value??"claude")}})},$o=()=>{Oe.mutate(qt.OPENCODE_MODEL,{onSuccess:Be=>{ss(Be.value!==null&&Be.value!==void 0?String(Be.value):null)}})},Ng=()=>{Oe.mutate(qt.OPENCODE_DEFAULT_AGENT,{onSuccess:Be=>{kr(Be.value??"build")}})},jk=()=>{Oe.mutate(qt.OPENCODE_PLAN_AGENT,{onSuccess:Be=>{hr(Be.value??"plan")}})},Nd=async Be=>{_t.mutate(Be,{onSuccess:Pt=>{Pt.success?rt.success(e("notifications.testSuccess",{channel:Be})):rt.error(e("notifications.testFailed",{channel:Be,error:Pt.error}))},onError:Pt=>{rt.error(e("notifications.testFailed",{channel:Be,error:Pt.message}))}})},Lk=async Be=>{const Pt=Be.target.files?.[0];if(Pt){b_(!0);try{const bs=new FormData;bs.append("file",Pt);const Ca=await fetch("/api/uploads/sound",{method:"POST",body:bs});if(!Ca.ok){const Au=await Ca.json();throw new Error(Au.error||"Upload failed")}cv(!0),rt.success(e("notifications.soundUploaded"))}catch(bs){rt.error(e("notifications.soundUploadFailed",{error:bs instanceof Error?bs.message:"Unknown error"}))}finally{b_(!1),Fc.current&&(Fc.current.value="")}}},Mk=async()=>{try{if(!(await fetch("/api/uploads/sound",{method:"DELETE"})).ok)throw new Error("Delete failed");cv(!1),rt.success(e("notifications.soundDeleted"))}catch{rt.error(e("notifications.soundDeleteFailed"))}},S_=()=>{Et.mutate(void 0,{onSuccess:()=>{rt.info(e("version.updateStarted"))},onError:()=>{rt.error(e("version.updateFailed"))}})};return c.jsxs("div",{className:"flex h-full flex-col",children:[c.jsx("div",{className:"flex-1 overflow-hidden",children:c.jsxs(Jo,{value:i,onValueChange:s,className:"flex h-full flex-col",children:[c.jsxs("div",{className:"film-grain relative flex shrink-0 items-center border-b border-border px-4",style:{background:"var(--gradient-header)"},children:[c.jsxs(el,{className:"justify-start gap-1 bg-transparent rounded-none h-10",children:[c.jsxs(Bn,{value:"general",className:"gap-1.5 data-[state=active]:bg-muted",children:[c.jsx(J,{icon:AO,size:14,strokeWidth:2}),c.jsx("span",{className:"max-sm:hidden",children:e("tabs.general")})]}),c.jsxs(Bn,{value:"ai",className:"gap-1.5 data-[state=active]:bg-muted",children:[c.jsx(J,{icon:L1e,size:14,strokeWidth:2}),c.jsx("span",{className:"max-sm:hidden",children:e("tabs.ai")})]}),c.jsxs(Bn,{value:"messaging",className:"gap-1.5 data-[state=active]:bg-muted",children:[c.jsx(J,{icon:M3,size:14,strokeWidth:2}),c.jsx("span",{className:"max-sm:hidden",children:e("tabs.messaging")})]}),c.jsxs(Bn,{value:"calendar",className:"gap-1.5 data-[state=active]:bg-muted",children:[c.jsx(J,{icon:ng,size:14,strokeWidth:2}),c.jsx("span",{className:"max-sm:hidden",children:e("tabs.calendar")})]})]}),c.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[st&&c.jsxs("span",{className:"text-xs font-mono text-muted-foreground",children:["v",st]}),c.jsx(Ce,{variant:"ghost",size:"icon",className:"h-6 w-6 text-muted-foreground hover:text-foreground",onClick:()=>wt.mutate(),disabled:pt||wt.isPending,title:e("version.refresh"),"aria-label":e("version.refresh"),children:c.jsx(J,{icon:tp,size:14,strokeWidth:2,className:wt.isPending?"animate-spin":""})}),pt&&c.jsxs("div",{className:"flex h-6 items-center gap-1.5 rounded-full bg-muted/50 px-2.5 text-xs text-muted-foreground",children:[c.jsx(J,{icon:Rt,size:12,strokeWidth:2,className:"animate-spin"}),c.jsx("span",{children:e("version.checkingForUpdates")})]}),et?.updateAvailable&&et.latestVersion&&c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsxs("span",{className:"flex h-6 items-center gap-1.5 rounded-full bg-primary/10 px-2.5 text-xs font-medium text-primary border border-primary/20",children:[c.jsx(J,{icon:Oie,size:12,strokeWidth:2.5}),e("version.updateAvailable",{version:et.latestVersion})]}),c.jsx(Ce,{size:"sm",className:"h-6 gap-1.5 px-2.5 text-xs",disabled:Et.isPending||Et.isSuccess,onClick:S_,children:Et.isPending?c.jsxs(c.Fragment,{children:[c.jsx(J,{icon:Rt,size:12,strokeWidth:2,className:"animate-spin"}),e("version.updating")]}):c.jsxs(c.Fragment,{children:[c.jsx(J,{icon:Oie,size:12,strokeWidth:2}),e("version.update")]})}),c.jsx(Ce,{variant:"outline",size:"sm",className:"h-6 gap-1.5 px-2.5 text-xs",onClick:()=>{et.releaseUrl&&window.open(et.releaseUrl,"_blank")},children:e("version.viewRelease")})]}),!pt&&et&&!et.updateAvailable&&c.jsxs("span",{className:"flex h-6 items-center gap-1.5 rounded-full bg-green-500/10 px-2.5 text-xs font-medium text-green-600 dark:text-green-400 border border-green-500/20",children:[c.jsx(J,{icon:cr,size:12,strokeWidth:2.5}),e("version.upToDate")]})]})]}),c.jsx(Un,{value:"general",className:"flex-1 overflow-auto p-6",children:c.jsxs("div",{className:"mx-auto max-w-5xl space-y-4",children:[c.jsx(yl,{title:e("sections.appearance"),children:c.jsxs("div",{className:"space-y-4",children:[c.jsxs("div",{className:"space-y-1",children:[c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[c.jsx("label",{className:"text-sm text-muted-foreground sm:w-32 sm:shrink-0",children:e("fields.language.label")}),c.jsxs(Vr,{value:Q??"auto",onValueChange:Be=>ee(Be==="auto"?null:Be),children:[c.jsx(qr,{className:"w-40",children:c.jsx(Wr,{})}),c.jsxs(Gr,{children:[c.jsx(Kt,{value:"auto",children:e("fields.language.options.auto")}),c.jsx(Kt,{value:"en",children:e("fields.language.options.en")}),c.jsx(Kt,{value:"zh",children:e("fields.language.options.zh")})]})]})]}),c.jsx("p",{className:"text-xs text-muted-foreground sm:ml-32 sm:pl-2",children:e("fields.language.description")})]}),c.jsxs("div",{className:"space-y-1",children:[c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[c.jsx("label",{className:"text-sm text-muted-foreground sm:w-32 sm:shrink-0",children:e("fields.theme.label")}),c.jsxs(Vr,{value:ne??"system",onValueChange:Be=>fe(Be),children:[c.jsx(qr,{className:"w-40",children:c.jsx(Wr,{})}),c.jsxs(Gr,{children:[c.jsx(Kt,{value:"system",children:e("fields.theme.options.system")}),c.jsx(Kt,{value:"light",children:e("fields.theme.options.light")}),c.jsx(Kt,{value:"dark",children:e("fields.theme.options.dark")})]})]})]}),c.jsx("p",{className:"text-xs text-muted-foreground sm:ml-32 sm:pl-2",children:e("fields.theme.description")})]}),c.jsxs("div",{className:"space-y-1",children:[c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[c.jsx("label",{className:"text-sm text-muted-foreground sm:w-32 sm:shrink-0",children:e("fields.timezone.label")}),c.jsxs(Vr,{value:f_??"auto",onValueChange:Be=>bk(Be==="auto"?null:Be),children:[c.jsx(qr,{className:"w-56",children:c.jsx(Wr,{})}),c.jsxs(Gr,{children:[c.jsx(Kt,{value:"auto",children:e("fields.timezone.options.auto")}),c.jsx(Kt,{value:"America/New_York",children:"America/New_York (EST/EDT)"}),c.jsx(Kt,{value:"America/Chicago",children:"America/Chicago (CST/CDT)"}),c.jsx(Kt,{value:"America/Denver",children:"America/Denver (MST/MDT)"}),c.jsx(Kt,{value:"America/Los_Angeles",children:"America/Los_Angeles (PST/PDT)"}),c.jsx(Kt,{value:"America/Anchorage",children:"America/Anchorage (AKST/AKDT)"}),c.jsx(Kt,{value:"Pacific/Honolulu",children:"Pacific/Honolulu (HST)"}),c.jsx(Kt,{value:"Europe/London",children:"Europe/London (GMT/BST)"}),c.jsx(Kt,{value:"Europe/Paris",children:"Europe/Paris (CET/CEST)"}),c.jsx(Kt,{value:"Europe/Berlin",children:"Europe/Berlin (CET/CEST)"}),c.jsx(Kt,{value:"Asia/Tokyo",children:"Asia/Tokyo (JST)"}),c.jsx(Kt,{value:"Asia/Shanghai",children:"Asia/Shanghai (CST)"}),c.jsx(Kt,{value:"Asia/Singapore",children:"Asia/Singapore (SGT)"}),c.jsx(Kt,{value:"Australia/Sydney",children:"Australia/Sydney (AEST/AEDT)"}),c.jsx(Kt,{value:"Pacific/Auckland",children:"Pacific/Auckland (NZST/NZDT)"}),c.jsx(Kt,{value:"UTC",children:"UTC"})]})]})]}),c.jsx("p",{className:"text-xs text-muted-foreground sm:ml-32 sm:pl-2",children:e("fields.timezone.description")})]}),c.jsxs("div",{className:"space-y-1",children:[c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[c.jsx("label",{className:"text-sm text-muted-foreground sm:w-32 sm:shrink-0",children:e("fields.syncClaudeTheme.label")}),c.jsx(Dr,{checked:zf,onCheckedChange:_p})]}),c.jsx("p",{className:"text-xs text-muted-foreground sm:ml-32 sm:pl-2",children:e("fields.syncClaudeTheme.description")})]}),zf&&c.jsxs("div",{className:"space-y-3 border-t border-border pt-4 sm:ml-32 sm:pl-2",children:[c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[c.jsx("label",{className:"text-sm text-muted-foreground sm:w-24 sm:shrink-0",children:e("fields.claudeCodeTheme.light")}),c.jsxs(Vr,{value:Hf,onValueChange:Be=>d_(Be),children:[c.jsx(qr,{className:"w-40",children:c.jsx(Wr,{})}),c.jsx(Gr,{children:Zie.filter(Be=>Be.startsWith("light")).map(Be=>c.jsx(Kt,{value:Be,children:e(`fields.claudeCodeTheme.options.${Be}`)},Be))})]})]}),c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[c.jsx("label",{className:"text-sm text-muted-foreground sm:w-24 sm:shrink-0",children:e("fields.claudeCodeTheme.dark")}),c.jsxs(Vr,{value:Jy,onValueChange:Be=>mk(Be),children:[c.jsx(qr,{className:"w-40",children:c.jsx(Wr,{})}),c.jsx(Gr,{children:Zie.filter(Be=>Be.startsWith("dark")).map(Be=>c.jsx(Kt,{value:Be,children:e(`fields.claudeCodeTheme.options.${Be}`)},Be))})]})]})]})]})}),c.jsxs("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-2",children:[c.jsx(yl,{title:e("sections.editor"),children:c.jsxs("div",{className:"space-y-4",children:[c.jsxs("div",{className:"space-y-1",children:[c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[c.jsx("label",{className:"text-sm text-muted-foreground sm:w-20 sm:shrink-0",children:e("fields.editor.app.label")}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsxs(Vr,{value:Mr,onValueChange:Be=>oi(Be),children:[c.jsx(qr,{className:"w-32",children:c.jsx(Wr,{})}),c.jsxs(Gr,{children:[c.jsx(Kt,{value:"vscode",children:"VS Code"}),c.jsx(Kt,{value:"cursor",children:"Cursor"}),c.jsx(Kt,{value:"windsurf",children:"Windsurf"}),c.jsx(Kt,{value:"zed",children:"Zed"}),c.jsx(Kt,{value:"antigravity",children:"Antigravity"})]})]}),c.jsx(Ce,{variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-foreground",onClick:iP,disabled:en||Oe.isPending,title:t("buttons.reset"),children:c.jsx(J,{icon:Pd,size:14,strokeWidth:2})})]})]}),c.jsx("p",{className:"text-xs text-muted-foreground sm:ml-20 sm:pl-2",children:e("fields.editor.app.description")})]}),c.jsxs("div",{className:"space-y-1",children:[c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[c.jsx("label",{className:"text-sm text-muted-foreground sm:w-20 sm:shrink-0",children:e("fields.editor.host.label")}),c.jsxs("div",{className:"flex flex-1 items-center gap-2",children:[c.jsx(kt,{value:gs,onChange:Be=>xi(Be.target.value),placeholder:e("fields.editor.host.placeholder"),disabled:en,className:"flex-1 font-mono text-sm"}),c.jsx(Ce,{variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-foreground",onClick:sP,disabled:en||Oe.isPending,title:t("buttons.reset"),children:c.jsx(J,{icon:Pd,size:14,strokeWidth:2})})]})]}),c.jsx("p",{className:"text-xs text-muted-foreground sm:ml-20 sm:pl-2",children:e("fields.editor.host.description")})]}),c.jsxs("div",{className:"space-y-1",children:[c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[c.jsx("label",{className:"text-sm text-muted-foreground sm:w-20 sm:shrink-0",children:e("fields.editor.sshPort.label")}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(kt,{type:"number",min:1,max:65535,value:dr,onChange:Be=>fr(Be.target.value),placeholder:"22",disabled:en,className:"w-20 font-mono text-sm"}),c.jsx(Ce,{variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-foreground",onClick:aP,disabled:en||Oe.isPending,title:t("buttons.reset"),children:c.jsx(J,{icon:Pd,size:14,strokeWidth:2})})]})]}),c.jsx("p",{className:"text-xs text-muted-foreground sm:ml-20 sm:pl-2",children:e("fields.editor.sshPort.description")})]})]})}),c.jsx(yl,{title:e("sections.integrations"),children:c.jsxs("div",{className:"space-y-4",children:[c.jsxs("div",{className:"space-y-1",children:[c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[c.jsx("label",{className:"text-sm text-muted-foreground sm:w-20 sm:shrink-0",children:e("fields.github.label")}),c.jsxs("div",{className:"flex flex-1 items-center gap-2",children:[c.jsxs("div",{className:"relative flex-1",children:[c.jsx(kt,{type:"password",value:Fi,onChange:Be=>Ai(Be.target.value),placeholder:"ghp_...",disabled:en,className:"flex-1 pr-8 font-mono text-sm"}),!!v&&c.jsx("div",{className:"absolute right-2 top-1/2 -translate-y-1/2 text-green-500",children:c.jsx(J,{icon:cr,size:14,strokeWidth:2})})]}),c.jsx(Ce,{variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-foreground",onClick:oP,disabled:en||Oe.isPending,title:t("buttons.reset"),children:c.jsx(J,{icon:Pd,size:14,strokeWidth:2})})]})]}),c.jsx("p",{className:"text-xs text-muted-foreground sm:ml-20 sm:pl-2",children:e("fields.github.description")})]}),c.jsxs("div",{className:"space-y-1",children:[c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[c.jsx("label",{className:"text-sm text-muted-foreground sm:w-20 sm:shrink-0",children:e("fields.cloudflare.label")}),c.jsx("div",{className:"flex flex-1 items-center gap-2",children:c.jsxs("div",{className:"relative flex-1",children:[c.jsx(kt,{type:"password",value:Ea,onChange:Be=>vp(Be.target.value),placeholder:e("fields.cloudflare.placeholder"),disabled:en,className:"flex-1 pr-8 font-mono text-sm"}),!!Y?.cloudflareApiToken&&c.jsx("div",{className:"absolute right-2 top-1/2 -translate-y-1/2 text-green-500",children:c.jsx(J,{icon:cr,size:14,strokeWidth:2})})]})})]}),c.jsx("p",{className:"text-xs text-muted-foreground sm:ml-20 sm:pl-2",children:e("fields.cloudflare.description")})]}),c.jsxs("div",{className:"space-y-1",children:[c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[c.jsx("label",{className:"text-sm text-muted-foreground sm:w-20 sm:shrink-0",children:"Account ID"}),c.jsx("div",{className:"flex flex-1 items-center gap-2",children:c.jsxs("div",{className:"relative flex-1",children:[c.jsx(kt,{type:"password",value:xp,onChange:Be=>Qy(Be.target.value),placeholder:"CF Account ID",disabled:en,className:"flex-1 pr-8 font-mono text-sm"}),!!Y?.cloudflareAccountId&&c.jsx("div",{className:"absolute right-2 top-1/2 -translate-y-1/2 text-green-500",children:c.jsx(J,{icon:cr,size:14,strokeWidth:2})})]})})]}),c.jsxs("p",{className:"text-xs text-muted-foreground sm:ml-20 sm:pl-2",children:["Required for Cloudflare Tunnel. Find in your dashboard URL: dash.cloudflare.com/","<account_id>","/..."]})]}),c.jsx(bAt,{clientId:Ki,onClientIdChange:vo,clientIdSaved:!!w,clientSecret:Yi,onClientSecretChange:tt,clientSecretSaved:!!C,isLoading:en,onSaveCredentials:__})]})})]}),c.jsx(yl,{title:e("sections.tasks"),children:c.jsxs("div",{className:"space-y-4",children:[c.jsxs("div",{className:"space-y-1",children:[c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[c.jsx("label",{className:"text-sm text-muted-foreground sm:w-32 sm:shrink-0",children:e("fields.tasks.defaultType.label")}),c.jsxs(Vr,{value:ev,onValueChange:Be=>tv(Be),children:[c.jsx(qr,{className:"w-40",children:c.jsx(Wr,{})}),c.jsxs(Gr,{children:[c.jsx(Kt,{value:"worktree",children:e("fields.tasks.defaultType.options.worktree")}),c.jsx(Kt,{value:"non-worktree",children:e("fields.tasks.defaultType.options.nonWorktree")})]})]})]}),c.jsx("p",{className:"text-xs text-muted-foreground sm:ml-32 sm:pl-2",children:e("fields.tasks.defaultType.description")})]}),c.jsxs("div",{className:"space-y-1",children:[c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[c.jsx("label",{className:"text-sm text-muted-foreground sm:w-32 sm:shrink-0",children:e("fields.tasks.startImmediately.label")}),c.jsx(Dr,{checked:nv,onCheckedChange:gk,disabled:en})]}),c.jsx("p",{className:"text-xs text-muted-foreground sm:ml-32 sm:pl-2",children:e("fields.tasks.startImmediately.description")})]})]})}),c.jsx(yl,{title:e("sections.server"),children:c.jsxs("div",{className:"space-y-1",children:[c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[c.jsx("label",{className:"text-sm text-muted-foreground sm:w-32 sm:shrink-0",children:e("fields.port.label")}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(kt,{type:"number",min:1,max:65535,value:zt,onChange:Be=>sn(Be.target.value),placeholder:"7777",disabled:en,className:"w-24 font-mono text-sm"}),c.jsx(Ce,{variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-foreground",onClick:Dk,disabled:en||Oe.isPending,title:t("buttons.reset"),children:c.jsx(J,{icon:Pd,size:14,strokeWidth:2})})]})]}),c.jsx("p",{className:"text-xs text-muted-foreground sm:ml-32 sm:pl-2",children:e("fields.port.description")})]})}),c.jsx(yl,{title:e("sections.paths"),children:c.jsxs("div",{className:"space-y-1",children:[c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[c.jsx("label",{className:"text-sm text-muted-foreground sm:w-32 sm:shrink-0",children:e("fields.gitReposDir.label")}),c.jsxs("div",{className:"flex flex-1 items-center gap-2",children:[c.jsx(kt,{value:Ln,onChange:Be=>vr(Be.target.value),placeholder:"~/projects",disabled:en,className:"flex-1 font-mono text-sm"}),c.jsx(Ce,{variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-foreground",onClick:()=>Wt(!0),disabled:en,title:t("buttons.browse"),children:c.jsx(J,{icon:$a,size:14,strokeWidth:2})}),c.jsx(Ce,{variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-foreground",onClick:Pk,disabled:en||Oe.isPending,title:t("buttons.reset"),children:c.jsx(J,{icon:Pd,size:14,strokeWidth:2})})]})]}),c.jsx("p",{className:"text-xs text-muted-foreground sm:ml-32 sm:pl-2",children:e("fields.gitReposDir.description")})]})}),X?.enabled&&c.jsx(yl,{title:e("sections.developer"),children:c.jsx("div",{className:"space-y-1",children:c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between",children:[c.jsx("div",{className:"flex-1",children:c.jsx("p",{className:"text-sm text-muted-foreground",children:e("developer.restartDescription")})}),c.jsxs(Ce,{variant:"outline",size:"sm",onClick:()=>{const Be=X?.startedAt;uv(!0),z.mutate(void 0,{onSuccess:()=>{(async()=>{for(let Ca=0;Ca<120;Ca++){await new Promise(Au=>setTimeout(Au,500));try{const Au=await fetch("/api/config/developer-mode");if(Au.ok&&(await Au.json()).startedAt!==Be){window.location.reload();return}}catch{}}uv(!1),rt.error(e("developer.restartFailed"),{description:e("developer.checkLogs")})})()},onError:Pt=>{uv(!1),rt.error(e("developer.restartFailed"),{description:Pt.message})}})},disabled:z.isPending||p_,className:"shrink-0 gap-2",children:[(z.isPending||p_)&&c.jsx(J,{icon:Rt,size:14,strokeWidth:2,className:"animate-spin"}),e(p_?"developer.restarting":"developer.restartButton")]})]})})})]})}),c.jsx(Un,{value:"ai",className:"flex-1 overflow-auto p-6",children:c.jsxs("div",{className:"mx-auto max-w-5xl space-y-4",children:[c.jsxs(yl,{title:e("sections.agent"),children:[c.jsxs("div",{className:"space-y-4",children:[c.jsxs("div",{className:"space-y-1",children:[c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[c.jsx("label",{className:"text-sm text-muted-foreground sm:w-32 sm:shrink-0",children:e("fields.agent.default.label")}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsxs(Vr,{value:Mn,onValueChange:Be=>An(Be),children:[c.jsx(qr,{className:"w-40",children:c.jsx(Wr,{})}),c.jsx(Gr,{children:Object.keys(Ua).map(Be=>c.jsx(Kt,{value:Be,children:Ua[Be]},Be))})]}),c.jsx(Ce,{variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-foreground",onClick:lP,disabled:en||Oe.isPending,title:t("buttons.reset"),children:c.jsx(J,{icon:Pd,size:14,strokeWidth:2})})]})]}),c.jsx("p",{className:"text-xs text-muted-foreground sm:ml-32 sm:pl-2",children:e("fields.agent.default.description")})]}),c.jsxs("div",{className:"space-y-1",children:[c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[c.jsx("label",{className:"text-sm text-muted-foreground sm:w-32 sm:shrink-0",children:e("fields.agent.opencodeModel.label")}),c.jsxs("div",{className:"flex flex-1 items-center gap-2",children:[c.jsx(Bb,{value:Fr,onChange:ss,placeholder:e("fields.agent.opencodeModel.placeholder"),className:"w-64"}),c.jsx(Ce,{variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-foreground",onClick:$o,disabled:en||Oe.isPending,title:t("buttons.reset"),children:c.jsx(J,{icon:Pd,size:14,strokeWidth:2})})]})]}),c.jsx("p",{className:"text-xs text-muted-foreground sm:ml-32 sm:pl-2",children:e("fields.agent.opencodeModel.description")})]})]}),c.jsxs(pg,{className:"mt-4 space-y-1",children:[c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-start",children:[c.jsxs(mg,{className:"group flex cursor-pointer items-center gap-1.5 text-left text-sm text-muted-foreground transition-colors hover:text-foreground sm:w-32 sm:shrink-0",children:[c.jsx(J,{icon:Do,size:12,strokeWidth:2,className:"shrink-0 transition-transform duration-200 group-data-[state=open]:rotate-180"}),c.jsx("span",{children:e("fields.agent.advancedAgentNames.label")})]}),c.jsx("p",{className:"text-xs text-muted-foreground sm:pt-0.5",children:e("fields.agent.advancedAgentNames.description")})]}),c.jsxs(gg,{className:"space-y-4 pt-2 sm:ml-32 sm:pl-2",children:[c.jsxs("div",{className:"flex items-start gap-2 rounded-md border border-amber-500/20 bg-amber-500/10 p-3",children:[c.jsx(J,{icon:Pr,size:16,strokeWidth:2,className:"mt-0.5 shrink-0 text-amber-600 dark:text-amber-400"}),c.jsx("p",{className:"text-xs text-amber-600 dark:text-amber-400",children:e("fields.agent.advancedAgentNames.warning")})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[c.jsx("label",{className:"text-sm text-muted-foreground sm:w-32 sm:shrink-0",children:e("fields.agent.opencodeDefaultAgent.label")}),c.jsxs("div",{className:"flex flex-1 items-center gap-2",children:[c.jsx(kt,{value:li??"build",onChange:Be=>kr(Be.target.value),placeholder:"build",disabled:en,className:"font-mono text-sm"}),c.jsx(Ce,{variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-foreground",onClick:Ng,disabled:en||Oe.isPending,title:t("buttons.reset"),children:c.jsx(J,{icon:Pd,size:14,strokeWidth:2})})]})]}),c.jsx("p",{className:"text-xs text-muted-foreground sm:ml-32 sm:pl-2",children:e("fields.agent.opencodeDefaultAgent.description")})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[c.jsx("label",{className:"text-sm text-muted-foreground sm:w-32 sm:shrink-0",children:e("fields.agent.opencodePlanAgent.label")}),c.jsxs("div",{className:"flex flex-1 items-center gap-2",children:[c.jsx(kt,{value:ei??"plan",onChange:Be=>hr(Be.target.value),placeholder:"plan",disabled:en,className:"font-mono text-sm"}),c.jsx(Ce,{variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-foreground",onClick:jk,disabled:en||Oe.isPending,title:t("buttons.reset"),children:c.jsx(J,{icon:Pd,size:14,strokeWidth:2})})]})]}),c.jsx("p",{className:"text-xs text-muted-foreground sm:ml-32 sm:pl-2",children:e("fields.agent.opencodePlanAgent.description")})]})]})]}),c.jsxs("div",{className:"mt-4 space-y-1 border-t border-border pt-4",children:[c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[c.jsx("label",{className:"text-sm text-muted-foreground sm:w-32 sm:shrink-0",children:e("fields.agent.autoScrollToBottom.label")}),c.jsx(Dr,{checked:Br,onCheckedChange:Xi,disabled:en})]}),c.jsx("p",{className:"text-xs text-muted-foreground sm:ml-32 sm:pl-2",children:e("fields.agent.autoScrollToBottom.description")})]}),c.jsxs("div",{className:"mt-4 space-y-1 border-t border-border pt-4",children:[c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[c.jsx("label",{className:"text-sm text-muted-foreground sm:w-32 sm:shrink-0",children:e("fields.agent.claudeCodePath.label")}),c.jsx(kt,{value:Fo,onChange:Be=>Gt(Be.target.value),placeholder:e("fields.agent.claudeCodePath.placeholder"),className:"flex-1",disabled:en})]}),c.jsx("p",{className:"text-xs text-muted-foreground sm:ml-32 sm:pl-2",children:e("fields.agent.claudeCodePath.description")})]})]}),c.jsx(yl,{title:e("sections.assistant"),children:c.jsxs("div",{className:"space-y-4",children:[c.jsxs("div",{className:"grid gap-4 md:grid-cols-2 md:gap-x-8",children:[c.jsxs("div",{className:"space-y-4",children:[c.jsxs("div",{className:"space-y-1",children:[c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[c.jsx("label",{className:"text-sm text-muted-foreground sm:w-32 sm:shrink-0",children:e("fields.assistant.provider.label")}),c.jsxs(Vr,{value:Ad,onValueChange:Be=>h_(Be),children:[c.jsx(qr,{className:"w-48",children:c.jsx(Wr,{})}),c.jsxs(Gr,{children:[c.jsx(Kt,{value:"claude",children:"Claude"}),Ue&&c.jsx(Kt,{value:"opencode",children:"OpenCode"})]})]})]}),c.jsx("p",{className:"text-xs text-muted-foreground sm:ml-32 sm:pl-2",children:e("fields.assistant.provider.description")})]}),Ad==="claude"&&c.jsxs("div",{className:"space-y-1",children:[c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[c.jsx("label",{className:"text-sm text-muted-foreground sm:w-32 sm:shrink-0",children:e("fields.assistant.model.label")}),c.jsxs(Vr,{value:rv,onValueChange:Be=>yk(Be),children:[c.jsx(qr,{className:"w-48",children:c.jsx(Wr,{})}),c.jsx(Gr,{children:Qie.map(Be=>c.jsx(Kt,{value:Be,children:e(`fields.assistant.model.options.${Be}`)},Be))})]})]}),c.jsx("p",{className:"text-xs text-muted-foreground sm:ml-32 sm:pl-2",children:e("fields.assistant.model.description")})]}),Ad==="opencode"&&c.jsxs("div",{className:"space-y-1",children:[c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[c.jsx("label",{className:"text-sm text-muted-foreground sm:w-32 sm:shrink-0",children:e("fields.assistant.opencodeModel.label")}),c.jsx(Bb,{value:S,onChange:Be=>{Se.mutate({key:qt.OPENCODE_MODEL,value:Be})},placeholder:e("fields.assistant.opencodeModel.placeholder"),className:"w-64"})]}),c.jsx("p",{className:"text-xs text-muted-foreground sm:ml-32 sm:pl-2",children:e("fields.assistant.opencodeModel.description")})]})]}),c.jsxs("div",{className:"space-y-4",children:[c.jsxs("div",{className:"space-y-1",children:[c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[c.jsx("label",{className:"text-sm text-muted-foreground sm:w-32 sm:shrink-0",children:e("fields.assistant.observerProvider.label")}),c.jsxs(Vr,{value:Tu??"same-as-main",onValueChange:Be=>xk(Be==="same-as-main"?null:Be),children:[c.jsx(qr,{className:"w-48",children:c.jsx(Wr,{})}),c.jsxs(Gr,{children:[c.jsx(Kt,{value:"same-as-main",children:e("fields.assistant.observerProvider.options.default")}),c.jsx(Kt,{value:"claude",children:"Claude"}),Ue&&c.jsx(Kt,{value:"opencode",children:"OpenCode"})]})]})]}),c.jsx("p",{className:"text-xs text-muted-foreground sm:ml-32 sm:pl-2",children:e("fields.assistant.observerProvider.description")})]}),(Tu==="claude"||Tu===null&&Ad==="claude")&&c.jsxs("div",{className:"space-y-1",children:[c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[c.jsx("label",{className:"text-sm text-muted-foreground sm:w-32 sm:shrink-0",children:e("fields.assistant.observerModel.label")}),c.jsxs(Vr,{value:iv,onValueChange:Be=>vk(Be),children:[c.jsx(qr,{className:"w-48",children:c.jsx(Wr,{})}),c.jsx(Gr,{children:Qie.map(Be=>c.jsx(Kt,{value:Be,children:e(`fields.assistant.observerModel.options.${Be}`)},Be))})]})]}),c.jsx("p",{className:"text-xs text-muted-foreground sm:ml-32 sm:pl-2",children:e("fields.assistant.observerModel.description")})]}),(Tu==="opencode"||Tu===null&&Ad==="opencode")&&Ue&&c.jsxs("div",{className:"space-y-1",children:[c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[c.jsx("label",{className:"text-sm text-muted-foreground sm:w-32 sm:shrink-0",children:e("fields.assistant.observerOpencodeModel.label")}),c.jsx(Bb,{value:sv,onChange:Be=>_k(Be),placeholder:e("fields.assistant.observerOpencodeModel.placeholder"),className:"w-64"})]}),c.jsx("p",{className:"text-xs text-muted-foreground sm:ml-32 sm:pl-2",children:e("fields.assistant.observerOpencodeModel.description")})]})]})]}),c.jsxs("div",{className:"space-y-1",children:[c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[c.jsx("label",{className:"text-sm text-muted-foreground sm:w-32 sm:shrink-0",children:e("fields.assistant.customInstructions.label")}),c.jsx(ai,{to:"/assistant",search:{tab:"memory"},children:c.jsx(Ce,{variant:"outline",size:"sm",children:e("fields.assistant.customInstructions.openMemoryFile")})})]}),c.jsx("p",{className:"text-xs text-muted-foreground sm:ml-32 sm:pl-2",children:e("fields.assistant.customInstructions.memoryDescription")})]}),c.jsxs("div",{className:"space-y-1",children:[c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[c.jsx("label",{className:"text-sm text-muted-foreground sm:w-32 sm:shrink-0",children:e("fields.assistant.documentsDir.label")}),c.jsx(kt,{value:kg,onChange:Be=>Sk(Be.target.value),placeholder:"~/.fulcrum/documents",disabled:en,className:"w-64 font-mono text-sm"})]}),c.jsx("p",{className:"text-xs text-muted-foreground sm:ml-32 sm:pl-2",children:e("fields.assistant.documentsDir.description")})]}),c.jsxs("div",{className:"border-t border-border pt-4 space-y-1",children:[c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[c.jsx("label",{className:"text-sm text-muted-foreground sm:w-32 sm:shrink-0",children:e("concierge.rituals")}),c.jsx(Dr,{checked:Tg,onCheckedChange:wk,disabled:en})]}),c.jsx("p",{className:"text-xs text-muted-foreground sm:ml-32 sm:pl-2",children:e("concierge.ritualsDescription")})]}),Tg&&c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"space-y-3",children:[c.jsxs("div",{className:"space-y-1",children:[c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[c.jsx("label",{className:"text-sm text-muted-foreground sm:w-32 sm:shrink-0",children:e("concierge.morningRitual")}),c.jsx(kt,{type:"time",value:av,onChange:Be=>Ek(Be.target.value),disabled:en,className:"w-32"})]}),c.jsx("p",{className:"text-xs text-muted-foreground sm:ml-32 sm:pl-2",children:e("concierge.morningRitualDescription")})]}),c.jsx("div",{className:"sm:ml-32 sm:pl-2",children:c.jsx(dd,{value:ov,onChange:Be=>Ck(Be.target.value),placeholder:e("concierge.morningRitualPromptPlaceholder"),disabled:en,className:"min-h-[80px] text-sm"})})]}),c.jsxs("div",{className:"space-y-3",children:[c.jsxs("div",{className:"space-y-1",children:[c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[c.jsx("label",{className:"text-sm text-muted-foreground sm:w-32 sm:shrink-0",children:e("concierge.eveningRitual")}),c.jsx(kt,{type:"time",value:lv,onChange:Be=>kk(Be.target.value),disabled:en,className:"w-32"})]}),c.jsx("p",{className:"text-xs text-muted-foreground sm:ml-32 sm:pl-2",children:e("concierge.eveningRitualDescription")})]}),c.jsx("div",{className:"sm:ml-32 sm:pl-2",children:c.jsx(dd,{value:Sp,onChange:Be=>wp(Be.target.value),placeholder:e("concierge.eveningRitualPromptPlaceholder"),disabled:en,className:"min-h-[80px] text-sm"})})]})]})]})}),c.jsx(yl,{title:e("sections.zai"),children:c.jsxs("div",{className:"space-y-4",children:[c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[c.jsx("label",{className:"text-sm text-muted-foreground sm:w-20 sm:shrink-0",children:e("fields.zai.enable")}),c.jsx(Dr,{checked:Tt,onCheckedChange:Lt,disabled:en})]}),Tt&&c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"space-y-1",children:[c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[c.jsx("label",{className:"text-sm text-muted-foreground sm:w-20 sm:shrink-0",children:e("fields.zai.apiKey")}),c.jsxs("div",{className:"relative flex-1",children:[c.jsx(kt,{type:"password",value:Cn,onChange:Be=>Fn(Be.target.value),placeholder:"zai_...",disabled:en,className:"flex-1 pr-8 font-mono text-sm"}),!!U?.apiKey&&c.jsx("div",{className:"absolute right-2 top-1/2 -translate-y-1/2 text-green-500",children:c.jsx(J,{icon:cr,size:14,strokeWidth:2})})]})]}),c.jsx("p",{className:"text-xs text-muted-foreground sm:ml-20 sm:pl-2",children:e("fields.zai.description")})]}),c.jsxs("div",{className:"space-y-3 border-t border-border pt-4",children:[c.jsx("p",{className:"text-xs font-medium text-muted-foreground",children:e("fields.zai.modelMappings")}),c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[c.jsx("label",{className:"text-sm text-muted-foreground sm:w-20 sm:shrink-0",children:e("fields.zai.haiku")}),c.jsx(kt,{value:Ur,onChange:Be=>Zi(Be.target.value),placeholder:"glm-4.5-air",disabled:en,className:"flex-1 font-mono text-sm"})]}),c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[c.jsx("label",{className:"text-sm text-muted-foreground sm:w-20 sm:shrink-0",children:e("fields.zai.sonnet")}),c.jsx(kt,{value:cl,onChange:Be=>ku(Be.target.value),placeholder:"glm-4.7",disabled:en,className:"flex-1 font-mono text-sm"})]}),c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[c.jsx("label",{className:"text-sm text-muted-foreground sm:w-20 sm:shrink-0",children:e("fields.zai.opus")}),c.jsx(kt,{value:os,onChange:Be=>Qa(Be.target.value),placeholder:"glm-4.7",disabled:en,className:"flex-1 font-mono text-sm"})]})]})]})]})})]})}),c.jsx(Un,{value:"messaging",className:"flex-1 overflow-auto p-6",children:c.jsxs("div",{className:"mx-auto max-w-5xl space-y-4",children:[c.jsx(yl,{title:e("sections.notifications"),children:c.jsxs("div",{className:"space-y-4",children:[c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[c.jsx("label",{className:"text-sm text-muted-foreground sm:w-40 sm:shrink-0",children:e("notifications.enable")}),c.jsx(Dr,{checked:In,onCheckedChange:As,disabled:en})]}),c.jsxs("div",{className:"space-y-2 pl-4",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(Dr,{checked:wu,onCheckedChange:Ya,disabled:en||!In}),c.jsx("label",{className:"text-sm text-muted-foreground",children:e("notifications.toast")})]}),c.jsx("p",{className:"ml-10 text-xs text-muted-foreground",children:e("notifications.toastDescription")})]}),c.jsxs("div",{className:"space-y-2 pl-4",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(Dr,{checked:Sa,onCheckedChange:Eu,disabled:en||!In}),c.jsx("label",{className:"text-sm text-muted-foreground",children:e("notifications.desktop")})]}),c.jsx("p",{className:"ml-10 text-xs text-muted-foreground",children:e("notifications.desktopDescription")})]}),c.jsxs("div",{className:"space-y-2 pl-4",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(Dr,{checked:$i,onCheckedChange:Ns,disabled:en||!In}),c.jsx("label",{className:"text-sm text-muted-foreground",children:e("notifications.sound")}),c.jsxs("div",{className:"ml-auto flex items-center gap-1",children:[c.jsx("input",{ref:Fc,type:"file",accept:"audio/mpeg,audio/mp3,audio/wav,audio/ogg",className:"hidden",onChange:Lk}),c.jsx(Ce,{variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-foreground",onClick:()=>Fc.current?.click(),disabled:en||!In||!$i||g_,title:e("notifications.uploadSound"),children:g_?c.jsx(J,{icon:Rt,size:14,strokeWidth:2,className:"animate-spin"}):c.jsx(J,{icon:y$e,size:14,strokeWidth:2})}),m_&&c.jsx(Ce,{variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-destructive",onClick:Mk,disabled:en||!In||!$i,title:e("notifications.deleteSound"),children:c.jsx(J,{icon:ma,size:14,strokeWidth:2})}),c.jsx(Ce,{variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-foreground",onClick:()=>Nd("sound"),disabled:en||!In||!$i||_t.isPending,title:e("notifications.testSound"),children:_t.isPending?c.jsx(J,{icon:Rt,size:14,strokeWidth:2,className:"animate-spin"}):c.jsx(J,{icon:nm,size:14,strokeWidth:2})})]})]}),m_&&c.jsx("p",{className:"ml-10 text-xs text-muted-foreground",children:e("notifications.customSoundActive")})]}),c.jsxs("div",{className:"space-y-2 pl-4",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(Dr,{checked:as,onCheckedChange:Lc,disabled:en||!In}),c.jsx("label",{className:"text-sm text-muted-foreground",children:e("notifications.slack")}),c.jsx(Ce,{variant:"ghost",size:"icon",className:"ml-auto h-8 w-8 text-muted-foreground hover:text-foreground",onClick:()=>Nd("slack"),disabled:en||!In||!as||!Mc&&!oe||_t.isPending,title:e("notifications.slack"),children:_t.isPending?c.jsx(J,{icon:Rt,size:14,strokeWidth:2,className:"animate-spin"}):c.jsx(J,{icon:nm,size:14,strokeWidth:2})})]}),as&&c.jsxs("div",{className:"ml-6 space-y-2",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(Dr,{checked:oe,onCheckedChange:_e,disabled:en||!In||!as}),c.jsx("label",{className:"text-xs text-muted-foreground",children:e("notifications.useMessagingChannel")||"Use messaging channel"})]}),!oe&&c.jsxs("div",{className:"relative",children:[c.jsx(kt,{type:"password",value:Mc,onChange:Be=>Td(Be.target.value),placeholder:"https://hooks.slack.com/services/...",disabled:en||!In,className:"flex-1 pr-8 font-mono text-sm"}),!!M?.slack?.webhookUrl&&c.jsx("div",{className:"absolute right-2 top-1/2 -translate-y-1/2 text-green-500",children:c.jsx(J,{icon:cr,size:14,strokeWidth:2})})]}),oe&&c.jsx("p",{className:"text-xs text-muted-foreground",children:e("notifications.messagingChannelNote")||"Sends via connected Slack messaging channel"})]})]}),c.jsxs("div",{className:"space-y-2 pl-4",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(Dr,{checked:Xa,onCheckedChange:Uf,disabled:en||!In}),c.jsx("label",{className:"text-sm text-muted-foreground",children:e("notifications.discord")}),c.jsx(Ce,{variant:"ghost",size:"icon",className:"ml-auto h-8 w-8 text-muted-foreground hover:text-foreground",onClick:()=>Nd("discord"),disabled:en||!In||!Xa||!Vt&&!He||_t.isPending,title:e("notifications.discord"),children:_t.isPending?c.jsx(J,{icon:Rt,size:14,strokeWidth:2,className:"animate-spin"}):c.jsx(J,{icon:nm,size:14,strokeWidth:2})})]}),Xa&&c.jsxs("div",{className:"ml-6 space-y-2",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(Dr,{checked:He,onCheckedChange:Xe,disabled:en||!In||!Xa}),c.jsx("label",{className:"text-xs text-muted-foreground",children:e("notifications.useMessagingChannel")||"Use messaging channel"})]}),!He&&c.jsxs("div",{className:"relative",children:[c.jsx(kt,{type:"password",value:Vt,onChange:Be=>dn(Be.target.value),placeholder:"https://discord.com/api/webhooks/...",disabled:en||!In,className:"flex-1 pr-8 font-mono text-sm"}),!!M?.discord?.webhookUrl&&c.jsx("div",{className:"absolute right-2 top-1/2 -translate-y-1/2 text-green-500",children:c.jsx(J,{icon:cr,size:14,strokeWidth:2})})]}),He&&c.jsx("p",{className:"text-xs text-muted-foreground",children:e("notifications.messagingChannelNote")||"Sends via connected Discord messaging channel"})]})]}),c.jsxs("div",{className:"space-y-2 pl-4",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(Dr,{checked:On,onCheckedChange:$r,disabled:en||!In}),c.jsx("label",{className:"text-sm text-muted-foreground",children:e("notifications.pushover")}),c.jsx(Ce,{variant:"ghost",size:"icon",className:"ml-auto h-8 w-8 text-muted-foreground hover:text-foreground",onClick:()=>Nd("pushover"),disabled:en||!In||!On||!Rr||!xo||_t.isPending,title:e("notifications.pushover"),children:_t.isPending?c.jsx(J,{icon:Rt,size:14,strokeWidth:2,className:"animate-spin"}):c.jsx(J,{icon:nm,size:14,strokeWidth:2})})]}),On&&c.jsxs("div",{className:"ml-6 space-y-2",children:[c.jsxs("div",{className:"relative",children:[c.jsx(kt,{type:"password",value:Rr,onChange:Be=>_n(Be.target.value),placeholder:e("notifications.appToken"),disabled:en||!In,className:"flex-1 pr-8 font-mono text-sm"}),!!M?.pushover?.appToken&&c.jsx("div",{className:"absolute right-2 top-1/2 -translate-y-1/2 text-green-500",children:c.jsx(J,{icon:cr,size:14,strokeWidth:2})})]}),c.jsxs("div",{className:"relative",children:[c.jsx(kt,{type:"password",value:xo,onChange:Be=>Bo(Be.target.value),placeholder:e("notifications.userKey"),disabled:en||!In,className:"flex-1 pr-8 font-mono text-sm"}),!!M?.pushover?.userKey&&c.jsx("div",{className:"absolute right-2 top-1/2 -translate-y-1/2 text-green-500",children:c.jsx(J,{icon:cr,size:14,strokeWidth:2})})]})]})]}),c.jsxs("div",{className:"space-y-2 pl-4",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(Dr,{checked:wa,onCheckedChange:Za,disabled:en||!In}),c.jsx("label",{className:"text-sm text-muted-foreground",children:e("notifications.whatsapp")||"WhatsApp"}),c.jsx(Ce,{variant:"ghost",size:"icon",className:"ml-auto h-8 w-8 text-muted-foreground hover:text-foreground",onClick:()=>Nd("whatsapp"),disabled:en||!In||!wa||_t.isPending,title:e("notifications.whatsapp")||"WhatsApp",children:_t.isPending?c.jsx(J,{icon:Rt,size:14,strokeWidth:2,className:"animate-spin"}):c.jsx(J,{icon:nm,size:14,strokeWidth:2})})]}),wa&&c.jsx("p",{className:"ml-10 text-xs text-muted-foreground",children:e("notifications.messagingChannelRequired")||"Requires connected WhatsApp messaging channel"})]}),c.jsxs("div",{className:"space-y-2 pl-4",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(Dr,{checked:Cu,onCheckedChange:yp,disabled:en||!In}),c.jsx("label",{className:"text-sm text-muted-foreground",children:e("notifications.telegram")||"Telegram"}),c.jsx(Ce,{variant:"ghost",size:"icon",className:"ml-auto h-8 w-8 text-muted-foreground hover:text-foreground",onClick:()=>Nd("telegram"),disabled:en||!In||!Cu||_t.isPending,title:e("notifications.telegram")||"Telegram",children:_t.isPending?c.jsx(J,{icon:Rt,size:14,strokeWidth:2,className:"animate-spin"}):c.jsx(J,{icon:nm,size:14,strokeWidth:2})})]}),Cu&&c.jsx("p",{className:"ml-10 text-xs text-muted-foreground",children:e("notifications.messagingChannelRequired")||"Requires connected Telegram messaging channel"})]}),c.jsxs("div",{className:"space-y-2 pl-4",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(Dr,{checked:ul,onCheckedChange:N,disabled:en||!In}),c.jsx("label",{className:"text-sm text-muted-foreground",children:e("notifications.gmail")}),c.jsx(Ce,{variant:"ghost",size:"icon",className:"ml-auto h-8 w-8 text-muted-foreground hover:text-foreground",onClick:()=>Nd("gmail"),disabled:en||!In||!ul||_t.isPending,title:e("notifications.gmail"),children:_t.isPending?c.jsx(J,{icon:Rt,size:14,strokeWidth:2,className:"animate-spin"}):c.jsx(J,{icon:nm,size:14,strokeWidth:2})})]}),ul&&c.jsxs("div",{className:"ml-10 space-y-2",children:[c.jsx("p",{className:"text-xs text-muted-foreground",children:e("notifications.gmailDescription")}),an.length>1&&c.jsxs(Vr,{value:H||"auto",onValueChange:Be=>te(!Be||Be==="auto"?"":Be),children:[c.jsx(qr,{className:"h-8 w-60",children:c.jsx(Wr,{})}),c.jsxs(Gr,{children:[c.jsx(Kt,{value:"auto",children:e("notifications.gmailAutoResolve")}),an.map(Be=>c.jsx(Kt,{value:Be.id,children:Be.email||Be.name},Be.id))]})]}),an.length===0&&c.jsx("p",{className:"text-xs text-destructive",children:e("notifications.gmailNoAccounts")})]})]})]})}),c.jsx(yl,{title:"Channels",children:c.jsxs("div",{className:"space-y-8",children:[c.jsx("div",{className:"rounded-lg border border-border p-4",children:c.jsx(XTt,{isLoading:en})}),c.jsx(BTt,{isLoading:en}),c.jsx($Tt,{isLoading:en}),c.jsx(UTt,{isLoading:en}),c.jsx(zTt,{isLoading:en})]})})]})}),c.jsx(Un,{value:"calendar",className:"flex-1 overflow-auto p-6",children:c.jsxs("div",{className:"mx-auto max-w-5xl space-y-4",children:[c.jsx(yl,{title:e("sections.googleCalendar","Google Calendar"),children:c.jsx(yAt,{})}),c.jsxs(yl,{title:e("sections.caldav"),children:[c.jsx(gAt,{isLoading:en}),c.jsx(vAt,{isLoading:en})]})]})})]})}),c.jsx("div",{className:"shrink-0 border-t border-border bg-background px-6 py-3",children:c.jsx("div",{className:"mx-auto flex max-w-5xl items-center justify-start",children:c.jsxs("div",{className:"flex items-center gap-2",children:[Xn&&c.jsxs("span",{className:"flex items-center gap-1 text-xs text-accent",children:[c.jsx(J,{icon:cr,size:12,strokeWidth:2}),t("status.saved")]}),c.jsx(Ce,{size:"sm",onClick:Ik,disabled:!x_||en||Se.isPending||Qe.isPending||It.isPending||q.isPending,children:t("buttons.save")})]})})}),c.jsx(bh,{open:it,onOpenChange:Wt,onSelect:Be=>vr(Be),initialPath:Ln||void 0})]})}const o5="";function SAt(){return Qt({queryKey:["github-user"],queryFn:async()=>{const e=await fetch(`${o5}/api/github/user`);return e.ok?e.json():null},staleTime:600*1e3,retry:!1})}function wAt(){return Qt({queryKey:["github-orgs"],queryFn:async()=>{const e=await fetch(`${o5}/api/github/orgs`);return e.ok?e.json():[]},staleTime:600*1e3})}function EAt(e,t,n){return Qt({queryKey:["github-issues",e,t,n],queryFn:async()=>{const r=new URLSearchParams({filter:e});t&&r.set("fulcrumReposOnly","true"),n&&r.set("org",n);const i=await fetch(`${o5}/api/github/issues?${r}`);if(!i.ok)throw new Error("Failed to fetch issues");return i.json()},staleTime:300*1e3})}function CAt(e,t,n){return Qt({queryKey:["github-prs",e,t,n],queryFn:async()=>{const r=new URLSearchParams({filter:e});t&&r.set("fulcrumReposOnly","true"),n&&r.set("org",n);const i=await fetch(`${o5}/api/github/prs?${r}`);if(!i.ok)throw new Error("Failed to fetch PRs");return i.json()},staleTime:300*1e3})}function kAt({filter:e,fulcrumReposOnly:t,org:n}){const{t:r}=Dt("review"),{t:i}=Dt("common"),{data:s,isLoading:a,error:o}=EAt(e,t,n);if(a)return c.jsx("div",{className:"flex h-48 items-center justify-center",children:c.jsx(J,{icon:Rt,size:24,className:"animate-spin text-muted-foreground"})});if(o)return c.jsxs("div",{className:"flex h-48 flex-col items-center justify-center gap-2 text-muted-foreground",children:[c.jsx(J,{icon:Pr,size:24}),c.jsx("p",{className:"text-sm",children:r("issues.failedToLoad")}),c.jsx("p",{className:"text-xs",children:o.message})]});const l={assigned:"issues.empty.assigned",created:"issues.empty.created",mentioned:"issues.empty.mentioned"};return s?.length?c.jsxs("div",{className:"space-y-4",children:[c.jsx("div",{className:"text-xs text-muted-foreground",children:i(s.length===1?"results.one":"results.other",{count:s.length})}),c.jsx("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4",children:s.map(u=>c.jsx(TAt,{issue:u},u.id))})]}):c.jsxs("div",{className:"flex h-48 flex-col items-center justify-center gap-2 text-muted-foreground",children:[c.jsx(J,{icon:cr,size:24}),c.jsx("p",{className:"text-sm",children:r(l[e])})]})}function TAt({issue:e}){return c.jsx(Gi,{className:"transition-colors hover:border-border/80",children:c.jsx(za,{className:"py-4",children:c.jsxs("a",{href:e.htmlUrl,target:"_blank",rel:"noopener noreferrer",className:"block space-y-2",children:[c.jsx("div",{className:"flex items-start gap-2",children:c.jsx("span",{className:"line-clamp-2 text-sm font-medium",children:e.title})}),c.jsx("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:c.jsxs("span",{className:"font-mono",children:[e.repository.fullName,"#",e.number]})}),e.labels.length>0&&c.jsxs("div",{className:"flex flex-wrap gap-1",children:[e.labels.slice(0,3).map(t=>c.jsx(jr,{className:"text-xs",style:{backgroundColor:`#${t.color}20`,color:`#${t.color}`,borderColor:`#${t.color}40`},children:t.name},t.name)),e.labels.length>3&&c.jsxs(jr,{variant:"secondary",className:"text-xs",children:["+",e.labels.length-3]})]})]})})})}function AAt({filter:e,fulcrumReposOnly:t,org:n}){const{t:r}=Dt("review"),{t:i}=Dt("common"),{data:s,isLoading:a,error:o}=CAt(e,t,n);if(a)return c.jsx("div",{className:"flex h-48 items-center justify-center",children:c.jsx(J,{icon:Rt,size:24,className:"animate-spin text-muted-foreground"})});if(o)return c.jsxs("div",{className:"flex h-48 flex-col items-center justify-center gap-2 text-muted-foreground",children:[c.jsx(J,{icon:Pr,size:24}),c.jsx("p",{className:"text-sm",children:r("prs.failedToLoad")}),c.jsx("p",{className:"text-xs",children:o.message})]});const l={all:"prs.empty.all",created:"prs.empty.created",assigned:"prs.empty.assigned",review_requested:"prs.empty.reviewRequested",mentioned:"prs.empty.mentioned"};return s?.length?c.jsxs("div",{className:"space-y-4",children:[c.jsx("div",{className:"text-xs text-muted-foreground",children:i(s.length===1?"results.one":"results.other",{count:s.length})}),c.jsx("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4",children:s.map(u=>c.jsx(NAt,{pr:u},u.id))})]}):c.jsxs("div",{className:"flex h-48 flex-col items-center justify-center gap-2 text-muted-foreground",children:[c.jsx(J,{icon:cr,size:24}),c.jsx("p",{className:"text-sm",children:r(l[e])})]})}function NAt({pr:e}){const{t}=Dt("review");return c.jsx(Gi,{className:"transition-colors hover:border-border/80",children:c.jsx(za,{className:"py-4",children:c.jsxs("a",{href:e.htmlUrl,target:"_blank",rel:"noopener noreferrer",className:"block space-y-2",children:[c.jsx("div",{className:"flex items-start gap-2",children:c.jsx("span",{className:"line-clamp-2 text-sm font-medium",children:e.title})}),c.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[c.jsxs("span",{className:"font-mono",children:[e.repository.fullName,"#",e.number]}),e.draft&&c.jsx(jr,{variant:"secondary",className:Pe("text-xs","bg-muted-foreground/20 text-muted-foreground"),children:t("prs.draft")})]}),c.jsxs("div",{className:"flex items-center gap-2",children:[e.author.avatarUrl&&c.jsx("img",{src:e.author.avatarUrl,alt:e.author.login,className:"h-4 w-4 rounded-full"}),c.jsx("span",{className:"text-xs text-muted-foreground",children:e.author.login})]}),e.labels.length>0&&c.jsxs("div",{className:"flex flex-wrap gap-1",children:[e.labels.slice(0,3).map(n=>c.jsx(jr,{className:"text-xs",style:{backgroundColor:`#${n.color}20`,color:`#${n.color}`,borderColor:`#${n.color}40`},children:n.name},n.name)),e.labels.length>3&&c.jsxs(jr,{variant:"secondary",className:"text-xs",children:["+",e.labels.length-3]})]})]})})})}const OAt=js("/review/")({component:RAt});function RAt(){const{t:e}=Dt("review"),[t,n]=x.useState("prs"),[r,i]=x.useState("review_requested"),[s,a]=x.useState("assigned"),[o,l]=x.useState(!1),[u,d]=x.useState(""),{data:f,isLoading:h}=SAt(),{data:m=[]}=wAt();return!h&&!f?c.jsxs("div",{className:"flex h-full flex-col",children:[c.jsx("div",{className:"film-grain relative flex shrink-0 items-center border-b border-border px-4 py-2",style:{background:"var(--gradient-header)"}}),c.jsx("div",{className:"flex flex-1 items-center justify-center p-8",children:c.jsxs("div",{className:"max-w-md space-y-4 text-center",children:[c.jsx("div",{className:"mx-auto flex h-12 w-12 items-center justify-center rounded-full bg-muted",children:c.jsx(J,{icon:s$e,size:24,className:"text-muted-foreground"})}),c.jsx("h2",{className:"text-lg font-medium",children:e("github.tokenRequired")}),c.jsx("p",{className:"text-sm text-muted-foreground",children:e("github.tokenDescription")}),c.jsxs("div",{className:"rounded-lg border border-border bg-muted/50 p-4 text-left",children:[c.jsx("p",{className:"mb-2 text-xs font-medium text-muted-foreground",children:e("github.requiredScopes")}),c.jsxs("ul",{className:"space-y-1 text-xs text-muted-foreground",children:[c.jsxs("li",{children:["• ",c.jsx("code",{className:"rounded bg-muted px-1",children:"repo"})," ",e("github.scopes.repo")]}),c.jsxs("li",{children:["• ",c.jsx("code",{className:"rounded bg-muted px-1",children:"read:user"})," ",e("github.scopes.readUser")]}),c.jsxs("li",{children:["• ",c.jsx("code",{className:"rounded bg-muted px-1",children:"read:org"})," ",e("github.scopes.readOrg")]})]})]}),c.jsxs("div",{className:"flex flex-col gap-2",children:[c.jsx("a",{href:"https://github.com/settings/tokens/new?scopes=repo,read:user,read:org&description=Fulcrum",target:"_blank",rel:"noopener noreferrer",children:c.jsxs(Ce,{variant:"outline",size:"sm",className:"w-full",children:[c.jsx(J,{icon:a$e,size:14,"data-slot":"icon"}),e("github.generateToken")]})}),c.jsx(ai,{to:"/settings",children:c.jsx(Ce,{size:"sm",className:"w-full",children:e("github.goToSettings")})})]})]})})]}):c.jsx("div",{className:"flex h-full flex-col",children:c.jsxs(Jo,{value:t,onValueChange:b=>n(b),className:"flex flex-1 flex-col overflow-hidden",children:[c.jsxs("div",{className:"film-grain relative flex shrink-0 flex-col border-b border-border sm:flex-row sm:items-center sm:justify-between",style:{background:"var(--gradient-header)"},children:[c.jsxs("div",{className:"flex items-center justify-between px-4 py-1 max-sm:px-2",children:[c.jsxs(el,{variant:"line",children:[c.jsx(Bn,{value:"prs",children:e("tabs.pullRequests")}),c.jsx(Bn,{value:"issues",children:e("tabs.issues")})]}),c.jsx("label",{className:"flex cursor-pointer items-center gap-2 text-xs sm:hidden",title:e("filters.fulcrumReposOnly"),children:c.jsx(Dr,{checked:o,onCheckedChange:l,disabled:!!u})})]}),c.jsxs("div",{className:"flex items-center gap-2 border-t border-border px-4 py-1.5 sm:gap-4 sm:border-t-0 sm:px-4 sm:py-1",children:[t==="prs"?c.jsxs(Vr,{value:r,onValueChange:b=>i(b),children:[c.jsx(qr,{size:"sm",className:"flex-1 sm:flex-initial",children:c.jsx(Wr,{})}),c.jsxs(Gr,{children:[c.jsx(Kt,{value:"created",children:e("filters.pr.created")}),c.jsx(Kt,{value:"assigned",children:e("filters.pr.assigned")}),c.jsx(Kt,{value:"review_requested",children:e("filters.pr.reviewRequested")}),c.jsx(Kt,{value:"mentioned",children:e("filters.pr.mentioned")})]})]}):c.jsxs(Vr,{value:s,onValueChange:b=>a(b),children:[c.jsx(qr,{size:"sm",className:"flex-1 sm:flex-initial",children:c.jsx(Wr,{})}),c.jsxs(Gr,{children:[c.jsx(Kt,{value:"assigned",children:e("filters.issue.assigned")}),c.jsx(Kt,{value:"created",children:e("filters.issue.created")}),c.jsx(Kt,{value:"mentioned",children:e("filters.issue.mentioned")})]})]}),c.jsxs(Vr,{value:u,onValueChange:b=>d(b||""),children:[c.jsx(qr,{size:"sm",className:"flex-1 sm:flex-initial",children:c.jsx(Wr,{children:u||e("filters.allOrgs")})}),c.jsxs(Gr,{children:[c.jsx(Kt,{value:"",children:e("filters.allOrganizations")}),m.map(b=>c.jsx(Kt,{value:b.login,children:b.login},b.login))]})]}),c.jsxs("label",{className:"hidden cursor-pointer items-center gap-2 text-xs sm:flex",title:e("filters.fulcrumReposOnly"),children:[c.jsx(Dr,{checked:o,onCheckedChange:l,disabled:!!u}),c.jsx("span",{className:"text-muted-foreground",children:e("filters.fulcrumReposOnly")})]})]})]}),c.jsx(Un,{value:"prs",className:"flex-1 overflow-auto p-4",children:c.jsx(AAt,{filter:r,fulcrumReposOnly:o,org:u||void 0})}),c.jsx(Un,{value:"issues",className:"flex-1 overflow-auto p-4",children:c.jsx(kAt,{filter:s,fulcrumReposOnly:o,org:u||void 0})})]})})}const IAt=js("/repositories/")({beforeLoad:()=>{throw zm({to:"/projects",search:{tab:"repositories"}})},component:()=>null});function DAt({open:e,onOpenChange:t,onCreated:n}){const{t:r}=Dt("projects"),i=ji(),s=HSe(),[a,o]=x.useState(""),[l,u]=x.useState(""),[d,f]=x.useState([]),[h,m]=x.useState(""),[b,y]=x.useState(!1),[v,_]=x.useState(null),w=x.useRef(null),{data:C=[]}=eW(h),T=C.filter(j=>!d.includes(j.name)),k=C.find(j=>j.name.toLowerCase()===h.toLowerCase()),S=h.trim()&&!k&&!d.includes(h.trim());x.useEffect(()=>{e&&(o(""),u(""),f([]),m(""),_(null),y(!1))},[e]),x.useEffect(()=>{const j=B=>{w.current&&!w.current.contains(B.target)&&y(!1)};return document.addEventListener("mousedown",j),()=>document.removeEventListener("mousedown",j)},[]);const A=j=>{const B=j.trim();B&&!d.includes(B)&&f([...d,B]),m(""),y(!1)},R=j=>{f(d.filter(B=>B!==j))},I=j=>{j.key==="Enter"&&h.trim()?(j.preventDefault(),k&&!d.includes(k.name)?A(k.name):S&&A(h.trim())):j.key==="Escape"?(y(!1),m("")):j.key==="Backspace"&&!h&&d.length>0&&f(d.slice(0,-1))},D=async()=>{_(null);const j=a.trim();if(j)try{const B=await s.mutateAsync({name:j,description:l.trim()||void 0,tags:d.length>0?d:void 0});t(!1),n?n(B):i({to:"/projects/$projectId",params:{projectId:B.id}})}catch(B){_(B instanceof Error?B.message:"Failed to create project")}},P=j=>{j.key==="Enter"&&!j.shiftKey&&a.trim()&&(j.preventDefault(),D())};return c.jsx(Va,{open:e,onOpenChange:t,children:c.jsxs(Wa,{className:"sm:max-w-md",children:[c.jsx(Po,{children:c.jsx(jo,{children:r("newProjectButton")})}),c.jsxs("div",{className:"space-y-4 py-2",children:[c.jsxs("div",{className:"space-y-2",children:[c.jsx(Kr,{htmlFor:"project-name",children:r("newProject.projectName")}),c.jsx(kt,{id:"project-name",value:a,onChange:j=>o(j.target.value),onKeyDown:P,placeholder:r("newProject.projectNamePlaceholder"),disabled:s.isPending,autoFocus:!0})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsx(Kr,{htmlFor:"project-description",children:r("newProject.description")}),c.jsx(dd,{id:"project-description",value:l,onChange:j=>u(j.target.value),placeholder:r("newProject.descriptionPlaceholder"),disabled:s.isPending,rows:3})]}),c.jsxs("div",{className:"space-y-2",ref:w,children:[c.jsx(Kr,{children:"Tags"}),d.length>0&&c.jsx("div",{className:"flex flex-wrap gap-1.5 mb-2",children:d.map(j=>c.jsxs(jr,{variant:"default",className:"pr-1 gap-1",children:[j,c.jsx("button",{type:"button",onClick:()=>R(j),className:"ml-0.5 hover:text-destructive transition-colors",children:c.jsx(J,{icon:jn,size:10})})]},j))}),c.jsxs("div",{className:"relative",children:[c.jsx(kt,{value:h,onChange:j=>{m(j.target.value),y(!0)},onFocus:()=>y(!0),onKeyDown:I,placeholder:"Add tags...",disabled:s.isPending}),b&&(h||T.length>0)&&c.jsxs("div",{className:"absolute top-full left-0 right-0 mt-1 bg-popover border rounded-md shadow-lg z-50 max-h-48 overflow-y-auto",children:[T.map(j=>c.jsxs("button",{type:"button",className:"w-full px-3 py-2 text-left text-sm hover:bg-accent flex items-center justify-between",onClick:()=>A(j.name),children:[c.jsx("span",{children:j.name}),c.jsxs("span",{className:"text-xs text-muted-foreground",children:[j.taskCount+j.projectCount," uses"]})]},j.id)),S&&c.jsxs("button",{type:"button",className:Pe("w-full px-3 py-2 text-left text-sm hover:bg-accent flex items-center gap-2",T.length>0&&"border-t"),onClick:()=>A(h.trim()),children:[c.jsx(J,{icon:mu,size:14}),c.jsxs("span",{children:['Create "',h.trim(),'"']})]}),!S&&T.length===0&&h&&c.jsx("div",{className:"px-3 py-2 text-sm text-muted-foreground",children:"No matching tags"})]})]})]}),v&&c.jsxs("div",{className:"flex items-start gap-2 rounded-md bg-destructive/10 px-3 py-2 text-xs text-destructive",children:[c.jsx(J,{icon:Pr,size:14,strokeWidth:2,className:"mt-0.5 shrink-0"}),c.jsx("span",{children:v})]})]}),c.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[c.jsx(Ce,{variant:"outline",onClick:()=>t(!1),disabled:s.isPending,children:r("newProject.cancel")}),c.jsx(Ce,{onClick:D,disabled:!a.trim()||s.isPending,children:s.isPending?c.jsxs(c.Fragment,{children:[c.jsx(J,{icon:Rt,size:16,strokeWidth:2,className:"animate-spin"}),r("newProject.creating")]}):r("newProject.create")})]})]})})}const PAt="";function jAt(e){return Qt({queryKey:["copier-questions",e],queryFn:()=>ct(`${PAt}/api/copier/questions?source=${encodeURIComponent(e)}`),enabled:!!e,staleTime:300*1e3,retry:!1})}function LAt(){const{data:e,...t}=sg();return{...t,data:e?.filter(n=>n.isCopierTemplate)??[]}}function X6(e){return e.startsWith("git@")||e.startsWith("https://")||e.startsWith("http://")||e.startsWith("gh:")||e.startsWith("gl:")||e.startsWith("bb:")}function MAt(e){const t=e.replace(/\.git$/,"");if(t.startsWith("git@")){const n=t.match(/:([^/]+\/)?([^/]+)$/);if(n)return n[2]}else if(t.startsWith("gh:")||t.startsWith("gl:")||t.startsWith("bb:")){const n=t.split("/");if(n.length>0)return n[n.length-1]}else{const n=t.split("/");if(n.length>0)return n[n.length-1]}return t}function hOe({open:e,onOpenChange:t,projectId:n,initialTab:r="clone"}){const{t:i}=Dt("repositories"),s=At(),{data:a}=q3(),{data:o}=_u(),l=VSe(),u=NWe(),d=OWe(),f=HSe(),[h,m]=x.useState(null),[b,y]=x.useState(""),[v,_]=x.useState(null),[w,C]=x.useState(!1),[T,k]=x.useState(""),S=n??h,[A,R]=x.useState(r),[I,D]=x.useState(""),[P,j]=x.useState(""),[B,L]=x.useState(""),[M,$]=x.useState(null),[U,W]=x.useState(!1),[Y,G]=x.useState(""),[q,X]=x.useState(null),[z,Q]=x.useState(!1),[ee,ne]=x.useState(""),[ae,fe]=x.useState(null),[re,de]=x.useState(new Set),[he,ce]=x.useState(null),[ye,be]=x.useState(!1),[ue,Ae]=x.useState(""),[le,ke]=x.useState(""),[Fe,ze]=x.useState({}),[ve,je]=x.useState(""),[we,Le]=x.useState(""),[qe,Re]=x.useState(null),[Ie,se]=x.useState(!0),[Ge,ut]=x.useState(!1),[mt,Ke]=x.useState(new Set),[lt,Ve]=x.useState({open:!1,conflict:null,pendingAction:null}),{data:Ct}=LAt(),Ne=ue||le,{data:Ue,isLoading:st,error:et}=jAt(A==="template"&&Ne?Ne:null);x.useEffect(()=>{e&&(R(r),m(null),y(""),_(null),C(!1),k(""),D(""),j(""),L(""),$(null),G(""),X(null),ne(""),fe(null),de(new Set),ce(null),Ae(""),ke(""),ze({}),je(a||""),Le(""),Re(null),se(!0),Ke(new Set))},[e,r,a]);const pt=x.useMemo(()=>I.trim()?MAt(I.trim()):null,[I]);x.useEffect(()=>{pt&&!B&&L(pt)},[pt,B]);const wt=P.trim()||a||"",Et=ee.trim()||a||"",Se=x.useMemo(()=>{if(!I.trim()||!wt)return null;const tt=B.trim()||pt||"";return tt?`${wt}/${tt}`:null},[I,wt,B,pt]),Oe=x.useMemo(()=>ae?.filter(tt=>!tt.hasProject)??[],[ae]),Qe=l.isPending&&A==="clone",It=l.isPending&&A==="local",_t=u.isPending||d.isPending,rn=l.isPending&&A==="template",an=x.useMemo(()=>{if(!o)return[];if(!b.trim())return o;const tt=b.toLowerCase();return o.filter(Mn=>Mn.name.toLowerCase().includes(tt))},[o,b]),vn=o?.find(tt=>tt.id===h),zt=async()=>{if(T.trim()){_(null);try{const tt=await f.mutateAsync({name:T.trim()});m(tt.id),C(!1),k("")}catch(tt){_(tt instanceof Error?tt.message:"Failed to create project")}}};x.useEffect(()=>{Ue?.questions&&ze(tt=>{const Mn={...tt};for(const An of Ue.questions)Mn[An.name]===void 0&&An.default!==void 0&&(Mn[An.name]=An.default);return Mn})},[Ue]),x.useEffect(()=>{a&&!ve&&je(a)},[a,ve]);const sn=Ue?.questions.filter(tt=>{if(tt.default!==void 0&&!(typeof tt.default=="string"&&tt.default.includes("{{")))return!1;const An=Fe[tt.name];return An==null||An===""})??[],Ln=Ne&&we.trim()&&ve.trim()&&!st&&sn.length===0,vr=async(tt=!1)=>{if(!S){_("Please select a project first");return}$(null),_(null);const Mn=I.trim();if(!(!Mn||!X6(Mn)))try{await l.mutateAsync({projectId:S,url:Mn,targetDir:P.trim()||void 0,folderName:B.trim()||void 0,moveFromProject:tt}),t(!1)}catch(An){const Fr=An;Fr.conflict?.conflictProject?Ve({open:!0,conflict:Fr.conflict,pendingAction:()=>vr(!0)}):$(Fr.message||i("addModal.cloneFailed"))}},Mr=async(tt=!1)=>{if(!S){_("Please select a project first");return}X(null),_(null);const Mn=Y.trim();if(Mn)try{await l.mutateAsync({projectId:S,path:Mn,moveFromProject:tt}),t(!1)}catch(An){const Fr=An;Fr.conflict?.conflictProject?Ve({open:!0,conflict:Fr.conflict,pendingAction:()=>Mr(!0)}):X(Fr.message||i("addModal.createFailed"))}},oi=()=>{ce(null),fe(null),de(new Set),u.mutate(Et||void 0,{onSuccess:tt=>{fe(tt.repositories);const Mn=tt.repositories.filter(An=>!An.hasProject);de(new Set(Mn.map(An=>An.path)))},onError:tt=>{ce(tt instanceof Error?tt.message:i("bulkAdd.scanFailed"))}})},gs=tt=>{de(Mn=>{const An=new Set(Mn);return An.has(tt)?An.delete(tt):An.add(tt),An})},xi=()=>{de(new Set(Oe.map(tt=>tt.path)))},dr=()=>{de(new Set)},fr=async()=>{if(!S){_("Please select a project first");return}if(re.size===0)return;ce(null),_(null);let tt=0,Mn=0;for(const An of re)try{await l.mutateAsync({projectId:S,path:An}),tt++}catch{Mn++}Mn>0?ce(`Added ${tt} repositories, ${Mn} failed`):t(!1)},Fi=!!ue||Ie,Ai=async()=>{if(!S){_("Please select a project first");return}Re(null),_(null);try{await ct("/api/copier/create",{method:"POST",body:JSON.stringify({templateSource:Ne,outputPath:ve,answers:Fe,projectName:we,trust:Fi,existingProjectId:S})}),await Promise.all([s.invalidateQueries({queryKey:["projects"]}),s.invalidateQueries({queryKey:["repositories"]})]),t(!1)}catch(tt){Re(tt instanceof Error?tt.message:"Failed to create from template")}},Ki=tt=>{const Mn=Fe[tt.name],An=li=>ze(kr=>({...kr,[tt.name]:li})),ss=tt.default===void 0||typeof tt.default=="string"&&tt.default.includes("{{")?`${tt.name} *`:tt.name;switch(tt.type){case"bool":return c.jsxs(Gn,{children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(Ci,{checked:Mn,onCheckedChange:An}),c.jsx(Kn,{className:"cursor-pointer",children:ss})]}),tt.help&&c.jsx(es,{children:tt.help})]},tt.name);case"int":case"float":return c.jsxs(Gn,{children:[c.jsx(Kn,{children:ss}),c.jsx(kt,{type:"number",value:Mn,onChange:li=>An(tt.type==="int"?parseInt(li.target.value):parseFloat(li.target.value)),step:tt.type==="float"?"any":1}),tt.help&&c.jsx(es,{children:tt.help})]},tt.name);default:{if(tt.choices&&tt.choices.length>0)return c.jsxs(Gn,{children:[c.jsx(Kn,{children:ss}),c.jsxs(Vr,{value:String(Mn??""),onValueChange:An,children:[c.jsx(qr,{className:"w-full",children:c.jsx(Wr,{})}),c.jsx(Gr,{children:tt.choices.map(hr=>c.jsx(Kt,{value:String(hr.value),children:hr.label},String(hr.value)))})]}),tt.help&&c.jsx(es,{children:tt.help})]},tt.name);const li=tt.type==="yaml"||tt.type==="json",kr=tt.name.toLowerCase().includes("password"),ei=mt.has(tt.name);return c.jsxs(Gn,{children:[c.jsx(Kn,{children:ss}),li?c.jsx(dd,{value:String(Mn??""),onChange:hr=>An(hr.target.value),rows:4}):kr?c.jsxs("div",{className:"relative",children:[c.jsx(kt,{type:ei?"text":"password",value:String(Mn??""),onChange:hr=>An(hr.target.value),className:"pr-8"}),c.jsx("button",{type:"button",className:"absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",onClick:()=>{Ke(hr=>{const Br=new Set(hr);return Br.has(tt.name)?Br.delete(tt.name):Br.add(tt.name),Br})},children:c.jsx(J,{icon:ei?a_e:PV,size:14,strokeWidth:2})})]}):c.jsx(kt,{value:String(Mn??""),onChange:hr=>An(hr.target.value)}),tt.help&&c.jsx(es,{children:tt.help})]},tt.name)}}},vo=()=>{t(!1)},Yi=()=>n?null:c.jsxs("div",{className:"space-y-2 border-t border-border pt-4",children:[c.jsx(Kr,{children:"Add to Project"}),w?c.jsxs("div",{className:"flex gap-2",children:[c.jsx(kt,{value:T,onChange:tt=>k(tt.target.value),placeholder:"New project name...",autoFocus:!0,onKeyDown:tt=>{tt.key==="Enter"?(tt.preventDefault(),zt()):tt.key==="Escape"&&(C(!1),k(""))},disabled:f.isPending}),c.jsx(Ce,{size:"sm",onClick:zt,disabled:!T.trim()||f.isPending,children:f.isPending?c.jsx(J,{icon:Rt,size:14,strokeWidth:2,className:"animate-spin"}):"Create"}),c.jsx(Ce,{size:"sm",variant:"outline",onClick:()=>{C(!1),k("")},disabled:f.isPending,children:"Cancel"})]}):c.jsxs(c2,{value:h,onValueChange:tt=>{m(tt),_(null)},children:[c.jsx(d2,{placeholder:vn?.name||"Select a project...",value:b,onChange:tt=>y(tt.target.value),className:"w-full"}),c.jsxs(f2,{children:[c.jsxs(h2,{children:[c.jsx(W3,{children:"No projects found"}),an.map(tt=>c.jsx(tx,{value:tt.id,children:tt.name},tt.id))]}),c.jsx("div",{className:"border-t p-1",children:c.jsxs("button",{type:"button",className:"flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-xs hover:bg-accent hover:text-accent-foreground",onClick:()=>{C(!0),y("")},children:[c.jsx(J,{icon:mu,size:14,strokeWidth:2}),"Create new project"]})})]})]}),v&&c.jsxs("div",{className:"flex items-center gap-2 text-xs text-destructive",children:[c.jsx(J,{icon:Pr,size:12,strokeWidth:2}),v]})]});return c.jsxs(c.Fragment,{children:[c.jsx(Va,{open:e,onOpenChange:t,children:c.jsxs(Wa,{className:"sm:max-w-2xl max-h-[80dvh] flex flex-col overflow-hidden",children:[c.jsx(Po,{className:"shrink-0",children:c.jsx(jo,{children:i("addRepository")})}),c.jsx("div",{className:"flex-1 overflow-y-auto min-h-0 px-1",children:c.jsx("div",{className:"space-y-4",children:c.jsxs(Jo,{value:A,onValueChange:R,children:[c.jsxs(el,{className:"w-full",children:[c.jsx(Bn,{value:"clone",className:"flex-1",children:"Clone"}),c.jsx(Bn,{value:"local",className:"flex-1",children:"Local"}),c.jsx(Bn,{value:"scan",className:"flex-1",children:i("addModal.tabs.scan")}),c.jsx(Bn,{value:"template",className:"flex-1",children:i("addModal.tabs.template")})]}),c.jsxs(Un,{value:"clone",className:"space-y-4 pt-4",children:[c.jsxs("div",{className:"space-y-2",children:[c.jsx(Kr,{children:"Git URL"}),c.jsxs("div",{className:"relative",children:[c.jsx(kt,{value:I,onChange:tt=>{D(tt.target.value),$(null),X6(tt.target.value.trim())||L("")},placeholder:"https://github.com/user/repo.git",disabled:Qe,className:"pr-8"}),I&&c.jsx("div",{className:"absolute right-2 top-1/2 -translate-y-1/2",children:c.jsx(J,{icon:ky,size:14,strokeWidth:2,className:"text-muted-foreground"})})]})]}),I.trim()&&c.jsxs("div",{className:"space-y-3 rounded-md border border-border bg-muted/30 p-3",children:[c.jsx("div",{className:"text-xs font-medium text-muted-foreground",children:"Clone Options"}),c.jsxs("div",{className:"space-y-1",children:[c.jsx(Kr,{className:"text-xs",children:"Clone to directory"}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx(kt,{value:P,onChange:tt=>j(tt.target.value),placeholder:a||"~/",disabled:Qe,className:"flex-1 text-xs"}),c.jsx(Ce,{type:"button",variant:"outline",size:"sm",onClick:()=>W(!0),disabled:Qe,children:"Browse"})]})]}),c.jsxs("div",{className:"space-y-1",children:[c.jsx(Kr,{className:"text-xs",children:"Folder name"}),c.jsx(kt,{value:B,onChange:tt=>L(tt.target.value),placeholder:pt||"",disabled:Qe,className:"text-xs"})]}),Se&&c.jsxs("div",{className:"rounded-md bg-background px-3 py-2 text-xs text-muted-foreground",children:["Will clone to: ",c.jsx("span",{className:"font-mono",children:Se})]})]}),Qe&&c.jsxs("div",{className:"flex items-center justify-center gap-2 py-2 text-sm text-muted-foreground",children:[c.jsx(J,{icon:Rt,size:16,strokeWidth:2,className:"animate-spin"}),"Cloning repository..."]}),M&&c.jsxs("div",{className:"flex items-start gap-2 rounded-md bg-destructive/10 px-3 py-2 text-xs text-destructive",children:[c.jsx(J,{icon:Pr,size:14,strokeWidth:2,className:"mt-0.5 shrink-0"}),c.jsx("span",{children:M})]}),Yi(),c.jsxs("div",{className:"flex justify-end gap-2",children:[c.jsx(Ce,{variant:"outline",onClick:vo,disabled:Qe,children:i("addModal.cancel")}),c.jsx(Ce,{onClick:()=>vr(!1),disabled:!I.trim()||!X6(I.trim())||Qe||!S,children:Qe?c.jsxs(c.Fragment,{children:[c.jsx(J,{icon:Rt,size:16,strokeWidth:2,className:"animate-spin"}),"Cloning..."]}):"Clone & Add"})]})]}),c.jsxs(Un,{value:"local",className:"space-y-4 pt-4",children:[c.jsxs("div",{className:"space-y-2",children:[c.jsx(Kr,{children:"Repository path"}),c.jsxs("div",{className:"flex gap-2",children:[c.jsxs("div",{className:"relative flex-1",children:[c.jsx(kt,{value:Y,onChange:tt=>{G(tt.target.value),X(null)},placeholder:"~/code/my-repo",disabled:It,className:"pr-8"}),Y&&c.jsx("div",{className:"absolute right-2 top-1/2 -translate-y-1/2",children:c.jsx(J,{icon:$a,size:14,strokeWidth:2,className:"text-muted-foreground"})})]}),c.jsx(Ce,{type:"button",variant:"outline",size:"sm",onClick:()=>Q(!0),disabled:It,children:"Browse"})]})]}),It&&c.jsxs("div",{className:"flex items-center justify-center gap-2 py-2 text-sm text-muted-foreground",children:[c.jsx(J,{icon:Rt,size:16,strokeWidth:2,className:"animate-spin"}),"Adding repository..."]}),q&&c.jsxs("div",{className:"flex items-start gap-2 rounded-md bg-destructive/10 px-3 py-2 text-xs text-destructive",children:[c.jsx(J,{icon:Pr,size:14,strokeWidth:2,className:"mt-0.5 shrink-0"}),c.jsx("span",{children:q})]}),Yi(),c.jsxs("div",{className:"flex justify-end gap-2",children:[c.jsx(Ce,{variant:"outline",onClick:vo,disabled:It,children:i("addModal.cancel")}),c.jsx(Ce,{onClick:()=>Mr(!1),disabled:!Y.trim()||It||!S,children:It?c.jsxs(c.Fragment,{children:[c.jsx(J,{icon:Rt,size:16,strokeWidth:2,className:"animate-spin"}),"Adding..."]}):i("addModal.add")})]})]}),c.jsxs(Un,{value:"scan",className:"space-y-4 pt-4",children:[c.jsxs("div",{className:"space-y-2",children:[c.jsx(Kr,{children:i("bulkAdd.directoryLabel")}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx(kt,{value:ee,onChange:tt=>{ne(tt.target.value),ce(null),fe(null)},placeholder:a||i("bulkAdd.directoryPlaceholder"),disabled:_t,className:"flex-1"}),c.jsx(Ce,{type:"button",variant:"outline",size:"sm",onClick:()=>be(!0),disabled:_t,children:i("bulkAdd.browse")}),c.jsxs(Ce,{type:"button",size:"sm",onClick:oi,disabled:_t||!Et,children:[u.isPending?c.jsx(J,{icon:Rt,size:16,strokeWidth:2,className:"animate-spin"}):c.jsx(J,{icon:np,size:16,strokeWidth:2}),i("bulkAdd.scan")]})]})]}),ae!==null&&c.jsxs("div",{className:"space-y-2",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx(Kr,{className:"text-xs",children:i("bulkAdd.foundRepos",{count:ae.length})}),Oe.length>0&&c.jsxs("div",{className:"flex gap-2 text-xs",children:[c.jsx("button",{type:"button",className:"text-primary hover:underline",onClick:xi,disabled:_t,children:i("bulkAdd.selectAll")}),c.jsx("span",{className:"text-muted-foreground",children:"/"}),c.jsx("button",{type:"button",className:"text-primary hover:underline",onClick:dr,disabled:_t,children:i("bulkAdd.selectNone")})]})]}),ae.length===0?c.jsx("div",{className:"rounded-md bg-muted/50 px-3 py-4 text-center text-sm text-muted-foreground",children:i("bulkAdd.noReposFound")}):c.jsx("div",{className:"max-h-64 overflow-y-auto rounded-md border",children:ae.map(tt=>c.jsxs("div",{className:`flex items-center gap-3 border-b px-3 py-2 last:border-b-0 ${tt.hasProject?"bg-muted/30 opacity-60":""}`,children:[c.jsx(Ci,{checked:re.has(tt.path),onCheckedChange:()=>gs(tt.path),disabled:tt.hasProject||_t}),c.jsx(J,{icon:tt.hasProject?gu:$a,size:16,strokeWidth:2,className:tt.hasProject?"text-green-500":"text-muted-foreground"}),c.jsxs("div",{className:"min-w-0 flex-1",children:[c.jsx("div",{className:"truncate text-sm font-medium",children:tt.name}),c.jsx("div",{className:"truncate text-xs text-muted-foreground",children:tt.path})]}),tt.hasProject&&c.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:i("bulkAdd.alreadyAdded")})]},tt.path))})]}),l.isPending&&A==="scan"&&c.jsxs("div",{className:"flex items-center justify-center gap-2 py-2 text-sm text-muted-foreground",children:[c.jsx(J,{icon:Rt,size:16,strokeWidth:2,className:"animate-spin"}),i("bulkAdd.adding")]}),he&&c.jsxs("div",{className:"flex items-start gap-2 rounded-md bg-destructive/10 px-3 py-2 text-xs text-destructive",children:[c.jsx(J,{icon:Pr,size:14,strokeWidth:2,className:"mt-0.5 shrink-0"}),c.jsx("span",{children:he})]}),Yi(),re.size>0&&c.jsx(Ce,{onClick:fr,disabled:re.size===0||_t||l.isPending||!S,className:"w-full",children:i("bulkAdd.addSelected",{count:re.size})})]}),c.jsxs(Un,{value:"template",className:"space-y-4 pt-4",children:[c.jsxs("div",{className:"space-y-1",children:[c.jsx("div",{className:"text-xs font-medium text-muted-foreground",children:i("newProject.steps.template.sectionTitle")}),c.jsxs("div",{className:"text-xs text-muted-foreground",children:[i("newProject.steps.template.sectionDescription")," ",c.jsx("a",{href:"https://copier.readthedocs.io/",target:"_blank",rel:"noopener noreferrer",className:"underline hover:opacity-80",children:i("newProject.steps.template.learnMore")})]})]}),c.jsxs($h,{children:[c.jsxs(Gn,{children:[c.jsx(Kn,{children:i("newProject.steps.template.savedTemplates")}),c.jsxs("div",{className:"flex gap-2",children:[c.jsxs(Vr,{value:ue,onValueChange:tt=>{Ae(tt??""),ke(""),ze({})},children:[c.jsx(qr,{className:"w-full",children:c.jsx(Wr,{children:ue?Ct?.find(tt=>tt.id===ue)?.displayName:c.jsx("span",{className:"text-muted-foreground",children:i("newProject.steps.template.selectTemplate")})})}),c.jsx(Gr,{children:Ct?.map(tt=>c.jsx(Kt,{value:tt.id,children:tt.displayName},tt.id))})]}),ue&&c.jsx(Ce,{type:"button",variant:"ghost",size:"sm",onClick:()=>{Ae(""),ze({})},disabled:rn,className:"text-muted-foreground hover:text-foreground",children:"Clear"})]})]}),!ue&&c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"text-center text-muted-foreground text-xs py-1",children:i("newProject.steps.template.or")}),c.jsxs(Gn,{children:[c.jsx(Kn,{children:i("newProject.steps.template.customUrl")}),c.jsx(kt,{value:le,onChange:tt=>{ke(tt.target.value),Ae(""),ze({})},placeholder:"https://github.com/user/template or /path/to/template",disabled:rn})]})]})]}),Ne&&c.jsxs("div",{className:"space-y-3 rounded-md border border-border bg-muted/30 p-3",children:[c.jsx("div",{className:"text-xs font-medium text-muted-foreground",children:i("newProject.steps.questions.title")}),st&&c.jsx("div",{className:"flex items-center justify-center py-4",children:c.jsx(J,{icon:Rt,size:20,strokeWidth:2,className:"animate-spin text-muted-foreground"})}),et&&c.jsx("div",{className:"text-destructive text-sm py-2",children:et.message}),Ue&&c.jsx($h,{children:Ue.questions.length===0?c.jsx("div",{className:"text-muted-foreground text-sm py-2",children:i("newProject.steps.questions.noQuestions")}):Ue.questions.map(Ki)})]}),Ne&&!st&&c.jsxs("div",{className:"space-y-3 rounded-md border border-border bg-muted/30 p-3",children:[c.jsx("div",{className:"text-xs font-medium text-muted-foreground",children:i("newProject.steps.output.title")}),c.jsxs(Gn,{children:[c.jsx(Kn,{children:i("newProject.steps.output.projectName")}),c.jsx(kt,{value:we,onChange:tt=>Le(tt.target.value),placeholder:"my-new-project",disabled:rn})]}),c.jsxs(Gn,{children:[c.jsx(Kn,{children:i("newProject.steps.output.outputDirectory")}),c.jsxs(Ce,{type:"button",variant:"outline",className:"w-full justify-start font-normal",onClick:()=>ut(!0),disabled:rn,children:[c.jsx(J,{icon:$a,size:14,strokeWidth:2,className:"mr-2"}),ve||i("newProject.steps.output.selectDirectory")]})]}),we&&ve&&c.jsxs(es,{className:"font-mono text-xs",children:[i("newProject.steps.output.willCreate"),": ",ve,"/",we]})]}),rn&&c.jsxs("div",{className:"flex items-center justify-center gap-2 py-2 text-sm text-muted-foreground",children:[c.jsx(J,{icon:Rt,size:16,strokeWidth:2,className:"animate-spin"}),i("newProject.steps.creating.inProgress")]}),qe&&c.jsxs("div",{className:"flex items-start gap-2 rounded-md bg-destructive/10 px-3 py-2 text-xs text-destructive",children:[c.jsx(J,{icon:Pr,size:14,strokeWidth:2,className:"mt-0.5 shrink-0"}),c.jsx("span",{children:qe})]}),Yi(),c.jsxs("div",{className:"flex items-center justify-between pt-2",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(Ci,{id:"trust-template",checked:Ie,onCheckedChange:tt=>se(tt===!0),disabled:rn}),c.jsx("label",{htmlFor:"trust-template",className:"text-xs text-muted-foreground cursor-pointer",children:i("newProject.steps.output.trust")})]}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx(Ce,{variant:"outline",onClick:vo,disabled:rn,children:i("addModal.cancel")}),c.jsx(Ce,{onClick:Ai,disabled:!Ln||rn||!S,children:"Create & Add"})]})]})]})]})})})]})}),c.jsx(xc,{open:lt.open,onOpenChange:tt=>{tt||Ve({open:!1,conflict:null,pendingAction:null})},children:c.jsxs(_c,{children:[c.jsxs(Sc,{children:[c.jsx(Ec,{children:"Repository Already Assigned"}),c.jsxs(Cc,{children:['This repository is already in project "',lt.conflict?.conflictProject?.name,'". Would you like to move it to this project instead?']})]}),c.jsxs(wc,{children:[c.jsx(kc,{children:"Cancel"}),c.jsx(hg,{onClick:()=>{lt.pendingAction?.(),Ve({open:!1,conflict:null,pendingAction:null})},children:"Move to This Project"})]})]})}),c.jsx(bh,{open:U,onOpenChange:W,onSelect:tt=>{j(tt),W(!1)},initialPath:wt||void 0}),c.jsx(bh,{open:z,onOpenChange:Q,onSelect:tt=>{G(tt),Q(!1)},initialPath:a||void 0}),c.jsx(bh,{open:ye,onOpenChange:be,onSelect:tt=>{ne(tt),be(!1),fe(null),de(new Set)},initialPath:Et||void 0}),c.jsx(bh,{open:Ge,onOpenChange:ut,onSelect:tt=>{je(tt),ut(!1)},initialPath:ve||a||void 0})]})}const FAt=js("/projects/")({component:UAt});function BAt({project:e,onAddRepo:t,onDeleteClick:n}){const{t:r}=Dt("projects"),i=e.repositories.length>0?e.repositories.length:e.repositoryId?1:0;return c.jsxs(Gi,{className:"h-full group transition-colors hover:border-foreground/20",children:[c.jsx(ai,{to:"/projects/$projectId",params:{projectId:e.id},className:"block",children:c.jsxs(za,{className:"flex flex-col items-start gap-3 py-4",children:[c.jsx("span",{className:"truncate font-medium group-hover:text-primary transition-colors",children:e.name}),e.description&&c.jsx("p",{className:"text-xs text-muted-foreground line-clamp-2",children:e.description}),e.tags&&e.tags.length>0&&c.jsxs("div",{className:"flex flex-wrap gap-1",children:[e.tags.slice(0,3).map(s=>c.jsx(jr,{variant:"default",className:"text-[10px] px-1.5 py-0",style:s.color?{backgroundColor:s.color,color:"#fff"}:void 0,children:s.name},s.id)),e.tags.length>3&&c.jsxs(jr,{variant:"default",className:"text-[10px] px-1.5 py-0",children:["+",e.tags.length-3]})]}),c.jsxs("div",{className:"flex items-center gap-3 text-xs text-muted-foreground",children:[c.jsxs("div",{className:"flex items-center gap-1.5",children:[c.jsx(J,{icon:$a,size:14,strokeWidth:2,className:"shrink-0 -translate-y-px"}),c.jsxs("span",{children:[i," ",i===1?"repository":"repositories"]})]}),c.jsxs("div",{className:"flex items-center gap-1.5",children:[c.jsx(J,{icon:B3,size:14,strokeWidth:2,className:"shrink-0 -translate-y-px"}),c.jsxs("span",{children:[e.taskCount??0," active ",e.taskCount===1?"task":"tasks"]})]})]})]})}),c.jsx(za,{className:"flex flex-col items-start pt-0 pb-4",children:c.jsxs("div",{className:"flex flex-wrap gap-1",children:[c.jsxs(Ce,{variant:"outline",size:"sm",onClick:t,className:"text-muted-foreground hover:text-foreground",children:[c.jsx(J,{icon:HB,size:14,strokeWidth:2,"data-slot":"icon"}),c.jsx("span",{className:"max-sm:hidden",children:r("linkRepo")})]}),c.jsxs(Ce,{variant:"outline",size:"sm",onClick:n,className:"text-muted-foreground hover:text-destructive",title:r("delete.button"),children:[c.jsx(J,{icon:ma,size:14,strokeWidth:2,"data-slot":"icon"}),c.jsx("span",{className:"max-sm:hidden",children:r("delete.button")})]})]})})]})}function $At({project:e,open:t,onOpenChange:n,onDelete:r}){const{t:i}=Dt("projects"),[s,a]=x.useState(!1),[o,l]=x.useState(!1),[u,d]=x.useState(!1),f=async()=>{d(!0);try{await r(s,o),n(!1)}finally{d(!1)}};return c.jsx(xc,{open:t,onOpenChange:n,children:c.jsxs(_c,{children:[c.jsxs(Sc,{children:[c.jsx(Ec,{children:i("delete.title")}),c.jsx(Cc,{children:i("delete.description",{name:e?.name})})]}),c.jsxs("div",{className:"space-y-3 py-2",children:[e&&e.repositories.length>0&&c.jsx("div",{className:"rounded-md bg-amber-500/10 px-3 py-2 text-sm text-amber-600",children:i("delete.reposWarning",{count:e.repositories.length})}),e?.repository&&c.jsxs("div",{className:"flex items-center space-x-2",children:[c.jsx(Ci,{id:"deleteDirectory",checked:s,onCheckedChange:h=>a(h===!0)}),c.jsx(Kr,{htmlFor:"deleteDirectory",className:"text-sm",children:i("delete.alsoDeleteDirectory")})]}),e?.app&&c.jsxs("div",{className:"flex items-center space-x-2",children:[c.jsx(Ci,{id:"deleteApp",checked:o,onCheckedChange:h=>l(h===!0)}),c.jsx(Kr,{htmlFor:"deleteApp",className:"text-sm",children:i("delete.alsoDeleteApp")})]})]}),c.jsxs(wc,{children:[c.jsx(kc,{disabled:u,children:"Cancel"}),c.jsx(hg,{onClick:f,disabled:u,className:"bg-destructive hover:bg-destructive/90",children:i(u?"delete.deleting":"delete.button")})]})]})})}function UAt(){const{t:e}=Dt("projects"),t=ji(),{data:n,isLoading:r,error:i}=_u(),s=qSe(),[a,o]=x.useState(null),[l,u]=x.useState(!1),[d,f]=x.useState(!1),[h,m]=x.useState(""),b=x.useMemo(()=>n?h?.trim()?n.map(v=>({project:v,score:Math.max(Sl(v.name,h),Sl(v.repository?.path??"",h),Sl(v.repository?.displayName??"",h))})).filter(({score:v})=>v>0).sort((v,_)=>_.score-v.score).map(({project:v})=>v):n:[],[n,h]),y=async(v,_)=>{a&&await s.mutateAsync({id:a.id,deleteDirectory:v,deleteApp:_})};return c.jsxs("div",{className:"flex h-full flex-col",children:[c.jsxs("div",{className:"film-grain relative flex shrink-0 items-center gap-2 border-b border-border px-4 py-2",style:{background:"var(--gradient-header)"},children:[c.jsxs("div",{className:"relative min-w-0 flex-1 sm:max-w-64 sm:flex-none",children:[c.jsx(J,{icon:np,size:12,strokeWidth:2,className:"absolute left-2 top-1/2 -translate-y-1/2 text-muted-foreground"}),c.jsx(kt,{value:h,onChange:v=>m(v.target.value),placeholder:e("searchPlaceholder"),className:"w-full pl-6"})]}),c.jsx("div",{className:"hidden sm:block flex-1"}),c.jsxs(Ce,{size:"sm",variant:"outline",onClick:()=>f(!0),children:[c.jsx(J,{icon:VB,size:16,strokeWidth:2,"data-slot":"icon"}),c.jsx("span",{className:"max-sm:hidden",children:e("addRepo")})]}),c.jsxs(Ce,{size:"sm",onClick:()=>u(!0),children:[c.jsx(J,{icon:Q1e,size:16,strokeWidth:2,"data-slot":"icon"}),c.jsx("span",{className:"max-sm:hidden",children:e("newProjectButton")})]})]}),c.jsxs("div",{className:"flex-1 overflow-auto p-4",children:[r&&c.jsx("div",{className:"flex items-center justify-center py-12",children:c.jsx(J,{icon:Rt,size:24,strokeWidth:2,className:"animate-spin text-muted-foreground"})}),i&&c.jsxs("div",{className:"flex items-center gap-3 py-6 text-destructive",children:[c.jsx(J,{icon:Pr,size:20,strokeWidth:2}),c.jsx("span",{className:"text-sm",children:e("error.failedToLoad",{message:i.message})})]}),!r&&!i&&n?.length===0&&c.jsx("div",{className:"py-12 text-muted-foreground",children:c.jsx("p",{className:"text-sm",children:e("empty.noProjects")})}),!r&&!i&&n&&n.length>0&&b.length===0&&c.jsx("div",{className:"py-12 text-muted-foreground",children:c.jsx("p",{className:"text-sm",children:e("empty.noMatches")})}),c.jsx("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4",children:b.map(v=>c.jsx(BAt,{project:v,onAddRepo:()=>t({to:"/projects/$projectId",params:{projectId:v.id},search:{addRepo:!0}}),onDeleteClick:()=>o(v)},v.id))})]}),c.jsx($At,{project:a,open:a!==null,onOpenChange:v=>!v&&o(null),onDelete:y}),c.jsx(DAt,{open:l,onOpenChange:u}),c.jsx(hOe,{open:d,onOpenChange:f})]})}var Z6,zce;function al(){if(zce)return Z6;zce=1;var e=Array.isArray;return Z6=e,Z6}var Q6,Hce;function pOe(){if(Hce)return Q6;Hce=1;var e=typeof $T=="object"&&$T&&$T.Object===Object&&$T;return Q6=e,Q6}var J6,Vce;function Sd(){if(Vce)return J6;Vce=1;var e=pOe(),t=typeof self=="object"&&self&&self.Object===Object&&self,n=e||t||Function("return this")();return J6=n,J6}var eM,Wce;function H1(){if(Wce)return eM;Wce=1;var e=Sd(),t=e.Symbol;return eM=t,eM}var tM,qce;function zAt(){if(qce)return tM;qce=1;var e=H1(),t=Object.prototype,n=t.hasOwnProperty,r=t.toString,i=e?e.toStringTag:void 0;function s(a){var o=n.call(a,i),l=a[i];try{a[i]=void 0;var u=!0}catch{}var d=r.call(a);return u&&(o?a[i]=l:delete a[i]),d}return tM=s,tM}var nM,Gce;function HAt(){if(Gce)return nM;Gce=1;var e=Object.prototype,t=e.toString;function n(r){return t.call(r)}return nM=n,nM}var rM,Kce;function fp(){if(Kce)return rM;Kce=1;var e=H1(),t=zAt(),n=HAt(),r="[object Null]",i="[object Undefined]",s=e?e.toStringTag:void 0;function a(o){return o==null?o===void 0?i:r:s&&s in Object(o)?t(o):n(o)}return rM=a,rM}var iM,Yce;function wd(){if(Yce)return iM;Yce=1;function e(t){return t!=null&&typeof t=="object"}return iM=e,iM}var sM,Xce;function V1(){if(Xce)return sM;Xce=1;var e=fp(),t=wd(),n="[object Symbol]";function r(i){return typeof i=="symbol"||t(i)&&e(i)==n}return sM=r,sM}var aM,Zce;function UZ(){if(Zce)return aM;Zce=1;var e=al(),t=V1(),n=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,r=/^\w*$/;function i(s,a){if(e(s))return!1;var o=typeof s;return o=="number"||o=="symbol"||o=="boolean"||s==null||t(s)?!0:r.test(s)||!n.test(s)||a!=null&&s in Object(a)}return aM=i,aM}var oM,Qce;function Ed(){if(Qce)return oM;Qce=1;function e(t){var n=typeof t;return t!=null&&(n=="object"||n=="function")}return oM=e,oM}var lM,Jce;function zZ(){if(Jce)return lM;Jce=1;var e=fp(),t=Ed(),n="[object AsyncFunction]",r="[object Function]",i="[object GeneratorFunction]",s="[object Proxy]";function a(o){if(!t(o))return!1;var l=e(o);return l==r||l==i||l==n||l==s}return lM=a,lM}var uM,ede;function VAt(){if(ede)return uM;ede=1;var e=Sd(),t=e["__core-js_shared__"];return uM=t,uM}var cM,tde;function WAt(){if(tde)return cM;tde=1;var e=VAt(),t=(function(){var r=/[^.]+$/.exec(e&&e.keys&&e.keys.IE_PROTO||"");return r?"Symbol(src)_1."+r:""})();function n(r){return!!t&&t in r}return cM=n,cM}var dM,nde;function mOe(){if(nde)return dM;nde=1;var e=Function.prototype,t=e.toString;function n(r){if(r!=null){try{return t.call(r)}catch{}try{return r+""}catch{}}return""}return dM=n,dM}var fM,rde;function qAt(){if(rde)return fM;rde=1;var e=zZ(),t=WAt(),n=Ed(),r=mOe(),i=/[\\^$.*+?()[\]{}|]/g,s=/^\[object .+?Constructor\]$/,a=Function.prototype,o=Object.prototype,l=a.toString,u=o.hasOwnProperty,d=RegExp("^"+l.call(u).replace(i,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function f(h){if(!n(h)||t(h))return!1;var m=e(h)?d:s;return m.test(r(h))}return fM=f,fM}var hM,ide;function GAt(){if(ide)return hM;ide=1;function e(t,n){return t?.[n]}return hM=e,hM}var pM,sde;function Wy(){if(sde)return pM;sde=1;var e=qAt(),t=GAt();function n(r,i){var s=t(r,i);return e(s)?s:void 0}return pM=n,pM}var mM,ade;function l5(){if(ade)return mM;ade=1;var e=Wy(),t=e(Object,"create");return mM=t,mM}var gM,ode;function KAt(){if(ode)return gM;ode=1;var e=l5();function t(){this.__data__=e?e(null):{},this.size=0}return gM=t,gM}var bM,lde;function YAt(){if(lde)return bM;lde=1;function e(t){var n=this.has(t)&&delete this.__data__[t];return this.size-=n?1:0,n}return bM=e,bM}var yM,ude;function XAt(){if(ude)return yM;ude=1;var e=l5(),t="__lodash_hash_undefined__",n=Object.prototype,r=n.hasOwnProperty;function i(s){var a=this.__data__;if(e){var o=a[s];return o===t?void 0:o}return r.call(a,s)?a[s]:void 0}return yM=i,yM}var vM,cde;function ZAt(){if(cde)return vM;cde=1;var e=l5(),t=Object.prototype,n=t.hasOwnProperty;function r(i){var s=this.__data__;return e?s[i]!==void 0:n.call(s,i)}return vM=r,vM}var xM,dde;function QAt(){if(dde)return xM;dde=1;var e=l5(),t="__lodash_hash_undefined__";function n(r,i){var s=this.__data__;return this.size+=this.has(r)?0:1,s[r]=e&&i===void 0?t:i,this}return xM=n,xM}var _M,fde;function JAt(){if(fde)return _M;fde=1;var e=KAt(),t=YAt(),n=XAt(),r=ZAt(),i=QAt();function s(a){var o=-1,l=a==null?0:a.length;for(this.clear();++o<l;){var u=a[o];this.set(u[0],u[1])}}return s.prototype.clear=e,s.prototype.delete=t,s.prototype.get=n,s.prototype.has=r,s.prototype.set=i,_M=s,_M}var SM,hde;function eNt(){if(hde)return SM;hde=1;function e(){this.__data__=[],this.size=0}return SM=e,SM}var wM,pde;function u5(){if(pde)return wM;pde=1;function e(t,n){return t===n||t!==t&&n!==n}return wM=e,wM}var EM,mde;function c5(){if(mde)return EM;mde=1;var e=u5();function t(n,r){for(var i=n.length;i--;)if(e(n[i][0],r))return i;return-1}return EM=t,EM}var CM,gde;function tNt(){if(gde)return CM;gde=1;var e=c5(),t=Array.prototype,n=t.splice;function r(i){var s=this.__data__,a=e(s,i);if(a<0)return!1;var o=s.length-1;return a==o?s.pop():n.call(s,a,1),--this.size,!0}return CM=r,CM}var kM,bde;function nNt(){if(bde)return kM;bde=1;var e=c5();function t(n){var r=this.__data__,i=e(r,n);return i<0?void 0:r[i][1]}return kM=t,kM}var TM,yde;function rNt(){if(yde)return TM;yde=1;var e=c5();function t(n){return e(this.__data__,n)>-1}return TM=t,TM}var AM,vde;function iNt(){if(vde)return AM;vde=1;var e=c5();function t(n,r){var i=this.__data__,s=e(i,n);return s<0?(++this.size,i.push([n,r])):i[s][1]=r,this}return AM=t,AM}var NM,xde;function d5(){if(xde)return NM;xde=1;var e=eNt(),t=tNt(),n=nNt(),r=rNt(),i=iNt();function s(a){var o=-1,l=a==null?0:a.length;for(this.clear();++o<l;){var u=a[o];this.set(u[0],u[1])}}return s.prototype.clear=e,s.prototype.delete=t,s.prototype.get=n,s.prototype.has=r,s.prototype.set=i,NM=s,NM}var OM,_de;function HZ(){if(_de)return OM;_de=1;var e=Wy(),t=Sd(),n=e(t,"Map");return OM=n,OM}var RM,Sde;function sNt(){if(Sde)return RM;Sde=1;var e=JAt(),t=d5(),n=HZ();function r(){this.size=0,this.__data__={hash:new e,map:new(n||t),string:new e}}return RM=r,RM}var IM,wde;function aNt(){if(wde)return IM;wde=1;function e(t){var n=typeof t;return n=="string"||n=="number"||n=="symbol"||n=="boolean"?t!=="__proto__":t===null}return IM=e,IM}var DM,Ede;function f5(){if(Ede)return DM;Ede=1;var e=aNt();function t(n,r){var i=n.__data__;return e(r)?i[typeof r=="string"?"string":"hash"]:i.map}return DM=t,DM}var PM,Cde;function oNt(){if(Cde)return PM;Cde=1;var e=f5();function t(n){var r=e(this,n).delete(n);return this.size-=r?1:0,r}return PM=t,PM}var jM,kde;function lNt(){if(kde)return jM;kde=1;var e=f5();function t(n){return e(this,n).get(n)}return jM=t,jM}var LM,Tde;function uNt(){if(Tde)return LM;Tde=1;var e=f5();function t(n){return e(this,n).has(n)}return LM=t,LM}var MM,Ade;function cNt(){if(Ade)return MM;Ade=1;var e=f5();function t(n,r){var i=e(this,n),s=i.size;return i.set(n,r),this.size+=i.size==s?0:1,this}return MM=t,MM}var FM,Nde;function VZ(){if(Nde)return FM;Nde=1;var e=sNt(),t=oNt(),n=lNt(),r=uNt(),i=cNt();function s(a){var o=-1,l=a==null?0:a.length;for(this.clear();++o<l;){var u=a[o];this.set(u[0],u[1])}}return s.prototype.clear=e,s.prototype.delete=t,s.prototype.get=n,s.prototype.has=r,s.prototype.set=i,FM=s,FM}var BM,Ode;function gOe(){if(Ode)return BM;Ode=1;var e=VZ(),t="Expected a function";function n(r,i){if(typeof r!="function"||i!=null&&typeof i!="function")throw new TypeError(t);var s=function(){var a=arguments,o=i?i.apply(this,a):a[0],l=s.cache;if(l.has(o))return l.get(o);var u=r.apply(this,a);return s.cache=l.set(o,u)||l,u};return s.cache=new(n.Cache||e),s}return n.Cache=e,BM=n,BM}var $M,Rde;function dNt(){if(Rde)return $M;Rde=1;var e=gOe(),t=500;function n(r){var i=e(r,function(a){return s.size===t&&s.clear(),a}),s=i.cache;return i}return $M=n,$M}var UM,Ide;function fNt(){if(Ide)return UM;Ide=1;var e=dNt(),t=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,n=/\\(\\)?/g,r=e(function(i){var s=[];return i.charCodeAt(0)===46&&s.push(""),i.replace(t,function(a,o,l,u){s.push(l?u.replace(n,"$1"):o||a)}),s});return UM=r,UM}var zM,Dde;function h5(){if(Dde)return zM;Dde=1;function e(t,n){for(var r=-1,i=t==null?0:t.length,s=Array(i);++r<i;)s[r]=n(t[r],r,t);return s}return zM=e,zM}var HM,Pde;function hNt(){if(Pde)return HM;Pde=1;var e=H1(),t=h5(),n=al(),r=V1(),i=e?e.prototype:void 0,s=i?i.toString:void 0;function a(o){if(typeof o=="string")return o;if(n(o))return t(o,a)+"";if(r(o))return s?s.call(o):"";var l=o+"";return l=="0"&&1/o==-1/0?"-0":l}return HM=a,HM}var VM,jde;function bOe(){if(jde)return VM;jde=1;var e=hNt();function t(n){return n==null?"":e(n)}return VM=t,VM}var WM,Lde;function p5(){if(Lde)return WM;Lde=1;var e=al(),t=UZ(),n=fNt(),r=bOe();function i(s,a){return e(s)?s:t(s,a)?[s]:n(r(s))}return WM=i,WM}var qM,Mde;function ek(){if(Mde)return qM;Mde=1;var e=V1();function t(n){if(typeof n=="string"||e(n))return n;var r=n+"";return r=="0"&&1/n==-1/0?"-0":r}return qM=t,qM}var GM,Fde;function m5(){if(Fde)return GM;Fde=1;var e=p5(),t=ek();function n(r,i){i=e(i,r);for(var s=0,a=i.length;r!=null&&s<a;)r=r[t(i[s++])];return s&&s==a?r:void 0}return GM=n,GM}var KM,Bde;function yOe(){if(Bde)return KM;Bde=1;var e=m5();function t(n,r,i){var s=n==null?void 0:e(n,r);return s===void 0?i:s}return KM=t,KM}var pNt=yOe();const Fa=Yn(pNt);var YM,$de;function mNt(){if($de)return YM;$de=1;function e(t){return t==null}return YM=e,YM}var gNt=mNt();const Nn=Yn(gNt);var XM,Ude;function bNt(){if(Ude)return XM;Ude=1;var e=fp(),t=al(),n=wd(),r="[object String]";function i(s){return typeof s=="string"||!t(s)&&n(s)&&e(s)==r}return XM=i,XM}var yNt=bNt();const Gm=Yn(yNt);var vNt=zZ();const cn=Yn(vNt);var xNt=Ed();const W1=Yn(xNt);var ZM={exports:{}},ri={};var zde;function _Nt(){if(zde)return ri;zde=1;var e=Symbol.for("react.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),s=Symbol.for("react.provider"),a=Symbol.for("react.context"),o=Symbol.for("react.server_context"),l=Symbol.for("react.forward_ref"),u=Symbol.for("react.suspense"),d=Symbol.for("react.suspense_list"),f=Symbol.for("react.memo"),h=Symbol.for("react.lazy"),m=Symbol.for("react.offscreen"),b;b=Symbol.for("react.module.reference");function y(v){if(typeof v=="object"&&v!==null){var _=v.$$typeof;switch(_){case e:switch(v=v.type,v){case n:case i:case r:case u:case d:return v;default:switch(v=v&&v.$$typeof,v){case o:case a:case l:case h:case f:case s:return v;default:return _}}case t:return _}}}return ri.ContextConsumer=a,ri.ContextProvider=s,ri.Element=e,ri.ForwardRef=l,ri.Fragment=n,ri.Lazy=h,ri.Memo=f,ri.Portal=t,ri.Profiler=i,ri.StrictMode=r,ri.Suspense=u,ri.SuspenseList=d,ri.isAsyncMode=function(){return!1},ri.isConcurrentMode=function(){return!1},ri.isContextConsumer=function(v){return y(v)===a},ri.isContextProvider=function(v){return y(v)===s},ri.isElement=function(v){return typeof v=="object"&&v!==null&&v.$$typeof===e},ri.isForwardRef=function(v){return y(v)===l},ri.isFragment=function(v){return y(v)===n},ri.isLazy=function(v){return y(v)===h},ri.isMemo=function(v){return y(v)===f},ri.isPortal=function(v){return y(v)===t},ri.isProfiler=function(v){return y(v)===i},ri.isStrictMode=function(v){return y(v)===r},ri.isSuspense=function(v){return y(v)===u},ri.isSuspenseList=function(v){return y(v)===d},ri.isValidElementType=function(v){return typeof v=="string"||typeof v=="function"||v===n||v===i||v===r||v===u||v===d||v===m||typeof v=="object"&&v!==null&&(v.$$typeof===h||v.$$typeof===f||v.$$typeof===s||v.$$typeof===a||v.$$typeof===l||v.$$typeof===b||v.getModuleId!==void 0)},ri.typeOf=y,ri}var Hde;function SNt(){return Hde||(Hde=1,ZM.exports=_Nt()),ZM.exports}var wNt=SNt(),QM,Vde;function vOe(){if(Vde)return QM;Vde=1;var e=fp(),t=wd(),n="[object Number]";function r(i){return typeof i=="number"||t(i)&&e(i)==n}return QM=r,QM}var JM,Wde;function ENt(){if(Wde)return JM;Wde=1;var e=vOe();function t(n){return e(n)&&n!=+n}return JM=t,JM}var CNt=ENt();const bg=Yn(CNt);var kNt=vOe();const xOe=Yn(kNt);var Ba=function(t){return t===0?0:t>0?1:-1},Tb=function(t){return Gm(t)&&t.indexOf("%")===t.length-1},Bt=function(t){return xOe(t)&&!bg(t)},TNt=function(t){return Nn(t)},fa=function(t){return Bt(t)||Gm(t)},ANt=0,hp=function(t){var n=++ANt;return"".concat(t||"").concat(n)},Zo=function(t,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1;if(!Bt(t)&&!Gm(t))return r;var s;if(Tb(t)){var a=t.indexOf("%");s=n*parseFloat(t.slice(0,a))/100}else s=+t;return bg(s)&&(s=r),i&&s>n&&(s=n),s},hm=function(t){if(!t)return null;var n=Object.keys(t);return n&&n.length?t[n[0]]:null},NNt=function(t){if(!Array.isArray(t))return!1;for(var n=t.length,r={},i=0;i<n;i++)if(!r[t[i]])r[t[i]]=!0;else return!0;return!1},nr=function(t,n){return Bt(t)&&Bt(n)?function(r){return t+r*(n-t)}:function(){return n}};function _R(e,t,n){return!e||!e.length?null:e.find(function(r){return r&&(typeof t=="function"?t(r):Fa(r,t))===n})}var ONt=function(t){if(!t||!t.length)return null;for(var n=t.length,r=0,i=0,s=0,a=0,o=1/0,l=-1/0,u=0,d=0,f=0;f<n;f++)u=t[f].cx||0,d=t[f].cy||0,r+=u,i+=d,s+=u*d,a+=u*u,o=Math.min(o,u),l=Math.max(l,u);var h=n*a!==r*r?(n*s-r*i)/(n*a-r*r):0;return{xmin:o,xmax:l,a:h,b:(i-h*r)/n}},RNt=function(t,n){return Bt(t)&&Bt(n)?t-n:Gm(t)&&Gm(n)?t.localeCompare(n):t instanceof Date&&n instanceof Date?t.getTime()-n.getTime():String(t).localeCompare(String(n))};function Yb(e,t){for(var n in e)if({}.hasOwnProperty.call(e,n)&&(!{}.hasOwnProperty.call(t,n)||e[n]!==t[n]))return!1;for(var r in t)if({}.hasOwnProperty.call(t,r)&&!{}.hasOwnProperty.call(e,r))return!1;return!0}function HU(e){"@babel/helpers - typeof";return HU=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},HU(e)}var INt=["viewBox","children"],DNt=["aria-activedescendant","aria-atomic","aria-autocomplete","aria-busy","aria-checked","aria-colcount","aria-colindex","aria-colspan","aria-controls","aria-current","aria-describedby","aria-details","aria-disabled","aria-errormessage","aria-expanded","aria-flowto","aria-haspopup","aria-hidden","aria-invalid","aria-keyshortcuts","aria-label","aria-labelledby","aria-level","aria-live","aria-modal","aria-multiline","aria-multiselectable","aria-orientation","aria-owns","aria-placeholder","aria-posinset","aria-pressed","aria-readonly","aria-relevant","aria-required","aria-roledescription","aria-rowcount","aria-rowindex","aria-rowspan","aria-selected","aria-setsize","aria-sort","aria-valuemax","aria-valuemin","aria-valuenow","aria-valuetext","className","color","height","id","lang","max","media","method","min","name","style","target","width","role","tabIndex","accentHeight","accumulate","additive","alignmentBaseline","allowReorder","alphabetic","amplitude","arabicForm","ascent","attributeName","attributeType","autoReverse","azimuth","baseFrequency","baselineShift","baseProfile","bbox","begin","bias","by","calcMode","capHeight","clip","clipPath","clipPathUnits","clipRule","colorInterpolation","colorInterpolationFilters","colorProfile","colorRendering","contentScriptType","contentStyleType","cursor","cx","cy","d","decelerate","descent","diffuseConstant","direction","display","divisor","dominantBaseline","dur","dx","dy","edgeMode","elevation","enableBackground","end","exponent","externalResourcesRequired","fill","fillOpacity","fillRule","filter","filterRes","filterUnits","floodColor","floodOpacity","focusable","fontFamily","fontSize","fontSizeAdjust","fontStretch","fontStyle","fontVariant","fontWeight","format","from","fx","fy","g1","g2","glyphName","glyphOrientationHorizontal","glyphOrientationVertical","glyphRef","gradientTransform","gradientUnits","hanging","horizAdvX","horizOriginX","href","ideographic","imageRendering","in2","in","intercept","k1","k2","k3","k4","k","kernelMatrix","kernelUnitLength","kerning","keyPoints","keySplines","keyTimes","lengthAdjust","letterSpacing","lightingColor","limitingConeAngle","local","markerEnd","markerHeight","markerMid","markerStart","markerUnits","markerWidth","mask","maskContentUnits","maskUnits","mathematical","mode","numOctaves","offset","opacity","operator","order","orient","orientation","origin","overflow","overlinePosition","overlineThickness","paintOrder","panose1","pathLength","patternContentUnits","patternTransform","patternUnits","pointerEvents","pointsAtX","pointsAtY","pointsAtZ","preserveAlpha","preserveAspectRatio","primitiveUnits","r","radius","refX","refY","renderingIntent","repeatCount","repeatDur","requiredExtensions","requiredFeatures","restart","result","rotate","rx","ry","seed","shapeRendering","slope","spacing","specularConstant","specularExponent","speed","spreadMethod","startOffset","stdDeviation","stemh","stemv","stitchTiles","stopColor","stopOpacity","strikethroughPosition","strikethroughThickness","string","stroke","strokeDasharray","strokeDashoffset","strokeLinecap","strokeLinejoin","strokeMiterlimit","strokeOpacity","strokeWidth","surfaceScale","systemLanguage","tableValues","targetX","targetY","textAnchor","textDecoration","textLength","textRendering","to","transform","u1","u2","underlinePosition","underlineThickness","unicode","unicodeBidi","unicodeRange","unitsPerEm","vAlphabetic","values","vectorEffect","version","vertAdvY","vertOriginX","vertOriginY","vHanging","vIdeographic","viewTarget","visibility","vMathematical","widths","wordSpacing","writingMode","x1","x2","x","xChannelSelector","xHeight","xlinkActuate","xlinkArcrole","xlinkHref","xlinkRole","xlinkShow","xlinkTitle","xlinkType","xmlBase","xmlLang","xmlns","xmlnsXlink","xmlSpace","y1","y2","y","yChannelSelector","z","zoomAndPan","ref","key","angle"],qde=["points","pathLength"],e8={svg:INt,polygon:qde,polyline:qde},WZ=["dangerouslySetInnerHTML","onCopy","onCopyCapture","onCut","onCutCapture","onPaste","onPasteCapture","onCompositionEnd","onCompositionEndCapture","onCompositionStart","onCompositionStartCapture","onCompositionUpdate","onCompositionUpdateCapture","onFocus","onFocusCapture","onBlur","onBlurCapture","onChange","onChangeCapture","onBeforeInput","onBeforeInputCapture","onInput","onInputCapture","onReset","onResetCapture","onSubmit","onSubmitCapture","onInvalid","onInvalidCapture","onLoad","onLoadCapture","onError","onErrorCapture","onKeyDown","onKeyDownCapture","onKeyPress","onKeyPressCapture","onKeyUp","onKeyUpCapture","onAbort","onAbortCapture","onCanPlay","onCanPlayCapture","onCanPlayThrough","onCanPlayThroughCapture","onDurationChange","onDurationChangeCapture","onEmptied","onEmptiedCapture","onEncrypted","onEncryptedCapture","onEnded","onEndedCapture","onLoadedData","onLoadedDataCapture","onLoadedMetadata","onLoadedMetadataCapture","onLoadStart","onLoadStartCapture","onPause","onPauseCapture","onPlay","onPlayCapture","onPlaying","onPlayingCapture","onProgress","onProgressCapture","onRateChange","onRateChangeCapture","onSeeked","onSeekedCapture","onSeeking","onSeekingCapture","onStalled","onStalledCapture","onSuspend","onSuspendCapture","onTimeUpdate","onTimeUpdateCapture","onVolumeChange","onVolumeChangeCapture","onWaiting","onWaitingCapture","onAuxClick","onAuxClickCapture","onClick","onClickCapture","onContextMenu","onContextMenuCapture","onDoubleClick","onDoubleClickCapture","onDrag","onDragCapture","onDragEnd","onDragEndCapture","onDragEnter","onDragEnterCapture","onDragExit","onDragExitCapture","onDragLeave","onDragLeaveCapture","onDragOver","onDragOverCapture","onDragStart","onDragStartCapture","onDrop","onDropCapture","onMouseDown","onMouseDownCapture","onMouseEnter","onMouseLeave","onMouseMove","onMouseMoveCapture","onMouseOut","onMouseOutCapture","onMouseOver","onMouseOverCapture","onMouseUp","onMouseUpCapture","onSelect","onSelectCapture","onTouchCancel","onTouchCancelCapture","onTouchEnd","onTouchEndCapture","onTouchMove","onTouchMoveCapture","onTouchStart","onTouchStartCapture","onPointerDown","onPointerDownCapture","onPointerMove","onPointerMoveCapture","onPointerUp","onPointerUpCapture","onPointerCancel","onPointerCancelCapture","onPointerEnter","onPointerEnterCapture","onPointerLeave","onPointerLeaveCapture","onPointerOver","onPointerOverCapture","onPointerOut","onPointerOutCapture","onGotPointerCapture","onGotPointerCaptureCapture","onLostPointerCapture","onLostPointerCaptureCapture","onScroll","onScrollCapture","onWheel","onWheelCapture","onAnimationStart","onAnimationStartCapture","onAnimationEnd","onAnimationEndCapture","onAnimationIteration","onAnimationIterationCapture","onTransitionEnd","onTransitionEndCapture"],SR=function(t,n){if(!t||typeof t=="function"||typeof t=="boolean")return null;var r=t;if(x.isValidElement(t)&&(r=t.props),!W1(r))return null;var i={};return Object.keys(r).forEach(function(s){WZ.includes(s)&&(i[s]=n||function(a){return r[s](r,a)})}),i},PNt=function(t,n,r){return function(i){return t(n,r,i),null}},pd=function(t,n,r){if(!W1(t)||HU(t)!=="object")return null;var i=null;return Object.keys(t).forEach(function(s){var a=t[s];WZ.includes(s)&&typeof a=="function"&&(i||(i={}),i[s]=PNt(a,n,r))}),i},jNt=["children"],LNt=["children"];function Gde(e,t){if(e==null)return{};var n=MNt(e,t),r,i;if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(i=0;i<s.length;i++)r=s[i],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}function MNt(e,t){if(e==null)return{};var n={};for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r)){if(t.indexOf(r)>=0)continue;n[r]=e[r]}return n}function VU(e){"@babel/helpers - typeof";return VU=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},VU(e)}var Kde={click:"onClick",mousedown:"onMouseDown",mouseup:"onMouseUp",mouseover:"onMouseOver",mousemove:"onMouseMove",mouseout:"onMouseOut",mouseenter:"onMouseEnter",mouseleave:"onMouseLeave",touchcancel:"onTouchCancel",touchend:"onTouchEnd",touchmove:"onTouchMove",touchstart:"onTouchStart",contextmenu:"onContextMenu",dblclick:"onDoubleClick"},Ih=function(t){return typeof t=="string"?t:t?t.displayName||t.name||"Component":""},Yde=null,t8=null,g5=function e(t){if(t===Yde&&Array.isArray(t8))return t8;var n=[];return x.Children.forEach(t,function(r){Nn(r)||(wNt.isFragment(r)?n=n.concat(e(r.props.children)):n.push(r))}),t8=n,Yde=t,n};function lo(e,t){var n=[],r=[];return Array.isArray(t)?r=t.map(function(i){return Ih(i)}):r=[Ih(t)],g5(e).forEach(function(i){var s=Fa(i,"type.displayName")||Fa(i,"type.name");r.indexOf(s)!==-1&&n.push(i)}),n}function Ws(e,t){var n=lo(e,t);return n&&n[0]}var wR=function(t){if(!t||!t.props)return!1;var n=t.props,r=n.width,i=n.height;return!(!Bt(r)||r<=0||!Bt(i)||i<=0)},FNt=["a","altGlyph","altGlyphDef","altGlyphItem","animate","animateColor","animateMotion","animateTransform","circle","clipPath","color-profile","cursor","defs","desc","ellipse","feBlend","feColormatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence","filter","font","font-face","font-face-format","font-face-name","font-face-url","foreignObject","g","glyph","glyphRef","hkern","image","line","lineGradient","marker","mask","metadata","missing-glyph","mpath","path","pattern","polygon","polyline","radialGradient","rect","script","set","stop","style","svg","switch","symbol","text","textPath","title","tref","tspan","use","view","vkern"],_Oe=function(t){return t&&t.type&&Gm(t.type)&&FNt.indexOf(t.type)>=0},SOe=function(t){return t&&VU(t)==="object"&&"clipDot"in t},BNt=function(t,n,r,i){var s,a=(s=e8?.[i])!==null&&s!==void 0?s:[];return n.startsWith("data-")||!cn(t)&&(i&&a.includes(n)||DNt.includes(n))||r&&WZ.includes(n)},wOe=function(t){var n=[];return g5(t).forEach(function(r){_Oe(r)&&n.push(r)}),n},Zt=function(t,n,r){if(!t||typeof t=="function"||typeof t=="boolean")return null;var i=t;if(x.isValidElement(t)&&(i=t.props),!W1(i))return null;var s={};return Object.keys(i).forEach(function(a){var o;BNt((o=i)===null||o===void 0?void 0:o[a],a,n,r)&&(s[a]=i[a])}),s},WU=function e(t,n){if(t===n)return!0;var r=x.Children.count(t);if(r!==x.Children.count(n))return!1;if(r===0)return!0;if(r===1)return Xde(Array.isArray(t)?t[0]:t,Array.isArray(n)?n[0]:n);for(var i=0;i<r;i++){var s=t[i],a=n[i];if(Array.isArray(s)||Array.isArray(a)){if(!e(s,a))return!1}else if(!Xde(s,a))return!1}return!0},Xde=function(t,n){if(Nn(t)&&Nn(n))return!0;if(!Nn(t)&&!Nn(n)){var r=t.props||{},i=r.children,s=Gde(r,jNt),a=n.props||{},o=a.children,l=Gde(a,LNt);return i&&o?Yb(s,l)&&WU(i,o):!i&&!o?Yb(s,l):!1}return!1},Zde=function(t,n){var r=[],i={};return g5(t).forEach(function(s,a){if(_Oe(s))r.push(s);else if(s){var o=Ih(s.type),l=n[o]||{},u=l.handler,d=l.once;if(u&&(!d||!i[o])){var f=u(s,o,a);r.push(f),i[o]=!0}}}),r},$Nt=function(t){var n=t&&t.type;return n&&Kde[n]?Kde[n]:null},UNt=function(t,n){return g5(n).indexOf(t)},zNt=["children","width","height","viewBox","className","style","title","desc"];function qU(){return qU=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},qU.apply(this,arguments)}function HNt(e,t){if(e==null)return{};var n=VNt(e,t),r,i;if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(i=0;i<s.length;i++)r=s[i],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}function VNt(e,t){if(e==null)return{};var n={};for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r)){if(t.indexOf(r)>=0)continue;n[r]=e[r]}return n}function ZE(e){var t=e.children,n=e.width,r=e.height,i=e.viewBox,s=e.className,a=e.style,o=e.title,l=e.desc,u=HNt(e,zNt),d=i||{width:n,height:r,x:0,y:0},f=Tn("recharts-surface",s);return Z.createElement("svg",qU({},Zt(u,!0,"svg"),{className:f,width:n,height:r,style:a,viewBox:"".concat(d.x," ").concat(d.y," ").concat(d.width," ").concat(d.height)}),Z.createElement("title",null,o),Z.createElement("desc",null,l),t)}var WNt=["children","className"];function GU(){return GU=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},GU.apply(this,arguments)}function qNt(e,t){if(e==null)return{};var n=GNt(e,t),r,i;if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(i=0;i<s.length;i++)r=s[i],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}function GNt(e,t){if(e==null)return{};var n={};for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r)){if(t.indexOf(r)>=0)continue;n[r]=e[r]}return n}var Sn=Z.forwardRef(function(e,t){var n=e.children,r=e.className,i=qNt(e,WNt),s=Tn("recharts-layer",r);return Z.createElement("g",GU({className:s},Zt(i,!0),{ref:t}),n)}),ld=function(t,n){for(var r=arguments.length,i=new Array(r>2?r-2:0),s=2;s<r;s++)i[s-2]=arguments[s]},n8,Qde;function EOe(){if(Qde)return n8;Qde=1;function e(t,n,r){var i=-1,s=t.length;n<0&&(n=-n>s?0:s+n),r=r>s?s:r,r<0&&(r+=s),s=n>r?0:r-n>>>0,n>>>=0;for(var a=Array(s);++i<s;)a[i]=t[i+n];return a}return n8=e,n8}var r8,Jde;function KNt(){if(Jde)return r8;Jde=1;var e=EOe();function t(n,r,i){var s=n.length;return i=i===void 0?s:i,!r&&i>=s?n:e(n,r,i)}return r8=t,r8}var i8,efe;function COe(){if(efe)return i8;efe=1;var e="\\ud800-\\udfff",t="\\u0300-\\u036f",n="\\ufe20-\\ufe2f",r="\\u20d0-\\u20ff",i=t+n+r,s="\\ufe0e\\ufe0f",a="\\u200d",o=RegExp("["+a+e+i+s+"]");function l(u){return o.test(u)}return i8=l,i8}var s8,tfe;function YNt(){if(tfe)return s8;tfe=1;function e(t){return t.split("")}return s8=e,s8}var a8,nfe;function XNt(){if(nfe)return a8;nfe=1;var e="\\ud800-\\udfff",t="\\u0300-\\u036f",n="\\ufe20-\\ufe2f",r="\\u20d0-\\u20ff",i=t+n+r,s="\\ufe0e\\ufe0f",a="["+e+"]",o="["+i+"]",l="\\ud83c[\\udffb-\\udfff]",u="(?:"+o+"|"+l+")",d="[^"+e+"]",f="(?:\\ud83c[\\udde6-\\uddff]){2}",h="[\\ud800-\\udbff][\\udc00-\\udfff]",m="\\u200d",b=u+"?",y="["+s+"]?",v="(?:"+m+"(?:"+[d,f,h].join("|")+")"+y+b+")*",_=y+b+v,w="(?:"+[d+o+"?",o,f,h,a].join("|")+")",C=RegExp(l+"(?="+l+")|"+w+_,"g");function T(k){return k.match(C)||[]}return a8=T,a8}var o8,rfe;function ZNt(){if(rfe)return o8;rfe=1;var e=YNt(),t=COe(),n=XNt();function r(i){return t(i)?n(i):e(i)}return o8=r,o8}var l8,ife;function QNt(){if(ife)return l8;ife=1;var e=KNt(),t=COe(),n=ZNt(),r=bOe();function i(s){return function(a){a=r(a);var o=t(a)?n(a):void 0,l=o?o[0]:a.charAt(0),u=o?e(o,1).join(""):a.slice(1);return l[s]()+u}}return l8=i,l8}var u8,sfe;function JNt(){if(sfe)return u8;sfe=1;var e=QNt(),t=e("toUpperCase");return u8=t,u8}var eOt=JNt();const b5=Yn(eOt);function Di(e){return function(){return e}}const kOe=Math.cos,ER=Math.sin,Cd=Math.sqrt,CR=Math.PI,y5=2*CR,KU=Math.PI,YU=2*KU,ab=1e-6,tOt=YU-ab;function TOe(e){this._+=e[0];for(let t=1,n=e.length;t<n;++t)this._+=arguments[t]+e[t]}function nOt(e){let t=Math.floor(e);if(!(t>=0))throw new Error(`invalid digits: ${e}`);if(t>15)return TOe;const n=10**t;return function(r){this._+=r[0];for(let i=1,s=r.length;i<s;++i)this._+=Math.round(arguments[i]*n)/n+r[i]}}class rOt{constructor(t){this._x0=this._y0=this._x1=this._y1=null,this._="",this._append=t==null?TOe:nOt(t)}moveTo(t,n){this._append`M${this._x0=this._x1=+t},${this._y0=this._y1=+n}`}closePath(){this._x1!==null&&(this._x1=this._x0,this._y1=this._y0,this._append`Z`)}lineTo(t,n){this._append`L${this._x1=+t},${this._y1=+n}`}quadraticCurveTo(t,n,r,i){this._append`Q${+t},${+n},${this._x1=+r},${this._y1=+i}`}bezierCurveTo(t,n,r,i,s,a){this._append`C${+t},${+n},${+r},${+i},${this._x1=+s},${this._y1=+a}`}arcTo(t,n,r,i,s){if(t=+t,n=+n,r=+r,i=+i,s=+s,s<0)throw new Error(`negative radius: ${s}`);let a=this._x1,o=this._y1,l=r-t,u=i-n,d=a-t,f=o-n,h=d*d+f*f;if(this._x1===null)this._append`M${this._x1=t},${this._y1=n}`;else if(h>ab)if(!(Math.abs(f*l-u*d)>ab)||!s)this._append`L${this._x1=t},${this._y1=n}`;else{let m=r-a,b=i-o,y=l*l+u*u,v=m*m+b*b,_=Math.sqrt(y),w=Math.sqrt(h),C=s*Math.tan((KU-Math.acos((y+h-v)/(2*_*w)))/2),T=C/w,k=C/_;Math.abs(T-1)>ab&&this._append`L${t+T*d},${n+T*f}`,this._append`A${s},${s},0,0,${+(f*m>d*b)},${this._x1=t+k*l},${this._y1=n+k*u}`}}arc(t,n,r,i,s,a){if(t=+t,n=+n,r=+r,a=!!a,r<0)throw new Error(`negative radius: ${r}`);let o=r*Math.cos(i),l=r*Math.sin(i),u=t+o,d=n+l,f=1^a,h=a?i-s:s-i;this._x1===null?this._append`M${u},${d}`:(Math.abs(this._x1-u)>ab||Math.abs(this._y1-d)>ab)&&this._append`L${u},${d}`,r&&(h<0&&(h=h%YU+YU),h>tOt?this._append`A${r},${r},0,1,${f},${t-o},${n-l}A${r},${r},0,1,${f},${this._x1=u},${this._y1=d}`:h>ab&&this._append`A${r},${r},0,${+(h>=KU)},${f},${this._x1=t+r*Math.cos(s)},${this._y1=n+r*Math.sin(s)}`)}rect(t,n,r,i){this._append`M${this._x0=this._x1=+t},${this._y0=this._y1=+n}h${r=+r}v${+i}h${-r}Z`}toString(){return this._}}function qZ(e){let t=3;return e.digits=function(n){if(!arguments.length)return t;if(n==null)t=null;else{const r=Math.floor(n);if(!(r>=0))throw new RangeError(`invalid digits: ${n}`);t=r}return e},()=>new rOt(t)}function GZ(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function AOe(e){this._context=e}AOe.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._point=0},lineEnd:function(){(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;default:this._context.lineTo(e,t);break}}};function v5(e){return new AOe(e)}function NOe(e){return e[0]}function OOe(e){return e[1]}function ROe(e,t){var n=Di(!0),r=null,i=v5,s=null,a=qZ(o);e=typeof e=="function"?e:e===void 0?NOe:Di(e),t=typeof t=="function"?t:t===void 0?OOe:Di(t);function o(l){var u,d=(l=GZ(l)).length,f,h=!1,m;for(r==null&&(s=i(m=a())),u=0;u<=d;++u)!(u<d&&n(f=l[u],u,l))===h&&((h=!h)?s.lineStart():s.lineEnd()),h&&s.point(+e(f,u,l),+t(f,u,l));if(m)return s=null,m+""||null}return o.x=function(l){return arguments.length?(e=typeof l=="function"?l:Di(+l),o):e},o.y=function(l){return arguments.length?(t=typeof l=="function"?l:Di(+l),o):t},o.defined=function(l){return arguments.length?(n=typeof l=="function"?l:Di(!!l),o):n},o.curve=function(l){return arguments.length?(i=l,r!=null&&(s=i(r)),o):i},o.context=function(l){return arguments.length?(l==null?r=s=null:s=i(r=l),o):r},o}function qA(e,t,n){var r=null,i=Di(!0),s=null,a=v5,o=null,l=qZ(u);e=typeof e=="function"?e:e===void 0?NOe:Di(+e),t=typeof t=="function"?t:Di(t===void 0?0:+t),n=typeof n=="function"?n:n===void 0?OOe:Di(+n);function u(f){var h,m,b,y=(f=GZ(f)).length,v,_=!1,w,C=new Array(y),T=new Array(y);for(s==null&&(o=a(w=l())),h=0;h<=y;++h){if(!(h<y&&i(v=f[h],h,f))===_)if(_=!_)m=h,o.areaStart(),o.lineStart();else{for(o.lineEnd(),o.lineStart(),b=h-1;b>=m;--b)o.point(C[b],T[b]);o.lineEnd(),o.areaEnd()}_&&(C[h]=+e(v,h,f),T[h]=+t(v,h,f),o.point(r?+r(v,h,f):C[h],n?+n(v,h,f):T[h]))}if(w)return o=null,w+""||null}function d(){return ROe().defined(i).curve(a).context(s)}return u.x=function(f){return arguments.length?(e=typeof f=="function"?f:Di(+f),r=null,u):e},u.x0=function(f){return arguments.length?(e=typeof f=="function"?f:Di(+f),u):e},u.x1=function(f){return arguments.length?(r=f==null?null:typeof f=="function"?f:Di(+f),u):r},u.y=function(f){return arguments.length?(t=typeof f=="function"?f:Di(+f),n=null,u):t},u.y0=function(f){return arguments.length?(t=typeof f=="function"?f:Di(+f),u):t},u.y1=function(f){return arguments.length?(n=f==null?null:typeof f=="function"?f:Di(+f),u):n},u.lineX0=u.lineY0=function(){return d().x(e).y(t)},u.lineY1=function(){return d().x(e).y(n)},u.lineX1=function(){return d().x(r).y(t)},u.defined=function(f){return arguments.length?(i=typeof f=="function"?f:Di(!!f),u):i},u.curve=function(f){return arguments.length?(a=f,s!=null&&(o=a(s)),u):a},u.context=function(f){return arguments.length?(f==null?s=o=null:o=a(s=f),u):s},u}class IOe{constructor(t,n){this._context=t,this._x=n}areaStart(){this._line=0}areaEnd(){this._line=NaN}lineStart(){this._point=0}lineEnd(){(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line}point(t,n){switch(t=+t,n=+n,this._point){case 0:{this._point=1,this._line?this._context.lineTo(t,n):this._context.moveTo(t,n);break}case 1:this._point=2;default:{this._x?this._context.bezierCurveTo(this._x0=(this._x0+t)/2,this._y0,this._x0,n,t,n):this._context.bezierCurveTo(this._x0,this._y0=(this._y0+n)/2,t,this._y0,t,n);break}}this._x0=t,this._y0=n}}function iOt(e){return new IOe(e,!0)}function sOt(e){return new IOe(e,!1)}const KZ={draw(e,t){const n=Cd(t/CR);e.moveTo(n,0),e.arc(0,0,n,0,y5)}},aOt={draw(e,t){const n=Cd(t/5)/2;e.moveTo(-3*n,-n),e.lineTo(-n,-n),e.lineTo(-n,-3*n),e.lineTo(n,-3*n),e.lineTo(n,-n),e.lineTo(3*n,-n),e.lineTo(3*n,n),e.lineTo(n,n),e.lineTo(n,3*n),e.lineTo(-n,3*n),e.lineTo(-n,n),e.lineTo(-3*n,n),e.closePath()}},DOe=Cd(1/3),oOt=DOe*2,lOt={draw(e,t){const n=Cd(t/oOt),r=n*DOe;e.moveTo(0,-n),e.lineTo(r,0),e.lineTo(0,n),e.lineTo(-r,0),e.closePath()}},uOt={draw(e,t){const n=Cd(t),r=-n/2;e.rect(r,r,n,n)}},cOt=.8908130915292852,POe=ER(CR/10)/ER(7*CR/10),dOt=ER(y5/10)*POe,fOt=-kOe(y5/10)*POe,hOt={draw(e,t){const n=Cd(t*cOt),r=dOt*n,i=fOt*n;e.moveTo(0,-n),e.lineTo(r,i);for(let s=1;s<5;++s){const a=y5*s/5,o=kOe(a),l=ER(a);e.lineTo(l*n,-o*n),e.lineTo(o*r-l*i,l*r+o*i)}e.closePath()}},c8=Cd(3),pOt={draw(e,t){const n=-Cd(t/(c8*3));e.moveTo(0,n*2),e.lineTo(-c8*n,-n),e.lineTo(c8*n,-n),e.closePath()}},Fu=-.5,Bu=Cd(3)/2,XU=1/Cd(12),mOt=(XU/2+1)*3,gOt={draw(e,t){const n=Cd(t/mOt),r=n/2,i=n*XU,s=r,a=n*XU+n,o=-s,l=a;e.moveTo(r,i),e.lineTo(s,a),e.lineTo(o,l),e.lineTo(Fu*r-Bu*i,Bu*r+Fu*i),e.lineTo(Fu*s-Bu*a,Bu*s+Fu*a),e.lineTo(Fu*o-Bu*l,Bu*o+Fu*l),e.lineTo(Fu*r+Bu*i,Fu*i-Bu*r),e.lineTo(Fu*s+Bu*a,Fu*a-Bu*s),e.lineTo(Fu*o+Bu*l,Fu*l-Bu*o),e.closePath()}};function bOt(e,t){let n=null,r=qZ(i);e=typeof e=="function"?e:Di(e||KZ),t=typeof t=="function"?t:Di(t===void 0?64:+t);function i(){let s;if(n||(n=s=r()),e.apply(this,arguments).draw(n,+t.apply(this,arguments)),s)return n=null,s+""||null}return i.type=function(s){return arguments.length?(e=typeof s=="function"?s:Di(s),i):e},i.size=function(s){return arguments.length?(t=typeof s=="function"?s:Di(+s),i):t},i.context=function(s){return arguments.length?(n=s??null,i):n},i}function kR(){}function TR(e,t,n){e._context.bezierCurveTo((2*e._x0+e._x1)/3,(2*e._y0+e._y1)/3,(e._x0+2*e._x1)/3,(e._y0+2*e._y1)/3,(e._x0+4*e._x1+t)/6,(e._y0+4*e._y1+n)/6)}function jOe(e){this._context=e}jOe.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=NaN,this._point=0},lineEnd:function(){switch(this._point){case 3:TR(this,this._x1,this._y1);case 2:this._context.lineTo(this._x1,this._y1);break}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;break;case 2:this._point=3,this._context.lineTo((5*this._x0+this._x1)/6,(5*this._y0+this._y1)/6);default:TR(this,e,t);break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t}};function yOt(e){return new jOe(e)}function LOe(e){this._context=e}LOe.prototype={areaStart:kR,areaEnd:kR,lineStart:function(){this._x0=this._x1=this._x2=this._x3=this._x4=this._y0=this._y1=this._y2=this._y3=this._y4=NaN,this._point=0},lineEnd:function(){switch(this._point){case 1:{this._context.moveTo(this._x2,this._y2),this._context.closePath();break}case 2:{this._context.moveTo((this._x2+2*this._x3)/3,(this._y2+2*this._y3)/3),this._context.lineTo((this._x3+2*this._x2)/3,(this._y3+2*this._y2)/3),this._context.closePath();break}case 3:{this.point(this._x2,this._y2),this.point(this._x3,this._y3),this.point(this._x4,this._y4);break}}},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._x2=e,this._y2=t;break;case 1:this._point=2,this._x3=e,this._y3=t;break;case 2:this._point=3,this._x4=e,this._y4=t,this._context.moveTo((this._x0+4*this._x1+e)/6,(this._y0+4*this._y1+t)/6);break;default:TR(this,e,t);break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t}};function vOt(e){return new LOe(e)}function MOe(e){this._context=e}MOe.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=NaN,this._point=0},lineEnd:function(){(this._line||this._line!==0&&this._point===3)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1;break;case 1:this._point=2;break;case 2:this._point=3;var n=(this._x0+4*this._x1+e)/6,r=(this._y0+4*this._y1+t)/6;this._line?this._context.lineTo(n,r):this._context.moveTo(n,r);break;case 3:this._point=4;default:TR(this,e,t);break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t}};function xOt(e){return new MOe(e)}function FOe(e){this._context=e}FOe.prototype={areaStart:kR,areaEnd:kR,lineStart:function(){this._point=0},lineEnd:function(){this._point&&this._context.closePath()},point:function(e,t){e=+e,t=+t,this._point?this._context.lineTo(e,t):(this._point=1,this._context.moveTo(e,t))}};function _Ot(e){return new FOe(e)}function afe(e){return e<0?-1:1}function ofe(e,t,n){var r=e._x1-e._x0,i=t-e._x1,s=(e._y1-e._y0)/(r||i<0&&-0),a=(n-e._y1)/(i||r<0&&-0),o=(s*i+a*r)/(r+i);return(afe(s)+afe(a))*Math.min(Math.abs(s),Math.abs(a),.5*Math.abs(o))||0}function lfe(e,t){var n=e._x1-e._x0;return n?(3*(e._y1-e._y0)/n-t)/2:t}function d8(e,t,n){var r=e._x0,i=e._y0,s=e._x1,a=e._y1,o=(s-r)/3;e._context.bezierCurveTo(r+o,i+o*t,s-o,a-o*n,s,a)}function AR(e){this._context=e}AR.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=this._t0=NaN,this._point=0},lineEnd:function(){switch(this._point){case 2:this._context.lineTo(this._x1,this._y1);break;case 3:d8(this,this._t0,lfe(this,this._t0));break}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){var n=NaN;if(e=+e,t=+t,!(e===this._x1&&t===this._y1)){switch(this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;break;case 2:this._point=3,d8(this,lfe(this,n=ofe(this,e,t)),n);break;default:d8(this,this._t0,n=ofe(this,e,t));break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t,this._t0=n}}};function BOe(e){this._context=new $Oe(e)}(BOe.prototype=Object.create(AR.prototype)).point=function(e,t){AR.prototype.point.call(this,t,e)};function $Oe(e){this._context=e}$Oe.prototype={moveTo:function(e,t){this._context.moveTo(t,e)},closePath:function(){this._context.closePath()},lineTo:function(e,t){this._context.lineTo(t,e)},bezierCurveTo:function(e,t,n,r,i,s){this._context.bezierCurveTo(t,e,r,n,s,i)}};function SOt(e){return new AR(e)}function wOt(e){return new BOe(e)}function UOe(e){this._context=e}UOe.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x=[],this._y=[]},lineEnd:function(){var e=this._x,t=this._y,n=e.length;if(n)if(this._line?this._context.lineTo(e[0],t[0]):this._context.moveTo(e[0],t[0]),n===2)this._context.lineTo(e[1],t[1]);else for(var r=ufe(e),i=ufe(t),s=0,a=1;a<n;++s,++a)this._context.bezierCurveTo(r[0][s],i[0][s],r[1][s],i[1][s],e[a],t[a]);(this._line||this._line!==0&&n===1)&&this._context.closePath(),this._line=1-this._line,this._x=this._y=null},point:function(e,t){this._x.push(+e),this._y.push(+t)}};function ufe(e){var t,n=e.length-1,r,i=new Array(n),s=new Array(n),a=new Array(n);for(i[0]=0,s[0]=2,a[0]=e[0]+2*e[1],t=1;t<n-1;++t)i[t]=1,s[t]=4,a[t]=4*e[t]+2*e[t+1];for(i[n-1]=2,s[n-1]=7,a[n-1]=8*e[n-1]+e[n],t=1;t<n;++t)r=i[t]/s[t-1],s[t]-=r,a[t]-=r*a[t-1];for(i[n-1]=a[n-1]/s[n-1],t=n-2;t>=0;--t)i[t]=(a[t]-i[t+1])/s[t];for(s[n-1]=(e[n]+i[n-1])/2,t=0;t<n-1;++t)s[t]=2*e[t+1]-i[t+1];return[i,s]}function EOt(e){return new UOe(e)}function x5(e,t){this._context=e,this._t=t}x5.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x=this._y=NaN,this._point=0},lineEnd:function(){0<this._t&&this._t<1&&this._point===2&&this._context.lineTo(this._x,this._y),(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line>=0&&(this._t=1-this._t,this._line=1-this._line)},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;default:{if(this._t<=0)this._context.lineTo(this._x,t),this._context.lineTo(e,t);else{var n=this._x*(1-this._t)+e*this._t;this._context.lineTo(n,this._y),this._context.lineTo(n,t)}break}}this._x=e,this._y=t}};function COt(e){return new x5(e,.5)}function kOt(e){return new x5(e,0)}function TOt(e){return new x5(e,1)}function wx(e,t){if((a=e.length)>1)for(var n=1,r,i,s=e[t[0]],a,o=s.length;n<a;++n)for(i=s,s=e[t[n]],r=0;r<o;++r)s[r][1]+=s[r][0]=isNaN(i[r][1])?i[r][0]:i[r][1]}function ZU(e){for(var t=e.length,n=new Array(t);--t>=0;)n[t]=t;return n}function AOt(e,t){return e[t]}function NOt(e){const t=[];return t.key=e,t}function OOt(){var e=Di([]),t=ZU,n=wx,r=AOt;function i(s){var a=Array.from(e.apply(this,arguments),NOt),o,l=a.length,u=-1,d;for(const f of s)for(o=0,++u;o<l;++o)(a[o][u]=[0,+r(f,a[o].key,u,s)]).data=f;for(o=0,d=GZ(t(a));o<l;++o)a[d[o]].index=o;return n(a,d),a}return i.keys=function(s){return arguments.length?(e=typeof s=="function"?s:Di(Array.from(s)),i):e},i.value=function(s){return arguments.length?(r=typeof s=="function"?s:Di(+s),i):r},i.order=function(s){return arguments.length?(t=s==null?ZU:typeof s=="function"?s:Di(Array.from(s)),i):t},i.offset=function(s){return arguments.length?(n=s??wx,i):n},i}function ROt(e,t){if((r=e.length)>0){for(var n,r,i=0,s=e[0].length,a;i<s;++i){for(a=n=0;n<r;++n)a+=e[n][i][1]||0;if(a)for(n=0;n<r;++n)e[n][i][1]/=a}wx(e,t)}}function IOt(e,t){if((i=e.length)>0){for(var n=0,r=e[t[0]],i,s=r.length;n<s;++n){for(var a=0,o=0;a<i;++a)o+=e[a][n][1]||0;r[n][1]+=r[n][0]=-o/2}wx(e,t)}}function DOt(e,t){if(!(!((a=e.length)>0)||!((s=(i=e[t[0]]).length)>0))){for(var n=0,r=1,i,s,a;r<s;++r){for(var o=0,l=0,u=0;o<a;++o){for(var d=e[t[o]],f=d[r][1]||0,h=d[r-1][1]||0,m=(f-h)/2,b=0;b<o;++b){var y=e[t[b]],v=y[r][1]||0,_=y[r-1][1]||0;m+=v-_}l+=f,u+=m*f}i[r-1][1]+=i[r-1][0]=n,l&&(n-=u/l)}i[r-1][1]+=i[r-1][0]=n,wx(e,t)}}function QE(e){"@babel/helpers - typeof";return QE=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},QE(e)}var POt=["type","size","sizeType"];function QU(){return QU=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},QU.apply(this,arguments)}function cfe(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function dfe(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?cfe(Object(n),!0).forEach(function(r){jOt(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):cfe(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function jOt(e,t,n){return t=LOt(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function LOt(e){var t=MOt(e,"string");return QE(t)=="symbol"?t:t+""}function MOt(e,t){if(QE(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(QE(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function FOt(e,t){if(e==null)return{};var n=BOt(e,t),r,i;if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(i=0;i<s.length;i++)r=s[i],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}function BOt(e,t){if(e==null)return{};var n={};for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r)){if(t.indexOf(r)>=0)continue;n[r]=e[r]}return n}var zOe={symbolCircle:KZ,symbolCross:aOt,symbolDiamond:lOt,symbolSquare:uOt,symbolStar:hOt,symbolTriangle:pOt,symbolWye:gOt},$Ot=Math.PI/180,UOt=function(t){var n="symbol".concat(b5(t));return zOe[n]||KZ},zOt=function(t,n,r){if(n==="area")return t;switch(r){case"cross":return 5*t*t/9;case"diamond":return .5*t*t/Math.sqrt(3);case"square":return t*t;case"star":{var i=18*$Ot;return 1.25*t*t*(Math.tan(i)-Math.tan(i*2)*Math.pow(Math.tan(i),2))}case"triangle":return Math.sqrt(3)*t*t/4;case"wye":return(21-10*Math.sqrt(3))*t*t/8;default:return Math.PI*t*t/4}},HOt=function(t,n){zOe["symbol".concat(b5(t))]=n},tk=function(t){var n=t.type,r=n===void 0?"circle":n,i=t.size,s=i===void 0?64:i,a=t.sizeType,o=a===void 0?"area":a,l=FOt(t,POt),u=dfe(dfe({},l),{},{type:r,size:s,sizeType:o}),d=function(){var v=UOt(r),_=bOt().type(v).size(zOt(s,o,r));return _()},f=u.className,h=u.cx,m=u.cy,b=Zt(u,!0);return h===+h&&m===+m&&s===+s?Z.createElement("path",QU({},b,{className:Tn("recharts-symbols",f),transform:"translate(".concat(h,", ").concat(m,")"),d:d()})):null};tk.registerSymbol=HOt;function Ex(e){"@babel/helpers - typeof";return Ex=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Ex(e)}function JU(){return JU=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},JU.apply(this,arguments)}function ffe(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function VOt(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?ffe(Object(n),!0).forEach(function(r){JE(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ffe(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function WOt(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function qOt(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,VOe(r.key),r)}}function GOt(e,t,n){return t&&qOt(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function KOt(e,t,n){return t=NR(t),YOt(e,HOe()?Reflect.construct(t,n||[],NR(e).constructor):t.apply(e,n))}function YOt(e,t){if(t&&(Ex(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return XOt(e)}function XOt(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function HOe(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(HOe=function(){return!!e})()}function NR(e){return NR=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},NR(e)}function ZOt(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&ez(e,t)}function ez(e,t){return ez=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,i){return r.__proto__=i,r},ez(e,t)}function JE(e,t,n){return t=VOe(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function VOe(e){var t=QOt(e,"string");return Ex(t)=="symbol"?t:t+""}function QOt(e,t){if(Ex(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(Ex(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}var $u=32,YZ=(function(e){function t(){return WOt(this,t),KOt(this,t,arguments)}return ZOt(t,e),GOt(t,[{key:"renderIcon",value:function(r){var i=this.props.inactiveColor,s=$u/2,a=$u/6,o=$u/3,l=r.inactive?i:r.color;if(r.type==="plainline")return Z.createElement("line",{strokeWidth:4,fill:"none",stroke:l,strokeDasharray:r.payload.strokeDasharray,x1:0,y1:s,x2:$u,y2:s,className:"recharts-legend-icon"});if(r.type==="line")return Z.createElement("path",{strokeWidth:4,fill:"none",stroke:l,d:"M0,".concat(s,"h").concat(o,`
|
|
138
138
|
A`).concat(a,",").concat(a,",0,1,1,").concat(2*o,",").concat(s,`
|
|
139
139
|
H`).concat($u,"M").concat(2*o,",").concat(s,`
|
|
140
140
|
A`).concat(a,",").concat(a,",0,1,1,").concat(o,",").concat(s),className:"recharts-legend-icon"});if(r.type==="rect")return Z.createElement("path",{stroke:"none",fill:l,d:"M0,".concat($u/8,"h").concat($u,"v").concat($u*3/4,"h").concat(-$u,"z"),className:"recharts-legend-icon"});if(Z.isValidElement(r.legendIcon)){var u=VOt({},r);return delete u.legendIcon,Z.cloneElement(r.legendIcon,u)}return Z.createElement(tk,{fill:l,cx:s,cy:s,size:$u,sizeType:"diameter",type:r.type})}},{key:"renderItems",value:function(){var r=this,i=this.props,s=i.payload,a=i.iconSize,o=i.layout,l=i.formatter,u=i.inactiveColor,d={x:0,y:0,width:$u,height:$u},f={display:o==="horizontal"?"inline-block":"block",marginRight:10},h={display:"inline-block",verticalAlign:"middle",marginRight:4};return s.map(function(m,b){var y=m.formatter||l,v=Tn(JE(JE({"recharts-legend-item":!0},"legend-item-".concat(b),!0),"inactive",m.inactive));if(m.type==="none")return null;var _=cn(m.value)?null:m.value;ld(!cn(m.value),`The name property is also required when using a function for the dataKey of a chart's cartesian components. Ex: <Bar name="Name of my Data"/>`);var w=m.inactive?u:m.color;return Z.createElement("li",JU({className:v,style:f,key:"legend-item-".concat(b)},pd(r.props,m,b)),Z.createElement(ZE,{width:a,height:a,viewBox:d,style:h},r.renderIcon(m)),Z.createElement("span",{className:"recharts-legend-item-text",style:{color:w}},y?y(_,m,b):_))})}},{key:"render",value:function(){var r=this.props,i=r.payload,s=r.layout,a=r.align;if(!i||!i.length)return null;var o={padding:0,margin:0,textAlign:s==="horizontal"?a:"left"};return Z.createElement("ul",{className:"recharts-default-legend",style:o},this.renderItems())}}])})(x.PureComponent);JE(YZ,"displayName","Legend");JE(YZ,"defaultProps",{iconSize:14,layout:"horizontal",align:"center",verticalAlign:"middle",inactiveColor:"#ccc"});var f8,hfe;function JOt(){if(hfe)return f8;hfe=1;var e=d5();function t(){this.__data__=new e,this.size=0}return f8=t,f8}var h8,pfe;function eRt(){if(pfe)return h8;pfe=1;function e(t){var n=this.__data__,r=n.delete(t);return this.size=n.size,r}return h8=e,h8}var p8,mfe;function tRt(){if(mfe)return p8;mfe=1;function e(t){return this.__data__.get(t)}return p8=e,p8}var m8,gfe;function nRt(){if(gfe)return m8;gfe=1;function e(t){return this.__data__.has(t)}return m8=e,m8}var g8,bfe;function rRt(){if(bfe)return g8;bfe=1;var e=d5(),t=HZ(),n=VZ(),r=200;function i(s,a){var o=this.__data__;if(o instanceof e){var l=o.__data__;if(!t||l.length<r-1)return l.push([s,a]),this.size=++o.size,this;o=this.__data__=new n(l)}return o.set(s,a),this.size=o.size,this}return g8=i,g8}var b8,yfe;function XZ(){if(yfe)return b8;yfe=1;var e=d5(),t=JOt(),n=eRt(),r=tRt(),i=nRt(),s=rRt();function a(o){var l=this.__data__=new e(o);this.size=l.size}return a.prototype.clear=t,a.prototype.delete=n,a.prototype.get=r,a.prototype.has=i,a.prototype.set=s,b8=a,b8}var y8,vfe;function iRt(){if(vfe)return y8;vfe=1;var e="__lodash_hash_undefined__";function t(n){return this.__data__.set(n,e),this}return y8=t,y8}var v8,xfe;function sRt(){if(xfe)return v8;xfe=1;function e(t){return this.__data__.has(t)}return v8=e,v8}var x8,_fe;function WOe(){if(_fe)return x8;_fe=1;var e=VZ(),t=iRt(),n=sRt();function r(i){var s=-1,a=i==null?0:i.length;for(this.__data__=new e;++s<a;)this.add(i[s])}return r.prototype.add=r.prototype.push=t,r.prototype.has=n,x8=r,x8}var _8,Sfe;function qOe(){if(Sfe)return _8;Sfe=1;function e(t,n){for(var r=-1,i=t==null?0:t.length;++r<i;)if(n(t[r],r,t))return!0;return!1}return _8=e,_8}var S8,wfe;function GOe(){if(wfe)return S8;wfe=1;function e(t,n){return t.has(n)}return S8=e,S8}var w8,Efe;function KOe(){if(Efe)return w8;Efe=1;var e=WOe(),t=qOe(),n=GOe(),r=1,i=2;function s(a,o,l,u,d,f){var h=l&r,m=a.length,b=o.length;if(m!=b&&!(h&&b>m))return!1;var y=f.get(a),v=f.get(o);if(y&&v)return y==o&&v==a;var _=-1,w=!0,C=l&i?new e:void 0;for(f.set(a,o),f.set(o,a);++_<m;){var T=a[_],k=o[_];if(u)var S=h?u(k,T,_,o,a,f):u(T,k,_,a,o,f);if(S!==void 0){if(S)continue;w=!1;break}if(C){if(!t(o,function(A,R){if(!n(C,R)&&(T===A||d(T,A,l,u,f)))return C.push(R)})){w=!1;break}}else if(!(T===k||d(T,k,l,u,f))){w=!1;break}}return f.delete(a),f.delete(o),w}return w8=s,w8}var E8,Cfe;function YOe(){if(Cfe)return E8;Cfe=1;var e=Sd(),t=e.Uint8Array;return E8=t,E8}var C8,kfe;function aRt(){if(kfe)return C8;kfe=1;function e(t){var n=-1,r=Array(t.size);return t.forEach(function(i,s){r[++n]=[s,i]}),r}return C8=e,C8}var k8,Tfe;function ZZ(){if(Tfe)return k8;Tfe=1;function e(t){var n=-1,r=Array(t.size);return t.forEach(function(i){r[++n]=i}),r}return k8=e,k8}var T8,Afe;function oRt(){if(Afe)return T8;Afe=1;var e=H1(),t=YOe(),n=u5(),r=KOe(),i=aRt(),s=ZZ(),a=1,o=2,l="[object Boolean]",u="[object Date]",d="[object Error]",f="[object Map]",h="[object Number]",m="[object RegExp]",b="[object Set]",y="[object String]",v="[object Symbol]",_="[object ArrayBuffer]",w="[object DataView]",C=e?e.prototype:void 0,T=C?C.valueOf:void 0;function k(S,A,R,I,D,P,j){switch(R){case w:if(S.byteLength!=A.byteLength||S.byteOffset!=A.byteOffset)return!1;S=S.buffer,A=A.buffer;case _:return!(S.byteLength!=A.byteLength||!P(new t(S),new t(A)));case l:case u:case h:return n(+S,+A);case d:return S.name==A.name&&S.message==A.message;case m:case y:return S==A+"";case f:var B=i;case b:var L=I&a;if(B||(B=s),S.size!=A.size&&!L)return!1;var M=j.get(S);if(M)return M==A;I|=o,j.set(S,A);var $=r(B(S),B(A),I,D,P,j);return j.delete(S),$;case v:if(T)return T.call(S)==T.call(A)}return!1}return T8=k,T8}var A8,Nfe;function QZ(){if(Nfe)return A8;Nfe=1;function e(t,n){for(var r=-1,i=n.length,s=t.length;++r<i;)t[s+r]=n[r];return t}return A8=e,A8}var N8,Ofe;function XOe(){if(Ofe)return N8;Ofe=1;var e=QZ(),t=al();function n(r,i,s){var a=i(r);return t(r)?a:e(a,s(r))}return N8=n,N8}var O8,Rfe;function lRt(){if(Rfe)return O8;Rfe=1;function e(t,n){for(var r=-1,i=t==null?0:t.length,s=0,a=[];++r<i;){var o=t[r];n(o,r,t)&&(a[s++]=o)}return a}return O8=e,O8}var R8,Ife;function ZOe(){if(Ife)return R8;Ife=1;function e(){return[]}return R8=e,R8}var I8,Dfe;function JZ(){if(Dfe)return I8;Dfe=1;var e=lRt(),t=ZOe(),n=Object.prototype,r=n.propertyIsEnumerable,i=Object.getOwnPropertySymbols,s=i?function(a){return a==null?[]:(a=Object(a),e(i(a),function(o){return r.call(a,o)}))}:t;return I8=s,I8}var D8,Pfe;function uRt(){if(Pfe)return D8;Pfe=1;function e(t,n){for(var r=-1,i=Array(t);++r<t;)i[r]=n(r);return i}return D8=e,D8}var P8,jfe;function cRt(){if(jfe)return P8;jfe=1;var e=fp(),t=wd(),n="[object Arguments]";function r(i){return t(i)&&e(i)==n}return P8=r,P8}var j8,Lfe;function eQ(){if(Lfe)return j8;Lfe=1;var e=cRt(),t=wd(),n=Object.prototype,r=n.hasOwnProperty,i=n.propertyIsEnumerable,s=e((function(){return arguments})())?e:function(a){return t(a)&&r.call(a,"callee")&&!i.call(a,"callee")};return j8=s,j8}var cw={exports:{}},L8,Mfe;function dRt(){if(Mfe)return L8;Mfe=1;function e(){return!1}return L8=e,L8}cw.exports;var Ffe;function tQ(){return Ffe||(Ffe=1,(function(e,t){var n=Sd(),r=dRt(),i=t&&!t.nodeType&&t,s=i&&!0&&e&&!e.nodeType&&e,a=s&&s.exports===i,o=a?n.Buffer:void 0,l=o?o.isBuffer:void 0,u=l||r;e.exports=u})(cw,cw.exports)),cw.exports}var M8,Bfe;function nQ(){if(Bfe)return M8;Bfe=1;var e=9007199254740991,t=/^(?:0|[1-9]\d*)$/;function n(r,i){var s=typeof r;return i=i??e,!!i&&(s=="number"||s!="symbol"&&t.test(r))&&r>-1&&r%1==0&&r<i}return M8=n,M8}var F8,$fe;function rQ(){if($fe)return F8;$fe=1;var e=9007199254740991;function t(n){return typeof n=="number"&&n>-1&&n%1==0&&n<=e}return F8=t,F8}var B8,Ufe;function fRt(){if(Ufe)return B8;Ufe=1;var e=fp(),t=rQ(),n=wd(),r="[object Arguments]",i="[object Array]",s="[object Boolean]",a="[object Date]",o="[object Error]",l="[object Function]",u="[object Map]",d="[object Number]",f="[object Object]",h="[object RegExp]",m="[object Set]",b="[object String]",y="[object WeakMap]",v="[object ArrayBuffer]",_="[object DataView]",w="[object Float32Array]",C="[object Float64Array]",T="[object Int8Array]",k="[object Int16Array]",S="[object Int32Array]",A="[object Uint8Array]",R="[object Uint8ClampedArray]",I="[object Uint16Array]",D="[object Uint32Array]",P={};P[w]=P[C]=P[T]=P[k]=P[S]=P[A]=P[R]=P[I]=P[D]=!0,P[r]=P[i]=P[v]=P[s]=P[_]=P[a]=P[o]=P[l]=P[u]=P[d]=P[f]=P[h]=P[m]=P[b]=P[y]=!1;function j(B){return n(B)&&t(B.length)&&!!P[e(B)]}return B8=j,B8}var $8,zfe;function _5(){if(zfe)return $8;zfe=1;function e(t){return function(n){return t(n)}}return $8=e,$8}var dw={exports:{}};dw.exports;var Hfe;function iQ(){return Hfe||(Hfe=1,(function(e,t){var n=pOe(),r=t&&!t.nodeType&&t,i=r&&!0&&e&&!e.nodeType&&e,s=i&&i.exports===r,a=s&&n.process,o=(function(){try{var l=i&&i.require&&i.require("util").types;return l||a&&a.binding&&a.binding("util")}catch{}})();e.exports=o})(dw,dw.exports)),dw.exports}var U8,Vfe;function QOe(){if(Vfe)return U8;Vfe=1;var e=fRt(),t=_5(),n=iQ(),r=n&&n.isTypedArray,i=r?t(r):e;return U8=i,U8}var z8,Wfe;function JOe(){if(Wfe)return z8;Wfe=1;var e=uRt(),t=eQ(),n=al(),r=tQ(),i=nQ(),s=QOe(),a=Object.prototype,o=a.hasOwnProperty;function l(u,d){var f=n(u),h=!f&&t(u),m=!f&&!h&&r(u),b=!f&&!h&&!m&&s(u),y=f||h||m||b,v=y?e(u.length,String):[],_=v.length;for(var w in u)(d||o.call(u,w))&&!(y&&(w=="length"||m&&(w=="offset"||w=="parent")||b&&(w=="buffer"||w=="byteLength"||w=="byteOffset")||i(w,_)))&&v.push(w);return v}return z8=l,z8}var H8,qfe;function sQ(){if(qfe)return H8;qfe=1;var e=Object.prototype;function t(n){var r=n&&n.constructor,i=typeof r=="function"&&r.prototype||e;return n===i}return H8=t,H8}var V8,Gfe;function eRe(){if(Gfe)return V8;Gfe=1;function e(t,n){return function(r){return t(n(r))}}return V8=e,V8}var W8,Kfe;function hRt(){if(Kfe)return W8;Kfe=1;var e=eRe(),t=e(Object.keys,Object);return W8=t,W8}var q8,Yfe;function pRt(){if(Yfe)return q8;Yfe=1;var e=sQ(),t=hRt(),n=Object.prototype,r=n.hasOwnProperty;function i(s){if(!e(s))return t(s);var a=[];for(var o in Object(s))r.call(s,o)&&o!="constructor"&&a.push(o);return a}return q8=i,q8}var G8,Xfe;function q1(){if(Xfe)return G8;Xfe=1;var e=zZ(),t=rQ();function n(r){return r!=null&&t(r.length)&&!e(r)}return G8=n,G8}var K8,Zfe;function G1(){if(Zfe)return K8;Zfe=1;var e=JOe(),t=pRt(),n=q1();function r(i){return n(i)?e(i):t(i)}return K8=r,K8}var Y8,Qfe;function tRe(){if(Qfe)return Y8;Qfe=1;var e=XOe(),t=JZ(),n=G1();function r(i){return e(i,n,t)}return Y8=r,Y8}var X8,Jfe;function mRt(){if(Jfe)return X8;Jfe=1;var e=tRe(),t=1,n=Object.prototype,r=n.hasOwnProperty;function i(s,a,o,l,u,d){var f=o&t,h=e(s),m=h.length,b=e(a),y=b.length;if(m!=y&&!f)return!1;for(var v=m;v--;){var _=h[v];if(!(f?_ in a:r.call(a,_)))return!1}var w=d.get(s),C=d.get(a);if(w&&C)return w==a&&C==s;var T=!0;d.set(s,a),d.set(a,s);for(var k=f;++v<m;){_=h[v];var S=s[_],A=a[_];if(l)var R=f?l(A,S,_,a,s,d):l(S,A,_,s,a,d);if(!(R===void 0?S===A||u(S,A,o,l,d):R)){T=!1;break}k||(k=_=="constructor")}if(T&&!k){var I=s.constructor,D=a.constructor;I!=D&&"constructor"in s&&"constructor"in a&&!(typeof I=="function"&&I instanceof I&&typeof D=="function"&&D instanceof D)&&(T=!1)}return d.delete(s),d.delete(a),T}return X8=i,X8}var Z8,ehe;function gRt(){if(ehe)return Z8;ehe=1;var e=Wy(),t=Sd(),n=e(t,"DataView");return Z8=n,Z8}var Q8,the;function bRt(){if(the)return Q8;the=1;var e=Wy(),t=Sd(),n=e(t,"Promise");return Q8=n,Q8}var J8,nhe;function nRe(){if(nhe)return J8;nhe=1;var e=Wy(),t=Sd(),n=e(t,"Set");return J8=n,J8}var e9,rhe;function yRt(){if(rhe)return e9;rhe=1;var e=Wy(),t=Sd(),n=e(t,"WeakMap");return e9=n,e9}var t9,ihe;function S5(){if(ihe)return t9;ihe=1;var e=gRt(),t=HZ(),n=bRt(),r=nRe(),i=yRt(),s=fp(),a=mOe(),o="[object Map]",l="[object Object]",u="[object Promise]",d="[object Set]",f="[object WeakMap]",h="[object DataView]",m=a(e),b=a(t),y=a(n),v=a(r),_=a(i),w=s;return(e&&w(new e(new ArrayBuffer(1)))!=h||t&&w(new t)!=o||n&&w(n.resolve())!=u||r&&w(new r)!=d||i&&w(new i)!=f)&&(w=function(C){var T=s(C),k=T==l?C.constructor:void 0,S=k?a(k):"";if(S)switch(S){case m:return h;case b:return o;case y:return u;case v:return d;case _:return f}return T}),t9=w,t9}var n9,she;function vRt(){if(she)return n9;she=1;var e=XZ(),t=KOe(),n=oRt(),r=mRt(),i=S5(),s=al(),a=tQ(),o=QOe(),l=1,u="[object Arguments]",d="[object Array]",f="[object Object]",h=Object.prototype,m=h.hasOwnProperty;function b(y,v,_,w,C,T){var k=s(y),S=s(v),A=k?d:i(y),R=S?d:i(v);A=A==u?f:A,R=R==u?f:R;var I=A==f,D=R==f,P=A==R;if(P&&a(y)){if(!a(v))return!1;k=!0,I=!1}if(P&&!I)return T||(T=new e),k||o(y)?t(y,v,_,w,C,T):n(y,v,A,_,w,C,T);if(!(_&l)){var j=I&&m.call(y,"__wrapped__"),B=D&&m.call(v,"__wrapped__");if(j||B){var L=j?y.value():y,M=B?v.value():v;return T||(T=new e),C(L,M,_,w,T)}}return P?(T||(T=new e),r(y,v,_,w,C,T)):!1}return n9=b,n9}var r9,ahe;function aQ(){if(ahe)return r9;ahe=1;var e=vRt(),t=wd();function n(r,i,s,a,o){return r===i?!0:r==null||i==null||!t(r)&&!t(i)?r!==r&&i!==i:e(r,i,s,a,n,o)}return r9=n,r9}var i9,ohe;function xRt(){if(ohe)return i9;ohe=1;var e=XZ(),t=aQ(),n=1,r=2;function i(s,a,o,l){var u=o.length,d=u,f=!l;if(s==null)return!d;for(s=Object(s);u--;){var h=o[u];if(f&&h[2]?h[1]!==s[h[0]]:!(h[0]in s))return!1}for(;++u<d;){h=o[u];var m=h[0],b=s[m],y=h[1];if(f&&h[2]){if(b===void 0&&!(m in s))return!1}else{var v=new e;if(l)var _=l(b,y,m,s,a,v);if(!(_===void 0?t(y,b,n|r,l,v):_))return!1}}return!0}return i9=i,i9}var s9,lhe;function rRe(){if(lhe)return s9;lhe=1;var e=Ed();function t(n){return n===n&&!e(n)}return s9=t,s9}var a9,uhe;function _Rt(){if(uhe)return a9;uhe=1;var e=rRe(),t=G1();function n(r){for(var i=t(r),s=i.length;s--;){var a=i[s],o=r[a];i[s]=[a,o,e(o)]}return i}return a9=n,a9}var o9,che;function iRe(){if(che)return o9;che=1;function e(t,n){return function(r){return r==null?!1:r[t]===n&&(n!==void 0||t in Object(r))}}return o9=e,o9}var l9,dhe;function SRt(){if(dhe)return l9;dhe=1;var e=xRt(),t=_Rt(),n=iRe();function r(i){var s=t(i);return s.length==1&&s[0][2]?n(s[0][0],s[0][1]):function(a){return a===i||e(a,i,s)}}return l9=r,l9}var u9,fhe;function wRt(){if(fhe)return u9;fhe=1;function e(t,n){return t!=null&&n in Object(t)}return u9=e,u9}var c9,hhe;function ERt(){if(hhe)return c9;hhe=1;var e=p5(),t=eQ(),n=al(),r=nQ(),i=rQ(),s=ek();function a(o,l,u){l=e(l,o);for(var d=-1,f=l.length,h=!1;++d<f;){var m=s(l[d]);if(!(h=o!=null&&u(o,m)))break;o=o[m]}return h||++d!=f?h:(f=o==null?0:o.length,!!f&&i(f)&&r(m,f)&&(n(o)||t(o)))}return c9=a,c9}var d9,phe;function CRt(){if(phe)return d9;phe=1;var e=wRt(),t=ERt();function n(r,i){return r!=null&&t(r,i,e)}return d9=n,d9}var f9,mhe;function kRt(){if(mhe)return f9;mhe=1;var e=aQ(),t=yOe(),n=CRt(),r=UZ(),i=rRe(),s=iRe(),a=ek(),o=1,l=2;function u(d,f){return r(d)&&i(f)?s(a(d),f):function(h){var m=t(h,d);return m===void 0&&m===f?n(h,d):e(f,m,o|l)}}return f9=u,f9}var h9,ghe;function K1(){if(ghe)return h9;ghe=1;function e(t){return t}return h9=e,h9}var p9,bhe;function TRt(){if(bhe)return p9;bhe=1;function e(t){return function(n){return n?.[t]}}return p9=e,p9}var m9,yhe;function ARt(){if(yhe)return m9;yhe=1;var e=m5();function t(n){return function(r){return e(r,n)}}return m9=t,m9}var g9,vhe;function NRt(){if(vhe)return g9;vhe=1;var e=TRt(),t=ARt(),n=UZ(),r=ek();function i(s){return n(s)?e(r(s)):t(s)}return g9=i,g9}var b9,xhe;function kd(){if(xhe)return b9;xhe=1;var e=SRt(),t=kRt(),n=K1(),r=al(),i=NRt();function s(a){return typeof a=="function"?a:a==null?n:typeof a=="object"?r(a)?t(a[0],a[1]):e(a):i(a)}return b9=s,b9}var y9,_he;function sRe(){if(_he)return y9;_he=1;function e(t,n,r,i){for(var s=t.length,a=r+(i?1:-1);i?a--:++a<s;)if(n(t[a],a,t))return a;return-1}return y9=e,y9}var v9,She;function ORt(){if(She)return v9;She=1;function e(t){return t!==t}return v9=e,v9}var x9,whe;function RRt(){if(whe)return x9;whe=1;function e(t,n,r){for(var i=r-1,s=t.length;++i<s;)if(t[i]===n)return i;return-1}return x9=e,x9}var _9,Ehe;function IRt(){if(Ehe)return _9;Ehe=1;var e=sRe(),t=ORt(),n=RRt();function r(i,s,a){return s===s?n(i,s,a):e(i,t,a)}return _9=r,_9}var S9,Che;function DRt(){if(Che)return S9;Che=1;var e=IRt();function t(n,r){var i=n==null?0:n.length;return!!i&&e(n,r,0)>-1}return S9=t,S9}var w9,khe;function PRt(){if(khe)return w9;khe=1;function e(t,n,r){for(var i=-1,s=t==null?0:t.length;++i<s;)if(r(n,t[i]))return!0;return!1}return w9=e,w9}var E9,The;function jRt(){if(The)return E9;The=1;function e(){}return E9=e,E9}var C9,Ahe;function LRt(){if(Ahe)return C9;Ahe=1;var e=nRe(),t=jRt(),n=ZZ(),r=1/0,i=e&&1/n(new e([,-0]))[1]==r?function(s){return new e(s)}:t;return C9=i,C9}var k9,Nhe;function MRt(){if(Nhe)return k9;Nhe=1;var e=WOe(),t=DRt(),n=PRt(),r=GOe(),i=LRt(),s=ZZ(),a=200;function o(l,u,d){var f=-1,h=t,m=l.length,b=!0,y=[],v=y;if(d)b=!1,h=n;else if(m>=a){var _=u?null:i(l);if(_)return s(_);b=!1,h=r,v=new e}else v=u?[]:y;e:for(;++f<m;){var w=l[f],C=u?u(w):w;if(w=d||w!==0?w:0,b&&C===C){for(var T=v.length;T--;)if(v[T]===C)continue e;u&&v.push(C),y.push(w)}else h(v,C,d)||(v!==y&&v.push(C),y.push(w))}return y}return k9=o,k9}var T9,Ohe;function FRt(){if(Ohe)return T9;Ohe=1;var e=kd(),t=MRt();function n(r,i){return r&&r.length?t(r,e(i,2)):[]}return T9=n,T9}var BRt=FRt();const Rhe=Yn(BRt);function aRe(e,t,n){return t===!0?Rhe(e,n):cn(t)?Rhe(e,t):e}function Cx(e){"@babel/helpers - typeof";return Cx=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Cx(e)}var $Rt=["ref"];function Ihe(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function uh(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?Ihe(Object(n),!0).forEach(function(r){w5(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Ihe(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function URt(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Dhe(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,lRe(r.key),r)}}function zRt(e,t,n){return t&&Dhe(e.prototype,t),n&&Dhe(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function HRt(e,t,n){return t=OR(t),VRt(e,oRe()?Reflect.construct(t,n||[],OR(e).constructor):t.apply(e,n))}function VRt(e,t){if(t&&(Cx(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return WRt(e)}function WRt(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function oRe(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(oRe=function(){return!!e})()}function OR(e){return OR=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},OR(e)}function qRt(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&tz(e,t)}function tz(e,t){return tz=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,i){return r.__proto__=i,r},tz(e,t)}function w5(e,t,n){return t=lRe(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function lRe(e){var t=GRt(e,"string");return Cx(t)=="symbol"?t:t+""}function GRt(e,t){if(Cx(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(Cx(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}function KRt(e,t){if(e==null)return{};var n=YRt(e,t),r,i;if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(i=0;i<s.length;i++)r=s[i],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}function YRt(e,t){if(e==null)return{};var n={};for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r)){if(t.indexOf(r)>=0)continue;n[r]=e[r]}return n}function XRt(e){return e.value}function ZRt(e,t){if(Z.isValidElement(e))return Z.cloneElement(e,t);if(typeof e=="function")return Z.createElement(e,t);t.ref;var n=KRt(t,$Rt);return Z.createElement(YZ,n)}var Phe=1,Xb=(function(e){function t(){var n;URt(this,t);for(var r=arguments.length,i=new Array(r),s=0;s<r;s++)i[s]=arguments[s];return n=HRt(this,t,[].concat(i)),w5(n,"lastBoundingBox",{width:-1,height:-1}),n}return qRt(t,e),zRt(t,[{key:"componentDidMount",value:function(){this.updateBBox()}},{key:"componentDidUpdate",value:function(){this.updateBBox()}},{key:"getBBox",value:function(){if(this.wrapperNode&&this.wrapperNode.getBoundingClientRect){var r=this.wrapperNode.getBoundingClientRect();return r.height=this.wrapperNode.offsetHeight,r.width=this.wrapperNode.offsetWidth,r}return null}},{key:"updateBBox",value:function(){var r=this.props.onBBoxUpdate,i=this.getBBox();i?(Math.abs(i.width-this.lastBoundingBox.width)>Phe||Math.abs(i.height-this.lastBoundingBox.height)>Phe)&&(this.lastBoundingBox.width=i.width,this.lastBoundingBox.height=i.height,r&&r(i)):(this.lastBoundingBox.width!==-1||this.lastBoundingBox.height!==-1)&&(this.lastBoundingBox.width=-1,this.lastBoundingBox.height=-1,r&&r(null))}},{key:"getBBoxSnapshot",value:function(){return this.lastBoundingBox.width>=0&&this.lastBoundingBox.height>=0?uh({},this.lastBoundingBox):{width:0,height:0}}},{key:"getDefaultPosition",value:function(r){var i=this.props,s=i.layout,a=i.align,o=i.verticalAlign,l=i.margin,u=i.chartWidth,d=i.chartHeight,f,h;if(!r||(r.left===void 0||r.left===null)&&(r.right===void 0||r.right===null))if(a==="center"&&s==="vertical"){var m=this.getBBoxSnapshot();f={left:((u||0)-m.width)/2}}else f=a==="right"?{right:l&&l.right||0}:{left:l&&l.left||0};if(!r||(r.top===void 0||r.top===null)&&(r.bottom===void 0||r.bottom===null))if(o==="middle"){var b=this.getBBoxSnapshot();h={top:((d||0)-b.height)/2}}else h=o==="bottom"?{bottom:l&&l.bottom||0}:{top:l&&l.top||0};return uh(uh({},f),h)}},{key:"render",value:function(){var r=this,i=this.props,s=i.content,a=i.width,o=i.height,l=i.wrapperStyle,u=i.payloadUniqBy,d=i.payload,f=uh(uh({position:"absolute",width:a||"auto",height:o||"auto"},this.getDefaultPosition(l)),l);return Z.createElement("div",{className:"recharts-legend-wrapper",style:f,ref:function(m){r.wrapperNode=m}},ZRt(s,uh(uh({},this.props),{},{payload:aRe(d,u,XRt)})))}}],[{key:"getWithHeight",value:function(r,i){var s=uh(uh({},this.defaultProps),r.props),a=s.layout;return a==="vertical"&&Bt(r.props.height)?{height:r.props.height}:a==="horizontal"?{width:r.props.width||i}:null}}])})(x.PureComponent);w5(Xb,"displayName","Legend");w5(Xb,"defaultProps",{iconSize:14,layout:"horizontal",align:"center",verticalAlign:"bottom"});var A9,jhe;function QRt(){if(jhe)return A9;jhe=1;var e=H1(),t=eQ(),n=al(),r=e?e.isConcatSpreadable:void 0;function i(s){return n(s)||t(s)||!!(r&&s&&s[r])}return A9=i,A9}var N9,Lhe;function oQ(){if(Lhe)return N9;Lhe=1;var e=QZ(),t=QRt();function n(r,i,s,a,o){var l=-1,u=r.length;for(s||(s=t),o||(o=[]);++l<u;){var d=r[l];i>0&&s(d)?i>1?n(d,i-1,s,a,o):e(o,d):a||(o[o.length]=d)}return o}return N9=n,N9}var O9,Mhe;function JRt(){if(Mhe)return O9;Mhe=1;function e(t){return function(n,r,i){for(var s=-1,a=Object(n),o=i(n),l=o.length;l--;){var u=o[t?l:++s];if(r(a[u],u,a)===!1)break}return n}}return O9=e,O9}var R9,Fhe;function eIt(){if(Fhe)return R9;Fhe=1;var e=JRt(),t=e();return R9=t,R9}var I9,Bhe;function uRe(){if(Bhe)return I9;Bhe=1;var e=eIt(),t=G1();function n(r,i){return r&&e(r,i,t)}return I9=n,I9}var D9,$he;function tIt(){if($he)return D9;$he=1;var e=q1();function t(n,r){return function(i,s){if(i==null)return i;if(!e(i))return n(i,s);for(var a=i.length,o=r?a:-1,l=Object(i);(r?o--:++o<a)&&s(l[o],o,l)!==!1;);return i}}return D9=t,D9}var P9,Uhe;function lQ(){if(Uhe)return P9;Uhe=1;var e=uRe(),t=tIt(),n=t(e);return P9=n,P9}var j9,zhe;function cRe(){if(zhe)return j9;zhe=1;var e=lQ(),t=q1();function n(r,i){var s=-1,a=t(r)?Array(r.length):[];return e(r,function(o,l,u){a[++s]=i(o,l,u)}),a}return j9=n,j9}var L9,Hhe;function nIt(){if(Hhe)return L9;Hhe=1;function e(t,n){var r=t.length;for(t.sort(n);r--;)t[r]=t[r].value;return t}return L9=e,L9}var M9,Vhe;function rIt(){if(Vhe)return M9;Vhe=1;var e=V1();function t(n,r){if(n!==r){var i=n!==void 0,s=n===null,a=n===n,o=e(n),l=r!==void 0,u=r===null,d=r===r,f=e(r);if(!u&&!f&&!o&&n>r||o&&l&&d&&!u&&!f||s&&l&&d||!i&&d||!a)return 1;if(!s&&!o&&!f&&n<r||f&&i&&a&&!s&&!o||u&&i&&a||!l&&a||!d)return-1}return 0}return M9=t,M9}var F9,Whe;function iIt(){if(Whe)return F9;Whe=1;var e=rIt();function t(n,r,i){for(var s=-1,a=n.criteria,o=r.criteria,l=a.length,u=i.length;++s<l;){var d=e(a[s],o[s]);if(d){if(s>=u)return d;var f=i[s];return d*(f=="desc"?-1:1)}}return n.index-r.index}return F9=t,F9}var B9,qhe;function sIt(){if(qhe)return B9;qhe=1;var e=h5(),t=m5(),n=kd(),r=cRe(),i=nIt(),s=_5(),a=iIt(),o=K1(),l=al();function u(d,f,h){f.length?f=e(f,function(y){return l(y)?function(v){return t(v,y.length===1?y[0]:y)}:y}):f=[o];var m=-1;f=e(f,s(n));var b=r(d,function(y,v,_){var w=e(f,function(C){return C(y)});return{criteria:w,index:++m,value:y}});return i(b,function(y,v){return a(y,v,h)})}return B9=u,B9}var $9,Ghe;function aIt(){if(Ghe)return $9;Ghe=1;function e(t,n,r){switch(r.length){case 0:return t.call(n);case 1:return t.call(n,r[0]);case 2:return t.call(n,r[0],r[1]);case 3:return t.call(n,r[0],r[1],r[2])}return t.apply(n,r)}return $9=e,$9}var U9,Khe;function dRe(){if(Khe)return U9;Khe=1;var e=aIt(),t=Math.max;function n(r,i,s){return i=t(i===void 0?r.length-1:i,0),function(){for(var a=arguments,o=-1,l=t(a.length-i,0),u=Array(l);++o<l;)u[o]=a[i+o];o=-1;for(var d=Array(i+1);++o<i;)d[o]=a[o];return d[i]=s(u),e(r,this,d)}}return U9=n,U9}var z9,Yhe;function oIt(){if(Yhe)return z9;Yhe=1;function e(t){return function(){return t}}return z9=e,z9}var H9,Xhe;function fRe(){if(Xhe)return H9;Xhe=1;var e=Wy(),t=(function(){try{var n=e(Object,"defineProperty");return n({},"",{}),n}catch{}})();return H9=t,H9}var V9,Zhe;function lIt(){if(Zhe)return V9;Zhe=1;var e=oIt(),t=fRe(),n=K1(),r=t?function(i,s){return t(i,"toString",{configurable:!0,enumerable:!1,value:e(s),writable:!0})}:n;return V9=r,V9}var W9,Qhe;function uIt(){if(Qhe)return W9;Qhe=1;var e=800,t=16,n=Date.now;function r(i){var s=0,a=0;return function(){var o=n(),l=t-(o-a);if(a=o,l>0){if(++s>=e)return arguments[0]}else s=0;return i.apply(void 0,arguments)}}return W9=r,W9}var q9,Jhe;function hRe(){if(Jhe)return q9;Jhe=1;var e=lIt(),t=uIt(),n=t(e);return q9=n,q9}var G9,epe;function cIt(){if(epe)return G9;epe=1;var e=K1(),t=dRe(),n=hRe();function r(i,s){return n(t(i,s,e),i+"")}return G9=r,G9}var K9,tpe;function E5(){if(tpe)return K9;tpe=1;var e=u5(),t=q1(),n=nQ(),r=Ed();function i(s,a,o){if(!r(o))return!1;var l=typeof a;return(l=="number"?t(o)&&n(a,o.length):l=="string"&&a in o)?e(o[a],s):!1}return K9=i,K9}var Y9,npe;function dIt(){if(npe)return Y9;npe=1;var e=oQ(),t=sIt(),n=cIt(),r=E5(),i=n(function(s,a){if(s==null)return[];var o=a.length;return o>1&&r(s,a[0],a[1])?a=[]:o>2&&r(a[0],a[1],a[2])&&(a=[a[0]]),t(s,e(a,1),[])});return Y9=i,Y9}var fIt=dIt();const uQ=Yn(fIt);function eC(e){"@babel/helpers - typeof";return eC=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},eC(e)}function nz(){return nz=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},nz.apply(this,arguments)}function hIt(e,t){return bIt(e)||gIt(e,t)||mIt(e,t)||pIt()}function pIt(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|