@seqyuan/ennote 0.11.0 → 0.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/out/404.html +1 -1
  2. package/out/__next.__PAGE__.txt +2 -2
  3. package/out/__next._full.txt +3 -3
  4. package/out/__next._head.txt +1 -1
  5. package/out/__next._index.txt +2 -2
  6. package/out/__next._tree.txt +2 -2
  7. package/out/_next/static/chunks/{0zlw~jfgelr2b.css → 0eg_yb4trirx0.css} +1 -1
  8. package/out/_next/static/chunks/{0o7ss4k63_7hk.js → 0mz2vew-4vveh.js} +5 -5
  9. package/out/_not-found/__next._full.txt +2 -2
  10. package/out/_not-found/__next._head.txt +1 -1
  11. package/out/_not-found/__next._index.txt +2 -2
  12. package/out/_not-found/__next._not-found.__PAGE__.txt +1 -1
  13. package/out/_not-found/__next._not-found.txt +1 -1
  14. package/out/_not-found/__next._tree.txt +2 -2
  15. package/out/_not-found.html +1 -1
  16. package/out/_not-found.txt +2 -2
  17. package/out/graphs/__next._full.txt +3 -3
  18. package/out/graphs/__next._head.txt +1 -1
  19. package/out/graphs/__next._index.txt +2 -2
  20. package/out/graphs/__next._tree.txt +2 -2
  21. package/out/graphs/__next.graphs.__PAGE__.txt +2 -2
  22. package/out/graphs/__next.graphs.txt +1 -1
  23. package/out/graphs.html +1 -1
  24. package/out/graphs.txt +3 -3
  25. package/out/heroes/__next._full.txt +3 -3
  26. package/out/heroes/__next._head.txt +1 -1
  27. package/out/heroes/__next._index.txt +2 -2
  28. package/out/heroes/__next._tree.txt +2 -2
  29. package/out/heroes/__next.heroes.__PAGE__.txt +2 -2
  30. package/out/heroes/__next.heroes.txt +1 -1
  31. package/out/heroes.html +1 -1
  32. package/out/heroes.txt +3 -3
  33. package/out/index.html +2 -2
  34. package/out/index.txt +3 -3
  35. package/package.json +1 -1
  36. /package/out/_next/static/{u-t25M_EyETzPH8M74KP3 → EVJEG2nCXGjH2F5sin_rN}/_buildManifest.js +0 -0
  37. /package/out/_next/static/{u-t25M_EyETzPH8M74KP3 → EVJEG2nCXGjH2F5sin_rN}/_clientMiddlewareManifest.js +0 -0
  38. /package/out/_next/static/{u-t25M_EyETzPH8M74KP3 → EVJEG2nCXGjH2F5sin_rN}/_ssgManifest.js +0 -0
@@ -1,8 +1,8 @@
1
- (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,89163,e=>{e.v({empty:"ProjectMenu-module__rpY9Zq__empty",folder:"ProjectMenu-module__rpY9Zq__folder",name:"ProjectMenu-module__rpY9Zq__name",pin:"ProjectMenu-module__rpY9Zq__pin",row:"ProjectMenu-module__rpY9Zq__row",select:"ProjectMenu-module__rpY9Zq__select"})},81938,e=>{e.v({chevron:"ProjectSelector-module__RVW5Pa__chevron",folder:"ProjectSelector-module__RVW5Pa__folder",label:"ProjectSelector-module__RVW5Pa__label",root:"ProjectSelector-module__RVW5Pa__root",trigger:"ProjectSelector-module__RVW5Pa__trigger"})},54145,e=>{e.v({dot:"ChatRail-module__LizpSa__dot",marker:"ChatRail-module__LizpSa__marker",preview:"ChatRail-module__LizpSa__preview",previewIndex:"ChatRail-module__LizpSa__previewIndex",previewText:"ChatRail-module__LizpSa__previewText",rail:"ChatRail-module__LizpSa__rail",track:"ChatRail-module__LizpSa__track"})},2668,e=>{e.v({action:"SelectionActions-module__wrs5DG__action",toolbar:"SelectionActions-module__wrs5DG__toolbar"})},26568,(e,t,n)=>{"use strict";var a=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,s=/\n/g,i=/^\s*/,r=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,l=/^:\s*/,o=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,c=/^[;\s]*/,d=/^\s+|\s+$/g;function u(e){return e?e.replace(d,""):""}t.exports=function(e,t){if("string"!=typeof e)throw TypeError("First argument must be a string");if(!e)return[];t=t||{};var n=1,d=1;function p(e){var t=e.match(s);t&&(n+=t.length);var a=e.lastIndexOf("\n");d=~a?e.length-a:d+e.length}function h(){var e={line:n,column:d};return function(t){return t.position=new m(e),g(i),t}}function m(e){this.start=e,this.end={line:n,column:d},this.source=t.source}function f(a){var s=Error(t.source+":"+n+":"+d+": "+a);if(s.reason=a,s.filename=t.source,s.line=n,s.column=d,s.source=e,t.silent);else throw s}function g(t){var n=t.exec(e);if(n){var a=n[0];return p(a),e=e.slice(a.length),n}}function x(e){var t;for(e=e||[];t=v();)!1!==t&&e.push(t);return e}function v(){var t=h();if("/"==e.charAt(0)&&"*"==e.charAt(1)){for(var n=2;""!=e.charAt(n)&&("*"!=e.charAt(n)||"/"!=e.charAt(n+1));)++n;if(n+=2,""===e.charAt(n-1))return f("End of comment missing");var a=e.slice(2,n-2);return d+=2,p(a),e=e.slice(n),d+=2,t({type:"comment",comment:a})}}m.prototype.content=e,g(i);var y,b=[];for(x(b);y=function(){var e=h(),t=g(r);if(t){if(v(),!g(l))return f("property missing ':'");var n=g(o),s=e({type:"declaration",property:u(t[0].replace(a,"")),value:n?u(n[0].replace(a,"")):""});return g(c),s}}();)!1!==y&&(b.push(y),x(b));return b}},30070,(e,t,n)=>{"use strict";var a=e.e&&e.e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(n,"__esModule",{value:!0}),n.default=function(e,t){let n=null;if(!e||"string"!=typeof e)return n;let a=(0,s.default)(e),i="function"==typeof t;return a.forEach(e=>{if("declaration"!==e.type)return;let{property:a,value:s}=e;i?t(a,s,e):s&&((n=n||{})[a]=s)}),n};let s=a(e.r(26568))},65185,(e,t,n)=>{"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.camelCase=void 0;var a=/^--[a-zA-Z0-9_-]+$/,s=/-([a-z])/g,i=/^[^-]+$/,r=/^-(webkit|moz|ms|o|khtml)-/,l=/^-(ms)-/,o=function(e,t){return t.toUpperCase()},c=function(e,t){return"".concat(t,"-")};n.camelCase=function(e,t){var n;return(void 0===t&&(t={}),!(n=e)||i.test(n)||a.test(n))?e:(e=e.toLowerCase(),(e=t.reactCompat?e.replace(l,c):e.replace(r,c)).replace(s,o))}},15511,(e,t,n)=>{"use strict";var a=(e.e&&e.e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}})(e.r(30070)),s=e.r(65185);function i(e,t){var n={};return e&&"string"==typeof e&&(0,a.default)(e,function(e,a){e&&a&&(n[(0,s.camelCase)(e,t)]=a)}),n}i.default=i,t.exports=i},4100,(e,t,n)=>{"use strict";var a=Object.prototype.hasOwnProperty,s=Object.prototype.toString,i=Object.defineProperty,r=Object.getOwnPropertyDescriptor,l=function(e){return"function"==typeof Array.isArray?Array.isArray(e):"[object Array]"===s.call(e)},o=function(e){if(!e||"[object Object]"!==s.call(e))return!1;var t,n=a.call(e,"constructor"),i=e.constructor&&e.constructor.prototype&&a.call(e.constructor.prototype,"isPrototypeOf");if(e.constructor&&!n&&!i)return!1;for(t in e);return void 0===t||a.call(e,t)},c=function(e,t){i&&"__proto__"===t.name?i(e,t.name,{enumerable:!0,configurable:!0,value:t.newValue,writable:!0}):e[t.name]=t.newValue},d=function(e,t){if("__proto__"===t){if(!a.call(e,t))return;else if(r)return r(e,t).value}return e[t]};t.exports=function e(){var t,n,a,s,i,r,u=arguments[0],p=1,h=arguments.length,m=!1;for("boolean"==typeof u&&(m=u,u=arguments[1]||{},p=2),(null==u||"object"!=typeof u&&"function"!=typeof u)&&(u={});p<h;++p)if(t=arguments[p],null!=t)for(n in t)a=d(u,n),u!==(s=d(t,n))&&(m&&s&&(o(s)||(i=l(s)))?(i?(i=!1,r=a&&l(a)?a:[]):r=a&&o(a)?a:{},c(u,{name:n,newValue:e(m,r,s)})):void 0!==s&&c(u,{name:n,newValue:s}));return u}},8823,e=>{e.v({actions:"QuestionCard-module__TPAdWW__actions",answered:"QuestionCard-module__TPAdWW__answered",card:"QuestionCard-module__TPAdWW__card",header:"QuestionCard-module__TPAdWW__header",hint:"QuestionCard-module__TPAdWW__hint",icon:"QuestionCard-module__TPAdWW__icon",option:"QuestionCard-module__TPAdWW__option",options:"QuestionCard-module__TPAdWW__options",otherInput:"QuestionCard-module__TPAdWW__otherInput",question:"QuestionCard-module__TPAdWW__question",questions:"QuestionCard-module__TPAdWW__questions",submit:"QuestionCard-module__TPAdWW__submit"})},6929,e=>{e.v({badge:"primitives-module__BWnyvW__badge",badgeAccent:"primitives-module__BWnyvW__badgeAccent",badgeDanger:"primitives-module__BWnyvW__badgeDanger",badgeNeutral:"primitives-module__BWnyvW__badgeNeutral",badgeSuccess:"primitives-module__BWnyvW__badgeSuccess",badgeWarning:"primitives-module__BWnyvW__badgeWarning",banner:"primitives-module__BWnyvW__banner",bannerDanger:"primitives-module__BWnyvW__bannerDanger",bannerNeutral:"primitives-module__BWnyvW__bannerNeutral",bannerSuccess:"primitives-module__BWnyvW__bannerSuccess",bannerWarning:"primitives-module__BWnyvW__bannerWarning",button:"primitives-module__BWnyvW__button",card:"primitives-module__BWnyvW__card",cardElevated:"primitives-module__BWnyvW__cardElevated",cardPad:"primitives-module__BWnyvW__cardPad",danger:"primitives-module__BWnyvW__danger",emptyAction:"primitives-module__BWnyvW__emptyAction",emptyDescription:"primitives-module__BWnyvW__emptyDescription",emptyState:"primitives-module__BWnyvW__emptyState",emptyTitle:"primitives-module__BWnyvW__emptyTitle",ghost:"primitives-module__BWnyvW__ghost",iconButton:"primitives-module__BWnyvW__iconButton",iconButtonSm:"primitives-module__BWnyvW__iconButtonSm",md:"primitives-module__BWnyvW__md",primary:"primitives-module__BWnyvW__primary",secondary:"primitives-module__BWnyvW__secondary",sm:"primitives-module__BWnyvW__sm"})},86609,e=>{e.v({actions:"confirm-module__5IFLza__actions",description:"confirm-module__5IFLza__description",dialog:"confirm-module__5IFLza__dialog",overlay:"confirm-module__5IFLza__overlay",title:"confirm-module__5IFLza__title"})},51535,e=>{e.v({bar:"TabBar-module__VnsErG__bar",close:"TabBar-module__VnsErG__close",icon:"TabBar-module__VnsErG__icon",label:"TabBar-module__VnsErG__label",tab:"TabBar-module__VnsErG__tab"})},73574,e=>{e.v({backdrop:"RightPanelLanes-module__CJ4Bja__backdrop",body:"RightPanelLanes-module__CJ4Bja__body",inspector:"RightPanelLanes-module__CJ4Bja__inspector",lanes:"RightPanelLanes-module__CJ4Bja__lanes",narrow:"RightPanelLanes-module__CJ4Bja__narrow","nav-toggle":"RightPanelLanes-module__CJ4Bja__nav-toggle",primary:"RightPanelLanes-module__CJ4Bja__primary","primary-overlay":"RightPanelLanes-module__CJ4Bja__primary-overlay",strip:"RightPanelLanes-module__CJ4Bja__strip"})},57840,e=>{e.v({card:"GraphActivityPanel-module__1FpL5W__card",cardButton:"GraphActivityPanel-module__1FpL5W__cardButton",cardSummary:"GraphActivityPanel-module__1FpL5W__cardSummary",cardTitle:"GraphActivityPanel-module__1FpL5W__cardTitle",chevron:"GraphActivityPanel-module__1FpL5W__chevron",details:"GraphActivityPanel-module__1FpL5W__details",empty:"GraphActivityPanel-module__1FpL5W__empty",error:"GraphActivityPanel-module__1FpL5W__error",flowDot:"GraphActivityPanel-module__1FpL5W__flowDot",header:"GraphActivityPanel-module__1FpL5W__header",meta:"GraphActivityPanel-module__1FpL5W__meta",nodeDot:"GraphActivityPanel-module__1FpL5W__nodeDot",nodeList:"GraphActivityPanel-module__1FpL5W__nodeList",nodeName:"GraphActivityPanel-module__1FpL5W__nodeName",nodeRow:"GraphActivityPanel-module__1FpL5W__nodeRow",nodeState:"GraphActivityPanel-module__1FpL5W__nodeState",pulse:"GraphActivityPanel-module__1FpL5W__pulse",pulseDot:"GraphActivityPanel-module__1FpL5W__pulseDot",root:"GraphActivityPanel-module__1FpL5W__root",running:"GraphActivityPanel-module__1FpL5W__running",scroll:"GraphActivityPanel-module__1FpL5W__scroll",stateDot:"GraphActivityPanel-module__1FpL5W__stateDot",stateLine:"GraphActivityPanel-module__1FpL5W__stateLine",title:"GraphActivityPanel-module__1FpL5W__title"})},26694,e=>{e.v({badge:"RunInspectorPanel-module__lAUECa__badge",body:"RunInspectorPanel-module__lAUECa__body",catalogLabel:"RunInspectorPanel-module__lAUECa__catalogLabel",catalogRow:"RunInspectorPanel-module__lAUECa__catalogRow",catalogValue:"RunInspectorPanel-module__lAUECa__catalogValue",digest:"RunInspectorPanel-module__lAUECa__digest",digestGroup:"RunInspectorPanel-module__lAUECa__digestGroup",digestLabel:"RunInspectorPanel-module__lAUECa__digestLabel",digestLine:"RunInspectorPanel-module__lAUECa__digestLine",digestValue:"RunInspectorPanel-module__lAUECa__digestValue",empty:"RunInspectorPanel-module__lAUECa__empty",entryBlock:"RunInspectorPanel-module__lAUECa__entryBlock",entryLabel:"RunInspectorPanel-module__lAUECa__entryLabel",entryPre:"RunInspectorPanel-module__lAUECa__entryPre",entrySummary:"RunInspectorPanel-module__lAUECa__entrySummary",group:"RunInspectorPanel-module__lAUECa__group",heading:"RunInspectorPanel-module__lAUECa__heading",headingCount:"RunInspectorPanel-module__lAUECa__headingCount",loadOlder:"RunInspectorPanel-module__lAUECa__loadOlder",mcpBinding:"RunInspectorPanel-module__lAUECa__mcpBinding",mcpHead:"RunInspectorPanel-module__lAUECa__mcpHead",mcpIdentity:"RunInspectorPanel-module__lAUECa__mcpIdentity",mcpInstructions:"RunInspectorPanel-module__lAUECa__mcpInstructions",mcpInstructionsBody:"RunInspectorPanel-module__lAUECa__mcpInstructionsBody",mcpProtocol:"RunInspectorPanel-module__lAUECa__mcpProtocol",mcpRevision:"RunInspectorPanel-module__lAUECa__mcpRevision",mcpRow:"RunInspectorPanel-module__lAUECa__mcpRow",mcpTools:"RunInspectorPanel-module__lAUECa__mcpTools",mcpUnavailable:"RunInspectorPanel-module__lAUECa__mcpUnavailable",muted:"RunInspectorPanel-module__lAUECa__muted",privateBadge:"RunInspectorPanel-module__lAUECa__privateBadge",promptBytes:"RunInspectorPanel-module__lAUECa__promptBytes",promptPre:"RunInspectorPanel-module__lAUECa__promptPre",promptToggle:"RunInspectorPanel-module__lAUECa__promptToggle",runId:"RunInspectorPanel-module__lAUECa__runId",sectionBytes:"RunInspectorPanel-module__lAUECa__sectionBytes",sectionDigest:"RunInspectorPanel-module__lAUECa__sectionDigest",sectionId:"RunInspectorPanel-module__lAUECa__sectionId",sectionIdentity:"RunInspectorPanel-module__lAUECa__sectionIdentity",sectionKind:"RunInspectorPanel-module__lAUECa__sectionKind",sectionRow:"RunInspectorPanel-module__lAUECa__sectionRow",sectionSource:"RunInspectorPanel-module__lAUECa__sectionSource",selectedSkills:"RunInspectorPanel-module__lAUECa__selectedSkills",toolList:"RunInspectorPanel-module__lAUECa__toolList",toolName:"RunInspectorPanel-module__lAUECa__toolName",toolRisk:"RunInspectorPanel-module__lAUECa__toolRisk",toolRow:"RunInspectorPanel-module__lAUECa__toolRow",transcriptBody:"RunInspectorPanel-module__lAUECa__transcriptBody",transcriptExcerpt:"RunInspectorPanel-module__lAUECa__transcriptExcerpt",transcriptNote:"RunInspectorPanel-module__lAUECa__transcriptNote",transcriptOrdinal:"RunInspectorPanel-module__lAUECa__transcriptOrdinal",transcriptRole:"RunInspectorPanel-module__lAUECa__transcriptRole",transcriptRow:"RunInspectorPanel-module__lAUECa__transcriptRow",transcriptSummary:"RunInspectorPanel-module__lAUECa__transcriptSummary"})},67203,e=>{e.v({actionId:"PacksPanel-module__e1KI0q__actionId",actionList:"PacksPanel-module__e1KI0q__actionList",actionRow:"PacksPanel-module__e1KI0q__actionRow",actionVerb:"PacksPanel-module__e1KI0q__actionVerb",actions:"PacksPanel-module__e1KI0q__actions",badge:"PacksPanel-module__e1KI0q__badge",button:"PacksPanel-module__e1KI0q__button",card:"PacksPanel-module__e1KI0q__card",cardHead:"PacksPanel-module__e1KI0q__cardHead",cardName:"PacksPanel-module__e1KI0q__cardName",counts:"PacksPanel-module__e1KI0q__counts",digest:"PacksPanel-module__e1KI0q__digest",empty:"PacksPanel-module__e1KI0q__empty",heading:"PacksPanel-module__e1KI0q__heading",iconButton:"PacksPanel-module__e1KI0q__iconButton",identity:"PacksPanel-module__e1KI0q__identity",installer:"PacksPanel-module__e1KI0q__installer",issueList:"PacksPanel-module__e1KI0q__issueList",issueRow:"PacksPanel-module__e1KI0q__issueRow",meta:"PacksPanel-module__e1KI0q__meta",name:"PacksPanel-module__e1KI0q__name",note:"PacksPanel-module__e1KI0q__note",pathInput:"PacksPanel-module__e1KI0q__pathInput",pathLabel:"PacksPanel-module__e1KI0q__pathLabel",primary:"PacksPanel-module__e1KI0q__primary",row:"PacksPanel-module__e1KI0q__row",sectionCount:"PacksPanel-module__e1KI0q__sectionCount",sectionHeader:"PacksPanel-module__e1KI0q__sectionHeader",stack:"PacksPanel-module__e1KI0q__stack",titleRow:"PacksPanel-module__e1KI0q__titleRow"})},82399,e=>{e.v({accent:"McpPanels-module__e-NKfa__accent",actions:"McpPanels-module__e-NKfa__actions",addButton:"McpPanels-module__e-NKfa__addButton",archiveButton:"McpPanels-module__e-NKfa__archiveButton",bindings:"McpPanels-module__e-NKfa__bindings",boundBadge:"McpPanels-module__e-NKfa__boundBadge",candidateActions:"McpPanels-module__e-NKfa__candidateActions",candidateGroup:"McpPanels-module__e-NKfa__candidateGroup",candidateIdentity:"McpPanels-module__e-NKfa__candidateIdentity",candidateMeta:"McpPanels-module__e-NKfa__candidateMeta",candidateName:"McpPanels-module__e-NKfa__candidateName",candidateRow:"McpPanels-module__e-NKfa__candidateRow",candidateSource:"McpPanels-module__e-NKfa__candidateSource",card:"McpPanels-module__e-NKfa__card",cardHead:"McpPanels-module__e-NKfa__cardHead",cardIdentity:"McpPanels-module__e-NKfa__cardIdentity",cardMeta:"McpPanels-module__e-NKfa__cardMeta",cardTitle:"McpPanels-module__e-NKfa__cardTitle",catalogEmpty:"McpPanels-module__e-NKfa__catalogEmpty",catalogScroll:"McpPanels-module__e-NKfa__catalogScroll",catalogTable:"McpPanels-module__e-NKfa__catalogTable",commandSummary:"McpPanels-module__e-NKfa__commandSummary",createButton:"McpPanels-module__e-NKfa__createButton",credentialEnv:"McpPanels-module__e-NKfa__credentialEnv",credentialEnvInput:"McpPanels-module__e-NKfa__credentialEnvInput",credentialInputRow:"McpPanels-module__e-NKfa__credentialInputRow",credentialNote:"McpPanels-module__e-NKfa__credentialNote",credentialRef:"McpPanels-module__e-NKfa__credentialRef",credentialRefInput:"McpPanels-module__e-NKfa__credentialRefInput",credentialRow:"McpPanels-module__e-NKfa__credentialRow",credentials:"McpPanels-module__e-NKfa__credentials",danger:"McpPanels-module__e-NKfa__danger",diffBody:"McpPanels-module__e-NKfa__diffBody",diffCard:"McpPanels-module__e-NKfa__diffCard",diffDigest:"McpPanels-module__e-NKfa__diffDigest",diffLine:"McpPanels-module__e-NKfa__diffLine",diffTitle:"McpPanels-module__e-NKfa__diffTitle",diffUnchanged:"McpPanels-module__e-NKfa__diffUnchanged",emptyText:"McpPanels-module__e-NKfa__emptyText",enableButton:"McpPanels-module__e-NKfa__enableButton",field:"McpPanels-module__e-NKfa__field",form:"McpPanels-module__e-NKfa__form",formGrid:"McpPanels-module__e-NKfa__formGrid",ghostButton:"McpPanels-module__e-NKfa__ghostButton",input:"McpPanels-module__e-NKfa__input",list:"McpPanels-module__e-NKfa__list",loadingText:"McpPanels-module__e-NKfa__loadingText",requiredButton:"McpPanels-module__e-NKfa__requiredButton",sectionHeader:"McpPanels-module__e-NKfa__sectionHeader",settingsDescription:"McpPanels-module__e-NKfa__settingsDescription",settingsHeader:"McpPanels-module__e-NKfa__settingsHeader",settingsRoot:"McpPanels-module__e-NKfa__settingsRoot",settingsTitle:"McpPanels-module__e-NKfa__settingsTitle",toolCheckCell:"McpPanels-module__e-NKfa__toolCheckCell",toolCheckbox:"McpPanels-module__e-NKfa__toolCheckbox",toolDescriptionCell:"McpPanels-module__e-NKfa__toolDescriptionCell",toolNameCell:"McpPanels-module__e-NKfa__toolNameCell",toolRow:"McpPanels-module__e-NKfa__toolRow",toolSearch:"McpPanels-module__e-NKfa__toolSearch",toolsHeader:"McpPanels-module__e-NKfa__toolsHeader",toolsHint:"McpPanels-module__e-NKfa__toolsHint",transportButton:"McpPanels-module__e-NKfa__transportButton",transportRow:"McpPanels-module__e-NKfa__transportRow"})},90239,e=>{e.v({actionRow:"SkillPanels-module__k8YHlG__actionRow",badge:"SkillPanels-module__k8YHlG__badge",catalogName:"SkillPanels-module__k8YHlG__catalogName",catalogRow:"SkillPanels-module__k8YHlG__catalogRow",danger:"SkillPanels-module__k8YHlG__danger",diagList:"SkillPanels-module__k8YHlG__diagList",diagRow:"SkillPanels-module__k8YHlG__diagRow",diagTitle:"SkillPanels-module__k8YHlG__diagTitle",diagnostics:"SkillPanels-module__k8YHlG__diagnostics",empty:"SkillPanels-module__k8YHlG__empty",ghostButton:"SkillPanels-module__k8YHlG__ghostButton",input:"SkillPanels-module__k8YHlG__input",inputName:"SkillPanels-module__k8YHlG__inputName",inputPreset:"SkillPanels-module__k8YHlG__inputPreset",inputRow:"SkillPanels-module__k8YHlG__inputRow",inputScope:"SkillPanels-module__k8YHlG__inputScope",installButton:"SkillPanels-module__k8YHlG__installButton",installedActions:"SkillPanels-module__k8YHlG__installedActions",installedCard:"SkillPanels-module__k8YHlG__installedCard",installedDescription:"SkillPanels-module__k8YHlG__installedDescription",installedHead:"SkillPanels-module__k8YHlG__installedHead",installedIdentity:"SkillPanels-module__k8YHlG__installedIdentity",installedMeta:"SkillPanels-module__k8YHlG__installedMeta",installedName:"SkillPanels-module__k8YHlG__installedName",installedTitleRow:"SkillPanels-module__k8YHlG__installedTitleRow",link:"SkillPanels-module__k8YHlG__link",linkIcon:"SkillPanels-module__k8YHlG__linkIcon",market:"SkillPanels-module__k8YHlG__market",marketTitle:"SkillPanels-module__k8YHlG__marketTitle",mono:"SkillPanels-module__k8YHlG__mono",note:"SkillPanels-module__k8YHlG__note",primaryButton:"SkillPanels-module__k8YHlG__primaryButton",resultInstalls:"SkillPanels-module__k8YHlG__resultInstalls",resultPackage:"SkillPanels-module__k8YHlG__resultPackage",resultRow:"SkillPanels-module__k8YHlG__resultRow",rootForm:"SkillPanels-module__k8YHlG__rootForm",rootIdentity:"SkillPanels-module__k8YHlG__rootIdentity",rootName:"SkillPanels-module__k8YHlG__rootName",rootPath:"SkillPanels-module__k8YHlG__rootPath",rootPriority:"SkillPanels-module__k8YHlG__rootPriority",rootRow:"SkillPanels-module__k8YHlG__rootRow",rootTitleRow:"SkillPanels-module__k8YHlG__rootTitleRow",searchRow:"SkillPanels-module__k8YHlG__searchRow",sectionCount:"SkillPanels-module__k8YHlG__sectionCount",sectionHeader:"SkillPanels-module__k8YHlG__sectionHeader",stack:"SkillPanels-module__k8YHlG__stack",statusError:"SkillPanels-module__k8YHlG__statusError",statusText:"SkillPanels-module__k8YHlG__statusText",toggle:"SkillPanels-module__k8YHlG__toggle",updateBadge:"SkillPanels-module__k8YHlG__updateBadge",warning:"SkillPanels-module__k8YHlG__warning"})},48686,e=>{e.v({banner:"OfflineBanner-module__byd1va__banner"})},59665,e=>{"use strict";var t=e.i(18050),n=e.i(71645);let a=(...e)=>e.filter((e,t,n)=>!!e&&""!==e.trim()&&n.indexOf(e)===t).join(" ").trim(),s=e=>{let t=e.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,t,n)=>n?n.toUpperCase():t.toLowerCase());return t.charAt(0).toUpperCase()+t.slice(1)};var i={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};let r=(0,n.createContext)({}),l=(0,n.forwardRef)(({color:e,size:t,strokeWidth:s,absoluteStrokeWidth:l,className:o="",children:c,iconNode:d,...u},p)=>{let{size:h=24,strokeWidth:m=2,absoluteStrokeWidth:f=!1,color:g="currentColor",className:x=""}=(0,n.useContext)(r)??{},v=l??f?24*Number(s??m)/Number(t??h):s??m;return(0,n.createElement)("svg",{ref:p,...i,width:t??h??i.width,height:t??h??i.height,stroke:e??g,strokeWidth:v,className:a("lucide",x,o),...!c&&!(e=>{for(let t in e)if(t.startsWith("aria-")||"role"===t||"title"===t)return!0;return!1})(u)&&{"aria-hidden":"true"},...u},[...d.map(([e,t])=>(0,n.createElement)(e,t)),...Array.isArray(c)?c:[c]])}),o=(e,t)=>{let i=(0,n.forwardRef)(({className:i,...r},o)=>(0,n.createElement)(l,{ref:o,iconNode:t,className:a(`lucide-${s(e).replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}`,`lucide-${e}`,i),...r}));return i.displayName=s(e),i},c=o("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"}]]),d=o("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"}]]),u=o("search",[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]]),p=o("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"}]]),h=o("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"}]]),m=o("x",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);var f=e.i(27437);let g=o("panel-left",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}]]);function x({size:e=24}){return(0,t.jsxs)("svg",{width:e,height:e,viewBox:"0 0 32 32",fill:"none","aria-hidden":"true",focusable:"false",children:[(0,t.jsx)("rect",{x:"1",y:"1",width:"30",height:"30",rx:"9",fill:"currentColor",opacity:"0.10"}),(0,t.jsx)("path",{d:"M11 9.5h10.5M11 16h8M11 22.5h10.5M11 9.5v13",stroke:"currentColor",strokeWidth:"2.4",strokeLinecap:"round",strokeLinejoin:"round"})]})}function v(e){let{onToggleSidebar:n,onCloseNavigation:a}=e,s=(0,f.useT)();return(0,t.jsxs)("div",{className:"sidebar-logo-row",children:[(0,t.jsx)("div",{className:"sidebar-brand",children:(0,t.jsxs)("span",{className:"sidebar-brand-identity",children:[(0,t.jsx)("span",{className:"brand-mark",children:(0,t.jsx)(x,{size:20})}),(0,t.jsx)("span",{className:"sidebar-brand-name",children:"Ennote"})]})}),(0,t.jsx)("button",{type:"button",className:"sidebar-collapse-toggle",onClick:n,title:s("sidebar.collapse"),"aria-label":s("sidebar.collapseNav"),"aria-expanded":"true","aria-controls":"workspace-navigation",children:(0,t.jsx)(g,{size:16,"aria-hidden":"true"})}),(0,t.jsx)("button",{type:"button",className:"sidebar-close-nav navigation-close",onClick:a,"aria-label":s("sidebar.closeNav"),children:(0,t.jsx)(m,{size:15,"aria-hidden":"true"})})]})}let y=o("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"}]]);function b(e){let{disabled:n,onClick:a}=e,s=(0,f.useT)();return(0,t.jsxs)("button",{type:"button",className:"sidebar-new-session",disabled:n,onClick:a,"aria-label":s("sidebar.newChatAria"),title:s(n?"sidebar.selectProjectFirst":"sidebar.newChatAria"),children:[(0,t.jsx)(y,{size:15,"aria-hidden":"true"}),(0,t.jsx)("span",{children:s("sidebar.newChat")})]})}function k({active:e,label:n,icon:a,onClick:s}){return(0,t.jsxs)("button",{type:"button",className:`sidebar-nav-item ${e?"active":""}`,"aria-current":e?"page":void 0,onClick:s,children:[(0,t.jsx)("span",{className:"nav-icon",children:a}),(0,t.jsx)("span",{children:n})]})}let j=o("chevron-right",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]),w=o("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"}]]),_=o("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"}]]),N=o("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"}]]),C=o("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"}]]),S=o("plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]),I=o("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"}]]),P=o("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"}]]),T=null;function M(e,t,{id:a,dismissOnEscape:s=!0,restoreFocus:i=!0}={}){let r=(0,n.useId)(),l=a??r,o=(0,n.useRef)(t),c=(0,n.useRef)(!1);(0,n.useEffect)(()=>{o.current=t}),(0,n.useEffect)(()=>{var t;let n,a,r,d;if(!e)return;let u=document.activeElement instanceof HTMLElement?document.activeElement:null;c.current=i;let p=(null===T&&(t=window,n=[],a=!1,r=e=>{if("Escape"!==e.key||e.defaultPrevented||e.isComposing)return;let t=n[n.length-1];t&&!1!==t.dismissOnEscape&&(e.preventDefault(),t.onDismiss())},d=()=>{t&&a&&(t.removeEventListener("keydown",r),a=!1)},T={push(e){(n=n.filter(t=>t.id!==e.id)).push(e),t&&!a&&(t.addEventListener("keydown",r),a=!0);let s=!1;return()=>{s||(s=!0,0===(n=n.filter(t=>t!==e)).length&&d())}},dismissTop(e){let t=n[n.length-1];return!!t&&!1!==t.dismissOnEscape&&(e?.preventDefault(),t.onDismiss(),!0)},reset(){n=[],d()},size:()=>n.length}),T).push({id:l,dismissOnEscape:s,onDismiss:()=>o.current()});return()=>{p(),c.current&&u?.isConnected&&u.focus()}},[e,l,s,i])}var R=e.i(19172);function E({title:e,initialName:a,onCancel:s,onConfirm:i}){let[r,l]=(0,n.useState)(a),[o,c]=(0,n.useState)(!1),[d,u]=(0,n.useState)(null),p=(0,n.useRef)(null),h=(0,f.useT)();(0,n.useEffect)(()=>{p.current?.select()},[]);let m=r.trim(),g=o||""===m||m===a,x=async()=>{if(!g){c(!0),u(null);try{await i(m)}catch(e){u(e.message),c(!1)}}};return(0,t.jsx)("div",{className:"sb-dialog-overlay",onPointerDown:e=>{e.target!==e.currentTarget||o||s()},children:(0,t.jsxs)("div",{className:"sb-dialog",role:"dialog","aria-modal":"true","aria-label":e,children:[(0,t.jsx)("h3",{children:e}),(0,t.jsx)("input",{ref:p,className:"sb-dialog-input",value:r,disabled:o,onChange:e=>l(e.target.value),onKeyDown:e=>{"Enter"===e.key&&x(),"Escape"!==e.key||e.nativeEvent.isComposing||(e.stopPropagation(),s())}}),d&&(0,t.jsx)("div",{className:"sb-dialog-error",role:"alert",children:d}),(0,t.jsxs)("div",{className:"sb-dialog-actions",children:[(0,t.jsx)("button",{type:"button",onClick:s,disabled:o,children:h("sidebar.cancel")}),(0,t.jsx)("button",{type:"button",className:"sb-primary",onClick:x,disabled:g,children:h("sidebar.save")})]})]})})}let A=o("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"}]]),$=o("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 z(e){let t=new Map(e.map(e=>[e.id,{session:e,children:[]}])),n=[];for(let e of t.values()){let a=e.session.sourceSessionId;if(!a||!t.has(a)||function(e,t,n){let a=new Set([e]),s=t;for(;s;){if(a.has(s))return!0;a.add(s),s=n.get(s)?.session.sourceSessionId}return!1}(e.session.id,a,t)){n.push(e);continue}t.get(a).children.push(e)}let a=e=>{e.sort((e,t)=>t.session.updatedAt.localeCompare(e.session.updatedAt)),e.forEach(e=>a(e.children))};return a(n),n}function F(e,n,a,s,i,r,l,o,c,d){return e.flatMap(e=>{let u=e.session,p=u.id===n,h=d?.has(u.id);return[(0,t.jsx)(L,{session:u,view:s,isSelected:p,isRunning:h,depth:c,mutatingId:o,switchSession:a,archiveSession:i,restoreSession:r,renameSession:l},u.id),...F(e.children,n,a,s,i,r,l,o,c+1,d)]})}function L({session:e,view:a,isSelected:s,isRunning:i,depth:r,mutatingId:l,switchSession:o,archiveSession:c,restoreSession:d,renameSession:u}){var p;let h,[m,g]=(0,n.useState)(!1),[x,v]=(0,n.useState)(!1);M(m,()=>g(!1));let y=(0,n.useRef)(null),b=(0,f.useT)();return(0,n.useEffect)(()=>{if(!m)return;let e=e=>{y.current?.contains(e.target)||g(!1)};return document.addEventListener("pointerdown",e),()=>document.removeEventListener("pointerdown",e)},[m]),(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("li",{className:`sb-session-row${s?" sb-selected":""}${m?" sb-menu-open":""}`,style:{marginLeft:22*r},children:[(0,t.jsxs)("div",{className:"sb-session-body",role:"button",tabIndex:0,"aria-current":s?"page":void 0,"aria-label":(0,R.isBlankSession)(e)?b("sidebar.newSession"):e.title,onClick:()=>"active"===a&&o(e.id),onKeyDown:t=>{("Enter"===t.key||" "===t.key)&&"active"===a&&(t.preventDefault(),o(e.id))},children:[(0,t.jsx)("span",{className:"sb-row-slot sb-session-status",children:i&&(0,t.jsx)("span",{className:"sb-running-dot","aria-hidden":"true"})}),(0,t.jsx)("span",{className:"sb-session-title",children:(0,R.isBlankSession)(e)?b("sidebar.newSession"):e.title}),(0,t.jsx)("span",{className:"sb-session-time","aria-hidden":"true",children:(p=e.updatedAt,(h=Math.max(0,Date.now()-new Date(p).getTime()))<6e4?b("time.now"):h<36e5?`${Math.floor(h/6e4)}${b("time.minutes")}`:h<864e5?`${Math.floor(h/36e5)}${b("time.hours")}`:h<2592e6?`${Math.floor(h/864e5)}${b("time.days")}`:h<31536e6?`${Math.floor(h/2592e6)}${b("time.months")}`:`${Math.floor(h/31536e6)}${b("time.years")}`)})]}),(0,t.jsxs)("span",{className:"sb-row-actions",ref:y,children:[(0,t.jsx)("button",{type:"button",className:"sb-row-icon-btn","aria-label":`Actions for ${e.title}`,"aria-haspopup":"menu","aria-expanded":m,onClick:e=>{e.stopPropagation(),g(e=>!e)},children:(0,t.jsx)(N,{size:15,"aria-hidden":"true"})}),m&&(0,t.jsxs)("div",{className:"sb-row-menu",role:"menu",children:[(0,t.jsxs)("button",{type:"button",role:"menuitem",disabled:l===e.id||"archived"===a,onClick:e=>{e.stopPropagation(),g(!1),v(!0)},children:[(0,t.jsx)(C,{size:13,"aria-hidden":"true"})," ",b("sidebar.renameSession")]}),(0,t.jsxs)("button",{type:"button",role:"menuitem",disabled:l===e.id,onClick:t=>{t.stopPropagation(),g(!1),"active"===a?c(e):d(e)},children:["active"===a?(0,t.jsx)(A,{size:13,"aria-hidden":"true"}):(0,t.jsx)($,{size:13,"aria-hidden":"true"}),b("active"===a?"sidebar.archive":"sidebar.restore")]})]})]})]}),x&&(0,t.jsx)(E,{title:b("sidebar.renameSession"),initialName:e.title,onCancel:()=>v(!1),onConfirm:async t=>{await u(e,t),v(!1)}})]})}function D({group:e,isCurrent:a,isPinned:s,isCollapsed:i,onToggleCollapsed:r,onTogglePin:l,query:o,selectedSession:c,switchSession:d,archiveSession:u,restoreSession:p,renameSession:h,renameProject:m,deleteProject:g,createSessionIn:x,mutatingId:v,archived:y,onOpenArchived:b,runningSessionIds:k}){let[T,A]=(0,n.useState)(!1),[$,L]=(0,n.useState)(!1),[q,B]=(0,n.useState)(!1);M($,()=>L(!1));let[U,H]=(0,n.useState)(!1),W=(0,n.useRef)(null),V=(0,f.useT)();(0,n.useEffect)(()=>{if(!$)return;let e=e=>{W.current?.contains(e.target)||L(!1)};return document.addEventListener("pointerdown",e),()=>document.removeEventListener("pointerdown",e)},[$]);let K=o?e.sessions.filter(e=>!(0,R.isBlankSession)(e)&&e.title.toLowerCase().includes(o)):[...e.sessions.filter(e=>(0,R.isBlankSession)(e)&&e.id===c),...e.sessions.filter(e=>!(0,R.isBlankSession)(e))];return(0,t.jsxs)("div",{className:"sidebar-project-group",children:[(0,t.jsxs)("div",{role:"treeitem",tabIndex:0,"aria-expanded":!i,"aria-selected":a,className:`sb-project-row${$?" sb-menu-open":""}`,onClick:r,onKeyDown:e=>{("Enter"===e.key||" "===e.key)&&(e.preventDefault(),r())},title:e.projectName,children:[(0,t.jsx)("span",{className:`sb-row-slot sb-folder${a?" sb-folder-active":""}`,children:i?(0,t.jsx)(w,{size:15,"aria-hidden":"true"}):(0,t.jsx)(_,{size:15,"aria-hidden":"true"})}),(0,t.jsx)("span",{className:"sb-row-slot sb-chevron","data-expanded":!i||void 0,children:(0,t.jsx)(j,{size:14,"aria-hidden":"true"})}),(0,t.jsx)("span",{className:"sb-project-title",children:e.projectName}),(0,t.jsxs)("span",{className:"sb-row-actions",ref:W,children:[(0,t.jsx)("button",{type:"button",className:s?"sb-pin-star":"sb-pin-star is-unpinned",title:V(s?"sidebar.unpin":"sidebar.pin"),"aria-label":V(s?"sidebar.unpin":"sidebar.pin"),onClick:e=>{e.stopPropagation(),l()},children:(0,t.jsx)(I,{size:13,fill:s?"currentColor":"none","aria-hidden":"true"})}),(0,t.jsx)("button",{type:"button",className:"sb-row-icon-btn","aria-label":V("sidebar.newSession"),title:V("sidebar.newSession"),onClick:t=>{t.stopPropagation(),x(e.projectId)},children:(0,t.jsx)(S,{size:14,"aria-hidden":"true"})}),(0,t.jsx)("button",{type:"button",className:"sb-row-icon-btn","aria-label":V("sidebar.deleteProject"),"aria-haspopup":"menu","aria-expanded":$,onClick:e=>{e.stopPropagation(),L(e=>!e)},children:(0,t.jsx)(N,{size:15,"aria-hidden":"true"})}),$&&(0,t.jsxs)("div",{className:"sb-row-menu",role:"menu",children:[(0,t.jsxs)("button",{type:"button",role:"menuitem",onClick:e=>{e.stopPropagation(),L(!1),B(!0)},children:[(0,t.jsx)(C,{size:13,"aria-hidden":"true"})," ",V("sidebar.renameProject")]}),(0,t.jsxs)("button",{type:"button",role:"menuitem",className:"is-danger",onClick:e=>{e.stopPropagation(),L(!1),H(!0)},children:[(0,t.jsx)(P,{size:13,"aria-hidden":"true"})," ",V("sidebar.deleteProject")]})]})]})]}),!i&&(0,t.jsxs)("div",{className:"sb-project-children",children:[e.error&&(0,t.jsx)("div",{className:"sidebar-empty is-error",children:e.error}),e.loading&&0===K.length?(0,t.jsx)("div",{className:"sidebar-empty",children:V("sidebar.loading")}):0===K.length?(0,t.jsx)("div",{className:"sidebar-empty",role:"status",children:o?`${V("sidebar.noSessionsMatch")} "${o}"`:V("sidebar.noSessions")}):(0,t.jsx)("ul",{className:"session-list","aria-label":`Sessions in ${e.projectName}`,children:F(z(K),c,d,"active",u,p,h,v,0,k)}),(0,t.jsx)("button",{type:"button",className:"sidebar-archived-toggle","aria-expanded":T,onClick:()=>{let e=!T;A(e),e&&b()},children:V(T?"sidebar.hideArchived":"sidebar.showArchived")}),T&&y.length>0&&(0,t.jsx)("ul",{className:"session-list","aria-label":`Archived sessions in ${e.projectName}`,children:F(z(y),c,d,"archived",u,p,h,v,0,k)}),T&&0===y.length&&(0,t.jsx)("div",{className:"sidebar-empty",children:V("sidebar.noArchived")})]}),q&&(0,t.jsx)(E,{title:V("sidebar.renameProject"),initialName:e.projectName,onCancel:()=>B(!1),onConfirm:async t=>{await m(e.projectId,t),B(!1)}}),U&&(0,t.jsx)(O,{projectName:e.projectName,onCancel:()=>H(!1),onConfirm:async()=>{await g(e.projectId),H(!1)}})]})}function O({projectName:e,onCancel:a,onConfirm:s}){let[i,r]=(0,n.useState)(!1),[l,o]=(0,n.useState)(null),c=(0,f.useT)(),d=async()=>{r(!0),o(null);try{await s()}catch(e){o(e.message),r(!1)}};return(0,t.jsx)("div",{className:"sb-dialog-overlay",onPointerDown:e=>{e.target!==e.currentTarget||i||a()},children:(0,t.jsxs)("div",{className:"sb-dialog",role:"dialog","aria-modal":"true","aria-label":c("sidebar.deleteProject"),children:[(0,t.jsx)("h3",{children:c("sidebar.deleteProjectTitle",{name:e})}),(0,t.jsx)("p",{children:c("sidebar.deleteProjectBody")}),l&&(0,t.jsx)("div",{className:"sb-dialog-error",role:"alert",children:l}),(0,t.jsxs)("div",{className:"sb-dialog-actions",children:[(0,t.jsx)("button",{type:"button",onClick:a,disabled:i,children:c("sidebar.cancel")}),(0,t.jsx)("button",{type:"button",className:"sb-danger",onClick:d,disabled:i,children:c("sidebar.deleteProjectConfirm")})]})]})})}let q=o("chevron-down",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);var B=e.i(89163);function U(e){let{projects:n,selectedProject:a,pinnedProjectIds:s,togglePinProject:i,onSelect:r,className:l}=e,o=(0,f.useT)();return(0,t.jsxs)("div",{role:"menu","aria-label":"Projects",className:`project-menu ${l??""}`,children:[0===n.length&&(0,t.jsx)("div",{className:B.default.empty,children:o("sidebar.noProjects")}),n.map(e=>(0,t.jsxs)("div",{className:B.default.row,children:[(0,t.jsxs)("button",{type:"button",onClick:()=>r(e.id),className:B.default.select,"data-selected":e.id===a||void 0,children:[(0,t.jsx)(w,{size:14,"aria-hidden":"true",className:B.default.folder}),(0,t.jsx)("span",{className:B.default.name,children:e.name})]}),(0,t.jsx)("button",{type:"button",title:`${s.includes(e.id)?o("sidebar.unpin"):o("sidebar.pin")} ${e.name}`,"aria-label":s.includes(e.id)?o("sidebar.unpin"):o("sidebar.pin"),onClick:()=>i(e.id),className:B.default.pin,"data-pinned":s.includes(e.id)||void 0,children:(0,t.jsx)(I,{size:13,fill:s.includes(e.id)?"currentColor":"none","aria-hidden":"true"})})]},e.id))]})}var H=e.i(81938);function W(e){let{projects:n,selectedProject:a,pinnedProjectIds:s,togglePinProject:i,onSelect:r,control:l}=e,{open:o,toggle:c,close:d,rootRef:u}=l,p=(0,f.useT)();return M(o,d),(0,t.jsxs)("div",{ref:u,className:`sidebar-project-selector ${H.default.root}`,children:[(0,t.jsxs)("button",{type:"button",onClick:c,className:H.default.trigger,"data-selected":!!a||void 0,title:a?n.find(e=>e.id===a)?.name??p("sidebar.selectProject"):p("sidebar.selectProject"),"aria-haspopup":"menu","aria-expanded":o,children:[(0,t.jsx)(w,{size:14,"aria-hidden":"true",className:H.default.folder}),(0,t.jsx)("span",{className:H.default.label,children:a?n.find(e=>e.id===a)?.name??p("sidebar.unknown"):p("sidebar.selectProjectEllipsis")}),(0,t.jsx)(q,{size:12,"aria-hidden":"true",className:H.default.chevron,"data-open":o||void 0})]}),o&&(0,t.jsx)(U,{projects:n,selectedProject:a,pinnedProjectIds:s,togglePinProject:i,onSelect:e=>{r(e),d()},className:"sidebar-project-menu"})]})}function V({projects:e,groups:a,selectedProject:s,selectedSession:i,settingsOpen:r,query:l,setQuery:o,mutatingId:g,announcement:x,pinnedProjectIds:y,togglePinProject:j,renameProject:w,deleteProject:_,renameSession:N,createSessionIn:C,collapsed:S,toggleCollapsed:I,archived:P,openArchived:T,createProject:M,createSession:R,switchProject:E,switchSession:A,archiveSession:$,restoreSession:z,openSettings:F,closeNavigation:L,runningSessionIds:O,onToggleSidebar:q,projectSelector:B,view:U,setView:H}){let K=(0,f.useT)(),G=(0,n.useRef)(null),J=(0,n.useRef)(null),Y=(0,n.useRef)(void 0),[Q,Z]=(0,n.useState)(!1),[X,ee]=(0,n.useState)(!1);(0,n.useEffect)(()=>{Q&&G.current?.focus({preventScroll:!0})},[Q]);let et=(0,n.useCallback)(()=>{void 0!==Y.current&&(window.clearTimeout(Y.current),Y.current=void 0)},[]),en=(0,n.useCallback)(()=>{void 0===Y.current&&(Y.current=window.setTimeout(()=>{Y.current=void 0,ee(!1)},2e3))},[]);(0,n.useEffect)(()=>{if(!X)return;let e=e=>{let t=J.current?.getBoundingClientRect();t&&(e.clientX>=t.left&&e.clientX<t.right&&e.clientY>=t.top&&e.clientY<t.bottom?et():en())};return document.addEventListener("pointermove",e),()=>{document.removeEventListener("pointermove",e),et()}},[X,et,en]),(0,n.useEffect)(()=>()=>et(),[et]);let ea=()=>{o(""),Z(!1)};return(0,t.jsxs)("aside",{ref:J,className:`sidebar${X?"":" quiet-bars"}`,"aria-label":K("sidebar.aria"),onPointerEnter:()=>{et(),ee(!0)},onPointerLeave:()=>{en()},children:[(0,t.jsx)(v,{onToggleSidebar:q,onCloseNavigation:L}),(0,t.jsx)(b,{disabled:!s,onClick:R}),(0,t.jsxs)("nav",{className:"sidebar-nav","aria-label":"Workspace",children:[(0,t.jsx)(k,{active:"heroes"===U,label:K("sidebar.heroes"),icon:(0,t.jsx)(c,{size:16}),onClick:()=>H("heroes")}),(0,t.jsx)(k,{active:"graphs"===U,label:K("sidebar.graphs"),icon:(0,t.jsx)(h,{size:16}),onClick:()=>H("graphs")})]}),(0,t.jsxs)("div",{className:`sidebar-workspace-head${Q?" search-expanded":""}`,children:[(0,t.jsx)("span",{className:"workspace-label",children:K("sidebar.workspaces")}),(0,t.jsx)("div",{className:"workspace-search-slot",children:(0,t.jsxs)("div",{className:"workspace-search",children:[(0,t.jsx)("button",{type:"button",className:"workspace-action-button workspace-search-button","aria-label":K("sidebar.searchSessions"),"aria-expanded":Q,title:Q?void 0:K("sidebar.searchSessions"),onClick:()=>Z(!0),children:(0,t.jsx)(u,{size:Q?11:14,"aria-hidden":"true"})}),(0,t.jsx)("input",{ref:G,type:"text",value:l,tabIndex:Q?0:-1,placeholder:K("sidebar.searchSessions"),"aria-label":K("sidebar.searchSessions"),onChange:e=>o(e.target.value),onKeyDown:e=>{"Escape"!==e.key||e.nativeEvent.isComposing||(e.preventDefault(),e.stopPropagation(),ea())}}),Q&&(0,t.jsx)("button",{type:"button",className:"workspace-search-clear","aria-label":K("sidebar.clearSearch"),onClick:ea,children:(0,t.jsx)(m,{size:13,"aria-hidden":"true"})})]})}),(0,t.jsx)("div",{className:"workspace-head-actions",children:(0,t.jsx)("button",{type:"button",className:"workspace-action-button","aria-label":K("sidebar.addWorkspace"),title:K("sidebar.addWorkspace"),onClick:M,children:(0,t.jsx)(d,{size:16,"aria-hidden":"true"})})})]}),(0,t.jsx)(W,{projects:e,selectedProject:s,pinnedProjectIds:y,togglePinProject:j,onSelect:E,control:B}),s&&(0,t.jsx)("section",{className:"sidebar-sessions","aria-label":K("sidebar.sessions"),children:(0,t.jsxs)("div",{className:"sidebar-tree-body",children:[(0,t.jsx)("div",{className:"sidebar-session-list",children:0===a.length?(0,t.jsx)("div",{className:"sidebar-empty",children:K("sidebar.loadingSessions")}):a.map(e=>(0,t.jsx)(D,{group:e,isCurrent:e.projectId===s,isPinned:y.includes(e.projectId),isCollapsed:S.has(e.projectId),onToggleCollapsed:()=>I(e.projectId),onTogglePin:()=>j(e.projectId),query:l.trim(),selectedSession:i,switchSession:A,archiveSession:$,restoreSession:z,renameSession:N,renameProject:w,deleteProject:_,createSessionIn:C,mutatingId:g,archived:P[e.projectId]??[],onOpenArchived:()=>T(e.projectId),runningSessionIds:O},e.projectId))}),(0,t.jsx)("div",{className:"sidebar-list-fade","aria-hidden":"true"})]})}),!s&&(0,t.jsx)("div",{className:"sidebar-empty-project",children:(0,t.jsx)("div",{children:K("sidebar.chooseProject")})}),(0,t.jsx)("span",{className:"sr-only",role:"status","aria-live":"polite",children:x}),(0,t.jsx)("div",{className:"sidebar-settings",children:(0,t.jsxs)("button",{type:"button",className:`sidebar-settings-trigger${r?" active":""}`,onClick:()=>F(),"aria-haspopup":"dialog","aria-expanded":r,children:[(0,t.jsx)(p,{size:16,"aria-hidden":"true"}),(0,t.jsx)("span",{children:K("sidebar.settings")})]})})]})}let K=o("arrow-down",[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]]);var G=e.i(54145);function J({nodes:e,scrollContainer:a}){let s=(0,f.useT)(),i=(0,n.useMemo)(()=>e.filter(e=>"turn"===e.kind).map((e,t)=>({id:e.id,index:t,text:(e.user?.text??"").replace(/\s+/g," ").trim()})),[e]),[r,l]=(0,n.useState)(0),[o,c]=(0,n.useState)(null),d=(0,n.useRef)(null),u=(e,t)=>e.querySelector(`[data-turn-id="${CSS.escape(t.id)}"]`);if((0,n.useEffect)(()=>{let e=a.current;if(!e)return;let t=()=>{null===d.current&&(d.current=window.requestAnimationFrame(()=>{d.current=null,(()=>{if(0===i.length)return;let t=e.scrollTop+.3*e.clientHeight,n=0,a=1/0,s=e.getBoundingClientRect().top;for(let r of i){let i=u(e,r);if(!i)continue;let l=Math.abs(i.getBoundingClientRect().top-s+e.scrollTop-t);l<a&&(a=l,n=r.index)}l(n)})()}))};e.addEventListener("scroll",t,{passive:!0});let n=new ResizeObserver(t);return n.observe(e),t(),()=>{e.removeEventListener("scroll",t),n.disconnect(),null!==d.current&&window.cancelAnimationFrame(d.current),d.current=null}},[a,i]),i.length<2)return null;let p=e=>e.text||s("conversation.rail.turn",{index:String(e.index+1)});return(0,t.jsxs)("nav",{className:G.default.rail,"aria-label":s("conversation.rail.aria"),children:[(0,t.jsx)("span",{className:G.default.track,"aria-hidden":"true"}),i.map(e=>{let n=(e.index+.5)/i.length*100,o=p(e),d=r===e.index;return(0,t.jsx)("button",{type:"button",className:G.default.marker,style:{top:`${n}%`},"data-active":d||void 0,"aria-current":d?"true":void 0,"aria-label":s("conversation.rail.goTo",{index:String(e.index+1),label:o}),onClick:()=>(e=>{let t=a.current;if(!t)return;let n=u(t,e);if(!n)return;let s=n.getBoundingClientRect().top-t.getBoundingClientRect().top+t.scrollTop-12;t.scrollTo({top:Math.max(0,s),behavior:"smooth"}),l(e.index)})(e),onMouseEnter:()=>c(e.index),onMouseLeave:()=>c(t=>t===e.index?null:t),onFocus:()=>c(e.index),onBlur:()=>c(t=>t===e.index?null:t),children:(0,t.jsx)("span",{className:G.default.dot,"aria-hidden":"true"})},e.id)}),null!==o&&i[o]&&(0,t.jsxs)("div",{className:G.default.preview,style:{top:`${(o+.5)/i.length*100}%`},role:"tooltip",children:[(0,t.jsx)("span",{className:G.default.previewIndex,children:String(o+1).padStart(2,"0")}),(0,t.jsx)("span",{className:G.default.previewText,children:p(i[o])})]})]})}let Y=o("check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]),Q=o("copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]),Z=o("message-square-quote",[["path",{d:"M14 14a2 2 0 0 0 2-2V8h-2",key:"1r06pg"}],["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:"M8 14a2 2 0 0 0 2-2V8H8",key:"1jzu5j"}]]),X=o("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"}]]);var ee=e.i(2668);function et({selection:e,onQuote:a,onExplain:s,onDismiss:i}){let r=(0,f.useT)(),[l,o]=(0,n.useState)(!1),c=(0,n.useRef)(null);M(!0,i);let d=(0,n.useCallback)(()=>{navigator.clipboard?.writeText(e.text).then(()=>{o(!0),null!==c.current&&window.clearTimeout(c.current),c.current=window.setTimeout(()=>o(!1),1e3)}).catch(()=>{})},[e.text]),u=e.rect.top>56,p=Math.min(window.innerWidth-150,Math.max(150,e.rect.left+e.rect.width/2));return(0,t.jsxs)("div",{className:ee.default.toolbar,"data-placement":u?"above":"below",role:"toolbar","aria-label":r("selection.aria"),style:{left:p,top:u?e.rect.top-8:e.rect.bottom+8},onPointerDown:e=>e.preventDefault(),children:[(0,t.jsxs)("button",{type:"button",className:ee.default.action,onClick:()=>a(e.text),children:[(0,t.jsx)(Z,{size:14,"aria-hidden":"true"}),r("selection.quote")]}),(0,t.jsxs)("button",{type:"button",className:ee.default.action,onClick:d,children:[l?(0,t.jsx)(Y,{size:14,"aria-hidden":"true"}):(0,t.jsx)(Q,{size:14,"aria-hidden":"true"}),r(l?"selection.copied":"selection.copy")]}),(0,t.jsxs)("button",{type:"button",className:ee.default.action,onClick:()=>s(e.text),children:[(0,t.jsx)(X,{size:14,"aria-hidden":"true"}),r("selection.explain")]})]})}let en=o("arrow-up",[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]]),ea=o("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"}]]),es=o("file-spreadsheet",[["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:"M8 13h2",key:"yr2amv"}],["path",{d:"M14 13h2",key:"un5t4a"}],["path",{d:"M8 17h2",key:"2yhykz"}],["path",{d:"M14 17h2",key:"10kma7"}]]),ei=o("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"}]]),er=o("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"}]]),el=o("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"}]]),eo=o("presentation",[["path",{d:"M2 3h20",key:"91anmk"}],["path",{d:"M21 3v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V3",key:"2k9sn8"}],["path",{d:"m7 21 5-5 5 5",key:"bip4we"}]]),ec=o("square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]),ed="ennote-picker-collapsed";function eu(){try{let e=JSON.parse(localStorage.getItem(ed)??"{}");return"object"==typeof e&&null!==e?e:{}}catch{return{}}}let ep=(0,n.forwardRef)(function({open:e,sections:a,filter:s,showFilter:i=!1,activeKey:r,ariaLabel:l,onFilterChange:o,onPick:c,onClose:d},p){let h=(0,f.useT)(),[m,g]=(0,n.useState)(eu),[x,v]=(0,n.useState)(0),y=(0,n.useRef)(null),b=(0,n.useRef)(null),k=(0,n.useRef)(null),w=(0,n.useMemo)(()=>{let e=s.trim().toLowerCase();return a.map(t=>{if(t.pinned)return{...t,total:t.items.length};let n=m[t.key]??t.readOnly??!1,a=e?t.items.filter(t=>`${t.label} ${t.hint??""} ${t.description??""}`.toLowerCase().includes(e)):t.items;return{...t,items:n?[]:a,total:a.length}}).filter(e=>e.pinned||e.items.length>0||e.readOnly)},[a,m,s]),_=(0,n.useMemo)(()=>w.flatMap(e=>e.items.filter(t=>!e.pinned&&!e.readOnly&&!t.disabled).map(t=>({item:t,section:e}))),[w]),N=`${s}\u0000${e}`,[C,S]=(0,n.useState)(N);C!==N&&(S(N),v(0)),(0,n.useEffect)(()=>{e&&(i?k.current?.focus():y.current?.querySelector("[data-picker-item][data-active='true']")?.scrollIntoView({block:"nearest"}))},[e,i,x]),M(e,d),(0,n.useEffect)(()=>{if(!e)return;let t=e=>{e.target instanceof Node&&y.current?.contains(e.target)===!0||d()};return document.addEventListener("pointerdown",t),()=>document.removeEventListener("pointerdown",t)},[e,d]);let I=(0,n.useCallback)((e,t)=>{g(n=>{let a={...n,[e]:!t};try{localStorage.setItem(ed,JSON.stringify(a))}catch{}return a})},[]);if((0,n.useImperativeHandle)(p,()=>({move:e=>v(t=>{let n=t+e;return n<0?0:Math.min(n,Math.max(_.length-1,0))}),pickActive:()=>{let e=_[Math.min(x,Math.max(_.length-1,0))];return!!e&&(c(e.item,e.section),!0)}}),[_,x,c]),!e)return null;let P=w.some(e=>!e.pinned&&e.items.length>0);return i||!(s.trim().length>0)||P?(0,t.jsxs)("div",{ref:y,className:"composer-picker",role:"dialog","aria-label":l,onKeyDown:e=>{if("ArrowDown"===e.key){e.preventDefault(),v(e=>Math.min(e+1,Math.max(_.length-1,0)));return}if("ArrowUp"===e.key){e.preventDefault(),v(e=>Math.max(e-1,0));return}if("Enter"===e.key){let t=_[x];if(!t)return;e.preventDefault(),c(t.item,t.section);return}"Escape"===e.key&&(e.preventDefault(),e.stopPropagation(),d())},children:[i&&(0,t.jsxs)("label",{className:"composer-picker-filter",children:[(0,t.jsx)(u,{size:13,"aria-hidden":"true"}),(0,t.jsx)("input",{ref:k,value:s,placeholder:h("picker.filter"),"aria-label":h("picker.filter"),onChange:e=>o?.(e.target.value)})]}),(0,t.jsxs)("div",{ref:b,className:"composer-picker-body",role:"listbox","aria-label":h("picker.list"),"aria-activedescendant":_[x]?`picker-${_[x].item.key}`:void 0,children:[w.map(e=>{let n=m[e.key]??e.readOnly??!1,a=!e.pinned;return(0,t.jsxs)("section",{className:"composer-picker-group",role:"group","aria-label":e.label,children:[(0,t.jsxs)("button",{type:"button",className:"composer-picker-group-head","aria-expanded":a?!n:void 0,disabled:!a,onClick:()=>a&&I(e.key,n),onKeyDown:t=>{("Enter"===t.key||" "===t.key)&&(t.preventDefault(),t.stopPropagation(),a&&I(e.key,n))},title:a?h(n?"picker.expand":"picker.collapse"):void 0,children:[a?n?(0,t.jsx)(j,{size:12,"aria-hidden":"true"}):(0,t.jsx)(q,{size:12,"aria-hidden":"true"}):(0,t.jsx)("span",{className:"composer-picker-group-dot","aria-hidden":"true"}),(0,t.jsx)("span",{children:e.label}),(0,t.jsx)("span",{className:"composer-picker-group-count",children:e.total}),e.readOnly&&(0,t.jsx)("span",{className:"composer-picker-group-tag",children:h("picker.readOnly")})]}),e.items.map(n=>{let a=!e.readOnly&&_[x]?.item.key===n.key;return(0,t.jsxs)("button",{id:`picker-${n.key}`,type:"button",role:"option","data-picker-item":!0,"data-active":a||void 0,"aria-selected":a,"aria-disabled":e.readOnly||n.disabled||void 0,className:`composer-picker-item${a?" active":""}${e.pinned?" is-action":""}`,onClick:()=>{e.readOnly||n.disabled||c(n,e)},children:[(0,t.jsx)("span",{className:"composer-picker-item-icon","aria-hidden":"true",children:n.icon}),(0,t.jsxs)("span",{className:"composer-picker-item-copy",children:[(0,t.jsx)("span",{className:"composer-picker-item-label",children:n.label}),n.description&&(0,t.jsx)("span",{className:"composer-picker-item-desc",children:n.description})]}),n.hint&&(0,t.jsx)("span",{className:"composer-picker-item-hint",children:n.hint})]},n.key)})]},e.key)}),0===_.length&&(0,t.jsx)("div",{className:"composer-picker-empty",children:h("picker.empty")})]}),(0,t.jsx)("span",{className:"sr-only","aria-live":"polite",children:r??_[x]?.item.label??""})]}):null});function eh({hero:e,graph:n,skills:a,onClearHero:s,onClearGraph:i,onRemoveSkill:r}){let l=(0,f.useT)();return e||n||0!==a.length?(0,t.jsxs)("div",{className:"composer-target-pills","aria-label":l("composer.targets"),children:[e&&(0,t.jsxs)("span",{className:"composer-pill is-hero",children:[(0,t.jsx)(c,{size:12,"aria-hidden":"true"}),(0,t.jsxs)("span",{className:"composer-pill-label",children:["@",e.handle]}),(0,t.jsx)("button",{type:"button","aria-label":`${l("composer.removeHero")} ${e.name}`,onClick:s,children:(0,t.jsx)(m,{size:10,"aria-hidden":"true"})})]}),n&&(0,t.jsxs)("span",{className:"composer-pill is-graph",children:[(0,t.jsx)(h,{size:12,"aria-hidden":"true"}),(0,t.jsxs)("span",{className:"composer-pill-label",children:[n.name,n.version?`@${n.version}`:""]}),(0,t.jsx)("button",{type:"button","aria-label":`${l("composer.removeGraph")} ${n.name}`,onClick:i,children:(0,t.jsx)(m,{size:10,"aria-hidden":"true"})})]}),a.map(e=>(0,t.jsxs)("span",{className:"composer-pill is-skill",children:[(0,t.jsx)(X,{size:12,"aria-hidden":"true"}),(0,t.jsxs)("span",{className:"composer-pill-label",children:["/",e.label]}),(0,t.jsx)("button",{type:"button","aria-label":`${l("composer.removeSkill")} ${e.label}`,onClick:()=>r(e.id),children:(0,t.jsx)(m,{size:10,"aria-hidden":"true"})})]},e.id))]}):null}let em=["discuss","ask","auto"],ef="M8.20554 0.899994L14.7901 3.36857V7.01026C14.7901 12 11.0466 14.2103 8.20554 15.3C5.36446 14.2103 1.62012 12 1.62012 7.01026V3.36857L8.20554 0.899994Z";function eg({mode:e}){return"ask"===e?(0,t.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none","aria-hidden":!0,children:[(0,t.jsx)("path",{d:"M8.08887 0.251709C8.20479 0.23085 8.32486 0.241168 8.43652 0.282959L15.0215 2.75171C15.2787 2.84819 15.4492 3.09414 15.4492 3.3689V7.0105C15.4492 7.10986 15.4441 7.2081 15.4414 7.30542C15.0285 7.07175 14.5905 6.87695 14.1309 6.73022V3.82495L8.20508 1.60327L2.2793 3.82495V7.0105C2.27936 9.7171 3.4745 11.5379 5.02734 12.7947C5.01025 12.9942 5 13.1962 5 13.4001C5.00001 13.7617 5.02722 14.1169 5.08008 14.4636C2.91555 13.0393 0.961014 10.752 0.960938 7.0105V3.3689C0.960938 3.09417 1.13146 2.84821 1.38867 2.75171L7.97461 0.282959L8.08887 0.251709Z",fill:"currentColor"}),(0,t.jsx)("path",{d:"M11.3525 5.64688V6.85688H5V5.64688H11.3525Z",fill:"currentColor"}),(0,t.jsx)("path",{d:"M9.5824 8.29376V9.50376H5V8.29376H9.5824Z",fill:"currentColor"})]}):"auto"===e?(0,t.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none","aria-hidden":!0,children:[(0,t.jsx)("path",{d:ef,stroke:"currentColor",strokeWidth:"1.31831",strokeLinejoin:"round"}),(0,t.jsx)("path",{d:"M9.10094 4.5V8.75939H7.59888V4.5H9.10094Z",fill:"currentColor"}),(0,t.jsx)("path",{d:"M9.10094 9.8114V11.5H7.59888V9.8114H9.10094Z",fill:"currentColor"})]}):(0,t.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none","aria-hidden":!0,children:[(0,t.jsx)("path",{d:ef,stroke:"currentColor",strokeWidth:"1.31831",strokeLinejoin:"round"}),(0,t.jsx)("path",{d:"M12.1654 5.7552L8.9447 9.41475C8.73044 9.65816 8.53628 9.8804 8.35774 10.0423C8.1713 10.2114 7.94235 10.3717 7.64016 10.4254C7.48207 10.4535 7.32 10.4552 7.16151 10.4294C6.85843 10.3801 6.62728 10.2223 6.43836 10.0559C6.25752 9.89653 6.06037 9.67732 5.84264 9.43705L4.72925 8.20897L5.63557 7.38707L6.74897 8.61594C6.98603 8.87755 7.12974 9.03533 7.24673 9.13839C7.31033 9.19443 7.34485 9.21476 7.35823 9.22122C7.38068 9.22484 7.40352 9.22515 7.42593 9.22122C7.40522 9.22502 7.42893 9.23294 7.53583 9.136C7.65132 9.03126 7.79316 8.87139 8.02643 8.60638L11.2479 4.94763L12.1654 5.7552Z",fill:"currentColor"})]})}function ex(e,t){return t(`permission.${e}`)}function ev({permissionMode:e,permissionReady:a,setPermissionMode:s,disabled:i,frozen:r=!1}){let l=(0,f.useT)(),[o,c]=(0,n.useState)(!1),d=(0,n.useRef)(null),u=(0,n.useRef)(null),p=(0,n.useRef)(null),h=(0,n.useId)(),m=i||!a,g=o&&!m;return M(g,()=>c(!1)),(0,n.useEffect)(()=>{if(!g)return;let e=e=>{d.current?.contains(e.target)||c(!1)},t=e=>{if("ArrowDown"!==e.key&&"ArrowUp"!==e.key)return;e.preventDefault();let t=Array.from(p.current?.querySelectorAll('[role="menuitemradio"]')??[]);if(0===t.length)return;let n=(Math.max(t.indexOf(document.activeElement),0)+("ArrowDown"===e.key?1:-1)+t.length)%t.length;t[n]?.focus()};return document.addEventListener("mousedown",e),document.addEventListener("keydown",t),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("keydown",t)}},[g]),(0,n.useEffect)(()=>{if(!g)return;let e=window.requestAnimationFrame(()=>{let e=p.current?.querySelector('[aria-checked="true"]'),t=p.current?.querySelector('[role="menuitemradio"]');(e??t)?.focus()});return()=>window.cancelAnimationFrame(e)},[g]),(0,t.jsxs)("div",{ref:d,className:"permission-chip",children:[(0,t.jsxs)("button",{ref:u,type:"button",className:"permission-chip-trigger","aria-label":`${l("composer.permissionMode")}: ${ex(e,l)}`,"aria-haspopup":"menu","aria-expanded":g,"aria-controls":g?`${h}-menu`:void 0,disabled:m,title:r?`${ex(e,l)} ${l("composer.frozenForRun")}`:void 0,onClick:()=>c(e=>!e),children:[(0,t.jsx)("span",{className:"permission-chip-icon","aria-hidden":!0,children:(0,t.jsx)(eg,{mode:e})}),(0,t.jsx)("span",{className:"permission-chip-label",children:ex(e,l)}),(0,t.jsx)("svg",{className:g?"permission-chip-chevron open":"permission-chip-chevron",width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:(0,t.jsx)("path",{d:"M3.5 5.25L7 8.75L10.5 5.25"})})]}),g&&(0,t.jsx)("div",{ref:p,id:`${h}-menu`,className:"permission-chip-menu",role:"menu","aria-label":l("composer.permissionMode"),children:em.map(n=>{let a=n===e,i=`${h}-${n}-description`;return(0,t.jsxs)("button",{type:"button",role:"menuitemradio","aria-checked":a,"aria-label":ex(n,l),"aria-describedby":i,className:a?"permission-chip-option selected":"permission-chip-option",onClick:()=>{s(n),c(!1),u.current?.focus()},children:[(0,t.jsx)("span",{className:"permission-chip-option-icon","aria-hidden":!0,children:(0,t.jsx)(eg,{mode:n})}),(0,t.jsxs)("span",{className:"permission-chip-option-copy",children:[(0,t.jsx)("span",{className:"permission-chip-option-label",children:ex(n,l)}),(0,t.jsx)("span",{className:"permission-chip-option-desc",id:i,children:l(`permission.${n}.description`)})]}),(0,t.jsx)("span",{className:"permission-chip-check","aria-hidden":!0,children:a&&(0,t.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,t.jsx)("polyline",{points:"3 8.5 6.5 12 13 4.5"})})})]},n)})})]})}function ey(e){return e?.supportsThinking===!0}function eb(e){if(!ey(e))return[];let t=e?.supportedThinkingEfforts;return t&&t.length>0?t:["default"]}function ek(e){return e.charAt(0).toUpperCase()+e.slice(1)}function ej(e,t){return e.replace(/\{(\w+)\}/g,(e,n)=>t[n]??`{${n}}`)}function ew({models:e,providers:a=[],selectedModelId:s,setSelectedModelId:i,thinkingEffort:r,setThinkingEffort:l,disabled:o}){let c=0,d=(0,f.useT)(),[u,p]=(0,n.useState)(!1),[h,m]=(0,n.useState)("root"),g=(0,n.useRef)(null),x=(0,n.useRef)(null),v=(0,n.useId)(),y=(0,n.useMemo)(()=>e.find(e=>e.id===s)??null,[e,s]),b=(0,n.useMemo)(()=>(function(e,t){let n=new Map(t.map(e=>[e.id,e.name])),a=[],s=new Map;for(let t of e){let e=s.get(t.providerId);if(e){e.push(t);continue}a.push(t.providerId),s.set(t.providerId,[t])}return a.map(e=>({id:e,name:n.get(e)||e,models:s.get(e)??[]}))})(e,a),[e,a]),k=ey(y),w=(0,n.useMemo)(()=>eb(y),[y]),_=w.length>0&&w.includes(r)?r:"default",N=k?ek(_):void 0;(0,n.useEffect)(()=>{if(!y)return;let e=eb(y);e.length>0&&!e.includes(r)&&l("default")},[s]);let C=y?.displayName||y?.modelName||d("composer.modelSelect.triggerFallback"),S=void 0===N?C:`${C} \xb7 ${N}`,I=null===y?d("composer.modelSelect.selectAria"):void 0===N?ej(d("composer.modelSelect.aria"),{model:C}):ej(d("composer.modelSelect.ariaEffort"),{model:C,effort:N}),P=(e=!1)=>{p(!1),m("root"),e&&queueMicrotask(()=>{x.current?.focus()})};return M(u,()=>{"root"!==h?m("root"):P()}),(0,n.useEffect)(()=>{if(!u)return;let e=e=>{g.current?.contains(e.target)||p(!1)};return document.addEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e)}},[u]),(0,n.useEffect)(()=>{if(!u)return;let e=e=>{("ArrowDown"===e.key||"ArrowUp"===e.key)&&(e.preventDefault(),(e=>{let t=Array.from(g.current?.querySelectorAll("[data-menu-index]")??[]);if(0===t.length)return;let n=(Math.max(t.findIndex(e=>e===document.activeElement),0)+e+t.length)%t.length;t[n]?.focus()})("ArrowDown"===e.key?1:-1))};return window.addEventListener("keydown",e),()=>{window.removeEventListener("keydown",e)}},[u]),(0,t.jsxs)("div",{ref:g,className:"model-select",onBlur:e=>{e.relatedTarget instanceof Node&&(g.current?.contains(e.relatedTarget)||P())},children:[(0,t.jsxs)("button",{ref:x,type:"button",className:"model-select-trigger","aria-label":I,"aria-haspopup":"menu","aria-expanded":u,"aria-controls":u?`${v}-menu`:void 0,title:S,disabled:o,onClick:()=>{u?P():(m("root"),p(!0))},children:[(0,t.jsx)("span",{className:"model-select-trigger-label",children:C}),void 0!==N&&(0,t.jsx)("span",{className:"model-select-trigger-effort",children:N}),(0,t.jsx)(q,{size:14,className:u?"model-select-chevron open":"model-select-chevron","aria-hidden":"true"})]}),u&&(0,t.jsxs)("div",{id:`${v}-menu`,className:"model-select-menu",role:"menu","aria-label":d("composer.modelSelect.menu"),children:["root"===h&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("button",{"data-menu-index":c++,type:"button",role:"menuitem",className:"model-select-cell",onClick:()=>{m("model")},children:[(0,t.jsx)("span",{className:"model-select-cell-label",children:d("composer.modelSelect.model")}),(0,t.jsx)("span",{className:"model-select-cell-value",children:C}),(0,t.jsx)(j,{size:14,className:"model-select-cell-chevron","aria-hidden":"true"})]}),k&&(0,t.jsxs)("button",{"data-menu-index":c++,type:"button",role:"menuitem",className:"model-select-cell",onClick:()=>{m("effort")},children:[(0,t.jsx)("span",{className:"model-select-cell-label",children:d("composer.modelSelect.effort")}),(0,t.jsx)("span",{className:"model-select-cell-value",children:N}),(0,t.jsx)(j,{size:14,className:"model-select-cell-chevron","aria-hidden":"true"})]})]}),"model"===h&&(0,t.jsxs)("div",{className:"model-select-groups",children:[b.map(e=>(0,t.jsxs)("section",{role:"group","aria-labelledby":`${v}-${e.id}`,className:"model-select-group",children:[(0,t.jsx)("div",{className:"model-select-group-title",id:`${v}-${e.id}`,children:e.name}),e.models.map(e=>{let n=s===e.id;return(0,t.jsxs)("button",{"data-menu-index":c++,type:"button",role:"menuitemradio","aria-checked":n,className:n?"model-select-option selected":"model-select-option",title:e.displayName||e.modelName,onClick:()=>{s===e.id||(i(e.id),l("default")),P(!0)},children:[(0,t.jsx)("span",{className:"model-select-option-copy",children:(0,t.jsx)("span",{className:"model-select-option-name",children:e.displayName||e.modelName})}),(0,t.jsx)("span",{className:"model-select-check",children:n&&(0,t.jsx)(Y,{size:16,"aria-hidden":"true"})})]},e.id)})]},e.id)),0===e.length&&(0,t.jsx)("div",{className:"model-select-empty",children:d("composer.modelSelect.emptyModels")})]}),"effort"===h&&(0,t.jsxs)(t.Fragment,{children:[w.map(e=>{let n=_===e;return(0,t.jsxs)("button",{"data-menu-index":c++,type:"button",role:"menuitemradio","aria-checked":n,className:n?"model-select-option selected":"model-select-option",onClick:()=>{_===e||l(e),P(!0)},children:[(0,t.jsx)("span",{className:"model-select-option-copy",children:(0,t.jsx)("span",{className:"model-select-option-name",children:ek(e)})}),(0,t.jsx)("span",{className:"model-select-check",children:n&&(0,t.jsx)(Y,{size:16,"aria-hidden":"true"})})]},e)}),0===w.length&&(0,t.jsx)("div",{className:"model-select-empty",children:d("composer.modelSelect.emptyEfforts")})]})]})]})}let e_=o("activity",[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]]);function eN(e){let t=e=>e>=100?String(Math.round(e)):String(Math.round(10*e)/10);return e<1e3?String(e):e<1e6?`${t(e/1e3)}K`:`${t(e/1e6)}M`}function eC(e){let t=e/1e3;if(t<60)return`${Math.round(10*t)/10}s`;let n=Math.round(t);return`${Math.floor(n/60)}m${n%60}s`}function eS(e){let t=Math.max(0,e);return t>=10?String(Math.round(t)):String(Math.round(10*t)/10)}function eI(e,t){return e.replace(/\{(\w+)\}/g,(e,n)=>t[n]??`{${n}}`)}function eP(e,t){if(null===e)return[];let n=[];if(e.steps>0){n.push(eI(t("stats.counts"),{turns:String(e.turns),steps:String(e.steps)}));let a=[];e.llmMs>0&&a.push(eI(t("stats.llm"),{duration:eC(e.llmMs)})),e.toolMs>0&&a.push(eI(t("stats.toolCall"),{duration:eC(e.toolMs)})),a.length>0&&n.push(a.join(" · "));let s=[];e.ttftSteps>0&&s.push(eI(t("stats.ttftAverage"),{duration:eC(e.ttftMs/e.ttftSteps)})),e.decodeMs>0&&s.push(eI(t("stats.tokensPerSecond"),{throughput:eS(e.decodeTokens/(e.decodeMs/1e3))})),s.length>0&&n.push(s.join(" · "))}let a=e.uncachedInputTokens+e.cacheReadTokens+e.cacheWriteTokens;return a>0&&n.push(eI(t("stats.cacheHit"),{percent:String(Math.round(e.cacheReadTokens/a*100))})),(a>0||e.outputTokens>0)&&n.push(eI(t("stats.tokens"),{input:eN(a),output:eN(e.outputTokens)})),n}function eT({stats:e}){let n=(0,f.useT)(),a=eP(e,n);return 0===a.length?null:(0,t.jsxs)("div",{className:"context-meter-stats",children:[(0,t.jsx)("span",{className:"context-meter-stats-label",children:n("stats.section")}),a.map(e=>(0,t.jsx)("span",{children:e},e))]})}let eM=2*Math.PI*5.5,eR=[{key:"systemTokens",label:"context.system",color:"cm-color-system"},{key:"toolsTokens",label:"context.tools",color:"cm-color-tools"},{key:"messageTokens",label:"context.messages",color:"cm-color-messages"}],eE={system:{label:"context.system",color:"cm-color-system"},hero:{label:"context.hero",color:"cm-color-hero"},rules:{label:"context.rules",color:"cm-color-rules"},skills:{label:"context.skills",color:"cm-color-skills"},tools:{label:"context.tools",color:"cm-color-tools"},reminders:{label:"context.reminders",color:"cm-color-reminders"},conversation:{label:"context.conversation",color:"cm-color-messages"}};function eA({contextUsage:e,stats:a=null,initialOpen:s=!1}){let i=(0,f.useT)(),[r,l]=(0,n.useState)(s),o=(0,n.useRef)(null),c=null!==e&&e.contextWindow>0||eP(a,i).length>0;if((0,n.useEffect)(()=>{!c&&r&&l(!1)},[c,r]),M(r&&c,()=>l(!1)),(0,n.useEffect)(()=>{if(!r||!c)return;let e=e=>{e.target instanceof Node&&o.current?.contains(e.target)===!0||l(!1)};return document.addEventListener("pointerdown",e),()=>document.removeEventListener("pointerdown",e)},[c,r]),!c)return null;if(null===e||e.contextWindow<=0)return(0,t.jsxs)("span",{ref:o,className:"context-meter",children:[(0,t.jsx)("button",{type:"button",className:"context-meter-trigger","aria-label":i("stats.section"),"aria-haspopup":"dialog","aria-expanded":r,title:i("stats.section"),onClick:()=>l(e=>!e),children:(0,t.jsx)(e_,{size:14,"aria-hidden":"true"})}),r&&(0,t.jsx)("div",{className:"context-meter-panel",role:"dialog","aria-label":i("stats.section"),children:(0,t.jsx)(eT,{stats:a})})]});let d=Math.min(100,Math.round(e.projectedTokens/e.contextWindow*100)),u=d>=95?"is-critical":d>=85?"is-high":"",p=`${d}%`,[h="",m=""]=i("context.aria",{percent:"\0"}).split("\0").map(e=>e.trim()),g=e.categories??[],x=g.length>0&&g.some(e=>e.tokens>0),v=x?e.projectedTokens:e.systemTokens+e.toolsTokens+e.messageTokens,y=x?g.map(e=>({key:e.key,label:eE[e.key]?.label??"context.other",color:eE[e.key]?.color??"cm-color-messages",tokens:e.tokens})):eR.map(t=>({key:t.key,label:t.label,color:t.color,tokens:e[t.key]})),b=(0===v?[{key:"total",color:void 0,width:d}]:y.map(t=>({key:t.key,color:t.color,width:e.contextWindow>0?t.tokens/e.contextWindow*100:d*t.tokens/v}))).filter(e=>e.width>0);return(0,t.jsxs)("span",{ref:o,className:"context-meter",children:[(0,t.jsx)("button",{type:"button",className:"context-meter-trigger","aria-label":i("context.aria",{percent:p}),"aria-haspopup":"dialog","aria-expanded":r,title:i("context.aria",{percent:p}),onClick:()=>l(e=>!e),children:(0,t.jsxs)("svg",{viewBox:"0 0 14 14",width:"14",height:"14","aria-hidden":"true",children:[(0,t.jsx)("circle",{className:"context-meter-track",cx:"7",cy:"7",r:5.5}),(0,t.jsx)("circle",{className:u?`context-meter-fill ${u}`:"context-meter-fill",cx:"7",cy:"7",r:5.5,strokeDasharray:`${eM*d/100} ${eM}`,transform:"rotate(-90 7 7)"})]})}),r&&(0,t.jsxs)("div",{className:"context-meter-panel",role:"dialog","aria-label":i("context.used"),children:[(0,t.jsxs)("div",{className:"context-meter-header",children:[(0,t.jsx)("span",{className:"context-meter-headline",children:h}),(0,t.jsx)("span",{className:"context-meter-percent",children:p}),(0,t.jsx)("span",{className:"context-meter-headline",children:m}),(0,t.jsx)("span",{className:"context-meter-figures",children:`~${eN(e.projectedTokens)} / ${eN(e.contextWindow)}`})]}),(0,t.jsx)("div",{className:"context-meter-bar",children:b.map(e=>(0,t.jsx)("div",{className:`context-meter-segment${void 0===e.color?"":` ${e.color}`}`,style:{width:`${e.width}%`}},e.key))}),(0,t.jsx)("dl",{className:"context-meter-rows",children:y.map(n=>(0,t.jsxs)("div",{className:"context-meter-row",children:[(0,t.jsxs)("dt",{children:[(0,t.jsx)("span",{className:`context-meter-swatch ${n.color}`,"aria-hidden":"true"}),i(n.label)]}),(0,t.jsxs)("dd",{children:[`~${eN(n.tokens)}`,(0,t.jsx)("span",{className:"context-meter-row-pct",children:`${Math.round(n.tokens/e.contextWindow*100)}%`})]})]},n.key))}),(0,t.jsx)(eT,{stats:a})]})]})}let e$=encodeURIComponent;function ez(e,t){return`/api/worker/v1/sessions/${e$(e)}/artifacts/${e$(t)}`}function eF(e,t,n){let a=`${ez(e,t)}/preview`;return n?`${a}?${new URLSearchParams({sheet:n}).toString()}`:a}let eL=o("image-plus",[["path",{d:"M16 5h6",key:"1vod17"}],["path",{d:"M19 2v6",key:"4bpg5p"}],["path",{d:"M21 11.5V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7.5",key:"1ue2ih"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}]]),eD=o("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"}]]),eO=new Set([":","/","\\","."]),eq=o("chevron-up",[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]]),eB=o("corner-up-right",[["path",{d:"m15 14 5-5-5-5",key:"12vg1m"}],["path",{d:"M4 20v-7a4 4 0 0 1 4-4h12",key:"1lu4f8"}]]);function eU({items:e,onEdit:a,onRemove:s,onSteer:i}){let r=(0,f.useT)(),[l,o]=(0,n.useState)(!1);if(0===e.length)return null;let c=!l||1===e.length;return(0,t.jsxs)("section",{className:"queue-dock","aria-label":r("composer.queue.aria"),children:[(0,t.jsxs)("button",{type:"button",className:"queue-dock-header","aria-expanded":c,onClick:()=>o(e=>!e),children:[(0,t.jsx)(er,{size:14,"aria-hidden":"true"}),(0,t.jsx)("span",{className:"queue-dock-title",children:r("composer.queue.count",{count:String(e.length)})}),(0,t.jsx)("span",{className:"queue-dock-chevron","aria-hidden":"true",children:c?(0,t.jsx)(q,{size:14}):(0,t.jsx)(eq,{size:14})})]}),c&&(0,t.jsx)("ul",{className:"queue-dock-list",children:e.map((e,n)=>(0,t.jsxs)("li",{className:"queue-dock-row",children:[(0,t.jsx)("span",{className:"queue-dock-index","aria-hidden":"true",children:n+1}),(0,t.jsx)("span",{className:"queue-dock-text",title:e.text,children:e.text}),(0,t.jsxs)("span",{className:"queue-dock-actions",children:[(0,t.jsx)("button",{type:"button",className:"queue-dock-action",title:r("composer.queue.edit"),"aria-label":r("composer.queue.edit"),onClick:()=>a(e),children:(0,t.jsx)(C,{size:13,"aria-hidden":"true"})}),(0,t.jsx)("button",{type:"button",className:"queue-dock-action",title:r("composer.queue.steer"),"aria-label":r("composer.queue.steer"),onClick:()=>i(e),children:(0,t.jsx)(eB,{size:13,"aria-hidden":"true"})}),(0,t.jsx)("button",{type:"button",className:"queue-dock-action is-danger",title:r("composer.queue.remove"),"aria-label":r("composer.queue.remove"),onClick:()=>s(e),children:(0,t.jsx)(m,{size:13,"aria-hidden":"true"})})]})]},e.id))})]})}let eH="ennote-composer-height";function eW(e){return Math.min(336,Math.max(120,e))}let eV={pdf:{Icon:ei,color:"var(--danger)"},docx:{Icon:ei,color:"var(--info)"},doc:{Icon:ei,color:"var(--info)"},xlsx:{Icon:es,color:"var(--success)"},xls:{Icon:es,color:"var(--success)"},pptx:{Icon:eo,color:"var(--warning)"},ppt:{Icon:eo,color:"var(--warning)"}};function eK({selectedSession:e,activeLeafMessageId:a,input:s,setInput:i,activeRun:r,questionPending:l=!1,compacting:o,hasPendingImage:d,reconnecting:u,permissionMode:p,permissionReady:g,setPermissionMode:x,models:v,providers:y,selectedModelId:b,setSelectedModelId:k,thinkingEffort:j,setThinkingEffort:w,textAttachments:_,removeTextAttachment:N,pendingImage:C,clearPendingImage:I,attachFiles:P,uploadImage:T,submit:M,steer:R,steerText:E,followUp:A,cancel:$,cancelFollowUp:z,compactSession:F,pendingFollowUps:L,picker:D,expanding:O,expandDiag:q,contextUsage:B,stats:U,focusNonce:H,onRequestProject:W,inert:V=!1,welcome:K=!1}){let G=(0,n.useRef)(null),J=(0,n.useRef)(null),Y=(0,n.useRef)(null),Q=(0,n.useRef)(null),[Z,ee]=(0,n.useState)(!1),et=(0,n.useRef)(0),[es,eo]=(0,n.useState)(()=>{try{let e=Number.parseInt(localStorage.getItem(eH)??"",10);return Number.isFinite(e)?eW(e):0}catch{return 0}}),[ed,eu]=(0,n.useState)(!1),em=(0,n.useRef)(es),ef=(0,n.useRef)(null),eg=(0,f.useT)(),ex=(0,n.useCallback)(e=>{em.current=e,eo(e)},[]),ey=(0,n.useCallback)(e=>{try{e>0?localStorage.setItem(eH,String(e)):localStorage.removeItem(eH)}catch{}},[]),eb=(0,n.useCallback)(()=>{ex(0),ey(0)},[ex,ey]),ek=(0,n.useCallback)(e=>{if(0!==e.button||!e.isPrimary)return;e.preventDefault();let t=em.current||G.current?.offsetHeight||120;ef.current={y:e.clientY,height:t},eu(!0),e.currentTarget.setPointerCapture(e.pointerId),document.body.style.cursor="row-resize",document.body.style.userSelect="none"},[]),ej=(0,n.useCallback)(e=>{let t=ef.current;t&&(e.preventDefault(),ex(eW(t.height+t.y-e.clientY)))},[ex]),e_=(0,n.useCallback)(e=>{ef.current&&(ef.current=null,eu(!1),document.body.style.cursor="",document.body.style.userSelect="",e.currentTarget.hasPointerCapture(e.pointerId)&&e.currentTarget.releasePointerCapture(e.pointerId),ey(em.current))},[ey]),eN=(0,n.useCallback)(e=>{let t=eW((em.current||G.current?.offsetHeight||120)+e);ex(t),ey(t)},[ex,ey]);(0,n.useEffect)(()=>{if(!H)return;let e=G.current;if(!e)return;e.focus();let t=e.value.length;e.setSelectionRange(t,t)},[H]),(0,n.useEffect)(()=>{let e=G.current;e&&(e.style.height="0px",e.style.height=`${Math.min(Math.max(e.scrollHeight,es),336)}px`)},[s,es]);let eC=(0,n.useCallback)(async e=>{await z(e.id)&&(i(e.text),window.requestAnimationFrame(()=>G.current?.focus()))},[z,i]),eS=(0,n.useCallback)(e=>{z(e.id)},[z]),eI=(0,n.useCallback)(async e=>{await z(e.id)&&await E(e.text)},[z,E]),eP=!!e&&!r&&!o,eT=(0,n.useRef)(null),eM=function({input:e,setInput:a,data:s,canAct:i,panel:r,onAttachFile:l,onAttachImage:o,onCompact:d}){let u=(0,f.useT)(),[p,m]=(0,n.useState)(null),[g,x]=(0,n.useState)(""),v=(0,n.useMemo)(()=>{let e=s.skills.filter(e=>!e.heroBound),n=s.skills.filter(e=>e.heroBound),a=[{key:"actions",label:u("picker.actions"),pinned:!0,items:[{key:"action:file",label:u("composer.attachFiles"),icon:(0,t.jsx)(el,{size:14,"aria-hidden":"true"}),disabled:!i},{key:"action:image",label:u("composer.attachImage"),icon:(0,t.jsx)(eL,{size:14,"aria-hidden":"true"}),disabled:!i},{key:"action:compact",label:u("composer.compactContext"),icon:(0,t.jsx)(eD,{size:14,"aria-hidden":"true"}),disabled:!i}]},{key:"heroes",label:u("picker.heroes"),items:s.heroes.map(e=>({key:`hero:${e.id}`,label:`@${e.handle}`,hint:e.id===s.selectedHeroId?u("picker.selected"):void 0,description:e.description??e.name,icon:(0,t.jsx)(c,{size:14,"aria-hidden":"true"})}))},{key:"graphs",label:u("picker.graphs"),items:s.graphs.map(e=>({key:`graph:${e.name}`,label:e.name,hint:e.version?`v${e.version}`:void 0,icon:(0,t.jsx)(h,{size:14,"aria-hidden":"true"}),disabled:!0===s.oneShotLocked}))},{key:"skills",label:u("picker.skills"),items:e.map(e=>({key:`skill:${e.id}`,label:`/${e.label}`,hint:s.pendingSkills.includes(e.id)?u("picker.selected"):void 0,description:e.description,icon:(0,t.jsx)(X,{size:14,"aria-hidden":"true"}),disabled:!0===s.oneShotLocked||null!==s.pendingGraph}))},{key:"templates",label:u("picker.templates"),items:s.templates.map(e=>({key:`template:${e.name}`,label:`/${e.name}`,hint:e.argumentHint||void 0,description:e.description,icon:(0,t.jsx)(ei,{size:14,"aria-hidden":"true"})}))}];return n.length>0&&a.push({key:"bound",label:u("picker.boundSkills"),readOnly:!0,items:n.map(e=>({key:`bound:${e.id}`,label:`/${e.label}`,hint:e.boundBy.join(", "),icon:(0,t.jsx)(X,{size:14,"aria-hidden":"true"})}))}),a},[s,u,i]),y=(0,n.useCallback)(e=>"hero"===e?["heroes"]:"graph"===e?["graphs"]:"skill"===e?["skills","templates","bound"]:"template"===e?["templates"]:["heroes","graphs"],[]),b=(0,n.useCallback)(()=>{p&&!p.fromPlus&&a(e.slice(0,p.start)+e.slice(p.caret))},[p,e,a]),k=(0,n.useCallback)((e,t)=>{if(!e.disabled){if("actions"===t.key){"action:file"===e.key&&l(),"action:image"===e.key&&o(),"action:compact"===e.key&&d(),m(null);return}if("heroes"===t.key)s.onSelectHero(e.key.slice(5),e.label.replace(/^@/,""));else if("graphs"===t.key){let t=s.graphs.find(t=>`graph:${t.name}`===e.key);for(let e of(s.selectedHeroId&&s.onSelectHero("",""),s.pendingSkills))s.onToggleSkill(e);s.onSelectGraph(e.key.slice(6),t?.version)}else if("skills"===t.key){s.onToggleSkill(e.key.slice(6)),b(),m(null);return}else if("templates"===t.key){s.onSelectTemplate(e.key.slice(9)),m(null);return}b(),m(null)}},[s,p,e,a,l,o,d,b]),j=(0,n.useCallback)(()=>{x(""),m({kind:"all",query:"",start:0,caret:0,fromPlus:!0})},[]),w=(0,n.useRef)(!1),_=(0,n.useCallback)(()=>{w.current=null!==p},[p]),N=(0,n.useCallback)(()=>{if(w.current){w.current=!1;return}p?m(null):j()},[p,j]),C=(0,n.useCallback)(e=>{let t=e.target.value;a(t);let n=e.target.selectionStart??t.length,s=function(e,t){if(!Number.isFinite(t)||t<0||t>e.length)return null;let n=e.slice(0,t),a=-1;for(let e=n.length-1;e>=0;e-=1){let t=n[e];if("@"===t||"/"===t){a=e;break}if(/\s/.test(t))return null}if(a<0)return null;let s=n[a],i=a>0?n[a-1]:void 0;return!(void 0===i||!/[A-Za-z0-9_]/.test(i))||"/"===s&&void 0!==i&&eO.has(i)?null:{...function(e,t){let n=t.toLowerCase(),[a,...s]=n.split(":"),i=s.join(":");return"@"===e?"hero"===a||"role"===a?{kind:"hero",query:i,start:0}:"graph"===a||"flow"===a?{kind:"graph",query:i,start:0}:{kind:"all",query:n,start:0}:"skill"===a?{kind:"skill",query:i,start:0}:"template"===a?{kind:"template",query:i,start:0}:{kind:"skill",query:n,start:0}}(s,n.slice(a+1)),start:a}}(t,n);s?m({kind:s.kind,query:s.query,start:s.start,caret:n,fromPlus:!1}):m(null)},[a]),S=(0,n.useMemo)(()=>{if(p?.fromPlus)return v;let e=new Set(y(p?.kind??"all"));return v.filter(t=>e.has(t.key))},[v,p?.kind,p?.fromPlus,y]),I=(0,n.useCallback)(e=>!!p&&("ArrowDown"===e.key?(e.preventDefault(),r.current?.move(1),!0):"ArrowUp"===e.key?(e.preventDefault(),r.current?.move(-1),!0):"Enter"===e.key?!!r.current?.pickActive()&&(e.preventDefault(),!0):"Escape"===e.key&&(e.preventDefault(),m(null),!0)),[p,r]);return{open:null!==p,notePointerClose:_,handleKeyDown:I,fromPlus:p?.fromPlus===!0,filter:p?.fromPlus?g:p?.query??"",sections:S,pick:k,openFromPlus:j,onInputChange:C,setPlusFilter:x,close:()=>m(null),toggle:N}}({input:s,setInput:i,data:D,canAct:eP,panel:eT,onAttachFile:()=>Y.current?.click(),onAttachImage:()=>Q.current?.click(),onCompact:F}),eR=(0,n.useCallback)(e=>{eP&&e.dataTransfer.types.includes("Files")&&(e.preventDefault(),et.current+=1,1===et.current&&ee(!0))},[eP]),eE=(0,n.useCallback)(e=>{Z&&(e.preventDefault(),et.current-=1,et.current<=0&&(et.current=0,ee(!1)))},[Z]),e$=(0,n.useCallback)(e=>{eP&&(e.preventDefault(),e.dataTransfer.dropEffect="copy")},[eP]),ez=(0,n.useCallback)(e=>{if(!eP)return;e.preventDefault(),et.current=0,ee(!1);let t=Array.from(e.dataTransfer.files);t.length&&P(t)},[P,eP]);return(0,t.jsxs)("div",{className:"composer-shell",onDragEnter:eR,onDragLeave:eE,onDragOver:e$,onDrop:ez,children:[Z&&(0,t.jsxs)("div",{className:"composer-drop-zone",children:[(0,t.jsx)(el,{size:18}),eg("composer.dropFiles")]}),(0,t.jsx)(eU,{items:L,onEdit:eC,onRemove:eS,onSteer:eI}),(C||_.length>0)&&(0,t.jsxs)("div",{className:"composer-attachments","aria-label":eg("composer.attachedFiles"),children:[C&&e&&(0,t.jsxs)("div",{className:"composer-image-preview",children:[(0,t.jsx)("img",{src:eF(e,C.id),alt:C.name}),(0,t.jsx)("button",{type:"button",onClick:I,"aria-label":eg("composer.removeImage"),children:(0,t.jsx)(m,{size:10,"aria-hidden":"true"})})]}),_.map(e=>{var n;let a=eV[e.name.toLowerCase().split(".").pop()??""]??{Icon:ea,color:"var(--content-3)"},s=a.Icon,i=e.name.toLowerCase().split(".").pop()??"";return(0,t.jsxs)("span",{className:"composer-attachment",title:e.name,children:[(0,t.jsx)("span",{className:"composer-attachment-icon",style:{color:a.color},children:(0,t.jsx)(s,{size:14,"aria-hidden":"true"})}),(0,t.jsxs)("span",{className:"composer-attachment-body",children:[(0,t.jsx)("span",{className:"composer-attachment-name",children:e.name}),(0,t.jsxs)("span",{className:"composer-attachment-meta",children:[i.toUpperCase()," · ",(n=e.size)<1024?`${n} B`:n<1048576?`${(n/1024).toFixed(1)} KB`:`${(n/1048576).toFixed(1)} MB`," · text"]})]}),(0,t.jsx)("button",{type:"button",onClick:()=>N(e.id),"aria-label":`${eg("composer.remove")} ${e.name}`,children:(0,t.jsx)(m,{size:9,"aria-hidden":"true"})})]},e.id)})]}),(0,t.jsx)(eh,{hero:D.heroes.find(e=>e.id===D.selectedHeroId)??null,graph:D.pendingGraph,skills:D.pendingSkills.map(e=>{let t=D.skills.find(t=>t.id===e);return{id:e,label:t?.label??e}}),onClearHero:()=>D.onSelectHero("",""),onClearGraph:D.onClearGraph,onRemoveSkill:D.onToggleSkill}),(0,t.jsxs)("form",{className:"composer",onSubmit:function(e){(e.preventDefault(),r)?!l&&(o||u||R()):M()},ref:J,children:[(0,t.jsx)("div",{className:"composer-resizer","data-resizing":ed||void 0,role:"separator","aria-orientation":"horizontal","aria-label":eg("composer.hint.resizeAria"),tabIndex:0,onPointerDown:ek,onPointerMove:ej,onPointerUp:e_,onPointerCancel:e_,onDoubleClick:eb,onKeyDown:e=>{if("ArrowUp"===e.key){e.preventDefault(),eN(24);return}if("ArrowDown"===e.key){e.preventDefault(),eN(-24);return}("Enter"===e.key||" "===e.key)&&(e.preventDefault(),eb())}}),(0,t.jsxs)("div",{className:`composer-editor${V?" composer-no-session":""}`,onClick:()=>{V&&W?.()},children:[(0,t.jsx)(ep,{ref:eT,open:eM.open,sections:eM.sections,filter:eM.filter,showFilter:eM.fromPlus,ariaLabel:eg("composer.picker"),onFilterChange:eM.setPlusFilter,onPick:eM.pick,onClose:()=>{eM.close(),G.current?.focus()}}),(0,t.jsx)("textarea",{ref:G,value:s,onChange:eM.onInputChange,onKeyDown:function(t){!e||!t.nativeEvent.isComposing&&eM.handleKeyDown(t)||"Enter"!==t.key||t.shiftKey||t.nativeEvent.isComposing||(t.preventDefault(),r&&l||J.current?.requestSubmit())},rows:1,readOnly:V,disabled:o,placeholder:o?eg("composer.placeholderCompacting"):l?eg("composer.answerQuestionFirst"):r?eg("composer.placeholderSteer"):V?eg("composer.placeholderNoSession"):K?eg("composer.placeholderWelcome"):eg("composer.placeholderDefault"),"aria-label":r?eg("composer.steerAria"):eg("composer.messageAria")}),(0,t.jsx)("input",{ref:Q,className:"sr-only",type:"file",accept:"image/png,image/jpeg,image/gif,image/webp",disabled:!eP,onChange:e=>{let t=e.target.files?.[0];t&&T(t),e.currentTarget.value=""}}),(0,t.jsx)("input",{ref:Y,className:"sr-only",type:"file",multiple:!0,accept:"image/png,image/jpeg,image/gif,image/webp,text/*,.md,.mdx,.json,.yaml,.yml,.toml,.csv,.tsv,.js,.jsx,.ts,.tsx,.py,.r,.go,.rs,.java,.c,.cpp,.h,.hpp,.css,.html,.xml,.sh,.sql",disabled:!eP,onChange:e=>{let t=Array.from(e.currentTarget.files??[]);t.length&&P(t),e.currentTarget.value=""}}),(0,t.jsxs)("div",{className:"composer-toolbar-row",children:[(0,t.jsx)("div",{className:"composer-tools",children:(0,t.jsx)("button",{type:"button",className:"composer-plus","aria-expanded":eM.open,"aria-haspopup":"dialog",onPointerDown:eM.notePointerClose,"aria-label":eg("composer.insert"),title:eg("composer.insert"),disabled:!e||o,onClick:eM.toggle,children:(0,t.jsx)(S,{size:14,"aria-hidden":"true"})})}),(0,t.jsxs)("div",{className:"composer-trailing",children:[r&&(0,t.jsxs)("button",{type:"button",className:"composer-followup","aria-label":eg("composer.queueFollowUp"),disabled:!s.trim()||o||u||l,onClick:A,children:[(0,t.jsx)(er,{size:12,"aria-hidden":"true"}),(0,t.jsx)("span",{children:eg("composer.followUp")})]}),r?(0,t.jsx)("button",{type:"button",className:"composer-primary","aria-label":eg("composer.stopRun"),title:eg("composer.stopRun"),onClick:$,children:(0,t.jsx)(ec,{size:12,fill:"currentColor","aria-hidden":"true"})}):(0,t.jsx)("button",{type:"submit",className:"composer-primary","aria-label":eg("composer.send"),disabled:V||!e||!g&&!D.selectedHeroId||!s.trim()&&!d&&0===_.length&&!D.pendingGraph,children:(0,t.jsx)(en,{size:16,"aria-hidden":"true"})})]})]})]}),(0,t.jsxs)("div",{className:"composer-context-bar","aria-label":eg("composer.runContext"),children:[(0,t.jsx)(ev,{permissionMode:p,permissionReady:g,setPermissionMode:x,disabled:!e||r||o||!!D.selectedHeroId,frozen:r}),(0,t.jsx)("span",{className:"composer-context-spacer","aria-hidden":"true"}),(0,t.jsx)(ew,{models:v,providers:y,selectedModelId:b,setSelectedModelId:k,thinkingEffort:j,setThinkingEffort:w,disabled:!e||r||0===v.length||!!D.selectedHeroId}),(0,t.jsx)(eA,{contextUsage:B,stats:U})]})]}),(0,t.jsxs)("div",{className:"composer-status-line",children:[!g&&e&&!D.selectedHeroId&&(0,t.jsx)("span",{className:"composer-config-hint is-danger",children:eg("composer.policyUnavailable")}),O&&(0,t.jsx)("span",{className:"composer-status","aria-live":"polite",children:eg("composer.expanding")}),q&&(0,t.jsx)("span",{className:"composer-status diag-warning","aria-live":"polite",children:q})]})]})}function eG(){let e=`empty-glow-${(0,n.useId)().replace(/:/g,"")}`;return(0,t.jsxs)("svg",{className:"composer-welcome-glow",viewBox:"0 0 1051 468",fill:"none","aria-hidden":"true",children:[(0,t.jsx)("defs",{children:(0,t.jsxs)("filter",{id:e,x:"0",y:"0",width:"1051",height:"468",filterUnits:"userSpaceOnUse",colorInterpolationFilters:"sRGB",children:[(0,t.jsx)("feFlood",{floodOpacity:"0",result:"BackgroundImageFix"}),(0,t.jsx)("feBlend",{mode:"normal",in:"SourceGraphic",in2:"BackgroundImageFix",result:"shape"}),(0,t.jsx)("feGaussianBlur",{stdDeviation:"50",result:"effect1_foregroundBlur"})]})}),(0,t.jsx)("g",{filter:`url(#${e})`,children:(0,t.jsx)("ellipse",{cx:"525.5",cy:"234",rx:"425.5",ry:"134",fill:"var(--accent)",fillOpacity:"0.08"})})]})}function eJ(e){let{hasModel:n,onOpenSettings:a}=e,s=(0,f.useT)();return(0,t.jsx)("div",{className:"welcome-stage","data-testid":"welcome-stage",children:(0,t.jsxs)("div",{className:"welcome-stage-headline",children:[(0,t.jsx)("span",{className:"welcome-stage-mark","aria-hidden":"true",children:(0,t.jsx)(x,{size:28})}),(0,t.jsx)("h1",{className:"welcome-stage-title",children:s("welcome.headline")}),(0,t.jsx)("span",{className:"welcome-stage-preview",children:s("welcome.preview")}),!n&&(0,t.jsx)("button",{type:"button",className:"welcome-stage-settings",onClick:()=>a(),children:s("empty.noModel")})]})})}function eY(e){let{projects:n,selectedProject:a,pinnedProjectIds:s,togglePinProject:i,onRequestProject:r,onSwitchProject:l,projectSelector:o}=e,{open:c,close:d,rootRef:u}=o,p=(0,f.useT)();M(c,d);let h=a?n.find(e=>e.id===a)?.name??null:null;return(0,t.jsxs)("div",{ref:u,className:"workspace-chip-wrap",children:[(0,t.jsxs)("button",{type:"button",className:"workspace-chip",onClick:r,title:h??p("empty.project.choose"),"aria-label":h?`${h} \xb7 ${p("sidebar.selectProject")}`:p("sidebar.selectProjectEllipsis"),"aria-haspopup":"menu","aria-expanded":c,children:[h?(0,t.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.35",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:(0,t.jsx)("path",{d:"M1.5 5A1.5 1.5 0 0 1 3 3.5h3l1.2 1.5H13A1.5 1.5 0 0 1 14.5 6.5L13.6 11A1.5 1.5 0 0 1 12.1 12.5H3A1.5 1.5 0 0 1 1.5 11V5ZM1.5 8V11A1.5 1.5 0 0 0 3 12.5h10A1.5 1.5 0 0 0 14.5 11V8"})}):(0,t.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.35",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:(0,t.jsx)("path",{d:"M1.5 5A1.5 1.5 0 0 1 3 3.5h3l1.2 1.5H13A1.5 1.5 0 0 1 14.5 6.5L13.6 11A1.5 1.5 0 0 1 12.1 12.5H3A1.5 1.5 0 0 1 1.5 11V5Z"})}),(0,t.jsx)("span",{className:"workspace-chip-label",children:h??p("empty.project.choose")}),(0,t.jsx)("svg",{className:"workspace-chip-chevron",width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:(0,t.jsx)("path",{d:"M3 4.5L6 7.5L9 4.5"})})]}),c&&(0,t.jsx)(U,{projects:n,selectedProject:a,pinnedProjectIds:s,togglePinProject:i,onSelect:e=>{d(),l(e)},className:"workspace-chip-menu"})]})}let eQ=o("loader-circle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]),eZ=o("timer-reset",[["path",{d:"M10 2h4",key:"n1abiw"}],["path",{d:"M12 14v-4",key:"1evpnu"}],["path",{d:"M4 13a8 8 0 0 1 8-7 8 8 0 1 1-5.3 14L4 17.6",key:"1ts96g"}],["path",{d:"M9 17H4v5",key:"8t5av"}]]),eX=o("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"}]]),e0=o("circle-check",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]),e1=o("clock-3",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 6v6h4",key:"135r8i"}]]);function e2({completion:e}){let n=(0,f.useT)(),a=e.kind??"completed",s=e.deliveryStatus??"pending",i="pending"===s||"resume_queued"===s,r="cancelled"===a?(0,t.jsx)(eX,{size:13,"aria-hidden":"true"}):i?(0,t.jsx)(e1,{size:13,"aria-hidden":"true"}):(0,t.jsx)(e0,{size:13,"aria-hidden":"true"});return(0,t.jsxs)("div",{className:"delivery-row","data-delivery-status":s,role:"listitem",children:[(0,t.jsx)("span",{className:"delivery-icon",children:r}),(0,t.jsxs)("span",{className:"delivery-identity",children:[(0,t.jsx)("strong",{children:n("delegation.completion",{generation:String(e.generation??"")})}),(0,t.jsx)("span",{children:e4(n,"delegation.handle",s)})]}),(0,t.jsxs)("span",{className:"delivery-summary",children:[(0,t.jsx)(c,{size:11,"aria-hidden":"true"}),function(e){if(!e)return"";let t="string"==typeof e?e:JSON.stringify(e);return t.length>300?t.slice(0,300)+"…":t}(e.result)]})]})}function e4(e,t,n){let a=`${t}.${n}`,s=e(a);return s===a?n.replaceAll("_"," "):s}var e5=e.i(9323);let e3={session:void 0,rows:{}};function e6({sessionId:e}){let{deliveries:a,refreshing:s}=function(e){let[t,a]=(0,n.useState)(e3),[s,i]=(0,n.useState)(!1),r=(0,n.useRef)(e3);return(0,n.useEffect)(()=>{r.current=t},[t]),(0,n.useEffect)(()=>{let t;if(!e)return;let n=new AbortController,s=!1,l=async()=>{try{i(!0);let t=await (0,e5.apiFetch)(`/v1/sessions/${encodeURIComponent(e)}/delegation-handles?limit=20`,{signal:n.signal});if(s||n.signal.aborted)return;let l=r.current.session===e?r.current.rows:{},o=function(e,t,n){let a={rows:{},toFetch:[]};for(let s of n){if(s.sessionId&&s.sessionId!==t)continue;let n=e[s.id];if(n&&n.handle.sessionId===t&&n&&n.handle.updatedAt===s.updatedAt&&(n.completion||"completed"!==s.status)){a.rows[s.id]=n;continue}a.toFetch.push(s)}return a}(l,e,t.items),c=o.rows;if(await Promise.all(o.toFetch.map(async t=>{try{let a=await (0,e5.apiFetch)(`/v1/delegation-handles/${encodeURIComponent(t.id)}`,{signal:n.signal});if(s||n.signal.aborted||a.handle.sessionId&&a.handle.sessionId!==e)return;c[t.id]={handle:a.handle,completion:a.completion}}catch{c[t.id]={handle:t}}})),s||n.signal.aborted)return;a(t=>{let n={};for(let[a,s]of Object.entries(c)){let i=t.rows[a];n[a]=s.completion||i?.handle.sessionId!==e?s:i}return{session:e,rows:n}})}catch{}finally{s||i(!1),t=window.setTimeout(l,4e3)}};return l(),()=>{s=!0,n.abort(),void 0!==t&&window.clearTimeout(t)}},[e]),{deliveries:(0,n.useMemo)(()=>t.session!==e?[]:Object.values(t.rows).filter(t=>t.handle.sessionId===e).sort((e,t)=>(e.handle.createdAt??"").localeCompare(t.handle.createdAt??"")),[t,e]),refreshing:s}}(e);return(0,t.jsx)(e8,{deliveries:a,refreshing:s},e??"no-session")}function e8({deliveries:e,refreshing:a}){let s=(0,f.useT)(),i=(0,n.useId)(),r=e.filter(e=>e.completion).length,[l,o]=(0,n.useState)(()=>e9({seenCompletions:0,collapsed:!0},r));if(l.seenCompletions!==r&&o(e9(l,r)),!e.length)return null;let c=!l.collapsed,d=e.filter(e=>"active"===e.handle.status),u=d.length?s("conversation.delegation.active",{count:String(d.length)}):s("conversation.delegation.settled");return(0,t.jsxs)("div",{className:"background-delegation-strip","aria-label":s("conversation.delegation.background"),children:[(0,t.jsxs)("button",{type:"button",className:"background-delegation-header","aria-expanded":c,"aria-controls":i,onClick:()=>o(e=>({...e,collapsed:!e.collapsed})),children:[(0,t.jsxs)("span",{children:[(0,t.jsx)(eZ,{size:13,"aria-hidden":"true"})," ",s("conversation.delegation.background"),a&&(0,t.jsx)(eQ,{size:12,"aria-hidden":"true",className:"delivery-spinner"})]}),(0,t.jsx)("span",{"aria-hidden":"true",children:u})]}),(0,t.jsx)("span",{className:"sr-only",role:"status","aria-live":"polite",children:u}),c&&(0,t.jsx)("div",{className:"delivery-list",id:i,role:"list",children:e.map(e=>e.completion?(0,t.jsx)(e2,{completion:e.completion},e.handle.id):(0,t.jsxs)("div",{className:"delivery-row",role:"listitem",children:[(0,t.jsx)("span",{className:"delivery-icon",children:(0,t.jsx)(eZ,{size:13,"aria-hidden":"true"})}),(0,t.jsx)("span",{className:"delivery-identity",children:(0,t.jsxs)("strong",{children:[e4(s,"delegation.mode",e.handle.executionMode)," · ",e4(s,"delegation.handle",e.handle.status)]})}),(0,t.jsx)("span",{className:"delivery-summary",children:s("conversation.delegation.running")})]},e.handle.id))})]})}function e9(e,t){return t===e.seenCompletions?e:{seenCompletions:t,collapsed:!(t>e.seenCompletions)&&e.collapsed}}function e7({value:e,onChange:a,busy:s,onConfirm:i,onCancel:r}){let l=(0,f.useT)(),o=(0,n.useRef)(null);return M(!0,r,{dismissOnEscape:!s}),(0,n.useEffect)(()=>{o.current?.focus()},[]),(0,t.jsxs)("div",{className:"compaction-prompt-bar",role:"dialog","aria-label":l("conversation.compaction.aria"),children:[(0,t.jsxs)("div",{className:"compaction-prompt-header",children:[(0,t.jsxs)("span",{children:[(0,t.jsx)(eD,{size:13,"aria-hidden":"true"})," ",l("conversation.compaction.title")]}),(0,t.jsx)("button",{type:"button",className:"follow-up-close","aria-label":l("conversation.compaction.cancel"),title:l("conversation.compaction.cancel"),onClick:r,disabled:s,children:(0,t.jsx)(m,{size:13,"aria-hidden":"true"})})]}),(0,t.jsxs)("div",{className:"compaction-prompt-body",children:[(0,t.jsx)("input",{ref:o,value:e,onChange:e=>a(e.target.value),placeholder:l("conversation.compaction.placeholder"),disabled:s,onKeyDown:e=>{"Enter"!==e.key||s||(e.preventDefault(),i())}}),(0,t.jsxs)("div",{className:"compaction-prompt-actions",children:[(0,t.jsx)("button",{type:"button",className:"secondary-btn",onClick:r,disabled:s,children:l("conversation.compaction.cancel")}),(0,t.jsx)("button",{type:"button",className:"compaction-prompt-confirm",onClick:i,disabled:s,children:l(s?"conversation.compaction.creating":"conversation.compaction.confirm")})]})]})]})}let te=o("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"}]]),tt=o("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"}]]),tn=o("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"}]]),ta=o("users",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["path",{d:"M16 3.128a4 4 0 0 1 0 7.744",key:"16gr8j"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}]]),ts={read_only:"conversation.tool.risk.readOnly",local_write:"conversation.tool.risk.localWrite",shell:"conversation.tool.risk.shell",external:"conversation.tool.risk.external",delegation:"conversation.tool.risk.delegation",sensitive:"conversation.tool.risk.sensitive"};function ti({item:e,checked:n,onChange:a}){let s=(0,f.useT)();return e.standingScope?(0,t.jsxs)("label",{className:"standing-remember",children:[(0,t.jsx)("input",{type:"checkbox",checked:n,onChange:()=>a(e.callIndex)}),s("conversation.approval.remember",{scope:e.standingScope.display})]}):null}function tr({item:e}){let n=(0,f.useT)();return e.delegations?.length?(0,t.jsx)("div",{className:"approval-delegations",children:e.delegations.map((e,a)=>{let s=e.hero||e.heroHandle,i=e.goalPreview||e.assignmentPreview;return(0,t.jsxs)("div",{className:"approval-delegation",children:[(0,t.jsx)("span",{className:"approval-delegation-icon",children:(0,t.jsx)(ta,{size:14,"aria-hidden":"true"})}),(0,t.jsxs)("span",{className:"approval-delegation-copy",children:[(0,t.jsx)("strong",{children:e.name}),(0,t.jsxs)("span",{children:["@",s]}),(0,t.jsx)("small",{children:i}),!!e.skills?.length&&(0,t.jsxs)("small",{className:"approval-delegation-meta",children:[n("conversation.approval.skills"),": ",(e.skills??[]).join(", ")]}),!!e.depends?.length&&(0,t.jsxs)("small",{className:"approval-delegation-meta",children:[n("conversation.approval.after"),": ",(e.depends??[]).join(", ")]})]}),(0,t.jsxs)("span",{className:"approval-delegation-budget",children:[e.budget.maxModelCalls," ",n("conversation.approval.modelCalls")," · ",e.budget.maxToolCalls," ",n("conversation.approval.toolCalls")]})]},`${s}-${a}`)})}):(0,t.jsx)("pre",{children:e.argumentsPreview})}function tl({approval:e,resolving:a,decide:s}){let i=(0,f.useT)(),[r,l]=(0,n.useState)(()=>({approvalID:e.id,indexes:[]})),o=(0,n.useMemo)(()=>r.approvalID===e.id?r.indexes:[],[e.id,r]),c=(0,n.useMemo)(()=>new Set(o),[o]),d=e.items.some(e=>"delegate_tasks"===e.toolName||"delegate_heroes"===e.toolName),u=(0,n.useCallback)(t=>{l(n=>{let a=new Set(n.approvalID===e.id?n.indexes:[]);return a.has(t)?a.delete(t):a.add(t),{approvalID:e.id,indexes:Array.from(a).sort((e,t)=>e-t)}})},[e.id]),p=(0,n.useCallback)(()=>{s("approved",o)},[s,o]),h=(0,n.useCallback)(()=>{s("rejected",[])},[s]),m=i(1===e.items.length?"conversation.approval.batchOne":"conversation.approval.batchMany",{iteration:e.iteration,count:e.items.length});return(0,t.jsxs)("section",{className:"approval-panel","aria-label":i("conversation.approval.panelAria"),children:[(0,t.jsxs)("div",{className:"approval-heading",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("strong",{children:d?i("conversation.approval.delegationRequired"):i("conversation.approval.required")}),e.attribution?.speakerKind==="hero"&&(0,t.jsxs)("span",{className:"approval-attribution",children:["@",e.attribution.handle||e.attribution.displayName," · ",e.attribution.authority," · ",e.attribution.permissionCeiling]}),(0,t.jsx)("span",{children:m})]}),(0,t.jsx)("span",{className:"approval-waiting",children:i("conversation.approval.waiting")})]}),(0,t.jsx)("div",{className:"approval-items",children:e.items.map(e=>(0,t.jsxs)("div",{className:"approval-item",children:[(0,t.jsxs)("div",{className:"approval-item-title",children:[(0,t.jsx)("code",{children:e.toolName}),(0,t.jsx)("span",{"data-risk":e.riskClass,children:i(ts[e.riskClass]??"conversation.tool.risk.sensitive")})]}),"delegate_tasks"===e.toolName||"delegate_heroes"===e.toolName?(0,t.jsx)(tr,{item:e}):(0,t.jsx)("pre",{children:e.argumentsPreview}),(0,t.jsx)(ti,{item:e,checked:c.has(e.callIndex),onChange:u})]},`${e.callIndex}-${e.toolCallId}`))}),(0,t.jsxs)("div",{className:"approval-actions",children:[(0,t.jsx)("button",{type:"button",className:"secondary-btn",disabled:!!a,onClick:h,children:"rejected"===a?i("conversation.approval.rejecting"):i("conversation.approval.rejectBatch")}),(0,t.jsx)("button",{type:"button",disabled:!!a,onClick:p,children:"approved"===a?i("conversation.approval.approving"):i("conversation.approval.approveBatch")})]})]})}let to=o("image",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]]),tc=o("git-fork",[["circle",{cx:"12",cy:"18",r:"3",key:"1mpf1b"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["path",{d:"M18 9v2c0 .6-.4 1-1 1H7c-.6 0-1-.4-1-1V9",key:"1uq4wg"}],["path",{d:"M12 12v3",key:"158kv8"}]]);function td(e){return String(e).padStart(2,"0")}function tu(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function tp(e,t){return e.replace(/\{(\w+)\}/g,(e,n)=>t[n]??`{${n}}`)}function th({text:e,time:a,runMs:s,ttftMs:i,tokensPerSecond:r,branchMessageId:l,branchDisabled:o,onBranch:c}){let d,u,p,h,m=(0,f.useT)(),[g,x]=(0,n.useState)(!1),v=(0,n.useRef)(null),y=(0,n.useCallback)(()=>{navigator.clipboard?.writeText(e).then(()=>{x(!0),v.current&&clearTimeout(v.current),v.current=setTimeout(()=>x(!1),1e3)}).catch(()=>{})},[e]),b=a?function(e,t=Date.now()){let n=new Date(e);if(Number.isNaN(n.getTime()))return"";let a=new Date(t),s=`${td(n.getHours())}:${td(n.getMinutes())}`;if(n.getFullYear()===a.getFullYear()&&n.getMonth()===a.getMonth()&&n.getDate()===a.getDate())return s;let i=`${n.getMonth()+1}/${n.getDate()}`;return n.getFullYear()===a.getFullYear()?`${i} ${s}`:`${n.getFullYear()}/${i} ${s}`}(a):null,k=[];void 0!==s&&k.push(tp(m("message.ranFor"),{duration:(u=Math.floor((d=Math.max(0,Math.floor(s/1e3)))/60),p=d%60,u>0?tp(m("duration.minutes"),{minutes:String(u),seconds:String(p).padStart(2,"0")}):tp(m("duration.seconds"),{seconds:String(p)}))})),void 0!==i&&k.push(tp(m("message.ttft"),{seconds:(h=Math.max(0,i)/1e3)<10?String(Math.round(10*h)/10):String(Math.round(h))})),void 0!==r&&k.push(tp(m("message.tokensPerSecond"),{tps:eS(r)}));let j=[b,...k].filter(Boolean).join(" · "),w=!!(l&&c);return j||w||e?(0,t.jsxs)("div",{className:"message-actions",children:[j&&(0,t.jsx)("span",{className:"message-clock",children:j}),(0,t.jsx)("button",{type:"button",className:"message-action","aria-label":m(g?"copied":"copy"),title:m(g?"copied":"copy"),onClick:y,children:g?(0,t.jsx)(Y,{size:13,"aria-hidden":"true"}):(0,t.jsx)(Q,{size:13,"aria-hidden":"true"})}),w&&(0,t.jsx)("button",{type:"button",className:"message-action","aria-label":m("message.branch"),title:m("message.branch"),disabled:o,onClick:()=>c(l),children:(0,t.jsx)(tc,{size:13,"aria-hidden":"true"})})]}):null}function tm(){}function tf(){}var tg=e.i(76696);let tx=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,tv=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,ty={};function tb(e,t){return((t||ty).jsx?tv:tx).test(e)}var tk=e.i(24963),tj=e.i(40553);let tw={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"};var t_=e.i(57871),tN=e.i(59091),tC=e.i(15511);let tS=tP("end"),tI=tP("start");function tP(e){return function(t){let n=t&&t.position&&t.position[e]||{};if("number"==typeof n.line&&n.line>0&&"number"==typeof n.column&&n.column>0)return{line:n.line,column:n.column,offset:"number"==typeof n.offset&&n.offset>-1?n.offset:void 0}}}function tT(e){return e&&"object"==typeof e?"position"in e||"type"in e?tR(e.position):"start"in e||"end"in e?tR(e):"line"in e||"column"in e?tM(e):"":""}function tM(e){return tE(e&&e.line)+":"+tE(e&&e.column)}function tR(e){return tM(e&&e.start)+"-"+tM(e&&e.end)}function tE(e){return e&&"number"==typeof e?e:1}class tA extends Error{constructor(e,t,n){super(),"string"==typeof t&&(n=t,t=void 0);let a="",s={},i=!1;if(t&&(s="line"in t&&"column"in t||"start"in t&&"end"in t?{place:t}:"type"in t?{ancestors:[t],place:t.position}:{...t}),"string"==typeof e?a=e:!s.cause&&e&&(i=!0,a=e.message,s.cause=e),!s.ruleId&&!s.source&&"string"==typeof n){const e=n.indexOf(":");-1===e?s.ruleId=n:(s.source=n.slice(0,e),s.ruleId=n.slice(e+1))}if(!s.place&&s.ancestors&&s.ancestors){const e=s.ancestors[s.ancestors.length-1];e&&(s.place=e.position)}const r=s.place&&"start"in s.place?s.place.start:s.place;this.ancestors=s.ancestors||void 0,this.cause=s.cause||void 0,this.column=r?r.column:void 0,this.fatal=void 0,this.file="",this.message=a,this.line=r?r.line:void 0,this.name=tT(s.place)||"1:1",this.place=s.place||void 0,this.reason=this.message,this.ruleId=s.ruleId||void 0,this.source=s.source||void 0,this.stack=i&&s.cause&&"string"==typeof s.cause.stack?s.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}tA.prototype.file="",tA.prototype.name="",tA.prototype.reason="",tA.prototype.message="",tA.prototype.stack="",tA.prototype.column=void 0,tA.prototype.line=void 0,tA.prototype.ancestors=void 0,tA.prototype.cause=void 0,tA.prototype.fatal=void 0,tA.prototype.place=void 0,tA.prototype.ruleId=void 0,tA.prototype.source=void 0;let t$={}.hasOwnProperty,tz=new Map,tF=/[A-Z]/g,tL=new Set(["table","tbody","thead","tfoot","tr"]),tD=new Set(["td","th"]),tO="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function tq(e,t,n){var a,s,i,r,l,o,c,d,u;let p,h,m,f,g,x,v,y,b,k,j;return"element"===t.type?(a=e,s=t,i=n,h=p=a.schema,"svg"===s.tagName.toLowerCase()&&"html"===p.space&&(a.schema=t_.svg),a.ancestors.push(s),m=tW(a,s.tagName,!1),f=function(e,t){let n,a,s={};for(a in t.properties)if("children"!==a&&t$.call(t.properties,a)){let i=function(e,t,n){let a=(0,tj.find)(e.schema,t);if(!(null==n||"number"==typeof n&&Number.isNaN(n))){if(Array.isArray(n)&&(n=a.commaSeparated?(0,tg.stringify)(n):(0,tN.stringify)(n)),"style"===a.property){let t="object"==typeof n?n:function(e,t){try{return(0,tC.default)(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};let t=new tA("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:n,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw t.file=e.filePath||void 0,t.url=tO+"#cannot-parse-style-attribute",t}}(e,String(n));return"css"===e.stylePropertyNameCase&&(t=function(e){let t,n={};for(t in e)t$.call(e,t)&&(n[function(e){let t=e.replace(tF,tK);return"ms-"===t.slice(0,3)&&(t="-"+t),t}(t)]=e[t]);return n}(t)),["style",t]}return["react"===e.elementAttributeNameCase&&a.space?tw[a.property]||a.property:a.attribute,n]}}(e,a,t.properties[a]);if(i){let[a,r]=i;e.tableCellAlignToStyle&&"align"===a&&"string"==typeof r&&tD.has(t.tagName)?n=r:s[a]=r}}return n&&((s.style||(s.style={}))["css"===e.stylePropertyNameCase?"text-align":"textAlign"]=n),s}(a,s),g=tH(a,s),tL.has(s.tagName)&&(g=g.filter(function(e){return"string"!=typeof e||!(0,tk.whitespace)(e)})),tB(a,f,m,s),tU(f,g),a.ancestors.pop(),a.schema=p,a.create(s,m,f,i)):"mdxFlowExpression"===t.type||"mdxTextExpression"===t.type?function(e,t){if(t.data&&t.data.estree&&e.evaluater){let n=t.data.estree.body[0];return tm("ExpressionStatement"===n.type),e.evaluater.evaluateExpression(n.expression)}tV(e,t.position)}(e,t):"mdxJsxFlowElement"===t.type||"mdxJsxTextElement"===t.type?(r=e,l=t,o=n,v=x=r.schema,"svg"===l.name&&"html"===x.space&&(r.schema=t_.svg),r.ancestors.push(l),y=null===l.name?r.Fragment:tW(r,l.name,!0),b=function(e,t){let n={};for(let a of t.attributes)if("mdxJsxExpressionAttribute"===a.type)if(a.data&&a.data.estree&&e.evaluater){let t=a.data.estree.body[0];tm("ExpressionStatement"===t.type);let s=t.expression;tm("ObjectExpression"===s.type);let i=s.properties[0];tm("SpreadElement"===i.type),Object.assign(n,e.evaluater.evaluateExpression(i.argument))}else tV(e,t.position);else{let s,i=a.name;if(a.value&&"object"==typeof a.value)if(a.value.data&&a.value.data.estree&&e.evaluater){let t=a.value.data.estree.body[0];tm("ExpressionStatement"===t.type),s=e.evaluater.evaluateExpression(t.expression)}else tV(e,t.position);else s=null===a.value||a.value;n[i]=s}return n}(r,l),k=tH(r,l),tB(r,b,y,l),tU(b,k),r.ancestors.pop(),r.schema=x,r.create(l,y,b,o)):"mdxjsEsm"===t.type?function(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);tV(e,t.position)}(e,t):"root"===t.type?(c=e,d=t,u=n,tU(j={},tH(c,d)),c.create(d,c.Fragment,j,u)):"text"===t.type?t.value:void 0}function tB(e,t,n,a){"string"!=typeof n&&n!==e.Fragment&&e.passNode&&(t.node=a)}function tU(e,t){if(t.length>0){let n=t.length>1?t:t[0];n&&(e.children=n)}}function tH(e,t){let n=[],a=-1,s=e.passKeys?new Map:tz;for(;++a<t.children.length;){let i,r=t.children[a];if(e.passKeys){let e="element"===r.type?r.tagName:"mdxJsxFlowElement"===r.type||"mdxJsxTextElement"===r.type?r.name:void 0;if(e){let t=s.get(e)||0;i=e+"-"+t,s.set(e,t+1)}}let l=tq(e,r,i);void 0!==l&&n.push(l)}return n}function tW(e,t,n){let a;if(n)if(t.includes(".")){let e,n=t.split("."),s=-1;for(;++s<n.length;){let t=tb(n[s])?{type:"Identifier",name:n[s]}:{type:"Literal",value:n[s]};e=e?{type:"MemberExpression",object:e,property:t,computed:!!(s&&"Literal"===t.type),optional:!1}:t}tm(e,"always a result"),a=e}else a=tb(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};else a={type:"Literal",value:t};if("Literal"===a.type){let t=a.value;return t$.call(e.components,t)?e.components[t]:t}if(e.evaluater)return e.evaluater.evaluateExpression(a);tV(e)}function tV(e,t){let n=new tA("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw n.file=e.filePath||void 0,n.url=tO+"#cannot-handle-mdx-estrees-without-createevaluater",n}function tK(e){return"-"+e.toLowerCase()}let tG={action:["form"],cite:["blockquote","del","ins","q"],data:["object"],formAction:["button","input"],href:["a","area","base","link"],icon:["menuitem"],itemId:null,manifest:["html"],ping:["a","area"],poster:["video"],src:["audio","embed","iframe","img","input","script","source","track","video"]},tJ={};function tY(e,t){let n=t||tJ;return tQ(e,"boolean"!=typeof n.includeImageAlt||n.includeImageAlt,"boolean"!=typeof n.includeHtml||n.includeHtml)}function tQ(e,t,n){var a;if((a=e)&&"object"==typeof a){if("value"in e)return"html"!==e.type||n?e.value:"";if(t&&"alt"in e&&e.alt)return e.alt;if("children"in e)return tZ(e.children,t,n)}return Array.isArray(e)?tZ(e,t,n):""}function tZ(e,t,n){let a=[],s=-1;for(;++s<e.length;)a[s]=tQ(e[s],t,n);return a.join("")}function tX(e,t,n,a){let s,i=e.length,r=0;if(t=t<0?-t>i?0:i+t:t>i?i:t,n=n>0?n:0,a.length<1e4)(s=Array.from(a)).unshift(t,n),e.splice(...s);else for(n&&e.splice(t,n);r<a.length;)(s=a.slice(r,r+1e4)).unshift(t,0),e.splice(...s),r+=1e4,t+=1e4}function t0(e,t){return e.length>0?(tX(e,e.length,0,t),e):t}let t1={}.hasOwnProperty;function t2(e){let t={},n=-1;for(;++n<e.length;)!function(e,t){let n;for(n in t){let a,s=(t1.call(e,n)?e[n]:void 0)||(e[n]={}),i=t[n];if(i)for(a in i){t1.call(s,a)||(s[a]=[]);let e=i[a];!function(e,t){let n=-1,a=[];for(;++n<t.length;)("after"===t[n].add?e:a).push(t[n]);tX(e,0,0,a)}(s[a],Array.isArray(e)?e:e?[e]:[])}}}(t,e[n]);return t}let t4=ni(/[A-Za-z]/),t5=ni(/[\dA-Za-z]/),t3=ni(/[#-'*+\--9=?A-Z^-~]/);function t6(e){return null!==e&&(e<32||127===e)}let t8=ni(/\d/),t9=ni(/[\dA-Fa-f]/),t7=ni(/[!-/:-@[-`{-~]/);function ne(e){return null!==e&&e<-2}function nt(e){return null!==e&&(e<0||32===e)}function nn(e){return -2===e||-1===e||32===e}let na=ni(/\p{P}|\p{S}/u),ns=ni(/\s/);function ni(e){return function(t){return null!==t&&t>-1&&e.test(String.fromCharCode(t))}}function nr(e,t,n,a){let s=a?a-1:1/0,i=0;return function(a){return nn(a)?(e.enter(n),function a(r){return nn(r)&&i++<s?(e.consume(r),a):(e.exit(n),t(r))}(a)):t(a)}}let nl={tokenize:function(e){let t,n=e.attempt(this.parser.constructs.contentInitial,function(t){return null===t?void e.consume(t):(e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),nr(e,n,"linePrefix"))},function(n){return e.enter("paragraph"),function n(a){let s=e.enter("chunkText",{contentType:"text",previous:t});return t&&(t.next=s),t=s,function t(a){if(null===a){e.exit("chunkText"),e.exit("paragraph"),e.consume(a);return}return ne(a)?(e.consume(a),e.exit("chunkText"),n):(e.consume(a),t)}(a)}(n)});return n}},no={tokenize:function(e){let t,n,a,s=this,i=[],r=0;return l;function l(t){if(r<i.length){let n=i[r];return s.containerState=n[1],e.attempt(n[0].continuation,o,c)(t)}return c(t)}function o(e){if(r++,s.containerState._closeFlow){let n;s.containerState._closeFlow=void 0,t&&x();let a=s.events.length,i=a;for(;i--;)if("exit"===s.events[i][0]&&"chunkFlow"===s.events[i][1].type){n=s.events[i][1].end;break}g(r);let l=a;for(;l<s.events.length;)s.events[l][1].end={...n},l++;return tX(s.events,i+1,0,s.events.slice(a)),s.events.length=l,c(e)}return l(e)}function c(n){if(r===i.length){if(!t)return p(n);if(t.currentConstruct&&t.currentConstruct.concrete)return m(n);s.interrupt=!!(t.currentConstruct&&!t._gfmTableDynamicInterruptHack)}return s.containerState={},e.check(nc,d,u)(n)}function d(e){return t&&x(),g(r),p(e)}function u(e){return s.parser.lazy[s.now().line]=r!==i.length,a=s.now().offset,m(e)}function p(t){return s.containerState={},e.attempt(nc,h,m)(t)}function h(e){return r++,i.push([s.currentConstruct,s.containerState]),p(e)}function m(a){if(null===a){t&&x(),g(0),e.consume(a);return}return t=t||s.parser.flow(s.now()),e.enter("chunkFlow",{_tokenizer:t,contentType:"flow",previous:n}),function t(n){if(null===n){f(e.exit("chunkFlow"),!0),g(0),e.consume(n);return}return ne(n)?(e.consume(n),f(e.exit("chunkFlow")),r=0,s.interrupt=void 0,l):(e.consume(n),t)}(a)}function f(e,i){let l=s.sliceStream(e);if(i&&l.push(null),e.previous=n,n&&(n.next=e),n=e,t.defineSkip(e.start),t.write(l),s.parser.lazy[e.start.line]){let e,n,i=t.events.length;for(;i--;)if(t.events[i][1].start.offset<a&&(!t.events[i][1].end||t.events[i][1].end.offset>a))return;let l=s.events.length,o=l;for(;o--;)if("exit"===s.events[o][0]&&"chunkFlow"===s.events[o][1].type){if(e){n=s.events[o][1].end;break}e=!0}for(g(r),i=l;i<s.events.length;)s.events[i][1].end={...n},i++;tX(s.events,o+1,0,s.events.slice(l)),s.events.length=i}}function g(t){let n=i.length;for(;n-- >t;){let t=i[n];s.containerState=t[1],t[0].exit.call(s,e)}i.length=t}function x(){t.write([null]),n=void 0,t=void 0,s.containerState._closeFlow=void 0}}},nc={tokenize:function(e,t,n){return nr(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}},nd={partial:!0,tokenize:function(e,t,n){return function(t){return nn(t)?nr(e,a,"linePrefix")(t):a(t)};function a(e){return null===e||ne(e)?t(e):n(e)}}};class nu{constructor(e){this.left=e?[...e]:[],this.right=[]}get(e){if(e<0||e>=this.left.length+this.right.length)throw RangeError("Cannot access index `"+e+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return e<this.left.length?this.left[e]:this.right[this.right.length-e+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(e,t){let n=null==t?1/0:t;return n<this.left.length?this.left.slice(e,n):e>this.left.length?this.right.slice(this.right.length-n+this.left.length,this.right.length-e+this.left.length).reverse():this.left.slice(e).concat(this.right.slice(this.right.length-n+this.left.length).reverse())}splice(e,t,n){this.setCursor(Math.trunc(e));let a=this.right.splice(this.right.length-(t||0),1/0);return n&&np(this.left,n),a.reverse()}pop(){return this.setCursor(1/0),this.left.pop()}push(e){this.setCursor(1/0),this.left.push(e)}pushMany(e){this.setCursor(1/0),np(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),np(this.right,e.reverse())}setCursor(e){if(e!==this.left.length&&(!(e>this.left.length)||0!==this.right.length)&&(!(e<0)||0!==this.left.length))if(e<this.left.length){let t=this.left.splice(e,1/0);np(this.right,t.reverse())}else{let t=this.right.splice(this.left.length+this.right.length-e,1/0);np(this.left,t.reverse())}}}function np(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function nh(e){let t,n,a,s,i,r,l,o={},c=-1,d=new nu(e);for(;++c<d.length;){for(;c in o;)c=o[c];if(t=d.get(c),c&&"chunkFlow"===t[1].type&&"listItemPrefix"===d.get(c-1)[1].type&&((a=0)<(r=t[1]._tokenizer.events).length&&"lineEndingBlank"===r[a][1].type&&(a+=2),a<r.length&&"content"===r[a][1].type))for(;++a<r.length&&"content"!==r[a][1].type;)"chunkText"===r[a][1].type&&(r[a][1]._isInFirstContentOfListItem=!0,a++);if("enter"===t[0])t[1].contentType&&(Object.assign(o,function(e,t){let n,a,s=e.get(t)[1],i=e.get(t)[2],r=t-1,l=[],o=s._tokenizer;!o&&(o=i.parser[s.contentType](s.start),s._contentTypeTextTrailing&&(o._contentTypeTextTrailing=!0));let c=o.events,d=[],u={},p=-1,h=s,m=0,f=0,g=[0];for(;h;){for(;e.get(++r)[1]!==h;);l.push(r),!h._tokenizer&&(n=i.sliceStream(h),h.next||n.push(null),a&&o.defineSkip(h.start),h._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=!0),o.write(n),h._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=void 0)),a=h,h=h.next}for(h=s;++p<c.length;)"exit"===c[p][0]&&"enter"===c[p-1][0]&&c[p][1].type===c[p-1][1].type&&c[p][1].start.line!==c[p][1].end.line&&(f=p+1,g.push(f),h._tokenizer=void 0,h.previous=void 0,h=h.next);for(o.events=[],h?(h._tokenizer=void 0,h.previous=void 0):g.pop(),p=g.length;p--;){let t=c.slice(g[p],g[p+1]),n=l.pop();d.push([n,n+t.length-1]),e.splice(n,2,t)}for(d.reverse(),p=-1;++p<d.length;)u[m+d[p][0]]=m+d[p][1],m+=d[p][1]-d[p][0]-1;return u}(d,c)),c=o[c],l=!0);else if(t[1]._container){for(a=c,n=void 0;a--;)if("lineEnding"===(s=d.get(a))[1].type||"lineEndingBlank"===s[1].type)"enter"===s[0]&&(n&&(d.get(n)[1].type="lineEndingBlank"),s[1].type="lineEnding",n=a);else if("linePrefix"===s[1].type||"listItemIndent"===s[1].type);else break;n&&(t[1].end={...d.get(n)[1].start},(i=d.slice(n,c)).unshift(t),d.splice(n,c-n+1,i))}}return tX(e,0,1/0,d.slice(0)),!l}let nm={resolve:function(e){return nh(e),e},tokenize:function(e,t){let n;return function(t){return e.enter("content"),n=e.enter("chunkContent",{contentType:"content"}),a(t)};function a(t){return null===t?s(t):ne(t)?e.check(nf,i,s)(t):(e.consume(t),a)}function s(n){return e.exit("chunkContent"),e.exit("content"),t(n)}function i(t){return e.consume(t),e.exit("chunkContent"),n.next=e.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,a}}},nf={partial:!0,tokenize:function(e,t,n){let a=this;return function(t){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),nr(e,s,"linePrefix")};function s(s){if(null===s||ne(s))return n(s);let i=a.events[a.events.length-1];return!a.parser.constructs.disable.null.includes("codeIndented")&&i&&"linePrefix"===i[1].type&&i[2].sliceSerialize(i[1],!0).length>=4?t(s):e.interrupt(a.parser.constructs.flow,n,t)(s)}}},ng={tokenize:function(e){let t=this,n=e.attempt(nd,function(a){return null===a?void e.consume(a):(e.enter("lineEndingBlank"),e.consume(a),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n)},e.attempt(this.parser.constructs.flowInitial,a,nr(e,e.attempt(this.parser.constructs.flow,a,e.attempt(nm,a)),"linePrefix")));return n;function a(a){return null===a?void e.consume(a):(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),t.currentConstruct=void 0,n)}}},nx={resolveAll:nk()},nv=nb("string"),ny=nb("text");function nb(e){return{resolveAll:nk("text"===e?nj:void 0),tokenize:function(t){let n=this,a=this.parser.constructs[e],s=t.attempt(a,i,r);return i;function i(e){return o(e)?s(e):r(e)}function r(e){return null===e?void t.consume(e):(t.enter("data"),t.consume(e),l)}function l(e){return o(e)?(t.exit("data"),s(e)):(t.consume(e),l)}function o(e){if(null===e)return!0;let t=a[e],s=-1;if(t)for(;++s<t.length;){let e=t[s];if(!e.previous||e.previous.call(n,n.previous))return!0}return!1}}}}function nk(e){return function(t,n){let a,s=-1;for(;++s<=t.length;)void 0===a?t[s]&&"data"===t[s][1].type&&(a=s,s++):t[s]&&"data"===t[s][1].type||(s!==a+2&&(t[a][1].end=t[s-1][1].end,t.splice(a+2,s-a-2),s=a+2),a=void 0);return e?e(t,n):t}}function nj(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||"lineEnding"===e[n][1].type)&&"data"===e[n-1][1].type){let a,s=e[n-1][1],i=t.sliceStream(s),r=i.length,l=-1,o=0;for(;r--;){let e=i[r];if("string"==typeof e){for(l=e.length;32===e.charCodeAt(l-1);)o++,l--;if(l)break;l=-1}else if(-2===e)a=!0,o++;else if(-1===e);else{r++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(o=0),o){let i={type:n===e.length||a||o<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:r?l:s.start._bufferIndex+l,_index:s.start._index+r,line:s.end.line,column:s.end.column-o,offset:s.end.offset-o},end:{...s.end}};s.end={...i.start},s.start.offset===s.end.offset?Object.assign(s,i):(e.splice(n,0,["enter",i,t],["exit",i,t]),n+=2)}n++}return e}function nw(e){return null===e||nt(e)||ns(e)?1:na(e)?2:void 0}function n_(e,t,n){let a=[],s=-1;for(;++s<e.length;){let i=e[s].resolveAll;i&&!a.includes(i)&&(t=i(t,n),a.push(i))}return t}let nN={name:"attention",resolveAll:function(e,t){let n,a,s,i,r,l,o,c,d=-1;for(;++d<e.length;)if("enter"===e[d][0]&&"attentionSequence"===e[d][1].type&&e[d][1]._close){for(n=d;n--;)if("exit"===e[n][0]&&"attentionSequence"===e[n][1].type&&e[n][1]._open&&t.sliceSerialize(e[n][1]).charCodeAt(0)===t.sliceSerialize(e[d][1]).charCodeAt(0)){if((e[n][1]._close||e[d][1]._open)&&(e[d][1].end.offset-e[d][1].start.offset)%3&&!((e[n][1].end.offset-e[n][1].start.offset+e[d][1].end.offset-e[d][1].start.offset)%3))continue;l=e[n][1].end.offset-e[n][1].start.offset>1&&e[d][1].end.offset-e[d][1].start.offset>1?2:1;let u={...e[n][1].end},p={...e[d][1].start};nC(u,-l),nC(p,l),i={type:l>1?"strongSequence":"emphasisSequence",start:u,end:{...e[n][1].end}},r={type:l>1?"strongSequence":"emphasisSequence",start:{...e[d][1].start},end:p},s={type:l>1?"strongText":"emphasisText",start:{...e[n][1].end},end:{...e[d][1].start}},a={type:l>1?"strong":"emphasis",start:{...i.start},end:{...r.end}},e[n][1].end={...i.start},e[d][1].start={...r.end},o=[],e[n][1].end.offset-e[n][1].start.offset&&(o=t0(o,[["enter",e[n][1],t],["exit",e[n][1],t]])),o=t0(o,[["enter",a,t],["enter",i,t],["exit",i,t],["enter",s,t]]),o=t0(o,n_(t.parser.constructs.insideSpan.null,e.slice(n+1,d),t)),o=t0(o,[["exit",s,t],["enter",r,t],["exit",r,t],["exit",a,t]]),e[d][1].end.offset-e[d][1].start.offset?(c=2,o=t0(o,[["enter",e[d][1],t],["exit",e[d][1],t]])):c=0,tX(e,n-1,d-n+3,o),d=n+o.length-c-2;break}}for(d=-1;++d<e.length;)"attentionSequence"===e[d][1].type&&(e[d][1].type="data");return e},tokenize:function(e,t){let n,a=this.parser.constructs.attentionMarkers.null,s=this.previous,i=nw(s);return function(r){return n=r,e.enter("attentionSequence"),function r(l){if(l===n)return e.consume(l),r;let o=e.exit("attentionSequence"),c=nw(l),d=!c||2===c&&i||a.includes(l),u=!i||2===i&&c||a.includes(s);return o._open=!!(42===n?d:d&&(i||!u)),o._close=!!(42===n?u:u&&(c||!d)),t(l)}(r)}}};function nC(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}let nS={continuation:{tokenize:function(e,t,n){let a=this;return function(t){return nn(t)?nr(e,s,"linePrefix",a.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(t):s(t)};function s(a){return e.attempt(nS,t,n)(a)}}},exit:function(e){e.exit("blockQuote")},name:"blockQuote",tokenize:function(e,t,n){let a=this;return function(t){if(62===t){let n=a.containerState;return n.open||(e.enter("blockQuote",{_container:!0}),n.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(t),e.exit("blockQuoteMarker"),s}return n(t)};function s(n){return nn(n)?(e.enter("blockQuotePrefixWhitespace"),e.consume(n),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(n))}}},nI={name:"characterEscape",tokenize:function(e,t,n){return function(t){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(t),e.exit("escapeMarker"),a};function a(a){return t7(a)?(e.enter("characterEscapeValue"),e.consume(a),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(a)}}},nP=document.createElement("i");function nT(e){let t="&"+e+";";nP.innerHTML=t;let n=nP.textContent;return(59!==n.charCodeAt(n.length-1)||"semi"===e)&&n!==t&&n}let nM={name:"characterReference",tokenize:function(e,t,n){let a,s,i=this,r=0;return function(t){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(t),e.exit("characterReferenceMarker"),l};function l(t){return 35===t?(e.enter("characterReferenceMarkerNumeric"),e.consume(t),e.exit("characterReferenceMarkerNumeric"),o):(e.enter("characterReferenceValue"),a=31,s=t5,c(t))}function o(t){return 88===t||120===t?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(t),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),a=6,s=t9,c):(e.enter("characterReferenceValue"),a=7,s=t8,c(t))}function c(l){if(59===l&&r){let a=e.exit("characterReferenceValue");return s!==t5||nT(i.sliceSerialize(a))?(e.enter("characterReferenceMarker"),e.consume(l),e.exit("characterReferenceMarker"),e.exit("characterReference"),t):n(l)}return s(l)&&r++<a?(e.consume(l),c):n(l)}}},nR={partial:!0,tokenize:function(e,t,n){let a=this;return function(t){return null===t?n(t):(e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),s)};function s(e){return a.parser.lazy[a.now().line]?n(e):t(e)}}},nE={concrete:!0,name:"codeFenced",tokenize:function(e,t,n){let a,s=this,i={partial:!0,tokenize:function(e,t,n){let i=0;return function(t){return e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),r};function r(t){return e.enter("codeFencedFence"),nn(t)?nr(e,o,"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(t):o(t)}function o(t){return t===a?(e.enter("codeFencedFenceSequence"),function t(s){return s===a?(i++,e.consume(s),t):i>=l?(e.exit("codeFencedFenceSequence"),nn(s)?nr(e,c,"whitespace")(s):c(s)):n(s)}(t)):n(t)}function c(a){return null===a||ne(a)?(e.exit("codeFencedFence"),t(a)):n(a)}}},r=0,l=0;return function(t){var i;let c;return i=t,r=(c=s.events[s.events.length-1])&&"linePrefix"===c[1].type?c[2].sliceSerialize(c[1],!0).length:0,a=i,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),function t(s){return s===a?(l++,e.consume(s),t):l<3?n(s):(e.exit("codeFencedFenceSequence"),nn(s)?nr(e,o,"whitespace")(s):o(s))}(i)};function o(i){return null===i||ne(i)?(e.exit("codeFencedFence"),s.interrupt?t(i):e.check(nR,d,m)(i)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),function t(s){return null===s||ne(s)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),o(s)):nn(s)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),nr(e,c,"whitespace")(s)):96===s&&s===a?n(s):(e.consume(s),t)}(i))}function c(t){return null===t||ne(t)?o(t):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),function t(s){return null===s||ne(s)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),o(s)):96===s&&s===a?n(s):(e.consume(s),t)}(t))}function d(t){return e.attempt(i,m,u)(t)}function u(t){return e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),p}function p(t){return r>0&&nn(t)?nr(e,h,"linePrefix",r+1)(t):h(t)}function h(t){return null===t||ne(t)?e.check(nR,d,m)(t):(e.enter("codeFlowValue"),function t(n){return null===n||ne(n)?(e.exit("codeFlowValue"),h(n)):(e.consume(n),t)}(t))}function m(n){return e.exit("codeFenced"),t(n)}}},nA={name:"codeIndented",tokenize:function(e,t,n){let a=this;return function(t){return e.enter("codeIndented"),nr(e,s,"linePrefix",5)(t)};function s(t){let s=a.events[a.events.length-1];return s&&"linePrefix"===s[1].type&&s[2].sliceSerialize(s[1],!0).length>=4?function t(n){return null===n?i(n):ne(n)?e.attempt(n$,t,i)(n):(e.enter("codeFlowValue"),function n(a){return null===a||ne(a)?(e.exit("codeFlowValue"),t(a)):(e.consume(a),n)}(n))}(t):n(t)}function i(n){return e.exit("codeIndented"),t(n)}}},n$={partial:!0,tokenize:function(e,t,n){let a=this;return s;function s(t){return a.parser.lazy[a.now().line]?n(t):ne(t)?(e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),s):nr(e,i,"linePrefix",5)(t)}function i(e){let i=a.events[a.events.length-1];return i&&"linePrefix"===i[1].type&&i[2].sliceSerialize(i[1],!0).length>=4?t(e):ne(e)?s(e):n(e)}}};function nz(e,t,n,a,s,i,r,l,o){let c=o||1/0,d=0;return function(t){return 60===t?(e.enter(a),e.enter(s),e.enter(i),e.consume(t),e.exit(i),u):null===t||32===t||41===t||t6(t)?n(t):(e.enter(a),e.enter(r),e.enter(l),e.enter("chunkString",{contentType:"string"}),m(t))};function u(n){return 62===n?(e.enter(i),e.consume(n),e.exit(i),e.exit(s),e.exit(a),t):(e.enter(l),e.enter("chunkString",{contentType:"string"}),p(n))}function p(t){return 62===t?(e.exit("chunkString"),e.exit(l),u(t)):null===t||60===t||ne(t)?n(t):(e.consume(t),92===t?h:p)}function h(t){return 60===t||62===t||92===t?(e.consume(t),p):p(t)}function m(s){return!d&&(null===s||41===s||nt(s))?(e.exit("chunkString"),e.exit(l),e.exit(r),e.exit(a),t(s)):d<c&&40===s?(e.consume(s),d++,m):41===s?(e.consume(s),d--,m):null===s||32===s||40===s||t6(s)?n(s):(e.consume(s),92===s?f:m)}function f(t){return 40===t||41===t||92===t?(e.consume(t),m):m(t)}}function nF(e,t,n,a,s,i){let r,l=this,o=0;return function(t){return e.enter(a),e.enter(s),e.consume(t),e.exit(s),e.enter(i),c};function c(u){return o>999||null===u||91===u||93===u&&!r||94===u&&!o&&"_hiddenFootnoteSupport"in l.parser.constructs?n(u):93===u?(e.exit(i),e.enter(s),e.consume(u),e.exit(s),e.exit(a),t):ne(u)?(e.enter("lineEnding"),e.consume(u),e.exit("lineEnding"),c):(e.enter("chunkString",{contentType:"string"}),d(u))}function d(t){return null===t||91===t||93===t||ne(t)||o++>999?(e.exit("chunkString"),c(t)):(e.consume(t),r||(r=!nn(t)),92===t?u:d)}function u(t){return 91===t||92===t||93===t?(e.consume(t),o++,d):d(t)}}function nL(e,t,n,a,s,i){let r;return function(t){return 34===t||39===t||40===t?(e.enter(a),e.enter(s),e.consume(t),e.exit(s),r=40===t?41:t,l):n(t)};function l(n){return n===r?(e.enter(s),e.consume(n),e.exit(s),e.exit(a),t):(e.enter(i),o(n))}function o(t){return t===r?(e.exit(i),l(r)):null===t?n(t):ne(t)?(e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),nr(e,o,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),c(t))}function c(t){return t===r||null===t||ne(t)?(e.exit("chunkString"),o(t)):(e.consume(t),92===t?d:c)}function d(t){return t===r||92===t?(e.consume(t),c):c(t)}}function nD(e,t){let n;return function a(s){return ne(s)?(e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),n=!0,a):nn(s)?nr(e,a,n?"linePrefix":"lineSuffix")(s):t(s)}}function nO(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}let nq={partial:!0,tokenize:function(e,t,n){return function(t){return nt(t)?nD(e,a)(t):n(t)};function a(t){return nL(e,s,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(t)}function s(t){return nn(t)?nr(e,i,"whitespace")(t):i(t)}function i(e){return null===e||ne(e)?t(e):n(e)}}},nB=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],nU=["pre","script","style","textarea"],nH={partial:!0,tokenize:function(e,t,n){return function(a){return e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),e.attempt(nd,t,n)}}},nW={partial:!0,tokenize:function(e,t,n){let a=this;return function(t){return ne(t)?(e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),s):n(t)};function s(e){return a.parser.lazy[a.now().line]?n(e):t(e)}}},nV={name:"labelEnd",resolveAll:function(e){let t=-1,n=[];for(;++t<e.length;){let a=e[t][1];if(n.push(e[t]),"labelImage"===a.type||"labelLink"===a.type||"labelEnd"===a.type){let e="labelImage"===a.type?4:2;a.type="data",t+=e}}return e.length!==n.length&&tX(e,0,e.length,n),e},resolveTo:function(e,t){let n,a,s,i,r=e.length,l=0;for(;r--;)if(n=e[r][1],a){if("link"===n.type||"labelLink"===n.type&&n._inactive)break;"enter"===e[r][0]&&"labelLink"===n.type&&(n._inactive=!0)}else if(s){if("enter"===e[r][0]&&("labelImage"===n.type||"labelLink"===n.type)&&!n._balanced&&(a=r,"labelLink"!==n.type)){l=2;break}}else"labelEnd"===n.type&&(s=r);let o={type:"labelLink"===e[a][1].type?"link":"image",start:{...e[a][1].start},end:{...e[e.length-1][1].end}},c={type:"label",start:{...e[a][1].start},end:{...e[s][1].end}},d={type:"labelText",start:{...e[a+l+2][1].end},end:{...e[s-2][1].start}};return i=t0(i=[["enter",o,t],["enter",c,t]],e.slice(a+1,a+l+3)),i=t0(i,[["enter",d,t]]),i=t0(i,n_(t.parser.constructs.insideSpan.null,e.slice(a+l+4,s-3),t)),i=t0(i,[["exit",d,t],e[s-2],e[s-1],["exit",c,t]]),i=t0(i,e.slice(s+1)),i=t0(i,[["exit",o,t]]),tX(e,a,e.length,i),e},tokenize:function(e,t,n){let a,s,i=this,r=i.events.length;for(;r--;)if(("labelImage"===i.events[r][1].type||"labelLink"===i.events[r][1].type)&&!i.events[r][1]._balanced){a=i.events[r][1];break}return function(t){return a?a._inactive?d(t):(s=i.parser.defined.includes(nO(i.sliceSerialize({start:a.end,end:i.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(t),e.exit("labelMarker"),e.exit("labelEnd"),l):n(t)};function l(t){return 40===t?e.attempt(nK,c,s?c:d)(t):91===t?e.attempt(nG,c,s?o:d)(t):s?c(t):d(t)}function o(t){return e.attempt(nJ,c,d)(t)}function c(e){return t(e)}function d(e){return a._balanced=!0,n(e)}}},nK={tokenize:function(e,t,n){return function(t){return e.enter("resource"),e.enter("resourceMarker"),e.consume(t),e.exit("resourceMarker"),a};function a(t){return nt(t)?nD(e,s)(t):s(t)}function s(t){return 41===t?c(t):nz(e,i,r,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(t)}function i(t){return nt(t)?nD(e,l)(t):c(t)}function r(e){return n(e)}function l(t){return 34===t||39===t||40===t?nL(e,o,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(t):c(t)}function o(t){return nt(t)?nD(e,c)(t):c(t)}function c(a){return 41===a?(e.enter("resourceMarker"),e.consume(a),e.exit("resourceMarker"),e.exit("resource"),t):n(a)}}},nG={tokenize:function(e,t,n){let a=this;return function(t){return nF.call(a,e,s,i,"reference","referenceMarker","referenceString")(t)};function s(e){return a.parser.defined.includes(nO(a.sliceSerialize(a.events[a.events.length-1][1]).slice(1,-1)))?t(e):n(e)}function i(e){return n(e)}}},nJ={tokenize:function(e,t,n){return function(t){return e.enter("reference"),e.enter("referenceMarker"),e.consume(t),e.exit("referenceMarker"),a};function a(a){return 93===a?(e.enter("referenceMarker"),e.consume(a),e.exit("referenceMarker"),e.exit("reference"),t):n(a)}}},nY={name:"labelStartImage",resolveAll:nV.resolveAll,tokenize:function(e,t,n){let a=this;return function(t){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(t),e.exit("labelImageMarker"),s};function s(t){return 91===t?(e.enter("labelMarker"),e.consume(t),e.exit("labelMarker"),e.exit("labelImage"),i):n(t)}function i(e){return 94===e&&"_hiddenFootnoteSupport"in a.parser.constructs?n(e):t(e)}}},nQ={name:"labelStartLink",resolveAll:nV.resolveAll,tokenize:function(e,t,n){let a=this;return function(t){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(t),e.exit("labelMarker"),e.exit("labelLink"),s};function s(e){return 94===e&&"_hiddenFootnoteSupport"in a.parser.constructs?n(e):t(e)}}},nZ={name:"lineEnding",tokenize:function(e,t){return function(n){return e.enter("lineEnding"),e.consume(n),e.exit("lineEnding"),nr(e,t,"linePrefix")}}},nX={name:"thematicBreak",tokenize:function(e,t,n){let a,s=0;return function(i){var r;return e.enter("thematicBreak"),a=r=i,function i(r){return r===a?(e.enter("thematicBreakSequence"),function t(n){return n===a?(e.consume(n),s++,t):(e.exit("thematicBreakSequence"),nn(n)?nr(e,i,"whitespace")(n):i(n))}(r)):s>=3&&(null===r||ne(r))?(e.exit("thematicBreak"),t(r)):n(r)}(r)}}},n0={continuation:{tokenize:function(e,t,n){let a=this;return a.containerState._closeFlow=void 0,e.check(nd,function(n){return a.containerState.furtherBlankLines=a.containerState.furtherBlankLines||a.containerState.initialBlankLine,nr(e,t,"listItemIndent",a.containerState.size+1)(n)},function(n){return a.containerState.furtherBlankLines||!nn(n)?(a.containerState.furtherBlankLines=void 0,a.containerState.initialBlankLine=void 0,s(n)):(a.containerState.furtherBlankLines=void 0,a.containerState.initialBlankLine=void 0,e.attempt(n2,t,s)(n))});function s(s){return a.containerState._closeFlow=!0,a.interrupt=void 0,nr(e,e.attempt(n0,t,n),"linePrefix",a.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(s)}}},exit:function(e){e.exit(this.containerState.type)},name:"list",tokenize:function(e,t,n){let a=this,s=a.events[a.events.length-1],i=s&&"linePrefix"===s[1].type?s[2].sliceSerialize(s[1],!0).length:0,r=0;return function(t){let s=a.containerState.type||(42===t||43===t||45===t?"listUnordered":"listOrdered");if("listUnordered"===s?!a.containerState.marker||t===a.containerState.marker:t8(t)){if(a.containerState.type||(a.containerState.type=s,e.enter(s,{_container:!0})),"listUnordered"===s)return e.enter("listItemPrefix"),42===t||45===t?e.check(nX,n,l)(t):l(t);if(!a.interrupt||49===t)return e.enter("listItemPrefix"),e.enter("listItemValue"),function t(s){return t8(s)&&++r<10?(e.consume(s),t):(!a.interrupt||r<2)&&(a.containerState.marker?s===a.containerState.marker:41===s||46===s)?(e.exit("listItemValue"),l(s)):n(s)}(t)}return n(t)};function l(t){return e.enter("listItemMarker"),e.consume(t),e.exit("listItemMarker"),a.containerState.marker=a.containerState.marker||t,e.check(nd,a.interrupt?n:o,e.attempt(n1,d,c))}function o(e){return a.containerState.initialBlankLine=!0,i++,d(e)}function c(t){return nn(t)?(e.enter("listItemPrefixWhitespace"),e.consume(t),e.exit("listItemPrefixWhitespace"),d):n(t)}function d(n){return a.containerState.size=i+a.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(n)}}},n1={partial:!0,tokenize:function(e,t,n){let a=this;return nr(e,function(e){let s=a.events[a.events.length-1];return!nn(e)&&s&&"listItemPrefixWhitespace"===s[1].type?t(e):n(e)},"listItemPrefixWhitespace",a.parser.constructs.disable.null.includes("codeIndented")?void 0:5)}},n2={partial:!0,tokenize:function(e,t,n){let a=this;return nr(e,function(e){let s=a.events[a.events.length-1];return s&&"listItemIndent"===s[1].type&&s[2].sliceSerialize(s[1],!0).length===a.containerState.size?t(e):n(e)},"listItemIndent",a.containerState.size+1)}},n4={name:"setextUnderline",resolveTo:function(e,t){let n,a,s,i=e.length;for(;i--;)if("enter"===e[i][0]){if("content"===e[i][1].type){n=i;break}"paragraph"===e[i][1].type&&(a=i)}else"content"===e[i][1].type&&e.splice(i,1),s||"definition"!==e[i][1].type||(s=i);let r={type:"setextHeading",start:{...e[n][1].start},end:{...e[e.length-1][1].end}};return e[a][1].type="setextHeadingText",s?(e.splice(a,0,["enter",r,t]),e.splice(s+1,0,["exit",e[n][1],t]),e[n][1].end={...e[s][1].end}):e[n][1]=r,e.push(["exit",r,t]),e},tokenize:function(e,t,n){let a,s=this;return function(t){var r;let l,o=s.events.length;for(;o--;)if("lineEnding"!==s.events[o][1].type&&"linePrefix"!==s.events[o][1].type&&"content"!==s.events[o][1].type){l="paragraph"===s.events[o][1].type;break}return!s.parser.lazy[s.now().line]&&(s.interrupt||l)?(e.enter("setextHeadingLine"),a=t,r=t,e.enter("setextHeadingLineSequence"),function t(n){return n===a?(e.consume(n),t):(e.exit("setextHeadingLineSequence"),nn(n)?nr(e,i,"lineSuffix")(n):i(n))}(r)):n(t)};function i(a){return null===a||ne(a)?(e.exit("setextHeadingLine"),t(a)):n(a)}}};e.s(["attentionMarkers",0,{null:[42,95]},"contentInitial",0,{91:{name:"definition",tokenize:function(e,t,n){let a,s=this;return function(t){var a;return e.enter("definition"),a=t,nF.call(s,e,i,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(a)};function i(t){return(a=nO(s.sliceSerialize(s.events[s.events.length-1][1]).slice(1,-1)),58===t)?(e.enter("definitionMarker"),e.consume(t),e.exit("definitionMarker"),r):n(t)}function r(t){return nt(t)?nD(e,l)(t):l(t)}function l(t){return nz(e,o,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(t)}function o(t){return e.attempt(nq,c,c)(t)}function c(t){return nn(t)?nr(e,d,"whitespace")(t):d(t)}function d(i){return null===i||ne(i)?(e.exit("definition"),s.parser.defined.push(a),t(i)):n(i)}}}},"disable",0,{null:[]},"document",0,{42:n0,43:n0,45:n0,48:n0,49:n0,50:n0,51:n0,52:n0,53:n0,54:n0,55:n0,56:n0,57:n0,62:nS},"flow",0,{35:{name:"headingAtx",resolve:function(e,t){let n,a,s=e.length-2,i=3;return"whitespace"===e[3][1].type&&(i+=2),s-2>i&&"whitespace"===e[s][1].type&&(s-=2),"atxHeadingSequence"===e[s][1].type&&(i===s-1||s-4>i&&"whitespace"===e[s-2][1].type)&&(s-=i+1===s?2:4),s>i&&(n={type:"atxHeadingText",start:e[i][1].start,end:e[s][1].end},a={type:"chunkText",start:e[i][1].start,end:e[s][1].end,contentType:"text"},tX(e,i,s-i+1,[["enter",n,t],["enter",a,t],["exit",a,t],["exit",n,t]])),e},tokenize:function(e,t,n){let a=0;return function(s){var i;return e.enter("atxHeading"),i=s,e.enter("atxHeadingSequence"),function s(i){return 35===i&&a++<6?(e.consume(i),s):null===i||nt(i)?(e.exit("atxHeadingSequence"),function n(a){return 35===a?(e.enter("atxHeadingSequence"),function t(a){return 35===a?(e.consume(a),t):(e.exit("atxHeadingSequence"),n(a))}(a)):null===a||ne(a)?(e.exit("atxHeading"),t(a)):nn(a)?nr(e,n,"whitespace")(a):(e.enter("atxHeadingText"),function t(a){return null===a||35===a||nt(a)?(e.exit("atxHeadingText"),n(a)):(e.consume(a),t)}(a))}(i)):n(i)}(i)}}},42:nX,45:[n4,nX],60:{concrete:!0,name:"htmlFlow",resolveTo:function(e){let t=e.length;for(;t--&&("enter"!==e[t][0]||"htmlFlow"!==e[t][1].type););return t>1&&"linePrefix"===e[t-2][1].type&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e},tokenize:function(e,t,n){let a,s,i,r,l,o=this;return function(t){var n;return n=t,e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(n),c};function c(r){return 33===r?(e.consume(r),d):47===r?(e.consume(r),s=!0,h):63===r?(e.consume(r),a=3,o.interrupt?t:R):t4(r)?(e.consume(r),i=String.fromCharCode(r),m):n(r)}function d(s){return 45===s?(e.consume(s),a=2,u):91===s?(e.consume(s),a=5,r=0,p):t4(s)?(e.consume(s),a=4,o.interrupt?t:R):n(s)}function u(a){return 45===a?(e.consume(a),o.interrupt?t:R):n(a)}function p(a){let s="CDATA[";return a===s.charCodeAt(r++)?(e.consume(a),r===s.length)?o.interrupt?t:_:p:n(a)}function h(t){return t4(t)?(e.consume(t),i=String.fromCharCode(t),m):n(t)}function m(r){if(null===r||47===r||62===r||nt(r)){let l=47===r,c=i.toLowerCase();return!l&&!s&&nU.includes(c)?(a=1,o.interrupt?t(r):_(r)):nB.includes(i.toLowerCase())?(a=6,l)?(e.consume(r),f):o.interrupt?t(r):_(r):(a=7,o.interrupt&&!o.parser.lazy[o.now().line]?n(r):s?function t(n){return nn(n)?(e.consume(n),t):j(n)}(r):g(r))}return 45===r||t5(r)?(e.consume(r),i+=String.fromCharCode(r),m):n(r)}function f(a){return 62===a?(e.consume(a),o.interrupt?t:_):n(a)}function g(t){return 47===t?(e.consume(t),j):58===t||95===t||t4(t)?(e.consume(t),x):nn(t)?(e.consume(t),g):j(t)}function x(t){return 45===t||46===t||58===t||95===t||t5(t)?(e.consume(t),x):v(t)}function v(t){return 61===t?(e.consume(t),y):nn(t)?(e.consume(t),v):g(t)}function y(t){return null===t||60===t||61===t||62===t||96===t?n(t):34===t||39===t?(e.consume(t),l=t,b):nn(t)?(e.consume(t),y):function t(n){return null===n||34===n||39===n||47===n||60===n||61===n||62===n||96===n||nt(n)?v(n):(e.consume(n),t)}(t)}function b(t){return t===l?(e.consume(t),l=null,k):null===t||ne(t)?n(t):(e.consume(t),b)}function k(e){return 47===e||62===e||nn(e)?g(e):n(e)}function j(t){return 62===t?(e.consume(t),w):n(t)}function w(t){return null===t||ne(t)?_(t):nn(t)?(e.consume(t),w):n(t)}function _(t){return 45===t&&2===a?(e.consume(t),I):60===t&&1===a?(e.consume(t),P):62===t&&4===a?(e.consume(t),E):63===t&&3===a?(e.consume(t),R):93===t&&5===a?(e.consume(t),M):ne(t)&&(6===a||7===a)?(e.exit("htmlFlowData"),e.check(nH,A,N)(t)):null===t||ne(t)?(e.exit("htmlFlowData"),N(t)):(e.consume(t),_)}function N(t){return e.check(nW,C,A)(t)}function C(t){return e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),S}function S(t){return null===t||ne(t)?N(t):(e.enter("htmlFlowData"),_(t))}function I(t){return 45===t?(e.consume(t),R):_(t)}function P(t){return 47===t?(e.consume(t),i="",T):_(t)}function T(t){if(62===t){let n=i.toLowerCase();return nU.includes(n)?(e.consume(t),E):_(t)}return t4(t)&&i.length<8?(e.consume(t),i+=String.fromCharCode(t),T):_(t)}function M(t){return 93===t?(e.consume(t),R):_(t)}function R(t){return 62===t?(e.consume(t),E):45===t&&2===a?(e.consume(t),R):_(t)}function E(t){return null===t||ne(t)?(e.exit("htmlFlowData"),A(t)):(e.consume(t),E)}function A(n){return e.exit("htmlFlow"),t(n)}}},61:n4,95:nX,96:nE,126:nE},"flowInitial",0,{[-2]:nA,[-1]:nA,32:nA},"insideSpan",0,{null:[nN,nx]},"string",0,{38:nM,92:nI},"text",0,{[-5]:nZ,[-4]:nZ,[-3]:nZ,33:nY,38:nM,42:nN,60:[{name:"autolink",tokenize:function(e,t,n){let a=0;return function(t){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(t),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),s};function s(t){return t4(t)?(e.consume(t),i):64===t?n(t):l(t)}function i(t){return 43===t||45===t||46===t||t5(t)?(a=1,function t(n){return 58===n?(e.consume(n),a=0,r):(43===n||45===n||46===n||t5(n))&&a++<32?(e.consume(n),t):(a=0,l(n))}(t)):l(t)}function r(a){return 62===a?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(a),e.exit("autolinkMarker"),e.exit("autolink"),t):null===a||32===a||60===a||t6(a)?n(a):(e.consume(a),r)}function l(t){return 64===t?(e.consume(t),o):t3(t)?(e.consume(t),l):n(t)}function o(s){return t5(s)?function s(i){return 46===i?(e.consume(i),a=0,o):62===i?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(i),e.exit("autolinkMarker"),e.exit("autolink"),t):function t(i){if((45===i||t5(i))&&a++<63){let n=45===i?t:s;return e.consume(i),n}return n(i)}(i)}(s):n(s)}}},{name:"htmlText",tokenize:function(e,t,n){let a,s,i,r=this;return function(t){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(t),l};function l(t){return 33===t?(e.consume(t),o):47===t?(e.consume(t),b):63===t?(e.consume(t),v):t4(t)?(e.consume(t),j):n(t)}function o(t){return 45===t?(e.consume(t),c):91===t?(e.consume(t),s=0,h):t4(t)?(e.consume(t),x):n(t)}function c(t){return 45===t?(e.consume(t),p):n(t)}function d(t){return null===t?n(t):45===t?(e.consume(t),u):ne(t)?(i=d,T(t)):(e.consume(t),d)}function u(t){return 45===t?(e.consume(t),p):d(t)}function p(e){return 62===e?P(e):45===e?u(e):d(e)}function h(t){let a="CDATA[";return t===a.charCodeAt(s++)?(e.consume(t),s===a.length?m:h):n(t)}function m(t){return null===t?n(t):93===t?(e.consume(t),f):ne(t)?(i=m,T(t)):(e.consume(t),m)}function f(t){return 93===t?(e.consume(t),g):m(t)}function g(t){return 62===t?P(t):93===t?(e.consume(t),g):m(t)}function x(t){return null===t||62===t?P(t):ne(t)?(i=x,T(t)):(e.consume(t),x)}function v(t){return null===t?n(t):63===t?(e.consume(t),y):ne(t)?(i=v,T(t)):(e.consume(t),v)}function y(e){return 62===e?P(e):v(e)}function b(t){return t4(t)?(e.consume(t),k):n(t)}function k(t){return 45===t||t5(t)?(e.consume(t),k):function t(n){return ne(n)?(i=t,T(n)):nn(n)?(e.consume(n),t):P(n)}(t)}function j(t){return 45===t||t5(t)?(e.consume(t),j):47===t||62===t||nt(t)?w(t):n(t)}function w(t){return 47===t?(e.consume(t),P):58===t||95===t||t4(t)?(e.consume(t),_):ne(t)?(i=w,T(t)):nn(t)?(e.consume(t),w):P(t)}function _(t){return 45===t||46===t||58===t||95===t||t5(t)?(e.consume(t),_):function t(n){return 61===n?(e.consume(n),N):ne(n)?(i=t,T(n)):nn(n)?(e.consume(n),t):w(n)}(t)}function N(t){return null===t||60===t||61===t||62===t||96===t?n(t):34===t||39===t?(e.consume(t),a=t,C):ne(t)?(i=N,T(t)):nn(t)?(e.consume(t),N):(e.consume(t),S)}function C(t){return t===a?(e.consume(t),a=void 0,I):null===t?n(t):ne(t)?(i=C,T(t)):(e.consume(t),C)}function S(t){return null===t||34===t||39===t||60===t||61===t||96===t?n(t):47===t||62===t||nt(t)?w(t):(e.consume(t),S)}function I(e){return 47===e||62===e||nt(e)?w(e):n(e)}function P(a){return 62===a?(e.consume(a),e.exit("htmlTextData"),e.exit("htmlText"),t):n(a)}function T(t){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),M}function M(t){return nn(t)?nr(e,R,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(t):R(t)}function R(t){return e.enter("htmlTextData"),i(t)}}}],91:nQ,92:[{name:"hardBreakEscape",tokenize:function(e,t,n){return function(t){return e.enter("hardBreakEscape"),e.consume(t),a};function a(a){return ne(a)?(e.exit("hardBreakEscape"),t(a)):n(a)}}},nI],93:nV,95:nN,96:{name:"codeText",previous:function(e){return 96!==e||"characterEscape"===this.events[this.events.length-1][1].type},resolve:function(e){let t,n,a=e.length-4,s=3;if(("lineEnding"===e[3][1].type||"space"===e[s][1].type)&&("lineEnding"===e[a][1].type||"space"===e[a][1].type)){for(t=s;++t<a;)if("codeTextData"===e[t][1].type){e[s][1].type="codeTextPadding",e[a][1].type="codeTextPadding",s+=2,a-=2;break}}for(t=s-1,a++;++t<=a;)void 0===n?t!==a&&"lineEnding"!==e[t][1].type&&(n=t):(t===a||"lineEnding"===e[t][1].type)&&(e[n][1].type="codeTextData",t!==n+2&&(e[n][1].end=e[t-1][1].end,e.splice(n+2,t-n-2),a-=t-n-2,t=n+2),n=void 0);return e},tokenize:function(e,t,n){let a,s,i=0;return function(t){return e.enter("codeText"),e.enter("codeTextSequence"),function t(n){return 96===n?(e.consume(n),i++,t):(e.exit("codeTextSequence"),r(n))}(t)};function r(o){return null===o?n(o):32===o?(e.enter("space"),e.consume(o),e.exit("space"),r):96===o?(s=e.enter("codeTextSequence"),a=0,function n(r){return 96===r?(e.consume(r),a++,n):a===i?(e.exit("codeTextSequence"),e.exit("codeText"),t(r)):(s.type="codeTextData",l(r))}(o)):ne(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),r):(e.enter("codeTextData"),l(o))}function l(t){return null===t||32===t||96===t||ne(t)?(e.exit("codeTextData"),r(t)):(e.consume(t),l)}}}}],4127);var n5=e.i(4127);let n3=/[\0\t\n\r]/g;function n6(e,t){let n=Number.parseInt(e,t);return n<9||11===n||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(65535&n)==65535||(65535&n)==65534||n>1114111?"�":String.fromCodePoint(n)}let n8=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function n9(e,t,n){if(t)return t;if(35===n.charCodeAt(0)){let e=n.charCodeAt(1),t=120===e||88===e;return n6(n.slice(t?2:1),t?16:10)}return nT(n)||e}let n7={}.hasOwnProperty;function ae(e){return{line:e.line,column:e.column,offset:e.offset}}function at(e,t){if(e)throw Error("Cannot close `"+e.type+"` ("+tT({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+tT({start:t.start,end:t.end})+") is open");throw Error("Cannot close document, a token (`"+t.type+"`, "+tT({start:t.start,end:t.end})+") is still open")}function an(e){let t=this;t.parser=function(n){var a,s;let i,r,l,o;return"object"==typeof(a={...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})&&(s=a,a=void 0),(function(e){let t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:a(x),autolinkProtocol:c,autolinkEmail:c,atxHeading:a(m),blockQuote:a(function(){return{type:"blockquote",children:[]}}),characterEscape:c,characterReference:c,codeFenced:a(h),codeFencedFenceInfo:s,codeFencedFenceMeta:s,codeIndented:a(h,s),codeText:a(function(){return{type:"inlineCode",value:""}},s),codeTextData:c,data:c,codeFlowValue:c,definition:a(function(){return{type:"definition",identifier:"",label:null,title:null,url:""}}),definitionDestinationString:s,definitionLabelString:s,definitionTitleString:s,emphasis:a(function(){return{type:"emphasis",children:[]}}),hardBreakEscape:a(f),hardBreakTrailing:a(f),htmlFlow:a(g,s),htmlFlowData:c,htmlText:a(g,s),htmlTextData:c,image:a(function(){return{type:"image",title:null,url:"",alt:null}}),label:s,link:a(x),listItem:a(function(e){return{type:"listItem",spread:e._spread,checked:null,children:[]}}),listItemValue:function(e){this.data.expectingFirstListItemValue&&(this.stack[this.stack.length-2].start=Number.parseInt(this.sliceSerialize(e),10),this.data.expectingFirstListItemValue=void 0)},listOrdered:a(v,function(){this.data.expectingFirstListItemValue=!0}),listUnordered:a(v),paragraph:a(function(){return{type:"paragraph",children:[]}}),reference:function(){this.data.referenceType="collapsed"},referenceString:s,resourceDestinationString:s,resourceTitleString:s,setextHeading:a(m),strong:a(function(){return{type:"strong",children:[]}}),thematicBreak:a(function(){return{type:"thematicBreak"}})},exit:{atxHeading:r(),atxHeadingSequence:function(e){let t=this.stack[this.stack.length-1];t.depth||(t.depth=this.sliceSerialize(e).length)},autolink:r(),autolinkEmail:function(e){d.call(this,e),this.stack[this.stack.length-1].url="mailto:"+this.sliceSerialize(e)},autolinkProtocol:function(e){d.call(this,e),this.stack[this.stack.length-1].url=this.sliceSerialize(e)},blockQuote:r(),characterEscapeValue:d,characterReferenceMarkerHexadecimal:p,characterReferenceMarkerNumeric:p,characterReferenceValue:function(e){let t,n=this.sliceSerialize(e),a=this.data.characterReferenceType;a?(t=n6(n,"characterReferenceMarkerNumeric"===a?10:16),this.data.characterReferenceType=void 0):t=nT(n);let s=this.stack[this.stack.length-1];s.value+=t},characterReference:function(e){this.stack.pop().position.end=ae(e.end)},codeFenced:r(function(){let e=this.resume();this.stack[this.stack.length-1].value=e.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}),codeFencedFence:function(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)},codeFencedFenceInfo:function(){let e=this.resume();this.stack[this.stack.length-1].lang=e},codeFencedFenceMeta:function(){let e=this.resume();this.stack[this.stack.length-1].meta=e},codeFlowValue:d,codeIndented:r(function(){let e=this.resume();this.stack[this.stack.length-1].value=e.replace(/(\r?\n|\r)$/g,"")}),codeText:r(function(){let e=this.resume();this.stack[this.stack.length-1].value=e}),codeTextData:d,data:d,definition:r(),definitionDestinationString:function(){let e=this.resume();this.stack[this.stack.length-1].url=e},definitionLabelString:function(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=nO(this.sliceSerialize(e)).toLowerCase()},definitionTitleString:function(){let e=this.resume();this.stack[this.stack.length-1].title=e},emphasis:r(),hardBreakEscape:r(u),hardBreakTrailing:r(u),htmlFlow:r(function(){let e=this.resume();this.stack[this.stack.length-1].value=e}),htmlFlowData:d,htmlText:r(function(){let e=this.resume();this.stack[this.stack.length-1].value=e}),htmlTextData:d,image:r(function(){let e=this.stack[this.stack.length-1];if(this.data.inReference){let t=this.data.referenceType||"shortcut";e.type+="Reference",e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}),label:function(){let e=this.stack[this.stack.length-1],t=this.resume(),n=this.stack[this.stack.length-1];this.data.inReference=!0,"link"===n.type?n.children=e.children:n.alt=t},labelText:function(e){let t=this.sliceSerialize(e),n=this.stack[this.stack.length-2];n.label=t.replace(n8,n9),n.identifier=nO(t).toLowerCase()},lineEnding:function(e){let n=this.stack[this.stack.length-1];if(this.data.atHardBreak){n.children[n.children.length-1].position.end=ae(e.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(n.type)&&(c.call(this,e),d.call(this,e))},link:r(function(){let e=this.stack[this.stack.length-1];if(this.data.inReference){let t=this.data.referenceType||"shortcut";e.type+="Reference",e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}),listItem:r(),listOrdered:r(),listUnordered:r(),paragraph:r(),referenceString:function(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=nO(this.sliceSerialize(e)).toLowerCase(),this.data.referenceType="full"},resourceDestinationString:function(){let e=this.resume();this.stack[this.stack.length-1].url=e},resourceTitleString:function(){let e=this.resume();this.stack[this.stack.length-1].title=e},resource:function(){this.data.inReference=void 0},setextHeading:r(function(){this.data.setextHeadingSlurpLineEnding=void 0}),setextHeadingLineSequence:function(e){this.stack[this.stack.length-1].depth=61===this.sliceSerialize(e).codePointAt(0)?1:2},setextHeadingText:function(){this.data.setextHeadingSlurpLineEnding=!0},strong:r(),thematicBreak:r()}};!function e(t,n){let a=-1;for(;++a<n.length;){let s=n[a];Array.isArray(s)?e(t,s):function(e,t){let n;for(n in t)if(n7.call(t,n))switch(n){case"canContainEols":{let a=t[n];a&&e[n].push(...a);break}case"transforms":{let a=t[n];a&&e[n].push(...a);break}case"enter":case"exit":{let a=t[n];a&&Object.assign(e[n],a)}}}(t,s)}}(t,(e||{}).mdastExtensions||[]);let n={};return function(e){let a={type:"root",children:[]},r={stack:[a],tokenStack:[],config:t,enter:i,exit:l,buffer:s,resume:o,data:n},c=[],d=-1;for(;++d<e.length;)("listOrdered"===e[d][1].type||"listUnordered"===e[d][1].type)&&("enter"===e[d][0]?c.push(d):d=function(e,t,n){let a,s,i,r,l=t-1,o=-1,c=!1;for(;++l<=n;){let t=e[l];switch(t[1].type){case"listUnordered":case"listOrdered":case"blockQuote":"enter"===t[0]?o++:o--,r=void 0;break;case"lineEndingBlank":"enter"===t[0]&&(!a||r||o||i||(i=l),r=void 0);break;case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:r=void 0}if(!o&&"enter"===t[0]&&"listItemPrefix"===t[1].type||-1===o&&"exit"===t[0]&&("listUnordered"===t[1].type||"listOrdered"===t[1].type)){if(a){let r=l;for(s=void 0;r--;){let t=e[r];if("lineEnding"===t[1].type||"lineEndingBlank"===t[1].type){if("exit"===t[0])continue;s&&(e[s][1].type="lineEndingBlank",c=!0),t[1].type="lineEnding",s=r}else if("linePrefix"===t[1].type||"blockQuotePrefix"===t[1].type||"blockQuotePrefixWhitespace"===t[1].type||"blockQuoteMarker"===t[1].type||"listItemIndent"===t[1].type);else break}i&&(!s||i<s)&&(a._spread=!0),a.end=Object.assign({},s?e[s][1].start:t[1].end),e.splice(s||l,0,["exit",a,t[2]]),l++,n++}if("listItemPrefix"===t[1].type){let s={type:"listItem",_spread:!1,start:Object.assign({},t[1].start),end:void 0};a=s,e.splice(l,0,["enter",s,t[2]]),l++,n++,i=void 0,r=!0}}}return e[t][1]._spread=c,n}(e,c.pop(),d));for(d=-1;++d<e.length;){let n=t[e[d][0]];n7.call(n,e[d][1].type)&&n[e[d][1].type].call(Object.assign({sliceSerialize:e[d][2].sliceSerialize},r),e[d][1])}if(r.tokenStack.length>0){let e=r.tokenStack[r.tokenStack.length-1];(e[1]||at).call(r,void 0,e[0])}for(a.position={start:ae(e.length>0?e[0][1].start:{line:1,column:1,offset:0}),end:ae(e.length>0?e[e.length-2][1].end:{line:1,column:1,offset:0})},d=-1;++d<t.transforms.length;)a=t.transforms[d](a)||a;return a};function a(e,t){return function(n){i.call(this,e(n),n),t&&t.call(this,n)}}function s(){this.stack.push({type:"fragment",children:[]})}function i(e,t,n){this.stack[this.stack.length-1].children.push(e),this.stack.push(e),this.tokenStack.push([t,n||void 0]),e.position={start:ae(t.start),end:void 0}}function r(e){return function(t){e&&e.call(this,t),l.call(this,t)}}function l(e,t){let n=this.stack.pop(),a=this.tokenStack.pop();if(a)a[0].type!==e.type&&(t?t.call(this,e,a[0]):(a[1]||at).call(this,e,a[0]));else throw Error("Cannot close `"+e.type+"` ("+tT({start:e.start,end:e.end})+"): it’s not open");n.position.end=ae(e.end)}function o(){return tY(this.stack.pop())}function c(e){let t=this.stack[this.stack.length-1].children,n=t[t.length-1];n&&"text"===n.type||((n={type:"text",value:""}).position={start:ae(e.start),end:void 0},t.push(n)),this.stack.push(n)}function d(e){let t=this.stack.pop();t.value+=this.sliceSerialize(e),t.position.end=ae(e.end)}function u(){this.data.atHardBreak=!0}function p(e){this.data.characterReferenceType=e.type}function h(){return{type:"code",lang:null,meta:null,value:""}}function m(){return{type:"heading",depth:0,children:[]}}function f(){return{type:"break"}}function g(){return{type:"html",value:""}}function x(){return{type:"link",title:null,url:"",children:[]}}function v(e){return{type:"list",ordered:"listOrdered"===e.type,start:null,spread:e._spread,children:[]}}})(s)(function(e){for(;!nh(e););return e}((function(e){let t={constructs:t2([n5,...(e||{}).extensions||[]]),content:n(nl),defined:[],document:n(no),flow:n(ng),lazy:{},string:n(nv),text:n(ny)};return t;function n(e){return function(n){return function(e,t,n){let a={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0},s={},i=[],r=[],l=[],o={attempt:m(function(e,t){f(e,t.from)}),check:m(h),consume:function(e){ne(e)?(a.line++,a.column=1,a.offset+=-3===e?2:1,g()):-1!==e&&(a.column++,a.offset++),a._bufferIndex<0?a._index++:(a._bufferIndex++,a._bufferIndex===r[a._index].length&&(a._bufferIndex=-1,a._index++)),c.previous=e},enter:function(e,t){let n=t||{};return n.type=e,n.start=p(),c.events.push(["enter",n,c]),l.push(n),n},exit:function(e){let t=l.pop();return t.end=p(),c.events.push(["exit",t,c]),t},interrupt:m(h,{interrupt:!0})},c={code:null,containerState:{},defineSkip:function(e){s[e.line]=e.column,g()},events:[],now:p,parser:e,previous:null,sliceSerialize:function(e,t){return function(e,t){let n,a=-1,s=[];for(;++a<e.length;){let i,r=e[a];if("string"==typeof r)i=r;else switch(r){case -5:i="\r";break;case -4:i="\n";break;case -3:i="\r\n";break;case -2:i=t?" ":" ";break;case -1:if(!t&&n)continue;i=" ";break;default:i=String.fromCharCode(r)}n=-2===r,s.push(i)}return s.join("")}(u(e),t)},sliceStream:u,write:function(e){return(r=t0(r,e),function(){let e;for(;a._index<r.length;){let n=r[a._index];if("string"==typeof n)for(e=a._index,a._bufferIndex<0&&(a._bufferIndex=0);a._index===e&&a._bufferIndex<n.length;){var t;t=n.charCodeAt(a._bufferIndex),d=d(t)}else d=d(n)}}(),null!==r[r.length-1])?[]:(f(t,0),c.events=n_(i,c.events,c),c.events)}},d=t.tokenize.call(c,o);return t.resolveAll&&i.push(t),c;function u(e){return function(e,t){let n,a=t.start._index,s=t.start._bufferIndex,i=t.end._index,r=t.end._bufferIndex;if(a===i)n=[e[a].slice(s,r)];else{if(n=e.slice(a,i),s>-1){let e=n[0];"string"==typeof e?n[0]=e.slice(s):n.shift()}r>0&&n.push(e[i].slice(0,r))}return n}(r,e)}function p(){let{_bufferIndex:e,_index:t,line:n,column:s,offset:i}=a;return{_bufferIndex:e,_index:t,line:n,column:s,offset:i}}function h(e,t){t.restore()}function m(e,t){return function(n,s,i){var r;let d,u,h,m;return Array.isArray(n)?f(n):"tokenize"in n?f([n]):(r=n,function(e){let t=null!==e&&r[e],n=null!==e&&r.null;return f([...Array.isArray(t)?t:t?[t]:[],...Array.isArray(n)?n:n?[n]:[]])(e)});function f(e){return(d=e,u=0,0===e.length)?i:x(e[u])}function x(e){return function(n){let s,i,r,d,u;return(s=p(),i=c.previous,r=c.currentConstruct,d=c.events.length,u=Array.from(l),m={from:d,restore:function(){a=s,c.previous=i,c.currentConstruct=r,c.events.length=d,l=u,g()}},h=e,e.partial||(c.currentConstruct=e),e.name&&c.parser.constructs.disable.null.includes(e.name))?y(n):e.tokenize.call(t?Object.assign(Object.create(c),t):c,o,v,y)(n)}}function v(t){return e(h,m),s}function y(e){return(m.restore(),++u<d.length)?x(d[u]):i}}}function f(e,t){e.resolveAll&&!i.includes(e)&&i.push(e),e.resolve&&tX(c.events,t,c.events.length-t,e.resolve(c.events.slice(t),c)),e.resolveTo&&(c.events=e.resolveTo(c.events,c))}function g(){a.line in s&&a.column<2&&(a.column=s[a.line],a.offset+=s[a.line]-1)}}(t,e,n)}}})(s).document().write((r=1,l="",o=!0,function(e,t,n){let a,s,c,d,u,p=[];for(e=l+("string"==typeof e?e.toString():new TextDecoder(t||void 0).decode(e)),c=0,l="",o&&(65279===e.charCodeAt(0)&&c++,o=void 0);c<e.length;){if(n3.lastIndex=c,d=(a=n3.exec(e))&&void 0!==a.index?a.index:e.length,u=e.charCodeAt(d),!a){l=e.slice(c);break}if(10===u&&c===d&&i)p.push(-3),i=void 0;else switch(i&&(p.push(-5),i=void 0),c<d&&(p.push(e.slice(c,d)),r+=d-c),u){case 0:p.push(65533),r++;break;case 9:for(s=4*Math.ceil(r/4),p.push(-2);r++<s;)p.push(-1);break;case 10:p.push(-4),r=1;break;default:i=!0,r=1}c=d+1}return n&&(i&&p.push(-5),l&&p.push(l),p.push(null)),p})(n,a,!0))))}}let aa="object"==typeof self?self:globalThis,as=(e,t)=>{switch(e){case"Function":case"SharedWorker":case"Worker":case"eval":case"setInterval":case"setTimeout":throw TypeError("unable to deserialize "+e)}return new aa[e](t)},ai=e=>{var t;let n,a;return(t=new Map,n=(e,n)=>(t.set(n,e),e),a=s=>{if(t.has(s))return t.get(s);let[i,r]=e[s];switch(i){case 0:case -1:return n(r,s);case 1:{let e=n([],s);for(let t of r)e.push(a(t));return e}case 2:{let e=n({},s);for(let[t,n]of r)e[a(t)]=a(n);return e}case 3:return n(new Date(r),s);case 4:{let{source:e,flags:t}=r;return n(new RegExp(e,t),s)}case 5:{let e=n(new Map,s);for(let[t,n]of r)e.set(a(t),a(n));return e}case 6:{let e=n(new Set,s);for(let t of r)e.add(a(t));return e}case 7:{let{name:e,message:t}=r;return n("function"==typeof aa[e]?as(e,t):Error(t),s)}case 8:return n(BigInt(r),s);case"BigInt":return n(Object(BigInt(r)),s);case"ArrayBuffer":return n(new Uint8Array(r).buffer,r);case"DataView":{let{buffer:e}=new Uint8Array(r);return n(new DataView(e),r)}}return n(as(i,r),s)})(0)},{toString:ar}={},{keys:al}=Object,ao=e=>{let t=typeof e;if("object"!==t||!e)return[0,t];let n=ar.call(e).slice(8,-1);switch(n){case"Array":return[1,""];case"Object":return[2,""];case"Date":return[3,""];case"RegExp":return[4,""];case"Map":return[5,""];case"Set":return[6,""];case"DataView":return[1,n]}return n.includes("Array")?[1,n]:e instanceof Error?[7,e.name||"Error"]:[2,n]},ac=([e,t])=>0===e&&("function"===t||"symbol"===t),ad=(e,{json:t,lossy:n}={})=>{var a,s,i;let r,l,o=[];return(a=!(t||n),s=!!t,i=new Map,r=(e,t)=>{let n=o.push(e)-1;return i.set(t,n),n},l=e=>{if(i.has(e))return i.get(e);let[t,n]=ao(e);switch(t){case 0:{let s=e;switch(n){case"bigint":t=8,s=e.toString();break;case"function":case"symbol":if(a)throw TypeError("unable to serialize "+n);s=null;break;case"undefined":return r([-1],e)}return r([t,s],e)}case 1:{if(n){let t=e;return"DataView"===n?t=new Uint8Array(e.buffer):"ArrayBuffer"===n&&(t=new Uint8Array(e)),r([n,[...t]],e)}let a=[],s=r([t,a],e);for(let t of e)a.push(l(t));return s}case 2:{if(n)switch(n){case"BigInt":return r([n,e.toString()],e);case"Boolean":case"Number":case"String":return r([n,e.valueOf()],e)}if(s&&"toJSON"in e)return l(e.toJSON());let i=[],o=r([t,i],e);for(let t of al(e))(a||!ac(ao(e[t])))&&i.push([l(t),l(e[t])]);return o}case 3:return r([t,isNaN(e.getTime())?"":e.toISOString()],e);case 4:{let{source:n,flags:a}=e;return r([t,{source:n,flags:a}],e)}case 5:{let n=[],s=r([t,n],e);for(let[t,s]of e)(a||!(ac(ao(t))||ac(ao(s))))&&n.push([l(t),l(s)]);return s}case 6:{let n=[],s=r([t,n],e);for(let t of e)(a||!ac(ao(t)))&&n.push(l(t));return s}}let{message:o}=e;return r([t,{name:n,message:o}],e)})(e),o},au="function"==typeof structuredClone?(e,t)=>t&&("json"in t||"lossy"in t)?ai(ad(e,t)):structuredClone(e):(e,t)=>ai(ad(e,t));function ap(e){let t=[],n=-1,a=0,s=0;for(;++n<e.length;){let i=e.charCodeAt(n),r="";if(37===i&&t5(e.charCodeAt(n+1))&&t5(e.charCodeAt(n+2)))s=2;else if(i<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(i))||(r=String.fromCharCode(i));else if(i>55295&&i<57344){let t=e.charCodeAt(n+1);i<56320&&t>56319&&t<57344?(r=String.fromCharCode(i,t),s=1):r="�"}else r=String.fromCharCode(i);r&&(t.push(e.slice(a,n),encodeURIComponent(r)),a=n+s+1,r=""),s&&(n+=s,s=0)}return t.join("")+e.slice(a)}function ah(e,t){let n=[{type:"text",value:"↩"}];return t>1&&n.push({type:"element",tagName:"sup",properties:{},children:[{type:"text",value:String(t)}]}),n}function am(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}let af=function(e){var t,n;if(null==e)return ax;if("function"==typeof e)return ag(e);if("object"==typeof e){return Array.isArray(e)?function(e){let t=[],n=-1;for(;++n<e.length;)t[n]=af(e[n]);return ag(function(...e){let n=-1;for(;++n<t.length;)if(t[n].apply(this,e))return!0;return!1})}(e):(t=e,ag(function(e){let n;for(n in t)if(e[n]!==t[n])return!1;return!0}))}if("string"==typeof e){return n=e,ag(function(e){return e&&e.type===n})}throw Error("Expected function, string, or object as test")};function ag(e){return function(t,n,a){return!!(function(e){return null!==e&&"object"==typeof e&&"type"in e}(t)&&e.call(this,t,"number"==typeof n?n:void 0,a||void 0))}}function ax(){return!0}let av=[];function ay(e,t,n,a){let s;"function"==typeof t&&"function"!=typeof n?(a=n,n=t):s=t;let i=af(s),r=a?-1:1;(function e(s,l,o){let c=s&&"object"==typeof s?s:{};if("string"==typeof c.type){let e="string"==typeof c.tagName?c.tagName:"string"==typeof c.name?c.name:void 0;Object.defineProperty(d,"name",{value:"node ("+s.type+(e?"<"+e+">":"")+")"})}return d;function d(){var c;let d,u,p,h=av;if((!t||i(s,l,o[o.length-1]||void 0))&&!1===(h=Array.isArray(c=n(s,o))?c:"number"==typeof c?[!0,c]:null==c?av:[c])[0])return h;if("children"in s&&s.children&&s.children&&"skip"!==h[0])for(u=(a?s.children.length:-1)+r,p=o.concat(s);u>-1&&u<s.children.length;){if(!1===(d=e(s.children[u],u,p)())[0])return d;u="number"==typeof d[1]?d[1]:u+r}return h}})(e,void 0,[])()}function ab(e,t,n,a){let s,i,r;"function"==typeof t&&"function"!=typeof n?(i=void 0,r=t,s=n):(i=t,r=n,s=a),ay(e,i,function(e,t){let n=t[t.length-1],a=n?n.children.indexOf(e):void 0;return r(e,a,n)},s)}function ak(e,t){let n=t.referenceType,a="]";if("collapsed"===n?a+="[]":"full"===n&&(a+="["+(t.label||t.identifier)+"]"),"imageReference"===t.type)return[{type:"text",value:"!["+t.alt+a}];let s=e.all(t),i=s[0];i&&"text"===i.type?i.value="["+i.value:s.unshift({type:"text",value:"["});let r=s[s.length-1];return r&&"text"===r.type?r.value+=a:s.push({type:"text",value:a}),s}function aj(e){let t=e.spread;return null==t?e.children.length>1:t}function aw(e,t,n){let a=0,s=e.length;if(t){let t=e.codePointAt(a);for(;9===t||32===t;)a++,t=e.codePointAt(a)}if(n){let t=e.codePointAt(s-1);for(;9===t||32===t;)s--,t=e.codePointAt(s-1)}return s>a?e.slice(a,s):""}let a_={blockquote:function(e,t){let n={type:"element",tagName:"blockquote",properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)},break:function(e,t){let n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:"\n"}]},code:function(e,t){let n=t.value?t.value+"\n":"",a={},s=t.lang?t.lang.split(/\s+/):[];s.length>0&&(a.className=["language-"+s[0]]);let i={type:"element",tagName:"code",properties:a,children:[{type:"text",value:n}]};return t.meta&&(i.data={meta:t.meta}),e.patch(t,i),i={type:"element",tagName:"pre",properties:{},children:[i=e.applyData(t,i)]},e.patch(t,i),i},delete:function(e,t){let n={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},emphasis:function(e,t){let n={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},footnoteReference:function(e,t){let n,a="string"==typeof e.options.clobberPrefix?e.options.clobberPrefix:"user-content-",s=String(t.identifier).toUpperCase(),i=ap(s.toLowerCase()),r=e.footnoteOrder.indexOf(s),l=e.footnoteCounts.get(s);void 0===l?(l=0,e.footnoteOrder.push(s),n=e.footnoteOrder.length):n=r+1,l+=1,e.footnoteCounts.set(s,l);let o={type:"element",tagName:"a",properties:{href:"#"+a+"fn-"+i,id:a+"fnref-"+i+(l>1?"-"+l:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(n)}]};e.patch(t,o);let c={type:"element",tagName:"sup",properties:{},children:[o]};return e.patch(t,c),e.applyData(t,c)},heading:function(e,t){let n={type:"element",tagName:"h"+t.depth,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},html:function(e,t){if(e.options.allowDangerousHtml){let n={type:"raw",value:t.value};return e.patch(t,n),e.applyData(t,n)}},imageReference:function(e,t){let n=String(t.identifier).toUpperCase(),a=e.definitionById.get(n);if(!a)return ak(e,t);let s={src:ap(a.url||""),alt:t.alt};null!==a.title&&void 0!==a.title&&(s.title=a.title);let i={type:"element",tagName:"img",properties:s,children:[]};return e.patch(t,i),e.applyData(t,i)},image:function(e,t){let n={src:ap(t.url)};null!==t.alt&&void 0!==t.alt&&(n.alt=t.alt),null!==t.title&&void 0!==t.title&&(n.title=t.title);let a={type:"element",tagName:"img",properties:n,children:[]};return e.patch(t,a),e.applyData(t,a)},inlineCode:function(e,t){let n={type:"text",value:t.value.replace(/\r?\n|\r/g," ")};e.patch(t,n);let a={type:"element",tagName:"code",properties:{},children:[n]};return e.patch(t,a),e.applyData(t,a)},linkReference:function(e,t){let n=String(t.identifier).toUpperCase(),a=e.definitionById.get(n);if(!a)return ak(e,t);let s={href:ap(a.url||"")};null!==a.title&&void 0!==a.title&&(s.title=a.title);let i={type:"element",tagName:"a",properties:s,children:e.all(t)};return e.patch(t,i),e.applyData(t,i)},link:function(e,t){let n={href:ap(t.url)};null!==t.title&&void 0!==t.title&&(n.title=t.title);let a={type:"element",tagName:"a",properties:n,children:e.all(t)};return e.patch(t,a),e.applyData(t,a)},listItem:function(e,t,n){let a=e.all(t),s=n?function(e){let t=!1;if("list"===e.type){t=e.spread||!1;let n=e.children,a=-1;for(;!t&&++a<n.length;)t=aj(n[a])}return t}(n):aj(t),i={},r=[];if("boolean"==typeof t.checked){let e,n=a[0];n&&"element"===n.type&&"p"===n.tagName?e=n:(e={type:"element",tagName:"p",properties:{},children:[]},a.unshift(e)),e.children.length>0&&e.children.unshift({type:"text",value:" "}),e.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:t.checked,disabled:!0},children:[]}),i.className=["task-list-item"]}let l=-1;for(;++l<a.length;){let e=a[l];(s||0!==l||"element"!==e.type||"p"!==e.tagName)&&r.push({type:"text",value:"\n"}),"element"!==e.type||"p"!==e.tagName||s?r.push(e):r.push(...e.children)}let o=a[a.length-1];o&&(s||"element"!==o.type||"p"!==o.tagName)&&r.push({type:"text",value:"\n"});let c={type:"element",tagName:"li",properties:i,children:r};return e.patch(t,c),e.applyData(t,c)},list:function(e,t){let n={},a=e.all(t),s=-1;for("number"==typeof t.start&&1!==t.start&&(n.start=t.start);++s<a.length;){let e=a[s];if("element"===e.type&&"li"===e.tagName&&e.properties&&Array.isArray(e.properties.className)&&e.properties.className.includes("task-list-item")){n.className=["contains-task-list"];break}}let i={type:"element",tagName:t.ordered?"ol":"ul",properties:n,children:e.wrap(a,!0)};return e.patch(t,i),e.applyData(t,i)},paragraph:function(e,t){let n={type:"element",tagName:"p",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},root:function(e,t){let n={type:"root",children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)},strong:function(e,t){let n={type:"element",tagName:"strong",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},table:function(e,t){let n=e.all(t),a=n.shift(),s=[];if(a){let n={type:"element",tagName:"thead",properties:{},children:e.wrap([a],!0)};e.patch(t.children[0],n),s.push(n)}if(n.length>0){let a={type:"element",tagName:"tbody",properties:{},children:e.wrap(n,!0)},i=tI(t.children[1]),r=tS(t.children[t.children.length-1]);i&&r&&(a.position={start:i,end:r}),s.push(a)}let i={type:"element",tagName:"table",properties:{},children:e.wrap(s,!0)};return e.patch(t,i),e.applyData(t,i)},tableCell:function(e,t){let n={type:"element",tagName:"td",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},tableRow:function(e,t,n){let a=n?n.children:void 0,s=0===(a?a.indexOf(t):1)?"th":"td",i=n&&"table"===n.type?n.align:void 0,r=i?i.length:t.children.length,l=-1,o=[];for(;++l<r;){let n=t.children[l],a={},r=i?i[l]:void 0;r&&(a.align=r);let c={type:"element",tagName:s,properties:a,children:[]};n&&(c.children=e.all(n),e.patch(n,c),c=e.applyData(n,c)),o.push(c)}let c={type:"element",tagName:"tr",properties:{},children:e.wrap(o,!0)};return e.patch(t,c),e.applyData(t,c)},text:function(e,t){let n={type:"text",value:function(e){let t=String(e),n=/\r?\n|\r/g,a=n.exec(t),s=0,i=[];for(;a;)i.push(aw(t.slice(s,a.index),s>0,!0),a[0]),s=a.index+a[0].length,a=n.exec(t);return i.push(aw(t.slice(s),s>0,!1)),i.join("")}(String(t.value))};return e.patch(t,n),e.applyData(t,n)},thematicBreak:function(e,t){let n={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)},toml:aN,yaml:aN,definition:aN,footnoteDefinition:aN};function aN(){}let aC={}.hasOwnProperty,aS={};function aI(e,t){e.position&&(t.position=function(e){let t=tI(e),n=tS(e);if(t&&n)return{start:t,end:n}}(e))}function aP(e,t){let n=t;if(e&&e.data){let t=e.data.hName,a=e.data.hChildren,s=e.data.hProperties;"string"==typeof t&&("element"===n.type?n.tagName=t:n={type:"element",tagName:t,properties:{},children:"children"in n?n.children:[n]}),"element"===n.type&&s&&Object.assign(n.properties,au(s)),"children"in n&&n.children&&null!=a&&(n.children=a)}return n}function aT(e,t){let n=[],a=-1;for(t&&n.push({type:"text",value:"\n"});++a<e.length;)a&&n.push({type:"text",value:"\n"}),n.push(e[a]);return t&&e.length>0&&n.push({type:"text",value:"\n"}),n}function aM(e){let t=0,n=e.charCodeAt(t);for(;9===n||32===n;)t++,n=e.charCodeAt(t);return e.slice(t)}function aR(e,t){let n,a,s,i,r=(n=t||aS,a=new Map,s=new Map,i={all:function(e){let t=[];if("children"in e){let n=e.children,a=-1;for(;++a<n.length;){let s=i.one(n[a],e);if(s){if(a&&"break"===n[a-1].type&&(Array.isArray(s)||"text"!==s.type||(s.value=aM(s.value)),!Array.isArray(s)&&"element"===s.type)){let e=s.children[0];e&&"text"===e.type&&(e.value=aM(e.value))}Array.isArray(s)?t.push(...s):t.push(s)}}}return t},applyData:aP,definitionById:a,footnoteById:s,footnoteCounts:new Map,footnoteOrder:[],handlers:{...a_,...n.handlers},one:function(e,t){let n=e.type,a=i.handlers[n];if(aC.call(i.handlers,n)&&a)return a(i,e,t);if(i.options.passThrough&&i.options.passThrough.includes(n)){if("children"in e){let{children:t,...n}=e,a=au(n);return a.children=i.all(e),a}return au(e)}return(i.options.unknownHandler||function(e,t){let n=t.data||{},a="value"in t&&!(aC.call(n,"hProperties")||aC.call(n,"hChildren"))?{type:"text",value:t.value}:{type:"element",tagName:"div",properties:{},children:e.all(t)};return e.patch(t,a),e.applyData(t,a)})(i,e,t)},options:n,patch:aI,wrap:aT},ab(e,function(e){if("definition"===e.type||"footnoteDefinition"===e.type){let t="definition"===e.type?a:s,n=String(e.identifier).toUpperCase();t.has(n)||t.set(n,e)}}),i),l=r.one(e,void 0),o=function(e){let t="string"==typeof e.options.clobberPrefix?e.options.clobberPrefix:"user-content-",n=e.options.footnoteBackContent||ah,a=e.options.footnoteBackLabel||am,s=e.options.footnoteLabel||"Footnotes",i=e.options.footnoteLabelTagName||"h2",r=e.options.footnoteLabelProperties||{className:["sr-only"]},l=[],o=-1;for(;++o<e.footnoteOrder.length;){let s=e.footnoteById.get(e.footnoteOrder[o]);if(!s)continue;let i=e.all(s),r=String(s.identifier).toUpperCase(),c=ap(r.toLowerCase()),d=0,u=[],p=e.footnoteCounts.get(r);for(;void 0!==p&&++d<=p;){u.length>0&&u.push({type:"text",value:" "});let e="string"==typeof n?n:n(o,d);"string"==typeof e&&(e={type:"text",value:e}),u.push({type:"element",tagName:"a",properties:{href:"#"+t+"fnref-"+c+(d>1?"-"+d:""),dataFootnoteBackref:"",ariaLabel:"string"==typeof a?a:a(o,d),className:["data-footnote-backref"]},children:Array.isArray(e)?e:[e]})}let h=i[i.length-1];if(h&&"element"===h.type&&"p"===h.tagName){let e=h.children[h.children.length-1];e&&"text"===e.type?e.value+=" ":h.children.push({type:"text",value:" "}),h.children.push(...u)}else i.push(...u);let m={type:"element",tagName:"li",properties:{id:t+"fn-"+c},children:e.wrap(i,!0)};e.patch(s,m),l.push(m)}if(0!==l.length)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:i,properties:{...au(r),id:"footnote-label"},children:[{type:"text",value:s}]},{type:"text",value:"\n"},{type:"element",tagName:"ol",properties:{},children:e.wrap(l,!0)},{type:"text",value:"\n"}]}}(r),c=Array.isArray(l)?{type:"root",children:l}:l||{type:"root",children:[]};return o&&(tm("children"in c),c.children.push({type:"text",value:"\n"},o)),c}function aE(e,t){return e&&"run"in e?async function(n,a){let s=aR(n,{file:a,...t});await e.run(s,a)}:function(n,a){return aR(n,{file:a,...e||t})}}function aA(e){if(e)throw e}var a$=e.i(4100);function az(e){if("object"!=typeof e||null===e)return!1;let t=Object.getPrototypeOf(e);return(null===t||t===Object.prototype||null===Object.getPrototypeOf(t))&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}let aF=function(e,t){let n;if(void 0!==t&&"string"!=typeof t)throw TypeError('"ext" argument must be a string');aq(e);let a=0,s=-1,i=e.length;if(void 0===t||0===t.length||t.length>e.length){for(;i--;)if(47===e.codePointAt(i)){if(n){a=i+1;break}}else s<0&&(n=!0,s=i+1);return s<0?"":e.slice(a,s)}if(t===e)return"";let r=-1,l=t.length-1;for(;i--;)if(47===e.codePointAt(i)){if(n){a=i+1;break}}else r<0&&(n=!0,r=i+1),l>-1&&(e.codePointAt(i)===t.codePointAt(l--)?l<0&&(s=i):(l=-1,s=r));return a===s?s=r:s<0&&(s=e.length),e.slice(a,s)},aL=function(e){let t;if(aq(e),0===e.length)return".";let n=-1,a=e.length;for(;--a;)if(47===e.codePointAt(a)){if(t){n=a;break}}else t||(t=!0);return n<0?47===e.codePointAt(0)?"/":".":1===n&&47===e.codePointAt(0)?"//":e.slice(0,n)},aD=function(e){let t;aq(e);let n=e.length,a=-1,s=0,i=-1,r=0;for(;n--;){let l=e.codePointAt(n);if(47===l){if(t){s=n+1;break}continue}a<0&&(t=!0,a=n+1),46===l?i<0?i=n:1!==r&&(r=1):i>-1&&(r=-1)}return i<0||a<0||0===r||1===r&&i===a-1&&i===s+1?"":e.slice(i,a)},aO=function(...e){var t;let n,a,s,i=-1;for(;++i<e.length;)aq(e[i]),e[i]&&(s=void 0===s?e[i]:s+"/"+e[i]);return void 0===s?".":(aq(t=s),n=47===t.codePointAt(0),0!==(a=function(e,t){let n,a,s="",i=0,r=-1,l=0,o=-1;for(;++o<=e.length;){if(o<e.length)n=e.codePointAt(o);else if(47===n)break;else n=47;if(47===n){if(r===o-1||1===l);else if(r!==o-1&&2===l){if(s.length<2||2!==i||46!==s.codePointAt(s.length-1)||46!==s.codePointAt(s.length-2)){if(s.length>2){if((a=s.lastIndexOf("/"))!==s.length-1){a<0?(s="",i=0):i=(s=s.slice(0,a)).length-1-s.lastIndexOf("/"),r=o,l=0;continue}}else if(s.length>0){s="",i=0,r=o,l=0;continue}}t&&(s=s.length>0?s+"/..":"..",i=2)}else s.length>0?s+="/"+e.slice(r+1,o):s=e.slice(r+1,o),i=o-r-1;r=o,l=0}else 46===n&&l>-1?l++:l=-1}return s}(t,!n)).length||n||(a="."),a.length>0&&47===t.codePointAt(t.length-1)&&(a+="/"),n?"/"+a:a)};function aq(e){if("string"!=typeof e)throw TypeError("Path must be a string. Received "+JSON.stringify(e))}function aB(e){return!!(null!==e&&"object"==typeof e&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&void 0===e.auth)}let aU=["history","path","basename","stem","extname","dirname"];class aH{constructor(e){let t,n;t=e?aB(e)?{path:e}:"string"==typeof e||function(e){return!!(e&&"object"==typeof e&&"byteLength"in e&&"byteOffset"in e)}(e)?{value:e}:e:{},this.cwd="cwd"in t?"":"/",this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let a=-1;for(;++a<aU.length;){const e=aU[a];e in t&&void 0!==t[e]&&null!==t[e]&&(this[e]="history"===e?[...t[e]]:t[e])}for(n in t)aU.includes(n)||(this[n]=t[n])}get basename(){return"string"==typeof this.path?aF(this.path):void 0}set basename(e){aV(e,"basename"),aW(e,"basename"),this.path=aO(this.dirname||"",e)}get dirname(){return"string"==typeof this.path?aL(this.path):void 0}set dirname(e){aK(this.basename,"dirname"),this.path=aO(e||"",this.basename)}get extname(){return"string"==typeof this.path?aD(this.path):void 0}set extname(e){if(aW(e,"extname"),aK(this.dirname,"extname"),e){if(46!==e.codePointAt(0))throw Error("`extname` must start with `.`");if(e.includes(".",1))throw Error("`extname` cannot contain multiple dots")}this.path=aO(this.dirname,this.stem+(e||""))}get path(){return this.history[this.history.length-1]}set path(e){aB(e)&&(e=function(e){if("string"==typeof e)e=new URL(e);else if(!aB(e)){let t=TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code="ERR_INVALID_ARG_TYPE",t}if("file:"!==e.protocol){let e=TypeError("The URL must be of scheme file");throw e.code="ERR_INVALID_URL_SCHEME",e}return function(e){if(""!==e.hostname){let e=TypeError('File URL host must be "localhost" or empty on darwin');throw e.code="ERR_INVALID_FILE_URL_HOST",e}let t=e.pathname,n=-1;for(;++n<t.length;)if(37===t.codePointAt(n)&&50===t.codePointAt(n+1)){let e=t.codePointAt(n+2);if(70===e||102===e){let e=TypeError("File URL path must not include encoded / characters");throw e.code="ERR_INVALID_FILE_URL_PATH",e}}return decodeURIComponent(t)}(e)}(e)),aV(e,"path"),this.path!==e&&this.history.push(e)}get stem(){return"string"==typeof this.path?aF(this.path,this.extname):void 0}set stem(e){aV(e,"stem"),aW(e,"stem"),this.path=aO(this.dirname||"",e+(this.extname||""))}fail(e,t,n){let a=this.message(e,t,n);throw a.fatal=!0,a}info(e,t,n){let a=this.message(e,t,n);return a.fatal=void 0,a}message(e,t,n){let a=new tA(e,t,n);return this.path&&(a.name=this.path+":"+a.name,a.file=this.path),a.fatal=!1,this.messages.push(a),a}toString(e){return void 0===this.value?"":"string"==typeof this.value?this.value:new TextDecoder(e||void 0).decode(this.value)}}function aW(e,t){if(e&&e.includes("/"))throw Error("`"+t+"` cannot be a path: did not expect `/`")}function aV(e,t){if(!e)throw Error("`"+t+"` cannot be empty")}function aK(e,t){if(!e)throw Error("Setting `"+t+"` requires `path` to be set too")}let aG=function(e){let t=this.constructor.prototype,n=t[e],a=function(){return n.apply(a,arguments)};return Object.setPrototypeOf(a,t),a},aJ={}.hasOwnProperty;class aY extends aG{constructor(){super("copy"),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=function(){let e=[],t={run:function(...t){let n=-1,a=t.pop();if("function"!=typeof a)throw TypeError("Expected function as last argument, not "+a);!function s(i,...r){let l=e[++n],o=-1;if(i)return void a(i);for(;++o<t.length;)(null===r[o]||void 0===r[o])&&(r[o]=t[o]);t=r,l?(function(e,t){let n;return function(...t){let i,r=e.length>t.length;r&&t.push(a);try{i=e.apply(this,t)}catch(e){if(r&&n)throw e;return a(e)}r||(i&&i.then&&"function"==typeof i.then?i.then(s,a):i instanceof Error?a(i):s(i))};function a(e,...s){n||(n=!0,t(e,...s))}function s(e){a(null,e)}})(l,s)(...r):a(null,...r)}(null,...t)},use:function(n){if("function"!=typeof n)throw TypeError("Expected `middelware` to be a function, not "+n);return e.push(n),t}};return t}()}copy(){let e=new aY,t=-1;for(;++t<this.attachers.length;){let n=this.attachers[t];e.use(...n)}return e.data((0,a$.default)(!0,{},this.namespace)),e}data(e,t){return"string"==typeof e?2==arguments.length?(a0("data",this.frozen),this.namespace[e]=t,this):aJ.call(this.namespace,e)&&this.namespace[e]||void 0:e?(a0("data",this.frozen),this.namespace=e,this):this.namespace}freeze(){if(this.frozen)return this;for(;++this.freezeIndex<this.attachers.length;){let[e,...t]=this.attachers[this.freezeIndex];if(!1===t[0])continue;!0===t[0]&&(t[0]=void 0);let n=e.call(this,...t);"function"==typeof n&&this.transformers.use(n)}return this.frozen=!0,this.freezeIndex=1/0,this}parse(e){this.freeze();let t=a4(e),n=this.parser||this.Parser;return aZ("parse",n),n(String(t),t)}process(e,t){let n=this;return this.freeze(),aZ("process",this.parser||this.Parser),aX("process",this.compiler||this.Compiler),t?a(void 0,t):new Promise(a);function a(a,s){let i=a4(e),r=n.parse(i);function l(e,n){e||!n?s(e):a?a(n):(tm(t,"`done` is defined if `resolve` is not"),t(void 0,n))}n.run(r,i,function(e,t,a){var s,i;if(e||!t||!a)return l(e);let r=n.stringify(t,a);"string"==typeof(s=r)||(i=s)&&"object"==typeof i&&"byteLength"in i&&"byteOffset"in i?a.value=r:a.result=r,l(e,a)})}}processSync(e){let t,n=!1;return this.freeze(),aZ("processSync",this.parser||this.Parser),aX("processSync",this.compiler||this.Compiler),this.process(e,function(e,a){n=!0,aA(e),t=a}),a2("processSync","process",n),tm(t,"we either bailed on an error or have a tree"),t}run(e,t,n){a1(e),this.freeze();let a=this.transformers;return n||"function"!=typeof t||(n=t,t=void 0),n?s(void 0,n):new Promise(s);function s(s,i){tm("function"!=typeof t,"`file` can’t be a `done` anymore, we checked");let r=a4(t);a.run(e,r,function(t,a,r){let l=a||e;t?i(t):s?s(l):(tm(n,"`done` is defined if `resolve` is not"),n(void 0,l,r))})}}runSync(e,t){let n,a=!1;return this.run(e,t,function(e,t){aA(e),n=t,a=!0}),a2("runSync","run",a),tm(n,"we either bailed on an error or have a tree"),n}stringify(e,t){this.freeze();let n=a4(t),a=this.compiler||this.Compiler;return aX("stringify",a),a1(e),a(e,n)}use(e,...t){let n=this.attachers,a=this.namespace;if(a0("use",this.frozen),null==e);else if("function"==typeof e)r(e,t);else if("object"==typeof e)Array.isArray(e)?i(e):s(e);else throw TypeError("Expected usable value, not `"+e+"`");return this;function s(e){if(!("plugins"in e)&&!("settings"in e))throw Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");i(e.plugins),e.settings&&(a.settings=(0,a$.default)(!0,a.settings,e.settings))}function i(e){let t=-1;if(null==e);else if(Array.isArray(e))for(;++t<e.length;)!function(e){if("function"==typeof e)r(e,[]);else if("object"==typeof e)if(Array.isArray(e)){let[t,...n]=e;r(t,n)}else s(e);else throw TypeError("Expected usable value, not `"+e+"`")}(e[t]);else throw TypeError("Expected a list of plugins, not `"+e+"`")}function r(e,t){let a=-1,s=-1;for(;++a<n.length;)if(n[a][0]===e){s=a;break}if(-1===s)n.push([e,...t]);else if(t.length>0){let[a,...i]=t,r=n[s][1];az(r)&&az(a)&&(a=(0,a$.default)(!0,r,a)),n[s]=[e,a,...i]}}}}let aQ=new aY().freeze();function aZ(e,t){if("function"!=typeof t)throw TypeError("Cannot `"+e+"` without `parser`")}function aX(e,t){if("function"!=typeof t)throw TypeError("Cannot `"+e+"` without `compiler`")}function a0(e,t){if(t)throw Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function a1(e){if(!az(e)||"string"!=typeof e.type)throw TypeError("Expected node, got `"+e+"`")}function a2(e,t,n){if(!n)throw Error("`"+e+"` finished async. Use `"+t+"` instead")}function a4(e){var t;return(t=e)&&"object"==typeof t&&"message"in t&&"messages"in t?e:new aH(e)}let a5=[],a3={allowDangerousHtml:!0},a6=/^(https?|ircs?|mailto|xmpp)$/i,a8=[{from:"astPlugins",id:"remove-buggy-html-in-markdown-parser"},{from:"allowDangerousHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"allowNode",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowElement"},{from:"allowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowedElements"},{from:"className",id:"remove-classname"},{from:"disallowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"disallowedElements"},{from:"escapeHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"includeElementIndex",id:"#remove-includeelementindex"},{from:"includeNodeIndex",id:"change-includenodeindex-to-includeelementindex"},{from:"linkTarget",id:"remove-linktarget"},{from:"plugins",id:"change-plugins-to-remarkplugins",to:"remarkPlugins"},{from:"rawSourcePos",id:"#remove-rawsourcepos"},{from:"renderers",id:"change-renderers-to-components",to:"components"},{from:"source",id:"change-source-to-children",to:"children"},{from:"sourcePos",id:"#remove-sourcepos"},{from:"transformImageUri",id:"#add-urltransform",to:"urlTransform"},{from:"transformLinkUri",id:"#add-urltransform",to:"urlTransform"}];function a9(e){var n;let a,s,i,r,l,o=(a=(n=e).rehypePlugins||a5,s=n.remarkPlugins||a5,i=n.remarkRehypeOptions?{...n.remarkRehypeOptions,...a3}:a3,aQ().use(an).use(s).use(aE,i).use(a)),c=(r=e.children||"",l=new aH,"string"==typeof r?l.value=r:tf("Unexpected value `"+r+"` for `children` prop, expected `string`"),l);return function(e,n){let a=n.allowedElements,s=n.allowElement,i=n.components,r=n.disallowedElements,l=n.skipHtml,o=n.unwrapDisallowed,c=n.urlTransform||a7;for(let e of a8)Object.hasOwn(n,e.from)&&tf("Unexpected `"+e.from+"` prop, "+(e.to?"use `"+e.to+"` instead":"remove it")+" (see <https://github.com/remarkjs/react-markdown/blob/main/changelog.md#"+e.id+"> for more info)");return a&&r&&tf("Unexpected combined `allowedElements` and `disallowedElements`, expected one or the other"),ab(e,function(e,t,n){if("raw"===e.type&&n&&"number"==typeof t)return l?n.children.splice(t,1):n.children[t]={type:"text",value:e.value},t;if("element"===e.type){let t;for(t in tG)if(Object.hasOwn(tG,t)&&Object.hasOwn(e.properties,t)){let n=e.properties[t],a=tG[t];(null===a||a.includes(e.tagName))&&(e.properties[t]=c(String(n||""),t,e))}}if("element"===e.type){let i=a?!a.includes(e.tagName):!!r&&r.includes(e.tagName);if(!i&&s&&"number"==typeof t&&(i=!s(e,t,n)),i&&n&&"number"==typeof t)return o&&e.children?n.children.splice(t,1,...e.children):n.children.splice(t,1),t}}),function(e,t){var n,a,s,i;let r;if(!t||void 0===t.Fragment)throw TypeError("Expected `Fragment` in options");let l=t.filePath||void 0;if(t.development){if("function"!=typeof t.jsxDEV)throw TypeError("Expected `jsxDEV` in options when `development: true`");n=l,a=t.jsxDEV,r=function(e,t,s,i){let r=Array.isArray(s.children),l=tI(e);return a(t,s,i,r,{columnNumber:l?l.column-1:void 0,fileName:n,lineNumber:l?l.line:void 0},void 0)}}else{if("function"!=typeof t.jsx)throw TypeError("Expected `jsx` in production options");if("function"!=typeof t.jsxs)throw TypeError("Expected `jsxs` in production options");s=t.jsx,i=t.jsxs,r=function(e,t,n,a){let r=Array.isArray(n.children)?i:s;return a?r(t,n,a):r(t,n)}}let o={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:r,elementAttributeNameCase:t.elementAttributeNameCase||"react",evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:l,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:!1!==t.passKeys,passNode:t.passNode||!1,schema:"svg"===t.space?t_.svg:t_.html,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:!1!==t.tableCellAlignToStyle},c=tq(o,e,void 0);return c&&"string"!=typeof c?c:o.create(e,o.Fragment,{children:c||void 0},void 0)}(e,{Fragment:t.Fragment,components:i,ignoreInvalidStyle:!0,jsx:t.jsx,jsxs:t.jsxs,passKeys:!0,passNode:!0})}(o.runSync(o.parse(c),c),e)}function a7(e){let t=e.indexOf(":"),n=e.indexOf("?"),a=e.indexOf("#"),s=e.indexOf("/");return -1===t||-1!==s&&t>s||-1!==n&&t>n||-1!==a&&t>a||a6.test(e.slice(0,t))?e:""}var se=e.i(96481);let st="phrasing",sn=["autolink","link","image","label"];function sa(e){this.enter({type:"link",title:null,url:"",children:[]},e)}function ss(e){this.config.enter.autolinkProtocol.call(this,e)}function si(e){this.config.exit.autolinkProtocol.call(this,e)}function sr(e){this.config.exit.data.call(this,e);let t=this.stack[this.stack.length-1];tm("link"===t.type),t.url="http://"+this.sliceSerialize(e)}function sl(e){this.config.exit.autolinkEmail.call(this,e)}function so(e){this.exit(e)}function sc(e){!function(e,t,n){let a=af((n||{}).ignore||[]),s=function(e){let t=[];if(!Array.isArray(e))throw TypeError("Expected find and replace tuple or list of tuples");let n=!e[0]||Array.isArray(e[0])?e:[e],a=-1;for(;++a<n.length;){var s;let e=n[a];t.push(["string"==typeof(s=e[0])?RegExp(function(e){if("string"!=typeof e)throw TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}(s),"g"):s,function(e){return"function"==typeof e?e:function(){return e}}(e[1])])}return t}(t),i=-1;for(;++i<s.length;)ay(e,"text",r);function r(e,t){let n,r=-1;for(;++r<t.length;){let e=t[r],s=n?n.children:void 0;if(a(e,s?s.indexOf(e):void 0,n))return;n=e}if(n)return function(e,t){let n=t[t.length-1],a=s[i][0],r=s[i][1],l=0,o=n.children.indexOf(e),c=!1,d=[];a.lastIndex=0;let u=a.exec(e.value);for(;u;){let n=u.index,s={index:u.index,input:u.input,stack:[...t,e]},i=r(...u,s);if("string"==typeof i&&(i=i.length>0?{type:"text",value:i}:void 0),!1===i?a.lastIndex=n+1:(l!==n&&d.push({type:"text",value:e.value.slice(l,n)}),Array.isArray(i)?d.push(...i):i&&d.push(i),l=n+u[0].length,c=!0),!a.global)break;u=a.exec(e.value)}return c?(l<e.value.length&&d.push({type:"text",value:e.value.slice(l)}),n.children.splice(o,1,...d)):d=[e],o+d.length}(e,t)}}(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,sd],[/(?<=^|\s|\p{P}|\p{S})([-.\w+]+)@([-\w]+(?:\.[-\w]+)+)/gu,su]],{ignore:["link","linkReference"]})}function sd(e,t,n,a,s){let i,r="";if(!sp(s))return!1;if(/^w/i.test(t)&&(n=t+n,t="",r="http://"),(i=n.split(".")).length<2||i[i.length-1]&&(/_/.test(i[i.length-1])||!/[a-zA-Z\d]/.test(i[i.length-1]))||i[i.length-2]&&(/_/.test(i[i.length-2])||!/[a-zA-Z\d]/.test(i[i.length-2])))return!1;let l=function(e){let t=/[!"&'),.:;<>?\]}]+$/.exec(e);if(!t)return[e,void 0];e=e.slice(0,t.index);let n=t[0],a=n.indexOf(")"),s=(0,se.ccount)(e,"("),i=(0,se.ccount)(e,")");for(;-1!==a&&s>i;)e+=n.slice(0,a+1),a=(n=n.slice(a+1)).indexOf(")"),i++;return[e,n]}(n+a);if(!l[0])return!1;let o={type:"link",title:null,url:r+t+l[0],children:[{type:"text",value:t+l[0]}]};return l[1]?[o,{type:"text",value:l[1]}]:o}function su(e,t,n,a){return!(!sp(a,!0)||/[-\d_]$/.test(n))&&{type:"link",title:null,url:"mailto:"+t+"@"+n,children:[{type:"text",value:t+"@"+n}]}}function sp(e,t){let n=e.input.charCodeAt(e.index-1);return(0===e.index||ns(n)||na(n))&&(!t||47!==n)}function sh(){this.buffer()}function sm(e){this.enter({type:"footnoteReference",identifier:"",label:""},e)}function sf(){this.buffer()}function sg(e){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},e)}function sx(e){let t=this.resume(),n=this.stack[this.stack.length-1];tm("footnoteReference"===n.type),n.identifier=nO(this.sliceSerialize(e)).toLowerCase(),n.label=t}function sv(e){this.exit(e)}function sy(e){let t=this.resume(),n=this.stack[this.stack.length-1];tm("footnoteDefinition"===n.type),n.identifier=nO(this.sliceSerialize(e)).toLowerCase(),n.label=t}function sb(e){this.exit(e)}function sk(e,t,n,a){let s=n.createTracker(a),i=s.move("[^"),r=n.enter("footnoteReference"),l=n.enter("reference");return i+=s.move(n.safe(n.associationId(e),{after:"]",before:i})),l(),r(),i+=s.move("]")}function sj(e,t,n){return 0===t?e:sw(e,t,n)}function sw(e,t,n){return(n?"":" ")+e}sk.peek=function(){return"["};let s_=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];function sN(e){this.enter({type:"delete",children:[]},e)}function sC(e){this.exit(e)}function sS(e,t,n,a){let s=n.createTracker(a),i=n.enter("strikethrough"),r=s.move("~~");return r+=n.containerPhrasing(e,{...s.current(),before:r,after:"~"}),r+=s.move("~~"),i(),r}function sI(e){return e.length}function sP(e){let t="string"==typeof e?e.codePointAt(0):0;return 67===t||99===t?99:76===t||108===t?108:114*(82===t||114===t)}sS.peek=function(){return"~"};function sT(e,t,n){let a=e.value||"",s="`",i=-1;for(;RegExp("(^|[^`])"+s+"([^`]|$)").test(a);)s+="`";for(/[^ \r\n]/.test(a)&&(/^[ \r\n]/.test(a)&&/[ \r\n]$/.test(a)||/^`|`$/.test(a))&&(a=" "+a+" ");++i<n.unsafe.length;){let e,t=n.unsafe[i],s=n.compilePattern(t);if(t.atBreak)for(;e=s.exec(a);){let t=e.index;10===a.charCodeAt(t)&&13===a.charCodeAt(t-1)&&t--,a=a.slice(0,t)+" "+a.slice(e.index+1)}}return s+a+s}sT.peek=function(){return"`"};af(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);let sM=function(e,t,n,a){let s=function(e){let t=e.options.listItemIndent||"one";if("tab"!==t&&"one"!==t&&"mixed"!==t)throw Error("Cannot serialize items with `"+t+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return t}(n),i=n.bulletCurrent||function(e){let t=e.options.bullet||"*";if("*"!==t&&"+"!==t&&"-"!==t)throw Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}(n);t&&"list"===t.type&&t.ordered&&(i=("number"==typeof t.start&&t.start>-1?t.start:1)+(!1===n.options.incrementListMarker?0:t.children.indexOf(e))+i);let r=i.length+1;("tab"===s||"mixed"===s&&(t&&"list"===t.type&&t.spread||e.spread))&&(r=4*Math.ceil(r/4));let l=n.createTracker(a);l.move(i+" ".repeat(r-i.length)),l.shift(r);let o=n.enter("listItem"),c=n.indentLines(n.containerFlow(e,l.current()),function(e,t,n){return t?(n?"":" ".repeat(r))+e:(n?i:i+" ".repeat(r-i.length))+e});return o(),c};function sR(e){let t=e._align;tm(t,"expected `_align` on table"),this.enter({type:"table",align:t.map(function(e){return"none"===e?null:e}),children:[]},e),this.data.inTable=!0}function sE(e){this.exit(e),this.data.inTable=void 0}function sA(e){this.enter({type:"tableRow",children:[]},e)}function s$(e){this.exit(e)}function sz(e){this.enter({type:"tableCell",children:[]},e)}function sF(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,sL));let n=this.stack[this.stack.length-1];tm("inlineCode"===n.type),n.value=t,this.exit(e)}function sL(e,t){return"|"===t?t:e}function sD(e){let t=this.stack[this.stack.length-2];tm("listItem"===t.type),t.checked="taskListCheckValueChecked"===e.type}function sO(e){let t=this.stack[this.stack.length-2];if(t&&"listItem"===t.type&&"boolean"==typeof t.checked){let e=this.stack[this.stack.length-1];tm("paragraph"===e.type);let n=e.children[0];if(n&&"text"===n.type){let a,s=t.children,i=-1;for(;++i<s.length;){let e=s[i];if("paragraph"===e.type){a=e;break}}a===e&&(n.value=n.value.slice(1),0===n.value.length?e.children.shift():e.position&&n.position&&"number"==typeof n.position.start.offset&&(n.position.start.column++,n.position.start.offset++,e.position.start=Object.assign({},n.position.start)))}}this.exit(e)}function sq(e,t,n,a){let s=e.children[0],i="boolean"==typeof e.checked&&s&&"paragraph"===s.type,r="["+(e.checked?"x":" ")+"] ",l=n.createTracker(a);i&&l.move(r);let o=sM(e,t,n,{...a,...l.current()});return i&&(o=o.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,function(e){return e+r})),o}let sB={tokenize:function(e,t,n){let a=0;return function t(i){return(87===i||119===i)&&a<3?(a++,e.consume(i),t):46===i&&3===a?(e.consume(i),s):n(i)};function s(e){return null===e?n(e):t(e)}},partial:!0},sU={tokenize:function(e,t,n){let a,s,i;return r;function r(t){return 46===t||95===t?e.check(sW,o,l)(t):null===t||nt(t)||ns(t)||45!==t&&na(t)?o(t):(i=!0,e.consume(t),r)}function l(t){return 95===t?a=!0:(s=a,a=void 0),e.consume(t),r}function o(e){return s||a||!i?n(e):t(e)}},partial:!0},sH={tokenize:function(e,t){let n=0,a=0;return s;function s(r){return 40===r?(n++,e.consume(r),s):41===r&&a<n?i(r):33===r||34===r||38===r||39===r||41===r||42===r||44===r||46===r||58===r||59===r||60===r||63===r||93===r||95===r||126===r?e.check(sW,t,i)(r):null===r||nt(r)||ns(r)?t(r):(e.consume(r),s)}function i(t){return 41===t&&a++,e.consume(t),s}},partial:!0},sW={tokenize:function(e,t,n){return a;function a(r){return 33===r||34===r||39===r||41===r||42===r||44===r||46===r||58===r||59===r||63===r||95===r||126===r?(e.consume(r),a):38===r?(e.consume(r),i):93===r?(e.consume(r),s):60===r||null===r||nt(r)||ns(r)?t(r):n(r)}function s(e){return null===e||40===e||91===e||nt(e)||ns(e)?t(e):a(e)}function i(t){return t4(t)?function t(s){return 59===s?(e.consume(s),a):t4(s)?(e.consume(s),t):n(s)}(t):n(t)}},partial:!0},sV={tokenize:function(e,t,n){return function(t){return e.consume(t),a};function a(e){return t5(e)?n(e):t(e)}},partial:!0},sK={name:"wwwAutolink",tokenize:function(e,t,n){let a=this;return function(t){return 87!==t&&119!==t||!sZ.call(a,a.previous)||s2(a.events)?n(t):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(sB,e.attempt(sU,e.attempt(sH,s),n),n)(t))};function s(n){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(n)}},previous:sZ},sG={name:"protocolAutolink",tokenize:function(e,t,n){let a=this,s="",i=!1;return function(t){return(72===t||104===t)&&sX.call(a,a.previous)&&!s2(a.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),s+=String.fromCodePoint(t),e.consume(t),r):n(t)};function r(t){if(t4(t)&&s.length<5)return s+=String.fromCodePoint(t),e.consume(t),r;if(58===t){let n=s.toLowerCase();if("http"===n||"https"===n)return e.consume(t),l}return n(t)}function l(t){return 47===t?(e.consume(t),i)?o:(i=!0,l):n(t)}function o(t){return null===t||t6(t)||nt(t)||ns(t)||na(t)?n(t):e.attempt(sU,e.attempt(sH,c),n)(t)}function c(n){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(n)}},previous:sX},sJ={name:"emailAutolink",tokenize:function(e,t,n){let a,s,i=this;return function(t){return!s1(t)||!s0.call(i,i.previous)||s2(i.events)?n(t):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),function t(a){return s1(a)?(e.consume(a),t):64===a?(e.consume(a),r):n(a)}(t))};function r(t){return 46===t?e.check(sV,o,l)(t):45===t||95===t||t5(t)?(s=!0,e.consume(t),r):o(t)}function l(t){return e.consume(t),a=!0,r}function o(r){return s&&a&&t4(i.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(r)):n(r)}},previous:s0},sY={},sQ=48;for(;sQ<123;)sY[sQ]=sJ,58==++sQ?sQ=65:91===sQ&&(sQ=97);function sZ(e){return null===e||40===e||42===e||95===e||91===e||93===e||126===e||nt(e)}function sX(e){return!t4(e)}function s0(e){return!(47===e||s1(e))}function s1(e){return 43===e||45===e||46===e||95===e||t5(e)}function s2(e){let t=e.length,n=!1;for(;t--;){let a=e[t][1];if(("labelLink"===a.type||"labelImage"===a.type)&&!a._balanced){n=!0;break}if(a._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}sY[43]=sJ,sY[45]=sJ,sY[46]=sJ,sY[95]=sJ,sY[72]=[sJ,sG],sY[104]=[sJ,sG],sY[87]=[sJ,sK],sY[119]=[sJ,sK];let s4={tokenize:function(e,t,n){let a=this;return nr(e,function(e){let s=a.events[a.events.length-1];return s&&"gfmFootnoteDefinitionIndent"===s[1].type&&4===s[2].sliceSerialize(s[1],!0).length?t(e):n(e)},"gfmFootnoteDefinitionIndent",5)},partial:!0};function s5(e,t,n){let a,s=this,i=s.events.length,r=s.parser.gfmFootnotes||(s.parser.gfmFootnotes=[]);for(;i--;){let e=s.events[i][1];if("labelImage"===e.type){a=e;break}if("gfmFootnoteCall"===e.type||"labelLink"===e.type||"label"===e.type||"image"===e.type||"link"===e.type)break}return function(i){if(!a||!a._balanced)return n(i);let l=nO(s.sliceSerialize({start:a.end,end:s.now()}));return 94===l.codePointAt(0)&&r.includes(l.slice(1))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(i),e.exit("gfmFootnoteCallLabelMarker"),t(i)):n(i)}}function s3(e,t){let n=e.length;for(;n--;)if("labelImage"===e[n][1].type&&"enter"===e[n][0]){e[n][1];break}e[n+1][1].type="data",e[n+3][1].type="gfmFootnoteCallLabelMarker";let a={type:"gfmFootnoteCall",start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},s={type:"gfmFootnoteCallMarker",start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};s.end.column++,s.end.offset++,s.end._bufferIndex++;let i={type:"gfmFootnoteCallString",start:Object.assign({},s.end),end:Object.assign({},e[e.length-1][1].start)},r={type:"chunkString",contentType:"string",start:Object.assign({},i.start),end:Object.assign({},i.end)},l=[e[n+1],e[n+2],["enter",a,t],e[n+3],e[n+4],["enter",s,t],["exit",s,t],["enter",i,t],["enter",r,t],["exit",r,t],["exit",i,t],e[e.length-2],e[e.length-1],["exit",a,t]];return e.splice(n,e.length-n+1,...l),e}function s6(e,t,n){let a,s=this,i=s.parser.gfmFootnotes||(s.parser.gfmFootnotes=[]),r=0;return function(t){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(t),e.exit("gfmFootnoteCallLabelMarker"),l};function l(t){return 94!==t?n(t):(e.enter("gfmFootnoteCallMarker"),e.consume(t),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",o)}function o(l){if(r>999||93===l&&!a||null===l||91===l||nt(l))return n(l);if(93===l){e.exit("chunkString");let a=e.exit("gfmFootnoteCallString");return i.includes(nO(s.sliceSerialize(a)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(l),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):n(l)}return nt(l)||(a=!0),r++,e.consume(l),92===l?c:o}function c(t){return 91===t||92===t||93===t?(e.consume(t),r++,o):o(t)}}function s8(e,t,n){let a,s,i=this,r=i.parser.gfmFootnotes||(i.parser.gfmFootnotes=[]),l=0;return function(t){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(t),e.exit("gfmFootnoteDefinitionLabelMarker"),o};function o(t){return 94===t?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(t),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",c):n(t)}function c(t){if(l>999||93===t&&!s||null===t||91===t||nt(t))return n(t);if(93===t){e.exit("chunkString");let n=e.exit("gfmFootnoteDefinitionLabelString");return a=nO(i.sliceSerialize(n)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(t),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),u}return nt(t)||(s=!0),l++,e.consume(t),92===t?d:c}function d(t){return 91===t||92===t||93===t?(e.consume(t),l++,c):c(t)}function u(t){return 58===t?(e.enter("definitionMarker"),e.consume(t),e.exit("definitionMarker"),r.includes(a)||r.push(a),nr(e,p,"gfmFootnoteDefinitionWhitespace")):n(t)}function p(e){return t(e)}}function s9(e,t,n){return e.check(nd,t,e.attempt(s4,t,n))}function s7(e){e.exit("gfmFootnoteDefinition")}class ie{constructor(){this.map=[]}add(e,t,n){!function(e,t,n,a){let s=0;if(0!==n||0!==a.length){for(;s<e.map.length;){if(e.map[s][0]===t){e.map[s][1]+=n,e.map[s][2].push(...a);return}s+=1}e.map.push([t,n,a])}}(this,e,t,n)}consume(e){if(this.map.sort(function(e,t){return e[0]-t[0]}),0===this.map.length)return;let t=this.map.length,n=[];for(;t>0;)t-=1,n.push(e.slice(this.map[t][0]+this.map[t][1]),this.map[t][2]),e.length=this.map[t][0];n.push(e.slice()),e.length=0;let a=n.pop();for(;a;){for(let t of a)e.push(t);a=n.pop()}this.map.length=0}}function it(e,t,n){let a,s=this,i=0,r=0;return function(e){let t=s.events.length-1;for(;t>-1;){let e=s.events[t][1].type;if("lineEnding"===e||"linePrefix"===e)t--;else break}let a=t>-1?s.events[t][1].type:null,i="tableHead"===a||"tableRow"===a?v:l;return i===v&&s.parser.lazy[s.now().line]?n(e):i(e)};function l(t){var n;return e.enter("tableHead"),e.enter("tableRow"),124===(n=t)||(a=!0,r+=1),o(n)}function o(t){return null===t?n(t):ne(t)?r>1?(r=0,s.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),u):n(t):nn(t)?nr(e,o,"whitespace")(t):(r+=1,a&&(a=!1,i+=1),124===t)?(e.enter("tableCellDivider"),e.consume(t),e.exit("tableCellDivider"),a=!0,o):(e.enter("data"),c(t))}function c(t){return null===t||124===t||nt(t)?(e.exit("data"),o(t)):(e.consume(t),92===t?d:c)}function d(t){return 92===t||124===t?(e.consume(t),c):c(t)}function u(t){return(s.interrupt=!1,s.parser.lazy[s.now().line])?n(t):(e.enter("tableDelimiterRow"),a=!1,nn(t))?nr(e,p,"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(t):p(t)}function p(t){return 45===t||58===t?m(t):124===t?(a=!0,e.enter("tableCellDivider"),e.consume(t),e.exit("tableCellDivider"),h):n(t)}function h(t){return nn(t)?nr(e,m,"whitespace")(t):m(t)}function m(t){return 58===t?(r+=1,a=!0,e.enter("tableDelimiterMarker"),e.consume(t),e.exit("tableDelimiterMarker"),f):45===t?(r+=1,f(t)):null===t||ne(t)?x(t):n(t)}function f(t){return 45===t?(e.enter("tableDelimiterFiller"),function t(n){return 45===n?(e.consume(n),t):58===n?(a=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(n),e.exit("tableDelimiterMarker"),g):(e.exit("tableDelimiterFiller"),g(n))}(t)):n(t)}function g(t){return nn(t)?nr(e,x,"whitespace")(t):x(t)}function x(s){if(124===s)return p(s);if(null===s||ne(s))return a&&i===r?(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(s)):n(s);return n(s)}function v(t){return e.enter("tableRow"),y(t)}function y(n){return 124===n?(e.enter("tableCellDivider"),e.consume(n),e.exit("tableCellDivider"),y):null===n||ne(n)?(e.exit("tableRow"),t(n)):nn(n)?nr(e,y,"whitespace")(n):(e.enter("data"),b(n))}function b(t){return null===t||124===t||nt(t)?(e.exit("data"),y(t)):(e.consume(t),92===t?k:b)}function k(t){return 92===t||124===t?(e.consume(t),b):b(t)}}function ia(e,t){let n,a,s,i=-1,r=!0,l=0,o=[0,0,0,0],c=[0,0,0,0],d=!1,u=0,p=new ie;for(;++i<e.length;){let h=e[i],m=h[1];"enter"===h[0]?"tableHead"===m.type?(d=!1,0!==u&&(ii(p,t,u,n,a),a=void 0,u=0),n={type:"table",start:Object.assign({},m.start),end:Object.assign({},m.end)},p.add(i,0,[["enter",n,t]])):"tableRow"===m.type||"tableDelimiterRow"===m.type?(r=!0,s=void 0,o=[0,0,0,0],c=[0,i+1,0,0],d&&(d=!1,a={type:"tableBody",start:Object.assign({},m.start),end:Object.assign({},m.end)},p.add(i,0,[["enter",a,t]])),l="tableDelimiterRow"===m.type?2:a?3:1):l&&("data"===m.type||"tableDelimiterMarker"===m.type||"tableDelimiterFiller"===m.type)?(r=!1,0===c[2]&&(0!==o[1]&&(c[0]=c[1],s=is(p,t,o,l,void 0,s),o=[0,0,0,0]),c[2]=i)):"tableCellDivider"===m.type&&(r?r=!1:(0!==o[1]&&(c[0]=c[1],s=is(p,t,o,l,void 0,s)),c=[(o=c)[1],i,0,0])):"tableHead"===m.type?(d=!0,u=i):"tableRow"===m.type||"tableDelimiterRow"===m.type?(u=i,0!==o[1]?(c[0]=c[1],s=is(p,t,o,l,i,s)):0!==c[1]&&(s=is(p,t,c,l,i,s)),l=0):l&&("data"===m.type||"tableDelimiterMarker"===m.type||"tableDelimiterFiller"===m.type)&&(c[3]=i)}for(0!==u&&ii(p,t,u,n,a),p.consume(t.events),i=-1;++i<t.events.length;){let e=t.events[i];"enter"===e[0]&&"table"===e[1].type&&(e[1]._align=function(e,t){let n=!1,a=[];for(;t<e.length;){let s=e[t];if(n){if("enter"===s[0])"tableContent"===s[1].type&&a.push("tableDelimiterMarker"===e[t+1][1].type?"left":"none");else if("tableContent"===s[1].type){if("tableDelimiterMarker"===e[t-1][1].type){let e=a.length-1;a[e]="left"===a[e]?"center":"right"}}else if("tableDelimiterRow"===s[1].type)break}else"enter"===s[0]&&"tableDelimiterRow"===s[1].type&&(n=!0);t+=1}return a}(t.events,i))}return e}function is(e,t,n,a,s,i){0!==n[0]&&(i.end=Object.assign({},ir(t.events,n[0])),e.add(n[0],0,[["exit",i,t]]));let r=ir(t.events,n[1]);if(i={type:1===a?"tableHeader":2===a?"tableDelimiter":"tableData",start:Object.assign({},r),end:Object.assign({},r)},e.add(n[1],0,[["enter",i,t]]),0!==n[2]){let s=ir(t.events,n[2]),i=ir(t.events,n[3]),r={type:"tableContent",start:Object.assign({},s),end:Object.assign({},i)};if(e.add(n[2],0,[["enter",r,t]]),2!==a){let a=t.events[n[2]],s=t.events[n[3]];if(a[1].end=Object.assign({},s[1].end),a[1].type="chunkText",a[1].contentType="text",n[3]>n[2]+1){let t=n[2]+1,a=n[3]-n[2]-1;e.add(t,a,[])}}e.add(n[3]+1,0,[["exit",r,t]])}return void 0!==s&&(i.end=Object.assign({},ir(t.events,s)),e.add(s,0,[["exit",i,t]]),i=void 0),i}function ii(e,t,n,a,s){let i=[],r=ir(t.events,n);s&&(s.end=Object.assign({},r),i.push(["exit",s,t])),a.end=Object.assign({},r),i.push(["exit",a,t]),e.add(n+1,0,i)}function ir(e,t){let n=e[t],a="enter"===n[0]?"start":"end";return n[1][a]}let il={name:"tasklistCheck",tokenize:function(e,t,n){let a=this;return function(t){return null===a.previous&&a._gfmTasklistFirstContentOfListItem?(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(t),e.exit("taskListCheckMarker"),s):n(t)};function s(t){return nt(t)?(e.enter("taskListCheckValueUnchecked"),e.consume(t),e.exit("taskListCheckValueUnchecked"),i):88===t||120===t?(e.enter("taskListCheckValueChecked"),e.consume(t),e.exit("taskListCheckValueChecked"),i):n(t)}function i(t){return 93===t?(e.enter("taskListCheckMarker"),e.consume(t),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),r):n(t)}function r(a){return ne(a)?t(a):nn(a)?e.check({tokenize:io},t,n)(a):n(a)}}};function io(e,t,n){return nr(e,function(e){return null===e?n(e):t(e)},"whitespace")}let ic={};function id(e){let t,n,a,s=e||ic,i=this.data(),r=i.micromarkExtensions||(i.micromarkExtensions=[]),l=i.fromMarkdownExtensions||(i.fromMarkdownExtensions=[]),o=i.toMarkdownExtensions||(i.toMarkdownExtensions=[]);r.push(t2([{text:sY},{document:{91:{name:"gfmFootnoteDefinition",tokenize:s8,continuation:{tokenize:s9},exit:s7}},text:{91:{name:"gfmFootnoteCall",tokenize:s6},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:s5,resolveTo:s3}}},(t=(s||{}).singleTilde,n={name:"strikethrough",tokenize:function(e,n,a){let s=this.previous,i=this.events,r=0;return function(l){return 126===s&&"characterEscape"!==i[i.length-1][1].type?a(l):(e.enter("strikethroughSequenceTemporary"),function i(l){let o=nw(s);if(126===l)return r>1?a(l):(e.consume(l),r++,i);if(r<2&&!t)return a(l);let c=e.exit("strikethroughSequenceTemporary"),d=nw(l);return c._open=!d||2===d&&!!o,c._close=!o||2===o&&!!d,n(l)}(l))}},resolveAll:function(e,t){let n=-1;for(;++n<e.length;)if("enter"===e[n][0]&&"strikethroughSequenceTemporary"===e[n][1].type&&e[n][1]._close){let a=n;for(;a--;)if("exit"===e[a][0]&&"strikethroughSequenceTemporary"===e[a][1].type&&e[a][1]._open&&e[n][1].end.offset-e[n][1].start.offset==e[a][1].end.offset-e[a][1].start.offset){e[n][1].type="strikethroughSequence",e[a][1].type="strikethroughSequence";let s={type:"strikethrough",start:Object.assign({},e[a][1].start),end:Object.assign({},e[n][1].end)},i={type:"strikethroughText",start:Object.assign({},e[a][1].end),end:Object.assign({},e[n][1].start)},r=[["enter",s,t],["enter",e[a][1],t],["exit",e[a][1],t],["enter",i,t]],l=t.parser.constructs.insideSpan.null;l&&tX(r,r.length,0,n_(l,e.slice(a+1,n),t)),tX(r,r.length,0,[["exit",i,t],["enter",e[n][1],t],["exit",e[n][1],t],["exit",s,t]]),tX(e,a-1,n-a+3,r),n=a+r.length-2;break}}for(n=-1;++n<e.length;)"strikethroughSequenceTemporary"===e[n][1].type&&(e[n][1].type="data");return e}},null==t&&(t=!0),{text:{126:n},insideSpan:{null:[n]},attentionMarkers:{null:[126]}}),{flow:{null:{name:"table",tokenize:it,resolveAll:ia}}},{text:{91:il}}])),l.push([{transforms:[sc],enter:{literalAutolink:sa,literalAutolinkEmail:ss,literalAutolinkHttp:ss,literalAutolinkWww:ss},exit:{literalAutolink:so,literalAutolinkEmail:sl,literalAutolinkHttp:si,literalAutolinkWww:sr}},{enter:{gfmFootnoteCallString:sh,gfmFootnoteCall:sm,gfmFootnoteDefinitionLabelString:sf,gfmFootnoteDefinition:sg},exit:{gfmFootnoteCallString:sx,gfmFootnoteCall:sv,gfmFootnoteDefinitionLabelString:sy,gfmFootnoteDefinition:sb}},{canContainEols:["delete"],enter:{strikethrough:sN},exit:{strikethrough:sC}},{enter:{table:sR,tableData:sz,tableHeader:sz,tableRow:sA},exit:{codeText:sF,table:sE,tableData:s$,tableHeader:s$,tableRow:s$}},{exit:{taskListCheckValueChecked:sD,taskListCheckValueUnchecked:sD,paragraph:sO}}]),o.push({extensions:[{unsafe:[{character:"@",before:"[+\\-.\\w]",after:"[\\-.\\w]",inConstruct:st,notInConstruct:sn},{character:".",before:"[Ww]",after:"[\\-.\\w]",inConstruct:st,notInConstruct:sn},{character:":",before:"[ps]",after:"\\/",inConstruct:st,notInConstruct:sn}]},(a=!1,s&&s.firstLineBlank&&(a=!0),{handlers:{footnoteDefinition:function(e,t,n,s){let i=n.createTracker(s),r=i.move("[^"),l=n.enter("footnoteDefinition"),o=n.enter("label");return r+=i.move(n.safe(n.associationId(e),{before:r,after:"]"})),o(),r+=i.move("]:"),e.children&&e.children.length>0&&(i.shift(4),r+=i.move((a?"\n":" ")+n.indentLines(n.containerFlow(e,i.current()),a?sw:sj))),l(),r},footnoteReference:sk},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]}),{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:s_}],handlers:{delete:sS}},function(e){let t=e||{},n=t.tableCellPadding,a=t.tablePipeAlign,s=t.stringLength,i=n?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:"\n",inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:function(e,t,n){let a=sT(e,t,n);return n.stack.includes("tableCell")&&(a=a.replace(/\|/g,"\\$&")),a},table:function(e,t,n,a){return l(function(e,t,n){let a=e.children,s=-1,i=[],r=t.enter("table");for(;++s<a.length;)i[s]=o(a[s],t,n);return r(),i}(e,n,a),e.align)},tableCell:r,tableRow:function(e,t,n,a){let s=l([o(e,n,a)]);return s.slice(0,s.indexOf("\n"))}}};function r(e,t,n,a){let s=n.enter("tableCell"),r=n.enter("phrasing"),l=n.containerPhrasing(e,{...a,before:i,after:i});return r(),s(),l}function l(e,t){return function(e,t){let n=t||{},a=(n.align||[]).concat(),s=n.stringLength||sI,i=[],r=[],l=[],o=[],c=0,d=-1;for(;++d<e.length;){let t=[],a=[],i=-1;for(e[d].length>c&&(c=e[d].length);++i<e[d].length;){var u;let r=null==(u=e[d][i])?"":String(u);if(!1!==n.alignDelimiters){let e=s(r);a[i]=e,(void 0===o[i]||e>o[i])&&(o[i]=e)}t.push(r)}r[d]=t,l[d]=a}let p=-1;if("object"==typeof a&&"length"in a)for(;++p<c;)i[p]=sP(a[p]);else{let e=sP(a);for(;++p<c;)i[p]=e}p=-1;let h=[],m=[];for(;++p<c;){let e=i[p],t="",a="";99===e?(t=":",a=":"):108===e?t=":":114===e&&(a=":");let s=!1===n.alignDelimiters?1:Math.max(1,o[p]-t.length-a.length),r=t+"-".repeat(s)+a;!1!==n.alignDelimiters&&((s=t.length+s+a.length)>o[p]&&(o[p]=s),m[p]=s),h[p]=r}r.splice(1,0,h),l.splice(1,0,m),d=-1;let f=[];for(;++d<r.length;){let e=r[d],t=l[d];p=-1;let a=[];for(;++p<c;){let s=e[p]||"",r="",l="";if(!1!==n.alignDelimiters){let e=o[p]-(t[p]||0),n=i[p];114===n?r=" ".repeat(e):99===n?e%2?(r=" ".repeat(e/2+.5),l=" ".repeat(e/2-.5)):l=r=" ".repeat(e/2):l=" ".repeat(e)}!1===n.delimiterStart||p||a.push("|"),!1!==n.padding&&(!1!==n.alignDelimiters||""!==s)&&(!1!==n.delimiterStart||p)&&a.push(" "),!1!==n.alignDelimiters&&a.push(r),a.push(s),!1!==n.alignDelimiters&&a.push(l),!1!==n.padding&&a.push(" "),(!1!==n.delimiterEnd||p!==c-1)&&a.push("|")}f.push(!1===n.delimiterEnd?a.join("").replace(/ +$/,""):a.join(""))}return f.join("\n")}(e,{align:t,alignDelimiters:a,padding:n,stringLength:s})}function o(e,t,n){let a=e.children,s=-1,i=[],l=t.enter("tableRow");for(;++s<a.length;)i[s]=r(a[s],e,t,n);return l(),i}}(s),{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:sq}}]})}function iu({text:e,className:n=""}){return(0,t.jsx)("div",{className:`markdown-body ${n}`.trim(),children:(0,t.jsx)(a9,{remarkPlugins:[id],children:e})})}let ip=o("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"}]]);function ih({text:e}){let n=(0,f.useT)();return(0,t.jsxs)("details",{className:"thinking-block",children:[(0,t.jsxs)("summary",{children:[(0,t.jsx)(ip,{size:14,"aria-hidden":"true"}),(0,t.jsx)("span",{children:n("conversation.thinking.reasoning")})]}),(0,t.jsx)("div",{className:"thinking-content",children:e})]})}let im=(0,n.memo)(function({step:e,activeLeafMessageId:n,branchDisabled:a,createBranch:s,metrics:i,isFirst:r=!0,isFinal:l=!0}){let o=e.speaker?.kind==="hero",d=e.speaker?.handle?`@${e.speaker.handle}`:e.speaker?.displayName||"Host",u=e.speaker?.modelName,p=e.blocks.filter(e=>"text"===e.kind).map(e=>e.text).join("\n\n");return(0,t.jsxs)("section",{className:"assistant-step","data-message-id":e.sourceMessageId,"data-variant":l?void 0:"commentary","data-continuation":r?void 0:"true",children:[r&&(0,t.jsxs)("div",{className:o?"assistant-speaker role":"assistant-speaker",children:[(0,t.jsx)("span",{style:e.speaker?.color?{color:e.speaker.color}:void 0,children:(0,t.jsx)(c,{size:13,"aria-hidden":"true"})}),(0,t.jsx)("strong",{children:d}),o&&(0,t.jsx)("small",{children:"Role"}),u&&(0,t.jsx)("small",{className:"assistant-model",children:u})]}),e.blocks.map((e,n)=>"text"===e.kind?(0,t.jsx)(iu,{text:e.text},n):"thinking"===e.kind?(0,t.jsx)(ih,{text:e.text},n):"image"===e.kind?(0,t.jsxs)("div",{className:"image-reference",children:[(0,t.jsx)(to,{size:15,"aria-hidden":"true"})," Image ",e.width,"×",e.height]},n):(0,t.jsxs)("details",{className:"image-description",children:[(0,t.jsx)("summary",{children:"Image description"}),(0,t.jsx)("div",{children:e.text})]},n)),(0,t.jsx)(th,{text:p,time:e.createdAt,runMs:i?.runMs,ttftMs:i?.ttftMs,tokensPerSecond:i?.tokensPerSecond,branchMessageId:e.sourceMessageId!==n?e.sourceMessageId:void 0,branchDisabled:a,onBranch:s})]})});function ig({text:e,children:a}){let s=(0,f.useT)(),i=function(e,{charLimit:t=1200,lineLimit:n=14}={}){return e.length>t||e.split(/\r?\n/).length>n}(e),[r,l]=(0,n.useState)(!1),o=i&&!r;return(0,t.jsxs)("div",{className:"collapsible-message","data-collapsed":o||void 0,children:[(0,t.jsx)("div",{className:"collapsible-message-body",children:a}),i&&(0,t.jsx)("button",{type:"button",className:"collapsible-message-toggle","aria-expanded":r,onClick:()=>l(e=>!e),children:s(r?"message.collapse":"message.expand")})]})}let ix=o("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 iv=e.i(8823);function iy(e){return e.id||e.label}function ib({approval:e,submitting:a,answer:s}){let i=(0,f.useT)(),r=(0,n.useMemo)(()=>e.questions??[],[e.questions]),[l,o]=(0,n.useState)({}),[c,d]=(0,n.useState)({}),[u,p]=(0,n.useState)({}),[h,m]=(0,n.useState)(null),g="pending"!==e.status||null!==h,x=e=>{if(!0===c[e]){let t=(u[e]??"").trim();if(!t)return null;let n=r.find(t=>t.id===e);return{questionId:e,values:n?.multiSelect?l[e]??[]:[],otherText:t}}let t=l[e]??[];return t.length>0?{questionId:e,values:t}:null},v=r.length>0&&r.every(e=>null!==x(e.id));return(0,t.jsxs)("section",{className:iv.default.card,"aria-label":i("conversation.question.title"),children:[(0,t.jsxs)("header",{className:iv.default.header,children:[(0,t.jsx)("span",{className:iv.default.icon,children:(0,t.jsx)(ix,{size:16,"aria-hidden":"true"})}),(0,t.jsxs)("div",{children:[(0,t.jsx)("strong",{children:i("conversation.question.title")}),(0,t.jsx)("span",{children:g?i("conversation.question.submitted"):i("conversation.question.waiting")})]})]}),(0,t.jsx)("div",{className:iv.default.questions,children:r.map(n=>{let s=!0===n.multiSelect,m=l[n.id]??[],f=!0===c[n.id];return(0,t.jsxs)("fieldset",{className:iv.default.question,children:[(0,t.jsx)("legend",{children:n.prompt}),s&&(0,t.jsx)("small",{className:iv.default.hint,children:i("conversation.question.multiHint")}),(0,t.jsxs)("div",{className:iv.default.options,children:[n.options.map(i=>{let r=iy(i),l=m.includes(r);return(0,t.jsxs)("label",{className:iv.default.option,"data-selected":l||void 0,children:[(0,t.jsx)("input",{type:s?"checkbox":"radio",name:`question-${e.id}-${n.id}`,checked:l,disabled:g||a,onChange:()=>{var e;return e=n.id,void(o(t=>{let n=t[e]??[];return s?{...t,[e]:n.includes(r)?n.filter(e=>e!==r):[...n,r]}:{...t,[e]:[r]}}),!s&&d(t=>({...t,[e]:!1})))}}),(0,t.jsxs)("span",{children:[(0,t.jsx)("strong",{children:i.label}),i.description&&(0,t.jsx)("small",{children:i.description})]})]},r)}),n.allowOther&&!g&&(0,t.jsxs)("label",{className:iv.default.option,"data-selected":f||void 0,children:[(0,t.jsx)("input",{type:s?"checkbox":"radio",name:`question-${e.id}-${n.id}`,checked:f,disabled:a,onChange:()=>{d(e=>({...e,[n.id]:!f})),f||s||o(e=>({...e,[n.id]:[]}))}}),(0,t.jsxs)("span",{children:[(0,t.jsx)("strong",{children:i("conversation.question.other")}),f&&(0,t.jsx)("input",{className:iv.default.otherInput,value:u[n.id]??"",placeholder:i("conversation.question.otherPlaceholder"),disabled:a,onChange:e=>p(t=>({...t,[n.id]:e.target.value}))})]})]})]}),g&&(0,t.jsxs)("p",{className:iv.default.answered,children:[i("conversation.question.answered"),": ",(t=>{let n=(e.answers??h??[]).find(e=>e.questionId===t);if(!n)return"";let a=(n.values??[]).map(e=>{let n=r.find(e=>e.id===t)?.options.find(t=>iy(t)===e);return n?.label??e});return n.otherText&&a.push(n.otherText),a.join(", ")})(n.id)||"—"]})]},n.id)})}),!g&&(0,t.jsx)("div",{className:iv.default.actions,children:(0,t.jsx)("button",{type:"button",className:iv.default.submit,disabled:!v||a,onClick:()=>{let e=r.map(e=>x(e.id)).filter(e=>null!==e);m(e),s(e)},children:a?i("conversation.question.submitting"):i("conversation.question.submit")})})]})}let ik=o("circle-pause",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"10",x2:"10",y1:"15",y2:"9",key:"c1nkhi"}],["line",{x1:"14",x2:"14",y1:"15",y2:"9",key:"h65svq"}]]),ij=o("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"}]]),iw="reconnecting",i_={waiting_answer:"run.status.waitingAnswer",waiting_approval:"run.status.waitingApproval",waiting_delegation_admission:"run.status.waitingDelegation",waiting_children:"run.status.waitingChildren",running:"run.status.running",running_tool:"run.status.runningTool",reconnecting:"run.status.reconnecting",steering:"run.status.steering",cancelled:"run.status.cancelled",compacting:"run.status.compacting",compaction_queued:"run.status.compactionQueued",compaction_retry_wait:"run.status.compactionRetryWait",compaction_retry:"run.status.compactionRetry",checkpoint_ready:"run.status.checkpointReady",answer_submitted:"run.status.answerSubmitted",approval_granted:"run.status.approvalGranted",approval_rejected:"run.status.approvalRejected",resuming:"run.status.resuming",model_retry:"run.status.modelRetry",preparing_context:"run.status.preparingContext",preparing_run_context:"run.status.preparingRunContext",compacting_run:"run.status.compactingRun",run_compaction_retry:"run.status.runCompactionRetry",run_context_compacted:"run.status.runContextCompacted",run_compaction_skipped:"run.status.runCompactionSkipped",using_checkpoint:"run.status.usingCheckpoint",recovering_tool:"run.status.recoveringTool",output_truncated:"run.status.outputTruncated",using_model:"run.status.usingModel",describing_image:"run.status.describingImage",image_ready:"run.status.imageReady",completed:"run.status.completed",interrupted:"run.status.interrupted",sending:"run.status.sending",uploading_image:"run.status.uploadingImage"};function iN(e,t){return t?`${e}\u001f${t}`:e}function iC(e){let t=e.indexOf("\x1f");return t<0?{code:e,detail:""}:{code:e.slice(0,t),detail:e.slice(t+1)}}function iS(e,t){let{code:n,detail:a}=iC(e),s=i_[n];return s?t(s).split("{detail}").join(a):a||n.replaceAll("_"," ")}function iI({status:e,active:a,waiting:s,waitingForQuestion:i,reconnecting:r,compacting:l,startedAt:o,runId:c,cacheReadTokens:d=0,inputTokens:u=0,outputTokens:p=0}){let h=(0,f.useT)(),m=function(e,t,a){let[s,i]=(0,n.useState)(null),r=(0,n.useRef)(null);return(0,n.useEffect)(()=>{var n;let s;if(!e||!t)return;r.current?.runId!==t&&(r.current={runId:t,origin:(n=Date.now(),Number.isNaN(s=a?Date.parse(a):NaN)||s>n+5e3?n:s)});let l=r.current.origin,o=()=>i({runId:t,seconds:Math.max(0,Math.floor((Date.now()-l)/1e3))}),c=window.requestAnimationFrame(o),d=window.setInterval(o,1e3);return()=>{window.cancelAnimationFrame(c),window.clearInterval(d)}},[e,t,a]),e&&t&&s&&s.runId===t?s.seconds:null}(a,c,o);if(!a&&!e)return null;let g=iC(e).code,x=r?h("run.status.reconnecting"):s?h(i?"run.status.waitingAnswer":"run.status.waitingApproval"):e?iS(e,h):h(l?"run.status.compacting":"run.status.running"),v=r?ij:s?ik:a?eQ:"interrupted"===g||"run_compaction_skipped"===g?eX:e0;return(0,t.jsxs)("div",{className:`run-status ${a?"is-active":""} ${s?"is-waiting":""}`,children:[(0,t.jsxs)("span",{role:"status",children:[(0,t.jsx)(v,{size:14,"aria-hidden":"true",className:!a||s||r?"":"status-spin"}),(0,t.jsx)("span",{children:x})]}),(null!==m||d>0||u>0||p>0)&&(0,t.jsxs)("span",{className:"run-status-metrics","aria-hidden":"true",children:[null!==m?function(e){if(e<60)return`${e}s`;let t=Math.floor(e/60);return`${t}m ${String(e%60).padStart(2,"0")}s`}(m):"",d>0?` ${h("run.status.cache",{count:tu(d)})}`:"",u>0||p>0?` ↑${tu(u)} ↓${tu(p)}`:""]})]})}let iP=o("file-pen-line",[["path",{d:"M14.364 13.634a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506l4.013-4.009a1 1 0 0 0-3.004-3.004z",key:"ukzhwg"}],["path",{d:"M14.487 7.858A1 1 0 0 1 14 7V2",key:"1klhew"}],["path",{d:"M20 19.645V20a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l2.516 2.516",key:"rxaxab"}],["path",{d:"M8 18h1",key:"13wk12"}]]),iT=o("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"}]]),iM=o("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"}]]),iR=o("terminal",[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]]),iE=o("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"}]]),iA=o("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"}]]),i$=o("file-code-corner",[["path",{d:"M4 12.15V4a2 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 2h-3.35",key:"1wthlu"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"m5 16-3 3 3 3",key:"331omg"}],["path",{d:"m9 22 3-3-3-3",key:"lsp7cz"}]]),iz=o("table-2",[["path",{d:"M9 3H5a2 2 0 0 0-2 2v4m6-6h10a2 2 0 0 1 2 2v4M9 3v18m0 0h10a2 2 0 0 0 2-2V9M9 21H5a2 2 0 0 1-2-2V9m0 0h18",key:"gugj83"}]]);function iF({sessionId:e,artifact:a}){let[s,i]=(0,n.useState)(""),[r,l]=(0,n.useState)(null),[o,c]=(0,n.useState)(!1);return((0,n.useEffect)(()=>{let t=new AbortController;return(0,e5.apiFetch)(eF(e,a.artifactId,s||void 0),{signal:t.signal}).then(e=>{c(!1),l(e)}).catch(e=>{"AbortError"!==e.name&&c(!0)}),()=>t.abort()},[a.artifactId,e,s]),r||o)?o||!r?(0,t.jsx)("div",{className:"artifact-preview-state is-error",role:"alert",children:"Preview unavailable"}):(0,t.jsxs)("div",{className:"artifact-table-preview",children:[(r.sheets?.length??0)>1&&(0,t.jsxs)("label",{className:"artifact-sheet-control",children:[(0,t.jsx)("span",{children:"Worksheet"}),(0,t.jsx)("select",{value:s||r.sheet||"",onChange:e=>i(e.target.value),children:r.sheets?.map(e=>(0,t.jsx)("option",{value:e,children:e},e))})]}),(0,t.jsx)("div",{className:"artifact-table-scroll",tabIndex:0,"aria-label":`Scrollable preview of ${a.name}`,children:(0,t.jsxs)("table",{children:[(0,t.jsxs)("caption",{className:"sr-only",children:["Preview of ",a.name]}),(0,t.jsx)("thead",{children:(0,t.jsx)("tr",{children:r.columns.map((e,n)=>(0,t.jsx)("th",{scope:"col",title:e,children:e||`Column ${n+1}`},`${e}-${n}`))})}),(0,t.jsx)("tbody",{children:r.rows.map((e,n)=>(0,t.jsx)("tr",{children:r.columns.map((n,a)=>(0,t.jsx)("td",{title:e[a]??"",children:e[a]??""},a))},n))})]})}),(r.truncatedRows||r.truncatedColumns)&&(0,t.jsxs)("div",{className:"artifact-preview-limit",children:["Preview limited to ",r.rowLimit," rows x ",r.columnLimit," columns"]})]}):(0,t.jsx)("div",{className:"artifact-preview-state",role:"status","aria-live":"polite",children:"Loading preview..."})}function iL({sessionId:e,artifact:n}){var a,s,i;let r,l=eF(e,n.artifactId),o=(a=n.artifactId,`${ez(e,a)}/download`);return(0,t.jsxs)("section",{className:"artifact-result","aria-label":`Artifact ${n.name}`,"data-artifact-kind":n.kind,"data-artifact-id":n.artifactId,children:[(0,t.jsxs)("header",{className:"artifact-result-header",children:[(0,t.jsx)("span",{className:"artifact-result-icon",children:(i=n.kind,r={size:15,"aria-hidden":!0},"image"===i?(0,t.jsx)(to,{...r}):"table"===i?(0,t.jsx)(iz,{...r}):"static_html"===i?(0,t.jsx)(i$,{...r}):(0,t.jsx)(ei,{...r}))}),(0,t.jsx)("span",{className:"artifact-result-name",title:n.name,children:n.name}),(0,t.jsxs)("span",{className:"artifact-result-meta",children:[n.mimeType," · ",(s=n.sizeBytes)<1024?`${s} B`:s<1048576?`${(s/1024).toFixed(+(s<10240))} KB`:`${(s/1048576).toFixed(+(s<0xa00000))} MB`]}),(0,t.jsx)("a",{className:"artifact-download",href:o,download:n.name,"aria-label":`Download ${n.name}`,title:`Download ${n.name}`,children:(0,t.jsx)(iA,{size:15,"aria-hidden":"true"})})]}),"image"===n.kind&&(0,t.jsx)(iD,{artifact:n,previewURL:l}),"table"===n.kind&&(0,t.jsx)(iF,{sessionId:e,artifact:n}),"static_html"===n.kind&&(0,t.jsx)("iframe",{className:"artifact-html-preview",src:l,title:`${n.name} preview`,sandbox:"",referrerPolicy:"no-referrer",loading:"lazy"}),"text"===n.kind&&(0,t.jsx)(iO,{sessionId:e,artifact:n})]})}function iD({artifact:e,previewURL:a}){let[s,i]=(0,n.useState)(!1);return s?(0,t.jsx)("div",{className:"artifact-preview-state is-error",role:"alert",children:"Preview unavailable"}):(0,t.jsxs)("figure",{className:"artifact-image-preview",children:[(0,t.jsx)("img",{src:a,alt:e.name,width:e.width,height:e.height,loading:"lazy",onError:()=>i(!0)}),(e.width||e.height)&&(0,t.jsxs)("figcaption",{children:[e.width," x ",e.height]})]})}function iO({sessionId:e,artifact:a}){let[s,i]=(0,n.useState)(null),[r,l]=(0,n.useState)(!1);return((0,n.useEffect)(()=>{let t=new AbortController;return(0,e5.apiFetch)(eF(e,a.artifactId),{signal:t.signal}).then(i).catch(e=>{"AbortError"!==e.name&&l(!0)}),()=>t.abort()},[a.artifactId,e]),r)?(0,t.jsx)("div",{className:"artifact-preview-state is-error",role:"alert",children:"Preview unavailable"}):s?(0,t.jsxs)("div",{className:"artifact-text-preview",children:[(0,t.jsx)("pre",{children:s.text}),s.truncated&&(0,t.jsx)("span",{children:"Preview truncated"})]}):(0,t.jsx)("div",{className:"artifact-preview-state",role:"status","aria-live":"polite",children:"Loading preview..."})}let iq=o("ban",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M4.929 4.929 19.07 19.071",key:"196cmz"}]]),iB=o("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"}]]),iU=o("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"}]]),iH=new Set(["read","ls","list","grep","search","find","search_compacted_history","todo","ask_user"]),iW=new Set(["write","edit","publish_artifact"]),iV=new Set(["bash","exec"]),iK=new Set(["http","http_request","fetch","web_search","web_fetch"]),iG=/api[_-]?key|token|secret|password|credential|authorization|cookie/i;function iJ(e){let t=e.toLowerCase();return iH.has(t)?"read_only":iW.has(t)?"local_write":iV.has(t)?"shell":iK.has(t)?"external":"delegate_tasks"===t||"delegate_heroes"===t?"delegation":"sensitive"}function iY(e,t=0){return t>8?"[nested value omitted]":Array.isArray(e)?e.slice(0,50).map(e=>iY(e,t+1)):e&&"object"==typeof e?Object.fromEntries(Object.entries(e).slice(0,80).map(([e,n])=>[e,iG.test(e)?"[redacted]":iY(n,t+1)])):e}function iQ(e,t=4e3){return e.length<=t?e:`${e.slice(0,t)}
2
- [${e.length-t} characters omitted]`}function iZ(e){return e&&"object"==typeof e&&!Array.isArray(e)?e:{}}function iX(e){return"string"==typeof e?e:""}function i0(e){return"number"==typeof e&&Number.isFinite(e)?e:void 0}function i1(e){return"string"==typeof e?`${e.length.toLocaleString()} characters`:void 0}function i2(e,t){let n=e.replace(/\s+/g," ").trim();return n.length<=t?n:`${n.slice(0,t-1)}…`}function i4({child:e,reused:n=!1,activity:a,onRetry:s,onContinue:i}){var r,l,o;let d,u,p=function(e){if("blocked"===e.itemStatus)return"blocked";switch(e.runStatus){case"queued":return"queued";case"running":return"running";case"waiting_for_approval":return"approval";case"succeeded":return"completed";case"failed":return"failed";case"interrupted":return"interrupted";case"cancelled":return"cancelled"}return"succeeded"===e.itemStatus?"completed":"failed"===e.itemStatus||"not_authorized"===e.itemStatus?"failed":"cancelled"===e.itemStatus?"cancelled":"queued"}(e),h=e.result?.summary||e.errorMessage||"",m=void 0!==s&&("failed"===p||"interrupted"===p||"cancelled"===p),f=void 0!==i?(d=(r=e).result,d?.status==="needs_input"?"input":d?.status==="blocked"||"succeeded"===r.itemStatus?"follow_up":null):null,g=("running"===p||"queued"===p)&&a?a:void 0;return(0,t.jsxs)("div",{className:"child-run-row","data-child-run-id":e.childRunId,"data-state":p,role:"listitem",children:[(0,t.jsx)("span",{className:"child-run-icon",children:(0,t.jsx)(c,{size:14,"aria-hidden":"true"})}),(0,t.jsxs)("span",{className:"child-run-identity",children:[(0,t.jsx)("strong",{children:e.name}),(0,t.jsxs)("span",{children:["@",e.heroHandle]}),n&&(0,t.jsx)("span",{className:"child-run-reused",children:"Reused"})]}),(0,t.jsxs)("span",{className:"child-run-actions",children:[m&&(0,t.jsx)("button",{type:"button",className:"child-run-retry","aria-label":`Retry ${e.name}`,title:"Retry this delegated task",onClick:()=>s(e.itemId),children:(0,t.jsx)($,{size:13,"aria-hidden":"true"})}),f&&i&&(0,t.jsx)("button",{type:"button",className:"child-run-retry","aria-label":`${"input"===f?"Reply":"Follow up"} ${e.name}`,title:"input"===f?"Reply to this delegated task":"Follow up privately",onClick:()=>i(e.itemId,f),children:(0,t.jsx)(iU,{size:13,"aria-hidden":"true"})}),(0,t.jsxs)("span",{className:"child-run-status",children:[(u={size:13,"aria-hidden":!0},"completed"===(l=p)?(0,t.jsx)(e0,{...u}):"failed"===l?(0,t.jsx)(eX,{...u}):"blocked"===l||"interrupted"===l?(0,t.jsx)(ik,{...u}):"cancelled"===l?(0,t.jsx)(iE,{...u}):(0,t.jsx)(e1,{...u})),"queued"===(o=p)?"Queued":"running"===o?"Running":"approval"===o?"Approval":"completed"===o?"Completed":"blocked"===o?"Blocked":"interrupted"===o?"Interrupted":"cancelled"===o?"Cancelled":"Failed",g&&(0,t.jsx)("span",{className:"child-run-activity",title:g,children:g}),i5(e)&&("failed"===p||"blocked"===p)&&(0,t.jsx)("span",{className:"child-run-error-code",children:i5(e)})]})]}),h&&(0,t.jsxs)("details",{className:"child-run-result",children:[(0,t.jsx)("summary",{children:e.result?"Result":"Failure"}),(0,t.jsx)("div",{children:iQ(h,1200)})]})]})}function i5(e){if("blocked"===e.itemStatus)return"Blocked";switch(e.errorCode){case"delegation_budget_exceeded":return"Budget exceeded";case"delegation_not_authorized":return"Not authorized";case"delegation_dag_invalid":return"Blocked";case"tool_batch_failed":return"Tool failure";case"process_not_allowed":return"Process not allowed";case"permission_mode_sensitive":return"Sensitive action";default:return e.errorCode?e.errorCode:null}}let i3=o("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 i6({itemID:e,itemName:a,kind:s,sourceAttemptID:i,expectedGeneration:r,onDone:l}){let[o,c]=(0,n.useState)(""),[d,u]=(0,n.useState)(!1),[p,h]=(0,n.useState)(null),f=(0,n.useRef)(null);M(!0,l,{dismissOnEscape:!d}),(0,n.useEffect)(()=>{f.current?.focus()},[]);let g="input"===s?"input":"follow-up",x=async()=>{if(!d&&o.trim()){u(!0),h(null);try{await (0,e5.apiFetch)(`/v1/delegation-items/${encodeURIComponent(e)}/${g}`,{method:"POST",body:JSON.stringify({sourceAttemptId:i,expectedGeneration:r,text:o,clientRequestId:crypto.randomUUID()})}),l()}catch(e){h(e.message),l(),c(o)}finally{u(!1)}}};return(0,t.jsxs)("div",{className:"follow-up-dialog",role:"dialog","aria-label":`${"input"===s?"Reply":"Follow up"} ${a}`,children:[(0,t.jsxs)("div",{className:"follow-up-header",children:[(0,t.jsxs)("span",{children:[(0,t.jsx)(iU,{size:14,"aria-hidden":"true"}),"input"===s?"Reply to delegated task":"Private follow-up"]}),(0,t.jsx)("button",{type:"button",className:"follow-up-close","aria-label":"Close",title:"Close",onClick:l,children:(0,t.jsx)(m,{size:14,"aria-hidden":"true"})})]}),(0,t.jsxs)("div",{className:"follow-up-meta",children:[(0,t.jsx)("strong",{children:a}),(0,t.jsxs)("span",{children:["generation ",r," → ",r+1]})]}),(0,t.jsx)("textarea",{ref:f,className:"follow-up-input",rows:3,placeholder:"input"===s?"Answer the question the delegated task asked…":"Additional private instruction…",value:o,onChange:e=>c(e.target.value)}),p&&(0,t.jsxs)("div",{className:"follow-up-error",role:"status",children:["Refreshed: ",p]}),(0,t.jsx)("div",{className:"follow-up-actions",children:(0,t.jsxs)("button",{type:"button",className:"follow-up-submit",disabled:d||!o.trim(),onClick:x,children:[(0,t.jsx)(i3,{size:13,"aria-hidden":"true"})," ","input"===s?"Send reply":"Follow up"]})})]})}let i8=o("rotate-ccw-clock",[["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"}]]);function i9(e){if(!e)return"";let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function i7({inspection:e}){let n=e.generations??[];if(0===n.length)return null;let a=e.currentGeneration??0;return(0,t.jsxs)("details",{className:"generation-history",children:[(0,t.jsxs)("summary",{children:[(0,t.jsx)(i8,{size:12,"aria-hidden":"true"}),(0,t.jsxs)("span",{children:["Generations (",n.length,")"]})]}),(0,t.jsx)("div",{className:"generation-history-body",children:n.map(e=>(0,t.jsxs)("div",{className:"generation-row","data-generation":e.generation,children:[(0,t.jsx)("strong",{children:e.generation===a?`Generation ${e.generation} (current)`:`Generation ${e.generation}`}),(0,t.jsxs)("span",{children:[e.kind," · ",e.retrySelection?.length??0," selected"," · ",e.reusedAttempts?.length??0," reused"]}),(0,t.jsx)("span",{className:"generation-status-tag","data-status":e.status,children:e.status}),(0,t.jsxs)("details",{className:"generation-detail",children:[(0,t.jsx)("summary",{children:"Details"}),(0,t.jsxs)("ul",{children:[(0,t.jsxs)("li",{children:["Created: ",(0,t.jsx)("time",{children:i9(e.createdAt)})]}),e.completedAt&&(0,t.jsxs)("li",{children:["Completed: ",(0,t.jsx)("time",{children:i9(e.completedAt)})]}),e.retrySelection?.length>0&&(0,t.jsxs)("li",{children:["Retried items: ",e.retrySelection.join(", ")]}),e.reusedAttempts?.map(e=>(0,t.jsxs)("li",{children:["Reused ",e.itemId," · attempt ",e.generation,e.resultDigest?` \xb7 ${e.resultDigest.slice(0,12)}…`:""]},e.attemptId))]})]})]},e.id))})]})}var re=e.i(6929);function rt(...e){return e.filter(Boolean).join(" ")}let rn=(0,n.forwardRef)(function({variant:e="secondary",size:n="md",className:a,type:s="button",...i},r){return(0,t.jsx)("button",{ref:r,type:s,className:rt(re.default.button,re.default[e],re.default[n],a),...i})}),ra=(0,n.forwardRef)(function({label:e,title:n,size:a="md",active:s=!1,className:i,type:r="button",children:l,...o},c){return(0,t.jsx)("button",{ref:c,type:r,"aria-label":e,title:n??e,"data-active":s||void 0,className:rt(re.default.iconButton,"sm"===a&&re.default.iconButtonSm,i),...o,children:l})});var rs=e.i(86609);let ri=[],rr=1,rl=null;function ro(){return ri.shift()??null}function rc(e){if(!rl){let t=[e.title,e.description].filter(Boolean).join("\n\n");return Promise.resolve(window.confirm(t))}return new Promise(t=>{ri.push({id:rr++,options:e,resolve:t}),rl?.()})}function rd(){let[e,a]=(0,n.useState)(null),s=(0,n.useRef)(null),i=(0,n.useRef)(null),r=(0,n.useRef)(null),l=(0,n.useId)(),o=(0,n.useId)(),c=(0,n.useCallback)(()=>{if(null!==s.current)return;let e=ro();null!==e&&(s.current=e,a(e))},[]);(0,n.useEffect)(()=>{let e=(rl=c,()=>{rl===c&&(rl=null)});return queueMicrotask(c),e},[c]);let d=(0,n.useCallback)(e=>{let t=s.current;if(null===t)return;s.current=null,t.resolve(e),a(null);let n=ro();null!==n&&(s.current=n,a(n))},[]);if(M(null!==e,()=>d(!1)),(0,n.useEffect)(()=>{if(null===e)return;let t=window.requestAnimationFrame(()=>r.current?.focus()),n=e=>{if("Tab"!==e.key||null===i.current)return;let t=Array.from(i.current.querySelectorAll('button:not(:disabled), [href], input:not(:disabled), select:not(:disabled), textarea:not(:disabled), [tabindex]:not([tabindex="-1"])')).filter(e=>e.getClientRects().length>0);if(0===t.length)return;let n=t[0],a=t[t.length-1];e.shiftKey&&document.activeElement===n?(e.preventDefault(),a.focus()):e.shiftKey||document.activeElement!==a||(e.preventDefault(),n.focus())};return document.addEventListener("keydown",n),()=>{window.cancelAnimationFrame(t),document.removeEventListener("keydown",n)}},[e]),null===e)return null;let{options:u}=e;return(0,t.jsx)("div",{className:rs.default.overlay,onPointerDown:e=>{e.target===e.currentTarget&&d(!1)},children:(0,t.jsxs)("div",{ref:i,className:rs.default.dialog,role:"alertdialog","aria-modal":"true","aria-labelledby":l,"aria-describedby":u.description?o:void 0,children:[(0,t.jsx)("h2",{id:l,className:rs.default.title,children:u.title}),u.description&&(0,t.jsx)("p",{id:o,className:rs.default.description,children:u.description}),(0,t.jsxs)("div",{className:rs.default.actions,children:[(0,t.jsx)(rn,{ref:r,variant:"secondary",onClick:()=>d(!1),children:u.cancelLabel??"Cancel"}),(0,t.jsx)(rn,{variant:"danger"===u.tone?"danger":"primary",onClick:()=>d(!0),children:u.confirmLabel??"Confirm"})]})]})})}let ru=null,rp=(0,n.createContext)(null);function rh({children:e}){let[a,s]=(0,n.useState)(new Map);(0,n.useEffect)(()=>(ru=e=>{s(t=>{let n=new Map(t),a=new Map(n.get(e.delegationGroupId)??[]);return a.set(e.taskName,e.activity),n.set(e.delegationGroupId,a),n})},()=>void(ru=null)),[]);let i=(0,n.useMemo)(()=>({progress:a}),[a]);return(0,t.jsx)(rp.Provider,{value:i,children:e})}let rm=new Map;function rf({parentRunId:e,toolCallId:a}){let[s,i]=(0,n.useState)(null),[r,l]=(0,n.useState)({}),[o,c]=(0,n.useState)(null),[d,u]=(0,n.useState)(!0),[p,h]=(0,n.useState)(0),[m,f]=(0,n.useState)(!0),[g,x]=(0,n.useState)(null),v=function(){let e=(0,n.useContext)(rp);if(!e)throw Error("useChildProgress must be used inside ChildProgressProvider");return e.progress}(),[y,b]=(0,n.useState)(null);(0,n.useEffect)(()=>{let t,n=new AbortController,s=0,r=async()=>{try{let l=await (0,e5.apiFetch)(`/v1/runs/${encodeURIComponent(e)}/children`,{signal:n.signal});if(n.signal.aborted)return;i(l),c(null);let o=l.groups.filter(e=>e.parentToolCallId===a),d=o.some(e=>{var t;return t=e,"settled"!==t.status&&"cancelled"!==t.status||t.children.some(e=>e.runStatus?!rv(e.runStatus):"pending"===e.itemStatus||"running"===e.itemStatus)});0===o.length?s+=1:s=0;let p=d||0===o.length&&s<20;u(0===o.length&&p),p&&(t=window.setTimeout(r,1200))}catch(e){if(n.signal.aborted)return;c(e.message),u(!1)}};return r(),()=>{n.abort(),void 0!==t&&window.clearTimeout(t)}},[e,p,a]);let k=(0,n.useMemo)(()=>s?.groups.filter(e=>e.parentToolCallId===a)??[],[s,a]),j=(0,n.useMemo)(()=>k.map(e=>e.id).join(","),[k]);(0,n.useEffect)(()=>{let e=new AbortController;for(let t of j.split(",").filter(Boolean))(0,e5.apiFetch)(`/v1/delegations/${encodeURIComponent(t)}`,{signal:e.signal}).then(n=>{e.signal.aborted||l(e=>({...e,[t]:n}))}).catch(()=>{});return()=>e.abort()},[j,p]);let w=k.flatMap(e=>e.children),_=w.filter(e=>e.runStatus&&!rv(e.runStatus)).length,N=(0,n.useCallback)(async(e,t)=>{if(g)return;let n=r[e.id],a=n?.currentGeneration??0;x(t);try{await (0,e5.apiFetch)(`/v1/delegations/${encodeURIComponent(e.id)}/retry`,{method:"POST",body:JSON.stringify({expectedGeneration:a,itemIds:[t],clientRequestId:crypto.randomUUID()})}),h(e=>e+1)}catch(e){c(e.message),h(e=>e+1)}finally{x(null)}},[g,r]),C=(0,n.useCallback)(async e=>{if(!g&&await rc({title:"Cancel all active tasks in this delegation?",description:"Running children will be cancelled; completed results are kept.",confirmLabel:"Cancel tasks",tone:"danger"})){x(`${e.id}:cancel`);try{await (0,e5.apiFetch)(`/v1/delegations/${encodeURIComponent(e.id)}/cancel`,{method:"POST"}),c(null),h(e=>e+1)}catch(e){c(e.message)}finally{x(null)}}},[g]),S=(0,n.useCallback)(async(e,t)=>{if(!g){x(e+t);try{await (0,e5.apiFetch)(`/v1/delegation-approvals/${encodeURIComponent(e)}/decision`,{method:"POST",body:JSON.stringify({decision:t,clientRequestId:crypto.randomUUID()})}),h(e=>e+1)}catch(e){c(e.message)}finally{x(null)}}},[g]);return(0,t.jsxs)("details",{className:"nested-activity",open:m,onToggle:e=>f(e.currentTarget.open),children:[(0,t.jsxs)("summary",{children:[(0,t.jsxs)("span",{children:[(0,t.jsx)(ta,{size:14,"aria-hidden":"true"})," Delegated heroes"]}),(0,t.jsx)("span",{children:w.length?`${w.length} ${_?`\xb7 ${_} active`:"· settled"}`:""})]}),(0,t.jsxs)("div",{className:"nested-activity-body",children:[!s&&!o&&(0,t.jsx)("div",{className:"nested-activity-state",children:"Loading delegated activity…"}),s&&0===k.length&&d&&(0,t.jsx)("div",{className:"nested-activity-state",children:"Preparing delegated runs…"}),s&&0===k.length&&!d&&!o&&(0,t.jsx)("div",{className:"nested-activity-state",children:"No delegated runs were recorded."}),o&&(0,t.jsxs)("div",{className:"nested-activity-error",role:"status",children:[(0,t.jsx)("span",{children:"Delegation activity unavailable"}),(0,t.jsx)("button",{type:"button","aria-label":"Retry delegation activity",title:"Retry",onClick:()=>h(e=>e+1),children:(0,t.jsx)(iB,{size:14,"aria-hidden":"true"})})]}),k.map(e=>(0,t.jsx)(rg,{group:e,inspection:r[e.id],busy:g,progress:v.get(e.id)??rm,onRetry:N,onCancel:C,onDecide:S,onContinue:(e,t,n,a,s)=>b({itemID:e,itemName:t,kind:n,sourceAttemptID:a,expectedGeneration:s})},e.id))]}),y&&(0,t.jsx)(i6,{itemID:y.itemID,itemName:y.itemName,kind:y.kind,sourceAttemptID:y.sourceAttemptID,expectedGeneration:y.expectedGeneration,onDone:()=>{b(null),h(e=>e+1)}})]})}function rg({group:e,inspection:a,busy:s,onRetry:i,onCancel:r,onDecide:l,onContinue:o,progress:c}){let d=(0,n.useMemo)(()=>{let e=new Set;for(let t of a?.generations??[])for(let n of t.reusedAttempts??[])n.childRunId&&e.add(n.childRunId);return e},[a]),u=a?.pendingApproval,p=a?.validActions.includes("cancel")??!1;return(0,t.jsxs)(t.Fragment,{children:[p&&(0,t.jsxs)("div",{className:"delegation-group-actions",children:[(0,t.jsx)("span",{children:"Delegation in progress"}),(0,t.jsxs)("button",{type:"button",className:"child-run-reject",disabled:null!==s,onClick:()=>r(e),children:[(0,t.jsx)(iq,{size:13,"aria-hidden":"true"})," Cancel delegation"]})]}),(0,t.jsx)("div",{className:"child-run-list",role:"list",children:e.children.map(n=>(0,t.jsx)(i4,{child:n,reused:d.has(n.childRunId??""),activity:c.get(n.name),onRetry:t=>i(e,t),onContinue:rx(a,n.itemId)?(e,t)=>{let s=rx(a,e);o(e,n.name,t,s,a?.currentGeneration??0)}:void 0},n.itemId))}),u&&(0,t.jsxs)("div",{className:"delegation-approval-banner",role:"status",children:[(0,t.jsx)("span",{children:"Retry budget increase awaits approval"}),(0,t.jsxs)("span",{className:"banner-actions",children:[(0,t.jsxs)("button",{type:"button",className:"child-run-approve","aria-label":"Approve retry budget",title:"Approve",disabled:null!==s,onClick:()=>l(u.id,"approved"),children:[(0,t.jsx)(Y,{size:13,"aria-hidden":"true"})," Approve"]}),(0,t.jsxs)("button",{type:"button",className:"child-run-reject","aria-label":"Reject retry budget",title:"Reject",disabled:null!==s,onClick:()=>l(u.id,"rejected"),children:[(0,t.jsx)(m,{size:13,"aria-hidden":"true"})," Reject"]})]})]}),a&&(0,t.jsx)(i7,{inspection:a})]})}function rx(e,t){if(!e)return"";let n=e.generations.find(t=>t.generation===e.currentGeneration),a=n?.reusedAttempts.find(e=>e.itemId===t);if(a)return a.attemptId;let s=e.items.find(e=>e.itemId===t);return s?.attempts.find(t=>t.generation===e.currentGeneration)?.attemptId??""}function rv(e){return"succeeded"===e||"failed"===e||"cancelled"===e||"interrupted"===e}let ry={read_only:"conversation.tool.risk.readOnly",local_write:"conversation.tool.risk.localWrite",shell:"conversation.tool.risk.shell",external:"conversation.tool.risk.external",delegation:"conversation.tool.risk.delegation",sensitive:"conversation.tool.risk.sensitive"};function rb({arguments:e}){let a=(0,f.useT)(),s=(0,n.useMemo)(()=>{let t=e&&"object"==typeof e?e:{};return(Array.isArray(t.tasks)?t.tasks:Array.isArray(t.delegations)?t.delegations:[]).map(e=>{let t=e&&"object"==typeof e?e:{},n=String(t.hero??t.heroHandle??""),a=Array.isArray(t.depends)?t.depends.map(String).filter(Boolean):[];return{name:String(t.name??""),hero:n,depends:a}}).filter(e=>e.name||e.hero)},[e]);return 0===s.length?null:(0,t.jsx)("div",{className:"delegation-task-list",role:"list",children:s.map((e,n)=>(0,t.jsxs)("div",{className:"delegation-task",role:"listitem",children:[(0,t.jsx)("span",{className:"delegation-task-name",children:e.name||"(task)"}),e.hero&&(0,t.jsxs)("span",{className:"delegation-task-hero",children:["@",e.hero]}),e.depends.length>0&&(0,t.jsx)("span",{className:"delegation-task-depends",children:a("conversation.tool.after",{names:e.depends.join(", ")})})]},`${e.name}-${n}`))})}function rk({activity:e,sessionId:n}){var a,s,i,r;let l,o=(0,f.useT)(),c=function(e,t){let n=iZ(iY(t)),a=iX(n.path??n.filePath??n.directory??n.cwd);switch(e.toLowerCase()){case"read":{let e=i0(n.offset),t=i0(n.limit);return{label:"Read file",target:a||"Workspace file",detail:void 0!==e&&void 0!==t?`lines ${e}-${e+t-1}`:void 0}}case"ls":case"list":return{label:"List directory",target:a||"Workspace"};case"grep":case"search":return{label:"Search text",target:iX(n.query??n.pattern)||"Search",detail:a||void 0};case"find":return{label:"Find files",target:iX(n.pattern??n.name)||"Files",detail:a||void 0};case"write":return{label:"Write file",target:a||"Workspace file",detail:i1(n.content)};case"edit":return{label:"Edit file",target:a||"Workspace file",detail:i1(n.newText??n.replacement)};case"publish_artifact":return{label:"Publish artifact",target:iX(n.name)||a||"Workspace file"};case"bash":case"exec":return{label:"Run command",target:i2(iX(n.command??n.cmd)||"Shell command",180),detail:a||void 0};case"web_fetch":return{label:"Fetch external page",target:i2(iX(n.url)||"External URL",180)};case"http":case"http_request":case"fetch":return{label:"External request",target:i2(iX(n.url)||"External service",180)};case"search_compacted_history":return{label:"Search compacted history",target:i2(iX(n.query)||"Session history",180)};case"ask_user":{let e=Array.isArray(n.questions)?n.questions:[];return{label:"Ask user",target:1===e.length?"1 question":`${e.length} questions`}}case"delegate_tasks":case"delegate_heroes":{let e=Array.isArray(n.tasks)?n.tasks:Array.isArray(n.delegations)?n.delegations:[],t=e.map(e=>iZ(e)).map(e=>iX(e.role??e.heroHandle)).filter(Boolean);return{label:"Delegate tasks",target:1===e.length?"1 task":`${e.length} tasks`,detail:t.length?t.map(e=>`@${e}`).join(", "):void 0}}case"todo":{let e=Array.isArray(t&&"object"==typeof t&&"todos"in t?t.todos:void 0)?t.todos:[],n=e.filter(e=>e&&"object"==typeof e&&"completed"===e.status).length;return{label:"Update task list",target:`${n}/${e.length} completed`}}default:if(e.includes("__")){let t=e.indexOf("__"),n=e.slice(0,t);return{label:e.slice(t+2)||e,target:`MCP \xb7 ${n}`}}return{label:e||"Unknown tool",target:"Sensitive tool call"}}}(e.toolName,e.arguments),d=e.arguments?iQ(JSON.stringify(iY(e.arguments),null,2),2200):o(e.argumentsFragment?"conversation.tool.incompleteArguments":"conversation.tool.noArguments"),p=e.result?iQ(e.result.content):"";return(0,t.jsxs)("div",{className:"tool-activity-entry",children:[(0,t.jsxs)("details",{className:"tool-activity","data-risk":e.riskClass,"data-state":e.state,"data-tool-call-id":e.toolCallId,open:(a=e.riskClass,"completed"!==e.state||"read_only"!==a||void 0),children:[(0,t.jsxs)("summary",{children:[(0,t.jsx)("span",{className:"tool-icon",children:function(e){let n={size:15,"aria-hidden":!0};switch(e.toLowerCase()){case"read":return(0,t.jsx)(ei,{...n});case"ls":case"list":return(0,t.jsx)(_,{...n});case"grep":case"search":case"find":case"search_compacted_history":return(0,t.jsx)(u,{...n});case"ask_user":return(0,t.jsx)(ix,{...n});case"write":case"edit":case"publish_artifact":return(0,t.jsx)(iP,{...n});case"bash":case"exec":return(0,t.jsx)(iR,{...n});case"delegate_tasks":case"delegate_heroes":return(0,t.jsx)(ta,{...n});case"http":case"http_request":case"fetch":case"web_search":return(0,t.jsx)(iT,{...n});default:return(0,t.jsx)(iM,{...n})}}(e.toolName)}),(0,t.jsxs)("span",{className:"tool-summary",children:[(0,t.jsx)("strong",{children:c.label}),(0,t.jsx)("span",{className:"tool-target",children:c.target}),c.detail&&(0,t.jsx)("span",{className:"tool-detail",children:c.detail})]}),(0,t.jsx)("span",{className:"tool-risk",children:o(ry[e.riskClass]??"conversation.tool.risk.sensitive")}),(0,t.jsxs)("span",{className:"tool-state",children:[(i=e.state,l={size:14,"aria-hidden":!0},"completed"===i?(0,t.jsx)(e0,{...l}):"pending"===i||"running"===i?(0,t.jsx)(e1,{...l}):"rejected"===i?(0,t.jsx)(iE,{...l}):(0,t.jsx)(eX,{...l})),(r=e.state,o("completed"===r?"conversation.tool.state.done":"pending"===r?"conversation.tool.state.pending":"running"===r?"conversation.tool.state.running":"rejected"===r?"conversation.tool.state.rejected":"interrupted"===r?"conversation.tool.state.interrupted":"conversation.tool.state.failed"))]})]}),(0,t.jsxs)("div",{className:"tool-activity-details",children:["delegate_tasks"===(s=e.toolName)||"delegate_heroes"===s?(0,t.jsx)(rb,{arguments:e.arguments}):(0,t.jsxs)("details",{className:"tool-detail-disclosure",children:[(0,t.jsx)("summary",{children:o("conversation.tool.arguments")}),(0,t.jsx)("pre",{children:d})]}),e.result&&(0,t.jsxs)("details",{className:"tool-detail-disclosure",open:"completed"!==e.state||void 0,children:[(0,t.jsx)("summary",{children:o(e.result.isError?"conversation.tool.errorOutput":"conversation.tool.result")}),(0,t.jsx)("pre",{children:p||o("conversation.tool.noOutput")})]})]})]}),("delegate_tasks"===e.toolName||"delegate_heroes"===e.toolName)&&e.runId&&(0,t.jsx)(rf,{parentRunId:e.runId,toolCallId:e.toolCallId}),(e.result?.artifacts.length??0)>0&&(0,t.jsx)("div",{className:"tool-artifact-results",children:e.result?.artifacts.map(e=>(0,t.jsx)(iL,{sessionId:n,artifact:e},e.artifactId))})]})}let rj=(0,n.memo)(function({sessionId:e,turn:n,active:a=!1,pendingApproval:s,resolvingApproval:i,decideApproval:r,answeringQuestion:l,answerQuestion:o,runStatus:c,activeLeafMessageId:d,branchDisabled:u,createBranch:p}){let h=s?n.steps.find(e=>"tool_batch"===e.kind&&s.items.some(t=>e.activities.some(e=>e.toolCallId===t.toolCallId)))?.id:void 0,m=n.steps.map(e=>e.kind).lastIndexOf("assistant"),f=n.steps.map(e=>e.kind).indexOf("assistant");return(0,t.jsxs)("article",{className:`conversation-turn ${a?"is-active":""}`,"data-turn-id":n.id,children:[n.user&&(0,t.jsxs)("div",{className:"user-row","data-message-id":n.user.sourceMessageId??n.user.id,children:[(0,t.jsx)("div",{className:"user-message",children:(0,t.jsx)(ig,{text:n.user.text,children:(0,t.jsx)(iu,{text:n.user.text})})}),(0,t.jsx)(th,{text:n.user.text,time:n.user.createdAt,branchMessageId:n.user.sourceMessageId!==d?n.user.sourceMessageId:void 0,branchDisabled:u,onBranch:p})]}),(0,t.jsxs)("div",{className:"agent-flow",children:[n.steps.map((a,l)=>{if("assistant"===a.kind)return(0,t.jsx)(im,{step:a,isFirst:l===f,isFinal:l===m,metrics:l===m?n.metrics:void 0,activeLeafMessageId:d,branchDisabled:u,createBranch:p},a.id);if("steer"===a.kind)return(0,t.jsxs)("div",{className:"steer-message",children:[(0,t.jsx)(tt,{size:14,"aria-hidden":"true"}),(0,t.jsx)("span",{children:a.text})]},a.id);let o=a.id===h;return(0,t.jsx)(rw,{sessionId:e,batch:a,isLast:l===n.steps.length-1,approval:o?s:null,resolving:i,decide:r},a.activities[0]?.toolCallId||a.id)}),s&&!h&&(0,t.jsx)(r_,{approval:s,resolving:i,decide:r,answering:l,answer:o}),c&&(0,t.jsx)(iI,{...c})]})]})}),rw=(0,n.memo)(function({sessionId:e,batch:a,isLast:s,approval:i,resolving:r,decide:l}){let o=(0,f.useT)(),c=(0,n.useId)(),[d,u]=(0,n.useState)(null),p=a.activities.length,h=a.activities.some(e=>"running"===e.state||"pending"===e.state),m=a.activities.filter(e=>"failed"===e.state||"rejected"===e.state).length,g=m>0||a.activities.some(e=>(e.result?.artifacts.length??0)>0||"delegate_tasks"===e.toolName||"delegate_heroes"===e.toolName),x=d??function({isLast:e,hasActive:t,hasApproval:n,hasOutcome:a}){return e||t||n||a}({isLast:s,hasActive:h,hasApproval:!!i,hasOutcome:g}),v=[...a.activities].reverse().find(e=>"running"===e.state||"pending"===e.state)??a.activities[a.activities.length-1],y=v?"running"===v.state||"pending"===v.state?o("conversation.toolBatch.running",{tool:v.toolName}):v.toolName:"";return(0,t.jsxs)("section",{className:"tool-batch","data-open":x||void 0,"aria-label":o(1===p?"conversation.toolBatch.ariaOne":"conversation.toolBatch.ariaMany",{count:p}),children:[(0,t.jsxs)("button",{type:"button",className:"tool-batch-summary","aria-expanded":x,"aria-controls":c,onClick:()=>u(!x),children:[(0,t.jsx)(j,{size:14,className:"tool-batch-chevron","aria-hidden":"true"}),(0,t.jsx)("span",{className:"tool-batch-title",children:1===p?o("conversation.toolBatch.titleOne"):o("conversation.toolBatch.titleMany",{count:String(p)})}),y&&(0,t.jsx)("span",{className:"tool-batch-now",children:y}),m>0&&(0,t.jsx)("span",{className:"tool-batch-failed",children:o("conversation.toolBatch.failed",{count:String(m)})})]}),(0,t.jsx)("div",{id:c,className:"tool-batch-body",hidden:!x,children:(0,t.jsx)("div",{className:"tool-activity-list",children:a.activities.map(n=>(0,t.jsx)(rk,{sessionId:e,activity:n},n.toolCallId))})}),i&&l&&(0,t.jsx)(tl,{approval:i,resolving:r??null,decide:l})]})});function r_({approval:e,resolving:n,decide:a,answering:s,answer:i}){let r=(0,f.useT)();if("question"===e.kind)return(0,t.jsx)(ib,{approval:e,submitting:!!s,answer:i??(()=>void 0)},e.id);if(!a)return null;let l=e.items.length;return(0,t.jsxs)("section",{className:"tool-batch pending-tool-batch","aria-label":r(1===l?"conversation.toolBatch.ariaOne":"conversation.toolBatch.ariaMany",{count:l}),children:[(0,t.jsxs)("div",{className:"tool-batch-heading",children:[(0,t.jsx)(tn,{size:14,"aria-hidden":"true"}),(0,t.jsx)("span",{children:1===l?r("conversation.toolBatch.pendingOne"):r("conversation.toolBatch.pendingMany",{count:String(l)})})]}),(0,t.jsx)(tl,{approval:e,resolving:n??null,decide:a})]})}function rN(e,t=12){return e?e.length<=t?e:`${e.slice(0,t)}…`:""}function rC(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KiB`:`${(e/1048576).toFixed(1)} MiB`}function rS({sessionId:e,nodes:n,pendingApproval:a,resolvingApproval:s,decideApproval:i,answeringQuestion:r,answerQuestion:l,runStatus:o,activeLeafMessageId:c,branchDisabled:d,createBranch:u}){let p=-1;for(let e=n.length-1;e>=0;e-=1)if("turn"===n[e].kind){p=e;break}return(0,t.jsxs)("div",{className:"conversation-list",children:[n.map((n,h)=>"checkpoint"===n.kind?(0,t.jsx)(rI,{node:n},n.id):(0,t.jsx)(rj,{sessionId:e,turn:n,active:h===p&&!!o?.active,pendingApproval:h===p?a:null,resolvingApproval:s,decideApproval:i,answeringQuestion:r,answerQuestion:l,branchDisabled:d,activeLeafMessageId:c,createBranch:u,runStatus:h===p?o:void 0},n.id)),p<0&&a&&(0,t.jsxs)("div",{className:"orphan-active-flow",children:[(0,t.jsx)(r_,{approval:a,resolving:s,decide:i,answering:r,answer:l}),o&&(0,t.jsx)(iI,{...o})]})]})}function rI({node:e}){let n=(0,f.useT)();return(0,t.jsxs)("div",{className:"checkpoint-separator","data-checkpoint-id":e.id,children:[(0,t.jsx)("span",{className:"checkpoint-line"}),(0,t.jsxs)("details",{children:[(0,t.jsxs)("summary",{children:[(0,t.jsx)(te,{size:14,"aria-hidden":"true"})," Context checkpoint",e.reclaimedTokens>0&&(0,t.jsxs)("span",{children:[e.reclaimedTokens.toLocaleString()," tokens reclaimed"]})]}),(0,t.jsx)("div",{children:e.summary}),(0,t.jsxs)("div",{className:"checkpoint-identity",children:[(0,t.jsx)("span",{children:`${n("checkpoint.promptVersion")}: ${e.promptVersion}`}),""!==e.summaryContractDigest&&(0,t.jsx)("span",{title:e.summaryContractDigest,children:`${n("checkpoint.contract")}: ${rN(e.summaryContractDigest,8)}`})]})]}),(0,t.jsx)("span",{className:"checkpoint-line"})]})}function rP(){let[e,t]=(0,n.useState)(!1),a=(0,n.useRef)(null);(0,n.useEffect)(()=>{if(!e)return;let n=e=>{a.current?.contains(e.target)||t(!1)};return document.addEventListener("pointerdown",n),()=>document.removeEventListener("pointerdown",n)},[e]);let s=(0,n.useCallback)(()=>t(e=>!e),[]);return{open:e,toggle:s,openDropdown:(0,n.useCallback)(()=>t(!0),[]),close:(0,n.useCallback)(()=>t(!1),[]),rootRef:a}}function rT(e,t){let n=e.replace(/\r\n/g,"\n").replace(/[ \t]+\n/g,"\n").replace(/\n{3,}/g,"\n\n").trim();if(!n)return null;let a=(n.length>4e3?`${n.slice(0,4e3).trimEnd()}…`:n).split("\n").map(e=>e.length>0?`> ${e}`:">").join("\n");return`${a}
1
+ (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,89163,e=>{e.v({empty:"ProjectMenu-module__rpY9Zq__empty",folder:"ProjectMenu-module__rpY9Zq__folder",name:"ProjectMenu-module__rpY9Zq__name",pin:"ProjectMenu-module__rpY9Zq__pin",row:"ProjectMenu-module__rpY9Zq__row",select:"ProjectMenu-module__rpY9Zq__select"})},81938,e=>{e.v({chevron:"ProjectSelector-module__RVW5Pa__chevron",folder:"ProjectSelector-module__RVW5Pa__folder",label:"ProjectSelector-module__RVW5Pa__label",root:"ProjectSelector-module__RVW5Pa__root",trigger:"ProjectSelector-module__RVW5Pa__trigger"})},54145,e=>{e.v({dot:"ChatRail-module__LizpSa__dot",marker:"ChatRail-module__LizpSa__marker",preview:"ChatRail-module__LizpSa__preview",previewIndex:"ChatRail-module__LizpSa__previewIndex",previewText:"ChatRail-module__LizpSa__previewText",rail:"ChatRail-module__LizpSa__rail",track:"ChatRail-module__LizpSa__track"})},2668,e=>{e.v({action:"SelectionActions-module__wrs5DG__action",toolbar:"SelectionActions-module__wrs5DG__toolbar"})},26568,(e,t,n)=>{"use strict";var a=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,s=/\n/g,i=/^\s*/,r=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,l=/^:\s*/,o=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,c=/^[;\s]*/,d=/^\s+|\s+$/g;function u(e){return e?e.replace(d,""):""}t.exports=function(e,t){if("string"!=typeof e)throw TypeError("First argument must be a string");if(!e)return[];t=t||{};var n=1,d=1;function p(e){var t=e.match(s);t&&(n+=t.length);var a=e.lastIndexOf("\n");d=~a?e.length-a:d+e.length}function h(){var e={line:n,column:d};return function(t){return t.position=new m(e),g(i),t}}function m(e){this.start=e,this.end={line:n,column:d},this.source=t.source}function f(a){var s=Error(t.source+":"+n+":"+d+": "+a);if(s.reason=a,s.filename=t.source,s.line=n,s.column=d,s.source=e,t.silent);else throw s}function g(t){var n=t.exec(e);if(n){var a=n[0];return p(a),e=e.slice(a.length),n}}function x(e){var t;for(e=e||[];t=v();)!1!==t&&e.push(t);return e}function v(){var t=h();if("/"==e.charAt(0)&&"*"==e.charAt(1)){for(var n=2;""!=e.charAt(n)&&("*"!=e.charAt(n)||"/"!=e.charAt(n+1));)++n;if(n+=2,""===e.charAt(n-1))return f("End of comment missing");var a=e.slice(2,n-2);return d+=2,p(a),e=e.slice(n),d+=2,t({type:"comment",comment:a})}}m.prototype.content=e,g(i);var y,b=[];for(x(b);y=function(){var e=h(),t=g(r);if(t){if(v(),!g(l))return f("property missing ':'");var n=g(o),s=e({type:"declaration",property:u(t[0].replace(a,"")),value:n?u(n[0].replace(a,"")):""});return g(c),s}}();)!1!==y&&(b.push(y),x(b));return b}},30070,(e,t,n)=>{"use strict";var a=e.e&&e.e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(n,"__esModule",{value:!0}),n.default=function(e,t){let n=null;if(!e||"string"!=typeof e)return n;let a=(0,s.default)(e),i="function"==typeof t;return a.forEach(e=>{if("declaration"!==e.type)return;let{property:a,value:s}=e;i?t(a,s,e):s&&((n=n||{})[a]=s)}),n};let s=a(e.r(26568))},65185,(e,t,n)=>{"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.camelCase=void 0;var a=/^--[a-zA-Z0-9_-]+$/,s=/-([a-z])/g,i=/^[^-]+$/,r=/^-(webkit|moz|ms|o|khtml)-/,l=/^-(ms)-/,o=function(e,t){return t.toUpperCase()},c=function(e,t){return"".concat(t,"-")};n.camelCase=function(e,t){var n;return(void 0===t&&(t={}),!(n=e)||i.test(n)||a.test(n))?e:(e=e.toLowerCase(),(e=t.reactCompat?e.replace(l,c):e.replace(r,c)).replace(s,o))}},15511,(e,t,n)=>{"use strict";var a=(e.e&&e.e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}})(e.r(30070)),s=e.r(65185);function i(e,t){var n={};return e&&"string"==typeof e&&(0,a.default)(e,function(e,a){e&&a&&(n[(0,s.camelCase)(e,t)]=a)}),n}i.default=i,t.exports=i},4100,(e,t,n)=>{"use strict";var a=Object.prototype.hasOwnProperty,s=Object.prototype.toString,i=Object.defineProperty,r=Object.getOwnPropertyDescriptor,l=function(e){return"function"==typeof Array.isArray?Array.isArray(e):"[object Array]"===s.call(e)},o=function(e){if(!e||"[object Object]"!==s.call(e))return!1;var t,n=a.call(e,"constructor"),i=e.constructor&&e.constructor.prototype&&a.call(e.constructor.prototype,"isPrototypeOf");if(e.constructor&&!n&&!i)return!1;for(t in e);return void 0===t||a.call(e,t)},c=function(e,t){i&&"__proto__"===t.name?i(e,t.name,{enumerable:!0,configurable:!0,value:t.newValue,writable:!0}):e[t.name]=t.newValue},d=function(e,t){if("__proto__"===t){if(!a.call(e,t))return;else if(r)return r(e,t).value}return e[t]};t.exports=function e(){var t,n,a,s,i,r,u=arguments[0],p=1,h=arguments.length,m=!1;for("boolean"==typeof u&&(m=u,u=arguments[1]||{},p=2),(null==u||"object"!=typeof u&&"function"!=typeof u)&&(u={});p<h;++p)if(t=arguments[p],null!=t)for(n in t)a=d(u,n),u!==(s=d(t,n))&&(m&&s&&(o(s)||(i=l(s)))?(i?(i=!1,r=a&&l(a)?a:[]):r=a&&o(a)?a:{},c(u,{name:n,newValue:e(m,r,s)})):void 0!==s&&c(u,{name:n,newValue:s}));return u}},8823,e=>{e.v({actions:"QuestionCard-module__TPAdWW__actions",answered:"QuestionCard-module__TPAdWW__answered",card:"QuestionCard-module__TPAdWW__card",header:"QuestionCard-module__TPAdWW__header",hint:"QuestionCard-module__TPAdWW__hint",icon:"QuestionCard-module__TPAdWW__icon",option:"QuestionCard-module__TPAdWW__option",options:"QuestionCard-module__TPAdWW__options",otherInput:"QuestionCard-module__TPAdWW__otherInput",question:"QuestionCard-module__TPAdWW__question",questions:"QuestionCard-module__TPAdWW__questions",submit:"QuestionCard-module__TPAdWW__submit"})},6929,e=>{e.v({badge:"primitives-module__BWnyvW__badge",badgeAccent:"primitives-module__BWnyvW__badgeAccent",badgeDanger:"primitives-module__BWnyvW__badgeDanger",badgeNeutral:"primitives-module__BWnyvW__badgeNeutral",badgeSuccess:"primitives-module__BWnyvW__badgeSuccess",badgeWarning:"primitives-module__BWnyvW__badgeWarning",banner:"primitives-module__BWnyvW__banner",bannerDanger:"primitives-module__BWnyvW__bannerDanger",bannerNeutral:"primitives-module__BWnyvW__bannerNeutral",bannerSuccess:"primitives-module__BWnyvW__bannerSuccess",bannerWarning:"primitives-module__BWnyvW__bannerWarning",button:"primitives-module__BWnyvW__button",card:"primitives-module__BWnyvW__card",cardElevated:"primitives-module__BWnyvW__cardElevated",cardPad:"primitives-module__BWnyvW__cardPad",danger:"primitives-module__BWnyvW__danger",emptyAction:"primitives-module__BWnyvW__emptyAction",emptyDescription:"primitives-module__BWnyvW__emptyDescription",emptyState:"primitives-module__BWnyvW__emptyState",emptyTitle:"primitives-module__BWnyvW__emptyTitle",ghost:"primitives-module__BWnyvW__ghost",iconButton:"primitives-module__BWnyvW__iconButton",iconButtonSm:"primitives-module__BWnyvW__iconButtonSm",md:"primitives-module__BWnyvW__md",primary:"primitives-module__BWnyvW__primary",secondary:"primitives-module__BWnyvW__secondary",sm:"primitives-module__BWnyvW__sm"})},86609,e=>{e.v({actions:"confirm-module__5IFLza__actions",description:"confirm-module__5IFLza__description",dialog:"confirm-module__5IFLza__dialog",overlay:"confirm-module__5IFLza__overlay",title:"confirm-module__5IFLza__title"})},51535,e=>{e.v({bar:"TabBar-module__VnsErG__bar",close:"TabBar-module__VnsErG__close",icon:"TabBar-module__VnsErG__icon",label:"TabBar-module__VnsErG__label",tab:"TabBar-module__VnsErG__tab"})},73574,e=>{e.v({backdrop:"RightPanelLanes-module__CJ4Bja__backdrop",body:"RightPanelLanes-module__CJ4Bja__body",inspector:"RightPanelLanes-module__CJ4Bja__inspector",lanes:"RightPanelLanes-module__CJ4Bja__lanes",narrow:"RightPanelLanes-module__CJ4Bja__narrow","nav-toggle":"RightPanelLanes-module__CJ4Bja__nav-toggle",primary:"RightPanelLanes-module__CJ4Bja__primary","primary-overlay":"RightPanelLanes-module__CJ4Bja__primary-overlay",strip:"RightPanelLanes-module__CJ4Bja__strip"})},57840,e=>{e.v({card:"GraphActivityPanel-module__1FpL5W__card",cardButton:"GraphActivityPanel-module__1FpL5W__cardButton",cardSummary:"GraphActivityPanel-module__1FpL5W__cardSummary",cardTitle:"GraphActivityPanel-module__1FpL5W__cardTitle",chevron:"GraphActivityPanel-module__1FpL5W__chevron",details:"GraphActivityPanel-module__1FpL5W__details",empty:"GraphActivityPanel-module__1FpL5W__empty",error:"GraphActivityPanel-module__1FpL5W__error",flowDot:"GraphActivityPanel-module__1FpL5W__flowDot",header:"GraphActivityPanel-module__1FpL5W__header",meta:"GraphActivityPanel-module__1FpL5W__meta",nodeDot:"GraphActivityPanel-module__1FpL5W__nodeDot",nodeList:"GraphActivityPanel-module__1FpL5W__nodeList",nodeName:"GraphActivityPanel-module__1FpL5W__nodeName",nodeRow:"GraphActivityPanel-module__1FpL5W__nodeRow",nodeState:"GraphActivityPanel-module__1FpL5W__nodeState",pulse:"GraphActivityPanel-module__1FpL5W__pulse",pulseDot:"GraphActivityPanel-module__1FpL5W__pulseDot",root:"GraphActivityPanel-module__1FpL5W__root",running:"GraphActivityPanel-module__1FpL5W__running",scroll:"GraphActivityPanel-module__1FpL5W__scroll",stateDot:"GraphActivityPanel-module__1FpL5W__stateDot",stateLine:"GraphActivityPanel-module__1FpL5W__stateLine",title:"GraphActivityPanel-module__1FpL5W__title"})},26694,e=>{e.v({badge:"RunInspectorPanel-module__lAUECa__badge",body:"RunInspectorPanel-module__lAUECa__body",catalogLabel:"RunInspectorPanel-module__lAUECa__catalogLabel",catalogRow:"RunInspectorPanel-module__lAUECa__catalogRow",catalogValue:"RunInspectorPanel-module__lAUECa__catalogValue",digest:"RunInspectorPanel-module__lAUECa__digest",digestGroup:"RunInspectorPanel-module__lAUECa__digestGroup",digestLabel:"RunInspectorPanel-module__lAUECa__digestLabel",digestLine:"RunInspectorPanel-module__lAUECa__digestLine",digestValue:"RunInspectorPanel-module__lAUECa__digestValue",empty:"RunInspectorPanel-module__lAUECa__empty",entryBlock:"RunInspectorPanel-module__lAUECa__entryBlock",entryLabel:"RunInspectorPanel-module__lAUECa__entryLabel",entryPre:"RunInspectorPanel-module__lAUECa__entryPre",entrySummary:"RunInspectorPanel-module__lAUECa__entrySummary",group:"RunInspectorPanel-module__lAUECa__group",heading:"RunInspectorPanel-module__lAUECa__heading",headingCount:"RunInspectorPanel-module__lAUECa__headingCount",loadOlder:"RunInspectorPanel-module__lAUECa__loadOlder",mcpBinding:"RunInspectorPanel-module__lAUECa__mcpBinding",mcpHead:"RunInspectorPanel-module__lAUECa__mcpHead",mcpIdentity:"RunInspectorPanel-module__lAUECa__mcpIdentity",mcpInstructions:"RunInspectorPanel-module__lAUECa__mcpInstructions",mcpInstructionsBody:"RunInspectorPanel-module__lAUECa__mcpInstructionsBody",mcpProtocol:"RunInspectorPanel-module__lAUECa__mcpProtocol",mcpRevision:"RunInspectorPanel-module__lAUECa__mcpRevision",mcpRow:"RunInspectorPanel-module__lAUECa__mcpRow",mcpTools:"RunInspectorPanel-module__lAUECa__mcpTools",mcpUnavailable:"RunInspectorPanel-module__lAUECa__mcpUnavailable",muted:"RunInspectorPanel-module__lAUECa__muted",privateBadge:"RunInspectorPanel-module__lAUECa__privateBadge",promptBytes:"RunInspectorPanel-module__lAUECa__promptBytes",promptPre:"RunInspectorPanel-module__lAUECa__promptPre",promptToggle:"RunInspectorPanel-module__lAUECa__promptToggle",runId:"RunInspectorPanel-module__lAUECa__runId",sectionBytes:"RunInspectorPanel-module__lAUECa__sectionBytes",sectionDigest:"RunInspectorPanel-module__lAUECa__sectionDigest",sectionId:"RunInspectorPanel-module__lAUECa__sectionId",sectionIdentity:"RunInspectorPanel-module__lAUECa__sectionIdentity",sectionKind:"RunInspectorPanel-module__lAUECa__sectionKind",sectionRow:"RunInspectorPanel-module__lAUECa__sectionRow",sectionSource:"RunInspectorPanel-module__lAUECa__sectionSource",selectedSkills:"RunInspectorPanel-module__lAUECa__selectedSkills",toolList:"RunInspectorPanel-module__lAUECa__toolList",toolName:"RunInspectorPanel-module__lAUECa__toolName",toolRisk:"RunInspectorPanel-module__lAUECa__toolRisk",toolRow:"RunInspectorPanel-module__lAUECa__toolRow",transcriptBody:"RunInspectorPanel-module__lAUECa__transcriptBody",transcriptExcerpt:"RunInspectorPanel-module__lAUECa__transcriptExcerpt",transcriptNote:"RunInspectorPanel-module__lAUECa__transcriptNote",transcriptOrdinal:"RunInspectorPanel-module__lAUECa__transcriptOrdinal",transcriptRole:"RunInspectorPanel-module__lAUECa__transcriptRole",transcriptRow:"RunInspectorPanel-module__lAUECa__transcriptRow",transcriptSummary:"RunInspectorPanel-module__lAUECa__transcriptSummary"})},67203,e=>{e.v({actionId:"PacksPanel-module__e1KI0q__actionId",actionList:"PacksPanel-module__e1KI0q__actionList",actionRow:"PacksPanel-module__e1KI0q__actionRow",actionVerb:"PacksPanel-module__e1KI0q__actionVerb",actions:"PacksPanel-module__e1KI0q__actions",badge:"PacksPanel-module__e1KI0q__badge",button:"PacksPanel-module__e1KI0q__button",card:"PacksPanel-module__e1KI0q__card",cardHead:"PacksPanel-module__e1KI0q__cardHead",cardName:"PacksPanel-module__e1KI0q__cardName",counts:"PacksPanel-module__e1KI0q__counts",digest:"PacksPanel-module__e1KI0q__digest",empty:"PacksPanel-module__e1KI0q__empty",heading:"PacksPanel-module__e1KI0q__heading",iconButton:"PacksPanel-module__e1KI0q__iconButton",identity:"PacksPanel-module__e1KI0q__identity",installer:"PacksPanel-module__e1KI0q__installer",issueList:"PacksPanel-module__e1KI0q__issueList",issueRow:"PacksPanel-module__e1KI0q__issueRow",meta:"PacksPanel-module__e1KI0q__meta",name:"PacksPanel-module__e1KI0q__name",note:"PacksPanel-module__e1KI0q__note",pathInput:"PacksPanel-module__e1KI0q__pathInput",pathLabel:"PacksPanel-module__e1KI0q__pathLabel",primary:"PacksPanel-module__e1KI0q__primary",row:"PacksPanel-module__e1KI0q__row",sectionCount:"PacksPanel-module__e1KI0q__sectionCount",sectionHeader:"PacksPanel-module__e1KI0q__sectionHeader",stack:"PacksPanel-module__e1KI0q__stack",titleRow:"PacksPanel-module__e1KI0q__titleRow"})},82399,e=>{e.v({accent:"McpPanels-module__e-NKfa__accent",actions:"McpPanels-module__e-NKfa__actions",addButton:"McpPanels-module__e-NKfa__addButton",archiveButton:"McpPanels-module__e-NKfa__archiveButton",bindings:"McpPanels-module__e-NKfa__bindings",boundBadge:"McpPanels-module__e-NKfa__boundBadge",candidateActions:"McpPanels-module__e-NKfa__candidateActions",candidateGroup:"McpPanels-module__e-NKfa__candidateGroup",candidateIdentity:"McpPanels-module__e-NKfa__candidateIdentity",candidateMeta:"McpPanels-module__e-NKfa__candidateMeta",candidateName:"McpPanels-module__e-NKfa__candidateName",candidateRow:"McpPanels-module__e-NKfa__candidateRow",candidateSource:"McpPanels-module__e-NKfa__candidateSource",card:"McpPanels-module__e-NKfa__card",cardHead:"McpPanels-module__e-NKfa__cardHead",cardIdentity:"McpPanels-module__e-NKfa__cardIdentity",cardMeta:"McpPanels-module__e-NKfa__cardMeta",cardTitle:"McpPanels-module__e-NKfa__cardTitle",catalogEmpty:"McpPanels-module__e-NKfa__catalogEmpty",catalogScroll:"McpPanels-module__e-NKfa__catalogScroll",catalogTable:"McpPanels-module__e-NKfa__catalogTable",commandSummary:"McpPanels-module__e-NKfa__commandSummary",createButton:"McpPanels-module__e-NKfa__createButton",credentialEnv:"McpPanels-module__e-NKfa__credentialEnv",credentialEnvInput:"McpPanels-module__e-NKfa__credentialEnvInput",credentialInputRow:"McpPanels-module__e-NKfa__credentialInputRow",credentialNote:"McpPanels-module__e-NKfa__credentialNote",credentialRef:"McpPanels-module__e-NKfa__credentialRef",credentialRefInput:"McpPanels-module__e-NKfa__credentialRefInput",credentialRow:"McpPanels-module__e-NKfa__credentialRow",credentials:"McpPanels-module__e-NKfa__credentials",danger:"McpPanels-module__e-NKfa__danger",diffBody:"McpPanels-module__e-NKfa__diffBody",diffCard:"McpPanels-module__e-NKfa__diffCard",diffDigest:"McpPanels-module__e-NKfa__diffDigest",diffLine:"McpPanels-module__e-NKfa__diffLine",diffTitle:"McpPanels-module__e-NKfa__diffTitle",diffUnchanged:"McpPanels-module__e-NKfa__diffUnchanged",emptyText:"McpPanels-module__e-NKfa__emptyText",enableButton:"McpPanels-module__e-NKfa__enableButton",field:"McpPanels-module__e-NKfa__field",form:"McpPanels-module__e-NKfa__form",formGrid:"McpPanels-module__e-NKfa__formGrid",ghostButton:"McpPanels-module__e-NKfa__ghostButton",input:"McpPanels-module__e-NKfa__input",list:"McpPanels-module__e-NKfa__list",loadingText:"McpPanels-module__e-NKfa__loadingText",requiredButton:"McpPanels-module__e-NKfa__requiredButton",sectionHeader:"McpPanels-module__e-NKfa__sectionHeader",settingsDescription:"McpPanels-module__e-NKfa__settingsDescription",settingsHeader:"McpPanels-module__e-NKfa__settingsHeader",settingsRoot:"McpPanels-module__e-NKfa__settingsRoot",settingsTitle:"McpPanels-module__e-NKfa__settingsTitle",toolCheckCell:"McpPanels-module__e-NKfa__toolCheckCell",toolCheckbox:"McpPanels-module__e-NKfa__toolCheckbox",toolDescriptionCell:"McpPanels-module__e-NKfa__toolDescriptionCell",toolNameCell:"McpPanels-module__e-NKfa__toolNameCell",toolRow:"McpPanels-module__e-NKfa__toolRow",toolSearch:"McpPanels-module__e-NKfa__toolSearch",toolsHeader:"McpPanels-module__e-NKfa__toolsHeader",toolsHint:"McpPanels-module__e-NKfa__toolsHint",transportButton:"McpPanels-module__e-NKfa__transportButton",transportRow:"McpPanels-module__e-NKfa__transportRow"})},90239,e=>{e.v({actionRow:"SkillPanels-module__k8YHlG__actionRow",badge:"SkillPanels-module__k8YHlG__badge",catalogName:"SkillPanels-module__k8YHlG__catalogName",catalogRow:"SkillPanels-module__k8YHlG__catalogRow",danger:"SkillPanels-module__k8YHlG__danger",diagList:"SkillPanels-module__k8YHlG__diagList",diagRow:"SkillPanels-module__k8YHlG__diagRow",diagTitle:"SkillPanels-module__k8YHlG__diagTitle",diagnostics:"SkillPanels-module__k8YHlG__diagnostics",empty:"SkillPanels-module__k8YHlG__empty",ghostButton:"SkillPanels-module__k8YHlG__ghostButton",input:"SkillPanels-module__k8YHlG__input",inputName:"SkillPanels-module__k8YHlG__inputName",inputPreset:"SkillPanels-module__k8YHlG__inputPreset",inputRow:"SkillPanels-module__k8YHlG__inputRow",inputScope:"SkillPanels-module__k8YHlG__inputScope",installButton:"SkillPanels-module__k8YHlG__installButton",installedActions:"SkillPanels-module__k8YHlG__installedActions",installedCard:"SkillPanels-module__k8YHlG__installedCard",installedDescription:"SkillPanels-module__k8YHlG__installedDescription",installedHead:"SkillPanels-module__k8YHlG__installedHead",installedIdentity:"SkillPanels-module__k8YHlG__installedIdentity",installedMeta:"SkillPanels-module__k8YHlG__installedMeta",installedName:"SkillPanels-module__k8YHlG__installedName",installedTitleRow:"SkillPanels-module__k8YHlG__installedTitleRow",link:"SkillPanels-module__k8YHlG__link",linkIcon:"SkillPanels-module__k8YHlG__linkIcon",market:"SkillPanels-module__k8YHlG__market",marketTitle:"SkillPanels-module__k8YHlG__marketTitle",mono:"SkillPanels-module__k8YHlG__mono",note:"SkillPanels-module__k8YHlG__note",primaryButton:"SkillPanels-module__k8YHlG__primaryButton",resultInstalls:"SkillPanels-module__k8YHlG__resultInstalls",resultPackage:"SkillPanels-module__k8YHlG__resultPackage",resultRow:"SkillPanels-module__k8YHlG__resultRow",rootForm:"SkillPanels-module__k8YHlG__rootForm",rootIdentity:"SkillPanels-module__k8YHlG__rootIdentity",rootName:"SkillPanels-module__k8YHlG__rootName",rootPath:"SkillPanels-module__k8YHlG__rootPath",rootPriority:"SkillPanels-module__k8YHlG__rootPriority",rootRow:"SkillPanels-module__k8YHlG__rootRow",rootTitleRow:"SkillPanels-module__k8YHlG__rootTitleRow",searchRow:"SkillPanels-module__k8YHlG__searchRow",sectionCount:"SkillPanels-module__k8YHlG__sectionCount",sectionHeader:"SkillPanels-module__k8YHlG__sectionHeader",stack:"SkillPanels-module__k8YHlG__stack",statusError:"SkillPanels-module__k8YHlG__statusError",statusText:"SkillPanels-module__k8YHlG__statusText",toggle:"SkillPanels-module__k8YHlG__toggle",updateBadge:"SkillPanels-module__k8YHlG__updateBadge",warning:"SkillPanels-module__k8YHlG__warning"})},48686,e=>{e.v({banner:"OfflineBanner-module__byd1va__banner"})},59665,e=>{"use strict";var t=e.i(18050),n=e.i(71645);let a=(...e)=>e.filter((e,t,n)=>!!e&&""!==e.trim()&&n.indexOf(e)===t).join(" ").trim(),s=e=>{let t=e.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,t,n)=>n?n.toUpperCase():t.toLowerCase());return t.charAt(0).toUpperCase()+t.slice(1)};var i={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};let r=(0,n.createContext)({}),l=(0,n.forwardRef)(({color:e,size:t,strokeWidth:s,absoluteStrokeWidth:l,className:o="",children:c,iconNode:d,...u},p)=>{let{size:h=24,strokeWidth:m=2,absoluteStrokeWidth:f=!1,color:g="currentColor",className:x=""}=(0,n.useContext)(r)??{},v=l??f?24*Number(s??m)/Number(t??h):s??m;return(0,n.createElement)("svg",{ref:p,...i,width:t??h??i.width,height:t??h??i.height,stroke:e??g,strokeWidth:v,className:a("lucide",x,o),...!c&&!(e=>{for(let t in e)if(t.startsWith("aria-")||"role"===t||"title"===t)return!0;return!1})(u)&&{"aria-hidden":"true"},...u},[...d.map(([e,t])=>(0,n.createElement)(e,t)),...Array.isArray(c)?c:[c]])}),o=(e,t)=>{let i=(0,n.forwardRef)(({className:i,...r},o)=>(0,n.createElement)(l,{ref:o,iconNode:t,className:a(`lucide-${s(e).replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}`,`lucide-${e}`,i),...r}));return i.displayName=s(e),i},c=o("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"}]]),d=o("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"}]]),u=o("search",[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]]),p=o("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"}]]),h=o("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"}]]),m=o("x",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);var f=e.i(27437);let g=o("panel-left",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}]]);function x({size:e=24}){return(0,t.jsxs)("svg",{width:e,height:e,viewBox:"0 0 32 32",fill:"none","aria-hidden":"true",focusable:"false",children:[(0,t.jsx)("rect",{x:"1",y:"1",width:"30",height:"30",rx:"9",fill:"currentColor",opacity:"0.10"}),(0,t.jsx)("path",{d:"M11 9.5h10.5M11 16h8M11 22.5h10.5M11 9.5v13",stroke:"currentColor",strokeWidth:"2.4",strokeLinecap:"round",strokeLinejoin:"round"})]})}function v(e){let{onToggleSidebar:n,onCloseNavigation:a}=e,s=(0,f.useT)();return(0,t.jsxs)("div",{className:"sidebar-logo-row",children:[(0,t.jsx)("div",{className:"sidebar-brand",children:(0,t.jsxs)("span",{className:"sidebar-brand-identity",children:[(0,t.jsx)("span",{className:"brand-mark",children:(0,t.jsx)(x,{size:20})}),(0,t.jsx)("span",{className:"sidebar-brand-name",children:"Ennote"})]})}),(0,t.jsx)("button",{type:"button",className:"sidebar-collapse-toggle",onClick:n,title:s("sidebar.collapse"),"aria-label":s("sidebar.collapseNav"),"aria-expanded":"true","aria-controls":"workspace-navigation",children:(0,t.jsx)(g,{size:16,"aria-hidden":"true"})}),(0,t.jsx)("button",{type:"button",className:"sidebar-close-nav navigation-close",onClick:a,"aria-label":s("sidebar.closeNav"),children:(0,t.jsx)(m,{size:15,"aria-hidden":"true"})})]})}let y=o("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"}]]);function b(e){let{disabled:n,onClick:a}=e,s=(0,f.useT)();return(0,t.jsxs)("button",{type:"button",className:"sidebar-new-session",disabled:n,onClick:a,"aria-label":s("sidebar.newChatAria"),title:s(n?"sidebar.selectProjectFirst":"sidebar.newChatAria"),children:[(0,t.jsx)(y,{size:15,"aria-hidden":"true"}),(0,t.jsx)("span",{children:s("sidebar.newChat")})]})}function k({active:e,label:n,icon:a,onClick:s}){return(0,t.jsxs)("button",{type:"button",className:`sidebar-nav-item ${e?"active":""}`,"aria-current":e?"page":void 0,onClick:s,children:[(0,t.jsx)("span",{className:"nav-icon",children:a}),(0,t.jsx)("span",{children:n})]})}let j=o("chevron-right",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]),w=o("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"}]]),N=o("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"}]]),_=o("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"}]]),C=o("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"}]]),S=o("plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]),I=o("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"}]]),P=o("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"}]]),T=null;function M(e,t,{id:a,dismissOnEscape:s=!0,restoreFocus:i=!0}={}){let r=(0,n.useId)(),l=a??r,o=(0,n.useRef)(t),c=(0,n.useRef)(!1);(0,n.useEffect)(()=>{o.current=t}),(0,n.useEffect)(()=>{var t;let n,a,r,d;if(!e)return;let u=document.activeElement instanceof HTMLElement?document.activeElement:null;c.current=i;let p=(null===T&&(t=window,n=[],a=!1,r=e=>{if("Escape"!==e.key||e.defaultPrevented||e.isComposing)return;let t=n[n.length-1];t&&!1!==t.dismissOnEscape&&(e.preventDefault(),t.onDismiss())},d=()=>{t&&a&&(t.removeEventListener("keydown",r),a=!1)},T={push(e){(n=n.filter(t=>t.id!==e.id)).push(e),t&&!a&&(t.addEventListener("keydown",r),a=!0);let s=!1;return()=>{s||(s=!0,0===(n=n.filter(t=>t!==e)).length&&d())}},dismissTop(e){let t=n[n.length-1];return!!t&&!1!==t.dismissOnEscape&&(e?.preventDefault(),t.onDismiss(),!0)},reset(){n=[],d()},size:()=>n.length}),T).push({id:l,dismissOnEscape:s,onDismiss:()=>o.current()});return()=>{p(),c.current&&u?.isConnected&&u.focus()}},[e,l,s,i])}var R=e.i(19172);function E({title:e,initialName:a,onCancel:s,onConfirm:i}){let[r,l]=(0,n.useState)(a),[o,c]=(0,n.useState)(!1),[d,u]=(0,n.useState)(null),p=(0,n.useRef)(null),h=(0,f.useT)();(0,n.useEffect)(()=>{p.current?.select()},[]);let m=r.trim(),g=o||""===m||m===a,x=async()=>{if(!g){c(!0),u(null);try{await i(m)}catch(e){u(e.message),c(!1)}}};return(0,t.jsx)("div",{className:"sb-dialog-overlay",onPointerDown:e=>{e.target!==e.currentTarget||o||s()},children:(0,t.jsxs)("div",{className:"sb-dialog",role:"dialog","aria-modal":"true","aria-label":e,children:[(0,t.jsx)("h3",{children:e}),(0,t.jsx)("input",{ref:p,className:"sb-dialog-input",value:r,disabled:o,onChange:e=>l(e.target.value),onKeyDown:e=>{"Enter"===e.key&&x(),"Escape"!==e.key||e.nativeEvent.isComposing||(e.stopPropagation(),s())}}),d&&(0,t.jsx)("div",{className:"sb-dialog-error",role:"alert",children:d}),(0,t.jsxs)("div",{className:"sb-dialog-actions",children:[(0,t.jsx)("button",{type:"button",onClick:s,disabled:o,children:h("sidebar.cancel")}),(0,t.jsx)("button",{type:"button",className:"sb-primary",onClick:x,disabled:g,children:h("sidebar.save")})]})]})})}let A=o("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"}]]),$=o("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 z(e){let t=new Map(e.map(e=>[e.id,{session:e,children:[]}])),n=[];for(let e of t.values()){let a=e.session.sourceSessionId;if(!a||!t.has(a)||function(e,t,n){let a=new Set([e]),s=t;for(;s;){if(a.has(s))return!0;a.add(s),s=n.get(s)?.session.sourceSessionId}return!1}(e.session.id,a,t)){n.push(e);continue}t.get(a).children.push(e)}let a=e=>{e.sort((e,t)=>t.session.updatedAt.localeCompare(e.session.updatedAt)),e.forEach(e=>a(e.children))};return a(n),n}function F(e,n,a,s,i,r,l,o,c,d){return e.flatMap(e=>{let u=e.session,p=u.id===n,h=d?.has(u.id);return[(0,t.jsx)(L,{session:u,view:s,isSelected:p,isRunning:h,depth:c,mutatingId:o,switchSession:a,archiveSession:i,restoreSession:r,renameSession:l},u.id),...F(e.children,n,a,s,i,r,l,o,c+1,d)]})}function L({session:e,view:a,isSelected:s,isRunning:i,depth:r,mutatingId:l,switchSession:o,archiveSession:c,restoreSession:d,renameSession:u}){var p;let h,[m,g]=(0,n.useState)(!1),[x,v]=(0,n.useState)(!1);M(m,()=>g(!1));let y=(0,n.useRef)(null),b=(0,f.useT)();return(0,n.useEffect)(()=>{if(!m)return;let e=e=>{y.current?.contains(e.target)||g(!1)};return document.addEventListener("pointerdown",e),()=>document.removeEventListener("pointerdown",e)},[m]),(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("li",{className:`sb-session-row${s?" sb-selected":""}${m?" sb-menu-open":""}`,style:{marginLeft:22*r},children:[(0,t.jsxs)("div",{className:"sb-session-body",role:"button",tabIndex:0,"aria-current":s?"page":void 0,"aria-label":(0,R.isBlankSession)(e)?b("sidebar.newSession"):e.title,onClick:()=>"active"===a&&o(e.id),onKeyDown:t=>{("Enter"===t.key||" "===t.key)&&"active"===a&&(t.preventDefault(),o(e.id))},children:[(0,t.jsx)("span",{className:"sb-row-slot sb-session-status",children:i&&(0,t.jsx)("span",{className:"sb-running-dot","aria-hidden":"true"})}),(0,t.jsx)("span",{className:"sb-session-title",children:(0,R.isBlankSession)(e)?b("sidebar.newSession"):e.title}),(0,t.jsx)("span",{className:"sb-session-time","aria-hidden":"true",children:(p=e.updatedAt,(h=Math.max(0,Date.now()-new Date(p).getTime()))<6e4?b("time.now"):h<36e5?`${Math.floor(h/6e4)}${b("time.minutes")}`:h<864e5?`${Math.floor(h/36e5)}${b("time.hours")}`:h<2592e6?`${Math.floor(h/864e5)}${b("time.days")}`:h<31536e6?`${Math.floor(h/2592e6)}${b("time.months")}`:`${Math.floor(h/31536e6)}${b("time.years")}`)})]}),(0,t.jsxs)("span",{className:"sb-row-actions",ref:y,children:[(0,t.jsx)("button",{type:"button",className:"sb-row-icon-btn","aria-label":`Actions for ${e.title}`,"aria-haspopup":"menu","aria-expanded":m,onClick:e=>{e.stopPropagation(),g(e=>!e)},children:(0,t.jsx)(_,{size:15,"aria-hidden":"true"})}),m&&(0,t.jsxs)("div",{className:"sb-row-menu",role:"menu",children:[(0,t.jsxs)("button",{type:"button",role:"menuitem",disabled:l===e.id||"archived"===a,onClick:e=>{e.stopPropagation(),g(!1),v(!0)},children:[(0,t.jsx)(C,{size:13,"aria-hidden":"true"})," ",b("sidebar.renameSession")]}),(0,t.jsxs)("button",{type:"button",role:"menuitem",disabled:l===e.id,onClick:t=>{t.stopPropagation(),g(!1),"active"===a?c(e):d(e)},children:["active"===a?(0,t.jsx)(A,{size:13,"aria-hidden":"true"}):(0,t.jsx)($,{size:13,"aria-hidden":"true"}),b("active"===a?"sidebar.archive":"sidebar.restore")]})]})]})]}),x&&(0,t.jsx)(E,{title:b("sidebar.renameSession"),initialName:e.title,onCancel:()=>v(!1),onConfirm:async t=>{await u(e,t),v(!1)}})]})}function D({group:e,isCurrent:a,isPinned:s,isCollapsed:i,onToggleCollapsed:r,onTogglePin:l,query:o,selectedSession:c,switchSession:d,archiveSession:u,restoreSession:p,renameSession:h,renameProject:m,deleteProject:g,createSessionIn:x,mutatingId:v,archived:y,onOpenArchived:b,runningSessionIds:k}){let[T,A]=(0,n.useState)(!1),[$,L]=(0,n.useState)(!1),[q,B]=(0,n.useState)(!1);M($,()=>L(!1));let[U,H]=(0,n.useState)(!1),W=(0,n.useRef)(null),V=(0,f.useT)();(0,n.useEffect)(()=>{if(!$)return;let e=e=>{W.current?.contains(e.target)||L(!1)};return document.addEventListener("pointerdown",e),()=>document.removeEventListener("pointerdown",e)},[$]);let K=o?e.sessions.filter(e=>!(0,R.isBlankSession)(e)&&e.title.toLowerCase().includes(o)):[...e.sessions.filter(e=>(0,R.isBlankSession)(e)&&e.id===c),...e.sessions.filter(e=>!(0,R.isBlankSession)(e))];return(0,t.jsxs)("div",{className:"sidebar-project-group",children:[(0,t.jsxs)("div",{role:"treeitem",tabIndex:0,"aria-expanded":!i,"aria-selected":a,className:`sb-project-row${$?" sb-menu-open":""}`,onClick:r,onKeyDown:e=>{("Enter"===e.key||" "===e.key)&&(e.preventDefault(),r())},title:e.projectName,children:[(0,t.jsx)("span",{className:`sb-row-slot sb-folder${a?" sb-folder-active":""}`,children:i?(0,t.jsx)(w,{size:15,"aria-hidden":"true"}):(0,t.jsx)(N,{size:15,"aria-hidden":"true"})}),(0,t.jsx)("span",{className:"sb-row-slot sb-chevron","data-expanded":!i||void 0,children:(0,t.jsx)(j,{size:14,"aria-hidden":"true"})}),(0,t.jsx)("span",{className:"sb-project-title",children:e.projectName}),(0,t.jsxs)("span",{className:"sb-row-actions",ref:W,children:[(0,t.jsx)("button",{type:"button",className:s?"sb-pin-star":"sb-pin-star is-unpinned",title:V(s?"sidebar.unpin":"sidebar.pin"),"aria-label":V(s?"sidebar.unpin":"sidebar.pin"),onClick:e=>{e.stopPropagation(),l()},children:(0,t.jsx)(I,{size:13,fill:s?"currentColor":"none","aria-hidden":"true"})}),(0,t.jsx)("button",{type:"button",className:"sb-row-icon-btn","aria-label":V("sidebar.newSession"),title:V("sidebar.newSession"),onClick:t=>{t.stopPropagation(),x(e.projectId)},children:(0,t.jsx)(S,{size:14,"aria-hidden":"true"})}),(0,t.jsx)("button",{type:"button",className:"sb-row-icon-btn","aria-label":V("sidebar.deleteProject"),"aria-haspopup":"menu","aria-expanded":$,onClick:e=>{e.stopPropagation(),L(e=>!e)},children:(0,t.jsx)(_,{size:15,"aria-hidden":"true"})}),$&&(0,t.jsxs)("div",{className:"sb-row-menu",role:"menu",children:[(0,t.jsxs)("button",{type:"button",role:"menuitem",onClick:e=>{e.stopPropagation(),L(!1),B(!0)},children:[(0,t.jsx)(C,{size:13,"aria-hidden":"true"})," ",V("sidebar.renameProject")]}),(0,t.jsxs)("button",{type:"button",role:"menuitem",className:"is-danger",onClick:e=>{e.stopPropagation(),L(!1),H(!0)},children:[(0,t.jsx)(P,{size:13,"aria-hidden":"true"})," ",V("sidebar.deleteProject")]})]})]})]}),!i&&(0,t.jsxs)("div",{className:"sb-project-children",children:[e.error&&(0,t.jsx)("div",{className:"sidebar-empty is-error",children:e.error}),e.loading&&0===K.length?(0,t.jsx)("div",{className:"sidebar-empty",children:V("sidebar.loading")}):0===K.length?(0,t.jsx)("div",{className:"sidebar-empty",role:"status",children:o?`${V("sidebar.noSessionsMatch")} "${o}"`:V("sidebar.noSessions")}):(0,t.jsx)("ul",{className:"session-list","aria-label":`Sessions in ${e.projectName}`,children:F(z(K),c,d,"active",u,p,h,v,0,k)}),(0,t.jsx)("button",{type:"button",className:"sidebar-archived-toggle","aria-expanded":T,onClick:()=>{let e=!T;A(e),e&&b()},children:V(T?"sidebar.hideArchived":"sidebar.showArchived")}),T&&y.length>0&&(0,t.jsx)("ul",{className:"session-list","aria-label":`Archived sessions in ${e.projectName}`,children:F(z(y),c,d,"archived",u,p,h,v,0,k)}),T&&0===y.length&&(0,t.jsx)("div",{className:"sidebar-empty",children:V("sidebar.noArchived")})]}),q&&(0,t.jsx)(E,{title:V("sidebar.renameProject"),initialName:e.projectName,onCancel:()=>B(!1),onConfirm:async t=>{await m(e.projectId,t),B(!1)}}),U&&(0,t.jsx)(O,{projectName:e.projectName,onCancel:()=>H(!1),onConfirm:async()=>{await g(e.projectId),H(!1)}})]})}function O({projectName:e,onCancel:a,onConfirm:s}){let[i,r]=(0,n.useState)(!1),[l,o]=(0,n.useState)(null),c=(0,f.useT)(),d=async()=>{r(!0),o(null);try{await s()}catch(e){o(e.message),r(!1)}};return(0,t.jsx)("div",{className:"sb-dialog-overlay",onPointerDown:e=>{e.target!==e.currentTarget||i||a()},children:(0,t.jsxs)("div",{className:"sb-dialog",role:"dialog","aria-modal":"true","aria-label":c("sidebar.deleteProject"),children:[(0,t.jsx)("h3",{children:c("sidebar.deleteProjectTitle",{name:e})}),(0,t.jsx)("p",{children:c("sidebar.deleteProjectBody")}),l&&(0,t.jsx)("div",{className:"sb-dialog-error",role:"alert",children:l}),(0,t.jsxs)("div",{className:"sb-dialog-actions",children:[(0,t.jsx)("button",{type:"button",onClick:a,disabled:i,children:c("sidebar.cancel")}),(0,t.jsx)("button",{type:"button",className:"sb-danger",onClick:d,disabled:i,children:c("sidebar.deleteProjectConfirm")})]})]})})}let q=o("chevron-down",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);var B=e.i(89163);function U(e){let{projects:n,selectedProject:a,pinnedProjectIds:s,togglePinProject:i,onSelect:r,className:l}=e,o=(0,f.useT)();return(0,t.jsxs)("div",{role:"menu","aria-label":"Projects",className:`project-menu ${l??""}`,children:[0===n.length&&(0,t.jsx)("div",{className:B.default.empty,children:o("sidebar.noProjects")}),n.map(e=>(0,t.jsxs)("div",{className:B.default.row,children:[(0,t.jsxs)("button",{type:"button",onClick:()=>r(e.id),className:B.default.select,"data-selected":e.id===a||void 0,children:[(0,t.jsx)(w,{size:14,"aria-hidden":"true",className:B.default.folder}),(0,t.jsx)("span",{className:B.default.name,children:e.name})]}),(0,t.jsx)("button",{type:"button",title:`${s.includes(e.id)?o("sidebar.unpin"):o("sidebar.pin")} ${e.name}`,"aria-label":s.includes(e.id)?o("sidebar.unpin"):o("sidebar.pin"),onClick:()=>i(e.id),className:B.default.pin,"data-pinned":s.includes(e.id)||void 0,children:(0,t.jsx)(I,{size:13,fill:s.includes(e.id)?"currentColor":"none","aria-hidden":"true"})})]},e.id))]})}var H=e.i(81938);function W(e){let{projects:n,selectedProject:a,pinnedProjectIds:s,togglePinProject:i,onSelect:r,control:l}=e,{open:o,toggle:c,close:d,rootRef:u}=l,p=(0,f.useT)();return M(o,d),(0,t.jsxs)("div",{ref:u,className:`sidebar-project-selector ${H.default.root}`,children:[(0,t.jsxs)("button",{type:"button",onClick:c,className:H.default.trigger,"data-selected":!!a||void 0,title:a?n.find(e=>e.id===a)?.name??p("sidebar.selectProject"):p("sidebar.selectProject"),"aria-haspopup":"menu","aria-expanded":o,children:[(0,t.jsx)(w,{size:14,"aria-hidden":"true",className:H.default.folder}),(0,t.jsx)("span",{className:H.default.label,children:a?n.find(e=>e.id===a)?.name??p("sidebar.unknown"):p("sidebar.selectProjectEllipsis")}),(0,t.jsx)(q,{size:12,"aria-hidden":"true",className:H.default.chevron,"data-open":o||void 0})]}),o&&(0,t.jsx)(U,{projects:n,selectedProject:a,pinnedProjectIds:s,togglePinProject:i,onSelect:e=>{r(e),d()},className:"sidebar-project-menu"})]})}function V({projects:e,groups:a,selectedProject:s,selectedSession:i,settingsOpen:r,query:l,setQuery:o,mutatingId:g,announcement:x,pinnedProjectIds:y,togglePinProject:j,renameProject:w,deleteProject:N,renameSession:_,createSessionIn:C,collapsed:S,toggleCollapsed:I,archived:P,openArchived:T,createProject:M,createSession:R,switchProject:E,switchSession:A,archiveSession:$,restoreSession:z,openSettings:F,closeNavigation:L,runningSessionIds:O,onToggleSidebar:q,projectSelector:B,view:U,setView:H}){let K=(0,f.useT)(),G=(0,n.useRef)(null),J=(0,n.useRef)(null),Y=(0,n.useRef)(void 0),[Q,Z]=(0,n.useState)(!1),[X,ee]=(0,n.useState)(!1);(0,n.useEffect)(()=>{Q&&G.current?.focus({preventScroll:!0})},[Q]);let et=(0,n.useCallback)(()=>{void 0!==Y.current&&(window.clearTimeout(Y.current),Y.current=void 0)},[]),en=(0,n.useCallback)(()=>{void 0===Y.current&&(Y.current=window.setTimeout(()=>{Y.current=void 0,ee(!1)},2e3))},[]);(0,n.useEffect)(()=>{if(!X)return;let e=e=>{let t=J.current?.getBoundingClientRect();t&&(e.clientX>=t.left&&e.clientX<t.right&&e.clientY>=t.top&&e.clientY<t.bottom?et():en())};return document.addEventListener("pointermove",e),()=>{document.removeEventListener("pointermove",e),et()}},[X,et,en]),(0,n.useEffect)(()=>()=>et(),[et]);let ea=()=>{o(""),Z(!1)};return(0,t.jsxs)("aside",{ref:J,className:`sidebar${X?"":" quiet-bars"}`,"aria-label":K("sidebar.aria"),onPointerEnter:()=>{et(),ee(!0)},onPointerLeave:()=>{en()},children:[(0,t.jsx)(v,{onToggleSidebar:q,onCloseNavigation:L}),(0,t.jsx)(b,{disabled:!s,onClick:R}),(0,t.jsxs)("nav",{className:"sidebar-nav","aria-label":"Workspace",children:[(0,t.jsx)(k,{active:"heroes"===U,label:K("sidebar.heroes"),icon:(0,t.jsx)(c,{size:16}),onClick:()=>H("heroes")}),(0,t.jsx)(k,{active:"graphs"===U,label:K("sidebar.graphs"),icon:(0,t.jsx)(h,{size:16}),onClick:()=>H("graphs")})]}),(0,t.jsxs)("div",{className:`sidebar-workspace-head${Q?" search-expanded":""}`,children:[(0,t.jsx)("span",{className:"workspace-label",children:K("sidebar.workspaces")}),(0,t.jsx)("div",{className:"workspace-search-slot",children:(0,t.jsxs)("div",{className:"workspace-search",children:[(0,t.jsx)("button",{type:"button",className:"workspace-action-button workspace-search-button","aria-label":K("sidebar.searchSessions"),"aria-expanded":Q,title:Q?void 0:K("sidebar.searchSessions"),onClick:()=>Z(!0),children:(0,t.jsx)(u,{size:Q?11:14,"aria-hidden":"true"})}),(0,t.jsx)("input",{ref:G,type:"text",value:l,tabIndex:Q?0:-1,placeholder:K("sidebar.searchSessions"),"aria-label":K("sidebar.searchSessions"),onChange:e=>o(e.target.value),onKeyDown:e=>{"Escape"!==e.key||e.nativeEvent.isComposing||(e.preventDefault(),e.stopPropagation(),ea())}}),Q&&(0,t.jsx)("button",{type:"button",className:"workspace-search-clear","aria-label":K("sidebar.clearSearch"),onClick:ea,children:(0,t.jsx)(m,{size:13,"aria-hidden":"true"})})]})}),(0,t.jsx)("div",{className:"workspace-head-actions",children:(0,t.jsx)("button",{type:"button",className:"workspace-action-button","aria-label":K("sidebar.addWorkspace"),title:K("sidebar.addWorkspace"),onClick:M,children:(0,t.jsx)(d,{size:16,"aria-hidden":"true"})})})]}),(0,t.jsx)(W,{projects:e,selectedProject:s,pinnedProjectIds:y,togglePinProject:j,onSelect:E,control:B}),s&&(0,t.jsx)("section",{className:"sidebar-sessions","aria-label":K("sidebar.sessions"),children:(0,t.jsxs)("div",{className:"sidebar-tree-body",children:[(0,t.jsx)("div",{className:"sidebar-session-list",children:0===a.length?(0,t.jsx)("div",{className:"sidebar-empty",children:K("sidebar.loadingSessions")}):a.map(e=>(0,t.jsx)(D,{group:e,isCurrent:e.projectId===s,isPinned:y.includes(e.projectId),isCollapsed:S.has(e.projectId),onToggleCollapsed:()=>I(e.projectId),onTogglePin:()=>j(e.projectId),query:l.trim(),selectedSession:i,switchSession:A,archiveSession:$,restoreSession:z,renameSession:_,renameProject:w,deleteProject:N,createSessionIn:C,mutatingId:g,archived:P[e.projectId]??[],onOpenArchived:()=>T(e.projectId),runningSessionIds:O},e.projectId))}),(0,t.jsx)("div",{className:"sidebar-list-fade","aria-hidden":"true"})]})}),!s&&(0,t.jsx)("div",{className:"sidebar-empty-project",children:(0,t.jsx)("div",{children:K("sidebar.chooseProject")})}),(0,t.jsx)("span",{className:"sr-only",role:"status","aria-live":"polite",children:x}),(0,t.jsx)("div",{className:"sidebar-settings",children:(0,t.jsxs)("button",{type:"button",className:`sidebar-settings-trigger${r?" active":""}`,onClick:()=>F(),"aria-haspopup":"dialog","aria-expanded":r,children:[(0,t.jsx)(p,{size:16,"aria-hidden":"true"}),(0,t.jsx)("span",{children:K("sidebar.settings")})]})})]})}let K=o("arrow-down",[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]]);var G=e.i(54145);function J({nodes:e,scrollContainer:a}){let s=(0,f.useT)(),i=(0,n.useMemo)(()=>e.filter(e=>"turn"===e.kind).map((e,t)=>({id:e.id,index:t,text:(e.user?.text??"").replace(/\s+/g," ").trim()})),[e]),[r,l]=(0,n.useState)(0),[o,c]=(0,n.useState)(null),d=(0,n.useRef)(null),u=(e,t)=>e.querySelector(`[data-turn-id="${CSS.escape(t.id)}"]`);if((0,n.useEffect)(()=>{let e=a.current;if(!e)return;let t=()=>{null===d.current&&(d.current=window.requestAnimationFrame(()=>{d.current=null,(()=>{if(0===i.length)return;let t=e.scrollTop+.3*e.clientHeight,n=0,a=1/0,s=e.getBoundingClientRect().top;for(let r of i){let i=u(e,r);if(!i)continue;let l=Math.abs(i.getBoundingClientRect().top-s+e.scrollTop-t);l<a&&(a=l,n=r.index)}l(n)})()}))};e.addEventListener("scroll",t,{passive:!0});let n=new ResizeObserver(t);return n.observe(e),t(),()=>{e.removeEventListener("scroll",t),n.disconnect(),null!==d.current&&window.cancelAnimationFrame(d.current),d.current=null}},[a,i]),i.length<2)return null;let p=e=>e.text||s("conversation.rail.turn",{index:String(e.index+1)});return(0,t.jsxs)("nav",{className:G.default.rail,"aria-label":s("conversation.rail.aria"),children:[(0,t.jsx)("span",{className:G.default.track,"aria-hidden":"true"}),i.map(e=>{let n=(e.index+.5)/i.length*100,o=p(e),d=r===e.index;return(0,t.jsx)("button",{type:"button",className:G.default.marker,style:{top:`${n}%`},"data-active":d||void 0,"aria-current":d?"true":void 0,"aria-label":s("conversation.rail.goTo",{index:String(e.index+1),label:o}),onClick:()=>(e=>{let t=a.current;if(!t)return;let n=u(t,e);if(!n)return;let s=n.getBoundingClientRect().top-t.getBoundingClientRect().top+t.scrollTop-12;t.scrollTo({top:Math.max(0,s),behavior:"smooth"}),l(e.index)})(e),onMouseEnter:()=>c(e.index),onMouseLeave:()=>c(t=>t===e.index?null:t),onFocus:()=>c(e.index),onBlur:()=>c(t=>t===e.index?null:t),children:(0,t.jsx)("span",{className:G.default.dot,"aria-hidden":"true"})},e.id)}),null!==o&&i[o]&&(0,t.jsxs)("div",{className:G.default.preview,style:{top:`${(o+.5)/i.length*100}%`},role:"tooltip",children:[(0,t.jsx)("span",{className:G.default.previewIndex,children:String(o+1).padStart(2,"0")}),(0,t.jsx)("span",{className:G.default.previewText,children:p(i[o])})]})]})}let Y=o("check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]),Q=o("copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]),Z=o("message-square-quote",[["path",{d:"M14 14a2 2 0 0 0 2-2V8h-2",key:"1r06pg"}],["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:"M8 14a2 2 0 0 0 2-2V8H8",key:"1jzu5j"}]]),X=o("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"}]]);var ee=e.i(2668);function et({selection:e,onQuote:a,onExplain:s,onDismiss:i}){let r=(0,f.useT)(),[l,o]=(0,n.useState)(!1),c=(0,n.useRef)(null);M(!0,i);let d=(0,n.useCallback)(()=>{navigator.clipboard?.writeText(e.text).then(()=>{o(!0),null!==c.current&&window.clearTimeout(c.current),c.current=window.setTimeout(()=>o(!1),1e3)}).catch(()=>{})},[e.text]),u=e.rect.top>56,p=Math.min(window.innerWidth-150,Math.max(150,e.rect.left+e.rect.width/2));return(0,t.jsxs)("div",{className:ee.default.toolbar,"data-placement":u?"above":"below",role:"toolbar","aria-label":r("selection.aria"),style:{left:p,top:u?e.rect.top-8:e.rect.bottom+8},onPointerDown:e=>e.preventDefault(),children:[(0,t.jsxs)("button",{type:"button",className:ee.default.action,onClick:()=>a(e.text),children:[(0,t.jsx)(Z,{size:14,"aria-hidden":"true"}),r("selection.quote")]}),(0,t.jsxs)("button",{type:"button",className:ee.default.action,onClick:d,children:[l?(0,t.jsx)(Y,{size:14,"aria-hidden":"true"}):(0,t.jsx)(Q,{size:14,"aria-hidden":"true"}),r(l?"selection.copied":"selection.copy")]}),(0,t.jsxs)("button",{type:"button",className:ee.default.action,onClick:()=>s(e.text),children:[(0,t.jsx)(X,{size:14,"aria-hidden":"true"}),r("selection.explain")]})]})}let en=o("arrow-up",[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]]),ea=o("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"}]]),es=o("file-spreadsheet",[["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:"M8 13h2",key:"yr2amv"}],["path",{d:"M14 13h2",key:"un5t4a"}],["path",{d:"M8 17h2",key:"2yhykz"}],["path",{d:"M14 17h2",key:"10kma7"}]]),ei=o("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"}]]),er=o("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"}]]),el=o("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"}]]),eo=o("presentation",[["path",{d:"M2 3h20",key:"91anmk"}],["path",{d:"M21 3v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V3",key:"2k9sn8"}],["path",{d:"m7 21 5-5 5 5",key:"bip4we"}]]),ec=o("square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]),ed="ennote-picker-collapsed";function eu(){try{let e=JSON.parse(localStorage.getItem(ed)??"{}");return"object"==typeof e&&null!==e?e:{}}catch{return{}}}let ep=(0,n.forwardRef)(function({open:e,sections:a,filter:s,showFilter:i=!1,activeKey:r,ariaLabel:l,onFilterChange:o,onPick:c,onClose:d},p){let h=(0,f.useT)(),[m,g]=(0,n.useState)(eu),[x,v]=(0,n.useState)(0),y=(0,n.useRef)(null),b=(0,n.useRef)(null),k=(0,n.useRef)(null),w=(0,n.useMemo)(()=>{let e=s.trim().toLowerCase();return a.map(t=>{if(t.pinned)return{...t,total:t.items.length};let n=m[t.key]??t.readOnly??!1,a=e?t.items.filter(t=>`${t.label} ${t.hint??""} ${t.description??""}`.toLowerCase().includes(e)):t.items;return{...t,items:n?[]:a,total:a.length}}).filter(e=>e.pinned||e.items.length>0||e.readOnly)},[a,m,s]),N=(0,n.useMemo)(()=>w.flatMap(e=>e.items.filter(t=>!e.pinned&&!e.readOnly&&!t.disabled).map(t=>({item:t,section:e}))),[w]),_=`${s}\u0000${e}`,[C,S]=(0,n.useState)(_);C!==_&&(S(_),v(0)),(0,n.useEffect)(()=>{e&&(i?k.current?.focus():y.current?.querySelector("[data-picker-item][data-active='true']")?.scrollIntoView({block:"nearest"}))},[e,i,x]),M(e,d),(0,n.useEffect)(()=>{if(!e)return;let t=e=>{e.target instanceof Node&&y.current?.contains(e.target)===!0||d()};return document.addEventListener("pointerdown",t),()=>document.removeEventListener("pointerdown",t)},[e,d]);let I=(0,n.useCallback)((e,t)=>{g(n=>{let a={...n,[e]:!t};try{localStorage.setItem(ed,JSON.stringify(a))}catch{}return a})},[]);if((0,n.useImperativeHandle)(p,()=>({move:e=>v(t=>{let n=t+e;return n<0?0:Math.min(n,Math.max(N.length-1,0))}),pickActive:()=>{let e=N[Math.min(x,Math.max(N.length-1,0))];return!!e&&(c(e.item,e.section),!0)}}),[N,x,c]),!e)return null;let P=w.some(e=>!e.pinned&&e.items.length>0);return i||!(s.trim().length>0)||P?(0,t.jsxs)("div",{ref:y,className:"composer-picker",role:"dialog","aria-label":l,onKeyDown:e=>{if("ArrowDown"===e.key){e.preventDefault(),v(e=>Math.min(e+1,Math.max(N.length-1,0)));return}if("ArrowUp"===e.key){e.preventDefault(),v(e=>Math.max(e-1,0));return}if("Enter"===e.key){let t=N[x];if(!t)return;e.preventDefault(),c(t.item,t.section);return}"Escape"===e.key&&(e.preventDefault(),e.stopPropagation(),d())},children:[i&&(0,t.jsxs)("label",{className:"composer-picker-filter",children:[(0,t.jsx)(u,{size:13,"aria-hidden":"true"}),(0,t.jsx)("input",{ref:k,value:s,placeholder:h("picker.filter"),"aria-label":h("picker.filter"),onChange:e=>o?.(e.target.value)})]}),(0,t.jsxs)("div",{ref:b,className:"composer-picker-body",role:"listbox","aria-label":h("picker.list"),"aria-activedescendant":N[x]?`picker-${N[x].item.key}`:void 0,children:[w.map(e=>{let n=m[e.key]??e.readOnly??!1,a=!e.pinned;return(0,t.jsxs)("section",{className:"composer-picker-group",role:"group","aria-label":e.label,children:[(0,t.jsxs)("button",{type:"button",className:"composer-picker-group-head","aria-expanded":a?!n:void 0,disabled:!a,onClick:()=>a&&I(e.key,n),onKeyDown:t=>{("Enter"===t.key||" "===t.key)&&(t.preventDefault(),t.stopPropagation(),a&&I(e.key,n))},title:a?h(n?"picker.expand":"picker.collapse"):void 0,children:[a?n?(0,t.jsx)(j,{size:12,"aria-hidden":"true"}):(0,t.jsx)(q,{size:12,"aria-hidden":"true"}):(0,t.jsx)("span",{className:"composer-picker-group-dot","aria-hidden":"true"}),(0,t.jsx)("span",{children:e.label}),(0,t.jsx)("span",{className:"composer-picker-group-count",children:e.total}),e.readOnly&&(0,t.jsx)("span",{className:"composer-picker-group-tag",children:h("picker.readOnly")})]}),e.items.map(n=>{let a=!e.readOnly&&N[x]?.item.key===n.key;return(0,t.jsxs)("button",{id:`picker-${n.key}`,type:"button",role:"option","data-picker-item":!0,"data-active":a||void 0,"aria-selected":a,"aria-disabled":e.readOnly||n.disabled||void 0,className:`composer-picker-item${a?" active":""}${e.pinned?" is-action":""}`,onClick:()=>{e.readOnly||n.disabled||c(n,e)},children:[(0,t.jsx)("span",{className:"composer-picker-item-icon","aria-hidden":"true",children:n.icon}),(0,t.jsxs)("span",{className:"composer-picker-item-copy",children:[(0,t.jsx)("span",{className:"composer-picker-item-label",children:n.label}),n.description&&(0,t.jsx)("span",{className:"composer-picker-item-desc",children:n.description})]}),n.hint&&(0,t.jsx)("span",{className:"composer-picker-item-hint",children:n.hint})]},n.key)})]},e.key)}),0===N.length&&(0,t.jsx)("div",{className:"composer-picker-empty",children:h("picker.empty")})]}),(0,t.jsx)("span",{className:"sr-only","aria-live":"polite",children:r??N[x]?.item.label??""})]}):null});function eh({hero:e,graph:n,skills:a,onClearHero:s,onClearGraph:i,onRemoveSkill:r}){let l=(0,f.useT)();return e||n||0!==a.length?(0,t.jsxs)("div",{className:"composer-target-pills","aria-label":l("composer.targets"),children:[e&&(0,t.jsxs)("span",{className:"composer-pill is-hero",children:[(0,t.jsx)(c,{size:12,"aria-hidden":"true"}),(0,t.jsxs)("span",{className:"composer-pill-label",children:["@",e.handle]}),(0,t.jsx)("button",{type:"button","aria-label":`${l("composer.removeHero")} ${e.name}`,onClick:s,children:(0,t.jsx)(m,{size:10,"aria-hidden":"true"})})]}),n&&(0,t.jsxs)("span",{className:"composer-pill is-graph",children:[(0,t.jsx)(h,{size:12,"aria-hidden":"true"}),(0,t.jsxs)("span",{className:"composer-pill-label",children:[n.name,n.version?`@${n.version}`:""]}),(0,t.jsx)("button",{type:"button","aria-label":`${l("composer.removeGraph")} ${n.name}`,onClick:i,children:(0,t.jsx)(m,{size:10,"aria-hidden":"true"})})]}),a.map(e=>(0,t.jsxs)("span",{className:"composer-pill is-skill",children:[(0,t.jsx)(X,{size:12,"aria-hidden":"true"}),(0,t.jsxs)("span",{className:"composer-pill-label",children:["/",e.label]}),(0,t.jsx)("button",{type:"button","aria-label":`${l("composer.removeSkill")} ${e.label}`,onClick:()=>r(e.id),children:(0,t.jsx)(m,{size:10,"aria-hidden":"true"})})]},e.id))]}):null}let em=["discuss","ask","auto"],ef="M8.20554 0.899994L14.7901 3.36857V7.01026C14.7901 12 11.0466 14.2103 8.20554 15.3C5.36446 14.2103 1.62012 12 1.62012 7.01026V3.36857L8.20554 0.899994Z";function eg({mode:e}){return"ask"===e?(0,t.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none","aria-hidden":!0,children:[(0,t.jsx)("path",{d:"M8.08887 0.251709C8.20479 0.23085 8.32486 0.241168 8.43652 0.282959L15.0215 2.75171C15.2787 2.84819 15.4492 3.09414 15.4492 3.3689V7.0105C15.4492 7.10986 15.4441 7.2081 15.4414 7.30542C15.0285 7.07175 14.5905 6.87695 14.1309 6.73022V3.82495L8.20508 1.60327L2.2793 3.82495V7.0105C2.27936 9.7171 3.4745 11.5379 5.02734 12.7947C5.01025 12.9942 5 13.1962 5 13.4001C5.00001 13.7617 5.02722 14.1169 5.08008 14.4636C2.91555 13.0393 0.961014 10.752 0.960938 7.0105V3.3689C0.960938 3.09417 1.13146 2.84821 1.38867 2.75171L7.97461 0.282959L8.08887 0.251709Z",fill:"currentColor"}),(0,t.jsx)("path",{d:"M11.3525 5.64688V6.85688H5V5.64688H11.3525Z",fill:"currentColor"}),(0,t.jsx)("path",{d:"M9.5824 8.29376V9.50376H5V8.29376H9.5824Z",fill:"currentColor"})]}):"auto"===e?(0,t.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none","aria-hidden":!0,children:[(0,t.jsx)("path",{d:ef,stroke:"currentColor",strokeWidth:"1.31831",strokeLinejoin:"round"}),(0,t.jsx)("path",{d:"M9.10094 4.5V8.75939H7.59888V4.5H9.10094Z",fill:"currentColor"}),(0,t.jsx)("path",{d:"M9.10094 9.8114V11.5H7.59888V9.8114H9.10094Z",fill:"currentColor"})]}):(0,t.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none","aria-hidden":!0,children:[(0,t.jsx)("path",{d:ef,stroke:"currentColor",strokeWidth:"1.31831",strokeLinejoin:"round"}),(0,t.jsx)("path",{d:"M12.1654 5.7552L8.9447 9.41475C8.73044 9.65816 8.53628 9.8804 8.35774 10.0423C8.1713 10.2114 7.94235 10.3717 7.64016 10.4254C7.48207 10.4535 7.32 10.4552 7.16151 10.4294C6.85843 10.3801 6.62728 10.2223 6.43836 10.0559C6.25752 9.89653 6.06037 9.67732 5.84264 9.43705L4.72925 8.20897L5.63557 7.38707L6.74897 8.61594C6.98603 8.87755 7.12974 9.03533 7.24673 9.13839C7.31033 9.19443 7.34485 9.21476 7.35823 9.22122C7.38068 9.22484 7.40352 9.22515 7.42593 9.22122C7.40522 9.22502 7.42893 9.23294 7.53583 9.136C7.65132 9.03126 7.79316 8.87139 8.02643 8.60638L11.2479 4.94763L12.1654 5.7552Z",fill:"currentColor"})]})}function ex(e,t){return t(`permission.${e}`)}function ev({permissionMode:e,permissionReady:a,setPermissionMode:s,disabled:i,frozen:r=!1}){let l=(0,f.useT)(),[o,c]=(0,n.useState)(!1),d=(0,n.useRef)(null),u=(0,n.useRef)(null),p=(0,n.useRef)(null),h=(0,n.useId)(),m=i||!a,g=o&&!m;return M(g,()=>c(!1)),(0,n.useEffect)(()=>{if(!g)return;let e=e=>{d.current?.contains(e.target)||c(!1)},t=e=>{if("ArrowDown"!==e.key&&"ArrowUp"!==e.key)return;e.preventDefault();let t=Array.from(p.current?.querySelectorAll('[role="menuitemradio"]')??[]);if(0===t.length)return;let n=(Math.max(t.indexOf(document.activeElement),0)+("ArrowDown"===e.key?1:-1)+t.length)%t.length;t[n]?.focus()};return document.addEventListener("mousedown",e),document.addEventListener("keydown",t),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("keydown",t)}},[g]),(0,n.useEffect)(()=>{if(!g)return;let e=window.requestAnimationFrame(()=>{let e=p.current?.querySelector('[aria-checked="true"]'),t=p.current?.querySelector('[role="menuitemradio"]');(e??t)?.focus()});return()=>window.cancelAnimationFrame(e)},[g]),(0,t.jsxs)("div",{ref:d,className:"permission-chip",children:[(0,t.jsxs)("button",{ref:u,type:"button",className:"permission-chip-trigger","aria-label":`${l("composer.permissionMode")}: ${ex(e,l)}`,"aria-haspopup":"menu","aria-expanded":g,"aria-controls":g?`${h}-menu`:void 0,disabled:m,title:r?`${ex(e,l)} ${l("composer.frozenForRun")}`:void 0,onClick:()=>c(e=>!e),children:[(0,t.jsx)("span",{className:"permission-chip-icon","aria-hidden":!0,children:(0,t.jsx)(eg,{mode:e})}),(0,t.jsx)("span",{className:"permission-chip-label",children:ex(e,l)}),(0,t.jsx)("svg",{className:g?"permission-chip-chevron open":"permission-chip-chevron",width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:(0,t.jsx)("path",{d:"M3.5 5.25L7 8.75L10.5 5.25"})})]}),g&&(0,t.jsx)("div",{ref:p,id:`${h}-menu`,className:"permission-chip-menu",role:"menu","aria-label":l("composer.permissionMode"),children:em.map(n=>{let a=n===e,i=`${h}-${n}-description`;return(0,t.jsxs)("button",{type:"button",role:"menuitemradio","aria-checked":a,"aria-label":ex(n,l),"aria-describedby":i,className:a?"permission-chip-option selected":"permission-chip-option",onClick:()=>{s(n),c(!1),u.current?.focus()},children:[(0,t.jsx)("span",{className:"permission-chip-option-icon","aria-hidden":!0,children:(0,t.jsx)(eg,{mode:n})}),(0,t.jsxs)("span",{className:"permission-chip-option-copy",children:[(0,t.jsx)("span",{className:"permission-chip-option-label",children:ex(n,l)}),(0,t.jsx)("span",{className:"permission-chip-option-desc",id:i,children:l(`permission.${n}.description`)})]}),(0,t.jsx)("span",{className:"permission-chip-check","aria-hidden":!0,children:a&&(0,t.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,t.jsx)("polyline",{points:"3 8.5 6.5 12 13 4.5"})})})]},n)})})]})}function ey(e){return e?.supportsThinking===!0}function eb(e){if(!ey(e))return[];let t=e?.supportedThinkingEfforts;return t&&t.length>0?t:["default"]}function ek(e){return e.charAt(0).toUpperCase()+e.slice(1)}function ej(e,t){return e.replace(/\{(\w+)\}/g,(e,n)=>t[n]??`{${n}}`)}function ew({models:e,providers:a=[],selectedModelId:s,setSelectedModelId:i,thinkingEffort:r,setThinkingEffort:l,disabled:o}){let c=0,d=(0,f.useT)(),[u,p]=(0,n.useState)(!1),[h,m]=(0,n.useState)("root"),g=(0,n.useRef)(null),x=(0,n.useRef)(null),v=(0,n.useId)(),y=(0,n.useMemo)(()=>e.find(e=>e.id===s)??null,[e,s]),b=(0,n.useMemo)(()=>(function(e,t){let n=new Map(t.map(e=>[e.id,e.name])),a=[],s=new Map;for(let t of e){let e=s.get(t.providerId);if(e){e.push(t);continue}a.push(t.providerId),s.set(t.providerId,[t])}return a.map(e=>({id:e,name:n.get(e)||e,models:s.get(e)??[]}))})(e,a),[e,a]),k=ey(y),w=(0,n.useMemo)(()=>eb(y),[y]),N=w.length>0&&w.includes(r)?r:"default",_=k?ek(N):void 0;(0,n.useEffect)(()=>{if(!y)return;let e=eb(y);e.length>0&&!e.includes(r)&&l("default")},[s]);let C=y?.displayName||y?.modelName||d("composer.modelSelect.triggerFallback"),S=void 0===_?C:`${C} \xb7 ${_}`,I=null===y?d("composer.modelSelect.selectAria"):void 0===_?ej(d("composer.modelSelect.aria"),{model:C}):ej(d("composer.modelSelect.ariaEffort"),{model:C,effort:_}),P=(e=!1)=>{p(!1),m("root"),e&&queueMicrotask(()=>{x.current?.focus()})};return M(u,()=>{"root"!==h?m("root"):P()}),(0,n.useEffect)(()=>{if(!u)return;let e=e=>{g.current?.contains(e.target)||p(!1)};return document.addEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e)}},[u]),(0,n.useEffect)(()=>{if(!u)return;let e=e=>{("ArrowDown"===e.key||"ArrowUp"===e.key)&&(e.preventDefault(),(e=>{let t=Array.from(g.current?.querySelectorAll("[data-menu-index]")??[]);if(0===t.length)return;let n=(Math.max(t.findIndex(e=>e===document.activeElement),0)+e+t.length)%t.length;t[n]?.focus()})("ArrowDown"===e.key?1:-1))};return window.addEventListener("keydown",e),()=>{window.removeEventListener("keydown",e)}},[u]),(0,t.jsxs)("div",{ref:g,className:"model-select",onBlur:e=>{e.relatedTarget instanceof Node&&(g.current?.contains(e.relatedTarget)||P())},children:[(0,t.jsxs)("button",{ref:x,type:"button",className:"model-select-trigger","aria-label":I,"aria-haspopup":"menu","aria-expanded":u,"aria-controls":u?`${v}-menu`:void 0,title:S,disabled:o,onClick:()=>{u?P():(m("root"),p(!0))},children:[(0,t.jsx)("span",{className:"model-select-trigger-label",children:C}),void 0!==_&&(0,t.jsx)("span",{className:"model-select-trigger-effort",children:_}),(0,t.jsx)(q,{size:14,className:u?"model-select-chevron open":"model-select-chevron","aria-hidden":"true"})]}),u&&(0,t.jsxs)("div",{id:`${v}-menu`,className:"model-select-menu",role:"menu","aria-label":d("composer.modelSelect.menu"),children:["root"===h&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("button",{"data-menu-index":c++,type:"button",role:"menuitem",className:"model-select-cell",onClick:()=>{m("model")},children:[(0,t.jsx)("span",{className:"model-select-cell-label",children:d("composer.modelSelect.model")}),(0,t.jsx)("span",{className:"model-select-cell-value",children:C}),(0,t.jsx)(j,{size:14,className:"model-select-cell-chevron","aria-hidden":"true"})]}),k&&(0,t.jsxs)("button",{"data-menu-index":c++,type:"button",role:"menuitem",className:"model-select-cell",onClick:()=>{m("effort")},children:[(0,t.jsx)("span",{className:"model-select-cell-label",children:d("composer.modelSelect.effort")}),(0,t.jsx)("span",{className:"model-select-cell-value",children:_}),(0,t.jsx)(j,{size:14,className:"model-select-cell-chevron","aria-hidden":"true"})]})]}),"model"===h&&(0,t.jsxs)("div",{className:"model-select-groups",children:[b.map(e=>(0,t.jsxs)("section",{role:"group","aria-labelledby":`${v}-${e.id}`,className:"model-select-group",children:[(0,t.jsx)("div",{className:"model-select-group-title",id:`${v}-${e.id}`,children:e.name}),e.models.map(e=>{let n=s===e.id;return(0,t.jsxs)("button",{"data-menu-index":c++,type:"button",role:"menuitemradio","aria-checked":n,className:n?"model-select-option selected":"model-select-option",title:e.displayName||e.modelName,onClick:()=>{s===e.id||(i(e.id),l("default")),P(!0)},children:[(0,t.jsx)("span",{className:"model-select-option-copy",children:(0,t.jsx)("span",{className:"model-select-option-name",children:e.displayName||e.modelName})}),(0,t.jsx)("span",{className:"model-select-check",children:n&&(0,t.jsx)(Y,{size:16,"aria-hidden":"true"})})]},e.id)})]},e.id)),0===e.length&&(0,t.jsx)("div",{className:"model-select-empty",children:d("composer.modelSelect.emptyModels")})]}),"effort"===h&&(0,t.jsxs)(t.Fragment,{children:[w.map(e=>{let n=N===e;return(0,t.jsxs)("button",{"data-menu-index":c++,type:"button",role:"menuitemradio","aria-checked":n,className:n?"model-select-option selected":"model-select-option",onClick:()=>{N===e||l(e),P(!0)},children:[(0,t.jsx)("span",{className:"model-select-option-copy",children:(0,t.jsx)("span",{className:"model-select-option-name",children:ek(e)})}),(0,t.jsx)("span",{className:"model-select-check",children:n&&(0,t.jsx)(Y,{size:16,"aria-hidden":"true"})})]},e)}),0===w.length&&(0,t.jsx)("div",{className:"model-select-empty",children:d("composer.modelSelect.emptyEfforts")})]})]})]})}let eN=o("activity",[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]]);function e_(e){let t=e=>e>=100?String(Math.round(e)):String(Math.round(10*e)/10);return e<1e3?String(e):e<1e6?`${t(e/1e3)}K`:`${t(e/1e6)}M`}function eC(e){let t=e/1e3;if(t<60)return`${Math.round(10*t)/10}s`;let n=Math.round(t);return`${Math.floor(n/60)}m${n%60}s`}function eS(e){let t=Math.max(0,e);return t>=10?String(Math.round(t)):String(Math.round(10*t)/10)}function eI(e,t){return e.replace(/\{(\w+)\}/g,(e,n)=>t[n]??`{${n}}`)}function eP(e,t){if(null===e)return[];let n=[];if(e.steps>0){n.push(eI(t("stats.counts"),{turns:String(e.turns),steps:String(e.steps)}));let a=[];e.llmMs>0&&a.push(eI(t("stats.llm"),{duration:eC(e.llmMs)})),e.toolMs>0&&a.push(eI(t("stats.toolCall"),{duration:eC(e.toolMs)})),a.length>0&&n.push(a.join(" · "));let s=[];e.ttftSteps>0&&s.push(eI(t("stats.ttftAverage"),{duration:eC(e.ttftMs/e.ttftSteps)})),e.decodeMs>0&&s.push(eI(t("stats.tokensPerSecond"),{throughput:eS(e.decodeTokens/(e.decodeMs/1e3))})),s.length>0&&n.push(s.join(" · "))}let a=e.uncachedInputTokens+e.cacheReadTokens+e.cacheWriteTokens;return a>0&&n.push(eI(t("stats.cacheHit"),{percent:String(Math.round(e.cacheReadTokens/a*100))})),(a>0||e.outputTokens>0)&&n.push(eI(t("stats.tokens"),{input:e_(a),output:e_(e.outputTokens)})),n}function eT({stats:e}){let n=(0,f.useT)(),a=eP(e,n);return 0===a.length?null:(0,t.jsxs)("div",{className:"context-meter-stats",children:[(0,t.jsx)("span",{className:"context-meter-stats-label",children:n("stats.section")}),a.map(e=>(0,t.jsx)("span",{children:e},e))]})}let eM=2*Math.PI*5.5,eR=[{key:"systemTokens",label:"context.system",color:"cm-color-system"},{key:"toolsTokens",label:"context.tools",color:"cm-color-tools"},{key:"messageTokens",label:"context.messages",color:"cm-color-messages"}],eE={system:{label:"context.system",color:"cm-color-system"},hero:{label:"context.hero",color:"cm-color-hero"},rules:{label:"context.rules",color:"cm-color-rules"},skills:{label:"context.skills",color:"cm-color-skills"},tools:{label:"context.tools",color:"cm-color-tools"},reminders:{label:"context.reminders",color:"cm-color-reminders"},conversation:{label:"context.conversation",color:"cm-color-messages"}};function eA({contextUsage:e,stats:a=null,initialOpen:s=!1}){let i=(0,f.useT)(),[r,l]=(0,n.useState)(s),o=(0,n.useRef)(null),c=null!==e&&e.contextWindow>0||eP(a,i).length>0;if((0,n.useEffect)(()=>{!c&&r&&l(!1)},[c,r]),M(r&&c,()=>l(!1)),(0,n.useEffect)(()=>{if(!r||!c)return;let e=e=>{e.target instanceof Node&&o.current?.contains(e.target)===!0||l(!1)};return document.addEventListener("pointerdown",e),()=>document.removeEventListener("pointerdown",e)},[c,r]),!c)return null;if(null===e||e.contextWindow<=0)return(0,t.jsxs)("span",{ref:o,className:"context-meter",children:[(0,t.jsx)("button",{type:"button",className:"context-meter-trigger","aria-label":i("stats.section"),"aria-haspopup":"dialog","aria-expanded":r,title:i("stats.section"),onClick:()=>l(e=>!e),children:(0,t.jsx)(eN,{size:14,"aria-hidden":"true"})}),r&&(0,t.jsx)("div",{className:"context-meter-panel",role:"dialog","aria-label":i("stats.section"),children:(0,t.jsx)(eT,{stats:a})})]});let d=Math.min(100,Math.round(e.projectedTokens/e.contextWindow*100)),u=d>=95?"is-critical":d>=85?"is-high":"",p=`${d}%`,[h="",m=""]=i("context.aria",{percent:"\0"}).split("\0").map(e=>e.trim()),g=e.categories??[],x=g.length>0&&g.some(e=>e.tokens>0),v=x?e.projectedTokens:e.systemTokens+e.toolsTokens+e.messageTokens,y=x?g.map(e=>({key:e.key,label:eE[e.key]?.label??"context.other",color:eE[e.key]?.color??"cm-color-messages",tokens:e.tokens})):eR.map(t=>({key:t.key,label:t.label,color:t.color,tokens:e[t.key]})),b=(0===v?[{key:"total",color:void 0,width:d}]:y.map(t=>({key:t.key,color:t.color,width:e.contextWindow>0?t.tokens/e.contextWindow*100:d*t.tokens/v}))).filter(e=>e.width>0);return(0,t.jsxs)("span",{ref:o,className:"context-meter",children:[(0,t.jsx)("button",{type:"button",className:"context-meter-trigger","aria-label":i("context.aria",{percent:p}),"aria-haspopup":"dialog","aria-expanded":r,title:i("context.aria",{percent:p}),onClick:()=>l(e=>!e),children:(0,t.jsxs)("svg",{viewBox:"0 0 14 14",width:"14",height:"14","aria-hidden":"true",children:[(0,t.jsx)("circle",{className:"context-meter-track",cx:"7",cy:"7",r:5.5}),(0,t.jsx)("circle",{className:u?`context-meter-fill ${u}`:"context-meter-fill",cx:"7",cy:"7",r:5.5,strokeDasharray:`${eM*d/100} ${eM}`,transform:"rotate(-90 7 7)"})]})}),r&&(0,t.jsxs)("div",{className:"context-meter-panel",role:"dialog","aria-label":i("context.used"),children:[(0,t.jsxs)("div",{className:"context-meter-header",children:[(0,t.jsx)("span",{className:"context-meter-headline",children:h}),(0,t.jsx)("span",{className:"context-meter-percent",children:p}),(0,t.jsx)("span",{className:"context-meter-headline",children:m}),(0,t.jsx)("span",{className:"context-meter-figures",children:`~${e_(e.projectedTokens)} / ${e_(e.contextWindow)}`})]}),(0,t.jsx)("div",{className:"context-meter-bar",children:b.map(e=>(0,t.jsx)("div",{className:`context-meter-segment${void 0===e.color?"":` ${e.color}`}`,style:{width:`${e.width}%`}},e.key))}),(0,t.jsx)("dl",{className:"context-meter-rows",children:y.map(n=>(0,t.jsxs)("div",{className:"context-meter-row",children:[(0,t.jsxs)("dt",{children:[(0,t.jsx)("span",{className:`context-meter-swatch ${n.color}`,"aria-hidden":"true"}),i(n.label)]}),(0,t.jsxs)("dd",{children:[`~${e_(n.tokens)}`,(0,t.jsx)("span",{className:"context-meter-row-pct",children:`${Math.round(n.tokens/e.contextWindow*100)}%`})]})]},n.key))}),(0,t.jsx)(eT,{stats:a})]})]})}let e$=encodeURIComponent;function ez(e,t){return`/api/worker/v1/sessions/${e$(e)}/artifacts/${e$(t)}`}function eF(e,t,n){let a=`${ez(e,t)}/preview`;return n?`${a}?${new URLSearchParams({sheet:n}).toString()}`:a}let eL=o("image-plus",[["path",{d:"M16 5h6",key:"1vod17"}],["path",{d:"M19 2v6",key:"4bpg5p"}],["path",{d:"M21 11.5V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7.5",key:"1ue2ih"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}]]),eD=o("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"}]]),eO=new Set([":","/","\\","."]),eq=o("chevron-up",[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]]),eB=o("corner-up-right",[["path",{d:"m15 14 5-5-5-5",key:"12vg1m"}],["path",{d:"M4 20v-7a4 4 0 0 1 4-4h12",key:"1lu4f8"}]]);function eU({items:e,onEdit:a,onRemove:s,onSteer:i}){let r=(0,f.useT)(),[l,o]=(0,n.useState)(!1);if(0===e.length)return null;let c=!l||1===e.length;return(0,t.jsxs)("section",{className:"queue-dock","aria-label":r("composer.queue.aria"),children:[(0,t.jsxs)("button",{type:"button",className:"queue-dock-header","aria-expanded":c,onClick:()=>o(e=>!e),children:[(0,t.jsx)(er,{size:14,"aria-hidden":"true"}),(0,t.jsx)("span",{className:"queue-dock-title",children:r("composer.queue.count",{count:String(e.length)})}),(0,t.jsx)("span",{className:"queue-dock-chevron","aria-hidden":"true",children:c?(0,t.jsx)(q,{size:14}):(0,t.jsx)(eq,{size:14})})]}),c&&(0,t.jsx)("ul",{className:"queue-dock-list",children:e.map((e,n)=>(0,t.jsxs)("li",{className:"queue-dock-row",children:[(0,t.jsx)("span",{className:"queue-dock-index","aria-hidden":"true",children:n+1}),(0,t.jsx)("span",{className:"queue-dock-text",title:e.text,children:e.text}),(0,t.jsxs)("span",{className:"queue-dock-actions",children:[(0,t.jsx)("button",{type:"button",className:"queue-dock-action",title:r("composer.queue.edit"),"aria-label":r("composer.queue.edit"),onClick:()=>a(e),children:(0,t.jsx)(C,{size:13,"aria-hidden":"true"})}),(0,t.jsx)("button",{type:"button",className:"queue-dock-action",title:r("composer.queue.steer"),"aria-label":r("composer.queue.steer"),onClick:()=>i(e),children:(0,t.jsx)(eB,{size:13,"aria-hidden":"true"})}),(0,t.jsx)("button",{type:"button",className:"queue-dock-action is-danger",title:r("composer.queue.remove"),"aria-label":r("composer.queue.remove"),onClick:()=>s(e),children:(0,t.jsx)(m,{size:13,"aria-hidden":"true"})})]})]},e.id))})]})}let eH="ennote-composer-height";function eW(e){return Math.min(336,Math.max(120,e))}let eV={pdf:{Icon:ei,color:"var(--danger)"},docx:{Icon:ei,color:"var(--info)"},doc:{Icon:ei,color:"var(--info)"},xlsx:{Icon:es,color:"var(--success)"},xls:{Icon:es,color:"var(--success)"},pptx:{Icon:eo,color:"var(--warning)"},ppt:{Icon:eo,color:"var(--warning)"}};function eK({selectedSession:e,activeLeafMessageId:a,input:s,setInput:i,activeRun:r,questionPending:l=!1,compacting:o,hasPendingImage:d,reconnecting:u,permissionMode:p,permissionReady:g,setPermissionMode:x,models:v,providers:y,selectedModelId:b,setSelectedModelId:k,thinkingEffort:j,setThinkingEffort:w,textAttachments:N,removeTextAttachment:_,pendingImage:C,clearPendingImage:I,attachFiles:P,uploadImage:T,submit:M,steer:R,steerText:E,followUp:A,cancel:$,cancelFollowUp:z,compactSession:F,pendingFollowUps:L,picker:D,expanding:O,expandDiag:q,contextUsage:B,stats:U,focusNonce:H,onRequestProject:W,inert:V=!1,welcome:K=!1}){let G=(0,n.useRef)(null),J=(0,n.useRef)(null),Y=(0,n.useRef)(null),Q=(0,n.useRef)(null),[Z,ee]=(0,n.useState)(!1),et=(0,n.useRef)(0),[es,eo]=(0,n.useState)(()=>{try{let e=Number.parseInt(localStorage.getItem(eH)??"",10);return Number.isFinite(e)?eW(e):0}catch{return 0}}),[ed,eu]=(0,n.useState)(!1),em=(0,n.useRef)(es),ef=(0,n.useRef)(null),eg=(0,f.useT)(),ex=(0,n.useCallback)(e=>{em.current=e,eo(e)},[]),ey=(0,n.useCallback)(e=>{try{e>0?localStorage.setItem(eH,String(e)):localStorage.removeItem(eH)}catch{}},[]),eb=(0,n.useCallback)(()=>{ex(0),ey(0)},[ex,ey]),ek=(0,n.useCallback)(e=>{if(0!==e.button||!e.isPrimary)return;e.preventDefault();let t=em.current||G.current?.offsetHeight||120;ef.current={y:e.clientY,height:t},eu(!0),e.currentTarget.setPointerCapture(e.pointerId),document.body.style.cursor="row-resize",document.body.style.userSelect="none"},[]),ej=(0,n.useCallback)(e=>{let t=ef.current;t&&(e.preventDefault(),ex(eW(t.height+t.y-e.clientY)))},[ex]),eN=(0,n.useCallback)(e=>{ef.current&&(ef.current=null,eu(!1),document.body.style.cursor="",document.body.style.userSelect="",e.currentTarget.hasPointerCapture(e.pointerId)&&e.currentTarget.releasePointerCapture(e.pointerId),ey(em.current))},[ey]),e_=(0,n.useCallback)(e=>{let t=eW((em.current||G.current?.offsetHeight||120)+e);ex(t),ey(t)},[ex,ey]);(0,n.useEffect)(()=>{if(!H)return;let e=G.current;if(!e)return;e.focus();let t=e.value.length;e.setSelectionRange(t,t)},[H]),(0,n.useEffect)(()=>{let e=G.current;e&&(e.style.height="0px",e.style.height=`${Math.min(Math.max(e.scrollHeight,es),336)}px`)},[s,es]);let eC=(0,n.useCallback)(async e=>{await z(e.id)&&(i(e.text),window.requestAnimationFrame(()=>G.current?.focus()))},[z,i]),eS=(0,n.useCallback)(e=>{z(e.id)},[z]),eI=(0,n.useCallback)(async e=>{await z(e.id)&&await E(e.text)},[z,E]),eP=!!e&&!r&&!o,eT=(0,n.useRef)(null),eM=function({input:e,setInput:a,data:s,canAct:i,panel:r,onAttachFile:l,onAttachImage:o,onCompact:d}){let u=(0,f.useT)(),[p,m]=(0,n.useState)(null),[g,x]=(0,n.useState)(""),v=(0,n.useMemo)(()=>{let e=s.skills.filter(e=>!e.heroBound),n=s.skills.filter(e=>e.heroBound),a=[{key:"actions",label:u("picker.actions"),pinned:!0,items:[{key:"action:file",label:u("composer.attachFiles"),icon:(0,t.jsx)(el,{size:14,"aria-hidden":"true"}),disabled:!i},{key:"action:image",label:u("composer.attachImage"),icon:(0,t.jsx)(eL,{size:14,"aria-hidden":"true"}),disabled:!i},{key:"action:compact",label:u("composer.compactContext"),icon:(0,t.jsx)(eD,{size:14,"aria-hidden":"true"}),disabled:!i}]},{key:"heroes",label:u("picker.heroes"),items:s.heroes.map(e=>({key:`hero:${e.id}`,label:`@${e.handle}`,hint:e.id===s.selectedHeroId?u("picker.selected"):void 0,description:e.description??e.name,icon:(0,t.jsx)(c,{size:14,"aria-hidden":"true"})}))},{key:"graphs",label:u("picker.graphs"),items:s.graphs.map(e=>({key:`graph:${e.name}`,label:e.name,hint:e.version?`v${e.version}`:void 0,icon:(0,t.jsx)(h,{size:14,"aria-hidden":"true"}),disabled:!0===s.oneShotLocked}))},{key:"skills",label:u("picker.skills"),items:e.map(e=>({key:`skill:${e.id}`,label:`/${e.label}`,hint:s.pendingSkills.includes(e.id)?u("picker.selected"):void 0,description:e.description,icon:(0,t.jsx)(X,{size:14,"aria-hidden":"true"}),disabled:!0===s.oneShotLocked||null!==s.pendingGraph}))},{key:"templates",label:u("picker.templates"),items:s.templates.map(e=>({key:`template:${e.name}`,label:`/${e.name}`,hint:e.argumentHint||void 0,description:e.description,icon:(0,t.jsx)(ei,{size:14,"aria-hidden":"true"})}))}];return n.length>0&&a.push({key:"bound",label:u("picker.boundSkills"),readOnly:!0,items:n.map(e=>({key:`bound:${e.id}`,label:`/${e.label}`,hint:e.boundBy.join(", "),icon:(0,t.jsx)(X,{size:14,"aria-hidden":"true"})}))}),a},[s,u,i]),y=(0,n.useCallback)(e=>"hero"===e?["heroes"]:"graph"===e?["graphs"]:"skill"===e?["skills","templates","bound"]:"template"===e?["templates"]:["heroes","graphs"],[]),b=(0,n.useCallback)(()=>{p&&!p.fromPlus&&a(e.slice(0,p.start)+e.slice(p.caret))},[p,e,a]),k=(0,n.useCallback)((e,t)=>{if(!e.disabled){if("actions"===t.key){"action:file"===e.key&&l(),"action:image"===e.key&&o(),"action:compact"===e.key&&d(),m(null);return}if("heroes"===t.key)s.onSelectHero(e.key.slice(5),e.label.replace(/^@/,""));else if("graphs"===t.key){let t=s.graphs.find(t=>`graph:${t.name}`===e.key);for(let e of(s.selectedHeroId&&s.onSelectHero("",""),s.pendingSkills))s.onToggleSkill(e);s.onSelectGraph(e.key.slice(6),t?.version)}else if("skills"===t.key){s.onToggleSkill(e.key.slice(6)),b(),m(null);return}else if("templates"===t.key){s.onSelectTemplate(e.key.slice(9)),m(null);return}b(),m(null)}},[s,p,e,a,l,o,d,b]),j=(0,n.useCallback)(()=>{x(""),m({kind:"all",query:"",start:0,caret:0,fromPlus:!0})},[]),w=(0,n.useRef)(!1),N=(0,n.useCallback)(()=>{w.current=null!==p},[p]),_=(0,n.useCallback)(()=>{if(w.current){w.current=!1;return}p?m(null):j()},[p,j]),C=(0,n.useCallback)(e=>{let t=e.target.value;a(t);let n=e.target.selectionStart??t.length,s=function(e,t){if(!Number.isFinite(t)||t<0||t>e.length)return null;let n=e.slice(0,t),a=-1;for(let e=n.length-1;e>=0;e-=1){let t=n[e];if("@"===t||"/"===t){a=e;break}if(/\s/.test(t))return null}if(a<0)return null;let s=n[a],i=a>0?n[a-1]:void 0;return!(void 0===i||!/[A-Za-z0-9_]/.test(i))||"/"===s&&void 0!==i&&eO.has(i)?null:{...function(e,t){let n=t.toLowerCase(),[a,...s]=n.split(":"),i=s.join(":");return"@"===e?"hero"===a||"role"===a?{kind:"hero",query:i,start:0}:"graph"===a||"flow"===a?{kind:"graph",query:i,start:0}:{kind:"all",query:n,start:0}:"skill"===a?{kind:"skill",query:i,start:0}:"template"===a?{kind:"template",query:i,start:0}:{kind:"skill",query:n,start:0}}(s,n.slice(a+1)),start:a}}(t,n);s?m({kind:s.kind,query:s.query,start:s.start,caret:n,fromPlus:!1}):m(null)},[a]),S=(0,n.useMemo)(()=>{if(p?.fromPlus)return v;let e=new Set(y(p?.kind??"all"));return v.filter(t=>e.has(t.key))},[v,p?.kind,p?.fromPlus,y]),I=(0,n.useCallback)(e=>!!p&&("ArrowDown"===e.key?(e.preventDefault(),r.current?.move(1),!0):"ArrowUp"===e.key?(e.preventDefault(),r.current?.move(-1),!0):"Enter"===e.key?!!r.current?.pickActive()&&(e.preventDefault(),!0):"Escape"===e.key&&(e.preventDefault(),m(null),!0)),[p,r]);return{open:null!==p,notePointerClose:N,handleKeyDown:I,fromPlus:p?.fromPlus===!0,filter:p?.fromPlus?g:p?.query??"",sections:S,pick:k,openFromPlus:j,onInputChange:C,setPlusFilter:x,close:()=>m(null),toggle:_}}({input:s,setInput:i,data:D,canAct:eP,panel:eT,onAttachFile:()=>Y.current?.click(),onAttachImage:()=>Q.current?.click(),onCompact:F}),eR=(0,n.useCallback)(e=>{eP&&e.dataTransfer.types.includes("Files")&&(e.preventDefault(),et.current+=1,1===et.current&&ee(!0))},[eP]),eE=(0,n.useCallback)(e=>{Z&&(e.preventDefault(),et.current-=1,et.current<=0&&(et.current=0,ee(!1)))},[Z]),e$=(0,n.useCallback)(e=>{eP&&(e.preventDefault(),e.dataTransfer.dropEffect="copy")},[eP]),ez=(0,n.useCallback)(e=>{if(!eP)return;e.preventDefault(),et.current=0,ee(!1);let t=Array.from(e.dataTransfer.files);t.length&&P(t)},[P,eP]);return(0,t.jsxs)("div",{className:"composer-shell",onDragEnter:eR,onDragLeave:eE,onDragOver:e$,onDrop:ez,children:[Z&&(0,t.jsxs)("div",{className:"composer-drop-zone",children:[(0,t.jsx)(el,{size:18}),eg("composer.dropFiles")]}),(0,t.jsx)(eU,{items:L,onEdit:eC,onRemove:eS,onSteer:eI}),(C||N.length>0)&&(0,t.jsxs)("div",{className:"composer-attachments","aria-label":eg("composer.attachedFiles"),children:[C&&e&&(0,t.jsxs)("div",{className:"composer-image-preview",children:[(0,t.jsx)("img",{src:eF(e,C.id),alt:C.name}),(0,t.jsx)("button",{type:"button",onClick:I,"aria-label":eg("composer.removeImage"),children:(0,t.jsx)(m,{size:10,"aria-hidden":"true"})})]}),N.map(e=>{var n;let a=eV[e.name.toLowerCase().split(".").pop()??""]??{Icon:ea,color:"var(--content-3)"},s=a.Icon,i=e.name.toLowerCase().split(".").pop()??"";return(0,t.jsxs)("span",{className:"composer-attachment",title:e.name,children:[(0,t.jsx)("span",{className:"composer-attachment-icon",style:{color:a.color},children:(0,t.jsx)(s,{size:14,"aria-hidden":"true"})}),(0,t.jsxs)("span",{className:"composer-attachment-body",children:[(0,t.jsx)("span",{className:"composer-attachment-name",children:e.name}),(0,t.jsxs)("span",{className:"composer-attachment-meta",children:[i.toUpperCase()," · ",(n=e.size)<1024?`${n} B`:n<1048576?`${(n/1024).toFixed(1)} KB`:`${(n/1048576).toFixed(1)} MB`," · text"]})]}),(0,t.jsx)("button",{type:"button",onClick:()=>_(e.id),"aria-label":`${eg("composer.remove")} ${e.name}`,children:(0,t.jsx)(m,{size:9,"aria-hidden":"true"})})]},e.id)})]}),(0,t.jsx)(eh,{hero:D.heroes.find(e=>e.id===D.selectedHeroId)??null,graph:D.pendingGraph,skills:D.pendingSkills.map(e=>{let t=D.skills.find(t=>t.id===e);return{id:e,label:t?.label??e}}),onClearHero:()=>D.onSelectHero("",""),onClearGraph:D.onClearGraph,onRemoveSkill:D.onToggleSkill}),(0,t.jsxs)("form",{className:"composer",onSubmit:function(e){(e.preventDefault(),r)?!l&&(o||u||R()):M()},ref:J,children:[(0,t.jsx)("div",{className:"composer-resizer","data-resizing":ed||void 0,role:"separator","aria-orientation":"horizontal","aria-label":eg("composer.hint.resizeAria"),tabIndex:0,onPointerDown:ek,onPointerMove:ej,onPointerUp:eN,onPointerCancel:eN,onDoubleClick:eb,onKeyDown:e=>{if("ArrowUp"===e.key){e.preventDefault(),e_(24);return}if("ArrowDown"===e.key){e.preventDefault(),e_(-24);return}("Enter"===e.key||" "===e.key)&&(e.preventDefault(),eb())}}),(0,t.jsxs)("div",{className:`composer-editor${V?" composer-no-session":""}`,onClick:()=>{V&&W?.()},children:[(0,t.jsx)(ep,{ref:eT,open:eM.open,sections:eM.sections,filter:eM.filter,showFilter:eM.fromPlus,ariaLabel:eg("composer.picker"),onFilterChange:eM.setPlusFilter,onPick:eM.pick,onClose:()=>{eM.close(),G.current?.focus()}}),(0,t.jsx)("textarea",{ref:G,value:s,onChange:eM.onInputChange,onKeyDown:function(t){!e||!t.nativeEvent.isComposing&&eM.handleKeyDown(t)||"Enter"!==t.key||t.shiftKey||t.nativeEvent.isComposing||(t.preventDefault(),r&&l||J.current?.requestSubmit())},rows:1,readOnly:V,disabled:o,placeholder:o?eg("composer.placeholderCompacting"):l?eg("composer.answerQuestionFirst"):r?eg("composer.placeholderSteer"):V?eg("composer.placeholderNoSession"):K?eg("composer.placeholderWelcome"):eg("composer.placeholderDefault"),"aria-label":r?eg("composer.steerAria"):eg("composer.messageAria")}),(0,t.jsx)("input",{ref:Q,className:"sr-only",type:"file",accept:"image/png,image/jpeg,image/gif,image/webp",disabled:!eP,onChange:e=>{let t=e.target.files?.[0];t&&T(t),e.currentTarget.value=""}}),(0,t.jsx)("input",{ref:Y,className:"sr-only",type:"file",multiple:!0,accept:"image/png,image/jpeg,image/gif,image/webp,text/*,.md,.mdx,.json,.yaml,.yml,.toml,.csv,.tsv,.js,.jsx,.ts,.tsx,.py,.r,.go,.rs,.java,.c,.cpp,.h,.hpp,.css,.html,.xml,.sh,.sql",disabled:!eP,onChange:e=>{let t=Array.from(e.currentTarget.files??[]);t.length&&P(t),e.currentTarget.value=""}}),(0,t.jsxs)("div",{className:"composer-toolbar-row",children:[(0,t.jsx)("div",{className:"composer-tools",children:(0,t.jsx)("button",{type:"button",className:"composer-plus","aria-expanded":eM.open,"aria-haspopup":"dialog",onPointerDown:eM.notePointerClose,"aria-label":eg("composer.insert"),title:eg("composer.insert"),disabled:!e||o,onClick:eM.toggle,children:(0,t.jsx)(S,{size:14,"aria-hidden":"true"})})}),(0,t.jsxs)("div",{className:"composer-trailing",children:[r&&(0,t.jsxs)("button",{type:"button",className:"composer-followup","aria-label":eg("composer.queueFollowUp"),disabled:!s.trim()||o||u||l,onClick:A,children:[(0,t.jsx)(er,{size:12,"aria-hidden":"true"}),(0,t.jsx)("span",{children:eg("composer.followUp")})]}),r?(0,t.jsx)("button",{type:"button",className:"composer-primary","aria-label":eg("composer.stopRun"),title:eg("composer.stopRun"),onClick:$,children:(0,t.jsx)(ec,{size:12,fill:"currentColor","aria-hidden":"true"})}):(0,t.jsx)("button",{type:"submit",className:"composer-primary","aria-label":eg("composer.send"),disabled:V||!e||!g&&!D.selectedHeroId||!s.trim()&&!d&&0===N.length&&!D.pendingGraph,children:(0,t.jsx)(en,{size:16,"aria-hidden":"true"})})]})]})]}),(0,t.jsxs)("div",{className:"composer-context-bar","aria-label":eg("composer.runContext"),children:[(0,t.jsx)(ev,{permissionMode:p,permissionReady:g,setPermissionMode:x,disabled:!e||r||o||!!D.selectedHeroId,frozen:r}),(0,t.jsx)("span",{className:"composer-context-spacer","aria-hidden":"true"}),(0,t.jsx)(ew,{models:v,providers:y,selectedModelId:b,setSelectedModelId:k,thinkingEffort:j,setThinkingEffort:w,disabled:!e||r||0===v.length||!!D.selectedHeroId}),(0,t.jsx)(eA,{contextUsage:B,stats:U})]})]}),(0,t.jsxs)("div",{className:"composer-status-line",children:[!g&&e&&!D.selectedHeroId&&(0,t.jsx)("span",{className:"composer-config-hint is-danger",children:eg("composer.policyUnavailable")}),O&&(0,t.jsx)("span",{className:"composer-status","aria-live":"polite",children:eg("composer.expanding")}),q&&(0,t.jsx)("span",{className:"composer-status diag-warning","aria-live":"polite",children:q})]})]})}function eG(){let e=`empty-glow-${(0,n.useId)().replace(/:/g,"")}`;return(0,t.jsxs)("svg",{className:"composer-welcome-glow",viewBox:"0 0 1051 468",fill:"none","aria-hidden":"true",children:[(0,t.jsx)("defs",{children:(0,t.jsxs)("filter",{id:e,x:"0",y:"0",width:"1051",height:"468",filterUnits:"userSpaceOnUse",colorInterpolationFilters:"sRGB",children:[(0,t.jsx)("feFlood",{floodOpacity:"0",result:"BackgroundImageFix"}),(0,t.jsx)("feBlend",{mode:"normal",in:"SourceGraphic",in2:"BackgroundImageFix",result:"shape"}),(0,t.jsx)("feGaussianBlur",{stdDeviation:"50",result:"effect1_foregroundBlur"})]})}),(0,t.jsx)("g",{filter:`url(#${e})`,children:(0,t.jsx)("ellipse",{cx:"525.5",cy:"234",rx:"425.5",ry:"134",fill:"var(--accent)",fillOpacity:"0.08"})})]})}function eJ(e){let{hasModel:n,onOpenSettings:a}=e,s=(0,f.useT)();return(0,t.jsx)("div",{className:"welcome-stage","data-testid":"welcome-stage",children:(0,t.jsxs)("div",{className:"welcome-stage-headline",children:[(0,t.jsx)("span",{className:"welcome-stage-mark","aria-hidden":"true",children:(0,t.jsx)(x,{size:28})}),(0,t.jsx)("h1",{className:"welcome-stage-title",children:s("welcome.headline")}),(0,t.jsx)("span",{className:"welcome-stage-preview",children:s("welcome.preview")}),!n&&(0,t.jsx)("button",{type:"button",className:"welcome-stage-settings",onClick:()=>a(),children:s("empty.noModel")})]})})}function eY(e){let{projects:n,selectedProject:a,pinnedProjectIds:s,togglePinProject:i,onRequestProject:r,onSwitchProject:l,projectSelector:o}=e,{open:c,close:d,rootRef:u}=o,p=(0,f.useT)();M(c,d);let h=a?n.find(e=>e.id===a)?.name??null:null;return(0,t.jsxs)("div",{ref:u,className:"workspace-chip-wrap",children:[(0,t.jsxs)("button",{type:"button",className:"workspace-chip",onClick:r,title:h??p("empty.project.choose"),"aria-label":h?`${h} \xb7 ${p("sidebar.selectProject")}`:p("sidebar.selectProjectEllipsis"),"aria-haspopup":"menu","aria-expanded":c,children:[h?(0,t.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.35",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:(0,t.jsx)("path",{d:"M1.5 5A1.5 1.5 0 0 1 3 3.5h3l1.2 1.5H13A1.5 1.5 0 0 1 14.5 6.5L13.6 11A1.5 1.5 0 0 1 12.1 12.5H3A1.5 1.5 0 0 1 1.5 11V5ZM1.5 8V11A1.5 1.5 0 0 0 3 12.5h10A1.5 1.5 0 0 0 14.5 11V8"})}):(0,t.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.35",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:(0,t.jsx)("path",{d:"M1.5 5A1.5 1.5 0 0 1 3 3.5h3l1.2 1.5H13A1.5 1.5 0 0 1 14.5 6.5L13.6 11A1.5 1.5 0 0 1 12.1 12.5H3A1.5 1.5 0 0 1 1.5 11V5Z"})}),(0,t.jsx)("span",{className:"workspace-chip-label",children:h??p("empty.project.choose")}),(0,t.jsx)("svg",{className:"workspace-chip-chevron",width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:(0,t.jsx)("path",{d:"M3 4.5L6 7.5L9 4.5"})})]}),c&&(0,t.jsx)(U,{projects:n,selectedProject:a,pinnedProjectIds:s,togglePinProject:i,onSelect:e=>{d(),l(e)},className:"workspace-chip-menu"})]})}let eQ=o("loader-circle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]),eZ=o("timer-reset",[["path",{d:"M10 2h4",key:"n1abiw"}],["path",{d:"M12 14v-4",key:"1evpnu"}],["path",{d:"M4 13a8 8 0 0 1 8-7 8 8 0 1 1-5.3 14L4 17.6",key:"1ts96g"}],["path",{d:"M9 17H4v5",key:"8t5av"}]]),eX=o("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"}]]),e0=o("circle-check",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]),e1=o("clock-3",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 6v6h4",key:"135r8i"}]]);function e2({completion:e}){let n=(0,f.useT)(),a=e.kind??"completed",s=e.deliveryStatus??"pending",i="pending"===s||"resume_queued"===s,r="cancelled"===a?(0,t.jsx)(eX,{size:13,"aria-hidden":"true"}):i?(0,t.jsx)(e1,{size:13,"aria-hidden":"true"}):(0,t.jsx)(e0,{size:13,"aria-hidden":"true"});return(0,t.jsxs)("div",{className:"delivery-row","data-delivery-status":s,role:"listitem",children:[(0,t.jsx)("span",{className:"delivery-icon",children:r}),(0,t.jsxs)("span",{className:"delivery-identity",children:[(0,t.jsx)("strong",{children:n("delegation.completion",{generation:String(e.generation??"")})}),(0,t.jsx)("span",{children:e4(n,"delegation.handle",s)})]}),(0,t.jsxs)("span",{className:"delivery-summary",children:[(0,t.jsx)(c,{size:11,"aria-hidden":"true"}),function(e){if(!e)return"";let t="string"==typeof e?e:JSON.stringify(e);return t.length>300?t.slice(0,300)+"…":t}(e.result)]})]})}function e4(e,t,n){let a=`${t}.${n}`,s=e(a);return s===a?n.replaceAll("_"," "):s}var e5=e.i(9323);let e3={session:void 0,rows:{}};function e6({sessionId:e}){let{deliveries:a,refreshing:s}=function(e){let[t,a]=(0,n.useState)(e3),[s,i]=(0,n.useState)(!1),r=(0,n.useRef)(e3);return(0,n.useEffect)(()=>{r.current=t},[t]),(0,n.useEffect)(()=>{let t;if(!e)return;let n=new AbortController,s=!1,l=async()=>{try{i(!0);let t=await (0,e5.apiFetch)(`/v1/sessions/${encodeURIComponent(e)}/delegation-handles?limit=20`,{signal:n.signal});if(s||n.signal.aborted)return;let l=r.current.session===e?r.current.rows:{},o=function(e,t,n){let a={rows:{},toFetch:[]};for(let s of n){if(s.sessionId&&s.sessionId!==t)continue;let n=e[s.id];if(n&&n.handle.sessionId===t&&n&&n.handle.updatedAt===s.updatedAt&&(n.completion||"completed"!==s.status)){a.rows[s.id]=n;continue}a.toFetch.push(s)}return a}(l,e,t.items),c=o.rows;if(await Promise.all(o.toFetch.map(async t=>{try{let a=await (0,e5.apiFetch)(`/v1/delegation-handles/${encodeURIComponent(t.id)}`,{signal:n.signal});if(s||n.signal.aborted||a.handle.sessionId&&a.handle.sessionId!==e)return;c[t.id]={handle:a.handle,completion:a.completion}}catch{c[t.id]={handle:t}}})),s||n.signal.aborted)return;a(t=>{let n={};for(let[a,s]of Object.entries(c)){let i=t.rows[a];n[a]=s.completion||i?.handle.sessionId!==e?s:i}return{session:e,rows:n}})}catch{}finally{s||i(!1),t=window.setTimeout(l,4e3)}};return l(),()=>{s=!0,n.abort(),void 0!==t&&window.clearTimeout(t)}},[e]),{deliveries:(0,n.useMemo)(()=>t.session!==e?[]:Object.values(t.rows).filter(t=>t.handle.sessionId===e).sort((e,t)=>(e.handle.createdAt??"").localeCompare(t.handle.createdAt??"")),[t,e]),refreshing:s}}(e);return(0,t.jsx)(e8,{deliveries:a,refreshing:s},e??"no-session")}function e8({deliveries:e,refreshing:a}){let s=(0,f.useT)(),i=(0,n.useId)(),r=e.filter(e=>e.completion).length,[l,o]=(0,n.useState)(()=>e9({seenCompletions:0,collapsed:!0},r));if(l.seenCompletions!==r&&o(e9(l,r)),!e.length)return null;let c=!l.collapsed,d=e.filter(e=>"active"===e.handle.status),u=d.length?s("conversation.delegation.active",{count:String(d.length)}):s("conversation.delegation.settled");return(0,t.jsxs)("div",{className:"background-delegation-strip","aria-label":s("conversation.delegation.background"),children:[(0,t.jsxs)("button",{type:"button",className:"background-delegation-header","aria-expanded":c,"aria-controls":i,onClick:()=>o(e=>({...e,collapsed:!e.collapsed})),children:[(0,t.jsxs)("span",{children:[(0,t.jsx)(eZ,{size:13,"aria-hidden":"true"})," ",s("conversation.delegation.background"),a&&(0,t.jsx)(eQ,{size:12,"aria-hidden":"true",className:"delivery-spinner"})]}),(0,t.jsx)("span",{"aria-hidden":"true",children:u})]}),(0,t.jsx)("span",{className:"sr-only",role:"status","aria-live":"polite",children:u}),c&&(0,t.jsx)("div",{className:"delivery-list",id:i,role:"list",children:e.map(e=>e.completion?(0,t.jsx)(e2,{completion:e.completion},e.handle.id):(0,t.jsxs)("div",{className:"delivery-row",role:"listitem",children:[(0,t.jsx)("span",{className:"delivery-icon",children:(0,t.jsx)(eZ,{size:13,"aria-hidden":"true"})}),(0,t.jsx)("span",{className:"delivery-identity",children:(0,t.jsxs)("strong",{children:[e4(s,"delegation.mode",e.handle.executionMode)," · ",e4(s,"delegation.handle",e.handle.status)]})}),(0,t.jsx)("span",{className:"delivery-summary",children:s("conversation.delegation.running")})]},e.handle.id))})]})}function e9(e,t){return t===e.seenCompletions?e:{seenCompletions:t,collapsed:!(t>e.seenCompletions)&&e.collapsed}}function e7({value:e,onChange:a,busy:s,onConfirm:i,onCancel:r}){let l=(0,f.useT)(),o=(0,n.useRef)(null);return M(!0,r,{dismissOnEscape:!s}),(0,n.useEffect)(()=>{o.current?.focus()},[]),(0,t.jsxs)("div",{className:"compaction-prompt-bar",role:"dialog","aria-label":l("conversation.compaction.aria"),children:[(0,t.jsxs)("div",{className:"compaction-prompt-header",children:[(0,t.jsxs)("span",{children:[(0,t.jsx)(eD,{size:13,"aria-hidden":"true"})," ",l("conversation.compaction.title")]}),(0,t.jsx)("button",{type:"button",className:"follow-up-close","aria-label":l("conversation.compaction.cancel"),title:l("conversation.compaction.cancel"),onClick:r,disabled:s,children:(0,t.jsx)(m,{size:13,"aria-hidden":"true"})})]}),(0,t.jsxs)("div",{className:"compaction-prompt-body",children:[(0,t.jsx)("input",{ref:o,value:e,onChange:e=>a(e.target.value),placeholder:l("conversation.compaction.placeholder"),disabled:s,onKeyDown:e=>{"Enter"!==e.key||s||(e.preventDefault(),i())}}),(0,t.jsxs)("div",{className:"compaction-prompt-actions",children:[(0,t.jsx)("button",{type:"button",className:"secondary-btn",onClick:r,disabled:s,children:l("conversation.compaction.cancel")}),(0,t.jsx)("button",{type:"button",className:"compaction-prompt-confirm",onClick:i,disabled:s,children:l(s?"conversation.compaction.creating":"conversation.compaction.confirm")})]})]})]})}let te=o("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"}]]),tt=o("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"}]]),tn=o("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"}]]),ta=o("users",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["path",{d:"M16 3.128a4 4 0 0 1 0 7.744",key:"16gr8j"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}]]),ts={read_only:"conversation.tool.risk.readOnly",local_write:"conversation.tool.risk.localWrite",shell:"conversation.tool.risk.shell",external:"conversation.tool.risk.external",delegation:"conversation.tool.risk.delegation",sensitive:"conversation.tool.risk.sensitive"};function ti({item:e,checked:n,onChange:a}){let s=(0,f.useT)();return e.standingScope?(0,t.jsxs)("label",{className:"standing-remember",children:[(0,t.jsx)("input",{type:"checkbox",checked:n,onChange:()=>a(e.callIndex)}),s("conversation.approval.remember",{scope:e.standingScope.display})]}):null}function tr({item:e}){let n=(0,f.useT)();return e.delegations?.length?(0,t.jsx)("div",{className:"approval-delegations",children:e.delegations.map((e,a)=>{let s=e.hero||e.heroHandle,i=e.goalPreview||e.assignmentPreview;return(0,t.jsxs)("div",{className:"approval-delegation",children:[(0,t.jsx)("span",{className:"approval-delegation-icon",children:(0,t.jsx)(ta,{size:14,"aria-hidden":"true"})}),(0,t.jsxs)("span",{className:"approval-delegation-copy",children:[(0,t.jsx)("strong",{children:e.name}),(0,t.jsxs)("span",{children:["@",s]}),(0,t.jsx)("small",{children:i}),!!e.skills?.length&&(0,t.jsxs)("small",{className:"approval-delegation-meta",children:[n("conversation.approval.skills"),": ",(e.skills??[]).join(", ")]}),!!e.depends?.length&&(0,t.jsxs)("small",{className:"approval-delegation-meta",children:[n("conversation.approval.after"),": ",(e.depends??[]).join(", ")]})]}),(0,t.jsxs)("span",{className:"approval-delegation-budget",children:[e.budget.maxModelCalls," ",n("conversation.approval.modelCalls")," · ",e.budget.maxToolCalls," ",n("conversation.approval.toolCalls")]})]},`${s}-${a}`)})}):(0,t.jsx)("pre",{children:e.argumentsPreview})}function tl({approval:e,resolving:a,decide:s}){let i=(0,f.useT)(),[r,l]=(0,n.useState)(()=>({approvalID:e.id,indexes:[]})),o=(0,n.useMemo)(()=>r.approvalID===e.id?r.indexes:[],[e.id,r]),c=(0,n.useMemo)(()=>new Set(o),[o]),d=e.items.some(e=>"delegate_tasks"===e.toolName||"delegate_heroes"===e.toolName),u=(0,n.useCallback)(t=>{l(n=>{let a=new Set(n.approvalID===e.id?n.indexes:[]);return a.has(t)?a.delete(t):a.add(t),{approvalID:e.id,indexes:Array.from(a).sort((e,t)=>e-t)}})},[e.id]),p=(0,n.useCallback)(()=>{s("approved",o)},[s,o]),h=(0,n.useCallback)(()=>{s("rejected",[])},[s]),m=i(1===e.items.length?"conversation.approval.batchOne":"conversation.approval.batchMany",{iteration:e.iteration,count:e.items.length});return(0,t.jsxs)("section",{className:"approval-panel","aria-label":i("conversation.approval.panelAria"),children:[(0,t.jsxs)("div",{className:"approval-heading",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("strong",{children:d?i("conversation.approval.delegationRequired"):i("conversation.approval.required")}),e.attribution?.speakerKind==="hero"&&(0,t.jsxs)("span",{className:"approval-attribution",children:["@",e.attribution.handle||e.attribution.displayName," · ",e.attribution.authority," · ",e.attribution.permissionCeiling]}),(0,t.jsx)("span",{children:m})]}),(0,t.jsx)("span",{className:"approval-waiting",children:i("conversation.approval.waiting")})]}),(0,t.jsx)("div",{className:"approval-items",children:e.items.map(e=>(0,t.jsxs)("div",{className:"approval-item",children:[(0,t.jsxs)("div",{className:"approval-item-title",children:[(0,t.jsx)("code",{children:e.toolName}),(0,t.jsx)("span",{"data-risk":e.riskClass,children:i(ts[e.riskClass]??"conversation.tool.risk.sensitive")})]}),"delegate_tasks"===e.toolName||"delegate_heroes"===e.toolName?(0,t.jsx)(tr,{item:e}):(0,t.jsx)("pre",{children:e.argumentsPreview}),(0,t.jsx)(ti,{item:e,checked:c.has(e.callIndex),onChange:u})]},`${e.callIndex}-${e.toolCallId}`))}),(0,t.jsxs)("div",{className:"approval-actions",children:[(0,t.jsx)("button",{type:"button",className:"secondary-btn",disabled:!!a,onClick:h,children:"rejected"===a?i("conversation.approval.rejecting"):i("conversation.approval.rejectBatch")}),(0,t.jsx)("button",{type:"button",disabled:!!a,onClick:p,children:"approved"===a?i("conversation.approval.approving"):i("conversation.approval.approveBatch")})]})]})}let to=o("image",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]]),tc=o("git-fork",[["circle",{cx:"12",cy:"18",r:"3",key:"1mpf1b"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["path",{d:"M18 9v2c0 .6-.4 1-1 1H7c-.6 0-1-.4-1-1V9",key:"1uq4wg"}],["path",{d:"M12 12v3",key:"158kv8"}]]);function td(e){return String(e).padStart(2,"0")}function tu(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function tp(e,t){return e.replace(/\{(\w+)\}/g,(e,n)=>t[n]??`{${n}}`)}function th({text:e,time:a,runMs:s,ttftMs:i,tokensPerSecond:r,branchMessageId:l,branchDisabled:o,onBranch:c}){let d,u,p,h,m=(0,f.useT)(),[g,x]=(0,n.useState)(!1),v=(0,n.useRef)(null),y=(0,n.useCallback)(()=>{navigator.clipboard?.writeText(e).then(()=>{x(!0),v.current&&clearTimeout(v.current),v.current=setTimeout(()=>x(!1),1e3)}).catch(()=>{})},[e]),b=a?function(e,t=Date.now()){let n=new Date(e);if(Number.isNaN(n.getTime()))return"";let a=new Date(t),s=`${td(n.getHours())}:${td(n.getMinutes())}`;if(n.getFullYear()===a.getFullYear()&&n.getMonth()===a.getMonth()&&n.getDate()===a.getDate())return s;let i=`${n.getMonth()+1}/${n.getDate()}`;return n.getFullYear()===a.getFullYear()?`${i} ${s}`:`${n.getFullYear()}/${i} ${s}`}(a):null,k=[];void 0!==s&&k.push(tp(m("message.ranFor"),{duration:(u=Math.floor((d=Math.max(0,Math.floor(s/1e3)))/60),p=d%60,u>0?tp(m("duration.minutes"),{minutes:String(u),seconds:String(p).padStart(2,"0")}):tp(m("duration.seconds"),{seconds:String(p)}))})),void 0!==i&&k.push(tp(m("message.ttft"),{seconds:(h=Math.max(0,i)/1e3)<10?String(Math.round(10*h)/10):String(Math.round(h))})),void 0!==r&&k.push(tp(m("message.tokensPerSecond"),{tps:eS(r)}));let j=[b,...k].filter(Boolean).join(" · "),w=!!(l&&c);return j||w||e?(0,t.jsxs)("div",{className:"message-actions",children:[j&&(0,t.jsx)("span",{className:"message-clock",children:j}),(0,t.jsx)("button",{type:"button",className:"message-action","aria-label":m(g?"copied":"copy"),title:m(g?"copied":"copy"),onClick:y,children:g?(0,t.jsx)(Y,{size:13,"aria-hidden":"true"}):(0,t.jsx)(Q,{size:13,"aria-hidden":"true"})}),w&&(0,t.jsx)("button",{type:"button",className:"message-action","aria-label":m("message.branch"),title:m("message.branch"),disabled:o,onClick:()=>c(l),children:(0,t.jsx)(tc,{size:13,"aria-hidden":"true"})})]}):null}function tm(){}function tf(){}var tg=e.i(76696);let tx=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,tv=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,ty={};function tb(e,t){return((t||ty).jsx?tv:tx).test(e)}var tk=e.i(24963),tj=e.i(40553);let tw={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"};var tN=e.i(57871),t_=e.i(59091),tC=e.i(15511);let tS=tP("end"),tI=tP("start");function tP(e){return function(t){let n=t&&t.position&&t.position[e]||{};if("number"==typeof n.line&&n.line>0&&"number"==typeof n.column&&n.column>0)return{line:n.line,column:n.column,offset:"number"==typeof n.offset&&n.offset>-1?n.offset:void 0}}}function tT(e){return e&&"object"==typeof e?"position"in e||"type"in e?tR(e.position):"start"in e||"end"in e?tR(e):"line"in e||"column"in e?tM(e):"":""}function tM(e){return tE(e&&e.line)+":"+tE(e&&e.column)}function tR(e){return tM(e&&e.start)+"-"+tM(e&&e.end)}function tE(e){return e&&"number"==typeof e?e:1}class tA extends Error{constructor(e,t,n){super(),"string"==typeof t&&(n=t,t=void 0);let a="",s={},i=!1;if(t&&(s="line"in t&&"column"in t||"start"in t&&"end"in t?{place:t}:"type"in t?{ancestors:[t],place:t.position}:{...t}),"string"==typeof e?a=e:!s.cause&&e&&(i=!0,a=e.message,s.cause=e),!s.ruleId&&!s.source&&"string"==typeof n){const e=n.indexOf(":");-1===e?s.ruleId=n:(s.source=n.slice(0,e),s.ruleId=n.slice(e+1))}if(!s.place&&s.ancestors&&s.ancestors){const e=s.ancestors[s.ancestors.length-1];e&&(s.place=e.position)}const r=s.place&&"start"in s.place?s.place.start:s.place;this.ancestors=s.ancestors||void 0,this.cause=s.cause||void 0,this.column=r?r.column:void 0,this.fatal=void 0,this.file="",this.message=a,this.line=r?r.line:void 0,this.name=tT(s.place)||"1:1",this.place=s.place||void 0,this.reason=this.message,this.ruleId=s.ruleId||void 0,this.source=s.source||void 0,this.stack=i&&s.cause&&"string"==typeof s.cause.stack?s.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}tA.prototype.file="",tA.prototype.name="",tA.prototype.reason="",tA.prototype.message="",tA.prototype.stack="",tA.prototype.column=void 0,tA.prototype.line=void 0,tA.prototype.ancestors=void 0,tA.prototype.cause=void 0,tA.prototype.fatal=void 0,tA.prototype.place=void 0,tA.prototype.ruleId=void 0,tA.prototype.source=void 0;let t$={}.hasOwnProperty,tz=new Map,tF=/[A-Z]/g,tL=new Set(["table","tbody","thead","tfoot","tr"]),tD=new Set(["td","th"]),tO="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function tq(e,t,n){var a,s,i,r,l,o,c,d,u;let p,h,m,f,g,x,v,y,b,k,j;return"element"===t.type?(a=e,s=t,i=n,h=p=a.schema,"svg"===s.tagName.toLowerCase()&&"html"===p.space&&(a.schema=tN.svg),a.ancestors.push(s),m=tW(a,s.tagName,!1),f=function(e,t){let n,a,s={};for(a in t.properties)if("children"!==a&&t$.call(t.properties,a)){let i=function(e,t,n){let a=(0,tj.find)(e.schema,t);if(!(null==n||"number"==typeof n&&Number.isNaN(n))){if(Array.isArray(n)&&(n=a.commaSeparated?(0,tg.stringify)(n):(0,t_.stringify)(n)),"style"===a.property){let t="object"==typeof n?n:function(e,t){try{return(0,tC.default)(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};let t=new tA("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:n,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw t.file=e.filePath||void 0,t.url=tO+"#cannot-parse-style-attribute",t}}(e,String(n));return"css"===e.stylePropertyNameCase&&(t=function(e){let t,n={};for(t in e)t$.call(e,t)&&(n[function(e){let t=e.replace(tF,tK);return"ms-"===t.slice(0,3)&&(t="-"+t),t}(t)]=e[t]);return n}(t)),["style",t]}return["react"===e.elementAttributeNameCase&&a.space?tw[a.property]||a.property:a.attribute,n]}}(e,a,t.properties[a]);if(i){let[a,r]=i;e.tableCellAlignToStyle&&"align"===a&&"string"==typeof r&&tD.has(t.tagName)?n=r:s[a]=r}}return n&&((s.style||(s.style={}))["css"===e.stylePropertyNameCase?"text-align":"textAlign"]=n),s}(a,s),g=tH(a,s),tL.has(s.tagName)&&(g=g.filter(function(e){return"string"!=typeof e||!(0,tk.whitespace)(e)})),tB(a,f,m,s),tU(f,g),a.ancestors.pop(),a.schema=p,a.create(s,m,f,i)):"mdxFlowExpression"===t.type||"mdxTextExpression"===t.type?function(e,t){if(t.data&&t.data.estree&&e.evaluater){let n=t.data.estree.body[0];return tm("ExpressionStatement"===n.type),e.evaluater.evaluateExpression(n.expression)}tV(e,t.position)}(e,t):"mdxJsxFlowElement"===t.type||"mdxJsxTextElement"===t.type?(r=e,l=t,o=n,v=x=r.schema,"svg"===l.name&&"html"===x.space&&(r.schema=tN.svg),r.ancestors.push(l),y=null===l.name?r.Fragment:tW(r,l.name,!0),b=function(e,t){let n={};for(let a of t.attributes)if("mdxJsxExpressionAttribute"===a.type)if(a.data&&a.data.estree&&e.evaluater){let t=a.data.estree.body[0];tm("ExpressionStatement"===t.type);let s=t.expression;tm("ObjectExpression"===s.type);let i=s.properties[0];tm("SpreadElement"===i.type),Object.assign(n,e.evaluater.evaluateExpression(i.argument))}else tV(e,t.position);else{let s,i=a.name;if(a.value&&"object"==typeof a.value)if(a.value.data&&a.value.data.estree&&e.evaluater){let t=a.value.data.estree.body[0];tm("ExpressionStatement"===t.type),s=e.evaluater.evaluateExpression(t.expression)}else tV(e,t.position);else s=null===a.value||a.value;n[i]=s}return n}(r,l),k=tH(r,l),tB(r,b,y,l),tU(b,k),r.ancestors.pop(),r.schema=x,r.create(l,y,b,o)):"mdxjsEsm"===t.type?function(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);tV(e,t.position)}(e,t):"root"===t.type?(c=e,d=t,u=n,tU(j={},tH(c,d)),c.create(d,c.Fragment,j,u)):"text"===t.type?t.value:void 0}function tB(e,t,n,a){"string"!=typeof n&&n!==e.Fragment&&e.passNode&&(t.node=a)}function tU(e,t){if(t.length>0){let n=t.length>1?t:t[0];n&&(e.children=n)}}function tH(e,t){let n=[],a=-1,s=e.passKeys?new Map:tz;for(;++a<t.children.length;){let i,r=t.children[a];if(e.passKeys){let e="element"===r.type?r.tagName:"mdxJsxFlowElement"===r.type||"mdxJsxTextElement"===r.type?r.name:void 0;if(e){let t=s.get(e)||0;i=e+"-"+t,s.set(e,t+1)}}let l=tq(e,r,i);void 0!==l&&n.push(l)}return n}function tW(e,t,n){let a;if(n)if(t.includes(".")){let e,n=t.split("."),s=-1;for(;++s<n.length;){let t=tb(n[s])?{type:"Identifier",name:n[s]}:{type:"Literal",value:n[s]};e=e?{type:"MemberExpression",object:e,property:t,computed:!!(s&&"Literal"===t.type),optional:!1}:t}tm(e,"always a result"),a=e}else a=tb(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};else a={type:"Literal",value:t};if("Literal"===a.type){let t=a.value;return t$.call(e.components,t)?e.components[t]:t}if(e.evaluater)return e.evaluater.evaluateExpression(a);tV(e)}function tV(e,t){let n=new tA("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw n.file=e.filePath||void 0,n.url=tO+"#cannot-handle-mdx-estrees-without-createevaluater",n}function tK(e){return"-"+e.toLowerCase()}let tG={action:["form"],cite:["blockquote","del","ins","q"],data:["object"],formAction:["button","input"],href:["a","area","base","link"],icon:["menuitem"],itemId:null,manifest:["html"],ping:["a","area"],poster:["video"],src:["audio","embed","iframe","img","input","script","source","track","video"]},tJ={};function tY(e,t){let n=t||tJ;return tQ(e,"boolean"!=typeof n.includeImageAlt||n.includeImageAlt,"boolean"!=typeof n.includeHtml||n.includeHtml)}function tQ(e,t,n){var a;if((a=e)&&"object"==typeof a){if("value"in e)return"html"!==e.type||n?e.value:"";if(t&&"alt"in e&&e.alt)return e.alt;if("children"in e)return tZ(e.children,t,n)}return Array.isArray(e)?tZ(e,t,n):""}function tZ(e,t,n){let a=[],s=-1;for(;++s<e.length;)a[s]=tQ(e[s],t,n);return a.join("")}function tX(e,t,n,a){let s,i=e.length,r=0;if(t=t<0?-t>i?0:i+t:t>i?i:t,n=n>0?n:0,a.length<1e4)(s=Array.from(a)).unshift(t,n),e.splice(...s);else for(n&&e.splice(t,n);r<a.length;)(s=a.slice(r,r+1e4)).unshift(t,0),e.splice(...s),r+=1e4,t+=1e4}function t0(e,t){return e.length>0?(tX(e,e.length,0,t),e):t}let t1={}.hasOwnProperty;function t2(e){let t={},n=-1;for(;++n<e.length;)!function(e,t){let n;for(n in t){let a,s=(t1.call(e,n)?e[n]:void 0)||(e[n]={}),i=t[n];if(i)for(a in i){t1.call(s,a)||(s[a]=[]);let e=i[a];!function(e,t){let n=-1,a=[];for(;++n<t.length;)("after"===t[n].add?e:a).push(t[n]);tX(e,0,0,a)}(s[a],Array.isArray(e)?e:e?[e]:[])}}}(t,e[n]);return t}let t4=ni(/[A-Za-z]/),t5=ni(/[\dA-Za-z]/),t3=ni(/[#-'*+\--9=?A-Z^-~]/);function t6(e){return null!==e&&(e<32||127===e)}let t8=ni(/\d/),t9=ni(/[\dA-Fa-f]/),t7=ni(/[!-/:-@[-`{-~]/);function ne(e){return null!==e&&e<-2}function nt(e){return null!==e&&(e<0||32===e)}function nn(e){return -2===e||-1===e||32===e}let na=ni(/\p{P}|\p{S}/u),ns=ni(/\s/);function ni(e){return function(t){return null!==t&&t>-1&&e.test(String.fromCharCode(t))}}function nr(e,t,n,a){let s=a?a-1:1/0,i=0;return function(a){return nn(a)?(e.enter(n),function a(r){return nn(r)&&i++<s?(e.consume(r),a):(e.exit(n),t(r))}(a)):t(a)}}let nl={tokenize:function(e){let t,n=e.attempt(this.parser.constructs.contentInitial,function(t){return null===t?void e.consume(t):(e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),nr(e,n,"linePrefix"))},function(n){return e.enter("paragraph"),function n(a){let s=e.enter("chunkText",{contentType:"text",previous:t});return t&&(t.next=s),t=s,function t(a){if(null===a){e.exit("chunkText"),e.exit("paragraph"),e.consume(a);return}return ne(a)?(e.consume(a),e.exit("chunkText"),n):(e.consume(a),t)}(a)}(n)});return n}},no={tokenize:function(e){let t,n,a,s=this,i=[],r=0;return l;function l(t){if(r<i.length){let n=i[r];return s.containerState=n[1],e.attempt(n[0].continuation,o,c)(t)}return c(t)}function o(e){if(r++,s.containerState._closeFlow){let n;s.containerState._closeFlow=void 0,t&&x();let a=s.events.length,i=a;for(;i--;)if("exit"===s.events[i][0]&&"chunkFlow"===s.events[i][1].type){n=s.events[i][1].end;break}g(r);let l=a;for(;l<s.events.length;)s.events[l][1].end={...n},l++;return tX(s.events,i+1,0,s.events.slice(a)),s.events.length=l,c(e)}return l(e)}function c(n){if(r===i.length){if(!t)return p(n);if(t.currentConstruct&&t.currentConstruct.concrete)return m(n);s.interrupt=!!(t.currentConstruct&&!t._gfmTableDynamicInterruptHack)}return s.containerState={},e.check(nc,d,u)(n)}function d(e){return t&&x(),g(r),p(e)}function u(e){return s.parser.lazy[s.now().line]=r!==i.length,a=s.now().offset,m(e)}function p(t){return s.containerState={},e.attempt(nc,h,m)(t)}function h(e){return r++,i.push([s.currentConstruct,s.containerState]),p(e)}function m(a){if(null===a){t&&x(),g(0),e.consume(a);return}return t=t||s.parser.flow(s.now()),e.enter("chunkFlow",{_tokenizer:t,contentType:"flow",previous:n}),function t(n){if(null===n){f(e.exit("chunkFlow"),!0),g(0),e.consume(n);return}return ne(n)?(e.consume(n),f(e.exit("chunkFlow")),r=0,s.interrupt=void 0,l):(e.consume(n),t)}(a)}function f(e,i){let l=s.sliceStream(e);if(i&&l.push(null),e.previous=n,n&&(n.next=e),n=e,t.defineSkip(e.start),t.write(l),s.parser.lazy[e.start.line]){let e,n,i=t.events.length;for(;i--;)if(t.events[i][1].start.offset<a&&(!t.events[i][1].end||t.events[i][1].end.offset>a))return;let l=s.events.length,o=l;for(;o--;)if("exit"===s.events[o][0]&&"chunkFlow"===s.events[o][1].type){if(e){n=s.events[o][1].end;break}e=!0}for(g(r),i=l;i<s.events.length;)s.events[i][1].end={...n},i++;tX(s.events,o+1,0,s.events.slice(l)),s.events.length=i}}function g(t){let n=i.length;for(;n-- >t;){let t=i[n];s.containerState=t[1],t[0].exit.call(s,e)}i.length=t}function x(){t.write([null]),n=void 0,t=void 0,s.containerState._closeFlow=void 0}}},nc={tokenize:function(e,t,n){return nr(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}},nd={partial:!0,tokenize:function(e,t,n){return function(t){return nn(t)?nr(e,a,"linePrefix")(t):a(t)};function a(e){return null===e||ne(e)?t(e):n(e)}}};class nu{constructor(e){this.left=e?[...e]:[],this.right=[]}get(e){if(e<0||e>=this.left.length+this.right.length)throw RangeError("Cannot access index `"+e+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return e<this.left.length?this.left[e]:this.right[this.right.length-e+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(e,t){let n=null==t?1/0:t;return n<this.left.length?this.left.slice(e,n):e>this.left.length?this.right.slice(this.right.length-n+this.left.length,this.right.length-e+this.left.length).reverse():this.left.slice(e).concat(this.right.slice(this.right.length-n+this.left.length).reverse())}splice(e,t,n){this.setCursor(Math.trunc(e));let a=this.right.splice(this.right.length-(t||0),1/0);return n&&np(this.left,n),a.reverse()}pop(){return this.setCursor(1/0),this.left.pop()}push(e){this.setCursor(1/0),this.left.push(e)}pushMany(e){this.setCursor(1/0),np(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),np(this.right,e.reverse())}setCursor(e){if(e!==this.left.length&&(!(e>this.left.length)||0!==this.right.length)&&(!(e<0)||0!==this.left.length))if(e<this.left.length){let t=this.left.splice(e,1/0);np(this.right,t.reverse())}else{let t=this.right.splice(this.left.length+this.right.length-e,1/0);np(this.left,t.reverse())}}}function np(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function nh(e){let t,n,a,s,i,r,l,o={},c=-1,d=new nu(e);for(;++c<d.length;){for(;c in o;)c=o[c];if(t=d.get(c),c&&"chunkFlow"===t[1].type&&"listItemPrefix"===d.get(c-1)[1].type&&((a=0)<(r=t[1]._tokenizer.events).length&&"lineEndingBlank"===r[a][1].type&&(a+=2),a<r.length&&"content"===r[a][1].type))for(;++a<r.length&&"content"!==r[a][1].type;)"chunkText"===r[a][1].type&&(r[a][1]._isInFirstContentOfListItem=!0,a++);if("enter"===t[0])t[1].contentType&&(Object.assign(o,function(e,t){let n,a,s=e.get(t)[1],i=e.get(t)[2],r=t-1,l=[],o=s._tokenizer;!o&&(o=i.parser[s.contentType](s.start),s._contentTypeTextTrailing&&(o._contentTypeTextTrailing=!0));let c=o.events,d=[],u={},p=-1,h=s,m=0,f=0,g=[0];for(;h;){for(;e.get(++r)[1]!==h;);l.push(r),!h._tokenizer&&(n=i.sliceStream(h),h.next||n.push(null),a&&o.defineSkip(h.start),h._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=!0),o.write(n),h._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=void 0)),a=h,h=h.next}for(h=s;++p<c.length;)"exit"===c[p][0]&&"enter"===c[p-1][0]&&c[p][1].type===c[p-1][1].type&&c[p][1].start.line!==c[p][1].end.line&&(f=p+1,g.push(f),h._tokenizer=void 0,h.previous=void 0,h=h.next);for(o.events=[],h?(h._tokenizer=void 0,h.previous=void 0):g.pop(),p=g.length;p--;){let t=c.slice(g[p],g[p+1]),n=l.pop();d.push([n,n+t.length-1]),e.splice(n,2,t)}for(d.reverse(),p=-1;++p<d.length;)u[m+d[p][0]]=m+d[p][1],m+=d[p][1]-d[p][0]-1;return u}(d,c)),c=o[c],l=!0);else if(t[1]._container){for(a=c,n=void 0;a--;)if("lineEnding"===(s=d.get(a))[1].type||"lineEndingBlank"===s[1].type)"enter"===s[0]&&(n&&(d.get(n)[1].type="lineEndingBlank"),s[1].type="lineEnding",n=a);else if("linePrefix"===s[1].type||"listItemIndent"===s[1].type);else break;n&&(t[1].end={...d.get(n)[1].start},(i=d.slice(n,c)).unshift(t),d.splice(n,c-n+1,i))}}return tX(e,0,1/0,d.slice(0)),!l}let nm={resolve:function(e){return nh(e),e},tokenize:function(e,t){let n;return function(t){return e.enter("content"),n=e.enter("chunkContent",{contentType:"content"}),a(t)};function a(t){return null===t?s(t):ne(t)?e.check(nf,i,s)(t):(e.consume(t),a)}function s(n){return e.exit("chunkContent"),e.exit("content"),t(n)}function i(t){return e.consume(t),e.exit("chunkContent"),n.next=e.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,a}}},nf={partial:!0,tokenize:function(e,t,n){let a=this;return function(t){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),nr(e,s,"linePrefix")};function s(s){if(null===s||ne(s))return n(s);let i=a.events[a.events.length-1];return!a.parser.constructs.disable.null.includes("codeIndented")&&i&&"linePrefix"===i[1].type&&i[2].sliceSerialize(i[1],!0).length>=4?t(s):e.interrupt(a.parser.constructs.flow,n,t)(s)}}},ng={tokenize:function(e){let t=this,n=e.attempt(nd,function(a){return null===a?void e.consume(a):(e.enter("lineEndingBlank"),e.consume(a),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n)},e.attempt(this.parser.constructs.flowInitial,a,nr(e,e.attempt(this.parser.constructs.flow,a,e.attempt(nm,a)),"linePrefix")));return n;function a(a){return null===a?void e.consume(a):(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),t.currentConstruct=void 0,n)}}},nx={resolveAll:nk()},nv=nb("string"),ny=nb("text");function nb(e){return{resolveAll:nk("text"===e?nj:void 0),tokenize:function(t){let n=this,a=this.parser.constructs[e],s=t.attempt(a,i,r);return i;function i(e){return o(e)?s(e):r(e)}function r(e){return null===e?void t.consume(e):(t.enter("data"),t.consume(e),l)}function l(e){return o(e)?(t.exit("data"),s(e)):(t.consume(e),l)}function o(e){if(null===e)return!0;let t=a[e],s=-1;if(t)for(;++s<t.length;){let e=t[s];if(!e.previous||e.previous.call(n,n.previous))return!0}return!1}}}}function nk(e){return function(t,n){let a,s=-1;for(;++s<=t.length;)void 0===a?t[s]&&"data"===t[s][1].type&&(a=s,s++):t[s]&&"data"===t[s][1].type||(s!==a+2&&(t[a][1].end=t[s-1][1].end,t.splice(a+2,s-a-2),s=a+2),a=void 0);return e?e(t,n):t}}function nj(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||"lineEnding"===e[n][1].type)&&"data"===e[n-1][1].type){let a,s=e[n-1][1],i=t.sliceStream(s),r=i.length,l=-1,o=0;for(;r--;){let e=i[r];if("string"==typeof e){for(l=e.length;32===e.charCodeAt(l-1);)o++,l--;if(l)break;l=-1}else if(-2===e)a=!0,o++;else if(-1===e);else{r++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(o=0),o){let i={type:n===e.length||a||o<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:r?l:s.start._bufferIndex+l,_index:s.start._index+r,line:s.end.line,column:s.end.column-o,offset:s.end.offset-o},end:{...s.end}};s.end={...i.start},s.start.offset===s.end.offset?Object.assign(s,i):(e.splice(n,0,["enter",i,t],["exit",i,t]),n+=2)}n++}return e}function nw(e){return null===e||nt(e)||ns(e)?1:na(e)?2:void 0}function nN(e,t,n){let a=[],s=-1;for(;++s<e.length;){let i=e[s].resolveAll;i&&!a.includes(i)&&(t=i(t,n),a.push(i))}return t}let n_={name:"attention",resolveAll:function(e,t){let n,a,s,i,r,l,o,c,d=-1;for(;++d<e.length;)if("enter"===e[d][0]&&"attentionSequence"===e[d][1].type&&e[d][1]._close){for(n=d;n--;)if("exit"===e[n][0]&&"attentionSequence"===e[n][1].type&&e[n][1]._open&&t.sliceSerialize(e[n][1]).charCodeAt(0)===t.sliceSerialize(e[d][1]).charCodeAt(0)){if((e[n][1]._close||e[d][1]._open)&&(e[d][1].end.offset-e[d][1].start.offset)%3&&!((e[n][1].end.offset-e[n][1].start.offset+e[d][1].end.offset-e[d][1].start.offset)%3))continue;l=e[n][1].end.offset-e[n][1].start.offset>1&&e[d][1].end.offset-e[d][1].start.offset>1?2:1;let u={...e[n][1].end},p={...e[d][1].start};nC(u,-l),nC(p,l),i={type:l>1?"strongSequence":"emphasisSequence",start:u,end:{...e[n][1].end}},r={type:l>1?"strongSequence":"emphasisSequence",start:{...e[d][1].start},end:p},s={type:l>1?"strongText":"emphasisText",start:{...e[n][1].end},end:{...e[d][1].start}},a={type:l>1?"strong":"emphasis",start:{...i.start},end:{...r.end}},e[n][1].end={...i.start},e[d][1].start={...r.end},o=[],e[n][1].end.offset-e[n][1].start.offset&&(o=t0(o,[["enter",e[n][1],t],["exit",e[n][1],t]])),o=t0(o,[["enter",a,t],["enter",i,t],["exit",i,t],["enter",s,t]]),o=t0(o,nN(t.parser.constructs.insideSpan.null,e.slice(n+1,d),t)),o=t0(o,[["exit",s,t],["enter",r,t],["exit",r,t],["exit",a,t]]),e[d][1].end.offset-e[d][1].start.offset?(c=2,o=t0(o,[["enter",e[d][1],t],["exit",e[d][1],t]])):c=0,tX(e,n-1,d-n+3,o),d=n+o.length-c-2;break}}for(d=-1;++d<e.length;)"attentionSequence"===e[d][1].type&&(e[d][1].type="data");return e},tokenize:function(e,t){let n,a=this.parser.constructs.attentionMarkers.null,s=this.previous,i=nw(s);return function(r){return n=r,e.enter("attentionSequence"),function r(l){if(l===n)return e.consume(l),r;let o=e.exit("attentionSequence"),c=nw(l),d=!c||2===c&&i||a.includes(l),u=!i||2===i&&c||a.includes(s);return o._open=!!(42===n?d:d&&(i||!u)),o._close=!!(42===n?u:u&&(c||!d)),t(l)}(r)}}};function nC(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}let nS={continuation:{tokenize:function(e,t,n){let a=this;return function(t){return nn(t)?nr(e,s,"linePrefix",a.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(t):s(t)};function s(a){return e.attempt(nS,t,n)(a)}}},exit:function(e){e.exit("blockQuote")},name:"blockQuote",tokenize:function(e,t,n){let a=this;return function(t){if(62===t){let n=a.containerState;return n.open||(e.enter("blockQuote",{_container:!0}),n.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(t),e.exit("blockQuoteMarker"),s}return n(t)};function s(n){return nn(n)?(e.enter("blockQuotePrefixWhitespace"),e.consume(n),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(n))}}},nI={name:"characterEscape",tokenize:function(e,t,n){return function(t){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(t),e.exit("escapeMarker"),a};function a(a){return t7(a)?(e.enter("characterEscapeValue"),e.consume(a),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(a)}}},nP=document.createElement("i");function nT(e){let t="&"+e+";";nP.innerHTML=t;let n=nP.textContent;return(59!==n.charCodeAt(n.length-1)||"semi"===e)&&n!==t&&n}let nM={name:"characterReference",tokenize:function(e,t,n){let a,s,i=this,r=0;return function(t){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(t),e.exit("characterReferenceMarker"),l};function l(t){return 35===t?(e.enter("characterReferenceMarkerNumeric"),e.consume(t),e.exit("characterReferenceMarkerNumeric"),o):(e.enter("characterReferenceValue"),a=31,s=t5,c(t))}function o(t){return 88===t||120===t?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(t),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),a=6,s=t9,c):(e.enter("characterReferenceValue"),a=7,s=t8,c(t))}function c(l){if(59===l&&r){let a=e.exit("characterReferenceValue");return s!==t5||nT(i.sliceSerialize(a))?(e.enter("characterReferenceMarker"),e.consume(l),e.exit("characterReferenceMarker"),e.exit("characterReference"),t):n(l)}return s(l)&&r++<a?(e.consume(l),c):n(l)}}},nR={partial:!0,tokenize:function(e,t,n){let a=this;return function(t){return null===t?n(t):(e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),s)};function s(e){return a.parser.lazy[a.now().line]?n(e):t(e)}}},nE={concrete:!0,name:"codeFenced",tokenize:function(e,t,n){let a,s=this,i={partial:!0,tokenize:function(e,t,n){let i=0;return function(t){return e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),r};function r(t){return e.enter("codeFencedFence"),nn(t)?nr(e,o,"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(t):o(t)}function o(t){return t===a?(e.enter("codeFencedFenceSequence"),function t(s){return s===a?(i++,e.consume(s),t):i>=l?(e.exit("codeFencedFenceSequence"),nn(s)?nr(e,c,"whitespace")(s):c(s)):n(s)}(t)):n(t)}function c(a){return null===a||ne(a)?(e.exit("codeFencedFence"),t(a)):n(a)}}},r=0,l=0;return function(t){var i;let c;return i=t,r=(c=s.events[s.events.length-1])&&"linePrefix"===c[1].type?c[2].sliceSerialize(c[1],!0).length:0,a=i,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),function t(s){return s===a?(l++,e.consume(s),t):l<3?n(s):(e.exit("codeFencedFenceSequence"),nn(s)?nr(e,o,"whitespace")(s):o(s))}(i)};function o(i){return null===i||ne(i)?(e.exit("codeFencedFence"),s.interrupt?t(i):e.check(nR,d,m)(i)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),function t(s){return null===s||ne(s)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),o(s)):nn(s)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),nr(e,c,"whitespace")(s)):96===s&&s===a?n(s):(e.consume(s),t)}(i))}function c(t){return null===t||ne(t)?o(t):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),function t(s){return null===s||ne(s)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),o(s)):96===s&&s===a?n(s):(e.consume(s),t)}(t))}function d(t){return e.attempt(i,m,u)(t)}function u(t){return e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),p}function p(t){return r>0&&nn(t)?nr(e,h,"linePrefix",r+1)(t):h(t)}function h(t){return null===t||ne(t)?e.check(nR,d,m)(t):(e.enter("codeFlowValue"),function t(n){return null===n||ne(n)?(e.exit("codeFlowValue"),h(n)):(e.consume(n),t)}(t))}function m(n){return e.exit("codeFenced"),t(n)}}},nA={name:"codeIndented",tokenize:function(e,t,n){let a=this;return function(t){return e.enter("codeIndented"),nr(e,s,"linePrefix",5)(t)};function s(t){let s=a.events[a.events.length-1];return s&&"linePrefix"===s[1].type&&s[2].sliceSerialize(s[1],!0).length>=4?function t(n){return null===n?i(n):ne(n)?e.attempt(n$,t,i)(n):(e.enter("codeFlowValue"),function n(a){return null===a||ne(a)?(e.exit("codeFlowValue"),t(a)):(e.consume(a),n)}(n))}(t):n(t)}function i(n){return e.exit("codeIndented"),t(n)}}},n$={partial:!0,tokenize:function(e,t,n){let a=this;return s;function s(t){return a.parser.lazy[a.now().line]?n(t):ne(t)?(e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),s):nr(e,i,"linePrefix",5)(t)}function i(e){let i=a.events[a.events.length-1];return i&&"linePrefix"===i[1].type&&i[2].sliceSerialize(i[1],!0).length>=4?t(e):ne(e)?s(e):n(e)}}};function nz(e,t,n,a,s,i,r,l,o){let c=o||1/0,d=0;return function(t){return 60===t?(e.enter(a),e.enter(s),e.enter(i),e.consume(t),e.exit(i),u):null===t||32===t||41===t||t6(t)?n(t):(e.enter(a),e.enter(r),e.enter(l),e.enter("chunkString",{contentType:"string"}),m(t))};function u(n){return 62===n?(e.enter(i),e.consume(n),e.exit(i),e.exit(s),e.exit(a),t):(e.enter(l),e.enter("chunkString",{contentType:"string"}),p(n))}function p(t){return 62===t?(e.exit("chunkString"),e.exit(l),u(t)):null===t||60===t||ne(t)?n(t):(e.consume(t),92===t?h:p)}function h(t){return 60===t||62===t||92===t?(e.consume(t),p):p(t)}function m(s){return!d&&(null===s||41===s||nt(s))?(e.exit("chunkString"),e.exit(l),e.exit(r),e.exit(a),t(s)):d<c&&40===s?(e.consume(s),d++,m):41===s?(e.consume(s),d--,m):null===s||32===s||40===s||t6(s)?n(s):(e.consume(s),92===s?f:m)}function f(t){return 40===t||41===t||92===t?(e.consume(t),m):m(t)}}function nF(e,t,n,a,s,i){let r,l=this,o=0;return function(t){return e.enter(a),e.enter(s),e.consume(t),e.exit(s),e.enter(i),c};function c(u){return o>999||null===u||91===u||93===u&&!r||94===u&&!o&&"_hiddenFootnoteSupport"in l.parser.constructs?n(u):93===u?(e.exit(i),e.enter(s),e.consume(u),e.exit(s),e.exit(a),t):ne(u)?(e.enter("lineEnding"),e.consume(u),e.exit("lineEnding"),c):(e.enter("chunkString",{contentType:"string"}),d(u))}function d(t){return null===t||91===t||93===t||ne(t)||o++>999?(e.exit("chunkString"),c(t)):(e.consume(t),r||(r=!nn(t)),92===t?u:d)}function u(t){return 91===t||92===t||93===t?(e.consume(t),o++,d):d(t)}}function nL(e,t,n,a,s,i){let r;return function(t){return 34===t||39===t||40===t?(e.enter(a),e.enter(s),e.consume(t),e.exit(s),r=40===t?41:t,l):n(t)};function l(n){return n===r?(e.enter(s),e.consume(n),e.exit(s),e.exit(a),t):(e.enter(i),o(n))}function o(t){return t===r?(e.exit(i),l(r)):null===t?n(t):ne(t)?(e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),nr(e,o,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),c(t))}function c(t){return t===r||null===t||ne(t)?(e.exit("chunkString"),o(t)):(e.consume(t),92===t?d:c)}function d(t){return t===r||92===t?(e.consume(t),c):c(t)}}function nD(e,t){let n;return function a(s){return ne(s)?(e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),n=!0,a):nn(s)?nr(e,a,n?"linePrefix":"lineSuffix")(s):t(s)}}function nO(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}let nq={partial:!0,tokenize:function(e,t,n){return function(t){return nt(t)?nD(e,a)(t):n(t)};function a(t){return nL(e,s,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(t)}function s(t){return nn(t)?nr(e,i,"whitespace")(t):i(t)}function i(e){return null===e||ne(e)?t(e):n(e)}}},nB=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],nU=["pre","script","style","textarea"],nH={partial:!0,tokenize:function(e,t,n){return function(a){return e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),e.attempt(nd,t,n)}}},nW={partial:!0,tokenize:function(e,t,n){let a=this;return function(t){return ne(t)?(e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),s):n(t)};function s(e){return a.parser.lazy[a.now().line]?n(e):t(e)}}},nV={name:"labelEnd",resolveAll:function(e){let t=-1,n=[];for(;++t<e.length;){let a=e[t][1];if(n.push(e[t]),"labelImage"===a.type||"labelLink"===a.type||"labelEnd"===a.type){let e="labelImage"===a.type?4:2;a.type="data",t+=e}}return e.length!==n.length&&tX(e,0,e.length,n),e},resolveTo:function(e,t){let n,a,s,i,r=e.length,l=0;for(;r--;)if(n=e[r][1],a){if("link"===n.type||"labelLink"===n.type&&n._inactive)break;"enter"===e[r][0]&&"labelLink"===n.type&&(n._inactive=!0)}else if(s){if("enter"===e[r][0]&&("labelImage"===n.type||"labelLink"===n.type)&&!n._balanced&&(a=r,"labelLink"!==n.type)){l=2;break}}else"labelEnd"===n.type&&(s=r);let o={type:"labelLink"===e[a][1].type?"link":"image",start:{...e[a][1].start},end:{...e[e.length-1][1].end}},c={type:"label",start:{...e[a][1].start},end:{...e[s][1].end}},d={type:"labelText",start:{...e[a+l+2][1].end},end:{...e[s-2][1].start}};return i=t0(i=[["enter",o,t],["enter",c,t]],e.slice(a+1,a+l+3)),i=t0(i,[["enter",d,t]]),i=t0(i,nN(t.parser.constructs.insideSpan.null,e.slice(a+l+4,s-3),t)),i=t0(i,[["exit",d,t],e[s-2],e[s-1],["exit",c,t]]),i=t0(i,e.slice(s+1)),i=t0(i,[["exit",o,t]]),tX(e,a,e.length,i),e},tokenize:function(e,t,n){let a,s,i=this,r=i.events.length;for(;r--;)if(("labelImage"===i.events[r][1].type||"labelLink"===i.events[r][1].type)&&!i.events[r][1]._balanced){a=i.events[r][1];break}return function(t){return a?a._inactive?d(t):(s=i.parser.defined.includes(nO(i.sliceSerialize({start:a.end,end:i.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(t),e.exit("labelMarker"),e.exit("labelEnd"),l):n(t)};function l(t){return 40===t?e.attempt(nK,c,s?c:d)(t):91===t?e.attempt(nG,c,s?o:d)(t):s?c(t):d(t)}function o(t){return e.attempt(nJ,c,d)(t)}function c(e){return t(e)}function d(e){return a._balanced=!0,n(e)}}},nK={tokenize:function(e,t,n){return function(t){return e.enter("resource"),e.enter("resourceMarker"),e.consume(t),e.exit("resourceMarker"),a};function a(t){return nt(t)?nD(e,s)(t):s(t)}function s(t){return 41===t?c(t):nz(e,i,r,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(t)}function i(t){return nt(t)?nD(e,l)(t):c(t)}function r(e){return n(e)}function l(t){return 34===t||39===t||40===t?nL(e,o,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(t):c(t)}function o(t){return nt(t)?nD(e,c)(t):c(t)}function c(a){return 41===a?(e.enter("resourceMarker"),e.consume(a),e.exit("resourceMarker"),e.exit("resource"),t):n(a)}}},nG={tokenize:function(e,t,n){let a=this;return function(t){return nF.call(a,e,s,i,"reference","referenceMarker","referenceString")(t)};function s(e){return a.parser.defined.includes(nO(a.sliceSerialize(a.events[a.events.length-1][1]).slice(1,-1)))?t(e):n(e)}function i(e){return n(e)}}},nJ={tokenize:function(e,t,n){return function(t){return e.enter("reference"),e.enter("referenceMarker"),e.consume(t),e.exit("referenceMarker"),a};function a(a){return 93===a?(e.enter("referenceMarker"),e.consume(a),e.exit("referenceMarker"),e.exit("reference"),t):n(a)}}},nY={name:"labelStartImage",resolveAll:nV.resolveAll,tokenize:function(e,t,n){let a=this;return function(t){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(t),e.exit("labelImageMarker"),s};function s(t){return 91===t?(e.enter("labelMarker"),e.consume(t),e.exit("labelMarker"),e.exit("labelImage"),i):n(t)}function i(e){return 94===e&&"_hiddenFootnoteSupport"in a.parser.constructs?n(e):t(e)}}},nQ={name:"labelStartLink",resolveAll:nV.resolveAll,tokenize:function(e,t,n){let a=this;return function(t){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(t),e.exit("labelMarker"),e.exit("labelLink"),s};function s(e){return 94===e&&"_hiddenFootnoteSupport"in a.parser.constructs?n(e):t(e)}}},nZ={name:"lineEnding",tokenize:function(e,t){return function(n){return e.enter("lineEnding"),e.consume(n),e.exit("lineEnding"),nr(e,t,"linePrefix")}}},nX={name:"thematicBreak",tokenize:function(e,t,n){let a,s=0;return function(i){var r;return e.enter("thematicBreak"),a=r=i,function i(r){return r===a?(e.enter("thematicBreakSequence"),function t(n){return n===a?(e.consume(n),s++,t):(e.exit("thematicBreakSequence"),nn(n)?nr(e,i,"whitespace")(n):i(n))}(r)):s>=3&&(null===r||ne(r))?(e.exit("thematicBreak"),t(r)):n(r)}(r)}}},n0={continuation:{tokenize:function(e,t,n){let a=this;return a.containerState._closeFlow=void 0,e.check(nd,function(n){return a.containerState.furtherBlankLines=a.containerState.furtherBlankLines||a.containerState.initialBlankLine,nr(e,t,"listItemIndent",a.containerState.size+1)(n)},function(n){return a.containerState.furtherBlankLines||!nn(n)?(a.containerState.furtherBlankLines=void 0,a.containerState.initialBlankLine=void 0,s(n)):(a.containerState.furtherBlankLines=void 0,a.containerState.initialBlankLine=void 0,e.attempt(n2,t,s)(n))});function s(s){return a.containerState._closeFlow=!0,a.interrupt=void 0,nr(e,e.attempt(n0,t,n),"linePrefix",a.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(s)}}},exit:function(e){e.exit(this.containerState.type)},name:"list",tokenize:function(e,t,n){let a=this,s=a.events[a.events.length-1],i=s&&"linePrefix"===s[1].type?s[2].sliceSerialize(s[1],!0).length:0,r=0;return function(t){let s=a.containerState.type||(42===t||43===t||45===t?"listUnordered":"listOrdered");if("listUnordered"===s?!a.containerState.marker||t===a.containerState.marker:t8(t)){if(a.containerState.type||(a.containerState.type=s,e.enter(s,{_container:!0})),"listUnordered"===s)return e.enter("listItemPrefix"),42===t||45===t?e.check(nX,n,l)(t):l(t);if(!a.interrupt||49===t)return e.enter("listItemPrefix"),e.enter("listItemValue"),function t(s){return t8(s)&&++r<10?(e.consume(s),t):(!a.interrupt||r<2)&&(a.containerState.marker?s===a.containerState.marker:41===s||46===s)?(e.exit("listItemValue"),l(s)):n(s)}(t)}return n(t)};function l(t){return e.enter("listItemMarker"),e.consume(t),e.exit("listItemMarker"),a.containerState.marker=a.containerState.marker||t,e.check(nd,a.interrupt?n:o,e.attempt(n1,d,c))}function o(e){return a.containerState.initialBlankLine=!0,i++,d(e)}function c(t){return nn(t)?(e.enter("listItemPrefixWhitespace"),e.consume(t),e.exit("listItemPrefixWhitespace"),d):n(t)}function d(n){return a.containerState.size=i+a.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(n)}}},n1={partial:!0,tokenize:function(e,t,n){let a=this;return nr(e,function(e){let s=a.events[a.events.length-1];return!nn(e)&&s&&"listItemPrefixWhitespace"===s[1].type?t(e):n(e)},"listItemPrefixWhitespace",a.parser.constructs.disable.null.includes("codeIndented")?void 0:5)}},n2={partial:!0,tokenize:function(e,t,n){let a=this;return nr(e,function(e){let s=a.events[a.events.length-1];return s&&"listItemIndent"===s[1].type&&s[2].sliceSerialize(s[1],!0).length===a.containerState.size?t(e):n(e)},"listItemIndent",a.containerState.size+1)}},n4={name:"setextUnderline",resolveTo:function(e,t){let n,a,s,i=e.length;for(;i--;)if("enter"===e[i][0]){if("content"===e[i][1].type){n=i;break}"paragraph"===e[i][1].type&&(a=i)}else"content"===e[i][1].type&&e.splice(i,1),s||"definition"!==e[i][1].type||(s=i);let r={type:"setextHeading",start:{...e[n][1].start},end:{...e[e.length-1][1].end}};return e[a][1].type="setextHeadingText",s?(e.splice(a,0,["enter",r,t]),e.splice(s+1,0,["exit",e[n][1],t]),e[n][1].end={...e[s][1].end}):e[n][1]=r,e.push(["exit",r,t]),e},tokenize:function(e,t,n){let a,s=this;return function(t){var r;let l,o=s.events.length;for(;o--;)if("lineEnding"!==s.events[o][1].type&&"linePrefix"!==s.events[o][1].type&&"content"!==s.events[o][1].type){l="paragraph"===s.events[o][1].type;break}return!s.parser.lazy[s.now().line]&&(s.interrupt||l)?(e.enter("setextHeadingLine"),a=t,r=t,e.enter("setextHeadingLineSequence"),function t(n){return n===a?(e.consume(n),t):(e.exit("setextHeadingLineSequence"),nn(n)?nr(e,i,"lineSuffix")(n):i(n))}(r)):n(t)};function i(a){return null===a||ne(a)?(e.exit("setextHeadingLine"),t(a)):n(a)}}};e.s(["attentionMarkers",0,{null:[42,95]},"contentInitial",0,{91:{name:"definition",tokenize:function(e,t,n){let a,s=this;return function(t){var a;return e.enter("definition"),a=t,nF.call(s,e,i,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(a)};function i(t){return(a=nO(s.sliceSerialize(s.events[s.events.length-1][1]).slice(1,-1)),58===t)?(e.enter("definitionMarker"),e.consume(t),e.exit("definitionMarker"),r):n(t)}function r(t){return nt(t)?nD(e,l)(t):l(t)}function l(t){return nz(e,o,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(t)}function o(t){return e.attempt(nq,c,c)(t)}function c(t){return nn(t)?nr(e,d,"whitespace")(t):d(t)}function d(i){return null===i||ne(i)?(e.exit("definition"),s.parser.defined.push(a),t(i)):n(i)}}}},"disable",0,{null:[]},"document",0,{42:n0,43:n0,45:n0,48:n0,49:n0,50:n0,51:n0,52:n0,53:n0,54:n0,55:n0,56:n0,57:n0,62:nS},"flow",0,{35:{name:"headingAtx",resolve:function(e,t){let n,a,s=e.length-2,i=3;return"whitespace"===e[3][1].type&&(i+=2),s-2>i&&"whitespace"===e[s][1].type&&(s-=2),"atxHeadingSequence"===e[s][1].type&&(i===s-1||s-4>i&&"whitespace"===e[s-2][1].type)&&(s-=i+1===s?2:4),s>i&&(n={type:"atxHeadingText",start:e[i][1].start,end:e[s][1].end},a={type:"chunkText",start:e[i][1].start,end:e[s][1].end,contentType:"text"},tX(e,i,s-i+1,[["enter",n,t],["enter",a,t],["exit",a,t],["exit",n,t]])),e},tokenize:function(e,t,n){let a=0;return function(s){var i;return e.enter("atxHeading"),i=s,e.enter("atxHeadingSequence"),function s(i){return 35===i&&a++<6?(e.consume(i),s):null===i||nt(i)?(e.exit("atxHeadingSequence"),function n(a){return 35===a?(e.enter("atxHeadingSequence"),function t(a){return 35===a?(e.consume(a),t):(e.exit("atxHeadingSequence"),n(a))}(a)):null===a||ne(a)?(e.exit("atxHeading"),t(a)):nn(a)?nr(e,n,"whitespace")(a):(e.enter("atxHeadingText"),function t(a){return null===a||35===a||nt(a)?(e.exit("atxHeadingText"),n(a)):(e.consume(a),t)}(a))}(i)):n(i)}(i)}}},42:nX,45:[n4,nX],60:{concrete:!0,name:"htmlFlow",resolveTo:function(e){let t=e.length;for(;t--&&("enter"!==e[t][0]||"htmlFlow"!==e[t][1].type););return t>1&&"linePrefix"===e[t-2][1].type&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e},tokenize:function(e,t,n){let a,s,i,r,l,o=this;return function(t){var n;return n=t,e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(n),c};function c(r){return 33===r?(e.consume(r),d):47===r?(e.consume(r),s=!0,h):63===r?(e.consume(r),a=3,o.interrupt?t:R):t4(r)?(e.consume(r),i=String.fromCharCode(r),m):n(r)}function d(s){return 45===s?(e.consume(s),a=2,u):91===s?(e.consume(s),a=5,r=0,p):t4(s)?(e.consume(s),a=4,o.interrupt?t:R):n(s)}function u(a){return 45===a?(e.consume(a),o.interrupt?t:R):n(a)}function p(a){let s="CDATA[";return a===s.charCodeAt(r++)?(e.consume(a),r===s.length)?o.interrupt?t:N:p:n(a)}function h(t){return t4(t)?(e.consume(t),i=String.fromCharCode(t),m):n(t)}function m(r){if(null===r||47===r||62===r||nt(r)){let l=47===r,c=i.toLowerCase();return!l&&!s&&nU.includes(c)?(a=1,o.interrupt?t(r):N(r)):nB.includes(i.toLowerCase())?(a=6,l)?(e.consume(r),f):o.interrupt?t(r):N(r):(a=7,o.interrupt&&!o.parser.lazy[o.now().line]?n(r):s?function t(n){return nn(n)?(e.consume(n),t):j(n)}(r):g(r))}return 45===r||t5(r)?(e.consume(r),i+=String.fromCharCode(r),m):n(r)}function f(a){return 62===a?(e.consume(a),o.interrupt?t:N):n(a)}function g(t){return 47===t?(e.consume(t),j):58===t||95===t||t4(t)?(e.consume(t),x):nn(t)?(e.consume(t),g):j(t)}function x(t){return 45===t||46===t||58===t||95===t||t5(t)?(e.consume(t),x):v(t)}function v(t){return 61===t?(e.consume(t),y):nn(t)?(e.consume(t),v):g(t)}function y(t){return null===t||60===t||61===t||62===t||96===t?n(t):34===t||39===t?(e.consume(t),l=t,b):nn(t)?(e.consume(t),y):function t(n){return null===n||34===n||39===n||47===n||60===n||61===n||62===n||96===n||nt(n)?v(n):(e.consume(n),t)}(t)}function b(t){return t===l?(e.consume(t),l=null,k):null===t||ne(t)?n(t):(e.consume(t),b)}function k(e){return 47===e||62===e||nn(e)?g(e):n(e)}function j(t){return 62===t?(e.consume(t),w):n(t)}function w(t){return null===t||ne(t)?N(t):nn(t)?(e.consume(t),w):n(t)}function N(t){return 45===t&&2===a?(e.consume(t),I):60===t&&1===a?(e.consume(t),P):62===t&&4===a?(e.consume(t),E):63===t&&3===a?(e.consume(t),R):93===t&&5===a?(e.consume(t),M):ne(t)&&(6===a||7===a)?(e.exit("htmlFlowData"),e.check(nH,A,_)(t)):null===t||ne(t)?(e.exit("htmlFlowData"),_(t)):(e.consume(t),N)}function _(t){return e.check(nW,C,A)(t)}function C(t){return e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),S}function S(t){return null===t||ne(t)?_(t):(e.enter("htmlFlowData"),N(t))}function I(t){return 45===t?(e.consume(t),R):N(t)}function P(t){return 47===t?(e.consume(t),i="",T):N(t)}function T(t){if(62===t){let n=i.toLowerCase();return nU.includes(n)?(e.consume(t),E):N(t)}return t4(t)&&i.length<8?(e.consume(t),i+=String.fromCharCode(t),T):N(t)}function M(t){return 93===t?(e.consume(t),R):N(t)}function R(t){return 62===t?(e.consume(t),E):45===t&&2===a?(e.consume(t),R):N(t)}function E(t){return null===t||ne(t)?(e.exit("htmlFlowData"),A(t)):(e.consume(t),E)}function A(n){return e.exit("htmlFlow"),t(n)}}},61:n4,95:nX,96:nE,126:nE},"flowInitial",0,{[-2]:nA,[-1]:nA,32:nA},"insideSpan",0,{null:[n_,nx]},"string",0,{38:nM,92:nI},"text",0,{[-5]:nZ,[-4]:nZ,[-3]:nZ,33:nY,38:nM,42:n_,60:[{name:"autolink",tokenize:function(e,t,n){let a=0;return function(t){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(t),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),s};function s(t){return t4(t)?(e.consume(t),i):64===t?n(t):l(t)}function i(t){return 43===t||45===t||46===t||t5(t)?(a=1,function t(n){return 58===n?(e.consume(n),a=0,r):(43===n||45===n||46===n||t5(n))&&a++<32?(e.consume(n),t):(a=0,l(n))}(t)):l(t)}function r(a){return 62===a?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(a),e.exit("autolinkMarker"),e.exit("autolink"),t):null===a||32===a||60===a||t6(a)?n(a):(e.consume(a),r)}function l(t){return 64===t?(e.consume(t),o):t3(t)?(e.consume(t),l):n(t)}function o(s){return t5(s)?function s(i){return 46===i?(e.consume(i),a=0,o):62===i?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(i),e.exit("autolinkMarker"),e.exit("autolink"),t):function t(i){if((45===i||t5(i))&&a++<63){let n=45===i?t:s;return e.consume(i),n}return n(i)}(i)}(s):n(s)}}},{name:"htmlText",tokenize:function(e,t,n){let a,s,i,r=this;return function(t){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(t),l};function l(t){return 33===t?(e.consume(t),o):47===t?(e.consume(t),b):63===t?(e.consume(t),v):t4(t)?(e.consume(t),j):n(t)}function o(t){return 45===t?(e.consume(t),c):91===t?(e.consume(t),s=0,h):t4(t)?(e.consume(t),x):n(t)}function c(t){return 45===t?(e.consume(t),p):n(t)}function d(t){return null===t?n(t):45===t?(e.consume(t),u):ne(t)?(i=d,T(t)):(e.consume(t),d)}function u(t){return 45===t?(e.consume(t),p):d(t)}function p(e){return 62===e?P(e):45===e?u(e):d(e)}function h(t){let a="CDATA[";return t===a.charCodeAt(s++)?(e.consume(t),s===a.length?m:h):n(t)}function m(t){return null===t?n(t):93===t?(e.consume(t),f):ne(t)?(i=m,T(t)):(e.consume(t),m)}function f(t){return 93===t?(e.consume(t),g):m(t)}function g(t){return 62===t?P(t):93===t?(e.consume(t),g):m(t)}function x(t){return null===t||62===t?P(t):ne(t)?(i=x,T(t)):(e.consume(t),x)}function v(t){return null===t?n(t):63===t?(e.consume(t),y):ne(t)?(i=v,T(t)):(e.consume(t),v)}function y(e){return 62===e?P(e):v(e)}function b(t){return t4(t)?(e.consume(t),k):n(t)}function k(t){return 45===t||t5(t)?(e.consume(t),k):function t(n){return ne(n)?(i=t,T(n)):nn(n)?(e.consume(n),t):P(n)}(t)}function j(t){return 45===t||t5(t)?(e.consume(t),j):47===t||62===t||nt(t)?w(t):n(t)}function w(t){return 47===t?(e.consume(t),P):58===t||95===t||t4(t)?(e.consume(t),N):ne(t)?(i=w,T(t)):nn(t)?(e.consume(t),w):P(t)}function N(t){return 45===t||46===t||58===t||95===t||t5(t)?(e.consume(t),N):function t(n){return 61===n?(e.consume(n),_):ne(n)?(i=t,T(n)):nn(n)?(e.consume(n),t):w(n)}(t)}function _(t){return null===t||60===t||61===t||62===t||96===t?n(t):34===t||39===t?(e.consume(t),a=t,C):ne(t)?(i=_,T(t)):nn(t)?(e.consume(t),_):(e.consume(t),S)}function C(t){return t===a?(e.consume(t),a=void 0,I):null===t?n(t):ne(t)?(i=C,T(t)):(e.consume(t),C)}function S(t){return null===t||34===t||39===t||60===t||61===t||96===t?n(t):47===t||62===t||nt(t)?w(t):(e.consume(t),S)}function I(e){return 47===e||62===e||nt(e)?w(e):n(e)}function P(a){return 62===a?(e.consume(a),e.exit("htmlTextData"),e.exit("htmlText"),t):n(a)}function T(t){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),M}function M(t){return nn(t)?nr(e,R,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(t):R(t)}function R(t){return e.enter("htmlTextData"),i(t)}}}],91:nQ,92:[{name:"hardBreakEscape",tokenize:function(e,t,n){return function(t){return e.enter("hardBreakEscape"),e.consume(t),a};function a(a){return ne(a)?(e.exit("hardBreakEscape"),t(a)):n(a)}}},nI],93:nV,95:n_,96:{name:"codeText",previous:function(e){return 96!==e||"characterEscape"===this.events[this.events.length-1][1].type},resolve:function(e){let t,n,a=e.length-4,s=3;if(("lineEnding"===e[3][1].type||"space"===e[s][1].type)&&("lineEnding"===e[a][1].type||"space"===e[a][1].type)){for(t=s;++t<a;)if("codeTextData"===e[t][1].type){e[s][1].type="codeTextPadding",e[a][1].type="codeTextPadding",s+=2,a-=2;break}}for(t=s-1,a++;++t<=a;)void 0===n?t!==a&&"lineEnding"!==e[t][1].type&&(n=t):(t===a||"lineEnding"===e[t][1].type)&&(e[n][1].type="codeTextData",t!==n+2&&(e[n][1].end=e[t-1][1].end,e.splice(n+2,t-n-2),a-=t-n-2,t=n+2),n=void 0);return e},tokenize:function(e,t,n){let a,s,i=0;return function(t){return e.enter("codeText"),e.enter("codeTextSequence"),function t(n){return 96===n?(e.consume(n),i++,t):(e.exit("codeTextSequence"),r(n))}(t)};function r(o){return null===o?n(o):32===o?(e.enter("space"),e.consume(o),e.exit("space"),r):96===o?(s=e.enter("codeTextSequence"),a=0,function n(r){return 96===r?(e.consume(r),a++,n):a===i?(e.exit("codeTextSequence"),e.exit("codeText"),t(r)):(s.type="codeTextData",l(r))}(o)):ne(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),r):(e.enter("codeTextData"),l(o))}function l(t){return null===t||32===t||96===t||ne(t)?(e.exit("codeTextData"),r(t)):(e.consume(t),l)}}}}],4127);var n5=e.i(4127);let n3=/[\0\t\n\r]/g;function n6(e,t){let n=Number.parseInt(e,t);return n<9||11===n||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(65535&n)==65535||(65535&n)==65534||n>1114111?"�":String.fromCodePoint(n)}let n8=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function n9(e,t,n){if(t)return t;if(35===n.charCodeAt(0)){let e=n.charCodeAt(1),t=120===e||88===e;return n6(n.slice(t?2:1),t?16:10)}return nT(n)||e}let n7={}.hasOwnProperty;function ae(e){return{line:e.line,column:e.column,offset:e.offset}}function at(e,t){if(e)throw Error("Cannot close `"+e.type+"` ("+tT({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+tT({start:t.start,end:t.end})+") is open");throw Error("Cannot close document, a token (`"+t.type+"`, "+tT({start:t.start,end:t.end})+") is still open")}function an(e){let t=this;t.parser=function(n){var a,s;let i,r,l,o;return"object"==typeof(a={...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})&&(s=a,a=void 0),(function(e){let t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:a(x),autolinkProtocol:c,autolinkEmail:c,atxHeading:a(m),blockQuote:a(function(){return{type:"blockquote",children:[]}}),characterEscape:c,characterReference:c,codeFenced:a(h),codeFencedFenceInfo:s,codeFencedFenceMeta:s,codeIndented:a(h,s),codeText:a(function(){return{type:"inlineCode",value:""}},s),codeTextData:c,data:c,codeFlowValue:c,definition:a(function(){return{type:"definition",identifier:"",label:null,title:null,url:""}}),definitionDestinationString:s,definitionLabelString:s,definitionTitleString:s,emphasis:a(function(){return{type:"emphasis",children:[]}}),hardBreakEscape:a(f),hardBreakTrailing:a(f),htmlFlow:a(g,s),htmlFlowData:c,htmlText:a(g,s),htmlTextData:c,image:a(function(){return{type:"image",title:null,url:"",alt:null}}),label:s,link:a(x),listItem:a(function(e){return{type:"listItem",spread:e._spread,checked:null,children:[]}}),listItemValue:function(e){this.data.expectingFirstListItemValue&&(this.stack[this.stack.length-2].start=Number.parseInt(this.sliceSerialize(e),10),this.data.expectingFirstListItemValue=void 0)},listOrdered:a(v,function(){this.data.expectingFirstListItemValue=!0}),listUnordered:a(v),paragraph:a(function(){return{type:"paragraph",children:[]}}),reference:function(){this.data.referenceType="collapsed"},referenceString:s,resourceDestinationString:s,resourceTitleString:s,setextHeading:a(m),strong:a(function(){return{type:"strong",children:[]}}),thematicBreak:a(function(){return{type:"thematicBreak"}})},exit:{atxHeading:r(),atxHeadingSequence:function(e){let t=this.stack[this.stack.length-1];t.depth||(t.depth=this.sliceSerialize(e).length)},autolink:r(),autolinkEmail:function(e){d.call(this,e),this.stack[this.stack.length-1].url="mailto:"+this.sliceSerialize(e)},autolinkProtocol:function(e){d.call(this,e),this.stack[this.stack.length-1].url=this.sliceSerialize(e)},blockQuote:r(),characterEscapeValue:d,characterReferenceMarkerHexadecimal:p,characterReferenceMarkerNumeric:p,characterReferenceValue:function(e){let t,n=this.sliceSerialize(e),a=this.data.characterReferenceType;a?(t=n6(n,"characterReferenceMarkerNumeric"===a?10:16),this.data.characterReferenceType=void 0):t=nT(n);let s=this.stack[this.stack.length-1];s.value+=t},characterReference:function(e){this.stack.pop().position.end=ae(e.end)},codeFenced:r(function(){let e=this.resume();this.stack[this.stack.length-1].value=e.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}),codeFencedFence:function(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)},codeFencedFenceInfo:function(){let e=this.resume();this.stack[this.stack.length-1].lang=e},codeFencedFenceMeta:function(){let e=this.resume();this.stack[this.stack.length-1].meta=e},codeFlowValue:d,codeIndented:r(function(){let e=this.resume();this.stack[this.stack.length-1].value=e.replace(/(\r?\n|\r)$/g,"")}),codeText:r(function(){let e=this.resume();this.stack[this.stack.length-1].value=e}),codeTextData:d,data:d,definition:r(),definitionDestinationString:function(){let e=this.resume();this.stack[this.stack.length-1].url=e},definitionLabelString:function(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=nO(this.sliceSerialize(e)).toLowerCase()},definitionTitleString:function(){let e=this.resume();this.stack[this.stack.length-1].title=e},emphasis:r(),hardBreakEscape:r(u),hardBreakTrailing:r(u),htmlFlow:r(function(){let e=this.resume();this.stack[this.stack.length-1].value=e}),htmlFlowData:d,htmlText:r(function(){let e=this.resume();this.stack[this.stack.length-1].value=e}),htmlTextData:d,image:r(function(){let e=this.stack[this.stack.length-1];if(this.data.inReference){let t=this.data.referenceType||"shortcut";e.type+="Reference",e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}),label:function(){let e=this.stack[this.stack.length-1],t=this.resume(),n=this.stack[this.stack.length-1];this.data.inReference=!0,"link"===n.type?n.children=e.children:n.alt=t},labelText:function(e){let t=this.sliceSerialize(e),n=this.stack[this.stack.length-2];n.label=t.replace(n8,n9),n.identifier=nO(t).toLowerCase()},lineEnding:function(e){let n=this.stack[this.stack.length-1];if(this.data.atHardBreak){n.children[n.children.length-1].position.end=ae(e.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(n.type)&&(c.call(this,e),d.call(this,e))},link:r(function(){let e=this.stack[this.stack.length-1];if(this.data.inReference){let t=this.data.referenceType||"shortcut";e.type+="Reference",e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}),listItem:r(),listOrdered:r(),listUnordered:r(),paragraph:r(),referenceString:function(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=nO(this.sliceSerialize(e)).toLowerCase(),this.data.referenceType="full"},resourceDestinationString:function(){let e=this.resume();this.stack[this.stack.length-1].url=e},resourceTitleString:function(){let e=this.resume();this.stack[this.stack.length-1].title=e},resource:function(){this.data.inReference=void 0},setextHeading:r(function(){this.data.setextHeadingSlurpLineEnding=void 0}),setextHeadingLineSequence:function(e){this.stack[this.stack.length-1].depth=61===this.sliceSerialize(e).codePointAt(0)?1:2},setextHeadingText:function(){this.data.setextHeadingSlurpLineEnding=!0},strong:r(),thematicBreak:r()}};!function e(t,n){let a=-1;for(;++a<n.length;){let s=n[a];Array.isArray(s)?e(t,s):function(e,t){let n;for(n in t)if(n7.call(t,n))switch(n){case"canContainEols":{let a=t[n];a&&e[n].push(...a);break}case"transforms":{let a=t[n];a&&e[n].push(...a);break}case"enter":case"exit":{let a=t[n];a&&Object.assign(e[n],a)}}}(t,s)}}(t,(e||{}).mdastExtensions||[]);let n={};return function(e){let a={type:"root",children:[]},r={stack:[a],tokenStack:[],config:t,enter:i,exit:l,buffer:s,resume:o,data:n},c=[],d=-1;for(;++d<e.length;)("listOrdered"===e[d][1].type||"listUnordered"===e[d][1].type)&&("enter"===e[d][0]?c.push(d):d=function(e,t,n){let a,s,i,r,l=t-1,o=-1,c=!1;for(;++l<=n;){let t=e[l];switch(t[1].type){case"listUnordered":case"listOrdered":case"blockQuote":"enter"===t[0]?o++:o--,r=void 0;break;case"lineEndingBlank":"enter"===t[0]&&(!a||r||o||i||(i=l),r=void 0);break;case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:r=void 0}if(!o&&"enter"===t[0]&&"listItemPrefix"===t[1].type||-1===o&&"exit"===t[0]&&("listUnordered"===t[1].type||"listOrdered"===t[1].type)){if(a){let r=l;for(s=void 0;r--;){let t=e[r];if("lineEnding"===t[1].type||"lineEndingBlank"===t[1].type){if("exit"===t[0])continue;s&&(e[s][1].type="lineEndingBlank",c=!0),t[1].type="lineEnding",s=r}else if("linePrefix"===t[1].type||"blockQuotePrefix"===t[1].type||"blockQuotePrefixWhitespace"===t[1].type||"blockQuoteMarker"===t[1].type||"listItemIndent"===t[1].type);else break}i&&(!s||i<s)&&(a._spread=!0),a.end=Object.assign({},s?e[s][1].start:t[1].end),e.splice(s||l,0,["exit",a,t[2]]),l++,n++}if("listItemPrefix"===t[1].type){let s={type:"listItem",_spread:!1,start:Object.assign({},t[1].start),end:void 0};a=s,e.splice(l,0,["enter",s,t[2]]),l++,n++,i=void 0,r=!0}}}return e[t][1]._spread=c,n}(e,c.pop(),d));for(d=-1;++d<e.length;){let n=t[e[d][0]];n7.call(n,e[d][1].type)&&n[e[d][1].type].call(Object.assign({sliceSerialize:e[d][2].sliceSerialize},r),e[d][1])}if(r.tokenStack.length>0){let e=r.tokenStack[r.tokenStack.length-1];(e[1]||at).call(r,void 0,e[0])}for(a.position={start:ae(e.length>0?e[0][1].start:{line:1,column:1,offset:0}),end:ae(e.length>0?e[e.length-2][1].end:{line:1,column:1,offset:0})},d=-1;++d<t.transforms.length;)a=t.transforms[d](a)||a;return a};function a(e,t){return function(n){i.call(this,e(n),n),t&&t.call(this,n)}}function s(){this.stack.push({type:"fragment",children:[]})}function i(e,t,n){this.stack[this.stack.length-1].children.push(e),this.stack.push(e),this.tokenStack.push([t,n||void 0]),e.position={start:ae(t.start),end:void 0}}function r(e){return function(t){e&&e.call(this,t),l.call(this,t)}}function l(e,t){let n=this.stack.pop(),a=this.tokenStack.pop();if(a)a[0].type!==e.type&&(t?t.call(this,e,a[0]):(a[1]||at).call(this,e,a[0]));else throw Error("Cannot close `"+e.type+"` ("+tT({start:e.start,end:e.end})+"): it’s not open");n.position.end=ae(e.end)}function o(){return tY(this.stack.pop())}function c(e){let t=this.stack[this.stack.length-1].children,n=t[t.length-1];n&&"text"===n.type||((n={type:"text",value:""}).position={start:ae(e.start),end:void 0},t.push(n)),this.stack.push(n)}function d(e){let t=this.stack.pop();t.value+=this.sliceSerialize(e),t.position.end=ae(e.end)}function u(){this.data.atHardBreak=!0}function p(e){this.data.characterReferenceType=e.type}function h(){return{type:"code",lang:null,meta:null,value:""}}function m(){return{type:"heading",depth:0,children:[]}}function f(){return{type:"break"}}function g(){return{type:"html",value:""}}function x(){return{type:"link",title:null,url:"",children:[]}}function v(e){return{type:"list",ordered:"listOrdered"===e.type,start:null,spread:e._spread,children:[]}}})(s)(function(e){for(;!nh(e););return e}((function(e){let t={constructs:t2([n5,...(e||{}).extensions||[]]),content:n(nl),defined:[],document:n(no),flow:n(ng),lazy:{},string:n(nv),text:n(ny)};return t;function n(e){return function(n){return function(e,t,n){let a={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0},s={},i=[],r=[],l=[],o={attempt:m(function(e,t){f(e,t.from)}),check:m(h),consume:function(e){ne(e)?(a.line++,a.column=1,a.offset+=-3===e?2:1,g()):-1!==e&&(a.column++,a.offset++),a._bufferIndex<0?a._index++:(a._bufferIndex++,a._bufferIndex===r[a._index].length&&(a._bufferIndex=-1,a._index++)),c.previous=e},enter:function(e,t){let n=t||{};return n.type=e,n.start=p(),c.events.push(["enter",n,c]),l.push(n),n},exit:function(e){let t=l.pop();return t.end=p(),c.events.push(["exit",t,c]),t},interrupt:m(h,{interrupt:!0})},c={code:null,containerState:{},defineSkip:function(e){s[e.line]=e.column,g()},events:[],now:p,parser:e,previous:null,sliceSerialize:function(e,t){return function(e,t){let n,a=-1,s=[];for(;++a<e.length;){let i,r=e[a];if("string"==typeof r)i=r;else switch(r){case -5:i="\r";break;case -4:i="\n";break;case -3:i="\r\n";break;case -2:i=t?" ":" ";break;case -1:if(!t&&n)continue;i=" ";break;default:i=String.fromCharCode(r)}n=-2===r,s.push(i)}return s.join("")}(u(e),t)},sliceStream:u,write:function(e){return(r=t0(r,e),function(){let e;for(;a._index<r.length;){let n=r[a._index];if("string"==typeof n)for(e=a._index,a._bufferIndex<0&&(a._bufferIndex=0);a._index===e&&a._bufferIndex<n.length;){var t;t=n.charCodeAt(a._bufferIndex),d=d(t)}else d=d(n)}}(),null!==r[r.length-1])?[]:(f(t,0),c.events=nN(i,c.events,c),c.events)}},d=t.tokenize.call(c,o);return t.resolveAll&&i.push(t),c;function u(e){return function(e,t){let n,a=t.start._index,s=t.start._bufferIndex,i=t.end._index,r=t.end._bufferIndex;if(a===i)n=[e[a].slice(s,r)];else{if(n=e.slice(a,i),s>-1){let e=n[0];"string"==typeof e?n[0]=e.slice(s):n.shift()}r>0&&n.push(e[i].slice(0,r))}return n}(r,e)}function p(){let{_bufferIndex:e,_index:t,line:n,column:s,offset:i}=a;return{_bufferIndex:e,_index:t,line:n,column:s,offset:i}}function h(e,t){t.restore()}function m(e,t){return function(n,s,i){var r;let d,u,h,m;return Array.isArray(n)?f(n):"tokenize"in n?f([n]):(r=n,function(e){let t=null!==e&&r[e],n=null!==e&&r.null;return f([...Array.isArray(t)?t:t?[t]:[],...Array.isArray(n)?n:n?[n]:[]])(e)});function f(e){return(d=e,u=0,0===e.length)?i:x(e[u])}function x(e){return function(n){let s,i,r,d,u;return(s=p(),i=c.previous,r=c.currentConstruct,d=c.events.length,u=Array.from(l),m={from:d,restore:function(){a=s,c.previous=i,c.currentConstruct=r,c.events.length=d,l=u,g()}},h=e,e.partial||(c.currentConstruct=e),e.name&&c.parser.constructs.disable.null.includes(e.name))?y(n):e.tokenize.call(t?Object.assign(Object.create(c),t):c,o,v,y)(n)}}function v(t){return e(h,m),s}function y(e){return(m.restore(),++u<d.length)?x(d[u]):i}}}function f(e,t){e.resolveAll&&!i.includes(e)&&i.push(e),e.resolve&&tX(c.events,t,c.events.length-t,e.resolve(c.events.slice(t),c)),e.resolveTo&&(c.events=e.resolveTo(c.events,c))}function g(){a.line in s&&a.column<2&&(a.column=s[a.line],a.offset+=s[a.line]-1)}}(t,e,n)}}})(s).document().write((r=1,l="",o=!0,function(e,t,n){let a,s,c,d,u,p=[];for(e=l+("string"==typeof e?e.toString():new TextDecoder(t||void 0).decode(e)),c=0,l="",o&&(65279===e.charCodeAt(0)&&c++,o=void 0);c<e.length;){if(n3.lastIndex=c,d=(a=n3.exec(e))&&void 0!==a.index?a.index:e.length,u=e.charCodeAt(d),!a){l=e.slice(c);break}if(10===u&&c===d&&i)p.push(-3),i=void 0;else switch(i&&(p.push(-5),i=void 0),c<d&&(p.push(e.slice(c,d)),r+=d-c),u){case 0:p.push(65533),r++;break;case 9:for(s=4*Math.ceil(r/4),p.push(-2);r++<s;)p.push(-1);break;case 10:p.push(-4),r=1;break;default:i=!0,r=1}c=d+1}return n&&(i&&p.push(-5),l&&p.push(l),p.push(null)),p})(n,a,!0))))}}let aa="object"==typeof self?self:globalThis,as=(e,t)=>{switch(e){case"Function":case"SharedWorker":case"Worker":case"eval":case"setInterval":case"setTimeout":throw TypeError("unable to deserialize "+e)}return new aa[e](t)},ai=e=>{var t;let n,a;return(t=new Map,n=(e,n)=>(t.set(n,e),e),a=s=>{if(t.has(s))return t.get(s);let[i,r]=e[s];switch(i){case 0:case -1:return n(r,s);case 1:{let e=n([],s);for(let t of r)e.push(a(t));return e}case 2:{let e=n({},s);for(let[t,n]of r)e[a(t)]=a(n);return e}case 3:return n(new Date(r),s);case 4:{let{source:e,flags:t}=r;return n(new RegExp(e,t),s)}case 5:{let e=n(new Map,s);for(let[t,n]of r)e.set(a(t),a(n));return e}case 6:{let e=n(new Set,s);for(let t of r)e.add(a(t));return e}case 7:{let{name:e,message:t}=r;return n("function"==typeof aa[e]?as(e,t):Error(t),s)}case 8:return n(BigInt(r),s);case"BigInt":return n(Object(BigInt(r)),s);case"ArrayBuffer":return n(new Uint8Array(r).buffer,r);case"DataView":{let{buffer:e}=new Uint8Array(r);return n(new DataView(e),r)}}return n(as(i,r),s)})(0)},{toString:ar}={},{keys:al}=Object,ao=e=>{let t=typeof e;if("object"!==t||!e)return[0,t];let n=ar.call(e).slice(8,-1);switch(n){case"Array":return[1,""];case"Object":return[2,""];case"Date":return[3,""];case"RegExp":return[4,""];case"Map":return[5,""];case"Set":return[6,""];case"DataView":return[1,n]}return n.includes("Array")?[1,n]:e instanceof Error?[7,e.name||"Error"]:[2,n]},ac=([e,t])=>0===e&&("function"===t||"symbol"===t),ad=(e,{json:t,lossy:n}={})=>{var a,s,i;let r,l,o=[];return(a=!(t||n),s=!!t,i=new Map,r=(e,t)=>{let n=o.push(e)-1;return i.set(t,n),n},l=e=>{if(i.has(e))return i.get(e);let[t,n]=ao(e);switch(t){case 0:{let s=e;switch(n){case"bigint":t=8,s=e.toString();break;case"function":case"symbol":if(a)throw TypeError("unable to serialize "+n);s=null;break;case"undefined":return r([-1],e)}return r([t,s],e)}case 1:{if(n){let t=e;return"DataView"===n?t=new Uint8Array(e.buffer):"ArrayBuffer"===n&&(t=new Uint8Array(e)),r([n,[...t]],e)}let a=[],s=r([t,a],e);for(let t of e)a.push(l(t));return s}case 2:{if(n)switch(n){case"BigInt":return r([n,e.toString()],e);case"Boolean":case"Number":case"String":return r([n,e.valueOf()],e)}if(s&&"toJSON"in e)return l(e.toJSON());let i=[],o=r([t,i],e);for(let t of al(e))(a||!ac(ao(e[t])))&&i.push([l(t),l(e[t])]);return o}case 3:return r([t,isNaN(e.getTime())?"":e.toISOString()],e);case 4:{let{source:n,flags:a}=e;return r([t,{source:n,flags:a}],e)}case 5:{let n=[],s=r([t,n],e);for(let[t,s]of e)(a||!(ac(ao(t))||ac(ao(s))))&&n.push([l(t),l(s)]);return s}case 6:{let n=[],s=r([t,n],e);for(let t of e)(a||!ac(ao(t)))&&n.push(l(t));return s}}let{message:o}=e;return r([t,{name:n,message:o}],e)})(e),o},au="function"==typeof structuredClone?(e,t)=>t&&("json"in t||"lossy"in t)?ai(ad(e,t)):structuredClone(e):(e,t)=>ai(ad(e,t));function ap(e){let t=[],n=-1,a=0,s=0;for(;++n<e.length;){let i=e.charCodeAt(n),r="";if(37===i&&t5(e.charCodeAt(n+1))&&t5(e.charCodeAt(n+2)))s=2;else if(i<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(i))||(r=String.fromCharCode(i));else if(i>55295&&i<57344){let t=e.charCodeAt(n+1);i<56320&&t>56319&&t<57344?(r=String.fromCharCode(i,t),s=1):r="�"}else r=String.fromCharCode(i);r&&(t.push(e.slice(a,n),encodeURIComponent(r)),a=n+s+1,r=""),s&&(n+=s,s=0)}return t.join("")+e.slice(a)}function ah(e,t){let n=[{type:"text",value:"↩"}];return t>1&&n.push({type:"element",tagName:"sup",properties:{},children:[{type:"text",value:String(t)}]}),n}function am(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}let af=function(e){var t,n;if(null==e)return ax;if("function"==typeof e)return ag(e);if("object"==typeof e){return Array.isArray(e)?function(e){let t=[],n=-1;for(;++n<e.length;)t[n]=af(e[n]);return ag(function(...e){let n=-1;for(;++n<t.length;)if(t[n].apply(this,e))return!0;return!1})}(e):(t=e,ag(function(e){let n;for(n in t)if(e[n]!==t[n])return!1;return!0}))}if("string"==typeof e){return n=e,ag(function(e){return e&&e.type===n})}throw Error("Expected function, string, or object as test")};function ag(e){return function(t,n,a){return!!(function(e){return null!==e&&"object"==typeof e&&"type"in e}(t)&&e.call(this,t,"number"==typeof n?n:void 0,a||void 0))}}function ax(){return!0}let av=[];function ay(e,t,n,a){let s;"function"==typeof t&&"function"!=typeof n?(a=n,n=t):s=t;let i=af(s),r=a?-1:1;(function e(s,l,o){let c=s&&"object"==typeof s?s:{};if("string"==typeof c.type){let e="string"==typeof c.tagName?c.tagName:"string"==typeof c.name?c.name:void 0;Object.defineProperty(d,"name",{value:"node ("+s.type+(e?"<"+e+">":"")+")"})}return d;function d(){var c;let d,u,p,h=av;if((!t||i(s,l,o[o.length-1]||void 0))&&!1===(h=Array.isArray(c=n(s,o))?c:"number"==typeof c?[!0,c]:null==c?av:[c])[0])return h;if("children"in s&&s.children&&s.children&&"skip"!==h[0])for(u=(a?s.children.length:-1)+r,p=o.concat(s);u>-1&&u<s.children.length;){if(!1===(d=e(s.children[u],u,p)())[0])return d;u="number"==typeof d[1]?d[1]:u+r}return h}})(e,void 0,[])()}function ab(e,t,n,a){let s,i,r;"function"==typeof t&&"function"!=typeof n?(i=void 0,r=t,s=n):(i=t,r=n,s=a),ay(e,i,function(e,t){let n=t[t.length-1],a=n?n.children.indexOf(e):void 0;return r(e,a,n)},s)}function ak(e,t){let n=t.referenceType,a="]";if("collapsed"===n?a+="[]":"full"===n&&(a+="["+(t.label||t.identifier)+"]"),"imageReference"===t.type)return[{type:"text",value:"!["+t.alt+a}];let s=e.all(t),i=s[0];i&&"text"===i.type?i.value="["+i.value:s.unshift({type:"text",value:"["});let r=s[s.length-1];return r&&"text"===r.type?r.value+=a:s.push({type:"text",value:a}),s}function aj(e){let t=e.spread;return null==t?e.children.length>1:t}function aw(e,t,n){let a=0,s=e.length;if(t){let t=e.codePointAt(a);for(;9===t||32===t;)a++,t=e.codePointAt(a)}if(n){let t=e.codePointAt(s-1);for(;9===t||32===t;)s--,t=e.codePointAt(s-1)}return s>a?e.slice(a,s):""}let aN={blockquote:function(e,t){let n={type:"element",tagName:"blockquote",properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)},break:function(e,t){let n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:"\n"}]},code:function(e,t){let n=t.value?t.value+"\n":"",a={},s=t.lang?t.lang.split(/\s+/):[];s.length>0&&(a.className=["language-"+s[0]]);let i={type:"element",tagName:"code",properties:a,children:[{type:"text",value:n}]};return t.meta&&(i.data={meta:t.meta}),e.patch(t,i),i={type:"element",tagName:"pre",properties:{},children:[i=e.applyData(t,i)]},e.patch(t,i),i},delete:function(e,t){let n={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},emphasis:function(e,t){let n={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},footnoteReference:function(e,t){let n,a="string"==typeof e.options.clobberPrefix?e.options.clobberPrefix:"user-content-",s=String(t.identifier).toUpperCase(),i=ap(s.toLowerCase()),r=e.footnoteOrder.indexOf(s),l=e.footnoteCounts.get(s);void 0===l?(l=0,e.footnoteOrder.push(s),n=e.footnoteOrder.length):n=r+1,l+=1,e.footnoteCounts.set(s,l);let o={type:"element",tagName:"a",properties:{href:"#"+a+"fn-"+i,id:a+"fnref-"+i+(l>1?"-"+l:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(n)}]};e.patch(t,o);let c={type:"element",tagName:"sup",properties:{},children:[o]};return e.patch(t,c),e.applyData(t,c)},heading:function(e,t){let n={type:"element",tagName:"h"+t.depth,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},html:function(e,t){if(e.options.allowDangerousHtml){let n={type:"raw",value:t.value};return e.patch(t,n),e.applyData(t,n)}},imageReference:function(e,t){let n=String(t.identifier).toUpperCase(),a=e.definitionById.get(n);if(!a)return ak(e,t);let s={src:ap(a.url||""),alt:t.alt};null!==a.title&&void 0!==a.title&&(s.title=a.title);let i={type:"element",tagName:"img",properties:s,children:[]};return e.patch(t,i),e.applyData(t,i)},image:function(e,t){let n={src:ap(t.url)};null!==t.alt&&void 0!==t.alt&&(n.alt=t.alt),null!==t.title&&void 0!==t.title&&(n.title=t.title);let a={type:"element",tagName:"img",properties:n,children:[]};return e.patch(t,a),e.applyData(t,a)},inlineCode:function(e,t){let n={type:"text",value:t.value.replace(/\r?\n|\r/g," ")};e.patch(t,n);let a={type:"element",tagName:"code",properties:{},children:[n]};return e.patch(t,a),e.applyData(t,a)},linkReference:function(e,t){let n=String(t.identifier).toUpperCase(),a=e.definitionById.get(n);if(!a)return ak(e,t);let s={href:ap(a.url||"")};null!==a.title&&void 0!==a.title&&(s.title=a.title);let i={type:"element",tagName:"a",properties:s,children:e.all(t)};return e.patch(t,i),e.applyData(t,i)},link:function(e,t){let n={href:ap(t.url)};null!==t.title&&void 0!==t.title&&(n.title=t.title);let a={type:"element",tagName:"a",properties:n,children:e.all(t)};return e.patch(t,a),e.applyData(t,a)},listItem:function(e,t,n){let a=e.all(t),s=n?function(e){let t=!1;if("list"===e.type){t=e.spread||!1;let n=e.children,a=-1;for(;!t&&++a<n.length;)t=aj(n[a])}return t}(n):aj(t),i={},r=[];if("boolean"==typeof t.checked){let e,n=a[0];n&&"element"===n.type&&"p"===n.tagName?e=n:(e={type:"element",tagName:"p",properties:{},children:[]},a.unshift(e)),e.children.length>0&&e.children.unshift({type:"text",value:" "}),e.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:t.checked,disabled:!0},children:[]}),i.className=["task-list-item"]}let l=-1;for(;++l<a.length;){let e=a[l];(s||0!==l||"element"!==e.type||"p"!==e.tagName)&&r.push({type:"text",value:"\n"}),"element"!==e.type||"p"!==e.tagName||s?r.push(e):r.push(...e.children)}let o=a[a.length-1];o&&(s||"element"!==o.type||"p"!==o.tagName)&&r.push({type:"text",value:"\n"});let c={type:"element",tagName:"li",properties:i,children:r};return e.patch(t,c),e.applyData(t,c)},list:function(e,t){let n={},a=e.all(t),s=-1;for("number"==typeof t.start&&1!==t.start&&(n.start=t.start);++s<a.length;){let e=a[s];if("element"===e.type&&"li"===e.tagName&&e.properties&&Array.isArray(e.properties.className)&&e.properties.className.includes("task-list-item")){n.className=["contains-task-list"];break}}let i={type:"element",tagName:t.ordered?"ol":"ul",properties:n,children:e.wrap(a,!0)};return e.patch(t,i),e.applyData(t,i)},paragraph:function(e,t){let n={type:"element",tagName:"p",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},root:function(e,t){let n={type:"root",children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)},strong:function(e,t){let n={type:"element",tagName:"strong",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},table:function(e,t){let n=e.all(t),a=n.shift(),s=[];if(a){let n={type:"element",tagName:"thead",properties:{},children:e.wrap([a],!0)};e.patch(t.children[0],n),s.push(n)}if(n.length>0){let a={type:"element",tagName:"tbody",properties:{},children:e.wrap(n,!0)},i=tI(t.children[1]),r=tS(t.children[t.children.length-1]);i&&r&&(a.position={start:i,end:r}),s.push(a)}let i={type:"element",tagName:"table",properties:{},children:e.wrap(s,!0)};return e.patch(t,i),e.applyData(t,i)},tableCell:function(e,t){let n={type:"element",tagName:"td",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},tableRow:function(e,t,n){let a=n?n.children:void 0,s=0===(a?a.indexOf(t):1)?"th":"td",i=n&&"table"===n.type?n.align:void 0,r=i?i.length:t.children.length,l=-1,o=[];for(;++l<r;){let n=t.children[l],a={},r=i?i[l]:void 0;r&&(a.align=r);let c={type:"element",tagName:s,properties:a,children:[]};n&&(c.children=e.all(n),e.patch(n,c),c=e.applyData(n,c)),o.push(c)}let c={type:"element",tagName:"tr",properties:{},children:e.wrap(o,!0)};return e.patch(t,c),e.applyData(t,c)},text:function(e,t){let n={type:"text",value:function(e){let t=String(e),n=/\r?\n|\r/g,a=n.exec(t),s=0,i=[];for(;a;)i.push(aw(t.slice(s,a.index),s>0,!0),a[0]),s=a.index+a[0].length,a=n.exec(t);return i.push(aw(t.slice(s),s>0,!1)),i.join("")}(String(t.value))};return e.patch(t,n),e.applyData(t,n)},thematicBreak:function(e,t){let n={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)},toml:a_,yaml:a_,definition:a_,footnoteDefinition:a_};function a_(){}let aC={}.hasOwnProperty,aS={};function aI(e,t){e.position&&(t.position=function(e){let t=tI(e),n=tS(e);if(t&&n)return{start:t,end:n}}(e))}function aP(e,t){let n=t;if(e&&e.data){let t=e.data.hName,a=e.data.hChildren,s=e.data.hProperties;"string"==typeof t&&("element"===n.type?n.tagName=t:n={type:"element",tagName:t,properties:{},children:"children"in n?n.children:[n]}),"element"===n.type&&s&&Object.assign(n.properties,au(s)),"children"in n&&n.children&&null!=a&&(n.children=a)}return n}function aT(e,t){let n=[],a=-1;for(t&&n.push({type:"text",value:"\n"});++a<e.length;)a&&n.push({type:"text",value:"\n"}),n.push(e[a]);return t&&e.length>0&&n.push({type:"text",value:"\n"}),n}function aM(e){let t=0,n=e.charCodeAt(t);for(;9===n||32===n;)t++,n=e.charCodeAt(t);return e.slice(t)}function aR(e,t){let n,a,s,i,r=(n=t||aS,a=new Map,s=new Map,i={all:function(e){let t=[];if("children"in e){let n=e.children,a=-1;for(;++a<n.length;){let s=i.one(n[a],e);if(s){if(a&&"break"===n[a-1].type&&(Array.isArray(s)||"text"!==s.type||(s.value=aM(s.value)),!Array.isArray(s)&&"element"===s.type)){let e=s.children[0];e&&"text"===e.type&&(e.value=aM(e.value))}Array.isArray(s)?t.push(...s):t.push(s)}}}return t},applyData:aP,definitionById:a,footnoteById:s,footnoteCounts:new Map,footnoteOrder:[],handlers:{...aN,...n.handlers},one:function(e,t){let n=e.type,a=i.handlers[n];if(aC.call(i.handlers,n)&&a)return a(i,e,t);if(i.options.passThrough&&i.options.passThrough.includes(n)){if("children"in e){let{children:t,...n}=e,a=au(n);return a.children=i.all(e),a}return au(e)}return(i.options.unknownHandler||function(e,t){let n=t.data||{},a="value"in t&&!(aC.call(n,"hProperties")||aC.call(n,"hChildren"))?{type:"text",value:t.value}:{type:"element",tagName:"div",properties:{},children:e.all(t)};return e.patch(t,a),e.applyData(t,a)})(i,e,t)},options:n,patch:aI,wrap:aT},ab(e,function(e){if("definition"===e.type||"footnoteDefinition"===e.type){let t="definition"===e.type?a:s,n=String(e.identifier).toUpperCase();t.has(n)||t.set(n,e)}}),i),l=r.one(e,void 0),o=function(e){let t="string"==typeof e.options.clobberPrefix?e.options.clobberPrefix:"user-content-",n=e.options.footnoteBackContent||ah,a=e.options.footnoteBackLabel||am,s=e.options.footnoteLabel||"Footnotes",i=e.options.footnoteLabelTagName||"h2",r=e.options.footnoteLabelProperties||{className:["sr-only"]},l=[],o=-1;for(;++o<e.footnoteOrder.length;){let s=e.footnoteById.get(e.footnoteOrder[o]);if(!s)continue;let i=e.all(s),r=String(s.identifier).toUpperCase(),c=ap(r.toLowerCase()),d=0,u=[],p=e.footnoteCounts.get(r);for(;void 0!==p&&++d<=p;){u.length>0&&u.push({type:"text",value:" "});let e="string"==typeof n?n:n(o,d);"string"==typeof e&&(e={type:"text",value:e}),u.push({type:"element",tagName:"a",properties:{href:"#"+t+"fnref-"+c+(d>1?"-"+d:""),dataFootnoteBackref:"",ariaLabel:"string"==typeof a?a:a(o,d),className:["data-footnote-backref"]},children:Array.isArray(e)?e:[e]})}let h=i[i.length-1];if(h&&"element"===h.type&&"p"===h.tagName){let e=h.children[h.children.length-1];e&&"text"===e.type?e.value+=" ":h.children.push({type:"text",value:" "}),h.children.push(...u)}else i.push(...u);let m={type:"element",tagName:"li",properties:{id:t+"fn-"+c},children:e.wrap(i,!0)};e.patch(s,m),l.push(m)}if(0!==l.length)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:i,properties:{...au(r),id:"footnote-label"},children:[{type:"text",value:s}]},{type:"text",value:"\n"},{type:"element",tagName:"ol",properties:{},children:e.wrap(l,!0)},{type:"text",value:"\n"}]}}(r),c=Array.isArray(l)?{type:"root",children:l}:l||{type:"root",children:[]};return o&&(tm("children"in c),c.children.push({type:"text",value:"\n"},o)),c}function aE(e,t){return e&&"run"in e?async function(n,a){let s=aR(n,{file:a,...t});await e.run(s,a)}:function(n,a){return aR(n,{file:a,...e||t})}}function aA(e){if(e)throw e}var a$=e.i(4100);function az(e){if("object"!=typeof e||null===e)return!1;let t=Object.getPrototypeOf(e);return(null===t||t===Object.prototype||null===Object.getPrototypeOf(t))&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}let aF=function(e,t){let n;if(void 0!==t&&"string"!=typeof t)throw TypeError('"ext" argument must be a string');aq(e);let a=0,s=-1,i=e.length;if(void 0===t||0===t.length||t.length>e.length){for(;i--;)if(47===e.codePointAt(i)){if(n){a=i+1;break}}else s<0&&(n=!0,s=i+1);return s<0?"":e.slice(a,s)}if(t===e)return"";let r=-1,l=t.length-1;for(;i--;)if(47===e.codePointAt(i)){if(n){a=i+1;break}}else r<0&&(n=!0,r=i+1),l>-1&&(e.codePointAt(i)===t.codePointAt(l--)?l<0&&(s=i):(l=-1,s=r));return a===s?s=r:s<0&&(s=e.length),e.slice(a,s)},aL=function(e){let t;if(aq(e),0===e.length)return".";let n=-1,a=e.length;for(;--a;)if(47===e.codePointAt(a)){if(t){n=a;break}}else t||(t=!0);return n<0?47===e.codePointAt(0)?"/":".":1===n&&47===e.codePointAt(0)?"//":e.slice(0,n)},aD=function(e){let t;aq(e);let n=e.length,a=-1,s=0,i=-1,r=0;for(;n--;){let l=e.codePointAt(n);if(47===l){if(t){s=n+1;break}continue}a<0&&(t=!0,a=n+1),46===l?i<0?i=n:1!==r&&(r=1):i>-1&&(r=-1)}return i<0||a<0||0===r||1===r&&i===a-1&&i===s+1?"":e.slice(i,a)},aO=function(...e){var t;let n,a,s,i=-1;for(;++i<e.length;)aq(e[i]),e[i]&&(s=void 0===s?e[i]:s+"/"+e[i]);return void 0===s?".":(aq(t=s),n=47===t.codePointAt(0),0!==(a=function(e,t){let n,a,s="",i=0,r=-1,l=0,o=-1;for(;++o<=e.length;){if(o<e.length)n=e.codePointAt(o);else if(47===n)break;else n=47;if(47===n){if(r===o-1||1===l);else if(r!==o-1&&2===l){if(s.length<2||2!==i||46!==s.codePointAt(s.length-1)||46!==s.codePointAt(s.length-2)){if(s.length>2){if((a=s.lastIndexOf("/"))!==s.length-1){a<0?(s="",i=0):i=(s=s.slice(0,a)).length-1-s.lastIndexOf("/"),r=o,l=0;continue}}else if(s.length>0){s="",i=0,r=o,l=0;continue}}t&&(s=s.length>0?s+"/..":"..",i=2)}else s.length>0?s+="/"+e.slice(r+1,o):s=e.slice(r+1,o),i=o-r-1;r=o,l=0}else 46===n&&l>-1?l++:l=-1}return s}(t,!n)).length||n||(a="."),a.length>0&&47===t.codePointAt(t.length-1)&&(a+="/"),n?"/"+a:a)};function aq(e){if("string"!=typeof e)throw TypeError("Path must be a string. Received "+JSON.stringify(e))}function aB(e){return!!(null!==e&&"object"==typeof e&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&void 0===e.auth)}let aU=["history","path","basename","stem","extname","dirname"];class aH{constructor(e){let t,n;t=e?aB(e)?{path:e}:"string"==typeof e||function(e){return!!(e&&"object"==typeof e&&"byteLength"in e&&"byteOffset"in e)}(e)?{value:e}:e:{},this.cwd="cwd"in t?"":"/",this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let a=-1;for(;++a<aU.length;){const e=aU[a];e in t&&void 0!==t[e]&&null!==t[e]&&(this[e]="history"===e?[...t[e]]:t[e])}for(n in t)aU.includes(n)||(this[n]=t[n])}get basename(){return"string"==typeof this.path?aF(this.path):void 0}set basename(e){aV(e,"basename"),aW(e,"basename"),this.path=aO(this.dirname||"",e)}get dirname(){return"string"==typeof this.path?aL(this.path):void 0}set dirname(e){aK(this.basename,"dirname"),this.path=aO(e||"",this.basename)}get extname(){return"string"==typeof this.path?aD(this.path):void 0}set extname(e){if(aW(e,"extname"),aK(this.dirname,"extname"),e){if(46!==e.codePointAt(0))throw Error("`extname` must start with `.`");if(e.includes(".",1))throw Error("`extname` cannot contain multiple dots")}this.path=aO(this.dirname,this.stem+(e||""))}get path(){return this.history[this.history.length-1]}set path(e){aB(e)&&(e=function(e){if("string"==typeof e)e=new URL(e);else if(!aB(e)){let t=TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code="ERR_INVALID_ARG_TYPE",t}if("file:"!==e.protocol){let e=TypeError("The URL must be of scheme file");throw e.code="ERR_INVALID_URL_SCHEME",e}return function(e){if(""!==e.hostname){let e=TypeError('File URL host must be "localhost" or empty on darwin');throw e.code="ERR_INVALID_FILE_URL_HOST",e}let t=e.pathname,n=-1;for(;++n<t.length;)if(37===t.codePointAt(n)&&50===t.codePointAt(n+1)){let e=t.codePointAt(n+2);if(70===e||102===e){let e=TypeError("File URL path must not include encoded / characters");throw e.code="ERR_INVALID_FILE_URL_PATH",e}}return decodeURIComponent(t)}(e)}(e)),aV(e,"path"),this.path!==e&&this.history.push(e)}get stem(){return"string"==typeof this.path?aF(this.path,this.extname):void 0}set stem(e){aV(e,"stem"),aW(e,"stem"),this.path=aO(this.dirname||"",e+(this.extname||""))}fail(e,t,n){let a=this.message(e,t,n);throw a.fatal=!0,a}info(e,t,n){let a=this.message(e,t,n);return a.fatal=void 0,a}message(e,t,n){let a=new tA(e,t,n);return this.path&&(a.name=this.path+":"+a.name,a.file=this.path),a.fatal=!1,this.messages.push(a),a}toString(e){return void 0===this.value?"":"string"==typeof this.value?this.value:new TextDecoder(e||void 0).decode(this.value)}}function aW(e,t){if(e&&e.includes("/"))throw Error("`"+t+"` cannot be a path: did not expect `/`")}function aV(e,t){if(!e)throw Error("`"+t+"` cannot be empty")}function aK(e,t){if(!e)throw Error("Setting `"+t+"` requires `path` to be set too")}let aG=function(e){let t=this.constructor.prototype,n=t[e],a=function(){return n.apply(a,arguments)};return Object.setPrototypeOf(a,t),a},aJ={}.hasOwnProperty;class aY extends aG{constructor(){super("copy"),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=function(){let e=[],t={run:function(...t){let n=-1,a=t.pop();if("function"!=typeof a)throw TypeError("Expected function as last argument, not "+a);!function s(i,...r){let l=e[++n],o=-1;if(i)return void a(i);for(;++o<t.length;)(null===r[o]||void 0===r[o])&&(r[o]=t[o]);t=r,l?(function(e,t){let n;return function(...t){let i,r=e.length>t.length;r&&t.push(a);try{i=e.apply(this,t)}catch(e){if(r&&n)throw e;return a(e)}r||(i&&i.then&&"function"==typeof i.then?i.then(s,a):i instanceof Error?a(i):s(i))};function a(e,...s){n||(n=!0,t(e,...s))}function s(e){a(null,e)}})(l,s)(...r):a(null,...r)}(null,...t)},use:function(n){if("function"!=typeof n)throw TypeError("Expected `middelware` to be a function, not "+n);return e.push(n),t}};return t}()}copy(){let e=new aY,t=-1;for(;++t<this.attachers.length;){let n=this.attachers[t];e.use(...n)}return e.data((0,a$.default)(!0,{},this.namespace)),e}data(e,t){return"string"==typeof e?2==arguments.length?(a0("data",this.frozen),this.namespace[e]=t,this):aJ.call(this.namespace,e)&&this.namespace[e]||void 0:e?(a0("data",this.frozen),this.namespace=e,this):this.namespace}freeze(){if(this.frozen)return this;for(;++this.freezeIndex<this.attachers.length;){let[e,...t]=this.attachers[this.freezeIndex];if(!1===t[0])continue;!0===t[0]&&(t[0]=void 0);let n=e.call(this,...t);"function"==typeof n&&this.transformers.use(n)}return this.frozen=!0,this.freezeIndex=1/0,this}parse(e){this.freeze();let t=a4(e),n=this.parser||this.Parser;return aZ("parse",n),n(String(t),t)}process(e,t){let n=this;return this.freeze(),aZ("process",this.parser||this.Parser),aX("process",this.compiler||this.Compiler),t?a(void 0,t):new Promise(a);function a(a,s){let i=a4(e),r=n.parse(i);function l(e,n){e||!n?s(e):a?a(n):(tm(t,"`done` is defined if `resolve` is not"),t(void 0,n))}n.run(r,i,function(e,t,a){var s,i;if(e||!t||!a)return l(e);let r=n.stringify(t,a);"string"==typeof(s=r)||(i=s)&&"object"==typeof i&&"byteLength"in i&&"byteOffset"in i?a.value=r:a.result=r,l(e,a)})}}processSync(e){let t,n=!1;return this.freeze(),aZ("processSync",this.parser||this.Parser),aX("processSync",this.compiler||this.Compiler),this.process(e,function(e,a){n=!0,aA(e),t=a}),a2("processSync","process",n),tm(t,"we either bailed on an error or have a tree"),t}run(e,t,n){a1(e),this.freeze();let a=this.transformers;return n||"function"!=typeof t||(n=t,t=void 0),n?s(void 0,n):new Promise(s);function s(s,i){tm("function"!=typeof t,"`file` can’t be a `done` anymore, we checked");let r=a4(t);a.run(e,r,function(t,a,r){let l=a||e;t?i(t):s?s(l):(tm(n,"`done` is defined if `resolve` is not"),n(void 0,l,r))})}}runSync(e,t){let n,a=!1;return this.run(e,t,function(e,t){aA(e),n=t,a=!0}),a2("runSync","run",a),tm(n,"we either bailed on an error or have a tree"),n}stringify(e,t){this.freeze();let n=a4(t),a=this.compiler||this.Compiler;return aX("stringify",a),a1(e),a(e,n)}use(e,...t){let n=this.attachers,a=this.namespace;if(a0("use",this.frozen),null==e);else if("function"==typeof e)r(e,t);else if("object"==typeof e)Array.isArray(e)?i(e):s(e);else throw TypeError("Expected usable value, not `"+e+"`");return this;function s(e){if(!("plugins"in e)&&!("settings"in e))throw Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");i(e.plugins),e.settings&&(a.settings=(0,a$.default)(!0,a.settings,e.settings))}function i(e){let t=-1;if(null==e);else if(Array.isArray(e))for(;++t<e.length;)!function(e){if("function"==typeof e)r(e,[]);else if("object"==typeof e)if(Array.isArray(e)){let[t,...n]=e;r(t,n)}else s(e);else throw TypeError("Expected usable value, not `"+e+"`")}(e[t]);else throw TypeError("Expected a list of plugins, not `"+e+"`")}function r(e,t){let a=-1,s=-1;for(;++a<n.length;)if(n[a][0]===e){s=a;break}if(-1===s)n.push([e,...t]);else if(t.length>0){let[a,...i]=t,r=n[s][1];az(r)&&az(a)&&(a=(0,a$.default)(!0,r,a)),n[s]=[e,a,...i]}}}}let aQ=new aY().freeze();function aZ(e,t){if("function"!=typeof t)throw TypeError("Cannot `"+e+"` without `parser`")}function aX(e,t){if("function"!=typeof t)throw TypeError("Cannot `"+e+"` without `compiler`")}function a0(e,t){if(t)throw Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function a1(e){if(!az(e)||"string"!=typeof e.type)throw TypeError("Expected node, got `"+e+"`")}function a2(e,t,n){if(!n)throw Error("`"+e+"` finished async. Use `"+t+"` instead")}function a4(e){var t;return(t=e)&&"object"==typeof t&&"message"in t&&"messages"in t?e:new aH(e)}let a5=[],a3={allowDangerousHtml:!0},a6=/^(https?|ircs?|mailto|xmpp)$/i,a8=[{from:"astPlugins",id:"remove-buggy-html-in-markdown-parser"},{from:"allowDangerousHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"allowNode",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowElement"},{from:"allowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowedElements"},{from:"className",id:"remove-classname"},{from:"disallowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"disallowedElements"},{from:"escapeHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"includeElementIndex",id:"#remove-includeelementindex"},{from:"includeNodeIndex",id:"change-includenodeindex-to-includeelementindex"},{from:"linkTarget",id:"remove-linktarget"},{from:"plugins",id:"change-plugins-to-remarkplugins",to:"remarkPlugins"},{from:"rawSourcePos",id:"#remove-rawsourcepos"},{from:"renderers",id:"change-renderers-to-components",to:"components"},{from:"source",id:"change-source-to-children",to:"children"},{from:"sourcePos",id:"#remove-sourcepos"},{from:"transformImageUri",id:"#add-urltransform",to:"urlTransform"},{from:"transformLinkUri",id:"#add-urltransform",to:"urlTransform"}];function a9(e){var n;let a,s,i,r,l,o=(a=(n=e).rehypePlugins||a5,s=n.remarkPlugins||a5,i=n.remarkRehypeOptions?{...n.remarkRehypeOptions,...a3}:a3,aQ().use(an).use(s).use(aE,i).use(a)),c=(r=e.children||"",l=new aH,"string"==typeof r?l.value=r:tf("Unexpected value `"+r+"` for `children` prop, expected `string`"),l);return function(e,n){let a=n.allowedElements,s=n.allowElement,i=n.components,r=n.disallowedElements,l=n.skipHtml,o=n.unwrapDisallowed,c=n.urlTransform||a7;for(let e of a8)Object.hasOwn(n,e.from)&&tf("Unexpected `"+e.from+"` prop, "+(e.to?"use `"+e.to+"` instead":"remove it")+" (see <https://github.com/remarkjs/react-markdown/blob/main/changelog.md#"+e.id+"> for more info)");return a&&r&&tf("Unexpected combined `allowedElements` and `disallowedElements`, expected one or the other"),ab(e,function(e,t,n){if("raw"===e.type&&n&&"number"==typeof t)return l?n.children.splice(t,1):n.children[t]={type:"text",value:e.value},t;if("element"===e.type){let t;for(t in tG)if(Object.hasOwn(tG,t)&&Object.hasOwn(e.properties,t)){let n=e.properties[t],a=tG[t];(null===a||a.includes(e.tagName))&&(e.properties[t]=c(String(n||""),t,e))}}if("element"===e.type){let i=a?!a.includes(e.tagName):!!r&&r.includes(e.tagName);if(!i&&s&&"number"==typeof t&&(i=!s(e,t,n)),i&&n&&"number"==typeof t)return o&&e.children?n.children.splice(t,1,...e.children):n.children.splice(t,1),t}}),function(e,t){var n,a,s,i;let r;if(!t||void 0===t.Fragment)throw TypeError("Expected `Fragment` in options");let l=t.filePath||void 0;if(t.development){if("function"!=typeof t.jsxDEV)throw TypeError("Expected `jsxDEV` in options when `development: true`");n=l,a=t.jsxDEV,r=function(e,t,s,i){let r=Array.isArray(s.children),l=tI(e);return a(t,s,i,r,{columnNumber:l?l.column-1:void 0,fileName:n,lineNumber:l?l.line:void 0},void 0)}}else{if("function"!=typeof t.jsx)throw TypeError("Expected `jsx` in production options");if("function"!=typeof t.jsxs)throw TypeError("Expected `jsxs` in production options");s=t.jsx,i=t.jsxs,r=function(e,t,n,a){let r=Array.isArray(n.children)?i:s;return a?r(t,n,a):r(t,n)}}let o={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:r,elementAttributeNameCase:t.elementAttributeNameCase||"react",evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:l,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:!1!==t.passKeys,passNode:t.passNode||!1,schema:"svg"===t.space?tN.svg:tN.html,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:!1!==t.tableCellAlignToStyle},c=tq(o,e,void 0);return c&&"string"!=typeof c?c:o.create(e,o.Fragment,{children:c||void 0},void 0)}(e,{Fragment:t.Fragment,components:i,ignoreInvalidStyle:!0,jsx:t.jsx,jsxs:t.jsxs,passKeys:!0,passNode:!0})}(o.runSync(o.parse(c),c),e)}function a7(e){let t=e.indexOf(":"),n=e.indexOf("?"),a=e.indexOf("#"),s=e.indexOf("/");return -1===t||-1!==s&&t>s||-1!==n&&t>n||-1!==a&&t>a||a6.test(e.slice(0,t))?e:""}var se=e.i(96481);let st="phrasing",sn=["autolink","link","image","label"];function sa(e){this.enter({type:"link",title:null,url:"",children:[]},e)}function ss(e){this.config.enter.autolinkProtocol.call(this,e)}function si(e){this.config.exit.autolinkProtocol.call(this,e)}function sr(e){this.config.exit.data.call(this,e);let t=this.stack[this.stack.length-1];tm("link"===t.type),t.url="http://"+this.sliceSerialize(e)}function sl(e){this.config.exit.autolinkEmail.call(this,e)}function so(e){this.exit(e)}function sc(e){!function(e,t,n){let a=af((n||{}).ignore||[]),s=function(e){let t=[];if(!Array.isArray(e))throw TypeError("Expected find and replace tuple or list of tuples");let n=!e[0]||Array.isArray(e[0])?e:[e],a=-1;for(;++a<n.length;){var s;let e=n[a];t.push(["string"==typeof(s=e[0])?RegExp(function(e){if("string"!=typeof e)throw TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}(s),"g"):s,function(e){return"function"==typeof e?e:function(){return e}}(e[1])])}return t}(t),i=-1;for(;++i<s.length;)ay(e,"text",r);function r(e,t){let n,r=-1;for(;++r<t.length;){let e=t[r],s=n?n.children:void 0;if(a(e,s?s.indexOf(e):void 0,n))return;n=e}if(n)return function(e,t){let n=t[t.length-1],a=s[i][0],r=s[i][1],l=0,o=n.children.indexOf(e),c=!1,d=[];a.lastIndex=0;let u=a.exec(e.value);for(;u;){let n=u.index,s={index:u.index,input:u.input,stack:[...t,e]},i=r(...u,s);if("string"==typeof i&&(i=i.length>0?{type:"text",value:i}:void 0),!1===i?a.lastIndex=n+1:(l!==n&&d.push({type:"text",value:e.value.slice(l,n)}),Array.isArray(i)?d.push(...i):i&&d.push(i),l=n+u[0].length,c=!0),!a.global)break;u=a.exec(e.value)}return c?(l<e.value.length&&d.push({type:"text",value:e.value.slice(l)}),n.children.splice(o,1,...d)):d=[e],o+d.length}(e,t)}}(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,sd],[/(?<=^|\s|\p{P}|\p{S})([-.\w+]+)@([-\w]+(?:\.[-\w]+)+)/gu,su]],{ignore:["link","linkReference"]})}function sd(e,t,n,a,s){let i,r="";if(!sp(s))return!1;if(/^w/i.test(t)&&(n=t+n,t="",r="http://"),(i=n.split(".")).length<2||i[i.length-1]&&(/_/.test(i[i.length-1])||!/[a-zA-Z\d]/.test(i[i.length-1]))||i[i.length-2]&&(/_/.test(i[i.length-2])||!/[a-zA-Z\d]/.test(i[i.length-2])))return!1;let l=function(e){let t=/[!"&'),.:;<>?\]}]+$/.exec(e);if(!t)return[e,void 0];e=e.slice(0,t.index);let n=t[0],a=n.indexOf(")"),s=(0,se.ccount)(e,"("),i=(0,se.ccount)(e,")");for(;-1!==a&&s>i;)e+=n.slice(0,a+1),a=(n=n.slice(a+1)).indexOf(")"),i++;return[e,n]}(n+a);if(!l[0])return!1;let o={type:"link",title:null,url:r+t+l[0],children:[{type:"text",value:t+l[0]}]};return l[1]?[o,{type:"text",value:l[1]}]:o}function su(e,t,n,a){return!(!sp(a,!0)||/[-\d_]$/.test(n))&&{type:"link",title:null,url:"mailto:"+t+"@"+n,children:[{type:"text",value:t+"@"+n}]}}function sp(e,t){let n=e.input.charCodeAt(e.index-1);return(0===e.index||ns(n)||na(n))&&(!t||47!==n)}function sh(){this.buffer()}function sm(e){this.enter({type:"footnoteReference",identifier:"",label:""},e)}function sf(){this.buffer()}function sg(e){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},e)}function sx(e){let t=this.resume(),n=this.stack[this.stack.length-1];tm("footnoteReference"===n.type),n.identifier=nO(this.sliceSerialize(e)).toLowerCase(),n.label=t}function sv(e){this.exit(e)}function sy(e){let t=this.resume(),n=this.stack[this.stack.length-1];tm("footnoteDefinition"===n.type),n.identifier=nO(this.sliceSerialize(e)).toLowerCase(),n.label=t}function sb(e){this.exit(e)}function sk(e,t,n,a){let s=n.createTracker(a),i=s.move("[^"),r=n.enter("footnoteReference"),l=n.enter("reference");return i+=s.move(n.safe(n.associationId(e),{after:"]",before:i})),l(),r(),i+=s.move("]")}function sj(e,t,n){return 0===t?e:sw(e,t,n)}function sw(e,t,n){return(n?"":" ")+e}sk.peek=function(){return"["};let sN=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];function s_(e){this.enter({type:"delete",children:[]},e)}function sC(e){this.exit(e)}function sS(e,t,n,a){let s=n.createTracker(a),i=n.enter("strikethrough"),r=s.move("~~");return r+=n.containerPhrasing(e,{...s.current(),before:r,after:"~"}),r+=s.move("~~"),i(),r}function sI(e){return e.length}function sP(e){let t="string"==typeof e?e.codePointAt(0):0;return 67===t||99===t?99:76===t||108===t?108:114*(82===t||114===t)}sS.peek=function(){return"~"};function sT(e,t,n){let a=e.value||"",s="`",i=-1;for(;RegExp("(^|[^`])"+s+"([^`]|$)").test(a);)s+="`";for(/[^ \r\n]/.test(a)&&(/^[ \r\n]/.test(a)&&/[ \r\n]$/.test(a)||/^`|`$/.test(a))&&(a=" "+a+" ");++i<n.unsafe.length;){let e,t=n.unsafe[i],s=n.compilePattern(t);if(t.atBreak)for(;e=s.exec(a);){let t=e.index;10===a.charCodeAt(t)&&13===a.charCodeAt(t-1)&&t--,a=a.slice(0,t)+" "+a.slice(e.index+1)}}return s+a+s}sT.peek=function(){return"`"};af(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);let sM=function(e,t,n,a){let s=function(e){let t=e.options.listItemIndent||"one";if("tab"!==t&&"one"!==t&&"mixed"!==t)throw Error("Cannot serialize items with `"+t+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return t}(n),i=n.bulletCurrent||function(e){let t=e.options.bullet||"*";if("*"!==t&&"+"!==t&&"-"!==t)throw Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}(n);t&&"list"===t.type&&t.ordered&&(i=("number"==typeof t.start&&t.start>-1?t.start:1)+(!1===n.options.incrementListMarker?0:t.children.indexOf(e))+i);let r=i.length+1;("tab"===s||"mixed"===s&&(t&&"list"===t.type&&t.spread||e.spread))&&(r=4*Math.ceil(r/4));let l=n.createTracker(a);l.move(i+" ".repeat(r-i.length)),l.shift(r);let o=n.enter("listItem"),c=n.indentLines(n.containerFlow(e,l.current()),function(e,t,n){return t?(n?"":" ".repeat(r))+e:(n?i:i+" ".repeat(r-i.length))+e});return o(),c};function sR(e){let t=e._align;tm(t,"expected `_align` on table"),this.enter({type:"table",align:t.map(function(e){return"none"===e?null:e}),children:[]},e),this.data.inTable=!0}function sE(e){this.exit(e),this.data.inTable=void 0}function sA(e){this.enter({type:"tableRow",children:[]},e)}function s$(e){this.exit(e)}function sz(e){this.enter({type:"tableCell",children:[]},e)}function sF(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,sL));let n=this.stack[this.stack.length-1];tm("inlineCode"===n.type),n.value=t,this.exit(e)}function sL(e,t){return"|"===t?t:e}function sD(e){let t=this.stack[this.stack.length-2];tm("listItem"===t.type),t.checked="taskListCheckValueChecked"===e.type}function sO(e){let t=this.stack[this.stack.length-2];if(t&&"listItem"===t.type&&"boolean"==typeof t.checked){let e=this.stack[this.stack.length-1];tm("paragraph"===e.type);let n=e.children[0];if(n&&"text"===n.type){let a,s=t.children,i=-1;for(;++i<s.length;){let e=s[i];if("paragraph"===e.type){a=e;break}}a===e&&(n.value=n.value.slice(1),0===n.value.length?e.children.shift():e.position&&n.position&&"number"==typeof n.position.start.offset&&(n.position.start.column++,n.position.start.offset++,e.position.start=Object.assign({},n.position.start)))}}this.exit(e)}function sq(e,t,n,a){let s=e.children[0],i="boolean"==typeof e.checked&&s&&"paragraph"===s.type,r="["+(e.checked?"x":" ")+"] ",l=n.createTracker(a);i&&l.move(r);let o=sM(e,t,n,{...a,...l.current()});return i&&(o=o.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,function(e){return e+r})),o}let sB={tokenize:function(e,t,n){let a=0;return function t(i){return(87===i||119===i)&&a<3?(a++,e.consume(i),t):46===i&&3===a?(e.consume(i),s):n(i)};function s(e){return null===e?n(e):t(e)}},partial:!0},sU={tokenize:function(e,t,n){let a,s,i;return r;function r(t){return 46===t||95===t?e.check(sW,o,l)(t):null===t||nt(t)||ns(t)||45!==t&&na(t)?o(t):(i=!0,e.consume(t),r)}function l(t){return 95===t?a=!0:(s=a,a=void 0),e.consume(t),r}function o(e){return s||a||!i?n(e):t(e)}},partial:!0},sH={tokenize:function(e,t){let n=0,a=0;return s;function s(r){return 40===r?(n++,e.consume(r),s):41===r&&a<n?i(r):33===r||34===r||38===r||39===r||41===r||42===r||44===r||46===r||58===r||59===r||60===r||63===r||93===r||95===r||126===r?e.check(sW,t,i)(r):null===r||nt(r)||ns(r)?t(r):(e.consume(r),s)}function i(t){return 41===t&&a++,e.consume(t),s}},partial:!0},sW={tokenize:function(e,t,n){return a;function a(r){return 33===r||34===r||39===r||41===r||42===r||44===r||46===r||58===r||59===r||63===r||95===r||126===r?(e.consume(r),a):38===r?(e.consume(r),i):93===r?(e.consume(r),s):60===r||null===r||nt(r)||ns(r)?t(r):n(r)}function s(e){return null===e||40===e||91===e||nt(e)||ns(e)?t(e):a(e)}function i(t){return t4(t)?function t(s){return 59===s?(e.consume(s),a):t4(s)?(e.consume(s),t):n(s)}(t):n(t)}},partial:!0},sV={tokenize:function(e,t,n){return function(t){return e.consume(t),a};function a(e){return t5(e)?n(e):t(e)}},partial:!0},sK={name:"wwwAutolink",tokenize:function(e,t,n){let a=this;return function(t){return 87!==t&&119!==t||!sZ.call(a,a.previous)||s2(a.events)?n(t):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(sB,e.attempt(sU,e.attempt(sH,s),n),n)(t))};function s(n){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(n)}},previous:sZ},sG={name:"protocolAutolink",tokenize:function(e,t,n){let a=this,s="",i=!1;return function(t){return(72===t||104===t)&&sX.call(a,a.previous)&&!s2(a.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),s+=String.fromCodePoint(t),e.consume(t),r):n(t)};function r(t){if(t4(t)&&s.length<5)return s+=String.fromCodePoint(t),e.consume(t),r;if(58===t){let n=s.toLowerCase();if("http"===n||"https"===n)return e.consume(t),l}return n(t)}function l(t){return 47===t?(e.consume(t),i)?o:(i=!0,l):n(t)}function o(t){return null===t||t6(t)||nt(t)||ns(t)||na(t)?n(t):e.attempt(sU,e.attempt(sH,c),n)(t)}function c(n){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(n)}},previous:sX},sJ={name:"emailAutolink",tokenize:function(e,t,n){let a,s,i=this;return function(t){return!s1(t)||!s0.call(i,i.previous)||s2(i.events)?n(t):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),function t(a){return s1(a)?(e.consume(a),t):64===a?(e.consume(a),r):n(a)}(t))};function r(t){return 46===t?e.check(sV,o,l)(t):45===t||95===t||t5(t)?(s=!0,e.consume(t),r):o(t)}function l(t){return e.consume(t),a=!0,r}function o(r){return s&&a&&t4(i.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(r)):n(r)}},previous:s0},sY={},sQ=48;for(;sQ<123;)sY[sQ]=sJ,58==++sQ?sQ=65:91===sQ&&(sQ=97);function sZ(e){return null===e||40===e||42===e||95===e||91===e||93===e||126===e||nt(e)}function sX(e){return!t4(e)}function s0(e){return!(47===e||s1(e))}function s1(e){return 43===e||45===e||46===e||95===e||t5(e)}function s2(e){let t=e.length,n=!1;for(;t--;){let a=e[t][1];if(("labelLink"===a.type||"labelImage"===a.type)&&!a._balanced){n=!0;break}if(a._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}sY[43]=sJ,sY[45]=sJ,sY[46]=sJ,sY[95]=sJ,sY[72]=[sJ,sG],sY[104]=[sJ,sG],sY[87]=[sJ,sK],sY[119]=[sJ,sK];let s4={tokenize:function(e,t,n){let a=this;return nr(e,function(e){let s=a.events[a.events.length-1];return s&&"gfmFootnoteDefinitionIndent"===s[1].type&&4===s[2].sliceSerialize(s[1],!0).length?t(e):n(e)},"gfmFootnoteDefinitionIndent",5)},partial:!0};function s5(e,t,n){let a,s=this,i=s.events.length,r=s.parser.gfmFootnotes||(s.parser.gfmFootnotes=[]);for(;i--;){let e=s.events[i][1];if("labelImage"===e.type){a=e;break}if("gfmFootnoteCall"===e.type||"labelLink"===e.type||"label"===e.type||"image"===e.type||"link"===e.type)break}return function(i){if(!a||!a._balanced)return n(i);let l=nO(s.sliceSerialize({start:a.end,end:s.now()}));return 94===l.codePointAt(0)&&r.includes(l.slice(1))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(i),e.exit("gfmFootnoteCallLabelMarker"),t(i)):n(i)}}function s3(e,t){let n=e.length;for(;n--;)if("labelImage"===e[n][1].type&&"enter"===e[n][0]){e[n][1];break}e[n+1][1].type="data",e[n+3][1].type="gfmFootnoteCallLabelMarker";let a={type:"gfmFootnoteCall",start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},s={type:"gfmFootnoteCallMarker",start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};s.end.column++,s.end.offset++,s.end._bufferIndex++;let i={type:"gfmFootnoteCallString",start:Object.assign({},s.end),end:Object.assign({},e[e.length-1][1].start)},r={type:"chunkString",contentType:"string",start:Object.assign({},i.start),end:Object.assign({},i.end)},l=[e[n+1],e[n+2],["enter",a,t],e[n+3],e[n+4],["enter",s,t],["exit",s,t],["enter",i,t],["enter",r,t],["exit",r,t],["exit",i,t],e[e.length-2],e[e.length-1],["exit",a,t]];return e.splice(n,e.length-n+1,...l),e}function s6(e,t,n){let a,s=this,i=s.parser.gfmFootnotes||(s.parser.gfmFootnotes=[]),r=0;return function(t){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(t),e.exit("gfmFootnoteCallLabelMarker"),l};function l(t){return 94!==t?n(t):(e.enter("gfmFootnoteCallMarker"),e.consume(t),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",o)}function o(l){if(r>999||93===l&&!a||null===l||91===l||nt(l))return n(l);if(93===l){e.exit("chunkString");let a=e.exit("gfmFootnoteCallString");return i.includes(nO(s.sliceSerialize(a)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(l),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):n(l)}return nt(l)||(a=!0),r++,e.consume(l),92===l?c:o}function c(t){return 91===t||92===t||93===t?(e.consume(t),r++,o):o(t)}}function s8(e,t,n){let a,s,i=this,r=i.parser.gfmFootnotes||(i.parser.gfmFootnotes=[]),l=0;return function(t){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(t),e.exit("gfmFootnoteDefinitionLabelMarker"),o};function o(t){return 94===t?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(t),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",c):n(t)}function c(t){if(l>999||93===t&&!s||null===t||91===t||nt(t))return n(t);if(93===t){e.exit("chunkString");let n=e.exit("gfmFootnoteDefinitionLabelString");return a=nO(i.sliceSerialize(n)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(t),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),u}return nt(t)||(s=!0),l++,e.consume(t),92===t?d:c}function d(t){return 91===t||92===t||93===t?(e.consume(t),l++,c):c(t)}function u(t){return 58===t?(e.enter("definitionMarker"),e.consume(t),e.exit("definitionMarker"),r.includes(a)||r.push(a),nr(e,p,"gfmFootnoteDefinitionWhitespace")):n(t)}function p(e){return t(e)}}function s9(e,t,n){return e.check(nd,t,e.attempt(s4,t,n))}function s7(e){e.exit("gfmFootnoteDefinition")}class ie{constructor(){this.map=[]}add(e,t,n){!function(e,t,n,a){let s=0;if(0!==n||0!==a.length){for(;s<e.map.length;){if(e.map[s][0]===t){e.map[s][1]+=n,e.map[s][2].push(...a);return}s+=1}e.map.push([t,n,a])}}(this,e,t,n)}consume(e){if(this.map.sort(function(e,t){return e[0]-t[0]}),0===this.map.length)return;let t=this.map.length,n=[];for(;t>0;)t-=1,n.push(e.slice(this.map[t][0]+this.map[t][1]),this.map[t][2]),e.length=this.map[t][0];n.push(e.slice()),e.length=0;let a=n.pop();for(;a;){for(let t of a)e.push(t);a=n.pop()}this.map.length=0}}function it(e,t,n){let a,s=this,i=0,r=0;return function(e){let t=s.events.length-1;for(;t>-1;){let e=s.events[t][1].type;if("lineEnding"===e||"linePrefix"===e)t--;else break}let a=t>-1?s.events[t][1].type:null,i="tableHead"===a||"tableRow"===a?v:l;return i===v&&s.parser.lazy[s.now().line]?n(e):i(e)};function l(t){var n;return e.enter("tableHead"),e.enter("tableRow"),124===(n=t)||(a=!0,r+=1),o(n)}function o(t){return null===t?n(t):ne(t)?r>1?(r=0,s.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),u):n(t):nn(t)?nr(e,o,"whitespace")(t):(r+=1,a&&(a=!1,i+=1),124===t)?(e.enter("tableCellDivider"),e.consume(t),e.exit("tableCellDivider"),a=!0,o):(e.enter("data"),c(t))}function c(t){return null===t||124===t||nt(t)?(e.exit("data"),o(t)):(e.consume(t),92===t?d:c)}function d(t){return 92===t||124===t?(e.consume(t),c):c(t)}function u(t){return(s.interrupt=!1,s.parser.lazy[s.now().line])?n(t):(e.enter("tableDelimiterRow"),a=!1,nn(t))?nr(e,p,"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(t):p(t)}function p(t){return 45===t||58===t?m(t):124===t?(a=!0,e.enter("tableCellDivider"),e.consume(t),e.exit("tableCellDivider"),h):n(t)}function h(t){return nn(t)?nr(e,m,"whitespace")(t):m(t)}function m(t){return 58===t?(r+=1,a=!0,e.enter("tableDelimiterMarker"),e.consume(t),e.exit("tableDelimiterMarker"),f):45===t?(r+=1,f(t)):null===t||ne(t)?x(t):n(t)}function f(t){return 45===t?(e.enter("tableDelimiterFiller"),function t(n){return 45===n?(e.consume(n),t):58===n?(a=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(n),e.exit("tableDelimiterMarker"),g):(e.exit("tableDelimiterFiller"),g(n))}(t)):n(t)}function g(t){return nn(t)?nr(e,x,"whitespace")(t):x(t)}function x(s){if(124===s)return p(s);if(null===s||ne(s))return a&&i===r?(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(s)):n(s);return n(s)}function v(t){return e.enter("tableRow"),y(t)}function y(n){return 124===n?(e.enter("tableCellDivider"),e.consume(n),e.exit("tableCellDivider"),y):null===n||ne(n)?(e.exit("tableRow"),t(n)):nn(n)?nr(e,y,"whitespace")(n):(e.enter("data"),b(n))}function b(t){return null===t||124===t||nt(t)?(e.exit("data"),y(t)):(e.consume(t),92===t?k:b)}function k(t){return 92===t||124===t?(e.consume(t),b):b(t)}}function ia(e,t){let n,a,s,i=-1,r=!0,l=0,o=[0,0,0,0],c=[0,0,0,0],d=!1,u=0,p=new ie;for(;++i<e.length;){let h=e[i],m=h[1];"enter"===h[0]?"tableHead"===m.type?(d=!1,0!==u&&(ii(p,t,u,n,a),a=void 0,u=0),n={type:"table",start:Object.assign({},m.start),end:Object.assign({},m.end)},p.add(i,0,[["enter",n,t]])):"tableRow"===m.type||"tableDelimiterRow"===m.type?(r=!0,s=void 0,o=[0,0,0,0],c=[0,i+1,0,0],d&&(d=!1,a={type:"tableBody",start:Object.assign({},m.start),end:Object.assign({},m.end)},p.add(i,0,[["enter",a,t]])),l="tableDelimiterRow"===m.type?2:a?3:1):l&&("data"===m.type||"tableDelimiterMarker"===m.type||"tableDelimiterFiller"===m.type)?(r=!1,0===c[2]&&(0!==o[1]&&(c[0]=c[1],s=is(p,t,o,l,void 0,s),o=[0,0,0,0]),c[2]=i)):"tableCellDivider"===m.type&&(r?r=!1:(0!==o[1]&&(c[0]=c[1],s=is(p,t,o,l,void 0,s)),c=[(o=c)[1],i,0,0])):"tableHead"===m.type?(d=!0,u=i):"tableRow"===m.type||"tableDelimiterRow"===m.type?(u=i,0!==o[1]?(c[0]=c[1],s=is(p,t,o,l,i,s)):0!==c[1]&&(s=is(p,t,c,l,i,s)),l=0):l&&("data"===m.type||"tableDelimiterMarker"===m.type||"tableDelimiterFiller"===m.type)&&(c[3]=i)}for(0!==u&&ii(p,t,u,n,a),p.consume(t.events),i=-1;++i<t.events.length;){let e=t.events[i];"enter"===e[0]&&"table"===e[1].type&&(e[1]._align=function(e,t){let n=!1,a=[];for(;t<e.length;){let s=e[t];if(n){if("enter"===s[0])"tableContent"===s[1].type&&a.push("tableDelimiterMarker"===e[t+1][1].type?"left":"none");else if("tableContent"===s[1].type){if("tableDelimiterMarker"===e[t-1][1].type){let e=a.length-1;a[e]="left"===a[e]?"center":"right"}}else if("tableDelimiterRow"===s[1].type)break}else"enter"===s[0]&&"tableDelimiterRow"===s[1].type&&(n=!0);t+=1}return a}(t.events,i))}return e}function is(e,t,n,a,s,i){0!==n[0]&&(i.end=Object.assign({},ir(t.events,n[0])),e.add(n[0],0,[["exit",i,t]]));let r=ir(t.events,n[1]);if(i={type:1===a?"tableHeader":2===a?"tableDelimiter":"tableData",start:Object.assign({},r),end:Object.assign({},r)},e.add(n[1],0,[["enter",i,t]]),0!==n[2]){let s=ir(t.events,n[2]),i=ir(t.events,n[3]),r={type:"tableContent",start:Object.assign({},s),end:Object.assign({},i)};if(e.add(n[2],0,[["enter",r,t]]),2!==a){let a=t.events[n[2]],s=t.events[n[3]];if(a[1].end=Object.assign({},s[1].end),a[1].type="chunkText",a[1].contentType="text",n[3]>n[2]+1){let t=n[2]+1,a=n[3]-n[2]-1;e.add(t,a,[])}}e.add(n[3]+1,0,[["exit",r,t]])}return void 0!==s&&(i.end=Object.assign({},ir(t.events,s)),e.add(s,0,[["exit",i,t]]),i=void 0),i}function ii(e,t,n,a,s){let i=[],r=ir(t.events,n);s&&(s.end=Object.assign({},r),i.push(["exit",s,t])),a.end=Object.assign({},r),i.push(["exit",a,t]),e.add(n+1,0,i)}function ir(e,t){let n=e[t],a="enter"===n[0]?"start":"end";return n[1][a]}let il={name:"tasklistCheck",tokenize:function(e,t,n){let a=this;return function(t){return null===a.previous&&a._gfmTasklistFirstContentOfListItem?(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(t),e.exit("taskListCheckMarker"),s):n(t)};function s(t){return nt(t)?(e.enter("taskListCheckValueUnchecked"),e.consume(t),e.exit("taskListCheckValueUnchecked"),i):88===t||120===t?(e.enter("taskListCheckValueChecked"),e.consume(t),e.exit("taskListCheckValueChecked"),i):n(t)}function i(t){return 93===t?(e.enter("taskListCheckMarker"),e.consume(t),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),r):n(t)}function r(a){return ne(a)?t(a):nn(a)?e.check({tokenize:io},t,n)(a):n(a)}}};function io(e,t,n){return nr(e,function(e){return null===e?n(e):t(e)},"whitespace")}let ic={};function id(e){let t,n,a,s=e||ic,i=this.data(),r=i.micromarkExtensions||(i.micromarkExtensions=[]),l=i.fromMarkdownExtensions||(i.fromMarkdownExtensions=[]),o=i.toMarkdownExtensions||(i.toMarkdownExtensions=[]);r.push(t2([{text:sY},{document:{91:{name:"gfmFootnoteDefinition",tokenize:s8,continuation:{tokenize:s9},exit:s7}},text:{91:{name:"gfmFootnoteCall",tokenize:s6},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:s5,resolveTo:s3}}},(t=(s||{}).singleTilde,n={name:"strikethrough",tokenize:function(e,n,a){let s=this.previous,i=this.events,r=0;return function(l){return 126===s&&"characterEscape"!==i[i.length-1][1].type?a(l):(e.enter("strikethroughSequenceTemporary"),function i(l){let o=nw(s);if(126===l)return r>1?a(l):(e.consume(l),r++,i);if(r<2&&!t)return a(l);let c=e.exit("strikethroughSequenceTemporary"),d=nw(l);return c._open=!d||2===d&&!!o,c._close=!o||2===o&&!!d,n(l)}(l))}},resolveAll:function(e,t){let n=-1;for(;++n<e.length;)if("enter"===e[n][0]&&"strikethroughSequenceTemporary"===e[n][1].type&&e[n][1]._close){let a=n;for(;a--;)if("exit"===e[a][0]&&"strikethroughSequenceTemporary"===e[a][1].type&&e[a][1]._open&&e[n][1].end.offset-e[n][1].start.offset==e[a][1].end.offset-e[a][1].start.offset){e[n][1].type="strikethroughSequence",e[a][1].type="strikethroughSequence";let s={type:"strikethrough",start:Object.assign({},e[a][1].start),end:Object.assign({},e[n][1].end)},i={type:"strikethroughText",start:Object.assign({},e[a][1].end),end:Object.assign({},e[n][1].start)},r=[["enter",s,t],["enter",e[a][1],t],["exit",e[a][1],t],["enter",i,t]],l=t.parser.constructs.insideSpan.null;l&&tX(r,r.length,0,nN(l,e.slice(a+1,n),t)),tX(r,r.length,0,[["exit",i,t],["enter",e[n][1],t],["exit",e[n][1],t],["exit",s,t]]),tX(e,a-1,n-a+3,r),n=a+r.length-2;break}}for(n=-1;++n<e.length;)"strikethroughSequenceTemporary"===e[n][1].type&&(e[n][1].type="data");return e}},null==t&&(t=!0),{text:{126:n},insideSpan:{null:[n]},attentionMarkers:{null:[126]}}),{flow:{null:{name:"table",tokenize:it,resolveAll:ia}}},{text:{91:il}}])),l.push([{transforms:[sc],enter:{literalAutolink:sa,literalAutolinkEmail:ss,literalAutolinkHttp:ss,literalAutolinkWww:ss},exit:{literalAutolink:so,literalAutolinkEmail:sl,literalAutolinkHttp:si,literalAutolinkWww:sr}},{enter:{gfmFootnoteCallString:sh,gfmFootnoteCall:sm,gfmFootnoteDefinitionLabelString:sf,gfmFootnoteDefinition:sg},exit:{gfmFootnoteCallString:sx,gfmFootnoteCall:sv,gfmFootnoteDefinitionLabelString:sy,gfmFootnoteDefinition:sb}},{canContainEols:["delete"],enter:{strikethrough:s_},exit:{strikethrough:sC}},{enter:{table:sR,tableData:sz,tableHeader:sz,tableRow:sA},exit:{codeText:sF,table:sE,tableData:s$,tableHeader:s$,tableRow:s$}},{exit:{taskListCheckValueChecked:sD,taskListCheckValueUnchecked:sD,paragraph:sO}}]),o.push({extensions:[{unsafe:[{character:"@",before:"[+\\-.\\w]",after:"[\\-.\\w]",inConstruct:st,notInConstruct:sn},{character:".",before:"[Ww]",after:"[\\-.\\w]",inConstruct:st,notInConstruct:sn},{character:":",before:"[ps]",after:"\\/",inConstruct:st,notInConstruct:sn}]},(a=!1,s&&s.firstLineBlank&&(a=!0),{handlers:{footnoteDefinition:function(e,t,n,s){let i=n.createTracker(s),r=i.move("[^"),l=n.enter("footnoteDefinition"),o=n.enter("label");return r+=i.move(n.safe(n.associationId(e),{before:r,after:"]"})),o(),r+=i.move("]:"),e.children&&e.children.length>0&&(i.shift(4),r+=i.move((a?"\n":" ")+n.indentLines(n.containerFlow(e,i.current()),a?sw:sj))),l(),r},footnoteReference:sk},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]}),{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:sN}],handlers:{delete:sS}},function(e){let t=e||{},n=t.tableCellPadding,a=t.tablePipeAlign,s=t.stringLength,i=n?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:"\n",inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:function(e,t,n){let a=sT(e,t,n);return n.stack.includes("tableCell")&&(a=a.replace(/\|/g,"\\$&")),a},table:function(e,t,n,a){return l(function(e,t,n){let a=e.children,s=-1,i=[],r=t.enter("table");for(;++s<a.length;)i[s]=o(a[s],t,n);return r(),i}(e,n,a),e.align)},tableCell:r,tableRow:function(e,t,n,a){let s=l([o(e,n,a)]);return s.slice(0,s.indexOf("\n"))}}};function r(e,t,n,a){let s=n.enter("tableCell"),r=n.enter("phrasing"),l=n.containerPhrasing(e,{...a,before:i,after:i});return r(),s(),l}function l(e,t){return function(e,t){let n=t||{},a=(n.align||[]).concat(),s=n.stringLength||sI,i=[],r=[],l=[],o=[],c=0,d=-1;for(;++d<e.length;){let t=[],a=[],i=-1;for(e[d].length>c&&(c=e[d].length);++i<e[d].length;){var u;let r=null==(u=e[d][i])?"":String(u);if(!1!==n.alignDelimiters){let e=s(r);a[i]=e,(void 0===o[i]||e>o[i])&&(o[i]=e)}t.push(r)}r[d]=t,l[d]=a}let p=-1;if("object"==typeof a&&"length"in a)for(;++p<c;)i[p]=sP(a[p]);else{let e=sP(a);for(;++p<c;)i[p]=e}p=-1;let h=[],m=[];for(;++p<c;){let e=i[p],t="",a="";99===e?(t=":",a=":"):108===e?t=":":114===e&&(a=":");let s=!1===n.alignDelimiters?1:Math.max(1,o[p]-t.length-a.length),r=t+"-".repeat(s)+a;!1!==n.alignDelimiters&&((s=t.length+s+a.length)>o[p]&&(o[p]=s),m[p]=s),h[p]=r}r.splice(1,0,h),l.splice(1,0,m),d=-1;let f=[];for(;++d<r.length;){let e=r[d],t=l[d];p=-1;let a=[];for(;++p<c;){let s=e[p]||"",r="",l="";if(!1!==n.alignDelimiters){let e=o[p]-(t[p]||0),n=i[p];114===n?r=" ".repeat(e):99===n?e%2?(r=" ".repeat(e/2+.5),l=" ".repeat(e/2-.5)):l=r=" ".repeat(e/2):l=" ".repeat(e)}!1===n.delimiterStart||p||a.push("|"),!1!==n.padding&&(!1!==n.alignDelimiters||""!==s)&&(!1!==n.delimiterStart||p)&&a.push(" "),!1!==n.alignDelimiters&&a.push(r),a.push(s),!1!==n.alignDelimiters&&a.push(l),!1!==n.padding&&a.push(" "),(!1!==n.delimiterEnd||p!==c-1)&&a.push("|")}f.push(!1===n.delimiterEnd?a.join("").replace(/ +$/,""):a.join(""))}return f.join("\n")}(e,{align:t,alignDelimiters:a,padding:n,stringLength:s})}function o(e,t,n){let a=e.children,s=-1,i=[],l=t.enter("tableRow");for(;++s<a.length;)i[s]=r(a[s],e,t,n);return l(),i}}(s),{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:sq}}]})}function iu({text:e,className:n=""}){return(0,t.jsx)("div",{className:`markdown-body ${n}`.trim(),children:(0,t.jsx)(a9,{remarkPlugins:[id],children:e})})}let ip=o("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"}]]);function ih({text:e}){let n=(0,f.useT)();return(0,t.jsxs)("details",{className:"thinking-block",children:[(0,t.jsxs)("summary",{children:[(0,t.jsx)(ip,{size:14,"aria-hidden":"true"}),(0,t.jsx)("span",{children:n("conversation.thinking.reasoning")})]}),(0,t.jsx)("div",{className:"thinking-content",children:e})]})}let im=(0,n.memo)(function({step:e,activeLeafMessageId:n,branchDisabled:a,createBranch:s,metrics:i,isFirst:r=!0,isFinal:l=!0}){let o=e.speaker?.kind==="hero",d=e.speaker?.handle?`@${e.speaker.handle}`:e.speaker?.displayName||"Host",u=e.speaker?.modelName,p=e.blocks.filter(e=>"text"===e.kind).map(e=>e.text).join("\n\n");return(0,t.jsxs)("section",{className:"assistant-step","data-message-id":e.sourceMessageId,"data-variant":l?void 0:"commentary","data-continuation":r?void 0:"true",children:[r&&(0,t.jsxs)("div",{className:o?"assistant-speaker role":"assistant-speaker",children:[(0,t.jsx)("span",{style:e.speaker?.color?{color:e.speaker.color}:void 0,children:(0,t.jsx)(c,{size:13,"aria-hidden":"true"})}),(0,t.jsx)("strong",{children:d}),o&&(0,t.jsx)("small",{children:"Role"}),u&&(0,t.jsx)("small",{className:"assistant-model",children:u})]}),e.blocks.map((e,n)=>"text"===e.kind?(0,t.jsx)(iu,{text:e.text},n):"thinking"===e.kind?(0,t.jsx)(ih,{text:e.text},n):"image"===e.kind?(0,t.jsxs)("div",{className:"image-reference",children:[(0,t.jsx)(to,{size:15,"aria-hidden":"true"})," Image ",e.width,"×",e.height]},n):(0,t.jsxs)("details",{className:"image-description",children:[(0,t.jsx)("summary",{children:"Image description"}),(0,t.jsx)("div",{children:e.text})]},n)),(0,t.jsx)(th,{text:p,time:e.createdAt,runMs:i?.runMs,ttftMs:i?.ttftMs,tokensPerSecond:i?.tokensPerSecond,branchMessageId:e.sourceMessageId!==n?e.sourceMessageId:void 0,branchDisabled:a,onBranch:s})]})});function ig({text:e,children:a}){let s=(0,f.useT)(),i=function(e,{charLimit:t=1200,lineLimit:n=14}={}){return e.length>t||e.split(/\r?\n/).length>n}(e),[r,l]=(0,n.useState)(!1),o=i&&!r;return(0,t.jsxs)("div",{className:"collapsible-message","data-collapsed":o||void 0,children:[(0,t.jsx)("div",{className:"collapsible-message-body",children:a}),i&&(0,t.jsx)("button",{type:"button",className:"collapsible-message-toggle","aria-expanded":r,onClick:()=>l(e=>!e),children:s(r?"message.collapse":"message.expand")})]})}let ix=o("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 iv=e.i(8823);function iy(e){return e.id||e.label}function ib({approval:e,submitting:a,answer:s}){let i=(0,f.useT)(),r=(0,n.useMemo)(()=>e.questions??[],[e.questions]),[l,o]=(0,n.useState)({}),[c,d]=(0,n.useState)({}),[u,p]=(0,n.useState)({}),[h,m]=(0,n.useState)(null),g="pending"!==e.status||null!==h,x=e=>{if(!0===c[e]){let t=(u[e]??"").trim();if(!t)return null;let n=r.find(t=>t.id===e);return{questionId:e,values:n?.multiSelect?l[e]??[]:[],otherText:t}}let t=l[e]??[];return t.length>0?{questionId:e,values:t}:null},v=r.length>0&&r.every(e=>null!==x(e.id));return(0,t.jsxs)("section",{className:iv.default.card,"aria-label":i("conversation.question.title"),children:[(0,t.jsxs)("header",{className:iv.default.header,children:[(0,t.jsx)("span",{className:iv.default.icon,children:(0,t.jsx)(ix,{size:16,"aria-hidden":"true"})}),(0,t.jsxs)("div",{children:[(0,t.jsx)("strong",{children:i("conversation.question.title")}),(0,t.jsx)("span",{children:g?i("conversation.question.submitted"):i("conversation.question.waiting")})]})]}),(0,t.jsx)("div",{className:iv.default.questions,children:r.map(n=>{let s=!0===n.multiSelect,m=l[n.id]??[],f=!0===c[n.id];return(0,t.jsxs)("fieldset",{className:iv.default.question,children:[(0,t.jsx)("legend",{children:n.prompt}),s&&(0,t.jsx)("small",{className:iv.default.hint,children:i("conversation.question.multiHint")}),(0,t.jsxs)("div",{className:iv.default.options,children:[n.options.map(i=>{let r=iy(i),l=m.includes(r);return(0,t.jsxs)("label",{className:iv.default.option,"data-selected":l||void 0,children:[(0,t.jsx)("input",{type:s?"checkbox":"radio",name:`question-${e.id}-${n.id}`,checked:l,disabled:g||a,onChange:()=>{var e;return e=n.id,void(o(t=>{let n=t[e]??[];return s?{...t,[e]:n.includes(r)?n.filter(e=>e!==r):[...n,r]}:{...t,[e]:[r]}}),!s&&d(t=>({...t,[e]:!1})))}}),(0,t.jsxs)("span",{children:[(0,t.jsx)("strong",{children:i.label}),i.description&&(0,t.jsx)("small",{children:i.description})]})]},r)}),n.allowOther&&!g&&(0,t.jsxs)("label",{className:iv.default.option,"data-selected":f||void 0,children:[(0,t.jsx)("input",{type:s?"checkbox":"radio",name:`question-${e.id}-${n.id}`,checked:f,disabled:a,onChange:()=>{d(e=>({...e,[n.id]:!f})),f||s||o(e=>({...e,[n.id]:[]}))}}),(0,t.jsxs)("span",{children:[(0,t.jsx)("strong",{children:i("conversation.question.other")}),f&&(0,t.jsx)("input",{className:iv.default.otherInput,value:u[n.id]??"",placeholder:i("conversation.question.otherPlaceholder"),disabled:a,onChange:e=>p(t=>({...t,[n.id]:e.target.value}))})]})]})]}),g&&(0,t.jsxs)("p",{className:iv.default.answered,children:[i("conversation.question.answered"),": ",(t=>{let n=(e.answers??h??[]).find(e=>e.questionId===t);if(!n)return"";let a=(n.values??[]).map(e=>{let n=r.find(e=>e.id===t)?.options.find(t=>iy(t)===e);return n?.label??e});return n.otherText&&a.push(n.otherText),a.join(", ")})(n.id)||"—"]})]},n.id)})}),!g&&(0,t.jsx)("div",{className:iv.default.actions,children:(0,t.jsx)("button",{type:"button",className:iv.default.submit,disabled:!v||a,onClick:()=>{let e=r.map(e=>x(e.id)).filter(e=>null!==e);m(e),s(e)},children:a?i("conversation.question.submitting"):i("conversation.question.submit")})})]})}let ik=o("circle-pause",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"10",x2:"10",y1:"15",y2:"9",key:"c1nkhi"}],["line",{x1:"14",x2:"14",y1:"15",y2:"9",key:"h65svq"}]]),ij=o("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"}]]),iw="reconnecting",iN={waiting_answer:"run.status.waitingAnswer",waiting_approval:"run.status.waitingApproval",waiting_delegation_admission:"run.status.waitingDelegation",waiting_children:"run.status.waitingChildren",running:"run.status.running",running_tool:"run.status.runningTool",reconnecting:"run.status.reconnecting",steering:"run.status.steering",cancelled:"run.status.cancelled",compacting:"run.status.compacting",compaction_queued:"run.status.compactionQueued",compaction_retry_wait:"run.status.compactionRetryWait",compaction_retry:"run.status.compactionRetry",checkpoint_ready:"run.status.checkpointReady",answer_submitted:"run.status.answerSubmitted",approval_granted:"run.status.approvalGranted",approval_rejected:"run.status.approvalRejected",resuming:"run.status.resuming",model_retry:"run.status.modelRetry",preparing_context:"run.status.preparingContext",preparing_run_context:"run.status.preparingRunContext",compacting_run:"run.status.compactingRun",run_compaction_retry:"run.status.runCompactionRetry",run_context_compacted:"run.status.runContextCompacted",run_compaction_skipped:"run.status.runCompactionSkipped",using_checkpoint:"run.status.usingCheckpoint",recovering_tool:"run.status.recoveringTool",output_truncated:"run.status.outputTruncated",using_model:"run.status.usingModel",describing_image:"run.status.describingImage",image_ready:"run.status.imageReady",completed:"run.status.completed",interrupted:"run.status.interrupted",sending:"run.status.sending",uploading_image:"run.status.uploadingImage"};function i_(e,t){return t?`${e}\u001f${t}`:e}function iC(e){let t=e.indexOf("\x1f");return t<0?{code:e,detail:""}:{code:e.slice(0,t),detail:e.slice(t+1)}}function iS(e,t){let{code:n,detail:a}=iC(e),s=iN[n];return s?t(s).split("{detail}").join(a):a||n.replaceAll("_"," ")}function iI({status:e,active:a,waiting:s,waitingForQuestion:i,reconnecting:r,compacting:l,startedAt:o,runId:c,cacheReadTokens:d=0,inputTokens:u=0,outputTokens:p=0}){let h=(0,f.useT)(),m=function(e,t,a){let[s,i]=(0,n.useState)(null),r=(0,n.useRef)(null);return(0,n.useEffect)(()=>{var n;let s;if(!e||!t)return;r.current?.runId!==t&&(r.current={runId:t,origin:(n=Date.now(),Number.isNaN(s=a?Date.parse(a):NaN)||s>n+5e3?n:s)});let l=r.current.origin,o=()=>i({runId:t,seconds:Math.max(0,Math.floor((Date.now()-l)/1e3))}),c=window.requestAnimationFrame(o),d=window.setInterval(o,1e3);return()=>{window.cancelAnimationFrame(c),window.clearInterval(d)}},[e,t,a]),e&&t&&s&&s.runId===t?s.seconds:null}(a,c,o);if(!a&&!e)return null;let g=iC(e).code,x=r?h("run.status.reconnecting"):s?h(i?"run.status.waitingAnswer":"run.status.waitingApproval"):e?iS(e,h):h(l?"run.status.compacting":"run.status.running"),v=r?ij:s?ik:a?eQ:"interrupted"===g||"run_compaction_skipped"===g?eX:e0;return(0,t.jsxs)("div",{className:`run-status ${a?"is-active":""} ${s?"is-waiting":""}`,children:[(0,t.jsxs)("span",{role:"status",children:[(0,t.jsx)(v,{size:14,"aria-hidden":"true",className:!a||s||r?"":"status-spin"}),(0,t.jsx)("span",{children:x})]}),(null!==m||d>0||u>0||p>0)&&(0,t.jsxs)("span",{className:"run-status-metrics","aria-hidden":"true",children:[null!==m?function(e){if(e<60)return`${e}s`;let t=Math.floor(e/60);return`${t}m ${String(e%60).padStart(2,"0")}s`}(m):"",d>0?` ${h("run.status.cache",{count:tu(d)})}`:"",u>0||p>0?` ↑${tu(u)} ↓${tu(p)}`:""]})]})}let iP=o("file-pen-line",[["path",{d:"M14.364 13.634a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506l4.013-4.009a1 1 0 0 0-3.004-3.004z",key:"ukzhwg"}],["path",{d:"M14.487 7.858A1 1 0 0 1 14 7V2",key:"1klhew"}],["path",{d:"M20 19.645V20a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l2.516 2.516",key:"rxaxab"}],["path",{d:"M8 18h1",key:"13wk12"}]]),iT=o("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"}]]),iM=o("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"}]]),iR=o("terminal",[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]]),iE=o("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"}]]),iA=o("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"}]]),i$=o("file-code-corner",[["path",{d:"M4 12.15V4a2 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 2h-3.35",key:"1wthlu"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"m5 16-3 3 3 3",key:"331omg"}],["path",{d:"m9 22 3-3-3-3",key:"lsp7cz"}]]),iz=o("table-2",[["path",{d:"M9 3H5a2 2 0 0 0-2 2v4m6-6h10a2 2 0 0 1 2 2v4M9 3v18m0 0h10a2 2 0 0 0 2-2V9M9 21H5a2 2 0 0 1-2-2V9m0 0h18",key:"gugj83"}]]);function iF({sessionId:e,artifact:a}){let[s,i]=(0,n.useState)(""),[r,l]=(0,n.useState)(null),[o,c]=(0,n.useState)(!1);return((0,n.useEffect)(()=>{let t=new AbortController;return(0,e5.apiFetch)(eF(e,a.artifactId,s||void 0),{signal:t.signal}).then(e=>{c(!1),l(e)}).catch(e=>{"AbortError"!==e.name&&c(!0)}),()=>t.abort()},[a.artifactId,e,s]),r||o)?o||!r?(0,t.jsx)("div",{className:"artifact-preview-state is-error",role:"alert",children:"Preview unavailable"}):(0,t.jsxs)("div",{className:"artifact-table-preview",children:[(r.sheets?.length??0)>1&&(0,t.jsxs)("label",{className:"artifact-sheet-control",children:[(0,t.jsx)("span",{children:"Worksheet"}),(0,t.jsx)("select",{value:s||r.sheet||"",onChange:e=>i(e.target.value),children:r.sheets?.map(e=>(0,t.jsx)("option",{value:e,children:e},e))})]}),(0,t.jsx)("div",{className:"artifact-table-scroll",tabIndex:0,"aria-label":`Scrollable preview of ${a.name}`,children:(0,t.jsxs)("table",{children:[(0,t.jsxs)("caption",{className:"sr-only",children:["Preview of ",a.name]}),(0,t.jsx)("thead",{children:(0,t.jsx)("tr",{children:r.columns.map((e,n)=>(0,t.jsx)("th",{scope:"col",title:e,children:e||`Column ${n+1}`},`${e}-${n}`))})}),(0,t.jsx)("tbody",{children:r.rows.map((e,n)=>(0,t.jsx)("tr",{children:r.columns.map((n,a)=>(0,t.jsx)("td",{title:e[a]??"",children:e[a]??""},a))},n))})]})}),(r.truncatedRows||r.truncatedColumns)&&(0,t.jsxs)("div",{className:"artifact-preview-limit",children:["Preview limited to ",r.rowLimit," rows x ",r.columnLimit," columns"]})]}):(0,t.jsx)("div",{className:"artifact-preview-state",role:"status","aria-live":"polite",children:"Loading preview..."})}function iL({sessionId:e,artifact:n}){var a,s,i;let r,l=eF(e,n.artifactId),o=(a=n.artifactId,`${ez(e,a)}/download`);return(0,t.jsxs)("section",{className:"artifact-result","aria-label":`Artifact ${n.name}`,"data-artifact-kind":n.kind,"data-artifact-id":n.artifactId,children:[(0,t.jsxs)("header",{className:"artifact-result-header",children:[(0,t.jsx)("span",{className:"artifact-result-icon",children:(i=n.kind,r={size:15,"aria-hidden":!0},"image"===i?(0,t.jsx)(to,{...r}):"table"===i?(0,t.jsx)(iz,{...r}):"static_html"===i?(0,t.jsx)(i$,{...r}):(0,t.jsx)(ei,{...r}))}),(0,t.jsx)("span",{className:"artifact-result-name",title:n.name,children:n.name}),(0,t.jsxs)("span",{className:"artifact-result-meta",children:[n.mimeType," · ",(s=n.sizeBytes)<1024?`${s} B`:s<1048576?`${(s/1024).toFixed(+(s<10240))} KB`:`${(s/1048576).toFixed(+(s<0xa00000))} MB`]}),(0,t.jsx)("a",{className:"artifact-download",href:o,download:n.name,"aria-label":`Download ${n.name}`,title:`Download ${n.name}`,children:(0,t.jsx)(iA,{size:15,"aria-hidden":"true"})})]}),"image"===n.kind&&(0,t.jsx)(iD,{artifact:n,previewURL:l}),"table"===n.kind&&(0,t.jsx)(iF,{sessionId:e,artifact:n}),"static_html"===n.kind&&(0,t.jsx)("iframe",{className:"artifact-html-preview",src:l,title:`${n.name} preview`,sandbox:"",referrerPolicy:"no-referrer",loading:"lazy"}),"text"===n.kind&&(0,t.jsx)(iO,{sessionId:e,artifact:n})]})}function iD({artifact:e,previewURL:a}){let[s,i]=(0,n.useState)(!1);return s?(0,t.jsx)("div",{className:"artifact-preview-state is-error",role:"alert",children:"Preview unavailable"}):(0,t.jsxs)("figure",{className:"artifact-image-preview",children:[(0,t.jsx)("img",{src:a,alt:e.name,width:e.width,height:e.height,loading:"lazy",onError:()=>i(!0)}),(e.width||e.height)&&(0,t.jsxs)("figcaption",{children:[e.width," x ",e.height]})]})}function iO({sessionId:e,artifact:a}){let[s,i]=(0,n.useState)(null),[r,l]=(0,n.useState)(!1);return((0,n.useEffect)(()=>{let t=new AbortController;return(0,e5.apiFetch)(eF(e,a.artifactId),{signal:t.signal}).then(i).catch(e=>{"AbortError"!==e.name&&l(!0)}),()=>t.abort()},[a.artifactId,e]),r)?(0,t.jsx)("div",{className:"artifact-preview-state is-error",role:"alert",children:"Preview unavailable"}):s?(0,t.jsxs)("div",{className:"artifact-text-preview",children:[(0,t.jsx)("pre",{children:s.text}),s.truncated&&(0,t.jsx)("span",{children:"Preview truncated"})]}):(0,t.jsx)("div",{className:"artifact-preview-state",role:"status","aria-live":"polite",children:"Loading preview..."})}let iq=o("ban",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M4.929 4.929 19.07 19.071",key:"196cmz"}]]),iB=o("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"}]]),iU=o("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"}]]),iH=new Set(["read","ls","list","grep","search","find","search_compacted_history","todo","ask_user"]),iW=new Set(["write","edit","publish_artifact"]),iV=new Set(["bash","exec"]),iK=new Set(["http","http_request","fetch","web_search","web_fetch"]),iG=/api[_-]?key|token|secret|password|credential|authorization|cookie/i;function iJ(e){let t=e.toLowerCase();return iH.has(t)?"read_only":iW.has(t)?"local_write":iV.has(t)?"shell":iK.has(t)?"external":"delegate_tasks"===t||"delegate_heroes"===t?"delegation":"sensitive"}function iY(e,t=0){return t>8?"[nested value omitted]":Array.isArray(e)?e.slice(0,50).map(e=>iY(e,t+1)):e&&"object"==typeof e?Object.fromEntries(Object.entries(e).slice(0,80).map(([e,n])=>[e,iG.test(e)?"[redacted]":iY(n,t+1)])):e}function iQ(e,t=4e3){return e.length<=t?e:`${e.slice(0,t)}
2
+ [${e.length-t} characters omitted]`}function iZ(e){return e&&"object"==typeof e&&!Array.isArray(e)?e:{}}function iX(e){return"string"==typeof e?e:""}function i0(e){return"number"==typeof e&&Number.isFinite(e)?e:void 0}function i1(e){return"string"==typeof e?`${e.length.toLocaleString()} characters`:void 0}function i2(e,t){let n=e.replace(/\s+/g," ").trim();return n.length<=t?n:`${n.slice(0,t-1)}…`}function i4({child:e,reused:n=!1,activity:a,onRetry:s,onContinue:i}){var r,l,o;let d,u,p=function(e){if("blocked"===e.itemStatus)return"blocked";switch(e.runStatus){case"queued":return"queued";case"running":return"running";case"waiting_for_approval":return"approval";case"succeeded":return"completed";case"failed":return"failed";case"interrupted":return"interrupted";case"cancelled":return"cancelled"}return"succeeded"===e.itemStatus?"completed":"failed"===e.itemStatus||"not_authorized"===e.itemStatus?"failed":"cancelled"===e.itemStatus?"cancelled":"queued"}(e),h=e.result?.summary||e.errorMessage||"",m=void 0!==s&&("failed"===p||"interrupted"===p||"cancelled"===p),f=void 0!==i?(d=(r=e).result,d?.status==="needs_input"?"input":d?.status==="blocked"||"succeeded"===r.itemStatus?"follow_up":null):null,g=("running"===p||"queued"===p)&&a?a:void 0;return(0,t.jsxs)("div",{className:"child-run-row","data-child-run-id":e.childRunId,"data-state":p,role:"listitem",children:[(0,t.jsx)("span",{className:"child-run-icon",children:(0,t.jsx)(c,{size:14,"aria-hidden":"true"})}),(0,t.jsxs)("span",{className:"child-run-identity",children:[(0,t.jsx)("strong",{children:e.name}),(0,t.jsxs)("span",{children:["@",e.heroHandle]}),n&&(0,t.jsx)("span",{className:"child-run-reused",children:"Reused"})]}),(0,t.jsxs)("span",{className:"child-run-actions",children:[m&&(0,t.jsx)("button",{type:"button",className:"child-run-retry","aria-label":`Retry ${e.name}`,title:"Retry this delegated task",onClick:()=>s(e.itemId),children:(0,t.jsx)($,{size:13,"aria-hidden":"true"})}),f&&i&&(0,t.jsx)("button",{type:"button",className:"child-run-retry","aria-label":`${"input"===f?"Reply":"Follow up"} ${e.name}`,title:"input"===f?"Reply to this delegated task":"Follow up privately",onClick:()=>i(e.itemId,f),children:(0,t.jsx)(iU,{size:13,"aria-hidden":"true"})}),(0,t.jsxs)("span",{className:"child-run-status",children:[(u={size:13,"aria-hidden":!0},"completed"===(l=p)?(0,t.jsx)(e0,{...u}):"failed"===l?(0,t.jsx)(eX,{...u}):"blocked"===l||"interrupted"===l?(0,t.jsx)(ik,{...u}):"cancelled"===l?(0,t.jsx)(iE,{...u}):(0,t.jsx)(e1,{...u})),"queued"===(o=p)?"Queued":"running"===o?"Running":"approval"===o?"Approval":"completed"===o?"Completed":"blocked"===o?"Blocked":"interrupted"===o?"Interrupted":"cancelled"===o?"Cancelled":"Failed",g&&(0,t.jsx)("span",{className:"child-run-activity",title:g,children:g}),i5(e)&&("failed"===p||"blocked"===p)&&(0,t.jsx)("span",{className:"child-run-error-code",children:i5(e)})]})]}),h&&(0,t.jsxs)("details",{className:"child-run-result",children:[(0,t.jsx)("summary",{children:e.result?"Result":"Failure"}),(0,t.jsx)("div",{children:iQ(h,1200)})]})]})}function i5(e){if("blocked"===e.itemStatus)return"Blocked";switch(e.errorCode){case"delegation_budget_exceeded":return"Budget exceeded";case"delegation_not_authorized":return"Not authorized";case"delegation_dag_invalid":return"Blocked";case"tool_batch_failed":return"Tool failure";case"process_not_allowed":return"Process not allowed";case"permission_mode_sensitive":return"Sensitive action";default:return e.errorCode?e.errorCode:null}}let i3=o("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 i6({itemID:e,itemName:a,kind:s,sourceAttemptID:i,expectedGeneration:r,onDone:l}){let[o,c]=(0,n.useState)(""),[d,u]=(0,n.useState)(!1),[p,h]=(0,n.useState)(null),f=(0,n.useRef)(null);M(!0,l,{dismissOnEscape:!d}),(0,n.useEffect)(()=>{f.current?.focus()},[]);let g="input"===s?"input":"follow-up",x=async()=>{if(!d&&o.trim()){u(!0),h(null);try{await (0,e5.apiFetch)(`/v1/delegation-items/${encodeURIComponent(e)}/${g}`,{method:"POST",body:JSON.stringify({sourceAttemptId:i,expectedGeneration:r,text:o,clientRequestId:crypto.randomUUID()})}),l()}catch(e){h(e.message),l(),c(o)}finally{u(!1)}}};return(0,t.jsxs)("div",{className:"follow-up-dialog",role:"dialog","aria-label":`${"input"===s?"Reply":"Follow up"} ${a}`,children:[(0,t.jsxs)("div",{className:"follow-up-header",children:[(0,t.jsxs)("span",{children:[(0,t.jsx)(iU,{size:14,"aria-hidden":"true"}),"input"===s?"Reply to delegated task":"Private follow-up"]}),(0,t.jsx)("button",{type:"button",className:"follow-up-close","aria-label":"Close",title:"Close",onClick:l,children:(0,t.jsx)(m,{size:14,"aria-hidden":"true"})})]}),(0,t.jsxs)("div",{className:"follow-up-meta",children:[(0,t.jsx)("strong",{children:a}),(0,t.jsxs)("span",{children:["generation ",r," → ",r+1]})]}),(0,t.jsx)("textarea",{ref:f,className:"follow-up-input",rows:3,placeholder:"input"===s?"Answer the question the delegated task asked…":"Additional private instruction…",value:o,onChange:e=>c(e.target.value)}),p&&(0,t.jsxs)("div",{className:"follow-up-error",role:"status",children:["Refreshed: ",p]}),(0,t.jsx)("div",{className:"follow-up-actions",children:(0,t.jsxs)("button",{type:"button",className:"follow-up-submit",disabled:d||!o.trim(),onClick:x,children:[(0,t.jsx)(i3,{size:13,"aria-hidden":"true"})," ","input"===s?"Send reply":"Follow up"]})})]})}let i8=o("rotate-ccw-clock",[["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"}]]);function i9(e){if(!e)return"";let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function i7({inspection:e}){let n=e.generations??[];if(0===n.length)return null;let a=e.currentGeneration??0;return(0,t.jsxs)("details",{className:"generation-history",children:[(0,t.jsxs)("summary",{children:[(0,t.jsx)(i8,{size:12,"aria-hidden":"true"}),(0,t.jsxs)("span",{children:["Generations (",n.length,")"]})]}),(0,t.jsx)("div",{className:"generation-history-body",children:n.map(e=>(0,t.jsxs)("div",{className:"generation-row","data-generation":e.generation,children:[(0,t.jsx)("strong",{children:e.generation===a?`Generation ${e.generation} (current)`:`Generation ${e.generation}`}),(0,t.jsxs)("span",{children:[e.kind," · ",e.retrySelection?.length??0," selected"," · ",e.reusedAttempts?.length??0," reused"]}),(0,t.jsx)("span",{className:"generation-status-tag","data-status":e.status,children:e.status}),(0,t.jsxs)("details",{className:"generation-detail",children:[(0,t.jsx)("summary",{children:"Details"}),(0,t.jsxs)("ul",{children:[(0,t.jsxs)("li",{children:["Created: ",(0,t.jsx)("time",{children:i9(e.createdAt)})]}),e.completedAt&&(0,t.jsxs)("li",{children:["Completed: ",(0,t.jsx)("time",{children:i9(e.completedAt)})]}),e.retrySelection?.length>0&&(0,t.jsxs)("li",{children:["Retried items: ",e.retrySelection.join(", ")]}),e.reusedAttempts?.map(e=>(0,t.jsxs)("li",{children:["Reused ",e.itemId," · attempt ",e.generation,e.resultDigest?` \xb7 ${e.resultDigest.slice(0,12)}…`:""]},e.attemptId))]})]})]},e.id))})]})}var re=e.i(6929);function rt(...e){return e.filter(Boolean).join(" ")}let rn=(0,n.forwardRef)(function({variant:e="secondary",size:n="md",className:a,type:s="button",...i},r){return(0,t.jsx)("button",{ref:r,type:s,className:rt(re.default.button,re.default[e],re.default[n],a),...i})}),ra=(0,n.forwardRef)(function({label:e,title:n,size:a="md",active:s=!1,className:i,type:r="button",children:l,...o},c){return(0,t.jsx)("button",{ref:c,type:r,"aria-label":e,title:n??e,"data-active":s||void 0,className:rt(re.default.iconButton,"sm"===a&&re.default.iconButtonSm,i),...o,children:l})});var rs=e.i(86609);let ri=[],rr=1,rl=null;function ro(){return ri.shift()??null}function rc(e){if(!rl){let t=[e.title,e.description].filter(Boolean).join("\n\n");return Promise.resolve(window.confirm(t))}return new Promise(t=>{ri.push({id:rr++,options:e,resolve:t}),rl?.()})}function rd(){let[e,a]=(0,n.useState)(null),s=(0,n.useRef)(null),i=(0,n.useRef)(null),r=(0,n.useRef)(null),l=(0,n.useId)(),o=(0,n.useId)(),c=(0,n.useCallback)(()=>{if(null!==s.current)return;let e=ro();null!==e&&(s.current=e,a(e))},[]);(0,n.useEffect)(()=>{let e=(rl=c,()=>{rl===c&&(rl=null)});return queueMicrotask(c),e},[c]);let d=(0,n.useCallback)(e=>{let t=s.current;if(null===t)return;s.current=null,t.resolve(e),a(null);let n=ro();null!==n&&(s.current=n,a(n))},[]);if(M(null!==e,()=>d(!1)),(0,n.useEffect)(()=>{if(null===e)return;let t=window.requestAnimationFrame(()=>r.current?.focus()),n=e=>{if("Tab"!==e.key||null===i.current)return;let t=Array.from(i.current.querySelectorAll('button:not(:disabled), [href], input:not(:disabled), select:not(:disabled), textarea:not(:disabled), [tabindex]:not([tabindex="-1"])')).filter(e=>e.getClientRects().length>0);if(0===t.length)return;let n=t[0],a=t[t.length-1];e.shiftKey&&document.activeElement===n?(e.preventDefault(),a.focus()):e.shiftKey||document.activeElement!==a||(e.preventDefault(),n.focus())};return document.addEventListener("keydown",n),()=>{window.cancelAnimationFrame(t),document.removeEventListener("keydown",n)}},[e]),null===e)return null;let{options:u}=e;return(0,t.jsx)("div",{className:rs.default.overlay,onPointerDown:e=>{e.target===e.currentTarget&&d(!1)},children:(0,t.jsxs)("div",{ref:i,className:rs.default.dialog,role:"alertdialog","aria-modal":"true","aria-labelledby":l,"aria-describedby":u.description?o:void 0,children:[(0,t.jsx)("h2",{id:l,className:rs.default.title,children:u.title}),u.description&&(0,t.jsx)("p",{id:o,className:rs.default.description,children:u.description}),(0,t.jsxs)("div",{className:rs.default.actions,children:[(0,t.jsx)(rn,{ref:r,variant:"secondary",onClick:()=>d(!1),children:u.cancelLabel??"Cancel"}),(0,t.jsx)(rn,{variant:"danger"===u.tone?"danger":"primary",onClick:()=>d(!0),children:u.confirmLabel??"Confirm"})]})]})})}let ru=null,rp=(0,n.createContext)(null);function rh({children:e}){let[a,s]=(0,n.useState)(new Map);(0,n.useEffect)(()=>(ru=e=>{s(t=>{let n=new Map(t),a=new Map(n.get(e.delegationGroupId)??[]);return a.set(e.taskName,e.activity),n.set(e.delegationGroupId,a),n})},()=>void(ru=null)),[]);let i=(0,n.useMemo)(()=>({progress:a}),[a]);return(0,t.jsx)(rp.Provider,{value:i,children:e})}let rm=new Map;function rf({parentRunId:e,toolCallId:a}){let[s,i]=(0,n.useState)(null),[r,l]=(0,n.useState)({}),[o,c]=(0,n.useState)(null),[d,u]=(0,n.useState)(!0),[p,h]=(0,n.useState)(0),[m,f]=(0,n.useState)(!0),[g,x]=(0,n.useState)(null),v=function(){let e=(0,n.useContext)(rp);if(!e)throw Error("useChildProgress must be used inside ChildProgressProvider");return e.progress}(),[y,b]=(0,n.useState)(null);(0,n.useEffect)(()=>{let t,n=new AbortController,s=0,r=async()=>{try{let l=await (0,e5.apiFetch)(`/v1/runs/${encodeURIComponent(e)}/children`,{signal:n.signal});if(n.signal.aborted)return;i(l),c(null);let o=l.groups.filter(e=>e.parentToolCallId===a),d=o.some(e=>{var t;return t=e,"settled"!==t.status&&"cancelled"!==t.status||t.children.some(e=>e.runStatus?!rv(e.runStatus):"pending"===e.itemStatus||"running"===e.itemStatus)});0===o.length?s+=1:s=0;let p=d||0===o.length&&s<20;u(0===o.length&&p),p&&(t=window.setTimeout(r,1200))}catch(e){if(n.signal.aborted)return;c(e.message),u(!1)}};return r(),()=>{n.abort(),void 0!==t&&window.clearTimeout(t)}},[e,p,a]);let k=(0,n.useMemo)(()=>s?.groups.filter(e=>e.parentToolCallId===a)??[],[s,a]),j=(0,n.useMemo)(()=>k.map(e=>e.id).join(","),[k]);(0,n.useEffect)(()=>{let e=new AbortController;for(let t of j.split(",").filter(Boolean))(0,e5.apiFetch)(`/v1/delegations/${encodeURIComponent(t)}`,{signal:e.signal}).then(n=>{e.signal.aborted||l(e=>({...e,[t]:n}))}).catch(()=>{});return()=>e.abort()},[j,p]);let w=k.flatMap(e=>e.children),N=w.filter(e=>e.runStatus&&!rv(e.runStatus)).length,_=(0,n.useCallback)(async(e,t)=>{if(g)return;let n=r[e.id],a=n?.currentGeneration??0;x(t);try{await (0,e5.apiFetch)(`/v1/delegations/${encodeURIComponent(e.id)}/retry`,{method:"POST",body:JSON.stringify({expectedGeneration:a,itemIds:[t],clientRequestId:crypto.randomUUID()})}),h(e=>e+1)}catch(e){c(e.message),h(e=>e+1)}finally{x(null)}},[g,r]),C=(0,n.useCallback)(async e=>{if(!g&&await rc({title:"Cancel all active tasks in this delegation?",description:"Running children will be cancelled; completed results are kept.",confirmLabel:"Cancel tasks",tone:"danger"})){x(`${e.id}:cancel`);try{await (0,e5.apiFetch)(`/v1/delegations/${encodeURIComponent(e.id)}/cancel`,{method:"POST"}),c(null),h(e=>e+1)}catch(e){c(e.message)}finally{x(null)}}},[g]),S=(0,n.useCallback)(async(e,t)=>{if(!g){x(e+t);try{await (0,e5.apiFetch)(`/v1/delegation-approvals/${encodeURIComponent(e)}/decision`,{method:"POST",body:JSON.stringify({decision:t,clientRequestId:crypto.randomUUID()})}),h(e=>e+1)}catch(e){c(e.message)}finally{x(null)}}},[g]);return(0,t.jsxs)("details",{className:"nested-activity",open:m,onToggle:e=>f(e.currentTarget.open),children:[(0,t.jsxs)("summary",{children:[(0,t.jsxs)("span",{children:[(0,t.jsx)(ta,{size:14,"aria-hidden":"true"})," Delegated heroes"]}),(0,t.jsx)("span",{children:w.length?`${w.length} ${N?`\xb7 ${N} active`:"· settled"}`:""})]}),(0,t.jsxs)("div",{className:"nested-activity-body",children:[!s&&!o&&(0,t.jsx)("div",{className:"nested-activity-state",children:"Loading delegated activity…"}),s&&0===k.length&&d&&(0,t.jsx)("div",{className:"nested-activity-state",children:"Preparing delegated runs…"}),s&&0===k.length&&!d&&!o&&(0,t.jsx)("div",{className:"nested-activity-state",children:"No delegated runs were recorded."}),o&&(0,t.jsxs)("div",{className:"nested-activity-error",role:"status",children:[(0,t.jsx)("span",{children:"Delegation activity unavailable"}),(0,t.jsx)("button",{type:"button","aria-label":"Retry delegation activity",title:"Retry",onClick:()=>h(e=>e+1),children:(0,t.jsx)(iB,{size:14,"aria-hidden":"true"})})]}),k.map(e=>(0,t.jsx)(rg,{group:e,inspection:r[e.id],busy:g,progress:v.get(e.id)??rm,onRetry:_,onCancel:C,onDecide:S,onContinue:(e,t,n,a,s)=>b({itemID:e,itemName:t,kind:n,sourceAttemptID:a,expectedGeneration:s})},e.id))]}),y&&(0,t.jsx)(i6,{itemID:y.itemID,itemName:y.itemName,kind:y.kind,sourceAttemptID:y.sourceAttemptID,expectedGeneration:y.expectedGeneration,onDone:()=>{b(null),h(e=>e+1)}})]})}function rg({group:e,inspection:a,busy:s,onRetry:i,onCancel:r,onDecide:l,onContinue:o,progress:c}){let d=(0,n.useMemo)(()=>{let e=new Set;for(let t of a?.generations??[])for(let n of t.reusedAttempts??[])n.childRunId&&e.add(n.childRunId);return e},[a]),u=a?.pendingApproval,p=a?.validActions.includes("cancel")??!1;return(0,t.jsxs)(t.Fragment,{children:[p&&(0,t.jsxs)("div",{className:"delegation-group-actions",children:[(0,t.jsx)("span",{children:"Delegation in progress"}),(0,t.jsxs)("button",{type:"button",className:"child-run-reject",disabled:null!==s,onClick:()=>r(e),children:[(0,t.jsx)(iq,{size:13,"aria-hidden":"true"})," Cancel delegation"]})]}),(0,t.jsx)("div",{className:"child-run-list",role:"list",children:e.children.map(n=>(0,t.jsx)(i4,{child:n,reused:d.has(n.childRunId??""),activity:c.get(n.name),onRetry:t=>i(e,t),onContinue:rx(a,n.itemId)?(e,t)=>{let s=rx(a,e);o(e,n.name,t,s,a?.currentGeneration??0)}:void 0},n.itemId))}),u&&(0,t.jsxs)("div",{className:"delegation-approval-banner",role:"status",children:[(0,t.jsx)("span",{children:"Retry budget increase awaits approval"}),(0,t.jsxs)("span",{className:"banner-actions",children:[(0,t.jsxs)("button",{type:"button",className:"child-run-approve","aria-label":"Approve retry budget",title:"Approve",disabled:null!==s,onClick:()=>l(u.id,"approved"),children:[(0,t.jsx)(Y,{size:13,"aria-hidden":"true"})," Approve"]}),(0,t.jsxs)("button",{type:"button",className:"child-run-reject","aria-label":"Reject retry budget",title:"Reject",disabled:null!==s,onClick:()=>l(u.id,"rejected"),children:[(0,t.jsx)(m,{size:13,"aria-hidden":"true"})," Reject"]})]})]}),a&&(0,t.jsx)(i7,{inspection:a})]})}function rx(e,t){if(!e)return"";let n=e.generations.find(t=>t.generation===e.currentGeneration),a=n?.reusedAttempts.find(e=>e.itemId===t);if(a)return a.attemptId;let s=e.items.find(e=>e.itemId===t);return s?.attempts.find(t=>t.generation===e.currentGeneration)?.attemptId??""}function rv(e){return"succeeded"===e||"failed"===e||"cancelled"===e||"interrupted"===e}let ry={read_only:"conversation.tool.risk.readOnly",local_write:"conversation.tool.risk.localWrite",shell:"conversation.tool.risk.shell",external:"conversation.tool.risk.external",delegation:"conversation.tool.risk.delegation",sensitive:"conversation.tool.risk.sensitive"};function rb({arguments:e}){let a=(0,f.useT)(),s=(0,n.useMemo)(()=>{let t=e&&"object"==typeof e?e:{};return(Array.isArray(t.tasks)?t.tasks:Array.isArray(t.delegations)?t.delegations:[]).map(e=>{let t=e&&"object"==typeof e?e:{},n=String(t.hero??t.heroHandle??""),a=Array.isArray(t.depends)?t.depends.map(String).filter(Boolean):[];return{name:String(t.name??""),hero:n,depends:a}}).filter(e=>e.name||e.hero)},[e]);return 0===s.length?null:(0,t.jsx)("div",{className:"delegation-task-list",role:"list",children:s.map((e,n)=>(0,t.jsxs)("div",{className:"delegation-task",role:"listitem",children:[(0,t.jsx)("span",{className:"delegation-task-name",children:e.name||"(task)"}),e.hero&&(0,t.jsxs)("span",{className:"delegation-task-hero",children:["@",e.hero]}),e.depends.length>0&&(0,t.jsx)("span",{className:"delegation-task-depends",children:a("conversation.tool.after",{names:e.depends.join(", ")})})]},`${e.name}-${n}`))})}function rk({activity:e,sessionId:n}){var a,s,i,r;let l,o=(0,f.useT)(),c=function(e,t){let n=iZ(iY(t)),a=iX(n.path??n.filePath??n.directory??n.cwd);switch(e.toLowerCase()){case"read":{let e=i0(n.offset),t=i0(n.limit);return{label:"Read file",target:a||"Workspace file",detail:void 0!==e&&void 0!==t?`lines ${e}-${e+t-1}`:void 0}}case"ls":case"list":return{label:"List directory",target:a||"Workspace"};case"grep":case"search":return{label:"Search text",target:iX(n.query??n.pattern)||"Search",detail:a||void 0};case"find":return{label:"Find files",target:iX(n.pattern??n.name)||"Files",detail:a||void 0};case"write":return{label:"Write file",target:a||"Workspace file",detail:i1(n.content)};case"edit":return{label:"Edit file",target:a||"Workspace file",detail:i1(n.newText??n.replacement)};case"publish_artifact":return{label:"Publish artifact",target:iX(n.name)||a||"Workspace file"};case"bash":case"exec":return{label:"Run command",target:i2(iX(n.command??n.cmd)||"Shell command",180),detail:a||void 0};case"web_fetch":return{label:"Fetch external page",target:i2(iX(n.url)||"External URL",180)};case"http":case"http_request":case"fetch":return{label:"External request",target:i2(iX(n.url)||"External service",180)};case"search_compacted_history":return{label:"Search compacted history",target:i2(iX(n.query)||"Session history",180)};case"ask_user":{let e=Array.isArray(n.questions)?n.questions:[];return{label:"Ask user",target:1===e.length?"1 question":`${e.length} questions`}}case"delegate_tasks":case"delegate_heroes":{let e=Array.isArray(n.tasks)?n.tasks:Array.isArray(n.delegations)?n.delegations:[],t=e.map(e=>iZ(e)).map(e=>iX(e.role??e.heroHandle)).filter(Boolean);return{label:"Delegate tasks",target:1===e.length?"1 task":`${e.length} tasks`,detail:t.length?t.map(e=>`@${e}`).join(", "):void 0}}case"todo":{let e=Array.isArray(t&&"object"==typeof t&&"todos"in t?t.todos:void 0)?t.todos:[],n=e.filter(e=>e&&"object"==typeof e&&"completed"===e.status).length;return{label:"Update task list",target:`${n}/${e.length} completed`}}default:if(e.includes("__")){let t=e.indexOf("__"),n=e.slice(0,t);return{label:e.slice(t+2)||e,target:`MCP \xb7 ${n}`}}return{label:e||"Unknown tool",target:"Sensitive tool call"}}}(e.toolName,e.arguments),d=e.arguments?iQ(JSON.stringify(iY(e.arguments),null,2),2200):o(e.argumentsFragment?"conversation.tool.incompleteArguments":"conversation.tool.noArguments"),p=e.result?iQ(e.result.content):"";return(0,t.jsxs)("div",{className:"tool-activity-entry",children:[(0,t.jsxs)("details",{className:"tool-activity","data-risk":e.riskClass,"data-state":e.state,"data-tool-call-id":e.toolCallId,open:(a=e.riskClass,"completed"!==e.state||"read_only"!==a||void 0),children:[(0,t.jsxs)("summary",{children:[(0,t.jsx)("span",{className:"tool-icon",children:function(e){let n={size:15,"aria-hidden":!0};switch(e.toLowerCase()){case"read":return(0,t.jsx)(ei,{...n});case"ls":case"list":return(0,t.jsx)(N,{...n});case"grep":case"search":case"find":case"search_compacted_history":return(0,t.jsx)(u,{...n});case"ask_user":return(0,t.jsx)(ix,{...n});case"write":case"edit":case"publish_artifact":return(0,t.jsx)(iP,{...n});case"bash":case"exec":return(0,t.jsx)(iR,{...n});case"delegate_tasks":case"delegate_heroes":return(0,t.jsx)(ta,{...n});case"http":case"http_request":case"fetch":case"web_search":return(0,t.jsx)(iT,{...n});default:return(0,t.jsx)(iM,{...n})}}(e.toolName)}),(0,t.jsxs)("span",{className:"tool-summary",children:[(0,t.jsx)("strong",{children:c.label}),(0,t.jsx)("span",{className:"tool-target",children:c.target}),c.detail&&(0,t.jsx)("span",{className:"tool-detail",children:c.detail})]}),(0,t.jsx)("span",{className:"tool-risk",children:o(ry[e.riskClass]??"conversation.tool.risk.sensitive")}),(0,t.jsxs)("span",{className:"tool-state",children:[(i=e.state,l={size:14,"aria-hidden":!0},"completed"===i?(0,t.jsx)(e0,{...l}):"pending"===i||"running"===i?(0,t.jsx)(e1,{...l}):"rejected"===i?(0,t.jsx)(iE,{...l}):(0,t.jsx)(eX,{...l})),(r=e.state,o("completed"===r?"conversation.tool.state.done":"pending"===r?"conversation.tool.state.pending":"running"===r?"conversation.tool.state.running":"rejected"===r?"conversation.tool.state.rejected":"interrupted"===r?"conversation.tool.state.interrupted":"conversation.tool.state.failed"))]})]}),(0,t.jsxs)("div",{className:"tool-activity-details",children:["delegate_tasks"===(s=e.toolName)||"delegate_heroes"===s?(0,t.jsx)(rb,{arguments:e.arguments}):(0,t.jsxs)("details",{className:"tool-detail-disclosure",children:[(0,t.jsx)("summary",{children:o("conversation.tool.arguments")}),(0,t.jsx)("pre",{children:d})]}),e.result&&(0,t.jsxs)("details",{className:"tool-detail-disclosure",open:"completed"!==e.state||void 0,children:[(0,t.jsx)("summary",{children:o(e.result.isError?"conversation.tool.errorOutput":"conversation.tool.result")}),(0,t.jsx)("pre",{children:p||o("conversation.tool.noOutput")})]})]})]}),("delegate_tasks"===e.toolName||"delegate_heroes"===e.toolName)&&e.runId&&(0,t.jsx)(rf,{parentRunId:e.runId,toolCallId:e.toolCallId}),(e.result?.artifacts.length??0)>0&&(0,t.jsx)("div",{className:"tool-artifact-results",children:e.result?.artifacts.map(e=>(0,t.jsx)(iL,{sessionId:n,artifact:e},e.artifactId))})]})}let rj=(0,n.memo)(function({sessionId:e,turn:n,active:a=!1,pendingApproval:s,resolvingApproval:i,decideApproval:r,answeringQuestion:l,answerQuestion:o,runStatus:c,activeLeafMessageId:d,branchDisabled:u,createBranch:p}){let h=s?n.steps.find(e=>"tool_batch"===e.kind&&s.items.some(t=>e.activities.some(e=>e.toolCallId===t.toolCallId)))?.id:void 0,m=n.steps.map(e=>e.kind).lastIndexOf("assistant"),f=n.steps.map(e=>e.kind).indexOf("assistant");return(0,t.jsxs)("article",{className:`conversation-turn ${a?"is-active":""}`,"data-turn-id":n.id,children:[n.user&&(0,t.jsxs)("div",{className:"user-row","data-message-id":n.user.sourceMessageId??n.user.id,children:[(0,t.jsx)("div",{className:"user-message",children:(0,t.jsx)(ig,{text:n.user.text,children:(0,t.jsx)(iu,{text:n.user.text})})}),(0,t.jsx)(th,{text:n.user.text,time:n.user.createdAt,branchMessageId:n.user.sourceMessageId!==d?n.user.sourceMessageId:void 0,branchDisabled:u,onBranch:p})]}),(0,t.jsxs)("div",{className:"agent-flow",children:[n.steps.map((a,l)=>{if("assistant"===a.kind)return(0,t.jsx)(im,{step:a,isFirst:l===f,isFinal:l===m,metrics:l===m?n.metrics:void 0,activeLeafMessageId:d,branchDisabled:u,createBranch:p},a.id);if("steer"===a.kind)return(0,t.jsxs)("div",{className:"steer-message",children:[(0,t.jsx)(tt,{size:14,"aria-hidden":"true"}),(0,t.jsx)("span",{children:a.text})]},a.id);let o=a.id===h;return(0,t.jsx)(rw,{sessionId:e,batch:a,isLast:l===n.steps.length-1,approval:o?s:null,resolving:i,decide:r},a.activities[0]?.toolCallId||a.id)}),s&&!h&&(0,t.jsx)(rN,{approval:s,resolving:i,decide:r,answering:l,answer:o}),c&&(0,t.jsx)(iI,{...c})]})]})}),rw=(0,n.memo)(function({sessionId:e,batch:a,isLast:s,approval:i,resolving:r,decide:l}){let o=(0,f.useT)(),c=(0,n.useId)(),[d,u]=(0,n.useState)(null),p=a.activities.length,h=a.activities.some(e=>"running"===e.state||"pending"===e.state),m=a.activities.filter(e=>"failed"===e.state||"rejected"===e.state).length,g=m>0||a.activities.some(e=>(e.result?.artifacts.length??0)>0||"delegate_tasks"===e.toolName||"delegate_heroes"===e.toolName),x=d??function({isLast:e,hasActive:t,hasApproval:n,hasOutcome:a}){return e||t||n||a}({isLast:s,hasActive:h,hasApproval:!!i,hasOutcome:g}),v=[...a.activities].reverse().find(e=>"running"===e.state||"pending"===e.state)??a.activities[a.activities.length-1],y=v?"running"===v.state||"pending"===v.state?o("conversation.toolBatch.running",{tool:v.toolName}):v.toolName:"";return(0,t.jsxs)("section",{className:"tool-batch","data-open":x||void 0,"aria-label":o(1===p?"conversation.toolBatch.ariaOne":"conversation.toolBatch.ariaMany",{count:p}),children:[(0,t.jsxs)("button",{type:"button",className:"tool-batch-summary","aria-expanded":x,"aria-controls":c,onClick:()=>u(!x),children:[(0,t.jsx)(j,{size:14,className:"tool-batch-chevron","aria-hidden":"true"}),(0,t.jsx)("span",{className:"tool-batch-title",children:1===p?o("conversation.toolBatch.titleOne"):o("conversation.toolBatch.titleMany",{count:String(p)})}),y&&(0,t.jsx)("span",{className:"tool-batch-now",children:y}),m>0&&(0,t.jsx)("span",{className:"tool-batch-failed",children:o("conversation.toolBatch.failed",{count:String(m)})})]}),(0,t.jsx)("div",{id:c,className:"tool-batch-body",hidden:!x,children:(0,t.jsx)("div",{className:"tool-activity-list",children:a.activities.map(n=>(0,t.jsx)(rk,{sessionId:e,activity:n},n.toolCallId))})}),i&&l&&(0,t.jsx)(tl,{approval:i,resolving:r??null,decide:l})]})});function rN({approval:e,resolving:n,decide:a,answering:s,answer:i}){let r=(0,f.useT)();if("question"===e.kind)return(0,t.jsx)(ib,{approval:e,submitting:!!s,answer:i??(()=>void 0)},e.id);if(!a)return null;let l=e.items.length;return(0,t.jsxs)("section",{className:"tool-batch pending-tool-batch","aria-label":r(1===l?"conversation.toolBatch.ariaOne":"conversation.toolBatch.ariaMany",{count:l}),children:[(0,t.jsxs)("div",{className:"tool-batch-heading",children:[(0,t.jsx)(tn,{size:14,"aria-hidden":"true"}),(0,t.jsx)("span",{children:1===l?r("conversation.toolBatch.pendingOne"):r("conversation.toolBatch.pendingMany",{count:String(l)})})]}),(0,t.jsx)(tl,{approval:e,resolving:n??null,decide:a})]})}function r_(e,t=12){return e?e.length<=t?e:`${e.slice(0,t)}…`:""}function rC(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KiB`:`${(e/1048576).toFixed(1)} MiB`}function rS({sessionId:e,nodes:n,pendingApproval:a,resolvingApproval:s,decideApproval:i,answeringQuestion:r,answerQuestion:l,runStatus:o,activeLeafMessageId:c,branchDisabled:d,createBranch:u}){let p=-1;for(let e=n.length-1;e>=0;e-=1)if("turn"===n[e].kind){p=e;break}return(0,t.jsxs)("div",{className:"conversation-list",children:[n.map((n,h)=>"checkpoint"===n.kind?(0,t.jsx)(rI,{node:n},n.id):(0,t.jsx)(rj,{sessionId:e,turn:n,active:h===p&&!!o?.active,pendingApproval:h===p?a:null,resolvingApproval:s,decideApproval:i,answeringQuestion:r,answerQuestion:l,branchDisabled:d,activeLeafMessageId:c,createBranch:u,runStatus:h===p?o:void 0},n.id)),p<0&&a&&(0,t.jsxs)("div",{className:"orphan-active-flow",children:[(0,t.jsx)(rN,{approval:a,resolving:s,decide:i,answering:r,answer:l}),o&&(0,t.jsx)(iI,{...o})]})]})}function rI({node:e}){let n=(0,f.useT)();return(0,t.jsxs)("div",{className:"checkpoint-separator","data-checkpoint-id":e.id,children:[(0,t.jsx)("span",{className:"checkpoint-line"}),(0,t.jsxs)("details",{children:[(0,t.jsxs)("summary",{children:[(0,t.jsx)(te,{size:14,"aria-hidden":"true"})," Context checkpoint",e.reclaimedTokens>0&&(0,t.jsxs)("span",{children:[e.reclaimedTokens.toLocaleString()," tokens reclaimed"]})]}),(0,t.jsx)("div",{children:e.summary}),(0,t.jsxs)("div",{className:"checkpoint-identity",children:[(0,t.jsx)("span",{children:`${n("checkpoint.promptVersion")}: ${e.promptVersion}`}),""!==e.summaryContractDigest&&(0,t.jsx)("span",{title:e.summaryContractDigest,children:`${n("checkpoint.contract")}: ${r_(e.summaryContractDigest,8)}`})]})]}),(0,t.jsx)("span",{className:"checkpoint-line"})]})}function rP(){let[e,t]=(0,n.useState)(!1),a=(0,n.useRef)(null);(0,n.useEffect)(()=>{if(!e)return;let n=e=>{a.current?.contains(e.target)||t(!1)};return document.addEventListener("pointerdown",n),()=>document.removeEventListener("pointerdown",n)},[e]);let s=(0,n.useCallback)(()=>t(e=>!e),[]);return{open:e,toggle:s,openDropdown:(0,n.useCallback)(()=>t(!0),[]),close:(0,n.useCallback)(()=>t(!1),[]),rootRef:a}}function rT(e,t){let n=e.replace(/\r\n/g,"\n").replace(/[ \t]+\n/g,"\n").replace(/\n{3,}/g,"\n\n").trim();if(!n)return null;let a=(n.length>4e3?`${n.slice(0,4e3).trimEnd()}…`:n).split("\n").map(e=>e.length>0?`> ${e}`:">").join("\n");return`${a}
3
3
  >
4
- > — ${t}`}function rM({history:e,run:a,branches:s,composer:i,actions:r,error:l,clearError:o,projects:c,selectedProject:d,hasModel:u,pinnedProjectIds:p,togglePinProject:h,onSwitchProject:g,onNewProject:x,onOpenSettings:v}){let y=(0,f.useT)(),b=(0,n.useRef)(null),k=(0,n.useRef)(null),j=(0,n.useRef)(!1),w=(0,n.useRef)(0),_=(0,n.useRef)(0),[N,C]=(0,n.useState)(!0),[S,I]=(0,n.useState)(!1),[P,T]=(0,n.useState)(0),M=rP(),R="waiting_for_approval"===a.activeRunStatus||"waiting_delegation_admission"===a.activeRunStatus||!!a.pendingApproval,E=a.pendingApproval?.kind==="question",A=iC(a.status).code===iw&&!R,$=(0,n.useCallback)(()=>{0===c.length?x():M.open?M.close():M.openDropdown()},[M,x,c.length]);async function z(){let t=b.current;if(!t)return;let n=t.scrollHeight,a=t.scrollTop;j.current=!0,await e.loadOlder()?requestAnimationFrame(()=>requestAnimationFrame(()=>{t.scrollTop=a+(t.scrollHeight-n),j.current=!1,w.current=e.messages.length})):j.current=!1}(0,n.useEffect)(()=>{let t=b.current;if(!t||j.current)return;let n=t.scrollHeight-t.scrollTop-t.clientHeight<120;(0===w.current||n)&&k.current?.scrollIntoView({behavior:0===w.current?"auto":"smooth"}),w.current=e.messages.length},[e.messages,a.status]),(0,n.useEffect)(()=>{w.current=0,_.current=0,queueMicrotask(()=>{C(!0),I(!1)})},[e.activeBranchId,e.sessionId]);let F=!!e.sessionId&&!e.activeLeafMessageId&&0===e.messages.length&&!a.activeRun&&!a.pendingApproval,L=!e.sessionId||F,D=function(e,{enabled:t=!0,minWidth:a=640}={}){let[s,i]=(0,n.useState)(null),r=(0,n.useRef)(null);return(0,n.useEffect)(()=>{if(!t)return;let n=e.current;if(!n)return;let s=()=>i(null),l=()=>{null!==r.current&&window.clearTimeout(r.current),r.current=window.setTimeout(()=>{r.current=null,(()=>{if(window.innerWidth<a)return i(null);let e=window.getSelection();if(!e||e.isCollapsed||0===e.rangeCount)return i(null);let t=e.getRangeAt(0),s=t.commonAncestorContainer,r=s instanceof Element?s:s.parentElement;if(!r||!n.contains(r)||r.closest("input, textarea, [contenteditable='true']"))return i(null);let l=e.toString();if(0===l.trim().length)return i(null);let o=t.getBoundingClientRect();0===o.width&&0===o.height?i(null):i({text:l,rect:{top:o.top,bottom:o.bottom,left:o.left,width:o.width}})})()},120)};return document.addEventListener("selectionchange",l),document.addEventListener("pointerup",l),window.addEventListener("resize",s),n.addEventListener("scroll",s,{passive:!0}),()=>{document.removeEventListener("selectionchange",l),document.removeEventListener("pointerup",l),window.removeEventListener("resize",s),n.removeEventListener("scroll",s),null!==r.current&&window.clearTimeout(r.current),r.current=null}},[e,t,a]),{selection:t?s:null,clear:(0,n.useCallback)(()=>{i(null),window.getSelection()?.removeAllRanges()},[])}}(b,{enabled:!L}),{clear:O}=D,q=(0,n.useCallback)(e=>{let t=rT(e,y("selection.source.chat"));t&&(i.setInput([i.input,t].filter(Boolean).join("\n\n")),O(),T(e=>e+1))},[O,i,y]),B=(0,n.useCallback)(e=>{let t=rT(e,y("selection.source.chat"));if(t){var n;i.setInput([i.input,(n=y("selection.explainPrompt"),`${n}
4
+ > — ${t}`}function rM({history:e,run:a,branches:s,composer:i,actions:r,error:l,clearError:o,projects:c,selectedProject:d,hasModel:u,pinnedProjectIds:p,togglePinProject:h,onSwitchProject:g,onNewProject:x,onOpenSettings:v}){let y=(0,f.useT)(),b=(0,n.useRef)(null),k=(0,n.useRef)(null),j=(0,n.useRef)(!1),w=(0,n.useRef)(0),N=(0,n.useRef)(0),[_,C]=(0,n.useState)(!0),[S,I]=(0,n.useState)(!1),[P,T]=(0,n.useState)(0),M=rP(),R="waiting_for_approval"===a.activeRunStatus||"waiting_delegation_admission"===a.activeRunStatus||!!a.pendingApproval,E=a.pendingApproval?.kind==="question",A=iC(a.status).code===iw&&!R,$=(0,n.useCallback)(()=>{0===c.length?x():M.open?M.close():M.openDropdown()},[M,x,c.length]);async function z(){let t=b.current;if(!t)return;let n=t.scrollHeight,a=t.scrollTop;j.current=!0,await e.loadOlder()?requestAnimationFrame(()=>requestAnimationFrame(()=>{t.scrollTop=a+(t.scrollHeight-n),j.current=!1,w.current=e.messages.length})):j.current=!1}(0,n.useEffect)(()=>{let t=b.current;if(!t||j.current)return;let n=t.scrollHeight-t.scrollTop-t.clientHeight<120;(0===w.current||n)&&k.current?.scrollIntoView({behavior:0===w.current?"auto":"smooth"}),w.current=e.messages.length},[e.messages,a.status]),(0,n.useEffect)(()=>{w.current=0,N.current=0,queueMicrotask(()=>{C(!0),I(!1)})},[e.activeBranchId,e.sessionId]);let F=!!e.sessionId&&!e.activeLeafMessageId&&0===e.messages.length&&!a.activeRun&&!a.pendingApproval,L=!e.sessionId||F,D=function(e,{enabled:t=!0,minWidth:a=640}={}){let[s,i]=(0,n.useState)(null),r=(0,n.useRef)(null);return(0,n.useEffect)(()=>{if(!t)return;let n=e.current;if(!n)return;let s=()=>i(null),l=()=>{null!==r.current&&window.clearTimeout(r.current),r.current=window.setTimeout(()=>{r.current=null,(()=>{if(window.innerWidth<a)return i(null);let e=window.getSelection();if(!e||e.isCollapsed||0===e.rangeCount)return i(null);let t=e.getRangeAt(0),s=t.commonAncestorContainer,r=s instanceof Element?s:s.parentElement;if(!r||!n.contains(r)||r.closest("input, textarea, [contenteditable='true']"))return i(null);let l=e.toString();if(0===l.trim().length)return i(null);let o=t.getBoundingClientRect();0===o.width&&0===o.height?i(null):i({text:l,rect:{top:o.top,bottom:o.bottom,left:o.left,width:o.width}})})()},120)};return document.addEventListener("selectionchange",l),document.addEventListener("pointerup",l),window.addEventListener("resize",s),n.addEventListener("scroll",s,{passive:!0}),()=>{document.removeEventListener("selectionchange",l),document.removeEventListener("pointerup",l),window.removeEventListener("resize",s),n.removeEventListener("scroll",s),null!==r.current&&window.clearTimeout(r.current),r.current=null}},[e,t,a]),{selection:t?s:null,clear:(0,n.useCallback)(()=>{i(null),window.getSelection()?.removeAllRanges()},[])}}(b,{enabled:!L}),{clear:O}=D,q=(0,n.useCallback)(e=>{let t=rT(e,y("selection.source.chat"));t&&(i.setInput([i.input,t].filter(Boolean).join("\n\n")),O(),T(e=>e+1))},[O,i,y]),B=(0,n.useCallback)(e=>{let t=rT(e,y("selection.source.chat"));if(t){var n;i.setInput([i.input,(n=y("selection.explainPrompt"),`${n}
5
5
 
6
- ${t}`)].filter(Boolean).join("\n\n")),O(),T(e=>e+1)}},[O,i,y]);(0,n.useEffect)(()=>{let e=b.current;if(!e)return;let t=()=>{let t=e.scrollHeight-e.scrollTop-e.clientHeight<80;C(t),t&&I(!1)};return e.addEventListener("scroll",t,{passive:!0}),t(),()=>e.removeEventListener("scroll",t)},[e.sessionId,L]),(0,n.useEffect)(()=>{let t=e.messages.length;t>_.current&&_.current>0&&!N&&I(!0),_.current=t},[e.messages.length,N]);let U=(0,n.useCallback)(()=>{let e=b.current;e&&(e.scrollTo({top:e.scrollHeight,behavior:"smooth"}),I(!1))},[]);return(0,t.jsxs)("main",{className:"chat-area","data-phase":L?"welcome":"active",children:[l&&(0,t.jsxs)("div",{className:"error-bar",role:"alert",children:[(0,t.jsx)("span",{children:l}),(0,t.jsx)("button",{onClick:o,"aria-label":y("conversation.chat.dismissError"),children:(0,t.jsx)(m,{size:15,"aria-hidden":"true"})})]}),a.recovery&&(0,t.jsxs)("div",{className:`recovery-bar ${a.recovery.retryable?"is-retryable":"is-blocked"}`,"data-testid":"run-recovery",children:[(0,t.jsxs)("span",{children:[(0,t.jsx)("strong",{children:"interrupted"===a.recovery.run.status?y("conversation.chat.runInterrupted"):y("conversation.chat.runFailed")}),a.recovery.retryable?y("conversation.chat.attemptRetryable",{attempt:String(a.recovery.run.attempt)}):function(e,t){switch(e){case"side_effect_boundary":return t("conversation.chat.recovery.sideEffect");case"projected_output":return t("conversation.chat.recovery.projectedOutput");case"active_run":return t("conversation.chat.recovery.activeRun");default:return t("conversation.chat.recovery.notActive")}}(a.recovery.blockedReason,y)]}),a.recovery.retryable&&(0,t.jsx)("button",{type:"button",onClick:a.retryRun,disabled:a.retrying||!!a.activeRun,children:a.retrying?y("conversation.chat.retrying"):y("conversation.chat.retry")})]}),!L&&(0,t.jsxs)("div",{className:"chat-scroll-region",children:[(0,t.jsx)("div",{className:"messages",ref:b,"data-testid":"chat-messages",children:(0,t.jsxs)("div",{className:"conversation-viewport",children:[e.hasMore&&(0,t.jsx)("div",{className:"history-control",children:(0,t.jsx)("button",{type:"button",onClick:z,disabled:e.loadingOlder,children:e.loadingOlder?y("conversation.chat.loadingEarlier"):y("conversation.chat.loadEarlier")})}),e.loading&&(0,t.jsx)("div",{className:"history-state",children:y("conversation.chat.loading")}),e.error&&(0,t.jsx)("div",{className:"history-state history-state-error",children:y("conversation.chat.historyUnavailable",{message:e.error})}),!e.loading&&0===e.messages.length&&!e.error&&!a.pendingApproval&&(0,t.jsxs)("div",{className:"history-empty",children:[(0,t.jsx)("strong",{children:y("conversation.chat.newConversation")}),(0,t.jsx)("span",{children:y("conversation.chat.startHint")})]}),(0,t.jsx)(rS,{sessionId:e.sessionId??"",nodes:e.messages,pendingApproval:a.pendingApproval,resolvingApproval:a.resolvingApproval,decideApproval:a.decideApproval,answeringQuestion:a.answeringQuestion,answerQuestion:a.answerQuestion,activeLeafMessageId:e.activeLeafMessageId,branchDisabled:!!a.activeRun||s.changing,createBranch:s.createBranch,runStatus:a.activeRun||a.status?{status:a.status,active:!!a.activeRun,waiting:R,waitingForQuestion:E,reconnecting:A,compacting:a.compacting,startedAt:a.startedAt,runId:a.activeRun,cacheReadTokens:a.usage?.cacheReadTokens??0,inputTokens:(a.usage?.uncachedInputTokens??0)+(a.usage?.cacheReadTokens??0)+(a.usage?.cacheWriteTokens??0),outputTokens:a.usage?.outputTokens??0}:void 0}),(0,t.jsx)("div",{ref:k})]})}),(0,t.jsx)(J,{nodes:e.messages,scrollContainer:b}),!N&&(0,t.jsxs)("button",{type:"button",className:"chat-jump-latest","data-new":S||void 0,onClick:U,"aria-label":y(S?"conversation.newMessages":"conversation.jumpLatest"),children:[(0,t.jsx)(K,{size:14,"aria-hidden":"true"}),y(S?"conversation.newMessages":"conversation.jumpLatest")]})]}),!L&&D.selection&&(0,t.jsx)(et,{selection:D.selection,onQuote:q,onExplain:B,onDismiss:O}),!L&&(0,t.jsx)(e6,{sessionId:e.sessionId??void 0}),!L&&i.compaction.open&&(0,t.jsx)(e7,{value:i.compaction.instructions,onChange:i.compaction.setInstructions,busy:i.compaction.busy,onConfirm:i.compaction.confirm,onCancel:i.compaction.cancel}),(0,t.jsx)("div",{className:"composer-seat",children:(0,t.jsxs)("div",{className:L?"composer-stack composer-welcome":"composer-stack",children:[L&&(0,t.jsx)(eG,{}),L&&(0,t.jsx)(eJ,{hasModel:u,onOpenSettings:v}),L&&(0,t.jsx)("div",{className:"welcome-workspace-row",children:(0,t.jsx)(eY,{projects:c,selectedProject:d,pinnedProjectIds:p,togglePinProject:h,onRequestProject:$,onSwitchProject:g,projectSelector:M})}),(0,t.jsx)(eK,{selectedSession:e.sessionId,activeLeafMessageId:e.activeLeafMessageId,input:i.input,setInput:i.setInput,focusNonce:P,activeRun:!!a.activeRun,questionPending:!!E,compacting:a.compacting,hasPendingImage:!!i.pendingImage,reconnecting:A,inert:!d,welcome:L,onRequestProject:$,permissionMode:i.displayedPermissionMode,permissionReady:i.permissionReady,setPermissionMode:i.setPermissionMode,models:i.models,providers:i.providers,selectedModelId:i.selectedModelId,setSelectedModelId:i.setSelectedModelId,thinkingEffort:i.thinkingEffort,setThinkingEffort:i.setThinkingEffort,textAttachments:i.textAttachments,removeTextAttachment:i.removeTextAttachment,pendingImage:i.pendingImage,clearPendingImage:i.clearPendingImage,attachFiles:i.attachFiles,uploadImage:i.uploadImage,submit:r.submit,steer:r.steer,steerText:r.steerText,followUp:r.followUp,cancel:a.cancel,cancelFollowUp:a.cancelFollowUp,compactSession:i.compactSession,pendingFollowUps:a.pendingFollowUps,picker:{templates:i.promptPanel.templates,heroes:i.promptPanel.heroes,graphs:i.promptPanel.flows,skills:i.promptPanel.skills,pendingSkills:i.promptPanel.pendingSkills,pendingGraph:i.promptPanel.pendingGraph,selectedHeroId:i.selectedHeroId,onSelectTemplate:i.promptPanel.onSelect,onSelectHero:i.promptPanel.onHeroSelect,onSelectGraph:i.promptPanel.onFlowSelect,onToggleSkill:i.promptPanel.toggleSkill,onClearGraph:i.promptPanel.clearPendingGraph},expanding:i.promptPanel.expanding,expandDiag:i.promptPanel.expandDiag,contextUsage:a.contextUsage,stats:a.stats})]})})]})}let rR=o("menu",[["path",{d:"M4 5h16",key:"1tepv9"}],["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 19h16",key:"1djgab"}]]),rE=o("panel-right",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}]]),rA=o("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"}]]),r$=o("shield-check",[["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:"m9 12 2 2 4-4",key:"dzmm74"}]]);function rz({item:e,onNavigate:n,onDismiss:a}){let s,i=(0,f.useT)(),r=!e.requiresAction;return(0,t.jsxs)("div",{className:"attention-row",role:"listitem","data-kind":e.kind,"data-attention-id":e.id,children:[(0,t.jsx)("span",{className:"attention-icon",children:(s={size:13,"aria-hidden":!0},"needs_input"===e.kind?(0,t.jsx)(iU,{...s}):"approval_required"===e.kind?(0,t.jsx)(r$,{...s}):(e.kind,(0,t.jsx)(eX,{...s})))}),(0,t.jsxs)("button",{type:"button",className:"attention-main",onClick:()=>n(e),children:[(0,t.jsx)("strong",{children:function(e,t){let n=e.display;switch(e.kind){case"approval_required":return t(n?.kind==="retry_budget"?"conversation.attention.retryBudget":"conversation.attention.approvalRequired");case"needs_input":if(n?.kind==="question"){let e=n.questionCount??0;return t(1===e?"conversation.attention.questionOne":"conversation.attention.questionMany",{count:e})}return t("conversation.attention.needsInput");case"delegation_completed":return t("conversation.attention.completed");case"delegation_failed":return t("conversation.attention.failed")}return t("conversation.attention.title")}(e,i)}),(0,t.jsx)("span",{children:e.display?.summary??e.sessionId})]}),r?(0,t.jsx)("button",{type:"button",className:"attention-dismiss","aria-label":i("conversation.attention.dismiss"),title:i("conversation.attention.dismiss"),onClick:()=>a(e),children:(0,t.jsx)(m,{size:13,"aria-hidden":"true"})}):(0,t.jsx)("span",{className:"attention-action-tag",children:function(e,t){switch(e){case"answer_question":return t("conversation.attention.actionAnswerQuestion");case"tool_approval":return t("conversation.attention.actionToolApproval");case"delegation_approval":return t("conversation.attention.actionDelegationApproval");case"delegation_input":return t("conversation.attention.actionDelegationInput")}return t("conversation.attention.action")}(e.action?.kind,i)})]})}function rF({projectId:e,onNavigate:a}){let s=(0,f.useT)(),{items:i,pendingCount:r,refresh:l}=function(e){let[t,a]=(0,n.useState)([]),[s,i]=(0,n.useState)(0);(0,n.useEffect)(()=>{let t;if(!e)return;let n=new AbortController,s=async()=>{try{let t=await (0,e5.apiFetch)(`/v1/attention?projectId=${encodeURIComponent(e)}&status=pending&limit=50`,{signal:n.signal});n.signal.aborted||a(t.items??[])}catch{}finally{n.signal.aborted||(t=window.setTimeout(s,5e3))}};return s(),()=>{n.abort(),void 0!==t&&window.clearTimeout(t)}},[e,s]);let r=(0,n.useMemo)(()=>t.filter(e=>"pending"===e.status).length,[t]);return{items:t,pendingCount:r,refresh:()=>i(e=>e+1)}}(e),[o,c]=(0,n.useState)(!1),d=(0,n.useRef)(null);M(o,()=>c(!1)),(0,n.useEffect)(()=>{if(!o)return;let e=e=>{d.current?.contains(e.target)||c(!1)};return document.addEventListener("pointerdown",e),()=>document.removeEventListener("pointerdown",e)},[o]);let u=async e=>{try{await (0,e5.apiFetch)(`/v1/attention/${encodeURIComponent(e.id)}/dismiss`,{method:"POST",body:JSON.stringify({clientRequestId:crypto.randomUUID()})}),l()}catch{l()}},p=[...i].sort((e,t)=>!!t.requiresAction-!!e.requiresAction);return(0,t.jsxs)("div",{className:"attention-panel",ref:d,children:[(0,t.jsxs)("button",{type:"button",className:"attention-bell","aria-label":s("conversation.attention.aria",{count:String(r)}),title:s("conversation.attention.title"),onClick:()=>c(e=>!e),children:[(0,t.jsx)(rA,{size:15,"aria-hidden":"true"}),r>0&&(0,t.jsx)("span",{className:"attention-badge",children:r>99?"99+":r})]}),o&&(0,t.jsxs)("div",{className:"attention-popover",role:"dialog","aria-label":s("conversation.attention.title"),children:[(0,t.jsxs)("div",{className:"attention-popover-header",children:[(0,t.jsx)("strong",{children:s("conversation.attention.title")}),(0,t.jsx)("span",{children:s("conversation.attention.pending",{count:String(r)})})]}),(0,t.jsxs)("div",{className:"attention-list",role:"list",children:[0===p.length&&(0,t.jsx)("div",{className:"attention-empty",children:s("conversation.attention.empty")}),p.map(e=>(0,t.jsx)(rz,{item:e,onNavigate:e=>{c(!1),a(e)},onDismiss:u},e.id))]})]})]})}let rL=o("git-branch",[["path",{d:"M15 6a9 9 0 0 0-9 9V3",key:"1cii5b"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}]]);function rD({branches:e,activeBranchId:a,loading:s,changing:i,disabled:r,activate:l}){let[o,c]=(0,n.useState)(!1),d=(0,n.useRef)(null),u=e.find(e=>e.id===a);return M(o,()=>c(!1)),(0,n.useEffect)(()=>{if(!o)return;let e=e=>{d.current?.contains(e.target)||c(!1)};return window.addEventListener("pointerdown",e),()=>window.removeEventListener("pointerdown",e)},[o]),(0,t.jsxs)("div",{className:"branch-control",ref:d,children:[(0,t.jsxs)("button",{type:"button",className:"branch-trigger","aria-label":"Choose conversation branch",title:"Choose conversation branch","aria-haspopup":"menu","aria-expanded":o,disabled:r||s||i,onClick:()=>c(e=>!e),children:[(0,t.jsx)(rL,{size:15,"aria-hidden":"true"}),(0,t.jsx)("span",{children:u?.label??(s?"Loading":"Main")}),e.length>1&&(0,t.jsx)("small",{children:e.length})]}),o&&(0,t.jsx)("div",{className:"branch-menu",role:"menu","aria-label":"Conversation branches",children:e.map(e=>(0,t.jsxs)("button",{type:"button",role:"menuitemradio","aria-checked":e.id===a,onClick:()=>{c(!1),l(e.id)},children:[(0,t.jsx)(rL,{size:14,"aria-hidden":"true"}),(0,t.jsxs)("span",{children:[(0,t.jsx)("strong",{children:e.label}),(0,t.jsxs)("small",{children:[e.messageCount," messages"]})]}),e.id===a&&(0,t.jsx)(Y,{size:14,"aria-hidden":"true"})]},e.id))})]})}let rO=o("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"}]]),rq=o("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"}]]),rB=new Set;function rU(){let e=window.localStorage.getItem("ennote-theme");return"light"===e||"dark"===e?e:"system"}function rH(e=rU()){return"dark"===e?"dark":"light"===e?"light":window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function rW(){let e=rU();return`${e}:${rH(e)}`}function rV(e){rB.add(e);let t=window.matchMedia("(prefers-color-scheme: dark)"),n=()=>{"system"===rU()&&(rK(rH("system")),rB.forEach(e=>e()))},a=e=>{"ennote-theme"===e.key&&(rK(rH()),rB.forEach(e=>e()))};return t.addEventListener("change",n),window.addEventListener("storage",a),()=>{rB.delete(e),t.removeEventListener("change",n),window.removeEventListener("storage",a)}}function rK(e){document.documentElement.classList.toggle("dark","dark"===e),document.documentElement.dataset.theme=e}function rG(e,t){let n=()=>{"system"===e?window.localStorage.removeItem("ennote-theme"):window.localStorage.setItem("ennote-theme",e),rK(rH(e)),rB.forEach(e=>e())},a=window.matchMedia("(prefers-reduced-motion: reduce)").matches;if("function"!=typeof document.startViewTransition||a)return void n();let s=t?.x??window.innerWidth/2,i=t?.y??window.innerHeight/2,r=Math.hypot(Math.max(s,window.innerWidth-s),Math.max(i,window.innerHeight-i));document.startViewTransition(n).ready.then(()=>document.documentElement.animate({clipPath:[`circle(0 at ${s}px ${i}px)`,`circle(${r}px at ${s}px ${i}px)`]},{duration:420,easing:"cubic-bezier(0.22, 0.61, 0.36, 1)",pseudoElement:"::view-transition-new(root)"})).catch(()=>void 0)}function rJ(){let[e,t]=(0,n.useSyncExternalStore)(rV,rW,()=>"system:light").split(":"),a=(0,n.useCallback)((e,t)=>rG(e,t),[]),s=(0,n.useCallback)(e=>rG("dark"===t?"light":"dark",e),[t]);return{mode:e,theme:t,isDark:"dark"===t,setThemeMode:a,toggleTheme:s}}function rY(){let{isDark:e,toggleTheme:n}=rJ();return(0,t.jsx)(ra,{label:e?"Switch to light mode":"Switch to dark mode",title:e?"Switch to light mode":"Switch to dark mode","aria-pressed":e,onClick:e=>{let t=e.currentTarget.getBoundingClientRect();n({x:t.left+t.width/2,y:t.top+t.height/2})},children:e?(0,t.jsx)(rq,{size:15,"aria-hidden":"true"}):(0,t.jsx)(rO,{size:15,"aria-hidden":"true"})})}function rQ(e){let{sidebarOpen:n,onToggleSidebar:a,navigationTriggerRef:s,session:i,title:r,projectName:l,projectPath:o,branch:c,rightPanelOpen:d,onToggleRightPanel:u,attention:p}=e,{title:h,editing:m,draft:f,setDraft:x,startEdit:v,save:y,keyDown:b,inputRef:k}=r;return(0,t.jsxs)("div",{className:"app-topbar",children:[(0,t.jsx)(ra,{ref:s,label:n?"Hide navigation":"Open navigation",title:n?"Hide sidebar":"Show sidebar","aria-expanded":n,"aria-controls":"workspace-navigation",onClick:a,children:n?(0,t.jsx)(g,{size:16,"aria-hidden":"true"}):(0,t.jsx)(rR,{size:18,"aria-hidden":"true"})}),(0,t.jsxs)("div",{className:"topbar-title-area",children:[(0,t.jsx)("div",{className:"topbar-title-group",children:m&&i?(0,t.jsx)("input",{ref:k,className:"topbar-title-input",value:f,onChange:e=>x(e.target.value),onKeyDown:b,onBlur:()=>void y()}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("div",{className:"topbar-session-title",title:h,children:h}),i&&(0,t.jsx)("button",{type:"button",className:"topbar-title-edit",onClick:v,title:"Rename session","aria-label":"Rename session",children:(0,t.jsx)(C,{size:12,"aria-hidden":"true"})})]})}),l&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("span",{className:"topbar-project-sep",children:"/"}),(0,t.jsx)("span",{className:"topbar-project-crumb",title:o||l,children:l})]})]}),i&&(0,t.jsx)(rD,{branches:c.branches,activeBranchId:c.activeBranchId,loading:c.loading,changing:c.changing,disabled:c.disabled,activate:c.onActivate}),(0,t.jsx)(rY,{}),(0,t.jsx)(ra,{label:d?"Hide panel":"Show panel",title:d?"Hide panel":"Show panel",active:d,onClick:u,children:(0,t.jsx)(rE,{size:16,"aria-hidden":"true"})}),(0,t.jsx)(rF,{projectId:p.projectId,onNavigate:p.onNavigate})]})}let rZ=o("arrow-left",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]),rX=o("pin",[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z",key:"1nkz8b"}]]),r0=o("pin-off",[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M15 9.34V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H7.89",key:"znwnzq"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M9 9v1.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h11",key:"c9qhm2"}]]),r1=o("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"}]]);function r2(e,t){let n=new URLSearchParams({path:t});return`/v1/projects/${encodeURIComponent(e)}/files/content?${n.toString()}`}async function r4(e,t="/workspace",n){let a;return(0,e5.apiFetch)((a=new URLSearchParams({path:t}),`/v1/projects/${encodeURIComponent(e)}/files?${a.toString()}`),{signal:n})}async function r5(e,t,n){let a=await (0,e5.apiResponse)(r2(e,t),{signal:n});if(!a.ok){let e=await a.json().catch(()=>({}));throw Error(e.error?.message??`HTTP ${a.status}`)}return a}let r3=new Set(["png","jpg","jpeg","gif","webp","svg","bmp","ico","avif"]),r6=new Set(["md","mdx","rmd","qmd"]),r8=new Set(["txt","json","yaml","yml","toml","csv","tsv","log","ts","tsx","js","jsx","mjs","cjs","py","r","rb","go","rs","java","c","cpp","h","hpp","css","scss","less","html","htm","xml","sh","bash","zsh","fish","ps1","bat","sql","graphql","gql","conf","cfg","ini","properties"]);function r9({projectId:a,filePath:s,fileName:i}){var r;let[l,o]=(0,n.useState)({kind:"loading"}),c=i??s.split("/").pop()??s,d=r7(c);(0,n.useEffect)(()=>{let t=new AbortController,n=null;return async function(){o({kind:"loading"});try{var i,r,l;let u,p,h=await r5(a,s,t.signal),m=Number(h.headers.get("Content-Length")??0),f=h.headers.get("Content-Type")?.split(";",1)[0]??"application/octet-stream";if(r6.has(d)){if(m>4194304)throw Error("Text preview exceeds the 4 MiB limit");let e=await h.text();t.signal.aborted||o({kind:"markdown",content:e,size:e.length});return}if(i=c,r=f,u=r7(i),p=i.toLowerCase(),r.startsWith("text/")||r8.has(u)||["dockerfile","makefile"].includes(p)||p.startsWith(".env")){let n,a;if(m>4194304)throw Error("Text preview exceeds the 4 MiB limit");let s=await h.text(),i=(l=c,n=r7(l),a=l.toLowerCase(),"dockerfile"===a?"dockerfile":"makefile"===a?"makefile":({ts:"typescript",tsx:"tsx",js:"javascript",jsx:"jsx",mjs:"javascript",cjs:"javascript",py:"python",r:"r",rb:"ruby",go:"go",rs:"rust",java:"java",c:"c",cpp:"cpp",h:"c",hpp:"cpp",css:"css",scss:"scss",less:"less",html:"html",htm:"html",xml:"xml",json:"json",yaml:"yaml",yml:"yaml",toml:"toml",sh:"bash",bash:"bash",zsh:"bash",fish:"fish",ps1:"powershell",sql:"sql",graphql:"graphql",gql:"graphql"})[n]??null),r=null;if(i)try{let{codeToHtml:t}=await e.A(140);r=await t(s,{lang:i,themes:{light:"github-light",dark:"github-dark"},defaultColor:!1})}catch{r=null}t.signal.aborted||o({kind:"code",content:s,highlighted:r,language:i??"text",size:s.length});return}if(r3.has(d)||f.startsWith("image/")){let e=await h.blob();n=URL.createObjectURL(e),t.signal.aborted||o({kind:"image",url:n,mime:f,size:e.size});return}if("pdf"===d||"application/pdf"===f){let e=await h.blob();n=URL.createObjectURL(e),t.signal.aborted||o({kind:"pdf",url:n,mime:f,size:e.size});return}o({kind:"unsupported",mime:f,size:m})}catch(e){t.signal.aborted||o({kind:"error",message:e.message})}}(),()=>{t.abort(),n&&URL.revokeObjectURL(n)}},[d,s,c,a]);let u="size"in l?(r=l.size)?r<1024?`${r} B`:r<1048576?`${(r/1024).toFixed(1)} KB`:`${(r/1048576).toFixed(1)} MB`:"0 B":null,p="code"===l.kind?l.language:d||l.kind,h=(0,e5.workerAPIPath)(r2(a,s));return(0,t.jsxs)("div",{className:"file-viewer",children:[(0,t.jsxs)("div",{className:"file-viewer-status",children:[(0,t.jsx)("span",{className:"file-viewer-type",children:p}),(0,t.jsx)("span",{className:"file-viewer-path",title:s,children:s}),u&&(0,t.jsx)("span",{children:u}),(0,t.jsx)("a",{className:"file-viewer-download",href:h,download:c,title:"Download file","aria-label":`Download ${c}`,children:(0,t.jsx)(iA,{size:13,"aria-hidden":"true"})})]}),(0,t.jsxs)("div",{className:"file-viewer-body",children:["loading"===l.kind&&(0,t.jsxs)("div",{className:"file-viewer-empty",children:[(0,t.jsx)(eQ,{className:"spin",size:18}),"Loading preview..."]}),"error"===l.kind&&(0,t.jsxs)("div",{className:"file-viewer-empty is-error",children:[(0,t.jsx)(r1,{size:20}),l.message]}),"markdown"===l.kind&&(0,t.jsx)("article",{className:"markdown-body file-markdown",children:(0,t.jsx)(a9,{remarkPlugins:[id],children:l.content})}),"code"===l.kind&&l.highlighted&&(0,t.jsx)("div",{className:"file-code",dangerouslySetInnerHTML:{__html:l.highlighted}}),"code"===l.kind&&!l.highlighted&&(0,t.jsx)("pre",{className:"file-code-plain",children:l.content}),"image"===l.kind&&(0,t.jsx)("div",{className:"file-image-stage",children:(0,t.jsx)("img",{src:l.url,alt:c})}),"pdf"===l.kind&&(0,t.jsx)("iframe",{className:"file-pdf",src:l.url,title:c}),"unsupported"===l.kind&&(0,t.jsxs)("div",{className:"file-viewer-empty",children:[(0,t.jsx)(r1,{size:20}),"Preview is not available for ",l.mime,"."]})]})]})}function r7(e){return e.includes(".")?e.toLowerCase().split(".").pop()??"":""}var le=e.i(51535);let lt="var(--text-dim)";function ln({size:e=14,open:n=!1}){return n?(0,t.jsxs)("svg",{width:e,height:e,viewBox:"0 0 16 16",fill:"none",children:[(0,t.jsx)("path",{d:"M1 4.5A1 1 0 0 1 2 3.5H5.5L7 5h7.5v1H1V4.5Z",fill:lt}),(0,t.jsx)("path",{d:"M1 6h14.5L14 13H2L1 6Z",stroke:lt,strokeWidth:"1",fill:lt,fillOpacity:"0.12"})]}):(0,t.jsx)("svg",{width:e,height:e,viewBox:"0 0 16 16",fill:"none",children:(0,t.jsx)("path",{d:"M1 4.5A1 1 0 0 1 2 3.5H5.5L7 5H14a1 1 0 0 1 1 1v6a1 1 0 0 1-1 1H2a1 1 0 0 1-1-1V4.5Z",stroke:lt,strokeWidth:"1",fill:lt,fillOpacity:"0.1"})})}function la({size:e=14}){return(0,t.jsxs)("svg",{width:e,height:e,viewBox:"0 0 16 16",fill:"none",children:[(0,t.jsx)("path",{d:"M3 2h7l3 3v9H3V2Z",stroke:lt,strokeWidth:"1",fill:lt,fillOpacity:"0.08"}),(0,t.jsx)("path",{d:"M10 2v3h3",stroke:lt,strokeWidth:"1",fill:"none",strokeLinejoin:"round"})]})}function ls({label:e,size:n=14}){return(0,t.jsxs)("svg",{width:n,height:n,viewBox:"0 0 14 14",fill:"none",children:[(0,t.jsx)("path",{d:"M2.5 1h6l3 3v9h-9V1Z",stroke:lt,strokeWidth:"0.9",fill:lt,fillOpacity:"0.07",strokeLinejoin:"round"}),(0,t.jsx)("path",{d:"M8.5 1v3h3",stroke:lt,strokeWidth:"0.9",fill:"none",strokeLinejoin:"round"}),(0,t.jsx)("text",{x:"7",y:"9.5",textAnchor:"middle",fontSize:"3.4",fontFamily:"var(--font-mono), monospace",fontWeight:"600",fill:lt,children:e})]})}function li({size:e=14}){return(0,t.jsx)(ls,{label:"PY",size:e})}function lr({size:e=14}){return(0,t.jsx)(ls,{label:"R",size:e})}function ll({size:e=14}){return(0,t.jsx)(ls,{label:"TS",size:e})}function lo({size:e=14}){return(0,t.jsx)(ls,{label:"JS",size:e})}function lc({size:e=14}){return(0,t.jsx)(ls,{label:"{}",size:e})}function ld({size:e=14}){return(0,t.jsx)(ls,{label:"CSS",size:e})}function lu({size:e=14}){return(0,t.jsx)(ls,{label:"HTM",size:e})}function lp({size:e=14}){return(0,t.jsxs)("svg",{width:e,height:e,viewBox:"0 0 14 14",fill:"none",children:[(0,t.jsx)("path",{d:"M2.5 1h6l3 3v9h-9V1Z",stroke:lt,strokeWidth:"0.9",fill:lt,fillOpacity:"0.07",strokeLinejoin:"round"}),(0,t.jsx)("path",{d:"M8.5 1v3h3",stroke:lt,strokeWidth:"0.9",fill:"none",strokeLinejoin:"round"}),(0,t.jsx)("path",{d:"M3.5 9.5V7l1.5 1.5L6.5 7v2.5",stroke:lt,strokeWidth:"0.9",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"}),(0,t.jsx)("path",{d:"M8 7v2.5M7 9l1 1.5 1-1.5",stroke:lt,strokeWidth:"0.9",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"})]})}function lh({size:e=14}){return(0,t.jsx)(ls,{label:"YML",size:e})}function lm({size:e=14}){return(0,t.jsxs)("svg",{width:e,height:e,viewBox:"0 0 14 14",fill:"none",children:[(0,t.jsx)("path",{d:"M2.5 1h6l3 3v9h-9V1Z",stroke:lt,strokeWidth:"0.9",fill:lt,fillOpacity:"0.07",strokeLinejoin:"round"}),(0,t.jsx)("path",{d:"M8.5 1v3h3",stroke:lt,strokeWidth:"0.9",fill:"none",strokeLinejoin:"round"}),(0,t.jsx)("path",{d:"M4 7.5l2 1.5-2 1.5",stroke:lt,strokeWidth:"0.95",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"}),(0,t.jsx)("path",{d:"M7.5 10.5h2.5",stroke:lt,strokeWidth:"0.95",strokeLinecap:"round"})]})}function lf({size:e=14}){return(0,t.jsx)(ls,{label:"GO",size:e})}function lg({size:e=14}){return(0,t.jsx)(ls,{label:"RS",size:e})}function lx({size:e=14}){return(0,t.jsx)(ls,{label:"SQL",size:e})}function lv({size:e=14}){return(0,t.jsxs)("svg",{width:e,height:e,viewBox:"0 0 14 14",fill:"none",children:[(0,t.jsx)("path",{d:"M2.5 1h6l3 3v9h-9V1Z",stroke:lt,strokeWidth:"0.9",fill:lt,fillOpacity:"0.07",strokeLinejoin:"round"}),(0,t.jsx)("path",{d:"M8.5 1v3h3",stroke:lt,strokeWidth:"0.9",fill:"none",strokeLinejoin:"round"}),(0,t.jsx)("rect",{x:"3.5",y:"6.5",width:"2",height:"1.5",rx:"0.3",stroke:lt,strokeWidth:"0.8"}),(0,t.jsx)("rect",{x:"6",y:"6.5",width:"2",height:"1.5",rx:"0.3",stroke:lt,strokeWidth:"0.8"}),(0,t.jsx)("rect",{x:"3.5",y:"8.5",width:"2",height:"1.5",rx:"0.3",stroke:lt,strokeWidth:"0.8"})]})}function ly({size:e=14}){return(0,t.jsxs)("svg",{width:e,height:e,viewBox:"0 0 14 14",fill:"none",children:[(0,t.jsx)("path",{d:"M2.5 1h6l3 3v9h-9V1Z",stroke:lt,strokeWidth:"0.9",fill:lt,fillOpacity:"0.07",strokeLinejoin:"round"}),(0,t.jsx)("path",{d:"M8.5 1v3h3",stroke:lt,strokeWidth:"0.9",fill:"none",strokeLinejoin:"round"}),(0,t.jsx)("circle",{cx:"7",cy:"8.5",r:"1.3",stroke:lt,strokeWidth:"0.9"}),(0,t.jsx)("path",{d:"M7 6.5v.7M7 10.3v.7M5 8.5h.7M8.3 8.5H9M5.5 6.9l.5.5M8.5 9.6l-.5-.5M5.5 10.1l.5-.5M8.5 7.4l-.5.5",stroke:lt,strokeWidth:"0.8",strokeLinecap:"round"})]})}function lb(e,n=14){let a=e.toLowerCase(),s=a.split(".").pop()??"";return"dockerfile"===a||a.startsWith("dockerfile.")?(0,t.jsx)(lv,{size:n}):"py"===s?(0,t.jsx)(li,{size:n}):"r"===s||"rds"===s||"qs"===s?(0,t.jsx)(lr,{size:n}):"ts"===s?(0,t.jsx)(ll,{size:n}):"tsx"===s?(0,t.jsx)(ls,{label:"TSX",size:n}):"js"===s||"mjs"===s||"cjs"===s?(0,t.jsx)(lo,{size:n}):"jsx"===s?(0,t.jsx)(ls,{label:"JSX",size:n}):"json"===s||"jsonl"===s?(0,t.jsx)(lc,{size:n}):"css"===s||"less"===s?(0,t.jsx)(ld,{size:n}):"scss"===s?(0,t.jsx)(ls,{label:"SC",size:n}):"html"===s||"htm"===s?(0,t.jsx)(lu,{size:n}):"md"===s||"mdx"===s?(0,t.jsx)(lp,{size:n}):"yaml"===s||"yml"===s?(0,t.jsx)(lh,{size:n}):"toml"===s?(0,t.jsx)(ls,{label:"TOM",size:n}):"sh"===s||"bash"===s||"zsh"===s||"fish"===s?(0,t.jsx)(lm,{size:n}):"rs"===s?(0,t.jsx)(lg,{size:n}):"go"===s?(0,t.jsx)(lf,{size:n}):"sql"===s?(0,t.jsx)(lx,{size:n}):"tf"===s||"hcl"===s?(0,t.jsx)(ls,{label:"TF",size:n}):"lock"===s?(0,t.jsx)(ls,{label:"LK",size:n}):s.endsWith("config.ts")||s.endsWith("config.js")||s.endsWith("config.mjs")?(0,t.jsx)(ly,{size:n}):(0,t.jsx)(la,{size:n})}function lk({tabs:e,activeTabId:a,onSelectTab:s,onCloseTab:i,onReorder:r,closeLabel:l}){let[o,c]=(0,n.useState)(null),[d,u]=(0,n.useState)(null),p=()=>{c(null),u(null)};return(0,t.jsx)("div",{role:"tablist","aria-label":"Workspace panel tabs",className:le.default.bar,children:e.map((n,f)=>{let g=n.id===a,x=!1!==n.closable;return(0,t.jsxs)("div",{role:"tab",tabIndex:g?0:-1,"aria-selected":g,onClick:()=>s(n.id),draggable:!!r,"data-dragging":o===n.id||void 0,"data-drop-target":d===n.id||void 0,onDragStart:e=>{r&&(c(n.id),e.dataTransfer.effectAllowed="move",e.dataTransfer.setData("text/plain",n.id))},onDragOver:e=>{r&&null!==o&&o!==n.id&&(e.preventDefault(),e.dataTransfer.dropEffect="move",u(n.id))},onDragLeave:()=>u(e=>e===n.id?null:e),onDrop:e=>{if(!r)return;e.preventDefault();let t=e.dataTransfer.getData("text/plain")||o;t&&t!==n.id&&r(t,n.id),p()},onDragEnd:p,onKeyDown:t=>{if("Enter"===t.key||" "===t.key){t.preventDefault(),s(n.id);return}if("ArrowLeft"!==t.key&&"ArrowRight"!==t.key)return;t.preventDefault();let a=(f+("ArrowRight"===t.key?1:-1)+e.length)%e.length;t.altKey&&r?r(n.id,e[a].id):(s(e[a].id),t.currentTarget.parentElement?.children[a]?.focus())},className:le.default.tab,"data-active":g||void 0,children:[(0,t.jsx)("span",{className:le.default.icon,children:"files"===n.icon?(0,t.jsx)(w,{size:13,"aria-hidden":"true"}):"report"===n.icon?(0,t.jsx)(ei,{size:13,"aria-hidden":"true"}):"tools"===n.icon?(0,t.jsx)(tn,{size:13,"aria-hidden":"true"}):"graph"===n.icon?(0,t.jsx)(h,{size:13,"aria-hidden":"true"}):lb(n.filePath??n.label,13)}),(0,t.jsx)("span",{className:le.default.label,title:n.filePath??n.label,children:n.label}),x&&(0,t.jsx)("button",{type:"button",className:le.default.close,onClick:e=>{e.stopPropagation(),i(n.id)},title:"Close","aria-label":l?l(n):`Close ${n.label}`,children:(0,t.jsx)(m,{size:10,"aria-hidden":"true"})})]},n.id)})})}function lj(){document.body.style.cursor="",document.body.style.userSelect=""}function lw({side:e,onResize:a,onResizeStart:s,onResizeEnd:i,ariaLabel:r,value:l,min:o,max:c}){let d=(0,n.useRef)(null),u=(0,n.useRef)(!1),p=(0,n.useRef)(0),[h,m]=(0,n.useState)(!1),f=(0,n.useCallback)(e=>{if(!u.current)return;u.current=!1,m(!1);let t=d.current;t&&void 0!==e&&t.hasPointerCapture(e)&&t.releasePointerCapture(e),lj(),i?.()},[i]),g=(0,n.useCallback)(e=>{0===e.button&&e.isPrimary&&(e.preventDefault(),u.current=!0,p.current=e.clientX,m(!0),s?.(),e.currentTarget.setPointerCapture(e.pointerId),document.body.style.cursor="col-resize",document.body.style.userSelect="none")},[s]),x=(0,n.useCallback)(e=>{if(!u.current)return;e.preventDefault();let t=e.clientX-p.current;p.current=e.clientX,a(t)},[a]),v=(0,n.useCallback)(e=>{e.preventDefault(),f(e.pointerId)},[f]),y=(0,n.useCallback)(e=>{f(e.pointerId)},[f]);(0,n.useEffect)(()=>()=>{u.current&&(u.current=!1,lj(),i?.())},[i]);let b=(0,n.useCallback)(e=>{if("ArrowLeft"!==e.key&&"ArrowRight"!==e.key)return;e.preventDefault();let t="ArrowRight"===e.key?16:-16;s?.(),a(t),i?.()},[a,i,s]);return(0,t.jsx)("div",{ref:d,role:"separator","aria-label":r??"Resize panel","aria-orientation":"vertical","aria-valuemin":o,"aria-valuemax":c,"aria-valuenow":l,tabIndex:0,className:`resize-handle${h?" resize-handle-dragging":""}`,"data-side":e,onPointerDown:g,onPointerMove:x,onPointerUp:v,onPointerCancel:y,onKeyDown:b,style:{alignSelf:"stretch",cursor:"col-resize",display:"flex",flexShrink:0,justifyContent:"center",marginLeft:-5,marginRight:-5,position:"relative",touchAction:"none",width:10,zIndex:"var(--layer-drag-overlay)"},children:(0,t.jsx)("div",{className:"resize-handle-line"})})}function l_(e){let t=(0,n.useCallback)(t=>{let n=window.matchMedia(e);return n.addEventListener("change",t),()=>n.removeEventListener("change",t)},[e]),a=(0,n.useCallback)(()=>window.matchMedia(e).matches,[e]);return(0,n.useSyncExternalStore)(t,a,()=>!1)}function lN(e,t){return Math.max(280,Math.min(1e3,e-t-440-5))}function lC(e,t){return Math.max(220,Math.min(Math.max(220,t-8-264),null!==e&&Number.isFinite(e)?e:280))}function lS(e,t){return t?"narrow":e>=520?"wide":e>=280?"medium":"narrow"}var lI=e.i(73574);function lP(e){let n=(0,f.useT)(),a=l_("(max-width: 960px)"),s=lS(e.width,a),i=lC(e.primaryWidth,e.width);if("narrow"===s)return(0,t.jsxs)("div",{className:lI.default.narrow,children:[e.narrowStrip,(0,t.jsx)("div",{className:lI.default.body,children:e.narrowBody})]});let r=null!==e.inspectorBody,l="medium"===s&&r,o=r&&!e.primaryHidden,c=r&&!l&&e.primaryHidden,d=l&&!e.navigatorOpen,u=l?{width:"min(300px, 78%)"}:c?{display:"none"}:o?{width:i}:{flex:"1 1 auto"},p=l?"medium":c?"fill":o?"wide":"single";return(0,t.jsxs)("div",{className:lI.default.lanes,"data-mode":p,"data-testid":"right-panel-lanes",children:[l&&e.navigatorOpen&&(0,t.jsx)("div",{className:lI.default.backdrop,onPointerDown:e.onToggleNavigator,"aria-hidden":"true"},"backdrop"),(0,t.jsxs)("div",{className:`${lI.default.primary}${l?` ${lI.default["primary-overlay"]}`:""}`,style:u,"data-open":l&&e.navigatorOpen||void 0,"data-parked":d||void 0,"data-testid":"right-panel-primary",inert:d,children:[e.channelStrip,(0,t.jsx)("div",{className:lI.default.body,children:e.channelBody})]},"primary"),o&&!l&&(0,t.jsx)(lw,{side:"right",ariaLabel:n("rightPanel.resizeNavigator"),value:i,min:220,max:Math.max(220,e.width-8-264),onResize:e.onResizePrimary,onResizeStart:e.onResizePrimaryStart,onResizeEnd:e.onResizePrimaryEnd},"divider"),r&&(0,t.jsxs)("div",{className:lI.default.inspector,children:[(0,t.jsxs)("div",{className:lI.default.strip,children:[e.inspectorStrip,(0,t.jsx)("button",{type:"button",className:lI.default["nav-toggle"],"aria-label":n(e.navigatorOpen?"rightPanel.hideNavigator":"rightPanel.showNavigator"),"aria-expanded":e.navigatorOpen,"data-open":e.navigatorOpen||void 0,onClick:e.onToggleNavigator,children:(0,t.jsx)(g,{size:15,"aria-hidden":"true"})})]}),(0,t.jsx)("div",{className:lI.default.body,children:e.inspectorBody})]},"inspector")]})}let lT={files:"rightPanel.files",graph:"rightPanel.graphs",tools:"rightPanel.status"},lM={files:"files",graph:"graph",tools:"tools"};function lR(e,t){return e.map(e=>({id:e,label:t(lT[e]),closable:!0,icon:lM[e]}))}let lE={files:o("files",[["path",{d:"M15 2h-4a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V8",key:"14sh0y"}],["path",{d:"M16.706 2.706A2.4 2.4 0 0 0 15 2v5a1 1 0 0 0 1 1h5a2.4 2.4 0 0 0-.706-1.706z",key:"1970lx"}],["path",{d:"M5 7a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h8a2 2 0 0 0 1.732-1",key:"l4dndm"}]]),graph:h,tools:tn};function lA(e){return(0,t.jsxs)("div",{className:"right-panel-launcher",role:"group","aria-label":e.hint,children:[(0,t.jsx)("p",{className:"right-panel-launcher-hint",children:e.hint}),e.channels.map(n=>{let a=lE[n];return(0,t.jsxs)("button",{type:"button",className:"right-panel-launcher-card",onClick:()=>e.onOpen(n),children:[(0,t.jsx)(a,{size:15,"aria-hidden":"true"}),(0,t.jsx)("span",{children:(0,e.t)(lT[n])})]},n)})]})}let l$=o("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"}]]);function lz({projectId:e,displayPath:a,onOpenFile:s,onPreviewFile:i}){let[r,l]=(0,n.useState)([]),[o,c]=(0,n.useState)(!!e),[d,p]=(0,n.useState)(null),[h,m]=(0,n.useState)(new Map),[f,g]=(0,n.useState)(""),[x,v]=(0,n.useState)(new Set),[y,b]=(0,n.useState)(new Set),[k,j]=(0,n.useState)(new Map),[w,_]=(0,n.useState)(null),[N,C]=(0,n.useState)(null),S=(0,n.useRef)(new Map),I=(0,n.useRef)(36),P=(0,n.useRef)(null);(0,n.useEffect)(()=>{if(!e)return;let t=new AbortController,n=S.current;return r4(e,"/workspace",t.signal).then(e=>{l(e??[]),p(null)}).catch(e=>{t.signal.aborted||p(e.message)}).finally(()=>{t.signal.aborted||c(!1)}),()=>{t.abort(),n.forEach(e=>e.abort()),n.clear()}},[e]);let T=(0,n.useCallback)(async t=>{if(!e||k.has(t)||S.current.has(t))return;let n=new AbortController;S.current.set(t,n),b(e=>new Set(e).add(t));try{let a=await r4(e,t,n.signal);j(e=>new Map(e).set(t,a)),m(e=>{if(!e.has(t))return e;let n=new Map(e);return n.delete(t),n})}catch(e){n.signal.aborted||(m(n=>new Map(n).set(t,e.message)),v(e=>{if(!e.has(t))return e;let n=new Set(e);return n.delete(t),n}))}finally{S.current.get(t)===n&&S.current.delete(t),b(e=>{let n=new Set(e);return n.delete(t),n})}},[k,e]),M=(0,n.useCallback)(e=>{v(t=>{if(!t.has(e))return t;let n=new Set(t);return n.delete(e),n})},[]),R=(0,n.useCallback)(e=>{v(t=>t.has(e)?t:new Set(t).add(e)),T(e)},[T]),E=f.trim().toLowerCase(),A=(0,n.useMemo)(()=>{let e=[],t=new Map,n=e=>{if(!E)return!0;let a=t.get(e.path);if(void 0!==a)return a;let s=e.name.toLowerCase().includes(E)||e.isDir&&(k.get(e.path)??[]).some(n);return t.set(e.path,s),s},a=(t,s,i)=>{for(let r of t){if(!n(r))continue;e.push({entry:r,depth:s,parentPath:i});let t=r.isDir&&!h.has(r.path)&&(!!E||x.has(r.path));if(!r.isDir||!t)continue;let l=k.get(r.path);l&&a(l,s+1,r.path)}};return a(r,0,null),e},[r,k,x,h,E]);(0,n.useEffect)(()=>{if(!E){I.current=36;return}let e=window.setTimeout(()=>{let e=new Set;for(let t of r)t.isDir&&e.add(t.path);for(let t of k.values())for(let n of t)n.isDir&&e.add(n.path);let t=0;for(let n of e){if(t>=12||I.current<=0)break;k.has(n)||h.has(n)||S.current.has(n)||(T(n),I.current-=1,t+=1)}},250);return()=>window.clearTimeout(e)},[E,r,k,h,T]);let $=(0,n.useCallback)(e=>{_(e);let t=P.current;if(!t)return;let n=t.querySelector(`[data-path="${CSS.escape(e)}"]`);n?.focus()},[]),z=(0,n.useCallback)((e,t)=>{let n=A[e+t];n&&$(n.entry.path)},[A,$]),F=(0,n.useCallback)((e,t)=>{if(e.target!==e.currentTarget&&("Enter"===e.key||" "===e.key))return;let n=A[t];if(n)switch(e.key){case"ArrowDown":e.preventDefault(),z(t,1);break;case"ArrowUp":e.preventDefault(),z(t,-1);break;case"Home":e.preventDefault(),A[0]&&$(A[0].entry.path);break;case"End":e.preventDefault(),A.length>0&&$(A[A.length-1].entry.path);break;case"ArrowRight":if(e.preventDefault(),!n.entry.isDir||E)break;if(!x.has(n.entry.path)){R(n.entry.path);break}if(!k.has(n.entry.path))break;z(t,1);break;case"ArrowLeft":{if(e.preventDefault(),!E&&n.entry.isDir&&x.has(n.entry.path)){M(n.entry.path);break}let t=A.findIndex(e=>e.entry.path===n.parentPath);t>=0&&$(A[t].entry.path);break}case"Enter":case" ":if(e.preventDefault(),n.entry.isDir){if(E)break;x.has(n.entry.path)?M(n.entry.path):R(n.entry.path)}else s(n.entry.path,n.entry.name);break;case"ContextMenu":let a;e.preventDefault(),C({path:n.entry.path,...{x:(a=e.currentTarget.getBoundingClientRect()).left+12,y:a.bottom}})}},[A,x,k,E,M,R,z,$,s]),L=null===w?-1:A.findIndex(e=>e.entry.path===w),D=null!==w&&-1===L;(0,n.useEffect)(()=>{if(!D)return;let e=window.setTimeout(()=>{let e=P.current?.contains(document.activeElement)??!1,t=A[0]?.entry.path;_(t??null),e&&t&&$(t)},0);return()=>window.clearTimeout(e)},[D,A,$]);let O=L>=0?L:0;return(0,t.jsxs)("div",{className:"file-tree-panel",children:[(0,t.jsxs)("div",{className:"file-tree-header",children:[(0,t.jsx)("div",{className:"file-tree-heading",children:"Files"}),(0,t.jsx)("div",{className:"file-tree-path",title:a??"/workspace",children:e?a??"/workspace":"No project selected"}),(0,t.jsxs)("label",{className:"file-filter",children:[(0,t.jsx)(u,{size:12,"aria-hidden":"true"}),(0,t.jsx)("span",{className:"sr-only",children:"Filter files"}),(0,t.jsx)("input",{value:f,onChange:e=>g(e.target.value),onKeyDown:e=>{"ArrowDown"===e.key&&0!==A.length&&(e.preventDefault(),$(A[0].entry.path))},placeholder:"Filter files...",disabled:!e})]})]}),(0,t.jsx)("div",{className:"file-tree-list",ref:P,onScroll:()=>C(null),children:e?o?(0,t.jsx)("div",{className:"file-tree-state",children:"Loading..."}):d&&0===r.length?(0,t.jsx)("div",{className:"file-tree-state is-error",children:d}):0===A.length?(0,t.jsx)("div",{className:"file-tree-state",children:E?"No files match.":"No files found."}):(0,t.jsxs)(t.Fragment,{children:[d&&(0,t.jsx)("p",{className:"file-tree-inline-error",role:"alert",children:d}),(0,t.jsx)("div",{role:"tree","aria-label":"Workspace files",children:A.map((e,n)=>{var a;let{entry:r,depth:l}=e,o=E?(k.get(r.path)?.length??0)>0:x.has(r.path),c=y.has(r.path);return(0,t.jsxs)("div",{className:"file-tree-row",style:{paddingLeft:8+16*l},role:"treeitem","aria-level":l+1,"aria-expanded":r.isDir?o:void 0,"aria-selected":w===r.path||void 0,tabIndex:n===O?0:-1,"data-path":r.path,onClick:()=>{(_(r.path),r.isDir)?E||(o?M(r.path):R(r.path)):s(r.path,r.name)},onContextMenu:e=>{e.preventDefault(),$(r.path),C({path:r.path,x:e.clientX,y:e.clientY})},onKeyDown:e=>F(e,n),children:[(0,t.jsxs)("span",{className:"file-tree-main",title:r.path,children:[(0,t.jsx)("span",{className:"file-tree-icon",children:r.isDir?(0,t.jsx)(ln,{size:14,open:o}):lb(r.name,14)}),(0,t.jsx)("span",{className:"file-tree-name",children:r.name}),!r.isDir&&(0,t.jsx)("span",{className:"file-tree-size",children:(a=r.size)<1024?`${a} B`:a<1048576?`${(a/1024).toFixed(1)} K`:`${(a/1048576).toFixed(1)} M`}),c&&(0,t.jsx)("span",{className:"file-tree-loading",children:"..."}),h.has(r.path)&&(0,t.jsx)("span",{className:"file-tree-error-mark",title:h.get(r.path),"aria-label":`Could not list ${r.name}: ${h.get(r.path)}`,children:"!"})]}),!r.isDir&&(0,t.jsx)("button",{type:"button",className:"file-preview-action",onClick:e=>{e.stopPropagation(),i(r.path,r.name)},"aria-label":`Preview ${r.name} in a floating window`,title:"Open floating preview",onKeyDown:e=>{("Enter"===e.key||" "===e.key)&&e.stopPropagation()},children:(0,t.jsx)(l$,{size:12,"aria-hidden":"true"})})]},r.path)})})]}):(0,t.jsx)("div",{className:"file-tree-empty",children:"Select a project to browse files."})}),N&&(0,t.jsx)(lF,{row:A.find(e=>e.entry.path===N.path),at:N,onClose:()=>{let e=N.path;C(null),$(e)},onOpenFile:s,onPreviewFile:i})]})}function lF(e){let{row:a,at:s,onClose:i,onOpenFile:r,onPreviewFile:l}=e,o=(0,n.useRef)(null),c=a?.entry.path??null;if((0,n.useEffect)(()=>{if(null===c)return;let e=window.requestAnimationFrame(()=>{o.current?.querySelector('[role="menuitem"]')?.focus()});return()=>window.cancelAnimationFrame(e)},[c]),!a)return null;let{entry:d}=a,u=async()=>{try{await navigator.clipboard.writeText(d.path)}catch{}i()};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("div",{className:"file-tree-menu-backdrop",onPointerDown:i,"aria-hidden":"true"}),(0,t.jsxs)("div",{ref:o,className:"file-tree-menu",role:"menu","aria-label":`Actions for ${d.name}`,style:{left:s.x,top:s.y},onKeyDown:e=>{let t=Array.from(o.current?.querySelectorAll('[role="menuitem"]')??[]),n=t.indexOf(document.activeElement);if("Escape"===e.key){e.preventDefault(),i();return}if("ArrowDown"!==e.key&&"ArrowUp"!==e.key)return;e.preventDefault();let a="ArrowDown"===e.key?1:-1;t[(n+a+t.length)%t.length]?.focus()},children:[!d.isDir&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("button",{type:"button",role:"menuitem",onClick:()=>{r(d.path,d.name),i()},children:"Open"}),(0,t.jsx)("button",{type:"button",role:"menuitem",onClick:()=>{l(d.path,d.name),i()},children:"Open in floating window"})]}),(0,t.jsxs)("button",{type:"button",role:"menuitem",onClick:()=>void u(),children:[(0,t.jsx)(Q,{size:12,"aria-hidden":"true"})," Copy path"]})]})]})}function lL(e){return(0,t.jsx)(lz,{projectId:e.projectId,displayPath:e.displayPath,onOpenFile:e.onOpenFile,onPreviewFile:e.onPreviewFile},e.projectId??"no-project")}var lD=e.i(57840);function lO(e,t,n){if(!n)return"";let a=`${t}.${n}`,s=e(a);return s===a?n:s}function lq({sessionId:e}){let a=(0,f.useT)(),[s,i]=(0,n.useState)([]),[r,l]=(0,n.useState)({}),[o,c]=(0,n.useState)(null),[d,u]=(0,n.useState)(null),p=(0,n.useCallback)(async()=>{if(e)try{let t=await (0,e5.apiFetch)(`/v1/sessions/${encodeURIComponent(e)}/graph-runs`)??[];i(t),u(null),c(e=>{if(0===t.length)return null;let n=t[0].runId??null;if(null===n)return null;if(null===e||!t.some(t=>t.runId===e))return n;let a=t[0].createdAt,s=t.find(t=>t.runId===e)?.createdAt;return a&&s&&s<a?n:e})}catch(e){u(e.message)}},[e]);(0,n.useEffect)(()=>{let e,t=new AbortController,n=!1,a=async()=>{await p(),n||(e=window.setTimeout(a,1500))};return a(),()=>{n=!0,t.abort(),void 0!==e&&window.clearTimeout(e)}},[p]),(0,n.useEffect)(()=>{if(!e||!o)return;let t=!1;return(0,e5.apiFetch)(`/v1/sessions/${encodeURIComponent(e)}/graph-runs/${encodeURIComponent(o)}`).then(e=>{t||l(t=>({...t,[o]:e.nodes??[]}))}).catch(()=>{t||u("graph.loadFailed")}),()=>{t=!0}},[o,e]);let m=(0,n.useMemo)(()=>s.filter(e=>"running"===e.state).length,[s]);return(0,t.jsxs)("div",{className:lD.default.root,children:[(0,t.jsxs)("div",{className:lD.default.header,children:[(0,t.jsxs)("span",{className:lD.default.title,children:[(0,t.jsx)(h,{size:13,"aria-hidden":"true"}),a("graph.title")]}),m>0&&(0,t.jsx)("span",{className:lD.default.running,children:a("graph.running",{count:String(m)})})]}),d&&(0,t.jsx)("div",{className:lD.default.error,children:"graph.loadFailed"===d?a(d):d}),(0,t.jsx)("div",{className:lD.default.scroll,children:e?0===s.length?(0,t.jsx)("div",{className:lD.default.empty,children:a("graph.emptyRuns")}):s.map(e=>(0,t.jsx)(lB,{run:e,nodes:r[e.runId??""]??[],expanded:o===e.runId,onToggle:()=>c(t=>t===e.runId?null:e.runId??null),nodesLoading:o===e.runId&&void 0===r[e.runId??""],t:a},e.runId)):(0,t.jsx)("div",{className:lD.default.empty,children:a("graph.emptySession")})})]})}function lB({run:e,nodes:n,expanded:a,onToggle:s,nodesLoading:i,t:r}){let l=e.state,o=n.length,c=n.filter(e=>"completed"===e.terminalState).length,d=lO(r,"graph.flow",l);return(0,t.jsxs)("div",{className:lD.default.card,children:[(0,t.jsxs)("button",{type:"button",onClick:s,className:lD.default.cardButton,"data-expanded":a||void 0,"aria-expanded":a,children:[(0,t.jsx)(j,{size:11,className:lD.default.chevron,"data-expanded":a||void 0,"aria-hidden":"true"}),(0,t.jsx)("span",{className:`${lD.default.stateDot} ${lD.default.flowDot}`,"data-flow-state":l}),(0,t.jsx)("span",{className:lD.default.cardTitle,children:e.inputs?.name?String(e.inputs.name):r("graph.unnamed")}),(0,t.jsx)("span",{className:lD.default.cardSummary,children:o>0?r("graph.tasks",{done:String(c),total:String(o)}):d})]}),a&&(0,t.jsxs)("div",{className:lD.default.details,children:[(0,t.jsxs)("div",{className:lD.default.meta,children:[(0,t.jsx)("span",{children:r("graph.stateLabel",{state:d})}),e.totalTokensUsed?(0,t.jsx)("span",{children:r("graph.tokens",{count:String(e.totalTokensUsed)})}):null,e.createdAt?(0,t.jsx)("span",{children:function(e,t){let n=new Date(e);if(Number.isNaN(n.getTime()))return e;let a=Math.floor((new Date().getTime()-n.getTime())/6e4);return a<1?t("graph.justNow"):a<60?t("graph.minutesAgo",{count:String(a)}):n.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}(e.createdAt,r)}):null]}),i?(0,t.jsx)("div",{className:lD.default.stateLine,children:r("graph.loadingTasks")}):0===n.length?(0,t.jsx)("div",{className:lD.default.stateLine,children:r("graph.noTasks")}):(0,t.jsx)("ul",{className:lD.default.nodeList,children:n.map(e=>(0,t.jsxs)("li",{className:lD.default.nodeRow,children:[(0,t.jsx)("span",{className:lD.default.nodeDot,"data-node-state":e.terminalState}),(0,t.jsx)("span",{className:lD.default.nodeName,children:e.handle}),(0,t.jsx)("span",{className:lD.default.nodeState,children:lO(r,"graph.node",e.terminalState)})]},e.taskIndex??e.handle))})]})]})}function lU({sessionId:e}){return(0,t.jsx)(lq,{sessionId:e})}let lH=o("file-clock",[["path",{d:"M16 22h2a2 2 0 0 0 2-2V8a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 14 2H6a2 2 0 0 0-2 2v2.85",key:"ryk6xj"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M8 14v2.2l1.6 1",key:"6m4bie"}],["circle",{cx:"8",cy:"16",r:"6",key:"10v15b"}]]);function lW(e,t=""){return"string"==typeof e?e:t}function lV(e){let t=[];for(let n of e??[]){let e=n??{};switch(e.type){case"text":t.push({kind:"text",text:lW(e.text)});break;case"thinking":t.push({kind:"thinking",text:lW(e.text)});break;case"tool_call":{let n=e.toolCall??{},a=function(e){if(null!=e){if("object"!=typeof e)return String(e);try{return JSON.stringify(e,null,2)}catch{return}}}(n.arguments);t.push({kind:"tool_call",callId:lW(n.id),name:lW(n.name,"tool")||"tool",...void 0===a?{}:{arguments:a}});break}case"tool_result":{let n=e.toolResult??{};t.push({kind:"tool_result",callId:lW(n.toolCallId),name:lW(n.toolName,"tool")||"tool",text:lW(n.content),isError:!0===n.isError});break}case"image":{let n=e.image??{};t.push({kind:"image",width:"number"==typeof n.width?n.width:0,height:"number"==typeof n.height?n.height:0});break}case"image_description":{let n=e.imageDescription??{};t.push({kind:"text",text:lW(n.text)});break}default:t.push({kind:"unknown",type:lW(e.type,"unknown")||"unknown"})}}return t}var lK=e.i(26694);let lG={base:"Platform",hero:"Hero",context:"Project context",skills_catalog:"Skill catalog",skill_preload:"Preloaded skill"},lJ={system:"System",user:"User",assistant:"Assistant",tool:"Tool"};function lY({runId:e,composition:a,mcp:s,transcript:i,loading:r,error:l,t:o}){let[c,d]=(0,n.useState)(!1);if(!e)return(0,t.jsx)("div",{className:`${lK.default.empty} ${lK.default.muted}`,children:o("inspector.noRun")});if(r&&!a)return(0,t.jsx)("div",{className:`${lK.default.empty} ${lK.default.muted}`,children:o("inspector.loading")});if(l)return(0,t.jsx)("div",{className:`${lK.default.empty} ${lK.default.muted}`,children:l});if(!a)return(0,t.jsx)("div",{className:`${lK.default.empty} ${lK.default.muted}`,children:o("inspector.loading")});let u=a.sections??[],p=a.recorded,h=u.filter(e=>"skill_preload"===e.kind&&"user-skill-select"===e.source).map(e=>e.skillId||e.id.replace(/^skill\.preload\./,""));return(0,t.jsxs)("div",{className:lK.default.body,children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("div",{className:lK.default.heading,children:o("inspector.run")}),(0,t.jsx)("div",{className:`${lK.default.digest} ${lK.default.digestValue} ${lK.default.runId}`,title:e,children:e}),(0,t.jsx)("div",{className:lK.default.muted,children:p?o("inspector.frozen"):o("inspector.unrecorded")})]}),p&&(0,t.jsxs)("div",{children:[(0,t.jsxs)("div",{className:lK.default.heading,children:[o("inspector.composition"),(0,t.jsx)("span",{className:lK.default.headingCount,children:o("inspector.sections",{count:String(u.length)})})]}),h.length>0&&(0,t.jsxs)("div",{className:lK.default.selectedSkills,children:[(0,t.jsx)("span",{className:lK.default.muted,children:o("inspector.selectedSkills")}),h.map(e=>(0,t.jsx)("code",{children:`/${e}`},e))]}),(0,t.jsx)("div",{className:lK.default.group,children:u.map(e=>(0,t.jsx)(lQ,{section:e},e.id))})]}),(0,t.jsxs)("div",{className:lK.default.digestGroup,children:[(0,t.jsx)(l1,{label:o("inspector.sectionsDigest"),value:a.sectionsDigest}),(0,t.jsx)(l1,{label:o("inspector.composedDigest"),value:a.composedDigest}),(0,t.jsx)(l1,{label:o("inspector.baseDigest"),value:a.digest}),""!==a.skillCatalogState&&(0,t.jsxs)("div",{className:lK.default.catalogRow,children:[(0,t.jsx)("span",{className:`${lK.default.muted} ${lK.default.catalogLabel}`,children:o("inspector.skillCatalog")}),(0,t.jsx)("span",{className:`${lK.default.muted} ${lK.default.catalogValue}`,children:o(`inspector.catalog.${a.skillCatalogState}`)}),""!==a.skillCatalogDigest&&(0,t.jsx)("span",{className:`${lK.default.digest} ${lK.default.digestValue}`,title:a.skillCatalogDigest,children:rN(a.skillCatalogDigest,8)})]})]}),p&&void 0!==s&&(0,t.jsxs)("div",{children:[(0,t.jsx)("div",{className:lK.default.heading,children:o("inspector.mcp")}),null===s||0===(s.servers??[]).length?(0,t.jsx)("div",{className:lK.default.muted,children:o("inspector.mcpNone")}):(0,t.jsx)("div",{className:lK.default.group,children:(s.servers??[]).map(e=>(0,t.jsx)(lZ,{server:e,t:o},e.id))})]}),i?(0,t.jsxs)("div",{children:[(0,t.jsx)("div",{className:lK.default.heading,children:o("inspector.transcript")}),(0,t.jsx)("div",{className:`${lK.default.muted} ${lK.default.transcriptNote}`,children:o("inspector.transcriptNote")}),0===i.messages.length?(0,t.jsx)("div",{className:lK.default.muted,children:o("inspector.transcriptEmpty")}):(0,t.jsx)("div",{className:lK.default.group,children:i.messages.map(e=>(0,t.jsx)(lX,{message:e,t:o},e.id))}),i.hasMore&&(0,t.jsx)("button",{type:"button",className:lK.default.loadOlder,disabled:i.loadingOlder,onClick:i.loadOlder,children:o("inspector.transcriptOlder")})]}):null,p&&(0,t.jsxs)("div",{children:[(0,t.jsxs)("button",{type:"button",className:lK.default.promptToggle,onClick:()=>d(e=>!e),"aria-expanded":c,children:[c?(0,t.jsx)(q,{size:13,"aria-hidden":"true"}):(0,t.jsx)(j,{size:13,"aria-hidden":"true"}),(0,t.jsx)(lH,{size:13,"aria-hidden":"true"}),o("inspector.prompt"),(0,t.jsx)("span",{className:lK.default.promptBytes,children:rC(a.prompt.length)})]}),c&&(0,t.jsx)("pre",{"data-run-prompt":!0,className:lK.default.promptPre,children:a.prompt})]})]})}function lQ({section:e}){return(0,t.jsxs)("div",{"data-prompt-section":e.kind,className:lK.default.sectionRow,children:[(0,t.jsx)("span",{className:lK.default.sectionKind,children:lG[e.kind]??e.kind}),(0,t.jsxs)("span",{className:lK.default.sectionIdentity,children:[(0,t.jsx)("span",{className:lK.default.sectionId,children:e.id}),(0,t.jsx)("span",{className:lK.default.sectionSource,children:` \xb7 ${e.source}`})]}),(0,t.jsx)("span",{className:lK.default.sectionBytes,children:rC(e.bytes)}),(0,t.jsx)("span",{className:`${lK.default.digest} ${lK.default.sectionDigest}`,title:e.digest,children:rN(e.digest,8)})]})}function lZ({server:e,t:n}){let a=""!==e.unavailableReason;return(0,t.jsxs)("div",{"data-mcp-server":e.bindingId,"data-unavailable":a||void 0,className:lK.default.mcpRow,children:[(0,t.jsxs)("div",{className:lK.default.mcpHead,children:[(0,t.jsxs)("span",{className:lK.default.mcpIdentity,children:[(0,t.jsx)("span",{className:lK.default.mcpBinding,children:e.bindingId}),(0,t.jsx)("span",{className:lK.default.mcpRevision,children:` \xb7 rev ${e.bindingRevision}`})]}),e.required&&(0,t.jsx)("span",{className:lK.default.badge,children:n("inspector.mcpRequired")}),(0,t.jsx)("span",{className:lK.default.mcpTools,children:n("inspector.mcpTools",{count:String((e.tools??[]).length)})})]}),a&&(0,t.jsx)("div",{className:lK.default.mcpUnavailable,children:`${n("inspector.mcpUnavailable")}: ${e.unavailableReason}`}),""!==e.negotiatedProtocol&&(0,t.jsx)("div",{className:`${lK.default.muted} ${lK.default.mcpProtocol}`,children:`${n("inspector.mcpProtocol")}: ${e.negotiatedProtocol}`}),""!==e.instructions&&(0,t.jsxs)("details",{className:lK.default.mcpInstructions,children:[(0,t.jsx)("summary",{className:lK.default.muted,title:e.instructionsDigest,children:n("inspector.mcpInstructions")}),(0,t.jsx)("div",{className:lK.default.mcpInstructionsBody,"data-mcp-instructions":!0,children:e.instructions})]}),(e.tools??[]).length>0&&(0,t.jsx)("div",{className:lK.default.toolList,children:(e.tools??[]).map(e=>(0,t.jsxs)("div",{className:lK.default.toolRow,children:[(0,t.jsx)("span",{className:`${lK.default.digest} ${lK.default.toolName}`,title:e.exposedName,children:e.exposedName}),(0,t.jsx)("span",{className:lK.default.toolRisk,children:e.riskClass})]},e.exposedName))})]})}function lX({message:e,t:n}){let a=lV(e.content),s=function(e){let t=new Set,n=[];for(let a of lV(e))"tool_call"!==a.kind||t.has(a.name)||(t.add(a.name),n.push(a.name));return n.join(", ")}(e.content);return(0,t.jsxs)("details",{"data-transcript-ordinal":e.ordinal,className:lK.default.transcriptRow,children:[(0,t.jsxs)("summary",{className:lK.default.transcriptSummary,children:[(0,t.jsx)("span",{className:`${lK.default.muted} ${lK.default.transcriptOrdinal}`,children:e.ordinal}),(0,t.jsx)("span",{className:lK.default.transcriptRole,children:lJ[e.role]??e.role}),"private"===e.visibility&&(0,t.jsx)("span",{"data-transcript-private":!0,className:lK.default.privateBadge,children:n("inspector.transcriptPrivate")}),(0,t.jsx)("span",{className:lK.default.transcriptExcerpt,children:s})]}),(0,t.jsx)("div",{className:lK.default.transcriptBody,children:a.map((e,a)=>(0,t.jsx)(l0,{entry:e,t:n},a))})]})}function l0({entry:e,t:n}){return"text"===e.kind?(0,t.jsx)("div",{className:lK.default.entryPre,children:e.text}):"thinking"===e.kind?(0,t.jsxs)("div",{children:[(0,t.jsx)("div",{className:`${lK.default.muted} ${lK.default.entryLabel}`,children:n("inspector.transcriptThinking")}),(0,t.jsx)("div",{className:lK.default.entryPre,children:e.text})]}):"image"===e.kind?(0,t.jsx)("div",{className:lK.default.muted,children:n("inspector.transcriptImage",{width:String(e.width),height:String(e.height)})}):"unknown"===e.kind?(0,t.jsx)("div",{className:lK.default.muted,children:n("inspector.transcriptUnknown",{type:e.type})}):"tool_call"===e.kind?(0,t.jsxs)("details",{children:[(0,t.jsx)("summary",{className:`${lK.default.muted} ${lK.default.entrySummary}`,children:`${n("inspector.transcriptCall")} ${e.name}`}),void 0!==e.arguments&&(0,t.jsx)("div",{className:`${lK.default.entryPre} ${lK.default.entryBlock}`,children:e.arguments})]}):(0,t.jsxs)("details",{children:[(0,t.jsx)("summary",{className:`${lK.default.muted} ${lK.default.entrySummary}`,"data-error":e.isError||void 0,children:`${n(e.isError?"inspector.transcriptError":"inspector.transcriptResult")} ${e.name}`}),(0,t.jsx)("div",{className:`${lK.default.entryPre} ${lK.default.entryBlock}`,children:e.text})]})}function l1({label:e,value:n}){return n?(0,t.jsxs)("div",{className:lK.default.digestLine,children:[(0,t.jsx)("span",{className:`${lK.default.muted} ${lK.default.digestLabel}`,children:e}),(0,t.jsx)("span",{className:`${lK.default.digest} ${lK.default.digestValue}`,title:n,children:n})]}):null}function l2({runId:e,composition:n,mcp:a,transcript:s,loading:i,error:r}){let l=(0,f.useT)();return(0,t.jsx)(lY,{runId:e,composition:n,mcp:a,transcript:s,loading:i,error:r,t:l})}function l4(e){let{runId:a,selectedSession:s,sessionTitle:i,activeRun:r,status:l,permissionMode:o}=e,c=function(e){let[t,a]=(0,n.useState)(null),[s,i]=(0,n.useState)(!1),[r,l]=(0,n.useState)(null);return(0,n.useEffect)(()=>{if(!e){let e=window.setTimeout(()=>{a(null),l(null),i(!1)},0);return()=>window.clearTimeout(e)}let t=new AbortController,n=window.setTimeout(()=>{i(!0),(0,e5.apiFetch)(`/v1/runs/${encodeURIComponent(e)}/prompt`,{signal:t.signal}).then(e=>{t.signal.aborted||(a(e),l(null))}).catch(e=>{t.signal.aborted||(a(null),l(e instanceof Error?e.message:"Failed to load the run prompt"))}).finally(()=>{t.signal.aborted||i(!1)})},0);return()=>{window.clearTimeout(n),t.abort()}},[e]),{composition:t,loading:s,error:r}}(a),d=function(e){let[t,a]=(0,n.useState)(null),[s,i]=(0,n.useState)(!1),[r,l]=(0,n.useState)(null);return(0,n.useEffect)(()=>{if(!e){let e=window.setTimeout(()=>{a(null),l(null),i(!1)},0);return()=>window.clearTimeout(e)}let t=new AbortController,n=window.setTimeout(()=>{i(!0),(0,e5.apiFetch)(`/v1/runs/${encodeURIComponent(e)}/mcp`,{signal:t.signal}).then(e=>{t.signal.aborted||(a(e),l(null))}).catch(e=>{t.signal.aborted||(a(null),l(e instanceof Error?e.message:"Failed to load the run MCP surface"))}).finally(()=>{t.signal.aborted||i(!1)})},0);return()=>{window.clearTimeout(n),t.abort()}},[e]),{frozen:t,loading:s,error:r}}(a),u=function(e){let[t,a]=(0,n.useState)([]),[s,i]=(0,n.useState)(null),[r,l]=(0,n.useState)(!1),[o,c]=(0,n.useState)(!1),[d,u]=(0,n.useState)(null);(0,n.useEffect)(()=>{if(!e){let e=window.setTimeout(()=>{a([]),i(null),u(null),l(!1)},0);return()=>window.clearTimeout(e)}let t=new AbortController,n=window.setTimeout(()=>{l(!0),(0,e5.apiFetch)(`/v1/runs/${encodeURIComponent(e)}/messages?limit=200`,{signal:t.signal}).then(e=>{t.signal.aborted||(a(e.messages??[]),i(e.hasMore?e.nextBeforeOrdinal??null:null),u(null))}).catch(e=>{t.signal.aborted||(a([]),i(null),u(e instanceof Error?e.message:"Failed to load the run transcript"))}).finally(()=>{t.signal.aborted||l(!1)})},0);return()=>{window.clearTimeout(n),t.abort()}},[e]);let p=(0,n.useCallback)(()=>{e&&null!==s&&(c(!0),(0,e5.apiFetch)(`/v1/runs/${encodeURIComponent(e)}/messages?limit=200&beforeOrdinal=${s}`).then(e=>{a(t=>{let n=new Set(t.map(e=>e.ordinal));return[...(e.messages??[]).filter(e=>!n.has(e.ordinal)),...t]}),i(e.hasMore?e.nextBeforeOrdinal??null:null),u(null)}).catch(e=>{u(e instanceof Error?e.message:"Failed to load older transcript messages")}).finally(()=>c(!1)))},[e,s]);return{messages:t,hasMore:null!==s,loading:r,loadingOlder:o,error:d,loadOlder:p}}(a);return(0,t.jsxs)("div",{className:"right-panel-tools",children:[(0,t.jsx)(l2,{runId:a,composition:c.composition,mcp:d.frozen,transcript:u,loading:c.loading,error:c.error}),(0,t.jsx)(l5,{selectedSession:s,sessionTitle:i,activeRun:r,status:l,permissionMode:o})]})}function l5({selectedSession:e,sessionTitle:n,activeRun:a,status:s,permissionMode:i}){let r=(0,f.useT)();return(0,t.jsx)("div",{className:"right-panel-summary",children:e?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{children:["Session: ",n]}),(0,t.jsxs)("div",{children:["Active run: ",a||"none"]}),(0,t.jsxs)("div",{children:["Status: ",s?iS(s,r):"idle"]}),(0,t.jsxs)("div",{children:["Permission: ",i]})]}):(0,t.jsx)("div",{children:"No session selected"})})}let l3=["files","graph","tools"];function l6(e){return"string"==typeof e&&l3.includes(e)}function l8(e){return`ennote:right-panel:v1:${e}`}function l9(e){return{version:1,projectId:e,pinnedChannels:[],primaryWidth:280,open:!1,inspectorTabs:[],activeInspectorId:null,navigatorHidden:!1}}function l7(e){return l3.filter(t=>e.includes(t))}function oe(e){if(!Array.isArray(e))return[];let t=[],n=new Set;for(let a of e){if("object"==typeof a&&null!==a)"string"==typeof a.path&&0!==a.path.length&&(n.has(a.path)||(n.add(a.path),t.push({path:a.path,name:"string"==typeof a.name&&a.name.length>0?a.name:function(e){let t=e.split("/").filter(Boolean);return t[t.length-1]??e}(a.path)})))}return t.slice(-20)}function ot(e){let t=l7(e.pinnedChannels),n=t.length>0?l7(t):[...l3];return{projectId:e.projectId,openChannels:n,pinnedChannels:t,activeChannelId:n[0]??null,open:e.open,primaryWidth:e.primaryWidth,navigatorHidden:!0===e.navigatorHidden,activeInspectorId:e.activeInspectorId??null,activeLane:e.activeInspectorId?"inspector":"channel",inspectorTabs:oe(e.inspectorTabs)}}function on(e){let t=e.split(":");return t.length<3?e:t.slice(2).join(":")}function oa(e,t){return`file:${e}:${t}`}function os(e,t){let n=e.openChannels.includes(t)?e.openChannels:[...e.openChannels,t];return{...e,openChannels:n,activeChannelId:t,activeLane:"channel",open:!0}}function oi(e,t,n){let a=oe([...e.inspectorTabs.filter(e=>e.path!==n.path),n]);return{...e,inspectorTabs:a,activeInspectorId:t,activeLane:"inspector",open:!0}}function or(e){let{open:a,onClose:s,resize:i,panel:r,projectId:l,displayPath:o,onOpenFile:c,onPreviewFile:d,selectedSession:u,sessionTitle:p,activeRun:h,inspectorRunId:m,status:g,permissionMode:x}=e,v=(0,f.useT)(),{state:y,fileTabs:b}=r,k=l_("(max-width: 960px)"),j="medium"===lS(i.width,k),[w,_]=(0,n.useState)(!1),N=j?w:!y.navigatorHidden,C=y.openChannels,I=r.activeChannelId,P=e=>v("rightPanel.close",{name:e.label}),T=e=>{l6(e)?r.closeChannelTab(e):r.closeTab(e)},M=e=>{r.setActiveTabId(e),j&&_(!1),y.navigatorHidden&&"files"!==e&&r.toggleNavigator()},R=(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("div",{className:"right-panel-channel-slot",hidden:"files"!==I,children:(0,t.jsx)(lL,{projectId:l,displayPath:o,onOpenFile:(e,t)=>{c(e,t),j&&_(!1)},onPreviewFile:d})}),"graph"===I&&(0,t.jsx)(lU,{sessionId:u}),"tools"===I&&(0,t.jsx)(l4,{runId:m,selectedSession:u,sessionTitle:p,activeRun:h,status:g,permissionMode:x}),null===I&&(0,t.jsx)(lA,{channels:l3,hint:v("rightPanel.launcherHint"),t:v,onOpen:r.openChannel})]}),E=b.find(e=>e.id===y.activeInspectorId),A=E?.projectId===l&&E.filePath?(0,t.jsx)(r9,{projectId:E.projectId,filePath:E.filePath,fileName:E.label}):null;return(0,t.jsxs)("div",{className:`right-panel-container${a?" right-panel-open":" right-panel-closed"}`,style:{width:i.width,minWidth:i.width,transition:i.isResizing?"none":void 0},children:[(0,t.jsxs)("button",{type:"button",className:"right-panel-back-button",onClick:()=>{_(!1),s()},children:[(0,t.jsx)(rZ,{size:15,"aria-hidden":"true"}),"Back to conversation"]}),(0,t.jsx)(lP,{width:i.width,channelStrip:(0,t.jsxs)("div",{className:"right-panel-strip",children:[(0,t.jsx)(lk,{tabs:lR(C,v),activeTabId:I??"",onSelectTab:M,onCloseTab:T,closeLabel:P}),null!==I&&(0,t.jsx)("button",{type:"button",className:"right-panel-strip-action","aria-pressed":y.pinnedChannels.includes(I),"aria-label":y.pinnedChannels.includes(I)?v("rightPanel.unpin"):v("rightPanel.pin"),title:y.pinnedChannels.includes(I)?v("rightPanel.unpin"):v("rightPanel.pin"),onClick:()=>r.togglePin(I),children:y.pinnedChannels.includes(I)?(0,t.jsx)(rX,{size:13,"aria-hidden":"true"}):(0,t.jsx)(r0,{size:13,"aria-hidden":"true"})}),C.length<l3.length&&(0,t.jsx)("button",{type:"button",className:"right-panel-strip-action","aria-label":v("rightPanel.add"),title:v("rightPanel.add"),onClick:()=>{let e=l3.find(e=>!C.includes(e));e&&r.openChannel(e)},children:(0,t.jsx)(S,{size:13,"aria-hidden":"true"})})]}),channelBody:R,inspectorStrip:b.length>0?(0,t.jsx)(lk,{tabs:b,activeTabId:y.activeInspectorId??"",onSelectTab:M,onCloseTab:r.closeTab,onReorder:r.reorderTabs,closeLabel:P}):null,inspectorBody:A,narrowStrip:(0,t.jsx)("div",{className:"right-panel-strip",children:(0,t.jsx)(lk,{tabs:[...lR(C,v),...b],activeTabId:r.activeTabId,onSelectTab:M,onCloseTab:T,onReorder:r.reorderTabs,closeLabel:P})}),narrowBody:(0,t.jsx)("div",{className:"right-panel-body",children:r.activeTabId===y.activeInspectorId&&A?A:R}),primaryWidth:y.primaryWidth,onResizePrimary:e=>r.resizePrimaryBy(e,i.width),onResizePrimaryStart:r.beginPrimaryResize,onResizePrimaryEnd:r.endPrimaryResize,navigatorOpen:N&&a,primaryHidden:!N&&"files"===I,onToggleNavigator:()=>j?_(e=>!e):r.toggleNavigator()})]})}function ol({resize:e}){return(0,t.jsx)(lw,{side:"left",ariaLabel:"Resize right panel",value:e.width,min:280,max:e.maxWidth,onResizeStart:e.beginResize,onResize:e.resizeBy,onResizeEnd:e.endResize})}function oo({projectId:e,filePath:a,fileName:s,onClose:i}){let[r,l]=(0,n.useState)(()=>oc()),o=(0,n.useRef)(null),c=(0,n.useRef)(null);M(!0,i);let d=(0,n.useCallback)((e,t)=>{0!==t.button||r.maximized||(t.preventDefault(),c.current={kind:e,x:t.clientX,y:t.clientY,bounds:r},t.currentTarget.setPointerCapture(t.pointerId))},[r]),u=(0,n.useCallback)(e=>{let t=c.current;if(!t)return;e.preventDefault();let n=e.clientX-t.x,a=e.clientY-t.y,s=window.innerWidth,i=window.innerHeight;"move"===t.kind?l({...t.bounds,x:od(t.bounds.x+n,0,Math.max(0,s-160)),y:od(t.bounds.y+a,0,Math.max(0,i-44))}):l({...t.bounds,width:od(t.bounds.width+n,360,Math.max(360,s-t.bounds.x)),height:od(t.bounds.height+a,260,Math.max(260,i-t.bounds.y))})},[]),p=(0,n.useCallback)(e=>{c.current=null,e.currentTarget.hasPointerCapture(e.pointerId)&&e.currentTarget.releasePointerCapture(e.pointerId)},[]),h=(0,n.useCallback)(()=>{l(e=>e.maximized?o.current??oc():(o.current=e,{x:12,y:12,width:window.innerWidth-24,height:window.innerHeight-24,maximized:!0}))},[]);return(0,t.jsxs)("section",{className:`file-preview-window${r.maximized?" is-maximized":""}`,role:"dialog","aria-label":`Preview ${s}`,style:{left:r.x,top:r.y,width:r.width,height:r.height},children:[(0,t.jsxs)("header",{className:"file-preview-titlebar",onDoubleClick:h,onPointerDown:e=>d("move",e),onPointerMove:u,onPointerUp:p,onPointerCancel:p,children:[(0,t.jsx)("span",{title:a,children:s}),(0,t.jsxs)("div",{className:"file-preview-window-actions",onPointerDown:e=>e.stopPropagation(),children:[(0,t.jsx)("button",{type:"button",onClick:h,"aria-label":r.maximized?"Restore preview":"Maximize preview",title:r.maximized?"Restore preview":"Maximize preview",children:r.maximized?(0,t.jsx)(eD,{size:14}):(0,t.jsx)(l$,{size:14})}),(0,t.jsx)("button",{type:"button",onClick:i,"aria-label":"Close preview",title:"Close preview",children:(0,t.jsx)(m,{size:15})})]})]}),(0,t.jsx)("div",{className:"file-preview-content",children:(0,t.jsx)(r9,{projectId:e,filePath:a,fileName:s})}),!r.maximized&&(0,t.jsx)("div",{className:"file-preview-resize",role:"separator","aria-label":"Resize preview",onPointerDown:e=>d("resize",e),onPointerMove:u,onPointerUp:p,onPointerCancel:p})]})}function oc(){let e=window.innerWidth,t=window.innerHeight,n=Math.min(760,Math.max(360,e-48)),a=Math.min(600,Math.max(260,t-72));return{x:Math.max(12,Math.round((e-n)/2)),y:Math.max(12,Math.round((t-a)/2)),width:n,height:a,maximized:!1}}function od(e,t,n){return Math.min(n,Math.max(t,e))}function ou(e){return e.replace(/[\\/]+$/,"").split(/[\\/]/).at(-1)||e}function op({listing:e,selectedPath:n,showHidden:a,disabled:s,onSelect:i}){let r=a?e.entries:e.entries.filter(e=>!e.hidden||e.path===n);return(0,t.jsx)("div",{className:"project-picker-column",role:"list",children:r.map(e=>{let a=e.path===n;return(0,t.jsx)("span",{role:"listitem",className:"project-picker-row-seat",children:(0,t.jsxs)("button",{type:"button",className:`project-picker-row${a?" selected":""}`,"aria-current":a||void 0,disabled:s,onClick:()=>i(e),children:[a?(0,t.jsx)(_,{size:16,className:"project-picker-folder selected","aria-hidden":"true"}):(0,t.jsx)(w,{size:16,className:"project-picker-folder","aria-hidden":"true"}),(0,t.jsx)("span",{children:e.name}),(0,t.jsx)(j,{size:12,className:"project-picker-row-chevron","aria-hidden":"true"})]})},e.path)})})}function oh({busy:e,onCreate:a,onClose:s}){let i=(0,f.useT)(),[r,l]=(0,n.useState)(null),[o,c]=(0,n.useState)(null),[d,u]=(0,n.useState)(null),[p,h]=(0,n.useState)(!0),[m,g]=(0,n.useState)(null),[x,v]=(0,n.useState)(null),[y,b]=(0,n.useState)(!1),[k,w]=(0,n.useState)(null),[_,N]=(0,n.useState)(!1),[C,I]=(0,n.useState)(null),P=(0,n.useRef)(0),T=(0,n.useRef)(null),R=(0,n.useCallback)(async e=>{let t=e?`?${new URLSearchParams({path:e})}`:"";return(0,e5.apiFetch)(`/v1/host/directories${t}`)},[]),E=(0,n.useCallback)(async e=>{let t=++P.current;h(!0),g(null);try{let n=await R(e);if(t!==P.current)return;l(n),c(null),u(null),v(null)}catch(e){t===P.current&&g(e.message)}finally{t===P.current&&h(!1)}},[R]);(0,n.useEffect)(()=>{let e=++P.current;return R().then(t=>{e===P.current&&(l(t),h(!1))},t=>{e===P.current&&(g(t.message),h(!1))}),()=>{P.current+=1}},[R]),(0,n.useEffect)(()=>{null!==x&&T.current?.focus()},[x]);let A=(0,n.useCallback)(async e=>{let t=++P.current;c(e),u(null),h(!0),g(null);try{let n=await R(e.path);t===P.current&&u(n)}catch(e){t===P.current&&(c(null),g(e.message))}finally{t===P.current&&h(!1)}},[R]),$=(0,n.useCallback)(e=>{d&&(l(d),A(e))},[d,A]),z=o?.path??r?.path??null,F=z?ou(z):"",L=(0,n.useMemo)(()=>{var e;let t;return r?(e=i("directory.home"),(t=r.crumbs.findIndex(e=>e.path===r.home))<0?r.crumbs:[{name:e,path:r.home,hidden:!1},...r.crumbs.slice(t+1)]):[]},[r,i]),D=r?.roots??[],O=r&&r.home.includes("\\")?"\\":"/",q=e||_;M(!0,()=>{if(!q){if(null!==k)return void w(null);if(null!==x)return void v(null);s()}});let B=async()=>{if(z&&null!==k&&k.trim()&&!_){N(!0),I(null);try{let e=await (0,e5.apiFetch)("/v1/host/directories",{method:"POST",body:JSON.stringify({path:z,name:k})});if(w(null),o&&d){let t=await R(o.path);l(t);let n=t.entries.find(t=>t.path===e.path);n&&await A(n)}else{let t=await R(r?.path);l(t);let n=t.entries.find(t=>t.path===e.path);n&&A(n)}}catch(e){I(e.message)}finally{N(!1)}}},U=async()=>{if(z&&!e&&!p&&null===x){g(null);try{await a(F,z)}catch(e){g(e.message)}}};return(0,t.jsxs)("div",{className:"project-picker-overlay",onPointerDown:e=>{e.target!==e.currentTarget||q||null!==k||s()},children:[(0,t.jsxs)("div",{className:"project-picker-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"project-picker-title",children:[(0,t.jsxs)("header",{className:"project-picker-header",children:[(0,t.jsx)("h2",{id:"project-picker-title",children:i("directory.title")}),(0,t.jsx)("div",{className:`project-picker-crumb-bar${null!==x?" editing":""}`,children:null===x?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("nav",{className:"project-picker-crumbs","aria-label":i("directory.path"),children:L.map((e,n)=>(0,t.jsxs)("span",{children:[n>0&&(0,t.jsx)(j,{size:12,"aria-hidden":"true"}),(0,t.jsx)("button",{type:"button",disabled:q,onClick:()=>void E(e.path),children:e.name})]},e.path))}),(0,t.jsx)("button",{type:"button",className:"project-picker-edit-path","aria-label":i("directory.editPath"),title:i("directory.editPath"),disabled:q,onClick:()=>{if(!r||q)return;let e=o?.path??r.path;v(e.endsWith(O)?e:`${e}${O}`)},children:(0,t.jsx)(iP,{size:14,"aria-hidden":"true"})})]}):(0,t.jsx)("input",{ref:T,value:x,"aria-label":i("directory.editPath"),disabled:q,onChange:e=>v(e.target.value),onKeyDown:e=>{"Enter"===e.key&&x.trim()&&E(x),"Escape"!==e.key||e.nativeEvent.isComposing||(e.stopPropagation(),v(null))}})}),D.length>1&&(0,t.jsx)("nav",{className:"project-picker-roots","aria-label":i("directory.roots"),children:D.map(e=>{var n,a;return(0,t.jsx)("button",{type:"button",className:`project-picker-root${(n=r?.path??null,n&&(n===e||n.startsWith(e.endsWith(O)?e:`${e}${O}`)))?" active":""}`,title:e,disabled:q,onClick:()=>void E(e),children:(a=i("directory.home"),e===(r?.home??"")?a:ou(e))},e)})})]}),(0,t.jsxs)("main",{className:"project-picker-content",children:[(0,t.jsxs)("div",{className:"project-picker-miller-row",children:[r&&(0,t.jsx)(op,{listing:r,selectedPath:o?.path??null,showHidden:y,disabled:q,onSelect:e=>void A(e)}),o&&(0,t.jsx)("span",{className:"project-picker-divider"}),o&&d&&(0,t.jsx)(op,{listing:d,selectedPath:null,showHidden:y,disabled:q,onSelect:$})]}),p&&(0,t.jsx)("div",{className:"project-picker-loading",role:"status",children:i("directory.loading")}),(r?.truncated||d?.truncated)&&(0,t.jsx)("div",{className:"project-picker-status",children:i("directory.truncated")}),m&&(0,t.jsx)("div",{className:"project-picker-error",role:"alert",children:m})]}),(0,t.jsxs)("footer",{className:"project-picker-footer",children:[(0,t.jsxs)("button",{type:"button",className:"project-picker-button outline new-folder",disabled:!r||p||q||null!==x,onClick:()=>{w(""),I(null)},children:[(0,t.jsx)(S,{size:14,"aria-hidden":"true"})," ",i("directory.newFolder")]}),(0,t.jsxs)("button",{type:"button",className:`project-picker-show-hidden${y?" active":""}`,"aria-pressed":y,disabled:q,onClick:()=>b(e=>!e),children:[i("directory.showHidden"),y&&(0,t.jsx)(Y,{size:14,"aria-hidden":"true"})]}),(0,t.jsx)("span",{className:"project-picker-footer-gap"}),(0,t.jsx)("button",{type:"button",className:"project-picker-button outline",disabled:q,onClick:s,children:i("directory.cancel")}),(0,t.jsx)("button",{type:"button",className:"project-picker-button primary",disabled:!z||p||q||null!==x,onClick:()=>void U(),children:e?i("directory.opening"):i("directory.open")})]})]}),null!==k&&(0,t.jsx)("div",{className:"project-picker-nested-overlay",onPointerDown:e=>{e.target!==e.currentTarget||_||w(null)},children:(0,t.jsxs)("div",{className:"project-picker-create-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"project-folder-title",children:[(0,t.jsx)("h3",{id:"project-folder-title",children:i("directory.newFolder")}),(0,t.jsx)("p",{children:i("directory.createIn",{name:F})}),(0,t.jsx)("input",{value:k,"aria-label":i("directory.folderName"),placeholder:i("directory.untitledFolder"),autoFocus:!0,disabled:_,onChange:e=>w(e.target.value),onKeyDown:e=>{"Enter"===e.key&&B(),"Escape"!==e.key||_||e.nativeEvent.isComposing||(e.stopPropagation(),w(null))}}),C&&(0,t.jsx)("div",{className:"project-picker-error",role:"alert",children:C}),(0,t.jsxs)("div",{className:"project-picker-create-actions",children:[(0,t.jsx)("button",{type:"button",className:"project-picker-button outline",disabled:_,onClick:()=>w(null),children:i("directory.cancel")}),(0,t.jsx)("button",{type:"button",className:"project-picker-button primary",disabled:_||!k.trim(),onClick:()=>void B(),children:i("directory.create")})]})]})})]})}let om=o("database",[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]]),of=o("layers",[["path",{d:"M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z",key:"zw3jo"}],["path",{d:"M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12",key:"1wduqc"}],["path",{d:"M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17",key:"kqbvx6"}]]),og=o("package",[["path",{d:"M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z",key:"1a0edw"}],["path",{d:"M12 22V12",key:"d0xqtd"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}]]),ox=o("plug",[["path",{d:"M12 22v-5",key:"1ega77"}],["path",{d:"M15 8V2",key:"18g5xt"}],["path",{d:"M17 8a1 1 0 0 1 1 1v4a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1z",key:"1xoxul"}],["path",{d:"M9 8V2",key:"14iosj"}]]),ov=o("shield",[["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"}]]),oy={state:"idle"},ob=(0,n.createContext)({status:oy,markSaving:()=>{},markSaved:()=>{},markError:()=>{}});function ok({children:e}){let[a,s]=(0,n.useState)(oy),i=(0,n.useRef)(void 0),r=(0,n.useCallback)(()=>{void 0!==i.current&&(window.clearTimeout(i.current),i.current=void 0)},[]),l=(0,n.useCallback)(()=>{r(),s({state:"saving"})},[r]),o=(0,n.useCallback)(()=>{r(),s({state:"saved"}),i.current=window.setTimeout(()=>{i.current=void 0,s(oy)},2400)},[r]),c=(0,n.useCallback)(e=>{r(),s({state:"error",message:e})},[r]);(0,n.useEffect)(()=>r,[r]);let d=(0,n.useMemo)(()=>({status:a,markSaving:l,markSaved:o,markError:c}),[a,l,o,c]);return(0,t.jsx)(ob.Provider,{value:d,children:e})}function oj(){return(0,n.useContext)(ob)}function ow(){let{status:e}=oj(),n=(0,f.useT)();if("idle"===e.state)return null;let a=n("saving"===e.state?"settings.status.saving":"saved"===e.state?"settings.status.saved":"settings.status.failed"),s="saving"===e.state?(0,t.jsx)(eQ,{size:13,className:"spin","aria-hidden":"true"}):"saved"===e.state?(0,t.jsx)(Y,{size:13,"aria-hidden":"true"}):(0,t.jsx)(eX,{size:13,"aria-hidden":"true"});return(0,t.jsxs)("span",{className:"settings-save-status","data-state":e.state,role:"status","aria-live":"polite",title:e.message,children:[s,(0,t.jsx)("span",{children:a})]})}function o_(...e){return e.filter(Boolean).join(" ")}function oN({title:e,description:a,actions:s,className:i,children:r}){let l=(0,n.useId)();return(0,t.jsxs)("section",{className:o_("settings-section",i),"aria-labelledby":e?l:void 0,children:[(e||a||s)&&(0,t.jsxs)("div",{className:"settings-section-header",children:[(0,t.jsxs)("div",{children:[e&&(0,t.jsx)("h3",{id:l,children:e}),a&&(0,t.jsx)("p",{children:a})]}),s&&(0,t.jsx)("div",{className:"settings-section-actions",children:s})]}),r]})}function oC({title:e,meta:n,actions:a,children:s,className:i}){return(0,t.jsxs)("div",{className:o_("settings-row",i),children:[(0,t.jsxs)("div",{className:"settings-row-copy",children:[(0,t.jsx)("strong",{children:e}),n&&(0,t.jsx)("span",{children:n})]}),s,a&&(0,t.jsx)("div",{className:"settings-row-actions",children:a})]})}function oS({children:e,className:n}){return(0,t.jsx)("div",{className:o_("settings-list",n),children:e})}function oI({policies:e,models:n,session:a,refresh:s,setError:i,onSessionUpdated:r}){let{markSaving:l,markSaved:o}=oj();async function c(e,t){l();try{await (0,e5.apiFetch)("/v1/policy-profiles",{method:"POST",body:JSON.stringify({name:e,kind:"compaction",config:t})}),i(null),await s(),o()}catch(e){i(e.message)}}async function d(e){l();try{await (0,e5.apiFetch)(`/v1/policy-profiles/${encodeURIComponent(e)}/default`,{method:"PUT"}),i(null),await s(),o()}catch(e){i(e.message)}}async function u(e){if(a){l();try{let t=await (0,e5.apiFetch)(`/v1/sessions/${encodeURIComponent(a.id)}`,{method:"PATCH",body:JSON.stringify(e)});r(t),i(null),o()}catch(e){i(e.message)}}}return(0,t.jsxs)("section",{className:"settings-tab-section","aria-labelledby":"settings-context-heading",children:[(0,t.jsxs)("header",{children:[(0,t.jsx)("h2",{id:"settings-context-heading",children:"Context & session"}),(0,t.jsx)("p",{children:"Compaction policy versions and defaults frozen into the next Session Run."})]}),(0,t.jsx)(oP,{policies:e,models:n,onCreate:c,onDefault:d}),(0,t.jsx)(oN,{title:"Current session",description:a?a.title:"Select a Session to configure its defaults.",className:"current-session-settings",children:(0,t.jsxs)("div",{className:"session-default-grid",children:[(0,t.jsxs)("label",{className:"session-model-select",children:["Default model",(0,t.jsxs)("select",{disabled:!a,value:a?.defaultModelProfileId??"",onChange:e=>void u({defaultModelProfileId:e.target.value||null}),children:[(0,t.jsx)("option",{value:"",children:"Use global default"}),n.map(e=>(0,t.jsx)("option",{value:e.id,children:e.displayName||e.modelName},e.id))]})]}),(0,t.jsxs)("label",{className:"session-model-select",children:["Context compaction",(0,t.jsxs)("select",{disabled:!a,value:a?.compactionPolicyProfileId??"",onChange:e=>void u({compactionPolicyProfileId:e.target.value||null}),children:[(0,t.jsx)("option",{value:"",children:"Use global default"}),e.filter(e=>"compaction"===e.kind&&"active"===e.status).map(e=>(0,t.jsxs)("option",{value:e.id,children:[e.name," v",e.version]},e.id))]})]})]})}),(0,t.jsx)(oT,{sessionId:a?.id??null})]})}function oP({policies:e,models:a,onCreate:s,onDefault:i}){let r=(0,f.useT)(),[l,o]=(0,n.useState)([]),c=(e,t)=>o(n=>n.map((n,a)=>a===e?{...n,...t}:n));async function d(e){e.preventDefault();let t=e.currentTarget,n=new FormData(t),a=String(n.get("mode")),i="manual_and_auto"===a&&"on"===n.get("allowOverflowRecovery"),r=l.filter(e=>e.modelProfileId).map(e=>({modelProfileId:e.modelProfileId,...void 0!==e.triggerRatio?{triggerRatio:e.triggerRatio}:{},...void 0!==e.tailMaxTokens?{tailMaxTokens:e.tailMaxTokens}:{},...void 0!==e.summaryMaxOutputTokens?{summaryMaxOutputTokens:e.summaryMaxOutputTokens}:{}}));await s(String(n.get("name")),{mode:a,triggerRatio:Number(n.get("triggerRatio")),keepRecentTurns:Number(n.get("keepRecentTurns")),tailTokenRatio:Number(n.get("tailTokenRatio")),tailMinTokens:Number(n.get("tailMinTokens")),tailMaxTokens:Number(n.get("tailMaxTokens")),summaryInputRatio:Number(n.get("summaryInputRatio")),compactionModelProfileId:n.get("compactionModelProfileId")||null,summaryMaxOutputTokens:Number(n.get("summaryMaxOutputTokens")),...r.length>0?{modelPolicies:r}:{},includeReasoning:"on"===n.get("includeReasoning"),allowHistoryLookup:"on"===n.get("allowHistoryLookup"),allowOverflowRecovery:i,maxOverflowRecoveries:+!!i,ineffectiveReclaimRatio:Number(n.get("ineffectiveReclaimRatio")),ineffectiveLimit:Number(n.get("ineffectiveLimit")),failureCooldownSeconds:Number(n.get("failureCooldownSeconds")),promptVersion:"v1"}),t.reset(),o([])}return(0,t.jsxs)(oN,{title:"Context compaction",description:"Manual and bounded automatic context checkpoint behavior.",children:[(0,t.jsxs)("form",{className:"settings-form compaction-form",onSubmit:d,children:[(0,t.jsxs)("label",{children:["Name",(0,t.jsx)("input",{name:"name",required:!0})]}),(0,t.jsxs)("label",{children:["Mode",(0,t.jsxs)("select",{name:"mode",defaultValue:"manual_only",children:[(0,t.jsx)("option",{value:"disabled",children:"Disabled"}),(0,t.jsx)("option",{value:"manual_only",children:"Manual only"}),(0,t.jsx)("option",{value:"manual_and_auto",children:"Manual and automatic"})]})]}),(0,t.jsxs)("label",{children:["Summary model",(0,t.jsxs)("select",{name:"compactionModelProfileId",defaultValue:"",children:[(0,t.jsx)("option",{value:"",children:"Use run model"}),a.map(e=>(0,t.jsx)("option",{value:e.id,children:e.displayName||e.modelName},e.id))]})]}),(0,t.jsxs)("label",{children:["Trigger ratio",(0,t.jsx)("input",{name:"triggerRatio",type:"number",min:"0.01",max:"0.99",step:"0.01",defaultValue:"0.75",required:!0})]}),(0,t.jsxs)("label",{children:["Recent turns",(0,t.jsx)("input",{name:"keepRecentTurns",type:"number",min:"1",step:"1",defaultValue:"2",required:!0})]}),(0,t.jsxs)("label",{children:["Tail ratio",(0,t.jsx)("input",{name:"tailTokenRatio",type:"number",min:"0.01",max:"0.99",step:"0.01",defaultValue:"0.2",required:!0})]}),(0,t.jsxs)("label",{children:["Tail minimum",(0,t.jsx)("input",{name:"tailMinTokens",type:"number",min:"1",step:"1",defaultValue:"8000",required:!0})]}),(0,t.jsxs)("label",{children:["Tail maximum",(0,t.jsx)("input",{name:"tailMaxTokens",type:"number",min:"1",step:"1",defaultValue:"32000",required:!0})]}),(0,t.jsxs)("label",{children:["Summary input ratio",(0,t.jsx)("input",{name:"summaryInputRatio",type:"number",min:"0.01",max:"0.99",step:"0.01",defaultValue:"0.7",required:!0})]}),(0,t.jsxs)("label",{children:["Summary output",(0,t.jsx)("input",{name:"summaryMaxOutputTokens",type:"number",min:"1",step:"1",defaultValue:"4096",required:!0})]}),(0,t.jsxs)("label",{children:["Cooldown seconds",(0,t.jsx)("input",{name:"failureCooldownSeconds",type:"number",min:"0",step:"1",defaultValue:"600",required:!0})]}),(0,t.jsxs)("label",{children:["Ineffective ratio",(0,t.jsx)("input",{name:"ineffectiveReclaimRatio",type:"number",min:"0",max:"0.99",step:"0.01",defaultValue:"0.1",required:!0})]}),(0,t.jsxs)("label",{children:["Ineffective limit",(0,t.jsx)("input",{name:"ineffectiveLimit",type:"number",min:"1",step:"1",defaultValue:"3",required:!0})]}),(0,t.jsxs)("div",{className:"settings-toggles compaction-toggles",children:[(0,t.jsxs)("label",{children:[(0,t.jsx)("input",{name:"allowHistoryLookup",type:"checkbox",defaultChecked:!0})," History lookup"]}),(0,t.jsxs)("label",{children:[(0,t.jsx)("input",{name:"allowOverflowRecovery",type:"checkbox",defaultChecked:!0})," Overflow recovery"]}),(0,t.jsxs)("label",{children:[(0,t.jsx)("input",{name:"includeReasoning",type:"checkbox"})," Include reasoning"]})]}),(0,t.jsxs)("div",{className:"settings-subsection compaction-model-policies",children:[(0,t.jsxs)("header",{children:[(0,t.jsx)("h4",{children:"Per-model overrides"}),(0,t.jsx)("p",{children:"Optional budget overrides for a specific model."})]}),l.map((e,n)=>(0,t.jsxs)("div",{className:"model-policy-row",children:[(0,t.jsxs)("select",{value:e.modelProfileId,onChange:e=>c(n,{modelProfileId:e.target.value}),"aria-label":`Override model ${n+1}`,children:[(0,t.jsx)("option",{value:"",children:"Select model…"}),a.map(e=>(0,t.jsx)("option",{value:e.id,children:e.displayName||e.modelName},e.id))]}),(0,t.jsx)("input",{type:"number",step:"0.01",min:"0.01",max:"0.99",placeholder:"Trigger ratio",value:e.triggerRatio??"",onChange:e=>c(n,{triggerRatio:""===e.target.value?void 0:Number(e.target.value)})}),(0,t.jsx)("input",{type:"number",step:"1",min:"1",placeholder:"Tail max tokens",value:e.tailMaxTokens??"",onChange:e=>c(n,{tailMaxTokens:""===e.target.value?void 0:Number(e.target.value)})}),(0,t.jsx)("input",{type:"number",step:"1",min:"1",placeholder:"Summary output",value:e.summaryMaxOutputTokens??"",onChange:e=>c(n,{summaryMaxOutputTokens:""===e.target.value?void 0:Number(e.target.value)})}),(0,t.jsx)("button",{type:"button",className:"secondary-btn",onClick:()=>o(e=>e.filter((e,t)=>t!==n)),"aria-label":r("settings.context.removeOverride",{index:String(n+1)}),children:(0,t.jsx)(m,{size:12,"aria-hidden":"true"})})]},n)),(0,t.jsx)("button",{type:"button",className:"secondary-btn",onClick:()=>o(e=>[...e,{modelProfileId:""}]),children:"+ Add override"})]}),(0,t.jsx)("button",{type:"submit",children:"Create version"})]}),(0,t.jsx)("div",{className:"settings-list",children:e.filter(e=>"compaction"===e.kind).map(e=>(0,t.jsxs)("div",{className:"settings-row",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("strong",{children:e.name}),(0,t.jsxs)("span",{children:["v",e.version," · ",String(e.config.mode??"configured")]})]}),(0,t.jsx)("button",{className:"secondary-btn",disabled:"active"!==e.status,onClick:()=>i(e.id),children:"Use as default"})]},e.id))})]})}function oT({sessionId:e}){let{markSaving:a,markSaved:s}=oj(),[i,r]=(0,n.useState)([]),[l,o]=(0,n.useState)(null),[c,d]=(0,n.useState)(null);(0,n.useEffect)(()=>{if(!e)return;let t=!1;return(0,e5.apiFetch)(`/v1/sessions/${encodeURIComponent(e)}/standing-approvals`).then(n=>{t||(r(n?.items??[]),d(null),o(e))}).catch(n=>{t||(r([]),d(n.message),o(e))}),()=>{t=!0}},[e]);let u=l===e,p=u?i:[],h=!u,m=u?c:null,f=(0,n.useCallback)(async t=>{if(e){a();try{await (0,e5.apiFetch)(`/v1/sessions/${encodeURIComponent(e)}/standing-approvals/${encodeURIComponent(t)}/revoke`,{method:"POST"}),r(e=>e.filter(e=>e.id!==t)),d(null),s()}catch(e){d(e.message)}}},[e,a,s]);return e?(0,t.jsxs)(oN,{title:"Standing approvals",description:"Tools automatically authorised for this session. Revoke to require approval again.",className:"standing-approvals-section",children:[h&&(0,t.jsx)("div",{className:"settings-empty",children:"Loading…"}),!h&&m&&(0,t.jsx)("div",{className:"settings-error",children:m}),!h&&!m&&0===p.length&&(0,t.jsx)("div",{className:"settings-empty",children:"No standing approvals for this session."}),!h&&p.length>0&&(0,t.jsx)(oS,{children:p.map(e=>(0,t.jsx)(oC,{title:e.toolName,meta:e.scopeDisplay,actions:(0,t.jsx)("button",{className:"secondary-btn",onClick:()=>f(e.id),children:"Revoke"})},e.id))})]}):null}let oM=o("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"}]]),oR="ennote-default-permission",oE="ennote-default-permission-change",oA=["discuss","ask","auto"];function o$(){try{let e=window.localStorage.getItem(oR);if(null!==e&&oA.includes(e))return e}catch{}return"discuss"}var oz=e.i(18929),oF=e.i(426);let oL=["discuss","ask","auto"];function oD(){let{mode:e,setThemeMode:a}=rJ(),{locale:s,setLocale:i}=(0,f.useLocale)(),[r,l]=(0,n.useState)(()=>o$()),{markSaved:o}=oj(),c=e=>(0,oF.translate)(s,e),d=[{id:"light",label:"Light",icon:(0,t.jsx)(rq,{size:15,"aria-hidden":"true"})},{id:"dark",label:"Dark",icon:(0,t.jsx)(rO,{size:15,"aria-hidden":"true"})},{id:"system",label:"System",icon:(0,t.jsx)(oM,{size:15,"aria-hidden":"true"})}];return(0,t.jsxs)("section",{className:"settings-tab-section","aria-labelledby":"settings-general-heading",children:[(0,t.jsxs)("header",{children:[(0,t.jsx)("h2",{id:"settings-general-heading",children:c("general.title")}),(0,t.jsx)("p",{children:c("general.desc")})]}),(0,t.jsx)(oN,{title:c("general.appearance"),className:"appearance-group",children:(0,t.jsx)("div",{className:"appearance-cubes",role:"group","aria-label":c("general.appearance"),children:d.map(n=>(0,t.jsxs)("button",{type:"button",className:`appearance-cube ${e===n.id?"selected":""}`,"aria-pressed":e===n.id,onClick:()=>{a(n.id),o()},children:[n.icon,(0,t.jsx)("span",{children:n.label})]},n.id))})}),(0,t.jsx)(oN,{title:c("general.permission"),description:c("general.permission.desc"),className:"permission-group",children:(0,t.jsx)("div",{className:"appearance-cubes",role:"group","aria-label":c("general.permission"),children:oL.map(e=>(0,t.jsx)("button",{type:"button",className:`appearance-cube ${r===e?"selected":""}`,"aria-pressed":r===e,title:c(`permission.${e}.description`),onClick:()=>{l(e);try{window.localStorage.setItem(oR,e)}catch{}window.dispatchEvent(new CustomEvent(oE,{detail:e})),o()},children:(0,t.jsx)("span",{children:c(`permission.${e}`)})},e))})}),(0,t.jsx)(oN,{title:c("general.language"),className:"language-group",children:(0,t.jsx)("div",{className:"appearance-cubes",role:"group","aria-label":c("general.language"),children:oz.LOCALES.map(e=>(0,t.jsx)("button",{type:"button",className:`appearance-cube ${s===e?"selected":""}`,"aria-pressed":s===e,onClick:()=>{i(e),o()},children:(0,t.jsx)("span",{children:"en"===e?c("language.en"):c("language.zh")})},e))})})]})}function oO(e,t){return(0,e5.apiFetch)("/v1/packs/install",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({source:{kind:"path",path:e},dryRun:t.dryRun,...t.expectedDigest?{expectedDigest:t.expectedDigest}:{}})})}var oq=e.i(67203);function oB({setError:e}){let[a,s]=(0,n.useState)([]),[i,r]=(0,n.useState)(!0),[l,o]=(0,n.useState)(""),[c,d]=(0,n.useState)(!1),[u,p]=(0,n.useState)(null),[h,m]=(0,n.useState)(null),[f,g]=(0,n.useState)(null),[x,v]=(0,n.useState)(null),[y,b]=(0,n.useState)(null),k=async()=>{try{s(await (0,e5.apiFetch)("/v1/packs")),e(null)}catch(t){e(t.message)}finally{r(!1)}};(0,n.useEffect)(()=>{let e=window.setTimeout(()=>void k(),0);return()=>window.clearTimeout(e)},[]);let j=async t=>{if(!c){d(!0),e(null);try{await t()}catch(t){e(t.message)}finally{d(!1)}}},w=e=>{o(e),m(null),g(null),p(null),b(null)},_=async()=>{!h||f!==l.trim()||await rc({title:`Install ${h.pack.name} ${h.pack.version}?`,description:h.willPublishFlowRevision?"This creates disabled draft objects and publishes an Agent Flow revision.":"This creates disabled draft objects on this Worker. Nothing runs until a revision is published and bound.",confirmLabel:"Install"})&&await j(async()=>{await oO(l.trim(),{dryRun:!1,expectedDigest:h.packDigest}),m(null),g(null),p(null),w(""),await k()})},N=async(t,n)=>{let a,s=2!==(a=t.pack.id.split("/")).length||""===a[0]||""===a[1]?null:{publisher:a[0],name:a[1]};s?await rc({title:n?`Force-remove ${t.pack.name}?`:`Remove ${t.pack.name}?`,description:n?"This also deletes objects that were edited locally or still referenced by another Graph.":"Every object this pack installed is deleted. A locally edited Skill is kept, with a warning.",confirmLabel:n?"Force remove":"Remove",tone:"danger"})&&await j(async()=>{v(t.pack.id);try{await function(e,t,n=!1){return(0,e5.apiFetch)(`/v1/packs/${encodeURIComponent(e)}/${encodeURIComponent(t)}${n?"?force=true":""}`,{method:"DELETE"})}(s.publisher,s.name,n),b(null),await k()}catch(e){throw b(t.pack.id),e}finally{v(null)}}):e(`"${t.pack.id}" is not a publisher/name pack id.`)},C=null===h||f!==l.trim()||h.blockers.length>0;return(0,t.jsxs)("section",{className:"settings-tab-section","aria-labelledby":"settings-packs-heading",children:[(0,t.jsx)("h3",{id:"settings-packs-heading",className:oq.default.heading,children:"Agent Packs"}),(0,t.jsx)("p",{className:oq.default.note,children:"A pack ships Heroes, Skills, and optionally a Graph or Agent Flow. Installing one only creates disabled drafts on this Worker — nothing runs until a revision is published and bound."}),(0,t.jsxs)("div",{className:oq.default.installer,children:[(0,t.jsxs)("label",{className:oq.default.pathLabel,children:[(0,t.jsx)("span",{children:"Pack path on the Worker host"}),(0,t.jsx)("input",{className:oq.default.pathInput,value:l,placeholder:"/home/me/packs/example.enpack",onChange:e=>w(e.target.value)})]}),(0,t.jsxs)("div",{className:oq.default.actions,children:[(0,t.jsx)("button",{type:"button",className:oq.default.button,disabled:c||""===l.trim(),onClick:()=>j(async()=>{var e;m(null),g(null),p(await (e=l.trim(),(0,e5.apiFetch)("/v1/packs/inspect",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({source:{kind:"path",path:e}})})))}),children:"Inspect"}),(0,t.jsx)("button",{type:"button",className:oq.default.button,disabled:c||""===l.trim(),onClick:()=>j(async()=>{m(await oO(l.trim(),{dryRun:!0})),g(l.trim())}),children:"Check install"}),(0,t.jsx)("button",{type:"button",className:`${oq.default.button} ${oq.default.primary}`,disabled:c||""===l.trim()||C,onClick:_,children:"Install"})]})]}),u&&(0,t.jsxs)("div",{className:oq.default.card,"data-testid":"pack-inspect",children:[(0,t.jsxs)("div",{className:oq.default.cardHead,children:[(0,t.jsx)(og,{size:14,"aria-hidden":"true"}),(0,t.jsx)("span",{className:oq.default.cardName,children:u.pack.name}),(0,t.jsx)("span",{className:oq.default.badge,children:u.pack.version}),(0,t.jsx)("span",{className:oq.default.badge,children:u.pack.id}),!u.signed&&(0,t.jsx)("span",{className:oq.default.badge,children:"unsigned"})]}),(0,t.jsxs)("div",{className:oq.default.counts,children:[u.flows.length," flows · ",u.heroes.length," heroes · ",u.skills.length," skills · ",u.filesTotal," files"]}),(0,t.jsxs)("div",{className:oq.default.digest,children:["pack digest ",u.packDigest.slice(0,16),"…"]}),(0,t.jsx)(oU,{issues:u.warnings})]}),h&&(0,t.jsxs)("div",{className:oq.default.card,"data-testid":"pack-plan","data-blocked":C||void 0,children:[(0,t.jsxs)("div",{className:oq.default.cardHead,children:[(0,t.jsx)("span",{className:oq.default.cardName,children:"Install plan"}),(0,t.jsxs)("span",{className:oq.default.badge,children:[h.actions.length," actions"]}),h.willPublishFlowRevision&&(0,t.jsx)("span",{className:oq.default.badge,children:"publishes a revision"})]}),(0,t.jsx)("ul",{className:oq.default.actionList,children:h.actions.map(e=>(0,t.jsxs)("li",{className:oq.default.actionRow,children:[(0,t.jsx)("span",{className:oq.default.badge,children:e.kind}),(0,t.jsx)("span",{className:oq.default.actionId,children:e.storeId}),(0,t.jsx)("span",{className:oq.default.actionVerb,"data-action":e.action,children:e.action})]},`${e.kind}:${e.storeId}`))}),(0,t.jsx)(oU,{issues:[...h.blockers.map(e=>({...e,severity:e.severity??"error"})),...h.warnings.map(e=>({...e,severity:e.severity??"warning"}))]})]}),(0,t.jsxs)("div",{className:oq.default.sectionHeader,children:["Installed ",(0,t.jsx)("span",{className:oq.default.sectionCount,children:a.length}),(0,t.jsx)("button",{type:"button",className:oq.default.iconButton,"aria-label":"Refresh installed packs",onClick:()=>void k(),children:(0,t.jsx)(iB,{size:13,"aria-hidden":"true"})})]}),i?(0,t.jsx)("div",{className:oq.default.empty,children:"Loading…"}):0===a.length?(0,t.jsx)("div",{className:oq.default.empty,children:"No packs installed."}):(0,t.jsx)("div",{className:oq.default.stack,children:a.map(e=>(0,t.jsxs)("div",{className:oq.default.row,"data-testid":"pack-row",children:[(0,t.jsxs)("div",{className:oq.default.identity,children:[(0,t.jsxs)("div",{className:oq.default.titleRow,children:[(0,t.jsx)("span",{className:oq.default.name,children:e.pack.name}),(0,t.jsx)("span",{className:oq.default.badge,children:e.pack.version})]}),(0,t.jsxs)("div",{className:oq.default.meta,children:[e.flowCount," flows · ",e.heroCount," heroes · ",e.skillCount," skills"]})]}),y===e.pack.id&&(0,t.jsx)("button",{type:"button",className:oq.default.button,disabled:c||x===e.pack.id,onClick:()=>void N(e,!0),children:"Force remove"}),(0,t.jsx)("button",{type:"button",className:oq.default.iconButton,"aria-label":`Remove ${e.pack.name}`,disabled:c||x===e.pack.id,onClick:()=>void N(e,!1),children:(0,t.jsx)(P,{size:13,"aria-hidden":"true"})})]},e.pack.id))})]})}function oU({issues:e}){return 0===e.length?null:(0,t.jsx)("ul",{className:oq.default.issueList,children:e.map(e=>(0,t.jsxs)("li",{className:oq.default.issueRow,"data-severity":e.severity??"warning",children:[(0,t.jsx)("span",{className:oq.default.badge,children:e.code}),(0,t.jsx)("span",{children:e.message})]},`${e.code}:${e.message}`))})}var oH=e.i(82399);let oW={stdio:"stdio",streamable_http:"Streamable HTTP",legacy_sse:"HTTP + SSE"};function oV({mcp:e}){let{showCreate:n,transport:a,setTransport:s,displayName:i,setDisplayName:r,slug:l,setSlug:o,executable:c,setExecutable:d,argv:u,setArgv:p,endpoint:h,setEndpoint:m,createProfile:f}=e;return(0,t.jsx)(t.Fragment,{children:n&&(0,t.jsxs)("div",{className:oH.default.form,children:[(0,t.jsxs)("div",{className:oH.default.formGrid,children:[(0,t.jsxs)("label",{className:oH.default.field,children:["Display name",(0,t.jsx)("input",{value:i,onChange:e=>r(e.target.value),className:oH.default.input,placeholder:"PubMed"})]}),(0,t.jsxs)("label",{className:oH.default.field,children:["Slug (fixed once bound)",(0,t.jsx)("input",{value:l,onChange:e=>o(e.target.value),className:oH.default.input,placeholder:"pubmed"})]})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("div",{className:oH.default.transportRow,children:["stdio","streamable_http","legacy_sse"].map(e=>(0,t.jsx)("button",{type:"button",onClick:()=>s(e),className:oH.default.transportButton,"data-active":a===e||void 0,children:oW[e]},e))}),"stdio"===a?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("label",{className:oH.default.field,children:["Executable",(0,t.jsx)("input",{value:c,onChange:e=>d(e.target.value),className:oH.default.input,placeholder:"/usr/bin/python3"})]}),(0,t.jsxs)("label",{className:oH.default.field,children:["Arguments (space-separated)",(0,t.jsx)("input",{value:u,onChange:e=>p(e.target.value),className:oH.default.input,placeholder:"/path/to/server.py"})]})]}):(0,t.jsxs)("label",{className:oH.default.field,children:["Endpoint URL",(0,t.jsx)("input",{value:h,onChange:e=>m(e.target.value),className:oH.default.input,placeholder:"https://example.com/mcp"})]})]}),(0,t.jsx)("button",{type:"button",onClick:f,disabled:!i.trim()||!l.trim()||("stdio"===a?!c.trim():!h.trim()),className:oH.default.createButton,children:"Create profile"})]})})}function oK({mcp:e,binding:n}){let{catalogs:a,toolSearch:s,setToolSearch:i,showCreds:r,setShowCreds:l,credEnv:o,setCredEnv:c,credRef:d,setCredRef:u,versionFor:p,updateBinding:h,toggleTool:m,selectAllTools:f,addCredential:g,removeCredential:x,testBinding:v,refreshCatalog:y,removeBinding:b}=e,k=a[n.id]??[],j=n.selectedRemoteToolNames??[],w=p(n),_=w?"stdio"===w.transport?`${w.executable??""} ${(w.argv??[]).join(" ")}`.trim():w.endpoint??"":"";return(0,t.jsxs)("div",{className:oH.default.card,children:[(0,t.jsxs)("div",{className:oH.default.cardHead,children:[(0,t.jsxs)("div",{className:oH.default.cardIdentity,children:[(0,t.jsxs)("div",{className:oH.default.cardTitle,children:[w?oW[w.transport]??w.transport:"MCP server",(0,t.jsxs)("span",{className:oH.default.cardMeta,children:["rev ",n.revision??0," · ",j.length," tools selected"]})]}),_&&(0,t.jsx)("div",{className:oH.default.commandSummary,children:_})]}),(0,t.jsxs)("div",{className:oH.default.actions,children:[(0,t.jsx)("button",{type:"button",title:n.required?"Server is required: Run start fails when unreachable":"Server is optional: Run start continues when unreachable",onClick:()=>h(n,{required:!n.required}),className:oH.default.requiredButton,"data-required":n.required||void 0,children:n.required?"required":"optional"}),(0,t.jsx)("button",{type:"button",title:"Edit credential references for this binding",onClick:()=>l(e=>({...e,[n.id]:!e[n.id]})),className:oH.default.ghostButton,children:"Credentials"}),(0,t.jsx)("button",{type:"button",onClick:async()=>{let e=!n.desiredEnabled;if(e){let e=w?"stdio"===w.transport?`Command: ${_}`:`Endpoint: ${w.endpoint??""}`:"";if(!await rc({title:"Enable this MCP server?",description:`${e}
6
+ ${t}`)].filter(Boolean).join("\n\n")),O(),T(e=>e+1)}},[O,i,y]);(0,n.useEffect)(()=>{let e=b.current;if(!e)return;let t=()=>{let t=e.scrollHeight-e.scrollTop-e.clientHeight<80;C(t),t&&I(!1)};return e.addEventListener("scroll",t,{passive:!0}),t(),()=>e.removeEventListener("scroll",t)},[e.sessionId,L]),(0,n.useEffect)(()=>{let t=e.messages.length;t>N.current&&N.current>0&&!_&&I(!0),N.current=t},[e.messages.length,_]);let U=(0,n.useCallback)(()=>{let e=b.current;e&&(e.scrollTo({top:e.scrollHeight,behavior:"smooth"}),I(!1))},[]);return(0,t.jsxs)("main",{className:"chat-area","data-phase":L?"welcome":"active",children:[l&&(0,t.jsxs)("div",{className:"error-bar",role:"alert",children:[(0,t.jsx)("span",{children:l}),(0,t.jsx)("button",{onClick:o,"aria-label":y("conversation.chat.dismissError"),children:(0,t.jsx)(m,{size:15,"aria-hidden":"true"})})]}),a.recovery&&(0,t.jsxs)("div",{className:`recovery-bar ${a.recovery.retryable?"is-retryable":"is-blocked"}`,"data-testid":"run-recovery",children:[(0,t.jsxs)("span",{children:[(0,t.jsx)("strong",{children:"interrupted"===a.recovery.run.status?y("conversation.chat.runInterrupted"):y("conversation.chat.runFailed")}),a.recovery.retryable?y("conversation.chat.attemptRetryable",{attempt:String(a.recovery.run.attempt)}):function(e,t){switch(e){case"side_effect_boundary":return t("conversation.chat.recovery.sideEffect");case"projected_output":return t("conversation.chat.recovery.projectedOutput");case"active_run":return t("conversation.chat.recovery.activeRun");default:return t("conversation.chat.recovery.notActive")}}(a.recovery.blockedReason,y)]}),a.recovery.retryable&&(0,t.jsx)("button",{type:"button",onClick:a.retryRun,disabled:a.retrying||!!a.activeRun,children:a.retrying?y("conversation.chat.retrying"):y("conversation.chat.retry")})]}),!L&&(0,t.jsxs)("div",{className:"chat-scroll-region",children:[(0,t.jsx)("div",{className:"messages",ref:b,"data-testid":"chat-messages",children:(0,t.jsxs)("div",{className:"conversation-viewport",children:[e.hasMore&&(0,t.jsx)("div",{className:"history-control",children:(0,t.jsx)("button",{type:"button",onClick:z,disabled:e.loadingOlder,children:e.loadingOlder?y("conversation.chat.loadingEarlier"):y("conversation.chat.loadEarlier")})}),e.loading&&(0,t.jsx)("div",{className:"history-state",children:y("conversation.chat.loading")}),e.error&&(0,t.jsx)("div",{className:"history-state history-state-error",children:y("conversation.chat.historyUnavailable",{message:e.error})}),!e.loading&&0===e.messages.length&&!e.error&&!a.pendingApproval&&(0,t.jsxs)("div",{className:"history-empty",children:[(0,t.jsx)("strong",{children:y("conversation.chat.newConversation")}),(0,t.jsx)("span",{children:y("conversation.chat.startHint")})]}),(0,t.jsx)(rS,{sessionId:e.sessionId??"",nodes:e.messages,pendingApproval:a.pendingApproval,resolvingApproval:a.resolvingApproval,decideApproval:a.decideApproval,answeringQuestion:a.answeringQuestion,answerQuestion:a.answerQuestion,activeLeafMessageId:e.activeLeafMessageId,branchDisabled:!!a.activeRun||s.changing,createBranch:s.createBranch,runStatus:a.activeRun||a.status?{status:a.status,active:!!a.activeRun,waiting:R,waitingForQuestion:E,reconnecting:A,compacting:a.compacting,startedAt:a.startedAt,runId:a.activeRun,cacheReadTokens:a.usage?.cacheReadTokens??0,inputTokens:(a.usage?.uncachedInputTokens??0)+(a.usage?.cacheReadTokens??0)+(a.usage?.cacheWriteTokens??0),outputTokens:a.usage?.outputTokens??0}:void 0}),(0,t.jsx)("div",{ref:k})]})}),(0,t.jsx)(J,{nodes:e.messages,scrollContainer:b}),!_&&(0,t.jsxs)("button",{type:"button",className:"chat-jump-latest","data-new":S||void 0,onClick:U,"aria-label":y(S?"conversation.newMessages":"conversation.jumpLatest"),children:[(0,t.jsx)(K,{size:14,"aria-hidden":"true"}),y(S?"conversation.newMessages":"conversation.jumpLatest")]})]}),!L&&D.selection&&(0,t.jsx)(et,{selection:D.selection,onQuote:q,onExplain:B,onDismiss:O}),!L&&(0,t.jsx)(e6,{sessionId:e.sessionId??void 0}),!L&&i.compaction.open&&(0,t.jsx)(e7,{value:i.compaction.instructions,onChange:i.compaction.setInstructions,busy:i.compaction.busy,onConfirm:i.compaction.confirm,onCancel:i.compaction.cancel}),(0,t.jsx)("div",{className:"composer-seat",children:(0,t.jsxs)("div",{className:L?"composer-stack composer-welcome":"composer-stack",children:[L&&(0,t.jsx)(eG,{}),L&&(0,t.jsx)(eJ,{hasModel:u,onOpenSettings:v}),L&&(0,t.jsx)("div",{className:"welcome-workspace-row",children:(0,t.jsx)(eY,{projects:c,selectedProject:d,pinnedProjectIds:p,togglePinProject:h,onRequestProject:$,onSwitchProject:g,projectSelector:M})}),(0,t.jsx)(eK,{selectedSession:e.sessionId,activeLeafMessageId:e.activeLeafMessageId,input:i.input,setInput:i.setInput,focusNonce:P,activeRun:!!a.activeRun,questionPending:!!E,compacting:a.compacting,hasPendingImage:!!i.pendingImage,reconnecting:A,inert:!d,welcome:L,onRequestProject:$,permissionMode:i.displayedPermissionMode,permissionReady:i.permissionReady,setPermissionMode:i.setPermissionMode,models:i.models,providers:i.providers,selectedModelId:i.selectedModelId,setSelectedModelId:i.setSelectedModelId,thinkingEffort:i.thinkingEffort,setThinkingEffort:i.setThinkingEffort,textAttachments:i.textAttachments,removeTextAttachment:i.removeTextAttachment,pendingImage:i.pendingImage,clearPendingImage:i.clearPendingImage,attachFiles:i.attachFiles,uploadImage:i.uploadImage,submit:r.submit,steer:r.steer,steerText:r.steerText,followUp:r.followUp,cancel:a.cancel,cancelFollowUp:a.cancelFollowUp,compactSession:i.compactSession,pendingFollowUps:a.pendingFollowUps,picker:{templates:i.promptPanel.templates,heroes:i.promptPanel.heroes,graphs:i.promptPanel.flows,skills:i.promptPanel.skills,pendingSkills:i.promptPanel.pendingSkills,pendingGraph:i.promptPanel.pendingGraph,selectedHeroId:i.selectedHeroId,onSelectTemplate:i.promptPanel.onSelect,onSelectHero:i.promptPanel.onHeroSelect,onSelectGraph:i.promptPanel.onFlowSelect,onToggleSkill:i.promptPanel.toggleSkill,onClearGraph:i.promptPanel.clearPendingGraph},expanding:i.promptPanel.expanding,expandDiag:i.promptPanel.expandDiag,contextUsage:a.contextUsage,stats:a.stats})]})})]})}let rR=o("menu",[["path",{d:"M4 5h16",key:"1tepv9"}],["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 19h16",key:"1djgab"}]]),rE=o("panel-right",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}]]),rA=o("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"}]]),r$=o("shield-check",[["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:"m9 12 2 2 4-4",key:"dzmm74"}]]);function rz({item:e,onNavigate:n,onDismiss:a}){let s,i=(0,f.useT)(),r=!e.requiresAction;return(0,t.jsxs)("div",{className:"attention-row",role:"listitem","data-kind":e.kind,"data-attention-id":e.id,children:[(0,t.jsx)("span",{className:"attention-icon",children:(s={size:13,"aria-hidden":!0},"needs_input"===e.kind?(0,t.jsx)(iU,{...s}):"approval_required"===e.kind?(0,t.jsx)(r$,{...s}):(e.kind,(0,t.jsx)(eX,{...s})))}),(0,t.jsxs)("button",{type:"button",className:"attention-main",onClick:()=>n(e),children:[(0,t.jsx)("strong",{children:function(e,t){let n=e.display;switch(e.kind){case"approval_required":return t(n?.kind==="retry_budget"?"conversation.attention.retryBudget":"conversation.attention.approvalRequired");case"needs_input":if(n?.kind==="question"){let e=n.questionCount??0;return t(1===e?"conversation.attention.questionOne":"conversation.attention.questionMany",{count:e})}return t("conversation.attention.needsInput");case"delegation_completed":return t("conversation.attention.completed");case"delegation_failed":return t("conversation.attention.failed")}return t("conversation.attention.title")}(e,i)}),(0,t.jsx)("span",{children:e.display?.summary??e.sessionId})]}),r?(0,t.jsx)("button",{type:"button",className:"attention-dismiss","aria-label":i("conversation.attention.dismiss"),title:i("conversation.attention.dismiss"),onClick:()=>a(e),children:(0,t.jsx)(m,{size:13,"aria-hidden":"true"})}):(0,t.jsx)("span",{className:"attention-action-tag",children:function(e,t){switch(e){case"answer_question":return t("conversation.attention.actionAnswerQuestion");case"tool_approval":return t("conversation.attention.actionToolApproval");case"delegation_approval":return t("conversation.attention.actionDelegationApproval");case"delegation_input":return t("conversation.attention.actionDelegationInput")}return t("conversation.attention.action")}(e.action?.kind,i)})]})}function rF({projectId:e,onNavigate:a}){let s=(0,f.useT)(),{items:i,pendingCount:r,refresh:l}=function(e){let[t,a]=(0,n.useState)([]),[s,i]=(0,n.useState)(0);(0,n.useEffect)(()=>{let t;if(!e)return;let n=new AbortController,s=async()=>{try{let t=await (0,e5.apiFetch)(`/v1/attention?projectId=${encodeURIComponent(e)}&status=pending&limit=50`,{signal:n.signal});n.signal.aborted||a(t.items??[])}catch{}finally{n.signal.aborted||(t=window.setTimeout(s,5e3))}};return s(),()=>{n.abort(),void 0!==t&&window.clearTimeout(t)}},[e,s]);let r=(0,n.useMemo)(()=>t.filter(e=>"pending"===e.status).length,[t]);return{items:t,pendingCount:r,refresh:()=>i(e=>e+1)}}(e),[o,c]=(0,n.useState)(!1),d=(0,n.useRef)(null);M(o,()=>c(!1)),(0,n.useEffect)(()=>{if(!o)return;let e=e=>{d.current?.contains(e.target)||c(!1)};return document.addEventListener("pointerdown",e),()=>document.removeEventListener("pointerdown",e)},[o]);let u=async e=>{try{await (0,e5.apiFetch)(`/v1/attention/${encodeURIComponent(e.id)}/dismiss`,{method:"POST",body:JSON.stringify({clientRequestId:crypto.randomUUID()})}),l()}catch{l()}},p=[...i].sort((e,t)=>!!t.requiresAction-!!e.requiresAction);return(0,t.jsxs)("div",{className:"attention-panel",ref:d,children:[(0,t.jsxs)("button",{type:"button",className:"attention-bell","aria-label":s("conversation.attention.aria",{count:String(r)}),title:s("conversation.attention.title"),onClick:()=>c(e=>!e),children:[(0,t.jsx)(rA,{size:15,"aria-hidden":"true"}),r>0&&(0,t.jsx)("span",{className:"attention-badge",children:r>99?"99+":r})]}),o&&(0,t.jsxs)("div",{className:"attention-popover",role:"dialog","aria-label":s("conversation.attention.title"),children:[(0,t.jsxs)("div",{className:"attention-popover-header",children:[(0,t.jsx)("strong",{children:s("conversation.attention.title")}),(0,t.jsx)("span",{children:s("conversation.attention.pending",{count:String(r)})})]}),(0,t.jsxs)("div",{className:"attention-list",role:"list",children:[0===p.length&&(0,t.jsx)("div",{className:"attention-empty",children:s("conversation.attention.empty")}),p.map(e=>(0,t.jsx)(rz,{item:e,onNavigate:e=>{c(!1),a(e)},onDismiss:u},e.id))]})]})]})}let rL=o("git-branch",[["path",{d:"M15 6a9 9 0 0 0-9 9V3",key:"1cii5b"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}]]);function rD({branches:e,activeBranchId:a,loading:s,changing:i,disabled:r,activate:l}){let[o,c]=(0,n.useState)(!1),d=(0,n.useRef)(null),u=e.find(e=>e.id===a);return M(o,()=>c(!1)),(0,n.useEffect)(()=>{if(!o)return;let e=e=>{d.current?.contains(e.target)||c(!1)};return window.addEventListener("pointerdown",e),()=>window.removeEventListener("pointerdown",e)},[o]),(0,t.jsxs)("div",{className:"branch-control",ref:d,children:[(0,t.jsxs)("button",{type:"button",className:"branch-trigger","aria-label":"Choose conversation branch",title:"Choose conversation branch","aria-haspopup":"menu","aria-expanded":o,disabled:r||s||i,onClick:()=>c(e=>!e),children:[(0,t.jsx)(rL,{size:15,"aria-hidden":"true"}),(0,t.jsx)("span",{children:u?.label??(s?"Loading":"Main")}),e.length>1&&(0,t.jsx)("small",{children:e.length})]}),o&&(0,t.jsx)("div",{className:"branch-menu",role:"menu","aria-label":"Conversation branches",children:e.map(e=>(0,t.jsxs)("button",{type:"button",role:"menuitemradio","aria-checked":e.id===a,onClick:()=>{c(!1),l(e.id)},children:[(0,t.jsx)(rL,{size:14,"aria-hidden":"true"}),(0,t.jsxs)("span",{children:[(0,t.jsx)("strong",{children:e.label}),(0,t.jsxs)("small",{children:[e.messageCount," messages"]})]}),e.id===a&&(0,t.jsx)(Y,{size:14,"aria-hidden":"true"})]},e.id))})]})}let rO=o("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"}]]),rq=o("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"}]]),rB=new Set;function rU(){let e=window.localStorage.getItem("ennote-theme");return"light"===e||"dark"===e?e:"system"}function rH(e=rU()){return"dark"===e?"dark":"light"===e?"light":window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function rW(){let e=rU();return`${e}:${rH(e)}`}function rV(e){rB.add(e);let t=window.matchMedia("(prefers-color-scheme: dark)"),n=()=>{"system"===rU()&&(rK(rH("system")),rB.forEach(e=>e()))},a=e=>{"ennote-theme"===e.key&&(rK(rH()),rB.forEach(e=>e()))};return t.addEventListener("change",n),window.addEventListener("storage",a),()=>{rB.delete(e),t.removeEventListener("change",n),window.removeEventListener("storage",a)}}function rK(e){document.documentElement.classList.toggle("dark","dark"===e),document.documentElement.dataset.theme=e}function rG(e,t){let n=()=>{"system"===e?window.localStorage.removeItem("ennote-theme"):window.localStorage.setItem("ennote-theme",e),rK(rH(e)),rB.forEach(e=>e())},a=window.matchMedia("(prefers-reduced-motion: reduce)").matches;if("function"!=typeof document.startViewTransition||a)return void n();let s=t?.x??window.innerWidth/2,i=t?.y??window.innerHeight/2,r=Math.hypot(Math.max(s,window.innerWidth-s),Math.max(i,window.innerHeight-i));document.startViewTransition(n).ready.then(()=>document.documentElement.animate({clipPath:[`circle(0 at ${s}px ${i}px)`,`circle(${r}px at ${s}px ${i}px)`]},{duration:420,easing:"cubic-bezier(0.22, 0.61, 0.36, 1)",pseudoElement:"::view-transition-new(root)"})).catch(()=>void 0)}function rJ(){let[e,t]=(0,n.useSyncExternalStore)(rV,rW,()=>"system:light").split(":"),a=(0,n.useCallback)((e,t)=>rG(e,t),[]),s=(0,n.useCallback)(e=>rG("dark"===t?"light":"dark",e),[t]);return{mode:e,theme:t,isDark:"dark"===t,setThemeMode:a,toggleTheme:s}}function rY(){let{isDark:e,toggleTheme:n}=rJ();return(0,t.jsx)(ra,{label:e?"Switch to light mode":"Switch to dark mode",title:e?"Switch to light mode":"Switch to dark mode","aria-pressed":e,onClick:e=>{let t=e.currentTarget.getBoundingClientRect();n({x:t.left+t.width/2,y:t.top+t.height/2})},children:e?(0,t.jsx)(rq,{size:15,"aria-hidden":"true"}):(0,t.jsx)(rO,{size:15,"aria-hidden":"true"})})}function rQ(e){let{sidebarOpen:n,onToggleSidebar:a,navigationTriggerRef:s,session:i,title:r,projectName:l,projectPath:o,branch:c,rightPanelOpen:d,onToggleRightPanel:u,attention:p}=e,{title:h,editing:m,draft:f,setDraft:x,startEdit:v,save:y,keyDown:b,inputRef:k}=r;return(0,t.jsxs)("div",{className:"app-topbar",children:[(0,t.jsx)(ra,{ref:s,label:n?"Hide navigation":"Open navigation",title:n?"Hide sidebar":"Show sidebar","aria-expanded":n,"aria-controls":"workspace-navigation",onClick:a,children:n?(0,t.jsx)(g,{size:16,"aria-hidden":"true"}):(0,t.jsx)(rR,{size:18,"aria-hidden":"true"})}),(0,t.jsxs)("div",{className:"topbar-title-area",children:[(0,t.jsx)("div",{className:"topbar-title-group",children:m&&i?(0,t.jsx)("input",{ref:k,className:"topbar-title-input",value:f,onChange:e=>x(e.target.value),onKeyDown:b,onBlur:()=>void y()}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("div",{className:"topbar-session-title",title:h,children:h}),i&&(0,t.jsx)("button",{type:"button",className:"topbar-title-edit",onClick:v,title:"Rename session","aria-label":"Rename session",children:(0,t.jsx)(C,{size:12,"aria-hidden":"true"})})]})}),l&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("span",{className:"topbar-project-sep",children:"/"}),(0,t.jsx)("span",{className:"topbar-project-crumb",title:o||l,children:l})]})]}),i&&(0,t.jsx)(rD,{branches:c.branches,activeBranchId:c.activeBranchId,loading:c.loading,changing:c.changing,disabled:c.disabled,activate:c.onActivate}),(0,t.jsx)(rY,{}),(0,t.jsx)(ra,{label:d?"Hide panel":"Show panel",title:d?"Hide panel":"Show panel",active:d,onClick:u,children:(0,t.jsx)(rE,{size:16,"aria-hidden":"true"})}),(0,t.jsx)(rF,{projectId:p.projectId,onNavigate:p.onNavigate})]})}let rZ=o("arrow-left",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]),rX=o("pin",[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z",key:"1nkz8b"}]]),r0=o("pin-off",[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M15 9.34V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H7.89",key:"znwnzq"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M9 9v1.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h11",key:"c9qhm2"}]]),r1=o("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"}]]);function r2(e,t){let n=new URLSearchParams({path:t});return`/v1/projects/${encodeURIComponent(e)}/files/content?${n.toString()}`}async function r4(e,t="/workspace",n){let a;return(0,e5.apiFetch)((a=new URLSearchParams({path:t}),`/v1/projects/${encodeURIComponent(e)}/files?${a.toString()}`),{signal:n})}async function r5(e,t,n){let a=await (0,e5.apiResponse)(r2(e,t),{signal:n});if(!a.ok){let e=await a.json().catch(()=>({}));throw Error(e.error?.message??`HTTP ${a.status}`)}return a}function r3(e){let t=e.replace(/\/+$/,""),n=t.lastIndexOf("/");return n<=0?{parent:"/workspace",name:t}:{parent:t.slice(0,n),name:t.slice(n+1)}}async function r6(e,t){return(0,e5.apiFetch)(`/v1/projects/${encodeURIComponent(e)}/files/create`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})}async function r8(e,t){return(0,e5.apiFetch)(`/v1/projects/${encodeURIComponent(e)}/files/move`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})}async function r9(e,t,n={}){let a=new URLSearchParams({path:t});n.recursive&&a.set("recursive","true"),await (0,e5.apiFetch)(`/v1/projects/${encodeURIComponent(e)}/files?${a.toString()}`,{method:"DELETE"})}let r7=new Set(["png","jpg","jpeg","gif","webp","svg","bmp","ico","avif"]),le=new Set(["md","mdx","rmd","qmd"]),lt=new Set(["txt","json","yaml","yml","toml","csv","tsv","log","ts","tsx","js","jsx","mjs","cjs","py","r","rb","go","rs","java","c","cpp","h","hpp","css","scss","less","html","htm","xml","sh","bash","zsh","fish","ps1","bat","sql","graphql","gql","conf","cfg","ini","properties"]);function ln({projectId:a,filePath:s,fileName:i}){var r;let[l,o]=(0,n.useState)({kind:"loading"}),c=i??s.split("/").pop()??s,d=la(c);(0,n.useEffect)(()=>{let t=new AbortController,n=null;return async function(){o({kind:"loading"});try{var i,r,l;let u,p,h=await r5(a,s,t.signal),m=Number(h.headers.get("Content-Length")??0),f=h.headers.get("Content-Type")?.split(";",1)[0]??"application/octet-stream";if(le.has(d)){if(m>4194304)throw Error("Text preview exceeds the 4 MiB limit");let e=await h.text();t.signal.aborted||o({kind:"markdown",content:e,size:e.length});return}if(i=c,r=f,u=la(i),p=i.toLowerCase(),r.startsWith("text/")||lt.has(u)||["dockerfile","makefile"].includes(p)||p.startsWith(".env")){let n,a;if(m>4194304)throw Error("Text preview exceeds the 4 MiB limit");let s=await h.text(),i=(l=c,n=la(l),a=l.toLowerCase(),"dockerfile"===a?"dockerfile":"makefile"===a?"makefile":({ts:"typescript",tsx:"tsx",js:"javascript",jsx:"jsx",mjs:"javascript",cjs:"javascript",py:"python",r:"r",rb:"ruby",go:"go",rs:"rust",java:"java",c:"c",cpp:"cpp",h:"c",hpp:"cpp",css:"css",scss:"scss",less:"less",html:"html",htm:"html",xml:"xml",json:"json",yaml:"yaml",yml:"yaml",toml:"toml",sh:"bash",bash:"bash",zsh:"bash",fish:"fish",ps1:"powershell",sql:"sql",graphql:"graphql",gql:"graphql"})[n]??null),r=null;if(i)try{let{codeToHtml:t}=await e.A(140);r=await t(s,{lang:i,themes:{light:"github-light",dark:"github-dark"},defaultColor:!1})}catch{r=null}t.signal.aborted||o({kind:"code",content:s,highlighted:r,language:i??"text",size:s.length});return}if(r7.has(d)||f.startsWith("image/")){let e=await h.blob();n=URL.createObjectURL(e),t.signal.aborted||o({kind:"image",url:n,mime:f,size:e.size});return}if("pdf"===d||"application/pdf"===f){let e=await h.blob();n=URL.createObjectURL(e),t.signal.aborted||o({kind:"pdf",url:n,mime:f,size:e.size});return}o({kind:"unsupported",mime:f,size:m})}catch(e){t.signal.aborted||o({kind:"error",message:e.message})}}(),()=>{t.abort(),n&&URL.revokeObjectURL(n)}},[d,s,c,a]);let u="size"in l?(r=l.size)?r<1024?`${r} B`:r<1048576?`${(r/1024).toFixed(1)} KB`:`${(r/1048576).toFixed(1)} MB`:"0 B":null,p="code"===l.kind?l.language:d||l.kind,h=(0,e5.workerAPIPath)(r2(a,s));return(0,t.jsxs)("div",{className:"file-viewer",children:[(0,t.jsxs)("div",{className:"file-viewer-status",children:[(0,t.jsx)("span",{className:"file-viewer-type",children:p}),(0,t.jsx)("span",{className:"file-viewer-path",title:s,children:s}),u&&(0,t.jsx)("span",{children:u}),(0,t.jsx)("a",{className:"file-viewer-download",href:h,download:c,title:"Download file","aria-label":`Download ${c}`,children:(0,t.jsx)(iA,{size:13,"aria-hidden":"true"})})]}),(0,t.jsxs)("div",{className:"file-viewer-body",children:["loading"===l.kind&&(0,t.jsxs)("div",{className:"file-viewer-empty",children:[(0,t.jsx)(eQ,{className:"spin",size:18}),"Loading preview..."]}),"error"===l.kind&&(0,t.jsxs)("div",{className:"file-viewer-empty is-error",children:[(0,t.jsx)(r1,{size:20}),l.message]}),"markdown"===l.kind&&(0,t.jsx)("article",{className:"markdown-body file-markdown",children:(0,t.jsx)(a9,{remarkPlugins:[id],children:l.content})}),"code"===l.kind&&l.highlighted&&(0,t.jsx)("div",{className:"file-code",dangerouslySetInnerHTML:{__html:l.highlighted}}),"code"===l.kind&&!l.highlighted&&(0,t.jsx)("pre",{className:"file-code-plain",children:l.content}),"image"===l.kind&&(0,t.jsx)("div",{className:"file-image-stage",children:(0,t.jsx)("img",{src:l.url,alt:c})}),"pdf"===l.kind&&(0,t.jsx)("iframe",{className:"file-pdf",src:l.url,title:c}),"unsupported"===l.kind&&(0,t.jsxs)("div",{className:"file-viewer-empty",children:[(0,t.jsx)(r1,{size:20}),"Preview is not available for ",l.mime,"."]})]})]})}function la(e){return e.includes(".")?e.toLowerCase().split(".").pop()??"":""}var ls=e.i(51535);let li="var(--text-dim)";function lr({size:e=14,open:n=!1}){return n?(0,t.jsxs)("svg",{width:e,height:e,viewBox:"0 0 16 16",fill:"none",children:[(0,t.jsx)("path",{d:"M1 4.5A1 1 0 0 1 2 3.5H5.5L7 5h7.5v1H1V4.5Z",fill:li}),(0,t.jsx)("path",{d:"M1 6h14.5L14 13H2L1 6Z",stroke:li,strokeWidth:"1",fill:li,fillOpacity:"0.12"})]}):(0,t.jsx)("svg",{width:e,height:e,viewBox:"0 0 16 16",fill:"none",children:(0,t.jsx)("path",{d:"M1 4.5A1 1 0 0 1 2 3.5H5.5L7 5H14a1 1 0 0 1 1 1v6a1 1 0 0 1-1 1H2a1 1 0 0 1-1-1V4.5Z",stroke:li,strokeWidth:"1",fill:li,fillOpacity:"0.1"})})}function ll({size:e=14}){return(0,t.jsxs)("svg",{width:e,height:e,viewBox:"0 0 16 16",fill:"none",children:[(0,t.jsx)("path",{d:"M3 2h7l3 3v9H3V2Z",stroke:li,strokeWidth:"1",fill:li,fillOpacity:"0.08"}),(0,t.jsx)("path",{d:"M10 2v3h3",stroke:li,strokeWidth:"1",fill:"none",strokeLinejoin:"round"})]})}function lo({label:e,size:n=14}){return(0,t.jsxs)("svg",{width:n,height:n,viewBox:"0 0 14 14",fill:"none",children:[(0,t.jsx)("path",{d:"M2.5 1h6l3 3v9h-9V1Z",stroke:li,strokeWidth:"0.9",fill:li,fillOpacity:"0.07",strokeLinejoin:"round"}),(0,t.jsx)("path",{d:"M8.5 1v3h3",stroke:li,strokeWidth:"0.9",fill:"none",strokeLinejoin:"round"}),(0,t.jsx)("text",{x:"7",y:"9.5",textAnchor:"middle",fontSize:"3.4",fontFamily:"var(--font-mono), monospace",fontWeight:"600",fill:li,children:e})]})}function lc({size:e=14}){return(0,t.jsx)(lo,{label:"PY",size:e})}function ld({size:e=14}){return(0,t.jsx)(lo,{label:"R",size:e})}function lu({size:e=14}){return(0,t.jsx)(lo,{label:"TS",size:e})}function lp({size:e=14}){return(0,t.jsx)(lo,{label:"JS",size:e})}function lh({size:e=14}){return(0,t.jsx)(lo,{label:"{}",size:e})}function lm({size:e=14}){return(0,t.jsx)(lo,{label:"CSS",size:e})}function lf({size:e=14}){return(0,t.jsx)(lo,{label:"HTM",size:e})}function lg({size:e=14}){return(0,t.jsxs)("svg",{width:e,height:e,viewBox:"0 0 14 14",fill:"none",children:[(0,t.jsx)("path",{d:"M2.5 1h6l3 3v9h-9V1Z",stroke:li,strokeWidth:"0.9",fill:li,fillOpacity:"0.07",strokeLinejoin:"round"}),(0,t.jsx)("path",{d:"M8.5 1v3h3",stroke:li,strokeWidth:"0.9",fill:"none",strokeLinejoin:"round"}),(0,t.jsx)("path",{d:"M3.5 9.5V7l1.5 1.5L6.5 7v2.5",stroke:li,strokeWidth:"0.9",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"}),(0,t.jsx)("path",{d:"M8 7v2.5M7 9l1 1.5 1-1.5",stroke:li,strokeWidth:"0.9",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"})]})}function lx({size:e=14}){return(0,t.jsx)(lo,{label:"YML",size:e})}function lv({size:e=14}){return(0,t.jsxs)("svg",{width:e,height:e,viewBox:"0 0 14 14",fill:"none",children:[(0,t.jsx)("path",{d:"M2.5 1h6l3 3v9h-9V1Z",stroke:li,strokeWidth:"0.9",fill:li,fillOpacity:"0.07",strokeLinejoin:"round"}),(0,t.jsx)("path",{d:"M8.5 1v3h3",stroke:li,strokeWidth:"0.9",fill:"none",strokeLinejoin:"round"}),(0,t.jsx)("path",{d:"M4 7.5l2 1.5-2 1.5",stroke:li,strokeWidth:"0.95",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"}),(0,t.jsx)("path",{d:"M7.5 10.5h2.5",stroke:li,strokeWidth:"0.95",strokeLinecap:"round"})]})}function ly({size:e=14}){return(0,t.jsx)(lo,{label:"GO",size:e})}function lb({size:e=14}){return(0,t.jsx)(lo,{label:"RS",size:e})}function lk({size:e=14}){return(0,t.jsx)(lo,{label:"SQL",size:e})}function lj({size:e=14}){return(0,t.jsxs)("svg",{width:e,height:e,viewBox:"0 0 14 14",fill:"none",children:[(0,t.jsx)("path",{d:"M2.5 1h6l3 3v9h-9V1Z",stroke:li,strokeWidth:"0.9",fill:li,fillOpacity:"0.07",strokeLinejoin:"round"}),(0,t.jsx)("path",{d:"M8.5 1v3h3",stroke:li,strokeWidth:"0.9",fill:"none",strokeLinejoin:"round"}),(0,t.jsx)("rect",{x:"3.5",y:"6.5",width:"2",height:"1.5",rx:"0.3",stroke:li,strokeWidth:"0.8"}),(0,t.jsx)("rect",{x:"6",y:"6.5",width:"2",height:"1.5",rx:"0.3",stroke:li,strokeWidth:"0.8"}),(0,t.jsx)("rect",{x:"3.5",y:"8.5",width:"2",height:"1.5",rx:"0.3",stroke:li,strokeWidth:"0.8"})]})}function lw({size:e=14}){return(0,t.jsxs)("svg",{width:e,height:e,viewBox:"0 0 14 14",fill:"none",children:[(0,t.jsx)("path",{d:"M2.5 1h6l3 3v9h-9V1Z",stroke:li,strokeWidth:"0.9",fill:li,fillOpacity:"0.07",strokeLinejoin:"round"}),(0,t.jsx)("path",{d:"M8.5 1v3h3",stroke:li,strokeWidth:"0.9",fill:"none",strokeLinejoin:"round"}),(0,t.jsx)("circle",{cx:"7",cy:"8.5",r:"1.3",stroke:li,strokeWidth:"0.9"}),(0,t.jsx)("path",{d:"M7 6.5v.7M7 10.3v.7M5 8.5h.7M8.3 8.5H9M5.5 6.9l.5.5M8.5 9.6l-.5-.5M5.5 10.1l.5-.5M8.5 7.4l-.5.5",stroke:li,strokeWidth:"0.8",strokeLinecap:"round"})]})}function lN(e,n=14){let a=e.toLowerCase(),s=a.split(".").pop()??"";return"dockerfile"===a||a.startsWith("dockerfile.")?(0,t.jsx)(lj,{size:n}):"py"===s?(0,t.jsx)(lc,{size:n}):"r"===s||"rds"===s||"qs"===s?(0,t.jsx)(ld,{size:n}):"ts"===s?(0,t.jsx)(lu,{size:n}):"tsx"===s?(0,t.jsx)(lo,{label:"TSX",size:n}):"js"===s||"mjs"===s||"cjs"===s?(0,t.jsx)(lp,{size:n}):"jsx"===s?(0,t.jsx)(lo,{label:"JSX",size:n}):"json"===s||"jsonl"===s?(0,t.jsx)(lh,{size:n}):"css"===s||"less"===s?(0,t.jsx)(lm,{size:n}):"scss"===s?(0,t.jsx)(lo,{label:"SC",size:n}):"html"===s||"htm"===s?(0,t.jsx)(lf,{size:n}):"md"===s||"mdx"===s?(0,t.jsx)(lg,{size:n}):"yaml"===s||"yml"===s?(0,t.jsx)(lx,{size:n}):"toml"===s?(0,t.jsx)(lo,{label:"TOM",size:n}):"sh"===s||"bash"===s||"zsh"===s||"fish"===s?(0,t.jsx)(lv,{size:n}):"rs"===s?(0,t.jsx)(lb,{size:n}):"go"===s?(0,t.jsx)(ly,{size:n}):"sql"===s?(0,t.jsx)(lk,{size:n}):"tf"===s||"hcl"===s?(0,t.jsx)(lo,{label:"TF",size:n}):"lock"===s?(0,t.jsx)(lo,{label:"LK",size:n}):s.endsWith("config.ts")||s.endsWith("config.js")||s.endsWith("config.mjs")?(0,t.jsx)(lw,{size:n}):(0,t.jsx)(ll,{size:n})}function l_({tabs:e,activeTabId:a,onSelectTab:s,onCloseTab:i,onReorder:r,closeLabel:l}){let[o,c]=(0,n.useState)(null),[d,u]=(0,n.useState)(null),p=()=>{c(null),u(null)};return(0,t.jsx)("div",{role:"tablist","aria-label":"Workspace panel tabs",className:ls.default.bar,children:e.map((n,f)=>{let g=n.id===a,x=!1!==n.closable;return(0,t.jsxs)("div",{role:"tab",tabIndex:g?0:-1,"aria-selected":g,onClick:()=>s(n.id),draggable:!!r,"data-dragging":o===n.id||void 0,"data-drop-target":d===n.id||void 0,onDragStart:e=>{r&&(c(n.id),e.dataTransfer.effectAllowed="move",e.dataTransfer.setData("text/plain",n.id))},onDragOver:e=>{r&&null!==o&&o!==n.id&&(e.preventDefault(),e.dataTransfer.dropEffect="move",u(n.id))},onDragLeave:()=>u(e=>e===n.id?null:e),onDrop:e=>{if(!r)return;e.preventDefault();let t=e.dataTransfer.getData("text/plain")||o;t&&t!==n.id&&r(t,n.id),p()},onDragEnd:p,onKeyDown:t=>{if("Enter"===t.key||" "===t.key){t.preventDefault(),s(n.id);return}if("ArrowLeft"!==t.key&&"ArrowRight"!==t.key)return;t.preventDefault();let a=(f+("ArrowRight"===t.key?1:-1)+e.length)%e.length;t.altKey&&r?r(n.id,e[a].id):(s(e[a].id),t.currentTarget.parentElement?.children[a]?.focus())},className:ls.default.tab,"data-active":g||void 0,children:[(0,t.jsx)("span",{className:ls.default.icon,children:"files"===n.icon?(0,t.jsx)(w,{size:13,"aria-hidden":"true"}):"report"===n.icon?(0,t.jsx)(ei,{size:13,"aria-hidden":"true"}):"tools"===n.icon?(0,t.jsx)(tn,{size:13,"aria-hidden":"true"}):"graph"===n.icon?(0,t.jsx)(h,{size:13,"aria-hidden":"true"}):lN(n.filePath??n.label,13)}),(0,t.jsx)("span",{className:ls.default.label,title:n.filePath??n.label,children:n.label}),x&&(0,t.jsx)("button",{type:"button",className:ls.default.close,onClick:e=>{e.stopPropagation(),i(n.id)},title:"Close","aria-label":l?l(n):`Close ${n.label}`,children:(0,t.jsx)(m,{size:10,"aria-hidden":"true"})})]},n.id)})})}function lC(){document.body.style.cursor="",document.body.style.userSelect=""}function lS({side:e,onResize:a,onResizeStart:s,onResizeEnd:i,ariaLabel:r,value:l,min:o,max:c}){let d=(0,n.useRef)(null),u=(0,n.useRef)(!1),p=(0,n.useRef)(0),[h,m]=(0,n.useState)(!1),f=(0,n.useCallback)(e=>{if(!u.current)return;u.current=!1,m(!1);let t=d.current;t&&void 0!==e&&t.hasPointerCapture(e)&&t.releasePointerCapture(e),lC(),i?.()},[i]),g=(0,n.useCallback)(e=>{0===e.button&&e.isPrimary&&(e.preventDefault(),u.current=!0,p.current=e.clientX,m(!0),s?.(),e.currentTarget.setPointerCapture(e.pointerId),document.body.style.cursor="col-resize",document.body.style.userSelect="none")},[s]),x=(0,n.useCallback)(e=>{if(!u.current)return;e.preventDefault();let t=e.clientX-p.current;p.current=e.clientX,a(t)},[a]),v=(0,n.useCallback)(e=>{e.preventDefault(),f(e.pointerId)},[f]),y=(0,n.useCallback)(e=>{f(e.pointerId)},[f]);(0,n.useEffect)(()=>()=>{u.current&&(u.current=!1,lC(),i?.())},[i]);let b=(0,n.useCallback)(e=>{if("ArrowLeft"!==e.key&&"ArrowRight"!==e.key)return;e.preventDefault();let t="ArrowRight"===e.key?16:-16;s?.(),a(t),i?.()},[a,i,s]);return(0,t.jsx)("div",{ref:d,role:"separator","aria-label":r??"Resize panel","aria-orientation":"vertical","aria-valuemin":o,"aria-valuemax":c,"aria-valuenow":l,tabIndex:0,className:`resize-handle${h?" resize-handle-dragging":""}`,"data-side":e,onPointerDown:g,onPointerMove:x,onPointerUp:v,onPointerCancel:y,onKeyDown:b,style:{alignSelf:"stretch",cursor:"col-resize",display:"flex",flexShrink:0,justifyContent:"center",marginLeft:-5,marginRight:-5,position:"relative",touchAction:"none",width:10,zIndex:"var(--layer-drag-overlay)"},children:(0,t.jsx)("div",{className:"resize-handle-line"})})}function lI(e){let t=(0,n.useCallback)(t=>{let n=window.matchMedia(e);return n.addEventListener("change",t),()=>n.removeEventListener("change",t)},[e]),a=(0,n.useCallback)(()=>window.matchMedia(e).matches,[e]);return(0,n.useSyncExternalStore)(t,a,()=>!1)}function lP(e,t){return Math.max(280,Math.min(1e3,e-t-440-5))}function lT(e,t){return Math.max(220,Math.min(Math.max(220,t-8-264),null!==e&&Number.isFinite(e)?e:280))}function lM(e,t){return t?"narrow":e>=520?"wide":e>=280?"medium":"narrow"}var lR=e.i(73574);function lE(e){let n=(0,f.useT)(),a=lI("(max-width: 960px)"),s=lM(e.width,a),i=lT(e.primaryWidth,e.width);if("narrow"===s)return(0,t.jsxs)("div",{className:lR.default.narrow,children:[e.narrowStrip,(0,t.jsx)("div",{className:lR.default.body,children:e.narrowBody})]});let r=null!==e.inspectorBody,l="medium"===s&&r,o=r&&!e.primaryHidden,c=r&&!l&&e.primaryHidden,d=l&&!e.navigatorOpen,u=l?{width:"min(300px, 78%)"}:c?{display:"none"}:o?{width:i}:{flex:"1 1 auto"},p=l?"medium":c?"fill":o?"wide":"single";return(0,t.jsxs)("div",{className:lR.default.lanes,"data-mode":p,"data-testid":"right-panel-lanes",children:[l&&e.navigatorOpen&&(0,t.jsx)("div",{className:lR.default.backdrop,onPointerDown:e.onToggleNavigator,"aria-hidden":"true"},"backdrop"),(0,t.jsxs)("div",{className:`${lR.default.primary}${l?` ${lR.default["primary-overlay"]}`:""}`,style:u,"data-open":l&&e.navigatorOpen||void 0,"data-parked":d||void 0,"data-testid":"right-panel-primary",inert:d,children:[e.channelStrip,(0,t.jsx)("div",{className:lR.default.body,children:e.channelBody})]},"primary"),o&&!l&&(0,t.jsx)(lS,{side:"right",ariaLabel:n("rightPanel.resizeNavigator"),value:i,min:220,max:Math.max(220,e.width-8-264),onResize:e.onResizePrimary,onResizeStart:e.onResizePrimaryStart,onResizeEnd:e.onResizePrimaryEnd},"divider"),r&&(0,t.jsxs)("div",{className:lR.default.inspector,children:[(0,t.jsxs)("div",{className:lR.default.strip,children:[e.inspectorStrip,(0,t.jsx)("button",{type:"button",className:lR.default["nav-toggle"],"aria-label":n(e.navigatorOpen?"rightPanel.hideNavigator":"rightPanel.showNavigator"),"aria-expanded":e.navigatorOpen,"data-open":e.navigatorOpen||void 0,onClick:e.onToggleNavigator,children:(0,t.jsx)(g,{size:15,"aria-hidden":"true"})})]}),(0,t.jsx)("div",{className:lR.default.body,children:e.inspectorBody})]},"inspector")]})}let lA={files:"rightPanel.files",graph:"rightPanel.graphs",tools:"rightPanel.status"},l$={files:"files",graph:"graph",tools:"tools"};function lz(e,t){return e.map(e=>({id:e,label:t(lA[e]),closable:!0,icon:l$[e]}))}let lF={files:o("files",[["path",{d:"M15 2h-4a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V8",key:"14sh0y"}],["path",{d:"M16.706 2.706A2.4 2.4 0 0 0 15 2v5a1 1 0 0 0 1 1h5a2.4 2.4 0 0 0-.706-1.706z",key:"1970lx"}],["path",{d:"M5 7a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h8a2 2 0 0 0 1.732-1",key:"l4dndm"}]]),graph:h,tools:tn};function lL(e){return(0,t.jsxs)("div",{className:"right-panel-launcher",role:"group","aria-label":e.hint,children:[(0,t.jsx)("p",{className:"right-panel-launcher-hint",children:e.hint}),e.channels.map(n=>{let a=lF[n];return(0,t.jsxs)("button",{type:"button",className:"right-panel-launcher-card",onClick:()=>e.onOpen(n),children:[(0,t.jsx)(a,{size:15,"aria-hidden":"true"}),(0,t.jsx)("span",{children:(0,e.t)(lA[n])})]},n)})]})}let lD=o("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"}]]),lO=o("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"}]]);function lq(e){var n;let{entry:a,depth:s,expanded:i,loading:r,errorText:l,tabbable:o,selected:c}=e;return(0,t.jsxs)("div",{className:"file-tree-row",style:{paddingLeft:8+16*s},role:"treeitem","aria-level":s+1,"aria-expanded":a.isDir?i:void 0,"aria-selected":c||void 0,tabIndex:o?0:-1,"data-path":a.path,onClick:e.onClick,onContextMenu:e.onContextMenu,onKeyDown:e.onKeyDown,children:[(0,t.jsxs)("span",{className:"file-tree-main",title:a.path,children:[(0,t.jsx)("span",{className:"file-tree-icon",children:a.isDir?(0,t.jsx)(lr,{size:14,open:i}):lN(a.name,14)}),(0,t.jsx)("span",{className:"file-tree-name",children:a.name}),!a.isDir&&(0,t.jsx)("span",{className:"file-tree-size",children:(n=a.size)<1024?`${n} B`:n<1048576?`${(n/1024).toFixed(1)} K`:`${(n/1048576).toFixed(1)} M`}),r&&(0,t.jsx)("span",{className:"file-tree-loading",children:"..."}),l&&(0,t.jsx)("span",{className:"file-tree-error-mark",title:l,"aria-label":`Could not list ${a.name}: ${l}`,children:"!"})]}),!a.isDir&&(0,t.jsx)("button",{type:"button",className:"file-preview-action",onClick:t=>{t.stopPropagation(),e.onPreview()},"aria-label":`Preview ${a.name} in a floating window`,title:"Open floating preview",onKeyDown:e=>{("Enter"===e.key||" "===e.key)&&e.stopPropagation()},children:(0,t.jsx)(lO,{size:12,"aria-hidden":"true"})})]})}function lB(e){let a=(0,n.useRef)(null);return(0,n.useEffect)(()=>{let e=window.requestAnimationFrame(()=>{let e=a.current;e&&(e.focus(),e.select())});return()=>window.cancelAnimationFrame(e)},[]),(0,t.jsx)("div",{className:"file-tree-row file-tree-row-editing",style:{paddingLeft:8+16*e.depth},children:(0,t.jsxs)("span",{className:"file-tree-main",children:[(0,t.jsx)("span",{className:"file-tree-icon","aria-hidden":"true"}),(0,t.jsx)("input",{ref:a,className:"file-tree-editor","aria-label":e.label,defaultValue:e.initialValue,onKeyDown:t=>{"Enter"===t.key?(t.preventDefault(),e.onCommit(t.currentTarget.value)):"Escape"===t.key&&(t.preventDefault(),e.onCancel())},onBlur:()=>e.onCancel()})]})})}function lU(e){let{entry:a,at:s,onClose:i}=e,r=(0,n.useRef)(null),l=a?.path??null;if((0,n.useEffect)(()=>{if(null===l)return;let e=window.requestAnimationFrame(()=>{r.current?.querySelector('[role="menuitem"]')?.focus()});return()=>window.cancelAnimationFrame(e)},[l]),!a)return null;let o=async()=>{try{await navigator.clipboard.writeText(a.path)}catch{e.onError("The clipboard is unavailable in this window.")}i()},c=e=>()=>{e(),i()};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("div",{className:"file-tree-menu-backdrop",onPointerDown:i,"aria-hidden":"true"}),(0,t.jsxs)("div",{ref:r,className:"file-tree-menu",role:"menu","aria-label":`Actions for ${a.name}`,style:{left:s.x,top:s.y},onKeyDown:e=>{let t=Array.from(r.current?.querySelectorAll('[role="menuitem"]')??[]),n=t.indexOf(document.activeElement);if("Escape"===e.key){e.preventDefault(),i();return}if("ArrowDown"!==e.key&&"ArrowUp"!==e.key)return;e.preventDefault();let a="ArrowDown"===e.key?1:-1;t[(n+a+t.length)%t.length]?.focus()},children:[!a.isDir&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("button",{type:"button",role:"menuitem",onClick:c(e.onOpen),children:"Open"}),(0,t.jsx)("button",{type:"button",role:"menuitem",onClick:c(e.onPreview),children:"Open in floating window"})]}),(0,t.jsxs)("button",{type:"button",role:"menuitem",onClick:c(e.onNewFile),children:[(0,t.jsx)(lD,{size:12,"aria-hidden":"true"})," New file"]}),(0,t.jsxs)("button",{type:"button",role:"menuitem",onClick:c(e.onNewFolder),children:[(0,t.jsx)(d,{size:12,"aria-hidden":"true"})," New folder"]}),(0,t.jsxs)("button",{type:"button",role:"menuitem",onClick:c(e.onRename),children:[(0,t.jsx)(C,{size:12,"aria-hidden":"true"})," Rename"]}),(0,t.jsxs)("button",{type:"button",role:"menuitem",onClick:c(e.onDelete),children:[(0,t.jsx)(P,{size:12,"aria-hidden":"true"})," Delete"]}),(0,t.jsxs)("button",{type:"button",role:"menuitem",onClick:()=>void o(),children:[(0,t.jsx)(Q,{size:12,"aria-hidden":"true"})," Copy path"]})]})]})}function lH({projectId:e,displayPath:a,onOpenFile:s,onPreviewFile:i}){let[r,l]=(0,n.useState)([]),[o,c]=(0,n.useState)(!!e),[p,h]=(0,n.useState)(null),[m,f]=(0,n.useState)(new Map),[g,x]=(0,n.useState)(""),[v,y]=(0,n.useState)(new Set),[b,k]=(0,n.useState)(new Set),[j,w]=(0,n.useState)(new Map),[N,_]=(0,n.useState)(null),[C,S]=(0,n.useState)(null),I=(0,n.useRef)(new Map),P=(0,n.useRef)(36),T=(0,n.useRef)(null);(0,n.useEffect)(()=>{if(!e)return;let t=new AbortController,n=I.current;return r4(e,"/workspace",t.signal).then(e=>{l(e??[]),h(null)}).catch(e=>{t.signal.aborted||h(e.message)}).finally(()=>{t.signal.aborted||c(!1)}),()=>{t.abort(),n.forEach(e=>e.abort()),n.clear()}},[e]);let M=(0,n.useCallback)(async t=>{if(!e||j.has(t)||I.current.has(t))return;let n=new AbortController;I.current.set(t,n),k(e=>new Set(e).add(t));try{let a=await r4(e,t,n.signal);w(e=>new Map(e).set(t,a)),f(e=>{if(!e.has(t))return e;let n=new Map(e);return n.delete(t),n})}catch(e){n.signal.aborted||(f(n=>new Map(n).set(t,e.message)),y(e=>{if(!e.has(t))return e;let n=new Set(e);return n.delete(t),n}))}finally{I.current.get(t)===n&&I.current.delete(t),k(e=>{let n=new Set(e);return n.delete(t),n})}},[j,e]),R=(0,n.useCallback)(e=>{y(t=>{if(!t.has(e))return t;let n=new Set(t);return n.delete(e),n})},[]),E=(0,n.useCallback)(e=>{y(t=>t.has(e)?t:new Set(t).add(e)),M(e)},[M]),A=g.trim().toLowerCase(),$=(0,n.useMemo)(()=>{let e=[],t=new Map,n=e=>{if(!A)return!0;let a=t.get(e.path);if(void 0!==a)return a;let s=e.name.toLowerCase().includes(A)||e.isDir&&(j.get(e.path)??[]).some(n);return t.set(e.path,s),s},a=(t,s,i)=>{for(let r of t){if(!n(r))continue;e.push({entry:r,depth:s,parentPath:i});let t=r.isDir&&!m.has(r.path)&&(!!A||v.has(r.path));if(!r.isDir||!t)continue;let l=j.get(r.path);l&&a(l,s+1,r.path)}};return a(r,0,null),e},[r,j,v,m,A]);(0,n.useEffect)(()=>{if(!A){P.current=36;return}let e=window.setTimeout(()=>{let e=new Set;for(let t of r)t.isDir&&e.add(t.path);for(let t of j.values())for(let n of t)n.isDir&&e.add(n.path);let t=0;for(let n of e){if(t>=12||P.current<=0)break;j.has(n)||m.has(n)||I.current.has(n)||(M(n),P.current-=1,t+=1)}},250);return()=>window.clearTimeout(e)},[A,r,j,m,M]);let z=(0,n.useCallback)(async t=>{if(e)try{let n=await r4(e,t);"/workspace"===t?l(n??[]):w(e=>new Map(e).set(t,n??[])),h(null)}catch(e){h(e.message)}},[e]),F=(0,n.useCallback)(e=>{w(t=>{let n=new Map(t);for(let t of[...n.keys()])(t===e||t.startsWith(`${e}/`))&&n.delete(t);return n}),y(t=>{let n=new Set([...t].filter(t=>t!==e&&!t.startsWith(`${e}/`)));return n.size===t.size?t:n})},[]),{pending:L,setPending:D,beginCreate:O,beginRename:q,createDepth:B,submitCreate:U,submitRename:H,requestDelete:W}=function(e){let{projectId:t,rows:a,focusedPath:s,menuPath:i,expand:r,focusRow:l,refreshDir:o,forgetDir:c,setError:d}=e,[u,p]=(0,n.useState)(null),[h,m]=(0,n.useState)(!1),f=(0,n.useRef)(!1),g=e=>e.includes("/")||"."===e||".."===e?"A name cannot contain a slash or be . or ..":null,x=(e,t)=>`${"/workspace"===e?"/workspace":e}/${t}`,v=(0,n.useCallback)(()=>{let e=a.find(e=>e.entry.path===s);return e?.entry.isDir?e.entry.path:e?r3(e.entry.path).parent:"/workspace"},[a,s]),y=(0,n.useCallback)(e=>{let t=v();p({kind:"create",parent:t,entryKind:e}),"/workspace"!==t&&r(t)},[v,r]),b=(0,n.useCallback)(()=>{let e=a.find(e=>e.entry.path===s);e&&p({kind:"rename",path:e.entry.path})},[a,s]),k=(0,n.useCallback)(()=>{if(!u||"create"!==u.kind)return 0;let e=a.find(e=>e.entry.path===u.parent);return e?e.depth+1:0},[u,a]),j=(0,n.useCallback)(async e=>{if(!u||"create"!==u.kind||!t)return;let n=e.trim();if(""===n)return void p(null);let a=g(n);if(a)return void d(a);let s=x(u.parent,n);if(!f.current){f.current=!0,m(!0);try{await r6(t,{path:s,kind:u.entryKind,content:""}),p(null),await o(u.parent),window.requestAnimationFrame(()=>l(s))}catch(e){d(e.message)}finally{f.current=!1,m(!1)}}},[u,t,o,l,d]),w=(0,n.useCallback)(async(e,n)=>{if(!t)return;let a=n.trim();if(""===a||a===e.name)return void p(null);let s=g(a);if(s)return void d(s);let i=r3(e.path).parent,r=x(i,a);if(!f.current){f.current=!0,m(!0);try{await r8(t,{from:e.path,to:r}),p(null),c(e.path),await o(i),window.requestAnimationFrame(()=>l(r))}catch(e){d(e.message)}finally{f.current=!1,m(!1)}}},[t,o,c,l,d]),N=(0,n.useCallback)(async()=>{if(!t)return;let e=a.find(e=>e.entry.path===i);if(!e)return;let{entry:n}=e;if(await rc({title:`Delete ${n.name}?`,description:n.isDir?"The directory and everything inside it is deleted. There is no trash.":"The file is deleted. There is no trash.",confirmLabel:"Delete",tone:"danger"})&&!f.current){f.current=!0,m(!0);try{await r9(t,n.path,{recursive:n.isDir}),c(n.path),await o(r3(n.path).parent)}catch(e){d(e.message)}finally{f.current=!1,m(!1)}}},[t,a,i,o,c,d]);return{pending:u,setPending:p,busy:h,beginCreate:y,beginRename:b,createDepth:k,submitCreate:j,submitRename:w,requestDelete:N}}({projectId:e,rows:$,focusedPath:N,menuPath:C?.path??null,expand:E,focusRow:e=>V(e),refreshDir:z,forgetDir:F,setError:h}),V=(0,n.useCallback)(e=>{_(e);let t=T.current;if(!t)return;let n=t.querySelector(`[data-path="${CSS.escape(e)}"]`);n?.focus()},[]),K=(0,n.useCallback)((e,t)=>{let n=$[e+t];n&&V(n.entry.path)},[$,V]),G=(0,n.useCallback)((e,t)=>{if(e.target!==e.currentTarget&&("Enter"===e.key||" "===e.key))return;let n=$[t];if(n)switch(e.key){case"ArrowDown":e.preventDefault(),K(t,1);break;case"ArrowUp":e.preventDefault(),K(t,-1);break;case"Home":e.preventDefault(),$[0]&&V($[0].entry.path);break;case"End":e.preventDefault(),$.length>0&&V($[$.length-1].entry.path);break;case"ArrowRight":if(e.preventDefault(),!n.entry.isDir||A)break;if(!v.has(n.entry.path)){E(n.entry.path);break}if(!j.has(n.entry.path))break;K(t,1);break;case"ArrowLeft":{if(e.preventDefault(),!A&&n.entry.isDir&&v.has(n.entry.path)){R(n.entry.path);break}let t=$.findIndex(e=>e.entry.path===n.parentPath);t>=0&&V($[t].entry.path);break}case"Enter":case" ":if(e.preventDefault(),n.entry.isDir){if(A)break;v.has(n.entry.path)?R(n.entry.path):E(n.entry.path)}else s(n.entry.path,n.entry.name);break;case"ContextMenu":let a;e.preventDefault(),S({path:n.entry.path,...{x:(a=e.currentTarget.getBoundingClientRect()).left+12,y:a.bottom}})}},[$,v,j,A,R,E,K,V,s]),J=null===N?-1:$.findIndex(e=>e.entry.path===N),Y=null!==N&&-1===J;(0,n.useEffect)(()=>{if(!Y)return;let e=window.setTimeout(()=>{let e=T.current?.contains(document.activeElement)??!1,t=$[0]?.entry.path;_(t??null),e&&t&&V(t)},0);return()=>window.clearTimeout(e)},[Y,$,V]);let Q=J>=0?J:0;return(0,t.jsxs)("div",{className:"file-tree-panel",children:[(0,t.jsxs)("div",{className:"file-tree-header",children:[(0,t.jsx)("div",{className:"file-tree-heading",children:"Files"}),(0,t.jsx)("div",{className:"file-tree-path",title:a??"/workspace",children:e?a??"/workspace":"No project selected"}),(0,t.jsxs)("div",{className:"file-tree-actions",children:[(0,t.jsx)("button",{type:"button",className:"file-tree-action","aria-label":"New file",title:"New file",disabled:!e,onClick:()=>O("file"),children:(0,t.jsx)(lD,{size:13,"aria-hidden":"true"})}),(0,t.jsx)("button",{type:"button",className:"file-tree-action","aria-label":"New folder",title:"New folder",disabled:!e,onClick:()=>O("directory"),children:(0,t.jsx)(d,{size:13,"aria-hidden":"true"})})]}),(0,t.jsxs)("label",{className:"file-filter",children:[(0,t.jsx)(u,{size:12,"aria-hidden":"true"}),(0,t.jsx)("span",{className:"sr-only",children:"Filter files"}),(0,t.jsx)("input",{value:g,onChange:e=>x(e.target.value),onKeyDown:e=>{"ArrowDown"===e.key&&0!==$.length&&(e.preventDefault(),V($[0].entry.path))},placeholder:"Filter files...",disabled:!e})]})]}),(0,t.jsx)("div",{className:"file-tree-list",ref:T,onScroll:()=>S(null),children:e?o?(0,t.jsx)("div",{className:"file-tree-state",children:"Loading..."}):p&&0===r.length?(0,t.jsx)("div",{className:"file-tree-state is-error",children:p}):0===$.length?(0,t.jsxs)(t.Fragment,{children:[p&&(0,t.jsx)("p",{className:"file-tree-inline-error",role:"alert",children:p}),(0,t.jsx)("div",{className:"file-tree-state",children:A?"No files match.":"No files found."})]}):(0,t.jsxs)(t.Fragment,{children:[p&&(0,t.jsx)("p",{className:"file-tree-inline-error",role:"alert",children:p}),(0,t.jsxs)("div",{role:"tree","aria-label":"Workspace files",children:[$.map((e,n)=>{let{entry:a,depth:r}=e,l=A?(j.get(a.path)?.length??0)>0:v.has(a.path);return L&&"rename"===L.kind&&L.path===a.path?(0,t.jsx)(lB,{depth:r,label:`Rename ${a.name}`,initialValue:a.name,onCommit:e=>void H(a,e),onCancel:()=>D(null)},"editor"):(0,t.jsx)(lq,{entry:a,depth:r,expanded:l,loading:b.has(a.path),errorText:m.get(a.path),tabbable:n===Q,selected:N===a.path,onClick:()=>{(_(a.path),a.isDir)?A||(l?R(a.path):E(a.path)):s(a.path,a.name)},onContextMenu:e=>{e.preventDefault(),V(a.path),S({path:a.path,x:e.clientX,y:e.clientY})},onKeyDown:e=>G(e,n),onPreview:()=>i(a.path,a.name)},a.path)}),L&&"create"===L.kind&&(0,t.jsx)(lB,{depth:B(),label:"directory"===L.entryKind?"New folder name":"New file name",initialValue:"",onCommit:e=>void U(e),onCancel:()=>D(null)},"creator")]})]}):(0,t.jsx)("div",{className:"file-tree-empty",children:"Select a project to browse files."})}),C&&(0,t.jsx)(lU,{entry:$.find(e=>e.entry.path===C.path)?.entry,at:C,onClose:()=>{let e=C.path;S(null),V(e)},onOpen:()=>{let e=$.find(e=>e.entry.path===C.path)?.entry;e&&!e.isDir&&s(e.path,e.name)},onPreview:()=>{let e=$.find(e=>e.entry.path===C.path)?.entry;e&&!e.isDir&&i(e.path,e.name)},onNewFile:()=>O("file"),onNewFolder:()=>O("directory"),onRename:()=>q(),onDelete:()=>void W(),onError:e=>h(e)})]})}function lW(e){return(0,t.jsx)(lH,{projectId:e.projectId,displayPath:e.displayPath,onOpenFile:e.onOpenFile,onPreviewFile:e.onPreviewFile},e.projectId??"no-project")}var lV=e.i(57840);function lK(e,t,n){if(!n)return"";let a=`${t}.${n}`,s=e(a);return s===a?n:s}function lG({sessionId:e}){let a=(0,f.useT)(),[s,i]=(0,n.useState)([]),[r,l]=(0,n.useState)({}),[o,c]=(0,n.useState)(null),[d,u]=(0,n.useState)(null),p=(0,n.useCallback)(async()=>{if(e)try{let t=await (0,e5.apiFetch)(`/v1/sessions/${encodeURIComponent(e)}/graph-runs`)??[];i(t),u(null),c(e=>{if(0===t.length)return null;let n=t[0].runId??null;if(null===n)return null;if(null===e||!t.some(t=>t.runId===e))return n;let a=t[0].createdAt,s=t.find(t=>t.runId===e)?.createdAt;return a&&s&&s<a?n:e})}catch(e){u(e.message)}},[e]);(0,n.useEffect)(()=>{let e,t=new AbortController,n=!1,a=async()=>{await p(),n||(e=window.setTimeout(a,1500))};return a(),()=>{n=!0,t.abort(),void 0!==e&&window.clearTimeout(e)}},[p]),(0,n.useEffect)(()=>{if(!e||!o)return;let t=!1;return(0,e5.apiFetch)(`/v1/sessions/${encodeURIComponent(e)}/graph-runs/${encodeURIComponent(o)}`).then(e=>{t||l(t=>({...t,[o]:e.nodes??[]}))}).catch(()=>{t||u("graph.loadFailed")}),()=>{t=!0}},[o,e]);let m=(0,n.useMemo)(()=>s.filter(e=>"running"===e.state).length,[s]);return(0,t.jsxs)("div",{className:lV.default.root,children:[(0,t.jsxs)("div",{className:lV.default.header,children:[(0,t.jsxs)("span",{className:lV.default.title,children:[(0,t.jsx)(h,{size:13,"aria-hidden":"true"}),a("graph.title")]}),m>0&&(0,t.jsx)("span",{className:lV.default.running,children:a("graph.running",{count:String(m)})})]}),d&&(0,t.jsx)("div",{className:lV.default.error,children:"graph.loadFailed"===d?a(d):d}),(0,t.jsx)("div",{className:lV.default.scroll,children:e?0===s.length?(0,t.jsx)("div",{className:lV.default.empty,children:a("graph.emptyRuns")}):s.map(e=>(0,t.jsx)(lJ,{run:e,nodes:r[e.runId??""]??[],expanded:o===e.runId,onToggle:()=>c(t=>t===e.runId?null:e.runId??null),nodesLoading:o===e.runId&&void 0===r[e.runId??""],t:a},e.runId)):(0,t.jsx)("div",{className:lV.default.empty,children:a("graph.emptySession")})})]})}function lJ({run:e,nodes:n,expanded:a,onToggle:s,nodesLoading:i,t:r}){let l=e.state,o=n.length,c=n.filter(e=>"completed"===e.terminalState).length,d=lK(r,"graph.flow",l);return(0,t.jsxs)("div",{className:lV.default.card,children:[(0,t.jsxs)("button",{type:"button",onClick:s,className:lV.default.cardButton,"data-expanded":a||void 0,"aria-expanded":a,children:[(0,t.jsx)(j,{size:11,className:lV.default.chevron,"data-expanded":a||void 0,"aria-hidden":"true"}),(0,t.jsx)("span",{className:`${lV.default.stateDot} ${lV.default.flowDot}`,"data-flow-state":l}),(0,t.jsx)("span",{className:lV.default.cardTitle,children:e.inputs?.name?String(e.inputs.name):r("graph.unnamed")}),(0,t.jsx)("span",{className:lV.default.cardSummary,children:o>0?r("graph.tasks",{done:String(c),total:String(o)}):d})]}),a&&(0,t.jsxs)("div",{className:lV.default.details,children:[(0,t.jsxs)("div",{className:lV.default.meta,children:[(0,t.jsx)("span",{children:r("graph.stateLabel",{state:d})}),e.totalTokensUsed?(0,t.jsx)("span",{children:r("graph.tokens",{count:String(e.totalTokensUsed)})}):null,e.createdAt?(0,t.jsx)("span",{children:function(e,t){let n=new Date(e);if(Number.isNaN(n.getTime()))return e;let a=Math.floor((new Date().getTime()-n.getTime())/6e4);return a<1?t("graph.justNow"):a<60?t("graph.minutesAgo",{count:String(a)}):n.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}(e.createdAt,r)}):null]}),i?(0,t.jsx)("div",{className:lV.default.stateLine,children:r("graph.loadingTasks")}):0===n.length?(0,t.jsx)("div",{className:lV.default.stateLine,children:r("graph.noTasks")}):(0,t.jsx)("ul",{className:lV.default.nodeList,children:n.map(e=>(0,t.jsxs)("li",{className:lV.default.nodeRow,children:[(0,t.jsx)("span",{className:lV.default.nodeDot,"data-node-state":e.terminalState}),(0,t.jsx)("span",{className:lV.default.nodeName,children:e.handle}),(0,t.jsx)("span",{className:lV.default.nodeState,children:lK(r,"graph.node",e.terminalState)})]},e.taskIndex??e.handle))})]})]})}function lY({sessionId:e}){return(0,t.jsx)(lG,{sessionId:e})}let lQ=o("file-clock",[["path",{d:"M16 22h2a2 2 0 0 0 2-2V8a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 14 2H6a2 2 0 0 0-2 2v2.85",key:"ryk6xj"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M8 14v2.2l1.6 1",key:"6m4bie"}],["circle",{cx:"8",cy:"16",r:"6",key:"10v15b"}]]);function lZ(e,t=""){return"string"==typeof e?e:t}function lX(e){let t=[];for(let n of e??[]){let e=n??{};switch(e.type){case"text":t.push({kind:"text",text:lZ(e.text)});break;case"thinking":t.push({kind:"thinking",text:lZ(e.text)});break;case"tool_call":{let n=e.toolCall??{},a=function(e){if(null!=e){if("object"!=typeof e)return String(e);try{return JSON.stringify(e,null,2)}catch{return}}}(n.arguments);t.push({kind:"tool_call",callId:lZ(n.id),name:lZ(n.name,"tool")||"tool",...void 0===a?{}:{arguments:a}});break}case"tool_result":{let n=e.toolResult??{};t.push({kind:"tool_result",callId:lZ(n.toolCallId),name:lZ(n.toolName,"tool")||"tool",text:lZ(n.content),isError:!0===n.isError});break}case"image":{let n=e.image??{};t.push({kind:"image",width:"number"==typeof n.width?n.width:0,height:"number"==typeof n.height?n.height:0});break}case"image_description":{let n=e.imageDescription??{};t.push({kind:"text",text:lZ(n.text)});break}default:t.push({kind:"unknown",type:lZ(e.type,"unknown")||"unknown"})}}return t}var l0=e.i(26694);let l1={base:"Platform",hero:"Hero",context:"Project context",skills_catalog:"Skill catalog",skill_preload:"Preloaded skill"},l2={system:"System",user:"User",assistant:"Assistant",tool:"Tool"};function l4({runId:e,composition:a,mcp:s,transcript:i,loading:r,error:l,t:o}){let[c,d]=(0,n.useState)(!1);if(!e)return(0,t.jsx)("div",{className:`${l0.default.empty} ${l0.default.muted}`,children:o("inspector.noRun")});if(r&&!a)return(0,t.jsx)("div",{className:`${l0.default.empty} ${l0.default.muted}`,children:o("inspector.loading")});if(l)return(0,t.jsx)("div",{className:`${l0.default.empty} ${l0.default.muted}`,children:l});if(!a)return(0,t.jsx)("div",{className:`${l0.default.empty} ${l0.default.muted}`,children:o("inspector.loading")});let u=a.sections??[],p=a.recorded,h=u.filter(e=>"skill_preload"===e.kind&&"user-skill-select"===e.source).map(e=>e.skillId||e.id.replace(/^skill\.preload\./,""));return(0,t.jsxs)("div",{className:l0.default.body,children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("div",{className:l0.default.heading,children:o("inspector.run")}),(0,t.jsx)("div",{className:`${l0.default.digest} ${l0.default.digestValue} ${l0.default.runId}`,title:e,children:e}),(0,t.jsx)("div",{className:l0.default.muted,children:p?o("inspector.frozen"):o("inspector.unrecorded")})]}),p&&(0,t.jsxs)("div",{children:[(0,t.jsxs)("div",{className:l0.default.heading,children:[o("inspector.composition"),(0,t.jsx)("span",{className:l0.default.headingCount,children:o("inspector.sections",{count:String(u.length)})})]}),h.length>0&&(0,t.jsxs)("div",{className:l0.default.selectedSkills,children:[(0,t.jsx)("span",{className:l0.default.muted,children:o("inspector.selectedSkills")}),h.map(e=>(0,t.jsx)("code",{children:`/${e}`},e))]}),(0,t.jsx)("div",{className:l0.default.group,children:u.map(e=>(0,t.jsx)(l5,{section:e},e.id))})]}),(0,t.jsxs)("div",{className:l0.default.digestGroup,children:[(0,t.jsx)(l9,{label:o("inspector.sectionsDigest"),value:a.sectionsDigest}),(0,t.jsx)(l9,{label:o("inspector.composedDigest"),value:a.composedDigest}),(0,t.jsx)(l9,{label:o("inspector.baseDigest"),value:a.digest}),""!==a.skillCatalogState&&(0,t.jsxs)("div",{className:l0.default.catalogRow,children:[(0,t.jsx)("span",{className:`${l0.default.muted} ${l0.default.catalogLabel}`,children:o("inspector.skillCatalog")}),(0,t.jsx)("span",{className:`${l0.default.muted} ${l0.default.catalogValue}`,children:o(`inspector.catalog.${a.skillCatalogState}`)}),""!==a.skillCatalogDigest&&(0,t.jsx)("span",{className:`${l0.default.digest} ${l0.default.digestValue}`,title:a.skillCatalogDigest,children:r_(a.skillCatalogDigest,8)})]})]}),p&&void 0!==s&&(0,t.jsxs)("div",{children:[(0,t.jsx)("div",{className:l0.default.heading,children:o("inspector.mcp")}),null===s||0===(s.servers??[]).length?(0,t.jsx)("div",{className:l0.default.muted,children:o("inspector.mcpNone")}):(0,t.jsx)("div",{className:l0.default.group,children:(s.servers??[]).map(e=>(0,t.jsx)(l3,{server:e,t:o},e.id))})]}),i?(0,t.jsxs)("div",{children:[(0,t.jsx)("div",{className:l0.default.heading,children:o("inspector.transcript")}),(0,t.jsx)("div",{className:`${l0.default.muted} ${l0.default.transcriptNote}`,children:o("inspector.transcriptNote")}),0===i.messages.length?(0,t.jsx)("div",{className:l0.default.muted,children:o("inspector.transcriptEmpty")}):(0,t.jsx)("div",{className:l0.default.group,children:i.messages.map(e=>(0,t.jsx)(l6,{message:e,t:o},e.id))}),i.hasMore&&(0,t.jsx)("button",{type:"button",className:l0.default.loadOlder,disabled:i.loadingOlder,onClick:i.loadOlder,children:o("inspector.transcriptOlder")})]}):null,p&&(0,t.jsxs)("div",{children:[(0,t.jsxs)("button",{type:"button",className:l0.default.promptToggle,onClick:()=>d(e=>!e),"aria-expanded":c,children:[c?(0,t.jsx)(q,{size:13,"aria-hidden":"true"}):(0,t.jsx)(j,{size:13,"aria-hidden":"true"}),(0,t.jsx)(lQ,{size:13,"aria-hidden":"true"}),o("inspector.prompt"),(0,t.jsx)("span",{className:l0.default.promptBytes,children:rC(a.prompt.length)})]}),c&&(0,t.jsx)("pre",{"data-run-prompt":!0,className:l0.default.promptPre,children:a.prompt})]})]})}function l5({section:e}){return(0,t.jsxs)("div",{"data-prompt-section":e.kind,className:l0.default.sectionRow,children:[(0,t.jsx)("span",{className:l0.default.sectionKind,children:l1[e.kind]??e.kind}),(0,t.jsxs)("span",{className:l0.default.sectionIdentity,children:[(0,t.jsx)("span",{className:l0.default.sectionId,children:e.id}),(0,t.jsx)("span",{className:l0.default.sectionSource,children:` \xb7 ${e.source}`})]}),(0,t.jsx)("span",{className:l0.default.sectionBytes,children:rC(e.bytes)}),(0,t.jsx)("span",{className:`${l0.default.digest} ${l0.default.sectionDigest}`,title:e.digest,children:r_(e.digest,8)})]})}function l3({server:e,t:n}){let a=""!==e.unavailableReason;return(0,t.jsxs)("div",{"data-mcp-server":e.bindingId,"data-unavailable":a||void 0,className:l0.default.mcpRow,children:[(0,t.jsxs)("div",{className:l0.default.mcpHead,children:[(0,t.jsxs)("span",{className:l0.default.mcpIdentity,children:[(0,t.jsx)("span",{className:l0.default.mcpBinding,children:e.bindingId}),(0,t.jsx)("span",{className:l0.default.mcpRevision,children:` \xb7 rev ${e.bindingRevision}`})]}),e.required&&(0,t.jsx)("span",{className:l0.default.badge,children:n("inspector.mcpRequired")}),(0,t.jsx)("span",{className:l0.default.mcpTools,children:n("inspector.mcpTools",{count:String((e.tools??[]).length)})})]}),a&&(0,t.jsx)("div",{className:l0.default.mcpUnavailable,children:`${n("inspector.mcpUnavailable")}: ${e.unavailableReason}`}),""!==e.negotiatedProtocol&&(0,t.jsx)("div",{className:`${l0.default.muted} ${l0.default.mcpProtocol}`,children:`${n("inspector.mcpProtocol")}: ${e.negotiatedProtocol}`}),""!==e.instructions&&(0,t.jsxs)("details",{className:l0.default.mcpInstructions,children:[(0,t.jsx)("summary",{className:l0.default.muted,title:e.instructionsDigest,children:n("inspector.mcpInstructions")}),(0,t.jsx)("div",{className:l0.default.mcpInstructionsBody,"data-mcp-instructions":!0,children:e.instructions})]}),(e.tools??[]).length>0&&(0,t.jsx)("div",{className:l0.default.toolList,children:(e.tools??[]).map(e=>(0,t.jsxs)("div",{className:l0.default.toolRow,children:[(0,t.jsx)("span",{className:`${l0.default.digest} ${l0.default.toolName}`,title:e.exposedName,children:e.exposedName}),(0,t.jsx)("span",{className:l0.default.toolRisk,children:e.riskClass})]},e.exposedName))})]})}function l6({message:e,t:n}){let a=lX(e.content),s=function(e){let t=new Set,n=[];for(let a of lX(e))"tool_call"!==a.kind||t.has(a.name)||(t.add(a.name),n.push(a.name));return n.join(", ")}(e.content);return(0,t.jsxs)("details",{"data-transcript-ordinal":e.ordinal,className:l0.default.transcriptRow,children:[(0,t.jsxs)("summary",{className:l0.default.transcriptSummary,children:[(0,t.jsx)("span",{className:`${l0.default.muted} ${l0.default.transcriptOrdinal}`,children:e.ordinal}),(0,t.jsx)("span",{className:l0.default.transcriptRole,children:l2[e.role]??e.role}),"private"===e.visibility&&(0,t.jsx)("span",{"data-transcript-private":!0,className:l0.default.privateBadge,children:n("inspector.transcriptPrivate")}),(0,t.jsx)("span",{className:l0.default.transcriptExcerpt,children:s})]}),(0,t.jsx)("div",{className:l0.default.transcriptBody,children:a.map((e,a)=>(0,t.jsx)(l8,{entry:e,t:n},a))})]})}function l8({entry:e,t:n}){return"text"===e.kind?(0,t.jsx)("div",{className:l0.default.entryPre,children:e.text}):"thinking"===e.kind?(0,t.jsxs)("div",{children:[(0,t.jsx)("div",{className:`${l0.default.muted} ${l0.default.entryLabel}`,children:n("inspector.transcriptThinking")}),(0,t.jsx)("div",{className:l0.default.entryPre,children:e.text})]}):"image"===e.kind?(0,t.jsx)("div",{className:l0.default.muted,children:n("inspector.transcriptImage",{width:String(e.width),height:String(e.height)})}):"unknown"===e.kind?(0,t.jsx)("div",{className:l0.default.muted,children:n("inspector.transcriptUnknown",{type:e.type})}):"tool_call"===e.kind?(0,t.jsxs)("details",{children:[(0,t.jsx)("summary",{className:`${l0.default.muted} ${l0.default.entrySummary}`,children:`${n("inspector.transcriptCall")} ${e.name}`}),void 0!==e.arguments&&(0,t.jsx)("div",{className:`${l0.default.entryPre} ${l0.default.entryBlock}`,children:e.arguments})]}):(0,t.jsxs)("details",{children:[(0,t.jsx)("summary",{className:`${l0.default.muted} ${l0.default.entrySummary}`,"data-error":e.isError||void 0,children:`${n(e.isError?"inspector.transcriptError":"inspector.transcriptResult")} ${e.name}`}),(0,t.jsx)("div",{className:`${l0.default.entryPre} ${l0.default.entryBlock}`,children:e.text})]})}function l9({label:e,value:n}){return n?(0,t.jsxs)("div",{className:l0.default.digestLine,children:[(0,t.jsx)("span",{className:`${l0.default.muted} ${l0.default.digestLabel}`,children:e}),(0,t.jsx)("span",{className:`${l0.default.digest} ${l0.default.digestValue}`,title:n,children:n})]}):null}function l7({runId:e,composition:n,mcp:a,transcript:s,loading:i,error:r}){let l=(0,f.useT)();return(0,t.jsx)(l4,{runId:e,composition:n,mcp:a,transcript:s,loading:i,error:r,t:l})}function oe(e){let{runId:a,selectedSession:s,sessionTitle:i,activeRun:r,status:l,permissionMode:o}=e,c=function(e){let[t,a]=(0,n.useState)(null),[s,i]=(0,n.useState)(!1),[r,l]=(0,n.useState)(null);return(0,n.useEffect)(()=>{if(!e){let e=window.setTimeout(()=>{a(null),l(null),i(!1)},0);return()=>window.clearTimeout(e)}let t=new AbortController,n=window.setTimeout(()=>{i(!0),(0,e5.apiFetch)(`/v1/runs/${encodeURIComponent(e)}/prompt`,{signal:t.signal}).then(e=>{t.signal.aborted||(a(e),l(null))}).catch(e=>{t.signal.aborted||(a(null),l(e instanceof Error?e.message:"Failed to load the run prompt"))}).finally(()=>{t.signal.aborted||i(!1)})},0);return()=>{window.clearTimeout(n),t.abort()}},[e]),{composition:t,loading:s,error:r}}(a),d=function(e){let[t,a]=(0,n.useState)(null),[s,i]=(0,n.useState)(!1),[r,l]=(0,n.useState)(null);return(0,n.useEffect)(()=>{if(!e){let e=window.setTimeout(()=>{a(null),l(null),i(!1)},0);return()=>window.clearTimeout(e)}let t=new AbortController,n=window.setTimeout(()=>{i(!0),(0,e5.apiFetch)(`/v1/runs/${encodeURIComponent(e)}/mcp`,{signal:t.signal}).then(e=>{t.signal.aborted||(a(e),l(null))}).catch(e=>{t.signal.aborted||(a(null),l(e instanceof Error?e.message:"Failed to load the run MCP surface"))}).finally(()=>{t.signal.aborted||i(!1)})},0);return()=>{window.clearTimeout(n),t.abort()}},[e]),{frozen:t,loading:s,error:r}}(a),u=function(e){let[t,a]=(0,n.useState)([]),[s,i]=(0,n.useState)(null),[r,l]=(0,n.useState)(!1),[o,c]=(0,n.useState)(!1),[d,u]=(0,n.useState)(null);(0,n.useEffect)(()=>{if(!e){let e=window.setTimeout(()=>{a([]),i(null),u(null),l(!1)},0);return()=>window.clearTimeout(e)}let t=new AbortController,n=window.setTimeout(()=>{l(!0),(0,e5.apiFetch)(`/v1/runs/${encodeURIComponent(e)}/messages?limit=200`,{signal:t.signal}).then(e=>{t.signal.aborted||(a(e.messages??[]),i(e.hasMore?e.nextBeforeOrdinal??null:null),u(null))}).catch(e=>{t.signal.aborted||(a([]),i(null),u(e instanceof Error?e.message:"Failed to load the run transcript"))}).finally(()=>{t.signal.aborted||l(!1)})},0);return()=>{window.clearTimeout(n),t.abort()}},[e]);let p=(0,n.useCallback)(()=>{e&&null!==s&&(c(!0),(0,e5.apiFetch)(`/v1/runs/${encodeURIComponent(e)}/messages?limit=200&beforeOrdinal=${s}`).then(e=>{a(t=>{let n=new Set(t.map(e=>e.ordinal));return[...(e.messages??[]).filter(e=>!n.has(e.ordinal)),...t]}),i(e.hasMore?e.nextBeforeOrdinal??null:null),u(null)}).catch(e=>{u(e instanceof Error?e.message:"Failed to load older transcript messages")}).finally(()=>c(!1)))},[e,s]);return{messages:t,hasMore:null!==s,loading:r,loadingOlder:o,error:d,loadOlder:p}}(a);return(0,t.jsxs)("div",{className:"right-panel-tools",children:[(0,t.jsx)(l7,{runId:a,composition:c.composition,mcp:d.frozen,transcript:u,loading:c.loading,error:c.error}),(0,t.jsx)(ot,{selectedSession:s,sessionTitle:i,activeRun:r,status:l,permissionMode:o})]})}function ot({selectedSession:e,sessionTitle:n,activeRun:a,status:s,permissionMode:i}){let r=(0,f.useT)();return(0,t.jsx)("div",{className:"right-panel-summary",children:e?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{children:["Session: ",n]}),(0,t.jsxs)("div",{children:["Active run: ",a||"none"]}),(0,t.jsxs)("div",{children:["Status: ",s?iS(s,r):"idle"]}),(0,t.jsxs)("div",{children:["Permission: ",i]})]}):(0,t.jsx)("div",{children:"No session selected"})})}let on=["files","graph","tools"];function oa(e){return"string"==typeof e&&on.includes(e)}function os(e){return`ennote:right-panel:v1:${e}`}function oi(e){return{version:1,projectId:e,pinnedChannels:[],primaryWidth:280,open:!1,inspectorTabs:[],activeInspectorId:null,navigatorHidden:!1}}function or(e){return on.filter(t=>e.includes(t))}function ol(e){if(!Array.isArray(e))return[];let t=[],n=new Set;for(let a of e){if("object"==typeof a&&null!==a)"string"==typeof a.path&&0!==a.path.length&&(n.has(a.path)||(n.add(a.path),t.push({path:a.path,name:"string"==typeof a.name&&a.name.length>0?a.name:function(e){let t=e.split("/").filter(Boolean);return t[t.length-1]??e}(a.path)})))}return t.slice(-20)}function oo(e){let t=or(e.pinnedChannels),n=t.length>0?or(t):[...on];return{projectId:e.projectId,openChannels:n,pinnedChannels:t,activeChannelId:n[0]??null,open:e.open,primaryWidth:e.primaryWidth,navigatorHidden:!0===e.navigatorHidden,activeInspectorId:e.activeInspectorId??null,activeLane:e.activeInspectorId?"inspector":"channel",inspectorTabs:ol(e.inspectorTabs)}}function oc(e){let t=e.split(":");return t.length<3?e:t.slice(2).join(":")}function od(e,t){return`file:${e}:${t}`}function ou(e,t){let n=e.openChannels.includes(t)?e.openChannels:[...e.openChannels,t];return{...e,openChannels:n,activeChannelId:t,activeLane:"channel",open:!0}}function op(e,t,n){let a=ol([...e.inspectorTabs.filter(e=>e.path!==n.path),n]);return{...e,inspectorTabs:a,activeInspectorId:t,activeLane:"inspector",open:!0}}function oh(e){let{open:a,onClose:s,resize:i,panel:r,projectId:l,displayPath:o,onOpenFile:c,onPreviewFile:d,selectedSession:u,sessionTitle:p,activeRun:h,inspectorRunId:m,status:g,permissionMode:x}=e,v=(0,f.useT)(),{state:y,fileTabs:b}=r,k=lI("(max-width: 960px)"),j="medium"===lM(i.width,k),[w,N]=(0,n.useState)(!1),_=j?w:!y.navigatorHidden,C=y.openChannels,I=r.activeChannelId,P=e=>v("rightPanel.close",{name:e.label}),T=e=>{oa(e)?r.closeChannelTab(e):r.closeTab(e)},M=e=>{r.setActiveTabId(e),j&&N(!1),y.navigatorHidden&&"files"!==e&&r.toggleNavigator()},R=(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("div",{className:"right-panel-channel-slot",hidden:"files"!==I,children:(0,t.jsx)(lW,{projectId:l,displayPath:o,onOpenFile:(e,t)=>{c(e,t),j&&N(!1)},onPreviewFile:d})}),"graph"===I&&(0,t.jsx)(lY,{sessionId:u}),"tools"===I&&(0,t.jsx)(oe,{runId:m,selectedSession:u,sessionTitle:p,activeRun:h,status:g,permissionMode:x}),null===I&&(0,t.jsx)(lL,{channels:on,hint:v("rightPanel.launcherHint"),t:v,onOpen:r.openChannel})]}),E=b.find(e=>e.id===y.activeInspectorId),A=E?.projectId===l&&E.filePath?(0,t.jsx)(ln,{projectId:E.projectId,filePath:E.filePath,fileName:E.label}):null;return(0,t.jsxs)("div",{className:`right-panel-container${a?" right-panel-open":" right-panel-closed"}`,style:{width:i.width,minWidth:i.width,transition:i.isResizing?"none":void 0},children:[(0,t.jsxs)("button",{type:"button",className:"right-panel-back-button",onClick:()=>{N(!1),s()},children:[(0,t.jsx)(rZ,{size:15,"aria-hidden":"true"}),"Back to conversation"]}),(0,t.jsx)(lE,{width:i.width,channelStrip:(0,t.jsxs)("div",{className:"right-panel-strip",children:[(0,t.jsx)(l_,{tabs:lz(C,v),activeTabId:I??"",onSelectTab:M,onCloseTab:T,closeLabel:P}),null!==I&&(0,t.jsx)("button",{type:"button",className:"right-panel-strip-action","aria-pressed":y.pinnedChannels.includes(I),"aria-label":y.pinnedChannels.includes(I)?v("rightPanel.unpin"):v("rightPanel.pin"),title:y.pinnedChannels.includes(I)?v("rightPanel.unpin"):v("rightPanel.pin"),onClick:()=>r.togglePin(I),children:y.pinnedChannels.includes(I)?(0,t.jsx)(rX,{size:13,"aria-hidden":"true"}):(0,t.jsx)(r0,{size:13,"aria-hidden":"true"})}),C.length<on.length&&(0,t.jsx)("button",{type:"button",className:"right-panel-strip-action","aria-label":v("rightPanel.add"),title:v("rightPanel.add"),onClick:()=>{let e=on.find(e=>!C.includes(e));e&&r.openChannel(e)},children:(0,t.jsx)(S,{size:13,"aria-hidden":"true"})})]}),channelBody:R,inspectorStrip:b.length>0?(0,t.jsx)(l_,{tabs:b,activeTabId:y.activeInspectorId??"",onSelectTab:M,onCloseTab:r.closeTab,onReorder:r.reorderTabs,closeLabel:P}):null,inspectorBody:A,narrowStrip:(0,t.jsx)("div",{className:"right-panel-strip",children:(0,t.jsx)(l_,{tabs:[...lz(C,v),...b],activeTabId:r.activeTabId,onSelectTab:M,onCloseTab:T,onReorder:r.reorderTabs,closeLabel:P})}),narrowBody:(0,t.jsx)("div",{className:"right-panel-body",children:r.activeTabId===y.activeInspectorId&&A?A:R}),primaryWidth:y.primaryWidth,onResizePrimary:e=>r.resizePrimaryBy(e,i.width),onResizePrimaryStart:r.beginPrimaryResize,onResizePrimaryEnd:r.endPrimaryResize,navigatorOpen:_&&a,primaryHidden:!_&&"files"===I,onToggleNavigator:()=>j?N(e=>!e):r.toggleNavigator()})]})}function om({resize:e}){return(0,t.jsx)(lS,{side:"left",ariaLabel:"Resize right panel",value:e.width,min:280,max:e.maxWidth,onResizeStart:e.beginResize,onResize:e.resizeBy,onResizeEnd:e.endResize})}function of({projectId:e,filePath:a,fileName:s,onClose:i}){let[r,l]=(0,n.useState)(()=>og()),o=(0,n.useRef)(null),c=(0,n.useRef)(null);M(!0,i);let d=(0,n.useCallback)((e,t)=>{0!==t.button||r.maximized||(t.preventDefault(),c.current={kind:e,x:t.clientX,y:t.clientY,bounds:r},t.currentTarget.setPointerCapture(t.pointerId))},[r]),u=(0,n.useCallback)(e=>{let t=c.current;if(!t)return;e.preventDefault();let n=e.clientX-t.x,a=e.clientY-t.y,s=window.innerWidth,i=window.innerHeight;"move"===t.kind?l({...t.bounds,x:ox(t.bounds.x+n,0,Math.max(0,s-160)),y:ox(t.bounds.y+a,0,Math.max(0,i-44))}):l({...t.bounds,width:ox(t.bounds.width+n,360,Math.max(360,s-t.bounds.x)),height:ox(t.bounds.height+a,260,Math.max(260,i-t.bounds.y))})},[]),p=(0,n.useCallback)(e=>{c.current=null,e.currentTarget.hasPointerCapture(e.pointerId)&&e.currentTarget.releasePointerCapture(e.pointerId)},[]),h=(0,n.useCallback)(()=>{l(e=>e.maximized?o.current??og():(o.current=e,{x:12,y:12,width:window.innerWidth-24,height:window.innerHeight-24,maximized:!0}))},[]);return(0,t.jsxs)("section",{className:`file-preview-window${r.maximized?" is-maximized":""}`,role:"dialog","aria-label":`Preview ${s}`,style:{left:r.x,top:r.y,width:r.width,height:r.height},children:[(0,t.jsxs)("header",{className:"file-preview-titlebar",onDoubleClick:h,onPointerDown:e=>d("move",e),onPointerMove:u,onPointerUp:p,onPointerCancel:p,children:[(0,t.jsx)("span",{title:a,children:s}),(0,t.jsxs)("div",{className:"file-preview-window-actions",onPointerDown:e=>e.stopPropagation(),children:[(0,t.jsx)("button",{type:"button",onClick:h,"aria-label":r.maximized?"Restore preview":"Maximize preview",title:r.maximized?"Restore preview":"Maximize preview",children:r.maximized?(0,t.jsx)(eD,{size:14}):(0,t.jsx)(lO,{size:14})}),(0,t.jsx)("button",{type:"button",onClick:i,"aria-label":"Close preview",title:"Close preview",children:(0,t.jsx)(m,{size:15})})]})]}),(0,t.jsx)("div",{className:"file-preview-content",children:(0,t.jsx)(ln,{projectId:e,filePath:a,fileName:s})}),!r.maximized&&(0,t.jsx)("div",{className:"file-preview-resize",role:"separator","aria-label":"Resize preview",onPointerDown:e=>d("resize",e),onPointerMove:u,onPointerUp:p,onPointerCancel:p})]})}function og(){let e=window.innerWidth,t=window.innerHeight,n=Math.min(760,Math.max(360,e-48)),a=Math.min(600,Math.max(260,t-72));return{x:Math.max(12,Math.round((e-n)/2)),y:Math.max(12,Math.round((t-a)/2)),width:n,height:a,maximized:!1}}function ox(e,t,n){return Math.min(n,Math.max(t,e))}function ov(e){return e.replace(/[\\/]+$/,"").split(/[\\/]/).at(-1)||e}function oy({listing:e,selectedPath:n,showHidden:a,disabled:s,onSelect:i}){let r=a?e.entries:e.entries.filter(e=>!e.hidden||e.path===n);return(0,t.jsx)("div",{className:"project-picker-column",role:"list",children:r.map(e=>{let a=e.path===n;return(0,t.jsx)("span",{role:"listitem",className:"project-picker-row-seat",children:(0,t.jsxs)("button",{type:"button",className:`project-picker-row${a?" selected":""}`,"aria-current":a||void 0,disabled:s,onClick:()=>i(e),children:[a?(0,t.jsx)(N,{size:16,className:"project-picker-folder selected","aria-hidden":"true"}):(0,t.jsx)(w,{size:16,className:"project-picker-folder","aria-hidden":"true"}),(0,t.jsx)("span",{children:e.name}),(0,t.jsx)(j,{size:12,className:"project-picker-row-chevron","aria-hidden":"true"})]})},e.path)})})}function ob({busy:e,onCreate:a,onClose:s}){let i=(0,f.useT)(),[r,l]=(0,n.useState)(null),[o,c]=(0,n.useState)(null),[d,u]=(0,n.useState)(null),[p,h]=(0,n.useState)(!0),[m,g]=(0,n.useState)(null),[x,v]=(0,n.useState)(null),[y,b]=(0,n.useState)(!1),[k,w]=(0,n.useState)(null),[N,_]=(0,n.useState)(!1),[C,I]=(0,n.useState)(null),P=(0,n.useRef)(0),T=(0,n.useRef)(null),R=(0,n.useCallback)(async e=>{let t=e?`?${new URLSearchParams({path:e})}`:"";return(0,e5.apiFetch)(`/v1/host/directories${t}`)},[]),E=(0,n.useCallback)(async e=>{let t=++P.current;h(!0),g(null);try{let n=await R(e);if(t!==P.current)return;l(n),c(null),u(null),v(null)}catch(e){t===P.current&&g(e.message)}finally{t===P.current&&h(!1)}},[R]);(0,n.useEffect)(()=>{let e=++P.current;return R().then(t=>{e===P.current&&(l(t),h(!1))},t=>{e===P.current&&(g(t.message),h(!1))}),()=>{P.current+=1}},[R]),(0,n.useEffect)(()=>{null!==x&&T.current?.focus()},[x]);let A=(0,n.useCallback)(async e=>{let t=++P.current;c(e),u(null),h(!0),g(null);try{let n=await R(e.path);t===P.current&&u(n)}catch(e){t===P.current&&(c(null),g(e.message))}finally{t===P.current&&h(!1)}},[R]),$=(0,n.useCallback)(e=>{d&&(l(d),A(e))},[d,A]),z=o?.path??r?.path??null,F=z?ov(z):"",L=(0,n.useMemo)(()=>{var e;let t;return r?(e=i("directory.home"),(t=r.crumbs.findIndex(e=>e.path===r.home))<0?r.crumbs:[{name:e,path:r.home,hidden:!1},...r.crumbs.slice(t+1)]):[]},[r,i]),D=r?.roots??[],O=r&&r.home.includes("\\")?"\\":"/",q=e||N;M(!0,()=>{if(!q){if(null!==k)return void w(null);if(null!==x)return void v(null);s()}});let B=async()=>{if(z&&null!==k&&k.trim()&&!N){_(!0),I(null);try{let e=await (0,e5.apiFetch)("/v1/host/directories",{method:"POST",body:JSON.stringify({path:z,name:k})});if(w(null),o&&d){let t=await R(o.path);l(t);let n=t.entries.find(t=>t.path===e.path);n&&await A(n)}else{let t=await R(r?.path);l(t);let n=t.entries.find(t=>t.path===e.path);n&&A(n)}}catch(e){I(e.message)}finally{_(!1)}}},U=async()=>{if(z&&!e&&!p&&null===x){g(null);try{await a(F,z)}catch(e){g(e.message)}}};return(0,t.jsxs)("div",{className:"project-picker-overlay",onPointerDown:e=>{e.target!==e.currentTarget||q||null!==k||s()},children:[(0,t.jsxs)("div",{className:"project-picker-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"project-picker-title",children:[(0,t.jsxs)("header",{className:"project-picker-header",children:[(0,t.jsx)("h2",{id:"project-picker-title",children:i("directory.title")}),(0,t.jsx)("div",{className:`project-picker-crumb-bar${null!==x?" editing":""}`,children:null===x?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("nav",{className:"project-picker-crumbs","aria-label":i("directory.path"),children:L.map((e,n)=>(0,t.jsxs)("span",{children:[n>0&&(0,t.jsx)(j,{size:12,"aria-hidden":"true"}),(0,t.jsx)("button",{type:"button",disabled:q,onClick:()=>void E(e.path),children:e.name})]},e.path))}),(0,t.jsx)("button",{type:"button",className:"project-picker-edit-path","aria-label":i("directory.editPath"),title:i("directory.editPath"),disabled:q,onClick:()=>{if(!r||q)return;let e=o?.path??r.path;v(e.endsWith(O)?e:`${e}${O}`)},children:(0,t.jsx)(iP,{size:14,"aria-hidden":"true"})})]}):(0,t.jsx)("input",{ref:T,value:x,"aria-label":i("directory.editPath"),disabled:q,onChange:e=>v(e.target.value),onKeyDown:e=>{"Enter"===e.key&&x.trim()&&E(x),"Escape"!==e.key||e.nativeEvent.isComposing||(e.stopPropagation(),v(null))}})}),D.length>1&&(0,t.jsx)("nav",{className:"project-picker-roots","aria-label":i("directory.roots"),children:D.map(e=>{var n,a;return(0,t.jsx)("button",{type:"button",className:`project-picker-root${(n=r?.path??null,n&&(n===e||n.startsWith(e.endsWith(O)?e:`${e}${O}`)))?" active":""}`,title:e,disabled:q,onClick:()=>void E(e),children:(a=i("directory.home"),e===(r?.home??"")?a:ov(e))},e)})})]}),(0,t.jsxs)("main",{className:"project-picker-content",children:[(0,t.jsxs)("div",{className:"project-picker-miller-row",children:[r&&(0,t.jsx)(oy,{listing:r,selectedPath:o?.path??null,showHidden:y,disabled:q,onSelect:e=>void A(e)}),o&&(0,t.jsx)("span",{className:"project-picker-divider"}),o&&d&&(0,t.jsx)(oy,{listing:d,selectedPath:null,showHidden:y,disabled:q,onSelect:$})]}),p&&(0,t.jsx)("div",{className:"project-picker-loading",role:"status",children:i("directory.loading")}),(r?.truncated||d?.truncated)&&(0,t.jsx)("div",{className:"project-picker-status",children:i("directory.truncated")}),m&&(0,t.jsx)("div",{className:"project-picker-error",role:"alert",children:m})]}),(0,t.jsxs)("footer",{className:"project-picker-footer",children:[(0,t.jsxs)("button",{type:"button",className:"project-picker-button outline new-folder",disabled:!r||p||q||null!==x,onClick:()=>{w(""),I(null)},children:[(0,t.jsx)(S,{size:14,"aria-hidden":"true"})," ",i("directory.newFolder")]}),(0,t.jsxs)("button",{type:"button",className:`project-picker-show-hidden${y?" active":""}`,"aria-pressed":y,disabled:q,onClick:()=>b(e=>!e),children:[i("directory.showHidden"),y&&(0,t.jsx)(Y,{size:14,"aria-hidden":"true"})]}),(0,t.jsx)("span",{className:"project-picker-footer-gap"}),(0,t.jsx)("button",{type:"button",className:"project-picker-button outline",disabled:q,onClick:s,children:i("directory.cancel")}),(0,t.jsx)("button",{type:"button",className:"project-picker-button primary",disabled:!z||p||q||null!==x,onClick:()=>void U(),children:e?i("directory.opening"):i("directory.open")})]})]}),null!==k&&(0,t.jsx)("div",{className:"project-picker-nested-overlay",onPointerDown:e=>{e.target!==e.currentTarget||N||w(null)},children:(0,t.jsxs)("div",{className:"project-picker-create-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"project-folder-title",children:[(0,t.jsx)("h3",{id:"project-folder-title",children:i("directory.newFolder")}),(0,t.jsx)("p",{children:i("directory.createIn",{name:F})}),(0,t.jsx)("input",{value:k,"aria-label":i("directory.folderName"),placeholder:i("directory.untitledFolder"),autoFocus:!0,disabled:N,onChange:e=>w(e.target.value),onKeyDown:e=>{"Enter"===e.key&&B(),"Escape"!==e.key||N||e.nativeEvent.isComposing||(e.stopPropagation(),w(null))}}),C&&(0,t.jsx)("div",{className:"project-picker-error",role:"alert",children:C}),(0,t.jsxs)("div",{className:"project-picker-create-actions",children:[(0,t.jsx)("button",{type:"button",className:"project-picker-button outline",disabled:N,onClick:()=>w(null),children:i("directory.cancel")}),(0,t.jsx)("button",{type:"button",className:"project-picker-button primary",disabled:N||!k.trim(),onClick:()=>void B(),children:i("directory.create")})]})]})})]})}let ok=o("database",[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]]),oj=o("layers",[["path",{d:"M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z",key:"zw3jo"}],["path",{d:"M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12",key:"1wduqc"}],["path",{d:"M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17",key:"kqbvx6"}]]),ow=o("package",[["path",{d:"M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z",key:"1a0edw"}],["path",{d:"M12 22V12",key:"d0xqtd"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}]]),oN=o("plug",[["path",{d:"M12 22v-5",key:"1ega77"}],["path",{d:"M15 8V2",key:"18g5xt"}],["path",{d:"M17 8a1 1 0 0 1 1 1v4a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1z",key:"1xoxul"}],["path",{d:"M9 8V2",key:"14iosj"}]]),o_=o("shield",[["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"}]]),oC={state:"idle"},oS=(0,n.createContext)({status:oC,markSaving:()=>{},markSaved:()=>{},markError:()=>{}});function oI({children:e}){let[a,s]=(0,n.useState)(oC),i=(0,n.useRef)(void 0),r=(0,n.useCallback)(()=>{void 0!==i.current&&(window.clearTimeout(i.current),i.current=void 0)},[]),l=(0,n.useCallback)(()=>{r(),s({state:"saving"})},[r]),o=(0,n.useCallback)(()=>{r(),s({state:"saved"}),i.current=window.setTimeout(()=>{i.current=void 0,s(oC)},2400)},[r]),c=(0,n.useCallback)(e=>{r(),s({state:"error",message:e})},[r]);(0,n.useEffect)(()=>r,[r]);let d=(0,n.useMemo)(()=>({status:a,markSaving:l,markSaved:o,markError:c}),[a,l,o,c]);return(0,t.jsx)(oS.Provider,{value:d,children:e})}function oP(){return(0,n.useContext)(oS)}function oT(){let{status:e}=oP(),n=(0,f.useT)();if("idle"===e.state)return null;let a=n("saving"===e.state?"settings.status.saving":"saved"===e.state?"settings.status.saved":"settings.status.failed"),s="saving"===e.state?(0,t.jsx)(eQ,{size:13,className:"spin","aria-hidden":"true"}):"saved"===e.state?(0,t.jsx)(Y,{size:13,"aria-hidden":"true"}):(0,t.jsx)(eX,{size:13,"aria-hidden":"true"});return(0,t.jsxs)("span",{className:"settings-save-status","data-state":e.state,role:"status","aria-live":"polite",title:e.message,children:[s,(0,t.jsx)("span",{children:a})]})}function oM(...e){return e.filter(Boolean).join(" ")}function oR({title:e,description:a,actions:s,className:i,children:r}){let l=(0,n.useId)();return(0,t.jsxs)("section",{className:oM("settings-section",i),"aria-labelledby":e?l:void 0,children:[(e||a||s)&&(0,t.jsxs)("div",{className:"settings-section-header",children:[(0,t.jsxs)("div",{children:[e&&(0,t.jsx)("h3",{id:l,children:e}),a&&(0,t.jsx)("p",{children:a})]}),s&&(0,t.jsx)("div",{className:"settings-section-actions",children:s})]}),r]})}function oE({title:e,meta:n,actions:a,children:s,className:i}){return(0,t.jsxs)("div",{className:oM("settings-row",i),children:[(0,t.jsxs)("div",{className:"settings-row-copy",children:[(0,t.jsx)("strong",{children:e}),n&&(0,t.jsx)("span",{children:n})]}),s,a&&(0,t.jsx)("div",{className:"settings-row-actions",children:a})]})}function oA({children:e,className:n}){return(0,t.jsx)("div",{className:oM("settings-list",n),children:e})}function o$({policies:e,models:n,session:a,refresh:s,setError:i,onSessionUpdated:r}){let{markSaving:l,markSaved:o}=oP();async function c(e,t){l();try{await (0,e5.apiFetch)("/v1/policy-profiles",{method:"POST",body:JSON.stringify({name:e,kind:"compaction",config:t})}),i(null),await s(),o()}catch(e){i(e.message)}}async function d(e){l();try{await (0,e5.apiFetch)(`/v1/policy-profiles/${encodeURIComponent(e)}/default`,{method:"PUT"}),i(null),await s(),o()}catch(e){i(e.message)}}async function u(e){if(a){l();try{let t=await (0,e5.apiFetch)(`/v1/sessions/${encodeURIComponent(a.id)}`,{method:"PATCH",body:JSON.stringify(e)});r(t),i(null),o()}catch(e){i(e.message)}}}return(0,t.jsxs)("section",{className:"settings-tab-section","aria-labelledby":"settings-context-heading",children:[(0,t.jsxs)("header",{children:[(0,t.jsx)("h2",{id:"settings-context-heading",children:"Context & session"}),(0,t.jsx)("p",{children:"Compaction policy versions and defaults frozen into the next Session Run."})]}),(0,t.jsx)(oz,{policies:e,models:n,onCreate:c,onDefault:d}),(0,t.jsx)(oR,{title:"Current session",description:a?a.title:"Select a Session to configure its defaults.",className:"current-session-settings",children:(0,t.jsxs)("div",{className:"session-default-grid",children:[(0,t.jsxs)("label",{className:"session-model-select",children:["Default model",(0,t.jsxs)("select",{disabled:!a,value:a?.defaultModelProfileId??"",onChange:e=>void u({defaultModelProfileId:e.target.value||null}),children:[(0,t.jsx)("option",{value:"",children:"Use global default"}),n.map(e=>(0,t.jsx)("option",{value:e.id,children:e.displayName||e.modelName},e.id))]})]}),(0,t.jsxs)("label",{className:"session-model-select",children:["Context compaction",(0,t.jsxs)("select",{disabled:!a,value:a?.compactionPolicyProfileId??"",onChange:e=>void u({compactionPolicyProfileId:e.target.value||null}),children:[(0,t.jsx)("option",{value:"",children:"Use global default"}),e.filter(e=>"compaction"===e.kind&&"active"===e.status).map(e=>(0,t.jsxs)("option",{value:e.id,children:[e.name," v",e.version]},e.id))]})]})]})}),(0,t.jsx)(oF,{sessionId:a?.id??null})]})}function oz({policies:e,models:a,onCreate:s,onDefault:i}){let r=(0,f.useT)(),[l,o]=(0,n.useState)([]),c=(e,t)=>o(n=>n.map((n,a)=>a===e?{...n,...t}:n));async function d(e){e.preventDefault();let t=e.currentTarget,n=new FormData(t),a=String(n.get("mode")),i="manual_and_auto"===a&&"on"===n.get("allowOverflowRecovery"),r=l.filter(e=>e.modelProfileId).map(e=>({modelProfileId:e.modelProfileId,...void 0!==e.triggerRatio?{triggerRatio:e.triggerRatio}:{},...void 0!==e.tailMaxTokens?{tailMaxTokens:e.tailMaxTokens}:{},...void 0!==e.summaryMaxOutputTokens?{summaryMaxOutputTokens:e.summaryMaxOutputTokens}:{}}));await s(String(n.get("name")),{mode:a,triggerRatio:Number(n.get("triggerRatio")),keepRecentTurns:Number(n.get("keepRecentTurns")),tailTokenRatio:Number(n.get("tailTokenRatio")),tailMinTokens:Number(n.get("tailMinTokens")),tailMaxTokens:Number(n.get("tailMaxTokens")),summaryInputRatio:Number(n.get("summaryInputRatio")),compactionModelProfileId:n.get("compactionModelProfileId")||null,summaryMaxOutputTokens:Number(n.get("summaryMaxOutputTokens")),...r.length>0?{modelPolicies:r}:{},includeReasoning:"on"===n.get("includeReasoning"),allowHistoryLookup:"on"===n.get("allowHistoryLookup"),allowOverflowRecovery:i,maxOverflowRecoveries:+!!i,ineffectiveReclaimRatio:Number(n.get("ineffectiveReclaimRatio")),ineffectiveLimit:Number(n.get("ineffectiveLimit")),failureCooldownSeconds:Number(n.get("failureCooldownSeconds")),promptVersion:"v1"}),t.reset(),o([])}return(0,t.jsxs)(oR,{title:"Context compaction",description:"Manual and bounded automatic context checkpoint behavior.",children:[(0,t.jsxs)("form",{className:"settings-form compaction-form",onSubmit:d,children:[(0,t.jsxs)("label",{children:["Name",(0,t.jsx)("input",{name:"name",required:!0})]}),(0,t.jsxs)("label",{children:["Mode",(0,t.jsxs)("select",{name:"mode",defaultValue:"manual_only",children:[(0,t.jsx)("option",{value:"disabled",children:"Disabled"}),(0,t.jsx)("option",{value:"manual_only",children:"Manual only"}),(0,t.jsx)("option",{value:"manual_and_auto",children:"Manual and automatic"})]})]}),(0,t.jsxs)("label",{children:["Summary model",(0,t.jsxs)("select",{name:"compactionModelProfileId",defaultValue:"",children:[(0,t.jsx)("option",{value:"",children:"Use run model"}),a.map(e=>(0,t.jsx)("option",{value:e.id,children:e.displayName||e.modelName},e.id))]})]}),(0,t.jsxs)("label",{children:["Trigger ratio",(0,t.jsx)("input",{name:"triggerRatio",type:"number",min:"0.01",max:"0.99",step:"0.01",defaultValue:"0.75",required:!0})]}),(0,t.jsxs)("label",{children:["Recent turns",(0,t.jsx)("input",{name:"keepRecentTurns",type:"number",min:"1",step:"1",defaultValue:"2",required:!0})]}),(0,t.jsxs)("label",{children:["Tail ratio",(0,t.jsx)("input",{name:"tailTokenRatio",type:"number",min:"0.01",max:"0.99",step:"0.01",defaultValue:"0.2",required:!0})]}),(0,t.jsxs)("label",{children:["Tail minimum",(0,t.jsx)("input",{name:"tailMinTokens",type:"number",min:"1",step:"1",defaultValue:"8000",required:!0})]}),(0,t.jsxs)("label",{children:["Tail maximum",(0,t.jsx)("input",{name:"tailMaxTokens",type:"number",min:"1",step:"1",defaultValue:"32000",required:!0})]}),(0,t.jsxs)("label",{children:["Summary input ratio",(0,t.jsx)("input",{name:"summaryInputRatio",type:"number",min:"0.01",max:"0.99",step:"0.01",defaultValue:"0.7",required:!0})]}),(0,t.jsxs)("label",{children:["Summary output",(0,t.jsx)("input",{name:"summaryMaxOutputTokens",type:"number",min:"1",step:"1",defaultValue:"4096",required:!0})]}),(0,t.jsxs)("label",{children:["Cooldown seconds",(0,t.jsx)("input",{name:"failureCooldownSeconds",type:"number",min:"0",step:"1",defaultValue:"600",required:!0})]}),(0,t.jsxs)("label",{children:["Ineffective ratio",(0,t.jsx)("input",{name:"ineffectiveReclaimRatio",type:"number",min:"0",max:"0.99",step:"0.01",defaultValue:"0.1",required:!0})]}),(0,t.jsxs)("label",{children:["Ineffective limit",(0,t.jsx)("input",{name:"ineffectiveLimit",type:"number",min:"1",step:"1",defaultValue:"3",required:!0})]}),(0,t.jsxs)("div",{className:"settings-toggles compaction-toggles",children:[(0,t.jsxs)("label",{children:[(0,t.jsx)("input",{name:"allowHistoryLookup",type:"checkbox",defaultChecked:!0})," History lookup"]}),(0,t.jsxs)("label",{children:[(0,t.jsx)("input",{name:"allowOverflowRecovery",type:"checkbox",defaultChecked:!0})," Overflow recovery"]}),(0,t.jsxs)("label",{children:[(0,t.jsx)("input",{name:"includeReasoning",type:"checkbox"})," Include reasoning"]})]}),(0,t.jsxs)("div",{className:"settings-subsection compaction-model-policies",children:[(0,t.jsxs)("header",{children:[(0,t.jsx)("h4",{children:"Per-model overrides"}),(0,t.jsx)("p",{children:"Optional budget overrides for a specific model."})]}),l.map((e,n)=>(0,t.jsxs)("div",{className:"model-policy-row",children:[(0,t.jsxs)("select",{value:e.modelProfileId,onChange:e=>c(n,{modelProfileId:e.target.value}),"aria-label":`Override model ${n+1}`,children:[(0,t.jsx)("option",{value:"",children:"Select model…"}),a.map(e=>(0,t.jsx)("option",{value:e.id,children:e.displayName||e.modelName},e.id))]}),(0,t.jsx)("input",{type:"number",step:"0.01",min:"0.01",max:"0.99",placeholder:"Trigger ratio",value:e.triggerRatio??"",onChange:e=>c(n,{triggerRatio:""===e.target.value?void 0:Number(e.target.value)})}),(0,t.jsx)("input",{type:"number",step:"1",min:"1",placeholder:"Tail max tokens",value:e.tailMaxTokens??"",onChange:e=>c(n,{tailMaxTokens:""===e.target.value?void 0:Number(e.target.value)})}),(0,t.jsx)("input",{type:"number",step:"1",min:"1",placeholder:"Summary output",value:e.summaryMaxOutputTokens??"",onChange:e=>c(n,{summaryMaxOutputTokens:""===e.target.value?void 0:Number(e.target.value)})}),(0,t.jsx)("button",{type:"button",className:"secondary-btn",onClick:()=>o(e=>e.filter((e,t)=>t!==n)),"aria-label":r("settings.context.removeOverride",{index:String(n+1)}),children:(0,t.jsx)(m,{size:12,"aria-hidden":"true"})})]},n)),(0,t.jsx)("button",{type:"button",className:"secondary-btn",onClick:()=>o(e=>[...e,{modelProfileId:""}]),children:"+ Add override"})]}),(0,t.jsx)("button",{type:"submit",children:"Create version"})]}),(0,t.jsx)("div",{className:"settings-list",children:e.filter(e=>"compaction"===e.kind).map(e=>(0,t.jsxs)("div",{className:"settings-row",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("strong",{children:e.name}),(0,t.jsxs)("span",{children:["v",e.version," · ",String(e.config.mode??"configured")]})]}),(0,t.jsx)("button",{className:"secondary-btn",disabled:"active"!==e.status,onClick:()=>i(e.id),children:"Use as default"})]},e.id))})]})}function oF({sessionId:e}){let{markSaving:a,markSaved:s}=oP(),[i,r]=(0,n.useState)([]),[l,o]=(0,n.useState)(null),[c,d]=(0,n.useState)(null);(0,n.useEffect)(()=>{if(!e)return;let t=!1;return(0,e5.apiFetch)(`/v1/sessions/${encodeURIComponent(e)}/standing-approvals`).then(n=>{t||(r(n?.items??[]),d(null),o(e))}).catch(n=>{t||(r([]),d(n.message),o(e))}),()=>{t=!0}},[e]);let u=l===e,p=u?i:[],h=!u,m=u?c:null,f=(0,n.useCallback)(async t=>{if(e){a();try{await (0,e5.apiFetch)(`/v1/sessions/${encodeURIComponent(e)}/standing-approvals/${encodeURIComponent(t)}/revoke`,{method:"POST"}),r(e=>e.filter(e=>e.id!==t)),d(null),s()}catch(e){d(e.message)}}},[e,a,s]);return e?(0,t.jsxs)(oR,{title:"Standing approvals",description:"Tools automatically authorised for this session. Revoke to require approval again.",className:"standing-approvals-section",children:[h&&(0,t.jsx)("div",{className:"settings-empty",children:"Loading…"}),!h&&m&&(0,t.jsx)("div",{className:"settings-error",children:m}),!h&&!m&&0===p.length&&(0,t.jsx)("div",{className:"settings-empty",children:"No standing approvals for this session."}),!h&&p.length>0&&(0,t.jsx)(oA,{children:p.map(e=>(0,t.jsx)(oE,{title:e.toolName,meta:e.scopeDisplay,actions:(0,t.jsx)("button",{className:"secondary-btn",onClick:()=>f(e.id),children:"Revoke"})},e.id))})]}):null}let oL=o("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"}]]),oD="ennote-default-permission",oO="ennote-default-permission-change",oq=["discuss","ask","auto"];function oB(){try{let e=window.localStorage.getItem(oD);if(null!==e&&oq.includes(e))return e}catch{}return"discuss"}var oU=e.i(18929),oH=e.i(426);let oW=["discuss","ask","auto"];function oV(){let{mode:e,setThemeMode:a}=rJ(),{locale:s,setLocale:i}=(0,f.useLocale)(),[r,l]=(0,n.useState)(()=>oB()),{markSaved:o}=oP(),c=e=>(0,oH.translate)(s,e),d=[{id:"light",label:"Light",icon:(0,t.jsx)(rq,{size:15,"aria-hidden":"true"})},{id:"dark",label:"Dark",icon:(0,t.jsx)(rO,{size:15,"aria-hidden":"true"})},{id:"system",label:"System",icon:(0,t.jsx)(oL,{size:15,"aria-hidden":"true"})}];return(0,t.jsxs)("section",{className:"settings-tab-section","aria-labelledby":"settings-general-heading",children:[(0,t.jsxs)("header",{children:[(0,t.jsx)("h2",{id:"settings-general-heading",children:c("general.title")}),(0,t.jsx)("p",{children:c("general.desc")})]}),(0,t.jsx)(oR,{title:c("general.appearance"),className:"appearance-group",children:(0,t.jsx)("div",{className:"appearance-cubes",role:"group","aria-label":c("general.appearance"),children:d.map(n=>(0,t.jsxs)("button",{type:"button",className:`appearance-cube ${e===n.id?"selected":""}`,"aria-pressed":e===n.id,onClick:()=>{a(n.id),o()},children:[n.icon,(0,t.jsx)("span",{children:n.label})]},n.id))})}),(0,t.jsx)(oR,{title:c("general.permission"),description:c("general.permission.desc"),className:"permission-group",children:(0,t.jsx)("div",{className:"appearance-cubes",role:"group","aria-label":c("general.permission"),children:oW.map(e=>(0,t.jsx)("button",{type:"button",className:`appearance-cube ${r===e?"selected":""}`,"aria-pressed":r===e,title:c(`permission.${e}.description`),onClick:()=>{l(e);try{window.localStorage.setItem(oD,e)}catch{}window.dispatchEvent(new CustomEvent(oO,{detail:e})),o()},children:(0,t.jsx)("span",{children:c(`permission.${e}`)})},e))})}),(0,t.jsx)(oR,{title:c("general.language"),className:"language-group",children:(0,t.jsx)("div",{className:"appearance-cubes",role:"group","aria-label":c("general.language"),children:oU.LOCALES.map(e=>(0,t.jsx)("button",{type:"button",className:`appearance-cube ${s===e?"selected":""}`,"aria-pressed":s===e,onClick:()=>{i(e),o()},children:(0,t.jsx)("span",{children:"en"===e?c("language.en"):c("language.zh")})},e))})})]})}function oK(e,t){return(0,e5.apiFetch)("/v1/packs/install",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({source:{kind:"path",path:e},dryRun:t.dryRun,...t.expectedDigest?{expectedDigest:t.expectedDigest}:{}})})}var oG=e.i(67203);function oJ({setError:e}){let[a,s]=(0,n.useState)([]),[i,r]=(0,n.useState)(!0),[l,o]=(0,n.useState)(""),[c,d]=(0,n.useState)(!1),[u,p]=(0,n.useState)(null),[h,m]=(0,n.useState)(null),[f,g]=(0,n.useState)(null),[x,v]=(0,n.useState)(null),[y,b]=(0,n.useState)(null),k=async()=>{try{s(await (0,e5.apiFetch)("/v1/packs")),e(null)}catch(t){e(t.message)}finally{r(!1)}};(0,n.useEffect)(()=>{let e=window.setTimeout(()=>void k(),0);return()=>window.clearTimeout(e)},[]);let j=async t=>{if(!c){d(!0),e(null);try{await t()}catch(t){e(t.message)}finally{d(!1)}}},w=e=>{o(e),m(null),g(null),p(null),b(null)},N=async()=>{!h||f!==l.trim()||await rc({title:`Install ${h.pack.name} ${h.pack.version}?`,description:h.willPublishFlowRevision?"This creates disabled draft objects and publishes an Agent Flow revision.":"This creates disabled draft objects on this Worker. Nothing runs until a revision is published and bound.",confirmLabel:"Install"})&&await j(async()=>{await oK(l.trim(),{dryRun:!1,expectedDigest:h.packDigest}),m(null),g(null),p(null),w(""),await k()})},_=async(t,n)=>{let a,s=2!==(a=t.pack.id.split("/")).length||""===a[0]||""===a[1]?null:{publisher:a[0],name:a[1]};s?await rc({title:n?`Force-remove ${t.pack.name}?`:`Remove ${t.pack.name}?`,description:n?"This also deletes objects that were edited locally or still referenced by another Graph.":"Every object this pack installed is deleted. A locally edited Skill is kept, with a warning.",confirmLabel:n?"Force remove":"Remove",tone:"danger"})&&await j(async()=>{v(t.pack.id);try{await function(e,t,n=!1){return(0,e5.apiFetch)(`/v1/packs/${encodeURIComponent(e)}/${encodeURIComponent(t)}${n?"?force=true":""}`,{method:"DELETE"})}(s.publisher,s.name,n),b(null),await k()}catch(e){throw b(t.pack.id),e}finally{v(null)}}):e(`"${t.pack.id}" is not a publisher/name pack id.`)},C=null===h||f!==l.trim()||h.blockers.length>0;return(0,t.jsxs)("section",{className:"settings-tab-section","aria-labelledby":"settings-packs-heading",children:[(0,t.jsx)("h3",{id:"settings-packs-heading",className:oG.default.heading,children:"Agent Packs"}),(0,t.jsx)("p",{className:oG.default.note,children:"A pack ships Heroes, Skills, and optionally a Graph or Agent Flow. Installing one only creates disabled drafts on this Worker — nothing runs until a revision is published and bound."}),(0,t.jsxs)("div",{className:oG.default.installer,children:[(0,t.jsxs)("label",{className:oG.default.pathLabel,children:[(0,t.jsx)("span",{children:"Pack path on the Worker host"}),(0,t.jsx)("input",{className:oG.default.pathInput,value:l,placeholder:"/home/me/packs/example.enpack",onChange:e=>w(e.target.value)})]}),(0,t.jsxs)("div",{className:oG.default.actions,children:[(0,t.jsx)("button",{type:"button",className:oG.default.button,disabled:c||""===l.trim(),onClick:()=>j(async()=>{var e;m(null),g(null),p(await (e=l.trim(),(0,e5.apiFetch)("/v1/packs/inspect",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({source:{kind:"path",path:e}})})))}),children:"Inspect"}),(0,t.jsx)("button",{type:"button",className:oG.default.button,disabled:c||""===l.trim(),onClick:()=>j(async()=>{m(await oK(l.trim(),{dryRun:!0})),g(l.trim())}),children:"Check install"}),(0,t.jsx)("button",{type:"button",className:`${oG.default.button} ${oG.default.primary}`,disabled:c||""===l.trim()||C,onClick:N,children:"Install"})]})]}),u&&(0,t.jsxs)("div",{className:oG.default.card,"data-testid":"pack-inspect",children:[(0,t.jsxs)("div",{className:oG.default.cardHead,children:[(0,t.jsx)(ow,{size:14,"aria-hidden":"true"}),(0,t.jsx)("span",{className:oG.default.cardName,children:u.pack.name}),(0,t.jsx)("span",{className:oG.default.badge,children:u.pack.version}),(0,t.jsx)("span",{className:oG.default.badge,children:u.pack.id}),!u.signed&&(0,t.jsx)("span",{className:oG.default.badge,children:"unsigned"})]}),(0,t.jsxs)("div",{className:oG.default.counts,children:[u.flows.length," flows · ",u.heroes.length," heroes · ",u.skills.length," skills · ",u.filesTotal," files"]}),(0,t.jsxs)("div",{className:oG.default.digest,children:["pack digest ",u.packDigest.slice(0,16),"…"]}),(0,t.jsx)(oY,{issues:u.warnings})]}),h&&(0,t.jsxs)("div",{className:oG.default.card,"data-testid":"pack-plan","data-blocked":C||void 0,children:[(0,t.jsxs)("div",{className:oG.default.cardHead,children:[(0,t.jsx)("span",{className:oG.default.cardName,children:"Install plan"}),(0,t.jsxs)("span",{className:oG.default.badge,children:[h.actions.length," actions"]}),h.willPublishFlowRevision&&(0,t.jsx)("span",{className:oG.default.badge,children:"publishes a revision"})]}),(0,t.jsx)("ul",{className:oG.default.actionList,children:h.actions.map(e=>(0,t.jsxs)("li",{className:oG.default.actionRow,children:[(0,t.jsx)("span",{className:oG.default.badge,children:e.kind}),(0,t.jsx)("span",{className:oG.default.actionId,children:e.storeId}),(0,t.jsx)("span",{className:oG.default.actionVerb,"data-action":e.action,children:e.action})]},`${e.kind}:${e.storeId}`))}),(0,t.jsx)(oY,{issues:[...h.blockers.map(e=>({...e,severity:e.severity??"error"})),...h.warnings.map(e=>({...e,severity:e.severity??"warning"}))]})]}),(0,t.jsxs)("div",{className:oG.default.sectionHeader,children:["Installed ",(0,t.jsx)("span",{className:oG.default.sectionCount,children:a.length}),(0,t.jsx)("button",{type:"button",className:oG.default.iconButton,"aria-label":"Refresh installed packs",onClick:()=>void k(),children:(0,t.jsx)(iB,{size:13,"aria-hidden":"true"})})]}),i?(0,t.jsx)("div",{className:oG.default.empty,children:"Loading…"}):0===a.length?(0,t.jsx)("div",{className:oG.default.empty,children:"No packs installed."}):(0,t.jsx)("div",{className:oG.default.stack,children:a.map(e=>(0,t.jsxs)("div",{className:oG.default.row,"data-testid":"pack-row",children:[(0,t.jsxs)("div",{className:oG.default.identity,children:[(0,t.jsxs)("div",{className:oG.default.titleRow,children:[(0,t.jsx)("span",{className:oG.default.name,children:e.pack.name}),(0,t.jsx)("span",{className:oG.default.badge,children:e.pack.version})]}),(0,t.jsxs)("div",{className:oG.default.meta,children:[e.flowCount," flows · ",e.heroCount," heroes · ",e.skillCount," skills"]})]}),y===e.pack.id&&(0,t.jsx)("button",{type:"button",className:oG.default.button,disabled:c||x===e.pack.id,onClick:()=>void _(e,!0),children:"Force remove"}),(0,t.jsx)("button",{type:"button",className:oG.default.iconButton,"aria-label":`Remove ${e.pack.name}`,disabled:c||x===e.pack.id,onClick:()=>void _(e,!1),children:(0,t.jsx)(P,{size:13,"aria-hidden":"true"})})]},e.pack.id))})]})}function oY({issues:e}){return 0===e.length?null:(0,t.jsx)("ul",{className:oG.default.issueList,children:e.map(e=>(0,t.jsxs)("li",{className:oG.default.issueRow,"data-severity":e.severity??"warning",children:[(0,t.jsx)("span",{className:oG.default.badge,children:e.code}),(0,t.jsx)("span",{children:e.message})]},`${e.code}:${e.message}`))})}var oQ=e.i(82399);let oZ={stdio:"stdio",streamable_http:"Streamable HTTP",legacy_sse:"HTTP + SSE"};function oX({mcp:e}){let{showCreate:n,transport:a,setTransport:s,displayName:i,setDisplayName:r,slug:l,setSlug:o,executable:c,setExecutable:d,argv:u,setArgv:p,endpoint:h,setEndpoint:m,createProfile:f}=e;return(0,t.jsx)(t.Fragment,{children:n&&(0,t.jsxs)("div",{className:oQ.default.form,children:[(0,t.jsxs)("div",{className:oQ.default.formGrid,children:[(0,t.jsxs)("label",{className:oQ.default.field,children:["Display name",(0,t.jsx)("input",{value:i,onChange:e=>r(e.target.value),className:oQ.default.input,placeholder:"PubMed"})]}),(0,t.jsxs)("label",{className:oQ.default.field,children:["Slug (fixed once bound)",(0,t.jsx)("input",{value:l,onChange:e=>o(e.target.value),className:oQ.default.input,placeholder:"pubmed"})]})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("div",{className:oQ.default.transportRow,children:["stdio","streamable_http","legacy_sse"].map(e=>(0,t.jsx)("button",{type:"button",onClick:()=>s(e),className:oQ.default.transportButton,"data-active":a===e||void 0,children:oZ[e]},e))}),"stdio"===a?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("label",{className:oQ.default.field,children:["Executable",(0,t.jsx)("input",{value:c,onChange:e=>d(e.target.value),className:oQ.default.input,placeholder:"/usr/bin/python3"})]}),(0,t.jsxs)("label",{className:oQ.default.field,children:["Arguments (space-separated)",(0,t.jsx)("input",{value:u,onChange:e=>p(e.target.value),className:oQ.default.input,placeholder:"/path/to/server.py"})]})]}):(0,t.jsxs)("label",{className:oQ.default.field,children:["Endpoint URL",(0,t.jsx)("input",{value:h,onChange:e=>m(e.target.value),className:oQ.default.input,placeholder:"https://example.com/mcp"})]})]}),(0,t.jsx)("button",{type:"button",onClick:f,disabled:!i.trim()||!l.trim()||("stdio"===a?!c.trim():!h.trim()),className:oQ.default.createButton,children:"Create profile"})]})})}function o0({mcp:e,binding:n}){let{catalogs:a,toolSearch:s,setToolSearch:i,showCreds:r,setShowCreds:l,credEnv:o,setCredEnv:c,credRef:d,setCredRef:u,versionFor:p,updateBinding:h,toggleTool:m,selectAllTools:f,addCredential:g,removeCredential:x,testBinding:v,refreshCatalog:y,removeBinding:b}=e,k=a[n.id]??[],j=n.selectedRemoteToolNames??[],w=p(n),N=w?"stdio"===w.transport?`${w.executable??""} ${(w.argv??[]).join(" ")}`.trim():w.endpoint??"":"";return(0,t.jsxs)("div",{className:oQ.default.card,children:[(0,t.jsxs)("div",{className:oQ.default.cardHead,children:[(0,t.jsxs)("div",{className:oQ.default.cardIdentity,children:[(0,t.jsxs)("div",{className:oQ.default.cardTitle,children:[w?oZ[w.transport]??w.transport:"MCP server",(0,t.jsxs)("span",{className:oQ.default.cardMeta,children:["rev ",n.revision??0," · ",j.length," tools selected"]})]}),N&&(0,t.jsx)("div",{className:oQ.default.commandSummary,children:N})]}),(0,t.jsxs)("div",{className:oQ.default.actions,children:[(0,t.jsx)("button",{type:"button",title:n.required?"Server is required: Run start fails when unreachable":"Server is optional: Run start continues when unreachable",onClick:()=>h(n,{required:!n.required}),className:oQ.default.requiredButton,"data-required":n.required||void 0,children:n.required?"required":"optional"}),(0,t.jsx)("button",{type:"button",title:"Edit credential references for this binding",onClick:()=>l(e=>({...e,[n.id]:!e[n.id]})),className:oQ.default.ghostButton,children:"Credentials"}),(0,t.jsx)("button",{type:"button",onClick:async()=>{let e=!n.desiredEnabled;if(e){let e=w?"stdio"===w.transport?`Command: ${N}`:`Endpoint: ${w.endpoint??""}`:"";if(!await rc({title:"Enable this MCP server?",description:`${e}
7
7
 
8
- Only selected tools will be exposed to Runs.`,confirmLabel:"Enable server"}))return}await h(n,{desiredEnabled:e})},className:oH.default.enableButton,"data-enabled":n.desiredEnabled||void 0,children:n.desiredEnabled?"Enabled":"Disabled"}),(0,t.jsx)("button",{type:"button",title:"Test connection",onClick:()=>v(n),className:oH.default.ghostButton,children:"Test"}),(0,t.jsx)("button",{type:"button",title:"Refresh tool catalog",onClick:()=>y(n),className:oH.default.ghostButton,children:"Refresh"}),(0,t.jsx)("button",{type:"button",title:"Remove binding",onClick:()=>b(n),className:`${oH.default.ghostButton} ${oH.default.danger}`,children:"Remove"})]})]}),n.desiredEnabled&&(0,t.jsxs)("div",{children:[(0,t.jsxs)("div",{className:oH.default.toolsHeader,children:[(0,t.jsx)("span",{className:oH.default.toolsHint,children:"Selected tools (exact, frozen per Run)"}),k.length>0&&(0,t.jsx)("button",{type:"button",onClick:()=>f(n,k),className:oH.default.ghostButton,children:"Select all current"})]}),0===k.length?(0,t.jsx)("div",{className:oH.default.catalogEmpty,children:"No catalog yet — press Refresh to discover tools from the server."}):(0,t.jsxs)("div",{children:[(0,t.jsx)("input",{type:"search",placeholder:"Search tools…",value:s[n.id]??"",onChange:e=>i(t=>({...t,[n.id]:e.target.value})),className:`${oH.default.input} ${oH.default.toolSearch}`}),(0,t.jsx)("div",{className:oH.default.catalogScroll,children:(0,t.jsx)("table",{className:oH.default.catalogTable,children:(0,t.jsx)("tbody",{children:k.filter(e=>{let t=(s[n.id]??"").toLowerCase();return!t||e.remoteName.toLowerCase().includes(t)||(e.description??"").toLowerCase().includes(t)}).map(e=>(0,t.jsxs)("tr",{className:oH.default.toolRow,children:[(0,t.jsx)("td",{className:oH.default.toolCheckCell,children:(0,t.jsx)("input",{type:"checkbox",className:oH.default.toolCheckbox,"aria-label":e.remoteName,checked:j.includes(e.remoteName),onChange:()=>m(n,e.remoteName)})}),(0,t.jsx)("td",{className:oH.default.toolNameCell,children:e.remoteName}),(0,t.jsx)("td",{className:oH.default.toolDescriptionCell,children:e.description||"—"})]},e.remoteName))})})})]})]}),r[n.id]&&(0,t.jsxs)("div",{className:oH.default.credentials,children:[(0,t.jsx)("div",{className:oH.default.credentialNote,children:"Credential references (env: / file: / keyring: refs only — values never stored or shown)"}),Object.entries(n.credentialRefs??{}).map(([e,a])=>(0,t.jsxs)("div",{className:oH.default.credentialRow,children:[(0,t.jsx)("code",{className:oH.default.credentialEnv,children:e}),(0,t.jsx)("code",{className:oH.default.credentialRef,children:a}),(0,t.jsx)("button",{type:"button",onClick:()=>x(n,e),className:oH.default.ghostButton,children:"Remove"})]},e)),0===Object.keys(n.credentialRefs??{}).length&&(0,t.jsx)("div",{className:oH.default.credentialNote,children:"No binding-level credentials. The profile version's defaults apply."}),(0,t.jsxs)("div",{className:oH.default.credentialInputRow,children:[(0,t.jsx)("input",{value:o[n.id]??"",onChange:e=>c(t=>({...t,[n.id]:e.target.value})),placeholder:"ENV_NAME",className:`${oH.default.input} ${oH.default.credentialEnvInput}`}),(0,t.jsx)("input",{value:d[n.id]??"",onChange:e=>u(t=>({...t,[n.id]:e.target.value})),placeholder:"env:MY_REF / file:... / keyring:...",className:`${oH.default.input} ${oH.default.credentialRefInput}`}),(0,t.jsx)("button",{type:"button",onClick:()=>g(n),disabled:!(o[n.id]??"").trim()||!(d[n.id]??"").trim(),className:oH.default.ghostButton,children:"Add"})]})]})]},n.id)}function oG({mcp:e}){let{profiles:n,candidates:a,bindings:s,versions:i,diffView:r,bindCandidate:l,openProfileDiff:o,archiveProfile:c}=e;return 0===a.length&&0===n.length?null:(0,t.jsxs)("div",{children:[(0,t.jsx)("div",{className:oH.default.sectionHeader,children:"Discovered servers"}),(0,t.jsxs)("div",{className:oH.default.list,children:[a.map(e=>{let a;return(0,t.jsxs)("div",{className:oH.default.candidateGroup,children:[(0,t.jsxs)("div",{className:oH.default.candidateRow,children:[(0,t.jsxs)("div",{className:oH.default.candidateIdentity,children:[(0,t.jsx)("span",{className:oH.default.candidateName,children:e.displayName??e.slug}),(0,t.jsxs)("span",{className:oH.default.candidateMeta,children:[e.transport," · ",e.sourceKind]}),"project_file"===e.sourceKind&&(0,t.jsx)("div",{className:oH.default.candidateSource,children:e.sourceLocator})]}),(0,t.jsxs)("div",{className:oH.default.candidateActions,children:[e.alreadyBound?(0,t.jsx)("span",{className:oH.default.boundBadge,children:"Bound"}):(0,t.jsx)("button",{type:"button",onClick:()=>l(e),className:oH.default.ghostButton,children:"Bind"}),e.alreadyBound&&e.updateAvailable&&(0,t.jsx)("button",{type:"button",title:"Project file changed; rebind to the new immutable version",onClick:()=>l(e),className:`${oH.default.ghostButton} ${oH.default.accent}`,children:"Update available"}),e.alreadyBound&&e.updateAvailable&&(0,t.jsx)("button",{type:"button",title:"Show the read-only diff between the bound version and the project file",onClick:()=>o(e),className:oH.default.ghostButton,children:"View diff"}),"managed"===e.sourceKind&&!e.alreadyBound&&((a=n.find(t=>t.slug===e.slug&&"active"===t.lifecycleStatus))?(0,t.jsx)("button",{type:"button",title:"Archive MCP profile","aria-label":`Archive MCP profile ${a.displayName??a.slug}`,onClick:()=>c(a),className:`${oH.default.ghostButton} ${oH.default.danger} ${oH.default.archiveButton}`,children:(0,t.jsx)(A,{size:14,"aria-hidden":"true"})}):null)]})]}),r&&r.slug===e.slug&&(0,t.jsxs)("div",{className:oH.default.diffCard,children:[(0,t.jsxs)("div",{className:oH.default.diffTitle,children:["Read-only diff: bound version vs project file",r.digestTo&&(0,t.jsxs)("span",{className:oH.default.diffDigest,children:["new config ",r.digestTo.slice(0,8)]})]}),r.lines.some(e=>e.startsWith("+ ")||e.startsWith("- "))?(0,t.jsx)("div",{className:oH.default.diffBody,children:r.lines.map((e,n)=>(0,t.jsx)("div",{className:oH.default.diffLine,"data-kind":e.startsWith("- ")?"removed":e.startsWith("+ ")?"added":void 0,children:e},n))}):(0,t.jsxs)("div",{className:oH.default.diffUnchanged,children:["Connection fields are unchanged — the project file changed argv, env, headers, or timeout (config digest ",r.digestTo?r.digestTo.slice(0,8):"changed",")."]})]})]},`${e.sourceKind}:${e.slug}`)}),n.filter(e=>!a.some(t=>t.slug===e.slug)).map(e=>{let n=new Set((i[e.id]??[]).map(e=>e.id)),a=s.some(e=>n.has(e.profileVersionId));return(0,t.jsxs)("div",{className:oH.default.candidateRow,children:[(0,t.jsxs)("div",{className:oH.default.candidateIdentity,children:[(0,t.jsx)("span",{className:oH.default.candidateName,children:e.displayName}),(0,t.jsxs)("span",{className:oH.default.candidateMeta,children:[e.slug," · v",e.latestVersion??0," · managed"]})]}),(0,t.jsx)("div",{className:oH.default.candidateActions,children:a?(0,t.jsx)("span",{className:oH.default.boundBadge,children:"Bound"}):(0,t.jsx)("button",{type:"button",title:"Archive MCP profile","aria-label":`Archive MCP profile ${e.displayName??e.slug}`,onClick:()=>c(e),className:`${oH.default.ghostButton} ${oH.default.danger} ${oH.default.archiveButton}`,children:(0,t.jsx)(A,{size:14,"aria-hidden":"true"})})})]},e.id)})]})]})}function oJ({projectId:e,setError:a}){let s=function(e,t){let[a,s]=(0,n.useState)([]),[i,r]=(0,n.useState)([]),[l,o]=(0,n.useState)([]),[c,d]=(0,n.useState)({}),[u,p]=(0,n.useState)({}),[h,m]=(0,n.useState)({}),[f,g]=(0,n.useState)({}),[x,v]=(0,n.useState)({}),[y,b]=(0,n.useState)({}),[k,j]=(0,n.useState)(null),{markSaving:w,markSaved:_}=oj(),[N,C]=(0,n.useState)(!1),[S,I]=(0,n.useState)(!1),[P,T]=(0,n.useState)("stdio"),[M,R]=(0,n.useState)(""),[E,A]=(0,n.useState)(""),[$,z]=(0,n.useState)(""),[F,L]=(0,n.useState)(""),[D,O]=(0,n.useState)(""),q=(0,n.useCallback)(async e=>{let t={};await Promise.all(e.map(async e=>{try{t[e.id]=await (0,e5.apiFetch)(`/v1/mcp/server-profiles/${e.id}/versions`)}catch{}})),p(t)},[]),B=(0,n.useCallback)(e=>{for(let t of Object.values(u)){let n=t.find(t=>t.id===e.profileVersionId);if(n)return n}},[u]),U=(0,n.useCallback)(e=>{if(e)for(let t of Object.values(u)){let n=t.find(t=>t.id===e);if(n)return n}},[u]),H=(0,n.useCallback)(e=>{let t=U(e.boundVersionId),n=JSON.stringify(t?{transport:t.transport,..."stdio"===t.transport?{executable:t.executable??""}:{endpoint:t.endpoint??""}}:{transport:"(unknown bound version)"},null,2),a=JSON.stringify({transport:e.transport,..."stdio"===e.transport?{executable:e.executable??""}:{endpoint:e.endpoint??""}},null,2);j({slug:e.slug??"",lines:function(e,t){let n=e.split("\n"),a=t.split("\n"),s=[],i=Math.max(n.length,a.length);for(let e=0;e<i;e++){let t=n[e],i=a[e];void 0===t?s.push(`+ ${i}`):void 0===i?s.push(`- ${t}`):t===i?s.push(` ${t}`):(s.push(`- ${t}`),s.push(`+ ${i}`))}return s}(n,a),digestTo:e.configDigest??""})},[U]),W=(0,n.useCallback)(async()=>{if(e){C(!0);try{let[t,n,a]=await Promise.all([(0,e5.apiFetch)("/v1/mcp/server-profiles"),(0,e5.apiFetch)(`/v1/projects/${e}/mcp/bindings`),(0,e5.apiFetch)(`/v1/projects/${e}/mcp/candidates`)]);s(t),o(n),r(a),q(t);let i={};for(let t of n)if(t.desiredEnabled)try{i[t.id]=await (0,e5.apiFetch)(`/v1/projects/${e}/mcp/bindings/${t.id}/catalog`)}catch{}d(i)}catch(e){t(e instanceof Error?e.message:"Failed to load MCP settings")}finally{C(!1)}}},[e,t,q]);(0,n.useEffect)(()=>{let n=!1;if(e)return Promise.all([(0,e5.apiFetch)("/v1/mcp/server-profiles"),(0,e5.apiFetch)(`/v1/projects/${e}/mcp/bindings`),(0,e5.apiFetch)(`/v1/projects/${e}/mcp/candidates`).catch(()=>{throw Error("Failed to load discovered servers")})]).then(async([t,a,i])=>{if(n)return;s(t),o(a),r(i),q(t);let l={};for(let t of a)if(t.desiredEnabled)try{l[t.id]=await (0,e5.apiFetch)(`/v1/projects/${e}/mcp/bindings/${t.id}/catalog`)}catch{}n||d(l)}).catch(e=>{n||t(e instanceof Error?e.message:"Failed to load MCP settings")}),()=>{n=!0}},[e,t,q]);let V=async()=>{w();try{let e=await (0,e5.apiFetch)("/v1/mcp/server-profiles",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({displayName:M,slug:E,sourceKind:"managed"})}),t={transport:P};if("stdio"===P){t.executable=$.trim();let e=F.split(/\s+/).filter(Boolean);e.length>0&&(t.argv=e)}else t.endpoint=D.trim();await (0,e5.apiFetch)(`/v1/mcp/server-profiles/${e.id}/versions`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),I(!1),R(""),A(""),z(""),L(""),O(""),await W(),_()}catch(e){t(e instanceof Error?e.message:"Failed to create MCP profile")}},K=async(n,a)=>{if(e){w();try{await (0,e5.apiFetch)(`/v1/projects/${e}/mcp/bindings/${n.id}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)}),await W(),_()}catch(e){t(e instanceof Error?e.message:"Failed to update MCP binding")}}},G=async(e,t)=>{let n=e.selectedRemoteToolNames??[],a=n.includes(t)?n.filter(e=>e!==t):[...n,t];await K(e,{selectedRemoteToolNames:a})},J=async(e,t)=>{await K(e,{selectedRemoteToolNames:t.map(e=>e.remoteName)})},Y=async e=>{let t=(x[e.id]??"").trim(),n=(y[e.id]??"").trim();if(!t||!n)return;let a={...e.credentialRefs??{}};a[t]=n,await K(e,{credentialRefs:a}),v(t=>({...t,[e.id]:""})),b(t=>({...t,[e.id]:""}))},Q=async(e,t)=>{let n={...e.credentialRefs??{}};delete n[t],await K(e,{credentialRefs:n})};return{profiles:a,candidates:i,bindings:l,catalogs:c,versions:u,toolSearch:h,setToolSearch:m,showCreds:f,setShowCreds:g,credEnv:x,setCredEnv:v,credRef:y,setCredRef:b,diffView:k,loading:N,showCreate:S,setShowCreate:I,transport:P,setTransport:T,displayName:M,setDisplayName:R,slug:E,setSlug:A,executable:$,setExecutable:z,argv:F,setArgv:L,endpoint:D,setEndpoint:O,versionFor:B,openProfileDiff:H,createProfile:V,bindCandidate:async n=>{if(e){w();try{("project_file"!==n.sourceKind||n.boundVersionId||n.updateAvailable)&&n.boundVersionId&&!n.updateAvailable?await (0,e5.apiFetch)(`/v1/projects/${e}/mcp/bindings`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({profileVersionId:n.boundVersionId})}):await (0,e5.apiFetch)(`/v1/projects/${e}/mcp/bindings/from-candidate`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({slug:n.slug,transport:n.transport})}),await W(),_()}catch(e){t(e instanceof Error?e.message:"Failed to bind MCP candidate")}}},updateBinding:K,toggleTool:G,selectAllTools:J,addCredential:Y,removeCredential:Q,testBinding:async n=>{if(e)try{await (0,e5.apiFetch)(`/v1/projects/${e}/mcp/bindings/${n.id}/test`,{method:"POST"}),t(null)}catch(e){t(e instanceof Error?e.message:"Test failed")}},refreshCatalog:async n=>{if(e)try{let a=await (0,e5.apiFetch)(`/v1/projects/${e}/mcp/bindings/${n.id}/catalog/refresh`,{method:"POST"});d(e=>({...e,[n.id]:a})),t(null)}catch(e){t(e instanceof Error?e.message:"Catalog refresh failed")}},removeBinding:async n=>{if(e&&await rc({title:"Remove this MCP binding?",description:"Tools from this server will no longer be available to Runs in this project.",confirmLabel:"Remove binding",tone:"danger"})){w();try{await (0,e5.apiFetch)(`/v1/projects/${e}/mcp/bindings/${n.id}`,{method:"DELETE"}),await W(),_()}catch(e){t(e instanceof Error?e.message:"Failed to remove binding")}}},archiveProfile:async e=>{if(e.id&&await rc({title:`Archive MCP profile “${e.displayName??e.slug}”?`,description:"Bindings that reference this profile will stop resolving for new Runs.",confirmLabel:"Archive profile",tone:"danger"})){w();try{await (0,e5.apiFetch)(`/v1/mcp/server-profiles/${encodeURIComponent(e.id)}`,{method:"DELETE"}),t(null),await W(),_()}catch(e){t(e instanceof Error?e.message:"Failed to archive MCP profile")}}}}}(e,a);return e?(0,t.jsxs)("div",{className:oH.default.settingsRoot,children:[(0,t.jsxs)("div",{className:oH.default.settingsHeader,children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("div",{className:oH.default.settingsTitle,children:"MCP servers"}),(0,t.jsx)("div",{className:oH.default.settingsDescription,children:"Tools-first client. Servers are discovered, tested, then explicitly enabled per project."})]}),(0,t.jsx)("button",{type:"button",onClick:()=>s.setShowCreate(e=>!e),className:oH.default.addButton,children:s.showCreate?"Cancel":"+ Add server"})]}),(0,t.jsx)(oV,{mcp:s}),(0,t.jsxs)("div",{className:oH.default.bindings,children:[0===s.bindings.length&&!s.loading&&(0,t.jsx)("div",{className:oH.default.emptyText,children:"No MCP servers bound to this project yet."}),s.bindings.map(e=>(0,t.jsx)(oK,{mcp:s,binding:e},e.id))]}),(0,t.jsx)(oG,{mcp:s}),s.loading&&(0,t.jsx)("div",{className:oH.default.loadingText,children:"Loading…"})]}):(0,t.jsx)("div",{className:oH.default.emptyText,children:"Open a project to manage MCP servers."})}let oY=o("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"}]]);var oQ=e.i(90239);function oZ(e){let{roots:n,loading:a,control:s}=e,{showRootForm:i,setShowRootForm:r,rootName:l,setRootName:o,rootPreset:c,setRootPreset:d,rootPath:u,setRootPath:p,rootBusy:h,addRoot:f,toggleRoot:g,removeRoot:x}=s;return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:oQ.default.sectionHeader,children:["Skills roots ",(0,t.jsxs)("span",{className:oQ.default.sectionCount,children:[n.length," additional"]})]}),(0,t.jsx)("div",{className:oQ.default.note,children:"Resolution paths are on the Worker host. Remote clients (Tauri) read the same configured roots — no per-client setup."}),(0,t.jsxs)("div",{className:oQ.default.stack,children:[0===n.length&&!a&&(0,t.jsxs)("div",{className:oQ.default.empty,children:["No additional roots. Ennote reads ",(0,t.jsx)("code",{children:"$ENNOTE_HOME/skills"})," on the Worker host by default; add pi, Claude Code, Codex, or Cursor skill directories here."]}),n.map(e=>(0,t.jsxs)("div",{className:oQ.default.rootRow,children:[(0,t.jsxs)("div",{className:oQ.default.rootIdentity,children:[(0,t.jsxs)("div",{className:oQ.default.rootTitleRow,children:[(0,t.jsx)("span",{className:oQ.default.rootName,children:e.name}),(0,t.jsx)("span",{className:oQ.default.badge,children:e.agentKind}),(0,t.jsxs)("span",{className:oQ.default.rootPriority,children:["pri ",e.priority]})]}),(0,t.jsx)("div",{className:oQ.default.rootPath,children:e.path})]}),(0,t.jsx)("button",{type:"button",onClick:()=>void g(e),disabled:null!==h,className:oQ.default.toggle,"data-enabled":e.enabled||void 0,children:e.enabled?"Enabled":"Disabled"}),(0,t.jsx)("button",{type:"button",onClick:()=>void x(e),disabled:null!==h,title:`Stop reading skills from ${e.path}`,className:`${oQ.default.ghostButton} ${oQ.default.danger}`,children:(0,t.jsx)(m,{size:12,"aria-hidden":"true"})})]},e.id)),i?(0,t.jsxs)("div",{className:oQ.default.rootForm,children:[(0,t.jsxs)("div",{className:oQ.default.inputRow,children:[(0,t.jsxs)("select",{value:c,onChange:e=>d(e.target.value),"aria-label":"Ecosystem preset",className:`${oQ.default.input} ${oQ.default.inputPreset}`,disabled:!!u.trim(),children:[(0,t.jsx)("option",{value:"pi",children:"pi"}),(0,t.jsx)("option",{value:"claude",children:"Claude Code"}),(0,t.jsx)("option",{value:"codex",children:"Codex"}),(0,t.jsx)("option",{value:"cursor",children:"Cursor"}),(0,t.jsx)("option",{value:"generic",children:"Custom path"})]}),(0,t.jsx)("input",{value:l,onChange:e=>o(e.target.value),placeholder:"Name (defaults to preset)","aria-label":"Root name",className:`${oQ.default.input} ${oQ.default.inputName}`}),(0,t.jsx)("input",{value:u,onChange:e=>p(e.target.value),placeholder:"generic"===c?"/absolute/path/to/skills":"Optional explicit path (else preset)","aria-label":"Root path",className:oQ.default.input})]}),(0,t.jsxs)("div",{className:oQ.default.actionRow,children:[(0,t.jsx)("button",{type:"button",onClick:()=>void f(),disabled:null!==h,className:oQ.default.primaryButton,children:"add"===h?"Adding…":"Add root"}),(0,t.jsx)("button",{type:"button",onClick:()=>r(!1),className:oQ.default.ghostButton,children:"Cancel"})]})]}):(0,t.jsx)("button",{type:"button",onClick:()=>r(!0),className:oQ.default.ghostButton,children:"+ Add skills root"})]})]})}function oX(e){let{projectId:n,projectTrusted:a,query:s,setQuery:i,results:r,searching:l,searched:o,installScope:c,setInstallScope:d,installing:p,onSearch:h,onInstall:m}=e;return(0,t.jsxs)("div",{className:`skills-market-panel ${oQ.default.market}`,children:[(0,t.jsx)("div",{className:oQ.default.marketTitle,children:"Marketplace"}),(0,t.jsxs)("div",{className:oQ.default.searchRow,children:[(0,t.jsx)("input",{type:"search",value:s,onChange:e=>i(e.target.value),onKeyDown:e=>{"Enter"===e.key&&h()},placeholder:"Search skills.sh…","aria-label":"Search skills.sh",className:oQ.default.input}),(0,t.jsxs)("select",{value:c,onChange:e=>d(e.target.value),"aria-label":"Install scope",className:`${oQ.default.input} ${oQ.default.inputScope}`,children:[(0,t.jsx)("option",{value:"global",children:"Global"}),(0,t.jsxs)("option",{value:"project",disabled:!n||!a,children:["Project",!a&&n?" (needs trust)":""]})]}),(0,t.jsxs)("button",{type:"button",onClick:()=>void h(),disabled:l||!s.trim(),className:oQ.default.ghostButton,children:[(0,t.jsx)(u,{size:13,"aria-hidden":"true"})," ",l?"Searching…":"Search"]})]}),o&&0===r.length&&!l&&(0,t.jsxs)("div",{className:oQ.default.empty,children:['No skills match "',s.trim(),'".']}),r.map(e=>(0,t.jsxs)("div",{className:oQ.default.resultRow,children:[(0,t.jsx)("span",{className:oQ.default.resultPackage,children:e.package}),e.installs&&(0,t.jsx)("span",{className:oQ.default.resultInstalls,children:e.installs}),e.url&&(0,t.jsxs)("a",{href:e.url,target:"_blank",rel:"noreferrer",title:e.url,className:`${oQ.default.link} ${oQ.default.linkIcon}`,children:[(0,t.jsx)(oY,{size:13,"aria-hidden":"true"}),(0,t.jsxs)("span",{className:"sr-only",children:["Open ",e.package]})]}),(0,t.jsx)("button",{type:"button",disabled:null!==p,onClick:()=>void m(e.package),className:oQ.default.installButton,"data-busy":p===e.package||void 0,children:p===e.package?"Installing…":"Install"})]},e.package))]})}function o0(e){let{installed:n,loading:a,updateKey:s,updates:i,checking:r,toggling:l,removing:o,onCheck:c,onUpdate:d,onToggle:u,onRemove:p}=e;return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:oQ.default.sectionHeader,children:["Installed ",(0,t.jsx)("span",{className:oQ.default.sectionCount,children:n.length})]}),a&&(0,t.jsx)("div",{className:oQ.default.empty,children:"Loading…"}),!a&&0===n.length&&(0,t.jsx)("div",{className:oQ.default.empty,children:"No installed skills yet — search the marketplace above."}),!a&&n.length>0&&(0,t.jsx)("div",{className:oQ.default.stack,children:n.map(e=>{let n=e.install,a=s(n),h=i[a];return(0,t.jsx)("div",{className:oQ.default.installedCard,children:(0,t.jsxs)("div",{className:oQ.default.installedHead,children:[(0,t.jsxs)("div",{className:oQ.default.installedIdentity,children:[(0,t.jsxs)("div",{className:oQ.default.installedTitleRow,children:[(0,t.jsx)("strong",{className:oQ.default.installedName,children:e.name}),(0,t.jsx)("span",{className:`skill-row-scope ${oQ.default.badge}`,children:n.scope}),h?.state==="update-available"&&(0,t.jsx)("span",{className:oQ.default.updateBadge,children:"Update available"})]}),e.description&&(0,t.jsx)("div",{className:oQ.default.installedDescription,children:e.description}),(0,t.jsxs)("div",{className:oQ.default.installedMeta,children:[(0,t.jsx)("span",{className:oQ.default.mono,children:n.package}),n.versionHash&&(0,t.jsxs)("span",{className:oQ.default.mono,children:["v",n.versionHash.slice(0,8)]}),n.skillsShUrl&&(0,t.jsxs)("a",{href:n.skillsShUrl,target:"_blank",rel:"noreferrer",className:oQ.default.link,children:["skills.sh ",(0,t.jsx)(oY,{size:10,"aria-hidden":"true"})]})]})]}),(0,t.jsxs)("div",{className:oQ.default.installedActions,children:[(0,t.jsx)("button",{type:"button",title:"Allow or block model invocation for this skill",onClick:()=>void u(e),disabled:l===e.relPath,className:oQ.default.toggle,"data-disabled":e.disableModelInvocation||void 0,children:e.disableModelInvocation?"Disabled":"Enabled"}),(0,t.jsx)("button",{type:"button",title:"Check for updates",onClick:()=>void c(n),disabled:null!==r,className:oQ.default.ghostButton,children:r===a?(0,t.jsx)(iB,{size:12,"aria-hidden":"true",className:"delivery-spinner"}):"Check"}),h?.state==="update-available"&&(0,t.jsx)("button",{type:"button",onClick:()=>void d(n),disabled:null!==r,className:`${oQ.default.ghostButton} ${oQ.default.warning}`,children:"Update"}),h?.state==="up-to-date"&&(0,t.jsx)("span",{className:oQ.default.statusText,children:"Up to date"}),h?.state==="error"&&h.message&&(0,t.jsx)("span",{className:oQ.default.statusError,title:h.message,children:h.message}),h?.state==="unsupported"&&(0,t.jsx)("span",{className:oQ.default.statusText,title:h.message??"",children:"No updates"}),(0,t.jsx)("button",{type:"button",title:"Remove skill",onClick:()=>void p(e),disabled:null!==o,className:`${oQ.default.ghostButton} ${oQ.default.danger}`,children:o===e.relPath?"Removing…":(0,t.jsx)(m,{size:12,"aria-hidden":"true"})})]})]})},`${e.relPath}:${e.skillId}`)})})]})}function o1({local:e}){return 0===e.length?null:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:oQ.default.sectionHeader,children:["Catalog ",(0,t.jsx)("span",{className:oQ.default.sectionCount,children:e.length})]}),(0,t.jsx)("div",{className:oQ.default.stack,children:e.map(e=>(0,t.jsxs)("div",{className:oQ.default.catalogRow,children:[(0,t.jsx)("span",{className:oQ.default.catalogName,children:e.name}),(0,t.jsx)("span",{className:oQ.default.badge,children:e.sourceInfo.scope??"local"}),e.disableModelInvocation&&(0,t.jsx)("span",{className:oQ.default.statusText,children:"invocation disabled"})]},`${e.relPath}:${e.skillId}`))})]})}function o2({diagnostics:e}){return 0===e.length?null:(0,t.jsxs)("div",{className:oQ.default.diagnostics,children:[(0,t.jsx)("div",{className:oQ.default.diagTitle,children:"Catalog diagnostics"}),(0,t.jsx)("div",{className:oQ.default.diagList,children:e.map((e,n)=>(0,t.jsxs)("div",{className:oQ.default.diagRow,"data-level":"skip"===e.level?"skip":void 0,children:["[",e.level,"] ",e.relPath?`${e.relPath}: `:"",e.message]},n))})]})}function o4({projectId:e,setError:a}){let s=function(e,t){let[a,s]=(0,n.useState)([]),[i,r]=(0,n.useState)([]),[l,o]=(0,n.useState)(!1),[c,d]=(0,n.useState)(!1),[u,p]=(0,n.useState)([]),h=(0,n.useCallback)(async()=>{d(!0);try{let n=e?`?projectID=${encodeURIComponent(e)}`:"",a=await (0,e5.apiFetch)(`/v1/skills${n}`);s(a.skills??[]),r(a.diagnostics??[]),o(!!a.projectResourcesLoaded);let i=await (0,e5.apiFetch)("/v1/skills/roots");p(i.items??[]),t(null)}catch(e){t(e instanceof Error?e.message:"Failed to load skills")}finally{d(!1)}},[e,t]);return(0,n.useEffect)(()=>{let e=window.setTimeout(()=>void h(),0);return()=>window.clearTimeout(e)},[h]),{skills:a,setSkills:s,diagnostics:i,projectTrusted:l,loading:c,roots:u,setRoots:p,load:h}}(e,a),i=function(e,t,a){let[s,i]=(0,n.useState)(!1),[r,l]=(0,n.useState)(""),[o,c]=(0,n.useState)("pi"),[d,u]=(0,n.useState)(""),[p,h]=(0,n.useState)(null),{markSaving:m,markSaved:f}=oj(),g=(0,n.useCallback)(async()=>{h("add"),m();try{await (0,e5.apiFetch)("/v1/skills/roots",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:r.trim()||o,agentKind:d.trim()?"generic":o,path:d.trim()||void 0})}),l(""),u(""),i(!1),a(null),await t(),f()}catch(e){a(e instanceof Error?e.message:"Failed to add skill root")}finally{h(null)}},[r,o,d,a,t,m,f]);return{showRootForm:s,setShowRootForm:i,rootName:r,setRootName:l,rootPreset:o,setRootPreset:c,rootPath:d,setRootPath:u,rootBusy:p,addRoot:g,toggleRoot:(0,n.useCallback)(async n=>{h(n.id),m();try{let s=await (0,e5.apiFetch)(`/v1/skills/roots/${n.id}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:!n.enabled})});e(e=>e.map(e=>e.id===n.id?s:e)),a(null),await t(),f()}catch(e){a(e instanceof Error?e.message:"Toggle failed")}finally{h(null)}},[e,a,t,m,f]),removeRoot:(0,n.useCallback)(async n=>{if(await rc({title:`Stop reading skills from "${n.path}"?`,description:"Installed skills under this root are no longer discovered.",confirmLabel:"Stop reading",tone:"danger"})){h(n.id),m();try{await (0,e5.apiFetch)(`/v1/skills/roots/${n.id}`,{method:"DELETE"}),e(e=>e.filter(e=>e.id!==n.id)),a(null),await t(),f()}catch(e){a(e instanceof Error?e.message:"Remove failed")}finally{h(null)}}},[e,a,t,m,f])}}(s.setRoots,s.load,a),r=function(e,t,a,s){let[i,r]=(0,n.useState)(""),[l,o]=(0,n.useState)([]),[c,d]=(0,n.useState)(!1),[u,p]=(0,n.useState)(!1),[h,m]=(0,n.useState)("global"),[f,g]=(0,n.useState)(null),x=(0,n.useCallback)(async()=>{let e=i.trim();if(e){d(!0);try{let t=await (0,e5.apiFetch)(`/v1/skills/search?q=${encodeURIComponent(e)}&limit=20`);o(t.results??[]),p(!0),s(null)}catch(e){s(e instanceof Error?e.message:"Search failed")}finally{d(!1)}}},[i,s]),v=(0,n.useCallback)(async n=>{if("project"===h&&!t)return void s("Project resources must be trusted before installing project skills.");g(n);try{await (0,e5.apiFetch)("/v1/skills/install",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({package:n,scope:h,..."project"===h&&e?{projectId:e}:{}})}),s(null),o(e=>e.filter(e=>e.package!==n)),await a()}catch(e){s(e instanceof Error?e.message:"Install failed")}finally{g(null)}},[h,t,e,s,a]);return{query:i,setQuery:r,results:l,searching:c,searched:u,installScope:h,setInstallScope:m,installing:f,search:x,install:v}}(e,s.projectTrusted,s.load,a),l=function(e,t,a,s){let[i,r]=(0,n.useState)({}),[l,o]=(0,n.useState)(null),[c,d]=(0,n.useState)(null),[u,p]=(0,n.useState)(null),{markSaving:h,markSaved:m}=oj(),f=(0,n.useCallback)(e=>`${e.scope}\u0000${e.package}`,[]),g=(0,n.useCallback)(async t=>{o(f(t));try{let n=await (0,e5.apiFetch)("/v1/skills/check",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({package:t.package,scope:t.scope,..."project"===t.scope&&e?{projectId:e}:{}})});r(e=>{let t={...e};for(let e of n.updates??[])t[f(e)]=e;return t}),s(null)}catch(e){s(e instanceof Error?e.message:"Update check failed")}finally{o(null)}},[e,s,f]),x=(0,n.useCallback)(async t=>{let n=f(t);o(n),h();try{await (0,e5.apiFetch)("/v1/skills/update",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({package:t.package,scope:t.scope,..."project"===t.scope&&e?{projectId:e}:{}})}),s(null),r(e=>{let t={...e};return delete t[n],t}),await a(),m()}catch(e){s(e instanceof Error?e.message:"Update failed")}finally{o(null)}},[e,s,f,a,h,m]);return{updateKey:f,updates:i,checking:l,toggling:c,removing:u,check:g,update:x,toggle:(0,n.useCallback)(async e=>{d(e.relPath),h();try{await (0,e5.apiFetch)(`/v1/skills/disabled/${e.relPath}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({disabled:!e.disableModelInvocation})}),t(t=>t.map(t=>t.relPath===e.relPath?{...t,disableModelInvocation:!e.disableModelInvocation}:t)),s(null),m()}catch(e){s(e instanceof Error?e.message:"Toggle failed")}finally{d(null)}},[t,s,h,m]),remove:(0,n.useCallback)(async e=>{if(await rc({title:`Remove the skill "${e.name}"?`,description:"The skill files are removed from the managed catalog.",confirmLabel:"Remove skill",tone:"danger"})){p(e.relPath),h();try{await (0,e5.apiFetch)(`/v1/skills/remove/${e.relPath}`,{method:"POST"}),t(t=>t.filter(t=>t.relPath!==e.relPath)),s(null),m()}catch(e){s(e instanceof Error?e.message:"Remove failed")}finally{p(null)}}},[t,s,h,m])}}(e,s.setSkills,s.load,a),o=s.skills.filter(e=>!!e.install),c=s.skills.filter(e=>!e.install);return(0,t.jsxs)("section",{className:"settings-tab-section","aria-labelledby":"settings-skills-heading",children:[(0,t.jsxs)("header",{children:[(0,t.jsx)("h2",{id:"settings-skills-heading",children:"Skills"}),(0,t.jsx)("p",{children:"Marketplace installs, catalog browsing, and per-skill invocation control."})]}),(0,t.jsx)(oZ,{roots:s.roots,loading:s.loading,control:i}),(0,t.jsx)(oX,{projectId:e,projectTrusted:s.projectTrusted,query:r.query,setQuery:r.setQuery,results:r.results,searching:r.searching,searched:r.searched,installScope:r.installScope,setInstallScope:r.setInstallScope,installing:r.installing,onSearch:r.search,onInstall:r.install}),(0,t.jsx)(o0,{installed:o,loading:s.loading,updateKey:l.updateKey,updates:l.updates,checking:l.checking,toggling:l.toggling,removing:l.removing,onCheck:l.check,onUpdate:l.update,onToggle:l.toggle,onRemove:l.remove}),(0,t.jsx)(o1,{local:c}),(0,t.jsx)(o2,{diagnostics:s.diagnostics})]})}function o5({configured:e,missing:n}){let a=(0,f.useT)();return e?(0,t.jsx)("span",{className:"settings-models-dot settings-models-dot-ok",role:"img","aria-label":a("settings.models.credentialConfigured"),title:a("settings.models.credentialConfigured")}):n?(0,t.jsx)("span",{className:"settings-models-dot settings-models-dot-missing",role:"img","aria-label":a("settings.models.credentialMissing"),title:a("settings.models.credentialMissing")}):null}let o3=o("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"}]]),o6=o("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 o8({value:e,onChange:a,placeholder:s,ariaLabel:i}){let[r,l]=(0,n.useState)(!1);return(0,t.jsxs)("span",{className:"settings-models-secret",children:[(0,t.jsx)("input",{type:r?"text":"password",value:e,placeholder:s,"aria-label":i,autoComplete:"off",spellCheck:!1,onChange:e=>a(e.target.value)}),(0,t.jsx)("button",{type:"button",className:"settings-models-secret-toggle",title:r?"Hide key":"Show key","aria-label":r?"Hide key":"Show key",onClick:()=>l(e=>!e),children:r?(0,t.jsx)(o6,{size:13,"aria-hidden":"true"}):(0,t.jsx)(o3,{size:13,"aria-hidden":"true"})})]})}function o9(e){let t=e.trim();return 0===t.length?0===e.length?void 0:"keyBlank":/[^\x21-\x7E]/.test(t)||/^[A-Za-z_][A-Za-z0-9_]*=/.test(t)||t.startsWith('"')&&t.endsWith('"')||t.startsWith("'")&&t.endsWith("'")?"keyIllegalCharacters":void 0}async function o7(e){for(let t of(await (0,e5.apiFetch)("/v1/provider-profiles",{method:"POST",body:JSON.stringify({key:e.key,name:e.name,providerType:e.providerType,baseUrl:e.baseUrl,apiKey:e.apiKey||void 0})}),e.models)){let n=String(t.id??"").trim();0!==n.length&&await (0,e5.apiFetch)("/v1/model-profiles",{method:"POST",body:JSON.stringify({providerId:e.key,modelName:n,..."string"==typeof t.name&&t.name.length>0?{displayName:t.name}:{},contextWindow:"number"==typeof t.contextWindow?t.contextWindow:131072,maxOutputTokens:"number"==typeof t.maxTokens?t.maxTokens:16384,supportsToolUse:!0})})}}function ce(e){if(void 0===e)return;let t=Array.isArray(e)?e.map(e=>"object"!=typeof e||null===e||Array.isArray(e)?{}:e):[],n=new Set;for(let[e,a]of t.entries()){let t=a.id,s="string"==typeof t?t.trim():void 0;if(void 0===s||0===s.length)return{index:e,key:"modelIdRequired"};if(n.has(s))return{index:e,key:"modelIdDuplicate"};n.add(s);let i=a.name;if(void 0!==i&&("string"!=typeof i||0===i.length))return{index:e,key:"modelNameInvalid"};let r=a.contextWindow;if(void 0!==r&&("number"!=typeof r||!Number.isInteger(r)||r<=0))return{index:e,key:"modelContextInvalid"};let l=a.maxTokens;if(void 0!==l&&("number"!=typeof l||!Number.isInteger(l)||l<=0))return{index:e,key:"modelMaxTokensInvalid"}}}function ct(e){return{id:e.modelName,...e.displayName?{name:e.displayName}:{},...e.contextWindow?{contextWindow:e.contextWindow}:{},...e.maxOutputTokens?{maxTokens:e.maxOutputTokens}:{}}}function cn({probe:e,existingIds:a,onAdopt:s,onError:i,disabled:r,blockedReason:l}){let o=(0,f.useT)(),[c,d]=(0,n.useState)(!1),[u,p]=(0,n.useState)(null),[h,g]=(0,n.useState)(!1),[x,v]=(0,n.useState)(new Set),y=!!(e.baseUrl&&e.baseUrl.length>0),b=l??(y?void 0:o("settings.models.fetchNeedsBaseUrl")),k=async()=>{g(!0),p(null);try{let t=await (0,e5.apiFetch)("/v1/provider-profiles/discover-models",{method:"POST",body:JSON.stringify({baseUrl:e.baseUrl||void 0,apiKey:e.apiKey||void 0})})??[];if(0===t.length)return void i?.(o("settings.models.fetchEmpty"));let n=new Set(a);p(t),v(new Set(t.filter(e=>!n.has(e.modelName)).map(e=>e.modelName))),d(!0)}catch(e){i?.(e.message)}finally{g(!1)}},j=()=>{d(!1),p(null)},w=null!==u&&u.length>0&&u.every(e=>x.has(e.modelName));return M(c&&null!==u,j),(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("button",{type:"button",className:"settings-models-link",disabled:r||h||!y||void 0!==l,title:b,onClick:()=>{k()},children:h?o("settings.models.fetching"):o("settings.models.fetchModels")}),c&&u&&(0,t.jsx)("div",{className:"settings-overlay",role:"dialog","aria-modal":"true","aria-label":o("settings.models.fetchTitle"),children:(0,t.jsxs)("div",{className:"project-create-dialog settings-models-fetch",children:[(0,t.jsxs)("div",{className:"project-create-header",children:[(0,t.jsx)("span",{children:o("settings.models.fetchTitle")}),(0,t.jsx)("button",{type:"button",className:"follow-up-close","aria-label":o("settings.models.close"),title:o("settings.models.close"),onClick:j,children:(0,t.jsx)(m,{size:14,"aria-hidden":"true"})})]}),(0,t.jsxs)("div",{className:"project-create-form",children:[(0,t.jsx)("p",{className:"settings-models-hint",children:o("settings.models.fetchDescription")}),(0,t.jsx)("div",{className:"settings-models-fetch-actions",children:(0,t.jsx)("button",{type:"button",className:"settings-models-link",onClick:()=>{u&&v(w?new Set:new Set(u.map(e=>e.modelName)))},children:o(w?"settings.models.fetchDeselectAll":"settings.models.fetchSelectAll")})}),(0,t.jsx)("ul",{className:"settings-models-candidates",children:u.map(e=>(0,t.jsx)("li",{className:"settings-models-candidate",children:(0,t.jsxs)("label",{className:"settings-models-candidate-label",children:[(0,t.jsx)("input",{type:"checkbox",checked:x.has(e.modelName),onChange:()=>{v(t=>{let n=new Set(t);return n.delete(e.modelName)||n.add(e.modelName),n})}}),(0,t.jsx)("span",{className:"settings-models-candidate-id",children:e.modelName})]})},e.modelName))}),(0,t.jsxs)("div",{className:"project-create-actions",children:[(0,t.jsx)("button",{type:"button",className:"secondary-btn",onClick:j,children:o("settings.models.cancel")}),(0,t.jsx)("button",{type:"button",className:"secondary-btn",onClick:()=>{u&&(s(u.filter(e=>x.has(e.modelName)).map(ct)),j())},children:o("settings.models.fetchAdopt")})]})]})]})})]})}let ca=/^(\d+(?:\.\d+)?)([km])?$/i,cs={k:1e3,m:1e6};function ci(e,t){let n=e[t];return"string"==typeof n?n:""}function cr({open:e}){return(0,t.jsx)(j,{size:14,className:"model-editor-chevron","data-open":e||void 0,"aria-hidden":"true"})}function cl(){return(0,t.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none","aria-hidden":!0,children:(0,t.jsx)("path",{d:"M2.5 4h11M6.5 4V2.5h3V4M4 4l.7 9a1 1 0 001 .9h4.6a1 1 0 001-.9L12 4M6.5 6.8v4.4M9.5 6.8v4.4",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round"})})}function co(){return(0,t.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none","aria-hidden":!0,children:(0,t.jsx)("path",{d:"M8 3v10M3 8h10",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})})}function cc({models:e,onChange:a,overridden:s,onReset:i,disabled:r,probe:l,probeBlocked:o,onFetchError:c}){let d=(0,f.useT)(),[u,p]=(0,n.useState)(()=>new Set),[h,m]=(0,n.useState)(()=>new Map),g=(e,t)=>`${String(e)}:${t}`,x=(t,n)=>{a(e.map((e,a)=>{if(a!==t)return e;let s=new Set(Object.entries(n).filter(([,e])=>void 0===e||""===e).map(([e])=>e));return Object.fromEntries(Object.entries({...e,...n}).filter(([e])=>!s.has(e)))}))},v=(e,t,n)=>{m(a=>new Map(a).set(g(e,t),n)),x(e,{[t]:function(e){let t=e.trim();if(0===t.length)return;let n=ca.exec(t);if(null===n)return NaN;let a=n[2]?.toLowerCase(),s="k"===a||"m"===a?cs[a]:1,i=Number(n[1])*s,r=Math.round(i);return 1e-6>Math.abs(i-r)?r:i}(n)})},y=(e,t,n)=>{let a,s=h.get(g(t,n));if(void 0!==s)return s;let i="number"==typeof(a=e[n])?a:void 0;return void 0===i?"":!Number.isInteger(i)||i<=0?String(i):i%cs.m==0?`${String(i/cs.m)}M`:i%cs.k==0?`${String(i/cs.k)}K`:String(i)},b=e=>("string"==typeof e.id?e.id:"").trim();return(0,t.jsxs)("section",{className:"settings-models-catalog","aria-label":d("settings.models.models"),children:[(0,t.jsxs)("div",{className:"settings-models-list-head",children:[(0,t.jsxs)("div",{className:"settings-models-catalog-heading",children:[(0,t.jsx)("span",{className:"settings-models-catalog-title",children:d("settings.models.models")}),void 0!==s&&(0,t.jsx)("span",{className:"settings-models-catalog-meta",children:s?d("settings.models.modelsCustomized"):d("settings.models.modelsInherited")})]}),!0===s&&void 0!==i&&(0,t.jsx)("button",{type:"button",className:"settings-models-link",disabled:r,onClick:i,children:d("settings.models.resetModels")}),void 0!==l&&(0,t.jsx)(cn,{probe:l,existingIds:e.map(b),onAdopt:t=>{let n=new Map(e.map(e=>[b(e),e]));for(let e of t)n.set(b(e),n.get(b(e))??e);a([...n.values()])},onError:c,disabled:r,blockedReason:o})]}),0===e.length&&(0,t.jsx)("p",{className:"settings-models-catalog-empty",children:d("settings.models.modelsEmpty")}),e.map((n,s)=>(0,t.jsxs)("div",{className:"settings-models-entry",children:[(0,t.jsxs)("div",{className:"settings-models-entry-row",children:[(0,t.jsx)("input",{className:"settings-models-input",type:"text",value:ci(n,"id"),placeholder:d("settings.models.modelId"),"aria-label":`${d("settings.models.modelId")} ${s+1}`,disabled:r,onChange:e=>{x(s,{id:e.target.value})}}),(0,t.jsx)("input",{className:"settings-models-input",type:"text",value:ci(n,"name"),placeholder:d("settings.models.modelName"),"aria-label":`${d("settings.models.modelName")} ${s+1}`,disabled:r,onChange:e=>{x(s,{name:""===e.target.value?void 0:e.target.value})}}),(0,t.jsx)("button",{type:"button",className:"settings-models-icon","aria-label":`${d("settings.models.modelAdvanced")} ${s+1}`,"aria-expanded":u.has(s),title:d("settings.models.modelAdvanced"),onClick:()=>{p(e=>{let t=new Set(e);return t.delete(s)||t.add(s),t})},children:(0,t.jsx)(cr,{open:u.has(s)})}),(0,t.jsx)("button",{type:"button",className:"settings-models-icon settings-models-icon-danger","aria-label":`${d("settings.models.removeModel")} ${s+1}`,title:d("settings.models.removeModel"),disabled:r,onClick:()=>{a(e.filter((e,t)=>t!==s)),p(e=>{let t=new Set;for(let n of e)n<s?t.add(n):n>s&&t.add(n-1);return t}),m(e=>((e,t)=>{let n=new Map;for(let[a,s]of e){let e=Number(a.slice(0,a.indexOf(":")));e!==t&&n.set(e>t?a.replace(/^\d+/,String(e-1)):a,s)}return n})(e,s))},children:(0,t.jsx)(cl,{})})]}),u.has(s)&&(0,t.jsxs)("div",{className:"settings-models-entry-advanced",children:[(0,t.jsxs)("label",{className:"settings-models-entry-field",children:[(0,t.jsx)("span",{className:"settings-models-entry-field-label",children:d("settings.models.contextWindow")}),(0,t.jsx)("input",{className:"settings-models-input",type:"text",inputMode:"numeric",value:y(n,s,"contextWindow"),placeholder:"256K","aria-label":`${d("settings.models.contextWindow")} ${s+1}`,disabled:r,onChange:e=>{v(s,"contextWindow",e.target.value)}})]}),(0,t.jsxs)("label",{className:"settings-models-entry-field",children:[(0,t.jsx)("span",{className:"settings-models-entry-field-label",children:d("settings.models.maxTokens")}),(0,t.jsx)("input",{className:"settings-models-input",type:"text",inputMode:"numeric",value:y(n,s,"maxTokens"),placeholder:"32K","aria-label":`${d("settings.models.maxTokens")} ${s+1}`,disabled:r,onChange:e=>{v(s,"maxTokens",e.target.value)}})]})]})]},s)),(0,t.jsxs)("button",{type:"button",className:"settings-models-add-model",disabled:r,onClick:()=>{a([...e,{id:""}])},children:[(0,t.jsx)(co,{}),d("settings.models.addModel")]})]})}let cd=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/,cu=["openai-compatible","anthropic"];function cp({taken:e,onClose:a,refresh:s,setError:i,onSaved:r}){let l,o=(0,f.useT)(),[c,d]=(0,n.useState)(""),[u,p]=(0,n.useState)(""),[h,m]=(0,n.useState)(""),[g,x]=(0,n.useState)(cu[0]),[v,y]=(0,n.useState)(""),[b,k]=(0,n.useState)([]),[j,w]=(0,n.useState)(!1),[_,N]=(0,n.useState)(void 0),C=c.length>0&&!cd.test(c),S=e.includes(c),I=ce(b),P=o9(v),T=v.trim(),M=c.length>0&&!C&&!S&&h.trim().length>0&&b.length>0&&void 0===I&&void 0===P;async function R(){w(!0),N(void 0);try{await o7({key:c,name:u.trim()||c,providerType:g,baseUrl:h.trim(),apiKey:T||void 0,models:b}),i(null),r?.(u.trim()||c),await s(),a(!0)}catch(e){N(e.message)}finally{w(!1)}}return void 0!==_||M||C||S||void 0!==P||(0===c.length?l=o("settings.models.customRouteHint"):0===h.trim().length?l=o("settings.models.customNeedsBaseUrl"):0===b.length?l=o("settings.models.customNeedsModels"):void 0!==I&&(l=`${o("settings.models.model")} ${I.index+1}: ${o(`settings.models.${I.key}`)}`)),(0,t.jsxs)("div",{className:"settings-row provider-settings-row settings-models-editor",children:[(0,t.jsx)("div",{className:"settings-models-editor-header",children:(0,t.jsx)("span",{className:"settings-models-editor-title",children:o("settings.models.customTitle")})}),(0,t.jsxs)("div",{className:"settings-models-field",children:[(0,t.jsx)("span",{className:"settings-models-fieldlabel",children:o("settings.models.customRoute")}),(0,t.jsx)("input",{className:"settings-models-input",type:"text",value:c,placeholder:"acme-gateway",disabled:j,"aria-label":o("settings.models.customRoute"),onChange:e=>{d(e.target.value)}}),C||S?(0,t.jsx)("p",{className:"settings-models-error",children:o(C?"settings.models.customRouteInvalid":"settings.models.customRouteTaken")}):(0,t.jsx)("p",{className:"settings-models-hint",children:o("settings.models.customRouteHint")})]}),(0,t.jsxs)("div",{className:"settings-models-field",children:[(0,t.jsx)("span",{className:"settings-models-fieldlabel",children:o("settings.models.customDisplayName")}),(0,t.jsx)("input",{className:"settings-models-input",type:"text",value:u,placeholder:0===c.length?o("settings.models.customDisplayName"):c,disabled:j,"aria-label":o("settings.models.customDisplayName"),onChange:e=>{p(e.target.value)}})]}),(0,t.jsxs)("div",{className:"settings-models-field",children:[(0,t.jsx)("span",{className:"settings-models-fieldlabel",children:o("settings.models.baseUrl")}),(0,t.jsx)("input",{className:"settings-models-input",type:"text",value:h,placeholder:"https://gateway.example/v1",disabled:j,"aria-label":o("settings.models.baseUrl"),onChange:e=>{m(e.target.value)}})]}),(0,t.jsxs)("div",{className:"settings-models-field",children:[(0,t.jsx)("span",{className:"settings-models-fieldlabel",children:o("settings.models.customApi")}),(0,t.jsx)("select",{className:"settings-models-input settings-models-select",value:g,disabled:j,"aria-label":o("settings.models.customApi"),onChange:e=>{x(e.target.value)},children:cu.map(e=>(0,t.jsx)("option",{value:e,children:e},e))})]}),(0,t.jsxs)("div",{className:"settings-models-field",children:[(0,t.jsx)("span",{className:"settings-models-fieldlabel",children:o("settings.models.keyInput")}),(0,t.jsx)(o8,{value:v,onChange:y,placeholder:o("settings.models.keyPlaceholder"),ariaLabel:o("settings.models.keyInput")}),void 0===P?null:(0,t.jsx)("p",{className:"settings-models-error",children:o(`settings.models.${P}`)})]}),(0,t.jsx)(cc,{models:b,onChange:k,disabled:j,probe:{baseUrl:h.trim(),apiKey:T},probeBlocked:void 0!==P?o(`settings.models.${P}`):void 0,onFetchError:N}),void 0!==_?(0,t.jsx)("p",{className:"settings-models-error",children:_}):null,void 0===l?null:(0,t.jsx)("p",{className:"settings-models-hint",children:l}),(0,t.jsxs)("div",{className:"settings-models-editor-actions",children:[(0,t.jsx)("button",{type:"button",className:"secondary-btn",disabled:j,onClick:()=>a(!1),children:o("settings.models.cancel")}),(0,t.jsx)("button",{type:"button",className:"settings-models-primary",disabled:j||!M,onClick:()=>{R()},children:o(j?"settings.models.creating":"settings.models.create")})]})]})}function ch({open:e,providerName:n,busy:a,failure:s,onCancel:i,onConfirm:r}){let l=(0,f.useT)();if(M(e,i,{dismissOnEscape:!a}),!e)return null;let o=l("settings.models.deleteTitle",{provider:n}),c=l("settings.models.deleteDescriptionWithCredential",{provider:n}),d=l("settings.models.deleteConfirm",{provider:n}),u=l("settings.models.deleting",{provider:n});return(0,t.jsx)("div",{className:"settings-overlay",role:"dialog","aria-modal":"true","aria-label":o,children:(0,t.jsxs)("div",{className:"project-create-dialog",children:[(0,t.jsxs)("div",{className:"project-create-header",children:[(0,t.jsx)("span",{children:o}),(0,t.jsx)("button",{type:"button",className:"follow-up-close","aria-label":l("settings.models.close"),title:l("settings.models.close"),onClick:i,children:(0,t.jsx)(m,{size:14,"aria-hidden":"true"})})]}),(0,t.jsxs)("div",{className:"project-create-form",children:[(0,t.jsx)("p",{className:"settings-delete-description",children:c}),s&&(0,t.jsx)("p",{className:"settings-delete-error",children:s}),(0,t.jsxs)("div",{className:"project-create-actions",children:[(0,t.jsx)("button",{type:"button",className:"secondary-btn",disabled:a,onClick:i,children:l("settings.models.cancel")}),(0,t.jsx)("button",{type:"button",className:"project-create-submit",disabled:a,onClick:r,children:a?u:d})]})]})]})})}function cm(e,t){let n=e[t];return"string"==typeof n&&n.trim().length>0?n.trim():void 0}function cf(e,t){let n=e[t];return"number"==typeof n?n:void 0}async function cg(e){for(let t of e.toDelete)await (0,e5.apiFetch)(`/v1/model-profiles/${encodeURIComponent(t)}`,{method:"DELETE"});for(let{id:t,input:n}of e.toUpdate)await (0,e5.apiFetch)(`/v1/model-profiles/${encodeURIComponent(t)}`,{method:"PUT",body:JSON.stringify(n)});for(let t of e.toCreate)await (0,e5.apiFetch)("/v1/model-profiles",{method:"POST",body:JSON.stringify(t)})}function cx({provider:e,models:a,creating:s,hideTitle:i,onClose:r,refresh:l,setError:o,onSaved:c}){let d=(0,f.useT)(),[u,p]=(0,n.useState)(""),[h,m]=(0,n.useState)(e.baseUrl??""),[g,x]=(0,n.useState)(e.name??""),[v,y]=(0,n.useState)(()=>s?[]:a.map(e=>({id:e.modelName,...e.displayName&&e.displayName!==e.modelName?{name:e.displayName}:{},contextWindow:e.contextWindow,maxTokens:e.maxOutputTokens}))),[b,k]=(0,n.useState)(!1),[j,w]=(0,n.useState)(void 0),_=o9(u),N=ce(v),C=u.trim(),S=a.map(e=>({id:e.id,modelName:e.modelName,displayName:e.displayName,contextWindow:e.contextWindow,maxOutputTokens:e.maxOutputTokens}));async function I(){k(!0),w(void 0);try{if(s)await o7({key:e.id,name:g.trim()||e.name,providerType:e.providerType,baseUrl:h.trim()||e.baseUrl,apiKey:C||void 0,models:v});else{await (0,e5.apiFetch)(`/v1/provider-profiles/${encodeURIComponent(e.id)}`,{method:"PUT",body:JSON.stringify({name:g.trim()||void 0,baseUrl:h.trim()||void 0,apiKey:C||void 0})});let t=function(e,t,n,a=131072,s=16384){let i={toCreate:[],toDelete:[],toUpdate:[]},r=new Map(t.map(e=>[e.modelName,e])),l=new Set;for(let t of n){var o,c;let n=cm(t,"id");if(void 0===n)continue;l.add(n);let d=r.get(n);if(void 0===d){i.toCreate.push({providerId:e,modelName:n,...void 0===cm(t,"name")?{}:{displayName:cm(t,"name")},contextWindow:cf(t,"contextWindow")??a,maxOutputTokens:cf(t,"maxTokens")??s,supportsToolUse:!0});continue}o=t,c=d,(cm(o,"name")!==(c.displayName&&c.displayName!==c.modelName?c.displayName:void 0)||cf(o,"contextWindow")!==c.contextWindow||cf(o,"maxTokens")!==c.maxOutputTokens)&&i.toUpdate.push({id:d.id,input:{displayName:cm(t,"name")??null,contextWindow:cf(t,"contextWindow")??null,maxOutputTokens:cf(t,"maxTokens")??null}})}for(let e of t)l.has(e.modelName)||i.toDelete.push(e.id);return i}(e.id,S,v);await cg(t)}o(null),c?.(g.trim()||e.name),await l(),r(!0)}catch(e){w(e.message)}finally{k(!1)}}let P=b||void 0!==_||void 0!==N,T=d(e.credentialConfigured?"settings.models.keyStored":"settings.models.keyPlaceholder");return(0,t.jsxs)("div",{className:"settings-row provider-settings-row settings-models-editor",children:[!i&&(0,t.jsxs)("div",{className:"settings-models-editor-header",children:[(0,t.jsx)("span",{className:"settings-models-editor-title",children:e.name}),e.name!==e.id&&(0,t.jsx)("span",{className:"settings-models-editor-route",children:e.id})]}),(0,t.jsxs)("div",{className:"settings-models-field",children:[(0,t.jsx)("span",{className:"settings-models-fieldlabel",children:d("settings.models.keyInput")}),(0,t.jsx)(o8,{value:u,onChange:p,placeholder:T,ariaLabel:d("settings.models.keyInput")}),void 0===_?null:(0,t.jsx)("p",{className:"settings-models-error",children:d(`settings.models.${_}`)})]}),(0,t.jsxs)("details",{className:"settings-models-customized",children:[(0,t.jsx)("summary",{className:"settings-models-customized-summary",children:d("settings.models.customized")}),(0,t.jsxs)("div",{className:"settings-models-customized-body",children:[e.custom&&(0,t.jsxs)("div",{className:"settings-models-field",children:[(0,t.jsx)("span",{className:"settings-models-fieldlabel",children:d("settings.models.customDisplayName")}),(0,t.jsx)("input",{className:"settings-models-input",type:"text",value:g,disabled:b,"aria-label":d("settings.models.customDisplayName"),onChange:e=>{x(e.target.value)}})]}),(0,t.jsxs)("div",{className:"settings-models-field",children:[(0,t.jsx)("span",{className:"settings-models-fieldlabel",children:d("settings.models.baseUrl")}),(0,t.jsx)("input",{className:"settings-models-input",type:"text",value:h,disabled:b,placeholder:e.baseUrl||d("settings.models.baseUrlDefault"),"aria-label":d("settings.models.baseUrl"),onChange:e=>{m(e.target.value)}})]}),(0,t.jsx)(cc,{models:v,onChange:y,disabled:b,probe:{baseUrl:h.trim(),apiKey:C},probeBlocked:void 0!==_?d(`settings.models.${_}`):void 0,onFetchError:w})]})]}),void 0!==j?(0,t.jsx)("p",{className:"settings-models-error",children:j}):null,(0,t.jsxs)("div",{className:"settings-models-editor-actions",children:[(0,t.jsx)("button",{type:"button",className:"secondary-btn",disabled:b,onClick:()=>r(!1),children:d("settings.models.cancel")}),(0,t.jsx)("button",{type:"button",className:"settings-models-primary",disabled:P,onClick:()=>{I()},children:d(b?s?"settings.models.creating":"settings.models.applying":s?"settings.models.create":"settings.models.apply")})]})]})}function cv({size:e=14}){return(0,t.jsx)("svg",{width:e,height:e,viewBox:"0 0 16 16",fill:"none","aria-hidden":!0,children:(0,t.jsx)("path",{d:"M8 3v10M3 8h10",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})})}function cy({providers:e,models:a,refresh:s,setError:i}){let r=(0,f.useT)(),{markSaving:l,markSaved:o}=oj(),[c,d]=(0,n.useState)(null),[u,p]=(0,n.useState)(!1),[h,m]=(0,n.useState)(!1),[g,x]=(0,n.useState)(null),[v,y]=(0,n.useState)(!1),[b,k]=(0,n.useState)(void 0),[j,w]=(0,n.useState)(null),[_,N]=(0,n.useState)(()=>new Set),C=e.some(e=>e.credentialConfigured),S=e.filter(e=>e.directory),I=u?e.find(e=>e.directory&&e.id===c)??null:null,P=e=>{w(e),o()},T=async()=>{if(null!==g&&!v){y(!0),k(void 0),l();try{await (0,e5.apiFetch)(`/v1/provider-profiles/${encodeURIComponent(g.id)}`,{method:"DELETE"}),i(null),x(null),await s(),o()}catch(e){k(e.message)}finally{y(!1)}}};return(0,t.jsxs)("section",{className:"settings-tab-section","aria-labelledby":"settings-models-heading",children:[(0,t.jsxs)("header",{children:[(0,t.jsx)("h2",{id:"settings-models-heading",children:r("settings.models.title")}),(0,t.jsx)("p",{children:r("settings.models.intro")})]}),null!==j&&(0,t.jsx)("p",{className:"settings-models-saved",role:"status","aria-live":"polite",children:r("settings.models.savedProvider",{provider:j})}),(0,t.jsx)("ul",{className:"settings-models-rows",children:e.map(e=>{if(!C&&e.directory&&!_.has(e.id))return(0,t.jsx)("li",{className:"settings-models-setupcard",children:(0,t.jsx)(cx,{provider:e,models:[],creating:!0,refresh:s,setError:i,onSaved:P,onClose:()=>{N(t=>new Set([...t,e.id]))}})},e.id);let n=!u&&c===e.id;return(0,t.jsxs)("li",{className:"settings-models-rowcard",children:[(0,t.jsxs)("div",{className:"settings-models-rowhead",children:[(0,t.jsxs)("span",{className:"settings-models-rowidentity",children:[(0,t.jsx)("span",{className:"settings-models-rowname",children:e.name}),e.custom?(0,t.jsx)("span",{className:"settings-models-rowtag",children:r("settings.models.customTag")}):null,(0,t.jsx)(o5,{configured:e.credentialConfigured,missing:!e.credentialConfigured})]}),(0,t.jsxs)("span",{className:"settings-models-rowactions",children:[(0,t.jsx)("button",{type:"button",className:"settings-models-btn","aria-label":r("settings.models.editProvider",{provider:e.name}),onClick:()=>{w(null),m(!1),p(!1),d(n?null:e.id)},children:r("settings.models.edit")}),e.directory?null:(0,t.jsx)("button",{type:"button",className:"settings-models-btn settings-models-danger","aria-label":r("settings.models.removeProvider",{provider:e.name}),onClick:()=>{w(null),k(void 0),x(e)},children:r("settings.models.remove")})]})]}),n&&(0,t.jsx)(cx,{provider:e,models:a.filter(t=>t.providerId===e.id),creating:e.directory,refresh:s,setError:i,onSaved:P,onClose:()=>{d(null)}})]},e.id)})}),(0,t.jsxs)("div",{className:"settings-models-addblock",children:[null!==I&&(0,t.jsxs)("div",{className:"settings-models-addcard",children:[(0,t.jsxs)("div",{className:"settings-models-field",children:[(0,t.jsx)("span",{className:"settings-models-fieldlabel",children:r("settings.models.provider")}),(0,t.jsx)("select",{className:"settings-models-input settings-models-select",value:I.id,"aria-label":r("settings.models.provider"),onChange:e=>{d(e.target.value)},children:S.map(e=>(0,t.jsx)("option",{value:e.id,children:e.name},e.id))})]}),(0,t.jsx)(cx,{provider:I,models:[],creating:!0,hideTitle:!0,refresh:s,setError:i,onSaved:P,onClose:()=>{p(!1),d(null)}},I.id)]}),h&&(0,t.jsx)("div",{className:"settings-models-addcard",children:(0,t.jsx)(cp,{taken:e.map(e=>e.id),refresh:s,setError:i,onSaved:P,onClose:e=>{m(!1),e&&s()}})}),null===I&&!h&&(0,t.jsxs)("div",{className:"settings-models-addactions",children:[(0,t.jsxs)("button",{type:"button",className:"settings-models-addbutton",disabled:0===S.length,onClick:()=>{w(null),m(!1),p(!0),d(S[0]?.id??null)},children:[(0,t.jsx)(cv,{}),r("settings.models.add")]}),(0,t.jsxs)("button",{type:"button",className:"settings-models-addbutton",onClick:()=>{w(null),p(!1),d(null),m(!0)},children:[(0,t.jsx)(cv,{}),r("settings.models.customAdd")]})]})]}),(0,t.jsx)(ch,{open:null!==g,providerName:g?.name??"",busy:v,failure:b,onCancel:()=>{v||(x(null),k(void 0))},onConfirm:()=>{T()}})]})}let cb=[{kind:"tool",title:"Tool policy",description:"Permission mode and allowed local execution boundaries.",defaultConfig:'{"mode":"restricted","allowedTools":["read","ls","grep","find"],"allowedExecutables":["git","rg"],"maxTimeoutSeconds":300}'},{kind:"turn",title:"Turn routing",description:"Model routing candidates and upgrade thresholds.",defaultConfig:'{"mode":"context_upgrade","threshold":0.7,"candidateModelProfileIds":[]}'},{kind:"vision",title:"Vision",description:"Native image handling and descriptor fallback boundaries.",defaultConfig:'{"mode":"reject","maxImageBytes":10485760,"maxPixels":40000000}'}];function ck({policies:e,refresh:n,setError:a}){let{markSaving:s,markSaved:i}=oj();async function r(e,t){e.preventDefault();let r=e.currentTarget,l=new FormData(r);try{let e=JSON.parse(String(l.get("config")||"{}"));s(),await (0,e5.apiFetch)("/v1/policy-profiles",{method:"POST",body:JSON.stringify({name:l.get("name"),kind:t,config:e})}),r.reset(),a(null),await n(),i()}catch(e){a(e.message)}}async function l(e){s();try{await (0,e5.apiFetch)(`/v1/policy-profiles/${encodeURIComponent(e)}/default`,{method:"PUT"}),a(null),await n(),i()}catch(e){a(e.message)}}async function o(e){if(await rc({title:`Deactivate policy “${e.name}” v${e.version}?`,description:"Existing Runs keep their frozen policy. New Runs will no longer select it as the default.",confirmLabel:"Deactivate",tone:"danger"})){s();try{await (0,e5.apiFetch)(`/v1/policy-profiles/${encodeURIComponent(e.id)}`,{method:"DELETE"}),a(null),await n(),i()}catch(e){a(e.message)}}}return(0,t.jsxs)("section",{className:"settings-tab-section","aria-labelledby":"settings-policies-heading",children:[(0,t.jsxs)("header",{children:[(0,t.jsx)("h2",{id:"settings-policies-heading",children:"Policies"}),(0,t.jsx)("p",{children:"Immutable versioned execution, routing, and image handling configuration."})]}),cb.map(n=>(0,t.jsx)(cj,{...n,policies:e,onSubmit:r,onDefault:l,onDeactivate:o},n.kind))]})}function cj({kind:e,title:n,description:a,policies:s,defaultConfig:i,onSubmit:r,onDefault:l,onDeactivate:o}){return(0,t.jsxs)(oN,{title:n,description:a,children:[(0,t.jsxs)("form",{className:"settings-form policy-form",onSubmit:t=>r(t,e),children:[(0,t.jsxs)("label",{children:["Name",(0,t.jsx)("input",{name:"name",required:!0})]}),(0,t.jsxs)("label",{children:["Configuration JSON",(0,t.jsx)("textarea",{name:"config",required:!0,defaultValue:i})]}),(0,t.jsx)("button",{type:"submit",children:"Create version"})]}),(0,t.jsx)(oS,{children:s.filter(t=>t.kind===e).map(e=>(0,t.jsx)(oC,{title:e.name,meta:`v${e.version} \xb7 ${String(e.config.mode??"configured")}`,actions:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("button",{className:"secondary-btn",disabled:"active"!==e.status,onClick:()=>l(e.id),children:"Use as default"}),(0,t.jsx)("button",{className:"secondary-btn",type:"button",disabled:"active"!==e.status,title:"Deactivate policy","aria-label":`Deactivate policy ${e.name} version ${e.version}`,onClick:()=>o(e),children:(0,t.jsx)(A,{size:14,"aria-hidden":"true"})})]})},e.id))})]})}let cw=o("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"}]]),c_=o("info",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]]),cN=o("save",[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]]);function cC(e){return Promise.all([(0,e5.apiFetch)("/v1/prompt-templates").catch(()=>null),e?(0,e5.apiFetch)(`/v1/projects/${encodeURIComponent(e)}/prompt-templates`).catch(()=>null):Promise.resolve(null)])}function cS({projectId:e,setError:a}){let[s,i]=(0,n.useState)(null),[r,l]=(0,n.useState)(null),[o,c]=(0,n.useState)(void 0),[d,u]=(0,n.useState)(!1),[p,h]=(0,n.useState)(""),[m,f]=(0,n.useState)(""),[g,x]=(0,n.useState)(""),[v,y]=(0,n.useState)(""),[b,k]=(0,n.useState)(!1),{markSaving:j,markSaved:w}=oj(),[_,N]=(0,n.useState)(null),[C,I]=(0,n.useState)(""),[T,M]=(0,n.useState)(""),[R,E]=(0,n.useState)(""),[A,$]=(0,n.useState)(null),[z,F]=(0,n.useState)(null),L=(0,n.useCallback)(async()=>{try{let[t,n]=await cC(e);i(t),l(n),c(e),a(null)}catch{c(e),a("Failed to load prompt templates")}},[e,a]);(0,n.useEffect)(()=>{let t=!1;return cC(e).then(([n,s])=>{t||(i(n),l(s),c(e),a(null))}).catch(()=>{t||(c(e),a("Failed to load prompt templates"))}),()=>{t=!0}},[e,a]);let D=r??s;async function O(e){if(e.preventDefault(),p.trim()&&v.trim()){k(!0),j();try{await (0,e5.apiFetch)("/v1/prompt-templates",{method:"POST",body:JSON.stringify({name:p.trim(),description:m.trim(),argumentHint:g.trim(),body:v})}),h(""),f(""),x(""),y(""),u(!1),await L(),w()}catch(e){a(e.message)}finally{k(!1)}}}async function q(e){j();try{await (0,e5.apiFetch)(`/v1/prompt-templates/${encodeURIComponent(e)}`,{method:"DELETE"}),F(null),await L(),w()}catch(e){a(e.message)}}async function B(e){if(R.trim()){k(!0),j();try{await (0,e5.apiFetch)(`/v1/prompt-templates/${encodeURIComponent(e)}`,{method:"PUT",body:JSON.stringify({description:C.trim(),argumentHint:T.trim(),body:R})}),N(null),await L(),w()}catch(e){a(e.message)}finally{k(!1)}}}if(o!==e&&!s)return(0,t.jsx)("div",{className:"settings-tab-section",children:(0,t.jsx)("p",{children:"Loading…"})});let U=[...s?.diagnostics??[],...r?.diagnostics??[]],H=s?.globalRecoveryMode??!1;return(0,t.jsxs)("section",{className:"settings-tab-section","aria-labelledby":"settings-templates-heading",children:[(0,t.jsxs)("header",{children:[(0,t.jsx)("h2",{id:"settings-templates-heading",children:"Prompt templates"}),(0,t.jsx)("p",{children:"Manage slash-command prompt templates across builtin, settings, global, and project sources."})]}),U.length>0&&(0,t.jsx)("div",{className:"templates-diag-banner",role:"status",children:U.map((e,n)=>(0,t.jsxs)("div",{className:`templates-diag ${"warning"===e.level?"diag-warn":"diag-info"}`,children:[(0,t.jsx)("span",{className:"templates-diag-icon",children:"warning"===e.level?(0,t.jsx)(cw,{size:14}):(0,t.jsx)(c_,{size:14})}),(0,t.jsxs)("span",{className:"templates-diag-msg",children:[(0,t.jsx)("code",{children:e.code})," ",e.message]})]},n))}),D&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("header",{className:"templates-section-header",children:(0,t.jsxs)("h3",{children:["Effective templates ",e?"(project)":"(global)"]})}),0===D.templates.length?(0,t.jsxs)("p",{className:"templates-empty",children:["No templates available. Create a global template below or add markdown files to your project's ",(0,t.jsx)("code",{children:".ennote/prompts/"})," directory."]}):(0,t.jsx)("ul",{className:"templates-list",children:D.templates.map(e=>(0,t.jsxs)("li",{className:"template-row",children:[(0,t.jsxs)("span",{className:"template-name",children:["/",e.name]}),e.argumentHint&&(0,t.jsx)("span",{className:"template-hint",children:e.argumentHint}),(0,t.jsx)("span",{className:"template-source source-{t.source}",children:e.source}),(0,t.jsx)("span",{className:"template-desc",children:e.description})]},e.name))})]}),(0,t.jsxs)("header",{className:"templates-section-header",children:[(0,t.jsx)("h3",{children:"My global templates"}),!H&&(0,t.jsxs)("button",{type:"button",className:"settings-btn",onClick:()=>u(!d),children:[(0,t.jsx)(S,{size:14})," New"]})]}),H&&(0,t.jsxs)("div",{className:"templates-diag diag-warn templates-diag-block",children:[(0,t.jsx)(cw,{size:14}),(0,t.jsx)("span",{children:"Global store is in recovery mode. Delete some entries to restore normal operation. Create is disabled."})]}),d&&(0,t.jsxs)("form",{className:"template-edit-form",onSubmit:O,children:[(0,t.jsxs)("label",{children:["Name ",(0,t.jsx)("input",{value:p,onChange:e=>h(e.target.value),placeholder:"my-command",required:!0,disabled:b})]}),(0,t.jsxs)("label",{children:["Description ",(0,t.jsx)("input",{value:m,onChange:e=>f(e.target.value),placeholder:"Optional",disabled:b})]}),(0,t.jsxs)("label",{children:["Argument hint ",(0,t.jsx)("input",{value:g,onChange:e=>x(e.target.value),placeholder:"<path> [focus]",disabled:b})]}),(0,t.jsxs)("label",{children:["Body ",(0,t.jsx)("textarea",{value:v,onChange:e=>y(e.target.value),rows:4,placeholder:"Template body with $1, $@, etc.",required:!0,disabled:b})]}),(0,t.jsxs)("div",{className:"template-form-actions",children:[(0,t.jsxs)("button",{type:"submit",className:"settings-btn primary",disabled:b||!p.trim()||!v.trim(),children:[(0,t.jsx)(cN,{size:14})," ",b?"Saving…":"Create"]}),(0,t.jsx)("button",{type:"button",className:"settings-btn",onClick:()=>u(!1),children:"Cancel"})]})]}),s?.globalTemplates&&s.globalTemplates.length>0&&(0,t.jsx)("ul",{className:"templates-list",children:s.globalTemplates.map(e=>(0,t.jsxs)("li",{className:`template-row ${!e.valid?"invalid":""}`,children:[(0,t.jsxs)("span",{className:"template-name",children:["/",e.name]}),e.argumentHint&&(0,t.jsx)("span",{className:"template-hint",children:e.argumentHint}),e.valid?(0,t.jsx)("span",{className:"template-desc",children:e.description}):(0,t.jsxs)("span",{className:"template-desc diag-text",children:[e.diagnostic?.code,": ",e.diagnostic?.message]}),(0,t.jsx)("div",{className:"template-actions",children:e.editable&&_===e.name?(0,t.jsxs)("div",{className:"template-edit-form template-edit-form-inline",children:[e.valid&&(0,t.jsxs)("div",{className:"template-edit-readonly",children:["Name: ",e.name]}),(0,t.jsxs)("label",{children:["Description ",(0,t.jsx)("input",{value:C,onChange:e=>I(e.target.value),disabled:b})]}),(0,t.jsxs)("label",{children:["Argument hint ",(0,t.jsx)("input",{value:T,onChange:e=>M(e.target.value),disabled:b})]}),(0,t.jsxs)("label",{children:["Body ",(0,t.jsx)("textarea",{value:R,onChange:e=>E(e.target.value),rows:4,disabled:b})]}),(0,t.jsxs)("div",{className:"template-form-actions",children:[(0,t.jsxs)("button",{type:"button",className:"settings-btn primary",onClick:()=>B(e.name),disabled:b||!R.trim(),children:[(0,t.jsx)(cN,{size:14})," ",b?"Saving…":e.valid?"Update":"Repair"]}),(0,t.jsx)("button",{type:"button",className:"settings-btn",onClick:()=>N(null),children:"Cancel"})]})]}):e.editable?z===e.name?(0,t.jsxs)("span",{className:"template-confirm",children:[(0,t.jsxs)("span",{children:["Delete /",e.name,"?"]}),(0,t.jsx)("button",{type:"button",className:"settings-btn danger",onClick:()=>q(e.name),disabled:b,children:"Delete"}),(0,t.jsx)("button",{type:"button",className:"settings-btn",onClick:()=>F(null),children:"Cancel"})]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("button",{type:"button",className:"settings-btn",onClick:()=>{N(e.name),e.valid?(0,e5.apiFetch)(`/v1/prompt-templates/${encodeURIComponent(e.name)}`).then(e=>{I(e.description),M(e.argumentHint),E(e.body)}).catch(()=>{}):(I(""),M(""),E(""))},children:e.valid?"Edit":"Repair"}),(0,t.jsx)("button",{type:"button",className:"settings-btn danger",onClick:()=>F(e.name),children:(0,t.jsx)(P,{size:14})})]}):(0,t.jsx)("span",{className:"template-manual-cleanup",children:"Manual cleanup required in $ENNOTE_HOME/prompts/"})}),e.valid&&A===e.name&&(0,t.jsx)(cI,{name:e.name,onClose:()=>$(null)})]},e.name))}),(!s?.globalTemplates||0===s.globalTemplates.length)&&!H&&(0,t.jsx)("p",{className:"templates-empty",children:"No global templates yet. Create one above."})]})}function cI({name:e,onClose:a}){let[s,i]=(0,n.useState)(null);return((0,n.useEffect)(()=>{(0,e5.apiFetch)(`/v1/prompt-templates/${encodeURIComponent(e)}`).then(e=>i(e.body)).catch(()=>i("Failed to load"))},[e]),null===s)?(0,t.jsx)("div",{className:"template-body-preview",children:"Loading…"}):(0,t.jsxs)("div",{className:"template-body-preview",children:[(0,t.jsx)("pre",{children:s}),(0,t.jsx)("button",{type:"button",className:"settings-btn",onClick:a,children:"Close"})]})}function cP(e){switch(e){case"general":return(0,t.jsx)(p,{size:15,"aria-hidden":"true"});case"models":return(0,t.jsx)(om,{size:15,"aria-hidden":"true"});case"policies":return(0,t.jsx)(ov,{size:15,"aria-hidden":"true"});case"context":return(0,t.jsx)(of,{size:15,"aria-hidden":"true"});case"templates":return(0,t.jsx)(ei,{size:15,"aria-hidden":"true"});case"mcp":return(0,t.jsx)(ox,{size:15,"aria-hidden":"true"});case"skills":return(0,t.jsx)(X,{size:15,"aria-hidden":"true"});case"packs":return(0,t.jsx)(og,{size:15,"aria-hidden":"true"})}}function cT({open:e,onClose:n,initialTab:a,providers:s,models:i,policies:r,session:l,refresh:o,error:c,setError:d,onSessionUpdated:u,projectId:p}){return e?(0,t.jsx)("div",{className:"settings-dialog-backdrop",onClick:e=>{e.target===e.currentTarget&&n()},children:(0,t.jsx)(ok,{children:(0,t.jsx)(cM,{initialTab:a,onClose:n,providers:s,models:i,policies:r,session:l,refresh:o,error:c,setError:d,onSessionUpdated:u,projectId:p},a??"general")})}):null}function cM({onClose:e,initialTab:a,providers:s,models:i,policies:r,session:l,refresh:o,error:c,setError:d,onSessionUpdated:p,projectId:h}){let g=(0,f.useT)(),{markError:x}=oj(),v=(0,n.useCallback)(e=>{d(e),e&&x(e)},[d,x]),[y,b]=(0,n.useState)(a??"general"),[k,j]=(0,n.useState)(""),w=(0,n.useRef)(null),_=(0,n.useRef)(null),N=(0,n.useRef)(null);M(!0,e),(0,n.useEffect)(()=>{let e=window.requestAnimationFrame(()=>_.current?.focus()),t=e=>{if((e.metaKey||e.ctrlKey)&&"k"===e.key.toLowerCase()){e.preventDefault(),N.current?.focus();return}if("Tab"!==e.key||!w.current)return;let t=Array.from(w.current.querySelectorAll('button:not(:disabled), input:not(:disabled), select:not(:disabled), textarea:not(:disabled), [href], [tabindex]:not([tabindex="-1"])'));if(0===t.length)return;let n=t[0],a=t[t.length-1];e.shiftKey&&document.activeElement===n?(e.preventDefault(),a.focus()):e.shiftKey||document.activeElement!==a||(e.preventDefault(),n.focus())};return window.addEventListener("keydown",t),()=>{window.cancelAnimationFrame(e),window.removeEventListener("keydown",t)}},[]);let C=[{id:"general",label:"General",description:"Appearance and theme",icon:cP("general")},{id:"models",label:"Models",description:"Providers, API keys, and model profiles",icon:cP("models")},{id:"policies",label:"Policies",description:"Tool permission and routing policies",icon:cP("policies")},{id:"context",label:"Context & session",description:l?"Session defaults and compaction":"Compaction policy defaults",icon:cP("context")},{id:"templates",label:"Templates",description:"Slash-command prompt templates",icon:cP("templates")},{id:"mcp",label:"MCP",description:"MCP servers and project bindings",icon:cP("mcp")},{id:"skills",label:"Skills",description:"Skill catalog, marketplace, and updates",icon:cP("skills")},{id:"packs",label:"Packs",description:"Agent Packs: inspect, install, and remove",icon:cP("packs")}],S=k.trim().toLowerCase(),I=""===S?C:C.filter(e=>`${e.label} ${e.description}`.toLowerCase().includes(S));return(0,t.jsx)("div",{ref:w,className:"settings-dialog-shell",role:"dialog","aria-modal":"true","aria-label":"Settings",children:(0,t.jsxs)("div",{className:"settings-dialog-body",children:[(0,t.jsxs)("div",{className:"settings-dialog-tabs",role:"tablist","aria-label":"Settings sections",children:[(0,t.jsx)("div",{id:"settings-dialog-title",className:"settings-dialog-navtitle",children:"Settings"}),(0,t.jsxs)("label",{className:"settings-dialog-search",children:[(0,t.jsx)(u,{size:14,"aria-hidden":"true"}),(0,t.jsx)("input",{ref:N,type:"text",value:k,placeholder:g("settings.search.placeholder"),"aria-label":g("settings.search.aria"),onChange:e=>(e=>{j(e);let t=e.trim().toLowerCase();if(""===t)return;let n=C.filter(e=>`${e.label} ${e.description}`.toLowerCase().includes(t));n.length>0&&!n.some(e=>e.id===y)&&b(n[0].id)})(e.target.value),onKeyDown:e=>{if("Escape"===e.key&&""!==k&&!e.nativeEvent.isComposing){e.preventDefault(),e.stopPropagation(),j("");return}"Enter"===e.key&&I.length>0&&(e.preventDefault(),b(I[0].id))}}),""!==k&&(0,t.jsx)("button",{type:"button","aria-label":g("settings.search.clear"),onClick:()=>j(""),children:(0,t.jsx)(m,{size:12,"aria-hidden":"true"})})]}),0===I.length&&(0,t.jsx)("div",{className:"settings-dialog-empty",children:g("settings.search.empty",{query:k.trim()})}),I.map((e,n)=>{let a=y===e.id;return(0,t.jsxs)("button",{type:"button",onClick:()=>b(e.id),onKeyDown:e=>{let t=null;if(("ArrowRight"===e.key||"ArrowDown"===e.key)&&(t=(n+1)%I.length),("ArrowLeft"===e.key||"ArrowUp"===e.key)&&(t=(n-1+I.length)%I.length),"Home"===e.key&&(t=0),"End"===e.key&&(t=I.length-1),null===t)return;e.preventDefault();let a=I[t];b(a.id),window.requestAnimationFrame(()=>document.getElementById(`settings-tab-${a.id}`)?.focus())},className:`settings-dialog-tab ${a?"active":""}`,role:"tab",id:`settings-tab-${e.id}`,"aria-selected":a,"aria-controls":`settings-panel-${e.id}`,children:[(0,t.jsx)("span",{className:"settings-tab-icon",children:e.icon}),(0,t.jsx)("span",{className:"settings-tab-label",children:e.label})]},e.id)})]}),(0,t.jsxs)("div",{className:"settings-dialog-content",children:[(0,t.jsxs)("div",{className:"settings-dialog-header",children:[(0,t.jsxs)("div",{className:"settings-dialog-actions",children:[(0,t.jsx)(ow,{}),(0,t.jsx)("span",{id:"settings-dialog-current",className:"settings-dialog-current",children:C.find(e=>e.id===y)?.label})]}),(0,t.jsx)("button",{ref:_,type:"button",className:"settings-dialog-close",title:"Close settings","aria-label":"Close settings",onClick:e,children:(0,t.jsx)(m,{size:14,"aria-hidden":"true"})})]}),c&&(0,t.jsxs)("div",{className:"error-bar",role:"alert",children:[(0,t.jsx)("span",{children:c}),(0,t.jsx)("button",{type:"button",onClick:()=>d(null),"aria-label":"Dismiss error",children:(0,t.jsx)(m,{size:15,"aria-hidden":"true"})})]}),(0,t.jsxs)("div",{className:"settings-dialog-panel",role:"tabpanel",id:`settings-panel-${y}`,"aria-labelledby":`settings-tab-${y}`,children:["general"===y&&(0,t.jsx)("div",{className:"settings-tab-scroll",children:(0,t.jsx)(oD,{})}),"models"===y&&(0,t.jsx)("div",{className:"settings-tab-scroll",children:(0,t.jsx)(cy,{providers:s,models:i,refresh:o,setError:v})}),"policies"===y&&(0,t.jsx)("div",{className:"settings-tab-scroll",children:(0,t.jsx)(ck,{policies:r,refresh:o,setError:v})}),"context"===y&&(0,t.jsx)("div",{className:"settings-tab-scroll",children:(0,t.jsx)(oI,{policies:r,models:i,session:l,refresh:o,setError:v,onSessionUpdated:p})}),"templates"===y&&(0,t.jsx)("div",{className:"settings-tab-scroll",children:(0,t.jsx)(cS,{projectId:h,setError:v})}),"mcp"===y&&(0,t.jsx)("div",{className:"settings-tab-scroll",children:(0,t.jsx)(oJ,{projectId:h,setError:v})}),"skills"===y&&(0,t.jsx)("div",{className:"settings-tab-scroll",children:(0,t.jsx)(o4,{projectId:h,setError:v})}),"packs"===y&&(0,t.jsx)("div",{className:"settings-tab-scroll",children:(0,t.jsx)(oB,{setError:v})})]})]})]})})}var cR=e.i(85026);function cE({settingsOpen:e,settingsTab:n,onCloseSettings:a,providers:s,models:i,policies:r,session:l,projectId:o,error:c,refresh:d,setError:u,onSessionUpdated:p}){let{createProjectOpen:h,createProjectBusy:m,confirmCreateProject:f,cancelCreateProject:g}=(0,cR.useWorkspace)();return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(cT,{open:e,onClose:a,initialTab:n,providers:s,models:i,policies:r,session:l,refresh:d,error:c,setError:u,onSessionUpdated:p,projectId:o}),(0,t.jsx)(rd,{}),h&&(0,t.jsx)(oh,{busy:m,onCreate:f,onClose:g})]})}var cA=e.i(48686);function c$({workerUnreachable:e}){return e?(0,t.jsx)("div",{className:cA.default.banner,role:"status","data-testid":"offline-banner",children:"Worker unreachable — Ennote is read-only until it returns."}):null}function cz({initialWidth:e,minWidth:t,maxWidth:a,storageKey:s,direction:i="right",resolveStored:r,cssVariable:l}){let[o,c]=(0,n.useState)(e),[d,u]=(0,n.useState)(!1),p=(0,n.useRef)(e),h=(0,n.useCallback)(e=>{let n=Math.max(t,Math.min(a,e));c(n),p.current=n,l&&document.documentElement.style.setProperty(l,`${n}px`)},[t,a,l]);(0,n.useEffect)(()=>{let e=window.requestAnimationFrame(()=>{let e=p.current;try{let n=localStorage.getItem(s),i=n?Number.parseInt(n,10):NaN;Number.isFinite(i)&&(r?e=r(i):i>=t&&i<=a&&(e=i))}catch{}h(e)});return()=>window.cancelAnimationFrame(e)},[s,t,a,r,h]);let m=(0,n.useCallback)(()=>{u(!0)},[]),f=(0,n.useCallback)(e=>{let t="left"===i?-1:1;h(p.current+e*t)},[h,i]);return{beginResize:m,endResize:(0,n.useCallback)(()=>{u(!1);try{localStorage.setItem(s,String(p.current))}catch{}},[s]),isResizing:d,resizeBy:f,width:o}}let cF="ennote:sidebar:collapsed-projects";function cL(){try{let e=window.localStorage.getItem(cF);return e?new Set(JSON.parse(e)):new Set}catch{return new Set}}let cD="ennote-onboarding-done";function cO(){let[e,t]=(0,n.useState)([]),[a,s]=(0,n.useState)([]),[i,r]=(0,n.useState)([]),[l,o]=(0,n.useState)(null),[c,d]=(0,n.useState)(!0),u=(0,n.useRef)(0),p=(0,n.useRef)(null),h=(0,n.useCallback)(async()=>{p.current?.abort();let e=new AbortController;p.current=e;let n=++u.current;try{let[a,i,l]=await Promise.all([(0,e5.apiFetch)("/v1/provider-profiles",{signal:e.signal}),(0,e5.apiFetch)("/v1/model-profiles",{signal:e.signal}),(0,e5.apiFetch)("/v1/policy-profiles",{signal:e.signal})]);if(e.signal.aborted||u.current!==n)return;t(a),s(i),r(l),o(null)}catch(t){e.signal.aborted||u.current!==n||o(t.message)}finally{e.signal.aborted||u.current!==n||d(!1)}},[]);return(0,n.useEffect)(()=>{let e=window.setTimeout(()=>void h(),0);return()=>{window.clearTimeout(e),p.current?.abort()}},[h]),{providers:e,models:a,policies:i,error:l,loading:c,setError:o,refresh:h}}let cq={provider_configuration_invalid:"The provider runtime configuration is invalid.",provider_credential_unavailable:"The configured credential could not be resolved.",provider_authentication_failed:"The provider rejected the configured credential.",provider_model_not_found:"The configured model was not found by the provider.",provider_rate_limited:"The provider rate limit was reached. Try again later.",provider_request_timeout:"The provider did not respond before the timeout.",provider_request_rejected:"The provider rejected the model request.",provider_unavailable:"The provider is currently unavailable.",model_protocol_error:"The provider returned an invalid response.",model_stream_interrupted:"The provider response was interrupted.",context_overflow:"The request exceeds the model context window.",context_overflow_after_compaction:"The request still exceeds the context window after compaction.",context_overflow_in_run:"The active run exceeded the model context window."};function cB(e){let t="string"==typeof e?e:"";return cq[t]??(t?`The run failed (${t}).`:"The run failed.")}function cU(e,t){return e instanceof Error&&e.message?e.message:"string"==typeof e&&e.trim()?e:(console.warn("[ennote] non-Error rejection captured",e),t)}function cH(e){let t=e.toolCallId??e.id??e.recordId;return null!=t?String(t):`event-${e.callIndex??"unknown"}`}let cW={optimistic:[],settled:new Set};function cV(e,t){switch(t.type){case"queue":return{...e,optimistic:[...e.optimistic,t.row]};case"settle":{if(!t.id)return e;let n=new Set(e.settled);return n.add(t.id),{optimistic:e.optimistic.filter(e=>e.id!==t.id),settled:n}}case"reset":return cW}}function cK(){return"u">typeof crypto&&crypto.randomUUID?crypto.randomUUID():Math.random().toString(36).slice(2)+Date.now().toString(36)}class cG extends Error{}async function cJ(e,t,n){let a=await (0,e5.apiResponse)(`/v1/runs/${encodeURIComponent(e)}/events`,{signal:n});if(!a.ok)throw Error(`HTTP ${a.status}`);let s=a.body?.getReader();if(!s)return!1;let i=new TextDecoder,r="";try{for(;;){let{done:e,value:n}=await s.read();if(e)break;let a=(r+=i.decode(n,{stream:!0})).split("\n");for(let e of(r=a.pop()??"",a)){let n=e.endsWith("\r")?e.slice(0,-1):e;if(!n.startsWith("data:"))continue;let a=JSON.parse(n.slice(5).trimStart());switch(a.type){case"context_compaction_started":t(iN("compacting"));break;case"context_compaction_retry_scheduled":t(iN("compaction_retry_wait",String(a.payload?.delayMs??0)));break;case"context_compaction_retry_started":t(iN("compaction_retry"));break;case"context_compaction_completed":t(iN("checkpoint_ready"));break;case"context_compaction_failed":throw new cG("Context compaction failed.");case"context_compaction_cancelled":case"run_cancelled":throw new cG("Context compaction was cancelled.");case"run_succeeded":return!0;case"run_failed":throw new cG(cB(a.payload?.errorCode))}}}}finally{s.releaseLock()}return!1}async function cY(e,t,n,a,s,i,r,l,o){let c=new Headers;o.value&&c.set("Last-Event-ID",o.value);let d=await (0,e5.apiResponse)(`/v1/runs/${encodeURIComponent(e)}/events`,{signal:i,headers:c});if(!d.ok)throw Error(`HTTP ${d.status}`);let u=d.body?.getReader();if(!u)return!1;let p=new TextDecoder,h="",{assistants:m,toolDeltas:f,toolOutputs:g}=l,x=null,v=!1,{usageByIteration:y}=l;function b(e){let t=m.get(e)??{text:"",thinking:""};return m.set(e,t),t}function k(n){let a=b(n);t({id:`${e}-assistant-${n}`,role:"assistant",text:a.text,thinking:a.thinking})}function j(n,a,s){let i=cH(n),r=n.arguments&&"object"==typeof n.arguments&&!Array.isArray(n.arguments)?n.arguments:void 0;t({id:`${e}-tool-${i}`,role:"tool",kind:"tool",toolCallId:i,toolName:String(n.toolName??n.name??"tool"),text:String(n.content??n.reason??s),arguments:r,argumentsFragment:"string"==typeof n.argumentsFragment?n.argumentsFragment:void 0,isError:!!n.isError||"failed"===a,toolState:a,runId:e})}try{for(;;){let{done:i,value:c}=await u.read();if(i)break;let d=(h+=p.decode(c,{stream:!0})).split("\n");for(let i of(h=d.pop()??"",d)){let c=i.endsWith("\r")?i.slice(0,-1):i;if(c.startsWith("id:")){let e=c.slice(3).trim();e&&(o.value=e);continue}if(c.startsWith("event:")){x=c.slice(6).trim(),v="live"===x;continue}if(c.startsWith(":")||!c.startsWith("data:"))continue;let d=JSON.parse(c.slice(5).trimStart()),u=v;v=!1;let p=d.payload??{},h="number"==typeof p.iteration?p.iteration:1;switch(d.type){case"usage_updated":{let e=p.usage;e&&function(e,t){y.set(e,{uncachedInputTokens:Number(t.uncachedInputTokens??0),cacheReadTokens:Number(t.cacheReadTokens??0),cacheWriteTokens:Number(t.cacheWriteTokens??0),outputTokens:Number(t.outputTokens??0),reasoningTokens:Number(t.reasoningTokens??0)});let n={uncachedInputTokens:0,cacheReadTokens:0,cacheWriteTokens:0,outputTokens:0,reasoningTokens:0};for(let e of y.values())n.uncachedInputTokens+=e.uncachedInputTokens,n.cacheReadTokens+=e.cacheReadTokens,n.cacheWriteTokens+=e.cacheWriteTokens,n.outputTokens+=e.outputTokens,n.reasoningTokens+=e.reasoningTokens;a(n)}(h,e);break}case"context_usage":p&&"number"==typeof p.contextWindow&&s(p);break;case"text_delta":case"thinking_delta":if(!u)break;"text_delta"===d.type?b(h).text+=String(p.text??""):b(h).thinking+=String(p.text??""),k(h);break;case"model_call_retry_scheduled":m.set(h,{text:"",thinking:""}),k(h),n(iN("model_retry",String(p.delayMs??0)));break;case"context_pruned":n(iN("preparing_context"));break;case"context_compaction_planned":n(iN("compaction_queued"));break;case"context_compaction_started":n(iN("compacting"));break;case"context_compaction_retry_scheduled":n(iN("compaction_retry_wait",String(p.delayMs??0)));break;case"context_compaction_completed":n(iN("checkpoint_ready"));break;case"run_context_compaction_planned":n(iN("preparing_run_context"));break;case"run_context_compaction_started":n(iN("compacting_run"));break;case"run_context_compaction_retry_scheduled":n(iN("run_compaction_retry",String(p.delayMs??0)));break;case"run_context_compaction_completed":n(iN("run_context_compacted"));break;case"run_context_compaction_failed":n(iN("run_compaction_skipped"));break;case"run_context_compaction_cancelled":n("");break;case"context_checkpoint_selected":n(iN("using_checkpoint"));break;case"output_truncated":n(iN(Number(p.partialToolCallCount??0)>0?"recovering_tool":"output_truncated"));break;case"tool_call_delta":{if(!u)break;let e=p.id?String(p.id):"";if(e&&l.finishedTools.has(e))break;let t=`${h}:${p.index??0}`,n=f.get(t)??{id:"",name:"tool",argumentsFragment:""};p.id&&(n.id=String(p.id)),p.name&&(n.name=String(p.name)),n.argumentsFragment+=String(p.argumentsFragment??""),f.set(t,n),j({...p,toolCallId:n.id||t,toolName:n.name,argumentsFragment:n.argumentsFragment},"pending","Collecting tool arguments…");break}case"child_progress":var w;if(!u)break;w={delegationGroupId:String(p.delegationGroupId??""),taskName:String(p.taskName??""),childRunId:String(p.childRunId??""),activity:String(p.activity??""),tokens:Number(p.tokens??0)},ru?.(w);break;case"tool_output_delta":{if(!u)break;let n=function(e){let t=e.toolCallId,n=e.stream,a=e.text;if("string"!=typeof t||""===t)return null;let s="string"==typeof n&&({stdout:!0,stderr:!0,progress:!0})[n]?n:null;if(!s||"string"!=typeof a)return null;let i=e.toolName;return void 0!==i&&"string"!=typeof i?null:{toolCallId:t,stream:s,text:a,...void 0===i?{}:{toolName:i}}}(p);if(!n)break;let a=n.toolCallId;if(l.finishedTools.has(a))break;let s=n.stream,i=n.text,r=g.get(a)??{text:"",name:""};n.toolName&&(r.name=n.toolName),"stderr"===s?r.text+=`[stderr] ${i}`:r.text+=i,g.set(a,r),t({id:`${e}-tool-${a}`,role:"tool",kind:"tool",toolCallId:a,...r.name?{toolName:r.name}:{},text:r.text,isError:!1,toolState:"running",runId:e});break}case"tool_call_started":{let e=cH(p);l.finishedTools.delete(e),l.toolOutputs.delete(e),n(iN("running_tool",String(p.toolName??"tool"))),j(p,"running","Running");break}case"tool_call_completed":{n(""),("delegate_tasks"===p.toolName||"delegate_heroes"===p.toolName)&&r.delegated();let e=cH(p);g.delete(e),l.finishedTools.add(e),j(p,p.isError?"failed":"completed","No output");break}case"tool_call_failed":{let e=cH(p);g.delete(e),l.finishedTools.add(e),j(p,"failed","Tool call failed.");break}case"tool_policy_denied":case"tool_policy_terminated":case"tool_call_skipped":l.finishedTools.add(cH(p)),j(p,String(p.reason??"").includes("approval_rejected")?"rejected":"failed","Tool call skipped.");break;case"model_route_selected":n(iN("using_model",String(p.apiModel??"selected model")));break;case"vision_fallback_started":n(iN("describing_image"));break;case"vision_fallback_completed":n(iN("image_ready"));break;case"approval_requested":n(iN("waiting_approval")),r.requested();break;case"approval_resolved":n(iN("resuming")),r.resolved();break;case"follow_up_consumed":{let e=String(p.queueItemId??"");e&&r.followUpConsumed(e);break}case"input_cancelled":{let e=String(p.queueItemId??"");e&&r.inputCancelled(e);break}case"run_succeeded":return n(iN("completed")),!0;case"run_cancelled":return n(iN("cancelled")),!0;case"run_interrupted":return n(iN("interrupted")),!0;case"run_failed":throw new cG(cB(p.errorCode))}}}}finally{u.releaseLock()}return!1}function cQ(e,t,n){let a=e.steps[e.steps.length-1];for(let s of(a?.kind==="tool_batch"?a.activities.push(...t):e.steps.push({kind:"tool_batch",id:`batch-${t[0].id}`,activities:t}),t))n.set(s.toolCallId,s)}function cZ(e,t,n){e.set(t,[...e.get(t)??[],n])}function cX(e,t){return/approval[_ ]rejected/i.test(e)?"rejected":t?"failed":"completed"}class c0{read;timer;dirty;constructor(e){this.read=e,this.timer=null,this.dirty=!1}markDirty(){this.dirty=!0,this.timer||(this.timer=setTimeout(()=>{this.timer=null,this.dirty=!1,this.read()},400))}flush(){this.cancelPending(),this.dirty=!1,this.read()}cancelPending(){this.timer&&(clearTimeout(this.timer),this.timer=null)}takeInterruptedRead(){return!!this.dirty&&(this.dirty=!1,!0)}replaceWindow(){this.cancelPending(),this.dirty=!1}}class c1{sessionId;dataBranchId;requestedBranchId;loaded=!1;canonical=[];checkpoints=[];transient=[];nextCursor;hasMore=!1;loading=!1;loadingOlder=!1;error=null;requestVersion=0;requestController=null;activeRun=null;pendingApproval=null;queuedInputs=[];delegationActive=!1;lastSeq=0;workerInstanceId=null;streamController=null;streamOpen=!1;reconnectTimer=null;reconnectAttempt=0;eventCursor;streamPaused=!1;disposed=!1;windowRefresh=new c0(()=>this.refreshLatest());listeners=new Set;snapshot=null;constructor(e){this.sessionId=e}subscribe=e=>(this.listeners.add(e),()=>{this.listeners.delete(e)});getSnapshot=()=>(this.snapshot||(this.snapshot=this.buildSnapshot()),this.snapshot);getServerSnapshot=()=>(this.snapshot||(this.snapshot=this.buildSnapshot()),this.snapshot);ensureLoaded=e=>(this.requestedBranchId=e,this.openStream(),this.loaded&&this.dataBranchId===e)?this.windowRefresh.takeInterruptedRead()?this.refreshLatest():Promise.resolve():(this.resetForBranch(),this.loadInitial(e));loadOlder=async()=>{if(!this.loaded||!this.hasMore||!this.nextCursor||this.loadingOlder)return!1;this.requestVersion+=1;let e=this.requestVersion;this.requestController?.abort();let t=new AbortController;this.requestController=t,this.loadingOlder=!0,this.error=null,this.notify();try{let n,a=await (0,e5.apiFetch)(`/v1/sessions/${encodeURIComponent(this.sessionId)}/messages?limit=50&before=${encodeURIComponent(this.nextCursor)}`,{signal:t.signal});if(t.signal.aborted||this.requestVersion!==e)return!1;let s=a.messages??[],i=this.canonical,r=s.length>0?s[s.length-1].seq??0:0,l=i.length>0?i[0].seq??0:0;if(r>0&&l>0&&r+1!==l)return this.error="History window is out of order; re-open the session to re-sync.",!1;return this.canonical=(n=new Set,[...s,...i].filter(e=>!n.has(e.id)&&(n.add(e.id),!0))),this.nextCursor=a.nextCursor,this.hasMore=a.hasMore,!0}catch(n){return t.signal.aborted||this.requestVersion!==e||(this.error=n.message),!1}finally{t.signal.aborted||this.requestVersion!==e||(this.loadingOlder=!1),this.notify()}};refreshLatest=async()=>{if(this.disposed)return;this.requestVersion+=1;let e=this.requestVersion;this.requestController?.abort();let t=new AbortController;this.requestController=t,this.loadingOlder=!1;try{let[n,a]=await Promise.all([(0,e5.apiFetch)(`/v1/sessions/${encodeURIComponent(this.sessionId)}/messages?limit=50`,{signal:t.signal}),(0,e5.apiFetch)(`/v1/sessions/${encodeURIComponent(this.sessionId)}/compactions`,{signal:t.signal})]);if(t.signal.aborted||this.requestVersion!==e)return;let s=!this.loaded;this.canonical=s?n.messages??[]:function(e,t){if(0===e.length)return t;if(0===t.length)return e;let n=new Set(t.map(e=>e.id)),a=e.findIndex(e=>n.has(e.id));return a<0?t:[...e.slice(0,a),...t]}(this.canonical,n.messages??[]),this.checkpoints=a??[],s&&(this.nextCursor=n.nextCursor,this.hasMore=n.hasMore),this.dataBranchId=this.requestedBranchId,this.loaded=!0,this.loading=!1,this.transient=[],this.error=null}catch(n){t.signal.aborted||this.requestVersion!==e||(this.error=n.message)}finally{this.notify()}};appendTransient=e=>{this.transient.some(t=>t.id===e.id)||(this.transient=[...this.transient,e],this.notify())};upsertTransient=e=>{let t=this.transient.findIndex(t=>t.id===e.id);if(t<0)this.transient=[...this.transient,e];else{let n=[...this.transient];n[t]={...n[t],...e},this.transient=n}this.notify()};removeTransient=e=>{let t=this.transient.filter(t=>t.id!==e);t.length!==this.transient.length&&(this.transient=t,this.notify())};openStream=()=>{this.streamPaused=!1,this.disposed||this.streamOpen||this.streamController||this.openStreamInternal()};pauseStream=()=>{this.streamPaused=!0,this.reconnectTimer&&clearTimeout(this.reconnectTimer),this.reconnectTimer=null,this.reconnectAttempt=0,this.windowRefresh.cancelPending(),this.streamController?.abort(),this.streamController=null,this.clearProjection(),this.streamOpen&&(this.streamOpen=!1,this.notify())};dispose=()=>{this.disposed=!0,this.requestController?.abort(),this.streamController?.abort(),this.reconnectTimer&&clearTimeout(this.reconnectTimer),this.reconnectTimer=null,this.windowRefresh.replaceWindow(),this.listeners.clear()};async openStreamInternal(){if(this.disposed)return;let e=new AbortController;this.streamController=e,this.streamOpen=!0,this.notify();try{let t={};this.eventCursor&&(t["Last-Event-ID"]=this.eventCursor),await (0,e5.apiEventStream)(`/v1/sessions/${encodeURIComponent(this.sessionId)}/events`,e=>this.handleStreamFrame(e),{signal:e.signal,headers:t})}catch{}finally{this.streamController===e&&(this.streamController=null,this.streamOpen=!1,this.notify(),this.disposed||this.streamPaused||this.scheduleReconnect())}}handleStreamFrame(e){e.id&&(this.eventCursor=e.id),this.reconnectAttempt=0;let t=e.data;if(t&&"object"==typeof t)switch(t.type){case"subscribed":this.workerInstanceId=t.instanceId??null,this.lastSeq=t.lastSeq??0,this.applySnapshot(t.snapshot);break;case"snapshot":this.lastSeq=t.lastSeq??0,this.applySnapshot(t.snapshot);break;case"message_committed":this.lastSeq=Math.max(this.lastSeq,t.lastSeq??0),this.disposed||this.windowRefresh.markDirty();break;case"run_succeeded":case"run_failed":case"run_cancelled":case"run_interrupted":case"context_compaction_completed":case"run_context_compaction_completed":this.disposed||this.windowRefresh.flush()}}clearProjection(){(null!==this.activeRun||null!==this.pendingApproval||0!==this.queuedInputs.length||this.delegationActive)&&(this.activeRun=null,this.pendingApproval=null,this.queuedInputs=[],this.delegationActive=!1,this.notify())}applySnapshot(e){e&&(this.activeRun=e.activeRun??null,this.pendingApproval=e.pendingApproval??null,this.queuedInputs=e.queuedInputs??[],this.delegationActive=e.delegationActive??!1,e.checkpoints&&(this.checkpoints=e.checkpoints.map(e=>({id:e.id,status:e.status,reason:e.reason,summary:e.summary,reclaimedTokens:e.reclaimedTokens,firstKeptMessageId:e.firstKeptMessageId,sourceThroughMessageId:e.sourceThroughMessageId,baseLeafMessageId:e.baseLeafMessageId,createdAt:e.createdAt,promptVersion:e.promptVersion,summaryContractDigest:e.summaryContractDigest}))),this.notify())}scheduleReconnect(){if(this.disposed||this.streamPaused||this.reconnectTimer)return;let e=Math.min(1e3*2**this.reconnectAttempt,15e3);this.reconnectAttempt+=1,this.reconnectTimer=setTimeout(()=>{this.reconnectTimer=null,this.openStream()},e)}resetForBranch(){this.requestVersion+=1,this.requestController?.abort(),this.requestController=new AbortController,this.windowRefresh.replaceWindow(),this.dataBranchId=void 0,this.loaded=!1,this.canonical=[],this.checkpoints=[],this.transient=[],this.nextCursor=void 0,this.hasMore=!1,this.error=null,this.loading=!0,this.loadingOlder=!1,this.notify()}async loadInitial(e){let t=this.requestVersion,n=this.requestController;try{let[a,s]=await Promise.all([(0,e5.apiFetch)(`/v1/sessions/${encodeURIComponent(this.sessionId)}/messages?limit=50`,{signal:n.signal}),(0,e5.apiFetch)(`/v1/sessions/${encodeURIComponent(this.sessionId)}/compactions`,{signal:n.signal})]);if(n.signal.aborted||this.requestVersion!==t)return;this.dataBranchId=e,this.canonical=a.messages??[],this.checkpoints=s??[],this.nextCursor=a.nextCursor,this.hasMore=a.hasMore,this.loaded=!0}catch(e){n.signal.aborted||this.requestVersion!==t||(this.error=e.message)}finally{n.signal.aborted||this.requestVersion!==t||(this.loading=!1),this.notify()}}buildSnapshot(){return{sessionId:this.sessionId,dataBranchId:this.dataBranchId,loaded:this.loaded,canonical:this.canonical,checkpoints:this.checkpoints,transient:this.transient,nextCursor:this.nextCursor,hasMore:this.hasMore,loading:this.loading,loadingOlder:this.loadingOlder,error:this.error,activeRun:this.activeRun,pendingApproval:this.pendingApproval,queuedInputs:this.queuedInputs,delegationActive:this.delegationActive,lastSeq:this.lastSeq,workerInstanceId:this.workerInstanceId,streamOpen:this.streamOpen}}notify(){for(let e of(this.snapshot=null,this.listeners))e()}}class c2{stores=new Map;order=[];getStore=e=>{let t=this.stores.get(e);return t||(t=new c1(e),this.stores.set(e,t),this.order.push(e),this.prune(8)),this.touch(e),t};has=e=>this.stores.has(e);disposeStore=e=>{let t=this.stores.get(e);t&&(t.dispose(),this.stores.delete(e));let n=this.order.indexOf(e);n>=0&&this.order.splice(n,1)};prune=e=>{for(;this.order.length>e;){let e=this.order.shift();void 0!==e&&this.disposeStore(e)}};touch(e){let t=this.order.indexOf(e);t>=0&&this.order.splice(t,1),this.order.push(e)}}let c4=new c2,c5={sessionId:"",dataBranchId:void 0,loaded:!1,canonical:[],checkpoints:[],transient:[],nextCursor:void 0,hasMore:!1,loading:!1,loadingOlder:!1,error:null,activeRun:null,pendingApproval:null,queuedInputs:[],delegationActive:!1,lastSeq:0,workerInstanceId:null,streamOpen:!1},c3=()=>()=>{},c6=async()=>!1,c8=async()=>{},c9=()=>{},c7=()=>{},de=()=>{},dt={nodes:[],openTurn:null,calls:new Map,syntheticTurn:0};function dn(e){return"discuss"===e||"ask"===e||"auto"===e}function da(e){return"object"==typeof e&&null!==e?e:void 0}let ds=new Set(["txt","md","mdx","json","yaml","yml","toml","csv","tsv","log","js","jsx","ts","tsx","py","r","go","rs","java","c","cpp","h","hpp","css","html","xml","sh","bash","sql"]);function di(){return"u">typeof crypto&&crypto.randomUUID?crypto.randomUUID():Math.random().toString(36).slice(2)+Date.now().toString(36)}function dr(e,t){let n=new Map(t.map(e=>[e.id,e.name]));return e.filter(e=>"active"===e.status).map(e=>({ref:`${n.get(e.providerId)??e.providerId}/${e.modelName}`,label:e.displayName||e.modelName,model:e}))}let dl=["room","reply","fresh","task_only"],dc={room:"Room",reply:"Reply",fresh:"Fresh",task_only:"Task only"},dd=["discuss","ask","auto"];function du({models:e,providers:a,setError:s}){let i=(0,f.useT)(),r=(0,n.useMemo)(()=>dr(e,a),[e,a]),[l,o]=(0,n.useState)([]),[d,p]=(0,n.useState)(null),[h,m]=(0,n.useState)(null),[g,x]=(0,n.useState)(""),[v,y]=(0,n.useState)(null),[b,k]=(0,n.useState)(!1),[j,w]=(0,n.useState)({id:"",name:""}),[_,N]=(0,n.useState)(!1),[C,I]=(0,n.useState)(null);M(null!==C,()=>I(null));let P=(0,n.useCallback)(async()=>{let e=await (0,e5.apiFetch)("/v1/global-heroes");return o(e),e},[]),T=(0,n.useCallback)(async e=>{y("loading"),p(e);try{m(await (0,e5.apiFetch)(`/v1/global-heroes/${encodeURIComponent(e)}`)),N(!1),I(null),s(null)}catch(e){m(null),s(e.message)}finally{y(null)}},[s]);(0,n.useEffect)(()=>{let e=!1,t=window.setTimeout(()=>{P().then(t=>{let n=t.find(e=>!e.error);!e&&n&&T(n.id)}).catch(t=>{e||s(t.message)})},0);return()=>{e=!0,window.clearTimeout(t)}},[T,P,s]);let R=async()=>{if(!r[0])return void s("Create an active model before creating a Hero.");let e=j.id.trim(),t=j.name.trim();if(e&&t){y("creating");try{var n;let a=await (0,e5.apiFetch)("/v1/global-heroes",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({document:(n=r[0].ref,{schemaVersion:1,handle:e,name:t,description:"",positioning:"",icon:"bot",color:"neutral",model:{ref:n,thinkingEffort:"default",fallbacks:[]},skills:[],authority:"read_only",permissionCeiling:"discuss",allowedTools:["read","ls","grep","find"],context:{defaultMode:"room",allowedModes:["room","fresh","task_only"],ownExecutionContinuity:"none"},delegation:{admission:"auto_within_budget",allowedCallerKinds:["host"],allowedStrategies:["single","parallel"],maxInvocationsPerParentRun:16,maxConcurrentInstances:16,budgetCeiling:{maxModelCalls:4,maxToolCalls:8,maxTotalTokens:2e4,maxOutputTokens:4e3,maxCostUsdMicros:1e5,maxWallTimeMs:12e4}},outputContract:"text-v1",maxLoopIterations:8,prompt:"Perform the requested work independently. Distinguish evidence from assumptions and report a concise result."})})});k(!1),w({id:"",name:""}),m(a),p(a.id),await P(),s(null)}catch(e){s(e.message)}finally{y(null)}}},E=async e=>{if(h&&!v){y("saving");try{let t=await (0,e5.apiFetch)(`/v1/global-heroes/${encodeURIComponent(h.id)}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({expectedDigest:h.digest,document:e})});m(t),o(e=>e.map(e=>e.id===t.id?{...e,name:t.name,digest:t.digest,error:void 0}:e)),N(!1),I(null),s(null)}catch(e){N(!0),s(e.message)}finally{y(null)}}},A=async()=>{if(h)try{I(await (0,e5.apiFetch)(`/v1/global-heroes/${encodeURIComponent(h.id)}`))}catch(e){s(e.message)}},$=async()=>{if(h&&!v){y("publishing");try{await (0,e5.apiFetch)(`/v1/global-heroes/${encodeURIComponent(h.id)}/publish`,{method:"POST"}),s(null)}catch(e){s(e.message)}finally{y(null)}}},z=e=>{h&&m({...h,document:e(h.document)})},F=e=>{if(!h)return;let t=e(h.document);m({...h,document:t}),E(t)},L=l.filter(e=>`${e.name} ${e.id}`.toLowerCase().includes(g.trim().toLowerCase()));return(0,t.jsxs)("div",{className:`global-heroes ${d?"has-selection":""}`,children:[(0,t.jsxs)("aside",{className:"global-heroes-list",children:[(0,t.jsxs)("header",{children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("strong",{children:"Hero catalog"}),(0,t.jsxs)("span",{children:[l.length," global Heroes"]})]}),(0,t.jsx)("button",{type:"button",onClick:()=>k(e=>!e),"aria-label":"Add Hero",children:(0,t.jsx)(S,{size:18})})]}),b&&(0,t.jsxs)("div",{className:"global-hero-create",children:[(0,t.jsx)("input",{value:j.id,onChange:e=>w(t=>({...t,id:e.target.value})),placeholder:"hero-id"}),(0,t.jsx)("input",{value:j.name,onChange:e=>w(t=>({...t,name:e.target.value})),placeholder:"Hero name"}),(0,t.jsx)("button",{type:"button",onClick:()=>void R(),disabled:"creating"===v,children:"creating"===v?"Creating…":"Create"})]}),(0,t.jsxs)("label",{className:"global-hero-search",children:[(0,t.jsx)(u,{size:15}),(0,t.jsx)("input",{value:g,onChange:e=>x(e.target.value),placeholder:"Search Heroes"})]}),(0,t.jsxs)("div",{role:"listbox","aria-label":"Global Heroes",children:[L.map(e=>(0,t.jsxs)("button",{type:"button",role:"option","aria-selected":d===e.id,onClick:()=>void T(e.id),children:[(0,t.jsx)(c,{size:17}),(0,t.jsxs)("span",{children:[(0,t.jsx)("strong",{children:e.name}),(0,t.jsx)("code",{children:e.id}),e.error&&(0,t.jsx)("small",{children:e.error})]}),(0,t.jsx)(ei,{size:14})]},e.id)),0===L.length&&(0,t.jsx)("div",{className:"heroes-empty",children:"No global Heroes"})]})]}),(0,t.jsxs)("section",{className:"global-hero-detail",children:[!h&&"loading"===v&&(0,t.jsxs)("div",{className:"heroes-detail-empty",children:[(0,t.jsx)(eQ,{className:"spin",size:18})," Loading Hero…"]}),!h&&"loading"!==v&&(0,t.jsxs)("div",{className:"heroes-detail-empty",children:[(0,t.jsx)(c,{size:26})," Select or create a Hero"]}),h&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("header",{className:"global-hero-commandbar",children:[(0,t.jsxs)("button",{type:"button",className:"global-hero-back",onClick:()=>{p(null),m(null)},children:[(0,t.jsx)(rZ,{size:17})," Heroes"]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("strong",{children:h.document.name}),(0,t.jsx)("code",{children:h.path})]}),(0,t.jsxs)("div",{className:"global-hero-command-actions",children:[_?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("span",{className:"hero-conflict-state",children:"File changed on disk"}),(0,t.jsx)("button",{type:"button",onClick:()=>void A(),children:"Diff"}),(0,t.jsx)("button",{type:"button",onClick:()=>void T(h.id),children:"Reload"})]}):(0,t.jsx)("span",{className:"saving"===v?"is-saving":"",children:"saving"===v?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(eQ,{className:"spin",size:14})," Saving"]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(Y,{size:14})," Saved"]})}),(0,t.jsx)("button",{type:"button",onClick:()=>void $(),disabled:!!v||_,children:"publishing"===v?"Publishing…":"Publish"})]})]}),(0,t.jsxs)("div",{className:"global-hero-form",children:[(0,t.jsxs)("section",{children:[(0,t.jsx)("h3",{children:"Identity"}),(0,t.jsxs)("div",{className:"global-hero-grid",children:[(0,t.jsxs)("label",{children:["Name",(0,t.jsx)("input",{value:h.document.name,onChange:e=>z(t=>({...t,name:e.target.value})),onBlur:()=>void E(h.document)})]}),(0,t.jsxs)("label",{children:["Handle",(0,t.jsx)("input",{value:h.document.handle,disabled:!0})]}),(0,t.jsxs)("label",{className:"wide",children:["Description",(0,t.jsx)("input",{value:h.document.description,onChange:e=>z(t=>({...t,description:e.target.value})),onBlur:()=>void E(h.document)})]})]})]}),(0,t.jsxs)("section",{children:[(0,t.jsx)("h3",{children:"Runtime"}),(0,t.jsxs)("div",{className:"global-hero-grid",children:[(0,t.jsxs)("label",{className:"wide",children:["Model",(0,t.jsx)("select",{value:h.document.model.ref,onChange:e=>F(t=>({...t,model:{...t.model,ref:e.target.value}})),children:r.map(e=>(0,t.jsxs)("option",{value:e.ref,children:[e.label," · ",e.ref]},e.ref))})]}),(0,t.jsxs)("label",{children:["Thinking",(0,t.jsx)("select",{value:h.document.model.thinkingEffort,onChange:e=>F(t=>({...t,model:{...t.model,thinkingEffort:e.target.value}})),children:["default","low","medium","high"].map(e=>(0,t.jsx)("option",{children:e},e))})]}),(0,t.jsxs)("label",{children:["Permission ceiling",(0,t.jsx)("select",{value:h.document.permissionCeiling,onChange:e=>F(t=>({...t,permissionCeiling:e.target.value})),children:dd.map(e=>(0,t.jsx)("option",{value:e,children:i(`permission.${e}`)},e))})]}),(0,t.jsxs)("label",{className:"wide",children:["Skills",(0,t.jsx)("input",{value:h.document.skills.map(e=>e.id).join(", "),onChange:e=>z(t=>({...t,skills:e.target.value.split(",").map(e=>e.trim()).filter(Boolean).map(e=>({id:e,mode:"available"}))})),onBlur:()=>void E(h.document),placeholder:"report-writing, code-review"})]})]})]}),(0,t.jsxs)("section",{children:[(0,t.jsx)("h3",{children:"Execution context"}),(0,t.jsxs)("div",{className:"global-hero-grid",children:[(0,t.jsxs)("label",{children:["Default mode",(0,t.jsx)("select",{"aria-label":"Default context mode",value:h.document.context.defaultMode,onChange:e=>F(t=>({...t,context:{...t.context,defaultMode:e.target.value}})),children:h.document.context.allowedModes.map(e=>(0,t.jsx)("option",{value:e,children:dc[e]},e))})]}),(0,t.jsxs)("div",{className:"global-hero-modes wide",children:[(0,t.jsx)("span",{children:"Allowed modes"}),(0,t.jsx)("div",{role:"group","aria-label":"Allowed context modes",children:dl.map(e=>{let n=h.document.context.allowedModes.includes(e);return(0,t.jsxs)("label",{className:"global-hero-mode",children:[(0,t.jsx)("input",{type:"checkbox",checked:n,disabled:n&&1===h.document.context.allowedModes.length,onChange:t=>{var n;return n=t.target.checked,void F(t=>{let a=n?dl.filter(n=>n===e||t.context.allowedModes.includes(n)):t.context.allowedModes.filter(t=>t!==e);if(0===a.length)return t;let s=a.includes(t.context.defaultMode)?t.context.defaultMode:a[0];return{...t,context:{...t.context,allowedModes:a,defaultMode:s}}})}}),dc[e]]},e)})}),(0,t.jsx)("p",{className:"global-hero-hint",children:"Task only is required for Heroes that run as delegated children. Reply enables addressing a specific message; Room shares the session lineage; Fresh starts from the addressed request."})]})]})]}),(0,t.jsxs)("section",{children:[(0,t.jsx)("h3",{children:"Hero prompt"}),(0,t.jsx)("label",{className:"global-hero-prompt",children:(0,t.jsx)("textarea",{"aria-label":"Hero prompt",value:h.document.prompt,onChange:e=>z(t=>({...t,prompt:e.target.value})),onBlur:()=>void E(h.document)})})]})]}),C&&(0,t.jsxs)("div",{className:"hero-conflict-dialog",role:"dialog","aria-modal":"true","aria-label":"Hero file diff",children:[(0,t.jsxs)("div",{children:[(0,t.jsxs)("header",{children:[(0,t.jsx)("strong",{children:"Local edits"}),(0,t.jsx)("button",{type:"button",onClick:()=>I(null),children:"Close"})]}),(0,t.jsx)("pre",{children:JSON.stringify(h.document,null,2)})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("header",{children:(0,t.jsx)("strong",{children:"File on disk"})}),(0,t.jsx)("pre",{children:JSON.stringify(C.document,null,2)})]})]})]})]})]})}function dp({graphId:e,models:a,onApplied:s,setError:i}){let[r,l]=(0,n.useState)(null),[o,d]=(0,n.useState)(""),[u,p]=(0,n.useState)(""),[h,m]=(0,n.useState)(null),f=(0,n.useCallback)(async()=>{m("loading");try{let t=await (0,e5.apiFetch)(`/v1/graphs/${encodeURIComponent(e)}/builder`);l(t),d(t.modelProfileId||a[0]?.model.id||"")}catch(e){i(e.message)}finally{m(null)}},[e,a,i]);(0,n.useEffect)(()=>{let e=window.setTimeout(()=>void f(),0);return()=>window.clearTimeout(e)},[f]);let g=async()=>{if(u.trim()&&o&&!h){m("sending");try{let t=await (0,e5.apiFetch)(`/v1/graphs/${encodeURIComponent(e)}/builder/messages`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({modelProfileId:o,instruction:u.trim()})});l(t),p(""),i(null)}catch(e){i(e.message)}finally{m(null)}}},x=async()=>{if(r?.proposal&&!(r.proposal.diagnostics.length>0)&&!h){m("applying");try{let t=await (0,e5.apiFetch)(`/v1/graphs/${encodeURIComponent(e)}/builder/proposals/${encodeURIComponent(r.proposal.id)}/apply`,{method:"POST"});s(t),await f(),i(null)}catch(e){i(e.message)}finally{m(null)}}};return(0,t.jsxs)("aside",{className:"graph-builder-pane",children:[(0,t.jsxs)("div",{className:"graph-section-heading",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("span",{children:"Builder"}),(0,t.jsx)("p",{children:"Persistent conversation for this Graph."})]}),(0,t.jsx)(c,{size:18})]}),(0,t.jsxs)("div",{className:"graph-builder-content",children:[(0,t.jsxs)("label",{className:"graph-builder-model",children:["Builder model",(0,t.jsx)("select",{value:o,onChange:e=>d(e.target.value),disabled:!!h,children:a.map(e=>(0,t.jsx)("option",{value:e.model.id,children:e.label},e.model.id))})]}),(0,t.jsxs)("div",{className:"graph-builder-messages","aria-live":"polite",children:["loading"===h&&(0,t.jsxs)("div",{className:"graph-builder-loading",children:[(0,t.jsx)(eQ,{className:"spin",size:16})," Loading conversation…"]}),r?.messages.map(e=>(0,t.jsxs)("div",{className:`graph-builder-message is-${e.role}`,children:[(0,t.jsx)("span",{children:"user"===e.role?"You":"Builder"}),(0,t.jsx)("p",{children:e.content})]},e.id)),!h&&(r?.messages.length??0)===0&&(0,t.jsxs)("div",{className:"graph-builder-intro",children:[(0,t.jsx)(c,{size:22}),(0,t.jsx)("p",{children:"Describe Tasks, execution choices, and dependencies. Builder will return a validated proposal."})]})]}),r?.proposal&&(0,t.jsxs)("div",{className:`graph-builder-proposal ${r.proposal.diagnostics.length?"is-invalid":""}`,children:[(0,t.jsxs)("header",{children:[r.proposal.diagnostics.length?(0,t.jsx)(cw,{size:15}):(0,t.jsx)(Y,{size:15}),(0,t.jsx)("strong",{children:"Proposal"}),(0,t.jsxs)("span",{children:[r.proposal.operations.length," changes"]})]}),(0,t.jsx)("p",{children:r.proposal.summary}),(0,t.jsx)("ul",{children:r.proposal.operations.map((e,n)=>(0,t.jsxs)("li",{children:[(0,t.jsx)("code",{children:e.kind}),e.taskId?` \xb7 ${e.taskId}`:""]},n))}),r.proposal.diagnostics.map(e=>(0,t.jsx)("div",{className:"graph-builder-diagnostic",children:e},e)),(0,t.jsx)("button",{type:"button",onClick:()=>void x(),disabled:r.proposal.diagnostics.length>0||!!h,children:"applying"===h?"Applying…":"Apply proposal"})]}),(0,t.jsxs)("div",{className:"graph-builder-composer",children:[(0,t.jsx)("textarea",{value:u,onChange:e=>p(e.target.value),"aria-label":"Graph Builder instruction",placeholder:"Describe the Graph change…",disabled:!!h||!o,onKeyDown:e=>{"Enter"===e.key&&(e.metaKey||e.ctrlKey)&&g()}}),(0,t.jsx)("button",{type:"button",onClick:()=>void g(),disabled:!u.trim()||!o||!!h,"aria-label":"Send Builder instruction",children:"sending"===h?(0,t.jsx)(eQ,{className:"spin",size:17}):(0,t.jsx)(i3,{size:17})})]})]})]})}function dh(e){let t=new Set(Object.keys(e.tasks)),n=new Set,a=[];for(;t.size>0;){let s=[...t].filter(t=>(e.graph[t]??[]).every(e=>n.has(e))).sort();if(0===s.length)return[...a,[...t].sort()];a.push(s),s.forEach(e=>{t.delete(e),n.add(e)})}return a}function dm({document:e,busy:n,onOpenTask:a,onChange:s}){let i=Object.keys(e.tasks).sort();return 0===i.length?(0,t.jsx)("div",{className:"graph-empty-state",children:"Add a Task to start the Graph."}):(0,t.jsxs)("div",{className:"graph-dependency-editor",children:[(0,t.jsx)("div",{className:"graph-levels","aria-label":"Task dependency levels",children:dh(e).map((n,s)=>(0,t.jsxs)("div",{className:"graph-level",children:[(0,t.jsxs)("span",{className:"graph-level-label",children:["Level ",s+1]}),(0,t.jsx)("div",{children:n.map(n=>(0,t.jsx)("button",{type:"button",onClick:()=>a(n),children:e.tasks[n].name},n))}),s<dh(e).length-1&&(0,t.jsx)(j,{size:16,"aria-hidden":!0})]},s))}),(0,t.jsx)("div",{className:"graph-dependency-list",children:i.map(a=>{let r=new Set(e.graph[a]??[]);return(0,t.jsxs)("fieldset",{disabled:n,children:[(0,t.jsx)("legend",{children:e.tasks[a].name}),(0,t.jsxs)("div",{children:[i.filter(e=>e!==a).map(n=>(0,t.jsxs)("label",{children:[(0,t.jsx)("input",{type:"checkbox",checked:r.has(n),onChange:e=>{let t=new Set(r);e.target.checked?t.add(n):t.delete(n),s(a,[...t].sort())}}),e.tasks[n].name]},n)),1===i.length&&(0,t.jsx)("span",{children:"No other Tasks"})]})]},a)})})]})}function df({graphs:e,selected:n,onSelect:a,onAdd:s}){return(0,t.jsxs)("div",{className:"graph-tabs-row",children:[(0,t.jsx)("div",{className:"graph-tabs",role:"tablist","aria-label":"Graphs",children:e.map(e=>(0,t.jsxs)("button",{type:"button",role:"tab","aria-selected":n===e.id,className:"graph-tab",onClick:()=>a(e.id),children:[(0,t.jsx)("span",{children:e.name}),e.error&&(0,t.jsx)("span",{title:e.error,"aria-label":e.error,role:"img",children:(0,t.jsx)(cw,{size:12,"aria-hidden":"true"})})]},e.id))}),(0,t.jsx)("button",{type:"button",className:"graph-add-tab",onClick:s,"aria-label":"Add Graph",title:"Add Graph",children:(0,t.jsx)(S,{size:18})})]})}function dg({id:e,task:n,expanded:a,busy:s,models:i,onToggle:r,onSave:l,onRemove:o}){let c=!!n.hero,d=i.find(e=>e.ref===n.model),u=d?.model.supportsThinking?d.model.supportedThinkingEfforts:["default"],p=(e,t)=>l({...n,[e]:t});return(0,t.jsxs)("section",{className:"graph-task","data-task-id":e,children:[(0,t.jsxs)("button",{type:"button",className:"graph-task-summary",onClick:r,"aria-expanded":a,children:[a?(0,t.jsx)(q,{size:17}):(0,t.jsx)(j,{size:17}),(0,t.jsxs)("span",{children:[(0,t.jsx)("strong",{children:n.name}),(0,t.jsx)("code",{children:e})]}),(0,t.jsxs)("small",{children:[c?n.hero:n.model,!c&&n.thinking&&"default"!==n.thinking?` \xb7 ${n.thinking}`:""]})]}),a&&(0,t.jsxs)("div",{className:"graph-task-form",children:[(0,t.jsxs)("label",{children:["Task name",(0,t.jsx)("input",{defaultValue:n.name,disabled:s,onBlur:e=>p("name",e.target.value)})]}),(0,t.jsxs)("div",{className:"graph-execution-mode",role:"group","aria-label":"Execution mode",children:[(0,t.jsx)("button",{type:"button","aria-pressed":!c,disabled:s||!i[0],onClick:()=>l({name:n.name,model:n.model||i[0]?.ref,thinking:"default",skills:[],goal:n.goal,writes:n.writes,budget:n.budget}),children:"Inline configuration"}),(0,t.jsx)("button",{type:"button","aria-pressed":c,disabled:s,onClick:()=>l({name:n.name,hero:n.hero||`local/${e}`,goal:n.goal,writes:n.writes,budget:n.budget}),children:"Use a Hero"})]}),c?(0,t.jsxs)("label",{children:["Hero",(0,t.jsx)("input",{defaultValue:n.hero,disabled:s,placeholder:"local/alignment or global/reviewer",onBlur:e=>p("hero",e.target.value)}),(0,t.jsx)("span",{children:"Local Heroes belong only to this Graph. Global Heroes are shared and read-only here."})]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("label",{children:["Model",(0,t.jsx)("select",{value:n.model??"",disabled:s,onChange:e=>p("model",e.target.value),children:i.map(e=>(0,t.jsxs)("option",{value:e.ref,children:[e.label," · ",e.ref]},e.ref))})]}),d?.model.supportsThinking&&(0,t.jsxs)("label",{children:["Thinking",(0,t.jsx)("select",{value:n.thinking??"default",disabled:s,onChange:e=>p("thinking",e.target.value),children:u.map(e=>(0,t.jsx)("option",{value:e,children:e},e))})]}),(0,t.jsxs)("label",{children:["Skills",(0,t.jsx)("input",{defaultValue:(n.skills??[]).join(", "),disabled:s,placeholder:"local/alignment, global/report-writing",onBlur:e=>p("skills",e.target.value.split(",").map(e=>e.trim()).filter(Boolean))}),(0,t.jsx)("span",{children:"Use explicit local/ or global/ references."})]})]}),(0,t.jsxs)("label",{className:"graph-task-goal",children:["Goal",(0,t.jsx)("textarea",{defaultValue:n.goal,disabled:s,onBlur:e=>p("goal",e.target.value)})]}),(0,t.jsxs)("details",{children:[(0,t.jsx)("summary",{children:"Advanced"}),(0,t.jsxs)("label",{children:["Writes",(0,t.jsx)("input",{defaultValue:(n.writes??[]).join(", "),disabled:s,onBlur:e=>p("writes",e.target.value.split(",").map(e=>e.trim()).filter(Boolean))})]})]}),(0,t.jsxs)("button",{type:"button",className:"graph-task-remove",onClick:o,disabled:s,children:[(0,t.jsx)(P,{size:15})," Remove Task"]})]})]})}function dx({setError:e}){let a=cO(),s=(0,n.useMemo)(()=>dr(a.models,a.providers),[a.models,a.providers]),[i,r]=(0,n.useState)([]),[l,o]=(0,n.useState)(null),[c,d]=(0,n.useState)(null),[u,p]=(0,n.useState)(null),[m,f]=(0,n.useState)(null),[g,x]=(0,n.useState)(0),[v,y]=(0,n.useState)(!1);M(v,()=>y(!1));let[b,k]=(0,n.useState)({id:"",name:""}),[j,w]=(0,n.useState)(!1),[_,N]=(0,n.useState)({id:"",name:""}),[C,I]=(0,n.useState)("tasks"),P=(0,n.useCallback)(async e=>{let t=await (0,e5.apiFetch)("/v1/graphs");r(t);let n=e??t.find(e=>!e.error)?.id??null;return o(n),n},[]),T=(0,n.useCallback)(async t=>{f("loading"),o(t),p(null);try{let[n,a]=await Promise.all([(0,e5.apiFetch)(`/v1/graphs/${encodeURIComponent(t)}`),(0,e5.apiFetch)(`/v1/graphs/${encodeURIComponent(t)}/versions`)]);d(n),x(a.reduce((e,t)=>Math.max(e,t.version),0)),e(null)}catch(t){d(null),e(t.message)}finally{f(null)}},[e]);(0,n.useEffect)(()=>{let t=!1,n=window.setTimeout(()=>{P().then(e=>{!t&&e&&T(e)}).catch(n=>{t||e(n.message)})},0);return()=>{t=!0,window.clearTimeout(n)}},[T,P,e]);let R=async()=>{if(b.id.trim()&&b.name.trim()){f("creating");try{let t=await (0,e5.apiFetch)("/v1/graphs",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:b.id.trim(),name:b.name.trim()})});y(!1),k({id:"",name:""}),d(t),x(0),o(t.id),await P(t.id),e(null)}catch(t){e(t.message)}finally{f(null)}}},E=async t=>{if(c&&!m){f("saving");try{let n=await (0,e5.apiFetch)(`/v1/graphs/${encodeURIComponent(c.id)}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({expectedDigest:c.digest,...t})});d(n),r(e=>e.map(e=>e.id===n.id?{...e,name:n.name,digest:n.digest,error:void 0}:e)),e(null)}catch(t){e(t.message)}finally{f(null)}}},A=async()=>{if(c&&!m){f("publishing");try{let t=await (0,e5.apiFetch)(`/v1/graphs/${encodeURIComponent(c.id)}/publish`,{method:"POST"});x(t.version),e(null)}catch(t){e(t.message)}finally{f(null)}}},$=async e=>{await rc({title:`Remove Task “${c?.document.tasks[e]?.name??e}”?`,description:"This removes the task from the graph draft. Published versions are unaffected.",confirmLabel:"Remove task",tone:"danger"})&&await E({task:{id:e,value:null}})},z=async()=>{let t=s[0];if(!t)return void e("Create an active model before adding an inline Task.");let n=_.id.trim(),a=_.name.trim();n&&a&&(await E({task:{id:n,value:{name:a,model:t.ref,thinking:"default",skills:[],goal:"Describe the outcome this Task must produce."}}}),N({id:"",name:""}),w(!1),p(n))};return(0,t.jsxs)("div",{className:"graph-workspace",children:[(0,t.jsx)(df,{graphs:i,selected:l,onSelect:e=>void T(e),onAdd:()=>y(!0)}),v&&(0,t.jsxs)("div",{className:"graph-create-strip",role:"dialog","aria-label":"Add Graph",children:[(0,t.jsxs)("label",{children:["ID",(0,t.jsx)("input",{autoFocus:!0,value:b.id,onChange:e=>k(t=>({...t,id:e.target.value})),placeholder:"rna-seq"})]}),(0,t.jsxs)("label",{children:["Name",(0,t.jsx)("input",{value:b.name,onChange:e=>k(t=>({...t,name:e.target.value})),placeholder:"RNA-seq"})]}),(0,t.jsx)("button",{type:"button",onClick:()=>void R(),disabled:"creating"===m,children:"creating"===m?"Creating…":"Create Graph"}),(0,t.jsx)("button",{type:"button",onClick:()=>y(!1),children:"Cancel"})]}),(0,t.jsx)("div",{className:"graph-mobile-segments",role:"tablist","aria-label":"Graph views",children:["tasks","graph","build"].map(e=>(0,t.jsx)("button",{type:"button",role:"tab","aria-selected":C===e,onClick:()=>I(e),children:e},e))}),!c&&"loading"===m&&(0,t.jsxs)("div",{className:"graph-loading",children:[(0,t.jsx)(eQ,{className:"spin",size:18})," Loading Graph…"]}),!c&&"loading"!==m&&0===i.length&&(0,t.jsxs)("div",{className:"graph-welcome",children:[(0,t.jsx)(h,{size:28}),(0,t.jsx)("h2",{children:"Create your first Graph"}),(0,t.jsx)("p",{children:"Compose reusable Tasks and their dependencies without choosing a Project."}),(0,t.jsxs)("button",{type:"button",onClick:()=>y(!0),children:[(0,t.jsx)(S,{size:16})," Add Graph"]})]}),c&&(0,t.jsxs)("div",{className:"graph-document",children:[(0,t.jsxs)("header",{className:"graph-document-header",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("span",{children:"Graph"}),(0,t.jsx)("h2",{children:c.document.name}),(0,t.jsx)("code",{children:c.document.id})]}),(0,t.jsxs)("div",{className:"graph-document-actions",children:[(0,t.jsxs)("span",{children:["v",g||"draft"]}),(0,t.jsx)("div",{className:`graph-save-state ${"saving"===m?"is-saving":""}`,children:"saving"===m?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(eQ,{className:"spin",size:14})," Saving"]}):g>0?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(Y,{size:14})," Saved v",g]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(Y,{size:14})," Draft saved"]})}),(0,t.jsx)("button",{type:"button",onClick:()=>void A(),disabled:!!m||0===Object.keys(c.document.tasks).length,children:"publishing"===m?"Publishing…":"Publish"})]})]}),(0,t.jsxs)("main",{className:`graph-editor-view is-${C}`,children:[(0,t.jsxs)("section",{className:"graph-tasks-pane",children:[(0,t.jsxs)("div",{className:"graph-section-heading",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("span",{children:"Tasks"}),(0,t.jsx)("p",{children:"Execution configuration. Tasks are collapsed by default."})]}),(0,t.jsxs)("button",{type:"button",onClick:()=>w(e=>!e),children:[(0,t.jsx)(S,{size:16})," Add Task"]})]}),j&&(0,t.jsxs)("div",{className:"graph-add-task",children:[(0,t.jsx)("input",{value:_.id,onChange:e=>N(t=>({...t,id:e.target.value})),placeholder:"task_id"}),(0,t.jsx)("input",{value:_.name,onChange:e=>N(t=>({...t,name:e.target.value})),placeholder:"Task name"}),(0,t.jsx)("button",{type:"button",onClick:()=>void z(),children:"Add"})]}),(0,t.jsxs)("div",{className:"graph-task-list",children:[Object.keys(c.document.tasks).sort().map(e=>(0,t.jsx)(dg,{id:e,task:c.document.tasks[e],expanded:u===e,busy:!!m,models:s,onToggle:()=>p(t=>t===e?null:e),onSave:t=>{E({task:{id:e,value:t}})},onRemove:()=>void $(e)},e)),0===Object.keys(c.document.tasks).length&&(0,t.jsx)("div",{className:"graph-empty-state",children:"No Tasks yet. Add one or ask Builder to draft the Graph."})]})]}),(0,t.jsxs)("section",{className:"graph-dependencies-pane",children:[(0,t.jsx)("div",{className:"graph-section-heading",children:(0,t.jsxs)("div",{children:[(0,t.jsx)("span",{children:"Graph"}),(0,t.jsx)("p",{children:"Dependency orchestration. Hero details stay inside Tasks."})]})}),(0,t.jsx)(dm,{document:c.document,busy:!!m,onOpenTask:e=>{p(e),I("tasks"),requestAnimationFrame(()=>document.querySelector(`[data-task-id="${CSS.escape(e)}"]`)?.scrollIntoView({behavior:"smooth",block:"start"}))},onChange:(e,t)=>void E({dependencies:{taskId:e,depends:t}})})]}),(0,t.jsx)(dp,{graphId:c.id,models:s,setError:e,onApplied:e=>{d(e),r(t=>t.map(t=>t.id===e.id?{...t,name:e.name,digest:e.digest,error:void 0}:t))}})]})]})]})}function dv({view:e,models:a,providers:s,onBackToChat:i,onOpenMobileNav:r,menuTriggerRef:l}){let[o,c]=(0,n.useState)(null);return(0,t.jsxs)("div",{className:"settings-view","data-testid":"heroes"===e?"heroes-page":"graphs-page",children:[(0,t.jsx)("button",{ref:l,type:"button",className:"workspace-mobile-menu",onClick:r,"aria-label":"Open navigation",children:(0,t.jsx)(rR,{size:20})}),(0,t.jsxs)("header",{className:"workspace-page-header",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("h1",{children:"heroes"===e?"Heroes":"Graphs"}),(0,t.jsx)("p",{children:"heroes"===e?"Global reusable execution presets for Chat and Graph Tasks.":"Global Task graphs. Every published Graph can run in any Session."})]}),(0,t.jsxs)("button",{type:"button",className:"settings-view-back",onClick:i,children:[(0,t.jsx)(rZ,{size:15})," Chat"]})]}),o&&(0,t.jsxs)("div",{className:"error-bar workspace-page-error",role:"alert",children:[(0,t.jsx)("span",{children:o}),(0,t.jsx)("button",{type:"button",onClick:()=>c(null),"aria-label":"Dismiss error",children:(0,t.jsx)(m,{size:16})})]}),(0,t.jsx)("div",{className:"workspace-page-body",children:"heroes"===e?(0,t.jsx)(du,{models:a,providers:s,setError:c}):(0,t.jsx)(dx,{setError:c})})]})}var dy=e.i(51761);function db(e){let t=(0,e5.subscribeWorkerReachability)(e),n=()=>{(0,e5.probeWorkerReachability)().catch(()=>{})};return window.addEventListener("online",n),window.addEventListener("offline",n),()=>{t(),window.removeEventListener("online",n),window.removeEventListener("offline",n)}}function dk(){return"unreachable"===(0,e5.getWorkerReachability)()}function dj(){return!1}e.s(["AppShell",0,function({initialView:e="chat"}){let a=l_("(max-width: 640px)"),{projects:s,projectsReady:i,selectedProject:r,switchProject:l,openCreateProject:o,settingsOpen:c,settingsTab:d,openSettings:u,closeSettings:p,workspaceFor:h,togglePinProject:m,pinnedProjectIds:g,renameProject:x,deleteProject:v}=(0,cR.useWorkspace)(),[y,b]=(0,n.useState)(null),k=(0,n.useRef)(null),[j,w]=(0,n.useState)(e??"chat"),_=(0,n.useCallback)(e=>{w(e),window.history.replaceState(null,"","chat"===e?"/":`/?view=${e}`)},[]);(0,n.useEffect)(()=>{let e=()=>{let e=new URLSearchParams(window.location.search).get("view");("heroes"===e||"graphs"===e||"chat"===e)&&w(e)};return e(),window.addEventListener("popstate",e),()=>window.removeEventListener("popstate",e)},[]);let N=(0,n.useCallback)(e=>{k.current=e,b(e),(0,dy.writeStoredId)(dy.SELECTED_SESSION_KEY,e)},[]),C=cz({initialWidth:280,minWidth:264,maxWidth:420,storageKey:"--ennote-sidebar-width",cssVariable:"--ennote-sidebar-width"}),S=rP(),[I,P]=(0,n.useState)(!0),T=function(e){let[t,a]=(0,n.useState)(()=>window.innerWidth);(0,n.useEffect)(()=>{let e=()=>a(window.innerWidth);return window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]);let s=lN(t,e);return{...cz({initialWidth:680,minWidth:280,maxWidth:s,storageKey:"ennote-right-panel-width",direction:"left",resolveStored:(0,n.useCallback)(n=>{let a;return a=lN(t,e),null!==n&&Number.isFinite(n)?Math.max(280,Math.min(a,n)):Math.min(680,a)},[t,e])}),maxWidth:s}}(I&&!a?C.width:0),[E,A]=(0,n.useState)(null),$=(0,n.useRef)(null),z=(0,n.useRef)(null),F=(0,n.useCallback)(()=>{P(!1),window.requestAnimationFrame(()=>{($.current??z.current)?.focus()})},[]);(0,n.useEffect)(()=>{if(!a)return;let e=window.requestAnimationFrame(()=>P(!1));return()=>window.cancelAnimationFrame(e)},[a]),M(a&&I,F),(0,n.useEffect)(()=>{if(!a||!I)return;let e=document.querySelector(".sidebar-container");if(!e)return;let t=t=>{if("Tab"!==t.key)return;let n=Array.from(e.querySelectorAll('button:not(:disabled), input:not(:disabled), select:not(:disabled), [href], [tabindex]:not([tabindex="-1"])')).filter(e=>e.getClientRects().length>0);if(!n.length)return;let a=n[0],s=n[n.length-1];t.shiftKey&&document.activeElement===a?(t.preventDefault(),s.focus()):t.shiftKey||document.activeElement!==s||(t.preventDefault(),a.focus())};return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t)},[F,a,I]);let L=function(e){let[t,a]=(0,n.useState)([]),[s,i]=(0,n.useState)([]),[r,l]=(0,n.useState)("active"),[o,c]=(0,n.useState)(""),[d,u]=(0,n.useState)(!1),[p,h]=(0,n.useState)(null),[m,f]=(0,n.useState)(null),[g,x]=(0,n.useState)(null),[v,y]=(0,n.useState)(""),b=(0,n.useRef)(0),k=(0,n.useRef)(null),j=(0,n.useRef)(r),w=(0,n.useCallback)(e=>{j.current=e,l(e)},[]),_=(0,n.useCallback)(async(t=0)=>{if(k.current?.abort(),!e){a([]),i([]),h(null),u(!1);return}let n=new AbortController;k.current=n;let s=++b.current;if(t>0&&await new Promise(e=>setTimeout(e,t)),n.signal.aborted||b.current!==s)return;u(!0);let l=`/v1/projects/${encodeURIComponent(e)}/sessions`,c=new URLSearchParams({status:r}),d=o.trim(),p=`${e}:${r}:${d}`;d&&c.set("q",d);try{let e=(0,e5.apiFetch)(`${l}?status=active`,{signal:n.signal}),t="active"!==r||d?(0,e5.apiFetch)(`${l}?${c.toString()}`,{signal:n.signal}):e,[o,u]=await Promise.all([e,t]);if(n.signal.aborted||b.current!==s)return;a(o??[]),i(u??[]),h(p),x(null)}catch(e){n.signal.aborted||b.current!==s||(h(p),x(e.message))}finally{n.signal.aborted||b.current!==s||u(!1)}},[e,o,r]);(0,n.useEffect)(()=>{let e=window.setTimeout(()=>void _(0),200);return()=>{window.clearTimeout(e),k.current?.abort()}},[_]);let N=(0,n.useCallback)(()=>_(0),[_]),C=(0,n.useCallback)(e=>{a(t=>"active"===e.status?t.some(t=>t.id===e.id)?t.map(t=>t.id===e.id?e:t):[e,...t]:t.filter(t=>t.id!==e.id)),i(t=>t.map(t=>t.id===e.id?e:t).filter(e=>e.status===j.current))},[]),S=(0,n.useCallback)(async(e,t)=>{f(e.id);try{return await (0,e5.apiFetch)(`/v1/sessions/${encodeURIComponent(e.id)}/${t}`,{method:"POST",body:"{}"}),y(`${"archive"===t?"Archived":"Restored"} ${e.title}`),x(null),await N(),!0}catch(e){return x(e.message),!1}finally{f(null)}},[N]),I=e?`${e}:${r}:${o.trim()}`:null;return{activeSessions:t,visibleSessions:s,view:r,setView:w,query:o,setQuery:c,loading:d||null!==I&&p!==I,mutatingId:m,error:g,setError:x,announcement:v,refresh:N,replaceSession:C,archive:e=>S(e,"archive"),restore:e=>S(e,"restore")}}(r),D=function(e,t,a){let[s,i]=(0,n.useState)({}),[r,l]=(0,n.useState)({}),[o,c]=(0,n.useState)(cL),d=(0,n.useRef)(0),u=(0,n.useMemo)(()=>{let e=[],n=t=>{t&&!e.includes(t)&&e.push(t)};for(let e of(n(a),t))n(e);return e},[a,t]),p=(0,n.useCallback)(async t=>{let n=++d.current,a=e.find(e=>e.id===t),s=a?.name??t;i(e=>({...e,[t]:{projectId:t,projectName:s,sessions:[],loading:!0,error:null}}));try{let e=await (0,e5.apiFetch)(`/v1/projects/${encodeURIComponent(t)}/sessions?status=active`)??[];if(d.current!==n)return;i(n=>({...n,[t]:{projectId:t,projectName:s,sessions:e,loading:!1,error:null}}))}catch(e){if(d.current!==n)return;i(n=>({...n,[t]:{projectId:t,projectName:s,sessions:[],loading:!1,error:e.message}}))}},[e]);(0,n.useEffect)(()=>{for(let e of u)s[e]||p(e)},[u,s,p]),(0,n.useEffect)(()=>{a&&p(a)},[a,p]),(0,n.useEffect)(()=>{let e=window.setInterval(()=>{for(let e of u)p(e)},3e4);return()=>window.clearInterval(e)},[u,p]);let h=(0,n.useCallback)(e=>void p(e),[p]),m=(0,n.useCallback)(()=>{for(let e of u)p(e)},[u,p]),f=(0,n.useCallback)(async e=>{if(!r[e])try{let t=await (0,e5.apiFetch)(`/v1/projects/${encodeURIComponent(e)}/sessions?status=archived`)??[];l(n=>({...n,[e]:t}))}catch{l(t=>({...t,[e]:[]}))}},[r]),g=(0,n.useCallback)(async e=>{try{let t=await (0,e5.apiFetch)(`/v1/projects/${encodeURIComponent(e)}/sessions?status=archived`)??[];l(n=>({...n,[e]:t}))}catch{l(t=>({...t,[e]:[]}))}},[]),x=(0,n.useCallback)(e=>{c(t=>{let n=new Set(t);n.has(e)?n.delete(e):n.add(e);try{window.localStorage.setItem(cF,JSON.stringify([...n]))}catch{}return n})},[]);return{groups:(0,n.useMemo)(()=>u.map(e=>s[e]).filter(e=>!!e),[u,s]),archived:r,collapsed:o,toggleCollapsed:x,refresh:h,refreshAll:m,openArchived:f,refreshArchived:g}}(s,g,r),O=cO(),q=L.replaceSession,B=L.activeSessions.find(e=>e.id===y),U=function(e){let[t,a]=(0,n.useState)({templates:[],diagnostics:[],loading:!1,error:null}),s=(0,n.useRef)(null),i=(0,n.useCallback)(async()=>{if(!e)return void a({templates:[],diagnostics:[],loading:!1,error:null});s.current?.abort();let t=new AbortController;s.current=t,a(e=>({...e,loading:!0,error:null}));try{let n=await (0,e5.apiFetch)(`/v1/projects/${encodeURIComponent(e)}/prompt-templates`,{signal:t.signal});if(t.signal.aborted)return;a({templates:n.templates,diagnostics:n.diagnostics,loading:!1,error:null})}catch(e){if(t.signal.aborted)return;a(t=>({...t,loading:!1,error:e.message??"Failed to load prompt templates"}))}},[e]);return(0,n.useEffect)(()=>{e&&i()},[i,e]),(0,n.useEffect)(()=>()=>{s.current?.abort()},[]),{...t,refresh:i}}(r),H=function(e){var t;let a,s,i,r,l,o,{selectedSession:c,sessionRecord:d,selectedProject:u,promptCatalog:p,settings:h,replaceSession:m}=e,g=(0,n.useMemo)(()=>new Map(h.models.map(e=>[e.id,e.displayName||e.modelName])),[h.models]),x=(0,n.useCallback)((e,t)=>(e?g.get(e):void 0)??t,[g]),v=d?.activeBranchId,y=d?.activeLeafMessageId,b=(0,n.useCallback)(e=>m(e),[m]),k=(0,n.useCallback)(async()=>{if(!c)return null;let e=await (0,e5.apiFetch)(`/v1/sessions/${encodeURIComponent(c)}`);return m(e),e},[m,c]),j=(t={resolveModel:x},a=t?.resolveModel,s=c?c4.getStore(c):null,i=(0,n.useSyncExternalStore)(s?s.subscribe:c3,s?s.getSnapshot:()=>c5,s?s.getServerSnapshot:()=>c5),(0,n.useEffect)(()=>{if(s)return s.ensureLoaded(v),()=>s.pauseStream()},[s,v]),r=!!c&&i.loaded&&i.dataBranchId===v,l=function(e,t){let[a,s]=(0,n.useState)(new Map);return(0,n.useEffect)(()=>{if(!e)return void s(new Map);let t=!1;return(0,e5.apiFetch)(`/v1/sessions/${encodeURIComponent(e)}/turn-metrics`).then(e=>{t||s(new Map(e.map(e=>[e.runId,e])))}).catch(()=>{}),()=>{t=!0}},[e,t]),a}(c,i.activeRun?.id??null),o=(0,n.useMemo)(()=>r?function(e,t,n,a){let s=[],i=null,r=0,l=new Map,o=()=>{i&&(i.runId&&(i.metrics=n?.get(i.runId)),(i.user||i.steps.length>0)&&s.push(i),i=null,l.clear())};for(let n of function(e,t){let n=e.filter(e=>"private"!==e.visibility&&"room_control"!==e.visibility),a=new Set(n.map(e=>e.id)),s=[...new Map(t.filter(e=>"completed"===e.status).map(e=>[e.id,e])).values()].sort((e,t)=>e.createdAt.localeCompare(t.createdAt)),i=new Map,r=new Map;for(let e of s)e.firstKeptMessageId&&a.has(e.firstKeptMessageId)?cZ(i,e.firstKeptMessageId,e):e.sourceThroughMessageId&&a.has(e.sourceThroughMessageId)&&cZ(r,e.sourceThroughMessageId,e);return n.flatMap(e=>[...(i.get(e.id)??[]).map(e=>({kind:"checkpoint",value:e})),{kind:"message",value:e},...(r.get(e.id)??[]).map(e=>({kind:"checkpoint",value:e}))])}(e,t)){if("checkpoint"===n.kind){var c;o(),s.push((c=n.value,{kind:"checkpoint",id:`compaction-${c.id}`,reason:c.reason,summary:c.summary,reclaimedTokens:c.reclaimedTokens,createdAt:c.createdAt,promptVersion:c.promptVersion,summaryContractDigest:c.summaryContractDigest}));continue}!function(e){if("user"===e.role){o(),i={kind:"turn",id:`turn-${e.id}`,user:{id:e.id,sourceMessageId:e.id,text:e.parts.map(e=>"text"===e.type?e.text:"image"===e.type?`[Image \xb7 ${e.image.width}\xd7${e.image.height}]`:"image_description"===e.type?e.imageDescription.text:"").filter(Boolean).join("\n\n"),createdAt:e.createdAt},steps:[],messageIds:[e.id]};return}let t=(i||(r+=1,i={kind:"turn",id:`turn-orphan-${r}`,steps:[],messageIds:[]}),i);t.messageIds.push(e.id),e.runId&&(t.runId=t.runId??e.runId),"assistant"===e.role?function(e,t){let n=[],s=[],i=()=>{if(0===n.length)return;let s={...t.speakerSnapshot,modelProfileId:t.modelProfileId,apiModel:t.apiModel};if(a){let e=a(t.modelProfileId,t.apiModel);e&&(s.modelName=e)}e.steps.push({kind:"assistant",id:`${t.id}-assistant-${e.steps.length}`,sourceMessageId:t.id,blocks:n,speaker:s,createdAt:t.createdAt}),n=[]},r=()=>{0!==s.length&&(cQ(e,s,l),s=[])};for(let e of t.parts)if("tool_call"===e.type){i();let n={id:`${t.id}-${e.toolCall.id}`,toolCallId:e.toolCall.id,toolName:e.toolCall.name,arguments:e.toolCall.arguments,argumentsFragment:e.toolCall.argumentsFragment,state:e.toolCall.partial?"interrupted":"pending",riskClass:iJ(e.toolCall.name),sourceMessageIds:[t.id],runId:t.runId};s.push(n),l.set(n.toolCallId,n)}else{var o;r();let t="text"===(o=e).type?{kind:"text",text:o.text}:"thinking"===o.type?{kind:"thinking",text:o.text}:"image"===o.type?{kind:"image",artifactId:o.image.artifactId,mimeType:o.image.mimeType,width:o.image.width,height:o.image.height}:"image_description"===o.type?{kind:"image_description",artifactId:o.imageDescription.artifactId,text:o.imageDescription.text}:null;t&&n.push(t)}i(),r()}(t,e):"tool"===e.role&&function(e,t){let n=[];for(let e of t.parts){if("tool_result"!==e.type)continue;let a=l.get(e.toolResult.toolCallId);if(a)a.result={content:e.toolResult.content,isError:e.toolResult.isError,artifacts:e.toolResult.artifacts??[]},a.state=cX(e.toolResult.content,e.toolResult.isError),a.sourceMessageIds.push(t.id);else{let a={id:`${t.id}-${e.toolResult.toolCallId}`,toolCallId:e.toolResult.toolCallId,toolName:e.toolResult.toolName,result:{content:e.toolResult.content,isError:e.toolResult.isError,artifacts:e.toolResult.artifacts??[]},state:cX(e.toolResult.content,e.toolResult.isError),riskClass:iJ(e.toolResult.toolName),sourceMessageIds:[t.id],runId:t.runId};l.set(a.toolCallId,a),n.push(a)}}n.length>0&&cQ(e,n,l)}(t,e)}(n.value)}return{nodes:s,openTurn:i,calls:l,syntheticTurn:r}}(i.canonical,i.checkpoints,l,a):dt,[r,i.canonical,i.checkpoints,l,a]),{messages:(0,n.useMemo)(()=>(function(e,t,n,a,s){if(0===t.length){let t=function(e,t){if(!e)return null;let n={...e};return(n.runId&&(n.metrics=t?.get(n.runId)),n.user||0!==n.steps.length)?n:null}(e.openTurn,n);return t?[...e.nodes,t]:e.nodes}let i=[...e.nodes],r=new Map(e.calls),l=e.syntheticTurn,o=e.openTurn,c=null!==o,d=()=>{if(!o)return;let e=c?{...o}:o;e.runId&&(e.metrics=n?.get(e.runId)),(e.user||e.steps.length>0)&&i.push(e),o=null,c=!1,r.clear()};for(let e of t)!function(e){if("user"===e.role&&"steer"!==e.kind){d(),o={kind:"turn",id:`turn-${e.id}`,user:{id:e.id,text:e.text,sourceMessageId:e.sourceMessageId,createdAt:e.createdAt},steps:[],messageIds:[e.sourceMessageId??e.id]},c=!1;return}let t=(()=>{if(null===o)return l+=1,o={kind:"turn",id:`turn-orphan-${l}`,steps:[],messageIds:[]},c=!1,o;if(c){var e;for(let t of(o={...e=o,messageIds:[...e.messageIds],steps:e.steps.map(e=>"tool_batch"===e.kind?{...e,activities:e.activities.map(e=>({...e,sourceMessageIds:[...e.sourceMessageIds],result:e.result?{...e.result}:void 0}))}:e)},r.clear(),o.steps))if("tool_batch"===t.kind)for(let e of t.activities)r.set(e.toolCallId,e);c=!1}return o})();if(t.messageIds.push(e.sourceMessageId??e.id),e.runId&&(t.runId=t.runId??e.runId),"user"===e.role&&"steer"===e.kind)return t.steps.push({kind:"steer",id:e.id,text:e.text.replace(/^↪\s*/,""),createdAt:e.createdAt});if("assistant"===e.role){let n=[];e.thinking&&n.push({kind:"thinking",text:e.thinking}),e.text&&n.push({kind:"text",text:e.text}),n.length>0&&t.steps.push({kind:"assistant",id:e.id,sourceMessageId:e.sourceMessageId,blocks:n,speaker:function(e,t){if(!e)return;let n=e.effectiveConfig??{},a=e.requestedConfig??{},s="string"==typeof n.modelProfileId&&n.modelProfileId?n.modelProfileId:"string"==typeof a.modelProfileId?a.modelProfileId:void 0,i="string"==typeof n.apiModel&&n.apiModel?n.apiModel:"string"==typeof a.apiModel?a.apiModel:void 0,r=t?t(s,i):void 0;return{...e.speakerSnapshot,modelProfileId:s,apiModel:i,modelName:r}}(s,a),createdAt:e.createdAt});return}if("tool"===e.role){let n=e.toolCallId??e.id,a=r.get(n);if(a){e.arguments&&(a.arguments=e.arguments),e.runId&&(a.runId=e.runId),e.toolName&&a.toolName!==e.toolName&&(a.toolName=e.toolName,a.riskClass=iJ(e.toolName)),a.result="running"===e.toolState?a.result:{content:e.text,isError:!!e.isError,artifacts:[]},a.state=e.toolState??cX(e.text,!!e.isError),a.sourceMessageIds.push(e.sourceMessageId??e.id);return}cQ(t,[{id:e.id,toolCallId:n,toolName:e.toolName??"tool",arguments:e.arguments,argumentsFragment:e.argumentsFragment,result:"running"===e.toolState?void 0:{content:e.text,isError:!!e.isError,artifacts:[]},state:e.toolState??cX(e.text,!!e.isError),riskClass:iJ(e.toolName??"tool"),sourceMessageIds:[e.sourceMessageId??e.id],runId:e.runId}],r)}}(e);return d(),i})(o,i.transient,l,a,i.activeRun),[o,i.transient,l,a,i.activeRun]),loading:!!c&&!r&&!i.error||i.loading,loadingOlder:i.loadingOlder,historyError:i.error,hasMore:i.hasMore,loadOlder:s?s.loadOlder:c6,refreshLatest:s?s.refreshLatest:c8,appendTransient:s?s.appendTransient:c9,upsertTransient:s?s.upsertTransient:c7,removeTransient:s?s.removeTransient:de,activeRun:i.activeRun,pendingApproval:i.pendingApproval,queuedInputs:i.queuedInputs,delegationActive:i.delegationActive,lastSeq:i.lastSeq,workerInstanceId:i.workerInstanceId,streamOpen:i.streamOpen}),w=function({sessionId:e,lineageId:t,appendMessage:a,upsertMessage:s,refreshLatest:i,refreshSession:r,activeRun:l,pendingApproval:o,queuedInputs:c}){let d=(0,f.useT)(),[u,p]=(0,n.useState)(null),[h,m]=(0,n.useState)(!1),[g,x]=(0,n.useState)(""),[v,y]=(0,n.useState)(null),[b,k]=(0,n.useState)(null),[j,w]=(0,n.useState)(null),_=(0,n.useRef)(null),N=(0,n.useRef)(null),C=(0,n.useRef)(0),S=(0,n.useRef)(0),I=(0,n.useRef)(e),P=(0,n.useRef)(!1),T=(0,n.useRef)(null),M=(0,n.useRef)(new Map),R=(0,n.useRef)(new Map),[E,A]=(0,n.useState)(0),{rows:$,queue:z,settle:F,reset:L}=function(e){let[t,a]=(0,n.useReducer)(cV,cW),s=(0,n.useCallback)(e=>a({type:"queue",row:e}),[]),i=(0,n.useCallback)(e=>a({type:"settle",id:e}),[]),r=(0,n.useCallback)(()=>a({type:"reset"}),[]);return{rows:(0,n.useMemo)(()=>(function(e,t,n){let a=[],s=new Set;for(let t of e)"follow_up"!==t.kind||n.has(t.id)||s.has(t.id)||(s.add(t.id),a.push({id:t.id,text:t.text}));for(let e of t)n.has(e.id)||s.has(e.id)||(s.add(e.id),a.push(e));return a})(e,t.optimistic,t.settled),[e,t.optimistic,t.settled]),queue:s,settle:i,reset:r}}(c);(0,n.useEffect)(()=>{I.current=e},[e]);let D=(0,n.useCallback)(async(e,t,n)=>{let a=I.current;if(!a||e.sessionId!==a)return;T.current=e.id,P.current=!0,x(o?iN("question"===o.kind?"waiting_answer":"waiting_approval"):"context_compaction"===e.runKind?iN("compaction_queued"):"waiting_children"===e.status?iN("waiting_children"):"waiting_delegation_admission"===e.status?iN("waiting_delegation_admission"):iN("running")),y(null);let l=!1;try{if("context_compaction"===e.runKind)l=await cJ(e.id,x,t);else{let a=M.current.get(e.id)??{assistants:new Map,toolDeltas:new Map,toolOutputs:new Map,usageByIteration:new Map,finishedTools:new Set};M.current.set(e.id,a);let i=R.current.get(e.id)??{value:void 0};R.current.set(e.id,i),l=await cY(e.id,s,x,y,k,t,{requested:()=>{},resolved:()=>{},delegated:()=>{},followUpConsumed:e=>{C.current===n&&F(e)},inputCancelled:e=>{C.current===n&&F(e)}},a,i)}}catch(e){l=e instanceof cG,t.aborted||C.current!==n||w(e.message)}finally{C.current===n&&(P.current=!1),l||t.aborted||C.current!==n||x(iN(iw)),l&&(M.current.delete(e.id),R.current.delete(e.id)),l&&!t.aborted&&C.current===n&&I.current===a&&(L(),_.current=null,await r().catch(()=>null),await i(),window.setTimeout(()=>{C.current===n&&I.current===a&&x("")},1600))}},[i,r,s,o,L,F]),O=(0,n.useCallback)(e=>{let t=I.current;if(!t||e.sessionId!==t)return;let n=++C.current;_.current?.abort();let a=new AbortController;_.current=a,D(e,a.signal,n)},[D]),q=(0,n.useCallback)(()=>{p(null),x(""),y(null),k(null),w(null),L()},[L]);(0,n.useEffect)(()=>{C.current+=1,_.current?.abort(),N.current?.abort(),T.current=null,M.current.clear(),R.current.clear(),q()},[t,e,q]),(0,n.useEffect)(()=>{if(!e||l?.id)return;let t=!1;return(0,e5.apiFetch)(`/v1/sessions/${encodeURIComponent(e)}/context-usage`).then(e=>{t||k(e)}).catch(()=>{}),()=>{t=!0}},[e,l?.id]),(0,n.useEffect)(()=>{l?l.id!==T.current&&O(l):T.current&&(_.current?.abort(),M.current.delete(T.current),R.current.delete(T.current),T.current=null,q())},[l,O,q]);let B=l?.id??null;(0,n.useEffect)(()=>{if(iC(g).code!==iw||!B)return;let e=window.setTimeout(()=>A(e=>e+1),1e3);return()=>window.clearTimeout(e)},[g,B]);let U=(0,n.useRef)(l);(0,n.useEffect)(()=>{U.current=l},[l]),(0,n.useEffect)(()=>{if(0===E)return;let e=U.current;e&&(T.current=null,O(e))},[E,O]);let H=(0,n.useCallback)(async()=>{if(l)try{await (0,e5.apiFetch)(`/v1/runs/${encodeURIComponent(l.id)}/cancel`,{method:"POST"}),_.current?.abort(),C.current+=1,x(iN("cancelled")),await r().catch(()=>null),await i()}catch(e){w(e.message)}},[l,i,r]),W=(0,n.useCallback)(async e=>{if(!l||!e.trim())return!1;if(o?.kind==="question")return w(d("run.status.answerQuestionFirst")),!1;try{return x(iN("steering")),await (0,e5.apiFetch)(`/v1/runs/${encodeURIComponent(l.id)}/inputs`,{method:"POST",body:JSON.stringify({kind:"steer",text:e,clientRequestId:cK()})}),a({id:cK(),role:"user",text:`↪ ${e}`,kind:"steer"}),x("waiting_for_approval"===l.status?iN("waiting_approval"):""),!0}catch(e){return w(cU(e,"Failed to steer the run")),!1}},[l,a,o,d]),V=(0,n.useCallback)(async e=>{if(!l||!e.trim())return{queued:!1,runEnded:!1};if(o?.kind==="question")return w(d("run.status.answerQuestionFirst")),{queued:!1,runEnded:!1};try{let t=await (0,e5.apiFetch)(`/v1/runs/${encodeURIComponent(l.id)}/inputs`,{method:"POST",body:JSON.stringify({kind:"follow_up",text:e,clientRequestId:cK()})});return z({id:t.id,text:t.text||e}),{queued:!0,runEnded:!1}}catch(n){let e=cU(n,"Failed to send follow-up"),t=/not active|not_active/i.test(e);return t||w(e),{queued:!1,runEnded:t}}},[l,o,z,d]),K=(0,n.useCallback)(async e=>{if(!l)return!1;try{return await (0,e5.apiFetch)(`/v1/runs/${encodeURIComponent(l.id)}/inputs/${encodeURIComponent(e)}`,{method:"DELETE"}),F(e),!0}catch(e){return w(cU(e,"Failed to cancel the queued message")),!1}},[l,F]),G=(0,n.useCallback)(async e=>{if(o&&"question"===o.kind&&!h){m(!0);try{await (0,e5.apiFetch)(`/v1/approval-requests/${encodeURIComponent(o.id)}/answer`,{method:"POST",headers:{"Idempotency-Key":cK()},body:JSON.stringify({answers:e,clientRequestId:cK()})}),x(iN("answer_submitted")),!P.current&&l&&(T.current=null,O({...l,status:"queued"}))}catch(e){w(cU(e,"Failed to answer the question"))}finally{m(!1)}}},[l,h,o,O]),J=(0,n.useCallback)(async(e,t)=>{if(!o||u)return;N.current?.abort();let n=new AbortController;N.current=n;let a=++S.current;p(e);try{if(await (0,e5.apiFetch)(`/v1/approval-requests/${encodeURIComponent(o.id)}/decision`,{method:"POST",headers:{"Idempotency-Key":cK()},body:JSON.stringify({decision:e,clientRequestId:cK(),standingGrantCallIndexes:t??[]}),signal:n.signal}),n.signal.aborted||S.current!==a)return;x(iN("approved"===e?"approval_granted":"approval_rejected")),!P.current&&l&&(T.current=null,O({...l,status:"queued"}))}catch(e){n.signal.aborted||S.current!==a||w(e.message)}finally{n.signal.aborted||S.current!==a||p(null)}},[l,o,u,O]);return{activeRun:l,activeRunID:l?.id??null,contextUsage:b,compacting:l?.runKind==="context_compaction",pendingApproval:o,resolvingApproval:u,answeringQuestion:h,answerQuestion:G,status:g,setStatus:x,usage:v,error:j,setError:w,watchRun:O,cancel:H,steer:W,followUp:V,cancelFollowUp:K,pendingFollowUps:$,decideApproval:J}}({sessionId:c,lineageId:v,appendMessage:j.appendTransient,upsertMessage:j.upsertTransient,refreshLatest:j.refreshLatest,refreshSession:k,activeRun:j.activeRun,pendingApproval:j.pendingApproval,queuedInputs:j.queuedInputs}),_=function(e,t,a){let[s,i]=(0,n.useState)(null),[r,l]=(0,n.useState)(),[o,c]=(0,n.useState)(!1),[d,u]=(0,n.useState)(null),p=(0,n.useRef)(0),h=(0,n.useCallback)(async n=>{if(!e||a)return void i(null);let s=p.current;try{let a=await (0,e5.apiFetch)(`/v1/sessions/${encodeURIComponent(e)}/recovery`,{signal:n});n?.aborted||p.current!==s||(i(a),l(t),u(null))}catch(e){n?.aborted||p.current!==s||u(e.message)}},[a,t,e]);(0,n.useEffect)(()=>{let e=++p.current,t=new AbortController;return queueMicrotask(()=>{p.current===e&&(i(null),l(void 0),u(null),h(t.signal))}),()=>t.abort()},[t,h]);let m=(0,n.useCallback)(async()=>{if(!s?.retryable||o)return null;c(!0);try{let e="u">typeof crypto&&crypto.randomUUID?crypto.randomUUID():Math.random().toString(36).slice(2)+Date.now().toString(36),t=await (0,e5.apiFetch)(`/v1/runs/${encodeURIComponent(s.run.id)}/retry`,{method:"POST",headers:{"Content-Type":"application/json","Idempotency-Key":e},body:JSON.stringify({clientRequestId:e})});return i(null),u(null),t.run}catch(e){return u(e.message),null}finally{c(!1)}},[s,o]);return{recovery:r===t?s:null,retrying:o,error:d,clearError:(0,n.useCallback)(()=>u(null),[]),retry:m,refresh:h}}(c,v,w.activeRunID),N=function(e,t){let[a,s]=(0,n.useState)(null);return(0,n.useEffect)(()=>{if(!e)return void s(null);let n=!1,a=()=>{(0,e5.apiFetch)(`/v1/sessions/${encodeURIComponent(e)}/stats`).then(e=>{n||s(e)}).catch(()=>{})};a();let i=t?window.setInterval(a,2e3):void 0;return()=>{n=!0,void 0!==i&&window.clearInterval(i)}},[e,t]),a}(c,w.activeRunID),C=function({sessionId:e,activeBranchId:t,onSessionUpdated:a}){let[s,i]=(0,n.useState)([]),[r,l]=(0,n.useState)(null),[o,c]=(0,n.useState)(!1),[d,u]=(0,n.useState)(!1),[p,h]=(0,n.useState)(null),m=(0,n.useRef)(0),f=(0,n.useCallback)(async t=>{if(!e)return;let n=m.current;c(!0);try{let a=await (0,e5.apiFetch)(`/v1/sessions/${encodeURIComponent(e)}/branches`,{signal:t});t?.aborted||m.current!==n||(i(a??[]),l(e),h(null))}catch(e){t?.aborted||m.current!==n||h(e.message)}finally{t?.aborted||m.current!==n||c(!1)}},[e]);(0,n.useEffect)(()=>{let t=++m.current,n=new AbortController;return queueMicrotask(()=>{m.current===t&&(h(null),e?f(n.signal):c(!1))}),()=>n.abort()},[t,f,e]);let g=(0,n.useCallback)(e=>{m.current+=1,i(e.branches),l(e.session.id),a(e.session),h(null)},[a]),x=(0,n.useCallback)(async(t,n)=>{if(!e||d)return!1;u(!0);try{let a=await (0,e5.apiFetch)(`/v1/sessions/${encodeURIComponent(e)}/branches`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({fromMessageId:t,...n?.trim()?{label:n.trim()}:{}})});return g(a),!0}catch(e){return h(e.message),!1}finally{u(!1)}},[g,d,e]),v=(0,n.useCallback)(async n=>{if(!e||d||n===t)return!1;u(!0);try{let t=await (0,e5.apiFetch)(`/v1/sessions/${encodeURIComponent(e)}/branches/${encodeURIComponent(n)}/activate`,{method:"POST"});return g(t),!0}catch(e){return h(e.message),!1}finally{u(!1)}},[t,g,d,e]);return{branches:r===e?s:[],loading:o,changing:d,error:p,clearError:(0,n.useCallback)(()=>h(null),[]),refresh:f,createBranch:x,activateBranch:v}}({sessionId:c,activeBranchId:v,onSessionUpdated:b}),{composer:S,actions:I}=function(e){let{selectedSession:t,selectedProject:a,sessionRecord:s,promptCatalog:i,settings:r,runtime:l}=e,o=(0,f.useT)(),[c,d]=(0,n.useState)(""),{pendingImage:u,textAttachments:p,uploadImage:h,attachFiles:m,removeTextAttachment:g,clearPendingImage:x,clearAttachments:v,restoreAttachments:y}=function(e){let{selectedProject:t,selectedSession:a,runtime:s}=e,[i,r]=(0,n.useState)(null),[l,o]=(0,n.useState)([]),c=(0,n.useCallback)(async e=>{if(!t||!a)return;let n=new FormData;n.set("sessionId",a),n.set("file",e);try{s.setStatus(iN("uploading_image"));let e=await (0,e5.apiFetch)(`/v1/projects/${encodeURIComponent(t)}/attachments/images`,{method:"POST",body:n});r(e),s.setError(null)}catch(e){s.setError(cU(e,"Failed to attach the image"))}finally{s.setStatus("")}},[t,a,s]),d=(0,n.useCallback)(async e=>{if(!a)return;let t=e.filter(e=>e.type.startsWith("image/")),n=e.filter(e=>!e.type.startsWith("image/"));t[0]&&await c(t[0]),t.length>1&&s.setError("Only one image can be attached to a turn.");let i=[];for(let e of n){if(!function(e){if(e.type.startsWith("text/"))return!0;let t=e.name.toLowerCase().split(".").pop()??"";return ds.has(t)||["dockerfile","makefile"].includes(e.name.toLowerCase())}(e)){s.setError(`${e.name} is not a supported text attachment.`);continue}if(e.size>1048576){s.setError(`${e.name} exceeds the 1 MiB text attachment limit.`);continue}i.push({id:"u">typeof crypto&&crypto.randomUUID?crypto.randomUUID():Math.random().toString(36).slice(2)+Date.now().toString(36),name:e.name,size:e.size,text:await e.text()})}i.length&&(o(e=>[...e,...i].slice(0,3)),l.length+i.length>3&&s.setError("A turn can include at most three text files."))},[a,s,l.length,c]),u=(0,n.useCallback)(e=>{o(t=>t.filter(t=>t.id!==e))},[]),p=(0,n.useCallback)(()=>r(null),[]);return{pendingImage:i,textAttachments:l,uploadImage:c,attachFiles:d,removeTextAttachment:u,clearPendingImage:p,clearAttachments:(0,n.useCallback)(()=>{r(null),o([])},[]),restoreAttachments:(0,n.useCallback)((e,t)=>{r(e),o(t)},[])}}({selectedProject:a,selectedSession:t,runtime:l}),[b,k]=(0,n.useState)({}),[j,w]=(0,n.useState)("discuss");(0,n.useEffect)(()=>{w(o$());let e=e=>{let t=e.detail;("discuss"===t||"ask"===t||"auto"===t)&&w(t)};return window.addEventListener(oE,e),()=>window.removeEventListener(oE,e)},[]);let[_,N]=(0,n.useState)({}),[C,S]=(0,n.useState)({open:!1,instructions:"",busy:!1}),{heroes:I,selectedHeroId:P,setSelectedHeroId:T}=function(e){let[t,a]=(0,n.useState)(null),[s,i]=(0,n.useState)([]);return(0,n.useLayoutEffect)(()=>{a(null)},[e]),(0,n.useEffect)(()=>{if(!e)return;let t=!1;return(0,e5.apiFetch)("/v1/global-heroes").then(async e=>{let n=await Promise.all((e??[]).filter(e=>!e.error).map(async e=>{try{let[t,n]=await Promise.all([(0,e5.apiFetch)(`/v1/global-heroes/${encodeURIComponent(e.id)}`),(0,e5.apiFetch)(`/v1/global-heroes/${encodeURIComponent(e.id)}/versions`)]),a=n.at(-1);if(!a)return null;return{id:e.id,handle:t.document.handle,name:t.document.name,description:t.document.description,positioning:t.document.positioning,icon:t.document.icon,color:t.document.color,scope:"global",status:"active",sourceKind:"managed",sourceLocator:t.path,currentVersionId:`v${String(a.version).padStart(6,"0")}`,currentVersion:a.version,updatedAt:a.publishedAt}}catch{return null}}));if(t)return;let s=n.filter(e=>null!==e);i(s),a(e=>s.some(t=>t.id===e)?e:null)}).catch(()=>{t||i([])}),()=>{t=!0}},[e]),{heroes:s,selectedHeroId:t,setSelectedHeroId:a}}(a),M=function(e){let[t,a]=(0,n.useState)([]),s=(0,n.useCallback)(async(t=()=>!0)=>{try{let n=e?`?${new URLSearchParams({projectID:e})}`:"",s=await (0,e5.apiFetch)(`/v1/skills${n}`);if(!t())return;a((s?.skills??[]).filter(e=>!!e.skillId&&e.sourceInfo?.scope!=="project").map(e=>({id:e.skillId??"",label:e.name||e.skillId||"",description:e.description,heroBound:!0===e.heroBound,boundBy:e.boundBy??[]})))}catch{}},[e]);return(0,n.useEffect)(()=>{let e=!1;return(async()=>{await s(()=>!e)})(),()=>{e=!0}},[s]),{skills:t,refresh:s}}(a),[R,E]=(0,n.useState)([]),[A,$]=(0,n.useState)(null),z=(0,n.useRef)(t),{setInputVersioned:F,expandDraftOrFallback:L,expandedVersion:D,draftVersion:O,flowCatalog:q,commandPanelOpen:B,promptPanelDismissed:U,setPromptPanelDismissed:H,expanding:W,expandDiag:V,setExpandDiag:K}=function(e){let{selectedProject:t,selectedSession:a,input:s,promptCatalog:i,heroes:r,setInput:l,setError:o}=e,[c,d]=(0,n.useState)(0),[u,p]=(0,n.useState)(null),[h,m]=(0,n.useState)(!1),[f,g]=(0,n.useState)(null),[x,v]=(0,n.useState)(!1),y=(0,n.useRef)(null),[b,k]=(0,n.useState)([]),j=(0,n.useCallback)(e=>{l(e),d(e=>e+1),p(null),(!e.startsWith("/")||/\s/.test(e.slice(1)))&&v(!1)},[l]),w=(0,n.useCallback)(async()=>{try{let e=await (0,e5.apiFetch)("/v1/graphs");k((e??[]).filter(e=>(e.latestVersion??0)>0).map(e=>({name:e.id,version:e.latestVersion})))}catch{}},[]);(0,n.useEffect)(()=>{let e=window.setTimeout(()=>void w(),0);return()=>window.clearTimeout(e)},[w]);let _=!!(t&&!s.slice(1).match(/[\s]/)&&(s.startsWith("/")&&i.templates.length>0||s.startsWith("@role")&&r.length>0||s.startsWith("@graph")&&b.length>0||s.startsWith("@")&&(r.length>0||b.length>0))),N=(0,n.useRef)(!1);(0,n.useEffect)(()=>{_&&!N.current&&(i.refresh(),w()),N.current=_},[_,i,w]);let C=(0,n.useCallback)(async(e,t)=>{y.current?.abort();let n=new AbortController;y.current=n;try{let a=await (0,e5.apiFetch)(`/v1/projects/${encodeURIComponent(t)}/prompt-templates/expand`,{method:"POST",body:JSON.stringify({invocation:e}),signal:n.signal});if(n.signal.aborted)return null;return a}catch(e){if(n.signal.aborted)return null;throw e}},[]);return{setInputVersioned:j,expandDraftOrFallback:(0,n.useCallback)(async(e,n,s)=>{m(!0),g(null);try{let s=await C(e,n.project);if(!s||n.project!==t||n.session!==a||n.draftVersion!==c)return null;switch(s.case){case"matched":{let e=s.text.trim();if(!e)return o("Expanded prompt is empty."),{status:"empty"};return l(e),d(e=>e+1),p(c+1),{status:"matched",text:e,diagnostics:s.diagnostics}}case"not_found":case"invalid_invocation":return{status:"fallthrough"}}}catch(e){return o(cU(e,s)),null}finally{m(!1)}},[o,t,a,c,C,l,d,p,m,g]),expandedVersion:u,draftVersion:c,flowCatalog:b,commandPanelOpen:_,promptPanelDismissed:x,setPromptPanelDismissed:v,expanding:h,expandDiag:f,setExpandDiag:g}}({selectedProject:a,selectedSession:t,input:c,promptCatalog:i,heroes:I,setInput:d,setError:l.setError});(0,n.useEffect)(()=>{z.current=t},[t]);let G=(0,n.useRef)(t);(0,n.useLayoutEffect)(()=>{let e=G.current;G.current=t,null===e&&t||(F(""),E([]),$(null),v())},[t,F,v]);let J=t?b[t]??s?.defaultModelProfileId??r.models.find(e=>e.isDefault)?.id??r.models[0]?.id??null:null,Y=t?_[t]??"default":"default",Q=(0,n.useCallback)(e=>{t&&N(n=>({...n,[t]:e}))},[t]),Z=(0,n.useCallback)(()=>{var e;let t,n;return e=r.policies,t=e.filter(e=>"tool"===e.kind&&"active"===e.status&&e.config.mode===j),n=RegExp(`^builtin-tool-${j}-v\\d+$`),t.find(e=>n.test(e.id))?.id??t[0]?.id},[j,r.policies]),X=(0,n.useCallback)(()=>(function(e,t){let n=da(e?.effectiveConfig),a=da(n?.hero)?.permissionCeiling;if(dn(a))return a;let s=da(n?.toolPolicy)?.id,i=da(e?.requestedConfig)?.toolPolicyProfileId;return function(e,t){if("string"!=typeof t||!t)return;let n=e.find(e=>e.id===t&&"tool"===e.kind),a=n?.config.mode;if(dn(a))return a;let s=/^builtin-tool-(discuss|ask|auto)-v\d+$/.exec(t)?.[1];return"discuss"===s||"ask"===s||"auto"===s?s:void 0}(t,s??i)})(l.activeRunRecord,r.policies)??j,[l.activeRunRecord,j,r.policies]),ee=(0,n.useCallback)(async(e,n)=>{if(!t)return;let a=function(e,t){if(0===t.length)return e;let n=t.map(e=>[`--- Attached file: ${e.name} ---`,e.text,`--- End attached file: ${e.name} ---`].join("\n"));return[e.trim(),...n].filter(Boolean).join("\n\n")}(e,p),s=p.length?`[Files: ${p.map(e=>e.name).join(", ")}]`:"",i=di();F(""),v(),l.setStatus(iN("sending")),l.appendTransient({id:i,role:"user",text:[e,u?`[Image: ${u.name}]`:"",s].filter(Boolean).join("\n")});try{let e=u?{content:[...a?[{type:"text",text:a}]:[],{type:"image",artifactId:u.id}]}:{text:a},s=I.find(e=>e.id===P)??null,i=`/v1/sessions/${encodeURIComponent(t)}/invocations`,r=R.map(e=>({id:e})),o=r.length>0?{...e,skills:r}:e,c=s&&s.currentVersionId?{...o,target:{kind:"hero",objectId:s.id,versionId:s.currentVersionId,contextMode:"room"}}:{...{...o,config:{toolPolicyProfileId:n,...J?{modelProfileId:J}:{},...Y?{thinkingEffort:Y}:{}}},target:{kind:"host"}},d=await (0,e5.apiFetch)(i,{method:"POST",headers:{"Idempotency-Key":di()},body:JSON.stringify(c)});if(z.current!==t)return;E([]),l.setError(null),l.watchRun(d.run)}catch(n){z.current===t&&(F(e),y(u,p),l.removeTransient(i),l.setStatus(""),l.setError(cU(n,"Failed to send the message")))}},[t,u,p,l,J,P,I,R,F,Y,v,y]),et=!!l.activeRunID,en=(0,n.useCallback)(async(e,n,a)=>{if(!t)return l.setError("Select a session before invoking a graph."),!1;let s={};if(a)for(let e of a.split(/\s+/)){let[t,...n]=e.split("=");t&&n.length>0&&(s[t]=n.join("="))}try{return await (0,e5.apiFetch)(`/v1/graphs/${encodeURIComponent(e)}/runs`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:t,name:e,version:n??0,inputs:s})}),F(""),l.setError(null),!0}catch(e){return l.setError(e instanceof Error?e.message:"Failed to invoke graph"),!1}},[t,l,F]),ea=Z(),es=(0,n.useCallback)(async()=>{if(!t||!c.trim()&&!u&&0===p.length&&!A||l.activeRunID)return;let e=c.trim().match(/^\/invoke_agent_flow\s+(\S+)(?:\s+([\s\S]+))?$/);if(e){let[t,n]=e[1].split("@");en(t,n?Number(n):void 0,e[2]);return}if(A){let e=c.trim(),t=e?/(^|\s)[A-Za-z_][\w-]*=/.test(e)?e:`prompt=${JSON.stringify(e)}`:void 0;en(A.name,A.version,t).then(e=>{e&&$(null)});return}let n=c.trim().match(/^@graph:([\w.-]+)(?:@(\d+))?(?:\s+([\s\S]+))?$/);if(n)return void en(n[1],n[2]?Number(n[2]):void 0,n[3]);if(!ea&&!P)return void l.setError(`The ${j} permission policy is unavailable.`);if(c.startsWith("/")&&D!==O&&a){let e=await L(c,{project:a,session:t,draftVersion:O},"Failed to expand prompt template");if(!e)return;if("matched"===e.status){e.diagnostics.some(e=>"arguments_fallback"===e.code)&&K("Arguments could not be fully parsed; using raw input.");return}"fallthrough"===e.status&&ee(c,ea??"");return}ee(c,ea??"")},[t,c,u,p.length,ea,j,A,l,ee,a,P,D,O,en,L,K]),ei=(0,n.useCallback)(async()=>{if(l.activeRunID&&c.trim()){if(l.questionPending)return void l.setError(o("composer.answerQuestionFirst"));if(c.startsWith("/")&&D!==O&&a){let e=await L(c,{project:a,session:t,draftVersion:O},"Failed to expand");if(!e||"matched"===e.status)return;"fallthrough"===e.status&&(F(""),await l.steer(c)||F(c));return}F(""),await l.steer(c)||F(c)}},[l,c,a,t,D,O,F,L,o]),er=(0,n.useCallback)(async e=>!!l.activeRunID&&!!e.trim()&&(l.questionPending?(l.setError(o("composer.answerQuestionFirst")),!1):l.steer(e)),[l,o]),el=(0,n.useCallback)(async()=>{if(!l.activeRunID||!c.trim())return;F("");let{queued:e,runEnded:n}=await l.followUp(c);if(!e){if(n&&t)return void ee(c,ea??"");F(c)}},[l,c,ee,ea,t,F]),eo=(0,n.useCallback)(e=>{t&&(k(n=>({...n,[t]:e})),(0,e5.apiFetch)(`/v1/sessions/${encodeURIComponent(t)}`,{method:"PATCH",body:JSON.stringify({defaultModelProfileId:e})}).then(()=>{z.current===t&&l.refreshSelectedSession()}).catch(e=>{z.current===t&&l.setError(cU(e,"Failed to select model"))}))},[l,t]),ec=(0,n.useCallback)(async()=>{if(!t||l.activeRunID)return;let e=await l.refreshSelectedSession();e?.activeLeafMessageId?S({open:!0,instructions:"",busy:!1}):l.setError("This session has no conversation history to compact.")},[l,t]),ed=(0,n.useCallback)(async()=>{if(!t||l.activeRunID)return;let e=C.instructions.trim();S(e=>({...e,busy:!0}));try{let n=await l.refreshSelectedSession();if(!n?.activeLeafMessageId){l.setError("This session has no conversation history to compact."),S({open:!1,instructions:"",busy:!1});return}let a=await (0,e5.apiFetch)(`/v1/sessions/${encodeURIComponent(t)}/compactions`,{method:"POST",headers:{"Idempotency-Key":di()},body:JSON.stringify({baseMessageId:n.activeLeafMessageId,instructions:e})}),s=await (0,e5.apiFetch)(`/v1/runs/${encodeURIComponent(a.runId)}`);l.setError(null),S({open:!1,instructions:"",busy:!1}),l.watchRun(s)}catch(e){l.setError(e.message),S(e=>({...e,busy:!1}))}},[l,C.instructions,t]),eu=(0,n.useCallback)(()=>{S(e=>e.busy?e:{open:!1,instructions:"",busy:!1})},[]);return{composer:{sessionId:t,activeLeafMessageId:s?.activeLeafMessageId,input:c,setInput:F,pendingImage:u,clearPendingImage:x,uploadImage:e=>void h(e),textAttachments:p,removeTextAttachment:g,attachFiles:e=>void m(e),models:r.models.filter(e=>"active"===e.status),providers:r.providers,selectedModelId:J,setSelectedModelId:eo,thinkingEffort:Y,setThinkingEffort:Q,heroes:I,selectedHeroId:P,setSelectedHeroId:T,permissionMode:j,displayedPermissionMode:X(),permissionReady:!!ea,setPermissionMode:w,compactSession:()=>void ec(),compaction:{open:C.open,instructions:C.instructions,busy:C.busy,setInstructions:e=>S(t=>({...t,instructions:e})),confirm:()=>void ed(),cancel:eu},promptPanel:{templates:i.templates,heroes:I.map(e=>({id:e.id,handle:e.handle,name:e.name,description:e.description})),flows:q,show:B&&!U,skills:M.skills,oneShotLocked:et,pendingSkills:R,pendingGraph:A,toggleSkill:e=>E(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e]),clearPendingGraph:()=>$(null),onSelect:e=>{H(!1),F(`/${e} `)},onHeroSelect:e=>{T(""===e?null:e),H(!0)},onFlowSelect:(e,t)=>{H(!1),$({name:e,version:t})},onClose:()=>H(!0),expanding:W,expandDiag:V}},actions:{submit:es,steer:ei,steerText:er,followUp:el}}}({selectedSession:c,selectedProject:u,sessionRecord:d,promptCatalog:p,settings:h,runtime:{activeRunID:w.activeRunID,activeRunRecord:w.activeRun,questionPending:w.pendingApproval?.kind==="question",setStatus:w.setStatus,setError:w.setError,watchRun:w.watchRun,steer:w.steer,followUp:w.followUp,appendTransient:j.appendTransient,removeTransient:j.removeTransient,refreshSelectedSession:k}}),P=w.activeRunID,{decideApproval:T}=w,{createBranch:M}=C,R=(0,n.useCallback)(async e=>{P||await M(e)},[P,M]),E=async e=>{P||await C.activateBranch(e)},A=(0,n.useCallback)(e=>void T(e),[T]),$=(0,n.useCallback)(e=>void R(e),[R]),z=(0,n.useCallback)(async()=>{let e=await _.retry();e&&w.watchRun(e)},[_,w]),F=(0,n.useCallback)(()=>{w.setError(null),_.clearError(),C.clearError()},[w,_,C]),L=w.error??_.error??C.error,D={sessionId:c,activeBranchId:v,activeLeafMessageId:y,messages:j.messages,loading:j.loading,loadingOlder:j.loadingOlder,error:j.historyError,hasMore:j.hasMore,loadOlder:j.loadOlder};return{history:D,run:{activeRun:w.activeRunID,inspectorRunId:w.activeRunID??function(e){for(let t=e.length-1;t>=0;t-=1){let n=e[t];if("turn"===n.kind&&n.runId)return n.runId}return null}(j.messages),activeRunStatus:w.activeRun?.status,startedAt:w.activeRun?.startedAt||w.activeRun?.createdAt||null,status:w.status,usage:w.usage,contextUsage:w.contextUsage,stats:N,compacting:w.compacting,pendingApproval:w.pendingApproval,resolvingApproval:w.resolvingApproval,decideApproval:A,answeringQuestion:w.answeringQuestion,answerQuestion:w.answerQuestion,cancel:()=>void w.cancel(),pendingFollowUps:w.pendingFollowUps,cancelFollowUp:w.cancelFollowUp,recovery:_.recovery,retrying:_.retrying,retryRun:()=>void z(),error:w.error,setError:w.setError,clearError:()=>w.setError(null)},branches:{branches:C.branches,activeBranchId:v,loading:C.loading,changing:C.changing,error:C.error,createBranch:$,activateBranch:e=>void E(e)},composer:S,actions:I,error:L,clearError:F}}({selectedSession:y,sessionRecord:B,selectedProject:r,promptCatalog:U,settings:O,replaceSession:q}),W=function(e,t){let[a,s]=(0,n.useState)(new Set),i=[...new Set(e)].sort().join("\0");return(0,n.useEffect)(()=>{if(!i)return;let e=i.split("\0"),t=new AbortController,n=async()=>{let n=await Promise.all(e.map(async e=>{try{let n=await (0,e5.apiFetch)(`/v1/projects/${encodeURIComponent(e)}/active-runs`,{signal:t.signal});return n?.sessionIds??[]}catch{return[]}}));t.signal.aborted||s(new Set(n.flat()))};n();let a=window.setInterval(()=>void n(),15e3);return()=>{t.abort(),window.clearInterval(a)}},[i]),(0,n.useMemo)(()=>{let e=new Set(i?a:[]);return t&&e.add(t),e},[t,a,i])}(D.groups.flatMap(e=>[e.projectId]),H.run.activeRun?y:null),K=O.refresh,G=(0,n.useCallback)(e=>{u(e),K()},[K,u]),{closeSettings:J}=function({loading:e,error:t,providers:a,openSettings:s,closeSettings:i}){let r=(0,n.useRef)(!1),l=(0,n.useCallback)(()=>{try{window.localStorage.setItem(cD,"1")}catch{}i()},[i]);return(0,n.useEffect)(()=>{if(r.current||e||t||a.some(e=>e.credentialConfigured))return;let n=!1;try{n="1"===window.localStorage.getItem(cD)}catch{}n||(r.current=!0,s("models"))},[e,t,a,s]),{closeSettings:l}}({loading:O.loading,error:O.error,providers:O.providers,openSettings:G,closeSettings:p}),Y=(0,n.useCallback)(e=>{l(e),_("chat"),N(null),L.setView("active"),L.setQuery(""),a&&F()},[_,F,a,N,L,l]),Q=(0,n.useCallback)(async e=>{let t=k.current;try{let n=await (0,dy.reuseOrCreateBlankSession)(e,L.activeSessions);H.run.setError(null),L.replaceSession(n),k.current===t&&(N(n.id),_("chat")),await L.refresh(),D.refresh(e)}catch(e){H.run.setError(e.message)}},[_,N,L,D,H.run]),Z=(0,n.useCallback)(async e=>{l(e),await Q(e)},[Q,l]),X=(0,n.useCallback)(async()=>{r&&await Z(r)},[Z,r]);!function(e){let{projectsReady:t,selectedProject:a,selectedSession:s,sessions:i,sessionsLoading:r,selectSession:l,connectBlank:o}=e,c=(0,n.useRef)("waiting");(0,n.useEffect)(()=>{if(!t)return;if(!a){s&&l(null),c.current="done";return}if(r)return;if(s&&i.some(e=>e.id===s)){(0,dy.writeStoredId)(dy.SELECTED_SESSION_KEY,s),c.current="done";return}if("done"===c.current){if(s)return;let e=i.find(R.isBlankSession);e&&l(e.id);return}if("connecting"===c.current)return;let e=(0,dy.readStoredId)(dy.SELECTED_SESSION_KEY);if(e&&i.some(t=>t.id===e)){l(e),c.current="done";return}c.current="connecting",s&&l(null),o(a).finally(()=>{c.current="done"})},[t,a,s,i,r,l,o])}({projectsReady:i,selectedProject:r,selectedSession:y,sessions:L.activeSessions,sessionsLoading:L.loading,selectSession:N,connectBlank:Q});let ee=(0,n.useCallback)(async(e,t)=>{let n=await (0,e5.apiFetch)(`/v1/sessions/${encodeURIComponent(e.id)}`,{method:"PATCH",body:JSON.stringify({title:t})});L.replaceSession(n),D.refresh(e.projectId)},[L,D]),et=(0,n.useCallback)(async(e,t)=>{await x(e,t),D.refresh(e)},[x,D]),en=(0,n.useCallback)(async e=>{await v(e)},[v]),ea=(0,n.useCallback)(e=>{J(),_("chat"),N(e),(0,e5.apiFetch)(`/v1/sessions/${encodeURIComponent(e)}`).then(L.replaceSession).catch(()=>{}),a&&F()},[_,F,J,a,N,L]),es=(0,n.useCallback)(async e=>{let t=await L.archive(e);t&&(D.refresh(e.projectId),D.refreshArchived(e.projectId)),t&&y===e.id&&N(null)},[N,L,D,y]),ei=(0,n.useCallback)(async e=>{await L.restore(e),D.refresh(e.projectId),D.refreshArchived(e.projectId)},[L,D]),er=B?.projectId??r,{currentCwd:el,panel:eo,handleOpenFile:ec,handlePreviewFile:ed,panelOpen:eu,openPanel:ep,closePanel:eh}=function({projectId:e,workspaceFor:t,setRunError:a,onPreviewFile:s}){let i=e?t(e)??null:null,r=i?.hostPath??null;(0,n.useEffect)(()=>{if(!e||t(e))return;let n=new AbortController;return(0,e5.apiFetch)(`/v1/projects/${encodeURIComponent(e)}/workspace`,{signal:n.signal}).catch(e=>{n.signal.aborted||a(e.message)}),()=>n.abort()},[e,a,t]);let l=function(e){let[t,a]=(0,n.useState)(()=>ot(l9(e??""))),[s,i]=(0,n.useState)(null),[r,l]=(0,n.useState)(0),o=(0,n.useRef)(new Map),c=(0,n.useRef)(null),d=(0,n.useRef)(!1),u=(0,n.useRef)(null),p=(0,n.useRef)(!1),h=e??"",m=(0,n.useCallback)(e=>{var t;if(!e||!e.projectId||null===s||p.current||d.current)return;let n=JSON.stringify({version:1,projectId:(t={version:1,projectId:e.projectId,pinnedChannels:l7(e.pinnedChannels),primaryWidth:e.primaryWidth,open:e.open,inspectorTabs:oe(e.inspectorTabs),activeInspectorId:e.activeInspectorId,navigatorHidden:e.navigatorHidden}).projectId,pinnedChannels:l7(t.pinnedChannels),primaryWidth:t.primaryWidth,open:t.open,inspectorTabs:oe(t.inspectorTabs),navigatorHidden:!0===t.navigatorHidden,activeInspectorId:t.activeInspectorId??null});if(c.current!==n)try{window.localStorage.setItem(l8(e.projectId),n),c.current=n}catch{}},[s]);(0,n.useEffect)(()=>{if(s===h)return;m(u.current);let t=e?function(e,t){try{return function(e,t){let n;if(null===e)return l9(t);try{n=JSON.parse(e)}catch{return l9(t)}if("object"!=typeof n||null===n)return l9(t);let a=n;if(1!==a.version||a.projectId!==t)return l9(t);let s=Array.isArray(a.pinnedChannels)?l7(a.pinnedChannels.filter(l6)):[],i="number"==typeof a.primaryWidth&&Number.isFinite(a.primaryWidth)?a.primaryWidth:280,r=oe(a.inspectorTabs),l="string"==typeof a.activeInspectorId&&r.some(e=>`file:${t}:${e.path}`===a.activeInspectorId)?a.activeInspectorId:null;return{version:1,projectId:t,pinnedChannels:s,primaryWidth:i,open:!0===a.open,inspectorTabs:r,activeInspectorId:l,navigatorHidden:!0===a.navigatorHidden}}(window.localStorage.getItem(l8(e)),e)}catch{return t.current=!0,l9(e)}}(e,p):l9("");a(()=>{let n=ot(t),a=n.inspectorTabs.map(t=>oa(e??"",t.path)),s=o.current.get(h)??n.activeInspectorId??void 0,i=void 0!==s&&a.includes(s)?s:null;return{...n,activeInspectorId:i,activeLane:null===i?"channel":"inspector"}}),i(h)},[h,e,s,m]);let f=(0,n.useMemo)(()=>(t.projectId===e?t.inspectorTabs:[]).map(t=>({id:oa(e??"",t.path),label:t.name,filePath:t.path,projectId:e??void 0})),[t.projectId,t.inspectorTabs,e]),g=(0,n.useMemo)(()=>f.map(e=>e.id),[f]),x="inspector"===t.activeLane&&null!==t.activeInspectorId&&g.includes(t.activeInspectorId)?t.activeInspectorId:null,v=l6(t.activeChannelId)&&t.openChannels.includes(t.activeChannelId)?t.activeChannelId:t.openChannels[0]??null;(0,n.useEffect)(()=>{!e||t.projectId!==e||s!==e||d.current||p.current||m(t)},[e,t,s,r,m]),(0,n.useEffect)(()=>{u.current=t},[t]);let y=(0,n.useCallback)((t,n)=>{if(!e)return;let s=oa(e,t);o.current.set(e,s),a(e=>oi(e,s,{path:t,name:n}))},[e]),b=(0,n.useCallback)(t=>{l6(t)||o.current.set(e??"",t),a(e=>l6(t)?os(e,t):oi(e,t,e.inspectorTabs.find(n=>oa(e.projectId,n.path)===t)??{path:on(t),name:on(t).split("/").filter(Boolean).pop()??t}))},[e]),k=(0,n.useCallback)(t=>{l6(t)||(o.current.get(e??"")===t&&o.current.delete(e??""),a(e=>{let n,a;return n=e.inspectorTabs.filter(e=>e.path!==on(t)).map(t=>oa(e.projectId,t.path)),a=e.activeInspectorId===t?n[n.length-1]??null:e.activeInspectorId,{...e,inspectorTabs:e.inspectorTabs.filter(e=>e.path!==on(t)),activeInspectorId:a,activeLane:null===a?"channel":e.activeLane}}))},[e]),j=(0,n.useCallback)((e,t)=>{a(n=>(function(e,t,n){let a=e.inspectorTabs.findIndex(e=>e.path===t),s=e.inspectorTabs.findIndex(e=>e.path===n);if(a<0||s<0||a===s)return e;let i=[...e.inspectorTabs],[r]=i.splice(a,1);return i.splice(s,0,r),{...e,inspectorTabs:i}})(n,on(e),on(t)))},[]),w=(0,n.useCallback)(()=>{a(e=>{var t;return t=!e.navigatorHidden,e.navigatorHidden===t?e:{...e,navigatorHidden:t}})},[]),_=(0,n.useCallback)(e=>{a(t=>(function(e,t){if(!e.openChannels.includes(t))return e;let n=e.openChannels.filter(e=>e!==t);if(e.activeChannelId!==t)return{...e,openChannels:n};let a=l3.filter(e=>n.includes(e));return{...e,openChannels:n,activeChannelId:a[0]??null,activeLane:e.activeLane}})(t,e))},[]),N=(0,n.useCallback)(e=>{a(t=>os(t,e))},[]),C=(0,n.useCallback)(e=>{a(t=>{let n;return t.pinnedChannels.includes(e)?t.pinnedChannels.includes(e)?{...t,pinnedChannels:t.pinnedChannels.filter(t=>t!==e)}:t:(n=t.pinnedChannels.includes(e)?t.pinnedChannels:l7([...t.pinnedChannels,e]),os({...t,pinnedChannels:n},e))})},[]),S=(0,n.useCallback)((e,t)=>{a(n=>{var a;let s=lC(n.primaryWidth,t);return a=lC(s+e,t),n.primaryWidth===a?n:{...n,primaryWidth:a}})},[]);return{fileTabs:f,activeTabId:x??v??"files",activeInspectorId:x,activeChannelId:v,setActiveTabId:b,openInspector:y,closeTab:k,reorderTabs:j,closeChannelTab:_,toggleNavigator:w,openChannel:N,togglePin:C,resizePrimaryBy:S,beginPrimaryResize:(0,n.useCallback)(()=>{d.current=!0},[]),endPrimaryResize:(0,n.useCallback)(()=>{d.current=!1,l(e=>e+1)},[]),state:t,open:t.open,openShell:()=>a(e=>e.open?e:{...e,open:!0}),closeShell:()=>a(e=>e.open?{...e,open:!1}:e)}}(e),{openInspector:o}=l;return{currentWorkspace:i,currentCwd:r,panel:l,handleOpenFile:(0,n.useCallback)((e,t)=>{o(e,t)},[o]),handlePreviewFile:(0,n.useCallback)((t,n)=>{e&&s({projectId:e,path:t,name:n})},[e,s]),panelOpen:l.open,openPanel:l.openShell,closePanel:l.closeShell}}({projectId:er,workspaceFor:h,setRunError:H.run.setError,onPreviewFile:A}),em=function(e){let{session:t,replaceSession:a}=e,[s,i]=(0,n.useState)(!1),[r,l]=(0,n.useState)(""),o=(0,n.useRef)(null),c=(0,n.useCallback)(e=>e&&(e.title||e.id?.slice(0,12))||"",[]),d=(0,n.useCallback)(()=>{t&&(l(t.title||c(t)),i(!0),setTimeout(()=>o.current?.select(),0))},[c,t]),u=(0,n.useCallback)(async()=>{if(!t)return void i(!1);let e=r.trim();if(i(!1),e!==(t.title??""))try{let n=await (0,e5.apiFetch)(`/v1/sessions/${encodeURIComponent(t.id)}`,{method:"PATCH",body:JSON.stringify({title:e})});a(n)}catch{}},[t,r,a]),p=(0,n.useCallback)(e=>{"Enter"===e.key?(e.preventDefault(),u()):"Escape"===e.key&&(e.preventDefault(),e.stopPropagation(),i(!1))},[u]);return{title:t?c(t):"No session",editing:s,draft:r,setDraft:l,startEdit:d,save:u,keyDown:p,inputRef:o}}({session:B,replaceSession:L.replaceSession}),ef=el?el.replace(/\/+$/,"").split(/[\\/]/).filter(Boolean).pop()||el:"",eg=(0,t.jsx)(V,{projects:s,groups:D.groups,selectedProject:r,selectedSession:y,settingsOpen:c,query:L.query,setQuery:L.setQuery,mutatingId:L.mutatingId,announcement:L.announcement,pinnedProjectIds:g,togglePinProject:m,renameProject:et,deleteProject:en,collapsed:D.collapsed,toggleCollapsed:D.toggleCollapsed,archived:D.archived,openArchived:D.openArchived,createProject:o,createSession:X,createSessionIn:Z,renameSession:ee,switchProject:Y,switchSession:ea,archiveSession:e=>void es(e),restoreSession:e=>void ei(e),openSettings:G,closeNavigation:F,runningSessionIds:W,onToggleSidebar:()=>P(e=>!e),projectSelector:S,view:j,setView:_}),ex=H.error??L.error,ev=(0,n.useSyncExternalStore)(db,dk,dj);return(0,t.jsx)(rh,{children:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"app-shell","data-testid":"ennote-shell",children:[(0,t.jsx)("div",{className:"sidebar-overlay-backdrop","data-open":I||void 0,onClick:F}),(0,t.jsx)("div",{className:`sidebar-container${I?" sidebar-open":" sidebar-closed"}`,role:a&&I?"dialog":void 0,"aria-modal":a&&I?"true":void 0,"aria-label":a&&I?"Navigation":void 0,id:"workspace-navigation",style:{width:a?void 0:I?C.width:0,minWidth:a?void 0:I?C.width:0,transition:I||C.isResizing?"none":void 0},children:eg}),I&&!a&&(0,t.jsx)(lw,{side:"right",ariaLabel:"Resize sidebar",value:C.width,min:264,max:420,onResizeStart:C.beginResize,onResize:C.resizeBy,onResizeEnd:C.endResize}),(0,t.jsxs)("div",{className:"workspace-content",inert:a&&I,children:[(0,t.jsx)(c$,{workerUnreachable:ev}),"chat"===j?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(rQ,{sidebarOpen:I,onToggleSidebar:()=>P(e=>!e),navigationTriggerRef:$,session:B,title:em,projectName:ef,projectPath:el,branch:{branches:H.branches.branches,activeBranchId:H.branches.activeBranchId,loading:H.branches.loading,changing:H.branches.changing,disabled:!!H.run.activeRun,onActivate:H.branches.activateBranch},rightPanelOpen:eu,onToggleRightPanel:()=>eu?eh():ep(),attention:{projectId:r??er??void 0,onNavigate:e=>{e.sessionId&&e.sessionId!==y&&ea(e.sessionId)}}}),(0,t.jsx)(rM,{history:H.history,run:H.run,branches:H.branches,composer:H.composer,actions:H.actions,error:ex,clearError:()=>{H.clearError(),L.setError(null)},projects:s,selectedProject:r,hasModel:O.models.length>0,pinnedProjectIds:g,togglePinProject:m,onSwitchProject:e=>void Z(e),onNewProject:o,onOpenSettings:G})]}):(0,t.jsx)(dv,{view:j,models:O.models,providers:O.providers,onBackToChat:()=>_("chat"),onOpenMobileNav:()=>P(!0),menuTriggerRef:z})]}),"chat"===j&&eu&&(0,t.jsx)(ol,{resize:T}),"chat"===j&&(0,t.jsx)(or,{open:eu,onClose:eh,resize:T,panel:eo,projectId:er??null,displayPath:el,onOpenFile:ec,onPreviewFile:ed,selectedSession:y,sessionTitle:B?.title||y||"",activeRun:H.run.activeRun,inspectorRunId:H.run.inspectorRunId,status:H.run.status,permissionMode:H.composer.displayedPermissionMode})]}),E&&(0,t.jsx)(oo,{projectId:E.projectId,filePath:E.path,fileName:E.name,onClose:()=>A(null)}),(0,t.jsx)(cE,{settingsOpen:c,settingsTab:d,onCloseSettings:J,providers:O.providers,models:O.models,policies:O.policies,session:B,projectId:r,error:O.error,refresh:O.refresh,setError:O.setError,onSessionUpdated:L.replaceSession})]})})}],59665)}]);
8
+ Only selected tools will be exposed to Runs.`,confirmLabel:"Enable server"}))return}await h(n,{desiredEnabled:e})},className:oQ.default.enableButton,"data-enabled":n.desiredEnabled||void 0,children:n.desiredEnabled?"Enabled":"Disabled"}),(0,t.jsx)("button",{type:"button",title:"Test connection",onClick:()=>v(n),className:oQ.default.ghostButton,children:"Test"}),(0,t.jsx)("button",{type:"button",title:"Refresh tool catalog",onClick:()=>y(n),className:oQ.default.ghostButton,children:"Refresh"}),(0,t.jsx)("button",{type:"button",title:"Remove binding",onClick:()=>b(n),className:`${oQ.default.ghostButton} ${oQ.default.danger}`,children:"Remove"})]})]}),n.desiredEnabled&&(0,t.jsxs)("div",{children:[(0,t.jsxs)("div",{className:oQ.default.toolsHeader,children:[(0,t.jsx)("span",{className:oQ.default.toolsHint,children:"Selected tools (exact, frozen per Run)"}),k.length>0&&(0,t.jsx)("button",{type:"button",onClick:()=>f(n,k),className:oQ.default.ghostButton,children:"Select all current"})]}),0===k.length?(0,t.jsx)("div",{className:oQ.default.catalogEmpty,children:"No catalog yet — press Refresh to discover tools from the server."}):(0,t.jsxs)("div",{children:[(0,t.jsx)("input",{type:"search",placeholder:"Search tools…",value:s[n.id]??"",onChange:e=>i(t=>({...t,[n.id]:e.target.value})),className:`${oQ.default.input} ${oQ.default.toolSearch}`}),(0,t.jsx)("div",{className:oQ.default.catalogScroll,children:(0,t.jsx)("table",{className:oQ.default.catalogTable,children:(0,t.jsx)("tbody",{children:k.filter(e=>{let t=(s[n.id]??"").toLowerCase();return!t||e.remoteName.toLowerCase().includes(t)||(e.description??"").toLowerCase().includes(t)}).map(e=>(0,t.jsxs)("tr",{className:oQ.default.toolRow,children:[(0,t.jsx)("td",{className:oQ.default.toolCheckCell,children:(0,t.jsx)("input",{type:"checkbox",className:oQ.default.toolCheckbox,"aria-label":e.remoteName,checked:j.includes(e.remoteName),onChange:()=>m(n,e.remoteName)})}),(0,t.jsx)("td",{className:oQ.default.toolNameCell,children:e.remoteName}),(0,t.jsx)("td",{className:oQ.default.toolDescriptionCell,children:e.description||"—"})]},e.remoteName))})})})]})]}),r[n.id]&&(0,t.jsxs)("div",{className:oQ.default.credentials,children:[(0,t.jsx)("div",{className:oQ.default.credentialNote,children:"Credential references (env: / file: / keyring: refs only — values never stored or shown)"}),Object.entries(n.credentialRefs??{}).map(([e,a])=>(0,t.jsxs)("div",{className:oQ.default.credentialRow,children:[(0,t.jsx)("code",{className:oQ.default.credentialEnv,children:e}),(0,t.jsx)("code",{className:oQ.default.credentialRef,children:a}),(0,t.jsx)("button",{type:"button",onClick:()=>x(n,e),className:oQ.default.ghostButton,children:"Remove"})]},e)),0===Object.keys(n.credentialRefs??{}).length&&(0,t.jsx)("div",{className:oQ.default.credentialNote,children:"No binding-level credentials. The profile version's defaults apply."}),(0,t.jsxs)("div",{className:oQ.default.credentialInputRow,children:[(0,t.jsx)("input",{value:o[n.id]??"",onChange:e=>c(t=>({...t,[n.id]:e.target.value})),placeholder:"ENV_NAME",className:`${oQ.default.input} ${oQ.default.credentialEnvInput}`}),(0,t.jsx)("input",{value:d[n.id]??"",onChange:e=>u(t=>({...t,[n.id]:e.target.value})),placeholder:"env:MY_REF / file:... / keyring:...",className:`${oQ.default.input} ${oQ.default.credentialRefInput}`}),(0,t.jsx)("button",{type:"button",onClick:()=>g(n),disabled:!(o[n.id]??"").trim()||!(d[n.id]??"").trim(),className:oQ.default.ghostButton,children:"Add"})]})]})]},n.id)}function o1({mcp:e}){let{profiles:n,candidates:a,bindings:s,versions:i,diffView:r,bindCandidate:l,openProfileDiff:o,archiveProfile:c}=e;return 0===a.length&&0===n.length?null:(0,t.jsxs)("div",{children:[(0,t.jsx)("div",{className:oQ.default.sectionHeader,children:"Discovered servers"}),(0,t.jsxs)("div",{className:oQ.default.list,children:[a.map(e=>{let a;return(0,t.jsxs)("div",{className:oQ.default.candidateGroup,children:[(0,t.jsxs)("div",{className:oQ.default.candidateRow,children:[(0,t.jsxs)("div",{className:oQ.default.candidateIdentity,children:[(0,t.jsx)("span",{className:oQ.default.candidateName,children:e.displayName??e.slug}),(0,t.jsxs)("span",{className:oQ.default.candidateMeta,children:[e.transport," · ",e.sourceKind]}),"project_file"===e.sourceKind&&(0,t.jsx)("div",{className:oQ.default.candidateSource,children:e.sourceLocator})]}),(0,t.jsxs)("div",{className:oQ.default.candidateActions,children:[e.alreadyBound?(0,t.jsx)("span",{className:oQ.default.boundBadge,children:"Bound"}):(0,t.jsx)("button",{type:"button",onClick:()=>l(e),className:oQ.default.ghostButton,children:"Bind"}),e.alreadyBound&&e.updateAvailable&&(0,t.jsx)("button",{type:"button",title:"Project file changed; rebind to the new immutable version",onClick:()=>l(e),className:`${oQ.default.ghostButton} ${oQ.default.accent}`,children:"Update available"}),e.alreadyBound&&e.updateAvailable&&(0,t.jsx)("button",{type:"button",title:"Show the read-only diff between the bound version and the project file",onClick:()=>o(e),className:oQ.default.ghostButton,children:"View diff"}),"managed"===e.sourceKind&&!e.alreadyBound&&((a=n.find(t=>t.slug===e.slug&&"active"===t.lifecycleStatus))?(0,t.jsx)("button",{type:"button",title:"Archive MCP profile","aria-label":`Archive MCP profile ${a.displayName??a.slug}`,onClick:()=>c(a),className:`${oQ.default.ghostButton} ${oQ.default.danger} ${oQ.default.archiveButton}`,children:(0,t.jsx)(A,{size:14,"aria-hidden":"true"})}):null)]})]}),r&&r.slug===e.slug&&(0,t.jsxs)("div",{className:oQ.default.diffCard,children:[(0,t.jsxs)("div",{className:oQ.default.diffTitle,children:["Read-only diff: bound version vs project file",r.digestTo&&(0,t.jsxs)("span",{className:oQ.default.diffDigest,children:["new config ",r.digestTo.slice(0,8)]})]}),r.lines.some(e=>e.startsWith("+ ")||e.startsWith("- "))?(0,t.jsx)("div",{className:oQ.default.diffBody,children:r.lines.map((e,n)=>(0,t.jsx)("div",{className:oQ.default.diffLine,"data-kind":e.startsWith("- ")?"removed":e.startsWith("+ ")?"added":void 0,children:e},n))}):(0,t.jsxs)("div",{className:oQ.default.diffUnchanged,children:["Connection fields are unchanged — the project file changed argv, env, headers, or timeout (config digest ",r.digestTo?r.digestTo.slice(0,8):"changed",")."]})]})]},`${e.sourceKind}:${e.slug}`)}),n.filter(e=>!a.some(t=>t.slug===e.slug)).map(e=>{let n=new Set((i[e.id]??[]).map(e=>e.id)),a=s.some(e=>n.has(e.profileVersionId));return(0,t.jsxs)("div",{className:oQ.default.candidateRow,children:[(0,t.jsxs)("div",{className:oQ.default.candidateIdentity,children:[(0,t.jsx)("span",{className:oQ.default.candidateName,children:e.displayName}),(0,t.jsxs)("span",{className:oQ.default.candidateMeta,children:[e.slug," · v",e.latestVersion??0," · managed"]})]}),(0,t.jsx)("div",{className:oQ.default.candidateActions,children:a?(0,t.jsx)("span",{className:oQ.default.boundBadge,children:"Bound"}):(0,t.jsx)("button",{type:"button",title:"Archive MCP profile","aria-label":`Archive MCP profile ${e.displayName??e.slug}`,onClick:()=>c(e),className:`${oQ.default.ghostButton} ${oQ.default.danger} ${oQ.default.archiveButton}`,children:(0,t.jsx)(A,{size:14,"aria-hidden":"true"})})})]},e.id)})]})]})}function o2({projectId:e,setError:a}){let s=function(e,t){let[a,s]=(0,n.useState)([]),[i,r]=(0,n.useState)([]),[l,o]=(0,n.useState)([]),[c,d]=(0,n.useState)({}),[u,p]=(0,n.useState)({}),[h,m]=(0,n.useState)({}),[f,g]=(0,n.useState)({}),[x,v]=(0,n.useState)({}),[y,b]=(0,n.useState)({}),[k,j]=(0,n.useState)(null),{markSaving:w,markSaved:N}=oP(),[_,C]=(0,n.useState)(!1),[S,I]=(0,n.useState)(!1),[P,T]=(0,n.useState)("stdio"),[M,R]=(0,n.useState)(""),[E,A]=(0,n.useState)(""),[$,z]=(0,n.useState)(""),[F,L]=(0,n.useState)(""),[D,O]=(0,n.useState)(""),q=(0,n.useCallback)(async e=>{let t={};await Promise.all(e.map(async e=>{try{t[e.id]=await (0,e5.apiFetch)(`/v1/mcp/server-profiles/${e.id}/versions`)}catch{}})),p(t)},[]),B=(0,n.useCallback)(e=>{for(let t of Object.values(u)){let n=t.find(t=>t.id===e.profileVersionId);if(n)return n}},[u]),U=(0,n.useCallback)(e=>{if(e)for(let t of Object.values(u)){let n=t.find(t=>t.id===e);if(n)return n}},[u]),H=(0,n.useCallback)(e=>{let t=U(e.boundVersionId),n=JSON.stringify(t?{transport:t.transport,..."stdio"===t.transport?{executable:t.executable??""}:{endpoint:t.endpoint??""}}:{transport:"(unknown bound version)"},null,2),a=JSON.stringify({transport:e.transport,..."stdio"===e.transport?{executable:e.executable??""}:{endpoint:e.endpoint??""}},null,2);j({slug:e.slug??"",lines:function(e,t){let n=e.split("\n"),a=t.split("\n"),s=[],i=Math.max(n.length,a.length);for(let e=0;e<i;e++){let t=n[e],i=a[e];void 0===t?s.push(`+ ${i}`):void 0===i?s.push(`- ${t}`):t===i?s.push(` ${t}`):(s.push(`- ${t}`),s.push(`+ ${i}`))}return s}(n,a),digestTo:e.configDigest??""})},[U]),W=(0,n.useCallback)(async()=>{if(e){C(!0);try{let[t,n,a]=await Promise.all([(0,e5.apiFetch)("/v1/mcp/server-profiles"),(0,e5.apiFetch)(`/v1/projects/${e}/mcp/bindings`),(0,e5.apiFetch)(`/v1/projects/${e}/mcp/candidates`)]);s(t),o(n),r(a),q(t);let i={};for(let t of n)if(t.desiredEnabled)try{i[t.id]=await (0,e5.apiFetch)(`/v1/projects/${e}/mcp/bindings/${t.id}/catalog`)}catch{}d(i)}catch(e){t(e instanceof Error?e.message:"Failed to load MCP settings")}finally{C(!1)}}},[e,t,q]);(0,n.useEffect)(()=>{let n=!1;if(e)return Promise.all([(0,e5.apiFetch)("/v1/mcp/server-profiles"),(0,e5.apiFetch)(`/v1/projects/${e}/mcp/bindings`),(0,e5.apiFetch)(`/v1/projects/${e}/mcp/candidates`).catch(()=>{throw Error("Failed to load discovered servers")})]).then(async([t,a,i])=>{if(n)return;s(t),o(a),r(i),q(t);let l={};for(let t of a)if(t.desiredEnabled)try{l[t.id]=await (0,e5.apiFetch)(`/v1/projects/${e}/mcp/bindings/${t.id}/catalog`)}catch{}n||d(l)}).catch(e=>{n||t(e instanceof Error?e.message:"Failed to load MCP settings")}),()=>{n=!0}},[e,t,q]);let V=async()=>{w();try{let e=await (0,e5.apiFetch)("/v1/mcp/server-profiles",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({displayName:M,slug:E,sourceKind:"managed"})}),t={transport:P};if("stdio"===P){t.executable=$.trim();let e=F.split(/\s+/).filter(Boolean);e.length>0&&(t.argv=e)}else t.endpoint=D.trim();await (0,e5.apiFetch)(`/v1/mcp/server-profiles/${e.id}/versions`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),I(!1),R(""),A(""),z(""),L(""),O(""),await W(),N()}catch(e){t(e instanceof Error?e.message:"Failed to create MCP profile")}},K=async(n,a)=>{if(e){w();try{await (0,e5.apiFetch)(`/v1/projects/${e}/mcp/bindings/${n.id}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)}),await W(),N()}catch(e){t(e instanceof Error?e.message:"Failed to update MCP binding")}}},G=async(e,t)=>{let n=e.selectedRemoteToolNames??[],a=n.includes(t)?n.filter(e=>e!==t):[...n,t];await K(e,{selectedRemoteToolNames:a})},J=async(e,t)=>{await K(e,{selectedRemoteToolNames:t.map(e=>e.remoteName)})},Y=async e=>{let t=(x[e.id]??"").trim(),n=(y[e.id]??"").trim();if(!t||!n)return;let a={...e.credentialRefs??{}};a[t]=n,await K(e,{credentialRefs:a}),v(t=>({...t,[e.id]:""})),b(t=>({...t,[e.id]:""}))},Q=async(e,t)=>{let n={...e.credentialRefs??{}};delete n[t],await K(e,{credentialRefs:n})};return{profiles:a,candidates:i,bindings:l,catalogs:c,versions:u,toolSearch:h,setToolSearch:m,showCreds:f,setShowCreds:g,credEnv:x,setCredEnv:v,credRef:y,setCredRef:b,diffView:k,loading:_,showCreate:S,setShowCreate:I,transport:P,setTransport:T,displayName:M,setDisplayName:R,slug:E,setSlug:A,executable:$,setExecutable:z,argv:F,setArgv:L,endpoint:D,setEndpoint:O,versionFor:B,openProfileDiff:H,createProfile:V,bindCandidate:async n=>{if(e){w();try{("project_file"!==n.sourceKind||n.boundVersionId||n.updateAvailable)&&n.boundVersionId&&!n.updateAvailable?await (0,e5.apiFetch)(`/v1/projects/${e}/mcp/bindings`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({profileVersionId:n.boundVersionId})}):await (0,e5.apiFetch)(`/v1/projects/${e}/mcp/bindings/from-candidate`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({slug:n.slug,transport:n.transport})}),await W(),N()}catch(e){t(e instanceof Error?e.message:"Failed to bind MCP candidate")}}},updateBinding:K,toggleTool:G,selectAllTools:J,addCredential:Y,removeCredential:Q,testBinding:async n=>{if(e)try{await (0,e5.apiFetch)(`/v1/projects/${e}/mcp/bindings/${n.id}/test`,{method:"POST"}),t(null)}catch(e){t(e instanceof Error?e.message:"Test failed")}},refreshCatalog:async n=>{if(e)try{let a=await (0,e5.apiFetch)(`/v1/projects/${e}/mcp/bindings/${n.id}/catalog/refresh`,{method:"POST"});d(e=>({...e,[n.id]:a})),t(null)}catch(e){t(e instanceof Error?e.message:"Catalog refresh failed")}},removeBinding:async n=>{if(e&&await rc({title:"Remove this MCP binding?",description:"Tools from this server will no longer be available to Runs in this project.",confirmLabel:"Remove binding",tone:"danger"})){w();try{await (0,e5.apiFetch)(`/v1/projects/${e}/mcp/bindings/${n.id}`,{method:"DELETE"}),await W(),N()}catch(e){t(e instanceof Error?e.message:"Failed to remove binding")}}},archiveProfile:async e=>{if(e.id&&await rc({title:`Archive MCP profile “${e.displayName??e.slug}”?`,description:"Bindings that reference this profile will stop resolving for new Runs.",confirmLabel:"Archive profile",tone:"danger"})){w();try{await (0,e5.apiFetch)(`/v1/mcp/server-profiles/${encodeURIComponent(e.id)}`,{method:"DELETE"}),t(null),await W(),N()}catch(e){t(e instanceof Error?e.message:"Failed to archive MCP profile")}}}}}(e,a);return e?(0,t.jsxs)("div",{className:oQ.default.settingsRoot,children:[(0,t.jsxs)("div",{className:oQ.default.settingsHeader,children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("div",{className:oQ.default.settingsTitle,children:"MCP servers"}),(0,t.jsx)("div",{className:oQ.default.settingsDescription,children:"Tools-first client. Servers are discovered, tested, then explicitly enabled per project."})]}),(0,t.jsx)("button",{type:"button",onClick:()=>s.setShowCreate(e=>!e),className:oQ.default.addButton,children:s.showCreate?"Cancel":"+ Add server"})]}),(0,t.jsx)(oX,{mcp:s}),(0,t.jsxs)("div",{className:oQ.default.bindings,children:[0===s.bindings.length&&!s.loading&&(0,t.jsx)("div",{className:oQ.default.emptyText,children:"No MCP servers bound to this project yet."}),s.bindings.map(e=>(0,t.jsx)(o0,{mcp:s,binding:e},e.id))]}),(0,t.jsx)(o1,{mcp:s}),s.loading&&(0,t.jsx)("div",{className:oQ.default.loadingText,children:"Loading…"})]}):(0,t.jsx)("div",{className:oQ.default.emptyText,children:"Open a project to manage MCP servers."})}let o4=o("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"}]]);var o5=e.i(90239);function o3(e){let{roots:n,loading:a,control:s}=e,{showRootForm:i,setShowRootForm:r,rootName:l,setRootName:o,rootPreset:c,setRootPreset:d,rootPath:u,setRootPath:p,rootBusy:h,addRoot:f,toggleRoot:g,removeRoot:x}=s;return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:o5.default.sectionHeader,children:["Skills roots ",(0,t.jsxs)("span",{className:o5.default.sectionCount,children:[n.length," additional"]})]}),(0,t.jsx)("div",{className:o5.default.note,children:"Resolution paths are on the Worker host. Remote clients (Tauri) read the same configured roots — no per-client setup."}),(0,t.jsxs)("div",{className:o5.default.stack,children:[0===n.length&&!a&&(0,t.jsxs)("div",{className:o5.default.empty,children:["No additional roots. Ennote reads ",(0,t.jsx)("code",{children:"$ENNOTE_HOME/skills"})," on the Worker host by default; add pi, Claude Code, Codex, or Cursor skill directories here."]}),n.map(e=>(0,t.jsxs)("div",{className:o5.default.rootRow,children:[(0,t.jsxs)("div",{className:o5.default.rootIdentity,children:[(0,t.jsxs)("div",{className:o5.default.rootTitleRow,children:[(0,t.jsx)("span",{className:o5.default.rootName,children:e.name}),(0,t.jsx)("span",{className:o5.default.badge,children:e.agentKind}),(0,t.jsxs)("span",{className:o5.default.rootPriority,children:["pri ",e.priority]})]}),(0,t.jsx)("div",{className:o5.default.rootPath,children:e.path})]}),(0,t.jsx)("button",{type:"button",onClick:()=>void g(e),disabled:null!==h,className:o5.default.toggle,"data-enabled":e.enabled||void 0,children:e.enabled?"Enabled":"Disabled"}),(0,t.jsx)("button",{type:"button",onClick:()=>void x(e),disabled:null!==h,title:`Stop reading skills from ${e.path}`,className:`${o5.default.ghostButton} ${o5.default.danger}`,children:(0,t.jsx)(m,{size:12,"aria-hidden":"true"})})]},e.id)),i?(0,t.jsxs)("div",{className:o5.default.rootForm,children:[(0,t.jsxs)("div",{className:o5.default.inputRow,children:[(0,t.jsxs)("select",{value:c,onChange:e=>d(e.target.value),"aria-label":"Ecosystem preset",className:`${o5.default.input} ${o5.default.inputPreset}`,disabled:!!u.trim(),children:[(0,t.jsx)("option",{value:"pi",children:"pi"}),(0,t.jsx)("option",{value:"claude",children:"Claude Code"}),(0,t.jsx)("option",{value:"codex",children:"Codex"}),(0,t.jsx)("option",{value:"cursor",children:"Cursor"}),(0,t.jsx)("option",{value:"generic",children:"Custom path"})]}),(0,t.jsx)("input",{value:l,onChange:e=>o(e.target.value),placeholder:"Name (defaults to preset)","aria-label":"Root name",className:`${o5.default.input} ${o5.default.inputName}`}),(0,t.jsx)("input",{value:u,onChange:e=>p(e.target.value),placeholder:"generic"===c?"/absolute/path/to/skills":"Optional explicit path (else preset)","aria-label":"Root path",className:o5.default.input})]}),(0,t.jsxs)("div",{className:o5.default.actionRow,children:[(0,t.jsx)("button",{type:"button",onClick:()=>void f(),disabled:null!==h,className:o5.default.primaryButton,children:"add"===h?"Adding…":"Add root"}),(0,t.jsx)("button",{type:"button",onClick:()=>r(!1),className:o5.default.ghostButton,children:"Cancel"})]})]}):(0,t.jsx)("button",{type:"button",onClick:()=>r(!0),className:o5.default.ghostButton,children:"+ Add skills root"})]})]})}function o6(e){let{projectId:n,projectTrusted:a,query:s,setQuery:i,results:r,searching:l,searched:o,installScope:c,setInstallScope:d,installing:p,onSearch:h,onInstall:m}=e;return(0,t.jsxs)("div",{className:`skills-market-panel ${o5.default.market}`,children:[(0,t.jsx)("div",{className:o5.default.marketTitle,children:"Marketplace"}),(0,t.jsxs)("div",{className:o5.default.searchRow,children:[(0,t.jsx)("input",{type:"search",value:s,onChange:e=>i(e.target.value),onKeyDown:e=>{"Enter"===e.key&&h()},placeholder:"Search skills.sh…","aria-label":"Search skills.sh",className:o5.default.input}),(0,t.jsxs)("select",{value:c,onChange:e=>d(e.target.value),"aria-label":"Install scope",className:`${o5.default.input} ${o5.default.inputScope}`,children:[(0,t.jsx)("option",{value:"global",children:"Global"}),(0,t.jsxs)("option",{value:"project",disabled:!n||!a,children:["Project",!a&&n?" (needs trust)":""]})]}),(0,t.jsxs)("button",{type:"button",onClick:()=>void h(),disabled:l||!s.trim(),className:o5.default.ghostButton,children:[(0,t.jsx)(u,{size:13,"aria-hidden":"true"})," ",l?"Searching…":"Search"]})]}),o&&0===r.length&&!l&&(0,t.jsxs)("div",{className:o5.default.empty,children:['No skills match "',s.trim(),'".']}),r.map(e=>(0,t.jsxs)("div",{className:o5.default.resultRow,children:[(0,t.jsx)("span",{className:o5.default.resultPackage,children:e.package}),e.installs&&(0,t.jsx)("span",{className:o5.default.resultInstalls,children:e.installs}),e.url&&(0,t.jsxs)("a",{href:e.url,target:"_blank",rel:"noreferrer",title:e.url,className:`${o5.default.link} ${o5.default.linkIcon}`,children:[(0,t.jsx)(o4,{size:13,"aria-hidden":"true"}),(0,t.jsxs)("span",{className:"sr-only",children:["Open ",e.package]})]}),(0,t.jsx)("button",{type:"button",disabled:null!==p,onClick:()=>void m(e.package),className:o5.default.installButton,"data-busy":p===e.package||void 0,children:p===e.package?"Installing…":"Install"})]},e.package))]})}function o8(e){let{installed:n,loading:a,updateKey:s,updates:i,checking:r,toggling:l,removing:o,onCheck:c,onUpdate:d,onToggle:u,onRemove:p}=e;return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:o5.default.sectionHeader,children:["Installed ",(0,t.jsx)("span",{className:o5.default.sectionCount,children:n.length})]}),a&&(0,t.jsx)("div",{className:o5.default.empty,children:"Loading…"}),!a&&0===n.length&&(0,t.jsx)("div",{className:o5.default.empty,children:"No installed skills yet — search the marketplace above."}),!a&&n.length>0&&(0,t.jsx)("div",{className:o5.default.stack,children:n.map(e=>{let n=e.install,a=s(n),h=i[a];return(0,t.jsx)("div",{className:o5.default.installedCard,children:(0,t.jsxs)("div",{className:o5.default.installedHead,children:[(0,t.jsxs)("div",{className:o5.default.installedIdentity,children:[(0,t.jsxs)("div",{className:o5.default.installedTitleRow,children:[(0,t.jsx)("strong",{className:o5.default.installedName,children:e.name}),(0,t.jsx)("span",{className:`skill-row-scope ${o5.default.badge}`,children:n.scope}),h?.state==="update-available"&&(0,t.jsx)("span",{className:o5.default.updateBadge,children:"Update available"})]}),e.description&&(0,t.jsx)("div",{className:o5.default.installedDescription,children:e.description}),(0,t.jsxs)("div",{className:o5.default.installedMeta,children:[(0,t.jsx)("span",{className:o5.default.mono,children:n.package}),n.versionHash&&(0,t.jsxs)("span",{className:o5.default.mono,children:["v",n.versionHash.slice(0,8)]}),n.skillsShUrl&&(0,t.jsxs)("a",{href:n.skillsShUrl,target:"_blank",rel:"noreferrer",className:o5.default.link,children:["skills.sh ",(0,t.jsx)(o4,{size:10,"aria-hidden":"true"})]})]})]}),(0,t.jsxs)("div",{className:o5.default.installedActions,children:[(0,t.jsx)("button",{type:"button",title:"Allow or block model invocation for this skill",onClick:()=>void u(e),disabled:l===e.relPath,className:o5.default.toggle,"data-disabled":e.disableModelInvocation||void 0,children:e.disableModelInvocation?"Disabled":"Enabled"}),(0,t.jsx)("button",{type:"button",title:"Check for updates",onClick:()=>void c(n),disabled:null!==r,className:o5.default.ghostButton,children:r===a?(0,t.jsx)(iB,{size:12,"aria-hidden":"true",className:"delivery-spinner"}):"Check"}),h?.state==="update-available"&&(0,t.jsx)("button",{type:"button",onClick:()=>void d(n),disabled:null!==r,className:`${o5.default.ghostButton} ${o5.default.warning}`,children:"Update"}),h?.state==="up-to-date"&&(0,t.jsx)("span",{className:o5.default.statusText,children:"Up to date"}),h?.state==="error"&&h.message&&(0,t.jsx)("span",{className:o5.default.statusError,title:h.message,children:h.message}),h?.state==="unsupported"&&(0,t.jsx)("span",{className:o5.default.statusText,title:h.message??"",children:"No updates"}),(0,t.jsx)("button",{type:"button",title:"Remove skill",onClick:()=>void p(e),disabled:null!==o,className:`${o5.default.ghostButton} ${o5.default.danger}`,children:o===e.relPath?"Removing…":(0,t.jsx)(m,{size:12,"aria-hidden":"true"})})]})]})},`${e.relPath}:${e.skillId}`)})})]})}function o9({local:e}){return 0===e.length?null:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:o5.default.sectionHeader,children:["Catalog ",(0,t.jsx)("span",{className:o5.default.sectionCount,children:e.length})]}),(0,t.jsx)("div",{className:o5.default.stack,children:e.map(e=>(0,t.jsxs)("div",{className:o5.default.catalogRow,children:[(0,t.jsx)("span",{className:o5.default.catalogName,children:e.name}),(0,t.jsx)("span",{className:o5.default.badge,children:e.sourceInfo.scope??"local"}),e.disableModelInvocation&&(0,t.jsx)("span",{className:o5.default.statusText,children:"invocation disabled"})]},`${e.relPath}:${e.skillId}`))})]})}function o7({diagnostics:e}){return 0===e.length?null:(0,t.jsxs)("div",{className:o5.default.diagnostics,children:[(0,t.jsx)("div",{className:o5.default.diagTitle,children:"Catalog diagnostics"}),(0,t.jsx)("div",{className:o5.default.diagList,children:e.map((e,n)=>(0,t.jsxs)("div",{className:o5.default.diagRow,"data-level":"skip"===e.level?"skip":void 0,children:["[",e.level,"] ",e.relPath?`${e.relPath}: `:"",e.message]},n))})]})}function ce({projectId:e,setError:a}){let s=function(e,t){let[a,s]=(0,n.useState)([]),[i,r]=(0,n.useState)([]),[l,o]=(0,n.useState)(!1),[c,d]=(0,n.useState)(!1),[u,p]=(0,n.useState)([]),h=(0,n.useCallback)(async()=>{d(!0);try{let n=e?`?projectID=${encodeURIComponent(e)}`:"",a=await (0,e5.apiFetch)(`/v1/skills${n}`);s(a.skills??[]),r(a.diagnostics??[]),o(!!a.projectResourcesLoaded);let i=await (0,e5.apiFetch)("/v1/skills/roots");p(i.items??[]),t(null)}catch(e){t(e instanceof Error?e.message:"Failed to load skills")}finally{d(!1)}},[e,t]);return(0,n.useEffect)(()=>{let e=window.setTimeout(()=>void h(),0);return()=>window.clearTimeout(e)},[h]),{skills:a,setSkills:s,diagnostics:i,projectTrusted:l,loading:c,roots:u,setRoots:p,load:h}}(e,a),i=function(e,t,a){let[s,i]=(0,n.useState)(!1),[r,l]=(0,n.useState)(""),[o,c]=(0,n.useState)("pi"),[d,u]=(0,n.useState)(""),[p,h]=(0,n.useState)(null),{markSaving:m,markSaved:f}=oP(),g=(0,n.useCallback)(async()=>{h("add"),m();try{await (0,e5.apiFetch)("/v1/skills/roots",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:r.trim()||o,agentKind:d.trim()?"generic":o,path:d.trim()||void 0})}),l(""),u(""),i(!1),a(null),await t(),f()}catch(e){a(e instanceof Error?e.message:"Failed to add skill root")}finally{h(null)}},[r,o,d,a,t,m,f]);return{showRootForm:s,setShowRootForm:i,rootName:r,setRootName:l,rootPreset:o,setRootPreset:c,rootPath:d,setRootPath:u,rootBusy:p,addRoot:g,toggleRoot:(0,n.useCallback)(async n=>{h(n.id),m();try{let s=await (0,e5.apiFetch)(`/v1/skills/roots/${n.id}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:!n.enabled})});e(e=>e.map(e=>e.id===n.id?s:e)),a(null),await t(),f()}catch(e){a(e instanceof Error?e.message:"Toggle failed")}finally{h(null)}},[e,a,t,m,f]),removeRoot:(0,n.useCallback)(async n=>{if(await rc({title:`Stop reading skills from "${n.path}"?`,description:"Installed skills under this root are no longer discovered.",confirmLabel:"Stop reading",tone:"danger"})){h(n.id),m();try{await (0,e5.apiFetch)(`/v1/skills/roots/${n.id}`,{method:"DELETE"}),e(e=>e.filter(e=>e.id!==n.id)),a(null),await t(),f()}catch(e){a(e instanceof Error?e.message:"Remove failed")}finally{h(null)}}},[e,a,t,m,f])}}(s.setRoots,s.load,a),r=function(e,t,a,s){let[i,r]=(0,n.useState)(""),[l,o]=(0,n.useState)([]),[c,d]=(0,n.useState)(!1),[u,p]=(0,n.useState)(!1),[h,m]=(0,n.useState)("global"),[f,g]=(0,n.useState)(null),x=(0,n.useCallback)(async()=>{let e=i.trim();if(e){d(!0);try{let t=await (0,e5.apiFetch)(`/v1/skills/search?q=${encodeURIComponent(e)}&limit=20`);o(t.results??[]),p(!0),s(null)}catch(e){s(e instanceof Error?e.message:"Search failed")}finally{d(!1)}}},[i,s]),v=(0,n.useCallback)(async n=>{if("project"===h&&!t)return void s("Project resources must be trusted before installing project skills.");g(n);try{await (0,e5.apiFetch)("/v1/skills/install",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({package:n,scope:h,..."project"===h&&e?{projectId:e}:{}})}),s(null),o(e=>e.filter(e=>e.package!==n)),await a()}catch(e){s(e instanceof Error?e.message:"Install failed")}finally{g(null)}},[h,t,e,s,a]);return{query:i,setQuery:r,results:l,searching:c,searched:u,installScope:h,setInstallScope:m,installing:f,search:x,install:v}}(e,s.projectTrusted,s.load,a),l=function(e,t,a,s){let[i,r]=(0,n.useState)({}),[l,o]=(0,n.useState)(null),[c,d]=(0,n.useState)(null),[u,p]=(0,n.useState)(null),{markSaving:h,markSaved:m}=oP(),f=(0,n.useCallback)(e=>`${e.scope}\u0000${e.package}`,[]),g=(0,n.useCallback)(async t=>{o(f(t));try{let n=await (0,e5.apiFetch)("/v1/skills/check",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({package:t.package,scope:t.scope,..."project"===t.scope&&e?{projectId:e}:{}})});r(e=>{let t={...e};for(let e of n.updates??[])t[f(e)]=e;return t}),s(null)}catch(e){s(e instanceof Error?e.message:"Update check failed")}finally{o(null)}},[e,s,f]),x=(0,n.useCallback)(async t=>{let n=f(t);o(n),h();try{await (0,e5.apiFetch)("/v1/skills/update",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({package:t.package,scope:t.scope,..."project"===t.scope&&e?{projectId:e}:{}})}),s(null),r(e=>{let t={...e};return delete t[n],t}),await a(),m()}catch(e){s(e instanceof Error?e.message:"Update failed")}finally{o(null)}},[e,s,f,a,h,m]);return{updateKey:f,updates:i,checking:l,toggling:c,removing:u,check:g,update:x,toggle:(0,n.useCallback)(async e=>{d(e.relPath),h();try{await (0,e5.apiFetch)(`/v1/skills/disabled/${e.relPath}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({disabled:!e.disableModelInvocation})}),t(t=>t.map(t=>t.relPath===e.relPath?{...t,disableModelInvocation:!e.disableModelInvocation}:t)),s(null),m()}catch(e){s(e instanceof Error?e.message:"Toggle failed")}finally{d(null)}},[t,s,h,m]),remove:(0,n.useCallback)(async e=>{if(await rc({title:`Remove the skill "${e.name}"?`,description:"The skill files are removed from the managed catalog.",confirmLabel:"Remove skill",tone:"danger"})){p(e.relPath),h();try{await (0,e5.apiFetch)(`/v1/skills/remove/${e.relPath}`,{method:"POST"}),t(t=>t.filter(t=>t.relPath!==e.relPath)),s(null),m()}catch(e){s(e instanceof Error?e.message:"Remove failed")}finally{p(null)}}},[t,s,h,m])}}(e,s.setSkills,s.load,a),o=s.skills.filter(e=>!!e.install),c=s.skills.filter(e=>!e.install);return(0,t.jsxs)("section",{className:"settings-tab-section","aria-labelledby":"settings-skills-heading",children:[(0,t.jsxs)("header",{children:[(0,t.jsx)("h2",{id:"settings-skills-heading",children:"Skills"}),(0,t.jsx)("p",{children:"Marketplace installs, catalog browsing, and per-skill invocation control."})]}),(0,t.jsx)(o3,{roots:s.roots,loading:s.loading,control:i}),(0,t.jsx)(o6,{projectId:e,projectTrusted:s.projectTrusted,query:r.query,setQuery:r.setQuery,results:r.results,searching:r.searching,searched:r.searched,installScope:r.installScope,setInstallScope:r.setInstallScope,installing:r.installing,onSearch:r.search,onInstall:r.install}),(0,t.jsx)(o8,{installed:o,loading:s.loading,updateKey:l.updateKey,updates:l.updates,checking:l.checking,toggling:l.toggling,removing:l.removing,onCheck:l.check,onUpdate:l.update,onToggle:l.toggle,onRemove:l.remove}),(0,t.jsx)(o9,{local:c}),(0,t.jsx)(o7,{diagnostics:s.diagnostics})]})}function ct({configured:e,missing:n}){let a=(0,f.useT)();return e?(0,t.jsx)("span",{className:"settings-models-dot settings-models-dot-ok",role:"img","aria-label":a("settings.models.credentialConfigured"),title:a("settings.models.credentialConfigured")}):n?(0,t.jsx)("span",{className:"settings-models-dot settings-models-dot-missing",role:"img","aria-label":a("settings.models.credentialMissing"),title:a("settings.models.credentialMissing")}):null}let cn=o("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"}]]),ca=o("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 cs({value:e,onChange:a,placeholder:s,ariaLabel:i}){let[r,l]=(0,n.useState)(!1);return(0,t.jsxs)("span",{className:"settings-models-secret",children:[(0,t.jsx)("input",{type:r?"text":"password",value:e,placeholder:s,"aria-label":i,autoComplete:"off",spellCheck:!1,onChange:e=>a(e.target.value)}),(0,t.jsx)("button",{type:"button",className:"settings-models-secret-toggle",title:r?"Hide key":"Show key","aria-label":r?"Hide key":"Show key",onClick:()=>l(e=>!e),children:r?(0,t.jsx)(ca,{size:13,"aria-hidden":"true"}):(0,t.jsx)(cn,{size:13,"aria-hidden":"true"})})]})}function ci(e){let t=e.trim();return 0===t.length?0===e.length?void 0:"keyBlank":/[^\x21-\x7E]/.test(t)||/^[A-Za-z_][A-Za-z0-9_]*=/.test(t)||t.startsWith('"')&&t.endsWith('"')||t.startsWith("'")&&t.endsWith("'")?"keyIllegalCharacters":void 0}async function cr(e){for(let t of(await (0,e5.apiFetch)("/v1/provider-profiles",{method:"POST",body:JSON.stringify({key:e.key,name:e.name,providerType:e.providerType,baseUrl:e.baseUrl,apiKey:e.apiKey||void 0})}),e.models)){let n=String(t.id??"").trim();0!==n.length&&await (0,e5.apiFetch)("/v1/model-profiles",{method:"POST",body:JSON.stringify({providerId:e.key,modelName:n,..."string"==typeof t.name&&t.name.length>0?{displayName:t.name}:{},contextWindow:"number"==typeof t.contextWindow?t.contextWindow:131072,maxOutputTokens:"number"==typeof t.maxTokens?t.maxTokens:16384,supportsToolUse:!0})})}}function cl(e){if(void 0===e)return;let t=Array.isArray(e)?e.map(e=>"object"!=typeof e||null===e||Array.isArray(e)?{}:e):[],n=new Set;for(let[e,a]of t.entries()){let t=a.id,s="string"==typeof t?t.trim():void 0;if(void 0===s||0===s.length)return{index:e,key:"modelIdRequired"};if(n.has(s))return{index:e,key:"modelIdDuplicate"};n.add(s);let i=a.name;if(void 0!==i&&("string"!=typeof i||0===i.length))return{index:e,key:"modelNameInvalid"};let r=a.contextWindow;if(void 0!==r&&("number"!=typeof r||!Number.isInteger(r)||r<=0))return{index:e,key:"modelContextInvalid"};let l=a.maxTokens;if(void 0!==l&&("number"!=typeof l||!Number.isInteger(l)||l<=0))return{index:e,key:"modelMaxTokensInvalid"}}}function co(e){return{id:e.modelName,...e.displayName?{name:e.displayName}:{},...e.contextWindow?{contextWindow:e.contextWindow}:{},...e.maxOutputTokens?{maxTokens:e.maxOutputTokens}:{}}}function cc({probe:e,existingIds:a,onAdopt:s,onError:i,disabled:r,blockedReason:l}){let o=(0,f.useT)(),[c,d]=(0,n.useState)(!1),[u,p]=(0,n.useState)(null),[h,g]=(0,n.useState)(!1),[x,v]=(0,n.useState)(new Set),y=!!(e.baseUrl&&e.baseUrl.length>0),b=l??(y?void 0:o("settings.models.fetchNeedsBaseUrl")),k=async()=>{g(!0),p(null);try{let t=await (0,e5.apiFetch)("/v1/provider-profiles/discover-models",{method:"POST",body:JSON.stringify({baseUrl:e.baseUrl||void 0,apiKey:e.apiKey||void 0})})??[];if(0===t.length)return void i?.(o("settings.models.fetchEmpty"));let n=new Set(a);p(t),v(new Set(t.filter(e=>!n.has(e.modelName)).map(e=>e.modelName))),d(!0)}catch(e){i?.(e.message)}finally{g(!1)}},j=()=>{d(!1),p(null)},w=null!==u&&u.length>0&&u.every(e=>x.has(e.modelName));return M(c&&null!==u,j),(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("button",{type:"button",className:"settings-models-link",disabled:r||h||!y||void 0!==l,title:b,onClick:()=>{k()},children:h?o("settings.models.fetching"):o("settings.models.fetchModels")}),c&&u&&(0,t.jsx)("div",{className:"settings-overlay",role:"dialog","aria-modal":"true","aria-label":o("settings.models.fetchTitle"),children:(0,t.jsxs)("div",{className:"project-create-dialog settings-models-fetch",children:[(0,t.jsxs)("div",{className:"project-create-header",children:[(0,t.jsx)("span",{children:o("settings.models.fetchTitle")}),(0,t.jsx)("button",{type:"button",className:"follow-up-close","aria-label":o("settings.models.close"),title:o("settings.models.close"),onClick:j,children:(0,t.jsx)(m,{size:14,"aria-hidden":"true"})})]}),(0,t.jsxs)("div",{className:"project-create-form",children:[(0,t.jsx)("p",{className:"settings-models-hint",children:o("settings.models.fetchDescription")}),(0,t.jsx)("div",{className:"settings-models-fetch-actions",children:(0,t.jsx)("button",{type:"button",className:"settings-models-link",onClick:()=>{u&&v(w?new Set:new Set(u.map(e=>e.modelName)))},children:o(w?"settings.models.fetchDeselectAll":"settings.models.fetchSelectAll")})}),(0,t.jsx)("ul",{className:"settings-models-candidates",children:u.map(e=>(0,t.jsx)("li",{className:"settings-models-candidate",children:(0,t.jsxs)("label",{className:"settings-models-candidate-label",children:[(0,t.jsx)("input",{type:"checkbox",checked:x.has(e.modelName),onChange:()=>{v(t=>{let n=new Set(t);return n.delete(e.modelName)||n.add(e.modelName),n})}}),(0,t.jsx)("span",{className:"settings-models-candidate-id",children:e.modelName})]})},e.modelName))}),(0,t.jsxs)("div",{className:"project-create-actions",children:[(0,t.jsx)("button",{type:"button",className:"secondary-btn",onClick:j,children:o("settings.models.cancel")}),(0,t.jsx)("button",{type:"button",className:"secondary-btn",onClick:()=>{u&&(s(u.filter(e=>x.has(e.modelName)).map(co)),j())},children:o("settings.models.fetchAdopt")})]})]})]})})]})}let cd=/^(\d+(?:\.\d+)?)([km])?$/i,cu={k:1e3,m:1e6};function cp(e,t){let n=e[t];return"string"==typeof n?n:""}function ch({open:e}){return(0,t.jsx)(j,{size:14,className:"model-editor-chevron","data-open":e||void 0,"aria-hidden":"true"})}function cm(){return(0,t.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none","aria-hidden":!0,children:(0,t.jsx)("path",{d:"M2.5 4h11M6.5 4V2.5h3V4M4 4l.7 9a1 1 0 001 .9h4.6a1 1 0 001-.9L12 4M6.5 6.8v4.4M9.5 6.8v4.4",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round"})})}function cf(){return(0,t.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none","aria-hidden":!0,children:(0,t.jsx)("path",{d:"M8 3v10M3 8h10",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})})}function cg({models:e,onChange:a,overridden:s,onReset:i,disabled:r,probe:l,probeBlocked:o,onFetchError:c}){let d=(0,f.useT)(),[u,p]=(0,n.useState)(()=>new Set),[h,m]=(0,n.useState)(()=>new Map),g=(e,t)=>`${String(e)}:${t}`,x=(t,n)=>{a(e.map((e,a)=>{if(a!==t)return e;let s=new Set(Object.entries(n).filter(([,e])=>void 0===e||""===e).map(([e])=>e));return Object.fromEntries(Object.entries({...e,...n}).filter(([e])=>!s.has(e)))}))},v=(e,t,n)=>{m(a=>new Map(a).set(g(e,t),n)),x(e,{[t]:function(e){let t=e.trim();if(0===t.length)return;let n=cd.exec(t);if(null===n)return NaN;let a=n[2]?.toLowerCase(),s="k"===a||"m"===a?cu[a]:1,i=Number(n[1])*s,r=Math.round(i);return 1e-6>Math.abs(i-r)?r:i}(n)})},y=(e,t,n)=>{let a,s=h.get(g(t,n));if(void 0!==s)return s;let i="number"==typeof(a=e[n])?a:void 0;return void 0===i?"":!Number.isInteger(i)||i<=0?String(i):i%cu.m==0?`${String(i/cu.m)}M`:i%cu.k==0?`${String(i/cu.k)}K`:String(i)},b=e=>("string"==typeof e.id?e.id:"").trim();return(0,t.jsxs)("section",{className:"settings-models-catalog","aria-label":d("settings.models.models"),children:[(0,t.jsxs)("div",{className:"settings-models-list-head",children:[(0,t.jsxs)("div",{className:"settings-models-catalog-heading",children:[(0,t.jsx)("span",{className:"settings-models-catalog-title",children:d("settings.models.models")}),void 0!==s&&(0,t.jsx)("span",{className:"settings-models-catalog-meta",children:s?d("settings.models.modelsCustomized"):d("settings.models.modelsInherited")})]}),!0===s&&void 0!==i&&(0,t.jsx)("button",{type:"button",className:"settings-models-link",disabled:r,onClick:i,children:d("settings.models.resetModels")}),void 0!==l&&(0,t.jsx)(cc,{probe:l,existingIds:e.map(b),onAdopt:t=>{let n=new Map(e.map(e=>[b(e),e]));for(let e of t)n.set(b(e),n.get(b(e))??e);a([...n.values()])},onError:c,disabled:r,blockedReason:o})]}),0===e.length&&(0,t.jsx)("p",{className:"settings-models-catalog-empty",children:d("settings.models.modelsEmpty")}),e.map((n,s)=>(0,t.jsxs)("div",{className:"settings-models-entry",children:[(0,t.jsxs)("div",{className:"settings-models-entry-row",children:[(0,t.jsx)("input",{className:"settings-models-input",type:"text",value:cp(n,"id"),placeholder:d("settings.models.modelId"),"aria-label":`${d("settings.models.modelId")} ${s+1}`,disabled:r,onChange:e=>{x(s,{id:e.target.value})}}),(0,t.jsx)("input",{className:"settings-models-input",type:"text",value:cp(n,"name"),placeholder:d("settings.models.modelName"),"aria-label":`${d("settings.models.modelName")} ${s+1}`,disabled:r,onChange:e=>{x(s,{name:""===e.target.value?void 0:e.target.value})}}),(0,t.jsx)("button",{type:"button",className:"settings-models-icon","aria-label":`${d("settings.models.modelAdvanced")} ${s+1}`,"aria-expanded":u.has(s),title:d("settings.models.modelAdvanced"),onClick:()=>{p(e=>{let t=new Set(e);return t.delete(s)||t.add(s),t})},children:(0,t.jsx)(ch,{open:u.has(s)})}),(0,t.jsx)("button",{type:"button",className:"settings-models-icon settings-models-icon-danger","aria-label":`${d("settings.models.removeModel")} ${s+1}`,title:d("settings.models.removeModel"),disabled:r,onClick:()=>{a(e.filter((e,t)=>t!==s)),p(e=>{let t=new Set;for(let n of e)n<s?t.add(n):n>s&&t.add(n-1);return t}),m(e=>((e,t)=>{let n=new Map;for(let[a,s]of e){let e=Number(a.slice(0,a.indexOf(":")));e!==t&&n.set(e>t?a.replace(/^\d+/,String(e-1)):a,s)}return n})(e,s))},children:(0,t.jsx)(cm,{})})]}),u.has(s)&&(0,t.jsxs)("div",{className:"settings-models-entry-advanced",children:[(0,t.jsxs)("label",{className:"settings-models-entry-field",children:[(0,t.jsx)("span",{className:"settings-models-entry-field-label",children:d("settings.models.contextWindow")}),(0,t.jsx)("input",{className:"settings-models-input",type:"text",inputMode:"numeric",value:y(n,s,"contextWindow"),placeholder:"256K","aria-label":`${d("settings.models.contextWindow")} ${s+1}`,disabled:r,onChange:e=>{v(s,"contextWindow",e.target.value)}})]}),(0,t.jsxs)("label",{className:"settings-models-entry-field",children:[(0,t.jsx)("span",{className:"settings-models-entry-field-label",children:d("settings.models.maxTokens")}),(0,t.jsx)("input",{className:"settings-models-input",type:"text",inputMode:"numeric",value:y(n,s,"maxTokens"),placeholder:"32K","aria-label":`${d("settings.models.maxTokens")} ${s+1}`,disabled:r,onChange:e=>{v(s,"maxTokens",e.target.value)}})]})]})]},s)),(0,t.jsxs)("button",{type:"button",className:"settings-models-add-model",disabled:r,onClick:()=>{a([...e,{id:""}])},children:[(0,t.jsx)(cf,{}),d("settings.models.addModel")]})]})}let cx=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/,cv=["openai-compatible","anthropic"];function cy({taken:e,onClose:a,refresh:s,setError:i,onSaved:r}){let l,o=(0,f.useT)(),[c,d]=(0,n.useState)(""),[u,p]=(0,n.useState)(""),[h,m]=(0,n.useState)(""),[g,x]=(0,n.useState)(cv[0]),[v,y]=(0,n.useState)(""),[b,k]=(0,n.useState)([]),[j,w]=(0,n.useState)(!1),[N,_]=(0,n.useState)(void 0),C=c.length>0&&!cx.test(c),S=e.includes(c),I=cl(b),P=ci(v),T=v.trim(),M=c.length>0&&!C&&!S&&h.trim().length>0&&b.length>0&&void 0===I&&void 0===P;async function R(){w(!0),_(void 0);try{await cr({key:c,name:u.trim()||c,providerType:g,baseUrl:h.trim(),apiKey:T||void 0,models:b}),i(null),r?.(u.trim()||c),await s(),a(!0)}catch(e){_(e.message)}finally{w(!1)}}return void 0!==N||M||C||S||void 0!==P||(0===c.length?l=o("settings.models.customRouteHint"):0===h.trim().length?l=o("settings.models.customNeedsBaseUrl"):0===b.length?l=o("settings.models.customNeedsModels"):void 0!==I&&(l=`${o("settings.models.model")} ${I.index+1}: ${o(`settings.models.${I.key}`)}`)),(0,t.jsxs)("div",{className:"settings-row provider-settings-row settings-models-editor",children:[(0,t.jsx)("div",{className:"settings-models-editor-header",children:(0,t.jsx)("span",{className:"settings-models-editor-title",children:o("settings.models.customTitle")})}),(0,t.jsxs)("div",{className:"settings-models-field",children:[(0,t.jsx)("span",{className:"settings-models-fieldlabel",children:o("settings.models.customRoute")}),(0,t.jsx)("input",{className:"settings-models-input",type:"text",value:c,placeholder:"acme-gateway",disabled:j,"aria-label":o("settings.models.customRoute"),onChange:e=>{d(e.target.value)}}),C||S?(0,t.jsx)("p",{className:"settings-models-error",children:o(C?"settings.models.customRouteInvalid":"settings.models.customRouteTaken")}):(0,t.jsx)("p",{className:"settings-models-hint",children:o("settings.models.customRouteHint")})]}),(0,t.jsxs)("div",{className:"settings-models-field",children:[(0,t.jsx)("span",{className:"settings-models-fieldlabel",children:o("settings.models.customDisplayName")}),(0,t.jsx)("input",{className:"settings-models-input",type:"text",value:u,placeholder:0===c.length?o("settings.models.customDisplayName"):c,disabled:j,"aria-label":o("settings.models.customDisplayName"),onChange:e=>{p(e.target.value)}})]}),(0,t.jsxs)("div",{className:"settings-models-field",children:[(0,t.jsx)("span",{className:"settings-models-fieldlabel",children:o("settings.models.baseUrl")}),(0,t.jsx)("input",{className:"settings-models-input",type:"text",value:h,placeholder:"https://gateway.example/v1",disabled:j,"aria-label":o("settings.models.baseUrl"),onChange:e=>{m(e.target.value)}})]}),(0,t.jsxs)("div",{className:"settings-models-field",children:[(0,t.jsx)("span",{className:"settings-models-fieldlabel",children:o("settings.models.customApi")}),(0,t.jsx)("select",{className:"settings-models-input settings-models-select",value:g,disabled:j,"aria-label":o("settings.models.customApi"),onChange:e=>{x(e.target.value)},children:cv.map(e=>(0,t.jsx)("option",{value:e,children:e},e))})]}),(0,t.jsxs)("div",{className:"settings-models-field",children:[(0,t.jsx)("span",{className:"settings-models-fieldlabel",children:o("settings.models.keyInput")}),(0,t.jsx)(cs,{value:v,onChange:y,placeholder:o("settings.models.keyPlaceholder"),ariaLabel:o("settings.models.keyInput")}),void 0===P?null:(0,t.jsx)("p",{className:"settings-models-error",children:o(`settings.models.${P}`)})]}),(0,t.jsx)(cg,{models:b,onChange:k,disabled:j,probe:{baseUrl:h.trim(),apiKey:T},probeBlocked:void 0!==P?o(`settings.models.${P}`):void 0,onFetchError:_}),void 0!==N?(0,t.jsx)("p",{className:"settings-models-error",children:N}):null,void 0===l?null:(0,t.jsx)("p",{className:"settings-models-hint",children:l}),(0,t.jsxs)("div",{className:"settings-models-editor-actions",children:[(0,t.jsx)("button",{type:"button",className:"secondary-btn",disabled:j,onClick:()=>a(!1),children:o("settings.models.cancel")}),(0,t.jsx)("button",{type:"button",className:"settings-models-primary",disabled:j||!M,onClick:()=>{R()},children:o(j?"settings.models.creating":"settings.models.create")})]})]})}function cb({open:e,providerName:n,busy:a,failure:s,onCancel:i,onConfirm:r}){let l=(0,f.useT)();if(M(e,i,{dismissOnEscape:!a}),!e)return null;let o=l("settings.models.deleteTitle",{provider:n}),c=l("settings.models.deleteDescriptionWithCredential",{provider:n}),d=l("settings.models.deleteConfirm",{provider:n}),u=l("settings.models.deleting",{provider:n});return(0,t.jsx)("div",{className:"settings-overlay",role:"dialog","aria-modal":"true","aria-label":o,children:(0,t.jsxs)("div",{className:"project-create-dialog",children:[(0,t.jsxs)("div",{className:"project-create-header",children:[(0,t.jsx)("span",{children:o}),(0,t.jsx)("button",{type:"button",className:"follow-up-close","aria-label":l("settings.models.close"),title:l("settings.models.close"),onClick:i,children:(0,t.jsx)(m,{size:14,"aria-hidden":"true"})})]}),(0,t.jsxs)("div",{className:"project-create-form",children:[(0,t.jsx)("p",{className:"settings-delete-description",children:c}),s&&(0,t.jsx)("p",{className:"settings-delete-error",children:s}),(0,t.jsxs)("div",{className:"project-create-actions",children:[(0,t.jsx)("button",{type:"button",className:"secondary-btn",disabled:a,onClick:i,children:l("settings.models.cancel")}),(0,t.jsx)("button",{type:"button",className:"project-create-submit",disabled:a,onClick:r,children:a?u:d})]})]})]})})}function ck(e,t){let n=e[t];return"string"==typeof n&&n.trim().length>0?n.trim():void 0}function cj(e,t){let n=e[t];return"number"==typeof n?n:void 0}async function cw(e){for(let t of e.toDelete)await (0,e5.apiFetch)(`/v1/model-profiles/${encodeURIComponent(t)}`,{method:"DELETE"});for(let{id:t,input:n}of e.toUpdate)await (0,e5.apiFetch)(`/v1/model-profiles/${encodeURIComponent(t)}`,{method:"PUT",body:JSON.stringify(n)});for(let t of e.toCreate)await (0,e5.apiFetch)("/v1/model-profiles",{method:"POST",body:JSON.stringify(t)})}function cN({provider:e,models:a,creating:s,hideTitle:i,onClose:r,refresh:l,setError:o,onSaved:c}){let d=(0,f.useT)(),[u,p]=(0,n.useState)(""),[h,m]=(0,n.useState)(e.baseUrl??""),[g,x]=(0,n.useState)(e.name??""),[v,y]=(0,n.useState)(()=>s?[]:a.map(e=>({id:e.modelName,...e.displayName&&e.displayName!==e.modelName?{name:e.displayName}:{},contextWindow:e.contextWindow,maxTokens:e.maxOutputTokens}))),[b,k]=(0,n.useState)(!1),[j,w]=(0,n.useState)(void 0),N=ci(u),_=cl(v),C=u.trim(),S=a.map(e=>({id:e.id,modelName:e.modelName,displayName:e.displayName,contextWindow:e.contextWindow,maxOutputTokens:e.maxOutputTokens}));async function I(){k(!0),w(void 0);try{if(s)await cr({key:e.id,name:g.trim()||e.name,providerType:e.providerType,baseUrl:h.trim()||e.baseUrl,apiKey:C||void 0,models:v});else{await (0,e5.apiFetch)(`/v1/provider-profiles/${encodeURIComponent(e.id)}`,{method:"PUT",body:JSON.stringify({name:g.trim()||void 0,baseUrl:h.trim()||void 0,apiKey:C||void 0})});let t=function(e,t,n,a=131072,s=16384){let i={toCreate:[],toDelete:[],toUpdate:[]},r=new Map(t.map(e=>[e.modelName,e])),l=new Set;for(let t of n){var o,c;let n=ck(t,"id");if(void 0===n)continue;l.add(n);let d=r.get(n);if(void 0===d){i.toCreate.push({providerId:e,modelName:n,...void 0===ck(t,"name")?{}:{displayName:ck(t,"name")},contextWindow:cj(t,"contextWindow")??a,maxOutputTokens:cj(t,"maxTokens")??s,supportsToolUse:!0});continue}o=t,c=d,(ck(o,"name")!==(c.displayName&&c.displayName!==c.modelName?c.displayName:void 0)||cj(o,"contextWindow")!==c.contextWindow||cj(o,"maxTokens")!==c.maxOutputTokens)&&i.toUpdate.push({id:d.id,input:{displayName:ck(t,"name")??null,contextWindow:cj(t,"contextWindow")??null,maxOutputTokens:cj(t,"maxTokens")??null}})}for(let e of t)l.has(e.modelName)||i.toDelete.push(e.id);return i}(e.id,S,v);await cw(t)}o(null),c?.(g.trim()||e.name),await l(),r(!0)}catch(e){w(e.message)}finally{k(!1)}}let P=b||void 0!==N||void 0!==_,T=d(e.credentialConfigured?"settings.models.keyStored":"settings.models.keyPlaceholder");return(0,t.jsxs)("div",{className:"settings-row provider-settings-row settings-models-editor",children:[!i&&(0,t.jsxs)("div",{className:"settings-models-editor-header",children:[(0,t.jsx)("span",{className:"settings-models-editor-title",children:e.name}),e.name!==e.id&&(0,t.jsx)("span",{className:"settings-models-editor-route",children:e.id})]}),(0,t.jsxs)("div",{className:"settings-models-field",children:[(0,t.jsx)("span",{className:"settings-models-fieldlabel",children:d("settings.models.keyInput")}),(0,t.jsx)(cs,{value:u,onChange:p,placeholder:T,ariaLabel:d("settings.models.keyInput")}),void 0===N?null:(0,t.jsx)("p",{className:"settings-models-error",children:d(`settings.models.${N}`)})]}),(0,t.jsxs)("details",{className:"settings-models-customized",children:[(0,t.jsx)("summary",{className:"settings-models-customized-summary",children:d("settings.models.customized")}),(0,t.jsxs)("div",{className:"settings-models-customized-body",children:[e.custom&&(0,t.jsxs)("div",{className:"settings-models-field",children:[(0,t.jsx)("span",{className:"settings-models-fieldlabel",children:d("settings.models.customDisplayName")}),(0,t.jsx)("input",{className:"settings-models-input",type:"text",value:g,disabled:b,"aria-label":d("settings.models.customDisplayName"),onChange:e=>{x(e.target.value)}})]}),(0,t.jsxs)("div",{className:"settings-models-field",children:[(0,t.jsx)("span",{className:"settings-models-fieldlabel",children:d("settings.models.baseUrl")}),(0,t.jsx)("input",{className:"settings-models-input",type:"text",value:h,disabled:b,placeholder:e.baseUrl||d("settings.models.baseUrlDefault"),"aria-label":d("settings.models.baseUrl"),onChange:e=>{m(e.target.value)}})]}),(0,t.jsx)(cg,{models:v,onChange:y,disabled:b,probe:{baseUrl:h.trim(),apiKey:C},probeBlocked:void 0!==N?d(`settings.models.${N}`):void 0,onFetchError:w})]})]}),void 0!==j?(0,t.jsx)("p",{className:"settings-models-error",children:j}):null,(0,t.jsxs)("div",{className:"settings-models-editor-actions",children:[(0,t.jsx)("button",{type:"button",className:"secondary-btn",disabled:b,onClick:()=>r(!1),children:d("settings.models.cancel")}),(0,t.jsx)("button",{type:"button",className:"settings-models-primary",disabled:P,onClick:()=>{I()},children:d(b?s?"settings.models.creating":"settings.models.applying":s?"settings.models.create":"settings.models.apply")})]})]})}function c_({size:e=14}){return(0,t.jsx)("svg",{width:e,height:e,viewBox:"0 0 16 16",fill:"none","aria-hidden":!0,children:(0,t.jsx)("path",{d:"M8 3v10M3 8h10",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})})}function cC({providers:e,models:a,refresh:s,setError:i}){let r=(0,f.useT)(),{markSaving:l,markSaved:o}=oP(),[c,d]=(0,n.useState)(null),[u,p]=(0,n.useState)(!1),[h,m]=(0,n.useState)(!1),[g,x]=(0,n.useState)(null),[v,y]=(0,n.useState)(!1),[b,k]=(0,n.useState)(void 0),[j,w]=(0,n.useState)(null),[N,_]=(0,n.useState)(()=>new Set),C=e.some(e=>e.credentialConfigured),S=e.filter(e=>e.directory),I=u?e.find(e=>e.directory&&e.id===c)??null:null,P=e=>{w(e),o()},T=async()=>{if(null!==g&&!v){y(!0),k(void 0),l();try{await (0,e5.apiFetch)(`/v1/provider-profiles/${encodeURIComponent(g.id)}`,{method:"DELETE"}),i(null),x(null),await s(),o()}catch(e){k(e.message)}finally{y(!1)}}};return(0,t.jsxs)("section",{className:"settings-tab-section","aria-labelledby":"settings-models-heading",children:[(0,t.jsxs)("header",{children:[(0,t.jsx)("h2",{id:"settings-models-heading",children:r("settings.models.title")}),(0,t.jsx)("p",{children:r("settings.models.intro")})]}),null!==j&&(0,t.jsx)("p",{className:"settings-models-saved",role:"status","aria-live":"polite",children:r("settings.models.savedProvider",{provider:j})}),(0,t.jsx)("ul",{className:"settings-models-rows",children:e.map(e=>{if(!C&&e.directory&&!N.has(e.id))return(0,t.jsx)("li",{className:"settings-models-setupcard",children:(0,t.jsx)(cN,{provider:e,models:[],creating:!0,refresh:s,setError:i,onSaved:P,onClose:()=>{_(t=>new Set([...t,e.id]))}})},e.id);let n=!u&&c===e.id;return(0,t.jsxs)("li",{className:"settings-models-rowcard",children:[(0,t.jsxs)("div",{className:"settings-models-rowhead",children:[(0,t.jsxs)("span",{className:"settings-models-rowidentity",children:[(0,t.jsx)("span",{className:"settings-models-rowname",children:e.name}),e.custom?(0,t.jsx)("span",{className:"settings-models-rowtag",children:r("settings.models.customTag")}):null,(0,t.jsx)(ct,{configured:e.credentialConfigured,missing:!e.credentialConfigured})]}),(0,t.jsxs)("span",{className:"settings-models-rowactions",children:[(0,t.jsx)("button",{type:"button",className:"settings-models-btn","aria-label":r("settings.models.editProvider",{provider:e.name}),onClick:()=>{w(null),m(!1),p(!1),d(n?null:e.id)},children:r("settings.models.edit")}),e.directory?null:(0,t.jsx)("button",{type:"button",className:"settings-models-btn settings-models-danger","aria-label":r("settings.models.removeProvider",{provider:e.name}),onClick:()=>{w(null),k(void 0),x(e)},children:r("settings.models.remove")})]})]}),n&&(0,t.jsx)(cN,{provider:e,models:a.filter(t=>t.providerId===e.id),creating:e.directory,refresh:s,setError:i,onSaved:P,onClose:()=>{d(null)}})]},e.id)})}),(0,t.jsxs)("div",{className:"settings-models-addblock",children:[null!==I&&(0,t.jsxs)("div",{className:"settings-models-addcard",children:[(0,t.jsxs)("div",{className:"settings-models-field",children:[(0,t.jsx)("span",{className:"settings-models-fieldlabel",children:r("settings.models.provider")}),(0,t.jsx)("select",{className:"settings-models-input settings-models-select",value:I.id,"aria-label":r("settings.models.provider"),onChange:e=>{d(e.target.value)},children:S.map(e=>(0,t.jsx)("option",{value:e.id,children:e.name},e.id))})]}),(0,t.jsx)(cN,{provider:I,models:[],creating:!0,hideTitle:!0,refresh:s,setError:i,onSaved:P,onClose:()=>{p(!1),d(null)}},I.id)]}),h&&(0,t.jsx)("div",{className:"settings-models-addcard",children:(0,t.jsx)(cy,{taken:e.map(e=>e.id),refresh:s,setError:i,onSaved:P,onClose:e=>{m(!1),e&&s()}})}),null===I&&!h&&(0,t.jsxs)("div",{className:"settings-models-addactions",children:[(0,t.jsxs)("button",{type:"button",className:"settings-models-addbutton",disabled:0===S.length,onClick:()=>{w(null),m(!1),p(!0),d(S[0]?.id??null)},children:[(0,t.jsx)(c_,{}),r("settings.models.add")]}),(0,t.jsxs)("button",{type:"button",className:"settings-models-addbutton",onClick:()=>{w(null),p(!1),d(null),m(!0)},children:[(0,t.jsx)(c_,{}),r("settings.models.customAdd")]})]})]}),(0,t.jsx)(cb,{open:null!==g,providerName:g?.name??"",busy:v,failure:b,onCancel:()=>{v||(x(null),k(void 0))},onConfirm:()=>{T()}})]})}let cS=[{kind:"tool",title:"Tool policy",description:"Permission mode and allowed local execution boundaries.",defaultConfig:'{"mode":"restricted","allowedTools":["read","ls","grep","find"],"allowedExecutables":["git","rg"],"maxTimeoutSeconds":300}'},{kind:"turn",title:"Turn routing",description:"Model routing candidates and upgrade thresholds.",defaultConfig:'{"mode":"context_upgrade","threshold":0.7,"candidateModelProfileIds":[]}'},{kind:"vision",title:"Vision",description:"Native image handling and descriptor fallback boundaries.",defaultConfig:'{"mode":"reject","maxImageBytes":10485760,"maxPixels":40000000}'}];function cI({policies:e,refresh:n,setError:a}){let{markSaving:s,markSaved:i}=oP();async function r(e,t){e.preventDefault();let r=e.currentTarget,l=new FormData(r);try{let e=JSON.parse(String(l.get("config")||"{}"));s(),await (0,e5.apiFetch)("/v1/policy-profiles",{method:"POST",body:JSON.stringify({name:l.get("name"),kind:t,config:e})}),r.reset(),a(null),await n(),i()}catch(e){a(e.message)}}async function l(e){s();try{await (0,e5.apiFetch)(`/v1/policy-profiles/${encodeURIComponent(e)}/default`,{method:"PUT"}),a(null),await n(),i()}catch(e){a(e.message)}}async function o(e){if(await rc({title:`Deactivate policy “${e.name}” v${e.version}?`,description:"Existing Runs keep their frozen policy. New Runs will no longer select it as the default.",confirmLabel:"Deactivate",tone:"danger"})){s();try{await (0,e5.apiFetch)(`/v1/policy-profiles/${encodeURIComponent(e.id)}`,{method:"DELETE"}),a(null),await n(),i()}catch(e){a(e.message)}}}return(0,t.jsxs)("section",{className:"settings-tab-section","aria-labelledby":"settings-policies-heading",children:[(0,t.jsxs)("header",{children:[(0,t.jsx)("h2",{id:"settings-policies-heading",children:"Policies"}),(0,t.jsx)("p",{children:"Immutable versioned execution, routing, and image handling configuration."})]}),cS.map(n=>(0,t.jsx)(cP,{...n,policies:e,onSubmit:r,onDefault:l,onDeactivate:o},n.kind))]})}function cP({kind:e,title:n,description:a,policies:s,defaultConfig:i,onSubmit:r,onDefault:l,onDeactivate:o}){return(0,t.jsxs)(oR,{title:n,description:a,children:[(0,t.jsxs)("form",{className:"settings-form policy-form",onSubmit:t=>r(t,e),children:[(0,t.jsxs)("label",{children:["Name",(0,t.jsx)("input",{name:"name",required:!0})]}),(0,t.jsxs)("label",{children:["Configuration JSON",(0,t.jsx)("textarea",{name:"config",required:!0,defaultValue:i})]}),(0,t.jsx)("button",{type:"submit",children:"Create version"})]}),(0,t.jsx)(oA,{children:s.filter(t=>t.kind===e).map(e=>(0,t.jsx)(oE,{title:e.name,meta:`v${e.version} \xb7 ${String(e.config.mode??"configured")}`,actions:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("button",{className:"secondary-btn",disabled:"active"!==e.status,onClick:()=>l(e.id),children:"Use as default"}),(0,t.jsx)("button",{className:"secondary-btn",type:"button",disabled:"active"!==e.status,title:"Deactivate policy","aria-label":`Deactivate policy ${e.name} version ${e.version}`,onClick:()=>o(e),children:(0,t.jsx)(A,{size:14,"aria-hidden":"true"})})]})},e.id))})]})}let cT=o("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"}]]),cM=o("info",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]]),cR=o("save",[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]]);function cE(e){return Promise.all([(0,e5.apiFetch)("/v1/prompt-templates").catch(()=>null),e?(0,e5.apiFetch)(`/v1/projects/${encodeURIComponent(e)}/prompt-templates`).catch(()=>null):Promise.resolve(null)])}function cA({projectId:e,setError:a}){let[s,i]=(0,n.useState)(null),[r,l]=(0,n.useState)(null),[o,c]=(0,n.useState)(void 0),[d,u]=(0,n.useState)(!1),[p,h]=(0,n.useState)(""),[m,f]=(0,n.useState)(""),[g,x]=(0,n.useState)(""),[v,y]=(0,n.useState)(""),[b,k]=(0,n.useState)(!1),{markSaving:j,markSaved:w}=oP(),[N,_]=(0,n.useState)(null),[C,I]=(0,n.useState)(""),[T,M]=(0,n.useState)(""),[R,E]=(0,n.useState)(""),[A,$]=(0,n.useState)(null),[z,F]=(0,n.useState)(null),L=(0,n.useCallback)(async()=>{try{let[t,n]=await cE(e);i(t),l(n),c(e),a(null)}catch{c(e),a("Failed to load prompt templates")}},[e,a]);(0,n.useEffect)(()=>{let t=!1;return cE(e).then(([n,s])=>{t||(i(n),l(s),c(e),a(null))}).catch(()=>{t||(c(e),a("Failed to load prompt templates"))}),()=>{t=!0}},[e,a]);let D=r??s;async function O(e){if(e.preventDefault(),p.trim()&&v.trim()){k(!0),j();try{await (0,e5.apiFetch)("/v1/prompt-templates",{method:"POST",body:JSON.stringify({name:p.trim(),description:m.trim(),argumentHint:g.trim(),body:v})}),h(""),f(""),x(""),y(""),u(!1),await L(),w()}catch(e){a(e.message)}finally{k(!1)}}}async function q(e){j();try{await (0,e5.apiFetch)(`/v1/prompt-templates/${encodeURIComponent(e)}`,{method:"DELETE"}),F(null),await L(),w()}catch(e){a(e.message)}}async function B(e){if(R.trim()){k(!0),j();try{await (0,e5.apiFetch)(`/v1/prompt-templates/${encodeURIComponent(e)}`,{method:"PUT",body:JSON.stringify({description:C.trim(),argumentHint:T.trim(),body:R})}),_(null),await L(),w()}catch(e){a(e.message)}finally{k(!1)}}}if(o!==e&&!s)return(0,t.jsx)("div",{className:"settings-tab-section",children:(0,t.jsx)("p",{children:"Loading…"})});let U=[...s?.diagnostics??[],...r?.diagnostics??[]],H=s?.globalRecoveryMode??!1;return(0,t.jsxs)("section",{className:"settings-tab-section","aria-labelledby":"settings-templates-heading",children:[(0,t.jsxs)("header",{children:[(0,t.jsx)("h2",{id:"settings-templates-heading",children:"Prompt templates"}),(0,t.jsx)("p",{children:"Manage slash-command prompt templates across builtin, settings, global, and project sources."})]}),U.length>0&&(0,t.jsx)("div",{className:"templates-diag-banner",role:"status",children:U.map((e,n)=>(0,t.jsxs)("div",{className:`templates-diag ${"warning"===e.level?"diag-warn":"diag-info"}`,children:[(0,t.jsx)("span",{className:"templates-diag-icon",children:"warning"===e.level?(0,t.jsx)(cT,{size:14}):(0,t.jsx)(cM,{size:14})}),(0,t.jsxs)("span",{className:"templates-diag-msg",children:[(0,t.jsx)("code",{children:e.code})," ",e.message]})]},n))}),D&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("header",{className:"templates-section-header",children:(0,t.jsxs)("h3",{children:["Effective templates ",e?"(project)":"(global)"]})}),0===D.templates.length?(0,t.jsxs)("p",{className:"templates-empty",children:["No templates available. Create a global template below or add markdown files to your project's ",(0,t.jsx)("code",{children:".ennote/prompts/"})," directory."]}):(0,t.jsx)("ul",{className:"templates-list",children:D.templates.map(e=>(0,t.jsxs)("li",{className:"template-row",children:[(0,t.jsxs)("span",{className:"template-name",children:["/",e.name]}),e.argumentHint&&(0,t.jsx)("span",{className:"template-hint",children:e.argumentHint}),(0,t.jsx)("span",{className:"template-source source-{t.source}",children:e.source}),(0,t.jsx)("span",{className:"template-desc",children:e.description})]},e.name))})]}),(0,t.jsxs)("header",{className:"templates-section-header",children:[(0,t.jsx)("h3",{children:"My global templates"}),!H&&(0,t.jsxs)("button",{type:"button",className:"settings-btn",onClick:()=>u(!d),children:[(0,t.jsx)(S,{size:14})," New"]})]}),H&&(0,t.jsxs)("div",{className:"templates-diag diag-warn templates-diag-block",children:[(0,t.jsx)(cT,{size:14}),(0,t.jsx)("span",{children:"Global store is in recovery mode. Delete some entries to restore normal operation. Create is disabled."})]}),d&&(0,t.jsxs)("form",{className:"template-edit-form",onSubmit:O,children:[(0,t.jsxs)("label",{children:["Name ",(0,t.jsx)("input",{value:p,onChange:e=>h(e.target.value),placeholder:"my-command",required:!0,disabled:b})]}),(0,t.jsxs)("label",{children:["Description ",(0,t.jsx)("input",{value:m,onChange:e=>f(e.target.value),placeholder:"Optional",disabled:b})]}),(0,t.jsxs)("label",{children:["Argument hint ",(0,t.jsx)("input",{value:g,onChange:e=>x(e.target.value),placeholder:"<path> [focus]",disabled:b})]}),(0,t.jsxs)("label",{children:["Body ",(0,t.jsx)("textarea",{value:v,onChange:e=>y(e.target.value),rows:4,placeholder:"Template body with $1, $@, etc.",required:!0,disabled:b})]}),(0,t.jsxs)("div",{className:"template-form-actions",children:[(0,t.jsxs)("button",{type:"submit",className:"settings-btn primary",disabled:b||!p.trim()||!v.trim(),children:[(0,t.jsx)(cR,{size:14})," ",b?"Saving…":"Create"]}),(0,t.jsx)("button",{type:"button",className:"settings-btn",onClick:()=>u(!1),children:"Cancel"})]})]}),s?.globalTemplates&&s.globalTemplates.length>0&&(0,t.jsx)("ul",{className:"templates-list",children:s.globalTemplates.map(e=>(0,t.jsxs)("li",{className:`template-row ${!e.valid?"invalid":""}`,children:[(0,t.jsxs)("span",{className:"template-name",children:["/",e.name]}),e.argumentHint&&(0,t.jsx)("span",{className:"template-hint",children:e.argumentHint}),e.valid?(0,t.jsx)("span",{className:"template-desc",children:e.description}):(0,t.jsxs)("span",{className:"template-desc diag-text",children:[e.diagnostic?.code,": ",e.diagnostic?.message]}),(0,t.jsx)("div",{className:"template-actions",children:e.editable&&N===e.name?(0,t.jsxs)("div",{className:"template-edit-form template-edit-form-inline",children:[e.valid&&(0,t.jsxs)("div",{className:"template-edit-readonly",children:["Name: ",e.name]}),(0,t.jsxs)("label",{children:["Description ",(0,t.jsx)("input",{value:C,onChange:e=>I(e.target.value),disabled:b})]}),(0,t.jsxs)("label",{children:["Argument hint ",(0,t.jsx)("input",{value:T,onChange:e=>M(e.target.value),disabled:b})]}),(0,t.jsxs)("label",{children:["Body ",(0,t.jsx)("textarea",{value:R,onChange:e=>E(e.target.value),rows:4,disabled:b})]}),(0,t.jsxs)("div",{className:"template-form-actions",children:[(0,t.jsxs)("button",{type:"button",className:"settings-btn primary",onClick:()=>B(e.name),disabled:b||!R.trim(),children:[(0,t.jsx)(cR,{size:14})," ",b?"Saving…":e.valid?"Update":"Repair"]}),(0,t.jsx)("button",{type:"button",className:"settings-btn",onClick:()=>_(null),children:"Cancel"})]})]}):e.editable?z===e.name?(0,t.jsxs)("span",{className:"template-confirm",children:[(0,t.jsxs)("span",{children:["Delete /",e.name,"?"]}),(0,t.jsx)("button",{type:"button",className:"settings-btn danger",onClick:()=>q(e.name),disabled:b,children:"Delete"}),(0,t.jsx)("button",{type:"button",className:"settings-btn",onClick:()=>F(null),children:"Cancel"})]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("button",{type:"button",className:"settings-btn",onClick:()=>{_(e.name),e.valid?(0,e5.apiFetch)(`/v1/prompt-templates/${encodeURIComponent(e.name)}`).then(e=>{I(e.description),M(e.argumentHint),E(e.body)}).catch(()=>{}):(I(""),M(""),E(""))},children:e.valid?"Edit":"Repair"}),(0,t.jsx)("button",{type:"button",className:"settings-btn danger",onClick:()=>F(e.name),children:(0,t.jsx)(P,{size:14})})]}):(0,t.jsx)("span",{className:"template-manual-cleanup",children:"Manual cleanup required in $ENNOTE_HOME/prompts/"})}),e.valid&&A===e.name&&(0,t.jsx)(c$,{name:e.name,onClose:()=>$(null)})]},e.name))}),(!s?.globalTemplates||0===s.globalTemplates.length)&&!H&&(0,t.jsx)("p",{className:"templates-empty",children:"No global templates yet. Create one above."})]})}function c$({name:e,onClose:a}){let[s,i]=(0,n.useState)(null);return((0,n.useEffect)(()=>{(0,e5.apiFetch)(`/v1/prompt-templates/${encodeURIComponent(e)}`).then(e=>i(e.body)).catch(()=>i("Failed to load"))},[e]),null===s)?(0,t.jsx)("div",{className:"template-body-preview",children:"Loading…"}):(0,t.jsxs)("div",{className:"template-body-preview",children:[(0,t.jsx)("pre",{children:s}),(0,t.jsx)("button",{type:"button",className:"settings-btn",onClick:a,children:"Close"})]})}function cz(e){switch(e){case"general":return(0,t.jsx)(p,{size:15,"aria-hidden":"true"});case"models":return(0,t.jsx)(ok,{size:15,"aria-hidden":"true"});case"policies":return(0,t.jsx)(o_,{size:15,"aria-hidden":"true"});case"context":return(0,t.jsx)(oj,{size:15,"aria-hidden":"true"});case"templates":return(0,t.jsx)(ei,{size:15,"aria-hidden":"true"});case"mcp":return(0,t.jsx)(oN,{size:15,"aria-hidden":"true"});case"skills":return(0,t.jsx)(X,{size:15,"aria-hidden":"true"});case"packs":return(0,t.jsx)(ow,{size:15,"aria-hidden":"true"})}}function cF({open:e,onClose:n,initialTab:a,providers:s,models:i,policies:r,session:l,refresh:o,error:c,setError:d,onSessionUpdated:u,projectId:p}){return e?(0,t.jsx)("div",{className:"settings-dialog-backdrop",onClick:e=>{e.target===e.currentTarget&&n()},children:(0,t.jsx)(oI,{children:(0,t.jsx)(cL,{initialTab:a,onClose:n,providers:s,models:i,policies:r,session:l,refresh:o,error:c,setError:d,onSessionUpdated:u,projectId:p},a??"general")})}):null}function cL({onClose:e,initialTab:a,providers:s,models:i,policies:r,session:l,refresh:o,error:c,setError:d,onSessionUpdated:p,projectId:h}){let g=(0,f.useT)(),{markError:x}=oP(),v=(0,n.useCallback)(e=>{d(e),e&&x(e)},[d,x]),[y,b]=(0,n.useState)(a??"general"),[k,j]=(0,n.useState)(""),w=(0,n.useRef)(null),N=(0,n.useRef)(null),_=(0,n.useRef)(null);M(!0,e),(0,n.useEffect)(()=>{let e=window.requestAnimationFrame(()=>N.current?.focus()),t=e=>{if((e.metaKey||e.ctrlKey)&&"k"===e.key.toLowerCase()){e.preventDefault(),_.current?.focus();return}if("Tab"!==e.key||!w.current)return;let t=Array.from(w.current.querySelectorAll('button:not(:disabled), input:not(:disabled), select:not(:disabled), textarea:not(:disabled), [href], [tabindex]:not([tabindex="-1"])'));if(0===t.length)return;let n=t[0],a=t[t.length-1];e.shiftKey&&document.activeElement===n?(e.preventDefault(),a.focus()):e.shiftKey||document.activeElement!==a||(e.preventDefault(),n.focus())};return window.addEventListener("keydown",t),()=>{window.cancelAnimationFrame(e),window.removeEventListener("keydown",t)}},[]);let C=[{id:"general",label:"General",description:"Appearance and theme",icon:cz("general")},{id:"models",label:"Models",description:"Providers, API keys, and model profiles",icon:cz("models")},{id:"policies",label:"Policies",description:"Tool permission and routing policies",icon:cz("policies")},{id:"context",label:"Context & session",description:l?"Session defaults and compaction":"Compaction policy defaults",icon:cz("context")},{id:"templates",label:"Templates",description:"Slash-command prompt templates",icon:cz("templates")},{id:"mcp",label:"MCP",description:"MCP servers and project bindings",icon:cz("mcp")},{id:"skills",label:"Skills",description:"Skill catalog, marketplace, and updates",icon:cz("skills")},{id:"packs",label:"Packs",description:"Agent Packs: inspect, install, and remove",icon:cz("packs")}],S=k.trim().toLowerCase(),I=""===S?C:C.filter(e=>`${e.label} ${e.description}`.toLowerCase().includes(S));return(0,t.jsx)("div",{ref:w,className:"settings-dialog-shell",role:"dialog","aria-modal":"true","aria-label":"Settings",children:(0,t.jsxs)("div",{className:"settings-dialog-body",children:[(0,t.jsxs)("div",{className:"settings-dialog-tabs",role:"tablist","aria-label":"Settings sections",children:[(0,t.jsx)("div",{id:"settings-dialog-title",className:"settings-dialog-navtitle",children:"Settings"}),(0,t.jsxs)("label",{className:"settings-dialog-search",children:[(0,t.jsx)(u,{size:14,"aria-hidden":"true"}),(0,t.jsx)("input",{ref:_,type:"text",value:k,placeholder:g("settings.search.placeholder"),"aria-label":g("settings.search.aria"),onChange:e=>(e=>{j(e);let t=e.trim().toLowerCase();if(""===t)return;let n=C.filter(e=>`${e.label} ${e.description}`.toLowerCase().includes(t));n.length>0&&!n.some(e=>e.id===y)&&b(n[0].id)})(e.target.value),onKeyDown:e=>{if("Escape"===e.key&&""!==k&&!e.nativeEvent.isComposing){e.preventDefault(),e.stopPropagation(),j("");return}"Enter"===e.key&&I.length>0&&(e.preventDefault(),b(I[0].id))}}),""!==k&&(0,t.jsx)("button",{type:"button","aria-label":g("settings.search.clear"),onClick:()=>j(""),children:(0,t.jsx)(m,{size:12,"aria-hidden":"true"})})]}),0===I.length&&(0,t.jsx)("div",{className:"settings-dialog-empty",children:g("settings.search.empty",{query:k.trim()})}),I.map((e,n)=>{let a=y===e.id;return(0,t.jsxs)("button",{type:"button",onClick:()=>b(e.id),onKeyDown:e=>{let t=null;if(("ArrowRight"===e.key||"ArrowDown"===e.key)&&(t=(n+1)%I.length),("ArrowLeft"===e.key||"ArrowUp"===e.key)&&(t=(n-1+I.length)%I.length),"Home"===e.key&&(t=0),"End"===e.key&&(t=I.length-1),null===t)return;e.preventDefault();let a=I[t];b(a.id),window.requestAnimationFrame(()=>document.getElementById(`settings-tab-${a.id}`)?.focus())},className:`settings-dialog-tab ${a?"active":""}`,role:"tab",id:`settings-tab-${e.id}`,"aria-selected":a,"aria-controls":`settings-panel-${e.id}`,children:[(0,t.jsx)("span",{className:"settings-tab-icon",children:e.icon}),(0,t.jsx)("span",{className:"settings-tab-label",children:e.label})]},e.id)})]}),(0,t.jsxs)("div",{className:"settings-dialog-content",children:[(0,t.jsxs)("div",{className:"settings-dialog-header",children:[(0,t.jsxs)("div",{className:"settings-dialog-actions",children:[(0,t.jsx)(oT,{}),(0,t.jsx)("span",{id:"settings-dialog-current",className:"settings-dialog-current",children:C.find(e=>e.id===y)?.label})]}),(0,t.jsx)("button",{ref:N,type:"button",className:"settings-dialog-close",title:"Close settings","aria-label":"Close settings",onClick:e,children:(0,t.jsx)(m,{size:14,"aria-hidden":"true"})})]}),c&&(0,t.jsxs)("div",{className:"error-bar",role:"alert",children:[(0,t.jsx)("span",{children:c}),(0,t.jsx)("button",{type:"button",onClick:()=>d(null),"aria-label":"Dismiss error",children:(0,t.jsx)(m,{size:15,"aria-hidden":"true"})})]}),(0,t.jsxs)("div",{className:"settings-dialog-panel",role:"tabpanel",id:`settings-panel-${y}`,"aria-labelledby":`settings-tab-${y}`,children:["general"===y&&(0,t.jsx)("div",{className:"settings-tab-scroll",children:(0,t.jsx)(oV,{})}),"models"===y&&(0,t.jsx)("div",{className:"settings-tab-scroll",children:(0,t.jsx)(cC,{providers:s,models:i,refresh:o,setError:v})}),"policies"===y&&(0,t.jsx)("div",{className:"settings-tab-scroll",children:(0,t.jsx)(cI,{policies:r,refresh:o,setError:v})}),"context"===y&&(0,t.jsx)("div",{className:"settings-tab-scroll",children:(0,t.jsx)(o$,{policies:r,models:i,session:l,refresh:o,setError:v,onSessionUpdated:p})}),"templates"===y&&(0,t.jsx)("div",{className:"settings-tab-scroll",children:(0,t.jsx)(cA,{projectId:h,setError:v})}),"mcp"===y&&(0,t.jsx)("div",{className:"settings-tab-scroll",children:(0,t.jsx)(o2,{projectId:h,setError:v})}),"skills"===y&&(0,t.jsx)("div",{className:"settings-tab-scroll",children:(0,t.jsx)(ce,{projectId:h,setError:v})}),"packs"===y&&(0,t.jsx)("div",{className:"settings-tab-scroll",children:(0,t.jsx)(oJ,{setError:v})})]})]})]})})}var cD=e.i(85026);function cO({settingsOpen:e,settingsTab:n,onCloseSettings:a,providers:s,models:i,policies:r,session:l,projectId:o,error:c,refresh:d,setError:u,onSessionUpdated:p}){let{createProjectOpen:h,createProjectBusy:m,confirmCreateProject:f,cancelCreateProject:g}=(0,cD.useWorkspace)();return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(cF,{open:e,onClose:a,initialTab:n,providers:s,models:i,policies:r,session:l,refresh:d,error:c,setError:u,onSessionUpdated:p,projectId:o}),(0,t.jsx)(rd,{}),h&&(0,t.jsx)(ob,{busy:m,onCreate:f,onClose:g})]})}var cq=e.i(48686);function cB({workerUnreachable:e}){return e?(0,t.jsx)("div",{className:cq.default.banner,role:"status","data-testid":"offline-banner",children:"Worker unreachable — Ennote is read-only until it returns."}):null}function cU({initialWidth:e,minWidth:t,maxWidth:a,storageKey:s,direction:i="right",resolveStored:r,cssVariable:l}){let[o,c]=(0,n.useState)(e),[d,u]=(0,n.useState)(!1),p=(0,n.useRef)(e),h=(0,n.useCallback)(e=>{let n=Math.max(t,Math.min(a,e));c(n),p.current=n,l&&document.documentElement.style.setProperty(l,`${n}px`)},[t,a,l]);(0,n.useEffect)(()=>{let e=window.requestAnimationFrame(()=>{let e=p.current;try{let n=localStorage.getItem(s),i=n?Number.parseInt(n,10):NaN;Number.isFinite(i)&&(r?e=r(i):i>=t&&i<=a&&(e=i))}catch{}h(e)});return()=>window.cancelAnimationFrame(e)},[s,t,a,r,h]);let m=(0,n.useCallback)(()=>{u(!0)},[]),f=(0,n.useCallback)(e=>{let t="left"===i?-1:1;h(p.current+e*t)},[h,i]);return{beginResize:m,endResize:(0,n.useCallback)(()=>{u(!1);try{localStorage.setItem(s,String(p.current))}catch{}},[s]),isResizing:d,resizeBy:f,width:o}}let cH="ennote:sidebar:collapsed-projects";function cW(){try{let e=window.localStorage.getItem(cH);return e?new Set(JSON.parse(e)):new Set}catch{return new Set}}let cV="ennote-onboarding-done";function cK(){let[e,t]=(0,n.useState)([]),[a,s]=(0,n.useState)([]),[i,r]=(0,n.useState)([]),[l,o]=(0,n.useState)(null),[c,d]=(0,n.useState)(!0),u=(0,n.useRef)(0),p=(0,n.useRef)(null),h=(0,n.useCallback)(async()=>{p.current?.abort();let e=new AbortController;p.current=e;let n=++u.current;try{let[a,i,l]=await Promise.all([(0,e5.apiFetch)("/v1/provider-profiles",{signal:e.signal}),(0,e5.apiFetch)("/v1/model-profiles",{signal:e.signal}),(0,e5.apiFetch)("/v1/policy-profiles",{signal:e.signal})]);if(e.signal.aborted||u.current!==n)return;t(a),s(i),r(l),o(null)}catch(t){e.signal.aborted||u.current!==n||o(t.message)}finally{e.signal.aborted||u.current!==n||d(!1)}},[]);return(0,n.useEffect)(()=>{let e=window.setTimeout(()=>void h(),0);return()=>{window.clearTimeout(e),p.current?.abort()}},[h]),{providers:e,models:a,policies:i,error:l,loading:c,setError:o,refresh:h}}let cG={provider_configuration_invalid:"The provider runtime configuration is invalid.",provider_credential_unavailable:"The configured credential could not be resolved.",provider_authentication_failed:"The provider rejected the configured credential.",provider_model_not_found:"The configured model was not found by the provider.",provider_rate_limited:"The provider rate limit was reached. Try again later.",provider_request_timeout:"The provider did not respond before the timeout.",provider_request_rejected:"The provider rejected the model request.",provider_unavailable:"The provider is currently unavailable.",model_protocol_error:"The provider returned an invalid response.",model_stream_interrupted:"The provider response was interrupted.",context_overflow:"The request exceeds the model context window.",context_overflow_after_compaction:"The request still exceeds the context window after compaction.",context_overflow_in_run:"The active run exceeded the model context window."};function cJ(e){let t="string"==typeof e?e:"";return cG[t]??(t?`The run failed (${t}).`:"The run failed.")}function cY(e,t){return e instanceof Error&&e.message?e.message:"string"==typeof e&&e.trim()?e:(console.warn("[ennote] non-Error rejection captured",e),t)}function cQ(e){let t=e.toolCallId??e.id??e.recordId;return null!=t?String(t):`event-${e.callIndex??"unknown"}`}let cZ={optimistic:[],settled:new Set};function cX(e,t){switch(t.type){case"queue":return{...e,optimistic:[...e.optimistic,t.row]};case"settle":{if(!t.id)return e;let n=new Set(e.settled);return n.add(t.id),{optimistic:e.optimistic.filter(e=>e.id!==t.id),settled:n}}case"reset":return cZ}}function c0(){return"u">typeof crypto&&crypto.randomUUID?crypto.randomUUID():Math.random().toString(36).slice(2)+Date.now().toString(36)}class c1 extends Error{}async function c2(e,t,n){let a=await (0,e5.apiResponse)(`/v1/runs/${encodeURIComponent(e)}/events`,{signal:n});if(!a.ok)throw Error(`HTTP ${a.status}`);let s=a.body?.getReader();if(!s)return!1;let i=new TextDecoder,r="";try{for(;;){let{done:e,value:n}=await s.read();if(e)break;let a=(r+=i.decode(n,{stream:!0})).split("\n");for(let e of(r=a.pop()??"",a)){let n=e.endsWith("\r")?e.slice(0,-1):e;if(!n.startsWith("data:"))continue;let a=JSON.parse(n.slice(5).trimStart());switch(a.type){case"context_compaction_started":t(i_("compacting"));break;case"context_compaction_retry_scheduled":t(i_("compaction_retry_wait",String(a.payload?.delayMs??0)));break;case"context_compaction_retry_started":t(i_("compaction_retry"));break;case"context_compaction_completed":t(i_("checkpoint_ready"));break;case"context_compaction_failed":throw new c1("Context compaction failed.");case"context_compaction_cancelled":case"run_cancelled":throw new c1("Context compaction was cancelled.");case"run_succeeded":return!0;case"run_failed":throw new c1(cJ(a.payload?.errorCode))}}}}finally{s.releaseLock()}return!1}async function c4(e,t,n,a,s,i,r,l,o){let c=new Headers;o.value&&c.set("Last-Event-ID",o.value);let d=await (0,e5.apiResponse)(`/v1/runs/${encodeURIComponent(e)}/events`,{signal:i,headers:c});if(!d.ok)throw Error(`HTTP ${d.status}`);let u=d.body?.getReader();if(!u)return!1;let p=new TextDecoder,h="",{assistants:m,toolDeltas:f,toolOutputs:g}=l,x=null,v=!1,{usageByIteration:y}=l;function b(e){let t=m.get(e)??{text:"",thinking:""};return m.set(e,t),t}function k(n){let a=b(n);t({id:`${e}-assistant-${n}`,role:"assistant",text:a.text,thinking:a.thinking})}function j(n,a,s){let i=cQ(n),r=n.arguments&&"object"==typeof n.arguments&&!Array.isArray(n.arguments)?n.arguments:void 0;t({id:`${e}-tool-${i}`,role:"tool",kind:"tool",toolCallId:i,toolName:String(n.toolName??n.name??"tool"),text:String(n.content??n.reason??s),arguments:r,argumentsFragment:"string"==typeof n.argumentsFragment?n.argumentsFragment:void 0,isError:!!n.isError||"failed"===a,toolState:a,runId:e})}try{for(;;){let{done:i,value:c}=await u.read();if(i)break;let d=(h+=p.decode(c,{stream:!0})).split("\n");for(let i of(h=d.pop()??"",d)){let c=i.endsWith("\r")?i.slice(0,-1):i;if(c.startsWith("id:")){let e=c.slice(3).trim();e&&(o.value=e);continue}if(c.startsWith("event:")){x=c.slice(6).trim(),v="live"===x;continue}if(c.startsWith(":")||!c.startsWith("data:"))continue;let d=JSON.parse(c.slice(5).trimStart()),u=v;v=!1;let p=d.payload??{},h="number"==typeof p.iteration?p.iteration:1;switch(d.type){case"usage_updated":{let e=p.usage;e&&function(e,t){y.set(e,{uncachedInputTokens:Number(t.uncachedInputTokens??0),cacheReadTokens:Number(t.cacheReadTokens??0),cacheWriteTokens:Number(t.cacheWriteTokens??0),outputTokens:Number(t.outputTokens??0),reasoningTokens:Number(t.reasoningTokens??0)});let n={uncachedInputTokens:0,cacheReadTokens:0,cacheWriteTokens:0,outputTokens:0,reasoningTokens:0};for(let e of y.values())n.uncachedInputTokens+=e.uncachedInputTokens,n.cacheReadTokens+=e.cacheReadTokens,n.cacheWriteTokens+=e.cacheWriteTokens,n.outputTokens+=e.outputTokens,n.reasoningTokens+=e.reasoningTokens;a(n)}(h,e);break}case"context_usage":p&&"number"==typeof p.contextWindow&&s(p);break;case"text_delta":case"thinking_delta":if(!u)break;"text_delta"===d.type?b(h).text+=String(p.text??""):b(h).thinking+=String(p.text??""),k(h);break;case"model_call_retry_scheduled":m.set(h,{text:"",thinking:""}),k(h),n(i_("model_retry",String(p.delayMs??0)));break;case"context_pruned":n(i_("preparing_context"));break;case"context_compaction_planned":n(i_("compaction_queued"));break;case"context_compaction_started":n(i_("compacting"));break;case"context_compaction_retry_scheduled":n(i_("compaction_retry_wait",String(p.delayMs??0)));break;case"context_compaction_completed":n(i_("checkpoint_ready"));break;case"run_context_compaction_planned":n(i_("preparing_run_context"));break;case"run_context_compaction_started":n(i_("compacting_run"));break;case"run_context_compaction_retry_scheduled":n(i_("run_compaction_retry",String(p.delayMs??0)));break;case"run_context_compaction_completed":n(i_("run_context_compacted"));break;case"run_context_compaction_failed":n(i_("run_compaction_skipped"));break;case"run_context_compaction_cancelled":n("");break;case"context_checkpoint_selected":n(i_("using_checkpoint"));break;case"output_truncated":n(i_(Number(p.partialToolCallCount??0)>0?"recovering_tool":"output_truncated"));break;case"tool_call_delta":{if(!u)break;let e=p.id?String(p.id):"";if(e&&l.finishedTools.has(e))break;let t=`${h}:${p.index??0}`,n=f.get(t)??{id:"",name:"tool",argumentsFragment:""};p.id&&(n.id=String(p.id)),p.name&&(n.name=String(p.name)),n.argumentsFragment+=String(p.argumentsFragment??""),f.set(t,n),j({...p,toolCallId:n.id||t,toolName:n.name,argumentsFragment:n.argumentsFragment},"pending","Collecting tool arguments…");break}case"child_progress":var w;if(!u)break;w={delegationGroupId:String(p.delegationGroupId??""),taskName:String(p.taskName??""),childRunId:String(p.childRunId??""),activity:String(p.activity??""),tokens:Number(p.tokens??0)},ru?.(w);break;case"tool_output_delta":{if(!u)break;let n=function(e){let t=e.toolCallId,n=e.stream,a=e.text;if("string"!=typeof t||""===t)return null;let s="string"==typeof n&&({stdout:!0,stderr:!0,progress:!0})[n]?n:null;if(!s||"string"!=typeof a)return null;let i=e.toolName;return void 0!==i&&"string"!=typeof i?null:{toolCallId:t,stream:s,text:a,...void 0===i?{}:{toolName:i}}}(p);if(!n)break;let a=n.toolCallId;if(l.finishedTools.has(a))break;let s=n.stream,i=n.text,r=g.get(a)??{text:"",name:""};n.toolName&&(r.name=n.toolName),"stderr"===s?r.text+=`[stderr] ${i}`:r.text+=i,g.set(a,r),t({id:`${e}-tool-${a}`,role:"tool",kind:"tool",toolCallId:a,...r.name?{toolName:r.name}:{},text:r.text,isError:!1,toolState:"running",runId:e});break}case"tool_call_started":{let e=cQ(p);l.finishedTools.delete(e),l.toolOutputs.delete(e),n(i_("running_tool",String(p.toolName??"tool"))),j(p,"running","Running");break}case"tool_call_completed":{n(""),("delegate_tasks"===p.toolName||"delegate_heroes"===p.toolName)&&r.delegated();let e=cQ(p);g.delete(e),l.finishedTools.add(e),j(p,p.isError?"failed":"completed","No output");break}case"tool_call_failed":{let e=cQ(p);g.delete(e),l.finishedTools.add(e),j(p,"failed","Tool call failed.");break}case"tool_policy_denied":case"tool_policy_terminated":case"tool_call_skipped":l.finishedTools.add(cQ(p)),j(p,String(p.reason??"").includes("approval_rejected")?"rejected":"failed","Tool call skipped.");break;case"model_route_selected":n(i_("using_model",String(p.apiModel??"selected model")));break;case"vision_fallback_started":n(i_("describing_image"));break;case"vision_fallback_completed":n(i_("image_ready"));break;case"approval_requested":n(i_("waiting_approval")),r.requested();break;case"approval_resolved":n(i_("resuming")),r.resolved();break;case"follow_up_consumed":{let e=String(p.queueItemId??"");e&&r.followUpConsumed(e);break}case"input_cancelled":{let e=String(p.queueItemId??"");e&&r.inputCancelled(e);break}case"run_succeeded":return n(i_("completed")),!0;case"run_cancelled":return n(i_("cancelled")),!0;case"run_interrupted":return n(i_("interrupted")),!0;case"run_failed":throw new c1(cJ(p.errorCode))}}}}finally{u.releaseLock()}return!1}function c5(e,t,n){let a=e.steps[e.steps.length-1];for(let s of(a?.kind==="tool_batch"?a.activities.push(...t):e.steps.push({kind:"tool_batch",id:`batch-${t[0].id}`,activities:t}),t))n.set(s.toolCallId,s)}function c3(e,t,n){e.set(t,[...e.get(t)??[],n])}function c6(e,t){return/approval[_ ]rejected/i.test(e)?"rejected":t?"failed":"completed"}class c8{read;timer;dirty;constructor(e){this.read=e,this.timer=null,this.dirty=!1}markDirty(){this.dirty=!0,this.timer||(this.timer=setTimeout(()=>{this.timer=null,this.dirty=!1,this.read()},400))}flush(){this.cancelPending(),this.dirty=!1,this.read()}cancelPending(){this.timer&&(clearTimeout(this.timer),this.timer=null)}takeInterruptedRead(){return!!this.dirty&&(this.dirty=!1,!0)}replaceWindow(){this.cancelPending(),this.dirty=!1}}class c9{sessionId;dataBranchId;requestedBranchId;loaded=!1;canonical=[];checkpoints=[];transient=[];nextCursor;hasMore=!1;loading=!1;loadingOlder=!1;error=null;requestVersion=0;requestController=null;activeRun=null;pendingApproval=null;queuedInputs=[];delegationActive=!1;lastSeq=0;workerInstanceId=null;streamController=null;streamOpen=!1;reconnectTimer=null;reconnectAttempt=0;eventCursor;streamPaused=!1;disposed=!1;windowRefresh=new c8(()=>this.refreshLatest());listeners=new Set;snapshot=null;constructor(e){this.sessionId=e}subscribe=e=>(this.listeners.add(e),()=>{this.listeners.delete(e)});getSnapshot=()=>(this.snapshot||(this.snapshot=this.buildSnapshot()),this.snapshot);getServerSnapshot=()=>(this.snapshot||(this.snapshot=this.buildSnapshot()),this.snapshot);ensureLoaded=e=>(this.requestedBranchId=e,this.openStream(),this.loaded&&this.dataBranchId===e)?this.windowRefresh.takeInterruptedRead()?this.refreshLatest():Promise.resolve():(this.resetForBranch(),this.loadInitial(e));loadOlder=async()=>{if(!this.loaded||!this.hasMore||!this.nextCursor||this.loadingOlder)return!1;this.requestVersion+=1;let e=this.requestVersion;this.requestController?.abort();let t=new AbortController;this.requestController=t,this.loadingOlder=!0,this.error=null,this.notify();try{let n,a=await (0,e5.apiFetch)(`/v1/sessions/${encodeURIComponent(this.sessionId)}/messages?limit=50&before=${encodeURIComponent(this.nextCursor)}`,{signal:t.signal});if(t.signal.aborted||this.requestVersion!==e)return!1;let s=a.messages??[],i=this.canonical,r=s.length>0?s[s.length-1].seq??0:0,l=i.length>0?i[0].seq??0:0;if(r>0&&l>0&&r+1!==l)return this.error="History window is out of order; re-open the session to re-sync.",!1;return this.canonical=(n=new Set,[...s,...i].filter(e=>!n.has(e.id)&&(n.add(e.id),!0))),this.nextCursor=a.nextCursor,this.hasMore=a.hasMore,!0}catch(n){return t.signal.aborted||this.requestVersion!==e||(this.error=n.message),!1}finally{t.signal.aborted||this.requestVersion!==e||(this.loadingOlder=!1),this.notify()}};refreshLatest=async()=>{if(this.disposed)return;this.requestVersion+=1;let e=this.requestVersion;this.requestController?.abort();let t=new AbortController;this.requestController=t,this.loadingOlder=!1;try{let[n,a]=await Promise.all([(0,e5.apiFetch)(`/v1/sessions/${encodeURIComponent(this.sessionId)}/messages?limit=50`,{signal:t.signal}),(0,e5.apiFetch)(`/v1/sessions/${encodeURIComponent(this.sessionId)}/compactions`,{signal:t.signal})]);if(t.signal.aborted||this.requestVersion!==e)return;let s=!this.loaded;this.canonical=s?n.messages??[]:function(e,t){if(0===e.length)return t;if(0===t.length)return e;let n=new Set(t.map(e=>e.id)),a=e.findIndex(e=>n.has(e.id));return a<0?t:[...e.slice(0,a),...t]}(this.canonical,n.messages??[]),this.checkpoints=a??[],s&&(this.nextCursor=n.nextCursor,this.hasMore=n.hasMore),this.dataBranchId=this.requestedBranchId,this.loaded=!0,this.loading=!1,this.transient=[],this.error=null}catch(n){t.signal.aborted||this.requestVersion!==e||(this.error=n.message)}finally{this.notify()}};appendTransient=e=>{this.transient.some(t=>t.id===e.id)||(this.transient=[...this.transient,e],this.notify())};upsertTransient=e=>{let t=this.transient.findIndex(t=>t.id===e.id);if(t<0)this.transient=[...this.transient,e];else{let n=[...this.transient];n[t]={...n[t],...e},this.transient=n}this.notify()};removeTransient=e=>{let t=this.transient.filter(t=>t.id!==e);t.length!==this.transient.length&&(this.transient=t,this.notify())};openStream=()=>{this.streamPaused=!1,this.disposed||this.streamOpen||this.streamController||this.openStreamInternal()};pauseStream=()=>{this.streamPaused=!0,this.reconnectTimer&&clearTimeout(this.reconnectTimer),this.reconnectTimer=null,this.reconnectAttempt=0,this.windowRefresh.cancelPending(),this.streamController?.abort(),this.streamController=null,this.clearProjection(),this.streamOpen&&(this.streamOpen=!1,this.notify())};dispose=()=>{this.disposed=!0,this.requestController?.abort(),this.streamController?.abort(),this.reconnectTimer&&clearTimeout(this.reconnectTimer),this.reconnectTimer=null,this.windowRefresh.replaceWindow(),this.listeners.clear()};async openStreamInternal(){if(this.disposed)return;let e=new AbortController;this.streamController=e,this.streamOpen=!0,this.notify();try{let t={};this.eventCursor&&(t["Last-Event-ID"]=this.eventCursor),await (0,e5.apiEventStream)(`/v1/sessions/${encodeURIComponent(this.sessionId)}/events`,e=>this.handleStreamFrame(e),{signal:e.signal,headers:t})}catch{}finally{this.streamController===e&&(this.streamController=null,this.streamOpen=!1,this.notify(),this.disposed||this.streamPaused||this.scheduleReconnect())}}handleStreamFrame(e){e.id&&(this.eventCursor=e.id),this.reconnectAttempt=0;let t=e.data;if(t&&"object"==typeof t)switch(t.type){case"subscribed":this.workerInstanceId=t.instanceId??null,this.lastSeq=t.lastSeq??0,this.applySnapshot(t.snapshot);break;case"snapshot":this.lastSeq=t.lastSeq??0,this.applySnapshot(t.snapshot);break;case"message_committed":this.lastSeq=Math.max(this.lastSeq,t.lastSeq??0),this.disposed||this.windowRefresh.markDirty();break;case"run_succeeded":case"run_failed":case"run_cancelled":case"run_interrupted":case"context_compaction_completed":case"run_context_compaction_completed":this.disposed||this.windowRefresh.flush()}}clearProjection(){(null!==this.activeRun||null!==this.pendingApproval||0!==this.queuedInputs.length||this.delegationActive)&&(this.activeRun=null,this.pendingApproval=null,this.queuedInputs=[],this.delegationActive=!1,this.notify())}applySnapshot(e){e&&(this.activeRun=e.activeRun??null,this.pendingApproval=e.pendingApproval??null,this.queuedInputs=e.queuedInputs??[],this.delegationActive=e.delegationActive??!1,e.checkpoints&&(this.checkpoints=e.checkpoints.map(e=>({id:e.id,status:e.status,reason:e.reason,summary:e.summary,reclaimedTokens:e.reclaimedTokens,firstKeptMessageId:e.firstKeptMessageId,sourceThroughMessageId:e.sourceThroughMessageId,baseLeafMessageId:e.baseLeafMessageId,createdAt:e.createdAt,promptVersion:e.promptVersion,summaryContractDigest:e.summaryContractDigest}))),this.notify())}scheduleReconnect(){if(this.disposed||this.streamPaused||this.reconnectTimer)return;let e=Math.min(1e3*2**this.reconnectAttempt,15e3);this.reconnectAttempt+=1,this.reconnectTimer=setTimeout(()=>{this.reconnectTimer=null,this.openStream()},e)}resetForBranch(){this.requestVersion+=1,this.requestController?.abort(),this.requestController=new AbortController,this.windowRefresh.replaceWindow(),this.dataBranchId=void 0,this.loaded=!1,this.canonical=[],this.checkpoints=[],this.transient=[],this.nextCursor=void 0,this.hasMore=!1,this.error=null,this.loading=!0,this.loadingOlder=!1,this.notify()}async loadInitial(e){let t=this.requestVersion,n=this.requestController;try{let[a,s]=await Promise.all([(0,e5.apiFetch)(`/v1/sessions/${encodeURIComponent(this.sessionId)}/messages?limit=50`,{signal:n.signal}),(0,e5.apiFetch)(`/v1/sessions/${encodeURIComponent(this.sessionId)}/compactions`,{signal:n.signal})]);if(n.signal.aborted||this.requestVersion!==t)return;this.dataBranchId=e,this.canonical=a.messages??[],this.checkpoints=s??[],this.nextCursor=a.nextCursor,this.hasMore=a.hasMore,this.loaded=!0}catch(e){n.signal.aborted||this.requestVersion!==t||(this.error=e.message)}finally{n.signal.aborted||this.requestVersion!==t||(this.loading=!1),this.notify()}}buildSnapshot(){return{sessionId:this.sessionId,dataBranchId:this.dataBranchId,loaded:this.loaded,canonical:this.canonical,checkpoints:this.checkpoints,transient:this.transient,nextCursor:this.nextCursor,hasMore:this.hasMore,loading:this.loading,loadingOlder:this.loadingOlder,error:this.error,activeRun:this.activeRun,pendingApproval:this.pendingApproval,queuedInputs:this.queuedInputs,delegationActive:this.delegationActive,lastSeq:this.lastSeq,workerInstanceId:this.workerInstanceId,streamOpen:this.streamOpen}}notify(){for(let e of(this.snapshot=null,this.listeners))e()}}class c7{stores=new Map;order=[];getStore=e=>{let t=this.stores.get(e);return t||(t=new c9(e),this.stores.set(e,t),this.order.push(e),this.prune(8)),this.touch(e),t};has=e=>this.stores.has(e);disposeStore=e=>{let t=this.stores.get(e);t&&(t.dispose(),this.stores.delete(e));let n=this.order.indexOf(e);n>=0&&this.order.splice(n,1)};prune=e=>{for(;this.order.length>e;){let e=this.order.shift();void 0!==e&&this.disposeStore(e)}};touch(e){let t=this.order.indexOf(e);t>=0&&this.order.splice(t,1),this.order.push(e)}}let de=new c7,dt={sessionId:"",dataBranchId:void 0,loaded:!1,canonical:[],checkpoints:[],transient:[],nextCursor:void 0,hasMore:!1,loading:!1,loadingOlder:!1,error:null,activeRun:null,pendingApproval:null,queuedInputs:[],delegationActive:!1,lastSeq:0,workerInstanceId:null,streamOpen:!1},dn=()=>()=>{},da=async()=>!1,ds=async()=>{},di=()=>{},dr=()=>{},dl=()=>{},dc={nodes:[],openTurn:null,calls:new Map,syntheticTurn:0};function dd(e){return"discuss"===e||"ask"===e||"auto"===e}function du(e){return"object"==typeof e&&null!==e?e:void 0}let dp=new Set(["txt","md","mdx","json","yaml","yml","toml","csv","tsv","log","js","jsx","ts","tsx","py","r","go","rs","java","c","cpp","h","hpp","css","html","xml","sh","bash","sql"]);function dh(){return"u">typeof crypto&&crypto.randomUUID?crypto.randomUUID():Math.random().toString(36).slice(2)+Date.now().toString(36)}function dm(e,t){let n=new Map(t.map(e=>[e.id,e.name]));return e.filter(e=>"active"===e.status).map(e=>({ref:`${n.get(e.providerId)??e.providerId}/${e.modelName}`,label:e.displayName||e.modelName,model:e}))}let df=["room","reply","fresh","task_only"],dg={room:"Room",reply:"Reply",fresh:"Fresh",task_only:"Task only"},dx=["discuss","ask","auto"];function dv({models:e,providers:a,setError:s}){let i=(0,f.useT)(),r=(0,n.useMemo)(()=>dm(e,a),[e,a]),[l,o]=(0,n.useState)([]),[d,p]=(0,n.useState)(null),[h,m]=(0,n.useState)(null),[g,x]=(0,n.useState)(""),[v,y]=(0,n.useState)(null),[b,k]=(0,n.useState)(!1),[j,w]=(0,n.useState)({id:"",name:""}),[N,_]=(0,n.useState)(!1),[C,I]=(0,n.useState)(null);M(null!==C,()=>I(null));let P=(0,n.useCallback)(async()=>{let e=await (0,e5.apiFetch)("/v1/global-heroes");return o(e),e},[]),T=(0,n.useCallback)(async e=>{y("loading"),p(e);try{m(await (0,e5.apiFetch)(`/v1/global-heroes/${encodeURIComponent(e)}`)),_(!1),I(null),s(null)}catch(e){m(null),s(e.message)}finally{y(null)}},[s]);(0,n.useEffect)(()=>{let e=!1,t=window.setTimeout(()=>{P().then(t=>{let n=t.find(e=>!e.error);!e&&n&&T(n.id)}).catch(t=>{e||s(t.message)})},0);return()=>{e=!0,window.clearTimeout(t)}},[T,P,s]);let R=async()=>{if(!r[0])return void s("Create an active model before creating a Hero.");let e=j.id.trim(),t=j.name.trim();if(e&&t){y("creating");try{var n;let a=await (0,e5.apiFetch)("/v1/global-heroes",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({document:(n=r[0].ref,{schemaVersion:1,handle:e,name:t,description:"",positioning:"",icon:"bot",color:"neutral",model:{ref:n,thinkingEffort:"default",fallbacks:[]},skills:[],authority:"read_only",permissionCeiling:"discuss",allowedTools:["read","ls","grep","find"],context:{defaultMode:"room",allowedModes:["room","fresh","task_only"],ownExecutionContinuity:"none"},delegation:{admission:"auto_within_budget",allowedCallerKinds:["host"],allowedStrategies:["single","parallel"],maxInvocationsPerParentRun:16,maxConcurrentInstances:16,budgetCeiling:{maxModelCalls:4,maxToolCalls:8,maxTotalTokens:2e4,maxOutputTokens:4e3,maxCostUsdMicros:1e5,maxWallTimeMs:12e4}},outputContract:"text-v1",maxLoopIterations:8,prompt:"Perform the requested work independently. Distinguish evidence from assumptions and report a concise result."})})});k(!1),w({id:"",name:""}),m(a),p(a.id),await P(),s(null)}catch(e){s(e.message)}finally{y(null)}}},E=async e=>{if(h&&!v){y("saving");try{let t=await (0,e5.apiFetch)(`/v1/global-heroes/${encodeURIComponent(h.id)}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({expectedDigest:h.digest,document:e})});m(t),o(e=>e.map(e=>e.id===t.id?{...e,name:t.name,digest:t.digest,error:void 0}:e)),_(!1),I(null),s(null)}catch(e){_(!0),s(e.message)}finally{y(null)}}},A=async()=>{if(h)try{I(await (0,e5.apiFetch)(`/v1/global-heroes/${encodeURIComponent(h.id)}`))}catch(e){s(e.message)}},$=async()=>{if(h&&!v){y("publishing");try{await (0,e5.apiFetch)(`/v1/global-heroes/${encodeURIComponent(h.id)}/publish`,{method:"POST"}),s(null)}catch(e){s(e.message)}finally{y(null)}}},z=e=>{h&&m({...h,document:e(h.document)})},F=e=>{if(!h)return;let t=e(h.document);m({...h,document:t}),E(t)},L=l.filter(e=>`${e.name} ${e.id}`.toLowerCase().includes(g.trim().toLowerCase()));return(0,t.jsxs)("div",{className:`global-heroes ${d?"has-selection":""}`,children:[(0,t.jsxs)("aside",{className:"global-heroes-list",children:[(0,t.jsxs)("header",{children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("strong",{children:"Hero catalog"}),(0,t.jsxs)("span",{children:[l.length," global Heroes"]})]}),(0,t.jsx)("button",{type:"button",onClick:()=>k(e=>!e),"aria-label":"Add Hero",children:(0,t.jsx)(S,{size:18})})]}),b&&(0,t.jsxs)("div",{className:"global-hero-create",children:[(0,t.jsx)("input",{value:j.id,onChange:e=>w(t=>({...t,id:e.target.value})),placeholder:"hero-id"}),(0,t.jsx)("input",{value:j.name,onChange:e=>w(t=>({...t,name:e.target.value})),placeholder:"Hero name"}),(0,t.jsx)("button",{type:"button",onClick:()=>void R(),disabled:"creating"===v,children:"creating"===v?"Creating…":"Create"})]}),(0,t.jsxs)("label",{className:"global-hero-search",children:[(0,t.jsx)(u,{size:15}),(0,t.jsx)("input",{value:g,onChange:e=>x(e.target.value),placeholder:"Search Heroes"})]}),(0,t.jsxs)("div",{role:"listbox","aria-label":"Global Heroes",children:[L.map(e=>(0,t.jsxs)("button",{type:"button",role:"option","aria-selected":d===e.id,onClick:()=>void T(e.id),children:[(0,t.jsx)(c,{size:17}),(0,t.jsxs)("span",{children:[(0,t.jsx)("strong",{children:e.name}),(0,t.jsx)("code",{children:e.id}),e.error&&(0,t.jsx)("small",{children:e.error})]}),(0,t.jsx)(ei,{size:14})]},e.id)),0===L.length&&(0,t.jsx)("div",{className:"heroes-empty",children:"No global Heroes"})]})]}),(0,t.jsxs)("section",{className:"global-hero-detail",children:[!h&&"loading"===v&&(0,t.jsxs)("div",{className:"heroes-detail-empty",children:[(0,t.jsx)(eQ,{className:"spin",size:18})," Loading Hero…"]}),!h&&"loading"!==v&&(0,t.jsxs)("div",{className:"heroes-detail-empty",children:[(0,t.jsx)(c,{size:26})," Select or create a Hero"]}),h&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("header",{className:"global-hero-commandbar",children:[(0,t.jsxs)("button",{type:"button",className:"global-hero-back",onClick:()=>{p(null),m(null)},children:[(0,t.jsx)(rZ,{size:17})," Heroes"]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("strong",{children:h.document.name}),(0,t.jsx)("code",{children:h.path})]}),(0,t.jsxs)("div",{className:"global-hero-command-actions",children:[N?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("span",{className:"hero-conflict-state",children:"File changed on disk"}),(0,t.jsx)("button",{type:"button",onClick:()=>void A(),children:"Diff"}),(0,t.jsx)("button",{type:"button",onClick:()=>void T(h.id),children:"Reload"})]}):(0,t.jsx)("span",{className:"saving"===v?"is-saving":"",children:"saving"===v?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(eQ,{className:"spin",size:14})," Saving"]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(Y,{size:14})," Saved"]})}),(0,t.jsx)("button",{type:"button",onClick:()=>void $(),disabled:!!v||N,children:"publishing"===v?"Publishing…":"Publish"})]})]}),(0,t.jsxs)("div",{className:"global-hero-form",children:[(0,t.jsxs)("section",{children:[(0,t.jsx)("h3",{children:"Identity"}),(0,t.jsxs)("div",{className:"global-hero-grid",children:[(0,t.jsxs)("label",{children:["Name",(0,t.jsx)("input",{value:h.document.name,onChange:e=>z(t=>({...t,name:e.target.value})),onBlur:()=>void E(h.document)})]}),(0,t.jsxs)("label",{children:["Handle",(0,t.jsx)("input",{value:h.document.handle,disabled:!0})]}),(0,t.jsxs)("label",{className:"wide",children:["Description",(0,t.jsx)("input",{value:h.document.description,onChange:e=>z(t=>({...t,description:e.target.value})),onBlur:()=>void E(h.document)})]})]})]}),(0,t.jsxs)("section",{children:[(0,t.jsx)("h3",{children:"Runtime"}),(0,t.jsxs)("div",{className:"global-hero-grid",children:[(0,t.jsxs)("label",{className:"wide",children:["Model",(0,t.jsx)("select",{value:h.document.model.ref,onChange:e=>F(t=>({...t,model:{...t.model,ref:e.target.value}})),children:r.map(e=>(0,t.jsxs)("option",{value:e.ref,children:[e.label," · ",e.ref]},e.ref))})]}),(0,t.jsxs)("label",{children:["Thinking",(0,t.jsx)("select",{value:h.document.model.thinkingEffort,onChange:e=>F(t=>({...t,model:{...t.model,thinkingEffort:e.target.value}})),children:["default","low","medium","high"].map(e=>(0,t.jsx)("option",{children:e},e))})]}),(0,t.jsxs)("label",{children:["Permission ceiling",(0,t.jsx)("select",{value:h.document.permissionCeiling,onChange:e=>F(t=>({...t,permissionCeiling:e.target.value})),children:dx.map(e=>(0,t.jsx)("option",{value:e,children:i(`permission.${e}`)},e))})]}),(0,t.jsxs)("label",{className:"wide",children:["Skills",(0,t.jsx)("input",{value:h.document.skills.map(e=>e.id).join(", "),onChange:e=>z(t=>({...t,skills:e.target.value.split(",").map(e=>e.trim()).filter(Boolean).map(e=>({id:e,mode:"available"}))})),onBlur:()=>void E(h.document),placeholder:"report-writing, code-review"})]})]})]}),(0,t.jsxs)("section",{children:[(0,t.jsx)("h3",{children:"Execution context"}),(0,t.jsxs)("div",{className:"global-hero-grid",children:[(0,t.jsxs)("label",{children:["Default mode",(0,t.jsx)("select",{"aria-label":"Default context mode",value:h.document.context.defaultMode,onChange:e=>F(t=>({...t,context:{...t.context,defaultMode:e.target.value}})),children:h.document.context.allowedModes.map(e=>(0,t.jsx)("option",{value:e,children:dg[e]},e))})]}),(0,t.jsxs)("div",{className:"global-hero-modes wide",children:[(0,t.jsx)("span",{children:"Allowed modes"}),(0,t.jsx)("div",{role:"group","aria-label":"Allowed context modes",children:df.map(e=>{let n=h.document.context.allowedModes.includes(e);return(0,t.jsxs)("label",{className:"global-hero-mode",children:[(0,t.jsx)("input",{type:"checkbox",checked:n,disabled:n&&1===h.document.context.allowedModes.length,onChange:t=>{var n;return n=t.target.checked,void F(t=>{let a=n?df.filter(n=>n===e||t.context.allowedModes.includes(n)):t.context.allowedModes.filter(t=>t!==e);if(0===a.length)return t;let s=a.includes(t.context.defaultMode)?t.context.defaultMode:a[0];return{...t,context:{...t.context,allowedModes:a,defaultMode:s}}})}}),dg[e]]},e)})}),(0,t.jsx)("p",{className:"global-hero-hint",children:"Task only is required for Heroes that run as delegated children. Reply enables addressing a specific message; Room shares the session lineage; Fresh starts from the addressed request."})]})]})]}),(0,t.jsxs)("section",{children:[(0,t.jsx)("h3",{children:"Hero prompt"}),(0,t.jsx)("label",{className:"global-hero-prompt",children:(0,t.jsx)("textarea",{"aria-label":"Hero prompt",value:h.document.prompt,onChange:e=>z(t=>({...t,prompt:e.target.value})),onBlur:()=>void E(h.document)})})]})]}),C&&(0,t.jsxs)("div",{className:"hero-conflict-dialog",role:"dialog","aria-modal":"true","aria-label":"Hero file diff",children:[(0,t.jsxs)("div",{children:[(0,t.jsxs)("header",{children:[(0,t.jsx)("strong",{children:"Local edits"}),(0,t.jsx)("button",{type:"button",onClick:()=>I(null),children:"Close"})]}),(0,t.jsx)("pre",{children:JSON.stringify(h.document,null,2)})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("header",{children:(0,t.jsx)("strong",{children:"File on disk"})}),(0,t.jsx)("pre",{children:JSON.stringify(C.document,null,2)})]})]})]})]})]})}function dy({graphId:e,models:a,onApplied:s,setError:i}){let[r,l]=(0,n.useState)(null),[o,d]=(0,n.useState)(""),[u,p]=(0,n.useState)(""),[h,m]=(0,n.useState)(null),f=(0,n.useCallback)(async()=>{m("loading");try{let t=await (0,e5.apiFetch)(`/v1/graphs/${encodeURIComponent(e)}/builder`);l(t),d(t.modelProfileId||a[0]?.model.id||"")}catch(e){i(e.message)}finally{m(null)}},[e,a,i]);(0,n.useEffect)(()=>{let e=window.setTimeout(()=>void f(),0);return()=>window.clearTimeout(e)},[f]);let g=async()=>{if(u.trim()&&o&&!h){m("sending");try{let t=await (0,e5.apiFetch)(`/v1/graphs/${encodeURIComponent(e)}/builder/messages`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({modelProfileId:o,instruction:u.trim()})});l(t),p(""),i(null)}catch(e){i(e.message)}finally{m(null)}}},x=async()=>{if(r?.proposal&&!(r.proposal.diagnostics.length>0)&&!h){m("applying");try{let t=await (0,e5.apiFetch)(`/v1/graphs/${encodeURIComponent(e)}/builder/proposals/${encodeURIComponent(r.proposal.id)}/apply`,{method:"POST"});s(t),await f(),i(null)}catch(e){i(e.message)}finally{m(null)}}};return(0,t.jsxs)("aside",{className:"graph-builder-pane",children:[(0,t.jsxs)("div",{className:"graph-section-heading",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("span",{children:"Builder"}),(0,t.jsx)("p",{children:"Persistent conversation for this Graph."})]}),(0,t.jsx)(c,{size:18})]}),(0,t.jsxs)("div",{className:"graph-builder-content",children:[(0,t.jsxs)("label",{className:"graph-builder-model",children:["Builder model",(0,t.jsx)("select",{value:o,onChange:e=>d(e.target.value),disabled:!!h,children:a.map(e=>(0,t.jsx)("option",{value:e.model.id,children:e.label},e.model.id))})]}),(0,t.jsxs)("div",{className:"graph-builder-messages","aria-live":"polite",children:["loading"===h&&(0,t.jsxs)("div",{className:"graph-builder-loading",children:[(0,t.jsx)(eQ,{className:"spin",size:16})," Loading conversation…"]}),r?.messages.map(e=>(0,t.jsxs)("div",{className:`graph-builder-message is-${e.role}`,children:[(0,t.jsx)("span",{children:"user"===e.role?"You":"Builder"}),(0,t.jsx)("p",{children:e.content})]},e.id)),!h&&(r?.messages.length??0)===0&&(0,t.jsxs)("div",{className:"graph-builder-intro",children:[(0,t.jsx)(c,{size:22}),(0,t.jsx)("p",{children:"Describe Tasks, execution choices, and dependencies. Builder will return a validated proposal."})]})]}),r?.proposal&&(0,t.jsxs)("div",{className:`graph-builder-proposal ${r.proposal.diagnostics.length?"is-invalid":""}`,children:[(0,t.jsxs)("header",{children:[r.proposal.diagnostics.length?(0,t.jsx)(cT,{size:15}):(0,t.jsx)(Y,{size:15}),(0,t.jsx)("strong",{children:"Proposal"}),(0,t.jsxs)("span",{children:[r.proposal.operations.length," changes"]})]}),(0,t.jsx)("p",{children:r.proposal.summary}),(0,t.jsx)("ul",{children:r.proposal.operations.map((e,n)=>(0,t.jsxs)("li",{children:[(0,t.jsx)("code",{children:e.kind}),e.taskId?` \xb7 ${e.taskId}`:""]},n))}),r.proposal.diagnostics.map(e=>(0,t.jsx)("div",{className:"graph-builder-diagnostic",children:e},e)),(0,t.jsx)("button",{type:"button",onClick:()=>void x(),disabled:r.proposal.diagnostics.length>0||!!h,children:"applying"===h?"Applying…":"Apply proposal"})]}),(0,t.jsxs)("div",{className:"graph-builder-composer",children:[(0,t.jsx)("textarea",{value:u,onChange:e=>p(e.target.value),"aria-label":"Graph Builder instruction",placeholder:"Describe the Graph change…",disabled:!!h||!o,onKeyDown:e=>{"Enter"===e.key&&(e.metaKey||e.ctrlKey)&&g()}}),(0,t.jsx)("button",{type:"button",onClick:()=>void g(),disabled:!u.trim()||!o||!!h,"aria-label":"Send Builder instruction",children:"sending"===h?(0,t.jsx)(eQ,{className:"spin",size:17}):(0,t.jsx)(i3,{size:17})})]})]})]})}function db(e){let t=new Set(Object.keys(e.tasks)),n=new Set,a=[];for(;t.size>0;){let s=[...t].filter(t=>(e.graph[t]??[]).every(e=>n.has(e))).sort();if(0===s.length)return[...a,[...t].sort()];a.push(s),s.forEach(e=>{t.delete(e),n.add(e)})}return a}function dk({document:e,busy:n,onOpenTask:a,onChange:s}){let i=Object.keys(e.tasks).sort();return 0===i.length?(0,t.jsx)("div",{className:"graph-empty-state",children:"Add a Task to start the Graph."}):(0,t.jsxs)("div",{className:"graph-dependency-editor",children:[(0,t.jsx)("div",{className:"graph-levels","aria-label":"Task dependency levels",children:db(e).map((n,s)=>(0,t.jsxs)("div",{className:"graph-level",children:[(0,t.jsxs)("span",{className:"graph-level-label",children:["Level ",s+1]}),(0,t.jsx)("div",{children:n.map(n=>(0,t.jsx)("button",{type:"button",onClick:()=>a(n),children:e.tasks[n].name},n))}),s<db(e).length-1&&(0,t.jsx)(j,{size:16,"aria-hidden":!0})]},s))}),(0,t.jsx)("div",{className:"graph-dependency-list",children:i.map(a=>{let r=new Set(e.graph[a]??[]);return(0,t.jsxs)("fieldset",{disabled:n,children:[(0,t.jsx)("legend",{children:e.tasks[a].name}),(0,t.jsxs)("div",{children:[i.filter(e=>e!==a).map(n=>(0,t.jsxs)("label",{children:[(0,t.jsx)("input",{type:"checkbox",checked:r.has(n),onChange:e=>{let t=new Set(r);e.target.checked?t.add(n):t.delete(n),s(a,[...t].sort())}}),e.tasks[n].name]},n)),1===i.length&&(0,t.jsx)("span",{children:"No other Tasks"})]})]},a)})})]})}function dj({graphs:e,selected:n,onSelect:a,onAdd:s}){return(0,t.jsxs)("div",{className:"graph-tabs-row",children:[(0,t.jsx)("div",{className:"graph-tabs",role:"tablist","aria-label":"Graphs",children:e.map(e=>(0,t.jsxs)("button",{type:"button",role:"tab","aria-selected":n===e.id,className:"graph-tab",onClick:()=>a(e.id),children:[(0,t.jsx)("span",{children:e.name}),e.error&&(0,t.jsx)("span",{title:e.error,"aria-label":e.error,role:"img",children:(0,t.jsx)(cT,{size:12,"aria-hidden":"true"})})]},e.id))}),(0,t.jsx)("button",{type:"button",className:"graph-add-tab",onClick:s,"aria-label":"Add Graph",title:"Add Graph",children:(0,t.jsx)(S,{size:18})})]})}function dw({id:e,task:n,expanded:a,busy:s,models:i,onToggle:r,onSave:l,onRemove:o}){let c=!!n.hero,d=i.find(e=>e.ref===n.model),u=d?.model.supportsThinking?d.model.supportedThinkingEfforts:["default"],p=(e,t)=>l({...n,[e]:t});return(0,t.jsxs)("section",{className:"graph-task","data-task-id":e,children:[(0,t.jsxs)("button",{type:"button",className:"graph-task-summary",onClick:r,"aria-expanded":a,children:[a?(0,t.jsx)(q,{size:17}):(0,t.jsx)(j,{size:17}),(0,t.jsxs)("span",{children:[(0,t.jsx)("strong",{children:n.name}),(0,t.jsx)("code",{children:e})]}),(0,t.jsxs)("small",{children:[c?n.hero:n.model,!c&&n.thinking&&"default"!==n.thinking?` \xb7 ${n.thinking}`:""]})]}),a&&(0,t.jsxs)("div",{className:"graph-task-form",children:[(0,t.jsxs)("label",{children:["Task name",(0,t.jsx)("input",{defaultValue:n.name,disabled:s,onBlur:e=>p("name",e.target.value)})]}),(0,t.jsxs)("div",{className:"graph-execution-mode",role:"group","aria-label":"Execution mode",children:[(0,t.jsx)("button",{type:"button","aria-pressed":!c,disabled:s||!i[0],onClick:()=>l({name:n.name,model:n.model||i[0]?.ref,thinking:"default",skills:[],goal:n.goal,writes:n.writes,budget:n.budget}),children:"Inline configuration"}),(0,t.jsx)("button",{type:"button","aria-pressed":c,disabled:s,onClick:()=>l({name:n.name,hero:n.hero||`local/${e}`,goal:n.goal,writes:n.writes,budget:n.budget}),children:"Use a Hero"})]}),c?(0,t.jsxs)("label",{children:["Hero",(0,t.jsx)("input",{defaultValue:n.hero,disabled:s,placeholder:"local/alignment or global/reviewer",onBlur:e=>p("hero",e.target.value)}),(0,t.jsx)("span",{children:"Local Heroes belong only to this Graph. Global Heroes are shared and read-only here."})]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("label",{children:["Model",(0,t.jsx)("select",{value:n.model??"",disabled:s,onChange:e=>p("model",e.target.value),children:i.map(e=>(0,t.jsxs)("option",{value:e.ref,children:[e.label," · ",e.ref]},e.ref))})]}),d?.model.supportsThinking&&(0,t.jsxs)("label",{children:["Thinking",(0,t.jsx)("select",{value:n.thinking??"default",disabled:s,onChange:e=>p("thinking",e.target.value),children:u.map(e=>(0,t.jsx)("option",{value:e,children:e},e))})]}),(0,t.jsxs)("label",{children:["Skills",(0,t.jsx)("input",{defaultValue:(n.skills??[]).join(", "),disabled:s,placeholder:"local/alignment, global/report-writing",onBlur:e=>p("skills",e.target.value.split(",").map(e=>e.trim()).filter(Boolean))}),(0,t.jsx)("span",{children:"Use explicit local/ or global/ references."})]})]}),(0,t.jsxs)("label",{className:"graph-task-goal",children:["Goal",(0,t.jsx)("textarea",{defaultValue:n.goal,disabled:s,onBlur:e=>p("goal",e.target.value)})]}),(0,t.jsxs)("details",{children:[(0,t.jsx)("summary",{children:"Advanced"}),(0,t.jsxs)("label",{children:["Writes",(0,t.jsx)("input",{defaultValue:(n.writes??[]).join(", "),disabled:s,onBlur:e=>p("writes",e.target.value.split(",").map(e=>e.trim()).filter(Boolean))})]})]}),(0,t.jsxs)("button",{type:"button",className:"graph-task-remove",onClick:o,disabled:s,children:[(0,t.jsx)(P,{size:15})," Remove Task"]})]})]})}function dN({setError:e}){let a=cK(),s=(0,n.useMemo)(()=>dm(a.models,a.providers),[a.models,a.providers]),[i,r]=(0,n.useState)([]),[l,o]=(0,n.useState)(null),[c,d]=(0,n.useState)(null),[u,p]=(0,n.useState)(null),[m,f]=(0,n.useState)(null),[g,x]=(0,n.useState)(0),[v,y]=(0,n.useState)(!1);M(v,()=>y(!1));let[b,k]=(0,n.useState)({id:"",name:""}),[j,w]=(0,n.useState)(!1),[N,_]=(0,n.useState)({id:"",name:""}),[C,I]=(0,n.useState)("tasks"),P=(0,n.useCallback)(async e=>{let t=await (0,e5.apiFetch)("/v1/graphs");r(t);let n=e??t.find(e=>!e.error)?.id??null;return o(n),n},[]),T=(0,n.useCallback)(async t=>{f("loading"),o(t),p(null);try{let[n,a]=await Promise.all([(0,e5.apiFetch)(`/v1/graphs/${encodeURIComponent(t)}`),(0,e5.apiFetch)(`/v1/graphs/${encodeURIComponent(t)}/versions`)]);d(n),x(a.reduce((e,t)=>Math.max(e,t.version),0)),e(null)}catch(t){d(null),e(t.message)}finally{f(null)}},[e]);(0,n.useEffect)(()=>{let t=!1,n=window.setTimeout(()=>{P().then(e=>{!t&&e&&T(e)}).catch(n=>{t||e(n.message)})},0);return()=>{t=!0,window.clearTimeout(n)}},[T,P,e]);let R=async()=>{if(b.id.trim()&&b.name.trim()){f("creating");try{let t=await (0,e5.apiFetch)("/v1/graphs",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:b.id.trim(),name:b.name.trim()})});y(!1),k({id:"",name:""}),d(t),x(0),o(t.id),await P(t.id),e(null)}catch(t){e(t.message)}finally{f(null)}}},E=async t=>{if(c&&!m){f("saving");try{let n=await (0,e5.apiFetch)(`/v1/graphs/${encodeURIComponent(c.id)}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({expectedDigest:c.digest,...t})});d(n),r(e=>e.map(e=>e.id===n.id?{...e,name:n.name,digest:n.digest,error:void 0}:e)),e(null)}catch(t){e(t.message)}finally{f(null)}}},A=async()=>{if(c&&!m){f("publishing");try{let t=await (0,e5.apiFetch)(`/v1/graphs/${encodeURIComponent(c.id)}/publish`,{method:"POST"});x(t.version),e(null)}catch(t){e(t.message)}finally{f(null)}}},$=async e=>{await rc({title:`Remove Task “${c?.document.tasks[e]?.name??e}”?`,description:"This removes the task from the graph draft. Published versions are unaffected.",confirmLabel:"Remove task",tone:"danger"})&&await E({task:{id:e,value:null}})},z=async()=>{let t=s[0];if(!t)return void e("Create an active model before adding an inline Task.");let n=N.id.trim(),a=N.name.trim();n&&a&&(await E({task:{id:n,value:{name:a,model:t.ref,thinking:"default",skills:[],goal:"Describe the outcome this Task must produce."}}}),_({id:"",name:""}),w(!1),p(n))};return(0,t.jsxs)("div",{className:"graph-workspace",children:[(0,t.jsx)(dj,{graphs:i,selected:l,onSelect:e=>void T(e),onAdd:()=>y(!0)}),v&&(0,t.jsxs)("div",{className:"graph-create-strip",role:"dialog","aria-label":"Add Graph",children:[(0,t.jsxs)("label",{children:["ID",(0,t.jsx)("input",{autoFocus:!0,value:b.id,onChange:e=>k(t=>({...t,id:e.target.value})),placeholder:"rna-seq"})]}),(0,t.jsxs)("label",{children:["Name",(0,t.jsx)("input",{value:b.name,onChange:e=>k(t=>({...t,name:e.target.value})),placeholder:"RNA-seq"})]}),(0,t.jsx)("button",{type:"button",onClick:()=>void R(),disabled:"creating"===m,children:"creating"===m?"Creating…":"Create Graph"}),(0,t.jsx)("button",{type:"button",onClick:()=>y(!1),children:"Cancel"})]}),(0,t.jsx)("div",{className:"graph-mobile-segments",role:"tablist","aria-label":"Graph views",children:["tasks","graph","build"].map(e=>(0,t.jsx)("button",{type:"button",role:"tab","aria-selected":C===e,onClick:()=>I(e),children:e},e))}),!c&&"loading"===m&&(0,t.jsxs)("div",{className:"graph-loading",children:[(0,t.jsx)(eQ,{className:"spin",size:18})," Loading Graph…"]}),!c&&"loading"!==m&&0===i.length&&(0,t.jsxs)("div",{className:"graph-welcome",children:[(0,t.jsx)(h,{size:28}),(0,t.jsx)("h2",{children:"Create your first Graph"}),(0,t.jsx)("p",{children:"Compose reusable Tasks and their dependencies without choosing a Project."}),(0,t.jsxs)("button",{type:"button",onClick:()=>y(!0),children:[(0,t.jsx)(S,{size:16})," Add Graph"]})]}),c&&(0,t.jsxs)("div",{className:"graph-document",children:[(0,t.jsxs)("header",{className:"graph-document-header",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("span",{children:"Graph"}),(0,t.jsx)("h2",{children:c.document.name}),(0,t.jsx)("code",{children:c.document.id})]}),(0,t.jsxs)("div",{className:"graph-document-actions",children:[(0,t.jsxs)("span",{children:["v",g||"draft"]}),(0,t.jsx)("div",{className:`graph-save-state ${"saving"===m?"is-saving":""}`,children:"saving"===m?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(eQ,{className:"spin",size:14})," Saving"]}):g>0?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(Y,{size:14})," Saved v",g]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(Y,{size:14})," Draft saved"]})}),(0,t.jsx)("button",{type:"button",onClick:()=>void A(),disabled:!!m||0===Object.keys(c.document.tasks).length,children:"publishing"===m?"Publishing…":"Publish"})]})]}),(0,t.jsxs)("main",{className:`graph-editor-view is-${C}`,children:[(0,t.jsxs)("section",{className:"graph-tasks-pane",children:[(0,t.jsxs)("div",{className:"graph-section-heading",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("span",{children:"Tasks"}),(0,t.jsx)("p",{children:"Execution configuration. Tasks are collapsed by default."})]}),(0,t.jsxs)("button",{type:"button",onClick:()=>w(e=>!e),children:[(0,t.jsx)(S,{size:16})," Add Task"]})]}),j&&(0,t.jsxs)("div",{className:"graph-add-task",children:[(0,t.jsx)("input",{value:N.id,onChange:e=>_(t=>({...t,id:e.target.value})),placeholder:"task_id"}),(0,t.jsx)("input",{value:N.name,onChange:e=>_(t=>({...t,name:e.target.value})),placeholder:"Task name"}),(0,t.jsx)("button",{type:"button",onClick:()=>void z(),children:"Add"})]}),(0,t.jsxs)("div",{className:"graph-task-list",children:[Object.keys(c.document.tasks).sort().map(e=>(0,t.jsx)(dw,{id:e,task:c.document.tasks[e],expanded:u===e,busy:!!m,models:s,onToggle:()=>p(t=>t===e?null:e),onSave:t=>{E({task:{id:e,value:t}})},onRemove:()=>void $(e)},e)),0===Object.keys(c.document.tasks).length&&(0,t.jsx)("div",{className:"graph-empty-state",children:"No Tasks yet. Add one or ask Builder to draft the Graph."})]})]}),(0,t.jsxs)("section",{className:"graph-dependencies-pane",children:[(0,t.jsx)("div",{className:"graph-section-heading",children:(0,t.jsxs)("div",{children:[(0,t.jsx)("span",{children:"Graph"}),(0,t.jsx)("p",{children:"Dependency orchestration. Hero details stay inside Tasks."})]})}),(0,t.jsx)(dk,{document:c.document,busy:!!m,onOpenTask:e=>{p(e),I("tasks"),requestAnimationFrame(()=>document.querySelector(`[data-task-id="${CSS.escape(e)}"]`)?.scrollIntoView({behavior:"smooth",block:"start"}))},onChange:(e,t)=>void E({dependencies:{taskId:e,depends:t}})})]}),(0,t.jsx)(dy,{graphId:c.id,models:s,setError:e,onApplied:e=>{d(e),r(t=>t.map(t=>t.id===e.id?{...t,name:e.name,digest:e.digest,error:void 0}:t))}})]})]})]})}function d_({view:e,models:a,providers:s,onBackToChat:i,onOpenMobileNav:r,menuTriggerRef:l}){let[o,c]=(0,n.useState)(null);return(0,t.jsxs)("div",{className:"settings-view","data-testid":"heroes"===e?"heroes-page":"graphs-page",children:[(0,t.jsx)("button",{ref:l,type:"button",className:"workspace-mobile-menu",onClick:r,"aria-label":"Open navigation",children:(0,t.jsx)(rR,{size:20})}),(0,t.jsxs)("header",{className:"workspace-page-header",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("h1",{children:"heroes"===e?"Heroes":"Graphs"}),(0,t.jsx)("p",{children:"heroes"===e?"Global reusable execution presets for Chat and Graph Tasks.":"Global Task graphs. Every published Graph can run in any Session."})]}),(0,t.jsxs)("button",{type:"button",className:"settings-view-back",onClick:i,children:[(0,t.jsx)(rZ,{size:15})," Chat"]})]}),o&&(0,t.jsxs)("div",{className:"error-bar workspace-page-error",role:"alert",children:[(0,t.jsx)("span",{children:o}),(0,t.jsx)("button",{type:"button",onClick:()=>c(null),"aria-label":"Dismiss error",children:(0,t.jsx)(m,{size:16})})]}),(0,t.jsx)("div",{className:"workspace-page-body",children:"heroes"===e?(0,t.jsx)(dv,{models:a,providers:s,setError:c}):(0,t.jsx)(dN,{setError:c})})]})}var dC=e.i(51761);function dS(e){let t=(0,e5.subscribeWorkerReachability)(e),n=()=>{(0,e5.probeWorkerReachability)().catch(()=>{})};return window.addEventListener("online",n),window.addEventListener("offline",n),()=>{t(),window.removeEventListener("online",n),window.removeEventListener("offline",n)}}function dI(){return"unreachable"===(0,e5.getWorkerReachability)()}function dP(){return!1}e.s(["AppShell",0,function({initialView:e="chat"}){let a=lI("(max-width: 640px)"),{projects:s,projectsReady:i,selectedProject:r,switchProject:l,openCreateProject:o,settingsOpen:c,settingsTab:d,openSettings:u,closeSettings:p,workspaceFor:h,togglePinProject:m,pinnedProjectIds:g,renameProject:x,deleteProject:v}=(0,cD.useWorkspace)(),[y,b]=(0,n.useState)(null),k=(0,n.useRef)(null),[j,w]=(0,n.useState)(e??"chat"),N=(0,n.useCallback)(e=>{w(e),window.history.replaceState(null,"","chat"===e?"/":`/?view=${e}`)},[]);(0,n.useEffect)(()=>{let e=()=>{let e=new URLSearchParams(window.location.search).get("view");("heroes"===e||"graphs"===e||"chat"===e)&&w(e)};return e(),window.addEventListener("popstate",e),()=>window.removeEventListener("popstate",e)},[]);let _=(0,n.useCallback)(e=>{k.current=e,b(e),(0,dC.writeStoredId)(dC.SELECTED_SESSION_KEY,e)},[]),C=cU({initialWidth:280,minWidth:264,maxWidth:420,storageKey:"--ennote-sidebar-width",cssVariable:"--ennote-sidebar-width"}),S=rP(),[I,P]=(0,n.useState)(!0),T=function(e){let[t,a]=(0,n.useState)(()=>window.innerWidth);(0,n.useEffect)(()=>{let e=()=>a(window.innerWidth);return window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]);let s=lP(t,e);return{...cU({initialWidth:680,minWidth:280,maxWidth:s,storageKey:"ennote-right-panel-width",direction:"left",resolveStored:(0,n.useCallback)(n=>{let a;return a=lP(t,e),null!==n&&Number.isFinite(n)?Math.max(280,Math.min(a,n)):Math.min(680,a)},[t,e])}),maxWidth:s}}(I&&!a?C.width:0),[E,A]=(0,n.useState)(null),$=(0,n.useRef)(null),z=(0,n.useRef)(null),F=(0,n.useCallback)(()=>{P(!1),window.requestAnimationFrame(()=>{($.current??z.current)?.focus()})},[]);(0,n.useEffect)(()=>{if(!a)return;let e=window.requestAnimationFrame(()=>P(!1));return()=>window.cancelAnimationFrame(e)},[a]),M(a&&I,F),(0,n.useEffect)(()=>{if(!a||!I)return;let e=document.querySelector(".sidebar-container");if(!e)return;let t=t=>{if("Tab"!==t.key)return;let n=Array.from(e.querySelectorAll('button:not(:disabled), input:not(:disabled), select:not(:disabled), [href], [tabindex]:not([tabindex="-1"])')).filter(e=>e.getClientRects().length>0);if(!n.length)return;let a=n[0],s=n[n.length-1];t.shiftKey&&document.activeElement===a?(t.preventDefault(),s.focus()):t.shiftKey||document.activeElement!==s||(t.preventDefault(),a.focus())};return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t)},[F,a,I]);let L=function(e){let[t,a]=(0,n.useState)([]),[s,i]=(0,n.useState)([]),[r,l]=(0,n.useState)("active"),[o,c]=(0,n.useState)(""),[d,u]=(0,n.useState)(!1),[p,h]=(0,n.useState)(null),[m,f]=(0,n.useState)(null),[g,x]=(0,n.useState)(null),[v,y]=(0,n.useState)(""),b=(0,n.useRef)(0),k=(0,n.useRef)(null),j=(0,n.useRef)(r),w=(0,n.useCallback)(e=>{j.current=e,l(e)},[]),N=(0,n.useCallback)(async(t=0)=>{if(k.current?.abort(),!e){a([]),i([]),h(null),u(!1);return}let n=new AbortController;k.current=n;let s=++b.current;if(t>0&&await new Promise(e=>setTimeout(e,t)),n.signal.aborted||b.current!==s)return;u(!0);let l=`/v1/projects/${encodeURIComponent(e)}/sessions`,c=new URLSearchParams({status:r}),d=o.trim(),p=`${e}:${r}:${d}`;d&&c.set("q",d);try{let e=(0,e5.apiFetch)(`${l}?status=active`,{signal:n.signal}),t="active"!==r||d?(0,e5.apiFetch)(`${l}?${c.toString()}`,{signal:n.signal}):e,[o,u]=await Promise.all([e,t]);if(n.signal.aborted||b.current!==s)return;a(o??[]),i(u??[]),h(p),x(null)}catch(e){n.signal.aborted||b.current!==s||(h(p),x(e.message))}finally{n.signal.aborted||b.current!==s||u(!1)}},[e,o,r]);(0,n.useEffect)(()=>{let e=window.setTimeout(()=>void N(0),200);return()=>{window.clearTimeout(e),k.current?.abort()}},[N]);let _=(0,n.useCallback)(()=>N(0),[N]),C=(0,n.useCallback)(e=>{a(t=>"active"===e.status?t.some(t=>t.id===e.id)?t.map(t=>t.id===e.id?e:t):[e,...t]:t.filter(t=>t.id!==e.id)),i(t=>t.map(t=>t.id===e.id?e:t).filter(e=>e.status===j.current))},[]),S=(0,n.useCallback)(async(e,t)=>{f(e.id);try{return await (0,e5.apiFetch)(`/v1/sessions/${encodeURIComponent(e.id)}/${t}`,{method:"POST",body:"{}"}),y(`${"archive"===t?"Archived":"Restored"} ${e.title}`),x(null),await _(),!0}catch(e){return x(e.message),!1}finally{f(null)}},[_]),I=e?`${e}:${r}:${o.trim()}`:null;return{activeSessions:t,visibleSessions:s,view:r,setView:w,query:o,setQuery:c,loading:d||null!==I&&p!==I,mutatingId:m,error:g,setError:x,announcement:v,refresh:_,replaceSession:C,archive:e=>S(e,"archive"),restore:e=>S(e,"restore")}}(r),D=function(e,t,a){let[s,i]=(0,n.useState)({}),[r,l]=(0,n.useState)({}),[o,c]=(0,n.useState)(cW),d=(0,n.useRef)(0),u=(0,n.useMemo)(()=>{let e=[],n=t=>{t&&!e.includes(t)&&e.push(t)};for(let e of(n(a),t))n(e);return e},[a,t]),p=(0,n.useCallback)(async t=>{let n=++d.current,a=e.find(e=>e.id===t),s=a?.name??t;i(e=>({...e,[t]:{projectId:t,projectName:s,sessions:[],loading:!0,error:null}}));try{let e=await (0,e5.apiFetch)(`/v1/projects/${encodeURIComponent(t)}/sessions?status=active`)??[];if(d.current!==n)return;i(n=>({...n,[t]:{projectId:t,projectName:s,sessions:e,loading:!1,error:null}}))}catch(e){if(d.current!==n)return;i(n=>({...n,[t]:{projectId:t,projectName:s,sessions:[],loading:!1,error:e.message}}))}},[e]);(0,n.useEffect)(()=>{for(let e of u)s[e]||p(e)},[u,s,p]),(0,n.useEffect)(()=>{a&&p(a)},[a,p]),(0,n.useEffect)(()=>{let e=window.setInterval(()=>{for(let e of u)p(e)},3e4);return()=>window.clearInterval(e)},[u,p]);let h=(0,n.useCallback)(e=>void p(e),[p]),m=(0,n.useCallback)(()=>{for(let e of u)p(e)},[u,p]),f=(0,n.useCallback)(async e=>{if(!r[e])try{let t=await (0,e5.apiFetch)(`/v1/projects/${encodeURIComponent(e)}/sessions?status=archived`)??[];l(n=>({...n,[e]:t}))}catch{l(t=>({...t,[e]:[]}))}},[r]),g=(0,n.useCallback)(async e=>{try{let t=await (0,e5.apiFetch)(`/v1/projects/${encodeURIComponent(e)}/sessions?status=archived`)??[];l(n=>({...n,[e]:t}))}catch{l(t=>({...t,[e]:[]}))}},[]),x=(0,n.useCallback)(e=>{c(t=>{let n=new Set(t);n.has(e)?n.delete(e):n.add(e);try{window.localStorage.setItem(cH,JSON.stringify([...n]))}catch{}return n})},[]);return{groups:(0,n.useMemo)(()=>u.map(e=>s[e]).filter(e=>!!e),[u,s]),archived:r,collapsed:o,toggleCollapsed:x,refresh:h,refreshAll:m,openArchived:f,refreshArchived:g}}(s,g,r),O=cK(),q=L.replaceSession,B=L.activeSessions.find(e=>e.id===y),U=function(e){let[t,a]=(0,n.useState)({templates:[],diagnostics:[],loading:!1,error:null}),s=(0,n.useRef)(null),i=(0,n.useCallback)(async()=>{if(!e)return void a({templates:[],diagnostics:[],loading:!1,error:null});s.current?.abort();let t=new AbortController;s.current=t,a(e=>({...e,loading:!0,error:null}));try{let n=await (0,e5.apiFetch)(`/v1/projects/${encodeURIComponent(e)}/prompt-templates`,{signal:t.signal});if(t.signal.aborted)return;a({templates:n.templates,diagnostics:n.diagnostics,loading:!1,error:null})}catch(e){if(t.signal.aborted)return;a(t=>({...t,loading:!1,error:e.message??"Failed to load prompt templates"}))}},[e]);return(0,n.useEffect)(()=>{e&&i()},[i,e]),(0,n.useEffect)(()=>()=>{s.current?.abort()},[]),{...t,refresh:i}}(r),H=function(e){var t;let a,s,i,r,l,o,{selectedSession:c,sessionRecord:d,selectedProject:u,promptCatalog:p,settings:h,replaceSession:m}=e,g=(0,n.useMemo)(()=>new Map(h.models.map(e=>[e.id,e.displayName||e.modelName])),[h.models]),x=(0,n.useCallback)((e,t)=>(e?g.get(e):void 0)??t,[g]),v=d?.activeBranchId,y=d?.activeLeafMessageId,b=(0,n.useCallback)(e=>m(e),[m]),k=(0,n.useCallback)(async()=>{if(!c)return null;let e=await (0,e5.apiFetch)(`/v1/sessions/${encodeURIComponent(c)}`);return m(e),e},[m,c]),j=(t={resolveModel:x},a=t?.resolveModel,s=c?de.getStore(c):null,i=(0,n.useSyncExternalStore)(s?s.subscribe:dn,s?s.getSnapshot:()=>dt,s?s.getServerSnapshot:()=>dt),(0,n.useEffect)(()=>{if(s)return s.ensureLoaded(v),()=>s.pauseStream()},[s,v]),r=!!c&&i.loaded&&i.dataBranchId===v,l=function(e,t){let[a,s]=(0,n.useState)(new Map);return(0,n.useEffect)(()=>{if(!e)return void s(new Map);let t=!1;return(0,e5.apiFetch)(`/v1/sessions/${encodeURIComponent(e)}/turn-metrics`).then(e=>{t||s(new Map(e.map(e=>[e.runId,e])))}).catch(()=>{}),()=>{t=!0}},[e,t]),a}(c,i.activeRun?.id??null),o=(0,n.useMemo)(()=>r?function(e,t,n,a){let s=[],i=null,r=0,l=new Map,o=()=>{i&&(i.runId&&(i.metrics=n?.get(i.runId)),(i.user||i.steps.length>0)&&s.push(i),i=null,l.clear())};for(let n of function(e,t){let n=e.filter(e=>"private"!==e.visibility&&"room_control"!==e.visibility),a=new Set(n.map(e=>e.id)),s=[...new Map(t.filter(e=>"completed"===e.status).map(e=>[e.id,e])).values()].sort((e,t)=>e.createdAt.localeCompare(t.createdAt)),i=new Map,r=new Map;for(let e of s)e.firstKeptMessageId&&a.has(e.firstKeptMessageId)?c3(i,e.firstKeptMessageId,e):e.sourceThroughMessageId&&a.has(e.sourceThroughMessageId)&&c3(r,e.sourceThroughMessageId,e);return n.flatMap(e=>[...(i.get(e.id)??[]).map(e=>({kind:"checkpoint",value:e})),{kind:"message",value:e},...(r.get(e.id)??[]).map(e=>({kind:"checkpoint",value:e}))])}(e,t)){if("checkpoint"===n.kind){var c;o(),s.push((c=n.value,{kind:"checkpoint",id:`compaction-${c.id}`,reason:c.reason,summary:c.summary,reclaimedTokens:c.reclaimedTokens,createdAt:c.createdAt,promptVersion:c.promptVersion,summaryContractDigest:c.summaryContractDigest}));continue}!function(e){if("user"===e.role){o(),i={kind:"turn",id:`turn-${e.id}`,user:{id:e.id,sourceMessageId:e.id,text:e.parts.map(e=>"text"===e.type?e.text:"image"===e.type?`[Image \xb7 ${e.image.width}\xd7${e.image.height}]`:"image_description"===e.type?e.imageDescription.text:"").filter(Boolean).join("\n\n"),createdAt:e.createdAt},steps:[],messageIds:[e.id]};return}let t=(i||(r+=1,i={kind:"turn",id:`turn-orphan-${r}`,steps:[],messageIds:[]}),i);t.messageIds.push(e.id),e.runId&&(t.runId=t.runId??e.runId),"assistant"===e.role?function(e,t){let n=[],s=[],i=()=>{if(0===n.length)return;let s={...t.speakerSnapshot,modelProfileId:t.modelProfileId,apiModel:t.apiModel};if(a){let e=a(t.modelProfileId,t.apiModel);e&&(s.modelName=e)}e.steps.push({kind:"assistant",id:`${t.id}-assistant-${e.steps.length}`,sourceMessageId:t.id,blocks:n,speaker:s,createdAt:t.createdAt}),n=[]},r=()=>{0!==s.length&&(c5(e,s,l),s=[])};for(let e of t.parts)if("tool_call"===e.type){i();let n={id:`${t.id}-${e.toolCall.id}`,toolCallId:e.toolCall.id,toolName:e.toolCall.name,arguments:e.toolCall.arguments,argumentsFragment:e.toolCall.argumentsFragment,state:e.toolCall.partial?"interrupted":"pending",riskClass:iJ(e.toolCall.name),sourceMessageIds:[t.id],runId:t.runId};s.push(n),l.set(n.toolCallId,n)}else{var o;r();let t="text"===(o=e).type?{kind:"text",text:o.text}:"thinking"===o.type?{kind:"thinking",text:o.text}:"image"===o.type?{kind:"image",artifactId:o.image.artifactId,mimeType:o.image.mimeType,width:o.image.width,height:o.image.height}:"image_description"===o.type?{kind:"image_description",artifactId:o.imageDescription.artifactId,text:o.imageDescription.text}:null;t&&n.push(t)}i(),r()}(t,e):"tool"===e.role&&function(e,t){let n=[];for(let e of t.parts){if("tool_result"!==e.type)continue;let a=l.get(e.toolResult.toolCallId);if(a)a.result={content:e.toolResult.content,isError:e.toolResult.isError,artifacts:e.toolResult.artifacts??[]},a.state=c6(e.toolResult.content,e.toolResult.isError),a.sourceMessageIds.push(t.id);else{let a={id:`${t.id}-${e.toolResult.toolCallId}`,toolCallId:e.toolResult.toolCallId,toolName:e.toolResult.toolName,result:{content:e.toolResult.content,isError:e.toolResult.isError,artifacts:e.toolResult.artifacts??[]},state:c6(e.toolResult.content,e.toolResult.isError),riskClass:iJ(e.toolResult.toolName),sourceMessageIds:[t.id],runId:t.runId};l.set(a.toolCallId,a),n.push(a)}}n.length>0&&c5(e,n,l)}(t,e)}(n.value)}return{nodes:s,openTurn:i,calls:l,syntheticTurn:r}}(i.canonical,i.checkpoints,l,a):dc,[r,i.canonical,i.checkpoints,l,a]),{messages:(0,n.useMemo)(()=>(function(e,t,n,a,s){if(0===t.length){let t=function(e,t){if(!e)return null;let n={...e};return(n.runId&&(n.metrics=t?.get(n.runId)),n.user||0!==n.steps.length)?n:null}(e.openTurn,n);return t?[...e.nodes,t]:e.nodes}let i=[...e.nodes],r=new Map(e.calls),l=e.syntheticTurn,o=e.openTurn,c=null!==o,d=()=>{if(!o)return;let e=c?{...o}:o;e.runId&&(e.metrics=n?.get(e.runId)),(e.user||e.steps.length>0)&&i.push(e),o=null,c=!1,r.clear()};for(let e of t)!function(e){if("user"===e.role&&"steer"!==e.kind){d(),o={kind:"turn",id:`turn-${e.id}`,user:{id:e.id,text:e.text,sourceMessageId:e.sourceMessageId,createdAt:e.createdAt},steps:[],messageIds:[e.sourceMessageId??e.id]},c=!1;return}let t=(()=>{if(null===o)return l+=1,o={kind:"turn",id:`turn-orphan-${l}`,steps:[],messageIds:[]},c=!1,o;if(c){var e;for(let t of(o={...e=o,messageIds:[...e.messageIds],steps:e.steps.map(e=>"tool_batch"===e.kind?{...e,activities:e.activities.map(e=>({...e,sourceMessageIds:[...e.sourceMessageIds],result:e.result?{...e.result}:void 0}))}:e)},r.clear(),o.steps))if("tool_batch"===t.kind)for(let e of t.activities)r.set(e.toolCallId,e);c=!1}return o})();if(t.messageIds.push(e.sourceMessageId??e.id),e.runId&&(t.runId=t.runId??e.runId),"user"===e.role&&"steer"===e.kind)return t.steps.push({kind:"steer",id:e.id,text:e.text.replace(/^↪\s*/,""),createdAt:e.createdAt});if("assistant"===e.role){let n=[];e.thinking&&n.push({kind:"thinking",text:e.thinking}),e.text&&n.push({kind:"text",text:e.text}),n.length>0&&t.steps.push({kind:"assistant",id:e.id,sourceMessageId:e.sourceMessageId,blocks:n,speaker:function(e,t){if(!e)return;let n=e.effectiveConfig??{},a=e.requestedConfig??{},s="string"==typeof n.modelProfileId&&n.modelProfileId?n.modelProfileId:"string"==typeof a.modelProfileId?a.modelProfileId:void 0,i="string"==typeof n.apiModel&&n.apiModel?n.apiModel:"string"==typeof a.apiModel?a.apiModel:void 0,r=t?t(s,i):void 0;return{...e.speakerSnapshot,modelProfileId:s,apiModel:i,modelName:r}}(s,a),createdAt:e.createdAt});return}if("tool"===e.role){let n=e.toolCallId??e.id,a=r.get(n);if(a){e.arguments&&(a.arguments=e.arguments),e.runId&&(a.runId=e.runId),e.toolName&&a.toolName!==e.toolName&&(a.toolName=e.toolName,a.riskClass=iJ(e.toolName)),a.result="running"===e.toolState?a.result:{content:e.text,isError:!!e.isError,artifacts:[]},a.state=e.toolState??c6(e.text,!!e.isError),a.sourceMessageIds.push(e.sourceMessageId??e.id);return}c5(t,[{id:e.id,toolCallId:n,toolName:e.toolName??"tool",arguments:e.arguments,argumentsFragment:e.argumentsFragment,result:"running"===e.toolState?void 0:{content:e.text,isError:!!e.isError,artifacts:[]},state:e.toolState??c6(e.text,!!e.isError),riskClass:iJ(e.toolName??"tool"),sourceMessageIds:[e.sourceMessageId??e.id],runId:e.runId}],r)}}(e);return d(),i})(o,i.transient,l,a,i.activeRun),[o,i.transient,l,a,i.activeRun]),loading:!!c&&!r&&!i.error||i.loading,loadingOlder:i.loadingOlder,historyError:i.error,hasMore:i.hasMore,loadOlder:s?s.loadOlder:da,refreshLatest:s?s.refreshLatest:ds,appendTransient:s?s.appendTransient:di,upsertTransient:s?s.upsertTransient:dr,removeTransient:s?s.removeTransient:dl,activeRun:i.activeRun,pendingApproval:i.pendingApproval,queuedInputs:i.queuedInputs,delegationActive:i.delegationActive,lastSeq:i.lastSeq,workerInstanceId:i.workerInstanceId,streamOpen:i.streamOpen}),w=function({sessionId:e,lineageId:t,appendMessage:a,upsertMessage:s,refreshLatest:i,refreshSession:r,activeRun:l,pendingApproval:o,queuedInputs:c}){let d=(0,f.useT)(),[u,p]=(0,n.useState)(null),[h,m]=(0,n.useState)(!1),[g,x]=(0,n.useState)(""),[v,y]=(0,n.useState)(null),[b,k]=(0,n.useState)(null),[j,w]=(0,n.useState)(null),N=(0,n.useRef)(null),_=(0,n.useRef)(null),C=(0,n.useRef)(0),S=(0,n.useRef)(0),I=(0,n.useRef)(e),P=(0,n.useRef)(!1),T=(0,n.useRef)(null),M=(0,n.useRef)(new Map),R=(0,n.useRef)(new Map),[E,A]=(0,n.useState)(0),{rows:$,queue:z,settle:F,reset:L}=function(e){let[t,a]=(0,n.useReducer)(cX,cZ),s=(0,n.useCallback)(e=>a({type:"queue",row:e}),[]),i=(0,n.useCallback)(e=>a({type:"settle",id:e}),[]),r=(0,n.useCallback)(()=>a({type:"reset"}),[]);return{rows:(0,n.useMemo)(()=>(function(e,t,n){let a=[],s=new Set;for(let t of e)"follow_up"!==t.kind||n.has(t.id)||s.has(t.id)||(s.add(t.id),a.push({id:t.id,text:t.text}));for(let e of t)n.has(e.id)||s.has(e.id)||(s.add(e.id),a.push(e));return a})(e,t.optimistic,t.settled),[e,t.optimistic,t.settled]),queue:s,settle:i,reset:r}}(c);(0,n.useEffect)(()=>{I.current=e},[e]);let D=(0,n.useCallback)(async(e,t,n)=>{let a=I.current;if(!a||e.sessionId!==a)return;T.current=e.id,P.current=!0,x(o?i_("question"===o.kind?"waiting_answer":"waiting_approval"):"context_compaction"===e.runKind?i_("compaction_queued"):"waiting_children"===e.status?i_("waiting_children"):"waiting_delegation_admission"===e.status?i_("waiting_delegation_admission"):i_("running")),y(null);let l=!1;try{if("context_compaction"===e.runKind)l=await c2(e.id,x,t);else{let a=M.current.get(e.id)??{assistants:new Map,toolDeltas:new Map,toolOutputs:new Map,usageByIteration:new Map,finishedTools:new Set};M.current.set(e.id,a);let i=R.current.get(e.id)??{value:void 0};R.current.set(e.id,i),l=await c4(e.id,s,x,y,k,t,{requested:()=>{},resolved:()=>{},delegated:()=>{},followUpConsumed:e=>{C.current===n&&F(e)},inputCancelled:e=>{C.current===n&&F(e)}},a,i)}}catch(e){l=e instanceof c1,t.aborted||C.current!==n||w(e.message)}finally{C.current===n&&(P.current=!1),l||t.aborted||C.current!==n||x(i_(iw)),l&&(M.current.delete(e.id),R.current.delete(e.id)),l&&!t.aborted&&C.current===n&&I.current===a&&(L(),N.current=null,await r().catch(()=>null),await i(),window.setTimeout(()=>{C.current===n&&I.current===a&&x("")},1600))}},[i,r,s,o,L,F]),O=(0,n.useCallback)(e=>{let t=I.current;if(!t||e.sessionId!==t)return;let n=++C.current;N.current?.abort();let a=new AbortController;N.current=a,D(e,a.signal,n)},[D]),q=(0,n.useCallback)(()=>{p(null),x(""),y(null),k(null),w(null),L()},[L]);(0,n.useEffect)(()=>{C.current+=1,N.current?.abort(),_.current?.abort(),T.current=null,M.current.clear(),R.current.clear(),q()},[t,e,q]),(0,n.useEffect)(()=>{if(!e||l?.id)return;let t=!1;return(0,e5.apiFetch)(`/v1/sessions/${encodeURIComponent(e)}/context-usage`).then(e=>{t||k(e)}).catch(()=>{}),()=>{t=!0}},[e,l?.id]),(0,n.useEffect)(()=>{l?l.id!==T.current&&O(l):T.current&&(N.current?.abort(),M.current.delete(T.current),R.current.delete(T.current),T.current=null,q())},[l,O,q]);let B=l?.id??null;(0,n.useEffect)(()=>{if(iC(g).code!==iw||!B)return;let e=window.setTimeout(()=>A(e=>e+1),1e3);return()=>window.clearTimeout(e)},[g,B]);let U=(0,n.useRef)(l);(0,n.useEffect)(()=>{U.current=l},[l]),(0,n.useEffect)(()=>{if(0===E)return;let e=U.current;e&&(T.current=null,O(e))},[E,O]);let H=(0,n.useCallback)(async()=>{if(l)try{await (0,e5.apiFetch)(`/v1/runs/${encodeURIComponent(l.id)}/cancel`,{method:"POST"}),N.current?.abort(),C.current+=1,x(i_("cancelled")),await r().catch(()=>null),await i()}catch(e){w(e.message)}},[l,i,r]),W=(0,n.useCallback)(async e=>{if(!l||!e.trim())return!1;if(o?.kind==="question")return w(d("run.status.answerQuestionFirst")),!1;try{return x(i_("steering")),await (0,e5.apiFetch)(`/v1/runs/${encodeURIComponent(l.id)}/inputs`,{method:"POST",body:JSON.stringify({kind:"steer",text:e,clientRequestId:c0()})}),a({id:c0(),role:"user",text:`↪ ${e}`,kind:"steer"}),x("waiting_for_approval"===l.status?i_("waiting_approval"):""),!0}catch(e){return w(cY(e,"Failed to steer the run")),!1}},[l,a,o,d]),V=(0,n.useCallback)(async e=>{if(!l||!e.trim())return{queued:!1,runEnded:!1};if(o?.kind==="question")return w(d("run.status.answerQuestionFirst")),{queued:!1,runEnded:!1};try{let t=await (0,e5.apiFetch)(`/v1/runs/${encodeURIComponent(l.id)}/inputs`,{method:"POST",body:JSON.stringify({kind:"follow_up",text:e,clientRequestId:c0()})});return z({id:t.id,text:t.text||e}),{queued:!0,runEnded:!1}}catch(n){let e=cY(n,"Failed to send follow-up"),t=/not active|not_active/i.test(e);return t||w(e),{queued:!1,runEnded:t}}},[l,o,z,d]),K=(0,n.useCallback)(async e=>{if(!l)return!1;try{return await (0,e5.apiFetch)(`/v1/runs/${encodeURIComponent(l.id)}/inputs/${encodeURIComponent(e)}`,{method:"DELETE"}),F(e),!0}catch(e){return w(cY(e,"Failed to cancel the queued message")),!1}},[l,F]),G=(0,n.useCallback)(async e=>{if(o&&"question"===o.kind&&!h){m(!0);try{await (0,e5.apiFetch)(`/v1/approval-requests/${encodeURIComponent(o.id)}/answer`,{method:"POST",headers:{"Idempotency-Key":c0()},body:JSON.stringify({answers:e,clientRequestId:c0()})}),x(i_("answer_submitted")),!P.current&&l&&(T.current=null,O({...l,status:"queued"}))}catch(e){w(cY(e,"Failed to answer the question"))}finally{m(!1)}}},[l,h,o,O]),J=(0,n.useCallback)(async(e,t)=>{if(!o||u)return;_.current?.abort();let n=new AbortController;_.current=n;let a=++S.current;p(e);try{if(await (0,e5.apiFetch)(`/v1/approval-requests/${encodeURIComponent(o.id)}/decision`,{method:"POST",headers:{"Idempotency-Key":c0()},body:JSON.stringify({decision:e,clientRequestId:c0(),standingGrantCallIndexes:t??[]}),signal:n.signal}),n.signal.aborted||S.current!==a)return;x(i_("approved"===e?"approval_granted":"approval_rejected")),!P.current&&l&&(T.current=null,O({...l,status:"queued"}))}catch(e){n.signal.aborted||S.current!==a||w(e.message)}finally{n.signal.aborted||S.current!==a||p(null)}},[l,o,u,O]);return{activeRun:l,activeRunID:l?.id??null,contextUsage:b,compacting:l?.runKind==="context_compaction",pendingApproval:o,resolvingApproval:u,answeringQuestion:h,answerQuestion:G,status:g,setStatus:x,usage:v,error:j,setError:w,watchRun:O,cancel:H,steer:W,followUp:V,cancelFollowUp:K,pendingFollowUps:$,decideApproval:J}}({sessionId:c,lineageId:v,appendMessage:j.appendTransient,upsertMessage:j.upsertTransient,refreshLatest:j.refreshLatest,refreshSession:k,activeRun:j.activeRun,pendingApproval:j.pendingApproval,queuedInputs:j.queuedInputs}),N=function(e,t,a){let[s,i]=(0,n.useState)(null),[r,l]=(0,n.useState)(),[o,c]=(0,n.useState)(!1),[d,u]=(0,n.useState)(null),p=(0,n.useRef)(0),h=(0,n.useCallback)(async n=>{if(!e||a)return void i(null);let s=p.current;try{let a=await (0,e5.apiFetch)(`/v1/sessions/${encodeURIComponent(e)}/recovery`,{signal:n});n?.aborted||p.current!==s||(i(a),l(t),u(null))}catch(e){n?.aborted||p.current!==s||u(e.message)}},[a,t,e]);(0,n.useEffect)(()=>{let e=++p.current,t=new AbortController;return queueMicrotask(()=>{p.current===e&&(i(null),l(void 0),u(null),h(t.signal))}),()=>t.abort()},[t,h]);let m=(0,n.useCallback)(async()=>{if(!s?.retryable||o)return null;c(!0);try{let e="u">typeof crypto&&crypto.randomUUID?crypto.randomUUID():Math.random().toString(36).slice(2)+Date.now().toString(36),t=await (0,e5.apiFetch)(`/v1/runs/${encodeURIComponent(s.run.id)}/retry`,{method:"POST",headers:{"Content-Type":"application/json","Idempotency-Key":e},body:JSON.stringify({clientRequestId:e})});return i(null),u(null),t.run}catch(e){return u(e.message),null}finally{c(!1)}},[s,o]);return{recovery:r===t?s:null,retrying:o,error:d,clearError:(0,n.useCallback)(()=>u(null),[]),retry:m,refresh:h}}(c,v,w.activeRunID),_=function(e,t){let[a,s]=(0,n.useState)(null);return(0,n.useEffect)(()=>{if(!e)return void s(null);let n=!1,a=()=>{(0,e5.apiFetch)(`/v1/sessions/${encodeURIComponent(e)}/stats`).then(e=>{n||s(e)}).catch(()=>{})};a();let i=t?window.setInterval(a,2e3):void 0;return()=>{n=!0,void 0!==i&&window.clearInterval(i)}},[e,t]),a}(c,w.activeRunID),C=function({sessionId:e,activeBranchId:t,onSessionUpdated:a}){let[s,i]=(0,n.useState)([]),[r,l]=(0,n.useState)(null),[o,c]=(0,n.useState)(!1),[d,u]=(0,n.useState)(!1),[p,h]=(0,n.useState)(null),m=(0,n.useRef)(0),f=(0,n.useCallback)(async t=>{if(!e)return;let n=m.current;c(!0);try{let a=await (0,e5.apiFetch)(`/v1/sessions/${encodeURIComponent(e)}/branches`,{signal:t});t?.aborted||m.current!==n||(i(a??[]),l(e),h(null))}catch(e){t?.aborted||m.current!==n||h(e.message)}finally{t?.aborted||m.current!==n||c(!1)}},[e]);(0,n.useEffect)(()=>{let t=++m.current,n=new AbortController;return queueMicrotask(()=>{m.current===t&&(h(null),e?f(n.signal):c(!1))}),()=>n.abort()},[t,f,e]);let g=(0,n.useCallback)(e=>{m.current+=1,i(e.branches),l(e.session.id),a(e.session),h(null)},[a]),x=(0,n.useCallback)(async(t,n)=>{if(!e||d)return!1;u(!0);try{let a=await (0,e5.apiFetch)(`/v1/sessions/${encodeURIComponent(e)}/branches`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({fromMessageId:t,...n?.trim()?{label:n.trim()}:{}})});return g(a),!0}catch(e){return h(e.message),!1}finally{u(!1)}},[g,d,e]),v=(0,n.useCallback)(async n=>{if(!e||d||n===t)return!1;u(!0);try{let t=await (0,e5.apiFetch)(`/v1/sessions/${encodeURIComponent(e)}/branches/${encodeURIComponent(n)}/activate`,{method:"POST"});return g(t),!0}catch(e){return h(e.message),!1}finally{u(!1)}},[t,g,d,e]);return{branches:r===e?s:[],loading:o,changing:d,error:p,clearError:(0,n.useCallback)(()=>h(null),[]),refresh:f,createBranch:x,activateBranch:v}}({sessionId:c,activeBranchId:v,onSessionUpdated:b}),{composer:S,actions:I}=function(e){let{selectedSession:t,selectedProject:a,sessionRecord:s,promptCatalog:i,settings:r,runtime:l}=e,o=(0,f.useT)(),[c,d]=(0,n.useState)(""),{pendingImage:u,textAttachments:p,uploadImage:h,attachFiles:m,removeTextAttachment:g,clearPendingImage:x,clearAttachments:v,restoreAttachments:y}=function(e){let{selectedProject:t,selectedSession:a,runtime:s}=e,[i,r]=(0,n.useState)(null),[l,o]=(0,n.useState)([]),c=(0,n.useCallback)(async e=>{if(!t||!a)return;let n=new FormData;n.set("sessionId",a),n.set("file",e);try{s.setStatus(i_("uploading_image"));let e=await (0,e5.apiFetch)(`/v1/projects/${encodeURIComponent(t)}/attachments/images`,{method:"POST",body:n});r(e),s.setError(null)}catch(e){s.setError(cY(e,"Failed to attach the image"))}finally{s.setStatus("")}},[t,a,s]),d=(0,n.useCallback)(async e=>{if(!a)return;let t=e.filter(e=>e.type.startsWith("image/")),n=e.filter(e=>!e.type.startsWith("image/"));t[0]&&await c(t[0]),t.length>1&&s.setError("Only one image can be attached to a turn.");let i=[];for(let e of n){if(!function(e){if(e.type.startsWith("text/"))return!0;let t=e.name.toLowerCase().split(".").pop()??"";return dp.has(t)||["dockerfile","makefile"].includes(e.name.toLowerCase())}(e)){s.setError(`${e.name} is not a supported text attachment.`);continue}if(e.size>1048576){s.setError(`${e.name} exceeds the 1 MiB text attachment limit.`);continue}i.push({id:"u">typeof crypto&&crypto.randomUUID?crypto.randomUUID():Math.random().toString(36).slice(2)+Date.now().toString(36),name:e.name,size:e.size,text:await e.text()})}i.length&&(o(e=>[...e,...i].slice(0,3)),l.length+i.length>3&&s.setError("A turn can include at most three text files."))},[a,s,l.length,c]),u=(0,n.useCallback)(e=>{o(t=>t.filter(t=>t.id!==e))},[]),p=(0,n.useCallback)(()=>r(null),[]);return{pendingImage:i,textAttachments:l,uploadImage:c,attachFiles:d,removeTextAttachment:u,clearPendingImage:p,clearAttachments:(0,n.useCallback)(()=>{r(null),o([])},[]),restoreAttachments:(0,n.useCallback)((e,t)=>{r(e),o(t)},[])}}({selectedProject:a,selectedSession:t,runtime:l}),[b,k]=(0,n.useState)({}),[j,w]=(0,n.useState)("discuss");(0,n.useEffect)(()=>{w(oB());let e=e=>{let t=e.detail;("discuss"===t||"ask"===t||"auto"===t)&&w(t)};return window.addEventListener(oO,e),()=>window.removeEventListener(oO,e)},[]);let[N,_]=(0,n.useState)({}),[C,S]=(0,n.useState)({open:!1,instructions:"",busy:!1}),{heroes:I,selectedHeroId:P,setSelectedHeroId:T}=function(e){let[t,a]=(0,n.useState)(null),[s,i]=(0,n.useState)([]);return(0,n.useLayoutEffect)(()=>{a(null)},[e]),(0,n.useEffect)(()=>{if(!e)return;let t=!1;return(0,e5.apiFetch)("/v1/global-heroes").then(async e=>{let n=await Promise.all((e??[]).filter(e=>!e.error).map(async e=>{try{let[t,n]=await Promise.all([(0,e5.apiFetch)(`/v1/global-heroes/${encodeURIComponent(e.id)}`),(0,e5.apiFetch)(`/v1/global-heroes/${encodeURIComponent(e.id)}/versions`)]),a=n.at(-1);if(!a)return null;return{id:e.id,handle:t.document.handle,name:t.document.name,description:t.document.description,positioning:t.document.positioning,icon:t.document.icon,color:t.document.color,scope:"global",status:"active",sourceKind:"managed",sourceLocator:t.path,currentVersionId:`v${String(a.version).padStart(6,"0")}`,currentVersion:a.version,updatedAt:a.publishedAt}}catch{return null}}));if(t)return;let s=n.filter(e=>null!==e);i(s),a(e=>s.some(t=>t.id===e)?e:null)}).catch(()=>{t||i([])}),()=>{t=!0}},[e]),{heroes:s,selectedHeroId:t,setSelectedHeroId:a}}(a),M=function(e){let[t,a]=(0,n.useState)([]),s=(0,n.useCallback)(async(t=()=>!0)=>{try{let n=e?`?${new URLSearchParams({projectID:e})}`:"",s=await (0,e5.apiFetch)(`/v1/skills${n}`);if(!t())return;a((s?.skills??[]).filter(e=>!!e.skillId&&e.sourceInfo?.scope!=="project").map(e=>({id:e.skillId??"",label:e.name||e.skillId||"",description:e.description,heroBound:!0===e.heroBound,boundBy:e.boundBy??[]})))}catch{}},[e]);return(0,n.useEffect)(()=>{let e=!1;return(async()=>{await s(()=>!e)})(),()=>{e=!0}},[s]),{skills:t,refresh:s}}(a),[R,E]=(0,n.useState)([]),[A,$]=(0,n.useState)(null),z=(0,n.useRef)(t),{setInputVersioned:F,expandDraftOrFallback:L,expandedVersion:D,draftVersion:O,flowCatalog:q,commandPanelOpen:B,promptPanelDismissed:U,setPromptPanelDismissed:H,expanding:W,expandDiag:V,setExpandDiag:K}=function(e){let{selectedProject:t,selectedSession:a,input:s,promptCatalog:i,heroes:r,setInput:l,setError:o}=e,[c,d]=(0,n.useState)(0),[u,p]=(0,n.useState)(null),[h,m]=(0,n.useState)(!1),[f,g]=(0,n.useState)(null),[x,v]=(0,n.useState)(!1),y=(0,n.useRef)(null),[b,k]=(0,n.useState)([]),j=(0,n.useCallback)(e=>{l(e),d(e=>e+1),p(null),(!e.startsWith("/")||/\s/.test(e.slice(1)))&&v(!1)},[l]),w=(0,n.useCallback)(async()=>{try{let e=await (0,e5.apiFetch)("/v1/graphs");k((e??[]).filter(e=>(e.latestVersion??0)>0).map(e=>({name:e.id,version:e.latestVersion})))}catch{}},[]);(0,n.useEffect)(()=>{let e=window.setTimeout(()=>void w(),0);return()=>window.clearTimeout(e)},[w]);let N=!!(t&&!s.slice(1).match(/[\s]/)&&(s.startsWith("/")&&i.templates.length>0||s.startsWith("@role")&&r.length>0||s.startsWith("@graph")&&b.length>0||s.startsWith("@")&&(r.length>0||b.length>0))),_=(0,n.useRef)(!1);(0,n.useEffect)(()=>{N&&!_.current&&(i.refresh(),w()),_.current=N},[N,i,w]);let C=(0,n.useCallback)(async(e,t)=>{y.current?.abort();let n=new AbortController;y.current=n;try{let a=await (0,e5.apiFetch)(`/v1/projects/${encodeURIComponent(t)}/prompt-templates/expand`,{method:"POST",body:JSON.stringify({invocation:e}),signal:n.signal});if(n.signal.aborted)return null;return a}catch(e){if(n.signal.aborted)return null;throw e}},[]);return{setInputVersioned:j,expandDraftOrFallback:(0,n.useCallback)(async(e,n,s)=>{m(!0),g(null);try{let s=await C(e,n.project);if(!s||n.project!==t||n.session!==a||n.draftVersion!==c)return null;switch(s.case){case"matched":{let e=s.text.trim();if(!e)return o("Expanded prompt is empty."),{status:"empty"};return l(e),d(e=>e+1),p(c+1),{status:"matched",text:e,diagnostics:s.diagnostics}}case"not_found":case"invalid_invocation":return{status:"fallthrough"}}}catch(e){return o(cY(e,s)),null}finally{m(!1)}},[o,t,a,c,C,l,d,p,m,g]),expandedVersion:u,draftVersion:c,flowCatalog:b,commandPanelOpen:N,promptPanelDismissed:x,setPromptPanelDismissed:v,expanding:h,expandDiag:f,setExpandDiag:g}}({selectedProject:a,selectedSession:t,input:c,promptCatalog:i,heroes:I,setInput:d,setError:l.setError});(0,n.useEffect)(()=>{z.current=t},[t]);let G=(0,n.useRef)(t);(0,n.useLayoutEffect)(()=>{let e=G.current;G.current=t,null===e&&t||(F(""),E([]),$(null),v())},[t,F,v]);let J=t?b[t]??s?.defaultModelProfileId??r.models.find(e=>e.isDefault)?.id??r.models[0]?.id??null:null,Y=t?N[t]??"default":"default",Q=(0,n.useCallback)(e=>{t&&_(n=>({...n,[t]:e}))},[t]),Z=(0,n.useCallback)(()=>{var e;let t,n;return e=r.policies,t=e.filter(e=>"tool"===e.kind&&"active"===e.status&&e.config.mode===j),n=RegExp(`^builtin-tool-${j}-v\\d+$`),t.find(e=>n.test(e.id))?.id??t[0]?.id},[j,r.policies]),X=(0,n.useCallback)(()=>(function(e,t){let n=du(e?.effectiveConfig),a=du(n?.hero)?.permissionCeiling;if(dd(a))return a;let s=du(n?.toolPolicy)?.id,i=du(e?.requestedConfig)?.toolPolicyProfileId;return function(e,t){if("string"!=typeof t||!t)return;let n=e.find(e=>e.id===t&&"tool"===e.kind),a=n?.config.mode;if(dd(a))return a;let s=/^builtin-tool-(discuss|ask|auto)-v\d+$/.exec(t)?.[1];return"discuss"===s||"ask"===s||"auto"===s?s:void 0}(t,s??i)})(l.activeRunRecord,r.policies)??j,[l.activeRunRecord,j,r.policies]),ee=(0,n.useCallback)(async(e,n)=>{if(!t)return;let a=function(e,t){if(0===t.length)return e;let n=t.map(e=>[`--- Attached file: ${e.name} ---`,e.text,`--- End attached file: ${e.name} ---`].join("\n"));return[e.trim(),...n].filter(Boolean).join("\n\n")}(e,p),s=p.length?`[Files: ${p.map(e=>e.name).join(", ")}]`:"",i=dh();F(""),v(),l.setStatus(i_("sending")),l.appendTransient({id:i,role:"user",text:[e,u?`[Image: ${u.name}]`:"",s].filter(Boolean).join("\n")});try{let e=u?{content:[...a?[{type:"text",text:a}]:[],{type:"image",artifactId:u.id}]}:{text:a},s=I.find(e=>e.id===P)??null,i=`/v1/sessions/${encodeURIComponent(t)}/invocations`,r=R.map(e=>({id:e})),o=r.length>0?{...e,skills:r}:e,c=s&&s.currentVersionId?{...o,target:{kind:"hero",objectId:s.id,versionId:s.currentVersionId,contextMode:"room"}}:{...{...o,config:{toolPolicyProfileId:n,...J?{modelProfileId:J}:{},...Y?{thinkingEffort:Y}:{}}},target:{kind:"host"}},d=await (0,e5.apiFetch)(i,{method:"POST",headers:{"Idempotency-Key":dh()},body:JSON.stringify(c)});if(z.current!==t)return;E([]),l.setError(null),l.watchRun(d.run)}catch(n){z.current===t&&(F(e),y(u,p),l.removeTransient(i),l.setStatus(""),l.setError(cY(n,"Failed to send the message")))}},[t,u,p,l,J,P,I,R,F,Y,v,y]),et=!!l.activeRunID,en=(0,n.useCallback)(async(e,n,a)=>{if(!t)return l.setError("Select a session before invoking a graph."),!1;let s={};if(a)for(let e of a.split(/\s+/)){let[t,...n]=e.split("=");t&&n.length>0&&(s[t]=n.join("="))}try{return await (0,e5.apiFetch)(`/v1/graphs/${encodeURIComponent(e)}/runs`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:t,name:e,version:n??0,inputs:s})}),F(""),l.setError(null),!0}catch(e){return l.setError(e instanceof Error?e.message:"Failed to invoke graph"),!1}},[t,l,F]),ea=Z(),es=(0,n.useCallback)(async()=>{if(!t||!c.trim()&&!u&&0===p.length&&!A||l.activeRunID)return;let e=c.trim().match(/^\/invoke_agent_flow\s+(\S+)(?:\s+([\s\S]+))?$/);if(e){let[t,n]=e[1].split("@");en(t,n?Number(n):void 0,e[2]);return}if(A){let e=c.trim(),t=e?/(^|\s)[A-Za-z_][\w-]*=/.test(e)?e:`prompt=${JSON.stringify(e)}`:void 0;en(A.name,A.version,t).then(e=>{e&&$(null)});return}let n=c.trim().match(/^@graph:([\w.-]+)(?:@(\d+))?(?:\s+([\s\S]+))?$/);if(n)return void en(n[1],n[2]?Number(n[2]):void 0,n[3]);if(!ea&&!P)return void l.setError(`The ${j} permission policy is unavailable.`);if(c.startsWith("/")&&D!==O&&a){let e=await L(c,{project:a,session:t,draftVersion:O},"Failed to expand prompt template");if(!e)return;if("matched"===e.status){e.diagnostics.some(e=>"arguments_fallback"===e.code)&&K("Arguments could not be fully parsed; using raw input.");return}"fallthrough"===e.status&&ee(c,ea??"");return}ee(c,ea??"")},[t,c,u,p.length,ea,j,A,l,ee,a,P,D,O,en,L,K]),ei=(0,n.useCallback)(async()=>{if(l.activeRunID&&c.trim()){if(l.questionPending)return void l.setError(o("composer.answerQuestionFirst"));if(c.startsWith("/")&&D!==O&&a){let e=await L(c,{project:a,session:t,draftVersion:O},"Failed to expand");if(!e||"matched"===e.status)return;"fallthrough"===e.status&&(F(""),await l.steer(c)||F(c));return}F(""),await l.steer(c)||F(c)}},[l,c,a,t,D,O,F,L,o]),er=(0,n.useCallback)(async e=>!!l.activeRunID&&!!e.trim()&&(l.questionPending?(l.setError(o("composer.answerQuestionFirst")),!1):l.steer(e)),[l,o]),el=(0,n.useCallback)(async()=>{if(!l.activeRunID||!c.trim())return;F("");let{queued:e,runEnded:n}=await l.followUp(c);if(!e){if(n&&t)return void ee(c,ea??"");F(c)}},[l,c,ee,ea,t,F]),eo=(0,n.useCallback)(e=>{t&&(k(n=>({...n,[t]:e})),(0,e5.apiFetch)(`/v1/sessions/${encodeURIComponent(t)}`,{method:"PATCH",body:JSON.stringify({defaultModelProfileId:e})}).then(()=>{z.current===t&&l.refreshSelectedSession()}).catch(e=>{z.current===t&&l.setError(cY(e,"Failed to select model"))}))},[l,t]),ec=(0,n.useCallback)(async()=>{if(!t||l.activeRunID)return;let e=await l.refreshSelectedSession();e?.activeLeafMessageId?S({open:!0,instructions:"",busy:!1}):l.setError("This session has no conversation history to compact.")},[l,t]),ed=(0,n.useCallback)(async()=>{if(!t||l.activeRunID)return;let e=C.instructions.trim();S(e=>({...e,busy:!0}));try{let n=await l.refreshSelectedSession();if(!n?.activeLeafMessageId){l.setError("This session has no conversation history to compact."),S({open:!1,instructions:"",busy:!1});return}let a=await (0,e5.apiFetch)(`/v1/sessions/${encodeURIComponent(t)}/compactions`,{method:"POST",headers:{"Idempotency-Key":dh()},body:JSON.stringify({baseMessageId:n.activeLeafMessageId,instructions:e})}),s=await (0,e5.apiFetch)(`/v1/runs/${encodeURIComponent(a.runId)}`);l.setError(null),S({open:!1,instructions:"",busy:!1}),l.watchRun(s)}catch(e){l.setError(e.message),S(e=>({...e,busy:!1}))}},[l,C.instructions,t]),eu=(0,n.useCallback)(()=>{S(e=>e.busy?e:{open:!1,instructions:"",busy:!1})},[]);return{composer:{sessionId:t,activeLeafMessageId:s?.activeLeafMessageId,input:c,setInput:F,pendingImage:u,clearPendingImage:x,uploadImage:e=>void h(e),textAttachments:p,removeTextAttachment:g,attachFiles:e=>void m(e),models:r.models.filter(e=>"active"===e.status),providers:r.providers,selectedModelId:J,setSelectedModelId:eo,thinkingEffort:Y,setThinkingEffort:Q,heroes:I,selectedHeroId:P,setSelectedHeroId:T,permissionMode:j,displayedPermissionMode:X(),permissionReady:!!ea,setPermissionMode:w,compactSession:()=>void ec(),compaction:{open:C.open,instructions:C.instructions,busy:C.busy,setInstructions:e=>S(t=>({...t,instructions:e})),confirm:()=>void ed(),cancel:eu},promptPanel:{templates:i.templates,heroes:I.map(e=>({id:e.id,handle:e.handle,name:e.name,description:e.description})),flows:q,show:B&&!U,skills:M.skills,oneShotLocked:et,pendingSkills:R,pendingGraph:A,toggleSkill:e=>E(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e]),clearPendingGraph:()=>$(null),onSelect:e=>{H(!1),F(`/${e} `)},onHeroSelect:e=>{T(""===e?null:e),H(!0)},onFlowSelect:(e,t)=>{H(!1),$({name:e,version:t})},onClose:()=>H(!0),expanding:W,expandDiag:V}},actions:{submit:es,steer:ei,steerText:er,followUp:el}}}({selectedSession:c,selectedProject:u,sessionRecord:d,promptCatalog:p,settings:h,runtime:{activeRunID:w.activeRunID,activeRunRecord:w.activeRun,questionPending:w.pendingApproval?.kind==="question",setStatus:w.setStatus,setError:w.setError,watchRun:w.watchRun,steer:w.steer,followUp:w.followUp,appendTransient:j.appendTransient,removeTransient:j.removeTransient,refreshSelectedSession:k}}),P=w.activeRunID,{decideApproval:T}=w,{createBranch:M}=C,R=(0,n.useCallback)(async e=>{P||await M(e)},[P,M]),E=async e=>{P||await C.activateBranch(e)},A=(0,n.useCallback)(e=>void T(e),[T]),$=(0,n.useCallback)(e=>void R(e),[R]),z=(0,n.useCallback)(async()=>{let e=await N.retry();e&&w.watchRun(e)},[N,w]),F=(0,n.useCallback)(()=>{w.setError(null),N.clearError(),C.clearError()},[w,N,C]),L=w.error??N.error??C.error,D={sessionId:c,activeBranchId:v,activeLeafMessageId:y,messages:j.messages,loading:j.loading,loadingOlder:j.loadingOlder,error:j.historyError,hasMore:j.hasMore,loadOlder:j.loadOlder};return{history:D,run:{activeRun:w.activeRunID,inspectorRunId:w.activeRunID??function(e){for(let t=e.length-1;t>=0;t-=1){let n=e[t];if("turn"===n.kind&&n.runId)return n.runId}return null}(j.messages),activeRunStatus:w.activeRun?.status,startedAt:w.activeRun?.startedAt||w.activeRun?.createdAt||null,status:w.status,usage:w.usage,contextUsage:w.contextUsage,stats:_,compacting:w.compacting,pendingApproval:w.pendingApproval,resolvingApproval:w.resolvingApproval,decideApproval:A,answeringQuestion:w.answeringQuestion,answerQuestion:w.answerQuestion,cancel:()=>void w.cancel(),pendingFollowUps:w.pendingFollowUps,cancelFollowUp:w.cancelFollowUp,recovery:N.recovery,retrying:N.retrying,retryRun:()=>void z(),error:w.error,setError:w.setError,clearError:()=>w.setError(null)},branches:{branches:C.branches,activeBranchId:v,loading:C.loading,changing:C.changing,error:C.error,createBranch:$,activateBranch:e=>void E(e)},composer:S,actions:I,error:L,clearError:F}}({selectedSession:y,sessionRecord:B,selectedProject:r,promptCatalog:U,settings:O,replaceSession:q}),W=function(e,t){let[a,s]=(0,n.useState)(new Set),i=[...new Set(e)].sort().join("\0");return(0,n.useEffect)(()=>{if(!i)return;let e=i.split("\0"),t=new AbortController,n=async()=>{let n=await Promise.all(e.map(async e=>{try{let n=await (0,e5.apiFetch)(`/v1/projects/${encodeURIComponent(e)}/active-runs`,{signal:t.signal});return n?.sessionIds??[]}catch{return[]}}));t.signal.aborted||s(new Set(n.flat()))};n();let a=window.setInterval(()=>void n(),15e3);return()=>{t.abort(),window.clearInterval(a)}},[i]),(0,n.useMemo)(()=>{let e=new Set(i?a:[]);return t&&e.add(t),e},[t,a,i])}(D.groups.flatMap(e=>[e.projectId]),H.run.activeRun?y:null),K=O.refresh,G=(0,n.useCallback)(e=>{u(e),K()},[K,u]),{closeSettings:J}=function({loading:e,error:t,providers:a,openSettings:s,closeSettings:i}){let r=(0,n.useRef)(!1),l=(0,n.useCallback)(()=>{try{window.localStorage.setItem(cV,"1")}catch{}i()},[i]);return(0,n.useEffect)(()=>{if(r.current||e||t||a.some(e=>e.credentialConfigured))return;let n=!1;try{n="1"===window.localStorage.getItem(cV)}catch{}n||(r.current=!0,s("models"))},[e,t,a,s]),{closeSettings:l}}({loading:O.loading,error:O.error,providers:O.providers,openSettings:G,closeSettings:p}),Y=(0,n.useCallback)(e=>{l(e),N("chat"),_(null),L.setView("active"),L.setQuery(""),a&&F()},[N,F,a,_,L,l]),Q=(0,n.useCallback)(async e=>{let t=k.current;try{let n=await (0,dC.reuseOrCreateBlankSession)(e,L.activeSessions);H.run.setError(null),L.replaceSession(n),k.current===t&&(_(n.id),N("chat")),await L.refresh(),D.refresh(e)}catch(e){H.run.setError(e.message)}},[N,_,L,D,H.run]),Z=(0,n.useCallback)(async e=>{l(e),await Q(e)},[Q,l]),X=(0,n.useCallback)(async()=>{r&&await Z(r)},[Z,r]);!function(e){let{projectsReady:t,selectedProject:a,selectedSession:s,sessions:i,sessionsLoading:r,selectSession:l,connectBlank:o}=e,c=(0,n.useRef)("waiting");(0,n.useEffect)(()=>{if(!t)return;if(!a){s&&l(null),c.current="done";return}if(r)return;if(s&&i.some(e=>e.id===s)){(0,dC.writeStoredId)(dC.SELECTED_SESSION_KEY,s),c.current="done";return}if("done"===c.current){if(s)return;let e=i.find(R.isBlankSession);e&&l(e.id);return}if("connecting"===c.current)return;let e=(0,dC.readStoredId)(dC.SELECTED_SESSION_KEY);if(e&&i.some(t=>t.id===e)){l(e),c.current="done";return}c.current="connecting",s&&l(null),o(a).finally(()=>{c.current="done"})},[t,a,s,i,r,l,o])}({projectsReady:i,selectedProject:r,selectedSession:y,sessions:L.activeSessions,sessionsLoading:L.loading,selectSession:_,connectBlank:Q});let ee=(0,n.useCallback)(async(e,t)=>{let n=await (0,e5.apiFetch)(`/v1/sessions/${encodeURIComponent(e.id)}`,{method:"PATCH",body:JSON.stringify({title:t})});L.replaceSession(n),D.refresh(e.projectId)},[L,D]),et=(0,n.useCallback)(async(e,t)=>{await x(e,t),D.refresh(e)},[x,D]),en=(0,n.useCallback)(async e=>{await v(e)},[v]),ea=(0,n.useCallback)(e=>{J(),N("chat"),_(e),(0,e5.apiFetch)(`/v1/sessions/${encodeURIComponent(e)}`).then(L.replaceSession).catch(()=>{}),a&&F()},[N,F,J,a,_,L]),es=(0,n.useCallback)(async e=>{let t=await L.archive(e);t&&(D.refresh(e.projectId),D.refreshArchived(e.projectId)),t&&y===e.id&&_(null)},[_,L,D,y]),ei=(0,n.useCallback)(async e=>{await L.restore(e),D.refresh(e.projectId),D.refreshArchived(e.projectId)},[L,D]),er=B?.projectId??r,{currentCwd:el,panel:eo,handleOpenFile:ec,handlePreviewFile:ed,panelOpen:eu,openPanel:ep,closePanel:eh}=function({projectId:e,workspaceFor:t,setRunError:a,onPreviewFile:s}){let i=e?t(e)??null:null,r=i?.hostPath??null;(0,n.useEffect)(()=>{if(!e||t(e))return;let n=new AbortController;return(0,e5.apiFetch)(`/v1/projects/${encodeURIComponent(e)}/workspace`,{signal:n.signal}).catch(e=>{n.signal.aborted||a(e.message)}),()=>n.abort()},[e,a,t]);let l=function(e){let[t,a]=(0,n.useState)(()=>oo(oi(e??""))),[s,i]=(0,n.useState)(null),[r,l]=(0,n.useState)(0),o=(0,n.useRef)(new Map),c=(0,n.useRef)(null),d=(0,n.useRef)(!1),u=(0,n.useRef)(null),p=(0,n.useRef)(!1),h=e??"",m=(0,n.useCallback)(e=>{var t;if(!e||!e.projectId||null===s||p.current||d.current)return;let n=JSON.stringify({version:1,projectId:(t={version:1,projectId:e.projectId,pinnedChannels:or(e.pinnedChannels),primaryWidth:e.primaryWidth,open:e.open,inspectorTabs:ol(e.inspectorTabs),activeInspectorId:e.activeInspectorId,navigatorHidden:e.navigatorHidden}).projectId,pinnedChannels:or(t.pinnedChannels),primaryWidth:t.primaryWidth,open:t.open,inspectorTabs:ol(t.inspectorTabs),navigatorHidden:!0===t.navigatorHidden,activeInspectorId:t.activeInspectorId??null});if(c.current!==n)try{window.localStorage.setItem(os(e.projectId),n),c.current=n}catch{}},[s]);(0,n.useEffect)(()=>{if(s===h)return;m(u.current);let t=e?function(e,t){try{return function(e,t){let n;if(null===e)return oi(t);try{n=JSON.parse(e)}catch{return oi(t)}if("object"!=typeof n||null===n)return oi(t);let a=n;if(1!==a.version||a.projectId!==t)return oi(t);let s=Array.isArray(a.pinnedChannels)?or(a.pinnedChannels.filter(oa)):[],i="number"==typeof a.primaryWidth&&Number.isFinite(a.primaryWidth)?a.primaryWidth:280,r=ol(a.inspectorTabs),l="string"==typeof a.activeInspectorId&&r.some(e=>`file:${t}:${e.path}`===a.activeInspectorId)?a.activeInspectorId:null;return{version:1,projectId:t,pinnedChannels:s,primaryWidth:i,open:!0===a.open,inspectorTabs:r,activeInspectorId:l,navigatorHidden:!0===a.navigatorHidden}}(window.localStorage.getItem(os(e)),e)}catch{return t.current=!0,oi(e)}}(e,p):oi("");a(()=>{let n=oo(t),a=n.inspectorTabs.map(t=>od(e??"",t.path)),s=o.current.get(h)??n.activeInspectorId??void 0,i=void 0!==s&&a.includes(s)?s:null;return{...n,activeInspectorId:i,activeLane:null===i?"channel":"inspector"}}),i(h)},[h,e,s,m]);let f=(0,n.useMemo)(()=>(t.projectId===e?t.inspectorTabs:[]).map(t=>({id:od(e??"",t.path),label:t.name,filePath:t.path,projectId:e??void 0})),[t.projectId,t.inspectorTabs,e]),g=(0,n.useMemo)(()=>f.map(e=>e.id),[f]),x="inspector"===t.activeLane&&null!==t.activeInspectorId&&g.includes(t.activeInspectorId)?t.activeInspectorId:null,v=oa(t.activeChannelId)&&t.openChannels.includes(t.activeChannelId)?t.activeChannelId:t.openChannels[0]??null;(0,n.useEffect)(()=>{!e||t.projectId!==e||s!==e||d.current||p.current||m(t)},[e,t,s,r,m]),(0,n.useEffect)(()=>{u.current=t},[t]);let y=(0,n.useCallback)((t,n)=>{if(!e)return;let s=od(e,t);o.current.set(e,s),a(e=>op(e,s,{path:t,name:n}))},[e]),b=(0,n.useCallback)(t=>{oa(t)||o.current.set(e??"",t),a(e=>oa(t)?ou(e,t):op(e,t,e.inspectorTabs.find(n=>od(e.projectId,n.path)===t)??{path:oc(t),name:oc(t).split("/").filter(Boolean).pop()??t}))},[e]),k=(0,n.useCallback)(t=>{oa(t)||(o.current.get(e??"")===t&&o.current.delete(e??""),a(e=>{let n,a;return n=e.inspectorTabs.filter(e=>e.path!==oc(t)).map(t=>od(e.projectId,t.path)),a=e.activeInspectorId===t?n[n.length-1]??null:e.activeInspectorId,{...e,inspectorTabs:e.inspectorTabs.filter(e=>e.path!==oc(t)),activeInspectorId:a,activeLane:null===a?"channel":e.activeLane}}))},[e]),j=(0,n.useCallback)((e,t)=>{a(n=>(function(e,t,n){let a=e.inspectorTabs.findIndex(e=>e.path===t),s=e.inspectorTabs.findIndex(e=>e.path===n);if(a<0||s<0||a===s)return e;let i=[...e.inspectorTabs],[r]=i.splice(a,1);return i.splice(s,0,r),{...e,inspectorTabs:i}})(n,oc(e),oc(t)))},[]),w=(0,n.useCallback)(()=>{a(e=>{var t;return t=!e.navigatorHidden,e.navigatorHidden===t?e:{...e,navigatorHidden:t}})},[]),N=(0,n.useCallback)(e=>{a(t=>(function(e,t){if(!e.openChannels.includes(t))return e;let n=e.openChannels.filter(e=>e!==t);if(e.activeChannelId!==t)return{...e,openChannels:n};let a=on.filter(e=>n.includes(e));return{...e,openChannels:n,activeChannelId:a[0]??null,activeLane:e.activeLane}})(t,e))},[]),_=(0,n.useCallback)(e=>{a(t=>ou(t,e))},[]),C=(0,n.useCallback)(e=>{a(t=>{let n;return t.pinnedChannels.includes(e)?t.pinnedChannels.includes(e)?{...t,pinnedChannels:t.pinnedChannels.filter(t=>t!==e)}:t:(n=t.pinnedChannels.includes(e)?t.pinnedChannels:or([...t.pinnedChannels,e]),ou({...t,pinnedChannels:n},e))})},[]),S=(0,n.useCallback)((e,t)=>{a(n=>{var a;let s=lT(n.primaryWidth,t);return a=lT(s+e,t),n.primaryWidth===a?n:{...n,primaryWidth:a}})},[]);return{fileTabs:f,activeTabId:x??v??"files",activeInspectorId:x,activeChannelId:v,setActiveTabId:b,openInspector:y,closeTab:k,reorderTabs:j,closeChannelTab:N,toggleNavigator:w,openChannel:_,togglePin:C,resizePrimaryBy:S,beginPrimaryResize:(0,n.useCallback)(()=>{d.current=!0},[]),endPrimaryResize:(0,n.useCallback)(()=>{d.current=!1,l(e=>e+1)},[]),state:t,open:t.open,openShell:()=>a(e=>e.open?e:{...e,open:!0}),closeShell:()=>a(e=>e.open?{...e,open:!1}:e)}}(e),{openInspector:o}=l;return{currentWorkspace:i,currentCwd:r,panel:l,handleOpenFile:(0,n.useCallback)((e,t)=>{o(e,t)},[o]),handlePreviewFile:(0,n.useCallback)((t,n)=>{e&&s({projectId:e,path:t,name:n})},[e,s]),panelOpen:l.open,openPanel:l.openShell,closePanel:l.closeShell}}({projectId:er,workspaceFor:h,setRunError:H.run.setError,onPreviewFile:A}),em=function(e){let{session:t,replaceSession:a}=e,[s,i]=(0,n.useState)(!1),[r,l]=(0,n.useState)(""),o=(0,n.useRef)(null),c=(0,n.useCallback)(e=>e&&(e.title||e.id?.slice(0,12))||"",[]),d=(0,n.useCallback)(()=>{t&&(l(t.title||c(t)),i(!0),setTimeout(()=>o.current?.select(),0))},[c,t]),u=(0,n.useCallback)(async()=>{if(!t)return void i(!1);let e=r.trim();if(i(!1),e!==(t.title??""))try{let n=await (0,e5.apiFetch)(`/v1/sessions/${encodeURIComponent(t.id)}`,{method:"PATCH",body:JSON.stringify({title:e})});a(n)}catch{}},[t,r,a]),p=(0,n.useCallback)(e=>{"Enter"===e.key?(e.preventDefault(),u()):"Escape"===e.key&&(e.preventDefault(),e.stopPropagation(),i(!1))},[u]);return{title:t?c(t):"No session",editing:s,draft:r,setDraft:l,startEdit:d,save:u,keyDown:p,inputRef:o}}({session:B,replaceSession:L.replaceSession}),ef=el?el.replace(/\/+$/,"").split(/[\\/]/).filter(Boolean).pop()||el:"",eg=(0,t.jsx)(V,{projects:s,groups:D.groups,selectedProject:r,selectedSession:y,settingsOpen:c,query:L.query,setQuery:L.setQuery,mutatingId:L.mutatingId,announcement:L.announcement,pinnedProjectIds:g,togglePinProject:m,renameProject:et,deleteProject:en,collapsed:D.collapsed,toggleCollapsed:D.toggleCollapsed,archived:D.archived,openArchived:D.openArchived,createProject:o,createSession:X,createSessionIn:Z,renameSession:ee,switchProject:Y,switchSession:ea,archiveSession:e=>void es(e),restoreSession:e=>void ei(e),openSettings:G,closeNavigation:F,runningSessionIds:W,onToggleSidebar:()=>P(e=>!e),projectSelector:S,view:j,setView:N}),ex=H.error??L.error,ev=(0,n.useSyncExternalStore)(dS,dI,dP);return(0,t.jsx)(rh,{children:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"app-shell","data-testid":"ennote-shell",children:[(0,t.jsx)("div",{className:"sidebar-overlay-backdrop","data-open":I||void 0,onClick:F}),(0,t.jsx)("div",{className:`sidebar-container${I?" sidebar-open":" sidebar-closed"}`,role:a&&I?"dialog":void 0,"aria-modal":a&&I?"true":void 0,"aria-label":a&&I?"Navigation":void 0,id:"workspace-navigation",style:{width:a?void 0:I?C.width:0,minWidth:a?void 0:I?C.width:0,transition:I||C.isResizing?"none":void 0},children:eg}),I&&!a&&(0,t.jsx)(lS,{side:"right",ariaLabel:"Resize sidebar",value:C.width,min:264,max:420,onResizeStart:C.beginResize,onResize:C.resizeBy,onResizeEnd:C.endResize}),(0,t.jsxs)("div",{className:"workspace-content",inert:a&&I,children:[(0,t.jsx)(cB,{workerUnreachable:ev}),"chat"===j?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(rQ,{sidebarOpen:I,onToggleSidebar:()=>P(e=>!e),navigationTriggerRef:$,session:B,title:em,projectName:ef,projectPath:el,branch:{branches:H.branches.branches,activeBranchId:H.branches.activeBranchId,loading:H.branches.loading,changing:H.branches.changing,disabled:!!H.run.activeRun,onActivate:H.branches.activateBranch},rightPanelOpen:eu,onToggleRightPanel:()=>eu?eh():ep(),attention:{projectId:r??er??void 0,onNavigate:e=>{e.sessionId&&e.sessionId!==y&&ea(e.sessionId)}}}),(0,t.jsx)(rM,{history:H.history,run:H.run,branches:H.branches,composer:H.composer,actions:H.actions,error:ex,clearError:()=>{H.clearError(),L.setError(null)},projects:s,selectedProject:r,hasModel:O.models.length>0,pinnedProjectIds:g,togglePinProject:m,onSwitchProject:e=>void Z(e),onNewProject:o,onOpenSettings:G})]}):(0,t.jsx)(d_,{view:j,models:O.models,providers:O.providers,onBackToChat:()=>N("chat"),onOpenMobileNav:()=>P(!0),menuTriggerRef:z})]}),"chat"===j&&eu&&(0,t.jsx)(om,{resize:T}),"chat"===j&&(0,t.jsx)(oh,{open:eu,onClose:eh,resize:T,panel:eo,projectId:er??null,displayPath:el,onOpenFile:ec,onPreviewFile:ed,selectedSession:y,sessionTitle:B?.title||y||"",activeRun:H.run.activeRun,inspectorRunId:H.run.inspectorRunId,status:H.run.status,permissionMode:H.composer.displayedPermissionMode})]}),E&&(0,t.jsx)(of,{projectId:E.projectId,filePath:E.path,fileName:E.name,onClose:()=>A(null)}),(0,t.jsx)(cO,{settingsOpen:c,settingsTab:d,onCloseSettings:J,providers:O.providers,models:O.models,policies:O.policies,session:B,projectId:r,error:O.error,refresh:O.refresh,setError:O.setError,onSessionUpdated:L.replaceSession})]})})}],59665)}]);