@taico/taico 0.3.1 → 0.3.3
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.
- package/README.md +2 -2
- package/dist/agents/agent-avatar.library.js +6 -0
- package/dist/agents/agent-avatar.library.js.map +1 -1
- package/dist/agents/agent-template.catalog.js +23 -3
- package/dist/agents/agent-template.catalog.js.map +1 -1
- package/dist/app-init/agent/developer.agent.d.ts +2 -0
- package/dist/app-init/agent/developer.agent.js +23 -0
- package/dist/app-init/agent/developer.agent.js.map +1 -0
- package/dist/app-init/agent/lead.agent.d.ts +2 -0
- package/dist/app-init/agent/lead.agent.js +23 -0
- package/dist/app-init/agent/lead.agent.js.map +1 -0
- package/dist/app-init/agent/plan-reviewer.agent.d.ts +2 -0
- package/dist/app-init/agent/plan-reviewer.agent.js +24 -0
- package/dist/app-init/agent/plan-reviewer.agent.js.map +1 -0
- package/dist/app-init/agent/planner.agent.d.ts +2 -0
- package/dist/app-init/agent/planner.agent.js +23 -0
- package/dist/app-init/agent/planner.agent.js.map +1 -0
- package/dist/app-init/agent/taskmaster.agent.d.ts +2 -0
- package/dist/app-init/agent/taskmaster.agent.js +23 -0
- package/dist/app-init/agent/taskmaster.agent.js.map +1 -0
- package/dist/app-init/app-init.runner.js +35 -0
- package/dist/app-init/app-init.runner.js.map +1 -1
- package/dist/app-init/models/models.d.ts +4 -0
- package/dist/app-init/models/models.js +21 -1
- package/dist/app-init/models/models.js.map +1 -1
- package/dist/app-init/prompts/prompts.d.ts +4 -0
- package/dist/app-init/prompts/prompts.js +175 -1
- package/dist/app-init/prompts/prompts.js.map +1 -1
- package/dist/app.controller.d.ts +9 -1
- package/dist/app.controller.js +52 -2
- package/dist/app.controller.js.map +1 -1
- package/dist/app.controller.spec.js +16 -1
- package/dist/app.controller.spec.js.map +1 -1
- package/dist/app.module.js +4 -1
- package/dist/app.module.js.map +1 -1
- package/dist/main.js +10 -0
- package/dist/main.js.map +1 -1
- package/dist/meta/meta.service.d.ts +4 -1
- package/dist/meta/meta.service.js +38 -0
- package/dist/meta/meta.service.js.map +1 -1
- package/dist/meta/meta.service.spec.d.ts +1 -0
- package/dist/meta/meta.service.spec.js +100 -0
- package/dist/meta/meta.service.spec.js.map +1 -0
- package/dist/meta/system-tags.d.ts +6 -0
- package/dist/meta/system-tags.js +19 -0
- package/dist/meta/system-tags.js.map +1 -0
- package/dist/migrations/1742800000000-RemovePlannerPlanTagTrigger.d.ts +5 -0
- package/dist/migrations/1742800000000-RemovePlannerPlanTagTrigger.js +27 -0
- package/dist/migrations/1742800000000-RemovePlannerPlanTagTrigger.js.map +1 -0
- package/dist/public/assets/{index-DzwOFnwx.js → index-C1ykqErs.js} +1 -1
- package/dist/public/index.html +1 -1
- package/dist/public/package.json +4 -4
- package/dist/server-lifecycle.service.d.ts +14 -0
- package/dist/server-lifecycle.service.js +54 -0
- package/dist/server-lifecycle.service.js.map +1 -0
- package/dist/server-lifecycle.service.spec.d.ts +1 -0
- package/dist/server-lifecycle.service.spec.js +63 -0
- package/dist/server-lifecycle.service.spec.js.map +1 -0
- package/dist/tasks/tasks.service.auto-prune.spec.d.ts +1 -0
- package/dist/tasks/tasks.service.auto-prune.spec.js +135 -0
- package/dist/tasks/tasks.service.auto-prune.spec.js.map +1 -0
- package/dist/tasks/tasks.service.d.ts +2 -0
- package/dist/tasks/tasks.service.js +29 -0
- package/dist/tasks/tasks.service.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +5 -5
|
@@ -9,7 +9,7 @@ Error generating stack: `+o.message+`
|
|
|
9
9
|
`).replace(Y_,"")}function Jg(e,s){return s=Wg(s),Wg(e)===s}function rt(e,s,r,o,d,p){switch(r){case"children":typeof o=="string"?s==="body"||s==="textarea"&&o===""||Xa(e,o):(typeof o=="number"||typeof o=="bigint")&&s!=="body"&&Xa(e,""+o);break;case"className":hl(e,"class",o);break;case"tabIndex":hl(e,"tabindex",o);break;case"dir":case"role":case"viewBox":case"width":case"height":hl(e,r,o);break;case"style":Wh(e,o,p);break;case"data":if(s!=="object"){hl(e,"data",o);break}case"src":case"href":if(o===""&&(s!=="a"||r!=="href")){e.removeAttribute(r);break}if(o==null||typeof o=="function"||typeof o=="symbol"||typeof o=="boolean"){e.removeAttribute(r);break}o=pl(""+o),e.setAttribute(r,o);break;case"action":case"formAction":if(typeof o=="function"){e.setAttribute(r,"javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')");break}else typeof p=="function"&&(r==="formAction"?(s!=="input"&&rt(e,s,"name",d.name,d,null),rt(e,s,"formEncType",d.formEncType,d,null),rt(e,s,"formMethod",d.formMethod,d,null),rt(e,s,"formTarget",d.formTarget,d,null)):(rt(e,s,"encType",d.encType,d,null),rt(e,s,"method",d.method,d,null),rt(e,s,"target",d.target,d,null)));if(o==null||typeof o=="symbol"||typeof o=="boolean"){e.removeAttribute(r);break}o=pl(""+o),e.setAttribute(r,o);break;case"onClick":o!=null&&(e.onclick=xn);break;case"onScroll":o!=null&&Be("scroll",e);break;case"onScrollEnd":o!=null&&Be("scrollend",e);break;case"dangerouslySetInnerHTML":if(o!=null){if(typeof o!="object"||!("__html"in o))throw Error(l(61));if(r=o.__html,r!=null){if(d.children!=null)throw Error(l(60));e.innerHTML=r}}break;case"multiple":e.multiple=o&&typeof o!="function"&&typeof o!="symbol";break;case"muted":e.muted=o&&typeof o!="function"&&typeof o!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(o==null||typeof o=="function"||typeof o=="boolean"||typeof o=="symbol"){e.removeAttribute("xlink:href");break}r=pl(""+o),e.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",r);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":o!=null&&typeof o!="function"&&typeof o!="symbol"?e.setAttribute(r,""+o):e.removeAttribute(r);break;case"inert":case"allowFullScreen":case"async":case"autoPlay":case"controls":case"default":case"defer":case"disabled":case"disablePictureInPicture":case"disableRemotePlayback":case"formNoValidate":case"hidden":case"loop":case"noModule":case"noValidate":case"open":case"playsInline":case"readOnly":case"required":case"reversed":case"scoped":case"seamless":case"itemScope":o&&typeof o!="function"&&typeof o!="symbol"?e.setAttribute(r,""):e.removeAttribute(r);break;case"capture":case"download":o===!0?e.setAttribute(r,""):o!==!1&&o!=null&&typeof o!="function"&&typeof o!="symbol"?e.setAttribute(r,o):e.removeAttribute(r);break;case"cols":case"rows":case"size":case"span":o!=null&&typeof o!="function"&&typeof o!="symbol"&&!isNaN(o)&&1<=o?e.setAttribute(r,o):e.removeAttribute(r);break;case"rowSpan":case"start":o==null||typeof o=="function"||typeof o=="symbol"||isNaN(o)?e.removeAttribute(r):e.setAttribute(r,o);break;case"popover":Be("beforetoggle",e),Be("toggle",e),dl(e,"popover",o);break;case"xlinkActuate":yn(e,"http://www.w3.org/1999/xlink","xlink:actuate",o);break;case"xlinkArcrole":yn(e,"http://www.w3.org/1999/xlink","xlink:arcrole",o);break;case"xlinkRole":yn(e,"http://www.w3.org/1999/xlink","xlink:role",o);break;case"xlinkShow":yn(e,"http://www.w3.org/1999/xlink","xlink:show",o);break;case"xlinkTitle":yn(e,"http://www.w3.org/1999/xlink","xlink:title",o);break;case"xlinkType":yn(e,"http://www.w3.org/1999/xlink","xlink:type",o);break;case"xmlBase":yn(e,"http://www.w3.org/XML/1998/namespace","xml:base",o);break;case"xmlLang":yn(e,"http://www.w3.org/XML/1998/namespace","xml:lang",o);break;case"xmlSpace":yn(e,"http://www.w3.org/XML/1998/namespace","xml:space",o);break;case"is":dl(e,"is",o);break;case"innerText":case"textContent":break;default:(!(2<r.length)||r[0]!=="o"&&r[0]!=="O"||r[1]!=="n"&&r[1]!=="N")&&(r=_b.get(r)||r,dl(e,r,o))}}function Wu(e,s,r,o,d,p){switch(r){case"style":Wh(e,o,p);break;case"dangerouslySetInnerHTML":if(o!=null){if(typeof o!="object"||!("__html"in o))throw Error(l(61));if(r=o.__html,r!=null){if(d.children!=null)throw Error(l(60));e.innerHTML=r}}break;case"children":typeof o=="string"?Xa(e,o):(typeof o=="number"||typeof o=="bigint")&&Xa(e,""+o);break;case"onScroll":o!=null&&Be("scroll",e);break;case"onScrollEnd":o!=null&&Be("scrollend",e);break;case"onClick":o!=null&&(e.onclick=xn);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!Ph.hasOwnProperty(r))e:{if(r[0]==="o"&&r[1]==="n"&&(d=r.endsWith("Capture"),s=r.slice(2,d?r.length-7:void 0),p=e[ns]||null,p=p!=null?p[r]:null,typeof p=="function"&&e.removeEventListener(s,p,d),typeof o=="function")){typeof p!="function"&&p!==null&&(r in e?e[r]=null:e.hasAttribute(r)&&e.removeAttribute(r)),e.addEventListener(s,o,d);break e}r in e?e[r]=o:o===!0?e.setAttribute(r,""):dl(e,r,o)}}}function Yt(e,s,r){switch(s){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":Be("error",e),Be("load",e);var o=!1,d=!1,p;for(p in r)if(r.hasOwnProperty(p)){var S=r[p];if(S!=null)switch(p){case"src":o=!0;break;case"srcSet":d=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(l(137,s));default:rt(e,s,p,S,r,null)}}d&&rt(e,s,"srcSet",r.srcSet,r,null),o&&rt(e,s,"src",r.src,r,null);return;case"input":Be("invalid",e);var C=p=S=d=null,O=null,V=null;for(o in r)if(r.hasOwnProperty(o)){var ee=r[o];if(ee!=null)switch(o){case"name":d=ee;break;case"type":S=ee;break;case"checked":O=ee;break;case"defaultChecked":V=ee;break;case"value":p=ee;break;case"defaultValue":C=ee;break;case"children":case"dangerouslySetInnerHTML":if(ee!=null)throw Error(l(137,s));break;default:rt(e,s,o,ee,r,null)}}Qh(e,p,C,O,V,S,d,!1);return;case"select":Be("invalid",e),o=S=p=null;for(d in r)if(r.hasOwnProperty(d)&&(C=r[d],C!=null))switch(d){case"value":p=C;break;case"defaultValue":S=C;break;case"multiple":o=C;default:rt(e,s,d,C,r,null)}s=p,r=S,e.multiple=!!o,s!=null?Ka(e,!!o,s,!1):r!=null&&Ka(e,!!o,r,!0);return;case"textarea":Be("invalid",e),p=d=o=null;for(S in r)if(r.hasOwnProperty(S)&&(C=r[S],C!=null))switch(S){case"value":o=C;break;case"defaultValue":d=C;break;case"children":p=C;break;case"dangerouslySetInnerHTML":if(C!=null)throw Error(l(91));break;default:rt(e,s,S,C,r,null)}Xh(e,o,d,p);return;case"option":for(O in r)if(r.hasOwnProperty(O)&&(o=r[O],o!=null))switch(O){case"selected":e.selected=o&&typeof o!="function"&&typeof o!="symbol";break;default:rt(e,s,O,o,r,null)}return;case"dialog":Be("beforetoggle",e),Be("toggle",e),Be("cancel",e),Be("close",e);break;case"iframe":case"object":Be("load",e);break;case"video":case"audio":for(o=0;o<Ei.length;o++)Be(Ei[o],e);break;case"image":Be("error",e),Be("load",e);break;case"details":Be("toggle",e);break;case"embed":case"source":case"link":Be("error",e),Be("load",e);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(V in r)if(r.hasOwnProperty(V)&&(o=r[V],o!=null))switch(V){case"children":case"dangerouslySetInnerHTML":throw Error(l(137,s));default:rt(e,s,V,o,r,null)}return;default:if(hc(s)){for(ee in r)r.hasOwnProperty(ee)&&(o=r[ee],o!==void 0&&Wu(e,s,ee,o,r,void 0));return}}for(C in r)r.hasOwnProperty(C)&&(o=r[C],o!=null&&rt(e,s,C,o,r,null))}function Q_(e,s,r,o){switch(s){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var d=null,p=null,S=null,C=null,O=null,V=null,ee=null;for(X in r){var ie=r[X];if(r.hasOwnProperty(X)&&ie!=null)switch(X){case"checked":break;case"value":break;case"defaultValue":O=ie;default:o.hasOwnProperty(X)||rt(e,s,X,null,o,ie)}}for(var F in o){var X=o[F];if(ie=r[F],o.hasOwnProperty(F)&&(X!=null||ie!=null))switch(F){case"type":p=X;break;case"name":d=X;break;case"checked":V=X;break;case"defaultChecked":ee=X;break;case"value":S=X;break;case"defaultValue":C=X;break;case"children":case"dangerouslySetInnerHTML":if(X!=null)throw Error(l(137,s));break;default:X!==ie&&rt(e,s,F,X,o,ie)}}uc(e,S,C,O,V,ee,p,d);return;case"select":X=S=C=F=null;for(p in r)if(O=r[p],r.hasOwnProperty(p)&&O!=null)switch(p){case"value":break;case"multiple":X=O;default:o.hasOwnProperty(p)||rt(e,s,p,null,o,O)}for(d in o)if(p=o[d],O=r[d],o.hasOwnProperty(d)&&(p!=null||O!=null))switch(d){case"value":F=p;break;case"defaultValue":C=p;break;case"multiple":S=p;default:p!==O&&rt(e,s,d,p,o,O)}s=C,r=S,o=X,F!=null?Ka(e,!!r,F,!1):!!o!=!!r&&(s!=null?Ka(e,!!r,s,!0):Ka(e,!!r,r?[]:"",!1));return;case"textarea":X=F=null;for(C in r)if(d=r[C],r.hasOwnProperty(C)&&d!=null&&!o.hasOwnProperty(C))switch(C){case"value":break;case"children":break;default:rt(e,s,C,null,o,d)}for(S in o)if(d=o[S],p=r[S],o.hasOwnProperty(S)&&(d!=null||p!=null))switch(S){case"value":F=d;break;case"defaultValue":X=d;break;case"children":break;case"dangerouslySetInnerHTML":if(d!=null)throw Error(l(91));break;default:d!==p&&rt(e,s,S,d,o,p)}Kh(e,F,X);return;case"option":for(var ke in r)if(F=r[ke],r.hasOwnProperty(ke)&&F!=null&&!o.hasOwnProperty(ke))switch(ke){case"selected":e.selected=!1;break;default:rt(e,s,ke,null,o,F)}for(O in o)if(F=o[O],X=r[O],o.hasOwnProperty(O)&&F!==X&&(F!=null||X!=null))switch(O){case"selected":e.selected=F&&typeof F!="function"&&typeof F!="symbol";break;default:rt(e,s,O,F,o,X)}return;case"img":case"link":case"area":case"base":case"br":case"col":case"embed":case"hr":case"keygen":case"meta":case"param":case"source":case"track":case"wbr":case"menuitem":for(var Ae in r)F=r[Ae],r.hasOwnProperty(Ae)&&F!=null&&!o.hasOwnProperty(Ae)&&rt(e,s,Ae,null,o,F);for(V in o)if(F=o[V],X=r[V],o.hasOwnProperty(V)&&F!==X&&(F!=null||X!=null))switch(V){case"children":case"dangerouslySetInnerHTML":if(F!=null)throw Error(l(137,s));break;default:rt(e,s,V,F,o,X)}return;default:if(hc(s)){for(var it in r)F=r[it],r.hasOwnProperty(it)&&F!==void 0&&!o.hasOwnProperty(it)&&Wu(e,s,it,void 0,o,F);for(ee in o)F=o[ee],X=r[ee],!o.hasOwnProperty(ee)||F===X||F===void 0&&X===void 0||Wu(e,s,ee,F,o,X);return}}for(var $ in r)F=r[$],r.hasOwnProperty($)&&F!=null&&!o.hasOwnProperty($)&&rt(e,s,$,null,o,F);for(ie in o)F=o[ie],X=r[ie],!o.hasOwnProperty(ie)||F===X||F==null&&X==null||rt(e,s,ie,F,o,X)}function em(e){switch(e){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function K_(){if(typeof performance.getEntriesByType=="function"){for(var e=0,s=0,r=performance.getEntriesByType("resource"),o=0;o<r.length;o++){var d=r[o],p=d.transferSize,S=d.initiatorType,C=d.duration;if(p&&C&&em(S)){for(S=0,C=d.responseEnd,o+=1;o<r.length;o++){var O=r[o],V=O.startTime;if(V>C)break;var ee=O.transferSize,ie=O.initiatorType;ee&&em(ie)&&(O=O.responseEnd,S+=ee*(O<C?1:(C-V)/(O-V)))}if(--o,s+=8*(p+S)/(d.duration/1e3),e++,10<e)break}}if(0<e)return s/e/1e6}return navigator.connection&&(e=navigator.connection.downlink,typeof e=="number")?e:5}var Ju=null,ed=null;function co(e){return e.nodeType===9?e:e.ownerDocument}function tm(e){switch(e){case"http://www.w3.org/2000/svg":return 1;case"http://www.w3.org/1998/Math/MathML":return 2;default:return 0}}function sm(e,s){if(e===0)switch(s){case"svg":return 1;case"math":return 2;default:return 0}return e===1&&s==="foreignObject"?0:e}function td(e,s){return e==="textarea"||e==="noscript"||typeof s.children=="string"||typeof s.children=="number"||typeof s.children=="bigint"||typeof s.dangerouslySetInnerHTML=="object"&&s.dangerouslySetInnerHTML!==null&&s.dangerouslySetInnerHTML.__html!=null}var sd=null;function X_(){var e=window.event;return e&&e.type==="popstate"?e===sd?!1:(sd=e,!0):(sd=null,!1)}var nm=typeof setTimeout=="function"?setTimeout:void 0,Z_=typeof clearTimeout=="function"?clearTimeout:void 0,am=typeof Promise=="function"?Promise:void 0,W_=typeof queueMicrotask=="function"?queueMicrotask:typeof am<"u"?function(e){return am.resolve(null).then(e).catch(J_)}:nm;function J_(e){setTimeout(function(){throw e})}function ra(e){return e==="head"}function rm(e,s){var r=s,o=0;do{var d=r.nextSibling;if(e.removeChild(r),d&&d.nodeType===8)if(r=d.data,r==="/$"||r==="/&"){if(o===0){e.removeChild(d),Er(s);return}o--}else if(r==="$"||r==="$?"||r==="$~"||r==="$!"||r==="&")o++;else if(r==="html")Ni(e.ownerDocument.documentElement);else if(r==="head"){r=e.ownerDocument.head,Ni(r);for(var p=r.firstChild;p;){var S=p.nextSibling,C=p.nodeName;p[Yr]||C==="SCRIPT"||C==="STYLE"||C==="LINK"&&p.rel.toLowerCase()==="stylesheet"||r.removeChild(p),p=S}}else r==="body"&&Ni(e.ownerDocument.body);r=d}while(r);Er(s)}function im(e,s){var r=e;e=0;do{var o=r.nextSibling;if(r.nodeType===1?s?(r._stashedDisplay=r.style.display,r.style.display="none"):(r.style.display=r._stashedDisplay||"",r.getAttribute("style")===""&&r.removeAttribute("style")):r.nodeType===3&&(s?(r._stashedText=r.nodeValue,r.nodeValue=""):r.nodeValue=r._stashedText||""),o&&o.nodeType===8)if(r=o.data,r==="/$"){if(e===0)break;e--}else r!=="$"&&r!=="$?"&&r!=="$~"&&r!=="$!"||e++;r=o}while(r)}function nd(e){var s=e.firstChild;for(s&&s.nodeType===10&&(s=s.nextSibling);s;){var r=s;switch(s=s.nextSibling,r.nodeName){case"HTML":case"HEAD":case"BODY":nd(r),oc(r);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(r.rel.toLowerCase()==="stylesheet")continue}e.removeChild(r)}}function eS(e,s,r,o){for(;e.nodeType===1;){var d=r;if(e.nodeName.toLowerCase()!==s.toLowerCase()){if(!o&&(e.nodeName!=="INPUT"||e.type!=="hidden"))break}else if(o){if(!e[Yr])switch(s){case"meta":if(!e.hasAttribute("itemprop"))break;return e;case"link":if(p=e.getAttribute("rel"),p==="stylesheet"&&e.hasAttribute("data-precedence"))break;if(p!==d.rel||e.getAttribute("href")!==(d.href==null||d.href===""?null:d.href)||e.getAttribute("crossorigin")!==(d.crossOrigin==null?null:d.crossOrigin)||e.getAttribute("title")!==(d.title==null?null:d.title))break;return e;case"style":if(e.hasAttribute("data-precedence"))break;return e;case"script":if(p=e.getAttribute("src"),(p!==(d.src==null?null:d.src)||e.getAttribute("type")!==(d.type==null?null:d.type)||e.getAttribute("crossorigin")!==(d.crossOrigin==null?null:d.crossOrigin))&&p&&e.hasAttribute("async")&&!e.hasAttribute("itemprop"))break;return e;default:return e}}else if(s==="input"&&e.type==="hidden"){var p=d.name==null?null:""+d.name;if(d.type==="hidden"&&e.getAttribute("name")===p)return e}else return e;if(e=Os(e.nextSibling),e===null)break}return null}function tS(e,s,r){if(s==="")return null;for(;e.nodeType!==3;)if((e.nodeType!==1||e.nodeName!=="INPUT"||e.type!=="hidden")&&!r||(e=Os(e.nextSibling),e===null))return null;return e}function lm(e,s){for(;e.nodeType!==8;)if((e.nodeType!==1||e.nodeName!=="INPUT"||e.type!=="hidden")&&!s||(e=Os(e.nextSibling),e===null))return null;return e}function ad(e){return e.data==="$?"||e.data==="$~"}function rd(e){return e.data==="$!"||e.data==="$?"&&e.ownerDocument.readyState!=="loading"}function sS(e,s){var r=e.ownerDocument;if(e.data==="$~")e._reactRetry=s;else if(e.data!=="$?"||r.readyState!=="loading")s();else{var o=function(){s(),r.removeEventListener("DOMContentLoaded",o)};r.addEventListener("DOMContentLoaded",o),e._reactRetry=o}}function Os(e){for(;e!=null;e=e.nextSibling){var s=e.nodeType;if(s===1||s===3)break;if(s===8){if(s=e.data,s==="$"||s==="$!"||s==="$?"||s==="$~"||s==="&"||s==="F!"||s==="F")break;if(s==="/$"||s==="/&")return null}}return e}var id=null;function om(e){e=e.nextSibling;for(var s=0;e;){if(e.nodeType===8){var r=e.data;if(r==="/$"||r==="/&"){if(s===0)return Os(e.nextSibling);s--}else r!=="$"&&r!=="$!"&&r!=="$?"&&r!=="$~"&&r!=="&"||s++}e=e.nextSibling}return null}function cm(e){e=e.previousSibling;for(var s=0;e;){if(e.nodeType===8){var r=e.data;if(r==="$"||r==="$!"||r==="$?"||r==="$~"||r==="&"){if(s===0)return e;s--}else r!=="/$"&&r!=="/&"||s++}e=e.previousSibling}return null}function um(e,s,r){switch(s=co(r),e){case"html":if(e=s.documentElement,!e)throw Error(l(452));return e;case"head":if(e=s.head,!e)throw Error(l(453));return e;case"body":if(e=s.body,!e)throw Error(l(454));return e;default:throw Error(l(451))}}function Ni(e){for(var s=e.attributes;s.length;)e.removeAttributeNode(s[0]);oc(e)}var Ls=new Map,dm=new Set;function uo(e){return typeof e.getRootNode=="function"?e.getRootNode():e.nodeType===9?e:e.ownerDocument}var On=se.d;se.d={f:nS,r:aS,D:rS,C:iS,L:lS,m:oS,X:uS,S:cS,M:dS};function nS(){var e=On.f(),s=to();return e||s}function aS(e){var s=Fa(e);s!==null&&s.tag===5&&s.type==="form"?Cp(s):On.r(e)}var kr=typeof document>"u"?null:document;function hm(e,s,r){var o=kr;if(o&&typeof s=="string"&&s){var d=Es(s);d='link[rel="'+e+'"][href="'+d+'"]',typeof r=="string"&&(d+='[crossorigin="'+r+'"]'),dm.has(d)||(dm.add(d),e={rel:e,crossOrigin:r,href:s},o.querySelector(d)===null&&(s=o.createElement("link"),Yt(s,"link",e),Ut(s),o.head.appendChild(s)))}}function rS(e){On.D(e),hm("dns-prefetch",e,null)}function iS(e,s){On.C(e,s),hm("preconnect",e,s)}function lS(e,s,r){On.L(e,s,r);var o=kr;if(o&&e&&s){var d='link[rel="preload"][as="'+Es(s)+'"]';s==="image"&&r&&r.imageSrcSet?(d+='[imagesrcset="'+Es(r.imageSrcSet)+'"]',typeof r.imageSizes=="string"&&(d+='[imagesizes="'+Es(r.imageSizes)+'"]')):d+='[href="'+Es(e)+'"]';var p=d;switch(s){case"style":p=Tr(e);break;case"script":p=wr(e)}Ls.has(p)||(e=_({rel:"preload",href:s==="image"&&r&&r.imageSrcSet?void 0:e,as:s},r),Ls.set(p,e),o.querySelector(d)!==null||s==="style"&&o.querySelector(Ai(p))||s==="script"&&o.querySelector(Ri(p))||(s=o.createElement("link"),Yt(s,"link",e),Ut(s),o.head.appendChild(s)))}}function oS(e,s){On.m(e,s);var r=kr;if(r&&e){var o=s&&typeof s.as=="string"?s.as:"script",d='link[rel="modulepreload"][as="'+Es(o)+'"][href="'+Es(e)+'"]',p=d;switch(o){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":p=wr(e)}if(!Ls.has(p)&&(e=_({rel:"modulepreload",href:e},s),Ls.set(p,e),r.querySelector(d)===null)){switch(o){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(r.querySelector(Ri(p)))return}o=r.createElement("link"),Yt(o,"link",e),Ut(o),r.head.appendChild(o)}}}function cS(e,s,r){On.S(e,s,r);var o=kr;if(o&&e){var d=Ya(o).hoistableStyles,p=Tr(e);s=s||"default";var S=d.get(p);if(!S){var C={loading:0,preload:null};if(S=o.querySelector(Ai(p)))C.loading=5;else{e=_({rel:"stylesheet",href:e,"data-precedence":s},r),(r=Ls.get(p))&&ld(e,r);var O=S=o.createElement("link");Ut(O),Yt(O,"link",e),O._p=new Promise(function(V,ee){O.onload=V,O.onerror=ee}),O.addEventListener("load",function(){C.loading|=1}),O.addEventListener("error",function(){C.loading|=2}),C.loading|=4,ho(S,s,o)}S={type:"stylesheet",instance:S,count:1,state:C},d.set(p,S)}}}function uS(e,s){On.X(e,s);var r=kr;if(r&&e){var o=Ya(r).hoistableScripts,d=wr(e),p=o.get(d);p||(p=r.querySelector(Ri(d)),p||(e=_({src:e,async:!0},s),(s=Ls.get(d))&&od(e,s),p=r.createElement("script"),Ut(p),Yt(p,"link",e),r.head.appendChild(p)),p={type:"script",instance:p,count:1,state:null},o.set(d,p))}}function dS(e,s){On.M(e,s);var r=kr;if(r&&e){var o=Ya(r).hoistableScripts,d=wr(e),p=o.get(d);p||(p=r.querySelector(Ri(d)),p||(e=_({src:e,async:!0,type:"module"},s),(s=Ls.get(d))&&od(e,s),p=r.createElement("script"),Ut(p),Yt(p,"link",e),r.head.appendChild(p)),p={type:"script",instance:p,count:1,state:null},o.set(d,p))}}function fm(e,s,r,o){var d=(d=ae.current)?uo(d):null;if(!d)throw Error(l(446));switch(e){case"meta":case"title":return null;case"style":return typeof r.precedence=="string"&&typeof r.href=="string"?(s=Tr(r.href),r=Ya(d).hoistableStyles,o=r.get(s),o||(o={type:"style",instance:null,count:0,state:null},r.set(s,o)),o):{type:"void",instance:null,count:0,state:null};case"link":if(r.rel==="stylesheet"&&typeof r.href=="string"&&typeof r.precedence=="string"){e=Tr(r.href);var p=Ya(d).hoistableStyles,S=p.get(e);if(S||(d=d.ownerDocument||d,S={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},p.set(e,S),(p=d.querySelector(Ai(e)))&&!p._p&&(S.instance=p,S.state.loading=5),Ls.has(e)||(r={rel:"preload",as:"style",href:r.href,crossOrigin:r.crossOrigin,integrity:r.integrity,media:r.media,hrefLang:r.hrefLang,referrerPolicy:r.referrerPolicy},Ls.set(e,r),p||hS(d,e,r,S.state))),s&&o===null)throw Error(l(528,""));return S}if(s&&o!==null)throw Error(l(529,""));return null;case"script":return s=r.async,r=r.src,typeof r=="string"&&s&&typeof s!="function"&&typeof s!="symbol"?(s=wr(r),r=Ya(d).hoistableScripts,o=r.get(s),o||(o={type:"script",instance:null,count:0,state:null},r.set(s,o)),o):{type:"void",instance:null,count:0,state:null};default:throw Error(l(444,e))}}function Tr(e){return'href="'+Es(e)+'"'}function Ai(e){return'link[rel="stylesheet"]['+e+"]"}function pm(e){return _({},e,{"data-precedence":e.precedence,precedence:null})}function hS(e,s,r,o){e.querySelector('link[rel="preload"][as="style"]['+s+"]")?o.loading=1:(s=e.createElement("link"),o.preload=s,s.addEventListener("load",function(){return o.loading|=1}),s.addEventListener("error",function(){return o.loading|=2}),Yt(s,"link",r),Ut(s),e.head.appendChild(s))}function wr(e){return'[src="'+Es(e)+'"]'}function Ri(e){return"script[async]"+e}function gm(e,s,r){if(s.count++,s.instance===null)switch(s.type){case"style":var o=e.querySelector('style[data-href~="'+Es(r.href)+'"]');if(o)return s.instance=o,Ut(o),o;var d=_({},r,{"data-href":r.href,"data-precedence":r.precedence,href:null,precedence:null});return o=(e.ownerDocument||e).createElement("style"),Ut(o),Yt(o,"style",d),ho(o,r.precedence,e),s.instance=o;case"stylesheet":d=Tr(r.href);var p=e.querySelector(Ai(d));if(p)return s.state.loading|=4,s.instance=p,Ut(p),p;o=pm(r),(d=Ls.get(d))&&ld(o,d),p=(e.ownerDocument||e).createElement("link"),Ut(p);var S=p;return S._p=new Promise(function(C,O){S.onload=C,S.onerror=O}),Yt(p,"link",o),s.state.loading|=4,ho(p,r.precedence,e),s.instance=p;case"script":return p=wr(r.src),(d=e.querySelector(Ri(p)))?(s.instance=d,Ut(d),d):(o=r,(d=Ls.get(p))&&(o=_({},r),od(o,d)),e=e.ownerDocument||e,d=e.createElement("script"),Ut(d),Yt(d,"link",o),e.head.appendChild(d),s.instance=d);case"void":return null;default:throw Error(l(443,s.type))}else s.type==="stylesheet"&&(s.state.loading&4)===0&&(o=s.instance,s.state.loading|=4,ho(o,r.precedence,e));return s.instance}function ho(e,s,r){for(var o=r.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),d=o.length?o[o.length-1]:null,p=d,S=0;S<o.length;S++){var C=o[S];if(C.dataset.precedence===s)p=C;else if(p!==d)break}p?p.parentNode.insertBefore(e,p.nextSibling):(s=r.nodeType===9?r.head:r,s.insertBefore(e,s.firstChild))}function ld(e,s){e.crossOrigin==null&&(e.crossOrigin=s.crossOrigin),e.referrerPolicy==null&&(e.referrerPolicy=s.referrerPolicy),e.title==null&&(e.title=s.title)}function od(e,s){e.crossOrigin==null&&(e.crossOrigin=s.crossOrigin),e.referrerPolicy==null&&(e.referrerPolicy=s.referrerPolicy),e.integrity==null&&(e.integrity=s.integrity)}var fo=null;function mm(e,s,r){if(fo===null){var o=new Map,d=fo=new Map;d.set(r,o)}else d=fo,o=d.get(r),o||(o=new Map,d.set(r,o));if(o.has(e))return o;for(o.set(e,null),r=r.getElementsByTagName(e),d=0;d<r.length;d++){var p=r[d];if(!(p[Yr]||p[zt]||e==="link"&&p.getAttribute("rel")==="stylesheet")&&p.namespaceURI!=="http://www.w3.org/2000/svg"){var S=p.getAttribute(s)||"";S=e+S;var C=o.get(S);C?C.push(p):o.set(S,[p])}}return o}function ym(e,s,r){e=e.ownerDocument||e,e.head.insertBefore(r,s==="title"?e.querySelector("head > title"):null)}function fS(e,s,r){if(r===1||s.itemProp!=null)return!1;switch(e){case"meta":case"title":return!0;case"style":if(typeof s.precedence!="string"||typeof s.href!="string"||s.href==="")break;return!0;case"link":if(typeof s.rel!="string"||typeof s.href!="string"||s.href===""||s.onLoad||s.onError)break;switch(s.rel){case"stylesheet":return e=s.disabled,typeof s.precedence=="string"&&e==null;default:return!0}case"script":if(s.async&&typeof s.async!="function"&&typeof s.async!="symbol"&&!s.onLoad&&!s.onError&&s.src&&typeof s.src=="string")return!0}return!1}function xm(e){return!(e.type==="stylesheet"&&(e.state.loading&3)===0)}function pS(e,s,r,o){if(r.type==="stylesheet"&&(typeof o.media!="string"||matchMedia(o.media).matches!==!1)&&(r.state.loading&4)===0){if(r.instance===null){var d=Tr(o.href),p=s.querySelector(Ai(d));if(p){s=p._p,s!==null&&typeof s=="object"&&typeof s.then=="function"&&(e.count++,e=po.bind(e),s.then(e,e)),r.state.loading|=4,r.instance=p,Ut(p);return}p=s.ownerDocument||s,o=pm(o),(d=Ls.get(d))&&ld(o,d),p=p.createElement("link"),Ut(p);var S=p;S._p=new Promise(function(C,O){S.onload=C,S.onerror=O}),Yt(p,"link",o),r.instance=p}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(r,s),(s=r.state.preload)&&(r.state.loading&3)===0&&(e.count++,r=po.bind(e),s.addEventListener("load",r),s.addEventListener("error",r))}}var cd=0;function gS(e,s){return e.stylesheets&&e.count===0&&mo(e,e.stylesheets),0<e.count||0<e.imgCount?function(r){var o=setTimeout(function(){if(e.stylesheets&&mo(e,e.stylesheets),e.unsuspend){var p=e.unsuspend;e.unsuspend=null,p()}},6e4+s);0<e.imgBytes&&cd===0&&(cd=62500*K_());var d=setTimeout(function(){if(e.waitingForImages=!1,e.count===0&&(e.stylesheets&&mo(e,e.stylesheets),e.unsuspend)){var p=e.unsuspend;e.unsuspend=null,p()}},(e.imgBytes>cd?50:800)+s);return e.unsuspend=r,function(){e.unsuspend=null,clearTimeout(o),clearTimeout(d)}}:null}function po(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)mo(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}}var go=null;function mo(e,s){e.stylesheets=null,e.unsuspend!==null&&(e.count++,go=new Map,s.forEach(mS,e),go=null,po.call(e))}function mS(e,s){if(!(s.state.loading&4)){var r=go.get(e);if(r)var o=r.get(null);else{r=new Map,go.set(e,r);for(var d=e.querySelectorAll("link[data-precedence],style[data-precedence]"),p=0;p<d.length;p++){var S=d[p];(S.nodeName==="LINK"||S.getAttribute("media")!=="not all")&&(r.set(S.dataset.precedence,S),o=S)}o&&r.set(null,o)}d=s.instance,S=d.getAttribute("data-precedence"),p=r.get(S)||o,p===o&&r.set(null,d),r.set(S,d),this.count++,o=po.bind(this),d.addEventListener("load",o),d.addEventListener("error",o),p?p.parentNode.insertBefore(d,p.nextSibling):(e=e.nodeType===9?e.head:e,e.insertBefore(d,e.firstChild)),s.state.loading|=4}}var zi={$$typeof:z,Provider:null,Consumer:null,_currentValue:ge,_currentValue2:ge,_threadCount:0};function yS(e,s,r,o,d,p,S,C,O){this.tag=1,this.containerInfo=e,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=ct(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=ct(0),this.hiddenUpdates=ct(null),this.identifierPrefix=o,this.onUncaughtError=d,this.onCaughtError=p,this.onRecoverableError=S,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=O,this.incompleteTransitions=new Map}function vm(e,s,r,o,d,p,S,C,O,V,ee,ie){return e=new yS(e,s,r,S,O,V,ee,ie,C),s=1,p===!0&&(s|=24),p=ps(3,null,null,s),e.current=p,p.stateNode=e,s=Hc(),s.refCount++,e.pooledCache=s,s.refCount++,p.memoizedState={element:o,isDehydrated:r,cache:s},Fc(p),e}function bm(e){return e?(e=nr,e):nr}function _m(e,s,r,o,d,p){d=bm(d),o.context===null?o.context=d:o.pendingContext=d,o=Qn(s),o.payload={element:r},p=p===void 0?null:p,p!==null&&(o.callback=p),r=Kn(e,o,s),r!==null&&(cs(r,e,s),ui(r,e,s))}function Sm(e,s){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var r=e.retryLane;e.retryLane=r!==0&&r<s?r:s}}function ud(e,s){Sm(e,s),(e=e.alternate)&&Sm(e,s)}function jm(e){if(e.tag===13||e.tag===31){var s=_a(e,67108864);s!==null&&cs(s,e,67108864),ud(e,67108864)}}function km(e){if(e.tag===13||e.tag===31){var s=vs();s=Bt(s);var r=_a(e,s);r!==null&&cs(r,e,s),ud(e,s)}}var yo=!0;function xS(e,s,r,o){var d=B.T;B.T=null;var p=se.p;try{se.p=2,dd(e,s,r,o)}finally{se.p=p,B.T=d}}function vS(e,s,r,o){var d=B.T;B.T=null;var p=se.p;try{se.p=8,dd(e,s,r,o)}finally{se.p=p,B.T=d}}function dd(e,s,r,o){if(yo){var d=hd(o);if(d===null)Zu(e,s,o,xo,r),wm(e,o);else if(_S(d,e,s,r,o))o.stopPropagation();else if(wm(e,o),s&4&&-1<bS.indexOf(e)){for(;d!==null;){var p=Fa(d);if(p!==null)switch(p.tag){case 3:if(p=p.stateNode,p.current.memoizedState.isDehydrated){var S=Ps(p.pendingLanes);if(S!==0){var C=p;for(C.pendingLanes|=2,C.entangledLanes|=2;S;){var O=1<<31-Pt(S);C.entanglements[1]|=O,S&=~O}an(p),(We&6)===0&&(Jl=vt()+500,wi(0))}}break;case 31:case 13:C=_a(p,2),C!==null&&cs(C,p,2),to(),ud(p,2)}if(p=hd(o),p===null&&Zu(e,s,o,xo,r),p===d)break;d=p}d!==null&&o.stopPropagation()}else Zu(e,s,o,null,r)}}function hd(e){return e=pc(e),fd(e)}var xo=null;function fd(e){if(xo=null,e=Va(e),e!==null){var s=u(e);if(s===null)e=null;else{var r=s.tag;if(r===13){if(e=f(s),e!==null)return e;e=null}else if(r===31){if(e=x(s),e!==null)return e;e=null}else if(r===3){if(s.stateNode.current.memoizedState.isDehydrated)return s.tag===3?s.stateNode.containerInfo:null;e=null}else s!==e&&(e=null)}}return xo=e,null}function Tm(e){switch(e){case"beforetoggle":case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"toggle":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 2;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 8;case"message":switch(hn()){case fn:return 2;case ga:return 8;case In:case Gr:return 32;case Pa:return 268435456;default:return 32}default:return 32}}var pd=!1,ia=null,la=null,oa=null,Di=new Map,Oi=new Map,ca=[],bS="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset".split(" ");function wm(e,s){switch(e){case"focusin":case"focusout":ia=null;break;case"dragenter":case"dragleave":la=null;break;case"mouseover":case"mouseout":oa=null;break;case"pointerover":case"pointerout":Di.delete(s.pointerId);break;case"gotpointercapture":case"lostpointercapture":Oi.delete(s.pointerId)}}function Li(e,s,r,o,d,p){return e===null||e.nativeEvent!==p?(e={blockedOn:s,domEventName:r,eventSystemFlags:o,nativeEvent:p,targetContainers:[d]},s!==null&&(s=Fa(s),s!==null&&jm(s)),e):(e.eventSystemFlags|=o,s=e.targetContainers,d!==null&&s.indexOf(d)===-1&&s.push(d),e)}function _S(e,s,r,o,d){switch(s){case"focusin":return ia=Li(ia,e,s,r,o,d),!0;case"dragenter":return la=Li(la,e,s,r,o,d),!0;case"mouseover":return oa=Li(oa,e,s,r,o,d),!0;case"pointerover":var p=d.pointerId;return Di.set(p,Li(Di.get(p)||null,e,s,r,o,d)),!0;case"gotpointercapture":return p=d.pointerId,Oi.set(p,Li(Oi.get(p)||null,e,s,r,o,d)),!0}return!1}function Em(e){var s=Va(e.target);if(s!==null){var r=u(s);if(r!==null){if(s=r.tag,s===13){if(s=f(r),s!==null){e.blockedOn=s,hs(e.priority,function(){km(r)});return}}else if(s===31){if(s=x(r),s!==null){e.blockedOn=s,hs(e.priority,function(){km(r)});return}}else if(s===3&&r.stateNode.current.memoizedState.isDehydrated){e.blockedOn=r.tag===3?r.stateNode.containerInfo:null;return}}}e.blockedOn=null}function vo(e){if(e.blockedOn!==null)return!1;for(var s=e.targetContainers;0<s.length;){var r=hd(e.nativeEvent);if(r===null){r=e.nativeEvent;var o=new r.constructor(r.type,r);fc=o,r.target.dispatchEvent(o),fc=null}else return s=Fa(r),s!==null&&jm(s),e.blockedOn=r,!1;s.shift()}return!0}function Cm(e,s,r){vo(e)&&r.delete(s)}function SS(){pd=!1,ia!==null&&vo(ia)&&(ia=null),la!==null&&vo(la)&&(la=null),oa!==null&&vo(oa)&&(oa=null),Di.forEach(Cm),Oi.forEach(Cm)}function bo(e,s){e.blockedOn===s&&(e.blockedOn=null,pd||(pd=!0,n.unstable_scheduleCallback(n.unstable_NormalPriority,SS)))}var _o=null;function Nm(e){_o!==e&&(_o=e,n.unstable_scheduleCallback(n.unstable_NormalPriority,function(){_o===e&&(_o=null);for(var s=0;s<e.length;s+=3){var r=e[s],o=e[s+1],d=e[s+2];if(typeof o!="function"){if(fd(o||r)===null)continue;break}var p=Fa(r);p!==null&&(e.splice(s,3),s-=3,hu(p,{pending:!0,data:d,method:r.method,action:o},o,d))}}))}function Er(e){function s(O){return bo(O,e)}ia!==null&&bo(ia,e),la!==null&&bo(la,e),oa!==null&&bo(oa,e),Di.forEach(s),Oi.forEach(s);for(var r=0;r<ca.length;r++){var o=ca[r];o.blockedOn===e&&(o.blockedOn=null)}for(;0<ca.length&&(r=ca[0],r.blockedOn===null);)Em(r),r.blockedOn===null&&ca.shift();if(r=(e.ownerDocument||e).$$reactFormReplay,r!=null)for(o=0;o<r.length;o+=3){var d=r[o],p=r[o+1],S=d[ns]||null;if(typeof p=="function")S||Nm(r);else if(S){var C=null;if(p&&p.hasAttribute("formAction")){if(d=p,S=p[ns]||null)C=S.formAction;else if(fd(d)!==null)continue}else C=S.action;typeof C=="function"?r[o+1]=C:(r.splice(o,3),o-=3),Nm(r)}}}function Am(){function e(p){p.canIntercept&&p.info==="react-transition"&&p.intercept({handler:function(){return new Promise(function(S){return d=S})},focusReset:"manual",scroll:"manual"})}function s(){d!==null&&(d(),d=null),o||setTimeout(r,20)}function r(){if(!o&&!navigation.transition){var p=navigation.currentEntry;p&&p.url!=null&&navigation.navigate(p.url,{state:p.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var o=!1,d=null;return navigation.addEventListener("navigate",e),navigation.addEventListener("navigatesuccess",s),navigation.addEventListener("navigateerror",s),setTimeout(r,100),function(){o=!0,navigation.removeEventListener("navigate",e),navigation.removeEventListener("navigatesuccess",s),navigation.removeEventListener("navigateerror",s),d!==null&&(d(),d=null)}}}function gd(e){this._internalRoot=e}So.prototype.render=gd.prototype.render=function(e){var s=this._internalRoot;if(s===null)throw Error(l(409));var r=s.current,o=vs();_m(r,o,e,s,null,null)},So.prototype.unmount=gd.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var s=e.containerInfo;_m(e.current,2,null,e,null,null),to(),s[Ga]=null}};function So(e){this._internalRoot=e}So.prototype.unstable_scheduleHydration=function(e){if(e){var s=ul();e={blockedOn:null,target:e,priority:s};for(var r=0;r<ca.length&&s!==0&&s<ca[r].priority;r++);ca.splice(r,0,e),r===0&&Em(e)}};var Rm=t.version;if(Rm!=="19.2.5")throw Error(l(527,Rm,"19.2.5"));se.findDOMNode=function(e){var s=e._reactInternals;if(s===void 0)throw typeof e.render=="function"?Error(l(188)):(e=Object.keys(e).join(","),Error(l(268,e)));return e=m(s),e=e!==null?y(e):null,e=e===null?null:e.stateNode,e};var jS={bundleType:0,version:"19.2.5",rendererPackageName:"react-dom",currentDispatcherRef:B,reconcilerVersion:"19.2.5"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var jo=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!jo.isDisabled&&jo.supportsFiber)try{pn=jo.inject(jS),Ht=jo}catch{}}return qi.createRoot=function(e,s){if(!c(e))throw Error(l(299));var r=!1,o="",d=Ip,p=Bp,S=Up;return s!=null&&(s.unstable_strictMode===!0&&(r=!0),s.identifierPrefix!==void 0&&(o=s.identifierPrefix),s.onUncaughtError!==void 0&&(d=s.onUncaughtError),s.onCaughtError!==void 0&&(p=s.onCaughtError),s.onRecoverableError!==void 0&&(S=s.onRecoverableError)),s=vm(e,1,!1,null,null,r,o,null,d,p,S,Am),e[Ga]=s.current,Xu(e),new gd(s)},qi.hydrateRoot=function(e,s,r){if(!c(e))throw Error(l(299));var o=!1,d="",p=Ip,S=Bp,C=Up,O=null;return r!=null&&(r.unstable_strictMode===!0&&(o=!0),r.identifierPrefix!==void 0&&(d=r.identifierPrefix),r.onUncaughtError!==void 0&&(p=r.onUncaughtError),r.onCaughtError!==void 0&&(S=r.onCaughtError),r.onRecoverableError!==void 0&&(C=r.onRecoverableError),r.formState!==void 0&&(O=r.formState)),s=vm(e,1,!0,s,r??null,o,d,O,p,S,C,Am),s.context=bm(null),r=s.current,o=vs(),o=Bt(o),d=Qn(o),d.callback=null,Kn(r,d,o),r=o,s.current.lanes=r,bt(s,r),an(s),e[Ga]=s.current,Xu(e),new So(s)},qi.version="19.2.5",qi}var $m;function OS(){if($m)return xd.exports;$m=1;function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(t){console.error(t)}}return n(),xd.exports=DS(),xd.exports}var LS=OS();const MS=vx(LS);var Hm="popstate";function Pm(n){return typeof n=="object"&&n!=null&&"pathname"in n&&"search"in n&&"hash"in n&&"state"in n&&"key"in n}function qS(n={}){function t(l,c){let u=c.state?.masked,{pathname:f,search:x,hash:g}=u||l.location;return Gd("",{pathname:f,search:x,hash:g},c.state&&c.state.usr||null,c.state&&c.state.key||"default",u?{pathname:l.location.pathname,search:l.location.search,hash:l.location.hash}:void 0)}function i(l,c){return typeof c=="string"?c:Ji(c)}return BS(t,i,null,n)}function pt(n,t){if(n===!1||n===null||typeof n>"u")throw new Error(t)}function Us(n,t){if(!n){typeof console<"u"&&console.warn(t);try{throw new Error(t)}catch{}}}function IS(){return Math.random().toString(36).substring(2,10)}function Gm(n,t){return{usr:n.state,key:n.key,idx:t,masked:n.unstable_mask?{pathname:n.pathname,search:n.search,hash:n.hash}:void 0}}function Gd(n,t,i=null,l,c){return{pathname:typeof n=="string"?n:n.pathname,search:"",hash:"",...typeof t=="string"?Mr(t):t,state:i,key:t&&t.key||l||IS(),unstable_mask:c}}function Ji({pathname:n="/",search:t="",hash:i=""}){return t&&t!=="?"&&(n+=t.charAt(0)==="?"?t:"?"+t),i&&i!=="#"&&(n+=i.charAt(0)==="#"?i:"#"+i),n}function Mr(n){let t={};if(n){let i=n.indexOf("#");i>=0&&(t.hash=n.substring(i),n=n.substring(0,i));let l=n.indexOf("?");l>=0&&(t.search=n.substring(l),n=n.substring(0,l)),n&&(t.pathname=n)}return t}function BS(n,t,i,l={}){let{window:c=document.defaultView,v5Compat:u=!1}=l,f=c.history,x="POP",g=null,m=y();m==null&&(m=0,f.replaceState({...f.state,idx:m},""));function y(){return(f.state||{idx:null}).idx}function _(){x="POP";let w=y(),T=w==null?null:w-m;m=w,g&&g({action:x,location:E.location,delta:T})}function v(w,T){x="PUSH";let R=Pm(w)?w:Gd(E.location,w,T);m=y()+1;let z=Gm(R,m),L=E.createHref(R.unstable_mask||R);try{f.pushState(z,"",L)}catch(M){if(M instanceof DOMException&&M.name==="DataCloneError")throw M;c.location.assign(L)}u&&g&&g({action:x,location:E.location,delta:1})}function j(w,T){x="REPLACE";let R=Pm(w)?w:Gd(E.location,w,T);m=y();let z=Gm(R,m),L=E.createHref(R.unstable_mask||R);f.replaceState(z,"",L),u&&g&&g({action:x,location:E.location,delta:0})}function k(w){return US(w)}let E={get action(){return x},get location(){return n(c,f)},listen(w){if(g)throw new Error("A history only accepts one active listener");return c.addEventListener(Hm,_),g=w,()=>{c.removeEventListener(Hm,_),g=null}},createHref(w){return t(c,w)},createURL:k,encodeLocation(w){let T=k(w);return{pathname:T.pathname,search:T.search,hash:T.hash}},push:v,replace:j,go(w){return f.go(w)}};return E}function US(n,t=!1){let i="http://localhost";typeof window<"u"&&(i=window.location.origin!=="null"?window.location.origin:window.location.href),pt(i,"No window.location.(origin|href) available to create URL");let l=typeof n=="string"?n:Ji(n);return l=l.replace(/ $/,"%20"),!t&&l.startsWith("//")&&(l=i+l),new URL(l,i)}function bx(n,t,i="/"){return $S(n,t,i,!1)}function $S(n,t,i,l){let c=typeof t=="string"?Mr(t):t,u=Ln(c.pathname||"/",i);if(u==null)return null;let f=_x(n);HS(f);let x=null;for(let g=0;x==null&&g<f.length;++g){let m=JS(u);x=ZS(f[g],m,l)}return x}function _x(n,t=[],i=[],l="",c=!1){let u=(f,x,g=c,m)=>{let y={relativePath:m===void 0?f.path||"":m,caseSensitive:f.caseSensitive===!0,childrenIndex:x,route:f};if(y.relativePath.startsWith("/")){if(!y.relativePath.startsWith(l)&&g)return;pt(y.relativePath.startsWith(l),`Absolute route path "${y.relativePath}" nested under path "${l}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),y.relativePath=y.relativePath.slice(l.length)}let _=on([l,y.relativePath]),v=i.concat(y);f.children&&f.children.length>0&&(pt(f.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${_}".`),_x(f.children,t,v,_,g)),!(f.path==null&&!f.index)&&t.push({path:_,score:KS(_,f.index),routesMeta:v})};return n.forEach((f,x)=>{if(f.path===""||!f.path?.includes("?"))u(f,x);else for(let g of Sx(f.path))u(f,x,!0,g)}),t}function Sx(n){let t=n.split("/");if(t.length===0)return[];let[i,...l]=t,c=i.endsWith("?"),u=i.replace(/\?$/,"");if(l.length===0)return c?[u,""]:[u];let f=Sx(l.join("/")),x=[];return x.push(...f.map(g=>g===""?u:[u,g].join("/"))),c&&x.push(...f),x.map(g=>n.startsWith("/")&&g===""?"/":g)}function HS(n){n.sort((t,i)=>t.score!==i.score?i.score-t.score:XS(t.routesMeta.map(l=>l.childrenIndex),i.routesMeta.map(l=>l.childrenIndex)))}var PS=/^:[\w-]+$/,GS=3,VS=2,FS=1,YS=10,QS=-2,Vm=n=>n==="*";function KS(n,t){let i=n.split("/"),l=i.length;return i.some(Vm)&&(l+=QS),t&&(l+=VS),i.filter(c=>!Vm(c)).reduce((c,u)=>c+(PS.test(u)?GS:u===""?FS:YS),l)}function XS(n,t){return n.length===t.length&&n.slice(0,-1).every((l,c)=>l===t[c])?n[n.length-1]-t[t.length-1]:0}function ZS(n,t,i=!1){let{routesMeta:l}=n,c={},u="/",f=[];for(let x=0;x<l.length;++x){let g=l[x],m=x===l.length-1,y=u==="/"?t:t.slice(u.length)||"/",_=Go({path:g.relativePath,caseSensitive:g.caseSensitive,end:m},y),v=g.route;if(!_&&m&&i&&!l[l.length-1].route.index&&(_=Go({path:g.relativePath,caseSensitive:g.caseSensitive,end:!1},y)),!_)return null;Object.assign(c,_.params),f.push({params:c,pathname:on([u,_.pathname]),pathnameBase:nj(on([u,_.pathnameBase])),route:v}),_.pathnameBase!=="/"&&(u=on([u,_.pathnameBase]))}return f}function Go(n,t){typeof n=="string"&&(n={path:n,caseSensitive:!1,end:!0});let[i,l]=WS(n.path,n.caseSensitive,n.end),c=t.match(i);if(!c)return null;let u=c[0],f=u.replace(/(.)\/+$/,"$1"),x=c.slice(1);return{params:l.reduce((m,{paramName:y,isOptional:_},v)=>{if(y==="*"){let k=x[v]||"";f=u.slice(0,u.length-k.length).replace(/(.)\/+$/,"$1")}const j=x[v];return _&&!j?m[y]=void 0:m[y]=(j||"").replace(/%2F/g,"/"),m},{}),pathname:u,pathnameBase:f,pattern:n}}function WS(n,t=!1,i=!0){Us(n==="*"||!n.endsWith("*")||n.endsWith("/*"),`Route path "${n}" will be treated as if it were "${n.replace(/\*$/,"/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${n.replace(/\*$/,"/*")}".`);let l=[],c="^"+n.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(f,x,g,m,y)=>{if(l.push({paramName:x,isOptional:g!=null}),g){let _=y.charAt(m+f.length);return _&&_!=="/"?"/([^\\/]*)":"(?:/([^\\/]*))?"}return"/([^\\/]+)"}).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return n.endsWith("*")?(l.push({paramName:"*"}),c+=n==="*"||n==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):i?c+="\\/*$":n!==""&&n!=="/"&&(c+="(?:(?=\\/|$))"),[new RegExp(c,t?void 0:"i"),l]}function JS(n){try{return n.split("/").map(t=>decodeURIComponent(t).replace(/\//g,"%2F")).join("/")}catch(t){return Us(!1,`The URL path "${n}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${t}).`),n}}function Ln(n,t){if(t==="/")return n;if(!n.toLowerCase().startsWith(t.toLowerCase()))return null;let i=t.endsWith("/")?t.length-1:t.length,l=n.charAt(i);return l&&l!=="/"?null:n.slice(i)||"/"}var ej=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;function tj(n,t="/"){let{pathname:i,search:l="",hash:c=""}=typeof n=="string"?Mr(n):n,u;return i?(i=i.replace(/\/\/+/g,"/"),i.startsWith("/")?u=Fm(i.substring(1),"/"):u=Fm(i,t)):u=t,{pathname:u,search:aj(l),hash:rj(c)}}function Fm(n,t){let i=t.replace(/\/+$/,"").split("/");return n.split("/").forEach(c=>{c===".."?i.length>1&&i.pop():c!=="."&&i.push(c)}),i.length>1?i.join("/"):"/"}function Sd(n,t,i,l){return`Cannot include a '${n}' character in a manually specified \`to.${t}\` field [${JSON.stringify(l)}]. Please separate it out to the \`to.${i}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`}function sj(n){return n.filter((t,i)=>i===0||t.route.path&&t.route.path.length>0)}function oh(n){let t=sj(n);return t.map((i,l)=>l===t.length-1?i.pathname:i.pathnameBase)}function Zo(n,t,i,l=!1){let c;typeof n=="string"?c=Mr(n):(c={...n},pt(!c.pathname||!c.pathname.includes("?"),Sd("?","pathname","search",c)),pt(!c.pathname||!c.pathname.includes("#"),Sd("#","pathname","hash",c)),pt(!c.search||!c.search.includes("#"),Sd("#","search","hash",c)));let u=n===""||c.pathname==="",f=u?"/":c.pathname,x;if(f==null)x=i;else{let _=t.length-1;if(!l&&f.startsWith("..")){let v=f.split("/");for(;v[0]==="..";)v.shift(),_-=1;c.pathname=v.join("/")}x=_>=0?t[_]:"/"}let g=tj(c,x),m=f&&f!=="/"&&f.endsWith("/"),y=(u||f===".")&&i.endsWith("/");return!g.pathname.endsWith("/")&&(m||y)&&(g.pathname+="/"),g}var on=n=>n.join("/").replace(/\/\/+/g,"/"),nj=n=>n.replace(/\/+$/,"").replace(/^\/*/,"/"),aj=n=>!n||n==="?"?"":n.startsWith("?")?n:"?"+n,rj=n=>!n||n==="#"?"":n.startsWith("#")?n:"#"+n,ij=class{constructor(n,t,i,l=!1){this.status=n,this.statusText=t||"",this.internal=l,i instanceof Error?(this.data=i.toString(),this.error=i):this.data=i}};function lj(n){return n!=null&&typeof n.status=="number"&&typeof n.statusText=="string"&&typeof n.internal=="boolean"&&"data"in n}function oj(n){return n.map(t=>t.route.path).filter(Boolean).join("/").replace(/\/\/*/g,"/")||"/"}var jx=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function kx(n,t){let i=n;if(typeof i!="string"||!ej.test(i))return{absoluteURL:void 0,isExternal:!1,to:i};let l=i,c=!1;if(jx)try{let u=new URL(window.location.href),f=i.startsWith("//")?new URL(u.protocol+i):new URL(i),x=Ln(f.pathname,t);f.origin===u.origin&&x!=null?i=x+f.search+f.hash:c=!0}catch{Us(!1,`<Link to="${i}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}return{absoluteURL:l,isExternal:c,to:i}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");var Tx=["POST","PUT","PATCH","DELETE"];new Set(Tx);var cj=["GET",...Tx];new Set(cj);var qr=h.createContext(null);qr.displayName="DataRouter";var Wo=h.createContext(null);Wo.displayName="DataRouterState";var wx=h.createContext(!1);function uj(){return h.useContext(wx)}var Ex=h.createContext({isTransitioning:!1});Ex.displayName="ViewTransition";var dj=h.createContext(new Map);dj.displayName="Fetchers";var hj=h.createContext(null);hj.displayName="Await";var Ss=h.createContext(null);Ss.displayName="Navigation";var tl=h.createContext(null);tl.displayName="Location";var $s=h.createContext({outlet:null,matches:[],isDataRoute:!1});$s.displayName="Route";var ch=h.createContext(null);ch.displayName="RouteError";var Cx="REACT_ROUTER_ERROR",fj="REDIRECT",pj="ROUTE_ERROR_RESPONSE";function gj(n){if(n.startsWith(`${Cx}:${fj}:{`))try{let t=JSON.parse(n.slice(28));if(typeof t=="object"&&t&&typeof t.status=="number"&&typeof t.statusText=="string"&&typeof t.location=="string"&&typeof t.reloadDocument=="boolean"&&typeof t.replace=="boolean")return t}catch{}}function mj(n){if(n.startsWith(`${Cx}:${pj}:{`))try{let t=JSON.parse(n.slice(40));if(typeof t=="object"&&t&&typeof t.status=="number"&&typeof t.statusText=="string")return new ij(t.status,t.statusText,t.data)}catch{}}function yj(n,{relative:t}={}){pt(Ir(),"useHref() may be used only in the context of a <Router> component.");let{basename:i,navigator:l}=h.useContext(Ss),{hash:c,pathname:u,search:f}=sl(n,{relative:t}),x=u;return i!=="/"&&(x=u==="/"?i:on([i,u])),l.createHref({pathname:x,search:f,hash:c})}function Ir(){return h.useContext(tl)!=null}function qt(){return pt(Ir(),"useLocation() may be used only in the context of a <Router> component."),h.useContext(tl).location}var Nx="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function Ax(n){h.useContext(Ss).static||h.useLayoutEffect(n)}function ze(){let{isDataRoute:n}=h.useContext($s);return n?zj():xj()}function xj(){pt(Ir(),"useNavigate() may be used only in the context of a <Router> component.");let n=h.useContext(qr),{basename:t,navigator:i}=h.useContext(Ss),{matches:l}=h.useContext($s),{pathname:c}=qt(),u=JSON.stringify(oh(l)),f=h.useRef(!1);return Ax(()=>{f.current=!0}),h.useCallback((g,m={})=>{if(Us(f.current,Nx),!f.current)return;if(typeof g=="number"){i.go(g);return}let y=Zo(g,JSON.parse(u),c,m.relative==="path");n==null&&t!=="/"&&(y.pathname=y.pathname==="/"?t:on([t,y.pathname])),(m.replace?i.replace:i.push)(y,m.state,m)},[t,i,u,c,n])}var vj=h.createContext(null);function bj(n){let t=h.useContext($s).outlet;return h.useMemo(()=>t&&h.createElement(vj.Provider,{value:n},t),[t,n])}function Wt(){let{matches:n}=h.useContext($s),t=n[n.length-1];return t?t.params:{}}function sl(n,{relative:t}={}){let{matches:i}=h.useContext($s),{pathname:l}=qt(),c=JSON.stringify(oh(i));return h.useMemo(()=>Zo(n,JSON.parse(c),l,t==="path"),[n,c,l,t])}function _j(n,t){return Rx(n,t)}function Rx(n,t,i){pt(Ir(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:l}=h.useContext(Ss),{matches:c}=h.useContext($s),u=c[c.length-1],f=u?u.params:{},x=u?u.pathname:"/",g=u?u.pathnameBase:"/",m=u&&u.route;{let w=m&&m.path||"";Dx(x,!m||w.endsWith("*")||w.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${x}" (under <Route path="${w}">) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render.
|
|
10
10
|
|
|
11
11
|
Please change the parent <Route path="${w}"> to <Route path="${w==="/"?"*":`${w}/*`}">.`)}let y=qt(),_;if(t){let w=typeof t=="string"?Mr(t):t;pt(g==="/"||w.pathname?.startsWith(g),`When overriding the location using \`<Routes location>\` or \`useRoutes(routes, location)\`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "${g}" but pathname "${w.pathname}" was given in the \`location\` prop.`),_=w}else _=y;let v=_.pathname||"/",j=v;if(g!=="/"){let w=g.replace(/^\//,"").split("/");j="/"+v.replace(/^\//,"").split("/").slice(w.length).join("/")}let k=bx(n,{pathname:j});Us(m||k!=null,`No routes matched location "${_.pathname}${_.search}${_.hash}" `),Us(k==null||k[k.length-1].route.element!==void 0||k[k.length-1].route.Component!==void 0||k[k.length-1].route.lazy!==void 0,`Matched leaf route at location "${_.pathname}${_.search}${_.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`);let E=wj(k&&k.map(w=>Object.assign({},w,{params:Object.assign({},f,w.params),pathname:on([g,l.encodeLocation?l.encodeLocation(w.pathname.replace(/%/g,"%25").replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:w.pathname]),pathnameBase:w.pathnameBase==="/"?g:on([g,l.encodeLocation?l.encodeLocation(w.pathnameBase.replace(/%/g,"%25").replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:w.pathnameBase])})),c,i);return t&&E?h.createElement(tl.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",unstable_mask:void 0,..._},navigationType:"POP"}},E):E}function Sj(){let n=Rj(),t=lj(n)?`${n.status} ${n.statusText}`:n instanceof Error?n.message:JSON.stringify(n),i=n instanceof Error?n.stack:null,l="rgba(200,200,200, 0.5)",c={padding:"0.5rem",backgroundColor:l},u={padding:"2px 4px",backgroundColor:l},f=null;return console.error("Error handled by React Router default ErrorBoundary:",n),f=h.createElement(h.Fragment,null,h.createElement("p",null,"💿 Hey developer 👋"),h.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",h.createElement("code",{style:u},"ErrorBoundary")," or"," ",h.createElement("code",{style:u},"errorElement")," prop on your route.")),h.createElement(h.Fragment,null,h.createElement("h2",null,"Unexpected Application Error!"),h.createElement("h3",{style:{fontStyle:"italic"}},t),i?h.createElement("pre",{style:c},i):null,f)}var jj=h.createElement(Sj,null),zx=class extends h.Component{constructor(n){super(n),this.state={location:n.location,revalidation:n.revalidation,error:n.error}}static getDerivedStateFromError(n){return{error:n}}static getDerivedStateFromProps(n,t){return t.location!==n.location||t.revalidation!=="idle"&&n.revalidation==="idle"?{error:n.error,location:n.location,revalidation:n.revalidation}:{error:n.error!==void 0?n.error:t.error,location:t.location,revalidation:n.revalidation||t.revalidation}}componentDidCatch(n,t){this.props.onError?this.props.onError(n,t):console.error("React Router caught the following error during render",n)}render(){let n=this.state.error;if(this.context&&typeof n=="object"&&n&&"digest"in n&&typeof n.digest=="string"){const i=mj(n.digest);i&&(n=i)}let t=n!==void 0?h.createElement($s.Provider,{value:this.props.routeContext},h.createElement(ch.Provider,{value:n,children:this.props.component})):this.props.children;return this.context?h.createElement(kj,{error:n},t):t}};zx.contextType=wx;var jd=new WeakMap;function kj({children:n,error:t}){let{basename:i}=h.useContext(Ss);if(typeof t=="object"&&t&&"digest"in t&&typeof t.digest=="string"){let l=gj(t.digest);if(l){let c=jd.get(t);if(c)throw c;let u=kx(l.location,i);if(jx&&!jd.get(t))if(u.isExternal||l.reloadDocument)window.location.href=u.absoluteURL||u.to;else{const f=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(u.to,{replace:l.replace}));throw jd.set(t,f),f}return h.createElement("meta",{httpEquiv:"refresh",content:`0;url=${u.absoluteURL||u.to}`})}}return n}function Tj({routeContext:n,match:t,children:i}){let l=h.useContext(qr);return l&&l.static&&l.staticContext&&(t.route.errorElement||t.route.ErrorBoundary)&&(l.staticContext._deepestRenderedBoundaryId=t.route.id),h.createElement($s.Provider,{value:n},i)}function wj(n,t=[],i){let l=i?.state;if(n==null){if(!l)return null;if(l.errors)n=l.matches;else if(t.length===0&&!l.initialized&&l.matches.length>0)n=l.matches;else return null}let c=n,u=l?.errors;if(u!=null){let y=c.findIndex(_=>_.route.id&&u?.[_.route.id]!==void 0);pt(y>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(u).join(",")}`),c=c.slice(0,Math.min(c.length,y+1))}let f=!1,x=-1;if(i&&l){f=l.renderFallback;for(let y=0;y<c.length;y++){let _=c[y];if((_.route.HydrateFallback||_.route.hydrateFallbackElement)&&(x=y),_.route.id){let{loaderData:v,errors:j}=l,k=_.route.loader&&!v.hasOwnProperty(_.route.id)&&(!j||j[_.route.id]===void 0);if(_.route.lazy||k){i.isStatic&&(f=!0),x>=0?c=c.slice(0,x+1):c=[c[0]];break}}}}let g=i?.onError,m=l&&g?(y,_)=>{g(y,{location:l.location,params:l.matches?.[0]?.params??{},unstable_pattern:oj(l.matches),errorInfo:_})}:void 0;return c.reduceRight((y,_,v)=>{let j,k=!1,E=null,w=null;l&&(j=u&&_.route.id?u[_.route.id]:void 0,E=_.route.errorElement||jj,f&&(x<0&&v===0?(Dx("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),k=!0,w=null):x===v&&(k=!0,w=_.route.hydrateFallbackElement||null)));let T=t.concat(c.slice(0,v+1)),R=()=>{let z;return j?z=E:k?z=w:_.route.Component?z=h.createElement(_.route.Component,null):_.route.element?z=_.route.element:z=y,h.createElement(Tj,{match:_,routeContext:{outlet:y,matches:T,isDataRoute:l!=null},children:z})};return l&&(_.route.ErrorBoundary||_.route.errorElement||v===0)?h.createElement(zx,{location:l.location,revalidation:l.revalidation,component:E,error:j,children:R(),routeContext:{outlet:null,matches:T,isDataRoute:!0},onError:m}):R()},null)}function uh(n){return`${n} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Ej(n){let t=h.useContext(qr);return pt(t,uh(n)),t}function Cj(n){let t=h.useContext(Wo);return pt(t,uh(n)),t}function Nj(n){let t=h.useContext($s);return pt(t,uh(n)),t}function dh(n){let t=Nj(n),i=t.matches[t.matches.length-1];return pt(i.route.id,`${n} can only be used on routes that contain a unique "id"`),i.route.id}function Aj(){return dh("useRouteId")}function Rj(){let n=h.useContext(ch),t=Cj("useRouteError"),i=dh("useRouteError");return n!==void 0?n:t.errors?.[i]}function zj(){let{router:n}=Ej("useNavigate"),t=dh("useNavigate"),i=h.useRef(!1);return Ax(()=>{i.current=!0}),h.useCallback(async(c,u={})=>{Us(i.current,Nx),i.current&&(typeof c=="number"?await n.navigate(c):await n.navigate(c,{fromRouteId:t,...u}))},[n,t])}var Ym={};function Dx(n,t,i){!t&&!Ym[n]&&(Ym[n]=!0,Us(!1,i))}h.memo(Dj);function Dj({routes:n,future:t,state:i,isStatic:l,onError:c}){return Rx(n,void 0,{state:i,isStatic:l,onError:c})}function Ia({to:n,replace:t,state:i,relative:l}){pt(Ir(),"<Navigate> may be used only in the context of a <Router> component.");let{static:c}=h.useContext(Ss);Us(!c,"<Navigate> must not be used on the initial render in a <StaticRouter>. This is a no-op, but you should modify your code so the <Navigate> is only ever rendered in response to some user interaction or state change.");let{matches:u}=h.useContext($s),{pathname:f}=qt(),x=ze(),g=Zo(n,oh(u),f,l==="path"),m=JSON.stringify(g);return h.useEffect(()=>{x(JSON.parse(m),{replace:t,state:i,relative:l})},[x,m,l,t,i]),null}function Kt(n){return bj(n.context)}function Se(n){pt(!1,"A <Route> is only ever to be used as the child of <Routes> element, never rendered directly. Please wrap your <Route> in a <Routes>.")}function Oj({basename:n="/",children:t=null,location:i,navigationType:l="POP",navigator:c,static:u=!1,unstable_useTransitions:f}){pt(!Ir(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let x=n.replace(/^\/*/,"/"),g=h.useMemo(()=>({basename:x,navigator:c,static:u,unstable_useTransitions:f,future:{}}),[x,c,u,f]);typeof i=="string"&&(i=Mr(i));let{pathname:m="/",search:y="",hash:_="",state:v=null,key:j="default",unstable_mask:k}=i,E=h.useMemo(()=>{let w=Ln(m,x);return w==null?null:{location:{pathname:w,search:y,hash:_,state:v,key:j,unstable_mask:k},navigationType:l}},[x,m,y,_,v,j,l,k]);return Us(E!=null,`<Router basename="${x}"> is not able to match the URL "${m}${y}${_}" because it does not start with the basename, so the <Router> won't render anything.`),E==null?null:h.createElement(Ss.Provider,{value:g},h.createElement(tl.Provider,{children:t,value:E}))}function dn({children:n,location:t}){return _j(Vd(n),t)}function Vd(n,t=[]){let i=[];return h.Children.forEach(n,(l,c)=>{if(!h.isValidElement(l))return;let u=[...t,c];if(l.type===h.Fragment){i.push.apply(i,Vd(l.props.children,u));return}pt(l.type===Se,`[${typeof l.type=="string"?l.type:l.type.name}] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>`),pt(!l.props.index||!l.props.children,"An index route cannot have child routes.");let f={id:l.props.id||u.join("-"),caseSensitive:l.props.caseSensitive,element:l.props.element,Component:l.props.Component,index:l.props.index,path:l.props.path,middleware:l.props.middleware,loader:l.props.loader,action:l.props.action,hydrateFallbackElement:l.props.hydrateFallbackElement,HydrateFallback:l.props.HydrateFallback,errorElement:l.props.errorElement,ErrorBoundary:l.props.ErrorBoundary,hasErrorBoundary:l.props.hasErrorBoundary===!0||l.props.ErrorBoundary!=null||l.props.errorElement!=null,shouldRevalidate:l.props.shouldRevalidate,handle:l.props.handle,lazy:l.props.lazy};l.props.children&&(f.children=Vd(l.props.children,u)),i.push(f)}),i}var qo="get",Io="application/x-www-form-urlencoded";function Jo(n){return typeof HTMLElement<"u"&&n instanceof HTMLElement}function Lj(n){return Jo(n)&&n.tagName.toLowerCase()==="button"}function Mj(n){return Jo(n)&&n.tagName.toLowerCase()==="form"}function qj(n){return Jo(n)&&n.tagName.toLowerCase()==="input"}function Ij(n){return!!(n.metaKey||n.altKey||n.ctrlKey||n.shiftKey)}function Bj(n,t){return n.button===0&&(!t||t==="_self")&&!Ij(n)}function Fd(n=""){return new URLSearchParams(typeof n=="string"||Array.isArray(n)||n instanceof URLSearchParams?n:Object.keys(n).reduce((t,i)=>{let l=n[i];return t.concat(Array.isArray(l)?l.map(c=>[i,c]):[[i,l]])},[]))}function Uj(n,t){let i=Fd(n);return t&&t.forEach((l,c)=>{i.has(c)||t.getAll(c).forEach(u=>{i.append(c,u)})}),i}var ko=null;function $j(){if(ko===null)try{new FormData(document.createElement("form"),0),ko=!1}catch{ko=!0}return ko}var Hj=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function kd(n){return n!=null&&!Hj.has(n)?(Us(!1,`"${n}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${Io}"`),null):n}function Pj(n,t){let i,l,c,u,f;if(Mj(n)){let x=n.getAttribute("action");l=x?Ln(x,t):null,i=n.getAttribute("method")||qo,c=kd(n.getAttribute("enctype"))||Io,u=new FormData(n)}else if(Lj(n)||qj(n)&&(n.type==="submit"||n.type==="image")){let x=n.form;if(x==null)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');let g=n.getAttribute("formaction")||x.getAttribute("action");if(l=g?Ln(g,t):null,i=n.getAttribute("formmethod")||x.getAttribute("method")||qo,c=kd(n.getAttribute("formenctype"))||kd(x.getAttribute("enctype"))||Io,u=new FormData(x,n),!$j()){let{name:m,type:y,value:_}=n;if(y==="image"){let v=m?`${m}.`:"";u.append(`${v}x`,"0"),u.append(`${v}y`,"0")}else m&&u.append(m,_)}}else{if(Jo(n))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');i=qo,l=null,c=Io,f=n}return u&&c==="text/plain"&&(f=u,u=void 0),{action:l,method:i.toLowerCase(),encType:c,formData:u,body:f}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function hh(n,t){if(n===!1||n===null||typeof n>"u")throw new Error(t)}function Ox(n,t,i,l){let c=typeof n=="string"?new URL(n,typeof window>"u"?"server://singlefetch/":window.location.origin):n;return i?c.pathname.endsWith("/")?c.pathname=`${c.pathname}_.${l}`:c.pathname=`${c.pathname}.${l}`:c.pathname==="/"?c.pathname=`_root.${l}`:t&&Ln(c.pathname,t)==="/"?c.pathname=`${t.replace(/\/$/,"")}/_root.${l}`:c.pathname=`${c.pathname.replace(/\/$/,"")}.${l}`,c}async function Gj(n,t){if(n.id in t)return t[n.id];try{let i=await import(n.module);return t[n.id]=i,i}catch(i){return console.error(`Error loading route module \`${n.module}\`, reloading page...`),console.error(i),window.__reactRouterContext&&window.__reactRouterContext.isSpaMode,window.location.reload(),new Promise(()=>{})}}function Vj(n){return n==null?!1:n.href==null?n.rel==="preload"&&typeof n.imageSrcSet=="string"&&typeof n.imageSizes=="string":typeof n.rel=="string"&&typeof n.href=="string"}async function Fj(n,t,i){let l=await Promise.all(n.map(async c=>{let u=t.routes[c.route.id];if(u){let f=await Gj(u,i);return f.links?f.links():[]}return[]}));return Xj(l.flat(1).filter(Vj).filter(c=>c.rel==="stylesheet"||c.rel==="preload").map(c=>c.rel==="stylesheet"?{...c,rel:"prefetch",as:"style"}:{...c,rel:"prefetch"}))}function Qm(n,t,i,l,c,u){let f=(g,m)=>i[m]?g.route.id!==i[m].route.id:!0,x=(g,m)=>i[m].pathname!==g.pathname||i[m].route.path?.endsWith("*")&&i[m].params["*"]!==g.params["*"];return u==="assets"?t.filter((g,m)=>f(g,m)||x(g,m)):u==="data"?t.filter((g,m)=>{let y=l.routes[g.route.id];if(!y||!y.hasLoader)return!1;if(f(g,m)||x(g,m))return!0;if(g.route.shouldRevalidate){let _=g.route.shouldRevalidate({currentUrl:new URL(c.pathname+c.search+c.hash,window.origin),currentParams:i[0]?.params||{},nextUrl:new URL(n,window.origin),nextParams:g.params,defaultShouldRevalidate:!0});if(typeof _=="boolean")return _}return!0}):[]}function Yj(n,t,{includeHydrateFallback:i}={}){return Qj(n.map(l=>{let c=t.routes[l.route.id];if(!c)return[];let u=[c.module];return c.clientActionModule&&(u=u.concat(c.clientActionModule)),c.clientLoaderModule&&(u=u.concat(c.clientLoaderModule)),i&&c.hydrateFallbackModule&&(u=u.concat(c.hydrateFallbackModule)),c.imports&&(u=u.concat(c.imports)),u}).flat(1))}function Qj(n){return[...new Set(n)]}function Kj(n){let t={},i=Object.keys(n).sort();for(let l of i)t[l]=n[l];return t}function Xj(n,t){let i=new Set;return new Set(t),n.reduce((l,c)=>{let u=JSON.stringify(Kj(c));return i.has(u)||(i.add(u),l.push({key:u,link:c})),l},[])}function fh(){let n=h.useContext(qr);return hh(n,"You must render this element inside a <DataRouterContext.Provider> element"),n}function Zj(){let n=h.useContext(Wo);return hh(n,"You must render this element inside a <DataRouterStateContext.Provider> element"),n}var ph=h.createContext(void 0);ph.displayName="FrameworkContext";function gh(){let n=h.useContext(ph);return hh(n,"You must render this element inside a <HydratedRouter> element"),n}function Wj(n,t){let i=h.useContext(ph),[l,c]=h.useState(!1),[u,f]=h.useState(!1),{onFocus:x,onBlur:g,onMouseEnter:m,onMouseLeave:y,onTouchStart:_}=t,v=h.useRef(null);h.useEffect(()=>{if(n==="render"&&f(!0),n==="viewport"){let E=T=>{T.forEach(R=>{f(R.isIntersecting)})},w=new IntersectionObserver(E,{threshold:.5});return v.current&&w.observe(v.current),()=>{w.disconnect()}}},[n]),h.useEffect(()=>{if(l){let E=setTimeout(()=>{f(!0)},100);return()=>{clearTimeout(E)}}},[l]);let j=()=>{c(!0)},k=()=>{c(!1),f(!1)};return i?n!=="intent"?[u,v,{}]:[u,v,{onFocus:Ii(x,j),onBlur:Ii(g,k),onMouseEnter:Ii(m,j),onMouseLeave:Ii(y,k),onTouchStart:Ii(_,j)}]:[!1,v,{}]}function Ii(n,t){return i=>{n&&n(i),i.defaultPrevented||t(i)}}function Jj({page:n,...t}){let i=uj(),{router:l}=fh(),c=h.useMemo(()=>bx(l.routes,n,l.basename),[l.routes,n,l.basename]);return c?i?h.createElement(tk,{page:n,matches:c,...t}):h.createElement(sk,{page:n,matches:c,...t}):null}function ek(n){let{manifest:t,routeModules:i}=gh(),[l,c]=h.useState([]);return h.useEffect(()=>{let u=!1;return Fj(n,t,i).then(f=>{u||c(f)}),()=>{u=!0}},[n,t,i]),l}function tk({page:n,matches:t,...i}){let l=qt(),{future:c}=gh(),{basename:u}=fh(),f=h.useMemo(()=>{if(n===l.pathname+l.search+l.hash)return[];let x=Ox(n,u,c.unstable_trailingSlashAwareDataRequests,"rsc"),g=!1,m=[];for(let y of t)typeof y.route.shouldRevalidate=="function"?g=!0:m.push(y.route.id);return g&&m.length>0&&x.searchParams.set("_routes",m.join(",")),[x.pathname+x.search]},[u,c.unstable_trailingSlashAwareDataRequests,n,l,t]);return h.createElement(h.Fragment,null,f.map(x=>h.createElement("link",{key:x,rel:"prefetch",as:"fetch",href:x,...i})))}function sk({page:n,matches:t,...i}){let l=qt(),{future:c,manifest:u,routeModules:f}=gh(),{basename:x}=fh(),{loaderData:g,matches:m}=Zj(),y=h.useMemo(()=>Qm(n,t,m,u,l,"data"),[n,t,m,u,l]),_=h.useMemo(()=>Qm(n,t,m,u,l,"assets"),[n,t,m,u,l]),v=h.useMemo(()=>{if(n===l.pathname+l.search+l.hash)return[];let E=new Set,w=!1;if(t.forEach(R=>{let z=u.routes[R.route.id];!z||!z.hasLoader||(!y.some(L=>L.route.id===R.route.id)&&R.route.id in g&&f[R.route.id]?.shouldRevalidate||z.hasClientLoader?w=!0:E.add(R.route.id))}),E.size===0)return[];let T=Ox(n,x,c.unstable_trailingSlashAwareDataRequests,"data");return w&&E.size>0&&T.searchParams.set("_routes",t.filter(R=>E.has(R.route.id)).map(R=>R.route.id).join(",")),[T.pathname+T.search]},[x,c.unstable_trailingSlashAwareDataRequests,g,l,u,y,t,n,f]),j=h.useMemo(()=>Yj(_,u),[_,u]),k=ek(_);return h.createElement(h.Fragment,null,v.map(E=>h.createElement("link",{key:E,rel:"prefetch",as:"fetch",href:E,...i})),j.map(E=>h.createElement("link",{key:E,rel:"modulepreload",href:E,...i})),k.map(({key:E,link:w})=>h.createElement("link",{key:E,nonce:i.nonce,...w,crossOrigin:w.crossOrigin??i.crossOrigin})))}function nk(...n){return t=>{n.forEach(i=>{typeof i=="function"?i(t):i!=null&&(i.current=t)})}}var ak=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{ak&&(window.__reactRouterVersion="7.14.0")}catch{}function rk({basename:n,children:t,unstable_useTransitions:i,window:l}){let c=h.useRef();c.current==null&&(c.current=qS({window:l,v5Compat:!0}));let u=c.current,[f,x]=h.useState({action:u.action,location:u.location}),g=h.useCallback(m=>{i===!1?x(m):h.startTransition(()=>x(m))},[i]);return h.useLayoutEffect(()=>u.listen(g),[u,g]),h.createElement(Oj,{basename:n,children:t,location:f.location,navigationType:f.action,navigator:u,unstable_useTransitions:i})}var Lx=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Mn=h.forwardRef(function({onClick:t,discover:i="render",prefetch:l="none",relative:c,reloadDocument:u,replace:f,unstable_mask:x,state:g,target:m,to:y,preventScrollReset:_,viewTransition:v,unstable_defaultShouldRevalidate:j,...k},E){let{basename:w,navigator:T,unstable_useTransitions:R}=h.useContext(Ss),z=typeof y=="string"&&Lx.test(y),L=kx(y,w);y=L.to;let M=yj(y,{relative:c}),N=qt(),A=null;if(x){let me=Zo(x,[],N.unstable_mask?N.unstable_mask.pathname:"/",!0);w!=="/"&&(me.pathname=me.pathname==="/"?w:on([w,me.pathname])),A=T.createHref(me)}let[I,Q,Z]=Wj(l,k),U=ck(y,{replace:f,unstable_mask:x,state:g,target:m,preventScrollReset:_,relative:c,viewTransition:v,unstable_defaultShouldRevalidate:j,unstable_useTransitions:R});function le(me){t&&t(me),me.defaultPrevented||U(me)}let W=!(L.isExternal||u),oe=h.createElement("a",{...k,...Z,href:(W?A:void 0)||L.absoluteURL||M,onClick:W?le:t,ref:nk(E,Q),target:m,"data-discover":!z&&i==="render"?"true":void 0});return I&&!z?h.createElement(h.Fragment,null,oe,h.createElement(Jj,{page:M})):oe});Mn.displayName="Link";var ik=h.forwardRef(function({"aria-current":t="page",caseSensitive:i=!1,className:l="",end:c=!1,style:u,to:f,viewTransition:x,children:g,...m},y){let _=sl(f,{relative:m.relative}),v=qt(),j=h.useContext(Wo),{navigator:k,basename:E}=h.useContext(Ss),w=j!=null&&pk(_)&&x===!0,T=k.encodeLocation?k.encodeLocation(_).pathname:_.pathname,R=v.pathname,z=j&&j.navigation&&j.navigation.location?j.navigation.location.pathname:null;i||(R=R.toLowerCase(),z=z?z.toLowerCase():null,T=T.toLowerCase()),z&&E&&(z=Ln(z,E)||z);const L=T!=="/"&&T.endsWith("/")?T.length-1:T.length;let M=R===T||!c&&R.startsWith(T)&&R.charAt(L)==="/",N=z!=null&&(z===T||!c&&z.startsWith(T)&&z.charAt(T.length)==="/"),A={isActive:M,isPending:N,isTransitioning:w},I=M?t:void 0,Q;typeof l=="function"?Q=l(A):Q=[l,M?"active":null,N?"pending":null,w?"transitioning":null].filter(Boolean).join(" ");let Z=typeof u=="function"?u(A):u;return h.createElement(Mn,{...m,"aria-current":I,className:Q,ref:y,style:Z,to:f,viewTransition:x},typeof g=="function"?g(A):g)});ik.displayName="NavLink";var lk=h.forwardRef(({discover:n="render",fetcherKey:t,navigate:i,reloadDocument:l,replace:c,state:u,method:f=qo,action:x,onSubmit:g,relative:m,preventScrollReset:y,viewTransition:_,unstable_defaultShouldRevalidate:v,...j},k)=>{let{unstable_useTransitions:E}=h.useContext(Ss),w=hk(),T=fk(x,{relative:m}),R=f.toLowerCase()==="get"?"get":"post",z=typeof x=="string"&&Lx.test(x),L=M=>{if(g&&g(M),M.defaultPrevented)return;M.preventDefault();let N=M.nativeEvent.submitter,A=N?.getAttribute("formmethod")||f,I=()=>w(N||M.currentTarget,{fetcherKey:t,method:A,navigate:i,replace:c,state:u,relative:m,preventScrollReset:y,viewTransition:_,unstable_defaultShouldRevalidate:v});E&&i!==!1?h.startTransition(()=>I()):I()};return h.createElement("form",{ref:k,method:R,action:T,onSubmit:l?g:L,...j,"data-discover":!z&&n==="render"?"true":void 0})});lk.displayName="Form";function ok(n){return`${n} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Mx(n){let t=h.useContext(qr);return pt(t,ok(n)),t}function ck(n,{target:t,replace:i,unstable_mask:l,state:c,preventScrollReset:u,relative:f,viewTransition:x,unstable_defaultShouldRevalidate:g,unstable_useTransitions:m}={}){let y=ze(),_=qt(),v=sl(n,{relative:f});return h.useCallback(j=>{if(Bj(j,t)){j.preventDefault();let k=i!==void 0?i:Ji(_)===Ji(v),E=()=>y(n,{replace:k,unstable_mask:l,state:c,preventScrollReset:u,relative:f,viewTransition:x,unstable_defaultShouldRevalidate:g});m?h.startTransition(()=>E()):E()}},[_,y,v,i,l,c,t,n,u,f,x,g,m])}function mh(n){Us(typeof URLSearchParams<"u","You cannot use the `useSearchParams` hook in a browser that does not support the URLSearchParams API. If you need to support Internet Explorer 11, we recommend you load a polyfill such as https://github.com/ungap/url-search-params.");let t=h.useRef(Fd(n)),i=h.useRef(!1),l=qt(),c=h.useMemo(()=>Uj(l.search,i.current?null:t.current),[l.search]),u=ze(),f=h.useCallback((x,g)=>{const m=Fd(typeof x=="function"?x(new URLSearchParams(c)):x);i.current=!0,u("?"+m,g)},[u,c]);return[c,f]}var uk=0,dk=()=>`__${String(++uk)}__`;function hk(){let{router:n}=Mx("useSubmit"),{basename:t}=h.useContext(Ss),i=Aj(),l=n.fetch,c=n.navigate;return h.useCallback(async(u,f={})=>{let{action:x,method:g,encType:m,formData:y,body:_}=Pj(u,t);if(f.navigate===!1){let v=f.fetcherKey||dk();await l(v,i,f.action||x,{unstable_defaultShouldRevalidate:f.unstable_defaultShouldRevalidate,preventScrollReset:f.preventScrollReset,formData:y,body:_,formMethod:f.method||g,formEncType:f.encType||m,flushSync:f.flushSync})}else await c(f.action||x,{unstable_defaultShouldRevalidate:f.unstable_defaultShouldRevalidate,preventScrollReset:f.preventScrollReset,formData:y,body:_,formMethod:f.method||g,formEncType:f.encType||m,replace:f.replace,state:f.state,fromRouteId:i,flushSync:f.flushSync,viewTransition:f.viewTransition})},[l,c,t,i])}function fk(n,{relative:t}={}){let{basename:i}=h.useContext(Ss),l=h.useContext($s);pt(l,"useFormAction must be used inside a RouteContext");let[c]=l.matches.slice(-1),u={...sl(n||".",{relative:t})},f=qt();if(n==null){u.search=f.search;let x=new URLSearchParams(u.search),g=x.getAll("index");if(g.some(y=>y==="")){x.delete("index"),g.filter(_=>_).forEach(_=>x.append("index",_));let y=x.toString();u.search=y?`?${y}`:""}}return(!n||n===".")&&c.route.index&&(u.search=u.search?u.search.replace(/^\?/,"?index&"):"?index"),i!=="/"&&(u.pathname=u.pathname==="/"?i:on([i,u.pathname])),Ji(u)}function pk(n,{relative:t}={}){let i=h.useContext(Ex);pt(i!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:l}=Mx("useViewTransitionState"),c=sl(n,{relative:t});if(!i.isTransitioning)return!1;let u=Ln(i.currentLocation.pathname,l)||i.currentLocation.pathname,f=Ln(i.nextLocation.pathname,l)||i.nextLocation.pathname;return Go(c.pathname,f)!=null||Go(c.pathname,u)!=null}const qx=h.createContext(void 0);function gk({children:n}){const[t,i]=h.useState(()=>localStorage.getItem("theme")||"light");h.useEffect(()=>{document.documentElement.setAttribute("data-theme",t),localStorage.setItem("theme",t)},[t]);const l=c=>{i(c)};return a.jsx(qx.Provider,{value:{theme:t,setTheme:l},children:n})}function Ix(){const n=h.useContext(qx);if(!n)throw new Error("useTheme must be used within ThemeProvider");return n}let Km=class extends Error{url;status;statusText;body;request;constructor(t,i,l){super(l),this.name="ApiError",this.url=i.url,this.status=i.status,this.statusText=i.statusText,this.body=i.body,this.request=t}};class mk extends Error{constructor(t){super(t),this.name="CancelError"}get isCancelled(){return!0}}class yk{#t;#e;#s;#n;#r;#i;#a;constructor(t){this.#t=!1,this.#e=!1,this.#s=!1,this.#n=[],this.#r=new Promise((i,l)=>{this.#i=i,this.#a=l;const c=x=>{this.#t||this.#e||this.#s||(this.#t=!0,this.#i&&this.#i(x))},u=x=>{this.#t||this.#e||this.#s||(this.#e=!0,this.#a&&this.#a(x))},f=x=>{this.#t||this.#e||this.#s||this.#n.push(x)};return Object.defineProperty(f,"isResolved",{get:()=>this.#t}),Object.defineProperty(f,"isRejected",{get:()=>this.#e}),Object.defineProperty(f,"isCancelled",{get:()=>this.#s}),t(c,u,f)})}get[Symbol.toStringTag](){return"Cancellable Promise"}then(t,i){return this.#r.then(t,i)}catch(t){return this.#r.catch(t)}finally(t){return this.#r.finally(t)}cancel(){if(!(this.#t||this.#e||this.#s)){if(this.#s=!0,this.#n.length)try{for(const t of this.#n)t()}catch(t){console.warn("Cancellation threw an error",t);return}this.#n.length=0,this.#a&&this.#a(new mk("Request aborted"))}}get isCancelled(){return this.#s}}const Me={BASE:"",VERSION:"1.0",WITH_CREDENTIALS:!1,CREDENTIALS:"include",TOKEN:void 0,USERNAME:void 0,PASSWORD:void 0,HEADERS:void 0,ENCODE_PATH:void 0};var Xm;(function(n){(function(t){t.NOT_STARTED="NOT_STARTED",t.IN_PROGRESS="IN_PROGRESS",t.FOR_REVIEW="FOR_REVIEW",t.DONE="DONE"})(n.taskStatus||(n.taskStatus={})),(function(t){t.NOT_STARTED="NOT_STARTED",t.IN_PROGRESS="IN_PROGRESS",t.FOR_REVIEW="FOR_REVIEW",t.DONE="DONE"})(n.taskStatusBeforeClaim||(n.taskStatusBeforeClaim={}))})(Xm||(Xm={}));var Zm;(function(n){(function(t){t.HUMAN="human",t.AGENT="agent"})(n.type||(n.type={}))})(Zm||(Zm={}));var Wm;(function(n){(function(t){t.CLAUDE="claude",t.CODEX="codex",t.OPENCODE="opencode",t.ADK="adk",t.GITHUBCOPILOT="githubcopilot",t.OTHER="other"})(n.type||(n.type={}))})(Wm||(Wm={}));var Jm;(function(n){(function(t){t.CLAUDE="claude",t.CODEX="codex",t.OPENCODE="opencode",t.ADK="adk",t.GITHUBCOPILOT="githubcopilot",t.OTHER="other"})(n.type||(n.type={}))})(Jm||(Jm={}));var ey;(function(n){(function(t){t.CLAUDE="claude",t.CODEX="codex",t.OPENCODE="opencode",t.ADK="adk",t.GITHUBCOPILOT="githubcopilot",t.OTHER="other"})(n.type||(n.type={}))})(ey||(ey={}));var ty;(function(n){(function(t){t.HTTP="http",t.STDIO="stdio"})(n.type||(n.type={}))})(ty||(ty={}));var sy;(function(n){(function(t){t.NOT_STARTED="not_started",t.USER_CONSENT_REJECTED="USER_CONSENT_REJECTED",t.MCP_AUTH_FLOW_STARTED="mcp_auth_flow_started",t.MCP_AUTH_FLOW_COMPLETED="mcp_auth_flow_completed",t.CONNECTIONS_FLOW_STARTED="connections_flow_started",t.CONNECTIONS_FLOW_COMPLETED="connections_flow_completed",t.AUTHORIZATION_CODE_ISSUED="authorization_code_issued",t.AUTHORIZATION_CODE_EXCHANGED="authorization_code_exchanged"})(n.status||(n.status={}))})(sy||(sy={}));var ny;(function(n){(function(t){t.NOT_STARTED="NOT_STARTED",t.IN_PROGRESS="IN_PROGRESS",t.FOR_REVIEW="FOR_REVIEW",t.DONE="DONE"})(n.status||(n.status={}))})(ny||(ny={}));var ay;(function(n){(function(t){t.OPENAI="openai",t.ADK="adk"})(n.type||(n.type={}))})(ay||(ay={}));var ry;(function(n){(function(t){t.NONE="none",t.CLIENT_SECRET_BASIC="client_secret_basic"})(n.token_endpoint_auth_method||(n.token_endpoint_auth_method={}))})(ry||(ry={}));var iy;(function(n){(function(t){t.PENDING="pending",t.AUTHORIZED="authorized",t.FAILED="failed"})(n.status||(n.status={}))})(iy||(iy={}));var ly;(function(n){(function(t){t.CLAUDE="claude",t.CODEX="codex",t.OPENCODE="opencode",t.ADK="adk",t.GITHUBCOPILOT="githubcopilot",t.OTHER="other"})(n.type||(n.type={}))})(ly||(ly={}));var oy;(function(n){(function(t){t.OPENAI="openai",t.ADK="adk"})(n.type||(n.type={}))})(oy||(oy={}));var Nr;(function(n){(function(t){t.ADMIN="admin",t.STANDARD="standard"})(n.role||(n.role={}))})(Nr||(Nr={}));var cy;(function(n){(function(t){t.HTTP="http",t.STDIO="stdio"})(n.type||(n.type={}))})(cy||(cy={}));var uy;(function(n){(function(t){t.CLIENT_NOT_REGISTERED="CLIENT_NOT_REGISTERED",t.CLIENT_REGISTERED="CLIENT_REGISTERED",t.AUTHORIZATION_REQUEST_STARTED="AUTHORIZATION_REQUEST_STARTED",t.USER_CONSENT_OK="USER_CONSENT_OK",t.USER_CONSENT_REJECTED="USER_CONSENT_REJECTED",t.WAITING_ON_DOWNSTREAM_AUTH="WAITING_ON_DOWNSTREAM_AUTH",t.AUTHORIZATION_CODE_ISSUED="AUTHORIZATION_CODE_ISSUED",t.AUTHORIZATION_CODE_EXCHANGED="AUTHORIZATION_CODE_EXCHANGED"})(n.status||(n.status={}))})(uy||(uy={}));var dy;(function(n){(function(t){t.TASK="task",t.CONTEXT_BLOCK="context_block",t.AGENT="agent",t.PROJECT="project",t.TAG="tag",t.TOOL="tool"})(n.type||(n.type={}))})(dy||(dy={}));var hy;(function(n){(function(t){t.ACCESS_TOKEN="access_token",t.REFRESH_TOKEN="refresh_token"})(n.token_type_hint||(n.token_type_hint={}))})(hy||(hy={}));var fy;(function(n){(function(t){t.BEARER="Bearer"})(n.token_type||(n.token_type={}))})(fy||(fy={}));var py;(function(n){(function(t){t.ADMIN="admin",t.STANDARD="standard"})(n.role||(n.role={}))})(py||(py={}));var gy;(function(n){(function(t){t.CLIENT_NOT_REGISTERED="CLIENT_NOT_REGISTERED",t.CLIENT_REGISTERED="CLIENT_REGISTERED",t.AUTHORIZATION_REQUEST_STARTED="AUTHORIZATION_REQUEST_STARTED",t.USER_CONSENT_OK="USER_CONSENT_OK",t.USER_CONSENT_REJECTED="USER_CONSENT_REJECTED",t.WAITING_ON_DOWNSTREAM_AUTH="WAITING_ON_DOWNSTREAM_AUTH",t.AUTHORIZATION_CODE_ISSUED="AUTHORIZATION_CODE_ISSUED",t.AUTHORIZATION_CODE_EXCHANGED="AUTHORIZATION_CODE_EXCHANGED"})(n.status||(n.status={}))})(gy||(gy={}));var my;(function(n){(function(t){t.CLAUDE="claude",t.CODEX="codex",t.OPENCODE="opencode",t.ADK="adk",t.GITHUBCOPILOT="githubcopilot",t.OTHER="other"})(n.type||(n.type={}))})(my||(my={}));var yy;(function(n){(function(t){t.NONE="none",t.CLIENT_SECRET_BASIC="client_secret_basic"})(n.token_endpoint_auth_method||(n.token_endpoint_auth_method={}))})(yy||(yy={}));var xy;(function(n){(function(t){t.HTTP="http",t.STDIO="stdio"})(n.type||(n.type={}))})(xy||(xy={}));var vy;(function(n){(function(t){t.SUCCEEDED="SUCCEEDED",t.FAILED="FAILED",t.STALE="STALE",t.CANCELLED="CANCELLED"})(n.status||(n.status={})),(function(t){t.OUT_OF_QUOTA="OUT_OF_QUOTA",t.INTERRUPTED="INTERRUPTED",t.UNKNOWN="UNKNOWN"})(n.errorCode||(n.errorCode={}))})(vy||(vy={}));var by;(function(n){(function(t){t.NOT_STARTED="NOT_STARTED",t.IN_PROGRESS="IN_PROGRESS",t.FOR_REVIEW="FOR_REVIEW",t.DONE="DONE"})(n.taskStatus||(n.taskStatus={})),(function(t){t.SUCCEEDED="SUCCEEDED",t.FAILED="FAILED",t.STALE="STALE",t.CANCELLED="CANCELLED"})(n.status||(n.status={})),(function(t){t.OUT_OF_QUOTA="OUT_OF_QUOTA",t.INTERRUPTED="INTERRUPTED",t.UNKNOWN="UNKNOWN"})(n.errorCode||(n.errorCode={}))})(by||(by={}));var _y;(function(n){(function(t){t.NOT_STARTED="NOT_STARTED",t.IN_PROGRESS="IN_PROGRESS",t.FOR_REVIEW="FOR_REVIEW",t.DONE="DONE"})(n.taskStatus||(n.taskStatus={}))})(_y||(_y={}));var Sy;(function(n){(function(t){t.NOT_STARTED="NOT_STARTED",t.IN_PROGRESS="IN_PROGRESS",t.FOR_REVIEW="FOR_REVIEW",t.DONE="DONE"})(n.status||(n.status={}))})(Sy||(Sy={}));var jy;(function(n){(function(t){t.NOT_STARTED="NOT_STARTED",t.IN_PROGRESS="IN_PROGRESS",t.FOR_REVIEW="FOR_REVIEW",t.DONE="DONE"})(n.status||(n.status={}))})(jy||(jy={}));var ky;(function(n){(function(t){t.URN_IETF_PARAMS_OAUTH_GRANT_TYPE_TOKEN_EXCHANGE="urn:ietf:params:oauth:grant-type:token-exchange"})(n.grant_type||(n.grant_type={})),(function(t){t.URN_IETF_PARAMS_OAUTH_TOKEN_TYPE_ACCESS_TOKEN="urn:ietf:params:oauth:token-type:access_token"})(n.subject_token_type||(n.subject_token_type={}))})(ky||(ky={}));var Ty;(function(n){(function(t){t.AUTHORIZATION_CODE="authorization_code",t.REFRESH_TOKEN="refresh_token"})(n.grant_type||(n.grant_type={}))})(Ty||(Ty={}));var wy;(function(n){(function(t){t.BEARER="Bearer"})(n.token_type||(n.token_type={}))})(wy||(wy={}));var Ey;(function(n){(function(t){t.HTTP="http",t.STDIO="stdio"})(n.type||(n.type={}))})(Ey||(Ey={}));var Cy;(function(n){(function(t){t.ADMIN="admin",t.STANDARD="standard"})(n.role||(n.role={})),(function(t){t.FULL_PAGE="FULL_PAGE",t.BANNER="BANNER",t.OFF="OFF"})(n.onboardingDisplayMode||(n.onboardingDisplayMode={}))})(Cy||(Cy={}));var Ny;(function(n){(function(t){t.FULL_PAGE="FULL_PAGE",t.BANNER="BANNER",t.OFF="OFF"})(n.onboardingDisplayMode||(n.onboardingDisplayMode={}))})(Ny||(Ny={}));const yh=n=>n!=null,nl=n=>typeof n=="string",Td=n=>nl(n)&&n!=="",xh=n=>typeof n=="object"&&typeof n.type=="string"&&typeof n.stream=="function"&&typeof n.arrayBuffer=="function"&&typeof n.constructor=="function"&&typeof n.constructor.name=="string"&&/^(Blob|File)$/.test(n.constructor.name)&&/^(Blob|File)$/.test(n[Symbol.toStringTag]),Bx=n=>n instanceof FormData,xk=n=>{try{return btoa(n)}catch{return Buffer.from(n).toString("base64")}},vk=n=>{const t=[],i=(c,u)=>{t.push(`${encodeURIComponent(c)}=${encodeURIComponent(String(u))}`)},l=(c,u)=>{yh(u)&&(Array.isArray(u)?u.forEach(f=>{l(c,f)}):typeof u=="object"?Object.entries(u).forEach(([f,x])=>{l(`${c}[${f}]`,x)}):i(c,u))};return Object.entries(n).forEach(([c,u])=>{l(c,u)}),t.length>0?`?${t.join("&")}`:""},bk=(n,t)=>{const i=n.ENCODE_PATH||encodeURI,l=t.url.replace("{api-version}",n.VERSION).replace(/{(.*?)}/g,(u,f)=>t.path?.hasOwnProperty(f)?i(String(t.path[f])):u),c=`${n.BASE}${l}`;return t.query?`${c}${vk(t.query)}`:c},_k=n=>{if(n.formData){const t=new FormData,i=(l,c)=>{nl(c)||xh(c)?t.append(l,c):t.append(l,JSON.stringify(c))};return Object.entries(n.formData).filter(([l,c])=>yh(c)).forEach(([l,c])=>{Array.isArray(c)?c.forEach(u=>i(l,u)):i(l,c)}),t}},To=async(n,t)=>typeof t=="function"?t(n):t,Sk=async(n,t)=>{const[i,l,c,u]=await Promise.all([To(t,n.TOKEN),To(t,n.USERNAME),To(t,n.PASSWORD),To(t,n.HEADERS)]),f=Object.entries({Accept:"application/json",...u,...t.headers}).filter(([x,g])=>yh(g)).reduce((x,[g,m])=>({...x,[g]:String(m)}),{});if(Td(i)&&(f.Authorization=`Bearer ${i}`),Td(l)&&Td(c)){const x=xk(`${l}:${c}`);f.Authorization=`Basic ${x}`}return t.body!==void 0&&(t.mediaType?f["Content-Type"]=t.mediaType:xh(t.body)?f["Content-Type"]=t.body.type||"application/octet-stream":nl(t.body)?f["Content-Type"]="text/plain":Bx(t.body)||(f["Content-Type"]="application/json")),new Headers(f)},jk=n=>{if(n.body!==void 0)return n.mediaType?.includes("/json")?JSON.stringify(n.body):nl(n.body)||xh(n.body)||Bx(n.body)?n.body:JSON.stringify(n.body)},kk=async(n,t,i,l,c,u,f)=>{const x=new AbortController,g={headers:u,body:l??c,method:t.method,signal:x.signal};return n.WITH_CREDENTIALS&&(g.credentials=n.CREDENTIALS),f(()=>x.abort()),await fetch(i,g)},Tk=(n,t)=>{if(t){const i=n.headers.get(t);if(nl(i))return i}},wk=async n=>{if(n.status!==204)try{const t=n.headers.get("Content-Type");if(t)return["application/json","application/problem+json"].some(c=>t.toLowerCase().startsWith(c))?await n.json():await n.text()}catch(t){console.error(t)}},Ek=(n,t)=>{const l={400:"Bad Request",401:"Unauthorized",403:"Forbidden",404:"Not Found",500:"Internal Server Error",502:"Bad Gateway",503:"Service Unavailable",...n.errors}[t.status];if(l)throw new Km(n,t,l);if(!t.ok){const c=t.status??"unknown",u=t.statusText??"unknown",f=(()=>{try{return JSON.stringify(t.body,null,2)}catch{return}})();throw new Km(n,t,`Generic Error: status: ${c}; status text: ${u}; body: ${f}`)}},Ge=(n,t)=>new yk(async(i,l,c)=>{try{const u=bk(n,t),f=_k(t),x=jk(t),g=await Sk(n,t);if(!c.isCancelled){const m=await kk(n,t,u,x,f,g,c),y=await wk(m),_=Tk(m,t.responseHeader),v={url:u,ok:m.ok,status:m.status,statusText:m.statusText,body:_??y};Ek(t,v),i(v.body)}}catch(u){l(u)}});class Ux{static actorControllerListActors(t=Me){return Ge(t,{method:"GET",url:"/api/v1/actors"})}static actorControllerSearchActors(t,i=10,l=.3,c=Me){return Ge(c,{method:"GET",url:"/api/v1/actors/search",query:{query:t,limit:i,threshold:l}})}}class Ar{static chatProvidersControllerCreateChatProvider(t,i=Me){return Ge(i,{method:"POST",url:"/api/v1/chat-providers",body:t,mediaType:"application/json"})}static chatProvidersControllerListChatProviders(t=Me){return Ge(t,{method:"GET",url:"/api/v1/chat-providers"})}static chatProvidersControllerGetChatProvider(t,i=Me){return Ge(i,{method:"GET",url:"/api/v1/chat-providers/{id}",path:{id:t},errors:{404:"Chat provider not found"}})}static chatProvidersControllerUpdateChatProvider(t,i,l=Me){return Ge(l,{method:"PATCH",url:"/api/v1/chat-providers/{id}",path:{id:t},body:i,mediaType:"application/json",errors:{404:"Chat provider not found"}})}static chatProvidersControllerDeleteChatProvider(t,i=Me){return Ge(i,{method:"DELETE",url:"/api/v1/chat-providers/{id}",path:{id:t},errors:{404:"Chat provider not found"}})}static chatProvidersControllerSetActiveChatProvider(t,i=Me){return Ge(i,{method:"POST",url:"/api/v1/chat-providers/set-active",body:t,mediaType:"application/json",errors:{404:"Chat provider not found"}})}static chatProvidersControllerDeactivateActiveChatProvider(t=Me){return Ge(t,{method:"POST",url:"/api/v1/chat-providers/deactivate"})}}let $x=class{static metaControllerCreateTag(t,i=Me){return Ge(i,{method:"POST",url:"/api/v1/meta/tags",body:t,mediaType:"application/json",errors:{400:"Invalid input data"}})}static metaControllerGetAllTags(t=Me){return Ge(t,{method:"GET",url:"/api/v1/meta/tags"})}static metaControllerGetTagColors(t=Me){return Ge(t,{method:"GET",url:"/api/v1/meta/tags/colors"})}static metaControllerDeleteTag(t,i=Me){return Ge(i,{method:"DELETE",url:"/api/v1/meta/tags/{tagId}",path:{tagId:t},errors:{404:"Tag not found"}})}static metaControllerGetVersion(t=Me){return Ge(t,{method:"GET",url:"/api/v1/meta/version"})}};class Vo{static projectsControllerCreateProject(t,i=Me){return Ge(i,{method:"POST",url:"/api/v1/meta/projects",body:t,mediaType:"application/json",errors:{400:"Invalid input data"}})}static projectsControllerGetAllProjects(t=Me){return Ge(t,{method:"GET",url:"/api/v1/meta/projects"})}static projectsControllerSearchProjects(t,i,l,c=Me){return Ge(c,{method:"GET",url:"/api/v1/meta/projects/search",query:{q:t,limit:i,threshold:l}})}static projectsControllerGetProjectBySlug(t,i=Me){return Ge(i,{method:"GET",url:"/api/v1/meta/projects/by-slug/{slug}",path:{slug:t},errors:{404:"Project not found"}})}static projectsControllerGetProject(t,i=Me){return Ge(i,{method:"GET",url:"/api/v1/meta/projects/{projectId}",path:{projectId:t},errors:{404:"Project not found"}})}static projectsControllerUpdateProject(t,i,l=Me){return Ge(l,{method:"PATCH",url:"/api/v1/meta/projects/{projectId}",path:{projectId:t},body:i,mediaType:"application/json",errors:{400:"Invalid input data",404:"Project not found"}})}static projectsControllerDeleteProject(t,i=Me){return Ge(i,{method:"DELETE",url:"/api/v1/meta/projects/{projectId}",path:{projectId:t},errors:{404:"Project not found"}})}}class es{static webAuthControllerLogin(t,i=Me){return Ge(i,{method:"POST",url:"/api/v1/auth/login",body:t,mediaType:"application/json",errors:{401:"Invalid credentials"}})}static webAuthControllerListUsers(t=Me){return Ge(t,{method:"GET",url:"/api/v1/auth/users"})}static webAuthControllerCreateUser(t,i=Me){return Ge(i,{method:"POST",url:"/api/v1/auth/users",body:t,mediaType:"application/json"})}static webAuthControllerResetUserPassword(t,i=Me){return Ge(i,{method:"POST",url:"/api/v1/auth/users/{userId}/reset-password",path:{userId:t}})}static webAuthControllerDeleteUser(t,i=Me){return Ge(i,{method:"DELETE",url:"/api/v1/auth/users/{userId}",path:{userId:t}})}static webAuthControllerGetAccountSetupStatus(t,i=Me){return Ge(i,{method:"POST",url:"/api/v1/auth/account-setup-status",body:t,mediaType:"application/json"})}static webAuthControllerSetupAccount(t,i=Me){return Ge(i,{method:"POST",url:"/api/v1/auth/setup-account",body:t,mediaType:"application/json"})}static webAuthControllerRefresh(t=Me){return Ge(t,{method:"POST",url:"/api/v1/auth/refresh",errors:{401:"Invalid or expired refresh token"}})}static webAuthControllerLogout(t=Me){return Ge(t,{method:"POST",url:"/api/v1/auth/logout"})}static webAuthControllerMe(t=Me){return Ge(t,{method:"GET",url:"/api/v1/auth/me",errors:{401:"Not authenticated"}})}static webAuthControllerChangePassword(t,i=Me){return Ge(i,{method:"POST",url:"/api/v1/auth/change-password",body:t,mediaType:"application/json",errors:{401:"Not authenticated or current password is incorrect"}})}static webAuthControllerGetOnboardingStatus(t=Me){return Ge(t,{method:"GET",url:"/api/v1/auth/onboarding-status"})}static webAuthControllerOnboard(t,i=Me){return Ge(i,{method:"POST",url:"/api/v1/auth/onboard",body:t,mediaType:"application/json",errors:{409:"Admin users already exist, onboarding not allowed"}})}static webAuthControllerMarkWalkthroughSeen(t=Me){return Ge(t,{method:"POST",url:"/api/v1/auth/mark-walkthrough-seen",errors:{401:"Not authenticated"}})}}const Ck=()=>"",pa=n=>n,Ba=Ck();Me.BASE=Ba;Me.CREDENTIALS="include";Me.BASE=Ba;const Hx=h.createContext(void 0);function Nk({children:n}){const[t,i]=h.useState(null),[l,c]=h.useState(!0);h.useEffect(()=>{es.webAuthControllerMe().then(m=>{i(m)}).catch(()=>{i(null)}).finally(()=>{c(!1)})},[]),h.useEffect(()=>{if(!t)return;const m=setInterval(async()=>{try{const y=await es.webAuthControllerRefresh();i(y.user)}catch(y){console.error("Token refresh failed:",y),i(null)}},480*1e3);return()=>clearInterval(m)},[t]);const g={user:t,isAuthenticated:!!t,isLoading:l,login:async(m,y)=>{const _=await es.webAuthControllerLogin({email:m,password:y});i(_.user)},logout:async()=>{try{await es.webAuthControllerLogout()}finally{i(null)}},refreshAuth:async()=>{const m=await es.webAuthControllerRefresh();i(m.user)}};return a.jsx(Hx.Provider,{value:g,children:n})}function us(){const n=h.useContext(Hx);if(n===void 0)throw new Error("useAuth must be used within an AuthProvider");return n}function Px({children:n}){return a.jsx("div",{className:"login-page",children:a.jsx("div",{className:"login-container",children:a.jsx("div",{className:"login-card",children:n})})})}const wd=["a1","a2","a3","a4","a5","a6"];function Ak(n){let t=5381;for(let i=0;i<n.length;i++)t=t*33^n.charCodeAt(i);return t>>>0}function Rk(n){if(!n)return wd[0];const t=Ak(n.trim().toLowerCase())%wd.length;return wd[t]}function zk(n){if(!n)return"?";const t=n.trim();if(!t)return"?";const i=t.split(/\s+/).filter(Boolean),l=i[0]?.[0]??"?",c=i.length>1?i[i.length-1]?.[0]:"";return(l+c).toUpperCase()}function Dk(n){return typeof n=="number"?null:`avatar--${n}`}function Ok(n){if(typeof n=="number")return{width:n,height:n,fontSize:Math.max(10,Math.round(n*.42))}}function He({name:n,src:t,alt:i,size:l="md",className:c=""}){const u=zk(n),f=Rk(n),x=Dk(l),g=Ok(l);return t?a.jsx("img",{className:`avatar ${x??""} ${c}`,style:g,src:t,alt:i??n,loading:"lazy"}):a.jsx("div",{className:`avatar avatar--fallback avatar--${f} ${x??""} ${c}`,style:g,"aria-label":i??n,role:"img",title:n,children:u})}function _s(n){const t=["chip",`chip--${n.color??"gray"}`,n.onClick?"chip--clickable":"",n.className??""].filter(Boolean).join(" ");return n.onClick?a.jsx("button",{type:"button",className:t,style:n.style,"aria-label":n.clickLabel,onClick:i=>{i.stopPropagation(),n.onClick?.()},children:n.children}):a.jsxs("span",{className:t,style:n.style,children:[n.children,n.onRemove?a.jsx("button",{type:"button",className:"chip__remove","aria-label":n.removeLabel??`Remove ${n.children}`,onClick:i=>{i.stopPropagation(),n.onRemove?.()},children:"×"}):null]})}function te({children:n,spacing:t="4",align:i="stretch",className:l=""}){return a.jsx("div",{className:`stack stack--spacing-${t} stack--align-${i} ${l}`,"data-component":"stack",children:n})}function Mt({children:n,spacing:t="4",align:i="center",justify:l="start",className:c=""}){return a.jsx("div",{className:`row row--spacing-${t} row--align-${i} row--justify-${l} ${c}`,"data-component":"row",children:n})}function b({children:n,size:t="2",weight:i="normal",tone:l="default",style:c="sans",as:u="p",className:f="",wrap:x=!1}){return a.jsx(u,{className:`text text--size-${t} text--weight-${i} text--tone-${l} text--style-${c} ${x&&"text--wrap"} ${f}`,"data-component":"text",children:n})}function Zt(n){const{children:t}=n;return a.jsx("div",{className:"error--container",children:a.jsx(b,{size:n.size,weight:n.weight,tone:n.tone,as:n.as,wrap:n.wrap,className:"error--text",children:t})})}function ue({children:n,variant:t="primary",size:i="md",fullWidth:l=!1,className:c="",...u}){return a.jsx("button",{className:`btn btn--${t} btn--${i} ${l?"btn--full-width":""} ${c}`,"data-component":"button",...u,children:n})}function Fe({children:n,padding:t="4",className:i=""}){return a.jsx("div",{className:`card card--padding-${t} ${i}`,"data-component":"card",children:n})}function Gx({leading:n,children:t,tags:i=[],topRight:l,footer:c,trailing:u,animation:f,onClick:x,className:g="",pulseKey:m,highlight:y}){const[_,v]=h.useState(!1);h.useEffect(()=>{if(m==null)return;v(!0);const T=setTimeout(()=>v(!1),600);return()=>clearTimeout(T)},[m]);const j=f?`board-card--${f}`:"",k=_?"board-card--eventPulse":"",E=y?"board-card--highlight":"",w=T=>{x?.(T)};return a.jsx("div",{className:`board-card__wrapper ${j}`,onClick:w,children:a.jsxs("div",{className:`board-card ${E} ${k} ${g}`,"data-component":"board-card",children:[a.jsxs("div",{className:"board-card__header",children:[a.jsx("div",{className:"board-card__headerLeft",children:n?a.jsx("div",{className:"board-card__leading",children:n}):null}),a.jsxs("div",{className:"board-card__headerRight",children:[l?a.jsx("div",{className:"board-card__meta",children:l}):null,u?a.jsx("div",{className:"board-card__trailing",children:u}):null]})]}),a.jsx("div",{className:"board-card__main",children:t}),i.length?a.jsx("div",{className:"board-card__tags","aria-label":"tags",children:i.map(T=>a.jsx("span",{className:`chip chip--${T.color??"gray"}`,children:T.label},T.label))}):null,c?a.jsx("div",{className:"board-card__footer",children:c}):null]})})}function be({leading:n,children:t,tags:i=[],topRight:l,trailing:c,animation:u,onClick:f,highlight:x,className:g=""}){const m=u?`data-row--${u}`:"",y=x?"data-row--highlight":"",_=f?"data-row--clickable":"",v=j=>{f?.(j)};return a.jsx("div",{className:`data-row__wrapper ${m}`,onClick:v,children:a.jsxs("div",{className:`data-row ${y} ${_} ${g}`,"data-component":"data-row",children:[n?a.jsx("div",{className:"data-row__leading",children:n}):null,a.jsxs("div",{className:"data-row__content",children:[a.jsxs("div",{className:"data-row__top",children:[a.jsx("div",{className:`data-row__main ${g}`,children:t}),l?a.jsx("div",{className:"data-row__meta",children:l}):null]}),i.length?a.jsx("div",{className:"data-row__tags","aria-label":"tags",children:i.map((j,k)=>a.jsx(_s,{color:j.color,onClick:j.onClick,clickLabel:j.clickLabel??j.label,onRemove:j.onRemove,removeLabel:j.removeLabel??`Remove ${j.label}`,children:j.label},`${j.label}-${j.color??"gray"}-${k}`))}):null]}),c?a.jsx("div",{className:"data-row__trailing",children:c}):null]})})}function ye({children:n,title:t,className:i,action:l}){return a.jsxs("div",{className:`data-row__container ${i}`,children:[(t||l)&&a.jsxs("div",{className:"data-row__container-header",children:[t&&a.jsx(b,{size:"4",weight:"bold",children:t}),l&&a.jsx("div",{className:"data-row__container-action",children:l})]}),n]})}function Lk({children:n,onClick:t,interactive:i=!1,className:l=""}){const c=i||!!t;return a.jsx("div",{className:`list-row ${c?"list-row--interactive":""} ${l}`,onClick:t,role:t?"button":void 0,tabIndex:t?0:void 0,"data-component":"list-row",children:n})}function Mk(){const[n,t]=h.useState("sign-in"),[i,l]=h.useState(""),[c,u]=h.useState(""),[f,x]=h.useState(""),[g,m]=h.useState(""),[y,_]=h.useState(""),[v,j]=h.useState(!1),{login:k,refreshAuth:E,isLoading:w,isAuthenticated:T}=us(),R=ze(),L=qt().state?.from,M=L?.pathname||"/",N=L?.search||"",A=M==="/logout"?"/":`${M}${N}`;h.useEffect(()=>{!w&&T&&(console.log("you're in mate"),R(A))},[w,T,A]);const I=async U=>{U.preventDefault(),j(!0),_("");try{await k(i,c),R(A,{replace:!0})}catch{_("Invalid email or password")}finally{j(!1)}},Q=async U=>{U.preventDefault(),j(!0),_("");try{const le=await es.webAuthControllerGetAccountSetupStatus({email:i});if(!le.canSetup){_("That email is not ready for account setup. Ask an admin to create or reset the account.");return}l(le.email),t("setup-account")}catch(le){_(Ay(le,"Could not check that email."))}finally{j(!1)}},Z=async U=>{U.preventDefault(),j(!0),_("");try{await es.webAuthControllerSetupAccount({email:i,displayName:f,slug:g,password:c}),await E(),R(A,{replace:!0})}catch(le){_(Ay(le,"Failed to set up account."))}finally{j(!1)}};return n==="setup-email"?a.jsx("form",{onSubmit:Q,children:a.jsxs(te,{spacing:"6",children:[a.jsxs(te,{spacing:"2",align:"center",children:[a.jsx(b,{size:"6",weight:"bold",className:"login__copy",children:"Create account"}),a.jsx(b,{tone:"muted",className:"login__copy",children:"Enter the email an admin invited or reset for you."})]}),a.jsxs(te,{spacing:"4",children:[a.jsxs(te,{spacing:"2",children:[a.jsx("label",{htmlFor:"setup-email",className:"login-label",children:a.jsx(b,{size:"2",weight:"medium",children:"Email"})}),a.jsx("input",{id:"setup-email",type:"email",value:i,onChange:U=>l(U.target.value),className:"login-input",placeholder:"name@work.com",required:!0,disabled:v,autoComplete:"email"})]}),y&&a.jsx(Zt,{size:"2",weight:"medium",children:y}),a.jsx(ue,{type:"submit",variant:"primary",size:"lg",disabled:v,className:"login-button",children:v?"Checking...":"Continue"}),a.jsx(ue,{type:"button",variant:"secondary",size:"lg",disabled:v,className:"login-button",onClick:()=>{t("sign-in"),_("")},children:"Back to sign in"})]})]})}):n==="setup-account"?a.jsx("form",{onSubmit:Z,children:a.jsxs(te,{spacing:"6",children:[a.jsxs(te,{spacing:"2",align:"center",children:[a.jsx(b,{size:"6",weight:"bold",className:"login__copy",children:"Set up account"}),a.jsxs(b,{tone:"muted",className:"login__copy",children:["Finish your profile and create a password for ",i,"."]})]}),a.jsxs(te,{spacing:"4",children:[a.jsxs(te,{spacing:"2",children:[a.jsx("label",{htmlFor:"setup-display-name",className:"login-label",children:a.jsx(b,{size:"2",weight:"medium",children:"Display name"})}),a.jsx("input",{id:"setup-display-name",type:"text",value:f,onChange:U=>x(U.target.value),className:"login-input",placeholder:"Jane User",required:!0,disabled:v,autoComplete:"name"})]}),a.jsxs(te,{spacing:"2",children:[a.jsx("label",{htmlFor:"setup-slug",className:"login-label",children:a.jsx(b,{size:"2",weight:"medium",children:"Username"})}),a.jsx("input",{id:"setup-slug",type:"text",value:g,onChange:U=>m(U.target.value),className:"login-input",placeholder:"jane",required:!0,disabled:v,autoComplete:"username"})]}),a.jsxs(te,{spacing:"2",children:[a.jsx("label",{htmlFor:"setup-password",className:"login-label",children:a.jsx(b,{size:"2",weight:"medium",children:"Password"})}),a.jsx("input",{id:"setup-password",type:"password",value:c,onChange:U=>u(U.target.value),className:"login-input",placeholder:"••••••••",required:!0,disabled:v,autoComplete:"new-password"})]}),y&&a.jsx(Zt,{size:"2",weight:"medium",children:y}),a.jsx(ue,{type:"submit",variant:"primary",size:"lg",disabled:v,className:"login-button",children:v?"Creating account...":"Create account"}),a.jsx(ue,{type:"button",variant:"secondary",size:"lg",disabled:v,className:"login-button",onClick:()=>{t("setup-email"),_("")},children:"Use a different email"})]})]})}):a.jsx("form",{onSubmit:I,children:a.jsxs(te,{spacing:"6",children:[a.jsxs(te,{spacing:"2",align:"center",children:[a.jsx(b,{size:"6",weight:"bold",className:"login__copy",children:"Taico"}),a.jsx(b,{tone:"muted",className:"login__copy",children:"Where people and agents collaborate in threads, using shared context to get work done."})]}),a.jsxs(te,{spacing:"4",children:[a.jsxs(te,{spacing:"2",children:[a.jsx("label",{htmlFor:"email",className:"login-label",children:a.jsx(b,{size:"2",weight:"medium",children:"Email"})}),a.jsx("input",{id:"email",type:"email",value:i,onChange:U=>l(U.target.value),className:"login-input",placeholder:"name@work.com",required:!0,disabled:v,autoComplete:"email"})]}),a.jsxs(te,{spacing:"2",children:[a.jsx("label",{htmlFor:"password",className:"login-label",children:a.jsx(b,{size:"2",weight:"medium",children:"Password"})}),a.jsx("input",{id:"password",type:"password",value:c,onChange:U=>u(U.target.value),className:"login-input",placeholder:"••••••••",required:!0,disabled:v,autoComplete:"current-password"})]}),y&&a.jsx(Zt,{size:"2",weight:"medium",className:"",children:y}),a.jsx(ue,{type:"submit",variant:"primary",size:"lg",disabled:v,className:"login-button",children:v?"Signing in...":"Sign In"}),a.jsx(ue,{type:"button",variant:"secondary",size:"lg",disabled:v,className:"login-button",onClick:()=>{t("setup-email"),_(""),u("")},children:"Create account"})]})]})})}function Ay(n,t){return n?.body?.detail||n?.body?.title||n?.message||t}function qk(){return a.jsx(Px,{children:a.jsx(Mk,{})})}function Ik(){const[n,t]=h.useState(""),[i,l]=h.useState(""),[c,u]=h.useState(""),[f,x]=h.useState(""),[g,m]=h.useState(""),[y,_]=h.useState(!1),{refreshAuth:v}=us(),j=ze(),k=async E=>{E.preventDefault(),_(!0),m("");try{await es.webAuthControllerOnboard({email:n,displayName:i,slug:c,password:f}),await v(),j("/",{replace:!0})}catch(w){let T="Failed to create admin user";w.body?.context?.fields&&Array.isArray(w.body.context.fields)?T=w.body.context.fields.join(", "):w.body?.detail?T=w.body.detail:w.body?.title?T=w.body.title:w.message&&(T=w.message),m(T)}finally{_(!1)}};return a.jsx("form",{onSubmit:k,children:a.jsxs(te,{spacing:"6",children:[a.jsxs(te,{spacing:"2",align:"center",children:[a.jsx(b,{size:"6",weight:"bold",className:"login__copy",children:"Welcome to Taico"}),a.jsx(b,{tone:"muted",className:"login__copy",children:"Let's set up your first admin account to get started."})]}),a.jsxs(te,{spacing:"4",children:[a.jsxs(te,{spacing:"2",children:[a.jsx("label",{htmlFor:"displayName",className:"login-label",children:a.jsx(b,{size:"2",weight:"medium",children:"Display Name"})}),a.jsx("input",{id:"displayName",type:"text",value:i,onChange:E=>l(E.target.value),className:"login-input",placeholder:"Admin User",required:!0,disabled:y,autoComplete:"name"})]}),a.jsxs(te,{spacing:"2",children:[a.jsx("label",{htmlFor:"slug",className:"login-label",children:a.jsx(b,{size:"2",weight:"medium",children:"Username"})}),a.jsx("input",{id:"slug",type:"text",value:c,onChange:E=>u(E.target.value),className:"login-input",placeholder:"admin",required:!0,disabled:y,autoComplete:"username"})]}),a.jsxs(te,{spacing:"2",children:[a.jsx("label",{htmlFor:"email",className:"login-label",children:a.jsx(b,{size:"2",weight:"medium",children:"Email"})}),a.jsx("input",{id:"email",type:"email",value:n,onChange:E=>t(E.target.value),className:"login-input",placeholder:"admin@example.com",required:!0,disabled:y,autoComplete:"email"}),a.jsx(b,{size:"1",tone:"muted",children:"Email is not verified and cannot be changed later. Make sure it's correct."})]}),a.jsxs(te,{spacing:"2",children:[a.jsx("label",{htmlFor:"password",className:"login-label",children:a.jsx(b,{size:"2",weight:"medium",children:"Password"})}),a.jsx("input",{id:"password",type:"password",value:f,onChange:E=>x(E.target.value),className:"login-input",placeholder:"••••••••",required:!0,disabled:y,autoComplete:"new-password"}),a.jsx(b,{size:"1",tone:"muted",children:"Remember this password - you won't receive a confirmation email."})]}),g&&a.jsx(Zt,{size:"2",weight:"medium",className:"",children:g}),a.jsx(ue,{type:"submit",variant:"primary",size:"lg",disabled:y,className:"login-button",children:y?"Creating account...":"Create Admin Account"})]})]})})}function Bk(){return a.jsx(Px,{children:a.jsx(Ik,{})})}function Uk({children:n}){const{isAuthenticated:t,isLoading:i}=us(),l=qt();return i?null:t?a.jsx(a.Fragment,{children:n}):a.jsx(Ia,{to:"/login",state:{from:l},replace:!0})}const $k=4;function Hk({children:n}){const[t,i]=h.useState(null),[l,c]=h.useState(!0),[u,f]=h.useState(null),[x,g]=h.useState(0);return h.useEffect(()=>{let m=!0,y;const _=()=>{y&&clearTimeout(y)},v=async()=>{try{const j=await es.webAuthControllerGetOnboardingStatus();if(!m)return;_(),i(j.needsOnboarding),f(null)}catch(j){if(!m)return;console.error("Failed to check onboarding status:",j),f(j instanceof Error?j:new Error("Failed to check onboarding status")),i(null),g(k=>k+1),y=setTimeout(()=>{_(),m&&v()},$k*1e3)}finally{m&&c(!1)}};return v(),()=>{m=!1,_()}},[]),l?null:u?a.jsx("div",{className:"onboarding-checker-shell",children:a.jsxs(te,{spacing:"4",align:"center",className:"onboarding-checker-card",children:[a.jsxs("span",{className:"onboarding-checker-signal","aria-hidden":"true",children:[a.jsx("span",{}),a.jsx("span",{}),a.jsx("span",{})]}),a.jsx(b,{size:"5",weight:"semibold",as:"div",children:"Reconnecting to Taico..."}),a.jsx(b,{size:"3",tone:"muted",as:"div",className:"onboarding-checker-copy",children:"The backend is not responding yet. We will keep retrying until it is back."}),a.jsxs(b,{size:"1",tone:"muted",as:"div",className:"onboarding-checker-feedback",children:["Retry attempt ",x]})]})}):t?a.jsx(Ia,{to:"/onboarding",replace:!0}):a.jsx(a.Fragment,{children:n})}function Pk(n){return h.useSyncExternalStore(t=>{const i=window.matchMedia(n);return i.addEventListener("change",t),()=>i.removeEventListener("change",t)},()=>window.matchMedia(n).matches,()=>!1)}function Rt(){return Pk("(min-width: 768px)")}const Vx=(...n)=>n.filter((t,i,l)=>!!t&&t.trim()!==""&&l.indexOf(t)===i).join(" ").trim();const Gk=n=>n.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();const Vk=n=>n.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,i,l)=>l?l.toUpperCase():i.toLowerCase());const Ry=n=>{const t=Vk(n);return t.charAt(0).toUpperCase()+t.slice(1)};var Ed={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const Fk=n=>{for(const t in n)if(t.startsWith("aria-")||t==="role"||t==="title")return!0;return!1},Yk=h.createContext({}),Qk=()=>h.useContext(Yk),Kk=h.forwardRef(({color:n,size:t,strokeWidth:i,absoluteStrokeWidth:l,className:c="",children:u,iconNode:f,...x},g)=>{const{size:m=24,strokeWidth:y=2,absoluteStrokeWidth:_=!1,color:v="currentColor",className:j=""}=Qk()??{},k=l??_?Number(i??y)*24/Number(t??m):i??y;return h.createElement("svg",{ref:g,...Ed,width:t??m??Ed.width,height:t??m??Ed.height,stroke:n??v,strokeWidth:k,className:Vx("lucide",j,c),...!u&&!Fk(x)&&{"aria-hidden":"true"},...x},[...f.map(([E,w])=>h.createElement(E,w)),...Array.isArray(u)?u:[u]])});const qe=(n,t)=>{const i=h.forwardRef(({className:l,...c},u)=>h.createElement(Kk,{ref:u,iconNode:t,className:Vx(`lucide-${Gk(Ry(n))}`,`lucide-${n}`,l),...c}));return i.displayName=Ry(n),i};const Xk=[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]],Zk=qe("bot",Xk);const Wk=[["path",{d:"M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z",key:"hh9hay"}],["path",{d:"m3.3 7 8.7 5 8.7-5",key:"g66t2b"}],["path",{d:"M12 22V12",key:"d0xqtd"}]],Jk=qe("box",Wk);const eT=[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"M8 14h.01",key:"6423bh"}],["path",{d:"M12 14h.01",key:"1etili"}],["path",{d:"M16 14h.01",key:"1gbofw"}],["path",{d:"M8 18h.01",key:"lrp35t"}],["path",{d:"M12 18h.01",key:"mhygvu"}],["path",{d:"M16 18h.01",key:"kzsmim"}]],Fx=qe("calendar-days",eT);const tT=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],sT=qe("chevron-down",tT);const nT=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],Yx=qe("chevron-right",nT);const aT=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],rT=qe("circle-check",aT);const iT=[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}],["path",{d:"m9 14 2 2 4-4",key:"df797q"}]],Qx=qe("clipboard-check",iT);const lT=[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]],oT=qe("database",lT);const cT=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]],uT=qe("external-link",cT);const dT=[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],hT=qe("eye",dT);const fT=[["path",{d:"M4 20h16a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.93a2 2 0 0 1-1.66-.9l-.82-1.2A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13c0 1.1.9 2 2 2Z",key:"1fr9dc"}],["path",{d:"M8 10v4",key:"tgpxqk"}],["path",{d:"M12 10v2",key:"hh53o1"}],["path",{d:"M16 10v6",key:"1d6xys"}]],Yd=qe("folder-kanban",fT);const pT=[["path",{d:"M4 16v-2.38C4 11.5 2.97 10.5 3 8c.03-2.72 1.49-6 4.5-6C9.37 2 10 3.8 10 5.5c0 3.11-2 5.66-2 8.68V16a2 2 0 1 1-4 0Z",key:"1dudjm"}],["path",{d:"M20 20v-2.38c0-2.12 1.03-3.12 1-5.62-.03-2.72-1.49-6-4.5-6C14.63 6 14 7.8 14 9.5c0 3.11 2 5.66 2 8.68V20a2 2 0 1 0 4 0Z",key:"l2t8xc"}],["path",{d:"M16 17h4",key:"1dejxt"}],["path",{d:"M4 13h4",key:"1bwh8b"}]],gT=qe("footprints",pT);const mT=[["path",{d:"M15 6a9 9 0 0 0-9 9V3",key:"1cii5b"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}]],Kx=qe("git-branch",mT);const yT=[["path",{d:"m15 12-9.373 9.373a1 1 0 0 1-3.001-3L12 9",key:"1hayfq"}],["path",{d:"m18 15 4-4",key:"16gjal"}],["path",{d:"m21.5 11.5-1.914-1.914A2 2 0 0 1 19 8.172v-.344a2 2 0 0 0-.586-1.414l-1.657-1.657A6 6 0 0 0 12.516 3H9l1.243 1.243A6 6 0 0 1 12 8.485V10l2 2h1.172a2 2 0 0 1 1.414.586L18.5 14.5",key:"15ts47"}]],xT=qe("hammer",yT);const vT=[["path",{d:"M12.409 5.824c-.702.792-1.15 1.496-1.415 2.166l2.153 2.156a.5.5 0 0 1 0 .707l-2.293 2.293a.5.5 0 0 0 0 .707L12 15",key:"idzbju"}],["path",{d:"M13.508 20.313a2 2 0 0 1-3 .019L5 15c-1.5-1.5-3-3.2-3-5.5a5.5 5.5 0 0 1 9.591-3.677.6.6 0 0 0 .818.001A5.5 5.5 0 0 1 22 9.5c0 2.29-1.5 4-3 5.5z",key:"1su70f"}]],bT=qe("heart-crack",vT);const _T=[["path",{d:"M2 9.5a5.5 5.5 0 0 1 9.591-3.676.56.56 0 0 0 .818 0A5.49 5.49 0 0 1 22 9.5c0 2.29-1.5 4-3 5.5l-5.492 5.313a2 2 0 0 1-3 .019L5 15c-1.5-1.5-3-3.2-3-5.5",key:"mvr1a0"}]],ST=qe("heart",_T);const jT=[["path",{d:"M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8",key:"5wwlr5"}],["path",{d:"M3 10a2 2 0 0 1 .709-1.528l7-6a2 2 0 0 1 2.582 0l7 6A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z",key:"r6nss1"}]],vh=qe("house",jT);const kT=[["polyline",{points:"22 12 16 12 14 15 10 15 8 12 2 12",key:"o97t9d"}],["path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"oot6mr"}]],TT=qe("inbox",kT);const wT=[["path",{d:"M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z",key:"1s6t7t"}],["circle",{cx:"16.5",cy:"7.5",r:".5",fill:"currentColor",key:"w0ekpg"}]],ET=qe("key-round",wT);const CT=[["path",{d:"M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z",key:"zw3jo"}],["path",{d:"M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12",key:"1wduqc"}],["path",{d:"M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17",key:"kqbvx6"}]],bh=qe("layers",CT);const NT=[["rect",{width:"7",height:"9",x:"3",y:"3",rx:"1",key:"10lvy0"}],["rect",{width:"7",height:"5",x:"14",y:"3",rx:"1",key:"16une8"}],["rect",{width:"7",height:"9",x:"14",y:"12",rx:"1",key:"1hutg5"}],["rect",{width:"7",height:"5",x:"3",y:"16",rx:"1",key:"ldoo1y"}]],Xx=qe("layout-dashboard",NT);const AT=[["circle",{cx:"12",cy:"16",r:"1",key:"1au0dj"}],["rect",{x:"3",y:"10",width:"18",height:"12",rx:"2",key:"6s8ecr"}],["path",{d:"M7 10V7a5 5 0 0 1 10 0v3",key:"1pqi11"}]],RT=qe("lock-keyhole",AT);const zT=[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]],DT=qe("lock",zT);const OT=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"m21 3-7 7",key:"1l2asr"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M9 21H3v-6",key:"wtvkvv"}]],LT=qe("maximize-2",OT);const MT=[["path",{d:"M16 10a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 14.286V4a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2z",key:"1n2ejm"}],["path",{d:"M20 9a2 2 0 0 1 2 2v10.286a.71.71 0 0 1-1.212.502l-2.202-2.202A2 2 0 0 0 17.172 19H10a2 2 0 0 1-2-2v-1",key:"1qfcsi"}]],qT=qe("messages-square",MT);const IT=[["path",{d:"M12 22a1 1 0 0 1 0-20 10 9 0 0 1 10 9 5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z",key:"e79jfc"}],["circle",{cx:"13.5",cy:"6.5",r:".5",fill:"currentColor",key:"1okk4w"}],["circle",{cx:"17.5",cy:"10.5",r:".5",fill:"currentColor",key:"f64h9f"}],["circle",{cx:"6.5",cy:"12.5",r:".5",fill:"currentColor",key:"qy21gx"}],["circle",{cx:"8.5",cy:"7.5",r:".5",fill:"currentColor",key:"fotxhn"}]],BT=qe("palette",IT);const UT=[["path",{d:"M3 2v1c0 1 2 1 2 2S3 6 3 7s2 1 2 2-2 1-2 2 2 1 2 2",key:"19w3oe"}],["path",{d:"M18 6h.01",key:"1v4wsw"}],["path",{d:"M6 18h.01",key:"uhywen"}],["path",{d:"M20.83 8.83a4 4 0 0 0-5.66-5.66l-12 12a4 4 0 1 0 5.66 5.66Z",key:"6fykxj"}],["path",{d:"M18 11.66V22a4 4 0 0 0 4-4V6",key:"1utzek"}]],$T=qe("pocket-knife",UT);const HT=[["path",{d:"M15.39 4.39a1 1 0 0 0 1.68-.474 2.5 2.5 0 1 1 3.014 3.015 1 1 0 0 0-.474 1.68l1.683 1.682a2.414 2.414 0 0 1 0 3.414L19.61 15.39a1 1 0 0 1-1.68-.474 2.5 2.5 0 1 0-3.014 3.015 1 1 0 0 1 .474 1.68l-1.683 1.682a2.414 2.414 0 0 1-3.414 0L8.61 19.61a1 1 0 0 0-1.68.474 2.5 2.5 0 1 1-3.014-3.015 1 1 0 0 0 .474-1.68l-1.683-1.682a2.414 2.414 0 0 1 0-3.414L4.39 8.61a1 1 0 0 1 1.68.474 2.5 2.5 0 1 0 3.014-3.015 1 1 0 0 1-.474-1.68l1.683-1.682a2.414 2.414 0 0 1 3.414 0z",key:"w46dr5"}]],PT=qe("puzzle",HT);const GT=[["path",{d:"M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5",key:"qeys4"}],["path",{d:"M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 0 0-2.91-.09",key:"u4xsad"}],["path",{d:"M9 12a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.4 22.4 0 0 1-4 2z",key:"676m9"}],["path",{d:"M9 12H4s.55-3.03 2-4c1.62-1.08 5 .05 5 .05",key:"92ym6u"}]],VT=qe("rocket",GT);const FT=[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]],zy=qe("server",FT);const YT=[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915",key:"1i5ecw"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],Zx=qe("settings",YT);const QT=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]],KT=qe("shield",QT);const XT=[["path",{d:"M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z",key:"1s2grr"}],["path",{d:"M20 2v4",key:"1rf3ol"}],["path",{d:"M22 4h-4",key:"gwowj6"}],["circle",{cx:"4",cy:"20",r:"2",key:"6kqj1y"}]],ZT=qe("sparkles",XT);const WT=[["path",{d:"M15.236 22a3 3 0 0 0-2.2-5",key:"21bitc"}],["path",{d:"M16 20a3 3 0 0 1 3-3h1a2 2 0 0 0 2-2v-2a4 4 0 0 0-4-4V4",key:"oh0fg0"}],["path",{d:"M18 13h.01",key:"9veqaj"}],["path",{d:"M18 6a4 4 0 0 0-4 4 7 7 0 0 0-7 7c0-5 4-5 4-10.5a4.5 4.5 0 1 0-9 0 2.5 2.5 0 0 0 5 0C7 10 3 11 3 17c0 2.8 2.2 5 5 5h10",key:"980v8a"}]],Wx=qe("squirrel",WT);const JT=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"19",x2:"19",y1:"8",y2:"14",key:"1bvyxn"}],["line",{x1:"22",x2:"16",y1:"11",y2:"11",key:"1shjgl"}]],e0=qe("user-plus",JT);const t0=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["path",{d:"M16 3.128a4 4 0 0 1 0 7.744",key:"16gr8j"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}]],s0=qe("users",t0);const n0=[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]],a0=qe("zap",n0);const r0=[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"11",x2:"11",y1:"8",y2:"14",key:"1vmskp"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]],i0=qe("zoom-in",r0);const l0=[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]],o0=qe("zoom-out",l0),zr=[{path:"/home",label:"Home",icon:vh},{path:"/tasks",label:"Tasks",icon:Qx},{path:"/tasks/schedule",label:"Schedules",icon:Fx},{path:"/context",label:"Context",icon:bh},{path:"/agents",label:"Agents",icon:Wx},{path:"/threads",label:"Threads",icon:qT},{path:"/tools",label:"Tools",icon:$T},{path:"/runs",label:"Runs",icon:a0},{path:"/settings",label:"Settings",icon:Zx},{path:"/logout",label:"Logout",icon:DT}];function jt(n){const t=qt();Wt(),h.useEffect(()=>{const i=t.pathname;let l="taico";if(i.startsWith("/home"))l="taico";else if(i.match(/\/tasks\/task\/.+/)&&n?.task?.name){const c=n.task.name;l=c.length>50?c.substring(0,50)+"...":c}else if(i.startsWith("/tasks"))l="tasks";else if(i.match(/\/context\/block\/.+/)&&n?.contextBlock?.title){const c=n.contextBlock.title;l=c.length>50?c.substring(0,50)+"...":c}else if(i.startsWith("/context"))l="context";else if(i.startsWith("/settings"))l="settings";else if(i.match(/\/agents\/agent\/.+/)&&n?.agent?.name)l=n.agent.name;else if(i.startsWith("/agents"))l="agents";else if(i.match(/\/tools\/tool\/.+/)&&n?.tool?.name)l=n.tool.name;else if(i.startsWith("/tools"))l="tools";else if(i.match(/\/threads\/.+/)&&n?.thread?.title){const c=n.thread.title;l=c.length>50?c.substring(0,50)+"...":c}else i.startsWith("/threads")?l="threads":i.startsWith("/runs")||i.startsWith("/executions")?l="runs":i.startsWith("/walkthrough")&&(l="walkthrough");document.title=l},[t.pathname,n])}function al({icon:n,className:t,size:i=22}){if(typeof n=="string")return a.jsx("span",{className:t,children:n});const l=n;return a.jsx(l,{className:t,size:i,strokeWidth:1.5,absoluteStrokeWidth:!0})}function c0({children:n}){console.log("Beta shell");const{user:t}=us(),i=qt();jt();const l=h.useMemo(()=>{if(!(t?.onboardingDisplayMode==="FULL_PAGE"||t?.onboardingDisplayMode==="BANNER"))return zr;const m=zr.findIndex(_=>_.path==="/settings"),y=[...zr];return y.splice(m,0,{path:"/walkthrough",label:"Walkthrough",icon:gT}),y},[t?.onboardingDisplayMode]),c=Rt(),[u,f]=h.useState(()=>localStorage.getItem("sidebar-collapsed")==="true");h.useEffect(()=>{localStorage.setItem("sidebar-collapsed",String(u))},[u]);const x=()=>{f(!u)};return a.jsxs("div",{className:`${c?"beta-shell__desktop":"beta-shell__mobile"}`,"data-shell":`${c?"desktop":"mobile"}`,children:[c&&a.jsxs("aside",{className:`beta-shell__desktop__sidebar ${u?"beta-shell__desktop__sidebar--collapsed":""}`,children:[a.jsx("nav",{className:"beta-shell__desktop__nav",children:a.jsx("div",{className:"beta-shell__desktop__navInner",children:a.jsx(te,{spacing:"1",children:l.map(g=>{const m=i.pathname.startsWith(g.path);return a.jsxs(Mn,{to:g.path,title:u?g.label:void 0,className:`beta-shell__desktop__nav-item ${m?"beta-shell__desktop__nav-item--active":""}`,children:[a.jsx(al,{icon:g.icon,className:"beta-shell__desktop__nav-icon"}),!u&&a.jsx("span",{className:"beta-shell__desktop__nav-label",children:g.label})]},g.path)})})})}),a.jsx("button",{className:"beta-shell__desktop__sidebar--toggle",onClick:x,"aria-label":u?"Expand sidebar":"Collapse sidebar",children:u?"→":"←"})]}),a.jsx("div",{className:`${c?"beta-shell__desktop__main":""}`,children:n})]})}function u0(n){return typeof n=="object"&&n!==null}function d0(n){if(!u0(n))return;const t=n.detail;if(typeof t=="string"&&t.length>0)return t;const i=n.message;if(typeof i=="string"&&i.length>0)return i;const l=n.title;if(typeof l=="string"&&l.length>0)return l;const c=n.error_description;if(typeof c=="string"&&c.length>0)return c}class Dy extends Error{status;statusText;body;constructor(t,i){const l=d0(i)??`HTTP ${t.status}: ${t.statusText}`;super(l),this.name="ApiError",this.status=t.status,this.statusText=t.statusText,this.body=i}}class ht{config;constructor(t){this.config=t}async parseResponseBody(t,i="auto"){if(i==="void"||t.status===204||t.headers.get("content-length")==="0")return;if(i==="json")try{return await t.json()}catch{return}if(i==="text"){const u=await t.text();return u.length>0?u:void 0}if(i==="arrayBuffer"){const u=await t.arrayBuffer();return u.byteLength>0?u:void 0}if(t.headers.get("content-type")?.includes("application/json"))try{return await t.json()}catch{return}const c=await t.text();return c.length>0?c:void 0}hasHeader(t,i){const l=i.toLowerCase();return Object.keys(t).some(c=>c.toLowerCase()===l)}removeHeader(t,i){const l=i.toLowerCase();for(const c of Object.keys(t))c.toLowerCase()===l&&delete t[c]}async buildAuthHeaders(){const t={};if(this.config.getAccessToken){const i=await this.config.getAccessToken();t.Authorization=`Bearer ${i}`}return this.config.getCookies&&(t.Cookie=await this.config.getCookies()),t}async request(t,i,l){const c=new URL(i,this.config.baseUrl);if(l?.params)for(const[g,m]of Object.entries(l.params))m!=null&&c.searchParams.append(g,String(m));const u={};if(this.config.headers)for(const[g,m]of Object.entries(this.config.headers))m!=null&&(u[g]=String(m));if(l?.headers)for(const[g,m]of Object.entries(l.headers))m!=null&&(u[g]=String(m));Object.assign(u,await this.buildAuthHeaders());let f;if(l?.body!==void 0){const g=l.bodyType??"json";g==="form-data"?(f=l.body,this.removeHeader(u,"Content-Type")):g==="raw"?f=l.body:(this.hasHeader(u,"Content-Type")||(u["Content-Type"]="application/json"),f=JSON.stringify(l.body))}const x=await fetch(c.toString(),{method:t,headers:u,body:f,signal:l?.signal,credentials:this.config.credentials});if(!x.ok){const g=await this.parseResponseBody(x,"auto");throw new Dy(x,g)}return await this.parseResponseBody(x,l?.responseType??"auto")}async*streamEvents(t,i){const l=new URL(t,this.config.baseUrl);if(i?.params)for(const[m,y]of Object.entries(i.params))y!=null&&l.searchParams.append(m,String(y));const c={Accept:"text/event-stream"};if(this.config.headers)for(const[m,y]of Object.entries(this.config.headers))y!=null&&(c[m]=String(y));if(i?.headers)for(const[m,y]of Object.entries(i.headers))y!=null&&(c[m]=String(y));Object.assign(c,await this.buildAuthHeaders());const u=await fetch(l.toString(),{method:"GET",headers:c,signal:i?.signal,credentials:this.config.credentials});if(!u.ok){const m=await this.parseResponseBody(u);throw new Dy(u,m)}if(!u.body)throw new Error("Response body is null");const f=u.body.getReader(),x=new TextDecoder;let g="";try{for(;;){const{done:m,value:y}=await f.read();if(m)break;g+=x.decode(y,{stream:!0});const _=g.split(`
|
|
12
|
-
`);g=_.pop()||"";for(const v of _)if(v.startsWith("data: ")){const j=v.slice(6);try{yield JSON.parse(j)}catch{yield j}}}}finally{f.releaseLock()}}}class h0 extends ht{constructor(t){super(t)}async AppController_getHello(t){return this.request("GET","/api/v1",{signal:t?.signal})}}class f0 extends ht{constructor(t){super(t)}async MetaController_createTag(t){return this.request("POST","/api/v1/meta/tags",{body:t.body,signal:t?.signal})}async MetaController_getAllTags(t){return this.request("GET","/api/v1/meta/tags",{signal:t?.signal})}async MetaController_getTagColors(t){return this.request("GET","/api/v1/meta/tags/colors",{signal:t?.signal})}async MetaController_deleteTag(t){return this.request("DELETE",`/api/v1/meta/tags/${t.tagId}`,{responseType:"void",signal:t?.signal})}async MetaController_getVersion(t){return this.request("GET","/api/v1/meta/version",{signal:t?.signal})}}class p0 extends ht{constructor(t){super(t)}async ProjectsController_createProject(t){return this.request("POST","/api/v1/meta/projects",{body:t.body,signal:t?.signal})}async ProjectsController_getAllProjects(t){return this.request("GET","/api/v1/meta/projects",{signal:t?.signal})}async ProjectsController_searchProjects(t){return this.request("GET","/api/v1/meta/projects/search",{params:{q:t.q,limit:t.limit,threshold:t.threshold},signal:t?.signal})}async ProjectsController_getProjectBySlug(t){return this.request("GET",`/api/v1/meta/projects/by-slug/${t.slug}`,{signal:t?.signal})}async ProjectsController_getProject(t){return this.request("GET",`/api/v1/meta/projects/${t.projectId}`,{signal:t?.signal})}async ProjectsController_updateProject(t){return this.request("PATCH",`/api/v1/meta/projects/${t.projectId}`,{body:t.body,signal:t?.signal})}async ProjectsController_deleteProject(t){return this.request("DELETE",`/api/v1/meta/projects/${t.projectId}`,{responseType:"void",signal:t?.signal})}}class g0 extends ht{constructor(t){super(t)}async ClientRegistrationController_registerClient(t){return this.request("POST",`/api/v1/auth/clients/register/mcp/${t.serverId}/${t.version}`,{body:t.body,signal:t?.signal})}async ClientRegistrationController_getClient(t){return this.request("GET",`/api/v1/auth/clients/${t.clientId}`,{signal:t?.signal})}async ClientRegistrationController_listClients(t){return this.request("GET","/api/v1/auth/clients",{signal:t?.signal})}async AuthorizationController_authorize(t){return this.request("GET",`/api/v1/auth/authorize/mcp/${t.serverIdentifier}/${t.version}`,{params:{response_type:t.response_type,scope:t.scope,client_id:t.client_id,code_challenge:t.code_challenge,code_challenge_method:t.code_challenge_method,redirect_uri:t.redirect_uri,state:t.state,resource:t.resource},responseType:"void",signal:t?.signal})}async AuthorizationController_authorizeConsent(t){return this.request("POST",`/api/v1/auth/authorize/mcp/${t.serverIdentifier}/${t.version}`,{body:t.body,responseType:"void",signal:t?.signal})}async AuthorizationController_getConsentMetadata(t){return this.request("GET",`/api/v1/auth/consent/${t.flowId}`,{signal:t?.signal})}async AuthorizationController_token(t){return this.request("POST",`/api/v1/auth/token/mcp/${t.serverIdentifier}/${t.version}`,{body:t.body,signal:t?.signal})}async AuthorizationController_introspect(t){return this.request("POST",`/api/v1/auth/introspect/mcp/${t.serverIdentifier}/${t.version}`,{body:t.body,signal:t?.signal})}async AuthorizationController_tokenExchange(t){return this.request("POST",`/api/v1/auth/token-exchange/mcp/${t.serverIdentifier}/${t.version}`,{body:t.body,signal:t?.signal})}async AuthorizationController_callback(t){return this.request("GET","/api/v1/auth/callback",{params:{code:t.code,state:t.state,error:t.error,scope:t.scope,error_description:t.error_description},responseType:"void",signal:t?.signal})}async AuthorizationController_getScopes(t){return this.request("GET","/api/v1/auth/scopes",{signal:t?.signal})}}class m0 extends ht{constructor(t){super(t)}async WebAuthController_login(t){return this.request("POST","/api/v1/auth/login",{body:t.body,signal:t?.signal})}async WebAuthController_listUsers(t){return this.request("GET","/api/v1/auth/users",{signal:t?.signal})}async WebAuthController_createUser(t){return this.request("POST","/api/v1/auth/users",{body:t.body,signal:t?.signal})}async WebAuthController_resetUserPassword(t){return this.request("POST",`/api/v1/auth/users/${t.userId}/reset-password`,{signal:t?.signal})}async WebAuthController_deleteUser(t){return this.request("DELETE",`/api/v1/auth/users/${t.userId}`,{signal:t?.signal})}async WebAuthController_getAccountSetupStatus(t){return this.request("POST","/api/v1/auth/account-setup-status",{body:t.body,signal:t?.signal})}async WebAuthController_setupAccount(t){return this.request("POST","/api/v1/auth/setup-account",{body:t.body,signal:t?.signal})}async WebAuthController_refresh(t){return this.request("POST","/api/v1/auth/refresh",{signal:t?.signal})}async WebAuthController_logout(t){return this.request("POST","/api/v1/auth/logout",{signal:t?.signal})}async WebAuthController_me(t){return this.request("GET","/api/v1/auth/me",{signal:t?.signal})}async WebAuthController_changePassword(t){return this.request("POST","/api/v1/auth/change-password",{body:t.body,signal:t?.signal})}async WebAuthController_getOnboardingStatus(t){return this.request("GET","/api/v1/auth/onboarding-status",{signal:t?.signal})}async WebAuthController_onboard(t){return this.request("POST","/api/v1/auth/onboard",{body:t.body,signal:t?.signal})}async WebAuthController_markWalkthroughSeen(t){return this.request("POST","/api/v1/auth/mark-walkthrough-seen",{signal:t?.signal})}}class y0 extends ht{constructor(t){super(t)}async AuthJourneysController_getAuthJourneys(t){return this.request("GET",`/api/v1/auth-journeys/servers/${t.serverId}`,{signal:t?.signal})}}class x0 extends ht{constructor(t){super(t)}async McpRegistryController_createServer(t){return this.request("POST","/api/v1/mcp/servers",{body:t.body,signal:t?.signal})}async McpRegistryController_listServers(t){return this.request("GET","/api/v1/mcp/servers",{params:{page:t?.page,limit:t?.limit},signal:t?.signal})}async McpRegistryController_getServer(t){return this.request("GET",`/api/v1/mcp/servers/${t.serverId}`,{signal:t?.signal})}async McpRegistryController_updateServer(t){return this.request("PATCH",`/api/v1/mcp/servers/${t.serverId}`,{body:t.body,signal:t?.signal})}async McpRegistryController_deleteServer(t){return this.request("DELETE",`/api/v1/mcp/servers/${t.serverId}`,{signal:t?.signal})}async McpRegistryController_createScopes(t){return this.request("POST",`/api/v1/mcp/servers/${t.serverId}/scopes`,{body:t.body,signal:t?.signal})}async McpRegistryController_listScopes(t){return this.request("GET",`/api/v1/mcp/servers/${t.serverId}/scopes`,{signal:t?.signal})}async McpRegistryController_getScope(t){return this.request("GET",`/api/v1/mcp/servers/${t.serverId}/scopes/${t.scopeId}`,{signal:t?.signal})}async McpRegistryController_deleteScope(t){return this.request("DELETE",`/api/v1/mcp/servers/${t.serverId}/scopes/${t.scopeId}`,{signal:t?.signal})}async McpRegistryController_createConnection(t){return this.request("POST",`/api/v1/mcp/servers/${t.serverId}/connections`,{body:t.body,signal:t?.signal})}async McpRegistryController_listConnections(t){return this.request("GET",`/api/v1/mcp/servers/${t.serverId}/connections`,{signal:t?.signal})}async McpRegistryController_getConnection(t){return this.request("GET",`/api/v1/mcp/connections/${t.connectionId}`,{signal:t?.signal})}async McpRegistryController_updateConnection(t){return this.request("PATCH",`/api/v1/mcp/connections/${t.connectionId}`,{body:t.body,signal:t?.signal})}async McpRegistryController_deleteConnection(t){return this.request("DELETE",`/api/v1/mcp/connections/${t.connectionId}`,{signal:t?.signal})}async McpRegistryController_createMapping(t){return this.request("POST",`/api/v1/mcp/servers/${t.serverId}/mappings`,{body:t.body,signal:t?.signal})}async McpRegistryController_listMappings(t){return this.request("GET",`/api/v1/mcp/servers/${t.serverId}/scopes/${t.scopeId}/mappings`,{signal:t?.signal})}async McpRegistryController_deleteMapping(t){return this.request("DELETE",`/api/v1/mcp/mappings/${t.mappingId}`,{signal:t?.signal})}}class v0 extends ht{constructor(t){super(t)}async JwksController_getJwks(t){return this.request("GET","/.well-known/jwks.json",{signal:t?.signal})}}class b0 extends ht{constructor(t){super(t)}async ActorController_listActors(t){return this.request("GET","/api/v1/actors",{signal:t?.signal})}async ActorController_searchActors(t){return this.request("GET","/api/v1/actors/search",{params:{query:t.query,limit:t.limit,threshold:t.threshold},signal:t?.signal})}}class _0 extends ht{constructor(t){super(t)}async TasksController_createTask(t){return this.request("POST","/api/v1/tasks/tasks",{body:t.body,signal:t?.signal})}async TasksController_listTasks(t){return this.request("GET","/api/v1/tasks/tasks",{params:{assignee:t?.assignee,sessionId:t?.sessionId,tag:t?.tag,page:t?.page,limit:t?.limit},signal:t?.signal})}async TasksController_updateTask(t){return this.request("PATCH",`/api/v1/tasks/tasks/${t.id}`,{body:t.body,signal:t?.signal})}async TasksController_deleteTask(t){return this.request("DELETE",`/api/v1/tasks/tasks/${t.id}`,{responseType:"void",signal:t?.signal})}async TasksController_getTask(t){return this.request("GET",`/api/v1/tasks/tasks/${t.id}`,{signal:t?.signal})}async TasksController_assignTask(t){return this.request("PATCH",`/api/v1/tasks/tasks/${t.id}/assign`,{body:t.body,signal:t?.signal})}async TasksController_assignTaskToMe(t){return this.request("PATCH",`/api/v1/tasks/tasks/${t.id}/assign-to-me`,{signal:t?.signal})}async TasksController_searchTasks(t){return this.request("GET","/api/v1/tasks/tasks/search/query",{params:{query:t.query,limit:t.limit,threshold:t.threshold},signal:t?.signal})}async TasksController_addComment(t){return this.request("POST",`/api/v1/tasks/tasks/${t.id}/comments`,{body:t.body,signal:t?.signal})}async TasksController_addArtefact(t){return this.request("POST",`/api/v1/tasks/tasks/${t.id}/artefacts`,{body:t.body,signal:t?.signal})}async TasksController_changeStatus(t){return this.request("PATCH",`/api/v1/tasks/tasks/${t.id}/status`,{body:t.body,signal:t?.signal})}async TasksController_addTagToTask(t){return this.request("POST",`/api/v1/tasks/tasks/${t.id}/tags`,{body:t.body,signal:t?.signal})}async TasksController_removeTagFromTask(t){return this.request("DELETE",`/api/v1/tasks/tasks/${t.id}/tags/${t.tagId}`,{signal:t?.signal})}async TasksController_createInputRequest(t){return this.request("POST",`/api/v1/tasks/tasks/${t.id}/input-requests`,{body:t.body,signal:t?.signal})}async TasksController_answerInputRequest(t){return this.request("POST",`/api/v1/tasks/tasks/${t.id}/input-requests/${t.inputRequestId}/answer`,{body:t.body,signal:t?.signal})}async TasksController_handleMcp_get(t){return this.request("GET","/api/v1/tasks/tasks/mcp",{responseType:"void",signal:t?.signal})}async TasksController_handleMcp_post(t){return this.request("POST","/api/v1/tasks/tasks/mcp",{responseType:"void",signal:t?.signal})}async TasksController_handleMcp_put(t){return this.request("PUT","/api/v1/tasks/tasks/mcp",{responseType:"void",signal:t?.signal})}async TasksController_handleMcp_delete(t){return this.request("DELETE","/api/v1/tasks/tasks/mcp",{responseType:"void",signal:t?.signal})}async TasksController_handleMcp_patch(t){return this.request("PATCH","/api/v1/tasks/tasks/mcp",{responseType:"void",signal:t?.signal})}async TasksController_handleMcp_options(t){return this.request("OPTIONS","/api/v1/tasks/tasks/mcp",{responseType:"void",signal:t?.signal})}async TasksController_handleMcp_head(t){return this.request("HEAD","/api/v1/tasks/tasks/mcp",{responseType:"void",signal:t?.signal})}}class S0 extends ht{constructor(t){super(t)}async AgentRunsController_createAgentRun(t){return this.request("POST","/api/v1/agent-runs",{body:t.body,signal:t?.signal})}async AgentRunsController_listAgentRuns(t){return this.request("GET","/api/v1/agent-runs",{params:{actorId:t?.actorId,parentTaskId:t?.parentTaskId,page:t?.page,limit:t?.limit},signal:t?.signal})}async AgentRunsController_getAgentRunById(t){return this.request("GET",`/api/v1/agent-runs/${t.runId}`,{signal:t?.signal})}async AgentRunsController_updateAgentRun(t){return this.request("PATCH",`/api/v1/agent-runs/${t.runId}`,{body:t.body,signal:t?.signal})}}class j0 extends ht{constructor(t){super(t)}async ThreadsController_createThread(t){return this.request("POST","/api/v1/threads",{body:t.body,signal:t?.signal})}async ThreadsController_listThreads(t){return this.request("GET","/api/v1/threads",{params:{page:t?.page,limit:t?.limit},signal:t?.signal})}async ThreadsController_updateThread(t){return this.request("PATCH",`/api/v1/threads/${t.id}`,{body:t.body,signal:t?.signal})}async ThreadsController_getThread(t){return this.request("GET",`/api/v1/threads/${t.id}`,{signal:t?.signal})}async ThreadsController_deleteThread(t){return this.request("DELETE",`/api/v1/threads/${t.id}`,{responseType:"void",signal:t?.signal})}async ThreadsController_getThreadByTaskId(t){return this.request("GET",`/api/v1/threads/by-task/${t.taskId}`,{signal:t?.signal})}async ThreadsController_getThreadsByStateBlockId(t){return this.request("GET",`/api/v1/threads/by-state-block/${t.stateBlockId}`,{signal:t?.signal})}async ThreadsController_attachTask(t){return this.request("POST",`/api/v1/threads/${t.id}/tasks`,{body:t.body,signal:t?.signal})}async ThreadsController_referenceContextBlock(t){return this.request("POST",`/api/v1/threads/${t.id}/context-blocks`,{body:t.body,signal:t?.signal})}async ThreadsController_addTagToThread(t){return this.request("POST",`/api/v1/threads/${t.id}/tags`,{body:t.body,signal:t?.signal})}async ThreadsController_removeTagFromThread(t){return this.request("DELETE",`/api/v1/threads/${t.id}/tags/${t.tagId}`,{signal:t?.signal})}async ThreadsController_addParticipant(t){return this.request("POST",`/api/v1/threads/${t.id}/participants`,{body:t.body,signal:t?.signal})}async ThreadsController_getThreadState(t){return this.request("GET",`/api/v1/threads/${t.id}/state`,{signal:t?.signal})}async ThreadsController_updateThreadState(t){return this.request("PATCH",`/api/v1/threads/${t.id}/state`,{body:t.body,signal:t?.signal})}async ThreadsController_appendThreadState(t){return this.request("POST",`/api/v1/threads/${t.id}/state/append`,{body:t.body,signal:t?.signal})}async ThreadsController_createMessage(t){return this.request("POST",`/api/v1/threads/${t.id}/messages`,{body:t.body,signal:t?.signal})}async ThreadsController_listMessages(t){return this.request("GET",`/api/v1/threads/${t.id}/messages`,{params:{page:t.page,limit:t.limit},signal:t?.signal})}}class k0 extends ht{constructor(t){super(t)}async AgentsController_createAgent(t){return this.request("POST","/api/v1/agents",{body:t.body,signal:t?.signal})}async AgentsController_listAgents(t){return this.request("GET","/api/v1/agents",{params:{isActive:t?.isActive,page:t?.page,limit:t?.limit},signal:t?.signal})}async AgentsController_listAgentTemplates(t){return this.request("GET","/api/v1/agents/templates",{signal:t?.signal})}async AgentsController_getAgentBySlug(t){return this.request("GET",`/api/v1/agents/${t.slug}`,{signal:t?.signal})}async AgentsController_patchAgent(t){return this.request("PATCH",`/api/v1/agents/${t.actorId}`,{body:t.body,signal:t?.signal})}async AgentsController_deleteAgent(t){return this.request("DELETE",`/api/v1/agents/${t.actorId}`,{responseType:"void",signal:t?.signal})}async AgentToolPermissionsController_listAgentToolPermissions(t){return this.request("GET",`/api/v1/agents/${t.actorId}/tool-permissions`,{signal:t?.signal})}async AgentToolPermissionsController_upsertAgentToolPermission(t){return this.request("PUT",`/api/v1/agents/${t.actorId}/tool-permissions/${t.serverId}`,{body:t.body,signal:t?.signal})}async AgentToolPermissionsController_deleteAgentToolPermission(t){return this.request("DELETE",`/api/v1/agents/${t.actorId}/tool-permissions/${t.serverId}`,{responseType:"void",signal:t?.signal})}}class T0 extends ht{constructor(t){super(t)}async AgentTokensController_issueToken(t){return this.request("POST",`/api/v1/agents/${t.slug}/tokens`,{body:t.body,signal:t?.signal})}async AgentTokensController_listTokens(t){return this.request("GET",`/api/v1/agents/${t.slug}/tokens`,{signal:t?.signal})}async AgentTokensController_revokeToken(t){return this.request("DELETE",`/api/v1/agents/${t.slug}/tokens/${t.tokenId}`,{signal:t?.signal})}}class w0 extends ht{constructor(t){super(t)}async AgentExecutionTokensController_requestExecutionToken(t){return this.request("POST",`/api/v1/agents/${t.slug}/execution-token`,{body:t.body,signal:t?.signal})}}class E0 extends ht{constructor(t){super(t)}async ContextController_createBlock(t){return this.request("POST","/api/v1/context/blocks",{body:t.body,signal:t?.signal})}async ContextController_listBlocks(t){return this.request("GET","/api/v1/context/blocks",{params:{tag:t?.tag},signal:t?.signal})}async ContextController_searchBlocks(t){return this.request("GET","/api/v1/context/blocks/search/query",{params:{query:t.query,limit:t.limit,threshold:t.threshold},signal:t?.signal})}async ContextController_getBlockTree(t){return this.request("GET","/api/v1/context/blocks/tree",{signal:t?.signal})}async ContextController_exportBlocks(t){return this.request("GET","/api/v1/context/blocks/export",{responseType:"arrayBuffer",signal:t?.signal})}async ContextController_importBlocks(t){return this.request("POST","/api/v1/context/blocks/import",{body:t.body,bodyType:"form-data",signal:t?.signal})}async ContextController_getBlock(t){return this.request("GET",`/api/v1/context/blocks/${t.id}`,{signal:t?.signal})}async ContextController_updateBlock(t){return this.request("PATCH",`/api/v1/context/blocks/${t.id}`,{body:t.body,signal:t?.signal})}async ContextController_deleteBlock(t){return this.request("DELETE",`/api/v1/context/blocks/${t.id}`,{responseType:"void",signal:t?.signal})}async ContextController_appendToBlock(t){return this.request("POST",`/api/v1/context/blocks/${t.id}/append`,{body:t.body,signal:t?.signal})}async ContextController_reorderBlock(t){return this.request("PATCH",`/api/v1/context/blocks/${t.id}/reorder`,{body:t.body,signal:t?.signal})}async ContextController_moveBlock(t){return this.request("PATCH",`/api/v1/context/blocks/${t.id}/move`,{body:t.body,signal:t?.signal})}async ContextController_addTagToBlock(t){return this.request("POST",`/api/v1/context/blocks/${t.id}/tags`,{body:t.body,signal:t?.signal})}async ContextController_removeTagFromBlock(t){return this.request("DELETE",`/api/v1/context/blocks/${t.id}/tags/${t.tagId}`,{signal:t?.signal})}async ContextController_handleMcp_get(t){return this.request("GET","/api/v1/context/blocks/mcp",{responseType:"void",signal:t?.signal})}async ContextController_handleMcp_post(t){return this.request("POST","/api/v1/context/blocks/mcp",{responseType:"void",signal:t?.signal})}async ContextController_handleMcp_put(t){return this.request("PUT","/api/v1/context/blocks/mcp",{responseType:"void",signal:t?.signal})}async ContextController_handleMcp_delete(t){return this.request("DELETE","/api/v1/context/blocks/mcp",{responseType:"void",signal:t?.signal})}async ContextController_handleMcp_patch(t){return this.request("PATCH","/api/v1/context/blocks/mcp",{responseType:"void",signal:t?.signal})}async ContextController_handleMcp_options(t){return this.request("OPTIONS","/api/v1/context/blocks/mcp",{responseType:"void",signal:t?.signal})}async ContextController_handleMcp_head(t){return this.request("HEAD","/api/v1/context/blocks/mcp",{responseType:"void",signal:t?.signal})}}class C0 extends ht{constructor(t){super(t)}async ChatProvidersController_createChatProvider(t){return this.request("POST","/api/v1/chat-providers",{body:t.body,signal:t?.signal})}async ChatProvidersController_listChatProviders(t){return this.request("GET","/api/v1/chat-providers",{signal:t?.signal})}async ChatProvidersController_getChatProvider(t){return this.request("GET",`/api/v1/chat-providers/${t.id}`,{signal:t?.signal})}async ChatProvidersController_updateChatProvider(t){return this.request("PATCH",`/api/v1/chat-providers/${t.id}`,{body:t.body,signal:t?.signal})}async ChatProvidersController_deleteChatProvider(t){return this.request("DELETE",`/api/v1/chat-providers/${t.id}`,{responseType:"void",signal:t?.signal})}async ChatProvidersController_setActiveChatProvider(t){return this.request("POST","/api/v1/chat-providers/set-active",{body:t.body,signal:t?.signal})}async ChatProvidersController_deactivateActiveChatProvider(t){return this.request("POST","/api/v1/chat-providers/deactivate",{responseType:"void",signal:t?.signal})}}class N0 extends ht{constructor(t){super(t)}async SecretsController_createSecret(t){return this.request("POST","/api/v1/secrets",{body:t.body,signal:t?.signal})}async SecretsController_listSecrets(t){return this.request("GET","/api/v1/secrets",{signal:t?.signal})}async SecretsController_getSecret(t){return this.request("GET",`/api/v1/secrets/${t.id}`,{signal:t?.signal})}async SecretsController_updateSecret(t){return this.request("PATCH",`/api/v1/secrets/${t.id}`,{body:t.body,signal:t?.signal})}async SecretsController_deleteSecret(t){return this.request("DELETE",`/api/v1/secrets/${t.id}`,{responseType:"void",signal:t?.signal})}async SecretsController_getSecretValue(t){return this.request("GET",`/api/v1/secrets/${t.id}/value`,{signal:t?.signal})}}class A0 extends ht{constructor(t){super(t)}async TaskExecutionQueueController_listQueue(t){return this.request("GET","/api/v1/executions/queue",{params:{page:t?.page,limit:t?.limit},signal:t?.signal})}async TaskExecutionQueueController_claimTask(t){return this.request("POST",`/api/v1/executions/queue/${t.taskId}/claim`,{signal:t?.signal})}async ActiveTaskExecutionController_listActiveExecutions(t){return this.request("GET","/api/v1/executions/active",{params:{page:t?.page,limit:t?.limit,taskId:t?.taskId},signal:t?.signal})}async ActiveTaskExecutionController_stopTaskExecution(t){return this.request("POST",`/api/v1/executions/active/${t.executionId}/stop`,{body:t.body,signal:t?.signal})}async ActiveTaskExecutionController_unclaimTaskExecution(t){return this.request("POST",`/api/v1/executions/active/${t.executionId}/unclaim`,{responseType:"void",signal:t?.signal})}async ActiveTaskExecutionController_updateRunnerSessionId(t){return this.request("PATCH",`/api/v1/executions/active/${t.executionId}/session`,{body:t.body,responseType:"void",signal:t?.signal})}async ActiveTaskExecutionController_incrementToolCallCount(t){return this.request("PATCH",`/api/v1/executions/active/${t.executionId}/tool-calls/increment`,{responseType:"void",signal:t?.signal})}async ActiveTaskExecutionController_updateExecutionStats(t){return this.request("PATCH",`/api/v1/executions/active/${t.executionId}/stats`,{body:t.body,responseType:"void",signal:t?.signal})}async ActiveTaskExecutionController_interruptExecution(t){return this.request("POST",`/api/v1/executions/active/${t.executionId}/interrupt`,{responseType:"void",signal:t?.signal})}async TaskExecutionHistoryController_listHistory(t){return this.request("GET","/api/v1/executions/history",{params:{page:t?.page,limit:t?.limit,taskId:t?.taskId},signal:t?.signal})}}class R0 extends ht{constructor(t){super(t)}async WorkersController_listWorkers(t){return this.request("GET","/api/v1/workers",{signal:t?.signal})}}class z0 extends ht{constructor(t){super(t)}async TaskBlueprintsController_createTaskBlueprint(t){return this.request("POST","/api/v1/task-blueprints",{body:t.body,signal:t?.signal})}async TaskBlueprintsController_listTaskBlueprints(t){return this.request("GET","/api/v1/task-blueprints",{params:{page:t?.page,limit:t?.limit},signal:t?.signal})}async TaskBlueprintsController_getTaskBlueprint(t){return this.request("GET",`/api/v1/task-blueprints/${t.id}`,{signal:t?.signal})}async TaskBlueprintsController_updateTaskBlueprint(t){return this.request("PATCH",`/api/v1/task-blueprints/${t.id}`,{body:t.body,signal:t?.signal})}async TaskBlueprintsController_deleteTaskBlueprint(t){return this.request("DELETE",`/api/v1/task-blueprints/${t.id}`,{responseType:"void",signal:t?.signal})}async TaskBlueprintsController_createTaskFromBlueprint(t){return this.request("POST",`/api/v1/task-blueprints/${t.id}/create-task`,{signal:t?.signal})}}class D0 extends ht{constructor(t){super(t)}async ScheduledTasksController_createScheduledTask(t){return this.request("POST","/api/v1/scheduled-tasks",{body:t.body,signal:t?.signal})}async ScheduledTasksController_listScheduledTasks(t){return this.request("GET","/api/v1/scheduled-tasks",{params:{page:t?.page,limit:t?.limit,enabled:t?.enabled},signal:t?.signal})}async ScheduledTasksController_getScheduledTask(t){return this.request("GET",`/api/v1/scheduled-tasks/${t.id}`,{signal:t?.signal})}async ScheduledTasksController_updateScheduledTask(t){return this.request("PATCH",`/api/v1/scheduled-tasks/${t.id}`,{body:t.body,signal:t?.signal})}async ScheduledTasksController_deleteScheduledTask(t){return this.request("DELETE",`/api/v1/scheduled-tasks/${t.id}`,{responseType:"void",signal:t?.signal})}}class O0 extends ht{constructor(t){super(t)}async DiscoveryController_getIssuer(t){return this.request("GET","/.well-known/oauth-authorization-server/mcp/issuer",{signal:t?.signal})}async DiscoveryController_getAuthorizationServerMetadata(t){return this.request("GET",`/.well-known/oauth-authorization-server/mcp/${t.mcpServerId}/${t.version}`,{signal:t?.signal})}async DiscoveryController_all(t){return this.request("GET",`/.well-known/oauth-protected-resource/${t.path}`,{signal:t?.signal})}}class L0 extends ht{constructor(t){super(t)}async GlobalSearchController_search(t){return this.request("GET","/api/v1/search/query",{params:{query:t.query,limit:t.limit,threshold:t.threshold},signal:t?.signal})}}class M0 extends ht{constructor(t){super(t)}async WalkthroughController_acknowledge(t){return this.request("POST","/api/v1/walkthrough/acknowledge",{responseType:"void",signal:t?.signal})}async WalkthroughController_getStatus(t){return this.request("GET","/api/v1/walkthrough/status",{signal:t?.signal})}}class Ws{app;meta;metaProjects;authorizationServer;webAuthentication;authorizationJourneys;tools;jwks;actors;task;agentrun;threads;agent;agentTokens;agentExecutionTokens;context;chatProviders;secrets;executions;workers;taskBlueprints;scheduledTasks;discovery;search;walkthrough;constructor(t){this.app=new h0(t),this.meta=new f0(t),this.metaProjects=new p0(t),this.authorizationServer=new g0(t),this.webAuthentication=new m0(t),this.authorizationJourneys=new y0(t),this.tools=new x0(t),this.jwks=new v0(t),this.actors=new b0(t),this.task=new _0(t),this.agentrun=new S0(t),this.threads=new j0(t),this.agent=new k0(t),this.agentTokens=new T0(t),this.agentExecutionTokens=new w0(t),this.context=new E0(t),this.chatProviders=new C0(t),this.secrets=new N0(t),this.executions=new A0(t),this.workers=new R0(t),this.taskBlueprints=new z0(t),this.scheduledTasks=new D0(t),this.discovery=new O0(t),this.search=new L0(t),this.walkthrough=new M0(t)}}const q0=window.location.origin,I0=new Ws({baseUrl:q0,credentials:"include"}),_h=I0.walkthrough,B0=()=>{console.log("useHome mounting");const[n,t]=h.useState(null);return h.useEffect(()=>{console.log("useHome setting message"),t("Message coming from useHome")},[]),{message:n,setMessage:t}},Jx=h.createContext(null);function U0({children:n}){const{message:t}=B0(),[i,l]=h.useState(""),c=h.useMemo(()=>({message:t,sectionTitle:i,setSectionTitle:l}),[t,i,l]);return a.jsx(Jx.Provider,{value:c,children:n})}function js(){const n=h.useContext(Jx);if(!n)throw new Error("useHomeCtx must be used within <HomeProvider>");return n}const $0=window.location.origin,ev=new Ws({baseUrl:$0,credentials:"include"}),H0=ev.search;ev.search;function tv(){const[n,t]=h.useState(null),[i,l]=h.useState(!0),[c,u]=h.useState(null);return h.useEffect(()=>{_h.WalkthroughController_getStatus().then(f=>{const x=[{id:"worker",label:"Configure a worker",description:"A worker is a process that runs on your machine and executes agent tasks. Launch the Taico worker binary, then authenticate it with your account — it will appear here once connected.",href:"/settings/workers",completed:f.workerConfigured},{id:"agent",label:"Create an agent",description:"Agents are AI assistants that work on tasks. Create one by picking a runner (e.g. Claude Code, OpenCode), choosing a template, and selecting which tools it can use.",href:"/agents",completed:f.agentCreated},{id:"task",label:"Create a task",description:"Tasks are the core unit of work in Taico. Create your first task, write a clear description, and assign it to an agent to get it working.",href:"/tasks",completed:f.taskCreated},{id:"project-create",label:"Create a project",description:"Projects are created automatically when you add a tag in the format project:<name> to any task. Go to Tasks, open or create a task, and add a tag like project:my-app. Taico will create the project entry for you.",href:"/tasks",completed:f.projectCreated},{id:"project-configure",label:"Configure a project",description:"Link your project to a code repository. Go to Settings → Projects, find your project, and add a repository URL. Taico will automatically clone that repo for any task tagged with this project — no need to specify it per-task.",href:"/settings/projects",completed:f.projectConfigured},{id:"task-with-project",label:"Assign a task to an agent with a project",description:"Tag a task with a project tag and assign it to an agent. Taico will clone the linked repository and make it available in the agent's working directory automatically.",href:"/tasks",completed:f.taskWithProjectCreated},{id:"context",label:"Create a context block",description:"Context blocks are reusable pieces of text — instructions, reference docs, coding standards — that you can attach to tasks and threads. Agents will read them as part of their prompt.",href:"/context",completed:f.contextBlockCreated},{id:"thread",label:"Configure threads",description:"Threads coordinate parallel work when a task branches into sub-tasks. They are created automatically when a task spawns children. Explore the Threads section to see how work is organized.",href:"/settings/chat",completed:f.threadConfigured}],g=x.filter(m=>m.completed).length;t({steps:x,completedCount:g,totalCount:x.length,displayMode:f.onboardingDisplayMode})}).catch(f=>{console.error("Failed to fetch walkthrough status:",f),u(f instanceof Error?f.message:"Failed to load walkthrough")}).finally(()=>{l(!1)})},[]),{status:n,isLoading:i,error:c}}function P0(){const{user:n,refreshAuth:t}=us(),{status:i}=tv(),l=ze(),[c,u]=h.useState(!1),[f,x]=h.useState(!1);if(n?.onboardingDisplayMode!=="BANNER"||c)return null;const g=i?.completedCount??0,m=i?.totalCount??7,y=m-g,_=()=>l("/walkthrough"),v=k=>{k.stopPropagation(),u(!0)},j=async k=>{k.stopPropagation();try{x(!0),await es.webAuthControllerMarkWalkthroughSeen(),await t()}catch(E){console.error("Failed to hide walkthrough:",E),x(!1)}};return a.jsx("div",{className:"home-walkthrough-wrap",children:a.jsxs("div",{className:"home-walkthrough-card",onClick:_,role:"button",tabIndex:0,onKeyDown:k=>k.key==="Enter"&&_(),children:[a.jsx("div",{className:"home-walkthrough-dots","aria-hidden":"true",children:Array.from({length:m}).map((k,E)=>a.jsx("span",{className:`home-walkthrough-dot${E<g?" home-walkthrough-dot--done":""}`},E))}),a.jsxs("div",{className:"home-walkthrough-body",children:[a.jsx(b,{size:"2",weight:"semibold",children:y===0?"Setup complete!":`${y} step${y===1?"":"s"} to go`}),a.jsxs(b,{size:"1",tone:"muted",children:[g," of ",m," setup steps completed · Click to continue"]})]}),a.jsxs("div",{className:"home-walkthrough-actions",children:[a.jsx("button",{className:"home-walkthrough-not-now",onClick:v,children:"Not now"}),a.jsx("button",{className:"home-walkthrough-all-set",onClick:j,disabled:f,children:f?"…":"I'm all set"})]})]})})}function G0(){const n=ze(),{setSectionTitle:t}=js(),[i,l]=h.useState(""),[c,u]=h.useState([]),[f,x]=h.useState(!1),[g,m]=h.useState(-1),y=h.useRef(null),_=h.useRef([]);jt(),h.useEffect(()=>{t(""),y.current?.focus()},[t]);const v=h.useCallback(async T=>{if(!T.trim()){u([]),m(-1);return}x(!0);try{const R=await H0.GlobalSearchController_search({query:T,limit:20});u(R),m(-1),_.current=[]}catch(R){console.error("Search failed:",R),u([])}finally{x(!1)}},[]);h.useEffect(()=>{const T=setTimeout(()=>{v(i)},300);return()=>clearTimeout(T)},[i,v]);const j=T=>{T.key==="ArrowDown"?(T.preventDefault(),m(R=>{const z=R<c.length-1?R+1:R;return setTimeout(()=>{_.current[z]?.scrollIntoView({behavior:"smooth",block:"nearest"})},0),z})):T.key==="ArrowUp"?(T.preventDefault(),m(R=>{const z=R>0?R-1:0;return setTimeout(()=>{_.current[z]?.scrollIntoView({behavior:"smooth",block:"nearest"})},0),z})):T.key==="Enter"&&g>=0&&c[g]&&(T.preventDefault(),n(c[g].url))},k=T=>{n(T)},E=T=>{switch(T){case"task":return"blue";case"context_block":return"purple";case"agent":return"green";case"project":return"orange";case"tag":return"yellow";case"tool":return"red";default:return"gray"}},w=T=>{switch(T){case"task":return"Task";case"context_block":return"Context";case"agent":return"Agent";case"project":return"Project";case"tag":return"Tag";case"tool":return"Tool";default:return T}};return a.jsxs("div",{className:"home-page",children:[a.jsx(P0,{}),a.jsx("div",{className:"home-page-search",children:a.jsx("div",{className:"home-search-container",children:a.jsxs(te,{spacing:"6",align:"center",children:[a.jsxs(te,{spacing:"3",align:"center",children:[a.jsx(b,{size:"6",weight:"bold",className:"home-search-title",children:"Find anything"}),a.jsx(b,{size:"3",tone:"muted",className:"home-search-subtitle",children:"Search across tasks, context, agents, tools, and more"})]}),a.jsx("div",{className:"home-search-box",children:a.jsx("input",{ref:y,type:"text",className:"home-search-input",placeholder:"Search...",value:i,onChange:T=>l(T.target.value),onKeyDown:j,autoFocus:!0})}),i&&a.jsx(Fe,{className:"home-search-results",children:a.jsxs(te,{spacing:"2",children:[f&&a.jsx(b,{tone:"muted",size:"2",children:"Searching..."}),!f&&c.length===0&&a.jsx(b,{tone:"muted",size:"2",children:"No results found"}),!f&&c.length>0&&a.jsxs(a.Fragment,{children:[a.jsxs(b,{size:"1",tone:"muted",children:[c.length," ",c.length===1?"result":"results"]}),a.jsx("div",{className:"home-search-results-list",children:c.map((T,R)=>a.jsx("div",{ref:z=>{_.current[R]=z},children:a.jsxs(Lk,{interactive:!0,onClick:()=>k(T.url),className:`home-search-result-row ${R===g?"home-search-result-row--selected":""}`,children:[a.jsx("div",{className:"home-search-result-main",children:a.jsx(b,{weight:"medium",size:"3",children:T.title})}),a.jsxs("div",{className:"home-search-result-meta",children:[a.jsx(_s,{color:E(T.type),children:w(T.type)}),a.jsxs(b,{size:"1",tone:"muted",children:[Math.round(T.score*100),"% match"]})]})]})},T.id))})]})]})}),a.jsxs(Mt,{spacing:"2",className:"home-quick-links",children:[a.jsx(ue,{variant:"ghost",size:"sm",onClick:()=>n("/tasks"),children:"Tasks"}),a.jsx(ue,{variant:"ghost",size:"sm",onClick:()=>n("/threads"),children:"Threads"}),a.jsx(ue,{variant:"ghost",size:"sm",onClick:()=>n("/agents"),children:"Agents"}),a.jsx(ue,{variant:"ghost",size:"sm",onClick:()=>n("/context"),children:"Context"})]})]})})})]})}function Br({sectionTitle:n,titleAccessory:t,headerActions:i,children:l}){return a.jsxs("div",{className:"desktop-shell",children:[n&&a.jsxs("div",{className:"desktop-shell__header",children:[a.jsxs("div",{className:"desktop-shell__title-row",children:[a.jsx("h1",{className:"desktop-shell__title",children:n}),t?a.jsx("div",{className:"desktop-shell__title-accessory",children:t}):null]}),i?a.jsx("div",{className:"desktop-shell__actions",children:i}):null]}),a.jsx("div",{className:"desktop-shell__content",children:l})]})}function V0({navItems:n,activePath:t,onActiveItemClick:i}){return console.log("Rendering BottomNavContent with navItems:",n),n.length===0?a.jsx(a.Fragment,{}):a.jsx(Mt,{spacing:"1",justify:"space-between",children:n.map(l=>{const c=t===l.path;return a.jsxs(Mn,{to:l.path,className:`ios-shell__bottom-nav__item ${c?"ios-shell__bottom-nav__item--active":""}`,onClick:()=>{c&&i()},children:[a.jsx(al,{icon:l.icon,className:"ios-shell__bottom-nav__icon"}),a.jsx(b,{size:"1",className:"ios-shell__bottom-nav-label",children:l.label})]},l.label)})})}function $a(n){const t=qt();console.log("Mounting iOS shell");const[i,l]=h.useState(!1),c=()=>{l(!1)},[u,f]=h.useState(!0),[x,g]=h.useState(!0),[m,y]=h.useState(!0),_=h.useRef(null),v=U=>{_.current=U,I(),A(),Q()},j=h.useRef(null),k=U=>{j.current=U,I()},E=h.useRef(null),w=h.useRef(null),T=U=>{w.current=U,A()},R=h.useRef(null),z=h.useRef(null),L=U=>{z.current=U,Q()},M=h.useRef(null),N=(U,le,W)=>{const oe=le.current,me=_.current;!oe||!me||(U.current?.disconnect(),U.current=new IntersectionObserver(([B])=>{W(B.isIntersecting)},{root:me,threshold:[0,1]}),U.current.observe(oe))},A=()=>{N(R,w,U=>{console.log(`title visibility detector: ${U}`),f(U)})},I=()=>{N(E,j,U=>{console.log(`content behind header detector: ${U}`),g(!U)})},Q=()=>{N(M,z,U=>{console.log(`bottom detector: ${U}`),y(!U)})},Z=()=>{_.current?.scrollTo({top:0,behavior:"smooth"})};return h.useEffect(()=>()=>{R.current?.disconnect(),E.current?.disconnect(),M.current?.disconnect()},[]),a.jsxs("div",{className:"ios-shell",children:[a.jsxs("aside",{className:`ios-shell__drawer ${i?"ios-shell__drawer--open":""}`,children:[a.jsxs("div",{className:"ios-shell__drawer-header",children:[a.jsx(b,{size:"4",weight:"bold",children:"taico"}),a.jsx("button",{className:"ios-shell__drawer-close",onClick:c,"aria-label":"Close menu",children:"✕"})]}),a.jsx("nav",{className:"ios-shell__drawer-nav",children:zr.map(U=>{const le=t.pathname===U.path||t.pathname.startsWith(U.path+"/");return a.jsxs(Mn,{to:U.path,className:`ios-shell__drawer-item ${le?"ios-shell__drawer-item--active":""}`,onClick:c,children:[a.jsx(al,{icon:U.icon,className:"ios-shell__drawer-icon"}),a.jsx("span",{className:"ios-shell__drawer-label",children:U.label})]},U.path)})})]}),a.jsx("header",{className:`ios-shell__header ${x?"elevated":""}`,children:a.jsxs(Mt,{spacing:"5",align:"center",children:[a.jsx("button",{className:"ios-shell__hamburger",onClick:()=>l(!0),"aria-label":"Open menu",children:"☰"}),a.jsx(b,{size:"3",weight:"normal",as:"div",children:n.appTitle}),a.jsx("div",{className:`ios-shell__header__section-title ${u?"is-hidden":"is-visible"}`,children:n.sectionTitle})]})}),a.jsxs("main",{ref:v,className:"ios-shell__main",children:[a.jsx("div",{className:"ios-shell__main__top-padding"}),a.jsx("div",{ref:k,className:"ios-shell__main__section-title-top-sentinel"}),a.jsx("div",{className:`ios-shell__main__section-title ${u?"is-visible":"is-hidden"}`,children:n.sectionTitle}),n.topActions?a.jsx("div",{className:"ios-shell__main__top-actions",children:n.topActions}):null,a.jsx("div",{ref:T,className:"ios-shell__main__section-title-bottom-sentinel"}),a.jsx("div",{className:"ios-shell__main__top-sentinel"}),n.children,a.jsx("div",{ref:L,className:"ios-shell__main__bottom-sentinel"}),a.jsx("div",{className:"ios-shell__main__bottom-padding"})]}),a.jsx("nav",{className:`ios-shell__bottom-nav ${m?"elevated":""}`,children:a.jsx(V0,{navItems:n.navItems,activePath:t.pathname,onActiveItemClick:Z})})]})}const F0=[{path:"/home",label:"Home",icon:vh},{path:"/tasks",label:"Tasks",icon:Qx},{path:"/context",label:"Context",icon:bh},{path:"/agents",label:"Agents",icon:Wx},{path:"/settings",label:"Settings",icon:Zx}];function Y0(){const n=Rt(),{sectionTitle:t}=js();return a.jsx(a.Fragment,{children:n?a.jsx(Br,{sectionTitle:t,children:a.jsx(Kt,{})}):a.jsx($a,{appTitle:"Home",sectionTitle:t,navItems:F0,children:a.jsx(Kt,{})})})}const sv=h.createContext(null);function rl(){const n=h.useContext(sv);if(!n)throw new Error("useCommandPalette must be used within a CommandPaletteProvider");return n}function Q0({children:n}){const t=ze(),[i,l]=h.useState(new Map),[c,u]=h.useState(new Map),f=h.useRef(0),x=h.useMemo(()=>[{id:"nav-home",label:"Home",description:"Go to homepage",aliases:["home","search"],onSelect:()=>t("/home")},{id:"nav-tasks",label:"Tasks",description:"Go to tasks",aliases:["task"],onSelect:()=>t("/tasks")},{id:"nav-context",label:"Context",description:"Go to context blocks",aliases:["blocks","block"],onSelect:()=>t("/context")},{id:"nav-agents",label:"Agents",description:"Go to agents",aliases:["agent"],onSelect:()=>t("/agents")},{id:"nav-threads",label:"Threads",description:"Go to threads",aliases:["thread"],onSelect:()=>t("/threads")},{id:"nav-tools",label:"Tools",description:"Go to tools",aliases:["mcp","tool"],onSelect:()=>t("/tools")},{id:"nav-runs",label:"Runs",description:"Go to runs",aliases:["executions","execution","work queue"],onSelect:()=>t("/runs")},{id:"nav-schedule",label:"Schedule",description:"Go to schedule",aliases:["cron","schedules"],onSelect:()=>t("/tasks/schedule")},{id:"nav-settings",label:"Settings",description:"Go to settings",aliases:["setting","config"],onSelect:()=>t("/settings")}],[t]),g=h.useCallback(j=>{const k=String(++f.current);return l(E=>{const w=new Map(E);return w.set(k,j),w}),()=>{l(E=>{const w=new Map(E);return w.delete(k),w})}},[]),m=h.useCallback(j=>{const k=String(++f.current);return u(E=>{const w=new Map(E);return w.set(k,j),w}),()=>{u(E=>{const w=new Map(E);return w.delete(k),w})}},[]),y=h.useMemo(()=>[...Array.from(i.values()).flat(),...x],[x,i]),_=h.useMemo(()=>{const j=Array.from(c.values());return j[j.length-1]},[c]),v=h.useMemo(()=>({commands:y,registerCommands:g,searchTasks:_,registerTaskSearch:m}),[y,g,_,m]);return a.jsxs(sv.Provider,{value:v,children:[n,a.jsx(K0,{})]})}function K0(){const{commands:n,searchTasks:t}=rl(),i=ze(),[l,c]=h.useState(!1),[u,f]=h.useState(""),[x,g]=h.useState(0),[m,y]=h.useState(!1),[_,v]=h.useState([]),[j,k]=h.useState(!1),E=h.useRef(null),w=h.useRef(null),T=h.useRef(null),R=h.useRef(0);function z(U,le){const W=U.label.toLowerCase(),oe=U.description?.toLowerCase()||"",me=W.indexOf(le);if(me!==-1)return W===le?1e3:me===0?500:300;if(U.aliases)for(const B of U.aliases){const se=B.toLowerCase(),ge=se.indexOf(le);if(ge!==-1)return se===le?800:ge===0?400:200}return oe.includes(le)?100:0}const L=u.toLowerCase().trim(),N=[...n.map(U=>({command:U,score:L?z(U,L):0})).filter(U=>U.score>0).sort((U,le)=>le.score!==U.score?le.score-U.score:0).map(U=>U.command).map(U=>({type:"command",command:U})),..._.map(U=>({type:"task",task:U}))];function A(U){if(!L)return U;const le=U.toLowerCase().indexOf(L);return le===-1?U:a.jsxs(a.Fragment,{children:[U.slice(0,le),a.jsx("mark",{children:U.slice(le,le+L.length)}),U.slice(le+L.length)]})}h.useEffect(()=>{if(T.current&&clearTimeout(T.current),!t){R.current+=1,v([]),k(!1);return}if(!L){R.current+=1,v([]),k(!1);return}R.current+=1;const U=R.current;return T.current=window.setTimeout(async()=>{k(!0);try{const le=await t(L);R.current===U&&v(le)}catch(le){console.error("Failed to search tasks:",le),R.current===U&&v([])}finally{R.current===U&&k(!1)}},200),()=>{T.current&&clearTimeout(T.current)}},[L,t]),h.useEffect(()=>{g(0)},[u]),h.useEffect(()=>{const U=le=>{(le.metaKey||le.ctrlKey)&&le.key==="/"&&(le.preventDefault(),c(!0))};return document.addEventListener("keydown",U),()=>document.removeEventListener("keydown",U)},[]),h.useEffect(()=>{l&&E.current&&E.current.focus()},[l]),h.useEffect(()=>{const U=le=>{w.current&&!w.current.contains(le.target)&&l&&I()};if(l)return document.addEventListener("mousedown",U),()=>document.removeEventListener("mousedown",U)},[l]);function I(){c(!1),f(""),g(0),v([]),k(!1),T.current&&clearTimeout(T.current),R.current+=1}function Q(U){U.type==="command"?U.command.onSelect():i(`/tasks/task/${U.task.id}`),I()}function Z(U){if(U.key==="Escape"){U.preventDefault(),I();return}if(U.key==="ArrowDown"){U.preventDefault(),g(le=>le<N.length-1?le+1:le);return}if(U.key==="ArrowUp"){U.preventDefault(),g(le=>le>0?le-1:0);return}if(U.key==="Enter"){if(U.preventDefault(),N.length===0){y(!0),setTimeout(()=>y(!1),500);return}const le=N[x];le&&Q(le);return}}return l?a.jsx("div",{className:"command-palette-backdrop",children:a.jsxs("div",{className:`command-palette-container ${m?"command-palette-container--shake":""}`,ref:w,children:[a.jsx("input",{ref:E,type:"text",className:"command-palette-input",placeholder:"Type a command...",value:u,onChange:U=>f(U.target.value),onKeyDown:Z,autoComplete:"off",spellCheck:!1}),N.length>0&&a.jsx("div",{className:"command-palette-results",children:N.map((U,le)=>{if(U.type==="command"){const W=U.command;return a.jsxs("div",{className:`command-palette-item ${le===x?"command-palette-item--selected":""}`,onClick:()=>Q(U),onMouseEnter:()=>g(le),children:[a.jsx("span",{className:"command-palette-item-label",children:A(W.label)}),W.description&&a.jsx("span",{className:"command-palette-item-description",children:W.description})]},`cmd-${W.id}`)}else{const W=U.task;return a.jsxs("div",{className:`command-palette-item command-palette-item--task ${le===x?"command-palette-item--selected":""}`,onClick:()=>Q(U),onMouseEnter:()=>g(le),children:[a.jsx("span",{className:"command-palette-item-label",children:A(W.name)}),a.jsx("span",{className:"command-palette-item-description",children:"Task"})]},`task-${W.id}`)}})}),u&&N.length===0&&!j&&a.jsx("div",{className:"command-palette-no-results",children:"No results found"}),j&&a.jsx("div",{className:"command-palette-searching",children:"Searching tasks..."})]})}):null}function Ur({onDelete:n,deleteLabel:t="Delete",confirmLabel:i="Confirm Delete",cancelLabel:l="Cancel",className:c,size:u="lg"}){const[f,x]=h.useState(!1),g=async()=>{await n(),x(!1)};return a.jsx(ye,{className:c,children:f?a.jsxs(a.Fragment,{children:[a.jsx(ue,{size:u,variant:"secondary",onClick:()=>x(!1),children:l}),a.jsx(ue,{size:u,variant:"danger",onClick:g,children:i})]}):a.jsx(ue,{size:u,variant:"danger",onClick:()=>x(!0),children:t})})}const nv=h.createContext(void 0);function ds(){const n=h.useContext(nv);if(!n)throw new Error("useToast must be used within ToastProvider");return n}function X0(n){if(n&&typeof n=="object"){const t=n;if(t.body?.detail)return t.body.detail;if(t.detail)return t.detail;if(t.message)return t.message}return typeof n=="string"?n:"An unexpected error occurred"}function Z0({children:n}){const[t,i]=h.useState([]),l=h.useCallback((f,x="info",g=5e3)=>{const m=crypto.randomUUID(),y={id:m,message:f,type:x,duration:g};i(_=>[..._,y]),g>0&&setTimeout(()=>{u(m)},g)},[]),c=h.useCallback(f=>{const x=X0(f);l(x,"error",6e3)},[l]),u=h.useCallback(f=>{i(x=>x.filter(g=>g.id!==f))},[]);return a.jsx(nv.Provider,{value:{toasts:t,showToast:l,showError:c,dismissToast:u},children:n})}function W0(){const{toasts:n,dismissToast:t}=ds();return n.length===0?null:a.jsx("div",{className:"toast-container",children:n.map(i=>a.jsxs("div",{className:`toast toast--${i.type}`,role:"alert","aria-live":"assertive",children:[a.jsx("div",{className:"toast__content",children:a.jsx(b,{size:"2",className:"toast__message",children:i.message})}),a.jsx("button",{className:"toast__close",onClick:()=>t(i.id),"aria-label":"Dismiss notification",children:"×"})]},i.id))})}Me.BASE=Ba;const un=Object.create(null);un.open="0";un.close="1";un.ping="2";un.pong="3";un.message="4";un.upgrade="5";un.noop="6";const Bo=Object.create(null);Object.keys(un).forEach(n=>{Bo[un[n]]=n});const Qd={type:"error",data:"parser error"},av=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",rv=typeof ArrayBuffer=="function",iv=n=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(n):n&&n.buffer instanceof ArrayBuffer,Sh=({type:n,data:t},i,l)=>av&&t instanceof Blob?i?l(t):Oy(t,l):rv&&(t instanceof ArrayBuffer||iv(t))?i?l(t):Oy(new Blob([t]),l):l(un[n]+(t||"")),Oy=(n,t)=>{const i=new FileReader;return i.onload=function(){const l=i.result.split(",")[1];t("b"+(l||""))},i.readAsDataURL(n)};function Ly(n){return n instanceof Uint8Array?n:n instanceof ArrayBuffer?new Uint8Array(n):new Uint8Array(n.buffer,n.byteOffset,n.byteLength)}let Cd;function J0(n,t){if(av&&n.data instanceof Blob)return n.data.arrayBuffer().then(Ly).then(t);if(rv&&(n.data instanceof ArrayBuffer||iv(n.data)))return t(Ly(n.data));Sh(n,!1,i=>{Cd||(Cd=new TextEncoder),t(Cd.encode(i))})}const My="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Fi=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let n=0;n<My.length;n++)Fi[My.charCodeAt(n)]=n;const ew=n=>{let t=n.length*.75,i=n.length,l,c=0,u,f,x,g;n[n.length-1]==="="&&(t--,n[n.length-2]==="="&&t--);const m=new ArrayBuffer(t),y=new Uint8Array(m);for(l=0;l<i;l+=4)u=Fi[n.charCodeAt(l)],f=Fi[n.charCodeAt(l+1)],x=Fi[n.charCodeAt(l+2)],g=Fi[n.charCodeAt(l+3)],y[c++]=u<<2|f>>4,y[c++]=(f&15)<<4|x>>2,y[c++]=(x&3)<<6|g&63;return m},tw=typeof ArrayBuffer=="function",jh=(n,t)=>{if(typeof n!="string")return{type:"message",data:lv(n,t)};const i=n.charAt(0);return i==="b"?{type:"message",data:sw(n.substring(1),t)}:Bo[i]?n.length>1?{type:Bo[i],data:n.substring(1)}:{type:Bo[i]}:Qd},sw=(n,t)=>{if(tw){const i=ew(n);return lv(i,t)}else return{base64:!0,data:n}},lv=(n,t)=>{switch(t){case"blob":return n instanceof Blob?n:new Blob([n]);case"arraybuffer":default:return n instanceof ArrayBuffer?n:n.buffer}},ov="",nw=(n,t)=>{const i=n.length,l=new Array(i);let c=0;n.forEach((u,f)=>{Sh(u,!1,x=>{l[f]=x,++c===i&&t(l.join(ov))})})},aw=(n,t)=>{const i=n.split(ov),l=[];for(let c=0;c<i.length;c++){const u=jh(i[c],t);if(l.push(u),u.type==="error")break}return l};function rw(){return new TransformStream({transform(n,t){J0(n,i=>{const l=i.length;let c;if(l<126)c=new Uint8Array(1),new DataView(c.buffer).setUint8(0,l);else if(l<65536){c=new Uint8Array(3);const u=new DataView(c.buffer);u.setUint8(0,126),u.setUint16(1,l)}else{c=new Uint8Array(9);const u=new DataView(c.buffer);u.setUint8(0,127),u.setBigUint64(1,BigInt(l))}n.data&&typeof n.data!="string"&&(c[0]|=128),t.enqueue(c),t.enqueue(i)})}})}let Nd;function wo(n){return n.reduce((t,i)=>t+i.length,0)}function Eo(n,t){if(n[0].length===t)return n.shift();const i=new Uint8Array(t);let l=0;for(let c=0;c<t;c++)i[c]=n[0][l++],l===n[0].length&&(n.shift(),l=0);return n.length&&l<n[0].length&&(n[0]=n[0].slice(l)),i}function iw(n,t){Nd||(Nd=new TextDecoder);const i=[];let l=0,c=-1,u=!1;return new TransformStream({transform(f,x){for(i.push(f);;){if(l===0){if(wo(i)<1)break;const g=Eo(i,1);u=(g[0]&128)===128,c=g[0]&127,c<126?l=3:c===126?l=1:l=2}else if(l===1){if(wo(i)<2)break;const g=Eo(i,2);c=new DataView(g.buffer,g.byteOffset,g.length).getUint16(0),l=3}else if(l===2){if(wo(i)<8)break;const g=Eo(i,8),m=new DataView(g.buffer,g.byteOffset,g.length),y=m.getUint32(0);if(y>Math.pow(2,21)-1){x.enqueue(Qd);break}c=y*Math.pow(2,32)+m.getUint32(4),l=3}else{if(wo(i)<c)break;const g=Eo(i,c);x.enqueue(jh(u?g:Nd.decode(g),t)),l=0}if(c===0||c>n){x.enqueue(Qd);break}}}})}const cv=4;function At(n){if(n)return lw(n)}function lw(n){for(var t in At.prototype)n[t]=At.prototype[t];return n}At.prototype.on=At.prototype.addEventListener=function(n,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+n]=this._callbacks["$"+n]||[]).push(t),this};At.prototype.once=function(n,t){function i(){this.off(n,i),t.apply(this,arguments)}return i.fn=t,this.on(n,i),this};At.prototype.off=At.prototype.removeListener=At.prototype.removeAllListeners=At.prototype.removeEventListener=function(n,t){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var i=this._callbacks["$"+n];if(!i)return this;if(arguments.length==1)return delete this._callbacks["$"+n],this;for(var l,c=0;c<i.length;c++)if(l=i[c],l===t||l.fn===t){i.splice(c,1);break}return i.length===0&&delete this._callbacks["$"+n],this};At.prototype.emit=function(n){this._callbacks=this._callbacks||{};for(var t=new Array(arguments.length-1),i=this._callbacks["$"+n],l=1;l<arguments.length;l++)t[l-1]=arguments[l];if(i){i=i.slice(0);for(var l=0,c=i.length;l<c;++l)i[l].apply(this,t)}return this};At.prototype.emitReserved=At.prototype.emit;At.prototype.listeners=function(n){return this._callbacks=this._callbacks||{},this._callbacks["$"+n]||[]};At.prototype.hasListeners=function(n){return!!this.listeners(n).length};const ec=typeof Promise=="function"&&typeof Promise.resolve=="function"?t=>Promise.resolve().then(t):(t,i)=>i(t,0),Ms=typeof self<"u"?self:typeof window<"u"?window:Function("return this")(),ow="arraybuffer";function uv(n,...t){return t.reduce((i,l)=>(n.hasOwnProperty(l)&&(i[l]=n[l]),i),{})}const cw=Ms.setTimeout,uw=Ms.clearTimeout;function tc(n,t){t.useNativeTimers?(n.setTimeoutFn=cw.bind(Ms),n.clearTimeoutFn=uw.bind(Ms)):(n.setTimeoutFn=Ms.setTimeout.bind(Ms),n.clearTimeoutFn=Ms.clearTimeout.bind(Ms))}const dw=1.33;function hw(n){return typeof n=="string"?fw(n):Math.ceil((n.byteLength||n.size)*dw)}function fw(n){let t=0,i=0;for(let l=0,c=n.length;l<c;l++)t=n.charCodeAt(l),t<128?i+=1:t<2048?i+=2:t<55296||t>=57344?i+=3:(l++,i+=4);return i}function dv(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function pw(n){let t="";for(let i in n)n.hasOwnProperty(i)&&(t.length&&(t+="&"),t+=encodeURIComponent(i)+"="+encodeURIComponent(n[i]));return t}function gw(n){let t={},i=n.split("&");for(let l=0,c=i.length;l<c;l++){let u=i[l].split("=");t[decodeURIComponent(u[0])]=decodeURIComponent(u[1])}return t}class mw extends Error{constructor(t,i,l){super(t),this.description=i,this.context=l,this.type="TransportError"}}class kh extends At{constructor(t){super(),this.writable=!1,tc(this,t),this.opts=t,this.query=t.query,this.socket=t.socket,this.supportsBinary=!t.forceBase64}onError(t,i,l){return super.emitReserved("error",new mw(t,i,l)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return(this.readyState==="opening"||this.readyState==="open")&&(this.doClose(),this.onClose()),this}send(t){this.readyState==="open"&&this.write(t)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(t){const i=jh(t,this.socket.binaryType);this.onPacket(i)}onPacket(t){super.emitReserved("packet",t)}onClose(t){this.readyState="closed",super.emitReserved("close",t)}pause(t){}createUri(t,i={}){return t+"://"+this._hostname()+this._port()+this.opts.path+this._query(i)}_hostname(){const t=this.opts.hostname;return t.indexOf(":")===-1?t:"["+t+"]"}_port(){return this.opts.port&&(this.opts.secure&&Number(this.opts.port)!==443||!this.opts.secure&&Number(this.opts.port)!==80)?":"+this.opts.port:""}_query(t){const i=pw(t);return i.length?"?"+i:""}}class yw extends kh{constructor(){super(...arguments),this._polling=!1}get name(){return"polling"}doOpen(){this._poll()}pause(t){this.readyState="pausing";const i=()=>{this.readyState="paused",t()};if(this._polling||!this.writable){let l=0;this._polling&&(l++,this.once("pollComplete",function(){--l||i()})),this.writable||(l++,this.once("drain",function(){--l||i()}))}else i()}_poll(){this._polling=!0,this.doPoll(),this.emitReserved("poll")}onData(t){const i=l=>{if(this.readyState==="opening"&&l.type==="open"&&this.onOpen(),l.type==="close")return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(l)};aw(t,this.socket.binaryType).forEach(i),this.readyState!=="closed"&&(this._polling=!1,this.emitReserved("pollComplete"),this.readyState==="open"&&this._poll())}doClose(){const t=()=>{this.write([{type:"close"}])};this.readyState==="open"?t():this.once("open",t)}write(t){this.writable=!1,nw(t,i=>{this.doWrite(i,()=>{this.writable=!0,this.emitReserved("drain")})})}uri(){const t=this.opts.secure?"https":"http",i=this.query||{};return this.opts.timestampRequests!==!1&&(i[this.opts.timestampParam]=dv()),!this.supportsBinary&&!i.sid&&(i.b64=1),this.createUri(t,i)}}let hv=!1;try{hv=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}const xw=hv;function vw(){}class bw extends yw{constructor(t){if(super(t),typeof location<"u"){const i=location.protocol==="https:";let l=location.port;l||(l=i?"443":"80"),this.xd=typeof location<"u"&&t.hostname!==location.hostname||l!==t.port}}doWrite(t,i){const l=this.request({method:"POST",data:t});l.on("success",i),l.on("error",(c,u)=>{this.onError("xhr post error",c,u)})}doPoll(){const t=this.request();t.on("data",this.onData.bind(this)),t.on("error",(i,l)=>{this.onError("xhr poll error",i,l)}),this.pollXhr=t}}class cn extends At{constructor(t,i,l){super(),this.createRequest=t,tc(this,l),this._opts=l,this._method=l.method||"GET",this._uri=i,this._data=l.data!==void 0?l.data:null,this._create()}_create(){var t;const i=uv(this._opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");i.xdomain=!!this._opts.xd;const l=this._xhr=this.createRequest(i);try{l.open(this._method,this._uri,!0);try{if(this._opts.extraHeaders){l.setDisableHeaderCheck&&l.setDisableHeaderCheck(!0);for(let c in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(c)&&l.setRequestHeader(c,this._opts.extraHeaders[c])}}catch{}if(this._method==="POST")try{l.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch{}try{l.setRequestHeader("Accept","*/*")}catch{}(t=this._opts.cookieJar)===null||t===void 0||t.addCookies(l),"withCredentials"in l&&(l.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(l.timeout=this._opts.requestTimeout),l.onreadystatechange=()=>{var c;l.readyState===3&&((c=this._opts.cookieJar)===null||c===void 0||c.parseCookies(l.getResponseHeader("set-cookie"))),l.readyState===4&&(l.status===200||l.status===1223?this._onLoad():this.setTimeoutFn(()=>{this._onError(typeof l.status=="number"?l.status:0)},0))},l.send(this._data)}catch(c){this.setTimeoutFn(()=>{this._onError(c)},0);return}typeof document<"u"&&(this._index=cn.requestsCount++,cn.requests[this._index]=this)}_onError(t){this.emitReserved("error",t,this._xhr),this._cleanup(!0)}_cleanup(t){if(!(typeof this._xhr>"u"||this._xhr===null)){if(this._xhr.onreadystatechange=vw,t)try{this._xhr.abort()}catch{}typeof document<"u"&&delete cn.requests[this._index],this._xhr=null}}_onLoad(){const t=this._xhr.responseText;t!==null&&(this.emitReserved("data",t),this.emitReserved("success"),this._cleanup())}abort(){this._cleanup()}}cn.requestsCount=0;cn.requests={};if(typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",qy);else if(typeof addEventListener=="function"){const n="onpagehide"in Ms?"pagehide":"unload";addEventListener(n,qy,!1)}}function qy(){for(let n in cn.requests)cn.requests.hasOwnProperty(n)&&cn.requests[n].abort()}const _w=(function(){const n=fv({xdomain:!1});return n&&n.responseType!==null})();class Sw extends bw{constructor(t){super(t);const i=t&&t.forceBase64;this.supportsBinary=_w&&!i}request(t={}){return Object.assign(t,{xd:this.xd},this.opts),new cn(fv,this.uri(),t)}}function fv(n){const t=n.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!t||xw))return new XMLHttpRequest}catch{}if(!t)try{return new Ms[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}const pv=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative";class jw extends kh{get name(){return"websocket"}doOpen(){const t=this.uri(),i=this.opts.protocols,l=pv?{}:uv(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(l.headers=this.opts.extraHeaders);try{this.ws=this.createSocket(t,i,l)}catch(c){return this.emitReserved("error",c)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=t=>this.onClose({description:"websocket connection closed",context:t}),this.ws.onmessage=t=>this.onData(t.data),this.ws.onerror=t=>this.onError("websocket error",t)}write(t){this.writable=!1;for(let i=0;i<t.length;i++){const l=t[i],c=i===t.length-1;Sh(l,this.supportsBinary,u=>{try{this.doWrite(l,u)}catch{}c&&ec(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){typeof this.ws<"u"&&(this.ws.onerror=()=>{},this.ws.close(),this.ws=null)}uri(){const t=this.opts.secure?"wss":"ws",i=this.query||{};return this.opts.timestampRequests&&(i[this.opts.timestampParam]=dv()),this.supportsBinary||(i.b64=1),this.createUri(t,i)}}const Ad=Ms.WebSocket||Ms.MozWebSocket;class kw extends jw{createSocket(t,i,l){return pv?new Ad(t,i,l):i?new Ad(t,i):new Ad(t)}doWrite(t,i){this.ws.send(i)}}class Tw extends kh{get name(){return"webtransport"}doOpen(){try{this._transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name])}catch(t){return this.emitReserved("error",t)}this._transport.closed.then(()=>{this.onClose()}).catch(t=>{this.onError("webtransport error",t)}),this._transport.ready.then(()=>{this._transport.createBidirectionalStream().then(t=>{const i=iw(Number.MAX_SAFE_INTEGER,this.socket.binaryType),l=t.readable.pipeThrough(i).getReader(),c=rw();c.readable.pipeTo(t.writable),this._writer=c.writable.getWriter();const u=()=>{l.read().then(({done:x,value:g})=>{x||(this.onPacket(g),u())}).catch(x=>{})};u();const f={type:"open"};this.query.sid&&(f.data=`{"sid":"${this.query.sid}"}`),this._writer.write(f).then(()=>this.onOpen())})})}write(t){this.writable=!1;for(let i=0;i<t.length;i++){const l=t[i],c=i===t.length-1;this._writer.write(l).then(()=>{c&&ec(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var t;(t=this._transport)===null||t===void 0||t.close()}}const ww={websocket:kw,webtransport:Tw,polling:Sw},Ew=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,Cw=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function Kd(n){if(n.length>8e3)throw"URI too long";const t=n,i=n.indexOf("["),l=n.indexOf("]");i!=-1&&l!=-1&&(n=n.substring(0,i)+n.substring(i,l).replace(/:/g,";")+n.substring(l,n.length));let c=Ew.exec(n||""),u={},f=14;for(;f--;)u[Cw[f]]=c[f]||"";return i!=-1&&l!=-1&&(u.source=t,u.host=u.host.substring(1,u.host.length-1).replace(/;/g,":"),u.authority=u.authority.replace("[","").replace("]","").replace(/;/g,":"),u.ipv6uri=!0),u.pathNames=Nw(u,u.path),u.queryKey=Aw(u,u.query),u}function Nw(n,t){const i=/\/{2,9}/g,l=t.replace(i,"/").split("/");return(t.slice(0,1)=="/"||t.length===0)&&l.splice(0,1),t.slice(-1)=="/"&&l.splice(l.length-1,1),l}function Aw(n,t){const i={};return t.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(l,c,u){c&&(i[c]=u)}),i}const Xd=typeof addEventListener=="function"&&typeof removeEventListener=="function",Uo=[];Xd&&addEventListener("offline",()=>{Uo.forEach(n=>n())},!1);class fa extends At{constructor(t,i){if(super(),this.binaryType=ow,this.writeBuffer=[],this._prevBufferLen=0,this._pingInterval=-1,this._pingTimeout=-1,this._maxPayload=-1,this._pingTimeoutTime=1/0,t&&typeof t=="object"&&(i=t,t=null),t){const l=Kd(t);i.hostname=l.host,i.secure=l.protocol==="https"||l.protocol==="wss",i.port=l.port,l.query&&(i.query=l.query)}else i.host&&(i.hostname=Kd(i.host).host);tc(this,i),this.secure=i.secure!=null?i.secure:typeof location<"u"&&location.protocol==="https:",i.hostname&&!i.port&&(i.port=this.secure?"443":"80"),this.hostname=i.hostname||(typeof location<"u"?location.hostname:"localhost"),this.port=i.port||(typeof location<"u"&&location.port?location.port:this.secure?"443":"80"),this.transports=[],this._transportsByName={},i.transports.forEach(l=>{const c=l.prototype.name;this.transports.push(c),this._transportsByName[c]=l}),this.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},i),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),typeof this.opts.query=="string"&&(this.opts.query=gw(this.opts.query)),Xd&&(this.opts.closeOnBeforeunload&&(this._beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener("beforeunload",this._beforeunloadEventListener,!1)),this.hostname!=="localhost"&&(this._offlineEventListener=()=>{this._onClose("transport close",{description:"network connection lost"})},Uo.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(t){const i=Object.assign({},this.opts.query);i.EIO=cv,i.transport=t,this.id&&(i.sid=this.id);const l=Object.assign({},this.opts,{query:i,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[t]);return new this._transportsByName[t](l)}_open(){if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);return}const t=this.opts.rememberUpgrade&&fa.priorWebsocketSuccess&&this.transports.indexOf("websocket")!==-1?"websocket":this.transports[0];this.readyState="opening";const i=this.createTransport(t);i.open(),this.setTransport(i)}setTransport(t){this.transport&&this.transport.removeAllListeners(),this.transport=t,t.on("drain",this._onDrain.bind(this)).on("packet",this._onPacket.bind(this)).on("error",this._onError.bind(this)).on("close",i=>this._onClose("transport close",i))}onOpen(){this.readyState="open",fa.priorWebsocketSuccess=this.transport.name==="websocket",this.emitReserved("open"),this.flush()}_onPacket(t){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")switch(this.emitReserved("packet",t),this.emitReserved("heartbeat"),t.type){case"open":this.onHandshake(JSON.parse(t.data));break;case"ping":this._sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong"),this._resetPingTimeout();break;case"error":const i=new Error("server error");i.code=t.data,this._onError(i);break;case"message":this.emitReserved("data",t.data),this.emitReserved("message",t.data);break}}onHandshake(t){this.emitReserved("handshake",t),this.id=t.sid,this.transport.query.sid=t.sid,this._pingInterval=t.pingInterval,this._pingTimeout=t.pingTimeout,this._maxPayload=t.maxPayload,this.onOpen(),this.readyState!=="closed"&&this._resetPingTimeout()}_resetPingTimeout(){this.clearTimeoutFn(this._pingTimeoutTimer);const t=this._pingInterval+this._pingTimeout;this._pingTimeoutTime=Date.now()+t,this._pingTimeoutTimer=this.setTimeoutFn(()=>{this._onClose("ping timeout")},t),this.opts.autoUnref&&this._pingTimeoutTimer.unref()}_onDrain(){this.writeBuffer.splice(0,this._prevBufferLen),this._prevBufferLen=0,this.writeBuffer.length===0?this.emitReserved("drain"):this.flush()}flush(){if(this.readyState!=="closed"&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){const t=this._getWritablePackets();this.transport.send(t),this._prevBufferLen=t.length,this.emitReserved("flush")}}_getWritablePackets(){if(!(this._maxPayload&&this.transport.name==="polling"&&this.writeBuffer.length>1))return this.writeBuffer;let i=1;for(let l=0;l<this.writeBuffer.length;l++){const c=this.writeBuffer[l].data;if(c&&(i+=hw(c)),l>0&&i>this._maxPayload)return this.writeBuffer.slice(0,l);i+=2}return this.writeBuffer}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;const t=Date.now()>this._pingTimeoutTime;return t&&(this._pingTimeoutTime=0,ec(()=>{this._onClose("ping timeout")},this.setTimeoutFn)),t}write(t,i,l){return this._sendPacket("message",t,i,l),this}send(t,i,l){return this._sendPacket("message",t,i,l),this}_sendPacket(t,i,l,c){if(typeof i=="function"&&(c=i,i=void 0),typeof l=="function"&&(c=l,l=null),this.readyState==="closing"||this.readyState==="closed")return;l=l||{},l.compress=l.compress!==!1;const u={type:t,data:i,options:l};this.emitReserved("packetCreate",u),this.writeBuffer.push(u),c&&this.once("flush",c),this.flush()}close(){const t=()=>{this._onClose("forced close"),this.transport.close()},i=()=>{this.off("upgrade",i),this.off("upgradeError",i),t()},l=()=>{this.once("upgrade",i),this.once("upgradeError",i)};return(this.readyState==="opening"||this.readyState==="open")&&(this.readyState="closing",this.writeBuffer.length?this.once("drain",()=>{this.upgrading?l():t()}):this.upgrading?l():t()),this}_onError(t){if(fa.priorWebsocketSuccess=!1,this.opts.tryAllTransports&&this.transports.length>1&&this.readyState==="opening")return this.transports.shift(),this._open();this.emitReserved("error",t),this._onClose("transport error",t)}_onClose(t,i){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing"){if(this.clearTimeoutFn(this._pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),Xd&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){const l=Uo.indexOf(this._offlineEventListener);l!==-1&&Uo.splice(l,1)}this.readyState="closed",this.id=null,this.emitReserved("close",t,i),this.writeBuffer=[],this._prevBufferLen=0}}}fa.protocol=cv;class Rw extends fa{constructor(){super(...arguments),this._upgrades=[]}onOpen(){if(super.onOpen(),this.readyState==="open"&&this.opts.upgrade)for(let t=0;t<this._upgrades.length;t++)this._probe(this._upgrades[t])}_probe(t){let i=this.createTransport(t),l=!1;fa.priorWebsocketSuccess=!1;const c=()=>{l||(i.send([{type:"ping",data:"probe"}]),i.once("packet",_=>{if(!l)if(_.type==="pong"&&_.data==="probe"){if(this.upgrading=!0,this.emitReserved("upgrading",i),!i)return;fa.priorWebsocketSuccess=i.name==="websocket",this.transport.pause(()=>{l||this.readyState!=="closed"&&(y(),this.setTransport(i),i.send([{type:"upgrade"}]),this.emitReserved("upgrade",i),i=null,this.upgrading=!1,this.flush())})}else{const v=new Error("probe error");v.transport=i.name,this.emitReserved("upgradeError",v)}}))};function u(){l||(l=!0,y(),i.close(),i=null)}const f=_=>{const v=new Error("probe error: "+_);v.transport=i.name,u(),this.emitReserved("upgradeError",v)};function x(){f("transport closed")}function g(){f("socket closed")}function m(_){i&&_.name!==i.name&&u()}const y=()=>{i.removeListener("open",c),i.removeListener("error",f),i.removeListener("close",x),this.off("close",g),this.off("upgrading",m)};i.once("open",c),i.once("error",f),i.once("close",x),this.once("close",g),this.once("upgrading",m),this._upgrades.indexOf("webtransport")!==-1&&t!=="webtransport"?this.setTimeoutFn(()=>{l||i.open()},200):i.open()}onHandshake(t){this._upgrades=this._filterUpgrades(t.upgrades),super.onHandshake(t)}_filterUpgrades(t){const i=[];for(let l=0;l<t.length;l++)~this.transports.indexOf(t[l])&&i.push(t[l]);return i}}let zw=class extends Rw{constructor(t,i={}){const l=typeof t=="object"?t:i;(!l.transports||l.transports&&typeof l.transports[0]=="string")&&(l.transports=(l.transports||["polling","websocket","webtransport"]).map(c=>ww[c]).filter(c=>!!c)),super(t,l)}};function Dw(n,t="",i){let l=n;i=i||typeof location<"u"&&location,n==null&&(n=i.protocol+"//"+i.host),typeof n=="string"&&(n.charAt(0)==="/"&&(n.charAt(1)==="/"?n=i.protocol+n:n=i.host+n),/^(https?|wss?):\/\//.test(n)||(typeof i<"u"?n=i.protocol+"//"+n:n="https://"+n),l=Kd(n)),l.port||(/^(http|ws)$/.test(l.protocol)?l.port="80":/^(http|ws)s$/.test(l.protocol)&&(l.port="443")),l.path=l.path||"/";const u=l.host.indexOf(":")!==-1?"["+l.host+"]":l.host;return l.id=l.protocol+"://"+u+":"+l.port+t,l.href=l.protocol+"://"+u+(i&&i.port===l.port?"":":"+l.port),l}const Ow=typeof ArrayBuffer=="function",Lw=n=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(n):n.buffer instanceof ArrayBuffer,gv=Object.prototype.toString,Mw=typeof Blob=="function"||typeof Blob<"u"&&gv.call(Blob)==="[object BlobConstructor]",qw=typeof File=="function"||typeof File<"u"&&gv.call(File)==="[object FileConstructor]";function Th(n){return Ow&&(n instanceof ArrayBuffer||Lw(n))||Mw&&n instanceof Blob||qw&&n instanceof File}function $o(n,t){if(!n||typeof n!="object")return!1;if(Array.isArray(n)){for(let i=0,l=n.length;i<l;i++)if($o(n[i]))return!0;return!1}if(Th(n))return!0;if(n.toJSON&&typeof n.toJSON=="function"&&arguments.length===1)return $o(n.toJSON(),!0);for(const i in n)if(Object.prototype.hasOwnProperty.call(n,i)&&$o(n[i]))return!0;return!1}function Iw(n){const t=[],i=n.data,l=n;return l.data=Zd(i,t),l.attachments=t.length,{packet:l,buffers:t}}function Zd(n,t){if(!n)return n;if(Th(n)){const i={_placeholder:!0,num:t.length};return t.push(n),i}else if(Array.isArray(n)){const i=new Array(n.length);for(let l=0;l<n.length;l++)i[l]=Zd(n[l],t);return i}else if(typeof n=="object"&&!(n instanceof Date)){const i={};for(const l in n)Object.prototype.hasOwnProperty.call(n,l)&&(i[l]=Zd(n[l],t));return i}return n}function Bw(n,t){return n.data=Wd(n.data,t),delete n.attachments,n}function Wd(n,t){if(!n)return n;if(n&&n._placeholder===!0){if(typeof n.num=="number"&&n.num>=0&&n.num<t.length)return t[n.num];throw new Error("illegal attachments")}else if(Array.isArray(n))for(let i=0;i<n.length;i++)n[i]=Wd(n[i],t);else if(typeof n=="object")for(const i in n)Object.prototype.hasOwnProperty.call(n,i)&&(n[i]=Wd(n[i],t));return n}const Uw=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"];var Ve;(function(n){n[n.CONNECT=0]="CONNECT",n[n.DISCONNECT=1]="DISCONNECT",n[n.EVENT=2]="EVENT",n[n.ACK=3]="ACK",n[n.CONNECT_ERROR=4]="CONNECT_ERROR",n[n.BINARY_EVENT=5]="BINARY_EVENT",n[n.BINARY_ACK=6]="BINARY_ACK"})(Ve||(Ve={}));class $w{constructor(t){this.replacer=t}encode(t){return(t.type===Ve.EVENT||t.type===Ve.ACK)&&$o(t)?this.encodeAsBinary({type:t.type===Ve.EVENT?Ve.BINARY_EVENT:Ve.BINARY_ACK,nsp:t.nsp,data:t.data,id:t.id}):[this.encodeAsString(t)]}encodeAsString(t){let i=""+t.type;return(t.type===Ve.BINARY_EVENT||t.type===Ve.BINARY_ACK)&&(i+=t.attachments+"-"),t.nsp&&t.nsp!=="/"&&(i+=t.nsp+","),t.id!=null&&(i+=t.id),t.data!=null&&(i+=JSON.stringify(t.data,this.replacer)),i}encodeAsBinary(t){const i=Iw(t),l=this.encodeAsString(i.packet),c=i.buffers;return c.unshift(l),c}}class wh extends At{constructor(t){super(),this.opts=Object.assign({reviver:void 0,maxAttachments:10},typeof t=="function"?{reviver:t}:t)}add(t){let i;if(typeof t=="string"){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");i=this.decodeString(t);const l=i.type===Ve.BINARY_EVENT;l||i.type===Ve.BINARY_ACK?(i.type=l?Ve.EVENT:Ve.ACK,this.reconstructor=new Hw(i),i.attachments===0&&super.emitReserved("decoded",i)):super.emitReserved("decoded",i)}else if(Th(t)||t.base64)if(this.reconstructor)i=this.reconstructor.takeBinaryData(t),i&&(this.reconstructor=null,super.emitReserved("decoded",i));else throw new Error("got binary data when not reconstructing a packet");else throw new Error("Unknown type: "+t)}decodeString(t){let i=0;const l={type:Number(t.charAt(0))};if(Ve[l.type]===void 0)throw new Error("unknown packet type "+l.type);if(l.type===Ve.BINARY_EVENT||l.type===Ve.BINARY_ACK){const u=i+1;for(;t.charAt(++i)!=="-"&&i!=t.length;);const f=t.substring(u,i);if(f!=Number(f)||t.charAt(i)!=="-")throw new Error("Illegal attachments");const x=Number(f);if(!Pw(x)||x<0)throw new Error("Illegal attachments");if(x>this.opts.maxAttachments)throw new Error("too many attachments");l.attachments=x}if(t.charAt(i+1)==="/"){const u=i+1;for(;++i&&!(t.charAt(i)===","||i===t.length););l.nsp=t.substring(u,i)}else l.nsp="/";const c=t.charAt(i+1);if(c!==""&&Number(c)==c){const u=i+1;for(;++i;){const f=t.charAt(i);if(f==null||Number(f)!=f){--i;break}if(i===t.length)break}l.id=Number(t.substring(u,i+1))}if(t.charAt(++i)){const u=this.tryParse(t.substr(i));if(wh.isPayloadValid(l.type,u))l.data=u;else throw new Error("invalid payload")}return l}tryParse(t){try{return JSON.parse(t,this.opts.reviver)}catch{return!1}}static isPayloadValid(t,i){switch(t){case Ve.CONNECT:return Iy(i);case Ve.DISCONNECT:return i===void 0;case Ve.CONNECT_ERROR:return typeof i=="string"||Iy(i);case Ve.EVENT:case Ve.BINARY_EVENT:return Array.isArray(i)&&(typeof i[0]=="number"||typeof i[0]=="string"&&Uw.indexOf(i[0])===-1);case Ve.ACK:case Ve.BINARY_ACK:return Array.isArray(i)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class Hw{constructor(t){this.packet=t,this.buffers=[],this.reconPack=t}takeBinaryData(t){if(this.buffers.push(t),this.buffers.length===this.reconPack.attachments){const i=Bw(this.reconPack,this.buffers);return this.finishedReconstruction(),i}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}const Pw=Number.isInteger||function(n){return typeof n=="number"&&isFinite(n)&&Math.floor(n)===n};function Iy(n){return Object.prototype.toString.call(n)==="[object Object]"}const Gw=Object.freeze(Object.defineProperty({__proto__:null,Decoder:wh,Encoder:$w,get PacketType(){return Ve}},Symbol.toStringTag,{value:"Module"}));function Qs(n,t,i){return n.on(t,i),function(){n.off(t,i)}}const Vw=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class mv extends At{constructor(t,i,l){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=t,this.nsp=i,l&&l.auth&&(this.auth=l.auth),this._opts=Object.assign({},l),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;const t=this.io;this.subs=[Qs(t,"open",this.onopen.bind(this)),Qs(t,"packet",this.onpacket.bind(this)),Qs(t,"error",this.onerror.bind(this)),Qs(t,"close",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected?this:(this.subEvents(),this.io._reconnecting||this.io.open(),this.io._readyState==="open"&&this.onopen(),this)}open(){return this.connect()}send(...t){return t.unshift("message"),this.emit.apply(this,t),this}emit(t,...i){var l,c,u;if(Vw.hasOwnProperty(t))throw new Error('"'+t.toString()+'" is a reserved event name');if(i.unshift(t),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(i),this;const f={type:Ve.EVENT,data:i};if(f.options={},f.options.compress=this.flags.compress!==!1,typeof i[i.length-1]=="function"){const y=this.ids++,_=i.pop();this._registerAckCallback(y,_),f.id=y}const x=(c=(l=this.io.engine)===null||l===void 0?void 0:l.transport)===null||c===void 0?void 0:c.writable,g=this.connected&&!(!((u=this.io.engine)===null||u===void 0)&&u._hasPingExpired());return this.flags.volatile&&!x||(g?(this.notifyOutgoingListeners(f),this.packet(f)):this.sendBuffer.push(f)),this.flags={},this}_registerAckCallback(t,i){var l;const c=(l=this.flags.timeout)!==null&&l!==void 0?l:this._opts.ackTimeout;if(c===void 0){this.acks[t]=i;return}const u=this.io.setTimeoutFn(()=>{delete this.acks[t];for(let x=0;x<this.sendBuffer.length;x++)this.sendBuffer[x].id===t&&this.sendBuffer.splice(x,1);i.call(this,new Error("operation has timed out"))},c),f=(...x)=>{this.io.clearTimeoutFn(u),i.apply(this,x)};f.withError=!0,this.acks[t]=f}emitWithAck(t,...i){return new Promise((l,c)=>{const u=(f,x)=>f?c(f):l(x);u.withError=!0,i.push(u),this.emit(t,...i)})}_addToQueue(t){let i;typeof t[t.length-1]=="function"&&(i=t.pop());const l={id:this._queueSeq++,tryCount:0,pending:!1,args:t,flags:Object.assign({fromQueue:!0},this.flags)};t.push((c,...u)=>(this._queue[0],c!==null?l.tryCount>this._opts.retries&&(this._queue.shift(),i&&i(c)):(this._queue.shift(),i&&i(null,...u)),l.pending=!1,this._drainQueue())),this._queue.push(l),this._drainQueue()}_drainQueue(t=!1){if(!this.connected||this._queue.length===0)return;const i=this._queue[0];i.pending&&!t||(i.pending=!0,i.tryCount++,this.flags=i.flags,this.emit.apply(this,i.args))}packet(t){t.nsp=this.nsp,this.io._packet(t)}onopen(){typeof this.auth=="function"?this.auth(t=>{this._sendConnectPacket(t)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(t){this.packet({type:Ve.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},t):t})}onerror(t){this.connected||this.emitReserved("connect_error",t)}onclose(t,i){this.connected=!1,delete this.id,this.emitReserved("disconnect",t,i),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach(t=>{if(!this.sendBuffer.some(l=>String(l.id)===t)){const l=this.acks[t];delete this.acks[t],l.withError&&l.call(this,new Error("socket has been disconnected"))}})}onpacket(t){if(t.nsp===this.nsp)switch(t.type){case Ve.CONNECT:t.data&&t.data.sid?this.onconnect(t.data.sid,t.data.pid):this.emitReserved("connect_error",new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case Ve.EVENT:case Ve.BINARY_EVENT:this.onevent(t);break;case Ve.ACK:case Ve.BINARY_ACK:this.onack(t);break;case Ve.DISCONNECT:this.ondisconnect();break;case Ve.CONNECT_ERROR:this.destroy();const l=new Error(t.data.message);l.data=t.data.data,this.emitReserved("connect_error",l);break}}onevent(t){const i=t.data||[];t.id!=null&&i.push(this.ack(t.id)),this.connected?this.emitEvent(i):this.receiveBuffer.push(Object.freeze(i))}emitEvent(t){if(this._anyListeners&&this._anyListeners.length){const i=this._anyListeners.slice();for(const l of i)l.apply(this,t)}super.emit.apply(this,t),this._pid&&t.length&&typeof t[t.length-1]=="string"&&(this._lastOffset=t[t.length-1])}ack(t){const i=this;let l=!1;return function(...c){l||(l=!0,i.packet({type:Ve.ACK,id:t,data:c}))}}onack(t){const i=this.acks[t.id];typeof i=="function"&&(delete this.acks[t.id],i.withError&&t.data.unshift(null),i.apply(this,t.data))}onconnect(t,i){this.id=t,this.recovered=i&&this._pid===i,this._pid=i,this.connected=!0,this.emitBuffered(),this._drainQueue(!0),this.emitReserved("connect")}emitBuffered(){this.receiveBuffer.forEach(t=>this.emitEvent(t)),this.receiveBuffer=[],this.sendBuffer.forEach(t=>{this.notifyOutgoingListeners(t),this.packet(t)}),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach(t=>t()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:Ve.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(t){return this.flags.compress=t,this}get volatile(){return this.flags.volatile=!0,this}timeout(t){return this.flags.timeout=t,this}onAny(t){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(t),this}prependAny(t){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(t),this}offAny(t){if(!this._anyListeners)return this;if(t){const i=this._anyListeners;for(let l=0;l<i.length;l++)if(t===i[l])return i.splice(l,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(t){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(t),this}prependAnyOutgoing(t){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(t),this}offAnyOutgoing(t){if(!this._anyOutgoingListeners)return this;if(t){const i=this._anyOutgoingListeners;for(let l=0;l<i.length;l++)if(t===i[l])return i.splice(l,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(t){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){const i=this._anyOutgoingListeners.slice();for(const l of i)l.apply(this,t.data)}}}function $r(n){n=n||{},this.ms=n.min||100,this.max=n.max||1e4,this.factor=n.factor||2,this.jitter=n.jitter>0&&n.jitter<=1?n.jitter:0,this.attempts=0}$r.prototype.duration=function(){var n=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var t=Math.random(),i=Math.floor(t*this.jitter*n);n=(Math.floor(t*10)&1)==0?n-i:n+i}return Math.min(n,this.max)|0};$r.prototype.reset=function(){this.attempts=0};$r.prototype.setMin=function(n){this.ms=n};$r.prototype.setMax=function(n){this.max=n};$r.prototype.setJitter=function(n){this.jitter=n};class Jd extends At{constructor(t,i){var l;super(),this.nsps={},this.subs=[],t&&typeof t=="object"&&(i=t,t=void 0),i=i||{},i.path=i.path||"/socket.io",this.opts=i,tc(this,i),this.reconnection(i.reconnection!==!1),this.reconnectionAttempts(i.reconnectionAttempts||1/0),this.reconnectionDelay(i.reconnectionDelay||1e3),this.reconnectionDelayMax(i.reconnectionDelayMax||5e3),this.randomizationFactor((l=i.randomizationFactor)!==null&&l!==void 0?l:.5),this.backoff=new $r({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(i.timeout==null?2e4:i.timeout),this._readyState="closed",this.uri=t;const c=i.parser||Gw;this.encoder=new c.Encoder,this.decoder=new c.Decoder,this._autoConnect=i.autoConnect!==!1,this._autoConnect&&this.open()}reconnection(t){return arguments.length?(this._reconnection=!!t,t||(this.skipReconnect=!0),this):this._reconnection}reconnectionAttempts(t){return t===void 0?this._reconnectionAttempts:(this._reconnectionAttempts=t,this)}reconnectionDelay(t){var i;return t===void 0?this._reconnectionDelay:(this._reconnectionDelay=t,(i=this.backoff)===null||i===void 0||i.setMin(t),this)}randomizationFactor(t){var i;return t===void 0?this._randomizationFactor:(this._randomizationFactor=t,(i=this.backoff)===null||i===void 0||i.setJitter(t),this)}reconnectionDelayMax(t){var i;return t===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=t,(i=this.backoff)===null||i===void 0||i.setMax(t),this)}timeout(t){return arguments.length?(this._timeout=t,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()}open(t){if(~this._readyState.indexOf("open"))return this;this.engine=new zw(this.uri,this.opts);const i=this.engine,l=this;this._readyState="opening",this.skipReconnect=!1;const c=Qs(i,"open",function(){l.onopen(),t&&t()}),u=x=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",x),t?t(x):this.maybeReconnectOnOpen()},f=Qs(i,"error",u);if(this._timeout!==!1){const x=this._timeout,g=this.setTimeoutFn(()=>{c(),u(new Error("timeout")),i.close()},x);this.opts.autoUnref&&g.unref(),this.subs.push(()=>{this.clearTimeoutFn(g)})}return this.subs.push(c),this.subs.push(f),this}connect(t){return this.open(t)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");const t=this.engine;this.subs.push(Qs(t,"ping",this.onping.bind(this)),Qs(t,"data",this.ondata.bind(this)),Qs(t,"error",this.onerror.bind(this)),Qs(t,"close",this.onclose.bind(this)),Qs(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(t){try{this.decoder.add(t)}catch(i){this.onclose("parse error",i)}}ondecoded(t){ec(()=>{this.emitReserved("packet",t)},this.setTimeoutFn)}onerror(t){this.emitReserved("error",t)}socket(t,i){let l=this.nsps[t];return l?this._autoConnect&&!l.active&&l.connect():(l=new mv(this,t,i),this.nsps[t]=l),l}_destroy(t){const i=Object.keys(this.nsps);for(const l of i)if(this.nsps[l].active)return;this._close()}_packet(t){const i=this.encoder.encode(t);for(let l=0;l<i.length;l++)this.engine.write(i[l],t.options)}cleanup(){this.subs.forEach(t=>t()),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close")}disconnect(){return this._close()}onclose(t,i){var l;this.cleanup(),(l=this.engine)===null||l===void 0||l.close(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",t,i),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const t=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{const i=this.backoff.duration();this._reconnecting=!0;const l=this.setTimeoutFn(()=>{t.skipReconnect||(this.emitReserved("reconnect_attempt",t.backoff.attempts),!t.skipReconnect&&t.open(c=>{c?(t._reconnecting=!1,t.reconnect(),this.emitReserved("reconnect_error",c)):t.onreconnect()}))},i);this.opts.autoUnref&&l.unref(),this.subs.push(()=>{this.clearTimeoutFn(l)})}}onreconnect(){const t=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",t)}}const Bi={};function Bs(n,t){typeof n=="object"&&(t=n,n=void 0),t=t||{};const i=Dw(n,t.path||"/socket.io"),l=i.source,c=i.id,u=i.path,f=Bi[c]&&u in Bi[c].nsps,x=t.forceNew||t["force new connection"]||t.multiplex===!1||f;let g;return x?g=new Jd(l,t):(Bi[c]||(Bi[c]=new Jd(l,t)),g=Bi[c]),i.query&&!t.query&&(t.query=i.queryKey),g.socket(i.path,t)}Object.assign(Bs,{Manager:Jd,Socket:mv,io:Bs,connect:Bs});const bs={TASK_CREATED:"task.created",TASK_UPDATED:"task.updated",TASK_DELETED:"task.deleted",TASK_ASSIGNED:"task.assigned",TASK_STATUS_CHANGED:"task.status_changed",TASK_COMMENTED:"task.commented",INPUT_REQUEST_ANSWERED:"input.request.answered",TASK_ACTIVITY:"task.activity"},Dr={THREAD_UPDATED:"thread.updated",THREAD_TITLE_UPDATED:"thread.title.updated",MESSAGE_CREATED:"thread.message.created",AGENT_ACTIVITY:"thread.agent.activity",AGENT_RESPONSE_DELTA:"thread.agent.response.delta"};var Fo;(function(n){n.HUMAN="human",n.AGENT="agent"})(Fo||(Fo={}));const Fw={WORKER_SEEN:"worker.seen"},Yw=window.location.origin,yv=new Ws({baseUrl:Yw,credentials:"include"}),Qw=yv.workers;yv.workers;const Kw=pa("/workers");function Eh(){const[n,t]=h.useState([]),[i,l]=h.useState(!0),[c,u]=h.useState(null),[f,x]=h.useState(!1),g=y=>[...y].sort((_,v)=>{const j=new Date(_.lastSeenAt).getTime();return new Date(v.lastSeenAt).getTime()-j}),m=async()=>{try{l(!0),u(null);const y=await Qw.WorkersController_listWorkers();t(g(y))}catch(y){console.error("Error fetching workers:",y),u(y instanceof Error?y.message:"Failed to load workers")}finally{l(!1)}};return h.useEffect(()=>{const y=Bs(Kw,{withCredentials:!0,transports:["websocket","polling"]});return m(),y.on("connect",()=>{y.emit("workers.subscribe",{},_=>{if(_.ok){x(!0);return}x(!1)}),m()}),y.on("disconnect",()=>{x(!1)}),y.on("connect_error",_=>{console.error("Workers WebSocket connection error:",_)}),y.on(Fw.WORKER_SEEN,_=>{t(v=>{const j=v.findIndex(k=>k.id===_.worker.id);if(j>=0){const k=[...v];return k[j]=_.worker,g(k)}return g([...v,_.worker])})}),()=>{y.emit("workers.unsubscribe",{}),y.disconnect()}},[]),{workers:n,isLoading:i,error:c,isConnected:f}}function xv({preview:n,size:t="compact"}){const i={"--theme-preview-bg":n.background,"--theme-preview-surface":n.surface,"--theme-preview-card":n.card,"--theme-preview-border":n.border,"--theme-preview-text":n.text,"--theme-preview-muted":n.muted,"--theme-preview-accent":n.accent,"--theme-preview-accent-soft":n.accentSoft};return a.jsx("span",{className:`settings-theme-visual settings-theme-visual--${t}`,style:i,"aria-hidden":"true",children:a.jsxs("span",{className:"settings-theme-visual__window",children:[a.jsxs("span",{className:"settings-theme-visual__rail",children:[a.jsx("span",{className:"settings-theme-visual__accent-dot"}),a.jsx("span",{className:"settings-theme-visual__rail-line"}),a.jsx("span",{className:"settings-theme-visual__rail-line settings-theme-visual__rail-line--short"})]}),a.jsxs("span",{className:"settings-theme-visual__canvas",children:[a.jsx("span",{className:"settings-theme-visual__font",children:n.font==="Mono"?"Aa":"Ag"}),a.jsx("span",{className:"settings-theme-visual__line settings-theme-visual__line--wide"}),a.jsxs("span",{className:"settings-theme-visual__panel",children:[a.jsx("span",{className:"settings-theme-visual__chip"}),a.jsx("span",{className:"settings-theme-visual__line"}),a.jsx("span",{className:"settings-theme-visual__line settings-theme-visual__line--short"})]}),a.jsx("span",{className:"settings-theme-visual__button"})]})]})})}const vv=[{value:"light",label:"Light",description:"Clean light theme with a crisp blue accent.",preview:{background:"#ffffff",surface:"#f6f8fa",card:"#ffffff",border:"#d1d9e0",text:"#1f2328",muted:"#59636e",accent:"#0969da",accentSoft:"#ddf4ff",font:"Inter"}},{value:"dark",label:"Dark",description:"Low-light surfaces with GitHub-style blue highlights.",preview:{background:"#0d1117",surface:"#161b22",card:"#0d1117",border:"#30363d",text:"#e6edf3",muted:"#8b949e",accent:"#2f81f7",accentSoft:"#1f6feb33",font:"Inter"}},{value:"clarity",label:"Clarity",description:"Soft neutral surfaces for focused daytime work.",preview:{background:"#f7f7f5",surface:"#f2f4f7",card:"#ffffff",border:"#d9dee5",text:"#1f2328",muted:"#66707a",accent:"#3971d9",accentSoft:"#e5efff",font:"Inter"}},{value:"github",label:"GitHub",description:"GitHub-inspired neutrals with a green action color.",preview:{background:"#ffffff",surface:"#f6f8fa",card:"#ffffff",border:"#d0d7de",text:"#24292f",muted:"#57606a",accent:"#1f883d",accentSoft:"#dafbe1",font:"Inter"}},{value:"forest",label:"Forest",description:"Dark green workspace with softer natural contrast.",preview:{background:"#0f1a0f",surface:"#152615",card:"#102010",border:"#2d4a2d",text:"#e8f5e8",muted:"#9bb89b",accent:"#52c952",accentSoft:"#1f4d2a",font:"Inter"}},{value:"terminal",label:"Terminal",description:"Classic terminal green on a black interface.",preview:{background:"#000000",surface:"#0a0a0a",card:"#050505",border:"#00aa00",text:"#00ff00",muted:"#00aa00",accent:"#00dd00",accentSoft:"#003b00",font:"Mono"}},{value:"ai-vibes",label:"AI Vibes",description:"Deep purples with neon-like accents.",preview:{background:"#0c0716",surface:"#1a102b",card:"#130b21",border:"#3b255f",text:"#f5efff",muted:"#c4b5db",accent:"#a855f7",accentSoft:"#3b1762",font:"Inter"}},{value:"halo",label:"Halo",description:"Light background with cooler layered surfaces.",preview:{background:"#f9f9fc",surface:"#eef1f9",card:"#ffffff",border:"#d8deef",text:"#1f2937",muted:"#667085",accent:"#3b5bcc",accentSoft:"#e6ebff",font:"Inter"}},{value:"mono",label:"Mono",description:"Black and white minimalism with restrained contrast.",preview:{background:"#ffffff",surface:"#f5f5f5",card:"#ffffff",border:"#d4d4d4",text:"#111111",muted:"#666666",accent:"#111111",accentSoft:"#eeeeee",font:"Inter"}},{value:"terminal-amber",label:"Terminal Amber",description:"Warm terminal tones with a calm blue accent.",preview:{background:"#0b0a09",surface:"#17130d",card:"#120f0b",border:"#3a2d16",text:"#f5d78e",muted:"#b9975b",accent:"#8ab4f8",accentSoft:"#1d2740",font:"Mono"}},{value:"oceanic",label:"Oceanic",description:"Cool blues and teals for a calmer dark theme.",preview:{background:"#0c1b2a",surface:"#102a3d",card:"#0f2233",border:"#1d4a5f",text:"#e6fffb",muted:"#9bd5d0",accent:"#4fd1c5",accentSoft:"#123c47",font:"Inter"}},{value:"party",label:"Party",description:"Playful warm palette with saturated highlights.",preview:{background:"#fff7f0",surface:"#fff0e0",card:"#ffffff",border:"#ffd4d4",text:"#2d1b1b",muted:"#7a5a5a",accent:"#ff6b6b",accentSoft:"#ffe3df",font:"Inter"}},{value:"tribute",label:"Tribute",description:"Dark sidebar energy inspired by the previous UI.",preview:{background:"#0b1220",surface:"#111827",card:"#0f172a",border:"#1e293b",text:"#e5e7eb",muted:"#94a3b8",accent:"#2563eb",accentSoft:"#172554",font:"Inter"}}];function Xw(){const{setSectionTitle:n}=js(),t=Rt(),i=ze(),{registerCommands:l}=rl(),{theme:c,setTheme:u}=Ix(),{workers:f,isLoading:x}=Eh(),[g,m]=h.useState(null),[y,_]=h.useState({projects:null,providers:null});jt(),h.useEffect(()=>{n("Settings"),v(),j()},[]);const v=async()=>{try{const w=await $x.metaControllerGetVersion();m(w)}catch(w){console.error("Failed to load version:",w)}},j=async()=>{const[w,T]=await Promise.allSettled([Vo.projectsControllerGetAllProjects(),Ar.chatProvidersControllerListChatProviders()]);_({projects:w.status==="fulfilled"?w.value.length:null,providers:T.status==="fulfilled"?{configured:T.value.filter(R=>R.isConfigured).length,total:T.value.length,activeName:T.value.find(R=>R.isActive)?.name??null}:null})};h.useEffect(()=>l([{id:"settings-account",label:"Account Settings",description:"Manage your account security",aliases:["password","account","security"],onSelect:()=>i("/settings/account")},{id:"settings-appearance",label:"Appearance Settings",description:"Choose your preferred color theme",aliases:["theme","appearance","dark mode","light mode"],onSelect:()=>i("/settings/appearance")},{id:"settings-projects",label:"Projects Settings",description:"Manage your projects",aliases:["projects","manage projects"],onSelect:()=>i("/settings/projects")},{id:"settings-chat",label:"Chat Settings",description:"Configure chat providers for conversations",aliases:["chat","openai","providers","chat providers"],onSelect:()=>i("/settings/chat")},{id:"settings-workers",label:"Workers Settings",description:"Configure and manage background workers",aliases:["workers","background","execution"],onSelect:()=>i("/settings/workers")},{id:"settings-ai-providers",label:"AI Providers",description:"View usage and quota for AI providers",aliases:["ai","providers","usage","quota","anthropic","openai","claude"],onSelect:()=>i("/settings/ai-providers")},{id:"settings-data",label:"Import / Export",description:"Import and export workspace data",aliases:["data","export","import","backup","restore"],onSelect:()=>i("/settings/data")},{id:"settings-users",label:"User Management",description:"Invite users and manage access",aliases:["users","user management","admin","accounts"],onSelect:()=>i("/settings/users")}]),[l,i]);const k=f.filter(w=>{const T=new Date(w.lastSeenAt);return Date.now()-T.getTime()<=120*1e3}).length,E=[{title:"Appearance",description:"Theme and visual preferences for Taico.",icon:BT,iconTone:"accent",path:"/settings/appearance",action:"More themes",detail:{label:"Current theme",value:Zw(c),tone:"default"},preview:a.jsx(Ww,{activeTheme:c,onSelect:w=>u(w)})},{title:"Projects",description:"Project metadata and repository links.",icon:Yd,iconTone:"accent",path:"/settings/projects",action:"Manage",detail:{label:"Projects",value:y.projects===null?"Unavailable":String(y.projects),tone:"default"}},{title:"AI & Chat",description:"Conversation providers and active chat routing.",icon:ZT,iconTone:"warning",path:"/settings/chat",action:"Configure",detail:{label:"Active provider",value:y.providers?.activeName??"Not selected",tone:y.providers?.activeName?"default":"muted"}},{title:"Workers",description:"Background execution workers and harness health.",icon:zy,iconTone:"green",path:"/settings/workers",action:"Open workers",detail:{label:"Connected workers",value:x?"Loading":String(k),tone:"default"}},{title:"Account",description:"Password and account-level access controls.",icon:RT,iconTone:"red",path:"/settings/account",action:"Security",detail:{label:"Password",value:"Change available",tone:"default"}},{title:"Users",description:"Invite people, reset passwords, and disable access.",icon:s0,iconTone:"accent",path:"/settings/users",action:"Manage users",detail:{label:"Access",value:"Admin only",tone:"default"}},{title:"Data",description:"Import and export workspace context blocks.",icon:oT,iconTone:"neutral",path:"/settings/data",action:"Import / export",detail:{label:"Export",value:"Context blocks",tone:"default"}}];return a.jsxs("div",{className:"settings-page",children:[t?a.jsx(b,{tone:"muted",children:"Manage your workspace, execution, providers, and data."}):null,a.jsxs("div",{className:"settings-page__layout",children:[a.jsxs("main",{className:"settings-page__main","aria-label":"Settings sections",children:[a.jsxs("div",{className:"settings-page__nav","aria-label":"Settings shortcuts",children:[a.jsxs("button",{className:"settings-page__nav-item",type:"button",onClick:()=>i("/settings"),"aria-current":"page",children:[a.jsx(Xx,{size:16,strokeWidth:1.8,"aria-hidden":"true"}),a.jsx("span",{children:"Overview"})]}),E.slice(0,4).map(w=>{const T=w.icon;return a.jsxs("button",{className:"settings-page__nav-item",type:"button",onClick:()=>i(w.path),children:[a.jsx(T,{size:16,strokeWidth:1.8,"aria-hidden":"true"}),a.jsx("span",{children:w.title})]},w.title)})]}),a.jsx("div",{className:"settings-page__section-grid",children:E.map(w=>{const T=w.icon;return a.jsxs(Fe,{padding:"0",className:`settings-page__section-card ${w.preview?"settings-page__section-card--with-carousel":""}`,children:[a.jsxs("div",{className:"settings-page__section-header",children:[a.jsx("span",{className:`settings-page__section-icon settings-page__section-icon--${w.iconTone}`,children:a.jsx(T,{size:22,strokeWidth:1.8,"aria-hidden":"true"})}),a.jsxs(te,{spacing:"1",children:[a.jsx(b,{size:"3",weight:"semibold",children:w.title}),a.jsx(b,{size:"1",tone:"muted",children:w.description})]})]}),w.preview??a.jsxs("div",{className:"settings-page__detail",children:[a.jsx(b,{size:"1",tone:"muted",children:w.detail.label}),a.jsx(b,{size:"2",weight:"medium",tone:w.detail.tone,children:w.detail.value})]}),a.jsxs(ue,{variant:"secondary",size:"sm",fullWidth:!0,onClick:()=>i(w.path),className:"settings-page__section-action",children:[a.jsx("span",{children:w.action}),a.jsx(Yx,{size:16,strokeWidth:1.8,"aria-hidden":"true"})]})]},w.title)})})]}),a.jsxs("aside",{className:"settings-page__side","aria-label":"Settings status",children:[a.jsx(Fe,{padding:"4",className:"settings-page__side-card",children:a.jsxs(te,{spacing:"4",children:[a.jsx(b,{size:"3",weight:"semibold",children:"Readiness"}),a.jsx(Rd,{icon:a.jsx(rT,{size:16,strokeWidth:1.8}),label:"Chat provider",value:y.providers?.activeName??"Needs active provider",isReady:!!y.providers?.activeName}),a.jsx(Rd,{icon:a.jsx(zy,{size:16,strokeWidth:1.8}),label:"Worker connection",value:x?"Checking":k>0?`${k} online`:"No workers online",isReady:k>0}),a.jsx(Rd,{icon:a.jsx(Yd,{size:16,strokeWidth:1.8}),label:"Projects",value:y.projects===null?"Checking":`${y.projects} available`,isReady:(y.projects??0)>0})]})}),a.jsx(Fe,{padding:"4",className:"settings-page__side-card",children:a.jsxs(te,{spacing:"3",children:[a.jsx(b,{size:"3",weight:"semibold",children:"Quick links"}),a.jsx(Co,{icon:a.jsx(Zk,{size:16}),label:"AI usage",onClick:()=>i("/settings/ai-providers")}),a.jsx(Co,{icon:a.jsx(ET,{size:16}),label:"Chat API keys",onClick:()=>i("/settings/chat")}),a.jsx(Co,{icon:a.jsx(Jk,{size:16}),label:"Setup walkthrough",onClick:()=>i("/walkthrough")}),a.jsx(Co,{icon:a.jsx(uT,{size:16}),label:"Tools",onClick:()=>i("/tools")})]})}),g?a.jsxs(b,{size:"1",tone:"muted",className:"settings-page__version",children:["Taico v",g.backend," · UI v",g.ui]}):null]})]})]})}function Zw(n){return n.split("-").map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ")}function Ww({activeTheme:n,onSelect:t}){return a.jsx("div",{className:"settings-page__theme-carousel","aria-label":"Theme preview selector",children:vv.map(i=>{const l=n===i.value;return a.jsxs("button",{type:"button",className:`settings-page__theme-preview ${l?"settings-page__theme-preview--active":""}`,onClick:()=>t(i.value),"aria-pressed":l,children:[a.jsx(xv,{preview:i.preview}),a.jsxs("span",{className:"settings-page__theme-preview-copy",children:[a.jsx("span",{children:i.label}),a.jsx("span",{children:i.preview.font})]})]},i.value)})})}function Rd({icon:n,label:t,value:i,isReady:l}){return a.jsxs("div",{className:"settings-page__status-row",children:[a.jsx("span",{className:`settings-page__status-icon ${l?"settings-page__status-icon--ready":""}`,children:n}),a.jsxs("div",{children:[a.jsx(b,{size:"2",weight:"medium",children:t}),a.jsx(b,{size:"1",tone:"muted",children:i})]})]})}function Co({icon:n,label:t,onClick:i}){return a.jsxs("button",{className:"settings-page__quick-link",type:"button",onClick:i,children:[a.jsx("span",{className:"settings-page__quick-link-icon","aria-hidden":"true",children:n}),a.jsx("span",{children:t}),a.jsx(Yx,{size:15,strokeWidth:1.8,"aria-hidden":"true"})]})}function Jw(){const{setSectionTitle:n}=js(),{logout:t}=us(),i=ze(),[l,c]=h.useState(""),[u,f]=h.useState(""),[x,g]=h.useState(""),[m,y]=h.useState(""),[_,v]=h.useState(!1);h.useEffect(()=>{n("Account")},[]);const j=async k=>{k.preventDefault(),g(""),y(""),v(!0);try{await es.webAuthControllerChangePassword({currentPassword:l,newPassword:u}),y("Password changed successfully! You will be logged out."),c(""),f(""),setTimeout(async()=>{await t(),i("/login")},2e3)}catch(E){g(E?.body?.detail||"Failed to change password. Please check your current password.")}finally{v(!1)}};return a.jsxs(te,{spacing:"6",className:"settings-subpage",children:[a.jsx(b,{tone:"muted",className:"settings-subpage__intro",children:"Update the password used to sign in to this Taico instance."}),a.jsx(Fe,{padding:"5",className:"settings-panel-card",children:a.jsxs(te,{spacing:"4",children:[a.jsxs(te,{spacing:"2",children:[a.jsx(b,{size:"4",weight:"semibold",children:"Change Password"}),a.jsx(b,{tone:"muted",children:"Update your account password"})]}),a.jsx("form",{onSubmit:j,children:a.jsxs(te,{spacing:"4",children:[a.jsxs(te,{spacing:"2",children:[a.jsx("label",{htmlFor:"current-password",className:"login-label",children:a.jsx(b,{size:"2",weight:"medium",children:"Current Password"})}),a.jsx("input",{id:"current-password",type:"password",value:l,onChange:k=>c(k.target.value),className:"login-input",placeholder:"••••••••",required:!0,disabled:_,autoComplete:"current-password"})]}),a.jsxs(te,{spacing:"2",children:[a.jsx("label",{htmlFor:"new-password",className:"login-label",children:a.jsx(b,{size:"2",weight:"medium",children:"New Password"})}),a.jsx("input",{id:"new-password",type:"password",value:u,onChange:k=>f(k.target.value),className:"login-input",placeholder:"••••••••",required:!0,disabled:_,autoComplete:"new-password"})]}),x&&a.jsx(Zt,{size:"2",weight:"medium",children:x}),m&&a.jsx("div",{style:{color:"var(--accent)"},children:a.jsx(b,{size:"2",weight:"medium",children:m})}),a.jsx(ue,{type:"submit",variant:"primary",size:"md",disabled:_||!l||!u,children:_?"Changing Password...":"Change Password"})]})})]})})]})}function e1(){const{theme:n,setTheme:t}=Ix(),{setSectionTitle:i}=js();return h.useEffect(()=>{i("Appearance")},[]),a.jsxs(te,{spacing:"6",className:"settings-subpage settings-subpage--wide",children:[a.jsx(b,{tone:"muted",className:"settings-subpage__intro",children:"Choose the visual style used across Taico."}),a.jsx("div",{className:"settings-theme-grid","aria-label":"Theme choices",children:vv.map(l=>{const c=n===l.value;return a.jsxs("button",{type:"button",className:`settings-theme-card ${c?"settings-theme-card--active":""}`,onClick:()=>t(l.value),"aria-pressed":c,children:[a.jsx(xv,{preview:l.preview,size:"large"}),a.jsxs("span",{className:"settings-theme-card__body",children:[a.jsxs("span",{className:"settings-theme-card__header",children:[a.jsx("span",{className:"settings-theme-card__title",children:l.label}),a.jsx("span",{className:"settings-theme-card__badge",children:c?"Active":l.preview.font})]}),a.jsx("span",{className:"settings-theme-card__description",children:l.description}),a.jsxs("span",{className:"settings-theme-card__palette","aria-hidden":"true",children:[a.jsx("span",{style:{backgroundColor:l.preview.background}}),a.jsx("span",{style:{backgroundColor:l.preview.surface}}),a.jsx("span",{style:{backgroundColor:l.preview.card}}),a.jsx("span",{style:{backgroundColor:l.preview.accent}})]})]})]},l.value)})})]})}function t1(){const{setSectionTitle:n}=js(),t=ze(),[i,l]=h.useState([]),[c,u]=h.useState(!0),[f,x]=h.useState(""),[g,m]=h.useState(null),[y,_]=h.useState(""),[v,j]=h.useState(""),[k,E]=h.useState(""),[w,T]=h.useState("");h.useEffect(()=>{n("Projects"),R()},[]);const R=async()=>{u(!0),x("");try{const N=await Vo.projectsControllerGetAllProjects();l(N)}catch(N){x(N?.body?.detail||"Failed to load projects")}finally{u(!1)}},z=N=>{m(N.id),_(N.description||""),j(N.repoUrl||""),E(""),T("")},L=()=>{m(null),_(""),j(""),E(""),T("")},M=async N=>{E(""),T("");try{await Vo.projectsControllerUpdateProject(N,{description:y,repoUrl:v}),T("Project updated successfully!"),m(null),await R(),setTimeout(()=>{T("")},3e3)}catch(A){E(A?.body?.detail||"Failed to update project")}};return c?a.jsx(te,{spacing:"6",className:"settings-subpage",children:a.jsx(b,{tone:"muted",children:"Loading projects..."})}):f?a.jsxs(te,{spacing:"6",className:"settings-subpage",children:[a.jsx(Zt,{children:f}),a.jsx(ue,{variant:"secondary",onClick:R,children:"Retry"})]}):a.jsxs(te,{spacing:"6",className:"settings-subpage",children:[a.jsx(b,{tone:"muted",className:"settings-subpage__intro",children:"Manage project metadata and repository links used by task workflows."}),a.jsxs(Mt,{justify:"space-between",align:"center",className:"settings-projects__toolbar",children:[a.jsx(b,{size:"3",weight:"semibold",children:"Projects"}),a.jsx(ue,{variant:"primary",size:"sm",onClick:()=>t("/settings/projects/new"),children:"New project"})]}),i.length===0?a.jsx(Fe,{padding:"5",className:"settings-panel-card",children:a.jsxs(te,{spacing:"3",children:[a.jsx(b,{tone:"muted",children:"No projects found"}),a.jsx(Mt,{children:a.jsx(ue,{variant:"secondary",size:"sm",onClick:()=>t("/settings/projects/new"),children:"Create project"})})]})}):i.map(N=>a.jsx(Fe,{padding:"5",className:"settings-panel-card",children:a.jsxs(te,{spacing:"4",children:[a.jsxs(te,{spacing:"2",children:[a.jsx(b,{size:"4",weight:"semibold",children:N.slug}),a.jsxs(b,{size:"2",tone:"muted",children:["Tag: ",N.tagName]})]}),g===N.id?a.jsx("form",{onSubmit:A=>{A.preventDefault(),M(N.id)},children:a.jsxs(te,{spacing:"4",children:[a.jsxs(te,{spacing:"2",children:[a.jsx("label",{htmlFor:`description-${N.id}`,className:"login-label",children:a.jsx(b,{size:"2",weight:"medium",children:"Description"})}),a.jsx("textarea",{id:`description-${N.id}`,value:y,onChange:A=>_(A.target.value),className:"login-input",placeholder:"Project description",rows:3,style:{resize:"vertical",fontFamily:"inherit"}})]}),a.jsxs(te,{spacing:"2",children:[a.jsx("label",{htmlFor:`repo-url-${N.id}`,className:"login-label",children:a.jsx(b,{size:"2",weight:"medium",children:"Repository URL"})}),a.jsx("input",{id:`repo-url-${N.id}`,type:"url",value:v,onChange:A=>j(A.target.value),className:"login-input",placeholder:"https://github.com/username/repo"})]}),k&&a.jsx(Zt,{size:"2",weight:"medium",children:k}),w&&a.jsx("div",{style:{color:"var(--accent)"},children:a.jsx(b,{size:"2",weight:"medium",children:w})}),a.jsxs(Mt,{spacing:"3",children:[a.jsx(ue,{type:"submit",variant:"primary",size:"md",children:"Save Changes"}),a.jsx(ue,{type:"button",variant:"secondary",size:"md",onClick:L,children:"Cancel"})]})]})}):a.jsxs(a.Fragment,{children:[a.jsxs(te,{spacing:"2",children:[a.jsx(b,{size:"2",weight:"medium",children:"Description"}),a.jsx(b,{size:"2",tone:"muted",children:N.description||"No description"})]}),a.jsxs(te,{spacing:"2",children:[a.jsx(b,{size:"2",weight:"medium",children:"Repository URL"}),a.jsx(b,{size:"2",tone:"muted",children:N.repoUrl||"No repository URL"})]}),a.jsx(Mt,{justify:"end",children:a.jsx(ue,{variant:"secondary",size:"sm",onClick:()=>z(N),children:"Edit Project"})})]})]})},N.id))]})}function s1(){const{setSectionTitle:n}=js(),t=ze(),[i,l]=h.useState(""),[c,u]=h.useState(""),[f,x]=h.useState(""),[g,m]=h.useState(!1),[y,_]=h.useState("");h.useEffect(()=>{n("Create Project")},[]);const v=async j=>{j.preventDefault(),_(""),m(!0);try{await Vo.projectsControllerCreateProject({slug:i.trim(),description:c.trim()||void 0,repoUrl:f.trim()||void 0}),t("/settings/projects")}catch(k){_(k?.body?.detail||"Failed to create project")}finally{m(!1)}};return a.jsxs(te,{spacing:"6",className:"settings-subpage",children:[a.jsx(b,{tone:"muted",className:"settings-subpage__intro",children:"Add a project tag and optional repository link."}),a.jsx(Fe,{padding:"5",className:"settings-panel-card",children:a.jsx("form",{onSubmit:v,children:a.jsxs(te,{spacing:"4",children:[a.jsxs(te,{spacing:"2",children:[a.jsx("label",{htmlFor:"project-slug",className:"login-label",children:a.jsx(b,{size:"2",weight:"medium",children:"Slug"})}),a.jsx("input",{id:"project-slug",value:i,onChange:j=>l(j.target.value),className:"login-input",placeholder:"taico",required:!0,disabled:g})]}),a.jsxs(te,{spacing:"2",children:[a.jsx("label",{htmlFor:"project-description",className:"login-label",children:a.jsx(b,{size:"2",weight:"medium",children:"Description"})}),a.jsx("textarea",{id:"project-description",value:c,onChange:j=>u(j.target.value),className:"login-input",placeholder:"Project description",rows:3,disabled:g,style:{resize:"vertical",fontFamily:"inherit"}})]}),a.jsxs(te,{spacing:"2",children:[a.jsx("label",{htmlFor:"project-repo-url",className:"login-label",children:a.jsx(b,{size:"2",weight:"medium",children:"Repository URL"})}),a.jsx("input",{id:"project-repo-url",type:"url",value:f,onChange:j=>x(j.target.value),className:"login-input",placeholder:"https://github.com/username/repo",disabled:g})]}),y?a.jsx(Zt,{size:"2",weight:"medium",children:y}):null,a.jsxs(Mt,{justify:"end",spacing:"3",children:[a.jsx(ue,{type:"button",variant:"secondary",size:"md",onClick:()=>t("/settings/projects"),disabled:g,children:"Cancel"}),a.jsx(ue,{type:"submit",variant:"primary",size:"md",disabled:g||!i.trim(),children:g?"Creating...":"Create project"})]})]})})})]})}function n1(){const{setSectionTitle:n}=js(),[t,i]=h.useState([]),[l,c]=h.useState(""),[u,f]=h.useState(!0),[x,g]=h.useState(""),[m,y]=h.useState(null),[_,v]=h.useState(null);h.useEffect(()=>{if(!_)return;const T=window.setTimeout(()=>{v(R=>R?.providerId===_.providerId?null:R)},2400);return()=>window.clearTimeout(T)},[_]),h.useEffect(()=>{n("Chat Settings"),j()},[]);const j=async()=>{f(!0);try{const T=await Ar.chatProvidersControllerListChatProviders();i(T)}catch(T){c(T?.body?.detail||"Failed to load chat settings")}finally{f(!1)}},k=async T=>{if(!x.trim()){c("Please enter an API key");return}c(""),v(null);try{await Ar.chatProvidersControllerUpdateChatProvider(T,{apiKey:x}),v({providerId:T,action:"configure",message:"Config updated"}),y(null),g(""),await j()}catch(R){c(R?.body?.detail||"Failed to configure provider")}},E=async T=>{if(!t.find(z=>z.id===T)?.isConfigured){c("Please configure the provider first");return}c(""),v(null);try{await Ar.chatProvidersControllerSetActiveChatProvider({providerId:T}),v({providerId:T,action:"activate",message:"Now active"}),await j()}catch(z){c(z?.body?.detail||"Failed to set active provider")}},w=async T=>{c(""),v(null);try{await Ar.chatProvidersControllerDeactivateActiveChatProvider(),v({providerId:T,action:"deactivate",message:"Deactivated"}),await j()}catch(R){c(R?.body?.detail||"Failed to deactivate provider")}};return u?a.jsx(te,{spacing:"6",className:"settings-subpage",children:a.jsx(b,{children:"Loading..."})}):a.jsxs(te,{spacing:"6",className:"settings-subpage",children:[a.jsx(b,{tone:"muted",className:"settings-subpage__intro",children:"Configure chat providers for thread conversations."}),l&&a.jsx(Zt,{size:"2",weight:"medium",children:l}),t.length===0?a.jsx(Fe,{padding:"5",className:"settings-panel-card",children:a.jsx(b,{tone:"muted",children:"No chat providers available. OpenAI provider should be created automatically."})}):t.map(T=>a.jsx(Fe,{padding:"5",className:"settings-panel-card",children:a.jsxs(te,{spacing:"4",children:[a.jsx(Mt,{justify:"space-between",align:"center",children:a.jsxs(te,{spacing:"1",className:"settings-chat__header-copy",children:[a.jsxs("div",{className:"settings-chat__title-row",children:[a.jsx(b,{size:"4",weight:"semibold",children:T.name}),T.isActive?a.jsx("span",{className:"settings-chat__active-indicator",children:"Active"}):null]}),T.type==="openai"?a.jsxs(b,{size:"1",tone:"muted",children:["You can get an API key from"," ",a.jsx("a",{href:"https://platform.openai.com/api-keys",target:"_blank",rel:"noopener noreferrer",className:"settings-chat__helper-link",children:"platform.openai.com/api-keys"})]}):T.type==="adk"?a.jsx(b,{size:"1",tone:"muted",children:"Uses Google AI environment variables (GOOGLE_API_KEY or Vertex AI config). No key stored here."}):null]})}),m===T.id&&T.type!=="adk"?a.jsxs(te,{spacing:"3",children:[a.jsxs(te,{spacing:"2",children:[a.jsx(b,{size:"2",weight:"medium",children:"Enter API Key"}),a.jsx("input",{type:"password",value:x,onChange:R=>g(R.target.value),className:"login-input",placeholder:"sk-...",autoFocus:!0}),a.jsx(b,{size:"1",tone:"muted",children:"Your API key will be stored securely"})]}),a.jsxs(Mt,{spacing:"2",children:[a.jsx(ue,{variant:"primary",size:"sm",onClick:()=>k(T.id),disabled:!x.trim(),children:"Save"}),a.jsx(ue,{variant:"secondary",size:"sm",onClick:()=>{y(null),g("")},children:"Cancel"})]})]}):a.jsx(Mt,{spacing:"2",children:(()=>{const R=_?.providerId===T.id&&_.action==="configure"?_.message:null,z=_?.providerId===T.id&&_.action==="activate"?_.message:null,L=_?.providerId===T.id&&_.action==="deactivate"?_.message:null,M=z||L,N=!T.isActive&&!T.isConfigured,A=M?"primary":T.isActive?"danger":"primary",I=M||(T.isActive?"Deactivate":"Set Active"),Q=T.isActive?()=>w(T.id):()=>E(T.id),Z=N?"Configure the provider first to set it as active":"";return a.jsxs(a.Fragment,{children:[T.type!=="adk"&&a.jsx(ue,{variant:R?"primary":"secondary",size:"sm",onClick:()=>y(T.id),children:R||(T.isConfigured?"Update Config":"Configure")}),a.jsx("span",{className:"settings-chat__action-wrapper",title:Z,children:a.jsx(ue,{variant:A,size:"sm",onClick:Q,disabled:N,className:"settings-chat__action-button","data-feedback":z?"active":L?"deactivated":null,children:I})})]})})()})]})},T.id))]})}function a1(){const{setSectionTitle:n}=js(),[t,i]=h.useState(!1),[l,c]=h.useState(!1),[u,f]=h.useState(null),[x,g]=h.useState(""),[m,y]=h.useState("");h.useEffect(()=>{n("Import / Export")},[n]);const _=h.useMemo(()=>`${Ba}/api/v1/context/blocks/export`,[]),v=h.useMemo(()=>`${Ba}/api/v1/context/blocks/import`,[]),j=async()=>{i(!0),g(""),y("");try{const E=await fetch(_,{method:"GET",credentials:"include"});if(!E.ok)throw new Error("Failed to export blocks");const w=await E.blob(),R=E.headers.get("content-disposition")?.match(/filename="?([^";]+)"?/)?.[1]||"context-blocks.zip",z=window.URL.createObjectURL(w),L=document.createElement("a");L.href=z,L.download=R,document.body.appendChild(L),L.click(),L.remove(),window.URL.revokeObjectURL(z),y("Blocks export downloaded successfully.")}catch{g("Failed to export blocks. Please try again.")}finally{i(!1)}},k=async()=>{if(!u){g("Please choose a .zip file first."),y("");return}c(!0),g(""),y("");try{const E=new FormData;E.append("file",u);const w=await fetch(v,{method:"POST",credentials:"include",body:E}),T=await w.json().catch(()=>({}));if(!w.ok)throw new Error("Failed to import blocks");const R=T.importedCount??0;y(`Import complete. ${R} block${R===1?"":"s"} created.`),f(null)}catch{g("Failed to import blocks. Verify the archive format and try again.")}finally{c(!1)}};return a.jsxs(te,{spacing:"6",className:"settings-subpage",children:[a.jsx(b,{tone:"muted",className:"settings-subpage__intro",children:"Import and export workspace data. Blocks are available now; task support can be added in this section later."}),x?a.jsx(Zt,{size:"2",weight:"medium",children:x}):null,m?a.jsx(b,{size:"2",className:"settings-data__success",children:m}):null,a.jsx(Fe,{padding:"5",className:"settings-panel-card",children:a.jsxs(te,{spacing:"4",children:[a.jsxs(te,{spacing:"1",children:[a.jsx(b,{size:"4",weight:"semibold",children:"Export Blocks"}),a.jsx(b,{tone:"muted",children:"Download all context blocks as a nested markdown zip archive."})]}),a.jsx(Mt,{justify:"end",children:a.jsx(ue,{variant:"primary",size:"sm",onClick:j,disabled:t,children:t?"Exporting...":"Export Blocks"})})]})}),a.jsx(Fe,{padding:"5",className:"settings-panel-card",children:a.jsxs(te,{spacing:"4",children:[a.jsxs(te,{spacing:"1",children:[a.jsx(b,{size:"4",weight:"semibold",children:"Import Blocks"}),a.jsx(b,{tone:"muted",children:"Upload a blocks archive to create context blocks in this workspace."})]}),a.jsx("label",{htmlFor:"blocks-import-file",className:"settings-data__file-label",children:"Select archive (.zip)"}),a.jsx("input",{id:"blocks-import-file",type:"file",accept:".zip,application/zip",onChange:E=>f(E.target.files?.[0]??null),className:"settings-data__file-input"}),a.jsx(b,{size:"1",tone:"muted",children:u?`Selected: ${u.name}`:"No file selected"}),a.jsx(Mt,{justify:"end",children:a.jsx(ue,{variant:"secondary",size:"sm",onClick:k,disabled:l,children:l?"Importing...":"Import Blocks"})})]})})]})}function r1(){const{setSectionTitle:n}=js(),{workers:t,isLoading:i,error:l}=Eh(),[c,u]=h.useState(null);h.useEffect(()=>{n("Workers Settings")},[]);const x=`npx -y @taico/worker --serverurl ${`${window.location.protocol}//${window.location.host}`}`,g=y=>{const _=new Date(y),j=new Date().getTime()-_.getTime(),k=120*1e3;return j<=k},m=async()=>{try{await navigator.clipboard.writeText(x),u("Copied"),window.setTimeout(()=>u(null),1800)}catch{u("Copy failed"),window.setTimeout(()=>u(null),1800)}};return i?a.jsx(te,{spacing:"6",className:"settings-subpage",children:a.jsx(b,{children:"Loading..."})}):a.jsxs(te,{spacing:"6",className:"settings-subpage",children:[a.jsx(b,{tone:"muted",className:"settings-subpage__intro",children:"Workers execute tasks in the background. Configure workers to enable automated task execution."}),l?a.jsx(Zt,{size:"2",weight:"medium",children:l}):null,a.jsx(Fe,{padding:"5",className:"settings-panel-card",children:a.jsxs(te,{spacing:"4",children:[a.jsxs(te,{spacing:"1",children:[a.jsx(b,{size:"4",weight:"semibold",children:"Configure a New Worker"}),a.jsx(b,{tone:"muted",children:"Run this command in your terminal to start a new worker:"})]}),a.jsxs("div",{className:"settings-workers__command-container",children:[a.jsx("code",{className:"settings-workers__command",children:x}),a.jsx(ue,{className:"settings-workers__copy-button",variant:"secondary",size:"sm",onClick:m,children:c??"Copy"})]}),a.jsx(b,{size:"1",tone:"muted",children:"The worker will automatically register and appear in the list below when it connects."})]})}),a.jsxs(te,{spacing:"3",children:[a.jsxs(b,{size:"4",weight:"semibold",children:["Registered Workers (",t.length,")"]}),t.length===0?a.jsx(Fe,{padding:"5",className:"settings-panel-card",children:a.jsx(b,{tone:"muted",children:"No workers registered yet. Run the command above to start your first worker."})}):t.map(y=>{const _=g(y.lastSeenAt),j=new Date(y.lastSeenAt).toLocaleString();return a.jsx(Fe,{padding:"5",className:"settings-panel-card",children:a.jsxs(te,{spacing:"3",children:[a.jsx(Mt,{justify:"space-between",align:"center",children:a.jsxs(te,{spacing:"1",children:[a.jsxs("div",{className:"settings-workers__title-row",children:[a.jsx(b,{size:"3",weight:"semibold",children:"Worker"}),_?a.jsx(ST,{className:"settings-workers__status-icon settings-workers__status-icon--connected",size:18,strokeWidth:1.5,absoluteStrokeWidth:!0,"aria-label":"Connected"}):a.jsx(bT,{className:"settings-workers__status-icon settings-workers__status-icon--disconnected",size:18,strokeWidth:1.5,absoluteStrokeWidth:!0,"aria-label":"Disconnected"})]}),a.jsxs(b,{size:"1",tone:"muted",children:["ID: ",y.id]}),a.jsxs(b,{size:"1",tone:"muted",children:["Version: ",y.workerVersion??"Unknown"]}),a.jsxs(b,{size:"1",tone:"muted",children:["Last seen: ",j]})]})}),y.harnesses&&y.harnesses.length>0&&a.jsxs(te,{spacing:"1",children:[a.jsx(b,{size:"2",weight:"medium",children:"Harnesses:"}),a.jsx("div",{className:"settings-workers__harnesses",children:y.harnesses.map(k=>a.jsx("span",{className:"settings-workers__harness-badge",children:k},k))})]})]})},y.id)})]})]})}function i1(){const{setSectionTitle:n}=js();return jt(),h.useEffect(()=>{n("AI Providers")},[]),a.jsxs(te,{spacing:"6",className:"settings-subpage",children:[a.jsx(b,{tone:"muted",className:"settings-subpage__intro",children:"View usage and quota information for AI providers."}),a.jsx(Fe,{padding:"5",className:"settings-panel-card",children:a.jsxs(te,{spacing:"4",children:[a.jsx(Mt,{justify:"space-between",align:"center",children:a.jsxs(te,{spacing:"1",children:[a.jsx(b,{size:"4",weight:"semibold",children:"OpenAI"}),a.jsx(b,{size:"1",tone:"muted",children:"Codex and GPT models"})]})}),a.jsx(te,{spacing:"2",children:a.jsx(Mt,{spacing:"2",children:a.jsx(ue,{variant:"secondary",size:"sm",onClick:()=>window.open("https://chatgpt.com/codex/cloud/settings/usage","_blank","noopener,noreferrer"),children:"See usage"})})})]})}),a.jsx(Fe,{padding:"5",className:"settings-panel-card",children:a.jsxs(te,{spacing:"4",children:[a.jsx(Mt,{justify:"space-between",align:"center",children:a.jsxs(te,{spacing:"1",children:[a.jsx(b,{size:"4",weight:"semibold",children:"Anthropic"}),a.jsx(b,{size:"1",tone:"muted",children:"Claude models"})]})}),a.jsx(te,{spacing:"2",children:a.jsx(Mt,{spacing:"2",children:a.jsx(ue,{variant:"secondary",size:"sm",onClick:()=>window.open("https://claude.ai/settings/usage","_blank","noopener,noreferrer"),children:"See usage"})})})]})})]})}function l1(){const{setSectionTitle:n}=js(),{user:t,isLoading:i}=us(),[l,c]=h.useState([]),[u,f]=h.useState(""),[x,g]=h.useState(Nr.role.STANDARD),[m,y]=h.useState(""),[_,v]=h.useState(""),[j,k]=h.useState(!1),[E,w]=h.useState(!1);h.useEffect(()=>{n("User Management")},[n]);const T=t?.role==="admin";h.useEffect(()=>{i||!T||R()},[i,T]);const R=async()=>{if(T){k(!0),y("");try{const N=await es.webAuthControllerListUsers();c(N)}catch(N){y(No(N,"Failed to load users."))}finally{k(!1)}}},z=async N=>{N.preventDefault(),w(!0),y(""),v("");try{await es.webAuthControllerCreateUser({email:u,role:x}),f(""),g(Nr.role.STANDARD),v("User created. They can use Create account on the login screen to set their profile and password."),await R()}catch(A){y(No(A,"Failed to create user."))}finally{w(!1)}},L=async N=>{y(""),v("");try{await es.webAuthControllerResetUserPassword(N.id),v(`${N.email} can now set a new password from the login screen.`),await R()}catch(A){y(No(A,"Failed to reset password."))}},M=async N=>{if(window.confirm(`Disable login for ${N.email}?`)){y(""),v("");try{await es.webAuthControllerDeleteUser(N.id),v(`${N.email} has been deactivated.`),await R()}catch(A){y(No(A,"Failed to delete user."))}}};return i?a.jsx(Fe,{padding:"5",children:a.jsx(b,{tone:"muted",children:"Loading user management..."})}):T?a.jsxs("div",{className:"settings-users-page",children:[a.jsx(Fe,{padding:"5",className:"settings-users-page__hero",children:a.jsxs(te,{spacing:"2",children:[a.jsx("span",{className:"settings-users-page__hero-icon","aria-hidden":"true",children:a.jsx(KT,{size:20})}),a.jsx(b,{size:"5",weight:"bold",children:"User management"}),a.jsx(b,{tone:"muted",children:"Invite human users, manage roles, reset passwords, and disable access."})]})}),a.jsx(Fe,{padding:"5",children:a.jsx("form",{onSubmit:z,children:a.jsxs(te,{spacing:"4",children:[a.jsxs(te,{spacing:"1",children:[a.jsx(b,{size:"3",weight:"semibold",children:"Create user"}),a.jsx(b,{size:"1",tone:"muted",children:"New users receive access by setting up their account from the login screen."})]}),a.jsxs("div",{className:"settings-users-page__create-grid",children:[a.jsxs(te,{spacing:"2",children:[a.jsx("label",{className:"login-label",htmlFor:"managed-user-email",children:a.jsx(b,{size:"2",weight:"medium",children:"Email"})}),a.jsx("input",{id:"managed-user-email",className:"login-input",type:"email",value:u,onChange:N=>f(N.target.value),placeholder:"name@work.com",required:!0,disabled:E})]}),a.jsxs(te,{spacing:"2",children:[a.jsx("label",{className:"login-label",htmlFor:"managed-user-role",children:a.jsx(b,{size:"2",weight:"medium",children:"Role"})}),a.jsxs("select",{id:"managed-user-role",className:"login-input",value:x,onChange:N=>g(N.target.value),disabled:E,children:[a.jsx("option",{value:Nr.role.STANDARD,children:"Normal user"}),a.jsx("option",{value:Nr.role.ADMIN,children:"Admin"})]})]}),a.jsxs(ue,{type:"submit",variant:"primary",disabled:E,className:"settings-users-page__create-button",children:[a.jsx(e0,{size:16}),E?"Creating...":"Create user"]})]}),_?a.jsx(b,{size:"2",tone:"muted",children:_}):null,m?a.jsx(Zt,{size:"2",weight:"medium",children:m}):null]})})}),a.jsxs(Fe,{padding:"0",className:"settings-users-page__list-card",children:[a.jsxs("div",{className:"settings-users-page__list-header",children:[a.jsx(b,{size:"3",weight:"semibold",children:"Users"}),a.jsx(ue,{variant:"secondary",size:"sm",onClick:R,disabled:j,children:j?"Refreshing...":"Refresh"})]}),a.jsxs("div",{className:"settings-users-page__list",children:[l.map(N=>a.jsxs("div",{className:"settings-users-page__row",children:[a.jsxs("div",{className:"settings-users-page__identity",children:[a.jsx(b,{size:"2",weight:"semibold",children:N.displayName}),a.jsxs(b,{size:"1",tone:"muted",children:[N.email," · @",N.slug]})]}),a.jsxs("div",{className:"settings-users-page__badges",children:[a.jsx("span",{className:"settings-users-page__badge",children:N.role==="admin"?"Admin":"Normal"}),a.jsx("span",{className:`settings-users-page__badge ${N.isActive?"settings-users-page__badge--active":"settings-users-page__badge--inactive"}`,children:N.isActive?"Active":"Inactive"}),N.passwordSetupPending?a.jsx("span",{className:"settings-users-page__badge settings-users-page__badge--pending",children:"Setup pending"}):null]}),a.jsxs("div",{className:"settings-users-page__actions",children:[a.jsx(ue,{variant:"secondary",size:"sm",onClick:()=>L(N),disabled:!N.isActive,children:"Reset password"}),a.jsx(ue,{variant:"secondary",size:"sm",onClick:()=>M(N),disabled:!N.isActive||N.actorId===t?.actorId,children:"Delete"})]})]},N.id)),!j&&l.length===0?a.jsx(b,{tone:"muted",className:"settings-users-page__empty",children:"No users found."}):null]})]})]}):a.jsx(Fe,{padding:"5",children:a.jsxs(te,{spacing:"2",children:[a.jsx(b,{size:"4",weight:"semibold",children:"Admin access required"}),a.jsx(b,{tone:"muted",children:"Only admin users can manage user accounts."})]})})}function No(n,t){return n?.body?.detail||n?.body?.title||n?.message||t}function o1({step:n,isCompleted:t,isCurrent:i,isLast:l,isExpanded:c,onToggle:u}){return a.jsxs("div",{className:"walkthrough-step",children:[a.jsxs("div",{className:"walkthrough-step-rail",children:[a.jsx("div",{className:["walkthrough-step-dot",t?"walkthrough-step-dot--completed":"",i?"walkthrough-step-dot--current":""].filter(Boolean).join(" "),children:t&&a.jsx("svg",{width:"10",height:"8",viewBox:"0 0 10 8",fill:"none","aria-hidden":"true",children:a.jsx("path",{d:"M1 4L3.5 6.5L9 1",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),!l&&a.jsx("div",{className:["walkthrough-step-connector",t?"walkthrough-step-connector--completed":""].filter(Boolean).join(" ")})]}),a.jsxs("div",{className:"walkthrough-step-body",children:[a.jsx("button",{className:"walkthrough-step-header",onClick:u,"aria-expanded":c,children:a.jsx(b,{size:"2",weight:i?"semibold":"medium",className:t?"walkthrough-label-done":"",children:n.label})}),c&&a.jsxs("div",{className:"walkthrough-step-detail",children:[a.jsx(b,{size:"2",tone:"muted",as:"p",className:"walkthrough-step-description",children:n.description}),a.jsx(Mn,{to:n.href,className:"walkthrough-step-cta",children:"Go →"})]})]})]})}function c1(){const{setSectionTitle:n}=js(),{user:t,refreshAuth:i}=us(),{status:l,isLoading:c}=tv(),[u,f]=h.useState(new Set),x=h.useRef(!1),g=h.useRef(!1);jt(),h.useEffect(()=>{n("Setup walkthrough")},[n]),h.useEffect(()=>{g.current||!t||!l||t.onboardingDisplayMode==="OFF"&&l.completedCount<l.totalCount&&(g.current=!0,_h.WalkthroughController_acknowledge().then(()=>i()).catch(console.error))},[t,l,i]),h.useEffect(()=>{if(!l||x.current)return;x.current=!0;const j=l.steps.find(k=>!k.completed);j&&f(new Set([j.id]))},[l]);const m=j=>{f(k=>{const E=new Set(k);return E.has(j)?E.delete(j):E.add(j),E})},y=l?.completedCount??0,_=l?.totalCount??8,v=l?.steps.findIndex(j=>!j.completed)??-1;return a.jsx("div",{className:"walkthrough-page",children:a.jsxs(te,{spacing:"5",className:"walkthrough-page-inner",children:[a.jsxs(te,{spacing:"1",children:[a.jsx(b,{size:"2",tone:"muted",as:"p",children:"Complete these steps to get the most out of Taico."}),a.jsxs(b,{size:"2",weight:"semibold",children:[y," / ",_," completed"]})]}),c?a.jsx(b,{size:"2",tone:"muted",children:"Loading..."}):a.jsx("div",{className:"walkthrough-track",children:l?.steps.map((j,k)=>a.jsx(o1,{step:j,isCompleted:j.completed,isCurrent:k===v,isLast:k===l.steps.length-1,isExpanded:u.has(j.id),onToggle:()=>m(j.id)},j.id))})]})})}function u1(){return a.jsx(U0,{children:a.jsx(dn,{children:a.jsxs(Se,{element:a.jsx(Y0,{}),children:[a.jsx(Se,{path:"/home",element:a.jsx(G0,{})}),a.jsx(Se,{path:"/settings",element:a.jsx(Xw,{})}),a.jsx(Se,{path:"/settings/account",element:a.jsx(Jw,{})}),a.jsx(Se,{path:"/settings/appearance",element:a.jsx(e1,{})}),a.jsx(Se,{path:"/settings/projects",element:a.jsx(t1,{})}),a.jsx(Se,{path:"/settings/projects/new",element:a.jsx(s1,{})}),a.jsx(Se,{path:"/settings/chat",element:a.jsx(n1,{})}),a.jsx(Se,{path:"/settings/workers",element:a.jsx(r1,{})}),a.jsx(Se,{path:"/settings/ai-providers",element:a.jsx(i1,{})}),a.jsx(Se,{path:"/settings/data",element:a.jsx(a1,{})}),a.jsx(Se,{path:"/settings/users",element:a.jsx(l1,{})}),a.jsx(Se,{path:"/walkthrough",element:a.jsx(c1,{})})]})})})}const d1="/",h1=window.location.origin,ha=new Ws({baseUrl:h1,credentials:"include"}),Qt=ha.task;ha.actors;const f1=ha.meta,p1=ha.metaProjects;ha.task,ha.actors,ha.meta,ha.metaProjects;const g1=pa("/tasks"),m1=100,Ho="tasks.selectedProjectId";function y1(){try{return localStorage.getItem(Ho)}catch{return null}}function zd(n,t){return n.tags.some(i=>i.name===t)}const x1=()=>{const[n,t]=h.useState(!0),[i,l]=h.useState(!1),[c,u]=h.useState(null),[f,x]=h.useState([]),[g,m]=h.useState([]),[y,_]=h.useState([]),[v,j]=h.useState(!1),[k,E]=h.useState(()=>y1()),[w,T]=h.useState(null),[R,z]=h.useState(!1),[L,M]=h.useState({}),N=h.useRef([]),A=h.useRef(null),I=h.useRef(!1),Q=h.useRef(0),Z=h.useMemo(()=>k?y.find(ce=>ce.id===k)??null:null,[y,k]),U=Z?.tagName??null,le=!k||!!Z;h.useEffect(()=>{N.current=f},[f]),h.useEffect(()=>{A.current=U},[U]),h.useEffect(()=>{I.current=le},[le]);const W=h.useCallback(ce=>{E(ce);try{ce?localStorage.setItem(Ho,ce):localStorage.removeItem(Ho)}catch(Y){console.error("Failed to persist selected task project",Y)}},[]),oe=h.useCallback(async()=>{try{const ce=await p1.ProjectsController_getAllProjects();_(ce)}catch(ce){console.error("Failed to load projects",ce),_([])}finally{j(!0)}},[]),me=ce=>{if(!ce.message){console.warn("Received task activity event without message, skipping",ce);return}M(Y=>({...Y,[ce.taskId]:ce}))},B=ce=>{M(Y=>{const{[ce]:fe,...K}=Y;return K})},se=ce=>[...ce].sort((Y,fe)=>{const K=new Date(Y.updatedAt).getTime();return new Date(fe.updatedAt).getTime()-K}),ge=(ce,Y)=>{const fe=new Set(Y.map(K=>K.id));return se([...Y,...ce.filter(K=>!fe.has(K.id))])},Ee=ce=>{m(Y=>ge(Y,[ce]))},Ce=async ce=>{const Y=A.current,fe=Y?{...ce,tagNames:Array.from(new Set([...ce.tagNames??[],Y]))}:ce;return await Qt.TasksController_createTask({body:fe})},D=async({taskId:ce})=>await Qt.TasksController_deleteTask({id:ce}),H=async({taskId:ce,comment:Y})=>await Qt.TasksController_addComment({id:ce,body:{content:Y}}),he=async({taskId:ce,assigneeActorId:Y})=>{const fe={assigneeActorId:Y};return await Qt.TasksController_assignTask({id:ce,body:fe})},pe=async({taskId:ce})=>await Qt.TasksController_assignTaskToMe({id:ce}),G=async({taskId:ce,inputRequestId:Y,answer:fe})=>await Qt.TasksController_answerInputRequest({id:ce,inputRequestId:Y,body:{answer:fe}}),ae=async()=>{if(!I.current)return;const ce=Q.current+1;Q.current=ce;const Y=A.current;t(!0),u(null);try{const fe=await Qt.TasksController_listTasks({page:1,limit:m1,tag:Y??void 0});if(Q.current!==ce||A.current!==Y)return;const K=Y?fe.items.filter(je=>zd(je,Y)):fe.items;x(je=>ge(je,K))}catch(fe){if(Q.current!==ce||A.current!==Y)return;u(fe instanceof Error?fe.message:"Failed to load tasks")}finally{Q.current===ce&&A.current===Y&&(l(!0),t(!1))}},J=h.useCallback(async ce=>{try{const Y=await Qt.TasksController_getTask({id:ce});return Ee(Y),x(fe=>xe(Y)?fe.some(K=>K.id===Y.id)?se(fe.map(K=>K.id===Y.id?Y:K)):se([Y,...fe]):fe.filter(K=>K.id!==Y.id)),Y}catch(Y){return console.error("Failed to fetch task by ID",Y),null}},[]),xe=ce=>{const Y=A.current;return!Y||zd(ce,Y)},Re=ce=>{const Y=A.current;return Y?N.current.some(fe=>fe.id===ce&&zd(fe,Y)):!0},Qe=ce=>{if(Ee(ce),!xe(ce)){x(Y=>Y.filter(fe=>fe.id!==ce.id)),B(ce.id);return}x(Y=>Y.some(fe=>fe.id===ce.id)?se(Y.map(fe=>fe.id===ce.id?ce:fe)):se([ce,...Y]))},It=ce=>{x(Y=>Y.filter(fe=>fe.id!==ce)),m(Y=>Y.filter(fe=>fe.id!==ce)),B(ce)},nt=async(ce,Y)=>{try{const fe=await Qt.TasksController_getTask({id:ce});Qe(fe)}catch(fe){console.error(Y,fe)}},mt=()=>{const ce=Bs(g1,{transports:["websocket","polling"],withCredentials:!0});return ce.on("connect",()=>{console.log("Connected to websocket"),ce.emit("tasks.subscribe",{},Y=>{Y.ok?(console.log(Y),console.log("Subscribed to room:",Y.room),z(!0)):(console.error("Failed to subscribe to room"),z(!1))}),ae()}),ce.on("disconnect",()=>{console.log("WebSocket disconnected"),z(!1)}),ce.on(bs.TASK_CREATED,Y=>{console.log("task.created",Y),Qe(Y.payload)}),ce.on(bs.TASK_UPDATED,Y=>{console.log("task.updated",Y),Qe(Y.payload)}),ce.on(bs.TASK_DELETED,Y=>{console.log("task.deleted",Y),It(Y.payload.taskId)}),ce.on(bs.TASK_ASSIGNED,Y=>{console.log("task.assigned",Y),Qe(Y.payload)}),ce.on(bs.TASK_COMMENTED,async Y=>{console.log("task.commented",Y),await nt(Y.payload.taskId,"Failed to refresh task after comment")}),ce.on(bs.INPUT_REQUEST_ANSWERED,async Y=>{console.log("input.request.answered",Y),await nt(Y.payload.taskId,"Failed to refresh task after input request answer")}),ce.on(bs.TASK_STATUS_CHANGED,Y=>{console.log("task.status_changed",Y),Qe(Y.payload)}),ce.on(bs.TASK_ACTIVITY,Y=>{console.log("task.activity",Y),Re(Y.taskId)&&me(Y)}),T(ce),()=>{ce.close()}};return h.useEffect(()=>{oe()},[oe]),h.useEffect(()=>{const ce=Y=>{Y.key===Ho&&E(Y.newValue)};return window.addEventListener("storage",ce),()=>window.removeEventListener("storage",ce)},[]),h.useEffect(()=>{!v||!k||Z||W(null)},[v,Z,k,W]),h.useEffect(()=>le?(x([]),M({}),ae(),mt()):void 0,[le,U]),{isLoading:n,hasLoadedOnce:i,error:c,activityByTaskId:L,projects:y,projectsLoaded:v,selectedProjectId:k,selectedProject:Z,selectedProjectTag:U,setSelectedProjectId:W,tasks:f,detailTasks:g,getTaskById:J,createTask:Ce,deleteTask:D,addComment:H,assignTask:he,assignTaskToMe:pe,answerInputRequest:G,isConnected:R}},_e={NOT_STARTED:"NOT_STARTED",IN_PROGRESS:"IN_PROGRESS",FOR_REVIEW:"FOR_REVIEW",DONE:"DONE"},Zs={[_e.NOT_STARTED]:{path:"/tasks/not-started",label:"Queued",icon:TT},[_e.IN_PROGRESS]:{path:"/tasks/in-progress",label:"Building",icon:xT},[_e.FOR_REVIEW]:{path:"/tasks/in-review",label:"Review",icon:hT},[_e.DONE]:{path:"/tasks/done",label:"Shipped",icon:VT}},v1=[Zs[_e.NOT_STARTED],Zs[_e.IN_PROGRESS],Zs[_e.FOR_REVIEW],Zs[_e.DONE]],b1=()=>({[_e.NOT_STARTED]:{enteringIds:new Set,exitingTasks:[]},[_e.IN_PROGRESS]:{enteringIds:new Set,exitingTasks:[]},[_e.FOR_REVIEW]:{enteringIds:new Set,exitingTasks:[]},[_e.DONE]:{enteringIds:new Set,exitingTasks:[]}}),bv=h.createContext(null),_1=500,S1=4e3;function j1({children:n}){const{tasks:t,detailTasks:i,getTaskById:l,isLoading:c,hasLoadedOnce:u,error:f,isConnected:x,createTask:g,deleteTask:m,addComment:y,assignTask:_,assignTaskToMe:v,answerInputRequest:j,activityByTaskId:k,projects:E,projectsLoaded:w,selectedProjectId:T,selectedProject:R,selectedProjectTag:z,setSelectedProjectId:L}=x1(),[M,N]=h.useState(""),[A,I]=h.useState(0),Q=h.useRef(new Map),Z=h.useRef([]),U=h.useRef(new Map),le=h.useRef(0),[W,oe]=h.useState(0),{animationByStatus:me,globalEnteringIds:B,globalExitingTasks:se}=h.useMemo(()=>{const Ee=Date.now(),Ce=new Map(t.map(J=>[J.id,J])),D=Q.current,H=new Set(D.keys()),he=new Set(Ce.keys());if(Z.current=Z.current.filter(J=>J.expiresAt>Ee),H.size>0){const J={[_e.NOT_STARTED]:new Set,[_e.IN_PROGRESS]:new Set,[_e.FOR_REVIEW]:new Set,[_e.DONE]:new Set},xe={[_e.NOT_STARTED]:[],[_e.IN_PROGRESS]:[],[_e.FOR_REVIEW]:[],[_e.DONE]:[]},Re=new Set,Qe=[];for(const[nt,mt]of Ce){const ce=D.get(nt);ce?ce.status!==mt.status&&(xe[ce.status].push(ce),J[mt.status].add(nt)):(J[mt.status].add(nt),Re.add(nt))}for(const[nt,mt]of D)he.has(nt)||(xe[mt.status].push(mt),Qe.push(mt));(Object.values(J).some(nt=>nt.size>0)||Object.values(xe).some(nt=>nt.length>0))&&Z.current.push({enteringByStatus:J,exitingByStatus:xe,globalEntering:Re,globalExiting:Qe,expiresAt:Ee+_1})}Q.current=Ce;const pe=b1();let G=new Set,ae=[];for(const J of Z.current){for(const xe of Object.values(_e))J.enteringByStatus[xe].forEach(Re=>pe[xe].enteringIds.add(Re)),pe[xe].exitingTasks.push(...J.exitingByStatus[xe]);J.globalEntering.forEach(xe=>G.add(xe)),ae.push(...J.globalExiting)}return{animationByStatus:pe,globalEnteringIds:G,globalExitingTasks:ae}},[t,W]);h.useEffect(()=>{if(Z.current.length===0)return;const Ce=Math.min(...Z.current.map(H=>H.expiresAt))-Date.now();if(Ce<=0){oe(H=>H+1);return}const D=setTimeout(()=>{oe(H=>H+1)},Ce);return()=>clearTimeout(D)},[me,B,se]),h.useEffect(()=>{const Ee=U.current,Ce=new Map(t.map(H=>[H.id,H]));if(Ee.size===0){U.current=Ce;return}let D=!1;for(const[H,he]of Ce){const pe=Ee.get(H);if(pe&&pe.status!==_e.DONE&&he.status===_e.DONE){D=!0;break}}if(D){const H=Date.now();H-le.current>=S1&&(le.current=H,I(he=>he+1))}U.current=Ce},[t]);const ge=h.useMemo(()=>({tasks:t,detailTasks:i,getTaskById:l,createTask:g,deleteTask:m,addComment:y,assignTask:_,assignTaskToMe:v,answerInputRequest:j,isLoading:c,hasLoadedOnce:u,error:f,isConnected:x,sectionTitle:M,setSectionTitle:N,animationByStatus:me,globalEnteringIds:B,globalExitingTasks:se,activityByTaskId:k,shippedCelebrationTrigger:A,projects:E,projectsLoaded:w,selectedProjectId:T,selectedProject:R,selectedProjectTag:z,setSelectedProjectId:L}),[t,i,l,g,m,y,_,v,j,c,u,f,x,M,N,me,B,se,k,A,E,w,T,R,z,L]);return a.jsx(bv.Provider,{value:ge,children:n})}function qn(){const n=h.useContext(bv);if(!n)throw new Error("useTasksCtx must be used within <TasksProvider>");return n}function gt({title:n,onCancel:t,onSave:i,children:l,headerLeft:c,headerRight:u,closeMs:f=220}){const[x,g]=h.useState(!1),[m,y]=h.useState(!1);h.useEffect(()=>{requestAnimationFrame(()=>g(!0))},[]);function _(){g(!1),setTimeout(()=>t?.(),f)}async function v(){if(!(!i||m))try{y(!0),await i()&&_()}catch{}finally{y(!1)}}function j(k){if(!k.nativeEvent.isComposing){if(k.key==="Escape"){k.preventDefault(),_();return}k.key==="Enter"&&(!k.metaKey&&!k.ctrlKey||(k.preventDefault(),v()))}}return a.jsxs("div",{className:`pop-shell__overlay ${x?"pop-shell__overlay--open":""}`,children:[a.jsx("div",{className:"pop-shell__space",onClick:_}),a.jsxs("div",{className:`pop-shell__main-panel ${x?"pop-shell__main-panel--open":""}`,onKeyDown:j,children:[a.jsxs("div",{className:"pop-shell__main-title",children:[c??a.jsx("div",{onClick:_,children:a.jsx(b,{size:"4",weight:"normal",className:"pop-shell__main-title-button",children:"cancel"})}),a.jsx(b,{size:"4",weight:"medium",children:n}),u??a.jsx("div",{onClick:v,style:{opacity:m?.6:1,pointerEvents:m?"none":"auto"},children:a.jsx(b,{size:"4",weight:"normal",className:"pop-shell__main-title-button",children:m?"saving":"save"})})]}),a.jsx("div",{className:"pop-shell__main-content",children:l})]})]})}function By(n,t){try{const i=localStorage.getItem(n);if(i)return JSON.parse(i)}catch(i){console.error("Error loading draft from localStorage:",i)}return t}function Hr({key:n,defaultValue:t,debounceMs:i=500}){const l=h.useRef(t);h.useEffect(()=>{l.current=t},[t]);const[c,u]=h.useState(()=>By(n,t)),f=h.useRef(void 0);return h.useEffect(()=>{u(By(n,l.current))},[n]),h.useEffect(()=>(f.current&&clearTimeout(f.current),f.current=setTimeout(()=>{try{localStorage.setItem(n,JSON.stringify(c))}catch(g){console.error("Error saving draft to localStorage:",g)}},i),()=>{f.current&&clearTimeout(f.current)}),[c,n,i]),[c,u,()=>{try{localStorage.removeItem(n),u(l.current)}catch(g){console.error("Error clearing draft from localStorage:",g)}}]}const k1={title:"",description:""},Uy=n=>{n&&(n.style.height="auto",n.style.height=`${n.scrollHeight}px`)};function eh({onCancel:n,onSave:t}){const[i,l,c]=Hr({key:"new-task-draft",defaultValue:k1}),{title:u,description:f}=i,x=h.useRef(null),g=h.useRef(null),m=(v,j)=>{l({...i,[v]:j})};h.useEffect(()=>{x.current?.focus()},[]),h.useEffect(()=>{Uy(g.current)},[f]);function y(v){m("description",v.target.value),Uy(v.target)}async function _(){const v=await t({title:u,description:f});return v&&c(),v}return a.jsx(gt,{title:"Create a Task",onCancel:n,onSave:_,children:a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"new-task-pop__input-title",children:a.jsx("input",{className:"new-task-pop__input-title",ref:x,placeholder:"Title",value:u,onChange:v=>m("title",v.target.value),onKeyDown:v=>{v.key==="Enter"&&(v.preventDefault(),g.current?.focus())}})}),a.jsx("div",{className:"new-task-pop__input-description",children:a.jsx("textarea",{className:"new-task-pop__input-description",ref:g,placeholder:"Enter a description (optional)",value:f,onChange:y})})]})})}const Lt=n=>{const t=new Date(n),l=Math.round((new Date().getTime()-t.getTime())/(1e3*60));if(l<60)return`${Math.max(l,1)}m ago`;const c=Math.round(l/60);return c<24?`${c}h ago`:t.toLocaleDateString("en-US",{month:"short",day:"numeric"})};function Ki({task:n,animation:t,onClick:i,pulseKey:l,additionalTags:c}){const[u,f]=h.useState(!1),x=n.assigneeActor??n.createdByActor;h.useEffect(()=>{if(l==null)return;f(!0);const y=setTimeout(()=>f(!1),1e3);return()=>clearTimeout(y)},[l]);const g=n.tags.map(y=>({label:y.name}));n.comments.length&&g.push({label:`💬 ${n.comments.length}`}),n.artefacts.length&&g.push({label:`🔗 ${n.artefacts.length}`});const m=n.inputRequests.filter(y=>!y.resolvedAt).length;return m&&g.push({label:`✋ ${m}`}),c&&g.push(...c),a.jsxs(be,{leading:a.jsx(He,{name:x.displayName,size:"lg",src:x.avatarUrl||void 0}),topRight:Lt(n.updatedAt),tags:g,animation:t,highlight:n.inputRequests.filter(y=>!y.resolvedAt)?.length>0,onClick:i,children:[a.jsxs(b,{className:"pre",children:["#",n.id.slice(0,6)]}),a.jsx("div",{style:{minWidth:0,overflow:"hidden"},children:a.jsx(b,{weight:"bold",size:"3",tone:"default",children:a.jsxs("span",{className:"task-row__title",children:[a.jsx("span",{className:"task-row__titleText",children:n.name}),u?a.jsx("span",{className:"task-row__pulseDot","aria-hidden":!0}):null]})})}),a.jsx("div",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:n.description}),a.jsxs("div",{style:{fontSize:12},className:"text--tone-muted",children:[n.assignee?`Assigned: @${n.assignee}`:"unassigned"," · ",`Created by @${n.createdByActor.slug}`]})]})}function _v(n){const t=new Map,i=new Date;i.setHours(0,0,0,0);for(const l of n){const c=new Date(l.updatedAt);c.setHours(0,0,0,0);const u=c.toISOString().split("T")[0],f=c.getTime()===i.getTime();t.has(u)||t.set(u,{date:c,dateKey:u,tasks:[],isToday:f}),t.get(u).tasks.push(l)}return Array.from(t.values()).sort((l,c)=>c.date.getTime()-l.date.getTime())}function Sv(n){const t=new Date;t.setHours(0,0,0,0);const i=new Date(t);i.setDate(i.getDate()-1);const l=new Date(n);if(l.setHours(0,0,0,0),l.getTime()===t.getTime())return"Today";if(l.getTime()===i.getTime())return"Yesterday";const c=t.getFullYear(),u=l.getFullYear(),x=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][l.getMonth()],g=l.getDate();return u===c?`${x} ${g}`:`${x} ${g}, ${u}`}function T1({date:n,taskCount:t,isExpanded:i,onClick:l}){const c=Sv(n),u=i?"▼":"▶";return a.jsx(be,{onClick:l,className:"day-summary-row",children:a.jsxs("div",{className:"day-summary-row__content",children:[a.jsx("span",{className:"day-summary-row__chevron",children:u}),a.jsx(b,{weight:"bold",size:"3",children:c}),a.jsxs(b,{size:"2",tone:"muted",className:"day-summary-row__count",children:["· ",t," ",t===1?"task":"tasks"," shipped"]})]})})}function w1({tasks:n,enteringIds:t,exitingTasks:i,groupByDay:l=!1}){const c=ze(),{activityByTaskId:u}=qn(),[f,x]=h.useState(new Set),g=new Set(i.map(v=>v.id)),m=[...n,...i].sort((v,j)=>new Date(j.updatedAt).getTime()-new Date(v.updatedAt).getTime());if(!l)return a.jsx(ye,{children:m.map(v=>{const j=g.has(v.id),k=t.has(v.id);let E;j?E="exiting":k&&(E="entering");const w=u[v.id];return a.jsx(Ki,{task:v,animation:E,pulseKey:w?.ts,onClick:()=>c(`/tasks/task/${v.id}`)},j?`exiting-${v.id}`:v.id)})});const y=_v(m),_=v=>{x(j=>{const k=new Set(j);return k.has(v)?k.delete(v):k.add(v),k})};return a.jsx(ye,{children:y.map(v=>{if(v.isToday)return v.tasks.map(k=>{const E=g.has(k.id),w=t.has(k.id);let T;E?T="exiting":w&&(T="entering");const R=u[k.id];return a.jsx(Ki,{task:k,animation:T,pulseKey:R?.ts,onClick:()=>c(`/tasks/task/${k.id}`)},E?`exiting-${k.id}`:k.id)});const j=f.has(v.dateKey);return a.jsxs("div",{children:[a.jsx(T1,{date:v.date,taskCount:v.tasks.length,isExpanded:j,onClick:()=>_(v.dateKey)}),j&&v.tasks.map(k=>{const E=g.has(k.id),w=t.has(k.id);let T;E?T="exiting":w&&(T="entering");const R=u[k.id];return a.jsx(Ki,{task:k,animation:T,pulseKey:R?.ts,onClick:()=>c(`/tasks/task/${k.id}`)},E?`exiting-${k.id}`:k.id)})]},v.dateKey)})})}function Po({task:n,animation:t,onClick:i,pulseKey:l}){const c=n.assigneeActor??n.createdByActor,u=n.tags.map(x=>({label:x.name}));n.comments.length&&u.push({label:`💬 ${n.comments.length}`});const f=n.inputRequests.filter(x=>!x.resolvedAt).length;return f&&u.push({label:`✋ ${f}`}),n.artefacts.length&&u.push({label:`🔗 ${n.artefacts.length}`}),a.jsxs(Gx,{leading:a.jsx(He,{name:c.displayName,size:"md",src:c.avatarUrl||void 0}),topRight:Lt(n.updatedAt),tags:u,animation:t,onClick:i,pulseKey:l,highlight:n.inputRequests.filter(x=>!x.resolvedAt)?.length>0,footer:a.jsxs(a.Fragment,{children:[a.jsxs("span",{className:"row-detail truncate",children:["#",n.id.slice(0,6)]}),a.jsx("span",{className:"row-detail truncate",children:n.assigneeActor?`Assigned: @${n.assigneeActor.slug}`:"unassigned"})]}),children:[a.jsx("div",{className:"row-title truncate",children:n.name}),a.jsx("div",{className:"row-subtitle truncate",children:n.description})]})}function E1({date:n,taskCount:t,isExpanded:i,onClick:l}){const c=Sv(n),u=i?"▼":"▶";return a.jsxs("div",{className:"day-summary-card__content",onClick:l,children:[a.jsx("span",{className:"day-summary-card__chevron",children:u}),a.jsxs("span",{className:"day-summary-card__text",children:[a.jsx("strong",{children:c})," · ",t," ",t===1?"task":"tasks"]})]})}function C1({tasks:n,enteringIds:t,exitingTasks:i,groupByDay:l=!1}){const c=ze(),{activityByTaskId:u}=qn(),[f,x]=h.useState(new Set),g=new Set(i.map(j=>j.id)),m=[...n,...i].sort((j,k)=>new Date(k.updatedAt).getTime()-new Date(j.updatedAt).getTime());if(!l)return a.jsx(a.Fragment,{children:m.map(j=>{const k=g.has(j.id),E=t.has(j.id),w=u[j.id];let T;return k?T="exiting":E&&(T="entering"),a.jsx(Po,{task:j,animation:T,onClick:()=>c(`/tasks/task/${j.id}`),pulseKey:w?.ts},k?`exiting-${j.id}`:j.id)})});const y=[],_=_v(m),v=j=>{x(k=>{const E=new Set(k);return E.has(j)?E.delete(j):E.add(j),E})};return _.forEach(j=>{if(j.isToday){j.tasks.forEach(E=>{const w=g.has(E.id),T=t.has(E.id),R=u[E.id];let z;w?z="exiting":T&&(z="entering");const L=a.jsx(Po,{task:E,animation:z,onClick:()=>c(`/tasks/task/${E.id}`),pulseKey:R?.ts},w?`exiting-${E.id}`:E.id);y.push(L)});return}const k=f.has(j.dateKey);y.push(a.jsx(E1,{date:j.date,taskCount:j.tasks.length,isExpanded:k,onClick:()=>v(j.dateKey)},`date-group-${j.date}`)),k&&j.tasks.forEach(E=>{const w=g.has(E.id),T=t.has(E.id),R=u[E.id];let z;w?z="exiting":T&&(z="entering");const L=a.jsx(Po,{task:E,animation:z,onClick:()=>c(`/tasks/task/${E.id}`),pulseKey:R?.ts},w?`exiting-${E.id}`:E.id);y.push(L)})}),a.jsx(a.Fragment,{children:y})}function Ao({status:n}){const t=Rt(),i=t?void 0:n,{tasks:l,createTask:c,setSectionTitle:u,animationByStatus:f,globalEnteringIds:x,globalExitingTasks:g,activityByTaskId:m}=qn(),{showError:y}=ds(),{registerCommands:_,registerTaskSearch:v}=rl(),j=ze();jt(),h.useEffect(()=>{if(!i){u("All Tasks");return}u(Zs[i].label)},[i,u]),h.useEffect(()=>_([{id:"new-task",label:"New Task",description:"Create a new task",aliases:["create","add task"],onSelect:()=>M(!0)}]),[_]),h.useEffect(()=>v(I=>Qt.TasksController_searchTasks({query:I,limit:5,threshold:.1})),[v]);const k=h.useMemo(()=>i?l.filter(I=>I.status===i):l,[l,i]),E=h.useMemo(()=>i?{enteringIds:f[i].enteringIds,exitingTasks:f[i].exitingTasks}:{enteringIds:x,exitingTasks:g},[i,f,x,g]),[w,T]=mh(),[R,z]=h.useState(null),[L,M]=h.useState(!1);h.useEffect(()=>{w.get("new")==="1"&&(M(!0),T({},{replace:!0}))},[w,T]);const N=()=>{console.log("cancel"),M(!1)},A=async({title:I,description:Q})=>{console.log(`save title: ${I} - description: ${Q}`),z({name:I,description:Q});try{const Z=await c({name:I,description:Q});return Z?(z(Z),j(`/tasks/task/${Z.id}`),!0):!1}catch(Z){return console.error("Error saving task"),console.error(Z),y(Z),!1}};return a.jsx("div",{className:`${t?"full-height":""}`,children:t?a.jsxs("div",{className:"tasks-page",children:[a.jsx(N1,{tasks:l,animationByStatus:f}),a.jsxs("button",{className:"tasks-fab tasks-fab--desktop",type:"button",onClick:()=>M(!0),children:[a.jsx("span",{className:"tasks-fab__plus",children:"+"}),a.jsx("span",{className:"tasks-fab__label",children:"New task"})]}),L?a.jsx(eh,{onCancel:N,onSave:A}):null]}):a.jsxs(a.Fragment,{children:[a.jsx(w1,{tasks:k,enteringIds:E.enteringIds,exitingTasks:E.exitingTasks,groupByDay:i===_e.DONE}),a.jsx("button",{className:"tasks-fab",type:"button",onClick:()=>M(!0),"aria-label":"Create new task",children:"+"}),L?a.jsx(eh,{onCancel:N,onSave:A}):null]})})}function Ro({tasks:n,status:t,animationState:i}){const l=h.useMemo(()=>n.filter(u=>u.status===t),[n,t]),c=Zs[t].label;return a.jsxs("div",{className:"tasks-board-column",children:[a.jsxs("div",{className:"tasks-board-column__header",children:[a.jsx(b,{size:"3",weight:"bold",children:c}),a.jsx(b,{size:"1",tone:"muted",children:l.length})]}),a.jsx("div",{className:"tasks-board-column__body",children:a.jsx(C1,{tasks:l,enteringIds:i.enteringIds,exitingTasks:i.exitingTasks,groupByDay:t===_e.DONE})})]})}function N1({tasks:n,animationByStatus:t}){return a.jsxs("div",{className:"tasks-board-view",children:[a.jsx(Ro,{status:_e.NOT_STARTED,tasks:n,animationState:t[_e.NOT_STARTED]}),a.jsx(Ro,{status:_e.IN_PROGRESS,tasks:n,animationState:t[_e.IN_PROGRESS]}),a.jsx(Ro,{status:_e.FOR_REVIEW,tasks:n,animationState:t[_e.FOR_REVIEW]}),a.jsx(Ro,{status:_e.DONE,tasks:n,animationState:t[_e.DONE]})]})}const A1=2200;function R1({trigger:n,durationMs:t=A1}){const[i,l]=h.useState(!1);return h.useEffect(()=>{if(n<=0)return;l(!0);const c=window.setTimeout(()=>l(!1),t);return()=>window.clearTimeout(c)},[n,t]),i?a.jsxs("div",{className:"shipped-celebration",style:{"--celebration-duration":`${t}ms`},"aria-hidden":"true",children:[a.jsx("div",{className:"shipped-celebration__veil"}),a.jsx("div",{className:"shipped-celebration__rocket",role:"presentation",children:"🚀"}),a.jsx("div",{className:"shipped-celebration__spark shipped-celebration__spark--one"}),a.jsx("div",{className:"shipped-celebration__spark shipped-celebration__spark--two"}),a.jsx("div",{className:"shipped-celebration__spark shipped-celebration__spark--three"})]}):null}const z1=window.location.origin,jv=new Ws({baseUrl:z1,credentials:"include"}),Ui=jv.taskBlueprints,Cr=jv.scheduledTasks;function D1(){const n=Rt(),{sectionTitle:t,shippedCelebrationTrigger:i,projects:l,projectsLoaded:c,selectedProjectId:u,setSelectedProjectId:f}=qn(),x=ze(),g=qt(),[m,y]=h.useState(null),_=g.pathname==="/tasks/dependencies"||g.pathname.startsWith("/tasks/dependencies/"),v=["/tasks/not-started","/tasks/in-progress","/tasks/in-review","/tasks/done"].includes(g.pathname),j=v||_,k=v||_,E=a.jsx(L1,{isBoardView:v,isDependencyView:_,onBoardClick:()=>x("/tasks/not-started"),onDependenciesClick:()=>x("/tasks/dependencies")}),w=a.jsx(O1,{projects:l,projectsLoaded:c,selectedProjectId:u,onChange:f});return h.useEffect(()=>{let T=!0;return(async()=>{try{const z=await Cr.ScheduledTasksController_listScheduledTasks({page:1,limit:50});if(!T)return;const L=z.items.filter(M=>M.enabled).length;y(L)}catch{T&&y(null)}})(),()=>{T=!1}},[]),a.jsxs("div",{style:{minHeight:0},children:[a.jsx(R1,{trigger:i}),n?a.jsx(Br,{sectionTitle:t,titleAccessory:k?w:void 0,headerActions:a.jsxs("div",{className:"tasks-layout__header-actions",children:[j?E:null,a.jsxs(ue,{size:"sm",variant:"ghost",className:"tasks-layout__header-button",onClick:()=>x("/tasks/schedule"),children:[a.jsx(Fx,{className:"tasks-layout__header-icon",size:16,strokeWidth:1.5,absoluteStrokeWidth:!0}),"Schedule",m&&m>0?a.jsx("span",{className:"tasks-layout__schedule-badge",children:m}):null]})]}),children:a.jsx(Kt,{})}):a.jsx($a,{appTitle:"Tasks",sectionTitle:t,navItems:v1,topActions:k||j?a.jsxs("div",{className:"tasks-layout__mobile-top-actions",children:[k?w:null,j?a.jsx("div",{className:"tasks-layout__mobile-view-toggle",children:E}):null]}):void 0,children:a.jsx(Kt,{})})]})}function O1({projects:n,projectsLoaded:t,selectedProjectId:i,onChange:l}){const[c,u]=h.useState(!1),[f,x]=h.useState(""),g=h.useRef(null),m=h.useRef(null),y=n.find(k=>k.id===i)??null,_=f.trim().toLowerCase(),v=h.useMemo(()=>_?n.filter(k=>k.slug.toLowerCase().includes(_)||k.tagName.toLowerCase().includes(_)):n,[_,n]);h.useEffect(()=>{if(!c)return;const k=w=>{g.current?.contains(w.target)||u(!1)},E=w=>{w.key==="Escape"&&u(!1)};return document.addEventListener("pointerdown",k),document.addEventListener("keydown",E),window.setTimeout(()=>m.current?.focus(),0),()=>{document.removeEventListener("pointerdown",k),document.removeEventListener("keydown",E)}},[c]);const j=k=>{l(k),x(""),u(!1)};return a.jsxs("div",{className:"tasks-layout__project-selector",ref:g,children:[a.jsxs("button",{className:"tasks-layout__project-trigger",type:"button","aria-haspopup":"listbox","aria-expanded":c,"aria-label":"Task project",disabled:!t,onClick:()=>u(k=>!k),children:[a.jsx(Yd,{className:"tasks-layout__project-selector-icon",size:15,strokeWidth:1.75,absoluteStrokeWidth:!0}),a.jsx("span",{className:"tasks-layout__project-trigger-label",children:y?.slug??"All projects"}),a.jsx(sT,{className:`tasks-layout__project-selector-chevron${c?" tasks-layout__project-selector-chevron--open":""}`,size:14,strokeWidth:1.75,absoluteStrokeWidth:!0})]}),c?a.jsxs("div",{className:"tasks-layout__project-menu",children:[a.jsx("input",{ref:m,className:"tasks-layout__project-search",type:"search",value:f,onChange:k=>x(k.target.value),placeholder:"Search projects","aria-label":"Search projects"}),a.jsxs("div",{className:"tasks-layout__project-options",role:"listbox","aria-label":"Task project",children:[a.jsx("button",{className:`tasks-layout__project-option${i===null?" tasks-layout__project-option--selected":""}`,type:"button",role:"option","aria-selected":i===null,onClick:()=>j(null),children:"All projects"}),v.length===0?a.jsx("div",{className:"tasks-layout__project-empty",children:"No matching projects"}):v.map(k=>a.jsxs("button",{className:`tasks-layout__project-option${i===k.id?" tasks-layout__project-option--selected":""}`,type:"button",role:"option","aria-selected":i===k.id,onClick:()=>j(k.id),children:[a.jsx("span",{className:"tasks-layout__project-option-name",children:k.slug}),a.jsx("span",{className:"tasks-layout__project-option-tag",children:k.tagName})]},k.id))]})]}):null]})}function L1({isBoardView:n,isDependencyView:t,onBoardClick:i,onDependenciesClick:l}){return a.jsxs("div",{className:"tasks-layout__view-toggle",role:"group","aria-label":"Task view",children:[a.jsxs("button",{className:`tasks-layout__view-toggle-button${n?" tasks-layout__view-toggle-button--active":""}`,type:"button","aria-pressed":n,onClick:i,children:[a.jsx(Xx,{className:"tasks-layout__header-icon",size:16,strokeWidth:1.5,absoluteStrokeWidth:!0}),"Board"]}),a.jsxs("button",{className:`tasks-layout__view-toggle-button${t?" tasks-layout__view-toggle-button--active":""}`,type:"button","aria-pressed":t,onClick:l,children:[a.jsx(Kx,{className:"tasks-layout__header-icon",size:16,strokeWidth:1.5,absoluteStrokeWidth:!0}),"Dependencies"]})]})}const M1={content:""},$y=n=>{n&&(n.style.height="auto",n.style.height=`${n.scrollHeight}px`)};function q1({onCancel:n,onSave:t,taskId:i}){const[l,c,u]=Hr({key:`new-comment-draft-${i}`,defaultValue:M1}),{content:f}=l,x=h.useRef(null);h.useEffect(()=>{x.current?.focus()},[]),h.useEffect(()=>{$y(x.current)},[f]);function g(y){c({...l,content:y.target.value}),$y(y.target)}async function m(){const y=await t({content:f});return y&&u(),y}return a.jsx(gt,{title:"Add Comment",onCancel:n,onSave:m,children:a.jsx(a.Fragment,{children:a.jsx("div",{className:"new-comment-pop__input-content",children:a.jsx("textarea",{className:"new-comment-pop__input-content",ref:x,placeholder:"Leave a comment...",value:f,onChange:g})})})})}const I1={answer:""},Dd=n=>{n&&(n.style.height="auto",n.style.height=`${n.scrollHeight}px`)};function B1({onCancel:n,onSave:t,taskId:i,inputRequestId:l,question:c}){const[u,f,x]=Hr({key:`answer-input-request-draft-${l}`,defaultValue:I1}),{answer:g}=u,m=h.useRef(null),y=h.useRef(null);h.useEffect(()=>{y.current?.focus()},[]),h.useEffect(()=>{Dd(m.current)},[c]),h.useEffect(()=>{Dd(y.current)},[g]);function _(j){f({...u,answer:j.target.value}),Dd(j.target)}async function v(){const j=await t({answer:g});return j&&x(),j}return a.jsx(gt,{title:"Answer Input Request",onCancel:n,onSave:v,children:a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"new-comment-pop__input-content",children:a.jsx("textarea",{className:"new-comment-pop__input-content",ref:m,value:c,readOnly:!0,style:{opacity:.7,cursor:"default"}})}),a.jsx("div",{className:"new-comment-pop__input-content",children:a.jsx("textarea",{className:"new-comment-pop__input-content",ref:y,placeholder:"Your answer...",value:g,onChange:_})})]})})}function U1({onCancel:n,onSave:t,existingTags:i}){const[l,c]=h.useState([]),[u,f]=h.useState(!0),[x,g]=h.useState(""),[m,y]=h.useState(0),[_,v]=h.useState(!1),j=h.useRef(null),k=h.useRef(null);h.useEffect(()=>{(async()=>{try{const M=await $x.metaControllerGetAllTags();c(M)}catch(M){console.error("Failed to load tags:",M)}finally{f(!1)}})()},[]),h.useEffect(()=>{j.current?.focus()},[]);const E=h.useMemo(()=>{const L=new Set(i.map(I=>I.id)),M=l.filter(I=>!L.has(I.id));if(!x.trim())return M;const N=x.toLowerCase().trim();return M.map(I=>{let Q=0;return I.name.toLowerCase().startsWith(N)?Q+=100:I.name.toLowerCase().includes(N)&&(Q+=50),{tag:I,score:Q}}).filter(I=>I.score>0).sort((I,Q)=>Q.score-I.score).map(I=>I.tag)},[l,i,x]),w=h.useMemo(()=>{if(!x.trim())return!1;const L=x.toLowerCase().trim();return!l.some(M=>M.name.toLowerCase()===L)},[x,l]);h.useEffect(()=>{y(0)},[E.length,x,w]),h.useEffect(()=>{if(k.current){const L=E.length+(w?1:0);if(m<L){const M=k.current.children[m];M&&M.scrollIntoView({block:"nearest"})}}},[m,E.length,w]);const T=h.useCallback(async L=>{if(_)return!1;v(!0);try{const M=await t(L);return M&&n?.(),M}finally{v(!1)}},[_,n,t]),R=h.useCallback(L=>{if(L.nativeEvent.isComposing)return;const M=E.length+(w?1:0);switch(L.key){case"ArrowDown":if(M===0)return;L.preventDefault(),y(N=>N<M-1?N+1:N);break;case"ArrowUp":if(M===0)return;L.preventDefault(),y(N=>N>0?N-1:0);break;case"Enter":L.preventDefault(),m<E.length?T(E[m]):w&&m===E.length&&T(Od(x));break;case"Escape":L.preventDefault(),n?.();break}},[w,E,m,n,x,T]);async function z(){if(E.length+(w?1:0)===0)return!1;if(m<E.length){const M=E[m];return M?T(M):!1}return w&&m===E.length?T(Od(x)):!1}return a.jsx(gt,{title:"Add Tag",onCancel:n,onSave:z,children:a.jsxs("div",{className:"tag-search-pop",children:[a.jsx("input",{ref:j,type:"text",className:"tag-search-pop__input",placeholder:"Search or create tag...",value:x,onChange:L=>g(L.target.value),onKeyDown:R}),a.jsx("div",{className:"tag-search-pop__list",ref:k,role:"listbox","aria-label":"Available tags",children:u?a.jsx("div",{className:"tag-search-pop__empty",children:a.jsx(b,{tone:"muted",children:"Loading tags..."})}):E.length===0&&!w?a.jsx("div",{className:"tag-search-pop__empty",children:a.jsx(b,{tone:"muted",children:"No tags found"})}):a.jsxs(a.Fragment,{children:[E.map((L,M)=>a.jsx("button",{type:"button",role:"option","aria-selected":M===m,className:`tag-search-pop__item ${M===m?"tag-search-pop__item--highlighted":""}`,onClick:()=>void T(L),onMouseEnter:()=>y(M),disabled:_,children:a.jsx("div",{className:"tag-search-pop__tag-badge",style:{backgroundColor:L.color||"#999"},children:L.name})},L.id)),w&&a.jsxs("button",{type:"button",role:"option","aria-selected":m===E.length,className:`tag-search-pop__item tag-search-pop__item--create ${m===E.length?"tag-search-pop__item--highlighted":""}`,onClick:()=>void T(Od(x)),onMouseEnter:()=>y(E.length),disabled:_,children:[a.jsx(b,{size:"2",tone:"muted",children:"Create new tag:"}),a.jsx("div",{className:"tag-search-pop__tag-badge",style:{backgroundColor:"#999"},children:x.trim()})]})]})})]})})}function Od(n){return{id:"",name:n.trim(),color:void 0,createdAt:"",updatedAt:""}}function $1({onCancel:n,onSave:t,excludeTaskIds:i}){const[l,c]=h.useState(""),[u,f]=h.useState(0),[x,g]=h.useState([]),[m,y]=h.useState(!1),[_,v]=h.useState(null),[j,k]=h.useState(!1),E=h.useRef(null),w=h.useRef(null),T=h.useRef(0);h.useEffect(()=>{E.current?.focus()},[]),h.useEffect(()=>{const A=l.trim();if(!A){T.current=T.current+1,g([]),v(null),y(!1);return}const I=T.current+1;T.current=I,y(!0),v(null);const Q=window.setTimeout(async()=>{try{const Z=await Qt.TasksController_searchTasks({query:A,limit:20});if(T.current!==I)return;g(Z??[])}catch(Z){if(T.current!==I)return;v(Z instanceof Error?Z.message:"Failed to search tasks"),g([])}finally{T.current===I&&y(!1)}},200);return()=>{window.clearTimeout(Q)}},[l]);const R=h.useMemo(()=>{const A=new Set(i);return x.filter(I=>!A.has(I.id))},[x,i]);h.useEffect(()=>{f(0)},[R.length,l]),h.useEffect(()=>{if(w.current){const A=w.current.children[u];A&&A.scrollIntoView({block:"nearest"})}},[u]);const z=h.useCallback(async A=>{if(j)return!1;k(!0);try{const I=await Qt.TasksController_getTask({id:A.id}),Q=await t(I);return Q&&n?.(),Q}catch(I){return console.error("Failed to fetch task details:",I),!1}finally{k(!1)}},[j,n,t]),L=h.useCallback(()=>{if(R.length===0)return;const A=R[u];A&&z(A)},[R,u,z]),M=h.useCallback(A=>{if(!A.nativeEvent.isComposing)switch(A.key){case"ArrowDown":if(R.length===0)return;A.preventDefault(),f(I=>I<R.length-1?I+1:I);break;case"ArrowUp":if(R.length===0)return;A.preventDefault(),f(I=>I>0?I-1:0);break;case"Enter":A.preventDefault(),L();break;case"Escape":A.preventDefault(),n?.();break}},[R,L,n]);async function N(){if(R.length===0)return!1;const A=R[u];return A?z(A):!1}return a.jsx(gt,{title:"Add Dependency",onCancel:n,onSave:N,children:a.jsxs("div",{className:"task-search-pop",children:[a.jsx("input",{ref:E,type:"text",className:"task-search-pop__input",placeholder:"Search tasks...",value:l,onChange:A=>c(A.target.value),onKeyDown:M}),a.jsx("div",{className:"task-search-pop__list",ref:w,role:"listbox","aria-label":"Tasks",children:R.length===0?a.jsx("div",{className:"task-search-pop__empty",children:a.jsx(b,{tone:"muted",children:l.trim()?m?"Searching tasks...":_||"No tasks found":"Type to search for tasks"})}):R.map((A,I)=>a.jsx("button",{type:"button",role:"option","aria-selected":I===u,className:`task-search-pop__item ${I===u?"task-search-pop__item--highlighted":""}`,onClick:()=>void z(A),onMouseEnter:()=>f(I),disabled:j,children:a.jsxs("div",{className:"task-search-pop__item-info",children:[a.jsx(b,{weight:"medium",size:"2",children:A.name}),a.jsxs(b,{tone:"muted",size:"1",style:"mono",children:["#",A.id.slice(0,6)]})]})},A.id))})]})})}Me.BASE=Ba;const kv=h.createContext(null);function H1({children:n}){const[t,i]=h.useState([]),[l,c]=h.useState(!1),[u,f]=h.useState(null),x=h.useCallback(async()=>{c(!0),f(null);try{const y=await Ux.actorControllerListActors();i(y||[])}catch(y){f(y instanceof Error?y.message:"Failed to load actors")}finally{c(!1)}},[]);h.useEffect(()=>{x()},[x]);const g=h.useCallback(async()=>{await x()},[x]),m=h.useMemo(()=>({actors:t,isLoading:l,error:u,refreshActors:g}),[t,l,u,g]);return a.jsx(kv.Provider,{value:m,children:n})}function il(){const n=h.useContext(kv);if(!n)throw new Error("useActorsCtx must be used within <ActorsProvider>");return n}function P1({onCancel:n,onSave:t}){const{actors:i,isLoading:l,error:c,refreshActors:u}=il(),[f,x]=h.useState(""),[g,m]=h.useState(0),[y,_]=h.useState(null),[v,j]=h.useState(!1),[k,E]=h.useState(null),[w,T]=h.useState(!1),R=h.useRef(null),z=h.useRef(null),L=h.useRef(0);h.useEffect(()=>{R.current?.focus()},[]),h.useEffect(()=>{u().catch(()=>{})},[u]),h.useEffect(()=>{const Z=f.trim();if(!Z){_(null),E(null),j(!1);return}const U=L.current+1;L.current=U,j(!0),E(null);const le=window.setTimeout(async()=>{try{const W=await Ux.actorControllerSearchActors(Z,20);if(L.current!==U)return;_(W??[])}catch(W){if(L.current!==U)return;E(W instanceof Error?W.message:"Failed to search actors"),_([])}finally{L.current===U&&j(!1)}},200);return()=>{window.clearTimeout(le)}},[f]);const M=h.useMemo(()=>f.trim()?y??[]:i,[i,f,y]);h.useEffect(()=>{m(0)},[M.length,f]),h.useEffect(()=>{if(z.current){const Z=z.current.children[g];Z&&Z.scrollIntoView({block:"nearest"})}},[g]);const N=h.useCallback(async Z=>{if(w)return!1;T(!0);try{const U=await t(Z);return U&&n?.(),U}finally{T(!1)}},[w,n,t]),A=h.useCallback(()=>{if(M.length===0)return;const Z=M[g];Z&&N(Z)},[M,g,N]),I=h.useCallback(Z=>{if(!Z.nativeEvent.isComposing)switch(Z.key){case"ArrowDown":if(M.length===0)return;Z.preventDefault(),m(U=>U<M.length-1?U+1:U);break;case"ArrowUp":if(M.length===0)return;Z.preventDefault(),m(U=>U>0?U-1:0);break;case"Enter":Z.preventDefault(),A();break}},[M,A]);async function Q(){if(M.length===0)return!1;const Z=M[g];return Z?N(Z):!1}return a.jsx(gt,{title:"Assign Task",onCancel:n,onSave:Q,children:a.jsxs("div",{className:"actor-search-pop",children:[a.jsx("input",{ref:R,type:"text",className:"actor-search-pop__input",placeholder:"Search by name or @slug...",value:f,onChange:Z=>x(Z.target.value),onKeyDown:I}),a.jsx("div",{className:"actor-search-pop__list",ref:z,role:"listbox","aria-label":"Assignees",children:M.length===0?a.jsx("div",{className:"actor-search-pop__empty",children:a.jsx(b,{tone:"muted",children:f.trim()?v?"Searching actors...":k||"No actors found":l?"Loading actors...":c||"No actors found"})}):M.map((Z,U)=>a.jsxs("button",{type:"button",role:"option","aria-selected":U===g,className:`actor-search-pop__item ${U===g?"actor-search-pop__item--highlighted":""}`,onClick:()=>void N(Z),onMouseEnter:()=>m(U),disabled:w,children:[a.jsx(He,{name:Z.displayName,size:"sm",src:Z.avatarUrl||void 0}),a.jsxs("div",{className:"actor-search-pop__item-info",children:[a.jsx(b,{weight:"medium",size:"2",children:Z.displayName}),a.jsxs(b,{tone:"muted",size:"1",children:["@",Z.slug," · ",Z.type]})]})]},Z.id))})]})})}const G1=window.location.origin,V1=new Ws({baseUrl:G1,credentials:"include"}),Is=V1.threads,F1=window.location.origin,Y1=new Ws({baseUrl:F1,credentials:"include"}),Ma=Y1.executions,Q1=n=>n.some(l=>l.isActive&&l.isConfigured)?{isReady:!0,title:"Thread chat is ready",description:"Your conversation tools are online.",ctaLabel:"Open chat settings"}:n.length===0?{isReady:!1,title:"Thread chat is waiting at the gate",description:"Connect your first chat provider in settings to unlock new threads and live conversation.",ctaLabel:"Set up chat"}:n.some(l=>l.isConfigured)?{isReady:!1,title:"Your next level is one switch away",description:"A provider is configured, but none is active yet. Pick one in chat settings to open the thread portal.",ctaLabel:"Choose active provider"}:{isReady:!1,title:"Thread chat needs one more step",description:"A provider exists, but it still needs credentials before threads can talk back.",ctaLabel:"Finish chat setup"};function sc(){const[n,t]=h.useState(null),[i,l]=h.useState(!0),c=h.useCallback(async()=>{l(!0);try{const u=await Ar.chatProvidersControllerListChatProviders();t(Q1(u))}catch{t(null)}finally{l(!1)}},[]);return h.useEffect(()=>{c()},[c]),{readiness:n,isLoading:i,isReady:n?.isReady??!0,refresh:c}}function nc({title:n,description:t,ctaLabel:i,onOpenSettings:l,className:c}){return a.jsxs("div",{className:`chat-setup-callout ${c??""}`.trim(),children:[a.jsx("div",{className:"chat-setup-callout__badge",children:"Thread Chat"}),a.jsxs(te,{spacing:"3",children:[a.jsxs(te,{spacing:"1",children:[a.jsx(b,{size:"4",weight:"semibold",children:n}),a.jsx(b,{tone:"muted",children:t}),a.jsx(b,{size:"1",tone:"muted",children:"Visit `/settings/chat` to wire it up."})]}),a.jsx("div",{className:"chat-setup-callout__actions",children:a.jsx(ue,{variant:"primary",onClick:l,children:i})})]})]})}function th(n){return n===_e.DONE?{label:"done",color:"purple"}:n===_e.IN_PROGRESS?{label:"in progress",color:"green"}:n===_e.NOT_STARTED?{label:"not started",color:"blue"}:n===_e.FOR_REVIEW?{label:"in review",color:"orange"}:{label:"unknown",color:"gray"}}const Ld=3,Md=3;function Tv({task:n,backPath:t,setSectionTitle:i,isLoadingTask:l=!1,activityByTaskId:c={},handlers:u,allTasks:f}){const x=ze(),{actors:g}=il(),{user:m}=us(),{showError:y,showToast:_}=ds(),{registerCommands:v}=rl(),{readiness:j,isReady:k,isLoading:E}=sc(),[w,T]=h.useState(null),[R,z]=h.useState("idle"),[L,M]=h.useState(!1),[N,A]=h.useState(!1),I=h.useRef(null),Q=h.useRef(null),Z=3500,U=220;jt({task:{name:n?.name}});const le=h.useCallback(async re=>{if(n)try{await u.changeStatus({taskId:n.id,status:re})}catch(ve){y(ve)}},[n,u,y]),[W,oe]=h.useState(null),[me,B]=h.useState(!1),se=h.useCallback(async()=>{if(n){if(!k){_("Thread chat unlocks in Chat Settings.","info"),x("/settings/chat");return}B(!0);try{if(W){x(`/threads/${W}`);return}const re=await Is.ThreadsController_createThread({body:{title:n.name,parentTaskId:n.id}});oe(re.id),x(`/threads/${re.id}`)}catch(re){y(re)}finally{B(!1)}}},[n,W,k,x,y,_]);h.useEffect(()=>{if(!n){oe(null);return}let re=!1;return B(!0),Is.ThreadsController_getThreadByTaskId({taskId:n.id}).then(ve=>{re||oe(ve?.id??null)}).catch(ve=>{re||(y(ve),oe(null))}).finally(()=>{re||B(!1)}),()=>{re=!0}},[n,y]);const ge=h.useMemo(()=>!n||!n.dependsOnIds||n.dependsOnIds.length===0?[]:n.dependsOnIds.map(re=>f.find(ve=>ve.id===re)).filter(re=>re!==void 0),[n,f]);h.useEffect(()=>{if(!n)return;const re={[_e.NOT_STARTED]:["not started","to do","todo","queued"],[_e.IN_PROGRESS]:["in progress","doing","building"],[_e.FOR_REVIEW]:["for review","review","in review"],[_e.DONE]:["done","shipped","release","complete"]},ve=Object.entries(Zs).map(([ct,bt])=>({id:`task-status-${ct}`,label:bt.label,description:`Mark task as ${bt.label.toLowerCase()}`,aliases:re[ct],onSelect:()=>le(ct)})),Je=[{id:"task-add-comment",label:"Comment",description:"Add a comment to this task",aliases:["add comment","note"],onSelect:()=>ce(!0)},{id:"task-assign",label:"Assign",description:"Assign this task to someone",aliases:["reassign","assignee"],onSelect:()=>fe(!0)},{id:"task-assign-to-me",label:"Assign to Me",description:"Assign this task to yourself",aliases:["claim","take"],onSelect:()=>{u.assignTaskToMe({taskId:n.id}).catch(y)}},{id:"task-add-tag",label:"Tag",description:"Add a tag to this task",aliases:["add tag","label"],onSelect:()=>je(!0)},{id:"task-thread-action",label:W?"Go to thread":"Create thread",description:W?"Open this task thread":"Create a thread from this task",aliases:["thread","open thread","create thread","chat"],onSelect:()=>{se()}}];return v([...ve,...Je])},[n,v,le,u,y,W,se]),h.useEffect(()=>{if(l){i("Loading task...");return}if(!n){i("Task");return}i(n.name)},[n,l,i]),h.useEffect(()=>()=>{I.current&&window.clearTimeout(I.current),Q.current&&window.clearTimeout(Q.current)},[]);const[Ee,Ce]=h.useState(null),[D,H]=h.useState(!1),[he,pe]=h.useState([]),[G,ae]=h.useState(!1),[J,xe]=h.useState(null),[Re,Qe]=h.useState(new Set),[It,nt]=h.useState(new Set),[mt,ce]=h.useState(!1),[Y,fe]=h.useState(!1),[K,je]=h.useState(!1),[et,yt]=h.useState(!1),[xt,ks]=h.useState(null),ss=h.useCallback(re=>{Qe(ve=>{const Je=new Set(ve);return Je.has(re)?Je.delete(re):Je.add(re),Je})},[]),vt=h.useCallback(async(re,ve,Je)=>{if(confirm(`Are you sure you want to interrupt the active execution for "${ve??"this task"}"?`)){nt(ct=>new Set(ct).add(re));try{await Ma.ActiveTaskExecutionController_interruptExecution({executionId:re}),_(`Interrupt signal sent for "${ve??"this task"}"`)}catch(ct){y(ct)}finally{nt(ct=>{const bt=new Set(ct);return bt.delete(re),bt})}}},[_,y]);h.useEffect(()=>{const re=ve=>{if(!n||ve.defaultPrevented||ve.metaKey||ve.ctrlKey||ve.altKey||mt||Y||K||et||xt||W1(ve.target))return;const Je=ve.key.toLowerCase();Je==="a"?(ve.preventDefault(),fe(!0)):Je==="c"?(ve.preventDefault(),ce(!0)):Je==="t"&&(ve.preventDefault(),je(!0))};return window.addEventListener("keydown",re),()=>window.removeEventListener("keydown",re)},[n,mt,Y,K,et,xt]);const hn=async({content:re})=>{if(!n)return!1;try{return await u.addComment({taskId:n.id,comment:re}),!0}catch(ve){return y(ve),!1}},fn=()=>{ce(!1)},ga=async re=>{if(!n)return!1;try{return await u.assignTask({taskId:n.id,assigneeActorId:re.id}),!0}catch(ve){return y(ve),!1}},In=()=>{fe(!1)},Gr=async({answer:re})=>{if(!n||!xt)return!1;try{return await u.answerInputRequest({taskId:n.id,inputRequestId:xt.id,answer:re}),!0}catch(ve){return y(ve),!1}},Pa=()=>{ks(null)},Vr=async re=>{if(!n)return!1;try{return await u.addTag({taskId:n.id,tag:re}),!0}catch(ve){return y(ve),!1}},Fr=()=>{je(!1)},pn=async re=>{if(n)try{await u.removeTag({taskId:n.id,tagId:re})}catch(ve){y(ve)}},Ht=async re=>{if(!n)return!1;try{return await u.addDependency({taskId:n.id,dependencyTaskId:re.id}),!0}catch(ve){return y(ve),!1}},Ts=()=>{yt(!1)},Pt=async re=>{if(n)try{await u.removeDependency({taskId:n.id,dependencyTaskId:re})}catch(ve){y(ve)}},Hs=n?c[n.id]:null;h.useEffect(()=>{M(!1),A(!1)},[n?.id]);const Bn=h.useCallback(async re=>{ae(!0);try{const[ve,Je]=await Promise.all([Ma.ActiveTaskExecutionController_listActiveExecutions({taskId:re,limit:100}),Ma.TaskExecutionHistoryController_listHistory({taskId:re,limit:100})]),ct=ve.items.map(Ze=>({id:`active-${Ze.id}`,executionId:Ze.id,agentActorId:Ze.agentActorId,status:"ACTIVE",source:"active",timestamp:Ze.claimedAt,runnerSessionId:Ze.runnerSessionId,toolCallCount:Ze.toolCallCount,errorCode:null,errorMessage:null})),bt=Je.items.map(Ze=>({id:`history-${Ze.id}`,executionId:Ze.id,agentActorId:Ze.agentActorId,status:Ze.status,source:"history",timestamp:Ze.transitionedAt,runnerSessionId:Ze.runnerSessionId,toolCallCount:Ze.toolCallCount,errorCode:Ze.errorCode,errorMessage:Ze.errorMessage})),en=[...ct,...bt].sort((Ze,de)=>new Date(de.timestamp).getTime()-new Date(Ze.timestamp).getTime());pe(en),xe(null)}catch(ve){const Je=ve instanceof Error?ve.message:"Failed to load runs for this task";xe(Je)}finally{ae(!1)}},[]),gn=h.useMemo(()=>n?[...n.comments.map(re=>({type:"comment",data:re,timestamp:new Date(re.createdAt).getTime()})),...n.inputRequests.map(re=>({type:"inputRequest",data:re,timestamp:new Date(re.createdAt).getTime()}))].sort((re,ve)=>re.timestamp-ve.timestamp):[],[n]),Un=L?gn:gn.slice(0,Ld),mn=gn.length>Ld,Js=N?he:he.slice(0,Md),Ps=he.length>Md;if(h.useEffect(()=>{if(!n){pe([]),xe(null),Qe(new Set);return}Qe(new Set),Bn(n.id)},[n,Bn]),h.useEffect(()=>{!n||!Hs||Hs.kind.startsWith("execution.")&&Bn(n.id)},[Hs,n,Bn]),h.useEffect(()=>{!n||!Hs||!Hs.message||(I.current&&window.clearTimeout(I.current),Q.current&&window.clearTimeout(Q.current),T(Hs),z("enter"),I.current=window.setTimeout(()=>{z("exit"),Q.current=window.setTimeout(()=>{T(null),z("idle")},U)},Z))},[Hs,n,U,Z]),!n&&l)return a.jsx(X1,{backPath:t});if(!n)return a.jsx("div",{className:"task-detail-page",children:a.jsxs(te,{spacing:"4",align:"center",children:[a.jsx(b,{size:"3",tone:"muted",children:"Task not found"}),a.jsx(ue,{variant:"secondary",onClick:()=>x(t),children:"Back to tasks"})]})});const $n=async re=>{H(!0);try{await u.changeStatus({taskId:n.id,status:re}),Ce(null)}catch(ve){y(ve)}finally{H(!1)}};return a.jsxs("div",{className:"task-detail-page",children:[Ee&&a.jsxs(Zt,{children:[a.jsx("button",{onClick:()=>Ce(null),className:"task-detail-page__error-close",children:"×"}),Ee]}),a.jsxs(ye,{className:"task-detail-page__section",children:[a.jsxs(be,{leading:a.jsx(He,{size:"sm",name:n.createdByActor.displayName,src:n.createdByActor.avatarUrl||void 0}),tags:[th(n.status),...n.tags.map(re=>({label:re.name,onRemove:()=>pn(re.id)})),{label:"+ add tag",color:"gray",onClick:()=>je(!0),clickLabel:"Add tag"}],topRight:a.jsx(b,{size:"1",tone:"muted",children:Lt(n.updatedAt)}),children:[a.jsx(b,{as:"span",weight:"medium",size:"3",children:n.createdByActor.displayName}),a.jsx(b,{as:"span",weight:"normal",tone:"muted",size:"3",children:` @${n.createdByActor.slug} created `}),a.jsxs(b,{as:"span",tone:"muted",style:"mono",children:["#",n.id.slice(0,6)]}),n.assigneeActor?null:a.jsx(b,{tone:"muted",children:"unassigned"})]}),n.assigneeActor?a.jsxs(be,{leading:a.jsx(He,{size:"sm",name:n.assigneeActor.displayName,src:n.assigneeActor.avatarUrl||void 0}),onClick:()=>fe(!0),children:[a.jsx(b,{as:"span",weight:"medium",size:"3",children:n.assigneeActor.displayName}),a.jsx(b,{as:"span",weight:"normal",tone:"muted",size:"3",children:` @${n.assigneeActor.slug} assigned`}),a.jsx(b,{size:"1",tone:"muted",children:"tap to reassign"})]}):null]}),n.artefacts&&n.artefacts.length>0&&a.jsx(ye,{className:"task-detail-page__section",children:n.artefacts.map(re=>a.jsxs(be,{children:[a.jsx(b,{as:"span",weight:"medium",size:"3",children:`${re.name}: `}),a.jsx(b,{as:"span",children:a.jsx("a",{href:re.link,target:"_blank",rel:"noopener noreferrer",style:{color:"var(--accent)",textDecoration:"underline"},children:re.link})})]},re.id))}),(ge.length>0||n)&&a.jsxs(ye,{title:"Depends on",className:"task-detail-page__section",action:ge.length>0?a.jsxs(ue,{size:"sm",variant:"ghost",className:"task-detail-page__dependency-graph-button",onClick:()=>x(`/tasks/dependencies/${n.id}`),children:[a.jsx(Kx,{className:"task-detail-page__dependency-graph-icon",size:14,strokeWidth:1.5,absoluteStrokeWidth:!0}),"View graph"]}):void 0,children:[ge.map(re=>a.jsx(Ki,{task:re,onClick:()=>x(`/tasks/task/${re.id}`),additionalTags:[{label:"× remove",color:"red",onClick:()=>Pt(re.id),clickLabel:"Remove dependency"}]},re.id)),a.jsx(be,{tags:[{label:"+ add dependency",color:"gray",onClick:()=>yt(!0),clickLabel:"Add dependency"}],children:a.jsx(b,{tone:"muted",size:"2",children:ge.length===0?"No dependencies yet":"Add another dependency"})})]}),a.jsx(ye,{className:"task-detail-page__section",children:a.jsxs(be,{leading:a.jsx(He,{size:"sm",name:n.createdByActor.displayName,src:n.createdByActor.avatarUrl||void 0}),tags:[],topRight:a.jsx(b,{size:"1",tone:"muted",children:Lt(n.createdAt)}),children:[a.jsx(b,{as:"span",weight:"medium",size:"3",children:n.createdByActor.displayName}),a.jsx(b,{as:"span",weight:"normal",tone:"muted",size:"3",children:` @${n.createdByActor.slug}`}),a.jsx(b,{children:n.description?n.description:"no description"})]})}),a.jsxs(ye,{title:"Updates",className:"task-detail-page__section",children:[gn.length===0?a.jsx(b,{className:"task-detail-page__executions-state",tone:"muted",children:"No updates yet."}):null,Un.map(re=>{if(re.type==="comment"){const hs=re.data,Gs=hs.commenterActor?.displayName||"unknown",zt=hs.commenterActor?.slug||"unknown";return a.jsxs(be,{leading:a.jsx(He,{size:"sm",name:Gs,src:hs.commenterActor?.avatarUrl||void 0}),topRight:a.jsx(b,{size:"1",tone:"muted",children:Lt(hs.createdAt)}),children:[a.jsx(b,{as:"span",weight:"medium",size:"3",children:Gs}),a.jsx(b,{as:"span",weight:"normal",tone:"muted",size:"3",children:` @${zt}`}),a.jsx(b,{children:hs.content})]},`comment-${hs.id}`)}const ve=re.data,Je=g.find(hs=>hs.id===ve.askedByActorId),ct=g.find(hs=>hs.id===ve.assignedToActorId),bt=Je?.displayName||"Unknown",en=Je?.slug||"unknown",Ze=ct?.displayName||"Unknown",de=ct?.slug||"unknown",Te=!!ve.resolvedAt,Bt=m&&ve.assignedToActorId===m.actorId,ma=typeof ve.answer=="string"?ve.answer:JSON.stringify(ve.answer),ul=Te?[{label:"resolved question",color:"gray"},{label:"answer",color:"green"}]:[{label:"question",color:"orange"}];return a.jsx(be,{leading:Te?a.jsxs("div",{className:"task-detail-page__input-request-avatars",children:[a.jsx(He,{size:"sm",name:bt,src:Je?.avatarUrl||void 0}),a.jsx(He,{size:"sm",name:Ze,src:ct?.avatarUrl||void 0})]}):a.jsx(He,{size:"sm",name:bt,src:Je?.avatarUrl||void 0}),tags:ul,topRight:a.jsx(b,{size:"1",tone:"muted",children:Lt(ve.createdAt)}),children:a.jsxs(te,{spacing:"2",children:[a.jsxs("div",{className:"task-detail-page__input-request",children:[a.jsxs("div",{className:"task-detail-page__input-request-question",children:[a.jsxs("div",{className:"task-detail-page__input-request-header",children:[a.jsx(b,{as:"span",weight:"medium",size:"3",children:bt}),a.jsx(b,{as:"span",weight:"normal",tone:"muted",size:"3",children:` @${en}`})]}),a.jsxs(b,{children:[a.jsx(b,{as:"span",tone:"muted",children:"Asked:"})," ",ve.question]})]}),Te?a.jsxs("div",{className:"task-detail-page__input-request-answer",children:[a.jsxs("div",{className:"task-detail-page__input-request-header",children:[a.jsx(b,{as:"span",weight:"medium",size:"3",children:Ze}),a.jsx(b,{as:"span",weight:"normal",tone:"muted",size:"3",children:` @${de}`})]}),a.jsxs(b,{children:[a.jsx(b,{as:"span",tone:"muted",children:"Answered:"})," ",ma]})]}):null]}),!Te&&Bt&&a.jsx(ue,{size:"sm",variant:"primary",onClick:()=>ks(ve),children:"Respond"})]})},`input-request-${ve.id}`)}),mn?a.jsx("div",{className:"task-detail-page__section-toggle",children:a.jsx(ue,{size:"sm",variant:"secondary",onClick:()=>M(re=>!re),children:L?"Show fewer updates":`See ${gn.length-Ld} more updates`})}):null]}),a.jsx(ye,{className:"task-detail-page__section",children:a.jsx("div",{className:"task-detail-page__activity",children:a.jsxs("div",{className:`task-detail-page__activity-slot ${w?"task-detail-page__activity-slot--active":""}`,children:[a.jsx("div",{className:"task-detail-page__activity-placeholder",children:a.jsx(b,{size:"2",tone:"muted",children:"Live activity will show here"})}),w?a.jsx("div",{className:`task-detail-page__activity-card ${R==="enter"?"is-entering":""} ${R==="exit"?"is-exiting":""}`,children:a.jsx(b,{size:"2",className:"task-detail-page__activity-message",children:w.message?.replace(/\s+/g," ").trim()||"Activity in progress..."})}):null]})})}),a.jsxs(ye,{title:"Runs",className:"task-detail-page__section",children:[G&&he.length===0?a.jsx(b,{className:"task-detail-page__executions-state",tone:"muted",children:"Loading runs..."}):null,J?a.jsxs(b,{className:"task-detail-page__executions-state",tone:"muted",children:["Failed to load runs: ",J]}):null,!G&&!J&&he.length===0?a.jsx(b,{className:"task-detail-page__executions-state",tone:"muted",children:"No runs yet for this task."}):null,Js.map(re=>{const ve=g.find(ma=>ma.id===re.agentActorId),Je=ve?.displayName??qd(re.agentActorId),ct=ve?.slug,bt=Z1(re.status),en=re.status==="FAILED"&&!!(re.errorCode||re.errorMessage),Ze=Re.has(re.id),de=re.source==="active",Te=It.has(re.executionId),Bt={label:de?"active":"history",color:"gray"};return a.jsx(be,{leading:a.jsx(He,{size:"sm",name:Je,src:ve?.avatarUrl||void 0}),tags:[bt,Bt],topRight:de?a.jsx(ue,{variant:"danger",size:"sm",disabled:Te,onClick:()=>void vt(re.executionId,n?.name,n?.id??""),children:Te?"Interrupting…":"Interrupt"}):a.jsx(b,{size:"1",tone:"muted",children:Lt(re.timestamp)}),children:a.jsxs(te,{spacing:"1",children:[a.jsxs("div",{children:[a.jsx(b,{as:"span",weight:"medium",size:"3",children:Je}),a.jsx(b,{as:"span",weight:"normal",tone:"muted",size:"3",children:ct?` @${ct}`:""})]}),a.jsx(b,{as:"span",tone:"muted",size:"2",children:a.jsxs("span",{className:"task-detail-page__execution-meta",children:["run #",qd(re.executionId),en?a.jsx("button",{type:"button",className:"task-detail-page__execution-error-toggle",onClick:()=>ss(re.id),"aria-label":Ze?"Hide failure details":"Show failure details","aria-expanded":Ze,title:Ze?"Hide failure details":"Show failure details",children:"i"}):null]})}),a.jsx(b,{as:"span",size:"1",tone:"muted",children:a.jsxs("span",{className:"task-detail-page__execution-stats",children:["tools: ",re.toolCallCount,a.jsx("span",{className:"task-detail-page__execution-stats-separator",children:"|"}),"session: ",re.runnerSessionId?qd(re.runnerSessionId):"pending",de?a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"task-detail-page__execution-stats-separator",children:"|"}),Lt(re.timestamp)]}):null]})}),en&&Ze?a.jsxs("div",{className:"task-detail-page__execution-error-detail",children:[re.errorCode?a.jsx(b,{as:"span",size:"1",style:"mono",className:"task-detail-page__execution-error-code",children:re.errorCode}):null,re.errorMessage?a.jsx(b,{as:"span",size:"2",wrap:!0,children:re.errorMessage}):null]}):null]})},re.id)}),Ps?a.jsx("div",{className:"task-detail-page__section-toggle",children:a.jsx(ue,{size:"sm",variant:"secondary",onClick:()=>A(re=>!re),children:N?"Show fewer runs":`See ${he.length-Md} more runs`})}):null]}),a.jsx(ye,{className:"task-detail-page__status-buttons",children:Object.entries(Zs).map(([re,ve])=>{const Je=ve.icon;return a.jsx(ue,{size:"sm",variant:re===n.status?"primary":"secondary",onClick:()=>$n(re),disabled:D,children:a.jsxs(te,{spacing:"1",align:"center",children:[a.jsx(Je,{size:20}),a.jsx("div",{children:ve.label})]})},re)})}),a.jsx(ue,{className:"task-detail-fab",onClick:()=>ce(!0),variant:"primary",size:"lg",children:"Add Comment"}),!n.assigneeActor&&a.jsxs(ye,{className:"task-detail-page__comment-buttons",children:[a.jsx(ue,{size:"lg",onClick:()=>fe(!0),children:"Assign"}),a.jsx(ue,{size:"lg",variant:"primary",onClick:async()=>{await u.assignTaskToMe({taskId:n.id})},children:"Assign to Me"})]}),a.jsx(Ur,{className:"task-detail-page__comment-buttons",onDelete:async()=>{try{await u.deleteTask({taskId:n.id}),x(t)}catch(re){y(re)}}}),a.jsxs(ye,{className:"task-detail-page__actions",children:[!E&&j&&!j.isReady?a.jsx(nc,{title:j.title,description:j.description,ctaLabel:j.ctaLabel,onOpenSettings:()=>x("/settings/chat")}):null,a.jsx(ue,{size:"lg",variant:W?"primary":"secondary",onClick:()=>{se()},disabled:me||!k||E,children:W?"Go to thread":"Create thread"}),a.jsx(ue,{size:"lg",variant:"secondary",onClick:()=>x(t),children:"Back to Tasks"})]}),mt?a.jsx(q1,{onCancel:fn,onSave:hn,taskId:n.id}):null,Y?a.jsx(P1,{onCancel:In,onSave:ga}):null,K?a.jsx(U1,{onCancel:Fr,onSave:Vr,existingTags:n.tags}):null,et?a.jsx($1,{onCancel:Ts,onSave:Ht,excludeTaskIds:[n.id,...n.dependsOnIds||[]]}):null,xt?a.jsx(B1,{onCancel:Pa,onSave:Gr,taskId:n.id,inputRequestId:xt.id,question:xt.question}):null]})}function K1(){const{d:n}=Wt(),{tasks:t,detailTasks:i,getTaskById:l,isLoading:c,hasLoadedOnce:u,setSectionTitle:f,addComment:x,deleteTask:g,assignTask:m,assignTaskToMe:y,answerInputRequest:_,activityByTaskId:v}=qn(),[j,k]=h.useState(!1),E=h.useMemo(()=>{const z=new Map;for(const L of t)z.set(L.id,L);for(const L of i)z.set(L.id,L);return Array.from(z.values())},[t,i]),w=n?E.find(z=>z.id===n):void 0;h.useEffect(()=>{if(!n)return;let z=!1;return k(!0),l(n).catch(L=>console.error("Failed to fetch task",L)).finally(()=>{z||k(!1)}),()=>{z=!0}},[n,l]),h.useEffect(()=>{if(!w||!w.dependsOnIds||w.dependsOnIds.length===0)return;const z=w.dependsOnIds.filter(L=>!E.some(M=>M.id===L));z.length!==0&&Promise.all(z.map(L=>l(L).catch(M=>(console.error(`Failed to hydrate dependency ${L}`,M),null))))},[w,E,l]);const T=!w&&(!u||c||j),R={addComment:({taskId:z,comment:L})=>x({taskId:z,comment:L}),deleteTask:({taskId:z})=>g({taskId:z}),assignTask:({taskId:z,assigneeActorId:L})=>m({taskId:z,assigneeActorId:L}),assignTaskToMe:({taskId:z})=>y({taskId:z}),answerInputRequest:({taskId:z,inputRequestId:L,answer:M})=>_({taskId:z,inputRequestId:L,answer:M}),changeStatus:({taskId:z,status:L})=>Qt.TasksController_changeStatus({id:z,body:{status:L}}),addTag:({taskId:z,tag:L})=>Qt.TasksController_addTagToTask({id:z,body:{name:L.name}}),removeTag:({taskId:z,tagId:L})=>Qt.TasksController_removeTagFromTask({id:z,tagId:L}),addDependency:async({taskId:z,dependencyTaskId:L})=>{const M=E.find(A=>A.id===z);if(!M)return;const N=[...M.dependsOnIds||[],L];await Qt.TasksController_updateTask({id:z,body:{dependsOnIds:N}});try{await l(L)}catch(A){console.error(`Failed to hydrate dependency ${L} after adding`,A)}},removeDependency:async({taskId:z,dependencyTaskId:L})=>{const M=E.find(A=>A.id===z);if(!M)return;const N=(M.dependsOnIds||[]).filter(A=>A!==L);await Qt.TasksController_updateTask({id:z,body:{dependsOnIds:N}})}};return a.jsx(Tv,{task:w,backPath:"/tasks",setSectionTitle:f,isLoadingTask:T,activityByTaskId:v,handlers:R,allTasks:E})}function X1({backPath:n}){const t=ze();return a.jsxs("div",{className:"task-detail-page",children:[a.jsxs(ye,{className:"task-detail-page__section task-detail-page__shell-container",children:[a.jsx("div",{className:"task-detail-page__shell-line task-detail-page__shell-line--wide"}),a.jsx("div",{className:"task-detail-page__shell-line task-detail-page__shell-line--mid"})]}),a.jsxs(ye,{className:"task-detail-page__section task-detail-page__shell-container",children:[a.jsx("div",{className:"task-detail-page__shell-line task-detail-page__shell-line--full"}),a.jsx("div",{className:"task-detail-page__shell-line task-detail-page__shell-line--short"}),a.jsx("div",{className:"task-detail-page__shell-line task-detail-page__shell-line--mid"})]}),a.jsxs(ye,{className:"task-detail-page__section task-detail-page__shell-container",children:[a.jsx("div",{className:"task-detail-page__shell-line task-detail-page__shell-line--full"}),a.jsx("div",{className:"task-detail-page__shell-line task-detail-page__shell-line--full"})]}),a.jsx("div",{className:"task-detail-page__actions",children:a.jsx(ue,{size:"lg",variant:"secondary",onClick:()=>t(n),children:"Back to Tasks"})})]})}function Z1(n){return n==="ACTIVE"?{label:"active",color:"blue"}:n==="SUCCEEDED"?{label:"succeeded",color:"green"}:n==="FAILED"?{label:"failed",color:"red"}:n==="STALE"?{label:"stale",color:"orange"}:{label:"cancelled",color:"gray"}}function qd(n){return n.length<=12?n:`${n.slice(0,8)}…${n.slice(-4)}`}function W1(n){if(!(n instanceof HTMLElement))return!1;if(n.isContentEditable)return!0;const t=n.tagName.toLowerCase();return t==="input"||t==="textarea"||t==="select"?!0:!!n.closest('[contenteditable="true"], input, textarea, select')}const J1=5e3,eE=pa("/tasks"),Ch=()=>{const[n,t]=h.useState(!0),[i,l]=h.useState(!1),[c,u]=h.useState(null),[f,x]=h.useState(!1),[g,m]=h.useState([]),[y,_]=h.useState([]),[v,j]=h.useState([]),[k,E]=h.useState({queue:0,active:0,history:0}),[w,T]=h.useState(null),R=h.useRef(!1),z=h.useCallback(async L=>{if(R.current)return;R.current=!0;const M=!i,N=L?.silent??!1;M?t(!0):N||x(!0);try{const[A,I,Q]=await Promise.all([Ma.TaskExecutionQueueController_listQueue({limit:50}),Ma.ActiveTaskExecutionController_listActiveExecutions({limit:50}),Ma.TaskExecutionHistoryController_listHistory({limit:50})]);m(A.items),_(I.items),j(Q.items),E({queue:A.total,active:I.total,history:Q.total}),T(new Date().toISOString()),u(null)}catch(A){u(A instanceof Error?A.message:"Failed to load executions")}finally{R.current=!1,l(!0),t(!1),x(!1)}},[i]);return h.useEffect(()=>{z();const L=window.setInterval(()=>{z({silent:!0})},J1);return()=>window.clearInterval(L)},[z]),h.useEffect(()=>{const L=Bs(eE,{transports:["websocket","polling"],withCredentials:!0});return L.on("connect",()=>{L.emit("tasks.subscribe",{},()=>{})}),L.on(bs.TASK_ACTIVITY,M=>{M.kind.startsWith("execution.")&&z({silent:!0})}),()=>{L.close()}},[z]),{isLoading:n,isRefreshing:f,hasLoadedOnce:i,error:c,queue:g,active:y,history:v,totals:k,loadExecutions:z,lastUpdatedAt:w}},Yi=228,wv=48,tE=60,sE=84,Hy=112,Ev=20,zo=48,nE=.55,aE=1.6,Py=.15,rE=.0025,Cv="task-dependencies-view-preferences",$i={graphMode:"all",hideDonePaths:!0,selectedTagNames:[]};function Gy(){const{tasks:n,isLoading:t,error:i,setSectionTitle:l,activityByTaskId:c}=qn(),{active:u}=Ch(),f=ze(),{taskId:x}=Wt(),g=h.useRef(null),m=h.useRef({x:0,y:0}),y=h.useRef(null),_=h.useRef(void 0),v=h.useRef(null),[j,k]=h.useState(1),[E,w]=h.useState({x:0,y:0}),[T,R]=h.useState(!1),[z,L]=h.useState(oE),{graphMode:M,hideDonePaths:N,selectedTagNames:A}=z,[I,Q]=h.useState([]),[Z,U]=h.useState(""),[le,W]=h.useState(!1);jt(),h.useEffect(()=>{l("Tasks")},[l]),h.useEffect(()=>{m.current=E},[E]),h.useEffect(()=>{cE(z)},[z]),h.useEffect(()=>{const K=new AbortController;return f1.MetaController_getAllTags({signal:K.signal}).then(Q).catch(je=>{K.signal.aborted||console.error("Failed to load dependency graph tags:",je)}),()=>K.abort()},[]);const oe=h.useMemo(()=>fE(n,I),[I,n]),me=h.useMemo(()=>new Map(oe.map(K=>[K.name,K])),[oe]),B=h.useMemo(()=>A.map(K=>me.get(K)??{name:K,count:0}),[me,A]),se=h.useMemo(()=>{const K=new Set(A),je=Z.trim().toLowerCase();return oe.filter(et=>!K.has(et.name)).filter(et=>je.length===0||et.name.toLowerCase().includes(je)).slice(0,8)},[oe,A,Z]),ge=h.useMemo(()=>pE(n,A),[n,A]),Ee=h.useMemo(()=>new Set(u.map(K=>K.taskId)),[u]),Ce=h.useMemo(()=>new Map(u.map(K=>[K.taskId,K.taskStatus])),[u]),D=h.useMemo(()=>new Set(Object.values(c).filter(yE).map(K=>K.taskId)),[c]),H=h.useMemo(()=>hE(ge,Ce,Ee,D,{includeAllTasks:M==="all",hideDonePaths:N,focusedTaskId:x}),[Ce,Ee,D,ge,x,M,N]),he=A.length>0,pe=`${H.nodes.length} shown`,G=N?"Showing paths that contain unfinished work. Click to include completed-only paths.":"Showing every path. Click to hide completed-only paths.";h.useEffect(()=>{if(!le)return;const K=je=>{v.current?.contains(je.target)||W(!1)};return document.addEventListener("pointerdown",K),()=>document.removeEventListener("pointerdown",K)},[le]);const ae=h.useCallback(K=>{L(je=>je.selectedTagNames.includes(K)?je:{...je,selectedTagNames:[...je.selectedTagNames,K]}),U(""),W(!1)},[]),J=h.useCallback(K=>{L(je=>({...je,selectedTagNames:je.selectedTagNames.filter(et=>et!==K)}))},[]),xe=h.useCallback(()=>{L(K=>({...K,selectedTagNames:[]}))},[]),Re=h.useCallback(K=>{if(!K.nativeEvent.isComposing){if(K.key==="Enter"){K.preventDefault();const[je]=se;je&&ae(je.name);return}K.key==="Escape"&&(K.preventDefault(),W(!1))}},[ae,se]),Qe=h.useCallback((K,je)=>{const et=g.current,yt=Yy(K);if(!et||yt===j){k(yt);return}const xt=je??{x:et.clientWidth/2,y:et.clientHeight/2};w(ks=>{const ss=(xt.x-ks.x)/j,vt=(xt.y-ks.y)/j;return{x:xt.x-ss*yt,y:xt.y-vt*yt}}),k(yt)},[j]),It=h.useCallback(K=>{k(je=>Yy(je+K))},[]),nt=h.useCallback(()=>{w(vE(H,g.current,x)),k(1)},[x,H]);h.useEffect(()=>{if(!(x&&_.current!==x)||H.nodes.length===0)return;const je=H.nodes.find(et=>et.task.id===x);je&&(_.current=x,k(1),w(zv(je,g.current)))},[x,H]);const mt=h.useCallback(K=>{if(H.nodes.length===0)return;const je=K.currentTarget;if(K.ctrlKey||K.metaKey){K.preventDefault();const et=je.getBoundingClientRect();Qe(j*Math.exp(-K.deltaY*rE),{x:K.clientX-et.left,y:K.clientY-et.top});return}if(K.deltaX!==0||K.deltaY!==0){K.preventDefault();const et=K.deltaMode===1?16:K.deltaMode===2?je.clientHeight:1;w(yt=>({x:yt.x-K.deltaX*et,y:yt.y-K.deltaY*et}))}},[Qe,H.nodes.length,j]),ce=h.useCallback(K=>{H.nodes.length===0||K.button!==0||K.target.closest(".dependency-task-card")||(K.preventDefault(),K.currentTarget.setPointerCapture(K.pointerId),y.current={pointerId:K.pointerId,startClientX:K.clientX,startClientY:K.clientY,startPanX:m.current.x,startPanY:m.current.y},R(!0))},[H.nodes.length]),Y=h.useCallback(K=>{const je=y.current;!je||je.pointerId!==K.pointerId||(K.preventDefault(),w({x:je.startPanX+K.clientX-je.startClientX,y:je.startPanY+K.clientY-je.startClientY}))},[]),fe=h.useCallback(K=>{const je=y.current;!je||je.pointerId!==K.pointerId||(K.currentTarget.hasPointerCapture(K.pointerId)&&K.currentTarget.releasePointerCapture(K.pointerId),y.current=null,R(!1))},[]);return t&&n.length===0?a.jsx("div",{className:"task-dependencies-page task-dependencies-page--state",children:a.jsx(b,{tone:"muted",children:"Loading dependencies..."})}):i?a.jsx("div",{className:"task-dependencies-page task-dependencies-page--state",children:a.jsxs(b,{tone:"muted",children:["Could not load dependencies: ",i]})}):a.jsxs("div",{className:"task-dependencies-page",children:[a.jsxs("div",{className:"task-dependencies-controls","aria-label":"Dependency graph filters",children:[a.jsxs("div",{className:"task-dependencies-controls__main",children:[a.jsx("div",{className:"task-dependencies-controls__row",children:a.jsxs("div",{className:"task-dependencies-segmented",role:"group","aria-label":"Tasks shown in graph",children:[a.jsx("button",{className:`task-dependencies-segmented__button ${M==="dependencies"?"task-dependencies-segmented__button--active":""}`,type:"button",title:"Show only tasks that have dependency links.",onClick:()=>L(K=>({...K,graphMode:"dependencies"})),children:"Linked tasks"}),a.jsx("button",{className:`task-dependencies-segmented__button ${M==="all"?"task-dependencies-segmented__button--active":""}`,type:"button",title:"Show every task, including tasks without dependency links.",onClick:()=>L(K=>({...K,graphMode:"all"})),children:"Every task"})]})}),a.jsx("div",{className:"task-dependencies-controls__row",children:a.jsx("button",{className:`task-dependencies-toggle${N?" task-dependencies-toggle--active":""}`,type:"button","aria-pressed":N,onClick:()=>L(K=>({...K,hideDonePaths:!K.hideDonePaths})),"aria-label":"Show unfinished paths only",title:G,children:"Unfinished paths"})}),a.jsx("span",{className:"task-dependencies-controls__summary",children:pe}),a.jsxs("div",{className:"task-dependencies-tag-picker",ref:v,children:[a.jsx("input",{className:"task-dependencies-tag-picker__input",type:"search",value:Z,placeholder:"+ tag","aria-label":"Add tag filter","aria-expanded":le,"aria-controls":"task-dependencies-tag-picker-list",title:"Filter the graph by tag.",onChange:K=>{U(K.target.value),W(!0)},onFocus:()=>W(!0),onKeyDown:Re}),le?a.jsx("div",{id:"task-dependencies-tag-picker-list",className:"task-dependencies-tag-picker__menu",role:"listbox","aria-label":"Available tag filters",children:se.length===0?a.jsx("span",{className:"task-dependencies-tag-picker__empty",children:oe.length===A.length?"No more tags":"No matching tags"}):se.map(K=>a.jsxs("button",{className:"task-dependencies-tag-picker__option",type:"button",role:"option","aria-selected":"false",onMouseDown:je=>je.preventDefault(),onClick:()=>ae(K.name),children:[a.jsx("span",{className:"task-dependencies-tag-picker__option-name",children:K.name}),a.jsx("span",{className:"task-dependencies-tag-picker__option-count",children:K.count})]},K.name))}):null]})]}),he?a.jsxs("div",{className:"task-dependencies-controls__tags-row",children:[a.jsx("span",{className:"task-dependencies-controls__label",children:"Tags"}),a.jsx("div",{className:"task-dependencies-tags","aria-label":"Tag filters",children:a.jsxs("div",{className:"task-dependencies-selected-tags","aria-label":"Selected tag filters",children:[B.map(K=>a.jsx(_s,{className:"task-dependencies-tag-filter",onRemove:()=>J(K.name),removeLabel:`Remove ${K.name} filter`,children:K.name},K.name)),a.jsx("button",{className:"task-dependencies-tags__clear",type:"button",onClick:xe,children:"Clear"})]})})]}):null]}),a.jsx("div",{className:"task-dependencies-canvas","aria-label":"Task dependency graph",children:H.nodes.length===0?a.jsxs("div",{className:"task-dependencies-empty",children:[a.jsx(b,{size:"3",weight:"semibold",children:"No tasks match this graph"}),a.jsx(b,{tone:"muted",children:"Adjust the task scope or tag filters to show more tasks."})]}):a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"task-dependencies-toolbar","aria-label":"Dependency graph controls",children:[a.jsx("button",{className:"task-dependencies-toolbar__button",type:"button",onClick:()=>It(-Py),"aria-label":"Zoom out",title:"Zoom out",children:a.jsx(o0,{size:16,strokeWidth:1.8})}),a.jsxs("span",{className:"task-dependencies-toolbar__zoom",children:[Math.round(j*100),"%"]}),a.jsx("button",{className:"task-dependencies-toolbar__button",type:"button",onClick:()=>It(Py),"aria-label":"Zoom in",title:"Zoom in",children:a.jsx(i0,{size:16,strokeWidth:1.8})}),a.jsx("button",{className:"task-dependencies-toolbar__button",type:"button",onClick:nt,"aria-label":"Reset zoom",title:"Reset zoom",children:a.jsx(LT,{size:16,strokeWidth:1.8})})]}),a.jsx("div",{ref:g,className:`task-dependencies-viewport${T?" task-dependencies-viewport--panning":""}`,onWheel:mt,onPointerDown:ce,onPointerMove:Y,onPointerUp:fe,onPointerCancel:fe,children:a.jsxs("div",{className:"task-dependencies-graph",style:{width:H.width,height:H.height,transform:`translate(${E.x}px, ${E.y}px) scale(${j})`},children:[a.jsx(dE,{connections:H.connections,width:H.width,height:H.height}),H.nodes.map(K=>a.jsx(iE,{node:K,status:Ce.get(K.task.id)??K.task.status,hasActiveExecution:Ee.has(K.task.id)||D.has(K.task.id),onOpen:()=>f(`/tasks/task/${K.task.id}`)},K.task.id))]})})]})})]})}function iE({node:n,status:t,hasActiveExecution:i,onOpen:l}){const{task:c}=n,u=Nv(t,i),f=c.assigneeActor?.slug,x=!!(f&&(t===_e.IN_PROGRESS||t===_e.FOR_REVIEW));return a.jsxs("button",{className:`dependency-task-card dependency-task-card--${t.toLowerCase().replaceAll("_","-")}`,type:"button",onClick:l,style:{left:n.x,top:n.y,height:n.height},children:[a.jsxs("span",{className:"dependency-task-card__content",children:[a.jsx("span",{className:"dependency-task-card__title",children:c.name}),x?a.jsxs("span",{className:"dependency-task-card__assignee",children:["@",f]}):null,u?a.jsx("span",{className:"dependency-task-card__status-row",children:a.jsx(_s,{color:u.color,className:"dependency-task-card__status-chip",children:u.label})}):null]}),a.jsxs("span",{className:"dependency-task-card__meta",children:[t===_e.DONE?a.jsx(lE,{}):null,i?a.jsx("span",{className:"dependency-task-card__spinner","aria-label":"Active execution",title:"Active execution"}):null]})]})}function lE(){return a.jsx("span",{className:"dependency-run-status-icon dependency-run-status-icon--success","aria-label":"Done",children:"✓"})}function Nv(n,t=!1){return t&&n===_e.NOT_STARTED?th(_e.IN_PROGRESS):n===_e.IN_PROGRESS||n===_e.FOR_REVIEW?th(n):null}function oE(){try{const n=localStorage.getItem(Cv);if(!n)return $i;const t=JSON.parse(n);return{graphMode:uE(t.graphMode)?t.graphMode:$i.graphMode,hideDonePaths:typeof t.hideDonePaths=="boolean"?t.hideDonePaths:$i.hideDonePaths,selectedTagNames:Array.isArray(t.selectedTagNames)?t.selectedTagNames.filter(i=>typeof i=="string"):$i.selectedTagNames}}catch(n){return console.error("Failed to load dependency view preferences:",n),$i}}function cE(n){try{localStorage.setItem(Cv,JSON.stringify(n))}catch(t){console.error("Failed to save dependency view preferences:",t)}}function uE(n){return n==="dependencies"||n==="all"}function dE({connections:n,width:t,height:i}){return a.jsxs("svg",{className:"task-dependencies-connections",width:t,height:i,viewBox:`0 0 ${t} ${i}`,"aria-hidden":"true",children:[a.jsx("defs",{children:a.jsx("marker",{id:"task-dependencies-connection-arrow",markerWidth:"8",markerHeight:"8",refX:"7",refY:"4",orient:"auto",markerUnits:"strokeWidth",children:a.jsx("path",{className:"task-dependencies-connection-arrow",d:"M 0 0 L 8 4 L 0 8 Z"})})}),n.map(l=>{const c=Math.max(80,l.endX-l.startX),u=Math.min(140,c*.5);return a.jsx("path",{d:`M ${l.startX} ${l.startY} C ${l.startX+u} ${l.startY}, ${l.endX-u} ${l.endY}, ${l.endX} ${l.endY}`,className:"task-dependencies-connection",markerEnd:"url(#task-dependencies-connection-arrow)"},`${l.fromTaskId}-${l.toTaskId}`)})]})}function hE(n,t,i,l,c){const u=new Map(n.map(M=>[M.id,M])),f=new Set(c.includeAllTasks?n.map(M=>M.id):[]);c.focusedTaskId&&u.has(c.focusedTaskId)&&f.add(c.focusedTaskId);for(const M of n){const N=M.dependsOnIds.filter(A=>u.has(A));if(N.length!==0){f.add(M.id);for(const A of N)f.add(A)}}if(f.size===0)return{nodes:[],connections:[],width:0,height:0};if(c.hideDonePaths&&gE(f,u,t,c.focusedTaskId),f.size===0)return{nodes:[],connections:[],width:0,height:0};const x=new Map(n.map((M,N)=>[M.id,N])),g=new Map,m=new Set,y=M=>{const N=g.get(M);if(N!==void 0)return N;if(m.has(M))return 0;m.add(M);const I=u.get(M)?.dependsOnIds.filter(Z=>f.has(Z)).map(Z=>y(Z))??[];m.delete(M);const Q=I.length===0?0:Math.max(...I)+1;return g.set(M,Q),Q};for(const M of f)y(M);xE(f,u,g);const _=new Map;for(const M of f){const N=g.get(M)??0,A=_.get(N)??[];A.push(M),_.set(N,A)}for(const[M,N]of _)N.sort((A,I)=>{const Q=u.get(A),Z=u.get(I),U=Fy(Q,x),le=Fy(Z,x);return U!==le?U-le:(x.get(A)??0)-(x.get(I)??0)}),_.set(M,N);const v=[],j=new Map,k=Array.from(_.keys()).sort((M,N)=>M-N),E=new Map;for(const[M,N]of _){const A=mE(N,u,t,i,l);E.set(M,A)}const w=Math.max(...Array.from(E.values()));for(const M of k){const N=_.get(M)??[],A=E.get(M)??0,I=Math.max(0,(w-A)/2);let Q=zo+I;N.forEach(Z=>{const U=u.get(Z);if(!U)return;const le=Rv(U,t,i,l),W={task:U,layer:M,x:zo+M*(Yi+Hy),y:Q,height:le};v.push(W),j.set(Z,W),Q+=le+Ev})}const T=[];for(const M of v)for(const N of M.task.dependsOnIds){const A=j.get(N);A&&T.push({fromTaskId:N,toTaskId:M.task.id,startX:A.x+Yi,startY:A.y+A.height/2,endX:M.x,endY:M.y+M.height/2})}const R=k.at(-1)??0,z=zo*2+Yi+R*(Yi+Hy),L=zo*2+w;return{nodes:v,connections:T,width:z,height:L}}function fE(n,t){const i=new Map;for(const l of n)for(const c of l.tags)i.set(c.name,(i.get(c.name)??0)+1);for(const l of t)i.has(l.name)||i.set(l.name,0);return Array.from(i.entries()).map(([l,c])=>({name:l,count:c})).sort((l,c)=>l.name.localeCompare(c.name))}function pE(n,t){if(t.length===0)return n;const i=new Set(t);return n.filter(l=>l.tags.some(c=>i.has(c.name)))}function gE(n,t,i,l){const c=new Map,u=new Map;for(const f of n){const x=t.get(f);if(!x)continue;const g=x.dependsOnIds.filter(m=>n.has(m));c.set(f,g);for(const m of g){const y=u.get(m)??[];y.push(f),u.set(m,y)}}for(const f of Array.from(n)){if(f===l||!Av(f,t,i))continue;Vy(f,c,t,i)||Vy(f,u,t,i)||n.delete(f)}}function Vy(n,t,i,l){const c=new Set([n]),u=[...t.get(n)??[]];for(;u.length>0;){const f=u.pop();if(!(!f||c.has(f))){if(c.add(f),!Av(f,i,l))return!0;u.push(...t.get(f)??[])}}return!1}function Av(n,t,i){const l=t.get(n);return(i.get(n)??l?.status)===_e.DONE}function mE(n,t,i,l,c){return n.reduce((u,f,x)=>{const g=t.get(f),m=g?Rv(g,i,l,c):wv;return u+m+(x>0?Ev:0)},0)}function Rv(n,t,i,l){const c=t.get(n.id)??n.status,u=i.has(n.id)||l.has(n.id);return n.assigneeActor?.slug&&(c===_e.IN_PROGRESS||c===_e.FOR_REVIEW)?sE:Nv(c,u)?tE:wv}function yE(n){return n.kind.startsWith("execution.")?n.kind!=="execution.stopped"&&n.kind!=="execution.history.added"&&n.kind!=="execution.unclaimed":!1}function Fy(n,t){return!n||n.dependsOnIds.length===0?Number.MAX_SAFE_INTEGER:Math.min(...n.dependsOnIds.map(i=>t.get(i)??Number.MAX_SAFE_INTEGER))}function xE(n,t,i){const l=new Map;for(const u of n){const f=t.get(u);if(f)for(const x of f.dependsOnIds){if(!n.has(x))continue;const g=l.get(x)??[];g.push(u),l.set(x,g)}}let c=!0;for(;c;){c=!1;for(const u of n){const f=l.get(u);if(!f||f.length===0)continue;const x=Math.min(...f.map(y=>i.get(y)??0)),g=Math.max(0,x-1),m=i.get(u)??0;g>m&&(i.set(u,g),c=!0)}}}function vE(n,t,i){const l=i?n.nodes.find(c=>c.task.id===i):void 0;return l?zv(l,t):{x:0,y:0}}function zv(n,t){return t?{x:t.clientWidth/2-n.x-Yi/2,y:t.clientHeight/2-n.y-n.height/2}:{x:0,y:0}}function Yy(n){return Math.min(aE,Math.max(nE,Number(n.toFixed(2))))}const Qy=100,bE=()=>{const[n,t]=h.useState([]),[i,l]=h.useState({}),[c,u]=h.useState([]),[f,x]=h.useState(!1),[g,m]=h.useState(null),y=h.useCallback(N=>{l(A=>({...A,[N.id]:N})),u(A=>A.some(Q=>Q.id===N.id)?A.map(Q=>Q.id===N.id?N:Q):[N,...A])},[]),_=h.useCallback(N=>{t(A=>A.find(Q=>Q.id===N.id)?A.map(Q=>Q.id===N.id?N:Q):[N,...A])},[]),v=h.useCallback(async()=>{x(!0),m(null);try{const N=await Cr.ScheduledTasksController_listScheduledTasks({page:1,limit:Qy});t(N.items),N.items.forEach(A=>{A.taskBlueprint&&y(A.taskBlueprint)})}catch(N){m(N instanceof Error?N.message:"Failed to load scheduled tasks")}finally{x(!1)}},[y]),j=h.useCallback(async N=>{const A=await Cr.ScheduledTasksController_getScheduledTask({id:N});return _(A),A.taskBlueprint&&y(A.taskBlueprint),A},[_,y]),k=h.useCallback(async N=>{const A=await Ui.TaskBlueprintsController_getTaskBlueprint({id:N});return y(A),A},[y]),E=h.useCallback(async()=>{m(null);try{const N=await Ui.TaskBlueprintsController_listTaskBlueprints({page:1,limit:Qy});u(N.items),N.items.forEach(A=>y(A))}catch(N){m(N instanceof Error?N.message:"Failed to load task blueprints")}},[y]),w=h.useCallback(async N=>{const A=await Ui.TaskBlueprintsController_createTaskBlueprint({body:N});return y(A),A},[y]),T=h.useCallback(async(N,A)=>{const I=await Ui.TaskBlueprintsController_updateTaskBlueprint({id:N,body:A});return y(I),I},[y]),R=h.useCallback(async N=>{const A=await Cr.ScheduledTasksController_createScheduledTask({body:N});return _(A),A.taskBlueprint&&y(A.taskBlueprint),A},[_,y]),z=h.useCallback(async(N,A)=>{const I=await Cr.ScheduledTasksController_updateScheduledTask({id:N,body:A});return _(I),I.taskBlueprint&&y(I.taskBlueprint),I},[_,y]),L=h.useCallback(async N=>{await Cr.ScheduledTasksController_deleteScheduledTask({id:N}),t(A=>A.filter(I=>I.id!==N))},[]),M=h.useCallback(async N=>{await Ui.TaskBlueprintsController_deleteTaskBlueprint({id:N}),u(A=>A.filter(I=>I.id!==N)),l(A=>{const I={...A};return delete I[N],I})},[]);return h.useEffect(()=>{v()},[v]),{scheduledTasks:n,blueprintsById:i,blueprints:c,isLoading:f,error:g,loadScheduledTasks:v,loadScheduledTask:j,loadBlueprint:k,loadBlueprints:E,createBlueprint:w,updateBlueprint:T,createScheduledTask:R,updateScheduledTask:z,deleteScheduledTask:L,deleteBlueprint:M}},Dv=h.createContext(null);function _E({children:n}){const{scheduledTasks:t,blueprints:i,blueprintsById:l,isLoading:c,error:u,loadScheduledTasks:f,loadScheduledTask:x,loadBlueprint:g,loadBlueprints:m,createBlueprint:y,updateBlueprint:_,createScheduledTask:v,updateScheduledTask:j,deleteScheduledTask:k,deleteBlueprint:E}=bE(),[w,T]=h.useState(""),R=h.useMemo(()=>({scheduledTasks:t,blueprints:i,blueprintsById:l,isLoading:c,error:u,sectionTitle:w,setSectionTitle:T,loadScheduledTasks:f,loadScheduledTask:x,loadBlueprint:g,loadBlueprints:m,createBlueprint:y,updateBlueprint:_,createScheduledTask:v,updateScheduledTask:j,deleteScheduledTask:k,deleteBlueprint:E}),[t,i,l,c,u,w,f,x,g,m,y,_,v,j,k,E]);return a.jsx(Dv.Provider,{value:R,children:n})}function Nh(){const n=h.useContext(Dv);if(!n)throw new Error("useScheduledTasksCtx must be used within <ScheduledTasksProvider>");return n}const Yo=n=>String(n).padStart(2,"0"),SE=n=>{const[t="0",i="0"]=n.split(":"),l=Number(t),c=Number(i);return{hour:Number.isFinite(l)?l:0,minute:Number.isFinite(c)?c:0}},jE=(n,t,i)=>{if(!n||n==="*")return[];const l=n.split(","),c=[];for(const u of l){const f=u.trim();if(f)if(f.includes("-")){const[x,g]=f.split("-"),m=Number(x),y=Number(g);if(!Number.isFinite(m)||!Number.isFinite(y))continue;const _=Math.max(t,Math.min(m,y)),v=Math.min(i,Math.max(m,y));for(let j=_;j<=v;j+=1)c.push(j)}else{const x=Number(f);Number.isFinite(x)&&x>=t&&x<=i&&c.push(x)}}return Array.from(new Set(c)).sort((u,f)=>u-f)},kE=n=>{if(n.preset==="custom")return n.cronExpression.trim();const{hour:t,minute:i}=SE(n.time),l=Yo(i),c=Yo(t);if(n.preset==="daily")return`${l} ${c} * * *`;if(n.preset==="weekly"){const f=n.days.length?n.days.join(","):"1";return`${l} ${c} * * ${f}`}const u=Math.min(Math.max(n.dayOfMonth,1),28);return`${l} ${c} ${u} * *`},Ov=n=>{const t=n.trim(),i=t.split(/\s+/);if(i.length<5)return{preset:"custom",time:"09:00",days:[],dayOfMonth:1,cronExpression:t};const[l,c,u,f,x]=i,g=`${Yo(Number(c))}:${Yo(Number(l))}`;if(u==="*"&&f==="*"&&x==="*")return{preset:"daily",time:g,days:[],dayOfMonth:1,cronExpression:t};if(u==="*"&&f==="*"&&x!=="*"){const m=jE(x,0,7).map(y=>y===7?0:y);return m.length?{preset:"weekly",time:g,days:m,dayOfMonth:1,cronExpression:t}:{preset:"custom",time:g,days:[],dayOfMonth:1,cronExpression:t}}if(u!=="*"&&f==="*"&&x==="*"){const m=Number(u);return{preset:"monthly",time:g,days:[],dayOfMonth:Number.isFinite(m)?m:1,cronExpression:t}}return{preset:"custom",time:"09:00",days:[],dayOfMonth:1,cronExpression:t}},Lv=n=>{if(n.preset==="custom")return`Cron: ${n.cronExpression}`;if(n.preset==="daily")return`Daily at ${n.time}`;if(n.preset==="weekly"){const t=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];return`Weekly on ${(n.days.length?n.days:[1]).map(c=>t[c]??"").join(", ")} at ${n.time}`}return`Monthly on day ${n.dayOfMonth} at ${n.time}`},TE=/^[\d*/,\-]+$/,wE=n=>{const t=n.trim().split(/\s+/);return t.length!==5?"Cron must have 5 fields: minute hour day-of-month month day-of-week.":t.some(i=>!i||!TE.test(i))?"Cron can only include digits, *, /, -, and commas.":null};function EE({blueprints:n,onCancel:t,onSave:i,onRequestNewBlueprint:l}){const[c,u]=h.useState(""),[f,x]=h.useState(null),[g,m]=h.useState(0),y=h.useMemo(()=>{const v=c.trim().toLowerCase();return v?n.filter(j=>[j.name,j.description||"",j.assigneeActor?.displayName||"",j.assigneeActor?.slug||""].join(" ").toLowerCase().includes(v)):n},[n,c]),_=async()=>f?i(f):!1;return a.jsx(gt,{title:"Create Schedule",onCancel:t,onSave:_,children:a.jsxs("div",{className:"new-schedule-pop",children:[f?a.jsxs("div",{className:"new-schedule-pop__selected",onClick:()=>x(null),children:[a.jsx(He,{size:"md",name:f.name,src:f.assigneeActor?.avatarUrl||void 0}),a.jsxs("div",{className:"new-schedule-pop__selected-meta",children:[a.jsx(b,{weight:"medium",size:"3",children:f.name}),a.jsx(b,{tone:"muted",size:"2",children:f.description||"No description"})]}),a.jsx(b,{size:"2",tone:"muted",children:"tap to change"})]}):a.jsxs(a.Fragment,{children:[a.jsx("input",{className:"new-schedule-pop__input",placeholder:"Search blueprint by name...",value:c,onChange:v=>u(v.target.value),onKeyDown:v=>{v.key==="ArrowDown"&&(v.preventDefault(),m(j=>Math.min(j+1,y.length-1))),v.key==="ArrowUp"&&(v.preventDefault(),m(j=>Math.max(j-1,0))),v.key==="Enter"&&y[g]&&(v.preventDefault(),x(y[g]))}}),a.jsx("div",{className:"new-schedule-pop__list",children:y.length===0?a.jsx("div",{className:"new-schedule-pop__empty",children:a.jsx(b,{tone:"muted",size:"2",children:"No blueprints found"})}):y.map((v,j)=>a.jsxs("div",{className:`new-schedule-pop__item ${j===g?"new-schedule-pop__item--highlighted":""}`,onMouseEnter:()=>m(j),onClick:()=>x(v),children:[a.jsx(He,{size:"sm",name:v.name,src:v.assigneeActor?.avatarUrl||void 0}),a.jsxs("div",{className:"new-schedule-pop__item-meta",children:[a.jsx(b,{size:"2",weight:"medium",children:v.name}),a.jsx(b,{size:"1",tone:"muted",children:v.assigneeActor?`@${v.assigneeActor.slug}`:"Unassigned"})]})]},v.id))})]}),a.jsx(ue,{size:"sm",variant:"secondary",onClick:l,children:"+ New blueprint"})]})})}function CE(){const n=ze(),{scheduledTasks:t,blueprints:i,isLoading:l,error:c,createBlueprint:u,createScheduledTask:f,deleteScheduledTask:x,loadBlueprints:g}=Nh(),{setSectionTitle:m}=qn(),{showError:y}=ds(),_=Rt(),[v,j]=h.useState(!1),[k,E]=h.useState(!1),w=h.useRef(!1);jt(),h.useEffect(()=>{m("Schedule")},[m]),h.useEffect(()=>{g().catch(y)},[g,y]);const T=h.useMemo(()=>t.filter(N=>N.enabled).length,[t]),R=async N=>{try{const A=await u({name:N.title,description:N.description});return j(!1),n(`/tasks/blueprints/${A.id}`),!0}catch(A){return y(A),!1}},z=async N=>{if(w.current)return!1;w.current=!0;try{const A=await f({taskBlueprintId:N.id,cronExpression:"0 9 * * *",enabled:!1});return E(!1),n(`/tasks/schedule/${A.id}`),!0}catch(A){return y(A),!1}finally{w.current=!1}},L=h.useMemo(()=>i.map(N=>({id:N.id,name:N.name,description:N.description,status:_e.NOT_STARTED,assignee:null,assigneeActor:N.assigneeActor??void 0,sessionId:null,comments:[],artefacts:[],inputRequests:[],tags:N.tags,createdByActor:N.createdByActor,dependsOnIds:N.dependsOnIds,createdAt:N.createdAt,updatedAt:N.updatedAt})),[i]),M=async N=>{if(window.confirm("Delete this schedule?"))try{await x(N.id)}catch(A){y(A)}};return a.jsxs("div",{className:"scheduled-tasks-page",children:[c?a.jsx(b,{tone:"muted",children:c}):null,a.jsx("section",{className:"scheduled-tasks-page__section",children:l?a.jsx(b,{tone:"muted",children:"Loading scheduled tasks..."}):a.jsx(ye,{title:"Schedules",action:a.jsxs("div",{className:"scheduled-tasks-page__header-actions",children:[a.jsxs(b,{size:"2",tone:"muted",children:[T," active schedules"]}),a.jsx(ue,{size:"sm",variant:"secondary",onClick:()=>E(!0),children:"+ Add schedule"})]}),children:t.length===0?a.jsxs(Fe,{className:"scheduled-tasks-page__empty",children:[a.jsx(b,{weight:"medium",children:"No schedules yet"}),a.jsx(b,{tone:"muted",children:"Create a schedule from a blueprint."})]}):t.map(N=>{const A=N.taskBlueprint,I=Lv(Ov(N.cronExpression));return a.jsxs(be,{onClick:()=>n(`/tasks/schedule/${N.id}`),tags:[{label:N.enabled?"enabled":"paused",color:N.enabled?"green":"gray"}],topRight:a.jsxs(b,{size:"1",tone:"muted",children:["Next: ",new Date(N.nextRunAt).toLocaleString()]}),trailing:a.jsx(ue,{size:"sm",variant:"danger",onClick:Q=>{Q.stopPropagation(),M(N)},children:"Delete"}),children:[a.jsx(b,{as:"span",weight:"medium",size:"3",children:A?.name||"Untitled blueprint"}),a.jsx(b,{as:"span",size:"2",tone:"muted",children:` ${I}`})]},N.id)})})}),a.jsx("section",{className:"scheduled-tasks-page__section",children:L.length===0?a.jsxs(Fe,{className:"scheduled-tasks-page__empty",children:[a.jsx(b,{weight:"medium",children:"No blueprints yet"}),a.jsx(b,{tone:"muted",children:"Create a blueprint to reuse task definitions."})]}):_?a.jsx(ye,{title:"Blueprints",action:a.jsxs("div",{className:"scheduled-tasks-page__header-actions",children:[a.jsxs(b,{size:"2",tone:"muted",children:[i.length," blueprints"]}),a.jsx(ue,{size:"sm",variant:"secondary",onClick:()=>j(!0),children:"+ New blueprint"})]}),children:a.jsx("div",{className:"scheduled-tasks-page__blueprints-board",children:L.map(N=>a.jsx(Po,{task:N,onClick:()=>n(`/tasks/blueprints/${N.id}`)},N.id))})}):a.jsx(ye,{title:"Blueprints",action:a.jsxs("div",{className:"scheduled-tasks-page__header-actions",children:[a.jsxs(b,{size:"2",tone:"muted",children:[i.length," blueprints"]}),a.jsx(ue,{size:"sm",variant:"secondary",onClick:()=>j(!0),children:"+ New blueprint"})]}),children:L.map(N=>a.jsx(Ki,{task:N,onClick:()=>n(`/tasks/blueprints/${N.id}`)},N.id))})}),v?a.jsx(eh,{onCancel:()=>j(!1),onSave:R}):null,k?a.jsx(EE,{blueprints:i,onCancel:()=>E(!1),onSave:z,onRequestNewBlueprint:()=>{E(!1),j(!0)}}):null]})}const NE=[{value:0,label:"Sun"},{value:1,label:"Mon"},{value:2,label:"Tue"},{value:3,label:"Wed"},{value:4,label:"Thu"},{value:5,label:"Fri"},{value:6,label:"Sat"}];function AE(){const{scheduleId:n}=Wt(),t=ze(),{scheduledTasks:i,blueprintsById:l,loadScheduledTask:c,loadBlueprint:u,updateScheduledTask:f}=Nh(),{setSectionTitle:x}=qn(),{showError:g,showToast:m}=ds(),[y,_]=h.useState("daily"),[v,j]=h.useState("09:00"),[k,E]=h.useState([1]),[w,T]=h.useState(1),[R,z]=h.useState("0 9 * * *"),[L,M]=h.useState(!1),[N,A]=h.useState(!1),[I,Q]=h.useState(null),Z=i.find(B=>B.id===n),U=Z?.taskBlueprint||(Z?l[Z.taskBlueprintId]:void 0);jt(),h.useEffect(()=>{n&&(Z||c(n).catch(g))},[n,Z,c,g]),h.useEffect(()=>{Z&&!Z.taskBlueprint&&u(Z.taskBlueprintId).catch(g)},[Z,u,g]),h.useEffect(()=>{U?.name?x(U.name):x("Schedule")},[U,x]),h.useEffect(()=>{if(!Z)return;const B=Ov(Z.cronExpression);_(B.preset),j(B.time),E(B.days.length?B.days:[1]),T(B.dayOfMonth||1),z(B.cronExpression||Z.cronExpression),M(Z.enabled)},[Z]);const le=h.useMemo(()=>kE({preset:y,time:v,days:k,dayOfMonth:w,cronExpression:R}),[y,v,k,w,R]);if(!Z)return a.jsxs("div",{className:"scheduled-task-detail-page",children:[a.jsx(b,{tone:"muted",children:"Scheduled task not found."}),a.jsx(ue,{variant:"secondary",onClick:()=>t("/tasks/schedule"),children:"Back to schedules"})]});const W=Lv({preset:y,time:v,days:k,dayOfMonth:w,cronExpression:le}),oe=B=>{E(se=>{if(se.includes(B)){const ge=se.filter(Ee=>Ee!==B);return ge.length?ge:se}return[...se,B].sort((ge,Ee)=>ge-Ee)})},me=async()=>{if(y==="custom"){const B=wE(le);if(B){Q(B);return}}Q(null),A(!0);try{await f(Z.id,{cronExpression:le,enabled:L}),m("Schedule saved","success")}catch(B){g(B)}finally{A(!1)}};return a.jsxs("div",{className:"scheduled-task-detail-page",children:[a.jsx(ye,{title:"Task",className:"scheduled-task-detail-page__section",children:a.jsxs(be,{onClick:()=>t(`/tasks/blueprints/${Z.taskBlueprintId}`),tags:[{label:"blueprint",color:"blue"}],trailing:a.jsx(b,{size:"2",tone:"muted",children:"Open"}),children:[a.jsx(b,{as:"span",weight:"medium",size:"3",children:U?.name||"Untitled blueprint"}),a.jsx(b,{as:"span",tone:"muted",size:"2",children:` ${U?.description||"No description"}`})]})}),a.jsxs(ye,{title:"Schedule",className:"scheduled-task-detail-page__section",children:[a.jsxs("div",{className:"scheduled-task-detail-page__controls",children:[a.jsxs("label",{className:"scheduled-task-detail-page__label",children:[a.jsx(b,{size:"2",tone:"muted",children:"Frequency"}),a.jsxs("select",{className:"scheduled-task-detail-page__select",value:y,onChange:B=>_(B.target.value),children:[a.jsx("option",{value:"daily",children:"Daily"}),a.jsx("option",{value:"weekly",children:"Weekly"}),a.jsx("option",{value:"monthly",children:"Monthly"}),a.jsx("option",{value:"custom",children:"Custom (cron)"})]})]}),y!=="custom"?a.jsxs("label",{className:"scheduled-task-detail-page__label",children:[a.jsx(b,{size:"2",tone:"muted",children:"Time"}),a.jsx("input",{className:"scheduled-task-detail-page__input",type:"time",value:v,onChange:B=>j(B.target.value)})]}):null,y==="weekly"?a.jsxs("div",{className:"scheduled-task-detail-page__label",children:[a.jsx(b,{size:"2",tone:"muted",children:"Days"}),a.jsx("div",{className:"scheduled-task-detail-page__day-grid",children:NE.map(B=>a.jsx("button",{type:"button",className:`scheduled-task-detail-page__day ${k.includes(B.value)?"is-selected":""}`,onClick:()=>oe(B.value),children:B.label},B.value))})]}):null,y==="monthly"?a.jsxs("label",{className:"scheduled-task-detail-page__label",children:[a.jsx(b,{size:"2",tone:"muted",children:"Date"}),a.jsx("input",{className:"scheduled-task-detail-page__input",type:"date",value:`2026-01-${String(Math.min(Math.max(w,1),28)).padStart(2,"0")}`,onChange:B=>{const se=new Date(`${B.target.value}T00:00:00`).getDate();Number.isFinite(se)&&T(Math.min(Math.max(se,1),28))}})]}):null,y==="custom"?a.jsxs("label",{className:"scheduled-task-detail-page__label",children:[a.jsx(b,{size:"2",tone:"muted",children:"Cron expression"}),a.jsx("input",{className:"scheduled-task-detail-page__input",value:R,onChange:B=>{z(B.target.value),I&&Q(null)},placeholder:"0 9 * * 1-5"}),a.jsx(b,{size:"1",tone:"muted",children:"Use 5 fields: minute hour day-of-month month day-of-week."})]}):null,a.jsx(b,{size:"1",tone:"muted",children:"Schedules run using the server timezone."}),I?a.jsx(Zt,{size:"1",children:I}):null,a.jsxs("div",{className:"scheduled-task-detail-page__toggle-row",children:[a.jsx(b,{size:"2",tone:"muted",children:"Status"}),a.jsxs("div",{className:"scheduled-task-detail-page__toggle-buttons",children:[a.jsx(ue,{size:"sm",variant:L?"primary":"secondary",onClick:()=>M(!0),children:"On"}),a.jsx(ue,{size:"sm",variant:L?"secondary":"primary",onClick:()=>M(!1),children:"Off"})]})]})]}),a.jsx(be,{topRight:a.jsxs(b,{size:"1",tone:"muted",children:["Next: ",new Date(Z.nextRunAt).toLocaleString()]}),children:a.jsx(b,{as:"span",size:"2",children:W})}),a.jsx(be,{children:a.jsx(b,{as:"span",size:"2",style:"mono",children:le})})]}),a.jsxs(ye,{className:"scheduled-task-detail-page__actions",children:[a.jsx(ue,{size:"lg",variant:"primary",onClick:me,disabled:N,children:N?"Saving...":"Save schedule"}),a.jsx(ue,{size:"lg",variant:"secondary",onClick:()=>t("/tasks/schedule"),children:"Back to schedules"})]})]})}function RE(){const{taskBlueprintId:n}=Wt(),{user:t}=us(),{showError:i}=ds(),{blueprints:l,blueprintsById:c,loadBlueprint:u,updateBlueprint:f,deleteBlueprint:x}=Nh(),{setSectionTitle:g,tasks:m}=qn(),y=h.useMemo(()=>{if(n)return c[n]||l.find(j=>j.id===n)},[l,c,n]);h.useEffect(()=>{!n||y||u(n).catch(i)},[n,y,u,i]);const _=h.useMemo(()=>{if(y)return{id:y.id,name:y.name,description:y.description,status:_e.NOT_STARTED,assignee:null,assigneeActor:y.assigneeActor??void 0,sessionId:null,comments:[],artefacts:[],inputRequests:[],tags:y.tags,createdByActor:y.createdByActor,dependsOnIds:y.dependsOnIds,createdAt:y.createdAt,updatedAt:y.updatedAt}},[y]),v={addComment:async()=>{throw new Error("Blueprints do not support comments.")},deleteTask:async({taskId:j})=>{await x(j)},assignTask:async({taskId:j,assigneeActorId:k})=>{await f(j,{assigneeActorId:k})},assignTaskToMe:async({taskId:j})=>{if(!t?.actorId)throw new Error("No user session found.");await f(j,{assigneeActorId:t.actorId})},answerInputRequest:async()=>{throw new Error("Blueprints do not support input requests.")},changeStatus:async()=>{throw new Error("Blueprints do not have status updates.")},addTag:async({taskId:j,tag:k})=>{const E=y?.tags?.map(T=>T.name)??[],w=E.includes(k.name)?E:[...E,k.name];await f(j,{tagNames:w})},removeTag:async({taskId:j,tagId:k})=>{const w=(y?.tags??[]).filter(T=>T.id!==k).map(T=>T.name);await f(j,{tagNames:w})},addDependency:async({taskId:j,dependencyTaskId:k})=>{const w=[...y?.dependsOnIds??[],k];await f(j,{dependsOnIds:w})},removeDependency:async({taskId:j,dependencyTaskId:k})=>{const w=(y?.dependsOnIds??[]).filter(T=>T!==k);await f(j,{dependsOnIds:w})}};return a.jsx(Tv,{task:_,backPath:"/tasks/schedule",setSectionTitle:g,handlers:v,allTasks:m})}function zE(){return a.jsx(_E,{children:a.jsx(Kt,{})})}function DE(){return a.jsx(j1,{children:a.jsx(dn,{children:a.jsxs(Se,{element:a.jsx(D1,{}),children:[a.jsx(Se,{index:!0,element:a.jsx(Ia,{to:"/tasks/not-started",replace:!0})}),a.jsx(Se,{path:"not-started",element:a.jsx(Ao,{status:_e.NOT_STARTED})}),a.jsx(Se,{path:"in-progress",element:a.jsx(Ao,{status:_e.IN_PROGRESS})}),a.jsx(Se,{path:"in-review",element:a.jsx(Ao,{status:_e.FOR_REVIEW})}),a.jsx(Se,{path:"done",element:a.jsx(Ao,{status:_e.DONE})}),a.jsx(Se,{path:"dependencies",element:a.jsx(Gy,{})}),a.jsx(Se,{path:"dependencies/:taskId",element:a.jsx(Gy,{})}),a.jsx(Se,{path:"task/:d",element:a.jsx(K1,{})}),a.jsxs(Se,{element:a.jsx(zE,{}),children:[a.jsx(Se,{path:"schedule",element:a.jsx(CE,{})}),a.jsx(Se,{path:"schedule/:scheduleId",element:a.jsx(AE,{})}),a.jsx(Se,{path:"blueprints/:taskBlueprintId",element:a.jsx(RE,{})})]})]})})})}function OE(){const{logout:n}=us(),t=ze();return h.useEffect(()=>{(async()=>{try{await n()}finally{t("/login",{replace:!0})}})()},[n,t]),null}const LE=window.location.origin,Mv=new Ws({baseUrl:LE,credentials:"include"}),qa=Mv.context;Mv.context;const qv=pa("/context"),Xi={CONTEXT_BLOCK_CREATED:"context.block.created",CONTEXT_BLOCK_UPDATED:"context.block.updated",CONTEXT_BLOCK_DELETED:"context.block.deleted"};function ME(){const[n,t]=h.useState([]),[i,l]=h.useState(!0),[c,u]=h.useState(null),[f,x]=h.useState(!1),g=v=>[...v].sort((j,k)=>{const E=new Date(j.updatedAt).getTime();return new Date(k.updatedAt).getTime()-E}),m=async()=>{try{l(!0),u(null);const v=await qa.ContextController_listBlocks();t(g(v.items))}catch(v){u(v instanceof Error?v.message:"Failed to fetch context blocks"),console.error("Error fetching context blocks:",v)}finally{l(!1)}},y=()=>{const v=Bs(qv,{transports:["websocket","polling"],withCredentials:!0});return v.on("connect",()=>{console.log("Connected to context WebSocket"),v.emit("context.subscribe",{},j=>{j.ok?(console.log("Subscribed to context room:",j.room),x(!0)):(console.error("Failed to subscribe to context room"),x(!1))}),m()}),v.on("disconnect",()=>{console.log("Context WebSocket disconnected"),x(!1)}),v.on("connect_error",j=>{console.error("Context websocket connect_error",j.message)}),v.on(Xi.CONTEXT_BLOCK_CREATED,j=>{console.log("context.block.created",j),t(k=>k.some(E=>E.id===j.payload.id)?k:g([j.payload,...k]))}),v.on(Xi.CONTEXT_BLOCK_UPDATED,j=>{console.log("context.block.updated",j),t(k=>g(k.map(E=>E.id===j.payload.id?j.payload:E)))}),v.on(Xi.CONTEXT_BLOCK_DELETED,j=>{console.log("context.block.deleted",j),t(k=>k.filter(E=>E.id!==j.payload.blockId))}),()=>{v.emit("context.unsubscribe",{}),v.close()}},_=h.useCallback(async v=>{try{const j=await qa.ContextController_getBlock({id:v});return t(k=>k.some(E=>E.id===j.id)?k:g([j,...k])),j}catch(j){return console.error("Failed to fetch block by ID",j),null}},[]);return h.useEffect(()=>(m(),y()),[]),{blocks:n,getBlockById:_,isLoading:i,error:c,isConnected:f,reload:m}}function qE(n){const[t,i]=h.useState(null),[l,c]=h.useState(!0),[u,f]=h.useState(null),[x,g]=h.useState(!1),m=h.useCallback(async()=>{try{c(!0),f(null);const y=await qa.ContextController_getBlock({id:n});i(y),g(!1)}catch(y){f(y instanceof Error?y.message:"Failed to fetch context block"),console.error("Error fetching context block:",y)}finally{c(!1)}},[n]);return h.useEffect(()=>{n&&m()},[n,m]),h.useEffect(()=>{if(!n)return;const y=Bs(qv,{transports:["websocket","polling"],withCredentials:!0});return y.on("connect",()=>{console.log("Connected to context WebSocket (detail page)"),y.emit("context.subscribe",{blockId:n},_=>{_.ok?(console.log("Subscribed to context room (detail page):",_.room),m()):console.error("Failed to subscribe to context room (detail page)",_.error)})}),y.on("connect_error",_=>{console.error("Context detail websocket connect_error",_.message)}),y.on("disconnect",()=>{console.log("Context WebSocket disconnected (detail page)")}),y.on(Xi.CONTEXT_BLOCK_UPDATED,_=>{_.payload.id===n&&(console.log("context.block.updated (detail page)",_),m().catch(v=>console.error("Error refreshing block after update:",v)))}),y.on(Xi.CONTEXT_BLOCK_DELETED,_=>{_.payload.blockId===n&&(console.log("context.block.deleted (detail page)",_),g(!0),i(null))}),()=>{y.emit("context.unsubscribe",{blockId:n}),y.close()}},[n,m]),{block:t,isLoading:l,error:u,isDeleted:x}}const Iv=h.createContext(null);function IE({children:n}){const{blocks:t,getBlockById:i,isLoading:l,error:c,isConnected:u,reload:f}=ME(),[x,g]=h.useState(""),m=h.useMemo(()=>({blocks:t,getBlockById:i,isLoading:l,error:c,isConnected:u,reload:f,sectionTitle:x,setSectionTitle:g}),[t,i,l,c,u,f,x,g]);return a.jsx(Iv.Provider,{value:m,children:n})}function ac(){const n=h.useContext(Iv);if(!n)throw new Error("useContextCtx must be used within <ContextProvider>");return n}const BE=6;function Bv(n){return typeof n=="string"?n:n&&typeof n=="object"&&"id"in n&&typeof n.id=="string"?n.id:null}function Ky(n,t){return n.order!==t.order?t.order-n.order:n.title.localeCompare(t.title)}function UE(n){const t=new Map;n.forEach(u=>{t.set(u.id,{block:u,children:[],latestUpdatedAt:new Date(u.updatedAt).getTime()})});const i=[];n.forEach(u=>{const f=t.get(u.id);if(!f)return;const x=Bv(u.parentId);if(!x){i.push(f);return}const g=t.get(x);if(!g){i.push(f);return}g.children.push(f)});const l=u=>{u.sort((f,x)=>Ky(f.block,x.block)),u.forEach(f=>l(f.children))};l(i);const c=u=>{if(u.children.length===0)return u.latestUpdatedAt;let f=u.latestUpdatedAt;return u.children.forEach(x=>{const g=c(x);g>f&&(f=g)}),u.latestUpdatedAt=f,f};return i.forEach(u=>{c(u)}),i.sort((u,f)=>{const x=f.latestUpdatedAt-u.latestUpdatedAt;return x!==0?x:Ky(u.block,f.block)}),i}function Uv({nodes:n,depth:t,onOpenBlock:i,onAddChild:l,collapsedIds:c,onToggleNode:u,selectedBlockId:f,compact:x=!1}){return a.jsx("ul",{className:"context-tree__branch",role:t===0?"tree":"group",children:n.map(g=>{const m=g.children.length>0,y=m?!c.has(g.block.id):!1,_=Math.min(t,BE),v=f===g.block.id;return a.jsxs("li",{className:"context-tree__item",role:"treeitem","aria-expanded":m?y:void 0,children:[a.jsxs("div",{className:`context-tree__row ${v?"context-tree__row--selected":""} ${x?"context-tree__row--compact":""}`,style:{"--tree-depth":_},children:[m?a.jsx("button",{type:"button",className:"context-tree__toggle","aria-expanded":y,"aria-label":y?`Collapse ${g.block.title}`:`Expand ${g.block.title}`,onClick:()=>u(g.block.id),children:a.jsx("span",{className:"context-tree__marker","aria-hidden":"true",children:y?"▼":"►"})}):a.jsx("span",{className:"context-tree__spacer","aria-hidden":"true"}),a.jsxs("button",{type:"button",className:"context-tree__open",onClick:()=>i(g.block.id),children:[a.jsxs("div",{className:"context-tree__main",children:[a.jsx(b,{weight:v?"bold":"medium",size:x?"2":"3",tone:"default",className:"context-tree__title",children:g.block.title}),x?null:a.jsxs("div",{className:"context-tree__meta",children:[a.jsxs("span",{className:"context-tree__id",children:["#",g.block.id.slice(0,6)]}),a.jsx("span",{children:g.block.createdBy||"unknown"})]})]}),!x&&g.block.tags.length>0?a.jsxs("div",{className:"context-tree__tags","aria-label":"Block tags",children:[g.block.tags.slice(0,2).map(j=>a.jsx("span",{className:"context-tree__tag",children:j.name},`${g.block.id}-${j.id}`)),g.block.tags.length>2?a.jsxs("span",{className:"context-tree__tag context-tree__tag--count",children:["+",g.block.tags.length-2]}):null]}):null]}),l?a.jsx("button",{type:"button",className:"context-tree__add-child","aria-label":`Add child block under ${g.block.title}`,onClick:j=>{j.stopPropagation(),l(g.block.id)},children:"+"}):null]}),m&&y?a.jsx(Uv,{nodes:g.children,depth:t+1,onOpenBlock:i,onAddChild:l,collapsedIds:c,onToggleNode:u,selectedBlockId:f,compact:x}):null]},g.block.id)})})}function Xy(n){const t=new Set,i=l=>{for(const c of l)c.children.length>0&&(t.add(c.block.id),i(c.children))};return i(n),t}function $v({blocks:n,onOpenBlock:t,onAddChild:i,selectedBlockId:l,compact:c=!1}){const u=h.useMemo(()=>UE(n),[n]),[f,x]=h.useState(()=>Xy(u)),g=h.useRef(!1);h.useEffect(()=>{!g.current&&u.length>0&&(x(Xy(u)),g.current=!0)},[u]),h.useEffect(()=>{if(!l)return;const y=new Map;n.forEach(j=>{y.set(j.id,Bv(j.parentId))});const _=new Set;let v=y.get(l)??null;for(;v;)_.add(v),v=y.get(v)??null;_.size!==0&&x(j=>{const k=new Set(j);return _.forEach(E=>k.delete(E)),k})},[n,l]);const m=y=>{x(_=>{const v=new Set(_);return v.has(y)?v.delete(y):v.add(y),v})};return a.jsx("section",{className:`context-tree ${c?"context-tree--compact":""}`,children:a.jsx(Uv,{nodes:u,depth:0,onOpenBlock:t,onAddChild:i,collapsedIds:f,onToggleNode:m,selectedBlockId:l,compact:c})})}function $E(){const n=Rt(),{sectionTitle:t,blocks:i,isLoading:l,error:c}=ac(),u=ze(),f=qt(),{id:x}=Wt(),[g,m]=h.useState(!1),[y,_]=h.useState(!1);return h.useEffect(()=>{if(!n)return;const v=localStorage.getItem("context-sidebar-collapsed");m(v==="true")},[n]),h.useEffect(()=>{n&&localStorage.setItem("context-sidebar-collapsed",String(g))},[n,g]),h.useEffect(()=>{_(!1)},[f.pathname]),a.jsxs("div",{className:`context-layout ${n?"context-layout--desktop":"context-layout--mobile"}`,children:[!n&&a.jsxs(a.Fragment,{children:[y&&a.jsx("div",{className:"context-layout__drawer-overlay",onClick:()=>_(!1)}),a.jsxs("aside",{className:`context-layout__drawer ${y?"context-layout__drawer--open":""}`,children:[a.jsxs("div",{className:"context-layout__drawer-header",children:[a.jsx(b,{size:"4",weight:"bold",children:"taico"}),a.jsx("button",{className:"context-layout__drawer-close",onClick:()=>_(!1),"aria-label":"Close menu",children:"✕"})]}),a.jsx("nav",{className:"context-layout__drawer-nav",children:zr.map(v=>{const j=f.pathname===v.path||f.pathname.startsWith(v.path+"/");return a.jsxs(Mn,{to:v.path,className:`context-layout__drawer-item ${j?"context-layout__drawer-item--active":""}`,children:[a.jsx(al,{icon:v.icon,className:"context-layout__drawer-icon"}),a.jsx("span",{children:v.label})]},v.path)})})]})]}),!n&&a.jsx("header",{className:"context-layout__mobile-header",children:a.jsxs(Mt,{spacing:"5",align:"center",children:[a.jsx("button",{className:"context-layout__hamburger",onClick:()=>_(!0),"aria-label":"Open menu",children:"☰"}),a.jsx(b,{size:"3",weight:"normal",as:"div",children:"Context"}),a.jsx(b,{size:"3",weight:"semibold",as:"div",className:"context-layout__mobile-section-title",children:t})]})}),n&&a.jsxs("aside",{className:`context-desktop__sidebar ${g?"context-desktop__sidebar--collapsed":""}`,children:[a.jsx("div",{className:"context-desktop__sidebar-header",children:g?a.jsx(b,{as:"div",size:"1",tone:"muted",children:i.length}):a.jsxs(a.Fragment,{children:[a.jsx("button",{type:"button",className:"context-desktop__sidebar-title",onClick:()=>u("/context/home"),children:a.jsx(b,{as:"span",size:"2",weight:"semibold",children:"Context"})}),a.jsxs("div",{className:"context-desktop__sidebar-header-actions",children:[a.jsx(b,{as:"div",size:"1",tone:"muted",children:i.length}),a.jsx("button",{type:"button",className:"context-desktop__sidebar-new",onClick:()=>u("/context/new"),"aria-label":"New block",title:"New block",children:"+"})]})]})}),a.jsx("div",{className:"context-desktop__sidebar-body",children:g?null:l?a.jsx("div",{className:"context-home__loading",children:"Loading context blocks..."}):c?a.jsxs("div",{className:"context-home__error",children:["Error: ",c]}):i.length===0?a.jsx("div",{className:"context-home__empty",children:"No context blocks found"}):a.jsx($v,{blocks:i,onOpenBlock:v=>u(`/context/block/${v}`),onAddChild:v=>u(`/context/new?parentId=${v}`),selectedBlockId:x,compact:!0})}),a.jsx("button",{type:"button",className:"context-desktop__sidebar-toggle",onClick:()=>m(v=>!v),"aria-label":g?"Expand context sidebar":"Collapse context sidebar",children:g?"→":"←"})]}),a.jsx("main",{className:"context-layout__main",children:a.jsx(Kt,{})})]})}function HE(){const{setSectionTitle:n,blocks:t,isLoading:i,error:l}=ac(),c=ze(),u=Rt(),[f,x]=h.useState("");return jt(),h.useEffect(()=>{n("Context")},[n]),i?a.jsx("div",{className:"context-home__loading",children:"Loading context blocks..."}):l?a.jsxs("div",{className:"context-home__error",children:["Error: ",l]}):t.length===0?a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"context-home__empty",children:a.jsx("div",{className:"context-home__empty-message",children:"No context blocks found"})}),a.jsx(Id,{onClick:()=>c("/context/new"),isDesktop:u})]}):u?a.jsxs(a.Fragment,{children:[a.jsx(PE,{blocks:t,searchQuery:f,onSearchQueryChange:x,onOpenBlock:g=>c(`/context/block/${g}`)}),a.jsx(Id,{onClick:()=>c("/context/new"),isDesktop:u})]}):a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"context-home",children:a.jsx($v,{blocks:t,onOpenBlock:g=>c(`/context/block/${g}`),onAddChild:g=>c(`/context/new?parentId=${g}`)})}),a.jsx(Id,{onClick:()=>c("/context/new"),isDesktop:u})]})}function Id({onClick:n,isDesktop:t}){return t?a.jsxs("button",{className:"context-fab context-fab--desktop",type:"button",onClick:n,children:[a.jsx("span",{className:"context-fab__plus",children:"+"}),a.jsx("span",{className:"context-fab__label",children:"New block"})]}):a.jsx("button",{className:"context-fab",type:"button",onClick:n,"aria-label":"Create new block",children:"+"})}function PE({blocks:n,searchQuery:t,onSearchQueryChange:i,onOpenBlock:l}){const c=t.trim().toLowerCase(),u=h.useMemo(()=>c?n.filter(f=>[f.title,f.createdBy||"",f.id,...f.tags.map(g=>g.name)].some(g=>g.toLowerCase().includes(c))):n.slice(0,18),[n,c]);return a.jsxs("div",{className:"context-home-desktop",children:[a.jsx("div",{className:"context-home-desktop__hero",children:a.jsx(b,{as:"div",size:"6",weight:"bold",className:"context-home-desktop__title",children:"Blocks"})}),a.jsx("div",{className:"context-home-desktop__search-box",children:a.jsx("input",{type:"search",className:"context-home-desktop__search-input",placeholder:"Search by title, tag, author, or block id",value:t,onChange:f=>i(f.target.value)})}),a.jsx("div",{className:"context-home-desktop__results",children:u.length===0?a.jsxs("div",{className:"context-home-desktop__empty",children:[a.jsx(b,{as:"div",size:"3",weight:"medium",children:"No matching blocks"}),a.jsx(b,{as:"div",size:"2",tone:"muted",children:"Try a different title, tag, author, or id fragment."})]}):u.map(f=>a.jsx(be,{className:"context-home-desktop__result",onClick:()=>l(f.id),topRight:a.jsx(b,{as:"span",size:"2",tone:"muted",children:Lt(f.updatedAt)}),tags:f.tags.slice(0,3).map(x=>({label:x.name})),children:a.jsxs("div",{className:"context-home-desktop__result-main",children:[a.jsx("div",{className:"row-title",children:f.title}),a.jsxs("div",{className:"row-detail",children:["#",f.id.slice(0,6)," ",f.createdBy||"unknown"]})]})},f.id))})]})}function Ah(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var Ha=Ah();function Hv(n){Ha=n}var Oa={exec:()=>null};function Ye(n,t=""){let i=typeof n=="string"?n:n.source,l={replace:(c,u)=>{let f=typeof u=="string"?u:u.source;return f=f.replace(ts.caret,"$1"),i=i.replace(c,f),l},getRegex:()=>new RegExp(i,t)};return l}var GE=(()=>{try{return!!new RegExp("(?<=1)(?<!1)")}catch{return!1}})(),ts={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:n=>new RegExp(`^( {0,3}${n})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:n=>new RegExp(`^ {0,${Math.min(3,n-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:n=>new RegExp(`^ {0,${Math.min(3,n-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:n=>new RegExp(`^ {0,${Math.min(3,n-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:n=>new RegExp(`^ {0,${Math.min(3,n-1)}}#`),htmlBeginRegex:n=>new RegExp(`^ {0,${Math.min(3,n-1)}}<(?:[a-z].*>|!--)`,"i"),blockquoteBeginRegex:n=>new RegExp(`^ {0,${Math.min(3,n-1)}}>`)},VE=/^(?:[ \t]*(?:\n|$))+/,FE=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,YE=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,ll=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,QE=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,Rh=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,Pv=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Gv=Ye(Pv).replace(/bull/g,Rh).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),KE=Ye(Pv).replace(/bull/g,Rh).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),zh=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,XE=/^[^\n]+/,Dh=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,ZE=Ye(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Dh).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),WE=Ye(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,Rh).getRegex(),rc="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",Oh=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,JE=Ye("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",Oh).replace("tag",rc).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Vv=Ye(zh).replace("hr",ll).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",rc).getRegex(),eC=Ye(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",Vv).getRegex(),Lh={blockquote:eC,code:FE,def:ZE,fences:YE,heading:QE,hr:ll,html:JE,lheading:Gv,list:WE,newline:VE,paragraph:Vv,table:Oa,text:XE},Zy=Ye("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",ll).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",rc).getRegex(),tC={...Lh,lheading:KE,table:Zy,paragraph:Ye(zh).replace("hr",ll).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",Zy).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",rc).getRegex()},sC={...Lh,html:Ye(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Oh).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:Oa,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:Ye(zh).replace("hr",ll).replace("heading",` *#{1,6} *[^
|
|
12
|
+
`);g=_.pop()||"";for(const v of _)if(v.startsWith("data: ")){const j=v.slice(6);try{yield JSON.parse(j)}catch{yield j}}}}finally{f.releaseLock()}}}class h0 extends ht{constructor(t){super(t)}async AppController_getHello(t){return this.request("GET","/api/v1",{signal:t?.signal})}async AppController_getLive(t){return this.request("GET","/health/live",{signal:t?.signal})}async AppController_getReady(t){return this.request("GET","/health/ready",{signal:t?.signal})}}class f0 extends ht{constructor(t){super(t)}async MetaController_createTag(t){return this.request("POST","/api/v1/meta/tags",{body:t.body,signal:t?.signal})}async MetaController_getAllTags(t){return this.request("GET","/api/v1/meta/tags",{signal:t?.signal})}async MetaController_getTagColors(t){return this.request("GET","/api/v1/meta/tags/colors",{signal:t?.signal})}async MetaController_deleteTag(t){return this.request("DELETE",`/api/v1/meta/tags/${t.tagId}`,{responseType:"void",signal:t?.signal})}async MetaController_getVersion(t){return this.request("GET","/api/v1/meta/version",{signal:t?.signal})}}class p0 extends ht{constructor(t){super(t)}async ProjectsController_createProject(t){return this.request("POST","/api/v1/meta/projects",{body:t.body,signal:t?.signal})}async ProjectsController_getAllProjects(t){return this.request("GET","/api/v1/meta/projects",{signal:t?.signal})}async ProjectsController_searchProjects(t){return this.request("GET","/api/v1/meta/projects/search",{params:{q:t.q,limit:t.limit,threshold:t.threshold},signal:t?.signal})}async ProjectsController_getProjectBySlug(t){return this.request("GET",`/api/v1/meta/projects/by-slug/${t.slug}`,{signal:t?.signal})}async ProjectsController_getProject(t){return this.request("GET",`/api/v1/meta/projects/${t.projectId}`,{signal:t?.signal})}async ProjectsController_updateProject(t){return this.request("PATCH",`/api/v1/meta/projects/${t.projectId}`,{body:t.body,signal:t?.signal})}async ProjectsController_deleteProject(t){return this.request("DELETE",`/api/v1/meta/projects/${t.projectId}`,{responseType:"void",signal:t?.signal})}}class g0 extends ht{constructor(t){super(t)}async ClientRegistrationController_registerClient(t){return this.request("POST",`/api/v1/auth/clients/register/mcp/${t.serverId}/${t.version}`,{body:t.body,signal:t?.signal})}async ClientRegistrationController_getClient(t){return this.request("GET",`/api/v1/auth/clients/${t.clientId}`,{signal:t?.signal})}async ClientRegistrationController_listClients(t){return this.request("GET","/api/v1/auth/clients",{signal:t?.signal})}async AuthorizationController_authorize(t){return this.request("GET",`/api/v1/auth/authorize/mcp/${t.serverIdentifier}/${t.version}`,{params:{response_type:t.response_type,scope:t.scope,client_id:t.client_id,code_challenge:t.code_challenge,code_challenge_method:t.code_challenge_method,redirect_uri:t.redirect_uri,state:t.state,resource:t.resource},responseType:"void",signal:t?.signal})}async AuthorizationController_authorizeConsent(t){return this.request("POST",`/api/v1/auth/authorize/mcp/${t.serverIdentifier}/${t.version}`,{body:t.body,responseType:"void",signal:t?.signal})}async AuthorizationController_getConsentMetadata(t){return this.request("GET",`/api/v1/auth/consent/${t.flowId}`,{signal:t?.signal})}async AuthorizationController_token(t){return this.request("POST",`/api/v1/auth/token/mcp/${t.serverIdentifier}/${t.version}`,{body:t.body,signal:t?.signal})}async AuthorizationController_introspect(t){return this.request("POST",`/api/v1/auth/introspect/mcp/${t.serverIdentifier}/${t.version}`,{body:t.body,signal:t?.signal})}async AuthorizationController_tokenExchange(t){return this.request("POST",`/api/v1/auth/token-exchange/mcp/${t.serverIdentifier}/${t.version}`,{body:t.body,signal:t?.signal})}async AuthorizationController_callback(t){return this.request("GET","/api/v1/auth/callback",{params:{code:t.code,state:t.state,error:t.error,scope:t.scope,error_description:t.error_description},responseType:"void",signal:t?.signal})}async AuthorizationController_getScopes(t){return this.request("GET","/api/v1/auth/scopes",{signal:t?.signal})}}class m0 extends ht{constructor(t){super(t)}async WebAuthController_login(t){return this.request("POST","/api/v1/auth/login",{body:t.body,signal:t?.signal})}async WebAuthController_listUsers(t){return this.request("GET","/api/v1/auth/users",{signal:t?.signal})}async WebAuthController_createUser(t){return this.request("POST","/api/v1/auth/users",{body:t.body,signal:t?.signal})}async WebAuthController_resetUserPassword(t){return this.request("POST",`/api/v1/auth/users/${t.userId}/reset-password`,{signal:t?.signal})}async WebAuthController_deleteUser(t){return this.request("DELETE",`/api/v1/auth/users/${t.userId}`,{signal:t?.signal})}async WebAuthController_getAccountSetupStatus(t){return this.request("POST","/api/v1/auth/account-setup-status",{body:t.body,signal:t?.signal})}async WebAuthController_setupAccount(t){return this.request("POST","/api/v1/auth/setup-account",{body:t.body,signal:t?.signal})}async WebAuthController_refresh(t){return this.request("POST","/api/v1/auth/refresh",{signal:t?.signal})}async WebAuthController_logout(t){return this.request("POST","/api/v1/auth/logout",{signal:t?.signal})}async WebAuthController_me(t){return this.request("GET","/api/v1/auth/me",{signal:t?.signal})}async WebAuthController_changePassword(t){return this.request("POST","/api/v1/auth/change-password",{body:t.body,signal:t?.signal})}async WebAuthController_getOnboardingStatus(t){return this.request("GET","/api/v1/auth/onboarding-status",{signal:t?.signal})}async WebAuthController_onboard(t){return this.request("POST","/api/v1/auth/onboard",{body:t.body,signal:t?.signal})}async WebAuthController_markWalkthroughSeen(t){return this.request("POST","/api/v1/auth/mark-walkthrough-seen",{signal:t?.signal})}}class y0 extends ht{constructor(t){super(t)}async AuthJourneysController_getAuthJourneys(t){return this.request("GET",`/api/v1/auth-journeys/servers/${t.serverId}`,{signal:t?.signal})}}class x0 extends ht{constructor(t){super(t)}async McpRegistryController_createServer(t){return this.request("POST","/api/v1/mcp/servers",{body:t.body,signal:t?.signal})}async McpRegistryController_listServers(t){return this.request("GET","/api/v1/mcp/servers",{params:{page:t?.page,limit:t?.limit},signal:t?.signal})}async McpRegistryController_getServer(t){return this.request("GET",`/api/v1/mcp/servers/${t.serverId}`,{signal:t?.signal})}async McpRegistryController_updateServer(t){return this.request("PATCH",`/api/v1/mcp/servers/${t.serverId}`,{body:t.body,signal:t?.signal})}async McpRegistryController_deleteServer(t){return this.request("DELETE",`/api/v1/mcp/servers/${t.serverId}`,{signal:t?.signal})}async McpRegistryController_createScopes(t){return this.request("POST",`/api/v1/mcp/servers/${t.serverId}/scopes`,{body:t.body,signal:t?.signal})}async McpRegistryController_listScopes(t){return this.request("GET",`/api/v1/mcp/servers/${t.serverId}/scopes`,{signal:t?.signal})}async McpRegistryController_getScope(t){return this.request("GET",`/api/v1/mcp/servers/${t.serverId}/scopes/${t.scopeId}`,{signal:t?.signal})}async McpRegistryController_deleteScope(t){return this.request("DELETE",`/api/v1/mcp/servers/${t.serverId}/scopes/${t.scopeId}`,{signal:t?.signal})}async McpRegistryController_createConnection(t){return this.request("POST",`/api/v1/mcp/servers/${t.serverId}/connections`,{body:t.body,signal:t?.signal})}async McpRegistryController_listConnections(t){return this.request("GET",`/api/v1/mcp/servers/${t.serverId}/connections`,{signal:t?.signal})}async McpRegistryController_getConnection(t){return this.request("GET",`/api/v1/mcp/connections/${t.connectionId}`,{signal:t?.signal})}async McpRegistryController_updateConnection(t){return this.request("PATCH",`/api/v1/mcp/connections/${t.connectionId}`,{body:t.body,signal:t?.signal})}async McpRegistryController_deleteConnection(t){return this.request("DELETE",`/api/v1/mcp/connections/${t.connectionId}`,{signal:t?.signal})}async McpRegistryController_createMapping(t){return this.request("POST",`/api/v1/mcp/servers/${t.serverId}/mappings`,{body:t.body,signal:t?.signal})}async McpRegistryController_listMappings(t){return this.request("GET",`/api/v1/mcp/servers/${t.serverId}/scopes/${t.scopeId}/mappings`,{signal:t?.signal})}async McpRegistryController_deleteMapping(t){return this.request("DELETE",`/api/v1/mcp/mappings/${t.mappingId}`,{signal:t?.signal})}}class v0 extends ht{constructor(t){super(t)}async JwksController_getJwks(t){return this.request("GET","/.well-known/jwks.json",{signal:t?.signal})}}class b0 extends ht{constructor(t){super(t)}async ActorController_listActors(t){return this.request("GET","/api/v1/actors",{signal:t?.signal})}async ActorController_searchActors(t){return this.request("GET","/api/v1/actors/search",{params:{query:t.query,limit:t.limit,threshold:t.threshold},signal:t?.signal})}}class _0 extends ht{constructor(t){super(t)}async TasksController_createTask(t){return this.request("POST","/api/v1/tasks/tasks",{body:t.body,signal:t?.signal})}async TasksController_listTasks(t){return this.request("GET","/api/v1/tasks/tasks",{params:{assignee:t?.assignee,sessionId:t?.sessionId,tag:t?.tag,page:t?.page,limit:t?.limit},signal:t?.signal})}async TasksController_updateTask(t){return this.request("PATCH",`/api/v1/tasks/tasks/${t.id}`,{body:t.body,signal:t?.signal})}async TasksController_deleteTask(t){return this.request("DELETE",`/api/v1/tasks/tasks/${t.id}`,{responseType:"void",signal:t?.signal})}async TasksController_getTask(t){return this.request("GET",`/api/v1/tasks/tasks/${t.id}`,{signal:t?.signal})}async TasksController_assignTask(t){return this.request("PATCH",`/api/v1/tasks/tasks/${t.id}/assign`,{body:t.body,signal:t?.signal})}async TasksController_assignTaskToMe(t){return this.request("PATCH",`/api/v1/tasks/tasks/${t.id}/assign-to-me`,{signal:t?.signal})}async TasksController_searchTasks(t){return this.request("GET","/api/v1/tasks/tasks/search/query",{params:{query:t.query,limit:t.limit,threshold:t.threshold},signal:t?.signal})}async TasksController_addComment(t){return this.request("POST",`/api/v1/tasks/tasks/${t.id}/comments`,{body:t.body,signal:t?.signal})}async TasksController_addArtefact(t){return this.request("POST",`/api/v1/tasks/tasks/${t.id}/artefacts`,{body:t.body,signal:t?.signal})}async TasksController_changeStatus(t){return this.request("PATCH",`/api/v1/tasks/tasks/${t.id}/status`,{body:t.body,signal:t?.signal})}async TasksController_addTagToTask(t){return this.request("POST",`/api/v1/tasks/tasks/${t.id}/tags`,{body:t.body,signal:t?.signal})}async TasksController_removeTagFromTask(t){return this.request("DELETE",`/api/v1/tasks/tasks/${t.id}/tags/${t.tagId}`,{signal:t?.signal})}async TasksController_createInputRequest(t){return this.request("POST",`/api/v1/tasks/tasks/${t.id}/input-requests`,{body:t.body,signal:t?.signal})}async TasksController_answerInputRequest(t){return this.request("POST",`/api/v1/tasks/tasks/${t.id}/input-requests/${t.inputRequestId}/answer`,{body:t.body,signal:t?.signal})}async TasksController_handleMcp_get(t){return this.request("GET","/api/v1/tasks/tasks/mcp",{responseType:"void",signal:t?.signal})}async TasksController_handleMcp_post(t){return this.request("POST","/api/v1/tasks/tasks/mcp",{responseType:"void",signal:t?.signal})}async TasksController_handleMcp_put(t){return this.request("PUT","/api/v1/tasks/tasks/mcp",{responseType:"void",signal:t?.signal})}async TasksController_handleMcp_delete(t){return this.request("DELETE","/api/v1/tasks/tasks/mcp",{responseType:"void",signal:t?.signal})}async TasksController_handleMcp_patch(t){return this.request("PATCH","/api/v1/tasks/tasks/mcp",{responseType:"void",signal:t?.signal})}async TasksController_handleMcp_options(t){return this.request("OPTIONS","/api/v1/tasks/tasks/mcp",{responseType:"void",signal:t?.signal})}async TasksController_handleMcp_head(t){return this.request("HEAD","/api/v1/tasks/tasks/mcp",{responseType:"void",signal:t?.signal})}}class S0 extends ht{constructor(t){super(t)}async AgentRunsController_createAgentRun(t){return this.request("POST","/api/v1/agent-runs",{body:t.body,signal:t?.signal})}async AgentRunsController_listAgentRuns(t){return this.request("GET","/api/v1/agent-runs",{params:{actorId:t?.actorId,parentTaskId:t?.parentTaskId,page:t?.page,limit:t?.limit},signal:t?.signal})}async AgentRunsController_getAgentRunById(t){return this.request("GET",`/api/v1/agent-runs/${t.runId}`,{signal:t?.signal})}async AgentRunsController_updateAgentRun(t){return this.request("PATCH",`/api/v1/agent-runs/${t.runId}`,{body:t.body,signal:t?.signal})}}class j0 extends ht{constructor(t){super(t)}async ThreadsController_createThread(t){return this.request("POST","/api/v1/threads",{body:t.body,signal:t?.signal})}async ThreadsController_listThreads(t){return this.request("GET","/api/v1/threads",{params:{page:t?.page,limit:t?.limit},signal:t?.signal})}async ThreadsController_updateThread(t){return this.request("PATCH",`/api/v1/threads/${t.id}`,{body:t.body,signal:t?.signal})}async ThreadsController_getThread(t){return this.request("GET",`/api/v1/threads/${t.id}`,{signal:t?.signal})}async ThreadsController_deleteThread(t){return this.request("DELETE",`/api/v1/threads/${t.id}`,{responseType:"void",signal:t?.signal})}async ThreadsController_getThreadByTaskId(t){return this.request("GET",`/api/v1/threads/by-task/${t.taskId}`,{signal:t?.signal})}async ThreadsController_getThreadsByStateBlockId(t){return this.request("GET",`/api/v1/threads/by-state-block/${t.stateBlockId}`,{signal:t?.signal})}async ThreadsController_attachTask(t){return this.request("POST",`/api/v1/threads/${t.id}/tasks`,{body:t.body,signal:t?.signal})}async ThreadsController_referenceContextBlock(t){return this.request("POST",`/api/v1/threads/${t.id}/context-blocks`,{body:t.body,signal:t?.signal})}async ThreadsController_addTagToThread(t){return this.request("POST",`/api/v1/threads/${t.id}/tags`,{body:t.body,signal:t?.signal})}async ThreadsController_removeTagFromThread(t){return this.request("DELETE",`/api/v1/threads/${t.id}/tags/${t.tagId}`,{signal:t?.signal})}async ThreadsController_addParticipant(t){return this.request("POST",`/api/v1/threads/${t.id}/participants`,{body:t.body,signal:t?.signal})}async ThreadsController_getThreadState(t){return this.request("GET",`/api/v1/threads/${t.id}/state`,{signal:t?.signal})}async ThreadsController_updateThreadState(t){return this.request("PATCH",`/api/v1/threads/${t.id}/state`,{body:t.body,signal:t?.signal})}async ThreadsController_appendThreadState(t){return this.request("POST",`/api/v1/threads/${t.id}/state/append`,{body:t.body,signal:t?.signal})}async ThreadsController_createMessage(t){return this.request("POST",`/api/v1/threads/${t.id}/messages`,{body:t.body,signal:t?.signal})}async ThreadsController_listMessages(t){return this.request("GET",`/api/v1/threads/${t.id}/messages`,{params:{page:t.page,limit:t.limit},signal:t?.signal})}}class k0 extends ht{constructor(t){super(t)}async AgentsController_createAgent(t){return this.request("POST","/api/v1/agents",{body:t.body,signal:t?.signal})}async AgentsController_listAgents(t){return this.request("GET","/api/v1/agents",{params:{isActive:t?.isActive,page:t?.page,limit:t?.limit},signal:t?.signal})}async AgentsController_listAgentTemplates(t){return this.request("GET","/api/v1/agents/templates",{signal:t?.signal})}async AgentsController_getAgentBySlug(t){return this.request("GET",`/api/v1/agents/${t.slug}`,{signal:t?.signal})}async AgentsController_patchAgent(t){return this.request("PATCH",`/api/v1/agents/${t.actorId}`,{body:t.body,signal:t?.signal})}async AgentsController_deleteAgent(t){return this.request("DELETE",`/api/v1/agents/${t.actorId}`,{responseType:"void",signal:t?.signal})}async AgentToolPermissionsController_listAgentToolPermissions(t){return this.request("GET",`/api/v1/agents/${t.actorId}/tool-permissions`,{signal:t?.signal})}async AgentToolPermissionsController_upsertAgentToolPermission(t){return this.request("PUT",`/api/v1/agents/${t.actorId}/tool-permissions/${t.serverId}`,{body:t.body,signal:t?.signal})}async AgentToolPermissionsController_deleteAgentToolPermission(t){return this.request("DELETE",`/api/v1/agents/${t.actorId}/tool-permissions/${t.serverId}`,{responseType:"void",signal:t?.signal})}}class T0 extends ht{constructor(t){super(t)}async AgentTokensController_issueToken(t){return this.request("POST",`/api/v1/agents/${t.slug}/tokens`,{body:t.body,signal:t?.signal})}async AgentTokensController_listTokens(t){return this.request("GET",`/api/v1/agents/${t.slug}/tokens`,{signal:t?.signal})}async AgentTokensController_revokeToken(t){return this.request("DELETE",`/api/v1/agents/${t.slug}/tokens/${t.tokenId}`,{signal:t?.signal})}}class w0 extends ht{constructor(t){super(t)}async AgentExecutionTokensController_requestExecutionToken(t){return this.request("POST",`/api/v1/agents/${t.slug}/execution-token`,{body:t.body,signal:t?.signal})}}class E0 extends ht{constructor(t){super(t)}async ContextController_createBlock(t){return this.request("POST","/api/v1/context/blocks",{body:t.body,signal:t?.signal})}async ContextController_listBlocks(t){return this.request("GET","/api/v1/context/blocks",{params:{tag:t?.tag},signal:t?.signal})}async ContextController_searchBlocks(t){return this.request("GET","/api/v1/context/blocks/search/query",{params:{query:t.query,limit:t.limit,threshold:t.threshold},signal:t?.signal})}async ContextController_getBlockTree(t){return this.request("GET","/api/v1/context/blocks/tree",{signal:t?.signal})}async ContextController_exportBlocks(t){return this.request("GET","/api/v1/context/blocks/export",{responseType:"arrayBuffer",signal:t?.signal})}async ContextController_importBlocks(t){return this.request("POST","/api/v1/context/blocks/import",{body:t.body,bodyType:"form-data",signal:t?.signal})}async ContextController_getBlock(t){return this.request("GET",`/api/v1/context/blocks/${t.id}`,{signal:t?.signal})}async ContextController_updateBlock(t){return this.request("PATCH",`/api/v1/context/blocks/${t.id}`,{body:t.body,signal:t?.signal})}async ContextController_deleteBlock(t){return this.request("DELETE",`/api/v1/context/blocks/${t.id}`,{responseType:"void",signal:t?.signal})}async ContextController_appendToBlock(t){return this.request("POST",`/api/v1/context/blocks/${t.id}/append`,{body:t.body,signal:t?.signal})}async ContextController_reorderBlock(t){return this.request("PATCH",`/api/v1/context/blocks/${t.id}/reorder`,{body:t.body,signal:t?.signal})}async ContextController_moveBlock(t){return this.request("PATCH",`/api/v1/context/blocks/${t.id}/move`,{body:t.body,signal:t?.signal})}async ContextController_addTagToBlock(t){return this.request("POST",`/api/v1/context/blocks/${t.id}/tags`,{body:t.body,signal:t?.signal})}async ContextController_removeTagFromBlock(t){return this.request("DELETE",`/api/v1/context/blocks/${t.id}/tags/${t.tagId}`,{signal:t?.signal})}async ContextController_handleMcp_get(t){return this.request("GET","/api/v1/context/blocks/mcp",{responseType:"void",signal:t?.signal})}async ContextController_handleMcp_post(t){return this.request("POST","/api/v1/context/blocks/mcp",{responseType:"void",signal:t?.signal})}async ContextController_handleMcp_put(t){return this.request("PUT","/api/v1/context/blocks/mcp",{responseType:"void",signal:t?.signal})}async ContextController_handleMcp_delete(t){return this.request("DELETE","/api/v1/context/blocks/mcp",{responseType:"void",signal:t?.signal})}async ContextController_handleMcp_patch(t){return this.request("PATCH","/api/v1/context/blocks/mcp",{responseType:"void",signal:t?.signal})}async ContextController_handleMcp_options(t){return this.request("OPTIONS","/api/v1/context/blocks/mcp",{responseType:"void",signal:t?.signal})}async ContextController_handleMcp_head(t){return this.request("HEAD","/api/v1/context/blocks/mcp",{responseType:"void",signal:t?.signal})}}class C0 extends ht{constructor(t){super(t)}async ChatProvidersController_createChatProvider(t){return this.request("POST","/api/v1/chat-providers",{body:t.body,signal:t?.signal})}async ChatProvidersController_listChatProviders(t){return this.request("GET","/api/v1/chat-providers",{signal:t?.signal})}async ChatProvidersController_getChatProvider(t){return this.request("GET",`/api/v1/chat-providers/${t.id}`,{signal:t?.signal})}async ChatProvidersController_updateChatProvider(t){return this.request("PATCH",`/api/v1/chat-providers/${t.id}`,{body:t.body,signal:t?.signal})}async ChatProvidersController_deleteChatProvider(t){return this.request("DELETE",`/api/v1/chat-providers/${t.id}`,{responseType:"void",signal:t?.signal})}async ChatProvidersController_setActiveChatProvider(t){return this.request("POST","/api/v1/chat-providers/set-active",{body:t.body,signal:t?.signal})}async ChatProvidersController_deactivateActiveChatProvider(t){return this.request("POST","/api/v1/chat-providers/deactivate",{responseType:"void",signal:t?.signal})}}class N0 extends ht{constructor(t){super(t)}async SecretsController_createSecret(t){return this.request("POST","/api/v1/secrets",{body:t.body,signal:t?.signal})}async SecretsController_listSecrets(t){return this.request("GET","/api/v1/secrets",{signal:t?.signal})}async SecretsController_getSecret(t){return this.request("GET",`/api/v1/secrets/${t.id}`,{signal:t?.signal})}async SecretsController_updateSecret(t){return this.request("PATCH",`/api/v1/secrets/${t.id}`,{body:t.body,signal:t?.signal})}async SecretsController_deleteSecret(t){return this.request("DELETE",`/api/v1/secrets/${t.id}`,{responseType:"void",signal:t?.signal})}async SecretsController_getSecretValue(t){return this.request("GET",`/api/v1/secrets/${t.id}/value`,{signal:t?.signal})}}class A0 extends ht{constructor(t){super(t)}async TaskExecutionQueueController_listQueue(t){return this.request("GET","/api/v1/executions/queue",{params:{page:t?.page,limit:t?.limit},signal:t?.signal})}async TaskExecutionQueueController_claimTask(t){return this.request("POST",`/api/v1/executions/queue/${t.taskId}/claim`,{signal:t?.signal})}async ActiveTaskExecutionController_listActiveExecutions(t){return this.request("GET","/api/v1/executions/active",{params:{page:t?.page,limit:t?.limit,taskId:t?.taskId},signal:t?.signal})}async ActiveTaskExecutionController_stopTaskExecution(t){return this.request("POST",`/api/v1/executions/active/${t.executionId}/stop`,{body:t.body,signal:t?.signal})}async ActiveTaskExecutionController_unclaimTaskExecution(t){return this.request("POST",`/api/v1/executions/active/${t.executionId}/unclaim`,{responseType:"void",signal:t?.signal})}async ActiveTaskExecutionController_updateRunnerSessionId(t){return this.request("PATCH",`/api/v1/executions/active/${t.executionId}/session`,{body:t.body,responseType:"void",signal:t?.signal})}async ActiveTaskExecutionController_incrementToolCallCount(t){return this.request("PATCH",`/api/v1/executions/active/${t.executionId}/tool-calls/increment`,{responseType:"void",signal:t?.signal})}async ActiveTaskExecutionController_updateExecutionStats(t){return this.request("PATCH",`/api/v1/executions/active/${t.executionId}/stats`,{body:t.body,responseType:"void",signal:t?.signal})}async ActiveTaskExecutionController_interruptExecution(t){return this.request("POST",`/api/v1/executions/active/${t.executionId}/interrupt`,{responseType:"void",signal:t?.signal})}async TaskExecutionHistoryController_listHistory(t){return this.request("GET","/api/v1/executions/history",{params:{page:t?.page,limit:t?.limit,taskId:t?.taskId},signal:t?.signal})}}class R0 extends ht{constructor(t){super(t)}async WorkersController_listWorkers(t){return this.request("GET","/api/v1/workers",{signal:t?.signal})}}class z0 extends ht{constructor(t){super(t)}async TaskBlueprintsController_createTaskBlueprint(t){return this.request("POST","/api/v1/task-blueprints",{body:t.body,signal:t?.signal})}async TaskBlueprintsController_listTaskBlueprints(t){return this.request("GET","/api/v1/task-blueprints",{params:{page:t?.page,limit:t?.limit},signal:t?.signal})}async TaskBlueprintsController_getTaskBlueprint(t){return this.request("GET",`/api/v1/task-blueprints/${t.id}`,{signal:t?.signal})}async TaskBlueprintsController_updateTaskBlueprint(t){return this.request("PATCH",`/api/v1/task-blueprints/${t.id}`,{body:t.body,signal:t?.signal})}async TaskBlueprintsController_deleteTaskBlueprint(t){return this.request("DELETE",`/api/v1/task-blueprints/${t.id}`,{responseType:"void",signal:t?.signal})}async TaskBlueprintsController_createTaskFromBlueprint(t){return this.request("POST",`/api/v1/task-blueprints/${t.id}/create-task`,{signal:t?.signal})}}class D0 extends ht{constructor(t){super(t)}async ScheduledTasksController_createScheduledTask(t){return this.request("POST","/api/v1/scheduled-tasks",{body:t.body,signal:t?.signal})}async ScheduledTasksController_listScheduledTasks(t){return this.request("GET","/api/v1/scheduled-tasks",{params:{page:t?.page,limit:t?.limit,enabled:t?.enabled},signal:t?.signal})}async ScheduledTasksController_getScheduledTask(t){return this.request("GET",`/api/v1/scheduled-tasks/${t.id}`,{signal:t?.signal})}async ScheduledTasksController_updateScheduledTask(t){return this.request("PATCH",`/api/v1/scheduled-tasks/${t.id}`,{body:t.body,signal:t?.signal})}async ScheduledTasksController_deleteScheduledTask(t){return this.request("DELETE",`/api/v1/scheduled-tasks/${t.id}`,{responseType:"void",signal:t?.signal})}}class O0 extends ht{constructor(t){super(t)}async DiscoveryController_getIssuer(t){return this.request("GET","/.well-known/oauth-authorization-server/mcp/issuer",{signal:t?.signal})}async DiscoveryController_getAuthorizationServerMetadata(t){return this.request("GET",`/.well-known/oauth-authorization-server/mcp/${t.mcpServerId}/${t.version}`,{signal:t?.signal})}async DiscoveryController_all(t){return this.request("GET",`/.well-known/oauth-protected-resource/${t.path}`,{signal:t?.signal})}}class L0 extends ht{constructor(t){super(t)}async GlobalSearchController_search(t){return this.request("GET","/api/v1/search/query",{params:{query:t.query,limit:t.limit,threshold:t.threshold},signal:t?.signal})}}class M0 extends ht{constructor(t){super(t)}async WalkthroughController_acknowledge(t){return this.request("POST","/api/v1/walkthrough/acknowledge",{responseType:"void",signal:t?.signal})}async WalkthroughController_getStatus(t){return this.request("GET","/api/v1/walkthrough/status",{signal:t?.signal})}}class Ws{app;meta;metaProjects;authorizationServer;webAuthentication;authorizationJourneys;tools;jwks;actors;task;agentrun;threads;agent;agentTokens;agentExecutionTokens;context;chatProviders;secrets;executions;workers;taskBlueprints;scheduledTasks;discovery;search;walkthrough;constructor(t){this.app=new h0(t),this.meta=new f0(t),this.metaProjects=new p0(t),this.authorizationServer=new g0(t),this.webAuthentication=new m0(t),this.authorizationJourneys=new y0(t),this.tools=new x0(t),this.jwks=new v0(t),this.actors=new b0(t),this.task=new _0(t),this.agentrun=new S0(t),this.threads=new j0(t),this.agent=new k0(t),this.agentTokens=new T0(t),this.agentExecutionTokens=new w0(t),this.context=new E0(t),this.chatProviders=new C0(t),this.secrets=new N0(t),this.executions=new A0(t),this.workers=new R0(t),this.taskBlueprints=new z0(t),this.scheduledTasks=new D0(t),this.discovery=new O0(t),this.search=new L0(t),this.walkthrough=new M0(t)}}const q0=window.location.origin,I0=new Ws({baseUrl:q0,credentials:"include"}),_h=I0.walkthrough,B0=()=>{console.log("useHome mounting");const[n,t]=h.useState(null);return h.useEffect(()=>{console.log("useHome setting message"),t("Message coming from useHome")},[]),{message:n,setMessage:t}},Jx=h.createContext(null);function U0({children:n}){const{message:t}=B0(),[i,l]=h.useState(""),c=h.useMemo(()=>({message:t,sectionTitle:i,setSectionTitle:l}),[t,i,l]);return a.jsx(Jx.Provider,{value:c,children:n})}function js(){const n=h.useContext(Jx);if(!n)throw new Error("useHomeCtx must be used within <HomeProvider>");return n}const $0=window.location.origin,ev=new Ws({baseUrl:$0,credentials:"include"}),H0=ev.search;ev.search;function tv(){const[n,t]=h.useState(null),[i,l]=h.useState(!0),[c,u]=h.useState(null);return h.useEffect(()=>{_h.WalkthroughController_getStatus().then(f=>{const x=[{id:"worker",label:"Configure a worker",description:"A worker is a process that runs on your machine and executes agent tasks. Launch the Taico worker binary, then authenticate it with your account — it will appear here once connected.",href:"/settings/workers",completed:f.workerConfigured},{id:"agent",label:"Create an agent",description:"Agents are AI assistants that work on tasks. Create one by picking a runner (e.g. Claude Code, OpenCode), choosing a template, and selecting which tools it can use.",href:"/agents",completed:f.agentCreated},{id:"task",label:"Create a task",description:"Tasks are the core unit of work in Taico. Create your first task, write a clear description, and assign it to an agent to get it working.",href:"/tasks",completed:f.taskCreated},{id:"project-create",label:"Create a project",description:"Projects are created automatically when you add a tag in the format project:<name> to any task. Go to Tasks, open or create a task, and add a tag like project:my-app. Taico will create the project entry for you.",href:"/tasks",completed:f.projectCreated},{id:"project-configure",label:"Configure a project",description:"Link your project to a code repository. Go to Settings → Projects, find your project, and add a repository URL. Taico will automatically clone that repo for any task tagged with this project — no need to specify it per-task.",href:"/settings/projects",completed:f.projectConfigured},{id:"task-with-project",label:"Assign a task to an agent with a project",description:"Tag a task with a project tag and assign it to an agent. Taico will clone the linked repository and make it available in the agent's working directory automatically.",href:"/tasks",completed:f.taskWithProjectCreated},{id:"context",label:"Create a context block",description:"Context blocks are reusable pieces of text — instructions, reference docs, coding standards — that you can attach to tasks and threads. Agents will read them as part of their prompt.",href:"/context",completed:f.contextBlockCreated},{id:"thread",label:"Configure threads",description:"Threads coordinate parallel work when a task branches into sub-tasks. They are created automatically when a task spawns children. Explore the Threads section to see how work is organized.",href:"/settings/chat",completed:f.threadConfigured}],g=x.filter(m=>m.completed).length;t({steps:x,completedCount:g,totalCount:x.length,displayMode:f.onboardingDisplayMode})}).catch(f=>{console.error("Failed to fetch walkthrough status:",f),u(f instanceof Error?f.message:"Failed to load walkthrough")}).finally(()=>{l(!1)})},[]),{status:n,isLoading:i,error:c}}function P0(){const{user:n,refreshAuth:t}=us(),{status:i}=tv(),l=ze(),[c,u]=h.useState(!1),[f,x]=h.useState(!1);if(n?.onboardingDisplayMode!=="BANNER"||c)return null;const g=i?.completedCount??0,m=i?.totalCount??7,y=m-g,_=()=>l("/walkthrough"),v=k=>{k.stopPropagation(),u(!0)},j=async k=>{k.stopPropagation();try{x(!0),await es.webAuthControllerMarkWalkthroughSeen(),await t()}catch(E){console.error("Failed to hide walkthrough:",E),x(!1)}};return a.jsx("div",{className:"home-walkthrough-wrap",children:a.jsxs("div",{className:"home-walkthrough-card",onClick:_,role:"button",tabIndex:0,onKeyDown:k=>k.key==="Enter"&&_(),children:[a.jsx("div",{className:"home-walkthrough-dots","aria-hidden":"true",children:Array.from({length:m}).map((k,E)=>a.jsx("span",{className:`home-walkthrough-dot${E<g?" home-walkthrough-dot--done":""}`},E))}),a.jsxs("div",{className:"home-walkthrough-body",children:[a.jsx(b,{size:"2",weight:"semibold",children:y===0?"Setup complete!":`${y} step${y===1?"":"s"} to go`}),a.jsxs(b,{size:"1",tone:"muted",children:[g," of ",m," setup steps completed · Click to continue"]})]}),a.jsxs("div",{className:"home-walkthrough-actions",children:[a.jsx("button",{className:"home-walkthrough-not-now",onClick:v,children:"Not now"}),a.jsx("button",{className:"home-walkthrough-all-set",onClick:j,disabled:f,children:f?"…":"I'm all set"})]})]})})}function G0(){const n=ze(),{setSectionTitle:t}=js(),[i,l]=h.useState(""),[c,u]=h.useState([]),[f,x]=h.useState(!1),[g,m]=h.useState(-1),y=h.useRef(null),_=h.useRef([]);jt(),h.useEffect(()=>{t(""),y.current?.focus()},[t]);const v=h.useCallback(async T=>{if(!T.trim()){u([]),m(-1);return}x(!0);try{const R=await H0.GlobalSearchController_search({query:T,limit:20});u(R),m(-1),_.current=[]}catch(R){console.error("Search failed:",R),u([])}finally{x(!1)}},[]);h.useEffect(()=>{const T=setTimeout(()=>{v(i)},300);return()=>clearTimeout(T)},[i,v]);const j=T=>{T.key==="ArrowDown"?(T.preventDefault(),m(R=>{const z=R<c.length-1?R+1:R;return setTimeout(()=>{_.current[z]?.scrollIntoView({behavior:"smooth",block:"nearest"})},0),z})):T.key==="ArrowUp"?(T.preventDefault(),m(R=>{const z=R>0?R-1:0;return setTimeout(()=>{_.current[z]?.scrollIntoView({behavior:"smooth",block:"nearest"})},0),z})):T.key==="Enter"&&g>=0&&c[g]&&(T.preventDefault(),n(c[g].url))},k=T=>{n(T)},E=T=>{switch(T){case"task":return"blue";case"context_block":return"purple";case"agent":return"green";case"project":return"orange";case"tag":return"yellow";case"tool":return"red";default:return"gray"}},w=T=>{switch(T){case"task":return"Task";case"context_block":return"Context";case"agent":return"Agent";case"project":return"Project";case"tag":return"Tag";case"tool":return"Tool";default:return T}};return a.jsxs("div",{className:"home-page",children:[a.jsx(P0,{}),a.jsx("div",{className:"home-page-search",children:a.jsx("div",{className:"home-search-container",children:a.jsxs(te,{spacing:"6",align:"center",children:[a.jsxs(te,{spacing:"3",align:"center",children:[a.jsx(b,{size:"6",weight:"bold",className:"home-search-title",children:"Find anything"}),a.jsx(b,{size:"3",tone:"muted",className:"home-search-subtitle",children:"Search across tasks, context, agents, tools, and more"})]}),a.jsx("div",{className:"home-search-box",children:a.jsx("input",{ref:y,type:"text",className:"home-search-input",placeholder:"Search...",value:i,onChange:T=>l(T.target.value),onKeyDown:j,autoFocus:!0})}),i&&a.jsx(Fe,{className:"home-search-results",children:a.jsxs(te,{spacing:"2",children:[f&&a.jsx(b,{tone:"muted",size:"2",children:"Searching..."}),!f&&c.length===0&&a.jsx(b,{tone:"muted",size:"2",children:"No results found"}),!f&&c.length>0&&a.jsxs(a.Fragment,{children:[a.jsxs(b,{size:"1",tone:"muted",children:[c.length," ",c.length===1?"result":"results"]}),a.jsx("div",{className:"home-search-results-list",children:c.map((T,R)=>a.jsx("div",{ref:z=>{_.current[R]=z},children:a.jsxs(Lk,{interactive:!0,onClick:()=>k(T.url),className:`home-search-result-row ${R===g?"home-search-result-row--selected":""}`,children:[a.jsx("div",{className:"home-search-result-main",children:a.jsx(b,{weight:"medium",size:"3",children:T.title})}),a.jsxs("div",{className:"home-search-result-meta",children:[a.jsx(_s,{color:E(T.type),children:w(T.type)}),a.jsxs(b,{size:"1",tone:"muted",children:[Math.round(T.score*100),"% match"]})]})]})},T.id))})]})]})}),a.jsxs(Mt,{spacing:"2",className:"home-quick-links",children:[a.jsx(ue,{variant:"ghost",size:"sm",onClick:()=>n("/tasks"),children:"Tasks"}),a.jsx(ue,{variant:"ghost",size:"sm",onClick:()=>n("/threads"),children:"Threads"}),a.jsx(ue,{variant:"ghost",size:"sm",onClick:()=>n("/agents"),children:"Agents"}),a.jsx(ue,{variant:"ghost",size:"sm",onClick:()=>n("/context"),children:"Context"})]})]})})})]})}function Br({sectionTitle:n,titleAccessory:t,headerActions:i,children:l}){return a.jsxs("div",{className:"desktop-shell",children:[n&&a.jsxs("div",{className:"desktop-shell__header",children:[a.jsxs("div",{className:"desktop-shell__title-row",children:[a.jsx("h1",{className:"desktop-shell__title",children:n}),t?a.jsx("div",{className:"desktop-shell__title-accessory",children:t}):null]}),i?a.jsx("div",{className:"desktop-shell__actions",children:i}):null]}),a.jsx("div",{className:"desktop-shell__content",children:l})]})}function V0({navItems:n,activePath:t,onActiveItemClick:i}){return console.log("Rendering BottomNavContent with navItems:",n),n.length===0?a.jsx(a.Fragment,{}):a.jsx(Mt,{spacing:"1",justify:"space-between",children:n.map(l=>{const c=t===l.path;return a.jsxs(Mn,{to:l.path,className:`ios-shell__bottom-nav__item ${c?"ios-shell__bottom-nav__item--active":""}`,onClick:()=>{c&&i()},children:[a.jsx(al,{icon:l.icon,className:"ios-shell__bottom-nav__icon"}),a.jsx(b,{size:"1",className:"ios-shell__bottom-nav-label",children:l.label})]},l.label)})})}function $a(n){const t=qt();console.log("Mounting iOS shell");const[i,l]=h.useState(!1),c=()=>{l(!1)},[u,f]=h.useState(!0),[x,g]=h.useState(!0),[m,y]=h.useState(!0),_=h.useRef(null),v=U=>{_.current=U,I(),A(),Q()},j=h.useRef(null),k=U=>{j.current=U,I()},E=h.useRef(null),w=h.useRef(null),T=U=>{w.current=U,A()},R=h.useRef(null),z=h.useRef(null),L=U=>{z.current=U,Q()},M=h.useRef(null),N=(U,le,W)=>{const oe=le.current,me=_.current;!oe||!me||(U.current?.disconnect(),U.current=new IntersectionObserver(([B])=>{W(B.isIntersecting)},{root:me,threshold:[0,1]}),U.current.observe(oe))},A=()=>{N(R,w,U=>{console.log(`title visibility detector: ${U}`),f(U)})},I=()=>{N(E,j,U=>{console.log(`content behind header detector: ${U}`),g(!U)})},Q=()=>{N(M,z,U=>{console.log(`bottom detector: ${U}`),y(!U)})},Z=()=>{_.current?.scrollTo({top:0,behavior:"smooth"})};return h.useEffect(()=>()=>{R.current?.disconnect(),E.current?.disconnect(),M.current?.disconnect()},[]),a.jsxs("div",{className:"ios-shell",children:[a.jsxs("aside",{className:`ios-shell__drawer ${i?"ios-shell__drawer--open":""}`,children:[a.jsxs("div",{className:"ios-shell__drawer-header",children:[a.jsx(b,{size:"4",weight:"bold",children:"taico"}),a.jsx("button",{className:"ios-shell__drawer-close",onClick:c,"aria-label":"Close menu",children:"✕"})]}),a.jsx("nav",{className:"ios-shell__drawer-nav",children:zr.map(U=>{const le=t.pathname===U.path||t.pathname.startsWith(U.path+"/");return a.jsxs(Mn,{to:U.path,className:`ios-shell__drawer-item ${le?"ios-shell__drawer-item--active":""}`,onClick:c,children:[a.jsx(al,{icon:U.icon,className:"ios-shell__drawer-icon"}),a.jsx("span",{className:"ios-shell__drawer-label",children:U.label})]},U.path)})})]}),a.jsx("header",{className:`ios-shell__header ${x?"elevated":""}`,children:a.jsxs(Mt,{spacing:"5",align:"center",children:[a.jsx("button",{className:"ios-shell__hamburger",onClick:()=>l(!0),"aria-label":"Open menu",children:"☰"}),a.jsx(b,{size:"3",weight:"normal",as:"div",children:n.appTitle}),a.jsx("div",{className:`ios-shell__header__section-title ${u?"is-hidden":"is-visible"}`,children:n.sectionTitle})]})}),a.jsxs("main",{ref:v,className:"ios-shell__main",children:[a.jsx("div",{className:"ios-shell__main__top-padding"}),a.jsx("div",{ref:k,className:"ios-shell__main__section-title-top-sentinel"}),a.jsx("div",{className:`ios-shell__main__section-title ${u?"is-visible":"is-hidden"}`,children:n.sectionTitle}),n.topActions?a.jsx("div",{className:"ios-shell__main__top-actions",children:n.topActions}):null,a.jsx("div",{ref:T,className:"ios-shell__main__section-title-bottom-sentinel"}),a.jsx("div",{className:"ios-shell__main__top-sentinel"}),n.children,a.jsx("div",{ref:L,className:"ios-shell__main__bottom-sentinel"}),a.jsx("div",{className:"ios-shell__main__bottom-padding"})]}),a.jsx("nav",{className:`ios-shell__bottom-nav ${m?"elevated":""}`,children:a.jsx(V0,{navItems:n.navItems,activePath:t.pathname,onActiveItemClick:Z})})]})}const F0=[{path:"/home",label:"Home",icon:vh},{path:"/tasks",label:"Tasks",icon:Qx},{path:"/context",label:"Context",icon:bh},{path:"/agents",label:"Agents",icon:Wx},{path:"/settings",label:"Settings",icon:Zx}];function Y0(){const n=Rt(),{sectionTitle:t}=js();return a.jsx(a.Fragment,{children:n?a.jsx(Br,{sectionTitle:t,children:a.jsx(Kt,{})}):a.jsx($a,{appTitle:"Home",sectionTitle:t,navItems:F0,children:a.jsx(Kt,{})})})}const sv=h.createContext(null);function rl(){const n=h.useContext(sv);if(!n)throw new Error("useCommandPalette must be used within a CommandPaletteProvider");return n}function Q0({children:n}){const t=ze(),[i,l]=h.useState(new Map),[c,u]=h.useState(new Map),f=h.useRef(0),x=h.useMemo(()=>[{id:"nav-home",label:"Home",description:"Go to homepage",aliases:["home","search"],onSelect:()=>t("/home")},{id:"nav-tasks",label:"Tasks",description:"Go to tasks",aliases:["task"],onSelect:()=>t("/tasks")},{id:"nav-context",label:"Context",description:"Go to context blocks",aliases:["blocks","block"],onSelect:()=>t("/context")},{id:"nav-agents",label:"Agents",description:"Go to agents",aliases:["agent"],onSelect:()=>t("/agents")},{id:"nav-threads",label:"Threads",description:"Go to threads",aliases:["thread"],onSelect:()=>t("/threads")},{id:"nav-tools",label:"Tools",description:"Go to tools",aliases:["mcp","tool"],onSelect:()=>t("/tools")},{id:"nav-runs",label:"Runs",description:"Go to runs",aliases:["executions","execution","work queue"],onSelect:()=>t("/runs")},{id:"nav-schedule",label:"Schedule",description:"Go to schedule",aliases:["cron","schedules"],onSelect:()=>t("/tasks/schedule")},{id:"nav-settings",label:"Settings",description:"Go to settings",aliases:["setting","config"],onSelect:()=>t("/settings")}],[t]),g=h.useCallback(j=>{const k=String(++f.current);return l(E=>{const w=new Map(E);return w.set(k,j),w}),()=>{l(E=>{const w=new Map(E);return w.delete(k),w})}},[]),m=h.useCallback(j=>{const k=String(++f.current);return u(E=>{const w=new Map(E);return w.set(k,j),w}),()=>{u(E=>{const w=new Map(E);return w.delete(k),w})}},[]),y=h.useMemo(()=>[...Array.from(i.values()).flat(),...x],[x,i]),_=h.useMemo(()=>{const j=Array.from(c.values());return j[j.length-1]},[c]),v=h.useMemo(()=>({commands:y,registerCommands:g,searchTasks:_,registerTaskSearch:m}),[y,g,_,m]);return a.jsxs(sv.Provider,{value:v,children:[n,a.jsx(K0,{})]})}function K0(){const{commands:n,searchTasks:t}=rl(),i=ze(),[l,c]=h.useState(!1),[u,f]=h.useState(""),[x,g]=h.useState(0),[m,y]=h.useState(!1),[_,v]=h.useState([]),[j,k]=h.useState(!1),E=h.useRef(null),w=h.useRef(null),T=h.useRef(null),R=h.useRef(0);function z(U,le){const W=U.label.toLowerCase(),oe=U.description?.toLowerCase()||"",me=W.indexOf(le);if(me!==-1)return W===le?1e3:me===0?500:300;if(U.aliases)for(const B of U.aliases){const se=B.toLowerCase(),ge=se.indexOf(le);if(ge!==-1)return se===le?800:ge===0?400:200}return oe.includes(le)?100:0}const L=u.toLowerCase().trim(),N=[...n.map(U=>({command:U,score:L?z(U,L):0})).filter(U=>U.score>0).sort((U,le)=>le.score!==U.score?le.score-U.score:0).map(U=>U.command).map(U=>({type:"command",command:U})),..._.map(U=>({type:"task",task:U}))];function A(U){if(!L)return U;const le=U.toLowerCase().indexOf(L);return le===-1?U:a.jsxs(a.Fragment,{children:[U.slice(0,le),a.jsx("mark",{children:U.slice(le,le+L.length)}),U.slice(le+L.length)]})}h.useEffect(()=>{if(T.current&&clearTimeout(T.current),!t){R.current+=1,v([]),k(!1);return}if(!L){R.current+=1,v([]),k(!1);return}R.current+=1;const U=R.current;return T.current=window.setTimeout(async()=>{k(!0);try{const le=await t(L);R.current===U&&v(le)}catch(le){console.error("Failed to search tasks:",le),R.current===U&&v([])}finally{R.current===U&&k(!1)}},200),()=>{T.current&&clearTimeout(T.current)}},[L,t]),h.useEffect(()=>{g(0)},[u]),h.useEffect(()=>{const U=le=>{(le.metaKey||le.ctrlKey)&&le.key==="/"&&(le.preventDefault(),c(!0))};return document.addEventListener("keydown",U),()=>document.removeEventListener("keydown",U)},[]),h.useEffect(()=>{l&&E.current&&E.current.focus()},[l]),h.useEffect(()=>{const U=le=>{w.current&&!w.current.contains(le.target)&&l&&I()};if(l)return document.addEventListener("mousedown",U),()=>document.removeEventListener("mousedown",U)},[l]);function I(){c(!1),f(""),g(0),v([]),k(!1),T.current&&clearTimeout(T.current),R.current+=1}function Q(U){U.type==="command"?U.command.onSelect():i(`/tasks/task/${U.task.id}`),I()}function Z(U){if(U.key==="Escape"){U.preventDefault(),I();return}if(U.key==="ArrowDown"){U.preventDefault(),g(le=>le<N.length-1?le+1:le);return}if(U.key==="ArrowUp"){U.preventDefault(),g(le=>le>0?le-1:0);return}if(U.key==="Enter"){if(U.preventDefault(),N.length===0){y(!0),setTimeout(()=>y(!1),500);return}const le=N[x];le&&Q(le);return}}return l?a.jsx("div",{className:"command-palette-backdrop",children:a.jsxs("div",{className:`command-palette-container ${m?"command-palette-container--shake":""}`,ref:w,children:[a.jsx("input",{ref:E,type:"text",className:"command-palette-input",placeholder:"Type a command...",value:u,onChange:U=>f(U.target.value),onKeyDown:Z,autoComplete:"off",spellCheck:!1}),N.length>0&&a.jsx("div",{className:"command-palette-results",children:N.map((U,le)=>{if(U.type==="command"){const W=U.command;return a.jsxs("div",{className:`command-palette-item ${le===x?"command-palette-item--selected":""}`,onClick:()=>Q(U),onMouseEnter:()=>g(le),children:[a.jsx("span",{className:"command-palette-item-label",children:A(W.label)}),W.description&&a.jsx("span",{className:"command-palette-item-description",children:W.description})]},`cmd-${W.id}`)}else{const W=U.task;return a.jsxs("div",{className:`command-palette-item command-palette-item--task ${le===x?"command-palette-item--selected":""}`,onClick:()=>Q(U),onMouseEnter:()=>g(le),children:[a.jsx("span",{className:"command-palette-item-label",children:A(W.name)}),a.jsx("span",{className:"command-palette-item-description",children:"Task"})]},`task-${W.id}`)}})}),u&&N.length===0&&!j&&a.jsx("div",{className:"command-palette-no-results",children:"No results found"}),j&&a.jsx("div",{className:"command-palette-searching",children:"Searching tasks..."})]})}):null}function Ur({onDelete:n,deleteLabel:t="Delete",confirmLabel:i="Confirm Delete",cancelLabel:l="Cancel",className:c,size:u="lg"}){const[f,x]=h.useState(!1),g=async()=>{await n(),x(!1)};return a.jsx(ye,{className:c,children:f?a.jsxs(a.Fragment,{children:[a.jsx(ue,{size:u,variant:"secondary",onClick:()=>x(!1),children:l}),a.jsx(ue,{size:u,variant:"danger",onClick:g,children:i})]}):a.jsx(ue,{size:u,variant:"danger",onClick:()=>x(!0),children:t})})}const nv=h.createContext(void 0);function ds(){const n=h.useContext(nv);if(!n)throw new Error("useToast must be used within ToastProvider");return n}function X0(n){if(n&&typeof n=="object"){const t=n;if(t.body?.detail)return t.body.detail;if(t.detail)return t.detail;if(t.message)return t.message}return typeof n=="string"?n:"An unexpected error occurred"}function Z0({children:n}){const[t,i]=h.useState([]),l=h.useCallback((f,x="info",g=5e3)=>{const m=crypto.randomUUID(),y={id:m,message:f,type:x,duration:g};i(_=>[..._,y]),g>0&&setTimeout(()=>{u(m)},g)},[]),c=h.useCallback(f=>{const x=X0(f);l(x,"error",6e3)},[l]),u=h.useCallback(f=>{i(x=>x.filter(g=>g.id!==f))},[]);return a.jsx(nv.Provider,{value:{toasts:t,showToast:l,showError:c,dismissToast:u},children:n})}function W0(){const{toasts:n,dismissToast:t}=ds();return n.length===0?null:a.jsx("div",{className:"toast-container",children:n.map(i=>a.jsxs("div",{className:`toast toast--${i.type}`,role:"alert","aria-live":"assertive",children:[a.jsx("div",{className:"toast__content",children:a.jsx(b,{size:"2",className:"toast__message",children:i.message})}),a.jsx("button",{className:"toast__close",onClick:()=>t(i.id),"aria-label":"Dismiss notification",children:"×"})]},i.id))})}Me.BASE=Ba;const un=Object.create(null);un.open="0";un.close="1";un.ping="2";un.pong="3";un.message="4";un.upgrade="5";un.noop="6";const Bo=Object.create(null);Object.keys(un).forEach(n=>{Bo[un[n]]=n});const Qd={type:"error",data:"parser error"},av=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",rv=typeof ArrayBuffer=="function",iv=n=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(n):n&&n.buffer instanceof ArrayBuffer,Sh=({type:n,data:t},i,l)=>av&&t instanceof Blob?i?l(t):Oy(t,l):rv&&(t instanceof ArrayBuffer||iv(t))?i?l(t):Oy(new Blob([t]),l):l(un[n]+(t||"")),Oy=(n,t)=>{const i=new FileReader;return i.onload=function(){const l=i.result.split(",")[1];t("b"+(l||""))},i.readAsDataURL(n)};function Ly(n){return n instanceof Uint8Array?n:n instanceof ArrayBuffer?new Uint8Array(n):new Uint8Array(n.buffer,n.byteOffset,n.byteLength)}let Cd;function J0(n,t){if(av&&n.data instanceof Blob)return n.data.arrayBuffer().then(Ly).then(t);if(rv&&(n.data instanceof ArrayBuffer||iv(n.data)))return t(Ly(n.data));Sh(n,!1,i=>{Cd||(Cd=new TextEncoder),t(Cd.encode(i))})}const My="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Fi=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let n=0;n<My.length;n++)Fi[My.charCodeAt(n)]=n;const ew=n=>{let t=n.length*.75,i=n.length,l,c=0,u,f,x,g;n[n.length-1]==="="&&(t--,n[n.length-2]==="="&&t--);const m=new ArrayBuffer(t),y=new Uint8Array(m);for(l=0;l<i;l+=4)u=Fi[n.charCodeAt(l)],f=Fi[n.charCodeAt(l+1)],x=Fi[n.charCodeAt(l+2)],g=Fi[n.charCodeAt(l+3)],y[c++]=u<<2|f>>4,y[c++]=(f&15)<<4|x>>2,y[c++]=(x&3)<<6|g&63;return m},tw=typeof ArrayBuffer=="function",jh=(n,t)=>{if(typeof n!="string")return{type:"message",data:lv(n,t)};const i=n.charAt(0);return i==="b"?{type:"message",data:sw(n.substring(1),t)}:Bo[i]?n.length>1?{type:Bo[i],data:n.substring(1)}:{type:Bo[i]}:Qd},sw=(n,t)=>{if(tw){const i=ew(n);return lv(i,t)}else return{base64:!0,data:n}},lv=(n,t)=>{switch(t){case"blob":return n instanceof Blob?n:new Blob([n]);case"arraybuffer":default:return n instanceof ArrayBuffer?n:n.buffer}},ov="",nw=(n,t)=>{const i=n.length,l=new Array(i);let c=0;n.forEach((u,f)=>{Sh(u,!1,x=>{l[f]=x,++c===i&&t(l.join(ov))})})},aw=(n,t)=>{const i=n.split(ov),l=[];for(let c=0;c<i.length;c++){const u=jh(i[c],t);if(l.push(u),u.type==="error")break}return l};function rw(){return new TransformStream({transform(n,t){J0(n,i=>{const l=i.length;let c;if(l<126)c=new Uint8Array(1),new DataView(c.buffer).setUint8(0,l);else if(l<65536){c=new Uint8Array(3);const u=new DataView(c.buffer);u.setUint8(0,126),u.setUint16(1,l)}else{c=new Uint8Array(9);const u=new DataView(c.buffer);u.setUint8(0,127),u.setBigUint64(1,BigInt(l))}n.data&&typeof n.data!="string"&&(c[0]|=128),t.enqueue(c),t.enqueue(i)})}})}let Nd;function wo(n){return n.reduce((t,i)=>t+i.length,0)}function Eo(n,t){if(n[0].length===t)return n.shift();const i=new Uint8Array(t);let l=0;for(let c=0;c<t;c++)i[c]=n[0][l++],l===n[0].length&&(n.shift(),l=0);return n.length&&l<n[0].length&&(n[0]=n[0].slice(l)),i}function iw(n,t){Nd||(Nd=new TextDecoder);const i=[];let l=0,c=-1,u=!1;return new TransformStream({transform(f,x){for(i.push(f);;){if(l===0){if(wo(i)<1)break;const g=Eo(i,1);u=(g[0]&128)===128,c=g[0]&127,c<126?l=3:c===126?l=1:l=2}else if(l===1){if(wo(i)<2)break;const g=Eo(i,2);c=new DataView(g.buffer,g.byteOffset,g.length).getUint16(0),l=3}else if(l===2){if(wo(i)<8)break;const g=Eo(i,8),m=new DataView(g.buffer,g.byteOffset,g.length),y=m.getUint32(0);if(y>Math.pow(2,21)-1){x.enqueue(Qd);break}c=y*Math.pow(2,32)+m.getUint32(4),l=3}else{if(wo(i)<c)break;const g=Eo(i,c);x.enqueue(jh(u?g:Nd.decode(g),t)),l=0}if(c===0||c>n){x.enqueue(Qd);break}}}})}const cv=4;function At(n){if(n)return lw(n)}function lw(n){for(var t in At.prototype)n[t]=At.prototype[t];return n}At.prototype.on=At.prototype.addEventListener=function(n,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+n]=this._callbacks["$"+n]||[]).push(t),this};At.prototype.once=function(n,t){function i(){this.off(n,i),t.apply(this,arguments)}return i.fn=t,this.on(n,i),this};At.prototype.off=At.prototype.removeListener=At.prototype.removeAllListeners=At.prototype.removeEventListener=function(n,t){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var i=this._callbacks["$"+n];if(!i)return this;if(arguments.length==1)return delete this._callbacks["$"+n],this;for(var l,c=0;c<i.length;c++)if(l=i[c],l===t||l.fn===t){i.splice(c,1);break}return i.length===0&&delete this._callbacks["$"+n],this};At.prototype.emit=function(n){this._callbacks=this._callbacks||{};for(var t=new Array(arguments.length-1),i=this._callbacks["$"+n],l=1;l<arguments.length;l++)t[l-1]=arguments[l];if(i){i=i.slice(0);for(var l=0,c=i.length;l<c;++l)i[l].apply(this,t)}return this};At.prototype.emitReserved=At.prototype.emit;At.prototype.listeners=function(n){return this._callbacks=this._callbacks||{},this._callbacks["$"+n]||[]};At.prototype.hasListeners=function(n){return!!this.listeners(n).length};const ec=typeof Promise=="function"&&typeof Promise.resolve=="function"?t=>Promise.resolve().then(t):(t,i)=>i(t,0),Ms=typeof self<"u"?self:typeof window<"u"?window:Function("return this")(),ow="arraybuffer";function uv(n,...t){return t.reduce((i,l)=>(n.hasOwnProperty(l)&&(i[l]=n[l]),i),{})}const cw=Ms.setTimeout,uw=Ms.clearTimeout;function tc(n,t){t.useNativeTimers?(n.setTimeoutFn=cw.bind(Ms),n.clearTimeoutFn=uw.bind(Ms)):(n.setTimeoutFn=Ms.setTimeout.bind(Ms),n.clearTimeoutFn=Ms.clearTimeout.bind(Ms))}const dw=1.33;function hw(n){return typeof n=="string"?fw(n):Math.ceil((n.byteLength||n.size)*dw)}function fw(n){let t=0,i=0;for(let l=0,c=n.length;l<c;l++)t=n.charCodeAt(l),t<128?i+=1:t<2048?i+=2:t<55296||t>=57344?i+=3:(l++,i+=4);return i}function dv(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function pw(n){let t="";for(let i in n)n.hasOwnProperty(i)&&(t.length&&(t+="&"),t+=encodeURIComponent(i)+"="+encodeURIComponent(n[i]));return t}function gw(n){let t={},i=n.split("&");for(let l=0,c=i.length;l<c;l++){let u=i[l].split("=");t[decodeURIComponent(u[0])]=decodeURIComponent(u[1])}return t}class mw extends Error{constructor(t,i,l){super(t),this.description=i,this.context=l,this.type="TransportError"}}class kh extends At{constructor(t){super(),this.writable=!1,tc(this,t),this.opts=t,this.query=t.query,this.socket=t.socket,this.supportsBinary=!t.forceBase64}onError(t,i,l){return super.emitReserved("error",new mw(t,i,l)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return(this.readyState==="opening"||this.readyState==="open")&&(this.doClose(),this.onClose()),this}send(t){this.readyState==="open"&&this.write(t)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(t){const i=jh(t,this.socket.binaryType);this.onPacket(i)}onPacket(t){super.emitReserved("packet",t)}onClose(t){this.readyState="closed",super.emitReserved("close",t)}pause(t){}createUri(t,i={}){return t+"://"+this._hostname()+this._port()+this.opts.path+this._query(i)}_hostname(){const t=this.opts.hostname;return t.indexOf(":")===-1?t:"["+t+"]"}_port(){return this.opts.port&&(this.opts.secure&&Number(this.opts.port)!==443||!this.opts.secure&&Number(this.opts.port)!==80)?":"+this.opts.port:""}_query(t){const i=pw(t);return i.length?"?"+i:""}}class yw extends kh{constructor(){super(...arguments),this._polling=!1}get name(){return"polling"}doOpen(){this._poll()}pause(t){this.readyState="pausing";const i=()=>{this.readyState="paused",t()};if(this._polling||!this.writable){let l=0;this._polling&&(l++,this.once("pollComplete",function(){--l||i()})),this.writable||(l++,this.once("drain",function(){--l||i()}))}else i()}_poll(){this._polling=!0,this.doPoll(),this.emitReserved("poll")}onData(t){const i=l=>{if(this.readyState==="opening"&&l.type==="open"&&this.onOpen(),l.type==="close")return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(l)};aw(t,this.socket.binaryType).forEach(i),this.readyState!=="closed"&&(this._polling=!1,this.emitReserved("pollComplete"),this.readyState==="open"&&this._poll())}doClose(){const t=()=>{this.write([{type:"close"}])};this.readyState==="open"?t():this.once("open",t)}write(t){this.writable=!1,nw(t,i=>{this.doWrite(i,()=>{this.writable=!0,this.emitReserved("drain")})})}uri(){const t=this.opts.secure?"https":"http",i=this.query||{};return this.opts.timestampRequests!==!1&&(i[this.opts.timestampParam]=dv()),!this.supportsBinary&&!i.sid&&(i.b64=1),this.createUri(t,i)}}let hv=!1;try{hv=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}const xw=hv;function vw(){}class bw extends yw{constructor(t){if(super(t),typeof location<"u"){const i=location.protocol==="https:";let l=location.port;l||(l=i?"443":"80"),this.xd=typeof location<"u"&&t.hostname!==location.hostname||l!==t.port}}doWrite(t,i){const l=this.request({method:"POST",data:t});l.on("success",i),l.on("error",(c,u)=>{this.onError("xhr post error",c,u)})}doPoll(){const t=this.request();t.on("data",this.onData.bind(this)),t.on("error",(i,l)=>{this.onError("xhr poll error",i,l)}),this.pollXhr=t}}class cn extends At{constructor(t,i,l){super(),this.createRequest=t,tc(this,l),this._opts=l,this._method=l.method||"GET",this._uri=i,this._data=l.data!==void 0?l.data:null,this._create()}_create(){var t;const i=uv(this._opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");i.xdomain=!!this._opts.xd;const l=this._xhr=this.createRequest(i);try{l.open(this._method,this._uri,!0);try{if(this._opts.extraHeaders){l.setDisableHeaderCheck&&l.setDisableHeaderCheck(!0);for(let c in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(c)&&l.setRequestHeader(c,this._opts.extraHeaders[c])}}catch{}if(this._method==="POST")try{l.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch{}try{l.setRequestHeader("Accept","*/*")}catch{}(t=this._opts.cookieJar)===null||t===void 0||t.addCookies(l),"withCredentials"in l&&(l.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(l.timeout=this._opts.requestTimeout),l.onreadystatechange=()=>{var c;l.readyState===3&&((c=this._opts.cookieJar)===null||c===void 0||c.parseCookies(l.getResponseHeader("set-cookie"))),l.readyState===4&&(l.status===200||l.status===1223?this._onLoad():this.setTimeoutFn(()=>{this._onError(typeof l.status=="number"?l.status:0)},0))},l.send(this._data)}catch(c){this.setTimeoutFn(()=>{this._onError(c)},0);return}typeof document<"u"&&(this._index=cn.requestsCount++,cn.requests[this._index]=this)}_onError(t){this.emitReserved("error",t,this._xhr),this._cleanup(!0)}_cleanup(t){if(!(typeof this._xhr>"u"||this._xhr===null)){if(this._xhr.onreadystatechange=vw,t)try{this._xhr.abort()}catch{}typeof document<"u"&&delete cn.requests[this._index],this._xhr=null}}_onLoad(){const t=this._xhr.responseText;t!==null&&(this.emitReserved("data",t),this.emitReserved("success"),this._cleanup())}abort(){this._cleanup()}}cn.requestsCount=0;cn.requests={};if(typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",qy);else if(typeof addEventListener=="function"){const n="onpagehide"in Ms?"pagehide":"unload";addEventListener(n,qy,!1)}}function qy(){for(let n in cn.requests)cn.requests.hasOwnProperty(n)&&cn.requests[n].abort()}const _w=(function(){const n=fv({xdomain:!1});return n&&n.responseType!==null})();class Sw extends bw{constructor(t){super(t);const i=t&&t.forceBase64;this.supportsBinary=_w&&!i}request(t={}){return Object.assign(t,{xd:this.xd},this.opts),new cn(fv,this.uri(),t)}}function fv(n){const t=n.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!t||xw))return new XMLHttpRequest}catch{}if(!t)try{return new Ms[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}const pv=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative";class jw extends kh{get name(){return"websocket"}doOpen(){const t=this.uri(),i=this.opts.protocols,l=pv?{}:uv(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(l.headers=this.opts.extraHeaders);try{this.ws=this.createSocket(t,i,l)}catch(c){return this.emitReserved("error",c)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=t=>this.onClose({description:"websocket connection closed",context:t}),this.ws.onmessage=t=>this.onData(t.data),this.ws.onerror=t=>this.onError("websocket error",t)}write(t){this.writable=!1;for(let i=0;i<t.length;i++){const l=t[i],c=i===t.length-1;Sh(l,this.supportsBinary,u=>{try{this.doWrite(l,u)}catch{}c&&ec(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){typeof this.ws<"u"&&(this.ws.onerror=()=>{},this.ws.close(),this.ws=null)}uri(){const t=this.opts.secure?"wss":"ws",i=this.query||{};return this.opts.timestampRequests&&(i[this.opts.timestampParam]=dv()),this.supportsBinary||(i.b64=1),this.createUri(t,i)}}const Ad=Ms.WebSocket||Ms.MozWebSocket;class kw extends jw{createSocket(t,i,l){return pv?new Ad(t,i,l):i?new Ad(t,i):new Ad(t)}doWrite(t,i){this.ws.send(i)}}class Tw extends kh{get name(){return"webtransport"}doOpen(){try{this._transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name])}catch(t){return this.emitReserved("error",t)}this._transport.closed.then(()=>{this.onClose()}).catch(t=>{this.onError("webtransport error",t)}),this._transport.ready.then(()=>{this._transport.createBidirectionalStream().then(t=>{const i=iw(Number.MAX_SAFE_INTEGER,this.socket.binaryType),l=t.readable.pipeThrough(i).getReader(),c=rw();c.readable.pipeTo(t.writable),this._writer=c.writable.getWriter();const u=()=>{l.read().then(({done:x,value:g})=>{x||(this.onPacket(g),u())}).catch(x=>{})};u();const f={type:"open"};this.query.sid&&(f.data=`{"sid":"${this.query.sid}"}`),this._writer.write(f).then(()=>this.onOpen())})})}write(t){this.writable=!1;for(let i=0;i<t.length;i++){const l=t[i],c=i===t.length-1;this._writer.write(l).then(()=>{c&&ec(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var t;(t=this._transport)===null||t===void 0||t.close()}}const ww={websocket:kw,webtransport:Tw,polling:Sw},Ew=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,Cw=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function Kd(n){if(n.length>8e3)throw"URI too long";const t=n,i=n.indexOf("["),l=n.indexOf("]");i!=-1&&l!=-1&&(n=n.substring(0,i)+n.substring(i,l).replace(/:/g,";")+n.substring(l,n.length));let c=Ew.exec(n||""),u={},f=14;for(;f--;)u[Cw[f]]=c[f]||"";return i!=-1&&l!=-1&&(u.source=t,u.host=u.host.substring(1,u.host.length-1).replace(/;/g,":"),u.authority=u.authority.replace("[","").replace("]","").replace(/;/g,":"),u.ipv6uri=!0),u.pathNames=Nw(u,u.path),u.queryKey=Aw(u,u.query),u}function Nw(n,t){const i=/\/{2,9}/g,l=t.replace(i,"/").split("/");return(t.slice(0,1)=="/"||t.length===0)&&l.splice(0,1),t.slice(-1)=="/"&&l.splice(l.length-1,1),l}function Aw(n,t){const i={};return t.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(l,c,u){c&&(i[c]=u)}),i}const Xd=typeof addEventListener=="function"&&typeof removeEventListener=="function",Uo=[];Xd&&addEventListener("offline",()=>{Uo.forEach(n=>n())},!1);class fa extends At{constructor(t,i){if(super(),this.binaryType=ow,this.writeBuffer=[],this._prevBufferLen=0,this._pingInterval=-1,this._pingTimeout=-1,this._maxPayload=-1,this._pingTimeoutTime=1/0,t&&typeof t=="object"&&(i=t,t=null),t){const l=Kd(t);i.hostname=l.host,i.secure=l.protocol==="https"||l.protocol==="wss",i.port=l.port,l.query&&(i.query=l.query)}else i.host&&(i.hostname=Kd(i.host).host);tc(this,i),this.secure=i.secure!=null?i.secure:typeof location<"u"&&location.protocol==="https:",i.hostname&&!i.port&&(i.port=this.secure?"443":"80"),this.hostname=i.hostname||(typeof location<"u"?location.hostname:"localhost"),this.port=i.port||(typeof location<"u"&&location.port?location.port:this.secure?"443":"80"),this.transports=[],this._transportsByName={},i.transports.forEach(l=>{const c=l.prototype.name;this.transports.push(c),this._transportsByName[c]=l}),this.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},i),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),typeof this.opts.query=="string"&&(this.opts.query=gw(this.opts.query)),Xd&&(this.opts.closeOnBeforeunload&&(this._beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener("beforeunload",this._beforeunloadEventListener,!1)),this.hostname!=="localhost"&&(this._offlineEventListener=()=>{this._onClose("transport close",{description:"network connection lost"})},Uo.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(t){const i=Object.assign({},this.opts.query);i.EIO=cv,i.transport=t,this.id&&(i.sid=this.id);const l=Object.assign({},this.opts,{query:i,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[t]);return new this._transportsByName[t](l)}_open(){if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);return}const t=this.opts.rememberUpgrade&&fa.priorWebsocketSuccess&&this.transports.indexOf("websocket")!==-1?"websocket":this.transports[0];this.readyState="opening";const i=this.createTransport(t);i.open(),this.setTransport(i)}setTransport(t){this.transport&&this.transport.removeAllListeners(),this.transport=t,t.on("drain",this._onDrain.bind(this)).on("packet",this._onPacket.bind(this)).on("error",this._onError.bind(this)).on("close",i=>this._onClose("transport close",i))}onOpen(){this.readyState="open",fa.priorWebsocketSuccess=this.transport.name==="websocket",this.emitReserved("open"),this.flush()}_onPacket(t){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")switch(this.emitReserved("packet",t),this.emitReserved("heartbeat"),t.type){case"open":this.onHandshake(JSON.parse(t.data));break;case"ping":this._sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong"),this._resetPingTimeout();break;case"error":const i=new Error("server error");i.code=t.data,this._onError(i);break;case"message":this.emitReserved("data",t.data),this.emitReserved("message",t.data);break}}onHandshake(t){this.emitReserved("handshake",t),this.id=t.sid,this.transport.query.sid=t.sid,this._pingInterval=t.pingInterval,this._pingTimeout=t.pingTimeout,this._maxPayload=t.maxPayload,this.onOpen(),this.readyState!=="closed"&&this._resetPingTimeout()}_resetPingTimeout(){this.clearTimeoutFn(this._pingTimeoutTimer);const t=this._pingInterval+this._pingTimeout;this._pingTimeoutTime=Date.now()+t,this._pingTimeoutTimer=this.setTimeoutFn(()=>{this._onClose("ping timeout")},t),this.opts.autoUnref&&this._pingTimeoutTimer.unref()}_onDrain(){this.writeBuffer.splice(0,this._prevBufferLen),this._prevBufferLen=0,this.writeBuffer.length===0?this.emitReserved("drain"):this.flush()}flush(){if(this.readyState!=="closed"&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){const t=this._getWritablePackets();this.transport.send(t),this._prevBufferLen=t.length,this.emitReserved("flush")}}_getWritablePackets(){if(!(this._maxPayload&&this.transport.name==="polling"&&this.writeBuffer.length>1))return this.writeBuffer;let i=1;for(let l=0;l<this.writeBuffer.length;l++){const c=this.writeBuffer[l].data;if(c&&(i+=hw(c)),l>0&&i>this._maxPayload)return this.writeBuffer.slice(0,l);i+=2}return this.writeBuffer}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;const t=Date.now()>this._pingTimeoutTime;return t&&(this._pingTimeoutTime=0,ec(()=>{this._onClose("ping timeout")},this.setTimeoutFn)),t}write(t,i,l){return this._sendPacket("message",t,i,l),this}send(t,i,l){return this._sendPacket("message",t,i,l),this}_sendPacket(t,i,l,c){if(typeof i=="function"&&(c=i,i=void 0),typeof l=="function"&&(c=l,l=null),this.readyState==="closing"||this.readyState==="closed")return;l=l||{},l.compress=l.compress!==!1;const u={type:t,data:i,options:l};this.emitReserved("packetCreate",u),this.writeBuffer.push(u),c&&this.once("flush",c),this.flush()}close(){const t=()=>{this._onClose("forced close"),this.transport.close()},i=()=>{this.off("upgrade",i),this.off("upgradeError",i),t()},l=()=>{this.once("upgrade",i),this.once("upgradeError",i)};return(this.readyState==="opening"||this.readyState==="open")&&(this.readyState="closing",this.writeBuffer.length?this.once("drain",()=>{this.upgrading?l():t()}):this.upgrading?l():t()),this}_onError(t){if(fa.priorWebsocketSuccess=!1,this.opts.tryAllTransports&&this.transports.length>1&&this.readyState==="opening")return this.transports.shift(),this._open();this.emitReserved("error",t),this._onClose("transport error",t)}_onClose(t,i){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing"){if(this.clearTimeoutFn(this._pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),Xd&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){const l=Uo.indexOf(this._offlineEventListener);l!==-1&&Uo.splice(l,1)}this.readyState="closed",this.id=null,this.emitReserved("close",t,i),this.writeBuffer=[],this._prevBufferLen=0}}}fa.protocol=cv;class Rw extends fa{constructor(){super(...arguments),this._upgrades=[]}onOpen(){if(super.onOpen(),this.readyState==="open"&&this.opts.upgrade)for(let t=0;t<this._upgrades.length;t++)this._probe(this._upgrades[t])}_probe(t){let i=this.createTransport(t),l=!1;fa.priorWebsocketSuccess=!1;const c=()=>{l||(i.send([{type:"ping",data:"probe"}]),i.once("packet",_=>{if(!l)if(_.type==="pong"&&_.data==="probe"){if(this.upgrading=!0,this.emitReserved("upgrading",i),!i)return;fa.priorWebsocketSuccess=i.name==="websocket",this.transport.pause(()=>{l||this.readyState!=="closed"&&(y(),this.setTransport(i),i.send([{type:"upgrade"}]),this.emitReserved("upgrade",i),i=null,this.upgrading=!1,this.flush())})}else{const v=new Error("probe error");v.transport=i.name,this.emitReserved("upgradeError",v)}}))};function u(){l||(l=!0,y(),i.close(),i=null)}const f=_=>{const v=new Error("probe error: "+_);v.transport=i.name,u(),this.emitReserved("upgradeError",v)};function x(){f("transport closed")}function g(){f("socket closed")}function m(_){i&&_.name!==i.name&&u()}const y=()=>{i.removeListener("open",c),i.removeListener("error",f),i.removeListener("close",x),this.off("close",g),this.off("upgrading",m)};i.once("open",c),i.once("error",f),i.once("close",x),this.once("close",g),this.once("upgrading",m),this._upgrades.indexOf("webtransport")!==-1&&t!=="webtransport"?this.setTimeoutFn(()=>{l||i.open()},200):i.open()}onHandshake(t){this._upgrades=this._filterUpgrades(t.upgrades),super.onHandshake(t)}_filterUpgrades(t){const i=[];for(let l=0;l<t.length;l++)~this.transports.indexOf(t[l])&&i.push(t[l]);return i}}let zw=class extends Rw{constructor(t,i={}){const l=typeof t=="object"?t:i;(!l.transports||l.transports&&typeof l.transports[0]=="string")&&(l.transports=(l.transports||["polling","websocket","webtransport"]).map(c=>ww[c]).filter(c=>!!c)),super(t,l)}};function Dw(n,t="",i){let l=n;i=i||typeof location<"u"&&location,n==null&&(n=i.protocol+"//"+i.host),typeof n=="string"&&(n.charAt(0)==="/"&&(n.charAt(1)==="/"?n=i.protocol+n:n=i.host+n),/^(https?|wss?):\/\//.test(n)||(typeof i<"u"?n=i.protocol+"//"+n:n="https://"+n),l=Kd(n)),l.port||(/^(http|ws)$/.test(l.protocol)?l.port="80":/^(http|ws)s$/.test(l.protocol)&&(l.port="443")),l.path=l.path||"/";const u=l.host.indexOf(":")!==-1?"["+l.host+"]":l.host;return l.id=l.protocol+"://"+u+":"+l.port+t,l.href=l.protocol+"://"+u+(i&&i.port===l.port?"":":"+l.port),l}const Ow=typeof ArrayBuffer=="function",Lw=n=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(n):n.buffer instanceof ArrayBuffer,gv=Object.prototype.toString,Mw=typeof Blob=="function"||typeof Blob<"u"&&gv.call(Blob)==="[object BlobConstructor]",qw=typeof File=="function"||typeof File<"u"&&gv.call(File)==="[object FileConstructor]";function Th(n){return Ow&&(n instanceof ArrayBuffer||Lw(n))||Mw&&n instanceof Blob||qw&&n instanceof File}function $o(n,t){if(!n||typeof n!="object")return!1;if(Array.isArray(n)){for(let i=0,l=n.length;i<l;i++)if($o(n[i]))return!0;return!1}if(Th(n))return!0;if(n.toJSON&&typeof n.toJSON=="function"&&arguments.length===1)return $o(n.toJSON(),!0);for(const i in n)if(Object.prototype.hasOwnProperty.call(n,i)&&$o(n[i]))return!0;return!1}function Iw(n){const t=[],i=n.data,l=n;return l.data=Zd(i,t),l.attachments=t.length,{packet:l,buffers:t}}function Zd(n,t){if(!n)return n;if(Th(n)){const i={_placeholder:!0,num:t.length};return t.push(n),i}else if(Array.isArray(n)){const i=new Array(n.length);for(let l=0;l<n.length;l++)i[l]=Zd(n[l],t);return i}else if(typeof n=="object"&&!(n instanceof Date)){const i={};for(const l in n)Object.prototype.hasOwnProperty.call(n,l)&&(i[l]=Zd(n[l],t));return i}return n}function Bw(n,t){return n.data=Wd(n.data,t),delete n.attachments,n}function Wd(n,t){if(!n)return n;if(n&&n._placeholder===!0){if(typeof n.num=="number"&&n.num>=0&&n.num<t.length)return t[n.num];throw new Error("illegal attachments")}else if(Array.isArray(n))for(let i=0;i<n.length;i++)n[i]=Wd(n[i],t);else if(typeof n=="object")for(const i in n)Object.prototype.hasOwnProperty.call(n,i)&&(n[i]=Wd(n[i],t));return n}const Uw=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"];var Ve;(function(n){n[n.CONNECT=0]="CONNECT",n[n.DISCONNECT=1]="DISCONNECT",n[n.EVENT=2]="EVENT",n[n.ACK=3]="ACK",n[n.CONNECT_ERROR=4]="CONNECT_ERROR",n[n.BINARY_EVENT=5]="BINARY_EVENT",n[n.BINARY_ACK=6]="BINARY_ACK"})(Ve||(Ve={}));class $w{constructor(t){this.replacer=t}encode(t){return(t.type===Ve.EVENT||t.type===Ve.ACK)&&$o(t)?this.encodeAsBinary({type:t.type===Ve.EVENT?Ve.BINARY_EVENT:Ve.BINARY_ACK,nsp:t.nsp,data:t.data,id:t.id}):[this.encodeAsString(t)]}encodeAsString(t){let i=""+t.type;return(t.type===Ve.BINARY_EVENT||t.type===Ve.BINARY_ACK)&&(i+=t.attachments+"-"),t.nsp&&t.nsp!=="/"&&(i+=t.nsp+","),t.id!=null&&(i+=t.id),t.data!=null&&(i+=JSON.stringify(t.data,this.replacer)),i}encodeAsBinary(t){const i=Iw(t),l=this.encodeAsString(i.packet),c=i.buffers;return c.unshift(l),c}}class wh extends At{constructor(t){super(),this.opts=Object.assign({reviver:void 0,maxAttachments:10},typeof t=="function"?{reviver:t}:t)}add(t){let i;if(typeof t=="string"){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");i=this.decodeString(t);const l=i.type===Ve.BINARY_EVENT;l||i.type===Ve.BINARY_ACK?(i.type=l?Ve.EVENT:Ve.ACK,this.reconstructor=new Hw(i),i.attachments===0&&super.emitReserved("decoded",i)):super.emitReserved("decoded",i)}else if(Th(t)||t.base64)if(this.reconstructor)i=this.reconstructor.takeBinaryData(t),i&&(this.reconstructor=null,super.emitReserved("decoded",i));else throw new Error("got binary data when not reconstructing a packet");else throw new Error("Unknown type: "+t)}decodeString(t){let i=0;const l={type:Number(t.charAt(0))};if(Ve[l.type]===void 0)throw new Error("unknown packet type "+l.type);if(l.type===Ve.BINARY_EVENT||l.type===Ve.BINARY_ACK){const u=i+1;for(;t.charAt(++i)!=="-"&&i!=t.length;);const f=t.substring(u,i);if(f!=Number(f)||t.charAt(i)!=="-")throw new Error("Illegal attachments");const x=Number(f);if(!Pw(x)||x<0)throw new Error("Illegal attachments");if(x>this.opts.maxAttachments)throw new Error("too many attachments");l.attachments=x}if(t.charAt(i+1)==="/"){const u=i+1;for(;++i&&!(t.charAt(i)===","||i===t.length););l.nsp=t.substring(u,i)}else l.nsp="/";const c=t.charAt(i+1);if(c!==""&&Number(c)==c){const u=i+1;for(;++i;){const f=t.charAt(i);if(f==null||Number(f)!=f){--i;break}if(i===t.length)break}l.id=Number(t.substring(u,i+1))}if(t.charAt(++i)){const u=this.tryParse(t.substr(i));if(wh.isPayloadValid(l.type,u))l.data=u;else throw new Error("invalid payload")}return l}tryParse(t){try{return JSON.parse(t,this.opts.reviver)}catch{return!1}}static isPayloadValid(t,i){switch(t){case Ve.CONNECT:return Iy(i);case Ve.DISCONNECT:return i===void 0;case Ve.CONNECT_ERROR:return typeof i=="string"||Iy(i);case Ve.EVENT:case Ve.BINARY_EVENT:return Array.isArray(i)&&(typeof i[0]=="number"||typeof i[0]=="string"&&Uw.indexOf(i[0])===-1);case Ve.ACK:case Ve.BINARY_ACK:return Array.isArray(i)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class Hw{constructor(t){this.packet=t,this.buffers=[],this.reconPack=t}takeBinaryData(t){if(this.buffers.push(t),this.buffers.length===this.reconPack.attachments){const i=Bw(this.reconPack,this.buffers);return this.finishedReconstruction(),i}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}const Pw=Number.isInteger||function(n){return typeof n=="number"&&isFinite(n)&&Math.floor(n)===n};function Iy(n){return Object.prototype.toString.call(n)==="[object Object]"}const Gw=Object.freeze(Object.defineProperty({__proto__:null,Decoder:wh,Encoder:$w,get PacketType(){return Ve}},Symbol.toStringTag,{value:"Module"}));function Qs(n,t,i){return n.on(t,i),function(){n.off(t,i)}}const Vw=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class mv extends At{constructor(t,i,l){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=t,this.nsp=i,l&&l.auth&&(this.auth=l.auth),this._opts=Object.assign({},l),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;const t=this.io;this.subs=[Qs(t,"open",this.onopen.bind(this)),Qs(t,"packet",this.onpacket.bind(this)),Qs(t,"error",this.onerror.bind(this)),Qs(t,"close",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected?this:(this.subEvents(),this.io._reconnecting||this.io.open(),this.io._readyState==="open"&&this.onopen(),this)}open(){return this.connect()}send(...t){return t.unshift("message"),this.emit.apply(this,t),this}emit(t,...i){var l,c,u;if(Vw.hasOwnProperty(t))throw new Error('"'+t.toString()+'" is a reserved event name');if(i.unshift(t),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(i),this;const f={type:Ve.EVENT,data:i};if(f.options={},f.options.compress=this.flags.compress!==!1,typeof i[i.length-1]=="function"){const y=this.ids++,_=i.pop();this._registerAckCallback(y,_),f.id=y}const x=(c=(l=this.io.engine)===null||l===void 0?void 0:l.transport)===null||c===void 0?void 0:c.writable,g=this.connected&&!(!((u=this.io.engine)===null||u===void 0)&&u._hasPingExpired());return this.flags.volatile&&!x||(g?(this.notifyOutgoingListeners(f),this.packet(f)):this.sendBuffer.push(f)),this.flags={},this}_registerAckCallback(t,i){var l;const c=(l=this.flags.timeout)!==null&&l!==void 0?l:this._opts.ackTimeout;if(c===void 0){this.acks[t]=i;return}const u=this.io.setTimeoutFn(()=>{delete this.acks[t];for(let x=0;x<this.sendBuffer.length;x++)this.sendBuffer[x].id===t&&this.sendBuffer.splice(x,1);i.call(this,new Error("operation has timed out"))},c),f=(...x)=>{this.io.clearTimeoutFn(u),i.apply(this,x)};f.withError=!0,this.acks[t]=f}emitWithAck(t,...i){return new Promise((l,c)=>{const u=(f,x)=>f?c(f):l(x);u.withError=!0,i.push(u),this.emit(t,...i)})}_addToQueue(t){let i;typeof t[t.length-1]=="function"&&(i=t.pop());const l={id:this._queueSeq++,tryCount:0,pending:!1,args:t,flags:Object.assign({fromQueue:!0},this.flags)};t.push((c,...u)=>(this._queue[0],c!==null?l.tryCount>this._opts.retries&&(this._queue.shift(),i&&i(c)):(this._queue.shift(),i&&i(null,...u)),l.pending=!1,this._drainQueue())),this._queue.push(l),this._drainQueue()}_drainQueue(t=!1){if(!this.connected||this._queue.length===0)return;const i=this._queue[0];i.pending&&!t||(i.pending=!0,i.tryCount++,this.flags=i.flags,this.emit.apply(this,i.args))}packet(t){t.nsp=this.nsp,this.io._packet(t)}onopen(){typeof this.auth=="function"?this.auth(t=>{this._sendConnectPacket(t)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(t){this.packet({type:Ve.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},t):t})}onerror(t){this.connected||this.emitReserved("connect_error",t)}onclose(t,i){this.connected=!1,delete this.id,this.emitReserved("disconnect",t,i),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach(t=>{if(!this.sendBuffer.some(l=>String(l.id)===t)){const l=this.acks[t];delete this.acks[t],l.withError&&l.call(this,new Error("socket has been disconnected"))}})}onpacket(t){if(t.nsp===this.nsp)switch(t.type){case Ve.CONNECT:t.data&&t.data.sid?this.onconnect(t.data.sid,t.data.pid):this.emitReserved("connect_error",new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case Ve.EVENT:case Ve.BINARY_EVENT:this.onevent(t);break;case Ve.ACK:case Ve.BINARY_ACK:this.onack(t);break;case Ve.DISCONNECT:this.ondisconnect();break;case Ve.CONNECT_ERROR:this.destroy();const l=new Error(t.data.message);l.data=t.data.data,this.emitReserved("connect_error",l);break}}onevent(t){const i=t.data||[];t.id!=null&&i.push(this.ack(t.id)),this.connected?this.emitEvent(i):this.receiveBuffer.push(Object.freeze(i))}emitEvent(t){if(this._anyListeners&&this._anyListeners.length){const i=this._anyListeners.slice();for(const l of i)l.apply(this,t)}super.emit.apply(this,t),this._pid&&t.length&&typeof t[t.length-1]=="string"&&(this._lastOffset=t[t.length-1])}ack(t){const i=this;let l=!1;return function(...c){l||(l=!0,i.packet({type:Ve.ACK,id:t,data:c}))}}onack(t){const i=this.acks[t.id];typeof i=="function"&&(delete this.acks[t.id],i.withError&&t.data.unshift(null),i.apply(this,t.data))}onconnect(t,i){this.id=t,this.recovered=i&&this._pid===i,this._pid=i,this.connected=!0,this.emitBuffered(),this._drainQueue(!0),this.emitReserved("connect")}emitBuffered(){this.receiveBuffer.forEach(t=>this.emitEvent(t)),this.receiveBuffer=[],this.sendBuffer.forEach(t=>{this.notifyOutgoingListeners(t),this.packet(t)}),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach(t=>t()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:Ve.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(t){return this.flags.compress=t,this}get volatile(){return this.flags.volatile=!0,this}timeout(t){return this.flags.timeout=t,this}onAny(t){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(t),this}prependAny(t){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(t),this}offAny(t){if(!this._anyListeners)return this;if(t){const i=this._anyListeners;for(let l=0;l<i.length;l++)if(t===i[l])return i.splice(l,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(t){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(t),this}prependAnyOutgoing(t){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(t),this}offAnyOutgoing(t){if(!this._anyOutgoingListeners)return this;if(t){const i=this._anyOutgoingListeners;for(let l=0;l<i.length;l++)if(t===i[l])return i.splice(l,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(t){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){const i=this._anyOutgoingListeners.slice();for(const l of i)l.apply(this,t.data)}}}function $r(n){n=n||{},this.ms=n.min||100,this.max=n.max||1e4,this.factor=n.factor||2,this.jitter=n.jitter>0&&n.jitter<=1?n.jitter:0,this.attempts=0}$r.prototype.duration=function(){var n=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var t=Math.random(),i=Math.floor(t*this.jitter*n);n=(Math.floor(t*10)&1)==0?n-i:n+i}return Math.min(n,this.max)|0};$r.prototype.reset=function(){this.attempts=0};$r.prototype.setMin=function(n){this.ms=n};$r.prototype.setMax=function(n){this.max=n};$r.prototype.setJitter=function(n){this.jitter=n};class Jd extends At{constructor(t,i){var l;super(),this.nsps={},this.subs=[],t&&typeof t=="object"&&(i=t,t=void 0),i=i||{},i.path=i.path||"/socket.io",this.opts=i,tc(this,i),this.reconnection(i.reconnection!==!1),this.reconnectionAttempts(i.reconnectionAttempts||1/0),this.reconnectionDelay(i.reconnectionDelay||1e3),this.reconnectionDelayMax(i.reconnectionDelayMax||5e3),this.randomizationFactor((l=i.randomizationFactor)!==null&&l!==void 0?l:.5),this.backoff=new $r({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(i.timeout==null?2e4:i.timeout),this._readyState="closed",this.uri=t;const c=i.parser||Gw;this.encoder=new c.Encoder,this.decoder=new c.Decoder,this._autoConnect=i.autoConnect!==!1,this._autoConnect&&this.open()}reconnection(t){return arguments.length?(this._reconnection=!!t,t||(this.skipReconnect=!0),this):this._reconnection}reconnectionAttempts(t){return t===void 0?this._reconnectionAttempts:(this._reconnectionAttempts=t,this)}reconnectionDelay(t){var i;return t===void 0?this._reconnectionDelay:(this._reconnectionDelay=t,(i=this.backoff)===null||i===void 0||i.setMin(t),this)}randomizationFactor(t){var i;return t===void 0?this._randomizationFactor:(this._randomizationFactor=t,(i=this.backoff)===null||i===void 0||i.setJitter(t),this)}reconnectionDelayMax(t){var i;return t===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=t,(i=this.backoff)===null||i===void 0||i.setMax(t),this)}timeout(t){return arguments.length?(this._timeout=t,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()}open(t){if(~this._readyState.indexOf("open"))return this;this.engine=new zw(this.uri,this.opts);const i=this.engine,l=this;this._readyState="opening",this.skipReconnect=!1;const c=Qs(i,"open",function(){l.onopen(),t&&t()}),u=x=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",x),t?t(x):this.maybeReconnectOnOpen()},f=Qs(i,"error",u);if(this._timeout!==!1){const x=this._timeout,g=this.setTimeoutFn(()=>{c(),u(new Error("timeout")),i.close()},x);this.opts.autoUnref&&g.unref(),this.subs.push(()=>{this.clearTimeoutFn(g)})}return this.subs.push(c),this.subs.push(f),this}connect(t){return this.open(t)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");const t=this.engine;this.subs.push(Qs(t,"ping",this.onping.bind(this)),Qs(t,"data",this.ondata.bind(this)),Qs(t,"error",this.onerror.bind(this)),Qs(t,"close",this.onclose.bind(this)),Qs(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(t){try{this.decoder.add(t)}catch(i){this.onclose("parse error",i)}}ondecoded(t){ec(()=>{this.emitReserved("packet",t)},this.setTimeoutFn)}onerror(t){this.emitReserved("error",t)}socket(t,i){let l=this.nsps[t];return l?this._autoConnect&&!l.active&&l.connect():(l=new mv(this,t,i),this.nsps[t]=l),l}_destroy(t){const i=Object.keys(this.nsps);for(const l of i)if(this.nsps[l].active)return;this._close()}_packet(t){const i=this.encoder.encode(t);for(let l=0;l<i.length;l++)this.engine.write(i[l],t.options)}cleanup(){this.subs.forEach(t=>t()),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close")}disconnect(){return this._close()}onclose(t,i){var l;this.cleanup(),(l=this.engine)===null||l===void 0||l.close(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",t,i),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const t=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{const i=this.backoff.duration();this._reconnecting=!0;const l=this.setTimeoutFn(()=>{t.skipReconnect||(this.emitReserved("reconnect_attempt",t.backoff.attempts),!t.skipReconnect&&t.open(c=>{c?(t._reconnecting=!1,t.reconnect(),this.emitReserved("reconnect_error",c)):t.onreconnect()}))},i);this.opts.autoUnref&&l.unref(),this.subs.push(()=>{this.clearTimeoutFn(l)})}}onreconnect(){const t=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",t)}}const Bi={};function Bs(n,t){typeof n=="object"&&(t=n,n=void 0),t=t||{};const i=Dw(n,t.path||"/socket.io"),l=i.source,c=i.id,u=i.path,f=Bi[c]&&u in Bi[c].nsps,x=t.forceNew||t["force new connection"]||t.multiplex===!1||f;let g;return x?g=new Jd(l,t):(Bi[c]||(Bi[c]=new Jd(l,t)),g=Bi[c]),i.query&&!t.query&&(t.query=i.queryKey),g.socket(i.path,t)}Object.assign(Bs,{Manager:Jd,Socket:mv,io:Bs,connect:Bs});const bs={TASK_CREATED:"task.created",TASK_UPDATED:"task.updated",TASK_DELETED:"task.deleted",TASK_ASSIGNED:"task.assigned",TASK_STATUS_CHANGED:"task.status_changed",TASK_COMMENTED:"task.commented",INPUT_REQUEST_ANSWERED:"input.request.answered",TASK_ACTIVITY:"task.activity"},Dr={THREAD_UPDATED:"thread.updated",THREAD_TITLE_UPDATED:"thread.title.updated",MESSAGE_CREATED:"thread.message.created",AGENT_ACTIVITY:"thread.agent.activity",AGENT_RESPONSE_DELTA:"thread.agent.response.delta"};var Fo;(function(n){n.HUMAN="human",n.AGENT="agent"})(Fo||(Fo={}));const Fw={WORKER_SEEN:"worker.seen"},Yw=window.location.origin,yv=new Ws({baseUrl:Yw,credentials:"include"}),Qw=yv.workers;yv.workers;const Kw=pa("/workers");function Eh(){const[n,t]=h.useState([]),[i,l]=h.useState(!0),[c,u]=h.useState(null),[f,x]=h.useState(!1),g=y=>[...y].sort((_,v)=>{const j=new Date(_.lastSeenAt).getTime();return new Date(v.lastSeenAt).getTime()-j}),m=async()=>{try{l(!0),u(null);const y=await Qw.WorkersController_listWorkers();t(g(y))}catch(y){console.error("Error fetching workers:",y),u(y instanceof Error?y.message:"Failed to load workers")}finally{l(!1)}};return h.useEffect(()=>{const y=Bs(Kw,{withCredentials:!0,transports:["websocket","polling"]});return m(),y.on("connect",()=>{y.emit("workers.subscribe",{},_=>{if(_.ok){x(!0);return}x(!1)}),m()}),y.on("disconnect",()=>{x(!1)}),y.on("connect_error",_=>{console.error("Workers WebSocket connection error:",_)}),y.on(Fw.WORKER_SEEN,_=>{t(v=>{const j=v.findIndex(k=>k.id===_.worker.id);if(j>=0){const k=[...v];return k[j]=_.worker,g(k)}return g([...v,_.worker])})}),()=>{y.emit("workers.unsubscribe",{}),y.disconnect()}},[]),{workers:n,isLoading:i,error:c,isConnected:f}}function xv({preview:n,size:t="compact"}){const i={"--theme-preview-bg":n.background,"--theme-preview-surface":n.surface,"--theme-preview-card":n.card,"--theme-preview-border":n.border,"--theme-preview-text":n.text,"--theme-preview-muted":n.muted,"--theme-preview-accent":n.accent,"--theme-preview-accent-soft":n.accentSoft};return a.jsx("span",{className:`settings-theme-visual settings-theme-visual--${t}`,style:i,"aria-hidden":"true",children:a.jsxs("span",{className:"settings-theme-visual__window",children:[a.jsxs("span",{className:"settings-theme-visual__rail",children:[a.jsx("span",{className:"settings-theme-visual__accent-dot"}),a.jsx("span",{className:"settings-theme-visual__rail-line"}),a.jsx("span",{className:"settings-theme-visual__rail-line settings-theme-visual__rail-line--short"})]}),a.jsxs("span",{className:"settings-theme-visual__canvas",children:[a.jsx("span",{className:"settings-theme-visual__font",children:n.font==="Mono"?"Aa":"Ag"}),a.jsx("span",{className:"settings-theme-visual__line settings-theme-visual__line--wide"}),a.jsxs("span",{className:"settings-theme-visual__panel",children:[a.jsx("span",{className:"settings-theme-visual__chip"}),a.jsx("span",{className:"settings-theme-visual__line"}),a.jsx("span",{className:"settings-theme-visual__line settings-theme-visual__line--short"})]}),a.jsx("span",{className:"settings-theme-visual__button"})]})]})})}const vv=[{value:"light",label:"Light",description:"Clean light theme with a crisp blue accent.",preview:{background:"#ffffff",surface:"#f6f8fa",card:"#ffffff",border:"#d1d9e0",text:"#1f2328",muted:"#59636e",accent:"#0969da",accentSoft:"#ddf4ff",font:"Inter"}},{value:"dark",label:"Dark",description:"Low-light surfaces with GitHub-style blue highlights.",preview:{background:"#0d1117",surface:"#161b22",card:"#0d1117",border:"#30363d",text:"#e6edf3",muted:"#8b949e",accent:"#2f81f7",accentSoft:"#1f6feb33",font:"Inter"}},{value:"clarity",label:"Clarity",description:"Soft neutral surfaces for focused daytime work.",preview:{background:"#f7f7f5",surface:"#f2f4f7",card:"#ffffff",border:"#d9dee5",text:"#1f2328",muted:"#66707a",accent:"#3971d9",accentSoft:"#e5efff",font:"Inter"}},{value:"github",label:"GitHub",description:"GitHub-inspired neutrals with a green action color.",preview:{background:"#ffffff",surface:"#f6f8fa",card:"#ffffff",border:"#d0d7de",text:"#24292f",muted:"#57606a",accent:"#1f883d",accentSoft:"#dafbe1",font:"Inter"}},{value:"forest",label:"Forest",description:"Dark green workspace with softer natural contrast.",preview:{background:"#0f1a0f",surface:"#152615",card:"#102010",border:"#2d4a2d",text:"#e8f5e8",muted:"#9bb89b",accent:"#52c952",accentSoft:"#1f4d2a",font:"Inter"}},{value:"terminal",label:"Terminal",description:"Classic terminal green on a black interface.",preview:{background:"#000000",surface:"#0a0a0a",card:"#050505",border:"#00aa00",text:"#00ff00",muted:"#00aa00",accent:"#00dd00",accentSoft:"#003b00",font:"Mono"}},{value:"ai-vibes",label:"AI Vibes",description:"Deep purples with neon-like accents.",preview:{background:"#0c0716",surface:"#1a102b",card:"#130b21",border:"#3b255f",text:"#f5efff",muted:"#c4b5db",accent:"#a855f7",accentSoft:"#3b1762",font:"Inter"}},{value:"halo",label:"Halo",description:"Light background with cooler layered surfaces.",preview:{background:"#f9f9fc",surface:"#eef1f9",card:"#ffffff",border:"#d8deef",text:"#1f2937",muted:"#667085",accent:"#3b5bcc",accentSoft:"#e6ebff",font:"Inter"}},{value:"mono",label:"Mono",description:"Black and white minimalism with restrained contrast.",preview:{background:"#ffffff",surface:"#f5f5f5",card:"#ffffff",border:"#d4d4d4",text:"#111111",muted:"#666666",accent:"#111111",accentSoft:"#eeeeee",font:"Inter"}},{value:"terminal-amber",label:"Terminal Amber",description:"Warm terminal tones with a calm blue accent.",preview:{background:"#0b0a09",surface:"#17130d",card:"#120f0b",border:"#3a2d16",text:"#f5d78e",muted:"#b9975b",accent:"#8ab4f8",accentSoft:"#1d2740",font:"Mono"}},{value:"oceanic",label:"Oceanic",description:"Cool blues and teals for a calmer dark theme.",preview:{background:"#0c1b2a",surface:"#102a3d",card:"#0f2233",border:"#1d4a5f",text:"#e6fffb",muted:"#9bd5d0",accent:"#4fd1c5",accentSoft:"#123c47",font:"Inter"}},{value:"party",label:"Party",description:"Playful warm palette with saturated highlights.",preview:{background:"#fff7f0",surface:"#fff0e0",card:"#ffffff",border:"#ffd4d4",text:"#2d1b1b",muted:"#7a5a5a",accent:"#ff6b6b",accentSoft:"#ffe3df",font:"Inter"}},{value:"tribute",label:"Tribute",description:"Dark sidebar energy inspired by the previous UI.",preview:{background:"#0b1220",surface:"#111827",card:"#0f172a",border:"#1e293b",text:"#e5e7eb",muted:"#94a3b8",accent:"#2563eb",accentSoft:"#172554",font:"Inter"}}];function Xw(){const{setSectionTitle:n}=js(),t=Rt(),i=ze(),{registerCommands:l}=rl(),{theme:c,setTheme:u}=Ix(),{workers:f,isLoading:x}=Eh(),[g,m]=h.useState(null),[y,_]=h.useState({projects:null,providers:null});jt(),h.useEffect(()=>{n("Settings"),v(),j()},[]);const v=async()=>{try{const w=await $x.metaControllerGetVersion();m(w)}catch(w){console.error("Failed to load version:",w)}},j=async()=>{const[w,T]=await Promise.allSettled([Vo.projectsControllerGetAllProjects(),Ar.chatProvidersControllerListChatProviders()]);_({projects:w.status==="fulfilled"?w.value.length:null,providers:T.status==="fulfilled"?{configured:T.value.filter(R=>R.isConfigured).length,total:T.value.length,activeName:T.value.find(R=>R.isActive)?.name??null}:null})};h.useEffect(()=>l([{id:"settings-account",label:"Account Settings",description:"Manage your account security",aliases:["password","account","security"],onSelect:()=>i("/settings/account")},{id:"settings-appearance",label:"Appearance Settings",description:"Choose your preferred color theme",aliases:["theme","appearance","dark mode","light mode"],onSelect:()=>i("/settings/appearance")},{id:"settings-projects",label:"Projects Settings",description:"Manage your projects",aliases:["projects","manage projects"],onSelect:()=>i("/settings/projects")},{id:"settings-chat",label:"Chat Settings",description:"Configure chat providers for conversations",aliases:["chat","openai","providers","chat providers"],onSelect:()=>i("/settings/chat")},{id:"settings-workers",label:"Workers Settings",description:"Configure and manage background workers",aliases:["workers","background","execution"],onSelect:()=>i("/settings/workers")},{id:"settings-ai-providers",label:"AI Providers",description:"View usage and quota for AI providers",aliases:["ai","providers","usage","quota","anthropic","openai","claude"],onSelect:()=>i("/settings/ai-providers")},{id:"settings-data",label:"Import / Export",description:"Import and export workspace data",aliases:["data","export","import","backup","restore"],onSelect:()=>i("/settings/data")},{id:"settings-users",label:"User Management",description:"Invite users and manage access",aliases:["users","user management","admin","accounts"],onSelect:()=>i("/settings/users")}]),[l,i]);const k=f.filter(w=>{const T=new Date(w.lastSeenAt);return Date.now()-T.getTime()<=120*1e3}).length,E=[{title:"Appearance",description:"Theme and visual preferences for Taico.",icon:BT,iconTone:"accent",path:"/settings/appearance",action:"More themes",detail:{label:"Current theme",value:Zw(c),tone:"default"},preview:a.jsx(Ww,{activeTheme:c,onSelect:w=>u(w)})},{title:"Projects",description:"Project metadata and repository links.",icon:Yd,iconTone:"accent",path:"/settings/projects",action:"Manage",detail:{label:"Projects",value:y.projects===null?"Unavailable":String(y.projects),tone:"default"}},{title:"AI & Chat",description:"Conversation providers and active chat routing.",icon:ZT,iconTone:"warning",path:"/settings/chat",action:"Configure",detail:{label:"Active provider",value:y.providers?.activeName??"Not selected",tone:y.providers?.activeName?"default":"muted"}},{title:"Workers",description:"Background execution workers and harness health.",icon:zy,iconTone:"green",path:"/settings/workers",action:"Open workers",detail:{label:"Connected workers",value:x?"Loading":String(k),tone:"default"}},{title:"Account",description:"Password and account-level access controls.",icon:RT,iconTone:"red",path:"/settings/account",action:"Security",detail:{label:"Password",value:"Change available",tone:"default"}},{title:"Users",description:"Invite people, reset passwords, and disable access.",icon:s0,iconTone:"accent",path:"/settings/users",action:"Manage users",detail:{label:"Access",value:"Admin only",tone:"default"}},{title:"Data",description:"Import and export workspace context blocks.",icon:oT,iconTone:"neutral",path:"/settings/data",action:"Import / export",detail:{label:"Export",value:"Context blocks",tone:"default"}}];return a.jsxs("div",{className:"settings-page",children:[t?a.jsx(b,{tone:"muted",children:"Manage your workspace, execution, providers, and data."}):null,a.jsxs("div",{className:"settings-page__layout",children:[a.jsxs("main",{className:"settings-page__main","aria-label":"Settings sections",children:[a.jsxs("div",{className:"settings-page__nav","aria-label":"Settings shortcuts",children:[a.jsxs("button",{className:"settings-page__nav-item",type:"button",onClick:()=>i("/settings"),"aria-current":"page",children:[a.jsx(Xx,{size:16,strokeWidth:1.8,"aria-hidden":"true"}),a.jsx("span",{children:"Overview"})]}),E.slice(0,4).map(w=>{const T=w.icon;return a.jsxs("button",{className:"settings-page__nav-item",type:"button",onClick:()=>i(w.path),children:[a.jsx(T,{size:16,strokeWidth:1.8,"aria-hidden":"true"}),a.jsx("span",{children:w.title})]},w.title)})]}),a.jsx("div",{className:"settings-page__section-grid",children:E.map(w=>{const T=w.icon;return a.jsxs(Fe,{padding:"0",className:`settings-page__section-card ${w.preview?"settings-page__section-card--with-carousel":""}`,children:[a.jsxs("div",{className:"settings-page__section-header",children:[a.jsx("span",{className:`settings-page__section-icon settings-page__section-icon--${w.iconTone}`,children:a.jsx(T,{size:22,strokeWidth:1.8,"aria-hidden":"true"})}),a.jsxs(te,{spacing:"1",children:[a.jsx(b,{size:"3",weight:"semibold",children:w.title}),a.jsx(b,{size:"1",tone:"muted",children:w.description})]})]}),w.preview??a.jsxs("div",{className:"settings-page__detail",children:[a.jsx(b,{size:"1",tone:"muted",children:w.detail.label}),a.jsx(b,{size:"2",weight:"medium",tone:w.detail.tone,children:w.detail.value})]}),a.jsxs(ue,{variant:"secondary",size:"sm",fullWidth:!0,onClick:()=>i(w.path),className:"settings-page__section-action",children:[a.jsx("span",{children:w.action}),a.jsx(Yx,{size:16,strokeWidth:1.8,"aria-hidden":"true"})]})]},w.title)})})]}),a.jsxs("aside",{className:"settings-page__side","aria-label":"Settings status",children:[a.jsx(Fe,{padding:"4",className:"settings-page__side-card",children:a.jsxs(te,{spacing:"4",children:[a.jsx(b,{size:"3",weight:"semibold",children:"Readiness"}),a.jsx(Rd,{icon:a.jsx(rT,{size:16,strokeWidth:1.8}),label:"Chat provider",value:y.providers?.activeName??"Needs active provider",isReady:!!y.providers?.activeName}),a.jsx(Rd,{icon:a.jsx(zy,{size:16,strokeWidth:1.8}),label:"Worker connection",value:x?"Checking":k>0?`${k} online`:"No workers online",isReady:k>0}),a.jsx(Rd,{icon:a.jsx(Yd,{size:16,strokeWidth:1.8}),label:"Projects",value:y.projects===null?"Checking":`${y.projects} available`,isReady:(y.projects??0)>0})]})}),a.jsx(Fe,{padding:"4",className:"settings-page__side-card",children:a.jsxs(te,{spacing:"3",children:[a.jsx(b,{size:"3",weight:"semibold",children:"Quick links"}),a.jsx(Co,{icon:a.jsx(Zk,{size:16}),label:"AI usage",onClick:()=>i("/settings/ai-providers")}),a.jsx(Co,{icon:a.jsx(ET,{size:16}),label:"Chat API keys",onClick:()=>i("/settings/chat")}),a.jsx(Co,{icon:a.jsx(Jk,{size:16}),label:"Setup walkthrough",onClick:()=>i("/walkthrough")}),a.jsx(Co,{icon:a.jsx(uT,{size:16}),label:"Tools",onClick:()=>i("/tools")})]})}),g?a.jsxs(b,{size:"1",tone:"muted",className:"settings-page__version",children:["Taico v",g.backend," · UI v",g.ui]}):null]})]})]})}function Zw(n){return n.split("-").map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ")}function Ww({activeTheme:n,onSelect:t}){return a.jsx("div",{className:"settings-page__theme-carousel","aria-label":"Theme preview selector",children:vv.map(i=>{const l=n===i.value;return a.jsxs("button",{type:"button",className:`settings-page__theme-preview ${l?"settings-page__theme-preview--active":""}`,onClick:()=>t(i.value),"aria-pressed":l,children:[a.jsx(xv,{preview:i.preview}),a.jsxs("span",{className:"settings-page__theme-preview-copy",children:[a.jsx("span",{children:i.label}),a.jsx("span",{children:i.preview.font})]})]},i.value)})})}function Rd({icon:n,label:t,value:i,isReady:l}){return a.jsxs("div",{className:"settings-page__status-row",children:[a.jsx("span",{className:`settings-page__status-icon ${l?"settings-page__status-icon--ready":""}`,children:n}),a.jsxs("div",{children:[a.jsx(b,{size:"2",weight:"medium",children:t}),a.jsx(b,{size:"1",tone:"muted",children:i})]})]})}function Co({icon:n,label:t,onClick:i}){return a.jsxs("button",{className:"settings-page__quick-link",type:"button",onClick:i,children:[a.jsx("span",{className:"settings-page__quick-link-icon","aria-hidden":"true",children:n}),a.jsx("span",{children:t}),a.jsx(Yx,{size:15,strokeWidth:1.8,"aria-hidden":"true"})]})}function Jw(){const{setSectionTitle:n}=js(),{logout:t}=us(),i=ze(),[l,c]=h.useState(""),[u,f]=h.useState(""),[x,g]=h.useState(""),[m,y]=h.useState(""),[_,v]=h.useState(!1);h.useEffect(()=>{n("Account")},[]);const j=async k=>{k.preventDefault(),g(""),y(""),v(!0);try{await es.webAuthControllerChangePassword({currentPassword:l,newPassword:u}),y("Password changed successfully! You will be logged out."),c(""),f(""),setTimeout(async()=>{await t(),i("/login")},2e3)}catch(E){g(E?.body?.detail||"Failed to change password. Please check your current password.")}finally{v(!1)}};return a.jsxs(te,{spacing:"6",className:"settings-subpage",children:[a.jsx(b,{tone:"muted",className:"settings-subpage__intro",children:"Update the password used to sign in to this Taico instance."}),a.jsx(Fe,{padding:"5",className:"settings-panel-card",children:a.jsxs(te,{spacing:"4",children:[a.jsxs(te,{spacing:"2",children:[a.jsx(b,{size:"4",weight:"semibold",children:"Change Password"}),a.jsx(b,{tone:"muted",children:"Update your account password"})]}),a.jsx("form",{onSubmit:j,children:a.jsxs(te,{spacing:"4",children:[a.jsxs(te,{spacing:"2",children:[a.jsx("label",{htmlFor:"current-password",className:"login-label",children:a.jsx(b,{size:"2",weight:"medium",children:"Current Password"})}),a.jsx("input",{id:"current-password",type:"password",value:l,onChange:k=>c(k.target.value),className:"login-input",placeholder:"••••••••",required:!0,disabled:_,autoComplete:"current-password"})]}),a.jsxs(te,{spacing:"2",children:[a.jsx("label",{htmlFor:"new-password",className:"login-label",children:a.jsx(b,{size:"2",weight:"medium",children:"New Password"})}),a.jsx("input",{id:"new-password",type:"password",value:u,onChange:k=>f(k.target.value),className:"login-input",placeholder:"••••••••",required:!0,disabled:_,autoComplete:"new-password"})]}),x&&a.jsx(Zt,{size:"2",weight:"medium",children:x}),m&&a.jsx("div",{style:{color:"var(--accent)"},children:a.jsx(b,{size:"2",weight:"medium",children:m})}),a.jsx(ue,{type:"submit",variant:"primary",size:"md",disabled:_||!l||!u,children:_?"Changing Password...":"Change Password"})]})})]})})]})}function e1(){const{theme:n,setTheme:t}=Ix(),{setSectionTitle:i}=js();return h.useEffect(()=>{i("Appearance")},[]),a.jsxs(te,{spacing:"6",className:"settings-subpage settings-subpage--wide",children:[a.jsx(b,{tone:"muted",className:"settings-subpage__intro",children:"Choose the visual style used across Taico."}),a.jsx("div",{className:"settings-theme-grid","aria-label":"Theme choices",children:vv.map(l=>{const c=n===l.value;return a.jsxs("button",{type:"button",className:`settings-theme-card ${c?"settings-theme-card--active":""}`,onClick:()=>t(l.value),"aria-pressed":c,children:[a.jsx(xv,{preview:l.preview,size:"large"}),a.jsxs("span",{className:"settings-theme-card__body",children:[a.jsxs("span",{className:"settings-theme-card__header",children:[a.jsx("span",{className:"settings-theme-card__title",children:l.label}),a.jsx("span",{className:"settings-theme-card__badge",children:c?"Active":l.preview.font})]}),a.jsx("span",{className:"settings-theme-card__description",children:l.description}),a.jsxs("span",{className:"settings-theme-card__palette","aria-hidden":"true",children:[a.jsx("span",{style:{backgroundColor:l.preview.background}}),a.jsx("span",{style:{backgroundColor:l.preview.surface}}),a.jsx("span",{style:{backgroundColor:l.preview.card}}),a.jsx("span",{style:{backgroundColor:l.preview.accent}})]})]})]},l.value)})})]})}function t1(){const{setSectionTitle:n}=js(),t=ze(),[i,l]=h.useState([]),[c,u]=h.useState(!0),[f,x]=h.useState(""),[g,m]=h.useState(null),[y,_]=h.useState(""),[v,j]=h.useState(""),[k,E]=h.useState(""),[w,T]=h.useState("");h.useEffect(()=>{n("Projects"),R()},[]);const R=async()=>{u(!0),x("");try{const N=await Vo.projectsControllerGetAllProjects();l(N)}catch(N){x(N?.body?.detail||"Failed to load projects")}finally{u(!1)}},z=N=>{m(N.id),_(N.description||""),j(N.repoUrl||""),E(""),T("")},L=()=>{m(null),_(""),j(""),E(""),T("")},M=async N=>{E(""),T("");try{await Vo.projectsControllerUpdateProject(N,{description:y,repoUrl:v}),T("Project updated successfully!"),m(null),await R(),setTimeout(()=>{T("")},3e3)}catch(A){E(A?.body?.detail||"Failed to update project")}};return c?a.jsx(te,{spacing:"6",className:"settings-subpage",children:a.jsx(b,{tone:"muted",children:"Loading projects..."})}):f?a.jsxs(te,{spacing:"6",className:"settings-subpage",children:[a.jsx(Zt,{children:f}),a.jsx(ue,{variant:"secondary",onClick:R,children:"Retry"})]}):a.jsxs(te,{spacing:"6",className:"settings-subpage",children:[a.jsx(b,{tone:"muted",className:"settings-subpage__intro",children:"Manage project metadata and repository links used by task workflows."}),a.jsxs(Mt,{justify:"space-between",align:"center",className:"settings-projects__toolbar",children:[a.jsx(b,{size:"3",weight:"semibold",children:"Projects"}),a.jsx(ue,{variant:"primary",size:"sm",onClick:()=>t("/settings/projects/new"),children:"New project"})]}),i.length===0?a.jsx(Fe,{padding:"5",className:"settings-panel-card",children:a.jsxs(te,{spacing:"3",children:[a.jsx(b,{tone:"muted",children:"No projects found"}),a.jsx(Mt,{children:a.jsx(ue,{variant:"secondary",size:"sm",onClick:()=>t("/settings/projects/new"),children:"Create project"})})]})}):i.map(N=>a.jsx(Fe,{padding:"5",className:"settings-panel-card",children:a.jsxs(te,{spacing:"4",children:[a.jsxs(te,{spacing:"2",children:[a.jsx(b,{size:"4",weight:"semibold",children:N.slug}),a.jsxs(b,{size:"2",tone:"muted",children:["Tag: ",N.tagName]})]}),g===N.id?a.jsx("form",{onSubmit:A=>{A.preventDefault(),M(N.id)},children:a.jsxs(te,{spacing:"4",children:[a.jsxs(te,{spacing:"2",children:[a.jsx("label",{htmlFor:`description-${N.id}`,className:"login-label",children:a.jsx(b,{size:"2",weight:"medium",children:"Description"})}),a.jsx("textarea",{id:`description-${N.id}`,value:y,onChange:A=>_(A.target.value),className:"login-input",placeholder:"Project description",rows:3,style:{resize:"vertical",fontFamily:"inherit"}})]}),a.jsxs(te,{spacing:"2",children:[a.jsx("label",{htmlFor:`repo-url-${N.id}`,className:"login-label",children:a.jsx(b,{size:"2",weight:"medium",children:"Repository URL"})}),a.jsx("input",{id:`repo-url-${N.id}`,type:"url",value:v,onChange:A=>j(A.target.value),className:"login-input",placeholder:"https://github.com/username/repo"})]}),k&&a.jsx(Zt,{size:"2",weight:"medium",children:k}),w&&a.jsx("div",{style:{color:"var(--accent)"},children:a.jsx(b,{size:"2",weight:"medium",children:w})}),a.jsxs(Mt,{spacing:"3",children:[a.jsx(ue,{type:"submit",variant:"primary",size:"md",children:"Save Changes"}),a.jsx(ue,{type:"button",variant:"secondary",size:"md",onClick:L,children:"Cancel"})]})]})}):a.jsxs(a.Fragment,{children:[a.jsxs(te,{spacing:"2",children:[a.jsx(b,{size:"2",weight:"medium",children:"Description"}),a.jsx(b,{size:"2",tone:"muted",children:N.description||"No description"})]}),a.jsxs(te,{spacing:"2",children:[a.jsx(b,{size:"2",weight:"medium",children:"Repository URL"}),a.jsx(b,{size:"2",tone:"muted",children:N.repoUrl||"No repository URL"})]}),a.jsx(Mt,{justify:"end",children:a.jsx(ue,{variant:"secondary",size:"sm",onClick:()=>z(N),children:"Edit Project"})})]})]})},N.id))]})}function s1(){const{setSectionTitle:n}=js(),t=ze(),[i,l]=h.useState(""),[c,u]=h.useState(""),[f,x]=h.useState(""),[g,m]=h.useState(!1),[y,_]=h.useState("");h.useEffect(()=>{n("Create Project")},[]);const v=async j=>{j.preventDefault(),_(""),m(!0);try{await Vo.projectsControllerCreateProject({slug:i.trim(),description:c.trim()||void 0,repoUrl:f.trim()||void 0}),t("/settings/projects")}catch(k){_(k?.body?.detail||"Failed to create project")}finally{m(!1)}};return a.jsxs(te,{spacing:"6",className:"settings-subpage",children:[a.jsx(b,{tone:"muted",className:"settings-subpage__intro",children:"Add a project tag and optional repository link."}),a.jsx(Fe,{padding:"5",className:"settings-panel-card",children:a.jsx("form",{onSubmit:v,children:a.jsxs(te,{spacing:"4",children:[a.jsxs(te,{spacing:"2",children:[a.jsx("label",{htmlFor:"project-slug",className:"login-label",children:a.jsx(b,{size:"2",weight:"medium",children:"Slug"})}),a.jsx("input",{id:"project-slug",value:i,onChange:j=>l(j.target.value),className:"login-input",placeholder:"taico",required:!0,disabled:g})]}),a.jsxs(te,{spacing:"2",children:[a.jsx("label",{htmlFor:"project-description",className:"login-label",children:a.jsx(b,{size:"2",weight:"medium",children:"Description"})}),a.jsx("textarea",{id:"project-description",value:c,onChange:j=>u(j.target.value),className:"login-input",placeholder:"Project description",rows:3,disabled:g,style:{resize:"vertical",fontFamily:"inherit"}})]}),a.jsxs(te,{spacing:"2",children:[a.jsx("label",{htmlFor:"project-repo-url",className:"login-label",children:a.jsx(b,{size:"2",weight:"medium",children:"Repository URL"})}),a.jsx("input",{id:"project-repo-url",type:"url",value:f,onChange:j=>x(j.target.value),className:"login-input",placeholder:"https://github.com/username/repo",disabled:g})]}),y?a.jsx(Zt,{size:"2",weight:"medium",children:y}):null,a.jsxs(Mt,{justify:"end",spacing:"3",children:[a.jsx(ue,{type:"button",variant:"secondary",size:"md",onClick:()=>t("/settings/projects"),disabled:g,children:"Cancel"}),a.jsx(ue,{type:"submit",variant:"primary",size:"md",disabled:g||!i.trim(),children:g?"Creating...":"Create project"})]})]})})})]})}function n1(){const{setSectionTitle:n}=js(),[t,i]=h.useState([]),[l,c]=h.useState(""),[u,f]=h.useState(!0),[x,g]=h.useState(""),[m,y]=h.useState(null),[_,v]=h.useState(null);h.useEffect(()=>{if(!_)return;const T=window.setTimeout(()=>{v(R=>R?.providerId===_.providerId?null:R)},2400);return()=>window.clearTimeout(T)},[_]),h.useEffect(()=>{n("Chat Settings"),j()},[]);const j=async()=>{f(!0);try{const T=await Ar.chatProvidersControllerListChatProviders();i(T)}catch(T){c(T?.body?.detail||"Failed to load chat settings")}finally{f(!1)}},k=async T=>{if(!x.trim()){c("Please enter an API key");return}c(""),v(null);try{await Ar.chatProvidersControllerUpdateChatProvider(T,{apiKey:x}),v({providerId:T,action:"configure",message:"Config updated"}),y(null),g(""),await j()}catch(R){c(R?.body?.detail||"Failed to configure provider")}},E=async T=>{if(!t.find(z=>z.id===T)?.isConfigured){c("Please configure the provider first");return}c(""),v(null);try{await Ar.chatProvidersControllerSetActiveChatProvider({providerId:T}),v({providerId:T,action:"activate",message:"Now active"}),await j()}catch(z){c(z?.body?.detail||"Failed to set active provider")}},w=async T=>{c(""),v(null);try{await Ar.chatProvidersControllerDeactivateActiveChatProvider(),v({providerId:T,action:"deactivate",message:"Deactivated"}),await j()}catch(R){c(R?.body?.detail||"Failed to deactivate provider")}};return u?a.jsx(te,{spacing:"6",className:"settings-subpage",children:a.jsx(b,{children:"Loading..."})}):a.jsxs(te,{spacing:"6",className:"settings-subpage",children:[a.jsx(b,{tone:"muted",className:"settings-subpage__intro",children:"Configure chat providers for thread conversations."}),l&&a.jsx(Zt,{size:"2",weight:"medium",children:l}),t.length===0?a.jsx(Fe,{padding:"5",className:"settings-panel-card",children:a.jsx(b,{tone:"muted",children:"No chat providers available. OpenAI provider should be created automatically."})}):t.map(T=>a.jsx(Fe,{padding:"5",className:"settings-panel-card",children:a.jsxs(te,{spacing:"4",children:[a.jsx(Mt,{justify:"space-between",align:"center",children:a.jsxs(te,{spacing:"1",className:"settings-chat__header-copy",children:[a.jsxs("div",{className:"settings-chat__title-row",children:[a.jsx(b,{size:"4",weight:"semibold",children:T.name}),T.isActive?a.jsx("span",{className:"settings-chat__active-indicator",children:"Active"}):null]}),T.type==="openai"?a.jsxs(b,{size:"1",tone:"muted",children:["You can get an API key from"," ",a.jsx("a",{href:"https://platform.openai.com/api-keys",target:"_blank",rel:"noopener noreferrer",className:"settings-chat__helper-link",children:"platform.openai.com/api-keys"})]}):T.type==="adk"?a.jsx(b,{size:"1",tone:"muted",children:"Uses Google AI environment variables (GOOGLE_API_KEY or Vertex AI config). No key stored here."}):null]})}),m===T.id&&T.type!=="adk"?a.jsxs(te,{spacing:"3",children:[a.jsxs(te,{spacing:"2",children:[a.jsx(b,{size:"2",weight:"medium",children:"Enter API Key"}),a.jsx("input",{type:"password",value:x,onChange:R=>g(R.target.value),className:"login-input",placeholder:"sk-...",autoFocus:!0}),a.jsx(b,{size:"1",tone:"muted",children:"Your API key will be stored securely"})]}),a.jsxs(Mt,{spacing:"2",children:[a.jsx(ue,{variant:"primary",size:"sm",onClick:()=>k(T.id),disabled:!x.trim(),children:"Save"}),a.jsx(ue,{variant:"secondary",size:"sm",onClick:()=>{y(null),g("")},children:"Cancel"})]})]}):a.jsx(Mt,{spacing:"2",children:(()=>{const R=_?.providerId===T.id&&_.action==="configure"?_.message:null,z=_?.providerId===T.id&&_.action==="activate"?_.message:null,L=_?.providerId===T.id&&_.action==="deactivate"?_.message:null,M=z||L,N=!T.isActive&&!T.isConfigured,A=M?"primary":T.isActive?"danger":"primary",I=M||(T.isActive?"Deactivate":"Set Active"),Q=T.isActive?()=>w(T.id):()=>E(T.id),Z=N?"Configure the provider first to set it as active":"";return a.jsxs(a.Fragment,{children:[T.type!=="adk"&&a.jsx(ue,{variant:R?"primary":"secondary",size:"sm",onClick:()=>y(T.id),children:R||(T.isConfigured?"Update Config":"Configure")}),a.jsx("span",{className:"settings-chat__action-wrapper",title:Z,children:a.jsx(ue,{variant:A,size:"sm",onClick:Q,disabled:N,className:"settings-chat__action-button","data-feedback":z?"active":L?"deactivated":null,children:I})})]})})()})]})},T.id))]})}function a1(){const{setSectionTitle:n}=js(),[t,i]=h.useState(!1),[l,c]=h.useState(!1),[u,f]=h.useState(null),[x,g]=h.useState(""),[m,y]=h.useState("");h.useEffect(()=>{n("Import / Export")},[n]);const _=h.useMemo(()=>`${Ba}/api/v1/context/blocks/export`,[]),v=h.useMemo(()=>`${Ba}/api/v1/context/blocks/import`,[]),j=async()=>{i(!0),g(""),y("");try{const E=await fetch(_,{method:"GET",credentials:"include"});if(!E.ok)throw new Error("Failed to export blocks");const w=await E.blob(),R=E.headers.get("content-disposition")?.match(/filename="?([^";]+)"?/)?.[1]||"context-blocks.zip",z=window.URL.createObjectURL(w),L=document.createElement("a");L.href=z,L.download=R,document.body.appendChild(L),L.click(),L.remove(),window.URL.revokeObjectURL(z),y("Blocks export downloaded successfully.")}catch{g("Failed to export blocks. Please try again.")}finally{i(!1)}},k=async()=>{if(!u){g("Please choose a .zip file first."),y("");return}c(!0),g(""),y("");try{const E=new FormData;E.append("file",u);const w=await fetch(v,{method:"POST",credentials:"include",body:E}),T=await w.json().catch(()=>({}));if(!w.ok)throw new Error("Failed to import blocks");const R=T.importedCount??0;y(`Import complete. ${R} block${R===1?"":"s"} created.`),f(null)}catch{g("Failed to import blocks. Verify the archive format and try again.")}finally{c(!1)}};return a.jsxs(te,{spacing:"6",className:"settings-subpage",children:[a.jsx(b,{tone:"muted",className:"settings-subpage__intro",children:"Import and export workspace data. Blocks are available now; task support can be added in this section later."}),x?a.jsx(Zt,{size:"2",weight:"medium",children:x}):null,m?a.jsx(b,{size:"2",className:"settings-data__success",children:m}):null,a.jsx(Fe,{padding:"5",className:"settings-panel-card",children:a.jsxs(te,{spacing:"4",children:[a.jsxs(te,{spacing:"1",children:[a.jsx(b,{size:"4",weight:"semibold",children:"Export Blocks"}),a.jsx(b,{tone:"muted",children:"Download all context blocks as a nested markdown zip archive."})]}),a.jsx(Mt,{justify:"end",children:a.jsx(ue,{variant:"primary",size:"sm",onClick:j,disabled:t,children:t?"Exporting...":"Export Blocks"})})]})}),a.jsx(Fe,{padding:"5",className:"settings-panel-card",children:a.jsxs(te,{spacing:"4",children:[a.jsxs(te,{spacing:"1",children:[a.jsx(b,{size:"4",weight:"semibold",children:"Import Blocks"}),a.jsx(b,{tone:"muted",children:"Upload a blocks archive to create context blocks in this workspace."})]}),a.jsx("label",{htmlFor:"blocks-import-file",className:"settings-data__file-label",children:"Select archive (.zip)"}),a.jsx("input",{id:"blocks-import-file",type:"file",accept:".zip,application/zip",onChange:E=>f(E.target.files?.[0]??null),className:"settings-data__file-input"}),a.jsx(b,{size:"1",tone:"muted",children:u?`Selected: ${u.name}`:"No file selected"}),a.jsx(Mt,{justify:"end",children:a.jsx(ue,{variant:"secondary",size:"sm",onClick:k,disabled:l,children:l?"Importing...":"Import Blocks"})})]})})]})}function r1(){const{setSectionTitle:n}=js(),{workers:t,isLoading:i,error:l}=Eh(),[c,u]=h.useState(null);h.useEffect(()=>{n("Workers Settings")},[]);const x=`npx -y @taico/worker --serverurl ${`${window.location.protocol}//${window.location.host}`}`,g=y=>{const _=new Date(y),j=new Date().getTime()-_.getTime(),k=120*1e3;return j<=k},m=async()=>{try{await navigator.clipboard.writeText(x),u("Copied"),window.setTimeout(()=>u(null),1800)}catch{u("Copy failed"),window.setTimeout(()=>u(null),1800)}};return i?a.jsx(te,{spacing:"6",className:"settings-subpage",children:a.jsx(b,{children:"Loading..."})}):a.jsxs(te,{spacing:"6",className:"settings-subpage",children:[a.jsx(b,{tone:"muted",className:"settings-subpage__intro",children:"Workers execute tasks in the background. Configure workers to enable automated task execution."}),l?a.jsx(Zt,{size:"2",weight:"medium",children:l}):null,a.jsx(Fe,{padding:"5",className:"settings-panel-card",children:a.jsxs(te,{spacing:"4",children:[a.jsxs(te,{spacing:"1",children:[a.jsx(b,{size:"4",weight:"semibold",children:"Configure a New Worker"}),a.jsx(b,{tone:"muted",children:"Run this command in your terminal to start a new worker:"})]}),a.jsxs("div",{className:"settings-workers__command-container",children:[a.jsx("code",{className:"settings-workers__command",children:x}),a.jsx(ue,{className:"settings-workers__copy-button",variant:"secondary",size:"sm",onClick:m,children:c??"Copy"})]}),a.jsx(b,{size:"1",tone:"muted",children:"The worker will automatically register and appear in the list below when it connects."})]})}),a.jsxs(te,{spacing:"3",children:[a.jsxs(b,{size:"4",weight:"semibold",children:["Registered Workers (",t.length,")"]}),t.length===0?a.jsx(Fe,{padding:"5",className:"settings-panel-card",children:a.jsx(b,{tone:"muted",children:"No workers registered yet. Run the command above to start your first worker."})}):t.map(y=>{const _=g(y.lastSeenAt),j=new Date(y.lastSeenAt).toLocaleString();return a.jsx(Fe,{padding:"5",className:"settings-panel-card",children:a.jsxs(te,{spacing:"3",children:[a.jsx(Mt,{justify:"space-between",align:"center",children:a.jsxs(te,{spacing:"1",children:[a.jsxs("div",{className:"settings-workers__title-row",children:[a.jsx(b,{size:"3",weight:"semibold",children:"Worker"}),_?a.jsx(ST,{className:"settings-workers__status-icon settings-workers__status-icon--connected",size:18,strokeWidth:1.5,absoluteStrokeWidth:!0,"aria-label":"Connected"}):a.jsx(bT,{className:"settings-workers__status-icon settings-workers__status-icon--disconnected",size:18,strokeWidth:1.5,absoluteStrokeWidth:!0,"aria-label":"Disconnected"})]}),a.jsxs(b,{size:"1",tone:"muted",children:["ID: ",y.id]}),a.jsxs(b,{size:"1",tone:"muted",children:["Version: ",y.workerVersion??"Unknown"]}),a.jsxs(b,{size:"1",tone:"muted",children:["Last seen: ",j]})]})}),y.harnesses&&y.harnesses.length>0&&a.jsxs(te,{spacing:"1",children:[a.jsx(b,{size:"2",weight:"medium",children:"Harnesses:"}),a.jsx("div",{className:"settings-workers__harnesses",children:y.harnesses.map(k=>a.jsx("span",{className:"settings-workers__harness-badge",children:k},k))})]})]})},y.id)})]})]})}function i1(){const{setSectionTitle:n}=js();return jt(),h.useEffect(()=>{n("AI Providers")},[]),a.jsxs(te,{spacing:"6",className:"settings-subpage",children:[a.jsx(b,{tone:"muted",className:"settings-subpage__intro",children:"View usage and quota information for AI providers."}),a.jsx(Fe,{padding:"5",className:"settings-panel-card",children:a.jsxs(te,{spacing:"4",children:[a.jsx(Mt,{justify:"space-between",align:"center",children:a.jsxs(te,{spacing:"1",children:[a.jsx(b,{size:"4",weight:"semibold",children:"OpenAI"}),a.jsx(b,{size:"1",tone:"muted",children:"Codex and GPT models"})]})}),a.jsx(te,{spacing:"2",children:a.jsx(Mt,{spacing:"2",children:a.jsx(ue,{variant:"secondary",size:"sm",onClick:()=>window.open("https://chatgpt.com/codex/cloud/settings/usage","_blank","noopener,noreferrer"),children:"See usage"})})})]})}),a.jsx(Fe,{padding:"5",className:"settings-panel-card",children:a.jsxs(te,{spacing:"4",children:[a.jsx(Mt,{justify:"space-between",align:"center",children:a.jsxs(te,{spacing:"1",children:[a.jsx(b,{size:"4",weight:"semibold",children:"Anthropic"}),a.jsx(b,{size:"1",tone:"muted",children:"Claude models"})]})}),a.jsx(te,{spacing:"2",children:a.jsx(Mt,{spacing:"2",children:a.jsx(ue,{variant:"secondary",size:"sm",onClick:()=>window.open("https://claude.ai/settings/usage","_blank","noopener,noreferrer"),children:"See usage"})})})]})})]})}function l1(){const{setSectionTitle:n}=js(),{user:t,isLoading:i}=us(),[l,c]=h.useState([]),[u,f]=h.useState(""),[x,g]=h.useState(Nr.role.STANDARD),[m,y]=h.useState(""),[_,v]=h.useState(""),[j,k]=h.useState(!1),[E,w]=h.useState(!1);h.useEffect(()=>{n("User Management")},[n]);const T=t?.role==="admin";h.useEffect(()=>{i||!T||R()},[i,T]);const R=async()=>{if(T){k(!0),y("");try{const N=await es.webAuthControllerListUsers();c(N)}catch(N){y(No(N,"Failed to load users."))}finally{k(!1)}}},z=async N=>{N.preventDefault(),w(!0),y(""),v("");try{await es.webAuthControllerCreateUser({email:u,role:x}),f(""),g(Nr.role.STANDARD),v("User created. They can use Create account on the login screen to set their profile and password."),await R()}catch(A){y(No(A,"Failed to create user."))}finally{w(!1)}},L=async N=>{y(""),v("");try{await es.webAuthControllerResetUserPassword(N.id),v(`${N.email} can now set a new password from the login screen.`),await R()}catch(A){y(No(A,"Failed to reset password."))}},M=async N=>{if(window.confirm(`Disable login for ${N.email}?`)){y(""),v("");try{await es.webAuthControllerDeleteUser(N.id),v(`${N.email} has been deactivated.`),await R()}catch(A){y(No(A,"Failed to delete user."))}}};return i?a.jsx(Fe,{padding:"5",children:a.jsx(b,{tone:"muted",children:"Loading user management..."})}):T?a.jsxs("div",{className:"settings-users-page",children:[a.jsx(Fe,{padding:"5",className:"settings-users-page__hero",children:a.jsxs(te,{spacing:"2",children:[a.jsx("span",{className:"settings-users-page__hero-icon","aria-hidden":"true",children:a.jsx(KT,{size:20})}),a.jsx(b,{size:"5",weight:"bold",children:"User management"}),a.jsx(b,{tone:"muted",children:"Invite human users, manage roles, reset passwords, and disable access."})]})}),a.jsx(Fe,{padding:"5",children:a.jsx("form",{onSubmit:z,children:a.jsxs(te,{spacing:"4",children:[a.jsxs(te,{spacing:"1",children:[a.jsx(b,{size:"3",weight:"semibold",children:"Create user"}),a.jsx(b,{size:"1",tone:"muted",children:"New users receive access by setting up their account from the login screen."})]}),a.jsxs("div",{className:"settings-users-page__create-grid",children:[a.jsxs(te,{spacing:"2",children:[a.jsx("label",{className:"login-label",htmlFor:"managed-user-email",children:a.jsx(b,{size:"2",weight:"medium",children:"Email"})}),a.jsx("input",{id:"managed-user-email",className:"login-input",type:"email",value:u,onChange:N=>f(N.target.value),placeholder:"name@work.com",required:!0,disabled:E})]}),a.jsxs(te,{spacing:"2",children:[a.jsx("label",{className:"login-label",htmlFor:"managed-user-role",children:a.jsx(b,{size:"2",weight:"medium",children:"Role"})}),a.jsxs("select",{id:"managed-user-role",className:"login-input",value:x,onChange:N=>g(N.target.value),disabled:E,children:[a.jsx("option",{value:Nr.role.STANDARD,children:"Normal user"}),a.jsx("option",{value:Nr.role.ADMIN,children:"Admin"})]})]}),a.jsxs(ue,{type:"submit",variant:"primary",disabled:E,className:"settings-users-page__create-button",children:[a.jsx(e0,{size:16}),E?"Creating...":"Create user"]})]}),_?a.jsx(b,{size:"2",tone:"muted",children:_}):null,m?a.jsx(Zt,{size:"2",weight:"medium",children:m}):null]})})}),a.jsxs(Fe,{padding:"0",className:"settings-users-page__list-card",children:[a.jsxs("div",{className:"settings-users-page__list-header",children:[a.jsx(b,{size:"3",weight:"semibold",children:"Users"}),a.jsx(ue,{variant:"secondary",size:"sm",onClick:R,disabled:j,children:j?"Refreshing...":"Refresh"})]}),a.jsxs("div",{className:"settings-users-page__list",children:[l.map(N=>a.jsxs("div",{className:"settings-users-page__row",children:[a.jsxs("div",{className:"settings-users-page__identity",children:[a.jsx(b,{size:"2",weight:"semibold",children:N.displayName}),a.jsxs(b,{size:"1",tone:"muted",children:[N.email," · @",N.slug]})]}),a.jsxs("div",{className:"settings-users-page__badges",children:[a.jsx("span",{className:"settings-users-page__badge",children:N.role==="admin"?"Admin":"Normal"}),a.jsx("span",{className:`settings-users-page__badge ${N.isActive?"settings-users-page__badge--active":"settings-users-page__badge--inactive"}`,children:N.isActive?"Active":"Inactive"}),N.passwordSetupPending?a.jsx("span",{className:"settings-users-page__badge settings-users-page__badge--pending",children:"Setup pending"}):null]}),a.jsxs("div",{className:"settings-users-page__actions",children:[a.jsx(ue,{variant:"secondary",size:"sm",onClick:()=>L(N),disabled:!N.isActive,children:"Reset password"}),a.jsx(ue,{variant:"secondary",size:"sm",onClick:()=>M(N),disabled:!N.isActive||N.actorId===t?.actorId,children:"Delete"})]})]},N.id)),!j&&l.length===0?a.jsx(b,{tone:"muted",className:"settings-users-page__empty",children:"No users found."}):null]})]})]}):a.jsx(Fe,{padding:"5",children:a.jsxs(te,{spacing:"2",children:[a.jsx(b,{size:"4",weight:"semibold",children:"Admin access required"}),a.jsx(b,{tone:"muted",children:"Only admin users can manage user accounts."})]})})}function No(n,t){return n?.body?.detail||n?.body?.title||n?.message||t}function o1({step:n,isCompleted:t,isCurrent:i,isLast:l,isExpanded:c,onToggle:u}){return a.jsxs("div",{className:"walkthrough-step",children:[a.jsxs("div",{className:"walkthrough-step-rail",children:[a.jsx("div",{className:["walkthrough-step-dot",t?"walkthrough-step-dot--completed":"",i?"walkthrough-step-dot--current":""].filter(Boolean).join(" "),children:t&&a.jsx("svg",{width:"10",height:"8",viewBox:"0 0 10 8",fill:"none","aria-hidden":"true",children:a.jsx("path",{d:"M1 4L3.5 6.5L9 1",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),!l&&a.jsx("div",{className:["walkthrough-step-connector",t?"walkthrough-step-connector--completed":""].filter(Boolean).join(" ")})]}),a.jsxs("div",{className:"walkthrough-step-body",children:[a.jsx("button",{className:"walkthrough-step-header",onClick:u,"aria-expanded":c,children:a.jsx(b,{size:"2",weight:i?"semibold":"medium",className:t?"walkthrough-label-done":"",children:n.label})}),c&&a.jsxs("div",{className:"walkthrough-step-detail",children:[a.jsx(b,{size:"2",tone:"muted",as:"p",className:"walkthrough-step-description",children:n.description}),a.jsx(Mn,{to:n.href,className:"walkthrough-step-cta",children:"Go →"})]})]})]})}function c1(){const{setSectionTitle:n}=js(),{user:t,refreshAuth:i}=us(),{status:l,isLoading:c}=tv(),[u,f]=h.useState(new Set),x=h.useRef(!1),g=h.useRef(!1);jt(),h.useEffect(()=>{n("Setup walkthrough")},[n]),h.useEffect(()=>{g.current||!t||!l||t.onboardingDisplayMode==="OFF"&&l.completedCount<l.totalCount&&(g.current=!0,_h.WalkthroughController_acknowledge().then(()=>i()).catch(console.error))},[t,l,i]),h.useEffect(()=>{if(!l||x.current)return;x.current=!0;const j=l.steps.find(k=>!k.completed);j&&f(new Set([j.id]))},[l]);const m=j=>{f(k=>{const E=new Set(k);return E.has(j)?E.delete(j):E.add(j),E})},y=l?.completedCount??0,_=l?.totalCount??8,v=l?.steps.findIndex(j=>!j.completed)??-1;return a.jsx("div",{className:"walkthrough-page",children:a.jsxs(te,{spacing:"5",className:"walkthrough-page-inner",children:[a.jsxs(te,{spacing:"1",children:[a.jsx(b,{size:"2",tone:"muted",as:"p",children:"Complete these steps to get the most out of Taico."}),a.jsxs(b,{size:"2",weight:"semibold",children:[y," / ",_," completed"]})]}),c?a.jsx(b,{size:"2",tone:"muted",children:"Loading..."}):a.jsx("div",{className:"walkthrough-track",children:l?.steps.map((j,k)=>a.jsx(o1,{step:j,isCompleted:j.completed,isCurrent:k===v,isLast:k===l.steps.length-1,isExpanded:u.has(j.id),onToggle:()=>m(j.id)},j.id))})]})})}function u1(){return a.jsx(U0,{children:a.jsx(dn,{children:a.jsxs(Se,{element:a.jsx(Y0,{}),children:[a.jsx(Se,{path:"/home",element:a.jsx(G0,{})}),a.jsx(Se,{path:"/settings",element:a.jsx(Xw,{})}),a.jsx(Se,{path:"/settings/account",element:a.jsx(Jw,{})}),a.jsx(Se,{path:"/settings/appearance",element:a.jsx(e1,{})}),a.jsx(Se,{path:"/settings/projects",element:a.jsx(t1,{})}),a.jsx(Se,{path:"/settings/projects/new",element:a.jsx(s1,{})}),a.jsx(Se,{path:"/settings/chat",element:a.jsx(n1,{})}),a.jsx(Se,{path:"/settings/workers",element:a.jsx(r1,{})}),a.jsx(Se,{path:"/settings/ai-providers",element:a.jsx(i1,{})}),a.jsx(Se,{path:"/settings/data",element:a.jsx(a1,{})}),a.jsx(Se,{path:"/settings/users",element:a.jsx(l1,{})}),a.jsx(Se,{path:"/walkthrough",element:a.jsx(c1,{})})]})})})}const d1="/",h1=window.location.origin,ha=new Ws({baseUrl:h1,credentials:"include"}),Qt=ha.task;ha.actors;const f1=ha.meta,p1=ha.metaProjects;ha.task,ha.actors,ha.meta,ha.metaProjects;const g1=pa("/tasks"),m1=100,Ho="tasks.selectedProjectId";function y1(){try{return localStorage.getItem(Ho)}catch{return null}}function zd(n,t){return n.tags.some(i=>i.name===t)}const x1=()=>{const[n,t]=h.useState(!0),[i,l]=h.useState(!1),[c,u]=h.useState(null),[f,x]=h.useState([]),[g,m]=h.useState([]),[y,_]=h.useState([]),[v,j]=h.useState(!1),[k,E]=h.useState(()=>y1()),[w,T]=h.useState(null),[R,z]=h.useState(!1),[L,M]=h.useState({}),N=h.useRef([]),A=h.useRef(null),I=h.useRef(!1),Q=h.useRef(0),Z=h.useMemo(()=>k?y.find(ce=>ce.id===k)??null:null,[y,k]),U=Z?.tagName??null,le=!k||!!Z;h.useEffect(()=>{N.current=f},[f]),h.useEffect(()=>{A.current=U},[U]),h.useEffect(()=>{I.current=le},[le]);const W=h.useCallback(ce=>{E(ce);try{ce?localStorage.setItem(Ho,ce):localStorage.removeItem(Ho)}catch(Y){console.error("Failed to persist selected task project",Y)}},[]),oe=h.useCallback(async()=>{try{const ce=await p1.ProjectsController_getAllProjects();_(ce)}catch(ce){console.error("Failed to load projects",ce),_([])}finally{j(!0)}},[]),me=ce=>{if(!ce.message){console.warn("Received task activity event without message, skipping",ce);return}M(Y=>({...Y,[ce.taskId]:ce}))},B=ce=>{M(Y=>{const{[ce]:fe,...K}=Y;return K})},se=ce=>[...ce].sort((Y,fe)=>{const K=new Date(Y.updatedAt).getTime();return new Date(fe.updatedAt).getTime()-K}),ge=(ce,Y)=>{const fe=new Set(Y.map(K=>K.id));return se([...Y,...ce.filter(K=>!fe.has(K.id))])},Ee=ce=>{m(Y=>ge(Y,[ce]))},Ce=async ce=>{const Y=A.current,fe=Y?{...ce,tagNames:Array.from(new Set([...ce.tagNames??[],Y]))}:ce;return await Qt.TasksController_createTask({body:fe})},D=async({taskId:ce})=>await Qt.TasksController_deleteTask({id:ce}),H=async({taskId:ce,comment:Y})=>await Qt.TasksController_addComment({id:ce,body:{content:Y}}),he=async({taskId:ce,assigneeActorId:Y})=>{const fe={assigneeActorId:Y};return await Qt.TasksController_assignTask({id:ce,body:fe})},pe=async({taskId:ce})=>await Qt.TasksController_assignTaskToMe({id:ce}),G=async({taskId:ce,inputRequestId:Y,answer:fe})=>await Qt.TasksController_answerInputRequest({id:ce,inputRequestId:Y,body:{answer:fe}}),ae=async()=>{if(!I.current)return;const ce=Q.current+1;Q.current=ce;const Y=A.current;t(!0),u(null);try{const fe=await Qt.TasksController_listTasks({page:1,limit:m1,tag:Y??void 0});if(Q.current!==ce||A.current!==Y)return;const K=Y?fe.items.filter(je=>zd(je,Y)):fe.items;x(je=>ge(je,K))}catch(fe){if(Q.current!==ce||A.current!==Y)return;u(fe instanceof Error?fe.message:"Failed to load tasks")}finally{Q.current===ce&&A.current===Y&&(l(!0),t(!1))}},J=h.useCallback(async ce=>{try{const Y=await Qt.TasksController_getTask({id:ce});return Ee(Y),x(fe=>xe(Y)?fe.some(K=>K.id===Y.id)?se(fe.map(K=>K.id===Y.id?Y:K)):se([Y,...fe]):fe.filter(K=>K.id!==Y.id)),Y}catch(Y){return console.error("Failed to fetch task by ID",Y),null}},[]),xe=ce=>{const Y=A.current;return!Y||zd(ce,Y)},Re=ce=>{const Y=A.current;return Y?N.current.some(fe=>fe.id===ce&&zd(fe,Y)):!0},Qe=ce=>{if(Ee(ce),!xe(ce)){x(Y=>Y.filter(fe=>fe.id!==ce.id)),B(ce.id);return}x(Y=>Y.some(fe=>fe.id===ce.id)?se(Y.map(fe=>fe.id===ce.id?ce:fe)):se([ce,...Y]))},It=ce=>{x(Y=>Y.filter(fe=>fe.id!==ce)),m(Y=>Y.filter(fe=>fe.id!==ce)),B(ce)},nt=async(ce,Y)=>{try{const fe=await Qt.TasksController_getTask({id:ce});Qe(fe)}catch(fe){console.error(Y,fe)}},mt=()=>{const ce=Bs(g1,{transports:["websocket","polling"],withCredentials:!0});return ce.on("connect",()=>{console.log("Connected to websocket"),ce.emit("tasks.subscribe",{},Y=>{Y.ok?(console.log(Y),console.log("Subscribed to room:",Y.room),z(!0)):(console.error("Failed to subscribe to room"),z(!1))}),ae()}),ce.on("disconnect",()=>{console.log("WebSocket disconnected"),z(!1)}),ce.on(bs.TASK_CREATED,Y=>{console.log("task.created",Y),Qe(Y.payload)}),ce.on(bs.TASK_UPDATED,Y=>{console.log("task.updated",Y),Qe(Y.payload)}),ce.on(bs.TASK_DELETED,Y=>{console.log("task.deleted",Y),It(Y.payload.taskId)}),ce.on(bs.TASK_ASSIGNED,Y=>{console.log("task.assigned",Y),Qe(Y.payload)}),ce.on(bs.TASK_COMMENTED,async Y=>{console.log("task.commented",Y),await nt(Y.payload.taskId,"Failed to refresh task after comment")}),ce.on(bs.INPUT_REQUEST_ANSWERED,async Y=>{console.log("input.request.answered",Y),await nt(Y.payload.taskId,"Failed to refresh task after input request answer")}),ce.on(bs.TASK_STATUS_CHANGED,Y=>{console.log("task.status_changed",Y),Qe(Y.payload)}),ce.on(bs.TASK_ACTIVITY,Y=>{console.log("task.activity",Y),Re(Y.taskId)&&me(Y)}),T(ce),()=>{ce.close()}};return h.useEffect(()=>{oe()},[oe]),h.useEffect(()=>{const ce=Y=>{Y.key===Ho&&E(Y.newValue)};return window.addEventListener("storage",ce),()=>window.removeEventListener("storage",ce)},[]),h.useEffect(()=>{!v||!k||Z||W(null)},[v,Z,k,W]),h.useEffect(()=>le?(x([]),M({}),ae(),mt()):void 0,[le,U]),{isLoading:n,hasLoadedOnce:i,error:c,activityByTaskId:L,projects:y,projectsLoaded:v,selectedProjectId:k,selectedProject:Z,selectedProjectTag:U,setSelectedProjectId:W,tasks:f,detailTasks:g,getTaskById:J,createTask:Ce,deleteTask:D,addComment:H,assignTask:he,assignTaskToMe:pe,answerInputRequest:G,isConnected:R}},_e={NOT_STARTED:"NOT_STARTED",IN_PROGRESS:"IN_PROGRESS",FOR_REVIEW:"FOR_REVIEW",DONE:"DONE"},Zs={[_e.NOT_STARTED]:{path:"/tasks/not-started",label:"Queued",icon:TT},[_e.IN_PROGRESS]:{path:"/tasks/in-progress",label:"Building",icon:xT},[_e.FOR_REVIEW]:{path:"/tasks/in-review",label:"Review",icon:hT},[_e.DONE]:{path:"/tasks/done",label:"Shipped",icon:VT}},v1=[Zs[_e.NOT_STARTED],Zs[_e.IN_PROGRESS],Zs[_e.FOR_REVIEW],Zs[_e.DONE]],b1=()=>({[_e.NOT_STARTED]:{enteringIds:new Set,exitingTasks:[]},[_e.IN_PROGRESS]:{enteringIds:new Set,exitingTasks:[]},[_e.FOR_REVIEW]:{enteringIds:new Set,exitingTasks:[]},[_e.DONE]:{enteringIds:new Set,exitingTasks:[]}}),bv=h.createContext(null),_1=500,S1=4e3;function j1({children:n}){const{tasks:t,detailTasks:i,getTaskById:l,isLoading:c,hasLoadedOnce:u,error:f,isConnected:x,createTask:g,deleteTask:m,addComment:y,assignTask:_,assignTaskToMe:v,answerInputRequest:j,activityByTaskId:k,projects:E,projectsLoaded:w,selectedProjectId:T,selectedProject:R,selectedProjectTag:z,setSelectedProjectId:L}=x1(),[M,N]=h.useState(""),[A,I]=h.useState(0),Q=h.useRef(new Map),Z=h.useRef([]),U=h.useRef(new Map),le=h.useRef(0),[W,oe]=h.useState(0),{animationByStatus:me,globalEnteringIds:B,globalExitingTasks:se}=h.useMemo(()=>{const Ee=Date.now(),Ce=new Map(t.map(J=>[J.id,J])),D=Q.current,H=new Set(D.keys()),he=new Set(Ce.keys());if(Z.current=Z.current.filter(J=>J.expiresAt>Ee),H.size>0){const J={[_e.NOT_STARTED]:new Set,[_e.IN_PROGRESS]:new Set,[_e.FOR_REVIEW]:new Set,[_e.DONE]:new Set},xe={[_e.NOT_STARTED]:[],[_e.IN_PROGRESS]:[],[_e.FOR_REVIEW]:[],[_e.DONE]:[]},Re=new Set,Qe=[];for(const[nt,mt]of Ce){const ce=D.get(nt);ce?ce.status!==mt.status&&(xe[ce.status].push(ce),J[mt.status].add(nt)):(J[mt.status].add(nt),Re.add(nt))}for(const[nt,mt]of D)he.has(nt)||(xe[mt.status].push(mt),Qe.push(mt));(Object.values(J).some(nt=>nt.size>0)||Object.values(xe).some(nt=>nt.length>0))&&Z.current.push({enteringByStatus:J,exitingByStatus:xe,globalEntering:Re,globalExiting:Qe,expiresAt:Ee+_1})}Q.current=Ce;const pe=b1();let G=new Set,ae=[];for(const J of Z.current){for(const xe of Object.values(_e))J.enteringByStatus[xe].forEach(Re=>pe[xe].enteringIds.add(Re)),pe[xe].exitingTasks.push(...J.exitingByStatus[xe]);J.globalEntering.forEach(xe=>G.add(xe)),ae.push(...J.globalExiting)}return{animationByStatus:pe,globalEnteringIds:G,globalExitingTasks:ae}},[t,W]);h.useEffect(()=>{if(Z.current.length===0)return;const Ce=Math.min(...Z.current.map(H=>H.expiresAt))-Date.now();if(Ce<=0){oe(H=>H+1);return}const D=setTimeout(()=>{oe(H=>H+1)},Ce);return()=>clearTimeout(D)},[me,B,se]),h.useEffect(()=>{const Ee=U.current,Ce=new Map(t.map(H=>[H.id,H]));if(Ee.size===0){U.current=Ce;return}let D=!1;for(const[H,he]of Ce){const pe=Ee.get(H);if(pe&&pe.status!==_e.DONE&&he.status===_e.DONE){D=!0;break}}if(D){const H=Date.now();H-le.current>=S1&&(le.current=H,I(he=>he+1))}U.current=Ce},[t]);const ge=h.useMemo(()=>({tasks:t,detailTasks:i,getTaskById:l,createTask:g,deleteTask:m,addComment:y,assignTask:_,assignTaskToMe:v,answerInputRequest:j,isLoading:c,hasLoadedOnce:u,error:f,isConnected:x,sectionTitle:M,setSectionTitle:N,animationByStatus:me,globalEnteringIds:B,globalExitingTasks:se,activityByTaskId:k,shippedCelebrationTrigger:A,projects:E,projectsLoaded:w,selectedProjectId:T,selectedProject:R,selectedProjectTag:z,setSelectedProjectId:L}),[t,i,l,g,m,y,_,v,j,c,u,f,x,M,N,me,B,se,k,A,E,w,T,R,z,L]);return a.jsx(bv.Provider,{value:ge,children:n})}function qn(){const n=h.useContext(bv);if(!n)throw new Error("useTasksCtx must be used within <TasksProvider>");return n}function gt({title:n,onCancel:t,onSave:i,children:l,headerLeft:c,headerRight:u,closeMs:f=220}){const[x,g]=h.useState(!1),[m,y]=h.useState(!1);h.useEffect(()=>{requestAnimationFrame(()=>g(!0))},[]);function _(){g(!1),setTimeout(()=>t?.(),f)}async function v(){if(!(!i||m))try{y(!0),await i()&&_()}catch{}finally{y(!1)}}function j(k){if(!k.nativeEvent.isComposing){if(k.key==="Escape"){k.preventDefault(),_();return}k.key==="Enter"&&(!k.metaKey&&!k.ctrlKey||(k.preventDefault(),v()))}}return a.jsxs("div",{className:`pop-shell__overlay ${x?"pop-shell__overlay--open":""}`,children:[a.jsx("div",{className:"pop-shell__space",onClick:_}),a.jsxs("div",{className:`pop-shell__main-panel ${x?"pop-shell__main-panel--open":""}`,onKeyDown:j,children:[a.jsxs("div",{className:"pop-shell__main-title",children:[c??a.jsx("div",{onClick:_,children:a.jsx(b,{size:"4",weight:"normal",className:"pop-shell__main-title-button",children:"cancel"})}),a.jsx(b,{size:"4",weight:"medium",children:n}),u??a.jsx("div",{onClick:v,style:{opacity:m?.6:1,pointerEvents:m?"none":"auto"},children:a.jsx(b,{size:"4",weight:"normal",className:"pop-shell__main-title-button",children:m?"saving":"save"})})]}),a.jsx("div",{className:"pop-shell__main-content",children:l})]})]})}function By(n,t){try{const i=localStorage.getItem(n);if(i)return JSON.parse(i)}catch(i){console.error("Error loading draft from localStorage:",i)}return t}function Hr({key:n,defaultValue:t,debounceMs:i=500}){const l=h.useRef(t);h.useEffect(()=>{l.current=t},[t]);const[c,u]=h.useState(()=>By(n,t)),f=h.useRef(void 0);return h.useEffect(()=>{u(By(n,l.current))},[n]),h.useEffect(()=>(f.current&&clearTimeout(f.current),f.current=setTimeout(()=>{try{localStorage.setItem(n,JSON.stringify(c))}catch(g){console.error("Error saving draft to localStorage:",g)}},i),()=>{f.current&&clearTimeout(f.current)}),[c,n,i]),[c,u,()=>{try{localStorage.removeItem(n),u(l.current)}catch(g){console.error("Error clearing draft from localStorage:",g)}}]}const k1={title:"",description:""},Uy=n=>{n&&(n.style.height="auto",n.style.height=`${n.scrollHeight}px`)};function eh({onCancel:n,onSave:t}){const[i,l,c]=Hr({key:"new-task-draft",defaultValue:k1}),{title:u,description:f}=i,x=h.useRef(null),g=h.useRef(null),m=(v,j)=>{l({...i,[v]:j})};h.useEffect(()=>{x.current?.focus()},[]),h.useEffect(()=>{Uy(g.current)},[f]);function y(v){m("description",v.target.value),Uy(v.target)}async function _(){const v=await t({title:u,description:f});return v&&c(),v}return a.jsx(gt,{title:"Create a Task",onCancel:n,onSave:_,children:a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"new-task-pop__input-title",children:a.jsx("input",{className:"new-task-pop__input-title",ref:x,placeholder:"Title",value:u,onChange:v=>m("title",v.target.value),onKeyDown:v=>{v.key==="Enter"&&(v.preventDefault(),g.current?.focus())}})}),a.jsx("div",{className:"new-task-pop__input-description",children:a.jsx("textarea",{className:"new-task-pop__input-description",ref:g,placeholder:"Enter a description (optional)",value:f,onChange:y})})]})})}const Lt=n=>{const t=new Date(n),l=Math.round((new Date().getTime()-t.getTime())/(1e3*60));if(l<60)return`${Math.max(l,1)}m ago`;const c=Math.round(l/60);return c<24?`${c}h ago`:t.toLocaleDateString("en-US",{month:"short",day:"numeric"})};function Ki({task:n,animation:t,onClick:i,pulseKey:l,additionalTags:c}){const[u,f]=h.useState(!1),x=n.assigneeActor??n.createdByActor;h.useEffect(()=>{if(l==null)return;f(!0);const y=setTimeout(()=>f(!1),1e3);return()=>clearTimeout(y)},[l]);const g=n.tags.map(y=>({label:y.name}));n.comments.length&&g.push({label:`💬 ${n.comments.length}`}),n.artefacts.length&&g.push({label:`🔗 ${n.artefacts.length}`});const m=n.inputRequests.filter(y=>!y.resolvedAt).length;return m&&g.push({label:`✋ ${m}`}),c&&g.push(...c),a.jsxs(be,{leading:a.jsx(He,{name:x.displayName,size:"lg",src:x.avatarUrl||void 0}),topRight:Lt(n.updatedAt),tags:g,animation:t,highlight:n.inputRequests.filter(y=>!y.resolvedAt)?.length>0,onClick:i,children:[a.jsxs(b,{className:"pre",children:["#",n.id.slice(0,6)]}),a.jsx("div",{style:{minWidth:0,overflow:"hidden"},children:a.jsx(b,{weight:"bold",size:"3",tone:"default",children:a.jsxs("span",{className:"task-row__title",children:[a.jsx("span",{className:"task-row__titleText",children:n.name}),u?a.jsx("span",{className:"task-row__pulseDot","aria-hidden":!0}):null]})})}),a.jsx("div",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:n.description}),a.jsxs("div",{style:{fontSize:12},className:"text--tone-muted",children:[n.assignee?`Assigned: @${n.assignee}`:"unassigned"," · ",`Created by @${n.createdByActor.slug}`]})]})}function _v(n){const t=new Map,i=new Date;i.setHours(0,0,0,0);for(const l of n){const c=new Date(l.updatedAt);c.setHours(0,0,0,0);const u=c.toISOString().split("T")[0],f=c.getTime()===i.getTime();t.has(u)||t.set(u,{date:c,dateKey:u,tasks:[],isToday:f}),t.get(u).tasks.push(l)}return Array.from(t.values()).sort((l,c)=>c.date.getTime()-l.date.getTime())}function Sv(n){const t=new Date;t.setHours(0,0,0,0);const i=new Date(t);i.setDate(i.getDate()-1);const l=new Date(n);if(l.setHours(0,0,0,0),l.getTime()===t.getTime())return"Today";if(l.getTime()===i.getTime())return"Yesterday";const c=t.getFullYear(),u=l.getFullYear(),x=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][l.getMonth()],g=l.getDate();return u===c?`${x} ${g}`:`${x} ${g}, ${u}`}function T1({date:n,taskCount:t,isExpanded:i,onClick:l}){const c=Sv(n),u=i?"▼":"▶";return a.jsx(be,{onClick:l,className:"day-summary-row",children:a.jsxs("div",{className:"day-summary-row__content",children:[a.jsx("span",{className:"day-summary-row__chevron",children:u}),a.jsx(b,{weight:"bold",size:"3",children:c}),a.jsxs(b,{size:"2",tone:"muted",className:"day-summary-row__count",children:["· ",t," ",t===1?"task":"tasks"," shipped"]})]})})}function w1({tasks:n,enteringIds:t,exitingTasks:i,groupByDay:l=!1}){const c=ze(),{activityByTaskId:u}=qn(),[f,x]=h.useState(new Set),g=new Set(i.map(v=>v.id)),m=[...n,...i].sort((v,j)=>new Date(j.updatedAt).getTime()-new Date(v.updatedAt).getTime());if(!l)return a.jsx(ye,{children:m.map(v=>{const j=g.has(v.id),k=t.has(v.id);let E;j?E="exiting":k&&(E="entering");const w=u[v.id];return a.jsx(Ki,{task:v,animation:E,pulseKey:w?.ts,onClick:()=>c(`/tasks/task/${v.id}`)},j?`exiting-${v.id}`:v.id)})});const y=_v(m),_=v=>{x(j=>{const k=new Set(j);return k.has(v)?k.delete(v):k.add(v),k})};return a.jsx(ye,{children:y.map(v=>{if(v.isToday)return v.tasks.map(k=>{const E=g.has(k.id),w=t.has(k.id);let T;E?T="exiting":w&&(T="entering");const R=u[k.id];return a.jsx(Ki,{task:k,animation:T,pulseKey:R?.ts,onClick:()=>c(`/tasks/task/${k.id}`)},E?`exiting-${k.id}`:k.id)});const j=f.has(v.dateKey);return a.jsxs("div",{children:[a.jsx(T1,{date:v.date,taskCount:v.tasks.length,isExpanded:j,onClick:()=>_(v.dateKey)}),j&&v.tasks.map(k=>{const E=g.has(k.id),w=t.has(k.id);let T;E?T="exiting":w&&(T="entering");const R=u[k.id];return a.jsx(Ki,{task:k,animation:T,pulseKey:R?.ts,onClick:()=>c(`/tasks/task/${k.id}`)},E?`exiting-${k.id}`:k.id)})]},v.dateKey)})})}function Po({task:n,animation:t,onClick:i,pulseKey:l}){const c=n.assigneeActor??n.createdByActor,u=n.tags.map(x=>({label:x.name}));n.comments.length&&u.push({label:`💬 ${n.comments.length}`});const f=n.inputRequests.filter(x=>!x.resolvedAt).length;return f&&u.push({label:`✋ ${f}`}),n.artefacts.length&&u.push({label:`🔗 ${n.artefacts.length}`}),a.jsxs(Gx,{leading:a.jsx(He,{name:c.displayName,size:"md",src:c.avatarUrl||void 0}),topRight:Lt(n.updatedAt),tags:u,animation:t,onClick:i,pulseKey:l,highlight:n.inputRequests.filter(x=>!x.resolvedAt)?.length>0,footer:a.jsxs(a.Fragment,{children:[a.jsxs("span",{className:"row-detail truncate",children:["#",n.id.slice(0,6)]}),a.jsx("span",{className:"row-detail truncate",children:n.assigneeActor?`Assigned: @${n.assigneeActor.slug}`:"unassigned"})]}),children:[a.jsx("div",{className:"row-title truncate",children:n.name}),a.jsx("div",{className:"row-subtitle truncate",children:n.description})]})}function E1({date:n,taskCount:t,isExpanded:i,onClick:l}){const c=Sv(n),u=i?"▼":"▶";return a.jsxs("div",{className:"day-summary-card__content",onClick:l,children:[a.jsx("span",{className:"day-summary-card__chevron",children:u}),a.jsxs("span",{className:"day-summary-card__text",children:[a.jsx("strong",{children:c})," · ",t," ",t===1?"task":"tasks"]})]})}function C1({tasks:n,enteringIds:t,exitingTasks:i,groupByDay:l=!1}){const c=ze(),{activityByTaskId:u}=qn(),[f,x]=h.useState(new Set),g=new Set(i.map(j=>j.id)),m=[...n,...i].sort((j,k)=>new Date(k.updatedAt).getTime()-new Date(j.updatedAt).getTime());if(!l)return a.jsx(a.Fragment,{children:m.map(j=>{const k=g.has(j.id),E=t.has(j.id),w=u[j.id];let T;return k?T="exiting":E&&(T="entering"),a.jsx(Po,{task:j,animation:T,onClick:()=>c(`/tasks/task/${j.id}`),pulseKey:w?.ts},k?`exiting-${j.id}`:j.id)})});const y=[],_=_v(m),v=j=>{x(k=>{const E=new Set(k);return E.has(j)?E.delete(j):E.add(j),E})};return _.forEach(j=>{if(j.isToday){j.tasks.forEach(E=>{const w=g.has(E.id),T=t.has(E.id),R=u[E.id];let z;w?z="exiting":T&&(z="entering");const L=a.jsx(Po,{task:E,animation:z,onClick:()=>c(`/tasks/task/${E.id}`),pulseKey:R?.ts},w?`exiting-${E.id}`:E.id);y.push(L)});return}const k=f.has(j.dateKey);y.push(a.jsx(E1,{date:j.date,taskCount:j.tasks.length,isExpanded:k,onClick:()=>v(j.dateKey)},`date-group-${j.date}`)),k&&j.tasks.forEach(E=>{const w=g.has(E.id),T=t.has(E.id),R=u[E.id];let z;w?z="exiting":T&&(z="entering");const L=a.jsx(Po,{task:E,animation:z,onClick:()=>c(`/tasks/task/${E.id}`),pulseKey:R?.ts},w?`exiting-${E.id}`:E.id);y.push(L)})}),a.jsx(a.Fragment,{children:y})}function Ao({status:n}){const t=Rt(),i=t?void 0:n,{tasks:l,createTask:c,setSectionTitle:u,animationByStatus:f,globalEnteringIds:x,globalExitingTasks:g,activityByTaskId:m}=qn(),{showError:y}=ds(),{registerCommands:_,registerTaskSearch:v}=rl(),j=ze();jt(),h.useEffect(()=>{if(!i){u("All Tasks");return}u(Zs[i].label)},[i,u]),h.useEffect(()=>_([{id:"new-task",label:"New Task",description:"Create a new task",aliases:["create","add task"],onSelect:()=>M(!0)}]),[_]),h.useEffect(()=>v(I=>Qt.TasksController_searchTasks({query:I,limit:5,threshold:.1})),[v]);const k=h.useMemo(()=>i?l.filter(I=>I.status===i):l,[l,i]),E=h.useMemo(()=>i?{enteringIds:f[i].enteringIds,exitingTasks:f[i].exitingTasks}:{enteringIds:x,exitingTasks:g},[i,f,x,g]),[w,T]=mh(),[R,z]=h.useState(null),[L,M]=h.useState(!1);h.useEffect(()=>{w.get("new")==="1"&&(M(!0),T({},{replace:!0}))},[w,T]);const N=()=>{console.log("cancel"),M(!1)},A=async({title:I,description:Q})=>{console.log(`save title: ${I} - description: ${Q}`),z({name:I,description:Q});try{const Z=await c({name:I,description:Q});return Z?(z(Z),j(`/tasks/task/${Z.id}`),!0):!1}catch(Z){return console.error("Error saving task"),console.error(Z),y(Z),!1}};return a.jsx("div",{className:`${t?"full-height":""}`,children:t?a.jsxs("div",{className:"tasks-page",children:[a.jsx(N1,{tasks:l,animationByStatus:f}),a.jsxs("button",{className:"tasks-fab tasks-fab--desktop",type:"button",onClick:()=>M(!0),children:[a.jsx("span",{className:"tasks-fab__plus",children:"+"}),a.jsx("span",{className:"tasks-fab__label",children:"New task"})]}),L?a.jsx(eh,{onCancel:N,onSave:A}):null]}):a.jsxs(a.Fragment,{children:[a.jsx(w1,{tasks:k,enteringIds:E.enteringIds,exitingTasks:E.exitingTasks,groupByDay:i===_e.DONE}),a.jsx("button",{className:"tasks-fab",type:"button",onClick:()=>M(!0),"aria-label":"Create new task",children:"+"}),L?a.jsx(eh,{onCancel:N,onSave:A}):null]})})}function Ro({tasks:n,status:t,animationState:i}){const l=h.useMemo(()=>n.filter(u=>u.status===t),[n,t]),c=Zs[t].label;return a.jsxs("div",{className:"tasks-board-column",children:[a.jsxs("div",{className:"tasks-board-column__header",children:[a.jsx(b,{size:"3",weight:"bold",children:c}),a.jsx(b,{size:"1",tone:"muted",children:l.length})]}),a.jsx("div",{className:"tasks-board-column__body",children:a.jsx(C1,{tasks:l,enteringIds:i.enteringIds,exitingTasks:i.exitingTasks,groupByDay:t===_e.DONE})})]})}function N1({tasks:n,animationByStatus:t}){return a.jsxs("div",{className:"tasks-board-view",children:[a.jsx(Ro,{status:_e.NOT_STARTED,tasks:n,animationState:t[_e.NOT_STARTED]}),a.jsx(Ro,{status:_e.IN_PROGRESS,tasks:n,animationState:t[_e.IN_PROGRESS]}),a.jsx(Ro,{status:_e.FOR_REVIEW,tasks:n,animationState:t[_e.FOR_REVIEW]}),a.jsx(Ro,{status:_e.DONE,tasks:n,animationState:t[_e.DONE]})]})}const A1=2200;function R1({trigger:n,durationMs:t=A1}){const[i,l]=h.useState(!1);return h.useEffect(()=>{if(n<=0)return;l(!0);const c=window.setTimeout(()=>l(!1),t);return()=>window.clearTimeout(c)},[n,t]),i?a.jsxs("div",{className:"shipped-celebration",style:{"--celebration-duration":`${t}ms`},"aria-hidden":"true",children:[a.jsx("div",{className:"shipped-celebration__veil"}),a.jsx("div",{className:"shipped-celebration__rocket",role:"presentation",children:"🚀"}),a.jsx("div",{className:"shipped-celebration__spark shipped-celebration__spark--one"}),a.jsx("div",{className:"shipped-celebration__spark shipped-celebration__spark--two"}),a.jsx("div",{className:"shipped-celebration__spark shipped-celebration__spark--three"})]}):null}const z1=window.location.origin,jv=new Ws({baseUrl:z1,credentials:"include"}),Ui=jv.taskBlueprints,Cr=jv.scheduledTasks;function D1(){const n=Rt(),{sectionTitle:t,shippedCelebrationTrigger:i,projects:l,projectsLoaded:c,selectedProjectId:u,setSelectedProjectId:f}=qn(),x=ze(),g=qt(),[m,y]=h.useState(null),_=g.pathname==="/tasks/dependencies"||g.pathname.startsWith("/tasks/dependencies/"),v=["/tasks/not-started","/tasks/in-progress","/tasks/in-review","/tasks/done"].includes(g.pathname),j=v||_,k=v||_,E=a.jsx(L1,{isBoardView:v,isDependencyView:_,onBoardClick:()=>x("/tasks/not-started"),onDependenciesClick:()=>x("/tasks/dependencies")}),w=a.jsx(O1,{projects:l,projectsLoaded:c,selectedProjectId:u,onChange:f});return h.useEffect(()=>{let T=!0;return(async()=>{try{const z=await Cr.ScheduledTasksController_listScheduledTasks({page:1,limit:50});if(!T)return;const L=z.items.filter(M=>M.enabled).length;y(L)}catch{T&&y(null)}})(),()=>{T=!1}},[]),a.jsxs("div",{style:{minHeight:0},children:[a.jsx(R1,{trigger:i}),n?a.jsx(Br,{sectionTitle:t,titleAccessory:k?w:void 0,headerActions:a.jsxs("div",{className:"tasks-layout__header-actions",children:[j?E:null,a.jsxs(ue,{size:"sm",variant:"ghost",className:"tasks-layout__header-button",onClick:()=>x("/tasks/schedule"),children:[a.jsx(Fx,{className:"tasks-layout__header-icon",size:16,strokeWidth:1.5,absoluteStrokeWidth:!0}),"Schedule",m&&m>0?a.jsx("span",{className:"tasks-layout__schedule-badge",children:m}):null]})]}),children:a.jsx(Kt,{})}):a.jsx($a,{appTitle:"Tasks",sectionTitle:t,navItems:v1,topActions:k||j?a.jsxs("div",{className:"tasks-layout__mobile-top-actions",children:[k?w:null,j?a.jsx("div",{className:"tasks-layout__mobile-view-toggle",children:E}):null]}):void 0,children:a.jsx(Kt,{})})]})}function O1({projects:n,projectsLoaded:t,selectedProjectId:i,onChange:l}){const[c,u]=h.useState(!1),[f,x]=h.useState(""),g=h.useRef(null),m=h.useRef(null),y=n.find(k=>k.id===i)??null,_=f.trim().toLowerCase(),v=h.useMemo(()=>_?n.filter(k=>k.slug.toLowerCase().includes(_)||k.tagName.toLowerCase().includes(_)):n,[_,n]);h.useEffect(()=>{if(!c)return;const k=w=>{g.current?.contains(w.target)||u(!1)},E=w=>{w.key==="Escape"&&u(!1)};return document.addEventListener("pointerdown",k),document.addEventListener("keydown",E),window.setTimeout(()=>m.current?.focus(),0),()=>{document.removeEventListener("pointerdown",k),document.removeEventListener("keydown",E)}},[c]);const j=k=>{l(k),x(""),u(!1)};return a.jsxs("div",{className:"tasks-layout__project-selector",ref:g,children:[a.jsxs("button",{className:"tasks-layout__project-trigger",type:"button","aria-haspopup":"listbox","aria-expanded":c,"aria-label":"Task project",disabled:!t,onClick:()=>u(k=>!k),children:[a.jsx(Yd,{className:"tasks-layout__project-selector-icon",size:15,strokeWidth:1.75,absoluteStrokeWidth:!0}),a.jsx("span",{className:"tasks-layout__project-trigger-label",children:y?.slug??"All projects"}),a.jsx(sT,{className:`tasks-layout__project-selector-chevron${c?" tasks-layout__project-selector-chevron--open":""}`,size:14,strokeWidth:1.75,absoluteStrokeWidth:!0})]}),c?a.jsxs("div",{className:"tasks-layout__project-menu",children:[a.jsx("input",{ref:m,className:"tasks-layout__project-search",type:"search",value:f,onChange:k=>x(k.target.value),placeholder:"Search projects","aria-label":"Search projects"}),a.jsxs("div",{className:"tasks-layout__project-options",role:"listbox","aria-label":"Task project",children:[a.jsx("button",{className:`tasks-layout__project-option${i===null?" tasks-layout__project-option--selected":""}`,type:"button",role:"option","aria-selected":i===null,onClick:()=>j(null),children:"All projects"}),v.length===0?a.jsx("div",{className:"tasks-layout__project-empty",children:"No matching projects"}):v.map(k=>a.jsxs("button",{className:`tasks-layout__project-option${i===k.id?" tasks-layout__project-option--selected":""}`,type:"button",role:"option","aria-selected":i===k.id,onClick:()=>j(k.id),children:[a.jsx("span",{className:"tasks-layout__project-option-name",children:k.slug}),a.jsx("span",{className:"tasks-layout__project-option-tag",children:k.tagName})]},k.id))]})]}):null]})}function L1({isBoardView:n,isDependencyView:t,onBoardClick:i,onDependenciesClick:l}){return a.jsxs("div",{className:"tasks-layout__view-toggle",role:"group","aria-label":"Task view",children:[a.jsxs("button",{className:`tasks-layout__view-toggle-button${n?" tasks-layout__view-toggle-button--active":""}`,type:"button","aria-pressed":n,onClick:i,children:[a.jsx(Xx,{className:"tasks-layout__header-icon",size:16,strokeWidth:1.5,absoluteStrokeWidth:!0}),"Board"]}),a.jsxs("button",{className:`tasks-layout__view-toggle-button${t?" tasks-layout__view-toggle-button--active":""}`,type:"button","aria-pressed":t,onClick:l,children:[a.jsx(Kx,{className:"tasks-layout__header-icon",size:16,strokeWidth:1.5,absoluteStrokeWidth:!0}),"Dependencies"]})]})}const M1={content:""},$y=n=>{n&&(n.style.height="auto",n.style.height=`${n.scrollHeight}px`)};function q1({onCancel:n,onSave:t,taskId:i}){const[l,c,u]=Hr({key:`new-comment-draft-${i}`,defaultValue:M1}),{content:f}=l,x=h.useRef(null);h.useEffect(()=>{x.current?.focus()},[]),h.useEffect(()=>{$y(x.current)},[f]);function g(y){c({...l,content:y.target.value}),$y(y.target)}async function m(){const y=await t({content:f});return y&&u(),y}return a.jsx(gt,{title:"Add Comment",onCancel:n,onSave:m,children:a.jsx(a.Fragment,{children:a.jsx("div",{className:"new-comment-pop__input-content",children:a.jsx("textarea",{className:"new-comment-pop__input-content",ref:x,placeholder:"Leave a comment...",value:f,onChange:g})})})})}const I1={answer:""},Dd=n=>{n&&(n.style.height="auto",n.style.height=`${n.scrollHeight}px`)};function B1({onCancel:n,onSave:t,taskId:i,inputRequestId:l,question:c}){const[u,f,x]=Hr({key:`answer-input-request-draft-${l}`,defaultValue:I1}),{answer:g}=u,m=h.useRef(null),y=h.useRef(null);h.useEffect(()=>{y.current?.focus()},[]),h.useEffect(()=>{Dd(m.current)},[c]),h.useEffect(()=>{Dd(y.current)},[g]);function _(j){f({...u,answer:j.target.value}),Dd(j.target)}async function v(){const j=await t({answer:g});return j&&x(),j}return a.jsx(gt,{title:"Answer Input Request",onCancel:n,onSave:v,children:a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"new-comment-pop__input-content",children:a.jsx("textarea",{className:"new-comment-pop__input-content",ref:m,value:c,readOnly:!0,style:{opacity:.7,cursor:"default"}})}),a.jsx("div",{className:"new-comment-pop__input-content",children:a.jsx("textarea",{className:"new-comment-pop__input-content",ref:y,placeholder:"Your answer...",value:g,onChange:_})})]})})}function U1({onCancel:n,onSave:t,existingTags:i}){const[l,c]=h.useState([]),[u,f]=h.useState(!0),[x,g]=h.useState(""),[m,y]=h.useState(0),[_,v]=h.useState(!1),j=h.useRef(null),k=h.useRef(null);h.useEffect(()=>{(async()=>{try{const M=await $x.metaControllerGetAllTags();c(M)}catch(M){console.error("Failed to load tags:",M)}finally{f(!1)}})()},[]),h.useEffect(()=>{j.current?.focus()},[]);const E=h.useMemo(()=>{const L=new Set(i.map(I=>I.id)),M=l.filter(I=>!L.has(I.id));if(!x.trim())return M;const N=x.toLowerCase().trim();return M.map(I=>{let Q=0;return I.name.toLowerCase().startsWith(N)?Q+=100:I.name.toLowerCase().includes(N)&&(Q+=50),{tag:I,score:Q}}).filter(I=>I.score>0).sort((I,Q)=>Q.score-I.score).map(I=>I.tag)},[l,i,x]),w=h.useMemo(()=>{if(!x.trim())return!1;const L=x.toLowerCase().trim();return!l.some(M=>M.name.toLowerCase()===L)},[x,l]);h.useEffect(()=>{y(0)},[E.length,x,w]),h.useEffect(()=>{if(k.current){const L=E.length+(w?1:0);if(m<L){const M=k.current.children[m];M&&M.scrollIntoView({block:"nearest"})}}},[m,E.length,w]);const T=h.useCallback(async L=>{if(_)return!1;v(!0);try{const M=await t(L);return M&&n?.(),M}finally{v(!1)}},[_,n,t]),R=h.useCallback(L=>{if(L.nativeEvent.isComposing)return;const M=E.length+(w?1:0);switch(L.key){case"ArrowDown":if(M===0)return;L.preventDefault(),y(N=>N<M-1?N+1:N);break;case"ArrowUp":if(M===0)return;L.preventDefault(),y(N=>N>0?N-1:0);break;case"Enter":L.preventDefault(),m<E.length?T(E[m]):w&&m===E.length&&T(Od(x));break;case"Escape":L.preventDefault(),n?.();break}},[w,E,m,n,x,T]);async function z(){if(E.length+(w?1:0)===0)return!1;if(m<E.length){const M=E[m];return M?T(M):!1}return w&&m===E.length?T(Od(x)):!1}return a.jsx(gt,{title:"Add Tag",onCancel:n,onSave:z,children:a.jsxs("div",{className:"tag-search-pop",children:[a.jsx("input",{ref:j,type:"text",className:"tag-search-pop__input",placeholder:"Search or create tag...",value:x,onChange:L=>g(L.target.value),onKeyDown:R}),a.jsx("div",{className:"tag-search-pop__list",ref:k,role:"listbox","aria-label":"Available tags",children:u?a.jsx("div",{className:"tag-search-pop__empty",children:a.jsx(b,{tone:"muted",children:"Loading tags..."})}):E.length===0&&!w?a.jsx("div",{className:"tag-search-pop__empty",children:a.jsx(b,{tone:"muted",children:"No tags found"})}):a.jsxs(a.Fragment,{children:[E.map((L,M)=>a.jsx("button",{type:"button",role:"option","aria-selected":M===m,className:`tag-search-pop__item ${M===m?"tag-search-pop__item--highlighted":""}`,onClick:()=>void T(L),onMouseEnter:()=>y(M),disabled:_,children:a.jsx("div",{className:"tag-search-pop__tag-badge",style:{backgroundColor:L.color||"#999"},children:L.name})},L.id)),w&&a.jsxs("button",{type:"button",role:"option","aria-selected":m===E.length,className:`tag-search-pop__item tag-search-pop__item--create ${m===E.length?"tag-search-pop__item--highlighted":""}`,onClick:()=>void T(Od(x)),onMouseEnter:()=>y(E.length),disabled:_,children:[a.jsx(b,{size:"2",tone:"muted",children:"Create new tag:"}),a.jsx("div",{className:"tag-search-pop__tag-badge",style:{backgroundColor:"#999"},children:x.trim()})]})]})})]})})}function Od(n){return{id:"",name:n.trim(),color:void 0,createdAt:"",updatedAt:""}}function $1({onCancel:n,onSave:t,excludeTaskIds:i}){const[l,c]=h.useState(""),[u,f]=h.useState(0),[x,g]=h.useState([]),[m,y]=h.useState(!1),[_,v]=h.useState(null),[j,k]=h.useState(!1),E=h.useRef(null),w=h.useRef(null),T=h.useRef(0);h.useEffect(()=>{E.current?.focus()},[]),h.useEffect(()=>{const A=l.trim();if(!A){T.current=T.current+1,g([]),v(null),y(!1);return}const I=T.current+1;T.current=I,y(!0),v(null);const Q=window.setTimeout(async()=>{try{const Z=await Qt.TasksController_searchTasks({query:A,limit:20});if(T.current!==I)return;g(Z??[])}catch(Z){if(T.current!==I)return;v(Z instanceof Error?Z.message:"Failed to search tasks"),g([])}finally{T.current===I&&y(!1)}},200);return()=>{window.clearTimeout(Q)}},[l]);const R=h.useMemo(()=>{const A=new Set(i);return x.filter(I=>!A.has(I.id))},[x,i]);h.useEffect(()=>{f(0)},[R.length,l]),h.useEffect(()=>{if(w.current){const A=w.current.children[u];A&&A.scrollIntoView({block:"nearest"})}},[u]);const z=h.useCallback(async A=>{if(j)return!1;k(!0);try{const I=await Qt.TasksController_getTask({id:A.id}),Q=await t(I);return Q&&n?.(),Q}catch(I){return console.error("Failed to fetch task details:",I),!1}finally{k(!1)}},[j,n,t]),L=h.useCallback(()=>{if(R.length===0)return;const A=R[u];A&&z(A)},[R,u,z]),M=h.useCallback(A=>{if(!A.nativeEvent.isComposing)switch(A.key){case"ArrowDown":if(R.length===0)return;A.preventDefault(),f(I=>I<R.length-1?I+1:I);break;case"ArrowUp":if(R.length===0)return;A.preventDefault(),f(I=>I>0?I-1:0);break;case"Enter":A.preventDefault(),L();break;case"Escape":A.preventDefault(),n?.();break}},[R,L,n]);async function N(){if(R.length===0)return!1;const A=R[u];return A?z(A):!1}return a.jsx(gt,{title:"Add Dependency",onCancel:n,onSave:N,children:a.jsxs("div",{className:"task-search-pop",children:[a.jsx("input",{ref:E,type:"text",className:"task-search-pop__input",placeholder:"Search tasks...",value:l,onChange:A=>c(A.target.value),onKeyDown:M}),a.jsx("div",{className:"task-search-pop__list",ref:w,role:"listbox","aria-label":"Tasks",children:R.length===0?a.jsx("div",{className:"task-search-pop__empty",children:a.jsx(b,{tone:"muted",children:l.trim()?m?"Searching tasks...":_||"No tasks found":"Type to search for tasks"})}):R.map((A,I)=>a.jsx("button",{type:"button",role:"option","aria-selected":I===u,className:`task-search-pop__item ${I===u?"task-search-pop__item--highlighted":""}`,onClick:()=>void z(A),onMouseEnter:()=>f(I),disabled:j,children:a.jsxs("div",{className:"task-search-pop__item-info",children:[a.jsx(b,{weight:"medium",size:"2",children:A.name}),a.jsxs(b,{tone:"muted",size:"1",style:"mono",children:["#",A.id.slice(0,6)]})]})},A.id))})]})})}Me.BASE=Ba;const kv=h.createContext(null);function H1({children:n}){const[t,i]=h.useState([]),[l,c]=h.useState(!1),[u,f]=h.useState(null),x=h.useCallback(async()=>{c(!0),f(null);try{const y=await Ux.actorControllerListActors();i(y||[])}catch(y){f(y instanceof Error?y.message:"Failed to load actors")}finally{c(!1)}},[]);h.useEffect(()=>{x()},[x]);const g=h.useCallback(async()=>{await x()},[x]),m=h.useMemo(()=>({actors:t,isLoading:l,error:u,refreshActors:g}),[t,l,u,g]);return a.jsx(kv.Provider,{value:m,children:n})}function il(){const n=h.useContext(kv);if(!n)throw new Error("useActorsCtx must be used within <ActorsProvider>");return n}function P1({onCancel:n,onSave:t}){const{actors:i,isLoading:l,error:c,refreshActors:u}=il(),[f,x]=h.useState(""),[g,m]=h.useState(0),[y,_]=h.useState(null),[v,j]=h.useState(!1),[k,E]=h.useState(null),[w,T]=h.useState(!1),R=h.useRef(null),z=h.useRef(null),L=h.useRef(0);h.useEffect(()=>{R.current?.focus()},[]),h.useEffect(()=>{u().catch(()=>{})},[u]),h.useEffect(()=>{const Z=f.trim();if(!Z){_(null),E(null),j(!1);return}const U=L.current+1;L.current=U,j(!0),E(null);const le=window.setTimeout(async()=>{try{const W=await Ux.actorControllerSearchActors(Z,20);if(L.current!==U)return;_(W??[])}catch(W){if(L.current!==U)return;E(W instanceof Error?W.message:"Failed to search actors"),_([])}finally{L.current===U&&j(!1)}},200);return()=>{window.clearTimeout(le)}},[f]);const M=h.useMemo(()=>f.trim()?y??[]:i,[i,f,y]);h.useEffect(()=>{m(0)},[M.length,f]),h.useEffect(()=>{if(z.current){const Z=z.current.children[g];Z&&Z.scrollIntoView({block:"nearest"})}},[g]);const N=h.useCallback(async Z=>{if(w)return!1;T(!0);try{const U=await t(Z);return U&&n?.(),U}finally{T(!1)}},[w,n,t]),A=h.useCallback(()=>{if(M.length===0)return;const Z=M[g];Z&&N(Z)},[M,g,N]),I=h.useCallback(Z=>{if(!Z.nativeEvent.isComposing)switch(Z.key){case"ArrowDown":if(M.length===0)return;Z.preventDefault(),m(U=>U<M.length-1?U+1:U);break;case"ArrowUp":if(M.length===0)return;Z.preventDefault(),m(U=>U>0?U-1:0);break;case"Enter":Z.preventDefault(),A();break}},[M,A]);async function Q(){if(M.length===0)return!1;const Z=M[g];return Z?N(Z):!1}return a.jsx(gt,{title:"Assign Task",onCancel:n,onSave:Q,children:a.jsxs("div",{className:"actor-search-pop",children:[a.jsx("input",{ref:R,type:"text",className:"actor-search-pop__input",placeholder:"Search by name or @slug...",value:f,onChange:Z=>x(Z.target.value),onKeyDown:I}),a.jsx("div",{className:"actor-search-pop__list",ref:z,role:"listbox","aria-label":"Assignees",children:M.length===0?a.jsx("div",{className:"actor-search-pop__empty",children:a.jsx(b,{tone:"muted",children:f.trim()?v?"Searching actors...":k||"No actors found":l?"Loading actors...":c||"No actors found"})}):M.map((Z,U)=>a.jsxs("button",{type:"button",role:"option","aria-selected":U===g,className:`actor-search-pop__item ${U===g?"actor-search-pop__item--highlighted":""}`,onClick:()=>void N(Z),onMouseEnter:()=>m(U),disabled:w,children:[a.jsx(He,{name:Z.displayName,size:"sm",src:Z.avatarUrl||void 0}),a.jsxs("div",{className:"actor-search-pop__item-info",children:[a.jsx(b,{weight:"medium",size:"2",children:Z.displayName}),a.jsxs(b,{tone:"muted",size:"1",children:["@",Z.slug," · ",Z.type]})]})]},Z.id))})]})})}const G1=window.location.origin,V1=new Ws({baseUrl:G1,credentials:"include"}),Is=V1.threads,F1=window.location.origin,Y1=new Ws({baseUrl:F1,credentials:"include"}),Ma=Y1.executions,Q1=n=>n.some(l=>l.isActive&&l.isConfigured)?{isReady:!0,title:"Thread chat is ready",description:"Your conversation tools are online.",ctaLabel:"Open chat settings"}:n.length===0?{isReady:!1,title:"Thread chat is waiting at the gate",description:"Connect your first chat provider in settings to unlock new threads and live conversation.",ctaLabel:"Set up chat"}:n.some(l=>l.isConfigured)?{isReady:!1,title:"Your next level is one switch away",description:"A provider is configured, but none is active yet. Pick one in chat settings to open the thread portal.",ctaLabel:"Choose active provider"}:{isReady:!1,title:"Thread chat needs one more step",description:"A provider exists, but it still needs credentials before threads can talk back.",ctaLabel:"Finish chat setup"};function sc(){const[n,t]=h.useState(null),[i,l]=h.useState(!0),c=h.useCallback(async()=>{l(!0);try{const u=await Ar.chatProvidersControllerListChatProviders();t(Q1(u))}catch{t(null)}finally{l(!1)}},[]);return h.useEffect(()=>{c()},[c]),{readiness:n,isLoading:i,isReady:n?.isReady??!0,refresh:c}}function nc({title:n,description:t,ctaLabel:i,onOpenSettings:l,className:c}){return a.jsxs("div",{className:`chat-setup-callout ${c??""}`.trim(),children:[a.jsx("div",{className:"chat-setup-callout__badge",children:"Thread Chat"}),a.jsxs(te,{spacing:"3",children:[a.jsxs(te,{spacing:"1",children:[a.jsx(b,{size:"4",weight:"semibold",children:n}),a.jsx(b,{tone:"muted",children:t}),a.jsx(b,{size:"1",tone:"muted",children:"Visit `/settings/chat` to wire it up."})]}),a.jsx("div",{className:"chat-setup-callout__actions",children:a.jsx(ue,{variant:"primary",onClick:l,children:i})})]})]})}function th(n){return n===_e.DONE?{label:"done",color:"purple"}:n===_e.IN_PROGRESS?{label:"in progress",color:"green"}:n===_e.NOT_STARTED?{label:"not started",color:"blue"}:n===_e.FOR_REVIEW?{label:"in review",color:"orange"}:{label:"unknown",color:"gray"}}const Ld=3,Md=3;function Tv({task:n,backPath:t,setSectionTitle:i,isLoadingTask:l=!1,activityByTaskId:c={},handlers:u,allTasks:f}){const x=ze(),{actors:g}=il(),{user:m}=us(),{showError:y,showToast:_}=ds(),{registerCommands:v}=rl(),{readiness:j,isReady:k,isLoading:E}=sc(),[w,T]=h.useState(null),[R,z]=h.useState("idle"),[L,M]=h.useState(!1),[N,A]=h.useState(!1),I=h.useRef(null),Q=h.useRef(null),Z=3500,U=220;jt({task:{name:n?.name}});const le=h.useCallback(async re=>{if(n)try{await u.changeStatus({taskId:n.id,status:re})}catch(ve){y(ve)}},[n,u,y]),[W,oe]=h.useState(null),[me,B]=h.useState(!1),se=h.useCallback(async()=>{if(n){if(!k){_("Thread chat unlocks in Chat Settings.","info"),x("/settings/chat");return}B(!0);try{if(W){x(`/threads/${W}`);return}const re=await Is.ThreadsController_createThread({body:{title:n.name,parentTaskId:n.id}});oe(re.id),x(`/threads/${re.id}`)}catch(re){y(re)}finally{B(!1)}}},[n,W,k,x,y,_]);h.useEffect(()=>{if(!n){oe(null);return}let re=!1;return B(!0),Is.ThreadsController_getThreadByTaskId({taskId:n.id}).then(ve=>{re||oe(ve?.id??null)}).catch(ve=>{re||(y(ve),oe(null))}).finally(()=>{re||B(!1)}),()=>{re=!0}},[n,y]);const ge=h.useMemo(()=>!n||!n.dependsOnIds||n.dependsOnIds.length===0?[]:n.dependsOnIds.map(re=>f.find(ve=>ve.id===re)).filter(re=>re!==void 0),[n,f]);h.useEffect(()=>{if(!n)return;const re={[_e.NOT_STARTED]:["not started","to do","todo","queued"],[_e.IN_PROGRESS]:["in progress","doing","building"],[_e.FOR_REVIEW]:["for review","review","in review"],[_e.DONE]:["done","shipped","release","complete"]},ve=Object.entries(Zs).map(([ct,bt])=>({id:`task-status-${ct}`,label:bt.label,description:`Mark task as ${bt.label.toLowerCase()}`,aliases:re[ct],onSelect:()=>le(ct)})),Je=[{id:"task-add-comment",label:"Comment",description:"Add a comment to this task",aliases:["add comment","note"],onSelect:()=>ce(!0)},{id:"task-assign",label:"Assign",description:"Assign this task to someone",aliases:["reassign","assignee"],onSelect:()=>fe(!0)},{id:"task-assign-to-me",label:"Assign to Me",description:"Assign this task to yourself",aliases:["claim","take"],onSelect:()=>{u.assignTaskToMe({taskId:n.id}).catch(y)}},{id:"task-add-tag",label:"Tag",description:"Add a tag to this task",aliases:["add tag","label"],onSelect:()=>je(!0)},{id:"task-thread-action",label:W?"Go to thread":"Create thread",description:W?"Open this task thread":"Create a thread from this task",aliases:["thread","open thread","create thread","chat"],onSelect:()=>{se()}}];return v([...ve,...Je])},[n,v,le,u,y,W,se]),h.useEffect(()=>{if(l){i("Loading task...");return}if(!n){i("Task");return}i(n.name)},[n,l,i]),h.useEffect(()=>()=>{I.current&&window.clearTimeout(I.current),Q.current&&window.clearTimeout(Q.current)},[]);const[Ee,Ce]=h.useState(null),[D,H]=h.useState(!1),[he,pe]=h.useState([]),[G,ae]=h.useState(!1),[J,xe]=h.useState(null),[Re,Qe]=h.useState(new Set),[It,nt]=h.useState(new Set),[mt,ce]=h.useState(!1),[Y,fe]=h.useState(!1),[K,je]=h.useState(!1),[et,yt]=h.useState(!1),[xt,ks]=h.useState(null),ss=h.useCallback(re=>{Qe(ve=>{const Je=new Set(ve);return Je.has(re)?Je.delete(re):Je.add(re),Je})},[]),vt=h.useCallback(async(re,ve,Je)=>{if(confirm(`Are you sure you want to interrupt the active execution for "${ve??"this task"}"?`)){nt(ct=>new Set(ct).add(re));try{await Ma.ActiveTaskExecutionController_interruptExecution({executionId:re}),_(`Interrupt signal sent for "${ve??"this task"}"`)}catch(ct){y(ct)}finally{nt(ct=>{const bt=new Set(ct);return bt.delete(re),bt})}}},[_,y]);h.useEffect(()=>{const re=ve=>{if(!n||ve.defaultPrevented||ve.metaKey||ve.ctrlKey||ve.altKey||mt||Y||K||et||xt||W1(ve.target))return;const Je=ve.key.toLowerCase();Je==="a"?(ve.preventDefault(),fe(!0)):Je==="c"?(ve.preventDefault(),ce(!0)):Je==="t"&&(ve.preventDefault(),je(!0))};return window.addEventListener("keydown",re),()=>window.removeEventListener("keydown",re)},[n,mt,Y,K,et,xt]);const hn=async({content:re})=>{if(!n)return!1;try{return await u.addComment({taskId:n.id,comment:re}),!0}catch(ve){return y(ve),!1}},fn=()=>{ce(!1)},ga=async re=>{if(!n)return!1;try{return await u.assignTask({taskId:n.id,assigneeActorId:re.id}),!0}catch(ve){return y(ve),!1}},In=()=>{fe(!1)},Gr=async({answer:re})=>{if(!n||!xt)return!1;try{return await u.answerInputRequest({taskId:n.id,inputRequestId:xt.id,answer:re}),!0}catch(ve){return y(ve),!1}},Pa=()=>{ks(null)},Vr=async re=>{if(!n)return!1;try{return await u.addTag({taskId:n.id,tag:re}),!0}catch(ve){return y(ve),!1}},Fr=()=>{je(!1)},pn=async re=>{if(n)try{await u.removeTag({taskId:n.id,tagId:re})}catch(ve){y(ve)}},Ht=async re=>{if(!n)return!1;try{return await u.addDependency({taskId:n.id,dependencyTaskId:re.id}),!0}catch(ve){return y(ve),!1}},Ts=()=>{yt(!1)},Pt=async re=>{if(n)try{await u.removeDependency({taskId:n.id,dependencyTaskId:re})}catch(ve){y(ve)}},Hs=n?c[n.id]:null;h.useEffect(()=>{M(!1),A(!1)},[n?.id]);const Bn=h.useCallback(async re=>{ae(!0);try{const[ve,Je]=await Promise.all([Ma.ActiveTaskExecutionController_listActiveExecutions({taskId:re,limit:100}),Ma.TaskExecutionHistoryController_listHistory({taskId:re,limit:100})]),ct=ve.items.map(Ze=>({id:`active-${Ze.id}`,executionId:Ze.id,agentActorId:Ze.agentActorId,status:"ACTIVE",source:"active",timestamp:Ze.claimedAt,runnerSessionId:Ze.runnerSessionId,toolCallCount:Ze.toolCallCount,errorCode:null,errorMessage:null})),bt=Je.items.map(Ze=>({id:`history-${Ze.id}`,executionId:Ze.id,agentActorId:Ze.agentActorId,status:Ze.status,source:"history",timestamp:Ze.transitionedAt,runnerSessionId:Ze.runnerSessionId,toolCallCount:Ze.toolCallCount,errorCode:Ze.errorCode,errorMessage:Ze.errorMessage})),en=[...ct,...bt].sort((Ze,de)=>new Date(de.timestamp).getTime()-new Date(Ze.timestamp).getTime());pe(en),xe(null)}catch(ve){const Je=ve instanceof Error?ve.message:"Failed to load runs for this task";xe(Je)}finally{ae(!1)}},[]),gn=h.useMemo(()=>n?[...n.comments.map(re=>({type:"comment",data:re,timestamp:new Date(re.createdAt).getTime()})),...n.inputRequests.map(re=>({type:"inputRequest",data:re,timestamp:new Date(re.createdAt).getTime()}))].sort((re,ve)=>re.timestamp-ve.timestamp):[],[n]),Un=L?gn:gn.slice(0,Ld),mn=gn.length>Ld,Js=N?he:he.slice(0,Md),Ps=he.length>Md;if(h.useEffect(()=>{if(!n){pe([]),xe(null),Qe(new Set);return}Qe(new Set),Bn(n.id)},[n,Bn]),h.useEffect(()=>{!n||!Hs||Hs.kind.startsWith("execution.")&&Bn(n.id)},[Hs,n,Bn]),h.useEffect(()=>{!n||!Hs||!Hs.message||(I.current&&window.clearTimeout(I.current),Q.current&&window.clearTimeout(Q.current),T(Hs),z("enter"),I.current=window.setTimeout(()=>{z("exit"),Q.current=window.setTimeout(()=>{T(null),z("idle")},U)},Z))},[Hs,n,U,Z]),!n&&l)return a.jsx(X1,{backPath:t});if(!n)return a.jsx("div",{className:"task-detail-page",children:a.jsxs(te,{spacing:"4",align:"center",children:[a.jsx(b,{size:"3",tone:"muted",children:"Task not found"}),a.jsx(ue,{variant:"secondary",onClick:()=>x(t),children:"Back to tasks"})]})});const $n=async re=>{H(!0);try{await u.changeStatus({taskId:n.id,status:re}),Ce(null)}catch(ve){y(ve)}finally{H(!1)}};return a.jsxs("div",{className:"task-detail-page",children:[Ee&&a.jsxs(Zt,{children:[a.jsx("button",{onClick:()=>Ce(null),className:"task-detail-page__error-close",children:"×"}),Ee]}),a.jsxs(ye,{className:"task-detail-page__section",children:[a.jsxs(be,{leading:a.jsx(He,{size:"sm",name:n.createdByActor.displayName,src:n.createdByActor.avatarUrl||void 0}),tags:[th(n.status),...n.tags.map(re=>({label:re.name,onRemove:()=>pn(re.id)})),{label:"+ add tag",color:"gray",onClick:()=>je(!0),clickLabel:"Add tag"}],topRight:a.jsx(b,{size:"1",tone:"muted",children:Lt(n.updatedAt)}),children:[a.jsx(b,{as:"span",weight:"medium",size:"3",children:n.createdByActor.displayName}),a.jsx(b,{as:"span",weight:"normal",tone:"muted",size:"3",children:` @${n.createdByActor.slug} created `}),a.jsxs(b,{as:"span",tone:"muted",style:"mono",children:["#",n.id.slice(0,6)]}),n.assigneeActor?null:a.jsx(b,{tone:"muted",children:"unassigned"})]}),n.assigneeActor?a.jsxs(be,{leading:a.jsx(He,{size:"sm",name:n.assigneeActor.displayName,src:n.assigneeActor.avatarUrl||void 0}),onClick:()=>fe(!0),children:[a.jsx(b,{as:"span",weight:"medium",size:"3",children:n.assigneeActor.displayName}),a.jsx(b,{as:"span",weight:"normal",tone:"muted",size:"3",children:` @${n.assigneeActor.slug} assigned`}),a.jsx(b,{size:"1",tone:"muted",children:"tap to reassign"})]}):null]}),n.artefacts&&n.artefacts.length>0&&a.jsx(ye,{className:"task-detail-page__section",children:n.artefacts.map(re=>a.jsxs(be,{children:[a.jsx(b,{as:"span",weight:"medium",size:"3",children:`${re.name}: `}),a.jsx(b,{as:"span",children:a.jsx("a",{href:re.link,target:"_blank",rel:"noopener noreferrer",style:{color:"var(--accent)",textDecoration:"underline"},children:re.link})})]},re.id))}),(ge.length>0||n)&&a.jsxs(ye,{title:"Depends on",className:"task-detail-page__section",action:ge.length>0?a.jsxs(ue,{size:"sm",variant:"ghost",className:"task-detail-page__dependency-graph-button",onClick:()=>x(`/tasks/dependencies/${n.id}`),children:[a.jsx(Kx,{className:"task-detail-page__dependency-graph-icon",size:14,strokeWidth:1.5,absoluteStrokeWidth:!0}),"View graph"]}):void 0,children:[ge.map(re=>a.jsx(Ki,{task:re,onClick:()=>x(`/tasks/task/${re.id}`),additionalTags:[{label:"× remove",color:"red",onClick:()=>Pt(re.id),clickLabel:"Remove dependency"}]},re.id)),a.jsx(be,{tags:[{label:"+ add dependency",color:"gray",onClick:()=>yt(!0),clickLabel:"Add dependency"}],children:a.jsx(b,{tone:"muted",size:"2",children:ge.length===0?"No dependencies yet":"Add another dependency"})})]}),a.jsx(ye,{className:"task-detail-page__section",children:a.jsxs(be,{leading:a.jsx(He,{size:"sm",name:n.createdByActor.displayName,src:n.createdByActor.avatarUrl||void 0}),tags:[],topRight:a.jsx(b,{size:"1",tone:"muted",children:Lt(n.createdAt)}),children:[a.jsx(b,{as:"span",weight:"medium",size:"3",children:n.createdByActor.displayName}),a.jsx(b,{as:"span",weight:"normal",tone:"muted",size:"3",children:` @${n.createdByActor.slug}`}),a.jsx(b,{children:n.description?n.description:"no description"})]})}),a.jsxs(ye,{title:"Updates",className:"task-detail-page__section",children:[gn.length===0?a.jsx(b,{className:"task-detail-page__executions-state",tone:"muted",children:"No updates yet."}):null,Un.map(re=>{if(re.type==="comment"){const hs=re.data,Gs=hs.commenterActor?.displayName||"unknown",zt=hs.commenterActor?.slug||"unknown";return a.jsxs(be,{leading:a.jsx(He,{size:"sm",name:Gs,src:hs.commenterActor?.avatarUrl||void 0}),topRight:a.jsx(b,{size:"1",tone:"muted",children:Lt(hs.createdAt)}),children:[a.jsx(b,{as:"span",weight:"medium",size:"3",children:Gs}),a.jsx(b,{as:"span",weight:"normal",tone:"muted",size:"3",children:` @${zt}`}),a.jsx(b,{children:hs.content})]},`comment-${hs.id}`)}const ve=re.data,Je=g.find(hs=>hs.id===ve.askedByActorId),ct=g.find(hs=>hs.id===ve.assignedToActorId),bt=Je?.displayName||"Unknown",en=Je?.slug||"unknown",Ze=ct?.displayName||"Unknown",de=ct?.slug||"unknown",Te=!!ve.resolvedAt,Bt=m&&ve.assignedToActorId===m.actorId,ma=typeof ve.answer=="string"?ve.answer:JSON.stringify(ve.answer),ul=Te?[{label:"resolved question",color:"gray"},{label:"answer",color:"green"}]:[{label:"question",color:"orange"}];return a.jsx(be,{leading:Te?a.jsxs("div",{className:"task-detail-page__input-request-avatars",children:[a.jsx(He,{size:"sm",name:bt,src:Je?.avatarUrl||void 0}),a.jsx(He,{size:"sm",name:Ze,src:ct?.avatarUrl||void 0})]}):a.jsx(He,{size:"sm",name:bt,src:Je?.avatarUrl||void 0}),tags:ul,topRight:a.jsx(b,{size:"1",tone:"muted",children:Lt(ve.createdAt)}),children:a.jsxs(te,{spacing:"2",children:[a.jsxs("div",{className:"task-detail-page__input-request",children:[a.jsxs("div",{className:"task-detail-page__input-request-question",children:[a.jsxs("div",{className:"task-detail-page__input-request-header",children:[a.jsx(b,{as:"span",weight:"medium",size:"3",children:bt}),a.jsx(b,{as:"span",weight:"normal",tone:"muted",size:"3",children:` @${en}`})]}),a.jsxs(b,{children:[a.jsx(b,{as:"span",tone:"muted",children:"Asked:"})," ",ve.question]})]}),Te?a.jsxs("div",{className:"task-detail-page__input-request-answer",children:[a.jsxs("div",{className:"task-detail-page__input-request-header",children:[a.jsx(b,{as:"span",weight:"medium",size:"3",children:Ze}),a.jsx(b,{as:"span",weight:"normal",tone:"muted",size:"3",children:` @${de}`})]}),a.jsxs(b,{children:[a.jsx(b,{as:"span",tone:"muted",children:"Answered:"})," ",ma]})]}):null]}),!Te&&Bt&&a.jsx(ue,{size:"sm",variant:"primary",onClick:()=>ks(ve),children:"Respond"})]})},`input-request-${ve.id}`)}),mn?a.jsx("div",{className:"task-detail-page__section-toggle",children:a.jsx(ue,{size:"sm",variant:"secondary",onClick:()=>M(re=>!re),children:L?"Show fewer updates":`See ${gn.length-Ld} more updates`})}):null]}),a.jsx(ye,{className:"task-detail-page__section",children:a.jsx("div",{className:"task-detail-page__activity",children:a.jsxs("div",{className:`task-detail-page__activity-slot ${w?"task-detail-page__activity-slot--active":""}`,children:[a.jsx("div",{className:"task-detail-page__activity-placeholder",children:a.jsx(b,{size:"2",tone:"muted",children:"Live activity will show here"})}),w?a.jsx("div",{className:`task-detail-page__activity-card ${R==="enter"?"is-entering":""} ${R==="exit"?"is-exiting":""}`,children:a.jsx(b,{size:"2",className:"task-detail-page__activity-message",children:w.message?.replace(/\s+/g," ").trim()||"Activity in progress..."})}):null]})})}),a.jsxs(ye,{title:"Runs",className:"task-detail-page__section",children:[G&&he.length===0?a.jsx(b,{className:"task-detail-page__executions-state",tone:"muted",children:"Loading runs..."}):null,J?a.jsxs(b,{className:"task-detail-page__executions-state",tone:"muted",children:["Failed to load runs: ",J]}):null,!G&&!J&&he.length===0?a.jsx(b,{className:"task-detail-page__executions-state",tone:"muted",children:"No runs yet for this task."}):null,Js.map(re=>{const ve=g.find(ma=>ma.id===re.agentActorId),Je=ve?.displayName??qd(re.agentActorId),ct=ve?.slug,bt=Z1(re.status),en=re.status==="FAILED"&&!!(re.errorCode||re.errorMessage),Ze=Re.has(re.id),de=re.source==="active",Te=It.has(re.executionId),Bt={label:de?"active":"history",color:"gray"};return a.jsx(be,{leading:a.jsx(He,{size:"sm",name:Je,src:ve?.avatarUrl||void 0}),tags:[bt,Bt],topRight:de?a.jsx(ue,{variant:"danger",size:"sm",disabled:Te,onClick:()=>void vt(re.executionId,n?.name,n?.id??""),children:Te?"Interrupting…":"Interrupt"}):a.jsx(b,{size:"1",tone:"muted",children:Lt(re.timestamp)}),children:a.jsxs(te,{spacing:"1",children:[a.jsxs("div",{children:[a.jsx(b,{as:"span",weight:"medium",size:"3",children:Je}),a.jsx(b,{as:"span",weight:"normal",tone:"muted",size:"3",children:ct?` @${ct}`:""})]}),a.jsx(b,{as:"span",tone:"muted",size:"2",children:a.jsxs("span",{className:"task-detail-page__execution-meta",children:["run #",qd(re.executionId),en?a.jsx("button",{type:"button",className:"task-detail-page__execution-error-toggle",onClick:()=>ss(re.id),"aria-label":Ze?"Hide failure details":"Show failure details","aria-expanded":Ze,title:Ze?"Hide failure details":"Show failure details",children:"i"}):null]})}),a.jsx(b,{as:"span",size:"1",tone:"muted",children:a.jsxs("span",{className:"task-detail-page__execution-stats",children:["tools: ",re.toolCallCount,a.jsx("span",{className:"task-detail-page__execution-stats-separator",children:"|"}),"session: ",re.runnerSessionId?qd(re.runnerSessionId):"pending",de?a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"task-detail-page__execution-stats-separator",children:"|"}),Lt(re.timestamp)]}):null]})}),en&&Ze?a.jsxs("div",{className:"task-detail-page__execution-error-detail",children:[re.errorCode?a.jsx(b,{as:"span",size:"1",style:"mono",className:"task-detail-page__execution-error-code",children:re.errorCode}):null,re.errorMessage?a.jsx(b,{as:"span",size:"2",wrap:!0,children:re.errorMessage}):null]}):null]})},re.id)}),Ps?a.jsx("div",{className:"task-detail-page__section-toggle",children:a.jsx(ue,{size:"sm",variant:"secondary",onClick:()=>A(re=>!re),children:N?"Show fewer runs":`See ${he.length-Md} more runs`})}):null]}),a.jsx(ye,{className:"task-detail-page__status-buttons",children:Object.entries(Zs).map(([re,ve])=>{const Je=ve.icon;return a.jsx(ue,{size:"sm",variant:re===n.status?"primary":"secondary",onClick:()=>$n(re),disabled:D,children:a.jsxs(te,{spacing:"1",align:"center",children:[a.jsx(Je,{size:20}),a.jsx("div",{children:ve.label})]})},re)})}),a.jsx(ue,{className:"task-detail-fab",onClick:()=>ce(!0),variant:"primary",size:"lg",children:"Add Comment"}),!n.assigneeActor&&a.jsxs(ye,{className:"task-detail-page__comment-buttons",children:[a.jsx(ue,{size:"lg",onClick:()=>fe(!0),children:"Assign"}),a.jsx(ue,{size:"lg",variant:"primary",onClick:async()=>{await u.assignTaskToMe({taskId:n.id})},children:"Assign to Me"})]}),a.jsx(Ur,{className:"task-detail-page__comment-buttons",onDelete:async()=>{try{await u.deleteTask({taskId:n.id}),x(t)}catch(re){y(re)}}}),a.jsxs(ye,{className:"task-detail-page__actions",children:[!E&&j&&!j.isReady?a.jsx(nc,{title:j.title,description:j.description,ctaLabel:j.ctaLabel,onOpenSettings:()=>x("/settings/chat")}):null,a.jsx(ue,{size:"lg",variant:W?"primary":"secondary",onClick:()=>{se()},disabled:me||!k||E,children:W?"Go to thread":"Create thread"}),a.jsx(ue,{size:"lg",variant:"secondary",onClick:()=>x(t),children:"Back to Tasks"})]}),mt?a.jsx(q1,{onCancel:fn,onSave:hn,taskId:n.id}):null,Y?a.jsx(P1,{onCancel:In,onSave:ga}):null,K?a.jsx(U1,{onCancel:Fr,onSave:Vr,existingTags:n.tags}):null,et?a.jsx($1,{onCancel:Ts,onSave:Ht,excludeTaskIds:[n.id,...n.dependsOnIds||[]]}):null,xt?a.jsx(B1,{onCancel:Pa,onSave:Gr,taskId:n.id,inputRequestId:xt.id,question:xt.question}):null]})}function K1(){const{d:n}=Wt(),{tasks:t,detailTasks:i,getTaskById:l,isLoading:c,hasLoadedOnce:u,setSectionTitle:f,addComment:x,deleteTask:g,assignTask:m,assignTaskToMe:y,answerInputRequest:_,activityByTaskId:v}=qn(),[j,k]=h.useState(!1),E=h.useMemo(()=>{const z=new Map;for(const L of t)z.set(L.id,L);for(const L of i)z.set(L.id,L);return Array.from(z.values())},[t,i]),w=n?E.find(z=>z.id===n):void 0;h.useEffect(()=>{if(!n)return;let z=!1;return k(!0),l(n).catch(L=>console.error("Failed to fetch task",L)).finally(()=>{z||k(!1)}),()=>{z=!0}},[n,l]),h.useEffect(()=>{if(!w||!w.dependsOnIds||w.dependsOnIds.length===0)return;const z=w.dependsOnIds.filter(L=>!E.some(M=>M.id===L));z.length!==0&&Promise.all(z.map(L=>l(L).catch(M=>(console.error(`Failed to hydrate dependency ${L}`,M),null))))},[w,E,l]);const T=!w&&(!u||c||j),R={addComment:({taskId:z,comment:L})=>x({taskId:z,comment:L}),deleteTask:({taskId:z})=>g({taskId:z}),assignTask:({taskId:z,assigneeActorId:L})=>m({taskId:z,assigneeActorId:L}),assignTaskToMe:({taskId:z})=>y({taskId:z}),answerInputRequest:({taskId:z,inputRequestId:L,answer:M})=>_({taskId:z,inputRequestId:L,answer:M}),changeStatus:({taskId:z,status:L})=>Qt.TasksController_changeStatus({id:z,body:{status:L}}),addTag:({taskId:z,tag:L})=>Qt.TasksController_addTagToTask({id:z,body:{name:L.name}}),removeTag:({taskId:z,tagId:L})=>Qt.TasksController_removeTagFromTask({id:z,tagId:L}),addDependency:async({taskId:z,dependencyTaskId:L})=>{const M=E.find(A=>A.id===z);if(!M)return;const N=[...M.dependsOnIds||[],L];await Qt.TasksController_updateTask({id:z,body:{dependsOnIds:N}});try{await l(L)}catch(A){console.error(`Failed to hydrate dependency ${L} after adding`,A)}},removeDependency:async({taskId:z,dependencyTaskId:L})=>{const M=E.find(A=>A.id===z);if(!M)return;const N=(M.dependsOnIds||[]).filter(A=>A!==L);await Qt.TasksController_updateTask({id:z,body:{dependsOnIds:N}})}};return a.jsx(Tv,{task:w,backPath:"/tasks",setSectionTitle:f,isLoadingTask:T,activityByTaskId:v,handlers:R,allTasks:E})}function X1({backPath:n}){const t=ze();return a.jsxs("div",{className:"task-detail-page",children:[a.jsxs(ye,{className:"task-detail-page__section task-detail-page__shell-container",children:[a.jsx("div",{className:"task-detail-page__shell-line task-detail-page__shell-line--wide"}),a.jsx("div",{className:"task-detail-page__shell-line task-detail-page__shell-line--mid"})]}),a.jsxs(ye,{className:"task-detail-page__section task-detail-page__shell-container",children:[a.jsx("div",{className:"task-detail-page__shell-line task-detail-page__shell-line--full"}),a.jsx("div",{className:"task-detail-page__shell-line task-detail-page__shell-line--short"}),a.jsx("div",{className:"task-detail-page__shell-line task-detail-page__shell-line--mid"})]}),a.jsxs(ye,{className:"task-detail-page__section task-detail-page__shell-container",children:[a.jsx("div",{className:"task-detail-page__shell-line task-detail-page__shell-line--full"}),a.jsx("div",{className:"task-detail-page__shell-line task-detail-page__shell-line--full"})]}),a.jsx("div",{className:"task-detail-page__actions",children:a.jsx(ue,{size:"lg",variant:"secondary",onClick:()=>t(n),children:"Back to Tasks"})})]})}function Z1(n){return n==="ACTIVE"?{label:"active",color:"blue"}:n==="SUCCEEDED"?{label:"succeeded",color:"green"}:n==="FAILED"?{label:"failed",color:"red"}:n==="STALE"?{label:"stale",color:"orange"}:{label:"cancelled",color:"gray"}}function qd(n){return n.length<=12?n:`${n.slice(0,8)}…${n.slice(-4)}`}function W1(n){if(!(n instanceof HTMLElement))return!1;if(n.isContentEditable)return!0;const t=n.tagName.toLowerCase();return t==="input"||t==="textarea"||t==="select"?!0:!!n.closest('[contenteditable="true"], input, textarea, select')}const J1=5e3,eE=pa("/tasks"),Ch=()=>{const[n,t]=h.useState(!0),[i,l]=h.useState(!1),[c,u]=h.useState(null),[f,x]=h.useState(!1),[g,m]=h.useState([]),[y,_]=h.useState([]),[v,j]=h.useState([]),[k,E]=h.useState({queue:0,active:0,history:0}),[w,T]=h.useState(null),R=h.useRef(!1),z=h.useCallback(async L=>{if(R.current)return;R.current=!0;const M=!i,N=L?.silent??!1;M?t(!0):N||x(!0);try{const[A,I,Q]=await Promise.all([Ma.TaskExecutionQueueController_listQueue({limit:50}),Ma.ActiveTaskExecutionController_listActiveExecutions({limit:50}),Ma.TaskExecutionHistoryController_listHistory({limit:50})]);m(A.items),_(I.items),j(Q.items),E({queue:A.total,active:I.total,history:Q.total}),T(new Date().toISOString()),u(null)}catch(A){u(A instanceof Error?A.message:"Failed to load executions")}finally{R.current=!1,l(!0),t(!1),x(!1)}},[i]);return h.useEffect(()=>{z();const L=window.setInterval(()=>{z({silent:!0})},J1);return()=>window.clearInterval(L)},[z]),h.useEffect(()=>{const L=Bs(eE,{transports:["websocket","polling"],withCredentials:!0});return L.on("connect",()=>{L.emit("tasks.subscribe",{},()=>{})}),L.on(bs.TASK_ACTIVITY,M=>{M.kind.startsWith("execution.")&&z({silent:!0})}),()=>{L.close()}},[z]),{isLoading:n,isRefreshing:f,hasLoadedOnce:i,error:c,queue:g,active:y,history:v,totals:k,loadExecutions:z,lastUpdatedAt:w}},Yi=228,wv=48,tE=60,sE=84,Hy=112,Ev=20,zo=48,nE=.55,aE=1.6,Py=.15,rE=.0025,Cv="task-dependencies-view-preferences",$i={graphMode:"all",hideDonePaths:!0,selectedTagNames:[]};function Gy(){const{tasks:n,isLoading:t,error:i,setSectionTitle:l,activityByTaskId:c}=qn(),{active:u}=Ch(),f=ze(),{taskId:x}=Wt(),g=h.useRef(null),m=h.useRef({x:0,y:0}),y=h.useRef(null),_=h.useRef(void 0),v=h.useRef(null),[j,k]=h.useState(1),[E,w]=h.useState({x:0,y:0}),[T,R]=h.useState(!1),[z,L]=h.useState(oE),{graphMode:M,hideDonePaths:N,selectedTagNames:A}=z,[I,Q]=h.useState([]),[Z,U]=h.useState(""),[le,W]=h.useState(!1);jt(),h.useEffect(()=>{l("Tasks")},[l]),h.useEffect(()=>{m.current=E},[E]),h.useEffect(()=>{cE(z)},[z]),h.useEffect(()=>{const K=new AbortController;return f1.MetaController_getAllTags({signal:K.signal}).then(Q).catch(je=>{K.signal.aborted||console.error("Failed to load dependency graph tags:",je)}),()=>K.abort()},[]);const oe=h.useMemo(()=>fE(n,I),[I,n]),me=h.useMemo(()=>new Map(oe.map(K=>[K.name,K])),[oe]),B=h.useMemo(()=>A.map(K=>me.get(K)??{name:K,count:0}),[me,A]),se=h.useMemo(()=>{const K=new Set(A),je=Z.trim().toLowerCase();return oe.filter(et=>!K.has(et.name)).filter(et=>je.length===0||et.name.toLowerCase().includes(je)).slice(0,8)},[oe,A,Z]),ge=h.useMemo(()=>pE(n,A),[n,A]),Ee=h.useMemo(()=>new Set(u.map(K=>K.taskId)),[u]),Ce=h.useMemo(()=>new Map(u.map(K=>[K.taskId,K.taskStatus])),[u]),D=h.useMemo(()=>new Set(Object.values(c).filter(yE).map(K=>K.taskId)),[c]),H=h.useMemo(()=>hE(ge,Ce,Ee,D,{includeAllTasks:M==="all",hideDonePaths:N,focusedTaskId:x}),[Ce,Ee,D,ge,x,M,N]),he=A.length>0,pe=`${H.nodes.length} shown`,G=N?"Showing paths that contain unfinished work. Click to include completed-only paths.":"Showing every path. Click to hide completed-only paths.";h.useEffect(()=>{if(!le)return;const K=je=>{v.current?.contains(je.target)||W(!1)};return document.addEventListener("pointerdown",K),()=>document.removeEventListener("pointerdown",K)},[le]);const ae=h.useCallback(K=>{L(je=>je.selectedTagNames.includes(K)?je:{...je,selectedTagNames:[...je.selectedTagNames,K]}),U(""),W(!1)},[]),J=h.useCallback(K=>{L(je=>({...je,selectedTagNames:je.selectedTagNames.filter(et=>et!==K)}))},[]),xe=h.useCallback(()=>{L(K=>({...K,selectedTagNames:[]}))},[]),Re=h.useCallback(K=>{if(!K.nativeEvent.isComposing){if(K.key==="Enter"){K.preventDefault();const[je]=se;je&&ae(je.name);return}K.key==="Escape"&&(K.preventDefault(),W(!1))}},[ae,se]),Qe=h.useCallback((K,je)=>{const et=g.current,yt=Yy(K);if(!et||yt===j){k(yt);return}const xt=je??{x:et.clientWidth/2,y:et.clientHeight/2};w(ks=>{const ss=(xt.x-ks.x)/j,vt=(xt.y-ks.y)/j;return{x:xt.x-ss*yt,y:xt.y-vt*yt}}),k(yt)},[j]),It=h.useCallback(K=>{k(je=>Yy(je+K))},[]),nt=h.useCallback(()=>{w(vE(H,g.current,x)),k(1)},[x,H]);h.useEffect(()=>{if(!(x&&_.current!==x)||H.nodes.length===0)return;const je=H.nodes.find(et=>et.task.id===x);je&&(_.current=x,k(1),w(zv(je,g.current)))},[x,H]);const mt=h.useCallback(K=>{if(H.nodes.length===0)return;const je=K.currentTarget;if(K.ctrlKey||K.metaKey){K.preventDefault();const et=je.getBoundingClientRect();Qe(j*Math.exp(-K.deltaY*rE),{x:K.clientX-et.left,y:K.clientY-et.top});return}if(K.deltaX!==0||K.deltaY!==0){K.preventDefault();const et=K.deltaMode===1?16:K.deltaMode===2?je.clientHeight:1;w(yt=>({x:yt.x-K.deltaX*et,y:yt.y-K.deltaY*et}))}},[Qe,H.nodes.length,j]),ce=h.useCallback(K=>{H.nodes.length===0||K.button!==0||K.target.closest(".dependency-task-card")||(K.preventDefault(),K.currentTarget.setPointerCapture(K.pointerId),y.current={pointerId:K.pointerId,startClientX:K.clientX,startClientY:K.clientY,startPanX:m.current.x,startPanY:m.current.y},R(!0))},[H.nodes.length]),Y=h.useCallback(K=>{const je=y.current;!je||je.pointerId!==K.pointerId||(K.preventDefault(),w({x:je.startPanX+K.clientX-je.startClientX,y:je.startPanY+K.clientY-je.startClientY}))},[]),fe=h.useCallback(K=>{const je=y.current;!je||je.pointerId!==K.pointerId||(K.currentTarget.hasPointerCapture(K.pointerId)&&K.currentTarget.releasePointerCapture(K.pointerId),y.current=null,R(!1))},[]);return t&&n.length===0?a.jsx("div",{className:"task-dependencies-page task-dependencies-page--state",children:a.jsx(b,{tone:"muted",children:"Loading dependencies..."})}):i?a.jsx("div",{className:"task-dependencies-page task-dependencies-page--state",children:a.jsxs(b,{tone:"muted",children:["Could not load dependencies: ",i]})}):a.jsxs("div",{className:"task-dependencies-page",children:[a.jsxs("div",{className:"task-dependencies-controls","aria-label":"Dependency graph filters",children:[a.jsxs("div",{className:"task-dependencies-controls__main",children:[a.jsx("div",{className:"task-dependencies-controls__row",children:a.jsxs("div",{className:"task-dependencies-segmented",role:"group","aria-label":"Tasks shown in graph",children:[a.jsx("button",{className:`task-dependencies-segmented__button ${M==="dependencies"?"task-dependencies-segmented__button--active":""}`,type:"button",title:"Show only tasks that have dependency links.",onClick:()=>L(K=>({...K,graphMode:"dependencies"})),children:"Linked tasks"}),a.jsx("button",{className:`task-dependencies-segmented__button ${M==="all"?"task-dependencies-segmented__button--active":""}`,type:"button",title:"Show every task, including tasks without dependency links.",onClick:()=>L(K=>({...K,graphMode:"all"})),children:"Every task"})]})}),a.jsx("div",{className:"task-dependencies-controls__row",children:a.jsx("button",{className:`task-dependencies-toggle${N?" task-dependencies-toggle--active":""}`,type:"button","aria-pressed":N,onClick:()=>L(K=>({...K,hideDonePaths:!K.hideDonePaths})),"aria-label":"Show unfinished paths only",title:G,children:"Unfinished paths"})}),a.jsx("span",{className:"task-dependencies-controls__summary",children:pe}),a.jsxs("div",{className:"task-dependencies-tag-picker",ref:v,children:[a.jsx("input",{className:"task-dependencies-tag-picker__input",type:"search",value:Z,placeholder:"+ tag","aria-label":"Add tag filter","aria-expanded":le,"aria-controls":"task-dependencies-tag-picker-list",title:"Filter the graph by tag.",onChange:K=>{U(K.target.value),W(!0)},onFocus:()=>W(!0),onKeyDown:Re}),le?a.jsx("div",{id:"task-dependencies-tag-picker-list",className:"task-dependencies-tag-picker__menu",role:"listbox","aria-label":"Available tag filters",children:se.length===0?a.jsx("span",{className:"task-dependencies-tag-picker__empty",children:oe.length===A.length?"No more tags":"No matching tags"}):se.map(K=>a.jsxs("button",{className:"task-dependencies-tag-picker__option",type:"button",role:"option","aria-selected":"false",onMouseDown:je=>je.preventDefault(),onClick:()=>ae(K.name),children:[a.jsx("span",{className:"task-dependencies-tag-picker__option-name",children:K.name}),a.jsx("span",{className:"task-dependencies-tag-picker__option-count",children:K.count})]},K.name))}):null]})]}),he?a.jsxs("div",{className:"task-dependencies-controls__tags-row",children:[a.jsx("span",{className:"task-dependencies-controls__label",children:"Tags"}),a.jsx("div",{className:"task-dependencies-tags","aria-label":"Tag filters",children:a.jsxs("div",{className:"task-dependencies-selected-tags","aria-label":"Selected tag filters",children:[B.map(K=>a.jsx(_s,{className:"task-dependencies-tag-filter",onRemove:()=>J(K.name),removeLabel:`Remove ${K.name} filter`,children:K.name},K.name)),a.jsx("button",{className:"task-dependencies-tags__clear",type:"button",onClick:xe,children:"Clear"})]})})]}):null]}),a.jsx("div",{className:"task-dependencies-canvas","aria-label":"Task dependency graph",children:H.nodes.length===0?a.jsxs("div",{className:"task-dependencies-empty",children:[a.jsx(b,{size:"3",weight:"semibold",children:"No tasks match this graph"}),a.jsx(b,{tone:"muted",children:"Adjust the task scope or tag filters to show more tasks."})]}):a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"task-dependencies-toolbar","aria-label":"Dependency graph controls",children:[a.jsx("button",{className:"task-dependencies-toolbar__button",type:"button",onClick:()=>It(-Py),"aria-label":"Zoom out",title:"Zoom out",children:a.jsx(o0,{size:16,strokeWidth:1.8})}),a.jsxs("span",{className:"task-dependencies-toolbar__zoom",children:[Math.round(j*100),"%"]}),a.jsx("button",{className:"task-dependencies-toolbar__button",type:"button",onClick:()=>It(Py),"aria-label":"Zoom in",title:"Zoom in",children:a.jsx(i0,{size:16,strokeWidth:1.8})}),a.jsx("button",{className:"task-dependencies-toolbar__button",type:"button",onClick:nt,"aria-label":"Reset zoom",title:"Reset zoom",children:a.jsx(LT,{size:16,strokeWidth:1.8})})]}),a.jsx("div",{ref:g,className:`task-dependencies-viewport${T?" task-dependencies-viewport--panning":""}`,onWheel:mt,onPointerDown:ce,onPointerMove:Y,onPointerUp:fe,onPointerCancel:fe,children:a.jsxs("div",{className:"task-dependencies-graph",style:{width:H.width,height:H.height,transform:`translate(${E.x}px, ${E.y}px) scale(${j})`},children:[a.jsx(dE,{connections:H.connections,width:H.width,height:H.height}),H.nodes.map(K=>a.jsx(iE,{node:K,status:Ce.get(K.task.id)??K.task.status,hasActiveExecution:Ee.has(K.task.id)||D.has(K.task.id),onOpen:()=>f(`/tasks/task/${K.task.id}`)},K.task.id))]})})]})})]})}function iE({node:n,status:t,hasActiveExecution:i,onOpen:l}){const{task:c}=n,u=Nv(t,i),f=c.assigneeActor?.slug,x=!!(f&&(t===_e.IN_PROGRESS||t===_e.FOR_REVIEW));return a.jsxs("button",{className:`dependency-task-card dependency-task-card--${t.toLowerCase().replaceAll("_","-")}`,type:"button",onClick:l,style:{left:n.x,top:n.y,height:n.height},children:[a.jsxs("span",{className:"dependency-task-card__content",children:[a.jsx("span",{className:"dependency-task-card__title",children:c.name}),x?a.jsxs("span",{className:"dependency-task-card__assignee",children:["@",f]}):null,u?a.jsx("span",{className:"dependency-task-card__status-row",children:a.jsx(_s,{color:u.color,className:"dependency-task-card__status-chip",children:u.label})}):null]}),a.jsxs("span",{className:"dependency-task-card__meta",children:[t===_e.DONE?a.jsx(lE,{}):null,i?a.jsx("span",{className:"dependency-task-card__spinner","aria-label":"Active execution",title:"Active execution"}):null]})]})}function lE(){return a.jsx("span",{className:"dependency-run-status-icon dependency-run-status-icon--success","aria-label":"Done",children:"✓"})}function Nv(n,t=!1){return t&&n===_e.NOT_STARTED?th(_e.IN_PROGRESS):n===_e.IN_PROGRESS||n===_e.FOR_REVIEW?th(n):null}function oE(){try{const n=localStorage.getItem(Cv);if(!n)return $i;const t=JSON.parse(n);return{graphMode:uE(t.graphMode)?t.graphMode:$i.graphMode,hideDonePaths:typeof t.hideDonePaths=="boolean"?t.hideDonePaths:$i.hideDonePaths,selectedTagNames:Array.isArray(t.selectedTagNames)?t.selectedTagNames.filter(i=>typeof i=="string"):$i.selectedTagNames}}catch(n){return console.error("Failed to load dependency view preferences:",n),$i}}function cE(n){try{localStorage.setItem(Cv,JSON.stringify(n))}catch(t){console.error("Failed to save dependency view preferences:",t)}}function uE(n){return n==="dependencies"||n==="all"}function dE({connections:n,width:t,height:i}){return a.jsxs("svg",{className:"task-dependencies-connections",width:t,height:i,viewBox:`0 0 ${t} ${i}`,"aria-hidden":"true",children:[a.jsx("defs",{children:a.jsx("marker",{id:"task-dependencies-connection-arrow",markerWidth:"8",markerHeight:"8",refX:"7",refY:"4",orient:"auto",markerUnits:"strokeWidth",children:a.jsx("path",{className:"task-dependencies-connection-arrow",d:"M 0 0 L 8 4 L 0 8 Z"})})}),n.map(l=>{const c=Math.max(80,l.endX-l.startX),u=Math.min(140,c*.5);return a.jsx("path",{d:`M ${l.startX} ${l.startY} C ${l.startX+u} ${l.startY}, ${l.endX-u} ${l.endY}, ${l.endX} ${l.endY}`,className:"task-dependencies-connection",markerEnd:"url(#task-dependencies-connection-arrow)"},`${l.fromTaskId}-${l.toTaskId}`)})]})}function hE(n,t,i,l,c){const u=new Map(n.map(M=>[M.id,M])),f=new Set(c.includeAllTasks?n.map(M=>M.id):[]);c.focusedTaskId&&u.has(c.focusedTaskId)&&f.add(c.focusedTaskId);for(const M of n){const N=M.dependsOnIds.filter(A=>u.has(A));if(N.length!==0){f.add(M.id);for(const A of N)f.add(A)}}if(f.size===0)return{nodes:[],connections:[],width:0,height:0};if(c.hideDonePaths&&gE(f,u,t,c.focusedTaskId),f.size===0)return{nodes:[],connections:[],width:0,height:0};const x=new Map(n.map((M,N)=>[M.id,N])),g=new Map,m=new Set,y=M=>{const N=g.get(M);if(N!==void 0)return N;if(m.has(M))return 0;m.add(M);const I=u.get(M)?.dependsOnIds.filter(Z=>f.has(Z)).map(Z=>y(Z))??[];m.delete(M);const Q=I.length===0?0:Math.max(...I)+1;return g.set(M,Q),Q};for(const M of f)y(M);xE(f,u,g);const _=new Map;for(const M of f){const N=g.get(M)??0,A=_.get(N)??[];A.push(M),_.set(N,A)}for(const[M,N]of _)N.sort((A,I)=>{const Q=u.get(A),Z=u.get(I),U=Fy(Q,x),le=Fy(Z,x);return U!==le?U-le:(x.get(A)??0)-(x.get(I)??0)}),_.set(M,N);const v=[],j=new Map,k=Array.from(_.keys()).sort((M,N)=>M-N),E=new Map;for(const[M,N]of _){const A=mE(N,u,t,i,l);E.set(M,A)}const w=Math.max(...Array.from(E.values()));for(const M of k){const N=_.get(M)??[],A=E.get(M)??0,I=Math.max(0,(w-A)/2);let Q=zo+I;N.forEach(Z=>{const U=u.get(Z);if(!U)return;const le=Rv(U,t,i,l),W={task:U,layer:M,x:zo+M*(Yi+Hy),y:Q,height:le};v.push(W),j.set(Z,W),Q+=le+Ev})}const T=[];for(const M of v)for(const N of M.task.dependsOnIds){const A=j.get(N);A&&T.push({fromTaskId:N,toTaskId:M.task.id,startX:A.x+Yi,startY:A.y+A.height/2,endX:M.x,endY:M.y+M.height/2})}const R=k.at(-1)??0,z=zo*2+Yi+R*(Yi+Hy),L=zo*2+w;return{nodes:v,connections:T,width:z,height:L}}function fE(n,t){const i=new Map;for(const l of n)for(const c of l.tags)i.set(c.name,(i.get(c.name)??0)+1);for(const l of t)i.has(l.name)||i.set(l.name,0);return Array.from(i.entries()).map(([l,c])=>({name:l,count:c})).sort((l,c)=>l.name.localeCompare(c.name))}function pE(n,t){if(t.length===0)return n;const i=new Set(t);return n.filter(l=>l.tags.some(c=>i.has(c.name)))}function gE(n,t,i,l){const c=new Map,u=new Map;for(const f of n){const x=t.get(f);if(!x)continue;const g=x.dependsOnIds.filter(m=>n.has(m));c.set(f,g);for(const m of g){const y=u.get(m)??[];y.push(f),u.set(m,y)}}for(const f of Array.from(n)){if(f===l||!Av(f,t,i))continue;Vy(f,c,t,i)||Vy(f,u,t,i)||n.delete(f)}}function Vy(n,t,i,l){const c=new Set([n]),u=[...t.get(n)??[]];for(;u.length>0;){const f=u.pop();if(!(!f||c.has(f))){if(c.add(f),!Av(f,i,l))return!0;u.push(...t.get(f)??[])}}return!1}function Av(n,t,i){const l=t.get(n);return(i.get(n)??l?.status)===_e.DONE}function mE(n,t,i,l,c){return n.reduce((u,f,x)=>{const g=t.get(f),m=g?Rv(g,i,l,c):wv;return u+m+(x>0?Ev:0)},0)}function Rv(n,t,i,l){const c=t.get(n.id)??n.status,u=i.has(n.id)||l.has(n.id);return n.assigneeActor?.slug&&(c===_e.IN_PROGRESS||c===_e.FOR_REVIEW)?sE:Nv(c,u)?tE:wv}function yE(n){return n.kind.startsWith("execution.")?n.kind!=="execution.stopped"&&n.kind!=="execution.history.added"&&n.kind!=="execution.unclaimed":!1}function Fy(n,t){return!n||n.dependsOnIds.length===0?Number.MAX_SAFE_INTEGER:Math.min(...n.dependsOnIds.map(i=>t.get(i)??Number.MAX_SAFE_INTEGER))}function xE(n,t,i){const l=new Map;for(const u of n){const f=t.get(u);if(f)for(const x of f.dependsOnIds){if(!n.has(x))continue;const g=l.get(x)??[];g.push(u),l.set(x,g)}}let c=!0;for(;c;){c=!1;for(const u of n){const f=l.get(u);if(!f||f.length===0)continue;const x=Math.min(...f.map(y=>i.get(y)??0)),g=Math.max(0,x-1),m=i.get(u)??0;g>m&&(i.set(u,g),c=!0)}}}function vE(n,t,i){const l=i?n.nodes.find(c=>c.task.id===i):void 0;return l?zv(l,t):{x:0,y:0}}function zv(n,t){return t?{x:t.clientWidth/2-n.x-Yi/2,y:t.clientHeight/2-n.y-n.height/2}:{x:0,y:0}}function Yy(n){return Math.min(aE,Math.max(nE,Number(n.toFixed(2))))}const Qy=100,bE=()=>{const[n,t]=h.useState([]),[i,l]=h.useState({}),[c,u]=h.useState([]),[f,x]=h.useState(!1),[g,m]=h.useState(null),y=h.useCallback(N=>{l(A=>({...A,[N.id]:N})),u(A=>A.some(Q=>Q.id===N.id)?A.map(Q=>Q.id===N.id?N:Q):[N,...A])},[]),_=h.useCallback(N=>{t(A=>A.find(Q=>Q.id===N.id)?A.map(Q=>Q.id===N.id?N:Q):[N,...A])},[]),v=h.useCallback(async()=>{x(!0),m(null);try{const N=await Cr.ScheduledTasksController_listScheduledTasks({page:1,limit:Qy});t(N.items),N.items.forEach(A=>{A.taskBlueprint&&y(A.taskBlueprint)})}catch(N){m(N instanceof Error?N.message:"Failed to load scheduled tasks")}finally{x(!1)}},[y]),j=h.useCallback(async N=>{const A=await Cr.ScheduledTasksController_getScheduledTask({id:N});return _(A),A.taskBlueprint&&y(A.taskBlueprint),A},[_,y]),k=h.useCallback(async N=>{const A=await Ui.TaskBlueprintsController_getTaskBlueprint({id:N});return y(A),A},[y]),E=h.useCallback(async()=>{m(null);try{const N=await Ui.TaskBlueprintsController_listTaskBlueprints({page:1,limit:Qy});u(N.items),N.items.forEach(A=>y(A))}catch(N){m(N instanceof Error?N.message:"Failed to load task blueprints")}},[y]),w=h.useCallback(async N=>{const A=await Ui.TaskBlueprintsController_createTaskBlueprint({body:N});return y(A),A},[y]),T=h.useCallback(async(N,A)=>{const I=await Ui.TaskBlueprintsController_updateTaskBlueprint({id:N,body:A});return y(I),I},[y]),R=h.useCallback(async N=>{const A=await Cr.ScheduledTasksController_createScheduledTask({body:N});return _(A),A.taskBlueprint&&y(A.taskBlueprint),A},[_,y]),z=h.useCallback(async(N,A)=>{const I=await Cr.ScheduledTasksController_updateScheduledTask({id:N,body:A});return _(I),I.taskBlueprint&&y(I.taskBlueprint),I},[_,y]),L=h.useCallback(async N=>{await Cr.ScheduledTasksController_deleteScheduledTask({id:N}),t(A=>A.filter(I=>I.id!==N))},[]),M=h.useCallback(async N=>{await Ui.TaskBlueprintsController_deleteTaskBlueprint({id:N}),u(A=>A.filter(I=>I.id!==N)),l(A=>{const I={...A};return delete I[N],I})},[]);return h.useEffect(()=>{v()},[v]),{scheduledTasks:n,blueprintsById:i,blueprints:c,isLoading:f,error:g,loadScheduledTasks:v,loadScheduledTask:j,loadBlueprint:k,loadBlueprints:E,createBlueprint:w,updateBlueprint:T,createScheduledTask:R,updateScheduledTask:z,deleteScheduledTask:L,deleteBlueprint:M}},Dv=h.createContext(null);function _E({children:n}){const{scheduledTasks:t,blueprints:i,blueprintsById:l,isLoading:c,error:u,loadScheduledTasks:f,loadScheduledTask:x,loadBlueprint:g,loadBlueprints:m,createBlueprint:y,updateBlueprint:_,createScheduledTask:v,updateScheduledTask:j,deleteScheduledTask:k,deleteBlueprint:E}=bE(),[w,T]=h.useState(""),R=h.useMemo(()=>({scheduledTasks:t,blueprints:i,blueprintsById:l,isLoading:c,error:u,sectionTitle:w,setSectionTitle:T,loadScheduledTasks:f,loadScheduledTask:x,loadBlueprint:g,loadBlueprints:m,createBlueprint:y,updateBlueprint:_,createScheduledTask:v,updateScheduledTask:j,deleteScheduledTask:k,deleteBlueprint:E}),[t,i,l,c,u,w,f,x,g,m,y,_,v,j,k,E]);return a.jsx(Dv.Provider,{value:R,children:n})}function Nh(){const n=h.useContext(Dv);if(!n)throw new Error("useScheduledTasksCtx must be used within <ScheduledTasksProvider>");return n}const Yo=n=>String(n).padStart(2,"0"),SE=n=>{const[t="0",i="0"]=n.split(":"),l=Number(t),c=Number(i);return{hour:Number.isFinite(l)?l:0,minute:Number.isFinite(c)?c:0}},jE=(n,t,i)=>{if(!n||n==="*")return[];const l=n.split(","),c=[];for(const u of l){const f=u.trim();if(f)if(f.includes("-")){const[x,g]=f.split("-"),m=Number(x),y=Number(g);if(!Number.isFinite(m)||!Number.isFinite(y))continue;const _=Math.max(t,Math.min(m,y)),v=Math.min(i,Math.max(m,y));for(let j=_;j<=v;j+=1)c.push(j)}else{const x=Number(f);Number.isFinite(x)&&x>=t&&x<=i&&c.push(x)}}return Array.from(new Set(c)).sort((u,f)=>u-f)},kE=n=>{if(n.preset==="custom")return n.cronExpression.trim();const{hour:t,minute:i}=SE(n.time),l=Yo(i),c=Yo(t);if(n.preset==="daily")return`${l} ${c} * * *`;if(n.preset==="weekly"){const f=n.days.length?n.days.join(","):"1";return`${l} ${c} * * ${f}`}const u=Math.min(Math.max(n.dayOfMonth,1),28);return`${l} ${c} ${u} * *`},Ov=n=>{const t=n.trim(),i=t.split(/\s+/);if(i.length<5)return{preset:"custom",time:"09:00",days:[],dayOfMonth:1,cronExpression:t};const[l,c,u,f,x]=i,g=`${Yo(Number(c))}:${Yo(Number(l))}`;if(u==="*"&&f==="*"&&x==="*")return{preset:"daily",time:g,days:[],dayOfMonth:1,cronExpression:t};if(u==="*"&&f==="*"&&x!=="*"){const m=jE(x,0,7).map(y=>y===7?0:y);return m.length?{preset:"weekly",time:g,days:m,dayOfMonth:1,cronExpression:t}:{preset:"custom",time:g,days:[],dayOfMonth:1,cronExpression:t}}if(u!=="*"&&f==="*"&&x==="*"){const m=Number(u);return{preset:"monthly",time:g,days:[],dayOfMonth:Number.isFinite(m)?m:1,cronExpression:t}}return{preset:"custom",time:"09:00",days:[],dayOfMonth:1,cronExpression:t}},Lv=n=>{if(n.preset==="custom")return`Cron: ${n.cronExpression}`;if(n.preset==="daily")return`Daily at ${n.time}`;if(n.preset==="weekly"){const t=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];return`Weekly on ${(n.days.length?n.days:[1]).map(c=>t[c]??"").join(", ")} at ${n.time}`}return`Monthly on day ${n.dayOfMonth} at ${n.time}`},TE=/^[\d*/,\-]+$/,wE=n=>{const t=n.trim().split(/\s+/);return t.length!==5?"Cron must have 5 fields: minute hour day-of-month month day-of-week.":t.some(i=>!i||!TE.test(i))?"Cron can only include digits, *, /, -, and commas.":null};function EE({blueprints:n,onCancel:t,onSave:i,onRequestNewBlueprint:l}){const[c,u]=h.useState(""),[f,x]=h.useState(null),[g,m]=h.useState(0),y=h.useMemo(()=>{const v=c.trim().toLowerCase();return v?n.filter(j=>[j.name,j.description||"",j.assigneeActor?.displayName||"",j.assigneeActor?.slug||""].join(" ").toLowerCase().includes(v)):n},[n,c]),_=async()=>f?i(f):!1;return a.jsx(gt,{title:"Create Schedule",onCancel:t,onSave:_,children:a.jsxs("div",{className:"new-schedule-pop",children:[f?a.jsxs("div",{className:"new-schedule-pop__selected",onClick:()=>x(null),children:[a.jsx(He,{size:"md",name:f.name,src:f.assigneeActor?.avatarUrl||void 0}),a.jsxs("div",{className:"new-schedule-pop__selected-meta",children:[a.jsx(b,{weight:"medium",size:"3",children:f.name}),a.jsx(b,{tone:"muted",size:"2",children:f.description||"No description"})]}),a.jsx(b,{size:"2",tone:"muted",children:"tap to change"})]}):a.jsxs(a.Fragment,{children:[a.jsx("input",{className:"new-schedule-pop__input",placeholder:"Search blueprint by name...",value:c,onChange:v=>u(v.target.value),onKeyDown:v=>{v.key==="ArrowDown"&&(v.preventDefault(),m(j=>Math.min(j+1,y.length-1))),v.key==="ArrowUp"&&(v.preventDefault(),m(j=>Math.max(j-1,0))),v.key==="Enter"&&y[g]&&(v.preventDefault(),x(y[g]))}}),a.jsx("div",{className:"new-schedule-pop__list",children:y.length===0?a.jsx("div",{className:"new-schedule-pop__empty",children:a.jsx(b,{tone:"muted",size:"2",children:"No blueprints found"})}):y.map((v,j)=>a.jsxs("div",{className:`new-schedule-pop__item ${j===g?"new-schedule-pop__item--highlighted":""}`,onMouseEnter:()=>m(j),onClick:()=>x(v),children:[a.jsx(He,{size:"sm",name:v.name,src:v.assigneeActor?.avatarUrl||void 0}),a.jsxs("div",{className:"new-schedule-pop__item-meta",children:[a.jsx(b,{size:"2",weight:"medium",children:v.name}),a.jsx(b,{size:"1",tone:"muted",children:v.assigneeActor?`@${v.assigneeActor.slug}`:"Unassigned"})]})]},v.id))})]}),a.jsx(ue,{size:"sm",variant:"secondary",onClick:l,children:"+ New blueprint"})]})})}function CE(){const n=ze(),{scheduledTasks:t,blueprints:i,isLoading:l,error:c,createBlueprint:u,createScheduledTask:f,deleteScheduledTask:x,loadBlueprints:g}=Nh(),{setSectionTitle:m}=qn(),{showError:y}=ds(),_=Rt(),[v,j]=h.useState(!1),[k,E]=h.useState(!1),w=h.useRef(!1);jt(),h.useEffect(()=>{m("Schedule")},[m]),h.useEffect(()=>{g().catch(y)},[g,y]);const T=h.useMemo(()=>t.filter(N=>N.enabled).length,[t]),R=async N=>{try{const A=await u({name:N.title,description:N.description});return j(!1),n(`/tasks/blueprints/${A.id}`),!0}catch(A){return y(A),!1}},z=async N=>{if(w.current)return!1;w.current=!0;try{const A=await f({taskBlueprintId:N.id,cronExpression:"0 9 * * *",enabled:!1});return E(!1),n(`/tasks/schedule/${A.id}`),!0}catch(A){return y(A),!1}finally{w.current=!1}},L=h.useMemo(()=>i.map(N=>({id:N.id,name:N.name,description:N.description,status:_e.NOT_STARTED,assignee:null,assigneeActor:N.assigneeActor??void 0,sessionId:null,comments:[],artefacts:[],inputRequests:[],tags:N.tags,createdByActor:N.createdByActor,dependsOnIds:N.dependsOnIds,createdAt:N.createdAt,updatedAt:N.updatedAt})),[i]),M=async N=>{if(window.confirm("Delete this schedule?"))try{await x(N.id)}catch(A){y(A)}};return a.jsxs("div",{className:"scheduled-tasks-page",children:[c?a.jsx(b,{tone:"muted",children:c}):null,a.jsx("section",{className:"scheduled-tasks-page__section",children:l?a.jsx(b,{tone:"muted",children:"Loading scheduled tasks..."}):a.jsx(ye,{title:"Schedules",action:a.jsxs("div",{className:"scheduled-tasks-page__header-actions",children:[a.jsxs(b,{size:"2",tone:"muted",children:[T," active schedules"]}),a.jsx(ue,{size:"sm",variant:"secondary",onClick:()=>E(!0),children:"+ Add schedule"})]}),children:t.length===0?a.jsxs(Fe,{className:"scheduled-tasks-page__empty",children:[a.jsx(b,{weight:"medium",children:"No schedules yet"}),a.jsx(b,{tone:"muted",children:"Create a schedule from a blueprint."})]}):t.map(N=>{const A=N.taskBlueprint,I=Lv(Ov(N.cronExpression));return a.jsxs(be,{onClick:()=>n(`/tasks/schedule/${N.id}`),tags:[{label:N.enabled?"enabled":"paused",color:N.enabled?"green":"gray"}],topRight:a.jsxs(b,{size:"1",tone:"muted",children:["Next: ",new Date(N.nextRunAt).toLocaleString()]}),trailing:a.jsx(ue,{size:"sm",variant:"danger",onClick:Q=>{Q.stopPropagation(),M(N)},children:"Delete"}),children:[a.jsx(b,{as:"span",weight:"medium",size:"3",children:A?.name||"Untitled blueprint"}),a.jsx(b,{as:"span",size:"2",tone:"muted",children:` ${I}`})]},N.id)})})}),a.jsx("section",{className:"scheduled-tasks-page__section",children:L.length===0?a.jsxs(Fe,{className:"scheduled-tasks-page__empty",children:[a.jsx(b,{weight:"medium",children:"No blueprints yet"}),a.jsx(b,{tone:"muted",children:"Create a blueprint to reuse task definitions."})]}):_?a.jsx(ye,{title:"Blueprints",action:a.jsxs("div",{className:"scheduled-tasks-page__header-actions",children:[a.jsxs(b,{size:"2",tone:"muted",children:[i.length," blueprints"]}),a.jsx(ue,{size:"sm",variant:"secondary",onClick:()=>j(!0),children:"+ New blueprint"})]}),children:a.jsx("div",{className:"scheduled-tasks-page__blueprints-board",children:L.map(N=>a.jsx(Po,{task:N,onClick:()=>n(`/tasks/blueprints/${N.id}`)},N.id))})}):a.jsx(ye,{title:"Blueprints",action:a.jsxs("div",{className:"scheduled-tasks-page__header-actions",children:[a.jsxs(b,{size:"2",tone:"muted",children:[i.length," blueprints"]}),a.jsx(ue,{size:"sm",variant:"secondary",onClick:()=>j(!0),children:"+ New blueprint"})]}),children:L.map(N=>a.jsx(Ki,{task:N,onClick:()=>n(`/tasks/blueprints/${N.id}`)},N.id))})}),v?a.jsx(eh,{onCancel:()=>j(!1),onSave:R}):null,k?a.jsx(EE,{blueprints:i,onCancel:()=>E(!1),onSave:z,onRequestNewBlueprint:()=>{E(!1),j(!0)}}):null]})}const NE=[{value:0,label:"Sun"},{value:1,label:"Mon"},{value:2,label:"Tue"},{value:3,label:"Wed"},{value:4,label:"Thu"},{value:5,label:"Fri"},{value:6,label:"Sat"}];function AE(){const{scheduleId:n}=Wt(),t=ze(),{scheduledTasks:i,blueprintsById:l,loadScheduledTask:c,loadBlueprint:u,updateScheduledTask:f}=Nh(),{setSectionTitle:x}=qn(),{showError:g,showToast:m}=ds(),[y,_]=h.useState("daily"),[v,j]=h.useState("09:00"),[k,E]=h.useState([1]),[w,T]=h.useState(1),[R,z]=h.useState("0 9 * * *"),[L,M]=h.useState(!1),[N,A]=h.useState(!1),[I,Q]=h.useState(null),Z=i.find(B=>B.id===n),U=Z?.taskBlueprint||(Z?l[Z.taskBlueprintId]:void 0);jt(),h.useEffect(()=>{n&&(Z||c(n).catch(g))},[n,Z,c,g]),h.useEffect(()=>{Z&&!Z.taskBlueprint&&u(Z.taskBlueprintId).catch(g)},[Z,u,g]),h.useEffect(()=>{U?.name?x(U.name):x("Schedule")},[U,x]),h.useEffect(()=>{if(!Z)return;const B=Ov(Z.cronExpression);_(B.preset),j(B.time),E(B.days.length?B.days:[1]),T(B.dayOfMonth||1),z(B.cronExpression||Z.cronExpression),M(Z.enabled)},[Z]);const le=h.useMemo(()=>kE({preset:y,time:v,days:k,dayOfMonth:w,cronExpression:R}),[y,v,k,w,R]);if(!Z)return a.jsxs("div",{className:"scheduled-task-detail-page",children:[a.jsx(b,{tone:"muted",children:"Scheduled task not found."}),a.jsx(ue,{variant:"secondary",onClick:()=>t("/tasks/schedule"),children:"Back to schedules"})]});const W=Lv({preset:y,time:v,days:k,dayOfMonth:w,cronExpression:le}),oe=B=>{E(se=>{if(se.includes(B)){const ge=se.filter(Ee=>Ee!==B);return ge.length?ge:se}return[...se,B].sort((ge,Ee)=>ge-Ee)})},me=async()=>{if(y==="custom"){const B=wE(le);if(B){Q(B);return}}Q(null),A(!0);try{await f(Z.id,{cronExpression:le,enabled:L}),m("Schedule saved","success")}catch(B){g(B)}finally{A(!1)}};return a.jsxs("div",{className:"scheduled-task-detail-page",children:[a.jsx(ye,{title:"Task",className:"scheduled-task-detail-page__section",children:a.jsxs(be,{onClick:()=>t(`/tasks/blueprints/${Z.taskBlueprintId}`),tags:[{label:"blueprint",color:"blue"}],trailing:a.jsx(b,{size:"2",tone:"muted",children:"Open"}),children:[a.jsx(b,{as:"span",weight:"medium",size:"3",children:U?.name||"Untitled blueprint"}),a.jsx(b,{as:"span",tone:"muted",size:"2",children:` ${U?.description||"No description"}`})]})}),a.jsxs(ye,{title:"Schedule",className:"scheduled-task-detail-page__section",children:[a.jsxs("div",{className:"scheduled-task-detail-page__controls",children:[a.jsxs("label",{className:"scheduled-task-detail-page__label",children:[a.jsx(b,{size:"2",tone:"muted",children:"Frequency"}),a.jsxs("select",{className:"scheduled-task-detail-page__select",value:y,onChange:B=>_(B.target.value),children:[a.jsx("option",{value:"daily",children:"Daily"}),a.jsx("option",{value:"weekly",children:"Weekly"}),a.jsx("option",{value:"monthly",children:"Monthly"}),a.jsx("option",{value:"custom",children:"Custom (cron)"})]})]}),y!=="custom"?a.jsxs("label",{className:"scheduled-task-detail-page__label",children:[a.jsx(b,{size:"2",tone:"muted",children:"Time"}),a.jsx("input",{className:"scheduled-task-detail-page__input",type:"time",value:v,onChange:B=>j(B.target.value)})]}):null,y==="weekly"?a.jsxs("div",{className:"scheduled-task-detail-page__label",children:[a.jsx(b,{size:"2",tone:"muted",children:"Days"}),a.jsx("div",{className:"scheduled-task-detail-page__day-grid",children:NE.map(B=>a.jsx("button",{type:"button",className:`scheduled-task-detail-page__day ${k.includes(B.value)?"is-selected":""}`,onClick:()=>oe(B.value),children:B.label},B.value))})]}):null,y==="monthly"?a.jsxs("label",{className:"scheduled-task-detail-page__label",children:[a.jsx(b,{size:"2",tone:"muted",children:"Date"}),a.jsx("input",{className:"scheduled-task-detail-page__input",type:"date",value:`2026-01-${String(Math.min(Math.max(w,1),28)).padStart(2,"0")}`,onChange:B=>{const se=new Date(`${B.target.value}T00:00:00`).getDate();Number.isFinite(se)&&T(Math.min(Math.max(se,1),28))}})]}):null,y==="custom"?a.jsxs("label",{className:"scheduled-task-detail-page__label",children:[a.jsx(b,{size:"2",tone:"muted",children:"Cron expression"}),a.jsx("input",{className:"scheduled-task-detail-page__input",value:R,onChange:B=>{z(B.target.value),I&&Q(null)},placeholder:"0 9 * * 1-5"}),a.jsx(b,{size:"1",tone:"muted",children:"Use 5 fields: minute hour day-of-month month day-of-week."})]}):null,a.jsx(b,{size:"1",tone:"muted",children:"Schedules run using the server timezone."}),I?a.jsx(Zt,{size:"1",children:I}):null,a.jsxs("div",{className:"scheduled-task-detail-page__toggle-row",children:[a.jsx(b,{size:"2",tone:"muted",children:"Status"}),a.jsxs("div",{className:"scheduled-task-detail-page__toggle-buttons",children:[a.jsx(ue,{size:"sm",variant:L?"primary":"secondary",onClick:()=>M(!0),children:"On"}),a.jsx(ue,{size:"sm",variant:L?"secondary":"primary",onClick:()=>M(!1),children:"Off"})]})]})]}),a.jsx(be,{topRight:a.jsxs(b,{size:"1",tone:"muted",children:["Next: ",new Date(Z.nextRunAt).toLocaleString()]}),children:a.jsx(b,{as:"span",size:"2",children:W})}),a.jsx(be,{children:a.jsx(b,{as:"span",size:"2",style:"mono",children:le})})]}),a.jsxs(ye,{className:"scheduled-task-detail-page__actions",children:[a.jsx(ue,{size:"lg",variant:"primary",onClick:me,disabled:N,children:N?"Saving...":"Save schedule"}),a.jsx(ue,{size:"lg",variant:"secondary",onClick:()=>t("/tasks/schedule"),children:"Back to schedules"})]})]})}function RE(){const{taskBlueprintId:n}=Wt(),{user:t}=us(),{showError:i}=ds(),{blueprints:l,blueprintsById:c,loadBlueprint:u,updateBlueprint:f,deleteBlueprint:x}=Nh(),{setSectionTitle:g,tasks:m}=qn(),y=h.useMemo(()=>{if(n)return c[n]||l.find(j=>j.id===n)},[l,c,n]);h.useEffect(()=>{!n||y||u(n).catch(i)},[n,y,u,i]);const _=h.useMemo(()=>{if(y)return{id:y.id,name:y.name,description:y.description,status:_e.NOT_STARTED,assignee:null,assigneeActor:y.assigneeActor??void 0,sessionId:null,comments:[],artefacts:[],inputRequests:[],tags:y.tags,createdByActor:y.createdByActor,dependsOnIds:y.dependsOnIds,createdAt:y.createdAt,updatedAt:y.updatedAt}},[y]),v={addComment:async()=>{throw new Error("Blueprints do not support comments.")},deleteTask:async({taskId:j})=>{await x(j)},assignTask:async({taskId:j,assigneeActorId:k})=>{await f(j,{assigneeActorId:k})},assignTaskToMe:async({taskId:j})=>{if(!t?.actorId)throw new Error("No user session found.");await f(j,{assigneeActorId:t.actorId})},answerInputRequest:async()=>{throw new Error("Blueprints do not support input requests.")},changeStatus:async()=>{throw new Error("Blueprints do not have status updates.")},addTag:async({taskId:j,tag:k})=>{const E=y?.tags?.map(T=>T.name)??[],w=E.includes(k.name)?E:[...E,k.name];await f(j,{tagNames:w})},removeTag:async({taskId:j,tagId:k})=>{const w=(y?.tags??[]).filter(T=>T.id!==k).map(T=>T.name);await f(j,{tagNames:w})},addDependency:async({taskId:j,dependencyTaskId:k})=>{const w=[...y?.dependsOnIds??[],k];await f(j,{dependsOnIds:w})},removeDependency:async({taskId:j,dependencyTaskId:k})=>{const w=(y?.dependsOnIds??[]).filter(T=>T!==k);await f(j,{dependsOnIds:w})}};return a.jsx(Tv,{task:_,backPath:"/tasks/schedule",setSectionTitle:g,handlers:v,allTasks:m})}function zE(){return a.jsx(_E,{children:a.jsx(Kt,{})})}function DE(){return a.jsx(j1,{children:a.jsx(dn,{children:a.jsxs(Se,{element:a.jsx(D1,{}),children:[a.jsx(Se,{index:!0,element:a.jsx(Ia,{to:"/tasks/not-started",replace:!0})}),a.jsx(Se,{path:"not-started",element:a.jsx(Ao,{status:_e.NOT_STARTED})}),a.jsx(Se,{path:"in-progress",element:a.jsx(Ao,{status:_e.IN_PROGRESS})}),a.jsx(Se,{path:"in-review",element:a.jsx(Ao,{status:_e.FOR_REVIEW})}),a.jsx(Se,{path:"done",element:a.jsx(Ao,{status:_e.DONE})}),a.jsx(Se,{path:"dependencies",element:a.jsx(Gy,{})}),a.jsx(Se,{path:"dependencies/:taskId",element:a.jsx(Gy,{})}),a.jsx(Se,{path:"task/:d",element:a.jsx(K1,{})}),a.jsxs(Se,{element:a.jsx(zE,{}),children:[a.jsx(Se,{path:"schedule",element:a.jsx(CE,{})}),a.jsx(Se,{path:"schedule/:scheduleId",element:a.jsx(AE,{})}),a.jsx(Se,{path:"blueprints/:taskBlueprintId",element:a.jsx(RE,{})})]})]})})})}function OE(){const{logout:n}=us(),t=ze();return h.useEffect(()=>{(async()=>{try{await n()}finally{t("/login",{replace:!0})}})()},[n,t]),null}const LE=window.location.origin,Mv=new Ws({baseUrl:LE,credentials:"include"}),qa=Mv.context;Mv.context;const qv=pa("/context"),Xi={CONTEXT_BLOCK_CREATED:"context.block.created",CONTEXT_BLOCK_UPDATED:"context.block.updated",CONTEXT_BLOCK_DELETED:"context.block.deleted"};function ME(){const[n,t]=h.useState([]),[i,l]=h.useState(!0),[c,u]=h.useState(null),[f,x]=h.useState(!1),g=v=>[...v].sort((j,k)=>{const E=new Date(j.updatedAt).getTime();return new Date(k.updatedAt).getTime()-E}),m=async()=>{try{l(!0),u(null);const v=await qa.ContextController_listBlocks();t(g(v.items))}catch(v){u(v instanceof Error?v.message:"Failed to fetch context blocks"),console.error("Error fetching context blocks:",v)}finally{l(!1)}},y=()=>{const v=Bs(qv,{transports:["websocket","polling"],withCredentials:!0});return v.on("connect",()=>{console.log("Connected to context WebSocket"),v.emit("context.subscribe",{},j=>{j.ok?(console.log("Subscribed to context room:",j.room),x(!0)):(console.error("Failed to subscribe to context room"),x(!1))}),m()}),v.on("disconnect",()=>{console.log("Context WebSocket disconnected"),x(!1)}),v.on("connect_error",j=>{console.error("Context websocket connect_error",j.message)}),v.on(Xi.CONTEXT_BLOCK_CREATED,j=>{console.log("context.block.created",j),t(k=>k.some(E=>E.id===j.payload.id)?k:g([j.payload,...k]))}),v.on(Xi.CONTEXT_BLOCK_UPDATED,j=>{console.log("context.block.updated",j),t(k=>g(k.map(E=>E.id===j.payload.id?j.payload:E)))}),v.on(Xi.CONTEXT_BLOCK_DELETED,j=>{console.log("context.block.deleted",j),t(k=>k.filter(E=>E.id!==j.payload.blockId))}),()=>{v.emit("context.unsubscribe",{}),v.close()}},_=h.useCallback(async v=>{try{const j=await qa.ContextController_getBlock({id:v});return t(k=>k.some(E=>E.id===j.id)?k:g([j,...k])),j}catch(j){return console.error("Failed to fetch block by ID",j),null}},[]);return h.useEffect(()=>(m(),y()),[]),{blocks:n,getBlockById:_,isLoading:i,error:c,isConnected:f,reload:m}}function qE(n){const[t,i]=h.useState(null),[l,c]=h.useState(!0),[u,f]=h.useState(null),[x,g]=h.useState(!1),m=h.useCallback(async()=>{try{c(!0),f(null);const y=await qa.ContextController_getBlock({id:n});i(y),g(!1)}catch(y){f(y instanceof Error?y.message:"Failed to fetch context block"),console.error("Error fetching context block:",y)}finally{c(!1)}},[n]);return h.useEffect(()=>{n&&m()},[n,m]),h.useEffect(()=>{if(!n)return;const y=Bs(qv,{transports:["websocket","polling"],withCredentials:!0});return y.on("connect",()=>{console.log("Connected to context WebSocket (detail page)"),y.emit("context.subscribe",{blockId:n},_=>{_.ok?(console.log("Subscribed to context room (detail page):",_.room),m()):console.error("Failed to subscribe to context room (detail page)",_.error)})}),y.on("connect_error",_=>{console.error("Context detail websocket connect_error",_.message)}),y.on("disconnect",()=>{console.log("Context WebSocket disconnected (detail page)")}),y.on(Xi.CONTEXT_BLOCK_UPDATED,_=>{_.payload.id===n&&(console.log("context.block.updated (detail page)",_),m().catch(v=>console.error("Error refreshing block after update:",v)))}),y.on(Xi.CONTEXT_BLOCK_DELETED,_=>{_.payload.blockId===n&&(console.log("context.block.deleted (detail page)",_),g(!0),i(null))}),()=>{y.emit("context.unsubscribe",{blockId:n}),y.close()}},[n,m]),{block:t,isLoading:l,error:u,isDeleted:x}}const Iv=h.createContext(null);function IE({children:n}){const{blocks:t,getBlockById:i,isLoading:l,error:c,isConnected:u,reload:f}=ME(),[x,g]=h.useState(""),m=h.useMemo(()=>({blocks:t,getBlockById:i,isLoading:l,error:c,isConnected:u,reload:f,sectionTitle:x,setSectionTitle:g}),[t,i,l,c,u,f,x,g]);return a.jsx(Iv.Provider,{value:m,children:n})}function ac(){const n=h.useContext(Iv);if(!n)throw new Error("useContextCtx must be used within <ContextProvider>");return n}const BE=6;function Bv(n){return typeof n=="string"?n:n&&typeof n=="object"&&"id"in n&&typeof n.id=="string"?n.id:null}function Ky(n,t){return n.order!==t.order?t.order-n.order:n.title.localeCompare(t.title)}function UE(n){const t=new Map;n.forEach(u=>{t.set(u.id,{block:u,children:[],latestUpdatedAt:new Date(u.updatedAt).getTime()})});const i=[];n.forEach(u=>{const f=t.get(u.id);if(!f)return;const x=Bv(u.parentId);if(!x){i.push(f);return}const g=t.get(x);if(!g){i.push(f);return}g.children.push(f)});const l=u=>{u.sort((f,x)=>Ky(f.block,x.block)),u.forEach(f=>l(f.children))};l(i);const c=u=>{if(u.children.length===0)return u.latestUpdatedAt;let f=u.latestUpdatedAt;return u.children.forEach(x=>{const g=c(x);g>f&&(f=g)}),u.latestUpdatedAt=f,f};return i.forEach(u=>{c(u)}),i.sort((u,f)=>{const x=f.latestUpdatedAt-u.latestUpdatedAt;return x!==0?x:Ky(u.block,f.block)}),i}function Uv({nodes:n,depth:t,onOpenBlock:i,onAddChild:l,collapsedIds:c,onToggleNode:u,selectedBlockId:f,compact:x=!1}){return a.jsx("ul",{className:"context-tree__branch",role:t===0?"tree":"group",children:n.map(g=>{const m=g.children.length>0,y=m?!c.has(g.block.id):!1,_=Math.min(t,BE),v=f===g.block.id;return a.jsxs("li",{className:"context-tree__item",role:"treeitem","aria-expanded":m?y:void 0,children:[a.jsxs("div",{className:`context-tree__row ${v?"context-tree__row--selected":""} ${x?"context-tree__row--compact":""}`,style:{"--tree-depth":_},children:[m?a.jsx("button",{type:"button",className:"context-tree__toggle","aria-expanded":y,"aria-label":y?`Collapse ${g.block.title}`:`Expand ${g.block.title}`,onClick:()=>u(g.block.id),children:a.jsx("span",{className:"context-tree__marker","aria-hidden":"true",children:y?"▼":"►"})}):a.jsx("span",{className:"context-tree__spacer","aria-hidden":"true"}),a.jsxs("button",{type:"button",className:"context-tree__open",onClick:()=>i(g.block.id),children:[a.jsxs("div",{className:"context-tree__main",children:[a.jsx(b,{weight:v?"bold":"medium",size:x?"2":"3",tone:"default",className:"context-tree__title",children:g.block.title}),x?null:a.jsxs("div",{className:"context-tree__meta",children:[a.jsxs("span",{className:"context-tree__id",children:["#",g.block.id.slice(0,6)]}),a.jsx("span",{children:g.block.createdBy||"unknown"})]})]}),!x&&g.block.tags.length>0?a.jsxs("div",{className:"context-tree__tags","aria-label":"Block tags",children:[g.block.tags.slice(0,2).map(j=>a.jsx("span",{className:"context-tree__tag",children:j.name},`${g.block.id}-${j.id}`)),g.block.tags.length>2?a.jsxs("span",{className:"context-tree__tag context-tree__tag--count",children:["+",g.block.tags.length-2]}):null]}):null]}),l?a.jsx("button",{type:"button",className:"context-tree__add-child","aria-label":`Add child block under ${g.block.title}`,onClick:j=>{j.stopPropagation(),l(g.block.id)},children:"+"}):null]}),m&&y?a.jsx(Uv,{nodes:g.children,depth:t+1,onOpenBlock:i,onAddChild:l,collapsedIds:c,onToggleNode:u,selectedBlockId:f,compact:x}):null]},g.block.id)})})}function Xy(n){const t=new Set,i=l=>{for(const c of l)c.children.length>0&&(t.add(c.block.id),i(c.children))};return i(n),t}function $v({blocks:n,onOpenBlock:t,onAddChild:i,selectedBlockId:l,compact:c=!1}){const u=h.useMemo(()=>UE(n),[n]),[f,x]=h.useState(()=>Xy(u)),g=h.useRef(!1);h.useEffect(()=>{!g.current&&u.length>0&&(x(Xy(u)),g.current=!0)},[u]),h.useEffect(()=>{if(!l)return;const y=new Map;n.forEach(j=>{y.set(j.id,Bv(j.parentId))});const _=new Set;let v=y.get(l)??null;for(;v;)_.add(v),v=y.get(v)??null;_.size!==0&&x(j=>{const k=new Set(j);return _.forEach(E=>k.delete(E)),k})},[n,l]);const m=y=>{x(_=>{const v=new Set(_);return v.has(y)?v.delete(y):v.add(y),v})};return a.jsx("section",{className:`context-tree ${c?"context-tree--compact":""}`,children:a.jsx(Uv,{nodes:u,depth:0,onOpenBlock:t,onAddChild:i,collapsedIds:f,onToggleNode:m,selectedBlockId:l,compact:c})})}function $E(){const n=Rt(),{sectionTitle:t,blocks:i,isLoading:l,error:c}=ac(),u=ze(),f=qt(),{id:x}=Wt(),[g,m]=h.useState(!1),[y,_]=h.useState(!1);return h.useEffect(()=>{if(!n)return;const v=localStorage.getItem("context-sidebar-collapsed");m(v==="true")},[n]),h.useEffect(()=>{n&&localStorage.setItem("context-sidebar-collapsed",String(g))},[n,g]),h.useEffect(()=>{_(!1)},[f.pathname]),a.jsxs("div",{className:`context-layout ${n?"context-layout--desktop":"context-layout--mobile"}`,children:[!n&&a.jsxs(a.Fragment,{children:[y&&a.jsx("div",{className:"context-layout__drawer-overlay",onClick:()=>_(!1)}),a.jsxs("aside",{className:`context-layout__drawer ${y?"context-layout__drawer--open":""}`,children:[a.jsxs("div",{className:"context-layout__drawer-header",children:[a.jsx(b,{size:"4",weight:"bold",children:"taico"}),a.jsx("button",{className:"context-layout__drawer-close",onClick:()=>_(!1),"aria-label":"Close menu",children:"✕"})]}),a.jsx("nav",{className:"context-layout__drawer-nav",children:zr.map(v=>{const j=f.pathname===v.path||f.pathname.startsWith(v.path+"/");return a.jsxs(Mn,{to:v.path,className:`context-layout__drawer-item ${j?"context-layout__drawer-item--active":""}`,children:[a.jsx(al,{icon:v.icon,className:"context-layout__drawer-icon"}),a.jsx("span",{children:v.label})]},v.path)})})]})]}),!n&&a.jsx("header",{className:"context-layout__mobile-header",children:a.jsxs(Mt,{spacing:"5",align:"center",children:[a.jsx("button",{className:"context-layout__hamburger",onClick:()=>_(!0),"aria-label":"Open menu",children:"☰"}),a.jsx(b,{size:"3",weight:"normal",as:"div",children:"Context"}),a.jsx(b,{size:"3",weight:"semibold",as:"div",className:"context-layout__mobile-section-title",children:t})]})}),n&&a.jsxs("aside",{className:`context-desktop__sidebar ${g?"context-desktop__sidebar--collapsed":""}`,children:[a.jsx("div",{className:"context-desktop__sidebar-header",children:g?a.jsx(b,{as:"div",size:"1",tone:"muted",children:i.length}):a.jsxs(a.Fragment,{children:[a.jsx("button",{type:"button",className:"context-desktop__sidebar-title",onClick:()=>u("/context/home"),children:a.jsx(b,{as:"span",size:"2",weight:"semibold",children:"Context"})}),a.jsxs("div",{className:"context-desktop__sidebar-header-actions",children:[a.jsx(b,{as:"div",size:"1",tone:"muted",children:i.length}),a.jsx("button",{type:"button",className:"context-desktop__sidebar-new",onClick:()=>u("/context/new"),"aria-label":"New block",title:"New block",children:"+"})]})]})}),a.jsx("div",{className:"context-desktop__sidebar-body",children:g?null:l?a.jsx("div",{className:"context-home__loading",children:"Loading context blocks..."}):c?a.jsxs("div",{className:"context-home__error",children:["Error: ",c]}):i.length===0?a.jsx("div",{className:"context-home__empty",children:"No context blocks found"}):a.jsx($v,{blocks:i,onOpenBlock:v=>u(`/context/block/${v}`),onAddChild:v=>u(`/context/new?parentId=${v}`),selectedBlockId:x,compact:!0})}),a.jsx("button",{type:"button",className:"context-desktop__sidebar-toggle",onClick:()=>m(v=>!v),"aria-label":g?"Expand context sidebar":"Collapse context sidebar",children:g?"→":"←"})]}),a.jsx("main",{className:"context-layout__main",children:a.jsx(Kt,{})})]})}function HE(){const{setSectionTitle:n,blocks:t,isLoading:i,error:l}=ac(),c=ze(),u=Rt(),[f,x]=h.useState("");return jt(),h.useEffect(()=>{n("Context")},[n]),i?a.jsx("div",{className:"context-home__loading",children:"Loading context blocks..."}):l?a.jsxs("div",{className:"context-home__error",children:["Error: ",l]}):t.length===0?a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"context-home__empty",children:a.jsx("div",{className:"context-home__empty-message",children:"No context blocks found"})}),a.jsx(Id,{onClick:()=>c("/context/new"),isDesktop:u})]}):u?a.jsxs(a.Fragment,{children:[a.jsx(PE,{blocks:t,searchQuery:f,onSearchQueryChange:x,onOpenBlock:g=>c(`/context/block/${g}`)}),a.jsx(Id,{onClick:()=>c("/context/new"),isDesktop:u})]}):a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"context-home",children:a.jsx($v,{blocks:t,onOpenBlock:g=>c(`/context/block/${g}`),onAddChild:g=>c(`/context/new?parentId=${g}`)})}),a.jsx(Id,{onClick:()=>c("/context/new"),isDesktop:u})]})}function Id({onClick:n,isDesktop:t}){return t?a.jsxs("button",{className:"context-fab context-fab--desktop",type:"button",onClick:n,children:[a.jsx("span",{className:"context-fab__plus",children:"+"}),a.jsx("span",{className:"context-fab__label",children:"New block"})]}):a.jsx("button",{className:"context-fab",type:"button",onClick:n,"aria-label":"Create new block",children:"+"})}function PE({blocks:n,searchQuery:t,onSearchQueryChange:i,onOpenBlock:l}){const c=t.trim().toLowerCase(),u=h.useMemo(()=>c?n.filter(f=>[f.title,f.createdBy||"",f.id,...f.tags.map(g=>g.name)].some(g=>g.toLowerCase().includes(c))):n.slice(0,18),[n,c]);return a.jsxs("div",{className:"context-home-desktop",children:[a.jsx("div",{className:"context-home-desktop__hero",children:a.jsx(b,{as:"div",size:"6",weight:"bold",className:"context-home-desktop__title",children:"Blocks"})}),a.jsx("div",{className:"context-home-desktop__search-box",children:a.jsx("input",{type:"search",className:"context-home-desktop__search-input",placeholder:"Search by title, tag, author, or block id",value:t,onChange:f=>i(f.target.value)})}),a.jsx("div",{className:"context-home-desktop__results",children:u.length===0?a.jsxs("div",{className:"context-home-desktop__empty",children:[a.jsx(b,{as:"div",size:"3",weight:"medium",children:"No matching blocks"}),a.jsx(b,{as:"div",size:"2",tone:"muted",children:"Try a different title, tag, author, or id fragment."})]}):u.map(f=>a.jsx(be,{className:"context-home-desktop__result",onClick:()=>l(f.id),topRight:a.jsx(b,{as:"span",size:"2",tone:"muted",children:Lt(f.updatedAt)}),tags:f.tags.slice(0,3).map(x=>({label:x.name})),children:a.jsxs("div",{className:"context-home-desktop__result-main",children:[a.jsx("div",{className:"row-title",children:f.title}),a.jsxs("div",{className:"row-detail",children:["#",f.id.slice(0,6)," ",f.createdBy||"unknown"]})]})},f.id))})]})}function Ah(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var Ha=Ah();function Hv(n){Ha=n}var Oa={exec:()=>null};function Ye(n,t=""){let i=typeof n=="string"?n:n.source,l={replace:(c,u)=>{let f=typeof u=="string"?u:u.source;return f=f.replace(ts.caret,"$1"),i=i.replace(c,f),l},getRegex:()=>new RegExp(i,t)};return l}var GE=(()=>{try{return!!new RegExp("(?<=1)(?<!1)")}catch{return!1}})(),ts={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:n=>new RegExp(`^( {0,3}${n})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:n=>new RegExp(`^ {0,${Math.min(3,n-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:n=>new RegExp(`^ {0,${Math.min(3,n-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:n=>new RegExp(`^ {0,${Math.min(3,n-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:n=>new RegExp(`^ {0,${Math.min(3,n-1)}}#`),htmlBeginRegex:n=>new RegExp(`^ {0,${Math.min(3,n-1)}}<(?:[a-z].*>|!--)`,"i"),blockquoteBeginRegex:n=>new RegExp(`^ {0,${Math.min(3,n-1)}}>`)},VE=/^(?:[ \t]*(?:\n|$))+/,FE=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,YE=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,ll=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,QE=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,Rh=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,Pv=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Gv=Ye(Pv).replace(/bull/g,Rh).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),KE=Ye(Pv).replace(/bull/g,Rh).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),zh=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,XE=/^[^\n]+/,Dh=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,ZE=Ye(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Dh).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),WE=Ye(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,Rh).getRegex(),rc="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",Oh=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,JE=Ye("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",Oh).replace("tag",rc).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Vv=Ye(zh).replace("hr",ll).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",rc).getRegex(),eC=Ye(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",Vv).getRegex(),Lh={blockquote:eC,code:FE,def:ZE,fences:YE,heading:QE,hr:ll,html:JE,lheading:Gv,list:WE,newline:VE,paragraph:Vv,table:Oa,text:XE},Zy=Ye("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",ll).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",rc).getRegex(),tC={...Lh,lheading:KE,table:Zy,paragraph:Ye(zh).replace("hr",ll).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",Zy).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",rc).getRegex()},sC={...Lh,html:Ye(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Oh).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:Oa,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:Ye(zh).replace("hr",ll).replace("heading",` *#{1,6} *[^
|
|
13
13
|
]`).replace("lheading",Gv).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},nC=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,aC=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,Fv=/^( {2,}|\\)\n(?!\s*$)/,rC=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,Pr=/[\p{P}\p{S}]/u,ic=/[\s\p{P}\p{S}]/u,Mh=/[^\s\p{P}\p{S}]/u,iC=Ye(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,ic).getRegex(),Yv=/(?!~)[\p{P}\p{S}]/u,lC=/(?!~)[\s\p{P}\p{S}]/u,oC=/(?:[^\s\p{P}\p{S}]|~)/u,cC=Ye(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",GE?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),Qv=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,uC=Ye(Qv,"u").replace(/punct/g,Pr).getRegex(),dC=Ye(Qv,"u").replace(/punct/g,Yv).getRegex(),Kv="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",hC=Ye(Kv,"gu").replace(/notPunctSpace/g,Mh).replace(/punctSpace/g,ic).replace(/punct/g,Pr).getRegex(),fC=Ye(Kv,"gu").replace(/notPunctSpace/g,oC).replace(/punctSpace/g,lC).replace(/punct/g,Yv).getRegex(),pC=Ye("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,Mh).replace(/punctSpace/g,ic).replace(/punct/g,Pr).getRegex(),gC=Ye(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,Pr).getRegex(),mC="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",yC=Ye(mC,"gu").replace(/notPunctSpace/g,Mh).replace(/punctSpace/g,ic).replace(/punct/g,Pr).getRegex(),xC=Ye(/\\(punct)/,"gu").replace(/punct/g,Pr).getRegex(),vC=Ye(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),bC=Ye(Oh).replace("(?:-->|$)","-->").getRegex(),_C=Ye("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",bC).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),Qo=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,SC=Ye(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",Qo).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Xv=Ye(/^!?\[(label)\]\[(ref)\]/).replace("label",Qo).replace("ref",Dh).getRegex(),Zv=Ye(/^!?\[(ref)\](?:\[\])?/).replace("ref",Dh).getRegex(),jC=Ye("reflink|nolink(?!\\()","g").replace("reflink",Xv).replace("nolink",Zv).getRegex(),Wy=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,qh={_backpedal:Oa,anyPunctuation:xC,autolink:vC,blockSkip:cC,br:Fv,code:aC,del:Oa,delLDelim:Oa,delRDelim:Oa,emStrongLDelim:uC,emStrongRDelimAst:hC,emStrongRDelimUnd:pC,escape:nC,link:SC,nolink:Zv,punctuation:iC,reflink:Xv,reflinkSearch:jC,tag:_C,text:rC,url:Oa},kC={...qh,link:Ye(/^!?\[(label)\]\((.*?)\)/).replace("label",Qo).getRegex(),reflink:Ye(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",Qo).getRegex()},sh={...qh,emStrongRDelimAst:fC,emStrongLDelim:dC,delLDelim:gC,delRDelim:yC,url:Ye(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",Wy).replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:Ye(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",Wy).getRegex()},TC={...sh,br:Ye(Fv).replace("{2,}","*").getRegex(),text:Ye(sh.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},Do={normal:Lh,gfm:tC,pedantic:sC},Hi={normal:qh,gfm:sh,breaks:TC,pedantic:kC},wC={"&":"&","<":"<",">":">",'"':""","'":"'"},Jy=n=>wC[n];function rn(n,t){if(t){if(ts.escapeTest.test(n))return n.replace(ts.escapeReplace,Jy)}else if(ts.escapeTestNoEncode.test(n))return n.replace(ts.escapeReplaceNoEncode,Jy);return n}function ex(n){try{n=encodeURI(n).replace(ts.percentDecode,"%")}catch{return null}return n}function tx(n,t){let i=n.replace(ts.findPipe,(u,f,x)=>{let g=!1,m=f;for(;--m>=0&&x[m]==="\\";)g=!g;return g?"|":" |"}),l=i.split(ts.splitPipe),c=0;if(l[0].trim()||l.shift(),l.length>0&&!l.at(-1)?.trim()&&l.pop(),t)if(l.length>t)l.splice(t);else for(;l.length<t;)l.push("");for(;c<l.length;c++)l[c]=l[c].trim().replace(ts.slashPipe,"|");return l}function Pi(n,t,i){let l=n.length;if(l===0)return"";let c=0;for(;c<l&&n.charAt(l-c-1)===t;)c++;return n.slice(0,l-c)}function EC(n,t){if(n.indexOf(t[1])===-1)return-1;let i=0;for(let l=0;l<n.length;l++)if(n[l]==="\\")l++;else if(n[l]===t[0])i++;else if(n[l]===t[1]&&(i--,i<0))return l;return i>0?-2:-1}function CC(n,t=0){let i=t,l="";for(let c of n)if(c===" "){let u=4-i%4;l+=" ".repeat(u),i+=u}else l+=c,i++;return l}function sx(n,t,i,l,c){let u=t.href,f=t.title||null,x=n[1].replace(c.other.outputLinkReplace,"$1");l.state.inLink=!0;let g={type:n[0].charAt(0)==="!"?"image":"link",raw:i,href:u,title:f,text:x,tokens:l.inlineTokens(x)};return l.state.inLink=!1,g}function NC(n,t,i){let l=n.match(i.other.indentCodeCompensation);if(l===null)return t;let c=l[1];return t.split(`
|
|
14
14
|
`).map(u=>{let f=u.match(i.other.beginningSpace);if(f===null)return u;let[x]=f;return x.length>=c.length?u.slice(c.length):u}).join(`
|
|
15
15
|
`)}var Ko=class{options;rules;lexer;constructor(n){this.options=n||Ha}space(n){let t=this.rules.block.newline.exec(n);if(t&&t[0].length>0)return{type:"space",raw:t[0]}}code(n){let t=this.rules.block.code.exec(n);if(t){let i=t[0].replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:t[0],codeBlockStyle:"indented",text:this.options.pedantic?i:Pi(i,`
|