@vibedeckx/ui-dist 0.3.58 → 0.3.60

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/package.json +1 -1
  2. package/ui/404/index.html +2 -2
  3. package/ui/404.html +2 -2
  4. package/ui/__next.__PAGE__.txt +2 -2
  5. package/ui/__next._full.txt +15 -15
  6. package/ui/__next._head.txt +1 -1
  7. package/ui/__next._index.txt +7 -7
  8. package/ui/__next._tree.txt +9 -9
  9. package/ui/_next/static/chunks/0e993169304221bb.js +61 -0
  10. package/ui/_next/static/chunks/79f0dd146e2b507d.css +5 -0
  11. package/ui/_next/static/chunks/8034edb096bd186c.css +1 -0
  12. package/ui/_next/static/chunks/{a2d73337cfa8d439.js → 962476ea88adce27.js} +3 -3
  13. package/ui/_next/static/media/geist_latin_wght_normal-s.p.e574545b.woff2 +0 -0
  14. package/ui/_next/static/media/geist_mono_latin_wght_normal-s.p.2fc7e6c4.woff2 +0 -0
  15. package/ui/_next/static/media/instrument_serif_latin_400_italic-s.p.b1508682.woff2 +0 -0
  16. package/ui/_next/static/media/instrument_serif_latin_400_normal-s.p.60c916e2.woff2 +0 -0
  17. package/ui/_next/static/media/inter_latin_wght_normal-s.p.c757f81b.woff2 +0 -0
  18. package/ui/_next/static/media/jetbrains_mono_latin_wght_normal-s.p.1afd078f.woff2 +0 -0
  19. package/ui/_not-found/__next._full.txt +7 -7
  20. package/ui/_not-found/__next._head.txt +1 -1
  21. package/ui/_not-found/__next._index.txt +7 -7
  22. package/ui/_not-found/__next._not-found.__PAGE__.txt +1 -1
  23. package/ui/_not-found/__next._not-found.txt +1 -1
  24. package/ui/_not-found/__next._tree.txt +3 -3
  25. package/ui/_not-found/index.html +2 -2
  26. package/ui/_not-found/index.txt +7 -7
  27. package/ui/build-id.json +1 -1
  28. package/ui/index.html +2 -2
  29. package/ui/index.txt +15 -15
  30. package/ui/_next/static/chunks/17d604f0ddd0b318.css +0 -1
  31. package/ui/_next/static/chunks/22001ed4fb088143.css +0 -5
  32. package/ui/_next/static/chunks/c13918585c623f38.js +0 -61
  33. package/ui/_next/static/media/04c5164763c40239-s.690580e8.woff2 +0 -0
  34. package/ui/_next/static/media/051742360c26797e-s.p.102b7f24.woff2 +0 -0
  35. package/ui/_next/static/media/1bffadaabf893a1e-s.7cd81963.woff2 +0 -0
  36. package/ui/_next/static/media/26f284dcc38c84c0-s.303a03d6.woff2 +0 -0
  37. package/ui/_next/static/media/2bbe8d2671613f1f-s.76dcb0b2.woff2 +0 -0
  38. package/ui/_next/static/media/2c55a0e60120577a-s.2a48534a.woff2 +0 -0
  39. package/ui/_next/static/media/4fa387ec64143e14-s.3b336396.woff2 +0 -0
  40. package/ui/_next/static/media/53b9e256198e5412-s.853d50a3.woff2 +0 -0
  41. package/ui/_next/static/media/5476f68d60460930-s.c995e352.woff2 +0 -0
  42. package/ui/_next/static/media/5ce348bf30bf5439-s.56c1f21e.woff2 +0 -0
  43. package/ui/_next/static/media/6306c77e7c8268e4-s.e3369375.woff2 +0 -0
  44. package/ui/_next/static/media/6a5386fd6038edbe-s.719084df.woff2 +0 -0
  45. package/ui/_next/static/media/7178b3e590c64307-s.55554cd0.woff2 +0 -0
  46. package/ui/_next/static/media/797e433ab948586e-s.p.29207c2f.woff2 +0 -0
  47. package/ui/_next/static/media/7d817b4c03b0c5f1-s.a40b9a8b.woff2 +0 -0
  48. package/ui/_next/static/media/7e7f32a39836f228-s.0b4edfe7.woff2 +0 -0
  49. package/ui/_next/static/media/7ebf22b5a21034f8-s.p.d8bad3ab.woff2 +0 -0
  50. package/ui/_next/static/media/83afe278b6a6bb3c-s.p.3a6ba036.woff2 +0 -0
  51. package/ui/_next/static/media/8a480f0b521d4e75-s.ea323500.woff2 +0 -0
  52. package/ui/_next/static/media/9c72aa0f40e4eef8-s.18a48cbc.woff2 +0 -0
  53. package/ui/_next/static/media/ad66f9afd8947f86-s.7a40eb73.woff2 +0 -0
  54. package/ui/_next/static/media/bbc41e54d2fcbd21-s.fe42ddf4.woff2 +0 -0
  55. package/ui/_next/static/media/caa3a2e1cccd8315-s.p.3b6cae6d.woff2 +0 -0
  56. package/ui/_next/static/media/ccf27e5a7366fb23-s.262b87c4.woff2 +0 -0
  57. package/ui/_next/static/media/e41d5df559864f9e-s.p.380d09ea.woff2 +0 -0
  58. package/ui/_next/static/media/fa39153a3fc630ba-s.bff0868b.woff2 +0 -0
  59. package/ui/_next/static/media/fc0a7394b875fa43-s.614a1c00.woff2 +0 -0
  60. package/ui/_next/static/media/fef07dbb0973bf53-s.518e079e.woff2 +0 -0
  61. /package/ui/_next/static/{taMuyBo0-yy3yTQPOeFmC → OXtomahTgA81gvV3rfOIR}/_buildManifest.js +0 -0
  62. /package/ui/_next/static/{taMuyBo0-yy3yTQPOeFmC → OXtomahTgA81gvV3rfOIR}/_clientMiddlewareManifest.json +0 -0
  63. /package/ui/_next/static/{taMuyBo0-yy3yTQPOeFmC → OXtomahTgA81gvV3rfOIR}/_ssgManifest.js +0 -0
@@ -0,0 +1,61 @@
1
+ (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,263686,(e,r,s)=>{r.exports=(()=>{"use strict";var e,r,s={6949(e,r,s){Object.defineProperty(r,"__esModule",{value:!0}),r.CronParser=void 0;var n=s(9515);r.CronParser=function(){function e(e,r,s){void 0===r&&(r=!0),void 0===s&&(s=!1),this.expression=e,this.dayOfWeekStartIndexZero=r,this.monthStartIndexZero=s}return e.prototype.parse=function(){var e,r,s=null!=(e=this.expression)?e:"";if("@reboot"===s)return["@reboot","","","","","",""];if(s.startsWith("@")){var n=this.parseSpecial(this.expression);r=this.extractParts(n)}else r=this.extractParts(this.expression);return this.normalize(r),this.validate(r),r},e.prototype.parseSpecial=function(e){var r={"@yearly":"0 0 1 1 *","@annually":"0 0 1 1 *","@monthly":"0 0 1 * *","@weekly":"0 0 * * 0","@daily":"0 0 * * *","@midnight":"0 0 * * *","@hourly":"0 * * * *","@reboot":"@reboot"}[e];if(!r)throw Error("Unknown special expression.");return r},e.prototype.extractParts=function(e){if(!this.expression)throw Error("cron expression is empty");for(var r=e.trim().split(/[ ]+/),s=0;s<r.length;s++)if(r[s].includes(",")){var n=r[s].split(",").map(function(e){return e.trim()}).filter(function(e){return""!==e}).map(function(e){return isNaN(Number(e))?e:Number(e)}).filter(function(e){return null!==e&&""!==e});0===n.length&&n.push("*"),n.sort(function(e,r){return null!==e&&null!==r?e-r:0}),r[s]=n.map(function(e){return null!==e?e.toString():""}).join(",")}if(r.length<5)throw Error("Expression has only ".concat(r.length," part").concat(1==r.length?"":"s",". At least 5 parts are required."));if(5==r.length)r.unshift(""),r.push("");else if(6==r.length)/\d{4}$/.test(r[5])||"?"==r[4]||"?"==r[2]?r.unshift(""):r.push("");else if(r.length>7)throw Error("Expression has ".concat(r.length," parts; too many!"));return r},e.prototype.normalize=function(e){var r=this;if(e[3]=e[3].replace("?","*"),e[5]=e[5].replace("?","*"),e[2]=e[2].replace("?","*"),0==e[0].indexOf("0/")&&(e[0]=e[0].replace("0/","*/")),0==e[1].indexOf("0/")&&(e[1]=e[1].replace("0/","*/")),0==e[2].indexOf("0/")&&(e[2]=e[2].replace("0/","*/")),0==e[3].indexOf("1/")&&(e[3]=e[3].replace("1/","*/")),0==e[4].indexOf("1/")&&(e[4]=e[4].replace("1/","*/")),0==e[6].indexOf("1/")&&(e[6]=e[6].replace("1/","*/")),e[5]=e[5].replace(/(^\d)|([^#/\s]\d)/g,function(e){var s=e.replace(/\D/,""),n=s;return r.dayOfWeekStartIndexZero?"7"==s&&(n="0"):n=(parseInt(s)-1).toString(),e.replace(s,n)}),"L"==e[5]&&(e[5]="6"),"?"==e[3]&&(e[3]="*"),e[3].indexOf("W")>-1&&(e[3].indexOf(",")>-1||e[3].indexOf("-")>-1))throw Error("The 'W' character can be specified only when the day-of-month is a single day, not a range or list of days.");var s={SUN:0,MON:1,TUE:2,WED:3,THU:4,FRI:5,SAT:6};for(var n in s)e[5]=e[5].replace(RegExp(n,"gi"),s[n].toString());e[4]=e[4].replace(/(^\d{1,2})|([^#/\s]\d{1,2})/g,function(e){var s=e.replace(/\D/,""),n=s;return r.monthStartIndexZero&&(n=(parseInt(s)+1).toString()),e.replace(s,n)});var i={JAN:1,FEB:2,MAR:3,APR:4,MAY:5,JUN:6,JUL:7,AUG:8,SEP:9,OCT:10,NOV:11,DEC:12};for(var a in i)e[4]=e[4].replace(RegExp(a,"gi"),i[a].toString());"0"==e[0]&&(e[0]=""),!/\*|\-|\,|\//.test(e[2])&&(/\*|\//.test(e[1])||/\*|\//.test(e[0]))&&(e[2]+="-".concat(e[2]));for(var o=0;o<e.length;o++)if(-1!=e[o].indexOf(",")&&(e[o]=e[o].split(",").filter(function(e){return""!==e}).join(",")||"*"),"*/1"==e[o]&&(e[o]="*"),e[o].indexOf("/")>-1&&!/^\*|\-|\,/.test(e[o])){var l=null;switch(o){case 4:l="12";break;case 5:l="6";break;case 6:l="9999";break;default:l=null}if(null!==l){var c=e[o].split("/");e[o]="".concat(c[0],"-").concat(l,"/").concat(c[1])}}},e.prototype.validate=function(e){var r="0-9,\\-*/";this.validateOnlyExpectedCharactersFound(e[0],r),this.validateOnlyExpectedCharactersFound(e[1],r),this.validateOnlyExpectedCharactersFound(e[2],r),this.validateOnlyExpectedCharactersFound(e[3],"0-9,\\-*/LW"),this.validateOnlyExpectedCharactersFound(e[4],r),this.validateOnlyExpectedCharactersFound(e[5],"0-9,\\-*/L#"),this.validateOnlyExpectedCharactersFound(e[6],r),this.validateAnyRanges(e)},e.prototype.validateAnyRanges=function(e){n.default.secondRange(e[0]),n.default.minuteRange(e[1]),n.default.hourRange(e[2]),n.default.dayOfMonthRange(e[3]),n.default.monthRange(e[4],this.monthStartIndexZero),n.default.dayOfWeekRange(e[5],this.dayOfWeekStartIndexZero)},e.prototype.validateOnlyExpectedCharactersFound=function(e,r){var s=e.match(RegExp("[^".concat(r,"]+"),"gi"));if(s&&s.length)throw Error("Expression contains invalid values: '".concat(s.toString(),"'"))},e}()},8333(e,r,s){Object.defineProperty(r,"__esModule",{value:!0}),r.ExpressionDescriptor=void 0;var n=s(1823),i=s(6949);r.ExpressionDescriptor=function(){function e(r,s){if(this.expression=r,this.options=s,this.expressionParts=[,,,,,],!this.options.locale&&e.defaultLocale&&(this.options.locale=e.defaultLocale),!e.locales[this.options.locale]){var n=Object.keys(e.locales)[0];console.warn("Locale '".concat(this.options.locale,"' could not be found; falling back to '").concat(n,"'.")),this.options.locale=n}this.i18n=e.locales[this.options.locale],void 0===s.use24HourTimeFormat&&(s.use24HourTimeFormat=this.i18n.use24HourTimeFormatByDefault())}return e.toString=function(r,s){var n=void 0===s?{}:s,i=n.throwExceptionOnParseError,a=n.verbose,o=n.dayOfWeekStartIndexZero,l=n.monthStartIndexZero,c=n.use24HourTimeFormat,d=n.trimHoursLeadingZero,u=n.locale,h=n.logicalAndDayFields,f={throwExceptionOnParseError:void 0===i||i,verbose:void 0!==a&&a,dayOfWeekStartIndexZero:void 0===o||o,monthStartIndexZero:void 0!==l&&l,use24HourTimeFormat:c,trimHoursLeadingZero:void 0!==d&&d,locale:void 0===u?null:u,logicalAndDayFields:void 0!==h&&h};return f.tzOffset&&console.warn("'tzOffset' option has been deprecated and is no longer supported."),new e(r,f).getFullDescription()},e.initialize=function(r,s){void 0===s&&(s="en"),e.specialCharacters=["/","-",",","*"],e.defaultLocale=s,r.load(e.locales)},e.prototype.getFullDescription=function(){var e,r,s="";try{var n=new i.CronParser(this.expression,this.options.dayOfWeekStartIndexZero,this.options.monthStartIndexZero);if(this.expressionParts=n.parse(),"@reboot"===this.expressionParts[0])return(null==(r=(e=this.i18n).atReboot)?void 0:r.call(e))||"Run once, at startup";var a=this.getTimeOfDayDescription(),o=this.getDayOfMonthDescription(),l=this.getMonthDescription(),c=this.getDayOfWeekDescription(),d=this.getYearDescription();s+=a+o+c+l+d,s=(s=this.transformVerbosity(s,!!this.options.verbose)).charAt(0).toLocaleUpperCase()+s.substr(1)}catch(e){if(this.options.throwExceptionOnParseError)throw"".concat(e);s=this.i18n.anErrorOccuredWhenGeneratingTheExpressionD()}return s},e.prototype.getTimeOfDayDescription=function(){var r=this.expressionParts[0],s=this.expressionParts[1],i=this.expressionParts[2],a="";if(n.StringUtilities.containsAny(s,e.specialCharacters)||n.StringUtilities.containsAny(i,e.specialCharacters)||n.StringUtilities.containsAny(r,e.specialCharacters))if(!(!r&&s.indexOf("-")>-1)||s.indexOf(",")>-1||s.indexOf("/")>-1||n.StringUtilities.containsAny(i,e.specialCharacters))if(!r&&i.indexOf(",")>-1&&-1==i.indexOf("-")&&-1==i.indexOf("/")&&!n.StringUtilities.containsAny(s,e.specialCharacters)){var o=i.split(",");a+=this.i18n.at();for(var l=0;l<o.length;l++)a&&(a+=" "),a+=this.formatTime(o[l],s,""),l<o.length-2&&(a+=","),l==o.length-2&&(a+=this.i18n.spaceAnd())}else{var c=this.getSecondsDescription(),d=this.getMinutesDescription(),u=this.getHoursDescription();if((a+=c)&&d&&(a+=", "),a+=d,d===u)return a;a&&u&&(a+=", "),a+=u}else{var h=s.split("-");a+=n.StringUtilities.format(this.i18n.everyMinuteBetweenX0AndX1(),this.formatTime(i,h[0],""),this.formatTime(i,h[1],""))}else a+=this.i18n.atSpace()+this.formatTime(i,s,r);return a},e.prototype.getSecondsDescription=function(){var e=this;return this.getSegmentDescription(this.expressionParts[0],this.i18n.everySecond(),function(e){return e},function(r){return n.StringUtilities.format(e.i18n.everyX0Seconds(r),r)},function(r){return e.i18n.secondsX0ThroughX1PastTheMinute()},function(r){return"0"==r?"":20>parseInt(r)?e.i18n.atX0SecondsPastTheMinute(r):e.i18n.atX0SecondsPastTheMinuteGt20()||e.i18n.atX0SecondsPastTheMinute(r)},{min:0,max:59})},e.prototype.getMinutesDescription=function(){var e=this,r=this.expressionParts[0],s=this.expressionParts[2];return this.getSegmentDescription(this.expressionParts[1],this.i18n.everyMinute(),function(e){return e},function(r){return n.StringUtilities.format(e.i18n.everyX0Minutes(r),r)},function(r){return e.i18n.minutesX0ThroughX1PastTheHour()},function(n){var i,a;try{return"0"==n&&-1==s.indexOf("/")&&""==r?e.i18n.everyHour():"0"==n?(null==(a=(i=e.i18n).onTheHour)?void 0:a.call(i))||e.i18n.atX0MinutesPastTheHour(n):20>parseInt(n)?e.i18n.atX0MinutesPastTheHour(n):e.i18n.atX0MinutesPastTheHourGt20()||e.i18n.atX0MinutesPastTheHour(n)}catch(r){return e.i18n.atX0MinutesPastTheHour(n)}},{min:0,max:59})},e.prototype.getHoursDescription=function(){var e=this,r=this.expressionParts[2],s=0,i=[];r.split("/")[0].split(",").forEach(function(e){var r=e.split("-");2===r.length&&i.push({value:r[1],index:s+1}),s+=r.length});var a=0;return this.getSegmentDescription(r,this.i18n.everyHour(),function(r){var s=i.find(function(e){return e.value===r&&e.index===a})&&"0"!==e.expressionParts[1];return a++,s?e.formatTime(r,"59",""):e.formatTime(r,"0","")},function(r){return n.StringUtilities.format(e.i18n.everyX0Hours(r),r)},function(r){return e.i18n.betweenX0AndX1()},function(r){return e.i18n.atX0()},{min:0,max:23})},e.prototype.getDayOfWeekDescription=function(){var e=this,r=this.i18n.daysOfTheWeek();return"*"==this.expressionParts[5]?"":this.getSegmentDescription(this.expressionParts[5],this.i18n.commaEveryDay(),function(s,n){var i=s;s.indexOf("#")>-1?i=s.substring(0,s.indexOf("#")):s.indexOf("L")>-1&&(i=i.replace("L",""));var a=parseInt(i),o=e.i18n.daysOfTheWeekInCase?e.i18n.daysOfTheWeekInCase(n)[a]:r[a];if(s.indexOf("#")>-1){var l=null,c=s.substring(s.indexOf("#")+1),d=s.substring(0,s.indexOf("#"));switch(c){case"1":l=e.i18n.first(d);break;case"2":l=e.i18n.second(d);break;case"3":l=e.i18n.third(d);break;case"4":l=e.i18n.fourth(d);break;case"5":l=e.i18n.fifth(d)}o=l+" "+o}return o},function(r){return 1==parseInt(r)?"":n.StringUtilities.format(e.i18n.commaEveryX0DaysOfTheWeek(r),r)},function(r){var s=r.substring(0,r.indexOf("-"));return"*"!=e.expressionParts[3]?e.i18n.commaAndX0ThroughX1(s):e.i18n.commaX0ThroughX1(s)},function(r){var s=null;if(r.indexOf("#")>-1){var n=r.substring(r.indexOf("#")+1),i=r.substring(0,r.indexOf("#"));s=e.i18n.commaOnThe(n,i).trim()+e.i18n.spaceX0OfTheMonth()}else s=r.indexOf("L")>-1?e.i18n.commaOnTheLastX0OfTheMonth(r.replace("L","")):"*"!=e.expressionParts[3]?e.options.logicalAndDayFields?e.i18n.commaOnlyOnX0(r):e.i18n.commaAndOnX0():e.i18n.commaOnlyOnX0(r);return s})},e.prototype.getMonthDescription=function(){var e=this,r=this.i18n.monthsOfTheYear();return this.getSegmentDescription(this.expressionParts[4],"",function(s,n){return n&&e.i18n.monthsOfTheYearInCase?e.i18n.monthsOfTheYearInCase(n)[parseInt(s)-1]:r[parseInt(s)-1]},function(r){return 1==parseInt(r)?"":n.StringUtilities.format(e.i18n.commaEveryX0Months(r),r)},function(r){return e.i18n.commaMonthX0ThroughMonthX1()||e.i18n.commaX0ThroughX1()},function(r){return e.i18n.commaOnlyInMonthX0?e.i18n.commaOnlyInMonthX0():e.i18n.commaOnlyInX0()})},e.prototype.getDayOfMonthDescription=function(){var e=this,r=null,s=this.expressionParts[3];switch(s){case"L":r=this.i18n.commaOnTheLastDayOfTheMonth();break;case"WL":case"LW":r=this.i18n.commaOnTheLastWeekdayOfTheMonth();break;default:var i=s.match(/(\d{1,2}W)|(W\d{1,2})/);if(i){var a=parseInt(i[0].replace("W","")),o=1==a?this.i18n.firstWeekday():n.StringUtilities.format(this.i18n.weekdayNearestDayX0(),a.toString());r=n.StringUtilities.format(this.i18n.commaOnTheX0OfTheMonth(),o)}else{var l=s.match(/L-(\d{1,2})/);if(l){var c=l[1];r=n.StringUtilities.format(this.i18n.commaDaysBeforeTheLastDayOfTheMonth(c),c)}else{if("*"==s&&"*"!=this.expressionParts[5])return"";r=this.getSegmentDescription(s,this.i18n.commaEveryDay(),function(r){return"L"==r?e.i18n.lastDay():e.i18n.dayX0?n.StringUtilities.format(e.i18n.dayX0(),r):r},function(r){return"1"==r?e.i18n.commaEveryDay():e.i18n.commaEveryX0Days(r)},function(r){return e.i18n.commaBetweenDayX0AndX1OfTheMonth(r)},function(r){return e.i18n.commaOnDayX0OfTheMonth(r)})}}}return r},e.prototype.getYearDescription=function(){var e=this;return this.getSegmentDescription(this.expressionParts[6],"",function(e){return/^\d+$/.test(e)?new Date(parseInt(e),1).getFullYear().toString():e},function(r){return n.StringUtilities.format(e.i18n.commaEveryX0Years(r),r)},function(r){return e.i18n.commaYearX0ThroughYearX1()||e.i18n.commaX0ThroughX1()},function(r){return e.i18n.commaOnlyInYearX0?e.i18n.commaOnlyInYearX0():e.i18n.commaOnlyInX0()})},e.prototype.getSegmentDescription=function(e,r,s,i,a,o,l){var c=null,d=e.indexOf("/")>-1,u=e.indexOf("-")>-1,h=e.indexOf(",")>-1;if(e)if("*"===e)c=r;else if(d||u||h)if(h){for(var f=e.split(","),p="",m=this.i18n.spaceAnd(),g=0;g<f.length;g++)if(g>0&&f.length>2&&(p+=",",g<f.length-1&&(p+=" ")),g>0&&f.length>1&&(g==f.length-1||2==f.length)&&(p+=","==m&&f.length>2?" ":"".concat(m," ")),f[g].indexOf("/")>-1||f[g].indexOf("-")>-1){var x=f[g].indexOf("-")>-1&&-1==f[g].indexOf("/"),v=this.getSegmentDescription(f[g],r,s,i,x?this.i18n.commaX0ThroughX1:a,o);x&&(v=v.replace(", ","")),p+=v}else if(d){var y=this.getSegmentDescription(f[g],r,s,i,a,o);y&&y.startsWith(", ")&&(y=y.substring(2)),p+=y}else p+=s(f[g]);c=d?p:n.StringUtilities.format(o(e),p)}else if(d){var f=e.split("/");if(c=n.StringUtilities.format(i(f[1]),f[1]),f[0].indexOf("-")>-1){var b=this.generateRangeSegmentDescription(f[0],a,s);0!=b.indexOf(", ")&&(c+=", "),c+=b}else if(-1==f[0].indexOf("*")){var w=n.StringUtilities.format(o(f[0]),s(f[0]));w=w.replace(", ",""),c+=n.StringUtilities.format(this.i18n.commaStartingX0(),w)}c+=this.getWrappingIncrementDescription(e,l,r,s,i,a,o)}else u&&(c=this.generateRangeSegmentDescription(e,a,s));else c=n.StringUtilities.format(o(e),s(e));else c="";return c},e.prototype.getWrappingIncrementDescription=function(e,r,s,n,i,a,o){if(!this.options.verbose||!r)return"";var l=e.split("/"),c=l[0],d=parseInt(l[1]),u=r.max-r.min+1,h=Number.isInteger(d)&&d>1;if("*"!==c||!h||h&&u%d==0)return"";for(var f=[],p=r.min;p<=r.max;p+=d)f.push(p);if(f.length<2)return"";var m=this.getSegmentDescription(f.join(","),s,n,i,a,o);return m?", ".concat(m):""},e.prototype.generateRangeSegmentDescription=function(e,r,s){var i="",a=e.split("-"),o=s(a[0],1),l=s(a[1],2),c=r(e);return i+n.StringUtilities.format(c,o,l)},e.prototype.formatTime=function(e,r,s){var n=parseInt(e)+0,i=parseInt(r)+0;i>=60?(i-=60,n+=1):i<0&&(i+=60,n-=1),n>=24?n-=24:n<0&&(n=24+n);var a="",o=!1;this.options.use24HourTimeFormat||(a=(o=!!(this.i18n.setPeriodBeforeTime&&this.i18n.setPeriodBeforeTime()))?"".concat(this.getPeriod(n)," "):" ".concat(this.getPeriod(n)),n>12&&(n-=12),0===n&&(n=12));var l="";s&&(l=":".concat(("00"+s).substring(s.length)));var c=n.toString(),d=("00"+c).substring(c.length),u=i.toString(),h=("00"+u).substring(u.length),f=this.options.trimHoursLeadingZero?c:d;return"".concat(o?a:"").concat(f,":").concat(h).concat(l).concat(o?"":a)},e.prototype.transformVerbosity=function(e,r){if(!r&&(e=(e=(e=(e=e.replace(RegExp(", ".concat(this.i18n.everyMinute()),"g"),"")).replace(RegExp(", ".concat(this.i18n.everyHour()),"g"),"")).replace(RegExp(this.i18n.commaEveryDay(),"g"),"")).replace(/\, ?$/,""),this.i18n.conciseVerbosityReplacements))for(var s=0,n=Object.entries(this.i18n.conciseVerbosityReplacements());s<n.length;s++){var i=n[s],a=i[0],o=i[1];e=e.replace(RegExp(a,"g"),o)}return e},e.prototype.getPeriod=function(e){return e>=12?this.i18n.pm&&this.i18n.pm()||"PM":this.i18n.am&&this.i18n.am()||"AM"},e.locales={},e}()},3747(e,r,s){Object.defineProperty(r,"__esModule",{value:!0}),r.enLocaleLoader=void 0;var n=s(9486);r.enLocaleLoader=function(){function e(){}return e.prototype.load=function(e){e.en=new n.en},e}()},9486(e,r){Object.defineProperty(r,"__esModule",{value:!0}),r.en=void 0,r.en=function(){function e(){}return e.prototype.atX0SecondsPastTheMinuteGt20=function(){return null},e.prototype.atX0MinutesPastTheHourGt20=function(){return null},e.prototype.commaMonthX0ThroughMonthX1=function(){return null},e.prototype.commaYearX0ThroughYearX1=function(){return null},e.prototype.use24HourTimeFormatByDefault=function(){return!1},e.prototype.anErrorOccuredWhenGeneratingTheExpressionD=function(){return"An error occurred when generating the expression description. Check the cron expression syntax."},e.prototype.everyMinute=function(){return"every minute"},e.prototype.everyHour=function(){return"every hour"},e.prototype.atSpace=function(){return"At "},e.prototype.everyMinuteBetweenX0AndX1=function(){return"Every minute between %s and %s"},e.prototype.at=function(){return"At"},e.prototype.spaceAnd=function(){return" and"},e.prototype.everySecond=function(){return"every second"},e.prototype.everyX0Seconds=function(){return"every %s seconds"},e.prototype.secondsX0ThroughX1PastTheMinute=function(){return"seconds %s through %s past the minute"},e.prototype.atX0SecondsPastTheMinute=function(){return"at %s seconds past the minute"},e.prototype.everyX0Minutes=function(){return"every %s minutes"},e.prototype.minutesX0ThroughX1PastTheHour=function(){return"minutes %s through %s past the hour"},e.prototype.atX0MinutesPastTheHour=function(){return"at %s minutes past the hour"},e.prototype.everyX0Hours=function(){return"every %s hours"},e.prototype.betweenX0AndX1=function(){return"between %s and %s"},e.prototype.atX0=function(){return"at %s"},e.prototype.commaEveryDay=function(){return", every day"},e.prototype.commaEveryX0DaysOfTheWeek=function(){return", every %s days of the week"},e.prototype.commaX0ThroughX1=function(){return", %s through %s"},e.prototype.commaAndX0ThroughX1=function(){return", %s through %s"},e.prototype.first=function(){return"first"},e.prototype.second=function(){return"second"},e.prototype.third=function(){return"third"},e.prototype.fourth=function(){return"fourth"},e.prototype.fifth=function(){return"fifth"},e.prototype.commaOnThe=function(){return", on the "},e.prototype.spaceX0OfTheMonth=function(){return" %s of the month"},e.prototype.lastDay=function(){return"the last day"},e.prototype.commaOnTheLastX0OfTheMonth=function(){return", on the last %s of the month"},e.prototype.commaOnlyOnX0=function(){return", only on %s"},e.prototype.commaAndOnX0=function(){return", and on %s"},e.prototype.commaEveryX0Months=function(){return", every %s months"},e.prototype.commaOnlyInX0=function(){return", only in %s"},e.prototype.commaOnTheLastDayOfTheMonth=function(){return", on the last day of the month"},e.prototype.commaOnTheLastWeekdayOfTheMonth=function(){return", on the last weekday of the month"},e.prototype.commaDaysBeforeTheLastDayOfTheMonth=function(){return", %s days before the last day of the month"},e.prototype.firstWeekday=function(){return"first weekday"},e.prototype.weekdayNearestDayX0=function(){return"weekday nearest day %s"},e.prototype.commaOnTheX0OfTheMonth=function(){return", on the %s of the month"},e.prototype.commaEveryX0Days=function(){return", every %s days in a month"},e.prototype.commaBetweenDayX0AndX1OfTheMonth=function(){return", between day %s and %s of the month"},e.prototype.commaOnDayX0OfTheMonth=function(){return", on day %s of the month"},e.prototype.commaEveryHour=function(){return", every hour"},e.prototype.commaEveryX0Years=function(){return", every %s years"},e.prototype.commaStartingX0=function(){return", starting %s"},e.prototype.daysOfTheWeek=function(){return["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},e.prototype.monthsOfTheYear=function(){return["January","February","March","April","May","June","July","August","September","October","November","December"]},e.prototype.atReboot=function(){return"Run once, at startup"},e.prototype.onTheHour=function(){return"on the hour"},e}()},9515(e,r){function s(e,r){if(!e)throw Error(r)}Object.defineProperty(r,"__esModule",{value:!0}),r.default=function(){function e(){}return e.secondRange=function(e){for(var r=e.split(","),n=0;n<r.length;n++)if(!isNaN(parseInt(r[n],10))){var i=parseInt(r[n],10);s(i>=0&&i<=59,"seconds part must be >= 0 and <= 59")}},e.minuteRange=function(e){for(var r=e.split(","),n=0;n<r.length;n++)if(!isNaN(parseInt(r[n],10))){var i=parseInt(r[n],10);s(i>=0&&i<=59,"minutes part must be >= 0 and <= 59")}},e.hourRange=function(e){for(var r=e.split(","),n=0;n<r.length;n++)if(!isNaN(parseInt(r[n],10))){var i=parseInt(r[n],10);s(i>=0&&i<=23,"hours part must be >= 0 and <= 23")}},e.dayOfMonthRange=function(e){for(var r=e.split(","),n=0;n<r.length;n++)if(!isNaN(parseInt(r[n],10))){var i=parseInt(r[n],10);s(i>=1&&i<=31,"DOM part must be >= 1 and <= 31")}},e.monthRange=function(e,r){for(var n=e.split(","),i=0;i<n.length;i++)if(!isNaN(parseInt(n[i],10))){var a=parseInt(n[i],10);s(a>=1&&a<=12,r?"month part must be >= 0 and <= 11":"month part must be >= 1 and <= 12")}},e.dayOfWeekRange=function(e,r){for(var n=e.split(","),i=0;i<n.length;i++)if(!isNaN(parseInt(n[i],10))){var a=parseInt(n[i],10);s(a>=0&&a<=6,r?"DOW part must be >= 0 and <= 6":"DOW part must be >= 1 and <= 7")}},e}()},1823(e,r){Object.defineProperty(r,"__esModule",{value:!0}),r.StringUtilities=void 0,r.StringUtilities=function(){function e(){}return e.format=function(e){for(var r=[],s=1;s<arguments.length;s++)r[s-1]=arguments[s];return e.replace(/%s/g,function(e){for(var s=[],n=1;n<arguments.length;n++)s[n-1]=arguments[n];return r.shift()})},e.containsAny=function(e,r){return r.some(function(r){return e.indexOf(r)>-1})},e}()}},n={};function i(e){var r=n[e];if(void 0!==r)return r.exports;var a=n[e]={exports:{}};return s[e](a,a.exports,i),a.exports}var a={};return Object.defineProperty(a,"__esModule",{value:!0}),a.toString=void 0,e=i(8333),r=i(3747),e.ExpressionDescriptor.initialize(new r.enLocaleLoader),a.default=e.ExpressionDescriptor,a.toString=e.ExpressionDescriptor.toString,a})()},837031,e=>{"use strict";let r,s,n,i,a,o,l,c,d,u,h,f,p,m,g,x,v,y,b,w;var _,S,k,j,C,N,E,D,T,R,A,M,I,P,F,L,O,B,z,$,W,H,U=e.i(813443),V=e.i(629109);let q=[{id:"agent",label:"Agent",code:"KeyA"},{id:"executors",label:"Executors",code:"KeyE"},{id:"diff",label:"Diff",code:"KeyD"},{id:"terminal",label:"Terminal",code:"KeyT"},{id:"preview",label:"Preview",code:"KeyP"},{id:"files",label:"Files",code:"KeyF"}],K=Object.fromEntries(q.map(e=>[e.code,e.id])),X=()=>"undefined"!=typeof navigator&&/Mac|iPhone|iPad/.test(navigator.platform),Y="KeyR",G="KeyS",J="KeyM",Z=e=>X()?e.ctrlKey&&e.shiftKey&&!e.altKey&&!e.metaKey:e.ctrlKey&&e.altKey&&!e.shiftKey&&!e.metaKey;function Q(e){return Z(e)?K[e.code]??null:null}let ee=(e,r)=>Z(e)&&e.code===r,et=(e,r)=>`${e?"⌃⇧":"Ctrl+Alt+"}${r.slice(3)}`;function er(e,r,{checkForDefaultPrevented:s=!0}={}){return function(n){if(e?.(n),!1===s||!n.defaultPrevented)return r?.(n)}}function es(e,r=[]){let s=[],n=()=>{let r=s.map(e=>V.createContext(e));return function(s){let n=s?.[e]||r;return V.useMemo(()=>({[`__scope${e}`]:{...s,[e]:n}}),[s,n])}};return n.scopeName=e,[function(r,n){let i=V.createContext(n),a=s.length;s=[...s,n];let o=r=>{let{scope:s,children:n,...o}=r,l=s?.[e]?.[a]||i,c=V.useMemo(()=>o,Object.values(o));return(0,U.jsx)(l.Provider,{value:c,children:n})};return o.displayName=r+"Provider",[o,function(s,o){let l=o?.[e]?.[a]||i,c=V.useContext(l);if(c)return c;if(void 0!==n)return n;throw Error(`\`${s}\` must be used within \`${r}\``)}]},function(...e){let r=e[0];if(1===e.length)return r;let s=()=>{let s=e.map(e=>({useScope:e(),scopeName:e.scopeName}));return function(e){let n=s.reduce((r,{useScope:s,scopeName:n})=>{let i=s(e)[`__scope${n}`];return{...r,...i}},{});return V.useMemo(()=>({[`__scope${r.scopeName}`]:n}),[n])}};return s.scopeName=r.scopeName,s}(n,...r)]}"undefined"!=typeof window&&window.document&&window.document.createElement;var en=e.i(538422),ei=e.i(475299);function ea(e){let r=e+"CollectionProvider",[s,n]=es(r),[i,a]=s(r,{collectionRef:{current:null},itemMap:new Map}),o=e=>{let{scope:r,children:s}=e,n=V.default.useRef(null),a=V.default.useRef(new Map).current;return(0,U.jsx)(i,{scope:r,itemMap:a,collectionRef:n,children:s})};o.displayName=r;let l=e+"CollectionSlot",c=(0,ei.createSlot)(l),d=V.default.forwardRef((e,r)=>{let{scope:s,children:n}=e,i=a(l,s),o=(0,en.useComposedRefs)(r,i.collectionRef);return(0,U.jsx)(c,{ref:o,children:n})});d.displayName=l;let u=e+"CollectionItemSlot",h="data-radix-collection-item",f=(0,ei.createSlot)(u),p=V.default.forwardRef((e,r)=>{let{scope:s,children:n,...i}=e,o=V.default.useRef(null),l=(0,en.useComposedRefs)(r,o),c=a(u,s);return V.default.useEffect(()=>(c.itemMap.set(o,{ref:o,...i}),()=>void c.itemMap.delete(o))),(0,U.jsx)(f,{...{[h]:""},ref:l,children:n})});return p.displayName=u,[{Provider:o,Slot:d,ItemSlot:p},function(r){let s=a(e+"CollectionConsumer",r);return V.default.useCallback(()=>{let e=s.collectionRef.current;if(!e)return[];let r=Array.from(e.querySelectorAll(`[${h}]`));return Array.from(s.itemMap.values()).sort((e,s)=>r.indexOf(e.ref.current)-r.indexOf(s.ref.current))},[s.collectionRef,s.itemMap])},n]}var eo=new WeakMap;function el(e,r){var s,n;let i,a,o;if("at"in Array.prototype)return Array.prototype.at.call(e,r);let l=(s=e,n=r,i=s.length,(o=(a=ec(n))>=0?a:i+a)<0||o>=i?-1:o);return -1===l?void 0:e[l]}function ec(e){return e!=e||0===e?0:Math.trunc(e)}(class e extends Map{#e;constructor(e){super(e),this.#e=[...super.keys()],eo.set(this,!0)}set(e,r){return eo.get(this)&&(this.has(e)?this.#e[this.#e.indexOf(e)]=e:this.#e.push(e)),super.set(e,r),this}insert(e,r,s){let n,i=this.has(r),a=this.#e.length,o=ec(e),l=o>=0?o:a+o,c=l<0||l>=a?-1:l;if(c===this.size||i&&c===this.size-1||-1===c)return this.set(r,s),this;let d=this.size+ +!i;o<0&&l++;let u=[...this.#e],h=!1;for(let e=l;e<d;e++)if(l===e){let a=u[e];u[e]===r&&(a=u[e+1]),i&&this.delete(r),n=this.get(a),this.set(r,s)}else{h||u[e-1]!==r||(h=!0);let s=u[h?e:e-1],i=n;n=this.get(s),this.delete(s),this.set(s,i)}return this}with(r,s,n){let i=new e(this);return i.insert(r,s,n),i}before(e){let r=this.#e.indexOf(e)-1;if(!(r<0))return this.entryAt(r)}setBefore(e,r,s){let n=this.#e.indexOf(e);return -1===n?this:this.insert(n,r,s)}after(e){let r=this.#e.indexOf(e);if(-1!==(r=-1===r||r===this.size-1?-1:r+1))return this.entryAt(r)}setAfter(e,r,s){let n=this.#e.indexOf(e);return -1===n?this:this.insert(n+1,r,s)}first(){return this.entryAt(0)}last(){return this.entryAt(-1)}clear(){return this.#e=[],super.clear()}delete(e){let r=super.delete(e);return r&&this.#e.splice(this.#e.indexOf(e),1),r}deleteAt(e){let r=this.keyAt(e);return void 0!==r&&this.delete(r)}at(e){let r=el(this.#e,e);if(void 0!==r)return this.get(r)}entryAt(e){let r=el(this.#e,e);if(void 0!==r)return[r,this.get(r)]}indexOf(e){return this.#e.indexOf(e)}keyAt(e){return el(this.#e,e)}from(e,r){let s=this.indexOf(e);if(-1===s)return;let n=s+r;return n<0&&(n=0),n>=this.size&&(n=this.size-1),this.at(n)}keyFrom(e,r){let s=this.indexOf(e);if(-1===s)return;let n=s+r;return n<0&&(n=0),n>=this.size&&(n=this.size-1),this.keyAt(n)}find(e,r){let s=0;for(let n of this){if(Reflect.apply(e,r,[n,s,this]))return n;s++}}findIndex(e,r){let s=0;for(let n of this){if(Reflect.apply(e,r,[n,s,this]))return s;s++}return -1}filter(r,s){let n=[],i=0;for(let e of this)Reflect.apply(r,s,[e,i,this])&&n.push(e),i++;return new e(n)}map(r,s){let n=[],i=0;for(let e of this)n.push([e[0],Reflect.apply(r,s,[e,i,this])]),i++;return new e(n)}reduce(...e){let[r,s]=e,n=0,i=s??this.at(0);for(let s of this)i=0===n&&1===e.length?s:Reflect.apply(r,this,[i,s,n,this]),n++;return i}reduceRight(...e){let[r,s]=e,n=s??this.at(-1);for(let s=this.size-1;s>=0;s--){let i=this.at(s);n=s===this.size-1&&1===e.length?i:Reflect.apply(r,this,[n,i,s,this])}return n}toSorted(r){return new e([...this.entries()].sort(r))}toReversed(){let r=new e;for(let e=this.size-1;e>=0;e--){let s=this.keyAt(e),n=this.get(s);r.set(s,n)}return r}toSpliced(...r){let s=[...this.entries()];return s.splice(...r),new e(s)}slice(r,s){let n=new e,i=this.size-1;if(void 0===r)return n;r<0&&(r+=this.size),void 0!==s&&s>0&&(i=s-1);for(let e=r;e<=i;e++){let r=this.keyAt(e),s=this.get(r);n.set(r,s)}return n}every(e,r){let s=0;for(let n of this){if(!Reflect.apply(e,r,[n,s,this]))return!1;s++}return!0}some(e,r){let s=0;for(let n of this){if(Reflect.apply(e,r,[n,s,this]))return!0;s++}return!1}});var ed=globalThis?.document?V.useLayoutEffect:()=>{},eu=V[" useId ".trim().toString()]||(()=>void 0),eh=0;function ef(e){let[r,s]=V.useState(eu());return ed(()=>{e||s(e=>e??String(eh++))},[e]),e||(r?`radix-${r}`:"")}var ep=e.i(492521),em=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce((e,r)=>{let s=(0,ei.createSlot)(`Primitive.${r}`),n=V.forwardRef((e,n)=>{let{asChild:i,...a}=e;return"undefined"!=typeof window&&(window[Symbol.for("radix-ui")]=!0),(0,U.jsx)(i?s:r,{...a,ref:n})});return n.displayName=`Primitive.${r}`,{...e,[r]:n}},{});function eg(e,r){e&&ep.flushSync(()=>e.dispatchEvent(r))}function ex(e){let r=V.useRef(e);return V.useEffect(()=>{r.current=e}),V.useMemo(()=>(...e)=>r.current?.(...e),[])}V[" useEffectEvent ".trim().toString()],V[" useInsertionEffect ".trim().toString()];var ev=V[" useInsertionEffect ".trim().toString()]||ed;function ey({prop:e,defaultProp:r,onChange:s=()=>{},caller:n}){let[i,a,o]=function({defaultProp:e,onChange:r}){let[s,n]=V.useState(e),i=V.useRef(s),a=V.useRef(r);return ev(()=>{a.current=r},[r]),V.useEffect(()=>{i.current!==s&&(a.current?.(s),i.current=s)},[s,i]),[s,n,a]}({defaultProp:r,onChange:s}),l=void 0!==e,c=l?e:i;{let r=V.useRef(void 0!==e);V.useEffect(()=>{let e=r.current;if(e!==l){let r=l?"controlled":"uncontrolled";console.warn(`${n} is changing from ${e?"controlled":"uncontrolled"} to ${r}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`)}r.current=l},[l,n])}return[c,V.useCallback(r=>{if(l){let s="function"==typeof r?r(e):r;s!==e&&o.current?.(s)}else a(r)},[l,e,a,o])]}Symbol("RADIX:SYNC_STATE");var eb=V.createContext(void 0);function ew(e){let r=V.useContext(eb);return e||r||"ltr"}var e_="rovingFocusGroup.onEntryFocus",eS={bubbles:!1,cancelable:!0},ek="RovingFocusGroup",[ej,eC,eN]=ea(ek),[eE,eD]=es(ek,[eN]),[eT,eR]=eE(ek),eA=V.forwardRef((e,r)=>(0,U.jsx)(ej.Provider,{scope:e.__scopeRovingFocusGroup,children:(0,U.jsx)(ej.Slot,{scope:e.__scopeRovingFocusGroup,children:(0,U.jsx)(eM,{...e,ref:r})})}));eA.displayName=ek;var eM=V.forwardRef((e,r)=>{let{__scopeRovingFocusGroup:s,orientation:n,loop:i=!1,dir:a,currentTabStopId:o,defaultCurrentTabStopId:l,onCurrentTabStopIdChange:c,onEntryFocus:d,preventScrollOnEntryFocus:u=!1,...h}=e,f=V.useRef(null),p=(0,en.useComposedRefs)(r,f),m=ew(a),[g,x]=ey({prop:o,defaultProp:l??null,onChange:c,caller:ek}),[v,y]=V.useState(!1),b=ex(d),w=eC(s),_=V.useRef(!1),[S,k]=V.useState(0);return V.useEffect(()=>{let e=f.current;if(e)return e.addEventListener(e_,b),()=>e.removeEventListener(e_,b)},[b]),(0,U.jsx)(eT,{scope:s,orientation:n,dir:m,loop:i,currentTabStopId:g,onItemFocus:V.useCallback(e=>x(e),[x]),onItemShiftTab:V.useCallback(()=>y(!0),[]),onFocusableItemAdd:V.useCallback(()=>k(e=>e+1),[]),onFocusableItemRemove:V.useCallback(()=>k(e=>e-1),[]),children:(0,U.jsx)(em.div,{tabIndex:v||0===S?-1:0,"data-orientation":n,...h,ref:p,style:{outline:"none",...e.style},onMouseDown:er(e.onMouseDown,()=>{_.current=!0}),onFocus:er(e.onFocus,e=>{let r=!_.current;if(e.target===e.currentTarget&&r&&!v){let r=new CustomEvent(e_,eS);if(e.currentTarget.dispatchEvent(r),!r.defaultPrevented){let e=w().filter(e=>e.focusable);eL([e.find(e=>e.active),e.find(e=>e.id===g),...e].filter(Boolean).map(e=>e.ref.current),u)}}_.current=!1}),onBlur:er(e.onBlur,()=>y(!1))})})}),eI="RovingFocusGroupItem",eP=V.forwardRef((e,r)=>{let{__scopeRovingFocusGroup:s,focusable:n=!0,active:i=!1,tabStopId:a,children:o,...l}=e,c=ef(),d=a||c,u=eR(eI,s),h=u.currentTabStopId===d,f=eC(s),{onFocusableItemAdd:p,onFocusableItemRemove:m,currentTabStopId:g}=u;return V.useEffect(()=>{if(n)return p(),()=>m()},[n,p,m]),(0,U.jsx)(ej.ItemSlot,{scope:s,id:d,focusable:n,active:i,children:(0,U.jsx)(em.span,{tabIndex:h?0:-1,"data-orientation":u.orientation,...l,ref:r,onMouseDown:er(e.onMouseDown,e=>{n?u.onItemFocus(d):e.preventDefault()}),onFocus:er(e.onFocus,()=>u.onItemFocus(d)),onKeyDown:er(e.onKeyDown,e=>{if("Tab"===e.key&&e.shiftKey)return void u.onItemShiftTab();if(e.target!==e.currentTarget)return;let r=function(e,r,s){var n;let i=(n=e.key,"rtl"!==s?n:"ArrowLeft"===n?"ArrowRight":"ArrowRight"===n?"ArrowLeft":n);if(!("vertical"===r&&["ArrowLeft","ArrowRight"].includes(i))&&!("horizontal"===r&&["ArrowUp","ArrowDown"].includes(i)))return eF[i]}(e,u.orientation,u.dir);if(void 0!==r){if(e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)return;e.preventDefault();let i=f().filter(e=>e.focusable).map(e=>e.ref.current);if("last"===r)i.reverse();else if("prev"===r||"next"===r){var s,n;"prev"===r&&i.reverse();let a=i.indexOf(e.currentTarget);i=u.loop?(s=i,n=a+1,s.map((e,r)=>s[(n+r)%s.length])):i.slice(a+1)}setTimeout(()=>eL(i))}}),children:"function"==typeof o?o({isCurrentTabStop:h,hasTabStop:null!=g}):o})})});eP.displayName=eI;var eF={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function eL(e,r=!1){let s=document.activeElement;for(let n of e)if(n===s||(n.focus({preventScroll:r}),document.activeElement!==s))return}var eO=e=>{var r;let s,n,{present:i,children:a}=e,o=function(e){var r,s;let[n,i]=V.useState(),a=V.useRef(null),o=V.useRef(e),l=V.useRef("none"),[c,d]=(r=e?"mounted":"unmounted",s={mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}},V.useReducer((e,r)=>s[e][r]??e,r));return V.useEffect(()=>{let e=eB(a.current);l.current="mounted"===c?e:"none"},[c]),ed(()=>{let r=a.current,s=o.current;if(s!==e){let n=l.current,i=eB(r);e?d("MOUNT"):"none"===i||r?.display==="none"?d("UNMOUNT"):s&&n!==i?d("ANIMATION_OUT"):d("UNMOUNT"),o.current=e}},[e,d]),ed(()=>{if(n){let e,r=n.ownerDocument.defaultView??window,s=s=>{let i=eB(a.current).includes(CSS.escape(s.animationName));if(s.target===n&&i&&(d("ANIMATION_END"),!o.current)){let s=n.style.animationFillMode;n.style.animationFillMode="forwards",e=r.setTimeout(()=>{"forwards"===n.style.animationFillMode&&(n.style.animationFillMode=s)})}},i=e=>{e.target===n&&(l.current=eB(a.current))};return n.addEventListener("animationstart",i),n.addEventListener("animationcancel",s),n.addEventListener("animationend",s),()=>{r.clearTimeout(e),n.removeEventListener("animationstart",i),n.removeEventListener("animationcancel",s),n.removeEventListener("animationend",s)}}d("ANIMATION_END")},[n,d]),{isPresent:["mounted","unmountSuspended"].includes(c),ref:V.useCallback(e=>{a.current=e?getComputedStyle(e):null,i(e)},[])}}(i),l="function"==typeof a?a({present:o.isPresent}):V.Children.only(a),c=(0,en.useComposedRefs)(o.ref,(r=l,(n=(s=Object.getOwnPropertyDescriptor(r.props,"ref")?.get)&&"isReactWarning"in s&&s.isReactWarning)?r.ref:(n=(s=Object.getOwnPropertyDescriptor(r,"ref")?.get)&&"isReactWarning"in s&&s.isReactWarning)?r.props.ref:r.props.ref||r.ref));return"function"==typeof a||o.isPresent?V.cloneElement(l,{ref:c}):null};function eB(e){return e?.animationName||"none"}eO.displayName="Presence";var ez="Tabs",[e$,eW]=es(ez,[eD]),eH=eD(),[eU,eV]=e$(ez),eq=V.forwardRef((e,r)=>{let{__scopeTabs:s,value:n,onValueChange:i,defaultValue:a,orientation:o="horizontal",dir:l,activationMode:c="automatic",...d}=e,u=ew(l),[h,f]=ey({prop:n,onChange:i,defaultProp:a??"",caller:ez});return(0,U.jsx)(eU,{scope:s,baseId:ef(),value:h,onValueChange:f,orientation:o,dir:u,activationMode:c,children:(0,U.jsx)(em.div,{dir:u,"data-orientation":o,...d,ref:r})})});eq.displayName=ez;var eK="TabsList",eX=V.forwardRef((e,r)=>{let{__scopeTabs:s,loop:n=!0,...i}=e,a=eV(eK,s),o=eH(s);return(0,U.jsx)(eA,{asChild:!0,...o,orientation:a.orientation,dir:a.dir,loop:n,children:(0,U.jsx)(em.div,{role:"tablist","aria-orientation":a.orientation,...i,ref:r})})});eX.displayName=eK;var eY="TabsTrigger",eG=V.forwardRef((e,r)=>{let{__scopeTabs:s,value:n,disabled:i=!1,...a}=e,o=eV(eY,s),l=eH(s),c=eQ(o.baseId,n),d=e0(o.baseId,n),u=n===o.value;return(0,U.jsx)(eP,{asChild:!0,...l,focusable:!i,active:u,children:(0,U.jsx)(em.button,{type:"button",role:"tab","aria-selected":u,"aria-controls":d,"data-state":u?"active":"inactive","data-disabled":i?"":void 0,disabled:i,id:c,...a,ref:r,onMouseDown:er(e.onMouseDown,e=>{i||0!==e.button||!1!==e.ctrlKey?e.preventDefault():o.onValueChange(n)}),onKeyDown:er(e.onKeyDown,e=>{[" ","Enter"].includes(e.key)&&o.onValueChange(n)}),onFocus:er(e.onFocus,()=>{let e="manual"!==o.activationMode;u||i||!e||o.onValueChange(n)})})})});eG.displayName=eY;var eJ="TabsContent",eZ=V.forwardRef((e,r)=>{let{__scopeTabs:s,value:n,forceMount:i,children:a,...o}=e,l=eV(eJ,s),c=eQ(l.baseId,n),d=e0(l.baseId,n),u=n===l.value,h=V.useRef(u);return V.useEffect(()=>{let e=requestAnimationFrame(()=>h.current=!1);return()=>cancelAnimationFrame(e)},[]),(0,U.jsx)(eO,{present:i||u,children:({present:s})=>(0,U.jsx)(em.div,{"data-state":u?"active":"inactive","data-orientation":l.orientation,role:"tabpanel","aria-labelledby":c,hidden:!s,id:d,tabIndex:0,...o,ref:r,style:{...e.style,animationDuration:h.current?"0s":void 0},children:s&&a})})});function eQ(e,r){return`${e}-trigger-${r}`}function e0(e,r){return`${e}-content-${r}`}eZ.displayName=eJ;var e1=e.i(803545);let e2=V.forwardRef(({className:e,...r},s)=>(0,U.jsx)(eX,{ref:s,className:(0,e1.cn)("inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground",e),...r}));e2.displayName=eX.displayName;let e5=V.forwardRef(({className:e,...r},s)=>(0,U.jsx)(eG,{ref:s,className:(0,e1.cn)("inline-flex items-center justify-center whitespace-nowrap rounded-md px-3 py-1 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow",e),...r}));e5.displayName=eG.displayName;let e3=V.forwardRef(({className:e,...r},s)=>(0,U.jsx)(eZ,{ref:s,className:(0,e1.cn)("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",e),...r}));e3.displayName=eZ.displayName;var e4="dismissableLayer.update",e6=V.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),e7=V.forwardRef((e,r)=>{let{disableOutsidePointerEvents:s=!1,onEscapeKeyDown:n,onPointerDownOutside:i,onFocusOutside:a,onInteractOutside:o,onDismiss:l,...c}=e,d=V.useContext(e6),[u,h]=V.useState(null),f=u?.ownerDocument??globalThis?.document,[,p]=V.useState({}),m=(0,en.useComposedRefs)(r,e=>h(e)),g=Array.from(d.layers),[x]=[...d.layersWithOutsidePointerEventsDisabled].slice(-1),v=g.indexOf(x),y=u?g.indexOf(u):-1,b=d.layersWithOutsidePointerEventsDisabled.size>0,w=y>=v,_=function(e,r=globalThis?.document){let s=ex(e),n=V.useRef(!1),i=V.useRef(()=>{});return V.useEffect(()=>{let e=e=>{if(e.target&&!n.current){let n=function(){e9("dismissableLayer.pointerDownOutside",s,a,{discrete:!0})},a={originalEvent:e};"touch"===e.pointerType?(r.removeEventListener("click",i.current),i.current=n,r.addEventListener("click",i.current,{once:!0})):n()}else r.removeEventListener("click",i.current);n.current=!1},a=window.setTimeout(()=>{r.addEventListener("pointerdown",e)},0);return()=>{window.clearTimeout(a),r.removeEventListener("pointerdown",e),r.removeEventListener("click",i.current)}},[r,s]),{onPointerDownCapture:()=>n.current=!0}}(e=>{let r=e.target,s=[...d.branches].some(e=>e.contains(r));w&&!s&&(i?.(e),o?.(e),e.defaultPrevented||l?.())},f),S=function(e,r=globalThis?.document){let s=ex(e),n=V.useRef(!1);return V.useEffect(()=>{let e=e=>{e.target&&!n.current&&e9("dismissableLayer.focusOutside",s,{originalEvent:e},{discrete:!1})};return r.addEventListener("focusin",e),()=>r.removeEventListener("focusin",e)},[r,s]),{onFocusCapture:()=>n.current=!0,onBlurCapture:()=>n.current=!1}}(e=>{let r=e.target;![...d.branches].some(e=>e.contains(r))&&(a?.(e),o?.(e),e.defaultPrevented||l?.())},f);return!function(e,r=globalThis?.document){let s=ex(e);V.useEffect(()=>{let e=e=>{"Escape"===e.key&&s(e)};return r.addEventListener("keydown",e,{capture:!0}),()=>r.removeEventListener("keydown",e,{capture:!0})},[s,r])}(e=>{y===d.layers.size-1&&(n?.(e),!e.defaultPrevented&&l&&(e.preventDefault(),l()))},f),V.useEffect(()=>{if(u)return s&&(0===d.layersWithOutsidePointerEventsDisabled.size&&(vV=f.body.style.pointerEvents,f.body.style.pointerEvents="none"),d.layersWithOutsidePointerEventsDisabled.add(u)),d.layers.add(u),e8(),()=>{s&&1===d.layersWithOutsidePointerEventsDisabled.size&&(f.body.style.pointerEvents=vV)}},[u,f,s,d]),V.useEffect(()=>()=>{u&&(d.layers.delete(u),d.layersWithOutsidePointerEventsDisabled.delete(u),e8())},[u,d]),V.useEffect(()=>{let e=()=>p({});return document.addEventListener(e4,e),()=>document.removeEventListener(e4,e)},[]),(0,U.jsx)(em.div,{...c,ref:m,style:{pointerEvents:b?w?"auto":"none":void 0,...e.style},onFocusCapture:er(e.onFocusCapture,S.onFocusCapture),onBlurCapture:er(e.onBlurCapture,S.onBlurCapture),onPointerDownCapture:er(e.onPointerDownCapture,_.onPointerDownCapture)})});function e8(){let e=new CustomEvent(e4);document.dispatchEvent(e)}function e9(e,r,s,{discrete:n}){let i=s.originalEvent.target,a=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:s});r&&i.addEventListener(e,r,{once:!0}),n?eg(i,a):i.dispatchEvent(a)}e7.displayName="DismissableLayer",V.forwardRef((e,r)=>{let s=V.useContext(e6),n=V.useRef(null),i=(0,en.useComposedRefs)(r,n);return V.useEffect(()=>{let e=n.current;if(e)return s.branches.add(e),()=>{s.branches.delete(e)}},[s.branches]),(0,U.jsx)(em.div,{...e,ref:i})}).displayName="DismissableLayerBranch";var te="focusScope.autoFocusOnMount",tt="focusScope.autoFocusOnUnmount",tr={bubbles:!1,cancelable:!0},ts=V.forwardRef((e,r)=>{let{loop:s=!1,trapped:n=!1,onMountAutoFocus:i,onUnmountAutoFocus:a,...o}=e,[l,c]=V.useState(null),d=ex(i),u=ex(a),h=V.useRef(null),f=(0,en.useComposedRefs)(r,e=>c(e)),p=V.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;V.useEffect(()=>{if(n){let e=function(e){if(p.paused||!l)return;let r=e.target;l.contains(r)?h.current=r:ta(h.current,{select:!0})},r=function(e){if(p.paused||!l)return;let r=e.relatedTarget;null!==r&&(l.contains(r)||ta(h.current,{select:!0}))};document.addEventListener("focusin",e),document.addEventListener("focusout",r);let s=new MutationObserver(function(e){if(document.activeElement===document.body)for(let r of e)r.removedNodes.length>0&&ta(l)});return l&&s.observe(l,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",e),document.removeEventListener("focusout",r),s.disconnect()}}},[n,l,p.paused]),V.useEffect(()=>{if(l){to.add(p);let e=document.activeElement;if(!l.contains(e)){let r=new CustomEvent(te,tr);l.addEventListener(te,d),l.dispatchEvent(r),r.defaultPrevented||(function(e,{select:r=!1}={}){let s=document.activeElement;for(let n of e)if(ta(n,{select:r}),document.activeElement!==s)return}(tn(l).filter(e=>"A"!==e.tagName),{select:!0}),document.activeElement===e&&ta(l))}return()=>{l.removeEventListener(te,d),setTimeout(()=>{let r=new CustomEvent(tt,tr);l.addEventListener(tt,u),l.dispatchEvent(r),r.defaultPrevented||ta(e??document.body,{select:!0}),l.removeEventListener(tt,u),to.remove(p)},0)}}},[l,d,u,p]);let m=V.useCallback(e=>{if(!s&&!n||p.paused)return;let r="Tab"===e.key&&!e.altKey&&!e.ctrlKey&&!e.metaKey,i=document.activeElement;if(r&&i){var a;let r,n=e.currentTarget,[o,l]=[ti(r=tn(a=n),a),ti(r.reverse(),a)];o&&l?e.shiftKey||i!==l?e.shiftKey&&i===o&&(e.preventDefault(),s&&ta(l,{select:!0})):(e.preventDefault(),s&&ta(o,{select:!0})):i===n&&e.preventDefault()}},[s,n,p.paused]);return(0,U.jsx)(em.div,{tabIndex:-1,...o,ref:f,onKeyDown:m})});function tn(e){let r=[],s=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:e=>{let r="INPUT"===e.tagName&&"hidden"===e.type;return e.disabled||e.hidden||r?NodeFilter.FILTER_SKIP:e.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;s.nextNode();)r.push(s.currentNode);return r}function ti(e,r){for(let s of e)if(!function(e,{upTo:r}){if("hidden"===getComputedStyle(e).visibility)return!0;for(;e&&(void 0===r||e!==r);){if("none"===getComputedStyle(e).display)return!0;e=e.parentElement}return!1}(s,{upTo:r}))return s}function ta(e,{select:r=!1}={}){if(e&&e.focus){var s;let n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&(s=e)instanceof HTMLInputElement&&"select"in s&&r&&e.select()}}ts.displayName="FocusScope";var to=(b=[],{add(e){let r=b[0];e!==r&&r?.pause(),(b=tl(b,e)).unshift(e)},remove(e){b=tl(b,e),b[0]?.resume()}});function tl(e,r){let s=[...e],n=s.indexOf(r);return -1!==n&&s.splice(n,1),s}var tc=V.forwardRef((e,r)=>{let{container:s,...n}=e,[i,a]=V.useState(!1);ed(()=>a(!0),[]);let o=s||i&&globalThis?.document?.body;return o?ep.default.createPortal((0,U.jsx)(em.div,{...n,ref:r}),o):null});tc.displayName="Portal";var td=0;function tu(){V.useEffect(()=>{let e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??th()),document.body.insertAdjacentElement("beforeend",e[1]??th()),td++,()=>{1===td&&document.querySelectorAll("[data-radix-focus-guard]").forEach(e=>e.remove()),td--}},[])}function th(){let e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var tf=function(){return(tf=Object.assign||function(e){for(var r,s=1,n=arguments.length;s<n;s++)for(var i in r=arguments[s])Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i]);return e}).apply(this,arguments)};function tp(e,r){var s={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&0>r.indexOf(n)&&(s[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var i=0,n=Object.getOwnPropertySymbols(e);i<n.length;i++)0>r.indexOf(n[i])&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(s[n[i]]=e[n[i]]);return s}var tm=("function"==typeof SuppressedError&&SuppressedError,"right-scroll-bar-position"),tg="width-before-scroll-bar";function tx(e,r){return"function"==typeof e?e(r):e&&(e.current=r),e}var tv="undefined"!=typeof window?V.useLayoutEffect:V.useEffect,ty=new WeakMap,tb=(void 0===vL&&(vL={}),(void 0===vO&&(vO=function(e){return e}),vB=[],vz=!1,v$={read:function(){if(vz)throw Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return vB.length?vB[vB.length-1]:null},useMedium:function(e){var r=vO(e,vz);return vB.push(r),function(){vB=vB.filter(function(e){return e!==r})}},assignSyncMedium:function(e){for(vz=!0;vB.length;){var r=vB;vB=[],r.forEach(e)}vB={push:function(r){return e(r)},filter:function(){return vB}}},assignMedium:function(e){vz=!0;var r=[];if(vB.length){var s=vB;vB=[],s.forEach(e),r=vB}var n=function(){var s=r;r=[],s.forEach(e)},i=function(){return Promise.resolve().then(n)};i(),vB={push:function(e){r.push(e),i()},filter:function(e){return r=r.filter(e),vB}}}}).options=tf({async:!0,ssr:!1},vL),v$),tw=function(){},t_=V.forwardRef(function(e,r){var s,n,i,a,o=V.useRef(null),l=V.useState({onScrollCapture:tw,onWheelCapture:tw,onTouchMoveCapture:tw}),c=l[0],d=l[1],u=e.forwardProps,h=e.children,f=e.className,p=e.removeScrollBar,m=e.enabled,g=e.shards,x=e.sideCar,v=e.noRelative,y=e.noIsolation,b=e.inert,w=e.allowPinchZoom,_=e.as,S=e.gapMode,k=tp(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),j=(s=[o,r],n=function(e){return s.forEach(function(r){return tx(r,e)})},(i=(0,V.useState)(function(){return{value:null,callback:n,facade:{get current(){return i.value},set current(value){var e=i.value;e!==value&&(i.value=value,i.callback(value,e))}}}})[0]).callback=n,a=i.facade,tv(function(){var e=ty.get(a);if(e){var r=new Set(e),n=new Set(s),i=a.current;r.forEach(function(e){n.has(e)||tx(e,null)}),n.forEach(function(e){r.has(e)||tx(e,i)})}ty.set(a,s)},[s]),a),C=tf(tf({},k),c);return V.createElement(V.Fragment,null,m&&V.createElement(x,{sideCar:tb,removeScrollBar:p,shards:g,noRelative:v,noIsolation:y,inert:b,setCallbacks:d,allowPinchZoom:!!w,lockRef:o,gapMode:S}),u?V.cloneElement(V.Children.only(h),tf(tf({},C),{ref:j})):V.createElement(void 0===_?"div":_,tf({},C,{className:f,ref:j}),h))});t_.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},t_.classNames={fullWidth:tg,zeroRight:tm};var tS=function(e){var r=e.sideCar,s=tp(e,["sideCar"]);if(!r)throw Error("Sidecar: please provide `sideCar` property to import the right car");var n=r.read();if(!n)throw Error("Sidecar medium not found");return V.createElement(n,tf({},s))};tS.isSideCarExport=!0;var tk=function(){var e=0,r=null;return{add:function(s){if(0==e&&(r=function(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var r=vq||("undefined"!=typeof __webpack_nonce__?__webpack_nonce__:void 0);return r&&e.setAttribute("nonce",r),e}())){var n,i;(n=r).styleSheet?n.styleSheet.cssText=s:n.appendChild(document.createTextNode(s)),i=r,(document.head||document.getElementsByTagName("head")[0]).appendChild(i)}e++},remove:function(){--e||!r||(r.parentNode&&r.parentNode.removeChild(r),r=null)}}},tj=function(){var e=tk();return function(r,s){V.useEffect(function(){return e.add(r),function(){e.remove()}},[r&&s])}},tC=function(){var e=tj();return function(r){return e(r.styles,r.dynamic),null}},tN={left:0,top:0,right:0,gap:0},tE=function(e){return parseInt(e||"",10)||0},tD=function(e){var r=window.getComputedStyle(document.body),s=r["padding"===e?"paddingLeft":"marginLeft"],n=r["padding"===e?"paddingTop":"marginTop"],i=r["padding"===e?"paddingRight":"marginRight"];return[tE(s),tE(n),tE(i)]},tT=function(e){if(void 0===e&&(e="margin"),"undefined"==typeof window)return tN;var r=tD(e),s=document.documentElement.clientWidth,n=window.innerWidth;return{left:r[0],top:r[1],right:r[2],gap:Math.max(0,n-s+r[2]-r[0])}},tR=tC(),tA="data-scroll-locked",tM=function(e,r,s,n){var i=e.left,a=e.top,o=e.right,l=e.gap;return void 0===s&&(s="margin"),"\n .".concat("with-scroll-bars-hidden"," {\n overflow: hidden ").concat(n,";\n padding-right: ").concat(l,"px ").concat(n,";\n }\n body[").concat(tA,"] {\n overflow: hidden ").concat(n,";\n overscroll-behavior: contain;\n ").concat([r&&"position: relative ".concat(n,";"),"margin"===s&&"\n padding-left: ".concat(i,"px;\n padding-top: ").concat(a,"px;\n padding-right: ").concat(o,"px;\n margin-left:0;\n margin-top:0;\n margin-right: ").concat(l,"px ").concat(n,";\n "),"padding"===s&&"padding-right: ".concat(l,"px ").concat(n,";")].filter(Boolean).join(""),"\n }\n \n .").concat(tm," {\n right: ").concat(l,"px ").concat(n,";\n }\n \n .").concat(tg," {\n margin-right: ").concat(l,"px ").concat(n,";\n }\n \n .").concat(tm," .").concat(tm," {\n right: 0 ").concat(n,";\n }\n \n .").concat(tg," .").concat(tg," {\n margin-right: 0 ").concat(n,";\n }\n \n body[").concat(tA,"] {\n ").concat("--removed-body-scroll-bar-size",": ").concat(l,"px;\n }\n")},tI=function(){var e=parseInt(document.body.getAttribute(tA)||"0",10);return isFinite(e)?e:0},tP=function(){V.useEffect(function(){return document.body.setAttribute(tA,(tI()+1).toString()),function(){var e=tI()-1;e<=0?document.body.removeAttribute(tA):document.body.setAttribute(tA,e.toString())}},[])},tF=function(e){var r=e.noRelative,s=e.noImportant,n=e.gapMode,i=void 0===n?"margin":n;tP();var a=V.useMemo(function(){return tT(i)},[i]);return V.createElement(tR,{styles:tM(a,!r,i,s?"":"!important")})},tL=!1;if("undefined"!=typeof window)try{var tO=Object.defineProperty({},"passive",{get:function(){return tL=!0,!0}});window.addEventListener("test",tO,tO),window.removeEventListener("test",tO,tO)}catch(e){tL=!1}var tB=!!tL&&{passive:!1},tz=function(e,r){if(!(e instanceof Element))return!1;var s=window.getComputedStyle(e);return"hidden"!==s[r]&&(s.overflowY!==s.overflowX||"TEXTAREA"===e.tagName||"visible"!==s[r])},t$=function(e,r){var s=r.ownerDocument,n=r;do{if("undefined"!=typeof ShadowRoot&&n instanceof ShadowRoot&&(n=n.host),tW(e,n)){var i=tH(e,n);if(i[1]>i[2])return!0}n=n.parentNode}while(n&&n!==s.body)return!1},tW=function(e,r){return"v"===e?tz(r,"overflowY"):tz(r,"overflowX")},tH=function(e,r){return"v"===e?[r.scrollTop,r.scrollHeight,r.clientHeight]:[r.scrollLeft,r.scrollWidth,r.clientWidth]},tU=function(e,r,s,n,i){var a,o=(a=window.getComputedStyle(r).direction,"h"===e&&"rtl"===a?-1:1),l=o*n,c=s.target,d=r.contains(c),u=!1,h=l>0,f=0,p=0;do{if(!c)break;var m=tH(e,c),g=m[0],x=m[1]-m[2]-o*g;(g||x)&&tW(e,c)&&(f+=x,p+=g);var v=c.parentNode;c=v&&v.nodeType===Node.DOCUMENT_FRAGMENT_NODE?v.host:v}while(!d&&c!==document.body||d&&(r.contains(c)||r===c))return h&&(i&&1>Math.abs(f)||!i&&l>f)?u=!0:!h&&(i&&1>Math.abs(p)||!i&&-l>p)&&(u=!0),u},tV=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},tq=function(e){return[e.deltaX,e.deltaY]},tK=function(e){return e&&"current"in e?e.current:e},tX=0,tY=[];let tG=(vW=function(e){var r=V.useRef([]),s=V.useRef([0,0]),n=V.useRef(),i=V.useState(tX++)[0],a=V.useState(tC)[0],o=V.useRef(e);V.useEffect(function(){o.current=e},[e]),V.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(i));var r=(function(e,r,s){if(s||2==arguments.length)for(var n,i=0,a=r.length;i<a;i++)!n&&i in r||(n||(n=Array.prototype.slice.call(r,0,i)),n[i]=r[i]);return e.concat(n||Array.prototype.slice.call(r))})([e.lockRef.current],(e.shards||[]).map(tK),!0).filter(Boolean);return r.forEach(function(e){return e.classList.add("allow-interactivity-".concat(i))}),function(){document.body.classList.remove("block-interactivity-".concat(i)),r.forEach(function(e){return e.classList.remove("allow-interactivity-".concat(i))})}}},[e.inert,e.lockRef.current,e.shards]);var l=V.useCallback(function(e,r){if("touches"in e&&2===e.touches.length||"wheel"===e.type&&e.ctrlKey)return!o.current.allowPinchZoom;var i,a=tV(e),l=s.current,c="deltaX"in e?e.deltaX:l[0]-a[0],d="deltaY"in e?e.deltaY:l[1]-a[1],u=e.target,h=Math.abs(c)>Math.abs(d)?"h":"v";if("touches"in e&&"h"===h&&"range"===u.type)return!1;var f=window.getSelection(),p=f&&f.anchorNode;if(p&&(p===u||p.contains(u)))return!1;var m=t$(h,u);if(!m)return!0;if(m?i=h:(i="v"===h?"h":"v",m=t$(h,u)),!m)return!1;if(!n.current&&"changedTouches"in e&&(c||d)&&(n.current=i),!i)return!0;var g=n.current||i;return tU(g,r,e,"h"===g?c:d,!0)},[]),c=V.useCallback(function(e){if(tY.length&&tY[tY.length-1]===a){var s="deltaY"in e?tq(e):tV(e),n=r.current.filter(function(r){var n;return r.name===e.type&&(r.target===e.target||e.target===r.shadowParent)&&(n=r.delta,n[0]===s[0]&&n[1]===s[1])})[0];if(n&&n.should){e.cancelable&&e.preventDefault();return}if(!n){var i=(o.current.shards||[]).map(tK).filter(Boolean).filter(function(r){return r.contains(e.target)});(i.length>0?l(e,i[0]):!o.current.noIsolation)&&e.cancelable&&e.preventDefault()}}},[]),d=V.useCallback(function(e,s,n,i){var a={name:e,delta:s,target:n,should:i,shadowParent:function(e){for(var r=null;null!==e;)e instanceof ShadowRoot&&(r=e.host,e=e.host),e=e.parentNode;return r}(n)};r.current.push(a),setTimeout(function(){r.current=r.current.filter(function(e){return e!==a})},1)},[]),u=V.useCallback(function(e){s.current=tV(e),n.current=void 0},[]),h=V.useCallback(function(r){d(r.type,tq(r),r.target,l(r,e.lockRef.current))},[]),f=V.useCallback(function(r){d(r.type,tV(r),r.target,l(r,e.lockRef.current))},[]);V.useEffect(function(){return tY.push(a),e.setCallbacks({onScrollCapture:h,onWheelCapture:h,onTouchMoveCapture:f}),document.addEventListener("wheel",c,tB),document.addEventListener("touchmove",c,tB),document.addEventListener("touchstart",u,tB),function(){tY=tY.filter(function(e){return e!==a}),document.removeEventListener("wheel",c,tB),document.removeEventListener("touchmove",c,tB),document.removeEventListener("touchstart",u,tB)}},[]);var p=e.removeScrollBar,m=e.inert;return V.createElement(V.Fragment,null,m?V.createElement(a,{styles:"\n .block-interactivity-".concat(i," {pointer-events: none;}\n .allow-interactivity-").concat(i," {pointer-events: all;}\n")}):null,p?V.createElement(tF,{noRelative:e.noRelative,gapMode:e.gapMode}):null)},tb.useMedium(vW),tS);var tJ=V.forwardRef(function(e,r){return V.createElement(t_,tf({},e,{ref:r,sideCar:tG}))});tJ.classNames=t_.classNames;var tZ=new WeakMap,tQ=new WeakMap,t0={},t1=0,t2=function(e){return e&&(e.host||t2(e.parentNode))},t5=function(e,r,s,n){var i=(Array.isArray(e)?e:[e]).map(function(e){if(r.contains(e))return e;var s=t2(e);return s&&r.contains(s)?s:(console.error("aria-hidden",e,"in not contained inside",r,". Doing nothing"),null)}).filter(function(e){return!!e});t0[s]||(t0[s]=new WeakMap);var a=t0[s],o=[],l=new Set,c=new Set(i),d=function(e){!e||l.has(e)||(l.add(e),d(e.parentNode))};i.forEach(d);var u=function(e){!e||c.has(e)||Array.prototype.forEach.call(e.children,function(e){if(l.has(e))u(e);else try{var r=e.getAttribute(n),i=null!==r&&"false"!==r,c=(tZ.get(e)||0)+1,d=(a.get(e)||0)+1;tZ.set(e,c),a.set(e,d),o.push(e),1===c&&i&&tQ.set(e,!0),1===d&&e.setAttribute(s,"true"),i||e.setAttribute(n,"true")}catch(r){console.error("aria-hidden: cannot operate on ",e,r)}})};return u(r),l.clear(),t1++,function(){o.forEach(function(e){var r=tZ.get(e)-1,i=a.get(e)-1;tZ.set(e,r),a.set(e,i),r||(tQ.has(e)||e.removeAttribute(n),tQ.delete(e)),i||e.removeAttribute(s)}),--t1||(tZ=new WeakMap,tZ=new WeakMap,tQ=new WeakMap,t0={})}},t3=function(e,r,s){void 0===s&&(s="data-aria-hidden");var n=Array.from(Array.isArray(e)?e:[e]),i=r||("undefined"==typeof document?null:(Array.isArray(e)?e[0]:e).ownerDocument.body);return i?(n.push.apply(n,Array.from(i.querySelectorAll("[aria-live], script"))),t5(n,i,s,"aria-hidden")):function(){return null}},t4="Dialog",[t6,t7]=es(t4),[t8,t9]=t6(t4),re=e=>{let{__scopeDialog:r,children:s,open:n,defaultOpen:i,onOpenChange:a,modal:o=!0}=e,l=V.useRef(null),c=V.useRef(null),[d,u]=ey({prop:n,defaultProp:i??!1,onChange:a,caller:t4});return(0,U.jsx)(t8,{scope:r,triggerRef:l,contentRef:c,contentId:ef(),titleId:ef(),descriptionId:ef(),open:d,onOpenChange:u,onOpenToggle:V.useCallback(()=>u(e=>!e),[u]),modal:o,children:s})};re.displayName=t4;var rt="DialogTrigger",rr=V.forwardRef((e,r)=>{let{__scopeDialog:s,...n}=e,i=t9(rt,s),a=(0,en.useComposedRefs)(r,i.triggerRef);return(0,U.jsx)(em.button,{type:"button","aria-haspopup":"dialog","aria-expanded":i.open,"aria-controls":i.contentId,"data-state":r_(i.open),...n,ref:a,onClick:er(e.onClick,i.onOpenToggle)})});rr.displayName=rt;var rs="DialogPortal",[rn,ri]=t6(rs,{forceMount:void 0}),ra=e=>{let{__scopeDialog:r,forceMount:s,children:n,container:i}=e,a=t9(rs,r);return(0,U.jsx)(rn,{scope:r,forceMount:s,children:V.Children.map(n,e=>(0,U.jsx)(eO,{present:s||a.open,children:(0,U.jsx)(tc,{asChild:!0,container:i,children:e})}))})};ra.displayName=rs;var ro="DialogOverlay",rl=V.forwardRef((e,r)=>{let s=ri(ro,e.__scopeDialog),{forceMount:n=s.forceMount,...i}=e,a=t9(ro,e.__scopeDialog);return a.modal?(0,U.jsx)(eO,{present:n||a.open,children:(0,U.jsx)(rd,{...i,ref:r})}):null});rl.displayName=ro;var rc=(0,ei.createSlot)("DialogOverlay.RemoveScroll"),rd=V.forwardRef((e,r)=>{let{__scopeDialog:s,...n}=e,i=t9(ro,s);return(0,U.jsx)(tJ,{as:rc,allowPinchZoom:!0,shards:[i.contentRef],children:(0,U.jsx)(em.div,{"data-state":r_(i.open),...n,ref:r,style:{pointerEvents:"auto",...n.style}})})}),ru="DialogContent",rh=V.forwardRef((e,r)=>{let s=ri(ru,e.__scopeDialog),{forceMount:n=s.forceMount,...i}=e,a=t9(ru,e.__scopeDialog);return(0,U.jsx)(eO,{present:n||a.open,children:a.modal?(0,U.jsx)(rf,{...i,ref:r}):(0,U.jsx)(rp,{...i,ref:r})})});rh.displayName=ru;var rf=V.forwardRef((e,r)=>{let s=t9(ru,e.__scopeDialog),n=V.useRef(null),i=(0,en.useComposedRefs)(r,s.contentRef,n);return V.useEffect(()=>{let e=n.current;if(e)return t3(e)},[]),(0,U.jsx)(rm,{...e,ref:i,trapFocus:s.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:er(e.onCloseAutoFocus,e=>{e.preventDefault(),s.triggerRef.current?.focus()}),onPointerDownOutside:er(e.onPointerDownOutside,e=>{let r=e.detail.originalEvent,s=0===r.button&&!0===r.ctrlKey;(2===r.button||s)&&e.preventDefault()}),onFocusOutside:er(e.onFocusOutside,e=>e.preventDefault())})}),rp=V.forwardRef((e,r)=>{let s=t9(ru,e.__scopeDialog),n=V.useRef(!1),i=V.useRef(!1);return(0,U.jsx)(rm,{...e,ref:r,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:r=>{e.onCloseAutoFocus?.(r),r.defaultPrevented||(n.current||s.triggerRef.current?.focus(),r.preventDefault()),n.current=!1,i.current=!1},onInteractOutside:r=>{e.onInteractOutside?.(r),r.defaultPrevented||(n.current=!0,"pointerdown"===r.detail.originalEvent.type&&(i.current=!0));let a=r.target;s.triggerRef.current?.contains(a)&&r.preventDefault(),"focusin"===r.detail.originalEvent.type&&i.current&&r.preventDefault()}})}),rm=V.forwardRef((e,r)=>{let{__scopeDialog:s,trapFocus:n,onOpenAutoFocus:i,onCloseAutoFocus:a,...o}=e,l=t9(ru,s),c=V.useRef(null),d=(0,en.useComposedRefs)(r,c);return tu(),(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(ts,{asChild:!0,loop:!0,trapped:n,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,U.jsx)(e7,{role:"dialog",id:l.contentId,"aria-describedby":l.descriptionId,"aria-labelledby":l.titleId,"data-state":r_(l.open),...o,ref:d,onDismiss:()=>l.onOpenChange(!1)})}),(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(rC,{titleId:l.titleId}),(0,U.jsx)(rN,{contentRef:c,descriptionId:l.descriptionId})]})]})}),rg="DialogTitle",rx=V.forwardRef((e,r)=>{let{__scopeDialog:s,...n}=e,i=t9(rg,s);return(0,U.jsx)(em.h2,{id:i.titleId,...n,ref:r})});rx.displayName=rg;var rv="DialogDescription",ry=V.forwardRef((e,r)=>{let{__scopeDialog:s,...n}=e,i=t9(rv,s);return(0,U.jsx)(em.p,{id:i.descriptionId,...n,ref:r})});ry.displayName=rv;var rb="DialogClose",rw=V.forwardRef((e,r)=>{let{__scopeDialog:s,...n}=e,i=t9(rb,s);return(0,U.jsx)(em.button,{type:"button",...n,ref:r,onClick:er(e.onClick,()=>i.onOpenChange(!1))})});function r_(e){return e?"open":"closed"}rw.displayName=rb;var rS="DialogTitleWarning",[rk,rj]=(vH={contentName:ru,titleName:rg,docsSlug:"dialog"},n=V.createContext(vH),(i=e=>{let{children:r,...s}=e,i=V.useMemo(()=>s,Object.values(s));return(0,U.jsx)(n.Provider,{value:i,children:r})}).displayName=rS+"Provider",[i,function(e){let r=V.useContext(n);if(r)return r;if(void 0!==vH)return vH;throw Error(`\`${e}\` must be used within \`${rS}\``)}]),rC=({titleId:e})=>{let r=rj(rS),s=`\`${r.contentName}\` requires a \`${r.titleName}\` for the component to be accessible for screen reader users.
2
+
3
+ If you want to hide the \`${r.titleName}\`, you can wrap it with our VisuallyHidden component.
4
+
5
+ For more information, see https://radix-ui.com/primitives/docs/components/${r.docsSlug}`;return V.useEffect(()=>{e&&(document.getElementById(e)||console.error(s))},[s,e]),null},rN=({contentRef:e,descriptionId:r})=>{let s=rj("DialogDescriptionWarning"),n=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${s.contentName}}.`;return V.useEffect(()=>{let s=e.current?.getAttribute("aria-describedby");r&&s&&(document.getElementById(r)||console.warn(n))},[n,e,r]),null};e.s(["Close",()=>rw,"Content",()=>rh,"Description",()=>ry,"Dialog",()=>re,"DialogClose",()=>rw,"DialogContent",()=>rh,"DialogDescription",()=>ry,"DialogOverlay",()=>rl,"DialogPortal",()=>ra,"DialogTitle",()=>rx,"DialogTrigger",()=>rr,"Overlay",()=>rl,"Portal",()=>ra,"Root",()=>re,"Title",()=>rx,"Trigger",()=>rr,"WarningProvider",()=>rk,"createDialogScope",()=>t7],212142);var rE=e.i(198631);let rD=(0,rE.default)("x",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);function rT({...e}){return(0,U.jsx)(re,{"data-slot":"dialog",...e})}function rR({...e}){return(0,U.jsx)(rr,{"data-slot":"dialog-trigger",...e})}function rA({...e}){return(0,U.jsx)(ra,{"data-slot":"dialog-portal",...e})}function rM({...e}){return(0,U.jsx)(rw,{"data-slot":"dialog-close",...e})}function rI({className:e,...r}){return(0,U.jsx)(rl,{"data-slot":"dialog-overlay",className:(0,e1.cn)("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",e),...r})}function rP({className:e,children:r,showCloseButton:s=!0,overlayClassName:n,...i}){return(0,U.jsxs)(rA,{"data-slot":"dialog-portal",children:[(0,U.jsx)(rI,{className:n}),(0,U.jsxs)(rh,{"data-slot":"dialog-content",className:(0,e1.cn)("bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 outline-none sm:max-w-lg",e),...i,children:[r,s&&(0,U.jsxs)(rw,{"data-slot":"dialog-close",className:"ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",children:[(0,U.jsx)(rD,{}),(0,U.jsx)("span",{className:"sr-only",children:"Close"})]})]})]})}function rF({className:e,...r}){return(0,U.jsx)("div",{"data-slot":"dialog-header",className:(0,e1.cn)("flex flex-col gap-2 text-center sm:text-left",e),...r})}function rL({className:e,...r}){return(0,U.jsx)("div",{"data-slot":"dialog-footer",className:(0,e1.cn)("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",e),...r})}function rO({className:e,...r}){return(0,U.jsx)(rx,{"data-slot":"dialog-title",className:(0,e1.cn)("text-lg leading-none font-semibold",e),...r})}function rB({className:e,...r}){return(0,U.jsx)(ry,{"data-slot":"dialog-description",className:(0,e1.cn)("text-muted-foreground text-sm",e),...r})}let rz=(0,rE.default)("arrow-up-right",[["path",{d:"M7 7h10v10",key:"1tivn9"}],["path",{d:"M7 17 17 7",key:"1vkiza"}]]);var r$=Symbol.for("react.lazy"),rW=V[" use ".trim().toString()];function rH(e){var r;return null!=e&&"object"==typeof e&&"$$typeof"in e&&e.$$typeof===r$&&"_payload"in e&&"object"==typeof(r=e._payload)&&null!==r&&"then"in r}function rU(e){var r;let s,n=(r=e,(s=V.forwardRef((e,r)=>{let{children:s,...n}=e;if(rH(s)&&"function"==typeof rW&&(s=rW(s._payload)),V.isValidElement(s)){var i;let e,a,o=(i=s,(a=(e=Object.getOwnPropertyDescriptor(i.props,"ref")?.get)&&"isReactWarning"in e&&e.isReactWarning)?i.ref:(a=(e=Object.getOwnPropertyDescriptor(i,"ref")?.get)&&"isReactWarning"in e&&e.isReactWarning)?i.props.ref:i.props.ref||i.ref),l=function(e,r){let s={...r};for(let n in r){let i=e[n],a=r[n];/^on[A-Z]/.test(n)?i&&a?s[n]=(...e)=>{let r=a(...e);return i(...e),r}:i&&(s[n]=i):"style"===n?s[n]={...i,...a}:"className"===n&&(s[n]=[i,a].filter(Boolean).join(" "))}return{...e,...s}}(n,s.props);return s.type!==V.Fragment&&(l.ref=r?(0,en.composeRefs)(r,o):o),V.cloneElement(s,l)}return V.Children.count(s)>1?V.Children.only(null):null})).displayName=`${r}.SlotClone`,s),i=V.forwardRef((e,r)=>{let{children:s,...i}=e;rH(s)&&"function"==typeof rW&&(s=rW(s._payload));let a=V.Children.toArray(s),o=a.find(rK);if(o){let e=o.props.children,s=a.map(r=>r!==o?r:V.Children.count(e)>1?V.Children.only(null):V.isValidElement(e)?e.props.children:null);return(0,U.jsx)(n,{...i,ref:r,children:V.isValidElement(e)?V.cloneElement(e,void 0,s):null})}return(0,U.jsx)(n,{...i,ref:r,children:s})});return i.displayName=`${e}.Slot`,i}var rV=rU("Slot"),rq=Symbol("radix.slottable");function rK(e){return V.isValidElement(e)&&"function"==typeof e.type&&"__radixId"in e.type&&e.type.__radixId===rq}var rX=e.i(294237);let rY=(0,rX.cva)("inline-flex items-center justify-center rounded-full border px-2 py-0.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 [&>svg]:size-3 gap-1 [&>svg]:pointer-events-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive transition-[color,box-shadow] overflow-hidden",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground [a&]:hover:bg-primary/90",secondary:"border-transparent bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90",destructive:"border-transparent bg-destructive text-white [a&]:hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground"}},defaultVariants:{variant:"default"}});function rG({className:e,variant:r,asChild:s=!1,...n}){return(0,U.jsx)(s?rV:"span",{"data-slot":"badge",className:(0,e1.cn)(rY({variant:r}),e),...n})}let rJ=(0,rE.default)("message-square",[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}]]);function rZ({source:e,onOpen:r}){let s=e.title?.trim()||"Untitled session";return e.exists?(0,U.jsxs)("button",{type:"button",onClick:()=>r?.(e.branch||null,e.id),disabled:!r,className:"inline-flex min-w-0 items-center gap-1 text-primary hover:underline disabled:no-underline disabled:text-foreground",title:s,children:[(0,U.jsx)(rJ,{className:"h-3.5 w-3.5 shrink-0"}),(0,U.jsx)("span",{className:"truncate",children:s})]}):(0,U.jsx)("span",{className:"text-muted-foreground italic",children:"Source session deleted"})}var rQ=e.i(94265),r0=rQ;let r1={todo:{label:"Todo",color:"bg-muted text-muted-foreground"},in_progress:{label:"In Progress",color:"bg-blue-100 text-blue-800 dark:bg-blue-900/40 dark:text-blue-300"},done:{label:"Done",color:"bg-green-100 text-green-800 dark:bg-green-900/40 dark:text-green-300"},cancelled:{label:"Cancelled",color:"bg-neutral-100 text-neutral-500 dark:bg-neutral-800 dark:text-neutral-400 line-through"}},r2={low:{label:"Low",color:"bg-muted text-muted-foreground"},medium:{label:"Medium",color:"bg-yellow-100 text-yellow-800 dark:bg-yellow-900/40 dark:text-yellow-300"},high:{label:"High",color:"bg-orange-100 text-orange-800 dark:bg-orange-900/40 dark:text-orange-300"},urgent:{label:"Urgent",color:"bg-red-100 text-red-800 dark:bg-red-900/40 dark:text-red-300"}},r5=["todo","in_progress","done","cancelled"],r3=["low","medium","high","urgent"];function r4(e){return""===e?"main":e}let r6=/\[([^\]\n]*)\]\(\s*[^)\s]*\s*\)/g;function r7(e,r=80){let s=e.replace(r6,"$1").replace(/`/g,"").replace(/^\s*(?:[-*+]|\d+\.|#{1,6})\s+/gm,"").replace(/\s*\n\s*/g," ").trim();return s.length>r?s.slice(0,r)+"...":s}let r8={urgent:0,high:1,medium:2,low:3};function r9(e,r=Date.now()){let s=Math.floor(Math.max(0,r-new Date(e).getTime())/6e4);if(s<1)return"now";if(s<60)return`${s}m`;let n=Math.floor(s/60);if(n<24)return`${n}h`;let i=Math.floor(n/24);return i<7?`${i}d`:i<30?`${Math.floor(i/7)}w`:i<365?`${Math.floor(i/30)}mo`:`${Math.floor(i/365)}y`}let se=["top","right","bottom","left"],st=Math.min,sr=Math.max,ss=Math.round,sn=Math.floor,si=e=>({x:e,y:e}),sa={left:"right",right:"left",bottom:"top",top:"bottom"},so={start:"end",end:"start"};function sl(e,r){return"function"==typeof e?e(r):e}function sc(e){return e.split("-")[0]}function sd(e){return e.split("-")[1]}function su(e){return"x"===e?"y":"x"}function sh(e){return"y"===e?"height":"width"}let sf=new Set(["top","bottom"]);function sp(e){return sf.has(sc(e))?"y":"x"}function sm(e){return e.replace(/start|end/g,e=>so[e])}let sg=["left","right"],sx=["right","left"],sv=["top","bottom"],sy=["bottom","top"];function sb(e){return e.replace(/left|right|bottom|top/g,e=>sa[e])}function sw(e){return"number"!=typeof e?{top:0,right:0,bottom:0,left:0,...e}:{top:e,right:e,bottom:e,left:e}}function s_(e){let{x:r,y:s,width:n,height:i}=e;return{width:n,height:i,top:s,left:r,right:r+n,bottom:s+i,x:r,y:s}}function sS(e,r,s){let n,{reference:i,floating:a}=e,o=sp(r),l=su(sp(r)),c=sh(l),d=sc(r),u="y"===o,h=i.x+i.width/2-a.width/2,f=i.y+i.height/2-a.height/2,p=i[c]/2-a[c]/2;switch(d){case"top":n={x:h,y:i.y-a.height};break;case"bottom":n={x:h,y:i.y+i.height};break;case"right":n={x:i.x+i.width,y:f};break;case"left":n={x:i.x-a.width,y:f};break;default:n={x:i.x,y:i.y}}switch(sd(r)){case"start":n[l]-=p*(s&&u?-1:1);break;case"end":n[l]+=p*(s&&u?-1:1)}return n}async function sk(e,r){var s;void 0===r&&(r={});let{x:n,y:i,platform:a,rects:o,elements:l,strategy:c}=e,{boundary:d="clippingAncestors",rootBoundary:u="viewport",elementContext:h="floating",altBoundary:f=!1,padding:p=0}=sl(r,e),m=sw(p),g=l[f?"floating"===h?"reference":"floating":h],x=s_(await a.getClippingRect({element:null==(s=await (null==a.isElement?void 0:a.isElement(g)))||s?g:g.contextElement||await (null==a.getDocumentElement?void 0:a.getDocumentElement(l.floating)),boundary:d,rootBoundary:u,strategy:c})),v="floating"===h?{x:n,y:i,width:o.floating.width,height:o.floating.height}:o.reference,y=await (null==a.getOffsetParent?void 0:a.getOffsetParent(l.floating)),b=await (null==a.isElement?void 0:a.isElement(y))&&await (null==a.getScale?void 0:a.getScale(y))||{x:1,y:1},w=s_(a.convertOffsetParentRelativeRectToViewportRelativeRect?await a.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:v,offsetParent:y,strategy:c}):v);return{top:(x.top-w.top+m.top)/b.y,bottom:(w.bottom-x.bottom+m.bottom)/b.y,left:(x.left-w.left+m.left)/b.x,right:(w.right-x.right+m.right)/b.x}}let sj=async(e,r,s)=>{let{placement:n="bottom",strategy:i="absolute",middleware:a=[],platform:o}=s,l=a.filter(Boolean),c=await (null==o.isRTL?void 0:o.isRTL(r)),d=await o.getElementRects({reference:e,floating:r,strategy:i}),{x:u,y:h}=sS(d,n,c),f=n,p={},m=0;for(let s=0;s<l.length;s++){var g;let{name:a,fn:x}=l[s],{x:v,y:y,data:b,reset:w}=await x({x:u,y:h,initialPlacement:n,placement:f,strategy:i,middlewareData:p,rects:d,platform:{...o,detectOverflow:null!=(g=o.detectOverflow)?g:sk},elements:{reference:e,floating:r}});u=null!=v?v:u,h=null!=y?y:h,p={...p,[a]:{...p[a],...b}},w&&m<=50&&(m++,"object"==typeof w&&(w.placement&&(f=w.placement),w.rects&&(d=!0===w.rects?await o.getElementRects({reference:e,floating:r,strategy:i}):w.rects),{x:u,y:h}=sS(d,f,c)),s=-1)}return{x:u,y:h,placement:f,strategy:i,middlewareData:p}};function sC(e,r){return{top:e.top-r.height,right:e.right-r.width,bottom:e.bottom-r.height,left:e.left-r.width}}function sN(e){return se.some(r=>e[r]>=0)}let sE=new Set(["left","top"]);async function sD(e,r){let{placement:s,platform:n,elements:i}=e,a=await (null==n.isRTL?void 0:n.isRTL(i.floating)),o=sc(s),l=sd(s),c="y"===sp(s),d=sE.has(o)?-1:1,u=a&&c?-1:1,h=sl(r,e),{mainAxis:f,crossAxis:p,alignmentAxis:m}="number"==typeof h?{mainAxis:h,crossAxis:0,alignmentAxis:null}:{mainAxis:h.mainAxis||0,crossAxis:h.crossAxis||0,alignmentAxis:h.alignmentAxis};return l&&"number"==typeof m&&(p="end"===l?-1*m:m),c?{x:p*u,y:f*d}:{x:f*d,y:p*u}}function sT(){return"undefined"!=typeof window}function sR(e){return sI(e)?(e.nodeName||"").toLowerCase():"#document"}function sA(e){var r;return(null==e||null==(r=e.ownerDocument)?void 0:r.defaultView)||window}function sM(e){var r;return null==(r=(sI(e)?e.ownerDocument:e.document)||window.document)?void 0:r.documentElement}function sI(e){return!!sT()&&(e instanceof Node||e instanceof sA(e).Node)}function sP(e){return!!sT()&&(e instanceof Element||e instanceof sA(e).Element)}function sF(e){return!!sT()&&(e instanceof HTMLElement||e instanceof sA(e).HTMLElement)}function sL(e){return!!sT()&&"undefined"!=typeof ShadowRoot&&(e instanceof ShadowRoot||e instanceof sA(e).ShadowRoot)}let sO=new Set(["inline","contents"]);function sB(e){let{overflow:r,overflowX:s,overflowY:n,display:i}=sG(e);return/auto|scroll|overlay|hidden|clip/.test(r+n+s)&&!sO.has(i)}let sz=new Set(["table","td","th"]),s$=[":popover-open",":modal"];function sW(e){return s$.some(r=>{try{return e.matches(r)}catch(e){return!1}})}let sH=["transform","translate","scale","rotate","perspective"],sU=["transform","translate","scale","rotate","perspective","filter"],sV=["paint","layout","strict","content"];function sq(e){let r=sK(),s=sP(e)?sG(e):e;return sH.some(e=>!!s[e]&&"none"!==s[e])||!!s.containerType&&"normal"!==s.containerType||!r&&!!s.backdropFilter&&"none"!==s.backdropFilter||!r&&!!s.filter&&"none"!==s.filter||sU.some(e=>(s.willChange||"").includes(e))||sV.some(e=>(s.contain||"").includes(e))}function sK(){return"undefined"!=typeof CSS&&!!CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")}let sX=new Set(["html","body","#document"]);function sY(e){return sX.has(sR(e))}function sG(e){return sA(e).getComputedStyle(e)}function sJ(e){return sP(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function sZ(e){if("html"===sR(e))return e;let r=e.assignedSlot||e.parentNode||sL(e)&&e.host||sM(e);return sL(r)?r.host:r}function sQ(e,r,s){var n;void 0===r&&(r=[]),void 0===s&&(s=!0);let i=function e(r){let s=sZ(r);return sY(s)?r.ownerDocument?r.ownerDocument.body:r.body:sF(s)&&sB(s)?s:e(s)}(e),a=i===(null==(n=e.ownerDocument)?void 0:n.body),o=sA(i);if(a){let e=s0(o);return r.concat(o,o.visualViewport||[],sB(i)?i:[],e&&s?sQ(e):[])}return r.concat(i,sQ(i,[],s))}function s0(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function s1(e){let r=sG(e),s=parseFloat(r.width)||0,n=parseFloat(r.height)||0,i=sF(e),a=i?e.offsetWidth:s,o=i?e.offsetHeight:n,l=ss(s)!==a||ss(n)!==o;return l&&(s=a,n=o),{width:s,height:n,$:l}}function s2(e){return sP(e)?e:e.contextElement}function s5(e){let r=s2(e);if(!sF(r))return si(1);let s=r.getBoundingClientRect(),{width:n,height:i,$:a}=s1(r),o=(a?ss(s.width):s.width)/n,l=(a?ss(s.height):s.height)/i;return o&&Number.isFinite(o)||(o=1),l&&Number.isFinite(l)||(l=1),{x:o,y:l}}let s3=si(0);function s4(e){let r=sA(e);return sK()&&r.visualViewport?{x:r.visualViewport.offsetLeft,y:r.visualViewport.offsetTop}:s3}function s6(e,r,s,n){var i;void 0===r&&(r=!1),void 0===s&&(s=!1);let a=e.getBoundingClientRect(),o=s2(e),l=si(1);r&&(n?sP(n)&&(l=s5(n)):l=s5(e));let c=(void 0===(i=s)&&(i=!1),n&&(!i||n===sA(o))&&i)?s4(o):si(0),d=(a.left+c.x)/l.x,u=(a.top+c.y)/l.y,h=a.width/l.x,f=a.height/l.y;if(o){let e=sA(o),r=n&&sP(n)?sA(n):n,s=e,i=s0(s);for(;i&&n&&r!==s;){let e=s5(i),r=i.getBoundingClientRect(),n=sG(i),a=r.left+(i.clientLeft+parseFloat(n.paddingLeft))*e.x,o=r.top+(i.clientTop+parseFloat(n.paddingTop))*e.y;d*=e.x,u*=e.y,h*=e.x,f*=e.y,d+=a,u+=o,i=s0(s=sA(i))}}return s_({width:h,height:f,x:d,y:u})}function s7(e,r){let s=sJ(e).scrollLeft;return r?r.left+s:s6(sM(e)).left+s}function s8(e,r){let s=e.getBoundingClientRect();return{x:s.left+r.scrollLeft-s7(e,s),y:s.top+r.scrollTop}}let s9=new Set(["absolute","fixed"]);function ne(e,r,s){var n;let i;if("viewport"===r)i=function(e,r){let s=sA(e),n=sM(e),i=s.visualViewport,a=n.clientWidth,o=n.clientHeight,l=0,c=0;if(i){a=i.width,o=i.height;let e=sK();(!e||e&&"fixed"===r)&&(l=i.offsetLeft,c=i.offsetTop)}let d=s7(n);if(d<=0){let e=n.ownerDocument,r=e.body,s=getComputedStyle(r),i="CSS1Compat"===e.compatMode&&parseFloat(s.marginLeft)+parseFloat(s.marginRight)||0,o=Math.abs(n.clientWidth-r.clientWidth-i);o<=25&&(a-=o)}else d<=25&&(a+=d);return{width:a,height:o,x:l,y:c}}(e,s);else if("document"===r){let r,s,a,o,l,c,d;n=sM(e),r=sM(n),s=sJ(n),a=n.ownerDocument.body,o=sr(r.scrollWidth,r.clientWidth,a.scrollWidth,a.clientWidth),l=sr(r.scrollHeight,r.clientHeight,a.scrollHeight,a.clientHeight),c=-s.scrollLeft+s7(n),d=-s.scrollTop,"rtl"===sG(a).direction&&(c+=sr(r.clientWidth,a.clientWidth)-o),i={width:o,height:l,x:c,y:d}}else if(sP(r)){let e,n,a,o,l,c;n=(e=s6(r,!0,"fixed"===s)).top+r.clientTop,a=e.left+r.clientLeft,o=sF(r)?s5(r):si(1),l=r.clientWidth*o.x,c=r.clientHeight*o.y,i={width:l,height:c,x:a*o.x,y:n*o.y}}else{let s=s4(e);i={x:r.x-s.x,y:r.y-s.y,width:r.width,height:r.height}}return s_(i)}function nt(e){return"static"===sG(e).position}function nr(e,r){if(!sF(e)||"fixed"===sG(e).position)return null;if(r)return r(e);let s=e.offsetParent;return sM(e)===s&&(s=s.ownerDocument.body),s}function ns(e,r){var s;let n=sA(e);if(sW(e))return n;if(!sF(e)){let r=sZ(e);for(;r&&!sY(r);){if(sP(r)&&!nt(r))return r;r=sZ(r)}return n}let i=nr(e,r);for(;i&&(s=i,sz.has(sR(s)))&&nt(i);)i=nr(i,r);return i&&sY(i)&&nt(i)&&!sq(i)?n:i||function(e){let r=sZ(e);for(;sF(r)&&!sY(r);){if(sq(r))return r;if(sW(r))break;r=sZ(r)}return null}(e)||n}let nn=async function(e){let r=this.getOffsetParent||ns,s=this.getDimensions,n=await s(e.floating);return{reference:function(e,r,s){let n=sF(r),i=sM(r),a="fixed"===s,o=s6(e,!0,a,r),l={scrollLeft:0,scrollTop:0},c=si(0);if(n||!n&&!a)if(("body"!==sR(r)||sB(i))&&(l=sJ(r)),n){let e=s6(r,!0,a,r);c.x=e.x+r.clientLeft,c.y=e.y+r.clientTop}else i&&(c.x=s7(i));a&&!n&&i&&(c.x=s7(i));let d=!i||n||a?si(0):s8(i,l);return{x:o.left+l.scrollLeft-c.x-d.x,y:o.top+l.scrollTop-c.y-d.y,width:o.width,height:o.height}}(e.reference,await r(e.floating),e.strategy),floating:{x:0,y:0,width:n.width,height:n.height}}},ni={convertOffsetParentRelativeRectToViewportRelativeRect:function(e){let{elements:r,rect:s,offsetParent:n,strategy:i}=e,a="fixed"===i,o=sM(n),l=!!r&&sW(r.floating);if(n===o||l&&a)return s;let c={scrollLeft:0,scrollTop:0},d=si(1),u=si(0),h=sF(n);if((h||!h&&!a)&&(("body"!==sR(n)||sB(o))&&(c=sJ(n)),sF(n))){let e=s6(n);d=s5(n),u.x=e.x+n.clientLeft,u.y=e.y+n.clientTop}let f=!o||h||a?si(0):s8(o,c);return{width:s.width*d.x,height:s.height*d.y,x:s.x*d.x-c.scrollLeft*d.x+u.x+f.x,y:s.y*d.y-c.scrollTop*d.y+u.y+f.y}},getDocumentElement:sM,getClippingRect:function(e){let{element:r,boundary:s,rootBoundary:n,strategy:i}=e,a=[..."clippingAncestors"===s?sW(r)?[]:function(e,r){let s=r.get(e);if(s)return s;let n=sQ(e,[],!1).filter(e=>sP(e)&&"body"!==sR(e)),i=null,a="fixed"===sG(e).position,o=a?sZ(e):e;for(;sP(o)&&!sY(o);){let r=sG(o),s=sq(o);s||"fixed"!==r.position||(i=null),(a?!s&&!i:!s&&"static"===r.position&&!!i&&s9.has(i.position)||sB(o)&&!s&&function e(r,s){let n=sZ(r);return!(n===s||!sP(n)||sY(n))&&("fixed"===sG(n).position||e(n,s))}(e,o))?n=n.filter(e=>e!==o):i=r,o=sZ(o)}return r.set(e,n),n}(r,this._c):[].concat(s),n],o=a[0],l=a.reduce((e,s)=>{let n=ne(r,s,i);return e.top=sr(n.top,e.top),e.right=st(n.right,e.right),e.bottom=st(n.bottom,e.bottom),e.left=sr(n.left,e.left),e},ne(r,o,i));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}},getOffsetParent:ns,getElementRects:nn,getClientRects:function(e){return Array.from(e.getClientRects())},getDimensions:function(e){let{width:r,height:s}=s1(e);return{width:r,height:s}},getScale:s5,isElement:sP,isRTL:function(e){return"rtl"===sG(e).direction}};function na(e,r){return e.x===r.x&&e.y===r.y&&e.width===r.width&&e.height===r.height}let no=e=>({name:"arrow",options:e,async fn(r){let{x:s,y:n,placement:i,rects:a,platform:o,elements:l,middlewareData:c}=r,{element:d,padding:u=0}=sl(e,r)||{};if(null==d)return{};let h=sw(u),f={x:s,y:n},p=su(sp(i)),m=sh(p),g=await o.getDimensions(d),x="y"===p,v=x?"clientHeight":"clientWidth",y=a.reference[m]+a.reference[p]-f[p]-a.floating[m],b=f[p]-a.reference[p],w=await (null==o.getOffsetParent?void 0:o.getOffsetParent(d)),_=w?w[v]:0;_&&await (null==o.isElement?void 0:o.isElement(w))||(_=l.floating[v]||a.floating[m]);let S=_/2-g[m]/2-1,k=st(h[x?"top":"left"],S),j=st(h[x?"bottom":"right"],S),C=_-g[m]-j,N=_/2-g[m]/2+(y/2-b/2),E=sr(k,st(N,C)),D=!c.arrow&&null!=sd(i)&&N!==E&&a.reference[m]/2-(N<k?k:j)-g[m]/2<0,T=D?N<k?N-k:N-C:0;return{[p]:f[p]+T,data:{[p]:E,centerOffset:N-E-T,...D&&{alignmentOffset:T}},reset:D}}});var nl="undefined"!=typeof document?V.useLayoutEffect:function(){};function nc(e,r){let s,n,i;if(e===r)return!0;if(typeof e!=typeof r)return!1;if("function"==typeof e&&e.toString()===r.toString())return!0;if(e&&r&&"object"==typeof e){if(Array.isArray(e)){if((s=e.length)!==r.length)return!1;for(n=s;0!=n--;)if(!nc(e[n],r[n]))return!1;return!0}if((s=(i=Object.keys(e)).length)!==Object.keys(r).length)return!1;for(n=s;0!=n--;)if(!({}).hasOwnProperty.call(r,i[n]))return!1;for(n=s;0!=n--;){let s=i[n];if(("_owner"!==s||!e.$$typeof)&&!nc(e[s],r[s]))return!1}return!0}return e!=e&&r!=r}function nd(e){return"undefined"==typeof window?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function nu(e,r){let s=nd(e);return Math.round(r*s)/s}function nh(e){let r=V.useRef(e);return nl(()=>{r.current=e}),r}var nf=V.forwardRef((e,r)=>{let{children:s,width:n=10,height:i=5,...a}=e;return(0,U.jsx)(em.svg,{...a,ref:r,width:n,height:i,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?s:(0,U.jsx)("polygon",{points:"0,0 30,0 15,10"})})});function np(e){let[r,s]=V.useState(void 0);return ed(()=>{if(e){s({width:e.offsetWidth,height:e.offsetHeight});let r=new ResizeObserver(r=>{let n,i;if(!Array.isArray(r)||!r.length)return;let a=r[0];if("borderBoxSize"in a){let e=a.borderBoxSize,r=Array.isArray(e)?e[0]:e;n=r.inlineSize,i=r.blockSize}else n=e.offsetWidth,i=e.offsetHeight;s({width:n,height:i})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}s(void 0)},[e]),r}nf.displayName="Arrow";var nm="Popper",[ng,nx]=es(nm),[nv,ny]=ng(nm),nb=e=>{let{__scopePopper:r,children:s}=e,[n,i]=V.useState(null);return(0,U.jsx)(nv,{scope:r,anchor:n,onAnchorChange:i,children:s})};nb.displayName=nm;var nw="PopperAnchor",n_=V.forwardRef((e,r)=>{let{__scopePopper:s,virtualRef:n,...i}=e,a=ny(nw,s),o=V.useRef(null),l=(0,en.useComposedRefs)(r,o),c=V.useRef(null);return V.useEffect(()=>{let e=c.current;c.current=n?.current||o.current,e!==c.current&&a.onAnchorChange(c.current)}),n?null:(0,U.jsx)(em.div,{...i,ref:l})});n_.displayName=nw;var nS="PopperContent",[nk,nj]=ng(nS),nC=V.forwardRef((e,r)=>{var s,n,i,a,o,l,c,d,u,h,f,p,m,g,x,v,y,b,w,_,S;let{__scopePopper:k,side:j="bottom",sideOffset:C=0,align:N="center",alignOffset:E=0,arrowPadding:D=0,avoidCollisions:T=!0,collisionBoundary:R=[],collisionPadding:A=0,sticky:M="partial",hideWhenDetached:I=!1,updatePositionStrategy:P="optimized",onPlaced:F,...L}=e,O=ny(nS,k),[B,z]=V.useState(null),$=(0,en.useComposedRefs)(r,e=>z(e)),[W,H]=V.useState(null),q=np(W),K=q?.width??0,X=q?.height??0,Y="number"==typeof A?A:{top:0,right:0,bottom:0,left:0,...A},G=Array.isArray(R)?R:[R],J=G.length>0,Z={padding:Y,boundary:G.filter(nT),altBoundary:J},{refs:Q,floatingStyles:ee,placement:et,isPositioned:er,middlewareData:es}=function(e){void 0===e&&(e={});let{placement:r="bottom",strategy:s="absolute",middleware:n=[],platform:i,elements:{reference:a,floating:o}={},transform:l=!0,whileElementsMounted:c,open:d}=e,[u,h]=V.useState({x:0,y:0,strategy:s,placement:r,middlewareData:{},isPositioned:!1}),[f,p]=V.useState(n);nc(f,n)||p(n);let[m,g]=V.useState(null),[x,v]=V.useState(null),y=V.useCallback(e=>{e!==S.current&&(S.current=e,g(e))},[]),b=V.useCallback(e=>{e!==k.current&&(k.current=e,v(e))},[]),w=a||m,_=o||x,S=V.useRef(null),k=V.useRef(null),j=V.useRef(u),C=null!=c,N=nh(c),E=nh(i),D=nh(d),T=V.useCallback(()=>{var e,n;let i,a,o;if(!S.current||!k.current)return;let l={placement:r,strategy:s,middleware:f};E.current&&(l.platform=E.current),(e=S.current,n=k.current,i=new Map,o={...(a={platform:ni,...l}).platform,_c:i},sj(e,n,{...a,platform:o})).then(e=>{let r={...e,isPositioned:!1!==D.current};R.current&&!nc(j.current,r)&&(j.current=r,ep.flushSync(()=>{h(r)}))})},[f,r,s,E,D]);nl(()=>{!1===d&&j.current.isPositioned&&(j.current.isPositioned=!1,h(e=>({...e,isPositioned:!1})))},[d]);let R=V.useRef(!1);nl(()=>(R.current=!0,()=>{R.current=!1}),[]),nl(()=>{if(w&&(S.current=w),_&&(k.current=_),w&&_){if(N.current)return N.current(w,_,T);T()}},[w,_,T,N,C]);let A=V.useMemo(()=>({reference:S,floating:k,setReference:y,setFloating:b}),[y,b]),M=V.useMemo(()=>({reference:w,floating:_}),[w,_]),I=V.useMemo(()=>{let e={position:s,left:0,top:0};if(!M.floating)return e;let r=nu(M.floating,u.x),n=nu(M.floating,u.y);return l?{...e,transform:"translate("+r+"px, "+n+"px)",...nd(M.floating)>=1.5&&{willChange:"transform"}}:{position:s,left:r,top:n}},[s,l,M.floating,u.x,u.y]);return V.useMemo(()=>({...u,update:T,refs:A,elements:M,floatingStyles:I}),[u,T,A,M,I])}({strategy:"fixed",placement:j+("center"!==N?"-"+N:""),whileElementsMounted:(...e)=>(function(e,r,s,n){let i;void 0===n&&(n={});let{ancestorScroll:a=!0,ancestorResize:o=!0,elementResize:l="function"==typeof ResizeObserver,layoutShift:c="function"==typeof IntersectionObserver,animationFrame:d=!1}=n,u=s2(e),h=a||o?[...u?sQ(u):[],...sQ(r)]:[];h.forEach(e=>{a&&e.addEventListener("scroll",s,{passive:!0}),o&&e.addEventListener("resize",s)});let f=u&&c?function(e,r){let s,n=null,i=sM(e);function a(){var e;clearTimeout(s),null==(e=n)||e.disconnect(),n=null}return!function o(l,c){void 0===l&&(l=!1),void 0===c&&(c=1),a();let d=e.getBoundingClientRect(),{left:u,top:h,width:f,height:p}=d;if(l||r(),!f||!p)return;let m={rootMargin:-sn(h)+"px "+-sn(i.clientWidth-(u+f))+"px "+-sn(i.clientHeight-(h+p))+"px "+-sn(u)+"px",threshold:sr(0,st(1,c))||1},g=!0;function x(r){let n=r[0].intersectionRatio;if(n!==c){if(!g)return o();n?o(!1,n):s=setTimeout(()=>{o(!1,1e-7)},1e3)}1!==n||na(d,e.getBoundingClientRect())||o(),g=!1}try{n=new IntersectionObserver(x,{...m,root:i.ownerDocument})}catch(e){n=new IntersectionObserver(x,m)}n.observe(e)}(!0),a}(u,s):null,p=-1,m=null;l&&(m=new ResizeObserver(e=>{let[n]=e;n&&n.target===u&&m&&(m.unobserve(r),cancelAnimationFrame(p),p=requestAnimationFrame(()=>{var e;null==(e=m)||e.observe(r)})),s()}),u&&!d&&m.observe(u),m.observe(r));let g=d?s6(e):null;return d&&function r(){let n=s6(e);g&&!na(g,n)&&s(),g=n,i=requestAnimationFrame(r)}(),s(),()=>{var e;h.forEach(e=>{a&&e.removeEventListener("scroll",s),o&&e.removeEventListener("resize",s)}),null==f||f(),null==(e=m)||e.disconnect(),m=null,d&&cancelAnimationFrame(i)}})(...e,{animationFrame:"always"===P}),elements:{reference:O.anchor},middleware:[{...{name:"offset",options:i=s={mainAxis:C+X,alignmentAxis:E},async fn(e){var r,s;let{x:n,y:a,placement:o,middlewareData:l}=e,c=await sD(e,i);return o===(null==(r=l.offset)?void 0:r.placement)&&null!=(s=l.arrow)&&s.alignmentOffset?{}:{x:n+c.x,y:a+c.y,data:{...c,placement:o}}}},options:[s,n]},T&&{...{name:"shift",options:u=c={mainAxis:!0,crossAxis:!1,limiter:"partial"===M?{...(void 0===(l=a)&&(l={}),{options:l,fn(e){let{x:r,y:s,placement:n,rects:i,middlewareData:a}=e,{offset:o=0,mainAxis:c=!0,crossAxis:d=!0}=sl(l,e),u={x:r,y:s},h=sp(n),f=su(h),p=u[f],m=u[h],g=sl(o,e),x="number"==typeof g?{mainAxis:g,crossAxis:0}:{mainAxis:0,crossAxis:0,...g};if(c){let e="y"===f?"height":"width",r=i.reference[f]-i.floating[e]+x.mainAxis,s=i.reference[f]+i.reference[e]-x.mainAxis;p<r?p=r:p>s&&(p=s)}if(d){var v,y;let e="y"===f?"width":"height",r=sE.has(sc(n)),s=i.reference[h]-i.floating[e]+(r&&(null==(v=a.offset)?void 0:v[h])||0)+(r?0:x.crossAxis),o=i.reference[h]+i.reference[e]+(r?0:(null==(y=a.offset)?void 0:y[h])||0)-(r?x.crossAxis:0);m<s?m=s:m>o&&(m=o)}return{[f]:p,[h]:m}}}),options:[a,o]}:void 0,...Z},async fn(e){let{x:r,y:s,placement:n,platform:i}=e,{mainAxis:a=!0,crossAxis:o=!1,limiter:l={fn:e=>{let{x:r,y:s}=e;return{x:r,y:s}}},...c}=sl(u,e),d={x:r,y:s},h=await i.detectOverflow(e,c),f=sp(sc(n)),p=su(f),m=d[p],g=d[f];if(a){let e="y"===p?"top":"left",r="y"===p?"bottom":"right",s=m+h[e],n=m-h[r];m=sr(s,st(m,n))}if(o){let e="y"===f?"top":"left",r="y"===f?"bottom":"right",s=g+h[e],n=g-h[r];g=sr(s,st(g,n))}let x=l.fn({...e,[p]:m,[f]:g});return{...x,data:{x:x.x-r,y:x.y-s,enabled:{[p]:a,[f]:o}}}}},options:[c,d]},T&&{...{name:"flip",options:p=h={...Z},async fn(e){var r,s,n,i,a,o,l,c;let d,u,h,{placement:f,middlewareData:m,rects:g,initialPlacement:x,platform:v,elements:y}=e,{mainAxis:b=!0,crossAxis:w=!0,fallbackPlacements:_,fallbackStrategy:S="bestFit",fallbackAxisSideDirection:k="none",flipAlignment:j=!0,...C}=sl(p,e);if(null!=(r=m.arrow)&&r.alignmentOffset)return{};let N=sc(f),E=sp(x),D=sc(x)===x,T=await (null==v.isRTL?void 0:v.isRTL(y.floating)),R=_||(D||!j?[sb(x)]:(d=sb(x),[sm(x),d,sm(d)])),A="none"!==k;!_&&A&&R.push(...(u=sd(x),h=function(e,r,s){switch(e){case"top":case"bottom":if(s)return r?sx:sg;return r?sg:sx;case"left":case"right":return r?sv:sy;default:return[]}}(sc(x),"start"===k,T),u&&(h=h.map(e=>e+"-"+u),j&&(h=h.concat(h.map(sm)))),h));let M=[x,...R],I=await v.detectOverflow(e,C),P=[],F=(null==(s=m.flip)?void 0:s.overflows)||[];if(b&&P.push(I[N]),w){let e,r,s,n,i=(o=f,l=g,void 0===(c=T)&&(c=!1),e=sd(o),s=sh(r=su(sp(o))),n="x"===r?e===(c?"end":"start")?"right":"left":"start"===e?"bottom":"top",l.reference[s]>l.floating[s]&&(n=sb(n)),[n,sb(n)]);P.push(I[i[0]],I[i[1]])}if(F=[...F,{placement:f,overflows:P}],!P.every(e=>e<=0)){let e=((null==(n=m.flip)?void 0:n.index)||0)+1,r=M[e];if(r&&("alignment"!==w||E===sp(r)||F.every(e=>sp(e.placement)!==E||e.overflows[0]>0)))return{data:{index:e,overflows:F},reset:{placement:r}};let s=null==(i=F.filter(e=>e.overflows[0]<=0).sort((e,r)=>e.overflows[1]-r.overflows[1])[0])?void 0:i.placement;if(!s)switch(S){case"bestFit":{let e=null==(a=F.filter(e=>{if(A){let r=sp(e.placement);return r===E||"y"===r}return!0}).map(e=>[e.placement,e.overflows.filter(e=>e>0).reduce((e,r)=>e+r,0)]).sort((e,r)=>e[1]-r[1])[0])?void 0:a[0];e&&(s=e);break}case"initialPlacement":s=x}if(f!==s)return{reset:{placement:s}}}return{}}},options:[h,f]},{...{name:"size",options:x=m={...Z,apply:({elements:e,rects:r,availableWidth:s,availableHeight:n})=>{let{width:i,height:a}=r.reference,o=e.floating.style;o.setProperty("--radix-popper-available-width",`${s}px`),o.setProperty("--radix-popper-available-height",`${n}px`),o.setProperty("--radix-popper-anchor-width",`${i}px`),o.setProperty("--radix-popper-anchor-height",`${a}px`)}},async fn(e){var r,s;let n,i,{placement:a,rects:o,platform:l,elements:c}=e,{apply:d=()=>{},...u}=sl(x,e),h=await l.detectOverflow(e,u),f=sc(a),p=sd(a),m="y"===sp(a),{width:g,height:v}=o.floating;"top"===f||"bottom"===f?(n=f,i=p===(await (null==l.isRTL?void 0:l.isRTL(c.floating))?"start":"end")?"left":"right"):(i=f,n="end"===p?"top":"bottom");let y=v-h.top-h.bottom,b=g-h.left-h.right,w=st(v-h[n],y),_=st(g-h[i],b),S=!e.middlewareData.shift,k=w,j=_;if(null!=(r=e.middlewareData.shift)&&r.enabled.x&&(j=b),null!=(s=e.middlewareData.shift)&&s.enabled.y&&(k=y),S&&!p){let e=sr(h.left,0),r=sr(h.right,0),s=sr(h.top,0),n=sr(h.bottom,0);m?j=g-2*(0!==e||0!==r?e+r:sr(h.left,h.right)):k=v-2*(0!==s||0!==n?s+n:sr(h.top,h.bottom))}await d({...e,availableWidth:j,availableHeight:k});let C=await l.getDimensions(c.floating);return g!==C.width||v!==C.height?{reset:{rects:!0}}:{}}},options:[m,g]},W&&{...{name:"arrow",options:b=v={element:W,padding:D},fn(e){let{element:r,padding:s}="function"==typeof b?b(e):b;return r&&({}).hasOwnProperty.call(r,"current")?null!=r.current?no({element:r.current,padding:s}).fn(e):{}:r?no({element:r,padding:s}).fn(e):{}}},options:[v,y]},nR({arrowWidth:K,arrowHeight:X}),I&&{...{name:"hide",options:S=w={strategy:"referenceHidden",...Z},async fn(e){let{rects:r,platform:s}=e,{strategy:n="referenceHidden",...i}=sl(S,e);switch(n){case"referenceHidden":{let n=sC(await s.detectOverflow(e,{...i,elementContext:"reference"}),r.reference);return{data:{referenceHiddenOffsets:n,referenceHidden:sN(n)}}}case"escaped":{let n=sC(await s.detectOverflow(e,{...i,altBoundary:!0}),r.floating);return{data:{escapedOffsets:n,escaped:sN(n)}}}default:return{}}}},options:[w,_]}]}),[ei,ea]=nA(et),eo=ex(F);ed(()=>{er&&eo?.()},[er,eo]);let el=es.arrow?.x,ec=es.arrow?.y,eu=es.arrow?.centerOffset!==0,[eh,ef]=V.useState();return ed(()=>{B&&ef(window.getComputedStyle(B).zIndex)},[B]),(0,U.jsx)("div",{ref:Q.setFloating,"data-radix-popper-content-wrapper":"",style:{...ee,transform:er?ee.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:eh,"--radix-popper-transform-origin":[es.transformOrigin?.x,es.transformOrigin?.y].join(" "),...es.hide?.referenceHidden&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:(0,U.jsx)(nk,{scope:k,placedSide:ei,onArrowChange:H,arrowX:el,arrowY:ec,shouldHideArrow:eu,children:(0,U.jsx)(em.div,{"data-side":ei,"data-align":ea,...L,ref:$,style:{...L.style,animation:er?void 0:"none"}})})})});nC.displayName=nS;var nN="PopperArrow",nE={top:"bottom",right:"left",bottom:"top",left:"right"},nD=V.forwardRef(function(e,r){let{__scopePopper:s,...n}=e,i=nj(nN,s),a=nE[i.placedSide];return(0,U.jsx)("span",{ref:i.onArrowChange,style:{position:"absolute",left:i.arrowX,top:i.arrowY,[a]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[i.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[i.placedSide],visibility:i.shouldHideArrow?"hidden":void 0},children:(0,U.jsx)(nf,{...n,ref:r,style:{...n.style,display:"block"}})})});function nT(e){return null!==e}nD.displayName=nN;var nR=e=>({name:"transformOrigin",options:e,fn(r){let{placement:s,rects:n,middlewareData:i}=r,a=i.arrow?.centerOffset!==0,o=a?0:e.arrowWidth,l=a?0:e.arrowHeight,[c,d]=nA(s),u={start:"0%",center:"50%",end:"100%"}[d],h=(i.arrow?.x??0)+o/2,f=(i.arrow?.y??0)+l/2,p="",m="";return"bottom"===c?(p=a?u:`${h}px`,m=`${-l}px`):"top"===c?(p=a?u:`${h}px`,m=`${n.floating.height+l}px`):"right"===c?(p=`${-l}px`,m=a?u:`${f}px`):"left"===c&&(p=`${n.floating.width+l}px`,m=a?u:`${f}px`),{data:{x:p,y:m}}}});function nA(e){let[r,s="center"]=e.split("-");return[r,s]}var nM=["Enter"," "],nI=["ArrowUp","PageDown","End"],nP=["ArrowDown","PageUp","Home",...nI],nF={ltr:[...nM,"ArrowRight"],rtl:[...nM,"ArrowLeft"]},nL={ltr:["ArrowLeft"],rtl:["ArrowRight"]},nO="Menu",[nB,nz,n$]=ea(nO),[nW,nH]=es(nO,[n$,nx,eD]),nU=nx(),nV=eD(),[nq,nK]=nW(nO),[nX,nY]=nW(nO),nG=e=>{let{__scopeMenu:r,open:s=!1,children:n,dir:i,onOpenChange:a,modal:o=!0}=e,l=nU(r),[c,d]=V.useState(null),u=V.useRef(!1),h=ex(a),f=ew(i);return V.useEffect(()=>{let e=()=>{u.current=!0,document.addEventListener("pointerdown",r,{capture:!0,once:!0}),document.addEventListener("pointermove",r,{capture:!0,once:!0})},r=()=>u.current=!1;return document.addEventListener("keydown",e,{capture:!0}),()=>{document.removeEventListener("keydown",e,{capture:!0}),document.removeEventListener("pointerdown",r,{capture:!0}),document.removeEventListener("pointermove",r,{capture:!0})}},[]),(0,U.jsx)(nb,{...l,children:(0,U.jsx)(nq,{scope:r,open:s,onOpenChange:h,content:c,onContentChange:d,children:(0,U.jsx)(nX,{scope:r,onClose:V.useCallback(()=>h(!1),[h]),isUsingKeyboardRef:u,dir:f,modal:o,children:n})})})};nG.displayName=nO;var nJ=V.forwardRef((e,r)=>{let{__scopeMenu:s,...n}=e,i=nU(s);return(0,U.jsx)(n_,{...i,...n,ref:r})});nJ.displayName="MenuAnchor";var nZ="MenuPortal",[nQ,n0]=nW(nZ,{forceMount:void 0}),n1=e=>{let{__scopeMenu:r,forceMount:s,children:n,container:i}=e,a=nK(nZ,r);return(0,U.jsx)(nQ,{scope:r,forceMount:s,children:(0,U.jsx)(eO,{present:s||a.open,children:(0,U.jsx)(tc,{asChild:!0,container:i,children:n})})})};n1.displayName=nZ;var n2="MenuContent",[n5,n3]=nW(n2),n4=V.forwardRef((e,r)=>{let s=n0(n2,e.__scopeMenu),{forceMount:n=s.forceMount,...i}=e,a=nK(n2,e.__scopeMenu),o=nY(n2,e.__scopeMenu);return(0,U.jsx)(nB.Provider,{scope:e.__scopeMenu,children:(0,U.jsx)(eO,{present:n||a.open,children:(0,U.jsx)(nB.Slot,{scope:e.__scopeMenu,children:o.modal?(0,U.jsx)(n6,{...i,ref:r}):(0,U.jsx)(n7,{...i,ref:r})})})})}),n6=V.forwardRef((e,r)=>{let s=nK(n2,e.__scopeMenu),n=V.useRef(null),i=(0,en.useComposedRefs)(r,n);return V.useEffect(()=>{let e=n.current;if(e)return t3(e)},[]),(0,U.jsx)(n9,{...e,ref:i,trapFocus:s.open,disableOutsidePointerEvents:s.open,disableOutsideScroll:!0,onFocusOutside:er(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>s.onOpenChange(!1)})}),n7=V.forwardRef((e,r)=>{let s=nK(n2,e.__scopeMenu);return(0,U.jsx)(n9,{...e,ref:r,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>s.onOpenChange(!1)})}),n8=(0,ei.createSlot)("MenuContent.ScrollLock"),n9=V.forwardRef((e,r)=>{let{__scopeMenu:s,loop:n=!1,trapFocus:i,onOpenAutoFocus:a,onCloseAutoFocus:o,disableOutsidePointerEvents:l,onEntryFocus:c,onEscapeKeyDown:d,onPointerDownOutside:u,onFocusOutside:h,onInteractOutside:f,onDismiss:p,disableOutsideScroll:m,...g}=e,x=nK(n2,s),v=nY(n2,s),y=nU(s),b=nV(s),w=nz(s),[_,S]=V.useState(null),k=V.useRef(null),j=(0,en.useComposedRefs)(r,k,x.onContentChange),C=V.useRef(0),N=V.useRef(""),E=V.useRef(0),D=V.useRef(null),T=V.useRef("right"),R=V.useRef(0),A=m?tJ:V.Fragment;V.useEffect(()=>()=>window.clearTimeout(C.current),[]),tu();let M=V.useCallback(e=>{var r,s;return T.current===D.current?.side&&(r=e,!!(s=D.current?.area)&&function(e,r){let{x:s,y:n}=e,i=!1;for(let e=0,a=r.length-1;e<r.length;a=e++){let o=r[e],l=r[a],c=o.x,d=o.y,u=l.x,h=l.y;d>n!=h>n&&s<(u-c)*(n-d)/(h-d)+c&&(i=!i)}return i}({x:r.clientX,y:r.clientY},s))},[]);return(0,U.jsx)(n5,{scope:s,searchRef:N,onItemEnter:V.useCallback(e=>{M(e)&&e.preventDefault()},[M]),onItemLeave:V.useCallback(e=>{M(e)||(k.current?.focus(),S(null))},[M]),onTriggerLeave:V.useCallback(e=>{M(e)&&e.preventDefault()},[M]),pointerGraceTimerRef:E,onPointerGraceIntentChange:V.useCallback(e=>{D.current=e},[]),children:(0,U.jsx)(A,{...m?{as:n8,allowPinchZoom:!0}:void 0,children:(0,U.jsx)(ts,{asChild:!0,trapped:i,onMountAutoFocus:er(a,e=>{e.preventDefault(),k.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:o,children:(0,U.jsx)(e7,{asChild:!0,disableOutsidePointerEvents:l,onEscapeKeyDown:d,onPointerDownOutside:u,onFocusOutside:h,onInteractOutside:f,onDismiss:p,children:(0,U.jsx)(eA,{asChild:!0,...b,dir:v.dir,orientation:"vertical",loop:n,currentTabStopId:_,onCurrentTabStopIdChange:S,onEntryFocus:er(c,e=>{v.isUsingKeyboardRef.current||e.preventDefault()}),preventScrollOnEntryFocus:!0,children:(0,U.jsx)(nC,{role:"menu","aria-orientation":"vertical","data-state":iD(x.open),"data-radix-menu-content":"",dir:v.dir,...y,...g,ref:j,style:{outline:"none",...g.style},onKeyDown:er(g.onKeyDown,e=>{let r=e.target.closest("[data-radix-menu-content]")===e.currentTarget,s=e.ctrlKey||e.altKey||e.metaKey,n=1===e.key.length;if(r){var i;let r,a,o,l,c,d;"Tab"===e.key&&e.preventDefault(),!s&&n&&(i=e.key,r=N.current+i,a=w().filter(e=>!e.disabled),o=document.activeElement,l=a.find(e=>e.ref.current===o)?.textValue,c=function(e,r,s){var n;let i=r.length>1&&Array.from(r).every(e=>e===r[0])?r[0]:r,a=s?e.indexOf(s):-1,o=(n=Math.max(a,0),e.map((r,s)=>e[(n+s)%e.length]));1===i.length&&(o=o.filter(e=>e!==s));let l=o.find(e=>e.toLowerCase().startsWith(i.toLowerCase()));return l!==s?l:void 0}(a.map(e=>e.textValue),r,l),d=a.find(e=>e.textValue===c)?.ref.current,function e(r){N.current=r,window.clearTimeout(C.current),""!==r&&(C.current=window.setTimeout(()=>e(""),1e3))}(r),d&&setTimeout(()=>d.focus()))}let a=k.current;if(e.target!==a||!nP.includes(e.key))return;e.preventDefault();let o=w().filter(e=>!e.disabled).map(e=>e.ref.current);nI.includes(e.key)&&o.reverse(),function(e){let r=document.activeElement;for(let s of e)if(s===r||(s.focus(),document.activeElement!==r))return}(o)}),onBlur:er(e.onBlur,e=>{e.currentTarget.contains(e.target)||(window.clearTimeout(C.current),N.current="")}),onPointerMove:er(e.onPointerMove,iA(e=>{let r=e.target,s=R.current!==e.clientX;e.currentTarget.contains(r)&&s&&(T.current=e.clientX>R.current?"right":"left",R.current=e.clientX)}))})})})})})})});n4.displayName=n2;var ie=V.forwardRef((e,r)=>{let{__scopeMenu:s,...n}=e;return(0,U.jsx)(em.div,{role:"group",...n,ref:r})});ie.displayName="MenuGroup";var it=V.forwardRef((e,r)=>{let{__scopeMenu:s,...n}=e;return(0,U.jsx)(em.div,{...n,ref:r})});it.displayName="MenuLabel";var ir="MenuItem",is="menu.itemSelect",ii=V.forwardRef((e,r)=>{let{disabled:s=!1,onSelect:n,...i}=e,a=V.useRef(null),o=nY(ir,e.__scopeMenu),l=n3(ir,e.__scopeMenu),c=(0,en.useComposedRefs)(r,a),d=V.useRef(!1);return(0,U.jsx)(ia,{...i,ref:c,disabled:s,onClick:er(e.onClick,()=>{let e=a.current;if(!s&&e){let r=new CustomEvent(is,{bubbles:!0,cancelable:!0});e.addEventListener(is,e=>n?.(e),{once:!0}),eg(e,r),r.defaultPrevented?d.current=!1:o.onClose()}}),onPointerDown:r=>{e.onPointerDown?.(r),d.current=!0},onPointerUp:er(e.onPointerUp,e=>{d.current||e.currentTarget?.click()}),onKeyDown:er(e.onKeyDown,e=>{let r=""!==l.searchRef.current;s||r&&" "===e.key||nM.includes(e.key)&&(e.currentTarget.click(),e.preventDefault())})})});ii.displayName=ir;var ia=V.forwardRef((e,r)=>{let{__scopeMenu:s,disabled:n=!1,textValue:i,...a}=e,o=n3(ir,s),l=nV(s),c=V.useRef(null),d=(0,en.useComposedRefs)(r,c),[u,h]=V.useState(!1),[f,p]=V.useState("");return V.useEffect(()=>{let e=c.current;e&&p((e.textContent??"").trim())},[a.children]),(0,U.jsx)(nB.ItemSlot,{scope:s,disabled:n,textValue:i??f,children:(0,U.jsx)(eP,{asChild:!0,...l,focusable:!n,children:(0,U.jsx)(em.div,{role:"menuitem","data-highlighted":u?"":void 0,"aria-disabled":n||void 0,"data-disabled":n?"":void 0,...a,ref:d,onPointerMove:er(e.onPointerMove,iA(e=>{n?o.onItemLeave(e):(o.onItemEnter(e),e.defaultPrevented||e.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:er(e.onPointerLeave,iA(e=>o.onItemLeave(e))),onFocus:er(e.onFocus,()=>h(!0)),onBlur:er(e.onBlur,()=>h(!1))})})})}),io=V.forwardRef((e,r)=>{let{checked:s=!1,onCheckedChange:n,...i}=e;return(0,U.jsx)(ig,{scope:e.__scopeMenu,checked:s,children:(0,U.jsx)(ii,{role:"menuitemcheckbox","aria-checked":iT(s)?"mixed":s,...i,ref:r,"data-state":iR(s),onSelect:er(i.onSelect,()=>n?.(!!iT(s)||!s),{checkForDefaultPrevented:!1})})})});io.displayName="MenuCheckboxItem";var il="MenuRadioGroup",[ic,id]=nW(il,{value:void 0,onValueChange:()=>{}}),iu=V.forwardRef((e,r)=>{let{value:s,onValueChange:n,...i}=e,a=ex(n);return(0,U.jsx)(ic,{scope:e.__scopeMenu,value:s,onValueChange:a,children:(0,U.jsx)(ie,{...i,ref:r})})});iu.displayName=il;var ih="MenuRadioItem",ip=V.forwardRef((e,r)=>{let{value:s,...n}=e,i=id(ih,e.__scopeMenu),a=s===i.value;return(0,U.jsx)(ig,{scope:e.__scopeMenu,checked:a,children:(0,U.jsx)(ii,{role:"menuitemradio","aria-checked":a,...n,ref:r,"data-state":iR(a),onSelect:er(n.onSelect,()=>i.onValueChange?.(s),{checkForDefaultPrevented:!1})})})});ip.displayName=ih;var im="MenuItemIndicator",[ig,ix]=nW(im,{checked:!1}),iv=V.forwardRef((e,r)=>{let{__scopeMenu:s,forceMount:n,...i}=e,a=ix(im,s);return(0,U.jsx)(eO,{present:n||iT(a.checked)||!0===a.checked,children:(0,U.jsx)(em.span,{...i,ref:r,"data-state":iR(a.checked)})})});iv.displayName=im;var iy=V.forwardRef((e,r)=>{let{__scopeMenu:s,...n}=e;return(0,U.jsx)(em.div,{role:"separator","aria-orientation":"horizontal",...n,ref:r})});iy.displayName="MenuSeparator";var ib=V.forwardRef((e,r)=>{let{__scopeMenu:s,...n}=e,i=nU(s);return(0,U.jsx)(nD,{...i,...n,ref:r})});ib.displayName="MenuArrow";var iw="MenuSub",[i_,iS]=nW(iw),ik=e=>{let{__scopeMenu:r,children:s,open:n=!1,onOpenChange:i}=e,a=nK(iw,r),o=nU(r),[l,c]=V.useState(null),[d,u]=V.useState(null),h=ex(i);return V.useEffect(()=>(!1===a.open&&h(!1),()=>h(!1)),[a.open,h]),(0,U.jsx)(nb,{...o,children:(0,U.jsx)(nq,{scope:r,open:n,onOpenChange:h,content:d,onContentChange:u,children:(0,U.jsx)(i_,{scope:r,contentId:ef(),triggerId:ef(),trigger:l,onTriggerChange:c,children:s})})})};ik.displayName=iw;var ij="MenuSubTrigger",iC=V.forwardRef((e,r)=>{let s=nK(ij,e.__scopeMenu),n=nY(ij,e.__scopeMenu),i=iS(ij,e.__scopeMenu),a=n3(ij,e.__scopeMenu),o=V.useRef(null),{pointerGraceTimerRef:l,onPointerGraceIntentChange:c}=a,d={__scopeMenu:e.__scopeMenu},u=V.useCallback(()=>{o.current&&window.clearTimeout(o.current),o.current=null},[]);return V.useEffect(()=>u,[u]),V.useEffect(()=>{let e=l.current;return()=>{window.clearTimeout(e),c(null)}},[l,c]),(0,U.jsx)(nJ,{asChild:!0,...d,children:(0,U.jsx)(ia,{id:i.triggerId,"aria-haspopup":"menu","aria-expanded":s.open,"aria-controls":i.contentId,"data-state":iD(s.open),...e,ref:(0,en.composeRefs)(r,i.onTriggerChange),onClick:r=>{e.onClick?.(r),e.disabled||r.defaultPrevented||(r.currentTarget.focus(),s.open||s.onOpenChange(!0))},onPointerMove:er(e.onPointerMove,iA(r=>{a.onItemEnter(r),!r.defaultPrevented&&(e.disabled||s.open||o.current||(a.onPointerGraceIntentChange(null),o.current=window.setTimeout(()=>{s.onOpenChange(!0),u()},100)))})),onPointerLeave:er(e.onPointerLeave,iA(e=>{u();let r=s.content?.getBoundingClientRect();if(r){let n=s.content?.dataset.side,i="right"===n,o=r[i?"left":"right"],c=r[i?"right":"left"];a.onPointerGraceIntentChange({area:[{x:e.clientX+(i?-5:5),y:e.clientY},{x:o,y:r.top},{x:c,y:r.top},{x:c,y:r.bottom},{x:o,y:r.bottom}],side:n}),window.clearTimeout(l.current),l.current=window.setTimeout(()=>a.onPointerGraceIntentChange(null),300)}else{if(a.onTriggerLeave(e),e.defaultPrevented)return;a.onPointerGraceIntentChange(null)}})),onKeyDown:er(e.onKeyDown,r=>{let i=""!==a.searchRef.current;e.disabled||i&&" "===r.key||nF[n.dir].includes(r.key)&&(s.onOpenChange(!0),s.content?.focus(),r.preventDefault())})})})});iC.displayName=ij;var iN="MenuSubContent",iE=V.forwardRef((e,r)=>{let s=n0(n2,e.__scopeMenu),{forceMount:n=s.forceMount,...i}=e,a=nK(n2,e.__scopeMenu),o=nY(n2,e.__scopeMenu),l=iS(iN,e.__scopeMenu),c=V.useRef(null),d=(0,en.useComposedRefs)(r,c);return(0,U.jsx)(nB.Provider,{scope:e.__scopeMenu,children:(0,U.jsx)(eO,{present:n||a.open,children:(0,U.jsx)(nB.Slot,{scope:e.__scopeMenu,children:(0,U.jsx)(n9,{id:l.contentId,"aria-labelledby":l.triggerId,...i,ref:d,align:"start",side:"rtl"===o.dir?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:e=>{o.isUsingKeyboardRef.current&&c.current?.focus(),e.preventDefault()},onCloseAutoFocus:e=>e.preventDefault(),onFocusOutside:er(e.onFocusOutside,e=>{e.target!==l.trigger&&a.onOpenChange(!1)}),onEscapeKeyDown:er(e.onEscapeKeyDown,e=>{o.onClose(),e.preventDefault()}),onKeyDown:er(e.onKeyDown,e=>{let r=e.currentTarget.contains(e.target),s=nL[o.dir].includes(e.key);r&&s&&(a.onOpenChange(!1),l.trigger?.focus(),e.preventDefault())})})})})})});function iD(e){return e?"open":"closed"}function iT(e){return"indeterminate"===e}function iR(e){return iT(e)?"indeterminate":e?"checked":"unchecked"}function iA(e){return r=>"mouse"===r.pointerType?e(r):void 0}iE.displayName=iN;var iM="DropdownMenu",[iI,iP]=es(iM,[nH]),iF=nH(),[iL,iO]=iI(iM),iB=e=>{let{__scopeDropdownMenu:r,children:s,dir:n,open:i,defaultOpen:a,onOpenChange:o,modal:l=!0}=e,c=iF(r),d=V.useRef(null),[u,h]=ey({prop:i,defaultProp:a??!1,onChange:o,caller:iM});return(0,U.jsx)(iL,{scope:r,triggerId:ef(),triggerRef:d,contentId:ef(),open:u,onOpenChange:h,onOpenToggle:V.useCallback(()=>h(e=>!e),[h]),modal:l,children:(0,U.jsx)(nG,{...c,open:u,onOpenChange:h,dir:n,modal:l,children:s})})};iB.displayName=iM;var iz="DropdownMenuTrigger",i$=V.forwardRef((e,r)=>{let{__scopeDropdownMenu:s,disabled:n=!1,...i}=e,a=iO(iz,s),o=iF(s);return(0,U.jsx)(nJ,{asChild:!0,...o,children:(0,U.jsx)(em.button,{type:"button",id:a.triggerId,"aria-haspopup":"menu","aria-expanded":a.open,"aria-controls":a.open?a.contentId:void 0,"data-state":a.open?"open":"closed","data-disabled":n?"":void 0,disabled:n,...i,ref:(0,en.composeRefs)(r,a.triggerRef),onPointerDown:er(e.onPointerDown,e=>{!n&&0===e.button&&!1===e.ctrlKey&&(a.onOpenToggle(),a.open||e.preventDefault())}),onKeyDown:er(e.onKeyDown,e=>{!n&&(["Enter"," "].includes(e.key)&&a.onOpenToggle(),"ArrowDown"===e.key&&a.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(e.key)&&e.preventDefault())})})})});i$.displayName=iz;var iW=e=>{let{__scopeDropdownMenu:r,...s}=e,n=iF(r);return(0,U.jsx)(n1,{...n,...s})};iW.displayName="DropdownMenuPortal";var iH="DropdownMenuContent",iU=V.forwardRef((e,r)=>{let{__scopeDropdownMenu:s,...n}=e,i=iO(iH,s),a=iF(s),o=V.useRef(!1);return(0,U.jsx)(n4,{id:i.contentId,"aria-labelledby":i.triggerId,...a,...n,ref:r,onCloseAutoFocus:er(e.onCloseAutoFocus,e=>{o.current||i.triggerRef.current?.focus(),o.current=!1,e.preventDefault()}),onInteractOutside:er(e.onInteractOutside,e=>{let r=e.detail.originalEvent,s=0===r.button&&!0===r.ctrlKey,n=2===r.button||s;(!i.modal||n)&&(o.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});iU.displayName=iH,V.forwardRef((e,r)=>{let{__scopeDropdownMenu:s,...n}=e,i=iF(s);return(0,U.jsx)(ie,{...i,...n,ref:r})}).displayName="DropdownMenuGroup";var iV=V.forwardRef((e,r)=>{let{__scopeDropdownMenu:s,...n}=e,i=iF(s);return(0,U.jsx)(it,{...i,...n,ref:r})});iV.displayName="DropdownMenuLabel";var iq=V.forwardRef((e,r)=>{let{__scopeDropdownMenu:s,...n}=e,i=iF(s);return(0,U.jsx)(ii,{...i,...n,ref:r})});iq.displayName="DropdownMenuItem";var iK=V.forwardRef((e,r)=>{let{__scopeDropdownMenu:s,...n}=e,i=iF(s);return(0,U.jsx)(io,{...i,...n,ref:r})});iK.displayName="DropdownMenuCheckboxItem";var iX=V.forwardRef((e,r)=>{let{__scopeDropdownMenu:s,...n}=e,i=iF(s);return(0,U.jsx)(iu,{...i,...n,ref:r})});iX.displayName="DropdownMenuRadioGroup";var iY=V.forwardRef((e,r)=>{let{__scopeDropdownMenu:s,...n}=e,i=iF(s);return(0,U.jsx)(ip,{...i,...n,ref:r})});iY.displayName="DropdownMenuRadioItem";var iG=V.forwardRef((e,r)=>{let{__scopeDropdownMenu:s,...n}=e,i=iF(s);return(0,U.jsx)(iv,{...i,...n,ref:r})});iG.displayName="DropdownMenuItemIndicator";var iJ=V.forwardRef((e,r)=>{let{__scopeDropdownMenu:s,...n}=e,i=iF(s);return(0,U.jsx)(iy,{...i,...n,ref:r})});iJ.displayName="DropdownMenuSeparator",V.forwardRef((e,r)=>{let{__scopeDropdownMenu:s,...n}=e,i=iF(s);return(0,U.jsx)(ib,{...i,...n,ref:r})}).displayName="DropdownMenuArrow";var iZ=V.forwardRef((e,r)=>{let{__scopeDropdownMenu:s,...n}=e,i=iF(s);return(0,U.jsx)(iC,{...i,...n,ref:r})});iZ.displayName="DropdownMenuSubTrigger";var iQ=V.forwardRef((e,r)=>{let{__scopeDropdownMenu:s,...n}=e,i=iF(s);return(0,U.jsx)(iE,{...i,...n,ref:r,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});iQ.displayName="DropdownMenuSubContent";var i0=e=>{let{__scopeDropdownMenu:r,children:s,open:n,onOpenChange:i,defaultOpen:a}=e,o=iF(r),[l,c]=ey({prop:n,defaultProp:a??!1,onChange:i,caller:"DropdownMenuSub"});return(0,U.jsx)(ik,{...o,open:l,onOpenChange:c,children:s})},i1=e.i(322387),i1=i1;let i2=(0,rE.default)("chevron-right",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]),i5=(0,rE.default)("circle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);function i3({...e}){return(0,U.jsx)(iB,{"data-slot":"dropdown-menu",...e})}function i4({...e}){return(0,U.jsx)(i$,{"data-slot":"dropdown-menu-trigger",...e})}function i6({className:e,sideOffset:r=4,...s}){return(0,U.jsx)(iW,{children:(0,U.jsx)(iU,{"data-slot":"dropdown-menu-content",sideOffset:r,className:(0,e1.cn)("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 max-h-(--radix-dropdown-menu-content-available-height) min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border p-1 shadow-md",e),...s})})}function i7({className:e,inset:r,variant:s="default",...n}){return(0,U.jsx)(iq,{"data-slot":"dropdown-menu-item","data-inset":r,"data-variant":s,className:(0,e1.cn)("focus:bg-accent focus:text-accent-foreground data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 dark:data-[variant=destructive]:focus:bg-destructive/20 data-[variant=destructive]:focus:text-destructive data-[variant=destructive]:*:[svg]:!text-destructive [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 data-[inset]:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e),...n})}function i8({className:e,children:r,checked:s,...n}){return(0,U.jsxs)(iK,{"data-slot":"dropdown-menu-checkbox-item",className:(0,e1.cn)("focus:bg-accent focus:text-accent-foreground relative flex cursor-default items-center gap-2 rounded-sm py-1.5 pr-2 pl-8 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e),checked:s,...n,children:[(0,U.jsx)("span",{className:"pointer-events-none absolute left-2 flex size-3.5 items-center justify-center",children:(0,U.jsx)(iG,{children:(0,U.jsx)(i1.default,{className:"size-4"})})}),r]})}function i9({...e}){return(0,U.jsx)(iX,{"data-slot":"dropdown-menu-radio-group",...e})}function ae({className:e,children:r,...s}){return(0,U.jsxs)(iY,{"data-slot":"dropdown-menu-radio-item",className:(0,e1.cn)("focus:bg-accent focus:text-accent-foreground relative flex cursor-default items-center gap-2 rounded-sm py-1.5 pr-2 pl-8 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e),...s,children:[(0,U.jsx)("span",{className:"pointer-events-none absolute left-2 flex size-3.5 items-center justify-center",children:(0,U.jsx)(iG,{children:(0,U.jsx)(i5,{className:"size-2 fill-current"})})}),r]})}function at({className:e,inset:r,...s}){return(0,U.jsx)(iV,{"data-slot":"dropdown-menu-label","data-inset":r,className:(0,e1.cn)("px-2 py-1.5 text-sm font-medium data-[inset]:pl-8",e),...s})}function ar({className:e,...r}){return(0,U.jsx)(iJ,{"data-slot":"dropdown-menu-separator",className:(0,e1.cn)("bg-border -mx-1 my-1 h-px",e),...r})}function as({...e}){return(0,U.jsx)(i0,{"data-slot":"dropdown-menu-sub",...e})}function an({className:e,inset:r,children:s,...n}){return(0,U.jsxs)(iZ,{"data-slot":"dropdown-menu-sub-trigger","data-inset":r,className:(0,e1.cn)("focus:bg-accent focus:text-accent-foreground data-[state=open]:bg-accent data-[state=open]:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[inset]:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e),...n,children:[s,(0,U.jsx)(i2,{className:"ml-auto size-4"})]})}function ai({className:e,...r}){return(0,U.jsx)(iQ,{"data-slot":"dropdown-menu-sub-content",className:(0,e1.cn)("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-hidden rounded-md border p-1 shadow-lg",e),...r})}let aa=(0,rE.default)("chevron-down",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]),ao=(0,rE.default)("git-branch",[["line",{x1:"6",x2:"6",y1:"3",y2:"15",key:"17qcm7"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M18 9a9 9 0 0 1-9 9",key:"n2h4wq"}]]);var al=e.i(454267);function ac({status:e,pending:r,className:s}){let n="grid size-3.5 shrink-0 place-items-center rounded-full border-[1.5px] text-white";if(r)return(0,U.jsx)("span",{"aria-hidden":!0,className:(0,e1.cn)(n,"border-dashed border-border",s)});switch(e){case"in_progress":return(0,U.jsx)("span",{"aria-hidden":!0,className:(0,e1.cn)(n,"border-[oklch(0.58_0.16_245)] p-[2px]",s),style:{background:"conic-gradient(oklch(0.58 0.16 245) 0 50%, transparent 0) content-box"}});case"done":return(0,U.jsx)("span",{"aria-hidden":!0,className:(0,e1.cn)(n,"border-[oklch(0.6_0.14_152)] bg-[oklch(0.6_0.14_152)]",s),children:(0,U.jsx)(al.Check,{className:"size-[9px]",strokeWidth:3.5})});case"cancelled":return(0,U.jsx)("span",{"aria-hidden":!0,className:(0,e1.cn)(n,"border-muted-foreground/70 bg-muted-foreground/70",s),children:(0,U.jsx)(rD,{className:"size-2",strokeWidth:3.5})});default:return(0,U.jsx)("span",{"aria-hidden":!0,className:(0,e1.cn)(n,"border-muted-foreground/60",s)})}}let ad={low:{lit:1,color:"bg-muted-foreground"},medium:{lit:2,color:"bg-[oklch(0.76_0.15_85)]"},high:{lit:3,color:"bg-[oklch(0.7_0.17_50)]"}};function au({priority:e,className:r}){if("urgent"===e)return(0,U.jsx)("span",{"aria-hidden":!0,className:(0,e1.cn)("inline-grid size-[13px] shrink-0 place-items-center rounded-[3.5px] bg-[oklch(0.6_0.2_25)] font-mono text-[9.5px] font-bold leading-none text-white",r),children:"!"});let{lit:s,color:n}=ad[e];return(0,U.jsx)("span",{"aria-hidden":!0,className:(0,e1.cn)("inline-flex h-[11px] shrink-0 items-end gap-[1.5px]",r),children:[4,7,11].map((e,r)=>(0,U.jsx)("i",{className:(0,e1.cn)("w-[3px] rounded-[1px]",r<s?n:"bg-border"),style:{height:e}},e))})}function ah({done:e,total:r,className:s}){let n=r>0?e/r*100:0,i="radial-gradient(circle, transparent 2.6px, #000 3px)";return(0,U.jsxs)("span",{className:(0,e1.cn)("inline-flex shrink-0 items-center gap-1 font-mono text-[10.5px] font-normal tabular-nums text-muted-foreground",s),title:"Sub-tasks done",children:[(0,U.jsx)("span",{"aria-hidden":!0,className:"size-[11px] shrink-0 rounded-full",style:{background:`conic-gradient(oklch(0.6 0.14 152) ${n}%, var(--border) 0)`,WebkitMask:i,mask:i}}),e,"/",r]})}function af({status:e,onChange:r,children:s}){return(0,U.jsxs)(i3,{children:[(0,U.jsx)(i4,{asChild:!0,children:s}),(0,U.jsx)(i6,{align:"start",className:"w-44",children:r5.map(s=>(0,U.jsxs)(i7,{onClick:()=>r(s),className:"gap-2.5 text-[12.5px]",children:[(0,U.jsx)(ac,{status:s}),r1[s].label,s===e&&(0,U.jsx)(al.Check,{className:"ml-auto size-3 text-primary",strokeWidth:2.5})]},s))})]})}function ap({priority:e,onChange:r,children:s}){return(0,U.jsxs)(i3,{children:[(0,U.jsx)(i4,{asChild:!0,children:s}),(0,U.jsx)(i6,{align:"start",className:"w-44",children:[...r3].reverse().map(s=>(0,U.jsxs)(i7,{onClick:()=>r(s),className:"gap-2.5 text-[12.5px]",children:[(0,U.jsx)(au,{priority:s}),r2[s].label,s===e&&(0,U.jsx)(al.Check,{className:"ml-auto size-3 text-primary",strokeWidth:2.5})]},s))})]})}let am="field-sizing-content w-full resize-none rounded-md bg-transparent px-1.5 py-1 -mx-1.5 outline-none placeholder:text-muted-foreground/60",ag="text-[length:var(--task-body-font-size,14px)] leading-relaxed",ax=`min-h-32 ${ag}`,av="[&>*:first-child]:mt-0 [&>*:last-child]:mb-0 [&_ol]:list-inside [&_ol]:list-decimal [&_ul]:list-inside",ay=(0,U.jsx)(aa,{className:"size-3 shrink-0 text-muted-foreground/70 opacity-0 transition-opacity group-hover/fv:opacity-100 group-data-[state=open]/fv:opacity-100","aria-hidden":!0}),ab=(0,V.forwardRef)(function({muted:e,className:r,children:s,...n},i){return(0,U.jsxs)("button",{ref:i,type:"button",className:(0,e1.cn)("group/fv -ml-2 inline-flex h-[30px] min-w-0 max-w-full items-center gap-2 rounded-md px-2 text-left outline-none hover:bg-muted focus-visible:bg-muted data-[state=open]:bg-muted disabled:pointer-events-none",e?"text-muted-foreground/80":"text-foreground",r),...n,children:[s,ay]})});function aw({branch:e,className:r}){return(0,U.jsxs)("span",{className:(0,e1.cn)("inline-flex h-[22px] min-w-0 max-w-full items-center gap-1.5 rounded-md border border-border/60 bg-muted px-[7px] font-mono text-[11px] text-secondary-foreground",r),children:[(0,U.jsx)(ao,{className:"size-[11px] shrink-0 text-muted-foreground/70","aria-hidden":!0}),(0,U.jsx)("span",{className:"truncate",children:r4(e)})]})}function a_({current:e,onAssign:r,worktrees:s,assignedBranches:n,children:i}){let a=s.map(e=>({key:null===e.branch?"":e.branch,label:e.branch??"main"})).filter(({key:r})=>e!==r&&!n.has(r));return(0,U.jsxs)(i3,{children:[(0,U.jsx)(i4,{asChild:!0,children:i}),(0,U.jsxs)(i6,{align:"start",className:"min-w-44",children:[null!==e&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(i7,{onClick:()=>r(null),className:"text-[12.5px]",children:"Unassign"}),a.length>0&&(0,U.jsx)(ar,{})]}),a.map(({key:e,label:s})=>(0,U.jsxs)(i7,{onClick:()=>r(e),className:"gap-2 font-mono text-[12px]",children:[(0,U.jsx)(ao,{className:"size-3 text-muted-foreground"}),s]},e)),null===e&&0===a.length&&(0,U.jsx)("div",{className:"px-2 py-1.5 text-xs text-muted-foreground",children:"No free branches"})]})]})}function aS({status:e,priority:r,assignedBranch:s,onStatusChange:n,onPriorityChange:i,onAssign:a,worktrees:o,assignedBranches:l,readOnlyBranch:c,children:d}){return(0,U.jsxs)("dl",{className:"m-0 grid grid-cols-[96px_minmax(0,1fr)] items-center gap-x-2 gap-y-px text-[12.5px]",children:[(0,U.jsx)(ak,{label:"Status",children:(0,U.jsx)(af,{status:e,onChange:n,children:(0,U.jsxs)(ab,{"aria-label":"Status",children:[(0,U.jsx)(ac,{status:e}),r1[e].label]})})}),(0,U.jsx)(ak,{label:"Priority",children:(0,U.jsx)(ap,{priority:r,onChange:i,children:(0,U.jsxs)(ab,{"aria-label":"Priority",children:[(0,U.jsx)(au,{priority:r}),r2[r].label]})})}),(0,U.jsx)(ak,{label:"Branch",children:c?(0,U.jsx)("span",{className:"inline-flex h-[30px] items-center gap-2 text-muted-foreground/80",children:null!==s?(0,U.jsx)(aw,{branch:s}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(ao,{className:"size-3","aria-hidden":!0}),"Unassigned"]})}):(0,U.jsx)(a_,{current:s,onAssign:a,worktrees:o,assignedBranches:l,children:(0,U.jsx)(ab,{"aria-label":"Branch",muted:null===s,children:null!==s?(0,U.jsx)(aw,{branch:s}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(ao,{className:"size-3 shrink-0","aria-hidden":!0}),"Assign a branch"]})})})}),d]})}function ak({label:e,children:r}){return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)("dt",{className:"flex h-[30px] items-center text-muted-foreground",children:e}),(0,U.jsx)("dd",{className:"m-0 flex min-w-0",children:r})]})}function aj({task:e,open:r,onOpenChange:s,onOpenSourceSession:n,onOpenInTasks:i}){return e?(0,U.jsx)(rT,{open:r,onOpenChange:s,children:(0,U.jsxs)(rP,{className:"flex max-h-[min(32rem,80vh)] flex-col sm:max-w-lg",children:[(0,U.jsx)(rF,{className:"shrink-0 pr-6",children:(0,U.jsx)(rO,{className:"text-base leading-snug break-words",children:e.title})}),(0,U.jsxs)("div",{className:"-mr-6 min-h-0 min-w-0 flex-1 space-y-4 overflow-y-auto pr-6",children:[(0,U.jsxs)("div",{className:"flex items-center gap-2",children:[(0,U.jsx)(rG,{variant:"outline",className:`text-xs ${r1[e.status].color}`,children:r1[e.status].label}),(0,U.jsx)(rG,{variant:"outline",className:`text-xs ${r2[e.priority].color}`,children:r2[e.priority].label}),i&&(0,U.jsxs)("button",{type:"button",className:"ml-auto inline-flex shrink-0 items-center gap-1 rounded text-xs text-muted-foreground hover:text-foreground hover:underline",onClick:()=>{s(!1),i(e)},children:["Open in Tasks",(0,U.jsx)(rz,{className:"h-3 w-3"})]})]}),e.description&&(0,U.jsx)(r0.i,{mode:"static",className:`min-w-0 text-sm text-foreground break-words [&_pre]:max-w-full [&_pre]:overflow-x-auto ${av}`,children:e.description}),e.source_session&&(0,U.jsxs)("div",{className:"flex min-w-0 items-center gap-2 text-xs",children:[(0,U.jsx)("span",{className:"shrink-0 text-muted-foreground",children:"From session"}),(0,U.jsx)(rZ,{source:e.source_session,onOpen:n?()=>{s(!1),n(e)}:void 0})]}),(0,U.jsxs)("div",{className:"flex flex-wrap gap-x-4 gap-y-1 text-xs text-muted-foreground pt-2 border-t",children:[(0,U.jsxs)("span",{children:["Created: ",new Date(e.created_at).toLocaleString()]}),(0,U.jsxs)("span",{children:["Updated: ",new Date(e.updated_at).toLocaleString()]})]})]})]})}):null}var aC=e.i(165512);function aN(e){try{window.sessionStorage.removeItem(e)}catch{}}function aE(e){let r=(0,V.useRef)(e),s=(0,V.useRef)(new Map);return(0,V.useEffect)(()=>{r.current=e},[e]),(0,V.useCallback)(async e=>{let n,i=r.current;if(!i)throw Error("No project selected");let a=void 0===e?void 0:e.trim();if(void 0!==e&&!a)throw Error("Message is required");let o=`vibedeckx:project-chat:create:v1:${encodeURIComponent(i)}:${function(e){let r=void 0===e?"\0":`\u0001${e}`,s=0x811c9dc5,n=0x9e3779b9;for(let e=0;e<r.length;e++){let i=r.charCodeAt(e);s=Math.imul(s^i,0x1000193)>>>0,n=Math.imul(n^i,0x85ebca6b)>>>0}return`${s.toString(16).padStart(8,"0")}${n.toString(16).padStart(8,"0")}`}(a)}`,l=s.current.get(o)??function(e){try{return window.sessionStorage.getItem(e)??void 0}catch{return}}(o);if(l)s.current.set(o,l);else{l=crypto.randomUUID(),s.current.set(o,l);var c=l;try{window.sessionStorage.setItem(o,c)}catch{}}try{n=await aC.api.createProjectChatThread(i,a,l)}catch(e){throw"object"!=typeof e||null===e||Array.isArray(e)||409!==e.status||(s.current.delete(o),aN(o)),e}return s.current.delete(o),aN(o),n},[])}let aD=/[\s._/\\-]+/;function aT(e,r=2){let s=e.split(aD).filter(Boolean);if(0===s.length)return"";if(2===r&&s.length>=2){let e=Array.from(s[0])[0]??"",r=Array.from(s[1])[0]??"";if(e&&r)return(e+r).toLowerCase()}return Array.from(s[0]).slice(0,r).join("").toLowerCase()}let aR=(0,rE.default)("circle-alert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]),aA=(0,rE.default)("bot",[["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"}]]),aM=(0,rE.default)("calendar-clock",[["path",{d:"M16 14v2.2l1.6 1",key:"fo4ql5"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M21 7.5V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h3.5",key:"1osxxc"}],["path",{d:"M3 10h5",key:"r794hk"}],["path",{d:"M8 2v4",key:"1cmpym"}],["circle",{cx:"16",cy:"16",r:"6",key:"qoo3c4"}]]),aI=(0,rE.default)("inbox",[["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"}]]),aP=(0,rE.default)("loader-circle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);var aF=e.i(112683);let aL=(0,rE.default)("cloud",[["path",{d:"M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z",key:"p7xjir"}]]),aO=(0,rE.default)("cloud-off",[["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M5.782 5.782A7 7 0 0 0 9 19h8.5a4.5 4.5 0 0 0 1.307-.193",key:"yfwify"}],["path",{d:"M21.532 16.5A4.5 4.5 0 0 0 17.5 10h-1.79A7.008 7.008 0 0 0 10 5.07",key:"jlfiyv"}]]);function aB(e,r){let s=r?.withStatus??!1,[n,i]=(0,V.useState)([]),[a,o]=(0,V.useState)(!1),[l,c]=(0,V.useState)(null),d=void 0===e||l===e,[u,h]=(0,V.useState)(e);e!==u&&(h(e),i([]),c(null));let f=(0,V.useRef)(0),p=(0,V.useCallback)((e,r)=>{let s=new Map(r.map(e=>[e.id,e]));return e.map(e=>{let r=s.get(e.remote_server_id);return r?{...e,status:r.status}:e})},[]),m=(0,V.useCallback)(async()=>{let r=++f.current;if(!e)return void i([]);o(!0);try{let n=await aC.api.getProjectRemotes(e),a=n;if(s){let e=await aC.api.getRemoteServers();a=p(n,e)}if(r!==f.current)return;i(a)}catch(e){if(r!==f.current)return;console.error("Failed to fetch project remotes:",e)}finally{r===f.current&&(o(!1),c(e))}},[e,s,p]),g=(0,V.useCallback)(async()=>{if(e&&s)try{let e=await aC.api.getRemoteServers();i(r=>p(r,e))}catch(e){console.error("Failed to refresh remote server status:",e)}},[e,s,p]);return(0,V.useEffect)(()=>{m()},[m]),(0,aF.useGlobalEventStream)(r=>{s&&"remote-server:status"===r.type&&void 0!==e&&r.projectId===e&&g()}),(0,V.useEffect)(()=>{if(!s||!e)return;let r=setInterval(()=>void g(),6e4),n=()=>void g();return window.addEventListener("focus",n),()=>{clearInterval(r),window.removeEventListener("focus",n)}},[s,e,g]),{remotes:n,loading:a,loaded:d,refresh:m}}function az(e){return"online"!==e.status?aO:aL}var a$=e.i(331053);function aW(e,r){let s=e.branch||"main";return"local"===e.target?s:`${s} \xb7 ${r.get(e.target)??e.target}`}let aH=(0,rE.default)("archive",[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8",key:"1s80jp"}],["path",{d:"M10 12h4",key:"a56b0p"}]]),aU=(0,rE.default)("history",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]]),aV=(0,rE.default)("send",[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]]);function aq({className:e,...r}){return(0,U.jsx)("textarea",{"data-slot":"textarea",className:(0,e1.cn)("border-input placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 flex field-sizing-content min-h-16 w-full rounded-md border bg-transparent px-3 py-2 text-base shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),...r})}let aK=(0,rE.default)("search",[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]]);function aX({className:e,type:r,...s}){return(0,U.jsx)("input",{type:r,"data-slot":"input",className:(0,e1.cn)("file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground dark:bg-input/30 border-input h-9 w-full min-w-0 rounded-md border bg-transparent px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm","focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]","aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",e),...s})}function aY(e,r){let s=new Set;return[...e,...r].filter(e=>!s.has(e.id)&&(s.add(e.id),!0))}function aG(e){return e?.title?.trim()||"Untitled conversation"}function aJ({open:e,onOpenChange:r,projectId:s,defaultIncludeArchived:n,onSelectThread:i}){let a=function(e,r,s=!1){let[n,i]=(0,V.useState)([]),[a,o]=(0,V.useState)(!1),[l,c]=(0,V.useState)(!1),[d,u]=(0,V.useState)(null),[h,f]=(0,V.useState)(null),[p,m]=(0,V.useState)(""),[g,x]=(0,V.useState)(s),v=(0,V.useRef)(0),y=(0,V.useRef)(null),b=(0,V.useRef)(null),w=(0,V.useRef)({projectId:e,enabled:r,query:p,includeArchived:g});w.current={projectId:e,enabled:r,query:p,includeArchived:g},(0,V.useEffect)(()=>{v.current+=1;let s=v.current;if(b.current?.abort(),b.current=null,y.current=null,c(!1),!r||!e)return void o(!1);let n=new AbortController;return b.current=n,i([]),f(null),u(null),o(!0),aC.api.listProjectChatThreadPage(e,{includeArchived:g,...p.trim()?{query:p.trim()}:{},signal:n.signal}).then(e=>{n.signal.aborted||v.current!==s||(i(aY([],e.threads)),f(e.nextCursor))}).catch(e=>{n.signal.aborted||v.current!==s||u(e instanceof Error?e.message:"Failed to load thread history")}).finally(()=>{v.current===s&&o(!1),b.current===n&&(b.current=null)}),()=>{n.abort()}},[r,g,e,p]);let _=(0,V.useCallback)(async()=>{let e=w.current;if(!e.enabled||!e.projectId||!h||a||l||null!==y.current)return;let r=++v.current;y.current=r,b.current?.abort();let s=new AbortController;b.current=s,c(!0),u(null);try{let n=await aC.api.listProjectChatThreadPage(e.projectId,{includeArchived:e.includeArchived,...e.query.trim()?{query:e.query.trim()}:{},cursor:h,signal:s.signal});if(s.signal.aborted||v.current!==r||w.current.projectId!==e.projectId||w.current.query!==e.query||w.current.includeArchived!==e.includeArchived)return;i(e=>aY(e,n.threads)),f(n.nextCursor)}catch(e){s.signal.aborted||v.current!==r||u(e instanceof Error?e.message:"Failed to load more threads")}finally{v.current===r&&c(!1),y.current===r&&(y.current=null),b.current===s&&(b.current=null)}},[a,l,h]);return(0,V.useEffect)(()=>()=>b.current?.abort(),[]),{threads:n,loading:a,loadingMore:l,error:d,nextCursor:h,query:p,includeArchived:g,setQuery:m,showArchived:(0,V.useCallback)(()=>x(!0),[]),loadMore:_}}(s,e,n);return(0,U.jsx)(rT,{open:e,onOpenChange:r,children:(0,U.jsxs)(rP,{className:"max-h-[80vh] grid-rows-[auto_auto_minmax(0,1fr)]",children:[(0,U.jsxs)(rF,{children:[(0,U.jsx)(rO,{children:"All Project Chat threads"}),(0,U.jsx)(rB,{children:"Search, reopen, or include archived project conversations."})]}),(0,U.jsxs)("div",{className:"space-y-2",children:[(0,U.jsxs)("div",{className:"flex items-center gap-2",children:[(0,U.jsxs)("div",{className:"relative flex-1",children:[(0,U.jsx)(aK,{className:"pointer-events-none absolute left-2.5 top-1/2 size-4 -translate-y-1/2 text-muted-foreground","aria-hidden":"true"}),(0,U.jsx)(aX,{autoFocus:!0,"aria-label":"Search threads",maxLength:200,value:a.query,onChange:e=>a.setQuery(e.target.value),className:"pl-8"})]}),(0,U.jsxs)(a$.Button,{type:"button",variant:"outline",size:"sm",disabled:a.includeArchived||a.loading,onClick:a.showArchived,children:[(0,U.jsx)(aH,{className:"size-4","aria-hidden":"true"}),a.includeArchived?"Archived included":"Show archived threads"]})]}),a.error?(0,U.jsx)("div",{role:"alert",className:"rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive",children:a.error}):null]}),(0,U.jsxs)("div",{className:"min-h-0 space-y-1 overflow-y-auto",role:"list",children:[a.loading?(0,U.jsx)("p",{className:"py-8 text-center text-sm text-muted-foreground",children:"Loading threads…"}):0===a.threads.length?(0,U.jsx)("p",{className:"py-8 text-center text-sm text-muted-foreground",children:"No matching threads"}):a.threads.map(e=>{let s=aG(e);return(0,U.jsx)("div",{role:"listitem",children:(0,U.jsxs)("button",{type:"button","data-testid":"history-thread-row","aria-label":`Open history thread: ${s}`,onClick:()=>{i(e.id),r(!1)},className:"flex w-full items-center justify-between gap-3 rounded-md px-3 py-2 text-left hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:[(0,U.jsx)("span",{className:"min-w-0 truncate text-sm font-medium",children:s}),(0,U.jsx)("span",{className:"shrink-0 text-xs text-muted-foreground",children:e.archived_at?"Archived":new Date(e.updated_at).toLocaleDateString()})]})},e.id)}),a.nextCursor?(0,U.jsx)(a$.Button,{type:"button",variant:"outline",size:"sm",className:"mt-2 w-full",disabled:a.loadingMore,onClick:()=>void a.loadMore(),children:a.loadingMore?"Loading more…":"Load more threads"}):null]})]})})}function aZ({className:e,children:r,...s}){return(0,U.jsx)("section",{className:(0,e1.cn)("overflow-hidden rounded-[10px] border bg-card",e),...s,children:r})}function aQ({icon:e,children:r,trailing:s,className:n}){return(0,U.jsxs)("div",{className:(0,e1.cn)("flex items-center gap-2 border-b border-border/60 bg-secondary px-3.5 py-2.5 text-[11.5px] font-semibold text-foreground",n),children:[(0,U.jsx)("span",{className:"flex shrink-0 items-center text-muted-foreground",children:e}),r,(0,U.jsx)("span",{className:"flex-1"}),s]})}function a0({children:e,className:r}){return(0,U.jsx)("span",{className:(0,e1.cn)("font-mono text-[10.5px] font-medium text-muted-foreground/70",r),children:e})}function a1({children:e}){return(0,U.jsx)("p",{className:"px-3.5 py-4 text-xs text-muted-foreground",children:e})}function a2({className:e,children:r,...s}){return(0,U.jsx)("button",{type:"button",className:(0,e1.cn)("flex w-full items-start gap-2.5 border-b border-border/60 px-3.5 py-2.5 text-left transition-colors last:border-b-0 hover:bg-secondary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring",e),...s,children:r})}let a5={neutral:"bg-muted-foreground/60",blue:"bg-blue-500",green:"bg-emerald-500",lime:"bg-lime-400",amber:"bg-amber-500",rose:"bg-destructive"};function a3({tone:e,pulse:r,className:s}){return(0,U.jsxs)("span",{className:(0,e1.cn)("relative flex size-[7px] shrink-0",s),"aria-hidden":"true",children:[r?(0,U.jsx)("span",{className:(0,e1.cn)("absolute inset-0 animate-ping rounded-full opacity-50",a5[e])}):null,(0,U.jsx)("span",{className:(0,e1.cn)("relative size-[7px] rounded-full",a5[e])})]})}function a4({children:e}){return(0,U.jsx)("span",{className:"inline-flex h-4 items-center rounded-[4px] border border-b-2 bg-secondary px-[5px] font-mono text-[10px] leading-none text-muted-foreground",children:e})}function a6({scopeKey:e,projectId:r,threads:s,onCreateThread:n,onOpenThread:i}){let a=!!(n&&i),o=`project-chat-unavailable-${e}`,[l,c]=(0,V.useState)(""),[d,u]=(0,V.useState)(!1),[h,f]=(0,V.useState)(null),[p,m]=(0,V.useState)(!1),[g,x]=(0,V.useState)(!1),v=(0,V.useRef)(!1),y=(0,V.useRef)(!0),b=(0,V.useRef)(0);(0,V.useEffect)(()=>(y.current=!0,()=>{y.current=!1}),[]),(0,V.useEffect)(()=>{b.current+=1,v.current=!1,u(!1),c(""),f(null),m(!1)},[e]);let w=e=>{x(e),m(!0)},_=async e=>{e.preventDefault();let r=l.trim();if(!a||!n||!i||!r||v.current)return;v.current=!0;let s=b.current;u(!0),f(null);try{let e=await n(r);if(!y.current||b.current!==s)return;c(""),i(e.id)}catch(e){if(!y.current||b.current!==s)return;f(e instanceof Error?e.message:"Failed to start conversation")}finally{b.current===s&&(v.current=!1,y.current&&u(!1))}};return(0,U.jsxs)(aZ,{children:[(0,U.jsxs)("div",{className:"flex items-center gap-2.5 border-b border-border/60 bg-secondary px-3 py-2.5",children:[(0,U.jsx)("span",{className:"grid size-5.5 shrink-0 place-items-center rounded-md bg-accent text-accent-foreground",children:(0,U.jsx)(rJ,{className:"size-3.5","aria-hidden":"true"})}),(0,U.jsx)("h2",{className:"whitespace-nowrap text-[11.5px] font-semibold",children:"Project Chat"}),(0,U.jsx)("span",{className:"flex-1"}),(0,U.jsx)("span",{className:"min-w-0 truncate text-[11.5px] text-muted-foreground",children:"Spans every workspace in this project"})]}),(0,U.jsxs)("form",{onSubmit:e=>void _(e),className:"px-3 pt-2.5",children:[(0,U.jsxs)("div",{className:"flex items-center gap-2",children:[(0,U.jsxs)("div",{className:"flex min-w-0 flex-1 items-center gap-1 rounded-lg border bg-secondary py-0 pl-2.5 pr-1 transition-[color,background-color,border-color,box-shadow] focus-within:border-primary focus-within:bg-card focus-within:ring-[3px] focus-within:ring-accent",children:[(0,U.jsx)(aq,{value:l,onChange:e=>c(e.target.value),placeholder:"Discuss project progress, plans, or work across workspaces…","aria-label":"Message for a new Project Chat thread",rows:1,className:"max-h-32 min-h-0 resize-none border-0 bg-transparent p-0 py-[7px] text-[12.5px] shadow-none focus-visible:ring-0 dark:bg-transparent",disabled:!a||d,"aria-describedby":a?void 0:o,onKeyDown:e=>{"Enter"!==e.key||e.shiftKey||(e.preventDefault(),e.currentTarget.form?.requestSubmit())}}),(0,U.jsx)("span",{className:"flex shrink-0 items-center","aria-hidden":"true",children:(0,U.jsx)(a4,{children:"⏎"})})]}),(0,U.jsxs)(a$.Button,{type:"submit",size:"sm",disabled:!a||d||0===l.trim().length,children:[(0,U.jsx)(aV,{className:"size-3","aria-hidden":"true"}),d?"Starting…":"Start conversation"]})]}),h?(0,U.jsxs)("p",{role:"alert",className:"mt-2 text-[11.5px] text-destructive",children:[h,". Your message is still here; try again."]}):null,a?null:(0,U.jsx)("p",{id:o,className:"mt-2 text-[11.5px] text-muted-foreground",children:"Project Chat workbench is not available yet."})]}),(0,U.jsxs)("div",{className:"mt-2.5 border-t border-border/60",children:[0===s.length?(0,U.jsx)("p",{className:"px-3.5 py-4 text-xs text-muted-foreground",children:"No conversations yet"}):s.map(e=>{let r=e.title?.trim()||"Untitled conversation",s=function(e){let r=e.updated_at;if(!r)return null;let s=Date.parse(/(?:Z|[+-]\d\d:\d\d)$/i.test(r)?r:`${r.replace(" ","T")}Z`);if(Number.isNaN(s))return null;let n=Math.floor(Math.max(0,Date.now()-s)/6e4);if(n<1)return"now";if(n<60)return`${n}m ago`;let i=Math.floor(n/60);return i<24?`${i}h ago`:`${Math.floor(i/24)}d ago`}(e);return(0,U.jsxs)("button",{type:"button","data-testid":"recent-thread","aria-label":`Open Project Chat thread: ${r}`,"aria-disabled":!a,disabled:!a,onClick:i?()=>i(e.id):void 0,className:"flex w-full items-baseline gap-2.5 border-b border-border/60 px-3.5 py-2 text-left transition-colors last:border-b-0 hover:bg-secondary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50",children:[(0,U.jsx)("span",{className:"min-w-0 shrink truncate text-[12.5px] text-secondary-foreground",children:r}),s?(0,U.jsx)("span",{className:"shrink-0 font-mono text-[10.5px] text-muted-foreground/70",children:s}):null]},e.id)}),(0,U.jsxs)("div",{className:"flex flex-wrap items-center gap-2 border-t border-border/60 bg-secondary px-3.5 py-2",children:[(0,U.jsx)("span",{className:"font-mono text-[10.5px] text-muted-foreground/70",children:0===s.length?"No threads yet":`${s.length} most recent thread${1===s.length?"":"s"}`}),(0,U.jsx)("span",{className:"flex-1"}),(0,U.jsxs)(a$.Button,{type:"button",variant:"outline",size:"sm",className:"h-6 px-2 text-[11.5px]",disabled:!a,onClick:()=>w(!0),children:[(0,U.jsx)(aH,{className:"size-[11px]","aria-hidden":"true"}),"Show archived"]}),(0,U.jsxs)(a$.Button,{type:"button",variant:"outline",size:"sm",className:"h-6 px-2 text-[11.5px]",disabled:!a,onClick:()=>w(!1),children:[(0,U.jsx)(aU,{className:"size-[11px]","aria-hidden":"true"}),"All threads"]})]})]}),i?(0,U.jsx)(aJ,{open:p,onOpenChange:m,projectId:r,defaultIncludeArchived:g,onSelectThread:i},g?"archived":"recent"):null]})}let a7={running:"blue",stopped:"lime",error:"rose",unknown:"neutral"};function a8({sessions:e,remoteNames:r,onOpenSession:s}){let n=e.slice(0,8);return(0,U.jsxs)(aZ,{children:[(0,U.jsx)(aQ,{icon:(0,U.jsx)(aA,{className:"size-3","aria-hidden":"true"}),trailing:(0,U.jsx)(a0,{children:n.length}),children:"Recent Agent Sessions"}),0===n.length?(0,U.jsx)(a1,{children:"No agent sessions yet"}):n.map(e=>{let n=e.title?.trim()||e.branch||"Main workspace session";return(0,U.jsxs)(a2,{"data-testid":"recent-session","aria-label":`Open agent session: ${n}`,onClick:()=>s(e.id,e.workspace.target,e.workspace.branch),children:[(0,U.jsx)(a3,{tone:a7[e.status],pulse:"running"===e.status,className:"mt-[5px]"}),(0,U.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,U.jsx)("span",{className:"block truncate text-[12.5px] font-medium",children:n}),(0,U.jsxs)("span",{className:"mt-0.5 flex min-w-0 flex-wrap items-center gap-x-2.5 gap-y-0.5 font-mono text-[10.5px] text-muted-foreground",children:[(0,U.jsxs)("span",{className:"inline-flex min-w-0 max-w-50 items-center gap-1",children:[(0,U.jsx)(ao,{className:"size-2.5 shrink-0 text-muted-foreground/70","aria-hidden":"true"}),(0,U.jsx)("span",{className:"truncate",children:aW(e.workspace,r)})]}),e.model?(0,U.jsx)("span",{className:"truncate",children:e.model}):null,(0,U.jsx)("span",{children:function(e){if(!e)return"No activity time";let r=Math.floor(Math.max(0,Date.now()-e)/6e4);if(r<1)return"Just now";if(r<60)return`${r}m ago`;let s=Math.floor(r/60);return s<24?`${s}h ago`:`${Math.floor(s/24)}d ago`}(e.lastActiveAt)})]})]}),(0,U.jsx)("span",{className:"shrink-0 font-mono text-[10.5px] capitalize text-muted-foreground",children:e.status})]},`${e.target}:${e.id}`)})]})}let a9=(0,rE.default)("calendar-check",[["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:"m9 16 2 2 4-4",key:"19s6y9"}]]),oe={starting:"blue",running:"blue",completed:"green",failed:"rose",timeout:"amber",killed:"amber",skipped:"neutral"};function ot(e){return Date.parse(/(?:Z|[+-]\d\d:\d\d)$/i.test(e)?e:`${e.replace(" ","T")}Z`)}function or({runs:e,remoteNames:r,onOpenRun:s}){let n=e.slice(0,5);return(0,U.jsxs)(aZ,{children:[(0,U.jsx)(aQ,{icon:(0,U.jsx)(a9,{className:"size-3","aria-hidden":"true"}),trailing:(0,U.jsx)(a0,{children:n.length}),children:"Schedule Results"}),0===n.length?(0,U.jsx)(a1,{children:"No schedule runs yet"}):n.map(e=>{let n;return(0,U.jsxs)(a2,{"data-testid":"schedule-run","aria-label":`Open schedule run: ${e.scheduleName}`,onClick:()=>s(e.id,e.schedule_id),children:[(0,U.jsx)(a3,{tone:oe[e.status],pulse:"running"===e.status,className:"mt-[5px]"}),(0,U.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,U.jsx)("span",{className:"block truncate text-[12.5px] font-medium",children:e.scheduleName}),e.reportPreview?(0,U.jsx)("span",{className:"mt-1 block line-clamp-2 text-[11.5px] leading-[1.45] text-muted-foreground",children:e.reportPreview}):null,(0,U.jsxs)("span",{className:"mt-1 flex min-w-0 flex-wrap items-center gap-x-2.5 gap-y-0.5 font-mono text-[10.5px] text-muted-foreground",children:[(0,U.jsx)("span",{className:"capitalize",children:e.status}),(0,U.jsx)("span",{children:function(e){if(!e.finished_at)return"Running";let r=ot(e.finished_at)-ot(e.started_at);if(!Number.isFinite(r))return"Unknown duration";let s=Math.max(0,Math.round(r/1e3));return s<60?`${s}s`:`${Math.floor(s/60)}m ${s%60}s`}(e)}),(0,U.jsx)("span",{children:Number.isNaN(n=ot(e.finished_at||e.started_at))?"Unknown time":new Date(n).toLocaleString()}),(0,U.jsxs)("span",{className:"inline-flex min-w-0 max-w-50 items-center gap-1",children:[(0,U.jsx)(ao,{className:"size-2.5 shrink-0 text-muted-foreground/70","aria-hidden":"true"}),(0,U.jsx)("span",{className:"truncate",children:aW({target:e.target,branch:e.branch},r)})]})]})]})]},e.id)})]})}let os=(0,rE.default)("circle-check",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]),on=(0,rE.default)("list-todo",[["path",{d:"M13 5h8",key:"a7qcls"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 19h8",key:"c3s6r1"}],["path",{d:"m3 17 2 2 4-4",key:"1jhpwq"}],["rect",{x:"3",y:"4",width:"6",height:"6",rx:"1",key:"cif1o7"}]]),oi=(0,rE.default)("circle-x",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]),oa={in_progress:0,todo:1,done:2,cancelled:3},oo={urgent:0,high:1,medium:2,low:3},ol={urgent:"text-destructive",high:"text-amber-700 dark:text-amber-500",medium:"text-muted-foreground/70",low:"text-muted-foreground/70"};function oc({status:e}){return"in_progress"===e?(0,U.jsx)(aP,{className:"size-3.5 animate-spin text-blue-500","aria-hidden":"true"}):"done"===e?(0,U.jsx)(os,{className:"size-3.5 text-emerald-500","aria-hidden":"true"}):"cancelled"===e?(0,U.jsx)(oi,{className:"size-3.5 text-muted-foreground","aria-hidden":"true"}):(0,U.jsx)(i5,{className:"size-3.5 text-muted-foreground/70","aria-hidden":"true"})}function od({tasks:e,onOpenTask:r,onViewAll:s}){let n=[...e].filter(e=>null===e.archived_at&&"done"!==e.status&&"cancelled"!==e.status&&("in_progress"===e.status||"urgent"===e.priority||"high"===e.priority)).sort((e,r)=>oa[e.status]-oa[r.status]||oo[e.priority]-oo[r.priority]||r.updated_at.localeCompare(e.updated_at)||e.id.localeCompare(r.id)).slice(0,5);return(0,U.jsxs)(aZ,{children:[(0,U.jsx)(aQ,{icon:(0,U.jsx)(on,{className:"size-3","aria-hidden":"true"}),trailing:(0,U.jsxs)("button",{type:"button",onClick:s,"aria-label":"View all tasks",className:"rounded-sm text-[11.5px] font-medium text-primary hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:["View all tasks ",(0,U.jsx)("span",{"aria-hidden":"true",children:"→"})]}),children:"Priority Tasks"}),0===n.length?(0,U.jsx)(a1,{children:"No priority tasks"}):n.map(e=>(0,U.jsxs)(a2,{"data-testid":"priority-task","aria-label":`Open task: ${e.title}`,onClick:()=>r(e),className:"items-center",children:[(0,U.jsx)("span",{className:"flex shrink-0 items-center",children:(0,U.jsx)(oc,{status:e.status})}),(0,U.jsx)("span",{className:"min-w-0 flex-1 truncate text-[12.5px] text-secondary-foreground",children:e.title}),(0,U.jsx)("span",{className:(0,e1.cn)("shrink-0 font-mono text-[10.5px] capitalize",ol[e.priority]),children:e.priority})]},e.id))]})}let ou=(0,rE.default)("triangle-alert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]),oh=(0,rE.default)("external-link",[["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"}]]),of=(0,rE.default)("rotate-ccw",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]]);function op({scopeKey:e,items:r,onOpenAgentSession:s,onOpenScheduleRun:n,onRunScheduleAgain:i}){let a=(0,V.useRef)(new Set),[o,l]=(0,V.useState)(()=>new Set),[c,d]=(0,V.useState)(null),u=(0,V.useRef)(!0),h=(0,V.useRef)(0);(0,V.useEffect)(()=>(u.current=!0,()=>{u.current=!1}),[]),(0,V.useEffect)(()=>{h.current+=1,a.current.clear(),l(new Set),d(null)},[e]);let f=async e=>{if(a.current.has(e))return;let r=h.current;a.current.add(e),l(new Set(a.current)),d(null);try{await i(e)}catch(e){u.current&&h.current===r&&d(e instanceof Error?e.message:"Failed to start schedule run")}finally{h.current===r&&(a.current.delete(e),u.current&&l(new Set(a.current)))}};return 0===r.length?(0,U.jsxs)("div",{"data-testid":"attention-all-clear",className:"flex flex-wrap items-center gap-2 rounded-[10px] border border-emerald-500/25 bg-emerald-500/5 px-3.5 py-3 text-[12.5px] text-emerald-700 dark:text-emerald-300",children:[(0,U.jsx)(os,{className:"size-4 shrink-0","aria-hidden":"true"}),(0,U.jsx)("span",{className:"font-medium",children:"All clear"}),(0,U.jsx)("span",{className:"text-muted-foreground",children:"No failures need attention."})]}):(0,U.jsxs)(aZ,{className:"border-destructive/30",children:[(0,U.jsx)(aQ,{icon:(0,U.jsx)(ou,{className:"size-3 text-destructive","aria-hidden":"true"}),trailing:(0,U.jsx)(a0,{className:"text-destructive",children:r.length}),className:"border-b-destructive/20 bg-destructive/8",children:"Attention Required"}),c?(0,U.jsx)("p",{role:"alert",className:"border-b border-border/60 px-3.5 py-2 text-[12.5px] text-destructive",children:c}):null,r.map(e=>(0,U.jsxs)("div",{className:"flex flex-wrap items-center gap-2.5 border-b border-border/60 px-3.5 py-2.5 last:border-b-0",children:[(0,U.jsxs)("span",{className:"min-w-35 flex-1",children:[(0,U.jsx)("span",{className:"block truncate text-[12.5px] font-medium",children:e.title}),(0,U.jsx)("span",{className:"mt-0.5 block font-mono text-[10.5px] capitalize text-destructive",children:e.status.replaceAll("_"," ")})]}),(0,U.jsx)("span",{className:"flex shrink-0 gap-1.5",children:"agent_session"===e.type?(0,U.jsxs)(a$.Button,{type:"button",variant:"outline",size:"sm","aria-label":`Open agent session: ${e.title}`,onClick:()=>s(e.entityId,e.workspace?.target??e.target??"local",e.workspace?.branch??null),children:[(0,U.jsx)(oh,{className:"size-3","aria-hidden":"true"}),"Open session"]}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(a$.Button,{type:"button",variant:"outline",size:"sm","aria-label":`View output: ${e.title}`,onClick:()=>n(e.entityId,void 0),children:"View output"}),(0,U.jsxs)(a$.Button,{type:"button",variant:"outline",size:"sm","aria-label":`Run again: ${e.title}`,disabled:o.has(e.entityId),onClick:()=>void f(e.entityId),children:[(0,U.jsx)(of,{className:"size-3","aria-hidden":"true"}),o.has(e.entityId)?"Starting…":"Run again"]})]})})]},`${e.type}:${e.entityId}`))]})}let om=(0,rE.default)("star",[["path",{d:"M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z",key:"r04s7s"}]]),og={running:"blue",stopped:"lime",error:"rose",unknown:"neutral"};function ox({sessions:e,hasMore:r,remoteNames:s,onOpenSession:n}){return(0,U.jsxs)(aZ,{children:[(0,U.jsx)(aQ,{icon:(0,U.jsx)(om,{className:"size-3 fill-current text-amber-500","aria-hidden":"true"}),trailing:(0,U.jsxs)(a0,{children:[e.length,r?"+":""]}),children:"Starred Sessions"}),0===e.length?(0,U.jsx)(a1,{children:"No starred sessions — star one to keep it here"}):(0,U.jsx)("div",{"data-testid":"starred-scroller",className:"max-h-96 overflow-y-auto overscroll-contain",children:e.map(e=>{let r=e.title?.trim()||e.branch||"Main workspace session";return(0,U.jsxs)(a2,{"data-testid":"starred-session","aria-label":`Open starred session: ${r}`,onClick:()=>n(e.id,e.workspace.target,e.workspace.branch),children:[(0,U.jsx)(a3,{tone:og[e.status],pulse:"running"===e.status,className:"mt-[5px]"}),(0,U.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,U.jsx)("span",{className:"block truncate text-[12.5px] font-medium",children:r}),(0,U.jsxs)("span",{className:"mt-0.5 flex min-w-0 items-center gap-1 font-mono text-[10.5px] text-muted-foreground",children:[(0,U.jsx)(ao,{className:"size-2.5 shrink-0 text-muted-foreground/70","aria-hidden":"true"}),(0,U.jsx)("span",{className:"truncate",children:aW(e.workspace,s)})]})]})]},`${e.target}:${e.id}`)})})]})}function ov({label:e,icon:r,children:s,detail:n}){return(0,U.jsxs)("div",{className:"min-w-0 border-b border-border/60 py-3.5 last:border-b-0 sm:border-b-0 sm:border-r sm:px-6 sm:first:pl-0 sm:last:border-r-0 sm:last:pr-0",children:[(0,U.jsxs)("div",{className:"mb-1.5 flex items-center gap-1.5 text-[10px] font-semibold uppercase tracking-[0.07em] text-muted-foreground/70",children:[(0,U.jsx)("span",{className:"flex items-center",children:r}),e]}),s,(0,U.jsx)("p",{className:"mt-1.5 truncate font-mono text-[10.5px] text-muted-foreground",children:n})]})}function oy({unit:e,children:r}){return(0,U.jsxs)("p",{className:"flex items-baseline gap-1.5 font-mono text-[22px] font-medium leading-[1.1] tracking-[-0.03em]",children:[r,(0,U.jsx)("span",{className:"text-[11.5px] font-normal tracking-normal text-muted-foreground/70",children:e})]})}function ob({projectId:e,waitingCount:r,onCreateThread:s,onOpenThread:n,onOpenAgentSession:i,onOpenScheduleRun:a,onRunScheduleAgain:o,onOpenTask:l,onViewAllTasks:c}){let d,{activity:u,loading:h,error:f,refetch:p}=function(e){let[r,s]=(0,V.useState)(null),[n,i]=(0,V.useState)(!1),[a,o]=(0,V.useState)(null),l=(0,V.useRef)(e),c=(0,V.useRef)(0),d=(0,V.useRef)(0),u=(0,V.useRef)(null),h=(0,V.useRef)(!1),f=(0,V.useRef)(null),p=(0,V.useCallback)(async function e(r,n,a,u){if(u)h.current=!1,f.current?.controller.abort();else if(f.current?.generation===n)return h.current=!0,f.current.promise;let p=new AbortController,m=++d.current;a&&i(!0);let g=(async()=>{try{let e=await aC.api.getProjectActivity(r,{signal:p.signal});if(c.current!==n||l.current!==r||d.current!==m)return;s(e),o(null)}catch(e){if(p.signal.aborted||c.current!==n||l.current!==r||d.current!==m)return;o(e instanceof Error?e.message:"Failed to fetch project activity")}finally{if(f.current?.controller!==p||(f.current=null,c.current!==n||l.current!==r))return;i(!1),h.current&&(h.current=!1,e(r,n,!1,!1))}})();return f.current={generation:n,controller:p,promise:g},g},[]);(0,V.useEffect)(()=>{l.current=e,c.current+=1,d.current+=1;let r=c.current;if(f.current?.controller.abort(),f.current=null,h.current=!1,u.current&&(clearTimeout(u.current),u.current=null),!e){s(null),i(!1),o(null);return}return s(null),o(null),p(e,r,!0,!1),()=>{c.current===r&&(c.current+=1,d.current+=1),f.current?.controller.abort(),f.current=null,h.current=!1,u.current&&(clearTimeout(u.current),u.current=null)}},[p,e]);let m=(0,V.useCallback)(async()=>{let e=l.current;e&&await p(e,c.current,!1,!0)},[p]);return(0,aF.useGlobalEventStream)(e=>{e.type&&/^(session|schedule|task):/.test(e.type)&&l.current&&e.projectId===l.current&&(u.current||(u.current=setTimeout(()=>{u.current=null;let e=l.current;e&&p(e,c.current,!1,!1)},100)))}),{activity:r,loading:n,error:a,refetch:m}}(e),{remotes:m}=aB(e),g=(0,V.useMemo)(()=>new Map(m.map(e=>[e.remote_server_id,e.server_name])),[m]);return h&&!u?(0,U.jsxs)("div",{"aria-busy":"true","aria-live":"polite",className:"flex min-h-48 items-center justify-center gap-2 text-sm text-muted-foreground",children:[(0,U.jsx)(aP,{className:"size-4 animate-spin","aria-hidden":"true"}),"Loading project activity…"]}):f&&!u?(0,U.jsxs)("div",{role:"alert",className:"flex min-h-48 flex-col items-center justify-center gap-3 rounded-xl border border-destructive/20 bg-destructive/5 p-6 text-center",children:[(0,U.jsx)(aR,{className:"size-6 text-destructive","aria-hidden":"true"}),(0,U.jsxs)("div",{children:[(0,U.jsx)("p",{className:"font-medium",children:"Project activity is unavailable"}),(0,U.jsx)("p",{className:"mt-1 text-sm text-muted-foreground",children:f})]}),(0,U.jsx)(a$.Button,{type:"button",variant:"outline",size:"sm",onClick:()=>void p(),children:"Retry"})]}):u?(0,U.jsxs)("section",{"aria-label":"Project activity dashboard",className:"space-y-4",children:[(0,U.jsxs)("div",{className:"grid grid-cols-1 border-t border-border/60 sm:grid-cols-3",children:[(0,U.jsx)(ov,{label:"Running",icon:(0,U.jsx)(aA,{className:"size-[11px]","aria-hidden":"true"}),detail:0===(d=u.recentAgentSessions.filter(e=>"running"===e.status).map(e=>aW(e.workspace,g))).length?"Nothing running right now":d.slice(0,2).join(" · ")+(d.length>2?` +${d.length-2}`:""),children:(0,U.jsx)(oy,{unit:"agent sessions",children:(0,U.jsx)("span",{className:"text-blue-600 dark:text-blue-400",children:u.summary.running})})}),(0,U.jsx)(ov,{label:"Waiting",icon:(0,U.jsx)(aI,{className:"size-[11px]","aria-hidden":"true"}),detail:r>0?"Unread attention milestones":"You're all caught up",children:(0,U.jsx)(oy,{unit:"updates for you",children:(0,U.jsx)("span",{"data-testid":"waiting-count","aria-label":`${r} unread updates waiting for you`,className:r>0?"text-amber-600 dark:text-amber-400":void 0,children:r})})}),(0,U.jsx)(ov,{label:"Next schedule",icon:(0,U.jsx)(aM,{className:"size-[11px]","aria-hidden":"true"}),detail:function(e){if(!e)return"No upcoming runs";let r=new Date(e).getTime();if(Number.isNaN(r))return"Unrecognised schedule time";let s=Math.round((r-Date.now())/6e4);if(s<=0)return"Due now";if(s<60)return`in ${s}m`;let n=Math.floor(s/60);return n<24?`in ${n}h ${s%60}m`:`in ${Math.floor(n/24)}d ${n%24}h`}(u.summary.nextScheduleAt),children:(0,U.jsx)("p",{className:"truncate font-mono text-[13px] font-medium tracking-[-0.01em]",children:function(e){if(!e)return"None scheduled";let r=new Date(e);if(Number.isNaN(r.getTime()))return"Unknown";let s=r.toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"}),n=Math.round((new Date(r).setHours(0,0,0,0)-new Date().setHours(0,0,0,0))/864e5);return 0===n?`Today \xb7 ${s}`:1===n?`Tomorrow \xb7 ${s}`:`${r.toLocaleDateString()} \xb7 ${s}`}(u.summary.nextScheduleAt)})})]}),f?(0,U.jsxs)("div",{role:"status",className:"flex items-center justify-between gap-3 rounded-lg border border-amber-500/20 bg-amber-500/5 px-3 py-2 text-sm",children:[(0,U.jsxs)("span",{children:["Live refresh failed: ",f]}),(0,U.jsx)(a$.Button,{type:"button",variant:"ghost",size:"sm",onClick:()=>void p(),children:"Retry"})]}):null,(0,U.jsxs)("div",{className:"grid grid-cols-1 items-start gap-4 xl:grid-cols-[minmax(0,3fr)_minmax(16.25rem,2fr)]",children:[(0,U.jsxs)("div",{className:"flex min-w-0 flex-col gap-4",children:[(0,U.jsx)(a6,{scopeKey:e,projectId:e,threads:u.recentThreads,onCreateThread:s?async e=>{let r=await s(e);return p(),r}:void 0,onOpenThread:n}),(0,U.jsx)(a8,{sessions:u.recentAgentSessions,remoteNames:g,onOpenSession:i}),(0,U.jsx)(or,{runs:u.recentScheduleRuns,remoteNames:g,onOpenRun:a})]}),(0,U.jsxs)("div",{className:"flex min-w-0 flex-col gap-4",children:[(0,U.jsx)(od,{tasks:u.priorityTasks,onOpenTask:l,onViewAll:c}),(0,U.jsx)(ox,{sessions:u.starredSessions,hasMore:u.starredHasMore,remoteNames:g,onOpenSession:i}),(0,U.jsx)(op,{scopeKey:e,items:u.attention,onOpenAgentSession:i,onOpenScheduleRun:a,onRunScheduleAgain:o})]})]})]}):null}var ow=e.i(423917);let o_=(0,rE.default)("folder-open",[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]]),oS=(0,rE.default)("plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]),ok=(0,rE.default)("trash-2",[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]]),oj=(0,rE.default)("server",[["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"}]]),oC=(0,rE.default)("globe",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]]),oN=(0,rE.default)("crown",[["path",{d:"M11.562 3.266a.5.5 0 0 1 .876 0L15.39 8.87a1 1 0 0 0 1.516.294L21.183 5.5a.5.5 0 0 1 .798.519l-2.834 10.246a1 1 0 0 1-.956.734H5.81a1 1 0 0 1-.957-.734L2.02 6.02a.5.5 0 0 1 .798-.519l4.276 3.664a1 1 0 0 0 1.516-.294z",key:"1vdc57"}],["path",{d:"M5 21h14",key:"11awu3"}]]);function oE(e,[r,s]){return Math.min(s,Math.max(r,e))}var oD="ScrollArea",[oT,oR]=es(oD),[oA,oM]=oT(oD),oI=V.forwardRef((e,r)=>{let{__scopeScrollArea:s,type:n="hover",dir:i,scrollHideDelay:a=600,...o}=e,[l,c]=V.useState(null),[d,u]=V.useState(null),[h,f]=V.useState(null),[p,m]=V.useState(null),[g,x]=V.useState(null),[v,y]=V.useState(0),[b,w]=V.useState(0),[_,S]=V.useState(!1),[k,j]=V.useState(!1),C=(0,en.useComposedRefs)(r,e=>c(e)),N=ew(i);return(0,U.jsx)(oA,{scope:s,type:n,dir:N,scrollHideDelay:a,scrollArea:l,viewport:d,onViewportChange:u,content:h,onContentChange:f,scrollbarX:p,onScrollbarXChange:m,scrollbarXEnabled:_,onScrollbarXEnabledChange:S,scrollbarY:g,onScrollbarYChange:x,scrollbarYEnabled:k,onScrollbarYEnabledChange:j,onCornerWidthChange:y,onCornerHeightChange:w,children:(0,U.jsx)(em.div,{dir:N,...o,ref:C,style:{position:"relative","--radix-scroll-area-corner-width":v+"px","--radix-scroll-area-corner-height":b+"px",...e.style}})})});oI.displayName=oD;var oP="ScrollAreaViewport",oF=V.forwardRef((e,r)=>{let{__scopeScrollArea:s,children:n,nonce:i,...a}=e,o=oM(oP,s),l=V.useRef(null),c=(0,en.useComposedRefs)(r,l,o.onViewportChange);return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)("style",{dangerouslySetInnerHTML:{__html:"[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}"},nonce:i}),(0,U.jsx)(em.div,{"data-radix-scroll-area-viewport":"",...a,ref:c,style:{overflowX:o.scrollbarXEnabled?"scroll":"hidden",overflowY:o.scrollbarYEnabled?"scroll":"hidden",...e.style},children:(0,U.jsx)("div",{ref:o.onContentChange,style:{minWidth:"100%",display:"table"},children:n})})]})});oF.displayName=oP;var oL="ScrollAreaScrollbar",oO=V.forwardRef((e,r)=>{let{forceMount:s,...n}=e,i=oM(oL,e.__scopeScrollArea),{onScrollbarXEnabledChange:a,onScrollbarYEnabledChange:o}=i,l="horizontal"===e.orientation;return V.useEffect(()=>(l?a(!0):o(!0),()=>{l?a(!1):o(!1)}),[l,a,o]),"hover"===i.type?(0,U.jsx)(oB,{...n,ref:r,forceMount:s}):"scroll"===i.type?(0,U.jsx)(oz,{...n,ref:r,forceMount:s}):"auto"===i.type?(0,U.jsx)(o$,{...n,ref:r,forceMount:s}):"always"===i.type?(0,U.jsx)(oW,{...n,ref:r}):null});oO.displayName=oL;var oB=V.forwardRef((e,r)=>{let{forceMount:s,...n}=e,i=oM(oL,e.__scopeScrollArea),[a,o]=V.useState(!1);return V.useEffect(()=>{let e=i.scrollArea,r=0;if(e){let s=()=>{window.clearTimeout(r),o(!0)},n=()=>{r=window.setTimeout(()=>o(!1),i.scrollHideDelay)};return e.addEventListener("pointerenter",s),e.addEventListener("pointerleave",n),()=>{window.clearTimeout(r),e.removeEventListener("pointerenter",s),e.removeEventListener("pointerleave",n)}}},[i.scrollArea,i.scrollHideDelay]),(0,U.jsx)(eO,{present:s||a,children:(0,U.jsx)(o$,{"data-state":a?"visible":"hidden",...n,ref:r})})}),oz=V.forwardRef((e,r)=>{var s;let{forceMount:n,...i}=e,a=oM(oL,e.__scopeScrollArea),o="horizontal"===e.orientation,l=o6(()=>d("SCROLL_END"),100),[c,d]=(s={hidden:{SCROLL:"scrolling"},scrolling:{SCROLL_END:"idle",POINTER_ENTER:"interacting"},interacting:{SCROLL:"interacting",POINTER_LEAVE:"idle"},idle:{HIDE:"hidden",SCROLL:"scrolling",POINTER_ENTER:"interacting"}},V.useReducer((e,r)=>s[e][r]??e,"hidden"));return V.useEffect(()=>{if("idle"===c){let e=window.setTimeout(()=>d("HIDE"),a.scrollHideDelay);return()=>window.clearTimeout(e)}},[c,a.scrollHideDelay,d]),V.useEffect(()=>{let e=a.viewport,r=o?"scrollLeft":"scrollTop";if(e){let s=e[r],n=()=>{let n=e[r];s!==n&&(d("SCROLL"),l()),s=n};return e.addEventListener("scroll",n),()=>e.removeEventListener("scroll",n)}},[a.viewport,o,d,l]),(0,U.jsx)(eO,{present:n||"hidden"!==c,children:(0,U.jsx)(oW,{"data-state":"hidden"===c?"hidden":"visible",...i,ref:r,onPointerEnter:er(e.onPointerEnter,()=>d("POINTER_ENTER")),onPointerLeave:er(e.onPointerLeave,()=>d("POINTER_LEAVE"))})})}),o$=V.forwardRef((e,r)=>{let s=oM(oL,e.__scopeScrollArea),{forceMount:n,...i}=e,[a,o]=V.useState(!1),l="horizontal"===e.orientation,c=o6(()=>{if(s.viewport){let e=s.viewport.offsetWidth<s.viewport.scrollWidth,r=s.viewport.offsetHeight<s.viewport.scrollHeight;o(l?e:r)}},10);return o7(s.viewport,c),o7(s.content,c),(0,U.jsx)(eO,{present:n||a,children:(0,U.jsx)(oW,{"data-state":a?"visible":"hidden",...i,ref:r})})}),oW=V.forwardRef((e,r)=>{let{orientation:s="vertical",...n}=e,i=oM(oL,e.__scopeScrollArea),a=V.useRef(null),o=V.useRef(0),[l,c]=V.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),d=o1(l.viewport,l.content),u={...n,sizes:l,onSizesChange:c,hasThumb:!!(d>0&&d<1),onThumbChange:e=>a.current=e,onThumbPointerUp:()=>o.current=0,onThumbPointerDown:e=>o.current=e};function h(e,r){return function(e,r,s,n="ltr"){let i=o2(s),a=r||i/2,o=s.scrollbar.paddingStart+a,l=s.scrollbar.size-s.scrollbar.paddingEnd-(i-a),c=s.content-s.viewport;return o3([o,l],"ltr"===n?[0,c]:[-1*c,0])(e)}(e,o.current,l,r)}return"horizontal"===s?(0,U.jsx)(oH,{...u,ref:r,onThumbPositionChange:()=>{if(i.viewport&&a.current){let e=o5(i.viewport.scrollLeft,l,i.dir);a.current.style.transform=`translate3d(${e}px, 0, 0)`}},onWheelScroll:e=>{i.viewport&&(i.viewport.scrollLeft=e)},onDragScroll:e=>{i.viewport&&(i.viewport.scrollLeft=h(e,i.dir))}}):"vertical"===s?(0,U.jsx)(oU,{...u,ref:r,onThumbPositionChange:()=>{if(i.viewport&&a.current){let e=o5(i.viewport.scrollTop,l);a.current.style.transform=`translate3d(0, ${e}px, 0)`}},onWheelScroll:e=>{i.viewport&&(i.viewport.scrollTop=e)},onDragScroll:e=>{i.viewport&&(i.viewport.scrollTop=h(e))}}):null}),oH=V.forwardRef((e,r)=>{let{sizes:s,onSizesChange:n,...i}=e,a=oM(oL,e.__scopeScrollArea),[o,l]=V.useState(),c=V.useRef(null),d=(0,en.useComposedRefs)(r,c,a.onScrollbarXChange);return V.useEffect(()=>{c.current&&l(getComputedStyle(c.current))},[c]),(0,U.jsx)(oK,{"data-orientation":"horizontal",...i,ref:d,sizes:s,style:{bottom:0,left:"rtl"===a.dir?"var(--radix-scroll-area-corner-width)":0,right:"ltr"===a.dir?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":o2(s)+"px",...e.style},onThumbPointerDown:r=>e.onThumbPointerDown(r.x),onDragScroll:r=>e.onDragScroll(r.x),onWheelScroll:(r,s)=>{if(a.viewport){var n,i;let o=a.viewport.scrollLeft+r.deltaX;e.onWheelScroll(o),n=o,i=s,n>0&&n<i&&r.preventDefault()}},onResize:()=>{c.current&&a.viewport&&o&&n({content:a.viewport.scrollWidth,viewport:a.viewport.offsetWidth,scrollbar:{size:c.current.clientWidth,paddingStart:o0(o.paddingLeft),paddingEnd:o0(o.paddingRight)}})}})}),oU=V.forwardRef((e,r)=>{let{sizes:s,onSizesChange:n,...i}=e,a=oM(oL,e.__scopeScrollArea),[o,l]=V.useState(),c=V.useRef(null),d=(0,en.useComposedRefs)(r,c,a.onScrollbarYChange);return V.useEffect(()=>{c.current&&l(getComputedStyle(c.current))},[c]),(0,U.jsx)(oK,{"data-orientation":"vertical",...i,ref:d,sizes:s,style:{top:0,right:"ltr"===a.dir?0:void 0,left:"rtl"===a.dir?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":o2(s)+"px",...e.style},onThumbPointerDown:r=>e.onThumbPointerDown(r.y),onDragScroll:r=>e.onDragScroll(r.y),onWheelScroll:(r,s)=>{if(a.viewport){var n,i;let o=a.viewport.scrollTop+r.deltaY;e.onWheelScroll(o),n=o,i=s,n>0&&n<i&&r.preventDefault()}},onResize:()=>{c.current&&a.viewport&&o&&n({content:a.viewport.scrollHeight,viewport:a.viewport.offsetHeight,scrollbar:{size:c.current.clientHeight,paddingStart:o0(o.paddingTop),paddingEnd:o0(o.paddingBottom)}})}})}),[oV,oq]=oT(oL),oK=V.forwardRef((e,r)=>{let{__scopeScrollArea:s,sizes:n,hasThumb:i,onThumbChange:a,onThumbPointerUp:o,onThumbPointerDown:l,onThumbPositionChange:c,onDragScroll:d,onWheelScroll:u,onResize:h,...f}=e,p=oM(oL,s),[m,g]=V.useState(null),x=(0,en.useComposedRefs)(r,e=>g(e)),v=V.useRef(null),y=V.useRef(""),b=p.viewport,w=n.content-n.viewport,_=ex(u),S=ex(c),k=o6(h,10);function j(e){v.current&&d({x:e.clientX-v.current.left,y:e.clientY-v.current.top})}return V.useEffect(()=>{let e=e=>{let r=e.target;m?.contains(r)&&_(e,w)};return document.addEventListener("wheel",e,{passive:!1}),()=>document.removeEventListener("wheel",e,{passive:!1})},[b,m,w,_]),V.useEffect(S,[n,S]),o7(m,k),o7(p.content,k),(0,U.jsx)(oV,{scope:s,scrollbar:m,hasThumb:i,onThumbChange:ex(a),onThumbPointerUp:ex(o),onThumbPositionChange:S,onThumbPointerDown:ex(l),children:(0,U.jsx)(em.div,{...f,ref:x,style:{position:"absolute",...f.style},onPointerDown:er(e.onPointerDown,e=>{0===e.button&&(e.target.setPointerCapture(e.pointerId),v.current=m.getBoundingClientRect(),y.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",p.viewport&&(p.viewport.style.scrollBehavior="auto"),j(e))}),onPointerMove:er(e.onPointerMove,j),onPointerUp:er(e.onPointerUp,e=>{let r=e.target;r.hasPointerCapture(e.pointerId)&&r.releasePointerCapture(e.pointerId),document.body.style.webkitUserSelect=y.current,p.viewport&&(p.viewport.style.scrollBehavior=""),v.current=null})})})}),oX="ScrollAreaThumb",oY=V.forwardRef((e,r)=>{let{forceMount:s,...n}=e,i=oq(oX,e.__scopeScrollArea);return(0,U.jsx)(eO,{present:s||i.hasThumb,children:(0,U.jsx)(oG,{ref:r,...n})})}),oG=V.forwardRef((e,r)=>{let{__scopeScrollArea:s,style:n,...i}=e,a=oM(oX,s),o=oq(oX,s),{onThumbPositionChange:l}=o,c=(0,en.useComposedRefs)(r,e=>o.onThumbChange(e)),d=V.useRef(void 0),u=o6(()=>{d.current&&(d.current(),d.current=void 0)},100);return V.useEffect(()=>{let e=a.viewport;if(e){let r=()=>{u(),d.current||(d.current=o4(e,l),l())};return l(),e.addEventListener("scroll",r),()=>e.removeEventListener("scroll",r)}},[a.viewport,u,l]),(0,U.jsx)(em.div,{"data-state":o.hasThumb?"visible":"hidden",...i,ref:c,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...n},onPointerDownCapture:er(e.onPointerDownCapture,e=>{let r=e.target.getBoundingClientRect(),s=e.clientX-r.left,n=e.clientY-r.top;o.onThumbPointerDown({x:s,y:n})}),onPointerUp:er(e.onPointerUp,o.onThumbPointerUp)})});oY.displayName=oX;var oJ="ScrollAreaCorner",oZ=V.forwardRef((e,r)=>{let s=oM(oJ,e.__scopeScrollArea),n=!!(s.scrollbarX&&s.scrollbarY);return"scroll"!==s.type&&n?(0,U.jsx)(oQ,{...e,ref:r}):null});oZ.displayName=oJ;var oQ=V.forwardRef((e,r)=>{let{__scopeScrollArea:s,...n}=e,i=oM(oJ,s),[a,o]=V.useState(0),[l,c]=V.useState(0),d=!!(a&&l);return o7(i.scrollbarX,()=>{let e=i.scrollbarX?.offsetHeight||0;i.onCornerHeightChange(e),c(e)}),o7(i.scrollbarY,()=>{let e=i.scrollbarY?.offsetWidth||0;i.onCornerWidthChange(e),o(e)}),d?(0,U.jsx)(em.div,{...n,ref:r,style:{width:a,height:l,position:"absolute",right:"ltr"===i.dir?0:void 0,left:"rtl"===i.dir?0:void 0,bottom:0,...e.style}}):null});function o0(e){return e?parseInt(e,10):0}function o1(e,r){let s=e/r;return isNaN(s)?0:s}function o2(e){let r=o1(e.viewport,e.content),s=e.scrollbar.paddingStart+e.scrollbar.paddingEnd;return Math.max((e.scrollbar.size-s)*r,18)}function o5(e,r,s="ltr"){let n=o2(r),i=r.scrollbar.paddingStart+r.scrollbar.paddingEnd,a=r.scrollbar.size-i,o=r.content-r.viewport,l=oE(e,"ltr"===s?[0,o]:[-1*o,0]);return o3([0,o],[0,a-n])(l)}function o3(e,r){return s=>{if(e[0]===e[1]||r[0]===r[1])return r[0];let n=(r[1]-r[0])/(e[1]-e[0]);return r[0]+n*(s-e[0])}}var o4=(e,r=()=>{})=>{let s={left:e.scrollLeft,top:e.scrollTop},n=0;return!function i(){let a={left:e.scrollLeft,top:e.scrollTop},o=s.left!==a.left,l=s.top!==a.top;(o||l)&&r(),s=a,n=window.requestAnimationFrame(i)}(),()=>window.cancelAnimationFrame(n)};function o6(e,r){let s=ex(e),n=V.useRef(0);return V.useEffect(()=>()=>window.clearTimeout(n.current),[]),V.useCallback(()=>{window.clearTimeout(n.current),n.current=window.setTimeout(s,r)},[s,r])}function o7(e,r){let s=ex(r);ed(()=>{let r=0;if(e){let n=new ResizeObserver(()=>{cancelAnimationFrame(r),r=window.requestAnimationFrame(s)});return n.observe(e),()=>{window.cancelAnimationFrame(r),n.unobserve(e)}}},[e,s])}function o8({className:e,children:r,...s}){return(0,U.jsxs)(oI,{"data-slot":"scroll-area",className:(0,e1.cn)("relative",e),...s,children:[(0,U.jsx)(oF,{"data-slot":"scroll-area-viewport",className:"focus-visible:ring-ring/50 size-full rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:outline-1",children:r}),(0,U.jsx)(o9,{}),(0,U.jsx)(oZ,{})]})}function o9({className:e,orientation:r="vertical",...s}){return(0,U.jsx)(oO,{"data-slot":"scroll-area-scrollbar",orientation:r,className:(0,e1.cn)("flex touch-none p-px transition-colors select-none","vertical"===r&&"h-full w-2.5 border-l border-l-transparent","horizontal"===r&&"h-2.5 flex-col border-t border-t-transparent",e),...s,children:(0,U.jsx)(oY,{"data-slot":"scroll-area-thumb",className:"bg-border relative flex-1 rounded-full"})})}let le=(0,rE.default)("folder",[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]),lt=(0,rE.default)("folder-plus",[["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"M9 13h6",key:"1uhe8q"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]),lr=(0,rE.default)("chevron-up",[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]]);function ls({serverId:e,onSelect:r,selectedPath:s}){let[n,i]=(0,V.useState)("/"),[a,o]=(0,V.useState)([]),[l,c]=(0,V.useState)(!1),[d,u]=(0,V.useState)(""),[h,f]=(0,V.useState)(!1),[p,m]=(0,V.useState)(""),[g,x]=(0,V.useState)(""),[v,y]=(0,V.useState)(!1),b=(0,V.useRef)(null),w=(0,V.useRef)(!1),_=(0,V.useCallback)(async()=>{if(!e)return void o([]);c(!0),u("");try{let r=await aC.api.browseRemoteServerDirectory(e,n);o(r.items??[])}catch(e){u(e instanceof Error?e.message:"Failed to load directory"),o([])}finally{c(!1)}},[e,n]);(0,V.useEffect)(()=>{_(),f(!1),m(""),x("")},[_]),(0,V.useEffect)(()=>{h&&(b.current?.focus(),b.current?.select())},[h]);let S=()=>{f(!1),m(""),x("")},k=async()=>{if(w.current)return;let s=p.trim();if(!s)return void S();w.current=!0,y(!0),x("");try{let i=await aC.api.createRemoteServerDirectory(e,n,s);f(!1),m(""),await _(),r(i.path)}catch(e){x(e instanceof Error?e.message:"Failed to create folder")}finally{w.current=!1,y(!1)}};return e?(0,U.jsxs)("div",{className:"border rounded-md",children:[(0,U.jsxs)("div",{className:"flex items-center gap-2 p-2 border-b bg-muted/50",children:[(0,U.jsx)(a$.Button,{variant:"ghost",size:"sm",onClick:()=>{i(n.split("/").slice(0,-1).join("/")||"/")},disabled:"/"===n||l,children:(0,U.jsx)(lr,{className:"h-4 w-4"})}),(0,U.jsx)("span",{className:"text-sm font-mono truncate flex-1",children:n}),(0,U.jsx)(a$.Button,{variant:"ghost",size:"sm",onClick:()=>{x(""),m("New Folder"),f(!0)},disabled:l||h,title:"New folder",children:(0,U.jsx)(lt,{className:"h-4 w-4"})})]}),l?(0,U.jsx)("div",{className:"flex items-center justify-center h-[200px]",children:(0,U.jsx)(aP,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):d?(0,U.jsx)("div",{className:"p-4 text-sm text-red-500 h-[200px] overflow-y-auto",children:d}):(0,U.jsx)(o8,{className:"h-[200px]",children:(0,U.jsxs)("div",{className:"p-1",children:[h&&(0,U.jsxs)("div",{className:"flex flex-col gap-1 p-2",children:[(0,U.jsxs)("div",{className:"flex items-center gap-2",children:[(0,U.jsx)(le,{className:"h-4 w-4 text-muted-foreground shrink-0"}),(0,U.jsx)("input",{ref:b,value:p,onChange:e=>m(e.target.value),onKeyDown:e=>{"Enter"===e.key?(e.preventDefault(),k()):"Escape"===e.key&&(e.preventDefault(),S())},onBlur:()=>{v||k()},disabled:v,className:"flex-1 bg-background border rounded px-1.5 py-0.5 text-sm outline-none focus:ring-1 focus:ring-ring"}),v&&(0,U.jsx)(aP,{className:"h-4 w-4 animate-spin text-muted-foreground shrink-0"})]}),g&&(0,U.jsx)("span",{className:"text-xs text-red-500 pl-6",children:g})]}),0!==a.length||h?a.map(e=>(0,U.jsxs)("div",{className:`flex items-center gap-2 p-2 rounded-md cursor-pointer hover:bg-muted ${s===e.path?"bg-muted":""}`,children:[(0,U.jsxs)("button",{className:"flex items-center gap-2 flex-1 text-left",onClick:()=>{r(e.path)},children:[(0,U.jsx)(le,{className:"h-4 w-4 text-muted-foreground"}),(0,U.jsx)("span",{className:"text-sm truncate",children:e.name})]}),(0,U.jsx)(a$.Button,{variant:"ghost",size:"sm",onClick:()=>{i(e.path)},title:"Open folder",children:(0,U.jsx)(i2,{className:"h-4 w-4"})})]},e.path)):(0,U.jsx)("div",{className:"p-4 text-sm text-muted-foreground text-center",children:"No directories found"})]})})]}):(0,U.jsx)("div",{className:"text-sm text-muted-foreground p-4 text-center border rounded-md",children:"Select a remote server to browse directories"})}function ln(e,r){return`${e} ${r}${1===e?"":"s"}`}function li(e){if(!e)return"";let r=new Date(e.includes("T")||e.endsWith("Z")?e:`${e.replace(" ","T")}Z`);return Number.isNaN(r.getTime())?e:r.toLocaleString()}function la({usage:e}){let r=[];return e.workspaces.length>0&&r.push(`${ln(e.workspaces.length,"workspace")}: ${e.workspaces.join(", ")}`),e.schedules.length>0&&r.push(`${ln(e.schedules.length,"schedule")}: ${e.schedules.join(", ")}`),(0,U.jsx)("ul",{className:"list-disc pl-5 text-sm space-y-0.5",children:r.map(e=>(0,U.jsx)("li",{children:e},e))})}function lo({project:e,onSave:r,onCancel:s}){var n;let{remotes:i,refresh:a}=aB(e.id),{config:o}=(0,ow.useAppConfig)(),l=o?.localProjectsEnabled!==!1||!!e.path,[c,d]=(0,V.useState)(e.name),[u,h]=(0,V.useState)(e.path??""),[f,p]=(0,V.useState)(!1),[m,g]=(0,V.useState)(""),[x,v]=(0,V.useState)(null),[y,b]=(0,V.useState)("closed"),[w,_]=(0,V.useState)([]),[S,k]=(0,V.useState)(null),[j,C]=(0,V.useState)(""),[N,E]=(0,V.useState)(null),[D,T]=(0,V.useState)(!1),R=()=>{b("closed"),k(null),C("")};(0,V.useEffect)(()=>{d(e.name),h(e.path??""),g(""),R()},[e.id]);let A=async()=>{let e=await aC.api.selectFolder();e.path&&h(e.path)},M=async()=>{b("pick-server");try{let e=await aC.api.getRemoteServers();_(e)}catch{_([])}},I=async()=>{if(S&&j)try{await aC.api.addProjectRemote(e.id,{remoteServerId:S.id,remotePath:j}),await a(),R()}catch(e){g(e instanceof Error?e.message:"Failed to add remote")}},P=async(r,s)=>{g(""),T(!0);try{await aC.api.removeProjectRemote(e.id,r,s),E(null),await a()}catch(e){e instanceof aC.ProjectRemoteUnlinkError?E("remote-in-use"===e.body.errorCode?{kind:"in-use",body:e.body}:{kind:"unreachable",remoteId:r,body:e.body}):g(e instanceof Error?e.message:"Failed to remove remote")}finally{T(!1)}},F=async r=>{g(""),v(r);try{await aC.api.setProjectRemotePrimary(e.id,r),await a()}catch(e){g(e instanceof Error?e.message:"Failed to set primary remote")}finally{v(null)}},L=u.trim().length>0,O=async()=>{if(!c.trim())return void g("Project name is required");if(!L&&0===i.length)return void g(l?"Project must have at least a local folder or remote server":"Project must have at least one remote server");p(!0),g("");try{let s={};c.trim()!==e.name&&(s.name=c.trim());let n=L?u.trim():null;n!==(e.path??null)&&(s.path=n),await r(e.id,s)}catch(e){g(e instanceof Error?e.message:"Failed to update project")}finally{p(!1)}};return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)("div",{className:"space-y-5 py-2",children:[(0,U.jsxs)("div",{className:"space-y-2",children:[(0,U.jsx)("label",{className:"text-sm font-medium",children:"Project Name"}),(0,U.jsx)(aX,{value:c,onChange:e=>d(e.target.value),placeholder:"My Project"})]}),l&&(0,U.jsxs)("div",{className:"space-y-2",children:[(0,U.jsx)("label",{className:"text-sm font-medium",children:"Local Folder"}),(0,U.jsxs)("div",{className:"flex gap-2",children:[(0,U.jsx)(aX,{value:u,onChange:e=>h(e.target.value),placeholder:"/path/to/project (optional)",className:"flex-1"}),(0,U.jsx)(a$.Button,{variant:"outline",onClick:A,children:(0,U.jsx)(o_,{className:"h-4 w-4"})})]})]}),(0,U.jsxs)("div",{className:"space-y-3",children:[(0,U.jsx)("label",{className:"text-sm font-medium",children:"Remote Servers"}),(0,U.jsxs)("p",{className:"text-xs text-muted-foreground",children:["The primary remote is whose Git the sidebar describes: each workspace's merge status and uncommitted changes, plus the Files and Diff views. Where sessions run is chosen separately, in the session header.",l&&" When a local checkout exists, the sidebar reads it instead."]}),i.length>0&&(0,U.jsx)("div",{className:"space-y-2",children:i.map((e,r)=>(0,U.jsxs)("div",{className:"flex items-center gap-2 rounded-md border p-2 text-sm",children:[(0,U.jsx)(oC,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),(0,U.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,U.jsxs)("div",{className:"flex items-center gap-2",children:[(0,U.jsx)("p",{className:"font-medium truncate",children:e.server_name}),0===r&&(0,U.jsxs)(rG,{variant:"secondary",className:"shrink-0 gap-1",children:[(0,U.jsx)(oN,{className:"h-3 w-3"}),"Primary"]})]}),(0,U.jsx)("p",{className:"text-xs text-muted-foreground font-mono truncate",children:e.remote_path})]}),0!==r&&(0,U.jsxs)(a$.Button,{variant:"outline",size:"sm",className:"h-7 shrink-0",disabled:null!==x,onClick:()=>F(e.id),children:[x===e.id&&(0,U.jsx)(aP,{className:"h-3.5 w-3.5 animate-spin"}),"Set as Primary"]}),(0,U.jsx)(a$.Button,{variant:"ghost",size:"icon-sm",className:"h-7 w-7 shrink-0","aria-label":`Unlink ${e.server_name}`,disabled:D,onClick:()=>P(e.id),children:(0,U.jsx)(ok,{className:"h-3.5 w-3.5 text-muted-foreground"})})]},e.id))}),"closed"===y&&(0,U.jsxs)(a$.Button,{variant:"outline",size:"sm",onClick:M,className:"w-full",children:[(0,U.jsx)(oS,{className:"h-4 w-4 mr-1"}),"Add Remote"]}),"pick-server"===y&&(0,U.jsxs)("div",{className:"rounded-md border p-3 space-y-3",children:[(0,U.jsxs)("div",{className:"flex items-center justify-between",children:[(0,U.jsx)("label",{className:"text-xs font-medium",children:"Select a Remote Server"}),(0,U.jsx)(a$.Button,{variant:"ghost",size:"sm",onClick:R,children:(0,U.jsx)(rD,{className:"h-3.5 w-3.5"})})]}),w.length>0&&(0,U.jsx)("div",{className:"space-y-1",children:w.map(e=>(0,U.jsxs)("button",{className:"flex items-center gap-2 w-full rounded-md p-2 text-sm text-left hover:bg-muted",onClick:()=>{k(e),C(""),b("pick-path")},children:[(0,U.jsx)(oj,{className:"h-4 w-4 text-muted-foreground"}),(0,U.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,U.jsx)("p",{className:"truncate",children:e.name}),(0,U.jsx)("p",{className:"text-xs text-muted-foreground truncate",children:"online"===e.status?"Connected":"Not connected"})]})]},e.id))}),(0,U.jsx)("p",{className:"text-xs text-muted-foreground",children:"Add new servers in Settings → Remote Servers, then connect the remote machine with a connect token."})]}),"pick-path"===y&&S&&(0,U.jsxs)("div",{className:"rounded-md border p-3 space-y-3",children:[(0,U.jsxs)("div",{className:"flex items-center justify-between",children:[(0,U.jsxs)("label",{className:"text-xs font-medium",children:["Select Directory on ",S.name]}),(0,U.jsx)(a$.Button,{variant:"ghost",size:"sm",onClick:R,children:(0,U.jsx)(rD,{className:"h-3.5 w-3.5"})})]}),(0,U.jsx)(ls,{serverId:S.id,onSelect:e=>{C(e)},selectedPath:j}),j&&(0,U.jsxs)("div",{className:"flex items-center justify-between",children:[(0,U.jsxs)("p",{className:"text-xs text-muted-foreground",children:["Selected:"," ",(0,U.jsx)("span",{className:"font-mono",children:j})]}),(0,U.jsx)(a$.Button,{size:"sm",onClick:I,children:"Add"})]})]})]})]}),m&&(0,U.jsx)("p",{className:"text-sm text-red-500",children:m}),(0,U.jsxs)("div",{className:"flex justify-end gap-2 pt-2",children:[s&&(0,U.jsx)(a$.Button,{variant:"outline",onClick:s,children:"Cancel"}),(0,U.jsx)(a$.Button,{onClick:O,disabled:f,children:f?"Saving...":"Save Changes"})]}),(0,U.jsx)(rT,{open:N?.kind==="in-use",onOpenChange:e=>{e||E(null)},children:N?.kind==="in-use"&&(0,U.jsxs)(rP,{className:"sm:max-w-md",children:[(0,U.jsxs)(rF,{children:[(0,U.jsxs)(rO,{children:["Cannot unlink ",N.body.name]}),(0,U.jsxs)(rB,{children:["This project still has the following on ",N.body.name,":"]})]}),(0,U.jsx)(la,{usage:N.body.usage}),(0,U.jsx)("p",{className:"text-sm text-muted-foreground",children:"To unlink it: delete the workspaces on that machine and try again, and move the schedules to another target."}),(0,U.jsx)(rL,{children:(0,U.jsx)(a$.Button,{onClick:()=>E(null),children:"Got it"})})]})}),(0,U.jsx)(rT,{open:N?.kind==="unreachable",onOpenChange:e=>{e||E(null)},children:N?.kind==="unreachable"&&(0,U.jsxs)(rP,{className:"sm:max-w-md",children:[(0,U.jsxs)(rF,{children:[(0,U.jsxs)(rO,{children:["Cannot confirm what is on ",N.body.name]}),(0,U.jsx)(rB,{children:"sync-failed"===(n=N.body).reason?`${n.name} is online, but its workspace list could not be read (timeout or worker error). You can try again later.`:n.tokenRevoked?`${n.name} has no valid connect token and will not come back online.`:n.lastConnectedAt?`${n.name} is offline. Last online ${li(n.lastConnectedAt)}.`:`${n.name} is offline and has never connected.`})]}),N.body.lastKnownUsage?(0,U.jsxs)("div",{className:"space-y-1.5",children:[(0,U.jsxs)("p",{className:"text-sm",children:["As of the last sync on ",li(N.body.lastSyncedAt),", this project had the following on it (may be out of date):"]}),(0,U.jsx)(la,{usage:N.body.lastKnownUsage})]}):(0,U.jsx)("p",{className:"text-sm",children:"This machine's workspaces have never been read successfully."}),(0,U.jsx)("p",{className:"text-sm text-muted-foreground",children:"Unlinking deletes nothing on that machine. This hub loses its references to the workspaces, sessions and schedules there, including session history. Linking the same machine again restores most of them."}),(0,U.jsxs)(rL,{children:[(0,U.jsx)(a$.Button,{variant:"outline",onClick:()=>E(null),disabled:D,children:"Cancel"}),(0,U.jsxs)(a$.Button,{variant:"destructive",disabled:D,onClick:()=>P(N.remoteId,{force:!0}),children:[D&&(0,U.jsx)(aP,{className:"h-3.5 w-3.5 animate-spin"}),"Unlink anyway"]})]})]})})]})}let ll="mx-auto w-full max-w-[1200px] px-5 sm:px-7",lc=(0,e1.cn)("relative rounded-sm border-0 bg-transparent px-2.5 py-2.5 text-[12.5px] font-medium text-muted-foreground shadow-none","transition-colors hover:text-foreground focus-visible:ring-offset-0","data-[state=active]:bg-transparent data-[state=active]:text-foreground data-[state=active]:shadow-none","after:pointer-events-none after:absolute after:inset-x-2 after:-bottom-px after:h-0.5 after:rounded-[1px] after:bg-primary after:opacity-0","data-[state=active]:after:opacity-100");function ld({project:e,waitingCount:r,onOpenProjectChatThread:s,onOpenAgentSession:n,onOpenScheduleRun:i,onRunScheduleAgain:a,onViewAllTasks:o,onOpenTaskInTasks:l,onProjectUpdated:c}){let d=aE(e.id),[u,h]=(0,V.useState)(null),[f,p]=(0,V.useState)(!1);return(0,U.jsxs)(eq,{defaultValue:"home",className:"flex h-full flex-col overflow-hidden",children:[(0,U.jsxs)("div",{className:"min-h-0 flex-1 overflow-y-auto",children:[(0,U.jsxs)("header",{className:"relative overflow-hidden border-b bg-card py-6",children:[(0,U.jsx)("div",{"aria-hidden":"true",className:"pointer-events-none absolute inset-0 opacity-[0.07]",style:{backgroundImage:"radial-gradient(circle at 1px 1px, currentColor 1px, transparent 0)",backgroundSize:"16px 16px",maskImage:"linear-gradient(to bottom right, #000, transparent 62%)",WebkitMaskImage:"linear-gradient(to bottom right, #000, transparent 62%)"}}),(0,U.jsx)("div",{className:(0,e1.cn)("relative",ll),children:(0,U.jsxs)("div",{className:"flex flex-wrap items-start gap-4",children:[(0,U.jsx)("span",{"aria-hidden":"true",className:"relative grid size-13 shrink-0 place-items-center overflow-hidden rounded-xl border bg-secondary font-mono text-[19px] font-semibold tracking-[-0.04em] text-primary shadow-sm after:absolute after:inset-x-0 after:bottom-0 after:h-[3px] after:bg-primary after:opacity-55",children:aT(e.name)}),(0,U.jsxs)("div",{className:"min-w-0 flex-1 basis-[380px]",children:[(0,U.jsxs)("div",{className:"mb-1.5 flex items-center gap-2 font-mono text-[11px] text-muted-foreground/70",children:[(0,U.jsx)("span",{children:"Project"}),(0,U.jsx)("span",{"aria-hidden":"true",children:"·"}),(0,U.jsxs)("span",{children:["created ",new Date(e.created_at).toLocaleDateString()]})]}),(0,U.jsx)("h1",{className:"break-all font-mono text-[25px] font-semibold tracking-[-0.025em]",children:e.name})]})]})})]}),(0,U.jsx)("div",{className:"sticky top-0 z-10 border-b bg-card",children:(0,U.jsx)("div",{className:ll,children:(0,U.jsxs)(e2,{className:"h-auto justify-start gap-0.5 rounded-none bg-transparent p-0",children:[(0,U.jsx)(e5,{value:"home",className:lc,children:"Home"}),(0,U.jsx)(e5,{value:"settings",className:lc,children:"Settings"})]})})}),(0,U.jsx)(e3,{value:"home",className:(0,e1.cn)("mt-0 py-5 pb-15",ll),children:(0,U.jsx)(ob,{projectId:e.id,waitingCount:r,onCreateThread:s?d:void 0,onOpenThread:s,onOpenAgentSession:n,onOpenScheduleRun:i,onRunScheduleAgain:a,onOpenTask:e=>{h(e),p(!0)},onViewAllTasks:o})}),(0,U.jsx)(e3,{value:"settings",className:(0,e1.cn)("mt-0 py-5 pb-15",ll),children:(0,U.jsx)(lo,{project:e,onSave:c})})]}),(0,U.jsx)(aj,{task:u,open:f,onOpenChange:p,onOpenInTasks:l})]})}var lu=e.i(553154);let lh=(0,rE.default)("panel-right-close",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}],["path",{d:"m8 9 3 3-3 3",key:"12hl5m"}]]),lf=(0,rE.default)("panel-right-open",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}],["path",{d:"m10 15-3-3 3-3",key:"1pgupc"}]]);var lp=e.i(212142),lp=lp;function lm({...e}){return(0,U.jsx)(lp.Root,{"data-slot":"sheet",...e})}function lg({...e}){return(0,U.jsx)(lp.Portal,{"data-slot":"sheet-portal",...e})}function lx({className:e,...r}){return(0,U.jsx)(lp.Overlay,{"data-slot":"sheet-overlay",className:(0,e1.cn)("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",e),...r})}function lv({className:e,children:r,side:s="right",showCloseButton:n=!0,...i}){return(0,U.jsxs)(lg,{children:[(0,U.jsx)(lx,{}),(0,U.jsxs)(lp.Content,{"data-slot":"sheet-content",className:(0,e1.cn)("bg-background data-[state=open]:animate-in data-[state=closed]:animate-out fixed z-50 flex flex-col gap-4 shadow-lg transition ease-in-out data-[state=closed]:duration-300 data-[state=open]:duration-500","right"===s&&"data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right inset-y-0 right-0 h-full w-3/4 border-l sm:max-w-sm","left"===s&&"data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left inset-y-0 left-0 h-full w-3/4 border-r sm:max-w-sm","top"===s&&"data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top inset-x-0 top-0 h-auto border-b","bottom"===s&&"data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom inset-x-0 bottom-0 h-auto border-t",e),...i,children:[r,n&&(0,U.jsxs)(lp.Close,{className:"ring-offset-background focus:ring-ring data-[state=open]:bg-secondary absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none",children:[(0,U.jsx)(rD,{className:"size-4"}),(0,U.jsx)("span",{className:"sr-only",children:"Close"})]})]})]})}function ly({className:e,...r}){return(0,U.jsx)("div",{"data-slot":"sheet-header",className:(0,e1.cn)("flex flex-col gap-1.5 p-4",e),...r})}function lb({className:e,...r}){return(0,U.jsx)(lp.Title,{"data-slot":"sheet-title",className:(0,e1.cn)("text-foreground font-semibold",e),...r})}function lw({className:e,...r}){return(0,U.jsx)(lp.Description,{"data-slot":"sheet-description",className:(0,e1.cn)("text-muted-foreground text-sm",e),...r})}let l_=()=>({thread:null,messages:[],hasEarlierMessages:!1,earliestSequence:null,status:"idle",activeTurnId:null,pendingApprovalIds:[],queueLength:0,contextRefs:[]});function lS(e,r){for(e.delete(r.identity.threadId),e.set(r.identity.threadId,r);e.size>5;){let r=e.keys().next().value;if(void 0===r)break;e.delete(r)}}function lk(e,r){let s=new Map(e.map(e=>[e.id,e]));for(let e of r)s.set(e.id,e);return[...s.values()].sort((e,r)=>e.sequence-r.sequence)}function lj(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function lC(e){return lj(e)&&"string"==typeof e.id&&"string"==typeof e.thread_id&&"number"==typeof e.sequence&&"string"==typeof e.type&&"string"==typeof e.content&&"string"==typeof e.created_at}function lN(e){return!!lj(e)&&"string"==typeof e.thread_id&&!!["task","workspace","agent_session","schedule","schedule_run"].includes(String(e.entity_type))&&"string"==typeof e.entity_id&&"string"==typeof e.last_referenced_at&&"boolean"==typeof e.deleted&&(null===e.navigation||!e.deleted&&!!lj(e.navigation)&&e.navigation.kind===e.entity_type&&"string"==typeof e.navigation.label&&("task"===e.navigation.kind?"string"==typeof e.navigation.taskId:"workspace"===e.navigation.kind?"string"==typeof e.navigation.target&&(null===e.navigation.branch||"string"==typeof e.navigation.branch):"agent_session"===e.navigation.kind?"string"==typeof e.navigation.sessionId&&"string"==typeof e.navigation.target&&(null===e.navigation.branch||"string"==typeof e.navigation.branch):"schedule"===e.navigation.kind?"string"==typeof e.navigation.scheduleId:"schedule_run"===e.navigation.kind&&"string"==typeof e.navigation.scheduleId&&"string"==typeof e.navigation.runId))}function lE(e){return"idle"===e||"running"===e||"queued"===e}let lD=(0,rE.default)("ellipsis",[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}]]),lT=(0,rE.default)("pencil",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]]);var lR="AlertDialog",[lA,lM]=es(lR,[t7]),lI=t7(),lP=e=>{let{__scopeAlertDialog:r,...s}=e,n=lI(r);return(0,U.jsx)(re,{...n,...s,modal:!0})};lP.displayName=lR,V.forwardRef((e,r)=>{let{__scopeAlertDialog:s,...n}=e,i=lI(s);return(0,U.jsx)(rr,{...i,...n,ref:r})}).displayName="AlertDialogTrigger";var lF=e=>{let{__scopeAlertDialog:r,...s}=e,n=lI(r);return(0,U.jsx)(ra,{...n,...s})};lF.displayName="AlertDialogPortal";var lL=V.forwardRef((e,r)=>{let{__scopeAlertDialog:s,...n}=e,i=lI(s);return(0,U.jsx)(rl,{...i,...n,ref:r})});lL.displayName="AlertDialogOverlay";var lO="AlertDialogContent",[lB,lz]=lA(lO),l$=(0,ei.createSlottable)("AlertDialogContent"),lW=V.forwardRef((e,r)=>{let{__scopeAlertDialog:s,children:n,...i}=e,a=lI(s),o=V.useRef(null),l=(0,en.useComposedRefs)(r,o),c=V.useRef(null);return(0,U.jsx)(rk,{contentName:lO,titleName:lH,docsSlug:"alert-dialog",children:(0,U.jsx)(lB,{scope:s,cancelRef:c,children:(0,U.jsxs)(rh,{role:"alertdialog",...a,...i,ref:l,onOpenAutoFocus:er(i.onOpenAutoFocus,e=>{e.preventDefault(),c.current?.focus({preventScroll:!0})}),onPointerDownOutside:e=>e.preventDefault(),onInteractOutside:e=>e.preventDefault(),children:[(0,U.jsx)(l$,{children:n}),(0,U.jsx)(lG,{contentRef:o})]})})})});lW.displayName=lO;var lH="AlertDialogTitle",lU=V.forwardRef((e,r)=>{let{__scopeAlertDialog:s,...n}=e,i=lI(s);return(0,U.jsx)(rx,{...i,...n,ref:r})});lU.displayName=lH;var lV="AlertDialogDescription",lq=V.forwardRef((e,r)=>{let{__scopeAlertDialog:s,...n}=e,i=lI(s);return(0,U.jsx)(ry,{...i,...n,ref:r})});lq.displayName=lV;var lK=V.forwardRef((e,r)=>{let{__scopeAlertDialog:s,...n}=e,i=lI(s);return(0,U.jsx)(rw,{...i,...n,ref:r})});lK.displayName="AlertDialogAction";var lX="AlertDialogCancel",lY=V.forwardRef((e,r)=>{let{__scopeAlertDialog:s,...n}=e,{cancelRef:i}=lz(lX,s),a=lI(s),o=(0,en.useComposedRefs)(r,i);return(0,U.jsx)(rw,{...a,...n,ref:o})});lY.displayName=lX;var lG=({contentRef:e})=>{let r=`\`${lO}\` requires a description for the component to be accessible for screen reader users.
6
+
7
+ You can add a description to the \`${lO}\` by passing a \`${lV}\` component as a child, which also benefits sighted users by adding visible context to the dialog.
8
+
9
+ Alternatively, you can use your own component as a description by assigning it an \`id\` and passing the same value to the \`aria-describedby\` prop in \`${lO}\`. If the description is confusing or duplicative for sighted users, you can use the \`@radix-ui/react-visually-hidden\` primitive as a wrapper around your description component.
10
+
11
+ For more information, see https://radix-ui.com/primitives/docs/components/alert-dialog`;return V.useEffect(()=>{document.getElementById(e.current?.getAttribute("aria-describedby"))||console.warn(r)},[r,e]),null};function lJ({...e}){return(0,U.jsx)(lP,{"data-slot":"alert-dialog",...e})}function lZ({...e}){return(0,U.jsx)(lF,{"data-slot":"alert-dialog-portal",...e})}function lQ({className:e,...r}){return(0,U.jsx)(lL,{"data-slot":"alert-dialog-overlay",className:(0,e1.cn)("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",e),...r})}function l0({className:e,...r}){return(0,U.jsxs)(lZ,{children:[(0,U.jsx)(lQ,{}),(0,U.jsx)(lW,{"data-slot":"alert-dialog-content",className:(0,e1.cn)("bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 sm:max-w-lg",e),...r})]})}function l1({className:e,...r}){return(0,U.jsx)("div",{"data-slot":"alert-dialog-header",className:(0,e1.cn)("flex flex-col gap-2 text-center sm:text-left",e),...r})}function l2({className:e,...r}){return(0,U.jsx)("div",{"data-slot":"alert-dialog-footer",className:(0,e1.cn)("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",e),...r})}function l5({className:e,...r}){return(0,U.jsx)(lU,{"data-slot":"alert-dialog-title",className:(0,e1.cn)("text-lg font-semibold",e),...r})}function l3({className:e,...r}){return(0,U.jsx)(lq,{"data-slot":"alert-dialog-description",className:(0,e1.cn)("text-muted-foreground text-sm",e),...r})}function l4({className:e,...r}){return(0,U.jsx)(lK,{className:(0,e1.cn)((0,a$.buttonVariants)(),e),...r})}function l6({className:e,...r}){return(0,U.jsx)(lY,{className:(0,e1.cn)((0,a$.buttonVariants)({variant:"outline"}),e),...r})}let l7={task:"Task",workspace:"Workspace",agent_session:"Agent session",schedule:"Schedule",schedule_run:"Schedule run"};function l8({projectId:e,currentThreadId:r,threads:s,contextRefs:n,onNewThread:i,onSelectThread:a,onRenameThread:o,onArchiveThread:l,onDeleteThread:c,onOpenContext:d,newThreadPending:u=!1,className:h}){let[f,p]=(0,V.useState)(!0),[m,g]=(0,V.useState)(!0),[x,v]=(0,V.useState)(!1),[y,b]=(0,V.useState)(null),[w,_]=(0,V.useState)(null),[S,k]=(0,V.useState)(""),[j,C]=(0,V.useState)(null),[N,E]=(0,V.useState)(null),[D,T]=(0,V.useState)(new Set),[R,A]=(0,V.useState)(null),M=(0,V.useRef)(new Set),I=(0,V.useRef)(null),P=s.filter(e=>null===e.archived_at),F=!!w&&D.has(`rename:${w.id}`),L=!!N&&D.has(`delete:${N.id}`),O=!!j&&D.has(`archive:${j.id}`);(0,V.useEffect)(()=>{if(!y)return;I.current?.querySelector('[role="menuitem"]')?.focus();let e=e=>{"Escape"===e.key&&b(null)},r=e=>{I.current?.contains(e.target)||b(null)};return document.addEventListener("keydown",e),document.addEventListener("pointerdown",r),()=>{document.removeEventListener("keydown",e),document.removeEventListener("pointerdown",r)}},[y]);let B=async(e,r,s)=>{if(!M.current.has(e)){M.current.add(e),T(r=>new Set(r).add(e)),A(null);try{await r(),s()}catch(e){A(e instanceof Error?e.message:"Project Chat action failed")}finally{M.current.delete(e),T(r=>{let s=new Set(r);return s.delete(e),s})}}};return(0,U.jsxs)("aside",{"data-testid":"project-chat-rail","data-project-chat-column":!0,className:(0,e1.cn)("flex h-full w-[300px] shrink-0 flex-col overflow-hidden border-l border-border bg-muted/10",h),"aria-label":"Project Chat threads and context",children:[(0,U.jsxs)("section",{className:"flex min-h-0 flex-col border-b border-border/70",children:[(0,U.jsxs)("div",{className:"flex h-11 shrink-0 items-center gap-1 px-3",children:[(0,U.jsxs)("button",{type:"button",className:"flex min-w-0 flex-1 items-center gap-1.5 rounded px-1 py-1 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",onClick:()=>p(e=>!e),"aria-expanded":f,children:[f?(0,U.jsx)(aa,{className:"size-4"}):(0,U.jsx)(i2,{className:"size-4"}),(0,U.jsx)("h2",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:"Chat Threads"})]}),(0,U.jsx)(a$.Button,{type:"button",variant:"ghost",size:"icon-sm","aria-label":"New thread",disabled:u,onClick:()=>void i(),children:(0,U.jsx)(oS,{className:"size-4","aria-hidden":"true"})})]}),f?(0,U.jsxs)("div",{className:"space-y-1 px-2 pb-3",children:[P.slice(0,5).map(e=>{let s=aG(e),n=e.id===r;return(0,U.jsxs)("div",{"data-testid":"thread-row",className:(0,e1.cn)("relative flex items-center rounded-md",n?"bg-accent":"hover:bg-muted"),children:[(0,U.jsx)("button",{type:"button","aria-label":`Open thread: ${s}`,"aria-current":n?"page":void 0,onClick:()=>a(e.id),className:"min-w-0 flex-1 truncate px-2 py-2 text-left text-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:s}),(0,U.jsx)(a$.Button,{type:"button",variant:"ghost",size:"icon-sm","aria-label":`Thread actions: ${s}`,"aria-expanded":y===e.id,"aria-haspopup":"menu","aria-controls":y===e.id?`thread-actions-${e.id}`:void 0,onClick:()=>b(r=>r===e.id?null:e.id),children:(0,U.jsx)(lD,{className:"size-4","aria-hidden":"true"})}),y===e.id?(0,U.jsxs)("div",{ref:I,id:`thread-actions-${e.id}`,role:"menu","aria-label":`Actions for ${s}`,className:"absolute right-1 top-9 z-20 w-40 rounded-md border bg-popover p-1 text-popover-foreground shadow-md",children:[(0,U.jsxs)("button",{type:"button",role:"menuitem",className:"flex w-full items-center gap-2 rounded px-2 py-1.5 text-sm hover:bg-muted",onClick:()=>{b(null),A(null),_(e),k(s)},children:[(0,U.jsx)(lT,{className:"size-3.5"})," Rename thread"]}),(0,U.jsxs)("button",{type:"button",role:"menuitem",className:"flex w-full items-center gap-2 rounded px-2 py-1.5 text-sm hover:bg-muted",onClick:()=>{b(null),A(null),C(e)},children:[(0,U.jsx)(aH,{className:"size-3.5"})," Archive thread"]}),(0,U.jsxs)("button",{type:"button",role:"menuitem",className:"flex w-full items-center gap-2 rounded px-2 py-1.5 text-sm text-destructive hover:bg-destructive/10",onClick:()=>{b(null),A(null),E(e)},children:[(0,U.jsx)(ok,{className:"size-3.5"})," Delete thread"]})]}):null]},e.id)}),(0,U.jsx)(a$.Button,{type:"button",variant:"ghost",size:"sm","aria-label":"View all threads",className:"w-full",onClick:()=>v(!0),children:"View all"})]}):null]}),(0,U.jsxs)("section",{className:"flex min-h-0 flex-1 flex-col",children:[(0,U.jsxs)("button",{type:"button",className:"flex h-11 shrink-0 items-center gap-1.5 px-4 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring",onClick:()=>g(e=>!e),"aria-expanded":m,children:[m?(0,U.jsx)(aa,{className:"size-4"}):(0,U.jsx)(i2,{className:"size-4"}),(0,U.jsx)("h2",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:"Context"})]}),m?(0,U.jsx)("div",{className:"min-h-0 flex-1 space-y-1 overflow-y-auto px-2 pb-3",children:0===n.length?(0,U.jsx)("p",{className:"px-2 py-4 text-xs text-muted-foreground",children:"Referenced project items appear here."}):n.map(e=>{let r=l7[e.entity_type],s=!e.deleted&&(!e.navigation||!d),n=e.deleted||s,i=e.navigation?"Navigation is unavailable in this view.":"Navigation details are unavailable; refresh the thread and try again.";return(0,U.jsxs)("button",{type:"button",disabled:n,"aria-label":e.deleted?`Deleted ${r.toLocaleLowerCase()}`:s?`Unavailable ${r.toLocaleLowerCase()}`:`Open ${r}: ${e.navigation.label}`,title:s?i:void 0,onClick:()=>d?.(e),className:"flex w-full flex-col rounded-md px-2 py-2 text-left hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-55",children:[(0,U.jsx)("span",{className:"text-sm",children:e.deleted?`Deleted ${r.toLocaleLowerCase()}`:s?`Unavailable ${r.toLocaleLowerCase()}`:`${r} \xb7 ${e.navigation.label}`}),e.deleted?(0,U.jsx)("span",{className:"text-xs text-muted-foreground",children:"Deleted"}):null,s?(0,U.jsx)("span",{className:"text-xs text-muted-foreground",children:i}):null]},`${e.entity_type}:${e.entity_id}`)})}):null]}),(0,U.jsx)(aJ,{open:x,onOpenChange:v,projectId:e,onSelectThread:a}),(0,U.jsx)(rT,{open:null!==w,onOpenChange:e=>{e||F||(_(null),A(null))},children:(0,U.jsxs)(rP,{children:[(0,U.jsxs)(rF,{children:[(0,U.jsx)(rO,{children:"Rename Project Chat thread"}),(0,U.jsx)(rB,{children:"Give this conversation a concise project-level title."})]}),(0,U.jsx)(aX,{autoFocus:!0,"aria-label":"Thread title",value:S,onChange:e=>k(e.target.value),onKeyDown:e=>{"Enter"===e.key&&w&&S.trim()&&B(`rename:${w.id}`,()=>o(w.id,S.trim()),()=>_(null))}}),R?(0,U.jsx)("div",{role:"alert",className:"rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive",children:R}):null,(0,U.jsxs)(rL,{children:[(0,U.jsx)(a$.Button,{type:"button",variant:"outline",disabled:F,onClick:()=>{_(null),A(null)},children:"Cancel"}),(0,U.jsx)(a$.Button,{type:"button",disabled:!S.trim()||F,onClick:()=>{w&&B(`rename:${w.id}`,()=>o(w.id,S.trim()),()=>_(null))},children:"Save title"})]})]})}),(0,U.jsx)(lJ,{open:null!==N,onOpenChange:e=>{e||L||(E(null),A(null))},children:(0,U.jsxs)(l0,{children:[(0,U.jsxs)(l1,{children:[(0,U.jsx)(l5,{children:"Delete this Project Chat thread?"}),(0,U.jsx)(l3,{children:"This permanently removes the thread and its persisted conversation."})]}),R?(0,U.jsx)("div",{role:"alert",className:"rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive",children:R}):null,(0,U.jsxs)(l2,{children:[(0,U.jsx)(l6,{disabled:L,children:"Cancel"}),(0,U.jsx)(l4,{className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",disabled:L,onClick:e=>{e.preventDefault(),N&&B(`delete:${N.id}`,()=>c(N.id),()=>E(null))},children:"Confirm delete"})]})]})}),(0,U.jsx)(lJ,{open:null!==j,onOpenChange:e=>{e||O||(C(null),A(null))},children:(0,U.jsxs)(l0,{children:[(0,U.jsxs)(l1,{children:[(0,U.jsx)(l5,{children:"Archive this Project Chat thread?"}),(0,U.jsx)(l3,{children:"The conversation leaves recent selectors but remains available in thread history."})]}),R?(0,U.jsx)("div",{role:"alert",className:"rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive",children:R}):null,(0,U.jsxs)(l2,{children:[(0,U.jsx)(l6,{disabled:O,children:"Cancel"}),(0,U.jsx)(l4,{disabled:O,onClick:e=>{e.preventDefault(),j&&B(`archive:${j.id}`,()=>l(j.id),()=>C(null))},children:"Confirm archive"})]})]})})]})}var l9=e.i(113862);let ce=(0,rE.default)("square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);var ct="horizontal",cr=["horizontal","vertical"],cs=V.forwardRef((e,r)=>{var s;let{decorative:n,orientation:i=ct,...a}=e,o=(s=i,cr.includes(s))?i:ct;return(0,U.jsx)(em.div,{"data-orientation":o,...n?{role:"none"}:{"aria-orientation":"vertical"===o?o:void 0,role:"separator"},...a,ref:r})});cs.displayName="Separator",e.s(["Root",()=>cs,"Separator",()=>cs],691102),e.i(691102),(0,rX.cva)("flex w-fit items-stretch [&>*]:focus-visible:z-10 [&>*]:focus-visible:relative [&>[data-slot=select-trigger]:not([class*='w-'])]:w-fit [&>input]:flex-1 has-[select[aria-hidden=true]:last-child]:[&>[data-slot=select-trigger]:last-of-type]:rounded-r-md has-[>[data-slot=button-group]]:gap-2",{variants:{orientation:{horizontal:"[&>*:not(:first-child)]:rounded-l-none [&>*:not(:first-child)]:border-l-0 [&>*:not(:last-child)]:rounded-r-none",vertical:"flex-col [&>*:not(:first-child)]:rounded-t-none [&>*:not(:first-child)]:border-t-0 [&>*:not(:last-child)]:rounded-b-none"}},defaultVariants:{orientation:"horizontal"}});var cn=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),ci=V.forwardRef((e,r)=>(0,U.jsx)(em.span,{...e,ref:r,style:{...cn,...e.style}}));ci.displayName="VisuallyHidden";var[ca,co]=es("Tooltip",[nx]),cl=nx(),cc="TooltipProvider",cd="tooltip.open",[cu,ch]=ca(cc),cf=e=>{let{__scopeTooltip:r,delayDuration:s=700,skipDelayDuration:n=300,disableHoverableContent:i=!1,children:a}=e,o=V.useRef(!0),l=V.useRef(!1),c=V.useRef(0);return V.useEffect(()=>{let e=c.current;return()=>window.clearTimeout(e)},[]),(0,U.jsx)(cu,{scope:r,isOpenDelayedRef:o,delayDuration:s,onOpen:V.useCallback(()=>{window.clearTimeout(c.current),o.current=!1},[]),onClose:V.useCallback(()=>{window.clearTimeout(c.current),c.current=window.setTimeout(()=>o.current=!0,n)},[n]),isPointerInTransitRef:l,onPointerInTransitChange:V.useCallback(e=>{l.current=e},[]),disableHoverableContent:i,children:a})};cf.displayName=cc;var cp="Tooltip",[cm,cg]=ca(cp),cx=e=>{let{__scopeTooltip:r,children:s,open:n,defaultOpen:i,onOpenChange:a,disableHoverableContent:o,delayDuration:l}=e,c=ch(cp,e.__scopeTooltip),d=cl(r),[u,h]=V.useState(null),f=ef(),p=V.useRef(0),m=o??c.disableHoverableContent,g=l??c.delayDuration,x=V.useRef(!1),[v,y]=ey({prop:n,defaultProp:i??!1,onChange:e=>{e?(c.onOpen(),document.dispatchEvent(new CustomEvent(cd))):c.onClose(),a?.(e)},caller:cp}),b=V.useMemo(()=>v?x.current?"delayed-open":"instant-open":"closed",[v]),w=V.useCallback(()=>{window.clearTimeout(p.current),p.current=0,x.current=!1,y(!0)},[y]),_=V.useCallback(()=>{window.clearTimeout(p.current),p.current=0,y(!1)},[y]),S=V.useCallback(()=>{window.clearTimeout(p.current),p.current=window.setTimeout(()=>{x.current=!0,y(!0),p.current=0},g)},[g,y]);return V.useEffect(()=>()=>{p.current&&(window.clearTimeout(p.current),p.current=0)},[]),(0,U.jsx)(nb,{...d,children:(0,U.jsx)(cm,{scope:r,contentId:f,open:v,stateAttribute:b,trigger:u,onTriggerChange:h,onTriggerEnter:V.useCallback(()=>{c.isOpenDelayedRef.current?S():w()},[c.isOpenDelayedRef,S,w]),onTriggerLeave:V.useCallback(()=>{m?_():(window.clearTimeout(p.current),p.current=0)},[_,m]),onOpen:w,onClose:_,disableHoverableContent:m,children:s})})};cx.displayName=cp;var cv="TooltipTrigger",cy=V.forwardRef((e,r)=>{let{__scopeTooltip:s,...n}=e,i=cg(cv,s),a=ch(cv,s),o=cl(s),l=V.useRef(null),c=(0,en.useComposedRefs)(r,l,i.onTriggerChange),d=V.useRef(!1),u=V.useRef(!1),h=V.useCallback(()=>d.current=!1,[]);return V.useEffect(()=>()=>document.removeEventListener("pointerup",h),[h]),(0,U.jsx)(n_,{asChild:!0,...o,children:(0,U.jsx)(em.button,{"aria-describedby":i.open?i.contentId:void 0,"data-state":i.stateAttribute,...n,ref:c,onPointerMove:er(e.onPointerMove,e=>{"touch"!==e.pointerType&&(u.current||a.isPointerInTransitRef.current||(i.onTriggerEnter(),u.current=!0))}),onPointerLeave:er(e.onPointerLeave,()=>{i.onTriggerLeave(),u.current=!1}),onPointerDown:er(e.onPointerDown,()=>{i.open&&i.onClose(),d.current=!0,document.addEventListener("pointerup",h,{once:!0})}),onFocus:er(e.onFocus,()=>{d.current||i.onOpen()}),onBlur:er(e.onBlur,i.onClose),onClick:er(e.onClick,i.onClose)})})});cy.displayName=cv;var cb="TooltipPortal",[cw,c_]=ca(cb,{forceMount:void 0}),cS=e=>{let{__scopeTooltip:r,forceMount:s,children:n,container:i}=e,a=cg(cb,r);return(0,U.jsx)(cw,{scope:r,forceMount:s,children:(0,U.jsx)(eO,{present:s||a.open,children:(0,U.jsx)(tc,{asChild:!0,container:i,children:n})})})};cS.displayName=cb;var ck="TooltipContent",cj=V.forwardRef((e,r)=>{let s=c_(ck,e.__scopeTooltip),{forceMount:n=s.forceMount,side:i="top",...a}=e,o=cg(ck,e.__scopeTooltip);return(0,U.jsx)(eO,{present:n||o.open,children:o.disableHoverableContent?(0,U.jsx)(cT,{side:i,...a,ref:r}):(0,U.jsx)(cC,{side:i,...a,ref:r})})}),cC=V.forwardRef((e,r)=>{let s=cg(ck,e.__scopeTooltip),n=ch(ck,e.__scopeTooltip),i=V.useRef(null),a=(0,en.useComposedRefs)(r,i),[o,l]=V.useState(null),{trigger:c,onClose:d}=s,u=i.current,{onPointerInTransitChange:h}=n,f=V.useCallback(()=>{l(null),h(!1)},[h]),p=V.useCallback((e,r)=>{let s,n=e.currentTarget,i={x:e.clientX,y:e.clientY},a=function(e,r){let s=Math.abs(r.top-e.y),n=Math.abs(r.bottom-e.y),i=Math.abs(r.right-e.x),a=Math.abs(r.left-e.x);switch(Math.min(s,n,i,a)){case a:return"left";case i:return"right";case s:return"top";case n:return"bottom";default:throw Error("unreachable")}}(i,n.getBoundingClientRect());l(((s=[...function(e,r,s=5){let n=[];switch(r){case"top":n.push({x:e.x-s,y:e.y+s},{x:e.x+s,y:e.y+s});break;case"bottom":n.push({x:e.x-s,y:e.y-s},{x:e.x+s,y:e.y-s});break;case"left":n.push({x:e.x+s,y:e.y-s},{x:e.x+s,y:e.y+s});break;case"right":n.push({x:e.x-s,y:e.y-s},{x:e.x-s,y:e.y+s})}return n}(i,a),...function(e){let{top:r,right:s,bottom:n,left:i}=e;return[{x:i,y:r},{x:s,y:r},{x:s,y:n},{x:i,y:n}]}(r.getBoundingClientRect())].slice()).sort((e,r)=>e.x<r.x?-1:e.x>r.x?1:e.y<r.y?-1:1*!!(e.y>r.y)),function(e){if(e.length<=1)return e.slice();let r=[];for(let s=0;s<e.length;s++){let n=e[s];for(;r.length>=2;){let e=r[r.length-1],s=r[r.length-2];if((e.x-s.x)*(n.y-s.y)>=(e.y-s.y)*(n.x-s.x))r.pop();else break}r.push(n)}r.pop();let s=[];for(let r=e.length-1;r>=0;r--){let n=e[r];for(;s.length>=2;){let e=s[s.length-1],r=s[s.length-2];if((e.x-r.x)*(n.y-r.y)>=(e.y-r.y)*(n.x-r.x))s.pop();else break}s.push(n)}return(s.pop(),1===r.length&&1===s.length&&r[0].x===s[0].x&&r[0].y===s[0].y)?r:r.concat(s)}(s))),h(!0)},[h]);return V.useEffect(()=>()=>f(),[f]),V.useEffect(()=>{if(c&&u){let e=e=>p(e,u),r=e=>p(e,c);return c.addEventListener("pointerleave",e),u.addEventListener("pointerleave",r),()=>{c.removeEventListener("pointerleave",e),u.removeEventListener("pointerleave",r)}}},[c,u,p,f]),V.useEffect(()=>{if(o){let e=e=>{let r=e.target,s={x:e.clientX,y:e.clientY},n=c?.contains(r)||u?.contains(r),i=!function(e,r){let{x:s,y:n}=e,i=!1;for(let e=0,a=r.length-1;e<r.length;a=e++){let o=r[e],l=r[a],c=o.x,d=o.y,u=l.x,h=l.y;d>n!=h>n&&s<(u-c)*(n-d)/(h-d)+c&&(i=!i)}return i}(s,o);n?f():i&&(f(),d())};return document.addEventListener("pointermove",e),()=>document.removeEventListener("pointermove",e)}},[c,u,o,d,f]),(0,U.jsx)(cT,{...e,ref:a})}),[cN,cE]=ca(cp,{isInside:!1}),cD=(0,ei.createSlottable)("TooltipContent"),cT=V.forwardRef((e,r)=>{let{__scopeTooltip:s,children:n,"aria-label":i,onEscapeKeyDown:a,onPointerDownOutside:o,...l}=e,c=cg(ck,s),d=cl(s),{onClose:u}=c;return V.useEffect(()=>(document.addEventListener(cd,u),()=>document.removeEventListener(cd,u)),[u]),V.useEffect(()=>{if(c.trigger){let e=e=>{let r=e.target;r?.contains(c.trigger)&&u()};return window.addEventListener("scroll",e,{capture:!0}),()=>window.removeEventListener("scroll",e,{capture:!0})}},[c.trigger,u]),(0,U.jsx)(e7,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:e=>e.preventDefault(),onDismiss:u,children:(0,U.jsxs)(nC,{"data-state":c.stateAttribute,...d,...l,ref:r,style:{...l.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[(0,U.jsx)(cD,{children:n}),(0,U.jsx)(cN,{scope:s,isInside:!0,children:(0,U.jsx)(ci,{id:c.contentId,role:"tooltip",children:i||n})})]})})});cj.displayName=ck;var cR="TooltipArrow",cA=V.forwardRef((e,r)=>{let{__scopeTooltip:s,...n}=e,i=cl(s);return cE(cR,s).isInside?null:(0,U.jsx)(nD,{...i,...n,ref:r})});cA.displayName=cR,e.s(["Arrow",()=>cA,"Content",()=>cj,"Portal",()=>cS,"Provider",()=>cf,"Root",()=>cx,"Tooltip",()=>cx,"TooltipArrow",()=>cA,"TooltipContent",()=>cj,"TooltipPortal",()=>cS,"TooltipProvider",()=>cf,"TooltipTrigger",()=>cy,"Trigger",()=>cy,"createTooltipScope",()=>co],517964);var cM=e.i(517964),cM=cM;function cI({delayDuration:e=0,...r}){return(0,U.jsx)(cM.Provider,{"data-slot":"tooltip-provider",delayDuration:e,...r})}function cP({...e}){return(0,U.jsx)(cM.Root,{"data-slot":"tooltip",...e})}function cF({...e}){return(0,U.jsx)(cM.Trigger,{"data-slot":"tooltip-trigger",...e})}function cL({className:e,sideOffset:r=0,children:s,...n}){return(0,U.jsx)(cM.Portal,{children:(0,U.jsxs)(cM.Content,{"data-slot":"tooltip-content",sideOffset:r,className:(0,e1.cn)("bg-foreground text-background animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md px-3 py-1.5 text-xs text-balance",e),...n,children:[s,(0,U.jsx)(cM.Arrow,{className:"bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]"})]})})}(0,rE.default)("chevron-left",[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]]);var r0=rQ;let cO=({className:e,from:r,...s})=>(0,U.jsx)("div",{className:(0,e1.cn)("group flex w-full max-w-[95%] flex-col gap-2","user"===r?"is-user ml-auto justify-end":"is-assistant",e),...s}),cB=({children:e,className:r,...s})=>(0,U.jsx)("div",{className:(0,e1.cn)("is-user:dark flex w-fit max-w-full min-w-0 flex-col gap-2 overflow-hidden text-sm","group-[.is-user]:ml-auto group-[.is-user]:rounded-lg group-[.is-user]:bg-secondary group-[.is-user]:px-4 group-[.is-user]:py-3 group-[.is-user]:text-foreground","group-[.is-assistant]:text-foreground",r),...s,children:e}),cz=(0,V.memo)(({className:e,...r})=>(0,U.jsx)(r0.i,{className:(0,e1.cn)("size-full [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",e),...r}),(e,r)=>e.children===r.children);cz.displayName="MessageResponse";let c$=(0,rE.default)("arrow-down",[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]]),cW={damping:.7,stiffness:.05,mass:1.25},cH=1e3/60,cU=!1;function cV(e,r){let s=(0,V.useCallback)(r=>(s.current=r,e(r)),r);return s}globalThis.document?.addEventListener("mousedown",()=>{cU=!0}),globalThis.document?.addEventListener("mouseup",()=>{cU=!1}),globalThis.document?.addEventListener("click",()=>{cU=!1});let cq=new Map;function cK(...e){let r={...cW},s=!1;for(let n of e){if("instant"===n){s=!0;continue}"object"==typeof n&&(s=!1,r.damping=n.damping??r.damping,r.stiffness=n.stiffness??r.stiffness,r.mass=n.mass??r.mass)}let n=JSON.stringify(r);return cq.has(n)||cq.set(n,Object.freeze(r)),s?"instant":cq.get(n)}let cX=(0,V.createContext)(null),cY="undefined"!=typeof window?V.useLayoutEffect:V.useEffect;function cG({instance:e,children:r,resize:s,initial:n,mass:i,damping:a,stiffness:o,targetScrollTop:l,contextRef:c,...d}){let u=(0,V.useRef)(null),h=((e={})=>{let[r,s]=(0,V.useState)(!1),[n,i]=(0,V.useState)(!1!==e.initial),[a,o]=(0,V.useState)(!1),l=(0,V.useRef)(null);l.current=e;let c=(0,V.useCallback)(()=>{if(!cU)return!1;let e=window.getSelection();if(!e||!e.rangeCount)return!1;let r=e.getRangeAt(0);return r.commonAncestorContainer.contains(x.current)||x.current?.contains(r.commonAncestorContainer)},[]),d=(0,V.useCallback)(e=>{h.isAtBottom=e,i(e)},[]),u=(0,V.useCallback)(e=>{h.escapedFromLock=e,s(e)},[]),h=(0,V.useMemo)(()=>{let s;return{escapedFromLock:r,isAtBottom:n,resizeDifference:0,accumulated:0,velocity:0,listeners:new Set,get scrollTop(){return x.current?.scrollTop??0},set scrollTop(scrollTop){x.current&&(x.current.scrollTop=scrollTop,h.ignoreScrollToTop=x.current.scrollTop)},get targetScrollTop(){if(!x.current||!v.current)return 0;return x.current.scrollHeight-1-x.current.clientHeight},get calculatedTargetScrollTop(){if(!x.current||!v.current)return 0;let{targetScrollTop:r}=this;if(!e.targetScrollTop)return r;if(s?.targetScrollTop===r)return s.calculatedScrollTop;let n=Math.max(Math.min(e.targetScrollTop(r,{scrollElement:x.current,contentElement:v.current}),r),0);return s={targetScrollTop:r,calculatedScrollTop:n},requestAnimationFrame(()=>{s=void 0}),n},get scrollDifference(){return this.calculatedTargetScrollTop-this.scrollTop},get isNearBottom(){return this.scrollDifference<=70}}},[]),f=(0,V.useCallback)((e={})=>{let r;"string"==typeof e&&(e={animation:e}),e.preserveScrollPosition||d(!0);let s=Date.now()+(Number(e.wait)||0),n=cK(l.current,e.animation),{ignoreEscapes:i=!1}=e,a=h.calculatedTargetScrollTop;e.duration instanceof Promise?e.duration.finally(()=>{r=Date.now()}):r=s+(e.duration??0);let o=async()=>{let e=new Promise(requestAnimationFrame).then(()=>{if(!h.isAtBottom)return h.animation=void 0,!1;let{scrollTop:d}=h,u=performance.now(),p=(u-(h.lastTick??u))/cH;if(h.animation||(h.animation={behavior:n,promise:e,ignoreEscapes:i}),h.animation.behavior===n&&(h.lastTick=u),c()||s>Date.now())return o();if(d<Math.min(a,h.calculatedTargetScrollTop)){if(h.animation?.behavior===n){if("instant"===n)return h.scrollTop=h.calculatedTargetScrollTop,o();h.velocity=(n.damping*h.velocity+n.stiffness*h.scrollDifference)/n.mass,h.accumulated+=h.velocity*p,h.scrollTop+=h.accumulated,h.scrollTop!==d&&(h.accumulated=0)}return o()}return r>Date.now()?(a=h.calculatedTargetScrollTop,o()):(h.animation=void 0,h.scrollTop<h.calculatedTargetScrollTop)?f({animation:cK(l.current,l.current.resize),ignoreEscapes:i,duration:Math.max(0,r-Date.now())||void 0}):h.isAtBottom});return e.then(e=>(requestAnimationFrame(()=>{h.animation||(h.lastTick=void 0,h.velocity=0)}),e))};return(!0!==e.wait&&(h.animation=void 0),h.animation?.behavior===n)?h.animation.promise:o()},[d,c,h]),p=(0,V.useCallback)(()=>{u(!0),d(!1)},[u,d]),m=(0,V.useCallback)(({target:e})=>{if(e!==x.current)return;let{scrollTop:r,ignoreScrollToTop:s}=h,{lastScrollTop:n=r}=h;h.lastScrollTop=r,h.ignoreScrollToTop=void 0,s&&s>r&&(n=s),o(h.isNearBottom),setTimeout(()=>{if(h.resizeDifference||r===s)return;if(c()){u(!0),d(!1);return}let e=r>n,i=r<n;if(h.animation?.ignoreEscapes){h.scrollTop=n;return}i&&(u(!0),d(!1)),e&&u(!1),!h.escapedFromLock&&h.isNearBottom&&d(!0)},1)},[u,d,c,h]),g=(0,V.useCallback)(({target:e,deltaY:r})=>{let s=e;for(;!["scroll","auto"].includes(getComputedStyle(s).overflow);){if(!s.parentElement)return;s=s.parentElement}s===x.current&&r<0&&x.current.scrollHeight>x.current.clientHeight&&!h.animation?.ignoreEscapes&&(u(!0),d(!1))},[u,d,h]),x=cV(e=>{x.current?.removeEventListener("scroll",m),x.current?.removeEventListener("wheel",g),e?.addEventListener("scroll",m,{passive:!0}),e?.addEventListener("wheel",g,{passive:!0})},[]),v=cV(e=>{let r;h.resizeObserver?.disconnect(),e&&(h.resizeObserver=new ResizeObserver(([e])=>{let{height:s}=e.contentRect,n=s-(r??s);if(h.resizeDifference=n,h.scrollTop>h.targetScrollTop&&(h.scrollTop=h.targetScrollTop),o(h.isNearBottom),n>=0){let e=cK(l.current,r?l.current.resize:l.current.initial);f({animation:e,wait:!0,preserveScrollPosition:!0,duration:"instant"===e?void 0:350})}else h.isNearBottom&&(u(!1),d(!0));r=s,requestAnimationFrame(()=>{setTimeout(()=>{h.resizeDifference===n&&(h.resizeDifference=0)},1)})}),h.resizeObserver?.observe(e))},[]);return{contentRef:v,scrollRef:x,scrollToBottom:f,stopScroll:p,isAtBottom:n||a,isNearBottom:a,escapedFromLock:r,state:h}})({mass:i,damping:a,stiffness:o,resize:s,initial:n,targetScrollTop:V.useCallback((e,r)=>{let s=b?.targetScrollTop??l;return s?.(e,r)??e},[l])}),{scrollRef:f,contentRef:p,scrollToBottom:m,stopScroll:g,isAtBottom:x,escapedFromLock:v,state:y}=e??h,b=(0,V.useMemo)(()=>({scrollToBottom:m,stopScroll:g,scrollRef:f,isAtBottom:x,escapedFromLock:v,contentRef:p,state:y,get targetScrollTop(){return u.current},set targetScrollTop(targetScrollTop){u.current=targetScrollTop}}),[m,x,p,f,g,v,y]);return(0,V.useImperativeHandle)(c,()=>b,[b]),cY(()=>{f.current&&"visible"===getComputedStyle(f.current).overflow&&(f.current.style.overflow="auto")},[]),V.createElement(cX.Provider,{value:b},V.createElement("div",{...d},"function"==typeof r?r(b):r))}function cJ(){let e=(0,V.useContext)(cX);if(!e)throw Error("use-stick-to-bottom component context must be used within a StickToBottom component");return e}(cG||(cG={})).Content=function({children:e,scrollClassName:r,...s}){let n=cJ();return V.createElement("div",{ref:n.scrollRef,style:{height:"100%",width:"100%",scrollbarGutter:"stable both-edges"},className:r},V.createElement("div",{...s,ref:n.contentRef},"function"==typeof e?e(n):e))};let cZ=({className:e,...r})=>(0,U.jsx)(cG,{className:(0,e1.cn)("relative flex-1 overflow-y-hidden",e),initial:"smooth",resize:"smooth",role:"log",...r}),cQ=({className:e,...r})=>(0,U.jsx)(cG.Content,{className:(0,e1.cn)("flex flex-col gap-8 p-4",e),...r}),c0=({className:e,...r})=>{let{isAtBottom:s,scrollToBottom:n}=cJ(),i=(0,V.useCallback)(()=>{n()},[n]);return!s&&(0,U.jsx)(a$.Button,{className:(0,e1.cn)("absolute bottom-4 left-[50%] translate-x-[-50%] rounded-full",e),onClick:i,size:"icon",type:"button",variant:"outline",...r,children:(0,U.jsx)(c$,{className:"size-4"})})};var c1=e.i(909596);let c2=(0,rE.default)("circle-dot",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]]),c5=(0,rE.default)("clock-3",[["path",{d:"M12 6v6h4",key:"135r8i"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]),c3=(0,rE.default)("message-square-more",[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}],["path",{d:"M12 11h.01",key:"z322tv"}],["path",{d:"M16 11h.01",key:"xkw8gn"}],["path",{d:"M8 11h.01",key:"1dfujw"}]]);function c4({operation:e,onOpenSession:r,onViewOutput:s,onRunAgain:n,pendingAction:i,actionError:a}){let{label:o,detail:l}=function(e){switch(e.kind){case"task_create":return{label:"Task created",detail:e.title??e.taskId};case"task_update":return{label:"Task updated",detail:e.title??e.taskId};case"agent_session_create":return{label:"Agent session",detail:e.branch?`${e.target??"workspace"} / ${e.branch}`:e.target??"main workspace"};case"agent_instruction":return{label:"Agent instruction",detail:e.instruction??e.sessionId};case"schedule_run":return{label:"Schedule run",detail:e.runId}}}(e),c=e.failure?.code==="timeout"?{label:"Timed out",Icon:c5,className:"text-amber-600"}:e.failure?.code==="remote_offline"?{label:"Remote offline",Icon:aR,className:"text-destructive"}:e.failure?.code==="deleted_target"?{label:"Deleted target",Icon:aR,className:"text-muted-foreground"}:"completed"===e.status?{label:"Completed",Icon:os,className:"text-emerald-600"}:"failed"===e.status?{label:"Failed",Icon:aR,className:"text-destructive"}:"running"===e.status||"resolving"===e.status?{label:"Running",Icon:aP,className:"text-blue-600"}:{label:"Queued",Icon:c2,className:"text-muted-foreground"},d=e.failure?.code==="deleted_target",u="agent_session_create"===e.kind&&e.sessionAvailable&&("running"===e.status||"completed"===e.status)&&!d,h="schedule_run"===e.kind&&e.runAvailable&&("running"===e.status||"completed"===e.status||"failed"===e.status)&&!d,f="schedule_run"===e.kind&&e.runAvailable&&("completed"===e.status||"failed"===e.status)&&!d,p=c.Icon;return(0,U.jsxs)("section",{className:"rounded-lg border bg-card p-3 text-card-foreground","aria-label":`${o}: ${c.label}`,children:[(0,U.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,U.jsxs)("div",{className:"min-w-0",children:[(0,U.jsx)("div",{className:"text-sm font-medium",children:o}),l?(0,U.jsx)("div",{className:"mt-0.5 truncate text-xs text-muted-foreground",children:l}):null]}),(0,U.jsxs)("div",{"data-operation-status":e.status,className:(0,e1.cn)("flex shrink-0 items-center gap-1.5 text-xs font-medium",c.className),children:[(0,U.jsx)(p,{className:(0,e1.cn)("size-3.5",("running"===e.status||"resolving"===e.status)&&"animate-spin"),"aria-hidden":"true"}),c.label]})]}),e.failure?.message?(0,U.jsx)("p",{className:"mt-2 text-xs text-muted-foreground",children:e.failure.message}):null,"agent_session_create"===e.kind&&u&&r?(0,U.jsx)("div",{className:"mt-3",children:(0,U.jsxs)(a$.Button,{type:"button",size:"sm",variant:"outline","aria-busy":"open_session"===i,disabled:null!=i,onClick:()=>r(e),children:["open_session"===i?(0,U.jsx)(aP,{className:"size-3.5 animate-spin"}):(0,U.jsx)(oh,{className:"size-3.5"}),"Open Session"]})}):null,"schedule_run"===e.kind&&(h&&s||f&&n)?(0,U.jsxs)("div",{className:"mt-3 flex flex-wrap gap-2",children:[h&&s?(0,U.jsxs)(a$.Button,{type:"button",size:"sm",variant:"outline","aria-busy":"view_output"===i,disabled:null!=i,onClick:()=>s(e),children:["view_output"===i?(0,U.jsx)(aP,{className:"size-3.5 animate-spin"}):(0,U.jsx)(c3,{className:"size-3.5"}),"View Output"]}):null,f&&n?(0,U.jsxs)(a$.Button,{type:"button",size:"sm",variant:"outline","aria-busy":"run_again"===i,disabled:null!=i,onClick:()=>n(e),children:["run_again"===i?(0,U.jsx)(aP,{className:"size-3.5 animate-spin"}):(0,U.jsx)(of,{className:"size-3.5"}),"run_again"===i?"Running again…":"Run Again"]}):null]}):null,a?(0,U.jsx)("p",{role:"alert",className:"mt-2 text-xs text-destructive",children:a}):null]})}let c6=(0,rE.default)("map-pin",[["path",{d:"M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0",key:"1r0f0z"}],["circle",{cx:"12",cy:"10",r:"3",key:"ilqhr7"}]]);function c7({operation:e,onSelect:r,pendingWorkspaceId:s,actionError:n}){let i="pending"!==e.status;return(0,U.jsxs)("section",{className:"rounded-lg border bg-card p-3 text-card-foreground","aria-label":"Select a workspace for the agent session",children:[(0,U.jsx)("div",{className:"text-sm font-medium",children:"Choose a workspace"}),(0,U.jsx)("p",{className:"mt-0.5 text-xs text-muted-foreground",children:"This agent session needs one of the project's offered workspaces."}),(0,U.jsx)("div",{className:"mt-3 grid gap-2",children:e.candidates.map(n=>{let a=s===n.id,o=`${n.target} / ${n.branch??"main"}`;return(0,U.jsxs)(a$.Button,{type:"button",variant:"outline",className:"h-auto min-h-9 justify-start whitespace-normal text-left","aria-label":`Select workspace: ${o}`,"aria-busy":a,disabled:i||null!=s,onClick:()=>r({requestId:e.requestId,workspaceId:n.id}),children:[a?(0,U.jsx)(aP,{className:"size-3.5 animate-spin"}):(0,U.jsx)(c6,{className:"size-3.5"}),o,a?" · Selecting…":""]},n.id)})}),i?(0,U.jsx)("p",{className:"mt-2 text-xs text-muted-foreground",children:"Workspace selection resolved."}):null,n?(0,U.jsx)("p",{role:"alert",className:"mt-2 text-xs text-destructive",children:n}):null]})}function c8(e){try{let r=JSON.parse(e);return"object"!=typeof r||null===r||Array.isArray(r)?null:r}catch{return null}}let c9="#ref:",de=(0,V.createContext)({contextRefs:[]});function dt({href:e,entityType:r,entityId:s,children:n}){let{contextRefs:i,onOpenContext:a}=(0,V.useContext)(de),o=i.find(e=>e.entity_type===r&&e.entity_id===s);return o&&!o.deleted&&o.navigation&&a?(0,U.jsx)("a",{href:e,className:"wrap-anywhere cursor-pointer font-medium text-primary underline","data-context-link":r,onClick:e=>{e.preventDefault(),a(o)},children:n}):(0,U.jsx)(U.Fragment,{children:n})}let dr={a:({href:e,children:r,className:s,node:n,...i})=>{let a=function(e){let r;if(!e?.startsWith(c9))return null;try{r=decodeURIComponent(e.slice(c9.length))}catch{return null}let s=r.indexOf(":");return s<=0||s===r.length-1?null:{entityType:r.slice(0,s),entityId:r.slice(s+1)}}(e);return a?(0,U.jsx)(dt,{href:e,entityType:a.entityType,entityId:a.entityId,children:r}):(0,U.jsx)("a",{href:e,className:s??"wrap-anywhere font-medium text-primary underline","data-streamdown":"link",target:"_blank",rel:"noreferrer",...i,children:r})}};function ds(e){let r=c8(e);return("string"==typeof r?.toolName?r.toolName:"string"==typeof r?.tool?r.tool:"project tool").replaceAll("_"," ")}function dn(e){let r=c8(e);return"string"==typeof r?.output?r.output:"string"==typeof r?.error?r.error:e}function di(e){let r=c8(e)?.toolCallId;return"string"==typeof r&&r?r:null}function da(e){if("workspace_selection"===e.kind)switch(e.status){case"pending":return"Waiting for workspace selection";case"resolving":return"Creating agent session";case"running":return"Agent session running";case"completed":return"Agent session completed";case"failed":return"Workspace selection failed"}if("agent_session_create"===e.kind){if("resolving"===e.status)return"Creating agent session";if("running"===e.status)return"Agent session running";if("completed"===e.status)return"Agent session completed"}switch(e.status){case"pending":return"Queued";case"resolving":case"running":return"Running";case"completed":return"Completed";case"failed":return"Failed"}}function dl({messages:e,contextRefs:r,status:s,activeTurnId:n,pendingApprovalIds:i,queueLength:a,loading:o,hasEarlierMessages:l,loadingEarlierMessages:c,connected:d,error:u,initialDraft:h="",onDraftChange:f,onDraftSent:p,onSend:m,onLoadEarlierMessages:g,onStop:x,onResolveApproval:v,onSelectWorkspace:y,onOpenContext:b,onOpenAgentSession:w,onOpenScheduleRun:_,onRunScheduleAgain:S}){let{settings:k}=(0,c1.useConversationSettings)(),[j,C]=(0,V.useState)(h),[N,E]=(0,V.useState)(!1),[D,T]=(0,V.useState)(null),[R,A]=(0,V.useState)(new Set),[M,I]=(0,V.useState)(new Set),[P,F]=(0,V.useState)(null),L=(0,V.useRef)(!1),O=(0,V.useRef)(null),B=(0,V.useRef)(new Set),z=(0,V.useRef)(new Set),[$,W]=(0,V.useState)(new Map),[H,q]=(0,V.useState)(new Map),K=(0,V.useMemo)(()=>({contextRefs:r,onOpenContext:b}),[r,b]),X=(0,V.useMemo)(()=>{let r=new Map,s=new Map;for(let n of e){if("operation"!==n.type)continue;let e=(0,aC.parseProjectChatOperationMessage)(n.content);e&&(r.set(n.id,e),s.set(e.operationId,n.id))}return{byMessageId:r,latestMessageIdByOperation:s}},[e]),Y=(0,V.useMemo)(()=>{let r=new Set,s=new Map;for(let n of e){if("tool_use"!==n.type&&"tool_result"!==n.type)continue;let e=di(n.content);e&&("tool_use"===n.type?r.add(e):r.has(e)&&s.set(e,n))}return s},[e]),G=async(e,r,s)=>{if(!z.current.has(e)){z.current.add(e),W(s=>new Map(s).set(e,r)),q(r=>{let s=new Map(r);return s.delete(e),s});try{await s()}catch(r){q(s=>new Map(s).set(e,r instanceof Error?r.message:"Project operation failed"))}finally{z.current.delete(e),W(r=>{let s=new Map(r);return s.delete(e),s})}}},J=async e=>{e.preventDefault();let r=j.trim();if(r&&!L.current){L.current=!0,E(!0),F(null);try{await m(r),C(""),p?.(j)}catch(e){F(e instanceof Error?e.message:"Failed to send message")}finally{L.current=!1,E(!1)}}};(0,V.useEffect)(()=>{let e=O.current;e&&("running"!==s||n!==e)&&(O.current=null,T(null))},[n,s]);let Z=async()=>{if(n&&!O.current){O.current=n,T(n),F(null);try{await x(n)}catch(e){O.current===n&&F(e instanceof Error?e.message:"Failed to stop generation")}}},Q=async(e,r)=>{if(!B.current.has(e)){B.current.add(e),A(r=>new Set(r).add(e)),F(null);try{await v(e,r),I(r=>new Set(r).add(e))}catch(e){F(e instanceof Error?e.message:"Failed to resolve approval")}finally{B.current.delete(e),A(r=>{let s=new Set(r);return s.delete(e),s})}}};return(0,V.useEffect)(()=>{I(e=>{let r=new Set([...e].filter(e=>i.includes(e)));return r.size===e.size?e:r})},[i]),(0,U.jsxs)("div",{className:"flex h-full min-h-0 flex-col",children:[(0,U.jsxs)(cZ,{className:"min-h-0",initial:"instant",resize:"smooth","data-testid":"project-chat-scroll",children:[(0,U.jsx)(de.Provider,{value:K,children:(0,U.jsxs)(cQ,{className:"mx-auto w-full max-w-3xl gap-4 px-4 py-5 sm:px-6",children:[l?(0,U.jsx)("div",{className:"flex justify-center",children:(0,U.jsxs)(a$.Button,{type:"button",size:"sm",variant:"outline",disabled:c,onClick:()=>void g(),children:[c?(0,U.jsx)(aP,{className:"size-3.5 animate-spin"}):null,"Load earlier messages"]})}):null,o&&0===e.length?(0,U.jsx)("div",{className:"flex justify-center py-12",children:(0,U.jsx)(aP,{className:"size-5 animate-spin text-muted-foreground"})}):null,o||0!==e.length?null:(0,U.jsxs)("div",{className:"mx-auto max-w-md py-20 text-center",children:[(0,U.jsx)("h2",{className:"text-base font-semibold",children:"Start a project conversation"}),(0,U.jsx)("p",{className:"mt-1 text-sm text-muted-foreground",children:"Discuss tasks, schedules, sessions, and work across the whole project."})]}),(0,U.jsxs)("div",{className:"flex w-full flex-col gap-4",children:[e.map(e=>{var s;if("turn_end"===e.type)return(0,U.jsxs)("div",{"data-testid":"turn-boundary",className:"my-2 flex items-center gap-2","aria-label":"Turn complete",children:[(0,U.jsx)("span",{className:"h-px flex-1 bg-border"}),(0,U.jsx)("span",{className:"size-1 rounded-full bg-border"}),(0,U.jsx)("span",{className:"h-px flex-1 bg-border"})]},e.id);if("user"===e.type||"assistant"===e.type)return(0,U.jsx)(cO,{from:e.type,children:(0,U.jsx)(cB,{style:{fontSize:`${k.agentFontSize}px`},children:"assistant"===e.type?(0,U.jsx)(cz,{components:dr,children:e.content}):e.content})},e.id);if("tool_use"===e.type){let r=di(e.content),n=r?Y.get(r):void 0;if(!n)return(0,U.jsxs)("div",{className:"flex items-center gap-2 rounded-md bg-muted/50 px-3 py-2 text-xs text-muted-foreground",children:[(0,U.jsx)(aK,{className:"size-3.5"}),"Running ",ds(e.content),"…"]},e.id);let i=(s=n.content,"string"==typeof c8(s)?.error);return(0,U.jsxs)("details",{"data-testid":"tool-call",className:"rounded-md border px-3 py-2 text-xs",children:[(0,U.jsx)("summary",{className:"cursor-pointer text-muted-foreground",children:(0,U.jsxs)("span",{className:"inline-flex items-center gap-2 align-middle",children:[i?(0,U.jsx)(ou,{className:"size-3.5 text-destructive"}):(0,U.jsx)(al.Check,{className:"size-3.5"}),ds(e.content),i?" failed":""]})}),(0,U.jsx)("pre",{className:"mt-2 overflow-x-auto whitespace-pre-wrap",children:dn(n.content)})]},e.id)}if("tool_result"===e.type){let r=di(e.content);return r&&Y.get(r)===e?null:(0,U.jsxs)("details",{className:"rounded-md border px-3 py-2 text-xs",children:[(0,U.jsx)("summary",{className:"cursor-pointer text-muted-foreground",children:"Tool result"}),(0,U.jsx)("pre",{className:"mt-2 overflow-x-auto whitespace-pre-wrap",children:dn(e.content)})]},e.id)}if("tool_approval_request"===e.type){let r=c8(e.content);if(!r||"string"!=typeof r.approvalId)return null;let s="string"==typeof r.tool?r.tool:"project tool",n=i.includes(r.approvalId)&&!M.has(r.approvalId);return(0,U.jsxs)("div",{className:"rounded-lg border border-amber-500/40 bg-amber-500/10 p-3 text-sm",children:[(0,U.jsxs)("div",{className:"font-medium",children:["Approve ",s.replaceAll("_"," "),"?"]}),(0,U.jsx)("pre",{className:"mt-2 overflow-x-auto whitespace-pre-wrap text-xs text-muted-foreground",children:JSON.stringify(r.input??{},null,2)}),n?(0,U.jsxs)("div",{className:"mt-3 flex gap-2",children:[(0,U.jsxs)(a$.Button,{size:"sm","aria-label":`Approve ${s}`,disabled:R.has(r.approvalId),onClick:()=>void Q(r.approvalId,!0),children:[(0,U.jsx)(al.Check,{className:"size-3.5"}),"Approve"]}),(0,U.jsxs)(a$.Button,{size:"sm",variant:"outline","aria-label":`Deny ${s}`,disabled:R.has(r.approvalId),onClick:()=>void Q(r.approvalId,!1),children:[(0,U.jsx)(rD,{className:"size-3.5"}),"Deny"]})]}):(0,U.jsx)("div",{className:"mt-3 text-xs text-muted-foreground",children:"Approval expired or resolved"})]},e.id)}if("operation"===e.type){let s,n=X.byMessageId.get(e.id);if(!n)return(0,U.jsx)("div",{className:"rounded-md border bg-card px-3 py-2 text-sm text-muted-foreground",children:"Project operation unavailable"},e.id);if(X.latestMessageIdByOperation.get(n.operationId)!==e.id)return null;let i=(s=(e,s)=>r.some(r=>r.entity_type===e&&r.entity_id===s&&r.deleted),"task_create"===n.kind||"task_update"===n.kind?s("task",n.taskId):"agent_session_create"===n.kind||"agent_instruction"===n.kind?s("agent_session",n.sessionId):"schedule_run"===n.kind&&(s("schedule",n.scheduleId)||s("schedule_run",n.runId)))?{...n,failure:{code:"deleted_target",message:"The target no longer exists or is unavailable."}}:n,a=$.get(i.operationId),o=H.get(i.operationId);if("workspace_selection"===i.kind){let e=a?.startsWith("workspace:")?a.slice(10):null;return(0,U.jsxs)("div",{"data-operation-id":i.operationId,"data-operation-kind":i.kind,children:[(0,U.jsx)("p",{role:"status","aria-live":"polite","aria-atomic":"true",className:"sr-only",children:da(i)}),(0,U.jsx)(c7,{operation:i,pendingWorkspaceId:e,actionError:o,onSelect:({requestId:e,workspaceId:r})=>{G(i.operationId,"select_workspace",async()=>{W(e=>new Map(e).set(i.operationId,`workspace:${r}`)),await y(e,r)})}})]},`operation:${i.operationId}`)}return(0,U.jsxs)("div",{"data-operation-id":i.operationId,"data-operation-kind":i.kind,children:[(0,U.jsx)("p",{role:"status","aria-live":"polite","aria-atomic":"true",className:"sr-only",children:da(i)}),(0,U.jsx)(c4,{operation:i,pendingAction:a,actionError:o,onOpenSession:"agent_session_create"===i.kind&&w?e=>{G(e.operationId,"open_session",()=>w(e.sessionId,e.target??"local",e.branch??null))}:void 0,onViewOutput:"schedule_run"===i.kind&&_?e=>{G(e.operationId,"view_output",()=>_(e.runId,e.scheduleId))}:void 0,onRunAgain:"schedule_run"===i.kind&&S?e=>{G(e.operationId,"run_again",()=>S(e.runId))}:void 0})]},`operation:${i.operationId}`)}if("error"===e.type){let r=c8(e.content),s="string"==typeof r?.message?r.message:e.content;return(0,U.jsxs)("div",{role:"alert",className:"flex gap-2 rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive",children:[(0,U.jsx)(ou,{className:"mt-0.5 size-4 shrink-0"}),s]},e.id)}return(0,U.jsx)("div",{className:"rounded-md bg-muted/40 px-3 py-2 text-xs text-muted-foreground",children:e.content},e.id)}),u?(0,U.jsx)("div",{role:"alert",className:"rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive",children:u}):null,P?(0,U.jsx)("div",{role:"alert",className:"rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive",children:P}):null]})]})}),(0,U.jsx)(c0,{"aria-label":"Jump to latest message"})]}),(0,U.jsx)("div",{className:"shrink-0 border-t bg-background p-3 sm:px-6",children:(0,U.jsxs)("form",{onSubmit:e=>void J(e),className:"mx-auto max-w-3xl",children:["running"===s?(0,U.jsxs)("div",{className:"mb-2 flex items-center justify-between gap-3 text-xs text-muted-foreground",children:[(0,U.jsx)("span",{children:a>0?`${a} queued`:"Project Chat is working"}),(0,U.jsxs)(a$.Button,{type:"button",variant:"outline",size:"sm","aria-label":"Stop generating",disabled:!n||null!==D,onClick:()=>void Z(),children:[(0,U.jsx)(ce,{className:"size-3"}),D?"Stopping…":"Stop generating"]})]}):null,"queued"===s?(0,U.jsxs)("div",{className:"mb-2 flex items-center gap-2 text-xs text-muted-foreground",role:"status",children:[(0,U.jsx)(l9.Clock,{className:"size-3.5"}),(0,U.jsx)("span",{children:"Waiting to start…"})]}):null,(0,U.jsxs)("div",{className:"relative",children:[(0,U.jsx)(aq,{"aria-label":"Message Project Chat",value:j,onChange:e=>{C(e.target.value),f?.(e.target.value)},onKeyDown:e=>{"Enter"!==e.key||e.shiftKey||(e.preventDefault(),e.currentTarget.form?.requestSubmit())},placeholder:d?"Message Project Chat…":"Reconnecting to Project Chat…",disabled:!d||N,rows:2,className:"min-h-20 resize-none pr-16"}),(0,U.jsx)(a$.Button,{type:"submit",size:"sm","aria-label":"Send message",disabled:!d||N||!j.trim(),className:"absolute bottom-2 right-2",children:"Send"})]})]})})]})}function dc({projectId:e,threadId:r,projectName:s,onBack:n,onSelectThread:i,onOpenContext:a,onOpenAgentSession:o,onOpenScheduleRun:l,onRunScheduleAgain:c}){let d=function(e,r){let s=aE(e),[n,i]=(0,V.useState)([]),[a,o]=(0,V.useState)(!1),[l,c]=(0,V.useState)(!1),[d,u]=(0,V.useState)(!1),[h,f]=(0,V.useState)(l_),[p,m]=(0,V.useState)(!1),[g,x]=(0,V.useState)(null),[v,y]=(0,V.useState)(null),[b,w]=(0,V.useState)(null),_=(0,V.useRef)(l_()),S=(0,V.useRef)(e),k=(0,V.useRef)(r),j=(0,V.useRef)(0),C=(0,V.useRef)(0),N=(0,V.useRef)(null),E=(0,V.useRef)(!1),D=(0,V.useRef)(new Map),T=(0,V.useRef)(0),R=(0,V.useRef)(null),A=(0,V.useRef)(new Map);(0,V.useEffect)(()=>(E.current=!0,()=>{E.current=!1}),[]),(0,V.useEffect)(()=>{for(let[s,n]of(S.current=e,k.current=r,A.current))e&&n.identity.projectId===e||A.current.delete(s)},[e,r]);let M=(0,V.useCallback)(async(e,r,s)=>{N.current?.abort();let n=new AbortController;N.current=n;let a=++C.current;try{let o=await aC.api.listProjectChatThreads(e,s,{signal:n.signal});if(j.current!==r||S.current!==e||C.current!==a)return;i(o),x(null)}catch(s){if(n.signal.aborted||j.current!==r||S.current!==e||C.current!==a)return;x(s instanceof Error?s.message:"Failed to list Project Chat threads")}finally{N.current===n&&(N.current=null),j.current===r&&S.current===e&&C.current===a&&o(!1)}},[]);(0,V.useEffect)(()=>{j.current+=1,C.current+=1;let r=j.current;if(N.current?.abort(),N.current=null,!e){i([]),o(!1),x(null);return}return i([]),o(!0),x(null),M(e,r,!1),()=>{C.current+=1,N.current?.abort(),N.current=null}},[M,e]);let I=(0,V.useCallback)(async(e=!1)=>{let r=S.current;r&&await M(r,j.current,e)},[M]),P=(0,V.useCallback)((e,r)=>!!E.current&&S.current===e&&j.current===r&&(C.current+=1,N.current?.abort(),N.current=null,o(!1),!0),[]);(0,V.useEffect)(()=>{T.current+=1;let s=T.current,n=!1,a=!1,o=null,l=0,d=0,h=null,p=null,g=e=>{_.current=e,f(e)};if(R.current?.close(),R.current=null,m(!1),u(!1),y(null),w(null),!e||!r){g(l_()),c(!1);return}let x=A.current.get(r);x?.identity.projectId===e?(lS(A.current,x),g({thread:x.thread,messages:x.messages,hasEarlierMessages:x.hasEarlierMessages,earliestSequence:x.earliestSequence,status:x.status,activeTurnId:x.activeTurnId,pendingApprovalIds:x.pendingApprovalIds,queueLength:x.queueLength,contextRefs:x.contextRefs})):(A.current.delete(r),g(l_())),c(!0);let v=()=>!n&&!a&&T.current===s&&S.current===e&&k.current===r,b=()=>{null!==o&&clearTimeout(o),o=null},j=e=>v()&&p===e,C=e=>{null!==e.timeout&&clearTimeout(e.timeout),e.timeout=null,p===e&&(p=null)},N=e=>{C(e),e.controller.abort();let r=e.socket;e.socket=null,r&&R.current===r&&(R.current=null),r?.close()},E=e=>{a=!0,b(),p&&N(p),e&&R.current===e&&(R.current=null,e.close()),m(!1),c(!1),y("Thread not found"),w("thread_not_found")},D=(e=!1)=>{if(!v()||(e&&b(),null!==o))return;let r=e?0:Math.min(1e3*2**l,3e4);e||(l+=1),o=setTimeout(()=>{o=null,I(!0)},r)},M=(e,r)=>{v()&&R.current===e&&(p?.socket===e?N(p):(R.current=null,e.close()),m(!1),c(!1),r&&y(r),D())};async function I(s){if(!v()||p)return;let n={controller:new AbortController,timeout:null,socket:null};p=n,n.timeout=setTimeout(()=>{j(n)&&(N(n),m(!1),c(!1),y("Project Chat connection timed out"),D())},1e4);try{let[o,u]=await Promise.all([aC.api.getProjectChatThread(r,{signal:n.controller.signal}),(0,aC.getFreshToken)(s?{skipCache:!0}:void 0)]);if(!j(n))return;let{thread:f,contextRefs:x}=o;if(f.project_id!==e||f.id!==r){a=!0,N(n),y("Project Chat stream identity mismatch"),c(!1);return}if(!Array.isArray(x)||!x.every(lN)||x.some(e=>e.thread_id!==r))throw Error("Invalid Project Chat thread context");if(g({..._.current,thread:f,contextRefs:x}),!(0,aC.hasUsableStreamToken)()){N(n),D();return}let b=new WebSocket((0,aC.getWebSocketUrl)(`/api/project-chat/threads/${r}/stream`,u));n.socket=b,R.current=b;let S=!1;h=null,b.onopen=()=>{v()&&R.current===b&&m(!0)},b.onmessage=s=>{if(v()&&R.current===b)try{let o=JSON.parse(s.data);if(!lj(o))throw Error("invalid frame");if("type"in o&&"project_chat_snapshot"===o.type){let s=o.snapshot;if(!function(e){if(!lj(e)||!lj(e.identity)||!lj(e.thread)||!Array.isArray(e.messages)||!Array.isArray(e.contextRefs))return!1;let r=e.thread.id,s=e.thread.project_id,n=e.thread.user_id;return"string"==typeof r&&"string"==typeof s&&"string"==typeof n&&"string"==typeof e.identity.projectId&&"string"==typeof e.identity.threadId&&"string"==typeof e.identity.userId&&e.identity.threadId===r&&e.identity.projectId===s&&e.identity.userId===n&&e.messages.every(e=>lC(e)&&e.thread_id===r)&&"boolean"==typeof e.hasEarlierMessages&&(null===e.earliestSequence||Number.isSafeInteger(e.earliestSequence))&&e.contextRefs.every(e=>lN(e)&&e.thread_id===r)&&lE(e.status)&&(null===e.activeTurnId||"string"==typeof e.activeTurnId)&&Array.isArray(e.pendingApprovalIds)&&e.pendingApprovalIds.every(e=>"string"==typeof e&&e.length>0)&&Number.isSafeInteger(e.queueLength)&&e.queueLength>=0}(s))throw Error("invalid snapshot");if(s.identity.threadId!==r||s.identity.projectId!==e||s.identity.userId!==f.user_id||s.thread.id!==r||s.thread.project_id!==e||s.thread.user_id!==f.user_id){a=!0,y("Project Chat stream identity mismatch"),c(!1),p===n?N(n):(R.current=null,b.close());return}S=!0,d=0,h=Date.now(),C(n),l=0,w(null),y(null),lS(A.current,s),i(e=>e.map(e=>e.id===s.thread.id?s.thread:e)),g({thread:s.thread,messages:_.current.thread?.id===r&&null!==_.current.earliestSequence&&null!==s.earliestSequence&&_.current.earliestSequence<s.earliestSequence?lk(_.current.messages,s.messages):s.messages,hasEarlierMessages:_.current.thread?.id===r&&null!==_.current.earliestSequence&&null!==s.earliestSequence&&_.current.earliestSequence<s.earliestSequence?_.current.hasEarlierMessages:s.hasEarlierMessages,earliestSequence:_.current.thread?.id===r&&null!==_.current.earliestSequence&&null!==s.earliestSequence&&_.current.earliestSequence<s.earliestSequence?_.current.earliestSequence:s.earliestSequence,status:s.status,activeTurnId:s.activeTurnId,pendingApprovalIds:s.pendingApprovalIds,queueLength:s.queueLength,contextRefs:s.contextRefs}),c(!1)}else if("JsonPatch"in o){if(!S||!Array.isArray(o.JsonPatch))throw Error("invalid patch frame");let s=function(e,r){let s=e;for(let e of r){if(!lj(e)||"add"!==e.op&&"replace"!==e.op||"string"!=typeof e.path||!lj(e.value))return null;let r=/^\/messages\/(0|[1-9]\d*)$/.exec(e.path);if(r&&"ENTRY"===e.value.type&&lC(e.value.content)){let n=e.value.content,i=Number(r[1]);if(!Number.isSafeInteger(i)||null!==s.thread&&n.thread_id!==s.thread.id)return null;let a=[...s.messages];if("add"===e.op){if(i>a.length||a.some(e=>e.id===n.id))return null;a.push(n),a.sort((e,r)=>e.sequence-r.sequence)}else{let e=a.findIndex(e=>e.id===n.id);if(e<0)return null;a[e]=n}s={...s,messages:a,earliestSequence:a[0]?.sequence??null}}else if("/messages"===e.path&&"MESSAGES"===e.value.type&&Array.isArray(e.value.content)&&e.value.content.every(lC)&&"boolean"==typeof e.value.hasEarlierMessages&&(null===e.value.earliestSequence||Number.isSafeInteger(e.value.earliestSequence))&&e.value.content.every(e=>null===s.thread||e.thread_id===s.thread.id)){let r=null!==s.earliestSequence&&null!==e.value.earliestSequence&&s.earliestSequence<e.value.earliestSequence,n=r?lk(s.messages,e.value.content):e.value.content;s={...s,messages:n,earliestSequence:n[0]?.sequence??null,hasEarlierMessages:r?s.hasEarlierMessages:e.value.hasEarlierMessages}}else if("/status"===e.path&&"STATUS"===e.value.type&&lE(e.value.content))s={...s,status:e.value.content};else if("/activeTurnId"===e.path&&"ACTIVE_TURN"===e.value.type&&(null===e.value.content||"string"==typeof e.value.content))s={...s,activeTurnId:e.value.content};else if("/pendingApprovalIds"===e.path&&"APPROVALS"===e.value.type&&Array.isArray(e.value.content)&&e.value.content.every(e=>"string"==typeof e&&e.length>0))s={...s,pendingApprovalIds:[...new Set(e.value.content)].sort()};else if("/queueLength"===e.path&&"QUEUE"===e.value.type&&Number.isSafeInteger(e.value.content)&&e.value.content>=0)s={...s,queueLength:e.value.content};else if("/contextRefs"===e.path&&"CONTEXT"===e.value.type&&Array.isArray(e.value.content)&&e.value.content.every(lN)&&e.value.content.every(e=>null===s.thread||e.thread_id===s.thread.id))s={...s,contextRefs:e.value.content};else{var n;if(!("/thread"===e.path&&"THREAD"===e.value.type&&lj(n=e.value.content)&&"string"==typeof n.id&&"string"==typeof n.project_id&&"string"==typeof n.user_id&&(null===n.title||"string"==typeof n.title))||"string"!=typeof n.updated_at||null===s.thread||e.value.content.id!==s.thread.id||e.value.content.project_id!==s.thread.project_id||e.value.content.user_id!==s.thread.user_id)return null;s={...s,thread:e.value.content}}}return s}(_.current,o.JsonPatch);if(!s)throw Error("invalid patch frame");h=Date.now(),s.thread&&(s.thread!==_.current.thread&&i(e=>e.map(e=>e.id===s.thread.id?s.thread:e)),lS(A.current,{identity:{projectId:e,threadId:r,userId:s.thread.user_id},thread:s.thread,messages:s.messages,hasEarlierMessages:s.hasEarlierMessages,earliestSequence:s.earliestSequence,status:s.status,activeTurnId:s.activeTurnId,pendingApprovalIds:s.pendingApprovalIds,queueLength:s.queueLength,contextRefs:s.contextRefs})),g(s)}else if("error"in o){if("Thread not found"===o.error)return void E(b);if((0,aC.isStreamAuthError)(o.error)){d+=1,M(b,d>=aC.STREAM_AUTH_REJECTS_BEFORE_ERROR?aC.STREAM_AUTH_FAILED_MESSAGE:void 0);return}M(b,"string"==typeof o.error?o.error:"Project Chat stream failed")}else throw Error("unknown frame")}catch{M(b,"Invalid Project Chat stream message")}},b.onerror=()=>{M(b)},b.onclose=()=>{v()&&R.current===b&&(p?.socket===b&&N(p),R.current=null,m(!1),D())}}catch(e){if(!j(n))return;if(N(n),lj(e)&&(404===e.status||e instanceof Error&&"Thread not found"===e.message))return void E();c(!1),y(e instanceof Error?e.message:"Failed to open Project Chat thread"),D()}}let P=()=>{if(!v())return;b(),p&&N(p);let e=R.current;e&&(R.current=null,e.close()),m(!1),I(!0)},F=()=>P(),L=()=>{"visible"===document.visibilityState&&(p||null!==h&&Date.now()-h>4e4)&&P()};return window.addEventListener("online",F),document.addEventListener("visibilitychange",L),I(!1),()=>{n=!0,b(),p&&N(p),window.removeEventListener("online",F),document.removeEventListener("visibilitychange",L);let e=R.current;R.current=null,e?.close()}},[e,r]);let F=(0,V.useCallback)(async e=>{let r=S.current,n=j.current;if(!r)throw Error("No project selected");let a=await s(e);return a.project_id===r&&P(r,n)&&i(e=>[a,...e.filter(e=>e.id!==a.id)]),a},[s,P]),L=(0,V.useCallback)(e=>{if(i(r=>null===e.archived_at?[e,...r.filter(r=>r.id!==e.id)]:r.filter(r=>r.id!==e.id)),_.current.thread?.id===e.id){let r={..._.current,thread:e};_.current=r,f(r)}let r=A.current.get(e.id);r&&lS(A.current,{...r,thread:e})},[]),O=(0,V.useCallback)(async(e,r)=>{let s=S.current,n=j.current,i=r.trim();if(!i)throw Error("Title is required");let a=(D.current.get(e)??0)+1;D.current.set(e,a);let o=await aC.api.updateProjectChatThread(e,{title:i});return s&&o.project_id===s&&D.current.get(e)===a&&P(s,n)&&L(o),o},[P,L]),B=(0,V.useCallback)(async(e,r=!0)=>{let s=S.current,n=j.current,i=(D.current.get(e)??0)+1;D.current.set(e,i);let a=await aC.api.updateProjectChatThread(e,{archived:r});return s&&a.project_id===s&&D.current.get(e)===i&&P(s,n)&&L(a),a},[P,L]),z=(0,V.useCallback)(async e=>{let r=S.current,s=j.current,n=(D.current.get(e)??0)+1;if(D.current.set(e,n),await aC.api.deleteProjectChatThread(e),r&&D.current.get(e)===n&&P(r,s)&&(A.current.delete(e),i(r=>r.filter(r=>r.id!==e)),k.current===e)){T.current+=1,R.current?.close(),R.current=null,m(!1),c(!1);let e=l_();_.current=e,f(e)}},[P]),$=(0,V.useCallback)(async e=>{let r=k.current;if(!r)throw Error("No Project Chat thread selected");let s=e.trim();if(!s)throw Error("Message is required");await aC.api.sendProjectChatMessage(r,s)},[]),W=(0,V.useCallback)(async e=>{let r=k.current;return!!r&&aC.api.stopProjectChatTurn(r,e)},[]),H=(0,V.useCallback)(async(e,r)=>{let s=k.current;if(!s)throw Error("No Project Chat thread selected");await aC.api.approveProjectChatTool(s,e,r)},[]),U=(0,V.useCallback)(async(e,r)=>{let s=k.current;if(!s)throw Error("No Project Chat thread selected");await aC.api.selectProjectChatWorkspace(s,e,r)},[]),q=(0,V.useCallback)(async()=>{let e=k.current,r=_.current;if(e&&r.hasEarlierMessages&&null!==r.earliestSequence){u(!0);try{let s=await aC.api.listProjectChatMessages(e,{beforeSequence:r.earliestSequence});if(k.current!==e||_.current.thread?.id!==e)return;let n=lk(_.current.messages,s.messages),i={..._.current,messages:n,hasEarlierMessages:s.hasMore,earliestSequence:n[0]?.sequence??null};_.current=i,f(i),y(null)}catch(r){k.current===e&&y(r instanceof Error?r.message:"Failed to load earlier messages")}finally{k.current===e&&u(!1)}}},[]);return{...h,threads:n,loading:a||l,threadsLoading:a,threadLoading:l,loadingEarlierMessages:d,isConnected:p,error:v??g,terminalError:b,refetchThreads:I,createThread:F,renameThread:O,archiveThread:B,deleteThread:z,sendMessage:$,stopTurn:W,resolveToolApproval:H,selectWorkspace:U,loadEarlierMessages:q}}(e,r),[u,h]=(0,V.useState)(!0),[f,p]=(0,V.useState)(!1),[m,g]=(0,V.useState)(!1),[x,v]=(0,V.useState)(!1),[y,b]=(0,V.useState)(null),w=(0,V.useRef)(!1),_=(0,V.useRef)(new Map),S=(0,V.useRef)(null),k=(0,V.useRef)(0),j=aG(d.thread),C=d.threads.filter(e=>null===e.archived_at),N=`${e}:${r}`,E=function(){let[e,r]=V.useState(void 0);return V.useEffect(()=>{let e=window.matchMedia("(max-width: 767px)"),s=()=>{r(window.innerWidth<768)};return e.addEventListener("change",s),r(window.innerWidth<768),()=>e.removeEventListener("change",s)},[]),!!e}(),D=e=>{p(e),e||requestAnimationFrame(()=>S.current?.focus())};(0,V.useEffect)(()=>{k.current+=1,w.current=!1,v(!1),b(null),g(!1),p(!1)},[N]);let T=async()=>{if(w.current)return;let r=k.current;w.current=!0,v(!0),b(null);try{let s=await d.createThread();r===k.current&&s.project_id===e&&i(s.id)}catch(e){r===k.current&&b(e instanceof Error?e.message:"Failed to create thread")}finally{r===k.current&&(w.current=!1,v(!1))}},R=e=>{if(e!==r)return;let s=C.find(r=>r.id!==e);s?i(s.id):n()},A=async e=>{let r=k.current;await d.archiveThread(e,!0),r===k.current&&R(e)},M=async e=>{let r=k.current;await d.deleteThread(e),r===k.current&&R(e)};return(0,U.jsxs)("div",{className:"flex h-full min-h-0 flex-col bg-background",children:[(0,U.jsxs)("header",{className:"flex h-12 shrink-0 items-center justify-between gap-3 border-b px-3 sm:px-4",children:[(0,U.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,U.jsx)(a$.Button,{type:"button",variant:"ghost",size:"icon-sm","aria-label":"Back to Overview",onClick:n,children:(0,U.jsx)(lu.ArrowLeft,{className:"size-4"})}),(0,U.jsx)(rJ,{className:"size-4 shrink-0 text-primary","aria-hidden":"true"}),(0,U.jsxs)("div",{className:"min-w-0",children:[(0,U.jsxs)("div",{className:"truncate text-[11px] text-muted-foreground",children:[s," / Project Chat"]}),(0,U.jsxs)(i3,{open:m,onOpenChange:g,children:[(0,U.jsx)(i4,{asChild:!0,children:(0,U.jsxs)("button",{type:"button","aria-label":`Current thread: ${j}`,className:"flex max-w-[50vw] items-center gap-1 truncate text-sm font-semibold focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:[(0,U.jsx)("span",{className:"truncate",children:j}),(0,U.jsx)(aa,{className:"size-3.5 shrink-0"})]})}),(0,U.jsxs)(i6,{align:"start",className:"w-64",children:[C.slice(0,5).map(e=>{let r=aG(e);return(0,U.jsx)(i7,{asChild:!0,children:(0,U.jsx)("button",{type:"button","aria-label":`Switch to thread: ${r}`,onClick:()=>i(e.id),className:"w-full truncate text-left",children:r})},e.id)}),(0,U.jsx)(i7,{asChild:!0,children:(0,U.jsxs)("button",{type:"button",disabled:x,onClick:()=>void T(),className:"w-full border-t",children:[(0,U.jsx)(oS,{className:"size-3.5"}),"New thread"]})})]})]})]})]}),(0,U.jsx)(a$.Button,{ref:S,type:"button",variant:"ghost",size:"icon-sm","aria-label":E?"Open threads and context":u?"Hide threads and context":"Show threads and context",onClick:()=>E?p(!0):h(e=>!e),children:E?(0,U.jsx)(lf,{className:"size-4"}):u?(0,U.jsx)(lh,{className:"size-4"}):(0,U.jsx)(lf,{className:"size-4"})})]}),y?(0,U.jsx)("div",{role:"alert",className:"border-b border-destructive/40 bg-destructive/10 px-4 py-2 text-sm text-destructive",children:y}):null,(0,U.jsxs)("div",{className:"flex min-h-0 flex-1","data-testid":"project-chat-workbench-columns",children:[(0,U.jsx)("main",{"data-testid":"project-chat-main","data-project-chat-column":!0,className:"min-w-0 flex-1",children:"thread_not_found"===d.terminalError?(0,U.jsx)("div",{className:"flex h-full items-center justify-center p-6 text-center",children:(0,U.jsxs)("div",{children:[(0,U.jsx)("h2",{className:"font-semibold",children:"Thread not found"}),(0,U.jsx)(a$.Button,{className:"mt-3",variant:"outline",onClick:n,children:"Back to Overview"})]})}):(0,U.jsx)(dl,{messages:d.messages,contextRefs:d.contextRefs,status:d.status,activeTurnId:d.activeTurnId,pendingApprovalIds:d.pendingApprovalIds,queueLength:d.queueLength,loading:d.threadLoading,hasEarlierMessages:d.hasEarlierMessages,loadingEarlierMessages:d.loadingEarlierMessages,connected:d.isConnected,error:d.error,initialDraft:_.current.get(N)??"",onDraftChange:e=>{e?_.current.set(N,e):_.current.delete(N)},onDraftSent:e=>{_.current.get(N)===e&&_.current.delete(N)},onSend:d.sendMessage,onLoadEarlierMessages:d.loadEarlierMessages,onStop:d.stopTurn,onResolveApproval:d.resolveToolApproval,onSelectWorkspace:d.selectWorkspace,onOpenContext:a,onOpenAgentSession:o,onOpenScheduleRun:l,onRunScheduleAgain:c},N)}),!E&&u?(0,U.jsx)(l8,{projectId:e,currentThreadId:r,threads:d.threads,contextRefs:d.contextRefs,onNewThread:T,onSelectThread:i,onRenameThread:async(e,r)=>{await d.renameThread(e,r)},onArchiveThread:A,onDeleteThread:M,onOpenContext:a,newThreadPending:x},N):null]}),E?(0,U.jsx)(lm,{open:f,onOpenChange:D,children:(0,U.jsxs)(lv,{side:"right","data-testid":"project-chat-mobile-drawer",className:"w-[min(90vw,360px)] gap-0 p-0","aria-label":"Project Chat threads and context",onCloseAutoFocus:e=>{e.preventDefault(),S.current?.focus()},children:[(0,U.jsxs)(ly,{className:"shrink-0 border-b px-4 py-3 pr-14 text-left",children:[(0,U.jsx)(lb,{className:"text-sm",children:"Threads and context"}),(0,U.jsx)(lw,{className:"text-xs",children:"Switch conversations and open referenced project items."})]}),(0,U.jsx)(l8,{projectId:e,className:"min-h-0 w-full flex-1 border-l-0",currentThreadId:r,threads:d.threads,contextRefs:d.contextRefs,onNewThread:T,onSelectThread:e=>{D(!1),i(e)},onRenameThread:async(e,r)=>{await d.renameThread(e,r)},onArchiveThread:A,onDeleteThread:M,onOpenContext:a?e=>{D(!1),a(e)}:void 0,newThreadPending:x},N)]})}):null]})}function dd(e){let r=(e.targets??[]).map(e=>`${e.targetId}:${e.label}:${e.state}:${e.status??""}:${e.error??""}`).join("|"),s=(e.machines??[]).map(e=>`${e.serverId}:${e.name}:${e.state}:${e.error??""}:${e.deleted?"d":""}`).join("|");return`${r}/${s}`}let du=new Map,dh={staleRemote:null,activeRemoteInvalid:!1};function df(e){return e?"target-not-found"===e.error?e.requestedTarget:e.target:null}function dp(e){let r=[],s=`vibedeckx:mergeTarget:${e}:`;try{for(let e=0;e<localStorage.length;e+=1){let n=localStorage.key(e);if(!n?.startsWith(s))continue;let i=localStorage.getItem(n);i&&r.push({key:n,branch:n.slice(s.length),target:i})}}catch{}return r}let dm=new Map,dg=new Set(["working","main-running","main-waiting"]),dx=new Map,dv=new Map;function dy(e,r){return`vibedeckx:schedule-rerun:v2:${encodeURIComponent(e)}:${encodeURIComponent(r)}`}function db(e){try{window.sessionStorage.removeItem(e)}catch{}}let dw=(0,rE.default)("play",[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]]);var r0=rQ;let d_=(0,rE.default)("anchor",[["path",{d:"M12 6v16",key:"nqf5sj"}],["path",{d:"m19 13 2-1a9 9 0 0 1-18 0l2 1",key:"y7qv08"}],["path",{d:"M9 11h6",key:"1fldmi"}],["circle",{cx:"12",cy:"4",r:"2",key:"muu5ef"}]]),dS=(0,rE.default)("columns-3",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"M15 3v18",key:"14nvp0"}]]),dk=(0,rE.default)("settings",[["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"}]]),dj=(0,rE.default)("wifi-off",[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}],["path",{d:"M5 12.859a10 10 0 0 1 5.17-2.69",key:"1dl1wf"}],["path",{d:"M19 12.859a10 10 0 0 0-2.007-1.523",key:"4k23kn"}],["path",{d:"M2 8.82a15 15 0 0 1 4.177-2.643",key:"1grhjp"}],["path",{d:"M22 8.82a15 15 0 0 0-11.288-3.764",key:"z3jwby"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]),dC={sm:{box:"size-4 rounded",text:"text-[9.5px]",icon:"size-2.5",letters:1},md:{box:"size-5 rounded-[5px]",text:"text-[9px]",icon:"size-3",letters:2}};function dN({name:e,size:r="sm",className:s}){let n=dC[r],i=aT(e,n.letters);return(0,U.jsx)("span",{"aria-hidden":"true",className:(0,e1.cn)("grid shrink-0 place-items-center bg-primary/14 font-mono font-semibold leading-none tracking-[-0.02em] text-primary",n.box,n.text,s),children:i||(0,U.jsx)(le,{className:(0,e1.cn)(n.icon,"text-primary")})})}let dE=(0,rE.default)("check-check",[["path",{d:"M18 6 7 17l-5-5",key:"116fxf"}],["path",{d:"m22 10-7.5 7.5L13 16",key:"ke71qq"}]]);function dD({repositoryLabel:e,onClick:r}){let s,n=(s="Uncommitted changes",e?`${s} \xb7 ${e}`:s);return(0,U.jsxs)(cP,{children:[(0,U.jsx)(cF,{asChild:!0,children:(0,U.jsx)("button",{onClick:e=>{e.stopPropagation(),r()},"aria-label":n,className:"shrink-0 flex items-center justify-center h-4 min-w-4 px-0.5 rounded hover:bg-muted",children:(0,U.jsx)("span",{className:"h-1.5 w-1.5 rounded-full bg-orange-400"})})}),(0,U.jsx)(cL,{side:"right",children:n})]})}function dT({info:e,repositoryLabel:r,onClick:s}){let n=function(e,r){if("target-not-found"===e.error){let s=`Target branch '${e.requestedTarget}' not found — pick a new target or reset to default`;return r?`${s} \xb7 ${r}`:s}let s=["merged"===e.status?`Merged into ${e.target}`:"no-unique-commits"===e.status?`In sync with ${e.target}`:`${e.unmergedCount} commit${1!==e.unmergedCount?"s":""} not in ${e.target}`];return e.dirty&&s.push("uncommitted changes"),r&&s.push(r),s.join(" · ")}(e,r);return(0,U.jsxs)(cP,{children:[(0,U.jsx)(cF,{asChild:!0,children:(0,U.jsxs)("button",{onClick:e=>{e.stopPropagation(),s()},"aria-label":n,className:"relative shrink-0 flex items-center justify-center h-4 min-w-4 px-0.5 rounded hover:bg-muted",children:["target-not-found"===e.error?(0,U.jsx)(ou,{className:"h-3 w-3 text-amber-500"}):"merged"===e.status?(0,U.jsx)(al.Check,{className:"h-3 w-3 text-muted-foreground/70"}):"no-unique-commits"===e.status?(0,U.jsx)(dE,{className:"h-3 w-3 text-emerald-500"}):(0,U.jsx)("span",{className:"text-[10px] font-mono leading-none text-amber-500",children:e.unmergedCount}),!e.error&&e.dirty&&(0,U.jsx)("span",{className:"absolute -top-0.5 -right-0.5 h-1.5 w-1.5 rounded-full bg-orange-400"})]})}),(0,U.jsx)(cL,{side:"right",children:n})]})}let dR=(0,rE.default)("circle-question-mark",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);var dA=e.i(740770);function dM({machine:e,primary:r}){let s="error"===e.state||!!e.error;return(0,U.jsxs)("div",{className:"flex items-center gap-x-1.5 whitespace-nowrap text-background/70",children:[(0,U.jsx)(dI,{state:e.state}),(0,U.jsx)("span",{className:"text-background",children:e.name}),(0,U.jsx)("span",{className:(0,e1.cn)(s&&"text-red-400 dark:text-red-600"),children:(0,dA.machineStateText)(e)}),r&&(0,U.jsx)("span",{className:"ml-auto pl-3 text-background/60",children:"[primary]"})]})}function dI({state:e}){let r="h-3 w-3 shrink-0";switch(e){case"present":return(0,U.jsx)(al.Check,{className:(0,e1.cn)(r,"text-background"),"aria-label":"has it"});case"absent":return(0,U.jsx)(rD,{className:r,"aria-label":"does not have it"});case"error":return(0,U.jsx)(ou,{className:(0,e1.cn)(r,"text-red-400 dark:text-red-600"),"aria-label":"failed"});case"creating":case"deleting":return(0,U.jsx)(aP,{className:(0,e1.cn)(r,"animate-spin"),"aria-label":"in progress"});case"unknown":return(0,U.jsx)(dR,{className:r,"aria-label":"not checked"})}}let dP=(0,rE.default)("git-merge",[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M6 21V9a9 9 0 0 0 9 9",key:"7kw0sc"}]]);function dF({projectId:e,branch:r,currentTarget:s,onTargetChange:n,onTargetReset:i,onDelete:a,onManageRemotes:o}){let[l,c]=(0,V.useState)(null),d=async()=>{null!==l||c((await aC.api.getProjectBranches(e)).filter(e=>e!==r))};return(0,U.jsxs)(i3,{children:[(0,U.jsx)(i4,{asChild:!0,children:(0,U.jsx)("button",{onClick:e=>e.stopPropagation(),className:"shrink-0 p-0.5 rounded opacity-0 group-hover:opacity-100 data-[state=open]:opacity-100 hover:bg-muted transition-all",title:"Workspace menu",children:(0,U.jsx)(lD,{className:"h-3 w-3"})})}),(0,U.jsxs)(i6,{side:"right",align:"start",children:[(0,U.jsxs)(as,{children:[(0,U.jsxs)(an,{onPointerEnter:d,onFocus:d,children:[(0,U.jsx)(dP,{className:"h-3.5 w-3.5 mr-1.5"}),"Compare against"]}),(0,U.jsxs)(ai,{children:[null===l?(0,U.jsx)(i7,{disabled:!0,children:"Loading…"}):0===l.length?(0,U.jsx)(i7,{disabled:!0,children:"No other branches"}):l.map(e=>(0,U.jsx)(i8,{checked:e===s,onCheckedChange:()=>n(e),children:(0,U.jsx)("span",{className:"font-mono text-xs",children:e})},e)),(0,U.jsx)(ar,{}),(0,U.jsx)(i7,{onClick:i,children:(0,U.jsx)("span",{className:"text-xs",children:"Default branch (auto)"})})]})]}),o&&(0,U.jsxs)(i7,{onClick:o,children:[(0,U.jsx)(oj,{className:"h-3.5 w-3.5 mr-1.5"}),"Manage remotes…"]}),(0,U.jsxs)(i7,{onClick:a,className:"text-destructive focus:text-destructive",children:[(0,U.jsx)(ok,{className:"h-3.5 w-3.5 mr-1.5"}),"Delete worktree"]})]})]})}function dL({projectId:e,anchoredBranch:r,onAnchorChange:s}){let[n,i]=(0,V.useState)({}),a=n[e]??null,o=async()=>{if(null!==a)return;let r=await aC.api.getProjectBranches(e);i(s=>({...s,[e]:r}))};return(0,U.jsxs)(i3,{children:[(0,U.jsx)(i4,{asChild:!0,children:(0,U.jsx)("button",{onClick:e=>e.stopPropagation(),className:"shrink-0 p-0.5 rounded opacity-0 group-hover:opacity-100 data-[state=open]:opacity-100 hover:bg-muted transition-all",title:"Workspace menu",children:(0,U.jsx)(lD,{className:"h-3 w-3"})})}),(0,U.jsx)(i6,{side:"right",align:"start",children:(0,U.jsxs)(as,{children:[(0,U.jsxs)(an,{onPointerEnter:o,onFocus:o,children:[(0,U.jsx)(d_,{className:"h-3.5 w-3.5 mr-1.5"}),"Anchor to branch"]}),(0,U.jsx)(ai,{children:null===a?(0,U.jsx)(i7,{disabled:!0,children:"Loading…"}):0===a.length?(0,U.jsx)(i7,{disabled:!0,children:"No branches"}):a.map(e=>(0,U.jsx)(i8,{checked:e===r,onCheckedChange:()=>{e!==r&&s(e)},children:(0,U.jsx)("span",{className:"font-mono text-xs",children:e})},e))})]})})]})}let dO=new Set(["/","-","_","."," "]);function dB(e,r){let s=e.toLowerCase().replace(/\s+/g,"");if(!s)return null;let n=r.toLowerCase(),i=r.lastIndexOf("/")+1,a=0,o=0,l=-2;for(let e=0;e<s.length;e++){let c=s[e],d=-1;for(;o<n.length;o++)if(n[o]===c){d=o;break}if(-1===d)return null;let u=1;d===l+1&&(u+=5),d>=i&&(u+=3);let h=d>0?r[d-1]:"/";(0===d||d===i||dO.has(h))&&(u+=4),a+=u,l=d,o=d+1}return a+.1*Math.max(0,40-r.length)}let dz=e=>e instanceof HTMLElement&&("INPUT"===e.tagName||"TEXTAREA"===e.tagName||"SELECT"===e.tagName||e.isContentEditable);function d$({query:e,matchCount:r}){return(0,U.jsxs)("div",{className:"pointer-events-none fixed bottom-0 left-0 z-50 flex max-w-[360px] items-center gap-2 rounded-tr-md border-t border-r border-border bg-popover px-2.5 py-1",children:[(0,U.jsx)(aK,{className:"h-3 w-3 shrink-0 text-muted-foreground"}),(0,U.jsx)("span",{className:(0,e1.cn)("min-w-0 truncate font-mono text-xs leading-4",0===r?"text-destructive":"text-foreground"),children:e}),(0,U.jsx)("span",{className:"shrink-0 text-[10px] text-muted-foreground/80",children:r})]})}let dW=(0,V.createContext)({engaged:null,registerScope:()=>()=>{}}),dH=e=>e instanceof Element&&null!==e.closest('[role="dialog"],[role="alertdialog"],[role="menu"],[role="listbox"]'),dU=e=>{e.preventDefault(),e.stopPropagation()};function dV(e,r){let s=[],n=null,i=-1/0;for(let a of e.getItems()){let e=dB(r,a.text);null!==e&&(s.push(a.id),e>i&&(i=e,n=a.id))}return{scopeId:e.id,label:e.label,query:r,matchIds:s,selectedId:n}}function dq({children:e}){let r=(0,V.useRef)(new Map),[s,n]=(0,V.useState)(null),i=(0,V.useRef)(null);(0,V.useEffect)(()=>{i.current=s},[s]);let a=(0,V.useCallback)(()=>{n(null)},[]),o=(0,V.useCallback)(e=>(r.current.set(e.id,e),()=>{r.current.delete(e.id),i.current?.scopeId===e.id&&a()}),[a]);(0,V.useEffect)(()=>{let e=e=>{n(e)},s=s=>{let n=i.current;if(!n){if(s.defaultPrevented||s.metaKey||s.ctrlKey||s.altKey||1!==s.key.length||" "===s.key||"?"===s.key||dz(s.target)||dH(s.target))return;let n=(()=>{let e=null;for(let s of r.current.values())(!e||s.priority>e.priority)&&(e=s);return e})();if(!n)return;let i=dV(n,s.key);dU(s),e(i);return}if(dz(s.target)||dH(s.target))return void a();let o=r.current.get(n.scopeId);if(!o)return void a();if("Escape"===s.key){dU(s),a();return}if("Enter"===s.key||" "===s.key&&o.onSecondaryCommit){dU(s);let e=null!==n.selectedId?o.getItems().find(e=>e.id===n.selectedId):void 0,r="Enter"===s.key?o.onCommit:o.onSecondaryCommit;a(),e&&r(e);return}if("ArrowDown"===s.key||"ArrowUp"===s.key){dU(s);let r=n.matchIds.length;if(0===r)return;let i=null!==n.selectedId?n.matchIds.indexOf(n.selectedId):-1,a="ArrowDown"===s.key?(i+1)%r:(i-1+r)%r;e({...n,selectedId:n.matchIds[a]});return}if("Backspace"===s.key){dU(s);let r=n.query.slice(0,-1);return r?void e(dV(o,r)):void a()}if("Tab"===s.key){dU(s);let i=[...r.current.values()].sort((e,r)=>r.priority-e.priority);if(i.length>1){let r=i.findIndex(e=>e.id===n.scopeId);e(dV(i[(r+1)%i.length],n.query))}return}if(1===s.key.length&&!s.metaKey&&!s.ctrlKey&&!s.altKey){dU(s),e(dV(o,n.query+s.key));return}},o=()=>{i.current&&a()},l=e=>{i.current&&(dz(e.target)||dH(e.target))&&a()};return window.addEventListener("keydown",s,!0),window.addEventListener("pointerdown",o,!0),window.addEventListener("focusin",l,!0),()=>{window.removeEventListener("keydown",s,!0),window.removeEventListener("pointerdown",o,!0),window.removeEventListener("focusin",l,!0)}},[a]);let l=(0,V.useMemo)(()=>({engaged:s,registerScope:o}),[s,o]);return(0,U.jsxs)(dW.Provider,{value:l,children:[e,s&&(0,U.jsx)(d$,{query:s.query,matchCount:s.matchIds.length})]})}function dK(e,r){let{registerScope:s}=(0,V.useContext)(dW),n=(0,V.useRef)(e);(0,V.useEffect)(()=>{n.current=e},[e]),(0,V.useEffect)(()=>{if(r)return s({id:n.current.id,label:n.current.label,priority:n.current.priority,getItems:()=>n.current.getItems(),onCommit:e=>n.current.onCommit(e),onSecondaryCommit:n.current.onSecondaryCommit?e=>n.current.onSecondaryCommit?.(e):void 0})},[r,s])}function dX(e){let{engaged:r}=(0,V.useContext)(dW);return(0,V.useMemo)(()=>r&&r.scopeId===e?{query:r.query,label:r.label,matchSet:new Set(r.matchIds),matchCount:r.matchIds.length,selectedId:r.selectedId}:null,[r,e])}function dY({text:e,query:r}){let s=(0,V.useMemo)(()=>{let s=function(e,r){let s=e.toLowerCase().replace(/\s+/g,"");if(!s)return null;let n=r.toLowerCase(),i=[],a=0;for(let e=0;e<s.length;e++){let r=s[e],o=-1;for(;a<n.length;a++)if(n[a]===r){o=a;break}if(-1===o)return null;i.push(o),a=o+1}return i}(r,e);return s?function(e,r){let s=new Set(r),n=[];for(let[r,i]of Array.from(e).entries()){let e=n[n.length-1];e&&e.hit===s.has(r)?e.text+=i:n.push({text:i,hit:s.has(r)})}return n}(e,s):null},[r,e]);return s?(0,U.jsx)(U.Fragment,{children:s.map((e,r)=>e.hit?(0,U.jsx)("span",{className:"rounded-[2px] bg-primary/40",children:e.text},r):e.text)}):(0,U.jsx)(U.Fragment,{children:e})}let dG=(0,V.createContext)({region:"default",setRegion:()=>{}});function dJ(){return(0,V.useContext)(dG)}let dZ=e=>{let r=e instanceof Element?e.closest("[data-focus-region]"):null;return r?"right-panel"===r.getAttribute("data-focus-region")?"right-panel":"default":null},dQ=()=>null!==document.querySelector('[data-state="open"]:is([role="dialog"],[role="alertdialog"],[role="menu"],[role="listbox"])');function d0({children:e}){let[r,s]=(0,V.useState)("default");(0,V.useEffect)(()=>{let e=e=>{let r=dZ(e.target);r&&s(r)},r=e=>{let r=dZ(e.target);r&&s(r)},n=e=>{if("Escape"===e.key&&!e.defaultPrevented&&!dQ()){if(dz(e.target))return void e.target.blur();s("default")}};return window.addEventListener("pointerdown",e,!0),window.addEventListener("focusin",r,!0),window.addEventListener("keydown",n),()=>{window.removeEventListener("pointerdown",e,!0),window.removeEventListener("focusin",r,!0),window.removeEventListener("keydown",n)}},[]);let n=(0,V.useMemo)(()=>({region:r,setRegion:s}),[r]);return(0,U.jsx)(dG.Provider,{value:n,children:e})}function d1({status:e}){let r="relative h-[7px] w-[7px] rounded-full shrink-0";return e&&"idle"!==e?"working"===e?(0,U.jsx)("span",{className:(0,e1.cn)(r,"bg-blue-500"),children:(0,U.jsx)("span",{className:"absolute inset-[-2px] rounded-full bg-blue-500",style:{animation:"status-dot-pulse 1.6s ease-out infinite",opacity:.5}})}):"main-running"===e?(0,U.jsx)("span",{className:(0,e1.cn)(r,"bg-violet-500"),children:(0,U.jsx)("span",{className:"absolute inset-[-2px] rounded-full bg-violet-500",style:{animation:"status-dot-pulse 1.6s ease-out infinite",opacity:.5}})}):"main-waiting"===e?(0,U.jsx)("span",{className:(0,e1.cn)(r,"border-[1.5px] border-violet-500 bg-transparent"),children:(0,U.jsx)("span",{className:"absolute inset-[-2px] rounded-full border border-violet-500",style:{animation:"status-dot-pulse 2.4s ease-out infinite",opacity:.4}})}):"main-completed"===e?(0,U.jsx)("span",{className:(0,e1.cn)(r,"bg-emerald-500")}):"stopped"===e?(0,U.jsx)("span",{className:(0,e1.cn)(r,"bg-amber-500")}):(0,U.jsx)("span",{className:(0,e1.cn)(r,"bg-lime-400")}):(0,U.jsx)("span",{className:(0,e1.cn)(r,"bg-muted-foreground/40")})}function d2({status:e}){let r="relative h-[7px] w-[7px] rounded-full shrink-0";return"running"===e?(0,U.jsx)("span",{className:(0,e1.cn)(r,"bg-blue-500"),children:(0,U.jsx)("span",{className:"absolute inset-[-2px] rounded-full bg-blue-500",style:{animation:"status-dot-pulse 1.6s ease-out infinite",opacity:.5}})}):"error"===e?(0,U.jsx)("span",{className:(0,e1.cn)(r,"bg-red-500")}):"preparing"===e?(0,U.jsx)("span",{className:(0,e1.cn)(r,"bg-muted-foreground/60"),children:(0,U.jsx)("span",{className:"absolute inset-[-2px] rounded-full bg-muted-foreground/60",style:{animation:"status-dot-pulse 2.4s ease-out infinite",opacity:.4}})}):(0,U.jsx)("span",{className:(0,e1.cn)(r,"bg-lime-400")})}function d5({schedule:e}){let r="relative h-[7px] w-[7px] rounded-full shrink-0";if(e.running)return(0,U.jsx)("span",{className:(0,e1.cn)(r,"bg-blue-500"),children:(0,U.jsx)("span",{className:"absolute inset-[-2px] rounded-full bg-blue-500",style:{animation:"status-dot-pulse 1.6s ease-out infinite",opacity:.5}})});let s=e.last_run;return s&&"skipped"!==s.status?"completed"===s.status?(0,U.jsx)("span",{className:(0,e1.cn)(r,"bg-emerald-500")}):"failed"===s.status||"timeout"===s.status||"killed"===s.status?(0,U.jsx)("span",{className:(0,e1.cn)(r,"bg-red-500")}):(0,U.jsx)("span",{className:(0,e1.cn)(r,"bg-blue-500")}):(0,U.jsx)("span",{className:(0,e1.cn)(r,"bg-muted-foreground/40")})}function d3({children:e,className:r}){return(0,U.jsx)("div",{className:(0,e1.cn)("px-2 pt-2.5 pb-1.5 border-t border-border/50 first:border-t-0",r),children:e})}function d4({children:e,action:r}){return(0,U.jsxs)("div",{className:"flex items-center justify-between px-2 py-1 text-[10px] font-semibold uppercase tracking-[0.06em] text-muted-foreground/80",children:[(0,U.jsx)("span",{children:e}),r]})}function d6({icon:e,label:r,active:s,disabled:n,onClick:i}){return(0,U.jsxs)("button",{onClick:i,disabled:n,className:(0,e1.cn)("relative w-full flex items-center gap-[9px] rounded-md px-2 py-[5px] text-[12.5px] font-normal transition-colors",n&&"text-muted-foreground/40 cursor-not-allowed",!n&&!s&&"text-foreground/75 hover:bg-muted hover:text-foreground",s&&"bg-card text-foreground font-medium shadow-sm"),children:[s&&(0,U.jsx)("span",{className:"absolute -left-2 top-1.5 bottom-1.5 w-[2px] rounded-full bg-primary"}),(0,U.jsx)("span",{className:(0,e1.cn)("shrink-0 flex items-center justify-center",s?"text-foreground":"text-muted-foreground"),children:e}),(0,U.jsx)("span",{className:"truncate text-left",children:r})]})}function d7({activeView:e,onViewChange:r,worktrees:s,worktreesStale:n,staleRemoteName:i,activeRemoteInvalid:a,selectedBranch:o,onBranchChange:l,currentProject:c,onCreateWorktreeOpen:d,onDeleteWorktree:u,onManageWorkspaceRemotes:h,onAnchorRootWorkspace:f,onSetRootWorkspaceBranch:p,mergeStatuses:m,mergeRootDirty:g,mergeDefaultTarget:x,mergeRepositoryLabel:v,mergeRepositoryServerId:y,onMergeTargetChange:b,onMergeBadgeClick:w,workspaceStatuses:_,residentSessions:S,selectedSessionId:k,onResidentSessionSelect:j,hasProject:C=!0,projects:N,onSelectProject:E,onCreateProjectOpen:D,schedules:T,selectedScheduleId:R,onScheduleSelect:A,onCreateScheduleOpen:M,tasks:I,selectedTaskId:P,onTasksOpen:F,onTaskSelect:L,onCreateTaskOpen:O}){let B=(0,V.useRef)(null),z=(0,V.useRef)(null),{inProgressTasks:$,openTaskCount:W}=(0,V.useMemo)(()=>{let e=(I??[]).filter(e=>null===e.archived_at);return{inProgressTasks:e.filter(e=>"in_progress"===e.status),openTaskCount:e.filter(e=>"todo"===e.status||"in_progress"===e.status).length}},[I]),{region:H}=dJ(),q=dX("workspaces");dK({id:"workspaces",label:"Workspaces",priority:0,getItems:()=>(s??[]).map(e=>({id:e.branch??"__main__",text:e.branch??e.expectedBranch??"main"})),onCommit:e=>{let n=(s??[]).find(r=>(r.branch??"__main__")===e.id);n&&(l?.(n.branch),r("workspace"))}},!!(c&&s&&s.length>0&&"default"===H));let K=q?.selectedId??null;return(0,V.useEffect)(()=>{null!==K&&document.querySelector(`[data-locate-id="${CSS.escape(K)}"]`)?.scrollIntoView({block:"nearest"})},[K]),(0,V.useEffect)(()=>{B.current?.scrollIntoView({block:"nearest"})},[c?.id,N]),(0,V.useEffect)(()=>{z.current?.scrollIntoView({block:"nearest"})},[R,e,T]),(0,U.jsxs)("nav",{"data-focus-region":"default",className:"w-[220px] border-r border-border bg-sidebar flex flex-col overflow-hidden",children:[(0,U.jsxs)(d3,{children:[(0,U.jsx)(d4,{action:(0,U.jsx)("button",{onClick:D,className:"p-0.5 rounded hover:bg-muted hover:text-foreground transition-colors text-muted-foreground",title:"Create new project",children:(0,U.jsx)(oS,{className:"h-3 w-3"})}),children:"Projects"}),N&&N.length>0?(0,U.jsx)(cI,{delayDuration:300,children:(0,U.jsx)("div",{className:"flex flex-col gap-0.5 max-h-40 overflow-y-auto mt-0.5",children:N.map(s=>{let n=c?.id===s.id,i=n&&("project-info"===e||"project-chat"===e);return(0,U.jsxs)(cP,{children:[(0,U.jsx)(cF,{asChild:!0,children:(0,U.jsxs)("button",{ref:n?B:void 0,onClick:()=>{E?.(s),r("project-info")},className:(0,e1.cn)("relative w-full flex items-center gap-1.5 rounded-md px-2 py-[5px] text-[12.5px] transition-colors min-w-0","hover:bg-muted hover:text-foreground",n?"text-foreground font-medium":"text-foreground/75"),children:[i&&(0,U.jsx)("span",{className:"absolute -left-2 top-1.5 bottom-1.5 w-[2px] rounded-full bg-primary"}),(0,U.jsx)(dN,{name:s.name}),(0,U.jsx)("span",{className:"truncate flex-1 text-left",children:s.name}),n&&(0,U.jsx)(o_,{className:"h-3 w-3 shrink-0 text-muted-foreground ml-auto"})]})}),(0,U.jsx)(cL,{side:"right",children:s.name})]},s.id)})})}):(0,U.jsx)("span",{className:"block px-2 mt-1 text-[11.5px] text-muted-foreground/60",children:"No projects yet"})]}),(0,U.jsxs)(d3,{children:[(0,U.jsx)(d4,{action:C?(0,U.jsx)("button",{onClick:()=>{l?.(null),O?.()},className:"p-0.5 rounded hover:bg-muted hover:text-foreground transition-colors text-muted-foreground",title:"Create task",children:(0,U.jsx)(oS,{className:"h-3 w-3"})}):void 0,children:"Tasks"}),C&&$.length>0&&(0,U.jsx)("div",{className:"flex flex-col gap-px max-h-40 overflow-y-auto",children:$.map(r=>{let s="tasks"===e&&P===r.id;return(0,U.jsxs)("button",{onClick:()=>{l?.(null),L?.(r)},title:r.title,className:(0,e1.cn)("w-full min-w-0 flex items-center gap-2 rounded-[5px] px-2 py-1 text-[11.5px] transition-colors overflow-hidden",!s&&"text-foreground/80 hover:bg-muted",s&&"bg-accent text-accent-foreground font-medium"),children:[(0,U.jsx)("span",{className:"h-[7px] w-[7px] rounded-full shrink-0 bg-blue-500"}),(0,U.jsx)("span",{className:"truncate text-left flex-1",children:r.title}),null!==r.assigned_branch&&(0,U.jsx)("span",{className:"shrink-0 max-w-[64px] truncate font-mono text-[10px] text-muted-foreground",children:""===r.assigned_branch?"main":r.assigned_branch})]},r.id)})}),(0,U.jsxs)("button",{onClick:()=>{C&&(l?.(null),F?.())},disabled:!C,className:(0,e1.cn)("w-full flex items-center gap-2 rounded-[5px] px-2 py-1 text-[11.5px] transition-colors",!C&&"text-muted-foreground/40 cursor-not-allowed",C&&"tasks"===e&&!P?"bg-accent text-accent-foreground font-medium":C&&"text-muted-foreground hover:bg-muted hover:text-foreground"),children:[(0,U.jsx)(on,{className:"h-3 w-3 shrink-0"}),(0,U.jsx)("span",{className:"flex-1 text-left",children:"All tasks"}),C&&W>0&&(0,U.jsx)("span",{className:"tabular-nums text-[10.5px] text-muted-foreground",children:W})]})]}),(0,U.jsxs)(d3,{children:[(0,U.jsx)(d4,{action:c?(0,U.jsx)("button",{onClick:M,className:"p-0.5 rounded hover:bg-muted hover:text-foreground transition-colors text-muted-foreground",title:"Create scheduled task",children:(0,U.jsx)(oS,{className:"h-3 w-3"})}):void 0,children:"Schedule"}),c&&T&&T.length>0&&(0,U.jsx)("div",{className:"flex flex-col gap-px max-h-40 overflow-y-auto",children:T.map(r=>{let s="schedules"===e&&R===r.id;return(0,U.jsxs)("button",{ref:s?z:void 0,onClick:()=>A?.(r.id),className:(0,e1.cn)("w-full min-w-0 flex items-center gap-2 rounded-[5px] px-2 py-1 text-[11.5px] transition-colors overflow-hidden",!s&&"text-foreground/80 hover:bg-muted",s&&"bg-accent text-accent-foreground font-medium",!r.enabled&&"opacity-50"),children:[(0,U.jsx)(d5,{schedule:r}),(0,U.jsx)("span",{className:"truncate text-left flex-1",children:r.name})]},r.id)})}),c&&T&&0===T.length&&(0,U.jsx)("span",{className:"block px-2 mt-1 text-[11.5px] text-muted-foreground/60",children:"No scheduled tasks"})]}),(0,U.jsxs)(d3,{className:"flex-1 min-h-0 flex flex-col",children:[(0,U.jsx)(d4,{action:c?(0,U.jsx)("button",{onClick:d,className:"p-0.5 rounded hover:bg-muted hover:text-foreground transition-colors text-muted-foreground",title:"Create new workspace",children:(0,U.jsx)(oS,{className:"h-3 w-3"})}):void 0,children:"Workspace"}),(0,U.jsxs)("div",{className:"flex-1 min-h-0 overflow-y-auto",children:[c&&a&&(0,U.jsxs)("div",{role:"status",className:"mx-1 mb-1 flex items-start gap-1.5 rounded-[3px] border border-amber-500/30 bg-amber-500/10 px-2 py-1 text-[10.5px] text-amber-700 dark:text-amber-400",children:[(0,U.jsx)(ou,{className:"mt-px h-3 w-3 shrink-0"}),(0,U.jsx)("span",{children:"Sessions target a remote this project no longer has. Pick one in the session header."})]}),c&&i&&(0,U.jsxs)("div",{role:"status",className:"mx-1 mb-1 flex items-start gap-1.5 rounded-[3px] border bg-muted/60 px-2 py-1 text-[10.5px] text-muted-foreground",children:[(0,U.jsx)(dj,{className:"mt-px h-3 w-3 shrink-0"}),(0,U.jsxs)("span",{children:[i," is offline; this list may not be current."]})]}),c&&s&&s.length>0&&(0,U.jsx)(U.Fragment,{children:(0,U.jsx)(cI,{delayDuration:300,children:(0,U.jsx)("div",{className:"flex flex-col gap-px",children:s.map(s=>{var i;let a="workspace"===e&&!n&&o===s.branch,d=null===s.branch?"":s.branch,C=void 0!==s.currentBranch,N=s.currentBranch??"detached HEAD",E=s.branch??s.expectedBranch??"main",D=S?.get(d)??[],T=(i=_?.get(d),D.length>0&&"main-running"!==i&&"main-waiting"!==i&&"main-completed"!==i?"idle":i),R=s.branch??"__main__",A=q?.matchSet.has(R)??!1,M=q?.selectedId===R,I=null!==s.branch?s.machines??(s.targets?(0,dA.machinesFromTargets)(s.targets):void 0):void 0,P=I?.find(e=>e.serverId===y),F=P?.state==="absent"||P?.state==="error";return(0,U.jsxs)("div",{"data-locate-id":R,className:(0,e1.cn)("min-w-0 rounded-[3px]",a&&"bg-accent",q&&!A&&"opacity-40",q&&A&&!M&&"bg-muted",M&&"bg-accent"),children:[(0,U.jsxs)("div",{className:"group relative flex items-center min-w-0 gap-0.5 pr-1",children:[(0,U.jsxs)(cP,{children:[(0,U.jsx)(cF,{asChild:!0,children:(0,U.jsxs)("button",{onClick:()=>{l?.(s.branch),r("workspace")},className:(0,e1.cn)("flex-1 min-w-0 flex items-center gap-2 rounded-[3px] pl-2 pr-1 py-1 font-mono text-[11.5px] transition-colors overflow-hidden",!a&&"text-foreground/80 hover:bg-muted",a&&"text-accent-foreground font-medium"),children:[(0,U.jsx)(d1,{status:T}),(0,U.jsxs)("span",{className:(0,e1.cn)("truncate text-left",A&&"text-foreground"),children:[q&&A?(0,U.jsx)(dY,{text:E,query:q.query}):E,C&&(0,U.jsxs)("span",{className:"text-amber-600 dark:text-amber-400",children:[" → ",N]})]})]})}),(0,U.jsx)(cL,{side:"right",children:C?`Workspace branch: ${E}; currently checked out: ${N}`:E})]}),null===s.branch&&s.currentBranch&&(0,U.jsxs)(cP,{children:[(0,U.jsx)(cF,{asChild:!0,children:(0,U.jsx)("button",{onClick:()=>f?.(s.currentBranch),className:"shrink-0 p-0.5 rounded text-amber-600 dark:text-amber-400 hover:bg-muted transition-colors",children:(0,U.jsx)(d_,{className:"h-3 w-3"})})}),(0,U.jsx)(cL,{side:"right",children:`Anchor this workspace to ${s.currentBranch}`})]}),I&&(()=>{let e=(0,dA.workspaceCoverage)(I);if(!e.missing)return null;let r=(0,dA.coverageTooltipLead)(I,{branch:s.branch,currentId:c?.agent_mode??"local",primaryId:y,unfinishedDelete:s.unfinishedDelete});return(0,U.jsxs)(cP,{children:[(0,U.jsx)(cF,{asChild:!0,children:(0,U.jsxs)("button",{onClick:()=>h?.(s),"aria-label":`${E} exists on ${e.present} of ${e.total} remotes`,className:"shrink-0 rounded px-0.5 font-mono text-[9.5px] tabular-nums text-muted-foreground hover:bg-muted hover:text-foreground transition-colors",children:[e.present,"/",e.total]})}),(0,U.jsxs)(cL,{side:"right",children:[(0,U.jsx)("div",{className:"space-y-0.5",children:r.map(e=>(0,U.jsx)("div",{children:e},e))}),(0,U.jsx)("div",{className:"mt-1.5 space-y-0.5",children:I.map(e=>(0,U.jsx)(dM,{machine:e,primary:e.serverId===y},e.serverId))})]})]})})(),null===s.branch&&g&&(0,U.jsx)(dD,{repositoryLabel:v,onClick:()=>w?.(null)}),null!==s.branch&&m?.get(s.branch)&&!F&&(0,U.jsx)(dT,{info:m.get(s.branch),repositoryLabel:v,onClick:()=>w?.(s.branch)}),null===s.branch&&c&&(0,U.jsx)(dL,{projectId:c.id,anchoredBranch:s.expectedBranch??null,onAnchorChange:e=>p?.(e)}),null!==s.branch&&c&&(0,U.jsx)(dF,{projectId:c.id,branch:s.branch,currentTarget:df(m?.get(s.branch))??x??null,onTargetChange:e=>b?.(s.branch,e),onTargetReset:()=>b?.(s.branch,null),onDelete:()=>u?.(s),onManageRemotes:h&&s.machines&&s.machines.length>1?()=>h(s):void 0})]}),D.length>0&&(0,U.jsx)("div",{className:"ml-4 mt-px flex flex-col gap-px",children:D.map(r=>{let s="workspace"===e&&k===r.id;return(0,U.jsxs)(cP,{children:[(0,U.jsx)(cF,{asChild:!0,children:(0,U.jsxs)("button",{onClick:()=>j?.(r),className:(0,e1.cn)("min-w-0 flex items-center gap-1.5 rounded-[3px] py-0.5 pl-1.5 pr-2 font-mono text-[11px] transition-colors",!s&&"text-foreground/70 hover:text-foreground",s&&"text-[oklch(0.42_0.22_268)] dark:text-white font-medium"),children:[(0,U.jsx)("span",{className:"shrink-0 text-muted-foreground/70",children:"└"}),(0,U.jsx)(d2,{status:r.status}),(0,U.jsx)("span",{className:"truncate text-left",children:r.title})]})}),(0,U.jsx)(cL,{side:"right",children:"preparing-review"===r.kind?`${r.title} \xb7 preparing`:r.title})]},r.id)})})]},s.branch??"__main__")})})})}),(!s||0===s.length)&&(0,U.jsx)("div",{className:"mt-0.5",children:(0,U.jsx)(d6,{icon:(0,U.jsx)(dS,{className:"h-3.5 w-3.5"}),label:"Workspace",active:"workspace"===e,onClick:()=>r("workspace")})})]})]}),(0,U.jsx)(d3,{children:(0,U.jsxs)("div",{className:"flex flex-col gap-0.5",children:[(0,U.jsx)(d6,{icon:(0,U.jsx)(oC,{className:"h-3.5 w-3.5"}),label:"Remote Servers",active:"remote-servers"===e,onClick:()=>r("remote-servers")}),(0,U.jsx)(d6,{icon:(0,U.jsx)(dk,{className:"h-3.5 w-3.5"}),label:"Settings",active:"settings"===e,onClick:()=>r("settings")})]})})]})}function d8({title:e,count:r,description:s,actions:n,className:i}){return(0,U.jsxs)("div",{className:(0,e1.cn)("flex items-center justify-between gap-4 px-5 pt-[14px] pb-3 border-b border-border bg-background flex-shrink-0",i),children:[(0,U.jsxs)("div",{className:"min-w-0",children:[(0,U.jsxs)("h1",{className:"flex items-baseline gap-2.5 m-0 text-[17px] font-semibold tracking-[-0.018em] text-foreground",children:[(0,U.jsx)("span",{className:"truncate",children:e}),void 0!==r&&(0,U.jsx)("span",{className:"font-mono text-[11.5px] font-medium text-muted-foreground/80 tracking-normal",children:r})]}),s&&(0,U.jsx)("p",{className:"text-[11.5px] text-muted-foreground mt-0.5",children:s})]}),n&&(0,U.jsx)("div",{className:"flex items-center gap-2",children:n})]})}function d9({children:e,className:r}){return(0,U.jsx)("div",{className:(0,e1.cn)("flex items-center gap-1.5 px-5 py-2 border-b border-border bg-background flex-shrink-0 overflow-x-auto [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",r),children:e})}function ue({active:e,count:r,onClick:s,children:n}){return(0,U.jsxs)("button",{onClick:s,className:(0,e1.cn)("inline-flex items-center gap-1.5 px-2.5 py-[3px] rounded-full text-[11.5px] font-normal transition-colors whitespace-nowrap flex-shrink-0 border",e?"bg-card text-foreground font-medium border-border shadow-sm":"bg-transparent text-muted-foreground border-transparent hover:bg-muted hover:text-foreground"),children:[n,void 0!==r&&(0,U.jsx)("span",{className:(0,e1.cn)("font-mono text-[10.5px] pl-0.5",e?"text-muted-foreground":"text-muted-foreground/70"),children:r})]})}let ut=(0,rE.default)("grip-vertical",[["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}],["circle",{cx:"9",cy:"5",r:"1",key:"hp0tcf"}],["circle",{cx:"9",cy:"19",r:"1",key:"fkjjf6"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["circle",{cx:"15",cy:"19",r:"1",key:"f4zoj3"}]]),ur=(0,V.createContext)(null);ur.displayName="PanelGroupContext";let us="data-panel-group-direction",un="data-panel-group-id",ui="data-resize-handle",ua="data-panel-resize-handle-id",uo=V.useLayoutEffect,ul=V["useId".toString()],uc="function"==typeof ul?ul:()=>null,ud=0;function uu(e=null){let r=uc(),s=(0,V.useRef)(e||r||null);return null===s.current&&(s.current=""+ud++),null!=e?e:s.current}function uh({children:e,className:r="",collapsedSize:s,collapsible:n,defaultSize:i,forwardedRef:a,id:o,maxSize:l,minSize:c,onCollapse:d,onExpand:u,onResize:h,order:f,style:p,tagName:m="div",...g}){let x=(0,V.useContext)(ur);if(null===x)throw Error("Panel components must be rendered within a PanelGroup container");let{collapsePanel:v,expandPanel:y,getPanelSize:b,getPanelStyle:w,groupId:_,isPanelCollapsed:S,reevaluatePanelConstraints:k,registerPanel:j,resizePanel:C,unregisterPanel:N}=x,E=uu(o),D=(0,V.useRef)({callbacks:{onCollapse:d,onExpand:u,onResize:h},constraints:{collapsedSize:s,collapsible:n,defaultSize:i,maxSize:l,minSize:c},id:E,idIsFromProps:void 0!==o,order:f});(0,V.useRef)({didLogMissingDefaultSizeWarning:!1}),uo(()=>{let{callbacks:e,constraints:r}=D.current,a={...r};D.current.id=E,D.current.idIsFromProps=void 0!==o,D.current.order=f,e.onCollapse=d,e.onExpand=u,e.onResize=h,r.collapsedSize=s,r.collapsible=n,r.defaultSize=i,r.maxSize=l,r.minSize=c,(a.collapsedSize!==r.collapsedSize||a.collapsible!==r.collapsible||a.maxSize!==r.maxSize||a.minSize!==r.minSize)&&k(D.current,a)}),uo(()=>{let e=D.current;return j(e),()=>{N(e)}},[f,E,j,N]),(0,V.useImperativeHandle)(a,()=>({collapse:()=>{v(D.current)},expand:e=>{y(D.current,e)},getId:()=>E,getSize:()=>b(D.current),isCollapsed:()=>S(D.current),isExpanded:()=>!S(D.current),resize:e=>{C(D.current,e)}}),[v,y,b,S,E,C]);let T=w(D.current,i);return(0,V.createElement)(m,{...g,children:e,className:r,id:E,style:{...T,...p},[un]:_,"data-panel":"","data-panel-collapsible":n||void 0,"data-panel-id":E,"data-panel-size":parseFloat(""+T.flexGrow).toFixed(1)})}let uf=(0,V.forwardRef)((e,r)=>(0,V.createElement)(uh,{...e,forwardedRef:r}));uh.displayName="Panel",uf.displayName="forwardRef(Panel)";let up=null,um=!0,ug=-1,ux=null;function uv(e,s){var n,i,a;if(!um)return;let o=function(e,r){if(r){let e=(r&uE)!=0,s=(r&uD)!=0,n=(r&uT)!=0,i=(r&uR)!=0;if(e)if(n)return"se-resize";else if(i)return"ne-resize";else return"e-resize";if(s)if(n)return"sw-resize";else if(i)return"nw-resize";else return"w-resize";if(n)return"s-resize";else if(i)return"n-resize"}switch(e){case"horizontal":return"ew-resize";case"intersection":return"move";case"vertical":return"ns-resize"}}(e,s);up!==o&&(up=o,null===ux&&(ux=document.createElement("style"),r&&ux.setAttribute("nonce",r),document.head.appendChild(ux)),ug>=0&&(null==(a=ux.sheet)||a.removeRule(ug)),ug=null!=(n=null==(i=ux.sheet)?void 0:i.insertRule(`*{cursor: ${o} !important;}`))?n:-1)}function uy(e){return"keydown"===e.type}function ub(e){return e.type.startsWith("pointer")}function uw(e){return e.type.startsWith("mouse")}function u_(e){if(ub(e)){if(e.isPrimary)return{x:e.clientX,y:e.clientY}}else if(uw(e))return{x:e.clientX,y:e.clientY};return{x:1/0,y:1/0}}let uS=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function uk(e){let r=e.length;for(;r--;){let s=e[r];if(uK(s,"Missing node"),function(e){var r;let s,n=getComputedStyle(e);return"fixed"===n.position||!!("auto"!==n.zIndex&&("static"!==n.position||"flex"===(s=getComputedStyle(null!=(r=uN(e))?r:e).display)||"inline-flex"===s)||1>+n.opacity||"transform"in n&&"none"!==n.transform||"webkitTransform"in n&&"none"!==n.webkitTransform||"mixBlendMode"in n&&"normal"!==n.mixBlendMode||"filter"in n&&"none"!==n.filter||"webkitFilter"in n&&"none"!==n.webkitFilter||"isolation"in n&&"isolate"===n.isolation||uS.test(n.willChange))||"touch"===n.webkitOverflowScrolling}(s))return s}return null}function uj(e){return e&&Number(getComputedStyle(e).zIndex)||0}function uC(e){let r=[];for(;e;)r.push(e),e=uN(e);return r}function uN(e){let{parentNode:r}=e;return r&&r instanceof ShadowRoot?r.host:r}let uE=1,uD=2,uT=4,uR=8,uA="coarse"===function(){if("function"==typeof matchMedia)return matchMedia("(pointer:coarse)").matches?"coarse":"fine"}(),uM=[],uI=!1,uP=new Map,uF=new Map,uL=new Set;function uO(e){let{target:r}=e,{x:s,y:n}=u_(e);uI=!0,uW({target:r,x:s,y:n}),uV(),uM.length>0&&(uq("down",e),e.preventDefault(),u$(r)||e.stopImmediatePropagation())}function uB(e){let{x:r,y:s}=u_(e);if(uI&&0===e.buttons&&(uI=!1,uq("up",e)),!uI){let{target:n}=e;uW({target:n,x:r,y:s})}uq("move",e),uH(),uM.length>0&&e.preventDefault()}function uz(e){let{target:r}=e,{x:s,y:n}=u_(e);uF.clear(),uI=!1,uM.length>0&&(e.preventDefault(),u$(r)||e.stopImmediatePropagation()),uq("up",e),uW({target:r,x:s,y:n}),uH(),uV()}function u$(e){let r=e;for(;r;){if(r.hasAttribute(ui))return!0;r=r.parentElement}return!1}function uW({target:e,x:r,y:s}){uM.splice(0);let n=null;(e instanceof HTMLElement||e instanceof SVGElement)&&(n=e),uL.forEach(e=>{let{element:i,hitAreaMargins:a}=e,o=i.getBoundingClientRect(),{bottom:l,left:c,right:d,top:u}=o,h=uA?a.coarse:a.fine;if(r>=c-h&&r<=d+h&&s>=u-h&&s<=l+h){if(null!==n&&document.contains(n)&&i!==n&&!i.contains(n)&&!n.contains(i)&&function(e,r){let s;if(e===r)throw Error("Cannot compare node with itself");let n={a:uC(e),b:uC(r)};for(;n.a.at(-1)===n.b.at(-1);)e=n.a.pop(),r=n.b.pop(),s=e;uK(s,"Stacking order can only be calculated for elements with a common ancestor");let i={a:uj(uk(n.a)),b:uj(uk(n.b))};if(i.a===i.b){let e=s.childNodes,r={a:n.a.at(-1),b:n.b.at(-1)},i=e.length;for(;i--;){let s=e[i];if(s===r.a)return 1;if(s===r.b)return -1}}return Math.sign(i.a-i.b)}(n,i)>0){let e=n,r=!1;for(;e;){var f;if(e.contains(i))break;if(f=e.getBoundingClientRect(),f.x<o.x+o.width&&f.x+f.width>o.x&&f.y<o.y+o.height&&f.y+f.height>o.y){r=!0;break}e=e.parentElement}if(r)return}uM.push(e)}})}function uH(){let e=!1,r=!1;uM.forEach(s=>{let{direction:n}=s;"horizontal"===n?e=!0:r=!0});let s=0;uF.forEach(e=>{s|=e}),e&&r?uv("intersection",s):e?uv("horizontal",s):r?uv("vertical",s):null!==ux&&(document.head.removeChild(ux),up=null,ux=null,ug=-1)}let uU=new AbortController;function uV(){uU.abort();let e={capture:!0,signal:(uU=new AbortController).signal};uL.size&&(uI?(uM.length>0&&uP.forEach((r,s)=>{let{body:n}=s;r>0&&(n.addEventListener("contextmenu",uz,e),n.addEventListener("pointerleave",uB,e),n.addEventListener("pointermove",uB,e))}),window.addEventListener("pointerup",uz,e),window.addEventListener("pointercancel",uz,e)):uP.forEach((r,s)=>{let{body:n}=s;r>0&&(n.addEventListener("pointerdown",uO,e),n.addEventListener("pointermove",uB,e))}))}function uq(e,r){uL.forEach(s=>{let{setResizeHandlerState:n}=s;n(e,uM.includes(s),r)})}function uK(e,r){if(!e)throw console.error(r),Error(r)}function uX(e,r,s=10){return e.toFixed(s)===r.toFixed(s)?0:e>r?1:-1}function uY(e,r,s=10){return 0===uX(e,r,s)}function uG(e,r,s){return 0===uX(e,r,s)}function uJ({panelConstraints:e,panelIndex:r,size:s}){let n=e[r];uK(null!=n,`Panel constraints not found for index ${r}`);let{collapsedSize:i=0,collapsible:a,maxSize:o=100,minSize:l=0}=n;return 0>uX(s,l)&&(s=a&&0>uX(s,(i+l)/2)?i:l),s=parseFloat((s=Math.min(o,s)).toFixed(10))}function uZ({delta:e,initialLayout:r,panelConstraints:s,pivotIndices:n,prevLayout:i,trigger:a}){if(uG(e,0))return r;let o=[...r],[l,c]=n;uK(null!=l,"Invalid first pivot index"),uK(null!=c,"Invalid second pivot index");let d=0;if("keyboard"===a){{let n=e<0?c:l,i=s[n];uK(i,`Panel constraints not found for index ${n}`);let{collapsedSize:a=0,collapsible:o,minSize:d=0}=i;if(o){let s=r[n];if(uK(null!=s,`Previous layout not found for panel index ${n}`),uG(s,a)){let r=d-s;uX(r,Math.abs(e))>0&&(e=e<0?0-r:r)}}}{let n=e<0?l:c,i=s[n];uK(i,`No panel constraints found for index ${n}`);let{collapsedSize:a=0,collapsible:o,minSize:d=0}=i;if(o){let s=r[n];if(uK(null!=s,`Previous layout not found for panel index ${n}`),uG(s,d)){let r=s-a;uX(r,Math.abs(e))>0&&(e=e<0?0-r:r)}}}}{let n=e<0?1:-1,i=e<0?c:l,a=0;for(;;){let e=r[i];if(uK(null!=e,`Previous layout not found for panel index ${i}`),a+=uJ({panelConstraints:s,panelIndex:i,size:100})-e,(i+=n)<0||i>=s.length)break}let o=Math.min(Math.abs(e),Math.abs(a));e=e<0?0-o:o}{let n=e<0?l:c;for(;n>=0&&n<s.length;){let i=Math.abs(e)-Math.abs(d),a=r[n];uK(null!=a,`Previous layout not found for panel index ${n}`);let l=uJ({panelConstraints:s,panelIndex:n,size:a-i});if(!uG(a,l)&&(d+=a-l,o[n]=l,d.toPrecision(3).localeCompare(Math.abs(e).toPrecision(3),void 0,{numeric:!0})>=0))break;e<0?n--:n++}}if(function(e,r,s){if(e.length!==r.length)return!1;for(let s=0;s<e.length;s++)if(!uG(e[s],r[s],void 0))return!1;return!0}(i,o))return i;{let n=e<0?c:l,i=r[n];uK(null!=i,`Previous layout not found for panel index ${n}`);let a=i+d,u=uJ({panelConstraints:s,panelIndex:n,size:a});if(o[n]=u,!uG(u,a)){let r=a-u,n=e<0?c:l;for(;n>=0&&n<s.length;){let i=o[n];uK(null!=i,`Previous layout not found for panel index ${n}`);let a=uJ({panelConstraints:s,panelIndex:n,size:i+r});if(uG(i,a)||(r-=a-i,o[n]=a),uG(r,0))break;e>0?n--:n++}}}return uG(o.reduce((e,r)=>r+e,0),100)?o:i}function uQ(e,r=document){return Array.from(r.querySelectorAll(`[${ua}][data-panel-group-id="${e}"]`))}function u0(e,r,s=document){let n=uQ(e,s).findIndex(e=>e.getAttribute(ua)===r);return null!=n?n:null}function u1(e,r,s){let n=u0(e,r,s);return null!=n?[n,n+1]:[-1,-1]}function u2(e,r=document){var s;if(r instanceof HTMLElement&&(null==r||null==(s=r.dataset)?void 0:s.panelGroupId)==e)return r;let n=r.querySelector(`[data-panel-group][data-panel-group-id="${e}"]`);return n||null}function u5(e,r=document){let s=r.querySelector(`[${ua}="${e}"]`);return s||null}function u3(e,r){if(e.length!==r.length)return!1;for(let s=0;s<e.length;s++)if(e[s]!==r[s])return!1;return!0}function u4(e,r){let{x:s,y:n}=u_(r);return"horizontal"===e?s:n}function u6(e,r,s){r.forEach((r,n)=>{let i=e[n];uK(i,`Panel data not found for index ${n}`);let{callbacks:a,constraints:o,id:l}=i,{collapsedSize:c=0,collapsible:d}=o,u=s[l];if(null==u||r!==u){s[l]=r;let{onCollapse:e,onExpand:n,onResize:i}=a;i&&i(r,u),d&&(e||n)&&(n&&(null==u||uY(u,c))&&!uY(r,c)&&n(),e&&(null==u||!uY(u,c))&&uY(r,c)&&e())}})}function u7(e,r){if(e.length!==r.length)return!1;for(let s=0;s<e.length;s++)if(e[s]!=r[s])return!1;return!0}function u8(e){try{if("undefined"!=typeof localStorage)e.getItem=e=>localStorage.getItem(e),e.setItem=(e,r)=>{localStorage.setItem(e,r)};else throw Error("localStorage not supported in this environment")}catch(r){console.error(r),e.getItem=()=>null,e.setItem=()=>{}}}function u9(e){return`react-resizable-panels:${e}`}function he(e){return e.map(e=>{let{constraints:r,id:s,idIsFromProps:n,order:i}=e;return n?s:i?`${i}:${JSON.stringify(r)}`:JSON.stringify(r)}).sort((e,r)=>e.localeCompare(r)).join(",")}function ht(e,r){try{let s=u9(e),n=r.getItem(s);if(n){let e=JSON.parse(n);if("object"==typeof e&&null!=e)return e}}catch(e){}return null}function hr(e,r,s,n,i){var a;let o=u9(e),l=he(r),c=null!=(a=ht(e,i))?a:{};c[l]={expandToSizes:Object.fromEntries(s.entries()),layout:n};try{i.setItem(o,JSON.stringify(c))}catch(e){console.error(e)}}function hs({layout:e,panelConstraints:r}){let s=[...e],n=s.reduce((e,r)=>e+r,0);if(s.length!==r.length)throw Error(`Invalid ${r.length} panel layout: ${s.map(e=>`${e}%`).join(", ")}`);if(!uG(n,100)&&s.length>0)for(let e=0;e<r.length;e++){let r=s[e];uK(null!=r,`No layout data found for index ${e}`);let i=100/n*r;s[e]=i}let i=0;for(let e=0;e<r.length;e++){let n=s[e];uK(null!=n,`No layout data found for index ${e}`);let a=uJ({panelConstraints:r,panelIndex:e,size:n});n!=a&&(i+=n-a,s[e]=a)}if(!uG(i,0))for(let e=0;e<r.length;e++){let n=s[e];uK(null!=n,`No layout data found for index ${e}`);let a=uJ({panelConstraints:r,panelIndex:e,size:n+i});if(n!==a&&(i-=a-n,s[e]=a,uG(i,0)))break}return s}let hn={getItem:e=>(u8(hn),hn.getItem(e)),setItem:(e,r)=>{u8(hn),hn.setItem(e,r)}},hi={};function ha({autoSaveId:e=null,children:r,className:s="",direction:n,forwardedRef:i,id:a=null,onLayout:o=null,keyboardResizeBy:l=null,storage:c=hn,style:d,tagName:u="div",...h}){let f=uu(a),p=(0,V.useRef)(null),[m,g]=(0,V.useState)(null),[x,v]=(0,V.useState)([]),y=function(){let[e,r]=(0,V.useState)(0);return(0,V.useCallback)(()=>r(e=>e+1),[])}(),b=(0,V.useRef)({}),w=(0,V.useRef)(new Map),_=(0,V.useRef)(0),S=(0,V.useRef)({autoSaveId:e,direction:n,dragState:m,id:f,keyboardResizeBy:l,onLayout:o,storage:c}),k=(0,V.useRef)({layout:x,panelDataArray:[],panelDataArrayChanged:!1});(0,V.useRef)({didLogIdAndOrderWarning:!1,didLogPanelConstraintsWarning:!1,prevPanelIds:[]}),(0,V.useImperativeHandle)(i,()=>({getId:()=>S.current.id,getLayout:()=>{let{layout:e}=k.current;return e},setLayout:e=>{let{onLayout:r}=S.current,{layout:s,panelDataArray:n}=k.current,i=hs({layout:e,panelConstraints:n.map(e=>e.constraints)});u3(s,i)||(v(i),k.current.layout=i,r&&r(i),u6(n,i,b.current))}}),[]),uo(()=>{S.current.autoSaveId=e,S.current.direction=n,S.current.dragState=m,S.current.id=f,S.current.onLayout=o,S.current.storage=c}),function({committedValuesRef:e,eagerValuesRef:r,groupId:s,layout:n,panelDataArray:i,panelGroupElement:a,setLayout:o}){(0,V.useRef)({didWarnAboutMissingResizeHandle:!1}),uo(()=>{if(!a)return;let e=uQ(s,a);for(let r=0;r<i.length-1;r++){let{valueMax:s,valueMin:a,valueNow:o}=function({layout:e,panelsArray:r,pivotIndices:s}){let n=0,i=100,a=0,o=0,l=s[0];return uK(null!=l,"No pivot index found"),r.forEach((e,r)=>{let{constraints:s}=e,{maxSize:c=100,minSize:d=0}=s;r===l?(n=d,i=c):(a+=d,o+=c)}),{valueMax:Math.min(i,100-a),valueMin:Math.max(n,100-o),valueNow:e[l]}}({layout:n,panelsArray:i,pivotIndices:[r,r+1]}),l=e[r];if(null==l);else{let e=i[r];uK(e,`No panel data found for index "${r}"`),l.setAttribute("aria-controls",e.id),l.setAttribute("aria-valuemax",""+Math.round(s)),l.setAttribute("aria-valuemin",""+Math.round(a)),l.setAttribute("aria-valuenow",null!=o?""+Math.round(o):"")}}return()=>{e.forEach((e,r)=>{e.removeAttribute("aria-controls"),e.removeAttribute("aria-valuemax"),e.removeAttribute("aria-valuemin"),e.removeAttribute("aria-valuenow")})}},[s,n,i,a]),(0,V.useEffect)(()=>{if(!a)return;let e=r.current;uK(e,"Eager values not found");let{panelDataArray:i}=e;uK(null!=u2(s,a),`No group found for id "${s}"`);let l=uQ(s,a);uK(l,`No resize handles found for group id "${s}"`);let c=l.map(e=>{let r=e.getAttribute(ua);uK(r,"Resize handle element has no handle id attribute");let[l,c]=function(e,r,s,n=document){var i,a,o,l;let c=u5(r,n),d=uQ(e,n),u=c?d.indexOf(c):-1;return[null!=(i=null==(a=s[u])?void 0:a.id)?i:null,null!=(o=null==(l=s[u+1])?void 0:l.id)?o:null]}(s,r,i,a);if(null==l||null==c)return()=>{};let d=e=>{if(!e.defaultPrevented&&"Enter"===e.key){e.preventDefault();let c=i.findIndex(e=>e.id===l);if(c>=0){let e=i[c];uK(e,`No panel data found for index ${c}`);let l=n[c],{collapsedSize:d=0,collapsible:u,minSize:h=0}=e.constraints;if(null!=l&&u){let e=uZ({delta:uG(l,d)?h-d:d-l,initialLayout:n,panelConstraints:i.map(e=>e.constraints),pivotIndices:u1(s,r,a),prevLayout:n,trigger:"keyboard"});n!==e&&o(e)}}}};return e.addEventListener("keydown",d),()=>{e.removeEventListener("keydown",d)}});return()=>{c.forEach(e=>e())}},[a,e,r,s,n,i,o])}({committedValuesRef:S,eagerValuesRef:k,groupId:f,layout:x,panelDataArray:k.current.panelDataArray,setLayout:v,panelGroupElement:p.current}),(0,V.useEffect)(()=>{let{panelDataArray:r}=k.current;if(e){if(0===x.length||x.length!==r.length)return;let s=hi[e];null==s&&(s=function(e,r=10){let s=null;return(...n)=>{null!==s&&clearTimeout(s),s=setTimeout(()=>{e(...n)},r)}}(hr,100),hi[e]=s),s(e,[...r],new Map(w.current),x,c)}},[e,x,c]),(0,V.useEffect)(()=>{});let j=(0,V.useCallback)(e=>{let{onLayout:r}=S.current,{layout:s,panelDataArray:n}=k.current;if(e.constraints.collapsible){let i=n.map(e=>e.constraints),{collapsedSize:a=0,panelSize:o,pivotIndices:l}=hc(n,e,s);if(uK(null!=o,`Panel size not found for panel "${e.id}"`),!uY(o,a)){w.current.set(e.id,o);let c=uZ({delta:hl(n,e)===n.length-1?o-a:a-o,initialLayout:s,panelConstraints:i,pivotIndices:l,prevLayout:s,trigger:"imperative-api"});u7(s,c)||(v(c),k.current.layout=c,r&&r(c),u6(n,c,b.current))}}},[]),C=(0,V.useCallback)((e,r)=>{let{onLayout:s}=S.current,{layout:n,panelDataArray:i}=k.current;if(e.constraints.collapsible){let a=i.map(e=>e.constraints),{collapsedSize:o=0,panelSize:l=0,minSize:c=0,pivotIndices:d}=hc(i,e,n),u=null!=r?r:c;if(uY(l,o)){let r=w.current.get(e.id),o=null!=r&&r>=u?r:u,c=uZ({delta:hl(i,e)===i.length-1?l-o:o-l,initialLayout:n,panelConstraints:a,pivotIndices:d,prevLayout:n,trigger:"imperative-api"});u7(n,c)||(v(c),k.current.layout=c,s&&s(c),u6(i,c,b.current))}}},[]),N=(0,V.useCallback)(e=>{let{layout:r,panelDataArray:s}=k.current,{panelSize:n}=hc(s,e,r);return uK(null!=n,`Panel size not found for panel "${e.id}"`),n},[]),E=(0,V.useCallback)((e,r)=>{let{panelDataArray:s}=k.current,n=hl(s,e);return function({defaultSize:e,dragState:r,layout:s,panelData:n,panelIndex:i,precision:a=3}){let o=s[i];return{flexBasis:0,flexGrow:null==o?void 0!=e?e.toPrecision(a):"1":1===n.length?"1":o.toPrecision(a),flexShrink:1,overflow:"hidden",pointerEvents:null!==r?"none":void 0}}({defaultSize:r,dragState:m,layout:x,panelData:s,panelIndex:n})},[m,x]),D=(0,V.useCallback)(e=>{let{layout:r,panelDataArray:s}=k.current,{collapsedSize:n=0,collapsible:i,panelSize:a}=hc(s,e,r);return uK(null!=a,`Panel size not found for panel "${e.id}"`),!0===i&&uY(a,n)},[]),T=(0,V.useCallback)(e=>{let{layout:r,panelDataArray:s}=k.current,{collapsedSize:n=0,collapsible:i,panelSize:a}=hc(s,e,r);return uK(null!=a,`Panel size not found for panel "${e.id}"`),!i||uX(a,n)>0},[]),R=(0,V.useCallback)(e=>{let{panelDataArray:r}=k.current;r.push(e),r.sort((e,r)=>{let s=e.order,n=r.order;return null==s&&null==n?0:null==s?-1:null==n?1:s-n}),k.current.panelDataArrayChanged=!0,y()},[y]);uo(()=>{if(k.current.panelDataArrayChanged){k.current.panelDataArrayChanged=!1;let{autoSaveId:s,onLayout:n,storage:i}=S.current,{layout:a,panelDataArray:o}=k.current,l=null;if(s){var e,r;let n=null!=(r=(null!=(e=ht(s,i))?e:{})[he(o)])?r:null;n&&(w.current=new Map(Object.entries(n.expandToSizes)),l=n.layout)}null==l&&(l=function({panelDataArray:e}){let r=Array(e.length),s=e.map(e=>e.constraints),n=0,i=100;for(let a=0;a<e.length;a++){let e=s[a];uK(e,`Panel constraints not found for index ${a}`);let{defaultSize:o}=e;null!=o&&(n++,r[a]=o,i-=o)}for(let a=0;a<e.length;a++){let o=s[a];uK(o,`Panel constraints not found for index ${a}`);let{defaultSize:l}=o;if(null!=l)continue;let c=i/(e.length-n);n++,r[a]=c,i-=c}return r}({panelDataArray:o}));let c=hs({layout:l,panelConstraints:o.map(e=>e.constraints)});u3(a,c)||(v(c),k.current.layout=c,n&&n(c),u6(o,c,b.current))}}),uo(()=>{let e=k.current;return()=>{e.layout=[]}},[]);let A=(0,V.useCallback)(e=>{let r=!1,s=p.current;return s&&"rtl"===window.getComputedStyle(s,null).getPropertyValue("direction")&&(r=!0),function(s){var n,i;s.preventDefault();let a=p.current;if(!a)return()=>null;let{direction:o,dragState:l,id:c,keyboardResizeBy:d,onLayout:u}=S.current,{layout:h,panelDataArray:f}=k.current,{initialLayout:m}=null!=l?l:{},g=u1(c,e,a),x=function(e,r,s,n,i,a){if(uy(e)){let r="horizontal"===s,n=0;n=e.shiftKey?100:null!=i?i:10;let a=0;switch(e.key){case"ArrowDown":a=r?0:n;break;case"ArrowLeft":a=r?-n:0;break;case"ArrowRight":a=r?n:0;break;case"ArrowUp":a=r?0:-n;break;case"End":a=100;break;case"Home":a=-100}return a}return null==n?0:function(e,r,s,n,i){let a="horizontal"===s,o=u5(r,i);uK(o,`No resize handle element found for id "${r}"`);let l=o.getAttribute(un);uK(l,"Resize handle element has no group id attribute");let{initialCursorPosition:c}=n,d=u4(s,e),u=u2(l,i);uK(u,`No group element found for id "${l}"`);let h=u.getBoundingClientRect();return(d-c)/(a?h.width:h.height)*100}(e,r,s,n,a)}(s,e,o,l,d,a),y="horizontal"===o;y&&r&&(x=-x);let w=uZ({delta:x,initialLayout:null!=m?m:h,panelConstraints:f.map(e=>e.constraints),pivotIndices:g,prevLayout:h,trigger:uy(s)?"keyboard":"mouse-or-touch"}),j=!u7(h,w);(ub(s)||uw(s))&&_.current!=x&&((_.current=x,j||0===x)?uF.set(e,0):y?(n=x<0?uE:uD,uF.set(e,n)):(i=x<0?uT:uR,uF.set(e,i))),j&&(v(w),k.current.layout=w,u&&u(w),u6(f,w,b.current))}},[]),M=(0,V.useCallback)((e,r)=>{let{onLayout:s}=S.current,{layout:n,panelDataArray:i}=k.current,a=i.map(e=>e.constraints),{panelSize:o,pivotIndices:l}=hc(i,e,n);uK(null!=o,`Panel size not found for panel "${e.id}"`);let c=uZ({delta:hl(i,e)===i.length-1?o-r:r-o,initialLayout:n,panelConstraints:a,pivotIndices:l,prevLayout:n,trigger:"imperative-api"});u7(n,c)||(v(c),k.current.layout=c,s&&s(c),u6(i,c,b.current))},[]),I=(0,V.useCallback)((e,r)=>{let{layout:s,panelDataArray:n}=k.current,{collapsedSize:i=0,collapsible:a}=r,{collapsedSize:o=0,collapsible:l,maxSize:c=100,minSize:d=0}=e.constraints,{panelSize:u}=hc(n,e,s);null!=u&&(a&&l&&uY(u,i)?uY(i,o)||M(e,o):u<d?M(e,d):u>c&&M(e,c))},[M]),P=(0,V.useCallback)((e,r)=>{let{direction:s}=S.current,{layout:n}=k.current;if(!p.current)return;let i=u5(e,p.current);uK(i,`Drag handle element not found for id "${e}"`);let a=u4(s,r);g({dragHandleId:e,dragHandleRect:i.getBoundingClientRect(),initialCursorPosition:a,initialLayout:n})},[]),F=(0,V.useCallback)(()=>{g(null)},[]),L=(0,V.useCallback)(e=>{let{panelDataArray:r}=k.current,s=hl(r,e);s>=0&&(r.splice(s,1),delete b.current[e.id],k.current.panelDataArrayChanged=!0,y())},[y]),O=(0,V.useMemo)(()=>({collapsePanel:j,direction:n,dragState:m,expandPanel:C,getPanelSize:N,getPanelStyle:E,groupId:f,isPanelCollapsed:D,isPanelExpanded:T,reevaluatePanelConstraints:I,registerPanel:R,registerResizeHandle:A,resizePanel:M,startDragging:P,stopDragging:F,unregisterPanel:L,panelGroupElement:p.current}),[j,m,n,C,N,E,f,D,T,I,R,A,M,P,F,L]);return(0,V.createElement)(ur.Provider,{value:O},(0,V.createElement)(u,{...h,children:r,className:s,id:a,ref:p,style:{display:"flex",flexDirection:"horizontal"===n?"row":"column",height:"100%",overflow:"hidden",width:"100%",...d},"data-panel-group":"",[us]:n,[un]:f}))}let ho=(0,V.forwardRef)((e,r)=>(0,V.createElement)(ha,{...e,forwardedRef:r}));function hl(e,r){return e.findIndex(e=>e===r||e.id===r.id)}function hc(e,r,s){let n=hl(e,r),i=n===e.length-1,a=s[n];return{...r.constraints,panelSize:a,pivotIndices:i?[n-1,n]:[n,n+1]}}function hd({children:e=null,className:r="",disabled:s=!1,hitAreaMargins:n,id:i,onBlur:a,onClick:o,onDragging:l,onFocus:c,onPointerDown:d,onPointerUp:u,style:h={},tabIndex:f=0,tagName:p="div",...m}){var g,x;let v=(0,V.useRef)(null),y=(0,V.useRef)({onClick:o,onDragging:l,onPointerDown:d,onPointerUp:u});(0,V.useEffect)(()=>{y.current.onClick=o,y.current.onDragging=l,y.current.onPointerDown=d,y.current.onPointerUp=u});let b=(0,V.useContext)(ur);if(null===b)throw Error("PanelResizeHandle components must be rendered within a PanelGroup container");let{direction:w,groupId:_,registerResizeHandle:S,startDragging:k,stopDragging:j,panelGroupElement:C}=b,N=uu(i),[E,D]=(0,V.useState)("inactive"),[T,R]=(0,V.useState)(!1),[A,M]=(0,V.useState)(null),I=(0,V.useRef)({state:E});uo(()=>{I.current.state=E}),(0,V.useEffect)(()=>{if(s)M(null);else{let e=S(N);M(()=>e)}},[s,N,S]);let P=null!=(g=null==n?void 0:n.coarse)?g:15,F=null!=(x=null==n?void 0:n.fine)?x:5;return(0,V.useEffect)(()=>{if(s||null==A)return;let e=v.current;uK(e,"Element ref not attached");let r=!1;return function(e,r,s,n,i){var a;let{ownerDocument:o}=r,l={direction:s,element:r,hitAreaMargins:n,setResizeHandlerState:i},c=null!=(a=uP.get(o))?a:0;return uP.set(o,c+1),uL.add(l),uV(),function(){var r;uF.delete(e),uL.delete(l);let s=null!=(r=uP.get(o))?r:1;if(uP.set(o,s-1),uV(),1===s&&uP.delete(o),uM.includes(l)){let e=uM.indexOf(l);e>=0&&uM.splice(e,1),uH(),i("up",!0,null)}}}(N,e,w,{coarse:P,fine:F},(e,s,n)=>{if(!s)return void D("inactive");switch(e){case"down":{D("drag"),r=!1,uK(n,'Expected event to be defined for "down" action'),k(N,n);let{onDragging:e,onPointerDown:s}=y.current;null==e||e(!0),null==s||s();break}case"move":{let{state:e}=I.current;r=!0,"drag"!==e&&D("hover"),uK(n,'Expected event to be defined for "move" action'),A(n);break}case"up":{D("hover"),j();let{onClick:e,onDragging:s,onPointerUp:n}=y.current;null==s||s(!1),null==n||n(),r||null==e||e()}}})},[P,w,s,F,S,N,A,k,j]),!function({disabled:e,handleId:r,resizeHandler:s,panelGroupElement:n}){(0,V.useEffect)(()=>{if(e||null==s||null==n)return;let i=u5(r,n);if(null==i)return;let a=e=>{if(!e.defaultPrevented)switch(e.key){case"ArrowDown":case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"End":case"Home":e.preventDefault(),s(e);break;case"F6":{e.preventDefault();let s=i.getAttribute(un);uK(s,`No group element found for id "${s}"`);let a=uQ(s,n),o=u0(s,r,n);uK(null!==o,`No resize element found for id "${r}"`);let l=e.shiftKey?o>0?o-1:a.length-1:o+1<a.length?o+1:0;a[l].focus()}}};return i.addEventListener("keydown",a),()=>{i.removeEventListener("keydown",a)}},[n,e,r,s])}({disabled:s,handleId:N,resizeHandler:A,panelGroupElement:C}),(0,V.createElement)(p,{...m,children:e,className:r,id:i,onBlur:()=>{R(!1),null==a||a()},onFocus:()=>{R(!0),null==c||c()},ref:v,role:"separator",style:{touchAction:"none",userSelect:"none",...h},tabIndex:f,[us]:w,[un]:_,[ui]:"","data-resize-handle-active":"drag"===E?"pointer":T?"keyboard":void 0,"data-panel-resize-handle-enabled":!s,[ua]:N,"data-resize-handle-state":E})}ha.displayName="PanelGroup",ho.displayName="forwardRef(PanelGroup)",hd.displayName="PanelResizeHandle",um=!1;let hu=({className:e,...r})=>(0,U.jsx)(ho,{className:(0,e1.cn)("flex h-full w-full data-[panel-group-direction=vertical]:flex-col",e),...r}),hh=({withHandle:e,className:r,...s})=>(0,U.jsx)(hd,{className:(0,e1.cn)("relative flex w-px items-center justify-center bg-border/60 cursor-col-resize data-[panel-group-direction=vertical]:cursor-row-resize after:absolute after:inset-y-0 after:-left-1 after:-right-1 after:content-[''] focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 data-[panel-group-direction=vertical]:h-px data-[panel-group-direction=vertical]:w-full data-[panel-group-direction=vertical]:after:inset-x-0 data-[panel-group-direction=vertical]:after:-top-1 data-[panel-group-direction=vertical]:after:-bottom-1 data-[panel-group-direction=vertical]:after:left-0 data-[panel-group-direction=vertical]:after:right-0 before:absolute before:z-10 before:inset-y-0 before:-left-px before:right-0 before:bg-transparent before:transition-colors before:duration-150 before:content-[''] data-[panel-group-direction=vertical]:before:inset-x-0 data-[panel-group-direction=vertical]:before:-top-px data-[panel-group-direction=vertical]:before:bottom-0 data-[resize-handle-state=hover]:before:bg-ring data-[resize-handle-state=hover]:before:delay-300 [&[data-resize-handle-active]]:before:bg-ring [&[data-resize-handle-active]]:before:delay-0",r),...s,children:e&&(0,U.jsx)("div",{className:"z-10 flex h-4 w-3 items-center justify-center rounded-sm border bg-border",children:(0,U.jsx)(ut,{className:"h-2.5 w-2.5"})})});function hf({className:e,...r}){return(0,U.jsx)("div",{"data-slot":"table-container",className:"relative w-full overflow-x-auto",children:(0,U.jsx)("table",{"data-slot":"table",className:(0,e1.cn)("w-full caption-bottom text-sm",e),...r})})}function hp({className:e,...r}){return(0,U.jsx)("thead",{"data-slot":"table-header",className:(0,e1.cn)("[&_tr]:border-b",e),...r})}function hm({className:e,...r}){return(0,U.jsx)("tbody",{"data-slot":"table-body",className:(0,e1.cn)("[&_tr:last-child]:border-0",e),...r})}function hg({className:e,...r}){return(0,U.jsx)("tr",{"data-slot":"table-row",className:(0,e1.cn)("hover:bg-muted/50 data-[state=selected]:bg-muted border-b transition-colors",e),...r})}function hx({className:e,...r}){return(0,U.jsx)("th",{"data-slot":"table-head",className:(0,e1.cn)("text-foreground h-10 px-2 text-left align-middle font-medium whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",e),...r})}function hv({className:e,...r}){return(0,U.jsx)("td",{"data-slot":"table-cell",className:(0,e1.cn)("p-2 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",e),...r})}function hy(e){return Date.UTC(e.y,e.m-1,e.d,e.h,e.i,e.s)}function hb(e,r){return e.y===r.y&&e.m===r.m&&e.d===r.d&&e.h===r.h&&e.i===r.i&&e.s===r.s}function hw(e,r,s){return h_(function(e,r){let s=new Date(Date.parse(e));if(isNaN(s))throw Error("Invalid ISO8601 passed to timezone parser.");let n=e.substring(9);return n.includes("Z")||n.includes("+")||n.includes("-")?hk(s.getUTCFullYear(),s.getUTCMonth()+1,s.getUTCDate(),s.getUTCHours(),s.getUTCMinutes(),s.getUTCSeconds(),"Etc/UTC"):hk(s.getFullYear(),s.getMonth()+1,s.getDate(),s.getHours(),s.getMinutes(),s.getSeconds(),r)}(e,r),s)}function h_(e,r){let s=new Date(hy(e)),n=hS(s,e.tz),i=hy(e),a=hy(n),o=new Date(s.getTime()+(i-a)),l=hS(o,e.tz);if(hb(l,e)){let r=new Date(o.getTime()-36e5);return hb(hS(r,e.tz),e)?r:o}let c=new Date(o.getTime()+hy(e)-hy(l));if(hb(hS(c,e.tz),e))return c;if(r)throw Error("Invalid date passed to fromTZ()");return o.getTime()>c.getTime()?o:c}function hS(e,r){let s;try{s=new Intl.DateTimeFormat("en-US",{timeZone:r,year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric",hour12:!1}).formatToParts(e)}catch(s){let e=s instanceof Error?s.message:String(s);throw RangeError(`toTZ: Invalid timezone '${r}' or date. Please provide a valid IANA timezone (e.g., 'America/New_York', 'Europe/Stockholm'). Original error: ${e}`)}let n={year:0,month:0,day:0,hour:0,minute:0,second:0};for(let e of s)("year"===e.type||"month"===e.type||"day"===e.type||"hour"===e.type||"minute"===e.type||"second"===e.type)&&(n[e.type]=parseInt(e.value,10));if(isNaN(n.year)||isNaN(n.month)||isNaN(n.day)||isNaN(n.hour)||isNaN(n.minute)||isNaN(n.second))throw Error(`toTZ: Failed to parse all date components from timezone '${r}'. This may indicate an invalid date or timezone configuration. Parsed components: ${JSON.stringify(n)}`);return 24===n.hour&&(n.hour=0),{y:n.year,m:n.month,d:n.day,h:n.hour,i:n.minute,s:n.second,tz:r}}function hk(e,r,s,n,i,a,o){return{y:e,m:r,d:s,h:n,i:i,s:a,tz:o}}var hj=[1,2,4,8,16],hC=class{pattern;timezone;mode;alternativeWeekdays;sloppyRanges;second;minute;hour;day;month;dayOfWeek;year;lastDayOfMonth;lastWeekday;nearestWeekdays;starDOM;starDOW;starYear;useAndLogic;constructor(e,r,s){this.pattern=e,this.timezone=r,this.mode=s?.mode??"auto",this.alternativeWeekdays=s?.alternativeWeekdays??!1,this.sloppyRanges=s?.sloppyRanges??!1,this.second=Array(60).fill(0),this.minute=Array(60).fill(0),this.hour=Array(24).fill(0),this.day=Array(31).fill(0),this.month=Array(12).fill(0),this.dayOfWeek=Array(7).fill(0),this.year=Array(1e4).fill(0),this.lastDayOfMonth=!1,this.lastWeekday=!1,this.nearestWeekdays=Array(31).fill(0),this.starDOM=!1,this.starDOW=!1,this.starYear=!1,this.useAndLogic=!1,this.parse()}parse(){if(!("string"==typeof this.pattern||this.pattern instanceof String))throw TypeError("CronPattern: Pattern has to be of type string.");this.pattern.indexOf("@")>=0&&(this.pattern=this.handleNicknames(this.pattern).trim());let e=this.pattern.match(/\S+/g)||[""],r=e.length;if(e.length<5||e.length>7)throw TypeError("CronPattern: invalid configuration format ('"+this.pattern+"'), exactly five, six, or seven space separated parts are required.");if("auto"!==this.mode){let e;switch(this.mode){case"5-part":e=5;break;case"6-part":e=6;break;case"7-part":e=7;break;case"5-or-6-parts":e=[5,6];break;case"6-or-7-parts":e=[6,7];break;default:e=0}if(!(Array.isArray(e)?e.includes(r):r===e)){let s=Array.isArray(e)?e.join(" or "):e.toString();throw TypeError(`CronPattern: mode '${this.mode}' requires exactly ${s} parts, but pattern '${this.pattern}' has ${r} parts.`)}}if(5===e.length&&e.unshift("0"),6===e.length&&e.push("*"),"LW"===e[3].toUpperCase()?(this.lastWeekday=!0,e[3]=""):e[3].toUpperCase().indexOf("L")>=0&&(e[3]=e[3].replace(/L/gi,""),this.lastDayOfMonth=!0),"*"==e[3]&&(this.starDOM=!0),"*"==e[6]&&(this.starYear=!0),e[4].length>=3&&(e[4]=this.replaceAlphaMonths(e[4])),e[5].length>=3&&(e[5]=this.alternativeWeekdays?this.replaceAlphaDaysQuartz(e[5]):this.replaceAlphaDays(e[5])),e[5].startsWith("+")&&(this.useAndLogic=!0,e[5]=e[5].substring(1),""===e[5]))throw TypeError("CronPattern: Day-of-week field cannot be empty after '+' modifier.");switch("*"==e[5]&&(this.starDOW=!0),this.pattern.indexOf("?")>=0&&(e[0]=e[0].replace(/\?/g,"*"),e[1]=e[1].replace(/\?/g,"*"),e[2]=e[2].replace(/\?/g,"*"),e[3]=e[3].replace(/\?/g,"*"),e[4]=e[4].replace(/\?/g,"*"),e[5]=e[5].replace(/\?/g,"*"),e[6]&&(e[6]=e[6].replace(/\?/g,"*"))),this.mode){case"5-part":e[0]="0",e[6]="*";break;case"6-part":case"5-or-6-parts":e[6]="*"}this.throwAtIllegalCharacters(e),this.partToArray("second",e[0],0,1),this.partToArray("minute",e[1],0,1),this.partToArray("hour",e[2],0,1),this.partToArray("day",e[3],-1,1),this.partToArray("month",e[4],-1,1);let s=this.alternativeWeekdays?-1:0;this.partToArray("dayOfWeek",e[5],s,63),this.partToArray("year",e[6],0,1),!this.alternativeWeekdays&&this.dayOfWeek[7]&&(this.dayOfWeek[0]=this.dayOfWeek[7])}partToArray(e,r,s,n){let i=this[e],a="day"===e&&this.lastDayOfMonth,o="day"===e&&this.lastWeekday;if(""===r&&!a&&!o)throw TypeError("CronPattern: configuration entry "+e+" ("+r+") is empty, check for trailing spaces.");if("*"===r)return i.fill(n);let l=r.split(",");if(l.length>1)for(let r=0;r<l.length;r++)this.partToArray(e,l[r],s,n);else -1!==r.indexOf("-")&&-1!==r.indexOf("/")?this.handleRangeWithStepping(r,e,s,n):-1!==r.indexOf("-")?this.handleRange(r,e,s,n):-1!==r.indexOf("/")?this.handleStepping(r,e,s,n):""!==r&&this.handleNumber(r,e,s,n)}throwAtIllegalCharacters(e){for(let r=0;r<e.length;r++)if((3===r?/[^/*0-9,\-WwLl]+/:5===r?/[^/*0-9,\-#Ll]+/:/[^/*0-9,\-]+/).test(e[r]))throw TypeError("CronPattern: configuration entry "+r+" ("+e[r]+") contains illegal characters.")}handleNumber(e,r,s,n){let i=this.extractNth(e,r),a=e.toUpperCase().includes("W");if("day"!==r&&a)throw TypeError("CronPattern: Nearest weekday modifier (W) only allowed in day-of-month.");a&&(r="nearestWeekdays");let o=parseInt(i[0],10)+s;if(isNaN(o))throw TypeError("CronPattern: "+r+" is not a number: '"+e+"'");this.setPart(r,o,i[1]||n)}setPart(e,r,s){if(!Object.prototype.hasOwnProperty.call(this,e))throw TypeError("CronPattern: Invalid part specified: "+e);if("dayOfWeek"===e){if(7===r&&(r=0),r<0||r>6)throw RangeError("CronPattern: Invalid value for dayOfWeek: "+r);this.setNthWeekdayOfMonth(r,s);return}if("second"===e||"minute"===e){if(r<0||r>=60)throw RangeError("CronPattern: Invalid value for "+e+": "+r)}else if("hour"===e){if(r<0||r>=24)throw RangeError("CronPattern: Invalid value for "+e+": "+r)}else if("day"===e||"nearestWeekdays"===e){if(r<0||r>=31)throw RangeError("CronPattern: Invalid value for "+e+": "+r)}else if("month"===e){if(r<0||r>=12)throw RangeError("CronPattern: Invalid value for "+e+": "+r)}else if("year"===e&&(r<1||r>=1e4))throw RangeError("CronPattern: Invalid value for "+e+": "+r+" (supported range: 1-9999)");this[e][r]=s}validateNotNaN(e,r){if(isNaN(e))throw TypeError(r)}validateRange(e,r,s,n,i){if(e>r)throw TypeError("CronPattern: From value is larger than to value: '"+i+"'");if(void 0!==s){if(0===s)throw TypeError("CronPattern: Syntax error, illegal stepping: 0");if(s>this[n].length)throw TypeError("CronPattern: Syntax error, steps cannot be greater than maximum value of part ("+this[n].length+")")}}handleRangeWithStepping(e,r,s,n){if(e.toUpperCase().includes("W"))throw TypeError("CronPattern: Syntax error, W is not allowed in ranges with stepping.");let i=this.extractNth(e,r),a=i[0].match(/^(\d+)-(\d+)\/(\d+)$/);if(null===a)throw TypeError("CronPattern: Syntax error, illegal range with stepping: '"+e+"'");let[,o,l,c]=a,d=parseInt(o,10)+s,u=parseInt(l,10)+s,h=parseInt(c,10);this.validateNotNaN(d,"CronPattern: Syntax error, illegal lower range (NaN)"),this.validateNotNaN(u,"CronPattern: Syntax error, illegal upper range (NaN)"),this.validateNotNaN(h,"CronPattern: Syntax error, illegal stepping: (NaN)"),this.validateRange(d,u,h,r,e);for(let e=d;e<=u;e+=h)this.setPart(r,e,i[1]||n)}extractNth(e,r){let s=e,n;if(s.includes("#")){if("dayOfWeek"!==r)throw Error("CronPattern: nth (#) only allowed in day-of-week field");n=s.split("#")[1],s=s.split("#")[0]}else if(s.toUpperCase().endsWith("L")){if("dayOfWeek"!==r)throw Error("CronPattern: L modifier only allowed in day-of-week field (use L alone for day-of-month)");n="L",s=s.slice(0,-1)}return[s,n]}handleRange(e,r,s,n){if(e.toUpperCase().includes("W"))throw TypeError("CronPattern: Syntax error, W is not allowed in a range.");let i=this.extractNth(e,r),a=i[0].split("-");if(2!==a.length)throw TypeError("CronPattern: Syntax error, illegal range: '"+e+"'");let o=parseInt(a[0],10)+s,l=parseInt(a[1],10)+s;this.validateNotNaN(o,"CronPattern: Syntax error, illegal lower range (NaN)"),this.validateNotNaN(l,"CronPattern: Syntax error, illegal upper range (NaN)"),this.validateRange(o,l,void 0,r,e);for(let e=o;e<=l;e++)this.setPart(r,e,i[1]||n)}handleStepping(e,r,s,n){if(e.toUpperCase().includes("W"))throw TypeError("CronPattern: Syntax error, W is not allowed in parts with stepping.");let i=this.extractNth(e,r),a=i[0].split("/");if(2!==a.length)throw TypeError("CronPattern: Syntax error, illegal stepping: '"+e+"'");if(this.sloppyRanges)""===a[0]&&(a[0]="*");else{if(""===a[0])throw TypeError("CronPattern: Syntax error, stepping with missing prefix ('"+e+"') is not allowed. Use wildcard (*/step) or range (min-max/step) instead.");if("*"!==a[0])throw TypeError("CronPattern: Syntax error, stepping with numeric prefix ('"+e+"') is not allowed. Use wildcard (*/step) or range (min-max/step) instead.")}let o=0;"*"!==a[0]&&(o=parseInt(a[0],10)+s);let l=parseInt(a[1],10);this.validateNotNaN(l,"CronPattern: Syntax error, illegal stepping: (NaN)"),this.validateRange(0,this[r].length-1,l,r,e);for(let e=o;e<this[r].length;e+=l)this.setPart(r,e,i[1]||n)}replaceAlphaDays(e){return e.replace(/-sun/gi,"-7").replace(/sun/gi,"0").replace(/mon/gi,"1").replace(/tue/gi,"2").replace(/wed/gi,"3").replace(/thu/gi,"4").replace(/fri/gi,"5").replace(/sat/gi,"6")}replaceAlphaDaysQuartz(e){return e.replace(/sun/gi,"1").replace(/mon/gi,"2").replace(/tue/gi,"3").replace(/wed/gi,"4").replace(/thu/gi,"5").replace(/fri/gi,"6").replace(/sat/gi,"7")}replaceAlphaMonths(e){return e.replace(/jan/gi,"1").replace(/feb/gi,"2").replace(/mar/gi,"3").replace(/apr/gi,"4").replace(/may/gi,"5").replace(/jun/gi,"6").replace(/jul/gi,"7").replace(/aug/gi,"8").replace(/sep/gi,"9").replace(/oct/gi,"10").replace(/nov/gi,"11").replace(/dec/gi,"12")}handleNicknames(e){let r=e.trim().toLowerCase();if("@yearly"===r||"@annually"===r)return"0 0 1 1 *";if("@monthly"===r)return"0 0 1 * *";if("@weekly"===r)return"0 0 * * 0";if("@daily"===r||"@midnight"===r)return"0 0 * * *";if("@hourly"===r)return"0 * * * *";if("@reboot"===r)throw TypeError("CronPattern: @reboot is not supported in this environment. This is an event-based trigger that requires system startup detection.");return e}setNthWeekdayOfMonth(e,r){if("number"!=typeof r&&"L"===r.toUpperCase())this.dayOfWeek[e]=32|this.dayOfWeek[e];else if(63===r)this.dayOfWeek[e]=63;else if(r<6&&r>0)this.dayOfWeek[e]=this.dayOfWeek[e]|hj[r-1];else throw TypeError(`CronPattern: nth weekday out of range, should be 1-5 or L. Value: ${r}, Type: ${typeof r}`)}},hN=[31,28,31,30,31,30,31,31,30,31,30,31],hE=[["month","year",0],["day","month",-1],["hour","day",0],["minute","hour",0],["second","minute",0]],hD=class e{tz;ms;second;minute;hour;day;month;year;constructor(r,s){if(this.tz=s,r&&r instanceof Date)if(isNaN(r))throw TypeError("CronDate: Invalid date passed to CronDate constructor");else this.fromDate(r);else if(null==r)this.fromDate(new Date);else if(r&&"string"==typeof r)this.fromString(r);else if(r instanceof e)this.fromCronDate(r);else throw TypeError("CronDate: Invalid type ("+typeof r+") passed to CronDate constructor")}getLastDayOfMonth(e,r){return 1!==r?hN[r]:new Date(Date.UTC(e,r+1,0)).getUTCDate()}getLastWeekday(e,r){let s=this.getLastDayOfMonth(e,r),n=new Date(Date.UTC(e,r,s)).getUTCDay();return 0===n?s-2:6===n?s-1:s}getNearestWeekday(e,r,s){let n=this.getLastDayOfMonth(e,r);if(s>n)return -1;let i=new Date(Date.UTC(e,r,s)).getUTCDay();return 0===i?s===n?s-2:s+1:6===i?1===s?s+2:s-1:s}isNthWeekdayOfMonth(e,r,s,n){let i=new Date(Date.UTC(e,r,s)).getUTCDay(),a=0;for(let n=1;n<=s;n++)new Date(Date.UTC(e,r,n)).getUTCDay()===i&&a++;if(63&n&&hj[a-1]&n)return!0;if(32&n){let n=this.getLastDayOfMonth(e,r);for(let a=s+1;a<=n;a++)if(new Date(Date.UTC(e,r,a)).getUTCDay()===i)return!1;return!0}return!1}fromDate(e){if(void 0!==this.tz)if("number"==typeof this.tz)this.ms=e.getUTCMilliseconds(),this.second=e.getUTCSeconds(),this.minute=e.getUTCMinutes()+this.tz,this.hour=e.getUTCHours(),this.day=e.getUTCDate(),this.month=e.getUTCMonth(),this.year=e.getUTCFullYear(),this.apply();else try{let r=hS(e,this.tz);this.ms=e.getMilliseconds(),this.second=r.s,this.minute=r.i,this.hour=r.h,this.day=r.d,this.month=r.m-1,this.year=r.y}catch(r){let e=r instanceof Error?r.message:String(r);throw TypeError(`CronDate: Failed to convert date to timezone '${this.tz}'. This may happen with invalid timezone names or dates. Original error: ${e}`)}else this.ms=e.getMilliseconds(),this.second=e.getSeconds(),this.minute=e.getMinutes(),this.hour=e.getHours(),this.day=e.getDate(),this.month=e.getMonth(),this.year=e.getFullYear()}fromCronDate(e){this.tz=e.tz,this.year=e.year,this.month=e.month,this.day=e.day,this.hour=e.hour,this.minute=e.minute,this.second=e.second,this.ms=e.ms}apply(){if(!(this.month>11)&&!(this.month<0)&&!(this.day>hN[this.month])&&!(this.day<1)&&!(this.hour>59)&&!(this.minute>59)&&!(this.second>59)&&!(this.hour<0)&&!(this.minute<0)&&!(this.second<0))return!1;{let e=new Date(Date.UTC(this.year,this.month,this.day,this.hour,this.minute,this.second,this.ms));return this.ms=e.getUTCMilliseconds(),this.second=e.getUTCSeconds(),this.minute=e.getUTCMinutes(),this.hour=e.getUTCHours(),this.day=e.getUTCDate(),this.month=e.getUTCMonth(),this.year=e.getUTCFullYear(),!0}}fromString(e){if("number"!=typeof this.tz)return this.fromDate(hw(e,this.tz));{let r=hw(e);this.ms=r.getUTCMilliseconds(),this.second=r.getUTCSeconds(),this.minute=r.getUTCMinutes(),this.hour=r.getUTCHours(),this.day=r.getUTCDate(),this.month=r.getUTCMonth(),this.year=r.getUTCFullYear(),this.apply()}}findNext(e,r,s,n){return this._findMatch(e,r,s,n,1)}_findMatch(e,r,s,n,i){let a=this[r],o;s.lastDayOfMonth&&(o=this.getLastDayOfMonth(this.year,this.month));let l=s.starDOW||"day"!=r?void 0:new Date(Date.UTC(this.year,this.month,1,0,0,0,0)).getUTCDay(),c=this[r]+n,d=1===i?e=>e<s[r].length:e=>e>=0;for(let u=c;d(u);u+=i){let i=s[r][u];if("day"===r&&!i){for(let e=0;e<s.nearestWeekdays.length;e++)if(s.nearestWeekdays[e]){let r=this.getNearestWeekday(this.year,this.month,e-n);if(-1===r)continue;if(r===u-n){i=1;break}}}if("day"===r&&s.lastWeekday&&u-n===this.getLastWeekday(this.year,this.month)&&(i=1),"day"===r&&s.lastDayOfMonth&&u-n==o&&(i=1),"day"===r&&!s.starDOW){let r=s.dayOfWeek[(l+(u-n-1))%7];if(r&&63&r)r=+!!this.isNthWeekdayOfMonth(this.year,this.month,u-n,r);else if(r)throw Error(`CronDate: Invalid value for dayOfWeek encountered. ${r}`);i=s.useAndLogic||e.domAndDow||s.starDOM?i&&r:i||r}if(i)return this[r]=u-n,a!==this[r]?2:1}return 3}recurse(e,r,s){if(0===s&&!e.starYear){if(this.year>=0&&this.year<e.year.length&&0===e.year[this.year]){let r=-1;for(let s=this.year+1;s<e.year.length&&s<1e4;s++)if(1===e.year[s]){r=s;break}if(-1===r)return null;this.year=r,this.month=0,this.day=1,this.hour=0,this.minute=0,this.second=0,this.ms=0}if(this.year>=1e4)return null}let n=this.findNext(r,hE[s][0],e,hE[s][2]);if(n>1){let i=s+1;for(;i<hE.length;)this[hE[i][0]]=-hE[i][2],i++;if(3===n){if(this[hE[s][1]]++,this[hE[s][0]]=-hE[s][2],this.apply(),0===s&&!e.starYear){for(;this.year>=0&&this.year<e.year.length&&0===e.year[this.year]&&this.year<1e4;)this.year++;if(this.year>=1e4||this.year>=e.year.length)return null}return this.recurse(e,r,0)}if(this.apply())return this.recurse(e,r,s-1)}return(s+=1)>=hE.length?this:(e.starYear?this.year>=3e3:this.year>=1e4)?null:this.recurse(e,r,s)}increment(e,r,s){return this.second+=void 0!==r.interval&&r.interval>1&&s?r.interval:1,this.ms=0,this.apply(),this.recurse(e,r,0)}decrement(e,r){return this.second-=void 0!==r.interval&&r.interval>1?r.interval:1,this.ms=0,this.apply(),this.recurseBackward(e,r,0,0)}recurseBackward(e,r,s,n=0){if(n>1e4)return null;if(0===s&&!e.starYear){if(this.year>=0&&this.year<e.year.length&&0===e.year[this.year]){let r=-1;for(let s=this.year-1;s>=0;s--)if(1===e.year[s]){r=s;break}if(-1===r)return null;this.year=r,this.month=11,this.day=31,this.hour=23,this.minute=59,this.second=59,this.ms=0}if(this.year<0)return null}let i=this.findPrevious(r,hE[s][0],e,hE[s][2]);if(i>1){let a=s+1;for(;a<hE.length;){let r=hE[a][0],s=hE[a][2],n=this.getMaxPatternValue(r,e,s);this[r]=n,a++}if(3===i){if(this[hE[s][1]]--,0===s){let e=this.getLastDayOfMonth(this.year,this.month);this.day>e&&(this.day=e)}if(1===s)if(this.day<=0)this.day=1;else{let e=this.year,r=this.month;for(;r<0;)r+=12,e--;for(;r>11;)r-=12,e++;let s=1!==r?hN[r]:new Date(Date.UTC(e,r+1,0)).getUTCDate();this.day>s&&(this.day=s)}this.apply();let i=hE[s][0],a=hE[s][2],o=this.getMaxPatternValue(i,e,a);if("day"===i){let e=this.getLastDayOfMonth(this.year,this.month);this[i]=Math.min(o,e)}else this[i]=o;if(this.apply(),0===s){let r=hE[1][2],s=Math.min(this.getMaxPatternValue("day",e,r),this.getLastDayOfMonth(this.year,this.month));s!==this.day&&(this.day=s,this.hour=this.getMaxPatternValue("hour",e,hE[2][2]),this.minute=this.getMaxPatternValue("minute",e,hE[3][2]),this.second=this.getMaxPatternValue("second",e,hE[4][2]))}if(0===s&&!e.starYear){for(;this.year>=0&&this.year<e.year.length&&0===e.year[this.year];)this.year--;if(this.year<0)return null}return this.recurseBackward(e,r,0,n+1)}if(this.apply())return this.recurseBackward(e,r,s-1,n+1)}return(s+=1)>=hE.length?this:this.year<0?null:this.recurseBackward(e,r,s,n+1)}getMaxPatternValue(e,r,s){if("day"===e&&r.lastDayOfMonth||"day"===e&&!r.starDOW)return this.getLastDayOfMonth(this.year,this.month);for(let n=r[e].length-1;n>=0;n--)if(r[e][n])return n-s;return r[e].length-1-s}findPrevious(e,r,s,n){return this._findMatch(e,r,s,n,-1)}getDate(e){return e||void 0===this.tz?new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.ms):"number"==typeof this.tz?new Date(Date.UTC(this.year,this.month,this.day,this.hour,this.minute-this.tz,this.second,this.ms)):h_(hk(this.year,this.month+1,this.day,this.hour,this.minute,this.second,this.tz),!1)}getTime(){return this.getDate(!1).getTime()}match(e,r){if(!e.starYear&&(this.year<0||this.year>=e.year.length||0===e.year[this.year]))return!1;for(let s=0;s<hE.length;s++){let n=hE[s][0],i=hE[s][2],a=this[n];if(a+i<0||a+i>=e[n].length)return!1;let o=e[n][a+i];if("day"===n){if(!o){for(let r=0;r<e.nearestWeekdays.length;r++)if(e.nearestWeekdays[r]){let e=this.getNearestWeekday(this.year,this.month,r-i);if(-1!==e&&e===a){o=1;break}}}if(e.lastWeekday&&a===this.getLastWeekday(this.year,this.month)&&(o=1),e.lastDayOfMonth&&a===this.getLastDayOfMonth(this.year,this.month)&&(o=1),!e.starDOW){let s=new Date(Date.UTC(this.year,this.month,1,0,0,0,0)).getUTCDay(),n=e.dayOfWeek[(s+(a-1))%7];n&&63&n&&(n=+!!this.isNthWeekdayOfMonth(this.year,this.month,a,n)),o=e.useAndLogic||r.domAndDow||e.starDOM?o&&n:o||n}}if(!o)return!1}return!0}};function hT(e){return"[object Function]"===Object.prototype.toString.call(e)||"function"==typeof e||e instanceof Function}var hR=[],hA=class{name;options;_states;fn;getTz(){return this.options.timezone||this.options.utcOffset}applyDayOffset(e){if(void 0!==this.options.dayOffset&&0!==this.options.dayOffset){let r=24*this.options.dayOffset*36e5;return new Date(e.getTime()+r)}return e}constructor(e,r,s){let n,i;if(hT(r))i=r;else if("object"==typeof r)n=r;else if(void 0!==r)throw Error("Cron: Invalid argument passed for optionsIn. Should be one of function, or object (options).");if(hT(s))i=s;else if("object"==typeof s)n=s;else if(void 0!==s)throw Error("Cron: Invalid argument passed for funcIn. Should be one of function, or object (options).");if(this.name=n?.name,this.options=function(e){if(void 0===e&&(e={}),delete e.name,void 0!==e.legacyMode&&void 0===e.domAndDow?e.domAndDow=!e.legacyMode:void 0===e.domAndDow&&(e.domAndDow=!1),e.legacyMode=!e.domAndDow,e.paused=void 0!==e.paused&&e.paused,e.maxRuns=void 0===e.maxRuns?1/0:e.maxRuns,e.catch=void 0!==e.catch&&e.catch,e.interval=void 0===e.interval?0:parseInt(e.interval.toString(),10),e.utcOffset=void 0===e.utcOffset?void 0:parseInt(e.utcOffset.toString(),10),e.dayOffset=void 0===e.dayOffset?0:parseInt(e.dayOffset.toString(),10),e.unref=void 0!==e.unref&&e.unref,e.mode=void 0===e.mode?"auto":e.mode,e.alternativeWeekdays=void 0!==e.alternativeWeekdays&&e.alternativeWeekdays,e.sloppyRanges=void 0!==e.sloppyRanges&&e.sloppyRanges,!["auto","5-part","6-part","7-part","5-or-6-parts","6-or-7-parts"].includes(e.mode))throw Error("CronOptions: mode must be one of 'auto', '5-part', '6-part', '7-part', '5-or-6-parts', or '6-or-7-parts'.");if(e.startAt&&(e.startAt=new hD(e.startAt,e.timezone)),e.stopAt&&(e.stopAt=new hD(e.stopAt,e.timezone)),null!==e.interval){if(isNaN(e.interval))throw Error("CronOptions: Supplied value for interval is not a number");if(e.interval<0)throw Error("CronOptions: Supplied value for interval can not be negative")}if(void 0!==e.utcOffset){if(isNaN(e.utcOffset))throw Error("CronOptions: Invalid value passed for utcOffset, should be number representing minutes offset from UTC.");if(e.utcOffset<-870||e.utcOffset>870)throw Error("CronOptions: utcOffset out of bounds.");if(void 0!==e.utcOffset&&e.timezone)throw Error("CronOptions: Combining 'utcOffset' with 'timezone' is not allowed.")}if(!0!==e.unref&&!1!==e.unref)throw Error("CronOptions: Unref should be either true, false or undefined(false).");if(void 0!==e.dayOffset&&0!==e.dayOffset&&isNaN(e.dayOffset))throw Error("CronOptions: Invalid value passed for dayOffset, should be a number representing days to offset.");return e}(n),this._states={kill:!1,blocking:!1,previousRun:void 0,currentRun:void 0,once:void 0,currentTimeout:void 0,maxRuns:n?n.maxRuns:void 0,paused:!!n&&n.paused,pattern:new hC("* * * * *",void 0,{mode:"auto"})},e&&(e instanceof Date||"string"==typeof e&&e.indexOf(":")>0)?this._states.once=new hD(e,this.getTz()):this._states.pattern=new hC(e,this.options.timezone,{mode:this.options.mode,alternativeWeekdays:this.options.alternativeWeekdays,sloppyRanges:this.options.sloppyRanges}),this.name){if(hR.find(e=>e.name===this.name))throw Error("Cron: Tried to initialize new named job '"+this.name+"', but name already taken.");hR.push(this)}return void 0!==i&&hT(i)&&(this.fn=i,this.schedule()),this}nextRun(e){let r=this._next(e);return r?this.applyDayOffset(r.getDate(!1)):null}nextRuns(e,r){void 0!==this._states.maxRuns&&e>this._states.maxRuns&&(e=this._states.maxRuns);let s=r||this._states.currentRun||void 0;return this._enumerateRuns(e,s,"next")}previousRuns(e,r){return this._enumerateRuns(e,r||void 0,"previous")}_enumerateRuns(e,r,s){let n=[],i=r?new hD(r,this.getTz()):null,a="next"===s?this._next:this._previous;for(;e--;){let e=a.call(this,i);if(!e)break;let r=e.getDate(!1);n.push(this.applyDayOffset(r)),i=e}return n}match(e){if(this._states.once){let r=new hD(e,this.getTz());r.ms=0;let s=new hD(this._states.once,this.getTz());return s.ms=0,r.getTime()===s.getTime()}let r=new hD(e,this.getTz());return r.ms=0,r.match(this._states.pattern,this.options)}getPattern(){if(!this._states.once)return this._states.pattern?this._states.pattern.pattern:void 0}getOnce(){return this._states.once?this._states.once.getDate():null}isRunning(){let e=this.nextRun(this._states.currentRun),r=!this._states.paused,s=void 0!==this.fn,n=!this._states.kill;return r&&s&&n&&null!==e}isStopped(){return this._states.kill}isBusy(){return this._states.blocking}currentRun(){return this._states.currentRun?this._states.currentRun.getDate():null}previousRun(){return this._states.previousRun?this._states.previousRun.getDate():null}msToNext(e){let r=this._next(e);return r?e instanceof hD||e instanceof Date?r.getTime()-e.getTime():r.getTime()-new hD(e).getTime():null}stop(){this._states.kill=!0,this._states.currentTimeout&&clearTimeout(this._states.currentTimeout);let e=hR.indexOf(this);e>=0&&hR.splice(e,1)}pause(){return this._states.paused=!0,!this._states.kill}resume(){return this._states.paused=!1,!this._states.kill}schedule(e){var r;if(e&&this.fn)throw Error("Cron: It is not allowed to schedule two functions using the same Croner instance.");e&&(this.fn=e);let s=this.msToNext(),n=this.nextRun(this._states.currentRun);return null==s||isNaN(s)||null===n||(s>3e4&&(s=3e4),this._states.currentTimeout=setTimeout(()=>this._checkTrigger(n),s),this._states.currentTimeout&&this.options.unref&&(r=this._states.currentTimeout,"u">typeof Deno&&"u">typeof Deno.unrefTimer?Deno.unrefTimer(r):r&&"u">typeof r.unref&&r.unref())),this}async _trigger(e){this._states.blocking=!0,this._states.currentRun=new hD(void 0,this.getTz());try{if(this.options.catch)try{void 0!==this.fn&&await this.fn(this,this.options.context)}catch(e){if(hT(this.options.catch))try{this.options.catch(e,this)}catch{}}else void 0!==this.fn&&await this.fn(this,this.options.context)}finally{this._states.previousRun=new hD(e,this.getTz()),this._states.blocking=!1}}async trigger(){await this._trigger()}runsLeft(){return this._states.maxRuns}_checkTrigger(e){let r=new Date,s=!this._states.paused&&r.getTime()>=e.getTime(),n=this._states.blocking&&this.options.protect;s&&!n?(void 0!==this._states.maxRuns&&this._states.maxRuns--,this._trigger()):s&&n&&hT(this.options.protect)&&setTimeout(()=>this.options.protect(this),0),this.schedule()}_next(e){let r=!!(e||this._states.currentRun),s=!1;!e&&this.options.startAt&&this.options.interval&&([e,r]=this._calculatePreviousRun(e,r),s=!e),e=new hD(e,this.getTz()),this.options.startAt&&e&&e.getTime()<this.options.startAt.getTime()&&(e=this.options.startAt);let n=this._states.once||new hD(e,this.getTz());return s||n===this._states.once||(n=n.increment(this._states.pattern,this.options,r)),this._states.once&&this._states.once.getTime()<=e.getTime()||null===n||void 0!==this._states.maxRuns&&this._states.maxRuns<=0||this._states.kill||this.options.stopAt&&n.getTime()>=this.options.stopAt.getTime()?null:n}_previous(e){let r=new hD(e,this.getTz());this.options.stopAt&&r.getTime()>this.options.stopAt.getTime()&&(r=this.options.stopAt);let s=new hD(r,this.getTz());return this._states.once?this._states.once.getTime()<r.getTime()?this._states.once:null:null===(s=s.decrement(this._states.pattern,this.options))||this.options.startAt&&s.getTime()<this.options.startAt.getTime()?null:s}_calculatePreviousRun(e,r){let s=new hD(void 0,this.getTz()),n=e;if(this.options.startAt.getTime()<=s.getTime()){let e=(n=this.options.startAt).getTime()+1e3*this.options.interval;for(;e<=s.getTime();)e=(n=new hD(n,this.getTz()).increment(this._states.pattern,this.options,!0)).getTime()+1e3*this.options.interval;r=!0}return null===n&&(n=void 0),[n,r]}},hM=e.i(263686);let hI=[5,10,15,20,30],hP={frequency:"daily",interval:15,minute:0,time:"09:00",weekdays:[1],dayOfMonth:1};function hF(e,r,s){if(!/^\d{1,2}$/.test(e))return null;let n=parseInt(e,10);return n>=r&&n<=s?n:null}function hL(e){try{return new Intl.DateTimeFormat("en-US",{timeZone:e}),!0}catch{return!1}}function hO(e){let r,s=e.trim().split(/\s+/),n=5===s.length?4:5;s[n]&&"*"!==s[n]&&function(e){let r=new Set;for(let s of e.split(",")){let[e,n]=s.split("-"),i=Number(e),a=void 0===n?i:Number(n);if(!Number.isInteger(i)||!Number.isInteger(a)||i>a)return!1;for(let e=i;e<=a;e++)r.add(e%7)}return 7===r.size}(s[n])&&(s[n]="*");try{r=hM.default.toString(s.join(" "),{use24HourTimeFormat:!0,verbose:!1})}catch{return null}/^At \d{2}:\d{2}$/.test(r)&&(r+=", every day"),r=r.replace(/, only (on|in) /g,", $1 ");let[i,a]=5===s.length?[s[2],s[4]]:[s[3],s[5]],o=e=>void 0!==e&&"*"!==e&&"?"!==e;if(o(i)&&o(a)){let e=r.lastIndexOf(", and on ");-1!==e&&(r=`${r.slice(0,e)}, or on ${r.slice(e+9)}`),r+=" (runs when either the day of month or the weekday matches)"}return r}function hB(e,r){return new Intl.DateTimeFormat(void 0,{timeZone:r,weekday:"short",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",hourCycle:"h23"}).format(e)}function hz(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC"}catch{return"UTC"}}let h$=(0,rE.default)("info",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]]),hW=(0,rE.default)("monitor",[["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["line",{x1:"8",x2:"16",y1:"21",y2:"21",key:"1svkeh"}],["line",{x1:"12",x2:"12",y1:"17",y2:"21",key:"vw1qmm"}]]);function hH(e){let r=V.useRef({value:e,previous:e});return V.useMemo(()=>(r.current.value!==e&&(r.current.previous=r.current.value,r.current.value=e),r.current.previous),[e])}var hU=[" ","Enter","ArrowUp","ArrowDown"],hV=[" ","Enter"],hq="Select",[hK,hX,hY]=ea(hq),[hG,hJ]=es(hq,[hY,nx]),hZ=nx(),[hQ,h0]=hG(hq),[h1,h2]=hG(hq),h5=e=>{let{__scopeSelect:r,children:s,open:n,defaultOpen:i,onOpenChange:a,value:o,defaultValue:l,onValueChange:c,dir:d,name:u,autoComplete:h,disabled:f,required:p,form:m}=e,g=hZ(r),[x,v]=V.useState(null),[y,b]=V.useState(null),[w,_]=V.useState(!1),S=ew(d),[k,j]=ey({prop:n,defaultProp:i??!1,onChange:a,caller:hq}),[C,N]=ey({prop:o,defaultProp:l,onChange:c,caller:hq}),E=V.useRef(null),D=!x||m||!!x.closest("form"),[T,R]=V.useState(new Set),A=Array.from(T).map(e=>e.props.value).join(";");return(0,U.jsx)(nb,{...g,children:(0,U.jsxs)(hQ,{required:p,scope:r,trigger:x,onTriggerChange:v,valueNode:y,onValueNodeChange:b,valueNodeHasChildren:w,onValueNodeHasChildrenChange:_,contentId:ef(),value:C,onValueChange:N,open:k,onOpenChange:j,dir:S,triggerPointerDownPosRef:E,disabled:f,children:[(0,U.jsx)(hK.Provider,{scope:r,children:(0,U.jsx)(h1,{scope:e.__scopeSelect,onNativeOptionAdd:V.useCallback(e=>{R(r=>new Set(r).add(e))},[]),onNativeOptionRemove:V.useCallback(e=>{R(r=>{let s=new Set(r);return s.delete(e),s})},[]),children:s})}),D?(0,U.jsxs)(fR,{"aria-hidden":!0,required:p,tabIndex:-1,name:u,autoComplete:h,value:C,onChange:e=>N(e.target.value),disabled:f,form:m,children:[void 0===C?(0,U.jsx)("option",{value:""}):null,Array.from(T)]},A):null]})})};h5.displayName=hq;var h3="SelectTrigger",h4=V.forwardRef((e,r)=>{let{__scopeSelect:s,disabled:n=!1,...i}=e,a=hZ(s),o=h0(h3,s),l=o.disabled||n,c=(0,en.useComposedRefs)(r,o.onTriggerChange),d=hX(s),u=V.useRef("touch"),[h,f,p]=fM(e=>{let r=d().filter(e=>!e.disabled),s=r.find(e=>e.value===o.value),n=fI(r,e,s);void 0!==n&&o.onValueChange(n.value)}),m=e=>{l||(o.onOpenChange(!0),p()),e&&(o.triggerPointerDownPosRef.current={x:Math.round(e.pageX),y:Math.round(e.pageY)})};return(0,U.jsx)(n_,{asChild:!0,...a,children:(0,U.jsx)(em.button,{type:"button",role:"combobox","aria-controls":o.contentId,"aria-expanded":o.open,"aria-required":o.required,"aria-autocomplete":"none",dir:o.dir,"data-state":o.open?"open":"closed",disabled:l,"data-disabled":l?"":void 0,"data-placeholder":fA(o.value)?"":void 0,...i,ref:c,onClick:er(i.onClick,e=>{e.currentTarget.focus(),"mouse"!==u.current&&m(e)}),onPointerDown:er(i.onPointerDown,e=>{u.current=e.pointerType;let r=e.target;r.hasPointerCapture(e.pointerId)&&r.releasePointerCapture(e.pointerId),0===e.button&&!1===e.ctrlKey&&"mouse"===e.pointerType&&(m(e),e.preventDefault())}),onKeyDown:er(i.onKeyDown,e=>{let r=""!==h.current;e.ctrlKey||e.altKey||e.metaKey||1!==e.key.length||f(e.key),(!r||" "!==e.key)&&hU.includes(e.key)&&(m(),e.preventDefault())})})})});h4.displayName=h3;var h6="SelectValue",h7=V.forwardRef((e,r)=>{let{__scopeSelect:s,className:n,style:i,children:a,placeholder:o="",...l}=e,c=h0(h6,s),{onValueNodeHasChildrenChange:d}=c,u=void 0!==a,h=(0,en.useComposedRefs)(r,c.onValueNodeChange);return ed(()=>{d(u)},[d,u]),(0,U.jsx)(em.span,{...l,ref:h,style:{pointerEvents:"none"},children:fA(c.value)?(0,U.jsx)(U.Fragment,{children:o}):a})});h7.displayName=h6;var h8=V.forwardRef((e,r)=>{let{__scopeSelect:s,children:n,...i}=e;return(0,U.jsx)(em.span,{"aria-hidden":!0,...i,ref:r,children:n||"▼"})});h8.displayName="SelectIcon";var h9=e=>(0,U.jsx)(tc,{asChild:!0,...e});h9.displayName="SelectPortal";var fe="SelectContent",ft=V.forwardRef((e,r)=>{let s=h0(fe,e.__scopeSelect),[n,i]=V.useState();return(ed(()=>{i(new DocumentFragment)},[]),s.open)?(0,U.jsx)(fi,{...e,ref:r}):n?ep.createPortal((0,U.jsx)(fr,{scope:e.__scopeSelect,children:(0,U.jsx)(hK.Slot,{scope:e.__scopeSelect,children:(0,U.jsx)("div",{children:e.children})})}),n):null});ft.displayName=fe;var[fr,fs]=hG(fe),fn=(0,ei.createSlot)("SelectContent.RemoveScroll"),fi=V.forwardRef((e,r)=>{let{__scopeSelect:s,position:n="item-aligned",onCloseAutoFocus:i,onEscapeKeyDown:a,onPointerDownOutside:o,side:l,sideOffset:c,align:d,alignOffset:u,arrowPadding:h,collisionBoundary:f,collisionPadding:p,sticky:m,hideWhenDetached:g,avoidCollisions:x,...v}=e,y=h0(fe,s),[b,w]=V.useState(null),[_,S]=V.useState(null),k=(0,en.useComposedRefs)(r,e=>w(e)),[j,C]=V.useState(null),[N,E]=V.useState(null),D=hX(s),[T,R]=V.useState(!1),A=V.useRef(!1);V.useEffect(()=>{if(b)return t3(b)},[b]),tu();let M=V.useCallback(e=>{let[r,...s]=D().map(e=>e.ref.current),[n]=s.slice(-1),i=document.activeElement;for(let s of e)if(s===i||(s?.scrollIntoView({block:"nearest"}),s===r&&_&&(_.scrollTop=0),s===n&&_&&(_.scrollTop=_.scrollHeight),s?.focus(),document.activeElement!==i))return},[D,_]),I=V.useCallback(()=>M([j,b]),[M,j,b]);V.useEffect(()=>{T&&I()},[T,I]);let{onOpenChange:P,triggerPointerDownPosRef:F}=y;V.useEffect(()=>{if(b){let e={x:0,y:0},r=r=>{e={x:Math.abs(Math.round(r.pageX)-(F.current?.x??0)),y:Math.abs(Math.round(r.pageY)-(F.current?.y??0))}},s=s=>{e.x<=10&&e.y<=10?s.preventDefault():b.contains(s.target)||P(!1),document.removeEventListener("pointermove",r),F.current=null};return null!==F.current&&(document.addEventListener("pointermove",r),document.addEventListener("pointerup",s,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",r),document.removeEventListener("pointerup",s,{capture:!0})}}},[b,P,F]),V.useEffect(()=>{let e=()=>P(!1);return window.addEventListener("blur",e),window.addEventListener("resize",e),()=>{window.removeEventListener("blur",e),window.removeEventListener("resize",e)}},[P]);let[L,O]=fM(e=>{let r=D().filter(e=>!e.disabled),s=r.find(e=>e.ref.current===document.activeElement),n=fI(r,e,s);n&&setTimeout(()=>n.ref.current.focus())}),B=V.useCallback((e,r,s)=>{let n=!A.current&&!s;(void 0!==y.value&&y.value===r||n)&&(C(e),n&&(A.current=!0))},[y.value]),z=V.useCallback(()=>b?.focus(),[b]),$=V.useCallback((e,r,s)=>{let n=!A.current&&!s;(void 0!==y.value&&y.value===r||n)&&E(e)},[y.value]),W="popper"===n?fo:fa,H=W===fo?{side:l,sideOffset:c,align:d,alignOffset:u,arrowPadding:h,collisionBoundary:f,collisionPadding:p,sticky:m,hideWhenDetached:g,avoidCollisions:x}:{};return(0,U.jsx)(fr,{scope:s,content:b,viewport:_,onViewportChange:S,itemRefCallback:B,selectedItem:j,onItemLeave:z,itemTextRefCallback:$,focusSelectedItem:I,selectedItemText:N,position:n,isPositioned:T,searchRef:L,children:(0,U.jsx)(tJ,{as:fn,allowPinchZoom:!0,children:(0,U.jsx)(ts,{asChild:!0,trapped:y.open,onMountAutoFocus:e=>{e.preventDefault()},onUnmountAutoFocus:er(i,e=>{y.trigger?.focus({preventScroll:!0}),e.preventDefault()}),children:(0,U.jsx)(e7,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:e=>e.preventDefault(),onDismiss:()=>y.onOpenChange(!1),children:(0,U.jsx)(W,{role:"listbox",id:y.contentId,"data-state":y.open?"open":"closed",dir:y.dir,onContextMenu:e=>e.preventDefault(),...v,...H,onPlaced:()=>R(!0),ref:k,style:{display:"flex",flexDirection:"column",outline:"none",...v.style},onKeyDown:er(v.onKeyDown,e=>{let r=e.ctrlKey||e.altKey||e.metaKey;if("Tab"===e.key&&e.preventDefault(),r||1!==e.key.length||O(e.key),["ArrowUp","ArrowDown","Home","End"].includes(e.key)){let r=D().filter(e=>!e.disabled).map(e=>e.ref.current);if(["ArrowUp","End"].includes(e.key)&&(r=r.slice().reverse()),["ArrowUp","ArrowDown"].includes(e.key)){let s=e.target,n=r.indexOf(s);r=r.slice(n+1)}setTimeout(()=>M(r)),e.preventDefault()}})})})})})})});fi.displayName="SelectContentImpl";var fa=V.forwardRef((e,r)=>{let{__scopeSelect:s,onPlaced:n,...i}=e,a=h0(fe,s),o=fs(fe,s),[l,c]=V.useState(null),[d,u]=V.useState(null),h=(0,en.useComposedRefs)(r,e=>u(e)),f=hX(s),p=V.useRef(!1),m=V.useRef(!0),{viewport:g,selectedItem:x,selectedItemText:v,focusSelectedItem:y}=o,b=V.useCallback(()=>{if(a.trigger&&a.valueNode&&l&&d&&g&&x&&v){let e=a.trigger.getBoundingClientRect(),r=d.getBoundingClientRect(),s=a.valueNode.getBoundingClientRect(),i=v.getBoundingClientRect();if("rtl"!==a.dir){let n=i.left-r.left,a=s.left-n,o=e.left-a,c=e.width+o,d=Math.max(c,r.width),u=oE(a,[10,Math.max(10,window.innerWidth-10-d)]);l.style.minWidth=c+"px",l.style.left=u+"px"}else{let n=r.right-i.right,a=window.innerWidth-s.right-n,o=window.innerWidth-e.right-a,c=e.width+o,d=Math.max(c,r.width),u=oE(a,[10,Math.max(10,window.innerWidth-10-d)]);l.style.minWidth=c+"px",l.style.right=u+"px"}let o=f(),c=window.innerHeight-20,u=g.scrollHeight,h=window.getComputedStyle(d),m=parseInt(h.borderTopWidth,10),y=parseInt(h.paddingTop,10),b=parseInt(h.borderBottomWidth,10),w=m+y+u+parseInt(h.paddingBottom,10)+b,_=Math.min(5*x.offsetHeight,w),S=window.getComputedStyle(g),k=parseInt(S.paddingTop,10),j=parseInt(S.paddingBottom,10),C=e.top+e.height/2-10,N=x.offsetHeight/2,E=m+y+(x.offsetTop+N);if(E<=C){let e=o.length>0&&x===o[o.length-1].ref.current;l.style.bottom="0px";let r=Math.max(c-C,N+(e?j:0)+(d.clientHeight-g.offsetTop-g.offsetHeight)+b);l.style.height=E+r+"px"}else{let e=o.length>0&&x===o[0].ref.current;l.style.top="0px";let r=Math.max(C,m+g.offsetTop+(e?k:0)+N);l.style.height=r+(w-E)+"px",g.scrollTop=E-C+g.offsetTop}l.style.margin="10px 0",l.style.minHeight=_+"px",l.style.maxHeight=c+"px",n?.(),requestAnimationFrame(()=>p.current=!0)}},[f,a.trigger,a.valueNode,l,d,g,x,v,a.dir,n]);ed(()=>b(),[b]);let[w,_]=V.useState();ed(()=>{d&&_(window.getComputedStyle(d).zIndex)},[d]);let S=V.useCallback(e=>{e&&!0===m.current&&(b(),y?.(),m.current=!1)},[b,y]);return(0,U.jsx)(fl,{scope:s,contentWrapper:l,shouldExpandOnScrollRef:p,onScrollButtonChange:S,children:(0,U.jsx)("div",{ref:c,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:w},children:(0,U.jsx)(em.div,{...i,ref:h,style:{boxSizing:"border-box",maxHeight:"100%",...i.style}})})})});fa.displayName="SelectItemAlignedPosition";var fo=V.forwardRef((e,r)=>{let{__scopeSelect:s,align:n="start",collisionPadding:i=10,...a}=e,o=hZ(s);return(0,U.jsx)(nC,{...o,...a,ref:r,align:n,collisionPadding:i,style:{boxSizing:"border-box",...a.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});fo.displayName="SelectPopperPosition";var[fl,fc]=hG(fe,{}),fd="SelectViewport",fu=V.forwardRef((e,r)=>{let{__scopeSelect:s,nonce:n,...i}=e,a=fs(fd,s),o=fc(fd,s),l=(0,en.useComposedRefs)(r,a.onViewportChange),c=V.useRef(0);return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:n}),(0,U.jsx)(hK.Slot,{scope:s,children:(0,U.jsx)(em.div,{"data-radix-select-viewport":"",role:"presentation",...i,ref:l,style:{position:"relative",flex:1,overflow:"hidden auto",...i.style},onScroll:er(i.onScroll,e=>{let r=e.currentTarget,{contentWrapper:s,shouldExpandOnScrollRef:n}=o;if(n?.current&&s){let e=Math.abs(c.current-r.scrollTop);if(e>0){let n=window.innerHeight-20,i=Math.max(parseFloat(s.style.minHeight),parseFloat(s.style.height));if(i<n){let a=i+e,o=Math.min(n,a),l=a-o;s.style.height=o+"px","0px"===s.style.bottom&&(r.scrollTop=l>0?l:0,s.style.justifyContent="flex-end")}}}c.current=r.scrollTop})})})]})});fu.displayName=fd;var fh="SelectGroup",[ff,fp]=hG(fh);V.forwardRef((e,r)=>{let{__scopeSelect:s,...n}=e,i=ef();return(0,U.jsx)(ff,{scope:s,id:i,children:(0,U.jsx)(em.div,{role:"group","aria-labelledby":i,...n,ref:r})})}).displayName=fh;var fm="SelectLabel";V.forwardRef((e,r)=>{let{__scopeSelect:s,...n}=e,i=fp(fm,s);return(0,U.jsx)(em.div,{id:i.id,...n,ref:r})}).displayName=fm;var fg="SelectItem",[fx,fv]=hG(fg),fy=V.forwardRef((e,r)=>{let{__scopeSelect:s,value:n,disabled:i=!1,textValue:a,...o}=e,l=h0(fg,s),c=fs(fg,s),d=l.value===n,[u,h]=V.useState(a??""),[f,p]=V.useState(!1),m=(0,en.useComposedRefs)(r,e=>c.itemRefCallback?.(e,n,i)),g=ef(),x=V.useRef("touch"),v=()=>{i||(l.onValueChange(n),l.onOpenChange(!1))};if(""===n)throw Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return(0,U.jsx)(fx,{scope:s,value:n,disabled:i,textId:g,isSelected:d,onItemTextChange:V.useCallback(e=>{h(r=>r||(e?.textContent??"").trim())},[]),children:(0,U.jsx)(hK.ItemSlot,{scope:s,value:n,disabled:i,textValue:u,children:(0,U.jsx)(em.div,{role:"option","aria-labelledby":g,"data-highlighted":f?"":void 0,"aria-selected":d&&f,"data-state":d?"checked":"unchecked","aria-disabled":i||void 0,"data-disabled":i?"":void 0,tabIndex:i?void 0:-1,...o,ref:m,onFocus:er(o.onFocus,()=>p(!0)),onBlur:er(o.onBlur,()=>p(!1)),onClick:er(o.onClick,()=>{"mouse"!==x.current&&v()}),onPointerUp:er(o.onPointerUp,()=>{"mouse"===x.current&&v()}),onPointerDown:er(o.onPointerDown,e=>{x.current=e.pointerType}),onPointerMove:er(o.onPointerMove,e=>{x.current=e.pointerType,i?c.onItemLeave?.():"mouse"===x.current&&e.currentTarget.focus({preventScroll:!0})}),onPointerLeave:er(o.onPointerLeave,e=>{e.currentTarget===document.activeElement&&c.onItemLeave?.()}),onKeyDown:er(o.onKeyDown,e=>{(c.searchRef?.current===""||" "!==e.key)&&(hV.includes(e.key)&&v()," "===e.key&&e.preventDefault())})})})})});fy.displayName=fg;var fb="SelectItemText",fw=V.forwardRef((e,r)=>{let{__scopeSelect:s,className:n,style:i,...a}=e,o=h0(fb,s),l=fs(fb,s),c=fv(fb,s),d=h2(fb,s),[u,h]=V.useState(null),f=(0,en.useComposedRefs)(r,e=>h(e),c.onItemTextChange,e=>l.itemTextRefCallback?.(e,c.value,c.disabled)),p=u?.textContent,m=V.useMemo(()=>(0,U.jsx)("option",{value:c.value,disabled:c.disabled,children:p},c.value),[c.disabled,c.value,p]),{onNativeOptionAdd:g,onNativeOptionRemove:x}=d;return ed(()=>(g(m),()=>x(m)),[g,x,m]),(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(em.span,{id:c.textId,...a,ref:f}),c.isSelected&&o.valueNode&&!o.valueNodeHasChildren?ep.createPortal(a.children,o.valueNode):null]})});fw.displayName=fb;var f_="SelectItemIndicator",fS=V.forwardRef((e,r)=>{let{__scopeSelect:s,...n}=e;return fv(f_,s).isSelected?(0,U.jsx)(em.span,{"aria-hidden":!0,...n,ref:r}):null});fS.displayName=f_;var fk="SelectScrollUpButton",fj=V.forwardRef((e,r)=>{let s=fs(fk,e.__scopeSelect),n=fc(fk,e.__scopeSelect),[i,a]=V.useState(!1),o=(0,en.useComposedRefs)(r,n.onScrollButtonChange);return ed(()=>{if(s.viewport&&s.isPositioned){let e=function(){a(r.scrollTop>0)},r=s.viewport;return e(),r.addEventListener("scroll",e),()=>r.removeEventListener("scroll",e)}},[s.viewport,s.isPositioned]),i?(0,U.jsx)(fE,{...e,ref:o,onAutoScroll:()=>{let{viewport:e,selectedItem:r}=s;e&&r&&(e.scrollTop=e.scrollTop-r.offsetHeight)}}):null});fj.displayName=fk;var fC="SelectScrollDownButton",fN=V.forwardRef((e,r)=>{let s=fs(fC,e.__scopeSelect),n=fc(fC,e.__scopeSelect),[i,a]=V.useState(!1),o=(0,en.useComposedRefs)(r,n.onScrollButtonChange);return ed(()=>{if(s.viewport&&s.isPositioned){let e=function(){let e=r.scrollHeight-r.clientHeight;a(Math.ceil(r.scrollTop)<e)},r=s.viewport;return e(),r.addEventListener("scroll",e),()=>r.removeEventListener("scroll",e)}},[s.viewport,s.isPositioned]),i?(0,U.jsx)(fE,{...e,ref:o,onAutoScroll:()=>{let{viewport:e,selectedItem:r}=s;e&&r&&(e.scrollTop=e.scrollTop+r.offsetHeight)}}):null});fN.displayName=fC;var fE=V.forwardRef((e,r)=>{let{__scopeSelect:s,onAutoScroll:n,...i}=e,a=fs("SelectScrollButton",s),o=V.useRef(null),l=hX(s),c=V.useCallback(()=>{null!==o.current&&(window.clearInterval(o.current),o.current=null)},[]);return V.useEffect(()=>()=>c(),[c]),ed(()=>{let e=l().find(e=>e.ref.current===document.activeElement);e?.ref.current?.scrollIntoView({block:"nearest"})},[l]),(0,U.jsx)(em.div,{"aria-hidden":!0,...i,ref:r,style:{flexShrink:0,...i.style},onPointerDown:er(i.onPointerDown,()=>{null===o.current&&(o.current=window.setInterval(n,50))}),onPointerMove:er(i.onPointerMove,()=>{a.onItemLeave?.(),null===o.current&&(o.current=window.setInterval(n,50))}),onPointerLeave:er(i.onPointerLeave,()=>{c()})})}),fD=V.forwardRef((e,r)=>{let{__scopeSelect:s,...n}=e;return(0,U.jsx)(em.div,{"aria-hidden":!0,...n,ref:r})});fD.displayName="SelectSeparator";var fT="SelectArrow";V.forwardRef((e,r)=>{let{__scopeSelect:s,...n}=e,i=hZ(s),a=h0(fT,s),o=fs(fT,s);return a.open&&"popper"===o.position?(0,U.jsx)(nD,{...i,...n,ref:r}):null}).displayName=fT;var fR=V.forwardRef(({__scopeSelect:e,value:r,...s},n)=>{let i=V.useRef(null),a=(0,en.useComposedRefs)(n,i),o=hH(r);return V.useEffect(()=>{let e=i.current;if(!e)return;let s=Object.getOwnPropertyDescriptor(window.HTMLSelectElement.prototype,"value").set;if(o!==r&&s){let n=new Event("change",{bubbles:!0});s.call(e,r),e.dispatchEvent(n)}},[o,r]),(0,U.jsx)(em.select,{...s,style:{...cn,...s.style},ref:a,defaultValue:r})});function fA(e){return""===e||void 0===e}function fM(e){let r=ex(e),s=V.useRef(""),n=V.useRef(0),i=V.useCallback(e=>{let i=s.current+e;r(i),function e(r){s.current=r,window.clearTimeout(n.current),""!==r&&(n.current=window.setTimeout(()=>e(""),1e3))}(i)},[r]),a=V.useCallback(()=>{s.current="",window.clearTimeout(n.current)},[]);return V.useEffect(()=>()=>window.clearTimeout(n.current),[]),[s,i,a]}function fI(e,r,s){var n,i;let a=r.length>1&&Array.from(r).every(e=>e===r[0])?r[0]:r,o=s?e.indexOf(s):-1,l=(n=e,i=Math.max(o,0),n.map((e,r)=>n[(i+r)%n.length]));1===a.length&&(l=l.filter(e=>e!==s));let c=l.find(e=>e.textValue.toLowerCase().startsWith(a.toLowerCase()));return c!==s?c:void 0}fR.displayName="SelectBubbleInput";var i1=i1;function fP({...e}){return(0,U.jsx)(h5,{"data-slot":"select",...e})}function fF({...e}){return(0,U.jsx)(h7,{"data-slot":"select-value",...e})}function fL({className:e,size:r="default",children:s,...n}){return(0,U.jsxs)(h4,{"data-slot":"select-trigger","data-size":r,className:(0,e1.cn)("border-input data-[placeholder]:text-muted-foreground [&_svg:not([class*='text-'])]:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 dark:hover:bg-input/50 flex w-fit items-center justify-between gap-2 rounded-md border bg-transparent px-3 py-2 text-sm whitespace-nowrap shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 data-[size=default]:h-9 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e),...n,children:[s,(0,U.jsx)(h8,{asChild:!0,children:(0,U.jsx)(aa,{className:"size-4 opacity-50"})})]})}function fO({className:e,children:r,position:s="item-aligned",align:n="center",...i}){return(0,U.jsx)(h9,{children:(0,U.jsxs)(ft,{"data-slot":"select-content",className:(0,e1.cn)("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 relative z-50 max-h-(--radix-select-content-available-height) min-w-[8rem] origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border shadow-md","popper"===s&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:s,align:n,...i,children:[(0,U.jsx)(f$,{}),(0,U.jsx)(fu,{className:(0,e1.cn)("p-1","popper"===s&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1"),children:r}),(0,U.jsx)(fW,{})]})})}function fB({className:e,children:r,...s}){return(0,U.jsxs)(fy,{"data-slot":"select-item",className:(0,e1.cn)("focus:bg-accent focus:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2",e),...s,children:[(0,U.jsx)("span",{"data-slot":"select-item-indicator",className:"absolute right-2 flex size-3.5 items-center justify-center",children:(0,U.jsx)(fS,{children:(0,U.jsx)(i1.default,{className:"size-4"})})}),(0,U.jsx)(fw,{children:r})]})}function fz({className:e,...r}){return(0,U.jsx)(fD,{"data-slot":"select-separator",className:(0,e1.cn)("bg-border pointer-events-none -mx-1 my-1 h-px",e),...r})}function f$({className:e,...r}){return(0,U.jsx)(fj,{"data-slot":"select-scroll-up-button",className:(0,e1.cn)("flex cursor-default items-center justify-center py-1",e),...r,children:(0,U.jsx)(lr,{className:"size-4"})})}function fW({className:e,...r}){return(0,U.jsx)(fN,{"data-slot":"select-scroll-down-button",className:(0,e1.cn)("flex cursor-default items-center justify-center py-1",e),...r,children:(0,U.jsx)(aa,{className:"size-4"})})}function fH(e){let r=Math.round(e/1e3);if(r<60)return`${r}s`;let s=Math.floor(r/60),n=r%60;if(s<60)return n?`${s}m ${n}s`:`${s}m`;let i=Math.floor(s/60),a=s%60;return a?`${i}h ${a}m`:`${i}h`}var fU="Popover",[fV,fq]=es(fU,[nx]),fK=nx(),[fX,fY]=fV(fU),fG=e=>{let{__scopePopover:r,children:s,open:n,defaultOpen:i,onOpenChange:a,modal:o=!1}=e,l=fK(r),c=V.useRef(null),[d,u]=V.useState(!1),[h,f]=ey({prop:n,defaultProp:i??!1,onChange:a,caller:fU});return(0,U.jsx)(nb,{...l,children:(0,U.jsx)(fX,{scope:r,contentId:ef(),triggerRef:c,open:h,onOpenChange:f,onOpenToggle:V.useCallback(()=>f(e=>!e),[f]),hasCustomAnchor:d,onCustomAnchorAdd:V.useCallback(()=>u(!0),[]),onCustomAnchorRemove:V.useCallback(()=>u(!1),[]),modal:o,children:s})})};fG.displayName=fU;var fJ="PopoverAnchor",fZ=V.forwardRef((e,r)=>{let{__scopePopover:s,...n}=e,i=fY(fJ,s),a=fK(s),{onCustomAnchorAdd:o,onCustomAnchorRemove:l}=i;return V.useEffect(()=>(o(),()=>l()),[o,l]),(0,U.jsx)(n_,{...a,...n,ref:r})});fZ.displayName=fJ;var fQ="PopoverTrigger",f0=V.forwardRef((e,r)=>{let{__scopePopover:s,...n}=e,i=fY(fQ,s),a=fK(s),o=(0,en.useComposedRefs)(r,i.triggerRef),l=(0,U.jsx)(em.button,{type:"button","aria-haspopup":"dialog","aria-expanded":i.open,"aria-controls":i.contentId,"data-state":pn(i.open),...n,ref:o,onClick:er(e.onClick,i.onOpenToggle)});return i.hasCustomAnchor?l:(0,U.jsx)(n_,{asChild:!0,...a,children:l})});f0.displayName=fQ;var f1="PopoverPortal",[f2,f5]=fV(f1,{forceMount:void 0}),f3=e=>{let{__scopePopover:r,forceMount:s,children:n,container:i}=e,a=fY(f1,r);return(0,U.jsx)(f2,{scope:r,forceMount:s,children:(0,U.jsx)(eO,{present:s||a.open,children:(0,U.jsx)(tc,{asChild:!0,container:i,children:n})})})};f3.displayName=f1;var f4="PopoverContent",f6=V.forwardRef((e,r)=>{let s=f5(f4,e.__scopePopover),{forceMount:n=s.forceMount,...i}=e,a=fY(f4,e.__scopePopover);return(0,U.jsx)(eO,{present:n||a.open,children:a.modal?(0,U.jsx)(f8,{...i,ref:r}):(0,U.jsx)(f9,{...i,ref:r})})});f6.displayName=f4;var f7=(0,ei.createSlot)("PopoverContent.RemoveScroll"),f8=V.forwardRef((e,r)=>{let s=fY(f4,e.__scopePopover),n=V.useRef(null),i=(0,en.useComposedRefs)(r,n),a=V.useRef(!1);return V.useEffect(()=>{let e=n.current;if(e)return t3(e)},[]),(0,U.jsx)(tJ,{as:f7,allowPinchZoom:!0,children:(0,U.jsx)(pe,{...e,ref:i,trapFocus:s.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:er(e.onCloseAutoFocus,e=>{e.preventDefault(),a.current||s.triggerRef.current?.focus()}),onPointerDownOutside:er(e.onPointerDownOutside,e=>{let r=e.detail.originalEvent,s=0===r.button&&!0===r.ctrlKey;a.current=2===r.button||s},{checkForDefaultPrevented:!1}),onFocusOutside:er(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1})})})}),f9=V.forwardRef((e,r)=>{let s=fY(f4,e.__scopePopover),n=V.useRef(!1),i=V.useRef(!1);return(0,U.jsx)(pe,{...e,ref:r,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:r=>{e.onCloseAutoFocus?.(r),r.defaultPrevented||(n.current||s.triggerRef.current?.focus(),r.preventDefault()),n.current=!1,i.current=!1},onInteractOutside:r=>{e.onInteractOutside?.(r),r.defaultPrevented||(n.current=!0,"pointerdown"===r.detail.originalEvent.type&&(i.current=!0));let a=r.target;s.triggerRef.current?.contains(a)&&r.preventDefault(),"focusin"===r.detail.originalEvent.type&&i.current&&r.preventDefault()}})}),pe=V.forwardRef((e,r)=>{let{__scopePopover:s,trapFocus:n,onOpenAutoFocus:i,onCloseAutoFocus:a,disableOutsidePointerEvents:o,onEscapeKeyDown:l,onPointerDownOutside:c,onFocusOutside:d,onInteractOutside:u,...h}=e,f=fY(f4,s),p=fK(s);return tu(),(0,U.jsx)(ts,{asChild:!0,loop:!0,trapped:n,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,U.jsx)(e7,{asChild:!0,disableOutsidePointerEvents:o,onInteractOutside:u,onEscapeKeyDown:l,onPointerDownOutside:c,onFocusOutside:d,onDismiss:()=>f.onOpenChange(!1),children:(0,U.jsx)(nC,{"data-state":pn(f.open),role:"dialog",id:f.contentId,...p,...h,ref:r,style:{...h.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}})})})}),pt="PopoverClose",pr=V.forwardRef((e,r)=>{let{__scopePopover:s,...n}=e,i=fY(pt,s);return(0,U.jsx)(em.button,{type:"button",...n,ref:r,onClick:er(e.onClick,()=>i.onOpenChange(!1))})});pr.displayName=pt;var ps=V.forwardRef((e,r)=>{let{__scopePopover:s,...n}=e,i=fK(s);return(0,U.jsx)(nD,{...i,...n,ref:r})});function pn(e){return e?"open":"closed"}ps.displayName="PopoverArrow",e.s(["Anchor",()=>fZ,"Arrow",()=>ps,"Close",()=>pr,"Content",()=>f6,"Popover",()=>fG,"PopoverAnchor",()=>fZ,"PopoverArrow",()=>ps,"PopoverClose",()=>pr,"PopoverContent",()=>f6,"PopoverPortal",()=>f3,"PopoverTrigger",()=>f0,"Portal",()=>f3,"Root",()=>fG,"Trigger",()=>f0,"createPopoverScope",()=>fq],154484);var pi=e.i(154484),pi=pi;function pa({...e}){return(0,U.jsx)(pi.Root,{"data-slot":"popover",...e})}function po({...e}){return(0,U.jsx)(pi.Trigger,{"data-slot":"popover-trigger",...e})}function pl({className:e,align:r="start",sideOffset:s=4,...n}){return(0,U.jsx)(pi.Portal,{children:(0,U.jsx)(pi.Content,{"data-slot":"popover-content",align:r,sideOffset:s,className:(0,e1.cn)("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 z-50 w-72 origin-(--radix-popover-content-transform-origin) rounded-md border p-0 shadow-md outline-hidden",e),...n})})}var pc=/[\\\/_+.#"@\[\(\{&]/,pd=/[\\\/_+.#"@\[\(\{&]/g,pu=/[\s-]/,ph=/[\s-]/g;function pf(e){return e.toLowerCase().replace(ph," ")}var pp=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce((e,r)=>{let s=rU(`Primitive.${r}`),n=V.forwardRef((e,n)=>{let{asChild:i,...a}=e;return"undefined"!=typeof window&&(window[Symbol.for("radix-ui")]=!0),(0,U.jsx)(i?s:r,{...a,ref:n})});return n.displayName=`Primitive.${r}`,{...e,[r]:n}},{}),pm='[cmdk-group=""]',pg='[cmdk-group-items=""]',px='[cmdk-item=""]',pv=`${px}:not([aria-disabled="true"])`,py="cmdk-item-select",pb="data-value",pw=(e,r,s)=>{var n;return n=e,function e(r,s,n,i,a,o,l){if(o===s.length)return a===r.length?1:.99;var c=`${a},${o}`;if(void 0!==l[c])return l[c];for(var d,u,h,f,p=i.charAt(o),m=n.indexOf(p,a),g=0;m>=0;)(d=e(r,s,n,i,m+1,o+1,l))>g&&(m===a?d*=1:pc.test(r.charAt(m-1))?(d*=.8,(h=r.slice(a,m-1).match(pd))&&a>0&&(d*=Math.pow(.999,h.length))):pu.test(r.charAt(m-1))?(d*=.9,(f=r.slice(a,m-1).match(ph))&&a>0&&(d*=Math.pow(.999,f.length))):(d*=.17,a>0&&(d*=Math.pow(.999,m-a))),r.charAt(m)!==s.charAt(o)&&(d*=.9999)),(d<.1&&n.charAt(m-1)===i.charAt(o+1)||i.charAt(o+1)===i.charAt(o)&&n.charAt(m-1)!==i.charAt(o))&&.1*(u=e(r,s,n,i,m+1,o+2,l))>d&&(d=.1*u),d>g&&(g=d),m=n.indexOf(p,m+1);return l[c]=g,g}(n=s&&s.length>0?`${n+" "+s.join(" ")}`:n,r,pf(n),pf(r),0,0,{})},p_=V.createContext(void 0),pS=V.createContext(void 0),pk=V.createContext(void 0),pj=V.forwardRef((e,r)=>{let s=pP(()=>{var r,s;return{search:"",value:null!=(s=null!=(r=e.value)?r:e.defaultValue)?s:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),n=pP(()=>new Set),i=pP(()=>new Map),a=pP(()=>new Map),o=pP(()=>new Set),l=pM(e),{label:c,children:d,value:u,onValueChange:h,filter:f,shouldFilter:p,loop:m,disablePointerSelection:g=!1,vimBindings:x=!0,...v}=e,y=ef(),b=ef(),w=ef(),_=V.useRef(null),S=pO();pI(()=>{if(void 0!==u){let e=u.trim();s.current.value=e,k.emit()}},[u]),pI(()=>{S(6,T)},[]);let k=V.useMemo(()=>({subscribe:e=>(o.current.add(e),()=>o.current.delete(e)),snapshot:()=>s.current,setState:(e,r,n)=>{var i,a,o,c;if(!Object.is(s.current[e],r)){if(s.current[e]=r,"search"===e)D(),N(),S(1,E);else if("value"===e){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let e=document.getElementById(w);e?e.focus():null==(i=document.getElementById(y))||i.focus()}if(S(7,()=>{var e;s.current.selectedItemId=null==(e=R())?void 0:e.id,k.emit()}),n||S(5,T),(null==(a=l.current)?void 0:a.value)!==void 0){null==(c=(o=l.current).onValueChange)||c.call(o,null!=r?r:"");return}}k.emit()}},emit:()=>{o.current.forEach(e=>e())}}),[]),j=V.useMemo(()=>({value:(e,r,n)=>{var i;r!==(null==(i=a.current.get(e))?void 0:i.value)&&(a.current.set(e,{value:r,keywords:n}),s.current.filtered.items.set(e,C(r,n)),S(2,()=>{N(),k.emit()}))},item:(e,r)=>(n.current.add(e),r&&(i.current.has(r)?i.current.get(r).add(e):i.current.set(r,new Set([e]))),S(3,()=>{D(),N(),s.current.value||E(),k.emit()}),()=>{a.current.delete(e),n.current.delete(e),s.current.filtered.items.delete(e);let r=R();S(4,()=>{D(),(null==r?void 0:r.getAttribute("id"))===e&&E(),k.emit()})}),group:e=>(i.current.has(e)||i.current.set(e,new Set),()=>{a.current.delete(e),i.current.delete(e)}),filter:()=>l.current.shouldFilter,label:c||e["aria-label"],getDisablePointerSelection:()=>l.current.disablePointerSelection,listId:y,inputId:w,labelId:b,listInnerRef:_}),[]);function C(e,r){var n,i;let a=null!=(i=null==(n=l.current)?void 0:n.filter)?i:pw;return e?a(e,s.current.search,r):0}function N(){if(!s.current.search||!1===l.current.shouldFilter)return;let e=s.current.filtered.items,r=[];s.current.filtered.groups.forEach(s=>{let n=i.current.get(s),a=0;n.forEach(r=>{a=Math.max(e.get(r),a)}),r.push([s,a])});let n=_.current;A().sort((r,s)=>{var n,i;let a=r.getAttribute("id"),o=s.getAttribute("id");return(null!=(n=e.get(o))?n:0)-(null!=(i=e.get(a))?i:0)}).forEach(e=>{let r=e.closest(pg);r?r.appendChild(e.parentElement===r?e:e.closest(`${pg} > *`)):n.appendChild(e.parentElement===n?e:e.closest(`${pg} > *`))}),r.sort((e,r)=>r[1]-e[1]).forEach(e=>{var r;let s=null==(r=_.current)?void 0:r.querySelector(`${pm}[${pb}="${encodeURIComponent(e[0])}"]`);null==s||s.parentElement.appendChild(s)})}function E(){let e=A().find(e=>"true"!==e.getAttribute("aria-disabled")),r=null==e?void 0:e.getAttribute(pb);k.setState("value",r||void 0)}function D(){var e,r,o,c;if(!s.current.search||!1===l.current.shouldFilter){s.current.filtered.count=n.current.size;return}s.current.filtered.groups=new Set;let d=0;for(let i of n.current){let n=C(null!=(r=null==(e=a.current.get(i))?void 0:e.value)?r:"",null!=(c=null==(o=a.current.get(i))?void 0:o.keywords)?c:[]);s.current.filtered.items.set(i,n),n>0&&d++}for(let[e,r]of i.current)for(let n of r)if(s.current.filtered.items.get(n)>0){s.current.filtered.groups.add(e);break}s.current.filtered.count=d}function T(){var e,r,s;let n=R();n&&((null==(e=n.parentElement)?void 0:e.firstChild)===n&&(null==(s=null==(r=n.closest(pm))?void 0:r.querySelector('[cmdk-group-heading=""]'))||s.scrollIntoView({block:"nearest"})),n.scrollIntoView({block:"nearest"}))}function R(){var e;return null==(e=_.current)?void 0:e.querySelector(`${px}[aria-selected="true"]`)}function A(){var e;return Array.from((null==(e=_.current)?void 0:e.querySelectorAll(pv))||[])}function M(e){let r=A()[e];r&&k.setState("value",r.getAttribute(pb))}function I(e){var r;let s=R(),n=A(),i=n.findIndex(e=>e===s),a=n[i+e];null!=(r=l.current)&&r.loop&&(a=i+e<0?n[n.length-1]:i+e===n.length?n[0]:n[i+e]),a&&k.setState("value",a.getAttribute(pb))}function P(e){let r=R(),s=null==r?void 0:r.closest(pm),n;for(;s&&!n;)n=null==(s=e>0?function(e,r){let s=e.nextElementSibling;for(;s;){if(s.matches(r))return s;s=s.nextElementSibling}}(s,pm):function(e,r){let s=e.previousElementSibling;for(;s;){if(s.matches(r))return s;s=s.previousElementSibling}}(s,pm))?void 0:s.querySelector(pv);n?k.setState("value",n.getAttribute(pb)):I(e)}let F=()=>M(A().length-1),L=e=>{e.preventDefault(),e.metaKey?F():e.altKey?P(1):I(1)},O=e=>{e.preventDefault(),e.metaKey?M(0):e.altKey?P(-1):I(-1)};return V.createElement(pp.div,{ref:r,tabIndex:-1,...v,"cmdk-root":"",onKeyDown:e=>{var r;null==(r=v.onKeyDown)||r.call(v,e);let s=e.nativeEvent.isComposing||229===e.keyCode;if(!(e.defaultPrevented||s))switch(e.key){case"n":case"j":x&&e.ctrlKey&&L(e);break;case"ArrowDown":L(e);break;case"p":case"k":x&&e.ctrlKey&&O(e);break;case"ArrowUp":O(e);break;case"Home":e.preventDefault(),M(0);break;case"End":e.preventDefault(),F();break;case"Enter":{e.preventDefault();let r=R();if(r){let e=new Event(py);r.dispatchEvent(e)}}}}},V.createElement("label",{"cmdk-label":"",htmlFor:j.inputId,id:j.labelId,style:pz},c),pB(e,e=>V.createElement(pS.Provider,{value:k},V.createElement(p_.Provider,{value:j},e))))}),pC=V.forwardRef((e,r)=>{var s,n;let i=ef(),a=V.useRef(null),o=V.useContext(pk),l=V.useContext(p_),c=pM(e),d=null!=(n=null==(s=c.current)?void 0:s.forceMount)?n:null==o?void 0:o.forceMount;pI(()=>{if(!d)return l.item(i,null==o?void 0:o.id)},[d]);let u=pL(i,a,[e.value,e.children,a],e.keywords),h=V.useContext(pS),f=pF(e=>e.value&&e.value===u.current),p=pF(e=>!!d||!1===l.filter()||!e.search||e.filtered.items.get(i)>0);function m(){var e,r;g(),null==(r=(e=c.current).onSelect)||r.call(e,u.current)}function g(){h.setState("value",u.current,!0)}if(V.useEffect(()=>{let r=a.current;if(!(!r||e.disabled))return r.addEventListener(py,m),()=>r.removeEventListener(py,m)},[p,e.onSelect,e.disabled]),!p)return null;let{disabled:x,value:v,onSelect:y,forceMount:b,keywords:w,..._}=e;return V.createElement(pp.div,{ref:(0,en.composeRefs)(a,r),..._,id:i,"cmdk-item":"",role:"option","aria-disabled":!!x,"aria-selected":!!f,"data-disabled":!!x,"data-selected":!!f,onPointerMove:x||l.getDisablePointerSelection()?void 0:g,onClick:x?void 0:m},e.children)}),pN=V.forwardRef((e,r)=>{let{heading:s,children:n,forceMount:i,...a}=e,o=ef(),l=V.useRef(null),c=V.useRef(null),d=ef(),u=V.useContext(p_),h=pF(e=>!!i||!1===u.filter()||!e.search||e.filtered.groups.has(o));pI(()=>u.group(o),[]),pL(o,l,[e.value,e.heading,c]);let f=V.useMemo(()=>({id:o,forceMount:i}),[i]);return V.createElement(pp.div,{ref:(0,en.composeRefs)(l,r),...a,"cmdk-group":"",role:"presentation",hidden:!h||void 0},s&&V.createElement("div",{ref:c,"cmdk-group-heading":"","aria-hidden":!0,id:d},s),pB(e,e=>V.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":s?d:void 0},V.createElement(pk.Provider,{value:f},e))))}),pE=V.forwardRef((e,r)=>{let{alwaysRender:s,...n}=e,i=V.useRef(null),a=pF(e=>!e.search);return s||a?V.createElement(pp.div,{ref:(0,en.composeRefs)(i,r),...n,"cmdk-separator":"",role:"separator"}):null}),pD=V.forwardRef((e,r)=>{let{onValueChange:s,...n}=e,i=null!=e.value,a=V.useContext(pS),o=pF(e=>e.search),l=pF(e=>e.selectedItemId),c=V.useContext(p_);return V.useEffect(()=>{null!=e.value&&a.setState("search",e.value)},[e.value]),V.createElement(pp.input,{ref:r,...n,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":c.listId,"aria-labelledby":c.labelId,"aria-activedescendant":l,id:c.inputId,type:"text",value:i?e.value:o,onChange:e=>{i||a.setState("search",e.target.value),null==s||s(e.target.value)}})}),pT=V.forwardRef((e,r)=>{let{children:s,label:n="Suggestions",...i}=e,a=V.useRef(null),o=V.useRef(null),l=pF(e=>e.selectedItemId),c=V.useContext(p_);return V.useEffect(()=>{if(o.current&&a.current){let e=o.current,r=a.current,s,n=new ResizeObserver(()=>{s=requestAnimationFrame(()=>{let s=e.offsetHeight;r.style.setProperty("--cmdk-list-height",s.toFixed(1)+"px")})});return n.observe(e),()=>{cancelAnimationFrame(s),n.unobserve(e)}}},[]),V.createElement(pp.div,{ref:(0,en.composeRefs)(a,r),...i,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":l,"aria-label":n,id:c.listId},pB(e,e=>V.createElement("div",{ref:(0,en.composeRefs)(o,c.listInnerRef),"cmdk-list-sizer":""},e)))}),pR=V.forwardRef((e,r)=>{let{open:s,onOpenChange:n,overlayClassName:i,contentClassName:a,container:o,...l}=e;return V.createElement(re,{open:s,onOpenChange:n},V.createElement(ra,{container:o},V.createElement(rl,{"cmdk-overlay":"",className:i}),V.createElement(rh,{"aria-label":e.label,"cmdk-dialog":"",className:a},V.createElement(pj,{ref:r,...l}))))}),pA=Object.assign(pj,{List:pT,Item:pC,Input:pD,Group:pN,Separator:pE,Dialog:pR,Empty:V.forwardRef((e,r)=>pF(e=>0===e.filtered.count)?V.createElement(pp.div,{ref:r,...e,"cmdk-empty":"",role:"presentation"}):null),Loading:V.forwardRef((e,r)=>{let{progress:s,children:n,label:i="Loading...",...a}=e;return V.createElement(pp.div,{ref:r,...a,"cmdk-loading":"",role:"progressbar","aria-valuenow":s,"aria-valuemin":0,"aria-valuemax":100,"aria-label":i},pB(e,e=>V.createElement("div",{"aria-hidden":!0},e)))})});function pM(e){let r=V.useRef(e);return pI(()=>{r.current=e}),r}var pI="undefined"==typeof window?V.useEffect:V.useLayoutEffect;function pP(e){let r=V.useRef();return void 0===r.current&&(r.current=e()),r}function pF(e){let r=V.useContext(pS),s=()=>e(r.snapshot());return V.useSyncExternalStore(r.subscribe,s,s)}function pL(e,r,s,n=[]){let i=V.useRef(),a=V.useContext(p_);return pI(()=>{var o;let l=(()=>{var e;for(let r of s){if("string"==typeof r)return r.trim();if("object"==typeof r&&"current"in r)return r.current?null==(e=r.current.textContent)?void 0:e.trim():i.current}})(),c=n.map(e=>e.trim());a.value(e,l,c),null==(o=r.current)||o.setAttribute(pb,l),i.current=l}),i}var pO=()=>{let[e,r]=V.useState(),s=pP(()=>new Map);return pI(()=>{s.current.forEach(e=>e()),s.current=new Map},[e]),(e,n)=>{s.current.set(e,n),r({})}};function pB({asChild:e,children:r},s){let n;return e&&V.isValidElement(r)?V.cloneElement("function"==typeof(n=r.type)?n(r.props):"render"in n?n.render(r.props):r,{ref:r.ref},s(r.props.children)):s(r)}var pz={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};function p$({className:e,...r}){return(0,U.jsx)(pA,{"data-slot":"command",className:(0,e1.cn)("bg-popover text-popover-foreground flex h-full w-full flex-col overflow-hidden rounded-md",e),...r})}function pW({title:e="Command Palette",description:r="Search for a command to run...",children:s,className:n,showCloseButton:i=!0,shouldFilter:a,instantClose:o=!1,...l}){return(0,U.jsxs)(rT,{...l,children:[(0,U.jsxs)(rF,{className:"sr-only",children:[(0,U.jsx)(rO,{children:e}),(0,U.jsx)(rB,{children:r})]}),(0,U.jsx)(rP,{className:(0,e1.cn)("overflow-hidden p-0",o&&"data-[state=closed]:animate-none!",n),overlayClassName:o?"data-[state=closed]:animate-none!":void 0,showCloseButton:i,children:(0,U.jsx)(p$,{shouldFilter:a,className:"[&_[cmdk-group-heading]]:text-muted-foreground **:data-[slot=command-input-wrapper]:h-12 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group]]:px-2 [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5",children:s})})]})}function pH({className:e,...r}){return(0,U.jsxs)("div",{"data-slot":"command-input-wrapper",className:"flex h-9 items-center gap-2 border-b px-3",children:[(0,U.jsx)(aK,{className:"size-4 shrink-0 opacity-50"}),(0,U.jsx)(pA.Input,{"data-slot":"command-input",className:(0,e1.cn)("placeholder:text-muted-foreground flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-hidden disabled:cursor-not-allowed disabled:opacity-50",e),...r})]})}function pU({className:e,...r}){return(0,U.jsx)(pA.List,{"data-slot":"command-list",className:(0,e1.cn)("max-h-[300px] scroll-py-1 overflow-x-hidden overflow-y-auto",e),...r})}function pV({...e}){return(0,U.jsx)(pA.Empty,{"data-slot":"command-empty",className:"py-6 text-center text-sm",...e})}function pq({className:e,...r}){return(0,U.jsx)(pA.Group,{"data-slot":"command-group",className:(0,e1.cn)("text-foreground [&_[cmdk-group-heading]]:text-muted-foreground overflow-hidden p-1 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium",e),...r})}function pK({className:e,...r}){return(0,U.jsx)(pA.Item,{"data-slot":"command-item",className:(0,e1.cn)("data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e),...r})}let pX="h-[34px] data-[size=sm]:h-[34px] data-[size=default]:h-[34px] w-full min-w-0 rounded-[9px] border-input bg-card px-2.5 text-[12.5px] shadow-none hover:bg-muted focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-accent dark:bg-card dark:hover:bg-muted [&_svg:not([class*='size-'])]:size-3",pY="rounded-[9px] border-input bg-card shadow-none text-[12.5px] md:text-[12.5px] focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-accent dark:bg-card",pG="min-w-0 flex-1 bg-transparent p-0 text-[12.5px] text-foreground outline-none placeholder:text-muted-foreground/70 disabled:cursor-not-allowed";function pJ({className:e,disabled:r,invalid:s,children:n}){return(0,U.jsx)("div",{"data-disabled":r||void 0,"data-invalid":s||void 0,className:(0,e1.cn)("flex h-[34px] min-w-0 items-center gap-2 rounded-[9px] border border-input bg-card px-[11px] text-[12.5px] transition-[color,box-shadow]","focus-within:border-ring focus-within:ring-[3px] focus-within:ring-accent","data-[disabled]:bg-secondary data-[disabled]:text-muted-foreground","data-[invalid]:border-destructive/50 data-[invalid]:ring-[3px] data-[invalid]:ring-destructive/10","[&_svg]:size-3 [&_svg]:shrink-0 [&_svg]:text-muted-foreground/70",e),children:n})}function pZ({children:e,after:r,note:s,trailing:n}){return(0,U.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,U.jsx)("span",{className:"text-[10px] font-semibold tracking-[0.07em] text-muted-foreground/80 uppercase",children:e}),r,(0,U.jsx)("span",{className:"flex-1"}),n??(s&&(0,U.jsx)("span",{className:"text-[10.5px] leading-none text-muted-foreground/80",children:s}))]})}function pQ({value:e,onChange:r,options:s,disabled:n,label:i}){return(0,U.jsx)("div",{role:"radiogroup","aria-label":i,className:"inline-flex gap-0.5 rounded-lg border bg-secondary p-[1.5px]",children:s.map(s=>{let i=s.value===e;return(0,U.jsx)("button",{type:"button",role:"radio","aria-checked":i,disabled:n,onClick:()=>r(s.value),className:(0,e1.cn)("rounded-md border border-transparent px-2 py-[3px] text-[11px] font-medium whitespace-nowrap transition-colors disabled:opacity-50",i?"border-border bg-card text-foreground shadow-xs":"text-muted-foreground hover:text-foreground"),children:s.label},s.value)})})}function p0({children:e,nowrap:r}){return(0,U.jsx)("p",{className:(0,e1.cn)("m-0 flex min-w-0 items-center gap-x-1.5 text-[10.5px] leading-snug text-muted-foreground/80",r?"flex-nowrap whitespace-nowrap":"flex-wrap"),children:e})}function p1({onClick:e,disabled:r,children:s}){return(0,U.jsx)("button",{type:"button",onClick:e,disabled:r,className:"whitespace-nowrap text-accent-foreground underline-offset-2 hover:underline disabled:opacity-50 disabled:hover:no-underline",children:s})}function p2({tone:e,icon:r,children:s}){return(0,U.jsxs)("div",{role:"rose"===e?"alert":void 0,className:(0,e1.cn)("flex items-start gap-2 rounded-lg border px-2.5 py-2 text-[11.5px] leading-snug [&>svg]:mt-px [&>svg]:size-[13px] [&>svg]:shrink-0","info"===e?"border-primary/20 bg-accent text-accent-foreground":"border-destructive/30 bg-destructive/10 text-destructive"),children:[r,(0,U.jsx)("span",{className:"min-w-0",children:s})]})}let p5={minutes:"Every N minutes",hourly:"Hourly",daily:"Daily",weekdays:"Weekdays",weekly:"Weekly",monthly:"Monthly",custom:"Custom (cron)"},p3=/^([01]\d|2[0-3]):[0-5]\d$/,p4=[[1,"Mon"],[2,"Tue"],[3,"Wed"],[4,"Thu"],[5,"Fri"],[6,"Sat"],[0,"Sun"]];function p6({cronExpr:e,onCronExprChange:r,timezone:s,onTimezoneChange:n,preview:i,disabled:a}){let o=(0,V.useMemo)(()=>(function(e){let r=e.trim().split(/\s+/);if(5!==r.length)return null;let[s,n,i,a,o]=r;if("*"!==a)return null;let l=/^\*\/(\d{1,2})$/.exec(s);if(l&&"*"===n&&"*"===i&&"*"===o){let e=parseInt(l[1],10);return hI.includes(e)?{...hP,frequency:"minutes",interval:e}:null}let c=hF(s,0,59);if(null===c)return null;if("*"===n)return"*"===i&&"*"===o?{...hP,frequency:"hourly",minute:c}:null;let d=hF(n,0,23);if(null===d)return null;let u=`${String(d).padStart(2,"0")}:${String(c).padStart(2,"0")}`;if("*"===i&&"*"===o)return{...hP,frequency:"daily",time:u};if("*"===i&&"1-5"===o)return{...hP,frequency:"weekdays",time:u};if("*"===i){let e=o.split(",").map(e=>hF(e,0,6));if(e.some(e=>null===e))return null;let r=[...new Set(e)];return{...hP,frequency:"weekly",time:u,weekdays:r}}if("*"===o){let e=hF(i,1,31);return null===e?null:{...hP,frequency:"monthly",time:u,dayOfMonth:e}}return null})(e),[e]),[l,c]=(0,V.useState)(!1);o||l||c(!0);let d=l||!o?"custom":o.frequency,u=o??hP,h=e=>r(function(e){let[r,s]=function(e){let[r,s]=e.split(":").map(e=>parseInt(e,10));return[Number.isInteger(r)?r:0,Number.isInteger(s)?s:0]}(e.time);switch(e.frequency){case"minutes":return`*/${e.interval} * * * *`;case"hourly":return`${e.minute} * * * *`;case"daily":return`${s} ${r} * * *`;case"weekdays":return`${s} ${r} * * 1-5`;case"weekly":return`${s} ${r} * * ${[...e.weekdays].sort((e,r)=>e-r).join(",")}`;case"monthly":return`${s} ${r} ${e.dayOfMonth} * *`}}({...u,...e})),[f,p]=(0,V.useState)(null),m=e=>(0,U.jsxs)(pJ,{disabled:a,invalid:null!==f,className:e,children:[(0,U.jsx)(l9.Clock,{}),(0,U.jsx)("input",{type:"text",inputMode:"numeric","aria-label":"Time",placeholder:"09:00",value:f??u.time,onChange:e=>{let r=e.target.value;p3.test(r)?(p(null),h({time:r})):p(r)},onBlur:()=>p(null),className:(0,e1.cn)(pG,"font-mono text-xs tracking-tight"),disabled:a})]}),g=(0,U.jsx)("div",{className:"font-mono text-[10.5px] text-muted-foreground/70",children:e});return(0,U.jsxs)("div",{className:"flex min-w-0 flex-col gap-[7px]",children:[(0,U.jsx)(pZ,{trailing:"custom"===d?(0,U.jsx)("span",{title:"minute · hour · day of month · month · day of week",className:"max-w-[calc((100%-0.625rem)/2)] min-w-0 truncate font-mono text-[10.5px] leading-[14px] text-muted-foreground/80",children:"min hour day month weekday"}):void 0,children:"Schedule"}),(0,U.jsxs)("div",{className:"grid min-w-0 grid-cols-2 gap-2.5",children:[(0,U.jsxs)(fP,{value:d,onValueChange:e=>{"custom"===e?c(!0):(c(!1),h({frequency:e}))},disabled:a,children:[(0,U.jsx)(fL,{size:"sm","aria-label":"Frequency",className:pX,children:(0,U.jsx)(fF,{})}),(0,U.jsx)(fO,{children:Object.keys(p5).map(e=>(0,U.jsx)(fB,{value:e,children:p5[e]},e))})]}),"minutes"===d&&(0,U.jsxs)(fP,{value:String(u.interval),onValueChange:e=>h({interval:parseInt(e,10)}),disabled:a,children:[(0,U.jsx)(fL,{size:"sm","aria-label":"Interval",className:pX,children:(0,U.jsx)(fF,{})}),(0,U.jsx)(fO,{children:hI.map(e=>(0,U.jsxs)(fB,{value:String(e),children:["every ",e," minutes"]},e))})]}),"hourly"===d&&(0,U.jsxs)("div",{className:"flex min-w-0 items-center gap-2 text-[12.5px] text-muted-foreground",children:[(0,U.jsx)("span",{className:"shrink-0",children:"at minute"}),(0,U.jsx)(pJ,{disabled:a,className:"w-[72px] shrink-0 px-2.5",children:(0,U.jsx)("input",{type:"number","aria-label":"Minute",min:0,max:59,value:u.minute,onChange:e=>{let r=parseInt(e.target.value,10);Number.isInteger(r)&&r>=0&&r<=59&&h({minute:r})},className:(0,e1.cn)(pG,"font-mono text-xs"),disabled:a})})]}),("daily"===d||"weekdays"===d)&&m(),"weekly"===d&&(0,U.jsxs)("div",{className:"flex min-w-0 gap-2",children:[(0,U.jsx)(p7,{value:u.weekdays,onToggle:e=>{let r=u.weekdays.includes(e);r&&1===u.weekdays.length||h({weekdays:r?u.weekdays.filter(r=>r!==e):[...u.weekdays,e]})},disabled:a}),m("w-[84px] shrink-0 px-2")]}),"monthly"===d&&(0,U.jsxs)("div",{className:"flex min-w-0 gap-2",children:[(0,U.jsxs)(fP,{value:String(u.dayOfMonth),onValueChange:e=>h({dayOfMonth:parseInt(e,10)}),disabled:a,children:[(0,U.jsx)(fL,{size:"sm","aria-label":"Day of month",className:(0,e1.cn)(pX,"w-[64px] shrink-0"),children:(0,U.jsx)(fF,{})}),(0,U.jsx)(fO,{children:Array.from({length:31},(e,r)=>r+1).map(e=>(0,U.jsx)(fB,{value:String(e),children:e},e))})]}),m("flex-1")]}),"custom"===d&&(0,U.jsx)(pJ,{disabled:a,invalid:!i.ok,children:(0,U.jsx)("input",{value:e,onChange:e=>r(e.target.value),placeholder:"0 9 * * 1-5","aria-label":"Cron expression","aria-invalid":!i.ok||void 0,spellCheck:!1,className:(0,e1.cn)(pG,"font-mono text-xs tracking-tight"),disabled:a})})]}),(0,U.jsx)("div",{"data-slot":"schedule-preview",className:"flex min-w-0 flex-col gap-[3px] rounded-[9px] border border-border/60 bg-secondary px-2.5 py-2",children:i.ok?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-x-1.5 text-xs font-medium",children:[(0,U.jsx)("span",{className:i.description?void 0:"font-mono",children:i.description??e}),(0,U.jsx)(p8,{value:s,onChange:n,disabled:a})]}),(0,U.jsxs)("div",{className:"text-[11px] text-muted-foreground",children:["Next:"," ",i.nextRuns.length>0?i.nextRuns.map((e,r)=>(0,U.jsxs)("span",{children:[r>0&&" · ",(0,U.jsx)("span",{className:0===r?"font-medium text-secondary-foreground":void 0,children:hB(e,s)})]},e.getTime())):"never"]}),g]}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)("div",{className:"flex items-center gap-1.5 text-xs text-destructive",children:[(0,U.jsx)(ou,{className:"size-3 shrink-0"}),(0,U.jsx)("span",{className:"min-w-0",children:i.error})]}),(0,U.jsx)("div",{className:"w-fit",children:(0,U.jsx)(p8,{value:s,onChange:n,disabled:a})}),g]})})]})}function p7({value:e,onToggle:r,disabled:s}){let n;return(0,U.jsxs)(pa,{children:[(0,U.jsx)(po,{asChild:!0,children:(0,U.jsxs)("button",{type:"button","aria-label":"Weekdays",disabled:s,className:(0,e1.cn)("flex h-[34px] min-w-0 flex-1 items-center gap-2 rounded-[9px] border border-input bg-card px-2.5 text-left text-[12.5px] text-foreground transition-colors","hover:bg-muted focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-accent focus-visible:outline-none","disabled:cursor-not-allowed disabled:opacity-50"),children:[(0,U.jsx)("span",{className:"min-w-0 flex-1 truncate",children:7===(n=p4.filter(([r])=>e.includes(r))).length?"Every day":5===n.length&&n.every(([e])=>e>=1&&e<=5)?"Mon–Fri":n.length>3?`${n.length} days a week`:n.map(([,e])=>e).join(", ")}),(0,U.jsx)(aa,{className:"size-3 shrink-0 text-muted-foreground/70"})]})}),(0,U.jsx)(pl,{align:"start",className:"w-auto p-2",children:(0,U.jsx)("div",{className:"flex flex-wrap gap-[5px]",children:p4.map(([s,n])=>{let i=e.includes(s);return(0,U.jsx)("button",{type:"button","aria-pressed":i,onClick:()=>r(s),className:(0,e1.cn)("grid h-[26px] place-items-center rounded-[7px] border px-[9px] text-[11px] transition-colors",i?"border-primary bg-primary text-primary-foreground":"border-input bg-card text-muted-foreground hover:bg-muted"),children:n},s)})})})]})}function p8({value:e,onChange:r,disabled:s}){let[n,i]=(0,V.useState)(!1),a=(0,V.useMemo)(()=>{let e;return(e="function"==typeof Intl.supportedValuesOf?Intl.supportedValuesOf("timeZone"):[]).includes("UTC")?e:["UTC",...e]},[]);return(0,U.jsxs)(pa,{open:n,onOpenChange:i,children:[(0,U.jsx)(po,{asChild:!0,children:(0,U.jsxs)("button",{type:"button","aria-label":"Timezone",disabled:s,className:"inline-flex items-center gap-0.5 border-b border-dashed border-border text-[11.5px] font-normal text-muted-foreground transition-colors hover:border-foreground/40 hover:text-foreground disabled:opacity-50",children:["(",e,")",(0,U.jsx)(aa,{className:"size-2.5"})]})}),(0,U.jsx)(pl,{align:"start",className:"w-64 p-0",children:(0,U.jsxs)(p$,{children:[(0,U.jsx)(pH,{placeholder:"Search timezone…"}),(0,U.jsxs)(pU,{className:"max-h-64",children:[(0,U.jsx)(pV,{children:"No timezone found"}),a.map(s=>(0,U.jsxs)(pK,{value:s,onSelect:()=>{r(s),i(!1)},children:[(0,U.jsx)(al.Check,{className:(0,e1.cn)("h-3.5 w-3.5",s===e?"opacity-100":"opacity-0")}),s]},s))]})]})})]})}let p9="__main__",me=()=>()=>{};function mt(e){return new Date(e.includes("T")?e:e.replace(" ","T")+"Z")}function mr({open:e,onOpenChange:r,onSubmit:s,initial:n,worktrees:i,projectId:a,hasLocal:o=!0,onOpenRun:l,onDelete:c}){let[d,u]=(0,V.useState)(""),[h,f]=(0,V.useState)("0 9 * * *"),[p,m]=(0,V.useState)(""),[g,x]=(0,V.useState)("local"),[v,y]=(0,V.useState)([]),[b,w]=(0,V.useState)("command"),[_,S]=(0,V.useState)("claude"),[k,j]=(0,V.useState)(""),[C,N]=(0,V.useState)("branch"),[E,D]=(0,V.useState)(p9),[T,R]=(0,V.useState)(i),[A,M]=(0,V.useState)(!1),[I,P]=(0,V.useState)(""),[F,L]=(0,V.useState)("30"),[O,B]=(0,V.useState)(!1),[z,$]=(0,V.useState)(null),W=(0,V.useSyncExternalStore)(me,X,()=>!1);(0,V.useEffect)(()=>{e&&($(null),u(n?.name??""),f(n?.cron_expr??"0 9 * * *"),m(n?.timezone??hz()),x(n?.target??(o?"local":"")),w(n?.run_type??"command"),S(n?.prompt_provider??"claude"),j(n?.content??""),N(n?.cwd_mode??"branch"),D(n?.branch??p9),P(n?.directory??""),L(String(Math.round((n?.timeout_seconds??1800)/60))))},[e,n,o]),(0,V.useEffect)(()=>{"local"===g&&R(i)},[g,i]),(0,V.useEffect)(()=>{let r=!1;return e&&a&&aC.api.getProjectRemotes(a).then(e=>{r||y(e)}).catch(e=>console.error("Failed to load project remotes:",e)),()=>{r=!0}},[e,a]),(0,V.useEffect)(()=>{e&&!g&&v.length>0&&x(v[0].remote_server_id)},[e,g,v]),(0,V.useEffect)(()=>{let r=!1;if(e&&a&&g&&"local"!==g)return M(!0),aC.api.getProjectWorktrees(a,g).then(e=>{r||R(e)}).catch(e=>{console.error("Failed to load target worktrees:",e),r||R([{branch:null}])}).finally(()=>{r||M(!1)}),()=>{r=!0}},[e,a,g]);let H=(0,V.useMemo)(()=>(function(e,r,s=3){let n;if(!hL(r))return{ok:!1,error:`Invalid timezone: ${r}`};try{let i=new hA(e.trim(),{paused:!0,timezone:r});n=i.nextRuns(s),i.stop()}catch(e){return{ok:!1,error:e instanceof Error?e.message:String(e)}}return{ok:!0,description:hO(e),nextRuns:n}})(h,p||"UTC"),[h,p]),q=O||!g||!d.trim()||!k.trim()||!H.ok,K=async()=>{if(!d.trim()||!k.trim())return void $("Name and content are required");if(!H.ok)return void $(H.error);let e=parseInt(F,10);if(!Number.isInteger(e)||e<=0)return void $("Timeout must be a positive number of minutes");if("directory"===C&&!I.trim())return void $("Directory is required");B(!0),$(null);try{await s({name:d.trim(),cron_expr:h.trim(),timezone:p.trim()||"UTC",target:g,run_type:b,prompt_provider:"prompt"===b?_:null,content:k,cwd_mode:C,branch:"branch"===C?E===p9?null:E:null,directory:"directory"===C?I.trim():null,timeout_seconds:60*e}),r(!1)}catch(e){$(e instanceof Error?e.message:"Failed to save schedule")}finally{B(!1)}},Y=!!n,G=n?.last_run??null,J=g&&"local"!==g?v.find(e=>e.remote_server_id===g)?.server_name??g:null,Z=Y?"Save":"Create",Q=z??(H.ok?null:"Fix the cron expression before saving."),ee="prompt"===b?`${aC.PROMPT_PROVIDER_LABELS[_]} runs unattended on ${J??"this machine"}`:"Runs even while the app is closed";return(0,U.jsx)(rT,{open:e,onOpenChange:r,children:(0,U.jsxs)(rP,{showCloseButton:!1,className:"max-h-[calc(100dvh-2rem)] w-[calc(100%-2rem)] min-w-0 gap-0 overflow-hidden bg-card p-0 grid-rows-[auto_minmax(0,1fr)_auto] sm:w-full sm:max-w-[470px]",onKeyDown:e=>{"Enter"===e.key&&(e.metaKey||e.ctrlKey)&&!q&&(e.preventDefault(),K())},children:[(0,U.jsxs)("div",{className:"flex items-start gap-3 border-b bg-secondary px-4 py-3.5",children:[(0,U.jsx)("span",{className:"grid size-7 shrink-0 place-items-center rounded-lg border border-primary/20 bg-accent text-accent-foreground",children:(0,U.jsx)(l9.Clock,{className:"size-[15px]"})}),(0,U.jsxs)("div",{className:"min-w-0",children:[(0,U.jsx)(rO,{className:"text-[14.5px] font-semibold tracking-tight",children:Y?"Edit Scheduled Task":"New Scheduled Task"}),(0,U.jsx)(rB,{className:"mt-0.5 max-w-[42ch] text-[11.5px] leading-snug",children:Y?"Changes take effect from the next run. The current run, if any, finishes on the old settings.":"Run a command or an agent prompt on a schedule."})]}),(0,U.jsxs)(rM,{className:"ml-auto grid size-6 shrink-0 place-items-center rounded-md border border-transparent text-muted-foreground/70 transition-colors hover:border-border hover:bg-muted hover:text-foreground",children:[(0,U.jsx)(rD,{className:"size-3.5"}),(0,U.jsx)("span",{className:"sr-only",children:"Close"})]})]}),(0,U.jsxs)("div",{"data-slot":"schedule-form-body",className:"flex min-h-0 min-w-0 flex-col gap-[13px] overflow-x-hidden overflow-y-auto px-4 pt-3.5 pb-1",children:[Y&&G&&(0,U.jsxs)(p2,{tone:"info",icon:(0,U.jsx)(h$,{}),children:["Last run ",(0,U.jsx)("b",{className:"font-semibold",children:function(e){let r=Math.max(0,Math.round((Date.now()-e.getTime())/1e3));if(r<60)return"just now";let s=Math.round(r/60);if(s<60)return`${s}m ago`;let n=Math.round(s/60);return n<24?`${n}h ago`:`${Math.round(n/24)}d ago`}(mt(G.started_at))})," · ",function(e){let r=e.finished_at?fH(mt(e.finished_at).getTime()-mt(e.started_at).getTime()):null;switch(e.status){case"completed":return r?`succeeded in ${r}`:"succeeded";case"failed":return r?`failed after ${r}`:"failed";case"timeout":return r?`timed out after ${r}`:"timed out";case"killed":return r?`stopped after ${r}`:"stopped";case"skipped":return"skipped";default:return"running now"}}(G),l&&"skipped"!==G.status&&(0,U.jsxs)(U.Fragment,{children:[" · ",(0,U.jsx)(p1,{onClick:()=>{r(!1),l(G)},children:"Open run"})]})]}),(0,U.jsxs)("div",{className:"flex min-w-0 flex-col gap-[7px]",children:[(0,U.jsx)(pZ,{note:d.trim()?void 0:"Required",children:"Name"}),(0,U.jsx)(aX,{value:d,onChange:e=>u(e.target.value),placeholder:"Daily log analysis","aria-label":"Name",className:(0,e1.cn)(pY,"h-[34px] px-[11px]"),disabled:O})]}),(0,U.jsx)(p6,{cronExpr:h,onCronExprChange:f,timezone:p||"UTC",onTimezoneChange:m,preview:H,disabled:O}),(0,U.jsxs)("div",{className:"flex min-w-0 flex-col gap-[7px]",children:[(0,U.jsx)(pZ,{after:"prompt"===b&&(0,U.jsxs)(fP,{value:_,onValueChange:e=>S(e),disabled:O,children:[(0,U.jsx)(fL,{size:"sm","aria-label":"Agent",className:"h-[23px] gap-1 rounded-[7px] border-input bg-card px-2 py-0 text-[11px] font-medium text-secondary-foreground shadow-none hover:bg-muted [&_svg:not([class*='size-'])]:size-2.5",children:(0,U.jsx)(fF,{})}),(0,U.jsx)(fO,{children:aC.PROMPT_PROVIDERS.map(e=>(0,U.jsx)(fB,{value:e,children:aC.PROMPT_PROVIDER_LABELS[e]},e))})]}),trailing:(0,U.jsx)(pQ,{label:"Task type",value:b,onChange:w,disabled:O,options:[{value:"command",label:"Command (shell)"},{value:"prompt",label:"Prompt"}]}),children:"command"===b?"Command":"Prompt"}),(0,U.jsx)(aq,{value:k,onChange:e=>j(e.target.value),placeholder:"command"===b?"./scripts/scan.sh --daily":"Analyze today's server logs under ./logs and summarize anomalies","aria-label":"command"===b?"Command":"Prompt",className:(0,e1.cn)(pY,"field-sizing-fixed min-h-[74px] min-w-0 max-w-full resize-y overflow-auto px-[11px] py-2 font-mono text-xs leading-[1.55] md:text-xs"),disabled:O})]}),(0,U.jsxs)("div",{className:"flex min-w-0 flex-col gap-[7px]",children:[(0,U.jsx)(pZ,{note:"Runs in",children:"Target"}),(0,U.jsxs)("div",{className:"grid min-w-0 grid-cols-2 gap-2.5",children:[(0,U.jsxs)(fP,{value:g,onValueChange:e=>{x(e),D(p9)},disabled:O,children:[(0,U.jsx)(fL,{size:"sm","aria-label":"Target",className:pX,children:(0,U.jsx)(fF,{placeholder:"Select target"})}),(0,U.jsxs)(fO,{children:[(o||"local"===g)&&(0,U.jsxs)(fB,{value:"local",children:[(0,U.jsx)(hW,{className:"size-3 text-muted-foreground/70"}),"Local"]}),v.map(e=>(0,U.jsxs)(fB,{value:e.remote_server_id,children:[(0,U.jsx)(oj,{className:"size-3 text-muted-foreground/70"}),e.server_name??e.remote_server_id]},e.remote_server_id))]})]}),"branch"===C?A||!g?(0,U.jsxs)(pJ,{disabled:!0,className:"cursor-default px-2.5",children:[(0,U.jsx)(aP,{className:"animate-spin"}),(0,U.jsx)("span",{className:"truncate",children:"Loading workspaces…"})]}):(0,U.jsxs)(fP,{value:E,onValueChange:D,disabled:O,children:[(0,U.jsx)(fL,{size:"sm","aria-label":"Workspace",className:pX,children:(0,U.jsx)(fF,{placeholder:"Select workspace"})}),(0,U.jsx)(fO,{children:T.map(e=>(0,U.jsxs)(fB,{value:e.branch??p9,children:[(0,U.jsx)(ao,{className:"size-3 text-muted-foreground/70"}),(0,U.jsx)("span",{className:"font-mono text-xs",children:e.branch??"main"})]},e.branch??p9))})]}):(0,U.jsxs)(pJ,{disabled:O,children:[(0,U.jsx)(le,{}),(0,U.jsx)("input",{value:I,onChange:e=>P(e.target.value),placeholder:"/var/log/myapp","aria-label":"Directory",spellCheck:!1,className:(0,e1.cn)(pG,"font-mono text-xs tracking-tight"),disabled:O})]})]}),(0,U.jsxs)(p0,{nowrap:!0,children:[(0,U.jsx)("span",{className:"truncate",children:"branch"===C?J?A?`Loading workspaces on ${J}`:`${T.length} ${1===T.length?"workspace":"workspaces"} on ${J}`:"Runs in the selected workspace":"Runs straight in this directory, with no workspace"}),(0,U.jsx)("span",{className:"shrink-0",children:"·"}),"branch"===C?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(p1,{onClick:()=>N("directory"),disabled:O,children:"use a plain directory"}),(0,U.jsx)("span",{className:"shrink-0",children:"for non-repo work"})]}):(0,U.jsx)(p1,{onClick:()=>N("branch"),disabled:O,children:"use a workspace instead"})]})]}),(0,U.jsxs)("div",{className:"flex min-w-0 flex-col gap-[7px]",children:[(0,U.jsx)(pZ,{children:"Timeout"}),(0,U.jsxs)(pJ,{disabled:O,className:"w-32",children:[(0,U.jsx)("input",{value:F,onChange:e=>L(e.target.value),inputMode:"numeric","aria-label":"Timeout in minutes",className:pG,disabled:O}),(0,U.jsx)("span",{className:"text-[11px] whitespace-nowrap text-muted-foreground/70",children:"minutes"})]})]}),Q&&(0,U.jsx)(p2,{tone:"rose",icon:(0,U.jsx)(ou,{}),children:Q})]}),(0,U.jsxs)("div",{className:"mt-2.5 flex min-w-0 items-center gap-2.5 overflow-hidden border-t bg-secondary px-4 py-2.5",children:[(0,U.jsx)("span",{className:"flex min-w-0 flex-1 items-center gap-1.5 overflow-hidden text-[11px] text-muted-foreground",children:Y&&n&&c?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(ok,{className:"size-3 shrink-0 text-muted-foreground/70"}),(0,U.jsx)(p1,{onClick:()=>{r(!1),c(n)},disabled:O,children:"Delete task"})]}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(h$,{className:"size-3 shrink-0 text-muted-foreground/70"}),(0,U.jsx)("span",{className:"truncate",children:ee})]})}),(0,U.jsx)(a$.Button,{variant:"outline",size:"sm",className:"h-7 text-xs",onClick:()=>r(!1),disabled:O,children:"Cancel"}),(0,U.jsx)(a$.Button,{size:"sm",className:"h-7 gap-1.5 text-xs","aria-label":Z,onClick:()=>void K(),disabled:q,children:O?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(aP,{className:"size-3 animate-spin"}),"Saving…"]}):(0,U.jsxs)(U.Fragment,{children:[Y?(0,U.jsx)(al.Check,{className:"size-3"}):(0,U.jsx)(oS,{className:"size-3"}),Z,(0,U.jsx)("kbd",{className:"rounded border border-background/30 bg-background/15 px-1 font-mono text-[10px] leading-[1.4] text-background/90",title:W?"Command+Enter":"Ctrl+Enter",children:W?"⌘⏎":"Ctrl⏎"})]})})]})]})})}let ms={running:"bg-blue-500/15 text-blue-600",completed:"bg-emerald-500/15 text-emerald-600",failed:"bg-red-500/15 text-red-600",timeout:"bg-amber-500/15 text-amber-600",killed:"bg-amber-500/15 text-amber-600",skipped:"bg-muted text-muted-foreground"},mn=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g;function mi(e){return e.replace(mn,"").replace(/\r\n/g,"\n").replace(/\r/g,"\n")}function ma(e){return new Date(e.includes("T")?e:e.replace(" ","T")+"Z")}function mo(e){return e?ma(e).toLocaleString():"—"}function ml(e){if(!e.finished_at)return"…";let r=Math.max(0,Math.round((ma(e.finished_at).getTime()-ma(e.started_at).getTime())/1e3));return r<60?`${r}s`:`${Math.floor(r/60)}m ${r%60}s`}function mc({projectId:e,hasLocal:r=!0,schedules:s,loading:n,selectedId:i,onSelect:a,worktrees:o,onCreate:l,onUpdate:c,onDelete:d,onRunNow:u,createOpen:h,onCreateOpenChange:f,openRunId:p,onOpenRunHandled:m,onOpenSourceSession:g}){let x,v,y=s.find(e=>e.id===i)??s[0]??null,[b,w]=(0,V.useState)([]),[_,S]=(0,V.useState)(!1),[k,j]=(0,V.useState)(null),[C,N]=(0,V.useState)(null),[E,D]=(0,V.useState)(0),[T,R]=(0,V.useState)(null),[A,M]=(0,V.useState)(null),[I,P]=(0,V.useState)(null),F=(0,V.useCallback)(async e=>{try{return await aC.api.getScheduleRuns(e)}catch(e){return console.error("Failed to fetch schedule runs:",e),null}},[]);(0,V.useEffect)(()=>{let e=y?.id,r=!1;return(e?F(e):Promise.resolve([])).then(e=>{if(r)return;let s=e??[];w(s),j(e=>e&&(e===C||s.some(r=>r.id===e&&"skipped"!==r.status))?e:s.find(e=>"skipped"!==e.status)?.id??null)}),()=>{r=!0}},[y?.id,s,F,C]);let L=b.find(e=>e.id===k&&e.schedule_id===y?.id),O=L?`${L.status}:${L.finished_at??""}`:null;(0,V.useEffect)(()=>{if(!k)return;let e=!1;return aC.api.getScheduleRun(k).then(r=>{e||R({runId:k,nonce:E,run:r,error:null})},r=>{e||R({runId:k,nonce:E,run:null,error:r instanceof Error?r.message:"Failed to load run output"})}),()=>{e=!0}},[k,E,O]);let B=async()=>{if(y){M(null);try{await u(y.id)}catch(e){M(e instanceof Error?e.message:"Failed to start run")}}},z=e=>{"skipped"!==e.status&&(N(null),j(e.id))};(0,V.useEffect)(()=>{p&&(N(p),j(p),m?.(p))},[p,m]);let $=y?b.filter(e=>e.schedule_id===y.id):[],W=k===C||$.some(e=>e.id===k&&"skipped"!==e.status),H=W&&T?.runId===k&&T.nonce===E?T:null;return n||0!==s.length?(0,U.jsxs)("div",{className:"flex flex-col h-full",children:[y&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(d8,{title:y.name,description:(x=hO(y.cron_expr)??y.cron_expr,v=y.next_run_at?function(e,r){if(!hL(r))return e.toLocaleString();let s=`${hB(e,r)} (${r})`,n=hB(e,hz());return n===hB(e,r)?s:`${s} \xb7 your time ${n}`}(ma(y.next_run_at),y.timezone):"—",`${x} \xb7 next: ${v}`),actions:(0,U.jsxs)("div",{className:"flex items-center gap-2",children:[(0,U.jsxs)(a$.Button,{size:"sm",onClick:B,disabled:!!y.running,children:[(0,U.jsx)(dw,{className:"h-3.5 w-3.5 mr-1.5"}),y.running?"Running…":"Run now"]}),(0,U.jsxs)("label",{className:"flex items-center gap-2 text-sm cursor-pointer",children:[(0,U.jsx)("input",{type:"checkbox",checked:y.enabled,onChange:e=>void c(y.id,{enabled:e.target.checked}),className:"h-4 w-4 rounded border-input accent-primary"}),(0,U.jsx)("span",{children:"Enabled"})]}),(0,U.jsx)(a$.Button,{size:"sm",variant:"outline",onClick:()=>S(!0),children:(0,U.jsx)(lT,{className:"h-3.5 w-3.5"})}),(0,U.jsx)(a$.Button,{size:"sm",variant:"outline",onClick:()=>{y&&P(y)},className:"hover:bg-destructive/15 hover:text-destructive",children:(0,U.jsx)(ok,{className:"h-3.5 w-3.5"})})]})}),(0,U.jsxs)("div",{className:"px-5 py-3 grid grid-cols-2 gap-x-8 gap-y-1 text-sm border-b border-border/50",children:[(0,U.jsxs)("div",{children:[(0,U.jsx)("span",{className:"text-muted-foreground",children:"Type: "}),"command"===y.run_type?"Command":`Prompt (${null==y.prompt_provider?aC.PROMPT_PROVIDER_LABELS.claude:(0,aC.isPromptProvider)(y.prompt_provider)?aC.PROMPT_PROVIDER_LABELS[y.prompt_provider]:y.prompt_provider})`]}),(0,U.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,U.jsx)("span",{className:"text-muted-foreground",children:"Runs in: "}),"branch"===y.cwd_mode?`workspace ${y.branch??"main"}`:y.directory,"local"!==y.target&&(0,U.jsx)("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-violet-500/15 text-violet-600",children:"remote"})]}),(0,U.jsx)("div",{className:"col-span-2 font-mono text-xs text-muted-foreground truncate",title:y.content,children:y.content}),(0,U.jsxs)("div",{children:[(0,U.jsx)("span",{className:"text-muted-foreground",children:"Timeout: "}),Math.round(y.timeout_seconds/60),"m"]}),y.source_session&&(0,U.jsxs)("div",{className:"flex min-w-0 items-center gap-1.5",children:[(0,U.jsx)("span",{className:"shrink-0 text-muted-foreground",children:"Created from: "}),(0,U.jsx)(rZ,{source:y.source_session,onOpen:g})]})]}),A&&(0,U.jsx)("div",{className:"mx-5 mt-3 text-sm text-destructive bg-destructive/10 px-3 py-2 rounded-md",children:A}),(0,U.jsx)("div",{className:"flex-1 min-h-0",children:(0,U.jsxs)(hu,{direction:"horizontal",autoSaveId:"schedule-run-panels",children:[(0,U.jsx)(uf,{defaultSize:33,minSize:25,children:(0,U.jsx)("div",{className:"h-full overflow-auto px-5 py-3",children:(0,U.jsxs)(hf,{children:[(0,U.jsx)(hp,{children:(0,U.jsxs)(hg,{children:[(0,U.jsx)(hx,{children:"Started"}),(0,U.jsx)(hx,{children:"Duration"}),(0,U.jsx)(hx,{children:"Status"}),(0,U.jsx)(hx,{children:"Exit code"})]})}),(0,U.jsxs)(hm,{children:[$.map(e=>(0,U.jsxs)(hg,{onClick:()=>z(e),"aria-disabled":"skipped"===e.status,className:(0,e1.cn)("skipped"!==e.status&&"cursor-pointer",e.id===k&&"bg-muted/50"),children:[(0,U.jsx)(hv,{children:mo(e.started_at)}),(0,U.jsx)(hv,{children:"skipped"===e.status?"—":ml(e)}),(0,U.jsx)(hv,{children:(0,U.jsx)("span",{className:(0,e1.cn)("px-1.5 py-0.5 rounded text-[11px] font-medium",ms[e.status]),children:e.status})}),(0,U.jsx)(hv,{children:e.exit_code??"—"})]},e.id)),0===$.length&&(0,U.jsx)(hg,{children:(0,U.jsx)(hv,{colSpan:4,className:"text-center text-muted-foreground",children:"No runs yet — click “Run now” to try it"})})]})]})})}),(0,U.jsx)(hh,{}),(0,U.jsx)(uf,{defaultSize:67,minSize:25,children:(0,U.jsx)("div",{className:"h-full overflow-auto px-5 py-4",children:W&&!H?(0,U.jsx)("div",{className:"h-full flex items-center justify-center text-sm text-muted-foreground",children:"Loading run output…"}):H?.error?(0,U.jsxs)("div",{className:"h-full flex flex-col items-center justify-center gap-3 text-sm",children:[(0,U.jsx)("div",{className:"text-destructive",children:H.error}),(0,U.jsx)(a$.Button,{size:"sm",variant:"outline",onClick:()=>D(e=>e+1),children:"Retry"})]}):H?.run?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)("div",{className:"mb-4 pb-3 border-b border-border/60",children:[(0,U.jsxs)("div",{className:"text-sm font-medium",children:[H.run.report?"Run report":"Run output"," — ",mo(H.run.started_at)]}),(0,U.jsxs)("div",{className:"mt-2 flex items-center gap-3 text-xs text-muted-foreground",children:[(0,U.jsx)("span",{className:(0,e1.cn)("px-1.5 py-0.5 rounded text-[11px] font-medium",ms[H.run.status]),children:H.run.status}),(0,U.jsx)("span",{children:ml(H.run)}),(0,U.jsxs)("span",{children:["Exit code: ",H.run.exit_code??"—"]})]})]}),H.run.report?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)("div",{className:"rounded-md border border-border/50 p-3 text-sm",children:(0,U.jsx)(r0.i,{className:"[&>*:first-child]:mt-0 [&>*:last-child]:mb-0",children:H.run.report})}),(0,U.jsxs)("details",{className:"mt-3",children:[(0,U.jsx)("summary",{className:"text-xs text-muted-foreground cursor-pointer select-none",children:"Raw output"}),(0,U.jsx)("pre",{className:"mt-2 overflow-auto rounded-md bg-muted/50 p-3 font-mono text-xs whitespace-pre-wrap",children:H.run.output?mi(H.run.output):"(no output captured)"})]})]}):(0,U.jsx)("pre",{className:"overflow-auto rounded-md bg-muted/50 p-3 font-mono text-xs whitespace-pre-wrap",children:H.run.output?mi(H.run.output):"(no output captured)"})]}):(0,U.jsx)("div",{className:"h-full flex items-center justify-center text-sm text-muted-foreground",children:"Select a run to view its output"})})})]})}),(0,U.jsx)(mr,{open:_,onOpenChange:S,initial:y,onSubmit:async e=>{await c(y.id,e)},worktrees:o,projectId:e,hasLocal:r,onOpenRun:z,onDelete:P})]}),(0,U.jsx)(mr,{open:h,onOpenChange:f,onSubmit:async e=>{a((await l(e)).id)},worktrees:o,projectId:e}),(0,U.jsx)(lJ,{open:null!==I,onOpenChange:e=>{e||P(null)},children:(0,U.jsxs)(l0,{children:[(0,U.jsxs)(l1,{children:[(0,U.jsx)(l5,{children:"Delete scheduled task?"}),(0,U.jsx)(l3,{children:I?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)("span",{className:"font-medium text-foreground",children:I.name})," ","and its run history will be permanently deleted. This cannot be undone."]}):null})]}),(0,U.jsxs)(l2,{children:[(0,U.jsx)(l6,{children:"Cancel"}),(0,U.jsx)(l4,{className:(0,e1.cn)((0,a$.buttonVariants)({variant:"destructive"}),"border-transparent"),onClick:()=>{P(null),I&&(M(null),d(I.id).catch(e=>{M(e instanceof Error?e.message:"Failed to delete")}))},children:"Delete"})]})]})})]}):(0,U.jsxs)("div",{className:"flex flex-col h-full items-center justify-center gap-3 text-center",children:[(0,U.jsx)(aM,{className:"h-8 w-8 text-muted-foreground/50"}),(0,U.jsx)("p",{className:"text-sm text-muted-foreground",children:"No scheduled tasks yet"}),(0,U.jsx)(a$.Button,{size:"sm",onClick:()=>f(!0),children:"New Scheduled Task"}),(0,U.jsx)(mr,{open:h,onOpenChange:f,onSubmit:async e=>{await l(e)},worktrees:o,projectId:e,hasLocal:r})]})}let md=(0,rE.default)("panel-left-close",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m16 15-3-3 3-3",key:"14y99z"}]]),mu=(0,rE.default)("panel-left-open",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m14 9 3 3-3 3",key:"8010ee"}]]);function mh({className:e}){return(0,U.jsx)("svg",{viewBox:"0 0 24 24",fill:"currentColor",className:(0,e1.cn)("h-4 w-4",e),"aria-hidden":"true",children:(0,U.jsx)("path",{d:"M20.317 4.3698a19.7913 19.7913 0 00-4.8851-1.5152.0741.0741 0 00-.0785.0371c-.211.3753-.4447.8648-.6083 1.2495-1.8447-.2762-3.68-.2762-5.4868 0-.1636-.3933-.4058-.8742-.6177-1.2495a.077.077 0 00-.0785-.037 19.7363 19.7363 0 00-4.8852 1.515.0699.0699 0 00-.0321.0277C.5334 9.0458-.319 13.5799.0992 18.0578a.0824.0824 0 00.0312.0561c2.0528 1.5076 4.0413 2.4228 5.9929 3.0294a.0777.0777 0 00.0842-.0276c.4616-.6304.8731-1.2952 1.226-1.9942a.076.076 0 00-.0416-.1057c-.6528-.2476-1.2743-.5495-1.8722-.8923a.077.077 0 01-.0076-.1277c.1258-.0943.2517-.1923.3718-.2914a.0743.0743 0 01.0776-.0105c3.9278 1.7933 8.18 1.7933 12.0614 0a.0739.0739 0 01.0785.0095c.1202.099.246.1981.3728.2924a.077.077 0 01-.0066.1276 12.2986 12.2986 0 01-1.873.8914.0766.0766 0 00-.0407.1067c.3604.698.7719 1.3628 1.225 1.9932a.076.076 0 00.0842.0286c1.961-.6067 3.9495-1.5219 6.0023-3.0294a.077.077 0 00.0313-.0552c.5004-5.177-.8382-9.6739-3.5485-13.6604a.061.061 0 00-.0312-.0286zM8.02 15.3312c-1.1825 0-2.1569-1.0857-2.1569-2.419 0-1.3332.9555-2.4189 2.157-2.4189 1.2108 0 2.1757 1.0952 2.1568 2.419 0 1.3332-.9555 2.4189-2.1569 2.4189zm7.9748 0c-1.1825 0-2.1569-1.0857-2.1569-2.419 0-1.3332.9554-2.4189 2.1569-2.4189 1.2108 0 2.1757 1.0952 2.1568 2.419 0 1.3332-.946 2.4189-2.1568 2.4189z"})})}function mf({inviteUrl:e}){return e?(0,U.jsx)(a$.Button,{asChild:!0,variant:"ghost",size:"icon-sm",title:"Join our Discord",children:(0,U.jsx)("a",{href:e,target:"_blank",rel:"noopener noreferrer","aria-label":"Join our Discord",children:(0,U.jsx)(mh,{})})}):null}var mp=e.i(510339);function mm({open:e,onOpenChange:r,onProjectCreated:s}){let{config:n}=(0,ow.useAppConfig)(),i=n?.localProjectsEnabled!==!1,[a,o]=(0,V.useState)(""),[l,c]=(0,V.useState)(""),[d,u]=(0,V.useState)([]),[h,f]=(0,V.useState)("closed"),[p,m]=(0,V.useState)([]),[g,x]=(0,V.useState)(null),[v,y]=(0,V.useState)(""),[b,w]=(0,V.useState)(!1),[_,S]=(0,V.useState)(""),k=()=>{o(""),c(""),u([]),j(),S("")},j=()=>{f("closed"),x(null),y("")},C=e=>{e||k(),r(e)},N=async()=>{let e=await aC.api.selectFolder();e.path&&(c(e.path),a||o(e.path.split("/").pop()||""))},E=async()=>{f("pick-server");try{let e=await aC.api.getRemoteServers();m(e)}catch{m([])}},D=l.trim().length>0,T=d.length>0,R=async()=>{if(!a.trim())return void S("Project name is required");if(!D&&!T)return void S(i?"Please provide a local folder, remote server, or both":"Please add a remote server");w(!0),S("");try{let e=await aC.api.createProject({name:a.trim(),...D?{path:l.trim()}:{},...T&&!D?{agentMode:d[0].serverId}:{}});for(let r of d)await aC.api.addProjectRemote(e.id,{remoteServerId:r.serverId,remotePath:r.remotePath});s(e),k(),r(!1)}catch(e){S(e instanceof Error?e.message:"Failed to create project")}finally{w(!1)}};return(0,U.jsx)(rT,{open:e,onOpenChange:C,children:(0,U.jsxs)(rP,{className:"max-w-lg h-[620px] max-h-[calc(100vh-4rem)] grid-rows-[auto_minmax(0,1fr)_auto]",children:[(0,U.jsx)(rF,{children:(0,U.jsx)(rO,{children:"Create New Project"})}),(0,U.jsx)("div",{className:"overflow-y-auto -mx-1 px-1",children:(0,U.jsxs)("div",{className:"space-y-5 py-2",children:[(0,U.jsxs)("div",{className:"space-y-2",children:[(0,U.jsx)("label",{className:"text-sm font-medium",children:"Project Name"}),(0,U.jsx)(aX,{value:a,onChange:e=>o(e.target.value),placeholder:"My Project"})]}),i&&(0,U.jsxs)("div",{className:"space-y-2",children:[(0,U.jsx)("label",{className:"text-sm font-medium",children:"Local Folder"}),(0,U.jsxs)("div",{className:"flex gap-2",children:[(0,U.jsx)(aX,{value:l,onChange:e=>c(e.target.value),placeholder:"/path/to/project (optional)",className:"flex-1"}),(0,U.jsx)(a$.Button,{variant:"outline",onClick:N,children:(0,U.jsx)(o_,{className:"h-4 w-4"})})]})]}),(0,U.jsxs)("div",{className:"space-y-3",children:[(0,U.jsx)("label",{className:"text-sm font-medium",children:"Remote Servers"}),d.length>0&&(0,U.jsx)("div",{className:"space-y-2",children:d.map((e,r)=>(0,U.jsxs)("div",{className:"flex items-center gap-2 rounded-md border p-2 text-sm",children:[(0,U.jsx)(oC,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),(0,U.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,U.jsx)("p",{className:"font-medium truncate",children:e.serverName}),(0,U.jsx)("p",{className:"text-xs text-muted-foreground font-mono truncate",children:e.remotePath})]}),(0,U.jsx)(a$.Button,{variant:"ghost",size:"icon-sm",className:"h-7 w-7 shrink-0",onClick:()=>{u(e=>e.filter((e,s)=>s!==r))},children:(0,U.jsx)(ok,{className:"h-3.5 w-3.5 text-muted-foreground"})})]},`${e.serverId}-${e.remotePath}`))}),"closed"===h&&(0,U.jsxs)(a$.Button,{variant:"outline",size:"sm",onClick:E,className:"w-full",children:[(0,U.jsx)(oS,{className:"h-4 w-4 mr-1"}),"Add Remote"]}),"pick-server"===h&&(0,U.jsxs)("div",{className:"rounded-md border p-3 space-y-3",children:[(0,U.jsxs)("div",{className:"flex items-center justify-between",children:[(0,U.jsx)("label",{className:"text-xs font-medium",children:"Select a Remote Server"}),(0,U.jsx)(a$.Button,{variant:"ghost",size:"sm",onClick:j,children:(0,U.jsx)(rD,{className:"h-3.5 w-3.5"})})]}),p.length>0&&(0,U.jsx)("div",{className:"space-y-1",children:p.map(e=>(0,U.jsxs)("button",{className:"flex items-center gap-2 w-full rounded-md p-2 text-sm text-left hover:bg-muted",onClick:()=>{x(e),y(""),f("pick-path")},children:[(0,U.jsx)(oj,{className:"h-4 w-4 text-muted-foreground"}),(0,U.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,U.jsx)("p",{className:"truncate",children:e.name}),(0,U.jsx)("p",{className:"text-xs text-muted-foreground truncate",children:"online"===e.status?"Connected":"Not connected"})]})]},e.id))}),(0,U.jsx)("p",{className:"text-xs text-muted-foreground",children:"Add new servers in Settings → Remote Servers, then connect the remote machine with a connect token."})]}),"pick-path"===h&&g&&(0,U.jsxs)("div",{className:"rounded-md border p-3 space-y-3",children:[(0,U.jsxs)("div",{className:"flex items-center justify-between",children:[(0,U.jsxs)("label",{className:"text-xs font-medium",children:["Select Directory on ",g.name]}),(0,U.jsx)(a$.Button,{variant:"ghost",size:"sm",onClick:j,children:(0,U.jsx)(rD,{className:"h-3.5 w-3.5"})})]}),(0,U.jsx)(ls,{serverId:g.id,onSelect:e=>{y(e)},selectedPath:v}),v&&(0,U.jsxs)("div",{className:"flex items-center justify-between",children:[(0,U.jsxs)("p",{className:"text-xs text-muted-foreground",children:["Selected: ",(0,U.jsx)("span",{className:"font-mono",children:v})]}),(0,U.jsx)(a$.Button,{size:"sm",onClick:()=>{g&&v&&(d.some(e=>e.serverId===g.id&&e.remotePath===v)||(u(e=>[...e,{serverId:g.id,serverName:g.name,remotePath:v}]),a||o(v.split("/").pop()||"")),j())},children:"Add"})]})]})]}),_&&(0,U.jsx)("p",{className:"text-sm text-red-500 pt-3",children:_})]})}),(0,U.jsxs)(rL,{children:[(0,U.jsx)(a$.Button,{variant:"outline",onClick:()=>C(!1),children:"Cancel"}),(0,U.jsx)(a$.Button,{onClick:R,disabled:b,children:b?"Creating...":"Create Project"})]})]})})}let mg=(0,rE.default)("network",[["rect",{x:"16",y:"16",width:"6",height:"6",rx:"1",key:"4q2zg0"}],["rect",{x:"2",y:"16",width:"6",height:"6",rx:"1",key:"8cvhb9"}],["rect",{x:"9",y:"2",width:"6",height:"6",rx:"1",key:"1egb70"}],["path",{d:"M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3",key:"1jsf9p"}],["path",{d:"M12 12V8",key:"2874zd"}]]),mx=(0,rE.default)("palette",[["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"}]]),mv=(0,rE.default)("sparkles",[["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"}]]),my=(0,rE.default)("square-terminal",[["path",{d:"m7 11 2-2-2-2",key:"1lz0vl"}],["path",{d:"M11 13h4",key:"1p7l4v"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}]]),mb=(0,rE.default)("volume-2",[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",key:"uqj9uw"}],["path",{d:"M16 9a5 5 0 0 1 0 6",key:"1q6k2b"}],["path",{d:"M19.364 18.364a9 9 0 0 0 0-12.728",key:"ijwkga"}]]);var mw=e.i(710307);let m_=(0,rE.default)("refresh-cw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]]);function mS({label:e,value:r}){let[s,n]=(0,V.useState)(!1);return(0,U.jsxs)("div",{className:"flex items-center justify-between gap-3 py-1.5",children:[(0,U.jsx)("span",{className:"text-sm text-muted-foreground shrink-0",children:e}),(0,U.jsxs)("span",{className:"flex items-center gap-1 min-w-0",children:[(0,U.jsx)("code",{className:"text-xs font-mono truncate",children:r??"—"}),r&&(0,U.jsx)("button",{type:"button",title:"复制",className:"p-1 rounded text-muted-foreground hover:text-foreground hover:bg-muted transition-colors",onClick:()=>{navigator.clipboard.writeText(r).then(()=>{n(!0),setTimeout(()=>n(!1),1500)})},children:s?(0,U.jsx)(al.Check,{className:"h-3 w-3 text-green-600"}):(0,U.jsx)(mw.Copy,{className:"h-3 w-3"})})]})]})}function mk(){let{serverBuildId:e,updateAvailable:r}=(0,aF.useConnectionStatus)(),s=null!==aF.UI_BUILD_ID&&null!==e&&aF.UI_BUILD_ID===e;return(0,U.jsxs)("div",{className:"space-y-3",children:[(0,U.jsxs)("div",{className:"rounded-md border border-border divide-y divide-border px-3",children:[(0,U.jsx)(mS,{label:"UI build",value:aF.UI_BUILD_ID}),(0,U.jsx)(mS,{label:"Server build",value:e})]}),s&&(0,U.jsxs)("div",{className:"flex items-center gap-2 text-sm text-green-600 dark:text-green-400",children:[(0,U.jsx)(al.Check,{className:"h-4 w-4 shrink-0"}),"当前已是最新版本"]}),r&&(0,U.jsxs)("div",{className:"flex items-center justify-between gap-3 rounded-md border border-sky-500/40 bg-sky-500/10 p-3",children:[(0,U.jsx)("span",{className:"text-sm text-sky-700 dark:text-sky-400",children:"服务器已更新到新版本,刷新页面即可加载。"}),(0,U.jsxs)(a$.Button,{size:"sm",onClick:()=>window.location.reload(),children:[(0,U.jsx)(m_,{className:"h-3.5 w-3.5 mr-1.5"}),"刷新"]})]}),(0,U.jsx)("p",{className:"text-xs text-muted-foreground",children:"构建指纹在构建时取自 git 提交号,用于检测浏览器中的 UI 与服务器提供的 UI 是否为同一次构建。报告问题时请附上以上信息。"})]})}let mj=(0,rE.default)("moon",[["path",{d:"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401",key:"kfwtm"}]]),mC=(0,rE.default)("sun",[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]]);var mN=e.i(371263),mE=["PageUp","PageDown"],mD=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],mT={"from-left":["Home","PageDown","ArrowDown","ArrowLeft"],"from-right":["Home","PageDown","ArrowDown","ArrowRight"],"from-bottom":["Home","PageDown","ArrowDown","ArrowLeft"],"from-top":["Home","PageDown","ArrowUp","ArrowLeft"]},mR="Slider",[mA,mM,mI]=ea(mR),[mP,mF]=es(mR,[mI]),[mL,mO]=mP(mR),mB=V.forwardRef((e,r)=>{let{name:s,min:n=0,max:i=100,step:a=1,orientation:o="horizontal",disabled:l=!1,minStepsBetweenThumbs:c=0,defaultValue:d=[n],value:u,onValueChange:h=()=>{},onValueCommit:f=()=>{},inverted:p=!1,form:m,...g}=e,x=V.useRef(new Set),v=V.useRef(0),y="horizontal"===o,[b=[],w]=ey({prop:u,defaultProp:d,onChange:e=>{let r=[...x.current];r[v.current]?.focus(),h(e)}}),_=V.useRef(b);function S(e,r,{commit:s}={commit:!1}){let o,l=(String(a).split(".")[1]||"").length,d=oE(Math.round((Math.round((e-n)/a)*a+n)*(o=Math.pow(10,l)))/o,[n,i]);w((e=[])=>{let n=function(e=[],r,s){let n=[...e];return n[s]=r,n.sort((e,r)=>e-r)}(e,d,r);if(!function(e,r){if(r>0)return Math.min(...e.slice(0,-1).map((r,s)=>e[s+1]-r))>=r;return!0}(n,c*a))return e;{v.current=n.indexOf(d);let r=String(n)!==String(e);return r&&s&&f(n),r?n:e}})}return(0,U.jsx)(mL,{scope:e.__scopeSlider,name:s,disabled:l,min:n,max:i,valueIndexToChangeRef:v,thumbs:x.current,values:b,orientation:o,form:m,children:(0,U.jsx)(mA.Provider,{scope:e.__scopeSlider,children:(0,U.jsx)(mA.Slot,{scope:e.__scopeSlider,children:(0,U.jsx)(y?mW:mH,{"aria-disabled":l,"data-disabled":l?"":void 0,...g,ref:r,onPointerDown:er(g.onPointerDown,()=>{l||(_.current=b)}),min:n,max:i,inverted:p,onSlideStart:l?void 0:function(e){let r=function(e,r){if(1===e.length)return 0;let s=e.map(e=>Math.abs(e-r)),n=Math.min(...s);return s.indexOf(n)}(b,e);S(e,r)},onSlideMove:l?void 0:function(e){S(e,v.current)},onSlideEnd:l?void 0:function(){let e=_.current[v.current];b[v.current]!==e&&f(b)},onHomeKeyDown:()=>!l&&S(n,0,{commit:!0}),onEndKeyDown:()=>!l&&S(i,b.length-1,{commit:!0}),onStepKeyDown:({event:e,direction:r})=>{if(!l){let s=mE.includes(e.key)||e.shiftKey&&mD.includes(e.key),n=v.current;S(b[n]+a*(s?10:1)*r,n,{commit:!0})}}})})})})});mB.displayName=mR;var[mz,m$]=mP(mR,{startEdge:"left",endEdge:"right",size:"width",direction:1}),mW=V.forwardRef((e,r)=>{let{min:s,max:n,dir:i,inverted:a,onSlideStart:o,onSlideMove:l,onSlideEnd:c,onStepKeyDown:d,...u}=e,[h,f]=V.useState(null),p=(0,en.useComposedRefs)(r,e=>f(e)),m=V.useRef(void 0),g=ew(i),x="ltr"===g,v=x&&!a||!x&&a;function y(e){let r=m.current||h.getBoundingClientRect(),i=m0([0,r.width],v?[s,n]:[n,s]);return m.current=r,i(e-r.left)}return(0,U.jsx)(mz,{scope:e.__scopeSlider,startEdge:v?"left":"right",endEdge:v?"right":"left",direction:v?1:-1,size:"width",children:(0,U.jsx)(mU,{dir:g,"data-orientation":"horizontal",...u,ref:p,style:{...u.style,"--radix-slider-thumb-transform":"translateX(-50%)"},onSlideStart:e=>{let r=y(e.clientX);o?.(r)},onSlideMove:e=>{let r=y(e.clientX);l?.(r)},onSlideEnd:()=>{m.current=void 0,c?.()},onStepKeyDown:e=>{let r=mT[v?"from-left":"from-right"].includes(e.key);d?.({event:e,direction:r?-1:1})}})})}),mH=V.forwardRef((e,r)=>{let{min:s,max:n,inverted:i,onSlideStart:a,onSlideMove:o,onSlideEnd:l,onStepKeyDown:c,...d}=e,u=V.useRef(null),h=(0,en.useComposedRefs)(r,u),f=V.useRef(void 0),p=!i;function m(e){let r=f.current||u.current.getBoundingClientRect(),i=m0([0,r.height],p?[n,s]:[s,n]);return f.current=r,i(e-r.top)}return(0,U.jsx)(mz,{scope:e.__scopeSlider,startEdge:p?"bottom":"top",endEdge:p?"top":"bottom",size:"height",direction:p?1:-1,children:(0,U.jsx)(mU,{"data-orientation":"vertical",...d,ref:h,style:{...d.style,"--radix-slider-thumb-transform":"translateY(50%)"},onSlideStart:e=>{let r=m(e.clientY);a?.(r)},onSlideMove:e=>{let r=m(e.clientY);o?.(r)},onSlideEnd:()=>{f.current=void 0,l?.()},onStepKeyDown:e=>{let r=mT[p?"from-bottom":"from-top"].includes(e.key);c?.({event:e,direction:r?-1:1})}})})}),mU=V.forwardRef((e,r)=>{let{__scopeSlider:s,onSlideStart:n,onSlideMove:i,onSlideEnd:a,onHomeKeyDown:o,onEndKeyDown:l,onStepKeyDown:c,...d}=e,u=mO(mR,s);return(0,U.jsx)(em.span,{...d,ref:r,onKeyDown:er(e.onKeyDown,e=>{"Home"===e.key?(o(e),e.preventDefault()):"End"===e.key?(l(e),e.preventDefault()):mE.concat(mD).includes(e.key)&&(c(e),e.preventDefault())}),onPointerDown:er(e.onPointerDown,e=>{let r=e.target;r.setPointerCapture(e.pointerId),e.preventDefault(),u.thumbs.has(r)?r.focus():n(e)}),onPointerMove:er(e.onPointerMove,e=>{e.target.hasPointerCapture(e.pointerId)&&i(e)}),onPointerUp:er(e.onPointerUp,e=>{let r=e.target;r.hasPointerCapture(e.pointerId)&&(r.releasePointerCapture(e.pointerId),a(e))})})}),mV="SliderTrack",mq=V.forwardRef((e,r)=>{let{__scopeSlider:s,...n}=e,i=mO(mV,s);return(0,U.jsx)(em.span,{"data-disabled":i.disabled?"":void 0,"data-orientation":i.orientation,...n,ref:r})});mq.displayName=mV;var mK="SliderRange",mX=V.forwardRef((e,r)=>{let{__scopeSlider:s,...n}=e,i=mO(mK,s),a=m$(mK,s),o=V.useRef(null),l=(0,en.useComposedRefs)(r,o),c=i.values.length,d=i.values.map(e=>mQ(e,i.min,i.max)),u=c>1?Math.min(...d):0,h=100-Math.max(...d);return(0,U.jsx)(em.span,{"data-orientation":i.orientation,"data-disabled":i.disabled?"":void 0,...n,ref:l,style:{...e.style,[a.startEdge]:u+"%",[a.endEdge]:h+"%"}})});mX.displayName=mK;var mY="SliderThumb",mG=V.forwardRef((e,r)=>{let s=mM(e.__scopeSlider),[n,i]=V.useState(null),a=(0,en.useComposedRefs)(r,e=>i(e)),o=V.useMemo(()=>n?s().findIndex(e=>e.ref.current===n):-1,[s,n]);return(0,U.jsx)(mJ,{...e,ref:a,index:o})}),mJ=V.forwardRef((e,r)=>{var s,n,i,a,o;let l,c,{__scopeSlider:d,index:u,name:h,...f}=e,p=mO(mY,d),m=m$(mY,d),[g,x]=V.useState(null),v=(0,en.useComposedRefs)(r,e=>x(e)),y=!g||p.form||!!g.closest("form"),b=np(g),w=p.values[u],_=void 0===w?0:mQ(w,p.min,p.max),S=(s=u,(n=p.values.length)>2?`Value ${s+1} of ${n}`:2===n?["Minimum","Maximum"][s]:void 0),k=b?.[m.size],j=k?(i=k,a=_,o=m.direction,c=m0([0,50],[0,l=i/2]),(l-c(a)*o)*o):0;return V.useEffect(()=>{if(g)return p.thumbs.add(g),()=>{p.thumbs.delete(g)}},[g,p.thumbs]),(0,U.jsxs)("span",{style:{transform:"var(--radix-slider-thumb-transform)",position:"absolute",[m.startEdge]:`calc(${_}% + ${j}px)`},children:[(0,U.jsx)(mA.ItemSlot,{scope:e.__scopeSlider,children:(0,U.jsx)(em.span,{role:"slider","aria-label":e["aria-label"]||S,"aria-valuemin":p.min,"aria-valuenow":w,"aria-valuemax":p.max,"aria-orientation":p.orientation,"data-orientation":p.orientation,"data-disabled":p.disabled?"":void 0,tabIndex:p.disabled?void 0:0,...f,ref:v,style:void 0===w?{display:"none"}:e.style,onFocus:er(e.onFocus,()=>{p.valueIndexToChangeRef.current=u})})}),y&&(0,U.jsx)(mZ,{name:h??(p.name?p.name+(p.values.length>1?"[]":""):void 0),form:p.form,value:w},u)]})});mG.displayName=mY;var mZ=V.forwardRef(({__scopeSlider:e,value:r,...s},n)=>{let i=V.useRef(null),a=(0,en.useComposedRefs)(i,n),o=hH(r);return V.useEffect(()=>{let e=i.current;if(!e)return;let s=Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype,"value").set;if(o!==r&&s){let n=new Event("input",{bubbles:!0});s.call(e,r),e.dispatchEvent(n)}},[o,r]),(0,U.jsx)(em.input,{style:{display:"none"},...s,ref:a,defaultValue:r})});function mQ(e,r,s){return oE(100/(s-r)*(e-r),[0,100])}function m0(e,r){return s=>{if(e[0]===e[1]||r[0]===r[1])return r[0];let n=(r[1]-r[0])/(e[1]-e[0]);return r[0]+n*(s-e[0])}}mZ.displayName="RadioBubbleInput";let m1=V.forwardRef(({className:e,...r},s)=>(0,U.jsxs)(mB,{ref:s,className:(0,e1.cn)("relative flex w-full touch-none select-none items-center","data-[disabled]:opacity-50",e),...r,children:[(0,U.jsx)(mq,{className:"relative h-1.5 w-full grow overflow-hidden rounded-full bg-muted",children:(0,U.jsx)(mX,{className:"absolute h-full bg-primary"})}),(0,U.jsx)(mG,{className:(0,e1.cn)("block h-4 w-4 rounded-full border border-primary/60 bg-card shadow-[var(--shadow-sm-app)]","transition-colors hover:border-primary","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/40 focus-visible:ring-offset-1 focus-visible:ring-offset-background"),"aria-label":"Value"})]}));function m2({id:e,label:r,description:s,rightSlot:n,children:i}){return(0,U.jsxs)("section",{id:e,className:"scroll-mt-6 rounded-[10px] border border-border bg-card p-5 shadow-[var(--shadow-sm-app)]",children:[(0,U.jsxs)("header",{className:"flex items-end justify-between gap-3 pb-3 mb-4 border-b border-border/70",children:[(0,U.jsxs)("div",{className:"min-w-0",children:[(0,U.jsx)("h2",{className:"text-[10.5px] font-semibold uppercase tracking-[0.08em] text-muted-foreground/80 leading-none",children:r}),s&&(0,U.jsx)("p",{className:"mt-2 text-[12px] text-muted-foreground/90 leading-snug",children:s})]}),n&&(0,U.jsx)("div",{className:"shrink-0",children:n})]}),(0,U.jsx)("div",{className:"space-y-4",children:i})]})}function m5({label:e,hint:r,htmlFor:s,mono:n,children:i}){return(0,U.jsxs)("div",{children:[(0,U.jsx)("label",{htmlFor:s,className:(0,e1.cn)("block text-[12px] font-medium text-foreground/90 mb-1.5",n&&"font-mono tracking-tight"),children:e}),i,r&&(0,U.jsx)("p",{className:"mt-1.5 text-[11px] text-muted-foreground/85 leading-relaxed",children:r})]})}function m3({name:e,value:r,options:s,onChange:n,columns:i=1}){return(0,U.jsx)("div",{className:(0,e1.cn)("grid gap-2",1===i&&"grid-cols-1",2===i&&"grid-cols-1 sm:grid-cols-2",3===i&&"grid-cols-1 sm:grid-cols-3"),role:"radiogroup",children:s.map(s=>{let i=r===s.value,a=s.Icon;return(0,U.jsxs)("label",{className:(0,e1.cn)("group relative flex items-start gap-3 px-3 py-2.5 rounded-[8px] border cursor-pointer","transition-[border-color,background-color,box-shadow] duration-150","focus-within:ring-2 focus-within:ring-ring/40 focus-within:ring-offset-1 focus-within:ring-offset-background",i?"border-primary/40 bg-[color-mix(in_oklch,var(--primary)_8%,var(--card))] shadow-[var(--shadow-sm-app)]":"border-border/70 bg-card hover:border-border hover:bg-muted/40"),children:[(0,U.jsx)("input",{type:"radio",name:e,value:s.value,checked:i,onChange:()=>n(s.value),className:"sr-only"}),(0,U.jsx)("span",{"aria-hidden":!0,className:(0,e1.cn)("mt-0.5 inline-flex h-4 w-4 shrink-0 items-center justify-center rounded-full border transition-colors",i?"border-primary bg-primary":"border-border bg-card group-hover:border-foreground/40"),children:i&&(0,U.jsx)("span",{className:"h-1.5 w-1.5 rounded-full bg-primary-foreground"})}),a&&(0,U.jsx)(a,{className:(0,e1.cn)("h-4 w-4 mt-0.5 shrink-0 transition-colors",i?"text-primary":"text-muted-foreground")}),(0,U.jsxs)("span",{className:"flex-1 min-w-0",children:[(0,U.jsx)("span",{className:(0,e1.cn)("block text-[12.5px] font-medium leading-tight",i?"text-foreground":"text-foreground/90"),children:s.label}),s.description&&(0,U.jsx)("span",{className:"mt-0.5 block text-[11.5px] text-muted-foreground leading-snug",children:s.description})]}),s.meta&&(0,U.jsx)("span",{className:"ml-2 mt-0.5 shrink-0 font-mono text-[10.5px] text-muted-foreground/80",children:s.meta})]},s.value)})})}function m4({variant:e="default",icon:r,trailing:s,children:n}){return(0,U.jsxs)("div",{className:(0,e1.cn)("flex items-center gap-2 rounded-[6px] px-2.5 py-1.5 text-[12px]","default"===e&&"text-muted-foreground bg-muted/40","success"===e&&"text-[color:var(--chart-2)] bg-[color-mix(in_oklch,var(--chart-2)_10%,var(--card))] border border-[color-mix(in_oklch,var(--chart-2)_25%,transparent)]","error"===e&&"text-destructive bg-[color-mix(in_oklch,var(--destructive)_8%,var(--card))] border border-[color-mix(in_oklch,var(--destructive)_25%,transparent)]"),children:[r&&(0,U.jsx)("span",{className:"shrink-0",children:r}),(0,U.jsx)("span",{className:"truncate",children:n}),s&&(0,U.jsx)("span",{className:"shrink-0 inline-flex",children:s})]})}function m6({issues:e,summary:r}){if(0===e.length)return null;let s=(0,U.jsx)(ou,{className:"h-3.5 w-3.5"});if(1===e.length){let[r]=e;return(0,U.jsxs)(m4,{icon:s,children:[r.name,": ",r.message]})}return(0,U.jsx)(m4,{icon:s,trailing:(0,U.jsx)(cI,{children:(0,U.jsxs)(cP,{children:[(0,U.jsx)(cF,{asChild:!0,children:(0,U.jsx)("button",{type:"button","aria-label":"Show affected machines",className:"rounded-sm text-muted-foreground/80 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/40",children:(0,U.jsx)(h$,{className:"h-3.5 w-3.5"})})}),(0,U.jsx)(cL,{side:"top",className:"max-w-sm text-left text-pretty",children:(0,U.jsx)("ul",{className:"space-y-1",children:e.map(e=>(0,U.jsxs)("li",{children:[(0,U.jsx)("span",{className:"font-medium",children:e.name}),": ",e.message]},e.id))})})]})}),children:r})}function m7({children:e}){return(0,U.jsx)("div",{className:"flex items-center justify-end gap-2 pt-1",children:e})}function m8({nav:e,children:r}){let[s,n]=(0,V.useState)(e[0]?.id??""),i=(0,V.useRef)(null);return(0,V.useEffect)(()=>{let r=i.current;if(!r)return;let s=()=>{let s=r.getBoundingClientRect(),i=s.top+.25*s.height,a=e[0]?.id??"";for(let s of e){let e=r.querySelector(`#${CSS.escape(s.id)}`);e&&e.getBoundingClientRect().top<=i&&(a=s.id)}n(a)};return s(),r.addEventListener("scroll",s,{passive:!0}),()=>r.removeEventListener("scroll",s)},[e]),(0,U.jsxs)("div",{className:"flex-1 min-h-0 grid grid-cols-[200px_minmax(0,1fr)] overflow-hidden",children:[(0,U.jsx)("aside",{className:"border-r border-border bg-[color:var(--sidebar)] overflow-y-auto",children:(0,U.jsx)("nav",{className:"p-3 flex flex-col gap-0.5",children:e.map(e=>{let r=e.Icon,a=s===e.id;return(0,U.jsxs)("button",{type:"button",onClick:()=>(e=>{let r=i.current;if(!r)return;let s=r.querySelector(`#${CSS.escape(e)}`);if(!s)return;let a=s.offsetTop-12;r.scrollTo({top:a,behavior:"smooth"}),n(e)})(e.id),className:(0,e1.cn)("group relative flex items-center gap-2.5 w-full px-2.5 py-1.5 rounded-[6px] text-[12.5px] text-left","transition-colors duration-100",a?"bg-card text-foreground font-medium shadow-[var(--shadow-sm-app)]":"text-muted-foreground hover:bg-muted/50 hover:text-foreground"),children:[a&&(0,U.jsx)("span",{"aria-hidden":!0,className:"absolute -left-3 top-1.5 bottom-1.5 w-[2px] rounded-full bg-primary"}),r&&(0,U.jsx)(r,{className:(0,e1.cn)("h-3.5 w-3.5 shrink-0",a?"text-foreground":"text-muted-foreground/80")}),(0,U.jsx)("span",{className:"truncate",children:e.label}),e.badge&&(0,U.jsx)("span",{className:"ml-auto font-mono text-[10px] text-muted-foreground/80",children:e.badge})]},e.id)})})}),(0,U.jsx)("div",{ref:i,className:"overflow-y-auto",children:(0,U.jsx)("div",{className:"mx-auto max-w-2xl px-8 py-7 space-y-6",children:r})})]})}m1.displayName="Slider";let m9=[{value:"light",label:"Light",description:"Bright surface, true-white cards",Icon:mC},{value:"dark",label:"Dark",description:"Low-light surfaces with deep neutrals",Icon:mj},{value:"system",label:"System",description:"Match your OS preference",Icon:hW}],{fontSizeMin:ge,fontSizeMax:gt}=aC.CONVERSATION_SETTINGS_LIMITS;function gr(){let{theme:e,setTheme:r}=(0,mN.useTheme)(),{settings:s,setAgentFontSize:n,setChatFontSize:i,setFilesTreeFontSize:a,setFilesContentFontSize:o,setTasksFontSize:l}=(0,c1.useConversationSettings)();return(0,U.jsxs)("div",{className:"space-y-6",children:[(0,U.jsx)(m5,{label:"Theme",hint:"Sets the surface palette across the app. Switching is instant.",children:(0,U.jsx)(m3,{name:"theme",value:e,options:m9,onChange:r,columns:3})}),(0,U.jsx)(m5,{label:"Conversation font size",hint:"Independent typography for agent and chat views. Affects message body and tool output; chrome elements stay fixed.",children:(0,U.jsxs)("div",{className:"space-y-5",children:[(0,U.jsx)(gs,{label:"Agent session, Project Chat",value:s.agentFontSize,onChange:n}),(0,U.jsx)(gs,{label:"Chat session",value:s.chatFontSize,onChange:i})]})}),(0,U.jsx)(m5,{label:"Files font size",hint:"Independent typography for the Files tab. File tree controls the file list and search results; file content controls the preview and code.",children:(0,U.jsxs)("div",{className:"space-y-5",children:[(0,U.jsx)(gs,{label:"File tree, File search",value:s.filesTreeFontSize,onChange:a}),(0,U.jsx)(gs,{label:"File content",value:s.filesContentFontSize,onChange:o})]})}),(0,U.jsx)(m5,{label:"Tasks font size",hint:"Body text in the Tasks side panel — the description of an open task or a new draft.",children:(0,U.jsx)(gs,{label:"Task description",value:s.tasksFontSize,onChange:l})}),(0,U.jsx)(m7,{children:(0,U.jsx)(a$.Button,{variant:"ghost",size:"sm",onClick:()=>{n(aC.DEFAULT_CONVERSATION_SETTINGS.agentFontSize),i(aC.DEFAULT_CONVERSATION_SETTINGS.chatFontSize),a(aC.DEFAULT_CONVERSATION_SETTINGS.filesTreeFontSize),o(aC.DEFAULT_CONVERSATION_SETTINGS.filesContentFontSize),l(aC.DEFAULT_CONVERSATION_SETTINGS.tasksFontSize)},children:"Reset"})})]})}function gs({label:e,value:r,onChange:s}){return(0,U.jsxs)("div",{children:[(0,U.jsxs)("div",{className:"flex items-baseline justify-between mb-1.5",children:[(0,U.jsx)("span",{className:"text-[12px] font-medium text-foreground/90",children:e}),(0,U.jsxs)("span",{className:"font-mono text-[11.5px] text-foreground/80 tabular-nums",children:[r," px"]})]}),(0,U.jsx)(m1,{min:ge,max:gt,step:1,value:[r],onValueChange:e=>s(e[0])}),(0,U.jsxs)("div",{className:"flex justify-between mt-1 text-[10.5px] text-muted-foreground/80 font-mono",children:[(0,U.jsx)("span",{children:ge}),(0,U.jsx)("span",{children:gt})]})]})}let gn=(0,rE.default)("triangle",[["path",{d:"M13.73 4a2 2 0 0 0-3.46 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3Z",key:"14u9p9"}]]),gi=(0,rE.default)("waypoints",[["circle",{cx:"12",cy:"4.5",r:"2.5",key:"r5ysbb"}],["path",{d:"m10.2 6.3-3.9 3.9",key:"1nzqf6"}],["circle",{cx:"4.5",cy:"12",r:"2.5",key:"jydg6v"}],["path",{d:"M7 12h10",key:"b7w52i"}],["circle",{cx:"19.5",cy:"12",r:"2.5",key:"1piiel"}],["path",{d:"m13.8 17.7 3.9-3.9",key:"1wyg1y"}],["circle",{cx:"12",cy:"19.5",r:"2.5",key:"13o1pw"}]]),ga={deepseek:mv,openrouter:gi,gateway:gn},go=aC.PROVIDER_IDS.map(e=>({value:e,label:aC.PROVIDERS[e].label,description:aC.PROVIDERS[e].description,Icon:ga[e]}));function gl({name:e,value:r,onChange:s}){let n=aC.PROVIDERS[r.provider];return(0,U.jsxs)("div",{className:"space-y-3",children:[(0,U.jsx)(m3,{name:e,value:r.provider,options:go,onChange:e=>s((0,aC.defaultModelChoice)(e)),columns:2}),n.models?(0,U.jsxs)(fP,{value:r.model,onValueChange:e=>s({...r,model:e}),children:[(0,U.jsx)(fL,{className:"w-full font-mono text-[12.5px]",children:(0,U.jsx)(fF,{})}),(0,U.jsx)(fO,{children:n.models.map(e=>(0,U.jsx)(fB,{value:e,className:"font-mono text-[12.5px]",children:n.modelLabels?.[e]??e},e))})]}):(0,U.jsx)(aX,{className:"font-mono text-[12.5px]",placeholder:n.placeholder,value:r.model,onChange:e=>s({...r,model:e.target.value})})]})}function gc(){let[e,r]=(0,V.useState)(()=>(0,aC.defaultChatProviderConfig)().apiKeys),[s,n]=(0,V.useState)(()=>(0,aC.emptyByProvider)(!1)),[i,a]=(0,V.useState)(()=>(0,aC.defaultModelChoice)()),[o,l]=(0,V.useState)(()=>(0,aC.defaultModelChoice)()),[c,d]=(0,V.useState)(!0),[u,h]=(0,V.useState)(!1),[f,p]=(0,V.useState)(null);(0,V.useEffect)(()=>{d(!0),aC.api.getChatProviderSettings().then(e=>{r(e.apiKeys),a(e.main),l(e.fast),n((0,aC.emptyByProvider)(!1))}).finally(()=>d(!1))},[]);let m=async()=>{h(!0),p(null);try{let c={};for(let r of aC.PROVIDER_IDS)s[r]&&(c[r]=e[r]);let d={main:i,fast:o};Object.keys(c).length>0&&(d.apiKeys=c);let u=await aC.api.updateChatProviderSettings(d);r(u.apiKeys),a(u.main),l(u.fast),n((0,aC.emptyByProvider)(!1)),p("Settings saved"),setTimeout(()=>p(null),2e3)}catch(e){p(e instanceof Error?e.message:"Failed to save")}finally{h(!1)}};return c?(0,U.jsx)("div",{className:"flex items-center justify-center py-6",children:(0,U.jsx)(aP,{className:"h-4 w-4 animate-spin text-muted-foreground"})}):(0,U.jsxs)("div",{className:"space-y-6",children:[(0,U.jsxs)("div",{className:"space-y-4",children:[(0,U.jsx)("p",{className:"text-[12px] font-medium text-foreground/70",children:"API keys"}),aC.PROVIDER_IDS.map(i=>{let a=aC.PROVIDERS[i],o=s[i],l=e[i];return(0,U.jsx)(m5,{label:`${a.label} API key`,mono:!0,hint:(0,U.jsxs)(U.Fragment,{children:["Leave empty to fall back to the"," ",(0,U.jsx)("code",{className:"font-mono text-[10.5px] bg-muted/60 border border-border/60 rounded px-1 py-px",children:a.envKey})," ","environment variable."]}),children:(0,U.jsx)(aX,{type:"password",className:"font-mono text-[12px]",placeholder:l&&!o?l:a.keyPlaceholder??"sk-...",value:o?l:"",onChange:e=>{var s;return s=e.target.value,void(r(e=>({...e,[i]:s})),n(e=>({...e,[i]:!0})),p(null))}})},i)})]}),(0,U.jsx)(m5,{label:"Main model",hint:"Powers the chat session.",children:(0,U.jsx)(gl,{name:"main-provider",value:i,onChange:e=>{a(e),p(null)}})}),(0,U.jsx)(m5,{label:"Fast model",hint:"Powers translate and agent session titles. Can use a different provider than the main model.",children:(0,U.jsx)(gl,{name:"fast-provider",value:o,onChange:e=>{l(e),p(null)}})}),f&&(0,U.jsx)(m4,{variant:"Settings saved"===f?"success":"error",icon:"Settings saved"===f?(0,U.jsx)(os,{className:"h-3.5 w-3.5"}):(0,U.jsx)(oi,{className:"h-3.5 w-3.5"}),children:f}),(0,U.jsx)(m7,{children:(0,U.jsxs)(a$.Button,{size:"sm",onClick:m,disabled:u,children:[u&&(0,U.jsx)(aP,{className:"h-3.5 w-3.5 mr-1.5 animate-spin"}),"Save"]})})]})}let gd=(0,rE.default)("chevrons-up-down",[["path",{d:"m7 15 5 5 5-5",key:"1hf1tw"}],["path",{d:"m7 9 5-5 5 5",key:"sgt6xg"}]]),gu=new Set(["。","!","?","!","?","…","\n"]),gh=/(?<=[,,;;、::])/;var gf=e.i(289506);let gp=/[㐀-鿿豈-﫿]/g,gm=/[A-Za-z㐀-鿿豈-﫿]/g,gg=/[。!?!?.…::;;]$/,gx={"&amp;":"&","&lt;":"<","&gt;":">","&quot;":'"',"&#39;":"'","&apos;":"'","&nbsp;":" "};function gv(e){return e.replace(/&(?:amp|lt|gt|quot|#39|apos|nbsp);/g,e=>gx[e]??e)}function gy(e,r){if(!e)return"";let s="";for(let n of e)switch(n.type){case"text":s+="tokens"in n&&n.tokens?gy(n.tokens,r):gv(n.text);break;case"escape":s+=n.text;break;case"codespan":s+=gv(n.text);break;case"strong":case"em":case"del":s+=gy(n.tokens,r);break;case"link":s+=n.text===n.href||/^(https?:|mailto:|www\.)/i.test(n.text)?"zh"===r?"链接":"link":gy(n.tokens,r);break;case"br":s+=" "}return s}function gb(e,r){let s=e.replace(/\s+/g," ").trim();return s?gg.test(s)?s:s+("zh"===r?"。":"."):""}let gw={ts:"TypeScript",tsx:"TypeScript",typescript:"TypeScript",js:"JavaScript",jsx:"JavaScript",javascript:"JavaScript",py:"Python",python:"Python",sh:"shell",bash:"shell",zsh:"shell",shell:"shell",console:"shell",json:"JSON",yaml:"YAML",yml:"YAML",sql:"SQL",html:"HTML",css:"CSS",md:"Markdown",markdown:"Markdown",go:"Go",rs:"Rust",rust:"Rust",diff:"diff"};function g_(e,r){let s,n;if(!e.trim())return"";let i=gf.marked.lexer(e,{gfm:!0}),a=e.replace(/```[\s\S]*?(```|$)/g," "),o=[];return!function e(r,s,n){let{lang:i}=s;for(let a of r)switch(a.type){case"heading":case"paragraph":n.push(gb(gy(a.tokens,i),i));break;case"text":n.push(gb("tokens"in a&&a.tokens?gy(a.tokens,i):gv(a.text),i));break;case"code":s.announceCode&&n.push(function(e,r){var s;let n=e.text.replace(/\n+$/,"").split("\n").length,i=(e.lang??"").trim().split(/\s+/)[0],a=i?gw[(s=i).toLowerCase()]??s:"";if("zh"===r)return a?`一段 ${n} 行的 ${a} 代码。`:`一段 ${n} 行的代码。`;let o=1===n?"line":"lines";return a?`${a} code block, ${n} ${o}.`:`Code block, ${n} ${o}.`}(a,i));break;case"blockquote":e(a.tokens??[],s,n);break;case"list":for(let r of a.items)e(r.tokens,s,n);break;case"table":{let e="zh"===i?",":", ";for(let r of[a.header,...a.rows])n.push(gb(r.map(e=>gy(e.tokens,i).trim()).filter(Boolean).join(e),i))}}}(i,{lang:(s=a.match(gm)?.length??0,n=a.match(gp)?.length??0,s>0&&n/s>=.2?"zh":"en"),announceCode:r},o),o.filter(Boolean).join("\n")}function gS(e){return g_(e,!1).length>0}function gk(){return new DOMException("Aborted","AbortError")}function gj(e,r,s){return new Promise((n,i)=>{if(s.aborted)return i(gk());let a=()=>{e.removeEventListener(r,o),i(gk())},o=()=>{s.removeEventListener("abort",a),n()};e.addEventListener(r,o,{once:!0}),s.addEventListener("abort",a,{once:!0})})}async function gC(e,r){for(;e.updating;)await gj(e,"updateend",r)}async function gN(e,r,s,n){for(;;){await gC(e,n);try{e.appendBuffer(r),await gC(e,n);return}catch(i){if(i?.name!=="QuotaExceededError")throw i;let r=s.currentTime-5;r>0&&e.buffered.length>0&&e.buffered.start(0)<r&&(e.remove(e.buffered.start(0),r),await gC(e,n)),await function(e,r){return new Promise((e,s)=>{let n=setTimeout(e,500);r.addEventListener("abort",()=>{clearTimeout(n),s(gk())},{once:!0})})}(0,n)}}}async function gE(e){let{audio:r,signal:s}=e,n=new e.source.ctor,i=URL.createObjectURL(n),a=[],o=(e,r,s)=>{e.addEventListener(r,s),a.push(()=>e.removeEventListener(r,s))};try{let a;e.source.managed&&(r.disableRemotePlayback=!0);let l=gj(n,"sourceopen",s);r.defaultPlaybackRate=e.rate,r.src=i,r.playbackRate=e.rate,r.preservesPitch=!0,await l;let c=n.addSourceBuffer(e.mime);"sequence"!==c.mode&&(c.mode="sequence");let d=[],u=()=>{let e=d.findIndex(e=>r.currentTime<e);return -1===e?d.length:e},h=!1;o(r,"waiting",()=>{h=!1,e.onProgress("loading",u())}),o(r,"playing",()=>{h=!0,e.onProgress("playing",u())}),o(r,"timeupdate",()=>{h&&e.onProgress("playing",u())});let f=null,p=new Promise((e,r)=>a=r);p.catch(()=>{});let m=e=>{f||(f=e,a(e))},g=e=>Promise.race([e,p]),x=new Promise((e,n)=>{o(r,"ended",()=>e()),o(r,"error",()=>n(Error("Audio playback failed"))),s.addEventListener("abort",()=>n(gk()),{once:!0})});x.catch(m),Promise.resolve(r.play()).catch(m);for(let n=0;n<e.total;n++){let i=(await g(e.openChunk(n))).getReader(),a=[],o=!1;try{for(;;){let{done:e,value:n}=await g(i.read());if(f)throw f;if(e)break;n?.byteLength&&(a.push(n),await g(gN(c,n,r,s)))}o=!0}finally{o?i.releaseLock():i.cancel().catch(()=>{})}d.push(c.buffered.length>0?c.buffered.end(c.buffered.length-1):0),e.onChunkComplete?.(n,a)}await g(gC(c,s)),"open"===n.readyState&&n.endOfStream(),await x}finally{for(let e of a)e();URL.revokeObjectURL(i)}}let gD={status:"idle"},gT=null;class gR{state=gD;listeners=new Set;audio=null;run=null;settings=null;cache=null;errorTimer=null;subscribe=e=>(this.listeners.add(e),()=>this.listeners.delete(e));getSnapshot=()=>this.state;invalidateSettings(){this.settings=null,this.cache=null}play(e,r,s={}){if(this.stop(),!gS(r))return;let n=g_(r,!0),i=this.unlockAudio(),a={controller:new AbortController};this.run=a,this.set({status:"loading",ownerKey:e,chunk:0,total:0}),this.execute(a,i,e,n,s).then(()=>{this.run===a&&(this.run=null,this.set(gD))},r=>{this.run===a&&(a.controller.abort(),this.run=null,this.resetAudio(),this.fail(e,r))})}toggle(e,r,s){this.isActive(e)?this.stop():this.play(e,r,s)}isActive(e){let r=this.state;return("loading"===r.status||"playing"===r.status)&&r.ownerKey===e}stop(){this.run&&(this.run.controller.abort(),this.run=null),this.resetAudio(),"idle"!==this.state.status&&this.set(gD)}stopOwnersWithPrefix(e){let r=this.state;"idle"!==r.status&&r.ownerKey.startsWith(e)&&this.stop()}async execute(e,r,s,n,i){let{signal:a}=e.controller,o=await this.loadSettings();if(!o.configured)throw new aC.TtsRequestError("Text-to-speech is not configured",409,"tts_not_configured");let l=function(e,r,s=200){let n=[],i="",a=()=>0===n.length?Math.min(s,r):r,o=e=>{let r,s=i+((r=i)?/[㐀-鿿。!?,]$/.test(r)||/^[㐀-鿿]/.test(e)?"":" ":"")+e;if(s.length<=a()){i=s;return}if(i&&(n.push(i),i=""),e.length<=a()){i=e;return}let o=function(e,r){let s=[],n="";for(let i of e.split(gh)){if((n+i).length<=r){n+=i;continue}for(n&&s.push(n),n=i;n.length>r;)s.push(n.slice(0,r)),n=n.slice(r)}return n&&s.push(n),s.map(e=>e.trim()).filter(Boolean)}(e,a());for(let e of o.slice(0,-1))n.push(e);(i=o[o.length-1]??"").length>a()&&(n.push(i),i="")};for(let r of function(e){let r=[],s=0;for(let n=0;n<e.length;n++){let i=e[n];if(gu.has(i)||"."===i&&(n+1===e.length||/\s/.test(e[n+1]))){for(;n+1<e.length&&(gu.has(e[n+1])||/[”"'」』))]/.test(e[n+1]));)n++;r.push(e.slice(s,n+1)),s=n+1}}return s<e.length&&r.push(e.slice(s)),r.map(e=>e.trim()).filter(Boolean)}(e))o(r);return i&&n.push(i),n}(n,o.providers.find(e=>e.id===o.provider)?.maxCharsPerRequest??1500),c=i.rate??o.rate??1,d=JSON.stringify([n,i.voice??null]);this.cache?.key!==d&&(this.cache={key:d,chunks:[]});let u=this.cache.chunks,h=l.length,f=async e=>{var r;let s=u[e];return s?{type:s.type,stream:()=>new ReadableStream({start(e){for(let r of s.parts)e.enqueue(r);e.close()}}),blob:async()=>new Blob(s.parts,{type:s.type})}:{type:((r=await this.open(l[e],i.voice,a)).headers.get("Content-Type")??"").split(";")[0].trim(),stream:()=>r.body,blob:()=>r.blob()}},p=await f(0);if(a.aborted)return;let m=p.type,g=function(e){if(!e)return null;let r=window;return r.MediaSource?.isTypeSupported?.(e)?{ctor:r.MediaSource,managed:!1}:r.ManagedMediaSource?.isTypeSupported?.(e)?{ctor:r.ManagedMediaSource,managed:!0}:null}(m);if(g)return void await gE({audio:r,source:g,mime:m,rate:c,total:h,signal:a,openChunk:async e=>{let r=(0===e?p:await f(e)).stream();if(!r)throw Error("Empty audio response");return r},onChunkComplete:(e,r)=>{u[e]={type:m,parts:r}},onProgress:(e,r)=>this.set({status:e,ownerKey:s,chunk:Math.min(r,h-1),total:h})});let x=async e=>{let r=await (0===e?p:await f(e)).blob();return u[e]={type:m,parts:[new Uint8Array(await r.arrayBuffer())]},r},v=e=>{let r={promise:x(e),ready:!1};return r.promise.then(()=>r.ready=!0,()=>{}),r},y=v(0);for(let e=0;e<h;e++){y.ready||this.set({status:"loading",ownerKey:s,chunk:e,total:h});let n=await y.promise;if(a.aborted)return;e+1<h&&(y=v(e+1)),this.set({status:"playing",ownerKey:s,chunk:e,total:h}),await this.playBlob(r,n,c,a)}}async open(e,r,s){try{return await aC.api.openSpeechStream(e,{voice:r,signal:s})}catch(n){if(n instanceof aC.TtsRequestError&&"tts_busy"===n.code)return await new Promise((e,r)=>{let n=setTimeout(e,300);s.addEventListener("abort",()=>{clearTimeout(n),r(new DOMException("Aborted","AbortError"))})}),aC.api.openSpeechStream(e,{voice:r,signal:s});throw n}}playBlob(e,r,s,n){let i=URL.createObjectURL(r);return new Promise((r,a)=>{let o=()=>{e.removeEventListener("ended",l),e.removeEventListener("error",c),n.removeEventListener("abort",d),URL.revokeObjectURL(i)},l=()=>{o(),r()},c=()=>{o(),a(Error("Audio playback failed"))},d=()=>{o(),a(new DOMException("Aborted","AbortError"))};if(n.aborted)return d();e.addEventListener("ended",l),e.addEventListener("error",c),n.addEventListener("abort",d),e.defaultPlaybackRate=s,e.src=i,e.playbackRate=s,e.preservesPitch=!0,Promise.resolve(e.play()).catch(e=>{o(),a(e)})})}loadSettings(){if(!this.settings){let e=aC.api.getTtsSettings();this.settings=e,e.catch(()=>{this.settings===e&&(this.settings=null)})}return this.settings}unlockAudio(){this.audio||(this.audio=new Audio);let e=this.audio;return e.src=function(){if(gT)return gT;let e=new Uint8Array(444),r=new DataView(e.buffer),s=(r,s)=>{for(let n=0;n<s.length;n++)e[r+n]=s.charCodeAt(n)};s(0,"RIFF"),r.setUint32(4,436,!0),s(8,"WAVE"),s(12,"fmt "),r.setUint32(16,16,!0),r.setUint16(20,1,!0),r.setUint16(22,1,!0),r.setUint32(24,8e3,!0),r.setUint32(28,8e3,!0),r.setUint16(32,1,!0),r.setUint16(34,8,!0),s(36,"data"),r.setUint32(40,400,!0),e.fill(128,44);let n="";for(let r of e)n+=String.fromCharCode(r);return gT=`data:audio/wav;base64,${btoa(n)}`}(),Promise.resolve(e.play()).catch(()=>{}),e}resetAudio(){this.audio&&(this.audio.pause(),this.audio.removeAttribute("src"))}fail(e,r){if(r?.name==="AbortError")return void this.set(gD);let s=r instanceof aC.TtsRequestError&&"tts_not_configured"===r.code,n=r?.name==="NotAllowedError"?"The browser blocked audio playback":r instanceof Error?r.message:"Speech playback failed";s||console.warn("[tts] playback failed:",r);let i={status:"error",ownerKey:e,code:s?"not_configured":"failed",message:n};this.set(i),this.errorTimer&&clearTimeout(this.errorTimer),this.errorTimer=setTimeout(()=>{this.state===i&&this.set(gD)},3e3)}set(e){let r=this.state;if(r.status!==e.status||"loading"!==r.status&&"playing"!==r.status||"loading"!==e.status&&"playing"!==e.status||r.ownerKey!==e.ownerKey||r.chunk!==e.chunk||r.total!==e.total)for(let r of(this.state=e,this.listeners))r()}}let gA=new gR;function gM(){return(0,V.useSyncExternalStore)(gA.subscribe,gA.getSnapshot,gA.getSnapshot)}let gI="settings:tts-preview";function gP(){let[e,r]=(0,V.useState)(null),[s,n]=(0,V.useState)(null),[i,a]=(0,V.useState)(""),[o,l]=(0,V.useState)({}),[c,d]=(0,V.useState)({}),[u,h]=(0,V.useState)(""),[f,p]=(0,V.useState)(1),[m,g]=(0,V.useState)(null),[x,v]=(0,V.useState)(null),[y,b]=(0,V.useState)(!1),[w,_]=(0,V.useState)(!1),[S,k]=(0,V.useState)(null),j=e=>{r(e),a(e.provider),l(e.credentials),d({}),h(e.voice),p(e.rate)};(0,V.useEffect)(()=>{aC.api.getTtsSettings().then(j).catch(e=>n(e instanceof Error?e.message:"Failed to load speech settings"))},[]);let C=e?.providers.find(e=>e.id===i),N=C?.configured??!1;(0,V.useEffect)(()=>{if(!i||!N)return void g(null);let e=!1;return v(null),b(!0),aC.api.listTtsVoices(i).then(r=>!e&&g(r)).finally(()=>!e&&b(!1)).catch(r=>{e||(g(null),v(r instanceof aC.TtsRequestError&&"tts_auth_failed"===r.code?"The provider rejected these credentials.":r instanceof Error?r.message:"Failed to load voices"))}),()=>{e=!0}},[i,N,e]);let E=async()=>{if(e){_(!0),k(null);try{let e={};for(let[r,s]of Object.entries(c))for(let[n,i]of Object.entries(s))i&&((e[r]??={})[n]=o[r]?.[n]??"");let r=await aC.api.updateTtsSettings({provider:i,voice:u,rate:f,...Object.keys(e).length>0?{credentials:e}:{}});j(r),gA.invalidateSettings(),k({kind:"success",text:"Settings saved"}),setTimeout(()=>k(e=>e?.kind==="success"?null:e),2e3)}catch(e){k({kind:"error",text:e instanceof Error?e.message:"Failed to save"})}finally{_(!1)}}},D=gM(),T=("loading"===D.status||"playing"===D.status)&&D.ownerKey===gI;(0,V.useEffect)(()=>()=>gA.stopOwnersWithPrefix(gI),[]);let R="error"===D.status&&D.ownerKey===gI?D.message:null;if(s)return(0,U.jsx)(m4,{variant:"error",icon:(0,U.jsx)(oi,{className:"h-3.5 w-3.5"}),children:s});if(!e||!C)return(0,U.jsx)("div",{className:"flex items-center justify-center py-6",children:(0,U.jsx)(aP,{className:"h-4 w-4 animate-spin text-muted-foreground"})});let A=Object.values(c[i]??{}).some(Boolean);return(0,U.jsxs)("div",{className:"space-y-6",children:[e.providers.length>1&&(0,U.jsx)(m5,{label:"Provider",children:(0,U.jsxs)(fP,{value:i,onValueChange:r=>{a(r);let s=e?.providers.find(e=>e.id===r);h(r===e?.provider?e.voice:s?.defaultVoice??""),k(null)},children:[(0,U.jsx)(fL,{className:"w-full text-[12.5px]",children:(0,U.jsx)(fF,{})}),(0,U.jsx)(fO,{children:e.providers.map(e=>(0,U.jsx)(fB,{value:e.id,className:"text-[12.5px]",children:e.label},e.id))})]})}),(0,U.jsxs)("div",{className:"space-y-4",children:[(0,U.jsx)("p",{className:"text-[12px] font-medium text-foreground/70",children:C.label}),C.credentialFields.map(e=>{let r=o[i]?.[e.key]??"",s=c[i]?.[e.key]??!1;return(0,U.jsx)(m5,{label:e.label,mono:!0,hint:e.fromEnv?"Leave empty to use the server's default.":void 0,children:(0,U.jsx)(aX,{type:e.secret?"password":"text",className:"font-mono text-[12px]",placeholder:e.secret&&r&&!s?r:e.placeholder,value:e.secret&&!s?"":r,onChange:r=>{var s,n;return s=e.key,n=r.target.value,void(l(e=>({...e,[i]:{...e[i],[s]:n}})),d(e=>({...e,[i]:{...e[i],[s]:!0}})),k(null))},autoComplete:"off"})},e.key)})]}),(0,U.jsx)(m5,{label:"Voice",hint:x??(N?"Every listed voice speaks multiple languages and switches on its own. HD Omni sounds best; Multilingual costs less and works in every region. Not listed? Type the full voice ID in the search box.":"Save your credentials to load the voice list."),children:(0,U.jsx)(gF,{value:u,voices:m,loading:y,disabled:!N,onChange:e=>{h(e),k(null)}})}),(0,U.jsxs)("div",{children:[(0,U.jsxs)("div",{className:"flex items-baseline justify-between mb-1.5",children:[(0,U.jsx)("span",{className:"text-[12px] font-medium text-foreground/90",children:"Speed"}),(0,U.jsxs)("span",{className:"font-mono text-[11.5px] text-foreground/80 tabular-nums",children:[f.toFixed(2),"×"]})]}),(0,U.jsx)(m1,{min:e.rateRange.min,max:e.rateRange.max,step:.05,value:[f],onValueChange:e=>{p(Math.round(100*e[0])/100),k(null)}}),(0,U.jsxs)("div",{className:"flex justify-between mt-1 text-[10.5px] text-muted-foreground/80 font-mono",children:[(0,U.jsxs)("span",{children:[e.rateRange.min,"×"]}),(0,U.jsxs)("span",{children:[e.rateRange.max,"×"]})]}),(0,U.jsx)("p",{className:"mt-1.5 text-[11px] text-muted-foreground/85 leading-relaxed",children:"Applied during playback, so it works with every voice and takes effect without re-synthesizing."})]}),(0,U.jsxs)("p",{className:"text-[11px] text-muted-foreground/85 leading-relaxed",children:["When you read a message aloud, its text is sent to ",C.label," for synthesis."]}),(S||R)&&(0,U.jsx)(m4,{variant:S?.kind==="success"?"success":"error",icon:S?.kind==="success"?(0,U.jsx)(os,{className:"h-3.5 w-3.5"}):(0,U.jsx)(oi,{className:"h-3.5 w-3.5"}),children:S?.text??R}),(0,U.jsxs)(m7,{children:[(0,U.jsxs)(a$.Button,{size:"sm",variant:"outline",disabled:!N||A,title:A?"Save the credentials first":void 0,onClick:()=>gA.toggle(gI,"你好,这是语音朗读的试听。Hello, this is a preview of the selected voice.",{voice:u,rate:f}),children:[T?(0,U.jsx)(ce,{className:"h-3.5 w-3.5 mr-1.5"}):(0,U.jsx)(mb,{className:"h-3.5 w-3.5 mr-1.5"}),T?"Stop":"Preview"]}),(0,U.jsxs)(a$.Button,{size:"sm",onClick:E,disabled:w,children:[w&&(0,U.jsx)(aP,{className:"h-3.5 w-3.5 mr-1.5 animate-spin"}),"Save"]})]})]})}function gF({value:e,voices:r,loading:s,disabled:n,onChange:i}){let[a,o]=(0,V.useState)(!1),[l,c]=(0,V.useState)(""),d=(0,V.useMemo)(()=>r?.find(r=>r.id===e),[r,e]),u=(0,V.useMemo)(()=>{let s=r??[],n=s.some(r=>r.id===e)||!e?s:[{id:e,label:e,group:"Current"},...s],i=new Map;for(let e of n){let r=e.group??(e.multilingual?"Multilingual":"All voices");i.set(r,[...i.get(r)??[],e])}return[...i].map(([e,r])=>({heading:e,items:r}))},[r,e]),h=l.trim(),f=h.length>0&&!(r??[]).some(e=>e.id===h)&&h!==e,p=e=>{i(e),o(!1),c("")};return(0,U.jsxs)(pa,{open:a,onOpenChange:o,children:[(0,U.jsx)(po,{asChild:!0,children:(0,U.jsxs)(a$.Button,{variant:"outline",role:"combobox","aria-expanded":a,disabled:n,className:"w-full justify-between font-mono text-[12px] font-normal",children:[(0,U.jsx)("span",{className:"truncate",children:d?.label??e}),s?(0,U.jsx)(aP,{className:"h-3.5 w-3.5 animate-spin opacity-60"}):(0,U.jsx)(gd,{className:"h-3.5 w-3.5 opacity-60"})]})}),(0,U.jsx)(pl,{className:"p-0 w-[var(--radix-popover-trigger-width)]",align:"start",children:(0,U.jsxs)(p$,{children:[(0,U.jsx)(pH,{placeholder:"Search voices, or type a voice ID…",className:"text-[12.5px]",value:l,onValueChange:c}),(0,U.jsxs)(pU,{className:"max-h-72",children:[(0,U.jsx)(pV,{children:"No voice found."}),f&&(0,U.jsx)(pq,{heading:"Voice ID",children:(0,U.jsx)(pK,{value:`__typed__ ${h}`,onSelect:()=>p(h),className:"text-[12.5px]",children:(0,U.jsxs)("span",{className:"truncate",children:["Use ",(0,U.jsx)("span",{className:"font-mono",children:h})]})})}),u.map(r=>(0,U.jsx)(pq,{heading:r.heading,children:r.items.map(r=>(0,U.jsxs)(pK,{value:`${r.label} ${r.id}`,onSelect:()=>p(r.id),className:"text-[12.5px]",children:[(0,U.jsx)(al.Check,{className:(0,e1.cn)("h-3.5 w-3.5",r.id===e?"opacity-100":"opacity-0")}),(0,U.jsx)("span",{className:"truncate",children:r.label}),(0,U.jsx)("span",{className:"ml-auto font-mono text-[10.5px] text-muted-foreground truncate",children:r.id})]},r.id))},r.heading))]})]})})]})}let gL=[{value:"none",label:"Direct",description:"No proxy — connect directly to the internet",Icon:(0,rE.default)("shield-off",[["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M5 5a1 1 0 0 0-1 1v7c0 5 3.5 7.5 7.67 8.94a1 1 0 0 0 .67.01c2.35-.82 4.48-1.97 5.9-3.71",key:"1jlk70"}],["path",{d:"M9.309 3.652A12.252 12.252 0 0 0 11.24 2.28a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1v7a9.784 9.784 0 0 1-.08 1.264",key:"18rp1v"}]])},{value:"http",label:"HTTP / HTTPS",description:"Route through an HTTP CONNECT proxy",Icon:mg},{value:"socks5",label:"SOCKS5",description:"Route through a SOCKS5 proxy server",Icon:gi}];function gO(){let[e,r]=(0,V.useState)("none"),[s,n]=(0,V.useState)(""),[i,a]=(0,V.useState)(""),[o,l]=(0,V.useState)(!0),[c,d]=(0,V.useState)(!1),[u,h]=(0,V.useState)(!1),[f,p]=(0,V.useState)(null),[m,g]=(0,V.useState)(null);(0,V.useEffect)(()=>{l(!0),p(null),g(null),aC.api.getProxySettings().then(e=>{r(e.type),n(e.host),a(e.port?String(e.port):"")}).finally(()=>l(!1))},[]);let x=()=>({type:e,host:"none"===e?"":s.trim(),port:"none"===e?0:parseInt(i,10)||0}),v=async()=>{h(!0),p(null);try{p(await aC.api.testProxyConnection(x()))}catch(e){p({success:!1,message:e instanceof Error?e.message:"Test failed"})}finally{h(!1)}},y=async()=>{d(!0),g(null);try{await aC.api.updateProxySettings(x()),g("Settings saved"),setTimeout(()=>g(null),2e3)}catch(e){g(e instanceof Error?e.message:"Failed to save")}finally{d(!1)}},b="none"!==e;return o?(0,U.jsx)("div",{className:"flex items-center justify-center py-6",children:(0,U.jsx)(aP,{className:"h-4 w-4 animate-spin text-muted-foreground"})}):(0,U.jsxs)("div",{className:"space-y-4",children:[(0,U.jsx)(m5,{label:"Connection mode",children:(0,U.jsx)(m3,{name:"proxyType",value:e,options:gL,onChange:e=>{r(e),p(null),g(null)}})}),b&&(0,U.jsxs)("div",{className:"grid grid-cols-[1fr_120px] gap-3",children:[(0,U.jsx)(m5,{label:"Host",mono:!0,children:(0,U.jsx)(aX,{placeholder:"127.0.0.1",value:s,className:"font-mono text-[12.5px]",onChange:e=>{n(e.target.value),p(null),g(null)}})}),(0,U.jsx)(m5,{label:"Port",mono:!0,children:(0,U.jsx)(aX,{type:"number",placeholder:"1080",value:i,className:"font-mono text-[12.5px]",onChange:e=>{a(e.target.value),p(null),g(null)},min:1,max:65535})})]}),f&&(0,U.jsx)(m4,{variant:f.success?"success":"error",icon:f.success?(0,U.jsx)(os,{className:"h-3.5 w-3.5"}):(0,U.jsx)(oi,{className:"h-3.5 w-3.5"}),children:f.message??(f.success?"Connection succeeded":"Connection failed")}),m&&!f&&(0,U.jsx)(m4,{variant:"Settings saved"===m?"success":"error",icon:"Settings saved"===m?(0,U.jsx)(os,{className:"h-3.5 w-3.5"}):(0,U.jsx)(oi,{className:"h-3.5 w-3.5"}),children:m}),(0,U.jsxs)(m7,{children:[b&&(0,U.jsxs)(a$.Button,{variant:"outline",size:"sm",onClick:v,disabled:u||!s.trim()||!i,children:[u&&(0,U.jsx)(aP,{className:"h-3.5 w-3.5 mr-1.5 animate-spin"}),"Test connection"]}),(0,U.jsxs)(a$.Button,{size:"sm",onClick:y,disabled:c,children:[c&&(0,U.jsx)(aP,{className:"h-3.5 w-3.5 mr-1.5 animate-spin"}),"Save"]})]})]})}var gB=e.i(276949);let{scrollbackMin:gz,scrollbackMax:g$,fontSizeMin:gW,fontSizeMax:gH}=aC.TERMINAL_SETTINGS_LIMITS;function gU(){let{settings:e,loaded:r,refresh:s}=(0,gB.useTerminalSettings)(),[n,i]=(0,V.useState)(String(aC.DEFAULT_TERMINAL_SETTINGS.scrollback)),[a,o]=(0,V.useState)(String(aC.DEFAULT_TERMINAL_SETTINGS.fontSize)),[l,c]=(0,V.useState)(aC.DEFAULT_TERMINAL_SETTINGS.fontFamily),[d,u]=(0,V.useState)(!1),[h,f]=(0,V.useState)(null);(0,V.useEffect)(()=>{r&&(i(String(e.scrollback)),o(String(e.fontSize)),c(e.fontFamily))},[r,e.scrollback,e.fontSize,e.fontFamily]);let p=parseInt(n,10),m=parseInt(a,10),g=Number.isFinite(p)&&p>=gz&&p<=g$,x=Number.isFinite(m)&&m>=gW&&m<=gH,v=""!==l.trim(),y=g&&x&&v,b=async()=>{if(y){u(!0),f(null);try{let e={scrollback:p,fontSize:m,fontFamily:l.trim()};await aC.api.updateTerminalSettings(e),await s(),f("Settings saved"),setTimeout(()=>f(null),2e3)}catch(e){f(e instanceof Error?e.message:"Failed to save")}finally{u(!1)}}};return r?(0,U.jsxs)("div",{className:"space-y-4",children:[(0,U.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,U.jsx)(m5,{label:"Scrollback",mono:!0,hint:(0,U.jsxs)("span",{children:["Lines kept in buffer."," ",(0,U.jsxs)("span",{className:"font-mono text-foreground/70",children:[gz,"–",g$]})," · default ",(0,U.jsx)("span",{className:"font-mono text-foreground/70",children:aC.DEFAULT_TERMINAL_SETTINGS.scrollback})]}),children:(0,U.jsx)(aX,{type:"number",min:gz,max:g$,value:n,className:"font-mono text-[12.5px]",onChange:e=>{i(e.target.value),f(null)}})}),(0,U.jsx)(m5,{label:"Font size",mono:!0,hint:(0,U.jsxs)("span",{children:["Pixels."," ",(0,U.jsxs)("span",{className:"font-mono text-foreground/70",children:[gW,"–",gH]})," · default ",(0,U.jsx)("span",{className:"font-mono text-foreground/70",children:aC.DEFAULT_TERMINAL_SETTINGS.fontSize})]}),children:(0,U.jsx)(aX,{type:"number",min:gW,max:gH,value:a,className:"font-mono text-[12.5px]",onChange:e=>{o(e.target.value),f(null)}})})]}),(0,U.jsx)(m5,{label:"Font family",mono:!0,hint:"CSS font-family list. Use monospace fonts for column alignment.",children:(0,U.jsx)(aX,{value:l,className:"font-mono text-[12px]",onChange:e=>{c(e.target.value),f(null)},placeholder:aC.DEFAULT_TERMINAL_SETTINGS.fontFamily})}),h&&(0,U.jsx)(m4,{variant:"Settings saved"===h?"success":"error",icon:"Settings saved"===h?(0,U.jsx)(os,{className:"h-3.5 w-3.5"}):(0,U.jsx)(oi,{className:"h-3.5 w-3.5"}),children:h}),(0,U.jsxs)(m7,{children:[(0,U.jsx)(a$.Button,{variant:"outline",size:"sm",onClick:()=>{i(String(aC.DEFAULT_TERMINAL_SETTINGS.scrollback)),o(String(aC.DEFAULT_TERMINAL_SETTINGS.fontSize)),c(aC.DEFAULT_TERMINAL_SETTINGS.fontFamily),f(null)},disabled:d,children:"Reset"}),(0,U.jsxs)(a$.Button,{size:"sm",onClick:b,disabled:d||!y,children:[d&&(0,U.jsx)(aP,{className:"h-3.5 w-3.5 mr-1.5 animate-spin"}),"Save"]})]})]}):(0,U.jsx)("div",{className:"flex items-center justify-center py-6",children:(0,U.jsx)(aP,{className:"h-4 w-4 animate-spin text-muted-foreground"})})}let{min:gV,max:gq}=aC.AGENT_PROCESS_SETTINGS_LIMITS;function gK(){let e,r,[s,n]=(0,V.useState)(String(aC.DEFAULT_AGENT_PROCESS_SETTINGS.maxResidentAgentProcesses)),[i,a]=(0,V.useState)(!1),[o,l]=(0,V.useState)(!1),[c,d]=(0,V.useState)(null),[u,h]=(0,V.useState)([]);(0,V.useEffect)(()=>{let e=!1;return(0,aC.getAgentProcessSettings)().then(r=>{e||(n(String(r.maxResidentAgentProcesses)),a(!0))}).catch(r=>{e||(d(r instanceof Error?r.message:"Failed to load settings"),a(!0))}),()=>{e=!0}},[]);let f=parseInt(s,10),p=Number.isInteger(f)&&f>=gV&&f<=gq,m=async()=>{if(p){l(!0),d(null),h([]);try{let e=await (0,aC.updateAgentProcessSettings)({maxResidentAgentProcesses:f});n(String(e.maxResidentAgentProcesses)),h(e.workers??[]),d("Settings saved"),setTimeout(()=>d(null),2e3)}catch(e){d(e instanceof Error?e.message:"Failed to save")}finally{l(!1)}}},g=u.filter(e=>"applied"!==e.status);return i?(0,U.jsxs)("div",{className:"space-y-4",children:[(0,U.jsx)(m5,{label:"Resident agent processes",mono:!0,hint:(0,U.jsxs)("span",{children:["Live agent processes per workspace, applied to all of your machines."," ",(0,U.jsxs)("span",{className:"font-mono text-foreground/70",children:[gV,"–",gq]})," · default ",(0,U.jsx)("span",{className:"font-mono text-foreground/70",children:aC.DEFAULT_AGENT_PROCESS_SETTINGS.maxResidentAgentProcesses})]}),children:(0,U.jsxs)("div",{className:"flex items-center gap-2 max-w-[220px]",children:[(0,U.jsx)(aA,{className:"h-4 w-4 text-muted-foreground"}),(0,U.jsx)(aX,{type:"number",min:gV,max:gq,value:s,className:"font-mono text-[12.5px]",onChange:e=>{n(e.target.value),d(null)}})]})}),c&&(0,U.jsx)(m4,{variant:"Settings saved"===c?"success":"error",icon:"Settings saved"===c?(0,U.jsx)(os,{className:"h-3.5 w-3.5"}):(0,U.jsx)(oi,{className:"h-3.5 w-3.5"}),children:c}),(0,U.jsx)(m6,{issues:g.map(e=>({id:e.remoteServerId,name:e.name,message:"offline"===e.status?"offline — it will pick this up when it reconnects":`not applied (${e.detail??"failed"}) — save again later to retry`})),summary:(e=g.filter(e=>"offline"===e.status).length,0==(r=g.length-e)?`${e} machines offline — they will pick this up when they reconnect`:0===e?`${r} machines did not apply this — save again later to retry`:`${g.length} machines did not apply this yet (${e} offline, ${r} failed)`)}),(0,U.jsxs)(m7,{children:[(0,U.jsx)(a$.Button,{variant:"outline",size:"sm",onClick:()=>{n(String(aC.DEFAULT_AGENT_PROCESS_SETTINGS.maxResidentAgentProcesses)),d(null)},disabled:o,children:"Reset"}),(0,U.jsxs)(a$.Button,{size:"sm",onClick:m,disabled:o||!p,children:[o&&(0,U.jsx)(aP,{className:"h-3.5 w-3.5 mr-1.5 animate-spin"}),"Save"]})]})]}):(0,U.jsx)("div",{className:"flex items-center justify-center py-6",children:(0,U.jsx)(aP,{className:"h-4 w-4 animate-spin text-muted-foreground"})})}let gX=(0,rE.default)("infinity",[["path",{d:"M6 16c5 0 7-8 12-8a4 4 0 0 1 0 8c-5 0-7-8-12-8a4 4 0 1 0 0 8",key:"18ogeb"}]]);function gY(){let[e,r]=(0,V.useState)(null),[s,n]=(0,V.useState)("off"),[i,a]=(0,V.useState)(""),[o,l]=(0,V.useState)(!1),[c,d]=(0,V.useState)(null),[u,h]=(0,V.useState)([]);if((0,V.useEffect)(()=>{let e=!1;return(0,aC.getSessionRetentionSettings)().then(s=>{e||(r(s),n(null===s.days?"off":"on"),a(String(s.days??s.suggestedDays)))}).catch(s=>{e||(d({text:s instanceof Error?s.message:"Failed to load settings",ok:!1}),r({days:null,suggestedDays:90,minDays:1,maxDays:3650}))}),()=>{e=!0}},[]),!e)return(0,U.jsx)("div",{className:"flex items-center justify-center py-6",children:(0,U.jsx)(aP,{className:"h-4 w-4 animate-spin text-muted-foreground"})});let f=""===i.trim()?NaN:Number(i),p=Number.isInteger(f)&&f>=e.minDays&&f<=e.maxDays,m="off"===s||p,g=async()=>{if(m){l(!0),d(null),h([]);try{let r=await (0,aC.updateSessionRetentionSettings)("off"===s?null:f);a(String(r.days??e.suggestedDays)),h(r.workers),d({text:null===r.days?"Retention is off — sessions are kept indefinitely":`Sessions inactive for over ${r.days} days will be deleted`,ok:!0})}catch(e){d({text:e instanceof Error?e.message:"Failed to save",ok:!1})}finally{l(!1)}}},x=u.filter(e=>"applied"!==e.status);return(0,U.jsxs)("div",{className:"space-y-4",children:[(0,U.jsx)(m3,{name:"session-retention-mode",value:s,columns:2,onChange:r=>{n(r),d(null),"on"!==r||i||a(String(e.suggestedDays))},options:[{value:"off",label:"Keep everything",description:"Sessions are never deleted automatically.",Icon:gX,meta:"default"},{value:"on",label:"Delete old sessions",description:"Inactive, unfavorited sessions are removed.",Icon:aM}]}),"on"===s&&(0,U.jsx)(m5,{label:"Keep for",mono:!0,hint:(0,U.jsxs)("span",{children:["Counted from a session's last activity, not its creation date. Favorited sessions and sessions in an active review are never deleted."," ",(0,U.jsxs)("span",{className:"font-mono text-foreground/70",children:[e.minDays,"–",e.maxDays]})," days · suggested ",(0,U.jsx)("span",{className:"font-mono text-foreground/70",children:e.suggestedDays})]}),children:(0,U.jsxs)("div",{className:"flex items-center gap-2 max-w-[220px]",children:[(0,U.jsx)(aM,{className:"h-4 w-4 text-muted-foreground"}),(0,U.jsx)(aX,{type:"number",min:e.minDays,max:e.maxDays,value:i,className:"font-mono text-[12.5px]",onChange:e=>{a(e.target.value),d(null)}}),(0,U.jsx)("span",{className:"text-[12px] text-muted-foreground",children:"days"})]})}),c&&(0,U.jsx)(m4,{variant:c.ok?"success":"error",icon:c.ok?(0,U.jsx)(os,{className:"h-3.5 w-3.5"}):(0,U.jsx)(oi,{className:"h-3.5 w-3.5"}),children:c.text}),(0,U.jsx)(m6,{issues:x.map(e=>({id:e.remoteServerId,name:e.name,message:"needs_upgrade"===e.status?"update this worker to apply the retention window":"unreachable"===e.status?"offline — it will pick this up when it reconnects":e.detail??"could not apply the retention window"})),summary:function(e){let r=e.filter(e=>"unreachable"===e.status).length,s=e.filter(e=>"needs_upgrade"===e.status).length,n=e.length-r-s;if(r===e.length)return`${r} machines offline — they will pick this up when they reconnect`;if(s===e.length)return`${s} machines need a worker update to apply the retention window`;let i=[r>0&&`${r} offline`,s>0&&`${s} need update`,n>0&&`${n} failed`].filter(Boolean);return`${e.length} machines did not apply this yet (${i.join(", ")})`}(x)}),(0,U.jsx)(m7,{children:(0,U.jsxs)(a$.Button,{size:"sm",onClick:g,disabled:o||!m,children:[o&&(0,U.jsx)(aP,{className:"h-3.5 w-3.5 mr-1.5 animate-spin"}),"Save"]})})]})}let gG=[{id:"appearance",label:"Appearance",Icon:mx},{id:"ai-chat",label:"AI Chat",Icon:mv},{id:"speech",label:"Speech",Icon:mb},{id:"agents",label:"Agents",Icon:aA},{id:"retention",label:"History",Icon:aH},{id:"terminal",label:"Terminal",Icon:my},{id:"proxy",label:"Proxy",Icon:mg},{id:"about",label:"About",Icon:h$}];function gJ(){let{config:e}=(0,ow.useAppConfig)(),[r]=(0,V.useState)(aC.getPersistedConfig),s=(e??r)?.authEnabled!==!1,n=s?gG.filter(e=>"proxy"!==e.id):gG;return(0,U.jsxs)("div",{className:"h-full flex flex-col overflow-hidden",children:[(0,U.jsx)(d8,{title:"Settings",description:"Theme, intelligence, terminal, and network preferences."}),(0,U.jsxs)(m8,{nav:n,children:[(0,U.jsx)(m2,{id:"appearance",label:"Appearance",description:"Visual surface for the workspace. Affects every view.",children:(0,U.jsx)(gr,{})}),(0,U.jsx)(m2,{id:"ai-chat",label:"AI Chat",description:"Provider, credentials, and default model used for the orchestrator chat.",children:(0,U.jsx)(gc,{})}),(0,U.jsx)(m2,{id:"speech",label:"Speech",description:"Text-to-speech provider and voice used to read agent replies aloud.",children:(0,U.jsx)(gP,{})}),(0,U.jsx)(m2,{id:"agents",label:"Agents",description:"Resident coding-agent process limits per workspace branch.",children:(0,U.jsx)(gK,{})}),(0,U.jsx)(m2,{id:"retention",label:"History",description:"How long finished sessions are kept before they are deleted.",children:(0,U.jsx)(gY,{})}),(0,U.jsx)(m2,{id:"terminal",label:"Terminal",description:"Buffer size and typography for the executor terminal.",children:(0,U.jsx)(gU,{})}),!s&&(0,U.jsx)(m2,{id:"proxy",label:"Proxy",description:"Outbound network routing for AI providers and remote servers.",children:(0,U.jsx)(gO,{})}),(0,U.jsx)(m2,{id:"about",label:"About",description:"Build fingerprints of this tab and the server, for update checks and bug reports.",children:(0,U.jsx)(mk,{})})]})]})}let gZ={names:null,loadedAt:0},gQ=null,g0=new Set,g1=0;function g2(e){return g0.add(e),()=>g0.delete(e)}function g5(){return gZ.names}function g3(){return null}function g4(e){let r=new Map(gZ.names);for(let s of e)r.set(s.id,s.name);for(let e of(gZ.names=r,gZ.loadedAt=Date.now(),g0))e()}function g6(){if(gQ)return gQ;let e=aC.api.getRemoteServers().then(e=>{g4(e)}).catch(e=>{console.error("Failed to load remote server names:",e)}).finally(()=>{gQ===e&&(gQ=null)});return gQ=e,e}function g7(e){let r=(0,V.useSyncExternalStore)(g2,g5,g3);(0,V.useEffect)(()=>{(!gZ.names||Date.now()-gZ.loadedAt>6e4)&&g6()},[]),(0,V.useEffect)(()=>{if(!e||!r||r.has(e))return;let s=Date.now();s-g1<6e4||(g1=s,g6())},[e,r]);let s=e&&r?.get(e)||null;return{name:s,label:s??(e?`remote ${e.slice(0,8)}`:null),loading:null===r}}let g8=(0,rE.default)("plug-zap",[["path",{d:"M6.3 20.3a2.4 2.4 0 0 0 3.4 0L12 18l-6-6-2.3 2.3a2.4 2.4 0 0 0 0 3.4Z",key:"goz73y"}],["path",{d:"m2 22 3-3",key:"19mgm9"}],["path",{d:"M7.5 13.5 10 11",key:"7xgeeb"}],["path",{d:"M10.5 16.5 13 14",key:"10btkg"}],["path",{d:"m18 3-4 4h6l-4 4",key:"16psg9"}]]),g9=(0,rE.default)("key-round",[["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"}]]),xe={name:""};function xt(){let[e,r]=(0,V.useState)([]),[s,n]=(0,V.useState)(!0),[i,a]=(0,V.useState)(""),[o,l]=(0,V.useState)(!1),[c,d]=(0,V.useState)(null),[u,h]=(0,V.useState)(xe),[f,p]=(0,V.useState)(""),[m,g]=(0,V.useState)(!1),[x,v]=(0,V.useState)(null),[y,b]=(0,V.useState)(!1),[w,_]=(0,V.useState)(""),[S,k]=(0,V.useState)({}),[j,C]=(0,V.useState)({}),[N,E]=(0,V.useState)(null),[D,T]=(0,V.useState)(null),[R,A]=(0,V.useState)(null),[M,I]=(0,V.useState)(null),[P,F]=(0,V.useState)(!1),[L,O]=(0,V.useState)(null),[B,z]=(0,V.useState)(!1),[$,W]=(0,V.useState)(!1),H=(0,V.useRef)(null),q=(0,V.useCallback)(async()=>{try{let e=await aC.api.getRemoteServers();r(e),g4(e),a("")}catch(e){a(e instanceof Error?e.message:"Failed to load servers")}finally{n(!1)}},[]);(0,V.useEffect)(()=>{q()},[q]),(0,aF.useGlobalEventStream)(e=>{"remote-server:status"===e.type&&q()}),(0,V.useEffect)(()=>{let e=setInterval(q,6e4),r=()=>q();return window.addEventListener("focus",r),()=>{clearInterval(e),window.removeEventListener("focus",r)}},[q]);let K=async()=>{if(!u.name.trim())return void p("Name is required");g(!0),p("");try{c?u.name.trim()!==c.name&&await aC.api.updateRemoteServer(c.id,{name:u.name.trim()}):await aC.api.createRemoteServer({name:u.name.trim()}),l(!1),await q()}catch(e){p(e instanceof Error?e.message:"Failed to save server")}finally{g(!1)}},X=async()=>{if(x){b(!0),_("");try{await aC.api.deleteRemoteServer(x.id),v(null),await q()}catch(e){_(e instanceof Error?e.message:"Failed to delete server")}finally{b(!1)}}},Y=async e=>{k(r=>({...r,[e.id]:"testing"})),C(r=>{let s={...r};return delete s[e.id],s});try{let r=await aC.api.testRemoteServer(e.id);k(s=>({...s,[e.id]:r.success?"success":"error"})),r.success||C(r=>({...r,[e.id]:"Connection failed"}))}catch(r){k(r=>({...r,[e.id]:"error"})),C(s=>({...s,[e.id]:r instanceof Error?r.message:"Test failed"}))}},G=async e=>{H.current=e.id,E(e),T(null),A(null),I(null),O(null),W(!1),z(!1),F(!0);try{let r=await aC.api.getRemoteServerConnectToken(e.id);if(H.current!==e.id)return;T(r.token),A(r.connectCommand),I(r.installCommand??null)}catch(r){if(H.current!==e.id)return;H.current=null,p(r instanceof Error?r.message:"Failed to load token"),E(null)}finally{H.current===e.id&&F(!1)}},J=async e=>{z(!0),O(null);try{let r=await aC.api.rotateRemoteServerConnectToken(e.id);H.current===e.id&&(T(r.token),A(r.connectCommand),I(r.installCommand??null),W(!1)),await q()}catch(e){a(e instanceof Error?e.message:"Failed to rotate token")}finally{H.current===e.id&&z(!1)}},Z=async e=>{try{await aC.api.revokeRemoteServerConnectToken(e.id),await q()}catch(e){a(e instanceof Error?e.message:"Failed to revoke token")}},Q=(e,r)=>{navigator.clipboard.writeText(r),O(e),setTimeout(()=>O(r=>r===e?null:r),2e3)},ee=async(e,s)=>{try{let n=await aC.api.updateRemoteServer(e.id,{crossRemoteAccess:s});r(e=>e.map(e=>e.id===n.id?n:e))}catch(e){a(e instanceof Error?e.message:"Failed to update access")}},et="Update the vibedeckx package on the worker machine, then restart `vibedeckx connect`.";return s?(0,U.jsx)("div",{className:"flex items-center justify-center py-8",children:(0,U.jsx)(aP,{className:"h-5 w-5 animate-spin text-muted-foreground"})}):(0,U.jsxs)("div",{className:"space-y-4",children:[(0,U.jsxs)("div",{className:"flex items-center justify-between",children:[(0,U.jsxs)("div",{children:[(0,U.jsx)("h3",{className:"text-sm font-medium",children:"Remote Servers"}),(0,U.jsx)("p",{className:"text-xs text-muted-foreground",children:"Manage globally available remote servers"})]}),(0,U.jsxs)(a$.Button,{variant:"outline",size:"sm",onClick:()=>{d(null),h(xe),p(""),l(!0)},children:[(0,U.jsx)(oS,{className:"h-4 w-4 mr-1.5"}),"Add Server"]})]}),i&&(0,U.jsx)("p",{className:"text-sm text-red-500",children:i}),0===e.length?(0,U.jsxs)("div",{className:"text-center py-8 text-sm text-muted-foreground border rounded-md",children:[(0,U.jsx)(oC,{className:"h-8 w-8 mx-auto mb-2 opacity-40"}),"No remote servers configured"]}):(0,U.jsxs)(hf,{children:[(0,U.jsx)(hp,{children:(0,U.jsxs)(hg,{children:[(0,U.jsx)(hx,{children:"Name"}),(0,U.jsx)(hx,{children:"Status"}),(0,U.jsx)(hx,{children:"Cross-remote access"}),(0,U.jsx)(hx,{className:"w-[180px] text-right",children:"Actions"})]})}),(0,U.jsx)(hm,{children:e.map(e=>{let r,s;return(0,U.jsxs)(hg,{children:[(0,U.jsx)(hv,{className:"font-medium",children:(0,U.jsxs)("div",{className:"flex items-center",children:[(r="online"===e.status,(0,U.jsx)("span",{className:`inline-block h-2.5 w-2.5 rounded-full mr-2 ${r?"bg-green-500":"bg-gray-400"}`,title:r?"Online":"Offline"})),e.name]})}),(0,U.jsxs)(hv,{className:"font-mono text-xs text-muted-foreground",children:[(0,U.jsx)("div",{children:"online"===e.status?"Connected":"Waiting for connection..."}),(e=>{if(!e.worker_version)return e.last_connected_at?(0,U.jsx)("div",{className:"mt-0.5 text-[11px] text-muted-foreground",title:et,children:"version unknown · upgrade recommended"}):null;let r="behind-min"===e.worker_update_status?(0,U.jsx)("span",{className:"text-red-500",title:et,children:"upgrade required"}):"behind-latest"===e.worker_update_status?(0,U.jsxs)("span",{className:"text-amber-500",title:et,children:["update available → v",e.latest_worker_version]}):null;return(0,U.jsxs)("div",{className:"mt-0.5 text-[11px]",children:[(0,U.jsxs)("span",{className:"text-muted-foreground",children:["v",e.worker_version]}),r&&(0,U.jsx)("span",{className:"ml-1.5",children:r})]})})(e)]}),(0,U.jsx)(hv,{children:(0,U.jsxs)(fP,{value:e.cross_remote_access,onValueChange:r=>ee(e,r),children:[(0,U.jsx)(fL,{className:"w-[190px] text-[12.5px]",children:(0,U.jsx)(fF,{})}),(0,U.jsxs)(fO,{children:[(0,U.jsx)(fB,{value:"off",className:"text-[12.5px]",children:"Off"}),(0,U.jsx)(fB,{value:"read",className:"text-[12.5px]",children:"Diagnostic read"}),(0,U.jsx)(fB,{value:"exec",className:"text-[12.5px]",children:"Command execution"})]})]})}),(0,U.jsxs)(hv,{className:"text-right",children:[(0,U.jsxs)("div",{className:"flex items-center justify-end gap-1",children:[(0,U.jsx)(a$.Button,{variant:"ghost",size:"icon",onClick:()=>G(e),title:"Connect token",className:"h-8 w-8",children:(0,U.jsx)(g9,{className:"h-4 w-4"})}),(s=S[e.id]||"idle",(0,U.jsx)(a$.Button,{variant:"ghost",size:"icon",onClick:()=>Y(e),disabled:"testing"===s,title:"Test connection",className:"h-8 w-8",children:"testing"===s?(0,U.jsx)(aP,{className:"h-4 w-4 animate-spin"}):"success"===s?(0,U.jsx)(al.Check,{className:"h-4 w-4 text-green-500"}):"error"===s?(0,U.jsx)(rD,{className:"h-4 w-4 text-red-500"}):(0,U.jsx)(g8,{className:"h-4 w-4"})})),(0,U.jsx)(a$.Button,{variant:"ghost",size:"icon",onClick:()=>{d(e),h({name:e.name}),p(""),l(!0)},title:"Edit server",className:"h-8 w-8",children:(0,U.jsx)(lT,{className:"h-4 w-4"})}),(0,U.jsx)(a$.Button,{variant:"ghost",size:"icon",onClick:()=>{_(""),v(e)},title:"Delete server",className:"h-8 w-8 text-destructive hover:text-destructive",children:(0,U.jsx)(ok,{className:"h-4 w-4"})})]}),j[e.id]&&(0,U.jsx)("p",{className:"text-xs text-red-500 mt-1 text-right",children:j[e.id]})]})]},e.id)})})]}),(0,U.jsxs)("p",{className:"text-xs text-muted-foreground",children:["When enabled, agents running on your other machines can reach this one.",(0,U.jsx)("strong",{children:" Diagnostic read"})," exposes files, directories and the process list — including any secrets in logs and config files.",(0,U.jsx)("strong",{children:" Command execution"})," additionally allows arbitrary shell commands. Off by default."]}),(0,U.jsx)(rT,{open:o,onOpenChange:l,children:(0,U.jsxs)(rP,{className:"sm:max-w-md",children:[(0,U.jsxs)(rF,{children:[(0,U.jsx)(rO,{children:c?"Edit Server":"Add Remote Server"}),(0,U.jsx)(rB,{children:c?"Update the server name.":"Add a new remote server, then generate a connect token and run the connect command on the remote machine."})]}),(0,U.jsxs)("div",{className:"space-y-4",children:[(0,U.jsxs)("div",{className:"space-y-2",children:[(0,U.jsx)("label",{className:"text-sm font-medium",children:"Name"}),(0,U.jsx)(aX,{value:u.name,onChange:e=>{h(r=>({...r,name:e.target.value})),p("")},placeholder:"My Remote Server"})]}),f&&(0,U.jsx)("p",{className:"text-sm text-red-500",children:f})]}),(0,U.jsxs)(rL,{children:[(0,U.jsx)(a$.Button,{variant:"outline",onClick:()=>l(!1),children:"Cancel"}),(0,U.jsxs)(a$.Button,{onClick:K,disabled:m,children:[m&&(0,U.jsx)(aP,{className:"h-4 w-4 mr-1.5 animate-spin"}),c?"Save Changes":"Add Server"]})]})]})}),(0,U.jsx)(rT,{open:null!==N,onOpenChange:e=>{e||(H.current=null,E(null),T(null),A(null),I(null),W(!1))},children:(0,U.jsxs)(rP,{className:"sm:max-w-lg",children:[(0,U.jsxs)(rF,{children:[(0,U.jsx)(rO,{children:"Connect Token"}),(0,U.jsxs)(rB,{children:["Use this token to connect a remote node to"," ",(0,U.jsx)("span",{className:"font-semibold",children:N?.name}),". It stays the same every time you open this dialog — rotate it to issue a replacement."]})]}),P?(0,U.jsx)("div",{className:"flex items-center justify-center py-4",children:(0,U.jsx)(aP,{className:"h-5 w-5 animate-spin text-muted-foreground"})}):D?(0,U.jsxs)("div",{className:"space-y-4",children:[M&&(0,U.jsx)(xr,{label:"Install as a service (Linux, macOS)",value:M,copied:"install"===L,onCopy:()=>Q("install",M),hint:"Recommended. Runs the worker in the background, starts it at boot and restarts it if it crashes. Manage it afterwards with `vibedeckx connect status`."}),(0,U.jsxs)("div",{className:"space-y-2",children:[(0,U.jsx)(xr,{label:M?"Run in this terminal only":"Connect Command",value:R||"",copied:"run"===L,onCopy:()=>Q("run",R||""),hint:M?"Any OS. Stops when you close the terminal.":"Run this command on the remote machine to establish the reverse connection."}),$&&(0,U.jsx)("p",{className:"text-xs text-destructive",children:"Rotating invalidates the current token immediately. Any worker still using it will fail to reconnect until it gets the new one: run `vibedeckx connect setup` on a machine installed as a service, or re-run the new command."})]})]}):null,(0,U.jsxs)(rL,{children:[D&&N&&(0,U.jsxs)("div",{className:"mr-auto flex items-center gap-2",children:[(0,U.jsxs)(a$.Button,{variant:"outline",disabled:B,onClick:()=>{$?J(N):W(!0)},children:[B?(0,U.jsx)(aP,{className:"mr-2 h-4 w-4 animate-spin"}):(0,U.jsx)(m_,{className:"mr-2 h-4 w-4"}),$?"Confirm rotate":"Rotate Token"]}),(0,U.jsx)(a$.Button,{variant:"outline",className:"text-destructive hover:text-destructive",onClick:()=>{Z(N),H.current=null,E(null),T(null)},children:"Revoke Token"})]}),(0,U.jsx)(a$.Button,{variant:"outline",onClick:()=>{H.current=null,E(null),T(null),A(null),I(null),W(!1)},children:"Close"})]})]})}),(0,U.jsx)(rT,{open:null!==x,onOpenChange:e=>{e||v(null)},children:(0,U.jsxs)(rP,{className:"sm:max-w-sm",children:[(0,U.jsxs)(rF,{children:[(0,U.jsx)(rO,{children:"Delete Server"}),(0,U.jsxs)(rB,{children:["Are you sure you want to delete"," ",(0,U.jsx)("span",{className:"font-semibold",children:x?.name}),"? A server that projects still link cannot be deleted: unlink it in each project's settings first."]})]}),w&&(0,U.jsx)("p",{className:"text-sm text-red-500",children:w}),(0,U.jsxs)(rL,{children:[(0,U.jsx)(a$.Button,{variant:"outline",onClick:()=>v(null),children:"Cancel"}),(0,U.jsxs)(a$.Button,{variant:"destructive",onClick:X,disabled:y,children:[y&&(0,U.jsx)(aP,{className:"h-4 w-4 mr-1.5 animate-spin"}),"Delete"]})]})]})})]})}function xr({label:e,value:r,copied:s,onCopy:n,hint:i}){return(0,U.jsxs)("div",{className:"space-y-2",children:[(0,U.jsx)("label",{className:"text-sm font-medium",children:e}),(0,U.jsxs)("div",{className:"flex gap-2",children:[(0,U.jsx)(aX,{readOnly:!0,value:r,"aria-label":e,className:"font-mono text-xs"}),(0,U.jsx)(a$.Button,{variant:"outline",size:"icon",className:"shrink-0",onClick:n,title:"Copy command",children:s?(0,U.jsx)(al.Check,{className:"h-4 w-4 text-green-500"}):(0,U.jsx)(mw.Copy,{className:"h-4 w-4"})})]}),(0,U.jsx)("p",{className:"text-xs text-muted-foreground",children:i})]})}let xs=(0,rE.default)("lock",[["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"}]]),xn=(0,rE.default)("rotate-cw",[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8",key:"1p45f6"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}]]),xi=(0,V.createContext)(null);function xa({projectId:e,children:r}){let s=aB(e,{withStatus:!0});return(0,U.jsx)(xi.Provider,{value:s,children:r})}function xo(){return(0,V.useContext)(xi)}function xl(){let e=(0,V.useContext)(xi);if(!e)throw Error("useProjectRemotesContext must be used within a ProjectRemotesProvider");return e}var xc=e.i(754219);function xd(e){return e?.state==="absent"||e?.state==="error"}let xu=[],xh=/^[a-zA-Z0-9]/,xf=/[^a-zA-Z0-9/_-]/;function xp({projectId:e,project:r,open:s,onOpenChange:n,onWorktreeCreated:i,initialBranchName:a,initialMachines:o,initialTargets:l,initialSelectedTargets:c}){let[d,u]=(0,V.useState)(""),[h,f]=(0,V.useState)(!1),[p,m]=(0,V.useState)(null),[g,x]=(0,V.useState)(null),[v,y]=(0,V.useState)([]),[b,w]=(0,V.useState)("main"),[_,S]=(0,V.useState)(!1),[k,j]=(0,V.useState)(null),[C,N]=(0,V.useState)({status:"loading"}),[E,D]=(0,V.useState)(0),T=xo(),R=T&&T.remotes.length>0&&!T.loading?T.remotes:null,A="loading"!==C.status?C:R?{status:"ready",remotes:R}:C,M="ready"===A.status?A.remotes:xu,I="ready"===A.status;(0,V.useEffect)(()=>{if(!s)return;let r=!1;return N({status:"loading"}),aC.api.getProjectRemotes(e).then(e=>{r||N({status:"ready",remotes:e})},e=>{r||N({status:"error",message:e instanceof Error?e.message:"Could not read this project's machines"})}),()=>{r=!0}},[s,e,E]);let P=(0,V.useMemo)(()=>{let e=[];for(let s of(r.path&&e.push({id:"local",label:"Local",path:r.path}),M))e.push({id:s.remote_server_id,label:s.server_name,path:s.remote_path});return 0===M.length&&r.remote_path&&e.push({id:"remote",label:"Remote",path:r.remote_path}),e},[r.path,r.remote_path,M]),F=(0,V.useMemo)(()=>Math.min(Math.max(P.reduce((e,r)=>Math.max(e,r.label.length),0)+1,6),20),[P]),L=!!a,O=(0,V.useMemo)(()=>o??(l?(0,dA.machinesFromTargets)(l):[]),[o,l]),[B,z]=(0,V.useState)(new Map),[$,W]=(0,V.useState)("idle"),[H,q]=(0,V.useState)(0),[K,X]=(0,V.useState)(!1);(0,V.useEffect)(()=>{s&&z(new Map(O.map(e=>[e.serverId,{...e}])))},[s,O]);let Y=(0,V.useRef)(c);Y.current=c;let G=(0,V.useCallback)((e,r)=>B.get(e)??{serverId:e,name:r,state:"unknown"},[B]);(0,V.useEffect)(()=>{if(!s||!L||!a)return;let r=!1;return W("checking"),aC.api.getWorktreeMachines(e,a).then(e=>{if(r)return;if(!e)return void W("unavailable");z(r=>{let s=new Map(r);for(let r of e.machines){let e=s.get(r.serverId);s.set(r.serverId,{...e,...{serverId:r.serverId,name:r.name,state:r.state,...void 0!==r.error?{error:r.error}:{},...r.deleted?{deleted:!0}:{},checked:r.checked,...r.checkError?{checkError:r.checkError}:{}}})}return s});let s=Y.current;j(r=>{let n=new Set(r??[]);for(let r of e.machines)xd(r)?!Z.current.has(r.serverId)&&(!s||s.includes(r.serverId))&&n.add(r.serverId):n.delete(r.serverId);return n}),W("done")},()=>{r||W("unavailable")}),()=>{r=!0}},[s,L,a,e,H]),(0,V.useEffect)(()=>{s&&u(a??"")},[s,a]);let J=P.map(e=>e.id).join("\n");(0,V.useEffect)(()=>{if(!s||"ready"!==A.status)return;S(!0);let r=J?J.split("\n"):[void 0],n=!1;return Promise.all(r.map(r=>aC.api.getProjectBranches(e,r))).then(e=>{if(n)return;let r=[],s=new Set;for(let n of e)for(let e of n)s.has(e)||(s.add(e),r.push(e));y(r),w(e=>r.includes(e)?e:r.includes("main")?"main":r[0]||"main"),S(!1)}),()=>{n=!0}},[s,e,J,A.status]);let Z=(0,V.useRef)(new Set);(0,V.useEffect)(()=>{if(!s){Z.current=new Set;return}let e=P.filter(e=>!Z.current.has(e.id));if(0!==e.length){for(let r of e)Z.current.add(r.id);j(r=>{let s=new Set(r??[]);for(let r of e){if(!L){s.add(r.id);continue}let e=O.find(e=>e.serverId===r.id);if(!e||"unknown"===e.state){Z.current.delete(r.id);continue}xd(e)&&(!c||c.includes(r.id))&&s.add(r.id)}return s})}},[s,P,L,O,c]);let Q=(0,V.useMemo)(()=>P.filter(e=>k?.has(e.id)&&(!L||xd(G(e.id,e.label)))).map(e=>e.id),[P,k,L,G]),ee=d.trim(),et=ee?xf.test(ee)?"Use letters, numbers and / _ - only":xh.test(ee)?null:"Must start with a letter or a number":null,er=!L&&v.includes(ee),es=P.length>0&&0===Q.length,en="ready"===C.status,ei=L&&"checking"===$,ea=!!ee&&!et&&!es&&!h&&en&&!ei,eo=async()=>{if(ea){f(!0),m(null),x(null);try{let r=await aC.api.createWorktree(e,ee,P.length>0?Q:void 0,b);if(r.partialSuccess&&(x((0,dA.describeTargetResults)(r.results,"created")??"Some targets failed"),X(!0)),L){let e=Object.entries(r.results??{}).filter(e=>!!e[1]).map(([e,r])=>({id:r.targetId??e,outcome:r}));0===e.length&&1===Q.length&&e.push({id:Q[0],outcome:{success:!0,adopted:r.worktree.adopted}}),z(r=>{let s=new Map(r);for(let{id:r,outcome:n}of e){let e=s.get(r)??{serverId:r,name:r,state:"unknown"};s.set(r,n.success?{serverId:r,name:e.name,state:"present",checked:!0,reused:!!n.adopted}:{...e,failure:(0,dA.targetFailureReason)(n)})}return s}),j(r=>{let s=new Set(r??[]);for(let{id:r,outcome:n}of e)n.success&&s.delete(r);return s})}let s=(0,dA.adoptedTargets)(r.results);if(s.length>0||r.worktree.adopted){let e=s.length>0?` on ${s.join(", ")}`:"";xc.toast.info(`Reused the existing '${ee}' branch${e}`,{description:"The workspace keeps that branch's own history."})}i(r.worktree.branch),r.partialSuccess||el(!1)}catch(e){m(e instanceof Error?e.message:"Failed to create workspace")}finally{f(!1)}}},el=e=>{e||(u(""),m(null),x(null),y([]),w("main"),j(null),Z.current=new Set,N({status:"loading"}),z(new Map),W("idle"),X(!1)),n(e)},ec=(0,V.useMemo)(()=>{let e=P.map(e=>G(e.id,e.label));return{present:e.filter(e=>"present"===e.state).length,total:e.length}},[P,G]),ed=ee?et?{text:"Invalid",tone:"bad"}:L?{text:"Existing",tone:"muted"}:er?{text:"Exists",tone:"bad"}:_?null:{text:"Available",tone:"ok"}:null;return(0,U.jsx)(rT,{open:s,onOpenChange:el,children:(0,U.jsxs)(rP,{className:"sm:max-w-[440px] max-h-[85vh] grid-rows-[auto_minmax(0,1fr)_auto] gap-0 p-0 overflow-hidden",onKeyDown:e=>{"Enter"===e.key&&(e.metaKey||e.ctrlKey)&&eo()},children:[(0,U.jsxs)(rF,{className:"flex-row items-start gap-3 space-y-0 border-b bg-muted/40 px-4 py-3.5 pr-10 text-left",children:[(0,U.jsx)("span",{className:"mt-0.5 flex size-7 shrink-0 items-center justify-center rounded-lg border border-primary/20 bg-primary/10 text-primary",children:(0,U.jsx)(ao,{className:"size-3.5"})}),(0,U.jsxs)("div",{className:"min-w-0",children:[(0,U.jsx)(rO,{className:"text-sm font-semibold",children:L?(0,U.jsxs)(U.Fragment,{children:["Manage remotes for ",(0,U.jsx)("span",{className:"font-mono",children:a})]}):"Create New Workspace"}),(0,U.jsx)(rB,{className:"mt-1 text-xs",children:L?`${a} exists on ${ec.present} of ${ec.total} remotes.`:"Checks out a new branch as its own git worktree on each machine."})]})]}),(0,U.jsxs)("div",{className:"flex min-h-0 min-w-0 flex-col gap-3.5 overflow-y-auto px-4 py-3.5",children:[(0,U.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,U.jsxs)("div",{className:"flex items-center gap-2",children:[(0,U.jsx)("label",{htmlFor:"branch-name",className:"text-[10px] font-semibold uppercase tracking-[0.07em] text-muted-foreground",children:"Branch Name"}),(0,U.jsx)("span",{className:"flex-1"}),(0,U.jsx)("span",{className:"text-[10.5px] text-muted-foreground",children:L?"Existing workspace":"Required"})]}),(0,U.jsxs)("div",{className:(0,e1.cn)("flex h-9 items-center gap-2 rounded-lg border bg-background px-2.5 focus-within:border-primary focus-within:ring-[3px] focus-within:ring-primary/15",ed?.tone==="bad"&&"border-destructive/50 focus-within:border-destructive focus-within:ring-destructive/15"),children:[L?(0,U.jsx)(xs,{className:"size-3 shrink-0 text-muted-foreground"}):(0,U.jsx)(ao,{className:"size-3 shrink-0 text-muted-foreground"}),(0,U.jsx)("input",{id:"branch-name",className:"min-w-0 flex-1 bg-transparent font-mono text-[12.5px] outline-none placeholder:text-muted-foreground read-only:text-muted-foreground",placeholder:"feature/my-feature",value:d,onChange:e=>{L||u(e.target.value)},disabled:h,readOnly:L,autoFocus:!L,onKeyDown:e=>{"Enter"!==e.key||e.metaKey||e.ctrlKey||eo()}}),ed&&(0,U.jsx)("span",{className:(0,e1.cn)("shrink-0 font-mono text-[10px]","ok"===ed.tone&&"text-emerald-600 dark:text-emerald-500","bad"===ed.tone&&"text-destructive","muted"===ed.tone&&"text-muted-foreground"),children:ed.text})]}),(0,U.jsx)("p",{className:(0,e1.cn)("text-[10.5px] text-muted-foreground",(et||er)&&"text-destructive"),children:et||(L?"This workspace's name. To start a different one, use the + button.":er?"That branch already exists — continuing adopts it, keeping its own history":"Also names the workspace · use / to group")})]}),(0,U.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,U.jsxs)("div",{className:"flex items-center gap-2",children:[(0,U.jsx)("span",{className:"text-[10px] font-semibold uppercase tracking-[0.07em] text-muted-foreground",children:"Base Branch"}),(0,U.jsx)("span",{className:"flex-1"}),(0,U.jsx)("span",{className:"text-[10.5px] text-muted-foreground",children:_?"Loading…":`${v.length} ${1===v.length?"branch":"branches"}`})]}),(0,U.jsxs)(fP,{value:b,onValueChange:w,disabled:h||_||0===v.length,children:[(0,U.jsx)(fL,{size:"sm",className:"w-full font-mono text-[11.5px]",children:(0,U.jsx)(fF,{placeholder:_?"Loading branches…":"Select branch"})}),(0,U.jsx)(fO,{position:"popper",className:"w-(--radix-select-trigger-width)",children:v.map(e=>(0,U.jsx)(fB,{value:e,className:"font-mono text-[11.5px] *:[span]:last:min-w-0 *:[span]:last:overflow-hidden",children:(0,U.jsx)("span",{className:"truncate",children:e})},e))})]}),(0,U.jsx)("p",{className:"text-[10.5px] text-muted-foreground",children:L?(0,U.jsxs)(U.Fragment,{children:["New checkouts start from this branch. Work done on other remotes is not copied. If ",(0,U.jsx)("span",{className:"font-mono",children:a})," already exists in a remote's repository it is reused as-is."]}):"The same start point on every machine picked below."})]}),(P.length>0||"loading"===A.status)&&(0,U.jsxs)("div",{className:"flex min-h-0 flex-col gap-2",children:[(0,U.jsxs)("div",{className:"flex items-center gap-2",children:[(0,U.jsx)("span",{className:"text-[10px] font-semibold uppercase tracking-[0.07em] text-muted-foreground",children:"Create On"}),(0,U.jsx)("span",{className:"flex-1"}),L?(0,U.jsxs)("button",{type:"button",className:"flex items-center gap-1 text-[10.5px] text-muted-foreground underline-offset-2 hover:underline disabled:no-underline disabled:opacity-60",disabled:"checking"===$||h,onClick:()=>q(e=>e+1),children:["checking"===$?(0,U.jsx)(aP,{className:"size-3 animate-spin"}):(0,U.jsx)(xn,{className:"size-3"}),"checking"===$?"Checking…":"Check again"]}):(0,U.jsx)("span",{className:"text-[10.5px] text-muted-foreground",children:"Pick at least one"})]}),(0,U.jsx)("div",{className:"-mx-1 flex min-h-[40px] max-h-[144px] flex-col gap-2 overflow-y-auto px-1 py-0.5",children:P.map(e=>{var r;let s,n=G(e.id,e.label),i=!L||xd(n),a=i&&!!k?.has(e.id),o=L?(e=>{if(e.failure)return{text:"Failed",tone:"bad",title:e.failure};if("checking"===$)return{text:"Checking…",tone:"muted"};switch(e.state){case"present":return e.reused?{text:"Reused",tone:"ok"}:{text:"Has it",tone:"ok"};case"absent":return e.deleted?{text:"Deleted",tone:"warn"}:{text:"Missing",tone:"warn"};case"error":return{text:"Failed",tone:"bad",title:e.error||"The last attempt failed here"};case"creating":return{text:"Creating…",tone:"muted"};case"deleting":return{text:"Deleting…",tone:"muted"};case"unknown":return{text:"Could not check",tone:"muted",title:e.checkError}}})(n):null,[l,c]=(s=Math.max((r=e.path??"").lastIndexOf("/"),r.lastIndexOf("\\")))<=0||r.length-s>32?[r,""]:[r.slice(0,s),r.slice(s)];return(0,U.jsxs)("label",{className:(0,e1.cn)("flex shrink-0 items-center gap-2.5 rounded-lg border px-2.5 py-2 transition-colors","has-[:focus-visible]:ring-[3px] has-[:focus-visible]:ring-ring/40",i?"cursor-pointer":"cursor-default opacity-60",a?"border-primary bg-primary/5":i?"hover:bg-muted/60 opacity-80":""),children:[(0,U.jsx)("input",{type:"checkbox",className:"sr-only",checked:a,disabled:h||!i,onChange:()=>{var r;return r=e.id,void(Z.current.add(r),j(e=>{let s=new Set(e??[]);return s.has(r)?s.delete(r):s.add(r),s}))}}),(0,U.jsx)("span",{className:(0,e1.cn)("flex size-3.5 shrink-0 items-center justify-center rounded border",a?"border-primary bg-primary text-primary-foreground":"border-input bg-background"),children:a&&(0,U.jsx)(al.Check,{className:"size-2.5",strokeWidth:3.5})}),(0,U.jsxs)("span",{className:"flex min-w-0 flex-1 flex-col gap-0.5",children:[(0,U.jsxs)("span",{className:"flex min-w-0 items-center gap-2",children:[(0,U.jsx)("span",{title:e.label,style:{width:`${F}ch`},className:"shrink-0 truncate text-[12.5px] font-medium",children:e.label}),o&&(0,U.jsx)("span",{title:o.title,className:(0,e1.cn)("shrink-0 rounded-full border px-1.5 py-px font-mono text-[9.5px]","ok"===o.tone&&"border-emerald-600/30 bg-emerald-500/10 text-emerald-700 dark:text-emerald-400","bad"===o.tone&&"border-destructive/35 bg-destructive/10 text-destructive","warn"===o.tone&&"border-amber-500/35 bg-amber-500/10 text-amber-700 dark:text-amber-400","muted"===o.tone&&"border-border bg-muted text-muted-foreground"),children:o.text}),e.path&&(0,U.jsxs)("span",{title:e.path,className:"ml-auto flex min-w-0 font-mono text-[10.5px] text-muted-foreground",children:[(0,U.jsx)("span",{className:"min-w-0 truncate",children:l}),(0,U.jsx)("span",{className:"shrink-0",children:c})]})]}),n.failure&&(0,U.jsx)("span",{className:"truncate text-[10.5px] text-destructive",title:n.failure,children:n.failure})]})]},e.id)})})]}),"error"===A.status&&(0,U.jsxs)("div",{className:"flex shrink-0 items-start gap-2 rounded-lg border border-destructive/30 bg-destructive/10 px-2.5 py-2 text-[11.5px] text-destructive",children:[(0,U.jsx)(ou,{className:"mt-px size-3.5 shrink-0"}),(0,U.jsxs)("span",{className:"min-w-0 flex-1",children:["Could not read this project's machines — ",A.message,". Creating now could miss the machines it never listed."]}),(0,U.jsxs)("button",{type:"button",className:"flex shrink-0 items-center gap-1 underline underline-offset-2",onClick:()=>D(e=>e+1),children:[(0,U.jsx)(xn,{className:"size-3"}),"Try again"]})]}),g&&(0,U.jsxs)("div",{className:"flex shrink-0 items-start gap-2 rounded-lg border border-amber-500/30 bg-amber-500/10 px-2.5 py-2 text-[11.5px] text-amber-700 dark:text-amber-400",children:[(0,U.jsx)(ou,{className:"mt-px size-3.5 shrink-0"}),(0,U.jsx)("span",{children:g})]}),p&&(0,U.jsxs)("div",{className:"flex shrink-0 items-start gap-2 rounded-lg border border-destructive/30 bg-destructive/10 px-2.5 py-2 text-[11.5px] text-destructive",children:[(0,U.jsx)(ou,{className:"mt-px size-3.5 shrink-0"}),(0,U.jsx)("span",{children:p})]})]}),(0,U.jsxs)(rL,{className:"min-w-0 flex-row items-center gap-2.5 border-t bg-muted/40 px-4 py-3",children:[(0,U.jsxs)("span",{className:"flex min-w-0 items-center gap-1.5 text-[11px] text-muted-foreground",children:[h||"loading"===C.status?(0,U.jsx)(aP,{className:"size-3 shrink-0 animate-spin"}):es||"error"===A.status?(0,U.jsx)(xs,{className:"size-3 shrink-0"}):(0,U.jsx)(h$,{className:"size-3 shrink-0"}),(0,U.jsx)("span",{className:"min-w-0 truncate",children:h?"Checking out the worktree…":(()=>{if("error"===A.status)return"Cannot tell which machines this project has";if(!I)return"Looking up this project's machines…";if(!en)return"Confirming this project's machines…";if(0===P.length)return"Creates a worktree on every machine";if(0===Q.length)return"Pick at least one machine";let e=P.filter(e=>k?.has(e.id)).map(e=>e.label);return e.length<=2?`Creates a worktree on ${e.join(" and ")}`:`Creates a worktree on ${e.length} machines`})()})]}),(0,U.jsx)("span",{className:"flex-1"}),(0,U.jsx)(a$.Button,{variant:"outline",size:"sm",onClick:()=>el(!1),disabled:h,children:"Cancel"}),(0,U.jsxs)(a$.Button,{size:"sm",onClick:eo,disabled:!ea,children:[h?(0,U.jsx)(aP,{className:"size-3 animate-spin"}):(0,U.jsx)(oS,{className:"size-3"}),h?"Creating…":L?`${K?"Retry":"Create"} on ${Q.length} ${1===Q.length?"remote":"remotes"}`:er?"Adopt & Create":"Create",!h&&(0,U.jsx)("kbd",{className:"rounded border border-background/30 bg-background/15 px-1 font-mono text-[10px] leading-4",children:"⌘⏎"})]})]})]})})}function xm({missing:e,onOpenChange:r,onCreateHere:s,onOpenAnyway:n}){return(0,U.jsx)(rT,{open:null!==e,onOpenChange:r,children:(0,U.jsx)(rP,{className:"sm:max-w-[400px] gap-0 p-0 overflow-hidden",children:e&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(rF,{className:"border-b bg-muted/40 px-4 py-3.5 pr-10 text-left",children:[(0,U.jsxs)(rO,{className:"text-sm font-semibold",children:[(0,U.jsx)("span",{className:"font-mono",children:e.branch})," is not on ",e.current.name]}),(0,U.jsx)(rB,{className:"mt-1 text-xs",children:e.presentOn.length>0?`Sessions run on ${e.current.name}, which has no checkout of this workspace. It exists on ${e.presentOn.map(e=>e.name).join(", ")}; to work there, switch the project's remote in the session header.`:`Sessions run on ${e.current.name}, which has no checkout of this workspace.`})]}),(0,U.jsxs)("div",{className:"flex flex-col gap-1.5 px-4 py-3.5",children:[(0,U.jsxs)(a$.Button,{variant:"outline",size:"sm",className:"justify-start",onClick:s,children:[(0,U.jsx)(oS,{className:"size-3.5"}),"Create on ",e.current.name]}),(0,U.jsxs)(a$.Button,{variant:"ghost",size:"sm",className:"justify-start",onClick:n,children:[(0,U.jsx)(oh,{className:"size-3.5"}),"Open anyway"]})]}),(0,U.jsx)(rL,{className:"border-t bg-muted/40 px-4 py-2.5",children:(0,U.jsx)("p",{className:"text-[10.5px] text-muted-foreground",children:"What the hub last recorded; the remote itself may differ."})})]})})})}function xg({projectId:e,worktree:r,open:s,onOpenChange:n,onWorktreeDeleted:i,onOpenTerminal:a}){let[o,l]=(0,V.useState)(!1),[c,d]=(0,V.useState)(null),[u,h]=(0,V.useState)(null),[f,p]=(0,V.useState)(!1),[m,g]=(0,V.useState)(null),x=async r=>{let s=await aC.api.deleteWorktree(e,r),n=(0,dA.describeRetainedBranches)(s.results,s.branchRetained);return n&&xc.toast.info(n,{description:"Creating this workspace again will reuse that branch."}),i(),s},v=async()=>{if(r){l(!0),d(null);try{let e=r.branch,s=await x(e);n(!1),s.partialSuccess&&h({branch:e,lines:(0,dA.targetOutcomeLines)(s.results)})}catch(e){d(e instanceof Error?e.message:"Failed to delete workspace")}finally{l(!1)}}},y=async()=>{if(u){p(!0),g(null);try{let e=await x(u.branch);e.partialSuccess?h({branch:u.branch,lines:(0,dA.targetOutcomeLines)(e.results)}):(h(null),xc.toast.success(`Deleted '${u.branch}' everywhere`))}catch(e){g(e instanceof Error?e.message:"Failed to delete workspace")}finally{p(!1)}}},b=e=>{e||d(null),n(e)},w=()=>{h(null),g(null)};return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(rT,{open:s,onOpenChange:b,children:(0,U.jsxs)(rP,{children:[(0,U.jsxs)(rF,{children:[(0,U.jsx)(rO,{children:"Delete Workspace"}),(0,U.jsx)(rB,{children:"Are you sure you want to delete this workspace?"})]}),r&&(0,U.jsx)("div",{className:"space-y-2",children:(0,U.jsxs)("div",{className:"text-sm",children:[(0,U.jsx)("span",{className:"font-medium",children:"Branch:"})," ",(0,U.jsx)("span",{className:"text-muted-foreground",children:r.branch})]})}),c&&(0,U.jsx)("div",{className:"text-sm text-destructive bg-destructive/10 px-3 py-2 rounded-md",children:c}),(0,U.jsxs)(rL,{children:[(0,U.jsx)(a$.Button,{variant:"outline",onClick:()=>b(!1),disabled:o,children:"Cancel"}),(0,U.jsx)(a$.Button,{variant:"destructive",onClick:v,disabled:o,children:o?"Deleting...":"Delete"})]})]})}),(0,U.jsx)(rT,{open:null!==u,onOpenChange:e=>{e||w()},children:(0,U.jsxs)(rP,{children:[(0,U.jsxs)(rF,{children:[(0,U.jsx)(rO,{children:"Partly deleted"}),(0,U.jsx)(rB,{children:`'${u?.branch}' is still there on the machines marked below. Retrying deletes only those; the workspace stays in the sidebar, marked, until they are done.`})]}),(0,U.jsx)("ul",{className:"space-y-2 text-sm",children:u?.lines.map(e=>(0,U.jsxs)("li",{className:"flex gap-2",children:[e.ok?(0,U.jsx)(al.Check,{className:"size-4 shrink-0 mt-0.5 text-emerald-600 dark:text-emerald-500"}):(0,U.jsx)(rD,{className:"size-4 shrink-0 mt-0.5 text-destructive"}),(0,U.jsxs)("span",{className:"min-w-0",children:[(0,U.jsx)("span",{className:"font-medium",children:e.label}),e.detail&&(0,U.jsxs)("span",{className:"text-muted-foreground",children:[" — ",e.detail]}),!e.ok&&e.targetId&&a&&u&&(0,U.jsxs)("button",{className:"ml-2 inline-flex items-center gap-1 align-baseline text-xs text-muted-foreground hover:text-foreground underline underline-offset-2",onClick:()=>{w(),a(u.branch,e.targetId)},children:[(0,U.jsx)(my,{className:"size-3"}),"Open a terminal there"]})]})]},e.key))}),m&&(0,U.jsx)("div",{className:"text-sm text-destructive bg-destructive/10 px-3 py-2 rounded-md",children:m}),(0,U.jsxs)(rL,{children:[(0,U.jsx)(a$.Button,{variant:"outline",onClick:w,disabled:f,children:"Close"}),(0,U.jsx)(a$.Button,{variant:"destructive",onClick:y,disabled:f,children:f?"Retrying...":"Retry"})]})]})})]})}e.i(247755);var xx=e.i(642098);function xv(){let{config:e}=(0,ow.useAppConfig)();return e?.authEnabled?(0,U.jsx)("div",{className:"flex items-center",children:(0,U.jsx)(xx.UserButton,{appearance:{elements:{avatarBox:"h-7 w-7 ring-1 ring-border/60"}}})}):null}var xy=e.i(183663);let xb=(0,rE.default)("terminal",[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]]);var xw="Collapsible",[x_,xS]=es(xw),[xk,xj]=x_(xw),xC=V.forwardRef((e,r)=>{let{__scopeCollapsible:s,open:n,defaultOpen:i,disabled:a,onOpenChange:o,...l}=e,[c,d]=ey({prop:n,defaultProp:i??!1,onChange:o,caller:xw});return(0,U.jsx)(xk,{scope:s,disabled:a,contentId:ef(),open:c,onOpenToggle:V.useCallback(()=>d(e=>!e),[d]),children:(0,U.jsx)(em.div,{"data-state":xA(c),"data-disabled":a?"":void 0,...l,ref:r})})});xC.displayName=xw;var xN="CollapsibleTrigger",xE=V.forwardRef((e,r)=>{let{__scopeCollapsible:s,...n}=e,i=xj(xN,s);return(0,U.jsx)(em.button,{type:"button","aria-controls":i.contentId,"aria-expanded":i.open||!1,"data-state":xA(i.open),"data-disabled":i.disabled?"":void 0,disabled:i.disabled,...n,ref:r,onClick:er(e.onClick,i.onOpenToggle)})});xE.displayName=xN;var xD="CollapsibleContent",xT=V.forwardRef((e,r)=>{let{forceMount:s,...n}=e,i=xj(xD,e.__scopeCollapsible);return(0,U.jsx)(eO,{present:s||i.open,children:({present:e})=>(0,U.jsx)(xR,{...n,ref:r,present:e})})});xT.displayName=xD;var xR=V.forwardRef((e,r)=>{let{__scopeCollapsible:s,present:n,children:i,...a}=e,o=xj(xD,s),[l,c]=V.useState(n),d=V.useRef(null),u=(0,en.useComposedRefs)(r,d),h=V.useRef(0),f=h.current,p=V.useRef(0),m=p.current,g=o.open||l,x=V.useRef(g),v=V.useRef(void 0);return V.useEffect(()=>{let e=requestAnimationFrame(()=>x.current=!1);return()=>cancelAnimationFrame(e)},[]),ed(()=>{let e=d.current;if(e){v.current=v.current||{transitionDuration:e.style.transitionDuration,animationName:e.style.animationName},e.style.transitionDuration="0s",e.style.animationName="none";let r=e.getBoundingClientRect();h.current=r.height,p.current=r.width,x.current||(e.style.transitionDuration=v.current.transitionDuration,e.style.animationName=v.current.animationName),c(n)}},[o.open,n]),(0,U.jsx)(em.div,{"data-state":xA(o.open),"data-disabled":o.disabled?"":void 0,id:o.contentId,hidden:!g,...a,ref:u,style:{"--radix-collapsible-content-height":f?`${f}px`:void 0,"--radix-collapsible-content-width":m?`${m}px`:void 0,...e.style},children:g&&i})});function xA(e){return e?"open":"closed"}function xM({...e}){return(0,U.jsx)(xC,{"data-slot":"collapsible",...e})}function xI({...e}){return(0,U.jsx)(xE,{"data-slot":"collapsible-trigger",...e})}function xP({...e}){return(0,U.jsx)(xT,{"data-slot":"collapsible-content",...e})}let xF=(0,rE.default)("ellipsis-vertical",[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"12",cy:"5",r:"1",key:"gxeob9"}],["circle",{cx:"12",cy:"19",r:"1",key:"lyex9k"}]]),xL=(0,rE.default)("ban",[["path",{d:"M4.929 4.929 19.07 19.071",key:"196cmz"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);var xO=e.i(885101),xB=Object.defineProperty,xz=Object.getOwnPropertyDescriptor,x$=(e,r,s,n)=>{for(var i,a=n>1?void 0:n?xz(r,s):r,o=e.length-1;o>=0;o--)(i=e[o])&&(a=(n?i(r,s,a):i(a))||a);return n&&a&&xB(r,s,a),a},xW=(e,r)=>(s,n)=>r(s,n,e),xH="Terminal input",xU="Too much output to announce, navigate to rows manually to read";function xV(e,r,s,n){var i;i=e=e.replace(/\r?\n/g,"\r"),e=s.decPrivateModes.bracketedPasteMode&&!0!==n.rawOptions.ignoreBracketedPasteMode?"\x1b[200~"+i+"\x1b[201~":i,s.triggerDataEvent(e,!0),r.value=""}function xq(e,r,s){let n=s.getBoundingClientRect(),i=e.clientX-n.left-10,a=e.clientY-n.top-10;r.style.width="20px",r.style.height="20px",r.style.left=`${i}px`,r.style.top=`${a}px`,r.style.zIndex="1000",r.focus()}function xK(e,r,s,n,i){xq(e,r,s),i&&n.rightClickSelect(e),r.value=n.selectionText,r.select()}function xX(e){return e>65535?String.fromCharCode(((e-=65536)>>10)+55296)+String.fromCharCode(e%1024+56320):String.fromCharCode(e)}function xY(e,r=0,s=e.length){let n="";for(let i=r;i<s;++i){let r=e[i];r>65535?(r-=65536,n+=String.fromCharCode((r>>10)+55296)+String.fromCharCode(r%1024+56320)):n+=String.fromCharCode(r)}return n}var xG=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,r){let s=e.length;if(!s)return 0;let n=0,i=0;if(this._interim){let s=e.charCodeAt(i++);56320<=s&&s<=57343?r[n++]=(this._interim-55296)*1024+s-56320+65536:(r[n++]=this._interim,r[n++]=s),this._interim=0}for(let a=i;a<s;++a){let i=e.charCodeAt(a);if(55296<=i&&i<=56319){if(++a>=s)return this._interim=i,n;let o=e.charCodeAt(a);56320<=o&&o<=57343?r[n++]=(i-55296)*1024+o-56320+65536:(r[n++]=i,r[n++]=o);continue}65279!==i&&(r[n++]=i)}return n}},xJ=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,r){let s=e.length;if(!s)return 0;let n=0,i,a,o,l,c=0,d=0;if(this.interim[0]){let i=!1,a=this.interim[0];a&=(224&a)==192?31:(240&a)==224?15:7;let o=0,l;for(;(l=63&this.interim[++o])&&o<4;)a<<=6,a|=l;let c=(224&this.interim[0])==192?2:(240&this.interim[0])==224?3:4,u=c-o;for(;d<u;){if(d>=s)return 0;if((192&(l=e[d++]))!=128){d--,i=!0;break}this.interim[o++]=l,a<<=6,a|=63&l}i||(2===c?a<128?d--:r[n++]=a:3===c?a<2048||a>=55296&&a<=57343||65279===a||(r[n++]=a):a<65536||a>1114111||(r[n++]=a)),this.interim.fill(0)}let u=s-4,h=d;for(;h<s;){for(;h<u&&!(128&(i=e[h]))&&!(128&(a=e[h+1]))&&!(128&(o=e[h+2]))&&!(128&(l=e[h+3]));)r[n++]=i,r[n++]=a,r[n++]=o,r[n++]=l,h+=4;if((i=e[h++])<128)r[n++]=i;else if((224&i)==192){if(h>=s)return this.interim[0]=i,n;if((192&(a=e[h++]))!=128||(c=(31&i)<<6|63&a)<128){h--;continue}r[n++]=c}else if((240&i)==224){if(h>=s)return this.interim[0]=i,n;if((192&(a=e[h++]))!=128){h--;continue}if(h>=s)return this.interim[0]=i,this.interim[1]=a,n;if((192&(o=e[h++]))!=128){h--;continue}if((c=(15&i)<<12|(63&a)<<6|63&o)<2048||c>=55296&&c<=57343||65279===c)continue;r[n++]=c}else if((248&i)==240){if(h>=s)return this.interim[0]=i,n;if((192&(a=e[h++]))!=128){h--;continue}if(h>=s)return this.interim[0]=i,this.interim[1]=a,n;if((192&(o=e[h++]))!=128){h--;continue}if(h>=s)return this.interim[0]=i,this.interim[1]=a,this.interim[2]=o,n;if((192&(l=e[h++]))!=128){h--;continue}if((c=(7&i)<<18|(63&a)<<12|(63&o)<<6|63&l)<65536||c>1114111)continue;r[n++]=c}}return n}},xZ=class e{constructor(){this.fg=0,this.bg=0,this.extended=new xQ}static toColorRGB(e){return[e>>>16&255,e>>>8&255,255&e]}static fromColorRGB(e){return(255&e[0])<<16|(255&e[1])<<8|255&e[2]}clone(){let r=new e;return r.fg=this.fg,r.bg=this.bg,r.extended=this.extended.clone(),r}isInverse(){return 0x4000000&this.fg}isBold(){return 0x8000000&this.fg}isUnderline(){return this.hasExtendedAttrs()&&0!==this.extended.underlineStyle?1:0x10000000&this.fg}isBlink(){return 0x20000000&this.fg}isInvisible(){return 0x40000000&this.fg}isItalic(){return 0x4000000&this.bg}isDim(){return 0x8000000&this.bg}isStrikethrough(){return 0x80000000&this.fg}isProtected(){return 0x20000000&this.bg}isOverline(){return 0x40000000&this.bg}getFgColorMode(){return 0x3000000&this.fg}getBgColorMode(){return 0x3000000&this.bg}isFgRGB(){return(0x3000000&this.fg)==0x3000000}isBgRGB(){return(0x3000000&this.bg)==0x3000000}isFgPalette(){return(0x3000000&this.fg)==0x1000000||(0x3000000&this.fg)==0x2000000}isBgPalette(){return(0x3000000&this.bg)==0x1000000||(0x3000000&this.bg)==0x2000000}isFgDefault(){return(0x3000000&this.fg)==0}isBgDefault(){return(0x3000000&this.bg)==0}isAttributeDefault(){return 0===this.fg&&0===this.bg}getFgColor(){switch(0x3000000&this.fg){case 0x1000000:case 0x2000000:return 255&this.fg;case 0x3000000:return 0xffffff&this.fg;default:return -1}}getBgColor(){switch(0x3000000&this.bg){case 0x1000000:case 0x2000000:return 255&this.bg;case 0x3000000:return 0xffffff&this.bg;default:return -1}}hasExtendedAttrs(){return 0x10000000&this.bg}updateExtended(){this.extended.isEmpty()?this.bg&=-0x10000001:this.bg|=0x10000000}getUnderlineColor(){if(0x10000000&this.bg&&~this.extended.underlineColor)switch(0x3000000&this.extended.underlineColor){case 0x1000000:case 0x2000000:return 255&this.extended.underlineColor;case 0x3000000:return 0xffffff&this.extended.underlineColor}return this.getFgColor()}getUnderlineColorMode(){return 0x10000000&this.bg&&~this.extended.underlineColor?0x3000000&this.extended.underlineColor:this.getFgColorMode()}isUnderlineColorRGB(){return 0x10000000&this.bg&&~this.extended.underlineColor?(0x3000000&this.extended.underlineColor)==0x3000000:this.isFgRGB()}isUnderlineColorPalette(){return 0x10000000&this.bg&&~this.extended.underlineColor?(0x3000000&this.extended.underlineColor)==0x1000000||(0x3000000&this.extended.underlineColor)==0x2000000:this.isFgPalette()}isUnderlineColorDefault(){return 0x10000000&this.bg&&~this.extended.underlineColor?(0x3000000&this.extended.underlineColor)==0:this.isFgDefault()}getUnderlineStyle(){return 0x10000000&this.fg?0x10000000&this.bg?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},xQ=class e{constructor(e=0,r=0){this._ext=0,this._urlId=0,this._ext=e,this._urlId=r}get ext(){return this._urlId?-0x1c000001&this._ext|this.underlineStyle<<26:this._ext}set ext(e){this._ext=e}get underlineStyle(){return this._urlId?5:(0x1c000000&this._ext)>>26}set underlineStyle(e){this._ext&=-0x1c000001,this._ext|=e<<26&0x1c000000}get underlineColor(){return 0x3ffffff&this._ext}set underlineColor(e){this._ext&=-0x4000000,this._ext|=0x3ffffff&e}get urlId(){return this._urlId}set urlId(e){this._urlId=e}get underlineVariantOffset(){let e=(0xe0000000&this._ext)>>29;return e<0?0xfffffff8^e:e}set underlineVariantOffset(e){this._ext&=0x1fffffff,this._ext|=e<<29&0xe0000000}clone(){return new e(this._ext,this._urlId)}isEmpty(){return 0===this.underlineStyle&&0===this._urlId}},x0=class e extends xZ{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new xQ,this.combinedData=""}static fromCharData(r){let s=new e;return s.setFromCharData(r),s}isCombined(){return 2097152&this.content}getWidth(){return this.content>>22}getChars(){return 2097152&this.content?this.combinedData:2097151&this.content?xX(2097151&this.content):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):2097151&this.content}setFromCharData(e){this.fg=e[0],this.bg=0;let r=!1;if(e[1].length>2)r=!0;else if(2===e[1].length){let s=e[1].charCodeAt(0);if(55296<=s&&s<=56319){let n=e[1].charCodeAt(1);56320<=n&&n<=57343?this.content=(s-55296)*1024+n-56320+65536|e[2]<<22:r=!0}else r=!0}else this.content=e[1].charCodeAt(0)|e[2]<<22;r&&(this.combinedData=e[1],this.content=2097152|e[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},x1="di$target",x2="di$dependencies",x5=new Map;function x3(e){if(x5.has(e))return x5.get(e);let r=function(e,s,n){var i,a,o;if(3!=arguments.length)throw Error("@IServiceName-decorator can only be used to decorate a parameter");i=r,a=e,o=n,a[x1]===a?a[x2].push({id:i,index:o}):(a[x2]=[{id:i,index:o}],a[x1]=a)};return r._id=e,x5.set(e,r),r}var x4=x3("BufferService"),x6=x3("CoreMouseService"),x7=x3("CoreService"),x8=x3("CharsetService"),x9=x3("InstantiationService"),ve=x3("LogService"),vt=x3("OptionsService"),vr=x3("OscLinkService"),vs=x3("UnicodeService"),vn=x3("DecorationService"),vi=class{constructor(e,r,s){this._bufferService=e,this._optionsService=r,this._oscLinkService=s}provideLinks(e,r){let s=this._bufferService.buffer.lines.get(e-1);if(!s)return void r(void 0);let n=[],i=this._optionsService.rawOptions.linkHandler,a=new x0,o=s.getTrimmedLength(),l=-1,c=-1,d=!1;for(let r=0;r<o;r++)if(!(-1===c&&!s.hasContent(r))){if(s.loadCell(r,a),a.hasExtendedAttrs()&&a.extended.urlId)if(-1===c){c=r,l=a.extended.urlId;continue}else d=a.extended.urlId!==l;else -1!==c&&(d=!0);if(d||-1!==c&&r===o-1){let s=this._oscLinkService.getLinkData(l)?.uri;if(s){let a={start:{x:c+1,y:e},end:{x:r+ +(!d&&r===o-1),y:e}},l=!1;if(!i?.allowNonHttpProtocols)try{let e=new URL(s);["http:","https:"].includes(e.protocol)||(l=!0)}catch{l=!0}l||n.push({text:s,range:a,activate:(e,r)=>i?i.activate(e,r,a):function(e,r){if(confirm(`Do you want to navigate to ${r}?
12
+
13
+ WARNING: This link could potentially be dangerous`)){let e=window.open();if(e){try{e.opener=null}catch{}e.location.href=r}else console.warn("Opening link blocked as opener could not be cleared")}}(0,r),hover:(e,r)=>i?.hover?.(e,r,a),leave:(e,r)=>i?.leave?.(e,r,a)})}d=!1,a.hasExtendedAttrs()&&a.extended.urlId?(c=r,l=a.extended.urlId):(c=-1,l=-1)}}r(n)}};vi=x$([xW(0,x4),xW(1,vt),xW(2,vr)],vi);var va=x3("CharSizeService"),vo=x3("CoreBrowserService"),vl=x3("MouseService"),vc=x3("RenderService"),vd=x3("SelectionService"),vu=x3("CharacterJoinerService"),vh=x3("ThemeService"),vf=x3("LinkProviderService"),vp=new class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?vv.isErrorNoTelemetry(e)?new vv(e.message+`
14
+
15
+ `+e.stack):Error(e.message+`
16
+
17
+ `+e.stack):e},0)}}addListener(e){return this.listeners.push(e),()=>{this._removeListener(e)}}emit(e){this.listeners.forEach(r=>{r(e)})}_removeListener(e){this.listeners.splice(this.listeners.indexOf(e),1)}setUnexpectedErrorHandler(e){this.unexpectedErrorHandler=e}getUnexpectedErrorHandler(){return this.unexpectedErrorHandler}onUnexpectedError(e){this.unexpectedErrorHandler(e),this.emit(e)}onUnexpectedExternalError(e){this.unexpectedErrorHandler(e)}};function vm(e){var r;(r=e)instanceof vx||r instanceof Error&&r.name===vg&&r.message===vg||vp.onUnexpectedError(e)}var vg="Canceled",vx=class extends Error{constructor(){super(vg),this.name=this.message}},vv=class e extends Error{constructor(e){super(e),this.name="CodeExpectedError"}static fromError(r){if(r instanceof e)return r;let s=new e;return s.message=r.message,s.stack=r.stack,s}static isErrorNoTelemetry(e){return"CodeExpectedError"===e.name}},vy=class e extends Error{constructor(r){super(r||"An unexpected bug occurred."),Object.setPrototypeOf(this,e.prototype)}};function vb(e,r=0){return e[e.length-(1+r)]}(vU=vK||={}).isLessThan=function(e){return e<0},vU.isLessThanOrEqual=function(e){return e<=0},vU.isGreaterThan=function(e){return e>0},vU.isNeitherLessOrGreaterThan=function(e){return 0===e},vU.greaterThan=1,vU.lessThan=-1,vU.neitherLessOrGreaterThan=0;var vw=class e{constructor(e){this.iterate=e}forEach(e){this.iterate(r=>(e(r),!0))}toArray(){let e=[];return this.iterate(r=>(e.push(r),!0)),e}filter(r){return new e(e=>this.iterate(s=>!r(s)||e(s)))}map(r){return new e(e=>this.iterate(s=>e(r(s))))}some(e){let r=!1;return this.iterate(s=>!(r=e(s))),r}findFirst(e){let r;return this.iterate(s=>!e(s)||(r=s,!1)),r}findLast(e){let r;return this.iterate(s=>(e(s)&&(r=s),!0)),r}findLastMaxBy(e){let r,s=!0;return this.iterate(n=>((s||vK.isGreaterThan(e(n,r)))&&(s=!1,r=n),!0)),r}};vw.empty=new vw(e=>{});function v_(e){}function vS(e,r){}function vk(e){if(vX.is(e)){let r=[];for(let s of e)if(s)try{s.dispose()}catch(e){r.push(e)}if(1===r.length)throw r[0];if(r.length>1)throw AggregateError(r,"Encountered errors while disposing of store");return Array.isArray(e)?[]:e}if(e)return e.dispose(),e}function vj(e){let r={dispose:function(e,r){let s=this,n=!1,i;return function(){if(n)return i;if(n=!0,r)try{i=e.apply(s,arguments)}finally{r()}else i=e.apply(s,arguments);return i}}(()=>{v_(r),e()})};return r}(e=>{function r(e){return e&&"object"==typeof e&&"function"==typeof e[Symbol.iterator]}e.is=r;let s=Object.freeze([]);function*n(e){yield e}e.empty=function(){return s},e.single=n,e.wrap=function(e){return r(e)?e:n(e)},e.from=function(e){return e||s},e.reverse=function*(e){for(let r=e.length-1;r>=0;r--)yield e[r]},e.isEmpty=function(e){return!e||!0===e[Symbol.iterator]().next().done},e.first=function(e){return e[Symbol.iterator]().next().value},e.some=function(e,r){let s=0;for(let n of e)if(r(n,s++))return!0;return!1},e.find=function(e,r){for(let s of e)if(r(s))return s},e.filter=function*(e,r){for(let s of e)r(s)&&(yield s)},e.map=function*(e,r){let s=0;for(let n of e)yield r(n,s++)},e.flatMap=function*(e,r){let s=0;for(let n of e)yield*r(n,s++)},e.concat=function*(...e){for(let r of e)yield*r},e.reduce=function(e,r,s){let n=s;for(let s of e)n=r(n,s);return n},e.slice=function*(e,r,s=e.length){for(r<0&&(r+=e.length),s<0?s+=e.length:s>e.length&&(s=e.length);r<s;r++)yield e[r]},e.consume=function(r,s=1/0){let n=[];if(0===s)return[n,r];let i=r[Symbol.iterator]();for(let r=0;r<s;r++){let r=i.next();if(r.done)return[n,e.empty()];n.push(r.value)}return[n,{[Symbol.iterator]:()=>i}]},e.asyncToArray=async function(e){let r=[];for await(let s of e)r.push(s);return Promise.resolve(r)}})(vX||={});var vC=class e{constructor(){var e;this._toDispose=new Set,this._isDisposed=!1,e=this}dispose(){this._isDisposed||(v_(this),this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(0!==this._toDispose.size)try{vk(this._toDispose)}finally{this._toDispose.clear()}}add(r){if(!r)return r;if(r===this)throw Error("Cannot register a disposable on itself!");return vS(r,this),this._isDisposed?e.DISABLE_DISPOSED_WARNING||console.warn(Error("Trying to add a disposable to a DisposableStore that has already been disposed of. The added object will be leaked!").stack):this._toDispose.add(r),r}delete(e){if(e){if(e===this)throw Error("Cannot dispose a disposable on itself!");this._toDispose.delete(e),e.dispose()}}deleteAndLeak(e){e&&this._toDispose.has(e)&&(this._toDispose.delete(e),vS(e,null))}};vC.DISABLE_DISPOSED_WARNING=!1;var vN=vC,vE=class{constructor(){var e;this._store=new vN,e=this,vS(this._store,this)}dispose(){v_(this),this._store.dispose()}_register(e){if(e===this)throw Error("Cannot register a disposable on itself!");return this._store.add(e)}};vE.None=Object.freeze({dispose(){}});var vD=class{constructor(){var e;this._isDisposed=!1,e=this}get value(){return this._isDisposed?void 0:this._value}set value(e){this._isDisposed||e===this._value||(this._value?.dispose(),e&&vS(e,this),this._value=e)}clear(){this.value=void 0}dispose(){this._isDisposed=!0,v_(this),this._value?.dispose(),this._value=void 0}clearAndLeak(){let e=this._value;return this._value=void 0,e&&vS(e,null),e}},vT="object"==typeof window?window:globalThis,vR=class e{constructor(r){this.element=r,this.next=e.Undefined,this.prev=e.Undefined}};vR.Undefined=new vR(void 0);var vA=class{constructor(){this._first=vR.Undefined,this._last=vR.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===vR.Undefined}clear(){let e=this._first;for(;e!==vR.Undefined;){let r=e.next;e.prev=vR.Undefined,e.next=vR.Undefined,e=r}this._first=vR.Undefined,this._last=vR.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,r){let s=new vR(e);if(this._first===vR.Undefined)this._first=s,this._last=s;else if(r){let e=this._last;this._last=s,s.prev=e,e.next=s}else{let e=this._first;this._first=s,s.next=e,e.prev=s}this._size+=1;let n=!1;return()=>{n||(n=!0,this._remove(s))}}shift(){if(this._first!==vR.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==vR.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==vR.Undefined&&e.next!==vR.Undefined){let r=e.prev;r.next=e.next,e.next.prev=r}else e.prev===vR.Undefined&&e.next===vR.Undefined?(this._first=vR.Undefined,this._last=vR.Undefined):e.next===vR.Undefined?(this._last=this._last.prev,this._last.next=vR.Undefined):e.prev===vR.Undefined&&(this._first=this._first.next,this._first.prev=vR.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==vR.Undefined;)yield e.element,e=e.next}},vM=globalThis.performance&&"function"==typeof globalThis.performance.now,vI=class e{static create(r){return new e(r)}constructor(e){this._now=vM&&!1===e?Date.now:globalThis.performance.now.bind(globalThis.performance),this._startTime=this._now(),this._stopTime=-1}stop(){this._stopTime=this._now()}reset(){this._startTime=this._now(),this._stopTime=-1}elapsed(){return -1!==this._stopTime?this._stopTime-this._startTime:this._now()-this._startTime}};(e=>{function r(e){}function s(e){return(r,s=null,n)=>{let i=!1,a;return a=e(e=>{if(!i)return a?a.dispose():i=!0,r.call(s,e)},null,n),i&&a.dispose(),a}}function n(e,r,s){return a((s,n=null,i)=>e(e=>s.call(n,r(e)),null,i),s)}function i(e,r,s){return a((s,n=null,i)=>e(e=>r(e)&&s.call(n,e),null,i),s)}function a(e,s){let n,i={onWillAddFirstListener(){n=e(a.fire,a)},onDidRemoveLastListener(){n?.dispose()}};s||r(i);let a=new v2(i);return s?.add(a),a.event}function o(e,s,n=100,i=!1,a=!1,l,c){let d,u,h,f=0,p,m={leakWarningThreshold:l,onWillAddFirstListener(){d=e(e=>{f++,u=s(u,e),i&&!h&&(g.fire(u),u=void 0),p=()=>{let e=u;u=void 0,h=void 0,(!i||f>1)&&g.fire(e),f=0},"number"==typeof n?(clearTimeout(h),h=setTimeout(p,n)):void 0===h&&(h=0,queueMicrotask(p))})},onWillRemoveListener(){a&&f>0&&p?.()},onDidRemoveLastListener(){p=void 0,d.dispose()}};c||r(m);let g=new v2(m);return c?.add(g),g.event}e.None=()=>vE.None,e.defer=function(e,r){return o(e,()=>{},0,void 0,!0,void 0,r)},e.once=s,e.map=n,e.forEach=function(e,r,s){return a((s,n=null,i)=>e(e=>{r(e),s.call(n,e)},null,i),s)},e.filter=i,e.signal=function(e){return e},e.any=function(...e){return(r,s=null,n)=>{var i,a;return i=function(...e){var r,s;let n=vj(()=>vk(e));return r=0,s=0,n}(...e.map(e=>e(e=>r.call(s,e)))),(a=n)instanceof Array?a.push(i):a&&a.add(i),i}},e.reduce=function(e,r,s,i){let a=s;return n(e,e=>a=r(a,e),i)},e.debounce=o,e.accumulate=function(r,s=0,n){return e.debounce(r,(e,r)=>e?(e.push(r),e):[r],s,void 0,!0,void 0,n)},e.latch=function(e,r=(e,r)=>e===r,s){let n=!0,a;return i(e,e=>{let s=n||!r(e,a);return n=!1,a=e,s},s)},e.split=function(r,s,n){return[e.filter(r,s,n),e.filter(r,e=>!s(e),n)]},e.buffer=function(e,r=!1,s=[],n){let i=s.slice(),a=e(e=>{i?i.push(e):l.fire(e)});n&&n.add(a);let o=()=>{i?.forEach(e=>l.fire(e)),i=null},l=new v2({onWillAddFirstListener(){a||(a=e(e=>l.fire(e)),n&&n.add(a))},onDidAddFirstListener(){i&&(r?setTimeout(o):o())},onDidRemoveLastListener(){a&&a.dispose(),a=null}});return n&&n.add(l),l.event},e.chain=function(e,r){return(s,n,i)=>{let a=r(new c);return e(function(e){let r=a.evaluate(e);r!==l&&s.call(n,r)},void 0,i)}};let l=Symbol("HaltChainable");class c{constructor(){this.steps=[]}map(e){return this.steps.push(e),this}forEach(e){return this.steps.push(r=>(e(r),r)),this}filter(e){return this.steps.push(r=>e(r)?r:l),this}reduce(e,r){let s=r;return this.steps.push(r=>s=e(s,r)),this}latch(e=(e,r)=>e===r){let r=!0,s;return this.steps.push(n=>{let i=r||!e(n,s);return r=!1,s=n,i?n:l}),this}evaluate(e){for(let r of this.steps)if((e=r(e))===l)break;return e}}e.fromNodeEventEmitter=function(e,r,s=e=>e){let n=(...e)=>i.fire(s(...e)),i=new v2({onWillAddFirstListener:()=>e.on(r,n),onDidRemoveLastListener:()=>e.removeListener(r,n)});return i.event},e.fromDOMEventEmitter=function(e,r,s=e=>e){let n=(...e)=>i.fire(s(...e)),i=new v2({onWillAddFirstListener:()=>e.addEventListener(r,n),onDidRemoveLastListener:()=>e.removeEventListener(r,n)});return i.event},e.toPromise=function(e){return new Promise(r=>s(e)(r))},e.fromPromise=function(e){let r=new v2;return e.then(e=>{r.fire(e)},()=>{r.fire(void 0)}).finally(()=>{r.dispose()}),r.event},e.forward=function(e,r){return e(e=>r.fire(e))},e.runAndSubscribe=function(e,r,s){return r(s),e(e=>r(e))};class d{constructor(e,s){this._observable=e,this._counter=0,this._hasChanged=!1;let n={onWillAddFirstListener:()=>{e.addObserver(this)},onDidRemoveLastListener:()=>{e.removeObserver(this)}};s||r(n),this.emitter=new v2(n),s&&s.add(this.emitter)}beginUpdate(e){this._counter++}handlePossibleChange(e){}handleChange(e,r){this._hasChanged=!0}endUpdate(e){this._counter--,0===this._counter&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}e.fromObservable=function(e,r){return new d(e,r).emitter.event},e.fromObservableLight=function(e){return(r,s,n)=>{let i=0,a=!1,o={beginUpdate(){i++},endUpdate(){0==--i&&(e.reportChanges(),a&&(a=!1,r.call(s)))},handlePossibleChange(){},handleChange(){a=!0}};e.addObserver(o),e.reportChanges();let l={dispose(){e.removeObserver(o)}};return n instanceof vN?n.add(l):Array.isArray(n)&&n.push(l),l}}})(vY||={});var vP=class e{constructor(r){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${r}_${e._idPool++}`,e.all.add(this)}start(e){this._stopWatch=new vI,this.listenerCount=e}stop(){if(this._stopWatch){let e=this._stopWatch.elapsed();this.durations.push(e),this.elapsedOverall+=e,this.invocationCount+=1,this._stopWatch=void 0}}};vP.all=new Set,vP._idPool=0;var vF=class e{constructor(r,s,n=(e._idPool++).toString(16).padStart(3,"0")){this._errorHandler=r,this.threshold=s,this.name=n,this._warnCountdown=0}dispose(){this._stacks?.clear()}check(e,r){let s=this.threshold;if(s<=0||r<s)return;this._stacks||(this._stacks=new Map);let n=this._stacks.get(e.value)||0;if(this._stacks.set(e.value,n+1),this._warnCountdown-=1,this._warnCountdown<=0){this._warnCountdown=.5*s;let[e,n]=this.getMostFrequentStack(),i=`[${this.name}] potential listener LEAK detected, having ${r} listeners already. MOST frequent listener (${n}):`;console.warn(i),console.warn(e);let a=new vZ(i,e);this._errorHandler(a)}return()=>{let r=this._stacks.get(e.value)||0;this._stacks.set(e.value,r-1)}}getMostFrequentStack(){if(!this._stacks)return;let e,r=0;for(let[s,n]of this._stacks)(!e||r<n)&&(e=[s,n],r=n);return e}};vF._idPool=1;var vL,vO,vB,vz,v$,vW,vH,vU,vV,vq,vK,vX,vY,vG,vJ=class e{constructor(e){this.value=e}static create(){return new e(Error().stack??"")}print(){console.warn(this.value.split(`
18
+ `).slice(2).join(`
19
+ `))}},vZ=class extends Error{constructor(e,r){super(e),this.name="ListenerLeakError",this.stack=r}},vQ=class extends Error{constructor(e,r){super(e),this.name="ListenerRefusalError",this.stack=r}},v0=0,v1=class{constructor(e){this.value=e,this.id=v0++}},v2=class{constructor(e){this._size=0,this._options=e,this._leakageMon=this._options?.leakWarningThreshold?new vF(e?.onListenerError??vm,this._options?.leakWarningThreshold??-1):void 0,this._perfMon=this._options?._profName?new vP(this._options._profName):void 0,this._deliveryQueue=this._options?.deliveryQueue}dispose(){this._disposed||(this._disposed=!0,this._deliveryQueue?.current===this&&this._deliveryQueue.reset(),this._listeners&&(this._listeners=void 0,this._size=0),this._options?.onDidRemoveLastListener?.(),this._leakageMon?.dispose())}get event(){return this._event??=(e,r,s)=>{if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let e=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(e);let r=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],s=new vQ(`${e}. HINT: Stack shows most frequent listener (${r[1]}-times)`,r[0]);return(this._options?.onListenerError||vm)(s),vE.None}if(this._disposed)return vE.None;r&&(e=e.bind(r));let n=new v1(e),i;this._leakageMon&&this._size>=Math.ceil(.2*this._leakageMon.threshold)&&(n.stack=vJ.create(),i=this._leakageMon.check(n.stack,this._size+1)),this._listeners?this._listeners instanceof v1?(this._deliveryQueue??=new v5,this._listeners=[this._listeners,n]):this._listeners.push(n):(this._options?.onWillAddFirstListener?.(this),this._listeners=n,this._options?.onDidAddFirstListener?.(this)),this._size++;let a=vj(()=>{vG?.unregister(a),i?.(),this._removeListener(n)});if(s instanceof vN?s.add(a):Array.isArray(s)&&s.push(a),vG){let e=Error().stack.split(`
20
+ `).slice(2,3).join(`
21
+ `).trim(),r=/(file:|vscode-file:\/\/vscode-app)?(\/[^:]*:\d+:\d+)/.exec(e);vG.register(a,r?.[2]??e,a)}return a},this._event}_removeListener(e){if(this._options?.onWillRemoveListener?.(this),!this._listeners)return;if(1===this._size){this._listeners=void 0,this._options?.onDidRemoveLastListener?.(this),this._size=0;return}let r=this._listeners,s=r.indexOf(e);if(-1===s)throw console.log("disposed?",this._disposed),console.log("size?",this._size),console.log("arr?",JSON.stringify(this._listeners)),Error("Attempted to dispose unknown listener");this._size--,r[s]=void 0;let n=this._deliveryQueue.current===this;if(2*this._size<=r.length){let e=0;for(let s=0;s<r.length;s++)r[s]?r[e++]=r[s]:n&&(this._deliveryQueue.end--,e<this._deliveryQueue.i&&this._deliveryQueue.i--);r.length=e}}_deliver(e,r){if(!e)return;let s=this._options?.onListenerError||vm;try{e.value(r)}catch(e){s(e)}}_deliverQueue(e){let r=e.current._listeners;for(;e.i<e.end;)this._deliver(r[e.i++],e.value);e.reset()}fire(e){if(this._deliveryQueue?.current&&(this._deliverQueue(this._deliveryQueue),this._perfMon?.stop()),this._perfMon?.start(this._size),this._listeners)if(this._listeners instanceof v1)this._deliver(this._listeners,e);else{let r=this._deliveryQueue;r.enqueue(this,e,this._listeners.length),this._deliverQueue(r)}this._perfMon?.stop()}hasListeners(){return this._size>0}},v5=class{constructor(){this.i=-1,this.end=0}enqueue(e,r,s){this.i=0,this.end=s,this.current=e,this.value=r}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},v3=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new v2,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new v2,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(e){return this.mapWindowIdToZoomLevel.get(this.getWindowId(e))??0}setZoomLevel(e,r){if(this.getZoomLevel(r)===e)return;let s=this.getWindowId(r);this.mapWindowIdToZoomLevel.set(s,e),this._onDidChangeZoomLevel.fire(s)}getZoomFactor(e){return this.mapWindowIdToZoomFactor.get(this.getWindowId(e))??1}setZoomFactor(e,r){this.mapWindowIdToZoomFactor.set(this.getWindowId(r),e)}setFullscreen(e,r){if(this.isFullscreen(r)===e)return;let s=this.getWindowId(r);this.mapWindowIdToFullScreen.set(s,e),this._onDidChangeFullscreen.fire(s)}isFullscreen(e){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(e))}getWindowId(e){return e.vscodeWindowId}};v3.INSTANCE=new v3,v3.INSTANCE.onDidChangeZoomLevel,v3.INSTANCE.onDidChangeFullscreen;var v4="object"==typeof navigator?navigator.userAgent:"",v6=v4.indexOf("Firefox")>=0,v7=v4.indexOf("AppleWebKit")>=0,v8=v4.indexOf("Chrome")>=0,v9=!v8&&v4.indexOf("Safari")>=0;v4.indexOf("Electron/"),v4.indexOf("Android");var ye=!1;if("function"==typeof vT.matchMedia){let e=vT.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),r=vT.matchMedia("(display-mode: fullscreen)");ye=e.matches,yt=e,"string"==typeof yt&&(yt=vT.matchMedia(yt)),yt.addEventListener("change",({matches:e})=>{ye&&r.matches||(ye=e)})}var yt,yr,ys,yn=!1,yi=!1,ya=!1,yo=!1,yl=!1,yc="en",yd=globalThis;"u">typeof yd.vscode&&"u">typeof yd.vscode.process?ys=yd.vscode.process:"u">typeof xO.default&&"string"==typeof xO.default?.versions?.node&&(ys=xO.default);var yu="string"==typeof ys?.versions?.electron&&ys?.type==="renderer";if("object"==typeof ys){yn="win32"===ys.platform,yi="darwin"===ys.platform,(ya="linux"===ys.platform)&&ys.env.SNAP&&ys.env.SNAP_REVISION,ys.env.CI||ys.env.BUILD_ARTIFACTSTAGINGDIRECTORY,yc="en";let e=ys.env.VSCODE_NLS_CONFIG;if(e)try{let r=JSON.parse(e);r.userLocale,r.osLocale,yc=r.resolvedLanguage||"en",r.languagePack?.translationsConfigFile}catch{}yo=!0}else"object"!=typeof navigator||yu?console.error("Unable to resolve platform."):(yn=(yr=navigator.userAgent).indexOf("Windows")>=0,yi=yr.indexOf("Macintosh")>=0,(yr.indexOf("Macintosh")>=0||yr.indexOf("iPad")>=0||yr.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints,ya=yr.indexOf("Linux")>=0,yr?.indexOf("Mobi"),yl=!0,yc=globalThis._VSCODE_NLS_LANGUAGE||"en",navigator.language.toLowerCase());var yh=yn,yf=yi,yp=ya,ym=yo;yl&&"function"==typeof yd.importScripts&&yd.origin;var yg,yx=yr,yv=yc;(yE=yg||={}).value=function(){return yv},yE.isDefaultVariant=function(){return 2===yv.length?"en"===yv:yv.length>=3&&"e"===yv[0]&&"n"===yv[1]&&"-"===yv[2]},yE.isDefault=function(){return"en"===yv};var yy="function"==typeof yd.postMessage&&!yd.importScripts,yb=(()=>{if(yy){let e=[];yd.addEventListener("message",r=>{if(r.data&&r.data.vscodeScheduleAsyncWork)for(let s=0,n=e.length;s<n;s++){let n=e[s];if(n.id===r.data.vscodeScheduleAsyncWork){e.splice(s,1),n.callback();return}}});let r=0;return s=>{let n=++r;e.push({id:n,callback:s}),yd.postMessage({vscodeScheduleAsyncWork:n},"*")}}return e=>setTimeout(e)})(),yw=!!(yx&&yx.indexOf("Chrome")>=0);yx&&yx.indexOf("Firefox"),!yw&&yx&&yx.indexOf("Safari"),yx&&yx.indexOf("Edg/"),yx&&yx.indexOf("Android");var y_="object"==typeof navigator?navigator:{};ym||document.queryCommandSupported&&document.queryCommandSupported("copy")||y_&&y_.clipboard&&y_.clipboard.writeText,ym||y_&&y_.clipboard&&y_.clipboard.readText,ym||ye||y_.keyboard,"ontouchstart"in vT||y_.maxTouchPoints,vT.PointerEvent&&("ontouchstart"in vT||navigator.maxTouchPoints);var yS=class{constructor(){this._keyCodeToStr=[],this._strToKeyCode=Object.create(null)}define(e,r){this._keyCodeToStr[e]=r,this._strToKeyCode[r.toLowerCase()]=e}keyCodeToStr(e){return this._keyCodeToStr[e]}strToKeyCode(e){return this._strToKeyCode[e.toLowerCase()]||0}},yk=new yS,yj=new yS,yC=new yS,yN=Array(230);(yD=yT||={}).toString=function(e){return yk.keyCodeToStr(e)},yD.fromString=function(e){return yk.strToKeyCode(e)},yD.toUserSettingsUS=function(e){return yj.keyCodeToStr(e)},yD.toUserSettingsGeneral=function(e){return yC.keyCodeToStr(e)},yD.fromUserSettings=function(e){return yj.strToKeyCode(e)||yC.strToKeyCode(e)},yD.toElectronAccelerator=function(e){if(e>=98&&e<=113)return null;switch(e){case 16:return"Up";case 18:return"Down";case 15:return"Left";case 17:return"Right"}return yk.keyCodeToStr(e)};var yE,yD,yT,yR,yA=class e{constructor(e,r,s,n,i){this.ctrlKey=e,this.shiftKey=r,this.altKey=s,this.metaKey=n,this.keyCode=i}equals(r){return r instanceof e&&this.ctrlKey===r.ctrlKey&&this.shiftKey===r.shiftKey&&this.altKey===r.altKey&&this.metaKey===r.metaKey&&this.keyCode===r.keyCode}getHashCode(){let e=this.ctrlKey?"1":"0",r=this.shiftKey?"1":"0",s=this.altKey?"1":"0",n=this.metaKey?"1":"0";return`K${e}${r}${s}${n}${this.keyCode}`}isModifierKey(){return 0===this.keyCode||5===this.keyCode||57===this.keyCode||6===this.keyCode||4===this.keyCode}toKeybinding(){return new yM([this])}isDuplicateModifierCase(){return this.ctrlKey&&5===this.keyCode||this.shiftKey&&4===this.keyCode||this.altKey&&6===this.keyCode||this.metaKey&&57===this.keyCode}},yM=class{constructor(e){if(0===e.length)throw function(e){return e?Error(`Illegal argument: ${e}`):Error("Illegal argument")}("chords");this.chords=e}getHashCode(){let e="";for(let r=0,s=this.chords.length;r<s;r++)0!==r&&(e+=";"),e+=this.chords[r].getHashCode();return e}equals(e){if(null===e||this.chords.length!==e.chords.length)return!1;for(let r=0;r<this.chords.length;r++)if(!this.chords[r].equals(e.chords[r]))return!1;return!0}},yI=yf?256:2048,yP=yf?2048:256,yF=class{constructor(e){this._standardKeyboardEventBrand=!0,this.browserEvent=e,this.target=e.target,this.ctrlKey=e.ctrlKey,this.shiftKey=e.shiftKey,this.altKey=e.altKey,this.metaKey=e.metaKey,this.altGraphKey=e.getModifierState?.("AltGraph"),this.keyCode=function(e){if(e.charCode){let r=String.fromCharCode(e.charCode).toUpperCase();return yT.fromString(r)}let r=e.keyCode;if(3===r)return 7;if(v6)switch(r){case 59:return 85;case 60:if(yp)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(yf)return 57}else if(v7&&(yf&&93===r||!yf&&92===r))return 57;return yN[r]||0}(e),this.code=e.code,this.ctrlKey=this.ctrlKey||5===this.keyCode,this.altKey=this.altKey||6===this.keyCode,this.shiftKey=this.shiftKey||4===this.keyCode,this.metaKey=this.metaKey||57===this.keyCode,this._asKeybinding=this._computeKeybinding(),this._asKeyCodeChord=this._computeKeyCodeChord()}preventDefault(){this.browserEvent&&this.browserEvent.preventDefault&&this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent&&this.browserEvent.stopPropagation&&this.browserEvent.stopPropagation()}toKeyCodeChord(){return this._asKeyCodeChord}equals(e){return this._asKeybinding===e}_computeKeybinding(){let e=0;5!==this.keyCode&&4!==this.keyCode&&6!==this.keyCode&&57!==this.keyCode&&(e=this.keyCode);let r=0;return this.ctrlKey&&(r|=yI),this.altKey&&(r|=512),this.shiftKey&&(r|=1024),this.metaKey&&(r|=yP),r|=e}_computeKeyCodeChord(){let e=0;return 5!==this.keyCode&&4!==this.keyCode&&6!==this.keyCode&&57!==this.keyCode&&(e=this.keyCode),new yA(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,e)}},yL=new WeakMap,yO=class{static getSameOriginWindowChain(e){let r=yL.get(e);if(!r){r=[],yL.set(e,r);let s=e,n;do(n=function(e){if(!e.parent||e.parent===e)return null;try{let r=e.location,s=e.parent.location;if("null"!==r.origin&&"null"!==s.origin&&r.origin!==s.origin)return null}catch{return null}return e.parent}(s))?r.push({window:new WeakRef(s),iframeElement:s.frameElement||null}):r.push({window:new WeakRef(s),iframeElement:null}),s=n;while(s)}return r.slice(0)}static getPositionOfChildWindowRelativeToAncestorWindow(e,r){if(!r||e===r)return{top:0,left:0};let s=0,n=0;for(let i of this.getSameOriginWindowChain(e)){let e=i.window.deref();if(s+=e?.scrollY??0,n+=e?.scrollX??0,e===r||!i.iframeElement)break;let a=i.iframeElement.getBoundingClientRect();s+=a.top,n+=a.left}return{top:s,left:n}}},yB=class{constructor(e,r){this.timestamp=Date.now(),this.browserEvent=r,this.leftButton=0===r.button,this.middleButton=1===r.button,this.rightButton=2===r.button,this.buttons=r.buttons,this.target=r.target,this.detail=r.detail||1,"dblclick"===r.type&&(this.detail=2),this.ctrlKey=r.ctrlKey,this.shiftKey=r.shiftKey,this.altKey=r.altKey,this.metaKey=r.metaKey,"number"==typeof r.pageX?(this.posx=r.pageX,this.posy=r.pageY):(this.posx=r.clientX+this.target.ownerDocument.body.scrollLeft+this.target.ownerDocument.documentElement.scrollLeft,this.posy=r.clientY+this.target.ownerDocument.body.scrollTop+this.target.ownerDocument.documentElement.scrollTop);let s=yO.getPositionOfChildWindowRelativeToAncestorWindow(e,r.view);this.posx-=s.left,this.posy-=s.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},yz=class{constructor(e,r=0,s=0){this.browserEvent=e||null,this.target=e?e.target||e.targetNode||e.srcElement:null,this.deltaY=s,this.deltaX=r;let n=!1;if(v8){let e=navigator.userAgent.match(/Chrome\/(\d+)/);n=(e?parseInt(e[1]):123)<=122}if(e){let r=e.view?.devicePixelRatio||1;"u">typeof e.wheelDeltaY?n?this.deltaY=e.wheelDeltaY/(120*r):this.deltaY=e.wheelDeltaY/120:"u">typeof e.VERTICAL_AXIS&&e.axis===e.VERTICAL_AXIS?this.deltaY=-e.detail/3:"wheel"===e.type&&(e.deltaMode===e.DOM_DELTA_LINE?v6&&!yf?this.deltaY=-e.deltaY/3:this.deltaY=-e.deltaY:this.deltaY=-e.deltaY/40),"u">typeof e.wheelDeltaX?v9&&yh?this.deltaX=-(e.wheelDeltaX/120):n?this.deltaX=e.wheelDeltaX/(120*r):this.deltaX=e.wheelDeltaX/120:"u">typeof e.HORIZONTAL_AXIS&&e.axis===e.HORIZONTAL_AXIS?this.deltaX=-e.detail/3:"wheel"===e.type&&(e.deltaMode===e.DOM_DELTA_LINE?v6&&!yf?this.deltaX=-e.deltaX/3:this.deltaX=-e.deltaX:this.deltaX=-e.deltaX/40),0===this.deltaY&&0===this.deltaX&&e.wheelDelta&&(n?this.deltaY=e.wheelDelta/(120*r):this.deltaY=e.wheelDelta/120)}}preventDefault(){this.browserEvent?.preventDefault()}stopPropagation(){this.browserEvent?.stopPropagation()}},y$=Object.freeze(function(e,r){let s=setTimeout(e.bind(r),0);return{dispose(){clearTimeout(s)}}});(bR=yR||={}).isCancellationToken=function(e){return e===bR.None||e===bR.Cancelled||e instanceof yW||!!e&&"object"==typeof e&&"boolean"==typeof e.isCancellationRequested&&"function"==typeof e.onCancellationRequested},bR.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:vY.None}),bR.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:y$});var yW=class{constructor(){this._isCancelled=!1,this._emitter=null}cancel(){this._isCancelled||(this._isCancelled=!0,this._emitter&&(this._emitter.fire(void 0),this.dispose()))}get isCancellationRequested(){return this._isCancelled}get onCancellationRequested(){return this._isCancelled?y$:(this._emitter||(this._emitter=new v2),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}};Symbol("MicrotaskDelay");var yH=class{constructor(e,r){this._isDisposed=!1,this._token=-1,"function"==typeof e&&"number"==typeof r&&this.setIfNotSet(e,r)}dispose(){this.cancel(),this._isDisposed=!0}cancel(){-1!==this._token&&(clearTimeout(this._token),this._token=-1)}cancelAndSet(e,r){if(this._isDisposed)throw new vy("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},r)}setIfNotSet(e,r){if(this._isDisposed)throw new vy("Calling 'setIfNotSet' on a disposed TimeoutTimer");-1===this._token&&(this._token=setTimeout(()=>{this._token=-1,e()},r))}},yU=class{constructor(){this.disposable=void 0,this.isDisposed=!1}cancel(){this.disposable?.dispose(),this.disposable=void 0}cancelAndSet(e,r,s=globalThis){if(this.isDisposed)throw new vy("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let n=s.setInterval(()=>{e()},r);this.disposable=vj(()=>{s.clearInterval(n),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}};(bA=bM||={}).settled=async function(e){let r,s=await Promise.all(e.map(e=>e.then(e=>e,e=>{r||(r=e)})));if("u">typeof r)throw r;return s},bA.withAsyncBody=function(e){return new Promise(async(r,s)=>{try{await e(r,s)}catch(e){s(e)}})};var yV=class e{static fromArray(r){return new e(e=>{e.emitMany(r)})}static fromPromise(r){return new e(async e=>{e.emitMany(await r)})}static fromPromises(r){return new e(async e=>{await Promise.all(r.map(async r=>e.emitOne(await r)))})}static merge(r){return new e(async e=>{await Promise.all(r.map(async r=>{for await(let s of r)e.emitOne(s)}))})}constructor(e,r){this._state=0,this._results=[],this._error=null,this._onReturn=r,this._onStateChanged=new v2,queueMicrotask(async()=>{let r={emitOne:e=>this.emitOne(e),emitMany:e=>this.emitMany(e),reject:e=>this.reject(e)};try{await Promise.resolve(e(r)),this.resolve()}catch(e){this.reject(e)}finally{r.emitOne=void 0,r.emitMany=void 0,r.reject=void 0}})}[Symbol.asyncIterator](){let e=0;return{next:async()=>{for(;;){if(2===this._state)throw this._error;if(e<this._results.length)return{done:!1,value:this._results[e++]};if(1===this._state)return{done:!0,value:void 0};await vY.toPromise(this._onStateChanged.event)}},return:async()=>(this._onReturn?.(),{done:!0,value:void 0})}}static map(r,s){return new e(async e=>{for await(let n of r)e.emitOne(s(n))})}map(r){return e.map(this,r)}static filter(r,s){return new e(async e=>{for await(let n of r)s(n)&&e.emitOne(n)})}filter(r){return e.filter(this,r)}static coalesce(r){return e.filter(r,e=>!!e)}coalesce(){return e.coalesce(this)}static async toPromise(e){let r=[];for await(let s of e)r.push(s);return r}toPromise(){return e.toPromise(this)}emitOne(e){0===this._state&&(this._results.push(e),this._onStateChanged.fire())}emitMany(e){0===this._state&&(this._results=this._results.concat(e),this._onStateChanged.fire())}resolve(){0===this._state&&(this._state=1,this._onStateChanged.fire())}reject(e){0===this._state&&(this._state=2,this._error=e,this._onStateChanged.fire())}};yV.EMPTY=yV.fromArray([]);function yq(e,r){return(r<<5)-r+e|0}function yK(e,r){r=yq(149417,r);for(let s=0,n=e.length;s<n;s++)r=yq(e.charCodeAt(s),r);return r}new DataView(new ArrayBuffer(320));var{registerWindow:yX,getWindow:yY,getDocument:yG,getWindows:yJ,getWindowsCount:yZ,getWindowId:yQ,getWindowById:y0,hasWindow:y1,onDidRegisterWindow:y2,onWillUnregisterWindow:y5,onDidUnregisterWindow:y3}=(a=new Map,o={window:vT,disposables:new vN},a.set(vT.vscodeWindowId,o),l=new v2,c=new v2,d=new v2,{onDidRegisterWindow:l.event,onWillUnregisterWindow:d.event,onDidUnregisterWindow:c.event,registerWindow(e){if(a.has(e.vscodeWindowId))return vE.None;let r=new vN,s={window:e,disposables:r.add(new vN)};return a.set(e.vscodeWindowId,s),r.add(vj(()=>{a.delete(e.vscodeWindowId),c.fire(e)})),r.add(y6(e,bt.BEFORE_UNLOAD,()=>{d.fire(e)})),l.fire(s),r},getWindows:()=>a.values(),getWindowsCount:()=>a.size,getWindowId:e=>e.vscodeWindowId,hasWindow:e=>a.has(e),getWindowById:function(e,r){return("number"==typeof e?a.get(e):void 0)??(r?o:void 0)},getWindow:e=>e?.ownerDocument?.defaultView?e.ownerDocument.defaultView.window:e?.view?e.view.window:vT,getDocument:e=>yY(e).document}),y4=class{constructor(e,r,s,n){this._node=e,this._type=r,this._handler=s,this._options=n||!1,this._node.addEventListener(this._type,this._handler,this._options)}dispose(){this._handler&&(this._node.removeEventListener(this._type,this._handler,this._options),this._node=null,this._handler=null)}};function y6(e,r,s,n){return new y4(e,r,s,n)}var y7=function(e,r,s,n){var i;let a=s;return"click"===r||"mousedown"===r||"contextmenu"===r?(i=yY(e),a=function(e){return s(new yB(i,e))}):("keydown"===r||"keypress"===r||"keyup"===r)&&(a=function(e){return s(new yF(e))}),y6(e,r,a,n)},y8=class extends yU{constructor(e){super(),this.defaultTarget=e&&yY(e)}cancelAndSet(e,r,s){return super.cancelAndSet(e,r,s??this.defaultTarget)}},y9=class{constructor(e,r=0){this._runner=e,this.priority=r,this._canceled=!1}dispose(){this._canceled=!0}execute(){if(!this._canceled)try{this._runner()}catch(e){vm(e)}}static sort(e,r){return r.priority-e.priority}};u=new Map,h=new Map,f=new Map,p=new Map,bI=(e,r,s=0)=>{let n=yQ(e),i=new y9(r,s),a=u.get(n);return a||(a=[],u.set(n,a)),a.push(i),f.get(n)||(f.set(n,!0),e.requestAnimationFrame(()=>(e=>{f.set(e,!1);let r=u.get(e)??[];for(h.set(e,r),u.set(e,[]),p.set(e,!0);r.length>0;)r.sort(y9.sort),r.shift().execute();p.set(e,!1)})(n))),i};var be=class e{constructor(e,r){this.width=e,this.height=r}with(r=this.width,s=this.height){return r!==this.width||s!==this.height?new e(r,s):this}static is(e){return"object"==typeof e&&"number"==typeof e.height&&"number"==typeof e.width}static lift(r){return r instanceof e?r:new e(r.width,r.height)}static equals(e,r){return e===r||!!e&&!!r&&e.width===r.width&&e.height===r.height}};be.None=new be(0,0),new class{constructor(){this.mutationObservers=new Map}observe(e,r,s){let n=this.mutationObservers.get(e);n||(n=new Map,this.mutationObservers.set(e,n));let i=function e(r,s){switch(typeof r){case"object":var n,i,a,o;return null===r?yq(349,s):Array.isArray(r)?(n=r,i=yq(104579,i=s),n.reduce((r,s)=>e(s,r),i)):(a=r,o=yq(181387,o=s),Object.keys(a).sort().reduce((r,s)=>(r=yK(s,r),e(a[s],r)),o));case"string":return yK(r,s);case"boolean":return yq(r?433:863,s);case"number":return yq(r,s);case"undefined":return yq(937,s);default:return yq(617,s)}}(s,0),a=n.get(i);if(a)a.users+=1;else{let o=new v2,l=new MutationObserver(e=>o.fire(e));l.observe(e,s);let c=a={users:1,observer:l,onDidMutate:o.event};r.add(vj(()=>{c.users-=1,0===c.users&&(o.dispose(),l.disconnect(),n?.delete(i),n?.size===0&&this.mutationObservers.delete(e))})),n.set(i,a)}return a.onDidMutate}};var bt={CLICK:"click",MOUSE_DOWN:"mousedown",MOUSE_OVER:"mouseover",MOUSE_LEAVE:"mouseleave",MOUSE_WHEEL:"wheel",POINTER_UP:"pointerup",POINTER_DOWN:"pointerdown",POINTER_MOVE:"pointermove",KEY_DOWN:"keydown",KEY_UP:"keyup",BEFORE_UNLOAD:"beforeunload",CHANGE:"change",FOCUS:"focus",BLUR:"blur",INPUT:"input"},br=class{constructor(e){this.domNode=e,this._maxWidth="",this._width="",this._height="",this._top="",this._left="",this._bottom="",this._right="",this._paddingTop="",this._paddingLeft="",this._paddingBottom="",this._paddingRight="",this._fontFamily="",this._fontWeight="",this._fontSize="",this._fontStyle="",this._fontFeatureSettings="",this._fontVariationSettings="",this._textDecoration="",this._lineHeight="",this._letterSpacing="",this._className="",this._display="",this._position="",this._visibility="",this._color="",this._backgroundColor="",this._layerHint=!1,this._contain="none",this._boxShadow=""}setMaxWidth(e){let r=bs(e);this._maxWidth!==r&&(this._maxWidth=r,this.domNode.style.maxWidth=this._maxWidth)}setWidth(e){let r=bs(e);this._width!==r&&(this._width=r,this.domNode.style.width=this._width)}setHeight(e){let r=bs(e);this._height!==r&&(this._height=r,this.domNode.style.height=this._height)}setTop(e){let r=bs(e);this._top!==r&&(this._top=r,this.domNode.style.top=this._top)}setLeft(e){let r=bs(e);this._left!==r&&(this._left=r,this.domNode.style.left=this._left)}setBottom(e){let r=bs(e);this._bottom!==r&&(this._bottom=r,this.domNode.style.bottom=this._bottom)}setRight(e){let r=bs(e);this._right!==r&&(this._right=r,this.domNode.style.right=this._right)}setPaddingTop(e){let r=bs(e);this._paddingTop!==r&&(this._paddingTop=r,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(e){let r=bs(e);this._paddingLeft!==r&&(this._paddingLeft=r,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(e){let r=bs(e);this._paddingBottom!==r&&(this._paddingBottom=r,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(e){let r=bs(e);this._paddingRight!==r&&(this._paddingRight=r,this.domNode.style.paddingRight=this._paddingRight)}setFontFamily(e){this._fontFamily!==e&&(this._fontFamily=e,this.domNode.style.fontFamily=this._fontFamily)}setFontWeight(e){this._fontWeight!==e&&(this._fontWeight=e,this.domNode.style.fontWeight=this._fontWeight)}setFontSize(e){let r=bs(e);this._fontSize!==r&&(this._fontSize=r,this.domNode.style.fontSize=this._fontSize)}setFontStyle(e){this._fontStyle!==e&&(this._fontStyle=e,this.domNode.style.fontStyle=this._fontStyle)}setFontFeatureSettings(e){this._fontFeatureSettings!==e&&(this._fontFeatureSettings=e,this.domNode.style.fontFeatureSettings=this._fontFeatureSettings)}setFontVariationSettings(e){this._fontVariationSettings!==e&&(this._fontVariationSettings=e,this.domNode.style.fontVariationSettings=this._fontVariationSettings)}setTextDecoration(e){this._textDecoration!==e&&(this._textDecoration=e,this.domNode.style.textDecoration=this._textDecoration)}setLineHeight(e){let r=bs(e);this._lineHeight!==r&&(this._lineHeight=r,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(e){let r=bs(e);this._letterSpacing!==r&&(this._letterSpacing=r,this.domNode.style.letterSpacing=this._letterSpacing)}setClassName(e){this._className!==e&&(this._className=e,this.domNode.className=this._className)}toggleClassName(e,r){this.domNode.classList.toggle(e,r),this._className=this.domNode.className}setDisplay(e){this._display!==e&&(this._display=e,this.domNode.style.display=this._display)}setPosition(e){this._position!==e&&(this._position=e,this.domNode.style.position=this._position)}setVisibility(e){this._visibility!==e&&(this._visibility=e,this.domNode.style.visibility=this._visibility)}setColor(e){this._color!==e&&(this._color=e,this.domNode.style.color=this._color)}setBackgroundColor(e){this._backgroundColor!==e&&(this._backgroundColor=e,this.domNode.style.backgroundColor=this._backgroundColor)}setLayerHinting(e){this._layerHint!==e&&(this._layerHint=e,this.domNode.style.transform=this._layerHint?"translate3d(0px, 0px, 0px)":"")}setBoxShadow(e){this._boxShadow!==e&&(this._boxShadow=e,this.domNode.style.boxShadow=e)}setContain(e){this._contain!==e&&(this._contain=e,this.domNode.style.contain=this._contain)}setAttribute(e,r){this.domNode.setAttribute(e,r)}removeAttribute(e){this.domNode.removeAttribute(e)}appendChild(e){this.domNode.appendChild(e.domNode)}removeChild(e){this.domNode.removeChild(e.domNode)}};function bs(e){return"number"==typeof e?`${e}px`:e}function bn(e){return new br(e)}var bi=class{constructor(){this._hooks=new vN,this._pointerMoveCallback=null,this._onStopCallback=null}dispose(){this.stopMonitoring(!1),this._hooks.dispose()}stopMonitoring(e,r){if(!this.isMonitoring())return;this._hooks.clear(),this._pointerMoveCallback=null;let s=this._onStopCallback;this._onStopCallback=null,e&&s&&s(r)}isMonitoring(){return!!this._pointerMoveCallback}startMonitoring(e,r,s,n,i){this.isMonitoring()&&this.stopMonitoring(!1),this._pointerMoveCallback=n,this._onStopCallback=i;let a=e;try{e.setPointerCapture(r),this._hooks.add(vj(()=>{try{e.releasePointerCapture(r)}catch{}}))}catch{a=yY(e)}this._hooks.add(y6(a,bt.POINTER_MOVE,e=>{e.buttons!==s?this.stopMonitoring(!0):(e.preventDefault(),this._pointerMoveCallback(e))})),this._hooks.add(y6(a,bt.POINTER_UP,e=>this.stopMonitoring(!0)))}};(m=bP||={}).Tap="-xterm-gesturetap",m.Change="-xterm-gesturechange",m.Start="-xterm-gesturestart",m.End="-xterm-gesturesend",m.Contextmenu="-xterm-gesturecontextmenu";var ba=class e extends vE{constructor(){super(),this.dispatched=!1,this.targets=new vA,this.ignoreTargets=new vA,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(vY.runAndSubscribe(y2,({window:e,disposables:r})=>{r.add(y6(e.document,"touchstart",e=>this.onTouchStart(e),{passive:!1})),r.add(y6(e.document,"touchend",r=>this.onTouchEnd(e,r))),r.add(y6(e.document,"touchmove",e=>this.onTouchMove(e),{passive:!1}))},{window:vT,disposables:this._store}))}static addTarget(r){return e.isTouchDevice()?(e.INSTANCE||(e.INSTANCE=new e),vj(e.INSTANCE.targets.push(r))):vE.None}static ignoreTarget(r){return e.isTouchDevice()?(e.INSTANCE||(e.INSTANCE=new e),vj(e.INSTANCE.ignoreTargets.push(r))):vE.None}static isTouchDevice(){return"ontouchstart"in vT||navigator.maxTouchPoints>0}dispose(){this.handle&&(this.handle.dispose(),this.handle=null),super.dispose()}onTouchStart(e){let r=Date.now();this.handle&&(this.handle.dispose(),this.handle=null);for(let s=0,n=e.targetTouches.length;s<n;s++){let n=e.targetTouches.item(s);this.activeTouches[n.identifier]={id:n.identifier,initialTarget:n.target,initialTimeStamp:r,initialPageX:n.pageX,initialPageY:n.pageY,rollingTimestamps:[r],rollingPageX:[n.pageX],rollingPageY:[n.pageY]};let i=this.newGestureEvent(bP.Start,n.target);i.pageX=n.pageX,i.pageY=n.pageY,this.dispatchEvent(i)}this.dispatched&&(e.preventDefault(),e.stopPropagation(),this.dispatched=!1)}onTouchEnd(r,s){let n=Date.now(),i=Object.keys(this.activeTouches).length;for(let a=0,o=s.changedTouches.length;a<o;a++){let o=s.changedTouches.item(a);if(!this.activeTouches.hasOwnProperty(String(o.identifier))){console.warn("move of an UNKNOWN touch",o);continue}let l=this.activeTouches[o.identifier],c=Date.now()-l.initialTimeStamp;if(c<e.HOLD_DELAY&&30>Math.abs(l.initialPageX-vb(l.rollingPageX))&&30>Math.abs(l.initialPageY-vb(l.rollingPageY))){let e=this.newGestureEvent(bP.Tap,l.initialTarget);e.pageX=vb(l.rollingPageX),e.pageY=vb(l.rollingPageY),this.dispatchEvent(e)}else if(c>=e.HOLD_DELAY&&30>Math.abs(l.initialPageX-vb(l.rollingPageX))&&30>Math.abs(l.initialPageY-vb(l.rollingPageY))){let e=this.newGestureEvent(bP.Contextmenu,l.initialTarget);e.pageX=vb(l.rollingPageX),e.pageY=vb(l.rollingPageY),this.dispatchEvent(e)}else if(1===i){let e=vb(l.rollingPageX),s=vb(l.rollingPageY),i=vb(l.rollingTimestamps)-l.rollingTimestamps[0],a=e-l.rollingPageX[0],o=s-l.rollingPageY[0],c=[...this.targets].filter(e=>l.initialTarget instanceof Node&&e.contains(l.initialTarget));this.inertia(r,c,n,Math.abs(a)/i,a>0?1:-1,e,Math.abs(o)/i,o>0?1:-1,s)}this.dispatchEvent(this.newGestureEvent(bP.End,l.initialTarget)),delete this.activeTouches[o.identifier]}this.dispatched&&(s.preventDefault(),s.stopPropagation(),this.dispatched=!1)}newGestureEvent(e,r){let s=document.createEvent("CustomEvent");return s.initEvent(e,!1,!0),s.initialTarget=r,s.tapCount=0,s}dispatchEvent(r){if(r.type===bP.Tap){let s=new Date().getTime(),n=0;n=s-this._lastSetTapCountTime>e.CLEAR_TAP_COUNT_TIME?1:2,this._lastSetTapCountTime=s,r.tapCount=n}else(r.type===bP.Change||r.type===bP.Contextmenu)&&(this._lastSetTapCountTime=0);if(r.initialTarget instanceof Node){for(let e of this.ignoreTargets)if(e.contains(r.initialTarget))return;let e=[];for(let s of this.targets)if(s.contains(r.initialTarget)){let n=0,i=r.initialTarget;for(;i&&i!==s;)n++,i=i.parentElement;e.push([n,s])}for(let[s,n]of(e.sort((e,r)=>e[0]-r[0]),e))n.dispatchEvent(r),this.dispatched=!0}}inertia(r,s,n,i,a,o,l,c,d){this.handle=bI(r,()=>{let u=Date.now(),h=u-n,f=0,p=0,m=!0;i+=e.SCROLL_FRICTION*h,l+=e.SCROLL_FRICTION*h,i>0&&(m=!1,f=a*i*h),l>0&&(m=!1,p=c*l*h);let g=this.newGestureEvent(bP.Change);g.translationX=f,g.translationY=p,s.forEach(e=>e.dispatchEvent(g)),m||this.inertia(r,s,u,i,a,o+f,l,c,d+p)})}onTouchMove(e){let r=Date.now();for(let s=0,n=e.changedTouches.length;s<n;s++){let n=e.changedTouches.item(s);if(!this.activeTouches.hasOwnProperty(String(n.identifier))){console.warn("end of an UNKNOWN touch",n);continue}let i=this.activeTouches[n.identifier],a=this.newGestureEvent(bP.Change,i.initialTarget);a.translationX=n.pageX-vb(i.rollingPageX),a.translationY=n.pageY-vb(i.rollingPageY),a.pageX=n.pageX,a.pageY=n.pageY,this.dispatchEvent(a),i.rollingPageX.length>3&&(i.rollingPageX.shift(),i.rollingPageY.shift(),i.rollingTimestamps.shift()),i.rollingPageX.push(n.pageX),i.rollingPageY.push(n.pageY),i.rollingTimestamps.push(r)}this.dispatched&&(e.preventDefault(),e.stopPropagation(),this.dispatched=!1)}};ba.SCROLL_FRICTION=-.005,ba.HOLD_DELAY=700,ba.CLEAR_TAP_COUNT_TIME=400,x$([function(e,r,s){let n=null,i=null;if("function"==typeof s.value?(n="value",0!==(i=s.value).length&&console.warn("Memoize should only be used in functions with zero parameters")):"function"==typeof s.get&&(n="get",i=s.get),!i)throw Error("not supported");let a=`$memoize$${r}`;s[n]=function(...e){return this.hasOwnProperty(a)||Object.defineProperty(this,a,{configurable:!1,enumerable:!1,writable:!1,value:i.apply(this,e)}),this[a]}}],ba,"isTouchDevice",1);var bo=class extends vE{onclick(e,r){this._register(y6(e,bt.CLICK,s=>r(new yB(yY(e),s))))}onmousedown(e,r){this._register(y6(e,bt.MOUSE_DOWN,s=>r(new yB(yY(e),s))))}onmouseover(e,r){this._register(y6(e,bt.MOUSE_OVER,s=>r(new yB(yY(e),s))))}onmouseleave(e,r){this._register(y6(e,bt.MOUSE_LEAVE,s=>r(new yB(yY(e),s))))}onkeydown(e,r){this._register(y6(e,bt.KEY_DOWN,e=>r(new yF(e))))}onkeyup(e,r){this._register(y6(e,bt.KEY_UP,e=>r(new yF(e))))}oninput(e,r){this._register(y6(e,bt.INPUT,r))}onblur(e,r){this._register(y6(e,bt.BLUR,r))}onfocus(e,r){this._register(y6(e,bt.FOCUS,r))}onchange(e,r){this._register(y6(e,bt.CHANGE,r))}ignoreGesture(e){return ba.ignoreTarget(e)}},bl=class extends bo{constructor(e){super(),this._onActivate=e.onActivate,this.bgDomNode=document.createElement("div"),this.bgDomNode.className="arrow-background",this.bgDomNode.style.position="absolute",this.bgDomNode.style.width=e.bgWidth+"px",this.bgDomNode.style.height=e.bgHeight+"px","u">typeof e.top&&(this.bgDomNode.style.top="0px"),"u">typeof e.left&&(this.bgDomNode.style.left="0px"),"u">typeof e.bottom&&(this.bgDomNode.style.bottom="0px"),"u">typeof e.right&&(this.bgDomNode.style.right="0px"),this.domNode=document.createElement("div"),this.domNode.className=e.className,this.domNode.style.position="absolute",this.domNode.style.width="11px",this.domNode.style.height="11px","u">typeof e.top&&(this.domNode.style.top=e.top+"px"),"u">typeof e.left&&(this.domNode.style.left=e.left+"px"),"u">typeof e.bottom&&(this.domNode.style.bottom=e.bottom+"px"),"u">typeof e.right&&(this.domNode.style.right=e.right+"px"),this._pointerMoveMonitor=this._register(new bi),this._register(y7(this.bgDomNode,bt.POINTER_DOWN,e=>this._arrowPointerDown(e))),this._register(y7(this.domNode,bt.POINTER_DOWN,e=>this._arrowPointerDown(e))),this._pointerdownRepeatTimer=this._register(new y8),this._pointerdownScheduleRepeatTimer=this._register(new yH)}_arrowPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let r=()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,yY(e))};this._onActivate(),this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancelAndSet(r,200),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,e=>{},()=>{this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancel()}),e.preventDefault()}},bc=class e{constructor(e,r,s,n,i,a,o){this._forceIntegerValues=e,this._scrollStateBrand=void 0,this._forceIntegerValues&&(r|=0,s|=0,n|=0,i|=0,a|=0,o|=0),this.rawScrollLeft=n,this.rawScrollTop=o,r<0&&(r=0),n+r>s&&(n=s-r),n<0&&(n=0),i<0&&(i=0),o+i>a&&(o=a-i),o<0&&(o=0),this.width=r,this.scrollWidth=s,this.scrollLeft=n,this.height=i,this.scrollHeight=a,this.scrollTop=o}equals(e){return this.rawScrollLeft===e.rawScrollLeft&&this.rawScrollTop===e.rawScrollTop&&this.width===e.width&&this.scrollWidth===e.scrollWidth&&this.scrollLeft===e.scrollLeft&&this.height===e.height&&this.scrollHeight===e.scrollHeight&&this.scrollTop===e.scrollTop}withScrollDimensions(r,s){return new e(this._forceIntegerValues,"u">typeof r.width?r.width:this.width,"u">typeof r.scrollWidth?r.scrollWidth:this.scrollWidth,s?this.rawScrollLeft:this.scrollLeft,"u">typeof r.height?r.height:this.height,"u">typeof r.scrollHeight?r.scrollHeight:this.scrollHeight,s?this.rawScrollTop:this.scrollTop)}withScrollPosition(r){return new e(this._forceIntegerValues,this.width,this.scrollWidth,"u">typeof r.scrollLeft?r.scrollLeft:this.rawScrollLeft,this.height,this.scrollHeight,"u">typeof r.scrollTop?r.scrollTop:this.rawScrollTop)}createScrollEvent(e,r){let s=this.width!==e.width,n=this.scrollWidth!==e.scrollWidth,i=this.scrollLeft!==e.scrollLeft,a=this.height!==e.height,o=this.scrollHeight!==e.scrollHeight,l=this.scrollTop!==e.scrollTop;return{inSmoothScrolling:r,oldWidth:e.width,oldScrollWidth:e.scrollWidth,oldScrollLeft:e.scrollLeft,width:this.width,scrollWidth:this.scrollWidth,scrollLeft:this.scrollLeft,oldHeight:e.height,oldScrollHeight:e.scrollHeight,oldScrollTop:e.scrollTop,height:this.height,scrollHeight:this.scrollHeight,scrollTop:this.scrollTop,widthChanged:s,scrollWidthChanged:n,scrollLeftChanged:i,heightChanged:a,scrollHeightChanged:o,scrollTopChanged:l}}},bd=class extends vE{constructor(e){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new v2),this.onScroll=this._onScroll.event,this._smoothScrollDuration=e.smoothScrollDuration,this._scheduleAtNextAnimationFrame=e.scheduleAtNextAnimationFrame,this._state=new bc(e.forceIntegerValues,0,0,0,0,0,0),this._smoothScrolling=null}dispose(){this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),super.dispose()}setSmoothScrollDuration(e){this._smoothScrollDuration=e}validateScrollPosition(e){return this._state.withScrollPosition(e)}getScrollDimensions(){return this._state}setScrollDimensions(e,r){let s=this._state.withScrollDimensions(e,r);this._setState(s,!!this._smoothScrolling),this._smoothScrolling?.acceptScrollDimensions(this._state)}getFutureScrollPosition(){return this._smoothScrolling?this._smoothScrolling.to:this._state}getCurrentScrollPosition(){return this._state}setScrollPositionNow(e){let r=this._state.withScrollPosition(e);this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),this._setState(r,!1)}setScrollPositionSmooth(e,r){if(0===this._smoothScrollDuration)return this.setScrollPositionNow(e);if(this._smoothScrolling){let s;e={scrollLeft:typeof e.scrollLeft>"u"?this._smoothScrolling.to.scrollLeft:e.scrollLeft,scrollTop:typeof e.scrollTop>"u"?this._smoothScrolling.to.scrollTop:e.scrollTop};let n=this._state.withScrollPosition(e);if(this._smoothScrolling.to.scrollLeft===n.scrollLeft&&this._smoothScrolling.to.scrollTop===n.scrollTop)return;s=r?new bf(this._smoothScrolling.from,n,this._smoothScrolling.startTime,this._smoothScrolling.duration):this._smoothScrolling.combine(this._state,n,this._smoothScrollDuration),this._smoothScrolling.dispose(),this._smoothScrolling=s}else{let r=this._state.withScrollPosition(e);this._smoothScrolling=bf.start(this._state,r,this._smoothScrollDuration)}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}hasPendingScrollAnimation(){return!!this._smoothScrolling}_performSmoothScrolling(){if(!this._smoothScrolling)return;let e=this._smoothScrolling.tick(),r=this._state.withScrollPosition(e);if(this._setState(r,!0),this._smoothScrolling){if(e.isDone){this._smoothScrolling.dispose(),this._smoothScrolling=null;return}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}}_setState(e,r){let s=this._state;s.equals(e)||(this._state=e,this._onScroll.fire(this._state.createScrollEvent(s,r)))}},bu=class{constructor(e,r,s){this.scrollLeft=e,this.scrollTop=r,this.isDone=s}};function bh(e,r){let s=r-e;return function(r){return e+s*(1-Math.pow(1-r,3))}}var bf=class e{constructor(e,r,s,n){this.from=e,this.to=r,this.duration=n,this.startTime=s,this.animationFrameDisposable=null,this._initAnimations()}_initAnimations(){this.scrollLeft=this._initAnimation(this.from.scrollLeft,this.to.scrollLeft,this.to.width),this.scrollTop=this._initAnimation(this.from.scrollTop,this.to.scrollTop,this.to.height)}_initAnimation(e,r,s){if(Math.abs(e-r)>2.5*s){var n,i;let a,o;return e<r?(a=e+.75*s,o=r-.75*s):(a=e-.75*s,o=r+.75*s),n=bh(e,a),i=bh(o,r),function(e){return e<.33?n(e/.33):i((e-.33)/(1-.33))}}return bh(e,r)}dispose(){null!==this.animationFrameDisposable&&(this.animationFrameDisposable.dispose(),this.animationFrameDisposable=null)}acceptScrollDimensions(e){this.to=e.withScrollPosition(this.to),this._initAnimations()}tick(){return this._tick(Date.now())}_tick(e){let r=(e-this.startTime)/this.duration;return r<1?new bu(this.scrollLeft(r),this.scrollTop(r),!1):new bu(this.to.scrollLeft,this.to.scrollTop,!0)}combine(r,s,n){return e.start(r,s,n)}static start(r,s,n){return n+=10,new e(r,s,Date.now()-10,n)}},bp=class extends vE{constructor(e,r,s){super(),this._visibility=e,this._visibleClassName=r,this._invisibleClassName=s,this._domNode=null,this._isVisible=!1,this._isNeeded=!1,this._rawShouldBeVisible=!1,this._shouldBeVisible=!1,this._revealTimer=this._register(new yH)}setVisibility(e){this._visibility!==e&&(this._visibility=e,this._updateShouldBeVisible())}setShouldBeVisible(e){this._rawShouldBeVisible=e,this._updateShouldBeVisible()}_applyVisibilitySetting(){return 2!==this._visibility&&(3===this._visibility||this._rawShouldBeVisible)}_updateShouldBeVisible(){let e=this._applyVisibilitySetting();this._shouldBeVisible!==e&&(this._shouldBeVisible=e,this.ensureVisibility())}setIsNeeded(e){this._isNeeded!==e&&(this._isNeeded=e,this.ensureVisibility())}setDomNode(e){this._domNode=e,this._domNode.setClassName(this._invisibleClassName),this.setShouldBeVisible(!1)}ensureVisibility(){this._isNeeded?this._shouldBeVisible?this._reveal():this._hide(!0):this._hide(!1)}_reveal(){this._isVisible||(this._isVisible=!0,this._revealTimer.setIfNotSet(()=>{this._domNode?.setClassName(this._visibleClassName)},0))}_hide(e){this._revealTimer.cancel(),this._isVisible&&(this._isVisible=!1,this._domNode?.setClassName(this._invisibleClassName+(e?" fade":"")))}},bm=class extends bo{constructor(e){super(),this._lazyRender=e.lazyRender,this._host=e.host,this._scrollable=e.scrollable,this._scrollByPage=e.scrollByPage,this._scrollbarState=e.scrollbarState,this._visibilityController=this._register(new bp(e.visibility,"visible scrollbar "+e.extraScrollbarClassName,"invisible scrollbar "+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new bi),this._shouldRender=!0,this.domNode=bn(document.createElement("div")),this.domNode.setAttribute("role","presentation"),this.domNode.setAttribute("aria-hidden","true"),this._visibilityController.setDomNode(this.domNode),this.domNode.setPosition("absolute"),this._register(y6(this.domNode.domNode,bt.POINTER_DOWN,e=>this._domNodePointerDown(e)))}_createArrow(e){let r=this._register(new bl(e));this.domNode.domNode.appendChild(r.bgDomNode),this.domNode.domNode.appendChild(r.domNode)}_createSlider(e,r,s,n){this.slider=bn(document.createElement("div")),this.slider.setClassName("slider"),this.slider.setPosition("absolute"),this.slider.setTop(e),this.slider.setLeft(r),"number"==typeof s&&this.slider.setWidth(s),"number"==typeof n&&this.slider.setHeight(n),this.slider.setLayerHinting(!0),this.slider.setContain("strict"),this.domNode.domNode.appendChild(this.slider.domNode),this._register(y6(this.slider.domNode,bt.POINTER_DOWN,e=>{0===e.button&&(e.preventDefault(),this._sliderPointerDown(e))})),this.onclick(this.slider.domNode,e=>{e.leftButton&&e.stopPropagation()})}_onElementSize(e){return this._scrollbarState.setVisibleSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollSize(e){return this._scrollbarState.setScrollSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollPosition(e){return this._scrollbarState.setScrollPosition(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}beginReveal(){this._visibilityController.setShouldBeVisible(!0)}beginHide(){this._visibilityController.setShouldBeVisible(!1)}render(){this._shouldRender&&(this._shouldRender=!1,this._renderDomNode(this._scrollbarState.getRectangleLargeSize(),this._scrollbarState.getRectangleSmallSize()),this._updateSlider(this._scrollbarState.getSliderSize(),this._scrollbarState.getArrowSize()+this._scrollbarState.getSliderPosition()))}_domNodePointerDown(e){e.target===this.domNode.domNode&&this._onPointerDown(e)}delegatePointerDown(e){let r=this.domNode.domNode.getClientRects()[0].top,s=r+this._scrollbarState.getSliderPosition(),n=r+this._scrollbarState.getSliderPosition()+this._scrollbarState.getSliderSize(),i=this._sliderPointerPosition(e);s<=i&&i<=n?0===e.button&&(e.preventDefault(),this._sliderPointerDown(e)):this._onPointerDown(e)}_onPointerDown(e){let r,s;if(e.target===this.domNode.domNode&&"number"==typeof e.offsetX&&"number"==typeof e.offsetY)r=e.offsetX,s=e.offsetY;else{var n;let i,a,o=(i=(n=this.domNode.domNode).getBoundingClientRect(),a=yY(n),{left:i.left+a.scrollX,top:i.top+a.scrollY,width:i.width,height:i.height});r=e.pageX-o.left,s=e.pageY-o.top}let i=this._pointerDownRelativePosition(r,s);this._setDesiredScrollPositionNow(this._scrollByPage?this._scrollbarState.getDesiredScrollPositionFromOffsetPaged(i):this._scrollbarState.getDesiredScrollPositionFromOffset(i)),0===e.button&&(e.preventDefault(),this._sliderPointerDown(e))}_sliderPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let r=this._sliderPointerPosition(e),s=this._sliderOrthogonalPointerPosition(e),n=this._scrollbarState.clone();this.slider.toggleClassName("active",!0),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,e=>{let i=Math.abs(this._sliderOrthogonalPointerPosition(e)-s);if(yh&&i>140)return void this._setDesiredScrollPositionNow(n.getScrollPosition());let a=this._sliderPointerPosition(e)-r;this._setDesiredScrollPositionNow(n.getDesiredScrollPositionFromDelta(a))},()=>{this.slider.toggleClassName("active",!1),this._host.onDragEnd()}),this._host.onDragStart()}_setDesiredScrollPositionNow(e){let r={};this.writeScrollPosition(r,e),this._scrollable.setScrollPositionNow(r)}updateScrollbarSize(e){this._updateScrollbarSize(e),this._scrollbarState.setScrollbarSize(e),this._shouldRender=!0,this._lazyRender||this.render()}isNeeded(){return this._scrollbarState.isNeeded()}},bg=class e{constructor(e,r,s,n,i,a){this._scrollbarSize=Math.round(r),this._oppositeScrollbarSize=Math.round(s),this._arrowSize=Math.round(e),this._visibleSize=n,this._scrollSize=i,this._scrollPosition=a,this._computedAvailableSize=0,this._computedIsNeeded=!1,this._computedSliderSize=0,this._computedSliderRatio=0,this._computedSliderPosition=0,this._refreshComputedValues()}clone(){return new e(this._arrowSize,this._scrollbarSize,this._oppositeScrollbarSize,this._visibleSize,this._scrollSize,this._scrollPosition)}setVisibleSize(e){let r=Math.round(e);return this._visibleSize!==r&&(this._visibleSize=r,this._refreshComputedValues(),!0)}setScrollSize(e){let r=Math.round(e);return this._scrollSize!==r&&(this._scrollSize=r,this._refreshComputedValues(),!0)}setScrollPosition(e){let r=Math.round(e);return this._scrollPosition!==r&&(this._scrollPosition=r,this._refreshComputedValues(),!0)}setScrollbarSize(e){this._scrollbarSize=Math.round(e)}setOppositeScrollbarSize(e){this._oppositeScrollbarSize=Math.round(e)}static _computeValues(e,r,s,n,i){let a=Math.max(0,s-e),o=Math.max(0,a-2*r),l=n>0&&n>s;if(!l)return{computedAvailableSize:Math.round(a),computedIsNeeded:l,computedSliderSize:Math.round(o),computedSliderRatio:0,computedSliderPosition:0};let c=Math.round(Math.max(20,Math.floor(s*o/n))),d=(o-c)/(n-s);return{computedAvailableSize:Math.round(a),computedIsNeeded:l,computedSliderSize:Math.round(c),computedSliderRatio:d,computedSliderPosition:Math.round(i*d)}}_refreshComputedValues(){let r=e._computeValues(this._oppositeScrollbarSize,this._arrowSize,this._visibleSize,this._scrollSize,this._scrollPosition);this._computedAvailableSize=r.computedAvailableSize,this._computedIsNeeded=r.computedIsNeeded,this._computedSliderSize=r.computedSliderSize,this._computedSliderRatio=r.computedSliderRatio,this._computedSliderPosition=r.computedSliderPosition}getArrowSize(){return this._arrowSize}getScrollPosition(){return this._scrollPosition}getRectangleLargeSize(){return this._computedAvailableSize}getRectangleSmallSize(){return this._scrollbarSize}isNeeded(){return this._computedIsNeeded}getSliderSize(){return this._computedSliderSize}getSliderPosition(){return this._computedSliderPosition}getDesiredScrollPositionFromOffset(e){return this._computedIsNeeded?Math.round((e-this._arrowSize-this._computedSliderSize/2)/this._computedSliderRatio):0}getDesiredScrollPositionFromOffsetPaged(e){if(!this._computedIsNeeded)return 0;let r=e-this._arrowSize,s=this._scrollPosition;return r<this._computedSliderPosition?s-=this._visibleSize:s+=this._visibleSize,s}getDesiredScrollPositionFromDelta(e){return this._computedIsNeeded?Math.round((this._computedSliderPosition+e)/this._computedSliderRatio):0}},bx=class extends bm{constructor(e,r,s){let n=e.getScrollDimensions();if(super({lazyRender:r.lazyRender,host:s,scrollbarState:new bg(r.horizontalHasArrows?r.arrowSize:0,2===r.horizontal?0:r.horizontalScrollbarSize,2===r.vertical?0:r.verticalScrollbarSize,n.width,n.scrollWidth,e.getCurrentScrollPosition().scrollLeft),visibility:r.horizontal,extraScrollbarClassName:"horizontal",scrollable:e,scrollByPage:r.scrollByPage}),r.horizontalHasArrows)throw Error("horizontalHasArrows is not supported in xterm.js");this._createSlider(Math.floor((r.horizontalScrollbarSize-r.horizontalSliderSize)/2),0,void 0,r.horizontalSliderSize)}_updateSlider(e,r){this.slider.setWidth(e),this.slider.setLeft(r)}_renderDomNode(e,r){this.domNode.setWidth(e),this.domNode.setHeight(r),this.domNode.setLeft(0),this.domNode.setBottom(0)}onDidScroll(e){return this._shouldRender=this._onElementScrollSize(e.scrollWidth)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(e.scrollLeft)||this._shouldRender,this._shouldRender=this._onElementSize(e.width)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(e,r){return e}_sliderPointerPosition(e){return e.pageX}_sliderOrthogonalPointerPosition(e){return e.pageY}_updateScrollbarSize(e){this.slider.setHeight(e)}writeScrollPosition(e,r){e.scrollLeft=r}updateOptions(e){this.updateScrollbarSize(2===e.horizontal?0:e.horizontalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(2===e.vertical?0:e.verticalScrollbarSize),this._visibilityController.setVisibility(e.horizontal),this._scrollByPage=e.scrollByPage}},bv=class extends bm{constructor(e,r,s){let n=e.getScrollDimensions();if(super({lazyRender:r.lazyRender,host:s,scrollbarState:new bg(r.verticalHasArrows?r.arrowSize:0,2===r.vertical?0:r.verticalScrollbarSize,0,n.height,n.scrollHeight,e.getCurrentScrollPosition().scrollTop),visibility:r.vertical,extraScrollbarClassName:"vertical",scrollable:e,scrollByPage:r.scrollByPage}),r.verticalHasArrows)throw Error("horizontalHasArrows is not supported in xterm.js");this._createSlider(0,Math.floor((r.verticalScrollbarSize-r.verticalSliderSize)/2),r.verticalSliderSize,void 0)}_updateSlider(e,r){this.slider.setHeight(e),this.slider.setTop(r)}_renderDomNode(e,r){this.domNode.setWidth(r),this.domNode.setHeight(e),this.domNode.setRight(0),this.domNode.setTop(0)}onDidScroll(e){return this._shouldRender=this._onElementScrollSize(e.scrollHeight)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(e.scrollTop)||this._shouldRender,this._shouldRender=this._onElementSize(e.height)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(e,r){return r}_sliderPointerPosition(e){return e.pageY}_sliderOrthogonalPointerPosition(e){return e.pageX}_updateScrollbarSize(e){this.slider.setWidth(e)}writeScrollPosition(e,r){e.scrollTop=r}updateOptions(e){this.updateScrollbarSize(2===e.vertical?0:e.verticalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(0),this._visibilityController.setVisibility(e.vertical),this._scrollByPage=e.scrollByPage}},by=class{constructor(e,r,s){this.timestamp=e,this.deltaX=r,this.deltaY=s,this.score=0}},bb=class{constructor(){this._capacity=5,this._memory=[],this._front=-1,this._rear=-1}isPhysicalMouseWheel(){if(-1===this._front&&-1===this._rear)return!1;let e=1,r=0,s=1,n=this._rear;for(;;){let i=n===this._front?e:Math.pow(2,-s);if(e-=i,r+=this._memory[n].score*i,n===this._front)break;n=(this._capacity+n-1)%this._capacity,s++}return r<=.5}acceptStandardWheelEvent(e){if(v8){var r;let s=(r=yY(e.browserEvent),v3.INSTANCE.getZoomFactor(r));this.accept(Date.now(),e.deltaX*s,e.deltaY*s)}else this.accept(Date.now(),e.deltaX,e.deltaY)}accept(e,r,s){let n=null,i=new by(e,r,s);-1===this._front&&-1===this._rear?(this._memory[0]=i,this._front=0,this._rear=0):(n=this._memory[this._rear],this._rear=(this._rear+1)%this._capacity,this._rear===this._front&&(this._front=(this._front+1)%this._capacity),this._memory[this._rear]=i),i.score=this._computeScore(i,n)}_computeScore(e,r){if(Math.abs(e.deltaX)>0&&Math.abs(e.deltaY)>0)return 1;let s=.5;if(this._isAlmostInt(e.deltaX)&&this._isAlmostInt(e.deltaY)||(s+=.25),r){let n=Math.abs(e.deltaX),i=Math.abs(e.deltaY),a=Math.abs(r.deltaX),o=Math.abs(r.deltaY),l=Math.max(Math.min(n,a),1),c=Math.max(Math.min(i,o),1),d=Math.max(i,o);Math.max(n,a)%l==0&&d%c==0&&(s-=.5)}return Math.min(Math.max(s,0),1)}_isAlmostInt(e){return .01>Math.abs(Math.round(e)-e)}};bb.INSTANCE=new bb;var bw=class extends bo{constructor(e,r,s){super(),this._onScroll=this._register(new v2),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new v2),this.onWillScroll=this._onWillScroll.event,this._options=function(e){let r={lazyRender:"u">typeof e.lazyRender&&e.lazyRender,className:"u">typeof e.className?e.className:"",useShadows:!("u">typeof e.useShadows)||e.useShadows,handleMouseWheel:!("u">typeof e.handleMouseWheel)||e.handleMouseWheel,flipAxes:"u">typeof e.flipAxes&&e.flipAxes,consumeMouseWheelIfScrollbarIsNeeded:"u">typeof e.consumeMouseWheelIfScrollbarIsNeeded&&e.consumeMouseWheelIfScrollbarIsNeeded,alwaysConsumeMouseWheel:"u">typeof e.alwaysConsumeMouseWheel&&e.alwaysConsumeMouseWheel,scrollYToX:"u">typeof e.scrollYToX&&e.scrollYToX,mouseWheelScrollSensitivity:"u">typeof e.mouseWheelScrollSensitivity?e.mouseWheelScrollSensitivity:1,fastScrollSensitivity:"u">typeof e.fastScrollSensitivity?e.fastScrollSensitivity:5,scrollPredominantAxis:!("u">typeof e.scrollPredominantAxis)||e.scrollPredominantAxis,mouseWheelSmoothScroll:!("u">typeof e.mouseWheelSmoothScroll)||e.mouseWheelSmoothScroll,arrowSize:"u">typeof e.arrowSize?e.arrowSize:11,listenOnDomNode:"u">typeof e.listenOnDomNode?e.listenOnDomNode:null,horizontal:"u">typeof e.horizontal?e.horizontal:1,horizontalScrollbarSize:"u">typeof e.horizontalScrollbarSize?e.horizontalScrollbarSize:10,horizontalSliderSize:"u">typeof e.horizontalSliderSize?e.horizontalSliderSize:0,horizontalHasArrows:"u">typeof e.horizontalHasArrows&&e.horizontalHasArrows,vertical:"u">typeof e.vertical?e.vertical:1,verticalScrollbarSize:"u">typeof e.verticalScrollbarSize?e.verticalScrollbarSize:10,verticalHasArrows:"u">typeof e.verticalHasArrows&&e.verticalHasArrows,verticalSliderSize:"u">typeof e.verticalSliderSize?e.verticalSliderSize:0,scrollByPage:"u">typeof e.scrollByPage&&e.scrollByPage};return r.horizontalSliderSize="u">typeof e.horizontalSliderSize?e.horizontalSliderSize:r.horizontalScrollbarSize,r.verticalSliderSize="u">typeof e.verticalSliderSize?e.verticalSliderSize:r.verticalScrollbarSize,yf&&(r.className+=" mac"),r}(r),this._scrollable=s,this._register(this._scrollable.onScroll(e=>{this._onWillScroll.fire(e),this._onDidScroll(e),this._onScroll.fire(e)}));let n={onMouseWheel:e=>this._onMouseWheel(e),onDragStart:()=>this._onDragStart(),onDragEnd:()=>this._onDragEnd()};this._verticalScrollbar=this._register(new bv(this._scrollable,this._options,n)),this._horizontalScrollbar=this._register(new bx(this._scrollable,this._options,n)),this._domNode=document.createElement("div"),this._domNode.className="xterm-scrollable-element "+this._options.className,this._domNode.setAttribute("role","presentation"),this._domNode.style.position="relative",this._domNode.appendChild(e),this._domNode.appendChild(this._horizontalScrollbar.domNode.domNode),this._domNode.appendChild(this._verticalScrollbar.domNode.domNode),this._options.useShadows?(this._leftShadowDomNode=bn(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=bn(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=bn(document.createElement("div")),this._topLeftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topLeftShadowDomNode.domNode)):(this._leftShadowDomNode=null,this._topShadowDomNode=null,this._topLeftShadowDomNode=null),this._listenOnDomNode=this._options.listenOnDomNode||this._domNode,this._mouseWheelToDispose=[],this._setListeningToMouseWheel(this._options.handleMouseWheel),this.onmouseover(this._listenOnDomNode,e=>this._onMouseOver(e)),this.onmouseleave(this._listenOnDomNode,e=>this._onMouseLeave(e)),this._hideTimeout=this._register(new yH),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=vk(this._mouseWheelToDispose),super.dispose()}getDomNode(){return this._domNode}getOverviewRulerLayoutInfo(){return{parent:this._domNode,insertBefore:this._verticalScrollbar.domNode.domNode}}delegateVerticalScrollbarPointerDown(e){this._verticalScrollbar.delegatePointerDown(e)}getScrollDimensions(){return this._scrollable.getScrollDimensions()}setScrollDimensions(e){this._scrollable.setScrollDimensions(e,!1)}updateClassName(e){this._options.className=e,yf&&(this._options.className+=" mac"),this._domNode.className="xterm-scrollable-element "+this._options.className}updateOptions(e){"u">typeof e.handleMouseWheel&&(this._options.handleMouseWheel=e.handleMouseWheel,this._setListeningToMouseWheel(this._options.handleMouseWheel)),"u">typeof e.mouseWheelScrollSensitivity&&(this._options.mouseWheelScrollSensitivity=e.mouseWheelScrollSensitivity),"u">typeof e.fastScrollSensitivity&&(this._options.fastScrollSensitivity=e.fastScrollSensitivity),"u">typeof e.scrollPredominantAxis&&(this._options.scrollPredominantAxis=e.scrollPredominantAxis),"u">typeof e.horizontal&&(this._options.horizontal=e.horizontal),"u">typeof e.vertical&&(this._options.vertical=e.vertical),"u">typeof e.horizontalScrollbarSize&&(this._options.horizontalScrollbarSize=e.horizontalScrollbarSize),"u">typeof e.verticalScrollbarSize&&(this._options.verticalScrollbarSize=e.verticalScrollbarSize),"u">typeof e.scrollByPage&&(this._options.scrollByPage=e.scrollByPage),this._horizontalScrollbar.updateOptions(this._options),this._verticalScrollbar.updateOptions(this._options),this._options.lazyRender||this._render()}setRevealOnScroll(e){this._revealOnScroll=e}delegateScrollFromMouseWheelEvent(e){this._onMouseWheel(new yz(e))}_setListeningToMouseWheel(e){if(this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=vk(this._mouseWheelToDispose),e)){let e=e=>{this._onMouseWheel(new yz(e))};this._mouseWheelToDispose.push(y6(this._listenOnDomNode,bt.MOUSE_WHEEL,e,{passive:!1}))}}_onMouseWheel(e){if(e.browserEvent?.defaultPrevented)return;let r=bb.INSTANCE;r.acceptStandardWheelEvent(e);let s=!1;if(e.deltaY||e.deltaX){let n=e.deltaY*this._options.mouseWheelScrollSensitivity,i=e.deltaX*this._options.mouseWheelScrollSensitivity;this._options.scrollPredominantAxis&&(this._options.scrollYToX&&i+n===0?i=n=0:Math.abs(n)>=Math.abs(i)?i=0:n=0),this._options.flipAxes&&([n,i]=[i,n]);let a=!yf&&e.browserEvent&&e.browserEvent.shiftKey;(this._options.scrollYToX||a)&&!i&&(i=n,n=0),e.browserEvent&&e.browserEvent.altKey&&(i*=this._options.fastScrollSensitivity,n*=this._options.fastScrollSensitivity);let o=this._scrollable.getFutureScrollPosition(),l={};if(n){let e=50*n,r=o.scrollTop-(e<0?Math.floor(e):Math.ceil(e));this._verticalScrollbar.writeScrollPosition(l,r)}if(i){let e=50*i,r=o.scrollLeft-(e<0?Math.floor(e):Math.ceil(e));this._horizontalScrollbar.writeScrollPosition(l,r)}l=this._scrollable.validateScrollPosition(l),(o.scrollLeft!==l.scrollLeft||o.scrollTop!==l.scrollTop)&&(this._options.mouseWheelSmoothScroll&&r.isPhysicalMouseWheel()?this._scrollable.setScrollPositionSmooth(l):this._scrollable.setScrollPositionNow(l),s=!0)}let n=s;!n&&this._options.alwaysConsumeMouseWheel&&(n=!0),!n&&this._options.consumeMouseWheelIfScrollbarIsNeeded&&(this._verticalScrollbar.isNeeded()||this._horizontalScrollbar.isNeeded())&&(n=!0),n&&(e.preventDefault(),e.stopPropagation())}_onDidScroll(e){this._shouldRender=this._horizontalScrollbar.onDidScroll(e)||this._shouldRender,this._shouldRender=this._verticalScrollbar.onDidScroll(e)||this._shouldRender,this._options.useShadows&&(this._shouldRender=!0),this._revealOnScroll&&this._reveal(),this._options.lazyRender||this._render()}renderNow(){if(!this._options.lazyRender)throw Error("Please use `lazyRender` together with `renderNow`!");this._render()}_render(){if(this._shouldRender&&(this._shouldRender=!1,this._horizontalScrollbar.render(),this._verticalScrollbar.render(),this._options.useShadows)){let e=this._scrollable.getCurrentScrollPosition(),r=e.scrollTop>0,s=e.scrollLeft>0,n=s?" left":"",i=r?" top":"";this._leftShadowDomNode.setClassName(`shadow${n}`),this._topShadowDomNode.setClassName(`shadow${i}`),this._topLeftShadowDomNode.setClassName(`shadow${s||r?" top-left-corner":""}${i}${n}`)}}_onDragStart(){this._isDragging=!0,this._reveal()}_onDragEnd(){this._isDragging=!1,this._hide()}_onMouseLeave(e){this._mouseIsOver=!1,this._hide()}_onMouseOver(e){this._mouseIsOver=!0,this._reveal()}_reveal(){this._verticalScrollbar.beginReveal(),this._horizontalScrollbar.beginReveal(),this._scheduleHide()}_hide(){this._mouseIsOver||this._isDragging||(this._verticalScrollbar.beginHide(),this._horizontalScrollbar.beginHide())}_scheduleHide(){this._mouseIsOver||this._isDragging||this._hideTimeout.cancelAndSet(()=>this._hide(),500)}},b_=class extends bw{constructor(e,r,s){super(e,r,s)}setScrollPosition(e){e.reuseAnimation?this._scrollable.setScrollPositionSmooth(e,e.reuseAnimation):this._scrollable.setScrollPositionNow(e)}getScrollPosition(){return this._scrollable.getCurrentScrollPosition()}},bS=class extends vE{constructor(e,r,s,n,i,a,o,l){super(),this._bufferService=s,this._optionsService=o,this._renderService=l,this._onRequestScrollLines=this._register(new v2),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let c=this._register(new bd({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:e=>bI(n.window,e)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{c.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new b_(r,{vertical:1,horizontal:2,useShadows:!1,mouseWheelSmoothScroll:!0,...this._getChangeOptions()},c)),this._register(this._optionsService.onMultipleOptionChange(["scrollSensitivity","fastScrollSensitivity","overviewRuler"],()=>this._scrollableElement.updateOptions(this._getChangeOptions()))),this._register(i.onProtocolChange(e=>{this._scrollableElement.updateOptions({handleMouseWheel:!(16&e)})})),this._scrollableElement.setScrollDimensions({height:0,scrollHeight:0}),this._register(vY.runAndSubscribe(a.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=a.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(vj(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=n.mainDocument.createElement("style"),r.appendChild(this._styleElement),this._register(vj(()=>this._styleElement.remove())),this._register(vY.runAndSubscribe(a.onChangeColors,()=>{this._styleElement.textContent=[".xterm .xterm-scrollable-element > .scrollbar > .slider {",` background: ${a.colors.scrollbarSliderBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider:hover {",` background: ${a.colors.scrollbarSliderHoverBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider.active {",` background: ${a.colors.scrollbarSliderActiveBackground.css};`,"}"].join(`
22
+ `)})),this._register(this._bufferService.onResize(()=>this.queueSync())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._latestYDisp=void 0,this.queueSync()})),this._register(this._bufferService.onScroll(()=>this._sync())),this._register(this._scrollableElement.onScroll(e=>this._handleScroll(e)))}scrollLines(e){let r=this._scrollableElement.getScrollPosition();this._scrollableElement.setScrollPosition({reuseAnimation:!0,scrollTop:r.scrollTop+e*this._renderService.dimensions.css.cell.height})}scrollToLine(e,r){r&&(this._latestYDisp=e),this._scrollableElement.setScrollPosition({reuseAnimation:!r,scrollTop:e*this._renderService.dimensions.css.cell.height})}_getChangeOptions(){return{mouseWheelScrollSensitivity:this._optionsService.rawOptions.scrollSensitivity,fastScrollSensitivity:this._optionsService.rawOptions.fastScrollSensitivity,verticalScrollbarSize:this._optionsService.rawOptions.overviewRuler?.width||14}}queueSync(e){void 0!==e&&(this._latestYDisp=e),void 0===this._queuedAnimationFrame&&(this._queuedAnimationFrame=this._renderService.addRefreshCallback(()=>{this._queuedAnimationFrame=void 0,this._sync(this._latestYDisp)}))}_sync(e=this._bufferService.buffer.ydisp){!this._renderService||this._isSyncing||(this._isSyncing=!0,this._suppressOnScrollHandler=!0,this._scrollableElement.setScrollDimensions({height:this._renderService.dimensions.css.canvas.height,scrollHeight:this._renderService.dimensions.css.cell.height*this._bufferService.buffer.lines.length}),this._suppressOnScrollHandler=!1,e!==this._latestYDisp&&this._scrollableElement.setScrollPosition({scrollTop:e*this._renderService.dimensions.css.cell.height}),this._isSyncing=!1)}_handleScroll(e){if(!this._renderService||this._isHandlingScroll||this._suppressOnScrollHandler)return;this._isHandlingScroll=!0;let r=Math.round(e.scrollTop/this._renderService.dimensions.css.cell.height),s=r-this._bufferService.buffer.ydisp;0!==s&&(this._latestYDisp=r,this._onRequestScrollLines.fire(s)),this._isHandlingScroll=!1}};bS=x$([xW(2,x4),xW(3,vo),xW(4,x6),xW(5,vh),xW(6,vt),xW(7,vc)],bS);var bk=class extends vE{constructor(e,r,s,n,i){super(),this._screenElement=e,this._bufferService=r,this._coreBrowserService=s,this._decorationService=n,this._renderService=i,this._decorationElements=new Map,this._altBufferIsActive=!1,this._dimensionsChanged=!1,this._container=document.createElement("div"),this._container.classList.add("xterm-decoration-container"),this._screenElement.appendChild(this._container),this._register(this._renderService.onRenderedViewportChange(()=>this._doRefreshDecorations())),this._register(this._renderService.onDimensionsChange(()=>{this._dimensionsChanged=!0,this._queueRefresh()})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._altBufferIsActive=this._bufferService.buffer===this._bufferService.buffers.alt})),this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh())),this._register(this._decorationService.onDecorationRemoved(e=>this._removeDecoration(e))),this._register(vj(()=>{this._container.remove(),this._decorationElements.clear()}))}_queueRefresh(){void 0===this._animationFrame&&(this._animationFrame=this._renderService.addRefreshCallback(()=>{this._doRefreshDecorations(),this._animationFrame=void 0}))}_doRefreshDecorations(){for(let e of this._decorationService.decorations)this._renderDecoration(e);this._dimensionsChanged=!1}_renderDecoration(e){this._refreshStyle(e),this._dimensionsChanged&&this._refreshXPosition(e)}_createElement(e){let r=this._coreBrowserService.mainDocument.createElement("div");r.classList.add("xterm-decoration"),r.classList.toggle("xterm-decoration-top-layer",e?.options?.layer==="top"),r.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,r.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,r.style.top=`${(e.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height}px`,r.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`;let s=e.options.x??0;return s&&s>this._bufferService.cols&&(r.style.display="none"),this._refreshXPosition(e,r),r}_refreshStyle(e){let r=e.marker.line-this._bufferService.buffers.active.ydisp;if(r<0||r>=this._bufferService.rows)e.element&&(e.element.style.display="none",e.onRenderEmitter.fire(e.element));else{let s=this._decorationElements.get(e);s||(s=this._createElement(e),e.element=s,this._decorationElements.set(e,s),this._container.appendChild(s),e.onDispose(()=>{this._decorationElements.delete(e),s.remove()})),s.style.display=this._altBufferIsActive?"none":"block",this._altBufferIsActive||(s.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,s.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,s.style.top=`${r*this._renderService.dimensions.css.cell.height}px`,s.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`),e.onRenderEmitter.fire(s)}}_refreshXPosition(e,r=e.element){if(!r)return;let s=e.options.x??0;"right"===(e.options.anchor||"left")?r.style.right=s?`${s*this._renderService.dimensions.css.cell.width}px`:"":r.style.left=s?`${s*this._renderService.dimensions.css.cell.width}px`:""}_removeDecoration(e){this._decorationElements.get(e)?.remove(),this._decorationElements.delete(e),e.dispose()}};bk=x$([xW(1,x4),xW(2,vo),xW(3,vn),xW(4,vc)],bk);var bj=class{constructor(){this._zones=[],this._zonePool=[],this._zonePoolIndex=0,this._linePadding={full:0,left:0,center:0,right:0}}get zones(){return this._zonePool.length=Math.min(this._zonePool.length,this._zones.length),this._zones}clear(){this._zones.length=0,this._zonePoolIndex=0}addDecoration(e){if(e.options.overviewRulerOptions){for(let r of this._zones)if(r.color===e.options.overviewRulerOptions.color&&r.position===e.options.overviewRulerOptions.position){if(this._lineIntersectsZone(r,e.marker.line))return;if(this._lineAdjacentToZone(r,e.marker.line,e.options.overviewRulerOptions.position))return void this._addLineToZone(r,e.marker.line)}if(this._zonePoolIndex<this._zonePool.length){this._zonePool[this._zonePoolIndex].color=e.options.overviewRulerOptions.color,this._zonePool[this._zonePoolIndex].position=e.options.overviewRulerOptions.position,this._zonePool[this._zonePoolIndex].startBufferLine=e.marker.line,this._zonePool[this._zonePoolIndex].endBufferLine=e.marker.line,this._zones.push(this._zonePool[this._zonePoolIndex++]);return}this._zones.push({color:e.options.overviewRulerOptions.color,position:e.options.overviewRulerOptions.position,startBufferLine:e.marker.line,endBufferLine:e.marker.line}),this._zonePool.push(this._zones[this._zones.length-1]),this._zonePoolIndex++}}setPadding(e){this._linePadding=e}_lineIntersectsZone(e,r){return r>=e.startBufferLine&&r<=e.endBufferLine}_lineAdjacentToZone(e,r,s){return r>=e.startBufferLine-this._linePadding[s||"full"]&&r<=e.endBufferLine+this._linePadding[s||"full"]}_addLineToZone(e,r){e.startBufferLine=Math.min(e.startBufferLine,r),e.endBufferLine=Math.max(e.endBufferLine,r)}},bC={full:0,left:0,center:0,right:0},bN={full:0,left:0,center:0,right:0},bE={full:0,left:0,center:0,right:0},bD=class extends vE{constructor(e,r,s,n,i,a,o,l){super(),this._viewportElement=e,this._screenElement=r,this._bufferService=s,this._decorationService=n,this._renderService=i,this._optionsService=a,this._themeService=o,this._coreBrowserService=l,this._colorZoneStore=new bj,this._shouldUpdateDimensions=!0,this._shouldUpdateAnchor=!0,this._lastKnownBufferLength=0,this._canvas=this._coreBrowserService.mainDocument.createElement("canvas"),this._canvas.classList.add("xterm-decoration-overview-ruler"),this._refreshCanvasDimensions(),this._viewportElement.parentElement?.insertBefore(this._canvas,this._viewportElement),this._register(vj(()=>this._canvas?.remove()));let c=this._canvas.getContext("2d");if(c)this._ctx=c;else throw Error("Ctx cannot be null");this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh(void 0,!0))),this._register(this._decorationService.onDecorationRemoved(()=>this._queueRefresh(void 0,!0))),this._register(this._renderService.onRenderedViewportChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._canvas.style.display=this._bufferService.buffer===this._bufferService.buffers.alt?"none":"block"})),this._register(this._bufferService.onScroll(()=>{this._lastKnownBufferLength!==this._bufferService.buffers.normal.lines.length&&(this._refreshDrawHeightConstants(),this._refreshColorZonePadding())})),this._register(this._renderService.onRender(()=>{this._containerHeight&&this._containerHeight===this._screenElement.clientHeight||(this._queueRefresh(!0),this._containerHeight=this._screenElement.clientHeight)})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh(!0))),this._register(this._optionsService.onSpecificOptionChange("overviewRuler",()=>this._queueRefresh(!0))),this._register(this._themeService.onChangeColors(()=>this._queueRefresh())),this._queueRefresh(!0)}get _width(){return this._optionsService.options.overviewRuler?.width||0}_refreshDrawConstants(){let e=Math.floor((this._canvas.width-1)/3),r=Math.ceil((this._canvas.width-1)/3);bN.full=this._canvas.width,bN.left=e,bN.center=r,bN.right=e,this._refreshDrawHeightConstants(),bE.full=1,bE.left=1,bE.center=1+bN.left,bE.right=1+bN.left+bN.center}_refreshDrawHeightConstants(){bC.full=Math.round(2*this._coreBrowserService.dpr);let e=Math.round(Math.max(Math.min(this._canvas.height/this._bufferService.buffer.lines.length,12),6)*this._coreBrowserService.dpr);bC.left=e,bC.center=e,bC.right=e}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*bC.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*bC.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*bC.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*bC.right)}),this._lastKnownBufferLength=this._bufferService.buffers.normal.lines.length}_refreshCanvasDimensions(){this._canvas.style.width=`${this._width}px`,this._canvas.width=Math.round(this._width*this._coreBrowserService.dpr),this._canvas.style.height=`${this._screenElement.clientHeight}px`,this._canvas.height=Math.round(this._screenElement.clientHeight*this._coreBrowserService.dpr),this._refreshDrawConstants(),this._refreshColorZonePadding()}_refreshDecorations(){for(let e of(this._shouldUpdateDimensions&&this._refreshCanvasDimensions(),this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height),this._colorZoneStore.clear(),this._decorationService.decorations))this._colorZoneStore.addDecoration(e);this._ctx.lineWidth=1,this._renderRulerOutline();let e=this._colorZoneStore.zones;for(let r of e)"full"!==r.position&&this._renderColorZone(r);for(let r of e)"full"===r.position&&this._renderColorZone(r);this._shouldUpdateDimensions=!1,this._shouldUpdateAnchor=!1}_renderRulerOutline(){this._ctx.fillStyle=this._themeService.colors.overviewRulerBorder.css,this._ctx.fillRect(0,0,1,this._canvas.height),this._optionsService.rawOptions.overviewRuler.showTopBorder&&this._ctx.fillRect(1,0,this._canvas.width-1,1),this._optionsService.rawOptions.overviewRuler.showBottomBorder&&this._ctx.fillRect(1,this._canvas.height-1,this._canvas.width-1,this._canvas.height)}_renderColorZone(e){this._ctx.fillStyle=e.color,this._ctx.fillRect(bE[e.position||"full"],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-bC[e.position||"full"]/2),bN[e.position||"full"],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+bC[e.position||"full"]))}_queueRefresh(e,r){this._shouldUpdateDimensions=e||this._shouldUpdateDimensions,this._shouldUpdateAnchor=r||this._shouldUpdateAnchor,void 0===this._animationFrame&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._refreshDecorations(),this._animationFrame=void 0}))}};bD=x$([xW(2,x4),xW(3,vn),xW(4,vc),xW(5,vt),xW(6,vh),xW(7,vo)],bD),(g=bF||={}).NUL="\0",g.SOH="\x01",g.STX="\x02",g.ETX="\x03",g.EOT="\x04",g.ENQ="\x05",g.ACK="\x06",g.BEL="\x07",g.BS="\b",g.HT=" ",g.LF=`
23
+ `,g.VT="\v",g.FF="\f",g.CR="\r",g.SO="\x0e",g.SI="\x0f",g.DLE="\x10",g.DC1="\x11",g.DC2="\x12",g.DC3="\x13",g.DC4="\x14",g.NAK="\x15",g.SYN="\x16",g.ETB="\x17",g.CAN="\x18",g.EM="\x19",g.SUB="\x1a",g.ESC="\x1b",g.FS="\x1c",g.GS="\x1d",g.RS="\x1e",g.US="\x1f",g.SP=" ",g.DEL="",(x=bL||={}).PAD="€",x.HOP="",x.BPH="‚",x.NBH="ƒ",x.IND="„",x.NEL="…",x.SSA="†",x.ESA="‡",x.HTS="ˆ",x.HTJ="‰",x.VTS="Š",x.PLD="‹",x.PLU="Œ",x.RI="",x.SS2="Ž",x.SS3="",x.DCS="",x.PU1="‘",x.PU2="’",x.STS="“",x.CCH="”",x.MW="•",x.SPA="–",x.EPA="—",x.SOS="˜",x.SGCI="™",x.SCI="š",x.CSI="›",x.ST="œ",x.OSC="",x.PM="ž",x.APC="Ÿ",(bO||={}).ST=`${bF.ESC}\\`;var bT=class{constructor(e,r,s,n,i,a){this._textarea=e,this._compositionView=r,this._bufferService=s,this._optionsService=n,this._coreService=i,this._renderService=a,this._isComposing=!1,this._isSendingComposition=!1,this._compositionPosition={start:0,end:0},this._dataAlreadySent=""}get isComposing(){return this._isComposing}compositionstart(){this._isComposing=!0,this._compositionPosition.start=this._textarea.value.length,this._compositionView.textContent="",this._dataAlreadySent="",this._compositionView.classList.add("active")}compositionupdate(e){this._compositionView.textContent=e.data,this.updateCompositionElements(),setTimeout(()=>{this._compositionPosition.end=this._textarea.value.length},0)}compositionend(){this._finalizeComposition(!0)}keydown(e){if(this._isComposing||this._isSendingComposition){if(20===e.keyCode||229===e.keyCode||16===e.keyCode||17===e.keyCode||18===e.keyCode)return!1;this._finalizeComposition(!1)}return 229!==e.keyCode||(this._handleAnyTextareaChanges(),!1)}_finalizeComposition(e){if(this._compositionView.classList.remove("active"),this._isComposing=!1,e){let e={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout(()=>{if(this._isSendingComposition){let r;this._isSendingComposition=!1,e.start+=this._dataAlreadySent.length,(r=this._isComposing?this._textarea.value.substring(e.start,this._compositionPosition.start):this._textarea.value.substring(e.start)).length>0&&this._coreService.triggerDataEvent(r,!0)}},0)}else{this._isSendingComposition=!1;let e=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(e,!0)}}_handleAnyTextareaChanges(){let e=this._textarea.value;setTimeout(()=>{if(!this._isComposing){let r=this._textarea.value,s=r.replace(e,"");this._dataAlreadySent=s,r.length>e.length?this._coreService.triggerDataEvent(s,!0):r.length<e.length?this._coreService.triggerDataEvent(`${bF.DEL}`,!0):r.length===e.length&&r!==e&&this._coreService.triggerDataEvent(r,!0)}},0)}updateCompositionElements(e){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){let e=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),r=this._renderService.dimensions.css.cell.height,s=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,n=e*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=n+"px",this._compositionView.style.top=s+"px",this._compositionView.style.height=r+"px",this._compositionView.style.lineHeight=r+"px",this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+"px";let i=this._compositionView.getBoundingClientRect();this._textarea.style.left=n+"px",this._textarea.style.top=s+"px",this._textarea.style.width=Math.max(i.width,1)+"px",this._textarea.style.height=Math.max(i.height,1)+"px",this._textarea.style.lineHeight=i.height+"px"}e||setTimeout(()=>this.updateCompositionElements(!0),0)}}};bT=x$([xW(2,x4),xW(3,vt),xW(4,x7),xW(5,vc)],bT);var bR,bA,bM,bI,bP,bF,bL,bO,bB,bz=0,b$=0,bW=0,bH=0,bU={css:"#00000000",rgba:0};(_y=bB||={}).toCss=function(e,r,s,n){return void 0!==n?`#${bZ(e)}${bZ(r)}${bZ(s)}${bZ(n)}`:`#${bZ(e)}${bZ(r)}${bZ(s)}`},_y.toRgba=function(e,r,s,n=255){return(e<<24|r<<16|s<<8|n)>>>0},_y.toColor=function(e,r,s,n){return{css:_y.toCss(e,r,s,n),rgba:_y.toRgba(e,r,s,n)}};var bV=_b||={};function bq(e,r){return bH=Math.round(255*r),[bz,b$,bW]=_S.toChannels(e.rgba),{css:bB.toCss(bz,b$,bW,bH),rgba:bB.toRgba(bz,b$,bW,bH)}}bV.blend=function(e,r){if(1==(bH=(255&r.rgba)/255))return{css:r.css,rgba:r.rgba};let s=r.rgba>>24&255,n=r.rgba>>16&255,i=r.rgba>>8&255,a=e.rgba>>24&255,o=e.rgba>>16&255,l=e.rgba>>8&255;return bz=a+Math.round((s-a)*bH),b$=o+Math.round((n-o)*bH),bW=l+Math.round((i-l)*bH),{css:bB.toCss(bz,b$,bW),rgba:bB.toRgba(bz,b$,bW)}},bV.isOpaque=function(e){return(255&e.rgba)==255},bV.ensureContrastRatio=function(e,r,s){let n=_S.ensureContrastRatio(e.rgba,r.rgba,s);if(n)return bB.toColor(n>>24&255,n>>16&255,n>>8&255)},bV.opaque=function(e){let r=(255|e.rgba)>>>0;return[bz,b$,bW]=_S.toChannels(r),{css:bB.toCss(bz,b$,bW),rgba:r}},bV.opacity=bq,bV.multiplyOpacity=function(e,r){return bH=255&e.rgba,bq(e,bH*r/255)},bV.toColorRGB=function(e){return[e.rgba>>24&255,e.rgba>>16&255,e.rgba>>8&255]},(e=>{let r,s;try{let e=document.createElement("canvas");e.width=1,e.height=1;let n=e.getContext("2d",{willReadFrequently:!0});n&&((r=n).globalCompositeOperation="copy",s=r.createLinearGradient(0,0,1,1))}catch{}e.toColor=function(e){if(e.match(/#[\da-f]{3,8}/i))switch(e.length){case 4:return bz=parseInt(e.slice(1,2).repeat(2),16),b$=parseInt(e.slice(2,3).repeat(2),16),bW=parseInt(e.slice(3,4).repeat(2),16),bB.toColor(bz,b$,bW);case 5:return bz=parseInt(e.slice(1,2).repeat(2),16),b$=parseInt(e.slice(2,3).repeat(2),16),bW=parseInt(e.slice(3,4).repeat(2),16),bH=parseInt(e.slice(4,5).repeat(2),16),bB.toColor(bz,b$,bW,bH);case 7:return{css:e,rgba:(parseInt(e.slice(1),16)<<8|255)>>>0};case 9:return{css:e,rgba:parseInt(e.slice(1),16)>>>0}}let n=e.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(n)return bz=parseInt(n[1]),b$=parseInt(n[2]),bW=parseInt(n[3]),bH=Math.round((void 0===n[5]?1:parseFloat(n[5]))*255),bB.toColor(bz,b$,bW,bH);if(!r||!s||(r.fillStyle=s,r.fillStyle=e,"string"!=typeof r.fillStyle)||(r.fillRect(0,0,1,1),[bz,b$,bW,bH]=r.getImageData(0,0,1,1).data,255!==bH))throw Error("css.toColor: Unsupported css format");return{rgba:bB.toRgba(bz,b$,bW,bH),css:e}}})(_w||={});var bK=__||={};function bX(e,r,s){let n=e/255,i=r/255,a=s/255;return .2126*(n<=.03928?n/12.92:Math.pow((n+.055)/1.055,2.4))+.7152*(i<=.03928?i/12.92:Math.pow((i+.055)/1.055,2.4))+.0722*(a<=.03928?a/12.92:Math.pow((a+.055)/1.055,2.4))}bK.relativeLuminance=function(e){return bX(e>>16&255,e>>8&255,255&e)},bK.relativeLuminance2=bX;var bY=_S||={};function bG(e,r,s){let n=e>>24&255,i=e>>16&255,a=e>>8&255,o=r>>24&255,l=r>>16&255,c=r>>8&255,d=bQ(__.relativeLuminance2(o,l,c),__.relativeLuminance2(n,i,a));for(;d<s&&(o>0||l>0||c>0);)o-=Math.max(0,Math.ceil(.1*o)),l-=Math.max(0,Math.ceil(.1*l)),c-=Math.max(0,Math.ceil(.1*c)),d=bQ(__.relativeLuminance2(o,l,c),__.relativeLuminance2(n,i,a));return(o<<24|l<<16|c<<8|255)>>>0}function bJ(e,r,s){let n=e>>24&255,i=e>>16&255,a=e>>8&255,o=r>>24&255,l=r>>16&255,c=r>>8&255,d=bQ(__.relativeLuminance2(o,l,c),__.relativeLuminance2(n,i,a));for(;d<s&&(o<255||l<255||c<255);)o=Math.min(255,o+Math.ceil((255-o)*.1)),l=Math.min(255,l+Math.ceil((255-l)*.1)),c=Math.min(255,c+Math.ceil((255-c)*.1)),d=bQ(__.relativeLuminance2(o,l,c),__.relativeLuminance2(n,i,a));return(o<<24|l<<16|c<<8|255)>>>0}function bZ(e){let r=e.toString(16);return r.length<2?"0"+r:r}function bQ(e,r){return e<r?(r+.05)/(e+.05):(e+.05)/(r+.05)}bY.blend=function(e,r){if(1==(bH=(255&r)/255))return r;let s=e>>24&255,n=e>>16&255,i=e>>8&255;return bz=s+Math.round(((r>>24&255)-s)*bH),b$=n+Math.round(((r>>16&255)-n)*bH),bW=i+Math.round(((r>>8&255)-i)*bH),bB.toRgba(bz,b$,bW)},bY.ensureContrastRatio=function(e,r,s){let n=__.relativeLuminance(e>>8),i=__.relativeLuminance(r>>8);if(bQ(n,i)<s){if(i<n){let i=bG(e,r,s),a=bQ(n,__.relativeLuminance(i>>8));if(a<s){let o=bJ(e,r,s);return a>bQ(n,__.relativeLuminance(o>>8))?i:o}return i}let a=bJ(e,r,s),o=bQ(n,__.relativeLuminance(a>>8));if(o<s){let i=bG(e,r,s);return o>bQ(n,__.relativeLuminance(i>>8))?a:i}return a}},bY.reduceLuminance=bG,bY.increaseLuminance=bJ,bY.toChannels=function(e){return[e>>24&255,e>>16&255,e>>8&255,255&e]};var b0=class extends xZ{constructor(e,r,s){super(),this.content=0,this.combinedData="",this.fg=e.fg,this.bg=e.bg,this.combinedData=r,this._width=s}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(e){throw Error("not implemented")}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},b1=class{constructor(e){this._bufferService=e,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new x0}register(e){let r={id:this._nextCharacterJoinerId++,handler:e};return this._characterJoiners.push(r),r.id}deregister(e){for(let r=0;r<this._characterJoiners.length;r++)if(this._characterJoiners[r].id===e)return this._characterJoiners.splice(r,1),!0;return!1}getJoinedCharacters(e){if(0===this._characterJoiners.length)return[];let r=this._bufferService.buffer.lines.get(e);if(!r||0===r.length)return[];let s=[],n=r.translateToString(!0),i=0,a=0,o=0,l=r.getFg(0),c=r.getBg(0);for(let e=0;e<r.getTrimmedLength();e++)if(r.loadCell(e,this._workCell),0!==this._workCell.getWidth()){if(this._workCell.fg!==l||this._workCell.bg!==c){if(e-i>1){let e=this._getJoinedRanges(n,o,a,r,i);for(let r=0;r<e.length;r++)s.push(e[r])}i=e,o=a,l=this._workCell.fg,c=this._workCell.bg}a+=this._workCell.getChars().length||1}if(this._bufferService.cols-i>1){let e=this._getJoinedRanges(n,o,a,r,i);for(let r=0;r<e.length;r++)s.push(e[r])}return s}_getJoinedRanges(e,r,s,n,i){let a=e.substring(r,s),o=[];try{o=this._characterJoiners[0].handler(a)}catch(e){console.error(e)}for(let e=1;e<this._characterJoiners.length;e++)try{let r=this._characterJoiners[e].handler(a);for(let e=0;e<r.length;e++)b1._mergeRanges(o,r[e])}catch(e){console.error(e)}return this._stringRangesToCellRanges(o,n,i),o}_stringRangesToCellRanges(e,r,s){let n=0,i=!1,a=0,o=e[0];if(o){for(let l=s;l<this._bufferService.cols;l++){let s=r.getWidth(l),c=r.getString(l).length||1;if(0!==s){if(!i&&o[0]<=a&&(o[0]=l,i=!0),o[1]<=a){if(o[1]=l,!(o=e[++n]))break;o[0]<=a?(o[0]=l,i=!0):i=!1}a+=c}}o&&(o[1]=this._bufferService.cols)}}static _mergeRanges(e,r){let s=!1;for(let n=0;n<e.length;n++){let i=e[n];if(s){if(r[1]<=i[0])return e[n-1][1]=r[1],e;if(r[1]<=i[1])return e[n-1][1]=Math.max(r[1],i[1]),e.splice(n,1),e;e.splice(n,1),n--}else{if(r[1]<=i[0])return e.splice(n,0,r),e;if(r[1]<=i[1])return i[0]=Math.min(r[0],i[0]),e;r[0]<i[1]&&(i[0]=Math.min(r[0],i[0]),s=!0);continue}}return s?e[e.length-1][1]=r[1]:e.push(r),e}};function b2(){return{width:0,height:0}}b1=x$([xW(0,x4)],b1);var b5=class{constructor(e,r,s,n,i,a,o){this._document=e,this._characterJoinerService=r,this._optionsService=s,this._coreBrowserService=n,this._coreService=i,this._decorationService=a,this._themeService=o,this._workCell=new x0,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(e,r,s){this._selectionStart=e,this._selectionEnd=r,this._columnSelectMode=s}createRow(e,r,s,n,i,a,o,l,c,d,u){let h=[],f=this._characterJoinerService.getJoinedCharacters(r),p=this._themeService.colors,m=e.getNoBgTrimmedLength();s&&m<a+1&&(m=a+1);let g,x=0,v="",y=0,b=0,w=0,_=0,S=!1,k=0,j=!1,C=0,N=0,E=[],D=-1!==d&&-1!==u;for(let T=0;T<m;T++){let m;e.loadCell(T,this._workCell);let R=this._workCell.getWidth();if(0===R)continue;let A=!1,M=T>=N,I=T,P=this._workCell;if(f.length>0&&T===f[0][0]&&M){let n=f.shift(),i=this._isCellInSelection(n[0],r);for(y=n[0]+1;y<n[1];y++)M&&=i===this._isCellInSelection(y,r);(M&&=!s||a<n[0]||a>=n[1])?(A=!0,P=new b0(this._workCell,e.translateToString(!0,n[0],n[1]),n[1]-n[0]),I=n[1]-1,R=P.getWidth()):N=n[1]}let F=this._isCellInSelection(T,r),L=s&&T===a,O=D&&T>=d&&T<=u,B=!1;this._decorationService.forEachDecorationAtCell(T,r,void 0,e=>{B=!0});let z=P.getChars()||" ";if(" "===z&&(P.isUnderline()||P.isOverline())&&(z=" "),C=R*l-c.get(z,P.isBold(),P.isItalic()),g)if(x&&(F&&j||!F&&!j&&P.bg===b)&&(F&&j&&p.selectionForeground||P.fg===w)&&P.extended.ext===_&&O===S&&C===k&&!L&&!A&&!B&&M){P.isInvisible()?v+=" ":v+=z,x++;continue}else x&&(g.textContent=v),g=this._document.createElement("span"),x=0,v="";else g=this._document.createElement("span");if(b=P.bg,w=P.fg,_=P.extended.ext,S=O,k=C,j=F,A&&a>=T&&a<=I&&(a=T),!this._coreService.isCursorHidden&&L&&this._coreService.isCursorInitialized){if(E.push("xterm-cursor"),this._coreBrowserService.isFocused)o&&E.push("xterm-cursor-blink"),E.push("bar"===n?"xterm-cursor-bar":"underline"===n?"xterm-cursor-underline":"xterm-cursor-block");else if(i)switch(i){case"outline":E.push("xterm-cursor-outline");break;case"block":E.push("xterm-cursor-block");break;case"bar":E.push("xterm-cursor-bar");break;case"underline":E.push("xterm-cursor-underline")}}if(P.isBold()&&E.push("xterm-bold"),P.isItalic()&&E.push("xterm-italic"),P.isDim()&&E.push("xterm-dim"),v=P.isInvisible()?" ":P.getChars()||" ",P.isUnderline()&&(E.push(`xterm-underline-${P.extended.underlineStyle}`)," "===v&&(v=" "),!P.isUnderlineColorDefault()))if(P.isUnderlineColorRGB())g.style.textDecorationColor=`rgb(${xZ.toColorRGB(P.getUnderlineColor()).join(",")})`;else{let e=P.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&P.isBold()&&e<8&&(e+=8),g.style.textDecorationColor=p.ansi[e].css}P.isOverline()&&(E.push("xterm-overline")," "===v&&(v=" ")),P.isStrikethrough()&&E.push("xterm-strikethrough"),O&&(g.style.textDecoration="underline");let $=P.getFgColor(),W=P.getFgColorMode(),H=P.getBgColor(),U=P.getBgColorMode(),V=!!P.isInverse();if(V){let e=$;$=H,H=e;let r=W;W=U,U=r}let q,K,X=!1;switch(this._decorationService.forEachDecorationAtCell(T,r,void 0,e=>{"top"!==e.options.layer&&X||(e.backgroundColorRGB&&(U=0x3000000,H=e.backgroundColorRGB.rgba>>8&0xffffff,q=e.backgroundColorRGB),e.foregroundColorRGB&&(W=0x3000000,$=e.foregroundColorRGB.rgba>>8&0xffffff,K=e.foregroundColorRGB),X="top"===e.options.layer)}),!X&&F&&(H=(q=this._coreBrowserService.isFocused?p.selectionBackgroundOpaque:p.selectionInactiveBackgroundOpaque).rgba>>8&0xffffff,U=0x3000000,X=!0,p.selectionForeground&&(W=0x3000000,$=p.selectionForeground.rgba>>8&0xffffff,K=p.selectionForeground)),X&&E.push("xterm-decoration-top"),U){case 0x1000000:case 0x2000000:m=p.ansi[H],E.push(`xterm-bg-${H}`);break;case 0x3000000:m=bB.toColor(H>>16,H>>8&255,255&H),this._addStyle(g,`background-color:#${b3((H>>>0).toString(16),"0",6)}`);break;default:V?(m=p.foreground,E.push("xterm-bg-257")):m=p.background}switch(q||P.isDim()&&(q=_b.multiplyOpacity(m,.5)),W){case 0x1000000:case 0x2000000:P.isBold()&&$<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&($+=8),this._applyMinimumContrast(g,m,p.ansi[$],P,q,void 0)||E.push(`xterm-fg-${$}`);break;case 0x3000000:let Y=bB.toColor($>>16&255,$>>8&255,255&$);this._applyMinimumContrast(g,m,Y,P,q,K)||this._addStyle(g,`color:#${b3($.toString(16),"0",6)}`);break;default:this._applyMinimumContrast(g,m,p.foreground,P,q,K)||V&&E.push("xterm-fg-257")}E.length&&(g.className=E.join(" "),E.length=0),L||A||B||!M?g.textContent=v:x++,C!==this.defaultSpacing&&(g.style.letterSpacing=`${C}px`),h.push(g),T=I}return g&&x&&(g.textContent=v),h}_applyMinimumContrast(e,r,s,n,i,a){var o,l,c;if(1===this._optionsService.rawOptions.minimumContrastRatio||57508<=(l=o=n.getCode())&&l<=57558||9472<=(c=o)&&c<=9631)return!1;let d=this._getContrastCache(n),u;if(i||a||(u=d.getColor(r.rgba,s.rgba)),void 0===u){let e=this._optionsService.rawOptions.minimumContrastRatio/(n.isDim()?2:1);u=_b.ensureContrastRatio(i||r,a||s,e),d.setColor((i||r).rgba,(a||s).rgba,u??null)}return!!u&&(this._addStyle(e,`color:${u.css}`),!0)}_getContrastCache(e){return e.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(e,r){e.setAttribute("style",`${e.getAttribute("style")||""}${r};`)}_isCellInSelection(e,r){let s=this._selectionStart,n=this._selectionEnd;return!!s&&!!n&&(this._columnSelectMode?s[0]<=n[0]?e>=s[0]&&r>=s[1]&&e<n[0]&&r<=n[1]:e<s[0]&&r>=s[1]&&e>=n[0]&&r<=n[1]:r>s[1]&&r<n[1]||s[1]===n[1]&&r===s[1]&&e>=s[0]&&e<n[0]||s[1]<n[1]&&r===n[1]&&e<n[0]||s[1]<n[1]&&r===s[1]&&e>=s[0])}};function b3(e,r,s){for(;e.length<s;)e=r+e;return e}b5=x$([xW(1,vu),xW(2,vt),xW(3,vo),xW(4,x7),xW(5,vn),xW(6,vh)],b5);var b4=class{constructor(e,r){this._flat=new Float32Array(256),this._font="",this._fontSize=0,this._weight="normal",this._weightBold="bold",this._measureElements=[],this._container=e.createElement("div"),this._container.classList.add("xterm-width-cache-measure-container"),this._container.setAttribute("aria-hidden","true"),this._container.style.whiteSpace="pre",this._container.style.fontKerning="none";let s=e.createElement("span");s.classList.add("xterm-char-measure-element");let n=e.createElement("span");n.classList.add("xterm-char-measure-element"),n.style.fontWeight="bold";let i=e.createElement("span");i.classList.add("xterm-char-measure-element"),i.style.fontStyle="italic";let a=e.createElement("span");a.classList.add("xterm-char-measure-element"),a.style.fontWeight="bold",a.style.fontStyle="italic",this._measureElements=[s,n,i,a],this._container.appendChild(s),this._container.appendChild(n),this._container.appendChild(i),this._container.appendChild(a),r.appendChild(this._container),this.clear()}dispose(){this._container.remove(),this._measureElements.length=0,this._holey=void 0}clear(){this._flat.fill(-9999),this._holey=new Map}setFont(e,r,s,n){e===this._font&&r===this._fontSize&&s===this._weight&&n===this._weightBold||(this._font=e,this._fontSize=r,this._weight=s,this._weightBold=n,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${s}`,this._measureElements[1].style.fontWeight=`${n}`,this._measureElements[2].style.fontWeight=`${s}`,this._measureElements[3].style.fontWeight=`${n}`,this.clear())}get(e,r,s){let n=0;if(!r&&!s&&1===e.length&&(n=e.charCodeAt(0))<256){if(-9999!==this._flat[n])return this._flat[n];let r=this._measure(e,0);return r>0&&(this._flat[n]=r),r}let i=e;r&&(i+="B"),s&&(i+="I");let a=this._holey.get(i);if(void 0===a){let n=0;r&&(n|=1),s&&(n|=2),(a=this._measure(e,n))>0&&this._holey.set(i,a)}return a}_measure(e,r){let s=this._measureElements[r];return s.textContent=e.repeat(32),s.offsetWidth/32}},b6=class{constructor(){this.clear()}clear(){this.hasSelection=!1,this.columnSelectMode=!1,this.viewportStartRow=0,this.viewportEndRow=0,this.viewportCappedStartRow=0,this.viewportCappedEndRow=0,this.startCol=0,this.endCol=0,this.selectionStart=void 0,this.selectionEnd=void 0}update(e,r,s,n=!1){if(this.selectionStart=r,this.selectionEnd=s,!r||!s||r[0]===s[0]&&r[1]===s[1])return void this.clear();let i=e.buffers.active.ydisp,a=r[1]-i,o=s[1]-i,l=Math.max(a,0),c=Math.min(o,e.rows-1);l>=e.rows||c<0?this.clear():(this.hasSelection=!0,this.columnSelectMode=n,this.viewportStartRow=a,this.viewportEndRow=o,this.viewportCappedStartRow=l,this.viewportCappedEndRow=c,this.startCol=r[0],this.endCol=s[0])}isCellSelected(e,r,s){return!!this.hasSelection&&(s-=e.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?r>=this.startCol&&s>=this.viewportCappedStartRow&&r<this.endCol&&s<=this.viewportCappedEndRow:r<this.startCol&&s>=this.viewportCappedStartRow&&r>=this.endCol&&s<=this.viewportCappedEndRow:s>this.viewportStartRow&&s<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&s===this.viewportStartRow&&r>=this.startCol&&r<this.endCol||this.viewportStartRow<this.viewportEndRow&&s===this.viewportEndRow&&r<this.endCol||this.viewportStartRow<this.viewportEndRow&&s===this.viewportStartRow&&r>=this.startCol)}},b7="xterm-dom-renderer-owner-",b8="xterm-rows",b9="xterm-fg-",we="xterm-bg-",wt="xterm-focus",wr="xterm-selection",ws=1,wn=class extends vE{constructor(e,r,s,n,i,a,o,l,c,d,u,h,f,p){super(),this._terminal=e,this._document=r,this._element=s,this._screenElement=n,this._viewportElement=i,this._helperContainer=a,this._linkifier2=o,this._charSizeService=c,this._optionsService=d,this._bufferService=u,this._coreService=h,this._coreBrowserService=f,this._themeService=p,this._terminalClass=ws++,this._rowElements=[],this._selectionRenderModel=new b6,this.onRequestRedraw=this._register(new v2).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(b8),this._rowContainer.style.lineHeight="normal",this._rowContainer.setAttribute("aria-hidden","true"),this._refreshRowElements(this._bufferService.cols,this._bufferService.rows),this._selectionContainer=this._document.createElement("div"),this._selectionContainer.classList.add(wr),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions={css:{canvas:b2(),cell:b2()},device:{canvas:b2(),cell:b2(),char:{width:0,height:0,left:0,top:0}}},this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(e=>this._injectCss(e))),this._injectCss(this._themeService.colors),this._rowFactory=l.createInstance(b5,document),this._element.classList.add(b7+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(e=>this._handleLinkHover(e))),this._register(this._linkifier2.onHideLinkUnderline(e=>this._handleLinkLeave(e))),this._register(vj(()=>{this._element.classList.remove(b7+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new b4(this._document,this._helperContainer),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}_updateDimensions(){let e=this._coreBrowserService.dpr;for(let r of(this.dimensions.device.char.width=this._charSizeService.width*e,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*e),this.dimensions.device.cell.width=this.dimensions.device.char.width+Math.round(this._optionsService.rawOptions.letterSpacing),this.dimensions.device.cell.height=Math.floor(this.dimensions.device.char.height*this._optionsService.rawOptions.lineHeight),this.dimensions.device.char.left=0,this.dimensions.device.char.top=0,this.dimensions.device.canvas.width=this.dimensions.device.cell.width*this._bufferService.cols,this.dimensions.device.canvas.height=this.dimensions.device.cell.height*this._bufferService.rows,this.dimensions.css.canvas.width=Math.round(this.dimensions.device.canvas.width/e),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/e),this.dimensions.css.cell.width=this.dimensions.css.canvas.width/this._bufferService.cols,this.dimensions.css.cell.height=this.dimensions.css.canvas.height/this._bufferService.rows,this._rowElements))r.style.width=`${this.dimensions.css.canvas.width}px`,r.style.height=`${this.dimensions.css.cell.height}px`,r.style.lineHeight=`${this.dimensions.css.cell.height}px`,r.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));let r=`${this._terminalSelector} .${b8} span { display: inline-block; height: 100%; vertical-align: top;}`;this._dimensionsStyleElement.textContent=r,this._selectionContainer.style.height=this._viewportElement.style.height,this._screenElement.style.width=`${this.dimensions.css.canvas.width}px`,this._screenElement.style.height=`${this.dimensions.css.canvas.height}px`}_injectCss(e){this._themeStyleElement||(this._themeStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._themeStyleElement));let r=`${this._terminalSelector} .${b8} { pointer-events: none; color: ${e.foreground.css}; font-family: ${this._optionsService.rawOptions.fontFamily}; font-size: ${this._optionsService.rawOptions.fontSize}px; font-kerning: none; white-space: pre}`;r+=`${this._terminalSelector} .${b8} .xterm-dim { color: ${_b.multiplyOpacity(e.foreground,.5).css};}${this._terminalSelector} span:not(.xterm-bold) { font-weight: ${this._optionsService.rawOptions.fontWeight};}${this._terminalSelector} span.xterm-bold { font-weight: ${this._optionsService.rawOptions.fontWeightBold};}${this._terminalSelector} span.xterm-italic { font-style: italic;}`;let s=`blink_underline_${this._terminalClass}`,n=`blink_bar_${this._terminalClass}`,i=`blink_block_${this._terminalClass}`;for(let[a,o]of(r+=`@keyframes ${s} { 50% { border-bottom-style: hidden; }}@keyframes ${n} { 50% { box-shadow: none; }}@keyframes ${i} { 0% { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css}; } 50% { background-color: inherit; color: ${e.cursor.css}; }}${this._terminalSelector} .${b8}.${wt} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${s} 1s step-end infinite;}${this._terminalSelector} .${b8}.${wt} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${n} 1s step-end infinite;}${this._terminalSelector} .${b8}.${wt} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${i} 1s step-end infinite;}${this._terminalSelector} .${b8} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${b8} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${b8} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${b8} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${b8} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}${this._terminalSelector} .${wr} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${wr} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${wr} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`,e.ansi.entries()))r+=`${this._terminalSelector} .${b9}${a} { color: ${o.css}; }${this._terminalSelector} .${b9}${a}.xterm-dim { color: ${_b.multiplyOpacity(o,.5).css}; }${this._terminalSelector} .${we}${a} { background-color: ${o.css}; }`;r+=`${this._terminalSelector} .${b9}257 { color: ${_b.opaque(e.background).css}; }${this._terminalSelector} .${b9}257.xterm-dim { color: ${_b.multiplyOpacity(_b.opaque(e.background),.5).css}; }${this._terminalSelector} .${we}257 { background-color: ${e.foreground.css}; }`,this._themeStyleElement.textContent=r}_setDefaultSpacing(){let e=this.dimensions.css.cell.width-this._widthCache.get("W",!1,!1);this._rowContainer.style.letterSpacing=`${e}px`,this._rowFactory.defaultSpacing=e}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(e,r){for(let e=this._rowElements.length;e<=r;e++){let e=this._document.createElement("div");this._rowContainer.appendChild(e),this._rowElements.push(e)}for(;this._rowElements.length>r;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(e,r){this._refreshRowElements(e,r),this._updateDimensions(),this.handleSelectionChanged(this._selectionRenderModel.selectionStart,this._selectionRenderModel.selectionEnd,this._selectionRenderModel.columnSelectMode)}handleCharSizeChanged(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}handleBlur(){this._rowContainer.classList.remove(wt),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(wt),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(e,r,s){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(e,r,s),this.renderRows(0,this._bufferService.rows-1),!e||!r||(this._selectionRenderModel.update(this._terminal,e,r,s),!this._selectionRenderModel.hasSelection))return;let n=this._selectionRenderModel.viewportStartRow,i=this._selectionRenderModel.viewportEndRow,a=this._selectionRenderModel.viewportCappedStartRow,o=this._selectionRenderModel.viewportCappedEndRow,l=this._document.createDocumentFragment();if(s){let s=e[0]>r[0];l.appendChild(this._createSelectionElement(a,s?r[0]:e[0],s?e[0]:r[0],o-a+1))}else{let s=n===a?e[0]:0,c=a===i?r[0]:this._bufferService.cols;if(l.appendChild(this._createSelectionElement(a,s,c)),l.appendChild(this._createSelectionElement(a+1,0,this._bufferService.cols,o-a-1)),a!==o){let e=i===o?r[0]:this._bufferService.cols;l.appendChild(this._createSelectionElement(o,0,e))}}this._selectionContainer.appendChild(l)}_createSelectionElement(e,r,s,n=1){let i=this._document.createElement("div"),a=r*this.dimensions.css.cell.width,o=this.dimensions.css.cell.width*(s-r);return a+o>this.dimensions.css.canvas.width&&(o=this.dimensions.css.canvas.width-a),i.style.height=`${n*this.dimensions.css.cell.height}px`,i.style.top=`${e*this.dimensions.css.cell.height}px`,i.style.left=`${a}px`,i.style.width=`${o}px`,i}handleCursorMove(){}_handleOptionsChanged(){this._updateDimensions(),this._injectCss(this._themeService.colors),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}clear(){for(let e of this._rowElements)e.replaceChildren()}renderRows(e,r){let s=this._bufferService.buffer,n=s.ybase+s.y,i=Math.min(s.x,this._bufferService.cols-1),a=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,o=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,l=this._optionsService.rawOptions.cursorInactiveStyle;for(let c=e;c<=r;c++){let e=c+s.ydisp,r=this._rowElements[c],d=s.lines.get(e);if(!r||!d)break;r.replaceChildren(...this._rowFactory.createRow(d,e,e===n,o,l,i,a,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${b7}${this._terminalClass}`}_handleLinkHover(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!0)}_handleLinkLeave(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!1)}_setCellUnderline(e,r,s,n,i,a){s<0&&(e=0),n<0&&(r=0);let o=this._bufferService.rows-1;s=Math.max(Math.min(s,o),0),n=Math.max(Math.min(n,o),0),i=Math.min(i,this._bufferService.cols);let l=this._bufferService.buffer,c=l.ybase+l.y,d=Math.min(l.x,i-1),u=this._optionsService.rawOptions.cursorBlink,h=this._optionsService.rawOptions.cursorStyle,f=this._optionsService.rawOptions.cursorInactiveStyle;for(let o=s;o<=n;++o){let p=o+l.ydisp,m=this._rowElements[o],g=l.lines.get(p);if(!m||!g)break;m.replaceChildren(...this._rowFactory.createRow(g,p,p===c,h,f,d,u,this.dimensions.css.cell.width,this._widthCache,a?o===s?e:0:-1,a?(o===n?r:i)-1:-1))}}};wn=x$([xW(7,x9),xW(8,va),xW(9,vt),xW(10,x4),xW(11,x7),xW(12,vo),xW(13,vh)],wn);var wi=class extends vE{constructor(e,r,s){super(),this._optionsService=s,this.width=0,this.height=0,this._onCharSizeChange=this._register(new v2),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new wl(this._optionsService))}catch{this._measureStrategy=this._register(new wo(e,r,this._optionsService))}this._register(this._optionsService.onMultipleOptionChange(["fontFamily","fontSize"],()=>this.measure()))}get hasValidSize(){return this.width>0&&this.height>0}measure(){let e=this._measureStrategy.measure();(e.width!==this.width||e.height!==this.height)&&(this.width=e.width,this.height=e.height,this._onCharSizeChange.fire())}};wi=x$([xW(2,vt)],wi);var wa=class extends vE{constructor(){super(...arguments),this._result={width:0,height:0}}_validateAndSet(e,r){void 0!==e&&e>0&&void 0!==r&&r>0&&(this._result.width=e,this._result.height=r)}},wo=class extends wa{constructor(e,r,s){super(),this._document=e,this._parentElement=r,this._optionsService=s,this._measureElement=this._document.createElement("span"),this._measureElement.classList.add("xterm-char-measure-element"),this._measureElement.textContent="W".repeat(32),this._measureElement.setAttribute("aria-hidden","true"),this._measureElement.style.whiteSpace="pre",this._measureElement.style.fontKerning="none",this._parentElement.appendChild(this._measureElement)}measure(){return this._measureElement.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._measureElement.style.fontSize=`${this._optionsService.rawOptions.fontSize}px`,this._validateAndSet(Number(this._measureElement.offsetWidth)/32,Number(this._measureElement.offsetHeight)),this._result}},wl=class extends wa{constructor(e){super(),this._optionsService=e,this._canvas=new OffscreenCanvas(100,100),this._ctx=this._canvas.getContext("2d");let r=this._ctx.measureText("W");if(!("width"in r&&"fontBoundingBoxAscent"in r&&"fontBoundingBoxDescent"in r))throw Error("Required font metrics not supported")}measure(){this._ctx.font=`${this._optionsService.rawOptions.fontSize}px ${this._optionsService.rawOptions.fontFamily}`;let e=this._ctx.measureText("W");return this._validateAndSet(e.width,e.fontBoundingBoxAscent+e.fontBoundingBoxDescent),this._result}},wc=class extends vE{constructor(e,r,s){super(),this._textarea=e,this._window=r,this.mainDocument=s,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=this._register(new wd(this._window)),this._onDprChange=this._register(new v2),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new v2),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(e=>this._screenDprMonitor.setWindow(e))),this._register(vY.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(y6(this._textarea,"focus",()=>this._isFocused=!0)),this._register(y6(this._textarea,"blur",()=>this._isFocused=!1))}get window(){return this._window}set window(e){this._window!==e&&(this._window=e,this._onWindowChange.fire(this._window))}get dpr(){return this.window.devicePixelRatio}get isFocused(){return void 0===this._cachedIsFocused&&(this._cachedIsFocused=this._isFocused&&this._textarea.ownerDocument.hasFocus(),queueMicrotask(()=>this._cachedIsFocused=void 0)),this._cachedIsFocused}},wd=class extends vE{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new vD),this._onDprChange=this._register(new v2),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(vj(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=y6(this._parentWindow,"resize",()=>this._setDprAndFireIfDiffers())}_setDprAndFireIfDiffers(){this._parentWindow.devicePixelRatio!==this._currentDevicePixelRatio&&this._onDprChange.fire(this._parentWindow.devicePixelRatio),this._updateDpr()}_updateDpr(){this._outerListener&&(this._resolutionMediaMatchList?.removeListener(this._outerListener),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._resolutionMediaMatchList=this._parentWindow.matchMedia(`screen and (resolution: ${this._parentWindow.devicePixelRatio}dppx)`),this._resolutionMediaMatchList.addListener(this._outerListener))}clearListener(){this._resolutionMediaMatchList&&this._outerListener&&(this._resolutionMediaMatchList.removeListener(this._outerListener),this._resolutionMediaMatchList=void 0,this._outerListener=void 0)}},wu=class extends vE{constructor(){super(),this.linkProviders=[],this._register(vj(()=>this.linkProviders.length=0))}registerLinkProvider(e){return this.linkProviders.push(e),{dispose:()=>{let r=this.linkProviders.indexOf(e);-1!==r&&this.linkProviders.splice(r,1)}}}};function wh(e,r,s){let n=s.getBoundingClientRect(),i=e.getComputedStyle(s),a=parseInt(i.getPropertyValue("padding-left")),o=parseInt(i.getPropertyValue("padding-top"));return[r.clientX-n.left-a,r.clientY-n.top-o]}var wf=class{constructor(e,r){this._renderService=e,this._charSizeService=r}getCoords(e,r,s,n,i){return function(e,r,s,n,i,a,o,l,c){if(!a)return;let d=wh(e,r,s);return d[0]=Math.ceil((d[0]+(c?o/2:0))/o),d[1]=Math.ceil(d[1]/l),d[0]=Math.min(Math.max(d[0],1),n+ +!!c),d[1]=Math.min(Math.max(d[1],1),i),d}(window,e,r,s,n,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,i)}getMouseReportCoords(e,r){let s=wh(window,e,r);if(this._charSizeService.hasValidSize)return s[0]=Math.min(Math.max(s[0],0),this._renderService.dimensions.css.canvas.width-1),s[1]=Math.min(Math.max(s[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(s[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(s[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(s[0]),y:Math.floor(s[1])}}};wf=x$([xW(0,vc),xW(1,va)],wf);var wp=class{constructor(e,r){this._renderCallback=e,this._coreBrowserService=r,this._refreshCallbacks=[]}dispose(){this._animationFrame&&(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}addRefreshCallback(e){return this._refreshCallbacks.push(e),this._animationFrame||(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh())),this._animationFrame}refresh(e,r,s){this._rowCount=s,e=void 0!==e?e:0,r=void 0!==r?r:this._rowCount-1,this._rowStart=void 0!==this._rowStart?Math.min(this._rowStart,e):e,this._rowEnd=void 0!==this._rowEnd?Math.max(this._rowEnd,r):r,this._animationFrame||(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh()))}_innerRefresh(){if(this._animationFrame=void 0,void 0===this._rowStart||void 0===this._rowEnd||void 0===this._rowCount)return void this._runRefreshCallbacks();let e=Math.max(this._rowStart,0),r=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,r),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(let e of this._refreshCallbacks)e(0);this._refreshCallbacks=[]}},wm={},wg={getSafariVersion:()=>wk,isChromeOS:()=>wT,isFirefox:()=>ww,isIpad:()=>wC,isIphone:()=>wN,isLegacyEdge:()=>w_,isLinux:()=>wD,isMac:()=>wj,isNode:()=>wv,isSafari:()=>wS,isWindows:()=>wE};for(var wx in wg)xB(wm,wx,{get:wg[wx],enumerable:!0});var wv="u">typeof xO.default&&"title"in xO.default,wy=wv?"node":navigator.userAgent,wb=wv?"node":navigator.platform,ww=wy.includes("Firefox"),w_=wy.includes("Edge"),wS=/^((?!chrome|android).)*safari/i.test(wy);function wk(){if(!wS)return 0;let e=wy.match(/Version\/(\d+)/);return null===e||e.length<2?0:parseInt(e[1])}var wj=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(wb),wC="iPad"===wb,wN="iPhone"===wb,wE=["Windows","Win16","Win32","WinCE"].includes(wb),wD=wb.indexOf("Linux")>=0,wT=/\bCrOS\b/.test(wy),wR=class{constructor(){this._tasks=[],this._i=0}enqueue(e){this._tasks.push(e),this._start()}flush(){for(;this._i<this._tasks.length;)this._tasks[this._i]()||this._i++;this.clear()}clear(){this._idleCallback&&(this._cancelCallback(this._idleCallback),this._idleCallback=void 0),this._i=0,this._tasks.length=0}_start(){this._idleCallback||(this._idleCallback=this._requestCallback(this._process.bind(this)))}_process(e){this._idleCallback=void 0;let r=0,s=0,n=e.timeRemaining(),i=0;for(;this._i<this._tasks.length;){if(r=performance.now(),this._tasks[this._i]()||this._i++,1.5*(s=Math.max(r=Math.max(1,performance.now()-r),s))>(i=e.timeRemaining())){n-r<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(n-r))}ms`),this._start();return}n=i}this.clear()}},wA=class extends wR{_requestCallback(e){return setTimeout(()=>e(this._createDeadline(16)))}_cancelCallback(e){clearTimeout(e)}_createDeadline(e){let r=performance.now()+e;return{timeRemaining:()=>Math.max(0,r-performance.now())}}},wM=class extends wR{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},wI=!wv&&"requestIdleCallback"in window?wM:wA,wP=class{constructor(){this._queue=new wI}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},wF=class extends vE{constructor(e,r,s,n,i,a,o,l,c){super(),this._rowCount=e,this._optionsService=s,this._charSizeService=n,this._coreService=i,this._coreBrowserService=l,this._renderer=this._register(new vD),this._pausedResizeTask=new wP,this._observerDisposable=this._register(new vD),this._isPaused=!1,this._needsFullRefresh=!1,this._isNextRenderRedrawOnly=!0,this._needsSelectionRefresh=!1,this._canvasWidth=0,this._canvasHeight=0,this._selectionState={start:void 0,end:void 0,columnSelectMode:!1},this._onDimensionsChange=this._register(new v2),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new v2),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new v2),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new v2),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new wp((e,r)=>this._renderRows(e,r),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new wL(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(vj(()=>this._syncOutputHandler.dispose())),this._register(this._coreBrowserService.onDprChange(()=>this.handleDevicePixelRatioChange())),this._register(o.onResize(()=>this._fullRefresh())),this._register(o.buffers.onBufferActivate(()=>this._renderer.value?.clear())),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._charSizeService.onCharSizeChange(()=>this.handleCharSizeChanged())),this._register(a.onDecorationRegistered(()=>this._fullRefresh())),this._register(a.onDecorationRemoved(()=>this._fullRefresh())),this._register(this._optionsService.onMultipleOptionChange(["customGlyphs","drawBoldTextInBrightColors","letterSpacing","lineHeight","fontFamily","fontSize","fontWeight","fontWeightBold","minimumContrastRatio","rescaleOverlappingGlyphs"],()=>{this.clear(),this.handleResize(o.cols,o.rows),this._fullRefresh()})),this._register(this._optionsService.onMultipleOptionChange(["cursorBlink","cursorStyle"],()=>this.refreshRows(o.buffer.y,o.buffer.y,!0))),this._register(c.onChangeColors(()=>this._fullRefresh())),this._registerIntersectionObserver(this._coreBrowserService.window,r),this._register(this._coreBrowserService.onWindowChange(e=>this._registerIntersectionObserver(e,r)))}get dimensions(){return this._renderer.value.dimensions}_registerIntersectionObserver(e,r){if("IntersectionObserver"in e){let s=new e.IntersectionObserver(e=>this._handleIntersectionChange(e[e.length-1]),{threshold:0});s.observe(r),this._observerDisposable.value=vj(()=>s.disconnect())}}_handleIntersectionChange(e){this._isPaused=void 0===e.isIntersecting?0===e.intersectionRatio:!e.isIntersecting,this._isPaused||this._charSizeService.hasValidSize||this._charSizeService.measure(),!this._isPaused&&this._needsFullRefresh&&(this._pausedResizeTask.flush(),this.refreshRows(0,this._rowCount-1),this._needsFullRefresh=!1)}refreshRows(e,r,s=!1){if(this._isPaused){this._needsFullRefresh=!0;return}if(this._coreService.decPrivateModes.synchronizedOutput)return void this._syncOutputHandler.bufferRows(e,r);let n=this._syncOutputHandler.flush();n&&(e=Math.min(e,n.start),r=Math.max(r,n.end)),s||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(e,r,this._rowCount)}_renderRows(e,r){if(this._renderer.value){if(this._coreService.decPrivateModes.synchronizedOutput)return void this._syncOutputHandler.bufferRows(e,r);e=Math.min(e,this._rowCount-1),r=Math.min(r,this._rowCount-1),this._renderer.value.renderRows(e,r),this._needsSelectionRefresh&&(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),this._needsSelectionRefresh=!1),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start:e,end:r}),this._onRender.fire({start:e,end:r}),this._isNextRenderRedrawOnly=!0}}resize(e,r){this._rowCount=r,this._fireOnCanvasResize()}_handleOptionsChanged(){this._renderer.value&&(this.refreshRows(0,this._rowCount-1),this._fireOnCanvasResize())}_fireOnCanvasResize(){this._renderer.value&&(this._renderer.value.dimensions.css.canvas.width===this._canvasWidth&&this._renderer.value.dimensions.css.canvas.height===this._canvasHeight||this._onDimensionsChange.fire(this._renderer.value.dimensions))}hasRenderer(){return!!this._renderer.value}setRenderer(e){this._renderer.value=e,this._renderer.value&&(this._renderer.value.onRequestRedraw(e=>this.refreshRows(e.start,e.end,!0)),this._needsSelectionRefresh=!0,this._fullRefresh())}addRefreshCallback(e){return this._renderDebouncer.addRefreshCallback(e)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){this._renderer.value&&(this._renderer.value.clearTextureAtlas?.(),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(e,r){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set(()=>this._renderer.value?.handleResize(e,r)):this._renderer.value.handleResize(e,r),this._fullRefresh())}handleCharSizeChanged(){this._renderer.value?.handleCharSizeChanged()}handleBlur(){this._renderer.value?.handleBlur()}handleFocus(){this._renderer.value?.handleFocus()}handleSelectionChanged(e,r,s){this._selectionState.start=e,this._selectionState.end=r,this._selectionState.columnSelectMode=s,this._renderer.value?.handleSelectionChanged(e,r,s)}handleCursorMove(){this._renderer.value?.handleCursorMove()}clear(){this._renderer.value?.clear()}};wF=x$([xW(2,vt),xW(3,va),xW(4,x7),xW(5,vn),xW(6,x4),xW(7,vo),xW(8,vh)],wF);var wL=class{constructor(e,r,s){this._coreBrowserService=e,this._coreService=r,this._onTimeout=s,this._start=0,this._end=0,this._isBuffering=!1}bufferRows(e,r){this._isBuffering?(this._start=Math.min(this._start,e),this._end=Math.max(this._end,r)):(this._start=e,this._end=r,this._isBuffering=!0),void 0===this._timeout&&(this._timeout=this._coreBrowserService.window.setTimeout(()=>{this._timeout=void 0,this._coreService.decPrivateModes.synchronizedOutput=!1,this._onTimeout()},1e3))}flush(){if(void 0!==this._timeout&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0),!this._isBuffering)return;let e={start:this._start,end:this._end};return this._isBuffering=!1,e}dispose(){void 0!==this._timeout&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0)}};function wO(e,r,s,n){return wW(Math.abs(e-wB(e,s)-(r-wB(r,s)))-function(e,r,s){let n=0,i=e-wB(e,s),a=r-wB(r,s);for(let o=0;o<Math.abs(i-a);o++){let a="A"===function(e,r){return e>r?"A":"B"}(e,r)?-1:1;s.buffer.lines.get(i+a*o)?.isWrapped&&n++}return n}(e,r,s),w$(e>r?"A":"B",n))}function wB(e,r){let s=0,n=r.buffer.lines.get(e),i=n?.isWrapped;for(;i&&e>=0&&e<r.rows;)s++,n=r.buffer.lines.get(--e),i=n?.isWrapped;return s}function wz(e,r,s,n,i,a){let o=e,l=r,c="";for(;(o!==s||l!==n)&&l>=0&&l<a.buffer.lines.length;)o+=i?1:-1,i&&o>a.cols-1?(c+=a.buffer.translateBufferLineToString(l,!1,e,o),o=0,e=0,l++):!i&&o<0&&(c+=a.buffer.translateBufferLineToString(l,!1,0,e+1),e=o=a.cols-1,l--);return c+a.buffer.translateBufferLineToString(l,!1,e,o)}function w$(e,r){return bF.ESC+(r?"O":"[")+e}function wW(e,r){e=Math.floor(e);let s="";for(let n=0;n<e;n++)s+=r;return s}var wH=class{constructor(e){this._bufferService=e,this.isSelectAllActive=!1,this.selectionStartLength=0}clearSelection(){this.selectionStart=void 0,this.selectionEnd=void 0,this.isSelectAllActive=!1,this.selectionStartLength=0}get finalSelectionStart(){return this.isSelectAllActive?[0,0]:this.selectionEnd&&this.selectionStart&&this.areSelectionValuesReversed()?this.selectionEnd:this.selectionStart}get finalSelectionEnd(){if(this.isSelectAllActive)return[this._bufferService.cols,this._bufferService.buffer.ybase+this._bufferService.rows-1];if(this.selectionStart){if(!this.selectionEnd||this.areSelectionValuesReversed()){let e=this.selectionStart[0]+this.selectionStartLength;return e>this._bufferService.cols?e%this._bufferService.cols==0?[this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)-1]:[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[e,this.selectionStart[1]]}if(this.selectionStartLength&&this.selectionEnd[1]===this.selectionStart[1]){let e=this.selectionStart[0]+this.selectionStartLength;return e>this._bufferService.cols?[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[Math.max(e,this.selectionEnd[0]),this.selectionEnd[1]]}return this.selectionEnd}}areSelectionValuesReversed(){let e=this.selectionStart,r=this.selectionEnd;return!!e&&!!r&&(e[1]>r[1]||e[1]===r[1]&&e[0]>r[0])}handleTrim(e){return this.selectionStart&&(this.selectionStart[1]-=e),this.selectionEnd&&(this.selectionEnd[1]-=e),this.selectionEnd&&this.selectionEnd[1]<0?(this.clearSelection(),!0):(this.selectionStart&&this.selectionStart[1]<0&&(this.selectionStart[1]=0),!1)}};function wU(e,r){if(e.start.y>e.end.y)throw Error(`Buffer range end (${e.end.x}, ${e.end.y}) cannot be before start (${e.start.x}, ${e.start.y})`);return r*(e.end.y-e.start.y)+(e.end.x-e.start.x+1)}var wV=RegExp(" ","g"),wq=class extends vE{constructor(e,r,s,n,i,a,o,l,c){super(),this._element=e,this._screenElement=r,this._linkifier=s,this._bufferService=n,this._coreService=i,this._mouseService=a,this._optionsService=o,this._renderService=l,this._coreBrowserService=c,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new x0,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new v2),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new v2),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new v2),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new v2),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=e=>this._handleMouseMove(e),this._mouseUpListener=e=>this._handleMouseUp(e),this._coreService.onUserInput(()=>{this.hasSelection&&this.clearSelection()}),this._trimListener=this._bufferService.buffer.lines.onTrim(e=>this._handleTrim(e)),this._register(this._bufferService.buffers.onBufferActivate(e=>this._handleBufferActivate(e))),this.enable(),this._model=new wH(this._bufferService),this._activeSelectionMode=0,this._register(vj(()=>{this._removeMouseDownListeners()})),this._register(this._bufferService.onResize(e=>{e.rowsChanged&&this.clearSelection()}))}reset(){this.clearSelection()}disable(){this.clearSelection(),this._enabled=!1}enable(){this._enabled=!0}get selectionStart(){return this._model.finalSelectionStart}get selectionEnd(){return this._model.finalSelectionEnd}get hasSelection(){let e=this._model.finalSelectionStart,r=this._model.finalSelectionEnd;return!!e&&!!r&&(e[0]!==r[0]||e[1]!==r[1])}get selectionText(){let e=this._model.finalSelectionStart,r=this._model.finalSelectionEnd;if(!e||!r)return"";let s=this._bufferService.buffer,n=[];if(3===this._activeSelectionMode){if(e[0]===r[0])return"";let i=e[0]<r[0]?e[0]:r[0],a=e[0]<r[0]?r[0]:e[0];for(let o=e[1];o<=r[1];o++){let e=s.translateBufferLineToString(o,!0,i,a);n.push(e)}}else{let i=e[1]===r[1]?r[0]:void 0;n.push(s.translateBufferLineToString(e[1],!0,e[0],i));for(let i=e[1]+1;i<=r[1]-1;i++){let e=s.lines.get(i),r=s.translateBufferLineToString(i,!0);e?.isWrapped?n[n.length-1]+=r:n.push(r)}if(e[1]!==r[1]){let e=s.lines.get(r[1]),i=s.translateBufferLineToString(r[1],!0,0,r[0]);e&&e.isWrapped?n[n.length-1]+=i:n.push(i)}}return n.map(e=>e.replace(wV," ")).join(wE?`\r
24
+ `:`
25
+ `)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(e){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh())),wD&&e&&this.selectionText.length&&this._onLinuxMouseSelection.fire(this.selectionText)}_refresh(){this._refreshAnimationFrame=void 0,this._onRedrawRequest.fire({start:this._model.finalSelectionStart,end:this._model.finalSelectionEnd,columnSelectMode:3===this._activeSelectionMode})}_isClickInSelection(e){let r=this._getMouseBufferCoords(e),s=this._model.finalSelectionStart,n=this._model.finalSelectionEnd;return!!s&&!!n&&!!r&&this._areCoordsInSelection(r,s,n)}isCellInSelection(e,r){let s=this._model.finalSelectionStart,n=this._model.finalSelectionEnd;return!!s&&!!n&&this._areCoordsInSelection([e,r],s,n)}_areCoordsInSelection(e,r,s){return e[1]>r[1]&&e[1]<s[1]||r[1]===s[1]&&e[1]===r[1]&&e[0]>=r[0]&&e[0]<s[0]||r[1]<s[1]&&e[1]===s[1]&&e[0]<s[0]||r[1]<s[1]&&e[1]===r[1]&&e[0]>=r[0]}_selectWordAtCursor(e,r){let s=this._linkifier.currentLink?.link?.range;if(s)return this._model.selectionStart=[s.start.x-1,s.start.y-1],this._model.selectionStartLength=wU(s,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let n=this._getMouseBufferCoords(e);return!!n&&(this._selectWordAt(n,r),this._model.selectionEnd=void 0,!0)}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(e,r){this._model.clearSelection(),e=Math.max(e,0),r=Math.min(r,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,e],this._model.selectionEnd=[this._bufferService.cols,r],this.refresh(),this._onSelectionChange.fire()}_handleTrim(e){this._model.handleTrim(e)&&this.refresh()}_getMouseBufferCoords(e){let r=this._mouseService.getCoords(e,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(r)return r[0]--,r[1]--,r[1]+=this._bufferService.buffer.ydisp,r}_getMouseEventScrollAmount(e){let r=wh(this._coreBrowserService.window,e,this._screenElement)[1],s=this._renderService.dimensions.css.canvas.height;return r>=0&&r<=s?0:(r>s&&(r-=s),(r=Math.min(Math.max(r,-50),50)/50)/Math.abs(r)+Math.round(14*r))}shouldForceSelection(e){return wj?e.altKey&&this._optionsService.rawOptions.macOptionClickForcesSelection:e.shiftKey}handleMouseDown(e){if(this._mouseDownTimeStamp=e.timeStamp,!(2===e.button&&this.hasSelection)&&0===e.button){if(!this._enabled){if(!this.shouldForceSelection(e))return;e.stopPropagation()}e.preventDefault(),this._dragScrollAmount=0,this._enabled&&e.shiftKey?this._handleIncrementalClick(e):1===e.detail?this._handleSingleClick(e):2===e.detail?this._handleDoubleClick(e):3===e.detail&&this._handleTripleClick(e),this._addMouseDownListeners(),this.refresh(!0)}}_addMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.addEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.addEventListener("mouseup",this._mouseUpListener)),this._dragScrollIntervalTimer=this._coreBrowserService.window.setInterval(()=>this._dragScroll(),50)}_removeMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.removeEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.removeEventListener("mouseup",this._mouseUpListener)),this._coreBrowserService.window.clearInterval(this._dragScrollIntervalTimer),this._dragScrollIntervalTimer=void 0}_handleIncrementalClick(e){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(e))}_handleSingleClick(e){if(this._model.selectionStartLength=0,this._model.isSelectAllActive=!1,this._activeSelectionMode=3*!!this.shouldColumnSelect(e),this._model.selectionStart=this._getMouseBufferCoords(e),!this._model.selectionStart)return;this._model.selectionEnd=void 0;let r=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);r&&r.length!==this._model.selectionStart[0]&&0===r.hasWidth(this._model.selectionStart[0])&&this._model.selectionStart[0]++}_handleDoubleClick(e){this._selectWordAtCursor(e,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(e){let r=this._getMouseBufferCoords(e);r&&(this._activeSelectionMode=2,this._selectLineAt(r[1]))}shouldColumnSelect(e){return e.altKey&&!(wj&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(e){if(e.stopImmediatePropagation(),!this._model.selectionStart)return;let r=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(e),!this._model.selectionEnd)return void this.refresh(!0);2===this._activeSelectionMode?this._model.selectionEnd[1]<this._model.selectionStart[1]?this._model.selectionEnd[0]=0:this._model.selectionEnd[0]=this._bufferService.cols:1===this._activeSelectionMode&&this._selectToWordAt(this._model.selectionEnd),this._dragScrollAmount=this._getMouseEventScrollAmount(e),3!==this._activeSelectionMode&&(this._dragScrollAmount>0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));let s=this._bufferService.buffer;if(this._model.selectionEnd[1]<s.lines.length){let e=s.lines.get(this._model.selectionEnd[1]);e&&0===e.hasWidth(this._model.selectionEnd[0])&&this._model.selectionEnd[0]<this._bufferService.cols&&this._model.selectionEnd[0]++}r&&r[0]===this._model.selectionEnd[0]&&r[1]===this._model.selectionEnd[1]||this.refresh(!0)}_dragScroll(){if(!(!this._model.selectionEnd||!this._model.selectionStart)&&this._dragScrollAmount){this._onRequestScrollLines.fire({amount:this._dragScrollAmount,suppressScrollEvent:!1});let e=this._bufferService.buffer;this._dragScrollAmount>0?(3!==this._activeSelectionMode&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(e.ydisp+this._bufferService.rows,e.lines.length-1)):(3!==this._activeSelectionMode&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=e.ydisp),this.refresh()}}_handleMouseUp(e){let r=e.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&r<500&&e.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){let r=this._mouseService.getCoords(e,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(r&&void 0!==r[0]&&void 0!==r[1]){let e=function(e,r,s,n){var i,a,o,l,c,d,u,h,f,p,m,g,x,v,y,b,w,_;let S,k=s.buffer.x,j=s.buffer.y;if(!s.buffer.hasScrollback){let w,_,S;return i=k,o=0,(0===wO(a=j,r,l=s,c=n).length?"":wW(wz(i,a,i,a-wB(a,l),!1,l).length,w$("D",c)))+wO(j,r,s,n)+(d=k,u=j,h=e,w=wO(u,f=r,p=s,m=n).length>0?f-wB(f,p):u,S=(g=d,x=u,_=wO(v=h,y=f,b=p,m).length>0?y-wB(y,b):x,g<v&&_<=y||g>=v&&_<y?"C":"D"),wW(wz(d,w,h,f,"C"===S,p).length,w$(S,m)))}if(j===r)return S=k>e?"D":"C",wW(Math.abs(k-e),w$(S,n));S=j>r?"D":"C";let C=Math.abs(j-r);return wW((w=j>r?e:k,s.cols-w+(C-1)*s.cols+1+(_=0,(j>r?k:e)-1)),w$(S,n))}(r[0]-1,r[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(e,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){let e=this._model.finalSelectionStart,r=this._model.finalSelectionEnd,s=!!e&&!!r&&(e[0]!==r[0]||e[1]!==r[1]);if(!s){this._oldHasSelection&&this._fireOnSelectionChange(e,r,s);return}!e||!r||this._oldSelectionStart&&this._oldSelectionEnd&&e[0]===this._oldSelectionStart[0]&&e[1]===this._oldSelectionStart[1]&&r[0]===this._oldSelectionEnd[0]&&r[1]===this._oldSelectionEnd[1]||this._fireOnSelectionChange(e,r,s)}_fireOnSelectionChange(e,r,s){this._oldSelectionStart=e,this._oldSelectionEnd=r,this._oldHasSelection=s,this._onSelectionChange.fire()}_handleBufferActivate(e){this.clearSelection(),this._trimListener.dispose(),this._trimListener=e.activeBuffer.lines.onTrim(e=>this._handleTrim(e))}_convertViewportColToCharacterIndex(e,r){let s=r;for(let n=0;r>=n;n++){let i=e.loadCell(n,this._workCell).getChars().length;0===this._workCell.getWidth()?s--:i>1&&r!==n&&(s+=i-1)}return s}setSelection(e,r,s){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,r],this._model.selectionStartLength=s,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(e){this._isClickInSelection(e)||(this._selectWordAtCursor(e,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(e,r,s=!0,n=!0){if(e[0]>=this._bufferService.cols)return;let i=this._bufferService.buffer,a=i.lines.get(e[1]);if(!a)return;let o=i.translateBufferLineToString(e[1],!1),l=this._convertViewportColToCharacterIndex(a,e[0]),c=l,d=e[0]-l,u=0,h=0,f=0,p=0;if(" "===o.charAt(l)){for(;l>0&&" "===o.charAt(l-1);)l--;for(;c<o.length&&" "===o.charAt(c+1);)c++}else{let r=e[0],s=e[0];0===a.getWidth(r)&&(u++,r--),2===a.getWidth(s)&&(h++,s++);let n=a.getString(s).length;for(n>1&&(p+=n-1,c+=n-1);r>0&&l>0&&!this._isCharWordSeparator(a.loadCell(r-1,this._workCell));){a.loadCell(r-1,this._workCell);let e=this._workCell.getChars().length;0===this._workCell.getWidth()?(u++,r--):e>1&&(f+=e-1,l-=e-1),l--,r--}for(;s<a.length&&c+1<o.length&&!this._isCharWordSeparator(a.loadCell(s+1,this._workCell));){a.loadCell(s+1,this._workCell);let e=this._workCell.getChars().length;2===this._workCell.getWidth()?(h++,s++):e>1&&(p+=e-1,c+=e-1),c++,s++}}c++;let m=l+d-u+f,g=Math.min(this._bufferService.cols,c-l+u+h-f-p);if(!(!r&&""===o.slice(l,c).trim())){if(s&&0===m&&32!==a.getCodePoint(0)){let r=i.lines.get(e[1]-1);if(r&&a.isWrapped&&32!==r.getCodePoint(this._bufferService.cols-1)){let r=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(r){let e=this._bufferService.cols-r.start;m-=e,g+=e}}}if(n&&m+g===this._bufferService.cols&&32!==a.getCodePoint(this._bufferService.cols-1)){let r=i.lines.get(e[1]+1);if(r?.isWrapped&&32!==r.getCodePoint(0)){let r=this._getWordAt([0,e[1]+1],!1,!1,!0);r&&(g+=r.length)}}return{start:m,length:g}}}_selectWordAt(e,r){let s=this._getWordAt(e,r);if(s){for(;s.start<0;)s.start+=this._bufferService.cols,e[1]--;this._model.selectionStart=[s.start,e[1]],this._model.selectionStartLength=s.length}}_selectToWordAt(e){let r=this._getWordAt(e,!0);if(r){let s=e[1];for(;r.start<0;)r.start+=this._bufferService.cols,s--;if(!this._model.areSelectionValuesReversed())for(;r.start+r.length>this._bufferService.cols;)r.length-=this._bufferService.cols,s++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?r.start:r.start+r.length,s]}}_isCharWordSeparator(e){return 0!==e.getWidth()&&this._optionsService.rawOptions.wordSeparator.indexOf(e.getChars())>=0}_selectLineAt(e){let r=this._bufferService.buffer.getWrappedRangeForLine(e),s={start:{x:0,y:r.first},end:{x:this._bufferService.cols-1,y:r.last}};this._model.selectionStart=[0,r.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=wU(s,this._bufferService.cols)}};wq=x$([xW(3,x4),xW(4,x7),xW(5,vl),xW(6,vt),xW(7,vc),xW(8,vo)],wq);var wK=class{constructor(){this._data={}}set(e,r,s){this._data[e]||(this._data[e]={}),this._data[e][r]=s}get(e,r){return this._data[e]?this._data[e][r]:void 0}clear(){this._data={}}},wX=class{constructor(){this._color=new wK,this._css=new wK}setCss(e,r,s){this._css.set(e,r,s)}getCss(e,r){return this._css.get(e,r)}setColor(e,r,s){this._color.set(e,r,s)}getColor(e,r){return this._color.get(e,r)}clear(){this._color.clear(),this._css.clear()}},wY=Object.freeze((()=>{let e=[_w.toColor("#2e3436"),_w.toColor("#cc0000"),_w.toColor("#4e9a06"),_w.toColor("#c4a000"),_w.toColor("#3465a4"),_w.toColor("#75507b"),_w.toColor("#06989a"),_w.toColor("#d3d7cf"),_w.toColor("#555753"),_w.toColor("#ef2929"),_w.toColor("#8ae234"),_w.toColor("#fce94f"),_w.toColor("#729fcf"),_w.toColor("#ad7fa8"),_w.toColor("#34e2e2"),_w.toColor("#eeeeec")],r=[0,95,135,175,215,255];for(let s=0;s<216;s++){let n=r[s/36%6|0],i=r[s/6%6|0],a=r[s%6];e.push({css:bB.toCss(n,i,a),rgba:bB.toRgba(n,i,a)})}for(let r=0;r<24;r++){let s=8+10*r;e.push({css:bB.toCss(s,s,s),rgba:bB.toRgba(s,s,s)})}return e})()),wG=_w.toColor("#ffffff"),wJ=_w.toColor("#000000"),wZ=_w.toColor("#ffffff"),wQ={css:"rgba(255, 255, 255, 0.3)",rgba:0xffffff4d},w0=class extends vE{constructor(e){super(),this._optionsService=e,this._contrastCache=new wX,this._halfContrastCache=new wX,this._onChangeColors=this._register(new v2),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:wG,background:wJ,cursor:wZ,cursorAccent:wJ,selectionForeground:void 0,selectionBackgroundTransparent:wQ,selectionBackgroundOpaque:_b.blend(wJ,wQ),selectionInactiveBackgroundTransparent:wQ,selectionInactiveBackgroundOpaque:_b.blend(wJ,wQ),scrollbarSliderBackground:_b.opacity(wG,.2),scrollbarSliderHoverBackground:_b.opacity(wG,.4),scrollbarSliderActiveBackground:_b.opacity(wG,.5),overviewRulerBorder:wG,ansi:wY.slice(),contrastCache:this._contrastCache,halfContrastCache:this._halfContrastCache},this._updateRestoreColors(),this._setTheme(this._optionsService.rawOptions.theme),this._register(this._optionsService.onSpecificOptionChange("minimumContrastRatio",()=>this._contrastCache.clear())),this._register(this._optionsService.onSpecificOptionChange("theme",()=>this._setTheme(this._optionsService.rawOptions.theme)))}get colors(){return this._colors}_setTheme(e={}){let r=this._colors;if(r.foreground=w1(e.foreground,wG),r.background=w1(e.background,wJ),r.cursor=_b.blend(r.background,w1(e.cursor,wZ)),r.cursorAccent=_b.blend(r.background,w1(e.cursorAccent,wJ)),r.selectionBackgroundTransparent=w1(e.selectionBackground,wQ),r.selectionBackgroundOpaque=_b.blend(r.background,r.selectionBackgroundTransparent),r.selectionInactiveBackgroundTransparent=w1(e.selectionInactiveBackground,r.selectionBackgroundTransparent),r.selectionInactiveBackgroundOpaque=_b.blend(r.background,r.selectionInactiveBackgroundTransparent),r.selectionForeground=e.selectionForeground?w1(e.selectionForeground,bU):void 0,r.selectionForeground===bU&&(r.selectionForeground=void 0),_b.isOpaque(r.selectionBackgroundTransparent)&&(r.selectionBackgroundTransparent=_b.opacity(r.selectionBackgroundTransparent,.3)),_b.isOpaque(r.selectionInactiveBackgroundTransparent)&&(r.selectionInactiveBackgroundTransparent=_b.opacity(r.selectionInactiveBackgroundTransparent,.3)),r.scrollbarSliderBackground=w1(e.scrollbarSliderBackground,_b.opacity(r.foreground,.2)),r.scrollbarSliderHoverBackground=w1(e.scrollbarSliderHoverBackground,_b.opacity(r.foreground,.4)),r.scrollbarSliderActiveBackground=w1(e.scrollbarSliderActiveBackground,_b.opacity(r.foreground,.5)),r.overviewRulerBorder=w1(e.overviewRulerBorder,wG),r.ansi=wY.slice(),r.ansi[0]=w1(e.black,wY[0]),r.ansi[1]=w1(e.red,wY[1]),r.ansi[2]=w1(e.green,wY[2]),r.ansi[3]=w1(e.yellow,wY[3]),r.ansi[4]=w1(e.blue,wY[4]),r.ansi[5]=w1(e.magenta,wY[5]),r.ansi[6]=w1(e.cyan,wY[6]),r.ansi[7]=w1(e.white,wY[7]),r.ansi[8]=w1(e.brightBlack,wY[8]),r.ansi[9]=w1(e.brightRed,wY[9]),r.ansi[10]=w1(e.brightGreen,wY[10]),r.ansi[11]=w1(e.brightYellow,wY[11]),r.ansi[12]=w1(e.brightBlue,wY[12]),r.ansi[13]=w1(e.brightMagenta,wY[13]),r.ansi[14]=w1(e.brightCyan,wY[14]),r.ansi[15]=w1(e.brightWhite,wY[15]),e.extendedAnsi){let s=Math.min(r.ansi.length-16,e.extendedAnsi.length);for(let n=0;n<s;n++)r.ansi[n+16]=w1(e.extendedAnsi[n],wY[n+16])}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors)}restoreColor(e){this._restoreColor(e),this._onChangeColors.fire(this.colors)}_restoreColor(e){if(void 0===e){for(let e=0;e<this._restoreColors.ansi.length;++e)this._colors.ansi[e]=this._restoreColors.ansi[e];return}switch(e){case 256:this._colors.foreground=this._restoreColors.foreground;break;case 257:this._colors.background=this._restoreColors.background;break;case 258:this._colors.cursor=this._restoreColors.cursor;break;default:this._colors.ansi[e]=this._restoreColors.ansi[e]}}modifyColors(e){e(this._colors),this._onChangeColors.fire(this.colors)}_updateRestoreColors(){this._restoreColors={foreground:this._colors.foreground,background:this._colors.background,cursor:this._colors.cursor,ansi:this._colors.ansi.slice()}}};function w1(e,r){if(void 0!==e)try{return _w.toColor(e)}catch{}return r}w0=x$([xW(0,vt)],w0);var w2=class{constructor(...e){for(let[r,s]of(this._entries=new Map,e))this.set(r,s)}set(e,r){let s=this._entries.get(e);return this._entries.set(e,r),s}forEach(e){for(let[r,s]of this._entries.entries())e(r,s)}has(e){return this._entries.has(e)}get(e){return this._entries.get(e)}},w5=class{constructor(){this._services=new w2,this._services.set(x9,this)}setService(e,r){this._services.set(e,r)}getService(e){return this._services.get(e)}createInstance(e,...r){let s=(e[x2]||[]).sort((e,r)=>e.index-r.index),n=[];for(let r of s){let s=this._services.get(r.id);if(!s)throw Error(`[createInstance] ${e.name} depends on UNKNOWN service ${r.id._id}.`);n.push(s)}let i=s.length>0?s[0].index:r.length;if(r.length!==i)throw Error(`[createInstance] First service dependency of ${e.name} at position ${i+1} conflicts with ${r.length} static arguments`);return new e(...r,...n)}},w3={trace:0,debug:1,info:2,warn:3,error:4,off:5},w4=class extends vE{constructor(e){super(),this._optionsService=e,this._logLevel=5,this._updateLogLevel(),this._register(this._optionsService.onSpecificOptionChange("logLevel",()=>this._updateLogLevel()))}get logLevel(){return this._logLevel}_updateLogLevel(){this._logLevel=w3[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(e){for(let r=0;r<e.length;r++)"function"==typeof e[r]&&(e[r]=e[r]())}_log(e,r,s){this._evalLazyOptionalParams(s),e.call(console,(this._optionsService.options.logger?"":"xterm.js: ")+r,...s)}trace(e,...r){this._logLevel<=0&&this._log(this._optionsService.options.logger?.trace.bind(this._optionsService.options.logger)??console.log,e,r)}debug(e,...r){this._logLevel<=1&&this._log(this._optionsService.options.logger?.debug.bind(this._optionsService.options.logger)??console.log,e,r)}info(e,...r){this._logLevel<=2&&this._log(this._optionsService.options.logger?.info.bind(this._optionsService.options.logger)??console.info,e,r)}warn(e,...r){this._logLevel<=3&&this._log(this._optionsService.options.logger?.warn.bind(this._optionsService.options.logger)??console.warn,e,r)}error(e,...r){this._logLevel<=4&&this._log(this._optionsService.options.logger?.error.bind(this._optionsService.options.logger)??console.error,e,r)}};w4=x$([xW(0,vt)],w4);var w6=class extends vE{constructor(e){super(),this._maxLength=e,this.onDeleteEmitter=this._register(new v2),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new v2),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new v2),this.onTrim=this.onTrimEmitter.event,this._array=Array(this._maxLength),this._startIndex=0,this._length=0}get maxLength(){return this._maxLength}set maxLength(e){if(this._maxLength===e)return;let r=Array(e);for(let s=0;s<Math.min(e,this.length);s++)r[s]=this._array[this._getCyclicIndex(s)];this._array=r,this._maxLength=e,this._startIndex=0}get length(){return this._length}set length(e){if(e>this._length)for(let r=this._length;r<e;r++)this._array[r]=void 0;this._length=e}get(e){return this._array[this._getCyclicIndex(e)]}set(e,r){this._array[this._getCyclicIndex(e)]=r}push(e){this._array[this._getCyclicIndex(this._length)]=e,this._length===this._maxLength?(this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1)):this._length++}recycle(){if(this._length!==this._maxLength)throw Error("Can only recycle when the buffer is full");return this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1),this._array[this._getCyclicIndex(this._length-1)]}get isFull(){return this._length===this._maxLength}pop(){return this._array[this._getCyclicIndex(this._length---1)]}splice(e,r,...s){if(r){for(let s=e;s<this._length-r;s++)this._array[this._getCyclicIndex(s)]=this._array[this._getCyclicIndex(s+r)];this._length-=r,this.onDeleteEmitter.fire({index:e,amount:r})}for(let r=this._length-1;r>=e;r--)this._array[this._getCyclicIndex(r+s.length)]=this._array[this._getCyclicIndex(r)];for(let r=0;r<s.length;r++)this._array[this._getCyclicIndex(e+r)]=s[r];if(s.length&&this.onInsertEmitter.fire({index:e,amount:s.length}),this._length+s.length>this._maxLength){let e=this._length+s.length-this._maxLength;this._startIndex+=e,this._length=this._maxLength,this.onTrimEmitter.fire(e)}else this._length+=s.length}trimStart(e){e>this._length&&(e=this._length),this._startIndex+=e,this._length-=e,this.onTrimEmitter.fire(e)}shiftElements(e,r,s){if(!(r<=0)){if(e<0||e>=this._length)throw Error("start argument out of range");if(e+s<0)throw Error("Cannot shift elements in list beyond index 0");if(s>0){for(let n=r-1;n>=0;n--)this.set(e+n+s,this.get(e+n));let n=e+r+s-this._length;if(n>0)for(this._length+=n;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let n=0;n<r;n++)this.set(e+n+s,this.get(e+n))}}_getCyclicIndex(e){return(this._startIndex+e)%this._maxLength}},w7=Object.freeze(new xZ),w8=0,w9=class e{constructor(e,r,s=!1){this.isWrapped=s,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(3*e);let n=r||x0.fromCharData([0,"",1,0]);for(let r=0;r<e;++r)this.setCell(r,n);this.length=e}get(e){let r=this._data[3*e+0],s=2097151&r;return[this._data[3*e+1],2097152&r?this._combined[e]:s?xX(s):"",r>>22,2097152&r?this._combined[e].charCodeAt(this._combined[e].length-1):s]}set(e,r){this._data[3*e+1]=r[0],r[1].length>1?(this._combined[e]=r[1],this._data[3*e+0]=2097152|e|r[2]<<22):this._data[3*e+0]=r[1].charCodeAt(0)|r[2]<<22}getWidth(e){return this._data[3*e+0]>>22}hasWidth(e){return 0xc00000&this._data[3*e+0]}getFg(e){return this._data[3*e+1]}getBg(e){return this._data[3*e+2]}hasContent(e){return 4194303&this._data[3*e+0]}getCodePoint(e){let r=this._data[3*e+0];return 2097152&r?this._combined[e].charCodeAt(this._combined[e].length-1):2097151&r}isCombined(e){return 2097152&this._data[3*e+0]}getString(e){let r=this._data[3*e+0];return 2097152&r?this._combined[e]:2097151&r?xX(2097151&r):""}isProtected(e){return 0x20000000&this._data[3*e+2]}loadCell(e,r){return w8=3*e,r.content=this._data[w8+0],r.fg=this._data[w8+1],r.bg=this._data[w8+2],2097152&r.content&&(r.combinedData=this._combined[e]),0x10000000&r.bg&&(r.extended=this._extendedAttrs[e]),r}setCell(e,r){2097152&r.content&&(this._combined[e]=r.combinedData),0x10000000&r.bg&&(this._extendedAttrs[e]=r.extended),this._data[3*e+0]=r.content,this._data[3*e+1]=r.fg,this._data[3*e+2]=r.bg}setCellFromCodepoint(e,r,s,n){0x10000000&n.bg&&(this._extendedAttrs[e]=n.extended),this._data[3*e+0]=r|s<<22,this._data[3*e+1]=n.fg,this._data[3*e+2]=n.bg}addCodepointToCell(e,r,s){let n=this._data[3*e+0];2097152&n?this._combined[e]+=xX(r):2097151&n?(this._combined[e]=xX(2097151&n)+xX(r),n&=-2097152,n|=2097152):n=4194304|r,s&&(n&=-0xc00001,n|=s<<22),this._data[3*e+0]=n}insertCells(e,r,s){if((e%=this.length)&&2===this.getWidth(e-1)&&this.setCellFromCodepoint(e-1,0,1,s),r<this.length-e){let n=new x0;for(let s=this.length-e-r-1;s>=0;--s)this.setCell(e+r+s,this.loadCell(e+s,n));for(let n=0;n<r;++n)this.setCell(e+n,s)}else for(let r=e;r<this.length;++r)this.setCell(r,s);2===this.getWidth(this.length-1)&&this.setCellFromCodepoint(this.length-1,0,1,s)}deleteCells(e,r,s){if(e%=this.length,r<this.length-e){let n=new x0;for(let s=0;s<this.length-e-r;++s)this.setCell(e+s,this.loadCell(e+r+s,n));for(let e=this.length-r;e<this.length;++e)this.setCell(e,s)}else for(let r=e;r<this.length;++r)this.setCell(r,s);e&&2===this.getWidth(e-1)&&this.setCellFromCodepoint(e-1,0,1,s),0!==this.getWidth(e)||this.hasContent(e)||this.setCellFromCodepoint(e,0,1,s)}replaceCells(e,r,s,n=!1){if(n){for(e&&2===this.getWidth(e-1)&&!this.isProtected(e-1)&&this.setCellFromCodepoint(e-1,0,1,s),r<this.length&&2===this.getWidth(r-1)&&!this.isProtected(r)&&this.setCellFromCodepoint(r,0,1,s);e<r&&e<this.length;)this.isProtected(e)||this.setCell(e,s),e++;return}for(e&&2===this.getWidth(e-1)&&this.setCellFromCodepoint(e-1,0,1,s),r<this.length&&2===this.getWidth(r-1)&&this.setCellFromCodepoint(r,0,1,s);e<r&&e<this.length;)this.setCell(e++,s)}resize(e,r){if(e===this.length)return 4*this._data.length*2<this._data.buffer.byteLength;let s=3*e;if(e>this.length){if(this._data.buffer.byteLength>=4*s)this._data=new Uint32Array(this._data.buffer,0,s);else{let e=new Uint32Array(s);e.set(this._data),this._data=e}for(let s=this.length;s<e;++s)this.setCell(s,r)}else{this._data=this._data.subarray(0,s);let r=Object.keys(this._combined);for(let s=0;s<r.length;s++){let n=parseInt(r[s],10);n>=e&&delete this._combined[n]}let n=Object.keys(this._extendedAttrs);for(let r=0;r<n.length;r++){let s=parseInt(n[r],10);s>=e&&delete this._extendedAttrs[s]}}return this.length=e,4*s*2<this._data.buffer.byteLength}cleanupMemory(){if(4*this._data.length*2<this._data.buffer.byteLength){let e=new Uint32Array(this._data.length);return e.set(this._data),this._data=e,1}return 0}fill(e,r=!1){if(r){for(let r=0;r<this.length;++r)this.isProtected(r)||this.setCell(r,e);return}this._combined={},this._extendedAttrs={};for(let r=0;r<this.length;++r)this.setCell(r,e)}copyFrom(e){for(let r in this.length!==e.length?this._data=new Uint32Array(e._data):this._data.set(e._data),this.length=e.length,this._combined={},e._combined)this._combined[r]=e._combined[r];for(let r in this._extendedAttrs={},e._extendedAttrs)this._extendedAttrs[r]=e._extendedAttrs[r];this.isWrapped=e.isWrapped}clone(){let r=new e(0);for(let e in r._data=new Uint32Array(this._data),r.length=this.length,this._combined)r._combined[e]=this._combined[e];for(let e in this._extendedAttrs)r._extendedAttrs[e]=this._extendedAttrs[e];return r.isWrapped=this.isWrapped,r}getTrimmedLength(){for(let e=this.length-1;e>=0;--e)if(4194303&this._data[3*e+0])return e+(this._data[3*e+0]>>22);return 0}getNoBgTrimmedLength(){for(let e=this.length-1;e>=0;--e)if(4194303&this._data[3*e+0]||0x3000000&this._data[3*e+2])return e+(this._data[3*e+0]>>22);return 0}copyCellsFrom(e,r,s,n,i){let a=e._data;if(i)for(let i=n-1;i>=0;i--){for(let e=0;e<3;e++)this._data[(s+i)*3+e]=a[(r+i)*3+e];0x10000000&a[(r+i)*3+2]&&(this._extendedAttrs[s+i]=e._extendedAttrs[r+i])}else for(let i=0;i<n;i++){for(let e=0;e<3;e++)this._data[(s+i)*3+e]=a[(r+i)*3+e];0x10000000&a[(r+i)*3+2]&&(this._extendedAttrs[s+i]=e._extendedAttrs[r+i])}let o=Object.keys(e._combined);for(let n=0;n<o.length;n++){let i=parseInt(o[n],10);i>=r&&(this._combined[i-r+s]=e._combined[i])}}translateToString(e,r,s,n){r=r??0,s=s??this.length,e&&(s=Math.min(s,this.getTrimmedLength())),n&&(n.length=0);let i="";for(;r<s;){let e=this._data[3*r+0],s=2097151&e,a=2097152&e?this._combined[r]:s?xX(s):" ";if(i+=a,n)for(let e=0;e<a.length;++e)n.push(r);r+=e>>22||1}return n&&n.push(r),i}};function _e(e,r,s){if(r===e.length-1)return e[r].getTrimmedLength();let n=!e[r].hasContent(s-1)&&1===e[r].getWidth(s-1),i=2===e[r+1].getWidth(0);return n&&i?s-1:s}var _t=class e{constructor(r){this.line=r,this.isDisposed=!1,this._disposables=[],this._id=e._nextId++,this._onDispose=this.register(new v2),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),vk(this._disposables),this._disposables.length=0)}register(e){return this._disposables.push(e),e}};_t._nextId=1;var _r={},_s=_r.B;_r[0]={"`":"◆",a:"▒",b:"␉",c:"␌",d:"␍",e:"␊",f:"°",g:"±",h:"␤",i:"␋",j:"┘",k:"┐",l:"┌",m:"└",n:"┼",o:"⎺",p:"⎻",q:"─",r:"⎼",s:"⎽",t:"├",u:"┤",v:"┴",w:"┬",x:"│",y:"≤",z:"≥","{":"π","|":"≠","}":"£","~":"·"},_r.A={"#":"£"},_r.B=void 0,_r[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"},_r.C=_r[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"},_r.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"},_r.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"},_r.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"},_r.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"},_r.E=_r[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"},_r.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"},_r.H=_r[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"},_r["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var _n=class{constructor(e,r,s){this._hasScrollback=e,this._optionsService=r,this._bufferService=s,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=w7.clone(),this.savedCharset=_s,this.markers=[],this._nullCell=x0.fromCharData([0,"",1,0]),this._whitespaceCell=x0.fromCharData([0," ",1,32]),this._isClearing=!1,this._memoryCleanupQueue=new wI,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new w6(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}getNullCell(e){return e?(this._nullCell.fg=e.fg,this._nullCell.bg=e.bg,this._nullCell.extended=e.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new xQ),this._nullCell}getWhitespaceCell(e){return e?(this._whitespaceCell.fg=e.fg,this._whitespaceCell.bg=e.bg,this._whitespaceCell.extended=e.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new xQ),this._whitespaceCell}getBlankLine(e,r){return new w9(this._bufferService.cols,this.getNullCell(e),r)}get hasScrollback(){return this._hasScrollback&&this.lines.maxLength>this._rows}get isCursorInViewport(){let e=this.ybase+this.y-this.ydisp;return e>=0&&e<this._rows}_getCorrectBufferLength(e){if(!this._hasScrollback)return e;let r=e+this._optionsService.rawOptions.scrollback;return r>0xffffffff?0xffffffff:r}fillViewportRows(e){if(0===this.lines.length){void 0===e&&(e=w7);let r=this._rows;for(;r--;)this.lines.push(this.getBlankLine(e))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new w6(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,r){let s=this.getNullCell(w7),n=0,i=this._getCorrectBufferLength(r);if(i>this.lines.maxLength&&(this.lines.maxLength=i),this.lines.length>0){if(this._cols<e)for(let r=0;r<this.lines.length;r++)n+=+this.lines.get(r).resize(e,s);let a=0;if(this._rows<r)for(let n=this._rows;n<r;n++)this.lines.length<r+this.ybase&&(this._optionsService.rawOptions.windowsMode||void 0!==this._optionsService.rawOptions.windowsPty.backend||void 0!==this._optionsService.rawOptions.windowsPty.buildNumber?this.lines.push(new w9(e,s)):this.ybase>0&&this.lines.length<=this.ybase+this.y+a+1?(this.ybase--,a++,this.ydisp>0&&this.ydisp--):this.lines.push(new w9(e,s)));else for(let e=this._rows;e>r;e--)this.lines.length>r+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(i<this.lines.maxLength){let e=this.lines.length-i;e>0&&(this.lines.trimStart(e),this.ybase=Math.max(this.ybase-e,0),this.ydisp=Math.max(this.ydisp-e,0),this.savedY=Math.max(this.savedY-e,0)),this.lines.maxLength=i}this.x=Math.min(this.x,e-1),this.y=Math.min(this.y,r-1),a&&(this.y+=a),this.savedX=Math.min(this.savedX,e-1),this.scrollTop=0}if(this.scrollBottom=r-1,this._isReflowEnabled&&(this._reflow(e,r),this._cols>e))for(let r=0;r<this.lines.length;r++)n+=+this.lines.get(r).resize(e,s);this._cols=e,this._rows=r,this._memoryCleanupQueue.clear(),n>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue(()=>this._batchedMemoryCleanup()))}_batchedMemoryCleanup(){let e=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,e=!1);let r=0;for(;this._memoryCleanupPosition<this.lines.length;)if((r+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory())>100)return!0;return e}get _isReflowEnabled(){let e=this._optionsService.rawOptions.windowsPty;return e&&e.buildNumber?this._hasScrollback&&"conpty"===e.backend&&e.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(e,r){this._cols!==e&&(e>this._cols?this._reflowLarger(e,r):this._reflowSmaller(e,r))}_reflowLarger(e,r){let s=this._optionsService.rawOptions.reflowCursorLine,n=function(e,r,s,n,i,a){let o=[];for(let l=0;l<e.length-1;l++){let c=l,d=e.get(++c);if(!d.isWrapped)continue;let u=[e.get(l)];for(;c<e.length&&d.isWrapped;)u.push(d),d=e.get(++c);if(!a&&n>=l&&n<c){l+=u.length-1;continue}let h=0,f=_e(u,0,r),p=1,m=0;for(;p<u.length;){let e=_e(u,p,r),n=Math.min(e-m,s-f);u[h].copyCellsFrom(u[p],m,f,n,!1),(f+=n)===s&&(h++,f=0),(m+=n)===e&&(p++,m=0),0===f&&0!==h&&2===u[h-1].getWidth(s-1)&&(u[h].copyCellsFrom(u[h-1],s-1,f++,1,!1),u[h-1].setCell(s-1,i))}u[h].replaceCells(f,s,i);let g=0;for(let e=u.length-1;e>0&&(e>h||0===u[e].getTrimmedLength());e--)g++;g>0&&(o.push(l+u.length-g),o.push(g)),l+=u.length-1}return o}(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(w7),s);if(n.length>0){let s=function(e,r){let s=[],n=0,i=r[0],a=0;for(let o=0;o<e.length;o++)if(i===o){let s=r[++n];e.onDeleteEmitter.fire({index:o-a,amount:s}),o+=s-1,a+=s,i=r[++n]}else s.push(o);return{layout:s,countRemoved:a}}(this.lines,n);(function(e,r){let s=[];for(let n=0;n<r.length;n++)s.push(e.get(r[n]));for(let r=0;r<s.length;r++)e.set(r,s[r]);e.length=r.length})(this.lines,s.layout),this._reflowLargerAdjustViewport(e,r,s.countRemoved)}}_reflowLargerAdjustViewport(e,r,s){let n=this.getNullCell(w7),i=s;for(;i-- >0;)0===this.ybase?(this.y>0&&this.y--,this.lines.length<r&&this.lines.push(new w9(e,n))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-s,0)}_reflowSmaller(e,r){let s=this._optionsService.rawOptions.reflowCursorLine,n=this.getNullCell(w7),i=[],a=0;for(let o=this.lines.length-1;o>=0;o--){let l=this.lines.get(o);if(!l||!l.isWrapped&&l.getTrimmedLength()<=e)continue;let c=[l];for(;l.isWrapped&&o>0;)l=this.lines.get(--o),c.unshift(l);if(!s){let e=this.ybase+this.y;if(e>=o&&e<o+c.length)continue}let d=c[c.length-1].getTrimmedLength(),u=function(e,r,s){let n=[],i=e.map((s,n)=>_e(e,n,r)).reduce((e,r)=>e+r),a=0,o=0,l=0;for(;l<i;){if(i-l<s){n.push(i-l);break}a+=s;let c=_e(e,o,r);a>c&&(a-=c,o++);let d=2===e[o].getWidth(a-1);d&&a--;let u=d?s-1:s;n.push(u),l+=u}return n}(c,this._cols,e),h=u.length-c.length,f;f=0===this.ybase&&this.y!==this.lines.length-1?Math.max(0,this.y-this.lines.maxLength+h):Math.max(0,this.lines.length-this.lines.maxLength+h);let p=[];for(let e=0;e<h;e++){let e=this.getBlankLine(w7,!0);p.push(e)}p.length>0&&(i.push({start:o+c.length+a,newLines:p}),a+=p.length),c.push(...p);let m=u.length-1,g=u[m];0===g&&(g=u[--m]);let x=c.length-h-1,v=d;for(;x>=0;){let e=Math.min(v,g);if(void 0===c[m])break;c[m].copyCellsFrom(c[x],v-e,g-e,e,!0),0==(g-=e)&&(g=u[--m]),0==(v-=e)&&(v=_e(c,Math.max(--x,0),this._cols))}for(let r=0;r<c.length;r++)u[r]<e&&c[r].setCell(u[r],n);let y=h-f;for(;y-- >0;)0===this.ybase?this.y<r-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+a)-r&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+h,this.ybase+r-1)}if(i.length>0){let e=[],r=[];for(let e=0;e<this.lines.length;e++)r.push(this.lines.get(e));let s=this.lines.length,n=s-1,o=0,l=i[0];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+a);let c=0;for(let d=Math.min(this.lines.maxLength-1,s+a-1);d>=0;d--)if(l&&l.start>n+c){for(let e=l.newLines.length-1;e>=0;e--)this.lines.set(d--,l.newLines[e]);d++,e.push({index:n+1,amount:l.newLines.length}),c+=l.newLines.length,l=i[++o]}else this.lines.set(d,r[n--]);let d=0;for(let r=e.length-1;r>=0;r--)e[r].index+=d,this.lines.onInsertEmitter.fire(e[r]),d+=e[r].amount;let u=Math.max(0,s+a-this.lines.maxLength);u>0&&this.lines.onTrimEmitter.fire(u)}}translateBufferLineToString(e,r,s=0,n){let i=this.lines.get(e);return i?i.translateToString(r,s,n):""}getWrappedRangeForLine(e){let r=e,s=e;for(;r>0&&this.lines.get(r).isWrapped;)r--;for(;s+1<this.lines.length&&this.lines.get(s+1).isWrapped;)s++;return{first:r,last:s}}setupTabStops(e){for(null!=e?this.tabs[e]||(e=this.prevStop(e)):(this.tabs={},e=0);e<this._cols;e+=this._optionsService.rawOptions.tabStopWidth)this.tabs[e]=!0}prevStop(e){for(null==e&&(e=this.x);!this.tabs[--e]&&e>0;);return e>=this._cols?this._cols-1:e<0?0:e}nextStop(e){for(null==e&&(e=this.x);!this.tabs[++e]&&e<this._cols;);return e>=this._cols?this._cols-1:e<0?0:e}clearMarkers(e){this._isClearing=!0;for(let r=0;r<this.markers.length;r++)this.markers[r].line===e&&(this.markers[r].dispose(),this.markers.splice(r--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let e=0;e<this.markers.length;e++)this.markers[e].dispose();this.markers.length=0,this._isClearing=!1}addMarker(e){let r=new _t(e);return this.markers.push(r),r.register(this.lines.onTrim(e=>{r.line-=e,r.line<0&&r.dispose()})),r.register(this.lines.onInsert(e=>{r.line>=e.index&&(r.line+=e.amount)})),r.register(this.lines.onDelete(e=>{r.line>=e.index&&r.line<e.index+e.amount&&r.dispose(),r.line>e.index&&(r.line-=e.amount)})),r.register(r.onDispose(()=>this._removeMarker(r))),r}_removeMarker(e){this._isClearing||this.markers.splice(this.markers.indexOf(e),1)}},_i=class extends vE{constructor(e,r){super(),this._optionsService=e,this._bufferService=r,this._onBufferActivate=this._register(new v2),this.onBufferActivate=this._onBufferActivate.event,this.reset(),this._register(this._optionsService.onSpecificOptionChange("scrollback",()=>this.resize(this._bufferService.cols,this._bufferService.rows))),this._register(this._optionsService.onSpecificOptionChange("tabStopWidth",()=>this.setupTabStops()))}reset(){this._normal=new _n(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new _n(!1,this._optionsService,this._bufferService),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}),this.setupTabStops()}get alt(){return this._alt}get active(){return this._activeBuffer}get normal(){return this._normal}activateNormalBuffer(){this._activeBuffer!==this._normal&&(this._normal.x=this._alt.x,this._normal.y=this._alt.y,this._alt.clearAllMarkers(),this._alt.clear(),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}))}activateAltBuffer(e){this._activeBuffer!==this._alt&&(this._alt.fillViewportRows(e),this._alt.x=this._normal.x,this._alt.y=this._normal.y,this._activeBuffer=this._alt,this._onBufferActivate.fire({activeBuffer:this._alt,inactiveBuffer:this._normal}))}resize(e,r){this._normal.resize(e,r),this._alt.resize(e,r),this.setupTabStops(e)}setupTabStops(e){this._normal.setupTabStops(e),this._alt.setupTabStops(e)}},_a=class extends vE{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new v2),this.onResize=this._onResize.event,this._onScroll=this._register(new v2),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,2),this.rows=Math.max(e.rawOptions.rows||0,1),this.buffers=this._register(new _i(e,this)),this._register(this.buffers.onBufferActivate(e=>{this._onScroll.fire(e.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(e,r){let s=this.cols!==e,n=this.rows!==r;this.cols=e,this.rows=r,this.buffers.resize(e,r),this._onResize.fire({cols:e,rows:r,colsChanged:s,rowsChanged:n})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(e,r=!1){let s=this.buffer,n;(n=this._cachedBlankLine)&&n.length===this.cols&&n.getFg(0)===e.fg&&n.getBg(0)===e.bg||(n=s.getBlankLine(e,r),this._cachedBlankLine=n),n.isWrapped=r;let i=s.ybase+s.scrollTop,a=s.ybase+s.scrollBottom;if(0===s.scrollTop){let e=s.lines.isFull;a===s.lines.length-1?e?s.lines.recycle().copyFrom(n):s.lines.push(n.clone()):s.lines.splice(a+1,0,n.clone()),e?this.isUserScrolling&&(s.ydisp=Math.max(s.ydisp-1,0)):(s.ybase++,this.isUserScrolling||s.ydisp++)}else{let e=a-i+1;s.lines.shiftElements(i+1,e-1,-1),s.lines.set(a,n.clone())}this.isUserScrolling||(s.ydisp=s.ybase),this._onScroll.fire(s.ydisp)}scrollLines(e,r){let s=this.buffer;if(e<0){if(0===s.ydisp)return;this.isUserScrolling=!0}else e+s.ydisp>=s.ybase&&(this.isUserScrolling=!1);let n=s.ydisp;s.ydisp=Math.max(Math.min(s.ydisp+e,s.ybase),0),n!==s.ydisp&&(r||this._onScroll.fire(s.ydisp))}};_a=x$([xW(0,vt)],_a);var _o={cols:80,rows:24,cursorBlink:!1,cursorStyle:"block",cursorWidth:1,cursorInactiveStyle:"outline",customGlyphs:!0,drawBoldTextInBrightColors:!0,documentOverride:null,fastScrollModifier:"alt",fastScrollSensitivity:5,fontFamily:"monospace",fontSize:15,fontWeight:"normal",fontWeightBold:"bold",ignoreBracketedPasteMode:!1,lineHeight:1,letterSpacing:0,linkHandler:null,logLevel:"info",logger:null,scrollback:1e3,scrollOnEraseInDisplay:!1,scrollOnUserInput:!0,scrollSensitivity:1,screenReaderMode:!1,smoothScrollDuration:0,macOptionIsMeta:!1,macOptionClickForcesSelection:!1,minimumContrastRatio:1,disableStdin:!1,allowProposedApi:!1,allowTransparency:!1,tabStopWidth:8,theme:{},reflowCursorLine:!1,rescaleOverlappingGlyphs:!1,rightClickSelectsWord:wj,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},_l=["normal","bold","100","200","300","400","500","600","700","800","900"],_c=class extends vE{constructor(e){super(),this._onOptionChange=this._register(new v2),this.onOptionChange=this._onOptionChange.event;let r={..._o};for(let s in e)if(s in r)try{let n=e[s];r[s]=this._sanitizeAndValidateOption(s,n)}catch(e){console.error(e)}this.rawOptions=r,this.options={...r},this._setupOptions(),this._register(vj(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(e,r){return this.onOptionChange(s=>{s===e&&r(this.rawOptions[e])})}onMultipleOptionChange(e,r){return this.onOptionChange(s=>{-1!==e.indexOf(s)&&r()})}_setupOptions(){let e=e=>{if(!(e in _o))throw Error(`No option with key "${e}"`);return this.rawOptions[e]},r=(e,r)=>{if(!(e in _o))throw Error(`No option with key "${e}"`);r=this._sanitizeAndValidateOption(e,r),this.rawOptions[e]!==r&&(this.rawOptions[e]=r,this._onOptionChange.fire(e))};for(let s in this.rawOptions){let n={get:e.bind(this,s),set:r.bind(this,s)};Object.defineProperty(this.options,s,n)}}_sanitizeAndValidateOption(e,r){switch(e){case"cursorStyle":var s;if(r||(r=_o[e]),"block"!==(s=r)&&"underline"!==s&&"bar"!==s)throw Error(`"${r}" is not a valid value for ${e}`);break;case"wordSeparator":r||(r=_o[e]);break;case"fontWeight":case"fontWeightBold":if("number"==typeof r&&1<=r&&r<=1e3)break;r=_l.includes(r)?r:_o[e];break;case"cursorWidth":r=Math.floor(r);case"lineHeight":case"tabStopWidth":if(r<1)throw Error(`${e} cannot be less than 1, value: ${r}`);break;case"minimumContrastRatio":r=Math.max(1,Math.min(21,Math.round(10*r)/10));break;case"scrollback":if((r=Math.min(r,0xffffffff))<0)throw Error(`${e} cannot be less than 0, value: ${r}`);break;case"fastScrollSensitivity":case"scrollSensitivity":if(r<=0)throw Error(`${e} cannot be less than or equal to 0, value: ${r}`);break;case"rows":case"cols":if(!r&&0!==r)throw Error(`${e} must be numeric, value: ${r}`);break;case"windowsPty":r=r??{}}return r}};function _d(e,r=5){if("object"!=typeof e)return e;let s=Array.isArray(e)?[]:{};for(let n in e)s[n]=r<=1?e[n]:e[n]&&_d(e[n],r-1);return s}var _u=Object.freeze({insertMode:!1}),_h=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),_f=class extends vE{constructor(e,r,s){super(),this._bufferService=e,this._logService=r,this._optionsService=s,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new v2),this.onData=this._onData.event,this._onUserInput=this._register(new v2),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new v2),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new v2),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=_d(_u),this.decPrivateModes=_d(_h)}reset(){this.modes=_d(_u),this.decPrivateModes=_d(_h)}triggerDataEvent(e,r=!1){if(this._optionsService.rawOptions.disableStdin)return;let s=this._bufferService.buffer;r&&this._optionsService.rawOptions.scrollOnUserInput&&s.ybase!==s.ydisp&&this._onRequestScrollToBottom.fire(),r&&this._onUserInput.fire(),this._logService.debug(`sending data "${e}"`),this._logService.trace("sending data (codes)",()=>e.split("").map(e=>e.charCodeAt(0))),this._onData.fire(e)}triggerBinaryEvent(e){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${e}"`),this._logService.trace("sending binary (codes)",()=>e.split("").map(e=>e.charCodeAt(0))),this._onBinary.fire(e))}};_f=x$([xW(0,x4),xW(1,ve),xW(2,vt)],_f);var _p={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:e=>4!==e.button&&1===e.action&&(e.ctrl=!1,e.alt=!1,e.shift=!1,!0)},VT200:{events:19,restrict:e=>32!==e.action},DRAG:{events:23,restrict:e=>32!==e.action||3!==e.button},ANY:{events:31,restrict:e=>!0}};function _m(e,r){let s=16*!!e.ctrl|4*!!e.shift|8*!!e.alt;return 4===e.button?(s|=64,s|=e.action):(s|=3&e.button,4&e.button&&(s|=64),8&e.button&&(s|=128),32===e.action?s|=32:0!==e.action||r||(s|=3)),s}var _g=String.fromCharCode,_x={DEFAULT:e=>{let r=[_m(e,!1)+32,e.col+32,e.row+32];return r[0]>255||r[1]>255||r[2]>255?"":`\x1b[M${_g(r[0])}${_g(r[1])}${_g(r[2])}`},SGR:e=>{let r=0===e.action&&4!==e.button?"m":"M";return`\x1b[<${_m(e,!0)};${e.col};${e.row}${r}`},SGR_PIXELS:e=>{let r=0===e.action&&4!==e.button?"m":"M";return`\x1b[<${_m(e,!0)};${e.x};${e.y}${r}`}},_v=class extends vE{constructor(e,r,s){for(let n of(super(),this._bufferService=e,this._coreService=r,this._optionsService=s,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new v2),this.onProtocolChange=this._onProtocolChange.event,Object.keys(_p)))this.addProtocol(n,_p[n]);for(let e of Object.keys(_x))this.addEncoding(e,_x[e]);this.reset()}addProtocol(e,r){this._protocols[e]=r}addEncoding(e,r){this._encodings[e]=r}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return 0!==this._protocols[this._activeProtocol].events}set activeProtocol(e){if(!this._protocols[e])throw Error(`unknown protocol "${e}"`);this._activeProtocol=e,this._onProtocolChange.fire(this._protocols[e].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(e){if(!this._encodings[e])throw Error(`unknown encoding "${e}"`);this._activeEncoding=e}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null,this._wheelPartialScroll=0}consumeWheelEvent(e,r,s){if(0===e.deltaY||e.shiftKey||void 0===r||void 0===s)return 0;let n=this._applyScrollModifier(e.deltaY,e);return e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(n/=r/s+0,50>Math.abs(e.deltaY)&&(n*=.3),this._wheelPartialScroll+=n,n=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):e.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(n*=this._bufferService.rows),n}_applyScrollModifier(e,r){return r.altKey||r.ctrlKey||r.shiftKey?e*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:e*this._optionsService.rawOptions.scrollSensitivity}triggerMouseEvent(e){if(e.col<0||e.col>=this._bufferService.cols||e.row<0||e.row>=this._bufferService.rows||4===e.button&&32===e.action||3===e.button&&32!==e.action||4!==e.button&&(2===e.action||3===e.action)||(e.col++,e.row++,32===e.action&&this._lastEvent&&this._equalEvents(this._lastEvent,e,"SGR_PIXELS"===this._activeEncoding))||!this._protocols[this._activeProtocol].restrict(e))return!1;let r=this._encodings[this._activeEncoding](e);return r&&("DEFAULT"===this._activeEncoding?this._coreService.triggerBinaryEvent(r):this._coreService.triggerDataEvent(r,!0)),this._lastEvent=e,!0}explainEvents(e){return{down:!!(1&e),up:!!(2&e),drag:!!(4&e),move:!!(8&e),wheel:!!(16&e)}}_equalEvents(e,r,s){if(s){if(e.x!==r.x||e.y!==r.y)return!1}else if(e.col!==r.col||e.row!==r.row)return!1;return e.button===r.button&&e.action===r.action&&e.ctrl===r.ctrl&&e.alt===r.alt&&e.shift===r.shift}};_v=x$([xW(0,x4),xW(1,x7),xW(2,vt)],_v);var _y,_b,_w,__,_S,_k,_j=[[768,879],[1155,1158],[1160,1161],[1425,1469],[1471,1471],[1473,1474],[1476,1477],[1479,1479],[1536,1539],[1552,1557],[1611,1630],[1648,1648],[1750,1764],[1767,1768],[1770,1773],[1807,1807],[1809,1809],[1840,1866],[1958,1968],[2027,2035],[2305,2306],[2364,2364],[2369,2376],[2381,2381],[2385,2388],[2402,2403],[2433,2433],[2492,2492],[2497,2500],[2509,2509],[2530,2531],[2561,2562],[2620,2620],[2625,2626],[2631,2632],[2635,2637],[2672,2673],[2689,2690],[2748,2748],[2753,2757],[2759,2760],[2765,2765],[2786,2787],[2817,2817],[2876,2876],[2879,2879],[2881,2883],[2893,2893],[2902,2902],[2946,2946],[3008,3008],[3021,3021],[3134,3136],[3142,3144],[3146,3149],[3157,3158],[3260,3260],[3263,3263],[3270,3270],[3276,3277],[3298,3299],[3393,3395],[3405,3405],[3530,3530],[3538,3540],[3542,3542],[3633,3633],[3636,3642],[3655,3662],[3761,3761],[3764,3769],[3771,3772],[3784,3789],[3864,3865],[3893,3893],[3895,3895],[3897,3897],[3953,3966],[3968,3972],[3974,3975],[3984,3991],[3993,4028],[4038,4038],[4141,4144],[4146,4146],[4150,4151],[4153,4153],[4184,4185],[4448,4607],[4959,4959],[5906,5908],[5938,5940],[5970,5971],[6002,6003],[6068,6069],[6071,6077],[6086,6086],[6089,6099],[6109,6109],[6155,6157],[6313,6313],[6432,6434],[6439,6440],[6450,6450],[6457,6459],[6679,6680],[6912,6915],[6964,6964],[6966,6970],[6972,6972],[6978,6978],[7019,7027],[7616,7626],[7678,7679],[8203,8207],[8234,8238],[8288,8291],[8298,8303],[8400,8431],[12330,12335],[12441,12442],[43014,43014],[43019,43019],[43045,43046],[64286,64286],[65024,65039],[65056,65059],[65279,65279],[65529,65531]],_C=[[68097,68099],[68101,68102],[68108,68111],[68152,68154],[68159,68159],[119143,119145],[119155,119170],[119173,119179],[119210,119213],[119362,119364],[917505,917505],[917536,917631],[917760,917999]],_N=class{constructor(){if(this.version="6",!_k){(_k=new Uint8Array(65536)).fill(1),_k[0]=0,_k.fill(0,1,32),_k.fill(0,127,160),_k.fill(2,4352,4448),_k[9001]=2,_k[9002]=2,_k.fill(2,11904,42192),_k[12351]=1,_k.fill(2,44032,55204),_k.fill(2,63744,64256),_k.fill(2,65040,65050),_k.fill(2,65072,65136),_k.fill(2,65280,65377),_k.fill(2,65504,65511);for(let e=0;e<_j.length;++e)_k.fill(0,_j[e][0],_j[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?_k[e]:!function(e,r){let s=0,n=r.length-1,i;if(e<r[0][0]||e>r[n][1])return!1;for(;n>=s;)if(e>r[i=s+n>>1][1])s=i+1;else{if(!(e<r[i][0]))return!0;n=i-1}return!1}(e,_C)?e>=131072&&e<=196605||e>=196608&&e<=262141?2:1:0}charProperties(e,r){let s=this.wcwidth(e),n=0===s&&0!==r;if(n){let e=_E.extractWidth(r);0===e?n=!1:e>s&&(s=e)}return _E.createPropertyValue(0,s,n)}},_E=class e{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new v2,this.onChange=this._onChange.event;let e=new _N;this.register(e),this._active=e.version,this._activeProvider=e}static extractShouldJoin(e){return(1&e)!=0}static extractWidth(e){return e>>1&3}static extractCharKind(e){return e>>3}static createPropertyValue(e,r,s=!1){return(0xffffff&e)<<3|(3&r)<<1|!!s}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(e){if(!this._providers[e])throw Error(`unknown Unicode version "${e}"`);this._active=e,this._activeProvider=this._providers[e],this._onChange.fire(e)}register(e){this._providers[e.version]=e}wcwidth(e){return this._activeProvider.wcwidth(e)}getStringCellWidth(r){let s=0,n=0,i=r.length;for(let a=0;a<i;++a){let o=r.charCodeAt(a);if(55296<=o&&o<=56319){if(++a>=i)return s+this.wcwidth(o);let e=r.charCodeAt(a);56320<=e&&e<=57343?o=(o-55296)*1024+e-56320+65536:s+=this.wcwidth(e)}let l=this.charProperties(o,n),c=e.extractWidth(l);e.extractShouldJoin(l)&&(c-=e.extractWidth(n)),s+=c,n=l}return s}charProperties(e,r){return this._activeProvider.charProperties(e,r)}},_D=class{constructor(){this.glevel=0,this._charsets=[]}reset(){this.charset=void 0,this._charsets=[],this.glevel=0}setgLevel(e){this.glevel=e,this.charset=this._charsets[e]}setgCharset(e,r){this._charsets[e]=r,this.glevel===e&&(this.charset=r)}};function _T(e){let r=e.buffer.lines.get(e.buffer.ybase+e.buffer.y-1)?.get(e.cols-1),s=e.buffer.lines.get(e.buffer.ybase+e.buffer.y);s&&r&&(s.isWrapped=0!==r[3]&&32!==r[3])}var _R=class e{constructor(e=32,r=32){if(this.maxLength=e,this.maxSubParamsLength=r,r>256)throw Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(e),this.length=0,this._subParams=new Int32Array(r),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(e),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(r){let s=new e;if(!r.length)return s;for(let e=+!!Array.isArray(r[0]);e<r.length;++e){let n=r[e];if(Array.isArray(n))for(let e=0;e<n.length;++e)s.addSubParam(n[e]);else s.addParam(n)}return s}clone(){let r=new e(this.maxLength,this.maxSubParamsLength);return r.params.set(this.params),r.length=this.length,r._subParams.set(this._subParams),r._subParamsLength=this._subParamsLength,r._subParamsIdx.set(this._subParamsIdx),r._rejectDigits=this._rejectDigits,r._rejectSubDigits=this._rejectSubDigits,r._digitIsSub=this._digitIsSub,r}toArray(){let e=[];for(let r=0;r<this.length;++r){e.push(this.params[r]);let s=this._subParamsIdx[r]>>8,n=255&this._subParamsIdx[r];n-s>0&&e.push(Array.prototype.slice.call(this._subParams,s,n))}return e}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(e){if(this._digitIsSub=!1,this.length>=this.maxLength){this._rejectDigits=!0;return}if(e<-1)throw Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=e>0x7fffffff?0x7fffffff:e}addSubParam(e){if(this._digitIsSub=!0,this.length){if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength){this._rejectSubDigits=!0;return}if(e<-1)throw Error("values lesser than -1 are not allowed");this._subParams[this._subParamsLength++]=e>0x7fffffff?0x7fffffff:e,this._subParamsIdx[this.length-1]++}}hasSubParams(e){return(255&this._subParamsIdx[e])-(this._subParamsIdx[e]>>8)>0}getSubParams(e){let r=this._subParamsIdx[e]>>8,s=255&this._subParamsIdx[e];return s-r>0?this._subParams.subarray(r,s):null}getSubParamsAll(){let e={};for(let r=0;r<this.length;++r){let s=this._subParamsIdx[r]>>8,n=255&this._subParamsIdx[r];n-s>0&&(e[r]=this._subParams.slice(s,n))}return e}addDigit(e){let r;if(this._rejectDigits||!(r=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let s=this._digitIsSub?this._subParams:this.params,n=s[r-1];s[r-1]=~n?Math.min(10*n+e,0x7fffffff):e}},_A=[],_M=class{constructor(){this._state=0,this._active=_A,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(e,r){void 0===this._handlers[e]&&(this._handlers[e]=[]);let s=this._handlers[e];return s.push(r),{dispose:()=>{let e=s.indexOf(r);-1!==e&&s.splice(e,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=_A}reset(){if(2===this._state)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].end(!1);this._stack.paused=!1,this._active=_A,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||_A,this._active.length)for(let e=this._active.length-1;e>=0;e--)this._active[e].start();else this._handlerFb(this._id,"START")}_put(e,r,s){if(this._active.length)for(let n=this._active.length-1;n>=0;n--)this._active[n].put(e,r,s);else this._handlerFb(this._id,"PUT",xY(e,r,s))}start(){this.reset(),this._state=1}put(e,r,s){if(3!==this._state){if(1===this._state)for(;r<s;){let s=e[r++];if(59===s){this._state=2,this._start();break}if(s<48||57<s){this._state=3;return}-1===this._id&&(this._id=0),this._id=10*this._id+s-48}2===this._state&&s-r>0&&this._put(e,r,s)}}end(e,r=!0){if(0!==this._state){if(3!==this._state)if(1===this._state&&this._start(),this._active.length){let s=!1,n=this._active.length-1,i=!1;if(this._stack.paused&&(n=this._stack.loopPosition-1,s=r,i=this._stack.fallThrough,this._stack.paused=!1),!i&&!1===s){for(;n>=0&&!0!==(s=this._active[n].end(e));n--)if(s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=n,this._stack.fallThrough=!1,s;n--}for(;n>=0;n--)if((s=this._active[n].end(!1))instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=n,this._stack.fallThrough=!0,s}else this._handlerFb(this._id,"END",e);this._active=_A,this._id=-1,this._state=0}}},_I=class{constructor(e){this._handler=e,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(e,r,s){this._hitLimit||(this._data+=xY(e,r,s),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}end(e){let r=!1;if(this._hitLimit)r=!1;else if(e&&(r=this._handler(this._data))instanceof Promise)return r.then(e=>(this._data="",this._hitLimit=!1,e));return this._data="",this._hitLimit=!1,r}},_P=[],_F=class{constructor(){this._handlers=Object.create(null),this._active=_P,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=_P}registerHandler(e,r){void 0===this._handlers[e]&&(this._handlers[e]=[]);let s=this._handlers[e];return s.push(r),{dispose:()=>{let e=s.indexOf(r);-1!==e&&s.splice(e,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}reset(){if(this._active.length)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].unhook(!1);this._stack.paused=!1,this._active=_P,this._ident=0}hook(e,r){if(this.reset(),this._ident=e,this._active=this._handlers[e]||_P,this._active.length)for(let e=this._active.length-1;e>=0;e--)this._active[e].hook(r);else this._handlerFb(this._ident,"HOOK",r)}put(e,r,s){if(this._active.length)for(let n=this._active.length-1;n>=0;n--)this._active[n].put(e,r,s);else this._handlerFb(this._ident,"PUT",xY(e,r,s))}unhook(e,r=!0){if(this._active.length){let s=!1,n=this._active.length-1,i=!1;if(this._stack.paused&&(n=this._stack.loopPosition-1,s=r,i=this._stack.fallThrough,this._stack.paused=!1),!i&&!1===s){for(;n>=0&&!0!==(s=this._active[n].unhook(e));n--)if(s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=n,this._stack.fallThrough=!1,s;n--}for(;n>=0;n--)if((s=this._active[n].unhook(!1))instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=n,this._stack.fallThrough=!0,s}else this._handlerFb(this._ident,"UNHOOK",e);this._active=_P,this._ident=0}},_L=new _R;_L.addParam(0);var _O=class{constructor(e){this._handler=e,this._data="",this._params=_L,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():_L,this._data="",this._hitLimit=!1}put(e,r,s){this._hitLimit||(this._data+=xY(e,r,s),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}unhook(e){let r=!1;if(this._hitLimit)r=!1;else if(e&&(r=this._handler(this._data,this._params))instanceof Promise)return r.then(e=>(this._params=_L,this._data="",this._hitLimit=!1,e));return this._params=_L,this._data="",this._hitLimit=!1,r}},_B=class{constructor(e){this.table=new Uint8Array(e)}setDefault(e,r){this.table.fill(e<<4|r)}add(e,r,s,n){this.table[r<<8|e]=s<<4|n}addMany(e,r,s,n){for(let i=0;i<e.length;i++)this.table[r<<8|e[i]]=s<<4|n}},_z=function(){let e=new _B(4095),r=Array.apply(null,Array(256)).map((e,r)=>r),s=(e,s)=>r.slice(e,s),n=s(32,127),i=s(0,24);i.push(25),i.push.apply(i,s(28,32));let a=s(0,14),o;for(o in e.setDefault(1,0),e.addMany(n,0,2,0),a)e.addMany([24,26,153,154],o,3,0),e.addMany(s(128,144),o,3,0),e.addMany(s(144,152),o,3,0),e.add(156,o,0,0),e.add(27,o,11,1),e.add(157,o,4,8),e.addMany([152,158,159],o,0,7),e.add(155,o,11,3),e.add(144,o,11,9);return e.addMany(i,0,3,0),e.addMany(i,1,3,1),e.add(127,1,0,1),e.addMany(i,8,0,8),e.addMany(i,3,3,3),e.add(127,3,0,3),e.addMany(i,4,3,4),e.add(127,4,0,4),e.addMany(i,6,3,6),e.addMany(i,5,3,5),e.add(127,5,0,5),e.addMany(i,2,3,2),e.add(127,2,0,2),e.add(93,1,4,8),e.addMany(n,8,5,8),e.add(127,8,5,8),e.addMany([156,27,24,26,7],8,6,0),e.addMany(s(28,32),8,0,8),e.addMany([88,94,95],1,0,7),e.addMany(n,7,0,7),e.addMany(i,7,0,7),e.add(156,7,0,0),e.add(127,7,0,7),e.add(91,1,11,3),e.addMany(s(64,127),3,7,0),e.addMany(s(48,60),3,8,4),e.addMany([60,61,62,63],3,9,4),e.addMany(s(48,60),4,8,4),e.addMany(s(64,127),4,7,0),e.addMany([60,61,62,63],4,0,6),e.addMany(s(32,64),6,0,6),e.add(127,6,0,6),e.addMany(s(64,127),6,0,0),e.addMany(s(32,48),3,9,5),e.addMany(s(32,48),5,9,5),e.addMany(s(48,64),5,0,6),e.addMany(s(64,127),5,7,0),e.addMany(s(32,48),4,9,5),e.addMany(s(32,48),1,9,2),e.addMany(s(32,48),2,9,2),e.addMany(s(48,127),2,10,0),e.addMany(s(48,80),1,10,0),e.addMany(s(81,88),1,10,0),e.addMany([89,90,92],1,10,0),e.addMany(s(96,127),1,10,0),e.add(80,1,11,9),e.addMany(i,9,0,9),e.add(127,9,0,9),e.addMany(s(28,32),9,0,9),e.addMany(s(32,48),9,9,12),e.addMany(s(48,60),9,8,10),e.addMany([60,61,62,63],9,9,10),e.addMany(i,11,0,11),e.addMany(s(32,128),11,0,11),e.addMany(s(28,32),11,0,11),e.addMany(i,10,0,10),e.add(127,10,0,10),e.addMany(s(28,32),10,0,10),e.addMany(s(48,60),10,8,10),e.addMany([60,61,62,63],10,0,11),e.addMany(s(32,48),10,9,12),e.addMany(i,12,0,12),e.add(127,12,0,12),e.addMany(s(28,32),12,0,12),e.addMany(s(32,48),12,9,12),e.addMany(s(48,64),12,0,11),e.addMany(s(64,127),12,12,13),e.addMany(s(64,127),10,12,13),e.addMany(s(64,127),9,12,13),e.addMany(i,13,13,13),e.addMany(n,13,13,13),e.add(127,13,0,13),e.addMany([27,156,24,26],13,14,0),e.add(160,0,2,0),e.add(160,8,5,8),e.add(160,6,0,6),e.add(160,11,0,11),e.add(160,13,13,13),e}(),_$=class extends vE{constructor(e=_z){super(),this._transitions=e,this._parseStack={state:0,handlers:[],handlerPos:0,transition:0,chunkPos:0},this.initialState=0,this.currentState=this.initialState,this._params=new _R,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(e,r,s)=>{},this._executeHandlerFb=e=>{},this._csiHandlerFb=(e,r)=>{},this._escHandlerFb=e=>{},this._errorHandlerFb=e=>e,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this._register(vj(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new _M),this._dcsParser=this._register(new _F),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},()=>!0)}_identifier(e,r=[64,126]){let s=0;if(e.prefix){if(e.prefix.length>1)throw Error("only one byte as prefix supported");if((s=e.prefix.charCodeAt(0))&&60>s||s>63)throw Error("prefix must be in range 0x3c .. 0x3f")}if(e.intermediates){if(e.intermediates.length>2)throw Error("only two bytes as intermediates are supported");for(let r=0;r<e.intermediates.length;++r){let n=e.intermediates.charCodeAt(r);if(32>n||n>47)throw Error("intermediate must be in range 0x20 .. 0x2f");s<<=8,s|=n}}if(1!==e.final.length)throw Error("final must be a single byte");let n=e.final.charCodeAt(0);if(r[0]>n||n>r[1])throw Error(`final must be in range ${r[0]} .. ${r[1]}`);return s<<=8,s|=n}identToString(e){let r=[];for(;e;)r.push(String.fromCharCode(255&e)),e>>=8;return r.reverse().join("")}setPrintHandler(e){this._printHandler=e}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(e,r){let s=this._identifier(e,[48,126]);void 0===this._escHandlers[s]&&(this._escHandlers[s]=[]);let n=this._escHandlers[s];return n.push(r),{dispose:()=>{let e=n.indexOf(r);-1!==e&&n.splice(e,1)}}}clearEscHandler(e){this._escHandlers[this._identifier(e,[48,126])]&&delete this._escHandlers[this._identifier(e,[48,126])]}setEscHandlerFallback(e){this._escHandlerFb=e}setExecuteHandler(e,r){this._executeHandlers[e.charCodeAt(0)]=r}clearExecuteHandler(e){this._executeHandlers[e.charCodeAt(0)]&&delete this._executeHandlers[e.charCodeAt(0)]}setExecuteHandlerFallback(e){this._executeHandlerFb=e}registerCsiHandler(e,r){let s=this._identifier(e);void 0===this._csiHandlers[s]&&(this._csiHandlers[s]=[]);let n=this._csiHandlers[s];return n.push(r),{dispose:()=>{let e=n.indexOf(r);-1!==e&&n.splice(e,1)}}}clearCsiHandler(e){this._csiHandlers[this._identifier(e)]&&delete this._csiHandlers[this._identifier(e)]}setCsiHandlerFallback(e){this._csiHandlerFb=e}registerDcsHandler(e,r){return this._dcsParser.registerHandler(this._identifier(e),r)}clearDcsHandler(e){this._dcsParser.clearHandler(this._identifier(e))}setDcsHandlerFallback(e){this._dcsParser.setHandlerFallback(e)}registerOscHandler(e,r){return this._oscParser.registerHandler(e,r)}clearOscHandler(e){this._oscParser.clearHandler(e)}setOscHandlerFallback(e){this._oscParser.setHandlerFallback(e)}setErrorHandler(e){this._errorHandler=e}clearErrorHandler(){this._errorHandler=this._errorHandlerFb}reset(){this.currentState=this.initialState,this._oscParser.reset(),this._dcsParser.reset(),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0,0!==this._parseStack.state&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(e,r,s,n,i){this._parseStack.state=e,this._parseStack.handlers=r,this._parseStack.handlerPos=s,this._parseStack.transition=n,this._parseStack.chunkPos=i}parse(e,r,s){let n=0,i=0,a=0,o;if(this._parseStack.state)if(2===this._parseStack.state)this._parseStack.state=0,a=this._parseStack.chunkPos+1;else{if(void 0===s||1===this._parseStack.state)throw this._parseStack.state=1,Error("improper continuation due to previous async handler, giving up parsing");let r=this._parseStack.handlers,i=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(!1===s&&i>-1){for(;i>=0&&!0!==(o=r[i](this._params));i--)if(o instanceof Promise)return this._parseStack.handlerPos=i,o}this._parseStack.handlers=[];break;case 4:if(!1===s&&i>-1){for(;i>=0&&!0!==(o=r[i]());i--)if(o instanceof Promise)return this._parseStack.handlerPos=i,o}this._parseStack.handlers=[];break;case 6:if(n=e[this._parseStack.chunkPos],o=this._dcsParser.unhook(24!==n&&26!==n,s))return o;27===n&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(n=e[this._parseStack.chunkPos],o=this._oscParser.end(24!==n&&26!==n,s))return o;27===n&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0}this._parseStack.state=0,a=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=15&this._parseStack.transition}for(let s=a;s<r;++s){switch(n=e[s],(i=this._transitions.table[this.currentState<<8|(n<160?n:160)])>>4){case 2:for(let i=s+1;;++i)if(i>=r||(n=e[i])<32||n>126&&n<160||++i>=r||(n=e[i])<32||n>126&&n<160||++i>=r||(n=e[i])<32||n>126&&n<160||++i>=r||(n=e[i])<32||n>126&&n<160){this._printHandler(e,s,i),s=i-1;break}break;case 3:this._executeHandlers[n]?this._executeHandlers[n]():this._executeHandlerFb(n),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:s,code:n,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let a=this._csiHandlers[this._collect<<8|n],l=a?a.length-1:-1;for(;l>=0&&!0!==(o=a[l](this._params));l--)if(o instanceof Promise)return this._preserveStack(3,a,l,i,s),o;l<0&&this._csiHandlerFb(this._collect<<8|n,this._params),this.precedingJoinState=0;break;case 8:do switch(n){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(n-48)}while(++s<r&&(n=e[s])>47&&n<60)s--;break;case 9:this._collect<<=8,this._collect|=n;break;case 10:let c=this._escHandlers[this._collect<<8|n],d=c?c.length-1:-1;for(;d>=0&&!0!==(o=c[d]());d--)if(o instanceof Promise)return this._preserveStack(4,c,d,i,s),o;d<0&&this._escHandlerFb(this._collect<<8|n),this.precedingJoinState=0;break;case 11:this._params.reset(),this._params.addParam(0),this._collect=0;break;case 12:this._dcsParser.hook(this._collect<<8|n,this._params);break;case 13:for(let i=s+1;;++i)if(i>=r||24===(n=e[i])||26===n||27===n||n>127&&n<160){this._dcsParser.put(e,s,i),s=i-1;break}break;case 14:if(o=this._dcsParser.unhook(24!==n&&26!==n))return this._preserveStack(6,[],0,i,s),o;27===n&&(i|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break;case 4:this._oscParser.start();break;case 5:for(let i=s+1;;i++)if(i>=r||(n=e[i])<32||n>127&&n<160){this._oscParser.put(e,s,i),s=i-1;break}break;case 6:if(o=this._oscParser.end(24!==n&&26!==n))return this._preserveStack(5,[],0,i,s),o;27===n&&(i|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0}this.currentState=15&i}}},_W=/^([\da-f])\/([\da-f])\/([\da-f])$|^([\da-f]{2})\/([\da-f]{2})\/([\da-f]{2})$|^([\da-f]{3})\/([\da-f]{3})\/([\da-f]{3})$|^([\da-f]{4})\/([\da-f]{4})\/([\da-f]{4})$/,_H=/^[\da-f]+$/;function _U(e){if(!e)return;let r=e.toLowerCase();if(0===r.indexOf("rgb:")){r=r.slice(4);let e=_W.exec(r);if(e){let r=e[1]?15:e[4]?255:e[7]?4095:65535;return[Math.round(parseInt(e[1]||e[4]||e[7]||e[10],16)/r*255),Math.round(parseInt(e[2]||e[5]||e[8]||e[11],16)/r*255),Math.round(parseInt(e[3]||e[6]||e[9]||e[12],16)/r*255)]}}else if(0===r.indexOf("#")&&(r=r.slice(1),_H.exec(r)&&[3,6,9,12].includes(r.length))){let e=r.length/3,s=[0,0,0];for(let n=0;n<3;++n){let i=parseInt(r.slice(e*n,e*n+e),16);s[n]=1===e?i<<4:2===e?i:3===e?i>>4:i>>8}return s}}function _V(e,r){let s=e.toString(16),n=s.length<2?"0"+s:s;switch(r){case 4:return s[0];case 8:return n;case 12:return(n+n).slice(0,3);default:return n+n}}var _q={"(":0,")":1,"*":2,"+":3,"-":1,".":2};function _K(e,r){if(e>24)return r.setWinLines||!1;switch(e){case 1:return!!r.restoreWin;case 2:return!!r.minimizeWin;case 3:return!!r.setWinPosition;case 4:return!!r.setWinSizePixels;case 5:return!!r.raiseWin;case 6:return!!r.lowerWin;case 7:return!!r.refreshWin;case 8:return!!r.setWinSizeChars;case 9:return!!r.maximizeWin;case 10:return!!r.fullscreenWin;case 11:return!!r.getWinState;case 13:return!!r.getWinPosition;case 14:return!!r.getWinSizePixels;case 15:return!!r.getScreenSizePixels;case 16:return!!r.getCellSizePixels;case 18:return!!r.getWinSizeChars;case 19:return!!r.getScreenSizeChars;case 20:return!!r.getIconTitle;case 21:return!!r.getWinTitle;case 22:return!!r.pushTitle;case 23:return!!r.popTitle;case 24:return!!r.setWinLines}return!1}var _X=0,_Y=class extends vE{constructor(e,r,s,n,i,a,o,l,c=new _$){for(let d in super(),this._bufferService=e,this._charsetService=r,this._coreService=s,this._logService=n,this._optionsService=i,this._oscLinkService=a,this._coreMouseService=o,this._unicodeService=l,this._parser=c,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new xG,this._utf8Decoder=new xJ,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=w7.clone(),this._eraseAttrDataInternal=w7.clone(),this._onRequestBell=this._register(new v2),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new v2),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new v2),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new v2),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new v2),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new v2),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new v2),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new v2),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new v2),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new v2),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new v2),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new v2),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new v2),this.onColor=this._onColor.event,this._parseStack={paused:!1,cursorStartX:0,cursorStartY:0,decodedLength:0,position:0},this._specialColors=[256,257,258],this._register(this._parser),this._dirtyRowTracker=new _G(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(e=>this._activeBuffer=e.activeBuffer)),this._parser.setCsiHandlerFallback((e,r)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(e),params:r.toArray()})}),this._parser.setEscHandlerFallback(e=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(e)})}),this._parser.setExecuteHandlerFallback(e=>{this._logService.debug("Unknown EXECUTE code: ",{code:e})}),this._parser.setOscHandlerFallback((e,r,s)=>{this._logService.debug("Unknown OSC code: ",{identifier:e,action:r,data:s})}),this._parser.setDcsHandlerFallback((e,r,s)=>{"HOOK"===r&&(s=s.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(e),action:r,payload:s})}),this._parser.setPrintHandler((e,r,s)=>this.print(e,r,s)),this._parser.registerCsiHandler({final:"@"},e=>this.insertChars(e)),this._parser.registerCsiHandler({intermediates:" ",final:"@"},e=>this.scrollLeft(e)),this._parser.registerCsiHandler({final:"A"},e=>this.cursorUp(e)),this._parser.registerCsiHandler({intermediates:" ",final:"A"},e=>this.scrollRight(e)),this._parser.registerCsiHandler({final:"B"},e=>this.cursorDown(e)),this._parser.registerCsiHandler({final:"C"},e=>this.cursorForward(e)),this._parser.registerCsiHandler({final:"D"},e=>this.cursorBackward(e)),this._parser.registerCsiHandler({final:"E"},e=>this.cursorNextLine(e)),this._parser.registerCsiHandler({final:"F"},e=>this.cursorPrecedingLine(e)),this._parser.registerCsiHandler({final:"G"},e=>this.cursorCharAbsolute(e)),this._parser.registerCsiHandler({final:"H"},e=>this.cursorPosition(e)),this._parser.registerCsiHandler({final:"I"},e=>this.cursorForwardTab(e)),this._parser.registerCsiHandler({final:"J"},e=>this.eraseInDisplay(e,!1)),this._parser.registerCsiHandler({prefix:"?",final:"J"},e=>this.eraseInDisplay(e,!0)),this._parser.registerCsiHandler({final:"K"},e=>this.eraseInLine(e,!1)),this._parser.registerCsiHandler({prefix:"?",final:"K"},e=>this.eraseInLine(e,!0)),this._parser.registerCsiHandler({final:"L"},e=>this.insertLines(e)),this._parser.registerCsiHandler({final:"M"},e=>this.deleteLines(e)),this._parser.registerCsiHandler({final:"P"},e=>this.deleteChars(e)),this._parser.registerCsiHandler({final:"S"},e=>this.scrollUp(e)),this._parser.registerCsiHandler({final:"T"},e=>this.scrollDown(e)),this._parser.registerCsiHandler({final:"X"},e=>this.eraseChars(e)),this._parser.registerCsiHandler({final:"Z"},e=>this.cursorBackwardTab(e)),this._parser.registerCsiHandler({final:"`"},e=>this.charPosAbsolute(e)),this._parser.registerCsiHandler({final:"a"},e=>this.hPositionRelative(e)),this._parser.registerCsiHandler({final:"b"},e=>this.repeatPrecedingCharacter(e)),this._parser.registerCsiHandler({final:"c"},e=>this.sendDeviceAttributesPrimary(e)),this._parser.registerCsiHandler({prefix:">",final:"c"},e=>this.sendDeviceAttributesSecondary(e)),this._parser.registerCsiHandler({final:"d"},e=>this.linePosAbsolute(e)),this._parser.registerCsiHandler({final:"e"},e=>this.vPositionRelative(e)),this._parser.registerCsiHandler({final:"f"},e=>this.hVPosition(e)),this._parser.registerCsiHandler({final:"g"},e=>this.tabClear(e)),this._parser.registerCsiHandler({final:"h"},e=>this.setMode(e)),this._parser.registerCsiHandler({prefix:"?",final:"h"},e=>this.setModePrivate(e)),this._parser.registerCsiHandler({final:"l"},e=>this.resetMode(e)),this._parser.registerCsiHandler({prefix:"?",final:"l"},e=>this.resetModePrivate(e)),this._parser.registerCsiHandler({final:"m"},e=>this.charAttributes(e)),this._parser.registerCsiHandler({final:"n"},e=>this.deviceStatus(e)),this._parser.registerCsiHandler({prefix:"?",final:"n"},e=>this.deviceStatusPrivate(e)),this._parser.registerCsiHandler({intermediates:"!",final:"p"},e=>this.softReset(e)),this._parser.registerCsiHandler({intermediates:" ",final:"q"},e=>this.setCursorStyle(e)),this._parser.registerCsiHandler({final:"r"},e=>this.setScrollRegion(e)),this._parser.registerCsiHandler({final:"s"},e=>this.saveCursor(e)),this._parser.registerCsiHandler({final:"t"},e=>this.windowOptions(e)),this._parser.registerCsiHandler({final:"u"},e=>this.restoreCursor(e)),this._parser.registerCsiHandler({intermediates:"'",final:"}"},e=>this.insertColumns(e)),this._parser.registerCsiHandler({intermediates:"'",final:"~"},e=>this.deleteColumns(e)),this._parser.registerCsiHandler({intermediates:'"',final:"q"},e=>this.selectProtected(e)),this._parser.registerCsiHandler({intermediates:"$",final:"p"},e=>this.requestMode(e,!0)),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},e=>this.requestMode(e,!1)),this._parser.setExecuteHandler(bF.BEL,()=>this.bell()),this._parser.setExecuteHandler(bF.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(bF.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(bF.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(bF.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(bF.BS,()=>this.backspace()),this._parser.setExecuteHandler(bF.HT,()=>this.tab()),this._parser.setExecuteHandler(bF.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(bF.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(bL.IND,()=>this.index()),this._parser.setExecuteHandler(bL.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(bL.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new _I(e=>(this.setTitle(e),this.setIconName(e),!0))),this._parser.registerOscHandler(1,new _I(e=>this.setIconName(e))),this._parser.registerOscHandler(2,new _I(e=>this.setTitle(e))),this._parser.registerOscHandler(4,new _I(e=>this.setOrReportIndexedColor(e))),this._parser.registerOscHandler(8,new _I(e=>this.setHyperlink(e))),this._parser.registerOscHandler(10,new _I(e=>this.setOrReportFgColor(e))),this._parser.registerOscHandler(11,new _I(e=>this.setOrReportBgColor(e))),this._parser.registerOscHandler(12,new _I(e=>this.setOrReportCursorColor(e))),this._parser.registerOscHandler(104,new _I(e=>this.restoreIndexedColor(e))),this._parser.registerOscHandler(110,new _I(e=>this.restoreFgColor(e))),this._parser.registerOscHandler(111,new _I(e=>this.restoreBgColor(e))),this._parser.registerOscHandler(112,new _I(e=>this.restoreCursorColor(e))),this._parser.registerEscHandler({final:"7"},()=>this.saveCursor()),this._parser.registerEscHandler({final:"8"},()=>this.restoreCursor()),this._parser.registerEscHandler({final:"D"},()=>this.index()),this._parser.registerEscHandler({final:"E"},()=>this.nextLine()),this._parser.registerEscHandler({final:"H"},()=>this.tabSet()),this._parser.registerEscHandler({final:"M"},()=>this.reverseIndex()),this._parser.registerEscHandler({final:"="},()=>this.keypadApplicationMode()),this._parser.registerEscHandler({final:">"},()=>this.keypadNumericMode()),this._parser.registerEscHandler({final:"c"},()=>this.fullReset()),this._parser.registerEscHandler({final:"n"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"o"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"|"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"}"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"~"},()=>this.setgLevel(1)),this._parser.registerEscHandler({intermediates:"%",final:"@"},()=>this.selectDefaultCharset()),this._parser.registerEscHandler({intermediates:"%",final:"G"},()=>this.selectDefaultCharset()),_r)this._parser.registerEscHandler({intermediates:"(",final:d},()=>this.selectCharset("("+d)),this._parser.registerEscHandler({intermediates:")",final:d},()=>this.selectCharset(")"+d)),this._parser.registerEscHandler({intermediates:"*",final:d},()=>this.selectCharset("*"+d)),this._parser.registerEscHandler({intermediates:"+",final:d},()=>this.selectCharset("+"+d)),this._parser.registerEscHandler({intermediates:"-",final:d},()=>this.selectCharset("-"+d)),this._parser.registerEscHandler({intermediates:".",final:d},()=>this.selectCharset("."+d)),this._parser.registerEscHandler({intermediates:"/",final:d},()=>this.selectCharset("/"+d));this._parser.registerEscHandler({intermediates:"#",final:"8"},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler(e=>(this._logService.error("Parsing error: ",e),e)),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new _O((e,r)=>this.requestStatusString(e,r)))}getAttrData(){return this._curAttrData}_preserveStack(e,r,s,n){this._parseStack.paused=!0,this._parseStack.cursorStartX=e,this._parseStack.cursorStartY=r,this._parseStack.decodedLength=s,this._parseStack.position=n}_logSlowResolvingAsync(e){this._logService.logLevel<=3&&Promise.race([e,new Promise((e,r)=>setTimeout(()=>r("#SLOW_TIMEOUT"),5e3))]).catch(e=>{if("#SLOW_TIMEOUT"!==e)throw e;console.warn("async parser handler taking longer than 5000 ms")})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(e,r){let s,n=this._activeBuffer.x,i=this._activeBuffer.y,a=0,o=this._parseStack.paused;if(o){if(s=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,r))return this._logSlowResolvingAsync(s),s;n=this._parseStack.cursorStartX,i=this._parseStack.cursorStartY,this._parseStack.paused=!1,e.length>131072&&(a=this._parseStack.position+131072)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${"string"==typeof e?` "${e}"`:` "${Array.prototype.map.call(e,e=>String.fromCharCode(e)).join("")}"`}`),0===this._logService.logLevel&&this._logService.trace("parsing data (codes)","string"==typeof e?e.split("").map(e=>e.charCodeAt(0)):e),this._parseBuffer.length<e.length&&this._parseBuffer.length<131072&&(this._parseBuffer=new Uint32Array(Math.min(e.length,131072))),o||this._dirtyRowTracker.clearRange(),e.length>131072)for(let r=a;r<e.length;r+=131072){let a=r+131072<e.length?r+131072:e.length,o="string"==typeof e?this._stringDecoder.decode(e.substring(r,a),this._parseBuffer):this._utf8Decoder.decode(e.subarray(r,a),this._parseBuffer);if(s=this._parser.parse(this._parseBuffer,o))return this._preserveStack(n,i,o,r),this._logSlowResolvingAsync(s),s}else if(!o){let r="string"==typeof e?this._stringDecoder.decode(e,this._parseBuffer):this._utf8Decoder.decode(e,this._parseBuffer);if(s=this._parser.parse(this._parseBuffer,r))return this._preserveStack(n,i,r,0),this._logSlowResolvingAsync(s),s}(this._activeBuffer.x!==n||this._activeBuffer.y!==i)&&this._onCursorMove.fire();let l=this._dirtyRowTracker.end+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp),c=this._dirtyRowTracker.start+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp);c<this._bufferService.rows&&this._onRequestRefreshRows.fire({start:Math.min(c,this._bufferService.rows-1),end:Math.min(l,this._bufferService.rows-1)})}print(e,r,s){let n,i,a=this._charsetService.charset,o=this._optionsService.rawOptions.screenReaderMode,l=this._bufferService.cols,c=this._coreService.decPrivateModes.wraparound,d=this._coreService.modes.insertMode,u=this._curAttrData,h=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&s-r>0&&2===h.getWidth(this._activeBuffer.x-1)&&h.setCellFromCodepoint(this._activeBuffer.x-1,0,1,u);let f=this._parser.precedingJoinState;for(let p=r;p<s;++p){if((n=e[p])<127&&a){let e=a[String.fromCharCode(n)];e&&(n=e.charCodeAt(0))}let r=this._unicodeService.charProperties(n,f);i=_E.extractWidth(r);let s=_E.extractShouldJoin(r),m=s?_E.extractWidth(f):0;if(f=r,o&&this._onA11yChar.fire(xX(n)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+i-m>l){if(c){let e=h,r=this._activeBuffer.x-m;for(this._activeBuffer.x=m,this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData(),!0)):(this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!0),h=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),m>0&&h instanceof w9&&h.copyCellsFrom(e,r,0,m,!1);r<l;)e.setCellFromCodepoint(r++,0,1,u)}else if(this._activeBuffer.x=l-1,2===i)continue}if(s&&this._activeBuffer.x){let e=h.getWidth(this._activeBuffer.x-1)?1:2;h.addCodepointToCell(this._activeBuffer.x-e,n,i);for(let e=i-m;--e>=0;)h.setCellFromCodepoint(this._activeBuffer.x++,0,0,u);continue}if(d&&(h.insertCells(this._activeBuffer.x,i-m,this._activeBuffer.getNullCell(u)),2===h.getWidth(l-1)&&h.setCellFromCodepoint(l-1,0,1,u)),h.setCellFromCodepoint(this._activeBuffer.x++,n,i,u),i>0)for(;--i;)h.setCellFromCodepoint(this._activeBuffer.x++,0,0,u)}this._parser.precedingJoinState=f,this._activeBuffer.x<l&&s-r>0&&0===h.getWidth(this._activeBuffer.x)&&!h.hasContent(this._activeBuffer.x)&&h.setCellFromCodepoint(this._activeBuffer.x,0,1,u),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(e,r){return"t"!==e.final||e.prefix||e.intermediates?this._parser.registerCsiHandler(e,r):this._parser.registerCsiHandler(e,e=>!_K(e.params[0],this._optionsService.rawOptions.windowOptions)||r(e))}registerDcsHandler(e,r){return this._parser.registerDcsHandler(e,new _O(r))}registerEscHandler(e,r){return this._parser.registerEscHandler(e,r)}registerOscHandler(e,r){return this._parser.registerOscHandler(e,new _I(r))}bell(){return this._onRequestBell.fire(),!0}lineFeed(){return this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._optionsService.rawOptions.convertEol&&(this._activeBuffer.x=0),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows?this._activeBuffer.y=this._bufferService.rows-1:this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.x>=this._bufferService.cols&&this._activeBuffer.x--,this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._onLineFeed.fire(),!0}carriageReturn(){return this._activeBuffer.x=0,!0}backspace(){if(!this._coreService.decPrivateModes.reverseWraparound)return this._restrictCursor(),this._activeBuffer.x>0&&this._activeBuffer.x--,!0;if(this._restrictCursor(this._bufferService.cols),this._activeBuffer.x>0)this._activeBuffer.x--;else if(0===this._activeBuffer.x&&this._activeBuffer.y>this._activeBuffer.scrollTop&&this._activeBuffer.y<=this._activeBuffer.scrollBottom&&this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y)?.isWrapped){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;let e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);e.hasWidth(this._activeBuffer.x)&&!e.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let e=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-e),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(e=this._bufferService.cols-1){this._activeBuffer.x=Math.min(e,Math.max(0,this._activeBuffer.x)),this._activeBuffer.y=this._coreService.decPrivateModes.origin?Math.min(this._activeBuffer.scrollBottom,Math.max(this._activeBuffer.scrollTop,this._activeBuffer.y)):Math.min(this._bufferService.rows-1,Math.max(0,this._activeBuffer.y)),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_setCursor(e,r){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=e,this._activeBuffer.y=this._activeBuffer.scrollTop+r):(this._activeBuffer.x=e,this._activeBuffer.y=r),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(e,r){this._restrictCursor(),this._setCursor(this._activeBuffer.x+e,this._activeBuffer.y+r)}cursorUp(e){let r=this._activeBuffer.y-this._activeBuffer.scrollTop;return r>=0?this._moveCursor(0,-Math.min(r,e.params[0]||1)):this._moveCursor(0,-(e.params[0]||1)),!0}cursorDown(e){let r=this._activeBuffer.scrollBottom-this._activeBuffer.y;return r>=0?this._moveCursor(0,Math.min(r,e.params[0]||1)):this._moveCursor(0,e.params[0]||1),!0}cursorForward(e){return this._moveCursor(e.params[0]||1,0),!0}cursorBackward(e){return this._moveCursor(-(e.params[0]||1),0),!0}cursorNextLine(e){return this.cursorDown(e),this._activeBuffer.x=0,!0}cursorPrecedingLine(e){return this.cursorUp(e),this._activeBuffer.x=0,!0}cursorCharAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(e){return this._setCursor(e.length>=2?(e.params[1]||1)-1:0,(e.params[0]||1)-1),!0}charPosAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(e){return this._moveCursor(e.params[0]||1,0),!0}linePosAbsolute(e){return this._setCursor(this._activeBuffer.x,(e.params[0]||1)-1),!0}vPositionRelative(e){return this._moveCursor(0,e.params[0]||1),!0}hVPosition(e){return this.cursorPosition(e),!0}tabClear(e){let r=e.params[0];return 0===r?delete this._activeBuffer.tabs[this._activeBuffer.x]:3===r&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let r=e.params[0]||1;for(;r--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let r=e.params[0]||1;for(;r--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(e){let r=e.params[0];return 1===r&&(this._curAttrData.bg|=0x20000000),(2===r||0===r)&&(this._curAttrData.bg&=-0x20000001),!0}_eraseInBufferLine(e,r,s,n=!1,i=!1){let a=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);a.replaceCells(r,s,this._activeBuffer.getNullCell(this._eraseAttrData()),i),n&&(a.isWrapped=!1)}_resetBufferLine(e,r=!1){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);s&&(s.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),r),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+e),s.isWrapped=!1)}eraseInDisplay(e,r=!1){let s;switch(this._restrictCursor(this._bufferService.cols),e.params[0]){case 0:for(s=this._activeBuffer.y,this._dirtyRowTracker.markDirty(s),this._eraseInBufferLine(s++,this._activeBuffer.x,this._bufferService.cols,0===this._activeBuffer.x,r);s<this._bufferService.rows;s++)this._resetBufferLine(s,r);this._dirtyRowTracker.markDirty(s);break;case 1:for(s=this._activeBuffer.y,this._dirtyRowTracker.markDirty(s),this._eraseInBufferLine(s,0,this._activeBuffer.x+1,!0,r),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(s+1).isWrapped=!1);s--;)this._resetBufferLine(s,r);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(s=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,s-1);s--&&!this._activeBuffer.lines.get(this._activeBuffer.ybase+s)?.getTrimmedLength(););for(;s>=0;s--)this._bufferService.scroll(this._eraseAttrData())}else{for(s=this._bufferService.rows,this._dirtyRowTracker.markDirty(s-1);s--;)this._resetBufferLine(s,r);this._dirtyRowTracker.markDirty(0)}break;case 3:let n=this._activeBuffer.lines.length-this._bufferService.rows;n>0&&(this._activeBuffer.lines.trimStart(n),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-n,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-n,0),this._onScroll.fire(0))}return!0}eraseInLine(e,r=!1){switch(this._restrictCursor(this._bufferService.cols),e.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,0===this._activeBuffer.x,r);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,r);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,r)}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(e){this._restrictCursor();let r=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let s=this._activeBuffer.ybase+this._activeBuffer.y,n=this._bufferService.rows-1-this._activeBuffer.scrollBottom,i=this._bufferService.rows-1+this._activeBuffer.ybase-n+1;for(;r--;)this._activeBuffer.lines.splice(i-1,1),this._activeBuffer.lines.splice(s,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(e){this._restrictCursor();let r=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let s=this._activeBuffer.ybase+this._activeBuffer.y,n;for(n=this._bufferService.rows-1-this._activeBuffer.scrollBottom,n=this._bufferService.rows-1+this._activeBuffer.ybase-n;r--;)this._activeBuffer.lines.splice(s,1),this._activeBuffer.lines.splice(n,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(e){this._restrictCursor();let r=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return r&&(r.insertCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(e){this._restrictCursor();let r=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return r&&(r.deleteCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(e){let r=e.params[0]||1;for(;r--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollDown(e){let r=e.params[0]||1;for(;r--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,0,this._activeBuffer.getBlankLine(w7));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let r=e.params[0]||1;for(let e=this._activeBuffer.scrollTop;e<=this._activeBuffer.scrollBottom;++e){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);s.deleteCells(0,r,this._activeBuffer.getNullCell(this._eraseAttrData())),s.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let r=e.params[0]||1;for(let e=this._activeBuffer.scrollTop;e<=this._activeBuffer.scrollBottom;++e){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);s.insertCells(0,r,this._activeBuffer.getNullCell(this._eraseAttrData())),s.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let r=e.params[0]||1;for(let e=this._activeBuffer.scrollTop;e<=this._activeBuffer.scrollBottom;++e){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);s.insertCells(this._activeBuffer.x,r,this._activeBuffer.getNullCell(this._eraseAttrData())),s.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let r=e.params[0]||1;for(let e=this._activeBuffer.scrollTop;e<=this._activeBuffer.scrollBottom;++e){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);s.deleteCells(this._activeBuffer.x,r,this._activeBuffer.getNullCell(this._eraseAttrData())),s.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(e){this._restrictCursor();let r=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return r&&(r.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(e.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(e){let r=this._parser.precedingJoinState;if(!r)return!0;let s=e.params[0]||1,n=_E.extractWidth(r),i=this._activeBuffer.x-n,a=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(i),o=new Uint32Array(a.length*s),l=0;for(let e=0;e<a.length;){let r=a.codePointAt(e)||0;o[l++]=r,e+=r>65535?2:1}let c=l;for(let e=1;e<s;++e)o.copyWithin(c,0,l),c+=l;return this.print(o,0,c),!0}sendDeviceAttributesPrimary(e){return e.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(bF.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(bF.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(bF.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(bF.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(e.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(bF.ESC+"[>83;40003;0c")),!0}_is(e){return 0===(this._optionsService.rawOptions.termName+"").indexOf(e)}setMode(e){for(let r=0;r<e.length;r++)switch(e.params[r]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0}return!0}setModePrivate(e){for(let r=0;r<e.length;r++)switch(e.params[r]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,_s),this._charsetService.setgCharset(1,_s),this._charsetService.setgCharset(2,_s),this._charsetService.setgCharset(3,_s);break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(132,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!0,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!0;break;case 12:this._optionsService.options.cursorBlink=!0;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!0;break;case 66:this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire();break;case 9:this._coreMouseService.activeProtocol="X10";break;case 1e3:this._coreMouseService.activeProtocol="VT200";break;case 1002:this._coreMouseService.activeProtocol="DRAG";break;case 1003:this._coreMouseService.activeProtocol="ANY";break;case 1004:this._coreService.decPrivateModes.sendFocus=!0,this._onRequestSendFocus.fire();break;case 1005:this._logService.debug("DECSET 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="SGR";break;case 1015:this._logService.debug("DECSET 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="SGR_PIXELS";break;case 25:this._coreService.isCursorHidden=!1;break;case 1048:this.saveCursor();break;case 1049:this.saveCursor();case 47:case 1047:this._bufferService.buffers.activateAltBuffer(this._eraseAttrData()),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!0;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!0}return!0}resetMode(e){for(let r=0;r<e.length;r++)switch(e.params[r]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1}return!0}resetModePrivate(e){for(let r=0;r<e.length;r++)switch(e.params[r]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!1;break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(80,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!1,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!1;break;case 12:this._optionsService.options.cursorBlink=!1;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!1;break;case 66:this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire();break;case 9:case 1e3:case 1002:case 1003:this._coreMouseService.activeProtocol="NONE";break;case 1004:this._coreService.decPrivateModes.sendFocus=!1;break;case 1005:this._logService.debug("DECRST 1005 not supported (see #2507)");break;case 1006:case 1016:this._coreMouseService.activeEncoding="DEFAULT";break;case 1015:this._logService.debug("DECRST 1015 not supported (see #2507)");break;case 25:this._coreService.isCursorHidden=!0;break;case 1048:this.restoreCursor();break;case 1049:case 47:case 1047:this._bufferService.buffers.activateNormalBuffer(),1049===e.params[r]&&this.restoreCursor(),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!1;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!1,this._onRequestRefreshRows.fire(void 0)}return!0}requestMode(e,r){let s,n,i,a;(n=s||={})[n.NOT_RECOGNIZED=0]="NOT_RECOGNIZED",n[n.SET=1]="SET",n[n.RESET=2]="RESET",n[n.PERMANENTLY_SET=3]="PERMANENTLY_SET",n[n.PERMANENTLY_RESET=4]="PERMANENTLY_RESET";let o=this._coreService.decPrivateModes,{activeProtocol:l,activeEncoding:c}=this._coreMouseService,d=this._coreService,{buffers:u,cols:h}=this._bufferService,{active:f,alt:p}=u,m=this._optionsService.rawOptions,g=e=>e?1:2,x=e.params[0];return i=x,a=r?2===x?4:4===x?g(d.modes.insertMode):12===x?3:20===x?g(m.convertEol):0:1===x?g(o.applicationCursorKeys):3===x?m.windowOptions.setWinLines?80===h?2:+(132===h):0:6===x?g(o.origin):7===x?g(o.wraparound):8===x?3:9===x?g("X10"===l):12===x?g(m.cursorBlink):25===x?g(!d.isCursorHidden):45===x?g(o.reverseWraparound):66===x?g(o.applicationKeypad):67===x?4:1e3===x?g("VT200"===l):1002===x?g("DRAG"===l):1003===x?g("ANY"===l):1004===x?g(o.sendFocus):1005===x?4:1006===x?g("SGR"===c):1015===x?4:1016===x?g("SGR_PIXELS"===c):1048===x?1:47===x||1047===x||1049===x?g(f===p):2004===x?g(o.bracketedPasteMode):2026===x?g(o.synchronizedOutput):0,d.triggerDataEvent(`${bF.ESC}[${r?"":"?"}${i};${a}$y`),!0}_updateAttrColor(e,r,s,n,i){return 2===r?(e|=0x3000000,e&=-0x1000000,e|=xZ.fromColorRGB([s,n,i])):5===r&&(e&=-0x3000100,e|=0x2000000|255&s),e}_extractColor(e,r,s){let n=[0,0,-1,0,0,0],i=0,a=0;do{if(n[a+i]=e.params[r+a],e.hasSubParams(r+a)){let s=e.getSubParams(r+a),o=0;do 5===n[1]&&(i=1),n[a+o+1+i]=s[o];while(++o<s.length&&o+a+1+i<n.length)break}if(5===n[1]&&a+i>=2||2===n[1]&&a+i>=5)break;n[1]&&(i=1)}while(++a+r<e.length&&a+i<n.length)for(let e=2;e<n.length;++e)-1===n[e]&&(n[e]=0);switch(n[0]){case 38:s.fg=this._updateAttrColor(s.fg,n[1],n[3],n[4],n[5]);break;case 48:s.bg=this._updateAttrColor(s.bg,n[1],n[3],n[4],n[5]);break;case 58:s.extended=s.extended.clone(),s.extended.underlineColor=this._updateAttrColor(s.extended.underlineColor,n[1],n[3],n[4],n[5])}return a}_processUnderline(e,r){r.extended=r.extended.clone(),(!~e||e>5)&&(e=1),r.extended.underlineStyle=e,r.fg|=0x10000000,0===e&&(r.fg&=-0x10000001),r.updateExtended()}_processSGR0(e){e.fg=w7.fg,e.bg=w7.bg,e.extended=e.extended.clone(),e.extended.underlineStyle=0,e.extended.underlineColor&=-0x4000000,e.updateExtended()}charAttributes(e){if(1===e.length&&0===e.params[0])return this._processSGR0(this._curAttrData),!0;let r=e.length,s,n=this._curAttrData;for(let i=0;i<r;i++)(s=e.params[i])>=30&&s<=37?(n.fg&=-0x3000100,n.fg|=0x1000000|s-30):s>=40&&s<=47?(n.bg&=-0x3000100,n.bg|=0x1000000|s-40):s>=90&&s<=97?(n.fg&=-0x3000100,n.fg|=0x1000000|s-90|8):s>=100&&s<=107?(n.bg&=-0x3000100,n.bg|=0x1000000|s-100|8):0===s?this._processSGR0(n):1===s?n.fg|=0x8000000:3===s?n.bg|=0x4000000:4===s?(n.fg|=0x10000000,this._processUnderline(e.hasSubParams(i)?e.getSubParams(i)[0]:1,n)):5===s?n.fg|=0x20000000:7===s?n.fg|=0x4000000:8===s?n.fg|=0x40000000:9===s?n.fg|=0x80000000:2===s?n.bg|=0x8000000:21===s?this._processUnderline(2,n):22===s?(n.fg&=-0x8000001,n.bg&=-0x8000001):23===s?n.bg&=-0x4000001:24===s?(n.fg&=-0x10000001,this._processUnderline(0,n)):25===s?n.fg&=-0x20000001:27===s?n.fg&=-0x4000001:28===s?n.fg&=-0x40000001:29===s?n.fg&=0x7fffffff:39===s?(n.fg&=-0x4000000,n.fg|=0xffffff&w7.fg):49===s?(n.bg&=-0x4000000,n.bg|=0xffffff&w7.bg):38===s||48===s||58===s?i+=this._extractColor(e,i,n):53===s?n.bg|=0x40000000:55===s?n.bg&=-0x40000001:59===s?(n.extended=n.extended.clone(),n.extended.underlineColor=-1,n.updateExtended()):100===s?(n.fg&=-0x4000000,n.fg|=0xffffff&w7.fg,n.bg&=-0x4000000,n.bg|=0xffffff&w7.bg):this._logService.debug("Unknown SGR attribute: %d.",s);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${bF.ESC}[0n`);break;case 6:let r=this._activeBuffer.y+1,s=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${bF.ESC}[${r};${s}R`)}return!0}deviceStatusPrivate(e){if(6===e.params[0]){let e=this._activeBuffer.y+1,r=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${bF.ESC}[?${e};${r}R`)}return!0}softReset(e){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=w7.clone(),this._coreService.reset(),this._charsetService.reset(),this._activeBuffer.savedX=0,this._activeBuffer.savedY=this._activeBuffer.ybase,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,this._coreService.decPrivateModes.origin=!1,!0}setCursorStyle(e){let r=0===e.length?1:e.params[0];if(0===r)this._coreService.decPrivateModes.cursorStyle=void 0,this._coreService.decPrivateModes.cursorBlink=void 0;else{switch(r){case 1:case 2:this._coreService.decPrivateModes.cursorStyle="block";break;case 3:case 4:this._coreService.decPrivateModes.cursorStyle="underline";break;case 5:case 6:this._coreService.decPrivateModes.cursorStyle="bar"}this._coreService.decPrivateModes.cursorBlink=r%2==1}return!0}setScrollRegion(e){let r=e.params[0]||1,s;return(e.length<2||(s=e.params[1])>this._bufferService.rows||0===s)&&(s=this._bufferService.rows),s>r&&(this._activeBuffer.scrollTop=r-1,this._activeBuffer.scrollBottom=s-1,this._setCursor(0,0)),!0}windowOptions(e){if(!_K(e.params[0],this._optionsService.rawOptions.windowOptions))return!0;let r=e.length>1?e.params[1]:0;switch(e.params[0]){case 14:2!==r&&this._onRequestWindowsOptionsReport.fire(0);break;case 16:this._onRequestWindowsOptionsReport.fire(1);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${bF.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(0===r||2===r)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>10&&this._windowTitleStack.shift()),(0===r||1===r)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>10&&this._iconNameStack.shift());break;case 23:(0===r||2===r)&&this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),(0===r||1===r)&&this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop())}return!0}saveCursor(e){return this._activeBuffer.savedX=this._activeBuffer.x,this._activeBuffer.savedY=this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,!0}restoreCursor(e){return this._activeBuffer.x=this._activeBuffer.savedX||0,this._activeBuffer.y=Math.max(this._activeBuffer.savedY-this._activeBuffer.ybase,0),this._curAttrData.fg=this._activeBuffer.savedCurAttrData.fg,this._curAttrData.bg=this._activeBuffer.savedCurAttrData.bg,this._charsetService.charset=this._savedCharset,this._activeBuffer.savedCharset&&(this._charsetService.charset=this._activeBuffer.savedCharset),this._restrictCursor(),!0}setTitle(e){return this._windowTitle=e,this._onTitleChange.fire(e),!0}setIconName(e){return this._iconName=e,!0}setOrReportIndexedColor(e){let r=[],s=e.split(";");for(;s.length>1;){let e=s.shift(),n=s.shift();if(/^\d+$/.exec(e)){let s=parseInt(e);if(_J(s))if("?"===n)r.push({type:0,index:s});else{let e=_U(n);e&&r.push({type:1,index:s,color:e})}}}return r.length&&this._onColor.fire(r),!0}setHyperlink(e){let r=e.indexOf(";");if(-1===r)return!0;let s=e.slice(0,r).trim(),n=e.slice(r+1);return n?this._createHyperlink(s,n):!s.trim()&&this._finishHyperlink()}_createHyperlink(e,r){this._getCurrentLinkId()&&this._finishHyperlink();let s=e.split(":"),n,i=s.findIndex(e=>e.startsWith("id="));return -1!==i&&(n=s[i].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:n,uri:r}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(e,r){let s=e.split(";");for(let e=0;e<s.length&&!(r>=this._specialColors.length);++e,++r)if("?"===s[e])this._onColor.fire([{type:0,index:this._specialColors[r]}]);else{let n=_U(s[e]);n&&this._onColor.fire([{type:1,index:this._specialColors[r],color:n}])}return!0}setOrReportFgColor(e){return this._setOrReportSpecialColor(e,0)}setOrReportBgColor(e){return this._setOrReportSpecialColor(e,1)}setOrReportCursorColor(e){return this._setOrReportSpecialColor(e,2)}restoreIndexedColor(e){if(!e)return this._onColor.fire([{type:2}]),!0;let r=[],s=e.split(";");for(let e=0;e<s.length;++e)if(/^\d+$/.exec(s[e])){let n=parseInt(s[e]);_J(n)&&r.push({type:2,index:n})}return r.length&&this._onColor.fire(r),!0}restoreFgColor(e){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor(e){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor(e){return this._onColor.fire([{type:2,index:258}]),!0}nextLine(){return this._activeBuffer.x=0,this.index(),!0}keypadApplicationMode(){return this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire(),!0}keypadNumericMode(){return this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire(),!0}selectDefaultCharset(){return this._charsetService.setgLevel(0),this._charsetService.setgCharset(0,_s),!0}selectCharset(e){return 2!==e.length?this.selectDefaultCharset():"/"===e[0]||this._charsetService.setgCharset(_q[e[0]],_r[e[1]]||_s),!0}index(){return this._restrictCursor(),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._restrictCursor(),!0}tabSet(){return this._activeBuffer.tabs[this._activeBuffer.x]=!0,!0}reverseIndex(){if(this._restrictCursor(),this._activeBuffer.y===this._activeBuffer.scrollTop){let e=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,e,1),this._activeBuffer.lines.set(this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.getBlankLine(this._eraseAttrData())),this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom)}else this._activeBuffer.y--,this._restrictCursor();return!0}fullReset(){return this._parser.reset(),this._onRequestReset.fire(),!0}reset(){this._curAttrData=w7.clone(),this._eraseAttrDataInternal=w7.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-0x4000000,this._eraseAttrDataInternal.bg|=0x3ffffff&this._curAttrData.bg,this._eraseAttrDataInternal}setgLevel(e){return this._charsetService.setgLevel(e),!0}screenAlignmentPattern(){let e=new x0;e.content=4194373,e.fg=this._curAttrData.fg,e.bg=this._curAttrData.bg,this._setCursor(0,0);for(let r=0;r<this._bufferService.rows;++r){let s=this._activeBuffer.ybase+this._activeBuffer.y+r,n=this._activeBuffer.lines.get(s);n&&(n.fill(e),n.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(e,r){let s=e=>(this._coreService.triggerDataEvent(`${bF.ESC}${e}${bF.ESC}\\`),!0),n=this._bufferService.buffer,i=this._optionsService.rawOptions;return s('"q'===e?`P1$r${+!!this._curAttrData.isProtected()}"q`:'"p'===e?'P1$r61;1"p':"r"===e?`P1$r${n.scrollTop+1};${n.scrollBottom+1}r`:"m"===e?"P1$r0m":" q"===e?`P1$r${({block:2,underline:4,bar:6})[i.cursorStyle]-!!i.cursorBlink} q`:"P0$r")}markRangeDirty(e,r){this._dirtyRowTracker.markRangeDirty(e,r)}},_G=class{constructor(e){this._bufferService=e,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(e){e<this.start?this.start=e:e>this.end&&(this.end=e)}markRangeDirty(e,r){e>r&&(_X=e,e=r,r=_X),e<this.start&&(this.start=e),r>this.end&&(this.end=r)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};function _J(e){return 0<=e&&e<256}_G=x$([xW(0,x4)],_G);var _Z=class extends vE{constructor(e){super(),this._action=e,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this._register(new v2),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(e,r){let s;if(void 0!==r&&this._syncCalls>r){this._syncCalls=0;return}if(this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(void 0),this._syncCalls++,!this._isSyncWriting){for(this._isSyncWriting=!0;s=this._writeBuffer.shift();){this._action(s);let e=this._callbacks.shift();e&&e()}this._pendingData=0,this._bufferOffset=0x7fffffff,this._isSyncWriting=!1,this._syncCalls=0}}write(e,r){if(this._pendingData>5e7)throw Error("write data discarded, use flow control to avoid losing data");if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput){this._didUserInput=!1,this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(r),this._innerWrite();return}setTimeout(()=>this._innerWrite())}this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(r)}_innerWrite(e=0,r=!0){let s=e||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let e=this._writeBuffer[this._bufferOffset],n=this._action(e,r);if(n){let e=e=>performance.now()-s>=12?setTimeout(()=>this._innerWrite(0,e)):this._innerWrite(s,e);n.catch(e=>(queueMicrotask(()=>{throw e}),Promise.resolve(!1))).then(e);return}let i=this._callbacks[this._bufferOffset];if(i&&i(),this._bufferOffset++,this._pendingData-=e.length,performance.now()-s>=12)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>50&&(this._writeBuffer=this._writeBuffer.slice(this._bufferOffset),this._callbacks=this._callbacks.slice(this._bufferOffset),this._bufferOffset=0),setTimeout(()=>this._innerWrite())):(this._writeBuffer.length=0,this._callbacks.length=0,this._pendingData=0,this._bufferOffset=0),this._onWriteParsed.fire()}},_Q=class{constructor(e){this._bufferService=e,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(e){let r=this._bufferService.buffer;if(void 0===e.id){let s=r.addMarker(r.ybase+r.y),n={data:e,id:this._nextId++,lines:[s]};return s.onDispose(()=>this._removeMarkerFromLink(n,s)),this._dataByLinkId.set(n.id,n),n.id}let s=this._getEntryIdKey(e),n=this._entriesWithId.get(s);if(n)return this.addLineToLink(n.id,r.ybase+r.y),n.id;let i=r.addMarker(r.ybase+r.y),a={id:this._nextId++,key:this._getEntryIdKey(e),data:e,lines:[i]};return i.onDispose(()=>this._removeMarkerFromLink(a,i)),this._entriesWithId.set(a.key,a),this._dataByLinkId.set(a.id,a),a.id}addLineToLink(e,r){let s=this._dataByLinkId.get(e);if(s&&s.lines.every(e=>e.line!==r)){let e=this._bufferService.buffer.addMarker(r);s.lines.push(e),e.onDispose(()=>this._removeMarkerFromLink(s,e))}}getLinkData(e){return this._dataByLinkId.get(e)?.data}_getEntryIdKey(e){return`${e.id};;${e.uri}`}_removeMarkerFromLink(e,r){let s=e.lines.indexOf(r);-1!==s&&(e.lines.splice(s,1),0===e.lines.length&&(void 0!==e.data.id&&this._entriesWithId.delete(e.key),this._dataByLinkId.delete(e.id)))}};_Q=x$([xW(0,x4)],_Q);var _0=!1,_1=class extends vE{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new vD),this._onBinary=this._register(new v2),this.onBinary=this._onBinary.event,this._onData=this._register(new v2),this.onData=this._onData.event,this._onLineFeed=this._register(new v2),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new v2),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new v2),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new v2),this._instantiationService=new w5,this.optionsService=this._register(new _c(e)),this._instantiationService.setService(vt,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(_a)),this._instantiationService.setService(x4,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(w4)),this._instantiationService.setService(ve,this._logService),this.coreService=this._register(this._instantiationService.createInstance(_f)),this._instantiationService.setService(x7,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(_v)),this._instantiationService.setService(x6,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(_E)),this._instantiationService.setService(vs,this.unicodeService),this._charsetService=this._instantiationService.createInstance(_D),this._instantiationService.setService(x8,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(_Q),this._instantiationService.setService(vr,this._oscLinkService),this._inputHandler=this._register(new _Y(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(vY.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(vY.forward(this._bufferService.onResize,this._onResize)),this._register(vY.forward(this.coreService.onData,this._onData)),this._register(vY.forward(this.coreService.onBinary,this._onBinary)),this._register(this.coreService.onRequestScrollToBottom(()=>this.scrollToBottom(!0))),this._register(this.coreService.onUserInput(()=>this._writeBuffer.handleUserInput())),this._register(this.optionsService.onMultipleOptionChange(["windowsMode","windowsPty"],()=>this._handleWindowsPtyOptionChange())),this._register(this._bufferService.onScroll(()=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)})),this._writeBuffer=this._register(new _Z((e,r)=>this._inputHandler.parse(e,r))),this._register(vY.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new v2),this._onScroll.event(e=>{this._onScrollApi?.fire(e.position)})),this._onScrollApi.event}get cols(){return this._bufferService.cols}get rows(){return this._bufferService.rows}get buffers(){return this._bufferService.buffers}get options(){return this.optionsService.options}set options(e){for(let r in e)this.optionsService.options[r]=e[r]}write(e,r){this._writeBuffer.write(e,r)}writeSync(e,r){this._logService.logLevel<=3&&!_0&&(this._logService.warn("writeSync is unreliable and will be removed soon."),_0=!0),this._writeBuffer.writeSync(e,r)}input(e,r=!0){this.coreService.triggerDataEvent(e,r)}resize(e,r){isNaN(e)||isNaN(r)||(e=Math.max(e,2),r=Math.max(r,1),this._bufferService.resize(e,r))}scroll(e,r=!1){this._bufferService.scroll(e,r)}scrollLines(e,r){this._bufferService.scrollLines(e,r)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let r=e-this._bufferService.buffer.ydisp;0!==r&&this.scrollLines(r)}registerEscHandler(e,r){return this._inputHandler.registerEscHandler(e,r)}registerDcsHandler(e,r){return this._inputHandler.registerDcsHandler(e,r)}registerCsiHandler(e,r){return this._inputHandler.registerCsiHandler(e,r)}registerOscHandler(e,r){return this._inputHandler.registerOscHandler(e,r)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let e=!1,r=this.optionsService.rawOptions.windowsPty;r&&void 0!==r.buildNumber&&void 0!==r.buildNumber?e="conpty"===r.backend&&r.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(e=!0),e?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){let e=[];e.push(this.onLineFeed(_T.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:"H"},()=>(_T(this._bufferService),!1))),this._windowsWrappingHeuristics.value=vj(()=>{for(let r of e)r.dispose()})}}},_2={48:["0",")"],49:["1","!"],50:["2","@"],51:["3","#"],52:["4","$"],53:["5","%"],54:["6","^"],55:["7","&"],56:["8","*"],57:["9","("],186:[";",":"],187:["=","+"],188:[",","<"],189:["-","_"],190:[".",">"],191:["/","?"],192:["`","~"],219:["[","{"],220:["\\","|"],221:["]","}"],222:["'",'"']},_5=0,_3=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new wI,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new wI,this._isFlushingDeleted=!1}clear(){this._array.length=0,this._insertedValues.length=0,this._flushInsertedTask.clear(),this._isFlushingInserted=!1,this._deletedIndices.length=0,this._flushDeletedTask.clear(),this._isFlushingDeleted=!1}insert(e){this._flushCleanupDeleted(),0===this._insertedValues.length&&this._flushInsertedTask.enqueue(()=>this._flushInserted()),this._insertedValues.push(e)}_flushInserted(){let e=this._insertedValues.sort((e,r)=>this._getKey(e)-this._getKey(r)),r=0,s=0,n=Array(this._array.length+this._insertedValues.length);for(let i=0;i<n.length;i++)s>=this._array.length||this._getKey(e[r])<=this._getKey(this._array[s])?(n[i]=e[r],r++):n[i]=this._array[s++];this._array=n,this._insertedValues.length=0}_flushCleanupInserted(){!this._isFlushingInserted&&this._insertedValues.length>0&&this._flushInsertedTask.flush()}delete(e){if(this._flushCleanupInserted(),0===this._array.length)return!1;let r=this._getKey(e);if(void 0===r||-1===(_5=this._search(r))||this._getKey(this._array[_5])!==r)return!1;do if(this._array[_5]===e)return 0===this._deletedIndices.length&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(_5),!0;while(++_5<this._array.length&&this._getKey(this._array[_5])===r)return!1}_flushDeleted(){this._isFlushingDeleted=!0;let e=this._deletedIndices.sort((e,r)=>e-r),r=0,s=Array(this._array.length-e.length),n=0;for(let i=0;i<this._array.length;i++)e[r]===i?r++:s[n++]=this._array[i];this._array=s,this._deletedIndices.length=0,this._isFlushingDeleted=!1}_flushCleanupDeleted(){!this._isFlushingDeleted&&this._deletedIndices.length>0&&this._flushDeletedTask.flush()}*getKeyIterator(e){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),0!==this._array.length&&!((_5=this._search(e))<0||_5>=this._array.length)&&this._getKey(this._array[_5])===e)do yield this._array[_5];while(++_5<this._array.length&&this._getKey(this._array[_5])===e)}forEachByKey(e,r){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),0!==this._array.length&&!((_5=this._search(e))<0||_5>=this._array.length)&&this._getKey(this._array[_5])===e)do r(this._array[_5]);while(++_5<this._array.length&&this._getKey(this._array[_5])===e)}values(){return this._flushCleanupInserted(),this._flushCleanupDeleted(),[...this._array].values()}_search(e){let r=0,s=this._array.length-1;for(;s>=r;){let n=r+s>>1,i=this._getKey(this._array[n]);if(i>e)s=n-1;else if(i<e)r=n+1;else{for(;n>0&&this._getKey(this._array[n-1])===e;)n--;return n}}return r}},_4=0,_6=0,_7=class extends vE{constructor(){super(),this._decorations=new _3(e=>e?.marker.line),this._onDecorationRegistered=this._register(new v2),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new v2),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(vj(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let r=new _8(e);if(r){let e=r.marker.onDispose(()=>r.dispose()),s=r.onDispose(()=>{s.dispose(),r&&(this._decorations.delete(r)&&this._onDecorationRemoved.fire(r),e.dispose())});this._decorations.insert(r),this._onDecorationRegistered.fire(r)}return r}reset(){for(let e of this._decorations.values())e.dispose();this._decorations.clear()}*getDecorationsAtCell(e,r,s){let n=0,i=0;for(let a of this._decorations.getKeyIterator(r))i=(n=a.options.x??0)+(a.options.width??1),e>=n&&e<i&&(!s||(a.options.layer??"bottom")===s)&&(yield a)}forEachDecorationAtCell(e,r,s,n){this._decorations.forEachByKey(r,r=>{_6=(_4=r.options.x??0)+(r.options.width??1),e>=_4&&e<_6&&(!s||(r.options.layer??"bottom")===s)&&n(r)})}},_8=class extends vN{constructor(e){super(),this.options=e,this.onRenderEmitter=this.add(new v2),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new v2),this.onDispose=this._onDispose.event,this._cachedBg=null,this._cachedFg=null,this.marker=e.marker,this.options.overviewRulerOptions&&!this.options.overviewRulerOptions.position&&(this.options.overviewRulerOptions.position="full")}get backgroundColorRGB(){return null===this._cachedBg&&(this.options.backgroundColor?this._cachedBg=_w.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return null===this._cachedFg&&(this.options.foregroundColor?this._cachedFg=_w.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},_9=class{constructor(e,r=1e3){this._renderCallback=e,this._debounceThresholdMS=r,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(e,r,s){this._rowCount=s,e=void 0!==e?e:0,r=void 0!==r?r:this._rowCount-1,this._rowStart=void 0!==this._rowStart?Math.min(this._rowStart,e):e,this._rowEnd=void 0!==this._rowEnd?Math.max(this._rowEnd,r):r;let n=performance.now();if(n-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=n,this._innerRefresh();else if(!this._additionalRefreshRequested){let e=n-this._lastRefreshMs,r=this._debounceThresholdMS-e;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout(()=>{this._lastRefreshMs=performance.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0},r)}}_innerRefresh(){if(void 0===this._rowStart||void 0===this._rowEnd||void 0===this._rowCount)return;let e=Math.max(this._rowStart,0),r=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,r)}},Se=class extends vE{constructor(e,r,s,n){super(),this._terminal=e,this._coreBrowserService=s,this._renderService=n,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="";let i=this._coreBrowserService.mainDocument;this._accessibilityContainer=i.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=i.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let e=0;e<this._terminal.rows;e++)this._rowElements[e]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[e]);if(this._topBoundaryFocusListener=e=>this._handleBoundaryFocus(e,0),this._bottomBoundaryFocusListener=e=>this._handleBoundaryFocus(e,1),this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=i.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this._register(new _9(this._renderRows.bind(this))),!this._terminal.element)throw Error("Cannot enable accessibility before Terminal.open");this._terminal.element.insertAdjacentElement("afterbegin",this._accessibilityContainer),this._register(this._terminal.onResize(e=>this._handleResize(e.rows))),this._register(this._terminal.onRender(e=>this._refreshRows(e.start,e.end))),this._register(this._terminal.onScroll(()=>this._refreshRows())),this._register(this._terminal.onA11yChar(e=>this._handleChar(e))),this._register(this._terminal.onLineFeed(()=>this._handleChar(`
26
+ `))),this._register(this._terminal.onA11yTab(e=>this._handleTab(e))),this._register(this._terminal.onKey(e=>this._handleKey(e.key))),this._register(this._terminal.onBlur(()=>this._clearLiveRegion())),this._register(this._renderService.onDimensionsChange(()=>this._refreshRowsDimensions())),this._register(y6(i,"selectionchange",()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(vj(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(e){for(let r=0;r<e;r++)this._handleChar(" ")}_handleChar(e){this._liveRegionLineCount<21&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,e===`
27
+ `&&(this._liveRegionLineCount++,21===this._liveRegionLineCount&&(this._liveRegion.textContent+=xU)))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0}_handleKey(e){this._clearLiveRegion(),/\p{Control}/u.test(e)||this._charsToConsume.push(e)}_refreshRows(e,r){this._liveRegionDebouncer.refresh(e,r,this._terminal.rows)}_renderRows(e,r){let s=this._terminal.buffer,n=s.lines.length.toString();for(let i=e;i<=r;i++){let e=s.lines.get(s.ydisp+i),r=[],a=e?.translateToString(!0,void 0,void 0,r)||"",o=(s.ydisp+i+1).toString(),l=this._rowElements[i];l&&(0===a.length?(l.textContent=" ",this._rowColumns.set(l,[0,1])):(l.textContent=a,this._rowColumns.set(l,r)),l.setAttribute("aria-posinset",o),l.setAttribute("aria-setsize",n),this._alignRowWidth(l))}this._announceCharacters()}_announceCharacters(){0!==this._charsToAnnounce.length&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(e,r){let s,n,i=e.target,a=this._rowElements[0===r?1:this._rowElements.length-2];if(i.getAttribute("aria-posinset")!==(0===r?"1":`${this._terminal.buffer.lines.length}`)&&e.relatedTarget===a){if(0===r?(s=i,n=this._rowElements.pop(),this._rowContainer.removeChild(n)):(s=this._rowElements.shift(),n=i,this._rowContainer.removeChild(s)),s.removeEventListener("focus",this._topBoundaryFocusListener),n.removeEventListener("focus",this._bottomBoundaryFocusListener),0===r){let e=this._createAccessibilityTreeNode();this._rowElements.unshift(e),this._rowContainer.insertAdjacentElement("afterbegin",e)}else{let e=this._createAccessibilityTreeNode();this._rowElements.push(e),this._rowContainer.appendChild(e)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(0===r?-1:1),this._rowElements[0===r?1:this._rowElements.length-2].focus(),e.preventDefault(),e.stopImmediatePropagation()}}_handleSelectionChange(){if(0===this._rowElements.length)return;let e=this._coreBrowserService.mainDocument.getSelection();if(!e)return;if(e.isCollapsed){this._rowContainer.contains(e.anchorNode)&&this._terminal.clearSelection();return}if(!e.anchorNode||!e.focusNode)return void console.error("anchorNode and/or focusNode are null");let r={node:e.anchorNode,offset:e.anchorOffset},s={node:e.focusNode,offset:e.focusOffset};if((r.node.compareDocumentPosition(s.node)&Node.DOCUMENT_POSITION_PRECEDING||r.node===s.node&&r.offset>s.offset)&&([r,s]=[s,r]),r.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(r={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(r.node))return;let n=this._rowElements.slice(-1)[0];if(s.node.compareDocumentPosition(n)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(s={node:n,offset:n.textContent?.length??0}),!this._rowContainer.contains(s.node))return;let i=({node:e,offset:r})=>{let s=e instanceof Text?e.parentNode:e,n=parseInt(s?.getAttribute("aria-posinset"),10)-1;if(isNaN(n))return console.warn("row is invalid. Race condition?"),null;let i=this._rowColumns.get(s);if(!i)return console.warn("columns is null. Race condition?"),null;let a=r<i.length?i[r]:i.slice(-1)[0]+1;return a>=this._terminal.cols&&(++n,a=0),{row:n,column:a}},a=i(r),o=i(s);if(!(!a||!o)){if(a.row>o.row||a.row===o.row&&a.column>=o.column)throw Error("invalid range");this._terminal.select(a.column,a.row,(o.row-a.row)*this._terminal.cols-a.column+o.column)}}_handleResize(e){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let e=this._rowContainer.children.length;e<this._terminal.rows;e++)this._rowElements[e]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[e]);for(;this._rowElements.length>e;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){let e=this._coreBrowserService.mainDocument.createElement("div");return e.setAttribute("role","listitem"),e.tabIndex=-1,this._refreshRowDimensions(e),e}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){Object.assign(this._accessibilityContainer.style,{width:`${this._renderService.dimensions.css.canvas.width}px`,fontSize:`${this._terminal.options.fontSize}px`}),this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let e=0;e<this._terminal.rows;e++)this._refreshRowDimensions(this._rowElements[e]),this._alignRowWidth(this._rowElements[e])}}_refreshRowDimensions(e){e.style.height=`${this._renderService.dimensions.css.cell.height}px`}_alignRowWidth(e){e.style.transform="";let r=e.getBoundingClientRect().width,s=this._rowColumns.get(e)?.slice(-1)?.[0];if(!s)return;let n=s*this._renderService.dimensions.css.cell.width;e.style.transform=`scaleX(${n/r})`}};Se=x$([xW(1,x9),xW(2,vo),xW(3,vc)],Se);var St=class extends vE{constructor(e,r,s,n,i){super(),this._element=e,this._mouseService=r,this._renderService=s,this._bufferService=n,this._linkProviderService=i,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this._register(new v2),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new v2),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(vj(()=>{vk(this._linkCacheDisposables),this._linkCacheDisposables.length=0,this._lastMouseEvent=void 0,this._activeProviderReplies?.clear()})),this._register(this._bufferService.onResize(()=>{this._clearCurrentLink(),this._wasResized=!0})),this._register(y6(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(y6(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(y6(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(y6(this._element,"mouseup",this._handleMouseUp.bind(this)))}get currentLink(){return this._currentLink}_handleMouseMove(e){this._lastMouseEvent=e;let r=this._positionFromMouseEvent(e,this._element,this._mouseService);if(!r)return;this._isMouseOut=!1;let s=e.composedPath();for(let e=0;e<s.length;e++){let r=s[e];if(r.classList.contains("xterm"))break;if(r.classList.contains("xterm-hover"))return}this._lastBufferCell&&r.x===this._lastBufferCell.x&&r.y===this._lastBufferCell.y||(this._handleHover(r),this._lastBufferCell=r)}_handleHover(e){if(this._activeLine!==e.y||this._wasResized){this._clearCurrentLink(),this._askForLink(e,!1),this._wasResized=!1;return}this._currentLink&&this._linkAtPosition(this._currentLink.link,e)||(this._clearCurrentLink(),this._askForLink(e,!0))}_askForLink(e,r){this._activeProviderReplies&&r||(this._activeProviderReplies?.forEach(e=>{e?.forEach(e=>{e.link.dispose&&e.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=e.y);let s=!1;for(let[n,i]of this._linkProviderService.linkProviders.entries())r?this._activeProviderReplies?.get(n)&&(s=this._checkLinkProviderResult(n,e,s)):i.provideLinks(e.y,r=>{if(this._isMouseOut)return;let i=r?.map(e=>({link:e}));this._activeProviderReplies?.set(n,i),s=this._checkLinkProviderResult(n,e,s),this._activeProviderReplies?.size===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(e.y,this._activeProviderReplies)})}_removeIntersectingLinks(e,r){let s=new Set;for(let n=0;n<r.size;n++){let i=r.get(n);if(i)for(let r=0;r<i.length;r++){let n=i[r],a=n.link.range.start.y<e?0:n.link.range.start.x,o=n.link.range.end.y>e?this._bufferService.cols:n.link.range.end.x;for(let e=a;e<=o;e++){if(s.has(e)){i.splice(r--,1);break}s.add(e)}}}}_checkLinkProviderResult(e,r,s){if(!this._activeProviderReplies)return s;let n=this._activeProviderReplies.get(e),i=!1;for(let r=0;r<e;r++)(!this._activeProviderReplies.has(r)||this._activeProviderReplies.get(r))&&(i=!0);if(!i&&n){let e=n.find(e=>this._linkAtPosition(e.link,r));e&&(s=!0,this._handleNewLink(e))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!s)for(let e=0;e<this._activeProviderReplies.size;e++){let n=this._activeProviderReplies.get(e)?.find(e=>this._linkAtPosition(e.link,r));if(n){s=!0,this._handleNewLink(n);break}}return s}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(e){var r,s;if(!this._currentLink)return;let n=this._positionFromMouseEvent(e,this._element,this._mouseService);n&&this._mouseDownLink&&(r=this._mouseDownLink.link,s=this._currentLink.link,r.text===s.text&&r.range.start.x===s.range.start.x&&r.range.start.y===s.range.start.y&&r.range.end.x===s.range.end.x&&r.range.end.y===s.range.end.y)&&this._linkAtPosition(this._currentLink.link,n)&&this._currentLink.link.activate(e,this._currentLink.link.text)}_clearCurrentLink(e,r){this._currentLink&&this._lastMouseEvent&&(!e||!r||this._currentLink.link.range.start.y>=e&&this._currentLink.link.range.end.y<=r)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,vk(this._linkCacheDisposables),this._linkCacheDisposables.length=0)}_handleNewLink(e){if(!this._lastMouseEvent)return;let r=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);r&&this._linkAtPosition(e.link,r)&&(this._currentLink=e,this._currentLink.state={decorations:{underline:void 0===e.link.decorations||e.link.decorations.underline,pointerCursor:void 0===e.link.decorations||e.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,e.link,this._lastMouseEvent),e.link.decorations={},Object.defineProperties(e.link.decorations,{pointerCursor:{get:()=>this._currentLink?.state?.decorations.pointerCursor,set:e=>{this._currentLink?.state&&this._currentLink.state.decorations.pointerCursor!==e&&(this._currentLink.state.decorations.pointerCursor=e,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",e))}},underline:{get:()=>this._currentLink?.state?.decorations.underline,set:r=>{this._currentLink?.state&&this._currentLink?.state?.decorations.underline!==r&&(this._currentLink.state.decorations.underline=r,this._currentLink.state.isHovered&&this._fireUnderlineEvent(e.link,r))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(e=>{if(!this._currentLink)return;let r=0===e.start?0:e.start+1+this._bufferService.buffer.ydisp,s=this._bufferService.buffer.ydisp+1+e.end;if(this._currentLink.link.range.start.y>=r&&this._currentLink.link.range.end.y<=s&&(this._clearCurrentLink(r,s),this._lastMouseEvent)){let e=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);e&&this._askForLink(e,!1)}})))}_linkHover(e,r,s){this._currentLink?.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(r,!0),this._currentLink.state.decorations.pointerCursor&&e.classList.add("xterm-cursor-pointer")),r.hover&&r.hover(s,r.text)}_fireUnderlineEvent(e,r){let s=e.range,n=this._bufferService.buffer.ydisp,i=this._createLinkUnderlineEvent(s.start.x-1,s.start.y-n-1,s.end.x,s.end.y-n-1,void 0);(r?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(i)}_linkLeave(e,r,s){this._currentLink?.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(r,!1),this._currentLink.state.decorations.pointerCursor&&e.classList.remove("xterm-cursor-pointer")),r.leave&&r.leave(s,r.text)}_linkAtPosition(e,r){let s=e.range.start.y*this._bufferService.cols+e.range.start.x,n=e.range.end.y*this._bufferService.cols+e.range.end.x,i=r.y*this._bufferService.cols+r.x;return s<=i&&i<=n}_positionFromMouseEvent(e,r,s){let n=s.getCoords(e,r,this._bufferService.cols,this._bufferService.rows);if(n)return{x:n[0],y:n[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(e,r,s,n,i){return{x1:e,y1:r,x2:s,y2:n,cols:this._bufferService.cols,fg:i}}};St=x$([xW(1,vl),xW(2,vc),xW(3,x4),xW(4,vf)],St);var Sr=class extends _1{constructor(e={}){super(e),this._linkifier=this._register(new vD),this.browser=wm,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new vD),this._onCursorMove=this._register(new v2),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new v2),this.onKey=this._onKey.event,this._onRender=this._register(new v2),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new v2),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new v2),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new v2),this.onBell=this._onBell.event,this._onFocus=this._register(new v2),this._onBlur=this._register(new v2),this._onA11yCharEmitter=this._register(new v2),this._onA11yTabEmitter=this._register(new v2),this._onWillOpen=this._register(new v2),this._setup(),this._decorationService=this._instantiationService.createInstance(_7),this._instantiationService.setService(vn,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(wu),this._instantiationService.setService(vf,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(vi)),this._register(this._inputHandler.onRequestBell(()=>this._onBell.fire())),this._register(this._inputHandler.onRequestRefreshRows(e=>this.refresh(e?.start??0,e?.end??this.rows-1))),this._register(this._inputHandler.onRequestSendFocus(()=>this._reportFocus())),this._register(this._inputHandler.onRequestReset(()=>this.reset())),this._register(this._inputHandler.onRequestWindowsOptionsReport(e=>this._reportWindowsOptions(e))),this._register(this._inputHandler.onColor(e=>this._handleColorEvent(e))),this._register(vY.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(vY.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(vY.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(vY.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(e=>this._afterResize(e.cols,e.rows))),this._register(vj(()=>{this._customKeyEventHandler=void 0,this.element?.parentNode?.removeChild(this.element)}))}get linkifier(){return this._linkifier.value}get onFocus(){return this._onFocus.event}get onBlur(){return this._onBlur.event}get onA11yChar(){return this._onA11yCharEmitter.event}get onA11yTab(){return this._onA11yTabEmitter.event}get onWillOpen(){return this._onWillOpen.event}_handleColorEvent(e){if(this._themeService)for(let r of e){let e,s="";switch(r.index){case 256:e="foreground",s="10";break;case 257:e="background",s="11";break;case 258:e="cursor",s="12";break;default:e="ansi",s="4;"+r.index}switch(r.type){case 0:let n=_b.toColorRGB("ansi"===e?this._themeService.colors.ansi[r.index]:this._themeService.colors[e]);this.coreService.triggerDataEvent(`${bF.ESC}]${s};${function(e,r=16){let[s,n,i]=e;return`rgb:${_V(s,r)}/${_V(n,r)}/${_V(i,r)}`}(n)}${bO.ST}`);break;case 1:if("ansi"===e)this._themeService.modifyColors(e=>e.ansi[r.index]=bB.toColor(...r.color));else{let s=e;this._themeService.modifyColors(e=>e[s]=bB.toColor(...r.color))}break;case 2:this._themeService.restoreColor(r.index)}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(e){e?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(Se,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(bF.ESC+"[I"),this.element.classList.add("focus"),this._showCursor(),this._onFocus.fire()}blur(){return this.textarea?.blur()}_handleTextAreaBlur(){this.textarea.value="",this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(bF.ESC+"[O"),this.element.classList.remove("focus"),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;let e=this.buffer.ybase+this.buffer.y,r=this.buffer.lines.get(e);if(!r)return;let s=Math.min(this.buffer.x,this.cols-1),n=this._renderService.dimensions.css.cell.height,i=r.getWidth(s),a=this._renderService.dimensions.css.cell.width*i,o=this.buffer.y*this._renderService.dimensions.css.cell.height,l=s*this._renderService.dimensions.css.cell.width;this.textarea.style.left=l+"px",this.textarea.style.top=o+"px",this.textarea.style.width=a+"px",this.textarea.style.height=n+"px",this.textarea.style.lineHeight=n+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this._register(y6(this.element,"copy",e=>{var r;this.hasSelection()&&(r=this._selectionService,e.clipboardData&&e.clipboardData.setData("text/plain",r.selectionText),e.preventDefault())}));let e=e=>{var r,s,n;return r=this.textarea,s=this.coreService,n=this.optionsService,void(e.stopPropagation(),e.clipboardData&&xV(e.clipboardData.getData("text/plain"),r,s,n))};this._register(y6(this.textarea,"paste",e)),this._register(y6(this.element,"paste",e)),ww?this._register(y6(this.element,"mousedown",e=>{2===e.button&&xK(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(y6(this.element,"contextmenu",e=>{xK(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),wD&&this._register(y6(this.element,"auxclick",e=>{1===e.button&&xq(e,this.textarea,this.screenElement)}))}_bindKeys(){this._register(y6(this.textarea,"keyup",e=>this._keyUp(e),!0)),this._register(y6(this.textarea,"keydown",e=>this._keyDown(e),!0)),this._register(y6(this.textarea,"keypress",e=>this._keyPress(e),!0)),this._register(y6(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(y6(this.textarea,"compositionupdate",e=>this._compositionHelper.compositionupdate(e))),this._register(y6(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(y6(this.textarea,"input",e=>this._inputEvent(e),!0)),this._register(this.onRender(()=>this._compositionHelper.updateCompositionElements()))}open(e){if(!e)throw Error("Terminal requires a parent element.");if(e.isConnected||this._logService.debug("Terminal.open was called on an element that was not attached to the DOM"),this.element?.ownerDocument.defaultView&&this._coreBrowserService){this.element.ownerDocument.defaultView!==this._coreBrowserService.window&&(this._coreBrowserService.window=this.element.ownerDocument.defaultView);return}this._document=e.ownerDocument,this.options.documentOverride&&this.options.documentOverride instanceof Document&&(this._document=this.optionsService.rawOptions.documentOverride),this.element=this._document.createElement("div"),this.element.dir="ltr",this.element.classList.add("terminal"),this.element.classList.add("xterm"),e.appendChild(this.element);let r=this._document.createDocumentFragment();this._viewportElement=this._document.createElement("div"),this._viewportElement.classList.add("xterm-viewport"),r.appendChild(this._viewportElement),this.screenElement=this._document.createElement("div"),this.screenElement.classList.add("xterm-screen"),this._register(y6(this.screenElement,"mousemove",e=>this.updateCursorStyle(e))),this._helperContainer=this._document.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),r.appendChild(this.screenElement);let s=this.textarea=this._document.createElement("textarea");this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",xH),wT||this.textarea.setAttribute("aria-multiline","false"),this.textarea.setAttribute("autocorrect","off"),this.textarea.setAttribute("autocapitalize","off"),this.textarea.setAttribute("spellcheck","false"),this.textarea.tabIndex=0,this._register(this.optionsService.onSpecificOptionChange("disableStdin",()=>s.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance(wc,this.textarea,e.ownerDocument.defaultView??window,this._document??"u">typeof window?window.document:null)),this._instantiationService.setService(vo,this._coreBrowserService),this._register(y6(this.textarea,"focus",e=>this._handleTextAreaFocus(e))),this._register(y6(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(wi,this._document,this._helperContainer),this._instantiationService.setService(va,this._charSizeService),this._themeService=this._instantiationService.createInstance(w0),this._instantiationService.setService(vh,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(b1),this._instantiationService.setService(vu,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(wF,this.rows,this.screenElement)),this._instantiationService.setService(vc,this._renderService),this._register(this._renderService.onRenderedViewportChange(e=>this._onRender.fire(e))),this.onResize(e=>this._renderService.resize(e.cols,e.rows)),this._compositionView=this._document.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(bT,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(wf),this._instantiationService.setService(vl,this._mouseService);let n=this._linkifier.value=this._register(this._instantiationService.createInstance(St,this.screenElement));this.element.appendChild(r);try{this._onWillOpen.fire(this.element)}catch{}this._renderService.hasRenderer()||this._renderService.setRenderer(this._createRenderer()),this._register(this.onCursorMove(()=>{this._renderService.handleCursorMove(),this._syncTextArea()})),this._register(this.onResize(()=>this._renderService.handleResize(this.cols,this.rows))),this._register(this.onBlur(()=>this._renderService.handleBlur())),this._register(this.onFocus(()=>this._renderService.handleFocus())),this._viewport=this._register(this._instantiationService.createInstance(bS,this.element,this.screenElement)),this._register(this._viewport.onRequestScrollLines(e=>{super.scrollLines(e,!1),this.refresh(0,this.rows-1)})),this._selectionService=this._register(this._instantiationService.createInstance(wq,this.element,this.screenElement,n)),this._instantiationService.setService(vd,this._selectionService),this._register(this._selectionService.onRequestScrollLines(e=>this.scrollLines(e.amount,e.suppressScrollEvent))),this._register(this._selectionService.onSelectionChange(()=>this._onSelectionChange.fire())),this._register(this._selectionService.onRequestRedraw(e=>this._renderService.handleSelectionChanged(e.start,e.end,e.columnSelectMode))),this._register(this._selectionService.onLinuxMouseSelection(e=>{this.textarea.value=e,this.textarea.focus(),this.textarea.select()})),this._register(vY.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{this._selectionService.refresh(),this._viewport?.queueSync()})),this._register(this._instantiationService.createInstance(bk,this.screenElement)),this._register(y6(this.element,"mousedown",e=>this._selectionService.handleMouseDown(e))),this.coreMouseService.areMouseEventsActive?(this._selectionService.disable(),this.element.classList.add("enable-mouse-events")):this._selectionService.enable(),this.options.screenReaderMode&&(this._accessibilityManager.value=this._instantiationService.createInstance(Se,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",e=>this._handleScreenReaderModeOptionChange(e))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(bD,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",e=>{!this._overviewRulerRenderer&&e&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(bD,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(wn,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,r=this.element;function s(r){let s,n,i=e._mouseService.getMouseReportCoords(r,e.screenElement);if(!i)return!1;switch(r.overrideType||r.type){case"mousemove":n=32,void 0===r.buttons?(s=3,void 0!==r.button&&(s=r.button<3?r.button:3)):s=1&r.buttons?0:4&r.buttons?1:2&r.buttons?2:3;break;case"mouseup":n=0,s=r.button<3?r.button:3;break;case"mousedown":n=1,s=r.button<3?r.button:3;break;case"wheel":if(e._customWheelEventHandler&&!1===e._customWheelEventHandler(r))return!1;let a=r.deltaY;if(0===a||0===e.coreMouseService.consumeWheelEvent(r,e._renderService?.dimensions?.device?.cell?.height,e._coreBrowserService?.dpr))return!1;n=a<0?0:1,s=4;break;default:return!1}return void 0!==n&&void 0!==s&&!(s>4)&&e.coreMouseService.triggerMouseEvent({col:i.col,row:i.row,x:i.x,y:i.y,button:s,action:n,ctrl:r.ctrlKey,alt:r.altKey,shift:r.shiftKey})}let n={mouseup:null,wheel:null,mousedrag:null,mousemove:null},i=e=>(s(e),e.buttons||(this._document.removeEventListener("mouseup",n.mouseup),n.mousedrag&&this._document.removeEventListener("mousemove",n.mousedrag)),this.cancel(e)),a=e=>(s(e),this.cancel(e,!0)),o=e=>{e.buttons&&s(e)},l=e=>{e.buttons||s(e)};this._register(this.coreMouseService.onProtocolChange(e=>{e?("debug"===this.optionsService.rawOptions.logLevel&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(e)),this.element.classList.add("enable-mouse-events"),this._selectionService.disable()):(this._logService.debug("Unbinding from mouse events."),this.element.classList.remove("enable-mouse-events"),this._selectionService.enable()),8&e?n.mousemove||(r.addEventListener("mousemove",l),n.mousemove=l):(r.removeEventListener("mousemove",n.mousemove),n.mousemove=null),16&e?n.wheel||(r.addEventListener("wheel",a,{passive:!1}),n.wheel=a):(r.removeEventListener("wheel",n.wheel),n.wheel=null),2&e?n.mouseup||(n.mouseup=i):(this._document.removeEventListener("mouseup",n.mouseup),n.mouseup=null),4&e?n.mousedrag||(n.mousedrag=o):(this._document.removeEventListener("mousemove",n.mousedrag),n.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(y6(r,"mousedown",e=>{if(e.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(e)))return s(e),n.mouseup&&this._document.addEventListener("mouseup",n.mouseup),n.mousedrag&&this._document.addEventListener("mousemove",n.mousedrag),this.cancel(e)})),this._register(y6(r,"wheel",r=>{if(!n.wheel){if(this._customWheelEventHandler&&!1===this._customWheelEventHandler(r))return!1;if(!this.buffer.hasScrollback){if(0===r.deltaY)return!1;if(0===e.coreMouseService.consumeWheelEvent(r,e._renderService?.dimensions?.device?.cell?.height,e._coreBrowserService?.dpr))return this.cancel(r,!0);let s=bF.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(r.deltaY<0?"A":"B");return this.coreService.triggerDataEvent(s,!0),this.cancel(r,!0)}}},{passive:!1}))}refresh(e,r){this._renderService?.refreshRows(e,r)}updateCursorStyle(e){this._selectionService?.shouldColumnSelect(e)?this.element.classList.add("column-select"):this.element.classList.remove("column-select")}_showCursor(){this.coreService.isCursorInitialized||(this.coreService.isCursorInitialized=!0,this.refresh(this.buffer.y,this.buffer.y))}scrollLines(e,r){this._viewport?this._viewport.scrollLines(e):super.scrollLines(e,r),this.refresh(0,this.rows-1)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){e&&this._viewport?this._viewport.scrollToLine(this.buffer.ybase,!0):this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let r=e-this._bufferService.buffer.ydisp;0!==r&&this.scrollLines(r)}paste(e){xV(e,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(e){this._customKeyEventHandler=e}attachCustomWheelEventHandler(e){this._customWheelEventHandler=e}registerLinkProvider(e){return this._linkProviderService.registerLinkProvider(e)}registerCharacterJoiner(e){if(!this._characterJoinerService)throw Error("Terminal must be opened first");let r=this._characterJoinerService.register(e);return this.refresh(0,this.rows-1),r}deregisterCharacterJoiner(e){if(!this._characterJoinerService)throw Error("Terminal must be opened first");this._characterJoinerService.deregister(e)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(e){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+e)}registerDecoration(e){return this._decorationService.registerDecoration(e)}hasSelection(){return!!this._selectionService&&this._selectionService.hasSelection}select(e,r,s){this._selectionService.setSelection(e,r,s)}getSelection(){return this._selectionService?this._selectionService.selectionText:""}getSelectionPosition(){if(!(!this._selectionService||!this._selectionService.hasSelection))return{start:{x:this._selectionService.selectionStart[0],y:this._selectionService.selectionStart[1]},end:{x:this._selectionService.selectionEnd[0],y:this._selectionService.selectionEnd[1]}}}clearSelection(){this._selectionService?.clearSelection()}selectAll(){this._selectionService?.selectAll()}selectLines(e,r){this._selectionService?.selectLines(e,r)}_keyDown(e){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&!1===this._customKeyEventHandler(e))return!1;let r=this.browser.isMac&&this.options.macOptionIsMeta&&e.altKey;if(!r&&!this._compositionHelper.keydown(e))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(!0),!1;r||"Dead"!==e.key&&"AltGraph"!==e.key||(this._unprocessedDeadKey=!0);let s=function(e,r,s,n){let i={type:0,cancel:!1,key:void 0},a=!!e.shiftKey|2*!!e.altKey|4*!!e.ctrlKey|8*!!e.metaKey;switch(e.keyCode){case 0:"UIKeyInputUpArrow"===e.key?r?i.key=bF.ESC+"OA":i.key=bF.ESC+"[A":"UIKeyInputLeftArrow"===e.key?r?i.key=bF.ESC+"OD":i.key=bF.ESC+"[D":"UIKeyInputRightArrow"===e.key?r?i.key=bF.ESC+"OC":i.key=bF.ESC+"[C":"UIKeyInputDownArrow"===e.key&&(r?i.key=bF.ESC+"OB":i.key=bF.ESC+"[B");break;case 8:i.key=e.ctrlKey?"\b":bF.DEL,e.altKey&&(i.key=bF.ESC+i.key);break;case 9:if(e.shiftKey){i.key=bF.ESC+"[Z";break}i.key=bF.HT,i.cancel=!0;break;case 13:i.key=e.altKey?bF.ESC+bF.CR:bF.CR,i.cancel=!0;break;case 27:i.key=bF.ESC,e.altKey&&(i.key=bF.ESC+bF.ESC),i.cancel=!0;break;case 37:if(e.metaKey)break;a?i.key=bF.ESC+"[1;"+(a+1)+"D":r?i.key=bF.ESC+"OD":i.key=bF.ESC+"[D";break;case 39:if(e.metaKey)break;a?i.key=bF.ESC+"[1;"+(a+1)+"C":r?i.key=bF.ESC+"OC":i.key=bF.ESC+"[C";break;case 38:if(e.metaKey)break;a?i.key=bF.ESC+"[1;"+(a+1)+"A":r?i.key=bF.ESC+"OA":i.key=bF.ESC+"[A";break;case 40:if(e.metaKey)break;a?i.key=bF.ESC+"[1;"+(a+1)+"B":r?i.key=bF.ESC+"OB":i.key=bF.ESC+"[B";break;case 45:e.shiftKey||e.ctrlKey||(i.key=bF.ESC+"[2~");break;case 46:a?i.key=bF.ESC+"[3;"+(a+1)+"~":i.key=bF.ESC+"[3~";break;case 36:a?i.key=bF.ESC+"[1;"+(a+1)+"H":r?i.key=bF.ESC+"OH":i.key=bF.ESC+"[H";break;case 35:a?i.key=bF.ESC+"[1;"+(a+1)+"F":r?i.key=bF.ESC+"OF":i.key=bF.ESC+"[F";break;case 33:e.shiftKey?i.type=2:e.ctrlKey?i.key=bF.ESC+"[5;"+(a+1)+"~":i.key=bF.ESC+"[5~";break;case 34:e.shiftKey?i.type=3:e.ctrlKey?i.key=bF.ESC+"[6;"+(a+1)+"~":i.key=bF.ESC+"[6~";break;case 112:a?i.key=bF.ESC+"[1;"+(a+1)+"P":i.key=bF.ESC+"OP";break;case 113:a?i.key=bF.ESC+"[1;"+(a+1)+"Q":i.key=bF.ESC+"OQ";break;case 114:a?i.key=bF.ESC+"[1;"+(a+1)+"R":i.key=bF.ESC+"OR";break;case 115:a?i.key=bF.ESC+"[1;"+(a+1)+"S":i.key=bF.ESC+"OS";break;case 116:a?i.key=bF.ESC+"[15;"+(a+1)+"~":i.key=bF.ESC+"[15~";break;case 117:a?i.key=bF.ESC+"[17;"+(a+1)+"~":i.key=bF.ESC+"[17~";break;case 118:a?i.key=bF.ESC+"[18;"+(a+1)+"~":i.key=bF.ESC+"[18~";break;case 119:a?i.key=bF.ESC+"[19;"+(a+1)+"~":i.key=bF.ESC+"[19~";break;case 120:a?i.key=bF.ESC+"[20;"+(a+1)+"~":i.key=bF.ESC+"[20~";break;case 121:a?i.key=bF.ESC+"[21;"+(a+1)+"~":i.key=bF.ESC+"[21~";break;case 122:a?i.key=bF.ESC+"[23;"+(a+1)+"~":i.key=bF.ESC+"[23~";break;case 123:a?i.key=bF.ESC+"[24;"+(a+1)+"~":i.key=bF.ESC+"[24~";break;default:if(!e.ctrlKey||e.shiftKey||e.altKey||e.metaKey)if((!s||n)&&e.altKey&&!e.metaKey){let r=_2[e.keyCode]?.[+!!e.shiftKey];if(r)i.key=bF.ESC+r;else if(e.keyCode>=65&&e.keyCode<=90){let r=String.fromCharCode(e.ctrlKey?e.keyCode-64:e.keyCode+32);e.shiftKey&&(r=r.toUpperCase()),i.key=bF.ESC+r}else if(32===e.keyCode)i.key=bF.ESC+(e.ctrlKey?bF.NUL:" ");else if("Dead"===e.key&&e.code.startsWith("Key")){let r=e.code.slice(3,4);e.shiftKey||(r=r.toLowerCase()),i.key=bF.ESC+r,i.cancel=!0}}else!s||e.altKey||e.ctrlKey||e.shiftKey||!e.metaKey?!e.key||e.ctrlKey||e.altKey||e.metaKey||!(e.keyCode>=48)||1!==e.key.length?e.key&&e.ctrlKey&&("_"===e.key&&(i.key=bF.US),"@"===e.key&&(i.key=bF.NUL)):i.key=e.key:65===e.keyCode&&(i.type=1);else e.keyCode>=65&&e.keyCode<=90?i.key=String.fromCharCode(e.keyCode-64):32===e.keyCode?i.key=bF.NUL:e.keyCode>=51&&e.keyCode<=55?i.key=String.fromCharCode(e.keyCode-51+27):56===e.keyCode?i.key=bF.DEL:219===e.keyCode?i.key=bF.ESC:220===e.keyCode?i.key=bF.FS:221===e.keyCode&&(i.key=bF.GS)}return i}(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),3===s.type||2===s.type){let r=this.rows-1;return this.scrollLines(2===s.type?-r:r),this.cancel(e,!0)}return 1===s.type&&this.selectAll(),!!(this._isThirdLevelShift(this.browser,e)||(s.cancel&&this.cancel(e,!0),!s.key)||e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&1===e.key.length&&e.key.charCodeAt(0)>=65&&90>=e.key.charCodeAt(0))||(this._unprocessedDeadKey?(this._unprocessedDeadKey=!1,!0):((s.key===bF.ETX||s.key===bF.CR)&&(this.textarea.value=""),this._onKey.fire({key:s.key,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(s.key,!0),!this.optionsService.rawOptions.screenReaderMode||e.altKey||e.ctrlKey)?this.cancel(e,!0):void(this._keyDownHandled=!0))}_isThirdLevelShift(e,r){let s=e.isMac&&!this.options.macOptionIsMeta&&r.altKey&&!r.ctrlKey&&!r.metaKey||e.isWindows&&r.altKey&&r.ctrlKey&&!r.metaKey||e.isWindows&&r.getModifierState("AltGraph");return"keypress"===r.type?s:s&&(!r.keyCode||r.keyCode>47)}_keyUp(e){var r;this._keyDownSeen=!1,this._customKeyEventHandler&&!1===this._customKeyEventHandler(e)||(16===(r=e).keyCode||17===r.keyCode||18===r.keyCode||this.focus(),this.updateCursorStyle(e),this._keyPressHandled=!1)}_keyPress(e){let r;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&!1===this._customKeyEventHandler(e))return!1;if(this.cancel(e),e.charCode)r=e.charCode;else if(null===e.which||void 0===e.which)r=e.keyCode;else{if(0===e.which||0===e.charCode)return!1;r=e.which}return!!r&&(!e.altKey&&!e.ctrlKey&&!e.metaKey||!!this._isThirdLevelShift(this.browser,e))&&(r=String.fromCharCode(r),this._onKey.fire({key:r,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(r,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,!0)}_inputEvent(e){if(e.data&&"insertText"===e.inputType&&(!e.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;let r=e.data;return this.coreService.triggerDataEvent(r,!0),this.cancel(e),!0}return!1}resize(e,r){if(e===this.cols&&r===this.rows){this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure();return}super.resize(e,r)}_afterResize(e,r){this._charSizeService?.measure()}clear(){if(0!==this.buffer.ybase||0!==this.buffer.y){this.buffer.clearAllMarkers(),this.buffer.lines.set(0,this.buffer.lines.get(this.buffer.ybase+this.buffer.y)),this.buffer.lines.length=1,this.buffer.ydisp=0,this.buffer.ybase=0,this.buffer.y=0;for(let e=1;e<this.rows;e++)this.buffer.lines.push(this.buffer.getBlankLine(w7));this._onScroll.fire({position:this.buffer.ydisp}),this.refresh(0,this.rows-1)}}reset(){this.options.rows=this.rows,this.options.cols=this.cols;let e=this._customKeyEventHandler;this._setup(),super.reset(),this._selectionService?.reset(),this._decorationService.reset(),this._customKeyEventHandler=e,this.refresh(0,this.rows-1)}clearTextureAtlas(){this._renderService?.clearTextureAtlas()}_reportFocus(){this.element?.classList.contains("focus")?this.coreService.triggerDataEvent(bF.ESC+"[I"):this.coreService.triggerDataEvent(bF.ESC+"[O")}_reportWindowsOptions(e){if(this._renderService)switch(e){case 0:let r=this._renderService.dimensions.css.canvas.width.toFixed(0),s=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${bF.ESC}[4;${s};${r}t`);break;case 1:let n=this._renderService.dimensions.css.cell.width.toFixed(0),i=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${bF.ESC}[6;${i};${n}t`)}}cancel(e,r){if(!(!this.options.cancelEvents&&!r))return e.preventDefault(),e.stopPropagation(),!1}},Ss=class{constructor(){this._addons=[]}dispose(){for(let e=this._addons.length-1;e>=0;e--)this._addons[e].instance.dispose()}loadAddon(e,r){let s={instance:r,dispose:r.dispose,isDisposed:!1};this._addons.push(s),r.dispose=()=>this._wrappedAddonDispose(s),r.activate(e)}_wrappedAddonDispose(e){if(e.isDisposed)return;let r=-1;for(let s=0;s<this._addons.length;s++)if(this._addons[s]===e){r=s;break}if(-1===r)throw Error("Could not dispose an addon that has not been loaded");e.isDisposed=!0,e.dispose.apply(e.instance),this._addons.splice(r,1)}},Sn=class{constructor(e){this._line=e}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(e,r){if(!(e<0||e>=this._line.length))return r?(this._line.loadCell(e,r),r):this._line.loadCell(e,new x0)}translateToString(e,r,s){return this._line.translateToString(e,r,s)}},Si=class{constructor(e,r){this._buffer=e,this.type=r}init(e){return this._buffer=e,this}get cursorY(){return this._buffer.y}get cursorX(){return this._buffer.x}get viewportY(){return this._buffer.ydisp}get baseY(){return this._buffer.ybase}get length(){return this._buffer.lines.length}getLine(e){let r=this._buffer.lines.get(e);if(r)return new Sn(r)}getNullCell(){return new x0}},Sa=class extends vE{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new v2),this.onBufferChange=this._onBufferChange.event,this._normal=new Si(this._core.buffers.normal,"normal"),this._alternate=new Si(this._core.buffers.alt,"alternate"),this._core.buffers.onBufferActivate(()=>this._onBufferChange.fire(this.active))}get active(){if(this._core.buffers.active===this._core.buffers.normal)return this.normal;if(this._core.buffers.active===this._core.buffers.alt)return this.alternate;throw Error("Active buffer is neither normal nor alternate")}get normal(){return this._normal.init(this._core.buffers.normal)}get alternate(){return this._alternate.init(this._core.buffers.alt)}},So=class{constructor(e){this._core=e}registerCsiHandler(e,r){return this._core.registerCsiHandler(e,e=>r(e.toArray()))}addCsiHandler(e,r){return this.registerCsiHandler(e,r)}registerDcsHandler(e,r){return this._core.registerDcsHandler(e,(e,s)=>r(e,s.toArray()))}addDcsHandler(e,r){return this.registerDcsHandler(e,r)}registerEscHandler(e,r){return this._core.registerEscHandler(e,r)}addEscHandler(e,r){return this.registerEscHandler(e,r)}registerOscHandler(e,r){return this._core.registerOscHandler(e,r)}addOscHandler(e,r){return this.registerOscHandler(e,r)}},Sl=class{constructor(e){this._core=e}register(e){this._core.unicodeService.register(e)}get versions(){return this._core.unicodeService.versions}get activeVersion(){return this._core.unicodeService.activeVersion}set activeVersion(e){this._core.unicodeService.activeVersion=e}},Sc=["cols","rows"],Sd=0,Su=class extends vE{constructor(e){super(),this._core=this._register(new Sr(e)),this._addonManager=this._register(new Ss),this._publicOptions={...this._core.options};let r=e=>this._core.options[e],s=(e,r)=>{this._checkReadonlyOptions(e),this._core.options[e]=r};for(let e in this._core.options){let n={get:r.bind(this,e),set:s.bind(this,e)};Object.defineProperty(this._publicOptions,e,n)}}_checkReadonlyOptions(e){if(Sc.includes(e))throw Error(`Option "${e}" can only be set in the constructor`)}_checkProposedApi(){if(!this._core.optionsService.rawOptions.allowProposedApi)throw Error("You must set the allowProposedApi option to true to use proposed API")}get onBell(){return this._core.onBell}get onBinary(){return this._core.onBinary}get onCursorMove(){return this._core.onCursorMove}get onData(){return this._core.onData}get onKey(){return this._core.onKey}get onLineFeed(){return this._core.onLineFeed}get onRender(){return this._core.onRender}get onResize(){return this._core.onResize}get onScroll(){return this._core.onScroll}get onSelectionChange(){return this._core.onSelectionChange}get onTitleChange(){return this._core.onTitleChange}get onWriteParsed(){return this._core.onWriteParsed}get element(){return this._core.element}get parser(){return this._parser||(this._parser=new So(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new Sl(this._core)}get textarea(){return this._core.textarea}get rows(){return this._core.rows}get cols(){return this._core.cols}get buffer(){return this._buffer||(this._buffer=this._register(new Sa(this._core))),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){let e=this._core.coreService.decPrivateModes,r="none";switch(this._core.coreMouseService.activeProtocol){case"X10":r="x10";break;case"VT200":r="vt200";break;case"DRAG":r="drag";break;case"ANY":r="any"}return{applicationCursorKeysMode:e.applicationCursorKeys,applicationKeypadMode:e.applicationKeypad,bracketedPasteMode:e.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:r,originMode:e.origin,reverseWraparoundMode:e.reverseWraparound,sendFocusMode:e.sendFocus,synchronizedOutputMode:e.synchronizedOutput,wraparoundMode:e.wraparound}}get options(){return this._publicOptions}set options(e){for(let r in e)this._publicOptions[r]=e[r]}blur(){this._core.blur()}focus(){this._core.focus()}input(e,r=!0){this._core.input(e,r)}resize(e,r){this._verifyIntegers(e,r),this._core.resize(e,r)}open(e){this._core.open(e)}attachCustomKeyEventHandler(e){this._core.attachCustomKeyEventHandler(e)}attachCustomWheelEventHandler(e){this._core.attachCustomWheelEventHandler(e)}registerLinkProvider(e){return this._core.registerLinkProvider(e)}registerCharacterJoiner(e){return this._checkProposedApi(),this._core.registerCharacterJoiner(e)}deregisterCharacterJoiner(e){this._checkProposedApi(),this._core.deregisterCharacterJoiner(e)}registerMarker(e=0){return this._verifyIntegers(e),this._core.registerMarker(e)}registerDecoration(e){return this._checkProposedApi(),this._verifyPositiveIntegers(e.x??0,e.width??0,e.height??0),this._core.registerDecoration(e)}hasSelection(){return this._core.hasSelection()}select(e,r,s){this._verifyIntegers(e,r,s),this._core.select(e,r,s)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(e,r){this._verifyIntegers(e,r),this._core.selectLines(e,r)}dispose(){super.dispose()}scrollLines(e){this._verifyIntegers(e),this._core.scrollLines(e)}scrollPages(e){this._verifyIntegers(e),this._core.scrollPages(e)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(e){this._verifyIntegers(e),this._core.scrollToLine(e)}clear(){this._core.clear()}write(e,r){this._core.write(e,r)}writeln(e,r){this._core.write(e),this._core.write(`\r
28
+ `,r)}paste(e){this._core.paste(e)}refresh(e,r){this._verifyIntegers(e,r),this._core.refresh(e,r)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(e){this._addonManager.loadAddon(this,e)}static get strings(){return{get promptLabel(){return xH},set promptLabel(t){xH=t},get tooMuchOutput(){return xU},set tooMuchOutput(t){xU=t}}}_verifyIntegers(...e){for(Sd of e)if(Sd===1/0||isNaN(Sd)||Sd%1!=0)throw Error("This API only accepts integers")}_verifyPositiveIntegers(...e){for(Sd of e)if(Sd&&(Sd===1/0||isNaN(Sd)||Sd%1!=0||Sd<0))throw Error("This API only accepts positive integers")}},Sh=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let r=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(r._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(0===e.css.cell.width||0===e.css.cell.height)return;let r=0===this._terminal.options.scrollback?0:this._terminal.options.overviewRuler?.width||14,s=window.getComputedStyle(this._terminal.element.parentElement),n=parseInt(s.getPropertyValue("height")),i=Math.max(0,parseInt(s.getPropertyValue("width"))),a=window.getComputedStyle(this._terminal.element),o={top:parseInt(a.getPropertyValue("padding-top")),bottom:parseInt(a.getPropertyValue("padding-bottom")),right:parseInt(a.getPropertyValue("padding-right")),left:parseInt(a.getPropertyValue("padding-left"))},l=o.top+o.bottom;return{cols:Math.max(2,Math.floor((i-(o.right+o.left)-r)/e.css.cell.width)),rows:Math.max(1,Math.floor((n-l)/e.css.cell.height))}}},Sf=class{constructor(e,r,s,n={}){this._terminal=e,this._regex=r,this._handler=s,this._options=n}provideLinks(e,r){let s=Sp.computeLink(e,this._regex,this._terminal,this._handler);r(this._addCallbacks(s))}_addCallbacks(e){return e.map(e=>(e.leave=this._options.leave,e.hover=(r,s)=>{if(this._options.hover){let{range:n}=e;this._options.hover(r,s,n)}},e))}},Sp=class e{static computeLink(r,s,n,i){let a=RegExp(s.source,(s.flags||"")+"g"),[o,l]=e._getWindowedLineStrings(r-1,n),c=o.join(""),d,u=[];for(;d=a.exec(c);){let r=d[0];if(!function(e){try{let r=new URL(e),s=r.password&&r.username?`${r.protocol}//${r.username}:${r.password}@${r.host}`:r.username?`${r.protocol}//${r.username}@${r.host}`:`${r.protocol}//${r.host}`;return e.toLocaleLowerCase().startsWith(s.toLocaleLowerCase())}catch{return!1}}(r))continue;let[s,a]=e._mapStrIdx(n,l,0,d.index),[o,c]=e._mapStrIdx(n,s,a,r.length);if(-1===s||-1===a||-1===o||-1===c)continue;let h={start:{x:a+1,y:s+1},end:{x:c,y:o+1}};u.push({range:h,text:r,activate:i})}return u}static _getWindowedLineStrings(e,r){let s,n=e,i=e,a=0,o="",l=[];if(s=r.buffer.active.getLine(e)){let e=s.translateToString(!0);if(s.isWrapped&&" "!==e[0]){for(a=0;(s=r.buffer.active.getLine(--n))&&a<2048&&(a+=(o=s.translateToString(!0)).length,l.push(o),!(!s.isWrapped||-1!==o.indexOf(" "))););l.reverse()}for(l.push(e),a=0;(s=r.buffer.active.getLine(++i))&&s.isWrapped&&a<2048&&(a+=(o=s.translateToString(!0)).length,l.push(o),-1===o.indexOf(" ")););}return[l,n]}static _mapStrIdx(e,r,s,n){let i=e.buffer.active,a=i.getNullCell(),o=s;for(;n;){let e=i.getLine(r);if(!e)return[-1,-1];for(let s=o;s<e.length;++s){e.getCell(s,a);let o=a.getChars();if(a.getWidth()&&(n-=o.length||1,s===e.length-1&&""===o)){let e=i.getLine(r+1);e&&e.isWrapped&&(e.getCell(0,a),2===a.getWidth()&&(n+=1))}if(n<0)return[r,s]}r++,o=0}return[r,o]}},Sm=/(https?|HTTPS?):[/]{2}[^\s"'!*(){}|\\\^<>`]*[^\s"':,.!?{}|\\\^~\[\]`()<>]/;function Sg(e,r){let s=window.open();if(s){try{s.opener=null}catch{}s.location.href=r}else console.warn("Opening link blocked as opener could not be cleared")}var Sx=class{constructor(e=Sg,r={}){this._handler=e,this._options=r}activate(e){this._terminal=e;let r=this._options,s=r.urlRegex||Sm;this._linkProvider=this._terminal.registerLinkProvider(new Sf(this._terminal,s,this._handler,r))}dispose(){this._linkProvider?.dispose()}};let Sv=(0,rE.default)("list-filter",[["path",{d:"M2 5h20",key:"1fs1ex"}],["path",{d:"M6 12h12",key:"8npq4p"}],["path",{d:"M9 19h6",key:"456am0"}]]),Sy=(0,rE.default)("maximize-2",[["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"}]]),Sb=(0,rE.default)("minimize-2",[["path",{d:"m14 10 7-7",key:"oa77jy"}],["path",{d:"M20 10h-6V4",key:"mjg0md"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M4 14h6v6",key:"rmj7iw"}]]);function Sw(e,r){return 0===r.length?[...e]:e.filter(e=>(function(e,r){let s=e.toLowerCase();for(let e of r){let r=s.includes(e.pattern.toLowerCase());if(e.negate?r:!r)return!1}return!0})(e,r))}let S_=(0,rE.default)("eye",[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]),SS=(0,rE.default)("eye-off",[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);function Sk({filters:e,inputOpen:r,onAdd:s,onRemove:n,onCloseInput:i,counts:a}){let o=(0,V.useRef)(null),[l,c]=(0,V.useState)(!1);return(0,V.useEffect)(()=>{r&&o.current?.focus()},[r]),(0,U.jsxs)(U.Fragment,{children:[e.map(e=>(0,U.jsxs)("span",{"data-testid":"terminal-filter-chip","data-negate":e.negate||void 0,className:(0,e1.cn)("flex h-6 max-w-48 items-center gap-1 rounded border pl-1.5 pr-0.5 font-mono text-[11px]","bg-zinc-900/80 backdrop-blur-sm",e.negate?"border-red-500/50 text-red-300":"border-sky-500/50 text-sky-200"),title:e.negate?`Hide lines containing "${e.pattern}"`:`Keep lines containing "${e.pattern}"`,children:[(0,U.jsx)("span",{className:"truncate",children:e.pattern}),(0,U.jsx)("button",{type:"button","aria-label":`Remove filter ${e.pattern}`,onClick:()=>n(e.id),className:"flex h-4 w-4 shrink-0 items-center justify-center rounded text-zinc-400 hover:bg-zinc-700 hover:text-zinc-100",children:(0,U.jsx)(rD,{className:"h-3 w-3"})})]},e.id)),r&&(0,U.jsxs)("span",{"data-testid":"terminal-filter-input-group",className:(0,e1.cn)("flex h-6 items-center overflow-hidden rounded border bg-zinc-900/90 backdrop-blur-sm",l?"border-red-500/60":"border-zinc-600 focus-within:border-sky-500/70"),children:[(0,U.jsx)("button",{type:"button","aria-label":l?"Hide mode: chip hides matching lines":"Keep mode: chip keeps matching lines","aria-pressed":l,title:"Toggle between keeping and hiding lines that match",onMouseDown:e=>e.preventDefault(),onClick:()=>c(e=>!e),className:(0,e1.cn)("flex h-full shrink-0 items-center border-r px-1.5",l?"border-red-500/40 bg-red-500/15 text-red-300 hover:bg-red-500/25":"border-zinc-700 text-zinc-400 hover:bg-zinc-800 hover:text-zinc-200"),children:l?(0,U.jsx)(SS,{className:"h-3 w-3"}):(0,U.jsx)(S_,{className:"h-3 w-3"})}),(0,U.jsx)("input",{ref:o,type:"text","aria-label":"Add terminal filter",placeholder:l?"hide lines containing…":"keep lines containing…",spellCheck:!1,autoComplete:"off",onKeyDown:r=>{let a=r.currentTarget;if(!r.nativeEvent.isComposing&&229!==r.keyCode){if("Enter"===r.key){r.preventDefault();let e=function(e){let r=e.trim();if(!r)return null;if(r.startsWith("\\-")||r.startsWith("\\!"))return{pattern:r.slice(1),negate:!1};if(r.startsWith("-")||r.startsWith("!")){let e=r.slice(1).trim();return e?{pattern:e,negate:!0}:null}return{pattern:r,negate:!1}}(a.value);e&&(s(l?{...e,negate:!0}:e),a.value="");return}if("Escape"===r.key){r.preventDefault(),r.stopPropagation(),i();return}"Backspace"===r.key&&""===a.value&&e.length>0&&(r.preventDefault(),n(e[e.length-1].id))}},className:"h-full w-36 bg-transparent px-1.5 font-mono text-[11px] text-zinc-100 outline-none placeholder:text-zinc-500"})]}),a&&(0,U.jsxs)("span",{"data-testid":"terminal-filter-count",className:"select-none font-mono text-[11px] tabular-nums text-zinc-400",title:"matched / total lines",children:[a.matched.toLocaleString()," / ",a.total.toLocaleString()]})]})}function Sj(e,r){let s=e.top-r.top-22-4;s<0&&(s=e.bottom-r.top+4);let n=Math.max(0,r.width-64-2);return{top:s,left:Math.min(Math.max(e.left-r.left,2),n)}}function SC({anchor:e,onCopy:r,className:s}){return(0,U.jsxs)("button",{type:"button","data-testid":"selection-copy-button","aria-label":"Copy selection",onMouseDown:e=>e.preventDefault(),onClick:r,style:{top:e.top,left:e.left,height:22},className:(0,e1.cn)("absolute z-20 flex items-center gap-1 rounded border border-zinc-600 bg-zinc-800 px-2","text-[11px] text-zinc-100 shadow-md hover:bg-zinc-700 hover:border-zinc-500",s),children:[(0,U.jsx)(mw.Copy,{className:"h-3 w-3"}),"Copy"]})}function SN({lines:e,fontSize:r,fontFamily:s,isPty:n,className:i}){let a=(0,V.useRef)(null),o=(0,V.useRef)(null),l=(0,V.useRef)(!0),[c,d]=(0,V.useState)(null),u=(0,V.useRef)(!1),h=(0,V.useCallback)(()=>{let e=a.current,r=document.getSelection();if(u.current||!e||!r||r.isCollapsed||0===r.rangeCount||!e.contains(r.anchorNode))return void d(null);let s=e.getBoundingClientRect(),n=Array.from(r.getRangeAt(0).getClientRects()).find(e=>(e.width>0||e.height>0)&&e.bottom>s.top&&e.top<s.bottom);n?d(Sj(n,s)):d(null)},[]),f=(0,V.useCallback)(()=>{u.current=!0,d(null),window.addEventListener("mouseup",()=>{u.current=!1,h()},{once:!0})},[h]);(0,V.useEffect)(()=>{let e=()=>{let e=document.getSelection();(!e||e.isCollapsed)&&d(null)};return document.addEventListener("selectionchange",e),()=>document.removeEventListener("selectionchange",e)},[]);let p=async()=>{let e=document.getSelection()?.toString()??"";if(d(null),e)try{await navigator.clipboard.writeText(e),xc.toast.success("Copied selection")}catch{xc.toast.error("Failed to copy to clipboard")}};return(0,V.useLayoutEffect)(()=>{let e=o.current;e&&l.current&&(e.scrollTop=e.scrollHeight)},[e]),(0,U.jsxs)("div",{ref:a,"data-testid":"terminal-filter-view",className:(0,e1.cn)("absolute inset-0 flex flex-col bg-zinc-950",i),children:[c&&(0,U.jsx)(SC,{anchor:c,onCopy:p}),(0,U.jsx)("div",{ref:o,"data-testid":"terminal-filter-scroller",onScroll:()=>{let e=o.current;e&&(l.current=e.scrollHeight-e.scrollTop-e.clientHeight<4,h())},onMouseDown:f,className:"min-h-0 flex-1 overflow-y-auto overflow-x-hidden px-2 pb-2 pt-9",children:0===e.length?(0,U.jsx)("div",{className:"select-none py-4 text-center text-xs text-zinc-500",children:"No lines match"}):(0,U.jsx)("pre",{className:"m-0 whitespace-pre-wrap break-all text-zinc-100",style:{fontSize:r,fontFamily:s,lineHeight:1.2},children:e.map((e,r)=>(0,U.jsx)("div",{children:""===e?" ":e},r))})}),n&&(0,U.jsx)("div",{className:"select-none border-t border-zinc-800 px-2 py-1 text-[11px] text-zinc-500",children:"Filtered view — clear filters to type into the shell"})]})}let SE=/\x1B(?:\][^\x07]*(?:\x07|\x1B\\)|[@-Z\\-_]|\[[0-?]*[ -/]*[@-~])/g;function SD({logs:e,isPty:r,className:s,onInput:n,onResize:i,muteInput:a,focusHandle:o,processId:l,executorId:c,target:d,status:u,exitCode:h}){let f=(0,V.useRef)(null),p=(0,V.useRef)(null),m=(0,V.useRef)(null),g=(0,V.useRef)(0),x=(0,V.useRef)(0),v=(0,V.useRef)(!1),y=(0,V.useRef)(""),b=(0,V.useRef)(""),[w,_]=(0,V.useState)(!1),[S,k]=(0,V.useState)(!1),[j,C]=(0,V.useState)([]),[N,E]=(0,V.useState)(!1),[D,T]=(0,V.useState)(null),[R,A]=(0,V.useState)(0),M=j.length>0,I=(0,V.useRef)(M);(0,V.useEffect)(()=>{I.current=M},[M]);let[P,F]=(0,V.useState)(null),L=(0,V.useRef)(!1),O=(0,V.useRef)(null),B=(0,V.useRef)(l);(0,V.useEffect)(()=>{B.current=l},[l]);let z=(0,V.useRef)(a);z.current!==a&&console.log(`[ExecutorOutput] muteInput changed: ${z.current} → ${a}`),z.current=a;let{settings:$}=(0,gB.useTerminalSettings)(),W=(0,V.useRef)($),[H,q]=(0,V.useState)(!1),K=(0,V.useRef)(0),X=(0,V.useRef)(e);X.current=e;let Y=async()=>{if(!H){K.current=X.current.length,q(!0);return}let e=X.current,r=Math.min(K.current,e.length),s=e.slice(r).map(e=>"stdout"===e.type||"stderr"===e.type||"pty"===e.type?e.data:"").join("");q(!1);let n=s.replace(SE,""),i=j.length>0?Sw(n.split(/\r?\n/),j).join("\n"):n;if(!i)return void xc.toast.info(j.length>0?"Capture stopped — no output matched the filters":"Capture stopped — no output to copy");try{await navigator.clipboard.writeText(i),xc.toast.success(j.length>0?"Copied filtered captured output to clipboard":"Copied captured output to clipboard")}catch{xc.toast.error("Failed to copy to clipboard")}},G=(0,V.useCallback)((e,r)=>{let s=f.current;console.log(`[ExecutorOutput] resize → PTY ${e}x${r} process=${B.current??"?"} container=${s?.clientWidth??0}x${s?.clientHeight??0}px viewport=${window.innerWidth}x${window.innerHeight}px`)},[]),Z=(0,V.useCallback)((e,r,s)=>{let n=p.current;if(!n)return void s?.();if(e){x.current++;try{n.write(e,()=>{x.current=Math.max(0,x.current-1),r||s?.()})}catch(e){x.current=Math.max(0,x.current-1),console.error("[ExecutorOutput] terminal write failed",e),r||s?.()}}else r||s?.();if(r)try{n.write(r,()=>s?.())}catch(e){console.error("[ExecutorOutput] terminal write failed",e),s?.()}},[]),et=(0,V.useCallback)(()=>{v.current=!0;let e=y.current,r=b.current;y.current="",b.current="",e||r?Z(e,r,()=>{p.current?.scrollToBottom(),_(!0)}):_(!0)},[Z]),er=(0,V.useRef)(null),es=(0,V.useCallback)(()=>{let e=f.current,r=m.current;if(!e||!r||0===e.clientWidth||0===e.clientHeight)return!1;let s=r.proposeDimensions();if(!s||!Number.isFinite(s.cols)||!Number.isFinite(s.rows)||s.cols<=0||s.rows<=0)return!1;try{r.fit()}catch{return!1}return et(),!0},[et]),en=(0,V.useCallback)(()=>{if(null!==er.current)return;let e=()=>{if(er.current=null,v.current||!p.current)return;let r=f.current;r&&0!==r.clientWidth&&0!==r.clientHeight&&(es()||(er.current=requestAnimationFrame(e)))};er.current=requestAnimationFrame(e)},[es]),ei=(0,V.useCallback)(()=>{let e=p.current,r=O.current;if(!e||!r||L.current)return void F(null);let s=e.getSelectionPosition();if(!s)return void F(null);let n=e.buffer.active.viewportY,i=s.start.y-n;if(s.end.y-n<0||i>=e.rows)return void F(null);let a=Math.max(i,0),o=a===i?s.start.x:0,l=e.element?.querySelectorAll(".xterm-rows > div")[a],c=l?.getBoundingClientRect();if(!c||0===c.width)return void F(null);let d=c.width/e.cols;F(Sj({top:c.top,bottom:c.bottom,left:c.left+o*d},r.getBoundingClientRect()))},[]),ea=(0,V.useCallback)(()=>{L.current=!0,F(null),window.addEventListener("pointerup",()=>{L.current=!1,ei()},{once:!0})},[ei]),eo=async()=>{let e=p.current?.getSelection()??"";if(F(null),e)try{await navigator.clipboard.writeText(e),xc.toast.success("Copied selection")}catch{xc.toast.error("Failed to copy to clipboard")}};(0,V.useEffect)(()=>{if(!f.current||p.current)return;let e=W.current,s=new Su({cursorBlink:r,cursorStyle:r?"block":"underline",disableStdin:!r,convertEol:!0,fontSize:e.fontSize,fontFamily:e.fontFamily,scrollback:e.scrollback,theme:{background:"#09090b",foreground:"#fafafa",cursor:r?"#fafafa":"#09090b",cursorAccent:"#09090b",selectionBackground:"#3f3f46",black:"#09090b",red:"#f87171",green:"#4ade80",yellow:"#facc15",blue:"#60a5fa",magenta:"#c084fc",cyan:"#22d3ee",white:"#fafafa",brightBlack:"#71717a",brightRed:"#fca5a5",brightGreen:"#86efac",brightYellow:"#fde047",brightBlue:"#93c5fd",brightMagenta:"#d8b4fe",brightCyan:"#67e8f9",brightWhite:"#ffffff"},allowProposedApi:!0}),a=new Sh,o=new Sx;s.loadAddon(a),s.loadAddon(o),s.attachCustomKeyEventHandler(e=>!(null!==Q(e)||ee(e,J))),s.open(f.current);let l=setTimeout(()=>{try{let e=f.current;if(!e||0===e.clientWidth||0===e.clientHeight)return;es()?r&&(G(s.cols,s.rows),i?.(s.cols,s.rows)):en()}catch{}},0);return p.current=s,m.current=a,A(e=>e+1),r&&n&&s.onData(e=>{z.current||0!==x.current||I.current||n(e)}),s.onSelectionChange(ei),s.onScroll(ei),r&&i&&s.onResize(({cols:e,rows:r})=>{G(e,r),i(e,r)}),()=>{clearTimeout(l),null!==er.current&&(cancelAnimationFrame(er.current),er.current=null),s.dispose(),p.current=null,m.current=null,g.current=0,x.current=0,v.current=!1,y.current="",b.current=""}},[r,n,i,es,en,G,ei]),(0,V.useEffect)(()=>{if(!p.current)return;e.length<g.current&&(p.current.reset(),A(e=>e+1),g.current=0,y.current="",b.current="");let s="",n="";for(let r=g.current;r<e.length;r++){let i=e[r];("pty"===i.type||"stdout"===i.type||"stderr"===i.type)&&(i.historical?s+=i.data:n+=i.data)}if(g.current=e.length,r&&!v.current){y.current=(y.current+s).slice(-1e6),b.current=(b.current+n).slice(-1e6);return}(s||n)&&Z(s,n)},[e,r,Z]),(0,V.useEffect)(()=>{let e=p.current;if(e){e.options.fontSize=$.fontSize,e.options.fontFamily=$.fontFamily,e.options.scrollback=$.scrollback;try{m.current?.fit()}catch{}}},[$.fontSize,$.fontFamily,$.scrollback]),(0,V.useEffect)(()=>{S&&r&&!M&&!N&&p.current?.focus()},[S,r,M,N]),(0,V.useEffect)(()=>{if(!M)return void T(null);let e=p.current;if(!e)return;let r=null,s=()=>{r=null;let s=function(e){let r=[];for(let s=0;s<e.length;s++){let n=e.getLine(s);if(!n)continue;let i=n.translateToString(!0);n.isWrapped&&r.length>0?r[r.length-1]+=i:r.push(i)}let s=r.length;for(;s>0&&""===r[s-1];)s--;return r.slice(0,s)}(e.buffer.active);T({lines:Sw(s,j),total:s.length})};s();let n=e.onWriteParsed(()=>{null===r&&(r=requestAnimationFrame(s))});return()=>{n.dispose(),null!==r&&cancelAnimationFrame(r)}},[j,M,R]);let el=(0,V.useCallback)(e=>{C(r=>[...r,{...e,id:`${Date.now()}-${r.length}`}])},[]),ec=(0,V.useCallback)(e=>{C(r=>r.filter(r=>r.id!==e))},[]),ed=(0,V.useCallback)(()=>{E(!1),r&&0===j.length&&p.current?.focus()},[r,j.length]),eu=async()=>{let e=D?.lines.join("\n")??"";if(!e)return void xc.toast.info("No filtered lines to copy");try{await navigator.clipboard.writeText(e),xc.toast.success(`Copied ${D.lines.length} filtered lines`)}catch{xc.toast.error("Failed to copy to clipboard")}};(0,V.useImperativeHandle)(o,()=>({focus:()=>{r&&!I.current&&p.current?.focus()}}),[r]),(0,V.useEffect)(()=>{if(!f.current||!m.current)return;let e=new ResizeObserver(()=>{try{let e=f.current;if(!e||0===e.clientWidth||0===e.clientHeight)return;v.current?m.current?.fit():es()||en()}catch{}});return e.observe(f.current),()=>{e.disconnect()}},[es,en]);let eh=[{label:"Process",value:l??null},{label:"Executor",value:c??null},{label:"Target",value:d??null},{label:"Status",value:"closed"===u&&null!==h?`closed \xb7 exit ${h}`:u??null}],ef=(0,e1.cn)("flex h-6 w-6 items-center justify-center rounded","bg-zinc-900/70 backdrop-blur-sm border border-zinc-700/60","text-zinc-400 hover:text-zinc-100 hover:border-zinc-500 transition-colors");return(0,U.jsxs)("div",{className:(0,e1.cn)("relative h-[300px] rounded-md border bg-zinc-950 overflow-hidden",s),children:[S&&(0,U.jsx)("div",{className:"flex h-full select-none items-center justify-center text-xs text-zinc-500",children:"Terminal is maximized"}),(0,U.jsx)("div",{"data-testid":"executor-output-layer","data-maximized":S||void 0,role:S?"dialog":void 0,"aria-modal":S||void 0,"aria-label":S?"Maximized terminal":void 0,className:S?"fixed inset-0 z-50 flex items-center justify-center bg-black/70 p-4 sm:p-10 lg:p-16":"absolute inset-0",onMouseDown:S?e=>{e.target===e.currentTarget&&k(!1)}:void 0,children:(0,U.jsxs)("div",{ref:O,className:(0,e1.cn)("relative h-full w-full",S&&"max-h-[85vh] max-w-6xl overflow-hidden rounded-md border border-zinc-700 bg-zinc-950 shadow-2xl"),children:[(0,U.jsx)("div",{ref:f,onPointerDown:ea,className:(0,e1.cn)("h-full w-full",!w&&"opacity-0")}),P&&!D&&(0,U.jsx)(SC,{anchor:P,onCopy:eo}),D&&(0,U.jsx)(SN,{lines:D.lines,fontSize:$.fontSize,fontFamily:$.fontFamily,isPty:r}),(0,U.jsxs)("div",{className:"absolute top-2 right-3 z-10 flex max-w-[calc(100%-1.5rem)] flex-wrap items-center justify-end gap-1.5",children:[(0,U.jsx)(Sk,{filters:j,inputOpen:N,onAdd:el,onRemove:ec,onCloseInput:ed,counts:D?{matched:D.lines.length,total:D.total}:null}),D&&(0,U.jsx)("button",{type:"button",onClick:eu,title:"Copy filtered lines","aria-label":"Copy filtered lines",className:ef,children:(0,U.jsx)(mw.Copy,{className:"h-3 w-3"})}),(0,U.jsx)("button",{type:"button",onClick:()=>N?ed():E(!0),title:N?"Close filter input":"Filter output lines","aria-label":N?"Close filter input":"Filter output lines","aria-pressed":M,className:(0,e1.cn)(ef,M&&"text-sky-300 border-sky-500/70 hover:text-sky-200"),children:(0,U.jsx)(Sv,{className:"h-3 w-3"})}),(0,U.jsxs)(i3,{children:[(0,U.jsx)(i4,{asChild:!0,children:(0,U.jsx)("button",{type:"button",title:"Process info","aria-label":"Show process info",className:ef,children:(0,U.jsx)(h$,{className:"h-3 w-3"})})}),(0,U.jsxs)(i6,{align:"end",className:"w-72",children:[(0,U.jsx)(at,{className:"text-xs text-muted-foreground",children:"Process info"}),eh.map(e=>(0,U.jsxs)(i7,{disabled:!e.value,onSelect:r=>{var s,n;r.preventDefault(),s=e.label,(n=e.value)&&(navigator.clipboard.writeText(n),xc.toast.success(`${s} copied`))},className:"flex items-center justify-between gap-3 font-mono text-xs",children:[(0,U.jsx)("span",{className:"shrink-0 text-muted-foreground",children:e.label}),(0,U.jsxs)("span",{className:"flex min-w-0 items-center gap-1.5",children:[(0,U.jsx)("span",{className:"truncate",children:e.value??"—"}),e.value&&(0,U.jsx)(mw.Copy,{className:"h-3 w-3 shrink-0 opacity-60"})]})]},e.label))]})]}),(0,U.jsx)("button",{type:"button",onClick:Y,title:H?M?"Stop capture & copy filtered output":"Stop capture & copy to clipboard":"Start capturing output","aria-label":H?"Stop capture and copy":"Start capturing output",className:(0,e1.cn)(ef,H&&"text-red-400 border-red-500/70 hover:text-red-300"),children:H?(0,U.jsx)(ce,{className:"h-3 w-3 fill-current"}):(0,U.jsx)(i5,{className:"h-3 w-3"})}),(0,U.jsx)("button",{type:"button",onClick:()=>k(e=>!e),title:S?"Restore size":"Maximize terminal","aria-label":S?"Restore terminal size":"Maximize terminal","aria-pressed":S,className:ef,children:S?(0,U.jsx)(Sb,{className:"h-3 w-3"}):(0,U.jsx)(Sy,{className:"h-3 w-3"})})]})]})})]})}let ST=[{name:"Dev Server",command:"pnpm dev",executor_type:"command",pty:!0,lifecycle:"service",description:"Start the development server with hot reload"},{name:"Build",command:"pnpm build",executor_type:"command",pty:!0,description:"Build the project for production"},{name:"Lint",command:"pnpm lint",executor_type:"command",pty:!0,description:"Run the linter to check code quality"},{name:"Type Check",command:"npx tsc --noEmit",executor_type:"command",pty:!0,description:"Run TypeScript type checking without emitting files"},{name:"Test",command:"pnpm test",executor_type:"command",pty:!0,description:"Run the test suite"},{name:"Rebase on and merge into main",command:"Our goal is to sync the current local branch with the local branch/worktree `main`. The two branches may have diverged.\n\nPlease do the following in order. Only proceed to the next step if the previous step succeeds:\n\n1. Rebase the current local branch onto the local branch `main`, and resolve any conflicts if needed.\n2. If, after the rebase, `main` does not yet contain the current branch's commits, switch to the `main` branch/worktree and merge the current branch into `main` using `git merge`. Do not use `git branch -f`.\n3. If the current branch is already fully contained in `main`, and `main` has newer commits, update the current branch so it includes the latest commits from `main`.\n4. Push both the current local branch and the local branch `main` to the remote.",executor_type:"prompt",pty:!1,description:"Rebase current branch onto main, merge into main, and push both branches"},{name:"Reset to main",command:"git reset --hard main",executor_type:"command",pty:!0,description:"Hard reset the current branch to match main"},{name:"Push to remote",command:"git push --force-with-lease",executor_type:"command",pty:!0,description:"Force push to remote with lease safety check"},{name:"Git commit",command:"Inspect the modified and untracked and deleted files in the current repository, generate an appropriate commit message, and commit all relevant files.\n\nCommit message rules:\n- Use Conventional Commits format (feat:, fix:, chore:, refactor:, docs:, test:, ci:, build:, perf:, style:, etc.)\n- Choose the type that best matches the main purpose of the changes\n- Make the message specific to the actual changes\n- Keep it within 50 characters if possible\n- Use lowercase\n- Do not end with a period\n- Do not wrap the message in quotes, backticks, or markdown\n\nCommit requirements:\n- Include all relevant modified and untracked files\n- Do not include unrelated files\n- If there are no meaningful changes to commit, do not create a commit\n- Do not run tests, builds, type checks, or linters; only inspect the changes and commit\n\nWhen finished, output only the final commit message.",executor_type:"prompt",pty:!1,description:"Inspect changes, generate a conventional commit message, and commit"},{name:"Tag and push",command:"Find the latest SemVer tag in the repository, increase the patch number by 1, create the new tag from the current commit, and push it to origin.",executor_type:"prompt",pty:!1,description:"Bump the patch version tag and push it to origin"}];function SR({open:e,onOpenChange:r,executor:s,onSubmit:n}){let[i,a]=(0,V.useState)(s?.name??""),[o,l]=(0,V.useState)(s?.executor_type??"command"),[c,d]=(0,V.useState)(s?.prompt_provider??"claude"),[u,h]=(0,V.useState)(s?.command??""),[f,p]=(0,V.useState)(s?.cwd??""),[m,g]=(0,V.useState)(s?.pty??!0),[x,v]=(0,V.useState)(s?.lifecycle==="service"),[y,b]=(0,V.useState)(!1),[w,_]=(0,V.useState)(!1),[S,k]=(0,V.useState)(null),[j,C]=(0,V.useState)(null),[N,E]=(0,V.useState)(""),D=!!s;(0,V.useEffect)(()=>{e&&(_(!1),k(null),C(null),E(""),s&&(a(s.name),l(s.executor_type??"command"),d(s.prompt_provider??"claude"),h(s.command),p(s.cwd??""),g(s.pty),v("service"===s.lifecycle)))},[e]);let T=async e=>{if(e.preventDefault(),i.trim()&&u.trim()){b(!0);try{await n({name:i.trim(),command:u.trim(),executor_type:o,prompt_provider:"prompt"===o?c:null,cwd:f.trim()||void 0,pty:"prompt"===o||m,lifecycle:"command"===o&&x?"service":"oneshot"}),r(!1),D||(a(""),l("command"),d("claude"),h(""),p(""),g(!0),v(!1))}finally{b(!1)}}};return(0,U.jsx)(rT,{open:e,onOpenChange:r,children:(0,U.jsxs)(rP,{children:[(0,U.jsx)(rF,{children:(0,U.jsxs)("div",{className:"flex items-center justify-between pr-6",children:[(0,U.jsx)(rO,{children:w?"Select Preset":D?"Edit Executor":"Add Executor"}),!D&&!w&&(0,U.jsx)("button",{type:"button",className:"text-sm text-muted-foreground hover:text-foreground transition-colors",onClick:()=>_(!0),children:"Select from presets"})]})}),(0,U.jsxs)("div",{className:"h-[420px] flex flex-col",children:[!w&&(0,U.jsxs)("form",{onSubmit:T,className:"space-y-4 flex-1 flex flex-col",children:[(0,U.jsxs)("div",{className:"space-y-2",children:[(0,U.jsx)("label",{className:"text-sm font-medium",children:"Name"}),(0,U.jsx)(aX,{placeholder:"e.g., Dev Server",value:i,onChange:e=>a(e.target.value),required:!0})]}),(0,U.jsxs)("div",{className:"space-y-2",children:[(0,U.jsx)("label",{className:"text-sm font-medium",children:"Type"}),(0,U.jsxs)("div",{className:"flex rounded-md border border-input overflow-hidden",children:[(0,U.jsx)("button",{type:"button",className:(0,e1.cn)("flex-1 px-3 py-1.5 text-sm font-medium transition-colors","command"===o?"bg-primary text-primary-foreground":"bg-background text-muted-foreground hover:bg-muted"),onClick:()=>l("command"),children:"Command"}),(0,U.jsx)("button",{type:"button",className:(0,e1.cn)("flex-1 px-3 py-1.5 text-sm font-medium transition-colors border-l border-input","prompt"===o?"bg-primary text-primary-foreground":"bg-background text-muted-foreground hover:bg-muted"),onClick:()=>l("prompt"),children:"Prompt"})]})]}),"prompt"===o&&(0,U.jsxs)("div",{className:"flex gap-3",children:[(0,U.jsxs)("div",{className:"w-[140px] shrink-0 space-y-2",children:[(0,U.jsx)("label",{className:"text-sm font-medium",children:"Provider"}),(0,U.jsxs)(fP,{value:c,onValueChange:e=>d(e),children:[(0,U.jsx)(fL,{className:"w-full",children:(0,U.jsx)(fF,{})}),(0,U.jsx)(fO,{children:aC.PROMPT_PROVIDERS.map(e=>(0,U.jsx)(fB,{value:e,children:aC.PROMPT_PROVIDER_LABELS[e]},e))})]})]}),(0,U.jsxs)("div",{className:"flex-1 space-y-2",children:[(0,U.jsxs)("label",{className:"text-sm font-medium",children:["Working Directory"," ",(0,U.jsx)("span",{className:"text-muted-foreground",children:"(optional)"})]}),(0,U.jsx)(aX,{placeholder:"Relative to worktree root",value:f,onChange:e=>p(e.target.value)})]})]}),(0,U.jsxs)("div",{className:"space-y-2",children:[(0,U.jsx)("label",{className:"text-sm font-medium",children:"prompt"===o?"Prompt":"Command"}),"prompt"===o?(0,U.jsx)("textarea",{className:"flex min-h-[90px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 resize-y",placeholder:"e.g., Review the code and suggest improvements",value:u,onChange:e=>h(e.target.value),required:!0}):(0,U.jsx)(aX,{placeholder:"e.g., npm run dev",value:u,onChange:e=>h(e.target.value),required:!0})]}),"command"===o&&(0,U.jsxs)("div",{className:"space-y-2",children:[(0,U.jsxs)("label",{className:"text-sm font-medium",children:["Working Directory"," ",(0,U.jsx)("span",{className:"text-muted-foreground",children:"(optional)"})]}),(0,U.jsx)(aX,{placeholder:"Relative to worktree root (leave empty for root)",value:f,onChange:e=>p(e.target.value)})]}),"command"===o&&(0,U.jsxs)("div",{className:"flex items-center justify-between",children:[(0,U.jsxs)("div",{className:"space-y-0.5",children:[(0,U.jsx)("label",{className:"text-sm font-medium",children:"Terminal Mode (PTY)"}),(0,U.jsx)("p",{className:"text-xs text-muted-foreground",children:"Enable for interactive commands like top, vim, htop"})]}),(0,U.jsx)("button",{type:"button",role:"switch","aria-checked":m,onClick:()=>g(!m),className:(0,e1.cn)("relative inline-flex h-6 w-11 shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",m?"bg-primary":"bg-input"),children:(0,U.jsx)("span",{className:(0,e1.cn)("pointer-events-none inline-block h-5 w-5 transform rounded-full bg-background shadow-lg ring-0 transition-transform",m?"translate-x-5":"translate-x-0")})})]}),"command"===o&&(0,U.jsxs)("div",{className:"flex items-center justify-between",children:[(0,U.jsxs)("div",{className:"space-y-0.5",children:[(0,U.jsx)("label",{className:"text-sm font-medium",children:"Long-running service"}),(0,U.jsx)("p",{className:"text-xs text-muted-foreground",children:"For dev servers and watchers: Main Chat treats it as done once it starts, instead of waiting for it to exit"})]}),(0,U.jsx)("button",{type:"button",role:"switch","aria-checked":x,"aria-label":"Long-running service",onClick:()=>v(!x),className:(0,e1.cn)("relative inline-flex h-6 w-11 shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",x?"bg-primary":"bg-input"),children:(0,U.jsx)("span",{className:(0,e1.cn)("pointer-events-none inline-block h-5 w-5 transform rounded-full bg-background shadow-lg ring-0 transition-transform",x?"translate-x-5":"translate-x-0")})})]}),(0,U.jsx)("div",{className:"flex-1"}),(0,U.jsxs)(rL,{children:[(0,U.jsx)(a$.Button,{type:"button",variant:"outline",onClick:()=>r(!1),children:"Cancel"}),(0,U.jsx)(a$.Button,{type:"submit",disabled:y||!i.trim()||!u.trim(),children:y?"Saving...":D?"Save":"Add"})]})]}),w&&(0,U.jsxs)("div",{className:"space-y-4 flex-1 flex flex-col min-h-0",children:[(0,U.jsx)(aX,{placeholder:"Search presets...",value:N,onChange:e=>E(e.target.value),autoFocus:!0}),(0,U.jsx)("div",{className:"flex-1 overflow-y-auto min-h-0 space-y-1",children:ST.filter(e=>{if(!N.trim())return!0;let r=N.toLowerCase();return e.name.toLowerCase().includes(r)||e.command.toLowerCase().includes(r)||(e.description?.toLowerCase().includes(r)??!1)}).map(e=>{let r=S?.command===e.command,s=j===e.command;return(0,U.jsxs)("div",{className:"rounded-md overflow-hidden",children:[(0,U.jsxs)("button",{type:"button",className:(0,e1.cn)("w-full flex items-center gap-2 px-3 py-2 text-sm transition-colors",r?"bg-primary/10 text-primary":"hover:bg-muted"),onClick:()=>k(e),children:["command"===e.executor_type?(0,U.jsx)(xb,{className:"h-4 w-4 shrink-0 text-muted-foreground"}):(0,U.jsx)(rJ,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),(0,U.jsx)("span",{className:"font-medium flex-1 text-left",children:e.name}),(0,U.jsx)("button",{type:"button",className:"shrink-0 p-0.5 rounded hover:bg-muted-foreground/10 transition-colors",onClick:r=>{r.stopPropagation(),C(s?null:e.command)},children:s?(0,U.jsx)(aa,{className:"h-4 w-4 text-muted-foreground"}):(0,U.jsx)(i2,{className:"h-4 w-4 text-muted-foreground"})})]}),s&&(0,U.jsxs)("div",{className:(0,e1.cn)("px-3 pb-2 pt-1 text-xs text-muted-foreground space-y-1 border-t border-border/50",r?"bg-primary/5":"bg-muted/50"),children:[e.description&&(0,U.jsx)("p",{children:e.description}),(0,U.jsx)("pre",{className:"whitespace-pre-wrap break-all bg-muted/50 rounded px-2 py-1 font-mono",children:e.command}),(0,U.jsxs)("div",{className:"flex gap-3",children:[(0,U.jsxs)("span",{children:["Type: ",(0,U.jsx)("span",{className:"font-medium text-foreground/70",children:e.executor_type})]}),(0,U.jsxs)("span",{children:["PTY: ",(0,U.jsx)("span",{className:"font-medium text-foreground/70",children:e.pty?"on":"off"})]})]})]})]},e.command)})}),(0,U.jsxs)(rL,{children:[(0,U.jsx)(a$.Button,{type:"button",variant:"outline",onClick:()=>{_(!1),k(null),C(null)},children:"Cancel"}),(0,U.jsx)(a$.Button,{type:"button",disabled:!S,onClick:()=>{S&&(a(S.name),h(S.command),l(S.executor_type),g(S.pty),v("service"===S.lifecycle),_(!1),k(null),C(null))},children:"Select"})]})]})]})]})})}let SA={logs:[],status:"connecting",exitCode:null,isPty:!1,replayingHistory:!0},SM=(0,V.createContext)(null);function SI({projectId:e,children:r}){let s=(0,V.useRef)(new Map),n=(0,V.useRef)(new Map),i=(0,V.useRef)(new Set),a=(0,V.useRef)(null),o=(0,V.useRef)(0),l=(0,V.useRef)(null),c=(0,V.useCallback)(e=>{n.current.get(e)?.forEach(e=>e())},[]),d=(0,V.useCallback)((e,r)=>{let n=s.current.get(e)??SA;s.current.set(e,{...n,...r}),c(e)},[c]),u=(0,V.useRef)(new Map),h=(0,V.useRef)(new Map),f=(0,V.useCallback)(e=>{a.current?.readyState===WebSocket.OPEN&&a.current.send(JSON.stringify(e))},[]),p=(0,V.useCallback)(e=>{let r=u.current.get(e);r&&clearTimeout(r),u.current.delete(e),h.current.delete(e)},[]),m=(0,V.useCallback)(e=>{let r=u.current.get(e);r&&clearTimeout(r);let s=h.current.get(e)??0;if(s>=12){u.current.delete(e),d(e,{status:"error"});return}h.current.set(e,s+1);let n=Math.min(15e3,1e3*2**s),a=n+n*Math.random()*.25;d(e,{status:"connecting"});let o=setTimeout(()=>{u.current.delete(e),i.current.has(e)&&f({type:"subscribe",processId:e})},a);u.current.set(e,o)},[f,d]),g=(0,V.useCallback)(e=>{let{processId:r}=e;if(i.current.has(r))if("init"===e.type)p(r),d(r,{isPty:e.isPty,replayingHistory:!0,logs:[],status:"connected"});else if("history_end"===e.type)d(r,{replayingHistory:!1});else if("finished"===e.type)d(r,{exitCode:e.exitCode,status:"closed"});else if("error"===e.type)e.retryable?m(r):(p(r),d(r,{status:"error"}));else{let n=s.current.get(r)??SA,{processId:i,...a}=e;d(r,{logs:[...n.logs,{...a,historical:n.replayingHistory}]})}},[d,p,m]);(0,V.useEffect)(()=>{if(!e)return;let r=!1;o.current=0;let n=0,c=()=>{r||(0,aC.getFreshToken)().then(()=>{if(!r){if(!(0,aC.hasUsableStreamToken)()){let e=Math.min(15e3,1e3*2**Math.min(n,4));n+=1,l.current=setTimeout(()=>{l.current=null,c()},e);return}n=0,(()=>{if(r)return;let n=new WebSocket((0,aC.getWebSocketUrl)(`/api/executor-logs/stream?projectId=${encodeURIComponent(e)}`));a.current=n,n.onopen=()=>{if(!r)for(let e of(o.current=0,i.current))p(e),n.send(JSON.stringify({type:"subscribe",processId:e}))},n.onmessage=e=>{if(!r)try{g(JSON.parse(e.data))}catch(e){console.error("[ExecutorLogs] parse error:",e)}},n.onclose=()=>{if(a.current=null,r)return;let e=e=>{let r=s.current.get(e);return r?.status==="closed"||r?.status==="error"};if(o.current<8){let s=o.current++,n=Math.min(15e3,1e3*2**s),a=n+n*Math.random()*.25;for(let r of i.current)e(r)||d(r,{status:"connecting"});l.current=setTimeout(()=>{l.current=null,r||c()},a)}else for(let r of i.current)e(r)||d(r,{status:"error"})}})()}})};c();let f=u.current,m=h.current;return()=>{for(let e of(r=!0,l.current&&clearTimeout(l.current),l.current=null,f.values()))clearTimeout(e);f.clear(),m.clear(),a.current?.close(),a.current=null}},[e,g,d,p]);let x=(0,V.useMemo)(()=>({subscribeProcess:e=>{i.current.has(e)||(i.current.add(e),s.current.set(e,{...SA}),c(e),f({type:"subscribe",processId:e}))},unsubscribeProcess:e=>{i.current.has(e)&&(i.current.delete(e),p(e),f({type:"unsubscribe",processId:e}))},sendInput:(e,r)=>f({type:"input",processId:e,data:r}),sendResize:(e,r,s)=>f({type:"resize",processId:e,cols:r,rows:s}),onProcessChange:(e,r)=>{let s=n.current.get(e);return s||(s=new Set,n.current.set(e,s)),s.add(r),()=>{s?.delete(r)}},getProcessState:e=>s.current.get(e)??SA}),[c,f,p]);return(0,U.jsx)(SM.Provider,{value:x,children:r})}let SP="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement;function SF(e){let r=Object.prototype.toString.call(e);return"[object Window]"===r||"[object global]"===r}function SL(e){return"nodeType"in e}function SO(e){var r,s;return e?SF(e)?e:SL(e)&&null!=(r=null==(s=e.ownerDocument)?void 0:s.defaultView)?r:window:window}function SB(e){let{Document:r}=SO(e);return e instanceof r}function Sz(e){return!SF(e)&&e instanceof SO(e).HTMLElement}function S$(e){return e instanceof SO(e).SVGElement}function SW(e){return e?SF(e)?e.document:SL(e)?SB(e)?e:Sz(e)||S$(e)?e.ownerDocument:document:document:document}let SH=SP?V.useLayoutEffect:V.useEffect;function SU(e){let r=(0,V.useRef)(e);return SH(()=>{r.current=e}),(0,V.useCallback)(function(){for(var e=arguments.length,s=Array(e),n=0;n<e;n++)s[n]=arguments[n];return null==r.current?void 0:r.current(...s)},[])}function SV(e,r){void 0===r&&(r=[e]);let s=(0,V.useRef)(e);return SH(()=>{s.current!==e&&(s.current=e)},r),s}function Sq(e,r){let s=(0,V.useRef)();return(0,V.useMemo)(()=>{let r=e(s.current);return s.current=r,r},[...r])}function SK(e){let r=SU(e),s=(0,V.useRef)(null),n=(0,V.useCallback)(e=>{e!==s.current&&(null==r||r(e,s.current)),s.current=e},[]);return[s,n]}function SX(e){let r=(0,V.useRef)();return(0,V.useEffect)(()=>{r.current=e},[e]),r.current}let SY={};function SG(e,r){return(0,V.useMemo)(()=>{if(r)return r;let s=null==SY[e]?0:SY[e]+1;return SY[e]=s,e+"-"+s},[e,r])}function SJ(e){return function(r){for(var s=arguments.length,n=Array(s>1?s-1:0),i=1;i<s;i++)n[i-1]=arguments[i];return n.reduce((r,s)=>{for(let[n,i]of Object.entries(s)){let s=r[n];null!=s&&(r[n]=s+e*i)}return r},{...r})}}let SZ=SJ(1),SQ=SJ(-1);function S0(e){if(!e)return!1;let{KeyboardEvent:r}=SO(e.target);return r&&e instanceof r}function S1(e){if(function(e){if(!e)return!1;let{TouchEvent:r}=SO(e.target);return r&&e instanceof r}(e)){if(e.touches&&e.touches.length){let{clientX:r,clientY:s}=e.touches[0];return{x:r,y:s}}else if(e.changedTouches&&e.changedTouches.length){let{clientX:r,clientY:s}=e.changedTouches[0];return{x:r,y:s}}}return"clientX"in e&&"clientY"in e?{x:e.clientX,y:e.clientY}:null}let S2=Object.freeze({Translate:{toString(e){if(!e)return;let{x:r,y:s}=e;return"translate3d("+(r?Math.round(r):0)+"px, "+(s?Math.round(s):0)+"px, 0)"}},Scale:{toString(e){if(!e)return;let{scaleX:r,scaleY:s}=e;return"scaleX("+r+") scaleY("+s+")"}},Transform:{toString(e){if(e)return[S2.Translate.toString(e),S2.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:r,duration:s,easing:n}=e;return r+" "+s+"ms "+n}}}),S5="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]",S3={display:"none"};function S4(e){let{id:r,value:s}=e;return V.default.createElement("div",{id:r,style:S3},s)}function S6(e){let{id:r,announcement:s,ariaLiveType:n="assertive"}=e;return V.default.createElement("div",{id:r,style:{position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"},role:"status","aria-live":n,"aria-atomic":!0},s)}let S7=(0,V.createContext)(null),S8={draggable:"\n To pick up a draggable item, press the space bar.\n While dragging, use the arrow keys to move the item.\n Press space again to drop the item in its new position, or press escape to cancel.\n "},S9={onDragStart(e){let{active:r}=e;return"Picked up draggable item "+r.id+"."},onDragOver(e){let{active:r,over:s}=e;return s?"Draggable item "+r.id+" was moved over droppable area "+s.id+".":"Draggable item "+r.id+" is no longer over a droppable area."},onDragEnd(e){let{active:r,over:s}=e;return s?"Draggable item "+r.id+" was dropped over droppable area "+s.id:"Draggable item "+r.id+" was dropped."},onDragCancel(e){let{active:r}=e;return"Dragging was cancelled. Draggable item "+r.id+" was dropped."}};function ke(e){var r;let s,{announcements:n=S9,container:i,hiddenTextDescribedById:a,screenReaderInstructions:o=S8}=e,{announce:l,announcement:c}=function(){let[e,r]=(0,V.useState)("");return{announce:(0,V.useCallback)(e=>{null!=e&&r(e)},[]),announcement:e}}(),d=SG("DndLiveRegion"),[u,h]=(0,V.useState)(!1);if((0,V.useEffect)(()=>{h(!0)},[]),r=(0,V.useMemo)(()=>({onDragStart(e){let{active:r}=e;l(n.onDragStart({active:r}))},onDragMove(e){let{active:r,over:s}=e;n.onDragMove&&l(n.onDragMove({active:r,over:s}))},onDragOver(e){let{active:r,over:s}=e;l(n.onDragOver({active:r,over:s}))},onDragEnd(e){let{active:r,over:s}=e;l(n.onDragEnd({active:r,over:s}))},onDragCancel(e){let{active:r,over:s}=e;l(n.onDragCancel({active:r,over:s}))}}),[l,n]),s=(0,V.useContext)(S7),(0,V.useEffect)(()=>{if(!s)throw Error("useDndMonitor must be used within a children of <DndContext>");return s(r)},[r,s]),!u)return null;let f=V.default.createElement(V.default.Fragment,null,V.default.createElement(S4,{id:a,value:o.draggable}),V.default.createElement(S6,{id:d,announcement:c}));return i?(0,ep.createPortal)(f,i):f}function kt(){}function kr(e,r){return(0,V.useMemo)(()=>({sensor:e,options:null!=r?r:{}}),[e,r])}(_=A||(A={})).DragStart="dragStart",_.DragMove="dragMove",_.DragEnd="dragEnd",_.DragCancel="dragCancel",_.DragOver="dragOver",_.RegisterDroppable="registerDroppable",_.SetDroppableDisabled="setDroppableDisabled",_.UnregisterDroppable="unregisterDroppable";let ks=Object.freeze({x:0,y:0});function kn(e,r){return Math.sqrt(Math.pow(e.x-r.x,2)+Math.pow(e.y-r.y,2))}function ki(e,r){let{data:{value:s}}=e,{data:{value:n}}=r;return s-n}function ka(e,r){let{data:{value:s}}=e,{data:{value:n}}=r;return n-s}function ko(e){let{left:r,top:s,height:n,width:i}=e;return[{x:r,y:s},{x:r+i,y:s},{x:r,y:s+n},{x:r+i,y:s+n}]}function kl(e,r){if(!e||0===e.length)return null;let[s]=e;return r?s[r]:s}function kc(e,r,s){return void 0===r&&(r=e.left),void 0===s&&(s=e.top),{x:r+.5*e.width,y:s+.5*e.height}}let kd=e=>{let{collisionRect:r,droppableRects:s,droppableContainers:n}=e,i=[];for(let e of n){let{id:n}=e,a=s.get(n);if(a){let s=function(e,r){let s=Math.max(r.top,e.top),n=Math.max(r.left,e.left),i=Math.min(r.left+r.width,e.left+e.width),a=Math.min(r.top+r.height,e.top+e.height);if(n<i&&s<a){let o=r.width*r.height,l=e.width*e.height,c=(i-n)*(a-s);return Number((c/(o+l-c)).toFixed(4))}return 0}(a,r);s>0&&i.push({id:n,data:{droppableContainer:e,value:s}})}}return i.sort(ka)};function ku(e,r){return e&&r?{x:e.left-r.left,y:e.top-r.top}:ks}let kh=function(e){for(var r=arguments.length,s=Array(r>1?r-1:0),n=1;n<r;n++)s[n-1]=arguments[n];return s.reduce((e,r)=>({...e,top:e.top+ +r.y,bottom:e.bottom+ +r.y,left:e.left+ +r.x,right:e.right+ +r.x}),{...e})},kf={ignoreTransform:!1};function kp(e,r){void 0===r&&(r=kf);let s=e.getBoundingClientRect();if(r.ignoreTransform){let{transform:r,transformOrigin:n}=SO(e).getComputedStyle(e);r&&(s=function(e,r,s){let n=function(e){if(e.startsWith("matrix3d(")){let r=e.slice(9,-1).split(/, /);return{x:+r[12],y:+r[13],scaleX:+r[0],scaleY:+r[5]}}if(e.startsWith("matrix(")){let r=e.slice(7,-1).split(/, /);return{x:+r[4],y:+r[5],scaleX:+r[0],scaleY:+r[3]}}return null}(r);if(!n)return e;let{scaleX:i,scaleY:a,x:o,y:l}=n,c=e.left-o-(1-i)*parseFloat(s),d=e.top-l-(1-a)*parseFloat(s.slice(s.indexOf(" ")+1)),u=i?e.width/i:e.width,h=a?e.height/a:e.height;return{width:u,height:h,top:d,right:c+u,bottom:d+h,left:c}}(s,r,n))}let{top:n,left:i,width:a,height:o,bottom:l,right:c}=s;return{top:n,left:i,width:a,height:o,bottom:l,right:c}}function km(e){return kp(e,{ignoreTransform:!0})}function kg(e,r){let s=[];return e?function n(i){var a,o;let l;if(null!=r&&s.length>=r||!i)return s;if(SB(i)&&null!=i.scrollingElement&&!s.includes(i.scrollingElement))return s.push(i.scrollingElement),s;if(!Sz(i)||S$(i)||s.includes(i))return s;let c=SO(e).getComputedStyle(i);return(i!==e&&(void 0===(a=c)&&(a=SO(i).getComputedStyle(i)),l=/(auto|scroll|overlay)/,["overflow","overflowX","overflowY"].some(e=>{let r=a[e];return"string"==typeof r&&l.test(r)}))&&s.push(i),void 0===(o=c)&&(o=SO(i).getComputedStyle(i)),"fixed"===o.position)?s:n(i.parentNode)}(e):s}function kx(e){let[r]=kg(e,1);return null!=r?r:null}function kv(e){return SP&&e?SF(e)?e:SL(e)?SB(e)||e===SW(e).scrollingElement?window:Sz(e)?e:null:null:null}function ky(e){return SF(e)?e.scrollX:e.scrollLeft}function kb(e){return SF(e)?e.scrollY:e.scrollTop}function kw(e){return{x:ky(e),y:kb(e)}}function k_(e){return!!SP&&!!e&&e===document.scrollingElement}function kS(e){let r={x:0,y:0},s=k_(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},n={x:e.scrollWidth-s.width,y:e.scrollHeight-s.height},i=e.scrollTop<=r.y,a=e.scrollLeft<=r.x;return{isTop:i,isLeft:a,isBottom:e.scrollTop>=n.y,isRight:e.scrollLeft>=n.x,maxScroll:n,minScroll:r}}(S=M||(M={}))[S.Forward=1]="Forward",S[S.Backward=-1]="Backward";let kk={x:.2,y:.2};function kj(e){return e.reduce((e,r)=>SZ(e,kw(r)),ks)}let kC=[["x",["left","right"],function(e){return e.reduce((e,r)=>e+ky(r),0)}],["y",["top","bottom"],function(e){return e.reduce((e,r)=>e+kb(r),0)}]];class kN{constructor(e,r){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;const s=kg(r),n=kj(s);for(const[r,i,a]of(this.rect={...e},this.width=e.width,this.height=e.height,kC))for(const e of i)Object.defineProperty(this,e,{get:()=>{let i=a(s),o=n[r]-i;return this.rect[e]+o},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class kE{constructor(e){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(e=>{var r;return null==(r=this.target)?void 0:r.removeEventListener(...e)})},this.target=e}add(e,r,s){var n;null==(n=this.target)||n.addEventListener(e,r,s),this.listeners.push([e,r,s])}}function kD(e,r){let s=Math.abs(e.x),n=Math.abs(e.y);return"number"==typeof r?Math.sqrt(s**2+n**2)>r:"x"in r&&"y"in r?s>r.x&&n>r.y:"x"in r?s>r.x:"y"in r&&n>r.y}function kT(e){e.preventDefault()}function kR(e){e.stopPropagation()}(k=I||(I={})).Click="click",k.DragStart="dragstart",k.Keydown="keydown",k.ContextMenu="contextmenu",k.Resize="resize",k.SelectionChange="selectionchange",k.VisibilityChange="visibilitychange",(j=P||(P={})).Space="Space",j.Down="ArrowDown",j.Right="ArrowRight",j.Left="ArrowLeft",j.Up="ArrowUp",j.Esc="Escape",j.Enter="Enter",j.Tab="Tab";let kA={start:[P.Space,P.Enter],cancel:[P.Esc],end:[P.Space,P.Enter,P.Tab]},kM=(e,r)=>{let{currentCoordinates:s}=r;switch(e.code){case P.Right:return{...s,x:s.x+25};case P.Left:return{...s,x:s.x-25};case P.Down:return{...s,y:s.y+25};case P.Up:return{...s,y:s.y-25}}};class kI{constructor(e){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=e;const{event:{target:r}}=e;this.props=e,this.listeners=new kE(SW(r)),this.windowListeners=new kE(SO(r)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(I.Resize,this.handleCancel),this.windowListeners.add(I.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(I.Keydown,this.handleKeyDown))}handleStart(){let{activeNode:e,onStart:r}=this.props,s=e.node.current;s&&function(e,r){if(void 0===r&&(r=kp),!e)return;let{top:s,left:n,bottom:i,right:a}=r(e);kx(e)&&(i<=0||a<=0||s>=window.innerHeight||n>=window.innerWidth)&&e.scrollIntoView({block:"center",inline:"center"})}(s),r(ks)}handleKeyDown(e){if(S0(e)){let{active:r,context:s,options:n}=this.props,{keyboardCodes:i=kA,coordinateGetter:a=kM,scrollBehavior:o="smooth"}=n,{code:l}=e;if(i.end.includes(l))return void this.handleEnd(e);if(i.cancel.includes(l))return void this.handleCancel(e);let{collisionRect:c}=s.current,d=c?{x:c.left,y:c.top}:ks;this.referenceCoordinates||(this.referenceCoordinates=d);let u=a(e,{active:r,context:s.current,currentCoordinates:d});if(u){let r=SQ(u,d),n={x:0,y:0},{scrollableAncestors:i}=s.current;for(let s of i){let i=e.code,{isTop:a,isRight:l,isLeft:c,isBottom:d,maxScroll:h,minScroll:f}=kS(s),p=function(e){if(e===document.scrollingElement){let{innerWidth:e,innerHeight:r}=window;return{top:0,left:0,right:e,bottom:r,width:e,height:r}}let{top:r,left:s,right:n,bottom:i}=e.getBoundingClientRect();return{top:r,left:s,right:n,bottom:i,width:e.clientWidth,height:e.clientHeight}}(s),m={x:Math.min(i===P.Right?p.right-p.width/2:p.right,Math.max(i===P.Right?p.left:p.left+p.width/2,u.x)),y:Math.min(i===P.Down?p.bottom-p.height/2:p.bottom,Math.max(i===P.Down?p.top:p.top+p.height/2,u.y))},g=i===P.Right&&!l||i===P.Left&&!c,x=i===P.Down&&!d||i===P.Up&&!a;if(g&&m.x!==u.x){let e=s.scrollLeft+r.x,a=i===P.Right&&e<=h.x||i===P.Left&&e>=f.x;if(a&&!r.y)return void s.scrollTo({left:e,behavior:o});a?n.x=s.scrollLeft-e:n.x=i===P.Right?s.scrollLeft-h.x:s.scrollLeft-f.x,n.x&&s.scrollBy({left:-n.x,behavior:o});break}if(x&&m.y!==u.y){let e=s.scrollTop+r.y,a=i===P.Down&&e<=h.y||i===P.Up&&e>=f.y;if(a&&!r.x)return void s.scrollTo({top:e,behavior:o});a?n.y=s.scrollTop-e:n.y=i===P.Down?s.scrollTop-h.y:s.scrollTop-f.y,n.y&&s.scrollBy({top:-n.y,behavior:o});break}}this.handleMove(e,SZ(SQ(u,this.referenceCoordinates),n))}}}handleMove(e,r){let{onMove:s}=this.props;e.preventDefault(),s(r)}handleEnd(e){let{onEnd:r}=this.props;e.preventDefault(),this.detach(),r()}handleCancel(e){let{onCancel:r}=this.props;e.preventDefault(),this.detach(),r()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}function kP(e){return!!(e&&"distance"in e)}function kF(e){return!!(e&&"delay"in e)}kI.activators=[{eventName:"onKeyDown",handler:(e,r,s)=>{let{keyboardCodes:n=kA,onActivation:i}=r,{active:a}=s,{code:o}=e.nativeEvent;if(n.start.includes(o)){let r=a.activatorNode.current;return(!r||e.target===r)&&(e.preventDefault(),null==i||i({event:e.nativeEvent}),!0)}return!1}}];class kL{constructor(e,r,s){var n;void 0===s&&(s=function(e){let{EventTarget:r}=SO(e);return e instanceof r?e:SW(e)}(e.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=e,this.events=r;const{event:i}=e,{target:a}=i;this.props=e,this.events=r,this.document=SW(a),this.documentListeners=new kE(this.document),this.listeners=new kE(s),this.windowListeners=new kE(SO(a)),this.initialCoordinates=null!=(n=S1(i))?n:ks,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){let{events:e,props:{options:{activationConstraint:r,bypassActivationConstraint:s}}}=this;if(this.listeners.add(e.move.name,this.handleMove,{passive:!1}),this.listeners.add(e.end.name,this.handleEnd),e.cancel&&this.listeners.add(e.cancel.name,this.handleCancel),this.windowListeners.add(I.Resize,this.handleCancel),this.windowListeners.add(I.DragStart,kT),this.windowListeners.add(I.VisibilityChange,this.handleCancel),this.windowListeners.add(I.ContextMenu,kT),this.documentListeners.add(I.Keydown,this.handleKeydown),r){if(null!=s&&s({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(kF(r)){this.timeoutId=setTimeout(this.handleStart,r.delay),this.handlePending(r);return}if(kP(r))return void this.handlePending(r)}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),null!==this.timeoutId&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(e,r){let{active:s,onPending:n}=this.props;n(s,e,this.initialCoordinates,r)}handleStart(){let{initialCoordinates:e}=this,{onStart:r}=this.props;e&&(this.activated=!0,this.documentListeners.add(I.Click,kR,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(I.SelectionChange,this.removeTextSelection),r(e))}handleMove(e){var r;let{activated:s,initialCoordinates:n,props:i}=this,{onMove:a,options:{activationConstraint:o}}=i;if(!n)return;let l=null!=(r=S1(e))?r:ks,c=SQ(n,l);if(!s&&o){if(kP(o)){if(null!=o.tolerance&&kD(c,o.tolerance))return this.handleCancel();if(kD(c,o.distance))return this.handleStart()}return kF(o)&&kD(c,o.tolerance)?this.handleCancel():void this.handlePending(o,c)}e.cancelable&&e.preventDefault(),a(l)}handleEnd(){let{onAbort:e,onEnd:r}=this.props;this.detach(),this.activated||e(this.props.active),r()}handleCancel(){let{onAbort:e,onCancel:r}=this.props;this.detach(),this.activated||e(this.props.active),r()}handleKeydown(e){e.code===P.Esc&&this.handleCancel()}removeTextSelection(){var e;null==(e=this.document.getSelection())||e.removeAllRanges()}}let kO={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class kB extends kL{constructor(e){const{event:r}=e;super(e,kO,SW(r.target))}}kB.activators=[{eventName:"onPointerDown",handler:(e,r)=>{let{nativeEvent:s}=e,{onActivation:n}=r;return!!s.isPrimary&&0===s.button&&(null==n||n({event:s}),!0)}}];(C=F||(F={}))[C.RightClick=2]="RightClick";(N=L||(L={}))[N.Pointer=0]="Pointer",N[N.DraggableRect=1]="DraggableRect",(E=O||(O={}))[E.TreeOrder=0]="TreeOrder",E[E.ReversedTreeOrder=1]="ReversedTreeOrder";let kz={x:{[M.Backward]:!1,[M.Forward]:!1},y:{[M.Backward]:!1,[M.Forward]:!1}};(D=B||(B={}))[D.Always=0]="Always",D[D.BeforeDragging=1]="BeforeDragging",D[D.WhileDragging=2]="WhileDragging",(z||(z={})).Optimized="optimized";let k$=new Map;function kW(e,r){return Sq(s=>e?s||("function"==typeof r?r(e):e):null,[r,e])}function kH(e){let{callback:r,disabled:s}=e,n=SU(r),i=(0,V.useMemo)(()=>{if(s||"undefined"==typeof window||void 0===window.ResizeObserver)return;let{ResizeObserver:e}=window;return new e(n)},[s]);return(0,V.useEffect)(()=>()=>null==i?void 0:i.disconnect(),[i]),i}function kU(e){return new kN(kp(e),e)}function kV(e,r,s){void 0===r&&(r=kU);let[n,i]=(0,V.useState)(null);function a(){i(n=>{if(!e)return null;if(!1===e.isConnected){var i;return null!=(i=null!=n?n:s)?i:null}let a=r(e);return JSON.stringify(n)===JSON.stringify(a)?n:a})}let o=function(e){let{callback:r,disabled:s}=e,n=SU(r),i=(0,V.useMemo)(()=>{if(s||"undefined"==typeof window||void 0===window.MutationObserver)return;let{MutationObserver:e}=window;return new e(n)},[n,s]);return(0,V.useEffect)(()=>()=>null==i?void 0:i.disconnect(),[i]),i}({callback(r){if(e)for(let s of r){let{type:r,target:n}=s;if("childList"===r&&n instanceof HTMLElement&&n.contains(e)){a();break}}}}),l=kH({callback:a});return SH(()=>{a(),e?(null==l||l.observe(e),null==o||o.observe(document.body,{childList:!0,subtree:!0})):(null==l||l.disconnect(),null==o||o.disconnect())},[e]),n}let kq=[];function kK(e,r){void 0===r&&(r=[]);let s=(0,V.useRef)(null);return(0,V.useEffect)(()=>{s.current=null},r),(0,V.useEffect)(()=>{let r=e!==ks;r&&!s.current&&(s.current=e),!r&&s.current&&(s.current=null)},[e]),s.current?SQ(e,s.current):ks}function kX(e){return(0,V.useMemo)(()=>{let r,s;return e?(r=e.innerWidth,{top:0,left:0,right:r,bottom:s=e.innerHeight,width:r,height:s}):null},[e])}let kY=[],kG=[{sensor:kB,options:{}},{sensor:kI,options:{}}],kJ={current:{}},kZ={draggable:{measure:km},droppable:{measure:km,strategy:B.WhileDragging,frequency:z.Optimized},dragOverlay:{measure:kp}};class kQ extends Map{get(e){var r;return null!=e&&null!=(r=super.get(e))?r:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(e=>{let{disabled:r}=e;return!r})}getNodeFor(e){var r,s;return null!=(r=null==(s=this.get(e))?void 0:s.node.current)?r:void 0}}let k0={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new kQ,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:kt},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:kZ,measureDroppableContainers:kt,windowRect:null,measuringScheduled:!1},k1={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:kt,draggableNodes:new Map,over:null,measureDroppableContainers:kt},k2=(0,V.createContext)(k1),k5=(0,V.createContext)(k0);function k3(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new kQ}}}function k4(e,r){switch(r.type){case A.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:r.initialCoordinates,active:r.active}};case A.DragMove:if(null==e.draggable.active)return e;return{...e,draggable:{...e.draggable,translate:{x:r.coordinates.x-e.draggable.initialCoordinates.x,y:r.coordinates.y-e.draggable.initialCoordinates.y}}};case A.DragEnd:case A.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case A.RegisterDroppable:{let{element:s}=r,{id:n}=s,i=new kQ(e.droppable.containers);return i.set(n,s),{...e,droppable:{...e.droppable,containers:i}}}case A.SetDroppableDisabled:{let{id:s,key:n,disabled:i}=r,a=e.droppable.containers.get(s);if(!a||n!==a.key)return e;let o=new kQ(e.droppable.containers);return o.set(s,{...a,disabled:i}),{...e,droppable:{...e.droppable,containers:o}}}case A.UnregisterDroppable:{let{id:s,key:n}=r,i=e.droppable.containers.get(s);if(!i||n!==i.key)return e;let a=new kQ(e.droppable.containers);return a.delete(s),{...e,droppable:{...e.droppable,containers:a}}}default:return e}}function k6(e){let{disabled:r}=e,{active:s,activatorEvent:n,draggableNodes:i}=(0,V.useContext)(k2),a=SX(n),o=SX(null==s?void 0:s.id);return(0,V.useEffect)(()=>{if(!r&&!n&&a&&null!=o){if(!S0(a)||document.activeElement===a.target)return;let e=i.get(o);if(!e)return;let{activatorNode:r,node:s}=e;(r.current||s.current)&&requestAnimationFrame(()=>{for(let e of[r.current,s.current]){if(!e)continue;let r=e.matches(S5)?e:e.querySelector(S5);if(r){r.focus();break}}})}},[n,r,i,o,a]),null}let k7=(0,V.createContext)({...ks,scaleX:1,scaleY:1});(T=$||($={}))[T.Uninitialized=0]="Uninitialized",T[T.Initializing=1]="Initializing",T[T.Initialized=2]="Initialized";let k8=(0,V.memo)(function(e){var r,s,n,i,a,o,l,c;let d,u,h,f,p,m,g,x,{id:v,accessibility:y,autoScroll:b=!0,children:w,sensors:_=kG,collisionDetection:S=kd,measuring:k,modifiers:j,...C}=e,[N,E]=(0,V.useReducer)(k4,void 0,k3),[D,T]=function(){let[e]=(0,V.useState)(()=>new Set),r=(0,V.useCallback)(r=>(e.add(r),()=>e.delete(r)),[e]);return[(0,V.useCallback)(r=>{let{type:s,event:n}=r;e.forEach(e=>{var r;return null==(r=e[s])?void 0:r.call(e,n)})},[e]),r]}(),[R,I]=(0,V.useState)($.Uninitialized),P=R===$.Initialized,{draggable:{active:F,nodes:z,translate:W},droppable:{containers:H}}=N,U=null!=F?z.get(F):null,q=(0,V.useRef)({initial:null,translated:null}),K=(0,V.useMemo)(()=>{var e;return null!=F?{id:F,data:null!=(e=null==U?void 0:U.data)?e:kJ,rect:q}:null},[F,U]),X=(0,V.useRef)(null),[Y,G]=(0,V.useState)(null),[J,Z]=(0,V.useState)(null),Q=SV(C,Object.values(C)),ee=SG("DndDescribedBy",v),et=(0,V.useMemo)(()=>H.getEnabled(),[H]),er=(0,V.useMemo)(()=>({draggable:{...kZ.draggable,...null==k?void 0:k.draggable},droppable:{...kZ.droppable,...null==k?void 0:k.droppable},dragOverlay:{...kZ.dragOverlay,...null==k?void 0:k.dragOverlay}}),[null==k?void 0:k.draggable,null==k?void 0:k.droppable,null==k?void 0:k.dragOverlay]),{droppableRects:es,measureDroppableContainers:en,measuringScheduled:ei}=function(e,r){let{dragging:s,dependencies:n,config:i}=r,[a,o]=(0,V.useState)(null),{frequency:l,measure:c,strategy:d}=i,u=(0,V.useRef)(e),h=function(){switch(d){case B.Always:return!1;case B.BeforeDragging:return s;default:return!s}}(),f=SV(h),p=(0,V.useCallback)(function(e){void 0===e&&(e=[]),f.current||o(r=>null===r?e:r.concat(e.filter(e=>!r.includes(e))))},[f]),m=(0,V.useRef)(null),g=Sq(r=>{if(h&&!s)return k$;if(!r||r===k$||u.current!==e||null!=a){let r=new Map;for(let s of e){if(!s)continue;if(a&&a.length>0&&!a.includes(s.id)&&s.rect.current){r.set(s.id,s.rect.current);continue}let e=s.node.current,n=e?new kN(c(e),e):null;s.rect.current=n,n&&r.set(s.id,n)}return r}return r},[e,a,s,h,c]);return(0,V.useEffect)(()=>{u.current=e},[e]),(0,V.useEffect)(()=>{h||p()},[s,h]),(0,V.useEffect)(()=>{a&&a.length>0&&o(null)},[JSON.stringify(a)]),(0,V.useEffect)(()=>{h||"number"!=typeof l||null!==m.current||(m.current=setTimeout(()=>{p(),m.current=null},l))},[l,h,p,...n]),{droppableRects:g,measureDroppableContainers:p,measuringScheduled:null!=a}}(et,{dragging:P,dependencies:[W.x,W.y],config:er.droppable}),ea=Sq(e=>{var r;return null==F?null:null!=(r=null!=p?p:e)?r:null},[p=(f=null!=F?z.get(F):void 0)?f.node.current:null,F]),eo=(0,V.useMemo)(()=>J?S1(J):null,[J]),el=(d=(null==Y?void 0:Y.autoScrollEnabled)===!1,u="object"==typeof b?!1===b.enabled:!1===b,h=P&&!d&&!u,"object"==typeof b?{...b,enabled:h}:{enabled:h}),ec=kW(ea,er.draggable.measure);!function(e){let{activeNode:r,measure:s,initialRect:n,config:i=!0}=e,a=(0,V.useRef)(!1),{x:o,y:l}="boolean"==typeof i?{x:i,y:i}:i;SH(()=>{if(!o&&!l||!r){a.current=!1;return}if(a.current||!n)return;let e=null==r?void 0:r.node.current;if(!e||!1===e.isConnected)return;let i=ku(s(e),n);if(o||(i.x=0),l||(i.y=0),a.current=!0,Math.abs(i.x)>0||Math.abs(i.y)>0){let r=kx(e);r&&r.scrollBy({top:i.y,left:i.x})}},[r,o,l,n,s])}({activeNode:null!=F?z.get(F):null,config:el.layoutShiftCompensation,initialRect:ec,measure:er.draggable.measure});let ed=kV(ea,er.draggable.measure,ec),eu=kV(ea?ea.parentElement:null),eh=(0,V.useRef)({activatorEvent:null,active:null,activeNode:ea,collisionRect:null,collisions:null,droppableRects:es,draggableNodes:z,draggingNode:null,draggingNodeRect:null,droppableContainers:H,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),ef=H.getNodeFor(null==(r=eh.current.over)?void 0:r.id),em=function(e){let{measure:r}=e,[s,n]=(0,V.useState)(null),i=kH({callback:(0,V.useCallback)(e=>{for(let{target:s}of e)if(Sz(s)){n(e=>{let n=r(s);return e?{...e,width:n.width,height:n.height}:n});break}},[r])}),[a,o]=SK((0,V.useCallback)(e=>{let s=function(e){if(!e)return null;if(e.children.length>1)return e;let r=e.children[0];return Sz(r)?r:e}(e);null==i||i.disconnect(),s&&(null==i||i.observe(s)),n(s?r(s):null)},[r,i]));return(0,V.useMemo)(()=>({nodeRef:a,rect:s,setRef:o}),[s,a,o])}({measure:er.dragOverlay.measure}),eg=null!=(s=em.nodeRef.current)?s:ea,ex=P?null!=(n=em.rect)?n:ed:null,ev=!!(em.nodeRef.current&&em.rect),ey=(m=kW(a=ev?null:ed),ku(a,m)),eb=kX(eg?SO(eg):null),ew=(o=P?null!=ef?ef:ea:null,g=(0,V.useRef)(o),x=Sq(e=>o?e&&e!==kq&&o&&g.current&&o.parentNode===g.current.parentNode?e:kg(o):kq,[o]),(0,V.useEffect)(()=>{g.current=o},[o]),x),e_=function(e,r){void 0===r&&(r=kp);let[s]=e,n=kX(s?SO(s):null),[i,a]=(0,V.useState)(kY);function o(){a(()=>e.length?e.map(e=>k_(e)?n:new kN(r(e),e)):kY)}let l=kH({callback:o});return SH(()=>{null==l||l.disconnect(),o(),e.forEach(e=>null==l?void 0:l.observe(e))},[e]),i}(ew),eS=function(e,r){let{transform:s,...n}=r;return null!=e&&e.length?e.reduce((e,r)=>r({transform:e,...n}),s):s}(j,{transform:{x:W.x-ey.x,y:W.y-ey.y,scaleX:1,scaleY:1},activatorEvent:J,active:K,activeNodeRect:ed,containerNodeRect:eu,draggingNodeRect:ex,over:eh.current.over,overlayNodeRect:em.rect,scrollableAncestors:ew,scrollableAncestorRects:e_,windowRect:eb}),ek=eo?SZ(eo,W):null,ej=function(e){let[r,s]=(0,V.useState)(null),n=(0,V.useRef)(e),i=(0,V.useCallback)(e=>{let r=kv(e.target);r&&s(e=>e?(e.set(r,kw(r)),new Map(e)):null)},[]);return(0,V.useEffect)(()=>{let r=n.current;if(e!==r){a(r);let o=e.map(e=>{let r=kv(e);return r?(r.addEventListener("scroll",i,{passive:!0}),[r,kw(r)]):null}).filter(e=>null!=e);s(o.length?new Map(o):null),n.current=e}return()=>{a(e),a(r)};function a(e){e.forEach(e=>{let r=kv(e);null==r||r.removeEventListener("scroll",i)})}},[i,e]),(0,V.useMemo)(()=>e.length?r?Array.from(r.values()).reduce((e,r)=>SZ(e,r),ks):kj(e):ks,[e,r])}(ew),eC=kK(ej),eN=kK(ej,[ed]),eE=SZ(eS,eC),eD=ex?kh(ex,eS):null,eT=K&&eD?S({active:K,collisionRect:eD,droppableRects:es,droppableContainers:et,pointerCoordinates:ek}):null,eR=kl(eT,"id"),[eA,eM]=(0,V.useState)(null),eI=(l=ev?eS:SZ(eS,eN),c=null!=(i=null==eA?void 0:eA.rect)?i:null,{...l,scaleX:c&&ed?c.width/ed.width:1,scaleY:c&&ed?c.height/ed.height:1}),eP=(0,V.useRef)(null),eF=(0,V.useCallback)((e,r)=>{let{sensor:s,options:n}=r;if(null==X.current)return;let i=z.get(X.current);if(!i)return;let a=e.nativeEvent,o=new s({active:X.current,activeNode:i,event:a,options:n,context:eh,onAbort(e){if(!z.get(e))return;let{onDragAbort:r}=Q.current,s={id:e};null==r||r(s),D({type:"onDragAbort",event:s})},onPending(e,r,s,n){if(!z.get(e))return;let{onDragPending:i}=Q.current,a={id:e,constraint:r,initialCoordinates:s,offset:n};null==i||i(a),D({type:"onDragPending",event:a})},onStart(e){let r=X.current;if(null==r)return;let s=z.get(r);if(!s)return;let{onDragStart:n}=Q.current,i={activatorEvent:a,active:{id:r,data:s.data,rect:q}};(0,ep.unstable_batchedUpdates)(()=>{null==n||n(i),I($.Initializing),E({type:A.DragStart,initialCoordinates:e,active:r}),D({type:"onDragStart",event:i}),G(eP.current),Z(a)})},onMove(e){E({type:A.DragMove,coordinates:e})},onEnd:l(A.DragEnd),onCancel:l(A.DragCancel)});function l(e){return async function(){let{active:r,collisions:s,over:n,scrollAdjustedTranslate:i}=eh.current,o=null;if(r&&i){let{cancelDrop:l}=Q.current;o={activatorEvent:a,active:r,collisions:s,delta:i,over:n},e===A.DragEnd&&"function"==typeof l&&await Promise.resolve(l(o))&&(e=A.DragCancel)}X.current=null,(0,ep.unstable_batchedUpdates)(()=>{E({type:e}),I($.Uninitialized),eM(null),G(null),Z(null),eP.current=null;let r=e===A.DragEnd?"onDragEnd":"onDragCancel";if(o){let e=Q.current[r];null==e||e(o),D({type:r,event:o})}})}}eP.current=o},[z]),eL=(0,V.useCallback)((e,r)=>(s,n)=>{let i=s.nativeEvent,a=z.get(n);null!==X.current||!a||i.dndKit||i.defaultPrevented||!0===e(s,r.options,{active:a})&&(i.dndKit={capturedBy:r.sensor},X.current=n,eF(s,r))},[z,eF]),eO=(0,V.useMemo)(()=>_.reduce((e,r)=>{let{sensor:s}=r;return[...e,...s.activators.map(e=>({eventName:e.eventName,handler:eL(e.handler,r)}))]},[]),[_,eL]);(0,V.useEffect)(()=>{if(!SP)return;let e=_.map(e=>{let{sensor:r}=e;return null==r.setup?void 0:r.setup()});return()=>{for(let r of e)null==r||r()}},_.map(e=>{let{sensor:r}=e;return r})),SH(()=>{ed&&R===$.Initializing&&I($.Initialized)},[ed,R]),(0,V.useEffect)(()=>{let{onDragMove:e}=Q.current,{active:r,activatorEvent:s,collisions:n,over:i}=eh.current;if(!r||!s)return;let a={active:r,activatorEvent:s,collisions:n,delta:{x:eE.x,y:eE.y},over:i};(0,ep.unstable_batchedUpdates)(()=>{null==e||e(a),D({type:"onDragMove",event:a})})},[eE.x,eE.y]),(0,V.useEffect)(()=>{let{active:e,activatorEvent:r,collisions:s,droppableContainers:n,scrollAdjustedTranslate:i}=eh.current;if(!e||null==X.current||!r||!i)return;let{onDragOver:a}=Q.current,o=n.get(eR),l=o&&o.rect.current?{id:o.id,rect:o.rect.current,data:o.data,disabled:o.disabled}:null,c={active:e,activatorEvent:r,collisions:s,delta:{x:i.x,y:i.y},over:l};(0,ep.unstable_batchedUpdates)(()=>{eM(l),null==a||a(c),D({type:"onDragOver",event:c})})},[eR]),SH(()=>{eh.current={activatorEvent:J,active:K,activeNode:ea,collisionRect:eD,collisions:eT,droppableRects:es,draggableNodes:z,draggingNode:eg,draggingNodeRect:ex,droppableContainers:H,over:eA,scrollableAncestors:ew,scrollAdjustedTranslate:eE},q.current={initial:ex,translated:eD}},[K,ea,eT,eD,z,eg,ex,es,H,eA,ew,eE]),function(e){let r,{acceleration:s,activator:n=L.Pointer,canScroll:i,draggingRect:a,enabled:o,interval:l=5,order:c=O.TreeOrder,pointerCoordinates:d,scrollableAncestors:u,scrollableAncestorRects:h,delta:f,threshold:p}=e,m=function(e){let{delta:r,disabled:s}=e,n=SX(r);return Sq(e=>{if(s||!n||!e)return kz;let i={x:Math.sign(r.x-n.x),y:Math.sign(r.y-n.y)};return{x:{[M.Backward]:e.x[M.Backward]||-1===i.x,[M.Forward]:e.x[M.Forward]||1===i.x},y:{[M.Backward]:e.y[M.Backward]||-1===i.y,[M.Forward]:e.y[M.Forward]||1===i.y}}},[s,r,n])}({delta:f,disabled:!o}),[g,x]=(r=(0,V.useRef)(null),[(0,V.useCallback)((e,s)=>{r.current=setInterval(e,s)},[]),(0,V.useCallback)(()=>{null!==r.current&&(clearInterval(r.current),r.current=null)},[])]),v=(0,V.useRef)({x:0,y:0}),y=(0,V.useRef)({x:0,y:0}),b=(0,V.useMemo)(()=>{switch(n){case L.Pointer:return d?{top:d.y,bottom:d.y,left:d.x,right:d.x}:null;case L.DraggableRect:return a}},[n,a,d]),w=(0,V.useRef)(null),_=(0,V.useCallback)(()=>{let e=w.current;if(!e)return;let r=v.current.x*y.current.x,s=v.current.y*y.current.y;e.scrollBy(r,s)},[]),S=(0,V.useMemo)(()=>c===O.TreeOrder?[...u].reverse():u,[c,u]);(0,V.useEffect)(()=>{if(!o||!u.length||!b)return void x();for(let e of S){if((null==i?void 0:i(e))===!1)continue;let r=h[u.indexOf(e)];if(!r)continue;let{direction:n,speed:a}=function(e,r,s,n,i){let{top:a,left:o,right:l,bottom:c}=s;void 0===n&&(n=10),void 0===i&&(i=kk);let{isTop:d,isBottom:u,isLeft:h,isRight:f}=kS(e),p={x:0,y:0},m={x:0,y:0},g={height:r.height*i.y,width:r.width*i.x};return!d&&a<=r.top+g.height?(p.y=M.Backward,m.y=n*Math.abs((r.top+g.height-a)/g.height)):!u&&c>=r.bottom-g.height&&(p.y=M.Forward,m.y=n*Math.abs((r.bottom-g.height-c)/g.height)),!f&&l>=r.right-g.width?(p.x=M.Forward,m.x=n*Math.abs((r.right-g.width-l)/g.width)):!h&&o<=r.left+g.width&&(p.x=M.Backward,m.x=n*Math.abs((r.left+g.width-o)/g.width)),{direction:p,speed:m}}(e,r,b,s,p);for(let e of["x","y"])m[e][n[e]]||(a[e]=0,n[e]=0);if(a.x>0||a.y>0){x(),w.current=e,g(_,l),v.current=a,y.current=n;return}}v.current={x:0,y:0},y.current={x:0,y:0},x()},[s,_,i,x,o,l,JSON.stringify(b),JSON.stringify(m),g,u,S,h,JSON.stringify(p)])}({...el,delta:W,draggingRect:eD,pointerCoordinates:ek,scrollableAncestors:ew,scrollableAncestorRects:e_});let eB=(0,V.useMemo)(()=>({active:K,activeNode:ea,activeNodeRect:ed,activatorEvent:J,collisions:eT,containerNodeRect:eu,dragOverlay:em,draggableNodes:z,droppableContainers:H,droppableRects:es,over:eA,measureDroppableContainers:en,scrollableAncestors:ew,scrollableAncestorRects:e_,measuringConfiguration:er,measuringScheduled:ei,windowRect:eb}),[K,ea,ed,J,eT,eu,em,z,H,es,eA,en,ew,e_,er,ei,eb]),ez=(0,V.useMemo)(()=>({activatorEvent:J,activators:eO,active:K,activeNodeRect:ed,ariaDescribedById:{draggable:ee},dispatch:E,draggableNodes:z,over:eA,measureDroppableContainers:en}),[J,eO,K,ed,E,ee,z,eA,en]);return V.default.createElement(S7.Provider,{value:T},V.default.createElement(k2.Provider,{value:ez},V.default.createElement(k5.Provider,{value:eB},V.default.createElement(k7.Provider,{value:eI},w)),V.default.createElement(k6,{disabled:(null==y?void 0:y.restoreFocus)===!1})),V.default.createElement(ke,{...y,hiddenTextDescribedById:ee}))}),k9=(0,V.createContext)(null),je="button",jt={timeout:25},jr={position:"fixed",touchAction:"none"},js=e=>S0(e)?"transform 250ms ease":void 0;function jn(e,r,s){let n=e.slice();return n.splice(s<0?n.length+s:s,0,n.splice(r,1)[0]),n}function ji(e){return null!==e&&e>=0}(e,r)=>{let{as:s,activatorEvent:n,adjustScale:i,children:a,className:o,rect:l,style:c,transform:d,transition:u=js}=e;if(!l)return null;let h=i?d:{...d,scaleX:1,scaleY:1},f={...jr,width:l.width,height:l.height,top:l.top,left:l.left,transform:S2.Transform.toString(h),transformOrigin:i&&n?function(e,r){let s=S1(e);if(!s)return"0 0";let n={x:(s.x-r.left)/r.width*100,y:(s.y-r.top)/r.height*100};return n.x+"% "+n.y+"%"}(n,l):void 0,transition:"function"==typeof u?u(n):u,...c};return V.default.createElement(s,{className:o,style:f,ref:r},a)},v={styles:{active:{opacity:"0"}}};let ja=e=>{let{rects:r,activeIndex:s,overIndex:n,index:i}=e,a=jn(r,n,s),o=r[i],l=a[i];return l&&o?{x:l.left-o.left,y:l.top-o.top,scaleX:l.width/o.width,scaleY:l.height/o.height}:null},jo={scaleX:1,scaleY:1},jl=e=>{var r,s,n,i;let a,o,l,{activeIndex:c,activeNodeRect:d,index:u,rects:h,overIndex:f}=e,p=null!=(r=h[c])?r:d;if(!p)return null;if(u===c){let e=h[f];return e?{x:0,y:c<f?e.top+e.height-(p.top+p.height):e.top-p.top,...jo}:null}let m=(s=h,n=u,i=c,a=s[n],o=s[n-1],l=s[n+1],a?i<n?o?a.top-(o.top+o.height):l?l.top-(a.top+a.height):0:l?l.top-(a.top+a.height):o?a.top-(o.top+o.height):0:0);return u>c&&u<=f?{x:0,y:-p.height-m,...jo}:u<c&&u>=f?{x:0,y:p.height+m,...jo}:{x:0,y:0,...jo}},jc="Sortable",jd=V.default.createContext({activeIndex:-1,containerId:jc,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:ja,disabled:{draggable:!1,droppable:!1}});function ju(e){let{children:r,id:s,items:n,strategy:i=ja,disabled:a=!1}=e,{active:o,dragOverlay:l,droppableRects:c,over:d,measureDroppableContainers:u}=(0,V.useContext)(k5),h=SG(jc,s),f=null!==l.rect,p=(0,V.useMemo)(()=>n.map(e=>"object"==typeof e&&"id"in e?e.id:e),[n]),m=null!=o,g=o?p.indexOf(o.id):-1,x=d?p.indexOf(d.id):-1,v=(0,V.useRef)(p),y=!function(e,r){if(e===r)return!0;if(e.length!==r.length)return!1;for(let s=0;s<e.length;s++)if(e[s]!==r[s])return!1;return!0}(p,v.current),b=-1!==x&&-1===g||y,w="boolean"==typeof a?{draggable:a,droppable:a}:a;SH(()=>{y&&m&&u(p)},[y,p,m,u]),(0,V.useEffect)(()=>{v.current=p},[p]);let _=(0,V.useMemo)(()=>({activeIndex:g,containerId:h,disabled:w,disableTransforms:b,items:p,overIndex:x,useDragOverlay:f,sortedRects:p.reduce((e,r,s)=>{let n=c.get(r);return n&&(e[s]=n),e},Array(p.length)),strategy:i}),[g,h,w.draggable,w.droppable,b,p,x,c,f,i]);return V.default.createElement(jd.Provider,{value:_},r)}let jh=e=>{let{id:r,items:s,activeIndex:n,overIndex:i}=e;return jn(s,n,i).indexOf(r)},jf=e=>{let{containerId:r,isSorting:s,wasDragging:n,index:i,items:a,newIndex:o,previousItems:l,previousContainerId:c,transition:d}=e;return!!d&&!!n&&(l===a||i!==o)&&(!!s||o!==i&&r===c)},jp={duration:200,easing:"ease"},jm="transform",jg=S2.Transition.toString({property:jm,duration:0,easing:"linear"}),jx={roleDescription:"sortable"};function jv(e){if(!e)return!1;let r=e.data.current;return!!r&&"sortable"in r&&"object"==typeof r.sortable&&"containerId"in r.sortable&&"items"in r.sortable&&"index"in r.sortable}let jy=[P.Down,P.Right,P.Up,P.Left],jb=(e,r)=>{let{context:{active:s,collisionRect:n,droppableRects:i,droppableContainers:a,over:o,scrollableAncestors:l}}=r;if(jy.includes(e.code)){if(e.preventDefault(),!s||!n)return;let r=[];a.getEnabled().forEach(s=>{if(!s||null!=s&&s.disabled)return;let a=i.get(s.id);if(a)switch(e.code){case P.Down:n.top<a.top&&r.push(s);break;case P.Up:n.top>a.top&&r.push(s);break;case P.Left:n.left>a.left&&r.push(s);break;case P.Right:n.left<a.left&&r.push(s)}});let u=(e=>{let{collisionRect:r,droppableRects:s,droppableContainers:n}=e,i=ko(r),a=[];for(let e of n){let{id:r}=e,n=s.get(r);if(n){let s=ko(n),o=Number((i.reduce((e,r,n)=>e+kn(s[n],r),0)/4).toFixed(4));a.push({id:r,data:{droppableContainer:e,value:o}})}}return a.sort(ki)})({active:s,collisionRect:n,droppableRects:i,droppableContainers:r,pointerCoordinates:null}),h=kl(u,"id");if(h===(null==o?void 0:o.id)&&u.length>1&&(h=u[1].id),null!=h){let e=a.get(s.id),r=a.get(h),o=r?i.get(r.id):null,u=null==r?void 0:r.node.current;if(u&&o&&e&&r){var c,d;let s=kg(u).some((e,r)=>l[r]!==e),i=jw(e,r),a=(c=e,d=r,!!jv(c)&&!!jv(d)&&!!jw(c,d)&&c.data.current.sortable.index<d.data.current.sortable.index),h=s||!i?{x:0,y:0}:{x:a?n.width-o.width:0,y:a?n.height-o.height:0},f={x:o.left,y:o.top};return h.x&&h.y?f:SQ(f,h)}}}};function jw(e,r){return!!jv(e)&&!!jv(r)&&e.data.current.sortable.containerId===r.data.current.sortable.containerId}function j_({executor:e,executorMode:r,locateQuery:s=null,locateMatch:n=!1,keyboardSelected:i=!1,isOpen:a,onOpenChange:o,onStart:l,onStop:c,onUpdate:d,onDelete:u,onProcessFinished:h,deliveryNotice:f}){let p,m,g,x,v,y,b,[w,_]=(0,V.useState)(!1),[S,k]=(0,V.useState)(e.currentProcessId??e.lastProcessId),j=(0,V.useRef)(!1),C=(0,V.useRef)(e.currentProcessId),[N,E]=(0,V.useState)(null),D=(0,V.useRef)(null);(0,V.useEffect)(()=>()=>{D.current&&clearTimeout(D.current)},[]);let{attributes:T,listeners:R,setNodeRef:M,transform:I,transition:P,isDragging:F}=function(e){var r,s,n,i;let{animateLayoutChanges:a=jf,attributes:o,disabled:l,data:c,getNewIndex:d=jh,id:u,strategy:h,resizeObserverConfig:f,transition:p=jp}=e,{items:m,containerId:g,activeIndex:x,disabled:v,disableTransforms:y,sortedRects:b,overIndex:w,useDragOverlay:_,strategy:S}=(0,V.useContext)(jd),k=(r=l,s=v,"boolean"==typeof r?{draggable:r,droppable:!1}:{draggable:null!=(n=null==r?void 0:r.draggable)?n:s.draggable,droppable:null!=(i=null==r?void 0:r.droppable)?i:s.droppable}),j=m.indexOf(u),C=(0,V.useMemo)(()=>({sortable:{containerId:g,index:j,items:m},...c}),[g,c,j,m]),N=(0,V.useMemo)(()=>m.slice(m.indexOf(u)),[m,u]),{rect:E,node:D,isOver:T,setNodeRef:R}=function(e){let{data:r,disabled:s=!1,id:n,resizeObserverConfig:i}=e,a=SG("Droppable"),{active:o,dispatch:l,over:c,measureDroppableContainers:d}=(0,V.useContext)(k2),u=(0,V.useRef)({disabled:s}),h=(0,V.useRef)(!1),f=(0,V.useRef)(null),p=(0,V.useRef)(null),{disabled:m,updateMeasurementsFor:g,timeout:x}={...jt,...i},v=SV(null!=g?g:n),y=kH({callback:(0,V.useCallback)(()=>{if(!h.current){h.current=!0;return}null!=p.current&&clearTimeout(p.current),p.current=setTimeout(()=>{d(Array.isArray(v.current)?v.current:[v.current]),p.current=null},x)},[x]),disabled:m||!o}),[b,w]=SK((0,V.useCallback)((e,r)=>{y&&(r&&(y.unobserve(r),h.current=!1),e&&y.observe(e))},[y])),_=SV(r);return(0,V.useEffect)(()=>{y&&b.current&&(y.disconnect(),h.current=!1,y.observe(b.current))},[b,y]),(0,V.useEffect)(()=>(l({type:A.RegisterDroppable,element:{id:n,key:a,disabled:s,node:b,rect:f,data:_}}),()=>l({type:A.UnregisterDroppable,key:a,id:n})),[n]),(0,V.useEffect)(()=>{s!==u.current.disabled&&(l({type:A.SetDroppableDisabled,id:n,key:a,disabled:s}),u.current.disabled=s)},[n,a,s,l]),{active:o,rect:f,isOver:(null==c?void 0:c.id)===n,node:b,over:c,setNodeRef:w}}({id:u,data:C,disabled:k.droppable,resizeObserverConfig:{updateMeasurementsFor:N,...f}}),{active:M,activatorEvent:I,activeNodeRect:P,attributes:F,setNodeRef:L,listeners:O,isDragging:B,over:z,setActivatorNodeRef:$,transform:W}=function(e){let{id:r,data:s,disabled:n=!1,attributes:i}=e,a=SG("Draggable"),{activators:o,activatorEvent:l,active:c,activeNodeRect:d,ariaDescribedById:u,draggableNodes:h,over:f}=(0,V.useContext)(k2),{role:p=je,roleDescription:m="draggable",tabIndex:g=0}=null!=i?i:{},x=(null==c?void 0:c.id)===r,v=(0,V.useContext)(x?k7:k9),[y,b]=SK(),[w,_]=SK(),S=(0,V.useMemo)(()=>o.reduce((e,s)=>{let{eventName:n,handler:i}=s;return e[n]=e=>{i(e,r)},e},{}),[o,r]),k=SV(s);return SH(()=>(h.set(r,{id:r,key:a,node:y,activatorNode:w,data:k}),()=>{let e=h.get(r);e&&e.key===a&&h.delete(r)}),[h,r]),{active:c,activatorEvent:l,activeNodeRect:d,attributes:(0,V.useMemo)(()=>({role:p,tabIndex:g,"aria-disabled":n,"aria-pressed":!!x&&p===je||void 0,"aria-roledescription":m,"aria-describedby":u.draggable}),[n,p,g,x,m,u.draggable]),isDragging:x,listeners:n?void 0:S,node:y,over:f,setNodeRef:b,setActivatorNodeRef:_,transform:v}}({id:u,data:C,attributes:{...jx,...o},disabled:k.draggable}),H=function(){for(var e=arguments.length,r=Array(e),s=0;s<e;s++)r[s]=arguments[s];return(0,V.useMemo)(()=>e=>{r.forEach(r=>r(e))},r)}(R,L),U=!!M,q=U&&!y&&ji(x)&&ji(w),K=!_&&B,X=K&&q?W:null,Y=q?null!=X?X:(null!=h?h:S)({rects:b,activeNodeRect:P,activeIndex:x,overIndex:w,index:j}):null,G=ji(x)&&ji(w)?d({id:u,items:m,activeIndex:x,overIndex:w}):j,J=null==M?void 0:M.id,Z=(0,V.useRef)({activeId:J,items:m,newIndex:G,containerId:g}),Q=m!==Z.current.items,ee=a({active:M,containerId:g,isDragging:B,isSorting:U,id:u,index:j,items:m,newIndex:Z.current.newIndex,previousItems:Z.current.items,previousContainerId:Z.current.containerId,transition:p,wasDragging:null!=Z.current.activeId}),et=function(e){let{disabled:r,index:s,node:n,rect:i}=e,[a,o]=(0,V.useState)(null),l=(0,V.useRef)(s);return SH(()=>{if(!r&&s!==l.current&&n.current){let e=i.current;if(e){let r=kp(n.current,{ignoreTransform:!0}),s={x:e.left-r.left,y:e.top-r.top,scaleX:e.width/r.width,scaleY:e.height/r.height};(s.x||s.y)&&o(s)}}s!==l.current&&(l.current=s)},[r,s,n,i]),(0,V.useEffect)(()=>{a&&o(null)},[a]),a}({disabled:!ee,index:j,node:D,rect:E});return(0,V.useEffect)(()=>{U&&Z.current.newIndex!==G&&(Z.current.newIndex=G),g!==Z.current.containerId&&(Z.current.containerId=g),m!==Z.current.items&&(Z.current.items=m)},[U,G,g,m]),(0,V.useEffect)(()=>{if(J===Z.current.activeId)return;if(null!=J&&null==Z.current.activeId){Z.current.activeId=J;return}let e=setTimeout(()=>{Z.current.activeId=J},50);return()=>clearTimeout(e)},[J]),{active:M,activeIndex:x,attributes:F,data:C,rect:E,index:j,newIndex:G,items:m,isOver:T,isSorting:U,isDragging:B,listeners:O,node:D,overIndex:w,over:z,setNodeRef:H,setActivatorNodeRef:$,setDroppableNodeRef:R,setDraggableNodeRef:L,transform:null!=et?et:Y,transition:et||Q&&Z.current.newIndex===j?jg:(!K||S0(I))&&p&&(U||ee)?S2.Transition.toString({...p,property:jm}):void 0}}({id:e.id}),L={transform:S2.Translate.toString(I),transition:P,zIndex:F?50:void 0,position:F?"relative":void 0,opacity:F?1:void 0},{logs:O,status:B,exitCode:z,isPty:$,replayingHistory:W,sendInput:H,sendResize:q}=(p=function(){let e=(0,V.useContext)(SM);if(!e)throw Error("useExecutorLogsStore must be used within ExecutorLogsProvider");return e}(),m=(0,V.useCallback)(e=>{if(!S)return()=>{};p.subscribeProcess(S);let r=p.onProcessChange(S,e);return()=>{r(),p.unsubscribeProcess(S)}},[S,r,p]),g=(0,V.useCallback)(()=>S?p.getProcessState(S):null,[S,p]),x=(0,V.useSyncExternalStore)(m,g,g),v=(0,V.useCallback)(()=>{},[]),y=(0,V.useCallback)(e=>{S&&p.sendInput(S,e)},[S,p]),b=(0,V.useCallback)((e,r)=>{S&&p.sendResize(S,e,r)},[S,p]),{logs:x?.logs??[],status:x?.status??"closed",exitCode:x?.exitCode??null,isPty:x?.isPty??!1,replayingHistory:x?.replayingHistory??!0,clearLogs:v,sendInput:y,sendResize:b});(0,V.useEffect)(()=>{let r=C.current;C.current=e.currentProcessId,e.currentProcessId&&e.currentProcessId!==r&&(k(e.currentProcessId),j.current=!1,o(!0))},[e.currentProcessId,o]),(0,V.useEffect)(()=>{e.currentProcessId||e.lastProcessId&&k(r=>r??e.lastProcessId)},[e.currentProcessId,e.lastProcessId]),(0,V.useEffect)(()=>{"closed"!==B||null===z||j.current||(j.current=!0,h(S))},[B,z,S,h]);let K=()=>{D.current=setTimeout(()=>{D.current=null,E(null)},800)},X=async()=>{if(!N){E("start"),console.log(`[ExecutorItem] Starting executor ${e.id}`),j.current=!1;try{let e=await l();console.log(`[ExecutorItem] Got processId: ${e}`),e&&(k(e),o(!0))}finally{K()}}},Y=async()=>{if(!N){E("stop");try{await c(S||void 0)}finally{K()}}},G=e.isRunning,J=e.isDisabled,Z=e.lastStartedAt?new Date(e.lastStartedAt).toLocaleString(void 0,{dateStyle:"short",timeStyle:"short"}):null;return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(xM,{open:a,onOpenChange:o,children:(0,U.jsxs)("div",{ref:M,style:L,"data-locate-id":e.id,className:(0,e1.cn)("border rounded-lg",F&&"shadow-lg bg-background",null!==s&&!n&&"opacity-40",null!==s&&n&&"bg-muted/50",i&&"border-primary/60"),children:[(0,U.jsx)(xI,{asChild:!0,children:(0,U.jsxs)("div",{className:"group flex items-center justify-between p-3 cursor-pointer hover:bg-muted/50",children:[(0,U.jsxs)("div",{className:"flex items-center gap-2",children:[(0,U.jsx)("button",{type:"button",className:"cursor-grab touch-none text-muted-foreground hover:text-foreground",...T,...R,onClick:e=>e.stopPropagation(),children:(0,U.jsx)(ut,{className:"h-4 w-4"})}),a?(0,U.jsx)(aa,{className:"h-4 w-4"}):(0,U.jsx)(i2,{className:"h-4 w-4"}),(0,U.jsx)("span",{className:(0,e1.cn)("font-medium",J&&"text-muted-foreground line-through"),children:null!==s&&n?(0,U.jsx)(dY,{text:e.name,query:s}):e.name}),J?(0,U.jsxs)(rG,{variant:"outline",className:"text-muted-foreground border-muted-foreground/40 gap-1",children:[(0,U.jsx)(xL,{className:"h-3 w-3"}),"Disabled"]}):(0,U.jsx)(rG,{variant:G?"default":"secondary",className:(0,e1.cn)(G&&"bg-green-600 hover:bg-green-600"),children:G?"Running":null!==z?0===z?"Completed":"Failed":"Stopped"})]}),(0,U.jsxs)("div",{className:"flex items-center gap-2",onClick:e=>e.stopPropagation(),children:[Z&&(0,U.jsxs)("span",{className:"text-xs text-muted-foreground opacity-0 group-hover:opacity-100 transition-opacity",title:new Date(e.lastStartedAt).toLocaleString(),children:["Last run: ",Z]}),G?(0,U.jsxs)(a$.Button,{size:"sm",variant:"destructive",onClick:Y,disabled:null!==N,"aria-busy":"stop"===N,"data-locate-action":!0,className:"w-20 border border-destructive",children:["stop"===N?(0,U.jsx)(aP,{className:"h-3 w-3 mr-1 animate-spin"}):(0,U.jsx)(ce,{className:"h-3 w-3 mr-1"}),"Stop"]}):(0,U.jsxs)(a$.Button,{size:"sm",onClick:X,disabled:J||null!==N,"aria-busy":"start"===N,title:J?"Executor is disabled":void 0,"data-locate-action":!0,className:"w-20",children:["start"===N?(0,U.jsx)(aP,{className:"h-3 w-3 mr-1 animate-spin"}):(0,U.jsx)(dw,{className:"h-3 w-3 mr-1"}),"Start"]}),(0,U.jsxs)(i3,{children:[(0,U.jsx)(i4,{asChild:!0,children:(0,U.jsx)(a$.Button,{size:"icon",variant:"ghost",className:"h-8 w-8",children:(0,U.jsx)(xF,{className:"h-4 w-4"})})}),(0,U.jsxs)(i6,{align:"end",children:[(0,U.jsxs)(i7,{onClick:()=>_(!0),children:[(0,U.jsx)(lT,{className:"h-4 w-4 mr-2"}),"Edit"]}),(0,U.jsx)(i7,{onClick:()=>d({target:r??"local",disabled:!J}),children:J?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(os,{className:"h-4 w-4 mr-2"}),"Enable"]}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(xL,{className:"h-4 w-4 mr-2"}),"Disable"]})}),(0,U.jsxs)(i7,{onClick:u,className:"text-destructive",children:[(0,U.jsx)(ok,{className:"h-4 w-4 mr-2"}),"Delete"]})]})]})]})]})}),f&&(0,U.jsx)("div",{className:"px-3 pb-3",children:f}),(0,U.jsx)(xP,{children:(0,U.jsxs)("div",{className:"px-3 pb-3",children:[(0,U.jsx)("div",{className:"text-xs text-muted-foreground mb-2 font-mono",children:"prompt"===e.executor_type?`${e.prompt_provider??"claude"} → ${e.command}`:`$ ${e.command}`}),(0,U.jsx)(SD,{logs:O,isPty:$,onInput:H,onResize:q,muteInput:W,processId:S,executorId:e.id,target:r??"local",status:B,exitCode:z})]})})]})}),(0,U.jsx)(SR,{open:w,onOpenChange:_,executor:e,onSubmit:async e=>{await d(e)}})]})}let jS=[],jk=(e,r)=>`${e}:${r}`;function jj(e,r){if("executor:started"===r.type){let s=jk(r.executorId,r.target??"local");if(!e.has(s))return e;let n=new Map(e);return n.delete(s),n}let{delivery:s}=r,n=jk(s.executorId,s.remoteServerId),i=new Map(e);return"retrying"===s.state||"gave_up"===s.state?i.set(n,s):i.delete(n),i}let jC=new Map;function jN(e){let[r,s]=(0,V.useState)(()=>({projectId:e,deliveries:new Map})),n=(0,V.useRef)(null),i=(0,V.useRef)(0),a=(0,V.useCallback)(e=>{let r=++i.current;n.current=[],aC.api.getExecutorDeliveries(e).then(a=>{if(r!==i.current)return;let o=n.current??[];n.current=null;let l=new Map(a.map(e=>[jk(e.executorId,e.remoteServerId),e]));for(let e of o)l=jj(l,e);s({projectId:e,deliveries:l})}).catch(e=>{r===i.current&&(n.current=null),console.warn("[useExecutorDeliveries] load failed:",e)})},[]),o=(0,V.useCallback)(()=>{i.current++,n.current=null},[]);return(0,V.useEffect)(()=>{if(e)return a(e),o},[e,a,o]),(0,aF.useGlobalEventStream)(r=>{e&&(r.type===aF.STREAM_RECONNECTED_EVENT?a(e):r.projectId!==e||("executor:delivery"===r.type||"executor:started"===r.type)&&(n.current?.push(r),s(s=>({projectId:e,deliveries:jj(s.projectId===e?s.deliveries:jC,r)}))))}),r.projectId===e?r.deliveries:jC}function jE({delivery:e,onRetry:r,showExecutorName:s=!1,compact:n=!1,className:i}){let a,o,l=xo(),c=l?.remotes.find(r=>r.remote_server_id===e.remoteServerId)?.server_name??"the remote",d="retrying"===e.state,[u,h]=(0,V.useState)(!1),f=s&&e.executorName?`"${e.executorName}"`:"This start",p=function(e,r){switch(e.reason){case"offline":return`${r} is offline`;case"connection_closed":return"the connection dropped";case"timeout":return"no response within 30s";default:return e.error??"unknown error"}}(e,c);if(d){let r=null===e.nextAttemptAt?`waiting for ${c} to reconnect`:"trying again about every 30s";a=`${f} couldn't reach ${c} (${p}). Retrying automatically — attempt ${e.attempts}, ${r}.`,o=n?null:`Retries reuse the same start, so it won't run twice (unless ${c}'s worker restarts meanwhile). Gives up at ${new Date(e.deadlineAt).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"})}.`}else if(e.mayHaveRun){let r=Math.round((e.deadlineAt-e.firstSentAt)/6e4);a=`${f} couldn't reach ${c} for ${r} minutes (${e.attempts} attempts; ${p}).`,o=`It most likely did not run, but it may have — check on ${c} before running it again.`}else{let r=Math.round((e.deadlineAt-e.firstSentAt)/6e4);a=`${f} couldn't reach ${c} for ${r} minutes (${p}).`,o=`It never reached ${c}, so it did not run.`}let m=async()=>{if(!u){h(!0);try{await r()}finally{h(!1)}}};return(0,U.jsxs)("div",{role:"status","data-testid":"executor-delivery-notice",className:(0,e1.cn)("flex items-start gap-2 rounded-md border px-3 py-2 text-xs",d?"border-primary/30 bg-primary/5":"border-amber-500/40 bg-amber-500/10",i),children:[d?(0,U.jsx)(m_,{className:"h-3.5 w-3.5 shrink-0 self-center animate-spin text-primary/70"}):(0,U.jsx)(ou,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-amber-500"}),(0,U.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,U.jsx)("div",{className:"text-foreground",children:a}),o&&(0,U.jsx)("div",{className:"mt-0.5 text-muted-foreground",children:o})]}),(0,U.jsxs)(a$.Button,{size:"sm",variant:"outline",className:"h-7 shrink-0 self-center text-xs",onClick:m,disabled:u,children:[u&&(0,U.jsx)(aP,{className:"mr-1 h-3 w-3 animate-spin"}),d?"Retry now":"Run again"]})]})}function jD({targets:e,activeTarget:r,onTargetChange:s,onAddRemote:n,disabled:i}){if(e.length<=2)return(0,U.jsx)("div",{className:"inline-flex items-center rounded-md border bg-muted/50 px-0.5 text-xs",children:e.map(e=>{let n=e.icon;return(0,U.jsxs)("button",{onClick:()=>s(e.id),disabled:i,className:(0,e1.cn)("inline-flex items-center gap-1 rounded-sm px-2 py-0.5 transition-colors",r===e.id?"bg-primary text-primary-foreground font-medium shadow-sm":"text-muted-foreground hover:text-foreground",i&&"opacity-50 cursor-not-allowed"),children:[n&&(0,U.jsx)(n,{className:"h-3 w-3"}),e.label]},e.id)})});let a=e.find(e=>e.id===r)??e[0],o=a?.icon;return(0,U.jsxs)(i3,{children:[(0,U.jsx)(i4,{asChild:!0,children:(0,U.jsxs)("button",{disabled:i,className:(0,e1.cn)("inline-flex items-center gap-1 rounded-md border bg-muted/50 px-2 py-0.5 text-xs font-medium transition-colors hover:bg-muted",i&&"opacity-50 cursor-not-allowed"),children:[o&&(0,U.jsx)(o,{className:"h-3 w-3"}),a?.label??"Local",(0,U.jsx)(aa,{className:"h-3 w-3 text-muted-foreground"})]})}),(0,U.jsxs)(i6,{align:"start",children:[(0,U.jsx)(i9,{value:r,onValueChange:s,children:e.map(e=>{let r=e.icon;return(0,U.jsxs)(ae,{value:e.id,className:"text-xs",children:[r&&(0,U.jsx)(r,{className:"h-3 w-3"}),e.label]},e.id)})}),n&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(ar,{}),(0,U.jsxs)(i7,{onClick:n,className:"text-xs",children:[(0,U.jsx)(oS,{className:"h-3 w-3"}),"Add Remote"]})]})]})]})}let jT=new WeakMap,jR=e=>{let{droppableContainers:r,pointerCoordinates:s}=e;if(!s)return(e=>{let{collisionRect:r,droppableRects:s,droppableContainers:n}=e,i=kc(r,r.left,r.top),a=[];for(let e of n){let{id:r}=e,n=s.get(r);if(n){let s=kn(kc(n),i);a.push({id:r,data:{droppableContainer:e,value:s}})}}return a.sort(ki)})(e);let n=[];for(let e of r){let r=e.rect.current;if(!r)continue;let i=r.top,a=r.top+52;s.x>=r.left&&s.x<=r.right&&s.y>=i&&s.y<=a&&n.push({id:e.id,data:{droppableContainer:e}})}if(n.length>0)return n;let i=null;for(let e of r){let r=e.rect.current;if(!r)continue;let n=r.top+26,a=r.left+r.width/2,o=Math.sqrt(Math.pow(s.x-a,2)+Math.pow(s.y-n,2));(!i||o<i.distance)&&(i={id:e.id,distance:o,data:{droppableContainer:e}})}return i?[{id:i.id,data:i.data}]:[]};function jA({projectId:e,selectedBranch:r,project:s,onExecutorModeChange:n,locateActive:i}){let[a,o]=(0,V.useState)(!1),[l,c]=(0,V.useState)(new Set),{remotes:d}=xl(),{region:u}=dJ(),h=[];for(let e of(s?.path&&h.push({id:"local",label:"Local",icon:hW}),d))h.push({id:e.remote_server_id,label:e.server_name,icon:az(e)});let{executors:f,loading:p,createExecutor:m,updateExecutor:g,deleteExecutor:x,startExecutor:v,stopExecutor:y,markProcessFinished:b,reorderExecutors:w}=function(e,r,s){let n=r??"",i=e?`${e}::${n}`:null,[a,o]=(0,V.useState)(()=>new Map),l=(null!==i?a.get(i):void 0)??jS,c=null!==i&&!a.has(i),d=(0,V.useCallback)((e,r)=>{o(s=>new Map(s).set(e,r))},[]),u=(0,V.useRef)(new Map),h=(0,V.useCallback)(e=>{let r=u.current;for(let[s,n]of r)r.set(s,e(n));o(r=>{let s=new Map;for(let[n,i]of r)s.set(n,e(i));return s})},[]),[f,p]=(0,V.useState)(new Map),[m,g]=(0,V.useState)(new Map),x=(0,V.useCallback)(async()=>{if(!e||null===i)return;let r=u.current;r.set(i,[]);try{let s=await aC.api.getExecutors(e,n),a=r.get(i)??[];r.delete(i),d(i,[...s,...a.filter(e=>!s.some(r=>r.id===e.id))])}catch(e){console.error("Failed to fetch executors:",e),r.delete(i),o(e=>e.has(i)?e:new Map(e).set(i,[]))}},[e,n,i,d]),v=(0,V.useCallback)(async()=>{try{let e=await aC.api.getRunningProcesses();console.log(`[useExecutors] fetchRunningProcesses: ${e.length} running`,e.map(e=>`${e.executor_id}/${e.id}/${e.target??"local"}`));let{runningProcesses:r,lastStartedProcess:s}=function(e){let r=new Map,s=new Map;for(let n of e){let e={processId:n.id,target:n.target??"local"},i=r.get(n.executor_id);i?i.push(e):r.set(n.executor_id,[e]),s.set(n.executor_id,e)}return{runningProcesses:r,lastStartedProcess:s}}(e);p(r),g(e=>{let n=function(e,r){let s=new Map;for(let[n,i]of e)r.get(n)?.some(e=>e.processId===i.processId&&e.target===i.target)&&s.set(n,i);return s}(e,r);for(let[e,r]of s)n.set(e,r);return n})}catch(e){console.error("Failed to fetch running processes:",e)}},[]);(0,V.useEffect)(()=>{x()},[x]),(0,V.useEffect)(()=>{e&&v()},[e,v]),(0,V.useEffect)(()=>{let e=()=>{"visible"===document.visibilityState&&v()};return document.addEventListener("visibilitychange",e),()=>document.removeEventListener("visibilitychange",e)},[v]);let y=(0,V.useRef)(new Set);(0,V.useEffect)(()=>{y.current=new Set(l.map(e=>e.id))},[l]),(0,aF.useGlobalEventStream)(r=>{if(("executor:started"===r.type||"executor:stopped"===r.type)&&console.log(`[useExecutors] SSE received: ${r.type} executor=${r.executorId} process=${r.processId} target=${r.target??"local"} project=${r.projectId}`),!e||r.projectId!==e){("executor:started"===r.type||"executor:stopped"===r.type)&&console.log(`[useExecutors] SSE filtered: projectId mismatch (event=${r.projectId}, hook=${e})`);return}if(!y.current.has(r.executorId)){("executor:started"===r.type||"executor:stopped"===r.type)&&console.log(`[useExecutors] SSE filtered: executorId ${r.executorId} not in current group (known: ${Array.from(y.current).join(",")})`);return}"executor:started"===r.type?(console.log("[useExecutors] Processing executor:started, adding to runningProcesses"),p(e=>{let s=e.get(r.executorId)??[];if(s.some(e=>e.processId===r.processId))return e;let n=new Map(e);return n.set(r.executorId,[...s,{processId:r.processId,target:r.target??"local"}]),n}),g(e=>{let s=new Map(e);return s.set(r.executorId,{processId:r.processId,target:r.target??"local"}),s}),h(e=>e.map(e=>{if(e.id!==r.executorId)return e;let s=r.target??"local";return{...e,last_runs:{...e.last_runs??{},[s]:{started_at:new Date().toISOString(),process_id:r.processId}}}}))):"executor:stopped"===r.type&&(console.log("[useExecutors] Processing executor:stopped, removing from runningProcesses"),p(e=>{let s=e.get(r.executorId);if(!s)return e;let n=s.filter(e=>e.processId!==r.processId),i=new Map(e);return 0===n.length?i.delete(r.executorId):i.set(r.executorId,n),i}),g(e=>{let s=e.get(r.executorId);if(!s||s.processId!==r.processId)return e;let n=new Map(e);return n.delete(r.executorId),n}))});let b=(0,V.useCallback)(async r=>{if(!e||null===i)return null;try{let s=await aC.api.createExecutor(e,{...r,branch:n});return u.current.get(i)?.push(s),o(e=>new Map(e).set(i,[...e.get(i)??[],s])),s}catch(e){return console.error("Failed to create executor:",e),null}},[e,n,i]),w=(0,V.useCallback)(async(e,r)=>{try{let s=await aC.api.updateExecutor(e,r);return h(r=>r.map(r=>r.id===e?s:r)),s}catch(e){return console.error("Failed to update executor:",e),xc.toast.error("Failed to update executor",{description:e instanceof Error?e.message:void 0}),null}},[h]),_=(0,V.useCallback)(async e=>{try{await aC.api.deleteExecutor(e),h(r=>r.filter(r=>r.id!==e))}catch(e){console.error("Failed to delete executor:",e)}},[h]),S=(0,V.useCallback)(async(e,r)=>{let n=s??"local",i=r=>{p(s=>{let i=s.get(e)??[];if(i.some(e=>e.processId===r))return s;let a=new Map(s);return a.set(e,[...i,{processId:r,target:n}]),a}),g(s=>{let i=new Map(s);return i.set(e,{processId:r,target:n}),i})};try{let a=await aC.api.startExecutor(e,s,r);return i(a),h(r=>r.map(r=>r.id!==e?r:{...r,last_runs:{...r.last_runs??{},[n]:{started_at:new Date().toISOString(),process_id:a}}})),a}catch(r){console.error("Failed to start executor:",r);let e=function(e){if(!(e instanceof aC.ExecutorProcessRequestError)||409!==e.status)return null;let{code:r,processId:s}=e.body;return"already_running"===r&&"string"==typeof s?s:null}(r);return e?(i(e),xc.toast.info("Executor is already running",{description:"Stop it before starting again."})):r instanceof aC.ExecutorProcessRequestError&&"start_unknown"===r.body.code&&r.body.retrying||(r instanceof aC.ExecutorProcessRequestError&&"retry_ended"===r.body.code?xc.toast.info("Already settled",{description:r.message}):r instanceof aC.ExecutorProcessRequestError&&("starting"===r.body.code||"start_unknown"===r.body.code||"delivery_gave_up"===r.body.code)&&xc.toast.error("Executor not started",{description:r.message})),null}},[s,h]),k=(0,V.useCallback)(async(e,r)=>{let n=f.get(e),i=n?.find(e=>e.target===(s??"local")),a=r||i?.processId;if(a){try{await aC.api.stopProcess(a)}catch(e){if(console.error("Failed to stop executor:",e),!(e instanceof aC.ExecutorProcessRequestError&&404===e.status)){xc.toast.error("Failed to stop executor",{description:`${e instanceof Error?e.message:String(e)}. The process may still be running.`}),v();return}}p(r=>{let s=r.get(e);if(!s)return r;let n=s.filter(e=>e.processId!==a),i=new Map(r);return 0===n.length?i.delete(e):i.set(e,n),i}),g(r=>{let s=r.get(e);if(!s||s.processId!==a)return r;let n=new Map(r);return n.delete(e),n})}},[f,s,v]),j=(0,V.useCallback)((e,r)=>{p(s=>{let n=s.get(e);if(!n)return s;if(r){let i=n.filter(e=>e.processId!==r);if(i.length===n.length)return s;let a=new Map(s);return 0===i.length?a.delete(e):a.set(e,i),a}let i=new Map(s);return i.delete(e),i}),g(s=>{if(!r){if(!s.has(e))return s;let r=new Map(s);return r.delete(e),r}let n=s.get(e);if(!n||n.processId!==r)return s;let i=new Map(s);return i.delete(e),i})},[]),C=(0,V.useCallback)(async r=>{if(e&&null!==i){d(i,r.map(e=>l.find(r=>r.id===e)).filter(e=>void 0!==e));try{await aC.api.reorderExecutors(e,r,n)}catch(e){console.error("Failed to reorder executors:",e),d(i,l)}}},[e,n,i,l,d]);return{executors:l.map(e=>{let r=f.get(e.id),n=s??"local",i=r?.find(e=>e.target===n),a=m.get(e.id),o=a?.target===n?a:void 0,l=e.last_runs?.[n];return{...e,currentProcessId:i?.processId??o?.processId??null,isRunning:!!i,lastProcessId:l?.process_id??null,lastStartedAt:l?.started_at??null,isDisabled:e.disabled_targets.includes(n)}}),loading:c,createExecutor:b,updateExecutor:w,deleteExecutor:_,startExecutor:S,stopExecutor:k,markProcessFinished:j,reorderExecutors:C,refetch:x}}(e,r,s?.executor_mode),_=jN(e),S=!!(i&&f.length>0),k=S&&"right-panel"===u,j=(0,V.useCallback)(e=>{document.querySelector(`[data-locate-id="${CSS.escape(e)}"]`)?.scrollIntoView({block:"nearest"})},[]),C=(0,V.useRef)(null),N=(0,V.useCallback)(e=>{let r=C.current,s=r?.querySelector(`[data-locate-id="${CSS.escape(e)}"]`);if(!r||!s)return;let n=s.getBoundingClientRect(),i=r.getBoundingClientRect(),a=0;if(n.height>i.height?a=n.top-i.top:n.bottom>i.bottom?a=Math.max(0,Math.min(n.bottom+12-i.bottom,n.top-i.top)):n.top<i.top&&(a=n.top-12-i.top),1>Math.abs(a))return;let o=r.scrollTop+a;"function"==typeof r.scrollTo?r.scrollTo({top:o,behavior:"smooth"}):r.scrollTop=o},[]),E=(0,V.useRef)(l);(0,V.useEffect)(()=>{let e=E.current;E.current=l;let r=[...l].filter(r=>!e.has(r));if(r.length>0)return void N(r[r.length-1]);let s=[...e].filter(e=>!l.has(e));s.length>0&&j(s[s.length-1])},[l,N,j]);let D=(0,V.useCallback)(e=>{let r=document.querySelector(`[data-locate-id="${CSS.escape(e)}"]`);r?.scrollIntoView({block:"nearest"});let s=r?.querySelector("[data-locate-action]");s&&function(e){if(!(e instanceof HTMLButtonElement&&e.disabled)){let r=jT.get(e);void 0!==r&&window.clearTimeout(r),e.dataset.pressed="true",jT.set(e,window.setTimeout(()=>{jT.delete(e),delete e.dataset.pressed},160))}e.click()}(s)},[]),T=(0,V.useCallback)(e=>{let r=l.has(e);c(r=>new Set(r).add(e)),r&&N(e)},[l,N]),R=(0,V.useCallback)(e=>{c(r=>{let s=new Set(r);return s.delete(e)||s.add(e),s})},[]),[A,M]=(0,V.useState)(null),I=(0,V.useMemo)(()=>0===f.length?null:A&&f.some(e=>e.id===A)?A:f[0].id,[A,f]),P=dX("executors");dK({id:"executors",label:"Executors",priority:10,getItems:()=>f.map(e=>({id:e.id,text:e.name})),onCommit:e=>D(e.id),onSecondaryCommit:e=>T(e.id)},k);let F=P?.selectedId??null,[L,O]=(0,V.useState)(null);F!==L&&(O(F),null!==F&&M(F)),(0,V.useEffect)(()=>{null!==F&&j(F)},[F,j]);let B=P?P.selectedId:S?I:null,z=(0,V.useMemo)(()=>[...s?.path?["local"]:[],...d.map(e=>e.remote_server_id)],[s?.path,d]),$=s?.executor_mode??"local",W=null!==P;(0,V.useEffect)(()=>{if(!k||W)return;let e=e=>{if(e.defaultPrevented||e.metaKey||e.ctrlKey||e.altKey||e.shiftKey||dz(e.target)||dH(e.target))return;if("ArrowLeft"===e.key||"ArrowRight"===e.key){if(z.length<2||!n)return;e.preventDefault();let r=z.indexOf($);n(z[(r+("ArrowRight"===e.key?1:-1)+z.length)%z.length]);return}if("ArrowDown"===e.key||"ArrowUp"===e.key){e.preventDefault();let r=f.findIndex(e=>e.id===I),s=f[(r+("ArrowDown"===e.key?1:-1)+f.length)%f.length];M(s.id),j(s.id);return}let r=e.target instanceof Element&&null!==e.target.closest("button,a,[role='button']");if(" "===e.key&&I){if(r)return;e.preventDefault(),R(I);return}if("Enter"===e.key&&I){if(r)return;e.preventDefault(),D(I)}};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[k,W,z,$,n,f,I,j,D,R]),(0,V.useEffect)(()=>{if(!k)return;let e=document.activeElement;if(!(e instanceof HTMLElement)||!H.current?.contains(e))return;let r=e.closest("[data-locate-id]");r&&r.getAttribute("data-locate-id")!==B&&e.blur()},[k,B]);let H=(0,V.useRef)(null),q=(0,V.useCallback)(e=>{let r=e.target instanceof Element?e.target.closest("[data-locate-id]"):null,s=r?.getAttribute("data-locate-id");s&&M(s)},[]),K=function(){for(var e=arguments.length,r=Array(e),s=0;s<e;s++)r[s]=arguments[s];return(0,V.useMemo)(()=>[...r].filter(e=>null!=e),[...r])}(kr(kB,{activationConstraint:{distance:8}}),kr(kI,{coordinateGetter:jb}));return e?(0,U.jsx)(SI,{projectId:e,children:(0,U.jsxs)("div",{className:"h-full flex flex-col",children:[(0,U.jsxs)("div",{className:"flex items-center justify-between px-4 py-2 border-b border-border/60 h-10",children:[(0,U.jsxs)("div",{className:"flex items-center gap-2",children:[(0,U.jsxs)("h2",{className:"text-xs font-semibold flex items-center gap-2 text-foreground",children:[(0,U.jsx)(xb,{className:"h-3.5 w-3.5"}),"Executors"]}),h.length>1&&n&&(0,U.jsx)(jD,{targets:h,activeTarget:s?.executor_mode??"local",onTargetChange:n})]}),(0,U.jsxs)(a$.Button,{variant:"ghost",size:"sm",className:"h-7 text-xs",onClick:()=>o(!0),children:[(0,U.jsx)(oS,{className:"h-3 w-3 mr-1"}),"Add"]})]}),(0,U.jsx)("div",{className:"flex-1 overflow-y-auto",ref:C,children:(0,U.jsx)("div",{className:"p-4 space-y-3",ref:H,onPointerDown:q,children:p?(0,U.jsx)("div",{className:"text-center text-muted-foreground py-8",children:"Loading executors..."}):0===f.length?(0,U.jsxs)("div",{className:"text-center text-muted-foreground py-8",children:[(0,U.jsx)("p",{children:"No executors configured"}),(0,U.jsx)("p",{className:"text-sm mt-1",children:'Add an executor to run commands like "npm run dev"'})]}):(0,U.jsx)(k8,{sensors:K,collisionDetection:jR,onDragEnd:e=>{let{active:r,over:s}=e;if(s&&r.id!==s.id){let e=f.findIndex(e=>e.id===r.id),n=f.findIndex(e=>e.id===s.id),i=[...f],[a]=i.splice(e,1);i.splice(n,0,a),w(i.map(e=>e.id))}},children:(0,U.jsx)(ju,{items:f.map(e=>e.id),strategy:jl,children:f.map(e=>{let r;return(0,U.jsx)(j_,{executor:e,executorMode:s?.executor_mode??"local",locateQuery:P?.query??null,locateMatch:P?.matchSet.has(e.id)??!1,keyboardSelected:B===e.id,isOpen:l.has(e.id),onOpenChange:r=>c(s=>{let n=new Set(s);return r?n.add(e.id):n.delete(e.id),n}),onStart:()=>v(e.id),onStop:r=>y(e.id,r||e.currentProcessId||void 0),onUpdate:r=>g(e.id,r),onDelete:()=>x(e.id),onProcessFinished:r=>b(e.id,r),deliveryNotice:(r=_.get(jk(e.id,s?.executor_mode??"local")))?(0,U.jsx)(jE,{delivery:r,onRetry:()=>v(e.id,"retrying"===r.state?r.processId:void 0)}):null},`${e.id}-${s?.executor_mode??"local"}`)})})})})}),(0,U.jsx)(SR,{open:a,onOpenChange:o,onSubmit:async e=>{await m(e)}})]})},`${e??"none"}-${s?.executor_mode??"local"}`):(0,U.jsx)("div",{className:"h-full flex items-center justify-center text-muted-foreground",children:(0,U.jsxs)("div",{className:"text-center",children:[(0,U.jsx)("div",{className:"mx-auto w-10 h-10 rounded-xl bg-muted flex items-center justify-center mb-3",children:(0,U.jsx)(xb,{className:"h-5 w-5 text-muted-foreground/50"})}),(0,U.jsx)("p",{className:"text-sm",children:"Select a project to manage executors"})]})})}let jM=(0,rE.default)("file-symlink",[["path",{d:"M4 11V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2v-3a2 2 0 0 1 2-2h7",key:"huwfnr"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"m10 18 3-3-3-3",key:"18f6ys"}]]);function jI({path:e,className:r}){let[s,n]=(0,V.useState)(!1),i=(0,V.useCallback)(r=>{r.stopPropagation(),navigator.clipboard.writeText(e),n(!0),setTimeout(()=>n(!1),1500)},[e]);return(0,U.jsx)("button",{type:"button",onClick:i,className:(0,e1.cn)("p-0.5 rounded hover:bg-muted-foreground/20 transition-colors",r),title:`Copy path: ${e}`,"aria-label":"Copy path",children:s?(0,U.jsx)(al.Check,{className:"h-3 w-3 text-green-500"}):(0,U.jsx)(mw.Copy,{className:"h-3 w-3 text-muted-foreground"})})}let jP=(0,V.createContext)(null),jF={openFile:()=>{},index:null,scope:null};function jL(){return(0,V.useContext)(jP)??jF}let jO=jP.Provider;function jB({line:e}){let r="add"===e.type?"+":"delete"===e.type?"-":" ",s="add"===e.type,n="delete"===e.type,i=s?"bg-emerald-500/[0.07]":n?"bg-rose-500/[0.07]":"",a=s?"bg-emerald-500/[0.10]":n?"bg-rose-500/[0.10]":"bg-secondary",o=s?"text-emerald-600":n?"text-rose-600":"text-muted-foreground/70";return(0,U.jsxs)("div",{className:"flex font-mono text-[11.5px] leading-[1.55]",children:[(0,U.jsx)("span",{className:(0,e1.cn)("w-9 flex-shrink-0 text-right pr-2 select-none border-r border-border/60",a,o),children:e.oldLineNo??""}),(0,U.jsx)("span",{className:(0,e1.cn)("w-9 flex-shrink-0 text-right pr-2 select-none border-r border-border/60",a,o),children:e.newLineNo??""}),(0,U.jsx)("span",{className:(0,e1.cn)("w-5 flex-shrink-0 text-center select-none",i,o),children:r}),(0,U.jsx)("span",{className:(0,e1.cn)("whitespace-pre-wrap break-all pr-4 flex-1 min-w-0 pl-2",i,(s||n)&&"text-foreground"),children:e.content})]})}let jz={modified:"bg-yellow-500/20 text-yellow-500",added:"bg-green-500/20 text-green-500",deleted:"bg-red-500/20 text-red-500",renamed:"bg-blue-500/20 text-blue-500"},j$={modified:"Modified",added:"Added",deleted:"Deleted",renamed:"Renamed"};function jW({file:e,defaultOpen:r=!0}){let[s,n]=(0,V.useState)(r),i=function(e,r){if(!r||r===e){let r,{dir:s,base:n}=-1===(r=e.lastIndexOf("/"))?{dir:"",base:e}:{dir:e.slice(0,r),base:e.slice(r+1)};return{dir:s,from:null,to:n,suffix:""}}let s=r.split("/"),n=e.split("/"),i=0;for(;i<s.length-1&&i<n.length-1&&s[i]===n[i];)i++;let a=0;for(;a<s.length-i-1&&a<n.length-i-1&&s[s.length-1-a]===n[n.length-1-a];)a++;return{dir:s.slice(0,i).join("/"),from:s.slice(i,s.length-a).join("/"),to:n.slice(i,n.length-a).join("/"),suffix:0===a?"":s.slice(s.length-a).join("/")}}(e.path,"renamed"===e.status?e.oldPath:void 0),{openFile:a}=jL(),o="deleted"===e.status;return(0,U.jsxs)(xM,{open:s,onOpenChange:n,className:"border border-border rounded-lg overflow-hidden",children:[(0,U.jsxs)("div",{className:"group grid grid-cols-[minmax(0,1fr)_auto] items-center bg-secondary border-b border-border hover:bg-muted transition-colors",children:[(0,U.jsxs)(xI,{className:"grid grid-cols-[auto_minmax(0,1fr)_auto] items-center gap-2 pl-4 pr-2 py-2 w-full min-w-0 cursor-pointer",children:[s?(0,U.jsx)(aa,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}):(0,U.jsx)(i2,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),(0,U.jsxs)("span",{className:"font-mono text-[11.5px] flex min-w-0 overflow-hidden text-left text-foreground font-medium",title:null!==i.from?`${e.oldPath} → ${e.path}`:e.path,children:[i.dir&&(0,U.jsxs)("span",{className:"min-w-0 shrink-[9999] truncate text-muted-foreground font-normal",children:[i.dir,"/"]}),(0,U.jsxs)("span",{className:"min-w-0 truncate",children:[null!==i.from&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)("span",{className:"text-muted-foreground font-normal",children:i.from}),(0,U.jsx)("span",{className:"mx-1.5 text-muted-foreground",children:"→"})]}),i.to,i.suffix&&(0,U.jsxs)("span",{className:"text-muted-foreground font-normal",children:["/",i.suffix]})]})]}),(0,U.jsx)(rG,{variant:"secondary",className:jz[e.status],children:j$[e.status]})]}),(0,U.jsxs)("div",{className:"flex items-center gap-1 pr-3 opacity-60 group-hover:opacity-100 transition-opacity",children:[(0,U.jsx)(jI,{path:e.path}),(0,U.jsx)("button",{type:"button",disabled:o,onClick:()=>a(e.path,e.hunks[0]?.newStart??null),className:"p-0.5 rounded hover:bg-muted-foreground/20 transition-colors disabled:opacity-40 disabled:cursor-not-allowed disabled:hover:bg-transparent",title:o?"Deleted — not in the working tree":"Open in Files","aria-label":"Open in Files",children:(0,U.jsx)(jM,{className:"h-3 w-3 text-muted-foreground"})})]})]}),(0,U.jsx)(xP,{children:(0,U.jsxs)("div",{children:[e.binary&&(0,U.jsx)("div",{className:"px-4 py-2 text-[11.5px] text-muted-foreground",children:"Binary file — contents not shown"}),e.hunks.map((e,r)=>(0,U.jsxs)("div",{children:[(0,U.jsxs)("div",{className:"px-4 py-0.5 bg-accent text-accent-foreground text-[11px] font-mono font-medium sticky top-0",children:["@@ -",e.oldStart,",",e.oldLines," +",e.newStart,",",e.newLines," @@"]}),e.lines.map((e,r)=>(0,U.jsx)(jB,{line:e},r))]},r))]})})]})}let jH=(0,rE.default)("git-commit-horizontal",[["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}],["line",{x1:"3",x2:"9",y1:"12",y2:"12",key:"1dyftd"}],["line",{x1:"15",x2:"21",y1:"12",y2:"12",key:"oup4p8"}]]),jU="__head__",jV="__compare__";function jq({commits:e,selectedCommit:r,onSelectCommit:s,compareTarget:n,compareSelected:i,onSelectCompare:a,loading:o,disabled:l}){return(0,U.jsxs)(fP,{value:i?jV:r??jU,onValueChange:e=>{e===jV?a?.():s(e===jU?null:e)},disabled:l||o,children:[(0,U.jsxs)(fL,{size:"sm",className:"w-[200px]",children:[(0,U.jsx)(jH,{className:"h-3.5 w-3.5 shrink-0"}),(0,U.jsx)(fF,{placeholder:"Select commit..."})]}),(0,U.jsxs)(fO,{children:[(0,U.jsx)(fB,{value:jU,children:"HEAD (uncommitted)"}),n&&(0,U.jsxs)(fB,{value:jV,children:["vs ",(0,U.jsx)("span",{className:"font-mono text-xs",children:n})]}),e.map(e=>(0,U.jsxs)(fB,{value:e.hash,children:[(0,U.jsx)("span",{className:"font-mono text-xs",children:e.shortHash})," ",(0,U.jsx)("span",{className:"truncate",children:e.message.length>40?e.message.slice(0,40)+"...":e.message})]},e.hash))]})]})}let jK=[];function jX({projectId:e,selectedBranch:r,onMergeRequest:s,project:n,mergeTarget:i,compareRequestNonce:a}){let[o,l]=(0,V.useState)(null),[c,d]=(0,V.useState)(!1),[u,h]=(0,V.useState)(a),[f,p]=(0,V.useState)(r),m=void 0!==a&&a!==u;m&&(h(a),d(!0),l(null)),r!==f&&(p(r),l(null),m||d(!1));let{remotes:g,loaded:x}=xl(),v=[];for(let e of(n?.path&&v.push({id:"local",label:"Local",icon:hW}),g))v.push({id:e.remote_server_id,label:e.server_name,icon:aL});let y=n?.path?"local":g.length>0?g[0].remote_server_id:"local",[b,w]=(0,V.useState)(null),_=null!==b&&v.some(e=>e.id===b)?b:y,[S,k]=(0,V.useState)(!0),[j,C]=(0,V.useState)(0),N=!!n?.path||x,E="local"===_?n?.path?"local":void 0:"remote",{diff:D,loading:T,error:R,refresh:A}=function(e,r,s,n,i){let a=`${e??""}::${r??""}`,[o,l]=(0,V.useState)(null),[c,d]=(0,V.useState)(!1),u=(0,V.useRef)(0),h=(0,V.useCallback)(async()=>{let o=++u.current;if(!e){l({workspace:a,diff:null,error:null}),d(!1);return}d(!0);try{let c=await aC.api.getDiff(e,r,s,n,i);if(o!==u.current)return;l({workspace:a,diff:c,error:null})}catch(e){if(o!==u.current)return;l({workspace:a,diff:null,error:e instanceof Error?e.message:"Failed to load diff"})}finally{o===u.current&&d(!1)}},[e,r,s,n,i,a]),f=o?.workspace===a?o:null;return{diff:f?.diff??null,loading:c||null===f,error:f?.error??null,refresh:h}}(e,r,o,E,c&&i?i:null),{commits:M,loading:I,refetch:P}=function(e,r,s,n){let i=`${e??""}::${r??""}`,[a,o]=(0,V.useState)(null),[l,c]=(0,V.useState)(!1),d=(0,V.useRef)(0),u=(0,V.useCallback)(async()=>{let a=++d.current;if(!e){o({workspace:i,commits:jK}),c(!1);return}c(!0);try{let l=await aC.api.getCommits(e,r,s,n);if(a!==d.current)return;o({workspace:i,commits:l})}catch{if(a!==d.current)return;o({workspace:i,commits:jK})}finally{a===d.current&&c(!1)}},[e,r,s,n,i]);return{commits:a?.workspace===i?a.commits:jK,loading:l,refetch:u}}(e,r,void 0,E);if((0,V.useEffect)(()=>{N&&A()},[A,N]),(0,V.useEffect)(()=>{N&&P()},[P,N]),!e)return(0,U.jsx)("div",{className:"h-full flex items-center justify-center text-muted-foreground",children:(0,U.jsxs)("div",{className:"text-center",children:[(0,U.jsx)("div",{className:"mx-auto w-10 h-10 rounded-xl bg-muted flex items-center justify-center mb-3",children:(0,U.jsx)(ao,{className:"h-5 w-5 text-muted-foreground/50"})}),(0,U.jsx)("p",{className:"text-sm",children:"Select a project to view changes"})]})});let F=D?.files.length??0;return(0,U.jsxs)("div",{className:"h-full flex flex-col",children:[(0,U.jsxs)("div",{className:"flex items-center justify-between px-4 py-2 border-b border-border/60 h-10",children:[(0,U.jsx)("div",{className:"flex items-center gap-4",children:F>0&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)("span",{className:"text-xs text-muted-foreground",children:[F," file",1!==F?"s":""," changed"]}),(0,U.jsxs)(a$.Button,{size:"sm",variant:"ghost",onClick:()=>{k(e=>!e),C(e=>e+1)},title:S?"Collapse all":"Expand all",children:[(0,U.jsx)(gd,{className:"h-4 w-4 mr-1"}),S?"Collapse all":"Expand all"]})]})}),(0,U.jsxs)("div",{className:"flex items-center gap-2",children:[v.length>1&&(0,U.jsx)(jD,{targets:v,activeTarget:_,onTargetChange:w,disabled:T}),(0,U.jsx)("span",{className:"text-sm text-muted-foreground whitespace-nowrap",children:"Commit:"}),(0,U.jsx)(jq,{commits:M,selectedCommit:o,onSelectCommit:e=>{d(!1),l(e)},compareTarget:i,compareSelected:c,onSelectCompare:()=>{d(!0),l(null)},loading:I,disabled:T}),(0,U.jsxs)(a$.Button,{size:"sm",variant:"outline",onClick:s,disabled:T||0===F,children:[(0,U.jsx)(dP,{className:"h-4 w-4 mr-1"}),"Merge"]}),(0,U.jsxs)(a$.Button,{size:"sm",variant:"outline",onClick:A,disabled:T,children:[(0,U.jsx)(m_,{className:`h-4 w-4 mr-1 ${T?"animate-spin":""}`}),"Refresh"]})]})]}),(0,U.jsx)(o8,{className:"flex-1 overflow-hidden",children:(0,U.jsx)("div",{className:"p-4 space-y-4",children:T&&!D?(0,U.jsx)("div",{className:"text-center text-muted-foreground py-8",children:"Loading changes..."}):R?(0,U.jsx)("div",{className:"text-center text-red-400 py-8",children:R}):0===F?(0,U.jsx)("div",{className:"text-center text-muted-foreground py-8",children:(0,U.jsx)("p",{children:c&&i?`No changes vs ${i}`:o?"No changes in this commit":"No uncommitted changes"})}):D?.files.map((e,r)=>(0,U.jsx)(jW,{file:e,defaultOpen:S},`${r}-${j}`))})})]})}let jY=[];function jG({terminalId:e,onExit:r,active:s}){let{logs:n,sendInput:i,sendResize:a,exitCode:o,replayingHistory:l}=function(e,r){let[s,n]=(0,V.useState)([]),[i,a]=(0,V.useState)("closed"),[o,l]=(0,V.useState)(null),[c,d]=(0,V.useState)(!1),[u,h]=(0,V.useState)(!0),f=(0,V.useRef)(null),p=(0,V.useRef)(null),m=(0,V.useRef)(0),g=(0,V.useRef)(null),x=(0,V.useRef)(!1),v=(0,V.useCallback)(()=>{n([]),l(null),d(!1)},[]),y=(0,V.useCallback)(e=>{f.current?.readyState===WebSocket.OPEN&&f.current.send(JSON.stringify({type:"input",data:e}))},[]),b=(0,V.useCallback)((e,r)=>{f.current?.readyState===WebSocket.OPEN?f.current.send(JSON.stringify({type:"resize",cols:e,rows:r})):p.current={cols:e,rows:r}},[]);return(0,V.useEffect)(()=>{if(!e)return;n([]),l(null),d(!1),x.current=!1,m.current=0;let r=!1,s=0;return function i(){r||x.current||(0,aC.getFreshToken)().then(()=>{if(!r&&!x.current){if(!(0,aC.hasUsableStreamToken)()){a("connecting");let e=Math.min(15e3,1e3*2**Math.min(s,4));s+=1,g.current=setTimeout(()=>{g.current=null,i()},e);return}s=0,function(){if(r||x.current)return;a("connecting");let s=`/api/executor-processes/${e}/logs`;console.log(`[useExecutorLogs] Connecting to WebSocket: ${s}`);let o=new WebSocket((0,aC.getWebSocketUrl)(s));f.current=o;let c=!1,u=!1;o.onopen=()=>{if(!r&&(console.log("[useExecutorLogs] WebSocket connected"),a("connected"),n([]),p.current)){let{cols:e,rows:r}=p.current;o.send(JSON.stringify({type:"resize",cols:e,rows:r})),p.current=null}},o.onmessage=e=>{if(!r)try{let r=JSON.parse(e.data);if("init"===r.type)d(r.isPty),h(!0),console.log("[useExecutorLogs] init received, setReplayingHistory(true)");else if("history_end"===r.type)u=!0,h(!1),console.log("[useExecutorLogs] history_end received, setReplayingHistory(false)");else if("finished"===r.type)x.current=!0,l(r.exitCode),a("closed");else if("error"===r.type)x.current=!0,a("error");else{u&&(c=!0,m.current=0);let e="stdout"===r.type||"stderr"===r.type||"pty"===r.type?{...r,historical:!u}:r;n(r=>[...r,e])}}catch(e){console.error("Failed to parse WebSocket message:",e)}},o.onerror=e=>{r||console.error("[useExecutorLogs] WebSocket error:",e)},o.onclose=e=>{if(console.log("[useExecutorLogs] WebSocket closed:",e.code,e.reason),f.current=null,x.current||r)return void a("closed");if(u&&!c){console.log(`[useExecutorLogs] Server closed after history with no live data — treating as terminal`),x.current=!0,a("closed");return}if(m.current<8){let e=m.current,s=Math.min(15e3,1e3*Math.pow(2,e)),n=s*Math.random()*.25,o=s+n;console.log(`[useExecutorLogs] Scheduling reconnect in ${Math.round(o)}ms (attempt ${e+1}/8)`),a("connecting"),m.current=e+1,g.current=setTimeout(()=>{g.current=null,r||i()},o)}else console.log("[useExecutorLogs] Max reconnect attempts reached"),a("error")}}()}})}(),()=>{r=!0,g.current&&(clearTimeout(g.current),g.current=null),f.current&&(f.current.close(),f.current=null)}},[e,void 0]),{logs:s,status:i,exitCode:o,isPty:c,replayingHistory:u,clearLogs:v,sendInput:y,sendResize:b}}(e),c=(0,V.useRef)(null);return(0,V.useEffect)(()=>{s&&c.current?.focus()},[s]),(0,V.useEffect)(()=>{null!==o&&r(e)},[o,r,e]),(0,U.jsx)(SD,{logs:n,isPty:!0,className:"h-full rounded-none border-0",onInput:i,onResize:a,muteInput:l,focusHandle:c})}function jJ({projectId:e,selectedBranch:r,project:s,active:n=!0,createRequest:i}){let{terminals:a,activeTerminalId:o,createTerminal:l,closeTerminal:c,setActiveTerminal:d,removeTerminal:u}=function(e,r){let[s,n]=(0,V.useState)([]),[i,a]=(0,V.useState)(null),o=`${e??""}::${r??""}`,l=(0,V.useRef)(o),c=(0,V.useRef)([]),[d,u]=(0,V.useState)(null),h=(0,V.useRef)(null);(0,V.useEffect)(()=>{if(l.current=o,c.current=[],!e){n([]),a(null);return}aC.api.getTerminals(e,r).then(e=>{if(l.current!==o)return;let r=c.current;c.current=[];let s=0===r.length?e:[...e.filter(e=>!r.some(r=>r.id===e.id)),...r];n(s),h.current=o,u(o),a(r.length>0?r[r.length-1].id:s.length>0?s[0].id:null)})},[e,r,o]);let f=(0,V.useCallback)(async(s,i)=>{if(!e)return;let o=l.current;try{let d=await aC.api.createTerminal(e,r,s,i);if(l.current!==o)return;c.current=[...c.current,d];let f=c.current,p=h.current===o;n(e=>p?[...e,d]:f),h.current=o,u(o),a(d.id)}catch(e){console.error("[useTerminals] Failed to create terminal:",e)}},[e,r]),p=(0,V.useCallback)(e=>{c.current=c.current.filter(r=>r.id!==e)},[]),m=(0,V.useCallback)(async e=>{await aC.api.closeTerminal(e),p(e),n(r=>{let s=r.filter(r=>r.id!==e);return a(r=>r===e?s.length>0?s[s.length-1].id:null:r),s})},[p]),g=(0,V.useCallback)(e=>{a(e)},[]),x=(0,V.useCallback)(e=>{p(e),n(r=>{let s=r.filter(r=>r.id!==e);return a(r=>r===e?s.length>0?s[s.length-1].id:null:r),s})},[p]),v=null!==e&&d===o;return{terminals:v?s:jY,activeTerminalId:v?i:null,createTerminal:f,closeTerminal:m,setActiveTerminal:g,removeTerminal:x}}(e,r),{remotes:h}=xl(),[f,p]=(0,V.useState)(!1),m=(0,V.useRef)(null),g=!!s?.path,x=h.length>0,v=g&&x||h.length>1,y=g?"local":"remote",b=(0,V.useCallback)(()=>{l(y)},[l,y]),w=(0,V.useCallback)((e,r)=>{p(!1),l(e,r)},[l]),_=(0,V.useRef)(null);(0,V.useEffect)(()=>{i&&_.current!==i.nonce&&(_.current=i.nonce,"local"===i.targetId?l("local"):l("remote",i.targetId))},[i,l]),(0,V.useEffect)(()=>{if(f)return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e);function e(e){m.current&&!m.current.contains(e.target)&&p(!1)}},[f]);let S=(0,V.useCallback)(e=>{u(e)},[u]);return e?(0,U.jsxs)("div",{className:"h-full flex flex-col",children:[(0,U.jsxs)("div",{className:"flex items-center h-10 border-b border-border/60 px-2 gap-1 shrink-0 bg-muted/20",children:[(0,U.jsx)("div",{className:"flex-1 min-w-0 flex items-center gap-1 overflow-hidden",children:a.map(e=>{let r="remote"===e.location||e.id.startsWith("remote-"),s=v?r?aL:hW:xb,n=o===e.id;return(0,U.jsxs)("button",{onClick:()=>d(e.id),title:e.name,className:(0,e1.cn)("group flex items-center gap-1.5 px-2 py-1 rounded-md text-xs transition-all duration-150 border flex-1 min-w-0 basis-0 max-w-[180px]",n?"bg-background text-foreground border-border shadow-sm":"text-muted-foreground hover:text-foreground bg-muted/40 hover:bg-background/60 border-border/30 hover:border-border/60"),children:[(0,U.jsx)(s,{className:"h-3 w-3 shrink-0"}),(0,U.jsx)("span",{className:"truncate flex-1 text-left",children:e.name}),(0,U.jsx)("span",{role:"button",onClick:r=>{r.stopPropagation(),c(e.id)},className:(0,e1.cn)("shrink-0 rounded-sm p-0.5 hover:bg-destructive/10 hover:text-destructive",n?"opacity-80 hover:opacity-100":"opacity-0 group-hover:opacity-80 hover:!opacity-100"),children:(0,U.jsx)(rD,{className:"h-3 w-3"})})]},e.id)})}),(0,U.jsxs)("div",{className:"relative shrink-0",ref:m,children:[(0,U.jsx)(a$.Button,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:v?()=>p(e=>!e):b,children:(0,U.jsx)(oS,{className:"h-3.5 w-3.5"})}),v&&f&&(0,U.jsxs)("div",{className:"absolute right-0 top-full mt-1 z-50 min-w-[160px] rounded-md border bg-popover p-1 shadow-md",children:[g&&(0,U.jsxs)("button",{className:"flex w-full items-center gap-2 rounded-sm px-2 py-1.5 text-xs hover:bg-accent hover:text-accent-foreground transition-colors",onClick:()=>w("local"),children:[(0,U.jsx)(hW,{className:"h-3.5 w-3.5"}),"Local Terminal"]}),h.map(e=>(0,U.jsxs)("button",{className:"flex w-full items-center gap-2 rounded-sm px-2 py-1.5 text-xs hover:bg-accent hover:text-accent-foreground transition-colors",onClick:()=>w("remote",e.remote_server_id),children:[(0,U.jsx)(aL,{className:"h-3.5 w-3.5"}),e.server_name," Terminal"]},e.remote_server_id))]})]})]}),(0,U.jsxs)("div",{className:"flex-1 overflow-hidden bg-zinc-950",children:[a.map(e=>(0,U.jsx)("div",{className:(0,e1.cn)("h-full",o!==e.id&&"hidden"),children:(0,U.jsx)(jG,{terminalId:e.id,onExit:S,active:n&&o===e.id})},e.id)),!o&&(0,U.jsx)("div",{className:"h-full flex items-center justify-center text-muted-foreground",children:(0,U.jsx)(xb,{className:"h-10 w-10 text-muted-foreground/70"})})]})]}):(0,U.jsx)("div",{className:"h-full flex items-center justify-center text-muted-foreground",children:(0,U.jsxs)("div",{className:"text-center",children:[(0,U.jsx)("div",{className:"mx-auto w-10 h-10 rounded-xl bg-muted flex items-center justify-center mb-3",children:(0,U.jsx)(xb,{className:"h-5 w-5 text-muted-foreground/50"})}),(0,U.jsx)("p",{className:"text-sm",children:"Select a project to use the terminal"})]})})}function jZ(e){let r=!0;try{r=e.currentTarget.matches(":focus-visible")}catch{}r||e.preventDefault()}function jQ({label:e,children:r,side:s="bottom"}){return(0,U.jsx)(cI,{delayDuration:300,children:(0,U.jsxs)(cP,{children:[(0,U.jsx)(cF,{asChild:!0,onFocus:jZ,children:r}),null!=e&&(0,U.jsx)(cL,{side:s,className:"max-w-72",children:e})]})})}let j0="local";function j1(e){let r=window.open("about:blank","_blank");if(r){r.opener=null;try{r.document.title="Opening preview…",r.document.body.textContent="Opening preview…"}catch{}}return e().then(s=>{if(r){r.location.href=s;return}xc.toast.message("Preview ready",{description:"Your browser blocked the new tab.",action:{label:"Open",onClick:()=>{j1(e).catch(e=>xc.toast.error(e instanceof Error?e.message:"Failed to open preview"))}}})},e=>{throw r?.close(),e})}function j2({projectId:e,project:r}){let{config:s}=(0,ow.useAppConfig)(),n=xl(),i=n?.remotes,a=s?.previewLinks===!0,o=!!r?.path&&s?.localProjectsEnabled!==!1,[l,c]=(0,V.useState)([]),[d,u]=(0,V.useState)(!1),[h,f]=(0,V.useState)(""),[p,m]=(0,V.useState)("3000"),[g,x]=(0,V.useState)(!1),v=(0,V.useMemo)(()=>{let e=[];for(let r of(o&&e.push({id:j0,name:"This machine",online:null,local:!0}),i??[]))e.push({id:r.remote_server_id,name:r.server_name,online:r.status?"online"===r.status:null,local:!1});return e},[o,i]);(0,V.useEffect)(()=>{0!==v.length&&(v.some(e=>e.id===h)||f(v[0].id))},[v,h]);let y=(0,V.useRef)(e);y.current=e;let b=(0,V.useRef)(0),w=(0,V.useCallback)(async()=>{if(y.current!==e)return;let r=++b.current,s=()=>r!==b.current||y.current!==e;if(!e||!a){c([]),u(!0);return}try{let r=await aC.api.getPreviewLinks(e);if(s())return;c(r.links)}catch(e){if(s())return;console.error("Failed to load preview links:",e)}finally{s()||u(!0)}},[e,a]);(0,V.useEffect)(()=>{c([]),u(!1),w()},[w]);let _=(0,V.useCallback)(async r=>{if(r.preventDefault(),!e||!h||g)return;let s=Number(p);if(!Number.isInteger(s)||s<1||s>65535)return void xc.toast.error("Enter a port between 1 and 65535");x(!0);try{await j1(()=>aC.api.createPreviewLink(e,h,s).then(e=>e.authUrl)),await w()}catch(r){let e=r instanceof Error?r.message:"Failed to open preview";r instanceof aC.PreviewLinkError&&"worker-upgrade-required"===r.errorCode?xc.toast.error("Worker update needed",{description:e}):xc.toast.error(e)}finally{x(!1)}},[e,h,p,g,w]),S=(0,V.useCallback)(async e=>{try{await j1(()=>aC.api.openPreviewLink(e.slug).then(e=>e.authUrl))}catch(e){xc.toast.error(e instanceof Error?e.message:"Failed to open preview")}},[]),k=(0,V.useCallback)(async r=>{if(e)try{await aC.api.deletePreviewLink(e,r.slug),c(e=>e.filter(e=>e.slug!==r.slug))}catch(e){xc.toast.error(e instanceof Error?e.message:"Failed to remove preview link")}},[e]);return e?s&&!a?(0,U.jsx)(j5,{title:"Preview links are not set up on this server",detail:"Start the server with --preview-host (or VIBEDECKX_PREVIEW_HOST) pointing at a wildcard domain that resolves to it. Each preview then opens at its own origin in a new tab."}):(0,U.jsxs)("div",{className:"h-full flex flex-col",children:[(0,U.jsxs)("form",{onSubmit:_,className:"flex items-center gap-1.5 border-b px-2 h-10 shrink-0",children:[(0,U.jsxs)(fP,{value:h,onValueChange:f,disabled:0===v.length,children:[(0,U.jsx)(fL,{size:"sm",className:"w-[11rem] text-xs","aria-label":"Machine",children:(0,U.jsx)(fF,{placeholder:0===v.length?"No machines":"Machine"})}),(0,U.jsx)(fO,{children:v.map(e=>(0,U.jsx)(fB,{value:e.id,className:"text-xs",children:(0,U.jsxs)("span",{className:"flex items-center gap-1.5",children:[e.local?(0,U.jsx)(hW,{className:"h-3 w-3"}):(0,U.jsx)(aL,{className:"h-3 w-3"}),e.name,!1===e.online&&(0,U.jsx)("span",{className:"text-muted-foreground",children:"(offline)"})]})},e.id))})]}),(0,U.jsx)("span",{className:"text-xs text-muted-foreground",children:"localhost:"}),(0,U.jsx)(aX,{value:p,onChange:e=>m(e.target.value.replace(/[^\d]/g,"")),inputMode:"numeric",className:"h-8 w-20 text-xs","aria-label":"Port",placeholder:"3000"}),(0,U.jsxs)(a$.Button,{type:"submit",size:"sm",className:"text-xs",disabled:g||!h,children:[(0,U.jsx)(oh,{className:"h-3.5 w-3.5"}),"Open"]})]}),(0,U.jsx)("div",{className:"flex-1 overflow-y-auto",children:d&&0===l.length?(0,U.jsx)(j5,{title:"Open a dev server from any of this project's machines",detail:"Pick the machine the server runs on and its port. The page opens in a new tab at its own address, which you can keep and reopen later, also from your phone."}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)("ul",{className:"divide-y border-b",children:l.map(e=>{let r=v.find(r=>r.id===e.targetId),s=r?.online===!1;return(0,U.jsxs)("li",{className:"flex items-center gap-2 px-3 py-2 text-sm",children:[e.targetId===j0?(0,U.jsx)(hW,{className:"h-3.5 w-3.5 text-muted-foreground shrink-0"}):(0,U.jsx)(aL,{className:"h-3.5 w-3.5 text-muted-foreground shrink-0"}),(0,U.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,U.jsxs)("div",{className:"truncate",children:[(0,U.jsx)("span",{className:"font-medium",children:e.targetName}),(0,U.jsxs)("span",{className:"text-muted-foreground",children:[" · localhost:",e.port]}),s&&(0,U.jsx)("span",{className:"ml-1.5 text-xs text-muted-foreground",children:"offline"})]}),(0,U.jsx)("div",{className:"truncate text-xs text-muted-foreground",children:e.url})]}),(0,U.jsx)(jQ,{label:"Open in a new tab",children:(0,U.jsx)(a$.Button,{variant:"ghost",size:"icon",className:"h-7 w-7","aria-label":"Open preview",onClick:()=>void S(e),children:(0,U.jsx)(oh,{className:"h-3.5 w-3.5"})})}),(0,U.jsx)(jQ,{label:"Remove this preview link",children:(0,U.jsx)(a$.Button,{variant:"ghost",size:"icon",className:"h-7 w-7","aria-label":"Remove preview link",onClick:()=>void k(e),children:(0,U.jsx)(ok,{className:"h-3.5 w-3.5"})})})]},e.slug)})}),l.length<=3&&(0,U.jsxs)("div",{className:"flex flex-col items-center gap-2 px-6 py-10 text-center text-muted-foreground",children:[(0,U.jsx)(oC,{className:"h-6 w-6 opacity-40"}),(0,U.jsx)("p",{className:"max-w-sm text-xs leading-relaxed",children:"Each link keeps its address: bookmark it, or open it on another device and sign in to Vibedeckx there. Pick a machine and port above to add another."})]})]})})]}):(0,U.jsx)(j5,{title:"Select a project to preview its dev server"})}function j5({title:e,detail:r}){return(0,U.jsx)("div",{className:"h-full flex items-center justify-center text-muted-foreground p-6",children:(0,U.jsxs)("div",{className:"flex flex-col items-center gap-2 text-center max-w-sm",children:[(0,U.jsx)(oC,{className:"h-8 w-8 opacity-40"}),(0,U.jsx)("p",{className:"text-sm",children:e}),r&&(0,U.jsx)("p",{className:"text-xs leading-relaxed",children:r})]})})}let j3=(0,rE.default)("arrow-right",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]);function j4({className:e,...r}){return(0,U.jsx)("div",{"data-slot":"input-group",role:"group",className:(0,e1.cn)("group/input-group border-input dark:bg-input/30 relative flex w-full items-center rounded-md border shadow-xs transition-[color,box-shadow] outline-none","h-9 min-w-0 has-[textarea]:h-auto","has-[>[data-align=inline-start]]:[&>input]:pl-2","has-[>[data-align=inline-end]]:[&>input]:pr-2","has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col has-[>[data-align=block-start]]:[&>input]:pb-3","has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col has-[>[data-align=block-end]]:[&>input]:pt-3","has-[[data-slot=input-group-control]:focus-visible]:border-ring has-[[data-slot=input-group-control]:focus-visible]:ring-ring/50 has-[[data-slot=input-group-control]:focus-visible]:ring-[3px]","has-[[data-slot][aria-invalid=true]]:ring-destructive/20 has-[[data-slot][aria-invalid=true]]:border-destructive dark:has-[[data-slot][aria-invalid=true]]:ring-destructive/40",e),...r})}let j6=(0,rX.cva)("text-muted-foreground flex h-auto cursor-text items-center justify-center gap-2 py-1.5 text-sm font-medium select-none [&>svg:not([class*='size-'])]:size-4 [&>kbd]:rounded-[calc(var(--radius)-5px)] group-data-[disabled=true]/input-group:opacity-50",{variants:{align:{"inline-start":"order-first pl-3 has-[>button]:ml-[-0.45rem] has-[>kbd]:ml-[-0.35rem]","inline-end":"order-last pr-3 has-[>button]:mr-[-0.45rem] has-[>kbd]:mr-[-0.35rem]","block-start":"order-first w-full justify-start px-3 pt-3 [.border-b]:pb-3 group-has-[>input]/input-group:pt-2.5","block-end":"order-last w-full justify-start px-3 pb-3 [.border-t]:pt-3 group-has-[>input]/input-group:pb-2.5"}},defaultVariants:{align:"inline-start"}});function j7({className:e,align:r="inline-start",...s}){return(0,U.jsx)("div",{role:"group","data-slot":"input-group-addon","data-align":r,className:(0,e1.cn)(j6({align:r}),e),onClick:e=>{e.target.closest("button")||e.currentTarget.parentElement?.querySelector("input")?.focus()},...s})}let j8=(0,rX.cva)("text-sm shadow-none flex gap-2 items-center",{variants:{size:{xs:"h-6 gap-1 px-2 rounded-[calc(var(--radius)-5px)] [&>svg:not([class*='size-'])]:size-3.5 has-[>svg]:px-2",sm:"h-8 px-2.5 gap-1.5 rounded-md has-[>svg]:px-2.5","icon-xs":"size-6 rounded-[calc(var(--radius)-5px)] p-0 has-[>svg]:p-0","icon-sm":"size-8 p-0 has-[>svg]:p-0"}},defaultVariants:{size:"xs"}});function j9({className:e,type:r="button",variant:s="ghost",size:n="xs",...i}){return(0,U.jsx)(a$.Button,{type:r,"data-size":n,variant:s,className:(0,e1.cn)(j8({size:n}),e),...i})}function Ce({className:e,...r}){return(0,U.jsx)(aX,{"data-slot":"input-group-control",className:(0,e1.cn)("flex-1 rounded-none border-0 bg-transparent shadow-none focus-visible:ring-0 dark:bg-transparent",e),...r})}function Ct({className:e,...r}){return(0,U.jsx)(aq,{"data-slot":"input-group-control",className:(0,e1.cn)("flex-1 resize-none rounded-none border-0 bg-transparent py-3 shadow-none focus-visible:ring-0 dark:bg-transparent",e),...r})}let Cr=(0,rE.default)("file",[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}]]),Cs=(0,rE.default)("file-code",[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 12.5 8 15l2 2.5",key:"1tg20x"}],["path",{d:"m14 12.5 2 2.5-2 2.5",key:"yinavb"}]]),Cn=(0,rE.default)("file-text",[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]]),Ci=new Set(["ts","tsx","js","jsx","py","rb","go","rs","java","c","cpp","h","css","scss","html","vue","svelte","php","swift","kt","sh","bash","yaml","yml","toml","json","xml","sql","graphql","proto"]),Ca=new Set(["md","txt","log","csv","env","gitignore","dockerignore","editorconfig"]);function Co(e){return Array.from(e.dataTransfer.types).includes("Files")}function Cl(e){let r=e.dataTransfer.items;if(r&&r.length>0&&"function"==typeof r[0].webkitGetAsEntry){let e=[];for(let s of Array.from(r)){if("file"!==s.kind)continue;let r=s.webkitGetAsEntry();if(r?.isDirectory)continue;let n=s.getAsFile();n&&e.push(n)}return e}return Array.from(e.dataTransfer.files)}function Cc({entryPath:e,type:r,deleting:s,onRequestDelete:n}){return s?(0,U.jsx)(aP,{className:"h-3 w-3 animate-spin text-muted-foreground"}):(0,U.jsx)("button",{onClick:s=>{s.stopPropagation(),n(e,r)},className:"p-0.5 rounded hover:bg-destructive/20 transition-colors",title:`Delete ${e}`,"aria-label":`Delete ${e}`,children:(0,U.jsx)(ok,{className:"h-3 w-3 text-muted-foreground hover:text-destructive"})})}function Cd({entry:e,path:r,depth:s,expandedDirs:n,directoryContents:i,loadingDirs:a,selectedFile:o,revealNonce:l,uploadingDirs:c,dragOverPath:d,deletingPaths:u,onToggleDirectory:h,onSelectFile:f,onUploadFiles:p,onSetDragOverPath:m,onRequestDelete:g}){let x=n.has(r),v=a.has(r),y=i.get(r),b=e.name.startsWith(".");if("directory"===e.type){let w=x?aa:i2,_=d===r,S=c.has(r),k=u.has(r);return(0,U.jsxs)("div",{children:[(0,U.jsxs)("div",{className:(0,e1.cn)("group flex items-center w-full px-2 py-2 rounded-sm transition-colors cursor-pointer",_?"bg-primary/15 outline-2 -outline-offset-2 outline-dashed outline-primary/60":"hover:bg-accent"),style:{paddingLeft:`${16*s+8}px`},onClick:()=>h(r),onDragOver:e=>{Co(e)&&(e.preventDefault(),e.stopPropagation(),m(r))},onDrop:e=>{if(!Co(e))return;e.preventDefault(),e.stopPropagation(),m(null);let s=Cl(e);s.length&&p(r,s)},children:[(0,U.jsxs)("div",{className:"flex items-center gap-1 w-0 min-w-0 flex-1",children:[S||v?(0,U.jsx)(aP,{className:"h-3.5 w-3.5 shrink-0 animate-spin text-muted-foreground"}):(0,U.jsx)(w,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),(0,U.jsx)(x?o_:le,{className:(0,e1.cn)("h-4 w-4 shrink-0 text-blue-500",b&&"opacity-60")}),(0,U.jsx)("span",{className:(0,e1.cn)("truncate",b&&"text-muted-foreground"),children:e.name})]}),(0,U.jsxs)("div",{className:(0,e1.cn)("shrink-0 ml-1 items-center gap-1",k?"flex":"hidden group-hover:flex"),children:[(0,U.jsx)(jI,{path:r}),(0,U.jsx)(Cc,{entryPath:r,type:"directory",deleting:k,onRequestDelete:g})]})]}),x&&y&&(0,U.jsx)("div",{children:y.map(e=>{let x=r?`${r}/${e.name}`:e.name;return(0,U.jsx)(Cd,{entry:e,path:x,depth:s+1,expandedDirs:n,directoryContents:i,loadingDirs:a,selectedFile:o,revealNonce:l,uploadingDirs:c,dragOverPath:d,deletingPaths:u,onToggleDirectory:h,onSelectFile:f,onUploadFiles:p,onSetDragOverPath:m,onRequestDelete:g},x)})})]})}return(0,U.jsx)(Cu,{entry:e,path:r,depth:s,isSelected:o===r,revealNonce:l,deletingPaths:u,onSelectFile:f,onUploadFiles:p,onSetDragOverPath:m,onRequestDelete:g})}function Cu({entry:e,path:r,depth:s,isSelected:n,revealNonce:i,deletingPaths:a,onSelectFile:o,onUploadFiles:l,onSetDragOverPath:c,onRequestDelete:d}){var u,h,f,p;let m,g,x,v,y,b=(0,V.useRef)(null);(0,V.useEffect)(()=>{n&&b.current?.scrollIntoView?.({block:"nearest"})},[n,i]);let w=e.name.startsWith("."),_=r.includes("/")?r.slice(0,r.lastIndexOf("/")):"",S=a.has(r);return(0,U.jsxs)("div",{ref:b,className:(0,e1.cn)("group flex items-center w-full px-2 py-2 rounded-sm transition-colors cursor-pointer",n?"bg-accent text-accent-foreground":"hover:bg-accent/50"),style:{paddingLeft:`${16*s+8+18}px`},onClick:()=>o(r),onDragOver:e=>{Co(e)&&(e.preventDefault(),e.stopPropagation(),c(_))},onDrop:e=>{if(!Co(e))return;e.preventDefault(),e.stopPropagation(),c(null);let r=Cl(e);r.length&&l(_,r)},children:[(0,U.jsxs)("div",{className:"flex items-center gap-1 w-0 min-w-0 flex-1",children:[(u=e.name,h=(0,e1.cn)("h-4 w-4 shrink-0 text-muted-foreground",w&&"opacity-60"),m=u.split(".").pop()?.toLowerCase()??"",Ci.has(m)?(0,U.jsx)(Cs,{className:h}):Ca.has(m)?(0,U.jsx)(Cn,{className:h}):(0,U.jsx)(Cr,{className:h})),(0,U.jsx)("span",{className:(0,e1.cn)("truncate",w&&"text-muted-foreground"),children:e.name})]}),(0,U.jsxs)("div",{className:"shrink-0 flex items-center gap-2 ml-1",children:[(0,U.jsx)("span",{className:"text-[11px] text-muted-foreground/70 group-hover:hidden whitespace-nowrap w-[52px] text-right tabular-nums",children:e.mtime&&(f=e.mtime,g=Date.now(),y=Math.floor((v=Math.floor((x=Math.floor(Math.floor((g-new Date(f).getTime())/1e3)/60))/60))/24),x<1?"just now":x<60?`${x}m ago`:v<24?`${v}h ago`:y<30?`${y}d ago`:new Date(f).toLocaleDateString(void 0,{month:"short",day:"numeric"}))}),(0,U.jsx)("span",{className:"text-[11px] text-muted-foreground/70 group-hover:hidden whitespace-nowrap w-[52px] text-right tabular-nums",children:null!=e.size&&((p=e.size)<1024?`${p} B`:p<1048576?`${(p/1024).toFixed(1)} KB`:`${(p/1048576).toFixed(1)} MB`)}),(0,U.jsxs)("div",{className:(0,e1.cn)("items-center gap-1",S?"flex":"hidden group-hover:flex"),children:[(0,U.jsx)(jI,{path:r}),(0,U.jsx)(Cc,{entryPath:r,type:"file",deleting:S,onRequestDelete:d})]})]})]})}function Ch({entries:e,expandedDirs:r,directoryContents:s,loadingDirs:n,selectedFile:i,revealNonce:a,uploadingDirs:o,rootLoading:l,deletingPaths:c,onToggleDirectory:d,onSelectFile:u,onUploadFiles:h,onDeleteEntry:f}){let[p,m]=(0,V.useState)(null),[g,x]=(0,V.useState)(null),v=""===p,y=o.has(""),b=(0,V.useCallback)((e,r)=>{x({path:e,type:r})},[]),w=g?g.path.includes("/")?g.path.slice(g.path.lastIndexOf("/")+1):g.path:"";return(0,U.jsxs)("div",{className:(0,e1.cn)("h-full transition-colors",v&&"bg-accent/30 outline-2 -outline-offset-2 outline-dashed outline-primary/50"),style:{fontSize:"var(--files-tree-font-size, 14px)"},onDragOver:e=>{Co(e)&&(e.preventDefault(),m(""))},onDragLeave:e=>{e.currentTarget.contains(e.relatedTarget)||m(null)},onDrop:e=>{if(!Co(e))return;e.preventDefault(),m(null);let r=Cl(e);r.length&&h("",r)},children:[(0,U.jsx)(o8,{className:"h-full",children:(0,U.jsxs)("div",{className:"py-1",children:[y&&(0,U.jsxs)("div",{className:"flex items-center gap-2 px-2 py-1 text-xs text-muted-foreground",children:[(0,U.jsx)(aP,{className:"h-3.5 w-3.5 animate-spin"}),"Uploading…"]}),l&&0===e.length?(0,U.jsx)("div",{className:"flex items-center justify-center py-12 text-muted-foreground text-sm",children:"Loading files..."}):0===e.length?(0,U.jsx)("div",{className:"flex items-center justify-center py-8 text-muted-foreground text-sm",children:v?"Drop files to upload":"No files found. Drop files here to upload."}):e.map(e=>{let l=e.name;return(0,U.jsx)(Cd,{entry:e,path:l,depth:0,expandedDirs:r,directoryContents:s,loadingDirs:n,selectedFile:i,revealNonce:a,uploadingDirs:o,dragOverPath:p,deletingPaths:c,onToggleDirectory:d,onSelectFile:u,onUploadFiles:h,onSetDragOverPath:m,onRequestDelete:b},l)})]})}),(0,U.jsx)(lJ,{open:null!==g,onOpenChange:e=>{e||x(null)},children:(0,U.jsxs)(l0,{children:[(0,U.jsxs)(l1,{children:[(0,U.jsxs)(l5,{children:["Delete ",g?.type==="directory"?"folder":"file","?"]}),(0,U.jsx)(l3,{children:g?.type==="directory"?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)("span",{className:"font-medium text-foreground",children:w})," and all its contents will be permanently deleted. This can't be undone."]}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)("span",{className:"font-medium text-foreground",children:w})," will be permanently deleted. This can't be undone."]})})]}),(0,U.jsxs)(l2,{children:[(0,U.jsx)(l6,{children:"Cancel"}),(0,U.jsx)(l4,{className:(0,e1.cn)((0,a$.buttonVariants)({variant:"destructive"}),"border-transparent"),onClick:()=>{g&&f(g.path,g.type)},children:"Delete"})]})]})})]})}let Cf=(0,rE.default)("download",[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]]),Cp=(0,rE.default)("file-exclamation-point",[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]),Cm=(0,rE.default)("code",[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]]),Cg=(0,rE.default)("list-collapse",[["path",{d:"M10 5h11",key:"1hkqpe"}],["path",{d:"M10 12h11",key:"6m4ad9"}],["path",{d:"M10 19h11",key:"14g2nv"}],["path",{d:"m3 10 3-3-3-3",key:"i7pm08"}],["path",{d:"m3 20 3-3-3-3",key:"20gx1n"}]]),Cx=(0,rE.default)("highlighter",[["path",{d:"m9 11-6 6v3h9l3-3",key:"1a3l36"}],["path",{d:"m22 12-4.6 4.6a2 2 0 0 1-2.8 0l-5.2-5.2a2 2 0 0 1 0-2.8L14 4",key:"14a9rk"}]]),Cv=(0,rE.default)("list-tree",[["path",{d:"M8 5h13",key:"1pao27"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 19h8",key:"c3s6r1"}],["path",{d:"M3 10a2 2 0 0 0 2 2h3",key:"1npucw"}],["path",{d:"M3 5v12a2 2 0 0 0 2 2h3",key:"x1gjn2"}]]),Cy=/[\0-\x1F!-,\.\/:-@\[-\^`\{-\xA9\xAB-\xB4\xB6-\xB9\xBB-\xBF\xD7\xF7\u02C2-\u02C5\u02D2-\u02DF\u02E5-\u02EB\u02ED\u02EF-\u02FF\u0375\u0378\u0379\u037E\u0380-\u0385\u0387\u038B\u038D\u03A2\u03F6\u0482\u0530\u0557\u0558\u055A-\u055F\u0589-\u0590\u05BE\u05C0\u05C3\u05C6\u05C8-\u05CF\u05EB-\u05EE\u05F3-\u060F\u061B-\u061F\u066A-\u066D\u06D4\u06DD\u06DE\u06E9\u06FD\u06FE\u0700-\u070F\u074B\u074C\u07B2-\u07BF\u07F6-\u07F9\u07FB\u07FC\u07FE\u07FF\u082E-\u083F\u085C-\u085F\u086B-\u089F\u08B5\u08C8-\u08D2\u08E2\u0964\u0965\u0970\u0984\u098D\u098E\u0991\u0992\u09A9\u09B1\u09B3-\u09B5\u09BA\u09BB\u09C5\u09C6\u09C9\u09CA\u09CF-\u09D6\u09D8-\u09DB\u09DE\u09E4\u09E5\u09F2-\u09FB\u09FD\u09FF\u0A00\u0A04\u0A0B-\u0A0E\u0A11\u0A12\u0A29\u0A31\u0A34\u0A37\u0A3A\u0A3B\u0A3D\u0A43-\u0A46\u0A49\u0A4A\u0A4E-\u0A50\u0A52-\u0A58\u0A5D\u0A5F-\u0A65\u0A76-\u0A80\u0A84\u0A8E\u0A92\u0AA9\u0AB1\u0AB4\u0ABA\u0ABB\u0AC6\u0ACA\u0ACE\u0ACF\u0AD1-\u0ADF\u0AE4\u0AE5\u0AF0-\u0AF8\u0B00\u0B04\u0B0D\u0B0E\u0B11\u0B12\u0B29\u0B31\u0B34\u0B3A\u0B3B\u0B45\u0B46\u0B49\u0B4A\u0B4E-\u0B54\u0B58-\u0B5B\u0B5E\u0B64\u0B65\u0B70\u0B72-\u0B81\u0B84\u0B8B-\u0B8D\u0B91\u0B96-\u0B98\u0B9B\u0B9D\u0BA0-\u0BA2\u0BA5-\u0BA7\u0BAB-\u0BAD\u0BBA-\u0BBD\u0BC3-\u0BC5\u0BC9\u0BCE\u0BCF\u0BD1-\u0BD6\u0BD8-\u0BE5\u0BF0-\u0BFF\u0C0D\u0C11\u0C29\u0C3A-\u0C3C\u0C45\u0C49\u0C4E-\u0C54\u0C57\u0C5B-\u0C5F\u0C64\u0C65\u0C70-\u0C7F\u0C84\u0C8D\u0C91\u0CA9\u0CB4\u0CBA\u0CBB\u0CC5\u0CC9\u0CCE-\u0CD4\u0CD7-\u0CDD\u0CDF\u0CE4\u0CE5\u0CF0\u0CF3-\u0CFF\u0D0D\u0D11\u0D45\u0D49\u0D4F-\u0D53\u0D58-\u0D5E\u0D64\u0D65\u0D70-\u0D79\u0D80\u0D84\u0D97-\u0D99\u0DB2\u0DBC\u0DBE\u0DBF\u0DC7-\u0DC9\u0DCB-\u0DCE\u0DD5\u0DD7\u0DE0-\u0DE5\u0DF0\u0DF1\u0DF4-\u0E00\u0E3B-\u0E3F\u0E4F\u0E5A-\u0E80\u0E83\u0E85\u0E8B\u0EA4\u0EA6\u0EBE\u0EBF\u0EC5\u0EC7\u0ECE\u0ECF\u0EDA\u0EDB\u0EE0-\u0EFF\u0F01-\u0F17\u0F1A-\u0F1F\u0F2A-\u0F34\u0F36\u0F38\u0F3A-\u0F3D\u0F48\u0F6D-\u0F70\u0F85\u0F98\u0FBD-\u0FC5\u0FC7-\u0FFF\u104A-\u104F\u109E\u109F\u10C6\u10C8-\u10CC\u10CE\u10CF\u10FB\u1249\u124E\u124F\u1257\u1259\u125E\u125F\u1289\u128E\u128F\u12B1\u12B6\u12B7\u12BF\u12C1\u12C6\u12C7\u12D7\u1311\u1316\u1317\u135B\u135C\u1360-\u137F\u1390-\u139F\u13F6\u13F7\u13FE-\u1400\u166D\u166E\u1680\u169B-\u169F\u16EB-\u16ED\u16F9-\u16FF\u170D\u1715-\u171F\u1735-\u173F\u1754-\u175F\u176D\u1771\u1774-\u177F\u17D4-\u17D6\u17D8-\u17DB\u17DE\u17DF\u17EA-\u180A\u180E\u180F\u181A-\u181F\u1879-\u187F\u18AB-\u18AF\u18F6-\u18FF\u191F\u192C-\u192F\u193C-\u1945\u196E\u196F\u1975-\u197F\u19AC-\u19AF\u19CA-\u19CF\u19DA-\u19FF\u1A1C-\u1A1F\u1A5F\u1A7D\u1A7E\u1A8A-\u1A8F\u1A9A-\u1AA6\u1AA8-\u1AAF\u1AC1-\u1AFF\u1B4C-\u1B4F\u1B5A-\u1B6A\u1B74-\u1B7F\u1BF4-\u1BFF\u1C38-\u1C3F\u1C4A-\u1C4C\u1C7E\u1C7F\u1C89-\u1C8F\u1CBB\u1CBC\u1CC0-\u1CCF\u1CD3\u1CFB-\u1CFF\u1DFA\u1F16\u1F17\u1F1E\u1F1F\u1F46\u1F47\u1F4E\u1F4F\u1F58\u1F5A\u1F5C\u1F5E\u1F7E\u1F7F\u1FB5\u1FBD\u1FBF-\u1FC1\u1FC5\u1FCD-\u1FCF\u1FD4\u1FD5\u1FDC-\u1FDF\u1FED-\u1FF1\u1FF5\u1FFD-\u203E\u2041-\u2053\u2055-\u2070\u2072-\u207E\u2080-\u208F\u209D-\u20CF\u20F1-\u2101\u2103-\u2106\u2108\u2109\u2114\u2116-\u2118\u211E-\u2123\u2125\u2127\u2129\u212E\u213A\u213B\u2140-\u2144\u214A-\u214D\u214F-\u215F\u2189-\u24B5\u24EA-\u2BFF\u2C2F\u2C5F\u2CE5-\u2CEA\u2CF4-\u2CFF\u2D26\u2D28-\u2D2C\u2D2E\u2D2F\u2D68-\u2D6E\u2D70-\u2D7E\u2D97-\u2D9F\u2DA7\u2DAF\u2DB7\u2DBF\u2DC7\u2DCF\u2DD7\u2DDF\u2E00-\u2E2E\u2E30-\u3004\u3008-\u3020\u3030\u3036\u3037\u303D-\u3040\u3097\u3098\u309B\u309C\u30A0\u30FB\u3100-\u3104\u3130\u318F-\u319F\u31C0-\u31EF\u3200-\u33FF\u4DC0-\u4DFF\u9FFD-\u9FFF\uA48D-\uA4CF\uA4FE\uA4FF\uA60D-\uA60F\uA62C-\uA63F\uA673\uA67E\uA6F2-\uA716\uA720\uA721\uA789\uA78A\uA7C0\uA7C1\uA7CB-\uA7F4\uA828-\uA82B\uA82D-\uA83F\uA874-\uA87F\uA8C6-\uA8CF\uA8DA-\uA8DF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA954-\uA95F\uA97D-\uA97F\uA9C1-\uA9CE\uA9DA-\uA9DF\uA9FF\uAA37-\uAA3F\uAA4E\uAA4F\uAA5A-\uAA5F\uAA77-\uAA79\uAAC3-\uAADA\uAADE\uAADF\uAAF0\uAAF1\uAAF7-\uAB00\uAB07\uAB08\uAB0F\uAB10\uAB17-\uAB1F\uAB27\uAB2F\uAB5B\uAB6A-\uAB6F\uABEB\uABEE\uABEF\uABFA-\uABFF\uD7A4-\uD7AF\uD7C7-\uD7CA\uD7FC-\uD7FF\uE000-\uF8FF\uFA6E\uFA6F\uFADA-\uFAFF\uFB07-\uFB12\uFB18-\uFB1C\uFB29\uFB37\uFB3D\uFB3F\uFB42\uFB45\uFBB2-\uFBD2\uFD3E-\uFD4F\uFD90\uFD91\uFDC8-\uFDEF\uFDFC-\uFDFF\uFE10-\uFE1F\uFE30-\uFE32\uFE35-\uFE4C\uFE50-\uFE6F\uFE75\uFEFD-\uFF0F\uFF1A-\uFF20\uFF3B-\uFF3E\uFF40\uFF5B-\uFF65\uFFBF-\uFFC1\uFFC8\uFFC9\uFFD0\uFFD1\uFFD8\uFFD9\uFFDD-\uFFFF]|\uD800[\uDC0C\uDC27\uDC3B\uDC3E\uDC4E\uDC4F\uDC5E-\uDC7F\uDCFB-\uDD3F\uDD75-\uDDFC\uDDFE-\uDE7F\uDE9D-\uDE9F\uDED1-\uDEDF\uDEE1-\uDEFF\uDF20-\uDF2C\uDF4B-\uDF4F\uDF7B-\uDF7F\uDF9E\uDF9F\uDFC4-\uDFC7\uDFD0\uDFD6-\uDFFF]|\uD801[\uDC9E\uDC9F\uDCAA-\uDCAF\uDCD4-\uDCD7\uDCFC-\uDCFF\uDD28-\uDD2F\uDD64-\uDDFF\uDF37-\uDF3F\uDF56-\uDF5F\uDF68-\uDFFF]|\uD802[\uDC06\uDC07\uDC09\uDC36\uDC39-\uDC3B\uDC3D\uDC3E\uDC56-\uDC5F\uDC77-\uDC7F\uDC9F-\uDCDF\uDCF3\uDCF6-\uDCFF\uDD16-\uDD1F\uDD3A-\uDD7F\uDDB8-\uDDBD\uDDC0-\uDDFF\uDE04\uDE07-\uDE0B\uDE14\uDE18\uDE36\uDE37\uDE3B-\uDE3E\uDE40-\uDE5F\uDE7D-\uDE7F\uDE9D-\uDEBF\uDEC8\uDEE7-\uDEFF\uDF36-\uDF3F\uDF56-\uDF5F\uDF73-\uDF7F\uDF92-\uDFFF]|\uD803[\uDC49-\uDC7F\uDCB3-\uDCBF\uDCF3-\uDCFF\uDD28-\uDD2F\uDD3A-\uDE7F\uDEAA\uDEAD-\uDEAF\uDEB2-\uDEFF\uDF1D-\uDF26\uDF28-\uDF2F\uDF51-\uDFAF\uDFC5-\uDFDF\uDFF7-\uDFFF]|\uD804[\uDC47-\uDC65\uDC70-\uDC7E\uDCBB-\uDCCF\uDCE9-\uDCEF\uDCFA-\uDCFF\uDD35\uDD40-\uDD43\uDD48-\uDD4F\uDD74\uDD75\uDD77-\uDD7F\uDDC5-\uDDC8\uDDCD\uDDDB\uDDDD-\uDDFF\uDE12\uDE38-\uDE3D\uDE3F-\uDE7F\uDE87\uDE89\uDE8E\uDE9E\uDEA9-\uDEAF\uDEEB-\uDEEF\uDEFA-\uDEFF\uDF04\uDF0D\uDF0E\uDF11\uDF12\uDF29\uDF31\uDF34\uDF3A\uDF45\uDF46\uDF49\uDF4A\uDF4E\uDF4F\uDF51-\uDF56\uDF58-\uDF5C\uDF64\uDF65\uDF6D-\uDF6F\uDF75-\uDFFF]|\uD805[\uDC4B-\uDC4F\uDC5A-\uDC5D\uDC62-\uDC7F\uDCC6\uDCC8-\uDCCF\uDCDA-\uDD7F\uDDB6\uDDB7\uDDC1-\uDDD7\uDDDE-\uDDFF\uDE41-\uDE43\uDE45-\uDE4F\uDE5A-\uDE7F\uDEB9-\uDEBF\uDECA-\uDEFF\uDF1B\uDF1C\uDF2C-\uDF2F\uDF3A-\uDFFF]|\uD806[\uDC3B-\uDC9F\uDCEA-\uDCFE\uDD07\uDD08\uDD0A\uDD0B\uDD14\uDD17\uDD36\uDD39\uDD3A\uDD44-\uDD4F\uDD5A-\uDD9F\uDDA8\uDDA9\uDDD8\uDDD9\uDDE2\uDDE5-\uDDFF\uDE3F-\uDE46\uDE48-\uDE4F\uDE9A-\uDE9C\uDE9E-\uDEBF\uDEF9-\uDFFF]|\uD807[\uDC09\uDC37\uDC41-\uDC4F\uDC5A-\uDC71\uDC90\uDC91\uDCA8\uDCB7-\uDCFF\uDD07\uDD0A\uDD37-\uDD39\uDD3B\uDD3E\uDD48-\uDD4F\uDD5A-\uDD5F\uDD66\uDD69\uDD8F\uDD92\uDD99-\uDD9F\uDDAA-\uDEDF\uDEF7-\uDFAF\uDFB1-\uDFFF]|\uD808[\uDF9A-\uDFFF]|\uD809[\uDC6F-\uDC7F\uDD44-\uDFFF]|[\uD80A\uD80B\uD80E-\uD810\uD812-\uD819\uD824-\uD82B\uD82D\uD82E\uD830-\uD833\uD837\uD839\uD83D\uD83F\uD87B-\uD87D\uD87F\uD885-\uDB3F\uDB41-\uDBFF][\uDC00-\uDFFF]|\uD80D[\uDC2F-\uDFFF]|\uD811[\uDE47-\uDFFF]|\uD81A[\uDE39-\uDE3F\uDE5F\uDE6A-\uDECF\uDEEE\uDEEF\uDEF5-\uDEFF\uDF37-\uDF3F\uDF44-\uDF4F\uDF5A-\uDF62\uDF78-\uDF7C\uDF90-\uDFFF]|\uD81B[\uDC00-\uDE3F\uDE80-\uDEFF\uDF4B-\uDF4E\uDF88-\uDF8E\uDFA0-\uDFDF\uDFE2\uDFE5-\uDFEF\uDFF2-\uDFFF]|\uD821[\uDFF8-\uDFFF]|\uD823[\uDCD6-\uDCFF\uDD09-\uDFFF]|\uD82C[\uDD1F-\uDD4F\uDD53-\uDD63\uDD68-\uDD6F\uDEFC-\uDFFF]|\uD82F[\uDC6B-\uDC6F\uDC7D-\uDC7F\uDC89-\uDC8F\uDC9A-\uDC9C\uDC9F-\uDFFF]|\uD834[\uDC00-\uDD64\uDD6A-\uDD6C\uDD73-\uDD7A\uDD83\uDD84\uDD8C-\uDDA9\uDDAE-\uDE41\uDE45-\uDFFF]|\uD835[\uDC55\uDC9D\uDCA0\uDCA1\uDCA3\uDCA4\uDCA7\uDCA8\uDCAD\uDCBA\uDCBC\uDCC4\uDD06\uDD0B\uDD0C\uDD15\uDD1D\uDD3A\uDD3F\uDD45\uDD47-\uDD49\uDD51\uDEA6\uDEA7\uDEC1\uDEDB\uDEFB\uDF15\uDF35\uDF4F\uDF6F\uDF89\uDFA9\uDFC3\uDFCC\uDFCD]|\uD836[\uDC00-\uDDFF\uDE37-\uDE3A\uDE6D-\uDE74\uDE76-\uDE83\uDE85-\uDE9A\uDEA0\uDEB0-\uDFFF]|\uD838[\uDC07\uDC19\uDC1A\uDC22\uDC25\uDC2B-\uDCFF\uDD2D-\uDD2F\uDD3E\uDD3F\uDD4A-\uDD4D\uDD4F-\uDEBF\uDEFA-\uDFFF]|\uD83A[\uDCC5-\uDCCF\uDCD7-\uDCFF\uDD4C-\uDD4F\uDD5A-\uDFFF]|\uD83B[\uDC00-\uDDFF\uDE04\uDE20\uDE23\uDE25\uDE26\uDE28\uDE33\uDE38\uDE3A\uDE3C-\uDE41\uDE43-\uDE46\uDE48\uDE4A\uDE4C\uDE50\uDE53\uDE55\uDE56\uDE58\uDE5A\uDE5C\uDE5E\uDE60\uDE63\uDE65\uDE66\uDE6B\uDE73\uDE78\uDE7D\uDE7F\uDE8A\uDE9C-\uDEA0\uDEA4\uDEAA\uDEBC-\uDFFF]|\uD83C[\uDC00-\uDD2F\uDD4A-\uDD4F\uDD6A-\uDD6F\uDD8A-\uDFFF]|\uD83E[\uDC00-\uDFEF\uDFFA-\uDFFF]|\uD869[\uDEDE-\uDEFF]|\uD86D[\uDF35-\uDF3F]|\uD86E[\uDC1E\uDC1F]|\uD873[\uDEA2-\uDEAF]|\uD87A[\uDFE1-\uDFFF]|\uD87E[\uDE1E-\uDFFF]|\uD884[\uDF4B-\uDFFF]|\uDB40[\uDC00-\uDCFF\uDDF0-\uDFFF]/g,Cb=Object.hasOwnProperty;var Cw=e.i(216920);let C_={},CS=new class{constructor(){this.occurrences,this.reset()}slug(e,r){var s,n;let i=(s=e,n=!0===r,"string"!=typeof s?"":(n||(s=s.toLowerCase()),s.replace(Cy,"").replace(/ /g,"-"))),a=i;for(;Cb.call(this.occurrences,i);)this.occurrences[a]++,i=a+"-"+this.occurrences[a];return this.occurrences[i]=0,i}reset(){this.occurrences=Object.create(null)}};function Ck(e){let r=(e||C_).prefix||"";return function(e){CS.reset(),(0,Cw.visit)(e,"element",function(e){let s,n;((n=2===(s="element"===e.type?e.tagName.toLowerCase():"").length&&104===s.charCodeAt(0)?s.charCodeAt(1):0)>48&&n<55?n-48:void 0)&&!e.properties.id&&(e.properties.id=r+CS.slug("children"in e?function e(r){let s=-1,n=[];for(;++s<r.children.length;){var i;n[s]="text"===(i=r.children[s]).type?i.value:"children"in i?e(i):""}return n.join("")}(e):"value"in e?e.value:""))})}}var Cj=rQ,i1=i1,CC=e.i(829692),CC=CC;let CN={bash:()=>e.A(350825),c:()=>e.A(637078),cpp:()=>e.A(802318),csharp:()=>e.A(129951),css:()=>e.A(756163),dockerfile:()=>e.A(253540),go:()=>e.A(703741),graphql:()=>e.A(920758),html:()=>e.A(488168),java:()=>e.A(832431),javascript:()=>e.A(857908),json:()=>e.A(699038),jsx:()=>e.A(475799),kotlin:()=>e.A(476532),lua:()=>e.A(930588),makefile:()=>e.A(809849),markdown:()=>e.A(198794),mdx:()=>e.A(186622),php:()=>e.A(931135),python:()=>e.A(435385),r:()=>e.A(995633),ruby:()=>e.A(62790),rust:()=>e.A(733588),scala:()=>e.A(710477),scss:()=>e.A(742937),sql:()=>e.A(546234),svelte:()=>e.A(645265),swift:()=>e.A(993701),toml:()=>e.A(880929),tsx:()=>e.A(427335),typescript:()=>e.A(59512),vue:()=>e.A(945589),xml:()=>e.A(298220),yaml:()=>e.A(405971),zig:()=>e.A(681653)},CE="one-light",CD=null,CT=new Map;async function CR(r){let s=await (CD??=(async()=>{let[{createHighlighterCore:r},{createJavaScriptRegexEngine:s},n,i]=await Promise.all([e.A(733022),e.A(158048),e.A(905359),e.A(617706)]);return r({themes:[n.default,i.default],langs:[],engine:s({forgiving:!0})})})().catch(e=>{throw CD=null,e}));if("text"===r)return s;let n=CT.get(r);return n||(n=CN[r]().then(e=>s.loadLanguage(e.default)).catch(e=>{throw CT.delete(r),e}),CT.set(r,n)),await n,s}let CA=(0,V.createContext)({code:""}),CM={name:"line-data",line(e,r){e.properties["data-line"]=String(r)}},CI={name:"line-numbers",line(e,r){e.children.unshift({type:"element",tagName:"span",properties:{className:["inline-block","min-w-10","mr-2","text-right","select-none","text-muted-foreground"]},children:[{type:"text",value:String(r)}]})}};function CP(e){let r=new MutationObserver(e);return r.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>r.disconnect()}let CF=()=>document.documentElement.classList.contains("dark"),CL=()=>!1;async function CO(e,r,s=!1,n,i=!1){let a=[CM];return n&&n.size>0&&a.push({name:"fold-gutter",line(e,r){e.children.unshift({type:"element",tagName:"span",properties:n.has(r)?{className:["code-fold-toggle"],"data-fold-start":String(r)}:{className:["code-fold-spacer"]},children:[]})}}),s&&a.push(CI),(await CR(r)).codeToHtml(e,{lang:r,theme:i?"one-dark-pro":CE,transformers:a})}let CB=(0,V.forwardRef)(function({code:e,language:r,showLineNumbers:s=!1,scrollToLine:n,scrollKey:i,foldable:a=!1,className:o,children:l,...c},d){let[u,h]=(0,V.useState)(""),f=(0,V.useSyncExternalStore)(CP,CF,CL),p=(0,V.useRef)(null),m=(0,V.useMemo)(()=>({__html:u}),[u]),g=(0,V.useMemo)(()=>a?function(e,r={}){return function(...e){let r=new Map;for(let s of e.flat())!(s.endLine<=s.startLine)&&(r.has(s.startLine)||r.set(s.startLine,s));let s=[...r.values()].sort((e,r)=>e.startLine-r.startLine||r.endLine-e.endLine),n=[],i=[];for(let e of s){for(;i.length&&i[i.length-1].endLine<e.startLine;)i.pop();let r=i[i.length-1];r&&e.endLine>r.endLine||(n.push(e),i.push(e))}return n}((r.tokenIndex,[]),function(e){let r=e.split("\n"),s=[],n=[],i=0,a=e=>{i>e.line&&s.push({startLine:e.line+1,endLine:i+1})};for(let e=0;e<r.length;e++){let s=function(e){let r=e.match(/^[ \t]*/),s=r?r[0].length:0;return s===e.length?null:s}(r[e]);if(null!==s){for(;n.length&&n[n.length-1].indent>=s;)a(n.pop());n.push({indent:s,line:e}),i=e}}for(;n.length;)a(n.pop());return s}(e))}(e):[],[a,e]),x=(0,V.useMemo)(()=>new Set(g.map(e=>e.startLine)),[g]),[v,y]=(0,V.useState)(new Set),[b,w]=(0,V.useState)(e),[_,S]=(0,V.useState)({line:n,key:i});if((0,V.useImperativeHandle)(d,()=>({foldAll:()=>y(new Set(g.map(e=>e.startLine))),expandAll:()=>y(new Set)}),[g]),(0,V.useEffect)(()=>{let n=!1;return CO(e,r,s,x,f).then(e=>{n||h(e)}),()=>{n=!0}},[e,r,s,x,f]),(0,V.useEffect)(()=>{let e=p.current;if(!e)return;let r=new Map(g.map(e=>[e.startLine,e])),s=new Set;for(let e of v){let n=r.get(e);if(n)for(let e=n.startLine+1;e<=n.endLine;e++)s.add(e)}for(let r of e.querySelectorAll("[data-line]")){let e=Number(r.getAttribute("data-line"));r.style.display=s.has(e)?"none":"",r.classList.toggle("code-line-collapsed",v.has(e))}},[v,g,u]),(0,V.useEffect)(()=>{if(!a)return;let e=p.current;if(!e)return;let r=e=>{let r=e.target?.closest?.("[data-fold-start]");if(!r)return;e.stopPropagation(),e.preventDefault();let s=Number(r.getAttribute("data-fold-start"));y(e=>{let r=new Set(e);return r.has(s)?r.delete(s):r.add(s),r})};return e.addEventListener("click",r),()=>e.removeEventListener("click",r)},[a]),(0,V.useEffect)(()=>{if(null==n)return;let e=p.current;if(!e||!u)return;let r=Array.from(e.querySelectorAll(`[data-line="${n}"]`));if(0===r.length)return;let s=r[0],i=requestAnimationFrame(()=>{s.scrollIntoView({block:"center",behavior:"auto"}),r.forEach(e=>e.classList.add("code-line-highlight"))}),a=window.setTimeout(()=>r.forEach(e=>e.classList.remove("code-line-highlight")),1600);return()=>{cancelAnimationFrame(i),window.clearTimeout(a),r.forEach(e=>e.classList.remove("code-line-highlight"))}},[n,i,u]),e!==b&&(w(e),y(new Set)),(_.line!==n||_.key!==i)&&(S({line:n,key:i}),null!=n&&v.size>0)){let e=!1,r=new Set(v);for(let s of g)r.has(s.startLine)&&n>s.startLine&&n<=s.endLine&&(r.delete(s.startLine),e=!0);e&&y(r)}return(0,U.jsx)(CA.Provider,{value:{code:e},children:(0,U.jsx)("div",{ref:p,className:(0,e1.cn)("group relative w-full overflow-hidden rounded-md border bg-background text-foreground",o),...c,children:(0,U.jsxs)("div",{className:"relative",children:[(0,U.jsx)("div",{className:"overflow-auto [&>pre]:m-0 [&>pre]:bg-background! [&>pre]:p-4 [&>pre]:text-foreground! [&>pre]:text-sm [&_code]:grid [&_code]:font-mono [&_code]:text-sm",dangerouslySetInnerHTML:m}),l&&(0,U.jsx)("div",{className:"absolute top-2 right-2 flex items-center gap-2",children:l})]})})})}),Cz=({onCopy:e,onError:r,timeout:s=2e3,children:n,className:i,...a})=>{let[o,l]=(0,V.useState)(!1),{code:c}=(0,V.useContext)(CA),d=async()=>{if(!navigator?.clipboard?.writeText)return void r?.(Error("Clipboard API not available"));try{await navigator.clipboard.writeText(c),l(!0),e?.(),setTimeout(()=>l(!1),s)}catch(e){r?.(e)}},u=o?i1.default:CC.default;return(0,U.jsx)(a$.Button,{className:(0,e1.cn)("shrink-0",i),onClick:d,size:"icon",variant:"ghost",...a,children:n??(0,U.jsx)(u,{size:14})})};function C$({className:e,...r}){return(0,U.jsx)("div",{"data-slot":"skeleton",className:(0,e1.cn)("bg-accent animate-pulse rounded-md",e),...r})}let CW=/^remote-([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})-/i;function CH(e){return e?CW.exec(e)?.[1]??null:null}function CU({projectId:e,symbol:r,branch:s,target:n,currentFile:i,anchor:a,onJump:o,onClose:l}){let[c,d]=(0,V.useState)(!0),[u,h]=(0,V.useState)([]),[f,p]=(0,V.useState)(!1),m=(0,V.useRef)(null);(0,V.useEffect)(()=>{let i=!0;return d(!0),aC.api.searchSymbol(e,r,s,n).then(e=>{i&&(h(e.hits),p(e.truncated))}).catch(()=>{i&&h([])}).finally(()=>{i&&d(!1)}),()=>{i=!1}},[e,r,s,n]),(0,V.useEffect)(()=>{let e=e=>{e.detail>=2||m.current&&!m.current.contains(e.target)&&l()},s=e=>{if("Escape"===e.key)return void l();if((e.metaKey||e.ctrlKey)&&("c"===e.key||"C"===e.key)){let s=window.getSelection();if(s&&s.rangeCount>0&&!s.isCollapsed)return;e.preventDefault(),navigator.clipboard?.writeText(r)}};return document.addEventListener("mousedown",e),document.addEventListener("keydown",s),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("keydown",s)}},[l,r]);let g=(e,r)=>Number(r.file===i)-Number(e.file===i),x=u.filter(e=>"definition"===e.kind).sort(g),v=u.filter(e=>"reference"===e.kind).sort(g),y=Math.max(8,Math.min(a.x,window.innerWidth-440-8)),b=window.innerHeight-8-(a.y+18),w=a.y-18-8,_=b>=340||b>=w,S=Math.max(120,Math.min(340,_?b:w)),k=_?{top:a.y+18}:{bottom:window.innerHeight-(a.y-18)},j=({hit:e})=>(0,U.jsxs)("button",{type:"button",onClick:()=>{o(e.file,e.line),l()},className:"flex w-full flex-col items-start gap-0.5 rounded px-2 py-1.5 text-left hover:bg-accent",children:[(0,U.jsxs)("span",{className:"flex w-full items-baseline justify-between gap-2",children:[(0,U.jsxs)("span",{className:"truncate font-mono text-xs",children:[e.file.split("/").pop(),(0,U.jsxs)("span",{className:"text-muted-foreground",children:[":",e.line]})]}),e.file===i&&(0,U.jsx)("span",{className:"shrink-0 text-[10px] text-muted-foreground",children:"this file"})]}),(0,U.jsx)("code",{className:"w-full truncate text-xs text-muted-foreground",children:e.text.trim()})]}),C=({title:e,children:r})=>(0,U.jsxs)("div",{className:"mb-1",children:[(0,U.jsx)("div",{className:"px-2 py-1 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground",children:e}),r]});return(0,ep.createPortal)((0,U.jsxs)("div",{ref:m,style:{left:y,...k,width:440,maxHeight:S},className:"fixed z-50 flex flex-col overflow-hidden rounded-lg border bg-popover text-popover-foreground shadow-lg select-none",children:[(0,U.jsx)("div",{className:"border-b px-3 py-1.5 text-xs font-medium",children:(0,U.jsx)("span",{className:"font-mono",children:r})}),(0,U.jsx)("div",{className:"flex-1 overflow-auto p-1",children:c?(0,U.jsxs)("div",{className:"flex items-center justify-center gap-2 py-6 text-sm text-muted-foreground",children:[(0,U.jsx)(aP,{className:"h-4 w-4 animate-spin"})," Searching…"]}):0===u.length?(0,U.jsx)("div",{className:"py-6 text-center text-sm text-muted-foreground",children:"No results."}):(0,U.jsxs)(U.Fragment,{children:[x.length>0&&(0,U.jsx)(C,{title:`Definitions (${x.length})`,children:x.map((e,r)=>(0,U.jsx)(j,{hit:e},`d-${r}`))}),v.length>0&&(0,U.jsx)(C,{title:`References (${v.length})`,children:v.map((e,r)=>(0,U.jsx)(j,{hit:e},`r-${r}`))}),f&&(0,U.jsx)("div",{className:"px-2 py-1.5 text-[11px] text-muted-foreground",children:"Showing first matches — results truncated."})]})})]}),document.body)}let CV=(0,rE.default)("image-off",[["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}],["path",{d:"M10.41 10.41a2 2 0 1 1-2.83-2.83",key:"1bzlo9"}],["line",{x1:"13.5",x2:"6",y1:"13.5",y2:"21",key:"1q0aeu"}],["line",{x1:"18",x2:"21",y1:"12",y2:"15",key:"5mozeu"}],["path",{d:"M3.59 3.59A1.99 1.99 0 0 0 3 5v14a2 2 0 0 0 2 2h14c.55 0 1.052-.22 1.41-.59",key:"mmje98"}],["path",{d:"M21 15V5a2 2 0 0 0-2-2H9",key:"43el77"}]]);function Cq({projectId:e,filePath:r,branch:s,target:n,sessionId:i,onDownload:a}){let[o,l]=(0,V.useState)(null),[c,d]=(0,V.useState)(!1);return((0,V.useEffect)(()=>{let a=null,o=!1;return aC.api.getFileBlob(e,r,s,n,i).then(({blob:e})=>{o||l(a=URL.createObjectURL(e))}).catch(()=>{o||d(!0)}),()=>{o=!0,a&&URL.revokeObjectURL(a)}},[e,r,s,n,i]),c)?(0,U.jsxs)("div",{className:"flex flex-col items-center justify-center h-full gap-3 text-muted-foreground",children:[(0,U.jsx)(CV,{className:"h-10 w-10"}),(0,U.jsx)("p",{className:"text-sm",children:"Couldn't load image"}),(0,U.jsxs)(a$.Button,{variant:"outline",size:"sm",onClick:a,children:[(0,U.jsx)(Cf,{className:"h-4 w-4 mr-2"}),"Download"]})]}):o?(0,U.jsx)("div",{className:"flex items-center justify-center h-full p-4 bg-muted/30",children:(0,U.jsx)("img",{src:o,alt:r.split("/").pop()??"image",className:"max-w-full max-h-full object-contain",onError:()=>d(!0)})}):(0,U.jsx)("div",{className:"flex items-center justify-center h-full text-muted-foreground",children:(0,U.jsx)(aP,{className:"h-6 w-6 animate-spin"})})}let CK='<base href="about:srcdoc">';function CX({html:e,title:r,reloadKey:s}){let n=(0,V.useMemo)(()=>(function(e){let r=/<head\b[^>]*>/i.exec(e)??/^\s*<!doctype[^>]*>/i.exec(e);if(!r)return CK+e;let s=r.index+r[0].length;return e.slice(0,s)+CK+e.slice(s)})(e),[e]);return(0,U.jsx)("iframe",{title:r,srcDoc:n,sandbox:"allow-scripts allow-forms allow-modals allow-popups allow-popups-to-escape-sandbox allow-downloads",referrerPolicy:"no-referrer",className:"block w-full h-full border-0 bg-white"},s)}async function CY(e,r,s){let n,i=await CR(r),a=e.split("\n"),o=new Map;for(let e=0;e<a.length;e+=200){if(e>0&&await new Promise(e=>setTimeout(e,0)),s?.aborted)throw new DOMException("Aborted","AbortError");let l=i.codeToTokensBase(a.slice(e,e+200).join("\n"),{lang:r,theme:CE,includeExplanation:"scopeName",grammarState:n});n=i.getLastGrammarState(l),l.forEach((r,s)=>{let n=0,i=[];for(let e of r){let r=(e.explanation??[]).flatMap(e=>e.scopes.map(e=>e.scopeName)),s=n+e.content.length;i.push({start:n,end:s,kind:r.some(e=>e.startsWith("comment"))?"comment":r.some(e=>e.startsWith("string")||e.startsWith("constant.character"))?"string":r.some(e=>e.startsWith("keyword")||e.startsWith("storage")||e.startsWith("constant.language")||e.startsWith("variable.language"))?"keyword":"code"}),n=s}o.set(e+s+1,i)})}return o}function CG(e,r){let s=document;if(s.caretRangeFromPoint){let n=s.caretRangeFromPoint(e,r);return n?{node:n.startContainer,offset:n.startOffset}:null}if(s.caretPositionFromPoint){let n=s.caretPositionFromPoint(e,r);return n?{node:n.offsetNode,offset:n.offset}:null}return null}function CJ(e,r,s){return Math.min(Math.max(e,r),s)}function CZ(e,r){let s=e.getBoundingClientRect(),n=r.getBoundingClientRect();return{left:Math.max(s.left,n.left,0),right:Math.min(s.right,n.right,window.innerWidth),top:Math.max(s.top,n.top,4),bottom:Math.min(s.bottom,n.bottom,window.innerHeight-4)}}function CQ(e,r,s,n,i){let a=CZ(n,i),o=CJ(e,a.left+1,a.right-2),l=CJ(r,a.top+1,a.bottom-2),c=CG(o,l),d=c&&function(e,r){var s;if(!r.contains(e.node))return null;let n=e.node.nodeType===Node.ELEMENT_NODE?e.node:e.node.parentElement,i=n?.closest("[data-line]");if(!i||!r.contains(i))return e;let a=0;for(;a<i.childNodes.length&&(s=i.childNodes[a])instanceof Element&&"none"===getComputedStyle(s).userSelect;)a++;if(e.node===i)return{node:i,offset:Math.max(e.offset,a)};let o=e.node;for(;o&&o.parentNode!==i;)o=o.parentNode;return o&&Array.prototype.indexOf.call(i.childNodes,o)<a?{node:i,offset:a}:e}(c,s);if(d)return d;let u=s.getBoundingClientRect();return l<u.top?{node:s,offset:0}:l>u.bottom?{node:s,offset:s.childNodes.length}:null}function C0(e,r,s){return e<r?-Math.min(24,(r-e)/2+2):e>s?Math.min(24,(e-s)/2+2):0}let C1=new Set(["png","jpg","jpeg","gif","webp","bmp","ico","avif","svg"]);function C2(e){let r=e.split("/").pop()?.split(".").pop()?.toLowerCase()??"";return C1.has(r)}let C5=/^[A-Za-z_$][A-Za-z0-9_$]*$/,C3="symbol-nav";function C4(e,r,s){let n=document.createRange();return n.selectNodeContents(e),n.setEnd(r,s),n.toString().length}function C6(e,r){let s,n=document.createTreeWalker(e,NodeFilter.SHOW_TEXT),i=0;for(;s=n.nextNode();){let e=(s.textContent??"").length;if(r<=i+e)return{node:s,offset:r-i};i+=e}return null}function C7(e){let r=Array.from(document.querySelectorAll(`[data-line="${CSS.escape(e.line)}"]`)),s=r.find(e=>null!==e.offsetParent)??r[0];if(!s)return null;let n=C6(s,e.start),i=C6(s,e.end);if(!n||!i)return null;let a=document.createRange();return a.setStart(n.node,n.offset),a.setEnd(i.node,i.offset),a}let C8=/[A-Za-z0-9_$]/;function C9(e,r,s){let n=CG(e,r),i=n?.node??null,a=n?.offset??0;if(!i||i.nodeType!==Node.TEXT_NODE)return null;let o=i.textContent??"",l=a,c=a;for(;l>0&&C8.test(o[l-1]);)l--;for(;c<o.length&&C8.test(o[c]);)c++;if(l>=c)return null;let d=o.slice(l,c);if(!C5.test(d))return null;let u=document.createRange();u.setStart(i,l),u.setEnd(i,c);let h=function(e){let r=e.startContainer.nodeType===Node.ELEMENT_NODE?e.startContainer:e.startContainer.parentElement,s=r?.closest("[data-line]");if(!s||!s.contains(e.endContainer))return null;let n=s.getAttribute("data-line");if(null===n)return null;let i=C4(s,e.startContainer,e.startOffset),a=C4(s,e.endContainer,e.endOffset);return i>=a?null:{line:n,start:i,end:a}}(u);if(!h)return null;if(s){let e=h.start-h.line.length,r=function(e,r,s){let n=e.get(r);if(!n)return null;for(let e of n)if(s>=e.start&&s<e.end)return e.kind;return null}(s,Number(h.line),e);if(r&&"code"!==r)return null}return{word:d,anchor:h}}function Ne(){return"undefined"!=typeof CSS&&"highlights"in CSS&&"undefined"!=typeof Highlight}let Nt=!1;function Nr(){Ne()&&CSS.highlights.delete(C3)}let Ns={ts:"typescript",tsx:"tsx",js:"javascript",jsx:"jsx",py:"python",rb:"ruby",go:"go",rs:"rust",java:"java",c:"c",cpp:"cpp",h:"c",cs:"csharp",css:"css",scss:"scss",html:"html",htm:"html",vue:"vue",svelte:"svelte",php:"php",swift:"swift",kt:"kotlin",sh:"bash",bash:"bash",zsh:"bash",yaml:"yaml",yml:"yaml",toml:"toml",json:"json",xml:"xml",sql:"sql",graphql:"graphql",md:"markdown",mdx:"mdx",dockerfile:"dockerfile",makefile:"makefile",lua:"lua",r:"r",scala:"scala",zig:"zig"};function Nn(e){let r=e.split("/").pop()?.toLowerCase()??"";return"dockerfile"===r?"dockerfile":"makefile"===r?"makefile":Ns[r.split(".").pop()?.toLowerCase()??""]??"text"}function Ni(e){let r=Nn(e);return"markdown"===r||"mdx"===r}function Na(e){return"html"===Nn(e)}function No(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`}let Nl={mermaid:{panZoom:!1}};function Nc({filePath:e,fileContent:r,loading:s,downloadUrl:n,projectId:i,branch:a,target:o,sessionId:l,scrollToLine:c,scrollKey:d,onJump:u,restoreScrollTop:h,restoreScrollKey:f,onScroll:p}){let m=r?.serverId??null,{label:g}=g7(m&&m!==CH(l)?m:null),[x,v]=(0,V.useState)("rendered"),[y,b]=(0,V.useState)(0),[w,_]=(0,V.useState)(!1),[S,k]=(0,V.useState)(e),[j,C]=(0,V.useState)(null),N=(0,V.useRef)(null),E=(0,V.useRef)(null),D=(0,V.useRef)(null),T=(0,V.useRef)(!1);(0,V.useEffect)(()=>{T.current=null!==j},[j]);let R=(0,V.useCallback)(e=>{if(e.detail>=2){let r=window.getSelection();if(T.current){r?.removeAllRanges(),C(e=>e?{...e,selectWord:!0}:e);return}let s=C9(e.clientX,e.clientY),n=s?C7(s.anchor):null;n&&(r?.removeAllRanges(),r?.addRange(n));return}let r=window.getSelection();if(r&&!r.isCollapsed)return;let s=C9(e.clientX,e.clientY,N.current);s&&(r?.removeAllRanges(),C({symbol:s.word,x:e.clientX,y:e.clientY,anchor:s.anchor,selectWord:!1}))},[]),A=(0,V.useCallback)(e=>{if(e.detail>=2)return void e.preventDefault();if(0!==e.button)return;let r=e.target;if(!r.closest("pre")||r.closest("[data-fold-start], button"))return;let s=Array.from(e.currentTarget.querySelectorAll("pre code")).find(e=>null!==e.offsetParent),n=D.current;s&&n&&function(e,r,s){let n=window.getSelection();if(!n)return;let i=r.closest("pre")?.parentElement??s,a=CQ(e.clientX,e.clientY,r,s,i);if(!a)return;let o=e.shiftKey&&n.anchorNode&&r.contains(n.anchorNode)?{node:n.anchorNode,offset:n.anchorOffset}:a;e.preventDefault();let l=document.activeElement;l instanceof HTMLElement&&!r.contains(l)&&l.blur();let c=e.clientX,d=e.clientY,u=()=>{let e=CQ(c,d,r,s,i);e&&n.setBaseAndExtent(o.node,o.offset,e.node,e.offset)};u();let h=0,f=()=>{h=0;let e=CZ(s,i),r=C0(c,e.left,e.right),n=C0(d,e.top,e.bottom);(r||n)&&(n&&(s.scrollTop+=n),r&&(i.scrollLeft+=r),u(),h=requestAnimationFrame(f))},p=e=>{1&e.buttons?(c=e.clientX,d=e.clientY,u(),h||(h=requestAnimationFrame(f))):g()},m=()=>u(),g=()=>{h&&cancelAnimationFrame(h),document.removeEventListener("mousemove",p,!0),document.removeEventListener("mouseup",g,!0),window.removeEventListener("blur",g),s.removeEventListener("scroll",m),i.removeEventListener("scroll",m)};document.addEventListener("mousemove",p,!0),document.addEventListener("mouseup",g,!0),window.addEventListener("blur",g),s.addEventListener("scroll",m,{passive:!0}),i.addEventListener("scroll",m,{passive:!0})}(e.nativeEvent,s,n)},[]);(0,V.useEffect)(()=>{if(!j?.anchor)return void Nr();let e=C7(j.anchor);if(!e)return void Nr();if(j.selectWord){Nr();let r=window.getSelection();r?.removeAllRanges(),r?.addRange(e);return}return Ne()?(!function(){if(Nt||"undefined"==typeof document)return;Nt=!0;let e=document.createElement("style");e.textContent=`::highlight(${C3}){background-color:rgba(255, 196, 0, 0.32);}`,document.head.appendChild(e)}(),CSS.highlights.set(C3,new Highlight(e)),Nr):void Nr()},[j]);let M=!!e&&("source"===x||!(Ni(e)||Na(e))),I=(r?.content?.length??0)>5e4,P=I&&!w;(0,V.useEffect)(()=>{N.current=null;let s=r?.content;if(!e||!M||P||null==s||r?.binary||r?.tooLarge)return;let n=new AbortController;return CY(s,Nn(e),n.signal).then(e=>{n.signal.aborted||(N.current=e)}).catch(()=>{}),()=>n.abort()},[e,r,M,P]);let F=(0,V.useRef)(null),L=(0,V.useRef)(null),O=(0,V.useCallback)(e=>{let r=F.current;if(!r)return;let s=r.querySelector(`[id="${CSS.escape(e)}"]`);if(!s)return;L.current?.();let n=()=>s.scrollIntoView({block:"start",behavior:"auto"});n();let i=new ResizeObserver(n);i.observe(r);let a=()=>{i.disconnect(),window.clearTimeout(o),window.removeEventListener("wheel",a),window.removeEventListener("touchmove",a),window.removeEventListener("keydown",a),L.current=null},o=window.setTimeout(a,1e3);window.addEventListener("wheel",a,{passive:!0}),window.addEventListener("touchmove",a,{passive:!0}),window.addEventListener("keydown",a),L.current=a},[]);(0,V.useEffect)(()=>()=>L.current?.(),[]);let B=(0,V.useRef)(!1),z=(0,V.useRef)(p);z.current=p;let $=(0,V.useRef)(null),W=(0,V.useRef)(null),H=(0,V.useCallback)(e=>{if(B.current)return;let r=e.currentTarget.scrollTop;$.current&&clearTimeout($.current),$.current=setTimeout(()=>z.current?.(r),200)},[]);(0,V.useEffect)(()=>{void 0!==f&&(W.current=h??0)},[f,h]),(0,V.useEffect)(()=>{let e=D.current;e&&(e.scrollTop=0)},[e]),(0,V.useEffect)(()=>{let e=W.current;if(null==e)return;let r=D.current;if(!r||(W.current=null,!e))return;B.current=!0;let s=()=>{r.scrollTop=e};s();let n=new ResizeObserver(s);n.observe(r.firstElementChild??r);let i=()=>{B.current=!1,n.disconnect(),window.clearTimeout(a),r.removeEventListener("wheel",i),r.removeEventListener("touchmove",i),r.removeEventListener("keydown",i)},a=window.setTimeout(i,1500);return r.addEventListener("wheel",i,{passive:!0}),r.addEventListener("touchmove",i,{passive:!0}),r.addEventListener("keydown",i),i},[r]);let q=(0,V.useMemo)(()=>[...Object.values(Cj.e),Ck],[]),K=(0,V.useMemo)(()=>({a:({href:e,children:r,className:s,node:n,...i})=>{let a="string"==typeof e&&e.startsWith("#");return(0,U.jsx)("a",{href:e,className:(0,e1.cn)("wrap-anywhere font-medium text-primary underline",s),"data-streamdown":"link",...a?{onClick:r=>{r.preventDefault(),O(decodeURIComponent(e.slice(1)))}}:{target:"_blank",rel:"noreferrer"},...i,children:r})}}),[O]);if(e!==S&&(k(e),v("rendered"),_(!1),C(null)),!e)return(0,U.jsx)("div",{className:"flex items-center justify-center h-full text-muted-foreground text-sm",children:"Select a file to preview."});if(s)return(0,U.jsxs)("div",{className:"flex flex-col h-full",children:[(0,U.jsx)("div",{className:"flex items-center justify-between px-4 h-10 border-b flex-shrink-0",children:(0,U.jsx)(C$,{className:"h-4 w-48"})}),(0,U.jsxs)("div",{className:"flex-1 p-4",children:[(0,U.jsx)(C$,{className:"h-4 w-full mb-2"}),(0,U.jsx)(C$,{className:"h-4 w-3/4 mb-2"}),(0,U.jsx)(C$,{className:"h-4 w-5/6 mb-2"}),(0,U.jsx)(C$,{className:"h-4 w-2/3"})]})]});if(!r)return(0,U.jsx)("div",{className:"flex items-center justify-center h-full text-muted-foreground text-sm",children:"Failed to load file."});let X=()=>{e&&aC.api.downloadFile(i,e,a,o,l).catch(e=>{console.error("Failed to download file",e)})},Y=!r.tooLarge&&!r.binary&&!!r.content,G=Ni(e)&&Y,J=Na(e)&&Y,Z=G||J,Q=G&&"rendered"===x,ee=J&&"rendered"===x,et=!r.tooLarge&&!r.binary&&!Q&&!ee&&null!==r.content;return(0,U.jsxs)("div",{className:"flex flex-col h-full",children:[(0,U.jsxs)("div",{className:"flex items-center justify-between px-4 h-10 border-b flex-shrink-0 gap-2",children:[(0,U.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,U.jsx)("span",{className:"text-sm font-mono truncate",children:e}),(0,U.jsx)("span",{className:"text-xs text-muted-foreground shrink-0",children:No(r.size)}),et&&P&&(0,U.jsx)("span",{className:"text-xs text-muted-foreground shrink-0",children:"· plain text"}),g&&(0,U.jsxs)("span",{className:"text-xs text-muted-foreground shrink-0",children:["on ",(0,U.jsx)("span",{className:"text-foreground",children:g})]})]}),(0,U.jsxs)("div",{className:"flex items-center gap-1 shrink-0",children:[ee&&(0,U.jsx)(a$.Button,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>b(e=>e+1),title:"Reload page",children:(0,U.jsx)(xn,{className:"h-3.5 w-3.5"})}),Z&&(0,U.jsx)(a$.Button,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>v(e=>"rendered"===e?"source":"rendered"),title:"rendered"===x?"View source":"View rendered",children:"rendered"===x?(0,U.jsx)(Cm,{className:"h-3.5 w-3.5"}):(0,U.jsx)(S_,{className:"h-3.5 w-3.5"})}),et&&I&&(0,U.jsx)(a$.Button,{variant:"ghost",size:"icon",className:(0,e1.cn)("h-7 w-7",w&&"text-foreground bg-accent"),onClick:()=>_(e=>!e),title:w?"Show as plain text":"Highlight syntax (large file, may pause briefly)",children:(0,U.jsx)(Cx,{className:"h-3.5 w-3.5"})}),et&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(a$.Button,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>E.current?.foldAll(),title:"Fold all",children:(0,U.jsx)(Cg,{className:"h-3.5 w-3.5"})}),(0,U.jsx)(a$.Button,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>E.current?.expandAll(),title:"Expand all",children:(0,U.jsx)(Cv,{className:"h-3.5 w-3.5"})})]}),(0,U.jsx)(a$.Button,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>{navigator.clipboard.writeText(e)},title:"Copy path",children:(0,U.jsx)(mw.Copy,{className:"h-3.5 w-3.5"})}),n&&(0,U.jsx)(a$.Button,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:X,title:"Download",children:(0,U.jsx)(Cf,{className:"h-3.5 w-3.5"})})]})]}),(0,U.jsx)("div",{className:"flex-1 overflow-auto",ref:D,onScroll:H,children:r.tooLarge?(0,U.jsxs)("div",{className:"flex flex-col items-center justify-center h-full gap-3 text-muted-foreground",children:[(0,U.jsx)(Cp,{className:"h-10 w-10"}),(0,U.jsxs)("p",{className:"text-sm",children:["File too large to preview (",No(r.size),")"]}),n&&(0,U.jsxs)(a$.Button,{variant:"outline",size:"sm",onClick:X,children:[(0,U.jsx)(Cf,{className:"h-4 w-4 mr-2"}),"Download"]})]}):r.binary&&C2(e)&&r.size<=0xa00000?(0,U.jsx)(Cq,{projectId:i,filePath:e,branch:a,target:o,sessionId:l,onDownload:X},e):r.binary?(0,U.jsxs)("div",{className:"flex flex-col items-center justify-center h-full gap-3 text-muted-foreground",children:[(0,U.jsx)(Cp,{className:"h-10 w-10"}),(0,U.jsx)("p",{className:"text-sm",children:C2(e)?`Image too large to preview (${No(r.size)})`:`Binary file (${No(r.size)})`}),n&&(0,U.jsxs)(a$.Button,{variant:"outline",size:"sm",onClick:X,children:[(0,U.jsx)(Cf,{className:"h-4 w-4 mr-2"}),"Download"]})]}):ee?(0,U.jsx)(CX,{html:r.content??"",title:e,reloadKey:y}):Q?(0,U.jsx)("div",{className:"p-4",style:{fontSize:"var(--files-content-font-size, 14px)"},ref:F,children:(0,U.jsx)(cz,{components:K,rehypePlugins:q,controls:Nl,children:r.content??""})}):null!==r.content?(0,U.jsx)("div",{className:"h-full [&_pre]:text-[length:var(--files-content-font-size,14px)]! [&_code]:text-[length:var(--files-content-font-size,14px)]!",onMouseDown:A,onClick:R,children:(0,U.jsx)(CB,{ref:E,code:r.content,language:P?"text":Nn(e),showLineNumbers:!0,foldable:!0,scrollToLine:c,scrollKey:d,className:"border-0 rounded-none",children:(0,U.jsx)(Cz,{})})}):(0,U.jsx)("div",{className:"flex items-center justify-center h-full text-muted-foreground text-sm",children:"Empty file."})}),j&&(0,U.jsx)(CU,{projectId:i,symbol:j.symbol,branch:a,target:o,currentFile:e,anchor:{x:j.x,y:j.y},onJump:u,onClose:()=>C(null)})]})}class Nd{capacity;map;constructor(e){if(this.capacity=e,this.map=new Map,e<1)throw Error("LRUCache capacity must be at least 1")}get(e){if(!this.map.has(e))return;let r=this.map.get(e);return this.map.delete(e),this.map.set(e,r),r}has(e){return this.map.has(e)}set(e,r){for(this.map.has(e)&&this.map.delete(e),this.map.set(e,r);this.map.size>this.capacity;){let e=this.map.keys().next().value;if(void 0===e)break;this.map.delete(e)}}delete(e){return this.map.delete(e)}deleteWhere(e){for(let r of[...this.map.keys()])e(r)&&this.map.delete(r)}clear(){this.map.clear()}get size(){return this.map.size}}let Nu="vibedeckx:files:views";function Nh(){return{v:1,views:{}}}function Nf(){try{let e=localStorage.getItem(Nu);if(!e)return Nh();let r=JSON.parse(e);if(!r||1!==r.v||!r.views||"object"!=typeof r.views)return Nh();return r}catch{return Nh()}}function Np(e){try{localStorage.setItem(Nu,JSON.stringify(e))}catch{}}let Nm=[],Ng=new Map,Nx=new Set;function Nv(e){return e.slice(e.lastIndexOf("\0")+1)}function Ny({projectId:e,project:r,selectedBranch:s,navRequest:n,sessionId:i,active:a=!0}){let o=r&&!r.path?"remote":void 0,[l,c]=(0,V.useState)(!1),{settings:d}=(0,c1.useConversationSettings)(),u=(0,V.useRef)(null),[h,f]=(0,V.useState)(!1),p=(0,V.useCallback)(()=>{let e=u.current;e&&(e.isCollapsed()?e.expand():e.collapse())},[]),{rootEntries:m,directoryContents:g,expandedDirs:x,selectedFile:v,fileContent:y,fileLoading:b,rootLoading:w,loadingDirs:_,uploadingDirs:S,deletingPaths:k,jumpTarget:j,revealNonce:C,canGoBack:N,canGoForward:E,fetchRoot:D,refresh:T,reportScroll:R,restoreScroll:A,toggleDirectory:M,navigate:I,jumpTo:P,goBack:F,goForward:L,uploadFiles:O,deleteEntry:B,settled:z}=function({projectId:e,branch:r,target:s,sessionId:n,showHidden:i=!1}){let[a,o]=(0,V.useState)([]),[l,c]=(0,V.useState)(new Map),d=(0,V.useRef)(l);d.current=l;let[u,h]=(0,V.useState)(0),[f,p]=(0,V.useState)(0),[m,g]=(0,V.useState)(new Set),[x,v]=(0,V.useState)(null),[y,b]=(0,V.useState)(null),[w,_]=(0,V.useState)(null),S=(0,V.useRef)(0),[k,j]=(0,V.useState)({entries:[],index:-1}),C=(0,V.useRef)(k);C.current=k;let[N,E]=(0,V.useState)(!1),[D,T]=(0,V.useState)(!1),[R,A]=(0,V.useState)(new Set),[M,I]=(0,V.useState)(new Set),[P,F]=(0,V.useState)(new Set),L=(0,V.useRef)(0),O=(0,V.useRef)(0),B=(0,V.useRef)(new Nd(50)),z=e?[e,r??"",s??""].join("|"):null,$=(0,V.useRef)(z);$.current=z;let W=(0,V.useRef)(x);W.current=x;let H=(0,V.useRef)(0),U=(0,V.useRef)(null),q=(0,V.useRef)(0),[K,X]=(0,V.useState)(null),[Y,G]=(0,V.useState)(null),J=(0,V.useRef)(null),Z=(0,V.useCallback)(i=>[e,r??"",s??"",i.startsWith("/")||i.startsWith("~")?n??"":"",i].join("\0"),[e,r,s,n]),Q=(0,V.useCallback)(()=>{let e,r,s=$.current;if(!s||U.current!==s)return;let n={selectedFile:W.current,history:C.current,scrollTop:H.current};(e=Nf()).views[s]={...n,updatedAt:Date.now()},(r=Object.keys(e.views)).length>30&&r.sort((r,s)=>e.views[r].updatedAt-e.views[s].updatedAt).slice(0,r.length-30).forEach(r=>delete e.views[r]),Np(e)},[]),ee=(0,V.useCallback)(()=>{J.current&&clearTimeout(J.current),J.current=setTimeout(()=>{J.current=null,Q()},300)},[Q]),et=(0,V.useCallback)(e=>{H.current=e,ee()},[ee]);(0,V.useEffect)(()=>{ee()},[x,k,ee]);let er=(0,V.useCallback)(async n=>{if(e&&(g(e=>{let r=new Set(e);return r.has(n)?r.delete(n):r.add(n),r}),!l.has(n))){let a=$.current;A(e=>new Set(e).add(n));try{let o=await aC.api.browseProjectDirectory(e,n,r,s,i);if($.current!==a)return;c(e=>{let r=new Map(e);return r.set(n,o.items),r})}catch(e){console.error("Failed to browse directory:",e),xc.toast.error(`Failed to open ${n}`,{description:e instanceof Error?e.message:String(e)})}finally{A(e=>{let r=new Set(e);return r.delete(n),r})}}},[e,r,s,i,l]),es=(0,V.useCallback)(async n=>{if(!e||n.startsWith("/")||n.startsWith("~"))return;let a=n.split("/").slice(0,-1),o=a.map((e,r)=>a.slice(0,r+1).join("/"));if(0===o.length)return;g(e=>{if(o.every(r=>e.has(r)))return e;let r=new Set(e);for(let e of o)r.add(e);return r});let l=o.filter(e=>!d.current.has(e));if(0===l.length)return;let u=$.current;A(e=>{let r=new Set(e);for(let e of l)r.add(e);return r}),await Promise.all(l.map(async n=>{try{let a=await aC.api.browseProjectDirectory(e,n,r,s,i);if($.current!==u)return;c(e=>{let r=new Map(e);return r.set(n,a.items),r})}catch(e){console.error("Failed to reveal directory:",e)}finally{A(e=>{let r=new Set(e);return r.delete(n),r})}}))},[e,r,s,i]),en=(0,V.useCallback)(async i=>{if(!e)return"failed";let a=Z(i),o=++O.current,l=B.current.get(a);if(l)return b(l),E(!1),"loaded";E(!0),b(null);try{let l=await aC.api.getFileContent(e,i,r,s,n);if(o!==O.current)return"stale";return B.current.set(a,l),b(l),"loaded"}catch(e){if(o!==O.current)return"stale";return console.error("Failed to get file content:",e),b(null),"failed"}finally{o===O.current&&E(!1)}},[e,r,s,n,Z]),ei=(0,V.useCallback)(async r=>{e&&(v(r),p(e=>e+1),await en(r))},[e,en]),ea=(0,V.useRef)(en);ea.current=en;let eo=(0,V.useCallback)(async()=>{if(!e)return"stale";T(!0);let n=++L.current;try{let a=await aC.api.browseProjectDirectory(e,void 0,r,s,i);if(n!==L.current)return"stale";return o(a.items),c(new Map),g(new Set),h(e=>e+1),"loaded"}catch(e){if(console.error("Failed to browse root directory:",e),n!==L.current)return"stale";return o([]),xc.toast.error("Failed to browse files",{description:e instanceof Error?e.message:String(e)}),"failed"}finally{n===L.current&&T(!1)}},[e,r,s,i]),el=(0,V.useCallback)(async()=>{let r;if(!e)return;let s=await eo();if("stale"===s)return;let n=$.current;if("failed"===s){U.current!==n&&(++O.current,E(!1),v(null),b(null),j({entries:[],index:-1}),H.current=0),G(n);return}let i=n?(r=Nf().views[n])&&"object"==typeof r&&(null===r.selectedFile||"string"==typeof r.selectedFile)&&r.history&&"object"==typeof r.history&&Array.isArray(r.history.entries)&&"number"==typeof r.history.index?{selectedFile:r.selectedFile,history:r.history,scrollTop:"number"==typeof r.scrollTop&&Number.isFinite(r.scrollTop)?r.scrollTop:0}:null:null;if(n&&i&&i.selectedFile){if(j(i.history.entries.length?i.history:{entries:[{path:i.selectedFile,line:null}],index:0}),H.current=i.scrollTop,X({top:i.scrollTop,nonce:++q.current}),v(i.selectedFile),U.current=n,G(n),"failed"===await ea.current(i.selectedFile)){let e;v(null),j({entries:[],index:-1}),H.current=0,(e=Nf()).views[n]&&(delete e.views[n],Np(e))}}else++O.current,E(!1),v(null),b(null),j({entries:[],index:-1}),H.current=0,U.current=n,G(n)},[e,eo]),ec=(0,V.useCallback)(async()=>{if(!e||(B.current.clear(),"loaded"!==await eo()))return;let r=W.current;r&&await en(r)},[e,eo,en]),ed=(0,V.useCallback)(async(e,r=null)=>{j(({entries:s,index:n})=>{let i=s[n];if(i&&i.path===e){let i=s.slice();return i[n]={path:e,line:r},{entries:i,index:n}}let a=s.slice(0,n+1);return{entries:[...a,{path:e,line:r}],index:a.length}}),await ei(e),null!=r&&_({line:r,nonce:++S.current})},[ei]),eu=(0,V.useCallback)((e,r)=>ed(e,r),[ed]),eh=(0,V.useCallback)(()=>{let{entries:e,index:r}=C.current;if(r<=0)return;let s=e[r-1];j(e=>({...e,index:e.index-1})),ei(s.path),null!=s.line&&_({line:s.line,nonce:++S.current})},[ei]),ef=(0,V.useCallback)(()=>{let{entries:e,index:r}=C.current;if(r>=e.length-1)return;let s=e[r+1];j(e=>({...e,index:e.index+1})),ei(s.path),null!=s.line&&_({line:s.line,nonce:++S.current})},[ei]),ep=(0,V.useCallback)(async n=>{if(!e)return;let a=$.current;if(""===n){let n=await aC.api.browseProjectDirectory(e,void 0,r,s,i);if($.current!==a)return;o(n.items)}else{let o=await aC.api.browseProjectDirectory(e,n,r,s,i);if($.current!==a)return;c(e=>{let r=new Map(e);return r.set(n,o.items),r})}},[e,r,s,i]),em=(0,V.useCallback)(async(n,i)=>{if(!e||0===i.length)return;let a=$.current;I(e=>new Set(e).add(n));try{let{uploaded:o}=await aC.api.uploadFiles(e,i,n,r,s),l=new Set(o.map(e=>n?`${n}/${e}`:e));B.current.deleteWhere(e=>l.has(Nv(e))),$.current===a&&(""!==n&&g(e=>new Set(e).add(n)),await ep(n)),xc.toast.success(`Uploaded ${o.length} file${1===o.length?"":"s"}`)}catch(e){console.error("Failed to upload files:",e),xc.toast.error("Upload failed",{description:e instanceof Error?e.message:String(e)})}finally{I(e=>{let r=new Set(e);return r.delete(n),r})}},[e,r,s,ep]),eg=(0,V.useCallback)(async n=>{if(!e||!n)return;let i=$.current;F(e=>new Set(e).add(n));try{if(await aC.api.deleteFile(e,n,r,s),B.current.deleteWhere(e=>{let r=Nv(e);return r===n||r.startsWith(`${n}/`)}),$.current===i){v(e=>e===n||e&&e.startsWith(`${n}/`)?(b(null),null):e);let e=n.includes("/")?n.slice(0,n.lastIndexOf("/")):"";await ep(e)}xc.toast.success("Deleted")}catch(e){console.error("Failed to delete:",e),xc.toast.error("Delete failed",{description:e instanceof Error?e.message:String(e)})}finally{F(e=>{let r=new Set(e);return r.delete(n),r})}},[e,r,s,ep]),ex=null!==z&&Y===z,ev=ex?x:null;return(0,V.useEffect)(()=>{ev&&es(ev)},[ev,u,f]),{rootEntries:ex?a:Nm,directoryContents:ex?l:Ng,expandedDirs:ex?m:Nx,selectedFile:ex?x:null,fileContent:ex?y:null,fileLoading:ex&&N,rootLoading:D||null!==e&&!ex,settled:ex,loadingDirs:R,uploadingDirs:M,deletingPaths:P,jumpTarget:ex?w:null,revealNonce:f,canGoBack:ex&&k.index>0,canGoForward:ex&&k.index<k.entries.length-1,fetchRoot:el,refresh:ec,reportScroll:et,restoreScroll:ex?K:null,toggleDirectory:er,selectFile:ei,navigate:ed,jumpTo:eu,goBack:eh,goForward:ef,uploadFiles:em,refreshDirectory:ep,deleteEntry:eg}}({projectId:e,branch:s,target:o,sessionId:i,showHidden:l}),$=function({projectId:e,branch:r,target:s}){let[n,i]=(0,V.useState)([]),[a,o]=(0,V.useState)(!1),[l,c]=(0,V.useState)(!1),[d,u]=(0,V.useState)(!1),[h,f]=(0,V.useState)(""),p=(0,V.useRef)(0);(0,V.useEffect)(()=>{i([]),o(!1),u(!1),c(!1),f(""),p.current++},[e,r,s]);let m=(0,V.useCallback)(async()=>{if(!e)return;c(!0);let n=++p.current;try{let a=await aC.api.listProjectFiles(e,r,s);if(n!==p.current)return;i(a.files),o(a.truncated),u(!0)}catch(e){if(n!==p.current)return;i([]),u(!1),xc.toast.error("Failed to load file list",{description:e instanceof Error?e.message:String(e)})}finally{n===p.current&&c(!1)}},[e,r,s]),g=(0,V.useCallback)(()=>{d||l||m()},[d,l,m]),x=(0,V.useCallback)(()=>{u(!1),p.current++,h&&m()},[h,m]),v=(0,V.useDeferredValue)(h);return{query:h,setQuery:f,results:(0,V.useMemo)(()=>(function(e,r,s){if(!r.trim())return[];let n=[];for(let s of e){let e=dB(r,s);null!==e&&n.push({path:s,score:e})}return n.sort((e,r)=>r.score-e.score||e.path.length-r.path.length),n.slice(0,50)})(n,v,0),[n,v]),truncated:a,loading:l,loaded:d,ensureLoaded:g,refresh:x}}({projectId:e,branch:s,target:o});(0,V.useEffect)(()=>{D()},[D]);let W=(0,V.useRef)(null);(0,V.useEffect)(()=>{n&&z&&W.current!==n.nonce&&(W.current=n.nonce,null!=n.line?P(n.path,n.line):I(n.path))},[n?.nonce,z]);let H=(0,V.useCallback)(()=>{T(),$.refresh()},[T,$]),q=(0,V.useCallback)(e=>{I(e),$.setQuery("")},[I,$]);if(!e)return(0,U.jsx)("div",{className:"flex items-center justify-center h-full text-muted-foreground",children:(0,U.jsxs)("div",{className:"text-center",children:[(0,U.jsx)("div",{className:"mx-auto w-10 h-10 rounded-xl bg-muted flex items-center justify-center mb-3",children:(0,U.jsx)(m_,{className:"h-5 w-5 text-muted-foreground/50"})}),(0,U.jsx)("p",{className:"text-sm",children:"Select a project to browse files."})]})});let K=v&&e?aC.api.getFileDownloadUrl(e,v,s,o,i):null;return(0,U.jsxs)("div",{className:"flex flex-col h-full",style:{"--files-tree-font-size":`${d.filesTreeFontSize}px`,"--files-content-font-size":`${d.filesContentFontSize}px`},children:[(0,U.jsx)(d8,{title:"Files",actions:(0,U.jsxs)("div",{className:"flex items-center gap-1",children:[(0,U.jsx)(a$.Button,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-foreground",onClick:p,title:h?"Show file tree":"Hide file tree","aria-pressed":!h,children:h?(0,U.jsx)(mu,{className:"h-3.5 w-3.5"}):(0,U.jsx)(md,{className:"h-3.5 w-3.5"})}),(0,U.jsx)(a$.Button,{variant:"ghost",size:"icon",className:`h-7 w-7 hover:text-foreground ${l?"text-foreground":"text-muted-foreground"}`,onClick:()=>c(e=>!e),title:l?"Hide hidden files":"Show hidden files","aria-pressed":l,children:l?(0,U.jsx)(S_,{className:"h-3.5 w-3.5"}):(0,U.jsx)(SS,{className:"h-3.5 w-3.5"})}),(0,U.jsx)(a$.Button,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-foreground",onClick:F,disabled:!N,title:"Back",children:(0,U.jsx)(lu.ArrowLeft,{className:"h-3.5 w-3.5"})}),(0,U.jsx)(a$.Button,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-foreground",onClick:L,disabled:!E,title:"Forward",children:(0,U.jsx)(j3,{className:"h-3.5 w-3.5"})}),(0,U.jsx)(a$.Button,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-foreground",onClick:H,title:"Refresh",children:(0,U.jsx)(m_,{className:`h-3.5 w-3.5 ${w?"animate-spin":""}`})})]})}),(0,U.jsxs)(hu,{direction:"horizontal",autoSaveId:"files-panels",className:"flex-1",children:[(0,U.jsx)(uf,{ref:u,collapsible:!0,collapsedSize:0,defaultSize:33,minSize:20,onCollapse:()=>f(!0),onExpand:()=>f(!1),children:(0,U.jsxs)(p$,{shouldFilter:!1,className:"flex h-full flex-col bg-transparent",children:[(0,U.jsx)("div",{className:"flex h-10 shrink-0 items-center border-b px-2",children:(0,U.jsxs)(j4,{className:"h-8",children:[(0,U.jsx)(j7,{children:(0,U.jsx)(aK,{className:"h-3.5 w-3.5"})}),(0,U.jsx)(Ce,{type:"search",name:"files-search",autoComplete:"off","data-1p-ignore":!0,"data-lpignore":"true","data-form-type":"other",readOnly:!0,onFocus:e=>{e.currentTarget.removeAttribute("readonly"),$.ensureLoaded()},placeholder:"Search files...",value:$.query,onChange:e=>$.setQuery(e.target.value)}),$.query&&(0,U.jsx)(j7,{align:"inline-end",children:(0,U.jsx)(j9,{size:"icon-xs","aria-label":"Clear search",onClick:()=>$.setQuery(""),children:(0,U.jsx)(rD,{className:"h-3.5 w-3.5"})})})]})}),$.query?(0,U.jsx)(pU,{className:"max-h-none flex-1",children:$.loading&&0===$.results.length?(0,U.jsxs)("div",{className:"flex items-center justify-center gap-2 py-6 text-sm text-muted-foreground",children:[(0,U.jsx)(aP,{className:"h-4 w-4 animate-spin"}),"Loading files…"]}):0===$.results.length?(0,U.jsx)("div",{className:"py-6 text-center text-sm text-muted-foreground",children:"No matching files."}):(0,U.jsxs)(U.Fragment,{children:[$.results.map(e=>{let r=e.path.lastIndexOf("/"),s=r>=0?e.path.slice(0,r+1):"",n=r>=0?e.path.slice(r+1):e.path;return(0,U.jsxs)(pK,{value:e.path,onSelect:()=>q(e.path),className:"flex-col items-start gap-0 text-[length:var(--files-tree-font-size,14px)]!",children:[(0,U.jsx)("span",{className:"font-medium",children:n}),s&&(0,U.jsx)("span",{className:"w-full truncate text-xs text-muted-foreground",children:s})]},e.path)}),$.truncated&&(0,U.jsx)("div",{className:"px-2 py-2 text-xs text-muted-foreground",children:"Showing first 50,000 files — refine your search to narrow results."})]})}):(0,U.jsx)("div",{className:"flex-1 overflow-hidden",children:(0,U.jsx)(Ch,{entries:m,expandedDirs:x,directoryContents:g,loadingDirs:_,selectedFile:v,revealNonce:C,uploadingDirs:S,rootLoading:w,deletingPaths:k,onToggleDirectory:M,onSelectFile:I,onUploadFiles:O,onDeleteEntry:B})})]})}),(0,U.jsx)(hh,{disabled:!a}),(0,U.jsx)(uf,{defaultSize:67,minSize:25,children:(0,U.jsx)("div",{className:"h-full overflow-hidden",children:(0,U.jsx)(Nc,{filePath:v,fileContent:y,loading:b,downloadUrl:K,projectId:e,branch:s,target:o,sessionId:i,scrollToLine:j?.line??null,scrollKey:j?.nonce,onJump:P,restoreScrollTop:A?.top??null,restoreScrollKey:A?.nonce,onScroll:R})})})]})]})}let Nb=0;function Nw(e){let r=e.lastIndexOf("/");return r>=0?e.slice(r+1):e}function N_(e,r){let s=`idx-${++Nb}`,n=new Set(e),i=r?r.replace(/\/+$/,"")+"/":null,a=new Map;for(let r of e){let e=Nw(r),s=a.get(e);s?s.push(r):a.set(e,[r])}return{version:s,resolve(e){if(!e)return[];if(i&&(e.startsWith("/")||e.startsWith("~/"))){if(!e.startsWith(i))return[];let r=e.slice(i.length);return n.has(r)?[r]:[]}let r=e.replace(/^\/+/,"");if(!r)return[];if(r.includes("/")){if(n.has(r))return[r];let e=Nw(r);return(a.get(e)??[]).filter(e=>e===r||e.endsWith("/"+r)||r.endsWith("/"+e))}return a.get(r)??[]}}}let NS=[500,1e3,2e3,4e3,8e3];async function Nk(e,r={}){let s=r.delaysMs??NS,n=r.sleep??(e=>new Promise(r=>setTimeout(r,e))),i=r.cancelled??(()=>!1);for(let r=0;;r++){if(i())return null;let a=null;try{a=await e()}catch{a=null}if(i())return null;if(a&&a.files.length>0||r>=s.length)return a;await n(s[r])}}let Nj=(0,V.createContext)({active:!1,requestNonce:0}),NC=Nj.Provider,NN={agent:aA,executors:xb,diff:ao,terminal:my,preview:oC,files:o_},NE=q.map(e=>({...e,icon:NN[e.id]})),ND=()=>()=>{},NT=V.useLayoutEffect;function NR({projectId:e,selectedBranch:r,onMergeRequest:s,project:n,onExecutorModeChange:i,agentSlot:a,activateAgentTabNonce:o,diffCompareNonce:l,terminalRequest:c,fileOpenRequest:d,mergeTarget:u,forceAgentTab:h=!1,active:f=!0,agentSessionId:p=null,onAgentTabActiveChange:m}){let[g,x]=function(e,r){let s=`vibedeckx:activeTab:${e??"none"}:${r??"main"}`,[n,i]=(0,V.useState)(()=>localStorage.getItem(s)??"agent");return NT(()=>{i(localStorage.getItem(s)??"agent")},[s]),[n,(0,V.useCallback)(e=>{i(e),localStorage.setItem(s,e)},[s])]}(e,r),v=h?"agent":g,y=(0,V.useRef)(o);NT(()=>{void 0===o||y.current!==o&&(y.current=o,x("agent"))},[o,x]);let b=(0,V.useRef)(l);NT(()=>{void 0===l||b.current!==l&&(b.current=l,x("diff"))},[l,x]);let w=(0,V.useRef)(c?.nonce);NT(()=>{null==c||w.current!==c.nonce&&(w.current=c.nonce,x("terminal"))},[c,x]);let[_,S]=(0,V.useState)(0),k=(0,V.useCallback)(()=>S(e=>e+1),[]),j=(0,V.useRef)(null),C=(0,V.useRef)(!1),[N,E]=(0,V.useState)(0),D=(0,V.useCallback)(()=>{C.current=!0,E(e=>e+1)},[]);NT(()=>{!C.current||(C.current=!1,f&&null!==e&&"executors"===v&&j.current?.focus({preventScroll:!0}))},[f,v,N,e]);let{region:T,setRegion:R}=dJ(),A="right-panel"===T;(0,V.useEffect)(()=>{if(!f)return;let e=e=>{let r=Q(e);r&&(e.preventDefault(),x(r),R("right-panel"),"agent"===r&&k(),"executors"===r&&D())};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[f,x,R,k,D]);let M=(0,V.useSyncExternalStore)(ND,X,()=>!1),I=n&&!n.path?"remote":void 0,P=function({projectId:e,branch:r,target:s,enabled:n=!0}){let[i,a]=(0,V.useState)(null),o=(0,V.useRef)(0),l=(0,V.useRef)(0),c=(0,V.useRef)(null);return(0,V.useEffect)(()=>{if(a(null),!n||!e)return;let i=++o.current;return Nk(()=>aC.api.listProjectFiles(e,r,s),{cancelled:()=>i!==o.current}).then(e=>{i===o.current&&a(e?N_(e.files,e.root):N_([]))}),()=>{null!==c.current&&(clearTimeout(c.current),c.current=null)}},[e,r,s,n]),(0,aF.useGlobalEventStream)(i=>{if(!n||!e)return;let d="session:taskCompleted"===i.type||"session:finished"===i.type,u="files:changed"===i.type;if(!d&&!u||i.projectId!==e||(i.branch??null)!==(r??null))return;null!==c.current&&clearTimeout(c.current);let h=o.current;c.current=setTimeout(()=>{c.current=null;let n=++l.current;aC.api.listProjectFiles(e,r,s).then(e=>{h===o.current&&n===l.current&&a(N_(e.files,e.root))}).catch(()=>{})},250)}),i}({projectId:e,branch:r,target:I,enabled:f}),F=(0,V.useRef)(0),[L,O]=(0,V.useState)(null),B=(0,V.useCallback)((e,r=null)=>{x("files"),O({path:e,line:r,nonce:++F.current})},[x]),z=(0,V.useMemo)(()=>e?{projectId:e,branch:r??null,target:I,sessionId:p}:null,[e,r,I,p]),$=(0,V.useMemo)(()=>({openFile:B,index:P,scope:z}),[B,P,z]),W=(0,V.useRef)(d?.nonce);NT(()=>{d&&W.current!==d.nonce&&(r??null)===d.branch&&(W.current=d.nonce,B(d.path,d.line))},[d,r,B]);let H=(0,V.useMemo)(()=>({active:f&&null!==e&&"agent"===v,requestNonce:_}),[f,e,v,_]);return(0,V.useEffect)(()=>{m?.(H.active)},[H.active,m]),(0,U.jsx)(jO,{value:$,children:(0,U.jsxs)("div",{"data-focus-region":"right-panel",className:"h-full flex flex-col",children:[(0,U.jsx)("div",{className:"flex items-center px-3 gap-4 border-b border-border",children:NE.map(({id:e,icon:r,label:s,code:n})=>(0,U.jsxs)(V.Fragment,{children:[(0,U.jsxs)("button",{onClick:()=>{x(e),"agent"===e&&k(),"executors"===e&&D()},title:`${s} (${et(M,n)})`,className:(0,e1.cn)("flex items-center gap-0.5 py-2.5 text-xs font-medium border-b-2 transition-colors",v===e?(0,e1.cn)("text-foreground",A?"border-primary":"border-foreground/25"):"text-muted-foreground border-transparent hover:text-foreground/70"),children:[(0,U.jsx)(r,{className:"h-3.5 w-3.5"}),s]}),"agent"===e&&(0,U.jsx)("span",{className:"h-4 w-px bg-border/60 mx-1.5","aria-hidden":!0})]},e))}),(0,U.jsxs)("div",{className:"relative flex-1 overflow-hidden",children:[(0,U.jsx)("div",{className:(0,e1.cn)("absolute inset-0 overflow-hidden","agent"!==v&&"invisible pointer-events-none"),children:(0,U.jsx)(NC,{value:H,children:a})}),(0,U.jsx)("div",{ref:j,tabIndex:-1,className:(0,e1.cn)("absolute inset-0 overflow-hidden outline-hidden","executors"!==v&&"hidden"),children:(0,U.jsx)(jA,{projectId:e,selectedBranch:r,project:n,onExecutorModeChange:i,locateActive:f&&"executors"===v})}),(0,U.jsx)("div",{className:(0,e1.cn)("absolute inset-0 overflow-hidden","diff"!==v&&"hidden"),children:(0,U.jsx)(jX,{projectId:e,selectedBranch:r,onMergeRequest:s,project:n,mergeTarget:u,compareRequestNonce:l})}),(0,U.jsx)("div",{className:(0,e1.cn)("absolute inset-0 overflow-hidden","terminal"!==v&&"hidden"),children:(0,U.jsx)(jJ,{projectId:e,selectedBranch:r,project:n,active:f&&"terminal"===v,createRequest:c})}),(0,U.jsx)("div",{className:(0,e1.cn)("absolute inset-0 overflow-hidden","preview"!==v&&"hidden"),children:(0,U.jsx)(j2,{projectId:e,selectedBranch:r,project:n})}),(0,U.jsx)("div",{className:(0,e1.cn)("absolute inset-0 overflow-hidden","files"!==v&&"hidden"),children:(0,U.jsx)(Ny,{projectId:e,project:n,selectedBranch:r,navRequest:L,sessionId:p,active:"files"===v})})]})]})})}var NA=Symbol.for("immer-nothing"),NM=Symbol.for("immer-draftable"),NI=Symbol.for("immer-state");function NP(e){throw Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var NF=Object.getPrototypeOf;function NL(e){return!!e&&!!e[NI]}function NO(e){return!!e&&(N$(e)||Array.isArray(e)||!!e[NM]||!!e.constructor?.[NM]||Nq(e)||NK(e))}var NB=Object.prototype.constructor.toString(),Nz=new WeakMap;function N$(e){if(!e||"object"!=typeof e)return!1;let r=Object.getPrototypeOf(e);if(null===r||r===Object.prototype)return!0;let s=Object.hasOwnProperty.call(r,"constructor")&&r.constructor;if(s===Object)return!0;if("function"!=typeof s)return!1;let n=Nz.get(s);return void 0===n&&(n=Function.toString.call(s),Nz.set(s,n)),n===NB}function NW(e,r,s=!0){0===NH(e)?(s?Reflect.ownKeys(e):Object.keys(e)).forEach(s=>{r(s,e[s],e)}):e.forEach((s,n)=>r(n,s,e))}function NH(e){let r=e[NI];return r?r.type_:Array.isArray(e)?1:Nq(e)?2:3*!!NK(e)}function NU(e,r){return 2===NH(e)?e.has(r):Object.prototype.hasOwnProperty.call(e,r)}function NV(e,r,s){let n=NH(e);2===n?e.set(r,s):3===n?e.add(s):e[r]=s}function Nq(e){return e instanceof Map}function NK(e){return e instanceof Set}function NX(e){return e.copy_||e.base_}function NY(e,r){if(Nq(e))return new Map(e);if(NK(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);let s=N$(e);if(!0!==r&&("class_only"!==r||s)){let r=NF(e);return null!==r&&s?{...e}:Object.assign(Object.create(r),e)}{let r=Object.getOwnPropertyDescriptors(e);delete r[NI];let s=Reflect.ownKeys(r);for(let n=0;n<s.length;n++){let i=s[n],a=r[i];!1===a.writable&&(a.writable=!0,a.configurable=!0),(a.get||a.set)&&(r[i]={configurable:!0,writable:!0,enumerable:a.enumerable,value:e[i]})}return Object.create(NF(e),r)}}function NG(e,r=!1){return NZ(e)||NL(e)||!NO(e)||(NH(e)>1&&Object.defineProperties(e,{set:NJ,add:NJ,clear:NJ,delete:NJ}),Object.freeze(e),r&&Object.values(e).forEach(e=>NG(e,!0))),e}var NJ={value:function(){NP(2)}};function NZ(e){return null===e||"object"!=typeof e||Object.isFrozen(e)}var NQ={};function N0(e){let r=NQ[e];return r||NP(0,e),r}function N1(e,r){r&&(N0("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=r)}function N2(e){N5(e),e.drafts_.forEach(N4),e.drafts_=null}function N5(e){e===W&&(W=e.parent_)}function N3(e){return W={drafts_:[],parent_:W,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function N4(e){let r=e[NI];0===r.type_||1===r.type_?r.revoke_():r.revoked_=!0}function N6(e,r){r.unfinalizedDrafts_=r.drafts_.length;let s=r.drafts_[0];return void 0!==e&&e!==s?(s[NI].modified_&&(N2(r),NP(4)),NO(e)&&(e=N7(r,e),r.parent_||N9(r,e)),r.patches_&&N0("Patches").generateReplacementPatches_(s[NI].base_,e,r.patches_,r.inversePatches_)):e=N7(r,s,[]),N2(r),r.patches_&&r.patchListener_(r.patches_,r.inversePatches_),e!==NA?e:void 0}function N7(e,r,s){if(NZ(r))return r;let n=e.immer_.shouldUseStrictIteration(),i=r[NI];if(!i)return NW(r,(n,a)=>N8(e,i,r,n,a,s),n),r;if(i.scope_!==e)return r;if(!i.modified_)return N9(e,i.base_,!0),i.base_;if(!i.finalized_){i.finalized_=!0,i.scope_.unfinalizedDrafts_--;let r=i.copy_,a=r,o=!1;3===i.type_&&(a=new Set(r),r.clear(),o=!0),NW(a,(n,a)=>N8(e,i,r,n,a,s,o),n),N9(e,r,!1),s&&e.patches_&&N0("Patches").generatePatches_(i,s,e.patches_,e.inversePatches_)}return i.copy_}function N8(e,r,s,n,i,a,o){if(null==i||"object"!=typeof i&&!o)return;let l=NZ(i);if(!l||o){if(NL(i)){let o=N7(e,i,a&&r&&3!==r.type_&&!NU(r.assigned_,n)?a.concat(n):void 0);if(NV(s,n,o),!NL(o))return;e.canAutoFreeze_=!1}else o&&s.add(i);if(NO(i)&&!l){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1||r&&r.base_&&r.base_[n]===i&&l)return;N7(e,i),(!r||!r.scope_.parent_)&&"symbol"!=typeof n&&(Nq(s)?s.has(n):Object.prototype.propertyIsEnumerable.call(s,n))&&N9(e,i)}}}function N9(e,r,s=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&NG(r,s)}var Ee={get(e,r){if(r===NI)return e;let s=NX(e);if(!NU(s,r)){var n;let i;return n=e,(i=Es(s,r))?"value"in i?i.value:i.get?.call(n.draft_):void 0}let i=s[r];return e.finalized_||!NO(i)?i:i===Er(e.base_,r)?(Ei(e),e.copy_[r]=Ea(i,e)):i},has:(e,r)=>r in NX(e),ownKeys:e=>Reflect.ownKeys(NX(e)),set(e,r,s){let n=Es(NX(e),r);if(n?.set)return n.set.call(e.draft_,s),!0;if(!e.modified_){let n=Er(NX(e),r),i=n?.[NI];if(i&&i.base_===s)return e.copy_[r]=s,e.assigned_[r]=!1,!0;if((s===n?0!==s||1/s==1/n:s!=s&&n!=n)&&(void 0!==s||NU(e.base_,r)))return!0;Ei(e),En(e)}return!!(e.copy_[r]===s&&(void 0!==s||r in e.copy_)||Number.isNaN(s)&&Number.isNaN(e.copy_[r]))||(e.copy_[r]=s,e.assigned_[r]=!0,!0)},deleteProperty:(e,r)=>(void 0!==Er(e.base_,r)||r in e.base_?(e.assigned_[r]=!1,Ei(e),En(e)):delete e.assigned_[r],e.copy_&&delete e.copy_[r],!0),getOwnPropertyDescriptor(e,r){let s=NX(e),n=Reflect.getOwnPropertyDescriptor(s,r);return n?{writable:!0,configurable:1!==e.type_||"length"!==r,enumerable:n.enumerable,value:s[r]}:n},defineProperty(){NP(11)},getPrototypeOf:e=>NF(e.base_),setPrototypeOf(){NP(12)}},Et={};function Er(e,r){let s=e[NI];return(s?NX(s):e)[r]}function Es(e,r){if(!(r in e))return;let s=NF(e);for(;s;){let e=Object.getOwnPropertyDescriptor(s,r);if(e)return e;s=NF(s)}}function En(e){!e.modified_&&(e.modified_=!0,e.parent_&&En(e.parent_))}function Ei(e){e.copy_||(e.copy_=NY(e.base_,e.scope_.immer_.useStrictShallowCopy_))}function Ea(e,r){let s=Nq(e)?N0("MapSet").proxyMap_(e,r):NK(e)?N0("MapSet").proxySet_(e,r):function(e,r){let s=Array.isArray(e),n={type_:+!!s,scope_:r?r.scope_:W,modified_:!1,finalized_:!1,assigned_:{},parent_:r,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1},i=n,a=Ee;s&&(i=[n],a=Et);let{revoke:o,proxy:l}=Proxy.revocable(i,a);return n.draft_=l,n.revoke_=o,l}(e,r);return(r?r.scope_:W).drafts_.push(s),s}NW(Ee,(e,r)=>{Et[e]=function(){return arguments[0]=arguments[0][0],r.apply(this,arguments)}}),Et.deleteProperty=function(e,r){return Et.set.call(this,e,r,void 0)},Et.set=function(e,r,s){return Ee.set.call(this,e[0],r,s,e[0])};var Eo=new class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!0,this.produce=(e,r,s)=>{let n;if("function"==typeof e&&"function"!=typeof r){let s=r;r=e;let n=this;return function(e=s,...i){return n.produce(e,e=>r.call(this,e,...i))}}if("function"!=typeof r&&NP(6),void 0!==s&&"function"!=typeof s&&NP(7),NO(e)){let i=N3(this),a=Ea(e,void 0),o=!0;try{n=r(a),o=!1}finally{o?N2(i):N5(i)}return N1(i,s),N6(n,i)}if(e&&"object"==typeof e)NP(1,e);else{if(void 0===(n=r(e))&&(n=e),n===NA&&(n=void 0),this.autoFreeze_&&NG(n,!0),s){let r=[],i=[];N0("Patches").generateReplacementPatches_(e,n,r,i),s(r,i)}return n}},this.produceWithPatches=(e,r)=>{let s,n;return"function"==typeof e?(r,...s)=>this.produceWithPatches(r,r=>e(r,...s)):[this.produce(e,r,(e,r)=>{s=e,n=r}),s,n]},"boolean"==typeof e?.autoFreeze&&this.setAutoFreeze(e.autoFreeze),"boolean"==typeof e?.useStrictShallowCopy&&this.setUseStrictShallowCopy(e.useStrictShallowCopy),"boolean"==typeof e?.useStrictIteration&&this.setUseStrictIteration(e.useStrictIteration)}createDraft(e){var r;NO(e)||NP(8),NL(e)&&(NL(r=e)||NP(10,r),e=function e(r){let s;if(!NO(r)||NZ(r))return r;let n=r[NI],i=!0;if(n){if(!n.modified_)return n.base_;n.finalized_=!0,s=NY(r,n.scope_.immer_.useStrictShallowCopy_),i=n.scope_.immer_.shouldUseStrictIteration()}else s=NY(r,!0);return NW(s,(r,n)=>{NV(s,r,e(n))},i),n&&(n.finalized_=!1),s}(r));let s=N3(this),n=Ea(e,void 0);return n[NI].isManual_=!0,N5(s),n}finishDraft(e,r){let s=e&&e[NI];s&&s.isManual_||NP(9);let{scope_:n}=s;return N1(n,r),N6(void 0,n)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}setUseStrictIteration(e){this.useStrictIteration_=e}shouldUseStrictIteration(){return this.useStrictIteration_}applyPatches(e,r){let s;for(s=r.length-1;s>=0;s--){let n=r[s];if(0===n.path.length&&"replace"===n.op){e=n.value;break}}s>-1&&(r=r.slice(s+1));let n=N0("Patches").applyPatches_;return NL(e)?n(e,r):this.produce(e,e=>n(e,r))}}().produce;let El="vibedeckx:pending-submissions";function Ec(){try{let e=window.sessionStorage.getItem(El);if(!e)return new Map;let r=JSON.parse(e);if(!Array.isArray(r))return new Map;let s=new Map;for(let e of r)e&&"object"==typeof e&&"string"==typeof e.workspaceKey&&"string"==typeof e.operationId&&s.set(e.workspaceKey,e);return s}catch{return new Map}}function Ed(e){try{0===e.size?window.sessionStorage.removeItem(El):window.sessionStorage.setItem(El,JSON.stringify([...e.values()]))}catch{}}function Eu(e){return Ec().get(e)??null}function Eh(e){let r=Ec(),s=r.get(e.workspaceKey)??null;return r.set(e.workspaceKey,e),Ed(r),s&&s.operationId!==e.operationId?s:null}function Ef(e,r){let s=Ec(),n=s.get(e);return!!n&&n.operationId===r&&(s.delete(e),Ed(s),!0)}let Ep="claude-code",Em={"claude-code":{displayName:"Claude Code",messageName:"Claude",Icon:aA,accentText:"text-violet-500",avatarBackground:"bg-violet-500/10",branchAccent:"bg-violet-500/10 text-violet-600"},codex:{displayName:"Codex",messageName:"Codex",Icon:aA,accentText:"text-green-500",avatarBackground:"bg-green-500/10",branchAccent:"bg-emerald-500/10 text-emerald-600"}};function Eg(e,r=[]){let s=Object.hasOwn(Em,e)?Em[e]:void 0,n=r.find(r=>r.type===e)?.displayName??s?.displayName??e;return s?{...s,displayName:n}:{displayName:n,messageName:n,Icon:aA,accentText:"text-muted-foreground",avatarBackground:"bg-muted",branchAccent:"bg-muted text-muted-foreground"}}let Ex="vibedeckx:placeholder-workspaces";function Ev(e){try{window.localStorage.setItem(Ex,JSON.stringify([...e]))}catch{}}let Ey=function(){try{let e=window.localStorage.getItem(Ex);if(!e)return new Map;let r=JSON.parse(e);if(!Array.isArray(r))return new Map;let s=new Map;for(let e of r)if(Array.isArray(e)&&"string"==typeof e[0]&&"number"==typeof e[1]){let r=e[0].endsWith(":")?`${e[0]}local`:e[0];s.set(r,e[1])}else if("string"==typeof e){let r=e.endsWith(":")?`${e}local`:e;s.set(r,Date.now())}return s}catch{return new Map}}(),Eb=new Set,Ew=new Map;function E_(){for(let e of Eb)e()}function ES(e){return Eb.add(e),()=>{Eb.delete(e)}}function Ek(){return Ey}function Ej(){return Ew}function EC(e,r,s){return`${e}:${r??""}:${s||"local"}`}function EN(e){return Ey.has(e)}function EE(e){let r=new Map(Ey);r.set(e,Date.now()),Ev(Ey=r),E_()}function ED(e){if(!Ey.has(e))return!1;let r=new Map(Ey);return r.delete(e),Ev(Ey=r),E_(),!0}function ET(e,r,s,n){return e?{projectId:e,branch:r,agentMode:s||"local",explicitSessionId:n??null}:null}function ER(e,r){return e.projectId===r.projectId&&e.branch===r.branch&&e.agentMode===r.agentMode&&e.explicitSessionId===r.explicitSessionId}function EA(){return"localhost"===window.location.hostname&&"3000"===window.location.port?"http://localhost:5173":""}async function EM(e,r,s,n){let i=await (0,aC.authFetch)(`${EA()}/api/projects/${e}/agent-sessions`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({branch:r,permissionMode:s,agentType:n,historyTurns:5})});if(!i.ok)throw Error("Failed to load session");return i.json()}async function EI(e,r,s){let n,i=crypto.randomUUID();try{n=await (0,aC.authFetch)(`${EA()}/api/agent-sessions/${e}/message`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:r,idempotencyKey:i,...s?{grantedRemoteIds:s}:{}})})}catch(r){if(r instanceof TypeError)throw console.error(`[AgentSession] /message network error: ${r.message}, sessionId=${e}`),Error("Network connection lost — couldn't confirm the message was delivered. Check the conversation before sending again.");throw r}if(!n.ok){let r="";try{let e=await n.json();if(e.errorCode){let s=[`${e.errorCode}`];e.attempts&&s.push(`${e.attempts} attempts`),e.totalDurationMs&&s.push(`${(e.totalDurationMs/1e3).toFixed(1)}s`),r=` (${s.join(", ")})`}else e.error&&(r=` — ${e.error}`)}catch{}throw console.error(`[AgentSession] /message failed: status=${n.status}, sessionId=${e}, detail=${r}`),Error(`Failed to send message [${n.status}]${r}`)}}async function EP(e){let r=await (0,aC.authFetch)(`${EA()}/api/agent-sessions/${e}/discard-if-empty`,{method:"POST"});if(r.ok)return!0;if(404===r.status||409===r.status)return!1;throw Error(`Failed to discard empty session [${r.status}]`)}async function EF(e,r){let s=await (0,aC.authFetch)(`${EA()}/api/agent-sessions/${e}/paste`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:r})});if(!s.ok){let r="";try{let e=await s.json();if(e.errorCode){let s=[`${e.errorCode}`];e.attempts&&s.push(`${e.attempts} attempts`),e.totalDurationMs&&s.push(`${(e.totalDurationMs/1e3).toFixed(1)}s`),r=` (${s.join(", ")})`}else e.error&&(r=` — ${e.error}`)}catch{}throw console.error(`[AgentSession] /paste failed: status=${s.status}, sessionId=${e}, detail=${r}`),Error(`Failed to upload paste [${s.status}]${r}`)}return s.json()}async function EL(e,r,s){let n=`${EA()}/api/agent-sessions/${e}/attachment`,i=JSON.stringify(r),a=e=>new Promise((a,o)=>{let l=new XMLHttpRequest;l.open("POST",n),l.setRequestHeader("Content-Type","application/json"),e&&l.setRequestHeader("Authorization",`Bearer ${e}`),l.upload.onprogress=e=>{e.lengthComputable&&e.total>0&&s?.(Math.min(1,e.loaded/e.total))},l.onload=()=>a({status:l.status,text:l.responseText}),l.onerror=()=>o(Error(`Failed to upload ${r.name}`)),l.onabort=()=>o(Error(`Upload of ${r.name} was cancelled`)),l.send(i)}),o=await a(await (0,aC.getFreshToken)());if(401===o.status&&(o=await a(await (0,aC.getFreshToken)({skipCache:!0}))),o.status<200||o.status>=300){let s=`Failed to upload ${r.name} [${o.status}]`;try{let e=JSON.parse(o.text);"string"==typeof e?.error&&e.error&&(s=e.error)}catch{}throw console.error(`[AgentSession] /attachment failed: status=${o.status}, sessionId=${e}, name=${r.name}`),Error(s)}return s?.(1),JSON.parse(o.text)}async function EO(e,r){if(!(await (0,aC.authFetch)(`${EA()}/api/agent-sessions/${e}/restart`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({agentType:r})})).ok)throw Error("Failed to restart session")}async function EB(e,r){let s=await (0,aC.authFetch)(`${EA()}/api/agent-sessions/${e}/agent-type`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({agentType:r})});if(!s.ok){let e="";try{let r=await s.json();r.error&&(e=r.error)}catch{}throw Error(e||`Failed to switch agent [${s.status}]`)}}async function Ez(e,r){let s=await (0,aC.authFetch)(`${EA()}/api/agent-sessions/${e}/model`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:r})});if(!s.ok){let e="";try{let r=await s.json();r.error&&(e=r.error)}catch{}throw Error(e||`Failed to set model [${s.status}]`)}return(await s.json().catch(()=>({}))).model??null}async function E$(e){if(!(await (0,aC.authFetch)(`${EA()}/api/agent-sessions/${e}/stop`,{method:"POST"})).ok)throw Error("Failed to stop session")}async function EW(e,r){if(!(await (0,aC.authFetch)(`${EA()}/api/agent-sessions/${e}/switch-mode`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mode:r})})).ok)throw Error("Failed to switch mode")}async function EH(e,r){if(!(await (0,aC.authFetch)(`${EA()}/api/agent-sessions/${e}/accept-plan`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({planContent:r})})).ok)throw Error("Failed to accept plan")}let EU=new Map,EV=new Map;function Eq(e,r,s){return`${e}:${r??""}:${s??"latest"}`}function EK(e){let r=EU.get(e);if(r){EU.delete(e),EU.set(e,r);if(void 0===r.session.processAlive)return r;let s={...r.session};return delete s.processAlive,{session:s,history:r.history.session?{...r.history,session:s}:r.history}}}function EX(e,r){for(EU.delete(e),EU.set(e,r);EU.size>16;){let e=EU.keys().next().value;if(void 0===e)break;EU.delete(e)}}function EY(e,r,s,n,i){let a={session:n,history:{...i,entries:[...i.entries]}};EX(Eq(e,r,s),a),EX(Eq(e,r,n.id),a)}function EG(e,r,s,n){let i=Eq(e,r,s);EU.get(i)?.session.id===n&&EU.delete(i),EU.delete(Eq(e,r,n))}function EJ(e,r,s,n){let i=EK(Eq(e,r,n.id))??EK(Eq(e,r,s));i&&EY(e,r,s,n,i.history)}function EZ(e,r){return Error(404===r?`Session ${e} not found`:`Failed to load session ${e} (HTTP ${r})`)}async function EQ(e,r){let s=new URLSearchParams({turns:String(5)});null!=r&&s.set("before",String(r));let n=await (0,aC.authFetch)(`${EA()}/api/agent-sessions/${e}/history-window?${s}`);if(!n.ok)throw EZ(e,n.status);let i=await n.json();if(Array.isArray(i.entries))return i;let a=i.messages??[];return{historyEpoch:0,latestEntryIndex:a.length>0?a.length-1:null,lastTurnEndEntryIndex:a.reduce((e,r,s)=>"turn_end"===r.type?s:e,null),entries:a.map((e,r)=>({entryIndex:r,message:e})),previousCursor:null,hasMore:!1,status:i.session?.status??"stopped",session:i.session}}function E0(e){let r=EV.get(e);if(r)return r;let s=EQ(e).finally(()=>EV.delete(e));return EV.set(e,s),s}async function E1(e){let r=await (0,aC.authFetch)(`${EA()}/api/agent-sessions/${e}/history-head`);if(!r.ok)throw EZ(e,r.status);let s=await r.json();if("number"==typeof s.historyEpoch)return s;let n=s.messages??[];return{historyEpoch:0,latestEntryIndex:n.length>0?n.length-1:null,lastTurnEndEntryIndex:n.reduce((e,r,s)=>"turn_end"===r.type?s:e,null),status:s.session?.status??"stopped"}}function E2(e){return Object.fromEntries(e.map(({entryIndex:e,message:r})=>[e,r]))}function E5(e){return Object.entries(e.entries).map(([e,r])=>({entryIndex:Number(e),message:r})).sort((e,r)=>e.entryIndex-r.entryIndex)}function E3(e){let r=E5(e);for(let e=r.length-1;e>=0;e--){let s=r[e].message;if("turn_end"===s.type)return s.timestamp}return null}function E4(e){return{historyEpoch:0,latestEntryIndex:null,lastTurnEndEntryIndex:null,entries:[],previousCursor:null,hasMore:!1,status:e.status,session:e}}let E6=(0,rE.default)("user",[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]]),E7=(0,rE.default)("wrench",[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z",key:"1ngwbx"}]]),E8=(0,rE.default)("brain",[["path",{d:"M12 18V5",key:"adv99a"}],["path",{d:"M15 13a4.17 4.17 0 0 1-3-4 4.17 4.17 0 0 1-3 4",key:"1e3is1"}],["path",{d:"M17.598 6.5A3 3 0 1 0 12 5a3 3 0 1 0-5.598 1.5",key:"1gqd8o"}],["path",{d:"M17.997 5.125a4 4 0 0 1 2.526 5.77",key:"iwvgf7"}],["path",{d:"M18 18a4 4 0 0 0 2-7.464",key:"efp6ie"}],["path",{d:"M19.967 17.483A4 4 0 1 1 12 18a4 4 0 1 1-7.967-.517",key:"1gq6am"}],["path",{d:"M6 18a4 4 0 0 1-2-7.464",key:"k1g0md"}],["path",{d:"M6.003 5.125a4 4 0 0 0-2.526 5.77",key:"q97ue3"}]]),E9=(0,rE.default)("file-check",[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"m9 15 2 2 4-4",key:"1grp1n"}]]),De=(0,rE.default)("folder-search",[["path",{d:"M10.7 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v4.1",key:"1bw5m7"}],["path",{d:"m21 21-1.9-1.9",key:"1g2n9r"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}]]),Dt=(0,rE.default)("workflow",[["rect",{width:"8",height:"8",x:"3",y:"3",rx:"2",key:"by2w9f"}],["path",{d:"M7 11v4a2 2 0 0 0 2 2h4",key:"xkn7yn"}],["rect",{width:"8",height:"8",x:"13",y:"13",rx:"2",key:"1cgmvn"}]]),Dr=(0,rE.default)("file-pen-line",[["path",{d:"m18.226 5.226-2.52-2.52A2.4 2.4 0 0 0 14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-.351",key:"1k2beg"}],["path",{d:"M21.378 12.626a1 1 0 0 0-3.004-3.004l-4.01 4.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z",key:"2t3380"}],["path",{d:"M8 18h1",key:"13wk12"}]]),Ds=(0,rE.default)("file-plus-corner",[["path",{d:"M11.35 22H6a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v5.35",key:"17jvcc"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M14 19h6",key:"bvotb8"}],["path",{d:"M17 16v6",key:"18yu1i"}]]),Dn=(0,rE.default)("earth",[["path",{d:"M21.54 15H17a2 2 0 0 0-2 2v4.54",key:"1djwo0"}],["path",{d:"M7 3.34V5a3 3 0 0 0 3 3a2 2 0 0 1 2 2c0 1.1.9 2 2 2a2 2 0 0 0 2-2c0-1.1.9-2 2-2h3.17",key:"1tzkfa"}],["path",{d:"M11 21.95V18a2 2 0 0 0-2-2a2 2 0 0 1-2-2v-1a2 2 0 0 0-2-2H2.05",key:"14pb5j"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]),Di=(0,rE.default)("shield-alert",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M12 16h.01",key:"1drbdi"}]]),Da=(0,rE.default)("list-plus",[["path",{d:"M16 5H3",key:"m91uny"}],["path",{d:"M11 12H3",key:"51ecnj"}],["path",{d:"M16 19H3",key:"zzsher"}],["path",{d:"M18 9v6",key:"1twb98"}],["path",{d:"M21 12h-6",key:"bt1uis"}]]),Do=(0,rE.default)("pencil-line",[["path",{d:"M13 21h8",key:"1jsn5i"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}],["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]]);var r0=rQ,Cj=rQ;let Dl=RegExp("(?<![\\w./-])((?:~?\\/)?[\\w-]+(?:[./][\\w-]+)+)(?::(\\d+)(?::\\d+)?|#L(\\d+)(?:-L?\\d+)?)?","g"),Dc=/\[([^\]\n]*)\]\(\s*([^)\s]+?)\s*\)/g;function Dd(e){return e.includes("/")||/\.[A-Za-z0-9]+$/.test(e)}function Du(e){let r=e.trim();if(!r)return null;let s=/^(.*?)(?::(\d+)(?::\d+)?|#L(\d+)(?:-L?\d+)?)?$/.exec(r);if(!s||!s[1])return null;let n=s[1];return/^[a-z][a-z0-9+.-]*:/i.test(n)||n.startsWith("//")||n.startsWith("#")?null:{rawPath:n,line:s[2]?Number(s[2]):s[3]?Number(s[3]):null}}function Dh(e,r,s){return{type:"element",tagName:"a",properties:{className:["file-ref"],href:"#file-ref",dataFileRaw:e,...null!=r?{dataFileLine:String(r)}:{}},children:s}}var Df="HoverCard",[Dp,Dm]=es(Df,[nx]),Dg=nx(),[Dx,Dv]=Dp(Df),Dy=e=>{let{__scopeHoverCard:r,children:s,open:n,defaultOpen:i,onOpenChange:a,openDelay:o=700,closeDelay:l=300}=e,c=Dg(r),d=V.useRef(0),u=V.useRef(0),h=V.useRef(!1),f=V.useRef(!1),[p,m]=ey({prop:n,defaultProp:i??!1,onChange:a,caller:Df}),g=V.useCallback(()=>{clearTimeout(u.current),d.current=window.setTimeout(()=>m(!0),o)},[o,m]),x=V.useCallback(()=>{clearTimeout(d.current),h.current||f.current||(u.current=window.setTimeout(()=>m(!1),l))},[l,m]),v=V.useCallback(()=>m(!1),[m]);return V.useEffect(()=>()=>{clearTimeout(d.current),clearTimeout(u.current)},[]),(0,U.jsx)(Dx,{scope:r,open:p,onOpenChange:m,onOpen:g,onClose:x,onDismiss:v,hasSelectionRef:h,isPointerDownOnContentRef:f,children:(0,U.jsx)(nb,{...c,children:s})})};Dy.displayName=Df;var Db="HoverCardTrigger",Dw=V.forwardRef((e,r)=>{let{__scopeHoverCard:s,...n}=e,i=Dv(Db,s),a=Dg(s);return(0,U.jsx)(n_,{asChild:!0,...a,children:(0,U.jsx)(em.a,{"data-state":i.open?"open":"closed",...n,ref:r,onPointerEnter:er(e.onPointerEnter,DD(i.onOpen)),onPointerLeave:er(e.onPointerLeave,DD(i.onClose)),onFocus:er(e.onFocus,i.onOpen),onBlur:er(e.onBlur,i.onClose),onTouchStart:er(e.onTouchStart,e=>e.preventDefault())})})});Dw.displayName=Db;var D_="HoverCardPortal",[DS,Dk]=Dp(D_,{forceMount:void 0}),Dj=e=>{let{__scopeHoverCard:r,forceMount:s,children:n,container:i}=e,a=Dv(D_,r);return(0,U.jsx)(DS,{scope:r,forceMount:s,children:(0,U.jsx)(eO,{present:s||a.open,children:(0,U.jsx)(tc,{asChild:!0,container:i,children:n})})})};Dj.displayName=D_;var DC="HoverCardContent",DN=V.forwardRef((e,r)=>{let s=Dk(DC,e.__scopeHoverCard),{forceMount:n=s.forceMount,...i}=e,a=Dv(DC,e.__scopeHoverCard);return(0,U.jsx)(eO,{present:n||a.open,children:(0,U.jsx)(DE,{"data-state":a.open?"open":"closed",...i,onPointerEnter:er(e.onPointerEnter,DD(a.onOpen)),onPointerLeave:er(e.onPointerLeave,DD(a.onClose)),ref:r})})});DN.displayName=DC;var DE=V.forwardRef((e,r)=>{let{__scopeHoverCard:s,onEscapeKeyDown:n,onPointerDownOutside:i,onFocusOutside:a,onInteractOutside:o,...l}=e,c=Dv(DC,s),d=Dg(s),u=V.useRef(null),h=(0,en.useComposedRefs)(r,u),[f,p]=V.useState(!1);return V.useEffect(()=>{if(f){let e=document.body;return H=e.style.userSelect||e.style.webkitUserSelect,e.style.userSelect="none",e.style.webkitUserSelect="none",()=>{e.style.userSelect=H,e.style.webkitUserSelect=H}}},[f]),V.useEffect(()=>{if(u.current){let e=()=>{p(!1),c.isPointerDownOnContentRef.current=!1,setTimeout(()=>{document.getSelection()?.toString()!==""&&(c.hasSelectionRef.current=!0)})};return document.addEventListener("pointerup",e),()=>{document.removeEventListener("pointerup",e),c.hasSelectionRef.current=!1,c.isPointerDownOnContentRef.current=!1}}},[c.isPointerDownOnContentRef,c.hasSelectionRef]),V.useEffect(()=>{u.current&&(function(e){let r=[],s=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:e=>e.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP});for(;s.nextNode();)r.push(s.currentNode);return r})(u.current).forEach(e=>e.setAttribute("tabindex","-1"))}),(0,U.jsx)(e7,{asChild:!0,disableOutsidePointerEvents:!1,onInteractOutside:o,onEscapeKeyDown:n,onPointerDownOutside:i,onFocusOutside:er(a,e=>{e.preventDefault()}),onDismiss:c.onDismiss,children:(0,U.jsx)(nC,{...d,...l,onPointerDown:er(l.onPointerDown,e=>{e.currentTarget.contains(e.target)&&p(!0),c.hasSelectionRef.current=!1,c.isPointerDownOnContentRef.current=!0}),ref:h,style:{...l.style,userSelect:f?"text":void 0,WebkitUserSelect:f?"text":void 0,"--radix-hover-card-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-hover-card-content-available-width":"var(--radix-popper-available-width)","--radix-hover-card-content-available-height":"var(--radix-popper-available-height)","--radix-hover-card-trigger-width":"var(--radix-popper-anchor-width)","--radix-hover-card-trigger-height":"var(--radix-popper-anchor-height)"}})})});function DD(e){return r=>"touch"===r.pointerType?void 0:e()}function DT({...e}){return(0,U.jsx)(Dy,{"data-slot":"hover-card",...e})}function DR({...e}){return(0,U.jsx)(Dw,{"data-slot":"hover-card-trigger",...e})}function DA({className:e,align:r="center",sideOffset:s=4,...n}){return(0,U.jsx)(Dj,{"data-slot":"hover-card-portal",children:(0,U.jsx)(DN,{"data-slot":"hover-card-content",align:r,sideOffset:s,className:(0,e1.cn)("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-64 origin-(--radix-hover-card-content-transform-origin) rounded-md border p-4 shadow-md outline-hidden",e),...n})})}V.forwardRef((e,r)=>{let{__scopeHoverCard:s,...n}=e,i=Dg(s);return(0,U.jsx)(nD,{...i,...n,ref:r})}).displayName="HoverCardArrow";let DM=new Map,DI=new Map,DP=new Map,DF=new Set;function DL(e){for(let r of DP.get(e)??[])r()}let DO=new Set;function DB(e,r){DF.delete(e)&&(r=!0);let s=DI.get(e);if(s)return r&&DO.add(e),s;let n=DM.get(e);return!r&&n?Promise.resolve(n):function e(r){DO.delete(r);let s=aC.api.getTasks(r,{includeArchived:!0}).then(e=>(DO.has(r)||(DM.set(r,e),DL(r)),e)).finally(()=>{DI.get(r)===s&&DI.delete(r),DO.has(r)&&e(r).catch(()=>{})});return DI.set(r,s),s}(e)}function Dz(e,r){let s=new Set(r.map(e=>e.id)),n=DM.get(e)??[];DM.set(e,[...n.filter(e=>!s.has(e.id)),...r]),DI.has(e)&&DO.add(e),DL(e)}function D$(e,r,s){let n=(0,V.useSyncExternalStore)((0,V.useCallback)(r=>{let s;return e?((s=DP.get(e)??new Set).add(r),DP.set(e,s),()=>{s.delete(r),0===s.size&&(DP.delete(e),DF.add(e))}):()=>{}},[e]),(0,V.useCallback)(()=>e?DM.get(e)??null:null,[e]),()=>null),[i,a]=(0,V.useState)(null),o=(0,V.useCallback)(r=>{e&&DB(e,r).catch(e=>{console.error("Failed to load tasks for proposal lookup:",e),a(e instanceof Error?e.message:"Failed to load tasks")})},[e]);(0,V.useEffect)(()=>{o(!1)},[o]);let l=(0,V.useCallback)(()=>{a(null),o(!0)},[o]);return(0,aF.useGlobalEventStream)((0,V.useCallback)(r=>{!r.type?.startsWith("task:")||e&&r.projectId===e&&DB(e,!0).catch(()=>{})},[e])),{byItem:(0,V.useMemo)(()=>{let e=new Map;if(!s||!r||!n)return e;for(let i of n)i.source_tool_use_id===s&&i.source_session_id===r&&null!=i.source_item_index&&e.set(i.source_item_index,i);return e},[n,s,r]),tasks:n,loading:null===n&&null===i,loadError:null===n?i:null,retry:l}}let DW="#ref:task:";function DH({taskId:e,icon:r=!0,children:s}){let n=MH(),{tasks:i}=D$(n?.projectId??null,null,null),a=i?.find(r=>r.id===e),o=n?.openTask;return a&&o?(0,U.jsxs)("a",{href:`${DW}${encodeURIComponent(e)}`,"data-task-ref":e,className:"cursor-pointer font-medium text-primary underline",onClick:e=>{e.preventDefault(),o(a)},children:[r&&(0,U.jsx)(on,{"aria-hidden":!0,className:"mr-0.5 inline h-[1em] w-[1em] align-[-0.125em]"}),s]}):(0,U.jsx)(U.Fragment,{children:s})}function DU({refs:e}){return(0,U.jsxs)("span",{className:"flex min-w-0 items-baseline gap-1 text-xs font-normal text-muted-foreground",children:[(0,U.jsx)(on,{className:"h-3 w-3 shrink-0 self-center"}),(0,U.jsx)("span",{className:"flex min-w-0 items-baseline gap-1 truncate",children:e.map((r,s)=>(0,U.jsxs)("span",{className:"truncate",children:[(0,U.jsx)(DH,{taskId:r.id,icon:!1,children:r.title}),s<e.length-1&&","]},r.id))})]})}let DV="text-primary underline decoration-dotted underline-offset-2 cursor-pointer hover:decoration-solid",Dq="wrap-anywhere font-medium text-primary underline decoration-primary/60 underline-offset-2 transition-colors hover:text-primary/80 hover:decoration-primary",DK="text-primary/80 underline decoration-dotted underline-offset-2 cursor-pointer hover:decoration-solid",DX=new Set(["png","jpg","jpeg","gif","webp","bmp","ico","avif","svg"]);function DY({paths:e,line:r,children:s}){let{openFile:n}=jL();return(0,U.jsxs)(i3,{children:[(0,U.jsx)(i4,{asChild:!0,children:(0,U.jsx)("a",{href:"#",className:DV,onClick:e=>e.preventDefault(),children:s})}),(0,U.jsxs)(i6,{align:"start",className:"max-w-md",children:[(0,U.jsxs)(at,{children:[e.length," matching files"]}),e.map(e=>(0,U.jsx)(i7,{className:"font-mono text-xs",onSelect:()=>n(e,r),children:e},e))]})]})}function DG({scope:e,filePath:r}){let[s,n]=(0,V.useState)(null),[i,a]=(0,V.useState)(null),[o,l]=(0,V.useState)(null),{label:c}=g7(null!==o&&o!==CH(e.sessionId)?o:null);return((0,V.useEffect)(()=>{let s=null,i=!1;return aC.api.getFileBlob(e.projectId,r,e.branch,e.target,e.sessionId).then(({blob:e,serverId:r})=>{if(!i){if(e.size>0xa00000)return void a("Too large to preview — click to open");l(r),n(s=URL.createObjectURL(e))}}).catch(e=>{if(i)return;let r=e instanceof Error?e.message:"";a(/not found/i.test(r)?"File not found":"Couldn't load image")}),()=>{i=!0,s&&URL.revokeObjectURL(s)}},[e.projectId,e.branch,e.target,e.sessionId,r]),i)?(0,U.jsxs)("div",{className:"flex items-center gap-2 px-2 py-1.5 text-xs text-muted-foreground",children:[(0,U.jsx)(CV,{className:"h-3.5 w-3.5"}),i]}):s?(0,U.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,U.jsx)("img",{src:s,alt:r,className:"block max-h-64 max-w-[22rem] rounded object-contain"}),c&&(0,U.jsxs)("p",{className:"px-0.5 text-xs text-muted-foreground",children:["on ",(0,U.jsx)("span",{className:"text-foreground",children:c})]})]}):(0,U.jsxs)("div",{className:"flex items-center gap-2 px-2 py-1.5 text-xs text-muted-foreground",children:[(0,U.jsx)(aP,{className:"h-3.5 w-3.5 animate-spin"}),"Loading preview…"]})}let{harden:DJ,...DZ}=Cj.e,DQ=[...Object.values(DZ),function(){return e=>{!function e(r,s=!1){if(!r.children)return;let n=s||"pre"===r.tagName,i=[];for(let s of r.children)"text"===s.type?n?i.push(s):i.push(...function(e){let r=function(e){let r,s=[],n=[];for(Dc.lastIndex=0;null!==(r=Dc.exec(e));){let e=Du(r[2]);if(!e||!Dd(e.rawPath))continue;let i=r.index,a=r.index+r[0].length;s.push({start:i,end:a,rawPath:e.rawPath,line:e.line,display:r[1]||void 0}),n.push([i,a])}for(Dl.lastIndex=0;null!==(r=Dl.exec(e));){let e=r.index;if(n.some(([r,s])=>e>=r&&e<s))continue;let i=r[1];if(!Dd(i))continue;let a=r[2]?Number(r[2]):r[3]?Number(r[3]):null;s.push({start:e,end:e+r[0].length,rawPath:i,line:a})}return s.sort((e,r)=>e.start-r.start),s}(e);if(0===r.length)return[{type:"text",value:e}];let s=[],n=0;for(let i of r){i.start>n&&s.push({type:"text",value:e.slice(n,i.start)});let r=i.display??e.slice(i.start,i.end);s.push(Dh(i.rawPath,i.line,[{type:"text",value:r}])),n=i.end}return n<e.length&&s.push({type:"text",value:e.slice(n)}),s}(s.value??"")):"element"===s.type&&"pre"===s.tagName?(e(s,!0),i.push(s)):"element"!==s.type||"a"!==s.tagName||n?(e(s,n),i.push(s)):i.push(...function(e){let r=Du(String(e.properties?.href??""));return r?[Dh(r.rawPath,r.line,e.children??[])]:[e]}(s));r.children=i}(e)}},...DJ?[DJ]:[]],D0={a:function({node:e,children:r,href:s,className:n,...i}){let{openFile:a,index:o,scope:l}=jL(),c=e?.properties?.dataFileRaw;if(!c){let e=function(e){if(!e?.startsWith(DW))return null;try{return decodeURIComponent(e.slice(DW.length))||null}catch{return null}}(s);return e?(0,U.jsx)(DH,{taskId:e,children:r}):"string"==typeof s&&s.startsWith("#")?(0,U.jsx)("a",{href:s,className:(0,e1.cn)(Dq,n),...i,children:r}):(0,U.jsx)("a",{href:s,className:(0,e1.cn)(Dq,n),target:"_blank",rel:"noreferrer noopener",...i,children:r})}let d=e?.properties?.dataFileLine,u=null!=d?Number(d):null,h=o?o.resolve(c):[];if(0===h.length){let e=o&&l?function(e){let r,s;if(!(e.startsWith("/")||e.startsWith("~/")))return null;let n=(s=(r=e.slice(e.lastIndexOf("/")+1)).lastIndexOf("."))>0?r.slice(s+1).toLowerCase():"";return n?DX.has(n)?"image":"file":null}(c):null;if(!e||!l)return(0,U.jsx)(U.Fragment,{children:r});let s=e=>{e.preventDefault(),a(c,u)};return"file"===e?(0,U.jsx)("a",{href:"#",className:DK,onClick:s,children:r}):(0,U.jsxs)(DT,{openDelay:300,closeDelay:100,children:[(0,U.jsx)(DR,{asChild:!0,children:(0,U.jsx)("a",{href:"#",className:DK,onClick:s,children:r})}),(0,U.jsx)(DA,{side:"top",align:"start",className:"w-auto max-w-sm p-1.5",children:(0,U.jsx)(DG,{scope:l,filePath:c})})]})}return 1===h.length?(0,U.jsx)("a",{href:"#",className:DV,onClick:e=>{e.preventDefault(),a(h[0],u)},children:r}):(0,U.jsx)(DY,{paths:h,line:u,children:r})}},D1=(0,V.memo)(function({children:e,streaming:r=!1}){return(0,U.jsx)(r0.i,{className:"size-full [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",mode:r?"streaming":"static",rehypePlugins:DQ,components:D0,children:e})});function D2({input:e,messageIndex:r}){let{sendMessage:s,messages:n}=MW(),i=function(e){try{let r="string"==typeof e?JSON.parse(e):e;if(r&&Array.isArray(r.questions)&&r.questions.length>0&&r.questions.every(e=>"string"==typeof e.question&&"string"==typeof e.header&&Array.isArray(e.options)))return r}catch{}return null}(e),a=n[r+1],o=a?.type==="user",l=o?a.content:"",c="string"==typeof l?l:l.filter(e=>"text"===e.type).map(e=>e.text).join("\n");if(!i){let r="string"==typeof e?e:JSON.stringify(e,null,2);return(0,U.jsx)("pre",{className:"mt-1 bg-muted/50 p-2 rounded overflow-x-auto max-w-full whitespace-pre-wrap break-all",style:{fontSize:"var(--conv-font-size, 12px)"},children:r.length>500?r.substring(0,500)+"...":r})}return o?(0,U.jsx)(D5,{questions:i.questions,answeredText:c}):(0,U.jsx)(D3,{questions:i.questions,sendMessage:s})}function D5({questions:e,answeredText:r}){return(0,U.jsx)("div",{className:"space-y-3 mt-2",children:e.map((e,s)=>(0,U.jsxs)("div",{className:"rounded-lg border bg-muted/30 p-3",children:[(0,U.jsx)("div",{className:"flex items-center gap-2 mb-1.5",children:(0,U.jsx)(rG,{variant:"secondary",className:"text-[10px]",children:e.header})}),(0,U.jsx)("p",{className:"text-sm text-muted-foreground mb-2",children:e.question}),(0,U.jsxs)("div",{className:"flex items-center gap-2 text-sm text-green-600 dark:text-green-400",children:[(0,U.jsx)(os,{className:"h-4 w-4"}),(0,U.jsx)("span",{className:"font-medium",children:r})]})]},s))})}function D3({questions:e,sendMessage:r}){let[s,n]=(0,V.useState)(new Map),[i,a]=(0,V.useState)(new Map),[o,l]=(0,V.useState)(new Set),[c,d]=(0,V.useState)(!1);async function u(){let n=[];for(let r=0;r<e.length;r++)if(o.has(r)){let e=i.get(r)?.trim();e&&n.push(e)}else{let e=s.get(r);e&&e.size>0&&n.push(Array.from(e).join(", "))}if(n.length>0){d(!0);try{await r(n.join("\n"))}finally{d(!1)}}}let h=e.some((e,r)=>{if(o.has(r))return!!i.get(r)?.trim();let n=s.get(r);return n&&n.size>0});return(0,U.jsxs)("div",{className:"space-y-4 mt-2",children:[e.map((e,r)=>{let c=s.get(r)||new Set,d=i.get(r)||"",u=o.has(r);return(0,U.jsxs)("div",{className:"rounded-lg border bg-card p-3",children:[(0,U.jsxs)("div",{className:"flex items-center gap-2 mb-1.5",children:[(0,U.jsx)(dR,{className:"h-3.5 w-3.5 text-violet-500"}),(0,U.jsx)(rG,{variant:"secondary",className:"text-[10px]",children:e.header})]}),(0,U.jsx)("p",{className:"text-sm font-medium mb-3",children:e.question}),(0,U.jsxs)("div",{className:"grid gap-2",children:[e.options.map(s=>{let i=c.has(s.label)&&!u;return(0,U.jsx)(a$.Button,{variant:i?"default":"outline",className:(0,e1.cn)("h-auto py-2 px-3 justify-start text-left whitespace-normal",i&&"ring-2 ring-primary/50"),onClick:()=>{var i,a;return i=s.label,a=e.multiSelect,void(n(e=>{let s=new Map(e),n=new Set(s.get(r)||[]);return a?n.has(i)?n.delete(i):n.add(i):n.has(i)?n.clear():(n.clear(),n.add(i)),s.set(r,n),s}),l(e=>{let s=new Set(e);return s.delete(r),s}))},children:(0,U.jsxs)("div",{children:[(0,U.jsx)("span",{className:"font-medium text-sm",children:s.label}),s.description&&(0,U.jsx)("span",{className:"block text-xs text-muted-foreground mt-0.5",children:s.description})]})},s.label)}),(0,U.jsx)("div",{className:"flex items-center gap-2 mt-1",children:(0,U.jsx)(aX,{placeholder:"Other...",value:d,onChange:e=>{var s;return s=e.target.value,void(a(e=>new Map(e).set(r,s)),s&&(n(e=>{let s=new Map(e);return s.set(r,new Set),s}),l(e=>new Set(e).add(r))))},className:"text-sm"})})]})]},r)}),(0,U.jsxs)(a$.Button,{onClick:u,disabled:!h||c,size:"sm",className:"active:scale-95 transition-transform",children:[c&&(0,U.jsx)(aP,{className:"h-3.5 w-3.5 animate-spin"}),c?"Submitting...":"Submit"]})]})}function D4(e){try{return JSON.parse(e)}catch{return null}}function D6({input:e,messageIndex:r}){let{messages:s,acceptPlan:n,permissionMode:i,agentType:a}=MW(),[o,l]=(0,V.useState)(!0),[c,d]=(0,V.useState)(!1),u=function(e,r,s){let n="string"==typeof e?D4(e):e;if(n&&"object"==typeof n&&"plan"in n){let e=n.plan;if(e)return e}if("claude-code"===s)for(let e=r.length-1;e>=0;e--){let s=r[e];if("tool_use"===s.type&&"Write"===s.tool){let e="string"==typeof s.input?D4(s.input):s.input;if(e&&"object"==typeof e&&e.file_path?.includes(".claude/plans/")&&e.content)return e.content}}return"Plan written to file"}(e,s,a),h=(0,V.useCallback)(async()=>{d(!0);try{await n(u)}catch{d(!1)}},[n,u]),f="edit"===i,p=!1,m="";for(let e=r+1;e<s.length;e++){let r=s[e];if(r?.type==="user"){p=!0;let e=r.content??"";m="string"==typeof e?e:e.filter(e=>"text"===e.type).map(e=>e.text).join("\n");break}}return(f&&!p&&(p=!0),f||p)?(0,U.jsxs)("div",{className:"space-y-2 mt-2",children:[f?(0,U.jsxs)(rG,{variant:"default",className:"bg-green-600 hover:bg-green-700 text-white",children:[(0,U.jsx)(os,{className:"h-3 w-3 mr-1"}),"Plan Accepted"]}):(0,U.jsxs)("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[(0,U.jsx)(rJ,{className:"h-3.5 w-3.5"}),(0,U.jsxs)("span",{children:["Feedback sent: ",m.length>100?m.substring(0,100)+"...":m]})]}),(0,U.jsxs)("details",{open:!f,children:[(0,U.jsx)("summary",{className:"text-xs text-muted-foreground cursor-pointer hover:text-foreground",children:"View Plan"}),(0,U.jsx)("div",{className:"mt-2 rounded-lg border p-3 bg-muted/30",children:(0,U.jsx)("div",{className:"prose prose-sm dark:prose-invert max-w-none break-words [&_pre]:overflow-x-auto [&_pre]:max-w-full [&_code]:break-all [&_p]:break-words",style:{fontSize:"var(--conv-font-size, 14px)"},children:(0,U.jsx)(cz,{mode:"static",children:u})})})]})]}):(0,U.jsxs)("div",{className:"space-y-3 mt-2",children:[(0,U.jsxs)("div",{className:"rounded-lg border p-3 bg-card",children:[(0,U.jsxs)("button",{onClick:()=>l(!o),className:"text-xs text-muted-foreground cursor-pointer hover:text-foreground mb-2 block",children:[o?"Collapse":"Expand"," Plan"]}),o&&(0,U.jsx)("div",{className:"prose prose-sm dark:prose-invert max-w-none break-words [&_pre]:overflow-x-auto [&_pre]:max-w-full [&_code]:break-all [&_p]:break-words max-h-96 overflow-y-auto",style:{fontSize:"var(--conv-font-size, 14px)"},children:(0,U.jsx)(cz,{mode:"static",children:u})})]}),(0,U.jsxs)(a$.Button,{onClick:h,disabled:c,className:"bg-green-600 hover:bg-green-700 text-white",size:"sm",children:[c?(0,U.jsx)(aP,{className:"h-3.5 w-3.5 mr-1.5 animate-spin"}):(0,U.jsx)(dw,{className:"h-3.5 w-3.5 mr-1.5"}),c?"Accepting Plan...":"Accept Plan & Start Editing"]})]})}function D7({requestId:e,command:r,cwd:s,messageIndex:n}){let{messages:i,sessionId:a}=MW(),[o,l]=(0,V.useState)(!1),[c,d]=(0,V.useState)(null),u=!1;for(let e=n+1;e<i.length;e++)if(i[e]?.type==="user"){u=!0;break}c&&(u=!0);let h=(0,V.useCallback)(async r=>{if(a){l(!0),d(r);try{await (0,aC.sendApprovalResponse)(a,e,r)}catch{d(null),l(!1)}}},[a,e]);return u?(0,U.jsxs)("div",{className:"space-y-2 mt-2",children:[(0,U.jsxs)("div",{className:"rounded-lg border bg-muted/30 p-3",children:[(0,U.jsxs)("div",{className:"flex items-center gap-2 mb-2",children:[(0,U.jsx)(xb,{className:"h-3.5 w-3.5 text-muted-foreground"}),(0,U.jsx)("span",{className:"text-xs text-muted-foreground",children:"Command"})]}),(0,U.jsx)("pre",{className:"bg-muted/50 p-2 rounded overflow-x-auto max-w-full whitespace-pre-wrap break-all",style:{fontSize:"var(--conv-font-size, 12px)"},children:r||"(empty)"}),s&&(0,U.jsxs)("p",{className:"text-xs text-muted-foreground mt-1",children:["cwd: ",s]})]}),(0,U.jsxs)(rG,{variant:"default",className:"decline"===c?"bg-red-600 hover:bg-red-700 text-white":"bg-green-600 hover:bg-green-700 text-white",children:[(0,U.jsx)(os,{className:"h-3 w-3 mr-1"}),"decline"===c?"Denied":"Allowed"]})]}):(0,U.jsxs)("div",{className:"space-y-2 mt-2",children:[(0,U.jsxs)("div",{className:"rounded-lg border bg-card p-3",children:[(0,U.jsxs)("div",{className:"flex items-center gap-2 mb-2",children:[(0,U.jsx)(xb,{className:"h-3.5 w-3.5 text-muted-foreground"}),(0,U.jsx)("span",{className:"text-xs text-muted-foreground",children:"Command"})]}),(0,U.jsx)("pre",{className:"bg-muted/50 p-2 rounded overflow-x-auto max-w-full whitespace-pre-wrap break-all",style:{fontSize:"var(--conv-font-size, 12px)"},children:r||"(empty)"}),s&&(0,U.jsxs)("p",{className:"text-xs text-muted-foreground mt-1",children:["cwd: ",s]})]}),(0,U.jsxs)("div",{className:"flex gap-2",children:[(0,U.jsxs)(a$.Button,{onClick:()=>h("accept"),disabled:o,className:"bg-green-600 hover:bg-green-700 text-white",size:"sm",children:[o&&"accept"===c?(0,U.jsx)(aP,{className:"h-3.5 w-3.5 mr-1 animate-spin"}):(0,U.jsx)(os,{className:"h-3.5 w-3.5 mr-1"}),"Allow"]}),(0,U.jsxs)(a$.Button,{onClick:()=>h("decline"),disabled:o,variant:"destructive",size:"sm",children:[o&&"decline"===c?(0,U.jsx)(aP,{className:"h-3.5 w-3.5 mr-1 animate-spin"}):(0,U.jsx)(oi,{className:"h-3.5 w-3.5 mr-1"}),"Deny"]})]})]})}function D8({requestId:e,changes:r,messageIndex:s}){let{messages:n,sessionId:i}=MW(),[a,o]=(0,V.useState)(!1),[l,c]=(0,V.useState)(null),d=!1;for(let e=s+1;e<n.length;e++)if(n[e]?.type==="user"){d=!0;break}l&&(d=!0);let u=(0,V.useCallback)(async r=>{if(i){o(!0),c(r);try{await (0,aC.sendApprovalResponse)(i,e,r)}catch{c(null),o(!1)}}},[i,e]),h=r??[],f=()=>(0,U.jsx)("div",{className:"rounded-lg border bg-muted/30 p-3 space-y-2",children:0===h.length?(0,U.jsx)("p",{className:"text-xs text-muted-foreground",children:"No file changes"}):h.map((e,r)=>(0,U.jsxs)("div",{children:[(0,U.jsxs)("div",{className:"flex items-center gap-2",children:[(0,U.jsx)(Cn,{className:"h-3 w-3 text-muted-foreground flex-shrink-0"}),(0,U.jsx)("code",{className:"text-xs break-all",children:e.path}),(0,U.jsx)(rG,{variant:"secondary",className:`text-[10px] ${function(e){switch(e){case"added":case"add":return"bg-green-500/10 text-green-600";case"deleted":case"delete":return"bg-red-500/10 text-red-600";default:return"bg-blue-500/10 text-blue-600"}}(e.kind)}`,children:function(e){switch(e){case"added":case"add":return"added";case"deleted":case"delete":return"deleted";default:return"modified"}}(e.kind)})]}),e.diff&&(0,U.jsxs)("details",{className:"mt-1",children:[(0,U.jsx)("summary",{className:"text-xs text-muted-foreground cursor-pointer hover:text-foreground",children:"View diff"}),(0,U.jsx)("pre",{className:"mt-1 p-2 rounded overflow-x-auto max-h-48 overflow-y-auto scrollbar-none max-w-full whitespace-pre-wrap break-all",style:{fontSize:"var(--conv-font-size, 12px)"},children:e.diff.split("\n").map((e,r)=>{let s="";return e.startsWith("+")?s="bg-green-500/10 text-green-700 dark:text-green-400":e.startsWith("-")&&(s="bg-red-500/10 text-red-700 dark:text-red-400"),(0,U.jsx)("div",{className:s,children:e},r)})})]})]},r))});return d?(0,U.jsxs)("div",{className:"space-y-2 mt-2",children:[f(),(0,U.jsxs)(rG,{variant:"default",className:"decline"===l?"bg-red-600 hover:bg-red-700 text-white":"bg-green-600 hover:bg-green-700 text-white",children:[(0,U.jsx)(os,{className:"h-3 w-3 mr-1"}),"decline"===l?"Denied":"Allowed"]})]}):(0,U.jsxs)("div",{className:"space-y-2 mt-2",children:[f(),(0,U.jsxs)("div",{className:"flex gap-2",children:[(0,U.jsxs)(a$.Button,{onClick:()=>u("accept"),disabled:a,className:"bg-green-600 hover:bg-green-700 text-white",size:"sm",children:[a&&"accept"===l?(0,U.jsx)(aP,{className:"h-3.5 w-3.5 mr-1 animate-spin"}):(0,U.jsx)(os,{className:"h-3.5 w-3.5 mr-1"}),"Allow"]}),(0,U.jsxs)(a$.Button,{onClick:()=>u("decline"),disabled:a,variant:"destructive",size:"sm",children:[a&&"decline"===l?(0,U.jsx)(aP,{className:"h-3.5 w-3.5 mr-1 animate-spin"}):(0,U.jsx)(oi,{className:"h-3.5 w-3.5 mr-1"}),"Deny"]})]})]})}let D9=(0,rE.default)("circle-plus",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"M12 8v8",key:"napkw2"}]]),Te=(0,rE.default)("badge",[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}]]);function Tt({status:e,className:r}){switch(e){case"completed":return(0,U.jsx)(os,{className:(0,e1.cn)("h-4 w-4 text-green-500",r)});case"in_progress":return(0,U.jsx)(aP,{className:(0,e1.cn)("h-4 w-4 text-cyan-500 animate-spin",r)});case"pending":default:return(0,U.jsx)(i5,{className:(0,e1.cn)("h-4 w-4 text-muted-foreground",r)});case"deleted":return(0,U.jsx)(oi,{className:(0,e1.cn)("h-4 w-4 text-red-400",r)})}}function Tr(e,r){try{let s="string"==typeof e?JSON.parse(e):e;if(s&&"object"==typeof s&&r(s))return s}catch{}return null}function Ts({input:e}){let r="string"==typeof e?e:JSON.stringify(e,null,2);return(0,U.jsx)("pre",{className:"mt-1 bg-muted/50 p-2 rounded overflow-x-auto max-w-full whitespace-pre-wrap break-all",style:{fontSize:"var(--conv-font-size, 12px)"},children:r.length>500?r.substring(0,500)+"...":r})}function Tn({input:e}){let r=Tr(e,e=>Array.isArray(e.todos)&&e.todos.length>0);return r?(0,U.jsx)("div",{className:"mt-2 space-y-1",children:r.todos.map((e,r)=>(0,U.jsxs)("div",{className:"flex items-start gap-2 py-0.5",children:[(0,U.jsx)(Tt,{status:e.status,className:"mt-0.5 flex-shrink-0"}),(0,U.jsxs)("div",{className:"min-w-0",children:[(0,U.jsx)("span",{className:(0,e1.cn)("conv-text-sm break-words","completed"===e.status&&"line-through text-muted-foreground"),children:e.subject??e.content??"Untitled task"}),"in_progress"===e.status&&e.activeForm&&(0,U.jsx)("span",{className:"block conv-text-xs italic text-cyan-500",children:e.activeForm})]})]},e.id??r))}):(0,U.jsx)(Ts,{input:e})}function Ti({input:e}){let r=Tr(e,e=>"string"==typeof e.subject);return r?(0,U.jsxs)("div",{className:"mt-2 flex items-start gap-2",children:[(0,U.jsx)(D9,{className:"h-4 w-4 text-cyan-500 mt-0.5 flex-shrink-0"}),(0,U.jsxs)("div",{className:"min-w-0",children:[(0,U.jsx)("span",{className:"conv-text-sm font-medium break-words",children:r.subject}),r.description&&(0,U.jsx)("span",{className:"block conv-text-xs text-muted-foreground mt-0.5 break-words",children:r.description.length>200?r.description.substring(0,200)+"...":r.description})]})]}):(0,U.jsx)(Ts,{input:e})}function Ta({input:e}){let r=Tr(e,e=>"string"==typeof e.taskId);return r?(0,U.jsxs)("div",{className:"mt-2 flex items-start gap-2 flex-wrap",children:[r.status?(0,U.jsx)(Tt,{status:r.status,className:"mt-0.5 flex-shrink-0"}):(0,U.jsx)(j3,{className:"h-4 w-4 text-cyan-500 mt-0.5 flex-shrink-0"}),(0,U.jsxs)("span",{className:"conv-text-sm break-words",children:["Task #",r.taskId,r.status&&(0,U.jsxs)(U.Fragment,{children:[" ",(0,U.jsx)(j3,{className:"inline h-3 w-3 text-muted-foreground mx-0.5"})," ",r.status]}),r.subject&&(0,U.jsxs)("span",{className:"text-muted-foreground",children:[" — ",r.subject]})]}),r.addBlockedBy&&r.addBlockedBy.length>0&&(0,U.jsx)("div",{className:"flex gap-1 mt-1 w-full pl-6",children:r.addBlockedBy.map(e=>(0,U.jsxs)(rG,{variant:"outline",className:"text-[10px]",children:[(0,U.jsx)(Te,{className:"h-2.5 w-2.5 mr-0.5"}),"blocked by #",e]},e))}),r.addBlocks&&r.addBlocks.length>0&&(0,U.jsx)("div",{className:"flex gap-1 mt-1 w-full pl-6",children:r.addBlocks.map(e=>(0,U.jsxs)(rG,{variant:"outline",className:"text-[10px]",children:[(0,U.jsx)(Te,{className:"h-2.5 w-2.5 mr-0.5"}),"blocks #",e]},e))})]}):(0,U.jsx)(Ts,{input:e})}function To(){return(0,U.jsxs)("div",{className:"mt-2 flex items-center gap-2 conv-text-sm text-muted-foreground",children:[(0,U.jsx)(aP,{className:"h-4 w-4 animate-spin text-cyan-500"}),(0,U.jsx)("span",{children:"Listing tasks..."})]})}function Tl({input:e}){let r=Tr(e,e=>"string"==typeof e.taskId);return r?(0,U.jsxs)("div",{className:"mt-2 flex items-center gap-2 conv-text-sm text-muted-foreground",children:[(0,U.jsx)(aP,{className:"h-4 w-4 animate-spin text-cyan-500"}),(0,U.jsxs)("span",{children:["Fetching task #",r.taskId,"..."]})]}):(0,U.jsx)(Ts,{input:e})}function Tc({output:e}){let r=function(e){try{let r=JSON.parse(e);if(Array.isArray(r))return r.filter(e=>e.id&&e.subject).map(e=>({id:String(e.id),subject:String(e.subject),status:e.status||"pending",owner:e.owner?String(e.owner):void 0,blockedBy:Array.isArray(e.blockedBy)?e.blockedBy.map(String):void 0}));let s=r.tasks??r.items??r.data;if(Array.isArray(s))return s.filter(e=>e.id&&e.subject).map(e=>({id:String(e.id),subject:String(e.subject),status:e.status||"pending",owner:e.owner?String(e.owner):void 0,blockedBy:Array.isArray(e.blockedBy)?e.blockedBy.map(String):void 0}))}catch{let r=e.trim().split("\n").filter(Boolean),s=[];for(let e of r){let r=e.match(/^#?(\d+)[\s.:\-]+\[?(completed|in_progress|pending|deleted)\]?\s+(.+)/i);r&&s.push({id:r[1],status:r[2].toLowerCase(),subject:r[3].trim()})}if(s.length>0)return s}return null}(e);return r?(0,U.jsx)("div",{className:"mt-1 space-y-1",children:r.map(e=>(0,U.jsxs)("div",{className:"flex items-start gap-2 py-0.5",children:[(0,U.jsx)(Tt,{status:e.status,className:"mt-0.5 flex-shrink-0"}),(0,U.jsxs)("div",{className:"min-w-0 flex items-center gap-1.5 flex-wrap",children:[(0,U.jsxs)("span",{className:"conv-text-xs text-muted-foreground",children:["#",e.id]}),(0,U.jsx)("span",{className:(0,e1.cn)("conv-text-sm break-words","completed"===e.status&&"line-through text-muted-foreground"),children:e.subject}),e.blockedBy&&e.blockedBy.length>0&&(0,U.jsx)(rG,{variant:"outline",className:"text-[10px]",children:"blocked"})]})]},e.id))}):null}function Td({src:e,alt:r,className:s}){let[n,i]=(0,V.useState)(!1);return(0,U.jsxs)(re,{open:n,onOpenChange:i,children:[(0,U.jsx)(rr,{asChild:!0,children:(0,U.jsx)("button",{type:"button",title:"Click to enlarge","aria-label":`Enlarge image: ${r}`,className:"block cursor-zoom-in rounded-lg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:(0,U.jsx)("img",{src:e,alt:r,className:s})})}),(0,U.jsxs)(ra,{children:[(0,U.jsx)(rl,{className:"data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/70"}),(0,U.jsxs)(rh,{"aria-describedby":void 0,onPointerDown:e=>{e.target===e.currentTarget&&i(!1)},className:"data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed inset-0 z-50 flex items-center justify-center p-4 outline-none sm:p-10 lg:p-16",children:[(0,U.jsx)(rx,{className:"sr-only",children:r}),(0,U.jsx)(Tf,{src:e,alt:r})]})]})]})}let Tu={scale:1,x:0,y:0};function Th(e,r,s){let n=Math.min(8,Math.max(1,e.scale));return{scale:n,x:Math.min(0,Math.max(r*(1-n),e.x)),y:Math.min(0,Math.max(s*(1-n),e.y))}}function Tf({src:e,alt:r}){let s=(0,V.useRef)(null),[n,i]=(0,V.useState)(Tu),a=(0,V.useRef)(null),[o,l]=(0,V.useState)(!1);(0,V.useEffect)(()=>{let e=s.current;if(!e)return;let r=r=>{r.preventDefault();let s=e.getBoundingClientRect(),n=1===r.deltaMode?16*r.deltaY:r.deltaY;i(e=>{var i,a,o,l,c;let d,u;return i=r.clientX-s.left,a=r.clientY-s.top,o=e.scale*Math.exp(-(.002*n)),l=s.width,c=s.height,u=(d=Math.min(8,Math.max(1,o)))/e.scale,Th({scale:d,x:i-(i-e.x)*u,y:a-(a-e.y)*u},l,c)})};return e.addEventListener("wheel",r,{passive:!1}),()=>e.removeEventListener("wheel",r)},[]);let c=n.scale>1.001;return(0,U.jsxs)("div",{ref:s,"data-testid":"image-lightbox-panel",onDoubleClick:()=>i(Tu),onPointerDown:e=>{!c||0!==e.button||e.target.closest("button")||(e.currentTarget.setPointerCapture(e.pointerId),a.current={id:e.pointerId,x:e.clientX,y:e.clientY},l(!0))},onPointerMove:e=>{let r=a.current;if(!r||r.id!==e.pointerId)return;let s=e.clientX-r.x,n=e.clientY-r.y;r.x=e.clientX,r.y=e.clientY;let o=e.currentTarget.getBoundingClientRect();i(e=>Th({...e,x:e.x+s,y:e.y+n},o.width,o.height))},onPointerUp:()=>{a.current=null,l(!1)},onPointerCancel:()=>{a.current=null,l(!1)},className:(0,e1.cn)("relative h-full w-full max-h-[85vh] max-w-6xl touch-none select-none overflow-hidden rounded-md border border-zinc-700 bg-zinc-950 shadow-2xl",c&&(o?"cursor-grabbing":"cursor-grab")),children:[(0,U.jsx)("div",{"data-testid":"image-lightbox-layer",className:"absolute inset-0 origin-top-left",style:{transform:`translate(${n.x}px, ${n.y}px) scale(${n.scale})`},children:(0,U.jsx)("img",{src:e,alt:r,draggable:!1,className:"h-full w-full object-contain"})}),(0,U.jsx)("div",{className:"pointer-events-none absolute bottom-2 left-1/2 -translate-x-1/2 rounded bg-black/60 px-2 py-0.5 text-xs text-white/80",children:c?`${Math.round(100*n.scale)}% \xb7 drag to pan \xb7 double-click to reset`:"Scroll to zoom"}),(0,U.jsx)(rw,{"aria-label":"Close enlarged image",className:"absolute top-2 right-2 rounded-md bg-black/50 p-1.5 text-white/80 transition-colors hover:bg-black/70 hover:text-white focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-white/60",children:(0,U.jsx)(rD,{className:"h-4 w-4"})})]})}function Tp({input:e}){let r=function(e){try{let r="string"==typeof e?JSON.parse(e):e;if(r&&"object"==typeof r&&"string"==typeof r.file_path)return r;return null}catch{return null}}(e);if(!r)return(0,U.jsx)("pre",{className:"bg-muted/50 p-2 rounded overflow-x-auto max-w-full whitespace-pre-wrap break-all",style:{fontSize:"var(--conv-font-size, 12px)"},children:"string"==typeof e?e:JSON.stringify(e,null,2)});let{file_path:s,offset:n,limit:i}=r,a=s.split("/"),o=a.pop()||s,l=a.join("/"),c=null!=n||null!=i,d="";if(c){let e=n??1;d=null!=i?`Lines ${e}\u2013${e+i-1}`:`From line ${e}`}return(0,U.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,U.jsxs)("div",{className:"min-w-0",children:[(0,U.jsx)("span",{className:"conv-text-sm font-medium break-all",children:o}),l&&(0,U.jsx)("p",{className:"conv-text-xs text-muted-foreground truncate",title:s,children:l})]}),c&&(0,U.jsx)(rG,{variant:"outline",className:"text-xs shrink-0",children:d})]})}function Tm({images:e}){return(0,U.jsx)("div",{className:"flex flex-wrap gap-2",children:e.map((e,r)=>(0,U.jsx)(Td,{src:`data:${e.mediaType};base64,${e.data}`,alt:"Image viewed by the agent",className:"max-w-sm max-h-80 rounded-lg border border-border object-contain"},r))})}function Tg({output:e}){let r=e.split("\n").length;return(0,U.jsxs)("details",{children:[(0,U.jsxs)("summary",{className:"conv-text-xs text-muted-foreground cursor-pointer hover:text-foreground",children:["File contents (",r," ",1===r?"line":"lines",")"]}),(0,U.jsx)("pre",{className:"mt-1 bg-muted/50 p-2 rounded overflow-x-auto max-h-48 overflow-y-auto scrollbar-none max-w-full whitespace-pre-wrap break-all",style:{fontSize:"var(--conv-font-size, 12px)"},children:e.length>1e3?e.substring(0,1e3)+"...":e})]})}function Tx({input:e}){let r=function(e){try{let r="string"==typeof e?JSON.parse(e):e;if(r&&"object"==typeof r&&"string"==typeof r.file_path)return r;return null}catch{return null}}(e);if(!r)return(0,U.jsx)("pre",{className:"bg-muted/50 p-2 rounded overflow-x-auto max-w-full whitespace-pre-wrap break-all",style:{fontSize:"var(--conv-font-size, 12px)"},children:"string"==typeof e?e:JSON.stringify(e,null,2)});let{file_path:s,content:n}=r,i=s.split("/"),a=i.pop()||s,o=i.join("/"),l=n.split("\n").length;return(0,U.jsxs)("div",{className:"space-y-1",children:[(0,U.jsxs)("div",{className:"min-w-0",children:[(0,U.jsx)("span",{className:"conv-text-sm font-medium break-all",children:a}),o&&(0,U.jsx)("p",{className:"conv-text-xs text-muted-foreground truncate",title:s,children:o})]}),(0,U.jsxs)("details",{children:[(0,U.jsxs)("summary",{className:"conv-text-xs text-muted-foreground cursor-pointer hover:text-foreground",children:["Content (",l," ",1===l?"line":"lines",")"]}),(0,U.jsx)("pre",{className:"mt-1 bg-muted/50 p-2 rounded overflow-x-auto max-h-48 overflow-y-auto scrollbar-none max-w-full whitespace-pre-wrap break-all",style:{fontSize:"var(--conv-font-size, 12px)"},children:n.length>1e3?n.substring(0,1e3)+"...":n})]})]})}function Tv({output:e}){return e&&""!==e.trim()?(0,U.jsxs)("details",{children:[(0,U.jsx)("summary",{className:"conv-text-xs text-muted-foreground cursor-pointer hover:text-foreground",children:"Result"}),(0,U.jsx)("pre",{className:"mt-1 bg-muted/50 p-2 rounded overflow-x-auto max-h-48 overflow-y-auto scrollbar-none max-w-full whitespace-pre-wrap break-all",style:{fontSize:"var(--conv-font-size, 12px)"},children:e.length>1e3?e.substring(0,1e3)+"...":e})]}):(0,U.jsx)("p",{className:"conv-text-xs text-muted-foreground italic",children:"File written"})}function Ty({input:e}){let r=function(e){try{let r="string"==typeof e?JSON.parse(e):e;if(r&&"object"==typeof r&&"string"==typeof r.command)return r;return null}catch{return null}}(e);if(!r)return(0,U.jsx)("pre",{className:"bg-muted/50 p-2 rounded overflow-x-auto max-w-full whitespace-pre-wrap break-all",style:{fontSize:"var(--conv-font-size, 12px)"},children:"string"==typeof e?e:JSON.stringify(e,null,2)});let{command:s,description:n,timeout:i}=r;return(0,U.jsxs)("div",{className:"space-y-1",children:[n&&(0,U.jsx)("p",{className:"conv-text-xs text-muted-foreground",children:n}),(0,U.jsxs)("div",{className:"flex items-start gap-2",children:[(0,U.jsxs)("pre",{className:"flex-1 min-w-0 bg-muted/50 p-2 rounded overflow-x-auto max-w-full whitespace-pre-wrap break-all",style:{fontSize:"var(--conv-font-size, 12px)"},children:[(0,U.jsx)("span",{className:"text-muted-foreground select-none",children:"$ "}),s]}),null!=i&&(0,U.jsx)(rG,{variant:"outline",className:"text-xs shrink-0 mt-1",children:function(e){if(e>=6e4){let r=e/6e4;return`${r%1==0?r:r.toFixed(1)}m`}return`${e/1e3}s`}(i)})]})]})}function Tb({output:e}){if(!e||""===e.trim())return(0,U.jsx)("p",{className:"conv-text-xs text-muted-foreground italic",children:"No output"});let r=e.split("\n").length;return(0,U.jsxs)("details",{children:[(0,U.jsxs)("summary",{className:"conv-text-xs text-muted-foreground cursor-pointer hover:text-foreground",children:["Output (",r," ",1===r?"line":"lines",")"]}),(0,U.jsx)("pre",{className:"mt-1 bg-muted/50 p-2 rounded overflow-x-auto max-h-48 overflow-y-auto scrollbar-none max-w-full whitespace-pre-wrap break-all",style:{fontSize:"var(--conv-font-size, 12px)"},children:e.length>1e3?e.substring(0,1e3)+"...":e})]})}function Tw({input:e}){let r=function(e){try{let r="string"==typeof e?JSON.parse(e):e;if(r&&"object"==typeof r&&"string"==typeof r.pattern)return r;return null}catch{return null}}(e);if(!r)return(0,U.jsx)("pre",{className:"bg-muted/50 p-2 rounded overflow-x-auto max-w-full whitespace-pre-wrap break-all",style:{fontSize:"var(--conv-font-size, 12px)"},children:"string"==typeof e?e:JSON.stringify(e,null,2)});let s=[];return r.path&&s.push({label:r.path}),r.glob&&s.push({label:r.glob}),r.type&&s.push({label:`.${r.type}`}),r.output_mode&&"files_with_matches"!==r.output_mode&&s.push({label:r.output_mode}),null!=r.context&&s.push({label:`context: ${r.context}`}),null!=r["-C"]&&s.push({label:`context: ${r["-C"]}`}),null!=r["-B"]&&s.push({label:`before: ${r["-B"]}`}),null!=r["-A"]&&s.push({label:`after: ${r["-A"]}`}),r["-i"]&&s.push({label:"case-insensitive"}),r.multiline&&s.push({label:"multiline"}),null!=r.head_limit&&s.push({label:`limit: ${r.head_limit}`}),null!=r.offset&&s.push({label:`offset: ${r.offset}`}),(0,U.jsxs)("div",{className:"space-y-1",children:[(0,U.jsx)("div",{className:"flex items-start gap-2",children:(0,U.jsxs)("pre",{className:"flex-1 min-w-0 bg-muted/50 p-2 rounded overflow-x-auto max-w-full whitespace-pre-wrap break-all",style:{fontSize:"var(--conv-font-size, 12px)"},children:[(0,U.jsx)("span",{className:"text-muted-foreground select-none",children:"/ "}),r.pattern]})}),s.length>0&&(0,U.jsx)("div",{className:"flex items-center gap-1.5 flex-wrap",children:s.map((e,r)=>(0,U.jsx)(rG,{variant:"outline",className:"text-xs",children:e.label},r))})]})}function T_({output:e}){if(!e||""===e.trim())return(0,U.jsx)("p",{className:"conv-text-xs text-muted-foreground italic",children:"No matches"});let r=e.split("\n").length;return(0,U.jsxs)("details",{children:[(0,U.jsxs)("summary",{className:"conv-text-xs text-muted-foreground cursor-pointer hover:text-foreground",children:["Results (",r," ",1===r?"line":"lines",")"]}),(0,U.jsx)("pre",{className:"mt-1 bg-muted/50 p-2 rounded overflow-x-auto max-h-48 overflow-y-auto scrollbar-none max-w-full whitespace-pre-wrap break-all",style:{fontSize:"var(--conv-font-size, 12px)"},children:e.length>1e3?e.substring(0,1e3)+"...":e})]})}function TS({input:e}){let r=function(e){try{let r="string"==typeof e?JSON.parse(e):e;if(r&&"object"==typeof r&&"string"==typeof r.pattern)return r;return null}catch{return null}}(e);return r?(0,U.jsxs)("div",{className:"space-y-1",children:[(0,U.jsx)("div",{className:"flex items-start gap-2",children:(0,U.jsx)("pre",{className:"flex-1 min-w-0 bg-muted/50 p-2 rounded overflow-x-auto max-w-full whitespace-pre-wrap break-all",style:{fontSize:"var(--conv-font-size, 12px)"},children:r.pattern})}),r.path&&(0,U.jsx)("div",{className:"flex items-center gap-1.5 flex-wrap",children:(0,U.jsx)(rG,{variant:"outline",className:"text-xs",children:r.path})})]}):(0,U.jsx)("pre",{className:"bg-muted/50 p-2 rounded overflow-x-auto max-w-full whitespace-pre-wrap break-all",style:{fontSize:"var(--conv-font-size, 12px)"},children:"string"==typeof e?e:JSON.stringify(e,null,2)})}function Tk({output:e}){if(!e||""===e.trim())return(0,U.jsx)("p",{className:"conv-text-xs text-muted-foreground italic",children:"No matches"});let r=e.trim().split("\n").length;return(0,U.jsxs)("details",{children:[(0,U.jsxs)("summary",{className:"conv-text-xs text-muted-foreground cursor-pointer hover:text-foreground",children:[r," ",1===r?"file":"files"," found"]}),(0,U.jsx)("pre",{className:"mt-1 bg-muted/50 p-2 rounded overflow-x-auto max-h-48 overflow-y-auto scrollbar-none max-w-full whitespace-pre-wrap break-all",style:{fontSize:"var(--conv-font-size, 12px)"},children:e.length>1e3?e.substring(0,1e3)+"...":e})]})}let Tj={Explore:"Explore",Bash:"Bash",Plan:"Plan","general-purpose":"General","code-simplifier":"Simplify","superpowers:code-reviewer":"Review","memory-leak-detector":"Memory","directory-structure-validator":"Structure","tech-docs-finder":"Docs","claude-code-guide":"Guide","statusline-setup":"Status"};function TC({input:e}){let r=function(e){try{let r="string"==typeof e?JSON.parse(e):e;if(r&&"object"==typeof r&&"string"==typeof r.description&&"string"==typeof r.subagent_type)return r;return null}catch{return null}}(e);if(!r)return(0,U.jsx)("pre",{className:"bg-muted/50 p-2 rounded overflow-x-auto max-w-full whitespace-pre-wrap break-all",style:{fontSize:"var(--conv-font-size, 12px)"},children:"string"==typeof e?e:JSON.stringify(e,null,2)});let{description:s,subagent_type:n,prompt:i,model:a,max_turns:o,resume:l,run_in_background:c}=r,d=[];return d.push({label:Tj[n]||n}),a&&d.push({label:a}),null!=o&&d.push({label:`${o} turns`}),c&&d.push({label:"background"}),l&&d.push({label:"resume"}),(0,U.jsxs)("div",{className:"space-y-1",children:[(0,U.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,U.jsx)("span",{className:"conv-text-sm",children:s}),d.map((e,r)=>(0,U.jsx)(rG,{variant:"outline",className:"text-xs shrink-0",children:e.label},r))]}),i&&(0,U.jsxs)("details",{children:[(0,U.jsxs)("summary",{className:"conv-text-xs text-muted-foreground cursor-pointer hover:text-foreground",children:["Prompt (",i.length>1e3?`${Math.round(i.length/1e3)}k chars`:`${i.length} chars`,")"]}),(0,U.jsx)("pre",{className:"mt-1 bg-muted/50 p-2 rounded overflow-x-auto max-h-48 overflow-y-auto scrollbar-none max-w-full whitespace-pre-wrap break-all",style:{fontSize:"var(--conv-font-size, 12px)"},children:i.length>1e3?i.substring(0,1e3)+"...":i})]})]})}function TN({output:e}){if(!e||""===e.trim())return(0,U.jsx)("p",{className:"conv-text-xs text-muted-foreground italic",children:"No output"});let r=e.split("\n").length;return(0,U.jsxs)("details",{children:[(0,U.jsxs)("summary",{className:"conv-text-xs text-muted-foreground cursor-pointer hover:text-foreground",children:["Agent result (",r," ",1===r?"line":"lines",")"]}),(0,U.jsx)("pre",{className:"mt-1 bg-muted/50 p-2 rounded overflow-x-auto max-h-48 overflow-y-auto scrollbar-none max-w-full whitespace-pre-wrap break-all",style:{fontSize:"var(--conv-font-size, 12px)"},children:e.length>1e3?e.substring(0,1e3)+"...":e})]})}function TE(e,r){return e.length>r?e.substring(0,r)+"...":e}function TD({input:e}){let r=function(e){try{let r="string"==typeof e?JSON.parse(e):e;if(r&&"object"==typeof r&&"string"==typeof r.file_path&&"string"==typeof r.old_string&&"string"==typeof r.new_string)return r;return null}catch{return null}}(e);if(!r)return(0,U.jsx)("pre",{className:"bg-muted/50 p-2 rounded overflow-x-auto max-w-full whitespace-pre-wrap break-all",style:{fontSize:"var(--conv-font-size, 12px)"},children:"string"==typeof e?e:JSON.stringify(e,null,2)});let{file_path:s,old_string:n,new_string:i,replace_all:a}=r,o=s.split("/"),l=o.pop()||s,c=o.join("/"),d=n.split("\n").length,u=i.split("\n").length;return(0,U.jsxs)("div",{className:"space-y-1",children:[(0,U.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,U.jsxs)("div",{className:"min-w-0",children:[(0,U.jsx)("span",{className:"conv-text-sm font-medium break-all",children:l}),c&&(0,U.jsx)("p",{className:"conv-text-xs text-muted-foreground truncate",title:s,children:c})]}),(0,U.jsx)(rG,{variant:"outline",className:"text-xs shrink-0",children:d===u?`${d} ${1===d?"line":"lines"}`:`${d}\u2192${u} lines`}),a&&(0,U.jsx)(rG,{variant:"outline",className:"text-xs shrink-0",children:"replace all"})]}),(0,U.jsxs)("details",{children:[(0,U.jsx)("summary",{className:"conv-text-xs text-muted-foreground cursor-pointer hover:text-foreground",children:"Diff"}),(0,U.jsxs)("div",{className:"mt-1 conv-text-xs rounded overflow-x-auto max-h-48 overflow-y-auto scrollbar-none max-w-full",children:[(0,U.jsxs)("pre",{className:"bg-red-500/10 p-1.5 rounded-t whitespace-pre-wrap break-all",style:{fontSize:"var(--conv-font-size, 12px)"},children:[(0,U.jsx)("span",{className:"text-red-500 select-none",children:"- "}),TE(n,500)]}),(0,U.jsxs)("pre",{className:"bg-green-500/10 p-1.5 rounded-b whitespace-pre-wrap break-all",style:{fontSize:"var(--conv-font-size, 12px)"},children:[(0,U.jsx)("span",{className:"text-green-500 select-none",children:"+ "}),TE(i,500)]})]})]})]})}function TT({output:e}){if(!e||""===e.trim())return(0,U.jsx)("p",{className:"conv-text-xs text-muted-foreground italic",children:"No output"});if(e.length<=200)return(0,U.jsx)("p",{className:"conv-text-xs text-muted-foreground",children:e});let r=e.split("\n").length;return(0,U.jsxs)("details",{children:[(0,U.jsxs)("summary",{className:"conv-text-xs text-muted-foreground cursor-pointer hover:text-foreground",children:["Result (",r," ",1===r?"line":"lines",")"]}),(0,U.jsx)("pre",{className:"mt-1 bg-muted/50 p-2 rounded overflow-x-auto max-h-48 overflow-y-auto scrollbar-none max-w-full whitespace-pre-wrap break-all",style:{fontSize:"var(--conv-font-size, 12px)"},children:e.length>1e3?e.substring(0,1e3)+"...":e})]})}function TR({input:e}){let r=function(e){try{let r="string"==typeof e?JSON.parse(e):e;if(r&&"object"==typeof r&&"string"==typeof r.url&&"string"==typeof r.prompt)return r;return null}catch{return null}}(e);if(!r)return(0,U.jsx)("pre",{className:"bg-muted/50 p-2 rounded overflow-x-auto max-w-full whitespace-pre-wrap break-all",style:{fontSize:"var(--conv-font-size, 12px)"},children:"string"==typeof e?e:JSON.stringify(e,null,2)});let{display:s,href:n}=function(e){try{let r=new URL(e),s="/"===r.pathname?"":r.pathname,n=r.hostname+s;return{display:n.length>80?n.substring(0,77)+"...":n,href:e}}catch{return{display:e.length>80?e.substring(0,77)+"...":e,href:e}}}(r.url),i=r.prompt.length>150?r.prompt.substring(0,147)+"...":r.prompt;return(0,U.jsxs)("div",{className:"space-y-1",children:[(0,U.jsx)("a",{href:n,target:"_blank",rel:"noopener noreferrer",className:"block conv-text-xs font-mono text-blue-500 hover:underline truncate",children:s}),(0,U.jsxs)("p",{className:"conv-text-xs text-muted-foreground",children:['"',i,'"']})]})}function TA({output:e}){if(!e||""===e.trim())return(0,U.jsx)("p",{className:"conv-text-xs text-muted-foreground italic",children:"No content fetched"});let r=e.split("\n").length;return(0,U.jsxs)("details",{children:[(0,U.jsxs)("summary",{className:"conv-text-xs text-muted-foreground cursor-pointer hover:text-foreground",children:["Response (",r," ",1===r?"line":"lines",")"]}),(0,U.jsx)("pre",{className:"mt-1 bg-muted/50 p-2 rounded overflow-x-auto max-h-48 overflow-y-auto scrollbar-none max-w-full whitespace-pre-wrap break-all",style:{fontSize:"var(--conv-font-size, 12px)"},children:e.length>1e3?e.substring(0,1e3)+"...":e})]})}function TM({input:e}){let r=function(e){try{let r="string"==typeof e?JSON.parse(e):e;if(r&&"object"==typeof r&&"string"==typeof r.query)return r;return null}catch{return null}}(e);return r?(0,U.jsxs)("div",{className:"space-y-1.5",children:[(0,U.jsx)("p",{className:"conv-text-xs font-mono bg-muted/50 px-2 py-1 rounded break-words",children:r.query}),r.allowed_domains&&r.allowed_domains.length>0&&(0,U.jsxs)("div",{className:"flex items-center gap-1 flex-wrap",children:[(0,U.jsx)("span",{className:"conv-text-xs text-muted-foreground",children:"only:"}),r.allowed_domains.map(e=>(0,U.jsx)(rG,{variant:"secondary",className:"text-[10px] px-1.5 py-0",children:e},e))]}),r.blocked_domains&&r.blocked_domains.length>0&&(0,U.jsxs)("div",{className:"flex items-center gap-1 flex-wrap",children:[(0,U.jsx)("span",{className:"conv-text-xs text-muted-foreground",children:"exclude:"}),r.blocked_domains.map(e=>(0,U.jsx)(rG,{variant:"outline",className:"text-[10px] px-1.5 py-0",children:e},e))]})]}):(0,U.jsx)("pre",{className:"bg-muted/50 p-2 rounded overflow-x-auto max-w-full whitespace-pre-wrap break-all",style:{fontSize:"var(--conv-font-size, 12px)"},children:"string"==typeof e?e:JSON.stringify(e,null,2)})}function TI({output:e}){if(!e||""===e.trim())return(0,U.jsx)("p",{className:"conv-text-xs text-muted-foreground italic",children:"No search results"});let r=e.split("\n").length;return(0,U.jsxs)("details",{children:[(0,U.jsxs)("summary",{className:"conv-text-xs text-muted-foreground cursor-pointer hover:text-foreground",children:["Results (",r," ",1===r?"line":"lines",")"]}),(0,U.jsx)("pre",{className:"mt-1 bg-muted/50 p-2 rounded overflow-x-auto max-h-48 overflow-y-auto scrollbar-none max-w-full whitespace-pre-wrap break-all",style:{fontSize:"var(--conv-font-size, 12px)"},children:e.length>1e3?e.substring(0,1e3)+"...":e})]})}function TP({input:e}){let r=function(e){try{let r="string"==typeof e?JSON.parse(e):e;if(r&&"object"==typeof r&&"string"==typeof r.skill)return r;return null}catch{return null}}(e);return r?(0,U.jsxs)("div",{className:"space-y-1",children:[(0,U.jsx)("p",{className:"conv-text-xs font-mono text-foreground",children:r.skill}),r.args&&(0,U.jsxs)("p",{className:"conv-text-xs text-muted-foreground truncate",children:["args: ",r.args]})]}):(0,U.jsx)("pre",{className:"bg-muted/50 p-2 rounded overflow-x-auto max-w-full whitespace-pre-wrap break-all",style:{fontSize:"var(--conv-font-size, 12px)"},children:"string"==typeof e?e:JSON.stringify(e,null,2)})}function TF({output:e}){if(!e||""===e.trim())return(0,U.jsx)("p",{className:"conv-text-xs text-muted-foreground italic",children:"No output"});let r=e.split("\n").length;return(0,U.jsxs)("details",{children:[(0,U.jsxs)("summary",{className:"conv-text-xs text-muted-foreground cursor-pointer hover:text-foreground",children:["Loaded (",r," ",1===r?"line":"lines",")"]}),(0,U.jsx)("pre",{className:"mt-1 bg-muted/50 p-2 rounded overflow-x-auto max-h-48 overflow-y-auto scrollbar-none max-w-full whitespace-pre-wrap break-all",style:{fontSize:"var(--conv-font-size, 12px)"},children:e.length>1e3?e.substring(0,1e3)+"...":e})]})}function TL({input:e}){let r=function(e){try{let r="string"==typeof e?JSON.parse(e):e;if(r&&"object"==typeof r&&"string"==typeof r.task_id)return r;return null}catch{return null}}(e);if(!r)return(0,U.jsx)("pre",{className:"bg-muted/50 p-2 rounded overflow-x-auto max-w-full whitespace-pre-wrap break-all",style:{fontSize:"var(--conv-font-size, 12px)"},children:"string"==typeof e?e:JSON.stringify(e,null,2)});let{task_id:s,block:n,timeout:i}=r,a=[];return a.push({label:!1===n?"non-blocking":"blocking"}),null!=i&&a.push({label:`${Math.round(i/1e3)}s`}),(0,U.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,U.jsx)("code",{className:"conv-text-sm bg-muted/50 px-1.5 py-0.5 rounded",children:s}),a.map((e,r)=>(0,U.jsx)(rG,{variant:"outline",className:"text-xs shrink-0",children:e.label},r))]})}function TO({output:e}){if(!e||""===e.trim())return(0,U.jsx)("p",{className:"conv-text-xs text-muted-foreground italic",children:"No output"});let r=e.split("\n").length;return(0,U.jsxs)("details",{children:[(0,U.jsxs)("summary",{className:"conv-text-xs text-muted-foreground cursor-pointer hover:text-foreground",children:["Task output (",r," ",1===r?"line":"lines",")"]}),(0,U.jsx)("pre",{className:"mt-1 bg-muted/50 p-2 rounded overflow-x-auto max-h-48 overflow-y-auto scrollbar-none max-w-full whitespace-pre-wrap break-all",style:{fontSize:"var(--conv-font-size, 12px)"},children:e.length>1e3?e.substring(0,1e3)+"...":e})]})}function TB({input:e}){let r="string"==typeof e?function(e){try{return JSON.parse(e)}catch{return null}}(e):e,s=r?.changes??[];return 0===s.length?(0,U.jsx)("p",{className:"conv-text-xs text-muted-foreground",children:"No file changes"}):(0,U.jsx)("div",{className:"space-y-2 mt-1",children:s.map((e,r)=>(0,U.jsxs)("div",{children:[(0,U.jsxs)("div",{className:"flex items-center gap-2",children:[(0,U.jsx)(Cn,{className:"h-3 w-3 text-muted-foreground flex-shrink-0"}),(0,U.jsx)("code",{className:"conv-text-xs break-all",children:e.path}),(0,U.jsx)(rG,{variant:"secondary",className:`text-[10px] ${function(e){switch(e){case"added":case"add":return"bg-green-500/10 text-green-600";case"deleted":case"delete":return"bg-red-500/10 text-red-600";default:return"bg-blue-500/10 text-blue-600"}}(e.kind)}`,children:function(e){switch(e){case"added":case"add":return"added";case"deleted":case"delete":return"deleted";default:return"modified"}}(e.kind)})]}),e.diff&&(0,U.jsxs)("details",{className:"mt-1",children:[(0,U.jsx)("summary",{className:"conv-text-xs text-muted-foreground cursor-pointer hover:text-foreground",children:"View diff"}),(0,U.jsx)("pre",{className:"mt-1 p-2 rounded overflow-x-auto max-h-48 overflow-y-auto scrollbar-none max-w-full whitespace-pre-wrap break-all",style:{fontSize:"var(--conv-font-size, 12px)"},children:e.diff.split("\n").map((e,r)=>{let s="";return e.startsWith("+")?s="bg-green-500/10 text-green-700 dark:text-green-400":e.startsWith("-")&&(s="bg-red-500/10 text-red-700 dark:text-red-400"),(0,U.jsx)("div",{className:s,children:e},r)})})]})]},r))})}function Tz({output:e}){let r=e.toLowerCase(),s="text-muted-foreground";return r.includes("completed")||r.includes("success")?s="text-green-600 dark:text-green-400":r.includes("failed")||r.includes("error")?s="text-red-600 dark:text-red-400":(r.includes("declined")||r.includes("denied"))&&(s="text-amber-600 dark:text-amber-400"),(0,U.jsx)("p",{className:`conv-text-xs ${s}`,children:e})}let T$=new Map,TW=new Map,TH=new Map;function TU(e){for(let r of TH.get(e)??[])r()}async function TV(e,r){if(!r){let r=T$.get(e);if(r)return r;let s=TW.get(e);if(s)return s}let s=aC.api.getSchedules(e).then(r=>(T$.set(e,r),TU(e),r)).finally(()=>{TW.get(e)===s&&TW.delete(e)});return TW.set(e,s),s}let Tq="mcp__vibedeckx__propose_schedule";function TK({input:e,toolUseId:r}){let s,{sessionId:n,projectId:i,branch:a,target:o,targetLabel:l,agentType:c,openSchedule:d}=MW(),u=(0,V.useMemo)(()=>{let r,s,n,i,a,o;return s=(r="string"==typeof e?function(e){try{return JSON.parse(e)}catch{return null}}(e):e)&&"object"==typeof r?r:{},i=(n=e=>"string"==typeof e?e:"")(s.prompt),a=n(s.command),o=i.trim()||!a.trim()?"prompt":"command",{name:n(s.name).trim(),cronExpr:n(s.cron_expr).trim(),runType:o,content:"prompt"===o?i:a,timezone:n(s.timezone).trim()||function(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC"}catch{return"UTC"}}()}},[e]),[h,f]=(0,V.useState)(u),[p,m]=(0,V.useState)(a??""),[g,x]=(0,V.useState)(!1),[v,y]=(0,V.useState)(null),{schedule:b,loading:w}=(s=(0,V.useSyncExternalStore)((0,V.useCallback)(e=>{let r;return i?((r=TH.get(i)??new Set).add(e),TH.set(i,r),()=>{r.delete(e),0===r.size&&TH.delete(i)}):()=>{}},[i]),(0,V.useCallback)(()=>i?T$.get(i)??null:null,[i]),()=>null),(0,V.useEffect)(()=>{i&&TV(i,!1).catch(e=>{console.error("Failed to load schedules for proposal lookup:",e)})},[i]),(0,aF.useGlobalEventStream)((0,V.useCallback)(e=>{!e.type?.startsWith("schedule:")||i&&e.projectId===i&&TV(i,!0).catch(()=>{})},[i])),{schedule:r&&n&&s?s.find(e=>e.source_tool_use_id===r&&e.source_session_id===n)??null:null,loading:null===s}),_="command"===h.runType,S=!!i&&!!n&&!!r,k=async()=>{if(S&&!g){x(!0),y(null);try{let e,s=await aC.api.createSchedule(i,{name:h.name||"Scheduled check",cron_expr:h.cronExpr,timezone:h.timezone,target:o,run_type:h.runType,prompt_provider:"command"===h.runType?null:(0,aC.parsePromptProvider)("claude-code"===c?"claude":c),content:h.content,cwd_mode:"branch",branch:p.trim()?p.trim():null,source:{session_id:n,tool_use_id:r}});e=T$.get(i)??[],T$.set(i,[...e.filter(e=>e.id!==s.id),s]),TU(i)}catch(e){y(e instanceof Error?e.message:"Failed to create schedule")}finally{x(!1)}}};return b?(0,U.jsx)("div",{className:"rounded-lg border border-emerald-500/30 bg-emerald-500/5 p-3",children:(0,U.jsxs)("div",{className:"flex items-start gap-2",children:[(0,U.jsx)(os,{className:"mt-0.5 h-4 w-4 flex-shrink-0 text-emerald-500"}),(0,U.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,U.jsx)("p",{className:"text-sm font-medium text-foreground break-words",children:b.name}),(0,U.jsxs)("p",{className:"mt-0.5 font-mono text-xs text-muted-foreground break-all",children:[b.cron_expr," · ",b.timezone,"command"===b.run_type?" · command":` \xb7 ${b.prompt_provider??"claude"}`,b.branch?` \xb7 ${b.branch}`:""]})]}),d&&(0,U.jsxs)(a$.Button,{variant:"ghost",size:"sm",className:"flex-shrink-0",onClick:()=>d(b.id),children:[(0,U.jsx)(oh,{className:"mr-1 h-3.5 w-3.5"}),"View"]})]})}):(0,U.jsxs)("div",{className:"rounded-lg border border-border bg-muted/30 p-3",children:[(0,U.jsxs)("div",{className:"space-y-2",children:[(0,U.jsx)(aX,{value:h.name,onChange:e=>f(r=>({...r,name:e.target.value})),placeholder:"Name",className:"h-8 text-sm","aria-label":"Schedule name",disabled:g}),(0,U.jsxs)("div",{className:"flex gap-2",children:[(0,U.jsx)(aX,{value:h.cronExpr,onChange:e=>f(r=>({...r,cronExpr:e.target.value})),placeholder:"0 9 * * *",className:"h-8 font-mono text-xs","aria-label":"Cron expression",disabled:g}),(0,U.jsx)(aX,{value:p,onChange:e=>m(e.target.value),placeholder:"main worktree",className:"h-8 font-mono text-xs","aria-label":"Branch",disabled:g})]}),(0,U.jsx)(aq,{value:h.content,onChange:e=>f(r=>({...r,content:e.target.value})),placeholder:_?"Command to run":"What the scheduled agent should check",className:(0,e1.cn)("text-xs",_?"min-h-16 font-mono":"min-h-24"),"aria-label":_?"Check command":"Check prompt",disabled:g})]}),(0,U.jsxs)("p",{className:"mt-2 text-xs text-muted-foreground",children:[_?"Runs as a command":`Runs with ${c??"claude"}`," on ",l," · ",h.timezone]}),v&&(0,U.jsx)("p",{className:"mt-2 text-xs text-red-500 break-words",children:v}),(0,U.jsxs)("div",{className:"mt-3 flex items-center gap-2",children:[(0,U.jsxs)(a$.Button,{size:"sm",onClick:k,disabled:!S||g||w,children:[g?(0,U.jsx)(aP,{className:"mr-1 h-3.5 w-3.5 animate-spin"}):(0,U.jsx)(aM,{className:"mr-1 h-3.5 w-3.5"}),v?"Retry":"Create schedule"]}),d&&(0,U.jsx)(a$.Button,{variant:"ghost",size:"sm",onClick:()=>d(null),disabled:g,children:"View existing schedules"})]})]})}var r0=rQ;let TX=(0,rE.default)("corner-down-right",[["path",{d:"m15 10 5 5-5 5",key:"qqa56n"}],["path",{d:"M4 4v7a4 4 0 0 0 4 4h12",key:"z08zvw"}]]),TY=null,TG="__none__";function TJ({tasks:e,value:r,onChange:s,excludeIds:n,sessionId:i,disabled:a,className:o,field:l,align:c="start"}){let{mine:d,others:u}=(0,V.useMemo)(()=>{let s=e.filter(e=>!n?.has(e.id)&&(e.id===r||null===e.archived_at&&("todo"===e.status||"in_progress"===e.status)));return{mine:i?s.filter(e=>e.source_session_id===i):[],others:i?s.filter(e=>e.source_session_id!==i):s}},[e,n,i,r]),h=l&&r?e.find(e=>e.id===r):void 0;return(0,U.jsxs)(fP,{value:r??TG,onValueChange:e=>s(e===TG?null:e),disabled:a,children:[(0,U.jsx)(fL,{size:"sm",className:(0,e1.cn)("min-w-0 text-xs",l&&"-ml-2 h-[30px] max-w-full gap-2 border-transparent px-2 text-[12.5px] shadow-none hover:bg-muted data-[state=open]:bg-muted dark:bg-transparent [&>svg:last-child]:size-3 [&>svg:last-child]:opacity-0 hover:[&>svg:last-child]:opacity-70 data-[state=open]:[&>svg:last-child]:opacity-70",l&&!h&&"text-muted-foreground/80",o),"aria-label":"Parent task",children:l?(0,U.jsx)(fF,{children:h?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(ac,{status:h.status}),(0,U.jsx)("span",{className:"truncate",children:h.title})]}):"None"}):(0,U.jsx)(fF,{})}),(0,U.jsxs)(fO,{position:"popper",align:c,collisionPadding:8,className:"max-w-[min(28rem,90vw)]",children:[(0,U.jsx)(fB,{value:TG,children:"No parent"}),d.length>0&&(0,U.jsx)(fz,{}),d.map(e=>(0,U.jsx)(fB,{value:e.id,className:"*:[span]:last:min-w-0",children:(0,U.jsx)("span",{className:"truncate",children:e.title})},e.id)),u.length>0&&(0,U.jsx)(fz,{}),u.map(e=>(0,U.jsx)(fB,{value:e.id,className:"*:[span]:last:min-w-0",children:(0,U.jsx)("span",{className:"truncate",children:e.title})},e.id))]})]})}var Cj=rQ;let TZ=(0,V.createContext)(null),TQ=TZ.Provider,{harden:T0,...T1}=Cj.e,T2=[...Object.values(T1),function(){return e=>{!function e(r){if(!r.children||"pre"===r.tagName)return;let s=[];for(let n of r.children)"element"===n.type&&"a"===n.tagName?s.push(...function(e){let r,s=Du(String(e.properties?.href??""));if(!s)return[e];let n=!(r=s.rawPath.replace(/^(?:\.\/)+/,""))||r.startsWith("/")||"~"===r||r.startsWith("~/")||r.split("/").some(e=>".."===e)?null:r;return n?[Dh(n,s.line,e.children??[])]:e.children??[]}(n)):(e(n),s.push(n));r.children=s}(e)}},...T0?[T0]:[]],T5="wrap-anywhere font-medium text-primary underline decoration-primary/60 underline-offset-2 transition-colors hover:text-primary/80 hover:decoration-primary",T3={a:function({node:e,children:r,href:s,className:n,...i}){let a=(0,V.useContext)(TZ),o=e?.properties?.dataFileRaw;if(!o){let e="string"==typeof s&&s.startsWith("#");return(0,U.jsx)("a",{href:s,className:(0,e1.cn)(T5,n),...e?{}:{target:"_blank",rel:"noreferrer noopener"},...i,children:r})}let l=e?.properties?.dataFileLine,c=null!=l?Number(l):null;return a?(0,U.jsx)("a",{href:"#file-ref",className:(0,e1.cn)(T5,"cursor-pointer"),title:null!=c?`${o}:${c}`:o,onClick:e=>{e.preventDefault(),a(o,c)},children:r}):(0,U.jsx)(U.Fragment,{children:r})}},T4="mcp__vibedeckx__propose_task";function T6(e){try{return JSON.parse(e)}catch{return null}}let T7={low:"bg-slate-400",medium:"bg-amber-400",high:"bg-orange-500",urgent:"bg-red-500"},T8="bg-violet-600 text-white hover:bg-violet-700 dark:bg-violet-500 dark:hover:bg-violet-600",T9="w-[84px] shrink-0 justify-center",Re="grid grid-cols-[22px_minmax(0,1fr)_auto] gap-x-2.5 gap-y-1 border-t border-border/60 px-3 first:border-t-0";function Rt({input:e,toolUseId:r}){var s;let n,i,a,{sessionId:o,projectId:l,openTask:c}=MW(),d=(0,V.useMemo)(()=>{let r,s,n,i;return n=Array.isArray((s=(r="string"==typeof e?T6(e):e)&&"object"==typeof r?r:{}).tasks)?s.tasks:[],{parentTaskId:(i=e=>"string"==typeof e?e:"")(s.parent_task_id).trim()||null,items:n.map(e=>{let r=e&&"object"==typeof e?e:{},s=i(r.priority).toLowerCase();return{title:i(r.title).trim(),description:i(r.description),priority:r3.includes(s)?s:"medium"}})}},[e]),u=(0,V.useMemo)(()=>(function(e){let r="string"==typeof e?T6(e):e,s=r&&"object"==typeof r?r:{},n=s.tasks;if(!Array.isArray(n)||0===n.length)return"The proposal had no tasks.";if(n.length>10)return`It listed ${n.length} tasks; at most 10 fit in one proposal.`;let i=s.parent_task_id;if(null!=i&&("string"!=typeof i||i.length>200))return"Its parent task id was malformed.";let a=e=>"string"==typeof e?e.trim():"";for(let[e,r]of n.entries()){let s=r&&"object"==typeof r?r:{},n=a(s.title),i=a(s.description),o=a(s.priority).toLowerCase();if(!n||n.length>200)return`Task ${e+1} had a missing or overlong title.`;if(!i||i.length>2e4)return`Task ${e+1} had a missing or overlong description.`;if(o&&!r3.includes(o))return`Task ${e+1} had an unknown priority.`}return null})(e),[e]),[h,f]=(0,V.useState)(d.items),[p,m]=(0,V.useState)(void 0),[g,x]=(0,V.useState)(()=>new Map),[v,y]=(0,V.useState)(()=>new Set),[b,w]=(0,V.useState)(()=>new Set),[_,S]=(0,V.useState)(!1),[k,j]=(0,V.useState)(null),[C,N]=(0,V.useState)(()=>new Map),{byItem:E,tasks:D,loading:T,loadError:R,retry:A}=D$(l,o,r),M=void 0!==p?p:d.parentTaskId&&D?.some(e=>e.id===d.parentTaskId)?d.parentTaskId:null,I=e=>g.has(e)?g.get(e):M,P=e=>e?D?.find(r=>r.id===e)?.title:void 0,F=(0,V.useRef)(null),[L,O]=(0,V.useState)(!1);(0,V.useEffect)(()=>{if(!function(e){if(!e||!TY||TY.toolUseId!==e)return!1;let r=Date.now()-TY.at<=3e4;return TY=null,r}(r))return;F.current?.scrollIntoView({block:"center",behavior:"smooth"}),O(!0);let e=setTimeout(()=>O(!1),2e3);return()=>clearTimeout(e)},[r]);let B=!!l&&!!o&&!!r,z=(e,r)=>y(s=>{let n=new Set(s);return r?n.add(e):n.delete(e),n}),$=(0,V.useRef)(null),W=(e,r)=>{$.current={index:e,field:r},z(e,!0)},H=(e,r)=>s=>{let n=$.current;s&&n?.index===e&&n.field===r&&($.current=null,s.focus({preventScroll:!0}))},q=(e,r)=>f(s=>s.map((s,n)=>n===e?{...s,...r}:s)),K=async e=>{if(!B||b.has(e))return;let s=h[e];if(!s.description.trim()){N(r=>new Map(r).set(e,"Description is required")),z(e,!0);return}w(r=>new Set(r).add(e)),N(r=>{let s=new Map(r);return s.delete(e),s});try{var n,i;let a=await aC.api.createTask(l,{title:s.title.trim()||void 0,description:s.description,priority:s.priority,source:{session_id:o,tool_use_id:r,item_index:e},parent_id:I(e)});n=l,i=a,Dz(n,[i]),z(e,!1)}catch(r){N(s=>new Map(s).set(e,r instanceof Error?r.message:"Failed to create task"))}finally{w(r=>{let s=new Set(r);return s.delete(e),s})}},X=h.map((e,r)=>r).filter(e=>!E.has(e)),Y=async()=>{if(!B||_)return;let e=X.filter(e=>!h[e].description.trim());if(e.length>0){N(r=>{let s=new Map(r);for(let r of e)s.set(r,"Description is required");return s}),y(r=>new Set([...r,...e]));return}S(!0),j(null);try{let e=await aC.api.createTasks(l,X.map(e=>({title:h[e].title.trim()||void 0,description:h[e].description,priority:h[e].priority,source:{session_id:o,tool_use_id:r,item_index:e},parent_id:I(e)})));Dz(l,e),N(new Map),y(new Set)}catch(r){let e=r instanceof aC.TaskBatchRejectedError;j({message:r instanceof Error?r.message:"Failed to create tasks",rejected:e}),e||A()}finally{S(!1)}};if(u)return(0,U.jsxs)("div",{className:"flex items-start gap-2 rounded-xl border border-border bg-muted/40 px-3 py-2.5 text-[11.5px] text-muted-foreground",children:[(0,U.jsx)(oi,{className:"mt-px h-3.5 w-3.5 shrink-0"}),(0,U.jsxs)("span",{className:"min-w-0 break-words",children:["Not proposed — ",u," The agent was told why and may propose again."]})]});let G=h.length-X.length,J=0===X.length,Z=J?(n=(s=[...E.values()]).filter(e=>null!==e.archived_at).length,(a=[[(i=s.filter(e=>null===e.archived_at)).filter(e=>"done"===e.status).length,"done"],[i.filter(e=>"cancelled"===e.status).length,"cancelled"],[n,"archived"]].filter(([e])=>e>0).map(([e,r])=>`${e} ${r}`)).length?`All filed \xb7 ${a.join(", ")}`:"All filed"):0===G?"Nothing is created until you confirm":`${X.length} left to confirm`,Q=X.filter(e=>b.has(e)).length;return(0,U.jsxs)("div",{ref:F,className:(0,e1.cn)("overflow-hidden rounded-xl border border-border bg-card shadow-xs transition-shadow",L&&"ring-2 ring-violet-500/45 ring-offset-2 ring-offset-background"),children:[R&&(0,U.jsxs)("div",{className:"flex items-center gap-2 border-b border-red-500/20 bg-red-500/5 px-3 py-2 text-[11.5px] text-red-700 dark:text-red-400",children:[(0,U.jsx)(ou,{className:"h-3 w-3 shrink-0"}),(0,U.jsxs)("span",{className:"min-w-0 break-words",children:["Couldn't check which tasks already exist: ",R]}),(0,U.jsx)(a$.Button,{variant:"outline",size:"sm",className:"ml-auto h-[22px] shrink-0 border-red-500/30 px-2 text-[11px] text-red-700 dark:text-red-400",onClick:A,children:"Retry"})]}),(0,U.jsxs)("div",{className:"flex flex-wrap items-center gap-x-2.5 gap-y-2 border-b border-border/60 bg-muted/40 px-3 py-2.5",children:[(0,U.jsx)("span",{className:(0,e1.cn)("grid h-[26px] w-[26px] shrink-0 place-items-center rounded-[7px] border",J?"border-emerald-500/25 bg-emerald-500/10 text-emerald-600 dark:text-emerald-400":"border-violet-500/25 bg-violet-500/10 text-violet-600 dark:text-violet-400"),children:J?(0,U.jsx)(al.Check,{className:"h-3.5 w-3.5",strokeWidth:2.2}):(0,U.jsx)(Da,{className:"h-3.5 w-3.5"})}),(0,U.jsxs)("div",{className:"min-w-0",children:[(0,U.jsx)("div",{className:"text-[13px] font-semibold tracking-tight text-foreground",children:h.length>1?`${h.length} proposed tasks`:"Proposed task"}),(0,U.jsx)("div",{className:"text-[11px] text-muted-foreground",children:Z})]}),!J&&D&&(0,U.jsxs)("div",{className:"ml-auto flex min-w-0 items-center gap-1.5 text-[11px] text-muted-foreground",children:[(0,U.jsx)("span",{className:"shrink-0",children:X.length>1?"File these under":"File under"}),(0,U.jsx)(TJ,{tasks:D,value:M,onChange:e=>{m(e),x(new Map)},sessionId:o,disabled:b.size>0||_,align:"end",className:"h-[26px] max-w-[230px] bg-card text-[11.5px]"})]})]}),(0,U.jsx)("div",{className:"flex flex-col",children:h.map((e,r)=>{let s=E.get(r);if(s)return(0,U.jsx)(Rn,{task:s,parentTitle:P(s.parent_id),onOpen:c},r);let n=b.has(r),i=n||_,a=C.get(r),l=!e.description.trim(),d=I(r),u=(e,s=!1)=>(0,U.jsxs)(a$.Button,{size:"sm",variant:e?"default":"outline",className:(0,e1.cn)("h-6 gap-1 rounded-[7px] px-2.5 text-[11.5px]",e&&T8,s&&T9),"aria-label":"Create task",onClick:()=>void K(r),disabled:!B||i||T||v.has(r)&&l,children:[n?(0,U.jsx)(aP,{className:"h-3 w-3 animate-spin"}):(0,U.jsx)(oS,{className:"h-3 w-3"}),n?"Creating…":a&&!l?"Retry":"Create"]}),h=(0,U.jsx)(Rs,{value:e.priority,onChange:e=>q(r,{priority:e}),disabled:i}),f=a&&(0,U.jsxs)("p",{className:"col-span-2 col-start-2 flex items-center gap-1.5 text-[11.5px] break-words text-red-500",children:[(0,U.jsx)(ou,{className:"h-3 w-3 shrink-0"}),a]});return v.has(r)?(0,U.jsxs)("div",{className:(0,e1.cn)(Re,"bg-muted/40 pt-[11px] pb-3",i&&"opacity-70"),children:[(0,U.jsx)("span",{className:"pt-[7px] font-mono text-[10.5px] text-muted-foreground/70",children:Rr(r)}),(0,U.jsx)(aX,{value:e.title,onChange:e=>q(r,{title:e.target.value}),placeholder:"Title",className:"h-[30px] rounded-lg bg-card text-[13px] font-medium","aria-label":"Task title",ref:H(r,"title"),disabled:i}),(0,U.jsxs)("span",{className:"flex items-center gap-1.5 self-start pt-[3px]",children:[h,(0,U.jsx)("span",{className:T9,"aria-hidden":!0})]}),(0,U.jsx)(aq,{value:e.description,onChange:e=>q(r,{description:e.target.value}),placeholder:"What's left to do, and how to tell it's done",className:(0,e1.cn)("col-span-2 col-start-2 mt-1 min-h-[84px] rounded-lg bg-card font-mono text-[11.5px] leading-relaxed",l&&"border-red-500/50 focus-visible:ring-red-500/20"),"aria-label":"Task description","aria-invalid":l||void 0,ref:H(r,"description"),disabled:i}),f??(l&&(0,U.jsxs)("p",{className:"col-span-2 col-start-2 flex items-center gap-1.5 text-[11.5px] text-red-500",children:[(0,U.jsx)(ou,{className:"h-3 w-3 shrink-0"}),"Description is required"]})),(0,U.jsxs)("div",{className:"col-span-2 col-start-2 flex min-w-0 items-center gap-2 text-[10.5px] text-muted-foreground",children:[D&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)("span",{className:"shrink-0",children:"Parent"}),(0,U.jsx)(TJ,{tasks:D,value:d,onChange:e=>x(s=>new Map(s).set(r,e)),sessionId:o,disabled:i,className:"h-6 max-w-56 bg-card text-[11px]"})]}),(0,U.jsx)("span",{className:"flex-1"}),(0,U.jsx)(a$.Button,{variant:"ghost",size:"sm",className:"h-6 px-2.5 text-[11.5px] text-muted-foreground",onClick:()=>z(r,!1),disabled:i,children:"Collapse"}),u(!0)]})]},r):(0,U.jsxs)("div",{className:(0,e1.cn)(Re,"pt-[11px] pb-3",i&&"opacity-70"),children:[(0,U.jsx)("span",{className:"pt-0.5 font-mono text-[10.5px] text-muted-foreground/70",children:Rr(r)}),(0,U.jsx)("button",{type:"button","data-proposed-title":!0,title:"Click to edit",className:"-mx-1 -my-px cursor-text rounded px-1 py-px text-left text-[13px] font-medium break-words text-foreground hover:bg-muted disabled:cursor-default",onClick:()=>W(r,"title"),disabled:i,children:e.title||(0,U.jsx)("span",{className:"text-muted-foreground",children:"Untitled"})}),(0,U.jsxs)("span",{className:"flex items-center gap-1.5 self-start",children:[h,u(1===X.length,!0)]}),(0,U.jsx)("div",{"data-markdown-field":"Task description",title:"Click to edit",className:(0,e1.cn)("col-start-2 line-clamp-2 cursor-text text-xs leading-normal text-muted-foreground [&_*]:my-0 [&_code]:rounded [&_code]:px-1 [&_code]:py-0 [&_code]:text-[11px]",av),onClick:e=>{i||e.target.closest("a, button")||window.getSelection()?.isCollapsed&&W(r,"description")},children:l?(0,U.jsx)("span",{className:"italic",children:"No description"}):(0,U.jsx)(r0.i,{mode:"static",rehypePlugins:T2,components:T3,children:e.description})}),d!==M&&(0,U.jsxs)("span",{className:"col-start-2 flex min-w-0 items-center gap-1 text-[11px] text-muted-foreground",children:[(0,U.jsx)(TX,{className:"h-2.5 w-2.5 shrink-0"}),(0,U.jsx)("span",{className:"truncate",children:P(d)??"No parent"})]}),f]},r)})}),k&&!J&&(0,U.jsxs)("div",{className:"flex items-start gap-1.5 border-t border-red-500/20 bg-red-500/5 px-3 py-2 text-[11.5px] break-words text-red-700 dark:text-red-400",children:[(0,U.jsx)(ou,{className:"mt-px h-3 w-3 shrink-0"}),(0,U.jsx)("span",{className:"min-w-0",children:k.rejected?`Couldn't create the tasks — none were created. ${k.message}`:`Couldn't confirm whether the tasks were created (${k.message}). Any that were will show as created; trying again won't duplicate them.`})]}),h.length>1&&!J&&(0,U.jsxs)("div",{className:"flex items-center gap-2.5 border-t border-border/60 bg-muted/40 px-3 py-[9px]",children:[(0,U.jsxs)("span",{className:"flex items-center gap-2 text-[11px] text-muted-foreground",children:[(0,U.jsx)("span",{className:"flex gap-[3px]","aria-hidden":!0,children:h.map((e,r)=>(0,U.jsx)("i",{className:(0,e1.cn)("h-1 w-3.5 rounded-sm",E.has(r)?"bg-violet-500":b.has(r)?"bg-violet-500/40":"bg-border")},r))}),Q>0?`Creating ${Q}…`:`${G} of ${h.length} created`]}),(0,U.jsx)("span",{className:"flex-1"}),X.length>1&&(0,U.jsxs)(a$.Button,{size:"sm",className:(0,e1.cn)("h-7 gap-1.5 rounded-lg px-3 text-xs",T8),onClick:()=>void Y(),disabled:!B||T||_||Q>0,children:[_?(0,U.jsx)(aP,{className:"h-3 w-3 animate-spin"}):(0,U.jsx)(Da,{className:"h-3 w-3"}),_?"Creating…":`Create all ${X.length}`]})]})]})}let Rr=e=>String(e+1).padStart(2,"0");function Rs({value:e,onChange:r,disabled:s}){return(0,U.jsxs)(fP,{value:e,onValueChange:e=>r(e),disabled:s,children:[(0,U.jsx)(fL,{size:"sm",className:"h-6! w-[88px] shrink-0 justify-between gap-1 rounded-[7px] bg-card py-0 pr-1.5 pl-2 text-[11px] font-medium","aria-label":"Task priority",children:(0,U.jsx)(fF,{})}),(0,U.jsx)(fO,{children:r3.map(e=>(0,U.jsxs)(fB,{value:e,children:[(0,U.jsx)("span",{className:(0,e1.cn)("h-[7px] w-[7px] shrink-0 rounded-full",T7[e])}),r2[e].label]},e))})]})}function Rn({task:e,parentTitle:r,onOpen:s}){let n="done"===e.status||"cancelled"===e.status||null!==e.archived_at,{Icon:i,label:a,tone:o}=null!==e.archived_at?{Icon:aH,label:"Archived",tone:"text-muted-foreground"}:"done"===e.status?{Icon:os,label:"Done",tone:"text-emerald-500"}:"cancelled"===e.status?{Icon:oi,label:"Cancelled",tone:"text-muted-foreground"}:"in_progress"===e.status?{Icon:c2,label:"In progress",tone:"text-blue-500"}:{Icon:i5,label:"Created",tone:"text-violet-500"};return(0,U.jsxs)("div",{"data-created-task":!0,className:(0,e1.cn)(Re,"items-center py-[9px]",n?"bg-card":"bg-violet-500/[0.04]"),children:[(0,U.jsx)(i,{className:(0,e1.cn)("h-[15px] w-[15px] justify-self-center",o)}),(0,U.jsx)("p",{className:(0,e1.cn)("text-[13px] font-medium break-words",n?"text-muted-foreground line-through decoration-border":"text-foreground"),children:e.title}),s&&(0,U.jsxs)(a$.Button,{variant:"ghost",size:"sm",className:"col-start-3 row-span-2 row-start-1 h-6 gap-1 px-2 text-[11.5px] text-muted-foreground",onClick:()=>s(e),children:["View",(0,U.jsx)(rz,{className:"h-3 w-3"})]}),(0,U.jsxs)("div",{className:"col-start-2 flex flex-wrap items-center gap-1.5 text-[11px] text-muted-foreground",children:[(0,U.jsx)("span",{className:(0,e1.cn)("font-medium",o),children:a}),(0,U.jsx)("span",{className:"text-border",children:"·"}),(0,U.jsx)("span",{className:(0,e1.cn)("h-[7px] w-[7px] shrink-0 rounded-full",T7[e.priority])}),r2[e.priority].label,r&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)("span",{className:"text-border",children:"·"}),(0,U.jsxs)("span",{className:"flex max-w-[220px] min-w-0 items-center gap-1",children:[(0,U.jsx)(TX,{className:"h-2.5 w-2.5 shrink-0"}),(0,U.jsx)("span",{className:"truncate",children:r})]})]})]})]})}let Ri="mcp__vibedeckx__propose_task_update",Ra=["title","status","priority","parent","description"],Ro={title:"Title",status:"Status",priority:"Priority",parent:"Parent",description:"Description"},Rl={title:"title",status:"status",priority:"priority",parent:"parent_task_id",description:"description"},Rc=e=>{let r="string"==typeof e?function(e){try{return JSON.parse(e)}catch{return null}}(e):e,s=r&&"object"==typeof r?r:{};return Array.isArray(s.updates)?s.updates:null};function Rd(e,r,s){if(null===s)return null;let n=new Map(e.map(e=>[e.id,e])),i=new Set;for(let e=s;null!==e;e=n.get(e)?.parent_id??null){if(e===r)return"A task can't be nested under itself or its own sub-task.";if(i.has(e))break;if(i.add(e),!n.has(e))return"The proposed parent task doesn't exist."}return null}let Ru="border-t border-border/60 px-3 py-2.5 first:border-t-0";function Rh({input:e}){let{sessionId:r,projectId:s,openTask:n}=MW(),i=(0,V.useMemo)(()=>(Rc(e)??[]).map(e=>{let r=e&&"object"==typeof e?e:{};return{taskId:"string"==typeof r.task_id?r.task_id.trim():"",..."string"==typeof r.title?{title:r.title.trim()}:{},..."string"==typeof r.description?{description:r.description}:{},..."string"==typeof r.status?{status:r.status}:{},..."string"==typeof r.priority?{priority:r.priority}:{},...null===r.parent_task_id||"string"==typeof r.parent_task_id?{parent:"string"==typeof r.parent_task_id?r.parent_task_id.trim():null}:{}}}),[e]),a=(0,V.useMemo)(()=>(function(e){let r=Rc(e);if(!r||0===r.length)return"The proposal had no updates.";if(r.length>10)return`It listed ${r.length} updates; at most 10 fit in one proposal.`;let s=new Set;for(let[e,n]of r.entries()){let r=n&&"object"==typeof n?n:{},i="string"==typeof r.task_id?r.task_id.trim():"";if(!i||i.length>200)return`Update ${e+1} had no task id.`;if(s.has(i))return"It listed one task more than once.";if(s.add(i),void 0!==r.title&&("string"!=typeof r.title||!r.title.trim()||r.title.trim().length>200))return`Update ${e+1} had an empty or overlong title.`;if(void 0!==r.description&&("string"!=typeof r.description||!r.description.trim()||r.description.length>2e4))return`Update ${e+1} had an empty or overlong description.`;if(void 0!==r.status&&!r5.includes(r.status))return`Update ${e+1} had an unknown status.`;if(void 0!==r.priority&&!r3.includes(r.priority))return`Update ${e+1} had an unknown priority.`;if(void 0!==r.parent_task_id&&null!==r.parent_task_id&&("string"!=typeof r.parent_task_id||!r.parent_task_id.trim()||r.parent_task_id.trim().length>200))return`Update ${e+1} had an invalid parent task id.`;if(Ra.every(e=>void 0===r[Rl[e]]))return`Update ${e+1} changed nothing.`}return null})(e),[e]),{tasks:o,loading:l,loadError:c,retry:d}=D$(s,r,null),[u,h]=(0,V.useState)(()=>new Set),[f,p]=(0,V.useState)(!1),[m,g]=(0,V.useState)(()=>new Map),[x,v]=(0,V.useState)(null),y=(0,V.useMemo)(()=>o?function(e,r){let s=new Map(r.map(e=>[e.id,e])),n=new Map;for(let r of e){let e=s.get(r.taskId);e&&void 0!==r.parent&&r.parent!==(e.parent_id??null)&&n.set(r.taskId,r.parent)}for(;;){let e=r.map(e=>n.has(e.id)?{...e,parent_id:n.get(e.id)}:e),s=[...n].filter(([r,s])=>null!==Rd(e,r,s));if(0===s.length)return new Set(n.keys());for(let[e]of s)n.delete(e)}}(i,o):new Set,[i,o]),b=i.map(e=>{let r=o?.find(r=>r.id===e.taskId)??null,s=r&&o?function(e,r,s=[]){return Ra.filter(n=>"parent"===n?void 0!==e.parent&&e.parent!==(r.parent_id??null)&&null===Rd(s,r.id,e.parent):void 0!==e[n]&&e[n]!==(r[n]??""))}(e,r,o):[],n=!!r&&y.has(r.id),i=Ra.filter(e=>s.includes(e)||"parent"===e&&n);return{update:e,task:r,changes:s,batchChanges:i,parentProblem:r&&o&&!n?void 0===e.parent||e.parent===(r.parent_id??null)?null:Rd(o,r.id,e.parent):null}}),w=b.flatMap((e,r)=>e.batchChanges.length>0?[r]:[]),_=(e,r)=>{let{update:s,changes:n,batchChanges:i}=b[e];return Object.fromEntries((r?i:n).map(e=>"parent"===e?["parent_id",s.parent]:[e,s[e]]))},S=async e=>{let{task:r,changes:n}=b[e];if(!(!s||!r||0===n.length||u.has(e))){h(r=>new Set(r).add(e)),g(r=>{let s=new Map(r);return s.delete(e),s});try{var i,a;i=s,a=await aC.api.updateTask(r.id,_(e,!1)),Dz(i,[a])}catch(r){g(s=>new Map(s).set(e,r instanceof Error?r.message:"Failed to update task"))}finally{h(r=>{let s=new Set(r);return s.delete(e),s})}}},k=async()=>{if(s&&!f&&0!==w.length){p(!0),v(null);try{let e=await aC.api.updateTasks(s,w.map(e=>({id:b[e].task.id,..._(e,!0)})));Dz(s,e),g(new Map)}catch(r){let e=r instanceof aC.TaskBatchRejectedError;v({message:r instanceof Error?r.message:"Failed to update tasks",rejected:e}),e||d()}finally{p(!1)}}};if(a)return(0,U.jsxs)("div",{className:"flex items-start gap-2 rounded-xl border border-border bg-muted/40 px-3 py-2.5 text-[11.5px] text-muted-foreground",children:[(0,U.jsx)(oi,{className:"mt-px h-3.5 w-3.5 shrink-0"}),(0,U.jsxs)("span",{className:"min-w-0 break-words",children:["Not proposed — ",a," The agent was told why and may propose again."]})]});let j=null!==o&&0===w.length,C=null===o?"Checking the current tasks…":j?"Nothing left to apply":w.length<i.length?`${w.length} left to apply`:"Nothing changes until you apply";return(0,U.jsxs)("div",{className:"overflow-hidden rounded-xl border border-border bg-card shadow-xs",children:[c&&(0,U.jsxs)("div",{className:"flex items-center gap-2 border-b border-red-500/20 bg-red-500/5 px-3 py-2 text-[11.5px] text-red-700 dark:text-red-400",children:[(0,U.jsx)(ou,{className:"h-3 w-3 shrink-0"}),(0,U.jsxs)("span",{className:"min-w-0 break-words",children:["Couldn't load the current tasks: ",c]}),(0,U.jsx)(a$.Button,{variant:"outline",size:"sm",className:"ml-auto h-[22px] shrink-0 border-red-500/30 px-2 text-[11px] text-red-700 dark:text-red-400",onClick:d,children:"Retry"})]}),(0,U.jsxs)("div",{className:"flex items-center gap-2.5 border-b border-border/60 bg-muted/40 px-3 py-2.5",children:[(0,U.jsx)("span",{className:(0,e1.cn)("grid h-[26px] w-[26px] shrink-0 place-items-center rounded-[7px] border",j?"border-emerald-500/25 bg-emerald-500/10 text-emerald-600 dark:text-emerald-400":"border-violet-500/25 bg-violet-500/10 text-violet-600 dark:text-violet-400"),children:j?(0,U.jsx)(al.Check,{className:"h-3.5 w-3.5",strokeWidth:2.2}):(0,U.jsx)(Do,{className:"h-3.5 w-3.5"})}),(0,U.jsxs)("div",{className:"min-w-0",children:[(0,U.jsx)("div",{className:"text-[13px] font-semibold tracking-tight text-foreground",children:i.length>1?`${i.length} proposed task updates`:"Proposed task update"}),(0,U.jsx)("div",{className:"text-[11px] text-muted-foreground",children:C})]}),w.length>1&&(0,U.jsxs)(a$.Button,{size:"sm",className:(0,e1.cn)("ml-auto h-7 gap-1.5 rounded-lg px-3 text-xs",T8),onClick:()=>void k(),disabled:l||f||u.size>0,children:[f?(0,U.jsx)(aP,{className:"h-3 w-3 animate-spin"}):(0,U.jsx)(al.Check,{className:"h-3 w-3"}),f?"Applying…":`Apply all ${w.length}`]})]}),(0,U.jsx)("div",{className:"flex flex-col",children:b.map(({update:e,task:r,changes:s,batchChanges:i,parentProblem:a},l)=>{if(null===o)return(0,U.jsxs)("div",{className:(0,e1.cn)(Ru,"text-[12px] text-muted-foreground"),children:[(0,U.jsx)(aP,{className:"mr-1.5 inline h-3 w-3 animate-spin"}),"Loading task…"]},l);if(!r)return(0,U.jsxs)("div",{"data-update-row":"missing",className:(0,e1.cn)(Ru,"flex items-center gap-2 text-[12px] text-muted-foreground"),children:[(0,U.jsx)(oi,{className:"h-3.5 w-3.5 shrink-0"}),"This task no longer exists."]},l);let c=u.has(l)||f&&i.length>0,d=m.get(l),h=0===i.length,p=!h&&0===s.length;return(0,U.jsxs)("div",{"data-update-row":h?"applied":"pending",className:(0,e1.cn)(Ru,c&&"opacity-70"),children:[(0,U.jsxs)("div",{className:"flex items-center gap-2",children:[h&&(0,U.jsx)(al.Check,{className:"h-3.5 w-3.5 shrink-0 text-emerald-500"}),(0,U.jsx)("p",{className:(0,e1.cn)("min-w-0 flex-1 truncate text-[13px] font-medium",h?"text-muted-foreground":"text-foreground"),children:r.title}),n&&(0,U.jsxs)(a$.Button,{variant:"ghost",size:"sm",className:"h-6 gap-1 px-2 text-[11.5px] text-muted-foreground",onClick:()=>n(r),children:["View",(0,U.jsx)(rz,{className:"h-3 w-3"})]}),h?(0,U.jsx)("span",{className:"text-[11px] font-medium text-emerald-600 dark:text-emerald-400",children:"Up to date"}):(0,U.jsxs)(a$.Button,{size:"sm",variant:1===w.length?"default":"outline",className:(0,e1.cn)("h-6 gap-1 rounded-[7px] px-2.5 text-[11.5px]",1===w.length&&T8),"aria-label":"Apply update",onClick:()=>void S(l),disabled:c||f||p,children:[u.has(l)?(0,U.jsx)(aP,{className:"h-3 w-3 animate-spin"}):(0,U.jsx)(al.Check,{className:"h-3 w-3"}),u.has(l)?"Applying…":d?"Retry":"Apply"]})]}),!h&&(0,U.jsx)("dl",{className:"mt-2 grid grid-cols-[72px_minmax(0,1fr)] items-start gap-x-2 gap-y-1.5 text-[12px]",children:i.map(s=>(0,U.jsx)(Rf,{field:s,task:r,update:e,tasks:o},s))}),p&&(0,U.jsx)("p",{className:"mt-1.5 text-[11.5px] break-words text-muted-foreground",children:"This move depends on the others — apply all to make it."}),a&&(0,U.jsxs)("p",{className:"mt-1.5 flex items-center gap-1.5 text-[11.5px] break-words text-muted-foreground",children:[(0,U.jsx)(ou,{className:"h-3 w-3 shrink-0"}),"Parent not changed: ",a]}),d&&(0,U.jsxs)("p",{className:"mt-1.5 flex items-center gap-1.5 text-[11.5px] break-words text-red-500",children:[(0,U.jsx)(ou,{className:"h-3 w-3 shrink-0"}),d]})]},l)})}),x&&!j&&(0,U.jsxs)("div",{className:"flex items-start gap-1.5 border-t border-red-500/20 bg-red-500/5 px-3 py-2 text-[11.5px] break-words text-red-700 dark:text-red-400",children:[(0,U.jsx)(ou,{className:"mt-px h-3 w-3 shrink-0"}),(0,U.jsx)("span",{className:"min-w-0",children:x.rejected?`Couldn't apply the updates — none were applied. ${x.message}`:`Couldn't confirm whether the updates were applied (${x.message}). Any that were will show as up to date; applying again is safe.`})]})]})}function Rf({field:e,task:r,update:s,tasks:n}){let i=(0,U.jsx)("dt",{className:"pt-px text-[11px] text-muted-foreground",children:Ro[e]});if("description"===e)return(0,U.jsxs)(U.Fragment,{children:[i,(0,U.jsx)("dd",{className:"min-w-0",children:(0,U.jsx)(Rp,{before:r.description??"",after:s.description??""})})]});let a=r=>{if("status"===e){let e=r1[r];return(0,U.jsx)("span",{className:(0,e1.cn)("rounded px-1.5 py-px text-[11px] font-medium",e?.color),children:e?.label??r})}return"priority"===e?(0,U.jsxs)("span",{className:"inline-flex items-center gap-1.5 text-[11.5px]",children:[(0,U.jsx)("span",{className:(0,e1.cn)("h-[7px] w-[7px] rounded-full",T7[r])}),r2[r]?.label??r]}):(0,U.jsx)("span",{className:"break-words",children:r})},o=e=>e?n.find(r=>r.id===e)?.title??e:"None (top level)",l="parent"===e?o(r.parent_id):String(r[e]),c="parent"===e?o(s.parent):String(s[e]);return(0,U.jsxs)(U.Fragment,{children:[i,(0,U.jsxs)("dd",{className:"flex min-w-0 flex-wrap items-center gap-1.5",children:[(0,U.jsx)("span",{className:"text-muted-foreground line-through decoration-muted-foreground/50",children:a(l)}),(0,U.jsx)(j3,{className:"h-3 w-3 shrink-0 text-muted-foreground"}),(0,U.jsx)("span",{className:"text-foreground",children:a(c)})]})]})}function Rp({before:e,after:r}){let s=(0,V.useMemo)(()=>(function(e,r=2){let s=[],n=0;for(;n<e.length;){if("same"!==e[n].kind){s.push(e[n++]);continue}let i=n;for(;i<e.length&&"same"===e[i].kind;)i++;let a=e.slice(n,i),o=0===n?0:r,l=i===e.length?0:r;a.length>o+l+1?s.push(...a.slice(0,o),{kind:"fold",count:a.length-o-l},...a.slice(a.length-l)):s.push(...a),n=i}return s})(function(e,r){let s=e.split("\n"),n=r.split("\n"),i=0;for(;i<s.length&&i<n.length&&s[i]===n[i];)i++;let a=0;for(;a<s.length-i&&a<n.length-i&&s[s.length-1-a]===n[n.length-1-a];)a++;let o=s.slice(i,s.length-a),l=n.slice(i,n.length-a),c=e=>e.map(e=>({kind:"same",text:e})),d=[];if(o.length*l.length>25e4)d.push(...o.map(e=>({kind:"del",text:e})),...l.map(e=>({kind:"add",text:e})));else{let e=o.length,r=l.length,s=Array.from({length:e+1},()=>new Uint32Array(r+1));for(let n=e-1;n>=0;n--)for(let e=r-1;e>=0;e--)s[n][e]=o[n]===l[e]?s[n+1][e+1]+1:Math.max(s[n+1][e],s[n][e+1]);let n=0,i=0;for(;n<e||i<r;)n<e&&i<r&&o[n]===l[i]?(d.push({kind:"same",text:o[n]}),n++,i++):i>=r||n<e&&s[n+1][i]>=s[n][i+1]?d.push({kind:"del",text:o[n++]}):d.push({kind:"add",text:l[i++]})}return[...c(s.slice(0,i)),...d,...c(s.slice(s.length-a))]}(e,r)),[e,r]);return(0,U.jsx)("div",{"data-description-diff":!0,className:"max-h-56 overflow-auto rounded-lg border border-border/70 bg-muted/30 py-1 font-mono text-[11px] leading-relaxed",children:s.map((e,r)=>"fold"===e.kind?(0,U.jsxs)("div",{className:"px-2 text-muted-foreground/70 italic",children:["⋯ ",e.count," unchanged ",1===e.count?"line":"lines"]},r):(0,U.jsxs)("div",{className:(0,e1.cn)("px-2 break-words whitespace-pre-wrap","add"===e.kind&&"bg-emerald-500/10 text-emerald-800 dark:text-emerald-300","del"===e.kind&&"bg-red-500/10 text-red-800 dark:text-red-300"),children:[(0,U.jsx)("span",{className:"mr-2 inline-block w-2 select-none opacity-60",children:"add"===e.kind?"+":"del"===e.kind?"−":" "}),e.text||" "]},r))})}let Rm="cross-remote",Rg={remote_bash:"Run Command",remote_read_file:"Read File",remote_list_dir:"List Directory",remote_stat_path:"Stat Path",remote_process_list:"List Processes",list_accessible_remotes:"List Remotes",remote_mcp_open:"Open MCP Server",remote_mcp_list_tools:"List MCP Tools",remote_mcp_call:"Call MCP Tool",remote_mcp_ping:"Ping MCP Server",remote_mcp_close:"Close MCP Server"},Rx=[`mcp__${Rm}__`,`${Rm}__`,`${Rm}.`,`${Rm}/`];function Rv(e){let r=e.trim();for(let e of Rx)if(r.startsWith(e)){let s=r.slice(e.length);return s in Rg?s:null}return r in Rg?r:null}function Ry({value:e,limit:r}){let s="string"==typeof e?e:JSON.stringify(e,null,2);return(0,U.jsx)("pre",{className:"mt-1 bg-muted/50 p-2 rounded overflow-x-auto max-h-48 overflow-y-auto scrollbar-none max-w-full whitespace-pre-wrap break-all",style:{fontSize:"var(--conv-font-size, 12px)"},children:s.length>r?s.substring(0,r)+"...":s})}function Rb({bare:e,parsed:r,raw:s}){return r?"remote_bash"===e&&r.command?(0,U.jsxs)("div",{className:"flex items-start gap-2",children:[(0,U.jsxs)("pre",{className:"flex-1 min-w-0 bg-muted/50 p-2 rounded overflow-x-auto max-w-full whitespace-pre-wrap break-all",style:{fontSize:"var(--conv-font-size, 12px)"},children:[(0,U.jsx)("span",{className:"text-muted-foreground select-none",children:"$ "}),r.command]}),(0,U.jsxs)("div",{className:"flex flex-col gap-1 shrink-0 mt-1",children:[r.cwd&&(0,U.jsx)(rG,{variant:"outline",className:"text-xs max-w-40 truncate",title:r.cwd,children:r.cwd}),null!=r.timeoutSec&&(0,U.jsxs)(rG,{variant:"outline",className:"text-xs",children:[r.timeoutSec,"s"]})]})]}):r.path?(0,U.jsx)("p",{className:"font-mono text-muted-foreground break-all",style:{fontSize:"var(--conv-font-size, 12px)"},children:r.path}):"remote_process_list"===e||"list_accessible_remotes"===e?null:(0,U.jsx)(Ry,{value:s,limit:500}):(0,U.jsx)(Ry,{value:s,limit:500})}function Rw({tool:e,input:r}){let s=Rv(e)??e,n=function(e){try{let r="string"==typeof e?JSON.parse(e):e;if(!r||"object"!=typeof r)return null;let s=e=>"string"==typeof r[e]?r[e]:void 0;return{remoteId:s("remoteId"),command:s("command"),cwd:s("cwd"),path:s("path"),tool:s("tool"),timeoutSec:"number"==typeof r.timeoutSec?r.timeoutSec:void 0}}catch{return null}}(r),{label:i}=g7(n?.remoteId);return(0,U.jsxs)("div",{className:"flex gap-3 py-3",children:[(0,U.jsx)("div",{className:"flex-shrink-0 w-7 h-7 rounded-lg bg-violet-500/10 flex items-center justify-center",children:(0,U.jsx)(aL,{className:"w-4 h-4 text-violet-500"})}),(0,U.jsxs)("div",{className:"flex-1 min-w-0 overflow-hidden",children:[(0,U.jsxs)("p",{className:"conv-text-sm font-medium text-foreground mb-1 break-words",children:[Rg[s]??s,i&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)("span",{className:"font-normal text-muted-foreground",children:" on "}),(0,U.jsx)("span",{className:"text-foreground",title:n?.remoteId,children:i})]})]}),(0,U.jsx)(Rb,{bare:s,parsed:n,raw:r})]})]})}function R_(e){try{return{ok:!0,value:JSON.parse(e)}}catch{return{ok:!1}}}function RS({text:e}){return(0,U.jsx)("p",{className:"conv-text-xs text-muted-foreground break-words whitespace-pre-wrap",children:e})}function Rk({output:e}){var r;let s=R_(e);if(!s.ok)return(0,U.jsx)(RS,{text:e});let n=s.value,i=function(e){let r=e?.content;if(!Array.isArray(r))return null;let s=r.filter(e=>!!e&&"object"==typeof e&&"text"===e.type&&"string"==typeof e.text).map(e=>e.text);return s.length>0?s.join("\n"):null}(n);if(null!==i){let e=R_(i);if(!e.ok)return(0,U.jsx)(RS,{text:i});n=e.value}let a=(r=n)&&"object"==typeof r?"string"!=typeof r.stdout||"string"!=typeof r.stderr?null:{stdout:r.stdout,stderr:r.stderr,exitCode:"number"==typeof r.exitCode?r.exitCode:null,timedOut:!0===r.timedOut,truncated:!0===r.truncated}:null;if(a){let e=[a.stdout,a.stderr].filter(e=>""!==e.trim()).join("\n"),r=null!==a.exitCode&&0!==a.exitCode;return(0,U.jsxs)("div",{className:"space-y-1",children:[(r||a.timedOut||a.truncated)&&(0,U.jsxs)("div",{className:"flex flex-wrap gap-1",children:[a.timedOut&&(0,U.jsx)(rG,{variant:"destructive",className:"text-xs",children:"timed out"}),r&&(0,U.jsxs)(rG,{variant:"outline",className:"text-xs",children:["exit ",a.exitCode]}),a.truncated&&(0,U.jsx)(rG,{variant:"outline",className:"text-xs",children:"truncated"})]}),(0,U.jsx)(Tb,{output:e})]})}let o=n?.content;return"string"==typeof o?(0,U.jsx)(Tb,{output:o}):(0,U.jsx)(Ry,{value:n,limit:1e3})}let Rj=(0,rE.default)("volume-x",[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",key:"uqj9uw"}],["line",{x1:"22",x2:"16",y1:"9",y2:"15",key:"1ewh16"}],["line",{x1:"16",x2:"22",y1:"9",y2:"15",key:"5ykzw1"}]]);function RC({ownerKey:e,text:r,className:s}){let n=gM(),i="idle"!==n.status&&n.ownerKey===e,a=i&&"loading"===n.status,o=i&&"playing"===n.status,l=i&&"error"===n.status?n:null,c=(0,V.useMemo)(()=>gS(r),[r]),d=(0,V.useRef)(null);if((0,V.useEffect)(()=>{l&&d.current!==l&&(d.current=l,"not_configured"===l.code?xc.toast.error("Text-to-speech is not configured",{description:"Add a speech provider key in Settings → Speech."}):xc.toast.error("Could not read this message aloud",{description:l.message}))},[l]),!c)return null;let u=a||o,h=u?"Stop reading":"Read aloud",f=i&&"error"!==n.status&&n.total>1?` (${n.chunk+1}/${n.total})`:"";return(0,U.jsx)("button",{type:"button","data-speak-button":"",onClick:()=>gA.toggle(e,r),title:l?l.message:h+f,"aria-label":h,"aria-pressed":u,className:(0,e1.cn)("transition-opacity text-muted-foreground hover:text-foreground",i?"opacity-100":"opacity-0 group-hover:opacity-100 focus-visible:opacity-100",o&&"text-primary hover:text-primary/80",l&&"text-destructive",s),children:a?(0,U.jsx)(aP,{className:"w-3.5 h-3.5 animate-spin"}):l?(0,U.jsx)(Rj,{className:"w-3.5 h-3.5"}):(0,U.jsx)(mb,{className:(0,e1.cn)("w-3.5 h-3.5",o&&"animate-pulse")})})}let RN={sky:"bg-sky-500/10 text-sky-500",violet:"bg-violet-500/10 text-violet-500",purple:"bg-purple-500/10 text-purple-500",indigo:"bg-indigo-500/10 text-indigo-500",blue:"bg-blue-500/10 text-blue-500",cyan:"bg-cyan-500/10 text-cyan-500",teal:"bg-teal-500/10 text-teal-500",emerald:"bg-emerald-500/10 text-emerald-500",green:"bg-green-500/10 text-green-500",amber:"bg-amber-500/10 text-amber-500",orange:"bg-orange-500/10 text-orange-500",pink:"bg-pink-500/10 text-pink-500",red:"bg-red-500/10 text-red-500"};function RE({icon:e,title:r,color:s,className:n,titleClassName:i,children:a}){return(0,U.jsxs)("div",{className:(0,e1.cn)("flex gap-3 py-3",n),children:[(0,U.jsx)("div",{className:(0,e1.cn)("flex-shrink-0 w-7 h-7 rounded-lg flex items-center justify-center",RN[s]),children:(0,U.jsx)(e,{className:"w-4 h-4"})}),(0,U.jsxs)("div",{className:"flex-1 min-w-0 overflow-hidden",children:[(0,U.jsx)("p",{className:(0,e1.cn)("conv-text-sm font-medium text-foreground mb-1",i),children:r}),a]})]})}let RD=(0,rE.default)("clipboard-paste",[["path",{d:"M11 14h10",key:"1w8e9d"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v1.344",key:"1e62lh"}],["path",{d:"m17 18 4-4-4-4",key:"z2g111"}],["path",{d:"M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 1.793-1.113",key:"bjbb7m"}],["rect",{x:"8",y:"2",width:"8",height:"4",rx:"1",key:"ublpy"}]]);function RT(e){if(e<1024)return`${e} B`;let r=e/1024;return r<10?`${r.toFixed(1)} KB`:r<1024?`${Math.round(r)} KB`:`${(r/1024).toFixed(1)} MB`}function RR({names:e}){return(0,U.jsxs)("span",{className:"flex min-w-0 items-baseline gap-1 text-xs font-normal text-muted-foreground",title:`Remote access: ${e}`,children:[(0,U.jsx)(oj,{className:"w-3 h-3 shrink-0 self-center"}),(0,U.jsx)("span",{className:"truncate",children:e})]})}function RA(){return(0,U.jsxs)("span",{className:"flex shrink-0 items-baseline gap-1 text-xs font-normal text-muted-foreground",children:[(0,U.jsx)(aM,{className:"w-3 h-3 shrink-0 self-center"}),"Schedule"]})}function RM(){return(0,U.jsxs)("span",{className:"flex shrink-0 items-baseline gap-1 text-xs font-normal text-muted-foreground",children:[(0,U.jsx)(Da,{className:"w-3 h-3 shrink-0 self-center"}),"Add task"]})}function RI({path:e,size:r}){return(0,U.jsxs)(RP,{path:e,className:"mx-0.5 inline-flex items-center gap-1 rounded-md border border-border bg-muted/50 px-1.5 align-[-0.2em] text-[0.85em] leading-[1.6]",children:[(0,U.jsx)(RD,{className:"h-[1.05em] w-[1.05em] shrink-0 text-muted-foreground"}),(0,U.jsx)("span",{className:"font-medium",children:"Pasted text"}),(0,U.jsx)("span",{className:"text-muted-foreground",children:RT(r)})]})}function RP({path:e,className:r,children:s}){let{openFile:n,scope:i}=jL();return i?(0,U.jsx)("button",{type:"button",className:`${r} cursor-pointer text-left transition-colors hover:border-foreground/25 hover:bg-muted`,title:`Open in Files — ${e}`,onClick:()=>n(e),children:s}):(0,U.jsx)("span",{className:r,title:e,children:s})}function RF({path:e,size:r,name:s}){let n,i,a=s||((n=Math.max(e.lastIndexOf("/"),e.lastIndexOf("\\")))>=0?e.slice(n+1):e);return(0,U.jsxs)(RP,{path:e,className:"inline-flex max-w-[16rem] items-center gap-2.5 rounded-lg border border-border bg-muted/40 py-1.5 pl-1.5 pr-3",children:[(0,U.jsx)("span",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-md border border-border/70 bg-background",children:(0,U.jsx)(Cn,{className:"h-4 w-4 text-muted-foreground"})}),(0,U.jsxs)("span",{className:"flex min-w-0 flex-col leading-tight",children:[(0,U.jsx)("span",{className:"truncate text-xs font-medium text-foreground",children:a}),(0,U.jsxs)("span",{className:"truncate text-[11px] text-muted-foreground",children:[((i=a.lastIndexOf("."))>0&&i<a.length-1?a.slice(i+1).toUpperCase():null)??"File"," · ",RT(r)]})]})]})}let RL=/<vremotes names="([^"]*)">[\s\S]*?<\/vremotes>/g,RO=RegExp(`${/<vpaste path="([^"]+)" size="(\d+)" \/>/g.source}|${/<vfile path="([^"]+)" name="([^"]*)" size="(\d+)" \/>/g.source}|${RL.source}`,"g"),RB="<vschedule>\nThe user picked the Schedule action for this message: turn the work from this conversation into a recurring scheduled run by calling the propose_schedule tool (mcp__vibedeckx__propose_schedule).\n- Take what to run and how often from the user's message above. Where it is empty or leaves something open, infer it from the conversation; if the frequency can't be inferred, pick a sensible one and say so — the user can edit it on the confirmation card.\n- The scheduled run starts fresh, without this conversation. Carry the specifics over into a self-contained prompt (or a command): paths, commands, what counts as pass or fail, what to report.\n- Only propose the schedule: don't do the work itself now, and don't write cron jobs or scripts for it. If you can't tell what should be scheduled, ask instead of guessing. If the propose_schedule tool is not available, say so.\n</vschedule>",Rz=/<vschedule>[\s\S]*?<\/vschedule>/g,R$="<vtask>\nThe user picked the Task action for this message: record work from this conversation as project tasks by calling the propose_task tool (mcp__vibedeckx__propose_task).\n- Take what to record from the user's message above. Where it is empty or vague, infer it from the conversation (for example, what was skipped or left for later).\n- Only record the task. Do NOT do the work now — not even when the message reads like an instruction.\n- Each description must be self-contained: the task may be picked up later in a fresh session without this conversation. Include the background, the relevant files, what remains, and how to tell it is done.\n- When a description relies on a file in the repository (a design doc, the source to change), link to the file instead of copying its contents into the description.\n- Propose several tasks in one call if the user asks to split the work.\n- If you can't tell what should be recorded, ask instead of guessing. If the propose_task tool is not available, say so.\n</vtask>",RW=/<vtask>[\s\S]*?<\/vtask>/g,RH=/<vtasks-created(?:\s[^>]*)?>[\s\S]*?<\/vtasks-created>/g,RU=/<vselected-tasks(?:\s[^>]*)?>[\s\S]*?<\/vselected-tasks>/g,RV=e=>e.replace(/[\r\n]+/g," ").replace(/[&<>"]/g,e=>"&"===e?"&amp;":"<"===e?"&lt;":">"===e?"&gt;":"&quot;"),Rq=e=>e.replace(/&(amp|lt|gt|quot);/g,(e,r)=>({amp:"&",lt:"<",gt:">",quot:'"'})[r]);function RK(e,r){return e.filter(e=>e.parent_id===r).map(({id:e,title:r,status:s})=>({id:e,title:r,status:s}))}function RX({message:e,messageIndex:r,entryIndex:s,streaming:n=!1}){let i=function(e,r,s,n){switch(e.type){case"user":return(0,U.jsx)(RJ,{content:e.content,origin:e.origin});case"assistant":return(0,U.jsx)(RZ,{content:e.content,agentType:e.agentType,streaming:s,entryIndex:n});case"tool_use":return(0,U.jsx)(RQ,{tool:e.tool,input:e.input,messageIndex:r,toolUseId:e.toolUseId});case"tool_result":return(0,U.jsx)(R0,{tool:e.tool,output:e.output});case"thinking":return(0,U.jsx)(R1,{content:e.content});case"error":return(0,U.jsx)(R2,{message:e.message});case"system":return(0,U.jsx)(R5,{content:e.content});case"approval_request":return(0,U.jsx)(RE,{color:"amber",icon:Di,title:"command"===e.requestType?"Command Approval":"File Change Approval",children:"command"===e.requestType?(0,U.jsx)(D7,{requestId:e.requestId,command:e.command,cwd:e.cwd,messageIndex:r}):(0,U.jsx)(D8,{requestId:e.requestId,changes:e.changes,messageIndex:r})});default:return null}}(e,r,n,s);return i?(0,U.jsxs)("div",{className:"group relative",children:[i,(0,U.jsx)("span",{className:"pointer-events-none absolute right-0 top-3 conv-text-xs tabular-nums text-muted-foreground opacity-0 transition-opacity duration-150 group-hover:opacity-100",children:function(e){let r=new Date(e),s=new Date,n=r.getFullYear()===s.getFullYear()&&r.getMonth()===s.getMonth()&&r.getDate()===s.getDate(),i=r.toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1});if(n)return i;let a=r.toLocaleDateString(void 0,{year:"numeric",month:"2-digit",day:"2-digit"});return`${a} ${i}`}(e.timestamp)})]}):null}function RY(e){var r,s,n,i;let a,o,l,c,d,u,h,f=(a=e.replace(RegExp(RH.source,"g"),""))===e?{text:e,found:!1}:{text:a.trimEnd(),found:!0},p=(r=f.text,o={names:null},l=r.replace(RegExp(RL.source,"g"),(e,r)=>(o.names=r,"")),null===o.names?{text:r,names:null}:{text:l.trimEnd(),names:o.names}),m=(c=(s=p.text).replace(RegExp(Rz.source,"g"),""))===s?{text:s,found:!1}:{text:c.trimEnd(),found:!0},g=(d=(n=m.text).replace(RegExp(RW.source,"g"),""))===n?{text:n,found:!1}:{text:d.trimEnd(),found:!0},x=(i=g.text,u=null,h=i.replace(RegExp(RU.source,"g"),e=>{for(let r of(u??=[],e.matchAll(/<task id="([^"]*)" title="([^"]*)"/g)))u.push({id:Rq(r[1]),title:Rq(r[2])});return""}),null===u?{text:i,refs:null}:{text:h.trimEnd(),refs:u});return{text:x.text,remoteNames:p.names,scheduled:m.found,tasked:g.found,hadNote:f.found,selectedTasks:x.refs}}function RG(e){let r=function(e){let r,s=[],n=0,i=RegExp(RO.source,"g");for(;null!==(r=i.exec(e));)r.index>n&&s.push({kind:"text",text:e.slice(n,r.index)}),void 0!==r[1]?s.push({kind:"chip",path:r[1],size:Number(r[2])}):void 0!==r[3]?s.push({kind:"chip",path:r[3],name:r[4],size:Number(r[5])}):s.push({kind:"remotes",names:r[6]}),n=r.index+r[0].length;return n<e.length&&s.push({kind:"text",text:e.slice(n)}),s}(e);if(1===r.length&&"text"===r[0].kind)return(0,U.jsx)("span",{className:"whitespace-pre-wrap break-words",children:e??""});let s=[],n=[];for(let e of r)"chip"===e.kind&&void 0!==e.name?s.push({path:e.path,size:e.size,name:e.name}):"remotes"!==e.kind&&n.push(e);let i=n[0];i?.kind==="text"&&(n[0]={...i,text:i.text.trimStart()});let a=n[n.length-1];a?.kind==="text"&&(n[n.length-1]={...a,text:a.text.trimEnd()});let o=n.some(e=>"chip"===e.kind||e.text.length>0);return(0,U.jsxs)("div",{className:"text-foreground max-w-none break-words",style:{fontSize:"var(--conv-font-size, 14px)"},children:[s.length>0&&(0,U.jsx)("div",{className:`flex flex-wrap gap-2${o?" mb-2":""}`,children:s.map((e,r)=>(0,U.jsx)(RF,{path:e.path,size:e.size,name:e.name},r))}),o&&(0,U.jsx)("div",{className:"whitespace-pre-wrap break-words",children:n.map((e,r)=>"text"===e.kind?e.text:(0,U.jsx)(RI,{path:e.path,size:e.size},r))})]})}function RJ({content:e,origin:r}){let s;if("workflow"===r&&"string"==typeof e)return(0,U.jsx)(RE,{color:"sky",icon:Dt,title:"Workflow",children:(0,U.jsx)("div",{className:"text-foreground prose prose-sm dark:prose-invert max-w-none break-words [&_pre]:overflow-x-auto [&_pre]:max-w-full [&_code]:break-all [&_p]:break-words",style:{fontSize:"var(--conv-font-size, 14px)"},children:(0,U.jsx)(D1,{children:e})})});let n=null,i=!1,a=!1,o=null;if("string"==typeof e){let r=RY(e);n=r.remoteNames,i=r.scheduled,a=r.tasked,o=r.selectedTasks,s=r.text}else for(let r of(s=[],e)){if("text"!==r.type){s.push(r);continue}let e=RY(r.text);null!==e.remoteNames&&(n=e.remoteNames),e.scheduled&&(i=!0),e.tasked&&(a=!0),e.selectedTasks&&(o=[...o??[],...e.selectedTasks]),(!(null!==e.remoteNames||e.scheduled||e.tasked||e.hadNote||null!==e.selectedTasks)||e.text.length>0)&&s.push({...r,text:e.text})}return(0,U.jsxs)("div",{className:"flex gap-3 py-3",children:[(0,U.jsx)("div",{className:"flex-shrink-0 w-7 h-7 rounded-lg bg-primary/10 flex items-center justify-center",children:(0,U.jsx)(E6,{className:"w-4 h-4 text-primary"})}),(0,U.jsxs)("div",{className:"flex-1 min-w-0 overflow-hidden",children:[(0,U.jsxs)("p",{className:"flex min-w-0 items-baseline gap-1.5 conv-text-sm font-medium text-foreground mb-1",children:[(0,U.jsx)("span",{className:"shrink-0",children:"You"}),i&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)("span",{className:"shrink-0 text-muted-foreground/60","aria-hidden":!0,children:"·"}),(0,U.jsx)(RA,{})]}),a&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)("span",{className:"shrink-0 text-muted-foreground/60","aria-hidden":!0,children:"·"}),(0,U.jsx)(RM,{})]}),o&&o.length>0&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)("span",{className:"shrink-0 text-muted-foreground/60","aria-hidden":!0,children:"·"}),(0,U.jsx)(DU,{refs:o})]}),n&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)("span",{className:"shrink-0 text-muted-foreground/60","aria-hidden":!0,children:"·"}),(0,U.jsx)(RR,{names:n})]})]}),(0,U.jsx)("div",{className:"text-foreground max-w-none break-words",style:{fontSize:"var(--conv-font-size, 14px)"},children:"string"==typeof s?RG(s):s.map((e,r)=>"text"===e.type?(0,U.jsx)(V.Fragment,{children:RG(e.text)},r):(0,U.jsx)("div",{className:"mt-2",children:(0,U.jsx)(Td,{src:`data:${e.mediaType};base64,${e.data}`,alt:"Attached image",className:"max-w-sm rounded-lg"})},r))})]})]})}function RZ({content:e,agentType:r,streaming:s=!1,entryIndex:n}){let i,a=MH(),o=a?.agentType??Ep,l=a?.providers,c=a?.sessionId??null,d=(0,V.useMemo)(()=>(function(e,r,s){let n=0x811c9dc5;for(let e=0;e<r.length;e++)n^=r.charCodeAt(e),n=Math.imul(n,0x1000193);return`${e??"none"}:${s??"-"}:${(n>>>0).toString(36)}:${r.length}`})(c,e??"",n),[c,e,n]),u=(i=()=>{let e=gA.getSnapshot();return"idle"!==e.status&&e.ownerKey===d},(0,V.useSyncExternalStore)(gA.subscribe,i,i))?"opacity-100":"opacity-0 group-hover:opacity-100 focus-visible:opacity-100",{messageName:h,Icon:f,avatarBackground:p,accentText:m}=Eg(r??o,l),[g,x]=(0,V.useState)(!1),[v,y]=(0,V.useState)(!1);(0,V.useEffect)(()=>{if(!v)return;let e=setTimeout(()=>y(!1),1500);return()=>clearTimeout(e)},[v]);let b=async()=>{if(navigator?.clipboard?.writeText)try{await navigator.clipboard.writeText(e??""),y(!0)}catch(e){console.error("Failed to copy message",e)}};return(0,U.jsxs)("div",{className:"group flex gap-3 py-3","data-speak-message":"",children:[(0,U.jsx)("div",{className:`flex-shrink-0 w-7 h-7 rounded-lg ${p} flex items-center justify-center`,children:(0,U.jsx)(f,{className:`w-4 h-4 ${m}`})}),(0,U.jsxs)("div",{className:"flex-1 min-w-0 overflow-hidden",children:[(0,U.jsxs)("div",{className:"flex items-center gap-2 mb-1",children:[(0,U.jsx)("p",{className:"conv-text-sm font-medium text-foreground",children:h}),(0,U.jsx)("button",{type:"button",onClick:()=>x(e=>!e),title:g?"View rendered":"View source","aria-label":g?"View rendered":"View source","aria-pressed":g,className:(0,e1.cn)(u,"transition-opacity text-muted-foreground hover:text-foreground"),children:g?(0,U.jsx)(S_,{className:"w-3.5 h-3.5"}):(0,U.jsx)(Cm,{className:"w-3.5 h-3.5"})}),(0,U.jsx)("button",{type:"button",onClick:b,title:v?"Copied":"Copy source","aria-label":v?"Copied":"Copy source",className:(0,e1.cn)(u,"transition-opacity text-muted-foreground hover:text-foreground"),children:v?(0,U.jsx)(al.Check,{className:"w-3.5 h-3.5"}):(0,U.jsx)(mw.Copy,{className:"w-3.5 h-3.5"})}),!s&&(0,U.jsx)(RC,{ownerKey:d,text:e??""})]}),g?(0,U.jsx)("pre",{className:"text-xs font-mono whitespace-pre-wrap break-words bg-muted/50 rounded-md p-3 overflow-x-auto text-foreground select-text",children:e??""}):(0,U.jsx)("div",{className:"text-foreground prose prose-sm dark:prose-invert max-w-none break-words [&_pre]:overflow-x-auto [&_pre]:max-w-full [&_code]:break-all [&_p]:break-words",style:{fontSize:"var(--conv-font-size, 14px)"},children:(0,U.jsx)(D1,{streaming:s,children:e??""})})]})]})}function RQ({tool:e,input:r,messageIndex:s,toolUseId:n}){if(e===Tq)return(0,U.jsx)(RE,{color:"amber",icon:aM,title:"Suggested scheduled check",children:(0,U.jsx)(TK,{input:r,toolUseId:n})});if(e===T4)return(0,U.jsx)(RE,{color:"violet",icon:Da,title:"Proposed task",children:(0,U.jsx)(Rt,{input:r,toolUseId:n})});if(e===Ri)return(0,U.jsx)(RE,{color:"violet",icon:Do,title:"Proposed task update",children:(0,U.jsx)(Rh,{input:r})});if("ImageView"===e){let e="object"==typeof r&&null!==r&&"path"in r&&"string"==typeof r.path?r.path:"";return(0,U.jsx)(RE,{color:"sky",icon:S_,title:"View Image",children:(0,U.jsx)("p",{className:"font-mono text-muted-foreground break-all",style:{fontSize:"var(--conv-font-size, 12px)"},children:e})})}if("AskUserQuestion"===e)return(0,U.jsx)(RE,{color:"violet",icon:dR,title:"Question",children:(0,U.jsx)(D2,{input:r,messageIndex:s})});if("ExitPlanMode"===e)return(0,U.jsx)(RE,{color:"green",icon:E9,title:"Plan Ready",children:(0,U.jsx)(D6,{input:r,messageIndex:s})});let i={TodoWrite:{label:"Tasks",ui:(0,U.jsx)(Tn,{input:r})},TaskCreate:{label:"Create Task",ui:(0,U.jsx)(Ti,{input:r})},TaskUpdate:{label:"Update Task",ui:(0,U.jsx)(Ta,{input:r})},TaskList:{label:"Task List",ui:(0,U.jsx)(To,{})},TaskGet:{label:"Get Task",ui:(0,U.jsx)(Tl,{input:r})}}[e];if(i)return(0,U.jsx)(RE,{color:"cyan",icon:on,title:i.label,children:i.ui});if("Read"===e)return(0,U.jsx)(RE,{color:"sky",icon:Cn,title:"Read File",children:(0,U.jsx)(Tp,{input:r})});if("Edit"===e)return(0,U.jsx)(RE,{color:"sky",icon:Dr,title:"Edit File",children:(0,U.jsx)(TD,{input:r})});if("Write"===e)return(0,U.jsx)(RE,{color:"sky",icon:Ds,title:"Write File",children:(0,U.jsx)(Tx,{input:r})});if("Bash"===e)return(0,U.jsx)(RE,{color:"emerald",icon:xb,title:"Run Command",children:(0,U.jsx)(Ty,{input:r})});if("Grep"===e)return(0,U.jsx)(RE,{color:"orange",icon:aK,title:"Search",children:(0,U.jsx)(Tw,{input:r})});if("Glob"===e)return(0,U.jsx)(RE,{color:"teal",icon:De,title:"Glob",children:(0,U.jsx)(TS,{input:r})});if("Task"===e||"Agent"===e)return(0,U.jsx)(RE,{color:"purple",icon:Dt,title:"Agent",children:(0,U.jsx)(TC,{input:r})});if("TaskOutput"===e)return(0,U.jsx)(RE,{color:"purple",icon:Dt,title:"Task Output",children:(0,U.jsx)(TL,{input:r})});if("WebFetch"===e)return(0,U.jsx)(RE,{color:"blue",icon:oC,title:"Fetch Web Page",children:(0,U.jsx)(TR,{input:r})});if("WebSearch"===e)return(0,U.jsx)(RE,{color:"indigo",icon:Dn,title:"Web Search",children:(0,U.jsx)(TM,{input:r})});if("Skill"===e)return(0,U.jsx)(RE,{color:"pink",icon:mv,title:"Skill",children:(0,U.jsx)(TP,{input:r})});if("FileChange"===e)return(0,U.jsx)(RE,{color:"sky",icon:Dr,title:"File Changes",children:(0,U.jsx)(TB,{input:r})});if(null!==Rv(e))return(0,U.jsx)(Rw,{tool:e,input:r});let a="string"==typeof r?r:JSON.stringify(r,null,2);return(0,U.jsx)(RE,{color:"amber",icon:E7,title:`Tool: ${e}`,titleClassName:"break-words",children:(0,U.jsxs)("details",{open:!0,children:[(0,U.jsx)("summary",{className:"conv-text-xs text-muted-foreground cursor-pointer hover:text-foreground",children:"Input"}),(0,U.jsx)("pre",{className:"mt-1 bg-muted/50 p-2 rounded overflow-x-auto max-w-full whitespace-pre-wrap break-all",style:{fontSize:"var(--conv-font-size, 12px)"},children:a.length>500?a.substring(0,500)+"...":a})]})})}function R0({tool:e,output:r}){if(e===Tq||e===T4||e===Ri)return null;let s=function(e){if(!e.startsWith("[")||!e.includes('"type":"image"'))return null;try{let r=JSON.parse(e);if(!Array.isArray(r))return null;let s=[];for(let e of r){if(!e||"image"!==e.type)continue;let r=e.source;r?.type==="base64"&&"string"==typeof r.data&&s.push({mediaType:r.media_type??"image/png",data:r.data})}return s.length>0?s:null}catch{return null}}(r);if(s)return(0,U.jsx)("div",{className:"flex gap-3 py-3 pl-11",children:(0,U.jsx)("div",{className:"flex-1 min-w-0 overflow-hidden",children:(0,U.jsx)(Tm,{images:s})})});if(["TodoWrite","TaskCreate","TaskUpdate","TaskList","TaskGet"].includes(e)){let s="TaskList"===e?(0,U.jsx)(Tc,{output:r}):null;return(0,U.jsx)("div",{className:"flex gap-3 py-3 pl-11",children:(0,U.jsxs)("div",{className:"flex-1 min-w-0 overflow-hidden",children:[(0,U.jsxs)("p",{className:"conv-text-xs text-muted-foreground mb-1",children:["Result (",e,")"]}),s||(0,U.jsxs)("details",{children:[(0,U.jsx)("summary",{className:"conv-text-xs text-muted-foreground cursor-pointer hover:text-foreground",children:"Output"}),(0,U.jsx)("pre",{className:"mt-1 bg-muted/50 p-2 rounded overflow-x-auto max-h-48 overflow-y-auto scrollbar-none max-w-full whitespace-pre-wrap break-all",style:{fontSize:"var(--conv-font-size, 12px)"},children:r.length>1e3?r.substring(0,1e3)+"...":r})]})]})})}if("Read"===e)return(0,U.jsx)("div",{className:"flex gap-3 py-3 pl-11",children:(0,U.jsx)("div",{className:"flex-1 min-w-0 overflow-hidden",children:(0,U.jsx)(Tg,{output:r})})});if("Edit"===e)return(0,U.jsx)("div",{className:"flex gap-3 py-3 pl-11",children:(0,U.jsx)("div",{className:"flex-1 min-w-0 overflow-hidden",children:(0,U.jsx)(TT,{output:r})})});if("Write"===e)return(0,U.jsx)("div",{className:"flex gap-3 py-3 pl-11",children:(0,U.jsx)("div",{className:"flex-1 min-w-0 overflow-hidden",children:(0,U.jsx)(Tv,{output:r})})});if("Bash"===e)return(0,U.jsx)("div",{className:"flex gap-3 py-3 pl-11",children:(0,U.jsx)("div",{className:"flex-1 min-w-0 overflow-hidden",children:(0,U.jsx)(Tb,{output:r})})});if("Grep"===e)return(0,U.jsx)("div",{className:"flex gap-3 py-3 pl-11",children:(0,U.jsx)("div",{className:"flex-1 min-w-0 overflow-hidden",children:(0,U.jsx)(T_,{output:r})})});if("Glob"===e)return(0,U.jsx)("div",{className:"flex gap-3 py-3 pl-11",children:(0,U.jsx)("div",{className:"flex-1 min-w-0 overflow-hidden",children:(0,U.jsx)(Tk,{output:r})})});if("Task"===e||"Agent"===e)return(0,U.jsx)("div",{className:"flex gap-3 py-3 pl-11",children:(0,U.jsx)("div",{className:"flex-1 min-w-0 overflow-hidden",children:(0,U.jsx)(TN,{output:r})})});if("TaskOutput"===e)return(0,U.jsx)("div",{className:"flex gap-3 py-3 pl-11",children:(0,U.jsx)("div",{className:"flex-1 min-w-0 overflow-hidden",children:(0,U.jsx)(TO,{output:r})})});if("WebFetch"===e)return(0,U.jsx)("div",{className:"flex gap-3 py-3 pl-11",children:(0,U.jsx)("div",{className:"flex-1 min-w-0 overflow-hidden",children:(0,U.jsx)(TA,{output:r})})});if("WebSearch"===e)return(0,U.jsx)("div",{className:"flex gap-3 py-3 pl-11",children:(0,U.jsx)("div",{className:"flex-1 min-w-0 overflow-hidden",children:(0,U.jsx)(TI,{output:r})})});if("Skill"===e)return(0,U.jsx)("div",{className:"flex gap-3 py-3 pl-11",children:(0,U.jsx)("div",{className:"flex-1 min-w-0 overflow-hidden",children:(0,U.jsx)(TF,{output:r})})});if("FileChange"===e)return(0,U.jsx)("div",{className:"flex gap-3 py-3 pl-11",children:(0,U.jsx)("div",{className:"flex-1 min-w-0 overflow-hidden",children:(0,U.jsx)(Tz,{output:r})})});if(null!==Rv(e))return(0,U.jsx)("div",{className:"flex gap-3 py-3 pl-11",children:(0,U.jsx)("div",{className:"flex-1 min-w-0 overflow-hidden",children:(0,U.jsx)(Rk,{output:r})})});let n=r.length>200;return(0,U.jsx)("div",{className:"flex gap-3 py-3 pl-11",children:(0,U.jsxs)("div",{className:"flex-1 min-w-0 overflow-hidden",children:[(0,U.jsxs)("p",{className:"conv-text-xs text-muted-foreground mb-1",children:["Result",e?` (${e})`:""]}),(0,U.jsxs)("details",{className:(0,e1.cn)(!n&&"open"),children:[(0,U.jsx)("summary",{className:"conv-text-xs text-muted-foreground cursor-pointer hover:text-foreground",children:"Output"}),(0,U.jsx)("pre",{className:"mt-1 bg-muted/50 p-2 rounded overflow-x-auto max-h-48 overflow-y-auto scrollbar-none max-w-full whitespace-pre-wrap break-all",style:{fontSize:"var(--conv-font-size, 12px)"},children:r.length>1e3?r.substring(0,1e3)+"...":r})]})]})})}function R1({content:e}){let r=e??"",s=r.trim().length>0,n=s?r.length>500?r.substring(0,500)+"...":r:"Reasoning unavailable — this model does not expose its thinking content.";return(0,U.jsxs)("div",{className:"flex gap-3 py-3",children:[(0,U.jsx)("div",{className:"flex-shrink-0 w-7 h-7 rounded-lg bg-blue-500/10 flex items-center justify-center",children:(0,U.jsx)(E8,{className:"w-4 h-4 text-blue-500"})}),(0,U.jsx)("div",{className:"flex-1 min-w-0 overflow-hidden",children:(0,U.jsxs)("details",{children:[(0,U.jsx)("summary",{className:"conv-text-sm font-medium text-foreground cursor-pointer hover:underline",children:"Thinking..."}),(0,U.jsx)("div",{className:`mt-2 whitespace-pre-wrap break-words bg-muted/50 p-2 rounded-md overflow-hidden ${s?"text-muted-foreground":"text-muted-foreground/70 italic"}`,style:{fontSize:"var(--conv-font-size, 12px)"},children:n})]})})]})}function R2({message:e}){return(0,U.jsx)(RE,{color:"red",icon:aR,title:"Error",children:(0,U.jsx)("p",{className:"text-destructive/80 break-words whitespace-pre-wrap",style:{fontSize:"var(--conv-font-size, 14px)"},children:e})})}function R5({content:e}){return(0,U.jsxs)("div",{className:"flex gap-3 py-2",children:[(0,U.jsx)("div",{className:"flex-shrink-0 w-7 h-7 rounded-lg bg-muted flex items-center justify-center",children:(0,U.jsx)(h$,{className:"w-4 h-4 text-muted-foreground"})}),(0,U.jsx)("div",{className:"flex-1 min-w-0 overflow-hidden",children:(0,U.jsx)("p",{className:"text-muted-foreground break-words",style:{fontSize:"var(--conv-font-size, 12px)"},children:e??""})})]})}let R3=/^data:[^;,]*(?:;[^;,]*)*;base64,(.+)$/;async function R4(e){if(!e)return null;if(e.startsWith("data:"))return e;try{let r=await fetch(e),s=await r.blob();return await new Promise(e=>{let r=new FileReader;r.onload=()=>e("string"==typeof r.result?r.result:null),r.onerror=()=>e(null),r.readAsDataURL(s)})}catch{return null}}let R6=(0,rE.default)("arrow-up",[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]]),R7=(0,rE.default)("file-plus",[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M9 15h6",key:"cctwl0"}],["path",{d:"M12 18v-6",key:"17g6i2"}]]);(0,rE.default)("mic",[["path",{d:"M12 19v3",key:"npa21l"}],["path",{d:"M19 10v2a7 7 0 0 1-14 0v-2",key:"1vc78b"}],["rect",{x:"9",y:"2",width:"6",height:"13",rx:"3",key:"s6n7sd"}]]);let R8=(0,rE.default)("paperclip",[["path",{d:"m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551",key:"1miecu"}]]),R9=(e=21)=>{let r="",s=crypto.getRandomValues(new Uint8Array(e|=0));for(;e--;)r+="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict"[63&s[e]];return r},Ae=(0,V.createContext)(null),At=(0,V.createContext)(null),Ar=()=>(0,V.useContext)(Ae),As=(0,V.createContext)(null),An=()=>{let e=(0,V.useContext)(At),r=(0,V.useContext)(As),s=e??r;if(!s)throw Error("usePromptInputAttachments must be used within a PromptInput or PromptInputProvider");return s};function Ai({data:e,className:r,status:s,onRetry:n,...i}){let a=An(),o=e.filename||"",l=s?.phase==="reading"||s?.phase==="uploading",c=s?.phase==="error",d="image"==(e.mediaType?.startsWith("image/")&&e.url?"image":"file"),u=o||(d?"Image":"Attachment");return(0,U.jsxs)(Av,{children:[(0,U.jsx)(DR,{asChild:!0,children:(0,U.jsxs)("div",{className:(0,e1.cn)("group relative flex h-8 cursor-pointer select-none items-center gap-1.5 overflow-hidden rounded-md border border-border px-1.5 font-medium text-sm transition-all hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",c&&"border-destructive text-destructive",r),onClick:c?n:void 0,...i,children:[(0,U.jsxs)("div",{className:"relative size-5 shrink-0",children:[(0,U.jsx)("div",{className:"absolute inset-0 flex size-5 items-center justify-center overflow-hidden rounded bg-background transition-opacity group-hover:opacity-0",children:d?(0,U.jsx)("img",{alt:o||"attachment",className:"size-5 object-cover",height:20,src:e.url,width:20}):(0,U.jsx)("div",{className:"flex size-5 items-center justify-center text-muted-foreground",children:(0,U.jsx)(R8,{className:"size-3"})})}),(0,U.jsxs)(a$.Button,{"aria-label":"Remove attachment",className:"absolute inset-0 size-5 cursor-pointer rounded p-0 opacity-0 transition-opacity group-hover:pointer-events-auto group-hover:opacity-100 [&>svg]:size-2.5",onClick:r=>{r.stopPropagation(),a.remove(e.id)},type:"button",variant:"ghost",children:[(0,U.jsx)(rD,{}),(0,U.jsx)("span",{className:"sr-only",children:"Remove"})]})]}),(0,U.jsx)("span",{className:(0,e1.cn)("flex-1 truncate",l&&"opacity-60"),children:u}),l&&(0,U.jsx)(aP,{className:"size-3 shrink-0 animate-spin text-muted-foreground"}),c&&(0,U.jsx)(aR,{className:"size-3 shrink-0"}),s?.phase==="uploading"&&(0,U.jsx)("span",{"aria-hidden":!0,className:"absolute inset-x-0 bottom-0 h-0.5 bg-primary transition-[width] duration-150","data-testid":"attachment-progress",style:{width:`${Math.round((s.progress??0)*100)}%`}})]},e.id)}),(0,U.jsx)(Ay,{className:"w-auto p-2",children:(0,U.jsxs)("div",{className:"w-auto space-y-3",children:[d&&(0,U.jsx)("div",{className:"flex max-h-96 w-96 items-center justify-center overflow-hidden rounded-md border",children:(0,U.jsx)("img",{alt:o||"attachment preview",className:"max-h-full max-w-full object-contain",height:384,src:e.url,width:448})}),(0,U.jsx)("div",{className:"flex items-center gap-2.5",children:(0,U.jsxs)("div",{className:"min-w-0 flex-1 space-y-1 px-0.5",children:[(0,U.jsx)("h4",{className:"truncate font-semibold text-sm leading-none",children:o||(d?"Image":"Attachment")}),c?(0,U.jsxs)("p",{className:"text-destructive text-xs",children:[s?.message??"Upload failed",n?" — click to retry":""]}):l?(0,U.jsx)("p",{className:"text-muted-foreground text-xs",children:s?.phase==="reading"?"Reading…":`Uploading… ${Math.round((s?.progress??0)*100)}%`}):e.mediaType&&(0,U.jsx)("p",{className:"truncate font-mono text-muted-foreground text-xs",children:e.mediaType})]})})]})})]})}function Aa({children:e,className:r,...s}){let n=An();return n.files.length?(0,U.jsx)("div",{className:(0,e1.cn)("flex flex-wrap items-center gap-2 p-3 w-full",r),...s,children:n.files.map(r=>(0,U.jsx)(V.Fragment,{children:e(r)},r.id))}):null}let Ao=({label:e="Add photos or files",...r})=>{let s=An(),n=(0,V.useContext)(Ah);return(0,U.jsxs)(i7,{...r,onSelect:e=>{e.preventDefault(),s.openFileDialog(),setTimeout(()=>n?.(),0)},children:[(0,U.jsx)(R7,{className:"mr-2 size-4"})," ",e]})},Al=({className:e,accept:r,multiple:s,globalDrop:n,syncHiddenInput:i,maxFiles:a,maxFileSize:o,skipAttachmentConversion:l,onError:c,onSubmit:d,children:u,...h})=>{let f=Ar(),p=!!f,m=(0,V.useRef)(null),g=(0,V.useRef)(null),[x,v]=(0,V.useState)([]),y=p?f.attachments.files:x,b=(0,V.useRef)(y);b.current=y;let w=(0,V.useCallback)(()=>{m.current?.click()},[]),_=(0,V.useCallback)(e=>!r||""===r.trim()||r.split(",").map(e=>e.trim()).filter(Boolean).some(r=>{if(r.endsWith("/*")){let s=r.slice(0,-1);return e.type.startsWith(s)}return e.type===r}),[r]),S=(0,V.useCallback)(e=>{let r=Array.from(e),s=r.filter(e=>_(e));if(r.length&&0===s.length)return void c?.({code:"accept",message:"No files match the accepted types."});let n=e=>!o||e.size<=o,i=s.filter(n),l=s.filter(e=>!n(e));l.length>0&&(c?.({code:"max_file_size",message:0===i.length?"All files exceed the maximum size.":`Skipped ${l.length} file${1===l.length?"":"s"} over the maximum size: ${l.map(e=>e.name).join(", ")}`,files:l}),0===i.length)||v(e=>{let r="number"==typeof a?Math.max(0,a-e.length):void 0,s="number"==typeof r?i.slice(0,r):i;"number"==typeof r&&i.length>r&&c?.({code:"max_files",message:"Too many files. Some were not added."});let n=[];for(let e of s)n.push({id:R9(),type:"file",url:URL.createObjectURL(e),mediaType:e.type,filename:e.name});return e.concat(n)})},[_,a,o,c]),k=(0,V.useCallback)(e=>v(r=>{let s=r.find(r=>r.id===e);return s?.url&&URL.revokeObjectURL(s.url),r.filter(r=>r.id!==e)}),[]),j=(0,V.useCallback)(()=>v(e=>{for(let r of e)r.url&&URL.revokeObjectURL(r.url);return[]}),[]),C=(0,V.useCallback)(()=>{let e=b.current;return v([]),e},[]),N=(0,V.useCallback)(e=>{v(r=>{let s=new Set(r.map(e=>e.id));return r.concat(e.filter(e=>!s.has(e.id)))})},[]),E=p?f.attachments.add:S,D=p?f.attachments.remove:k,T=p?f.attachments.clear:j,R=p?f.attachments.detach:C,A=p?f.attachments.restore:N,M=p?f.attachments.openFileDialog:w;(0,V.useEffect)(()=>{p&&f.__registerFileInput(m,()=>m.current?.click())},[p,f]),(0,V.useEffect)(()=>{i&&m.current&&0===y.length&&(m.current.value="")},[y,i]),(0,V.useEffect)(()=>{let e=g.current;if(!e||n)return;let r=e=>{e.dataTransfer?.types?.includes("Files")&&e.preventDefault()},s=e=>{e.dataTransfer?.types?.includes("Files")&&e.preventDefault(),e.dataTransfer?.files&&e.dataTransfer.files.length>0&&E(e.dataTransfer.files)};return e.addEventListener("dragover",r),e.addEventListener("drop",s),()=>{e.removeEventListener("dragover",r),e.removeEventListener("drop",s)}},[E,n]),(0,V.useEffect)(()=>{if(!n)return;let e=e=>{e.dataTransfer?.types?.includes("Files")&&e.preventDefault()},r=e=>{e.dataTransfer?.types?.includes("Files")&&e.preventDefault(),e.dataTransfer?.files&&e.dataTransfer.files.length>0&&E(e.dataTransfer.files)};return document.addEventListener("dragover",e),document.addEventListener("drop",r),()=>{document.removeEventListener("dragover",e),document.removeEventListener("drop",r)}},[E,n]),(0,V.useEffect)(()=>()=>{if(!p)for(let e of b.current)e.url&&URL.revokeObjectURL(e.url)},[p]);let I=(0,V.useMemo)(()=>({files:y.map(e=>({...e,id:e.id})),add:E,remove:D,clear:T,detach:R,restore:A,openFileDialog:M,fileInputRef:m}),[y,E,D,T,R,A,M]),P=(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)("input",{accept:r,"aria-label":"Upload files",className:"hidden",multiple:s,onChange:e=>{e.currentTarget.files&&E(e.currentTarget.files),e.currentTarget.value=""},ref:m,title:"Upload files",type:"file"}),(0,U.jsx)("form",{className:(0,e1.cn)("w-full",e),onSubmit:e=>{e.preventDefault();let r=e.currentTarget,s=p?f.textInput.value:new FormData(r).get("message")||"";p||r.reset(),Promise.all(y.map(async e=>{if(!l&&e.url&&e.url.startsWith("blob:")){let r=await R4(e.url);return{...e,url:r??e.url}}return e})).then(r=>{try{let n=d({text:s,files:r},e);n instanceof Promise?n.then(()=>{T(),p&&f.textInput.clear()}).catch(()=>{}):(T(),p&&f.textInput.clear())}catch{}}).catch(()=>{})},ref:g,...h,children:(0,U.jsx)(j4,{className:"overflow-hidden border-[#dedede] bg-card shadow-none dark:border-input dark:bg-card focus-within:border-foreground has-[[data-slot=input-group-control]:focus-visible]:border-foreground has-[[data-slot=input-group-control]:focus-visible]:ring-0",children:u})})]});return p?P:(0,U.jsx)(As.Provider,{value:I,children:P})},Ac=({onChange:e,onKeyDown:r,onPasteText:s,className:n,placeholder:i="What would you like to know?",...a})=>{let o=Ar(),l=An(),[c,d]=(0,V.useState)(!1),u=o?{value:o.textInput.value,onChange:r=>{o.textInput.setInput(r.currentTarget.value),e?.(r)}}:{onChange:e};return(0,U.jsx)(Ct,{className:(0,e1.cn)("field-sizing-content max-h-48 min-h-9",n),name:"message",onCompositionEnd:()=>d(!1),onCompositionStart:()=>d(!0),onKeyDown:e=>{if(r?.(e),!e.defaultPrevented){if("Enter"===e.key){if(c||e.nativeEvent.isComposing||e.shiftKey)return;e.preventDefault();let r=e.currentTarget.form,s=r?.querySelector('button[type="submit"]');if(s?.disabled)return;r?.requestSubmit()}if("Backspace"===e.key&&""===e.currentTarget.value&&l.files.length>0){e.preventDefault();let r=l.files.at(-1);r&&l.remove(r.id)}}},onPaste:e=>{let r=e.clipboardData?.items;if(!r)return;let n=[];for(let e of r)if("file"===e.kind){let r=e.getAsFile();r&&n.push(r)}if(n.length>0){e.preventDefault(),l.add(n);return}if(s){let r=e.clipboardData.getData("text");r.length>0&&s(e,r)}},placeholder:i,...a,...u})},Ad=({className:e,...r})=>(0,U.jsx)(j7,{align:"block-end",className:(0,e1.cn)("order-first flex-wrap gap-1",e),...r}),Au=({variant:e="ghost",className:r,size:s,...n})=>{let i=s??(V.Children.count(n.children)>1?"sm":"icon-sm");return(0,U.jsx)(j9,{className:(0,e1.cn)(r),size:i,type:"button",variant:e,...n})},Ah=(0,V.createContext)(null),Af=({open:e,defaultOpen:r,onOpenChange:s,...n})=>{let[i,a]=(0,V.useState)(r??!1),o=void 0!==e,l=(0,V.useCallback)(e=>{o||a(e),s?.(e)},[o,s]),c=(0,V.useCallback)(()=>l(!1),[l]);return(0,U.jsx)(Ah.Provider,{value:c,children:(0,U.jsx)(i3,{open:o?e:i,onOpenChange:l,...n})})},Ap=({className:e,children:r,...s})=>(0,U.jsx)(i4,{asChild:!0,children:(0,U.jsx)(Au,{className:e,...s,children:r??(0,U.jsx)(oS,{className:"size-4"})})}),Am=({className:e,...r})=>(0,U.jsx)(i6,{align:"start",className:(0,e1.cn)(e),...r}),Ag=({className:e,...r})=>(0,U.jsx)(i7,{className:(0,e1.cn)(e),...r}),Ax=({className:e,variant:r="default",size:s="icon-sm",status:n,children:i,...a})=>{let o=(0,U.jsx)(R6,{className:"size-4"});return"submitted"===n?o=(0,U.jsx)(aP,{className:"size-4 animate-spin"}):"streaming"===n?o=(0,U.jsx)(ce,{className:"size-4"}):"error"===n&&(o=(0,U.jsx)(rD,{className:"size-4"})),(0,U.jsx)(j9,{"aria-label":"Submit",className:(0,e1.cn)("rounded-full",e),size:s,type:"submit",variant:r,...a,children:i??o})},Av=({openDelay:e=0,closeDelay:r=0,...s})=>(0,U.jsx)(DT,{closeDelay:r,openDelay:e,...s}),Ay=({align:e="start",...r})=>(0,U.jsx)(DA,{align:e,...r}),Ab=({size:e=16})=>(0,U.jsxs)("svg",{height:e,strokeLinejoin:"round",style:{color:"currentcolor"},viewBox:"0 0 16 16",width:e,children:[(0,U.jsx)("title",{children:"Loader"}),(0,U.jsxs)("g",{clipPath:"url(#clip0_2393_1490)",children:[(0,U.jsx)("path",{d:"M8 0V4",stroke:"currentColor",strokeWidth:"1.5"}),(0,U.jsx)("path",{d:"M8 16V12",opacity:"0.5",stroke:"currentColor",strokeWidth:"1.5"}),(0,U.jsx)("path",{d:"M3.29773 1.52783L5.64887 4.7639",opacity:"0.9",stroke:"currentColor",strokeWidth:"1.5"}),(0,U.jsx)("path",{d:"M12.7023 1.52783L10.3511 4.7639",opacity:"0.1",stroke:"currentColor",strokeWidth:"1.5"}),(0,U.jsx)("path",{d:"M12.7023 14.472L10.3511 11.236",opacity:"0.4",stroke:"currentColor",strokeWidth:"1.5"}),(0,U.jsx)("path",{d:"M3.29773 14.472L5.64887 11.236",opacity:"0.6",stroke:"currentColor",strokeWidth:"1.5"}),(0,U.jsx)("path",{d:"M15.6085 5.52783L11.8043 6.7639",opacity:"0.2",stroke:"currentColor",strokeWidth:"1.5"}),(0,U.jsx)("path",{d:"M0.391602 10.472L4.19583 9.23598",opacity:"0.7",stroke:"currentColor",strokeWidth:"1.5"}),(0,U.jsx)("path",{d:"M15.6085 10.4722L11.8043 9.2361",opacity:"0.3",stroke:"currentColor",strokeWidth:"1.5"}),(0,U.jsx)("path",{d:"M0.391602 5.52783L4.19583 6.7639",opacity:"0.8",stroke:"currentColor",strokeWidth:"1.5"})]}),(0,U.jsx)("defs",{children:(0,U.jsx)("clipPath",{id:"clip0_2393_1490",children:(0,U.jsx)("rect",{fill:"white",height:"16",width:"16"})})})]}),Aw=({className:e,size:r=16,...s})=>(0,U.jsx)("div",{className:(0,e1.cn)("inline-flex animate-spin items-center justify-center",e),...s,children:(0,U.jsx)(Ab,{size:r})}),A_=new Map;function AS(e,r){return`${e}\u0000${r??""}`}let Ak=null,Aj=new Map,AC=new Set;function AN(e){return AC.add(e),()=>{AC.delete(e)}}function AE(e,r,s){if(!e||!s)return;let n=Aj.get(AS(e,r));return n?n.has(s):void 0}function AD(e,r,s){let n=AS(e,r),i=function(){if(null===Ak){let e={};Ak=e,queueMicrotask(()=>{Ak===e&&(Ak=null)})}return Ak}(),a=A_.get(n);if(a&&(!s?.force||a.tick===i))return{request:a.request,awaitingDismissal:a.awaitingDismissal,issuedAt:a.issuedAt};let o=Date.now(),l=aC.api.getActiveWorkflowRuns(e,r),c=l.then(e=>(!function(e,r){if(!r)return;let s=Aj.get(e);if(s&&r.every(e=>s.has(e)))return;let n=new Set(s??[]);r.forEach(e=>n.add(e)),Aj.set(e,n),AC.forEach(e=>e())}(n,e.reviewedSessionIds),e.runs)),d=l.then(e=>e.awaitingDismissal??[]);d.catch(()=>{});let u={request:c,awaitingDismissal:d,tick:i,issuedAt:o};return A_.set(n,u),c.finally(()=>{A_.get(n)===u&&A_.delete(n)}).catch(()=>{}),{request:c,awaitingDismissal:d,issuedAt:o}}function AT(e,r,s){return AD(e,r,s).request}let AR=(0,rE.default)("wifi",[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M2 8.82a15 15 0 0 1 20 0",key:"dnpr2z"}],["path",{d:"M5 12.859a10 10 0 0 1 14 0",key:"1x1e6c"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}]]),AA=(0,rE.default)("square-pen",[["path",{d:"M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7",key:"1m0v6g"}],["path",{d:"M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z",key:"ohrbg2"}]]),AM=(0,rE.default)("languages",[["path",{d:"m5 8 6 6",key:"1wu5hv"}],["path",{d:"m4 14 6-6 2-3",key:"1k1g8d"}],["path",{d:"M2 5h12",key:"or177f"}],["path",{d:"M7 2h1",key:"1t2jsx"}],["path",{d:"m22 22-5-10-5 10",key:"don7ne"}],["path",{d:"M14 18h6",key:"1m8k6r"}]]),AI=(0,rE.default)("split",[["path",{d:"M16 3h5v5",key:"1806ms"}],["path",{d:"M8 3H3v5",key:"15dfkv"}],["path",{d:"M12 22v-8.3a4 4 0 0 0-1.172-2.872L3 3",key:"1qrqzj"}],["path",{d:"m15 9 6-6",key:"ko1vev"}]]);function AP({type:e}){let{Icon:r}=Eg(e);return(0,U.jsx)("div",{className:(0,e1.cn)("flex h-5 w-5 shrink-0 items-center justify-center rounded-full",Eg(e).branchAccent),children:(0,U.jsx)(r,{className:"h-3 w-3"})})}function AF({agentType:e,currentAgentName:r,alternateProviders:s,onBranch:n,disabled:i,emphasis:a="normal"}){return(0,U.jsxs)(i3,{children:[(0,U.jsx)(i4,{asChild:!0,children:(0,U.jsx)(a$.Button,{variant:"ghost",size:"icon",className:(0,e1.cn)("h-7 w-7 rounded-md transition-colors hover:bg-muted hover:text-foreground","subtle"===a?"text-muted-foreground/50 group-hover:text-muted-foreground group-focus-within:text-muted-foreground":"text-muted-foreground"),disabled:i,"aria-label":"Branch conversation",children:i?(0,U.jsx)(aP,{className:"h-4 w-4 animate-spin"}):(0,U.jsx)(AI,{className:"h-4 w-4"})})}),(0,U.jsxs)(i6,{align:"start",className:"w-44 p-1.5",children:[(0,U.jsx)(at,{className:"px-2 py-1.5",children:(0,U.jsx)("div",{className:"text-xs font-medium",children:"Branch conversation"})}),(0,U.jsxs)(i7,{className:"h-8 cursor-pointer items-center gap-2 rounded-md px-2 text-xs",onSelect:()=>n(),children:[(0,U.jsx)(AP,{type:e}),(0,U.jsx)("span",{className:"min-w-0 flex-1 truncate",children:r}),(0,U.jsx)("span",{className:"shrink-0 text-[11px] text-muted-foreground",children:"current"})]}),s.length>0&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(ar,{className:"my-1"}),s.map(e=>(0,U.jsxs)(i7,{className:"h-8 cursor-pointer items-center gap-2 rounded-md px-2 text-xs",onSelect:()=>n(e.type),children:[(0,U.jsx)(AP,{type:e.type}),(0,U.jsx)("span",{className:"min-w-0 flex-1 truncate",children:e.displayName})]},e.type))]})]})]})}let AL=(0,rE.default)("corner-up-left",[["path",{d:"M20 20v-7a4 4 0 0 0-4-4H4",key:"1nkjon"}],["path",{d:"M9 14 4 9l5-5",key:"102s5s"}]]),AO=e=>(0,e1.cn)("h-7 w-7 shrink-0 rounded-md transition-colors hover:bg-muted hover:text-foreground","subtle"===e?"text-muted-foreground/50 group-hover:text-muted-foreground group-focus-within:text-muted-foreground":"text-muted-foreground");function AB({sendBack:e,emphasis:r}){let s=e.available?e.sent?"Sent — click to send again":"Send this answer back to the source session":"Source session no longer exists",n=(0,U.jsx)(a$.Button,{variant:"ghost",size:"icon",className:AO(r),"aria-label":"Send back to source session",disabled:!e.available||e.busy,onClick:e.onSend,children:e.busy?(0,U.jsx)(aP,{className:"h-4 w-4 animate-spin"}):e.sent?(0,U.jsx)(al.Check,{className:"h-4 w-4"}):(0,U.jsx)(AL,{className:"h-4 w-4"})});return(0,U.jsx)(cI,{children:(0,U.jsxs)(cP,{children:[(0,U.jsx)(cF,{asChild:!0,children:e.available?n:(0,U.jsx)("span",{tabIndex:-1,children:n})}),(0,U.jsx)(cL,{children:s})]})})}function Az({durationMs:e,outcome:r,emphasis:s,agentType:n,currentAgentName:i,alternateProviders:a,onBranch:o,disabled:l,showFinalize:c,finalizeBusy:d,onFinalize:u,sendBack:h}){let f=void 0!==e?fH(e):"server_restart"===r?"interrupted":null;return(0,U.jsxs)("div",{className:"group flex items-center gap-2 py-0.5","data-turn-end":!0,children:[(0,U.jsx)("div",{className:"h-px flex-1 bg-border/60"}),null!==f&&(0,U.jsx)("span",{className:(0,e1.cn)("shrink-0 text-[11px] tabular-nums transition-colors","subtle"===s?"text-muted-foreground/50 group-hover:text-muted-foreground group-focus-within:text-muted-foreground":"text-muted-foreground"),children:f}),c&&(0,U.jsx)(cI,{children:(0,U.jsxs)(cP,{children:[(0,U.jsx)(cF,{asChild:!0,children:(0,U.jsx)(a$.Button,{variant:"ghost",size:"icon",className:AO(s),"aria-label":"生成 review 终稿",onClick:u,disabled:l||d,children:d?(0,U.jsx)(aP,{className:"h-4 w-4 animate-spin"}):(0,U.jsx)(E9,{className:"h-4 w-4"})})}),(0,U.jsx)(cL,{children:"生成 review 终稿"})]})}),h&&(0,U.jsx)(AB,{sendBack:h,emphasis:s}),(0,U.jsx)(AF,{agentType:n,currentAgentName:i,alternateProviders:a,onBranch:o,disabled:l,emphasis:s}),(0,U.jsx)("div",{className:"h-px flex-1 bg-border/60"})]})}let A$=(e,r)=>Math.max(0,e-r),AW=["process","agent","other"],AH={process:"Process",agent:"Subagent",other:"Task"},AU={process:["background process","background processes"],agent:["background subagent","background subagents"],other:["background task","background tasks"]};function AV(e){return"local_bash"===e.taskType?"process":"local_agent"===e.taskType||"codex_subagent"===e.taskType?"agent":"other"}function Aq({kind:e}){let r="h-3.5 w-3.5";return"process"===e?(0,U.jsx)(xb,{className:r,"aria-hidden":"true"}):"agent"===e?(0,U.jsx)(aA,{className:r,"aria-hidden":"true"}):(0,U.jsx)(on,{className:r,"aria-hidden":"true"})}function AK({sessionId:e,tasks:r,turnParked:s,parkDeadlineAt:n,canStopTasks:i,agentWorking:a}){let o,l,[c,d]=(0,V.useState)(!1),[u,h]=(0,V.useState)(new Set),f=function(e){let[r,s]=(0,V.useState)(()=>Date.now());return(0,V.useEffect)(()=>{if(!e)return;let r=setInterval(()=>s(Date.now()),1e3);return()=>clearInterval(r)},[e]),r}(r.length>0);if(0===r.length)return null;let p=r.reduce((e,r)=>Math.max(e,A$(f,r.startedAt)),0),m=null===n||(o=Math.round((n-f)/1e3))<=0?null:`${Math.floor(o/60)}:${String(o%60).padStart(2,"0")}`,g=r.some(e=>e.sanctioned),x=s||a,v=m?`${m} until this turn closes automatically`:s&&g?"Waiting for these tasks":s?"Response complete":a?"Running alongside the agent":"This turn has closed",y=async(r,s)=>{if(e){h(e=>new Set(e).add(r));try{return await s(r)}finally{h(e=>{let s=new Set(e);return s.delete(r),s})}}};return(0,U.jsxs)("div",{className:(0,e1.cn)("mb-2 rounded-lg border text-xs",x?"border-amber-500/40 bg-amber-500/5":"border-border/60 bg-muted/30"),children:[(0,U.jsxs)("button",{type:"button",onClick:()=>d(e=>!e),"aria-expanded":c,className:"flex w-full items-center gap-2 px-3 py-2 text-left text-muted-foreground transition-colors hover:text-foreground",children:[(0,U.jsxs)("span",{className:"relative flex h-1.5 w-1.5 shrink-0",children:[(0,U.jsx)("span",{className:(0,e1.cn)("absolute inline-flex h-full w-full animate-ping rounded-full",x?"bg-amber-500/60":"bg-muted-foreground/40")}),(0,U.jsx)("span",{className:(0,e1.cn)("relative inline-flex h-1.5 w-1.5 rounded-full",x?"bg-amber-500":"bg-muted-foreground/70")})]}),(0,U.jsxs)("span",{className:"truncate",children:[(l=AW.flatMap(e=>{let s=r.filter(r=>AV(r)===e).length;return s?[`${s} ${AU[e][+(1!==s)]}`]:[]}),`${l.join(" · ")} running`),(0,U.jsxs)("span",{className:"tabular-nums",children:[" · ",fH(p)]})]}),(0,U.jsx)("span",{className:(0,e1.cn)("shrink-0",m?"text-amber-600 dark:text-amber-500":"text-muted-foreground/70"),children:v}),(0,U.jsx)(aa,{className:(0,e1.cn)("ml-auto h-3.5 w-3.5 shrink-0 transition-transform",c&&"rotate-180")})]}),c&&(0,U.jsxs)("ul",{className:"border-t border-border/60 px-3 py-2",children:[r.map(r=>{let s=AV(r),n=AH[s];return(0,U.jsxs)("li",{className:"flex items-baseline gap-2 py-1",children:[(0,U.jsx)("span",{className:"inline-flex h-4 w-4 shrink-0 items-center justify-center self-center text-muted-foreground","aria-label":n,title:n,children:(0,U.jsx)(Aq,{kind:s})}),(0,U.jsx)("span",{className:"min-w-0 flex-1 truncate text-foreground/90",children:r.description||r.taskId}),(0,U.jsx)("span",{className:"shrink-0 tabular-nums text-muted-foreground",children:fH(A$(f,r.startedAt))}),e&&(0,U.jsxs)("span",{className:"flex shrink-0 gap-1",children:[m&&!r.sanctioned&&(0,U.jsx)("button",{type:"button",onClick:()=>y(r.taskId,r=>(0,aC.keepBackgroundTaskRunning)(e,r)),disabled:u.has(r.taskId),title:"Keep this turn open until this task finishes, instead of closing it when the timer runs out",className:"rounded border border-border/60 px-1.5 py-px text-[11px] text-muted-foreground transition-colors hover:text-foreground disabled:opacity-50",children:"Keep waiting"}),i&&(0,U.jsx)("button",{type:"button",onClick:()=>y(r.taskId,r=>(0,aC.stopBackgroundTask)(e,r)),disabled:u.has(r.taskId),title:"End this background task now",className:"rounded border border-border/60 px-1.5 py-px text-[11px] text-muted-foreground transition-colors hover:text-foreground disabled:opacity-50",children:"Stop task"})]})]},r.taskId)}),(0,U.jsx)("li",{className:"pt-1.5 text-muted-foreground/70",children:m?"The agent has already answered — these tasks are the only thing keeping this turn open. When the timer runs out the turn closes on its own, and the tasks keep running in the background.":s&&g?"You chose to keep waiting for these tasks, so this turn stays open until they finish.":s?"The agent has already answered — these tasks are the only thing keeping this turn open.":a?"The agent is still working. These tasks are running alongside it.":"This turn has closed, but these tasks are still running. Stopping them will not affect the completed turn."}),!i&&(0,U.jsx)("li",{className:"pt-1 text-muted-foreground/70",children:"This agent cannot stop individual background tasks. Stop the session to end them all."})]})]})}function AX({candidates:e,className:r,children:s}){let n=Array.from(new Set(e));return(0,U.jsxs)("span",{className:(0,e1.cn)("grid overflow-hidden text-left",r),children:[n.map(e=>(0,U.jsx)("span",{"aria-hidden":!0,className:"col-start-1 row-start-1 invisible whitespace-nowrap",children:e},e)),(0,U.jsx)("span",{className:"col-start-1 row-start-1 min-w-0 truncate",children:s})]})}let AY="Default",AG="Runs whatever model the CLI is currently set to, which may not be its built-in default.",AJ="inline-flex items-center gap-1 rounded-md border bg-muted/50 px-2 py-0.5 text-xs font-medium";function AZ(e){let r=e.querySelector(".truncate");return!!r&&r.scrollWidth>r.clientWidth}function AQ({models:e,widthCandidates:r,value:s,onChange:n,locked:i}){let a,[o,l]=(0,V.useState)(!1),[c,d]=(0,V.useState)(""),[u,h]=(0,V.useState)(!1),[f,p]=(0,V.useState)(!1),m=(0,V.useRef)(null),g=(0,V.useRef)(null),x=(0,V.useRef)(0);(0,V.useLayoutEffect)(()=>{let e=m.current,r=g.current;if(e&&r){var s;u||(x.current=e.clientWidth),h((s={textWidth:r.offsetWidth,narrowFieldWidth:x.current,wide:u}).narrowFieldWidth<=0?s.wide:s.textWidth>s.narrowFieldWidth)}},[o,c,u]);let v=s??AY,y=[AY,...r??e];if(i)return(0,U.jsx)(jQ,{label:`${v} — fixed while the agent is running, changeable once the turn ends`,children:(0,U.jsxs)("span",{"data-model-chip":"locked",className:(0,e1.cn)(AJ,"text-muted-foreground cursor-default"),children:[(0,U.jsx)(AX,{candidates:y,className:"max-w-40",children:v}),(0,U.jsx)(aa,{className:"h-3 w-3"})]})});let b=c.trim(),w=(a=c.trim()).length>0&&!e.includes(a),_=e=>{n(e),d(""),l(!1)};return(0,U.jsxs)(pa,{open:o,onOpenChange:l,children:[(0,U.jsx)(jQ,{label:f?v:null,children:(0,U.jsx)(po,{asChild:!0,children:(0,U.jsxs)("button",{className:(0,e1.cn)(AJ,"transition-colors hover:bg-muted"),onPointerEnter:e=>p(AZ(e.currentTarget)),onFocus:e=>p(AZ(e.currentTarget)),children:[(0,U.jsx)(AX,{candidates:y,className:"max-w-40",children:v}),(0,U.jsx)(aa,{className:"h-3 w-3 text-muted-foreground"})]})})}),(0,U.jsxs)(pl,{className:u?"w-56":"w-[var(--radix-popover-trigger-width)]",children:[(0,U.jsx)("span",{ref:g,"aria-hidden":!0,className:"pointer-events-none invisible absolute whitespace-pre text-sm",children:c}),(0,U.jsxs)(p$,{shouldFilter:!0,children:[(0,U.jsx)(pH,{ref:m,className:"min-w-0",value:c,onValueChange:d}),(0,U.jsxs)(pU,{children:[(0,U.jsx)(pV,{children:"No match."}),(0,U.jsxs)(pq,{children:[(0,U.jsxs)(pK,{value:AY,onSelect:()=>_(null),className:"text-xs",children:[AY,(0,U.jsx)(cI,{delayDuration:200,children:(0,U.jsxs)(cP,{children:[(0,U.jsx)(cF,{asChild:!0,children:(0,U.jsx)("span",{onClick:e=>e.stopPropagation(),onPointerDown:e=>e.stopPropagation(),className:"ml-auto flex cursor-help items-center text-muted-foreground",children:(0,U.jsx)(h$,{"aria-hidden":!0,className:"size-3"})})}),(0,U.jsx)(cL,{side:"right",className:"max-w-56",children:AG})]})}),(0,U.jsx)("span",{className:"sr-only",children:AG})]}),e.map(e=>(0,U.jsx)(pK,{value:e,onSelect:()=>_(e),className:"text-xs",children:e},e))]}),w&&(0,U.jsx)(pq,{heading:"Custom",children:(0,U.jsx)(pK,{value:b,onSelect:()=>_(b),className:"text-xs [&>span]:truncate",title:b,children:(0,U.jsxs)("span",{children:['Use "',b,'"']})})})]})]})]})]})}let A0=(0,rE.default)("settings-2",[["path",{d:"M14 17H5",key:"gfn3mx"}],["path",{d:"M19 7h-9",key:"6i9tg"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}],["circle",{cx:"7",cy:"7",r:"3",key:"dfmy0x"}]]),A1=new Set(["workspace","tasks","schedules","remote-servers","settings","project-info","project-chat"]),A2="tasks";function A5(e){return e.length>0&&e.trim()===e&&!/[\u0000-\u001f\u007f/\\]/.test(e)}function A3(){let e=window.location.pathname,r=new URLSearchParams(window.location.search),s=r.get("project");if(s){let e=r.get("tab");return{projectId:s,tab:e&&A1.has(e)?e:A2,branch:r.get("branch"),threadId:null}}let n=e.split("/").filter(Boolean);if(1===n.length&&A1.has(n[0])){let e=n[0];if("remote-servers"===e||"settings"===e)return{projectId:null,tab:e,branch:null,threadId:null}}let i=null,a=A2,o=null;if("p"===n[0]&&n[1]){i=n[1];let e=n[2];if("chat"===e&&4===n.length&&n[3])try{let e=decodeURIComponent(n[3]);A5(e)?(o=e,a="project-chat"):a="project-info"}catch{a="project-info",o=null}else"chat"===e?a="project-info":e&&A1.has(e)&&"project-chat"!==e&&(a=e)}return{projectId:i,tab:a,branch:r.get("branch"),threadId:o}}function A4(e){let{projectId:r,tab:s,branch:n,threadId:i}=e;if("remote-servers"===s||"settings"===s)return`/${s}`;if(!r)return"/";if("project-chat"===s)return i&&A5(i)?`/p/${r}/chat/${encodeURIComponent(i)}`:`/p/${r}/project-info`;let a=`/p/${r}/${s??A2}`;return n&&(a+=`?branch=${encodeURIComponent(n)}`),a}function A6({granted:e,onToggle:r,sourceRemoteId:s,disabled:n}){let[i,a]=(0,V.useState)(null),[o,l]=(0,V.useState)(!1),c=(0,V.useCallback)(()=>{l(!1),aC.api.getRemoteServers().then(e=>a([...e].sort((e,r)=>Number("online"===r.status)-Number("online"===e.status)))).catch(()=>l(!0))},[]),d=(i??[]).filter(e=>"off"!==e.cross_remote_access).filter(e=>e.id!==s);return(0,U.jsxs)(as,{onOpenChange:e=>{e&&c()},children:[(0,U.jsxs)(an,{disabled:n,children:[(0,U.jsx)(oj,{className:"mr-2 size-4"}),"Remote access"]}),(0,U.jsxs)(ai,{className:"w-64 p-1",children:[(0,U.jsxs)("div",{className:"px-2 pt-1.5 pb-2",children:[(0,U.jsx)("div",{className:"text-sm font-medium",children:"Remote access"}),(0,U.jsx)("div",{className:"text-xs text-muted-foreground",children:s?"Other machines this agent can reach":"Machines this agent can reach"})]}),(0,U.jsx)(ar,{}),(0,U.jsxs)("div",{className:"max-h-72 overflow-y-auto",children:[null===i&&!o&&(0,U.jsxs)("div",{className:"flex items-center gap-2 px-2 py-3 text-sm text-muted-foreground",children:[(0,U.jsx)(aP,{className:"size-3.5 animate-spin"})," Loading machines…"]}),o&&(0,U.jsx)("div",{className:"px-2 py-3 text-sm text-muted-foreground",children:"Could not load remote machines."}),null!==i&&!o&&0===d.length&&(0,U.jsxs)("div",{className:"flex flex-col items-center gap-2 px-4 py-5 text-center",children:[(0,U.jsx)("div",{className:"flex size-9 items-center justify-center rounded-full bg-muted",children:(0,U.jsx)(oj,{className:"size-4 text-muted-foreground"})}),(0,U.jsx)("div",{className:"text-sm font-medium",children:"No machines available"}),(0,U.jsx)("div",{className:"text-xs text-muted-foreground",children:"Enable cross-remote access for another machine in Remote Servers."})]}),d.map(s=>{let n=e.some(e=>e.id===s.id),i="online"===s.status,a="exec"===s.cross_remote_access;return(0,U.jsxs)(i7,{role:"menuitemcheckbox","aria-checked":n,onSelect:e=>{e.preventDefault(),r({id:s.id,name:s.name,access:s.cross_remote_access,online:i},!n)},className:"gap-3 py-2",children:[(0,U.jsxs)("span",{className:"relative flex size-8 shrink-0 items-center justify-center rounded-md border bg-muted/40",children:[(0,U.jsx)(oj,{className:"size-4"}),(0,U.jsx)("span",{className:(0,e1.cn)("absolute -right-0.5 -bottom-0.5 size-2.5 rounded-full ring-2 ring-popover",i?"bg-emerald-500":"bg-muted-foreground/50"),title:i?"Online":"Offline"})]}),(0,U.jsxs)("span",{className:"flex min-w-0 flex-1 flex-col",children:[(0,U.jsx)("span",{className:"truncate font-medium",children:s.name}),(0,U.jsx)("span",{className:"flex min-w-0 items-center gap-1 whitespace-nowrap text-xs text-muted-foreground",children:a?(0,U.jsxs)("span",{className:"flex min-w-0 items-center gap-1 text-amber-600 dark:text-amber-400",children:[(0,U.jsx)(my,{className:"size-3"}),(0,U.jsx)("span",{className:"truncate",children:"Run commands"})]}):(0,U.jsxs)("span",{className:"flex min-w-0 items-center gap-1",children:[(0,U.jsx)(S_,{className:"size-3"}),(0,U.jsx)("span",{className:"truncate",children:"Read only"})]})})]}),(0,U.jsx)("span",{"aria-hidden":!0,className:(0,e1.cn)("relative inline-flex h-4.5 w-8 shrink-0 items-center rounded-full transition-colors",n?"bg-emerald-500":"bg-muted-foreground/25"),children:(0,U.jsx)("span",{className:(0,e1.cn)("size-3.5 rounded-full bg-white shadow-sm transition-transform",n?"translate-x-4":"translate-x-0.5")})})]},s.id)})]}),(0,U.jsx)(ar,{}),(0,U.jsxs)(i7,{onSelect:()=>{window.history.pushState(null,"",A4({tab:"remote-servers"})),window.dispatchEvent(new PopStateEvent("popstate"))},className:"text-muted-foreground",children:[(0,U.jsx)(A0,{className:"size-4"}),"Manage machines…"]})]})]})}function A7({granted:e,onRevoke:r}){return 0===e.length?null:(0,U.jsx)("div",{className:"flex flex-wrap items-center gap-1.5 pl-12 pr-2 pt-1.5 pb-0.5",children:e.map(e=>(0,U.jsxs)("button",{type:"button",onClick:()=>r(e),title:`Cross-remote ${e.access} access \xb7 ${e.online?"online":"offline"}`,className:(0,e1.cn)("inline-flex shrink-0 items-center gap-1.5 rounded-full px-2.5 py-0.5 text-xs font-medium transition-colors","bg-emerald-500/10 text-emerald-700 dark:text-emerald-400 hover:bg-emerald-500/20"),children:[(0,U.jsxs)("span",{className:"relative flex",children:[(0,U.jsx)(oj,{className:"size-3"}),(0,U.jsx)("span",{className:(0,e1.cn)("absolute -right-0.5 -bottom-0.5 size-1.5 rounded-full ring-1 ring-background",e.online?"bg-emerald-500":"bg-muted-foreground/60")})]}),e.name,(0,U.jsx)(rD,{className:"size-3"})]},e.id))})}let A8=(0,rE.default)("list-checks",[["path",{d:"M13 5h8",key:"a7qcls"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 19h8",key:"c3s6r1"}],["path",{d:"m3 17 2 2 4-4",key:"1jhpwq"}],["path",{d:"m3 7 2 2 4-4",key:"1obspn"}]]),A9={todo:{Icon:i5,tone:"text-muted-foreground"},in_progress:{Icon:c2,tone:"text-blue-500"},done:{Icon:os,tone:"text-emerald-500"},cancelled:{Icon:oi,tone:"text-muted-foreground"}},Me={in_progress:0,todo:1,done:2,cancelled:3};function Mt({projectId:e,selected:r,onToggle:s,disabled:n}){let[i,a]=(0,V.useState)(null),[o,l]=(0,V.useState)(!1),[c,d]=(0,V.useState)(""),u=(0,V.useCallback)(()=>{e&&(l(!1),aC.api.getTasks(e).then(e=>a([...e].sort((e,r)=>Me[e.status]-Me[r.status]))).catch(()=>l(!0)))},[e]),h=c.trim().toLowerCase(),f=(i??[]).filter(e=>!h||e.title.toLowerCase().includes(h));return(0,U.jsxs)(as,{onOpenChange:e=>{e&&(d(""),u())},children:[(0,U.jsxs)(an,{disabled:n||!e,children:[(0,U.jsx)(on,{className:"mr-2 size-4"}),"Select task",r.length>0&&(0,U.jsx)("span",{className:"ml-auto rounded-full bg-violet-500/15 px-1.5 text-[11px] font-medium text-violet-700 dark:text-violet-300",children:r.length})]}),(0,U.jsxs)(ai,{className:"w-[360px] p-1",children:[(0,U.jsxs)("div",{className:"px-2 pt-1.5 pb-2",children:[(0,U.jsx)("div",{className:"text-sm font-medium",children:"Select task"}),(0,U.jsx)("div",{className:"text-xs text-muted-foreground",children:"Discuss, work on or change these in your next message"})]}),(0,U.jsxs)("div",{className:"relative px-1 pb-1",children:[(0,U.jsx)(aK,{className:"pointer-events-none absolute top-1/2 left-3 size-3.5 -translate-y-[60%] text-muted-foreground"}),(0,U.jsx)("input",{value:c,onChange:e=>d(e.target.value),onKeyDown:e=>{"Escape"!==e.key&&e.stopPropagation()},placeholder:"Filter tasks","aria-label":"Filter tasks",className:"h-7 w-full rounded-md border bg-transparent pr-2 pl-7 text-xs outline-none focus-visible:ring-1 focus-visible:ring-ring"})]}),(0,U.jsx)(ar,{}),(0,U.jsxs)("div",{className:"max-h-72 overflow-y-auto",children:[null===i&&!o&&(0,U.jsxs)("div",{className:"flex items-center gap-2 px-2 py-3 text-sm text-muted-foreground",children:[(0,U.jsx)(aP,{className:"size-3.5 animate-spin"})," Loading tasks…"]}),o&&(0,U.jsx)("div",{className:"px-2 py-3 text-sm text-muted-foreground",children:"Could not load tasks."}),null!==i&&!o&&0===f.length&&(0,U.jsxs)("div",{className:"flex flex-col items-center gap-2 px-4 py-5 text-center",children:[(0,U.jsx)("div",{className:"flex size-9 items-center justify-center rounded-full bg-muted",children:(0,U.jsx)(A8,{className:"size-4 text-muted-foreground"})}),(0,U.jsx)("div",{className:"text-sm font-medium",children:0===i.length?"No tasks yet":"No matching tasks"}),0===i.length&&(0,U.jsx)("div",{className:"text-xs text-muted-foreground",children:"Tasks you add to this project show up here."})]}),f.map(e=>{let n=r.some(r=>r.id===e.id),{Icon:a,tone:o}=A9[e.status],l="done"===e.status||"cancelled"===e.status;return(0,U.jsxs)(i7,{role:"menuitemcheckbox","aria-checked":n,onSelect:r=>{r.preventDefault(),s({...e,subtasks:RK(i??[],e.id)},!n)},className:"gap-2.5 py-1.5",children:[(0,U.jsx)(a,{className:(0,e1.cn)("size-4 shrink-0",o)}),(0,U.jsxs)("span",{className:"flex min-w-0 flex-1 flex-col",children:[(0,U.jsx)("span",{className:(0,e1.cn)("truncate",l&&"text-muted-foreground"),children:e.title}),(0,U.jsxs)("span",{className:"flex items-center gap-1 text-[11px] text-muted-foreground",children:[(0,U.jsx)("span",{className:(0,e1.cn)("size-1.5 rounded-full",T7[e.priority])}),(0,U.jsx)("span",{className:"capitalize",children:e.priority})]})]}),(0,U.jsx)(al.Check,{className:(0,e1.cn)("size-4 shrink-0 text-violet-600 dark:text-violet-400",!n&&"invisible")})]},e.id)})]}),(0,U.jsx)(ar,{}),(0,U.jsxs)(i7,{onSelect:()=>{window.history.pushState(null,"",A4({tab:"tasks"})),window.dispatchEvent(new PopStateEvent("popstate"))},className:"text-muted-foreground",children:[(0,U.jsx)(A8,{className:"size-4"}),"Open Tasks…"]})]})]})}function Mr({tasks:e,onRemove:r}){return 0===e.length?null:(0,U.jsx)("div",{className:"flex flex-wrap items-center gap-1.5 pl-12 pr-2 pt-1.5 pb-0.5",children:e.map(e=>(0,U.jsxs)("button",{type:"button",onClick:()=>r(e),title:e.title,className:"inline-flex max-w-44 shrink-0 items-center gap-1.5 rounded-full bg-violet-500/10 px-2.5 py-0.5 text-xs font-medium text-violet-700 transition-colors hover:bg-violet-500/20 dark:text-violet-300",children:[(0,U.jsx)(on,{className:"size-3 shrink-0"}),(0,U.jsx)("span",{className:"truncate",children:e.title}),(0,U.jsx)(rD,{className:"size-3 shrink-0"})]},e.id))})}let Ms="vibedeckx:remote-grant-declarations",Mn=(e,r)=>e?`s:${e}`:`w:${r}`;function Mi(){try{let e=window.localStorage.getItem(Ms),r=e?JSON.parse(e):null;return r&&"object"==typeof r&&!Array.isArray(r)?r:{}}catch{return{}}}function Ma(e){try{0===Object.keys(e).length?window.localStorage.removeItem(Ms):window.localStorage.setItem(Ms,JSON.stringify(e))}catch{}}function Mo(e){let r=Mi()[e];return Array.isArray(r)?r:[]}let Ml=(0,rE.default)("clipboard-list",[["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:"M12 11h4",key:"1jrz19"}],["path",{d:"M12 16h4",key:"n85exb"}],["path",{d:"M8 11h.01",key:"1dfujw"}],["path",{d:"M8 16h.01",key:"18s6g9"}]]);function Mc({mode:e,onModeChange:r,disabled:s}){return(0,U.jsxs)("div",{className:"inline-flex items-center rounded-md border bg-muted/50 px-0.5 text-xs",children:[(0,U.jsxs)("button",{onClick:()=>r("plan"),disabled:s,className:(0,e1.cn)("inline-flex items-center gap-1 rounded-sm px-2 py-0.5 transition-colors","plan"===e?"bg-primary text-primary-foreground font-medium shadow-sm":"text-muted-foreground hover:text-foreground","disabled:opacity-50 disabled:cursor-not-allowed"),children:[(0,U.jsx)(Ml,{className:"h-3 w-3"}),"Plan"]}),(0,U.jsxs)("button",{onClick:()=>r("edit"),disabled:s,className:(0,e1.cn)("inline-flex items-center gap-1 rounded-sm px-2 py-0.5 transition-colors","edit"===e?"bg-primary text-primary-foreground font-medium shadow-sm":"text-muted-foreground hover:text-foreground","disabled:opacity-50 disabled:cursor-not-allowed"),children:[(0,U.jsx)(lT,{className:"h-3 w-3"}),"Edit"]})]})}function Md({type:e,className:r}){let{Icon:s}=Eg(e);return(0,U.jsx)(s,{className:(0,e1.cn)("h-3 w-3 shrink-0",Eg(e).accentText,r)})}function Mu(e){if(!e)return[];try{let r=window.localStorage.getItem(e);if(!r)return[];let s=JSON.parse(r);if(!Array.isArray(s))return[];return s.filter(e=>"string"==typeof e)}catch{return[]}}let Mh=new Set(["preparing","waiting_reviewer","waiting_feedback","discussing","sending_feedback"]);function Mf(e){if(!e)return"";try{return window.localStorage.getItem(e)??""}catch{return""}}function Mp(e){let r=e.parentElement;for(;r;){let{overflowY:e}=getComputedStyle(r);if("auto"===e||"scroll"===e)return r;r=r.parentElement}return null}function Mm({messages:e,contentRef:r}){let[s,n]=(0,V.useState)([]),[i,a]=(0,V.useState)(!1),[o,l]=(0,V.useState)(null),c=(0,V.useRef)(null),d=(0,V.useCallback)(()=>{let s=r.current;if(!s)return;c.current||(c.current=Mp(s));let i=c.current;if(!i)return;let o=i.scrollHeight>i.clientHeight;if(a(o),!o)return void n([]);let l=s.querySelectorAll("[data-user-msg-idx]"),d=i.getBoundingClientRect(),u=[];l.forEach(r=>{let s=parseInt(r.dataset.userMsgIdx,10),n=e[s];if(!n)return;let a=(r.getBoundingClientRect().top-d.top+i.scrollTop)/i.scrollHeight;u.push({index:s,position:Math.max(0,Math.min(1,a)),preview:function(e){if("user"!==e.type)return"";let r=e.content,s="string"==typeof r?r:r.filter(e=>"text"===e.type).map(e=>e.text).join(" "),n="string"!=typeof r&&r.some(e=>"image"===e.type),i=s.replace(RL,"").replace(Rz,"").replace(RW,"").replace(RH,"").trim().split("\n")[0]??"";return(i.length>80?i.slice(0,77)+"...":i)||(n?"(Image)":s.includes("<vschedule>")?"(Schedule)":s.includes("<vtask>")?"(Task)":"")}(n)})}),n(u)},[e,r]);(0,V.useEffect)(()=>{let e=r.current;if(!e){c.current=null,n([]),a(!1);return}let s=Mp(e);if(!s)return;c.current=s,d();let i=new ResizeObserver(d);return i.observe(s),i.observe(e),()=>{i.disconnect()}},[e,d,r]);let u=(0,V.useCallback)(e=>{let s=r.current;if(!s)return;let n=s.querySelector(`[data-user-msg-idx="${e}"]`);n&&n.scrollIntoView({block:"start",behavior:"smooth"})},[r]);return i&&0!==s.length?(0,U.jsx)("div",{className:"absolute right-0 top-0 bottom-0 w-6 z-20 pointer-events-none",children:s.map(e=>(0,U.jsxs)("div",{className:"absolute right-0.5 -translate-y-1/2 pointer-events-auto",style:{top:`${100*e.position}%`},children:[(0,U.jsx)("div",{className:"w-3 h-[3px] rounded-sm bg-primary/50 hover:bg-primary cursor-pointer transition-colors",onClick:()=>u(e.index),onMouseEnter:()=>l(e.index),onMouseLeave:()=>l(null)}),o===e.index&&e.preview&&(0,U.jsxs)("div",{className:"absolute right-full mr-2 top-1/2 -translate-y-1/2 max-w-64 px-2.5 py-1.5 bg-popover border border-border rounded-md shadow-md text-xs text-popover-foreground whitespace-nowrap overflow-hidden text-ellipsis pointer-events-none",children:[e.preview,(0,U.jsx)("div",{className:"absolute top-1/2 -translate-y-1/2 -right-1 w-2 h-2 bg-popover border-r border-t border-border rotate-45"})]})]},e.index))}):null}function Mg(e,r){return`${e}:${r??""}`}function Mx({projectId:e,branch:r,currentSessionId:s,refreshKey:n,pendingTitleSessionId:i,aiTitleOverride:a,onSwitch:o,onDelete:l}){let[c,d]=(0,V.useState)([]),[u,h]=(0,V.useState)(null),[f,p]=(0,V.useState)(""),[m,g]=(0,V.useState)(!1),[x,v]=(0,V.useState)(null),[y,b]=(0,V.useState)(null),w=x?.id??null;(0,V.useEffect)(()=>{if(!w)return;let r=!1;return aC.api.getSchedules(e).then(e=>{if(r)return;let s=e.filter(e=>e.source_session_id===w).length;b({sessionId:w,count:s})},()=>void 0),()=>{r=!0}},[e,w]);let _=y?.sessionId===w?y.count:0,[S,k]=(0,V.useState)(null),[j,C]=(0,V.useState)(0),N=(0,V.useCallback)(()=>C(e=>e+1),[]),[E,D]=(0,V.useState)(null),T=Mg(e,r);(0,V.useEffect)(()=>{let s=!1;return(0,aC.listBranchSessions)(e,r).then(n=>{s||(d(n.sessions),D(Mg(e,r)))}).catch(n=>{s||(console.error("[SessionHistoryDropdown] refresh failed:",n),D(Mg(e,r)))}),()=>{s=!0}},[e,r,n,j]);let R=(0,V.useRef)(null);(0,V.useEffect)(()=>{if(!s||E!==T)return;if(c.some(e=>e.id===s)){R.current=null;return}if(R.current===s)return;R.current=s;let n=!1;return(0,aC.listBranchSessions)(e,r).then(i=>{if(n)return;d(i.sessions),D(Mg(e,r));let o=i.sessions.find(e=>e.id===s),l=!!o&&(a?.sessionId===o.id||!!(o.title&&o.title.trim().length>0));o&&!l&&k(s)}).catch(e=>{n||console.error("[SessionHistoryDropdown] missing-session refresh failed:",e)}),()=>{n=!0}},[s,c,e,r,T,E,a]),(0,V.useEffect)(()=>{if(!S)return;let e=setTimeout(()=>{k(e=>e===S?null:e)},3e4);return()=>clearTimeout(e)},[S]),(0,V.useEffect)(()=>{if(!S)return;let e=setTimeout(()=>{k(e=>e===S?null:e)},3e4);return()=>clearTimeout(e)},[S]);let A=async(e,r)=>{let s=r.trim().length>0?r.trim():null;try{await (0,aC.renameSession)(e,s),d(r=>r.map(r=>r.id===e?{...r,title:s}:r)),h(null),xc.toast.success("Renamed")}catch(e){xc.toast.error("Rename failed"),console.error(e)}},M=async(e,r)=>{let s=null==r,n=s?Date.now():null;d(r=>r.map(r=>r.id===e?{...r,favorited_at:n}:r));try{await (0,aC.setSessionFavorited)(e,s)}catch(n){d(s=>s.map(s=>s.id===e?{...s,favorited_at:r}:s)),xc.toast.error(s?"Favorite failed":"Unfavorite failed"),console.error(n)}},I=async e=>{try{await (0,aC.deleteSession)(e);let r=c.filter(r=>r.id!==e);d(r),l?.(e,r),xc.toast.success("Deleted")}catch(e){xc.toast.error("Delete failed"),console.error(e)}},P=e=>a&&a.sessionId===e.id?a.title:e.title&&e.title.trim().length>0?e.title:e.updated_at?new Date(e.updated_at).toLocaleString():new Date(e.created_at).toLocaleString(),F=e=>{let r;return a?.sessionId!==e.id&&(!e.title||!(e.title.trim().length>0))&&(r=e.id,null!==i&&i===r||S===e.id)},L=c.find(e=>e.id===s),O=null!==s&&(!L||F(L)),B=L?P(L):null===s?"New Session":"History",z=O?"Generating title…":B;return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(i3,{open:m,onOpenChange:e=>{g(e),e&&N()},children:[(0,U.jsx)(jQ,{label:z,children:(0,U.jsx)(i4,{asChild:!0,children:(0,U.jsxs)(a$.Button,{variant:"ghost",size:"sm",className:"h-7 text-xs gap-1 w-[200px] justify-start",children:[O?(0,U.jsx)("span",{className:"block h-3 flex-1 rounded-sm bg-accent animate-pulse",role:"status","aria-label":"Generating title"}):(0,U.jsx)("span",{className:"truncate flex-1 text-left",children:B}),(0,U.jsx)(aa,{className:"h-3 w-3 flex-shrink-0"})]})})}),(0,U.jsxs)(i6,{align:"start",className:"w-80 max-h-96 overflow-y-auto",children:[0===c.length&&(0,U.jsx)("div",{className:"px-2 py-3 text-xs text-muted-foreground",children:"No history yet."}),c.map(e=>{let r=e.id===s,n=u===e.id;return(0,U.jsxs)(i7,{onSelect:s=>{n?s.preventDefault():r||o(e.id)},onPointerMove:null!==u?e=>e.preventDefault():void 0,className:`flex items-center gap-2 group ${r?"bg-accent text-accent-foreground":""}`,children:[(0,U.jsx)("div",{className:"flex-1 min-w-0",children:n?(0,U.jsxs)("div",{className:"flex items-center gap-1",children:[(0,U.jsx)(aX,{value:f,onChange:e=>p(e.target.value),onKeyDown:r=>{r.stopPropagation(),"Enter"===r.key&&A(e.id,f),"Escape"===r.key&&h(null)},autoFocus:!0,className:"h-6 text-xs"}),(0,U.jsx)("button",{type:"button","aria-label":"Save rename",onClick:r=>{r.stopPropagation(),A(e.id,f)},children:(0,U.jsx)(al.Check,{className:"h-3 w-3"})}),(0,U.jsx)("button",{type:"button","aria-label":"Cancel rename",onClick:e=>{e.stopPropagation(),h(null)},children:(0,U.jsx)(rD,{className:"h-3 w-3"})})]}):F(e)?(0,U.jsx)("div",{className:"py-0.5",title:"Generating title…",children:(0,U.jsx)("span",{className:"block h-3 w-40 rounded-sm bg-accent animate-pulse",role:"status","aria-label":"Generating title"})}):(0,U.jsx)("div",{className:"truncate text-xs",title:`${e.updated_at?new Date(e.updated_at).toLocaleString():new Date(e.created_at).toLocaleString()} • ${e.entry_count??0} messages • status: ${e.status} • model: ${e.model??"Default"}`,children:P(e)})}),!n&&(0,U.jsxs)("div",{className:"flex items-center gap-1",children:[(0,U.jsxs)("div",{className:"opacity-0 group-hover:opacity-100 flex items-center gap-1",children:[(0,U.jsx)("button",{type:"button","aria-label":"Rename conversation",onClick:r=>{r.stopPropagation(),h(e.id),p(e.title??"")},className:"p-1 hover:bg-muted rounded",children:(0,U.jsx)(lT,{className:"h-3 w-3"})}),(0,U.jsx)("button",{type:"button","aria-label":"Delete conversation",onClick:r=>{r.stopPropagation(),g(!1),v(e)},className:"p-1 hover:bg-muted rounded text-destructive",children:(0,U.jsx)(ok,{className:"h-3 w-3"})})]}),(0,U.jsx)("button",{type:"button","aria-label":null!=e.favorited_at?"Unfavorite conversation":"Favorite conversation",title:null!=e.favorited_at?"Unfavorite":"Favorite",onClick:r=>{r.stopPropagation(),M(e.id,e.favorited_at??null)},className:`p-1 hover:bg-muted rounded ${null!=e.favorited_at?"opacity-100 text-yellow-500":"opacity-0 group-hover:opacity-100 text-muted-foreground"}`,children:(0,U.jsx)(om,{className:`h-3 w-3 ${null!=e.favorited_at?"fill-current":""}`})})]})]},e.id)}),c.length>0&&(0,U.jsx)(ar,{}),(0,U.jsx)(i7,{onSelect:()=>N(),className:"text-xs text-muted-foreground",children:"Refresh"})]})]}),(0,U.jsx)(lJ,{open:null!==x,onOpenChange:e=>{e||v(null)},children:(0,U.jsxs)(l0,{children:[(0,U.jsxs)(l1,{children:[(0,U.jsx)(l5,{children:"Delete conversation?"}),(0,U.jsx)(l3,{children:x?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)("span",{className:"font-medium text-foreground",children:P(x)})," ","and its message history will be permanently deleted. This cannot be undone.",_>0&&(0,U.jsx)("span",{className:"mt-2 block",children:1===_?"1 scheduled task was created from this conversation. It keeps running, but will no longer link back here.":`${_} scheduled tasks were created from this conversation. They keep running, but will no longer link back here.`})]}):null})]}),(0,U.jsxs)(l2,{children:[(0,U.jsx)(l6,{children:"Cancel"}),(0,U.jsx)(l4,{className:(0,e1.cn)((0,a$.buttonVariants)({variant:"destructive"}),"border-transparent"),onClick:()=>{x&&I(x.id),v(null)},children:"Delete"})]})]})})]})}let Mv=[];function My(e,r={}){Mv.push({t:Math.round(performance.now()),ev:e,...r}),Mv.length>200&&Mv.shift()}function Mb({messageCount:e,turnInFlight:r,sessionId:s,firstEntryKey:n}){let{scrollToBottom:i,scrollRef:a,contentRef:o,state:l}=cJ(),{index:c}=jL(),d=c?.version??null,u=(0,V.useRef)({turnInFlight:r,settleDeadline:0,settleHardCap:0,prevScrollHeight:0,prevClientHeight:0,anchor:null});u.current.turnInFlight=r;let h=()=>{let e=performance.now();u.current.settleDeadline=e+600,u.current.settleHardCap=e+8e3},f=(0,V.useRef)(!0),p=(0,V.useRef)(d),m=(0,V.useRef)(s),g=(0,V.useRef)(n),x=(0,V.useRef)(e),v=(0,V.useRef)(s);return(0,V.useLayoutEffect)(()=>{let r=s!==m.current,n=f.current&&e>0;if(m.current=s,f.current=0===e,!n&&!(r&&e>0))return;h(),My(n?"fill":"session-switch",{sessionId:s,messageCount:e});let o=a.current;o&&(o.scrollTop=o.scrollHeight),i({animation:"instant"})},[e,s,i,a]),(0,V.useLayoutEffect)(()=>{d!==p.current&&(p.current=d,My("index-version",{version:d,messageCount:e}),e>0&&h())},[d,e]),(0,V.useLayoutEffect)(()=>{let r=g.current,i=x.current,o=v.current;if(g.current=n,x.current=e,v.current=s,o!==s||null===r||null===n||n===r||e<=i)return;let l=a.current,c=u.current.anchor;if(!l||!c?.el.isConnected)return;h();let d=u.current;l.scrollTop+d.prevClientHeight>=d.prevScrollHeight-6||(l.scrollTop=c.el.offsetTop-c.offset,d.prevScrollHeight=l.scrollHeight,d.prevClientHeight=l.clientHeight,My("prepend",{messageCount:e,prevCount:i,scrollTop:Math.round(l.scrollTop)}))},[n,e,s,a]),(0,V.useEffect)(()=>{let e=a.current,r=o.current;if(!e||!r||"undefined"==typeof ResizeObserver)return;u.current.prevScrollHeight=e.scrollHeight,u.current.prevClientHeight=e.clientHeight;let s=e.scrollTop,n=()=>{let r=e.scrollTop;Math.abs(r-s)>40&&My("scroll-jump",{from:Math.round(s),to:Math.round(r)}),s=r,i()},i=()=>{let s=e.scrollTop,n=null;for(let e of r.querySelectorAll("[data-message-idx]"))if(e.offsetTop+e.offsetHeight>s){n={el:e,offset:e.offsetTop-s};break}u.current.anchor=n};n(),e.addEventListener("scroll",n,{passive:!0});let c=r=>{r.target===e&&(l.lastScrollTop=function({lastScrollTop:e,scrollTop:r,maxScrollTop:s}){return void 0===e||e<=s?e:r>=s-1?r:s}({lastScrollTop:l.lastScrollTop,scrollTop:e.scrollTop,maxScrollTop:e.scrollHeight-e.clientHeight}))},d=e.parentElement;d?.addEventListener("scroll",c,{capture:!0,passive:!0});let f=new Map,p=new ResizeObserver(()=>{let s,n,a=u.current,o=a.prevScrollHeight,l=e.scrollHeight,c=a.prevClientHeight,d=e.clientHeight;a.prevScrollHeight=l,a.prevClientHeight=d;let p=Math.abs(l-o)>1;if(Math.abs(d-c)>1&&!p){let r=function({scrollTop:e,scrollHeight:r,prevClientHeight:s}){return e+s>=r-6}({scrollTop:e.scrollTop,scrollHeight:l,prevClientHeight:c});r&&(e.scrollTop=l),My("viewport-resize",{prevClient:c,client:d,scrollTop:Math.round(e.scrollTop),pinned:r});return}if(!p)return;let m=(s=u.current,(n=performance.now())<s.settleDeadline&&n<s.settleHardCap);m&&h();let g=e.scrollTop+c>=o-6,x=function({settling:e,turnInFlight:r,wasAtBottom:s}){return!!s&&(e||!r)}({settling:m,turnInFlight:a.turnInFlight,wasAtBottom:g}),v=a.anchor;x?e.scrollTop=l:!g&&m&&v?.el.isConnected?e.scrollTop=v.el.offsetTop-v.offset:m||i();let y=l-e.clientHeight-e.scrollTop;My("resize",{prev:o,next:l,clientH:e.clientHeight,scrollTop:Math.round(e.scrollTop),settling:m,turnInFlight:a.turnInFlight,wasAtBottom:g,action:x?"hold-bottom":"none",distAfter:Math.round(y),grew:(()=>{let e=[];for(let s of r.querySelectorAll("[data-message-idx]")){let r=s.getAttribute("data-message-idx")??"?",n=s.offsetHeight,i=f.get(r);void 0!==i&&Math.abs(i-n)>2&&e.push({idx:r,from:i,to:n}),f.set(r,n)}return e.sort((e,r)=>Math.abs(r.to-r.from)-Math.abs(e.to-e.from)),e.slice(0,4)})()}),g&&y>50&&!(a.turnInFlight&&!m)&&console.warn("[vdx-scroll] displaced while pinned — recent timeline:",Mv.slice(-30))});return p.observe(r),p.observe(e),()=>{p.disconnect(),e.removeEventListener("scroll",n),d?.removeEventListener("scroll",c,{capture:!0})}},[a,o,l]),null}window.__vdxScrollDiag={buf:Mv,dump:()=>console.table(Mv)};let Mw=(0,rE.default)("quote",[["path",{d:"M16 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z",key:"rib7q0"}],["path",{d:"M5 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z",key:"1ymkrd"}]]);function M_(e,r){let s=e;for(;s&&s!==r;){if(s.nodeType===Node.ELEMENT_NODE){let e=s.getAttribute("data-message-idx");if(null!==e)return e}s=s.parentNode}return null}function MS({containerRef:e,onQuote:r}){let[s,n]=(0,V.useState)(null);if((0,V.useEffect)(()=>{function r(){let r=e.current;if(!r)return void n(null);let s=window.getSelection();if(!s||s.isCollapsed||0===s.rangeCount)return void n(null);let i=s.toString();if(!i.trim())return void n(null);let{anchorNode:a,focusNode:o}=s;if(!a||!o||!r.contains(a)||!r.contains(o))return void n(null);let l=M_(a,r),c=M_(o,r);if(null===l||null===c||l!==c)return void n(null);let d=s.getRangeAt(0).getBoundingClientRect();0===d.width&&0===d.height?n(null):n({text:i,rect:{top:d.top,bottom:d.bottom,left:d.left,width:d.width}})}function s(){let e=window.getSelection();e&&!e.isCollapsed&&e.toString().trim()||n(null)}return document.addEventListener("mouseup",r),document.addEventListener("keyup",r),document.addEventListener("touchend",r),document.addEventListener("selectionchange",s),window.addEventListener("scroll",r,!0),window.addEventListener("resize",r),()=>{document.removeEventListener("mouseup",r),document.removeEventListener("keyup",r),document.removeEventListener("touchend",r),document.removeEventListener("selectionchange",s),window.removeEventListener("scroll",r,!0),window.removeEventListener("resize",r)}},[e]),!s||"undefined"==typeof document)return null;let i=s.rect.top-8-30<8?s.rect.bottom+8:s.rect.top-8-30,a=s.rect.left+s.rect.width/2,o=Math.max(8,Math.min(window.innerWidth-8,a));return(0,ep.createPortal)((0,U.jsxs)("button",{type:"button",onMouseDown:e=>{e.preventDefault(),r(s.text),window.getSelection()?.removeAllRanges(),n(null)},style:{position:"fixed",top:i,left:o,transform:"translateX(-50%)",zIndex:50},className:"inline-flex items-center gap-1.5 rounded-md border border-border bg-popover px-3 py-1.5 text-xs font-medium text-popover-foreground shadow-2xl hover:bg-accent",children:[(0,U.jsx)(Mw,{className:"h-3 w-3"}),"Quote"]}),document.body)}let Mk=(0,rE.default)("search-check",[["path",{d:"m8 11 2 2 4-4",key:"1sed1v"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]);function Mj(e){let[r,s]=(0,V.useState)({enabled:e,result:null});r.enabled!==e&&s({enabled:e,result:null});let n=r.enabled===e?r.result:null;return(0,V.useEffect)(()=>{if(!e)return;let r=!0;return(0,aC.getAgentProviders)().then(e=>{r&&s({enabled:!0,result:{providers:e,error:null}})}).catch(()=>{r&&s({enabled:!0,result:{providers:[],error:"Failed to load agent providers"}})}),()=>{r=!1}},[e]),{providers:n?.providers??[],error:n?.error??null,loading:e&&null===n}}function MC(e){let r=Math.round(Number(e));return Number.isFinite(r)?Math.min(aC.REVIEW_LOOP_MAX_ROUNDS,Math.max(1,r)):aC.REVIEW_LOOP_DEFAULT_ROUNDS}let MN=()=>()=>{};function ME({tone:e,children:r}){return(0,U.jsx)("span",{className:(0,e1.cn)("rounded-full border px-1.5 py-px font-mono text-[9.5px] leading-[1.5] font-medium","rec"===e?"border-primary/25 bg-accent text-accent-foreground":"border-amber-500/35 bg-amber-500/10 text-amber-700 dark:text-amber-300"),children:r})}function MD({selected:e,title:r,meta:s,trailing:n,onSelect:i}){return(0,U.jsxs)("button",{type:"button",role:"radio","aria-checked":e,onClick:i,className:(0,e1.cn)("flex min-w-0 items-start gap-2.5 rounded-lg border px-2.5 py-2 text-left transition-colors",e?"border-primary bg-accent ring-[3px] ring-accent":"bg-card opacity-75 hover:bg-muted hover:opacity-100"),children:[(0,U.jsx)("span",{className:(0,e1.cn)("mt-[3px] grid size-3.5 shrink-0 place-items-center rounded-full border",e?"border-primary bg-primary":"border-input bg-card"),children:e&&(0,U.jsx)("span",{className:"size-[5px] rounded-full bg-primary-foreground"})}),(0,U.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,U.jsxs)("span",{className:"flex min-w-0 items-center gap-2 text-[12.5px] font-medium",children:[(0,U.jsx)("span",{className:"flex shrink-0 flex-wrap items-center gap-2",children:r}),n&&(0,U.jsx)("span",{className:"ml-auto flex min-w-0 items-center gap-1.5 font-mono text-[10.5px] font-normal text-muted-foreground",children:n})]}),s&&(0,U.jsx)("span",{className:"mt-0.5 flex flex-wrap items-center gap-2 font-mono text-[10.5px] text-muted-foreground",children:s})]})]})}function MT({children:e,note:r}){return(0,U.jsxs)("div",{className:"flex items-center gap-2",children:[(0,U.jsx)("span",{className:"text-[10px] font-semibold tracking-[0.07em] text-muted-foreground/80 uppercase",children:e}),(0,U.jsx)("span",{className:"flex-1"}),r&&(0,U.jsx)("span",{className:"text-[10.5px] text-muted-foreground/80",children:r})]})}function MR({projectId:e,branch:r,sessionId:s,currentAgentType:n,providers:i,shortcutEnabled:a=!1,onStarted:o}){var l;let c=(0,V.useSyncExternalStore)(MN,X,()=>!1),[d,u]=(0,V.useState)(!1),[h,f]=(0,V.useState)(""),[p,m]=(0,V.useState)(null),[g,x]=(0,V.useState)("this_turn"),[v,y]=(0,V.useState)("briefed"),[b,w]=(0,V.useState)(!1),[_,S]=(0,V.useState)(String(aC.REVIEW_LOOP_DEFAULT_ROUNDS)),[k,j]=(0,V.useState)(null),[C,N]=(0,V.useState)(null),[E,D]=(0,V.useState)(!1),[T,R]=(0,V.useState)(null),[A,M]=(0,V.useState)(!1),I=(0,V.useRef)(null),P=(0,V.useRef)(null),F=(0,V.useSyncExternalStore)(AN,()=>AE(e,r,s),()=>void 0),L=!1===F,O=s?`${e}\u0000${s}`:null,B=C?.key===O?C:null,z=k?.key===O?k.mode:null,$=B?.candidate??null,W=B?.notice??null,H=null!==B||L,q=d&&null!==O&&!H,K=Mj(d&&!i?.length),G=i?.length?i:K.providers,J=p&&G.some(e=>e.type===p)?p:(l=n??null,G.find(e=>e.type!==l)?.type??G[0]?.type??Ep),Z=G.some(e=>e.type===J);if((0,V.useEffect)(()=>{d&&(m(null),x("this_turn"),y("briefed"))},[d]),(0,V.useEffect)(()=>{if(!d||!s)return;let n=`${e}\u0000${s}`;if(L){P.current=null;return}let i=!1,a=aC.api.getReviewerCandidate(e,s);return P.current={projectId:e,sessionId:s,result:a},a.then(a=>{if(i)return;let o=!!(a?.available&&a.sessionId),l=null!==a||!0===AE(e,r,s);N({key:n,candidate:a,notice:!o&&l?"The last reviewer is no longer available — a new session will be created.":null})}).catch(()=>{i||N({key:n,candidate:null,notice:"Could not load the last reviewer — a new session will be created."})}),()=>{i=!0}},[d,e,r,s,L]),(0,V.useEffect)(()=>{if(!d){I.current=null;return}if(!s)return;let r=I.current;if(r&&r.projectId===e&&r.sessionId===s)return;M(!1);let n=aC.api.generateReviewIntentBrief(e,s).then(e=>({reached:!0,brief:e})).catch(()=>({reached:!1,brief:null}));I.current={projectId:e,sessionId:s,result:n},n.then(()=>{I.current?.result===n&&M(!0)})},[d,e,s]),(0,V.useEffect)(()=>{if(!s||!a)return;let e=e=>{ee(e,Y)&&(e.preventDefault(),u(!0))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[s,a]),!s)return null;let Q=e=>{u(e),e||(j(null),N(null),R(null))},er=async()=>{if(!ec){D(!0),R(null);try{let n=$;if("reuse"===ei&&!H&&O){let r=P.current;n=r?.projectId===e&&r?.sessionId===s?await r.result.catch(()=>null):null,N({key:O,candidate:n,notice:null})}if("reuse"===ei&&!(n?.available&&n.sessionId)){O&&N({key:O,candidate:n,notice:"The last reviewer is no longer available — a new session will be created."}),j(O?{key:O,mode:"new"}:null);return}if(!("reuse"===ei&&n?.sessionId)&&!Z)throw Error("No available agent providers");let i="reuse"===ei&&n?.sessionId?{reviewerSessionId:n.sessionId}:{reviewerAgentType:J},a="blind"===v&&"reviewerAgentType"in i,l=I.current,c=!a&&"reviewerAgentType"in i&&l?.projectId===e&&l?.sessionId===s?l:null,d=c&&A?await c.result:null,u=d?.reached?{intentBrief:d.brief??""}:{},p=await aC.api.createWorkflowRun({projectId:e,branch:r,sourceSessionId:s,reviewFocus:h.trim()||void 0,reviewSpan:g,...a?{reviewContextMode:"blind"}:{},...b?{loop:{maxRounds:MC(_)}}:{},...i,...u});b&&!p.loop_id&&xc.toast.info("This machine's worker doesn't support review loops yet — started a single-pass review."),Q(!1),f(""),o?.(p)}catch(r){R(r instanceof Error?r.message:String(r)),aC.api.getReviewerCandidate(e,s).then(r=>{let n=!r?.available||!r.sessionId;N({key:`${e}\u0000${s}`,candidate:r,notice:n?"The last reviewer is no longer available — a new session will be created.":null}),n&&j(O?{key:O,mode:"new"}:null)}).catch(()=>void 0)}finally{D(!1)}}},es=!!($?.available&&$.sessionId),en=H?es:!0===F,ei=en?z??"reuse":"new",ea="reuse"===ei,eo=ea?"briefed":v,el=e=>e?Eg(e,G).displayName:"—",ec=E||!ea&&!Z||q&&void 0===F,ed=E?{Icon:h$,text:"Setup continues in the background"}:ea?{Icon:h$,text:"Reuses context — no re-distillation"}:"blind"===v?{Icon:h$,text:b?"Blind applies to round 1 — later rounds see the author's replies":"Blind review — no conversation context is sent"}:A?{Icon:l9.Clock,text:"Intent summary ready"}:{Icon:l9.Clock,text:"Intent summary finishes in the background"};return(0,U.jsxs)(rT,{open:d,onOpenChange:Q,children:[(0,U.jsx)(jQ,{label:`Ask another agent to review this session's latest work (${et(c,Y)})`,children:(0,U.jsx)(rR,{asChild:!0,children:(0,U.jsx)(a$.Button,{variant:"ghost",size:"sm","aria-label":"Review this session",children:(0,U.jsx)(Mk,{className:"h-4 w-4"})})})}),(0,U.jsxs)(rP,{showCloseButton:!1,className:"bg-card w-[calc(100%-2rem)] min-w-0 gap-0 overflow-hidden p-0 sm:w-full sm:max-w-md",onKeyDown:e=>{"Enter"===e.key&&(e.metaKey||e.ctrlKey)&&!ec&&(e.preventDefault(),er())},children:[(0,U.jsxs)("div",{className:"flex items-start gap-3 border-b bg-secondary px-4 py-3.5",children:[(0,U.jsx)("span",{className:"grid size-7 shrink-0 place-items-center rounded-lg border border-primary/20 bg-accent text-accent-foreground",children:(0,U.jsx)(Mk,{className:"size-[15px]"})}),(0,U.jsxs)("div",{className:"min-w-0",children:[(0,U.jsx)(rO,{className:"text-[14.5px] font-semibold tracking-tight",children:"Start Review"}),(0,U.jsx)(rB,{className:"mt-0.5 max-w-[40ch] text-[11.5px] leading-snug",children:"Another agent reviews this session’s latest work; you confirm the feedback before it returns here."})]}),(0,U.jsxs)(rM,{className:"ml-auto grid size-6 shrink-0 place-items-center rounded-md border border-transparent text-muted-foreground/70 transition-colors hover:border-border hover:bg-muted hover:text-foreground",children:[(0,U.jsx)(rD,{className:"size-3.5"}),(0,U.jsx)("span",{className:"sr-only",children:"Close"})]})]}),(0,U.jsxs)("div",{className:"min-w-0 flex flex-col gap-3.5 px-4 pt-3.5 pb-1",children:[W&&(0,U.jsxs)("div",{className:"flex items-start gap-2 rounded-lg border border-amber-500/30 bg-amber-500/10 px-2.5 py-2 text-[11.5px] text-amber-700 dark:text-amber-300",children:[(0,U.jsx)(ou,{className:"mt-px size-3.5 shrink-0"}),(0,U.jsx)("span",{children:W})]}),(0,U.jsxs)("div",{className:"min-w-0 flex flex-col gap-1.5",children:[(0,U.jsx)(MT,{note:q?"Checking last reviewer…":en?"Last reviewer still available":void 0,children:"Reviewer"}),(0,U.jsxs)("div",{className:"grid gap-2",role:"radiogroup","aria-label":"Reviewer",children:[en&&(0,U.jsx)(MD,{selected:ea,onSelect:()=>O&&j({key:O,mode:"reuse"}),title:"Continue last reviewer",trailing:H&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)("span",{className:"shrink-0",children:el($?.agentType)}),"number"==typeof $?.lastActiveAt&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)("span",{className:"shrink-0 text-muted-foreground/60",children:"·"}),(0,U.jsx)("span",{className:"shrink-0",children:function(e){let r=Math.max(0,Math.round((Date.now()-e)/1e3));if(r<60)return"just now";let s=Math.round(r/60);if(s<60)return`${s}m ago`;let n=Math.round(s/60);return n<24?`${n}h ago`:`${Math.round(n/24)}d ago`}($.lastActiveAt)})]})]}),meta:H?(0,U.jsx)("span",{className:"min-w-0 truncate",children:$?.title??"Review session"}):(0,U.jsx)("span",{className:"text-muted-foreground/60",children:"Loading details…"})}),(0,U.jsx)(MD,{selected:!ea,onSelect:()=>O&&j({key:O,mode:"new"}),title:(0,U.jsxs)(U.Fragment,{children:["New reviewer session",W&&(0,U.jsx)(ME,{tone:"warn",children:"Only option"})]}),meta:en?"Starts fresh, without the last context":"Independent second opinion, from zero context"})]}),(0,U.jsxs)("div",{className:"mt-0.5 min-w-0 flex flex-col gap-2",children:[(0,U.jsxs)("div",{className:"min-w-0 flex items-center gap-2.5",children:[(0,U.jsx)("span",{className:"w-[92px] shrink-0 text-[11.5px] text-muted-foreground",children:"Agent"}),ea?(0,U.jsxs)("span",{className:"flex h-8 flex-1 items-center gap-2 rounded-md border bg-secondary px-2.5 text-xs text-muted-foreground",children:[(0,U.jsx)("span",{className:"truncate",children:H?el($?.agentType):"Loading…"}),(0,U.jsx)("span",{className:"flex-1"}),(0,U.jsx)("span",{className:"font-mono text-[10px] text-muted-foreground/70",children:"same as last reviewer"}),(0,U.jsx)(xs,{className:"size-3 shrink-0"})]}):(0,U.jsxs)(fP,{value:J,onValueChange:e=>m(e),children:[(0,U.jsxs)(fL,{size:"sm",className:"min-w-0 flex-1 text-xs",children:[(0,U.jsx)(fF,{}),(0,U.jsx)("span",{className:"ml-auto font-mono text-[10px] text-muted-foreground/70",children:J===n?"same as current agent":"differs from current agent"})]}),(0,U.jsx)(fO,{children:G.map(e=>(0,U.jsxs)(fB,{value:e.type,children:[e.displayName,e.type===n?" (current agent)":""]},e.type))})]})]}),(0,U.jsxs)("div",{className:"min-w-0 flex items-center gap-2.5",children:[(0,U.jsx)("span",{className:"w-[92px] shrink-0 text-[11.5px] text-muted-foreground",children:"Scope"}),(0,U.jsx)("div",{className:"min-w-0 flex h-8 flex-1 items-center gap-0.5 rounded-lg border bg-secondary p-0.5",children:[["this_turn","This turn only"],["session_start","Whole session"]].map(([e,r])=>(0,U.jsx)("button",{type:"button","aria-pressed":g===e,onClick:()=>x(e),className:(0,e1.cn)("h-full flex-1 rounded-md px-2 text-[11.5px] whitespace-nowrap transition-colors",g===e?"border bg-card font-medium text-foreground shadow-sm":"border border-transparent text-muted-foreground hover:text-foreground"),children:r},e))})]}),(0,U.jsxs)("div",{className:"min-w-0 flex items-center gap-2.5",children:[(0,U.jsx)("span",{className:"w-[92px] shrink-0 text-[11.5px] text-muted-foreground",children:"Context"}),(0,U.jsx)("div",{className:"min-w-0 flex h-8 flex-1 items-center gap-0.5 rounded-lg border bg-secondary p-0.5",children:[["briefed","With context"],["blind","Blind"]].map(([e,r])=>(0,U.jsx)("button",{type:"button",disabled:ea,"aria-pressed":eo===e,onClick:()=>y(e),className:(0,e1.cn)("h-full min-w-0 flex-1 rounded-md px-2 text-[11.5px] whitespace-nowrap transition-colors disabled:cursor-not-allowed",eo===e?"border bg-card font-medium text-foreground shadow-sm disabled:text-muted-foreground":"border border-transparent text-muted-foreground hover:text-foreground disabled:opacity-45"),children:r},e))})]}),(0,U.jsxs)("div",{className:"min-w-0 flex items-center gap-2.5",children:[(0,U.jsx)("span",{className:"w-[92px] shrink-0 text-[11.5px] text-muted-foreground",children:"Rounds"}),(0,U.jsx)("div",{className:"min-w-0 flex h-8 flex-1 items-center gap-0.5 rounded-lg border bg-secondary p-0.5",children:[[!1,"Single pass","One review. You decide what to send back."],[!0,"Auto loop","Sends feedback and re-reviews on its own until ship. The last round waits for you."]].map(([e,r,s])=>{let n=(0,U.jsx)("button",{type:"button","aria-pressed":b===e,onClick:()=>w(e),className:(0,e1.cn)("h-full min-w-0 flex-1 rounded-md px-2 text-[11.5px] whitespace-nowrap transition-colors",b===e?"border bg-card font-medium text-foreground shadow-sm":"border border-transparent text-muted-foreground hover:text-foreground"),children:r});return(0,U.jsx)(cI,{delayDuration:300,children:(0,U.jsxs)(cP,{children:[(0,U.jsx)(cF,{asChild:!0,children:n}),(0,U.jsx)(cL,{className:"max-w-64",children:s})]})},r)})}),(0,U.jsxs)("label",{className:(0,e1.cn)("flex shrink-0 items-center gap-1.5 text-[11.5px] text-muted-foreground",!b&&"opacity-45"),children:["up to",(0,U.jsx)("input",{type:"number",min:1,max:aC.REVIEW_LOOP_MAX_ROUNDS,"aria-label":"Maximum review rounds",disabled:!b,value:_,onChange:e=>S(e.target.value),onBlur:()=>S(String(MC(_))),className:"h-7 w-11 rounded-md border bg-card px-1.5 text-center text-[11.5px] text-foreground outline-none disabled:cursor-not-allowed"})]})]})]})]}),(0,U.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,U.jsx)(MT,{note:"Optional",children:"Review focus"}),(0,U.jsx)("div",{className:"focus-within:border-ring focus-within:ring-ring/40 flex h-[34px] items-center overflow-hidden rounded-lg border bg-card px-3 transition-[color,box-shadow] focus-within:ring-[3px]",children:(0,U.jsx)("input",{className:"min-w-0 flex-1 bg-transparent text-[12.5px] outline-none placeholder:text-muted-foreground/70",placeholder:"What to focus on, e.g. is the lock granularity too coarse…",value:h,onChange:e=>f(e.target.value)})})]}),K.loading&&!ea&&(0,U.jsx)("p",{role:"status",className:"text-xs text-muted-foreground",children:"Loading agent providers…"}),(T||K.error||!K.loading&&!ea&&!Z)&&(0,U.jsxs)("div",{className:"border-destructive/30 bg-destructive/10 text-destructive flex items-start gap-2 rounded-lg border px-2.5 py-2 text-[11.5px]",children:[(0,U.jsx)(ou,{className:"mt-px size-3.5 shrink-0"}),(0,U.jsx)("span",{className:"min-w-0",children:T||K.error||"No available agent providers"})]})]}),(0,U.jsxs)("div",{className:"mt-2.5 min-w-0 flex w-full items-center gap-2.5 overflow-hidden border-t bg-secondary px-4 py-2.5",children:[(0,U.jsxs)("span",{className:"flex min-w-0 flex-1 items-center gap-1.5 overflow-hidden text-[11px] text-muted-foreground",children:[(0,U.jsx)(ed.Icon,{className:"size-3 shrink-0 text-muted-foreground/70"}),(0,U.jsx)("span",{className:"truncate",children:ed.text})]}),(0,U.jsx)(rM,{asChild:!0,children:(0,U.jsx)(a$.Button,{variant:"outline",size:"sm",className:"h-7 text-xs",children:"Cancel"})}),(0,U.jsx)(a$.Button,{size:"sm",className:"h-7 w-28 gap-1.5 text-xs","aria-label":"Start",onClick:er,disabled:ec,children:E?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(aP,{className:"size-3 animate-spin"}),"Starting…"]}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(aV,{className:"size-3"}),"Start",(0,U.jsx)("kbd",{className:"rounded border border-background/30 bg-background/15 px-1 font-mono text-[10px] leading-[1.4] text-background/90",title:c?"Command+Enter":"Ctrl+Enter",children:c?"⌘⏎":"Ctrl⏎"})]})})]})]})]})}function MA({phase:e="distilling",children:r}){return(0,U.jsxs)("div",{className:"text-center py-16",children:[(0,U.jsx)(Aw,{className:"h-6 w-6 mx-auto mb-4"}),(0,U.jsx)("h3",{className:"text-sm font-semibold mb-1 text-foreground",children:"Preparing review…"}),(0,U.jsx)("p",{className:"text-xs text-muted-foreground leading-relaxed",children:"starting"===e?"The reviewer is starting. This view switches to the review conversation as soon as it is ready.":"Summarizing the source conversation and briefing the reviewer. The review will start here automatically — you can leave this window in the meantime."}),r]})}function MM({error:e,title:r="Review setup failed",children:s}){return(0,U.jsxs)("div",{className:"text-center py-16",children:[(0,U.jsx)("div",{className:"mx-auto w-12 h-12 rounded-xl bg-destructive/10 flex items-center justify-center mb-4",children:(0,U.jsx)(aR,{className:"h-6 w-6 text-destructive/70"})}),(0,U.jsx)("h3",{className:"text-sm font-semibold mb-1 text-foreground",children:r}),(0,U.jsx)("p",{className:"text-xs text-muted-foreground leading-relaxed",children:e??"The reviewer could not be started."}),s]})}function MI({status:e,children:r}){let s="completed"===e?os:xL;return(0,U.jsxs)("div",{className:"text-center py-16",children:[(0,U.jsx)("div",{className:"mx-auto w-12 h-12 rounded-xl bg-muted flex items-center justify-center mb-4",children:(0,U.jsx)(s,{className:"h-6 w-6 text-muted-foreground"})}),(0,U.jsx)("h3",{className:"text-sm font-semibold mb-1 text-foreground",children:"completed"===e?"Review completed":"cancelled"===e?"Review cancelled":"Review no longer available"}),(0,U.jsx)("p",{className:"text-xs text-muted-foreground leading-relaxed",children:"completed"===e?"The reviewer finished before this view could open it.":"cancelled"===e?"The review was ended before the reviewer started.":"The server no longer has this review run."}),r]})}let MP=[137,80,78,71,13,10,26,10],MF=[71,73,70,56],ML=[82,73,70,70],MO=[87,69,66,80];function MB(e,r,s=0){if(e.length<s+r.length)return!1;for(let n=0;n<r.length;n++)if(e[s+n]!==r[n])return!1;return!0}function Mz({uploads:e,workspaceKey:r,apiRef:s}){let n=An(),i=n.files,{track:a}=e,{clear:o,detach:l,restore:c}=n;(0,V.useEffect)(()=>(s.current={detach:l,restore:c},()=>{s.current=null}),[s,l,c]);let d=(0,V.useRef)(r);return((0,V.useEffect)(()=>{d.current!==r&&(d.current=r,o())},[r,o]),(0,V.useEffect)(()=>{a(i)},[i,a]),0===i.length)?null:(0,U.jsx)(Ad,{className:"pt-3 pb-0 pl-12 pr-2",children:(0,U.jsx)(Aa,{className:"p-0",children:r=>(0,U.jsx)(Ai,{data:r,status:e.statusOf(r.id),onRetry:()=>e.retry(r)})})})}let M$=(0,V.createContext)(null);function MW(){let e=(0,V.useContext)(M$);if(!e)throw Error("useAgentConversation must be used within AgentConversationContext");return e}function MH(){return(0,V.useContext)(M$)}let MU=/\[📎 paste #(\d+) \([^)]+\)\]/g;function MV(e){return"system"===e.type||"error"===e.type}function Mq(e,r){return`[📎 paste #${e} (${function(e){if(e<1024)return`${e}B`;let r=e/1024;return r<10?`${r.toFixed(1)}KB`:`${Math.round(r)}KB`}(r)})]`}let MK=(0,V.forwardRef)(function({projectId:e,branch:r,sessionId:s,navPending:n,setSessionUrlParam:i,project:a,onAgentModeChange:o,onTaskCompleted:l,onSessionStarted:c,onSessionTitleUpdated:d,onSessionSelected:u,onStatusChange:h,onNewConversation:f,onActiveSessionChange:p,onActiveSessionResultAtChange:m,onActiveSessionTurnEndAtChange:g,onOpenSchedule:x,onOpenTask:v,preparingReviews:y,onReviewStarted:b,onViewPreparingReview:w,taskSessionRequest:_,onTaskSessionRequestHandled:S},k){var j;let C,N,E,D,[T,R]=function(e,r){let s=e?`vibedeckx:agent-draft:${e}:${r??""}`:null,[n,i]=(0,V.useState)(()=>Mf(s)),[a,o]=(0,V.useState)(s);return a!==s&&(o(s),i(Mf(s))),[n,(0,V.useCallback)(e=>{i(e);if(s)try{e?window.localStorage.setItem(s,e):window.localStorage.removeItem(s)}catch{}},[s])]}(e,r),[A,M]=(0,V.useState)([]),[I,P]=(0,V.useState)(1),[F,L]=(0,V.useState)("edit"),[O,B]=(0,V.useState)(!1),[z,$]=(0,V.useState)(!1),[W,H]=(0,V.useState)(!1),q=(0,V.useRef)(null),[K,X]=(0,V.useState)(Ep),[Y,J]=(0,V.useState)([]),[Z,Q]=(0,V.useState)(null),[et,er]=(0,V.useState)(0),[es,en]=(0,V.useState)(null),[ei,ea]=(0,V.useState)(null),eo=(0,V.useRef)(null),el=(0,V.useCallback)(e=>{if("ArrowUp"!==e.key&&"ArrowDown"!==e.key||!e.shiftKey||e.ctrlKey||e.metaKey||e.altKey)return;let r=eo.current;if(!r)return;let s=Mp(r);if(!s)return;let n=s.getBoundingClientRect(),i=s.scrollTop,a="ArrowUp"===e.key,o=null,l=a?-1/0:1/0;r.querySelectorAll("[data-user-msg-idx]").forEach(e=>{let r=e.getBoundingClientRect().top-n.top+s.scrollTop;a?r<i-12&&r>l&&(l=r,o=e):r>i+12&&r<l&&(l=r,o=e)}),o&&(e.preventDefault(),o.scrollIntoView({block:"start",behavior:"smooth"}))},[eo]),ec=(0,V.useRef)(null),ed=function(e,r,s){let n=r&&s?`vibedeckx:agent-input-history:${r}:${s}`:null,i=(0,V.useRef)(Mu(n)),a=(0,V.useRef)(-1),o=(0,V.useRef)(""),[l,c]=(0,V.useState)(n);return l!==n&&(c(n),i.current=Mu(n),a.current=-1,o.current=""),{push:(0,V.useCallback)(e=>{let r=e.trim();if(!r)return;let s=i.current;if(s.length>0&&s[s.length-1]===r){a.current=-1;return}s.push(r),s.length>50&&s.shift(),a.current=-1;if(n)try{0===s.length?window.localStorage.removeItem(n):window.localStorage.setItem(n,JSON.stringify(s))}catch{}},[n]),handleKeyDown:(0,V.useCallback)(r=>{let s=r.currentTarget,n=i.current;if(0!==n.length)if("ArrowUp"===r.key){if(0!==s.selectionStart||0!==s.selectionEnd)return;if(r.preventDefault(),-1===a.current)o.current=s.value,a.current=n.length-1;else{if(!(a.current>0))return;a.current--}e(n[a.current])}else if("ArrowDown"===r.key){if(-1===a.current)return;let i=s.value.length;if(s.selectionStart!==i||s.selectionEnd!==i)return;r.preventDefault(),a.current<n.length-1?(a.current++,e(n[a.current])):(a.current=-1,e(o.current))}else -1!==a.current&&(a.current=-1)},[e])}}(R,e,r),{remotes:eu}=xl(),eh=[];for(let e of(a?.path&&eh.push({id:"local",label:"Local",icon:hW}),eu))eh.push({id:e.remote_server_id,label:e.server_name,icon:az(e)});let ef=a?.agent_mode??"local",ep=eh.find(e=>e.id===ef)?.label??("local"===ef?"Local":ef),em=(0,V.useRef)(null);em.current=ET(e,r,ef,s);let eg=(0,V.useCallback)(e=>{let r=em.current;return null!==r&&ER(e,r)},[]),ex=(0,V.useCallback)(e=>{let r=em.current;return null!==r&&e.projectId===r.projectId&&e.branch===r.branch},[]),{session:ev,messages:ey,status:eb,isConnected:ew,isInitialized:e_,isLoading:eS,isCachePreview:ek,error:ej,remoteStatus:eC,workflowRunUpdate:eN,backgroundTasks:eE,streamEpoch:eD,streamFinished:eT,messageEntryIndices:eR,hasEarlierHistory:eA,isLoadingEarlier:eM,loadEarlierHistory:eI,sendMessage:eP,sendEnsuredMessage:eF,discardEnsuredSessionIfEmpty:eL,startConversation:eO,prepareConversation:eB,activateConversation:ez,cancelPreparedConversation:e$,uploadPaste:eW,uploadAttachment:eH,stopSession:eU,switchAgentType:eV,setModel:eq,startNewConversation:eK,ensureSession:eX,switchMode:eY,acceptPlan:eG,residentLimitPrompt:eJ}=function(e,r,s,n,i){let a=i?.sessionId??null,o=i?.suspended??!1,[l,c]=(0,V.useState)(null),[d,u]=(0,V.useState)([]),[h,f]=(0,V.useState)("stopped"),[p,m]=(0,V.useState)(!1),[g,x]=(0,V.useState)(!1),[v,y]=(0,V.useState)(!1),[b,w]=(0,V.useState)(!1),[_,S]=(0,V.useState)(null),[k,j]=(0,V.useState)(null),[C,N]=(0,V.useState)(null),[E,D]=(0,V.useState)({tasks:[],turnParked:!1,parkDeadlineAt:null,canStopTasks:!1}),[T,R]=(0,V.useState)(0),[A,M]=(0,V.useState)(null),I=(0,V.useRef)(null),P=(0,V.useRef)(null),F=(0,V.useRef)(null),L=(0,V.useRef)(new WeakSet),O=(0,V.useRef)(()=>{}),B=(0,V.useRef)(()=>{}),z=(0,V.useRef)(()=>{}),$=(0,V.useRef)(null),W=(0,V.useRef)(0),H=(0,V.useRef)(0),U=(0,V.useRef)(0),q=(0,V.useRef)(null),K=(0,V.useRef)({sessionId:null,entries:{},status:"stopped"}),X=(0,V.useRef)(null),[Y,G]=(0,V.useState)(!1),[J,Z]=(0,V.useState)(!1),Q=(0,V.useRef)(null),ee=(0,V.useRef)(!1),et=(0,V.useRef)(!0),er=(0,V.useRef)(null),es=(0,V.useRef)(null),en=(0,V.useRef)(0),ei=(0,V.useRef)(!1),ea=(0,V.useRef)(null),eo=(0,V.useRef)(0),el=(0,V.useRef)(!1),ec=(0,V.useRef)(!1),ed=(0,V.useRef)(!1),eu=(0,V.useRef)(o),eh=(0,V.useRef)(Promise.resolve()),ef=(0,V.useRef)(i?.onTaskCompleted),ep=(0,V.useRef)(i?.onSessionStarted),em=(0,V.useRef)(i?.onTitleUpdated),eg=(0,V.useRef)(e),ex=(0,V.useRef)(r),ev=(0,V.useRef)(a),ey=(0,V.useRef)(ET(e,r,s,a));ey.current=ET(e,r,s,a),(0,V.useEffect)(()=>{ef.current=i?.onTaskCompleted,ep.current=i?.onSessionStarted,em.current=i?.onTitleUpdated,eg.current=e,ex.current=r,ev.current=a,Q.current=l,eu.current=o}),(0,aF.useGlobalEventStream)(e=>{if("notification:created"!==e.type)return;let r=e.notification,s=r?.session_id;if(!s||"session_result_ready"!==r.kind&&"session_failed"!==r.kind)return;let n=[...EU.entries()].filter(([,e])=>e.session.id===s);0!==n.length&&E0(s).then(e=>{for(let[r,s]of n)EX(r,{session:e.session??{...s.session,status:e.status},history:e})}).catch(e=>console.warn(`[AgentSession] completion prefetch failed for ${s}:`,e))});let eb=(0,V.useCallback)(()=>{ea.current&&(clearTimeout(ea.current),ea.current=null)},[]),ew=(0,V.useCallback)(e=>{ea.current&&clearTimeout(ea.current),ea.current=setTimeout(()=>{ea.current=null,e.readyState===WebSocket.OPEN&&(console.warn(`[AgentSession] No frames for 95000ms — assuming dead socket, forcing reconnect`),z.current(e))},95e3)},[]),e_=e=>{let r=Math.min(3e4,1e3*Math.pow(2,e)),s=r*Math.random()*.25;return r+s},eS=(0,V.useCallback)((e,r=!1)=>{F.current=e,I.current&&P.current!==e&&(console.log(`[AgentSession] Retiring WS for ${P.current}, claiming ${e}`),I.current.close(1e3,"session-switch"),I.current=null,P.current=null),Promise.race([(0,aC.getFreshToken)(r?{skipCache:!0}:void 0),new Promise(e=>setTimeout(e,5e3))]).catch(()=>void 0).then(()=>{if(F.current!==e)return void console.log(`[AgentSession] Dropping stale connect for ${e} (now ${F.current})`);if(!(0,aC.hasUsableStreamToken)()){let r=e_(Math.min(H.current,4));H.current++,console.log(`[AgentSession] No usable auth token (network?) — retrying connect in ${Math.round(r)}ms`),$.current&&clearTimeout($.current),$.current=setTimeout(()=>{$.current=null,F.current!==e||ee.current||B.current(e,!0)},r);return}H.current=0,O.current(e)})},[]),ek=(0,V.useCallback)(e=>{let r=()=>{let e=eg.current;if(!e)return;let r=ex.current;EU.delete(Eq(e,r,ev.current));let s=P.current;s&&EU.delete(Eq(e,r,s)),EU.delete(Eq(e,r,null))},s=()=>{let r=eg.current,s=Q.current;if(!r||!s||s.id!==e)return;let n=s.status===K.current.status?s:{...s,status:K.current.status};Q.current=n;let i=X.current;if(!i)return;let a=E5(K.current),o=a.at(-1)?.entryIndex??null,l=[...a].reverse().find(e=>"turn_end"===e.message.type)?.entryIndex??i.lastTurnEndEntryIndex,c={...i,status:K.current.status,latestEntryIndex:o,lastTurnEndEntryIndex:l,entries:a};X.current=c,EY(r,ex.current,ev.current,n,c)};if(I.current&&P.current!==e&&(console.log(`[AgentSession] Closing stale WS for ${P.current}, switching to ${e}`),I.current.close(1e3,"session-switch"),I.current=null,P.current=null),I.current?.readyState===WebSocket.OPEN||I.current?.readyState===WebSocket.CONNECTING)return;K.current.sessionId!==e&&(K.current={sessionId:e,entries:{},status:"running"}),ee.current=!1,ei.current=!0;let n=X.current,i=new URLSearchParams;n?.lastTurnEndEntryIndex!==null&&n?.lastTurnEndEntryIndex!==void 0&&(i.set("after",String(n.lastTurnEndEntryIndex)),i.set("epoch",String(n.historyEpoch)));let a=i.size>0?`?${i}`:"",o=`/api/agent-sessions/${e}/stream${a}`;console.log("[AgentSession] Connecting to WebSocket:",o);let l=new WebSocket((0,aC.getWebSocketUrl)(o));I.current=l,P.current=e,l.onopen=()=>{I.current===l&&(console.log("[AgentSession] WebSocket connected"),m(!0),S(null),j(null),er.current=Date.now(),ew(l),es.current&&clearTimeout(es.current),es.current=setTimeout(()=>{I.current===l&&(console.log("[AgentSession] Connection stable, resetting backoff counter"),W.current=0,en.current=0)},5e3))},l.onmessage=n=>{if(I.current!==l||K.current.sessionId!==e){L.current.has(l)||(L.current.add(l),console.warn(`[AgentSession] Dropping frames from retired socket for ${e}`+(K.current.sessionId===e?"":`; buffer holds ${K.current.sessionId}`)));return}ew(l);try{let a=JSON.parse(n.data);if("error"in a||(U.current=0),"keepalive"in a)return;if("HistorySync"in a){(a.HistorySync.reset||X.current&&X.current.historyEpoch!==a.HistorySync.historyEpoch)&&(K.current={sessionId:e,entries:{},status:K.current.status},X.current=X.current?{...X.current,historyEpoch:a.HistorySync.historyEpoch,latestEntryIndex:null,lastTurnEndEntryIndex:null,entries:[],previousCursor:null,hasMore:!1}:null,G(!1));return}if("JsonPatch"in a){var i;let r=a.JsonPatch;if(i=K.current,K.current=Eo(i,e=>{for(let s of r){let{op:r,path:n,value:i}=s;if("/entries"===n&&"replace"===r&&i?.type==="ENTRY"&&i.content?.type==="system"&&i.content?.content==="__CLEAR_ALL__"){console.log("[JsonPatch] Received clearAll signal - clearing all entries"),e.entries={};continue}if(n.startsWith("/entries/")){let s=parseInt(n.replace("/entries/",""),10);if(isNaN(s)){console.warn(`[JsonPatch] Invalid index in path: ${n}`);continue}if(i?.type!=="ENTRY"){console.warn("[JsonPatch] Expected ENTRY type for entries path");continue}switch(r){case"add":e.entries[s]=i.content;break;case"replace":void 0!==e.entries[s]?e.entries[s]=i.content:console.warn(`[JsonPatch] Replace index out of bounds: ${s}`);break;case"remove":delete e.entries[s]}}else"/status"===n&&i?.type==="STATUS"&&(console.log("[AgentSession] /status patch →",i.content),e.status=i.content)}}),ei.current)console.log("[AgentSession] /status patch applied during replay (no setStatus), container.status =",K.current.status);else{let r=E5(K.current).map(e=>e.message);u(r),console.log("[AgentSession] setStatus(live) →",K.current.status),f(K.current.status);let n=K.current.status,i=E3(K.current);M(r=>"running"===n?null:r?.sessionId!==e?{sessionId:e,at:Date.now(),turnEndAt:i}:r.turnEndAt===i?r:{...r,turnEndAt:i}),s()}return}if("Ready"in a){console.log(`[AgentSession] Received Ready signal for ${e} - history complete, status=${K.current.status}, tail=${E5(K.current).at(-1)?.entryIndex??"-"}`),ei.current=!1,u(E5(K.current).map(e=>e.message)),f(K.current.status),M("running"===K.current.status?null:{sessionId:e,at:Date.now(),turnEndAt:E3(K.current)}),x(!0),s(),R(e=>e+1);return}if("finished"in a){console.log("[AgentSession] Received finished signal, preserving cached snapshot"),ee.current=!0,s(),l.close(1e3,"finished");return}if("taskCompleted"in a){if(ei.current)return;let{duration_ms:e,cost_usd:r,input_tokens:s,output_tokens:n}=a.taskCompleted,i=[];if(null!=e){let r=(e/1e3).toFixed(1);i.push(`${r}s`)}if(null!=r)i.push(`$${r.toFixed(4)}`);else if(null!=s||null!=n){let e=(s??0)+(n??0),r=e>1e3?`${(e/1e3).toFixed(1)}K`:String(e);i.push(`${r} tokens`)}xc.toast.success("Task completed",{description:i.length>0?i.join(" · "):void 0}),ef.current?.();return}if("remoteStatus"in a)return void j(a.remoteStatus);if("processAlive"in a){let r=Q.current;if(r?.id===e&&r.processAlive!==a.processAlive.alive){let e={...r,processAlive:a.processAlive.alive};Q.current=e,c(e)}return}if("titleUpdated"in a)return void em.current?.(a.titleUpdated.title,e);if("backgroundTasks"in a){let{tasks:e,turnParked:r,parkDeadlineAt:s,canStopTasks:n}=a.backgroundTasks;D({tasks:e,turnParked:r,parkDeadlineAt:s??null,canStopTasks:n??!1});return}if("workflowRunUpdated"in a&&N(a.workflowRunUpdated),"error"in a){if(console.error("[AgentSession] Server error:",a.error),(0,aC.isStreamAuthError)(a.error)){q.current=l,U.current++,U.current>=aC.STREAM_AUTH_REJECTS_BEFORE_ERROR&&S(aC.STREAM_AUTH_FAILED_MESSAGE);return}S(a.error),"Session not found"===a.error&&(console.log("[AgentSession] Session invalid, invalidating cache, will create new session"),r(),ee.current=!0,c(null),f("stopped"),x(!1),et.current=!0);return}}catch(e){console.error("[AgentSession] Failed to parse message:",e)}},l.onclose=e=>{if(I.current!==l)return;console.log("[AgentSession] WebSocket disconnected",e.code,e.reason),I.current=null,m(!1),eb(),es.current&&(clearTimeout(es.current),es.current=null);let s=er.current?Date.now()-er.current:0;if(er.current=null,q.current===l){if(q.current=null,ee.current)return;let e=e_(Math.min(U.current-1,4));console.log(`[AgentSession] Auth token rejected — reconnecting with a fresh token in ${Math.round(e)}ms`),$.current=setTimeout(()=>{$.current=null;let e=P.current;e&&!ee.current&&eS(e,!0)},e);return}if(s>0&&s<5e3){if(en.current++,console.log(`[AgentSession] Short-lived connection (${s}ms), count: ${en.current}, backoff attempt: ${W.current}`),en.current>=3){if(console.log("[AgentSession] Multiple short-lived connections detected, session likely invalid - will recreate"),el.current){console.log("[AgentSession] Skipping auto-restart: last session creation failed"),S("Unable to connect to remote server. Please check the server configuration.");return}r(),c(null),S(null),W.current=0,en.current=0,et.current=!0;return}}else s>=5e3&&(en.current=0);if(ee.current||1e3===e.code)return;if(W.current>=10){console.log("[AgentSession] Max reconnect attempts reached"),S("Unable to connect to server. Please check if the backend is running.");return}let n=e_(W.current);console.log(`[AgentSession] Reconnecting in ${Math.round(n)}ms (attempt ${W.current+1})`),W.current++,$.current=setTimeout(()=>{let e=P.current;e&&!ee.current&&eS(e,!0)},n)},l.onerror=e=>{I.current===l&&console.error("[AgentSession] WebSocket error:",e)}},[eS,ew,eb]);(0,V.useEffect)(()=>{O.current=ek},[ek]),(0,V.useEffect)(()=>{B.current=eS},[eS]),(0,V.useEffect)(()=>(z.current=e=>{if(I.current!==e)return;let r=P.current;I.current=null,m(!1),es.current&&(clearTimeout(es.current),es.current=null),er.current=null;try{e.close(4e3,"silence watchdog")}catch{}r&&!ee.current&&eS(r,!0)},()=>{z.current=()=>{}}),[eS]);let ej=(0,V.useCallback)(async i=>{if(!e)return null;if(ec.current)return console.log("[AgentSession] startSession already in progress, skipping"),null;ec.current=!0;let o=eo.current;S(null),j(null),ed.current||x(!1),el.current=!1;let l=EK(Eq(e,r,a));y(!0);let d=()=>{console.log(`[AgentSession] No existing session for ${e}/${r??"<null>"} — placeholder`),c(null),f("stopped"),u([]),K.current={sessionId:null,entries:{},status:"stopped"},X.current=null,G(!1),x(!0)};try{let h,p,m;if(!a){let n=EC(e,r,s),i=Eu(n);if(i?.content){let e=await e0.current?.(i,o);if(e?.adopted)return e.session;if(eo.current!==o)return null;if(EN(n))return d(),null}}if(console.log(`[AgentSession] Starting REST call: projectId=${e}, branch=${r}, sessionId=${a??"latest"}, agentType=${n}, generation=${o}`),a){let e=l?await E1(a).catch(()=>null):null;h=(m=l&&e&&"stopped"===e.status&&e.historyEpoch===l.history.historyEpoch&&e.lastTurnEndEntryIndex===l.history.lastTurnEndEntryIndex?{...l.history,status:e.status,latestEntryIndex:e.latestEntryIndex}:await E0(a)).session??l?.session??null,p=m.entries.map(e=>e.message)}else if(l){let s=await E1(l.session.id).catch(()=>null);if(s&&"stopped"===s.status&&s.historyEpoch===l.history.historyEpoch&&s.lastTurnEndEntryIndex===l.history.lastTurnEndEntryIndex)m={...l.history,status:s.status,latestEntryIndex:s.latestEntryIndex},h={...l.session,status:s.status},p=m.entries.map(e=>e.message);else{let s=await EM(e,r,i,n);h=s.session,p=s.messages,m=s.historyWindow}}else{let s=await EM(e,r,i,n);h=s.session,p=s.messages,m=s.historyWindow}if(eo.current!==o)return console.log("[AgentSession] Discarding stale session response (generation mismatch)"),null;if(!h)return d(),null;console.log(`[AgentSession] REST response: sessionId=${h.id}, msgCount=${p?.length??0}, status=${h.status}, explicitSessionIdRequested=${a??"<null>"}, window=[${m?.entries[0]?.entryIndex??"-"}..${m?.latestEntryIndex??"-"}], streamTail=${E5(K.current).at(-1)?.entryIndex??"-"}`);let g=m?{...m,status:h.status,session:h}:{historyEpoch:0,latestEntryIndex:p.length>0?p.length-1:null,lastTurnEndEntryIndex:p.reduce((e,r,s)=>"turn_end"===r.type?s:e,null),entries:p.map((e,r)=>({entryIndex:r,message:e})),previousCursor:null,hasMore:!1,status:h.status,session:h},v=K.current.sessionId===h.id&&X.current?.historyEpoch===g.historyEpoch,y=function(e,r,s){if(!s)return e;let n=E5(r),i=n.at(-1)?.entryIndex??null;if(null===i||null!==e.latestEntryIndex&&e.latestEntryIndex>=i)return e;let a=new Map;for(let r of e.entries)a.set(r.entryIndex,r.message);for(let e of n)a.set(e.entryIndex,e.message);let o=[...a].sort((e,r)=>e[0]-r[0]).map(([e,r])=>({entryIndex:e,message:r}));return{...e,entries:o,latestEntryIndex:o.at(-1)?.entryIndex??null,lastTurnEndEntryIndex:[...o].reverse().find(e=>"turn_end"===e.message.type)?.entryIndex??null}}(g,K.current,v);return y!==g&&console.warn(`[AgentSession] Stale history window for ${h.id}: window ends at ${g.latestEntryIndex}, stream already at ${y.latestEntryIndex} — keeping live tail`),EY(e,r,a,h,y),c(h),Q.current=h,X.current=y,G(y.hasMore),f(h.status),y.entries.length>0&&(u(y.entries.map(e=>e.message)),K.current={sessionId:h.id,entries:E2(y.entries),status:h.status}),x(!0),eS(h.id),ep.current?.(h),h}catch(e){if(console.error("[AgentSession] startSession error:",e),eo.current!==o)return console.log("[AgentSession] Discarding error (generation mismatch)"),null;return S(e instanceof Error?e.message:"Failed to start session"),el.current=!0,null}finally{ec.current=!1,eo.current===o&&(y(!1),w(!1),ed.current=!1)}},[e,r,s,n,a,eS]),eC=(0,V.useCallback)(async(s,n,i)=>{let o=n||l?.id;if(!o)return console.warn("[AgentSession] sendMessage: no session ID available (sessionId param:",n,", session?.id:",l?.id,")"),!1;if("string"==typeof s&&!s.trim()||Array.isArray(s)&&0===s.length)return!1;console.log(`[AgentSession] sendMessage: targetSessionId=${o}, source=${n?"explicit":"state"}`);let d=ey.current,u=()=>{let e=ey.current;return!!d&&!!e&&ER(d,e)};try{let e="string"==typeof s?s.trim():s;return await EI(o,e,i),u()&&S(null),!0}catch(n){let s=n instanceof Error?n.message:"Failed to send message";return console.error("[AgentSession] Failed to send message:",s),s.includes("[404]")&&(e&&(EU.delete(Eq(e,r,a)),l?.id&&EU.delete(Eq(e,r,l.id))),u()&&(c(null),f("stopped"),x(!1),et.current=!0)),u()&&S(s),xc.toast.error("Failed to send message",{description:s}),!1}},[l?.id,e,r,a]),eN=(0,V.useCallback)(async(e,r)=>{try{let s="string"==typeof r?r.trim():r;await EI(e.session.id,s);let n=ey.current;return n&&ER(e.origin,n)&&S(null),!0}catch(n){let r=n instanceof Error?n.message:"Failed to send message";console.error(`[AgentSession] Failed first-send for ${e.session.id}:`,r);let s=ey.current;if(!s||!ER(e.origin,s))return!1;return r.includes("[404]")&&(EG(e.origin.projectId,e.origin.branch,e.origin.explicitSessionId,e.session.id),Q.current?.id===e.session.id&&(c(null),Q.current=null,X.current=null,f("stopped"),x(!1),et.current=!0)),S(r),xc.toast.error("Failed to send message",{description:r}),!1}},[]),eE=(0,V.useCallback)(async e=>{let r;try{r=await EP(e.session.id)}catch(r){return console.error(`[AgentSession] Failed to discard empty session ${e.session.id}:`,r),!1}if(!r)return!1;EG(e.origin.projectId,e.origin.branch,e.origin.explicitSessionId,e.session.id);let s=EC(e.origin.projectId,e.origin.branch,e.origin.agentMode);eH.current.get(s)===e.session.id&&(eH.current.delete(s),EE(s));let n=ey.current;return n&&ER(e.origin,n)&&Q.current?.id===e.session.id&&(P.current===e.session.id&&(I.current?.close(1e3,"discard-empty-session"),I.current=null,P.current=null),F.current=null,c(null),Q.current=null,X.current=null,f("stopped"),x(!0),u([]),K.current={sessionId:null,entries:{},status:"stopped"}),!0},[]),eD=(0,V.useCallback)(async(e,r)=>{let s=r||l?.id;if(!s)throw Error("No session id available for paste upload");return EF(s,e)},[l?.id]),eT=(0,V.useCallback)(async(e,r,s)=>{let n=r||l?.id;if(!n)throw Error("No session id available for attachment upload");return EL(n,e,s)},[l?.id]),eR=(0,V.useCallback)(async()=>{if(l?.id)try{await E$(l.id)}catch(e){e instanceof Error&&e.message,console.error("[AgentSession] Failed to stop session:",e),xc.toast.error("Failed to stop session")}},[l?.id]),eA=(0,V.useCallback)(async s=>{if(l?.id){e&&(EU.delete(Eq(e,r,a)),EU.delete(Eq(e,r,l.id))),y(!0),S(null);try{await EO(l.id,s),s&&c(e=>e?{...e,agentType:s}:null)}catch(e){S(e instanceof Error?e.message:"Failed to restart session"),console.error("[AgentSession] Failed to restart session:",e)}finally{y(!1)}}},[l?.id,e,r,a]),eM=(0,V.useCallback)(async s=>{if(!l?.id)return"No active session";S(null);try{return await EB(l.id,s),c(n=>{if(!n)return n;let i={...n,agentType:s,model:null};return e&&EJ(e,r,a,i),i}),null}catch(r){let e=r instanceof Error?r.message:"Failed to switch agent";return console.error("[AgentSession] Failed to switch agent:",r),e}},[l?.id,e,r,a]),eI=(0,V.useCallback)(async s=>{let n=l?.id;if(!n)return"No active session";S(null);let i=eh.current.then(()=>Ez(n,s));eh.current=i.then(()=>void 0,()=>void 0);try{let s=await i;return c(i=>{if(!i||i.id!==n)return i;let o={...i,model:s};return e&&EJ(e,r,a,o),o}),null}catch(r){let e=r instanceof Error?r.message:"Failed to set model";return console.error("[AgentSession] Failed to set model:",r),e}},[l?.id,e,r,a]),eP=(0,V.useCallback)(async s=>{if(l?.id){S(null);try{await EW(l.id,s),c(n=>{if(!n)return n;let i={...n,permissionMode:s};return e&&EJ(e,r,a,i),i})}catch(e){S(e instanceof Error?e.message:"Failed to switch mode"),console.error("[AgentSession] Failed to switch mode:",e)}}},[l?.id,e,r,a]),eF=(0,V.useCallback)(async s=>{if(l?.id){S(null);try{await EH(l.id,s),c(s=>{if(!s)return s;let n={...s,permissionMode:"edit"};return e&&EJ(e,r,a,n),n})}catch(e){S(e instanceof Error?e.message:"Failed to accept plan"),console.error("[AgentSession] Failed to accept plan:",e)}}},[l?.id,e,r,a]),eL=(0,V.useCallback)(async()=>(e&&(l?.id&&EU.delete(Eq(e,r,l.id)),EU.delete(Eq(e,r,a)),I.current&&(I.current.close(1e3,"new-conversation"),I.current=null,P.current=null),F.current=null,$.current&&(clearTimeout($.current),$.current=null),es.current&&(clearTimeout(es.current),es.current=null),ee.current=!1,ei.current=!1,m(!1),c(null),f("stopped"),x(!0),S(null),j(null),D({tasks:[],turnParked:!1,parkDeadlineAt:null,canStopTasks:!1}),u([]),K.current={sessionId:null,entries:{},status:"stopped"},X.current=null,G(!1),EE(EC(e,r,s))),null),[e,r,s,l?.id,a]),[eO,eB]=(0,V.useState)(null),ez=(0,V.useRef)(null),e$=(0,V.useCallback)(()=>{ez.current?.resolve(!1),ez.current=null,eB(null)},[]),eW=(0,V.useRef)(new Map),eH=(0,V.useRef)(new Map),eU=(0,V.useCallback)(async(e,r)=>{let s,n=new Promise(e=>{s=e}),i={maxResidentAgentProcesses:e.maxResidentAgentProcesses??0,runningSessions:e.runningSessions??[],resolve:s};ez.current=i,eB(i);let a=await n;return ez.current===i&&(ez.current=null),eB(e=>e===i?null:e),eo.current===r&&a},[]),eV=(0,V.useCallback)(e=>{K.current.sessionId!==e.id&&(console.log(`[AgentSession] Adopting ${e.id} over ${K.current.sessionId} — dropping its entries`),u([]),K.current={sessionId:e.id,entries:{},status:e.status},G(!1))},[]),eq=(0,V.useCallback)((e,r,s)=>{let n=e.session,i={id:n.id,projectId:n.projectId,branch:n.branch,status:n.status,permissionMode:n.permissionMode??"edit",agentType:n.agentType??Ep,model:n.model??null,processAlive:n.processAlive??!0},a=E4(i);EY(r.projectId,r.branch,r.explicitSessionId,i,a);let o=EC(r.projectId,r.branch,r.agentMode);ED(o),eH.current.set(o,i.id);try{s?.(i.id)}catch(e){console.error(`[AgentSession] onCreated failed for ${i.id}:`,e)}let l=ey.current,d=null!==l&&ER(r,l);if(d){eo.current+=1,y(!1),eV(i),c(i),Q.current=i,X.current=a,f(i.status),x(!0);try{eS(i.id)}catch(e){console.error(`[AgentSession] Failed to connect activated session ${i.id}:`,e)}try{ep.current?.(i)}catch(e){console.error(`[AgentSession] onSessionStarted failed for ${i.id}:`,e)}"uncertain"===e.kind&&xc.toast.warning("First message delivery could not be confirmed",{description:"The session exists, but the agent may not have received your message. Check the conversation before resending."})}else console.log(`[AgentSession] Activated session ${i.id} for a background workspace; not adopting it into the current view`);return{session:i,origin:r,adopted:d}},[eS,eV]),eK=(0,V.useCallback)(async(e,r,s,n,i)=>{let a=!1,o=0,l=s;for(;;){let c;try{c=await n(a)}catch(n){let e=n instanceof Error?n.message:"Failed to start session";return console.error(`[AgentSession] first send transport failure for ${s.operationId}:`,e),eo.current===r&&(S(e),xc.toast.error("Failed to send message",{description:`${e}. Sending again will retry the same request.`})),null}if((0,aC.lifecycleSessionReady)(c.kind)&&c.session)return Ef(l.workspaceKey,l.operationId),eq(c,e,i);if(eo.current!==r)return null;switch(!l.sessionId&&c.lifecycle?.sessionId&&Eh(l={...l,sessionId:c.lifecycle.sessionId}),c.kind){case"resident_limit":if(!await eU(c,r))return null;a=!0;continue;case"in_progress":if(o++>=15)return S("Activation is still in progress; try again in a moment"),null;if(await new Promise(e=>setTimeout(e,1e3)),eo.current!==r)return null;continue;case"retryable_failure":case"remote_unreachable":{let e=c.error??`Failed to start session (${c.kind})`;return S(e),xc.toast.error("Failed to send message",{description:`${e}. Sending again will retry the same request.`}),null}default:{Ef(l.workspaceKey,l.operationId);let e=c.error??`Failed to start session (${c.kind})`;return S(e),xc.toast.error("Failed to send message",{description:e}),null}}}},[eq,eU]),eX=(0,V.useRef)(new Map),eY=(0,V.useCallback)(()=>{if(!e)return null;let n=ET(e,r,s,a);return{origin:n,key:EC(n.projectId,n.branch,n.agentMode)}},[e,r,s,a]),eG=(0,V.useCallback)((e,r,s,i,a)=>{let o=eY();if(!o)return Promise.resolve(null);if(l)return Promise.resolve({session:l,origin:o.origin,adopted:!0});let{origin:c,key:d}=o,u=eo.current,h=eX.current.get(d);if(h)return h.then(async r=>r?(await eC(e,r.session.id),r):null);let f=(async()=>{y(!0),S(null);try{var o;let l=Eu(d),h=null!==l&&(o=l.content,null!==o&&null!==e&&("string"==typeof o||"string"==typeof e?"string"==typeof o&&"string"==typeof e&&o.trim()===e.trim():JSON.stringify(o)===JSON.stringify(e)))?{...l,content:e,grantedRemoteIds:i??l.grantedRemoteIds}:{workspaceKey:d,projectId:c.projectId,branch:c.branch,agentMode:c.agentMode??"local",operationId:crypto.randomUUID(),sessionId:null,content:e,permissionMode:r,model:s??null,grantedRemoteIds:i,createdAt:Date.now()},f=Eh(h);return f?.sessionId&&(0,aC.cancelPreparedAgentSession)(f.sessionId).catch(()=>void 0),await eK(c,u,h,a=>h.sessionId?(0,aC.activateAgentSession)(h.sessionId,{activationKey:h.operationId,instruction:e,force:a}):(0,aC.startAgentSession)(c.projectId,{operationId:h.operationId,branch:c.branch,permissionMode:h.permissionMode??r,agentType:n,model:h.model??s,instruction:e,force:a,grantedRemoteIds:h.grantedRemoteIds??i}),a)}finally{eX.current.get(d)===f&&eX.current.delete(d),eo.current===u&&y(!1)}})();return eX.current.set(d,f),f},[l,eY,n,eK,eC]),eJ=(0,V.useCallback)(async(e,r,s)=>{let i=eY();if(!i)return null;let{origin:a,key:o}=i,l=eo.current;S(null);let c=Eu(o),d=c&&null===c.content?c:{workspaceKey:o,projectId:a.projectId,branch:a.branch,agentMode:a.agentMode??"local",operationId:crypto.randomUUID(),sessionId:null,content:null,permissionMode:e,model:r??null,grantedRemoteIds:s,createdAt:Date.now()},u=Eh(d);u?.sessionId&&(0,aC.cancelPreparedAgentSession)(u.sessionId).catch(()=>void 0);for(let i=0;i<2;i++){let i;try{i=await (0,aC.prepareAgentSession)(a.projectId,{operationId:d.operationId,branch:a.branch,permissionMode:d.permissionMode??e,agentType:n,model:d.model??r,purpose:"interactive_upload",grantedRemoteIds:d.grantedRemoteIds??s})}catch(r){let e=r instanceof Error?r.message:"Failed to prepare session";eo.current===l&&(S(e),xc.toast.error("Failed to send message",{description:e}));break}if(eo.current!==l)break;if(("prepared"===i.kind||"replayed"===i.kind)&&i.lifecycle)return Eh(d={...d,sessionId:i.lifecycle.sessionId}),{operationId:d.operationId,sessionId:i.lifecycle.sessionId,origin:a,legacy:!0===i.lifecycle.legacy};if("expired"===i.kind){Ef(o,d.operationId),Eh(d={...d,operationId:crypto.randomUUID(),sessionId:null});continue}Ef(o,d.operationId);let c=i.error??`Failed to prepare session (${i.kind})`;S(c),xc.toast.error("Failed to send message",{description:c});break}return null},[eY,n]),eZ=(0,V.useCallback)((e,r,s,n)=>{let i=EC(e.origin.projectId,e.origin.branch,e.origin.agentMode),a=eo.current,o=Eu(i),l=o&&o.operationId===e.operationId?{...o,sessionId:e.sessionId,content:r,grantedRemoteIds:s}:{workspaceKey:i,projectId:e.origin.projectId,branch:e.origin.branch,agentMode:e.origin.agentMode??"local",operationId:e.operationId,sessionId:e.sessionId,content:r,grantedRemoteIds:s,createdAt:Date.now()};Eh(l);let c=(async()=>{y(!0),S(null);try{return await eK(e.origin,a,l,n=>(0,aC.activateAgentSession)(e.sessionId,{activationKey:e.operationId,instruction:r,force:n,grantedRemoteIds:s}),n)}finally{eX.current.get(i)===c&&eX.current.delete(i),eo.current===a&&y(!1)}})();return eX.current.set(i,c),c},[eK]),eQ=(0,V.useCallback)(async e=>{Ef(EC(e.origin.projectId,e.origin.branch,e.origin.agentMode),e.operationId);try{let r=await (0,aC.cancelPreparedAgentSession)(e.sessionId);e.legacy&&"cancelled"===r.kind&&EG(e.origin.projectId,e.origin.branch,e.origin.explicitSessionId,e.sessionId)}catch(r){console.warn(`[AgentSession] cancel prepared session ${e.sessionId} failed:`,r)}},[]),e0=(0,V.useRef)(null);e0.current=async(e,r)=>{let s=ET(e.projectId,e.branch,e.agentMode,null),i=e.content;return console.log(`[AgentSession] Replaying pending first send ${e.operationId} for ${e.workspaceKey}`),eK(s,r,e,r=>e.sessionId?(0,aC.activateAgentSession)(e.sessionId,{activationKey:e.operationId,instruction:i,force:r,grantedRemoteIds:e.grantedRemoteIds}):(0,aC.startAgentSession)(e.projectId,{operationId:e.operationId,branch:e.branch,permissionMode:e.permissionMode,agentType:n,model:e.model,instruction:i,force:r,grantedRemoteIds:e.grantedRemoteIds}))};let e1=(0,V.useCallback)((i,o)=>{if(!e)return Promise.resolve(null);let d=ET(e,r,s,a);if(l)return Promise.resolve({session:l,origin:d,adopted:!0});let u=eo.current,h=`${u}:${o??null}`,p=eW.current.get(h);if(p)return p;let m=(async()=>{y(!0),S(null);try{let s;try{s=await (0,aC.createNewAgentSession)(e,r,i,n,void 0,o)}catch(h){let a;if(!(h instanceof aC.ResidentLimitError))throw h;let l=new Promise(e=>{a=e}),c={maxResidentAgentProcesses:h.maxResidentAgentProcesses,runningSessions:h.runningSessions,resolve:a};ez.current=c,eB(c);let d=await l;if(ez.current===c&&(ez.current=null),eB(e=>e===c?null:e),eo.current!==u)return null;if(!d)throw h;s=await (0,aC.createNewAgentSession)(e,r,i,n,!0,o)}let a={id:s.session.id,projectId:s.session.projectId,branch:s.session.branch,status:s.session.status,permissionMode:s.session.permissionMode??"edit",agentType:s.session.agentType??Ep,model:s.session.model??null,processAlive:s.session.processAlive??!0},l=E4(a);EY(d.projectId,d.branch,d.explicitSessionId,a,l),ED(EC(d.projectId,d.branch,d.agentMode)),eH.current.set(EC(d.projectId,d.branch,d.agentMode),a.id);let h=ey.current,p=null!==h&&ER(d,h);if(p){eo.current+=1,y(!1),eV(a),c(a),Q.current=a,X.current=l,f(a.status),x(!0);try{eS(a.id)}catch(e){console.error(`[AgentSession] Failed to connect created session ${a.id}:`,e)}try{ep.current?.(a)}catch(e){console.error(`[AgentSession] onSessionStarted failed for ${a.id}:`,e)}}else console.log(`[AgentSession] Created session ${a.id} for a background workspace; not adopting it into the current view`);return{session:a,origin:d,adopted:p}}catch(e){if(console.error("[AgentSession] ensureSession:",e),eo.current!==u)return null;return S(e instanceof Error?e.message:"Failed to create session"),null}finally{eW.current.get(h)===m&&eW.current.delete(h),eo.current===u&&y(!1)}})();return eW.current.set(h,m),m},[e,r,s,n,l,a,eS,eV]),e2=(0,V.useCallback)(async()=>{let s=Q.current,n=X.current;if(s&&n?.hasMore&&null!==n.previousCursor&&!J){Z(!0);try{let i=await EQ(s.id,n.previousCursor);if(Q.current?.id!==s.id)return;if(i.historyEpoch!==n.historyEpoch)X.current=i,K.current={sessionId:s.id,entries:E2(i.entries),status:i.status};else{let e=new Map;for(let r of i.entries)e.set(r.entryIndex,r.message);for(let r of E5(K.current))e.set(r.entryIndex,r.message);let r=[...e].sort((e,r)=>e[0]-r[0]).map(([e,r])=>({entryIndex:e,message:r}));X.current={...n,entries:r,previousCursor:i.previousCursor,hasMore:i.hasMore},K.current={sessionId:K.current.sessionId,entries:E2(r),status:K.current.status}}let o=X.current;u(o.entries.map(e=>e.message)),G(o.hasMore),e&&EY(e,r,a,s,o)}catch(e){xc.toast.error("Failed to load earlier conversation",{description:e instanceof Error?e.message:String(e)})}finally{Z(!1)}}},[e,r,a,J]);(0,V.useEffect)(()=>()=>{I.current&&(ee.current=!0,I.current.close(),P.current=null),F.current=null,$.current&&clearTimeout($.current),es.current&&clearTimeout(es.current),eb(),eo.current+=1,e$(),EU.clear()},[e$,eb]);let e5=(0,V.useCallback)((e,r,s)=>{let n=EK(Eq(e,r,s))??(s?void 0:function(e,r){let s,n=`${e}:${r??""}:`;for(let e of EU.keys())e.startsWith(n)&&(s=e);return s?EK(s):void 0}(e,r));if(!n)return!1;let i=n.history.lastTurnEndEntryIndex??null,a="running"===n.session.status?n.history.entries.filter(e=>null!==i&&e.entryIndex<=i):n.history.entries,o={...n.history,entries:a,latestEntryIndex:a.at(-1)?.entryIndex??null};return c(n.session),Q.current=n.session,f(n.session.status),x(!0),w(!0),ed.current=!0,u(a.map(e=>e.message)),K.current={sessionId:n.session.id,entries:E2(a),status:n.session.status},X.current=o,G(o.hasMore??!1),!0},[]);return(0,V.useEffect)(()=>{I.current&&(I.current.close(1e3,"branch-switch"),I.current=null,P.current=null),F.current=null,$.current&&(clearTimeout($.current),$.current=null),es.current&&(clearTimeout(es.current),es.current=null),eb(),eo.current+=1,e$();let n=e?EC(e,r,s):null;n&&a&&ED(n);let i=!a&&null!==n&&EN(n)&&!Eu(n)?.content;!i&&e&&!eu.current&&e5(e,r,a)||(c(null),Q.current=null,f("stopped"),x(i),w(!1),ed.current=!1,u([]),K.current={sessionId:null,entries:E2([]),status:"stopped"},X.current=null,G(!1)),m(!1),S(null),y(!1),j(null),D({tasks:[],turnParked:!1,parkDeadlineAt:null,canStopTasks:!1}),ee.current=!1,W.current=0,er.current=null,en.current=0,el.current=!1,ec.current=!1,et.current=!i},[e,r,s,a,e5,e$,eb]),(0,V.useEffect)(()=>{o||!e||!et.current||ed.current||Q.current||EN(EC(e,r,s))||e5(e,r,a)},[o,e,r,s,a,e5]),(0,V.useEffect)(()=>{if(o)return;let n=null!==e?EC(e,r,s):null,i=null!==n&&EN(n)&&!Eu(n)?.content;!et.current||!e||l&&!ed.current||v||el.current||i||(et.current=!1,console.log(`[AgentSession] Auto-start: projectId=${e}, branch=${r}, agentMode=${s}`),ej())},[e,r,s,l,v,ej,o]),(0,V.useEffect)(()=>{let e=()=>{if("visible"===document.visibilityState&&l?.id&&!ee.current){let e=I.current;e&&e.readyState!==WebSocket.CLOSED&&e.readyState!==WebSocket.CLOSING||(console.log("[AgentSession] Tab visible, WebSocket disconnected - reconnecting"),W.current=0,en.current=0,$.current&&(clearTimeout($.current),$.current=null),eS(l.id))}},r=()=>{if(!l?.id||ee.current)return;let e=I.current;e&&e.readyState!==WebSocket.CLOSED&&e.readyState!==WebSocket.CLOSING||(console.log("[AgentSession] Network online, WebSocket disconnected - reconnecting"),W.current=0,H.current=0,$.current&&(clearTimeout($.current),$.current=null),eS(l.id,!0))};return document.addEventListener("visibilitychange",e),window.addEventListener("online",r),()=>{document.removeEventListener("visibilitychange",e),window.removeEventListener("online",r)}},[l?.id,eS]),(0,V.useEffect)(()=>{l?.id&&!ee.current&&eS(l.id)},[l?.id,eS]),{session:l,messages:d,status:h,isConnected:p,isInitialized:g,isLoading:v,isCachePreview:b,error:_,remoteStatus:k,workflowRunUpdate:C,backgroundTasks:E,streamEpoch:T,streamFinished:A,messageEntryIndices:E5(K.current).map(e=>e.entryIndex),hasEarlierHistory:Y,isLoadingEarlier:J,loadEarlierHistory:e2,startSession:ej,sendMessage:eC,sendEnsuredMessage:eN,discardEnsuredSessionIfEmpty:eE,uploadPaste:eD,uploadAttachment:eT,stopSession:eR,restartSession:eA,switchAgentType:eM,setModel:eI,startNewConversation:eL,ensureSession:e1,startConversation:eG,prepareConversation:eJ,activateConversation:eZ,cancelPreparedConversation:eQ,switchMode:eP,acceptPlan:eF,residentLimitPrompt:eO}}(e,r,a?.agent_mode,K,{sessionId:s,suspended:n,onTaskCompleted:l,onSessionStarted:c,onTitleUpdated:(e,r)=>{let s=r??ev?.id;s&&e&&(ea({sessionId:s,title:e}),d?.(s,e)),er(e=>e+1),en(null)}}),eZ=`${e}::${r}::${ef}::${ev?.id??""}`,[eQ,e0]=(0,V.useState)(null),e2=eQ?.key===eZ?eQ.kind:null,e5="schedule"===e2,e3="task"===e2,e4=e=>e0(e2===e?null:{key:eZ,kind:e}),[e6,e7]=(0,V.useState)(null),e8=e6?.key===eZ?e6.tasks:[],e9=(e,r)=>{let s=e8.filter(r=>r.id!==e.id);e7({key:eZ,tasks:r?[...s,e]:s})},te=eR??ey.map((e,r)=>r);j=ev?.id??null,(0,aF.useGlobalEventStream)(s=>{"session:status"!==s.type||"running"!==s.status||!e||s.projectId!==e||(s.branch??null)!==(r??null)||s.sessionId&&s.sessionId!==j&&(s=>{e&&AT(e,r).then(e=>{e.some(e=>e.reviewer_session_id===s)||i?.(s)}).catch(()=>i?.(s))})(s.sessionId)});let tt=ev?.id??null;(0,V.useEffect)(()=>{p?.(tt)},[tt,p]);let tr=eT?.sessionId===tt&&"running"!==eb?eT.at:null;(0,V.useEffect)(()=>{m?.(tr)},[tr,m]);let ts=null!==tr?eT?.turnEndAt??null:null;(0,V.useEffect)(()=>{g?.(ts)},[ts,g]);let{config:tn}=(0,ow.useAppConfig)(),ti=tn?.crossRemoteSessionGrants===!0,ta=function(e,r,s=!0){let[n,i]=(0,V.useState)([]),a=(0,V.useRef)(null);(0,V.useEffect)(()=>{(a.current=e,s)?i(Mo(Mn(e,r))):i([])},[e,r,s]);let o=(0,V.useCallback)((n,a)=>{s&&i(s=>{var i;let o,l=a?s.some(e=>e.id===n.id)?s:[...s,n]:s.filter(e=>e.id!==n.id);return i=Mn(e,r),o=Mi(),0===l.length?delete o[i]:o[i]=l,Ma(o),l})},[e,r,s]),l=(0,V.useCallback)(e=>{if(s){let s,n,o,l;s=Mn(null,r),n=Mn(e,r),(l=(o=Mi())[s])&&!o[n]&&(o[n]=l,delete o[s],Ma(o)),a.current===e&&i(Mo(Mn(e,r)))}},[r,s]);return{granted:n,selectedIds:s?n.map(e=>e.id):void 0,toggle:o,adoptInto:l}}(tt,`${e??""}::${r??""}`,ti),to=a?.agent_mode&&"local"!==a.agent_mode?a.agent_mode:void 0,tl=(0,V.useRef)(p);tl.current=p,(0,V.useEffect)(()=>()=>tl.current?.(null),[]),(0,V.useEffect)(()=>{(0,aC.getAgentProviders)().then(J).catch(()=>{})},[]);let tc=ev?.id??null,td=ev?.permissionMode??null;(0,V.useEffect)(()=>{null===tc?L("edit"):td&&L(td)},[tc,td]),(0,V.useEffect)(()=>{ev?.agentType&&X(ev.agentType)},[ev?.agentType]),(0,V.useEffect)(()=>{q.current=null,t3(),M([]),P(1),Q(null),$(!1),H(!1)},[e,r]);let tu=(0,V.useRef)({sessionId:null,count:0});(0,V.useEffect)(()=>{let e=ev?.id??null,r=tu.current;e&&r.sessionId===e&&0===r.count&&ey.length>0&&en(e),tu.current={sessionId:e,count:ey.length}},[ev?.id,ey.length]),(0,V.useEffect)(()=>{let e=ev?.id??null;return()=>gA.stopOwnersWithPrefix(`${e??"none"}:`)},[ev?.id]),(0,V.useEffect)(()=>{es&&ev?.id!==es&&en(null)},[ev?.id,es]),(0,V.useEffect)(()=>{ei&&ev?.id!==ei.sessionId&&ea(null)},[ev?.id,ei]),(0,V.useEffect)(()=>{if(!ei)return;let e=setTimeout(()=>{ea(e=>e===ei?null:e)},5e3);return()=>clearTimeout(e)},[ei]),(0,V.useEffect)(()=>{if(!es)return;let e=setTimeout(()=>{en(e=>e===es?null:e)},3e4);return()=>clearTimeout(e)},[es]);let[th,tf]=(0,V.useState)(!1);(0,V.useEffect)(()=>{tf(!1)},[ev?.id]),(0,V.useEffect)(()=>{ew&&tf(!0)},[ew]);let tp=async e=>{L(e),ev&&await eY(e)},tm=async e=>{let r=await eq(e);r&&xc.toast.error("Failed to change model",{description:r})},tg=async e=>{await eG(e),L("edit"),h?.()},[tx,tv]=(0,V.useState)(!1),ty=async(e,r)=>{if(ev&&!tx){tv(!0);try{let s=await (0,aC.branchAgentSession)(ev.id,e,r);er(e=>e+1),i?.(s.session.id)}catch(r){let e=r instanceof Error?r.message:"Failed to branch conversation";xc.toast.error("Branch failed",{description:e})}finally{tv(!1)}}},tb=Eg(K,Y).displayName,tw=Y.filter(e=>e.type!==K),t_=ev?.branchedFromSessionId??null,tS=ev?.branchedFromEntryIndex??-1,[tk,tj]=(0,V.useState)(()=>new Set),[tC,tN]=(0,V.useState)(null),[tE,tD]=(0,V.useState)(!1);(0,V.useEffect)(()=>{tj(new Set),tN(null),tD(!1)},[ev?.id]);let tT=(0,V.useCallback)(e=>{let r=function(e,r){for(let s=r-1;s>=0;s--){let r=e[s];if(r){if("assistant"===r.type&&r.content.trim())return r.content.trim();if("turn_end"===r.type)break}}return null}(ey,e);return null===r?null:`以下是另一个 agent(${tb})在分支会话中给出的意见,非用户本人观点,请自行判断是否采纳:
29
+
30
+ ${r}`},[ey,tb]),tR=(0,V.useCallback)(async(e,r)=>{if(!t_||null!==tC)return;let s=tT(r);if(null===s)return void xc.toast.error("This turn has no text answer to send back");tN(e);try{await (0,aC.sendAgentSessionMessage)(t_,s),tj(r=>new Set(r).add(e)),xc.toast.success("Sent back to source session"),i?.(t_)}catch(s){let e=s instanceof Error?s.message:String(s),r=e.includes("404");r&&tD(!0),xc.toast.error("Send back failed",{description:r?"The source session no longer exists":e})}finally{tN(null)}},[t_,tC,tT,i]),tA=(0,V.useMemo)(()=>{for(let e=ey.length-1;e>=0;e--)if(ey[e]?.type==="turn_end")return e;return -1},[ey]),tM="running"===eb&&ey.length>0&&"turn_end"!==ey[ey.length-1].type,tI=function(e,r,s,n,i){let a=s&&s.projectId===e&&s.branch===r?s.id:null,[o,l]=(0,V.useState)(null),c=(0,V.useRef)(0),d=(0,V.useRef)(null),[u,h]=(0,V.useState)({runUpdate:null,sessionId:null});(u.runUpdate!==n||u.sessionId!==a)&&(h({runUpdate:n,sessionId:a}),n&&n.reviewer_session_id===a&&l(Mh.has(n.status)?n:null)),(0,V.useLayoutEffect)(()=>{n&&n.reviewer_session_id===a&&c.current++},[n,a]);let[f,p]=(0,V.useState)({projectId:null,sessionId:null});return(f.projectId!==e||f.sessionId!==a)&&(p({projectId:e,sessionId:a}),l(null)),(0,V.useEffect)(()=>{if(!e||!a)return;let s=!1,n=c.current,o=null!==d.current&&d.current!==i;return d.current=i,AT(e,r,{force:o}).then(e=>{s||c.current!==n||l(e.find(e=>e.reviewer_session_id===a)??null)}).catch(()=>{}),()=>{s=!0}},[e,r,a,i]),o}(e,r,ev,eN,eD),tP=eN&&ev&&eN.reviewer_session_id===ev.id&&"failed"===eN.status?eN:null,tF=ey.flatMap((e,r)=>MV(e)?[{message:e,index:r}]:[]),tL=ey.every(MV),tO=!!(ev&&tI?.status==="preparing"&&tL),tB=!!(ev&&tP&&tL),tz=!tO&&!tB&&!ev&&0===ey.length,t$=ev?y?.find(e=>e.sourceSessionId===ev.id&&"preparing"===e.run.status):void 0,tW=ei&&ev&&ei.sessionId===ev.id?ei.title:null,tH=tF.length>0?(0,U.jsx)("div",{className:"mt-6 space-y-1 text-left",children:tF.map(({message:e,index:r})=>(0,U.jsx)("div",{"data-message-idx":r,className:"scroll-mt-2",children:(0,U.jsx)(RX,{message:e,messageIndex:r,entryIndex:te[r]??r,streaming:!1})},te[r]??r))}):null,[tU,tV]=(0,V.useState)(!1),tq=(0,V.useCallback)(async()=>{if(tI){tV(!0);try{await aC.api.workflowRunGate(tI.id,"finalize")}catch(e){xc.toast.error(e instanceof Error?e.message:"生成终稿失败")}finally{tV(!1)}}},[tI]),tK=(0,V.useCallback)(()=>{ec.current?.querySelector("textarea")?.focus({preventScroll:!0})},[]),{active:tX,requestNonce:tY}=(0,V.useContext)(Nj);(0,V.useEffect)(()=>{tX&&tK()},[tX,tY,tK]),(0,V.useEffect)(()=>{if(!tX)return;let e=e=>(function(e,r){if(!ee(e,G)||(e.preventDefault(),e.repeat))return;let s=r?function(e){let r=null,s=-1/0;for(let n of e.querySelectorAll("button[data-speak-button]")){let e=n.closest("[data-speak-message]")??n,i=e.getBoundingClientRect();if(0===i.height)continue;let a=function(e){let r=e.getBoundingClientRect(),s=Math.max(r.top,0),n=Math.min(r.bottom,window.innerHeight);for(let r=e.parentElement;r&&s<n;r=r.parentElement){if("visible"===getComputedStyle(r).overflowY)continue;let e=r.getBoundingClientRect();s=Math.max(s,e.top),n=Math.min(n,e.bottom)}return{top:s,bottom:n}}(e);!(a.bottom-a.top<Math.min(32,i.height))&&i.top>s&&(r=n,s=i.top)}return r}(r):null;s?s.click():gA.stop()})(e,eo.current);return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[tX]);let tG=(0,V.useCallback)(e=>{var r,s;let n;R((r=T,s=e,n=0===r.length||r.endsWith("\n\n")?"":r.endsWith("\n")?"\n":"\n\n",r+n+(s.replace(/\r?\n/g,"\n").split("\n").map(e=>`> ${e}`).join("\n")+"\n\n"))),requestAnimationFrame(()=>{let e=ec.current?.querySelector("textarea");if(!e)return;e.focus();let r=e.value.length;try{e.setSelectionRange(r,r)}catch{}})},[R,T]),tJ=(0,V.useCallback)(async()=>{!eS&&ev&&(await eK(),Q(null),f?.(),i?.(null),tK())},[eS,ev,eK,f,i,tK]),tZ=(0,V.useRef)(null);(0,V.useEffect)(()=>{if(_&&!n&&tZ.current!==_.nonce&&_.projectId===e&&_.branch===r&&!eS&&e_){if(ev)return void tJ();tZ.current=_.nonce,e0(null),e7({key:eZ,tasks:_.tasks}),S?.(),tK()}},[_,n,e,r,eS,e_,ev,eZ,tJ,S,tK]),(0,V.useImperativeHandle)(k,()=>({startNewConversation:tJ,submitMessage:async e=>{if(h?.(),ev)await eP(e,void 0,ta.selectedIds);else{let r=await eO(e,F,Z,ta.selectedIds,ta.adoptInto);r&&eg(r.origin)&&en(r.session.id)}}}),[tJ,ev,eO,eP,F,Z,h,eg,ta]);let tQ=(0,V.useCallback)((e,r)=>{if(r.length<=2e3)return;e.preventDefault();let s=e.currentTarget,n=s.selectionStart??T.length,i=s.selectionEnd??T.length,a=new TextEncoder().encode(r).length,o=Mq(I,a);R(T.slice(0,n)+o+T.slice(i)),M(e=>[...e,{id:I,content:r,size:a}]),P(I+1);let l=n+o.length;requestAnimationFrame(()=>{try{s.setSelectionRange(l,l)}catch{}})},[T,I,R]);async function t0(e,r,s,n){let i=new Set;for(let r of e.matchAll(MU))i.add(Number(r[1]));let a=r.filter(e=>i.has(e.id));if(0===a.length)return e;let o=e;for(let e of a){let r=await s(e.content,n),i=Mq(e.id,e.size),a=`<vpaste path="${r.path}" size="${r.size}" />`;o=o.split(i).join(a)}return o}let t1=(0,V.useRef)(null),t2=s=>!!s&&s.projectId===e&&s.branch===r&&s.agentType===K&&s.permissionMode===F&&s.model===Z&&Date.now()-s.createdAt<6e5,t5=async()=>{let s=await eB(F,Z,ta.selectedIds);if(!s)throw Error("Failed to prepare session");return{prepared:s,projectId:e,branch:r??null,agentType:K,permissionMode:F,model:Z,createdAt:Date.now()}},t3=async()=>{let e=t1.current;e&&(t1.current=null,await e$(e.prepared))},t4=function(e){let r=(0,V.useRef)(e);r.current=e;let s=(0,V.useRef)(new Map),n=(0,V.useRef)(new Set),[i,a]=(0,V.useState)(new Map),o=(0,V.useCallback)((e,r)=>{a(s=>{let n=s.get(e);if(n&&n.phase===r.phase&&n.progress===r.progress&&n.message===r.message)return s;let i=new Map(s);return i.set(e,r),i})},[]),l=(0,V.useCallback)(async(e,s)=>{var n;let i,a=e.filename||"attachment";s?.({phase:"reading",progress:0});let o=(n=await R4(e.url)??void 0,n?.match(R3)?.[1]??null);if(!o)throw Error(`Could not read ${a}`);let l=(i=function(e){let r=e.slice(0,24).replace(/[^A-Za-z0-9+/=]/g,"");try{let e=atob(r.length%4==0?r:r.slice(0,r.length-r.length%4)),s=new Uint8Array(e.length);for(let r=0;r<e.length;r++)s[r]=e.charCodeAt(r);return s}catch{return new Uint8Array(0)}}(o)).length>=3&&255===i[0]&&216===i[1]&&255===i[2]?"image/jpeg":MB(i,MP)?"image/png":MB(i,MF)?"image/gif":MB(i,ML)&&MB(i,MO,8)?"image/webp":null;if(l&&5242880>=function(e){let r=e.length;if(0===r)return 0;let s=0;return e.endsWith("==")?s=2:e.endsWith("=")&&(s=1),Math.floor(3*r/4)-s}(o))return s?.({phase:"inline",progress:1}),{kind:"image",mediaType:l,data:o};s?.({phase:"uploading",progress:0});let c=await r.current.getUploadTarget(),d=await r.current.upload({name:a,mediaType:e.mediaType||void 0,contentBase64:o},c,e=>s?.({phase:"uploading",progress:e}));return s?.({phase:"done",progress:1}),{kind:"file",marker:`<vfile path="${d.path}" name="${d.name}" size="${d.size}" />`}},[]),c=(0,V.useCallback)((e,r)=>{let n=l(e,e=>o(r,e));n.catch(e=>{o(r,{phase:"error",progress:0,message:e instanceof Error?e.message:"Upload failed"})}),s.current.set(r,{name:e.filename||"attachment",promise:n})},[l,o]),d=(0,V.useCallback)(e=>{let r=new Set;for(let n of e)n.id&&(r.add(n.id),s.current.has(n.id)||c(n,n.id));let i=e=>r.has(e)||n.current.has(e);for(let e of Array.from(s.current.keys()))i(e)||s.current.delete(e);a(e=>{if(0===e.size)return e;let r=new Map;for(let[s,n]of e)i(s)&&r.set(s,n);return r.size===e.size?e:r})},[c]),u=(0,V.useCallback)(e=>{for(let r of e)n.current.add(r)},[]),h=(0,V.useCallback)((e,r)=>{for(let i of e)n.current.delete(i),r&&s.current.delete(i);r&&a(r=>{let s=new Map(r);for(let r of e)s.delete(r);return s.size===r.size?r:s})},[]),f=(0,V.useCallback)(e=>{e.id&&(s.current.delete(e.id),c(e,e.id))},[c]),p=(0,V.useCallback)(e=>e?i.get(e):void 0,[i]);return{track:d,retry:f,retain:u,release:h,statusOf:p,resolve:(0,V.useCallback)(async e=>{let r=[],n=[];for(let i of e){let e=i.id?s.current.get(i.id):void 0,a=e?await e.promise:await l(i);"image"===a.kind?r.push({mediaType:a.mediaType,data:a.data}):n.push(a.marker)}return{images:r,markers:n}},[l]),pending:(0,V.useMemo)(()=>Array.from(i.values()).some(e=>"reading"===e.phase||"uploading"===e.phase),[i])}}({upload:eH,getUploadTarget:(0,V.useCallback)(async()=>ev?ev.id:(t2(t1.current)||(await t3(),t1.current=await t5()),t1.current.prepared.sessionId),[ev,e,r,K,F,Z,eB,e$])}),t6=(0,V.useRef)(null),t7=(0,V.useCallback)(e=>{if("max_file_size"===e.code){let r=e.files?.map(e=>e.name).join(", ");xc.toast.error(`Files must be ${Math.floor(20)}MB or smaller`,{description:r?`Not attached: ${r}`:e.message});return}xc.toast.error("Could not attach files",{description:e.message})},[]),t8=async e=>{let r=em.current;if(!r)return;let s=e.text,n=e.files.length>0,i=A.length>0,a=s.trim(),o=null!==e2&&!!ev;if(!a&&!n&&!o)return;let l=Symbol("agent-submission");q.current=l,H(!0);try{var c,d;let o,u,f;R(""),a&&ed.push(a),e2&&e0(null),e8.length>0&&e7(null);let p=()=>{e2&&e0({key:eZ,kind:e2}),e8.length>0&&e7({key:eZ,tasks:e8})};h?.();let m=null,g=async()=>{if(m){let e=m;m=null,await e$(e.prepared);return}ex(r)&&await t3()},x=[],v=()=>{for(let e of x)e.url?.startsWith("blob:")&&URL.revokeObjectURL(e.url)},y=()=>{if(0===x.length)return;let e=x.map(e=>e.id);ex(r)?(t6.current?.restore(x),t4.release(e,!1)):(v(),t4.release(e,!0)),x=[]},b=()=>{0!==x.length&&(v(),t4.release(x.map(e=>e.id),!0),x=[])},w=async(e,n)=>{let i=n instanceof Error?n:Error(e);throw await g(),ex(r)&&(xc.toast.error(e,{description:i.message}),R(s),p()),y(),i};try{({images:o,markers:u}=await t4.resolve(e.files))}catch(e){return await w("Attachment upload failed",e)}let _=o.length>0;!ev&&ex(r)&&t2(t1.current)&&(m=t1.current,t1.current=null),ex(r)&&(x=t6.current?.detach()??[],t4.retain(x.map(e=>e.id)));let S=async()=>ev?ev.id:(m||(ex(r)&&await t3(),m=await t5()),m.prepared.sessionId),k=a;if(i)try{k=(await t0(s,A,eW,await S())).trim()}catch(e){return await w("Paste upload failed",e)}if(k.length>2e3)try{let e=await eW(k,await S());k=`<vpaste path="${e.path}" size="${e.size}" />`}catch(e){return await w("Paste upload failed",e)}if(u.length>0&&(k=[k,...u].filter(Boolean).join("\n")),ex(r)&&(M([]),P(1)),_){let e=[];for(let r of(k&&e.push({type:"text",text:k}),o))e.push({type:"image",mediaType:r.mediaType,data:r.data});f=e}else f=k;if(O){let e="string"==typeof f?f:f.filter(e=>"text"===e.type).map(e=>e.text).join("\n");if(e.trim()){q.current===l&&ex(r)&&$(!0);let s=null;try{let r=await (0,aC.translateText)(e);r.error||(s=r.translatedText)}catch{s=null}finally{q.current===l&&$(!1)}if(null===s)return ex(r)&&(M(A),P(I)),await w("Translation failed",Error("Disable translation to send the original text."));f="string"==typeof f?s:f.map(e=>"text"===e.type?{...e,text:s}:e)}}if("schedule"===e2&&(c=f,f="string"==typeof c?c.length>0?`${c}
31
+
32
+ ${RB}`:RB:[...c,{type:"text",text:RB}]),"task"===e2&&(d=f,f="string"==typeof d?d.length>0?`${d}
33
+
34
+ ${R$}`:R$:[...d,{type:"text",text:R$}]),f=function(e,r){if(0===r.length)return e;let s=[`<vselected-tasks note="${RV("Tasks the user selected from the project's task list for this message, with their content as of selection. Act on what the user says about them. To change one, propose it with propose_task_update and its id; to file sub-tasks, pass its id as parent_task_id to propose_task. Never change a task unless the user asks. A task's existing direct sub-tasks are listed as <subtask> entries; read one in full with get_task when available. When you mention one to the user, link it as [title](#ref:task:<id>).")}">`,...r.map(e=>[`<task id="${RV(e.id)}" title="${RV(e.title)}" status="${e.status}" priority="${e.priority}">`,(e.description?.trim()||"(no description)").replace(/<\/(task|vselected-tasks)>/gi,"<\\/$1>"),...(e.subtasks??[]).map(e=>`<subtask id="${RV(e.id)}" title="${RV(e.title)}" status="${e.status}" />`),"</task>"].join("\n")),"</vselected-tasks>"].join("\n");return"string"==typeof e?e.length>0?`${e}
35
+
36
+ ${s}`:s:[...e,{type:"text",text:s}]}(f,e8),ev){let e;console.log(`[AgentConversation] handleSubmit: existing session ${ev.id}, status=${eb}`);try{e=await eP(f,void 0,ta.selectedIds)}catch(e){return await w("Failed to send message",e)}if(!1===e){if(ex(r)&&(R(s),p(),M(A),P(I)),y(),n)throw Error("Failed to send message");return}b()}else{t2(m??t1.current)||await g();let e=m?.prepared??null;m=null;let i=ta.selectedIds,a=e?await ez(e,f,i,ta.adoptInto):await eO(f,F,Z,i,ta.adoptInto);if(a)b(),console.log(`[AgentConversation] handleSubmit: started session ${a.session.id}`),eg(r)&&en(a.session.id);else if(ex(r)&&(R(s),p(),M(A),P(I)),y(),n)throw Error("Failed to start session")}}finally{q.current===l&&(q.current=null,$(!1),H(!1))}},{settings:t9}=(0,c1.useConversationSettings)();return e?(0,U.jsxs)("div",{className:"h-full flex flex-col min-h-0",style:{"--conv-font-size":`${t9.agentFontSize}px`},children:[(0,U.jsxs)("div",{className:"flex-shrink-0 flex items-center justify-between px-4 h-10 border-b border-border/60 bg-muted/20",children:[(0,U.jsxs)("div",{className:"flex items-center gap-2",children:[Y.length>1?(0,U.jsxs)(i3,{children:[(0,U.jsx)(i4,{asChild:!0,children:(0,U.jsxs)("button",{disabled:eS||"running"===eb&&ey.length>0,className:(0,e1.cn)("inline-flex items-center gap-1 rounded-md border bg-muted/50 px-2 py-0.5 text-xs font-medium transition-colors hover:bg-muted",(eS||"running"===eb&&ey.length>0)&&"opacity-50 cursor-not-allowed"),children:[(0,U.jsx)(Md,{type:K}),(0,U.jsx)(AX,{candidates:Y.map(e=>e.displayName),children:tb}),(0,U.jsx)(aa,{className:"h-3 w-3 text-muted-foreground"})]})}),(0,U.jsx)(i6,{align:"start",className:"min-w-[var(--radix-dropdown-menu-trigger-width)]",children:(0,U.jsx)(i9,{value:K,onValueChange:async e=>{if(!ev){e!==K&&Q(null),X(e);return}let r=await eV(e);r?xc.toast.error("Failed to switch agent",{description:r}):X(e)},children:Y.map(e=>(0,U.jsxs)(ae,{value:e.type,className:"text-xs pl-2 [&>span:first-child]:hidden data-[state=checked]:bg-accent data-[state=checked]:text-accent-foreground",children:[(0,U.jsx)(Md,{type:e.type}),(0,U.jsx)("span",{children:e.displayName})]},e.type))})})]}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(Md,{type:K,className:"h-4 w-4"}),(0,U.jsx)("span",{className:"text-sm font-medium",children:tb})]}),(0,U.jsx)(AQ,{models:Y.find(e=>e.type===K)?.models??[],widthCandidates:Y.flatMap(e=>e.models??[]),value:ev?ev.model??null:Z,onChange:ev?tm:Q,locked:null!=ev&&"running"===eb&&ey.length>0}),(0,U.jsx)(Mc,{mode:F,onModeChange:tp}),eh.length>=1&&o&&(0,U.jsx)(jD,{targets:eh,activeTarget:a?.agent_mode??"local",onTargetChange:o}),ev&&(C=ev.id.startsWith("remote-"),N="text-muted-foreground",E=(0,U.jsx)(dj,{className:"h-3 w-3"}),D="Disconnected",ek?(N="text-muted-foreground",E=(0,U.jsx)(aP,{className:"h-3 w-3 animate-spin"}),D="Checking for newer output..."):ew?C&&"connected"!==eC&&null!==eC?"reconnecting"===eC?(N="text-amber-500",E=(0,U.jsx)(AR,{className:"h-3 w-3 animate-pulse"}),D="Reconnecting..."):"disconnected"===eC&&(N="text-red-500",E=(0,U.jsx)(dj,{className:"h-3 w-3"}),D="Remote disconnected"):(N="text-green-500",E=(0,U.jsx)(AR,{className:"h-3 w-3"}),D="Connected"):th||(N="text-amber-500",E=(0,U.jsx)(AR,{className:"h-3 w-3 animate-pulse"}),D="Connecting..."),(0,U.jsx)(jQ,{label:D,children:(0,U.jsx)("span",{className:`flex items-center ${N}`,role:"img","aria-label":D,children:E})}))]}),(0,U.jsxs)("div",{className:"flex items-center gap-1",children:[e&&(0,U.jsx)(MR,{projectId:e,branch:r,sessionId:ev?.id??null,currentAgentType:K,providers:Y,shortcutEnabled:tX,onStarted:e=>b?.(e,tW)}),e&&(0,U.jsx)(Mx,{projectId:e,branch:r,currentSessionId:ev?.id??null,refreshKey:et,pendingTitleSessionId:es,aiTitleOverride:ei,onSwitch:e=>{u?.(e),i?.(e)},onDelete:(e,r)=>{if(e===ev?.id){let e=r[0];i?.(e?e.id:null)}}}),(0,U.jsx)(jQ,{label:"New Conversation (⌘⇧O / Ctrl+Shift+O)",children:(0,U.jsx)("span",{className:"inline-flex",children:(0,U.jsx)(a$.Button,{variant:"ghost",size:"icon",onClick:tJ,disabled:eS||!ev,className:"h-7 w-7","aria-label":"New Conversation",children:(0,U.jsx)(AA,{className:"h-3.5 w-3.5"})})})}),(0,U.jsxs)(a$.Button,{variant:"ghost",size:"sm",onClick:()=>eU(),disabled:"running"!==eb,className:"h-7 text-xs",children:[(0,U.jsx)(ce,{className:"h-3 w-3 mr-1"}),"Stop"]})]})]}),t$&&(0,U.jsxs)("div",{className:"flex items-center gap-2 px-4 py-1.5 border-b bg-muted/40 text-xs text-muted-foreground shrink-0","data-testid":"source-preparing-review",children:[(0,U.jsx)(aP,{className:"h-3 w-3 animate-spin shrink-0"}),(0,U.jsx)("span",{className:"flex-1 truncate",children:"Preparing review — summarizing this conversation and starting the reviewer"}),w&&(0,U.jsx)("button",{type:"button",className:"shrink-0 font-medium text-foreground/80 hover:text-foreground underline-offset-2 hover:underline",onClick:()=>w(t$.runId),children:"View"})]}),(0,U.jsxs)("div",{className:"flex-1 min-h-0 relative",children:[(0,U.jsxs)(cZ,{className:"h-full",initial:"instant",resize:tM?"smooth":"instant",children:[(0,U.jsx)(cQ,{className:(0,e1.cn)("gap-1 p-4 mx-auto w-full max-w-[1200px]",tz&&"min-h-full"),scrollClassName:"edge-scrollbar will-change-transform",children:tO?(0,U.jsx)(MA,{children:tH}):tB?(0,U.jsx)(MM,{error:tP?.error,children:tH}):tz?(0,U.jsx)("div",{className:"flex flex-1 flex-col items-center text-center before:grow-[382] before:content-[''] after:grow-[618] after:content-['']",children:eS||e&&!e_?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)("div",{className:"mx-auto w-12 h-12 rounded-xl bg-primary/10 flex items-center justify-center mb-4",children:(0,U.jsx)(Aw,{size:24,className:"text-primary/60"})}),(0,U.jsx)("h3",{className:"text-sm font-semibold mb-1 text-foreground",children:"Connecting to agent..."}),(0,U.jsx)("p",{className:"text-xs text-muted-foreground leading-relaxed",children:"Setting up the session for this worktree"})]}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)("div",{className:"mx-auto w-12 h-12 rounded-xl bg-primary/10 flex items-center justify-center mb-4",children:(0,U.jsx)(aA,{className:"h-6 w-6 text-primary/60"})}),(0,U.jsx)("h3",{className:"text-sm font-semibold mb-1 text-foreground",children:"Start a conversation"}),(0,U.jsx)("p",{className:"text-xs text-muted-foreground leading-relaxed",children:"Ask the agent to help you with coding tasks in this worktree"})]})}):(0,U.jsx)(M$.Provider,{value:{sendMessage:eP,messages:ey,providers:Y,acceptPlan:tg,permissionMode:ev?.permissionMode??F,agentType:ev?.agentType??K,sessionId:ev?.id??null,projectId:e,branch:r,target:ef,targetLabel:ep,openSchedule:x,openTask:v},children:(0,U.jsxs)("div",{className:"space-y-1 outline-none",ref:eo,tabIndex:-1,onKeyDown:el,children:[ev?.lifecycleState==="activation_uncertain"&&(0,U.jsxs)("div",{className:"flex items-start gap-2 p-3 mb-2 rounded-lg border border-amber-500/40 bg-amber-500/10 text-sm text-amber-700 dark:text-amber-400",children:[(0,U.jsx)(aR,{className:"h-4 w-4 mt-0.5 shrink-0"}),(0,U.jsx)("span",{children:"First message delivery could not be confirmed for this session. Check whether the agent actually responded before resending — a resend may duplicate the task."})]}),eA&&(0,U.jsx)("div",{className:"flex justify-center pb-3",children:(0,U.jsxs)(a$.Button,{type:"button",variant:"ghost",size:"sm",disabled:eM,onClick:()=>void eI(),children:[eM?(0,U.jsx)(aP,{className:"h-3.5 w-3.5 animate-spin"}):(0,U.jsx)(aa,{className:"h-3.5 w-3.5 rotate-180"}),"Load earlier turns"]})}),ey.map((e,r)=>e?.type==="turn_end"?(0,U.jsx)(Az,{durationMs:e.durationMs,outcome:e.outcome,emphasis:r===tA?"normal":"subtle",agentType:K,currentAgentName:tb,alternateProviders:tw,onBranch:e=>ty(e,te[r]??r),disabled:tx,showFinalize:r===tA&&tI?.status==="discussing",finalizeBusy:tU,onFinalize:tq,sendBack:t_&&(te[r]??r)>tS?{available:!tE&&ev?.branchedFromAvailable!==!1,sent:tk.has(te[r]??r),busy:tC===(te[r]??r),onSend:()=>void tR(te[r]??r,r)}:void 0},te[r]??r):(0,U.jsx)("div",{"data-message-idx":r,..."user"===e.type?{"data-user-msg-idx":r}:{},className:"scroll-mt-2",children:(0,U.jsx)(RX,{message:e,messageIndex:r,entryIndex:te[r]??r,streaming:"assistant"===e.type&&tM&&r===ey.length-1})},te[r]??r)),eS&&!ek&&(0,U.jsxs)("div",{className:"flex items-center gap-2 py-4 text-muted-foreground",children:[(0,U.jsx)(Aw,{className:"h-4 w-4"}),(0,U.jsx)("span",{className:"text-sm",children:"Connecting to agent..."})]})]})})}),(0,U.jsx)(c0,{}),(0,U.jsx)(Mb,{messageCount:ey.length,turnInFlight:tM,sessionId:ev?.id??null,firstEntryKey:ey.length>0?te[0]??0:null})]}),(0,U.jsx)(Mm,{messages:ey,contentRef:eo}),(0,U.jsx)(MS,{containerRef:eo,onQuote:tG})]}),(0,U.jsx)("div",{className:"flex-shrink-0 py-3 px-[14px]",children:(0,U.jsxs)("div",{className:"mx-auto w-full max-w-[1200px] px-4",children:[(0,U.jsx)(AK,{sessionId:tt,tasks:eE.tasks,turnParked:eE.turnParked,parkDeadlineAt:eE.parkDeadlineAt,canStopTasks:eE.canStopTasks,agentWorking:"running"===eb}),ej&&(0,U.jsxs)("div",{className:"flex items-center gap-2 p-3 mb-2 bg-red-500/10 rounded-lg text-red-500 text-sm",children:[(0,U.jsx)(aR,{className:"h-4 w-4 shrink-0"}),(0,U.jsx)("span",{className:"min-w-0 break-words",children:ej})]}),(0,U.jsxs)(Al,{onSubmit:t8,maxFileSize:0x1400000,onError:t7,skipAttachmentConversion:!0,className:"w-full",children:[(0,U.jsx)(Mz,{uploads:t4,workspaceKey:`${e}::${r}`,apiRef:t6}),(0,U.jsxs)("div",{className:"relative flex w-full flex-col",children:[ti&&(0,U.jsx)(A7,{granted:ta.granted,onRevoke:e=>ta.toggle(e,!1)}),(0,U.jsx)(Mr,{tasks:e8,onRemove:e=>e9(e,!1)}),O&&(0,U.jsx)("div",{className:"flex items-center pl-12 pr-2 pt-1.5 pb-0.5",children:(0,U.jsxs)("button",{type:"button",onClick:()=>B(!1),className:"inline-flex shrink-0 items-center gap-1.5 rounded-full bg-blue-500/10 text-blue-600 dark:text-blue-400 px-2.5 py-0.5 text-xs font-medium hover:bg-blue-500/20 transition-colors",children:[z?(0,U.jsx)(aP,{className:"size-3 animate-spin"}):(0,U.jsx)(AM,{className:"size-3"}),"Translate",(0,U.jsx)(rD,{className:"size-3"})]})}),e2&&(0,U.jsx)("div",{className:"flex items-center pl-12 pr-2 pt-1.5 pb-0.5",children:(0,U.jsxs)("button",{type:"button",onClick:()=>e0(null),className:"inline-flex shrink-0 items-center gap-1.5 rounded-full bg-blue-500/10 text-blue-600 dark:text-blue-400 px-2.5 py-0.5 text-xs font-medium hover:bg-blue-500/20 transition-colors",children:[e5?(0,U.jsx)(aM,{className:"size-3"}):(0,U.jsx)(Da,{className:"size-3"}),e5?"Schedule":"Add task",(0,U.jsx)(rD,{className:"size-3"})]})}),(0,U.jsxs)("div",{className:"flex w-full items-center",children:[(0,U.jsxs)(Af,{children:[(0,U.jsx)(Ap,{className:"ml-1"}),(0,U.jsxs)(Am,{children:[(0,U.jsx)(Ao,{label:"Add files"}),ti&&(0,U.jsx)(A6,{granted:ta.granted,onToggle:ta.toggle,sourceRemoteId:to}),(0,U.jsxs)(Ag,{role:"menuitemcheckbox","aria-checked":e5,onSelect:()=>e4("schedule"),children:[(0,U.jsx)(aM,{className:"mr-2 size-4"}),"Schedule",e5&&(0,U.jsx)(al.Check,{className:"ml-auto size-4"})]}),(0,U.jsxs)(Ag,{role:"menuitemcheckbox","aria-checked":e3,onSelect:()=>e4("task"),children:[(0,U.jsx)(Da,{className:"mr-2 size-4"}),"Add task",e3&&(0,U.jsx)(al.Check,{className:"ml-auto size-4"})]}),(0,U.jsx)(Mt,{projectId:e,selected:e8,onToggle:e9}),(0,U.jsxs)(Ag,{onSelect:()=>{B(!O)},children:[(0,U.jsx)(AM,{className:"mr-2 size-4"}),O?"Disable translation":"Translate"]})]})]}),(0,U.jsx)("div",{ref:ec,className:"contents",children:(0,U.jsx)(Ac,{value:T,onChange:e=>R(e.target.value),onPasteText:tQ,onKeyDown:ed.handleKeyDown,placeholder:e5?ev?"Send to turn this session's work into a schedule. You can add requirements and when it should run":"What should run, and how often? e.g. every weekday at 9am, run the tests and report failures":e3?ev?"Send to record follow-up work from this session as a task. You can say what to include":"What should be recorded as a task for later?":ev?"Ask the agent to help with your code...":"Type your first message to start...",className:"pr-12",style:{fontSize:"var(--conv-font-size, 14px)"}})}),(0,U.jsx)("div",{className:"pointer-events-none absolute bottom-0 right-2 flex items-center text-base md:text-sm",style:{fontSize:"var(--conv-font-size, 14px)",height:"calc(1lh + 1.5rem)"},children:(0,U.jsx)(Ax,{className:"pointer-events-auto",disabled:!T.trim()&&!(e2&&ev)&&!eS||z||W||t4.pending,status:W||z||t4.pending?"submitted":eS?"streaming":"ready"})})]})]})]})]})}),(0,U.jsx)(lJ,{open:null!==eJ,onOpenChange:e=>{e||eJ?.resolve(!1)},children:(0,U.jsxs)(l0,{children:[(0,U.jsxs)(l1,{children:[(0,U.jsx)(l5,{children:"Agent process limit reached"}),(0,U.jsxs)(l3,{children:["All ",eJ?.maxResidentAgentProcesses," resident agent processes for this workspace branch are running. Starting a new conversation will stop the least recently active running session in this branch."]})]}),(0,U.jsxs)(l2,{children:[(0,U.jsx)(l6,{children:"Cancel"}),(0,U.jsx)(l4,{onClick:()=>eJ?.resolve(!0),children:"Stop & start new"})]})]})})]}):(0,U.jsx)("div",{className:"h-full flex items-center justify-center text-muted-foreground",children:(0,U.jsxs)("div",{className:"text-center",children:[(0,U.jsx)("div",{className:"mx-auto w-10 h-10 rounded-xl bg-muted flex items-center justify-center mb-3",children:(0,U.jsx)(aA,{className:"h-5 w-5 text-muted-foreground/50"})}),(0,U.jsx)("p",{className:"text-sm",children:"Select a project to start coding"})]})})});function MX({runId:e,entry:r,title:s,onOpenSource:n}){let i,[a,o]=(0,V.useState)(null),[l,c]=(0,V.useState)(0);(0,V.useEffect)(()=>{if(r)return;let s=!1;return aC.api.getWorkflowRun(e).then(r=>{s||o({runId:e,attempt:l,run:r})}).catch(r=>{s||o({runId:e,attempt:l,error:r instanceof Error?r.message:String(r)})}),()=>{s=!0}},[r,e,l]);let d=a?.runId===e&&a.attempt===l?a:null,u=!d||"error"in d?null:d,h=r?.run??u?.run??null;return i=r?(0,U.jsx)(MA,{phase:"preparing"===r.run.status?"distilling":"starting"}):d&&"error"in d?(0,U.jsx)(MM,{error:d.error,title:"Could not read the review status",children:(0,U.jsx)(a$.Button,{variant:"outline",size:"sm",className:"mt-4",onClick:()=>c(e=>e+1),children:"Retry"})}):u?u.run?"failed"===u.run.status?(0,U.jsx)(MM,{error:u.run.error}):"cancelled"===u.run.status||"completed"===u.run.status?(0,U.jsx)(MI,{status:u.run.status}):(0,U.jsx)(MA,{phase:"starting"}):(0,U.jsx)(MI,{status:"gone"}):(0,U.jsxs)("div",{className:"text-center py-16",children:[(0,U.jsx)(Aw,{className:"h-6 w-6 mx-auto mb-4"}),(0,U.jsx)("h3",{className:"text-sm font-semibold mb-1 text-foreground",children:"Checking review status…"})]}),(0,U.jsxs)("div",{className:"flex flex-col h-full","data-testid":"preparing-review-view",children:[(0,U.jsxs)("div",{className:"flex items-center justify-between gap-2 px-3 py-2 border-b shrink-0",children:[(0,U.jsx)("span",{className:"text-sm font-medium truncate",title:s,children:s}),h&&(0,U.jsxs)(a$.Button,{variant:"ghost",size:"sm",className:"h-7 text-xs shrink-0",onClick:()=>n(h.source_session_id,h.branch),children:[(0,U.jsx)(lu.ArrowLeft,{className:"h-3 w-3 mr-1"}),"Source conversation"]})]}),(0,U.jsx)("div",{className:"flex-1 min-h-0 overflow-auto px-4",children:i})]})}function MY(e){return e.title?.trim()||"New Session"}async function MG(e){let r=await (0,aC.listAliveSessions)(e);return r.complete?r.sessions.map(r=>({id:r.id,projectId:e,branch:r.branch,title:MY(r),status:r.status,processAlive:!0})):"incomplete"}async function MJ(e,r){return 0===r.length?null:(await Promise.all(r.map(async r=>(await (0,aC.listBranchSessions)(e,r)).sessions.filter(e=>e.processAlive).map(s=>({id:s.id,projectId:e,branch:r,title:MY(s),status:s.status,processAlive:!0,updated_at:s.updated_at}))))).flat()}function MZ(e,r,s){return"live"===r&&s&&"live"!==e}let MQ=new Map,M0="preparing-review",M1={preparing:0,waiting_reviewer:1,waiting_feedback:2,discussing:3,sending_feedback:4,waiting_rereview:1,running_task:1,waiting_resume:1,completed:9,cancelled:9,failed:9};function M2(e){return 9===M1[e]}function M5(e){let r=Date.parse(e.updated_at);return(M1[e.status]??0)*1e13+(Number.isFinite(r)?r:0)}function M3(e){return{projectId:e,entries:new Map,tombstones:new Map}}function M4(e,r,s){let n=new Map(e.entries),i=new Map(e.tombstones);for(let e of r)n.delete(e),i.set(e,s+6e4);return{...e,entries:n,tombstones:i}}function M6(e,r,s,n){if(!e.projectId||r.project_id!==e.projectId)return e;let i=e.tombstones.get(r.id);if(void 0!==i&&i>s)return e;let a=e.entries.get(r.id);if(M2(r.status))return a?M4(e,[r.id],s):e;if(!a){if("preparing"!==r.status||!r.reviewer_session_id)return e;let i=new Map(e.entries);return i.set(r.id,{kind:M0,runId:r.id,projectId:r.project_id,branch:r.branch??null,reviewerSessionId:r.reviewer_session_id,sourceSessionId:r.source_session_id,run:r,version:M5(r),titleHint:n??null,insertedAt:s,appearedAt:null}),{...e,entries:i}}let o=M5(r);if(o<a.version)return e;let l=new Map(e.entries);return l.set(r.id,{...a,branch:r.branch??null,reviewerSessionId:r.reviewer_session_id??a.reviewerSessionId,run:r,version:o,titleHint:n??a.titleHint}),{...e,entries:l}}function M7(e,r,s){let n=null;for(let i of e.entries.values())null===i.appearedAt&&r.has(i.reviewerSessionId)&&(n??=new Map(e.entries)).set(i.runId,{...i,appearedAt:s});return n?{...e,entries:n}:e}function M8(e,r){let s=(e.titleHint??r??"").trim();return s&&"New Session"!==s?`Review - ${s}`:"Review"}let M9=Object.freeze({session:null,messages:[],status:"stopped",isConnected:!1,isInitialized:!1,isLoading:!1,error:null,workflowRunUpdate:null,turnState:{status:"idle",waitingFor:[]},streamEpoch:0,draft:""});function Ie(){return"localhost"===window.location.hostname&&"3000"===window.location.port?"http://localhost:5173":""}async function It(e,r){let s=await (0,aC.authFetch)(`${Ie()}/api/projects/${e}/chat-sessions`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({branch:r})});if(!s.ok)throw Error("Failed to create chat session");return s.json()}async function Ir(e,r){if(!(await (0,aC.authFetch)(`${Ie()}/api/chat-sessions/${e}/message`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:r})})).ok)throw Error("Failed to send message")}async function Is(e){if(!(await (0,aC.authFetch)(`${Ie()}/api/chat-sessions/${e}/stop`,{method:"POST"})).ok)throw Error("Failed to stop generation")}function In(e,r){return`chat:${e}:${r??""}`}let Ii=new Map,Ia=new Map;function Io(e,r){for(Ia.delete(e),Ia.set(e,r);Ia.size>20;){let e=Ia.keys().next().value;if(void 0===e)break;Ia.delete(e)}}let Il=new Map;function Ic(e){let r=Math.min(3e4,1e3*Math.pow(2,e));return r+r*Math.random()*.25}class Id{projectId;branch;key;state;listeners;active;epoch;ws;container;replaying;finished;reconnectTimer;stabilityTimer;silenceTimer;reconnectAttempt;shortLivedConnections;connectionStartedAt;lastStartFailed;tokenRetryAttempt;authRejects;authRejectedSocket;metadataWrites;constructor(e,r){this.projectId=e,this.branch=r,this.listeners=new Set,this.active=!1,this.epoch=0,this.ws=null,this.container={entries:[],status:"stopped"},this.replaying=!1,this.finished=!1,this.reconnectTimer=null,this.stabilityTimer=null,this.silenceTimer=null,this.reconnectAttempt=0,this.shortLivedConnections=0,this.connectionStartedAt=null,this.lastStartFailed=!1,this.tokenRetryAttempt=0,this.authRejects=0,this.authRejectedSocket=null,this.metadataWrites=0,this.subscribe=e=>(this.listeners.add(e),()=>{this.listeners.delete(e)}),this.getSnapshot=()=>this.state,this.onVisibilityChange=()=>{if("visible"!==document.visibilityState||!this.state.session?.id||this.finished)return;let e=this.ws;e&&e.readyState===WebSocket.OPEN&&e.close(4e3,"visibility-recovery")},this.onOnline=()=>{if(!this.state.session?.id||this.finished)return;let e=this.ws;e&&e.readyState!==WebSocket.CLOSED&&e.readyState!==WebSocket.CLOSING||(this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null),this.reconnectAttempt=0,this.tokenRetryAttempt=0,this.connect(!0))},this.setDraft=e=>{e!==this.state.draft&&(Il.set(this.key,e),this.set({draft:e}))},this.setEventListening=async e=>{let r=this.state.session;r&&(await aC.api.setChatEventListening(r.id,e),this.metadataWrites+=1,this.state.session?.id===r.id&&this.adoptSession({...r,eventListeningEnabled:e}))},this.sendMessage=async e=>{let r=this.state.session?.id,s=e.trim();if(r&&s)try{await Ir(r,s)}catch(r){let e=r instanceof Error?r.message:"Failed to send message";this.set({error:e}),xc.toast.error("Failed to send message",{description:e})}},this.stopGeneration=async()=>{let e=this.state.session?.id;if(e)try{await Is(e)}catch(e){console.error("[ChatSession] Failed to stop generation:",e)}},this.restartSession=async()=>{let e=this.state.session?.id;if(e)try{await aC.api.resetChatSession(e),this.container={entries:[],status:"stopped"},this.flush()}catch(e){console.error("[ChatSession] Failed to reset session:",e),xc.toast.error("Failed to start new conversation")}},this.key=In(e,r);const s=Ia.get(this.key),n=Il.get(this.key)??"",i=s?.session??Ii.get(this.key)??null;this.state=s?{...M9,session:i,messages:s.messages,status:s.status,isInitialized:!0,draft:n}:{...M9,session:i,draft:n}}subscribe;getSnapshot;set(e){for(let r of(this.state={...this.state,...e},this.listeners))r()}start(){this.active||(this.active=!0,this.finished=!1,"undefined"!=typeof document&&(document.addEventListener("visibilitychange",this.onVisibilityChange),window.addEventListener("online",this.onOnline)),this.startSession())}stop(){if(!this.active)return;this.active=!1,this.epoch+=1,"undefined"!=typeof document&&(document.removeEventListener("visibilitychange",this.onVisibilityChange),window.removeEventListener("online",this.onOnline));let e=this.ws;if(this.ws=null,e)try{e.close(1e3,"branch-switch")}catch{}this.clearTimers(),this.connectionStartedAt=null,this.state.isConnected&&this.set({isConnected:!1})}clearTimers(){this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null),this.stabilityTimer&&(clearTimeout(this.stabilityTimer),this.stabilityTimer=null),this.clearSilenceTimer()}async startSession(){if(!this.active)return;let e=this.epoch;this.lastStartFailed=!1,this.set({error:null});let r=Ii.get(this.key);if(r){this.set({session:r}),this.connect(),this.refreshSessionMetadata(e);return}this.set({isLoading:!0});try{let{session:r,messages:s}=await It(this.projectId,this.branch);if(e!==this.epoch)return;Ii.set(this.key,r),this.set({session:r,status:r.status,messages:s??[],isInitialized:!0}),this.connect()}catch(r){if(e!==this.epoch)return;this.lastStartFailed=!0,this.set({error:r instanceof Error?r.message:"Failed to start session"})}finally{e===this.epoch&&this.set({isLoading:!1})}}async refreshSessionMetadata(e){let r=this.metadataWrites;try{let{session:s,messages:n}=await It(this.projectId,this.branch);if(e!==this.epoch||r!==this.metadataWrites||s.id!==this.state.session?.id)return;this.adoptSession(s),this.state.isInitialized||this.set({messages:n??[],isInitialized:!0})}catch{}}adoptSession(e){Ii.set(this.key,e);let r=Ia.get(this.key);r&&r.session.id===e.id&&Io(this.key,{...r,session:e}),this.set({session:e})}connect(e=!1){if(!this.active||this.ws&&(this.ws.readyState===WebSocket.OPEN||this.ws.readyState===WebSocket.CONNECTING))return;let r=this.epoch;Promise.race([(0,aC.getFreshToken)(e?{skipCache:!0}:void 0),new Promise(e=>setTimeout(e,5e3))]).catch(()=>void 0).then(()=>{if(r===this.epoch&&this.active){if(!(0,aC.hasUsableStreamToken)()){let e=Ic(Math.min(this.tokenRetryAttempt,4));this.tokenRetryAttempt++,this.reconnectTimer&&clearTimeout(this.reconnectTimer),this.reconnectTimer=setTimeout(()=>{this.reconnectTimer=null,this.state.session?.id&&!this.finished&&this.connect(!0)},e);return}this.tokenRetryAttempt=0,this.openSocket()}})}openSocket(){if(this.ws&&(this.ws.readyState===WebSocket.OPEN||this.ws.readyState===WebSocket.CONNECTING))return;let e=this.state.session?.id;if(!e)return;this.container={entries:[],status:"stopped"},this.finished=!1,this.replaying=!0;let r=new WebSocket((0,aC.getWebSocketUrl)(`/api/chat-sessions/${e}/stream`));this.ws=r;let s=()=>this.ws===r;r.onopen=()=>{s()&&(this.set({isConnected:!0,error:null}),this.connectionStartedAt=Date.now(),this.armSilenceTimer(r),this.stabilityTimer&&clearTimeout(this.stabilityTimer),this.stabilityTimer=setTimeout(()=>{this.reconnectAttempt=0,this.shortLivedConnections=0},5e3))},r.onmessage=e=>{if(s()){this.armSilenceTimer(r);try{this.handleFrame(r,JSON.parse(e.data))}catch(e){console.error("[ChatSession] Failed to parse message:",e)}}},r.onclose=e=>{if(!s())return;this.ws=null,this.set({isConnected:!1}),this.clearSilenceTimer(),this.stabilityTimer&&(clearTimeout(this.stabilityTimer),this.stabilityTimer=null);let n=4e3===e.code,i=this.connectionStartedAt?Date.now()-this.connectionStartedAt:0;if(this.connectionStartedAt=null,this.authRejectedSocket===r){if(this.authRejectedSocket=null,this.finished)return;let e=Ic(Math.min(this.authRejects-1,4));this.reconnectTimer=setTimeout(()=>{this.reconnectTimer=null,this.state.session?.id&&!this.finished&&this.connect(!0)},e);return}if(!n&&i>0&&i<5e3){if(this.shortLivedConnections++,this.shortLivedConnections>=3)return this.lastStartFailed?void this.set({error:"Unable to connect to remote server. Please check the server configuration."}):(Ii.delete(this.key),this.reconnectAttempt=0,this.shortLivedConnections=0,this.set({session:null,error:null}),void this.startSession())}else i>=5e3&&(this.shortLivedConnections=0);if(this.finished||1e3===e.code)return;if(this.reconnectAttempt>=10)return void this.set({error:"Unable to connect to server."});let a=Ic(this.reconnectAttempt);this.reconnectAttempt++,this.reconnectTimer=setTimeout(()=>{this.reconnectTimer=null,this.state.session?.id&&!this.finished&&this.connect(!0)},a)},r.onerror=()=>{}}handleFrame(e,r){if("error"in r||(this.authRejects=0),!("keepalive"in r)){if("JsonPatch"in r){var s,n;this.container=(s=this.container,n=r.JsonPatch,Eo(s,e=>{for(let r of n){let{op:s,path:n,value:i}=r;if("/entries"===n&&"replace"===s&&i?.type==="ENTRY"&&i.content?.type==="system"&&i.content?.content==="__CLEAR_ALL__"){e.entries=[];continue}if(n.startsWith("/entries/")){let r=parseInt(n.replace("/entries/",""),10);if(isNaN(r)||i?.type!=="ENTRY")continue;switch(s){case"add":for(;e.entries.length<=r;)e.entries.push(null);e.entries[r]=i.content;break;case"replace":r<e.entries.length&&(e.entries[r]=i.content);break;case"remove":r<e.entries.length&&e.entries.splice(r,1)}}else"/status"===n&&i?.type==="STATUS"&&(e.status=i.content)}})),this.replaying||this.flush();return}if("Ready"in r){this.replaying=!1,this.flush(),this.set({isInitialized:!0,streamEpoch:this.state.streamEpoch+1});return}if("finished"in r){this.finished=!0,e.close(1e3,"finished");return}if("WorkflowRunUpdated"in r)return void this.set({workflowRunUpdate:r.WorkflowRunUpdated});if("TurnState"in r)return void this.set({turnState:r.TurnState});if("error"in r){if((0,aC.isStreamAuthError)(r.error)){this.authRejectedSocket=e,this.authRejects++,this.authRejects>=aC.STREAM_AUTH_REJECTS_BEFORE_ERROR&&this.set({error:aC.STREAM_AUTH_FAILED_MESSAGE});return}this.set({error:r.error}),"Session not found"===r.error&&(Ii.delete(this.key),Ia.delete(this.key),this.finished=!0)}}}flush(){let e=this.container.entries.filter(Boolean),r=this.container.status;this.set({messages:e,status:r}),this.state.session&&Io(this.key,{session:this.state.session,messages:e,status:r})}clearSilenceTimer(){this.silenceTimer&&(clearTimeout(this.silenceTimer),this.silenceTimer=null)}armSilenceTimer(e){this.silenceTimer&&clearTimeout(this.silenceTimer),this.silenceTimer=setTimeout(()=>{this.silenceTimer=null,e.readyState===WebSocket.OPEN&&(console.warn(`[ChatSession] No frames for 95000ms — assuming dead socket, forcing reconnect`),this.replaceSilentSocket(e))},95e3)}replaceSilentSocket(e){if(this.ws===e){this.ws=null,this.set({isConnected:!1}),this.stabilityTimer&&(clearTimeout(this.stabilityTimer),this.stabilityTimer=null),this.connectionStartedAt=null;try{e.close(4e3,"silence watchdog")}catch{}this.finished||this.connect(!0)}}onVisibilityChange;onOnline;setDraft;setEventListening;sendMessage;stopGeneration;restartSession}let Iu=()=>()=>{},Ih=()=>M9,If=async()=>{},Ip=()=>{};function Im(e){return e&&"object"==typeof e&&"string"==typeof e.goal&&Array.isArray(e.completionCriteria)&&e.completionCriteria.every(e=>"string"==typeof e)&&Array.isArray(e.steps)&&e.steps.every(e=>e&&"string"==typeof e.id&&"string"==typeof e.title&&["pending","in_progress","completed","failed","skipped"].includes(e.status)&&(void 0===e.result||"string"==typeof e.result))&&(void 0===e.planId||"string"==typeof e.planId)&&(void 0===e.waitingOn||"string"==typeof e.waitingOn)?e:null}function Ig(e){try{let r=JSON.parse(e);return r.success?Im(r.plan):null}catch{return null}}let Ix={pending:i5,in_progress:aP,completed:os,failed:oi,skipped:(0,rE.default)("circle-minus",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 12h8",key:"1wcyev"}]])},Iv={pending:"Pending",in_progress:"In progress",completed:"Completed",failed:"Failed",skipped:"Skipped"};function Iy({plan:e,draft:r=!1}){let s=e.steps.filter(e=>"completed"===e.status||"skipped"===e.status).length;return(0,U.jsxs)("div",{className:"rounded-lg border bg-muted/20 p-3 space-y-3 text-sm",children:[(0,U.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,U.jsx)("span",{className:"font-medium break-words",children:e.goal}),(0,U.jsx)("span",{className:"shrink-0 text-xs text-muted-foreground",children:r?"Plan draft":`${s}/${e.steps.length}`})]}),e.waitingOn&&!r&&(0,U.jsxs)("div",{className:"rounded-md border border-amber-500/30 bg-amber-500/10 px-2 py-1.5 text-xs text-amber-700 dark:text-amber-300 break-words",children:["Waiting for you: ",e.waitingOn]}),(0,U.jsxs)("div",{className:"text-xs text-muted-foreground space-y-1",children:[(0,U.jsx)("div",{className:"font-medium",children:"Completion criteria"}),e.completionCriteria.map((e,r)=>(0,U.jsxs)("div",{className:"break-words",children:["• ",e]},r))]}),(0,U.jsx)("ol",{className:"space-y-2",children:e.steps.map(e=>{let r=Ix[e.status];return(0,U.jsxs)("li",{className:"flex gap-2",children:[(0,U.jsx)(r,{"aria-label":Iv[e.status],className:`mt-0.5 h-4 w-4 shrink-0 ${"in_progress"===e.status?"animate-spin text-primary":"completed"===e.status?"text-emerald-600":"failed"===e.status?"text-destructive":"text-muted-foreground"}`}),(0,U.jsxs)("div",{className:"min-w-0",children:[(0,U.jsx)("div",{className:"break-words",children:e.title}),e.result&&(0,U.jsx)("div",{className:"text-xs text-muted-foreground whitespace-pre-wrap break-words",children:e.result})]})]},e.id)})}),r&&(0,U.jsx)("p",{className:"text-xs text-muted-foreground",children:"To change this plan, decline it and describe the changes in chat."})]})}function Ib({sessionId:e,approvalId:r,tool:s,input:n,resolved:i,embedded:a=!1}){let[o,l]=(0,V.useState)(null),c="setPlan"===s?Im(n):null,[d,u]=(0,V.useState)(null),h=function(e){if(null!==e&&"object"==typeof e){if("string"==typeof e.message)return e.message;if("string"==typeof e.prompt)return e.prompt}return JSON.stringify(e)}(n),f=async s=>{if(!o&&!i){l(s?"approve":"deny"),u(null);try{await aC.api.chatToolApproval(e,r,s)}catch{u("Could not submit your decision. Please try again.")}finally{l(null)}}};return(0,U.jsx)("div",{className:a?"@container/approval min-w-0":"@container/approval min-w-0 mx-4 my-1",children:(0,U.jsxs)("div",{className:a?"space-y-2":"rounded-lg border border-amber-500/30 bg-amber-500/5 p-3 space-y-2",children:[(0,U.jsxs)("div",{className:"flex items-center gap-2",children:[(0,U.jsx)(aA,{className:"h-3.5 w-3.5 text-amber-500 shrink-0"}),(0,U.jsxs)("span",{className:"text-xs font-medium text-amber-600 dark:text-amber-400",children:["Approval needed · ","setPlan"===s?"Review task plan":"spawnAgentSession"===s?"Start a new coding agent":"Send to the coding agent"]})]}),c?(0,U.jsx)(Iy,{plan:c,draft:!0}):(0,U.jsx)("pre",{className:"bg-muted/50 p-2 rounded overflow-x-auto max-w-full whitespace-pre-wrap break-all text-foreground/80",style:{fontSize:"var(--conv-font-size, 12px)"},children:h}),d&&(0,U.jsx)("p",{role:"alert",className:"text-xs text-destructive",children:d}),i?(0,U.jsxs)(rG,{variant:"default",className:"approved"===i?"bg-green-600 hover:bg-green-700 text-white":"bg-red-600 hover:bg-red-700 text-white",children:["approved"===i?(0,U.jsx)(os,{className:"h-3 w-3 mr-1"}):(0,U.jsx)(oi,{className:"h-3 w-3 mr-1"}),c?"approved"===i?"Plan confirmed":"Plan declined — describe changes in chat":"approved"===i?"Approved — sent.":"Denied — not sent."]}):(0,U.jsxs)("div",{className:c?"grid grid-cols-1 gap-2 @min-[24rem]/approval:grid-cols-2":"flex flex-wrap gap-2",children:[(0,U.jsxs)(a$.Button,{onClick:()=>f(!0),disabled:null!==o,className:"h-auto min-h-8 min-w-0 whitespace-normal py-1.5 bg-green-600 hover:bg-green-700 text-white",size:"sm",children:["approve"===o?(0,U.jsx)(aP,{className:"h-3.5 w-3.5 mr-1 animate-spin"}):(0,U.jsx)(os,{className:"h-3.5 w-3.5 mr-1"}),c?"Confirm and execute":"Approve"]}),(0,U.jsxs)(a$.Button,{onClick:()=>f(!1),disabled:null!==o,variant:"destructive",className:"h-auto min-h-8 min-w-0 whitespace-normal py-1.5",size:"sm",children:["deny"===o?(0,U.jsx)(aP,{className:"h-3.5 w-3.5 mr-1 animate-spin"}):(0,U.jsx)(oi,{className:"h-3.5 w-3.5 mr-1"}),c?"Decline and revise":"Deny"]})]})]})})}let Iw="[Plan Stalled]",I_="[Commander Stalled]",IS="[Plan Continuation]",Ik=e=>e.steps.length>0&&e.steps.every(e=>"completed"===e.status||"skipped"===e.status);function Ij({task:e,sessionId:r}){let{plan:s,approval:n}=e,i=(0,V.useId)(),a=s.steps.filter(e=>"completed"===e.status||"skipped"===e.status).length,o=!n&&s.steps.length>0&&a===s.steps.length,[l,c]=(0,V.useState)(null),d=l?.completed===o?l.expanded:!o,u=s.steps.find(e=>"in_progress"===e.status),h=s.steps.find(e=>"failed"===e.status),f=s.steps.find(e=>"pending"===e.status),p=n&&!n.resolved,m=!!e.stalled&&!o,g=p?"Needs confirmation":n?.resolved==="denied"?"Plan declined":n?.resolved==="approved"?"Confirmed":o?"Completed":m?"Stalled · send a message to continue":s.waitingOn?`Waiting for you: ${s.waitingOn}`:u?u.title:h?`Failed \xb7 ${h.title}`:f?`Next: ${f.title}`:"Task plan",x=p||n?.resolved==="denied"||h||m||s.waitingOn?ou:n?i5:o?os:u?aP:i5;return(0,U.jsxs)("section",{"aria-label":"Current task plan",className:"mb-2 overflow-hidden rounded-lg border bg-muted/20",children:[(0,U.jsxs)("button",{type:"button",className:"flex w-full items-center gap-2 px-3 py-2 text-left hover:bg-muted/50","aria-label":d?"Collapse task plan":"Expand task plan","aria-expanded":d,"aria-controls":i,onClick:()=>c({completed:o,expanded:!d}),children:[d?(0,U.jsx)(aa,{className:"h-3.5 w-3.5 shrink-0"}):(0,U.jsx)(i2,{className:"h-3.5 w-3.5 shrink-0"}),(0,U.jsx)(x,{className:`h-3 w-3 shrink-0 ${x===aP?"animate-spin":""} ${p||m||s.waitingOn?"text-amber-500":o?"text-emerald-600":h?"text-destructive":""}`}),(0,U.jsx)("span",{className:"min-w-0 flex-1 truncate text-xs font-medium",title:s.goal,children:s.goal}),(0,U.jsx)("span",{className:"max-w-[45%] truncate text-xs text-muted-foreground","aria-live":"polite",title:g,children:g}),(0,U.jsxs)("span",{className:"shrink-0 text-xs text-muted-foreground",children:[a,"/",s.steps.length]})]}),d&&(0,U.jsx)("div",{id:i,className:"max-h-[min(16rem,35dvh)] overflow-y-auto overscroll-contain border-t p-2",children:n?(0,U.jsx)(Ib,{sessionId:r,approvalId:n.approvalId,tool:"setPlan",input:n.input,resolved:n.resolved,embedded:!0},n.approvalId):(0,U.jsx)(Iy,{plan:s})})]})}let IC={key:"readDocs",label:"Docs to read every session",multiline:!0,placeholder:"AGENTS.md\ndocs/design.md\nOn conflicts, docs/design.md wins.",hint:"One per line; say which wins on a conflict."},IN={kind:"plan",label:"Plan file",description:"Work through a step-by-step plan in the repo, one step per session: implement, verify, commit. The loop keeps track of which steps are done.",fields:[{key:"planFile",label:"Plan file",placeholder:"docs/implementation-plan.md",hint:"Any numbered list of steps works; nothing in the file has to be ticked."},IC],defaults:{planFile:"docs/implementation-plan.md",readDocs:""},handoffByDefault:!0},IE={kind:"custom",label:"Write my own",description:"Say in your own words where the items come from; the rest of the instruction — one item per session, verify, commit, report — is generated as for a plan.",fields:[{key:"source",label:"Where items come from",required:!0,multiline:!0,placeholder:"Each error `pnpm lint` reports.\nOr: each file in todo/; move it to done/ when finished.",hint:"How a session finds the next item, and how a finished one drops out of the list. Sessions remember nothing of each other."},IC],defaults:{source:"",readDocs:""},handoffByDefault:!1},ID=[IN,IE];function IT(e){return"plan"===e?IN:IE}function IR(e){return(e??"").split(/\r?\n/).map(e=>e.trim()).filter(Boolean)}let IA=(e,r="")=>e.map(e=>`${r}- ${e}`).join("\n"),IM=e=>`- The loop records which ${e}s earlier sessions completed and lists them at the top of this message ("已完成的项"). No list means no ${e} has been recorded yet — this is the first session, or a restart.`,II="do not repeat an approach that already failed.",IP="- Also run the project's own checks every session — typecheck, tests, lint, whatever its docs or scripts define.",IF=e=>`- A threshold or parameter ${e} does not specify is not a blocker: pick a defensible default, keep it in one configurable place (a constants module or config), note the value and the reason in the commit body, and carry on.`,IL="- Something only a human can provide blocks the way (secrets, credentials, external accounts, a decision only a person can make): commit as usual, then end with `Status: blocked` and say exactly what is needed and where it goes (which environment variable or file). Do not work around it, do not fake secrets, and never write secrets into the repository.";function IO(e,r){var s;let n,i,a,o;return"plan"===e?(s="planFile",n=r[s]?.trim()||IN.defaults[s]||"",i=IR(r.readDocs),(a=[]).push(`You are implementing this project by following the plan in \`${n}\`. Each session completes exactly ONE step: implement it, verify it, commit it, then stop.`),o=[`- \`${n}\` — the plan, a sequence of numbered steps.`,IM("step")],i.length&&o.push(`- Also read these every session:
37
+ ${IA(i," ")}`),a.push(`## 1. Read first
38
+
39
+ ${o.join("\n")}`),a.push(`## 2. Pick the step
40
+
41
+ Go through the steps in order and pick the first one that is NOT in the completed list and whose dependencies are all done. Do only that one; do not start later steps early.
42
+ Before you change anything, check whether the step is in fact already done — an earlier session may have finished it without the loop recording it (a restart, an interrupted session), or the plan file may already mark it done. If its acceptance criteria are met and its verification passes, do not redo it: report it as this session's item (section 7) and stop.
43
+ If the step was attempted before and left unfinished, find out why before you start, and ${II}`),a.push(`## 3. Implement
44
+
45
+ - Before changing anything, read the design sections the step references and the existing code around it. Implement what is written, reuse the existing abstractions, and do not build a parallel one.
46
+ - Change only what is in scope for this step; the main branch must always build and run.`),a.push(["## 4. Verify\n\nMeet every acceptance criterion of the step, and actually RUN the verification — do not just claim it passes.\n",IP,"- If the environment truly cannot satisfy a check, use the fallback the plan gives, and say which check, why, and when it will be made up — in your final message and in the commit message.",IF("the plan")].join("\n")),a.push("## 5. Mark it done\n\nThe loop records completion from the `Item:` line of your final message (section 7); you do not have to edit the plan for that.\nIf the plan file itself tracks per-step status — a checkbox, a status line, a pass-condition flag — update that step's entry in the file's own convention once the criteria are really met. Otherwise leave the plan file alone.\nIf you cannot finish the step, do not report it as done; say why in your final message."),a.push("## 6. Commit\n\nCommit everything from this session — the code, and the plan file if you updated it — in ONE git commit:\n- Title like `<step number>: <summary>`.\n- Body: what was done, the key decisions, and the verification commands actually run with their results.\n\nThe session is not over until the commit is made. Do not push."),a.push(["## 7. Report\n\n- Every step in the plan is done (none left outside the completed list): end with `Status: done`.",IL,"- Otherwise: end with `Status: continue`, set `Item:` to the step number, and `Remaining:` to the number of steps still not done."].join("\n")),a.join("\n\n")):function(e){let r=IR(e.source);if(!r.length)return"";let s=IR(e.readDocs),n=[];n.push("You are working through a list of items, one per session. Each session handles exactly ONE item: handle it, verify it, commit it, then stop.");let i=[`- Where the items come from:
47
+ ${r.map(e=>` > ${e}`).join("\n")}`,IM("item")];return s.length&&i.push(`- Also read these every session:
48
+ ${IA(s," ")}`),n.push(`## 1. Read first
49
+
50
+ ${i.join("\n")}`),n.push(`## 2. Pick the item
51
+
52
+ Find the items as described above and pick the first one that is NOT in the completed list. Do only that one.
53
+ Before you change anything, check whether it is in fact already handled — an earlier session may have finished it without the loop recording it (a restart, an interrupted session). If it is, do not redo it: report it as this session's item (section 7) and stop.
54
+ If the item was attempted before and left unfinished, find out why before you start, and ${II}`),n.push("## 3. Handle it\n\n- Before changing anything, read the code and docs around the item. Reuse the existing abstractions, and do not build a parallel one.\n- Change only what this item needs; the main branch must always build and run."),n.push(["## 4. Verify\n\nMake sure the item is really handled, and actually RUN whatever shows it — do not just claim it works.\n",IP,IF("the item's description")].join("\n")),n.push("## 5. Mark it done\n\nThe loop records completion from the `Item:` line of your final message (section 7).\nIf the description of where the items come from says how a finished item is marked (moved, ticked, closed …), do that once the item is really handled. Otherwise leave the source alone.\nIf you cannot finish the item, do not report it as done; say why in your final message."),n.push("## 6. Commit\n\nIf this session changed files in the repository, commit them in ONE git commit:\n- Title like `<item>: <summary>`.\n- Body: what was done, the key decisions, and the verification commands actually run with their results.\n\nIf nothing in the repository changed, there is nothing to commit. Do not push."),n.push(["## 7. Report\n\n- No item is left to pick (every item is in the completed list or already handled): end with `Status: done`.",IL,"- Otherwise: end with `Status: continue`, set `Item:` to a short name for this item that a later session will recognize in the completed list, and `Remaining:` to the number of items still left, if you can tell."].join("\n")),n.join("\n\n")}(r)}let IB=e=>`loop-draft:${e}`,Iz=(0,V.createContext)({markReviewRunRead:()=>{}}),I$=Iz.Provider,IW=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],IH=new Set(IW),IU=(e,r,s)=>s>r?r:s<e?e:s,IV={test:e=>"number"==typeof e,parse:parseFloat,transform:e=>e},Iq={...IV,transform:e=>IU(0,1,e)},IK={...IV,default:1},IX=e=>Math.round(1e5*e)/1e5,IY=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu,IG=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,IJ=(e,r)=>s=>!!("string"==typeof s&&IG.test(s)&&s.startsWith(e)||r&&null!=s&&Object.prototype.hasOwnProperty.call(s,r)),IZ=(e,r,s)=>n=>{if("string"!=typeof n)return n;let[i,a,o,l]=n.match(IY);return{[e]:parseFloat(i),[r]:parseFloat(a),[s]:parseFloat(o),alpha:void 0!==l?parseFloat(l):1}},IQ={...IV,transform:e=>Math.round(IU(0,255,e))},I0={test:IJ("rgb","red"),parse:IZ("red","green","blue"),transform:({red:e,green:r,blue:s,alpha:n=1})=>"rgba("+IQ.transform(e)+", "+IQ.transform(r)+", "+IQ.transform(s)+", "+IX(Iq.transform(n))+")"},I1={test:IJ("#"),parse:function(e){let r="",s="",n="",i="";return e.length>5?(r=e.substring(1,3),s=e.substring(3,5),n=e.substring(5,7),i=e.substring(7,9)):(r=e.substring(1,2),s=e.substring(2,3),n=e.substring(3,4),i=e.substring(4,5),r+=r,s+=s,n+=n,i+=i),{red:parseInt(r,16),green:parseInt(s,16),blue:parseInt(n,16),alpha:i?parseInt(i,16)/255:1}},transform:I0.transform},I2=e=>({test:r=>"string"==typeof r&&r.endsWith(e)&&1===r.split(" ").length,parse:parseFloat,transform:r=>`${r}${e}`}),I5=I2("deg"),I3=I2("%"),I4=I2("px"),I6=I2("vh"),I7=I2("vw"),I8={...I3,parse:e=>I3.parse(e)/100,transform:e=>I3.transform(100*e)},I9={test:IJ("hsl","hue"),parse:IZ("hue","saturation","lightness"),transform:({hue:e,saturation:r,lightness:s,alpha:n=1})=>"hsla("+Math.round(e)+", "+I3.transform(IX(r))+", "+I3.transform(IX(s))+", "+IX(Iq.transform(n))+")"},Pe={test:e=>I0.test(e)||I1.test(e)||I9.test(e),parse:e=>I0.test(e)?I0.parse(e):I9.test(e)?I9.parse(e):I1.parse(e),transform:e=>"string"==typeof e?e:e.hasOwnProperty("red")?I0.transform(e):I9.transform(e),getAnimatableNone:e=>{let r=Pe.parse(e);return r.alpha=0,Pe.transform(r)}},Pt=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu,Pr="number",Ps="color",Pn=/var\s*\(\s*--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)|#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\)|-?(?:\d+(?:\.\d+)?|\.\d+)/giu;function Pi(e){let r=e.toString(),s=[],n={color:[],number:[],var:[]},i=[],a=0,o=r.replace(Pn,e=>(Pe.test(e)?(n.color.push(a),i.push(Ps),s.push(Pe.parse(e))):e.startsWith("var(")?(n.var.push(a),i.push("var"),s.push(e)):(n.number.push(a),i.push(Pr),s.push(parseFloat(e))),++a,"${}")).split("${}");return{values:s,split:o,indexes:n,types:i}}function Pa(e){return Pi(e).values}function Po(e){let{split:r,types:s}=Pi(e),n=r.length;return e=>{let i="";for(let a=0;a<n;a++)if(i+=r[a],void 0!==e[a]){let r=s[a];r===Pr?i+=IX(e[a]):r===Ps?i+=Pe.transform(e[a]):i+=e[a]}return i}}let Pl=e=>"number"==typeof e?0:Pe.test(e)?Pe.getAnimatableNone(e):e,Pc={test:function(e){return isNaN(e)&&"string"==typeof e&&(e.match(IY)?.length||0)+(e.match(Pt)?.length||0)>0},parse:Pa,createTransformer:Po,getAnimatableNone:function(e){let r=Pa(e);return Po(e)(r.map(Pl))}},Pd=new Set(["brightness","contrast","saturate","opacity"]);function Pu(e){let[r,s]=e.slice(0,-1).split("(");if("drop-shadow"===r)return e;let[n]=s.match(IY)||[];if(!n)return e;let i=s.replace(n,""),a=+!!Pd.has(r);return n!==s&&(a*=100),r+"("+a+i+")"}let Ph=/\b([a-z-]*)\(.*?\)/gu,Pf={...Pc,getAnimatableNone:e=>{let r=e.match(Ph);return r?r.map(Pu).join(" "):e}},Pp={...IV,transform:Math.round},Pm={borderWidth:I4,borderTopWidth:I4,borderRightWidth:I4,borderBottomWidth:I4,borderLeftWidth:I4,borderRadius:I4,borderTopLeftRadius:I4,borderTopRightRadius:I4,borderBottomRightRadius:I4,borderBottomLeftRadius:I4,width:I4,maxWidth:I4,height:I4,maxHeight:I4,top:I4,right:I4,bottom:I4,left:I4,inset:I4,insetBlock:I4,insetBlockStart:I4,insetBlockEnd:I4,insetInline:I4,insetInlineStart:I4,insetInlineEnd:I4,padding:I4,paddingTop:I4,paddingRight:I4,paddingBottom:I4,paddingLeft:I4,paddingBlock:I4,paddingBlockStart:I4,paddingBlockEnd:I4,paddingInline:I4,paddingInlineStart:I4,paddingInlineEnd:I4,margin:I4,marginTop:I4,marginRight:I4,marginBottom:I4,marginLeft:I4,marginBlock:I4,marginBlockStart:I4,marginBlockEnd:I4,marginInline:I4,marginInlineStart:I4,marginInlineEnd:I4,fontSize:I4,backgroundPositionX:I4,backgroundPositionY:I4,rotate:I5,rotateX:I5,rotateY:I5,rotateZ:I5,scale:IK,scaleX:IK,scaleY:IK,scaleZ:IK,skew:I5,skewX:I5,skewY:I5,distance:I4,translateX:I4,translateY:I4,translateZ:I4,x:I4,y:I4,z:I4,perspective:I4,transformPerspective:I4,opacity:Iq,originX:I8,originY:I8,originZ:I4,zIndex:Pp,fillOpacity:Iq,strokeOpacity:Iq,numOctaves:Pp},Pg={...Pm,color:Pe,backgroundColor:Pe,outlineColor:Pe,fill:Pe,stroke:Pe,borderColor:Pe,borderTopColor:Pe,borderRightColor:Pe,borderBottomColor:Pe,borderLeftColor:Pe,filter:Pf,WebkitFilter:Pf},Px=e=>Pg[e],Pv=()=>({translate:0,scale:1,origin:0,originPoint:0}),Py=()=>({x:Pv(),y:Pv()}),Pb=()=>({min:0,max:0}),Pw=()=>({x:Pb(),y:Pb()}),P_=e=>!!(e&&e.getVelocity),PS=new Set(["width","height","top","left","right","bottom",...IW]),Pk=e=>r=>r.test(e),Pj=[IV,I4,I3,I5,I7,I6,{test:e=>"auto"===e,parse:e=>e}],PC=e=>Pj.find(Pk(e)),PN=()=>{},PE=()=>{};xO.default;let PD=e=>r=>"string"==typeof r&&r.startsWith(e),PT=PD("--"),PR=PD("var(--"),PA=e=>!!PR(e)&&PM.test(e.split("/*")[0].trim()),PM=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu;function PI(e){return"string"==typeof e&&e.split("/*")[0].includes("var(--")}let PP=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u,PF=e=>180*e/Math.PI,PL=e=>PB(PF(Math.atan2(e[1],e[0]))),PO={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:e=>(Math.abs(e[0])+Math.abs(e[3]))/2,rotate:PL,rotateZ:PL,skewX:e=>PF(Math.atan(e[1])),skewY:e=>PF(Math.atan(e[2])),skew:e=>(Math.abs(e[1])+Math.abs(e[2]))/2},PB=e=>((e%=360)<0&&(e+=360),e),Pz=e=>Math.sqrt(e[0]*e[0]+e[1]*e[1]),P$=e=>Math.sqrt(e[4]*e[4]+e[5]*e[5]),PW={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:Pz,scaleY:P$,scale:e=>(Pz(e)+P$(e))/2,rotateX:e=>PB(PF(Math.atan2(e[6],e[5]))),rotateY:e=>PB(PF(Math.atan2(-e[2],e[0]))),rotateZ:PL,rotate:PL,skewX:e=>PF(Math.atan(e[4])),skewY:e=>PF(Math.atan(e[1])),skew:e=>(Math.abs(e[1])+Math.abs(e[4]))/2};function PH(e){return+!!e.includes("scale")}function PU(e,r){let s,n;if(!e||"none"===e)return PH(r);let i=e.match(/^matrix3d\(([-\d.e\s,]+)\)$/u);if(i)s=PW,n=i;else{let r=e.match(/^matrix\(([-\d.e\s,]+)\)$/u);s=PO,n=r}if(!n)return PH(r);let a=s[r],o=n[1].split(",").map(PV);return"function"==typeof a?a(o):o[a]}function PV(e){return parseFloat(e.trim())}let Pq=e=>e===IV||e===I4,PK=new Set(["x","y","z"]),PX=IW.filter(e=>!PK.has(e)),PY={width:({x:e},{paddingLeft:r="0",paddingRight:s="0"})=>e.max-e.min-parseFloat(r)-parseFloat(s),height:({y:e},{paddingTop:r="0",paddingBottom:s="0"})=>e.max-e.min-parseFloat(r)-parseFloat(s),top:(e,{top:r})=>parseFloat(r),left:(e,{left:r})=>parseFloat(r),bottom:({y:e},{top:r})=>parseFloat(r)+(e.max-e.min),right:({x:e},{left:r})=>parseFloat(r)+(e.max-e.min),x:(e,{transform:r})=>PU(r,"x"),y:(e,{transform:r})=>PU(r,"y")};PY.translateX=PY.x,PY.translateY=PY.y;let PG=e=>e,PJ={},PZ=["setup","read","resolveKeyframes","preUpdate","update","preRender","render","postRender"];function PQ(e,r){let s=!1,n=!0,i={delta:0,timestamp:0,isProcessing:!1},a=()=>s=!0,o=PZ.reduce((e,s)=>(e[s]=function(e,r){let s=new Set,n=new Set,i=!1,a=!1,o=new WeakSet,l={delta:0,timestamp:0,isProcessing:!1},c=0;function d(r){o.has(r)&&(u.schedule(r),e()),c++,r(l)}let u={schedule:(e,r=!1,a=!1)=>{let l=a&&i?s:n;return r&&o.add(e),l.has(e)||l.add(e),e},cancel:e=>{n.delete(e),o.delete(e)},process:e=>{if(l=e,i){a=!0;return}i=!0,[s,n]=[n,s],s.forEach(d),r,c=0,s.clear(),i=!1,a&&(a=!1,u.process(e))}};return u}(a,r?s:void 0),e),{}),{setup:l,read:c,resolveKeyframes:d,preUpdate:u,update:h,preRender:f,render:p,postRender:m}=o,g=()=>{let a=PJ.useManualTiming?i.timestamp:performance.now();s=!1,PJ.useManualTiming||(i.delta=n?1e3/60:Math.max(Math.min(a-i.timestamp,40),1)),i.timestamp=a,i.isProcessing=!0,l.process(i),c.process(i),d.process(i),u.process(i),h.process(i),f.process(i),p.process(i),m.process(i),i.isProcessing=!1,s&&r&&(n=!1,e(g))};return{schedule:PZ.reduce((r,a)=>{let l=o[a];return r[a]=(r,a=!1,o=!1)=>(!s&&(s=!0,n=!0,i.isProcessing||e(g)),l.schedule(r,a,o)),r},{}),cancel:e=>{for(let r=0;r<PZ.length;r++)o[PZ[r]].cancel(e)},state:i,steps:o}}let{schedule:P0,cancel:P1,state:P2,steps:P5}=PQ("undefined"!=typeof requestAnimationFrame?requestAnimationFrame:PG,!0),P3=new Set,P4=!1,P6=!1,P7=!1;function P8(){if(P6){let e=Array.from(P3).filter(e=>e.needsMeasurement),r=new Set(e.map(e=>e.element)),s=new Map;r.forEach(e=>{let r,n=(r=[],PX.forEach(s=>{let n=e.getValue(s);void 0!==n&&(r.push([s,n.get()]),n.set(+!!s.startsWith("scale")))}),r);n.length&&(s.set(e,n),e.render())}),e.forEach(e=>e.measureInitialState()),r.forEach(e=>{e.render();let r=s.get(e);r&&r.forEach(([r,s])=>{e.getValue(r)?.set(s)})}),e.forEach(e=>e.measureEndState()),e.forEach(e=>{void 0!==e.suspendedScrollY&&window.scrollTo(0,e.suspendedScrollY)})}P6=!1,P4=!1,P3.forEach(e=>e.complete(P7)),P3.clear()}function P9(){P3.forEach(e=>{e.readKeyframes(),e.needsMeasurement&&(P6=!0)})}class Fe{constructor(e,r,s,n,i,a=!1){this.state="pending",this.isAsync=!1,this.needsMeasurement=!1,this.unresolvedKeyframes=[...e],this.onComplete=r,this.name=s,this.motionValue=n,this.element=i,this.isAsync=a}scheduleResolve(){this.state="scheduled",this.isAsync?(P3.add(this),P4||(P4=!0,P0.read(P9),P0.resolveKeyframes(P8))):(this.readKeyframes(),this.complete())}readKeyframes(){let{unresolvedKeyframes:e,name:r,element:s,motionValue:n}=this;if(null===e[0]){let i=n?.get(),a=e[e.length-1];if(void 0!==i)e[0]=i;else if(s&&r){let n=s.readValue(r,a);null!=n&&(e[0]=n)}void 0===e[0]&&(e[0]=a),n&&void 0===i&&n.set(e[0])}for(let r=1;r<e.length;r++)e[r]??(e[r]=e[r-1])}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(e=!1){this.state="complete",this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,e),P3.delete(this)}cancel(){"scheduled"===this.state&&(P3.delete(this),this.state="pending")}resume(){"pending"===this.state&&this.scheduleResolve()}}function Ft(e,r){let s=Px(e);return s!==Pf&&(s=Pc),s.getAnimatableNone?s.getAnimatableNone(r):void 0}let Fr=new Set(["auto","none","0"]);class Fs extends Fe{constructor(e,r,s,n,i){super(e,r,s,n,i,!0)}readKeyframes(){let{unresolvedKeyframes:e,element:r,name:s}=this;if(!r||!r.current)return;super.readKeyframes();for(let s=0;s<e.length;s++){let n=e[s];if("string"==typeof n&&PA(n=n.trim())){let i=function e(r,s,n=1){PE(n<=4,`Max CSS variable fallback depth detected in property "${r}". This may indicate a circular fallback dependency.`,"max-css-var-depth");let[i,a]=function(e){let r=PP.exec(e);if(!r)return[,];let[,s,n,i]=r;return[`--${s??n}`,i]}(r);if(!i)return;let o=window.getComputedStyle(s).getPropertyValue(i);if(o){let e=o.trim();return/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(e)?parseFloat(e):e}return PA(a)?e(a,s,n+1):a}(n,r.current);void 0!==i&&(e[s]=i),s===e.length-1&&(this.finalKeyframe=n)}}if(this.resolveNoneKeyframes(),!PS.has(s)||2!==e.length)return;let[n,i]=e,a=PC(n),o=PC(i);if(PI(n)!==PI(i)&&PY[s]){this.needsMeasurement=!0;return}if(a!==o)if(Pq(a)&&Pq(o))for(let r=0;r<e.length;r++){let s=e[r];"string"==typeof s&&(e[r]=parseFloat(s))}else PY[s]&&(this.needsMeasurement=!0)}resolveNoneKeyframes(){let{unresolvedKeyframes:e,name:r}=this,s=[];for(let r=0;r<e.length;r++)(null===e[r]||function(e){if("number"==typeof e)return 0===e;if(null===e)return!0;return"none"===e||"0"===e||/^0[^.\s]+$/u.test(e)}(e[r]))&&s.push(r);s.length&&function(e,r,s){let n,i=0;for(;i<e.length&&!n;){let r=e[i];"string"==typeof r&&!Fr.has(r)&&Pi(r).values.length&&(n=e[i]),i++}if(n&&s)for(let i of r)e[i]=Ft(s,n)}(e,s,r)}measureInitialState(){let{element:e,unresolvedKeyframes:r,name:s}=this;if(!e||!e.current)return;"height"===s&&(this.suspendedScrollY=window.pageYOffset),this.measuredOrigin=PY[s](e.measureViewportBox(),window.getComputedStyle(e.current)),r[0]=this.measuredOrigin;let n=r[r.length-1];void 0!==n&&e.getValue(s,n).jump(n,!1)}measureEndState(){let{element:e,name:r,unresolvedKeyframes:s}=this;if(!e||!e.current)return;let n=e.getValue(r);n&&n.jump(this.measuredOrigin,!1);let i=s.length-1,a=s[i];s[i]=PY[r](e.measureViewportBox(),window.getComputedStyle(e.current)),null!==a&&void 0===this.finalKeyframe&&(this.finalKeyframe=a),this.removedTransforms?.length&&this.removedTransforms.forEach(([r,s])=>{e.getValue(r).set(s)}),this.resolveNoneKeyframes()}}function Fn(e,r){-1===e.indexOf(r)&&e.push(r)}function Fi(e,r){let s=e.indexOf(r);s>-1&&e.splice(s,1)}class Fa{constructor(){this.subscriptions=[]}add(e){return Fn(this.subscriptions,e),()=>Fi(this.subscriptions,e)}notify(e,r,s){let n=this.subscriptions.length;if(n)if(1===n)this.subscriptions[0](e,r,s);else for(let i=0;i<n;i++){let n=this.subscriptions[i];n&&n(e,r,s)}}getSize(){return this.subscriptions.length}clear(){this.subscriptions.length=0}}let{schedule:Fo}=PQ(queueMicrotask,!1);function Fl(){s=void 0}let Fc={now:()=>(void 0===s&&Fc.set(P2.isProcessing||PJ.useManualTiming?P2.timestamp:performance.now()),s),set:e=>{s=e,queueMicrotask(Fl)}};class Fd{constructor(e,r={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=e=>{let r=Fc.now();if(this.updatedAt!==r&&this.setPrevFrameValue(),this.prev=this.current,this.setCurrent(e),this.current!==this.prev&&(this.events.change?.notify(this.current),this.dependents))for(let e of this.dependents)e.dirty()},this.hasAnimated=!1,this.setCurrent(e),this.owner=r.owner}setCurrent(e){this.current=e,this.updatedAt=Fc.now(),null===this.canTrackVelocity&&void 0!==e&&(this.canTrackVelocity=!isNaN(parseFloat(this.current)))}setPrevFrameValue(e=this.current){this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt}onChange(e){return this.on("change",e)}on(e,r){this.events[e]||(this.events[e]=new Fa);let s=this.events[e].add(r);return"change"===e?()=>{s(),P0.read(()=>{this.events.change.getSize()||this.stop()})}:s}clearListeners(){for(let e in this.events)this.events[e].clear()}attach(e,r){this.passiveEffect=e,this.stopPassiveEffect=r}set(e){this.passiveEffect?this.passiveEffect(e,this.updateAndNotify):this.updateAndNotify(e)}setWithVelocity(e,r,s){this.set(r),this.prev=void 0,this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt-s}jump(e,r=!0){this.updateAndNotify(e),this.prev=e,this.prevUpdatedAt=this.prevFrameValue=void 0,r&&this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}dirty(){this.events.change?.notify(this.current)}addDependent(e){this.dependents||(this.dependents=new Set),this.dependents.add(e)}removeDependent(e){this.dependents&&this.dependents.delete(e)}get(){return w&&w.push(this),this.current}getPrevious(){return this.prev}getVelocity(){var e;let r=Fc.now();if(!this.canTrackVelocity||void 0===this.prevFrameValue||r-this.updatedAt>30)return 0;let s=Math.min(this.updatedAt-this.prevUpdatedAt,30);return e=parseFloat(this.current)-parseFloat(this.prevFrameValue),s?1e3/s*e:0}start(e){return this.stop(),new Promise(r=>{this.hasAnimated=!0,this.animation=e(r),this.events.animationStart&&this.events.animationStart.notify()}).then(()=>{this.events.animationComplete&&this.events.animationComplete.notify(),this.clearAnimation()})}stop(){this.animation&&(this.animation.stop(),this.events.animationCancel&&this.events.animationCancel.notify()),this.clearAnimation()}isAnimating(){return!!this.animation}clearAnimation(){delete this.animation}destroy(){this.dependents?.clear(),this.events.destroy?.notify(),this.clearListeners(),this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}}function Fu(e,r){return new Fd(e,r)}let Fh=[...Pj,Pe,Pc],Ff={current:null},Fp={current:!1},Fm="undefined"!=typeof window,Fg=new WeakMap;function Fx(e){return null!==e&&"object"==typeof e&&"function"==typeof e.start}function Fv(e){return"string"==typeof e||Array.isArray(e)}let Fy=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],Fb=["initial",...Fy];function Fw(e){return Fx(e.animate)||Fb.some(r=>Fv(e[r]))}function F_(e){return!!(Fw(e)||e.variants)}function FS(e){let r=[{},{}];return e?.values.forEach((e,s)=>{r[0][s]=e.get(),r[1][s]=e.getVelocity()}),r}function Fk(e,r,s,n){if("function"==typeof r){let[i,a]=FS(n);r=r(void 0!==s?s:e.custom,i,a)}if("string"==typeof r&&(r=e.variants&&e.variants[r]),"function"==typeof r){let[i,a]=FS(n);r=r(void 0!==s?s:e.custom,i,a)}return r}let Fj=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"],FC={};class FN{scrapeMotionValuesFromProps(e,r,s){return{}}constructor({parent:e,props:r,presenceContext:s,reducedMotionConfig:n,blockInitialAnimation:i,visualState:a},o={}){this.current=null,this.children=new Set,this.isVariantNode=!1,this.isControllingVariants=!1,this.shouldReduceMotion=null,this.values=new Map,this.KeyframeResolver=Fe,this.features={},this.valueSubscriptions=new Map,this.prevMotionValues={},this.events={},this.propEventSubscriptions={},this.notifyUpdate=()=>this.notify("Update",this.latestValues),this.render=()=>{this.current&&(this.triggerBuild(),this.renderInstance(this.current,this.renderState,this.props.style,this.projection))},this.renderScheduledAt=0,this.scheduleRender=()=>{let e=Fc.now();this.renderScheduledAt<e&&(this.renderScheduledAt=e,P0.render(this.render,!1,!0))};const{latestValues:l,renderState:c}=a;this.latestValues=l,this.baseTarget={...l},this.initialValues=r.initial?{...l}:{},this.renderState=c,this.parent=e,this.props=r,this.presenceContext=s,this.depth=e?e.depth+1:0,this.reducedMotionConfig=n,this.options=o,this.blockInitialAnimation=!!i,this.isControllingVariants=Fw(r),this.isVariantNode=F_(r),this.isVariantNode&&(this.variantChildren=new Set),this.manuallyAnimateOnMount=!!(e&&e.current);const{willChange:d,...u}=this.scrapeMotionValuesFromProps(r,{},this);for(const e in u){const r=u[e];void 0!==l[e]&&P_(r)&&r.set(l[e])}}mount(e){this.current=e,Fg.set(e,this),this.projection&&!this.projection.instance&&this.projection.mount(e),this.parent&&this.isVariantNode&&!this.isControllingVariants&&(this.removeFromVariantTree=this.parent.addVariantChild(this)),this.values.forEach((e,r)=>this.bindToMotionValue(r,e)),"never"===this.reducedMotionConfig?this.shouldReduceMotion=!1:"always"===this.reducedMotionConfig?this.shouldReduceMotion=!0:(Fp.current||function(){if(Fp.current=!0,Fm)if(window.matchMedia){let e=window.matchMedia("(prefers-reduced-motion)"),r=()=>Ff.current=e.matches;e.addEventListener("change",r),r()}else Ff.current=!1}(),this.shouldReduceMotion=Ff.current),this.parent?.addChild(this),this.update(this.props,this.presenceContext)}unmount(){for(let e in this.projection&&this.projection.unmount(),P1(this.notifyUpdate),P1(this.render),this.valueSubscriptions.forEach(e=>e()),this.valueSubscriptions.clear(),this.removeFromVariantTree&&this.removeFromVariantTree(),this.parent?.removeChild(this),this.events)this.events[e].clear();for(let e in this.features){let r=this.features[e];r&&(r.unmount(),r.isMounted=!1)}this.current=null}addChild(e){this.children.add(e),this.enteringChildren??(this.enteringChildren=new Set),this.enteringChildren.add(e)}removeChild(e){this.children.delete(e),this.enteringChildren&&this.enteringChildren.delete(e)}bindToMotionValue(e,r){let s;this.valueSubscriptions.has(e)&&this.valueSubscriptions.get(e)();let n=IH.has(e);n&&this.onBindTransform&&this.onBindTransform();let i=r.on("change",r=>{this.latestValues[e]=r,this.props.onUpdate&&P0.preRender(this.notifyUpdate),n&&this.projection&&(this.projection.isTransformDirty=!0),this.scheduleRender()});"undefined"!=typeof window&&window.MotionCheckAppearSync&&(s=window.MotionCheckAppearSync(this,e,r)),this.valueSubscriptions.set(e,()=>{i(),s&&s(),r.owner&&r.stop()})}sortNodePosition(e){return this.current&&this.sortInstanceNodePosition&&this.type===e.type?this.sortInstanceNodePosition(this.current,e.current):0}updateFeatures(){let e="animation";for(e in FC){let r=FC[e];if(!r)continue;let{isEnabled:s,Feature:n}=r;if(!this.features[e]&&n&&s(this.props)&&(this.features[e]=new n(this)),this.features[e]){let r=this.features[e];r.isMounted?r.update():(r.mount(),r.isMounted=!0)}}}triggerBuild(){this.build(this.renderState,this.latestValues,this.props)}measureViewportBox(){return this.current?this.measureInstanceViewportBox(this.current,this.props):Pw()}getStaticValue(e){return this.latestValues[e]}setStaticValue(e,r){this.latestValues[e]=r}update(e,r){(e.transformTemplate||this.props.transformTemplate)&&this.scheduleRender(),this.prevProps=this.props,this.props=e,this.prevPresenceContext=this.presenceContext,this.presenceContext=r;for(let r=0;r<Fj.length;r++){let s=Fj[r];this.propEventSubscriptions[s]&&(this.propEventSubscriptions[s](),delete this.propEventSubscriptions[s]);let n=e["on"+s];n&&(this.propEventSubscriptions[s]=this.on(s,n))}this.prevMotionValues=function(e,r,s){for(let n in r){let i=r[n],a=s[n];if(P_(i))e.addValue(n,i);else if(P_(a))e.addValue(n,Fu(i,{owner:e}));else if(a!==i)if(e.hasValue(n)){let r=e.getValue(n);!0===r.liveStyle?r.jump(i):r.hasAnimated||r.set(i)}else{let r=e.getStaticValue(n);e.addValue(n,Fu(void 0!==r?r:i,{owner:e}))}}for(let n in s)void 0===r[n]&&e.removeValue(n);return r}(this,this.scrapeMotionValuesFromProps(e,this.prevProps||{},this),this.prevMotionValues),this.handleChildMotionValue&&this.handleChildMotionValue()}getProps(){return this.props}getVariant(e){return this.props.variants?this.props.variants[e]:void 0}getDefaultTransition(){return this.props.transition}getTransformPagePoint(){return this.props.transformPagePoint}getClosestVariantNode(){return this.isVariantNode?this:this.parent?this.parent.getClosestVariantNode():void 0}addVariantChild(e){let r=this.getClosestVariantNode();if(r)return r.variantChildren&&r.variantChildren.add(e),()=>r.variantChildren.delete(e)}addValue(e,r){let s=this.values.get(e);r!==s&&(s&&this.removeValue(e),this.bindToMotionValue(e,r),this.values.set(e,r),this.latestValues[e]=r.get())}removeValue(e){this.values.delete(e);let r=this.valueSubscriptions.get(e);r&&(r(),this.valueSubscriptions.delete(e)),delete this.latestValues[e],this.removeValueFromRenderState(e,this.renderState)}hasValue(e){return this.values.has(e)}getValue(e,r){if(this.props.values&&this.props.values[e])return this.props.values[e];let s=this.values.get(e);return void 0===s&&void 0!==r&&(s=Fu(null===r?void 0:r,{owner:this}),this.addValue(e,s)),s}readValue(e,r){let s=void 0===this.latestValues[e]&&this.current?this.getBaseTargetFromProps(this.props,e)??this.readValueFromInstance(this.current,e,this.options):this.latestValues[e];if(null!=s){let n,i;if("string"==typeof s&&(n=s,/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(n)||(i=s,/^0[^.\s]+$/u.test(i))))s=parseFloat(s);else{let n;n=s,!Fh.find(Pk(n))&&Pc.test(r)&&(s=Ft(e,r))}this.setBaseTarget(e,P_(s)?s.get():s)}return P_(s)?s.get():s}setBaseTarget(e,r){this.baseTarget[e]=r}getBaseTarget(e){let r,{initial:s}=this.props;if("string"==typeof s||"object"==typeof s){let n=Fk(this.props,s,this.presenceContext?.custom);n&&(r=n[e])}if(s&&void 0!==r)return r;let n=this.getBaseTargetFromProps(this.props,e);return void 0===n||P_(n)?void 0!==this.initialValues[e]&&void 0===r?void 0:this.baseTarget[e]:n}on(e,r){return this.events[e]||(this.events[e]=new Fa),this.events[e].add(r)}notify(e,...r){this.events[e]&&this.events[e].notify(...r)}scheduleRenderMicrotask(){Fo.render(this.render)}}class FE extends FN{constructor(){super(...arguments),this.KeyframeResolver=Fs}sortInstanceNodePosition(e,r){return 2&e.compareDocumentPosition(r)?1:-1}getBaseTargetFromProps(e,r){let s=e.style;return s?s[r]:void 0}removeValueFromRenderState(e,{vars:r,style:s}){delete r[e],delete s[e]}handleChildMotionValue(){this.childSubscription&&(this.childSubscription(),delete this.childSubscription);let{children:e}=this.props;P_(e)&&(this.childSubscription=e.on("change",e=>{this.current&&(this.current.textContent=`${e}`)}))}}function FD(e){return e.replace(/([A-Z])/g,e=>`-${e.toLowerCase()}`)}let FT=(e,r)=>r&&"number"==typeof e?r.transform(e):e,FR={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},FA=IW.length;function FM(e,r,s){let{style:n,vars:i,transformOrigin:a}=e,o=!1,l=!1;for(let e in r){let s=r[e];if(IH.has(e)){o=!0;continue}if(PT(e)){i[e]=s;continue}{let r=FT(s,Pm[e]);e.startsWith("origin")?(l=!0,a[e]=r):n[e]=r}}if(!r.transform&&(o||s?n.transform=function(e,r,s){let n="",i=!0;for(let a=0;a<FA;a++){let o=IW[a],l=e[o];if(void 0===l)continue;let c=!0;if("number"==typeof l)c=l===+!!o.startsWith("scale");else{let e=parseFloat(l);c=o.startsWith("scale")?1===e:0===e}if(!c||s){let e=FT(l,Pm[o]);if(!c){i=!1;let r=FR[o]||o;n+=`${r}(${e}) `}s&&(r[o]=e)}}return n=n.trim(),s?n=s(r,i?"":n):i&&(n="none"),n}(r,e.transform,s):n.transform&&(n.transform="none")),l){let{originX:e="50%",originY:r="50%",originZ:s=0}=a;n.transformOrigin=`${e} ${r} ${s}`}}let FI={offset:"stroke-dashoffset",array:"stroke-dasharray"},FP={offset:"strokeDashoffset",array:"strokeDasharray"},FF=["offsetDistance","offsetPath","offsetRotate","offsetAnchor"];function FL(e,{attrX:r,attrY:s,attrScale:n,pathLength:i,pathSpacing:a=1,pathOffset:o=0,...l},c,d,u){if(FM(e,l,d),c){e.style.viewBox&&(e.attrs.viewBox=e.style.viewBox);return}e.attrs=e.style,e.style={};let{attrs:h,style:f}=e;for(let e of(h.transform&&(f.transform=h.transform,delete h.transform),(f.transform||h.transformOrigin)&&(f.transformOrigin=h.transformOrigin??"50% 50%",delete h.transformOrigin),f.transform&&(f.transformBox=u?.transformBox??"fill-box",delete h.transformBox),FF))void 0!==h[e]&&(f[e]=h[e],delete h[e]);void 0!==r&&(h.x=r),void 0!==s&&(h.y=s),void 0!==n&&(h.scale=n),void 0!==i&&function(e,r,s=1,n=0,i=!0){e.pathLength=1;let a=i?FI:FP;e[a.offset]=`${-n}`,e[a.array]=`${r} ${s}`}(h,i,a,o,!1)}let FO=new Set(["baseFrequency","diffuseConstant","kernelMatrix","kernelUnitLength","keySplines","keyTimes","limitingConeAngle","markerHeight","markerWidth","numOctaves","targetX","targetY","surfaceScale","specularConstant","specularExponent","stdDeviation","tableValues","viewBox","gradientTransform","pathLength","startOffset","textLength","lengthAdjust"]),FB=e=>"string"==typeof e&&"svg"===e.toLowerCase();function Fz(e,{style:r,vars:s},n,i){let a,o=e.style;for(a in r)o[a]=r[a];for(a in i?.applyProjectionStyles(o,n),s)o.setProperty(a,s[a])}function F$(e,r){return r.max===r.min?0:e/(r.max-r.min)*100}let FW={correct:(e,r)=>{if(!r.target)return e;if("string"==typeof e)if(!I4.test(e))return e;else e=parseFloat(e);let s=F$(e,r.target.x),n=F$(e,r.target.y);return`${s}% ${n}%`}},FH=(e,r,s)=>e+(r-e)*s,FU={borderRadius:{...FW,applyTo:["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"]},borderTopLeftRadius:FW,borderTopRightRadius:FW,borderBottomLeftRadius:FW,borderBottomRightRadius:FW,boxShadow:{correct:(e,{treeScale:r,projectionDelta:s})=>{let n=Pc.parse(e);if(n.length>5)return e;let i=Pc.createTransformer(e),a=+("number"!=typeof n[0]),o=s.x.scale*r.x,l=s.y.scale*r.y;n[0+a]/=o,n[1+a]/=l;let c=FH(o,l,.5);return"number"==typeof n[2+a]&&(n[2+a]/=c),"number"==typeof n[3+a]&&(n[3+a]/=c),i(n)}}};function FV(e,{layout:r,layoutId:s}){return IH.has(e)||e.startsWith("origin")||(r||void 0!==s)&&(!!FU[e]||"opacity"===e)}function Fq(e,r,s){let n=e.style,i=r?.style,a={};if(!n)return a;for(let r in n)(P_(n[r])||i&&P_(i[r])||FV(r,e)||s?.getValue(r)?.liveStyle!==void 0)&&(a[r]=n[r]);return a}function FK(e,r,s){let n=Fq(e,r,s);for(let s in e)(P_(e[s])||P_(r[s]))&&(n[-1!==IW.indexOf(s)?"attr"+s.charAt(0).toUpperCase()+s.substring(1):s]=e[s]);return n}class FX extends FE{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=Pw}getBaseTargetFromProps(e,r){return e[r]}readValueFromInstance(e,r){if(IH.has(r)){let e=Px(r);return e&&e.default||0}return r=FO.has(r)?r:FD(r),e.getAttribute(r)}scrapeMotionValuesFromProps(e,r,s){return FK(e,r,s)}build(e,r,s){FL(e,r,this.isSVGTag,s.transformTemplate,s.style)}renderInstance(e,r,s,n){for(let s in Fz(e,r,void 0,n),r.attrs)e.setAttribute(FO.has(s)?s:FD(s),r.attrs[s])}mount(e){this.isSVGTag=FB(e.tagName),super.mount(e)}}function FY({top:e,left:r,right:s,bottom:n}){return{x:{min:r,max:s},y:{min:e,max:n}}}function FG(e){return void 0===e||1===e}function FJ({scale:e,scaleX:r,scaleY:s}){return!FG(e)||!FG(r)||!FG(s)}function FZ(e){return FJ(e)||FQ(e)||e.z||e.rotate||e.rotateX||e.rotateY||e.skewX||e.skewY}function FQ(e){var r,s;return(r=e.x)&&"0%"!==r||(s=e.y)&&"0%"!==s}function F0(e,r,s,n,i){return void 0!==i&&(e=n+i*(e-n)),n+s*(e-n)+r}function F1(e,r=0,s=1,n,i){e.min=F0(e.min,r,s,n,i),e.max=F0(e.max,r,s,n,i)}function F2(e,{x:r,y:s}){F1(e.x,r.translate,r.scale,r.originPoint),F1(e.y,s.translate,s.scale,s.originPoint)}function F5(e,r){e.min=e.min+r,e.max=e.max+r}function F3(e,r,s,n,i=.5){let a=FH(e.min,e.max,i);F1(e,r,s,a,n)}function F4(e,r){F3(e.x,r.x,r.scaleX,r.scale,r.originX),F3(e.y,r.y,r.scaleY,r.scale,r.originY)}function F6(e,r){return FY(function(e,r){if(!r)return e;let s=r({x:e.left,y:e.top}),n=r({x:e.right,y:e.bottom});return{top:s.y,left:s.x,bottom:n.y,right:n.x}}(e.getBoundingClientRect(),r))}class F7 extends FE{constructor(){super(...arguments),this.type="html",this.renderInstance=Fz}readValueFromInstance(e,r){if(IH.has(r))return this.projection?.isProjecting?PH(r):((e,r)=>{let{transform:s="none"}=getComputedStyle(e);return PU(s,r)})(e,r);{let s=window.getComputedStyle(e),n=(PT(r)?s.getPropertyValue(r):s[r])||0;return"string"==typeof n?n.trim():n}}measureInstanceViewportBox(e,{transformPagePoint:r}){return F6(e,r)}build(e,r,s){FM(e,r,s.transformTemplate)}scrapeMotionValuesFromProps(e,r,s){return Fq(e,r,s)}}let F8=["animate","circle","defs","desc","ellipse","g","image","line","filter","marker","mask","metadata","path","pattern","polygon","polyline","rect","stop","switch","symbol","svg","text","tspan","use","view"];function F9(e){if("string"!=typeof e||e.includes("-"));else if(F8.indexOf(e)>-1||/[A-Z]/u.test(e))return!0;return!1}let Le=(0,V.createContext)({}),Lt=(0,V.createContext)({strict:!1}),Lr=(0,V.createContext)({transformPagePoint:e=>e,isStatic:!1,reducedMotion:"never"}),Ls=(0,V.createContext)({});function Ln(e){return Array.isArray(e)?e.join(" "):e}let Li=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function La(e,r,s){for(let n in r)P_(r[n])||FV(n,s)||(e[n]=r[n])}let Lo=()=>({...Li(),attrs:{}}),Ll=new Set(["animate","exit","variants","initial","style","values","variants","transition","transformTemplate","custom","inherit","onBeforeLayoutMeasure","onAnimationStart","onAnimationComplete","onUpdate","onDragStart","onDrag","onDragEnd","onMeasureDragConstraints","onDirectionLock","onDragTransitionEnd","_dragX","_dragY","onHoverStart","onHoverEnd","onViewportEnter","onViewportLeave","globalTapTarget","ignoreStrict","viewport"]);function Lc(e){return e.startsWith("while")||e.startsWith("drag")&&"draggable"!==e||e.startsWith("layout")||e.startsWith("onTap")||e.startsWith("onPan")||e.startsWith("onLayout")||Ll.has(e)}let Ld=e=>!Lc(e);try{R=(()=>{let e=Error("Cannot find module '@emotion/is-prop-valid'");throw e.code="MODULE_NOT_FOUND",e})().default,"function"==typeof R&&(Ld=e=>e.startsWith("on")?!Lc(e):R(e))}catch{}function Lu(e){return P_(e)?e.get():e}let Lh=(0,V.createContext)(null),Lf=e=>(r,s)=>{let n,i=(0,V.useContext)(Ls),a=(0,V.useContext)(Lh),o=()=>(function({scrapeMotionValuesFromProps:e,createRenderState:r},s,n,i){return{latestValues:function(e,r,s,n){let i={},a=n(e,{});for(let e in a)i[e]=Lu(a[e]);let{initial:o,animate:l}=e,c=Fw(e),d=F_(e);r&&d&&!c&&!1!==e.inherit&&(void 0===o&&(o=r.initial),void 0===l&&(l=r.animate));let u=!!s&&!1===s.initial,h=(u=u||!1===o)?l:o;if(h&&"boolean"!=typeof h&&!Fx(h)){let r=Array.isArray(h)?h:[h];for(let s=0;s<r.length;s++){let n=Fk(e,r[s]);if(n){let{transitionEnd:e,transition:r,...s}=n;for(let e in s){let r=s[e];if(Array.isArray(r)){let e=u?r.length-1:0;r=r[e]}null!==r&&(i[e]=r)}for(let r in e)i[r]=e[r]}}}return i}(s,n,i,e),renderState:r()}})(e,r,i,a);return s?o():(null===(n=(0,V.useRef)(null)).current&&(n.current=o()),n.current)},Lp=Lf({scrapeMotionValuesFromProps:Fq,createRenderState:Li}),Lm=Lf({scrapeMotionValuesFromProps:FK,createRenderState:Lo}),Lg="undefined"!=typeof window,Lx={animation:["animate","variants","whileHover","whileTap","exit","whileInView","whileFocus","whileDrag"],exit:["exit"],drag:["drag","dragControls"],focus:["whileFocus"],hover:["whileHover","onHoverStart","onHoverEnd"],tap:["whileTap","onTap","onTapStart","onTapCancel"],pan:["onPan","onPanStart","onPanSessionStart","onPanEnd"],inView:["whileInView","onViewportEnter","onViewportLeave"],layout:["layout","layoutId"]},Lv=!1;function Ly(){return!function(){if(Lv)return;let e={};for(let r in Lx)e[r]={isEnabled:e=>Lx[r].some(r=>!!e[r])};FC=e,Lv=!0}(),FC}let Lb=Symbol.for("motionComponentSymbol"),Lw="data-"+FD("framerAppearId"),L_=(0,V.createContext)({});function LS(e){return e&&"object"==typeof e&&Object.prototype.hasOwnProperty.call(e,"current")}let Lk=Lg?V.useLayoutEffect:V.useEffect;function Lj(e,{forwardMotionProps:r=!1,type:s}={},n,i){n&&function(e){let r=Ly();for(let s in e)r[s]={...r[s],...e[s]};FC=r}(n);let a=s?"svg"===s:F9(e),o=a?Lm:Lp;function l(s,n){var l;let c,d,u,h={...(0,V.useContext)(Lr),...s,layoutId:function({layoutId:e}){let r=(0,V.useContext)(Le).id;return r&&void 0!==e?r+"-"+e:e}(s)},{isStatic:f}=h,p=function(e){let{initial:r,animate:s}=function(e,r){if(Fw(e)){let{initial:r,animate:s}=e;return{initial:!1===r||Fv(r)?r:void 0,animate:Fv(s)?s:void 0}}return!1!==e.inherit?r:{}}(e,(0,V.useContext)(Ls));return(0,V.useMemo)(()=>({initial:r,animate:s}),[Ln(r),Ln(s)])}(s),m=o(s,f);if(!f&&Lg){(0,V.useContext)(Lt).strict;let r=function(e){let{drag:r,layout:s}=Ly();if(!r&&!s)return{};let n={...r,...s};return{MeasureLayout:r?.isEnabled(e)||s?.isEnabled(e)?n.MeasureLayout:void 0,ProjectionNode:n.ProjectionNode}}(h);c=r.MeasureLayout,p.visualElement=function(e,r,s,n,i,a){let{visualElement:o}=(0,V.useContext)(Ls),l=(0,V.useContext)(Lt),c=(0,V.useContext)(Lh),d=(0,V.useContext)(Lr).reducedMotion,u=(0,V.useRef)(null),h=(0,V.useRef)(!1);n=n||l.renderer,!u.current&&n&&(u.current=n(e,{visualState:r,parent:o,props:s,presenceContext:c,blockInitialAnimation:!!c&&!1===c.initial,reducedMotionConfig:d,isSVG:a}),h.current&&u.current&&(u.current.manuallyAnimateOnMount=!0));let f=u.current,p=(0,V.useContext)(L_);f&&!f.projection&&i&&("html"===f.type||"svg"===f.type)&&function(e,r,s,n){let{layoutId:i,layout:a,drag:o,dragConstraints:l,layoutScroll:c,layoutRoot:d,layoutCrossfade:u}=r;e.projection=new s(e.latestValues,r["data-framer-portal-id"]?void 0:function e(r){if(r)return!1!==r.options.allowProjection?r.projection:e(r.parent)}(e.parent)),e.projection.setOptions({layoutId:i,layout:a,alwaysMeasureLayout:!!o||l&&LS(l),visualElement:e,animationType:"string"==typeof a?a:"both",initialPromotionConfig:n,crossfade:u,layoutScroll:c,layoutRoot:d})}(u.current,s,i,p);let m=(0,V.useRef)(!1);(0,V.useInsertionEffect)(()=>{f&&m.current&&f.update(s,c)});let g=s[Lw],x=(0,V.useRef)(!!g&&!window.MotionHandoffIsComplete?.(g)&&window.MotionHasOptimisedAnimation?.(g));return Lk(()=>{h.current=!0,f&&(m.current=!0,window.MotionIsMounted=!0,f.updateFeatures(),f.scheduleRenderMicrotask(),x.current&&f.animationState&&f.animationState.animateChanges())}),(0,V.useEffect)(()=>{f&&(!x.current&&f.animationState&&f.animationState.animateChanges(),x.current&&(queueMicrotask(()=>{window.MotionHandoffMarkAsComplete?.(g)}),x.current=!1),f.enteringChildren=void 0)}),f}(e,m,h,i,r.ProjectionNode,a)}return(0,U.jsxs)(Ls.Provider,{value:p,children:[c&&p.visualElement?(0,U.jsx)(c,{visualElement:p.visualElement,...h}):null,function(e,r,s,{latestValues:n},i,a=!1,o){let l=(o??F9(e)?function(e,r,s,n){let i=(0,V.useMemo)(()=>{let s=Lo();return FL(s,r,FB(n),e.transformTemplate,e.style),{...s.attrs,style:{...s.style}}},[r]);if(e.style){let r={};La(r,e.style,e),i.style={...r,...i.style}}return i}:function(e,r){let s,n,i={},a=(s=e.style||{},La(n={},s,e),Object.assign(n,function({transformTemplate:e},r){return(0,V.useMemo)(()=>{let s=Li();return FM(s,r,e),Object.assign({},s.vars,s.style)},[r])}(e,r)),n);return e.drag&&!1!==e.dragListener&&(i.draggable=!1,a.userSelect=a.WebkitUserSelect=a.WebkitTouchCallout="none",a.touchAction=!0===e.drag?"none":`pan-${"x"===e.drag?"y":"x"}`),void 0===e.tabIndex&&(e.onTap||e.onTapStart||e.whileTap)&&(i.tabIndex=0),i.style=a,i})(r,n,i,e),c=function(e,r,s){let n={};for(let i in e)("values"!==i||"object"!=typeof e.values)&&(Ld(i)||!0===s&&Lc(i)||!r&&!Lc(i)||e.draggable&&i.startsWith("onDrag"))&&(n[i]=e[i]);return n}(r,"string"==typeof e,a),d=e!==V.Fragment?{...c,...l,ref:s}:{},{children:u}=r,h=(0,V.useMemo)(()=>P_(u)?u.get():u,[u]);return(0,V.createElement)(e,{...d,children:h})}(e,s,(l=p.visualElement,d=(0,V.useRef)(n),(0,V.useInsertionEffect)(()=>{d.current=n}),u=(0,V.useRef)(null),(0,V.useCallback)(e=>{e&&m.onMount?.(e),l&&(e?l.mount(e):l.unmount());let r=d.current;if("function"==typeof r)if(e){let s=r(e);"function"==typeof s&&(u.current=s)}else u.current?(u.current(),u.current=null):r(e);else r&&(r.current=e)},[l])),m,f,r,a)]})}l.displayName=`motion.${"string"==typeof e?e:`create(${e.displayName??e.name??""})`}`;let c=(0,V.forwardRef)(l);return c[Lb]=e,c}class LC{constructor(e){this.isMounted=!1,this.node=e}update(){}}function LN(e,r,s){let n=e.getProps();return Fk(n,r,void 0!==s?s:n.custom,e)}function LE(e,r){return e?.[r]??e?.default??e}let LD=e=>Array.isArray(e);function LT(e,r){let s=e.getValue("willChange");if(P_(s)&&s.add)return s.add(r);if(!s&&PJ.WillChange){let s=new PJ.WillChange("auto");e.addValue("willChange",s),s.add(r)}}let LR=e=>1e3*e,LA=(e,r)=>s=>r(e(s)),LM=(...e)=>e.reduce(LA),LI={layout:0,mainThread:0,waapi:0};function LP(e,r,s){return(s<0&&(s+=1),s>1&&(s-=1),s<1/6)?e+(r-e)*6*s:s<.5?r:s<2/3?e+(r-e)*(2/3-s)*6:e}function LF(e,r){return s=>s>0?r:e}let LL=(e,r,s)=>{let n=e*e,i=s*(r*r-n)+n;return i<0?0:Math.sqrt(i)},LO=[I1,I0,I9];function LB(e){let r=LO.find(r=>r.test(e));if(PN(!!r,`'${e}' is not an animatable color. Use the equivalent color code instead.`,"color-not-animatable"),!r)return!1;let s=r.parse(e);return r===I9&&(s=function({hue:e,saturation:r,lightness:s,alpha:n}){e/=360,s/=100;let i=0,a=0,o=0;if(r/=100){let n=s<.5?s*(1+r):s+r-s*r,l=2*s-n;i=LP(l,n,e+1/3),a=LP(l,n,e),o=LP(l,n,e-1/3)}else i=a=o=s;return{red:Math.round(255*i),green:Math.round(255*a),blue:Math.round(255*o),alpha:n}}(s)),s}let Lz=(e,r)=>{let s=LB(e),n=LB(r);if(!s||!n)return LF(e,r);let i={...s};return e=>(i.red=LL(s.red,n.red,e),i.green=LL(s.green,n.green,e),i.blue=LL(s.blue,n.blue,e),i.alpha=FH(s.alpha,n.alpha,e),I0.transform(i))},L$=new Set(["none","hidden"]);function LW(e,r){return s=>FH(e,r,s)}function LH(e){return"number"==typeof e?LW:"string"==typeof e?PA(e)?LF:Pe.test(e)?Lz:Lq:Array.isArray(e)?LU:"object"==typeof e?Pe.test(e)?Lz:LV:LF}function LU(e,r){let s=[...e],n=s.length,i=e.map((e,s)=>LH(e)(e,r[s]));return e=>{for(let r=0;r<n;r++)s[r]=i[r](e);return s}}function LV(e,r){let s={...e,...r},n={};for(let i in s)void 0!==e[i]&&void 0!==r[i]&&(n[i]=LH(e[i])(e[i],r[i]));return e=>{for(let r in n)s[r]=n[r](e);return s}}let Lq=(e,r)=>{let s=Pc.createTransformer(r),n=Pi(e),i=Pi(r);if(!(n.indexes.var.length===i.indexes.var.length&&n.indexes.color.length===i.indexes.color.length&&n.indexes.number.length>=i.indexes.number.length))return PN(!0,`Complex values '${e}' and '${r}' too different to mix. Ensure all colors are of the same type, and that each contains the same quantity of number and color values. Falling back to instant transition.`,"complex-values-different"),LF(e,r);if(L$.has(e)&&!i.values.length||L$.has(r)&&!n.values.length)return L$.has(e)?s=>s<=0?e:r:s=>s>=1?r:e;return LM(LU(function(e,r){let s=[],n={color:0,var:0,number:0};for(let i=0;i<r.values.length;i++){let a=r.types[i],o=e.indexes[a][n[a]],l=e.values[o]??0;s[i]=l,n[a]++}return s}(n,i),i.values),s)};function LK(e,r,s){return"number"==typeof e&&"number"==typeof r&&"number"==typeof s?FH(e,r,s):LH(e)(e,r)}let LX=e=>{let r=({timestamp:r})=>e(r);return{start:(e=!0)=>P0.update(r,e),stop:()=>P1(r),now:()=>P2.isProcessing?P2.timestamp:Fc.now()}},LY=(e,r,s=10)=>{let n="",i=Math.max(Math.round(r/s),2);for(let r=0;r<i;r++)n+=Math.round(1e4*e(r/(i-1)))/1e4+", ";return`linear(${n.substring(0,n.length-2)})`};function LG(e){let r=0,s=e.next(r);for(;!s.done&&r<2e4;)r+=50,s=e.next(r);return r>=2e4?1/0:r}function LJ(e,r,s){var n,i;let a=Math.max(r-5,0);return n=s-e(a),(i=r-a)?1e3/i*n:0}let LZ=.01,LQ=2,L0=.005,L1=.5;function L2(e,r){return e*Math.sqrt(1-r*r)}let L5=["duration","bounce"],L3=["stiffness","damping","mass"];function L4(e,r){return r.some(r=>void 0!==e[r])}function L6(e=.3,r=.3){let s,n="object"!=typeof e?{visualDuration:e,keyframes:[0,1],bounce:r}:e,{restSpeed:i,restDelta:a}=n,o=n.keyframes[0],l=n.keyframes[n.keyframes.length-1],c={done:!1,value:o},{stiffness:d,damping:u,mass:h,duration:f,velocity:p,isResolvedFromDuration:m}=function(e){let r={velocity:0,stiffness:100,damping:10,mass:1,isResolvedFromDuration:!1,...e};if(!L4(e,L3)&&L4(e,L5))if(e.visualDuration){let s=2*Math.PI/(1.2*e.visualDuration),n=s*s,i=2*IU(.05,1,1-(e.bounce||0))*Math.sqrt(n);r={...r,mass:1,stiffness:n,damping:i}}else{let s=function({duration:e=800,bounce:r=.3,velocity:s=0,mass:n=1}){let i,a;PN(e<=LR(10),"Spring duration must be 10 seconds or less","spring-duration-limit");let o=1-r;o=IU(.05,1,o),e=IU(.01,10,e/1e3),o<1?(i=r=>{let n=r*o,i=n*e;return .001-(n-s)/L2(r,o)*Math.exp(-i)},a=r=>{let n=r*o*e,a=Math.pow(o,2)*Math.pow(r,2)*e,l=Math.exp(-n),c=L2(Math.pow(r,2),o);return(n*s+s-a)*l*(-i(r)+.001>0?-1:1)/c}):(i=r=>-.001+Math.exp(-r*e)*((r-s)*e+1),a=r=>e*e*(s-r)*Math.exp(-r*e));let l=function(e,r,s){let n=s;for(let s=1;s<12;s++)n-=e(n)/r(n);return n}(i,a,5/e);if(e=LR(e),isNaN(l))return{stiffness:100,damping:10,duration:e};{let r=Math.pow(l,2)*n;return{stiffness:r,damping:2*o*Math.sqrt(n*r),duration:e}}}(e);(r={...r,...s,mass:1}).isResolvedFromDuration=!0}return r}({...n,velocity:-((n.velocity||0)/1e3)}),g=p||0,x=u/(2*Math.sqrt(d*h)),v=l-o,y=Math.sqrt(d/h)/1e3,b=5>Math.abs(v);if(i||(i=b?LZ:LQ),a||(a=b?L0:L1),x<1){let e=L2(y,x);s=r=>l-Math.exp(-x*y*r)*((g+x*y*v)/e*Math.sin(e*r)+v*Math.cos(e*r))}else if(1===x)s=e=>l-Math.exp(-y*e)*(v+(g+y*v)*e);else{let e=y*Math.sqrt(x*x-1);s=r=>{let s=Math.exp(-x*y*r),n=Math.min(e*r,300);return l-s*((g+x*y*v)*Math.sinh(n)+e*v*Math.cosh(n))/e}}let w={calculatedDuration:m&&f||null,next:e=>{let r=s(e);if(m)c.done=e>=f;else{let n=0===e?g:0;x<1&&(n=0===e?LR(g):LJ(s,e,r));let o=Math.abs(l-r)<=a;c.done=Math.abs(n)<=i&&o}return c.value=c.done?l:r,c},toString:()=>{let e=Math.min(LG(w),2e4),r=LY(r=>w.next(e*r).value,e,30);return e+"ms "+r},toTransition:()=>{}};return w}function L7({keyframes:e,velocity:r=0,power:s=.8,timeConstant:n=325,bounceDamping:i=10,bounceStiffness:a=500,modifyTarget:o,min:l,max:c,restDelta:d=.5,restSpeed:u}){let h,f,p=e[0],m={done:!1,value:p},g=s*r,x=p+g,v=void 0===o?x:o(x);v!==x&&(g=v-p);let y=e=>-g*Math.exp(-e/n),b=e=>v+y(e),w=e=>{let r=y(e),s=b(e);m.done=Math.abs(r)<=d,m.value=m.done?v:s},_=e=>{let r;if(r=m.value,void 0!==l&&r<l||void 0!==c&&r>c){var s;h=e,f=L6({keyframes:[m.value,(s=m.value,void 0===l?c:void 0===c||Math.abs(l-s)<Math.abs(c-s)?l:c)],velocity:LJ(b,e,m.value),damping:i,stiffness:a,restDelta:d,restSpeed:u})}};return _(0),{calculatedDuration:null,next:e=>{let r=!1;return(f||void 0!==h||(r=!0,w(e),_(e)),void 0!==h&&e>=h)?f.next(e-h):(r||w(e),m)}}}L6.applyToOptions=e=>{let r=function(e,r=100,s){let n=s({...e,keyframes:[0,r]}),i=Math.min(LG(n),2e4);return{type:"keyframes",ease:e=>n.next(i*e).value/r,duration:i/1e3}}(e,100,L6);return e.ease=r.ease,e.duration=LR(r.duration),e.type="keyframes",e};let L8=(e,r,s)=>(((1-3*s+3*r)*e+(3*s-6*r))*e+3*r)*e;function L9(e,r,s,n){return e===r&&s===n?PG:i=>0===i||1===i?i:L8(function(e,r,s,n,i){let a,o,l=0;do(a=L8(o=r+(s-r)/2,n,i)-e)>0?s=o:r=o;while(Math.abs(a)>1e-7&&++l<12)return o}(i,0,1,e,s),r,n)}let Oe=L9(.42,0,1,1),Ot=L9(0,0,.58,1),Or=L9(.42,0,.58,1),Os=e=>r=>r<=.5?e(2*r)/2:(2-e(2*(1-r)))/2,On=e=>r=>1-e(1-r),Oi=L9(.33,1.53,.69,.99),Oa=On(Oi),Oo=Os(Oa),Ol=e=>(e*=2)<1?.5*Oa(e):.5*(2-Math.pow(2,-10*(e-1))),Oc=e=>1-Math.sin(Math.acos(e)),Od=On(Oc),Ou=Os(Oc),Oh=e=>Array.isArray(e)&&"number"==typeof e[0],Of={linear:PG,easeIn:Oe,easeInOut:Or,easeOut:Ot,circIn:Oc,circInOut:Ou,circOut:Od,backIn:Oa,backInOut:Oo,backOut:Oi,anticipate:Ol},Op=e=>{if(Oh(e)){PE(4===e.length,"Cubic bezier arrays must contain four numerical values.","cubic-bezier-length");let[r,s,n,i]=e;return L9(r,s,n,i)}return"string"==typeof e?(PE(void 0!==Of[e],`Invalid easing type '${e}'`,"invalid-easing-type"),Of[e]):e},Om=(e,r,s)=>{let n=r-e;return 0===n?1:(s-e)/n};function Og({duration:e=300,keyframes:r,times:s,ease:n="easeInOut"}){var i;let a,o=Array.isArray(n)&&"number"!=typeof n[0]?n.map(Op):Op(n),l={done:!1,value:r[0]},c=function(e,r,{clamp:s=!0,ease:n,mixer:i}={}){let a=e.length;if(PE(a===r.length,"Both input and output ranges must be the same length","range-length"),1===a)return()=>r[0];if(2===a&&r[0]===r[1])return()=>r[1];let o=e[0]===e[1];e[0]>e[a-1]&&(e=[...e].reverse(),r=[...r].reverse());let l=function(e,r,s){let n=[],i=s||PJ.mix||LK,a=e.length-1;for(let s=0;s<a;s++){let a=i(e[s],e[s+1]);r&&(a=LM(Array.isArray(r)?r[s]||PG:r,a)),n.push(a)}return n}(r,n,i),c=l.length,d=s=>{if(o&&s<e[0])return r[0];let n=0;if(c>1)for(;n<e.length-2&&!(s<e[n+1]);n++);let i=Om(e[n],e[n+1],s);return l[n](i)};return s?r=>d(IU(e[0],e[a-1],r)):d}((i=s&&s.length===r.length?s:(!function(e,r){let s=e[e.length-1];for(let n=1;n<=r;n++){let i=Om(0,r,n);e.push(FH(s,1,i))}}(a=[0],r.length-1),a),i.map(r=>r*e)),r,{ease:Array.isArray(o)?o:r.map(()=>o||Or).splice(0,r.length-1)});return{calculatedDuration:e,next:r=>(l.value=c(r),l.done=r>=e,l)}}let Ox=e=>null!==e;function Ov(e,{repeat:r,repeatType:s="loop"},n,i=1){let a=e.filter(Ox),o=i<0||r&&"loop"!==s&&r%2==1?0:a.length-1;return o&&void 0!==n?n:a[o]}let Oy={decay:L7,inertia:L7,tween:Og,keyframes:Og,spring:L6};function Ob(e){"string"==typeof e.type&&(e.type=Oy[e.type])}class Ow{constructor(){this.updateFinished()}get finished(){return this._finished}updateFinished(){this._finished=new Promise(e=>{this.resolve=e})}notifyFinished(){this.resolve()}then(e,r){return this.finished.then(e,r)}}let O_=e=>e/100;class OS extends Ow{constructor(e){super(),this.state="idle",this.startTime=null,this.isStopped=!1,this.currentTime=0,this.holdTime=null,this.playbackSpeed=1,this.stop=()=>{let{motionValue:e}=this.options;e&&e.updatedAt!==Fc.now()&&this.tick(Fc.now()),this.isStopped=!0,"idle"!==this.state&&(this.teardown(),this.options.onStop?.())},LI.mainThread++,this.options=e,this.initAnimation(),this.play(),!1===e.autoplay&&this.pause()}initAnimation(){let{options:e}=this;Ob(e);let{type:r=Og,repeat:s=0,repeatDelay:n=0,repeatType:i,velocity:a=0}=e,{keyframes:o}=e,l=r||Og;l!==Og&&"number"!=typeof o[0]&&(this.mixKeyframes=LM(O_,LK(o[0],o[1])),o=[0,100]);let c=l({...e,keyframes:o});"mirror"===i&&(this.mirroredGenerator=l({...e,keyframes:[...o].reverse(),velocity:-a})),null===c.calculatedDuration&&(c.calculatedDuration=LG(c));let{calculatedDuration:d}=c;this.calculatedDuration=d,this.resolvedDuration=d+n,this.totalDuration=this.resolvedDuration*(s+1)-n,this.generator=c}updateTime(e){let r=Math.round(e-this.startTime)*this.playbackSpeed;null!==this.holdTime?this.currentTime=this.holdTime:this.currentTime=r}tick(e,r=!1){let{generator:s,totalDuration:n,mixKeyframes:i,mirroredGenerator:a,resolvedDuration:o,calculatedDuration:l}=this;if(null===this.startTime)return s.next(0);let{delay:c=0,keyframes:d,repeat:u,repeatType:h,repeatDelay:f,type:p,onUpdate:m,finalKeyframe:g}=this.options;this.speed>0?this.startTime=Math.min(this.startTime,e):this.speed<0&&(this.startTime=Math.min(e-n/this.speed,this.startTime)),r?this.currentTime=e:this.updateTime(e);let x=this.currentTime-c*(this.playbackSpeed>=0?1:-1),v=this.playbackSpeed>=0?x<0:x>n;this.currentTime=Math.max(x,0),"finished"===this.state&&null===this.holdTime&&(this.currentTime=n);let y=this.currentTime,b=s;if(u){let e=Math.min(this.currentTime,n)/o,r=Math.floor(e),s=e%1;!s&&e>=1&&(s=1),1===s&&r--,(r=Math.min(r,u+1))%2&&("reverse"===h?(s=1-s,f&&(s-=f/o)):"mirror"===h&&(b=a)),y=IU(0,1,s)*o}let w=v?{done:!1,value:d[0]}:b.next(y);i&&(w.value=i(w.value));let{done:_}=w;v||null===l||(_=this.playbackSpeed>=0?this.currentTime>=n:this.currentTime<=0);let S=null===this.holdTime&&("finished"===this.state||"running"===this.state&&_);return S&&p!==L7&&(w.value=Ov(d,this.options,g,this.speed)),m&&m(w.value),S&&this.finish(),w}then(e,r){return this.finished.then(e,r)}get duration(){return this.calculatedDuration/1e3}get iterationDuration(){let{delay:e=0}=this.options||{};return this.duration+e/1e3}get time(){return this.currentTime/1e3}set time(e){e=LR(e),this.currentTime=e,null===this.startTime||null!==this.holdTime||0===this.playbackSpeed?this.holdTime=e:this.driver&&(this.startTime=this.driver.now()-e/this.playbackSpeed),this.driver?.start(!1)}get speed(){return this.playbackSpeed}set speed(e){this.updateTime(Fc.now());let r=this.playbackSpeed!==e;this.playbackSpeed=e,r&&(this.time=this.currentTime/1e3)}play(){if(this.isStopped)return;let{driver:e=LX,startTime:r}=this.options;this.driver||(this.driver=e(e=>this.tick(e))),this.options.onPlay?.();let s=this.driver.now();"finished"===this.state?(this.updateFinished(),this.startTime=s):null!==this.holdTime?this.startTime=s-this.holdTime:this.startTime||(this.startTime=r??s),"finished"===this.state&&this.speed<0&&(this.startTime+=this.calculatedDuration),this.holdTime=null,this.state="running",this.driver.start()}pause(){this.state="paused",this.updateTime(Fc.now()),this.holdTime=this.currentTime}complete(){"running"!==this.state&&this.play(),this.state="finished",this.holdTime=null}finish(){this.notifyFinished(),this.teardown(),this.state="finished",this.options.onComplete?.()}cancel(){this.holdTime=null,this.startTime=0,this.tick(0),this.teardown(),this.options.onCancel?.()}teardown(){this.state="idle",this.stopDriver(),this.startTime=this.holdTime=null,LI.mainThread--}stopDriver(){this.driver&&(this.driver.stop(),this.driver=void 0)}sample(e){return this.startTime=0,this.tick(e,!0)}attachTimeline(e){return this.options.allowFlatten&&(this.options.type="keyframes",this.options.ease="linear",this.initAnimation()),this.driver?.stop(),e.observe(this)}}function Ok(e){let r;return()=>(void 0===r&&(r=e()),r)}let Oj=Ok(()=>void 0!==window.ScrollTimeline),OC={},ON=(y=Ok(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch(e){return!1}return!0}),()=>OC.linearEasing??y()),OE=([e,r,s,n])=>`cubic-bezier(${e}, ${r}, ${s}, ${n})`,OD={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:OE([0,.65,.55,1]),circOut:OE([.55,0,1,.45]),backIn:OE([.31,.01,.66,-.59]),backOut:OE([.33,1.53,.69,.99])};function OT(e){return"function"==typeof e&&"applyToOptions"in e}class OR extends Ow{constructor(e){if(super(),this.finishedTime=null,this.isStopped=!1,this.manualStartTime=null,!e)return;const{element:r,name:s,keyframes:n,pseudoElement:i,allowFlatten:a=!1,finalKeyframe:o,onComplete:l}=e;this.isPseudoElement=!!i,this.allowFlatten=a,this.options=e,PE("string"!=typeof e.type,'Mini animate() doesn\'t support "type" as a string.',"mini-spring");const c=function({type:e,...r}){return OT(e)&&ON()?e.applyToOptions(r):(r.duration??(r.duration=300),r.ease??(r.ease="easeOut"),r)}(e);this.animation=function(e,r,s,{delay:n=0,duration:i=300,repeat:a=0,repeatType:o="loop",ease:l="easeOut",times:c}={},d){let u={[r]:s};c&&(u.offset=c);let h=function e(r,s){if(r)return"function"==typeof r?ON()?LY(r,s):"ease-out":Oh(r)?OE(r):Array.isArray(r)?r.map(r=>e(r,s)||OD.easeOut):OD[r]}(l,i);Array.isArray(h)&&(u.easing=h);let f={delay:n,duration:i,easing:Array.isArray(h)?"linear":h,fill:"both",iterations:a+1,direction:"reverse"===o?"alternate":"normal"};d&&(f.pseudoElement=d);let p=e.animate(u,f);return p}(r,s,n,c,i),!1===c.autoplay&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!i){let e=Ov(n,this.options,o,this.speed);this.updateMotionValue?this.updateMotionValue(e):s.startsWith("--")?r.style.setProperty(s,e):r.style[s]=e,this.animation.cancel()}l?.(),this.notifyFinished()}}play(){this.isStopped||(this.manualStartTime=null,this.animation.play(),"finished"===this.state&&this.updateFinished())}pause(){this.animation.pause()}complete(){this.animation.finish?.()}cancel(){try{this.animation.cancel()}catch(e){}}stop(){if(this.isStopped)return;this.isStopped=!0;let{state:e}=this;"idle"!==e&&"finished"!==e&&(this.updateMotionValue?this.updateMotionValue():this.commitStyles(),this.isPseudoElement||this.cancel())}commitStyles(){this.isPseudoElement||this.animation.commitStyles?.()}get duration(){return Number(this.animation.effect?.getComputedTiming?.().duration||0)/1e3}get iterationDuration(){let{delay:e=0}=this.options||{};return this.duration+e/1e3}get time(){return(Number(this.animation.currentTime)||0)/1e3}set time(e){this.manualStartTime=null,this.finishedTime=null,this.animation.currentTime=LR(e)}get speed(){return this.animation.playbackRate}set speed(e){e<0&&(this.finishedTime=null),this.animation.playbackRate=e}get state(){return null!==this.finishedTime?"finished":this.animation.playState}get startTime(){return this.manualStartTime??Number(this.animation.startTime)}set startTime(e){this.manualStartTime=this.animation.startTime=e}attachTimeline({timeline:e,observe:r}){return(this.allowFlatten&&this.animation.effect?.updateTiming({easing:"linear"}),this.animation.onfinish=null,e&&Oj())?(this.animation.timeline=e,PG):r(this)}}let OA={anticipate:Ol,backInOut:Oo,circInOut:Ou};class OM extends OR{constructor(e){!function(e){"string"==typeof e.ease&&e.ease in OA&&(e.ease=OA[e.ease])}(e),Ob(e),super(e),void 0!==e.startTime&&(this.startTime=e.startTime),this.options=e}updateMotionValue(e){let{motionValue:r,onUpdate:s,onComplete:n,element:i,...a}=this.options;if(!r)return;if(void 0!==e)return void r.set(e);let o=new OS({...a,autoplay:!1}),l=Math.max(10,Fc.now()-this.startTime),c=IU(0,10,l-10);r.setWithVelocity(o.sample(Math.max(0,l-c)).value,o.sample(l).value,c),o.stop()}}let OI=(e,r)=>"zIndex"!==r&&!!("number"==typeof e||Array.isArray(e)||"string"==typeof e&&(Pc.test(e)||"0"===e)&&!e.startsWith("url("));function OP(e){e.duration=0,e.type="keyframes"}let OF=new Set(["opacity","clipPath","filter","transform"]),OL=Ok(()=>Object.hasOwnProperty.call(Element.prototype,"animate"));class OO extends Ow{constructor({autoplay:e=!0,delay:r=0,type:s="keyframes",repeat:n=0,repeatDelay:i=0,repeatType:a="loop",keyframes:o,name:l,motionValue:c,element:d,...u}){super(),this.stop=()=>{this._animation&&(this._animation.stop(),this.stopTimeline?.()),this.keyframeResolver?.cancel()},this.createdAt=Fc.now();const h={autoplay:e,delay:r,type:s,repeat:n,repeatDelay:i,repeatType:a,name:l,motionValue:c,element:d,...u},f=d?.KeyframeResolver||Fe;this.keyframeResolver=new f(o,(e,r,s)=>this.onKeyframesResolved(e,r,h,!s),l,c,d),this.keyframeResolver?.scheduleResolve()}onKeyframesResolved(e,r,s,n){this.keyframeResolver=void 0;let{name:i,type:a,velocity:o,delay:l,isHandoff:c,onUpdate:d}=s;this.resolvedAt=Fc.now(),!function(e,r,s,n){let i=e[0];if(null===i)return!1;if("display"===r||"visibility"===r)return!0;let a=e[e.length-1],o=OI(i,r),l=OI(a,r);return PN(o===l,`You are trying to animate ${r} from "${i}" to "${a}". "${o?a:i}" is not an animatable value.`,"value-not-animatable"),!!o&&!!l&&(function(e){let r=e[0];if(1===e.length)return!0;for(let s=0;s<e.length;s++)if(e[s]!==r)return!0}(e)||("spring"===s||OT(s))&&n)}(e,i,a,o)&&((PJ.instantAnimations||!l)&&d?.(Ov(e,s,r)),e[0]=e[e.length-1],OP(s),s.repeat=0);let u={startTime:n?this.resolvedAt&&this.resolvedAt-this.createdAt>40?this.resolvedAt:this.createdAt:void 0,finalKeyframe:r,...s,keyframes:e},h=!c&&function(e){let{motionValue:r,name:s,repeatDelay:n,repeatType:i,damping:a,type:o}=e;if(!(r?.owner?.current instanceof HTMLElement))return!1;let{onUpdate:l,transformTemplate:c}=r.owner.getProps();return OL()&&s&&OF.has(s)&&("transform"!==s||!c)&&!l&&!n&&"mirror"!==i&&0!==a&&"inertia"!==o}(u),f=u.motionValue?.owner?.current,p=h?new OM({...u,element:f}):new OS(u);p.finished.then(()=>{this.notifyFinished()}).catch(PG),this.pendingTimeline&&(this.stopTimeline=p.attachTimeline(this.pendingTimeline),this.pendingTimeline=void 0),this._animation=p}get finished(){return this._animation?this.animation.finished:this._finished}then(e,r){return this.finished.finally(e).then(()=>{})}get animation(){return this._animation||(this.keyframeResolver?.resume(),P7=!0,P9(),P8(),P7=!1),this._animation}get duration(){return this.animation.duration}get iterationDuration(){return this.animation.iterationDuration}get time(){return this.animation.time}set time(e){this.animation.time=e}get speed(){return this.animation.speed}get state(){return this.animation.state}set speed(e){this.animation.speed=e}get startTime(){return this.animation.startTime}attachTimeline(e){return this._animation?this.stopTimeline=this.animation.attachTimeline(e):this.pendingTimeline=e,()=>this.stop()}play(){this.animation.play()}pause(){this.animation.pause()}complete(){this.animation.complete()}cancel(){this._animation&&this.animation.cancel(),this.keyframeResolver?.cancel()}}let OB={type:"spring",stiffness:500,damping:25,restSpeed:10},Oz={type:"keyframes",duration:.8},O$={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},OW=e=>null!==e,OH=(e,r,s,n={},i,a)=>o=>{let l=LE(n,e)||{},c=l.delay||n.delay||0,{elapsed:d=0}=n;d-=LR(c);let u={keyframes:Array.isArray(s)?s:[null,s],ease:"easeOut",velocity:r.getVelocity(),...l,delay:-d,onUpdate:e=>{r.set(e),l.onUpdate&&l.onUpdate(e)},onComplete:()=>{o(),l.onComplete&&l.onComplete()},name:e,motionValue:r,element:a?void 0:i};!function({when:e,delay:r,delayChildren:s,staggerChildren:n,staggerDirection:i,repeat:a,repeatType:o,repeatDelay:l,from:c,elapsed:d,...u}){return!!Object.keys(u).length}(l)&&Object.assign(u,((e,{keyframes:r})=>r.length>2?Oz:IH.has(e)?e.startsWith("scale")?{type:"spring",stiffness:550,damping:0===r[1]?2*Math.sqrt(550):30,restSpeed:10}:OB:O$)(e,u)),u.duration&&(u.duration=LR(u.duration)),u.repeatDelay&&(u.repeatDelay=LR(u.repeatDelay)),void 0!==u.from&&(u.keyframes[0]=u.from);let h=!1;if(!1!==u.type&&(0!==u.duration||u.repeatDelay)||(OP(u),0===u.delay&&(h=!0)),(PJ.instantAnimations||PJ.skipAnimations)&&(h=!0,OP(u),u.delay=0),u.allowFlatten=!l.type&&!l.ease,h&&!a&&void 0!==r.get()){let e=function(e,{repeat:r,repeatType:s="loop"},n){let i=e.filter(OW),a=r&&"loop"!==s&&r%2==1?0:i.length-1;return i[a]}(u.keyframes,l);if(void 0!==e)return void P0.update(()=>{u.onUpdate(e),u.onComplete()})}return l.isSync?new OS(u):new OO(u)};function OU(e,r,{delay:s=0,transitionOverride:n,type:i}={}){let{transition:a=e.getDefaultTransition(),transitionEnd:o,...l}=r,c=a?.reduceMotion;n&&(a=n);let d=[],u=i&&e.animationState&&e.animationState.getState()[i];for(let r in l){let n=e.getValue(r,e.latestValues[r]??null),i=l[r];if(void 0===i||u&&function({protectedKeys:e,needsAnimating:r},s){let n=e.hasOwnProperty(s)&&!0!==r[s];return r[s]=!1,n}(u,r))continue;let o={delay:s,...LE(a||{},r)},h=n.get();if(void 0!==h&&!n.isAnimating&&!Array.isArray(i)&&i===h&&!o.velocity)continue;let f=!1;if(window.MotionHandoffAnimation){let s=e.props[Lw];if(s){let e=window.MotionHandoffAnimation(s,r,P0);null!==e&&(o.startTime=e,f=!0)}}LT(e,r);let p=c??e.shouldReduceMotion;n.start(OH(r,n,i,p&&PS.has(r)?{type:!1}:o,e,f));let m=n.animation;m&&d.push(m)}return o&&Promise.all(d).then(()=>{P0.update(()=>{o&&function(e,r){let{transitionEnd:s={},transition:n={},...i}=LN(e,r)||{};for(let r in i={...i,...s}){var a;let s=LD(a=i[r])?a[a.length-1]||0:a;e.hasValue(r)?e.getValue(r).set(s):e.addValue(r,Fu(s))}}(e,o)})}),d}function OV(e,r,s,n=0,i=1){let a=Array.from(e).sort((e,r)=>e.sortNodePosition(r)).indexOf(r),o=e.size,l=(o-1)*n;return"function"==typeof s?s(a,o):1===i?a*n:l-a*n}function Oq(e,r,s={}){let n=LN(e,r,"exit"===s.type?e.presenceContext?.custom:void 0),{transition:i=e.getDefaultTransition()||{}}=n||{};s.transitionOverride&&(i=s.transitionOverride);let a=n?()=>Promise.all(OU(e,n,s)):()=>Promise.resolve(),o=e.variantChildren&&e.variantChildren.size?(n=0)=>{let{delayChildren:a=0,staggerChildren:o,staggerDirection:l}=i;return function(e,r,s=0,n=0,i=0,a=1,o){let l=[];for(let c of e.variantChildren)c.notify("AnimationStart",r),l.push(Oq(c,r,{...o,delay:s+("function"==typeof n?0:n)+OV(e.variantChildren,c,n,i,a)}).then(()=>c.notify("AnimationComplete",r)));return Promise.all(l)}(e,r,n,a,o,l,s)}:()=>Promise.resolve(),{when:l}=i;if(!l)return Promise.all([a(),o(s.delay)]);{let[e,r]="beforeChildren"===l?[a,o]:[o,a];return e().then(()=>r())}}let OK=Fb.length;function OX(e,r){if(!Array.isArray(r))return!1;let s=r.length;if(s!==e.length)return!1;for(let n=0;n<s;n++)if(r[n]!==e[n])return!1;return!0}let OY=[...Fy].reverse(),OG=Fy.length;function OJ(e=!1){return{isActive:e,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function OZ(){return{animate:OJ(!0),whileInView:OJ(),whileHover:OJ(),whileTap:OJ(),whileDrag:OJ(),whileFocus:OJ(),exit:OJ()}}let OQ=0;function O0(e){return[e("x"),e("y")]}let O1=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);function O2(e){return O1.has(e.tagName)||!0===e.isContentEditable}function O5(e,r,s,n={passive:!0}){return e.addEventListener(r,s,n),()=>e.removeEventListener(r,s)}let O3={x:!1,y:!1};function O4(e){return e.max-e.min}function O6(e,r,s,n=.5){e.origin=n,e.originPoint=FH(r.min,r.max,e.origin),e.scale=O4(s)/O4(r),e.translate=FH(s.min,s.max,e.origin)-e.originPoint,(e.scale>=.9999&&e.scale<=1.0001||isNaN(e.scale))&&(e.scale=1),(e.translate>=-.01&&e.translate<=.01||isNaN(e.translate))&&(e.translate=0)}function O7(e,r,s,n){O6(e.x,r.x,s.x,n?n.originX:void 0),O6(e.y,r.y,s.y,n?n.originY:void 0)}function O8(e,r,s){e.min=s.min+r.min,e.max=e.min+O4(r)}function O9(e,r,s){e.min=r.min-s.min,e.max=e.min+O4(r)}function Be(e,r,s){O9(e.x,r.x,s.x),O9(e.y,r.y,s.y)}let Bt=e=>"mouse"===e.pointerType?"number"!=typeof e.button||e.button<=0:!1!==e.isPrimary;function Br(e){return{point:{x:e.pageX,y:e.pageY}}}function Bs(e,r,s,n){return O5(e,r,e=>Bt(e)&&s(e,Br(e)),n)}let Bn=({current:e})=>e?e.ownerDocument.defaultView:null,Bi=(e,r)=>Math.abs(e-r),Ba=new Set(["auto","scroll"]);class Bo{constructor(e,r,{transformPagePoint:s,contextWindow:n=window,dragSnapToOrigin:i=!1,distanceThreshold:a=3,element:o}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.scrollPositions=new Map,this.removeScrollListeners=null,this.onElementScroll=e=>{this.handleScroll(e.target)},this.onWindowScroll=()=>{this.handleScroll(window)},this.updatePoint=()=>{var e,r;if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;let s=Bd(this.lastMoveEventInfo,this.history),n=null!==this.startEvent,i=(e=s.offset,r={x:0,y:0},Math.sqrt(Bi(e.x,r.x)**2+Bi(e.y,r.y)**2)>=this.distanceThreshold);if(!n&&!i)return;let{point:a}=s,{timestamp:o}=P2;this.history.push({...a,timestamp:o});let{onStart:l,onMove:c}=this.handlers;n||(l&&l(this.lastMoveEvent,s),this.startEvent=this.lastMoveEvent),c&&c(this.lastMoveEvent,s)},this.handlePointerMove=(e,r)=>{this.lastMoveEvent=e,this.lastMoveEventInfo=Bl(r,this.transformPagePoint),P0.update(this.updatePoint,!0)},this.handlePointerUp=(e,r)=>{this.end();let{onEnd:s,onSessionEnd:n,resumeAnimation:i}=this.handlers;if((this.dragSnapToOrigin||!this.startEvent)&&i&&i(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;let a=Bd("pointercancel"===e.type?this.lastMoveEventInfo:Bl(r,this.transformPagePoint),this.history);this.startEvent&&s&&s(e,a),n&&n(e,a)},!Bt(e))return;this.dragSnapToOrigin=i,this.handlers=r,this.transformPagePoint=s,this.distanceThreshold=a,this.contextWindow=n||window;const l=Bl(Br(e),this.transformPagePoint),{point:c}=l,{timestamp:d}=P2;this.history=[{...c,timestamp:d}];const{onSessionStart:u}=r;u&&u(e,Bd(l,this.history)),this.removeListeners=LM(Bs(this.contextWindow,"pointermove",this.handlePointerMove),Bs(this.contextWindow,"pointerup",this.handlePointerUp),Bs(this.contextWindow,"pointercancel",this.handlePointerUp)),o&&this.startScrollTracking(o)}startScrollTracking(e){let r=e.parentElement;for(;r;){let e=getComputedStyle(r);(Ba.has(e.overflowX)||Ba.has(e.overflowY))&&this.scrollPositions.set(r,{x:r.scrollLeft,y:r.scrollTop}),r=r.parentElement}this.scrollPositions.set(window,{x:window.scrollX,y:window.scrollY}),window.addEventListener("scroll",this.onElementScroll,{capture:!0,passive:!0}),window.addEventListener("scroll",this.onWindowScroll,{passive:!0}),this.removeScrollListeners=()=>{window.removeEventListener("scroll",this.onElementScroll,{capture:!0}),window.removeEventListener("scroll",this.onWindowScroll)}}handleScroll(e){let r=this.scrollPositions.get(e);if(!r)return;let s=e===window,n=s?{x:window.scrollX,y:window.scrollY}:{x:e.scrollLeft,y:e.scrollTop},i={x:n.x-r.x,y:n.y-r.y};(0!==i.x||0!==i.y)&&(s?this.lastMoveEventInfo&&(this.lastMoveEventInfo.point.x+=i.x,this.lastMoveEventInfo.point.y+=i.y):this.history.length>0&&(this.history[0].x-=i.x,this.history[0].y-=i.y),this.scrollPositions.set(e,n),P0.update(this.updatePoint,!0))}updateHandlers(e){this.handlers=e}end(){this.removeListeners&&this.removeListeners(),this.removeScrollListeners&&this.removeScrollListeners(),this.scrollPositions.clear(),P1(this.updatePoint)}}function Bl(e,r){return r?{point:r(e.point)}:e}function Bc(e,r){return{x:e.x-r.x,y:e.y-r.y}}function Bd({point:e},r){return{point:e,delta:Bc(e,Bu(r)),offset:Bc(e,r[0]),velocity:function(e,r){if(e.length<2)return{x:0,y:0};let s=e.length-1,n=null,i=Bu(e);for(;s>=0&&(n=e[s],!(i.timestamp-n.timestamp>LR(.1)));)s--;if(!n)return{x:0,y:0};let a=(i.timestamp-n.timestamp)/1e3;if(0===a)return{x:0,y:0};let o={x:(i.x-n.x)/a,y:(i.y-n.y)/a};return o.x===1/0&&(o.x=0),o.y===1/0&&(o.y=0),o}(r,.1)}}function Bu(e){return e[e.length-1]}function Bh(e,r,s){return{min:void 0!==r?e.min+r:void 0,max:void 0!==s?e.max+s-(e.max-e.min):void 0}}function Bf(e,r){let s=r.min-e.min,n=r.max-e.max;return r.max-r.min<e.max-e.min&&([s,n]=[n,s]),{min:s,max:n}}function Bp(e,r,s){return{min:Bm(e,r),max:Bm(e,s)}}function Bm(e,r){return"number"==typeof e?e:e[r]||0}let Bg=new WeakMap;class Bx{constructor(e){this.openDragLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic=Pw(),this.latestPointerEvent=null,this.latestPanInfo=null,this.visualElement=e}start(e,{snapToCursor:r=!1,distanceThreshold:s}={}){let{presenceContext:n}=this.visualElement;if(n&&!1===n.isPresent)return;let i=e=>{r?(this.stopAnimation(),this.snapToCursor(Br(e).point)):this.pauseAnimation()},a=(e,r)=>{this.stopAnimation();let{drag:s,dragPropagation:n,onDragStart:i}=this.getProps();if(s&&!n&&(this.openDragLock&&this.openDragLock(),this.openDragLock=function(e){if("x"===e||"y"===e)if(O3[e])return null;else return O3[e]=!0,()=>{O3[e]=!1};return O3.x||O3.y?null:(O3.x=O3.y=!0,()=>{O3.x=O3.y=!1})}(s),!this.openDragLock))return;this.latestPointerEvent=e,this.latestPanInfo=r,this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),O0(e=>{let r=this.getAxisMotionValue(e).get()||0;if(I3.test(r)){let{projection:s}=this.visualElement;if(s&&s.layout){let n=s.layout.layoutBox[e];n&&(r=O4(n)*(parseFloat(r)/100))}}this.originPoint[e]=r}),i&&P0.postRender(()=>i(e,r)),LT(this.visualElement,"transform");let{animationState:a}=this.visualElement;a&&a.setActive("whileDrag",!0)},o=(e,r)=>{this.latestPointerEvent=e,this.latestPanInfo=r;let{dragPropagation:s,dragDirectionLock:n,onDirectionLock:i,onDrag:a}=this.getProps();if(!s&&!this.openDragLock)return;let{offset:o}=r;if(n&&null===this.currentDirection){this.currentDirection=function(e,r=10){let s=null;return Math.abs(e.y)>r?s="y":Math.abs(e.x)>r&&(s="x"),s}(o),null!==this.currentDirection&&i&&i(this.currentDirection);return}this.updateAxis("x",r.point,o),this.updateAxis("y",r.point,o),this.visualElement.render(),a&&a(e,r)},l=(e,r)=>{this.latestPointerEvent=e,this.latestPanInfo=r,this.stop(e,r),this.latestPointerEvent=null,this.latestPanInfo=null},c=()=>O0(e=>"paused"===this.getAnimationState(e)&&this.getAxisMotionValue(e).animation?.play()),{dragSnapToOrigin:d}=this.getProps();this.panSession=new Bo(e,{onSessionStart:i,onStart:a,onMove:o,onSessionEnd:l,resumeAnimation:c},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:d,distanceThreshold:s,contextWindow:Bn(this.visualElement),element:this.visualElement.current})}stop(e,r){let s=e||this.latestPointerEvent,n=r||this.latestPanInfo,i=this.isDragging;if(this.cancel(),!i||!n||!s)return;let{velocity:a}=n;this.startAnimation(a);let{onDragEnd:o}=this.getProps();o&&P0.postRender(()=>o(s,n))}cancel(){this.isDragging=!1;let{projection:e,animationState:r}=this.visualElement;e&&(e.isAnimationBlocked=!1),this.endPanSession();let{dragPropagation:s}=this.getProps();!s&&this.openDragLock&&(this.openDragLock(),this.openDragLock=null),r&&r.setActive("whileDrag",!1)}endPanSession(){this.panSession&&this.panSession.end(),this.panSession=void 0}updateAxis(e,r,s){let{drag:n}=this.getProps();if(!s||!Bv(e,n,this.currentDirection))return;let i=this.getAxisMotionValue(e),a=this.originPoint[e]+s[e];this.constraints&&this.constraints[e]&&(a=function(e,{min:r,max:s},n){return void 0!==r&&e<r?e=n?FH(r,e,n.min):Math.max(e,r):void 0!==s&&e>s&&(e=n?FH(s,e,n.max):Math.min(e,s)),e}(a,this.constraints[e],this.elastic[e])),i.set(a)}resolveConstraints(){let{dragConstraints:e,dragElastic:r}=this.getProps(),s=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):this.visualElement.projection?.layout,n=this.constraints;e&&LS(e)?this.constraints||(this.constraints=this.resolveRefConstraints()):e&&s?this.constraints=function(e,{top:r,left:s,bottom:n,right:i}){return{x:Bh(e.x,s,i),y:Bh(e.y,r,n)}}(s.layoutBox,e):this.constraints=!1,this.elastic=function(e=.35){return!1===e?e=0:!0===e&&(e=.35),{x:Bp(e,"left","right"),y:Bp(e,"top","bottom")}}(r),n!==this.constraints&&s&&this.constraints&&!this.hasMutatedConstraints&&O0(e=>{var r,n;let i;!1!==this.constraints&&this.getAxisMotionValue(e)&&(this.constraints[e]=(r=s.layoutBox[e],n=this.constraints[e],i={},void 0!==n.min&&(i.min=n.min-r.min),void 0!==n.max&&(i.max=n.max-r.min),i))})}resolveRefConstraints(){var e;let{dragConstraints:r,onMeasureDragConstraints:s}=this.getProps();if(!r||!LS(r))return!1;let n=r.current;PE(null!==n,"If `dragConstraints` is set as a React ref, that ref must be passed to another component's `ref` prop.","drag-constraints-ref");let{projection:i}=this.visualElement;if(!i||!i.layout)return!1;let a=function(e,r,s){let n=F6(e,s),{scroll:i}=r;return i&&(F5(n.x,i.offset.x),F5(n.y,i.offset.y)),n}(n,i.root,this.visualElement.getTransformPagePoint()),o=(e=i.layout.layoutBox,{x:Bf(e.x,a.x),y:Bf(e.y,a.y)});if(s){let e=s(function({x:e,y:r}){return{top:r.min,right:e.max,bottom:r.max,left:e.min}}(o));this.hasMutatedConstraints=!!e,e&&(o=FY(e))}return o}startAnimation(e){let{drag:r,dragMomentum:s,dragElastic:n,dragTransition:i,dragSnapToOrigin:a,onDragTransitionEnd:o}=this.getProps(),l=this.constraints||{};return Promise.all(O0(o=>{if(!Bv(o,r,this.currentDirection))return;let c=l&&l[o]||{};a&&(c={min:0,max:0});let d={type:"inertia",velocity:s?e[o]:0,bounceStiffness:n?200:1e6,bounceDamping:n?40:1e7,timeConstant:750,restDelta:1,restSpeed:10,...i,...c};return this.startAxisValueAnimation(o,d)})).then(o)}startAxisValueAnimation(e,r){let s=this.getAxisMotionValue(e);return LT(this.visualElement,e),s.start(OH(e,s,0,r,this.visualElement,!1))}stopAnimation(){O0(e=>this.getAxisMotionValue(e).stop())}pauseAnimation(){O0(e=>this.getAxisMotionValue(e).animation?.pause())}getAnimationState(e){return this.getAxisMotionValue(e).animation?.state}getAxisMotionValue(e){let r=`_drag${e.toUpperCase()}`,s=this.visualElement.getProps();return s[r]||this.visualElement.getValue(e,(s.initial?s.initial[e]:void 0)||0)}snapToCursor(e){O0(r=>{let{drag:s}=this.getProps();if(!Bv(r,s,this.currentDirection))return;let{projection:n}=this.visualElement,i=this.getAxisMotionValue(r);if(n&&n.layout){let{min:s,max:a}=n.layout.layoutBox[r],o=i.get()||0;i.set(e[r]-FH(s,a,.5)+o)}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;let{drag:e,dragConstraints:r}=this.getProps(),{projection:s}=this.visualElement;if(!LS(r)||!s||!this.constraints)return;this.stopAnimation();let n={x:0,y:0};O0(e=>{let r=this.getAxisMotionValue(e);if(r&&!1!==this.constraints){var s,i;let a,o,l,c=r.get();n[e]=(s={min:c,max:c},i=this.constraints[e],a=.5,o=O4(s),(l=O4(i))>o?a=Om(i.min,i.max-o,s.min):o>l&&(a=Om(s.min,s.max-l,i.min)),IU(0,1,a))}});let{transformTemplate:i}=this.visualElement.getProps();this.visualElement.current.style.transform=i?i({},""):"none",s.root&&s.root.updateScroll(),s.updateLayout(),this.resolveConstraints(),O0(r=>{if(!Bv(r,e,null))return;let s=this.getAxisMotionValue(r),{min:i,max:a}=this.constraints[r];s.set(FH(i,a,n[r]))})}addListeners(){if(!this.visualElement.current)return;Bg.set(this.visualElement,this);let e=this.visualElement.current,r=Bs(e,"pointerdown",r=>{let{drag:s,dragListener:n=!0}=this.getProps(),i=r.target,a=i!==e&&O2(i);s&&n&&!a&&this.start(r)}),s=()=>{let{dragConstraints:e}=this.getProps();LS(e)&&e.current&&(this.constraints=this.resolveRefConstraints())},{projection:n}=this.visualElement,i=n.addEventListener("measure",s);n&&!n.layout&&(n.root&&n.root.updateScroll(),n.updateLayout()),P0.read(s);let a=O5(window,"resize",()=>this.scalePositionWithinConstraints()),o=n.addEventListener("didUpdate",({delta:e,hasLayoutChanged:r})=>{this.isDragging&&r&&(O0(r=>{let s=this.getAxisMotionValue(r);s&&(this.originPoint[r]+=e[r].translate,s.set(s.get()+e[r].translate))}),this.visualElement.render())});return()=>{a(),r(),i(),o&&o()}}getProps(){let e=this.visualElement.getProps(),{drag:r=!1,dragDirectionLock:s=!1,dragPropagation:n=!1,dragConstraints:i=!1,dragElastic:a=.35,dragMomentum:o=!0}=e;return{...e,drag:r,dragDirectionLock:s,dragPropagation:n,dragConstraints:i,dragElastic:a,dragMomentum:o}}}function Bv(e,r,s){return(!0===r||r===e)&&(null===s||s===e)}let By=e=>(r,s)=>{e&&P0.postRender(()=>e(r,s))},Bb={hasAnimatedSinceResize:!0,hasEverUpdated:!1};var Bw=V;let B_=!1;class BS extends Bw.Component{componentDidMount(){let{visualElement:e,layoutGroup:r,switchLayoutGroup:s,layoutId:n}=this.props,{projection:i}=e;i&&(r.group&&r.group.add(i),s&&s.register&&n&&s.register(i),B_&&i.root.didUpdate(),i.addEventListener("animationComplete",()=>{this.safeToRemove()}),i.setOptions({...i.options,layoutDependency:this.props.layoutDependency,onExitComplete:()=>this.safeToRemove()})),Bb.hasEverUpdated=!0}getSnapshotBeforeUpdate(e){let{layoutDependency:r,visualElement:s,drag:n,isPresent:i}=this.props,{projection:a}=s;return a&&(a.isPresent=i,e.layoutDependency!==r&&a.setOptions({...a.options,layoutDependency:r}),B_=!0,n||e.layoutDependency!==r||void 0===r||e.isPresent!==i?a.willUpdate():this.safeToRemove(),e.isPresent!==i&&(i?a.promote():a.relegate()||P0.postRender(()=>{let e=a.getStack();e&&e.members.length||this.safeToRemove()}))),null}componentDidUpdate(){let{projection:e}=this.props.visualElement;e&&(e.root.didUpdate(),Fo.postRender(()=>{!e.currentAnimation&&e.isLead()&&this.safeToRemove()}))}componentWillUnmount(){let{visualElement:e,layoutGroup:r,switchLayoutGroup:s}=this.props,{projection:n}=e;B_=!0,n&&(n.scheduleCheckAfterUnmount(),r&&r.group&&r.group.remove(n),s&&s.deregister&&s.deregister(n))}safeToRemove(){let{safeToRemove:e}=this.props;e&&e()}render(){return null}}function Bk(e){let[r,s]=function(e=!0){let r=(0,V.useContext)(Lh);if(null===r)return[!0,null];let{isPresent:s,onExitComplete:n,register:i}=r,a=(0,V.useId)();(0,V.useEffect)(()=>{if(e)return i(a)},[e]);let o=(0,V.useCallback)(()=>e&&n&&n(a),[a,n,e]);return!s&&n?[!1,o]:[!0]}(),n=(0,Bw.useContext)(Le);return(0,U.jsx)(BS,{...e,layoutGroup:n,switchLayoutGroup:(0,Bw.useContext)(L_),isPresent:r,safeToRemove:s})}function Bj(e){return"object"==typeof e&&null!==e}function BC(e){return Bj(e)&&"ownerSVGElement"in e}let BN=["TopLeft","TopRight","BottomLeft","BottomRight"],BE=BN.length,BD=e=>"string"==typeof e?parseFloat(e):e,BT=e=>"number"==typeof e||I4.test(e);function BR(e,r){return void 0!==e[r]?e[r]:e.borderRadius}let BA=BI(0,.5,Od),BM=BI(.5,.95,PG);function BI(e,r,s){return n=>n<e?0:n>r?1:s(Om(e,r,n))}function BP(e,r){e.min=r.min,e.max=r.max}function BF(e,r){BP(e.x,r.x),BP(e.y,r.y)}function BL(e,r){e.translate=r.translate,e.scale=r.scale,e.originPoint=r.originPoint,e.origin=r.origin}function BO(e,r,s,n,i){return e-=r,e=n+1/s*(e-n),void 0!==i&&(e=n+1/i*(e-n)),e}function BB(e,r,[s,n,i],a,o){!function(e,r=0,s=1,n=.5,i,a=e,o=e){if(I3.test(r)&&(r=parseFloat(r),r=FH(o.min,o.max,r/100)-o.min),"number"!=typeof r)return;let l=FH(a.min,a.max,n);e===a&&(l-=r),e.min=BO(e.min,r,s,l,i),e.max=BO(e.max,r,s,l,i)}(e,r[s],r[n],r[i],r.scale,a,o)}let Bz=["x","scaleX","originX"],B$=["y","scaleY","originY"];function BW(e,r,s,n){BB(e.x,r,Bz,s?s.x:void 0,n?n.x:void 0),BB(e.y,r,B$,s?s.y:void 0,n?n.y:void 0)}function BH(e){return 0===e.translate&&1===e.scale}function BU(e){return BH(e.x)&&BH(e.y)}function BV(e,r){return e.min===r.min&&e.max===r.max}function Bq(e,r){return Math.round(e.min)===Math.round(r.min)&&Math.round(e.max)===Math.round(r.max)}function BK(e,r){return Bq(e.x,r.x)&&Bq(e.y,r.y)}function BX(e){return O4(e.x)/O4(e.y)}function BY(e,r){return e.translate===r.translate&&e.scale===r.scale&&e.originPoint===r.originPoint}class BG{constructor(){this.members=[]}add(e){Fn(this.members,e),e.scheduleRender()}remove(e){if(Fi(this.members,e),e===this.prevLead&&(this.prevLead=void 0),e===this.lead){let e=this.members[this.members.length-1];e&&this.promote(e)}}relegate(e){let r,s=this.members.findIndex(r=>e===r);if(0===s)return!1;for(let e=s;e>=0;e--){let s=this.members[e];if(!1!==s.isPresent){r=s;break}}return!!r&&(this.promote(r),!0)}promote(e,r){let s=this.lead;if(e!==s&&(this.prevLead=s,this.lead=e,e.show(),s)){s.instance&&s.scheduleRender(),e.scheduleRender();let n=s.options.layoutDependency,i=e.options.layoutDependency;(void 0===n||void 0===i||n!==i)&&(e.resumeFrom=s,r&&(e.resumeFrom.preserveOpacity=!0),s.snapshot&&(e.snapshot=s.snapshot,e.snapshot.latestValues=s.animationValues||s.latestValues),e.root&&e.root.isUpdating&&(e.isLayoutDirty=!0));let{crossfade:a}=e.options;!1===a&&s.hide()}}exitAnimationComplete(){this.members.forEach(e=>{let{options:r,resumingFrom:s}=e;r.onExitComplete&&r.onExitComplete(),s&&s.options.onExitComplete&&s.options.onExitComplete()})}scheduleRender(){this.members.forEach(e=>{e.instance&&e.scheduleRender(!1)})}removeLeadSnapshot(){this.lead&&this.lead.snapshot&&(this.lead.snapshot=void 0)}}let BJ=(e,r)=>e.depth-r.depth;class BZ{constructor(){this.children=[],this.isDirty=!1}add(e){Fn(this.children,e),this.isDirty=!0}remove(e){Fi(this.children,e),this.isDirty=!0}forEach(e){this.isDirty&&this.children.sort(BJ),this.isDirty=!1,this.children.forEach(e)}}let BQ=["","X","Y","Z"],B0=0;function B1(e,r,s,n){let{latestValues:i}=r;i[e]&&(s[e]=i[e],r.setStaticValue(e,0),n&&(n[e]=0))}function B2({attachResizeListener:e,defaultParent:r,measureScroll:s,checkIsScrollRoot:n,resetTransform:i}){return class{constructor(e={},s=r?.()){this.id=B0++,this.animationId=0,this.animationCommitId=0,this.children=new Set,this.options={},this.isTreeAnimating=!1,this.isAnimationBlocked=!1,this.isLayoutDirty=!1,this.isProjectionDirty=!1,this.isSharedProjectionDirty=!1,this.isTransformDirty=!1,this.updateManuallyBlocked=!1,this.updateBlockedByResize=!1,this.isUpdating=!1,this.isSVG=!1,this.needsReset=!1,this.shouldResetTransform=!1,this.hasCheckedOptimisedAppear=!1,this.treeScale={x:1,y:1},this.eventHandlers=new Map,this.hasTreeAnimated=!1,this.layoutVersion=0,this.updateScheduled=!1,this.scheduleUpdate=()=>this.update(),this.projectionUpdateScheduled=!1,this.checkUpdateFailed=()=>{this.isUpdating&&(this.isUpdating=!1,this.clearAllSnapshots())},this.updateProjection=()=>{this.projectionUpdateScheduled=!1,this.nodes.forEach(B4),this.nodes.forEach(zr),this.nodes.forEach(zs),this.nodes.forEach(B6)},this.resolvedRelativeTargetAt=0,this.linkedParentVersion=0,this.hasProjected=!1,this.isVisible=!0,this.animationProgress=0,this.sharedNodes=new Map,this.latestValues=e,this.root=s?s.root||s:this,this.path=s?[...s.path,s]:[],this.parent=s,this.depth=s?s.depth+1:0;for(let e=0;e<this.path.length;e++)this.path[e].shouldResetTransform=!0;this.root===this&&(this.nodes=new BZ)}addEventListener(e,r){return this.eventHandlers.has(e)||this.eventHandlers.set(e,new Fa),this.eventHandlers.get(e).add(r)}notifyListeners(e,...r){let s=this.eventHandlers.get(e);s&&s.notify(...r)}hasListeners(e){return this.eventHandlers.has(e)}mount(r){if(this.instance)return;this.isSVG=BC(r)&&!(BC(r)&&"svg"===r.tagName),this.instance=r;let{layoutId:s,layout:n,visualElement:i}=this.options;if(i&&!i.current&&i.mount(r),this.root.nodes.add(this),this.parent&&this.parent.children.add(this),this.root.hasTreeAnimated&&(n||s)&&(this.isLayoutDirty=!0),e){let s,n=0,i=()=>this.root.updateBlockedByResize=!1;P0.read(()=>{n=window.innerWidth}),e(r,()=>{let e=window.innerWidth;if(e!==n){let r,a;n=e,this.root.updateBlockedByResize=!0,s&&s(),r=Fc.now(),a=({timestamp:e})=>{let s=e-r;s>=250&&(P1(a),i(s-250))},P0.setup(a,!0),s=()=>P1(a),Bb.hasAnimatedSinceResize&&(Bb.hasAnimatedSinceResize=!1,this.nodes.forEach(zt))}})}s&&this.root.registerSharedNode(s,this),!1!==this.options.animate&&i&&(s||n)&&this.addEventListener("didUpdate",({delta:e,hasLayoutChanged:r,hasRelativeLayoutChanged:s,layout:n})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}let a=this.options.transition||i.getDefaultTransition()||zc,{onLayoutAnimationStart:o,onLayoutAnimationComplete:l}=i.getProps(),c=!this.targetLayout||!BK(this.targetLayout,n),d=!r&&s;if(this.options.layoutRoot||this.resumeFrom||d||r&&(c||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0);let r={...LE(a,"layout"),onPlay:o,onComplete:l};(i.shouldReduceMotion||this.options.layoutRoot)&&(r.delay=0,r.type=!1),this.startAnimation(r),this.setAnimationOrigin(e,d)}else r||zt(this),this.isLead()&&this.options.onExitComplete&&this.options.onExitComplete();this.targetLayout=n})}unmount(){this.options.layoutId&&this.willUpdate(),this.root.nodes.remove(this);let e=this.getStack();e&&e.remove(this),this.parent&&this.parent.children.delete(this),this.instance=void 0,this.eventHandlers.clear(),P1(this.updateProjection)}blockUpdate(){this.updateManuallyBlocked=!0}unblockUpdate(){this.updateManuallyBlocked=!1}isUpdateBlocked(){return this.updateManuallyBlocked||this.updateBlockedByResize}isTreeAnimationBlocked(){return this.isAnimationBlocked||this.parent&&this.parent.isTreeAnimationBlocked()||!1}startUpdate(){!this.isUpdateBlocked()&&(this.isUpdating=!0,this.nodes&&this.nodes.forEach(zn),this.animationId++)}getTransformTemplate(){let{visualElement:e}=this.options;return e&&e.getProps().transformTemplate}willUpdate(e=!0){if(this.root.hasTreeAnimated=!0,this.root.isUpdateBlocked()){this.options.onExitComplete&&this.options.onExitComplete();return}if(window.MotionCancelOptimisedAnimation&&!this.hasCheckedOptimisedAppear&&function e(r){if(r.hasCheckedOptimisedAppear=!0,r.root===r)return;let{visualElement:s}=r.options;if(!s)return;let n=s.props[Lw];if(window.MotionHasOptimisedAnimation(n,"transform")){let{layout:e,layoutId:s}=r.options;window.MotionCancelOptimisedAnimation(n,"transform",P0,!(e||s))}let{parent:i}=r;i&&!i.hasCheckedOptimisedAppear&&e(i)}(this),this.root.isUpdating||this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let e=0;e<this.path.length;e++){let r=this.path[e];r.shouldResetTransform=!0,r.updateScroll("snapshot"),r.options.layoutRoot&&r.willUpdate(!1)}let{layoutId:r,layout:s}=this.options;if(void 0===r&&!s)return;let n=this.getTransformTemplate();this.prevTransformTemplateValue=n?n(this.latestValues,""):void 0,this.updateSnapshot(),e&&this.notifyListeners("willUpdate")}update(){if(this.updateScheduled=!1,this.isUpdateBlocked()){this.unblockUpdate(),this.clearAllSnapshots(),this.nodes.forEach(B8);return}if(this.animationId<=this.animationCommitId)return void this.nodes.forEach(B9);this.animationCommitId=this.animationId,this.isUpdating?(this.isUpdating=!1,this.nodes.forEach(ze),this.nodes.forEach(B5),this.nodes.forEach(B3)):this.nodes.forEach(B9),this.clearAllSnapshots();let e=Fc.now();P2.delta=IU(0,1e3/60,e-P2.timestamp),P2.timestamp=e,P2.isProcessing=!0,P5.update.process(P2),P5.preRender.process(P2),P5.render.process(P2),P2.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,Fo.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach(B7),this.sharedNodes.forEach(zi)}scheduleUpdateProjection(){this.projectionUpdateScheduled||(this.projectionUpdateScheduled=!0,P0.preRender(this.updateProjection,!1,!0))}scheduleCheckAfterUnmount(){P0.postRender(()=>{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){!this.snapshot&&this.instance&&(this.snapshot=this.measure(),!this.snapshot||O4(this.snapshot.measuredBox.x)||O4(this.snapshot.measuredBox.y)||(this.snapshot=void 0))}updateLayout(){if(!this.instance||(this.updateScroll(),!(this.options.alwaysMeasureLayout&&this.isLead())&&!this.isLayoutDirty))return;if(this.resumeFrom&&!this.resumeFrom.instance)for(let e=0;e<this.path.length;e++)this.path[e].updateScroll();let e=this.layout;this.layout=this.measure(!1),this.layoutVersion++,this.layoutCorrected=Pw(),this.isLayoutDirty=!1,this.projectionDelta=void 0,this.notifyListeners("measure",this.layout.layoutBox);let{visualElement:r}=this.options;r&&r.notify("LayoutMeasure",this.layout.layoutBox,e?e.layoutBox:void 0)}updateScroll(e="measure"){let r=!!(this.options.layoutScroll&&this.instance);if(this.scroll&&this.scroll.animationId===this.root.animationId&&this.scroll.phase===e&&(r=!1),r&&this.instance){let r=n(this.instance);this.scroll={animationId:this.root.animationId,phase:e,isRoot:r,offset:s(this.instance),wasRoot:this.scroll?this.scroll.isRoot:r}}}resetTransform(){if(!i)return;let e=this.isLayoutDirty||this.shouldResetTransform||this.options.alwaysMeasureLayout,r=this.projectionDelta&&!BU(this.projectionDelta),s=this.getTransformTemplate(),n=s?s(this.latestValues,""):void 0,a=n!==this.prevTransformTemplateValue;e&&this.instance&&(r||FZ(this.latestValues)||a)&&(i(this.instance,n),this.shouldResetTransform=!1,this.scheduleRender())}measure(e=!0){var r;let s=this.measurePageBox(),n=this.removeElementScroll(s);return e&&(n=this.removeTransform(n)),zh((r=n).x),zh(r.y),{animationId:this.root.animationId,measuredBox:s,layoutBox:n,latestValues:{},source:this.id}}measurePageBox(){let{visualElement:e}=this.options;if(!e)return Pw();let r=e.measureViewportBox();if(!(this.scroll?.wasRoot||this.path.some(zp))){let{scroll:e}=this.root;e&&(F5(r.x,e.offset.x),F5(r.y,e.offset.y))}return r}removeElementScroll(e){let r=Pw();if(BF(r,e),this.scroll?.wasRoot)return r;for(let s=0;s<this.path.length;s++){let n=this.path[s],{scroll:i,options:a}=n;n!==this.root&&i&&a.layoutScroll&&(i.wasRoot&&BF(r,e),F5(r.x,i.offset.x),F5(r.y,i.offset.y))}return r}applyTransform(e,r=!1){let s=Pw();BF(s,e);for(let e=0;e<this.path.length;e++){let n=this.path[e];!r&&n.options.layoutScroll&&n.scroll&&n!==n.root&&F4(s,{x:-n.scroll.offset.x,y:-n.scroll.offset.y}),FZ(n.latestValues)&&F4(s,n.latestValues)}return FZ(this.latestValues)&&F4(s,this.latestValues),s}removeTransform(e){let r=Pw();BF(r,e);for(let e=0;e<this.path.length;e++){let s=this.path[e];if(!s.instance||!FZ(s.latestValues))continue;FJ(s.latestValues)&&s.updateSnapshot();let n=Pw();BF(n,s.measurePageBox()),BW(r,s.latestValues,s.snapshot?s.snapshot.layoutBox:void 0,n)}return FZ(this.latestValues)&&BW(r,this.latestValues),r}setTargetDelta(e){this.targetDelta=e,this.root.scheduleUpdateProjection(),this.isProjectionDirty=!0}setOptions(e){this.options={...this.options,...e,crossfade:void 0===e.crossfade||e.crossfade}}clearMeasurements(){this.scroll=void 0,this.layout=void 0,this.snapshot=void 0,this.prevTransformTemplateValue=void 0,this.targetDelta=void 0,this.target=void 0,this.isLayoutDirty=!1}forceRelativeParentToResolveTarget(){this.relativeParent&&this.relativeParent.resolvedRelativeTargetAt!==P2.timestamp&&this.relativeParent.resolveTargetDelta(!0)}resolveTargetDelta(e=!1){let r=this.getLead();this.isProjectionDirty||(this.isProjectionDirty=r.isProjectionDirty),this.isTransformDirty||(this.isTransformDirty=r.isTransformDirty),this.isSharedProjectionDirty||(this.isSharedProjectionDirty=r.isSharedProjectionDirty);let s=!!this.resumingFrom||this!==r;if(!(e||s&&this.isSharedProjectionDirty||this.isProjectionDirty||this.parent?.isProjectionDirty||this.attemptToResolveRelativeTarget||this.root.updateBlockedByResize))return;let{layout:n,layoutId:i}=this.options;if(!this.layout||!(n||i))return;this.resolvedRelativeTargetAt=P2.timestamp;let a=this.getClosestProjectingParent();if(a&&this.linkedParentVersion!==a.layoutVersion&&!a.options.layoutRoot&&this.removeRelativeTarget(),this.targetDelta||this.relativeTarget||(a&&a.layout?this.createRelativeTarget(a,this.layout.layoutBox,a.layout.layoutBox):this.removeRelativeTarget()),this.relativeTarget||this.targetDelta){if(this.target||(this.target=Pw(),this.targetWithTransforms=Pw()),this.relativeTarget&&this.relativeTargetOrigin&&this.relativeParent&&this.relativeParent.target){var o,l,c;this.forceRelativeParentToResolveTarget(),o=this.target,l=this.relativeTarget,c=this.relativeParent.target,O8(o.x,l.x,c.x),O8(o.y,l.y,c.y)}else this.targetDelta?(this.resumingFrom?this.target=this.applyTransform(this.layout.layoutBox):BF(this.target,this.layout.layoutBox),F2(this.target,this.targetDelta)):BF(this.target,this.layout.layoutBox);this.attemptToResolveRelativeTarget&&(this.attemptToResolveRelativeTarget=!1,a&&!!a.resumingFrom==!!this.resumingFrom&&!a.options.layoutScroll&&a.target&&1!==this.animationProgress?this.createRelativeTarget(a,this.target,a.target):this.relativeParent=this.relativeTarget=void 0)}}getClosestProjectingParent(){if(!(!this.parent||FJ(this.parent.latestValues)||FQ(this.parent.latestValues)))if(this.parent.isProjecting())return this.parent;else return this.parent.getClosestProjectingParent()}isProjecting(){return!!((this.relativeTarget||this.targetDelta||this.options.layoutRoot)&&this.layout)}createRelativeTarget(e,r,s){this.relativeParent=e,this.linkedParentVersion=e.layoutVersion,this.forceRelativeParentToResolveTarget(),this.relativeTarget=Pw(),this.relativeTargetOrigin=Pw(),Be(this.relativeTargetOrigin,r,s),BF(this.relativeTarget,this.relativeTargetOrigin)}removeRelativeTarget(){this.relativeParent=this.relativeTarget=void 0}calcProjection(){let e=this.getLead(),r=!!this.resumingFrom||this!==e,s=!0;if((this.isProjectionDirty||this.parent?.isProjectionDirty)&&(s=!1),r&&(this.isSharedProjectionDirty||this.isTransformDirty)&&(s=!1),this.resolvedRelativeTargetAt===P2.timestamp&&(s=!1),s)return;let{layout:n,layoutId:i}=this.options;if(this.isTreeAnimating=!!(this.parent&&this.parent.isTreeAnimating||this.currentAnimation||this.pendingAnimation),this.isTreeAnimating||(this.targetDelta=this.relativeTarget=void 0),!this.layout||!(n||i))return;BF(this.layoutCorrected,this.layout.layoutBox);let a=this.treeScale.x,o=this.treeScale.y;!function(e,r,s,n=!1){let i,a,o=s.length;if(o){r.x=r.y=1;for(let l=0;l<o;l++){a=(i=s[l]).projectionDelta;let{visualElement:o}=i.options;(!o||!o.props.style||"contents"!==o.props.style.display)&&(n&&i.options.layoutScroll&&i.scroll&&i!==i.root&&F4(e,{x:-i.scroll.offset.x,y:-i.scroll.offset.y}),a&&(r.x*=a.x.scale,r.y*=a.y.scale,F2(e,a)),n&&FZ(i.latestValues)&&F4(e,i.latestValues))}r.x<1.0000000000001&&r.x>.999999999999&&(r.x=1),r.y<1.0000000000001&&r.y>.999999999999&&(r.y=1)}}(this.layoutCorrected,this.treeScale,this.path,r),e.layout&&!e.target&&(1!==this.treeScale.x||1!==this.treeScale.y)&&(e.target=e.layout.layoutBox,e.targetWithTransforms=Pw());let{target:l}=e;if(!l){this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender());return}this.projectionDelta&&this.prevProjectionDelta?(BL(this.prevProjectionDelta.x,this.projectionDelta.x),BL(this.prevProjectionDelta.y,this.projectionDelta.y)):this.createProjectionDeltas(),O7(this.projectionDelta,this.layoutCorrected,l,this.latestValues),this.treeScale.x===a&&this.treeScale.y===o&&BY(this.projectionDelta.x,this.prevProjectionDelta.x)&&BY(this.projectionDelta.y,this.prevProjectionDelta.y)||(this.hasProjected=!0,this.scheduleRender(),this.notifyListeners("projectionUpdate",l))}hide(){this.isVisible=!1}show(){this.isVisible=!0}scheduleRender(e=!0){if(this.options.visualElement?.scheduleRender(),e){let e=this.getStack();e&&e.scheduleRender()}this.resumingFrom&&!this.resumingFrom.instance&&(this.resumingFrom=void 0)}createProjectionDeltas(){this.prevProjectionDelta=Py(),this.projectionDelta=Py(),this.projectionDeltaWithTransform=Py()}setAnimationOrigin(e,r=!1){let s,n=this.snapshot,i=n?n.latestValues:{},a={...this.latestValues},o=Py();this.relativeParent&&this.relativeParent.options.layoutRoot||(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!r;let l=Pw(),c=(n?n.source:void 0)!==(this.layout?this.layout.source:void 0),d=this.getStack(),u=!d||d.members.length<=1,h=!!(c&&!u&&!0===this.options.crossfade&&!this.path.some(zl));this.animationProgress=0,this.mixTargetDelta=r=>{let n=r/1e3;if(za(o.x,e.x,n),za(o.y,e.y,n),this.setTargetDelta(o),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout){var d,f,p,m,g,x;Be(l,this.layout.layoutBox,this.relativeParent.layout.layoutBox),p=this.relativeTarget,m=this.relativeTargetOrigin,g=l,x=n,zo(p.x,m.x,g.x,x),zo(p.y,m.y,g.y,x),s&&(d=this.relativeTarget,f=s,BV(d.x,f.x)&&BV(d.y,f.y))&&(this.isProjectionDirty=!1),s||(s=Pw()),BF(s,this.relativeTarget)}c&&(this.animationValues=a,function(e,r,s,n,i,a){i?(e.opacity=FH(0,s.opacity??1,BA(n)),e.opacityExit=FH(r.opacity??1,0,BM(n))):a&&(e.opacity=FH(r.opacity??1,s.opacity??1,n));for(let i=0;i<BE;i++){let a=`border${BN[i]}Radius`,o=BR(r,a),l=BR(s,a);(void 0!==o||void 0!==l)&&(o||(o=0),l||(l=0),0===o||0===l||BT(o)===BT(l)?(e[a]=Math.max(FH(BD(o),BD(l),n),0),(I3.test(l)||I3.test(o))&&(e[a]+="%")):e[a]=l)}(r.rotate||s.rotate)&&(e.rotate=FH(r.rotate||0,s.rotate||0,n))}(a,i,this.latestValues,n,h,u)),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=n},this.mixTargetDelta(1e3*!!this.options.layoutRoot)}startAnimation(e){this.notifyListeners("animationStart"),this.currentAnimation?.stop(),this.resumingFrom?.currentAnimation?.stop(),this.pendingAnimation&&(P1(this.pendingAnimation),this.pendingAnimation=void 0),this.pendingAnimation=P0.update(()=>{var r,s,n;let i;Bb.hasAnimatedSinceResize=!0,LI.layout++,this.motionValue||(this.motionValue=Fu(0)),this.currentAnimation=(r=this.motionValue,s=[0,1e3],n={...e,velocity:0,isSync:!0,onUpdate:r=>{this.mixTargetDelta(r),e.onUpdate&&e.onUpdate(r)},onStop:()=>{LI.layout--},onComplete:()=>{LI.layout--,e.onComplete&&e.onComplete(),this.completeAnimation()}},(i=P_(r)?r:Fu(r)).start(OH("",i,s,n)),i.animation),this.resumingFrom&&(this.resumingFrom.currentAnimation=this.currentAnimation),this.pendingAnimation=void 0})}completeAnimation(){this.resumingFrom&&(this.resumingFrom.currentAnimation=void 0,this.resumingFrom.preserveOpacity=void 0);let e=this.getStack();e&&e.exitAnimationComplete(),this.resumingFrom=this.currentAnimation=this.animationValues=void 0,this.notifyListeners("animationComplete")}finishAnimation(){this.currentAnimation&&(this.mixTargetDelta&&this.mixTargetDelta(1e3),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){let e=this.getLead(),{targetWithTransforms:r,target:s,layout:n,latestValues:i}=e;if(r&&s&&n){if(this!==e&&this.layout&&n&&zf(this.options.animationType,this.layout.layoutBox,n.layoutBox)){s=this.target||Pw();let r=O4(this.layout.layoutBox.x);s.x.min=e.target.x.min,s.x.max=s.x.min+r;let n=O4(this.layout.layoutBox.y);s.y.min=e.target.y.min,s.y.max=s.y.min+n}BF(r,s),F4(r,i),O7(this.projectionDeltaWithTransform,this.layoutCorrected,r,i)}}registerSharedNode(e,r){this.sharedNodes.has(e)||this.sharedNodes.set(e,new BG),this.sharedNodes.get(e).add(r);let s=r.options.initialPromotionConfig;r.promote({transition:s?s.transition:void 0,preserveFollowOpacity:s&&s.shouldPreserveFollowOpacity?s.shouldPreserveFollowOpacity(r):void 0})}isLead(){let e=this.getStack();return!e||e.lead===this}getLead(){let{layoutId:e}=this.options;return e&&this.getStack()?.lead||this}getPrevLead(){let{layoutId:e}=this.options;return e?this.getStack()?.prevLead:void 0}getStack(){let{layoutId:e}=this.options;if(e)return this.root.sharedNodes.get(e)}promote({needsReset:e,transition:r,preserveFollowOpacity:s}={}){let n=this.getStack();n&&n.promote(this,s),e&&(this.projectionDelta=void 0,this.needsReset=!0),r&&this.setOptions({transition:r})}relegate(){let e=this.getStack();return!!e&&e.relegate(this)}resetSkewAndRotation(){let{visualElement:e}=this.options;if(!e)return;let r=!1,{latestValues:s}=e;if((s.z||s.rotate||s.rotateX||s.rotateY||s.rotateZ||s.skewX||s.skewY)&&(r=!0),!r)return;let n={};s.z&&B1("z",e,n,this.animationValues);for(let r=0;r<BQ.length;r++)B1(`rotate${BQ[r]}`,e,n,this.animationValues),B1(`skew${BQ[r]}`,e,n,this.animationValues);for(let r in e.render(),n)e.setStaticValue(r,n[r]),this.animationValues&&(this.animationValues[r]=n[r]);e.scheduleRender()}applyProjectionStyles(e,r){if(!this.instance||this.isSVG)return;if(!this.isVisible){e.visibility="hidden";return}let s=this.getTransformTemplate();if(this.needsReset){this.needsReset=!1,e.visibility="",e.opacity="",e.pointerEvents=Lu(r?.pointerEvents)||"",e.transform=s?s(this.latestValues,""):"none";return}let n=this.getLead();if(!this.projectionDelta||!this.layout||!n.target){this.options.layoutId&&(e.opacity=void 0!==this.latestValues.opacity?this.latestValues.opacity:1,e.pointerEvents=Lu(r?.pointerEvents)||""),this.hasProjected&&!FZ(this.latestValues)&&(e.transform=s?s({},""):"none",this.hasProjected=!1);return}e.visibility="";let i=n.animationValues||n.latestValues;this.applyTransformsToTarget();let a=function(e,r,s){let n="",i=e.x.translate/r.x,a=e.y.translate/r.y,o=s?.z||0;if((i||a||o)&&(n=`translate3d(${i}px, ${a}px, ${o}px) `),(1!==r.x||1!==r.y)&&(n+=`scale(${1/r.x}, ${1/r.y}) `),s){let{transformPerspective:e,rotate:r,rotateX:i,rotateY:a,skewX:o,skewY:l}=s;e&&(n=`perspective(${e}px) ${n}`),r&&(n+=`rotate(${r}deg) `),i&&(n+=`rotateX(${i}deg) `),a&&(n+=`rotateY(${a}deg) `),o&&(n+=`skewX(${o}deg) `),l&&(n+=`skewY(${l}deg) `)}let l=e.x.scale*r.x,c=e.y.scale*r.y;return(1!==l||1!==c)&&(n+=`scale(${l}, ${c})`),n||"none"}(this.projectionDeltaWithTransform,this.treeScale,i);s&&(a=s(i,a)),e.transform=a;let{x:o,y:l}=this.projectionDelta;for(let r in e.transformOrigin=`${100*o.origin}% ${100*l.origin}% 0`,n.animationValues?e.opacity=n===this?i.opacity??this.latestValues.opacity??1:this.preserveOpacity?this.latestValues.opacity:i.opacityExit:e.opacity=n===this?void 0!==i.opacity?i.opacity:"":void 0!==i.opacityExit?i.opacityExit:0,FU){if(void 0===i[r])continue;let{correct:s,applyTo:o,isCSSVariable:l}=FU[r],c="none"===a?i[r]:s(i[r],n);if(o){let r=o.length;for(let s=0;s<r;s++)e[o[s]]=c}else l?this.options.visualElement.renderState.vars[r]=c:e[r]=c}this.options.layoutId&&(e.pointerEvents=n===this?Lu(r?.pointerEvents)||"":"none")}clearSnapshot(){this.resumeFrom=this.snapshot=void 0}resetTree(){this.root.nodes.forEach(e=>e.currentAnimation?.stop()),this.root.nodes.forEach(B8),this.root.sharedNodes.clear()}}}function B5(e){e.updateLayout()}function B3(e){let r=e.resumeFrom?.snapshot||e.snapshot;if(e.isLead()&&e.layout&&r&&e.hasListeners("didUpdate")){let{layoutBox:s,measuredBox:n}=e.layout,{animationType:i}=e.options,a=r.source!==e.layout.source;"size"===i?O0(e=>{let n=a?r.measuredBox[e]:r.layoutBox[e],i=O4(n);n.min=s[e].min,n.max=n.min+i}):zf(i,r.layoutBox,s)&&O0(n=>{let i=a?r.measuredBox[n]:r.layoutBox[n],o=O4(s[n]);i.max=i.min+o,e.relativeTarget&&!e.currentAnimation&&(e.isProjectionDirty=!0,e.relativeTarget[n].max=e.relativeTarget[n].min+o)});let o=Py();O7(o,s,r.layoutBox);let l=Py();a?O7(l,e.applyTransform(n,!0),r.measuredBox):O7(l,s,r.layoutBox);let c=!BU(o),d=!1;if(!e.resumeFrom){let n=e.getClosestProjectingParent();if(n&&!n.resumeFrom){let{snapshot:i,layout:a}=n;if(i&&a){let o=Pw();Be(o,r.layoutBox,i.layoutBox);let l=Pw();Be(l,s,a.layoutBox),BK(o,l)||(d=!0),n.options.layoutRoot&&(e.relativeTarget=l,e.relativeTargetOrigin=o,e.relativeParent=n)}}}e.notifyListeners("didUpdate",{layout:s,snapshot:r,delta:l,layoutDelta:o,hasLayoutChanged:c,hasRelativeLayoutChanged:d})}else if(e.isLead()){let{onExitComplete:r}=e.options;r&&r()}e.options.transition=void 0}function B4(e){e.parent&&(e.isProjecting()||(e.isProjectionDirty=e.parent.isProjectionDirty),e.isSharedProjectionDirty||(e.isSharedProjectionDirty=!!(e.isProjectionDirty||e.parent.isProjectionDirty||e.parent.isSharedProjectionDirty)),e.isTransformDirty||(e.isTransformDirty=e.parent.isTransformDirty))}function B6(e){e.isProjectionDirty=e.isSharedProjectionDirty=e.isTransformDirty=!1}function B7(e){e.clearSnapshot()}function B8(e){e.clearMeasurements()}function B9(e){e.isLayoutDirty=!1}function ze(e){let{visualElement:r}=e.options;r&&r.getProps().onBeforeLayoutMeasure&&r.notify("BeforeLayoutMeasure"),e.resetTransform()}function zt(e){e.finishAnimation(),e.targetDelta=e.relativeTarget=e.target=void 0,e.isProjectionDirty=!0}function zr(e){e.resolveTargetDelta()}function zs(e){e.calcProjection()}function zn(e){e.resetSkewAndRotation()}function zi(e){e.removeLeadSnapshot()}function za(e,r,s){e.translate=FH(r.translate,0,s),e.scale=FH(r.scale,1,s),e.origin=r.origin,e.originPoint=r.originPoint}function zo(e,r,s,n){e.min=FH(r.min,s.min,n),e.max=FH(r.max,s.max,n)}function zl(e){return e.animationValues&&void 0!==e.animationValues.opacityExit}let zc={duration:.45,ease:[.4,0,.1,1]},zd=e=>"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(e),zu=zd("applewebkit/")&&!zd("chrome/")?Math.round:PG;function zh(e){e.min=zu(e.min),e.max=zu(e.max)}function zf(e,r,s){return"position"===e||"preserve-aspect"===e&&!(.2>=Math.abs(BX(r)-BX(s)))}function zp(e){return e!==e.root&&e.scroll?.wasRoot}let zm=B2({attachResizeListener:(e,r)=>O5(e,"resize",r),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body?.scrollLeft||0,y:document.documentElement.scrollTop||document.body?.scrollTop||0}),checkIsScrollRoot:()=>!0}),zg={current:void 0},zx=B2({measureScroll:e=>({x:e.scrollLeft,y:e.scrollTop}),defaultParent:()=>{if(!zg.current){let e=new zm({});e.mount(window),e.setOptions({layoutScroll:!0}),zg.current=e}return zg.current},resetTransform:(e,r)=>{e.style.transform=void 0!==r?r:"none"},checkIsScrollRoot:e=>"fixed"===window.getComputedStyle(e).position});function zv(e,r){let s=function(e,r,s){if(null==e)return[];if(e instanceof EventTarget)return[e];if("string"==typeof e){let r=document,s=(void 0)??r.querySelectorAll(e);return s?Array.from(s):[]}return Array.from(e).filter(e=>null!=e)}(e),n=new AbortController;return[s,{passive:!0,...r,signal:n.signal},()=>n.abort()]}function zy(e){return!("touch"===e.pointerType||O3.x||O3.y)}function zb(e,r,s){let{props:n}=e;e.animationState&&n.whileHover&&e.animationState.setActive("whileHover","Start"===s);let i=n["onHover"+s];i&&P0.postRender(()=>i(r,Br(r)))}let zw=(e,r)=>!!r&&(e===r||zw(e,r.parentElement)),z_=new WeakSet;function zS(e){return r=>{"Enter"===r.key&&e(r)}}function zk(e,r){e.dispatchEvent(new PointerEvent("pointer"+r,{isPrimary:!0,bubbles:!0}))}function zj(e){return Bt(e)&&!(O3.x||O3.y)}function zC(e,r,s){let{props:n}=e;if(e.current instanceof HTMLButtonElement&&e.current.disabled)return;e.animationState&&n.whileTap&&e.animationState.setActive("whileTap","Start"===s);let i=n["onTap"+("End"===s?"":s)];i&&P0.postRender(()=>i(r,Br(r)))}let zN=new WeakMap,zE=new WeakMap,zD=e=>{let r=zN.get(e.target);r&&r(e)},zT=e=>{e.forEach(zD)},zR={some:0,all:1},zA=function(e,r){if("undefined"==typeof Proxy)return Lj;let s=new Map,n=(s,n)=>Lj(s,n,e,r);return new Proxy((e,r)=>n(e,r),{get:(i,a)=>"create"===a?n:(s.has(a)||s.set(a,Lj(a,void 0,e,r)),s.get(a))})}({animation:{Feature:class extends LC{constructor(e){super(e),e.animationState||(e.animationState=function(e){let r=r=>Promise.all(r.map(({animation:r,options:s})=>(function(e,r,s={}){let n;if(e.notify("AnimationStart",r),Array.isArray(r))n=Promise.all(r.map(r=>Oq(e,r,s)));else if("string"==typeof r)n=Oq(e,r,s);else{let i="function"==typeof r?LN(e,r,s.custom):r;n=Promise.all(OU(e,i,s))}return n.then(()=>{e.notify("AnimationComplete",r)})})(e,r,s))),s=OZ(),n=!0,i=r=>(s,n)=>{let i=LN(e,n,"exit"===r?e.presenceContext?.custom:void 0);if(i){let{transition:e,transitionEnd:r,...n}=i;s={...s,...n,...r}}return s};function a(a){let{props:o}=e,l=function e(r){if(!r)return;if(!r.isControllingVariants){let s=r.parent&&e(r.parent)||{};return void 0!==r.props.initial&&(s.initial=r.props.initial),s}let s={};for(let e=0;e<OK;e++){let n=Fb[e],i=r.props[n];(Fv(i)||!1===i)&&(s[n]=i)}return s}(e.parent)||{},c=[],d=new Set,u={},h=1/0;for(let r=0;r<OG;r++){var f,p;let m=OY[r],g=s[m],x=void 0!==o[m]?o[m]:l[m],v=Fv(x),y=m===a?g.isActive:null;!1===y&&(h=r);let b=x===l[m]&&x!==o[m]&&v;if(b&&n&&e.manuallyAnimateOnMount&&(b=!1),g.protectedKeys={...u},!g.isActive&&null===y||!x&&!g.prevProp||Fx(x)||"boolean"==typeof x)continue;let w=(f=g.prevProp,"string"==typeof(p=x)?p!==f:!!Array.isArray(p)&&!OX(p,f)),_=w||m===a&&g.isActive&&!b&&v||r>h&&v,S=!1,k=Array.isArray(x)?x:[x],j=k.reduce(i(m),{});!1===y&&(j={});let{prevResolvedValues:C={}}=g,N={...C,...j},E=r=>{_=!0,d.has(r)&&(S=!0,d.delete(r)),g.needsAnimating[r]=!0;let s=e.getValue(r);s&&(s.liveStyle=!1)};for(let e in N){let r=j[e],s=C[e];if(!u.hasOwnProperty(e))(LD(r)&&LD(s)?OX(r,s):r===s)?void 0!==r&&d.has(e)?E(e):g.protectedKeys[e]=!0:null!=r?E(e):d.add(e)}g.prevProp=x,g.prevResolvedValues=j,g.isActive&&(u={...u,...j}),n&&e.blockInitialAnimation&&(_=!1);let D=b&&w,T=!D||S;_&&T&&c.push(...k.map(r=>{let s={type:m};if("string"==typeof r&&n&&!D&&e.manuallyAnimateOnMount&&e.parent){let{parent:n}=e,i=LN(n,r);if(n.enteringChildren&&i){let{delayChildren:r}=i.transition||{};s.delay=OV(n.enteringChildren,e,r)}}return{animation:r,options:s}}))}if(d.size){let r={};if("boolean"!=typeof o.initial){let s=LN(e,Array.isArray(o.initial)?o.initial[0]:o.initial);s&&s.transition&&(r.transition=s.transition)}d.forEach(s=>{let n=e.getBaseTarget(s),i=e.getValue(s);i&&(i.liveStyle=!0),r[s]=n??null}),c.push({animation:r})}let m=!!c.length;return n&&(!1===o.initial||o.initial===o.animate)&&!e.manuallyAnimateOnMount&&(m=!1),n=!1,m?r(c):Promise.resolve()}return{animateChanges:a,setActive:function(r,n){if(s[r].isActive===n)return Promise.resolve();e.variantChildren?.forEach(e=>e.animationState?.setActive(r,n)),s[r].isActive=n;let i=a(r);for(let e in s)s[e].protectedKeys={};return i},setAnimateFunction:function(s){r=s(e)},getState:()=>s,reset:()=>{s=OZ()}}}(e))}updateAnimationControlsSubscription(){let{animate:e}=this.node.getProps();Fx(e)&&(this.unmountControls=e.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){let{animate:e}=this.node.getProps(),{animate:r}=this.node.prevProps||{};e!==r&&this.updateAnimationControlsSubscription()}unmount(){this.node.animationState.reset(),this.unmountControls?.()}}},exit:{Feature:class extends LC{constructor(){super(...arguments),this.id=OQ++}update(){if(!this.node.presenceContext)return;let{isPresent:e,onExitComplete:r}=this.node.presenceContext,{isPresent:s}=this.node.prevPresenceContext||{};if(!this.node.animationState||e===s)return;let n=this.node.animationState.setActive("exit",!e);r&&!e&&n.then(()=>{r(this.id)})}mount(){let{register:e,onExitComplete:r}=this.node.presenceContext||{};r&&r(this.id),e&&(this.unmount=e(this.id))}unmount(){}}},inView:{Feature:class extends LC{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){var e;let r;this.unmount();let{viewport:s={}}=this.node.getProps(),{root:n,margin:i,amount:a="some",once:o}=s,l={root:n?n.current:void 0,rootMargin:i,threshold:"number"==typeof a?a:zR[a]},c=e=>{let{isIntersecting:r}=e;if(this.isInView===r||(this.isInView=r,o&&!r&&this.hasEnteredView))return;r&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive("whileInView",r);let{onViewportEnter:s,onViewportLeave:n}=this.node.getProps(),i=r?s:n;i&&i(e)};return e=this.node.current,r=function({root:e,...r}){let s=e||document;zE.has(s)||zE.set(s,{});let n=zE.get(s),i=JSON.stringify(r);return n[i]||(n[i]=new IntersectionObserver(zT,{root:e,...r})),n[i]}(l),zN.set(e,c),r.observe(e),()=>{zN.delete(e),r.unobserve(e)}}mount(){this.startObserver()}update(){if("undefined"==typeof IntersectionObserver)return;let{props:e,prevProps:r}=this.node;["amount","margin","root"].some(function({viewport:e={}},{viewport:r={}}={}){return s=>e[s]!==r[s]}(e,r))&&this.startObserver()}unmount(){}}},tap:{Feature:class extends LC{mount(){let{current:e}=this.node;e&&(this.unmount=function(e,r,s={}){let[n,i,a]=zv(e,s),o=e=>{let n=e.currentTarget;if(!zj(e))return;z_.add(n);let a=r(n,e),o=(e,r)=>{window.removeEventListener("pointerup",l),window.removeEventListener("pointercancel",c),z_.has(n)&&z_.delete(n),zj(e)&&"function"==typeof a&&a(e,{success:r})},l=e=>{o(e,n===window||n===document||s.useGlobalTarget||zw(n,e.target))},c=e=>{o(e,!1)};window.addEventListener("pointerup",l,i),window.addEventListener("pointercancel",c,i)};return n.forEach(e=>{(s.useGlobalTarget?window:e).addEventListener("pointerdown",o,i),Bj(e)&&"offsetHeight"in e&&(e.addEventListener("focus",e=>((e,r)=>{let s=e.currentTarget;if(!s)return;let n=zS(()=>{if(z_.has(s))return;zk(s,"down");let e=zS(()=>{zk(s,"up")});s.addEventListener("keyup",e,r),s.addEventListener("blur",()=>zk(s,"cancel"),r)});s.addEventListener("keydown",n,r),s.addEventListener("blur",()=>s.removeEventListener("keydown",n),r)})(e,i)),O2(e)||e.hasAttribute("tabindex")||(e.tabIndex=0))}),a}(e,(e,r)=>(zC(this.node,r,"Start"),(e,{success:r})=>zC(this.node,e,r?"End":"Cancel")),{useGlobalTarget:this.node.props.globalTapTarget}))}unmount(){}}},focus:{Feature:class extends LC{constructor(){super(...arguments),this.isActive=!1}onFocus(){let e=!1;try{e=this.node.current.matches(":focus-visible")}catch(r){e=!0}e&&this.node.animationState&&(this.node.animationState.setActive("whileFocus",!0),this.isActive=!0)}onBlur(){this.isActive&&this.node.animationState&&(this.node.animationState.setActive("whileFocus",!1),this.isActive=!1)}mount(){this.unmount=LM(O5(this.node.current,"focus",()=>this.onFocus()),O5(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}},hover:{Feature:class extends LC{mount(){let{current:e}=this.node;e&&(this.unmount=function(e,r,s={}){let[n,i,a]=zv(e,s),o=e=>{if(!zy(e))return;let{target:s}=e,n=r(s,e);if("function"!=typeof n||!s)return;let a=e=>{zy(e)&&(n(e),s.removeEventListener("pointerleave",a))};s.addEventListener("pointerleave",a,i)};return n.forEach(e=>{e.addEventListener("pointerenter",o,i)}),a}(e,(e,r)=>(zb(this.node,r,"Start"),e=>zb(this.node,e,"End"))))}unmount(){}}},pan:{Feature:class extends LC{constructor(){super(...arguments),this.removePointerDownListener=PG}onPointerDown(e){this.session=new Bo(e,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:Bn(this.node)})}createPanHandlers(){let{onPanSessionStart:e,onPanStart:r,onPan:s,onPanEnd:n}=this.node.getProps();return{onSessionStart:By(e),onStart:By(r),onMove:s,onEnd:(e,r)=>{delete this.session,n&&P0.postRender(()=>n(e,r))}}}mount(){this.removePointerDownListener=Bs(this.node.current,"pointerdown",e=>this.onPointerDown(e))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}}},drag:{Feature:class extends LC{constructor(e){super(e),this.removeGroupControls=PG,this.removeListeners=PG,this.controls=new Bx(e)}mount(){let{dragControls:e}=this.node.getProps();e&&(this.removeGroupControls=e.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||PG}update(){let{dragControls:e}=this.node.getProps(),{dragControls:r}=this.node.prevProps||{};e!==r&&(this.removeGroupControls(),e&&(this.removeGroupControls=e.subscribe(this.controls)))}unmount(){this.removeGroupControls(),this.removeListeners(),this.controls.isDragging||this.controls.endPanSession()}},ProjectionNode:zx,MeasureLayout:Bk},layout:{ProjectionNode:zx,MeasureLayout:Bk}},(e,r)=>r.isSVG??F9(e)?new FX(r):new F7(r,{allowProjection:e!==V.Fragment})),zM=(0,V.memo)(({children:e,as:r="p",className:s,duration:n=2,spread:i=2})=>{let a=zA.create(r),o=(0,V.useMemo)(()=>(e?.length??0)*i,[e,i]);return(0,U.jsx)(a,{animate:{backgroundPosition:"0% center"},className:(0,e1.cn)("relative inline-block bg-[length:250%_100%,auto] bg-clip-text text-transparent","[--bg:linear-gradient(90deg,#0000_calc(50%-var(--spread)),var(--color-background),#0000_calc(50%+var(--spread)))] [background-repeat:no-repeat,padding-box]",s),initial:{backgroundPosition:"100% center"},style:{"--spread":`${o}px`,backgroundImage:"var(--bg), linear-gradient(var(--color-muted-foreground), var(--color-muted-foreground))"},transition:{repeat:1/0,duration:n,ease:"linear"},children:e})}),zI=(0,rE.default)("alarm-clock",[["circle",{cx:"12",cy:"13",r:"8",key:"3y4lt7"}],["path",{d:"M12 9v4l2 2",key:"1c63tq"}],["path",{d:"M5 3 2 6",key:"18tl5t"}],["path",{d:"m22 6-3-3",key:"1opdir"}],["path",{d:"M6.38 18.7 4 21",key:"17xu3x"}],["path",{d:"M17.64 18.67 20 21",key:"kv2oe2"}]]),zP=(0,rE.default)("pause",[["rect",{x:"14",y:"3",width:"5",height:"18",rx:"1",key:"kaeet6"}],["rect",{x:"5",y:"3",width:"5",height:"18",rx:"1",key:"1wsw3u"}]]),zF=new Set(["preparing","waiting_reviewer","waiting_feedback","discussing","sending_feedback","waiting_rereview","running_task","waiting_resume"]),zL={ship:{text:"ship",className:"border-emerald-500/40 bg-emerald-500/10 text-emerald-700 dark:text-emerald-400"},"needs-changes":{text:"needs-changes",className:"border-amber-500/40 bg-amber-500/10 text-amber-700 dark:text-amber-400"},"cannot-verify":{text:"cannot-verify",className:"border-border bg-muted text-muted-foreground"}};function zO(e){return null!=e.max_rounds&&(e.round??1)>e.max_rounds}function zB(e){return e.map(e=>e.id).sort().join(",")}function zz({projectId:e,branch:r,runUpdate:s,streamEpoch:n,onRunsChange:i}){let[a,o]=(0,V.useState)([]),[l,c]=(0,V.useState)([]),[d,u]=(0,V.useState)({}),[h,f]=(0,V.useState)({}),[p,m]=(0,V.useState)(null),[g,x]=(0,V.useState)(null),v=(0,V.useRef)(0),{markReviewRunRead:y}=(0,V.useContext)(Iz),[b,w]=(0,V.useState)(()=>({projectId:e,branch:r}));(b.projectId!==e||b.branch!==r)&&(w({projectId:e,branch:r}),x(null));let _=(0,V.useRef)(0),S=(0,V.useRef)(null),k=(0,V.useRef)({projectId:e,branch:r});(0,V.useEffect)(()=>{k.current={projectId:e,branch:r}},[e,r]);let j=(0,V.useCallback)(async s=>{if(!e)return;let n=++_.current,a=AD(e,r,s);try{let[e,r]=await Promise.all([a.request,a.awaitingDismissal]);if(n!==_.current)return;S.current={at:a.issuedAt,runs:e},o(e),c(r),i?.(e),x(r=>{if(!r)return r;let s=e.find(e=>e.id===r.runId)??null;return(s?.status??null)===r.status&&(s||zB(e)===r.signature)?r:null})}catch{}},[e,r,i]),C=(0,V.useRef)(null);(0,V.useEffect)(()=>{let e=null!==C.current&&C.current!==n;C.current=n,j({force:e})},[j,n]),(0,V.useEffect)(()=>{s&&j({force:!0})},[s,j]),(0,V.useEffect)(()=>{if(0===a.length)return;let e=setInterval(()=>void j({force:!0}),5e3);return()=>clearInterval(e)},[a.length,j]),(0,V.useEffect)(()=>{let e=()=>{"visible"===document.visibilityState&&j({force:!0})};return document.addEventListener("visibilitychange",e),window.addEventListener("online",e),()=>{document.removeEventListener("visibilitychange",e),window.removeEventListener("online",e)}},[j]);let N=async(s,n,i)=>{let a=++v.current;m(s),x(null);let o=null;try{await i()}catch(e){o=e instanceof Error?e.message:String(e)}finally{m(null),j({force:!0})}if(!o)return void y(s,{runEnded:"finalize"!==n&&"rereview"!==n&&"schedule"!==n});let l=null;if(e){let s=AD(e,r,{force:!0}),n=await s.request.catch(()=>null),i=S.current;l=i&&i.at>=s.issuedAt?i.runs:n}if(k.current.projectId!==e||k.current.branch!==r||a!==v.current)return;let c=l?.find(e=>e.id===s)??null;x({runId:s,status:c?.status??null,message:(l?function(e,r){if("cancel"===e||"pause"===e||"resume"===e||"schedule"===e||"dismiss"===e)return null;if(!r)return"This review has already ended — the feedback may have been sent, or the run was cancelled.";if("approve"===e){if("discussing"===r.status)return"The reviewer is in discussion: click Finalize for an updated verdict, then send the feedback.";if("waiting_reviewer"===r.status)return"The reviewer is redrafting — send once it finishes.";if("sending_feedback"===r.status)return"The feedback is being sent."}if("finalize"===e){if("waiting_feedback"===r.status)return"The final review is already out — just send the feedback.";if("waiting_reviewer"===r.status)return"The reviewer is drafting — try again shortly."}if("accept"===e){if("discussing"===r.status)return"The reviewer is in discussion: click Finalize for an updated verdict.";if("waiting_reviewer"===r.status)return"The reviewer is redrafting — decide once it finishes.";if("sending_feedback"===r.status)return"The feedback is being sent."}if("rereview"===e){if("waiting_rereview"===r.status)return null;if("waiting_reviewer"===r.status)return"The re-review has started — the reviewer is on it.";if("waiting_feedback"===r.status)return"This re-review round already has a verdict."}return null}(n,c):null)??o,signature:zB(l??[])})},E=a.filter(e=>zF.has(e.status)),D=!g||E.some(e=>e.id===g.runId)||l.some(e=>e.id===g.runId)?null:g;return 0!==E.length||0!==l.length||D?(0,U.jsxs)("div",{className:"shrink-0 border-b bg-muted/30 px-3 py-2.5 space-y-2 max-h-[50vh] overflow-y-auto",children:[D&&(0,U.jsxs)("div",{className:"flex items-start justify-between gap-2 rounded-md border border-destructive/30 bg-destructive/5 py-1 pl-2.5 pr-1 text-destructive",style:{fontSize:"var(--conv-font-size, 12px)"},children:[(0,U.jsxs)("span",{className:"flex min-w-0 items-start gap-1.5 py-0.5",children:[(0,U.jsx)(ou,{className:"mt-0.5 h-3 w-3 shrink-0"}),(0,U.jsx)("span",{className:"min-w-0 break-words",children:D.message})]}),(0,U.jsx)(a$.Button,{variant:"ghost",size:"icon-sm","aria-label":"Dismiss",onClick:()=>x(null),children:(0,U.jsx)(rD,{className:"h-3 w-3"})})]}),[...l,...E].map(e=>"repeat"===e.kind?(0,U.jsx)(zK,{run:e,busy:p===e.id,error:g?.runId===e.id?g.message:null,onAction:r=>N(e.id,r,()=>"cancel"===r?aC.api.cancelWorkflowRun(e.id):"dismiss"===r?aC.api.dismissWorkflowRun(e.id):aC.api.workflowRunGate(e.id,r)),onScheduleResume:r=>N(e.id,"schedule",()=>aC.api.scheduleResume(e.id,r))},e.id):(0,U.jsx)(zW,{run:e,busy:p===e.id,error:g?.runId===e.id?g.message:null,editing:!!h[e.id],draft:d[e.id],onDraftChange:r=>u(s=>({...s,[e.id]:r})),onToggleEditing:()=>f(r=>({...r,[e.id]:!r[e.id]})),onAction:(r,s)=>N(e.id,r,()=>"cancel"===r?aC.api.cancelWorkflowRun(e.id):"approve"===r?aC.api.workflowRunGate(e.id,"approve",d[e.id]??void 0):"rereview"===r?aC.api.workflowRunGate(e.id,"rereview",void 0,{extend:!!s?.extend}):aC.api.workflowRunGate(e.id,r))},e.id))]}):null}let z$={preparing:"Preparing…",waiting_reviewer:"Reviewer is reviewing…",waiting_feedback:"Feedback ready — waiting for you",discussing:"Discussing",sending_feedback:"Sending feedback…",waiting_rereview:"Changes made — waiting for you"};function zW({run:e,busy:r,error:s,editing:n,draft:i,onDraftChange:a,onToggleEditing:o,onAction:l}){let c="waiting_feedback"===e.status||"waiting_rereview"===e.status||"discussing"===e.status,d="preparing"===e.status||"waiting_reviewer"===e.status||"sending_feedback"===e.status,u=c?"bg-amber-500":"bg-sky-500",h=function(e){if(!e.loop_id)return null;let r=e.round??1,s=e.max_rounds?`Round ${r} / ${e.max_rounds}`:`Round ${r}`;return e.loop_manual?`${s} \xb7 manual`:s}(e),f=zO(e),p=e.verdict?zL[e.verdict]:null,m=i??e.feedback_snapshot??"",g={fontSize:"var(--conv-font-size, 12px)"},x=z$[e.status];return(0,U.jsxs)("div",{className:"flex max-h-[calc(50vh-1.375rem)] flex-col gap-2.5 rounded-lg border bg-background/70 p-3 shadow-xs",style:{fontSize:"var(--conv-font-size, 14px)"},children:[(0,U.jsxs)("div",{className:"shrink-0 space-y-0.5",children:[(0,U.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,U.jsxs)("div",{className:"min-w-0 space-y-0.5",children:[(0,U.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,U.jsxs)("span",{className:"relative flex h-2 w-2 shrink-0","aria-hidden":!0,children:[d&&(0,U.jsx)("span",{className:`absolute inline-flex h-full w-full animate-ping rounded-full opacity-60 ${u}`}),(0,U.jsx)("span",{className:`relative inline-flex h-2 w-2 rounded-full ${u}`})]}),(0,U.jsx)("span",{className:"shrink-0 rounded-sm bg-muted px-1.5 py-px font-mono text-[10px] uppercase tracking-wider text-muted-foreground",children:"Review"})]}),(0,U.jsx)("div",{className:"truncate pl-4 font-medium",title:e.review_focus??void 0,children:e.review_focus||"Code review"})]}),(0,U.jsx)(jQ,{label:"End this review",children:(0,U.jsxs)(a$.Button,{variant:"ghost",size:"sm",disabled:r,onClick:()=>l("cancel"),className:"shrink-0 text-muted-foreground hover:text-destructive",children:[(0,U.jsx)(rD,{className:"h-3 w-3 -translate-y-px"}),"End"]})})]}),(0,U.jsxs)("div",{className:"flex min-w-0 items-center gap-1.5 pl-4 pr-2.5 text-muted-foreground",style:g,children:[x&&(d?(0,U.jsx)(zM,{as:"span",className:"min-w-0 truncate",children:x}):(0,U.jsx)("span",{className:`min-w-0 truncate ${c?"text-amber-700 dark:text-amber-400":""}`,children:x})),h&&(0,U.jsx)("span",{className:"ml-auto shrink-0 pl-2 tabular-nums",children:h})]})]}),e.error&&(0,U.jsxs)("div",{className:"flex shrink-0 items-start gap-1.5 rounded-md border border-amber-500/30 bg-amber-500/10 px-2.5 py-1.5 text-amber-700 dark:text-amber-400",style:g,children:[(0,U.jsx)(ou,{className:"mt-0.5 h-3 w-3 shrink-0"}),(0,U.jsx)("span",{className:"min-w-0 break-words",children:e.error})]}),"preparing"===e.status&&(0,U.jsx)("div",{className:"shrink-0 rounded-md bg-muted/50 px-2.5 py-1.5 text-muted-foreground",style:g,children:"Distilling context and starting the reviewer"}),"discussing"===e.status&&(0,U.jsxs)("div",{className:"flex shrink-0 items-center justify-between gap-2 rounded-md bg-muted/50 py-1 pl-2.5 pr-1",children:[(0,U.jsx)("span",{className:"min-w-0 text-muted-foreground",style:g,children:"Discuss with the reviewer, then finalize the review to send it"}),(0,U.jsx)(jQ,{label:"Have the reviewer write its final review from the discussion",children:(0,U.jsxs)(a$.Button,{size:"sm",variant:"outline","aria-label":"Finalize review",className:"shrink-0 bg-background",disabled:r,onClick:()=>l("finalize"),children:[(0,U.jsx)(E9,{className:"h-3 w-3"}),"Finalize"]})})]}),"waiting_rereview"===e.status&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)("div",{className:"shrink-0 rounded-md bg-muted/50 px-2.5 py-1.5 text-muted-foreground",style:g,children:f?`The source session applied the feedback. It reached the ${e.max_rounds}-round limit — add another round?`:"The source session applied the feedback. Have the same reviewer re-review the changes?"}),(0,U.jsxs)("div",{className:"flex shrink-0 flex-wrap justify-end gap-2",children:[(0,U.jsx)(a$.Button,{variant:"outline",size:"sm",disabled:r,onClick:()=>l("cancel"),children:"End loop"}),(0,U.jsx)(jQ,{label:f?"Raise the round limit and re-review":"Have the same reviewer review the new changes",children:(0,U.jsx)(a$.Button,{size:"sm",disabled:r,onClick:()=>l("rereview",{extend:f}),children:f?"Add round":"Re-review"})})]})]}),"waiting_feedback"===e.status&&(0,U.jsxs)("div",{className:"flex min-h-24 flex-col overflow-hidden rounded-md border bg-background",children:[(0,U.jsxs)("div",{className:"flex shrink-0 items-center justify-between gap-2 border-b bg-muted/40 py-1 pl-2.5 pr-1",style:g,children:[(0,U.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,U.jsx)("span",{className:"shrink-0 text-muted-foreground",children:"Verdict"}),p?(0,U.jsx)("span",{className:`rounded border px-1.5 py-px font-mono ${p.className}`,children:p.text}):(0,U.jsx)("span",{className:"truncate rounded border border-dashed px-1.5 py-px text-muted-foreground",children:"Not detected — use your judgment"})]}),(0,U.jsx)(a$.Button,{variant:"ghost",size:"sm",disabled:r,onClick:o,className:"h-6 shrink-0 px-2 text-muted-foreground",children:n?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(S_,{className:"h-3 w-3 mr-1"}),"Preview"]}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(lT,{className:"h-3 w-3 mr-1"}),"Edit"]})})]}),n?(0,U.jsx)(aq,{className:"font-mono min-h-0 max-h-72 shrink resize-none overflow-y-auto rounded-none border-0 shadow-none focus-visible:ring-0",style:g,value:m,onChange:e=>a(e.target.value)}):(0,U.jsx)("div",{className:"min-h-0 max-h-72 overflow-y-auto px-3 py-2",style:g,children:(0,U.jsx)(cz,{children:m})})]}),"waiting_feedback"===e.status&&(0,U.jsxs)("div",{className:"flex shrink-0 flex-wrap justify-end gap-2",children:[(0,U.jsx)(jQ,{label:"Send this feedback to the source session",children:(0,U.jsx)(a$.Button,{size:"sm",variant:"ship"===e.verdict?"outline":"default",disabled:r,onClick:()=>l("approve"),children:"Send feedback"})}),"ship"===e.verdict&&(0,U.jsx)(jQ,{label:"Accept the verdict and end the review without sending anything",children:(0,U.jsx)(a$.Button,{size:"sm",disabled:r,onClick:()=>l("accept"),children:"Accept"})})]}),s&&(0,U.jsxs)("div",{className:"flex shrink-0 items-start gap-1.5 rounded-md border border-destructive/30 bg-destructive/5 px-2.5 py-1.5 text-destructive",style:g,children:[(0,U.jsx)(ou,{className:"mt-0.5 h-3 w-3 shrink-0"}),(0,U.jsx)("span",{className:"min-w-0 break-words",children:s})]})]})}let zH=e=>String(e).padStart(2,"0");function zU(e){let r=new Date(e);return`${r.getFullYear()}-${zH(r.getMonth()+1)}-${zH(r.getDate())}T${zH(r.getHours())}:${zH(r.getMinutes())}`}function zV({busy:e,onSchedule:r,onClose:s}){let[n,i]=(0,V.useState)(""),[a,o]=(0,V.useState)(null),[l]=(0,V.useState)(()=>Date.now());return(0,U.jsxs)("div",{className:"space-y-1.5",style:{fontSize:"var(--conv-font-size, 12px)"},children:[(0,U.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,U.jsx)("span",{className:"text-muted-foreground",children:"Continue in:"}),(0,U.jsx)(a$.Button,{size:"sm",variant:"outline",disabled:e,onClick:()=>r(Date.now()+36e5),children:"+1h"}),(0,U.jsx)(a$.Button,{size:"sm",variant:"outline",disabled:e,onClick:()=>r(Date.now()+18e6),children:"+5h"}),(0,U.jsx)("input",{type:"datetime-local","aria-label":"Custom resume time",value:n,min:zU(l),max:zU(l+6048e5),onChange:e=>{i(e.target.value),o(null)},className:"h-7 rounded-md border bg-background px-1.5 text-xs"}),(0,U.jsx)(a$.Button,{size:"sm",variant:"outline",disabled:e||!n,onClick:()=>{let e=new Date(n).getTime(),s=Date.now();return n&&Number.isFinite(e)?e<=s?o("That time has already passed"):e-s>6048e5?o("It has to be within 7 days"):void r(e):o("Pick a time first")},children:"Set this time"}),(0,U.jsx)(a$.Button,{size:"sm",variant:"ghost",disabled:e,onClick:s,children:"Cancel"})]}),a&&(0,U.jsx)("div",{className:"text-destructive",children:a})]})}let zq=(e,r)=>`${e} ${r}${1===e?"":"s"}`;function zK({run:e,busy:r,error:s,onAction:n,onScheduleResume:i}){let[a,o]=(0,V.useState)(!1),[l,c]=(0,V.useState)(!1),[d,u]=(0,V.useState)(!1),h=(0,aC.repeatLoopParams)(e),f=Array.isArray(h?.doneItems)?h.doneItems:[],p=e.round??1,m="waiting_resume"===e.status,g="completed"===e.status,x=m&&h?.dispatchFailed===!0,v=m&&!x?Math.max(1,p-1):p,y=h?.stopAfterCurrent===!0,b=function(e){if(!e)return null;let r="plan"===e.kind?`Plan: ${e.fields?.planFile?.trim()||IN.defaults.planFile}`:"custom"===e.kind?function(e){let r=IR(e)[0];if(!r)return"Own instruction";let s=Array.from(r);return`Own: ${s.length>60?`${s.slice(0,60).join("")}…`:r}`}(e.fields?.source):null;return r?e.edited?`${r} (edited)`:r:null}(h?.preset),w=h?.handoffNote?.trim()||null,_=m&&"number"==typeof h?.resumeAt?h.resumeAt:null,S=async e=>{await i(e),u(!1)},k=h?.name??"Loop",j=h?.remaining&&/^\d+$/.test(h.remaining.trim())?Number(h.remaining.trim()):null,C=null!==j&&f.length>0?f.length+j:null,N=C?Math.round(f.length/C*100):g?100:null,E="preparing"===e.status||"running_task"===e.status,D="preparing"===e.status?`Starting ${k} #${p}…`:"running_task"===e.status?`${k} #${p} ${y?"will pause after this item…":"is working"}`:m?"Paused — waiting for you":g?"Done":null,T=null!=e.max_rounds?e.max_rounds-p:null,R=m&&zO(e)?`Reached the ${e.max_rounds}-iteration limit`:E&&null!==T&&T<=3?T<=0?`Last iteration (limit ${e.max_rounds})`:`${zq(T,"iteration")} left before the limit`:null,A=m?"bg-amber-500":g?"bg-emerald-500":"bg-sky-500",M={fontSize:"var(--conv-font-size, 12px)"},I="inline-flex items-center gap-1 rounded-md border bg-background px-2 py-0.5 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground";return(0,U.jsxs)("div",{className:"space-y-2.5 rounded-lg border bg-background/70 p-3 shadow-xs",style:{fontSize:"var(--conv-font-size, 14px)"},children:[(0,U.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,U.jsxs)("div",{className:"min-w-0 space-y-0.5",children:[(0,U.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,U.jsxs)("span",{className:"relative flex h-2 w-2 shrink-0","aria-hidden":!0,children:[!m&&!g&&(0,U.jsx)("span",{className:`absolute inline-flex h-full w-full animate-ping rounded-full opacity-60 ${A}`}),(0,U.jsx)("span",{className:`relative inline-flex h-2 w-2 rounded-full ${A}`})]}),(0,U.jsx)("span",{className:"shrink-0 rounded-sm bg-muted px-1.5 py-px font-mono text-[10px] uppercase tracking-wider text-muted-foreground",children:"Loop"}),(0,U.jsx)("span",{className:"min-w-0 truncate font-medium",title:k,children:k})]}),(0,U.jsxs)("div",{className:"flex min-w-0 items-center gap-1.5 pl-4 text-muted-foreground",style:M,children:[D&&(E?(0,U.jsx)(zM,{as:"span",className:"min-w-0 truncate",children:D}):(0,U.jsx)("span",{className:`min-w-0 truncate ${m?"text-amber-700 dark:text-amber-400":""}`,children:D})),R&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)("span",{"aria-hidden":!0,children:"·"}),(0,U.jsx)("span",{className:"shrink-0 text-amber-700 dark:text-amber-400",children:R})]})]})]}),(0,U.jsxs)("div",{className:"flex shrink-0 items-center gap-1",children:["running_task"===e.status&&!y&&(0,U.jsxs)(a$.Button,{size:"sm",variant:"outline",disabled:r,onClick:()=>n("pause"),title:"Pause the loop once the current session finishes this item",children:[(0,U.jsx)(zP,{className:"h-3 w-3"}),"Stop after this item"]}),g?(0,U.jsx)(a$.Button,{variant:"ghost",size:"icon-sm",disabled:r,"aria-label":"Close",title:"Close this card",onClick:()=>n("dismiss"),children:(0,U.jsx)(rD,{className:"h-3 w-3"})}):(0,U.jsxs)(a$.Button,{variant:"ghost",size:"sm",disabled:r,onClick:()=>n("cancel"),className:"text-muted-foreground hover:text-destructive",title:"End the loop now and stop the running session",children:[(0,U.jsx)(rD,{className:"h-3 w-3 -translate-y-px"}),"End"]})]})]}),b&&(0,U.jsxs)("div",{className:"flex min-w-0 items-center gap-1.5 text-muted-foreground",style:M,title:b,children:[(0,U.jsx)(Cn,{className:"h-3 w-3 shrink-0"}),(0,U.jsx)("span",{className:"min-w-0 truncate font-mono",children:b})]}),(null!==N||h?.remaining)&&(0,U.jsxs)("div",{className:"flex items-center gap-3",style:M,children:[null!==N&&(0,U.jsx)("div",{className:"h-1.5 flex-1 overflow-hidden rounded-full bg-muted",role:"progressbar","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":N,children:(0,U.jsx)("div",{className:`h-full rounded-full transition-all ${g?"bg-emerald-500":"bg-primary/70"}`,style:{width:`${N}%`}})}),(0,U.jsx)("span",{className:"shrink-0 tabular-nums text-muted-foreground",children:null!==C?`${f.length} / ${C}`:h?.remaining&&`${h.remaining} left`})]}),h?.prevItem&&(0,U.jsxs)("div",{className:"flex min-w-0 items-baseline gap-2 rounded-md bg-muted/50 px-2.5 py-1.5",style:M,children:[(0,U.jsxs)("span",{className:"flex shrink-0 items-center gap-1 text-muted-foreground",children:[(0,U.jsx)(al.Check,{className:"h-3 w-3 self-center text-emerald-600 dark:text-emerald-400"}),"Last item"]}),(0,U.jsx)("span",{className:"min-w-0 break-words",children:h.prevItem})]}),g&&(0,U.jsxs)("div",{className:"text-muted-foreground",style:M,children:["Last session: ",k," #",p," (in the sidebar)"]}),e.error&&(0,U.jsxs)("div",{className:"flex items-start gap-1.5 rounded-md border border-amber-500/30 bg-amber-500/10 px-2.5 py-1.5 text-amber-700 dark:text-amber-400",style:M,children:[(0,U.jsx)(ou,{className:"mt-0.5 h-3 w-3 shrink-0"}),(0,U.jsx)("span",{className:"min-w-0 break-words",children:e.error})]}),(f.length>0||w)&&(0,U.jsxs)("div",{className:"space-y-2",style:M,children:[(0,U.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5",children:[f.length>0&&(0,U.jsxs)("button",{type:"button","aria-expanded":l,onClick:()=>c(e=>!e),className:I,children:[l?(0,U.jsx)(aa,{className:"h-3 w-3"}):(0,U.jsx)(i2,{className:"h-3 w-3"}),zq(f.length,"item")," done"]}),w&&(0,U.jsxs)("button",{type:"button","aria-expanded":a,onClick:()=>o(e=>!e),className:I,children:[a?(0,U.jsx)(aa,{className:"h-3 w-3"}):(0,U.jsx)(i2,{className:"h-3 w-3"}),"Last handoff"]})]}),l&&f.length>0&&(0,U.jsx)("ol",{"data-testid":"loop-done-items",className:"max-h-60 list-decimal overflow-y-auto rounded-md border bg-background py-2 pl-8 pr-3 font-mono text-muted-foreground",children:f.map((e,r)=>(0,U.jsx)("li",{className:"break-words",children:e},r))}),a&&(0,U.jsx)("pre",{"data-testid":"loop-handoff-note",className:"max-h-60 overflow-y-auto whitespace-pre-wrap break-words rounded-md border bg-background px-3 py-2 font-mono text-muted-foreground",children:w})]}),m&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)("div",{className:"text-muted-foreground",style:M,children:x?`Iteration #${p} could not start, so it has no session`:`Session: ${k} #${v} (in the sidebar)`}),(0,U.jsxs)("div",{className:"flex flex-wrap items-center justify-center gap-2",children:[(0,U.jsxs)(a$.Button,{size:"sm",variant:"outline",disabled:r,onClick:()=>n("resume"),children:[(0,U.jsx)(dw,{className:"h-3 w-3"}),"Continue loop"]}),null===_&&!d&&(0,U.jsxs)(a$.Button,{size:"sm",variant:"outline",disabled:r,onClick:()=>u(!0),children:[(0,U.jsx)(zI,{className:"h-3 w-3"}),"Continue later"]})]})]}),null!==_&&(0,U.jsxs)("div",{className:"flex items-center gap-1 text-muted-foreground",style:M,children:[(0,U.jsx)(zI,{className:"h-3 w-3"}),(0,U.jsxs)("span",{children:["Continues automatically at ",function(e,r=Date.now()){let s=new Date(e),n=`${zH(s.getHours())}:${zH(s.getMinutes())}`;return s.toDateString()===new Date(r).toDateString()?n:`${s.getMonth()+1}/${s.getDate()} ${n}`}(_)," ·"]}),(0,U.jsx)("button",{type:"button",disabled:r,onClick:()=>void S(null),className:"underline-offset-2 hover:text-foreground hover:underline disabled:opacity-50",children:"Cancel"})]}),m&&null===_&&d&&(0,U.jsx)(zV,{busy:r,onSchedule:e=>void S(e),onClose:()=>u(!1)}),s&&(0,U.jsx)("div",{className:"text-destructive",style:M,children:s})]})}let zX=(0,rE.default)("repeat",[["path",{d:"m17 2 4 4-4 4",key:"nntrym"}],["path",{d:"M3 11v-1a4 4 0 0 1 4-4h14",key:"84bu3i"}],["path",{d:"m7 22-4-4 4-4",key:"1wqhfi"}],["path",{d:"M21 13v1a4 4 0 0 1-4 4H3",key:"1rx37r"}]]),zY=()=>()=>{};function zG(e,r,s){let n=Math.round(Number(e));return Number.isFinite(n)&&""!==e.trim()?Math.min(s,Math.max(1,n)):r}function zJ({projectId:e,branch:r,disabled:s,onStarted:n}){let[i,a]=(0,V.useState)(!1),[o,l]=(0,V.useState)(""),[c,d]=(0,V.useState)("plan"),[u,h]=(0,V.useState)(()=>({...IT("plan").defaults})),[f,p]=(0,V.useState)(()=>IO("plan",IT("plan").defaults)),[m,g]=(0,V.useState)(!1),[x,v]=(0,V.useState)("form"),[y,b]=(0,V.useState)(null),[w,_]=(0,V.useState)(Ep),{providers:S,error:k,loading:j}=Mj(i),C=S.find(e=>e.type===w)?.type??S[0]?.type??w,N=S.some(e=>e.type===C),[E,D]=(0,V.useState)(String(aC.REPEAT_LOOP_DEFAULT_ITERATIONS)),[T,R]=(0,V.useState)(String(aC.REPEAT_LOOP_DEFAULT_MINUTES)),[A,M]=(0,V.useState)(""),[I,P]=(0,V.useState)(!1),[F,L]=(0,V.useState)(()=>IT("plan").handoffByDefault),[O,B]=(0,V.useState)(!1),[z,$]=(0,V.useState)(null),[W,H]=(0,V.useState)(!1),[q,K]=(0,V.useState)(null),Y=IT(c),G=Y.fields.length>0,J=G&&m||!G&&""!==f.trim(),Z=e=>{let r=IT(e);if(d(e),b(null),g(!1),L(r.handoffByDefault),0===r.fields.length)return void v("instruction");let s={...r.defaults,...u};h(s),p(IO(e,s)),v("form")},Q=(e,r)=>{let s={...u,[e]:r};h(s),m||p(IO(c,s))},ee=r=>{r?($(null),H(!1),b(null),K(null),P(!1),e&&(e=>{let r=function(e){try{let r=window.localStorage.getItem(IB(e));if(!r)return null;let s=JSON.parse(r);return s&&"object"==typeof s?s:null}catch{return null}}(e);if(!r)return;let s="custom"===r.kind?"custom":"plan",n=IT(s),i={...n.defaults,...r.fields??{}},a="custom"===s&&!r.fields?.source?.trim()&&!!r.prompt?.trim(),o=n.fields.length>0&&(!0===r.edited||a);d(s),h(i),g(o),p(n.fields.length>0&&!o?IO(s,i):r.prompt??""),v(n.fields.length>0&&!o?"form":"instruction"),"string"==typeof r.agentType&&_(r.agentType),"string"==typeof r.iterations&&D(r.iterations),"string"==typeof r.minutes&&R(r.minutes),"string"==typeof r.checkCommand&&M(r.checkCommand),L("boolean"==typeof r.handoff?r.handoff:n.handoffByDefault)})(e)):e&&function(e,r){try{window.localStorage.setItem(IB(e),JSON.stringify(r))}catch{}}(e,{kind:c,fields:u,prompt:f,edited:m,agentType:C,iterations:E,minutes:T,checkCommand:A,handoff:F}),a(r)},et=async e=>{try{return await aC.api.workflowRunGate(e.id,"pause"),!0}catch(r){return K({run:e,message:r instanceof Error?r.message:String(r)}),!1}},er=async()=>{if(q&&!O){B(!0);try{await et(q.run)&&(K(null),xc.toast.success("The loop will stop after its first item"),ee(!1))}finally{B(!1)}}},es=async(s=F)=>{if(!e||!f.trim()||O||q||!N)return;B(!0),$(null),H(!1);let i=function(e,r){let s=IT(e).fields.map(e=>e.key),n={};for(let e of s)r[e]?.trim()&&(n[e]=r[e]);return Object.keys(n).length?n:void 0}(c,u),a={kind:c,...i?{fields:i}:{},...G&&m?{edited:!0}:{}};try{let i=await aC.api.createRepeatLoop({projectId:e,branch:r,prompt:f.trim(),agentType:C,...o.trim()?{name:o.trim()}:{},maxIterations:zG(E,aC.REPEAT_LOOP_DEFAULT_ITERATIONS,aC.REPEAT_LOOP_MAX_ITERATIONS),maxMinutes:zG(T,aC.REPEAT_LOOP_DEFAULT_MINUTES,aC.REPEAT_LOOP_MAX_MINUTES),...A.trim()?{checkCommand:A.trim()}:{},preset:a,handoff:s});if(n?.(i),I&&!await et(i))return;l(""),ee(!1),xc.toast.success(I?"Loop started — it will stop after the first item":"Loop started")}catch(e){$(e instanceof Error?e.message:String(e)),H(s&&e?.code==="worker_unsupported")}finally{B(!1)}},en=(0,V.useSyncExternalStore)(zY,X,()=>!1),ei=!f.trim()||O||null!==q||!N;return(0,U.jsxs)(rT,{open:i,onOpenChange:ee,children:[(0,U.jsx)(rR,{asChild:!0,children:(0,U.jsx)(a$.Button,{variant:"ghost",size:"icon",className:"h-7 w-7",disabled:!e||s,title:s?"A loop is already running on this workspace":"New loop — repeat one instruction, a fresh session per item, until done","aria-label":"New loop",children:(0,U.jsx)(zX,{className:"h-3.5 w-3.5"})})}),(0,U.jsxs)(rP,{showCloseButton:!1,className:"max-h-[calc(100dvh-2rem)] w-[calc(100%-2rem)] min-w-0 gap-0 overflow-hidden bg-card p-0 grid-rows-[auto_minmax(0,1fr)_auto] sm:w-full sm:max-w-[560px]",onKeyDown:e=>{"Enter"===e.key&&(e.metaKey||e.ctrlKey)&&!ei&&(e.preventDefault(),es())},children:[(0,U.jsxs)("div",{className:"flex items-start gap-3 border-b bg-secondary px-4 py-3.5",children:[(0,U.jsx)("span",{className:"grid size-7 shrink-0 place-items-center rounded-lg border border-primary/20 bg-accent text-accent-foreground",children:(0,U.jsx)(zX,{className:"size-[15px]"})}),(0,U.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,U.jsx)(rO,{className:"text-[14.5px] font-semibold tracking-tight",children:"New loop"}),(0,U.jsxs)(rB,{className:"mt-0.5 text-[11.5px] leading-snug",children:["Runs the same instruction again and again, each time in a fresh session that handles one item, until a session reports there is nothing left."," ",(0,U.jsx)("a",{href:`${mp.DOCS_URL}/loops`,target:"_blank",rel:"noopener noreferrer",className:"whitespace-nowrap text-foreground underline underline-offset-2 hover:text-primary",children:"Learn more"})]})]}),(0,U.jsxs)(rM,{className:"ml-auto grid size-6 shrink-0 place-items-center rounded-md border border-transparent text-muted-foreground/70 transition-colors hover:border-border hover:bg-muted hover:text-foreground",children:[(0,U.jsx)(rD,{className:"size-3.5"}),(0,U.jsx)("span",{className:"sr-only",children:"Close"})]})]}),(0,U.jsxs)("div",{className:"flex min-h-0 min-w-0 flex-col gap-[13px] overflow-x-hidden overflow-y-auto px-4 pt-3.5 pb-1",children:[(0,U.jsxs)("div",{className:"flex min-w-0 flex-col gap-[7px]",children:[(0,U.jsx)(pZ,{children:"Items from"}),(0,U.jsxs)(fP,{value:c,onValueChange:e=>{e!==c&&(IT(e).fields.length>0&&J?b({action:"switch",to:e}):Z(e))},children:[(0,U.jsx)(fL,{size:"sm","aria-label":"Items from",className:pX,children:(0,U.jsx)(fF,{})}),(0,U.jsx)(fO,{children:ID.map(e=>(0,U.jsx)(fB,{value:e.kind,children:e.label},e.kind))})]}),(0,U.jsx)(p0,{children:Y.description})]}),y&&(0,U.jsxs)(p2,{tone:"rose",icon:(0,U.jsx)(ou,{}),children:["regenerate"===y.action?"Regenerating replaces the instruction with the form's version — your edits are lost.":`Switching to ${IT(y.to).label} replaces the instruction — your text is lost.`," ",(0,U.jsxs)("span",{className:"inline-flex gap-2",children:[(0,U.jsx)(p1,{onClick:()=>"regenerate"===y.action?void(g(!1),b(null),p(IO(c,u))):Z(y.to),children:"Discard my text"}),(0,U.jsx)(p1,{onClick:()=>b(null),children:"Keep it"})]})]}),G&&(0,U.jsx)("div",{role:"tablist","aria-label":"Instruction view",className:"flex min-w-0 gap-3 border-b",children:["form","instruction"].map(e=>(0,U.jsx)("button",{type:"button",role:"tab","aria-selected":x===e,onClick:()=>v(e),className:(0,e1.cn)("-mb-px border-b-2 px-0.5 pb-1.5 text-[12px] font-medium transition-colors",x===e?"border-primary text-foreground":"border-transparent text-muted-foreground hover:text-foreground"),children:"form"===e?"Form":"Instruction"},e))}),G&&m&&(0,U.jsxs)("div",{className:"flex items-start gap-2 rounded-lg border border-amber-500/30 bg-amber-500/10 px-2.5 py-2 text-[11.5px] leading-snug text-amber-700 dark:text-amber-300",children:[(0,U.jsx)(Do,{className:"mt-px size-[13px] shrink-0"}),(0,U.jsx)("span",{className:"min-w-0 flex-1",children:"Edited by hand — the form no longer applies; the instruction text is what runs."}),(0,U.jsxs)("button",{type:"button",onClick:()=>b({action:"regenerate"}),className:"inline-flex shrink-0 items-center gap-1 whitespace-nowrap underline-offset-2 hover:underline",children:[(0,U.jsx)(of,{className:"size-3"}),"Regenerate from form"]})]}),G&&"form"===x&&(0,U.jsx)("fieldset",{disabled:m,className:"grid min-w-0 grid-cols-2 gap-x-2.5 gap-y-[13px] disabled:opacity-60",children:Y.fields.map(e=>{let r=`loop-field-${e.key}`,s=e.multiline||"planFile"===e.key;return(0,U.jsxs)("div",{className:(0,e1.cn)("flex min-w-0 flex-col gap-[7px]",s&&"col-span-2"),children:[(0,U.jsx)(pZ,{note:e.required&&!u[e.key]?.trim()?"Required":void 0,children:(0,U.jsx)("label",{htmlFor:r,children:e.label})}),e.multiline?(0,U.jsx)(aq,{id:r,value:u[e.key]??"",onChange:r=>Q(e.key,r.target.value),placeholder:e.placeholder,spellCheck:!1,className:(0,e1.cn)(pY,"field-sizing-fixed min-h-[58px] min-w-0 max-w-full resize-y px-[11px] py-1.5 font-mono text-xs leading-[1.5] md:text-xs")}):(0,U.jsx)(aX,{id:r,value:u[e.key]??"",onChange:r=>Q(e.key,r.target.value),placeholder:e.placeholder,spellCheck:!1,className:(0,e1.cn)(pY,"h-[34px] px-[11px] font-mono text-xs md:text-xs")}),e.hint&&(0,U.jsx)(p0,{children:e.hint})]},e.key)})}),(!G||"instruction"===x)&&(0,U.jsxs)("div",{className:"flex min-w-0 flex-col gap-[7px]",children:[(0,U.jsx)(pZ,{note:f.trim()?void 0:"Required",children:(0,U.jsx)("label",{htmlFor:"loop-prompt",children:"Instruction"})}),(0,U.jsx)(aq,{id:"loop-prompt",value:f,onChange:e=>{p(e.target.value),G&&g(!0)},placeholder:"Fetch the unprocessed items from …, pick the first one, handle it, and mark it processed.\nIf none are left, say so.",className:(0,e1.cn)(pY,"field-sizing-fixed min-h-[118px] min-w-0 max-w-full resize-y overflow-auto px-[11px] py-2 font-mono text-xs leading-[1.55] md:text-xs",G&&"min-h-[220px]")}),!G&&(0,U.jsx)(p0,{children:"No session remembers the previous one: say where the next unprocessed item is found and how an item is marked done. Make handling an item safe to repeat — an interrupted item may be picked up again."})]}),(0,U.jsxs)("div",{className:"grid min-w-0 grid-cols-2 gap-x-2.5 gap-y-[13px]",children:[(0,U.jsxs)("div",{className:"flex min-w-0 flex-col gap-[7px]",children:[(0,U.jsx)(pZ,{note:"Optional",children:(0,U.jsx)("label",{htmlFor:"loop-name",children:"Name"})}),(0,U.jsx)(aX,{id:"loop-name",value:o,onChange:e=>l(e.target.value),placeholder:"Loop",maxLength:80,className:(0,e1.cn)(pY,"h-[34px] px-[11px]")})]}),(0,U.jsxs)("div",{className:"flex min-w-0 flex-col gap-[7px]",children:[(0,U.jsx)(pZ,{children:"Agent"}),(0,U.jsx)("div",{role:"radiogroup","aria-label":"Agent",className:"grid min-h-[34px] min-w-0 gap-0.5 rounded-[9px] border bg-secondary p-[3px]",style:{gridTemplateColumns:"repeat(auto-fit, minmax(min(100%, 80px), 1fr))"},children:S.map(({type:e,displayName:r})=>{let s=C===e;return(0,U.jsx)("button",{type:"button",role:"radio","aria-checked":s,title:r,onClick:()=>_(e),className:(0,e1.cn)("min-h-[26px] min-w-0 truncate rounded-md border border-transparent px-2 text-[12px] font-medium transition-colors disabled:opacity-50",s?"border-border bg-card text-foreground shadow-xs":"text-muted-foreground hover:text-foreground"),children:r},e)})})]}),(0,U.jsxs)("div",{className:"flex min-w-0 flex-col gap-[7px]",children:[(0,U.jsx)(pZ,{children:(0,U.jsx)("label",{htmlFor:"loop-iterations",children:"Stop after"})}),(0,U.jsxs)(pJ,{children:[(0,U.jsx)("input",{id:"loop-iterations",inputMode:"numeric",value:E,onChange:e=>D(e.target.value),"aria-label":"Stop after (items)",className:pG}),(0,U.jsx)("span",{className:"text-[11px] whitespace-nowrap text-muted-foreground/70",children:"items"})]})]}),(0,U.jsxs)("div",{className:"flex min-w-0 flex-col gap-[7px]",children:[(0,U.jsx)(pZ,{children:(0,U.jsx)("label",{htmlFor:"loop-minutes",children:"Stop after"})}),(0,U.jsxs)(pJ,{children:[(0,U.jsx)("input",{id:"loop-minutes",inputMode:"numeric",value:T,onChange:e=>R(e.target.value),"aria-label":"Stop after (minutes)",className:pG}),(0,U.jsx)("span",{className:"text-[11px] whitespace-nowrap text-muted-foreground/70",children:"minutes"})]})]})]}),(0,U.jsxs)("div",{className:"flex min-w-0 flex-col gap-[7px]",children:[(0,U.jsx)(pZ,{note:"Optional",children:(0,U.jsx)("label",{htmlFor:"loop-check",children:"Check command"})}),(0,U.jsxs)(pJ,{children:[(0,U.jsx)(my,{}),(0,U.jsx)("input",{id:"loop-check",value:A,onChange:e=>M(e.target.value),placeholder:"npm test",spellCheck:!1,className:(0,e1.cn)(pG,"font-mono text-xs tracking-tight")})]}),(0,U.jsx)(p0,{children:"Runs in the worktree after each item; a non-zero exit stops the loop."})]}),(0,U.jsxs)("label",{className:"flex min-w-0 items-start gap-2 text-[12px] leading-snug",children:[(0,U.jsx)("input",{type:"checkbox",id:"loop-handoff",checked:F,onChange:e=>L(e.target.checked),className:"mt-0.5 size-3.5 shrink-0 accent-primary"}),(0,U.jsxs)("span",{className:"min-w-0",children:["Keep a handoff note between sessions",(0,U.jsx)("span",{className:"block text-[10.5px] text-muted-foreground/80",children:"Each session ends with a short note — lessons learned, what it did, what to watch — and the loop hands it to the next session. Nothing is written to the repo."})]})]}),(0,U.jsxs)("label",{className:"flex min-w-0 items-start gap-2 text-[12px] leading-snug",children:[(0,U.jsx)("input",{type:"checkbox",id:"loop-run-once",checked:I,onChange:e=>P(e.target.checked),className:"mt-0.5 size-3.5 shrink-0 accent-primary"}),(0,U.jsxs)("span",{className:"min-w-0",children:["Run one item first, then decide",(0,U.jsx)("span",{className:"block text-[10.5px] text-muted-foreground/80",children:"The loop stops at a gate after the first item; read its session, then continue or end the loop."})]})]}),j&&(0,U.jsx)("p",{role:"status",className:"text-xs text-muted-foreground",children:"Loading agent providers…"}),(z||k||!j&&!N)&&(0,U.jsxs)(p2,{tone:"rose",icon:(0,U.jsx)(ou,{}),children:[z||k||"No available agent providers",W&&(0,U.jsxs)(U.Fragment,{children:[" ",(0,U.jsx)(p1,{onClick:()=>{L(!1),es(!1)},disabled:O,children:"Turn off handoff note and retry"})]})]}),q&&(0,U.jsxs)(p2,{tone:"rose",icon:(0,U.jsx)(ou,{}),children:["The loop started, but the pause could not be set — it is still running item after item. (",q.message,")"," ",(0,U.jsx)(p1,{onClick:()=>void er(),disabled:O,children:"Retry pause"})]})]}),(0,U.jsxs)("div",{className:"mt-2.5 flex min-w-0 items-center gap-2.5 overflow-hidden border-t bg-secondary px-4 py-2.5",children:[(0,U.jsxs)("span",{className:"flex min-w-0 flex-1 items-center gap-1.5 overflow-hidden text-[11px] text-muted-foreground",children:[(0,U.jsx)(ao,{className:"size-3 shrink-0 text-muted-foreground/70"}),(0,U.jsxs)("span",{className:"truncate",children:["Runs on ",(0,U.jsx)("span",{className:"font-mono",children:r??"main"})]})]}),(0,U.jsx)(rM,{asChild:!0,children:(0,U.jsx)(a$.Button,{variant:"outline",size:"sm",className:"h-7 text-xs",children:q?"Close":"Cancel"})}),(0,U.jsx)(a$.Button,{size:"sm",className:"h-7 gap-1.5 text-xs","aria-label":"Start loop",onClick:()=>void es(),disabled:ei,children:O?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(aP,{className:"size-3 animate-spin"}),"Starting…"]}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(zX,{className:"size-3"}),"Start loop",(0,U.jsx)("kbd",{className:"rounded border border-background/30 bg-background/15 px-1 font-mono text-[10px] leading-[1.4] text-background/90",title:en?"Command+Enter":"Ctrl+Enter",children:en?"⌘⏎":"Ctrl⏎"})]})})]})]})]})}let zZ=(0,rE.default)("zap",[["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"}]]);function zQ({open:e,onOpenChange:r,command:s,onSave:n,onDelete:i}){let[a,o]=(0,V.useState)(""),[l,c]=(0,V.useState)("");(0,V.useEffect)(()=>{e&&(o(s?.name??""),c(s?.content??""))},[e,s]);let d=!!s;return(0,U.jsx)(rT,{open:e,onOpenChange:r,children:(0,U.jsxs)(rP,{className:"sm:max-w-md",children:[(0,U.jsx)(rF,{children:(0,U.jsx)(rO,{children:d?"Edit Command":"Add Command"})}),(0,U.jsxs)("div",{className:"space-y-4",children:[(0,U.jsxs)("div",{className:"space-y-2",children:[(0,U.jsx)("label",{className:"text-sm font-medium",children:"Name"}),(0,U.jsx)(aX,{value:a,onChange:e=>o(e.target.value),placeholder:"e.g. Run tests"})]}),(0,U.jsxs)("div",{className:"space-y-2",children:[(0,U.jsx)("label",{className:"text-sm font-medium",children:"Command"}),(0,U.jsx)(aq,{value:l,onChange:e=>c(e.target.value),placeholder:"e.g. Run all unit tests and report any failures",rows:3})]})]}),(0,U.jsxs)(rL,{className:"flex justify-between",children:[(0,U.jsx)("div",{children:d&&i&&(0,U.jsxs)(a$.Button,{variant:"ghost",size:"sm",className:"text-destructive hover:text-destructive",onClick:()=>{i(s.id),r(!1)},children:[(0,U.jsx)(ok,{className:"h-4 w-4 mr-1"}),"Delete"]})}),(0,U.jsxs)("div",{className:"flex gap-2",children:[(0,U.jsx)(a$.Button,{variant:"outline",onClick:()=>r(!1),children:"Cancel"}),(0,U.jsx)(a$.Button,{onClick:()=>{a.trim()&&l.trim()&&(n({name:a.trim(),content:l.trim()}),r(!1))},disabled:!a.trim()||!l.trim(),children:"Save"})]})]})]})})}function z0({commands:e,open:r,onOpenChange:s,disabled:n,onExecute:i,onCreate:a,onUpdate:o,onDelete:l,onCloseFocus:c}){let[d,u]=(0,V.useState)(!1),[h,f]=(0,V.useState)(null),[p,m]=(0,V.useState)(""),g=e=>{s(!1),f(e),u(!0)},x=async e=>{h?await o(h.id,e):await a(e)},v=(0,U.jsxs)(Au,{className:"ml-1 gap-1.5",size:"sm","aria-label":"Commands",disabled:n,children:[(0,U.jsx)(zZ,{className:"size-4"}),(0,U.jsx)("span",{className:"hidden @md:inline",children:"Commands"})]});return n&&(v=(0,U.jsx)("span",{className:"inline-flex",children:v})),(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(pa,{open:r&&!n,onOpenChange:e=>{e||m(""),s(e)},children:[(0,U.jsx)(jQ,{label:"Commands (/)",side:"top",children:(0,U.jsx)(po,{asChild:!0,children:v})}),(0,U.jsxs)(pl,{side:"top",align:"start",className:"w-72",onCloseAutoFocus:e=>{c&&!d&&(e.preventDefault(),c())},children:[(0,U.jsxs)(p$,{children:[(0,U.jsx)(pH,{placeholder:"Search commands…",value:p,onValueChange:m}),(0,U.jsxs)(pU,{className:"max-h-64",children:[(0,U.jsx)(pV,{className:"py-4 text-center text-xs text-muted-foreground",children:0===e.length?"No commands yet.":"No matching commands."}),e.length>0&&(0,U.jsx)(pq,{children:e.map(e=>(0,U.jsxs)(pK,{value:`${e.name} ${e.id}`,keywords:[e.content],onSelect:()=>{s(!1),i(e.content)},className:"group gap-2",children:[(0,U.jsx)("span",{className:"flex-1 truncate",children:e.name}),(0,U.jsx)("button",{type:"button","aria-label":`Edit ${e.name}`,className:"shrink-0 rounded p-0.5 text-muted-foreground opacity-0 transition-opacity hover:text-foreground group-hover:opacity-100 group-data-[selected=true]:opacity-100",onClick:r=>{r.stopPropagation(),g(e)},onPointerDown:e=>e.stopPropagation(),children:(0,U.jsx)(lT,{className:"size-3.5"})})]},e.id))})]})]}),(0,U.jsxs)("div",{className:"flex items-center justify-between gap-2 border-t px-2 py-1.5",children:[(0,U.jsxs)("button",{type:"button",onClick:()=>g(null),className:"inline-flex items-center gap-1 rounded px-1.5 py-1 text-xs text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",children:[(0,U.jsx)(oS,{className:"size-3.5"}),"New command"]}),(0,U.jsxs)("span",{className:"text-[11px] text-muted-foreground",children:["Type ",(0,U.jsx)("kbd",{className:"rounded border px-1 font-mono",children:"/"})," to open"]})]})]})]}),(0,U.jsx)(zQ,{open:d,onOpenChange:u,command:h,onSave:x,onDelete:async e=>{await l(e)}})]})}let z1=(0,rE.default)("radio",[["path",{d:"M16.247 7.761a6 6 0 0 1 0 8.478",key:"1fwjs5"}],["path",{d:"M19.075 4.933a10 10 0 0 1 0 14.134",key:"ehdyv1"}],["path",{d:"M4.925 19.067a10 10 0 0 1 0-14.134",key:"1q22gi"}],["path",{d:"M7.753 16.239a6 6 0 0 1 0-8.478",key:"r2q7qm"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}]]),z2=(0,rE.default)("hourglass",[["path",{d:"M5 22h14",key:"ehvnwv"}],["path",{d:"M5 2h14",key:"pdyrp9"}],["path",{d:"M17 22v-4.172a2 2 0 0 0-.586-1.414L12 12l-4.414 4.414A2 2 0 0 0 7 17.828V22",key:"1d314k"}],["path",{d:"M7 2v4.172a2 2 0 0 0 .586 1.414L12 12l4.414-4.414A2 2 0 0 0 17 6.172V2",key:"1vvvr6"}]]);function z5({messages:e}){let{scrollToBottom:r}=cJ(),s=(0,V.useRef)(e.length);return(0,V.useEffect)(()=>{let n=s.current;if(s.current=e.length,!(e.length<=n))for(let s=n;s<e.length;s++){let n=e[s];if("user"===n.type&&n.content.startsWith("[Executor Event:"))return void r({animation:"instant"})}},[e,r]),null}let z3=(0,V.forwardRef)(function({projectId:e,branch:r},s){let{session:n,messages:i,status:a,isInitialized:o,isLoading:l,error:c,sendMessage:d,stopGeneration:u,restartSession:h,workflowRunUpdate:f,turnState:p,streamEpoch:m,draft:g,setDraft:x,setEventListening:v}=function(e,r){let s=e?In(e,r):null,[n,i]=(0,V.useState)(()=>e?new Id(e,r):null);return(n?.key??null)!==s&&i(e?new Id(e,r):null),(0,V.useEffect)(()=>{if(n)return n.start(),()=>n.stop()},[n]),{...(0,V.useSyncExternalStore)(n?.subscribe??Iu,n?.getSnapshot??Ih,n?.getSnapshot??Ih),sendMessage:n?.sendMessage??If,stopGeneration:n?.stopGeneration??If,restartSession:n?.restartSession??If,setDraft:n?.setDraft??Ip,setEventListening:n?.setEventListening??If}}(e,r),{settings:y}=(0,c1.useConversationSettings)(),{region:b}=dJ(),{commands:w,createCommand:_,updateCommand:S,deleteCommand:k}=function(e,r){let[s,n]=(0,V.useState)([]),[i,a]=(0,V.useState)(!0),o=(0,V.useCallback)(async()=>{if(!e){n([]),a(!1);return}try{let s=await aC.api.getCommands(e,r);n(s)}catch(e){console.error("Failed to fetch commands:",e)}finally{a(!1)}},[e,r]);(0,V.useEffect)(()=>{o()},[o]);let l=(0,V.useCallback)(async s=>{if(!e)return null;try{let i=await aC.api.createCommand(e,{...s,branch:r});return n(e=>[...e,i]),i}catch(e){return console.error("Failed to create command:",e),null}},[e,r]),c=(0,V.useCallback)(async(e,r)=>{n(s=>s.map(s=>s.id===e?{...s,...r,updated_at:new Date().toISOString()}:s));try{let s=await aC.api.updateCommand(e,r);return n(r=>r.map(r=>r.id===e?s:r)),s}catch(e){return console.error("Failed to update command:",e),n(s),null}},[s]),d=(0,V.useCallback)(async e=>{n(r=>r.filter(r=>r.id!==e));try{await aC.api.deleteCommand(e)}catch(e){console.error("Failed to delete command:",e),n(s)}},[s]);return{commands:s,loading:i,createCommand:l,updateCommand:c,deleteCommand:d,refetch:o}}(e,r),[j,C]=(0,V.useState)(!1),N=(0,V.useRef)(null),[E,D]=(0,V.useState)([]),T=(0,V.useMemo)(()=>(function(e){let r=new Map,s=null,n=!1,i=!1;for(let[a,o]of e.entries())if("tool_result"===o.type&&"setPlan"===o.tool){let e=Ig(o.output);if(!e?.planId)continue;r.set(e.planId,{plan:e,firstIndex:r.get(e.planId)?.firstIndex??a}),s={key:`plan:${e.planId}`,plan:e},n=!1,i=!1}else if("tool_approval_request"===o.type&&"setPlan"===o.tool){let e=Im(o.input);e&&(s={key:`approval:${o.approvalId}`,plan:e,approval:o}),n=!1}else"system"===o.type&&o.content.startsWith(Iw)?n=!0:"user"===o.type&&"commander"!==o.origin&&(n=!1,i=!0,s&&!s.approval&&Ik(s.plan)&&(s=null));if(s&&n&&!s.approval&&(s={...s,stalled:!0}),s&&i&&!s.approval&&s.plan.waitingOn){let{waitingOn:e,...r}=s.plan;s={...s,plan:r}}return{current:s,history:r}})(i),[i]),R=!l&&o&&0===i.length;(0,V.useImperativeHandle)(s,()=>({sendMessage:async e=>{let r=e.trim();r&&await d(r)}}),[d]);let A=n?.eventListeningEnabled??!1,M="running"===a,I="waiting"===a,[P,F]=o?M?["Waiting for response...","Waiting for response..."]:I?["Still on it — add to the task...","Add to the task..."]:["Type a message, / for commands...","Type a message..."]:["Connecting...","Connecting..."],L=function(e,r){let[s,n]=(0,V.useState)(!0);return(0,V.useEffect)(()=>{let s=e.current;if(!s)return;let i=document.createElement("canvas").getContext("2d");if(!i)return;let a=()=>{let e=getComputedStyle(s);i.font=`${e.fontWeight} ${e.fontSize} ${e.fontFamily}`;let a=s.clientWidth-parseFloat(e.paddingLeft)-parseFloat(e.paddingRight);n(i.measureText(r).width<=a)};a();let o=new ResizeObserver(a);return o.observe(s),()=>o.disconnect()},[e,r]),s}(N,P),O=jN(e),B=n?.id??null,z=(0,V.useMemo)(()=>B?[...O.values()].filter(e=>e.chatSessionId===B):[],[O,B]),$=(0,V.useCallback)(async e=>{try{await aC.api.startExecutor(e.executorId,e.remoteServerId,"retrying"===e.state?e.processId:void 0)}catch(e){if(e instanceof aC.ExecutorProcessRequestError&&"start_unknown"===e.body.code&&e.body.retrying)return;if(e instanceof aC.ExecutorProcessRequestError&&"retry_ended"===e.body.code)return void xc.toast.info("Already settled",{description:e.message});xc.toast.error("Executor not started",{description:e instanceof Error?e.message:String(e)})}},[]),W=(0,V.useCallback)(async e=>{let r=e.text.trim();r&&(x(""),await d(r))},[d,x]);return e?(0,U.jsxs)("div",{className:"h-full flex flex-col min-h-0",style:{"--conv-font-size":`${y.chatFontSize}px`},children:[(0,U.jsx)("div",{className:"flex-shrink-0 flex items-center px-3 gap-4 border-b border-border",children:(0,U.jsxs)("span",{className:`flex items-center gap-0.5 py-2.5 text-xs font-medium border-b-2 text-foreground ${"default"===b?"border-primary":"border-foreground/25"}`,children:[(0,U.jsx)(rJ,{className:"h-3.5 w-3.5"}),"Main Chat"]})}),(0,U.jsxs)("div",{className:"flex-shrink-0 flex items-center justify-between px-4 h-10 border-b border-border/60 bg-muted/20",children:[(0,U.jsxs)("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[M&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(aP,{className:"h-3 w-3 animate-spin text-primary/60"}),"Working…"]}),I&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(z2,{className:"h-3 w-3 text-primary/60","aria-label":"Waiting for results"}),"Waiting for results"]})]}),n&&(0,U.jsxs)("div",{className:"flex items-center gap-1",children:[(0,U.jsx)(a$.Button,{variant:"ghost",size:"icon",onClick:async()=>{try{await v(!A)}catch{xc.toast.error("Failed to toggle event listening")}},className:`h-7 w-7 ${A?"text-amber-500":""}`,title:A?"Listening to events from runs Commander did not start (click to disable)":"Also listen to events from runs Commander did not start (click to enable)",children:(0,U.jsx)(z1,{className:"h-3.5 w-3.5"})}),(0,U.jsx)(zJ,{projectId:e,branch:r,disabled:E.some(e=>"repeat"===e.kind)}),(0,U.jsx)(a$.Button,{variant:"ghost",size:"icon",onClick:()=>h(),disabled:M,className:"h-7 w-7",title:"New Conversation",children:(0,U.jsx)(AA,{className:"h-3.5 w-3.5"})})]})]}),(0,U.jsx)(zz,{projectId:e,branch:r,runUpdate:f,streamEpoch:m,onRunsChange:D}),(0,U.jsxs)(cZ,{className:"flex-1 min-h-0",initial:"instant",children:[(0,U.jsx)(z5,{messages:i}),(0,U.jsxs)(cQ,{className:(0,e1.cn)("gap-4 p-4",R&&"min-h-full"),children:[l&&0===i.length&&(0,U.jsx)("div",{className:"flex items-center justify-center py-8",children:(0,U.jsx)(aP,{className:"h-6 w-6 animate-spin text-muted-foreground"})}),R&&(0,U.jsxs)("div",{className:"flex flex-1 flex-col items-center text-center before:grow-[382] before:content-[''] after:grow-[618] after:content-['']",children:[(0,U.jsx)("div",{className:"mx-auto w-12 h-12 rounded-xl bg-primary/10 flex items-center justify-center mb-4",children:(0,U.jsx)(rJ,{className:"h-6 w-6 text-primary/60"})}),(0,U.jsx)("h3",{className:"text-sm font-semibold mb-1 text-foreground",children:"Start a conversation"}),(0,U.jsx)("p",{className:"text-xs text-muted-foreground leading-relaxed",children:"Give it a goal — it plans the work and dispatches agents to carry it out"})]}),i.map((s,i)=>{if("turn_end"===s.type)return(0,U.jsxs)("div",{className:"mx-4 my-3 flex items-center gap-2","aria-hidden":!0,children:[(0,U.jsx)("div",{className:"h-px flex-1 bg-border"}),(0,U.jsx)("div",{className:"h-1 w-1 shrink-0 rounded-full bg-border"}),(0,U.jsx)("div",{className:"h-px flex-1 bg-border"})]},i);if("user"===s.type&&(s.content.startsWith("[System Invariant Violation]")||s.content.startsWith(IS))){let e=s.content.startsWith(IS),r=s.content.replace(/^\[(System Invariant Violation|Plan Continuation)\]\n?/,"");return(0,U.jsxs)("div",{className:"mx-4 my-2 flex gap-2 rounded-md border border-amber-500/30 bg-amber-500/10 px-3 py-2",children:[(0,U.jsx)(ou,{className:"mt-0.5 h-4 w-4 shrink-0 text-amber-500"}),(0,U.jsxs)("div",{className:"min-w-0",children:[(0,U.jsx)("div",{className:"text-xs font-medium text-amber-600 dark:text-amber-400",children:e?"Plan continuation":"System invariant correction"}),(0,U.jsx)("div",{className:"mt-0.5 whitespace-pre-wrap text-muted-foreground",style:{fontSize:"var(--conv-font-size, 12px)"},children:r})]})]},i)}if("user"===s.type){let n=s.event,a=n?.kind==="agent_task_completed"&&E.some(e=>e.source_session_id===n.sessionId||e.reviewer_session_id===n.sessionId);return(0,U.jsxs)("div",{children:[(0,U.jsx)(cO,{from:"user",children:(0,U.jsx)(cB,{style:{fontSize:"var(--conv-font-size, 14px)"},children:s.content})}),n?.kind==="agent_task_completed"&&(0,U.jsx)("div",{className:"mt-1 flex justify-end",children:(0,U.jsx)(a$.Button,{variant:"outline",size:"sm",disabled:a,title:a?"该 session 已在一个进行中的 review 里":void 0,onClick:async()=>{if(e)try{await aC.api.createWorkflowRun({projectId:e,branch:r,sourceSessionId:n.sessionId,sourceTurnEndIndex:n.turnEndEntryIndex})}catch(e){alert(e instanceof Error?e.message:String(e))}},children:"Review"})})]},i)}if("assistant"===s.type)return(0,U.jsx)(cO,{from:"assistant",children:(0,U.jsx)(cB,{style:{fontSize:"var(--conv-font-size, 14px)"},children:(0,U.jsx)(cz,{children:s.content})})},i);if("tool_use"===s.type)return"setPlan"===s.tool?null:(0,U.jsxs)("div",{className:"flex items-center gap-2 px-4 py-2 text-xs text-muted-foreground",children:[(0,U.jsx)(aK,{className:"w-3.5 h-3.5 animate-pulse"}),(0,U.jsx)("span",{children:function(e){switch(e){case"getExecutorStatus":return"Checking executor status...";case"getAgentConversation":return"Checking agent conversation...";case"listTerminals":return"Listing terminals...";case"runInTerminal":return"Sending command to terminal...";case"spawnAgentSession":return"Starting a coding agent...";case"sendToAgentSession":return"Sending a message to the agent...";default:return`Running ${e}...`}}(s.tool)})]},i);if("tool_result"===s.type){if("setPlan"===s.tool){let e=Ig(s.output);if(e?.planId){if(T.current?.plan.planId===e.planId)return null;let r=T.history.get(e.planId);return r&&r.firstIndex===i?(0,U.jsx)("div",{className:"mx-4 my-2",children:(0,U.jsx)(Iy,{plan:r.plan})},i):null}}return(0,U.jsx)("div",{className:"px-4 py-2",children:(0,U.jsxs)("details",{className:"text-xs text-muted-foreground",children:[(0,U.jsx)("summary",{className:"cursor-pointer hover:text-foreground",children:"Tool result"}),(0,U.jsx)("pre",{className:"mt-1 p-2 bg-muted/50 rounded overflow-x-auto whitespace-pre-wrap",style:{fontSize:"var(--conv-font-size, 12px)"},children:s.output})]})},i)}if("tool_approval_request"===s.type)return("setPlan"!==s.tool||"approved"!==s.resolved&&T.current?.approval?.approvalId!==s.approvalId)&&n?(0,U.jsx)(Ib,{sessionId:n.id,approvalId:s.approvalId,tool:s.tool,input:s.input,resolved:s.resolved},i):null;if("system"===s.type&&(s.content.startsWith(Iw)||s.content.startsWith(I_))){let e=s.content.startsWith(Iw)?Iw:I_;return(0,U.jsxs)("div",{className:"mx-4 my-2 flex gap-2 rounded-md border border-amber-500/40 bg-amber-500/10 px-3 py-2",children:[(0,U.jsx)(ou,{className:"mt-0.5 h-4 w-4 shrink-0 text-amber-500"}),(0,U.jsxs)("div",{className:"min-w-0",children:[(0,U.jsx)("div",{className:"text-xs font-medium text-amber-600 dark:text-amber-400",children:e===Iw?"Plan stalled":"Commander stalled"}),(0,U.jsx)("div",{className:"mt-0.5 whitespace-pre-wrap text-muted-foreground",style:{fontSize:"var(--conv-font-size, 12px)"},children:s.content.slice(e.length).trim()})]})]},i)}return"error"===s.type?(0,U.jsx)("div",{className:"mx-auto max-w-[90%] rounded-lg border border-destructive/50 bg-destructive/10 px-4 py-3 text-destructive",style:{fontSize:"var(--conv-font-size, 14px)"},children:s.message},i):null}),c&&(0,U.jsx)("div",{className:"mx-auto max-w-[90%] rounded-lg border border-destructive/50 bg-destructive/10 px-4 py-3 text-sm text-destructive",children:c})]}),(0,U.jsx)(c0,{})]}),(0,U.jsxs)("div",{className:"flex-shrink-0 py-3 px-[22px]",children:[z.map(e=>(0,U.jsx)(jE,{delivery:e,showExecutorName:!0,compact:!0,onRetry:()=>$(e),className:"mb-2"},e.processId)),I&&p.waitingFor.length>0&&(0,U.jsxs)("div",{className:"mb-2 flex items-start gap-1.5 text-xs text-muted-foreground","data-testid":"turn-waiting-for",children:[(0,U.jsx)(z2,{className:"mt-0.5 h-3 w-3 shrink-0"}),(0,U.jsxs)("span",{children:["Waiting for ",p.waitingFor.join(", ")]})]}),T.current&&n&&(0,U.jsx)(Ij,{task:T.current,sessionId:n.id},T.current.key),(0,U.jsxs)(Al,{onSubmit:W,className:"w-full",children:[(0,U.jsxs)("div",{className:"@container flex w-full items-center",children:[(0,U.jsx)(z0,{commands:w,open:j,onOpenChange:C,disabled:!o||M,onExecute:e=>{d(e)},onCreate:_,onUpdate:S,onDelete:k,onCloseFocus:()=>N.current?.focus()}),(0,U.jsx)(Ac,{ref:N,disabled:!o||M,placeholder:L?P:F,className:"pr-12",style:{fontSize:"var(--conv-font-size, 14px)"},value:g,onChange:e=>x(e.currentTarget.value),onKeyDown:e=>{"/"!==e.key||""!==g||e.metaKey||e.ctrlKey||e.altKey||e.nativeEvent.isComposing||(e.preventDefault(),C(!0))}})]}),(0,U.jsx)("div",{className:"pointer-events-none absolute bottom-0 right-2 flex items-center text-base md:text-sm",style:{fontSize:"var(--conv-font-size, 14px)",height:"calc(1lh + 1.5rem)"},children:M||I&&!g.trim()?(0,U.jsx)(Ax,{className:"pointer-events-auto",type:"button","aria-label":M?"Stop generating":"Stop",title:M?"Stop generating":"Stop",onClick:u,children:(0,U.jsx)(ce,{className:"size-3.5 fill-current"})}):(0,U.jsx)(Ax,{className:"pointer-events-auto",disabled:!o||!g.trim()})})]})]})]}):(0,U.jsx)("div",{className:"h-full flex items-center justify-center text-muted-foreground",children:(0,U.jsxs)("div",{className:"text-center",children:[(0,U.jsx)("div",{className:"mx-auto w-10 h-10 rounded-xl bg-muted flex items-center justify-center mb-3",children:(0,U.jsx)(rJ,{className:"h-5 w-5 text-muted-foreground/50"})}),(0,U.jsx)("p",{className:"text-sm",children:"Select a project to start chatting"})]})})}),z4=(0,rE.default)("archive-restore",[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h2",key:"tvwodi"}],["path",{d:"M20 8v11a2 2 0 0 1-2 2h-2",key:"1gkqxj"}],["path",{d:"m9 15 3-3 3 3",key:"1pd0qc"}],["path",{d:"M12 12v9",key:"192myk"}]]),z6="grid-cols-[minmax(0,1fr)_88px_176px_44px_56px] @max-3xl:grid-cols-[minmax(0,1fr)_88px_44px_56px] @max-lg:grid-cols-[minmax(0,1fr)_44px_56px]",z7="@max-3xl:hidden",z8="@max-lg:hidden",z9="relative grid items-center gap-x-3 rounded-[7px] px-2";function $e({task:e,onUpdate:r,onDelete:s,onArchive:n,onUnarchive:i,archivedView:a,onClick:o,worktrees:l,assignedBranches:c,onAssign:d,onOpenSourceSession:u,selected:h,flash:f,compact:p,depth:m=0,progress:g}){let x="done"===e.status||"cancelled"===e.status,v=m>0,y=!p&&!v&&(e.description||e.source_session),b=e=>e.stopPropagation();return(0,U.jsxs)("div",{role:"row","data-task-id":e.id,"data-state":h?"selected":void 0,onClick:()=>o?.(e),className:(0,e1.cn)(z9,"group cursor-pointer hover:bg-muted",p?"min-h-[34px] grid-cols-[minmax(0,1fr)_auto]":z6,!p&&(v?"min-h-[34px] py-[3px]":"min-h-[46px] py-1.5"),"data-[state=selected]:bg-accent data-[state=selected]:hover:bg-accent data-[state=selected]:shadow-[inset_0_0_0_1px_color-mix(in_oklab,var(--primary)_14%,transparent)]",f&&"animate-task-row-flash"),children:[(0,U.jsxs)("div",{className:(0,e1.cn)("flex min-w-0 gap-[9px]",p||!y?"items-center":"items-start"),style:v?{paddingLeft:23+(m-1)*20}:void 0,children:[(0,U.jsx)(af,{status:e.status,onChange:s=>r(e.id,{status:s}),children:(0,U.jsx)("button",{type:"button","aria-label":`Status: ${e.status}`,onClick:b,className:(0,e1.cn)("shrink-0 rounded-full outline-none focus-visible:ring-2 focus-visible:ring-ring/50",y&&"mt-[2.5px]"),children:(0,U.jsx)(ac,{status:e.status})})}),(0,U.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,U.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,U.jsx)("span",{className:(0,e1.cn)("min-w-0 truncate text-[13px]",x?"font-[450] text-muted-foreground line-through decoration-border":v?"font-[450] text-secondary-foreground":"font-medium"),children:e.title}),g&&g.total>0&&(0,U.jsx)(ah,{done:g.done,total:g.total}),f&&(0,U.jsx)("span",{className:"shrink-0 rounded px-[5px] font-mono text-[10px] font-medium text-[oklch(0.6_0.14_152)] bg-[oklch(0.94_0.05_152)] dark:bg-[oklch(0.6_0.14_152/0.18)]",children:"new"})]}),y&&(0,U.jsxs)("div",{className:"mt-px flex min-w-0 items-center gap-1.5 text-xs text-muted-foreground",children:[e.description&&(0,U.jsx)("span",{className:"min-w-0 truncate",children:r7(e.description,240)}),e.description&&e.source_session&&(0,U.jsx)("span",{className:"shrink-0 text-border","aria-hidden":!0,children:"·"}),e.source_session&&(0,U.jsx)("span",{className:"flex min-w-0 max-w-[210px] shrink-0 [&_svg]:size-[11px]",onClick:b,children:(0,U.jsx)(rZ,{source:e.source_session,onOpen:u?()=>u(e):void 0})})]})]})]}),p?(0,U.jsxs)("div",{className:"flex items-center gap-2.5 text-muted-foreground/70",children:[null!==e.assigned_branch&&(0,U.jsx)("span",{title:r4(e.assigned_branch),className:"inline-flex",children:(0,U.jsx)(ao,{className:"size-3","aria-label":`Branch ${r4(e.assigned_branch)}`})}),(0,U.jsx)(au,{priority:e.priority})]}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(ap,{priority:e.priority,onChange:s=>r(e.id,{priority:s}),children:(0,U.jsxs)("button",{type:"button",onClick:b,className:(0,e1.cn)("-mx-1.5 flex w-fit items-center gap-[7px] rounded-md px-1.5 py-1 text-xs text-secondary-foreground outline-none hover:bg-background hover:shadow-[inset_0_0_0_1px_var(--border)] data-[state=open]:bg-background data-[state=open]:shadow-[inset_0_0_0_1px_var(--border)]",z8),children:[(0,U.jsx)(au,{priority:e.priority}),r2[e.priority].label]})}),(0,U.jsx)("div",{className:(0,e1.cn)("flex min-w-0",z7),children:(0,U.jsx)(a_,{current:e.assigned_branch,onAssign:r=>d(e.id,r),worktrees:l,assignedBranches:c,children:(0,U.jsx)("button",{type:"button",onClick:b,className:"flex min-w-0 max-w-full rounded-md outline-none focus-visible:ring-2 focus-visible:ring-ring/50",title:null!==e.assigned_branch?void 0:"Assign a branch",children:null!==e.assigned_branch?(0,U.jsx)(aw,{branch:e.assigned_branch,className:"hover:border-border"}):(0,U.jsx)("span",{className:"text-xs text-muted-foreground/70 hover:text-muted-foreground",children:"—"})})})}),(0,U.jsx)("span",{className:"text-right font-mono text-[11px] text-muted-foreground/70",title:new Date(e.created_at).toLocaleString(),children:r9(e.created_at)}),(0,U.jsxs)("div",{className:"flex justify-end gap-0.5 opacity-0 transition-opacity group-hover:opacity-100 focus-within:opacity-100",onClick:b,children:[a?(0,U.jsx)($t,{title:"Unarchive",onClick:()=>i(e.id),children:(0,U.jsx)(z4,{className:"size-[13px]"})}):(0,U.jsx)($t,{title:"Archive",onClick:()=>n(e.id),children:(0,U.jsx)(aH,{className:"size-[13px]"})}),(0,U.jsx)($t,{title:"Delete",onClick:()=>s(e.id),children:(0,U.jsx)(ok,{className:"size-[13px]"})})]})]})]})}function $t({title:e,onClick:r,children:s}){return(0,U.jsx)("button",{type:"button",title:e,"aria-label":e,onClick:r,className:"grid size-[26px] place-items-center rounded-md text-muted-foreground outline-none hover:bg-border/60 hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring/50",children:s})}function $r({pending:e,compact:r}){return(0,U.jsxs)("div",{role:"row","data-pending-task":!0,"aria-busy":!0,className:(0,e1.cn)(z9,"cursor-default",r?"min-h-[34px] grid-cols-[minmax(0,1fr)_auto]":(0,e1.cn)(z6,"min-h-[46px] py-1.5")),children:[(0,U.jsxs)("div",{className:(0,e1.cn)("flex min-w-0 gap-[9px]",r?"items-center":"items-start"),children:[(0,U.jsx)(ac,{status:e.status,pending:!0,className:r?void 0:"mt-[2.5px]"}),(0,U.jsxs)("div",{className:"min-w-0 flex-1",children:[null!==e.title?(0,U.jsx)("span",{className:"block truncate text-[13px] font-medium",children:e.title}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(C$,{className:"my-[5px] h-[9px] w-[46%] max-w-64"}),(0,U.jsx)("span",{className:"sr-only",children:"Generating title…"})]}),!r&&(0,U.jsx)("div",{className:"mt-px truncate text-xs text-muted-foreground",children:r7(e.description,1/0)})]})]}),r?(0,U.jsx)(au,{priority:e.priority,className:"opacity-55"}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)("div",{className:(0,e1.cn)("flex items-center gap-[7px] text-xs text-secondary-foreground opacity-55",z8),children:[(0,U.jsx)(au,{priority:e.priority}),r2[e.priority].label]}),(0,U.jsx)(C$,{className:(0,e1.cn)("h-[9px] w-[90px]",z7)}),(0,U.jsx)(C$,{className:"h-[9px] w-[26px] justify-self-end"}),(0,U.jsx)("span",{})]})]})}function $s({rows:e,allTasks:r,sort:s,onSortChange:n,onUpdate:i,onDelete:a,onArchive:o,onUnarchive:l,archivedView:c,worktrees:d,onAssign:u,onOpenSourceSession:h,panelOpen:f,selectedTaskId:p,onSelect:m,onStep:g,pendingTasks:x,flashTaskId:v,keyboardActive:y,assignedBranches:b}){let w=(0,V.useRef)(null),_=e=>{s?.field!==e?n({field:e,dir:"asc"}):"asc"===s.dir?n({field:e,dir:"desc"}):n(null)},S=(0,V.useMemo)(()=>{let e=new Map;for(let s of r){if(!s.parent_id||null!==s.archived_at||"cancelled"===s.status)continue;let r=e.get(s.parent_id)??{done:0,total:0};r.total+=1,"done"===s.status&&(r.done+=1),e.set(s.parent_id,r)}return e},[r]),k=(0,V.useMemo)(()=>{let r=[];for(let s of e){let e=r[r.length-1];s.depth>0&&e?e.kids.push(s):r.push({root:s,kids:[]})}return r},[e]);(0,V.useEffect)(()=>{if(!f||!y)return;let r=r=>{if(!(r.defaultPrevented||r.metaKey||r.ctrlKey||r.altKey||dz(r.target)||dQ())){if("Escape"===r.key){r.preventDefault(),m(null);return}null===p||"ArrowDown"!==r.key&&"ArrowUp"!==r.key||0!==e.length&&(r.preventDefault(),g("ArrowDown"===r.key?1:-1))}};return window.addEventListener("keydown",r,!0),()=>window.removeEventListener("keydown",r,!0)},[f,p,m,g,e.length,y]);let j=v??p;(0,V.useEffect)(()=>{if(null===j)return;let e=w.current?.querySelectorAll("[data-task-id]")??[];Array.from(e).find(e=>e.dataset.taskId===j)?.scrollIntoView({block:"nearest"})},[j]);let C=({task:e,depth:r})=>(0,U.jsx)($e,{task:e,depth:r,progress:S.get(e.id),onUpdate:i,onDelete:a,onArchive:o,onUnarchive:l,archivedView:c,onClick:e=>m(e.id===p?null:e.id),selected:e.id===p,flash:e.id===v,compact:f,worktrees:d,assignedBranches:b,onAssign:u,onOpenSourceSession:h},e.id);return(0,U.jsxs)("div",{ref:w,role:"grid","aria-label":"Tasks",className:"flex flex-col gap-px px-3 pt-2 pb-4",children:[!f&&(0,U.jsxs)("div",{role:"row",className:(0,e1.cn)("mb-1 grid h-[30px] items-center gap-x-3 border-b border-border/60 px-2 text-[11px] font-medium text-muted-foreground/70",z6),children:[(0,U.jsx)($n,{field:"title",sort:s,onToggle:_,children:"Title"}),(0,U.jsx)($n,{field:"priority",sort:s,onToggle:_,className:z8,children:"Priority"}),(0,U.jsx)("span",{className:z7,children:"Branch"}),(0,U.jsx)($n,{field:"created_at",sort:s,onToggle:_,className:"justify-self-end",children:"Created"}),(0,U.jsx)("span",{})]}),k.map(({root:e,kids:r})=>(0,U.jsxs)("div",{className:"contents",children:[C(e),r.length>0&&(0,U.jsx)("div",{className:"relative flex flex-col gap-px before:absolute before:top-[-2px] before:bottom-3 before:left-[15px] before:w-px before:bg-border",children:r.map(C)})]},e.task.id)),x.map(e=>(0,U.jsx)($r,{pending:e,compact:f},e.key)),0===e.length&&0===x.length&&(0,U.jsxs)("div",{className:"flex flex-col items-center gap-1 py-12 text-center",children:[(0,U.jsx)("p",{className:"text-sm font-medium text-foreground/60",children:"No tasks yet"}),(0,U.jsx)("p",{className:"text-xs text-muted-foreground",children:"Create one to get started."})]})]})}function $n({field:e,sort:r,onToggle:s,className:n,children:i}){let a=r?.field===e,o=a?"asc"===r.dir?R6:c$:gd;return(0,U.jsxs)("button",{type:"button",onClick:()=>s(e),className:(0,e1.cn)("group/sh inline-flex w-fit items-center gap-[3px] outline-none hover:text-muted-foreground",a&&"text-muted-foreground",n),children:[i,(0,U.jsx)(o,{className:(0,e1.cn)("size-2.5",!a&&"opacity-0 group-hover/sh:opacity-100"),"aria-hidden":!0})]})}let $i=(0,rE.default)("message-square-plus",[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}],["path",{d:"M12 8v6",key:"1ib9pf"}],["path",{d:"M9 11h6",key:"1fldmi"}]]);var r0=rQ;let $a=["boxSizing","width","paddingTop","paddingRight","paddingBottom","paddingLeft","borderTopWidth","borderRightWidth","borderBottomWidth","borderLeftWidth","fontFamily","fontSize","fontWeight","lineHeight","letterSpacing","tabSize","wordBreak","overflowWrap"];function $o({value:e,label:r,className:s,onOpenFile:n,children:i}){let[a,o]=(0,V.useState)(!1),l=(0,V.useRef)(null),c=(0,V.useRef)(null),d=(r,s)=>{let n=function(e){for(let r=e.parentElement;r;r=r.parentElement){let{overflowY:e}=getComputedStyle(r);if(("auto"===e||"scroll"===e)&&r.scrollHeight>r.clientHeight)return r}return null}(r);c.current={caret:s?function(e,r,s,n){let i=null,a=0;if(document.caretPositionFromPoint){let e=document.caretPositionFromPoint(r,s);i=e?.offsetNode??null,a=e?.offset??0}else if(document.caretRangeFromPoint){let e=document.caretRangeFromPoint(r,s);i=e?.startContainer??null,a=e?.startOffset??0}if(!i||i.nodeType!==Node.TEXT_NODE||!e.contains(i))return null;let o=0,l=document.createTreeWalker(e,NodeFilter.SHOW_TEXT);for(let e=l.nextNode();e;e=l.nextNode()){let r=e.textContent??"",s=r.trim()?n.indexOf(r,o):-1;if(e===i)return -1===s?null:s+a;-1!==s&&(o=s+r.length)}return null}(r,s.x,s.y,e):null,clientY:s?.y??null,scroller:n,scrollTop:n?.scrollTop??0},o(!0)};return((0,V.useLayoutEffect)(()=>{let e=l.current?.querySelector("textarea"),r=c.current;if(c.current=null,!a||!e)return;let s=r?.caret??e.value.length;e.focus({preventScroll:!0}),e.setSelectionRange(s,s),r?.scroller&&(r.scroller.scrollTop=r.scrollTop,null!==r.caret&&null!==r.clientY&&(r.scroller.scrollTop+=function(e,r){let s=getComputedStyle(e),n=document.createElement("div");for(let e of $a)n.style[e]=s[e];Object.assign(n.style,{position:"absolute",top:"0",left:"-9999px",visibility:"hidden",whiteSpace:"pre-wrap",borderStyle:"solid"}),n.textContent=e.value.slice(0,r);let i=document.createElement("span");i.textContent="​",n.appendChild(i),document.body.appendChild(n);let a=e.getBoundingClientRect().top-e.scrollTop+i.offsetTop+i.offsetHeight/2;return n.remove(),a}(e,s)-r.clientY))},[a]),!a&&e.trim())?(0,U.jsx)("div",{tabIndex:0,"data-markdown-field":r,title:"Click to edit",onClick:e=>{e.target.closest("a, button")||window.getSelection()?.isCollapsed&&d(e.currentTarget,{x:e.clientX,y:e.clientY})},onKeyDown:e=>{"Enter"===e.key&&e.target===e.currentTarget&&(e.preventDefault(),d(e.currentTarget))},className:`cursor-text outline-none ${s??""}`,children:(0,U.jsx)(TQ,{value:n??null,children:(0,U.jsx)(r0.i,{mode:"static",className:av,rehypePlugins:T2,components:T3,children:e})})}):(0,U.jsx)("div",{ref:l,className:"contents",onFocus:()=>o(!0),onBlur:()=>o(!1),children:i})}function $l({task:e,onUpdate:r,onAssign:s,onArchive:n,onUnarchive:i,onDelete:a,onClose:o,worktrees:l,assignedBranches:c,onOpenSourceSession:d,onStartSession:u,onOpenFile:h,tasks:f,onSelectTask:p,onAddSubtask:m,position:g,onStep:x}){let v=null!==e.archived_at,y=(0,V.useMemo)(()=>new Map(f.map(e=>[e.id,e])),[f]),b=(0,V.useMemo)(()=>{let r=[],s=new Set([e.id]),n=e.parent_id?y.get(e.parent_id):void 0;for(;n&&!s.has(n.id);)r.unshift(n),s.add(n.id),n=n.parent_id?y.get(n.parent_id):void 0;return r},[e,y]),w=(0,V.useMemo)(()=>f.filter(r=>r.parent_id===e.id&&null===r.archived_at),[f,e.id]),_=(0,V.useMemo)(()=>(function(e,r){let s=0,n=0;for(let i of r)i.parent_id===e&&null===i.archived_at&&"cancelled"!==i.status&&(n+=1,"done"===i.status&&(s+=1));return{done:s,total:n}})(e.id,f),[f,e.id]),S=(0,V.useMemo)(()=>(function(e,r){let s=new Set([e]),n=!0;for(;n;)for(let e of(n=!1,r))e.parent_id&&s.has(e.parent_id)&&!s.has(e.id)&&(s.add(e.id),n=!0);return s})(e.id,f),[f,e.id]),k=(0,V.useMemo)(()=>{let e=w.filter(e=>"cancelled"!==e.status),r=e.filter(e=>"done"===e.status).length,s=e.filter(e=>"in_progress"===e.status).length;return e.map((e,n)=>n<r?"done":n<r+s?"doing":"todo")},[w]),[j,C]=(0,V.useState)(!1);return(0,U.jsxs)("div",{className:"flex h-full min-w-0 flex-col bg-card",children:[(0,U.jsxs)("div",{className:"flex h-[42px] shrink-0 items-center gap-0.5 border-b border-border/60 pr-2 pl-3",children:[x&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)($t,{title:"Previous (↑)",onClick:()=>x(-1),children:(0,U.jsx)(lr,{className:"size-3.5"})}),(0,U.jsx)($t,{title:"Next (↓)",onClick:()=>x(1),children:(0,U.jsx)(aa,{className:"size-3.5"})})]}),g&&(0,U.jsxs)("span",{className:"mx-1.5 font-mono text-[10.5px] tabular-nums text-muted-foreground/70",children:[g.index+1," / ",g.total]}),(0,U.jsx)("span",{className:"flex-1"}),u&&!v&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)($c,{worktrees:l,onPick:r=>u(e,r)}),(0,U.jsx)("span",{className:"mx-1 h-4 w-px bg-border","aria-hidden":!0})]}),!v&&(0,U.jsx)($t,{title:"Archive",onClick:()=>n(e.id),children:(0,U.jsx)(aH,{className:"size-[13px]"})}),(0,U.jsx)($t,{title:"Delete",onClick:()=>a(e.id),children:(0,U.jsx)(ok,{className:"size-[13px]"})}),(0,U.jsx)("span",{className:"mx-1 h-4 w-px bg-border","aria-hidden":!0}),(0,U.jsx)($t,{title:"Close (Esc)",onClick:o,children:(0,U.jsx)(rD,{className:"size-3.5"})})]}),v&&(0,U.jsxs)("div",{className:"flex shrink-0 items-center gap-2 border-b border-border/60 bg-secondary py-2 pr-3 pl-3.5 text-xs text-muted-foreground",children:[(0,U.jsx)(aH,{className:"size-[13px] shrink-0","aria-hidden":!0}),(0,U.jsxs)("span",{className:"min-w-0 truncate",children:["Archived ",new Date(e.archived_at).toLocaleDateString(void 0,{month:"short",day:"numeric"})," — hidden from the list and the sidebar"]}),(0,U.jsxs)(a$.Button,{variant:"outline",size:"sm",className:"ml-auto h-6 gap-1 px-2 text-[11.5px]",onClick:()=>i(e.id),children:[(0,U.jsx)(z4,{className:"size-3"}),"Unarchive"]})]}),(0,U.jsxs)("div",{className:(0,e1.cn)("flex min-h-0 flex-1 flex-col overflow-auto [&>*]:shrink-0 px-6 pt-[18px] pb-[22px] edge-scrollbar",v&&"opacity-[.78]"),children:[b.length>0&&(0,U.jsx)("nav",{"aria-label":"Parent tasks",className:"mb-1 -ml-[5px] flex min-w-0 flex-wrap items-center gap-px text-[11.5px] text-muted-foreground/70",children:b.map(e=>(0,U.jsxs)("span",{className:"flex min-w-0 items-center gap-px",children:[(0,U.jsx)("button",{type:"button",className:"max-w-[280px] truncate rounded-[5px] px-[5px] py-0.5 text-muted-foreground hover:bg-muted hover:text-foreground",onClick:()=>p(e.id),children:e.title}),(0,U.jsx)(i2,{className:"size-[11px] shrink-0","aria-hidden":!0})]},e.id))}),(0,U.jsx)($f,{value:e.title,onCommit:s=>{let n=s.trim();n&&n!==e.title&&r(e.id,{title:n})},singleLine:!0,"aria-label":"Title",className:"mb-3.5 text-lg leading-[1.32] font-semibold tracking-[-0.02em] hover:bg-muted focus:bg-muted/60"}),(0,U.jsxs)(aS,{status:e.status,priority:e.priority,assignedBranch:e.assigned_branch,onStatusChange:s=>r(e.id,{status:s}),onPriorityChange:s=>r(e.id,{priority:s}),onAssign:r=>s(e.id,r),worktrees:l,assignedBranches:c,readOnlyBranch:v,children:[!(v&&!e.parent_id)&&(0,U.jsx)(ak,{label:"Parent",children:(0,U.jsx)(TJ,{tasks:f,value:e.parent_id??null,onChange:s=>r(e.id,{parent_id:s}),excludeIds:S,field:!0})}),e.source_session&&(0,U.jsx)(ak,{label:"From session",children:e.source_session.exists?(0,U.jsxs)("button",{type:"button",disabled:!d,onClick:()=>d?.(e),title:e.source_session.title?.trim()||"Untitled session",className:"-ml-2 inline-flex h-[30px] min-w-0 max-w-full items-center gap-2 rounded-md px-2 text-primary hover:bg-muted disabled:text-foreground",children:[(0,U.jsx)(rJ,{className:"size-[13px] shrink-0","aria-hidden":!0}),(0,U.jsx)("span",{className:"truncate",children:e.source_session.title?.trim()||"Untitled session"})]}):(0,U.jsx)("span",{className:"inline-flex h-[30px] items-center italic text-muted-foreground",children:"Source session deleted"})})]}),(0,U.jsxs)($d,{title:"Description",className:"flex flex-[1_0_auto] flex-col",hint:!j&&e.description?.trim()?"Click to edit · Markdown":void 0,children:[(0,U.jsx)($o,{value:e.description??"",label:"Description",onOpenFile:h?(r,s)=>h(e.source_session?.branch??null,r,s):void 0,className:`-mx-1.5 flex-1 rounded-md px-1.5 py-1 text-secondary-foreground hover:bg-secondary focus-visible:bg-muted/40 ${ag}`,children:(0,U.jsx)($f,{value:e.description??"",onCommit:s=>{let n=s.trim()?s:null;n!==e.description&&r(e.id,{description:n})},onEditingChange:C,placeholder:"Add a description…","aria-label":"Description",className:`${ax} focus:border focus:border-primary focus:bg-card focus:px-3 focus:py-2.5 focus:font-mono focus:text-xs focus:leading-[1.65] focus:shadow-[0_0_0_3px_var(--accent)]`})}),j&&(0,U.jsxs)("div",{className:"mt-2 flex items-center gap-2.5 text-[11px] text-muted-foreground/70",children:[(0,U.jsx)($h,{keys:["⌘","↵"],children:"save"}),(0,U.jsx)($h,{keys:["Esc"],children:"cancel"}),(0,U.jsx)("span",{className:"flex-1"}),(0,U.jsx)("span",{children:"Saves on blur"})]})]}),(0,U.jsxs)($d,{title:"Sub-tasks","aria-label":"Sub-tasks",compact:!0,hint:v&&0===w.length?"None":void 0,extra:_.total>0&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)("span",{className:"ml-0.5 flex gap-[3px]","aria-hidden":!0,children:k.map((e,r)=>(0,U.jsx)("i",{className:(0,e1.cn)("h-1 w-[18px] rounded-sm","done"===e?"bg-[oklch(0.6_0.14_152)]":"doing"===e?"bg-[oklch(0.58_0.16_245)]":"bg-border")},r))}),(0,U.jsxs)("span",{className:"font-mono text-[10.5px] font-normal tabular-nums text-muted-foreground/70",children:[_.done,"/",_.total]})]}),children:[w.length>0&&(0,U.jsx)("ul",{className:"-mx-2 flex flex-col",children:w.map(e=>{let r="done"===e.status||"cancelled"===e.status;return(0,U.jsx)("li",{children:(0,U.jsxs)("button",{type:"button",className:"flex h-7 w-full min-w-0 items-center gap-[9px] rounded-md px-2 text-left hover:bg-muted",onClick:()=>p(e.id),children:[(0,U.jsx)(ac,{status:e.status}),(0,U.jsx)("span",{className:(0,e1.cn)("min-w-0 flex-1 truncate text-[12.5px] font-[450]",r&&"text-muted-foreground line-through decoration-border"),children:e.title}),(0,U.jsx)(au,{priority:e.priority})]})},e.id)})}),!v&&(0,U.jsxs)("button",{type:"button",className:"-mx-2 flex h-7 w-[calc(100%+1rem)] items-center gap-[9px] rounded-md px-2 text-[12.5px] text-muted-foreground hover:bg-muted hover:text-foreground",onClick:()=>m(e.id),children:[(0,U.jsx)("span",{className:"grid size-3.5 place-items-center rounded-full border-[1.5px] border-dashed border-border text-muted-foreground/70",children:(0,U.jsx)(oS,{className:"size-2",strokeWidth:3})}),"Add sub-task"]})]})]}),(0,U.jsxs)("div",{className:"flex h-9 shrink-0 items-center gap-1.5 border-t border-border/60 bg-secondary px-4 text-[11px] text-muted-foreground",children:[(0,U.jsxs)("span",{title:new Date(e.created_at).toLocaleString(),children:["Created ",function(e,r=new Date){let s=new Date(e),n=s.toLocaleDateString(void 0,{month:"short",day:"numeric",...s.getFullYear()!==r.getFullYear()?{year:"numeric"}:{}}),i=s.toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit",hour12:!1});return`${n}, ${i}`}(e.created_at)]}),(0,U.jsx)("span",{className:"text-border","aria-hidden":!0,children:"·"}),(0,U.jsxs)("span",{title:new Date(e.updated_at).toLocaleString(),children:["Updated ",function(e,r=Date.now()){let s=r9(e,r);return"now"===s?"just now":`${s} ago`}(e.updated_at)]}),(0,U.jsx)("span",{className:"flex-1"}),g&&(0,U.jsx)($h,{keys:["↑","↓"],children:"switch"}),(0,U.jsx)($h,{keys:["Esc"],className:"ml-2",children:"close"})]})]})}function $c({worktrees:e,onPick:r}){return(0,U.jsxs)(i3,{children:[(0,U.jsx)(i4,{asChild:!0,children:(0,U.jsxs)("button",{type:"button",className:"inline-flex h-[26px] items-center gap-1.5 rounded-md px-2 text-[12px] font-medium text-muted-foreground outline-none hover:bg-border/60 hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring/50 data-[state=open]:bg-border/60 data-[state=open]:text-foreground",children:[(0,U.jsx)($i,{className:"size-[13px]","aria-hidden":!0}),"Start session",(0,U.jsx)(aa,{className:"size-3 text-muted-foreground/70","aria-hidden":!0})]})}),(0,U.jsxs)(i6,{align:"end",className:"max-h-72 w-(--radix-dropdown-menu-trigger-width) min-w-0 overflow-y-auto",children:[(0,U.jsx)(at,{className:"text-[11px] font-normal text-muted-foreground",children:"Select workspace"}),(0,U.jsx)(ar,{}),e.map(e=>(0,U.jsxs)(i7,{onClick:()=>r(e.branch),title:e.branch??"main",className:"gap-2 font-mono text-[12px]",children:[(0,U.jsx)(ao,{className:"size-3 shrink-0 text-muted-foreground"}),(0,U.jsx)("span",{className:"min-w-0 truncate",children:e.branch??"main"})]},e.branch??"")),0===e.length&&(0,U.jsx)("div",{className:"px-2 py-1.5 text-xs text-muted-foreground",children:"No workspaces"})]})]})}function $d({title:e,hint:r,extra:s,compact:n,className:i,children:a,...o}){return(0,U.jsxs)("section",{className:(0,e1.cn)("mt-[18px] border-t border-border/60",n?"pt-3":"pt-3.5",i),...o,children:[(0,U.jsxs)("div",{className:(0,e1.cn)("flex h-5 items-center gap-2 text-[11.5px] font-medium text-muted-foreground",n?"mb-1":"mb-2"),children:[e,s,r&&(0,U.jsx)("span",{className:"ml-auto text-[11px] font-normal text-muted-foreground/70",children:r})]}),a]})}function $u({children:e,className:r}){return(0,U.jsx)("kbd",{className:(0,e1.cn)("inline-grid h-[17px] min-w-[17px] place-items-center rounded border border-b-[1.5px] border-border bg-card px-1 font-mono text-[10px] leading-none text-secondary-foreground",r),children:e})}function $h({keys:e,className:r,children:s}){return(0,U.jsxs)("span",{className:(0,e1.cn)("inline-flex items-center gap-1",r),children:[e.map(e=>(0,U.jsx)($u,{children:e},e)),s]})}function $f({value:e,onCommit:r,singleLine:s,onEditingChange:n,className:i,...a}){let[o,l]=(0,V.useState)(null),c=(0,V.useRef)(!1);return(0,U.jsx)("textarea",{rows:1,value:o??e,onFocus:()=>{l(e),n?.(!0)},onChange:e=>l(s?e.target.value.replace(/\n/g," "):e.target.value),onBlur:()=>{null===o||c.current||r(o),c.current=!1,l(null),n?.(!1)},onKeyDown:e=>{if(!e.nativeEvent.isComposing&&229!==e.keyCode){if("Escape"===e.key){e.preventDefault(),c.current=!0,e.currentTarget.blur();return}"Enter"===e.key&&(s||e.metaKey||e.ctrlKey)&&(e.preventDefault(),e.currentTarget.blur())}},className:`${am} ${i??""}`,...a})}var i1=i1,$p="Checkbox",[$m,$g]=es($p),[$x,$v]=$m($p);function $y(e){let{__scopeCheckbox:r,checked:s,children:n,defaultChecked:i,disabled:a,form:o,name:l,onCheckedChange:c,required:d,value:u="on",internal_do_not_use_render:h}=e,[f,p]=ey({prop:s,defaultProp:i??!1,onChange:c,caller:$p}),[m,g]=V.useState(null),[x,v]=V.useState(null),y=V.useRef(!1),b=!m||!!o||!!m.closest("form"),w={checked:f,disabled:a,setChecked:p,control:m,setControl:g,name:l,form:o,value:u,hasConsumerStoppedPropagationRef:y,required:d,defaultChecked:!$N(i)&&i,isFormControl:b,bubbleInput:x,setBubbleInput:v};return(0,U.jsx)($x,{scope:r,...w,children:"function"==typeof h?h(w):n})}var $b="CheckboxTrigger",$w=V.forwardRef(({__scopeCheckbox:e,onKeyDown:r,onClick:s,...n},i)=>{let{control:a,value:o,disabled:l,checked:c,required:d,setControl:u,setChecked:h,hasConsumerStoppedPropagationRef:f,isFormControl:p,bubbleInput:m}=$v($b,e),g=(0,en.useComposedRefs)(i,u),x=V.useRef(c);return V.useEffect(()=>{let e=a?.form;if(e){let r=()=>h(x.current);return e.addEventListener("reset",r),()=>e.removeEventListener("reset",r)}},[a,h]),(0,U.jsx)(em.button,{type:"button",role:"checkbox","aria-checked":$N(c)?"mixed":c,"aria-required":d,"data-state":$E(c),"data-disabled":l?"":void 0,disabled:l,value:o,...n,ref:g,onKeyDown:er(r,e=>{"Enter"===e.key&&e.preventDefault()}),onClick:er(s,e=>{h(e=>!!$N(e)||!e),m&&p&&(f.current=e.isPropagationStopped(),f.current||e.stopPropagation())})})});$w.displayName=$b;var $_=V.forwardRef((e,r)=>{let{__scopeCheckbox:s,name:n,checked:i,defaultChecked:a,required:o,disabled:l,value:c,onCheckedChange:d,form:u,...h}=e;return(0,U.jsx)($y,{__scopeCheckbox:s,checked:i,defaultChecked:a,disabled:l,required:o,onCheckedChange:d,name:n,form:u,value:c,internal_do_not_use_render:({isFormControl:e})=>(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)($w,{...h,ref:r,__scopeCheckbox:s}),e&&(0,U.jsx)($C,{__scopeCheckbox:s})]})})});$_.displayName=$p;var $S="CheckboxIndicator",$k=V.forwardRef((e,r)=>{let{__scopeCheckbox:s,forceMount:n,...i}=e,a=$v($S,s);return(0,U.jsx)(eO,{present:n||$N(a.checked)||!0===a.checked,children:(0,U.jsx)(em.span,{"data-state":$E(a.checked),"data-disabled":a.disabled?"":void 0,...i,ref:r,style:{pointerEvents:"none",...e.style}})})});$k.displayName=$S;var $j="CheckboxBubbleInput",$C=V.forwardRef(({__scopeCheckbox:e,...r},s)=>{let{control:n,hasConsumerStoppedPropagationRef:i,checked:a,defaultChecked:o,required:l,disabled:c,name:d,value:u,form:h,bubbleInput:f,setBubbleInput:p}=$v($j,e),m=(0,en.useComposedRefs)(s,p),g=hH(a),x=np(n);V.useEffect(()=>{if(!f)return;let e=Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype,"checked").set,r=!i.current;if(g!==a&&e){let s=new Event("click",{bubbles:r});f.indeterminate=$N(a),e.call(f,!$N(a)&&a),f.dispatchEvent(s)}},[f,g,a,i]);let v=V.useRef(!$N(a)&&a);return(0,U.jsx)(em.input,{type:"checkbox","aria-hidden":!0,defaultChecked:o??v.current,required:l,disabled:c,name:d,value:u,form:h,...r,tabIndex:-1,ref:m,style:{...r.style,...x,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});function $N(e){return"indeterminate"===e}function $E(e){return $N(e)?"indeterminate":e?"checked":"unchecked"}$C.displayName=$j,e.s(["Checkbox",()=>$_,"CheckboxIndicator",()=>$k,"Indicator",()=>$k,"Root",()=>$_,"createCheckboxScope",()=>$g,"unstable_BubbleInput",()=>$C,"unstable_CheckboxBubbleInput",()=>$C,"unstable_CheckboxProvider",()=>$y,"unstable_CheckboxTrigger",()=>$w,"unstable_Provider",()=>$y,"unstable_Trigger",()=>$w],85402);var $D=e.i(85402),$D=$D;function $T({className:e,...r}){return(0,U.jsx)($D.Root,{"data-slot":"checkbox",className:(0,e1.cn)("peer border-input dark:bg-input/30 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground dark:data-[state=checked]:bg-primary data-[state=checked]:border-primary focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive size-4 shrink-0 rounded-[4px] border shadow-xs transition-shadow outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",e),...r,children:(0,U.jsx)($D.Indicator,{"data-slot":"checkbox-indicator",className:"grid place-content-center text-current transition-none",children:(0,U.jsx)(i1.default,{className:"size-3.5"})})})}let $R={title:"",description:"",status:"todo",priority:"medium",assigned_branch:null,parent_id:null},$A=e=>!e.title.trim()&&!e.description.trim(),$M=e=>e.nativeEvent.isComposing||229===e.keyCode;function $I({draft:e,onChange:r,onCreate:s,onDiscard:n,onClose:i,createMore:a,onCreateMoreChange:o,error:l,focusNonce:c,worktrees:d,assignedBranches:u,tasks:h}){let f=(0,V.useRef)(null),p=(0,V.useRef)(null),m=e.description.trim().length>0;return(0,V.useEffect)(()=>{f.current?.focus()},[c]),(0,U.jsxs)("div",{className:"flex h-full flex-col bg-card",onKeyDown:e=>{"Enter"===e.key&&(e.metaKey||e.ctrlKey)&&!$M(e)&&(e.preventDefault(),m&&s())},children:[(0,U.jsxs)("div",{className:"flex h-[42px] shrink-0 items-center justify-between border-b border-border/60 pr-2 pl-6",children:[(0,U.jsxs)("span",{className:"text-[11px] font-medium uppercase tracking-wide text-muted-foreground",children:["New task ",(0,U.jsx)("span",{className:"normal-case tracking-normal text-muted-foreground/70",children:"· Draft"})]}),(0,U.jsx)($t,{title:"Close (Esc) — keeps the draft",onClick:i,children:(0,U.jsx)(rD,{className:"size-3.5"})})]}),(0,U.jsxs)("div",{className:"flex-1 overflow-auto px-6 pt-[18px] pb-6 edge-scrollbar",children:[(0,U.jsx)("textarea",{ref:f,rows:1,value:e.title,onChange:e=>r({title:e.target.value.replace(/\n/g," ")}),onKeyDown:e=>{"Enter"!==e.key||e.metaKey||e.ctrlKey||$M(e)||(e.preventDefault(),p.current?.focus())},placeholder:"Untitled","aria-label":"Title",className:`${am} text-lg leading-[1.32] font-semibold tracking-[-0.02em]`}),(0,U.jsx)("p",{className:"mt-0.5 mb-3 min-h-4 text-[11px] text-muted-foreground/70",children:!e.title.trim()&&"Leave empty to generate a title from the description."}),(0,U.jsx)(aS,{status:e.status,priority:e.priority,assignedBranch:e.assigned_branch,onStatusChange:e=>r({status:e}),onPriorityChange:e=>r({priority:e}),onAssign:e=>r({assigned_branch:e}),worktrees:d,assignedBranches:u,children:(0,U.jsx)(ak,{label:"Parent",children:(0,U.jsx)(TJ,{tasks:h,value:e.parent_id,onChange:e=>r({parent_id:e}),field:!0})})}),(0,U.jsx)("div",{className:"mt-[18px] border-t border-border/60 pt-3.5",children:(0,U.jsx)("textarea",{ref:p,rows:1,value:e.description,onChange:e=>r({description:e.target.value}),placeholder:"Describe the task…","aria-label":"Description",className:`${am} ${ax}`})})]}),l&&(0,U.jsxs)("div",{role:"alert",className:"mx-6 mb-3 flex shrink-0 items-center gap-2 rounded-md bg-destructive/10 px-3 py-2 text-xs text-destructive",children:[(0,U.jsx)(aR,{className:"size-3.5 shrink-0"}),l]}),(0,U.jsxs)("div",{className:"flex shrink-0 items-center justify-end gap-2 border-t border-border/60 bg-secondary px-6 py-2.5",children:[(0,U.jsxs)("label",{className:"mr-auto flex cursor-pointer items-center gap-2 text-xs text-muted-foreground",children:[(0,U.jsx)($T,{checked:a,onCheckedChange:e=>o(!0===e)}),"Create more"]}),(0,U.jsx)(a$.Button,{variant:"ghost",size:"sm",onClick:n,disabled:$A(e),children:"Discard"}),(0,U.jsxs)(a$.Button,{size:"sm",onClick:s,disabled:!m,children:["Create",(0,U.jsx)("kbd",{className:"ml-1.5 rounded bg-background/15 px-1 font-sans text-[10px]",children:"⌘↵"})]})]})]})}let $P="vibedeckx:tasks:create-more",$F=[{value:"all",label:"All"},{value:"todo",label:"Todo"},{value:"in_progress",label:"Doing"},{value:"done",label:"Done"},{value:"cancelled",label:"Cancelled"},{value:"archived",label:"Archived"}];function $L({active:e=!0,projectId:r,tasks:s,loading:n,worktrees:i,onCreateTask:a,onUpdateTask:o,onDeleteTask:l,onArchiveTask:c,onUnarchiveTask:d,onOpenSourceSession:u,onStartSession:h,onOpenFile:f,openRequest:p,onSelectedTaskChange:m}){let{settings:g}=(0,c1.useConversationSettings)(),[x,v]=(0,V.useState)("all"),[y,b]=(0,V.useState)(null),[w,_]=(0,V.useState)(null),S=w?.projectId===r?w.panel:null,k=S?.kind==="task"?S.taskId:null,j=k?s.find(e=>e.id===k)??null:null,C=S?.kind==="draft",N=(0,V.useCallback)(e=>_(e?{projectId:r,panel:{kind:"task",taskId:e}}:null),[r]),[E,D]=(0,V.useState)(null),T=E?.projectId===r?E.draft:$R,[R,A]=(0,V.useState)(null),[M,I]=(0,V.useState)(0),[P,F]=(0,V.useState)(()=>"1"===window.localStorage.getItem($P)),[L,O]=(0,V.useState)([]),[B,z]=(0,V.useState)(null),$=B?.projectId===r?B.taskId:null,W=(0,V.useRef)(0);(0,V.useEffect)(()=>{if(!B)return;let e=setTimeout(()=>z(null),1600);return()=>clearTimeout(e)},[B]),(0,V.useEffect)(()=>{if(!p)return;if("draft"===p.kind){_({projectId:r,panel:{kind:"draft"}}),I(e=>e+1);return}_({projectId:r,panel:{kind:"task",taskId:p.taskId}});let{status:e}=p;v(r=>"all"===r||r===e?r:"all")},[p]);let H=j?.id??null;(0,V.useEffect)(()=>{m?.(H)},[H,m]);let q=async()=>{let e=T.description.trim();if(!e)return;let s=`pending-${++W.current}`,n=T.title.trim()||null;O(i=>[...i,{key:s,projectId:r,title:n,description:e,status:T.status,priority:T.priority}]),A(null),D(P&&T.parent_id?{projectId:r,draft:{...$R,parent_id:T.parent_id}}:null),P?I(e=>e+1):_(null);let i=await a({title:n??void 0,description:e,status:T.status,priority:T.priority,assigned_branch:T.assigned_branch,parent_id:T.parent_id});(O(e=>e.filter(e=>e.key!==s)),i)?z({projectId:r,taskId:i.id}):(D(e=>e&&e.projectId===r&&!$A(e.draft)?e:{projectId:r,draft:T}),_(e=>e??{projectId:r,panel:{kind:"draft"}}),A("Couldn't create the task. Your draft is restored, try again."))},K=(e,r)=>{o(e,{assigned_branch:r})},X=(0,V.useMemo)(()=>s.filter(e=>null===e.archived_at),[s]),Y=(0,V.useMemo)(()=>s.filter(e=>null!==e.archived_at),[s]),G=(0,V.useMemo)(()=>{let e={all:X.length,todo:0,in_progress:0,done:0,cancelled:0,archived:Y.length};for(let r of X)e[r.status]++;return e},[X,Y]),J=(0,V.useMemo)(()=>"archived"===x?Y:"all"===x?X:X.filter(e=>e.status===x),[X,Y,x]),Z="archived"===x,Q=(0,V.useMemo)(()=>(function(e){let r=new Set(e.map(e=>e.id)),s=new Map,n=[];for(let i of e)if(i.parent_id&&i.parent_id!==i.id&&r.has(i.parent_id)){let e=s.get(i.parent_id)??[];e.push(i),s.set(i.parent_id,e)}else n.push(i);let i=[],a=new Set,o=(e,r)=>{if(!a.has(e.id))for(let n of(a.add(e.id),i.push({task:e,depth:r}),s.get(e.id)??[]))o(n,r+1)};for(let e of n)o(e,0);for(let r of e)o(r,0);return i})(function(e,r){if(!r)return e;let s="asc"===r.dir?1:-1;return[...e].sort((e,n)=>{switch(r.field){case"title":return s*e.title.localeCompare(n.title);case"priority":return s*(r8[e.priority]-r8[n.priority]);case"created_at":return s*(new Date(e.created_at).getTime()-new Date(n.created_at).getTime())}})}(J,y)),[J,y]),ee=j?Q.findIndex(e=>e.task.id===j.id):-1,et=(0,V.useCallback)(e=>{if(0===Q.length)return;let r=-1===ee?0:Math.min(Math.max(ee+e,0),Q.length-1);N(Q[r].task.id)},[Q,ee,N]),er=(0,V.useMemo)(()=>L.filter(e=>e.projectId===r&&("all"===x||x===e.status)),[L,r,x]),es=(0,V.useMemo)(()=>C?{kind:"draft",draft:T}:j?{kind:"task",task:j}:null,[C,T,j]),[en,ei]=(0,V.useState)(null);es&&es!==en?ei(es):!es&&en&&("function"!=typeof window.matchMedia||window.matchMedia("(prefers-reduced-motion: reduce)").matches)&&ei(null);let ea=!es&&null!==en,eo=es??en;(0,V.useEffect)(()=>{if(!ea)return;let e=setTimeout(()=>ei(null),400);return()=>clearTimeout(e)},[ea]);let el=(0,V.useMemo)(()=>new Set(s.filter(e=>null!==e.assigned_branch).map(e=>e.assigned_branch)),[s]);return r?(0,U.jsxs)("div",{className:"flex flex-col h-full",children:[(0,U.jsx)(d8,{title:"Tasks",count:X.length,actions:(0,U.jsxs)(a$.Button,{size:"sm",onClick:()=>{_({projectId:r,panel:{kind:"draft"}}),I(e=>e+1)},className:"shadow-sm",children:[(0,U.jsx)(oS,{className:"h-3.5 w-3.5 mr-1.5"}),"New Task"]})}),(0,U.jsx)(d9,{children:$F.map(e=>(0,U.jsx)(ue,{active:x===e.value,count:G[e.value],onClick:()=>v(e.value),children:e.label},e.value))}),(0,U.jsx)("div",{className:"flex-1 min-h-0",children:(0,U.jsxs)(hu,{direction:"horizontal",autoSaveId:"task-detail-panels",children:[(0,U.jsx)(uf,{id:"task-list",order:1,minSize:30,children:(0,U.jsx)("div",{className:"@container h-full overflow-y-auto overflow-x-hidden edge-scrollbar",children:n?(0,U.jsx)("div",{className:"flex items-center justify-center py-12 text-muted-foreground text-sm",children:"Loading tasks..."}):(0,U.jsx)($s,{rows:Q,allTasks:s,sort:y,onSortChange:b,onStep:et,onUpdate:o,onDelete:l,onArchive:c,onUnarchive:d,archivedView:Z,worktrees:i,onAssign:K,onOpenSourceSession:u,panelOpen:null!==j||C,selectedTaskId:j?.id??null,keyboardActive:e,onSelect:N,pendingTasks:er,flashTaskId:$,assignedBranches:el})})}),eo&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(hh,{}),(0,U.jsx)(uf,{id:"task-detail",order:2,defaultSize:40,minSize:25,className:ea?"motion-safe:animate-side-panel-out":"motion-safe:animate-side-panel-in",onAnimationEnd:e=>{e.target===e.currentTarget&&ea&&ei(null)},children:(0,U.jsx)("div",{className:"h-full",inert:ea,style:{"--task-body-font-size":`${g.tasksFontSize}px`},children:"draft"===eo.kind?(0,U.jsx)($I,{draft:eo.draft,onChange:e=>D({projectId:r,draft:{...T,...e}}),onCreate:q,onDiscard:()=>{D(null),A(null),_(null)},onClose:()=>N(null),createMore:P,onCreateMoreChange:e=>{F(e),window.localStorage.setItem($P,e?"1":"0")},error:R,focusNonce:M,worktrees:i,assignedBranches:el,tasks:s}):(0,U.jsx)($l,{task:eo.task,onUpdate:o,onAssign:K,onArchive:c,onUnarchive:d,onDelete:l,onClose:()=>N(null),worktrees:i,assignedBranches:el,onOpenSourceSession:u,onStartSession:h,onOpenFile:f,tasks:s,onSelectTask:N,onAddSubtask:e=>{D({projectId:r,draft:{...T,parent_id:e}}),A(null),_({projectId:r,panel:{kind:"draft"}}),I(e=>e+1)},position:-1===ee||eo.task.id!==j?.id?null:{index:ee,total:Q.length},onStep:et},eo.task.id)})})]})]})})]}):(0,U.jsx)("div",{className:"flex items-center justify-center h-full text-muted-foreground",children:(0,U.jsxs)("div",{className:"text-center",children:[(0,U.jsx)("div",{className:"mx-auto w-10 h-10 rounded-xl bg-muted flex items-center justify-center mb-3",children:(0,U.jsx)(oS,{className:"h-5 w-5 text-muted-foreground/50"})}),(0,U.jsx)("p",{className:"text-sm",children:"Select a project to view tasks."})]})})}var $O=e.i(115796);let $B=[5e3,1e4,2e4,4e4];function $z({open:e,onOpenChange:r,onNavigateProject:s,onNavigateWorkspace:n,onNavigateSession:i}){let[a,o]=(0,V.useState)(""),[l,c]=(0,V.useState)(null),[d,u]=(0,V.useState)(!1),h=(0,V.useRef)(null),f=(0,V.useRef)(null),p=(0,V.useRef)("");(0,V.useLayoutEffect)(()=>{p.current=a},[a]),(0,aF.useGlobalEventStream)(e=>{if("session:title"!==e.type||"string"!=typeof e.sessionId)return;let r="string"==typeof e.title?e.title.trim():"";(0,$O.updateCachedSessionTitle)(e.sessionId,r||null)});let[m,g]=(0,V.useState)(e);e!==m&&(g(e),e&&(o(""),c((0,$O.getCachedEmptyResults)()),u(!1)));let x=(0,V.useCallback)(async e=>{h.current?.abort();let r=new AbortController;h.current=r;let s=""===e?(0,$O.beginEmptyQuerySearch)():null;for(let n=0;;n++){let i=Date.now();try{let i=await (0,aC.searchAll)(e,{signal:AbortSignal.any([r.signal,AbortSignal.timeout($B[n])])});r.signal.aborted||(null!==s&&(0,$O.commitEmptyQueryResults)(s,i),c(i),u(!1));return}catch{if(r.signal.aborted)return;if(n===$B.length-1)return void u(!0);let e=1e3*2**n-(Date.now()-i);if(e>0&&await function(e,r){return new Promise(s=>{let n=setTimeout(s,e);r.addEventListener("abort",()=>{clearTimeout(n),s()},{once:!0})})}(e,r.signal),r.signal.aborted)return}}},[]),v=(0,V.useRef)(!1);(0,V.useEffect)(()=>{let r=e&&!v.current;if(v.current=e,e)return f.current&&clearTimeout(f.current),f.current=setTimeout(()=>void x(a),150*!r),()=>{f.current&&clearTimeout(f.current)}},[a,e,x]),(0,V.useEffect)(()=>{if(!e)return;let r=!1;return(0,aC.refreshSearchCache)().then(()=>{r||x(p.current)}).catch(()=>{}),()=>{r=!0,h.current?.abort()}},[e,x]);let y=l?a.trim()?{sessions:l.sessions,favorites:l.favorites}:(0,$O.overlayRecents)(l):null,b=null===l,w=!!y&&0===l.projects.length&&0===l.workspaces.length&&0===y.sessions.length&&0===y.favorites.length,_=l?.cacheState==="cold",S=e=>(0,U.jsxs)(pK,{value:`session-${e.sessionId}`,onSelect:()=>i(e),children:[(0,U.jsx)(rJ,{}),(0,U.jsx)("span",{className:"truncate",children:e.title??"Untitled session"}),e.favoritedAt&&(0,U.jsx)(om,{className:"h-3.5 w-3.5 shrink-0 fill-current text-amber-500"}),(0,U.jsxs)("span",{className:"ml-auto shrink-0 text-xs text-muted-foreground",children:[e.projectName," · ",e.branch??"main"," · ",function(e){if(!e)return"";let r=Date.now()-e;return r<6e4?"just now":r<36e5?`${Math.floor(r/6e4)}m ago`:r<864e5?`${Math.floor(r/36e5)}h ago`:`${Math.floor(r/864e5)}d ago`}(e.lastActiveAt)]})]},e.sessionId);return(0,U.jsxs)(pW,{open:e,onOpenChange:r,title:"Quick Switcher",description:"Search projects, workspaces, and sessions",shouldFilter:!1,instantClose:!0,className:"top-[max(1rem,calc(50%_-_175px))] translate-y-0",children:[(0,U.jsx)(pH,{placeholder:"Search projects, workspaces, sessions…",value:a,onValueChange:o}),(0,U.jsxs)(pU,{children:[d&&(0,U.jsxs)("div",{className:"flex items-center justify-between gap-2 px-4 py-3 text-sm text-destructive",children:[(0,U.jsx)("span",{children:"Search failed."}),(0,U.jsx)(a$.Button,{variant:"link",size:"sm",className:"h-auto p-0 text-destructive",onClick:()=>void x(p.current),children:"Retry"})]}),!d&&b&&(0,U.jsxs)("div",{className:"flex items-center justify-center gap-2 py-6 text-sm text-muted-foreground",children:[(0,U.jsx)(aP,{className:"h-4 w-4 animate-spin"}),"Searching…"]}),!d&&!b&&w&&_&&(0,U.jsxs)("div",{className:"flex items-center justify-center gap-2 py-6 text-sm text-muted-foreground",children:[(0,U.jsx)(aP,{className:"h-4 w-4 animate-spin"}),"Syncing history…"]}),!d&&!b&&w&&!_&&(0,U.jsx)(pV,{children:"No results found."}),l&&l.projects.length>0&&(0,U.jsx)(pq,{heading:"Projects",children:l.projects.map(e=>(0,U.jsxs)(pK,{value:`project-${e.id}`,onSelect:()=>s(e.id),children:[(0,U.jsx)(dN,{name:e.name,size:"md"}),(0,U.jsx)("span",{children:e.name}),e.path&&(0,U.jsx)("span",{className:"truncate text-xs text-muted-foreground",children:e.path})]},e.id))}),l&&l.workspaces.length>0&&(0,U.jsx)(pq,{heading:"Workspaces",children:l.workspaces.map(e=>(0,U.jsxs)(pK,{value:`ws-${e.projectId}-${e.branch??""}`,onSelect:()=>n(e),children:[(0,U.jsx)(ao,{}),(0,U.jsx)("span",{children:e.branch??"main"}),(0,U.jsx)("span",{className:"text-xs text-muted-foreground",children:e.projectName})]},`${e.projectId}-${e.branch??""}`))}),y&&y.sessions.length>0&&(0,U.jsx)(pq,{heading:a.trim()?"Sessions":"Recent",children:y.sessions.map(S)}),y&&y.favorites.length>0&&(0,U.jsx)(pq,{heading:"Favorites",children:y.favorites.map(S)})]})]})}let $$={session_result_ready:"/sounds/sound1.mp3",review_ready:"/sounds/sound2.mp3",session_failed:"/sounds/failure.mp3",workflow_failed:"/sounds/failure.mp3",loop_done:"/sounds/sound1.mp3",commander_stalled:"/sounds/sound2.mp3",cross_remote_token_expired:"/sounds/sound2.mp3"},$W=[2e3,5e3,15e3];function $H(e,r){let s=[...e.filter(e=>e.id!==r.id),r];return s.sort((e,r)=>r.created_at-e.created_at||(e.id<r.id?1:-1)),s}let $U=new Set(["session_result_ready","session_failed"]);function $V(e){return $U.has(e.kind)&&e.session_id?`${e.kind}:${e.session_id}`:e.id}function $q(e){let r=new Map;for(let s of e){let e=null===s.read_at,n=r.get($V(s));n?(n.ids.push(s.id),n.count+=1,e&&(n.unreadCount+=1,n.unread=!0)):r.set($V(s),{latest:s,ids:[s.id],count:1,unreadCount:+!!e,unread:e})}return[...r.values()]}let $K=new Map,$X=new Set,$Y=new Set(["session_result_ready","session_failed"]);function $G(e,r){return $Y.has(e.kind)?null!==r.turnEndAt&&r.turnEndAt>=e.created_at:null!==r.resultAt&&r.resultAt>=e.created_at}function $J(e){let r=$K.get(e);r||((r=new Audio(e)).preload="auto",$K.set(e,r)),r.currentTime=0,r.play().catch(()=>{})}let $Z=(0,rE.default)("bell",[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0",key:"vwvbt9"}],["path",{d:"M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326",key:"11g9vi"}]]);async function $Q(e,r){let s=e.session_id;if("commander_stalled"===e.kind&&(s=null),e.workflow_run_id&&("workflow_failed"===e.kind||"loop_done"===e.kind)){let r=await aC.api.getWorkflowRun(e.workflow_run_id).catch(()=>null);r?.kind==="repeat"&&(s=r.source_session_id)}r(e.project_id,e.branch,s)}let $0={session_result_ready:{label:"Session result is ready",dot:"bg-lime-400"},review_ready:{label:"Review feedback is ready",dot:"bg-emerald-500"},session_failed:{label:"Session failed",dot:"bg-destructive"},workflow_failed:{label:"Workflow needs attention",dot:"bg-destructive"},loop_done:{label:"Loop finished — nothing left to process",dot:"bg-emerald-500"},commander_stalled:{label:"Commander stalled — the task needs you to continue it",dot:"bg-amber-500"},cross_remote_token_expired:{label:"Cross-remote expired — stop & send a message to renew",dot:"bg-amber-500"}};function $1({notifications:e,unreadCount:r,projects:s,onNavigate:n,markRead:i,markAllRead:a,remove:o,clear:l}){let[c,d]=(0,V.useState)(!1);return(0,V.useEffect)(()=>{let e=e=>{"j"===e.key&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),d(e=>!e))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[]),(0,U.jsxs)(i3,{open:c,onOpenChange:d,children:[(0,U.jsx)(i4,{asChild:!0,children:(0,U.jsxs)(a$.Button,{variant:"ghost",size:"icon-sm",className:"relative",title:"Notifications (⌘J)","aria-label":r>0?`${r} unread notifications`:"Notifications",children:[(0,U.jsx)($Z,{className:"h-4 w-4"}),r>0&&(0,U.jsx)("span",{className:"absolute -top-0.5 -right-0.5 flex h-4 min-w-4 items-center justify-center rounded-full bg-primary px-1 text-[9px] font-semibold leading-none text-primary-foreground",children:r>9?"9+":r})]})}),(0,U.jsxs)(i6,{align:"end",className:"w-80 p-0",children:[(0,U.jsxs)("div",{className:"flex items-center justify-between px-3 py-2",children:[(0,U.jsx)("span",{className:"text-[12.5px] font-semibold text-foreground",children:"Notifications"}),e.length>0&&(0,U.jsxs)("div",{className:"flex items-center gap-1",children:[(0,U.jsxs)("button",{onClick:a,disabled:0===r,className:"flex items-center gap-1 rounded px-1.5 py-0.5 text-[11px] text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:pointer-events-none disabled:opacity-40",title:"Mark all read",children:[(0,U.jsx)(dE,{className:"h-3 w-3"}),"Mark all read"]}),(0,U.jsx)("button",{onClick:l,className:"rounded px-1.5 py-0.5 text-[11px] text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",title:"Dismiss all (marks them read)",children:"Clear"})]})]}),(0,U.jsx)("div",{className:"max-h-[60vh] overflow-y-auto border-t border-border",children:0===e.length?(0,U.jsx)("div",{className:"px-3 py-8 text-center text-[12px] text-muted-foreground/70",children:"Nothing needs your attention."}):$q(e).map(e=>{let r,a=e.latest,l=$0[a.kind],c=e.unread;return(0,U.jsxs)(i7,{onSelect:()=>{for(let r of e.ids)i(r);$Q(a,n)},className:(0,e1.cn)("group flex flex-col items-start gap-0.5 rounded-none px-3 py-2",c?"bg-primary/[0.08] shadow-[inset_3px_0_0_0_var(--primary)] focus:bg-primary/[0.14] dark:bg-primary/[0.16] dark:focus:bg-primary/[0.26]":"focus:bg-foreground/[0.06] dark:focus:bg-foreground/[0.11]"),children:[(0,U.jsxs)("div",{className:"flex w-full items-center gap-2",children:[(0,U.jsx)("span",{className:(0,e1.cn)("h-[7px] w-[7px] shrink-0 rounded-full",l?.dot)}),(0,U.jsx)("span",{className:(0,e1.cn)("min-w-0 flex-1 truncate text-[12.5px]",c?"font-medium text-foreground":"text-foreground/70"),children:a.body??(r=a.project_id,s.find(e=>e.id===r)?.name??"Unknown project")}),e.unreadCount>1&&(0,U.jsxs)("span",{className:"shrink-0 rounded-full bg-muted px-1.5 text-[10px] font-medium leading-4 text-muted-foreground",title:`${e.unreadCount} new notifications, showing the latest`,children:["×",e.unreadCount]}),(0,U.jsx)("span",{className:"shrink-0 text-[10.5px] text-muted-foreground/70",children:function(e){let r=Math.max(0,Math.round((Date.now()-e)/1e3));if(r<60)return"just now";let s=Math.round(r/60);if(s<60)return`${s}m ago`;let n=Math.round(s/60);if(n<24)return`${n}h ago`;let i=Math.round(n/24);return`${i}d ago`}(a.created_at)}),(0,U.jsx)("button",{onClick:r=>{for(let s of(r.stopPropagation(),e.ids))o(s)},className:"shrink-0 rounded p-0.5 text-muted-foreground/60 opacity-0 transition-all hover:bg-muted hover:text-foreground group-hover:opacity-100",title:"Dismiss (marks it read)",children:(0,U.jsx)(rD,{className:"h-3 w-3"})})]}),(0,U.jsxs)("div",{className:"flex w-full items-center gap-1.5 pl-[15px] text-[11px] text-muted-foreground",children:[(0,U.jsx)("span",{className:"font-mono truncate",children:a.branch??"main"}),(0,U.jsx)("span",{className:"text-muted-foreground/50",children:"·"}),(0,U.jsx)("span",{className:"shrink-0",children:l?.label??a.title})]})]},a.id)})})]})]})}let $2=(0,rE.default)("keyboard",[["path",{d:"M10 8h.01",key:"1r9ogq"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M14 8h.01",key:"1primd"}],["path",{d:"M16 12h.01",key:"1l6xoz"}],["path",{d:"M18 8h.01",key:"emo2bl"}],["path",{d:"M6 8h.01",key:"x9i8wu"}],["path",{d:"M7 16h10",key:"wp8him"}],["path",{d:"M8 12h.01",key:"czm47f"}],["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}]]),$5=(e,r)=>e?`⌘${r}`:`Ctrl+${r}`,$3=()=>()=>{};function $4(){let[e,r]=(0,V.useState)(!1),s=(0,V.useSyncExternalStore)($3,X,()=>!1);return(0,V.useEffect)(()=>{let e=e=>{let s="/"===e.key&&(e.metaKey||e.ctrlKey)&&!e.shiftKey&&!e.altKey,n="?"===e.key&&!e.metaKey&&!e.ctrlKey&&!e.altKey&&!dz(e.target);(s||n)&&(e.preventDefault(),r(e=>!e))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[]),(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(a$.Button,{variant:"ghost",size:"icon-sm","aria-label":"Keyboard shortcuts",title:"Keyboard shortcuts (?)",onClick:()=>r(!0),children:(0,U.jsx)($2,{className:"h-4 w-4"})}),(0,U.jsx)(rT,{open:e,onOpenChange:r,children:(0,U.jsxs)(rP,{className:"sm:max-w-xl",children:[(0,U.jsx)(rF,{children:(0,U.jsx)(rO,{children:"Keyboard shortcuts"})}),(0,U.jsx)("div",{className:"grid gap-x-8 gap-y-5 sm:grid-cols-2",children:[{title:"Global",entries:[{hints:[$5(s,"K")],description:"Quick switcher"},{hints:[$5(s,"J")],description:"Notifications"},{hints:[$5(s,"B")],description:"Toggle sidebar"},{hints:[s?`⌘⇧O`:"Ctrl+Shift+O"],description:"New agent conversation"},{hints:[et(s,J)],description:"Show / hide Main Chat"},{hints:[et(s,Y)],description:"Start review of this session"},{hints:[et(s,G)],description:"Read aloud the lowest reply on screen (again to stop)"},{hints:["a…z"],description:"Locate workspace (type, ↑↓ cycle, ↵ jump)"},{hints:["Esc"],description:"Clear locate query / unfocus right panel"},{hints:["?",$5(s,"/")],description:"This dialog"}]},{title:"Workspace tabs",entries:[...q.map(e=>({hints:[et(s,e.code)],description:`Open ${e.label}`})),{hints:["←","→"],description:"Switch executor target (Executors focused)"}]}].map(e=>(0,U.jsxs)("section",{children:[(0,U.jsx)("h3",{className:"mb-2 text-[11px] font-semibold uppercase tracking-wider text-muted-foreground",children:e.title}),(0,U.jsx)("ul",{className:"space-y-1.5",children:e.entries.map(e=>(0,U.jsxs)("li",{className:"flex items-center justify-between gap-3 text-[13px]",children:[(0,U.jsx)("span",{className:"text-foreground/90",children:e.description}),(0,U.jsx)("span",{className:"flex shrink-0 items-center gap-1",children:e.hints.map(e=>(0,U.jsx)("kbd",{className:"rounded-md border border-border bg-muted px-1.5 py-0.5 font-mono text-[11px] leading-none text-foreground/80",children:e},e))})]},e.description))})]},e.title))})]})})]})}function $6(e){if(null===e)return"never";let r=Math.max(0,Math.round((Date.now()-e)/1e3));if(r<60)return`${r}s ago`;let s=Math.floor(r/60);return s<60?`${s}m ago`:`${Math.floor(s/60)}h ago`}function $7(){let{state:e,lastEventAt:r,updateAvailable:s,reconnect:n}=(0,aF.useConnectionStatus)(),[,i]=(0,V.useState)(0);if((0,V.useEffect)(()=>{let e=setInterval(()=>i(e=>e+1),5e3);return()=>clearInterval(e)},[]),"stale"===e)return(0,U.jsxs)("button",{type:"button",onClick:n,title:`Disconnected \xb7 last update ${$6(r)} \xb7 click to reconnect`,className:"flex items-center gap-1.5 rounded-full border border-amber-500/40 bg-amber-500/10 px-2 py-0.5 text-[11px] font-medium text-amber-600 transition-colors hover:bg-amber-500/20",children:[(0,U.jsx)("span",{className:"h-1.5 w-1.5 rounded-full bg-amber-500"}),"Disconnected"]});if(s)return(0,U.jsxs)("button",{type:"button",onClick:()=>window.location.reload(),title:"A new version is available · click to reload",className:"flex items-center gap-1.5 rounded-full border border-sky-500/40 bg-sky-500/10 px-2 py-0.5 text-[11px] font-medium text-sky-600 transition-colors hover:bg-sky-500/20",children:[(0,U.jsx)("span",{className:"h-1.5 w-1.5 rounded-full bg-sky-500"}),"Update available"]});let a="live"===e;return(0,U.jsx)("span",{title:a?`Connected \xb7 last update ${$6(r)}`:"Connecting…",className:"flex items-center px-1","aria-label":a?"Connected":"Connecting",children:(0,U.jsx)("span",{className:a?"h-1.5 w-1.5 rounded-full bg-emerald-500":"h-1.5 w-1.5 animate-pulse rounded-full bg-muted-foreground/40"})})}var $8=e.i(63833);function $9(e){return null===e?"":e}function We(e,r){let s=e?.machines?.find(e=>e.serverId===r);return e?.branch&&s?.state==="absent"?{kind:"absent",missing:{branch:e.branch,current:s,presentOn:e.machines.filter(e=>"present"===e.state)}}:s?.state==="creating"?{kind:"creating",machineName:s.name}:{kind:"present"}}let Wt=()=>()=>{};function Wr(){var e,r,s,n,i,a,o,l,c;let d,u,h,f,p,m,g,x,v,y,b,w,_,S,k,j,C,{projectId:N,tab:E,branch:D,threadId:T}=function(){let[e,r]=(0,V.useState)(()=>((0,$8.restoreLastLocation)(),A3()));return(0,V.useEffect)(()=>{let e=()=>r(A3());return window.addEventListener("popstate",e),()=>window.removeEventListener("popstate",e)},[]),e}(),{config:R}=(0,ow.useAppConfig)(),[A,M]=(0,V.useState)(()=>({branch:D,sessionId:new URLSearchParams(window.location.search).get("session")})),I=A.branch,P=A.sessionId,F=(0,V.useCallback)(e=>{M({branch:e,sessionId:null}),es(null)},[]),L=(0,V.useCallback)(e=>{M(r=>r.sessionId===e?r:{...r,sessionId:e})},[]),[O,B]=(0,V.useState)(null),[z,$]=(0,V.useState)(null),[W,H]=(0,V.useState)(null),[q,K]=(0,V.useState)(void 0),[Y,G]=(0,V.useState)(void 0),[Z,Q]=(0,V.useState)(null),[er,es]=(0,V.useState)(null);(0,V.useEffect)(()=>{let e=()=>{let e=new URLSearchParams(window.location.search).get("session");M(r=>r.sessionId===e?r:{...r,sessionId:e})};return window.addEventListener("popstate",e),()=>window.removeEventListener("popstate",e)},[]),(0,V.useEffect)(()=>{if(new URLSearchParams(window.location.search).has("project")){let e=A4({projectId:N,tab:E,branch:D,threadId:T});window.history.replaceState(null,"",e)}},[]);let[en,ei]=(0,V.useState)(!1),[ea,eo]=(0,V.useState)(!1),[el,ec]=(0,V.useState)(!1),[ed,eu]=(0,V.useState)(null),[eh,ef]=(0,V.useState)(E),[ep,em]=(0,V.useState)(T),[eg,ex]=(0,V.useState)(0),[ev,ey]=(0,V.useState)(0),[eb,ew]=(0,V.useState)(!1),[e_,eS]=(0,V.useState)(!1),ek=(0,V.useRef)(null),[ej,eC]=(0,V.useState)(void 0),[eN,eE]=(0,V.useTransition)(),{projects:eD,currentProject:eT,loading:eR,addProject:eA,createProject:eM,updateProject:eI,deleteProject:eP,selectProject:eF,routeProjectPending:eL,routeProjectNotFound:eO}=function(e){let[r,s]=(0,V.useState)([]),[n,i]=(0,V.useState)(null),[a,o]=(0,V.useState)(!0),[l,c]=(0,V.useState)(e),d=(0,V.useRef)(n),u=(0,V.useRef)(e);d.current=n,u.current=e;let h=l!==e,f=a||h,p=!f&&!!e&&!r.some(r=>r.id===e),m=(0,V.useCallback)(async()=>{o(!0);try{let e=await aC.api.getProjects();if(s(e),e.length>0&&!d.current){let r=u.current?e.find(e=>e.id===u.current):e[0];i(r??null)}}finally{o(!1)}},[]);(0,V.useEffect)(()=>{m()},[m]),(0,V.useEffect)(()=>{h&&!a&&(c(e),i(e?r.find(r=>r.id===e)??null:r[0]??null))},[e,a,r,h]);let g=async e=>{let r=await aC.api.createProject(e);return s(e=>[r,...e]),i(r),r},x=(0,V.useCallback)((e,r)=>{let n=e=>"function"==typeof r?r(e):r;s(r=>r.map(r=>r.id===e?n(r):r)),i(r=>r?.id===e?n(r):r)},[]),v=(0,V.useRef)(new Map),y=async(e,s)=>{let n,i={};if(void 0!==s.agentMode&&(i.agent_mode=s.agentMode),void 0!==s.executorMode&&(i.executor_mode=s.executorMode),Object.keys(i).length>0){let s=r.find(r=>r.id===e)??d.current;(n=v.current.get(e))||!s||s.id!==e||(n={seq:0,baseline:s},v.current.set(e,n)),n&&(n.seq+=1),x(e,e=>({...e,...i}))}let a=n?.seq,o=()=>!n||n.seq===a;try{let r=await aC.api.updateProject(e,s);return o()&&(n&&v.current.delete(e),x(e,r)),r}catch(r){throw n&&o()&&(v.current.delete(e),x(e,n.baseline)),r}},b=async e=>{await aC.api.deleteProject(e),s(r=>r.filter(r=>r.id!==e)),n?.id===e&&i(r.find(r=>r.id!==e)??null)};return{projects:r,currentProject:h?null:n,routeProjectPending:f,routeProjectNotFound:p,loading:a,addProject:e=>{s(r=>[e,...r]),i(e)},createProject:g,updateProject:y,deleteProject:b,selectProject:e=>{i(e)},refresh:m}}(N),eB=(0,V.useRef)(void 0);if(eT?.id!==ej){if(void 0!==ej){let s=(e=eB.current,r=eT?.id,e&&!e.checkPlacement&&void 0!==r&&e.projectId===r?{branch:e.branch,sessionId:e.sessionId}:{branch:null,sessionId:null});M(s),s.sessionId&&ex(e=>e+1)}eC(eT?.id)}let{worktrees:ez,loading:e$,stale:eW,listWarning:eH,refetch:eU}=function(e,r,s){let n=e?`${e}::${s??"local"}`:null,[i,a]=(0,V.useState)([]),[o,l]=(0,V.useState)(dh),[c,d]=(0,V.useState)(!0),[u,h]=(0,V.useState)(null),[f,p]=(0,V.useState)(null),m=(0,V.useRef)(null),g=e=>{m.current=e,h(e)},[x,v]=(0,V.useState)(null);if(n!==x){v(n),p(null);let e=n?du.get(n):void 0;e&&(a(e),g(n),d(!0))}let y=(0,V.useRef)(0),b=(0,V.useRef)(null),w=(0,V.useRef)(0),_=(0,V.useRef)(null),S=(0,V.useRef)(r);S.current=r;let k=(0,V.useCallback)(async(r=!1)=>{if(r&&b.current)return;b.current?.abort();let s=new AbortController;b.current=s,w.current=0;let i=y.current;if(!e||!n){b.current=null,a([]),l(dh),g(null),p(null),d(!1);return}r||d(!0);let o=!1;try{let c=await aC.api.getProjectWorktreeList(e,void 0,s.signal);if(i!==y.current)return;let d=c.worktrees;du.set(n,d),p(n),l(e=>{let r={staleRemote:c.stale??null,activeRemoteInvalid:!0===c.activeRemoteInvalid};return e.staleRemote?.serverId===r.staleRemote?.serverId&&e.activeRemoteInvalid===r.activeRemoteInvalid?e:r}),o=!0,a(e=>{let s=r?function(e,r,s){if(void 0===s||r.some(e=>e.branch===s))return r;let n=e.findIndex(e=>e.branch===s);if(n<0)return r;let i=[...r];return i.splice(Math.min(n,i.length),0,e[n]),i}(e,d,S.current):d;return e.length===s.length&&e.every((e,r)=>e.branch===s[r].branch&&e.currentBranch===s[r].currentBranch&&e.expectedBranch===s[r].expectedBranch&&dd(e)===dd(s[r]))?e:s})}catch(e){if(i!==y.current||e instanceof Error&&"AbortError"===e.name)return;console.error("Failed to fetch worktrees:",e),r||m.current===n||a([{branch:null}])}finally{if(i!==y.current||b.current!==s)return;o&&(w.current=Date.now()),g(n),r||d(!1),b.current=null}},[e,n]),j=(0,V.useCallback)(()=>{Date.now()-w.current<5e3||k(!0)},[k]);return(0,V.useEffect)(()=>(k(),()=>{b.current?.abort(),b.current=null,y.current+=1}),[k]),(0,V.useEffect)(()=>{let e=_.current;_.current={projectId:n,branch:r},e&&e.projectId===n&&e.branch!==r&&k(!0)},[n,r,k]),(0,aF.useGlobalEventStream)(r=>{if(!e||r.projectId!==e)return;let s="session:status"===r.type&&("stopped"===r.status||"error"===r.status);("session:taskCompleted"===r.type||"executor:stopped"===r.type||s)&&k(!0)}),(0,V.useEffect)(()=>{let e=null,r=()=>{null!==e&&(window.clearInterval(e),e=null)},s=()=>{r(),e=window.setInterval(()=>void k(!0),3e5)},n=()=>j(),i=()=>{"visible"===document.visibilityState?(j(),s()):r()};return window.addEventListener("focus",n),document.addEventListener("visibilitychange",i),"visible"===document.visibilityState&&s(),()=>{r(),window.removeEventListener("focus",n),document.removeEventListener("visibilitychange",i)}},[k,j]),{worktrees:i,loading:c||f!==n,stale:u!==n,listWarning:o,refetch:(0,V.useCallback)(()=>k(!1),[k])}}(eT?.id??null,I,eT?.agent_mode??null),{statuses:eV,rootDirty:eq,defaultTarget:eK,repositoryLabel:eX,repositoryServerId:eY,setTarget:eG,refetch:eJ}=function(e,r){let[s,n]=(0,V.useState)(new Map),[i,a]=(0,V.useState)(!1),[o,l]=(0,V.useState)(null),[c,d]=(0,V.useState)(null),[u,h]=(0,V.useState)(null),[f,p]=(0,V.useState)(0),[m,g]=(0,V.useState)(e);e!==m&&(g(e),n(new Map),a(!1),l(null),d(null));let x=(0,V.useCallback)(()=>p(e=>e+1),[]);return(0,V.useEffect)(()=>{let s,i=r.map(e=>e.branch).filter(e=>null!==e),o=new Set(i),c=(s=r.find(e=>null===e.branch))?(void 0===s.currentBranch?s.expectedBranch:s.currentBranch)??null:null,u=i.map(e=>({branch:e}));null===c||o.has(c)||u.push({branch:c});let f=!1;return(async()=>{if(!e||0===u.length){f||(n(new Map),a(!1),l(null),d(null));return}if(dp(e).length>0&&(await function(e){let r=dm.get(e);if(r)return r;let s=(async()=>{let r=new Map;for(;;){let s=dp(e).filter(({key:e,target:s})=>r.get(e)!==s);if(0===s.length)break;for(let{key:n,branch:i,target:a}of s){r.set(n,a);let s=!1;try{s=await aC.api.setMergeTarget(e,i,a,{ifAbsent:!0})}catch{}if(s)try{localStorage.getItem(n)===a&&localStorage.removeItem(n)}catch{}}}})();return dm.set(e,s),s.finally(()=>{dm.get(e)===s&&dm.delete(e)}),s}(e),f))return;let r=await aC.api.getMergeStatus(e,u);f||r.ok&&(n(function(e){let r=new Map;for(let s of e){if("target-not-found"===s.error&&s.requestedTarget){r.set(s.branch,{branch:s.branch,error:s.error,requestedTarget:s.requestedTarget,targetSource:s.targetSource});continue}!s.error&&s.target&&s.status&&r.set(s.branch,{branch:s.branch,status:s.status,unmergedCount:s.unmergedCount??0,dirty:s.dirty??!1,target:s.target})}return r}(r.entries.filter(e=>o.has(e.branch)).map(e=>e.branch===c?{...e,dirty:!1}:e))),a(null!==c&&(r.entries.find(e=>e.branch===c)?.dirty??!1)),l(function(e){for(let r of e)if("default"===r.targetSource&&r.target)return r.target;return null}(r.entries)),d(r.repository.label),h("local"===r.repository.kind?"local":r.repository.remoteServerId))})(),()=>{f=!0}},[e,r,f,x]),{statuses:s,rootDirty:i,defaultTarget:o,repositoryLabel:c,repositoryServerId:u,setTarget:(0,V.useCallback)((r,s)=>{e&&aC.api.setMergeTarget(e,r,s).then(e=>{e&&x()})},[e,x]),refetch:x}}(eT?.id??null,ez),eZ=function(e,r){let[s,n]=(0,V.useState)(()=>M3(e));s.projectId!==e&&n(M3(e));let i=(0,V.useRef)(e);(0,V.useEffect)(()=>{i.current=e},[e]);let a=(0,V.useRef)(new Map),o=(0,V.useRef)(new Map),[l,c]=(0,V.useState)(0),d=(0,V.useRef)(new Set),u=(0,V.useCallback)(e=>{n(r=>{let s=Date.now();return M7(e(r,s),d.current,s)})},[]),h=(0,V.useCallback)((e,r)=>{let s=i.current;if(!s)return;let n=`${s}\0${e??""}`,l=(a.current.get(n)??0)+1;a.current.set(n,l);let{request:c,issuedAt:d}=AD(s,e,{force:r});c.then(r=>{i.current!==s||(o.current.get(n)??0)>=l||(o.current.set(n,l),u((s,n)=>(function(e,r,s,n,i=n){let a=e;for(let e of s)a=M6(a,e,n);let o=new Set(s.map(e=>e.id)),l=[];for(let e of a.entries.values())(e.branch??null)===(r??null)&&(o.has(e.runId)||e.insertedAt>i||l.push(e.runId));return l.length>0?M4(a,l,n):a})(s,e,r,n,d)))}).catch(()=>{})},[u]);(0,V.useEffect)(()=>{e&&h(r,!1)},[e,r,h]);let{state:f}=(0,aF.useConnectionStatus)(),p=(0,V.useRef)(null),m=(0,V.useRef)(!1);(0,V.useEffect)(()=>{let s=p.current;p.current=f;let n=MZ(s,f,m.current);"live"===f&&(m.current=!0),n&&e&&h(r,!0)},[f,e,r,h]),(0,aF.useGlobalEventStream)(r=>{if("workflow:run-updated"!==r.type||!e||r.projectId!==e)return;let s=r.run;s&&"string"==typeof s.id&&u((e,r)=>M6(e,s,r))});let g=(0,V.useCallback)((e,r)=>{u((s,n)=>M6(s,e,n,r))},[u]),x=(0,V.useCallback)(e=>{d.current=e,n(r=>M7(r,e,Date.now()))},[]),v=(0,V.useMemo)(()=>[...s.entries.values()],[s]),y=JSON.stringify([...new Set(v.filter(e=>null===e.appearedAt).map(e=>e.branch??""))].sort());(0,V.useEffect)(()=>{let e=JSON.parse(y);if(0===e.length)return;let r=setInterval(()=>{for(let r of(n(e=>(function(e,r){let s=[];for(let n of e.entries.values())n.insertedAt+72e4<=r&&s.push(n.runId);let n=s.length>0?M4(e,s,r):e,i=!1;for(let e of n.tombstones.values())if(e<=r){i=!0;break}if(i){let e=new Map;for(let[s,i]of n.tombstones)i>r&&e.set(s,i);n={...n,tombstones:e}}return n})(e,Date.now())),e))h(""===r?null:r,!0);c(e=>e+1)},5e3);return()=>clearInterval(r)},[y,h]);let b=(0,V.useMemo)(()=>v.filter(e=>null===e.appearedAt&&"preparing"!==e.run.status&&!M2(e.run.status)).map(e=>e.reviewerSessionId),[v]);return(0,V.useMemo)(()=>({entries:v,addRun:g,awaitedSessionIds:b,pollTick:l,markAppeared:x}),[v,g,b,l,x])}(eT?.id??null,I),eQ=function(e,r,s,n){let i=JSON.stringify((r??[]).map(e=>e.branch)),a=(0,V.useMemo)(()=>JSON.parse(i),[i]),[o,l]=(0,V.useState)([]),[c,d]=(0,V.useState)(null);e!==c&&(d(e),l(e?MQ.get(e)??[]:[]));let u=(0,V.useRef)(e);u.current=e;let h=(0,V.useRef)(new Map),f=(0,V.useRef)(0),p=(0,V.useRef)(0),m=(0,V.useRef)(0),g=(0,V.useCallback)(e=>!(e<m.current)&&(m.current=e,!0),[]);(0,V.useEffect)(()=>{e&&MQ.set(e,o)},[e,o]);let[x,v]=(0,V.useState)(null),y=(0,V.useCallback)((e,r,s,n=1/0)=>{if(null===r||u.current!==e)return;let i=r.filter(e=>{let r=h.current.get(e.id);return void 0===r||r<=n});l(e=>{let r,n=(r=new Map(e.map(e=>[e.id,e])),i.map(e=>{let s=r.get(e.id);return s&&"New Session"===e.title&&"New Session"!==s.title?{...e,title:s.title}:e}));if(!s||n.some(e=>e.id===s))return n;let a=e.find(e=>e.id===s);return a?[a,...n]:n})},[]),b=(0,V.useCallback)(async r=>{if(!e)return void l([]);let s=f.current,n=++p.current,i=await MG(e);if(u.current===e&&g(n)){if("incomplete"===i)return void v(r=>({projectId:e,gen:(r?.gen??0)+1}));v(r=>r?.projectId===e?null:r),y(e,i,r?.keepSessionId,s)}},[e,y,g]);(0,V.useEffect)(()=>{let e=!1;return b().catch(r=>{e||console.warn("[ResidentSessions] refresh failed:",r)}),()=>{e=!0}},[b]),(0,V.useEffect)(()=>{if(!e||x?.projectId!==e)return;let r=!1,s=f.current,n=++p.current;return MJ(e,a).then(i=>{!r&&g(n)&&y(e,i,void 0,s)}).catch(e=>{r||console.warn("[ResidentSessions] fallback refresh failed:",e)}),()=>{r=!0}},[e,x,a,y,g]);let{state:w}=(0,aF.useConnectionStatus)(),_=(0,V.useRef)(null),S=(0,V.useRef)(!1);(0,V.useEffect)(()=>{let e=_.current;_.current=w;let r=MZ(e,w,S.current);"live"===w&&(S.current=!0),r&&b().catch(e=>console.warn("[ResidentSessions] reconnect refresh failed:",e))},[w,b]);let k=n&&n.sessionIds.length>0?`${n.tick}#${n.sessionIds.join("\0")}`:"",j=(0,V.useRef)(o);return(0,V.useEffect)(()=>{j.current=o},[o]),(0,V.useEffect)(()=>{!k||k.slice(k.indexOf("#")+1).split("\0").every(e=>j.current.some(r=>r.id===e))||b().catch(e=>console.warn("[ResidentSessions] awaited refresh failed:",e))},[k,b]),(0,V.useEffect)(()=>{if(!s||!s.processAlive||!e||s.projectId!==e||h.current.has(s.id))return;let r=!j.current.some(e=>e.id===s.id);l(e=>(function(e,r){let s=e.findIndex(e=>e.id===r.id);if(-1===s)return[r,...e];let n=e[s],i="New Session"===r.title&&"New Session"!==n.title?n.title:r.title,a=[...e];return a[s]={...r,title:i,status:n.status},a})(e,s)),r&&b({keepSessionId:s.id}).catch(e=>console.warn("[ResidentSessions] seed refresh failed:",e))},[e,s,b]),(0,aF.useGlobalEventStream)(r=>{if(e&&r.projectId===e){if("session:process"===r.type){let e="string"==typeof r.sessionId?r.sessionId:null,s="boolean"==typeof r.alive?r.alive:null,n="string"==typeof r.branch?r.branch:null;if(!e||null===s)return;if(!s){h.current.set(e,++f.current),l(r=>r.filter(r=>r.id!==e));return}h.current.delete(e),b().catch(e=>console.warn("[ResidentSessions] process refresh failed:",e)),null!==n&&l(r=>r.map(r=>r.id===e?{...r,branch:n}:r))}if("session:status"===r.type){let e="string"==typeof r.sessionId?r.sessionId:null,s="string"==typeof r.status?r.status:null;if(!e||!s)return;l(r=>r.map(r=>r.id===e?{...r,status:s}:r))}if("session:title"===r.type){let e="string"==typeof r.sessionId?r.sessionId:null;if(!e)return;l(s=>{var n,i;return i=("string"==typeof(n=r.title)?n.trim():"")||"New Session",s.map(r=>r.id===e?{...r,title:i}:r)})}}}),(0,V.useMemo)(()=>{let e=new Map;for(let r of o){let s=r.branch??"",n=e.get(s)??[];n.push(r),e.set(s,n)}for(let r of e.values())r.sort((e,r)=>(r.updated_at??"").localeCompare(e.updated_at??""));return e},[o])}(eT?.id??null,ez,O,{sessionIds:eZ.awaitedSessionIds,tick:eZ.pollTick}),e0=(0,V.useMemo)(()=>{let e=new Set;for(let r of eQ.values())for(let s of r)e.add(s.id);return e},[eQ]),e1=(0,V.useCallback)(e=>{for(let r of eQ.values()){let s=r.find(r=>r.id===e);if(s)return s.title}return null},[eQ]),e2=(0,V.useMemo)(()=>(function(e,r,s){if(0===r.length)return e;let n=new Map(e),i=new Set;for(let r of e.values())for(let e of r)i.add(e.id);for(let e of r){var a;if(null!==e.appearedAt||i.has(e.reviewerSessionId))continue;let r=e.branch??"",o=n.get(r)??[];n.set(r,[(a=s(e.sourceSessionId),{id:e.reviewerSessionId,projectId:e.projectId,branch:e.branch,title:M8(e,a),status:"preparing",processAlive:!1,updated_at:e.run.created_at,kind:M0,runId:e.runId}),...o])}return n})(eQ,eZ.entries,e1),[eQ,eZ.entries,e1]),e5=null!==er&&er.projectId===eT?.id,e3=e5?eZ.entries.find(e=>e.runId===er.runId):void 0,{tasks:e4,loading:e6,createTask:e7,updateTask:e8,deleteTask:e9,archive:te,unarchive:tt,refetch:tr}=function(e){let[r,s]=(0,V.useState)([]),[n,i]=(0,V.useState)(!0),[a,o]=(0,V.useState)(null);if(e!==a){o(e);let r=e?dx.get(e):void 0;s(r??[]),i(!!e&&!r)}(0,V.useEffect)(()=>{e&&dx.has(e)&&dx.set(e,r)},[e,r]);let l=(0,V.useRef)(e),c=(0,V.useRef)(0),d=(0,V.useCallback)(async(e,r)=>{if(!e){c.current===r&&i(!1);return}try{let n=await aC.api.getTasks(e,{includeArchived:!0});dx.set(e,n),c.current===r&&s(n)}catch(e){console.error("Failed to fetch tasks:",e)}finally{c.current===r&&i(!1)}},[]);(0,V.useEffect)(()=>{l.current=e,c.current+=1,d(e,c.current)},[e,d]);let u=(0,V.useCallback)(async()=>{await d(l.current,c.current)},[d]),h=(0,V.useCallback)(async r=>{if(!e)return null;try{let n=await aC.api.createTask(e,r);return l.current===e&&s(e=>[...e,n]),n}catch(e){return console.error("Failed to create task:",e),null}},[e]),f=(0,V.useCallback)(async(e,n)=>{let i=l.current;s(r=>r.map(r=>r.id===e?{...r,...n,updated_at:new Date().toISOString()}:r));try{let r=await aC.api.updateTask(e,n);return l.current===i&&s(s=>s.map(s=>s.id===e?r:s)),r}catch(e){return console.error("Failed to update task:",e),l.current===i&&s(r),null}},[r]),p=(0,V.useCallback)(async e=>{let n=l.current;s(r=>r.filter(r=>r.id!==e));try{await aC.api.deleteTask(e)}catch(e){console.error("Failed to delete task:",e),l.current===n&&s(r)}},[r]),m=(0,V.useCallback)(async e=>{let n=l.current;s(r=>r.map(r=>r.id===e?{...r,archived_at:Date.now()}:r));try{let r=await aC.api.archiveTask(e);l.current===n&&s(s=>s.map(s=>s.id===e?r:s))}catch(e){console.error("Failed to archive task:",e),l.current===n&&s(r)}},[r]),g=(0,V.useCallback)(async e=>{let n=l.current;s(r=>r.map(r=>r.id===e?{...r,archived_at:null}:r));try{let r=await aC.api.unarchiveTask(e);l.current===n&&s(s=>s.map(s=>s.id===e?r:s))}catch(e){console.error("Failed to unarchive task:",e),l.current===n&&s(r)}},[r]),x=(0,V.useCallback)(async n=>{if(!e)return;let i=l.current;s(n.map(e=>r.find(r=>r.id===e)).filter(e=>void 0!==e));try{await aC.api.reorderTasks(e,n)}catch(e){console.error("Failed to reorder tasks:",e),l.current===i&&s(r)}},[e,r]);return{tasks:r,loading:n,createTask:h,updateTask:f,deleteTask:p,archive:m,unarchive:g,reorderTasks:x,refetch:u}}(eT?.id??null),{schedules:ts,loading:tn,createSchedule:ti,updateSchedule:ta,deleteSchedule:to,runNow:tl}=function(e){let[r,s]=(0,V.useState)([]),[n,i]=(0,V.useState)(!1),[a,o]=(0,V.useState)(null);e!==a&&(o(e),s(e?dv.get(e)??[]:[])),(0,V.useEffect)(()=>{e&&dv.set(e,r)},[e,r]);let l=(0,V.useRef)(e),c=(0,V.useRef)(0),d=(0,V.useCallback)(async(e,r,n)=>{if(!e){c.current===r&&(s([]),i(!1));return}n&&i(!0);try{let n=await aC.api.getSchedules(e);c.current===r&&s(n)}catch(e){console.error("Failed to fetch schedules:",e)}finally{n&&c.current===r&&i(!1)}},[]);(0,V.useEffect)(()=>{l.current=e,c.current+=1,d(e,c.current,!0)},[e,d]);let u=(0,V.useCallback)(async()=>{let e=l.current;e&&await d(e,c.current,!1)},[d]),h=(0,V.useRef)(u);(0,V.useEffect)(()=>{h.current=u},[u]),(0,aF.useGlobalEventStream)(e=>{!e.type?.startsWith("schedule:")||l.current&&e.projectId===l.current&&h.current()});let f=(0,V.useCallback)(async r=>{if(!e)throw Error("No project selected");let s=await aC.api.createSchedule(e,r);return await u(),s},[e,u]),p=(0,V.useCallback)(async(e,r)=>{let s=await aC.api.updateSchedule(e,r);return await u(),s},[u]),m=(0,V.useCallback)(async e=>{await aC.api.deleteSchedule(e),await u()},[u]),g=(0,V.useCallback)(async(e,r)=>{let s=r;if(!s){let e=crypto.randomUUID();s={requestId:e,runId:e}}let n=await aC.api.runScheduleNow(e,s);return await u(),n},[u]);return{schedules:r,loading:n,refetch:u,createSchedule:f,updateSchedule:p,deleteSchedule:m,runNow:g}}(eT?.id??null),[tc,td]=(0,V.useState)(null),[tu,th]=(0,V.useState)(null),[tf,tp]=(0,V.useState)(null),[tm,tg]=(0,V.useState)(null),[tx,tv]=(0,V.useState)(!1),[ty,tb]=(0,V.useState)(null),tw=(0,V.useCallback)(e=>{th({kind:"task",taskId:e.id,status:e.status}),ef("tasks")},[ef]),{activity:t_,since:tS,refetch:tk,setOptimisticActivity:tj}=function(e){let[r,s]=(0,V.useState)(new Map),[n,i]=(0,V.useState)(new Map),a=(0,V.useRef)(new Map),o=(0,V.useRef)(new Map),l=(0,V.useRef)(null),c=(0,V.useCallback)(async()=>{if(!e){s(new Map),i(new Map),o.current=new Map,l.current=null,a.current=new Map;return}try{let r=await (0,aC.authFetch)(`${"localhost"===window.location.hostname&&"3000"===window.location.port?"http://localhost:5173":""}/api/projects/${e}/branches/activity`);if(!r.ok)return;let n=await r.json(),c=l.current!==e,{nextActivity:d,nextSince:u}=function(e,r,s,n){let i=new Map,a=new Map,o=[];for(let l of e){let e=l.branch??"",c=s.get(e)??0;if(!n&&l.since<c){let s=r.get(e);if(void 0!==s){i.set(e,s),a.set(e,c);continue}}i.set(e,l.activity),a.set(e,l.since),n||r.get(e)===l.activity||o.push(l.branch)}return{nextActivity:i,nextSince:a,transitions:o}}(n.branches,o.current,a.current,c);s(d),i(u),o.current=d,l.current=e,a.current=u}catch{}},[e]);return(0,V.useEffect)(()=>{c()},[c]),(0,aF.useGlobalEventStream)(r=>{var n,l,c;let d,u;if("branch:activity"!==r.type||!e||r.projectId!==e)return;let h=(n=r,l=o.current,c=a.current,d=n.branch??"",u=c.get(d)??0,n.since<u?{kind:"stale"}:l.get(d)===n.activity?{kind:"redundant",key:d}:{kind:"transition",key:d});"stale"===h.kind||(a.current.set(h.key,r.since),i(new Map(a.current)),"redundant"!==h.kind&&s(e=>{let s=new Map(e);return s.set(h.key,r.activity),o.current=s,s}))}),{activity:r,since:n,refetch:c,setOptimisticActivity:(0,V.useCallback)((e,r)=>{s(s=>{let n=function(e,r,s){let n=r??"";if(e.get(n)===s)return e;let i=new Map(e);return i.set(n,s),i}(s,e,r);return o.current=n,n})},[])}}(eT?.id??null),tC=(0,V.useRef)(null),tN=(0,V.useRef)(null),[tE,tD]=(0,V.useState)(!1),tT=(0,V.useCallback)(()=>{let e=tN.current;e&&(e.isCollapsed()?e.expand():e.collapse())},[]),tR=(0,V.useSyncExternalStore)(Wt,X,()=>!1),tA=`${tE?"Show":"Hide"} Main Chat`,tM=(0,V.useSyncExternalStore)(ES,Ek,Ej),tI=eT?.id??null,tP=eT?.agent_mode??null,tF=(0,V.useCallback)(e=>!!tI&&tM.has(EC(tI,e,tP)),[tM,tI,tP]),tL=(0,V.useCallback)(e=>{if(tI)return tM.get(EC(tI,e,tP))},[tM,tI,tP]),tO=(0,V.useCallback)(e=>tS.get($9(e)),[tS]),tB=(0,V.useMemo)(()=>(function(e,r,s,n){let i=new Map;if(!e)return i;for(let a of e){let e=$9(a.branch),o=r.get(e);if(!s?.(a.branch)){i.set(e,o??"idle");continue}if("main-running"===o||"main-waiting"===o)i.set(e,o);else if("main-completed"===o){let r=n?.backendSince?.(a.branch)??0,s=n?.placeholderSince?.(a.branch)??0;i.set(e,s>r?"idle":"main-completed")}else i.set(e,"idle")}return i})(ez,t_,tF,{backendSince:tO,placeholderSince:tL}),[ez,t_,tF,tO,tL]);o=eJ,l=tB,c=eT?.id??null,d=(0,V.useRef)(new Set),h=(u=function(e){let r=new Set;if(!e)return r;for(let[s,n]of e)dg.has(n)&&r.add(s);return r}(l)).size>0,f=JSON.stringify(Array.from(u).sort()),(0,V.useEffect)(()=>{let e=new Set(JSON.parse(f)),r=d.current;d.current=e,function(e,r){for(let s of e)if(!r.has(s))return!0;return!1}(r,e)&&o()},[f,o]),(0,V.useEffect)(()=>{let e=()=>o();return window.addEventListener("focus",e),()=>window.removeEventListener("focus",e)},[o]),(0,aF.useGlobalEventStream)(e=>{"executor:stopped"===e.type&&e.projectId===c&&o(),"merge-target:updated"===e.type&&null!==c&&e.projectId===c&&o(),"files:changed"===e.type&&null!==c&&e.projectId===c&&o()}),(0,V.useEffect)(()=>{let e=null,r=()=>{null!==e&&(clearInterval(e),e=null)},s=()=>{r(),e=setInterval(o,h?3e4:6e4)},n=()=>{"visible"===document.visibilityState?s():r()};return"visible"===document.visibilityState&&s(),document.addEventListener("visibilitychange",n),()=>{r(),document.removeEventListener("visibilitychange",n)}},[o,h]);let[tz,t$]=(0,V.useState)(null),[tW,tH]=(0,V.useState)(null),[tU,tV]=(0,V.useState)(null),[tq,tK]=(0,V.useState)(!1),tX="workspace"===eh&&tq&&null!==tW,{notifications:tY,unreadCount:tG,markRead:tJ,markAllRead:tZ,remove:tQ,clear:t0,markReviewRunRead:t1}=function(e,r=null,s=null){let[n,i]=(0,V.useState)([]),a=(0,V.useRef)(new Set),o=(0,V.useRef)(new Set),l=(0,V.useRef)(n);(0,V.useEffect)(()=>{l.current=n},[n]);let c=(0,V.useRef)(new Set);(0,V.useEffect)(()=>{for(let e of new Set(Object.values($$)))$K.has(e)||$X.has(e)||($X.add(e),(async()=>{try{let r=await fetch(e),s=await r.blob(),n=new Audio(URL.createObjectURL(s));n.preload="auto",n.load(),$K.set(e,n)}catch{}finally{$X.delete(e)}})())},[]);let d=(0,V.useRef)(e),u=(0,V.useRef)({resultAt:r,turnEndAt:s});(0,V.useEffect)(()=>{d.current=e,u.current={resultAt:r,turnEndAt:s}},[e,r,s]);let h=(0,V.useRef)(new Map);(0,V.useEffect)(()=>{if(!e||null===r)return;let n=()=>{if("visible"!==document.visibilityState)return;let n=h.current.get(e),i=(e,r)=>null==e?r:null===r?e:Math.max(e,r);h.current.set(e,{resultAt:i(n?.resultAt,r),turnEndAt:i(n?.turnEndAt,s)})};return n(),document.addEventListener("visibilitychange",n),()=>document.removeEventListener("visibilitychange",n)},[e,r,s]);let f=(0,V.useCallback)(e=>{if(null===e.session_id)return!1;let r=h.current.get(e.session_id);return void 0!==r&&$G(e,r)},[]),p=(0,V.useCallback)(e=>{if(o.current.has(e))return;o.current.add(e);let r=Date.now();i(s=>s.map(s=>s.id===e&&null===s.read_at?{...s,read_at:r}:s)),(0,aC.markNotificationRead)(e).catch(()=>{i(s=>s.map(s=>s.id===e&&s.read_at===r?{...s,read_at:null}:s))}).finally(()=>{o.current.delete(e)})},[]),m=(0,V.useCallback)(e=>null===e.read_at&&null!==e.workflow_run_id&&c.current.has(e.workflow_run_id)?((0,aC.markNotificationRead)(e.id).catch(()=>{}),{...e,read_at:Date.now()}):e,[]);(0,V.useEffect)(()=>{let e=!1;return(0,aC.getNotifications)({limit:100}).then(r=>{if(e)return;for(let e of r)a.current.add(e.id);let s=r.map(m);i(e=>{let r=[];for(let e of s)r=$H(r,e);for(let n of e)s.some(e=>e.id===n.id)||(r=$H(r,n));return r});try{window.localStorage.removeItem("vibedeckx:completion-notifications")}catch{}}).catch(e=>{console.warn("[notifications] hydration failed:",e)}),()=>{e=!0}},[m]);let g=(0,V.useCallback)((e,r=!1)=>{let s=!a.current.has(e.id);a.current.add(e.id);let n=d.current,o=null!==e.session_id&&e.session_id===n&&$G(e,u.current),l=null!==e.workflow_run_id&&c.current.has(e.workflow_run_id),h=o||l||r;return i(r=>$H(r,h?{...e,read_at:e.read_at??Date.now()}:e)),h&&null===e.read_at&&(0,aC.markNotificationRead)(e.id).catch(()=>{}),s&&!l&&!r},[]),x=(0,V.useRef)(null),v=(0,V.useRef)(!1);(0,V.useEffect)(()=>(v.current=!1,()=>{v.current=!0,x.current&&clearTimeout(x.current)}),[]);let y=(0,V.useCallback)(()=>{x.current&&(clearTimeout(x.current),x.current=null);let e=r=>{(0,aC.getNotifications)({limit:100}).then(e=>{let r=Date.now(),s=null;for(let n of e){if(a.current.has(n.id))continue;let e=g(n,f(n)),i=null===n.read_at&&r-n.created_at<=12e4;e&&i&&(!s||n.created_at>s.created_at)&&(s=n)}s&&$J($$[s.kind])}).catch(s=>{let n=$W[r];console.warn(`[notifications] reconnect catch-up failed${void 0===n?", giving up":`, retrying in ${n}ms`}:`,s),void 0===n||v.current||(x.current=setTimeout(()=>{x.current=null,e(r+1)},n))})};e(0)},[g,f]);(0,aF.useGlobalEventStream)(e=>{if(e.type===aF.STREAM_RECONNECTED_EVENT)return void y();if("notification:created"!==e.type)return;let r=e.notification;r?.id&&g(r)&&$J($$[r.kind])}),(0,V.useEffect)(()=>{if(e&&null!==r)for(let a of n){if(a.session_id!==e||null!==a.read_at||!$G(a,{resultAt:r,turnEndAt:s})||o.current.has(a.id))continue;let{id:n}=a;o.current.add(n),(0,aC.markNotificationRead)(n).then(()=>{i(e=>e.map(e=>e.id===n&&null===e.read_at?{...e,read_at:Date.now()}:e))}).catch(()=>{}).finally(()=>{o.current.delete(n)})}},[e,r,s,n]);let b=(0,V.useCallback)(e=>p(e),[p]),w=(0,V.useCallback)((e,r)=>{for(let s of(r?.runEnded&&c.current.add(e),l.current))s.workflow_run_id===e&&null===s.read_at&&p(s.id)},[p]),_=(0,V.useCallback)(()=>{let e=Date.now();i(r=>r.some(e=>null===e.read_at)?r.map(r=>null===r.read_at?{...r,read_at:e}:r):r),(0,aC.markAllNotificationsRead)().catch(()=>i(n))},[n]),S=(0,V.useCallback)(e=>{p(e),i(r=>r.filter(r=>r.id!==e))},[p]),k=(0,V.useCallback)(()=>{(0,aC.markAllNotificationsRead)().catch(e=>console.warn("[notifications] read-all failed:",e)),i(e=>e.length?[]:e)},[]),j=$q(n).reduce((e,r)=>e+ +!!r.unread,0);return{notifications:n,unreadCount:j,markRead:b,markAllRead:_,remove:S,clear:k,markReviewRunRead:w}}(tX?tz:null,tX?tW:null,tX?tU:null),t2=(0,V.useMemo)(()=>({markReviewRunRead:t1}),[t1]),t5=(0,V.useMemo)(()=>tY.filter(e=>e.project_id===eT?.id&&null===e.read_at).length,[tY,eT?.id]),t3=(0,V.useCallback)(()=>{tj(I,"working")},[I,tj]),t4=(0,V.useCallback)(()=>{tr()},[tr]),t6=(0,V.useCallback)((e,r)=>{M({branch:e,sessionId:r}),es(null),ex(e=>e+1),ew(!1),(0,$O.touchRecentSessionOpen)(r)},[]),t7=(0,V.useRef)(0),t8=(0,V.useCallback)((e,r,s)=>{ef("workspace"),F(e),H({branch:e,path:r,line:s,nonce:++t7.current})},[F]),t9=(0,V.useCallback)((e,r,s)=>{es({projectId:e,runId:r}),M({branch:s,sessionId:null}),ex(e=>e+1),ew(!1),ef("workspace")},[]),re=(0,V.useCallback)(e=>{"preparing-review"===e.kind&&e.runId?t9(e.projectId,e.runId,e.branch):(t6(e.branch,e.id),ef("workspace"))},[t6,t9]),rt=(0,V.useCallback)(e=>{let r=eZ.entries.find(r=>r.runId===e);r&&t9(r.projectId,r.runId,r.branch)},[eZ.entries,t9]),rr=eZ.markAppeared;(0,V.useEffect)(()=>{rr(e0)},[e0,rr]),(0,V.useEffect)(()=>{if(!er)return;if(er.projectId!==eT?.id)return void es(null);let e=e3?null!==e3.appearedAt?{kind:"switch",branch:e3.branch,sessionId:e3.reviewerSessionId}:"preparing"===e3.run.status?{kind:"wait"}:M2(e3.run.status)?{kind:"gone"}:e0.has(e3.reviewerSessionId)?{kind:"switch",branch:e3.branch,sessionId:e3.reviewerSessionId}:{kind:"wait"}:{kind:"gone"};"switch"===e.kind&&t6(e.branch,e.sessionId)},[er,e3,e0,eT?.id,t6]);let rs=(0,V.useCallback)(e=>{tk();let r=eD.find(r=>r.id===e.projectId);(0,$O.touchSessionStarted)({sessionId:e.id,projectId:e.projectId,projectName:r?.name??"",targetId:r?.agent_mode??"local",branch:e.branch});let s=function(e,r=new Date){return!0!==e.processAlive?null:{id:e.id,projectId:e.projectId,branch:e.branch,title:"New Session",status:e.status,processAlive:!0,updated_at:r.toISOString()}}(e);s&&B(s)},[tk,eD]),rn=(0,V.useCallback)((e,r)=>{r.trim()&&(0,$O.updateCachedSessionTitle)(e,r.trim())},[]),ri=(0,V.useCallback)(()=>{tj(I,"idle")},[I,tj]),ra=(0,V.useCallback)(()=>{tr()},[tr]);s=eT?.id??null,n={onTaskChanged:ra},p=(0,V.useRef)(n.onTaskChanged),(0,V.useEffect)(()=>{p.current=n.onTaskChanged}),(0,aF.useGlobalEventStream)(e=>{s&&e.projectId===s&&("task:created"===e.type||"task:updated"===e.type||"task:deleted"===e.type)&&p.current?.()}),(0,V.useCallback)(e=>{eE(async()=>{await ek.current?.submitMessage(e.description??e.title)})},[]);let[ro,rl]=(0,V.useState)(null),rc=(0,V.useCallback)((e,r)=>{eT&&(EE(EC(eT.id,r,eT.agent_mode)),rl({projectId:eT.id,branch:r,tasks:[{...e,subtasks:RK(e4,e.id)}],nonce:Date.now()}),ef("workspace"),F(r),ex(e=>e+1))},[eT,e4,F]);(0,V.useCallback)(e=>{e8(e,{assigned_branch:null})},[e8]),(0,V.useEffect)(()=>{let e=eB.current;if(void 0!==e&&e.projectId!==eT?.id&&(eB.current=void 0,ew(!1),eS(!1)),!eW&&0!==ez.length){if(void 0!==e&&e.projectId===eT?.id){let r=ez.find(r=>r.branch===e.branch);if(r&&e.checkPlacement){eB.current=void 0,ew(!1),eS(!1);let s=We(r,eT?.agent_mode??"local");return"absent"===s.kind?void Q(s.missing):("creating"===s.kind&&xc.toast.info(`'${e.branch}' is still being created on ${s.machineName}`),void F(e.branch))}if(r){eB.current=void 0,I!==e.branch||P!==e.sessionId?e.sessionId?t6(e.branch,e.sessionId):F(e.branch):e.sessionId&&(0,$O.touchRecentSessionOpen)(e.sessionId),eS(!1),ew(!1);return}return void(e$||(eB.current=void 0,ew(!1),eS(!1),xc.toast.warning(`Workspace "${e.branch??"main"}" no longer exists`),F(ez[0].branch)))}!e$&&(ez.some(e=>e.branch===I)||(P&&xc.toast.warning(`Workspace "${I??"main"}" no longer exists`),F(ez[0].branch)))}},[ez,e$,eW,I,P,eT?.id,eT?.agent_mode,t6,F]),(0,V.useEffect)(()=>{(eb||e_)&&(null===I&&(e$||0!==ez.length)||(ew(!1),eS(!1)))},[eb,e_,I,e$,ez]);let rd=(0,V.useCallback)((e,r,s=null)=>{if(ef("workspace"),e===eT?.id)return void(s?t6(r,s):F(r));let n=eD.find(r=>r.id===e);n&&(s?ew(!0):eS(!0),eB.current={projectId:e,branch:r,sessionId:s},eF(n))},[eT?.id,eD,eF,t6,F]),[ru,rh]=(0,V.useState)(!1),rf=!!eT;(0,V.useEffect)(()=>{let e=e=>{if("k"===e.key&&(e.metaKey||e.ctrlKey)){e.preventDefault(),rh(e=>!e);return}if(ee(e,J)){if("workspace"!==eh||!rf)return;e.preventDefault(),e.repeat||tT();return}"o"===e.key.toLowerCase()&&e.shiftKey&&(e.metaKey||e.ctrlKey)&&"workspace"===eh&&(e.preventDefault(),ex(e=>e+1),ek.current?.startNewConversation())};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[eh,rf,tT]);let rp=(0,V.useRef)(!1),rm=(0,V.useCallback)(async(e,r)=>{let s=eD.find(r=>r.id===e);if(!s)return null;let n="local"===r?"local":r;return(s.agent_mode??"local")!==n?eI(s.id,{agentMode:n}):s},[eD,eI]),rg=(i={projectId:eT?.id??null,resolveProjectForTarget:rm,getScheduleRun:aC.api.getScheduleRun,getSchedules:aC.api.getSchedules,runScheduleNow:tl,selectAgentSession:(e,r)=>{ef("workspace"),t6(e,r)},openScheduleRun:(e,r)=>{td(e),tg(r),ef("schedules")},onRerunResult:e=>{e.replay&&e.status&&"starting"!==e.status&&"running"!==e.status?"completed"===e.status?xc.toast.success("Schedule run already completed"):xc.toast.error(`Schedule run already ${e.status}`):xc.toast.success("Schedule run started")},onError:(e,r)=>{console.error(`Project activity ${e} failed:`,r),"session-navigation"===e?xc.toast.error("Failed to open agent session"):"schedule-navigation"===e?xc.toast.error("Failed to open schedule run"):xc.toast.error(r instanceof Error?r.message:"Failed to start schedule run")}},(m=(0,V.useRef)(i)).current=i,(g=(0,V.useRef)({projectId:i.projectId,generation:0})).current.projectId!==i.projectId&&(g.current={projectId:i.projectId,generation:g.current.generation+1}),x=(0,V.useRef)(new Map),v=(0,V.useRef)(new Map),y=(0,V.useCallback)(e=>g.current.projectId===e.projectId&&g.current.generation===e.generation,[]),b=(0,V.useCallback)(async(e,r)=>{if(!e.projectId)return null;let s=m.current,n=await s.getScheduleRun(r);if(!y(e))return null;if(n.project_id!==e.projectId)throw Error("Schedule run does not belong to the active project");let i=await s.getSchedules(e.projectId);if(!y(e))return null;let a=i.find(e=>e.id===n.schedule_id);if(!a||a.project_id!==e.projectId)throw Error("Schedule does not belong to the active project");return{run:n,schedule:a}},[y]),w=(0,V.useCallback)(async(e,r,s)=>{let n={...g.current};if(n.projectId)try{let i=await m.current.resolveProjectForTarget(n.projectId,r);if(!y(n)||!i||i.id!==n.projectId)return;m.current.selectAgentSession(s,e,i.id)}catch(e){y(n)&&m.current.onError("session-navigation",e)}},[y]),_=(0,V.useCallback)(async(e,r)=>{let s={...g.current};try{let n=await b(s,e);if(!n||!y(s))return;if(r&&r!==n.schedule.id)throw Error("Schedule run target changed while opening");m.current.openScheduleRun(n.schedule.id,e)}catch(e){y(s)&&m.current.onError("schedule-navigation",e)}},[y,b]),S=(0,V.useCallback)(e=>{let r={...g.current};if(!r.projectId)return Promise.resolve();let s=`${r.projectId}:${e}`,n=v.current.get(s);if(n)return n;let i=(async()=>{try{let n,i=dy(r.projectId,e),a=x.current.get(i)??function(e,r,s){try{let n=window.sessionStorage.getItem(e);if(!n)return;let i=JSON.parse(n);return"string"==typeof i.requestId&&"string"==typeof i.runId&&i.projectId===r&&"string"==typeof i.scheduleId&&i.scheduleId.length>0&&i.sourceRunId===s?i:void 0}catch{return}}(i,r.projectId,e);if(a){let e=await m.current.getSchedules(r.projectId);if(!y(r))return;let s=a.scheduleId,o=e.find(e=>e.id===s);if(!o||o.project_id!==r.projectId)throw Error("Schedule does not belong to the active project");n=o,x.current.set(i,a)}else{let o=await b(r,e);if(!o||!y(r))return;n=o.schedule;let l=crypto.randomUUID();a={projectId:r.projectId,scheduleId:n.id,requestId:l,runId:l,sourceRunId:e},x.current.set(i,a);var s=a;try{window.sessionStorage.setItem(i,JSON.stringify(s))}catch{}}let o={requestId:a.requestId,runId:a.runId,sourceRunId:a.sourceRunId},l=await m.current.runScheduleNow(n.id,o);if(x.current.delete(i),db(i),!y(r))return;m.current.onRerunResult(l)}catch(s){if(r.projectId&&("object"==typeof s&&null!==s&&"status"in s&&409===s.status||"object"==typeof s&&null!==s&&"durable"in s&&!0===s.durable)){let s=dy(r.projectId,e);x.current.delete(s),db(s)}throw y(r)&&m.current.onError("schedule-rerun",s),s}})().finally(()=>{v.current.get(s)===i&&v.current.delete(s)});return v.current.set(s,i),i},[y,b]),{openAgentSession:w,openScheduleRun:_,runScheduleAgain:S}),rx=(a={projectId:eT?.id??null,schedules:ts,getTask:aC.api.getTask,resolveProjectForTarget:rm,openTask:tb,selectAgentSession:(e,r)=>{ef("workspace"),t6(e,r)},selectWorkspace:e=>{F(e),ef("workspace")},selectSchedule:e=>{td(e),ef("schedules")},openScheduleRun:rg.openScheduleRun,onError:e=>{xc.toast.error(e instanceof Error?e.message:"Unable to open Context item")}},(k=(0,V.useRef)(a)).current=a,(j=(0,V.useRef)({projectId:a.projectId,generation:0})).current.projectId!==a.projectId&&(j.current={projectId:a.projectId,generation:j.current.generation+1}),C=(0,V.useCallback)(e=>e.projectId===j.current.projectId&&e.generation===j.current.generation,[]),{open:(0,V.useCallback)(async e=>{let r={...j.current},s=e.navigation;if(!r.projectId||e.deleted||!s){C(r)&&k.current.onError(Error("This Context item is no longer available"));return}try{if("task"===s.kind){let e=await k.current.getTask(r.projectId,s.taskId);if(!C(r))return;if(e.id!==s.taskId||e.project_id!==r.projectId)throw Error("Task is no longer available in this project");k.current.openTask(e);return}if("agent_session"===s.kind||"workspace"===s.kind){let e=await k.current.resolveProjectForTarget(r.projectId,s.target);if(!C(r))return;if(!e||e.id!==r.projectId)throw Error("Workspace target is no longer available");"agent_session"===s.kind?k.current.selectAgentSession(s.branch,s.sessionId,e.id):k.current.selectWorkspace(s.branch,e.id);return}if("schedule"===s.kind){let e=k.current.schedules.find(e=>e.id===s.scheduleId&&e.project_id===r.projectId);if(!e)throw Error("Schedule is no longer available in this project");k.current.selectSchedule(e.id);return}await k.current.openScheduleRun(s.runId,s.scheduleId)}catch(e){C(r)&&k.current.onError(e)}},[C])}),rv=(0,V.useCallback)(e=>{em(e),F(null),ef("project-chat")},[F]),ry=(0,V.useCallback)(()=>{em(null),ef("project-info")},[]);(0,V.useEffect)(()=>{ef(E),em("project-chat"===E?T:null),"project-chat"===E&&F(null)},[E,T,F]);let rb=(0,V.useCallback)(e=>{tg(r=>r===e?null:r)},[]),rw=(0,V.useCallback)(e=>{if(rp.current)return;let r=eD.find(r=>r.id===e);r&&(rh(!1),eF(r),ef("project-info"))},[eD,eF]),r_=(0,V.useCallback)(async e=>{if(!rp.current){rp.current=!0,rh(!1);try{let r=await rm(e.projectId,e.targetId);if(!r)return;(0,$O.touchRecentSessionOpen)(e.sessionId,e),ef("workspace"),r.id===eT?.id?t6(e.branch,e.sessionId):(ew(!0),eB.current={projectId:r.id,branch:e.branch,sessionId:e.sessionId},eF(r))}catch(e){console.error("Quick switcher navigation failed:",e),xc.toast.error("Failed to open session")}finally{rp.current=!1}}},[eT?.id,rm,eF,t6]);(0,V.useEffect)(()=>{if(eR||eL||eO)return;let e=A4({projectId:eT?.id,tab:eh,branch:I,threadId:ep}),r=e;if(P){let s=new URL(e,window.location.origin);s.searchParams.set("session",P),r=s.pathname+s.search}window.history.replaceState(null,"",r),(0,$8.saveLastLocation)(r)},[eT?.id,eh,I,ep,eR,eL,eO,P]),(0,V.useEffect)(()=>{eL||(0,$8.settleRestoredLocation)(!eO)&&(F(null),window.history.replaceState(null,"","/"),window.dispatchEvent(new PopStateEvent("popstate")))},[eL,eO,F]);let rS=(0,V.useCallback)(e=>{eU(),F(e)},[eU,F]),rk=(0,V.useCallback)((e,r)=>{e.branch&&(K(e),G(r),eo(!0))},[]),rj=(0,V.useCallback)(e=>{let r=We(null===e?void 0:ez.find(r=>r.branch===e),eT?.agent_mode??"local");"absent"===r.kind?Q(r.missing):("creating"===r.kind&&xc.toast.info(`'${e}' is still being created on ${r.machineName}`),F(e))},[ez,eT?.agent_mode,F]),rC=(0,V.useCallback)(e=>{if(rh(!1),ef("workspace"),e.projectId===eT?.id)return void rj(e.branch);let r=eD.find(r=>r.id===e.projectId);r&&(eS(!0),eB.current={projectId:e.projectId,branch:e.branch,sessionId:null,checkPlacement:!0},eF(r))},[eT?.id,eD,rj,eF]),rN=(0,V.useCallback)(()=>{let e=`Please perform the following git operations for this worktree:
55
+
56
+ 1. Commit all current uncommitted changes with an appropriate commit message
57
+ 2. Fetch the latest changes from the remote main branch
58
+ 3. Rebase the current branch onto main (resolve any conflicts if needed)
59
+ 4. Merge the current branch into main
60
+
61
+ Please proceed step by step and let me know if there are any issues or conflicts that need manual resolution.`;ek.current?.submitMessage(e)},[]),rE=(0,V.useCallback)(async e=>{if(eT)try{await eI(eT.id,{agentMode:e})}catch(e){console.error("Failed to update agent mode:",e)}},[eT,eI]),rD=(0,V.useCallback)(async e=>{if(eT)try{await eI(eT.id,{executorMode:e})}catch(e){console.error("Failed to update executor mode:",e)}},[eT,eI]),rT=!eT;return(0,U.jsx)(d0,{children:(0,U.jsx)(dq,{children:(0,U.jsx)(I$,{value:t2,children:(0,U.jsx)("div",{className:"h-screen flex flex-col w-full",children:(0,U.jsxs)(xa,{projectId:eT?.id??void 0,children:[(0,U.jsxs)("div",{"data-focus-region":"default",className:"border-b border-border bg-card px-3 h-[44px] flex items-center justify-between sticky top-0 z-10",children:[(0,U.jsxs)("div",{className:"flex items-center gap-[9px]",children:[(0,U.jsx)(xy.Logo,{size:22}),(0,U.jsxs)("h1",{className:"text-[13px] font-semibold tracking-tight text-foreground",children:["VibeDeck",(0,U.jsx)("span",{className:"text-primary font-bold",children:"X"})]})]}),(0,U.jsxs)("div",{className:"flex items-center gap-2.5",children:["workspace"===eh&&!rT&&(0,U.jsx)(a$.Button,{variant:"ghost",size:"icon-sm","aria-label":tA,"aria-pressed":tE,title:`${tA} (${et(tR,J)})`,onClick:tT,children:tE?(0,U.jsx)(mu,{className:"h-4 w-4"}):(0,U.jsx)(md,{className:"h-4 w-4"})}),(0,U.jsx)(a$.Button,{variant:"ghost",size:"icon-sm","aria-label":"Search projects, workspaces, and sessions",title:"Search (⌘K / Ctrl+K)",onClick:()=>rh(!0),children:(0,U.jsx)(aK,{className:"h-4 w-4"})}),(0,U.jsx)($4,{}),(0,U.jsx)(mp.DocsButton,{}),(0,U.jsx)(mf,{inviteUrl:R?.discordInviteUrl}),(0,U.jsx)($7,{}),(0,U.jsx)($1,{notifications:tY,unreadCount:tG,projects:eD,onNavigate:rd,markRead:tJ,markAllRead:tZ,remove:tQ,clear:t0}),(0,U.jsx)(xv,{})]})]}),(0,U.jsxs)("div",{className:"flex-1 flex overflow-hidden",children:[(0,U.jsx)(d7,{activeView:eh,onViewChange:e=>{"project-chat"!==e&&em(null),ef(e)},worktrees:ez,worktreesStale:eW,staleRemoteName:eH.staleRemote?.name??null,activeRemoteInvalid:eH.activeRemoteInvalid,selectedBranch:I,onBranchChange:rj,currentProject:eT,onCreateWorktreeOpen:()=>eo(!0),onDeleteWorktree:e=>{eu(e),ec(!0)},onManageWorkspaceRemotes:e=>rk(e),onAnchorRootWorkspace:async e=>{if(eT){try{await aC.api.anchorRootWorkspace(eT.id,e),xc.toast.success(`Main workspace anchored to ${e}`)}catch(e){xc.toast.error(e instanceof Error?e.message:"Failed to anchor workspace")}eU()}},onSetRootWorkspaceBranch:async e=>{if(eT){try{await aC.api.setRootWorkspaceBranch(eT.id,e),xc.toast.success(`Main workspace anchored to ${e}`)}catch(e){xc.toast.error(e instanceof Error?e.message:"Failed to change workspace branch")}eU()}},mergeStatuses:eV,mergeRootDirty:eq,mergeDefaultTarget:eK,mergeRepositoryLabel:eX,mergeRepositoryServerId:eY,onMergeTargetChange:eG,onMergeBadgeClick:e=>{F(e),ef("workspace"),ey(e=>e+1)},workspaceStatuses:tB,residentSessions:e2,selectedSessionId:e3?e3.reviewerSessionId:P,onResidentSessionSelect:re,hasProject:!rT,projects:eD,onSelectProject:eF,onCreateProjectOpen:()=>ei(!0),schedules:ts,selectedScheduleId:tc,onScheduleSelect:e=>{td(e),ef("schedules")},onCreateScheduleOpen:()=>{ef("schedules"),tv(!0)},tasks:e4,selectedTaskId:tf,onTasksOpen:()=>ef("tasks"),onTaskSelect:tw,onCreateTaskOpen:()=>{th({kind:"draft"}),ef("tasks")}}),(0,U.jsx)("div",{className:rT&&("workspace"===eh||"tasks"===eh||"project-info"===eh||"project-chat"===eh)?"flex-1 overflow-hidden":"hidden",children:(0,U.jsx)("div",{className:"h-full flex items-center justify-center bg-background",children:(0,U.jsxs)("div",{className:"text-center space-y-6",children:[(0,U.jsx)("div",{className:"mx-auto w-16 h-16 rounded-2xl bg-primary/10 flex items-center justify-center",children:eO?(0,U.jsx)(ou,{className:"h-8 w-8 text-destructive"}):(0,U.jsx)(oS,{className:"h-8 w-8 text-primary"})}),(0,U.jsx)("h1",{className:"text-3xl font-bold tracking-tight text-foreground",children:eO?"Project not found":"Welcome to VibeDeckX"}),(0,U.jsx)("p",{className:"text-muted-foreground max-w-sm mx-auto leading-relaxed",role:eO?"alert":void 0,children:eO?"This project does not exist or you do not have access to it.":"Create your first project to get started with AI-powered development."}),eO?(0,U.jsx)(a$.Button,{variant:"outline",size:"lg",onClick:()=>{let e=eD[0];e&&eF(e),window.history.replaceState(null,"",e?A4({projectId:e.id,tab:"project-info"}):"/"),window.dispatchEvent(new PopStateEvent("popstate")),ef("project-info"),em(null)},children:"Back to projects"}):(0,U.jsxs)(a$.Button,{variant:"accent",size:"lg",onClick:()=>ei(!0),className:"shadow-md",children:[(0,U.jsx)(oS,{className:"h-5 w-5 mr-2"}),"Create Project"]})]})})}),(0,U.jsx)("div",{className:"workspace"!==eh||rT?"hidden":"flex-1 overflow-hidden flex",children:(0,U.jsxs)(hu,{direction:"horizontal",autoSaveId:"workspace-panels",children:[(0,U.jsx)(uf,{ref:tN,defaultSize:33,minSize:25,collapsible:!0,collapsedSize:0,onCollapse:()=>tD(!0),onExpand:()=>tD(!1),children:(0,U.jsx)("div",{"data-focus-region":"default",className:"h-full flex flex-col overflow-hidden",children:(0,U.jsx)("div",{className:"flex-1 overflow-hidden",children:(0,U.jsx)(z3,{ref:tC,projectId:eT?.id??null,branch:I},`${eT?.id??""}:${I??""}`)})})}),(0,U.jsx)(hh,{}),(0,U.jsx)(uf,{defaultSize:67,minSize:25,children:(0,U.jsx)("div",{className:"h-full flex flex-col overflow-hidden",children:(0,U.jsx)(NR,{active:"workspace"===eh,agentSessionId:tz,onAgentTabActiveChange:tK,projectId:eT?.id??null,selectedBranch:I,activateAgentTabNonce:eg,diffCompareNonce:ev,terminalRequest:z,fileOpenRequest:W,forceAgentTab:eb,mergeTarget:I?df(eV.get(I))??eK:null,onMergeRequest:rN,project:eT,onExecutorModeChange:rD,agentSlot:(0,U.jsxs)(U.Fragment,{children:[e5&&er&&(0,U.jsx)(MX,{runId:er.runId,entry:e3,title:e3?M8(e3,e1(e3.sourceSessionId)):"Review",onOpenSource:(e,r)=>t6(r,e)}),(0,U.jsx)("div",{className:e5?"hidden":"contents",children:(0,U.jsx)(MK,{ref:ek,projectId:eT?.id??null,branch:I,sessionId:P,navPending:eb||e_||e5,preparingReviews:eZ.entries,onReviewStarted:eZ.addRun,onViewPreparingReview:rt,setSessionUrlParam:L,onActiveSessionChange:t$,onActiveSessionResultAtChange:tH,onActiveSessionTurnEndAtChange:tV,project:eT,onAgentModeChange:rE,onTaskCompleted:t4,onSessionStarted:rs,onSessionTitleUpdated:rn,onSessionSelected:$O.touchRecentSessionOpen,onStatusChange:t3,onNewConversation:ri,onOpenSchedule:e=>{td(e),ef("schedules")},onOpenTask:tb,taskSessionRequest:ro,onTaskSessionRequestHandled:()=>rl(null)})})]})})})})]})}),(0,U.jsx)("div",{className:"tasks"!==eh||rT?"hidden":"flex-1 overflow-hidden",children:(0,U.jsx)($L,{active:"tasks"===eh&&!rT,projectId:eT?.id??null,tasks:e4,loading:e6,worktrees:ez,onCreateTask:e7,onUpdateTask:e8,onDeleteTask:e9,onArchiveTask:te,onUnarchiveTask:tt,onOpenSourceSession:e=>{e.source_session_id&&(e.source_tool_use_id&&(TY={toolUseId:e.source_tool_use_id,at:Date.now()}),ef("workspace"),t6(e.source_session?.branch??null,e.source_session_id))},onStartSession:rc,onOpenFile:t8,openRequest:tu,onSelectedTaskChange:tp})}),"project-info"===eh&&!rT&&eT&&(0,U.jsx)("div",{className:"flex-1 overflow-hidden",children:(0,U.jsx)(ld,{project:eT,waitingCount:t5,onOpenProjectChatThread:rv,onOpenAgentSession:(e,r,s)=>{rg.openAgentSession(e,r,s)},onOpenScheduleRun:(e,r)=>{rg.openScheduleRun(e,r)},onRunScheduleAgain:rg.runScheduleAgain,onViewAllTasks:()=>ef("tasks"),onOpenTaskInTasks:tw,onProjectUpdated:eI})}),"project-chat"===eh&&!rT&&eT&&ep&&(0,U.jsx)("div",{className:"flex-1 overflow-hidden",children:(0,U.jsx)(dc,{projectId:eT.id,threadId:ep,projectName:eT.name,onBack:ry,onSelectThread:rv,onOpenContext:e=>{rx.open(e)},onOpenAgentSession:(e,r,s)=>rg.openAgentSession(e,r,s),onOpenScheduleRun:(e,r)=>rg.openScheduleRun(e,r),onRunScheduleAgain:rg.runScheduleAgain})}),"schedules"===eh&&!rT&&eT&&(0,U.jsx)("div",{className:"flex-1 overflow-hidden",children:(0,U.jsx)(mc,{projectId:eT?.id??"",hasLocal:!!eT?.path,schedules:ts,loading:tn,selectedId:tc,onSelect:td,worktrees:ez,onCreate:ti,onUpdate:ta,onDelete:async e=>{await to(e),tc===e&&td(null)},onOpenSourceSession:(e,r)=>{ef("workspace"),t6(e,r)},onRunNow:tl,createOpen:tx,onCreateOpenChange:tv,openRunId:tm,onOpenRunHandled:rb})}),"remote-servers"===eh&&(0,U.jsx)("div",{className:"flex-1 overflow-hidden",children:(0,U.jsxs)("div",{className:"h-full flex flex-col overflow-auto",children:[(0,U.jsx)(d8,{title:"Remote Servers"}),(0,U.jsx)("div",{className:"flex-1 px-6 py-5 flex justify-center",children:(0,U.jsx)("div",{className:"w-full max-w-2xl",children:(0,U.jsx)(xt,{})})})]})}),(0,U.jsx)("div",{className:"settings"!==eh?"hidden":"flex-1 overflow-hidden",children:(0,U.jsx)(gJ,{})})]}),eT&&(0,U.jsx)(xp,{projectId:eT.id,project:eT,open:ea,onOpenChange:e=>{eo(e),e||(K(void 0),G(void 0))},onWorktreeCreated:rS,initialBranchName:q?.branch??void 0,initialMachines:q?.machines,initialTargets:q?.targets,initialSelectedTargets:Y}),(0,U.jsx)(xm,{missing:Z,onOpenChange:e=>{e||Q(null)},onCreateHere:()=>{if(Q(null),!Z)return;let e=ez.find(e=>e.branch===Z.branch);e&&rk(e,[Z.current.serverId])},onOpenAnyway:()=>{Q(null),Z&&F(Z.branch)}}),(0,U.jsx)(aj,{task:ty,open:null!==ty,onOpenChange:e=>{e||tb(null)},onOpenInTasks:tw}),(0,U.jsx)(mm,{open:en,onOpenChange:ei,onProjectCreated:e=>{eA(e),ef("project-info")}}),eT&&(0,U.jsx)(xg,{projectId:eT.id,worktree:ed,open:el,onOpenChange:ec,onWorktreeDeleted:eU,onOpenTerminal:(e,r)=>{F(e),ef("workspace"),$(e=>({targetId:r,nonce:(e?.nonce??0)+1}))}}),(0,U.jsx)($z,{open:ru,onOpenChange:rh,onNavigateProject:rw,onNavigateWorkspace:rC,onNavigateSession:r_})]})})})})})}e.s(["default",()=>Wr],837031)}]);