retrohound 0.0.0-stage → 0.1.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 (143) hide show
  1. package/LICENSE +202 -0
  2. package/NOTICE +9 -0
  3. package/README.md +235 -2
  4. package/dist/THIRD_PARTY_LICENSES +62 -0
  5. package/dist/cli.mjs +364 -0
  6. package/package.json +52 -4
  7. package/rules/LICENSE +28 -0
  8. package/rules/ai_coding_agent/any/control_plane_disable_safety.yml +50 -0
  9. package/rules/ai_coding_agent/any/secrets_credential_store_access.yml +66 -0
  10. package/rules/ai_coding_agent/any/secrets_literal_in_tool_input.yml +37 -0
  11. package/rules/ai_coding_agent/any/secrets_read_secret_file.yml +59 -0
  12. package/rules/ai_coding_agent/config_change/control_plane_bypass_permissions_mode.yml +23 -0
  13. package/rules/ai_coding_agent/correlation/blocked_retry_secret_read.yml +54 -0
  14. package/rules/ai_coding_agent/correlation/exec_mass_delete.yml +36 -0
  15. package/rules/ai_coding_agent/correlation/secrets_read_then_egress.yml +78 -0
  16. package/rules/ai_coding_agent/correlation/secrets_read_then_mcp_payload.yml +49 -0
  17. package/rules/ai_coding_agent/file_event/control_plane_agent_config_risky_write.yml +52 -0
  18. package/rules/ai_coding_agent/file_event/control_plane_agent_config_write.yml +50 -0
  19. package/rules/ai_coding_agent/file_event/control_plane_llm_endpoint_override.yml +102 -0
  20. package/rules/ai_coding_agent/file_event/files_mcp_server_added.yml +19 -0
  21. package/rules/ai_coding_agent/file_event/files_npm_lifecycle_script.yml +20 -0
  22. package/rules/ai_coding_agent/file_event/files_persistence_location.yml +39 -0
  23. package/rules/ai_coding_agent/file_event/files_vscode_task_autorun.yml +19 -0
  24. package/rules/ai_coding_agent/file_event/files_write_outside_project.yml +30 -0
  25. package/rules/ai_coding_agent/instruction_load/files_instruction_concealment.yml +32 -0
  26. package/rules/ai_coding_agent/instruction_load/files_instruction_concealment_skill.yml +34 -0
  27. package/rules/ai_coding_agent/instruction_load/files_invisible_unicode_instruction.yml +37 -0
  28. package/rules/ai_coding_agent/instruction_load/files_invisible_unicode_skill.yml +38 -0
  29. package/rules/ai_coding_agent/instruction_load/files_invisible_unicode_write.yml +39 -0
  30. package/rules/ai_coding_agent/process_creation/control_plane_agent_config_risky_shell_write.yml +51 -0
  31. package/rules/ai_coding_agent/process_creation/control_plane_agent_config_shell_write.yml +49 -0
  32. package/rules/ai_coding_agent/process_creation/control_plane_hook_dropper_script.yml +33 -0
  33. package/rules/ai_coding_agent/process_creation/control_plane_hook_repo_script.yml +56 -0
  34. package/rules/ai_coding_agent/process_creation/exec_chmod_downloaded.yml +20 -0
  35. package/rules/ai_coding_agent/process_creation/exec_cloud_cli_credentials.yml +30 -0
  36. package/rules/ai_coding_agent/process_creation/exec_decode_to_shell.yml +31 -0
  37. package/rules/ai_coding_agent/process_creation/exec_docker_privileged.yml +28 -0
  38. package/rules/ai_coding_agent/process_creation/exec_download_then_run.yml +22 -0
  39. package/rules/ai_coding_agent/process_creation/exec_git_force_push.yml +20 -0
  40. package/rules/ai_coding_agent/process_creation/exec_git_global_hooks.yml +23 -0
  41. package/rules/ai_coding_agent/process_creation/exec_lolbin_download.yml +26 -0
  42. package/rules/ai_coding_agent/process_creation/exec_package_install_new.yml +49 -0
  43. package/rules/ai_coding_agent/process_creation/exec_pipe_download_to_shell.yml +37 -0
  44. package/rules/ai_coding_agent/process_creation/exec_rm_recursive_dangerous.yml +21 -0
  45. package/rules/ai_coding_agent/process_creation/exec_vulnerable_agent_version.yml +22 -0
  46. package/rules/ai_coding_agent/process_creation/files_mcp_server_command.yml +18 -0
  47. package/rules/ai_coding_agent/process_creation/files_persistence_command.yml +36 -0
  48. package/rules/ai_coding_agent/process_creation/network_paste_filedrop_command.yml +109 -0
  49. package/rules/ai_coding_agent/process_creation/secrets_credential_store_probe.yml +30 -0
  50. package/rules/ai_coding_agent/process_creation/secrets_env_dump.yml +48 -0
  51. package/rules/ai_coding_agent/web_request/network_paste_filedrop_domains.yml +84 -0
  52. package/rules/tests/blocked_retry_secret_read/negative.jsonl +61 -0
  53. package/rules/tests/blocked_retry_secret_read/positive.jsonl +4 -0
  54. package/rules/tests/control_plane_agent_config_risky_shell_write/negative.jsonl +2 -0
  55. package/rules/tests/control_plane_agent_config_risky_shell_write/positive.jsonl +2 -0
  56. package/rules/tests/control_plane_agent_config_risky_write/negative.jsonl +2 -0
  57. package/rules/tests/control_plane_agent_config_risky_write/positive.jsonl +5 -0
  58. package/rules/tests/control_plane_agent_config_shell_write/negative.jsonl +4 -0
  59. package/rules/tests/control_plane_agent_config_shell_write/positive.jsonl +3 -0
  60. package/rules/tests/control_plane_agent_config_write/negative.jsonl +3 -0
  61. package/rules/tests/control_plane_agent_config_write/positive.jsonl +5 -0
  62. package/rules/tests/control_plane_bypass_permissions_mode/negative.jsonl +3 -0
  63. package/rules/tests/control_plane_bypass_permissions_mode/positive.jsonl +1 -0
  64. package/rules/tests/control_plane_disable_safety/negative.jsonl +5 -0
  65. package/rules/tests/control_plane_disable_safety/positive.jsonl +6 -0
  66. package/rules/tests/control_plane_hook_dropper_script/negative.jsonl +7 -0
  67. package/rules/tests/control_plane_hook_dropper_script/positive.jsonl +4 -0
  68. package/rules/tests/control_plane_hook_repo_script/negative.jsonl +6 -0
  69. package/rules/tests/control_plane_hook_repo_script/positive.jsonl +5 -0
  70. package/rules/tests/control_plane_llm_endpoint_command/negative.jsonl +12 -0
  71. package/rules/tests/control_plane_llm_endpoint_command/positive.jsonl +18 -0
  72. package/rules/tests/control_plane_llm_endpoint_override/negative.jsonl +7 -0
  73. package/rules/tests/control_plane_llm_endpoint_override/positive.jsonl +14 -0
  74. package/rules/tests/exec_chmod_downloaded/negative.jsonl +3 -0
  75. package/rules/tests/exec_chmod_downloaded/positive.jsonl +3 -0
  76. package/rules/tests/exec_cloud_cli_credentials/negative.jsonl +4 -0
  77. package/rules/tests/exec_cloud_cli_credentials/positive.jsonl +5 -0
  78. package/rules/tests/exec_decode_to_shell/negative.jsonl +6 -0
  79. package/rules/tests/exec_decode_to_shell/positive.jsonl +8 -0
  80. package/rules/tests/exec_docker_privileged/negative.jsonl +3 -0
  81. package/rules/tests/exec_docker_privileged/positive.jsonl +4 -0
  82. package/rules/tests/exec_download_then_run/negative.jsonl +12 -0
  83. package/rules/tests/exec_download_then_run/positive.jsonl +6 -0
  84. package/rules/tests/exec_git_force_push/negative.jsonl +5 -0
  85. package/rules/tests/exec_git_force_push/positive.jsonl +5 -0
  86. package/rules/tests/exec_git_global_hooks/negative.jsonl +3 -0
  87. package/rules/tests/exec_git_global_hooks/positive.jsonl +2 -0
  88. package/rules/tests/exec_lolbin_download/negative.jsonl +3 -0
  89. package/rules/tests/exec_lolbin_download/positive.jsonl +4 -0
  90. package/rules/tests/exec_mass_delete/negative.jsonl +49 -0
  91. package/rules/tests/exec_mass_delete/positive.jsonl +25 -0
  92. package/rules/tests/exec_package_install_new/negative.jsonl +17 -0
  93. package/rules/tests/exec_package_install_new/positive.jsonl +13 -0
  94. package/rules/tests/exec_pipe_download_to_shell/negative.jsonl +15 -0
  95. package/rules/tests/exec_pipe_download_to_shell/positive.jsonl +45 -0
  96. package/rules/tests/exec_rm_recursive_dangerous/negative.jsonl +8 -0
  97. package/rules/tests/exec_rm_recursive_dangerous/positive.jsonl +11 -0
  98. package/rules/tests/exec_vulnerable_agent_version/negative.jsonl +5 -0
  99. package/rules/tests/exec_vulnerable_agent_version/positive.jsonl +2 -0
  100. package/rules/tests/files_instruction_concealment/negative.jsonl +1 -0
  101. package/rules/tests/files_instruction_concealment/positive.jsonl +3 -0
  102. package/rules/tests/files_instruction_concealment_skill/negative.jsonl +3 -0
  103. package/rules/tests/files_instruction_concealment_skill/positive.jsonl +1 -0
  104. package/rules/tests/files_invisible_unicode_instruction/negative.jsonl +2 -0
  105. package/rules/tests/files_invisible_unicode_instruction/positive.jsonl +2 -0
  106. package/rules/tests/files_invisible_unicode_skill/negative.jsonl +3 -0
  107. package/rules/tests/files_invisible_unicode_skill/positive.jsonl +1 -0
  108. package/rules/tests/files_invisible_unicode_write/negative.jsonl +2 -0
  109. package/rules/tests/files_invisible_unicode_write/positive.jsonl +2 -0
  110. package/rules/tests/files_mcp_server_added/negative.jsonl +2 -0
  111. package/rules/tests/files_mcp_server_added/positive.jsonl +2 -0
  112. package/rules/tests/files_mcp_server_command/negative.jsonl +1 -0
  113. package/rules/tests/files_mcp_server_command/positive.jsonl +2 -0
  114. package/rules/tests/files_npm_lifecycle_script/negative.jsonl +3 -0
  115. package/rules/tests/files_npm_lifecycle_script/positive.jsonl +3 -0
  116. package/rules/tests/files_persistence_command/negative.jsonl +3 -0
  117. package/rules/tests/files_persistence_command/positive.jsonl +4 -0
  118. package/rules/tests/files_persistence_location/negative.jsonl +1 -0
  119. package/rules/tests/files_persistence_location/positive.jsonl +4 -0
  120. package/rules/tests/files_vscode_task_autorun/negative.jsonl +3 -0
  121. package/rules/tests/files_vscode_task_autorun/positive.jsonl +1 -0
  122. package/rules/tests/files_write_outside_project/negative.jsonl +9 -0
  123. package/rules/tests/files_write_outside_project/positive.jsonl +3 -0
  124. package/rules/tests/network_paste_filedrop_command/negative.jsonl +2 -0
  125. package/rules/tests/network_paste_filedrop_command/positive.jsonl +3 -0
  126. package/rules/tests/network_paste_filedrop_domains/negative.jsonl +3 -0
  127. package/rules/tests/network_paste_filedrop_domains/positive.jsonl +3 -0
  128. package/rules/tests/secrets_credential_store_access/negative.jsonl +8 -0
  129. package/rules/tests/secrets_credential_store_access/positive.jsonl +8 -0
  130. package/rules/tests/secrets_credential_store_probe/negative.jsonl +4 -0
  131. package/rules/tests/secrets_credential_store_probe/positive.jsonl +3 -0
  132. package/rules/tests/secrets_env_dump/negative.jsonl +23 -0
  133. package/rules/tests/secrets_env_dump/positive.jsonl +26 -0
  134. package/rules/tests/secrets_literal_in_tool_input/negative.jsonl +5 -0
  135. package/rules/tests/secrets_literal_in_tool_input/positive.jsonl +5 -0
  136. package/rules/tests/secrets_read_secret_file/negative.jsonl +5 -0
  137. package/rules/tests/secrets_read_secret_file/positive.jsonl +5 -0
  138. package/rules/tests/secrets_read_secret_file_shell/negative.jsonl +9 -0
  139. package/rules/tests/secrets_read_secret_file_shell/positive.jsonl +6 -0
  140. package/rules/tests/secrets_read_then_egress/negative.jsonl +10 -0
  141. package/rules/tests/secrets_read_then_egress/positive.jsonl +4 -0
  142. package/rules/tests/secrets_read_then_mcp_payload/negative.jsonl +4 -0
  143. package/rules/tests/secrets_read_then_mcp_payload/positive.jsonl +2 -0
package/dist/cli.mjs ADDED
@@ -0,0 +1,364 @@
1
+ #!/usr/bin/env node
2
+ /*rh-warn*/{const e=process.emitWarning;process.emitWarning=function(w,...a){const t=typeof a[0]==="string"?a[0]:a[0]?.type;if(t==="ExperimentalWarning"&&/^SQLite\b/.test(String(w?.message??w)))return;return e.call(this,w,...a)}}
3
+ import{createRequire as cf}from"node:module";var nf=Object.create;var{getPrototypeOf:sf,defineProperty:Nr,getOwnPropertyNames:rf}=Object;var Lr=Object.prototype.hasOwnProperty;function of(e){return this[e]}var af,lf,Ir=(e,t,n)=>{var s=e!=null&&typeof e==="object";if(s){var i=t?af??=new WeakMap:lf??=new WeakMap,r=i.get(e);if(r)return r}n=e!=null?nf(sf(e)):{};let o=t||!e||!e.__esModule||!Lr.call(e,"default")?Nr(n,"default",{value:e,enumerable:!0}):n;if(e&&typeof e==="object"||typeof e==="function"){for(let a of rf(e))if(!Lr.call(o,a))Nr(o,a,{get:of.bind(e,a),enumerable:!0})}if(s)i.set(e,o);return o};var k=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var sn=cf(import.meta.url);var R=k(function(Fp){var Qs=Symbol.for("yaml.alias"),zo=Symbol.for("yaml.document"),yn=Symbol.for("yaml.map"),Xo=Symbol.for("yaml.pair"),Zs=Symbol.for("yaml.scalar"),wn=Symbol.for("yaml.seq"),ce=Symbol.for("yaml.node.type"),Lp=(e)=>!!e&&typeof e==="object"&&e[ce]===Qs,Ip=(e)=>!!e&&typeof e==="object"&&e[ce]===zo,Pp=(e)=>!!e&&typeof e==="object"&&e[ce]===yn,qp=(e)=>!!e&&typeof e==="object"&&e[ce]===Xo,Qo=(e)=>!!e&&typeof e==="object"&&e[ce]===Zs,Dp=(e)=>!!e&&typeof e==="object"&&e[ce]===wn;function Zo(e){if(e&&typeof e==="object")switch(e[ce]){case yn:case wn:return!0}return!1}function jp(e){if(e&&typeof e==="object")switch(e[ce]){case Qs:case yn:case Zs:case wn:return!0}return!1}var Mp=(e)=>(Qo(e)||Zo(e))&&!!e.anchor;Fp.ALIAS=Qs;Fp.DOC=zo;Fp.MAP=yn;Fp.NODE_TYPE=ce;Fp.PAIR=Xo;Fp.SCALAR=Zs;Fp.SEQ=wn;Fp.hasAnchor=Mp;Fp.isAlias=Lp;Fp.isCollection=Zo;Fp.isDocument=Ip;Fp.isMap=Pp;Fp.isNode=jp;Fp.isPair=qp;Fp.isScalar=Qo;Fp.isSeq=Dp});var _t=k(function(sh){var F=R(),J=Symbol("break visit"),ea=Symbol("skip children"),ie=Symbol("remove node");function bn(e,t){let n=ta(t);if(F.isDocument(e)){if(Ge(null,e.contents,n,Object.freeze([e]))===ie)e.contents=null}else Ge(null,e,n,Object.freeze([]))}bn.BREAK=J;bn.SKIP=ea;bn.REMOVE=ie;function Ge(e,t,n,s){let i=na(e,t,n,s);if(F.isNode(i)||F.isPair(i))return sa(e,s,i),Ge(e,i,n,s);if(typeof i!=="symbol"){if(F.isCollection(t)){s=Object.freeze(s.concat(t));for(let r=0;r<t.items.length;++r){let o=Ge(r,t.items[r],n,s);if(typeof o==="number")r=o-1;else if(o===J)return J;else if(o===ie)t.items.splice(r,1),r-=1}}else if(F.isPair(t)){s=Object.freeze(s.concat(t));let r=Ge("key",t.key,n,s);if(r===J)return J;else if(r===ie)t.key=null;let o=Ge("value",t.value,n,s);if(o===J)return J;else if(o===ie)t.value=null}}return i}async function _n(e,t){let n=ta(t);if(F.isDocument(e)){if(await Ye(null,e.contents,n,Object.freeze([e]))===ie)e.contents=null}else await Ye(null,e,n,Object.freeze([]))}_n.BREAK=J;_n.SKIP=ea;_n.REMOVE=ie;async function Ye(e,t,n,s){let i=await na(e,t,n,s);if(F.isNode(i)||F.isPair(i))return sa(e,s,i),Ye(e,i,n,s);if(typeof i!=="symbol"){if(F.isCollection(t)){s=Object.freeze(s.concat(t));for(let r=0;r<t.items.length;++r){let o=await Ye(r,t.items[r],n,s);if(typeof o==="number")r=o-1;else if(o===J)return J;else if(o===ie)t.items.splice(r,1),r-=1}}else if(F.isPair(t)){s=Object.freeze(s.concat(t));let r=await Ye("key",t.key,n,s);if(r===J)return J;else if(r===ie)t.key=null;let o=await Ye("value",t.value,n,s);if(o===J)return J;else if(o===ie)t.value=null}}return i}function ta(e){if(typeof e==="object"&&(e.Collection||e.Node||e.Value))return Object.assign({Alias:e.Node,Map:e.Node,Scalar:e.Node,Seq:e.Node},e.Value&&{Map:e.Value,Scalar:e.Value,Seq:e.Value},e.Collection&&{Map:e.Collection,Seq:e.Collection},e);return e}function na(e,t,n,s){if(typeof n==="function")return n(e,t,s);if(F.isMap(t))return n.Map?.(e,t,s);if(F.isSeq(t))return n.Seq?.(e,t,s);if(F.isPair(t))return n.Pair?.(e,t,s);if(F.isScalar(t))return n.Scalar?.(e,t,s);if(F.isAlias(t))return n.Alias?.(e,t,s);return}function sa(e,t,n){let s=t[t.length-1];if(F.isCollection(s))s.items[e]=n;else if(F.isPair(s))if(e==="key")s.key=n;else s.value=n;else if(F.isDocument(s))s.contents=n;else{let i=F.isAlias(s)?"alias":"scalar";throw Error(`Cannot replace node with ${i} parent`)}}sh.visit=bn;sh.visitAsync=_n});var ei=k(function(ch){var ia=R(),oh=_t(),ah={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},lh=(e)=>e.replace(/[!,[\]{}]/g,(t)=>ah[t]);class Q{constructor(e,t){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},Q.defaultYaml,e),this.tags=Object.assign({},Q.defaultTags,t)}clone(){let e=new Q(this.yaml,this.tags);return e.docStart=this.docStart,e}atDocument(){let e=new Q(this.yaml,this.tags);switch(this.yaml.version){case"1.1":this.atNextDocument=!0;break;case"1.2":this.atNextDocument=!1,this.yaml={explicit:Q.defaultYaml.explicit,version:"1.2"},this.tags=Object.assign({},Q.defaultTags);break}return e}add(e,t){if(this.atNextDocument)this.yaml={explicit:Q.defaultYaml.explicit,version:"1.1"},this.tags=Object.assign({},Q.defaultTags),this.atNextDocument=!1;let n=e.trim().split(/[ \t]+/),s=n.shift();switch(s){case"%TAG":{if(n.length!==2){if(t(0,"%TAG directive should contain exactly two parts"),n.length<2)return!1}let[i,r]=n;return this.tags[i]=r,!0}case"%YAML":{if(this.yaml.explicit=!0,n.length!==1)return t(0,"%YAML directive should contain exactly one part"),!1;let[i]=n;if(i==="1.1"||i==="1.2")return this.yaml.version=i,!0;else{let r=/^\d+\.\d+$/.test(i);return t(6,`Unsupported YAML version ${i}`,r),!1}}default:return t(0,`Unknown directive ${s}`,!0),!1}}tagName(e,t){if(e==="!")return"!";if(e[0]!=="!")return t(`Not a valid tag: ${e}`),null;if(e[1]==="<"){let r=e.slice(2,-1);if(r==="!"||r==="!!")return t(`Verbatim tags aren't resolved, so ${e} is invalid.`),null;if(e[e.length-1]!==">")t("Verbatim tags must end with a >");return r}let[,n,s]=e.match(/^(.*!)([^!]*)$/s);if(!s)t(`The ${e} tag has no suffix`);let i=this.tags[n];if(i)try{return i+decodeURIComponent(s)}catch(r){return t(String(r)),null}if(n==="!")return e;return t(`Could not resolve tag: ${e}`),null}tagString(e){for(let[t,n]of Object.entries(this.tags))if(e.startsWith(n))return t+lh(e.substring(n.length));return e[0]==="!"?e:`!<${e}>`}toString(e){let t=this.yaml.explicit?[`%YAML ${this.yaml.version||"1.2"}`]:[],n=Object.entries(this.tags),s;if(e&&n.length>0&&ia.isNode(e.contents)){let i={};oh.visit(e.contents,(r,o)=>{if(ia.isNode(o)&&o.tag)i[o.tag]=!0}),s=Object.keys(i)}else s=[];for(let[i,r]of n){if(i==="!!"&&r==="tag:yaml.org,2002:")continue;if(!e||s.some((o)=>o.startsWith(r)))t.push(`%TAG ${i} ${r}`)}return t.join(`
4
+ `)}}Q.defaultYaml={explicit:!1,version:"1.2"};Q.defaultTags={"!!":"tag:yaml.org,2002:"};ch.Directives=Q});var Sn=k(function(hh){var ra=R(),fh=_t();function dh(e){if(/[\x00-\x19\s,[\]{}]/.test(e)){let n=`Anchor must not contain whitespace or control characters: ${JSON.stringify(e)}`;throw Error(n)}return!0}function oa(e){let t=new Set;return fh.visit(e,{Value(n,s){if(s.anchor)t.add(s.anchor)}}),t}function aa(e,t){for(let n=1;;++n){let s=`${e}${n}`;if(!t.has(s))return s}}function ph(e,t){let n=[],s=new Map,i=null;return{onAnchor:(r)=>{n.push(r),i??(i=oa(e));let o=aa(t,i);return i.add(o),o},setAnchors:()=>{for(let r of n){let o=s.get(r);if(typeof o==="object"&&o.anchor&&(ra.isScalar(o.node)||ra.isCollection(o.node)))o.node.anchor=o.anchor;else{let a=Error("Failed to resolve repeated object (this should not happen)");throw a.source=r,a}}},sourceObjects:s}}hh.anchorIsValid=dh;hh.anchorNames=oa;hh.createNodeAnchors=ph;hh.findNewAnchor=aa});var ti=k(function(bh){function St(e,t,n,s){if(s&&typeof s==="object")if(Array.isArray(s))for(let i=0,r=s.length;i<r;++i){let o=s[i],a=St(e,s,String(i),o);if(a===void 0)delete s[i];else if(a!==o)s[i]=a}else if(s instanceof Map)for(let i of Array.from(s.keys())){let r=s.get(i),o=St(e,s,i,r);if(o===void 0)s.delete(i);else if(o!==r)s.set(i,o)}else if(s instanceof Set)for(let i of Array.from(s)){let r=St(e,s,i,i);if(r===void 0)s.delete(i);else if(r!==i)s.delete(i),s.add(r)}else for(let[i,r]of Object.entries(s)){let o=St(e,s,i,r);if(o===void 0)delete s[i];else if(o!==r)s[i]=o}return e.call(t,n,s)}bh.applyReviver=St});var ge=k(function(vh){var Sh=R();function la(e,t,n){if(Array.isArray(e))return e.map((s,i)=>la(s,String(i),n));if(e&&typeof e.toJSON==="function"){if(!n||!Sh.hasAnchor(e))return e.toJSON(t,n);let s={aliasCount:0,count:1,res:void 0};n.anchors.set(e,s),n.onCreate=(r)=>{s.res=r,delete n.onCreate};let i=e.toJSON(t,n);if(n.onCreate)n.onCreate(i);return i}if(typeof e==="bigint"&&!n?.keep)return Number(e);return e}vh.toJS=la});var vn=k(function(xh){var kh=ti(),ca=R(),Oh=ge();class ua{constructor(e){Object.defineProperty(this,ca.NODE_TYPE,{value:e})}clone(){let e=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));if(this.range)e.range=this.range.slice();return e}toJS(e,{mapAsMap:t,maxAliasCount:n,onAnchor:s,reviver:i}={}){if(!ca.isDocument(e))throw TypeError("A document argument is required");let r={anchors:new Map,doc:e,keep:!0,mapAsMap:t===!0,mapKeyWarned:!1,maxAliasCount:typeof n==="number"?n:100},o=Oh.toJS(this,"",r);if(typeof s==="function")for(let{count:a,res:l}of r.anchors.values())s(l,a);return typeof i==="function"?kh.applyReviver(i,{"":o},"",o):o}}xh.NodeBase=ua});var vt=k(function(Nh){var Ch=Sn(),Th=_t(),ze=R(),Rh=vn(),$h=ge();class fa extends Rh.NodeBase{constructor(e){super(ze.ALIAS);this.source=e,Object.defineProperty(this,"tag",{set(){throw Error("Alias nodes cannot have tags")}})}resolve(e,t){if(t?.maxAliasCount===0)throw ReferenceError("Alias resolution is disabled");let n;if(t?.aliasResolveCache)n=t.aliasResolveCache;else if(n=[],Th.visit(e,{Node:(i,r)=>{if(ze.isAlias(r)||ze.hasAnchor(r))n.push(r)}}),t)t.aliasResolveCache=n;let s=void 0;for(let i of n){if(i===this)break;if(i.anchor===this.source)s=i}if(s&&t){let{anchors:i,doc:r,maxAliasCount:o}=t,a=i.get(s);if(!a)$h.toJS(s,null,t),a=i.get(s);if(a?.res===void 0)throw ReferenceError("This should not happen: Alias anchor was not resolved?");if(o>=0){if(a.count+=1,a.aliasCount===0)a.aliasCount=En(r,s,i);if(a.count*a.aliasCount>o)throw ReferenceError("Excessive alias count indicates a resource exhaustion attack")}}return s}toJSON(e,t){if(!t)return{source:this.source};let n=this.resolve(t.doc,t);if(!n){let s=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw ReferenceError(s)}return t.anchors.get(n).res}toString(e,t,n){let s=`*${this.source}`;if(e){if(Ch.anchorIsValid(this.source),e.options.verifyAliasOrder&&!e.anchors.has(this.source)){let i=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw Error(i)}if(e.implicitKey)return`${s} `}return s}}function En(e,t,n){if(ze.isAlias(t)){let s=t.resolve(e),i=n&&s&&n.get(s);return i?i.count*i.aliasCount:0}else if(ze.isCollection(t)){let s=0;for(let i of t.items){let r=En(e,i,n);if(r>s)s=r}return s}else if(ze.isPair(t)){let s=En(e,t.key,n),i=En(e,t.value,n);return Math.max(s,i)}return 1}Nh.Alias=fa});var j=k(function(jh){var Ih=R(),Ph=vn(),qh=ge(),Dh=(e)=>!e||typeof e!=="function"&&typeof e!=="object";class Te extends Ph.NodeBase{constructor(e){super(Ih.SCALAR);this.value=e}toJSON(e,t){return t?.keep?this.value:qh.toJS(this.value,e,t)}toString(){return String(this.value)}}Te.BLOCK_FOLDED="BLOCK_FOLDED";Te.BLOCK_LITERAL="BLOCK_LITERAL";Te.PLAIN="PLAIN";Te.QUOTE_DOUBLE="QUOTE_DOUBLE";Te.QUOTE_SINGLE="QUOTE_SINGLE";jh.Scalar=Te;jh.isScalarValue=Dh});var Et=k(function(Hh){var Uh=vt(),Re=R(),da=j(),Bh="tag:yaml.org,2002:";function Vh(e,t,n){if(t){let s=n.filter((r)=>r.tag===t),i=s.find((r)=>!r.format)??s[0];if(!i)throw Error(`Tag ${t} not found`);return i}return n.find((s)=>s.identify?.(e)&&!s.format)}function Wh(e,t,n){if(Re.isDocument(e))e=e.contents;if(Re.isNode(e))return e;if(Re.isPair(e)){let f=n.schema[Re.MAP].createNode?.(n.schema,null,n);return f.items.push(e),f}if(e instanceof String||e instanceof Number||e instanceof Boolean||typeof BigInt<"u"&&e instanceof BigInt)e=e.valueOf();let{aliasDuplicateObjects:s,onAnchor:i,onTagObj:r,schema:o,sourceObjects:a}=n,l=void 0;if(s&&e&&typeof e==="object")if(l=a.get(e),l)return l.anchor??(l.anchor=i(e)),new Uh.Alias(l.anchor);else l={anchor:null,node:null},a.set(e,l);if(t?.startsWith("!!"))t=Bh+t.slice(2);let c=Vh(e,t,o.tags);if(!c){if(e&&typeof e.toJSON==="function")e=e.toJSON();if(!e||typeof e!=="object"){let f=new da.Scalar(e);if(l)l.node=f;return f}c=e instanceof Map?o[Re.MAP]:(Symbol.iterator in Object(e))?o[Re.SEQ]:o[Re.MAP]}if(r)r(c),delete n.onTagObj;let u=c?.createNode?c.createNode(n.schema,e,n):typeof c?.nodeClass?.from==="function"?c.nodeClass.from(n.schema,e,n):new da.Scalar(e);if(t)u.tag=t;else if(!c.default)u.tag=c.tag;if(l)l.node=u;return u}Hh.createNode=Wh});var kn=k(function(Yh){var Jh=Et(),re=R(),Gh=vn();function ni(e,t,n){let s=n;for(let i=t.length-1;i>=0;--i){let r=t[i];if(typeof r==="number"&&Number.isInteger(r)&&r>=0){let o=[];o[r]=s,s=o}else s=new Map([[r,s]])}return Jh.createNode(s,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw Error("This should not happen, please report a bug.")},schema:e,sourceObjects:new Map})}var pa=(e)=>e==null||typeof e==="object"&&!!e[Symbol.iterator]().next().done;class ha extends Gh.NodeBase{constructor(e,t){super(e);Object.defineProperty(this,"schema",{value:t,configurable:!0,enumerable:!1,writable:!0})}clone(e){let t=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));if(e)t.schema=e;if(t.items=t.items.map((n)=>re.isNode(n)||re.isPair(n)?n.clone(e):n),this.range)t.range=this.range.slice();return t}addIn(e,t){if(pa(e))this.add(t);else{let[n,...s]=e,i=this.get(n,!0);if(re.isCollection(i))i.addIn(s,t);else if(i===void 0&&this.schema)this.set(n,ni(this.schema,s,t));else throw Error(`Expected YAML collection at ${n}. Remaining path: ${s}`)}}deleteIn(e){let[t,...n]=e;if(n.length===0)return this.delete(t);let s=this.get(t,!0);if(re.isCollection(s))return s.deleteIn(n);else throw Error(`Expected YAML collection at ${t}. Remaining path: ${n}`)}getIn(e,t){let[n,...s]=e,i=this.get(n,!0);if(s.length===0)return!t&&re.isScalar(i)?i.value:i;else return re.isCollection(i)?i.getIn(s,t):void 0}hasAllNullValues(e){return this.items.every((t)=>{if(!re.isPair(t))return!1;let n=t.value;return n==null||e&&re.isScalar(n)&&n.value==null&&!n.commentBefore&&!n.comment&&!n.tag})}hasIn(e){let[t,...n]=e;if(n.length===0)return this.has(t);let s=this.get(t,!0);return re.isCollection(s)?s.hasIn(n):!1}setIn(e,t){let[n,...s]=e;if(s.length===0)this.set(n,t);else{let i=this.get(n,!0);if(re.isCollection(i))i.setIn(s,t);else if(i===void 0&&this.schema)this.set(n,ni(this.schema,s,t));else throw Error(`Expected YAML collection at ${n}. Remaining path: ${s}`)}}}Yh.Collection=ha;Yh.collectionFromPath=ni;Yh.isEmptyPath=pa});var kt=k(function(tm){var Zh=(e)=>e.replace(/^(?!$)(?: $)?/gm,"#");function si(e,t){if(/^\n+$/.test(e))return e.substring(1);return t?e.replace(/^(?! *$)/gm,t):e}var em=(e,t,n)=>e.endsWith(`
5
+ `)?si(n,t):n.includes(`
6
+ `)?`
7
+ `+si(n,t):(e.endsWith(" ")?"":" ")+n;tm.indentComment=si;tm.lineComment=em;tm.stringifyComment=Zh});var ga=k(function(om){function rm(e,t,n="flow",{indentAtStart:s,lineWidth:i=80,minContentWidth:r=20,onFold:o,onOverflow:a}={}){if(!i||i<0)return e;if(i<r)r=0;let l=Math.max(1+r,1+i-t.length);if(e.length<=l)return e;let c=[],u={},f=i-t.length;if(typeof s==="number")if(s>i-Math.max(2,r))c.push(0);else f=i-s;let d=void 0,h=void 0,g=!1,p=-1,m=-1,O=-1;if(n==="block"){if(p=ma(e,p,t.length),p!==-1)f=p+l}for(let v;v=e[p+=1];){if(n==="quoted"&&v==="\\"){switch(m=p,e[p+1]){case"x":p+=3;break;case"u":p+=5;break;case"U":p+=9;break;default:p+=1}O=p}if(v===`
8
+ `){if(n==="block")p=ma(e,p,t.length);f=p+t.length+l,d=void 0}else{if(v===" "&&h&&h!==" "&&h!==`
9
+ `&&h!=="\t"){let _=e[p+1];if(_&&_!==" "&&_!==`
10
+ `&&_!=="\t")d=p}if(p>=f)if(d)c.push(d),f=d+l,d=void 0;else if(n==="quoted"){while(h===" "||h==="\t")h=v,v=e[p+=1],g=!0;let _=p>O+1?p-2:m-1;if(u[_])return e;c.push(_),u[_]=!0,f=_+l,d=void 0}else g=!0}h=v}if(g&&a)a();if(c.length===0)return e;if(o)o();let y=e.slice(0,c[0]);for(let v=0;v<c.length;++v){let _=c[v],A=c[v+1]||e.length;if(_===0)y=`
11
+ ${t}${e.slice(0,A)}`;else{if(n==="quoted"&&u[_])y+=`${e[_]}\\`;y+=`
12
+ ${t}${e.slice(_+1,A)}`}}return y}function ma(e,t,n){let s=t,i=t+1,r=e[i];while(r===" "||r==="\t")if(t<i+n)r=e[++t];else{do r=e[++t];while(r&&r!==`
13
+ `);s=t,i=t+1,r=e[i]}return s}om.FOLD_BLOCK="block";om.FOLD_FLOW="flow";om.FOLD_QUOTED="quoted";om.foldFlowLines=rm});var xt=k(function(hm){var ee=j(),ye=ga(),xn=(e,t)=>({indentAtStart:t?e.indent.length:e.indentAtStart,lineWidth:e.options.lineWidth,minContentWidth:e.options.minContentWidth}),An=(e)=>/^(%|---|\.\.\.)/m.test(e);function fm(e,t,n){if(!t||t<0)return!1;let s=t-n,i=e.length;if(i<=s)return!1;for(let r=0,o=0;r<i;++r)if(e[r]===`
14
+ `){if(r-o>s)return!0;if(o=r+1,i-o<=s)return!1}return!0}function Ot(e,t){let n=JSON.stringify(e);if(t.options.doubleQuotedAsJSON)return n;let{implicitKey:s}=t,i=t.options.doubleQuotedMinMultiLineLength,r=t.indent||(An(e)?" ":""),o="",a=0;for(let l=0,c=n[l];c;c=n[++l]){if(c===" "&&n[l+1]==="\\"&&n[l+2]==="n")o+=n.slice(a,l)+"\\ ",l+=1,a=l,c="\\";if(c==="\\")switch(n[l+1]){case"u":{o+=n.slice(a,l);let u=n.substr(l+2,4);switch(u){case"0000":o+="\\0";break;case"0007":o+="\\a";break;case"000b":o+="\\v";break;case"001b":o+="\\e";break;case"0085":o+="\\N";break;case"00a0":o+="\\_";break;case"2028":o+="\\L";break;case"2029":o+="\\P";break;default:if(u.substr(0,2)==="00")o+="\\x"+u.substr(2);else o+=n.substr(l,6)}l+=5,a=l+1}break;case"n":if(s||n[l+2]==='"'||n.length<i)l+=1;else{o+=n.slice(a,l)+`
15
+
16
+ `;while(n[l+2]==="\\"&&n[l+3]==="n"&&n[l+4]!=='"')o+=`
17
+ `,l+=2;if(o+=r,n[l+2]===" ")o+="\\";l+=1,a=l+1}break;default:l+=1}}return o=a?o+n.slice(a):n,s?o:ye.foldFlowLines(o,r,ye.FOLD_QUOTED,xn(t,!1))}function ii(e,t){if(t.options.singleQuote===!1||t.implicitKey&&e.includes(`
18
+ `)||/[ \t]\n|\n[ \t]/.test(e))return Ot(e,t);let n=t.indent||(An(e)?" ":""),s="'"+e.replace(/'/g,"''").replace(/\n+/g,`$&
19
+ ${n}`)+"'";return t.implicitKey?s:ye.foldFlowLines(s,n,ye.FOLD_FLOW,xn(t,!1))}function Xe(e,t){let{singleQuote:n}=t.options,s;if(n===!1)s=Ot;else{let i=e.includes('"'),r=e.includes("'");if(i&&!r)s=ii;else if(r&&!i)s=Ot;else s=n?ii:Ot}return s(e,t)}var ri;try{ri=new RegExp(`(^|(?<!
20
+ ))
21
+ +(?!
22
+ |$)`,"g")}catch{ri=/\n+(?!\n|$)/g}function On({comment:e,type:t,value:n},s,i,r){let{blockQuote:o,commentString:a,lineWidth:l}=s.options;if(!o||/\n[\t ]+$/.test(n))return Xe(n,s);let c=s.indent||(s.forceBlockIndent||An(n)?" ":""),u=o==="literal"?!0:o==="folded"||t===ee.Scalar.BLOCK_FOLDED?!1:t===ee.Scalar.BLOCK_LITERAL?!0:!fm(n,l,c.length);if(!n)return u?`|
23
+ `:`>
24
+ `;let f,d;for(d=n.length;d>0;--d){let A=n[d-1];if(A!==`
25
+ `&&A!=="\t"&&A!==" ")break}let h=n.substring(d),g=h.indexOf(`
26
+ `);if(g===-1)f="-";else if(n===h||g!==h.length-1){if(f="+",r)r()}else f="";if(h){if(n=n.slice(0,-h.length),h[h.length-1]===`
27
+ `)h=h.slice(0,-1);h=h.replace(ri,`$&${c}`)}let p=!1,m,O=-1;for(m=0;m<n.length;++m){let A=n[m];if(A===" ")p=!0;else if(A===`
28
+ `)O=m;else break}let y=n.substring(0,O<m?O+1:m);if(y)n=n.substring(y.length),y=y.replace(/\n+/g,`$&${c}`);let _=(p?c?"2":"1":"")+f;if(e){if(_+=" "+a(e.replace(/ ?[\r\n]+/g," ")),i)i()}if(!u){let A=n.replace(/\n+/g,`
29
+ $&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,"$1$2").replace(/\n+/g,`$&${c}`),b=!1,S=xn(s,!0);if(o!=="folded"&&t!==ee.Scalar.BLOCK_FOLDED)S.onOverflow=()=>{b=!0};let w=ye.foldFlowLines(`${y}${A}${h}`,c,ye.FOLD_BLOCK,S);if(!b)return`>${_}
30
+ ${c}${w}`}return n=n.replace(/\n+/g,`$&${c}`),`|${_}
31
+ ${c}${y}${n}${h}`}function dm(e,t,n,s){let{type:i,value:r}=e,{actualString:o,implicitKey:a,indent:l,indentStep:c,inFlow:u}=t;if(a&&r.includes(`
32
+ `)||u&&/[[\]{},]/.test(r))return Xe(r,t);if(/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(r))return a||u||!r.includes(`
33
+ `)?Xe(r,t):On(e,t,n,s);if(!a&&!u&&i!==ee.Scalar.PLAIN&&r.includes(`
34
+ `))return On(e,t,n,s);if(An(r)){if(l==="")return t.forceBlockIndent=!0,On(e,t,n,s);else if(a&&l===c)return Xe(r,t)}let f=r.replace(/\n+/g,`$&
35
+ ${l}`);if(o){let d=(p)=>p.default&&p.tag!=="tag:yaml.org,2002:str"&&p.test?.test(f),{compat:h,tags:g}=t.doc.schema;if(g.some(d)||h?.some(d))return Xe(r,t)}return a?f:ye.foldFlowLines(f,l,ye.FOLD_FLOW,xn(t,!1))}function pm(e,t,n,s){let{implicitKey:i,inFlow:r}=t,o=typeof e.value==="string"?e:Object.assign({},e,{value:String(e.value)}),{type:a}=e;if(a!==ee.Scalar.QUOTE_DOUBLE){if(/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(o.value))a=ee.Scalar.QUOTE_DOUBLE}let l=(u)=>{switch(u){case ee.Scalar.BLOCK_FOLDED:case ee.Scalar.BLOCK_LITERAL:return i||r?Xe(o.value,t):On(o,t,n,s);case ee.Scalar.QUOTE_DOUBLE:return Ot(o.value,t);case ee.Scalar.QUOTE_SINGLE:return ii(o.value,t);case ee.Scalar.PLAIN:return dm(o,t,n,s);default:return null}},c=l(a);if(c===null){let{defaultKeyType:u,defaultStringType:f}=t.options,d=i&&u||f;if(c=l(d),c===null)throw Error(`Unsupported default string type ${d}`)}return c}hm.stringifyString=pm});var At=k(function(Em){var gm=Sn(),we=R(),ym=kt(),wm=xt();function bm(e,t){let n=Object.assign({blockQuote:!0,commentString:ym.stringifyComment,defaultKeyType:null,defaultStringType:"PLAIN",directives:null,doubleQuotedAsJSON:!1,doubleQuotedMinMultiLineLength:40,falseStr:"false",flowCollectionPadding:!0,indentSeq:!0,lineWidth:80,minContentWidth:20,nullStr:"null",simpleKeys:!1,singleQuote:null,trailingComma:!1,trueStr:"true",verifyAliasOrder:!0},e.schema.toStringOptions,t),s;switch(n.collectionStyle){case"block":s=!1;break;case"flow":s=!0;break;default:s=null}return{anchors:new Set,doc:e,flowCollectionPadding:n.flowCollectionPadding?" ":"",indent:"",indentStep:typeof n.indent==="number"?" ".repeat(n.indent):" ",inFlow:s,options:n}}function _m(e,t){if(t.tag){let i=e.filter((r)=>r.tag===t.tag);if(i.length>0)return i.find((r)=>r.format===t.format)??i[0]}let n=void 0,s;if(we.isScalar(t)){s=t.value;let i=e.filter((r)=>r.identify?.(s));if(i.length>1){let r=i.filter((o)=>o.test);if(r.length>0)i=r}n=i.find((r)=>r.format===t.format)??i.find((r)=>!r.format)}else s=t,n=e.find((i)=>i.nodeClass&&s instanceof i.nodeClass);if(!n){let i=s?.constructor?.name??(s===null?"null":typeof s);throw Error(`Tag not resolved for ${i} value`)}return n}function Sm(e,t,{anchors:n,doc:s}){if(!s.directives)return"";let i=[],r=(we.isScalar(e)||we.isCollection(e))&&e.anchor;if(r&&gm.anchorIsValid(r))n.add(r),i.push(`&${r}`);let o=e.tag??(t.default?null:t.tag);if(o)i.push(s.directives.tagString(o));return i.join(" ")}function vm(e,t,n,s){if(we.isPair(e))return e.toString(t,n,s);if(we.isAlias(e)){if(t.doc.directives)return e.toString(t);if(t.resolvedAliases?.has(e))throw TypeError("Cannot stringify circular structure without alias nodes");else{if(t.resolvedAliases)t.resolvedAliases.add(e);else t.resolvedAliases=new Set([e]);e=e.resolve(t.doc)}}let i=void 0,r=we.isNode(e)?e:t.doc.createNode(e,{onTagObj:(l)=>i=l});i??(i=_m(t.doc.schema.tags,r));let o=Sm(r,i,t);if(o.length>0)t.indentAtStart=(t.indentAtStart??0)+o.length+1;let a=typeof i.stringify==="function"?i.stringify(r,t,n,s):we.isScalar(r)?wm.stringifyString(r,t,n,s):r.toString(t,n,s);if(!o)return a;return we.isScalar(r)||a[0]==="{"||a[0]==="["?`${o} ${a}`:`${o}
36
+ ${t.indent}${a}`}Em.createStringifyContext=bm;Em.stringify=vm});var ba=k(function(Am){var ue=R(),ya=j(),wa=At(),Ct=kt();function xm({key:e,value:t},n,s,i){let{allNullValues:r,doc:o,indent:a,indentStep:l,options:{commentString:c,indentSeq:u,simpleKeys:f}}=n,d=ue.isNode(e)&&e.comment||null;if(f){if(d)throw Error("With simple keys, key nodes cannot have comments");if(ue.isCollection(e)||!ue.isNode(e)&&typeof e==="object")throw Error("With simple keys, collection cannot be used as a key value")}let h=!f&&(!e||d&&t==null&&!n.inFlow||ue.isCollection(e)||(ue.isScalar(e)?e.type===ya.Scalar.BLOCK_FOLDED||e.type===ya.Scalar.BLOCK_LITERAL:typeof e==="object"));n=Object.assign({},n,{allNullValues:!1,implicitKey:!h&&(f||!r),indent:a+l});let g=!1,p=!1,m=wa.stringify(e,n,()=>g=!0,()=>p=!0);if(!h&&!n.inFlow&&m.length>1024){if(f)throw Error("With simple keys, single line scalar must not span more than 1024 characters");h=!0}if(n.inFlow){if(r||t==null){if(g&&s)s();return m===""?"?":h?`? ${m}`:m}}else if(r&&!f||t==null&&h){if(m=`? ${m}`,d&&!g)m+=Ct.lineComment(m,n.indent,c(d));else if(p&&i)i();return m}if(g)d=null;if(h){if(d)m+=Ct.lineComment(m,n.indent,c(d));m=`? ${m}
37
+ ${a}:`}else if(m=`${m}:`,d)m+=Ct.lineComment(m,n.indent,c(d));let O,y,v;if(ue.isNode(t))O=!!t.spaceBefore,y=t.commentBefore,v=t.comment;else if(O=!1,y=null,v=null,t&&typeof t==="object")t=o.createNode(t);if(n.implicitKey=!1,!h&&!d&&ue.isScalar(t))n.indentAtStart=m.length+1;if(p=!1,!u&&l.length>=2&&!n.inFlow&&!h&&ue.isSeq(t)&&!t.flow&&!t.tag&&!t.anchor)n.indent=n.indent.substring(2);let _=!1,A=wa.stringify(t,n,()=>_=!0,()=>p=!0),b=" ";if(d||O||y){if(b=O?`
38
+ `:"",y){let S=c(y);b+=`
39
+ ${Ct.indentComment(S,n.indent)}`}if(A===""&&!n.inFlow){if(b===`
40
+ `&&v)b=`
41
+
42
+ `}else b+=`
43
+ ${n.indent}`}else if(!h&&ue.isCollection(t)){let S=A[0],w=A.indexOf(`
44
+ `),C=w!==-1,P=n.inFlow??t.flow??t.items.length===0;if(C||!P){let H=!1;if(C&&(S==="&"||S==="!")){let q=A.indexOf(" ");if(S==="&"&&q!==-1&&q<w&&A[q+1]==="!")q=A.indexOf(" ",q+1);if(q===-1||w<q)H=!0}if(!H)b=`
45
+ ${n.indent}`}}else if(A===""||A[0]===`
46
+ `)b="";if(m+=b+A,n.inFlow){if(_&&s)s()}else if(v&&!_)m+=Ct.lineComment(m,n.indent,c(v));else if(p&&i)i();return m}Am.stringifyPair=xm});var oi=k(function($m){var _a=sn("process");function Tm(e,...t){if(e==="debug")console.log(...t)}function Rm(e,t){if(e==="debug"||e==="warn")if(typeof _a.emitWarning==="function")_a.emitWarning(t);else console.warn(t)}$m.debug=Tm;$m.warn=Rm});var $n=k(function(Pm){var Rn=R(),Sa=j(),Cn="<<",Tn={identify:(e)=>e===Cn||typeof e==="symbol"&&e.description===Cn,default:"key",tag:"tag:yaml.org,2002:merge",test:/^<<$/,resolve:()=>Object.assign(new Sa.Scalar(Symbol(Cn)),{addToJSMap:va}),stringify:()=>Cn},Im=(e,t)=>(Tn.identify(t)||Rn.isScalar(t)&&(!t.type||t.type===Sa.Scalar.PLAIN)&&Tn.identify(t.value))&&e?.doc.schema.tags.some((n)=>n.tag===Tn.tag&&n.default);function va(e,t,n){let s=Ea(e,n);if(Rn.isSeq(s))for(let i of s.items)ai(e,t,i);else if(Array.isArray(s))for(let i of s)ai(e,t,i);else ai(e,t,s)}function ai(e,t,n){let s=Ea(e,n);if(!Rn.isMap(s))throw Error("Merge sources must be maps or map aliases");let i=s.toJSON(null,e,Map);for(let[r,o]of i)if(t instanceof Map){if(!t.has(r))t.set(r,o)}else if(t instanceof Set)t.add(r);else if(!Object.prototype.hasOwnProperty.call(t,r))Object.defineProperty(t,r,{value:o,writable:!0,enumerable:!0,configurable:!0});return t}function Ea(e,t){return e&&Rn.isAlias(t)?t.resolve(e.doc,e):t}Pm.addMergeToJSMap=va;Pm.isMergeKey=Im;Pm.merge=Tn});var ci=k(function(Vm){var Mm=oi(),ka=$n(),Fm=At(),Oa=R(),li=ge();function Um(e,t,{key:n,value:s}){if(Oa.isNode(n)&&n.addToJSMap)n.addToJSMap(e,t,s);else if(ka.isMergeKey(e,n))ka.addMergeToJSMap(e,t,s);else{let i=li.toJS(n,"",e);if(t instanceof Map)t.set(i,li.toJS(s,i,e));else if(t instanceof Set)t.add(i);else{let r=Bm(n,i,e),o=li.toJS(s,r,e);if(r in t)Object.defineProperty(t,r,{value:o,writable:!0,enumerable:!0,configurable:!0});else t[r]=o}}return t}function Bm(e,t,n){if(t===null)return"";if(typeof t!=="object")return String(t);if(Oa.isNode(e)&&n?.doc){let s=Fm.createStringifyContext(n.doc,{});s.anchors=new Set;for(let r of n.anchors.keys())s.anchors.add(r.anchor);s.inFlow=!0,s.inStringifyKey=!0;let i=e.toString(s);if(!n.mapKeyWarned){let r=JSON.stringify(i);if(r.length>40)r=r.substring(0,36)+'..."';Mm.warn(n.doc.options.logLevel,`Keys with collection values will be stringified due to JS Object restrictions: ${r}. Set mapAsMap: true to use object keys.`),n.mapKeyWarned=!0}return i}return JSON.stringify(t)}Vm.addPairToJSMap=Um});var be=k(function(Gm){var xa=Et(),Hm=ba(),Km=ci(),Nn=R();function Jm(e,t,n){let s=xa.createNode(e,void 0,n),i=xa.createNode(t,void 0,n);return new Ln(s,i)}class Ln{constructor(e,t=null){Object.defineProperty(this,Nn.NODE_TYPE,{value:Nn.PAIR}),this.key=e,this.value=t}clone(e){let{key:t,value:n}=this;if(Nn.isNode(t))t=t.clone(e);if(Nn.isNode(n))n=n.clone(e);return new Ln(t,n)}toJSON(e,t){let n=t?.mapAsMap?new Map:{};return Km.addPairToJSMap(t,n,this)}toString(e,t,n){return e?.doc?Hm.stringifyPair(this,e,t,n):JSON.stringify(this)}}Gm.Pair=Ln;Gm.createPair=Jm});var ui=k(function(eg){var $e=R(),Aa=At(),In=kt();function Xm(e,t,n){return(t.inFlow??e.flow?Zm:Qm)(e,t,n)}function Qm({comment:e,items:t},n,{blockItemPrefix:s,flowChars:i,itemIndent:r,onChompKeep:o,onComment:a}){let{indent:l,options:{commentString:c}}=n,u=Object.assign({},n,{indent:r,type:null}),f=!1,d=[];for(let g=0;g<t.length;++g){let p=t[g],m=null;if($e.isNode(p)){if(!f&&p.spaceBefore)d.push("");if(Pn(n,d,p.commentBefore,f),p.comment)m=p.comment}else if($e.isPair(p)){let y=$e.isNode(p.key)?p.key:null;if(y){if(!f&&y.spaceBefore)d.push("");Pn(n,d,y.commentBefore,f)}}f=!1;let O=Aa.stringify(p,u,()=>m=null,()=>f=!0);if(m)O+=In.lineComment(O,r,c(m));if(f&&m)f=!1;d.push(s+O)}let h;if(d.length===0)h=i.start+i.end;else{h=d[0];for(let g=1;g<d.length;++g){let p=d[g];h+=p?`
47
+ ${l}${p}`:`
48
+ `}}if(e){if(h+=`
49
+ `+In.indentComment(c(e),l),a)a()}else if(f&&o)o();return h}function Zm({items:e},t,{flowChars:n,itemIndent:s}){let{indent:i,indentStep:r,flowCollectionPadding:o,options:{commentString:a}}=t;s+=r;let l=Object.assign({},t,{indent:s,inFlow:!0,type:null}),c=!1,u=0,f=[];for(let g=0;g<e.length;++g){let p=e[g],m=null;if($e.isNode(p)){if(p.spaceBefore)f.push("");if(Pn(t,f,p.commentBefore,!1),p.comment)m=p.comment}else if($e.isPair(p)){let y=$e.isNode(p.key)?p.key:null;if(y){if(y.spaceBefore)f.push("");if(Pn(t,f,y.commentBefore,!1),y.comment)c=!0}let v=$e.isNode(p.value)?p.value:null;if(v){if(v.comment)m=v.comment;if(v.commentBefore)c=!0}else if(p.value==null&&y?.comment)m=y.comment}if(m)c=!0;let O=Aa.stringify(p,l,()=>m=null);if(c||(c=f.length>u||O.includes(`
50
+ `)),g<e.length-1)O+=",";else if(t.options.trailingComma){if(t.options.lineWidth>0)c||(c=f.reduce((y,v)=>y+v.length+2,2)+(O.length+2)>t.options.lineWidth);if(c)O+=","}if(m)O+=In.lineComment(O,s,a(m));f.push(O),u=f.length}let{start:d,end:h}=n;if(f.length===0)return d+h;else{if(!c){let g=f.reduce((p,m)=>p+m.length+2,2);c=t.options.lineWidth>0&&g>t.options.lineWidth}if(c){let g=d;for(let p of f)g+=p?`
51
+ ${r}${i}${p}`:`
52
+ `;return`${g}
53
+ ${i}${h}`}else return`${d}${o}${f.join(" ")}${o}${h}`}}function Pn({indent:e,options:{commentString:t}},n,s,i){if(s&&i)s=s.replace(/^\n+/,"");if(s){let r=In.indentComment(t(s),e);n.push(r.trimStart())}}eg.stringifyCollection=Xm});var Se=k(function(og){var ng=ui(),sg=ci(),ig=kn(),_e=R(),qn=be(),rg=j();function Tt(e,t){let n=_e.isScalar(t)?t.value:t;for(let s of e)if(_e.isPair(s)){if(s.key===t||s.key===n)return s;if(_e.isScalar(s.key)&&s.key.value===n)return s}return}class Ca extends ig.Collection{static get tagName(){return"tag:yaml.org,2002:map"}constructor(e){super(_e.MAP,e);this.items=[]}static from(e,t,n){let{keepUndefined:s,replacer:i}=n,r=new this(e),o=(a,l)=>{if(typeof i==="function")l=i.call(t,a,l);else if(Array.isArray(i)&&!i.includes(a))return;if(l!==void 0||s)r.items.push(qn.createPair(a,l,n))};if(t instanceof Map)for(let[a,l]of t)o(a,l);else if(t&&typeof t==="object")for(let a of Object.keys(t))o(a,t[a]);if(typeof e.sortMapEntries==="function")r.items.sort(e.sortMapEntries);return r}add(e,t){let n;if(_e.isPair(e))n=e;else if(!e||typeof e!=="object"||!("key"in e))n=new qn.Pair(e,e?.value);else n=new qn.Pair(e.key,e.value);let s=Tt(this.items,n.key),i=this.schema?.sortMapEntries;if(s){if(!t)throw Error(`Key ${n.key} already set`);if(_e.isScalar(s.value)&&rg.isScalarValue(n.value))s.value.value=n.value;else s.value=n.value}else if(i){let r=this.items.findIndex((o)=>i(n,o)<0);if(r===-1)this.items.push(n);else this.items.splice(r,0,n)}else this.items.push(n)}delete(e){let t=Tt(this.items,e);if(!t)return!1;return this.items.splice(this.items.indexOf(t),1).length>0}get(e,t){let s=Tt(this.items,e)?.value;return(!t&&_e.isScalar(s)?s.value:s)??void 0}has(e){return!!Tt(this.items,e)}set(e,t){this.add(new qn.Pair(e,t),!0)}toJSON(e,t,n){let s=n?new n:t?.mapAsMap?new Map:{};if(t?.onCreate)t.onCreate(s);for(let i of this.items)sg.addPairToJSMap(t,s,i);return s}toString(e,t,n){if(!e)return JSON.stringify(this);for(let s of this.items)if(!_e.isPair(s))throw Error(`Map items must all be pairs; found ${JSON.stringify(s)} instead`);if(!e.allNullValues&&this.hasAllNullValues(!1))e=Object.assign({},e,{allNullValues:!0});return ng.stringifyCollection(this,e,{blockItemPrefix:"",flowChars:{start:"{",end:"}"},itemIndent:e.indent||"",onChompKeep:n,onComment:t})}}og.YAMLMap=Ca;og.findPair=Tt});var Qe=k(function(fg){var cg=R(),Ta=Se(),ug={collection:"map",default:!0,nodeClass:Ta.YAMLMap,tag:"tag:yaml.org,2002:map",resolve(e,t){if(!cg.isMap(e))t("Expected a mapping for this tag");return e},createNode:(e,t,n)=>Ta.YAMLMap.from(e,t,n)};fg.map=ug});var ve=k(function(wg){var pg=Et(),hg=ui(),mg=kn(),jn=R(),gg=j(),yg=ge();class Ra extends mg.Collection{static get tagName(){return"tag:yaml.org,2002:seq"}constructor(e){super(jn.SEQ,e);this.items=[]}add(e){this.items.push(e)}delete(e){let t=Dn(e);if(typeof t!=="number")return!1;return this.items.splice(t,1).length>0}get(e,t){let n=Dn(e);if(typeof n!=="number")return;let s=this.items[n];return!t&&jn.isScalar(s)?s.value:s}has(e){let t=Dn(e);return typeof t==="number"&&t<this.items.length}set(e,t){let n=Dn(e);if(typeof n!=="number")throw Error(`Expected a valid index, not ${e}.`);let s=this.items[n];if(jn.isScalar(s)&&gg.isScalarValue(t))s.value=t;else this.items[n]=t}toJSON(e,t){let n=[];if(t?.onCreate)t.onCreate(n);let s=0;for(let i of this.items)n.push(yg.toJS(i,String(s++),t));return n}toString(e,t,n){if(!e)return JSON.stringify(this);return hg.stringifyCollection(this,e,{blockItemPrefix:"- ",flowChars:{start:"[",end:"]"},itemIndent:(e.indent||"")+" ",onChompKeep:n,onComment:t})}static from(e,t,n){let{replacer:s}=n,i=new this(e);if(t&&Symbol.iterator in Object(t)){let r=0;for(let o of t){if(typeof s==="function"){let a=t instanceof Set?o:String(r++);o=s.call(t,a,o)}i.items.push(pg.createNode(o,void 0,n))}}return i}}function Dn(e){let t=jn.isScalar(e)?e.value:e;if(t&&typeof t==="string")t=Number(t);return typeof t==="number"&&Number.isInteger(t)&&t>=0?t:null}wg.YAMLSeq=Ra});var Ze=k(function(vg){var _g=R(),$a=ve(),Sg={collection:"seq",default:!0,nodeClass:$a.YAMLSeq,tag:"tag:yaml.org,2002:seq",resolve(e,t){if(!_g.isSeq(e))t("Expected a sequence for this tag");return e},createNode:(e,t,n)=>$a.YAMLSeq.from(e,t,n)};vg.seq=Sg});var Rt=k(function(xg){var kg=xt(),Og={identify:(e)=>typeof e==="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:(e)=>e,stringify(e,t,n,s){return t=Object.assign({actualString:!0},t),kg.stringifyString(e,t,n,s)}};xg.string=Og});var Mn=k(function(Cg){var Na=j(),La={identify:(e)=>e==null,createNode:()=>new Na.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new Na.Scalar(null),stringify:({source:e},t)=>typeof e==="string"&&La.test.test(e)?e:t.options.nullStr};Cg.nullTag=La});var fi=k(function($g){var Rg=j(),Ia={identify:(e)=>typeof e==="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:(e)=>new Rg.Scalar(e[0]==="t"||e[0]==="T"),stringify({source:e,value:t},n){if(e&&Ia.test.test(e)){let s=e[0]==="t"||e[0]==="T";if(t===s)return e}return t?n.options.trueStr:n.options.falseStr}};$g.boolTag=Ia});var et=k(function(Ig){function Lg({format:e,minFractionDigits:t,tag:n,value:s}){if(typeof s==="bigint")return String(s);let i=typeof s==="number"?s:Number(s);if(!isFinite(i))return isNaN(i)?".nan":i<0?"-.inf":".inf";let r=Object.is(s,-0)?"-0":JSON.stringify(s);if(!e&&t&&(!n||n==="tag:yaml.org,2002:float")&&/^-?\d/.test(r)&&!r.includes("e")){let o=r.indexOf(".");if(o<0)o=r.length,r+=".";let a=t-(r.length-o-1);while(a-- >0)r+="0"}return r}Ig.stringifyNumber=Lg});var pi=k(function(Fg){var qg=j(),di=et(),Dg={identify:(e)=>typeof e==="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:(e)=>e.slice(-3).toLowerCase()==="nan"?NaN:e[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:di.stringifyNumber},jg={identify:(e)=>typeof e==="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/,resolve:(e)=>parseFloat(e),stringify(e){let t=Number(e.value);return isFinite(t)?t.toExponential():di.stringifyNumber(e)}},Mg={identify:(e)=>typeof e==="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:\.[0-9]+|[0-9]+\.[0-9]*)$/,resolve(e){let t=new qg.Scalar(parseFloat(e)),n=e.indexOf(".");if(n!==-1&&e[e.length-1]==="0")t.minFractionDigits=e.length-n-1;return t},stringify:di.stringifyNumber};Fg.float=Mg;Fg.floatExp=jg;Fg.floatNaN=Dg});var mi=k(function(Jg){var Pa=et(),Fn=(e)=>typeof e==="bigint"||Number.isInteger(e),hi=(e,t,n,{intAsBigInt:s})=>s?BigInt(e):parseInt(e.substring(t),n);function qa(e,t,n){let{value:s}=e;if(Fn(s)&&s>=0)return n+s.toString(t);return Pa.stringifyNumber(e)}var Wg={identify:(e)=>Fn(e)&&e>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^0o[0-7]+$/,resolve:(e,t,n)=>hi(e,2,8,n),stringify:(e)=>qa(e,8,"0o")},Hg={identify:Fn,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9]+$/,resolve:(e,t,n)=>hi(e,0,10,n),stringify:Pa.stringifyNumber},Kg={identify:(e)=>Fn(e)&&e>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^0x[0-9a-fA-F]+$/,resolve:(e,t,n)=>hi(e,2,16,n),stringify:(e)=>qa(e,16,"0x")};Jg.int=Hg;Jg.intHex=Kg;Jg.intOct=Wg});var Da=k(function(sy){var Xg=Qe(),Qg=Mn(),Zg=Ze(),ey=Rt(),ty=fi(),gi=pi(),yi=mi(),ny=[Xg.map,Zg.seq,ey.string,Qg.nullTag,ty.boolTag,yi.intOct,yi.int,yi.intHex,gi.floatNaN,gi.floatExp,gi.float];sy.schema=ny});var Ma=k(function(fy){var ry=j(),oy=Qe(),ay=Ze();function ja(e){return typeof e==="bigint"||Number.isInteger(e)}var Un=({value:e})=>JSON.stringify(e),ly=[{identify:(e)=>typeof e==="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:(e)=>e,stringify:Un},{identify:(e)=>e==null,createNode:()=>new ry.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^null$/,resolve:()=>null,stringify:Un},{identify:(e)=>typeof e==="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^true$|^false$/,resolve:(e)=>e==="true",stringify:Un},{identify:ja,default:!0,tag:"tag:yaml.org,2002:int",test:/^-?(?:0|[1-9][0-9]*)$/,resolve:(e,t,{intAsBigInt:n})=>n?BigInt(e):parseInt(e,10),stringify:({value:e})=>ja(e)?e.toString():JSON.stringify(e)},{identify:(e)=>typeof e==="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/,resolve:(e)=>parseFloat(e),stringify:Un}],cy={default:!0,tag:"",test:/^/,resolve(e,t){return t(`Unresolved plain scalar ${JSON.stringify(e)}`),e}},uy=[oy.map,ay.seq].concat(ly,cy);fy.schema=uy});var bi=k(function(my){var $t=sn("buffer"),wi=j(),py=xt(),hy={identify:(e)=>e instanceof Uint8Array,default:!1,tag:"tag:yaml.org,2002:binary",resolve(e,t){if(typeof $t.Buffer==="function")return $t.Buffer.from(e,"base64");else if(typeof atob==="function"){let n=atob(e.replace(/[\n\r]/g,"")),s=new Uint8Array(n.length);for(let i=0;i<n.length;++i)s[i]=n.charCodeAt(i);return s}else return t("This environment does not support reading binary tags; either Buffer or atob is required"),e},stringify({comment:e,type:t,value:n},s,i,r){if(!n)return"";let o=n,a;if(typeof $t.Buffer==="function")a=o instanceof $t.Buffer?o.toString("base64"):$t.Buffer.from(o.buffer).toString("base64");else if(typeof btoa==="function"){let l="";for(let c=0;c<o.length;++c)l+=String.fromCharCode(o[c]);a=btoa(l)}else throw Error("This environment does not support writing binary tags; either Buffer or btoa is required");if(t??(t=wi.Scalar.BLOCK_LITERAL),t!==wi.Scalar.QUOTE_DOUBLE){let l=Math.max(s.options.lineWidth-s.indent.length,s.options.minContentWidth),c=Math.ceil(a.length/l),u=Array(c);for(let f=0,d=0;f<c;++f,d+=l)u[f]=a.substr(d,l);a=u.join(t===wi.Scalar.BLOCK_LITERAL?`
54
+ `:" ")}return py.stringifyString({comment:e,type:t,value:a},s,i,r)}};my.binary=hy});var Vn=k(function(_y){var Bn=R(),_i=be(),yy=j(),wy=ve();function Fa(e,t){if(Bn.isSeq(e))for(let n=0;n<e.items.length;++n){let s=e.items[n];if(Bn.isPair(s))continue;else if(Bn.isMap(s)){if(s.items.length>1)t("Each pair must have its own sequence indicator");let i=s.items[0]||new _i.Pair(new yy.Scalar(null));if(s.commentBefore)i.key.commentBefore=i.key.commentBefore?`${s.commentBefore}
55
+ ${i.key.commentBefore}`:s.commentBefore;if(s.comment){let r=i.value??i.key;r.comment=r.comment?`${s.comment}
56
+ ${r.comment}`:s.comment}s=i}e.items[n]=Bn.isPair(s)?s:new _i.Pair(s)}else t("Expected a sequence for this tag");return e}function Ua(e,t,n){let{replacer:s}=n,i=new wy.YAMLSeq(e);i.tag="tag:yaml.org,2002:pairs";let r=0;if(t&&Symbol.iterator in Object(t))for(let o of t){if(typeof s==="function")o=s.call(t,String(r++),o);let a,l;if(Array.isArray(o))if(o.length===2)a=o[0],l=o[1];else throw TypeError(`Expected [key, value] tuple: ${o}`);else if(o&&o instanceof Object){let c=Object.keys(o);if(c.length===1)a=c[0],l=o[a];else throw TypeError(`Expected tuple with one key, not ${c.length} keys`)}else a=o;i.items.push(_i.createPair(a,l,n))}return i}var by={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:Fa,createNode:Ua};_y.createPairs=Ua;_y.pairs=by;_y.resolvePairs=Fa});var vi=k(function(xy){var Ba=R(),Si=ge(),Nt=Se(),ky=ve(),Va=Vn();class Ne extends ky.YAMLSeq{constructor(){super();this.add=Nt.YAMLMap.prototype.add.bind(this),this.delete=Nt.YAMLMap.prototype.delete.bind(this),this.get=Nt.YAMLMap.prototype.get.bind(this),this.has=Nt.YAMLMap.prototype.has.bind(this),this.set=Nt.YAMLMap.prototype.set.bind(this),this.tag=Ne.tag}toJSON(e,t){if(!t)return super.toJSON(e);let n=new Map;if(t?.onCreate)t.onCreate(n);for(let s of this.items){let i,r;if(Ba.isPair(s))i=Si.toJS(s.key,"",t),r=Si.toJS(s.value,i,t);else i=Si.toJS(s,"",t);if(n.has(i))throw Error("Ordered maps must not include duplicate keys");n.set(i,r)}return n}static from(e,t,n){let s=Va.createPairs(e,t,n),i=new this;return i.items=s.items,i}}Ne.tag="tag:yaml.org,2002:omap";var Oy={collection:"seq",identify:(e)=>e instanceof Map,nodeClass:Ne,default:!1,tag:"tag:yaml.org,2002:omap",resolve(e,t){let n=Va.resolvePairs(e,t),s=[];for(let{key:i}of n.items)if(Ba.isScalar(i))if(s.includes(i.value))t(`Ordered maps must not include duplicate keys: ${i.value}`);else s.push(i.value);return Object.assign(new Ne,n)},createNode:(e,t,n)=>Ne.from(e,t,n)};xy.YAMLOMap=Ne;xy.omap=Oy});var Ga=k(function(Ty){var Wa=j();function Ha({value:e,source:t},n){if(t&&(e?Ka:Ja).test.test(t))return t;return e?n.options.trueStr:n.options.falseStr}var Ka={identify:(e)=>e===!0,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,resolve:()=>new Wa.Scalar(!0),stringify:Ha},Ja={identify:(e)=>e===!1,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,resolve:()=>new Wa.Scalar(!1),stringify:Ha};Ty.falseTag=Ja;Ty.trueTag=Ka});var Ya=k(function(qy){var Ny=j(),Ei=et(),Ly={identify:(e)=>typeof e==="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:(e)=>e.slice(-3).toLowerCase()==="nan"?NaN:e[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:Ei.stringifyNumber},Iy={identify:(e)=>typeof e==="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,resolve:(e)=>parseFloat(e.replace(/_/g,"")),stringify(e){let t=Number(e.value);return isFinite(t)?t.toExponential():Ei.stringifyNumber(e)}},Py={identify:(e)=>typeof e==="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,resolve(e){let t=new Ny.Scalar(parseFloat(e.replace(/_/g,""))),n=e.indexOf(".");if(n!==-1){let s=e.substring(n+1).replace(/_/g,"");if(s[s.length-1]==="0")t.minFractionDigits=s.length}return t},stringify:Ei.stringifyNumber};qy.float=Py;qy.floatExp=Iy;qy.floatNaN=Ly});var Xa=k(function(Wy){var za=et(),Lt=(e)=>typeof e==="bigint"||Number.isInteger(e);function Wn(e,t,n,{intAsBigInt:s}){let i=e[0];if(i==="-"||i==="+")t+=1;if(e=e.substring(t).replace(/_/g,""),s){switch(n){case 2:e=`0b${e}`;break;case 8:e=`0o${e}`;break;case 16:e=`0x${e}`;break}let o=BigInt(e);return i==="-"?BigInt(-1)*o:o}let r=parseInt(e,n);return i==="-"?-1*r:r}function ki(e,t,n){let{value:s}=e;if(Lt(s)){let i=s.toString(t);return s<0?"-"+n+i.substr(1):n+i}return za.stringifyNumber(e)}var Fy={identify:Lt,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:(e,t,n)=>Wn(e,2,2,n),stringify:(e)=>ki(e,2,"0b")},Uy={identify:Lt,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:(e,t,n)=>Wn(e,1,8,n),stringify:(e)=>ki(e,8,"0")},By={identify:Lt,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:(e,t,n)=>Wn(e,0,10,n),stringify:za.stringifyNumber},Vy={identify:Lt,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(e,t,n)=>Wn(e,2,16,n),stringify:(e)=>ki(e,16,"0x")};Wy.int=By;Wy.intBin=Fy;Wy.intHex=Vy;Wy.intOct=Uy});var Oi=k(function(zy){var Jn=R(),Hn=be(),Kn=Se();class Le extends Kn.YAMLMap{constructor(e){super(e);this.tag=Le.tag}add(e){let t;if(Jn.isPair(e))t=e;else if(e&&typeof e==="object"&&"key"in e&&"value"in e&&e.value===null)t=new Hn.Pair(e.key,null);else t=new Hn.Pair(e,null);if(!Kn.findPair(this.items,t.key))this.items.push(t)}get(e,t){let n=Kn.findPair(this.items,e);return!t&&Jn.isPair(n)?Jn.isScalar(n.key)?n.key.value:n.key:n}set(e,t){if(typeof t!=="boolean")throw Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof t}`);let n=Kn.findPair(this.items,e);if(n&&!t)this.items.splice(this.items.indexOf(n),1);else if(!n&&t)this.items.push(new Hn.Pair(e))}toJSON(e,t){return super.toJSON(e,t,Set)}toString(e,t,n){if(!e)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},e,{allNullValues:!0}),t,n);else throw Error("Set items must all have null values")}static from(e,t,n){let{replacer:s}=n,i=new this(e);if(t&&Symbol.iterator in Object(t))for(let r of t){if(typeof s==="function")r=s.call(t,r,r);i.items.push(Hn.createPair(r,null,n))}return i}}Le.tag="tag:yaml.org,2002:set";var Yy={collection:"map",identify:(e)=>e instanceof Set,nodeClass:Le,default:!1,tag:"tag:yaml.org,2002:set",createNode:(e,t,n)=>Le.from(e,t,n),resolve(e,t){if(Jn.isMap(e))if(e.hasAllNullValues(!0))return Object.assign(new Le,e);else t("Set items must all have null values");else t("Expected a mapping for this tag");return e}};zy.YAMLSet=Le;zy.set=Yy});var Ai=k(function(nw){var Zy=et();function xi(e,t){let n=e[0],s=n==="-"||n==="+"?e.substring(1):e,i=(o)=>t?BigInt(o):Number(o),r=s.replace(/_/g,"").split(":").reduce((o,a)=>o*i(60)+i(a),i(0));return n==="-"?i(-1)*r:r}function Qa(e){let{value:t}=e,n=(o)=>o;if(typeof t==="bigint")n=(o)=>BigInt(o);else if(isNaN(t)||!isFinite(t))return Zy.stringifyNumber(e);let s="";if(t<0)s="-",t*=n(-1);let i=n(60),r=[t%i];if(t<60)r.unshift(0);else if(t=(t-r[0])/i,r.unshift(t%i),t>=60)t=(t-r[0])/i,r.unshift(t);return s+r.map((o)=>String(o).padStart(2,"0")).join(":").replace(/000000\d*$/,"")}var ew={identify:(e)=>typeof e==="bigint"||Number.isInteger(e),default:!0,tag:"tag:yaml.org,2002:int",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/,resolve:(e,t,{intAsBigInt:n})=>xi(e,n),stringify:Qa},tw={identify:(e)=>typeof e==="number",default:!0,tag:"tag:yaml.org,2002:float",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*$/,resolve:(e)=>xi(e,!1),stringify:Qa},Za={identify:(e)=>e instanceof Date,default:!0,tag:"tag:yaml.org,2002:timestamp",test:RegExp("^([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})(?:(?:t|T|[ \\t]+)([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}(\\.[0-9]+)?)(?:[ \\t]*(Z|[-+][012]?[0-9](?::[0-9]{2})?))?)?$"),resolve(e){let t=e.match(Za.test);if(!t)throw Error("!!timestamp expects a date, starting with yyyy-mm-dd");let[,n,s,i,r,o,a]=t.map(Number),l=t[7]?Number((t[7]+"00").substr(1,3)):0,c=Date.UTC(n,s-1,i,r||0,o||0,a||0,l),u=t[8];if(u&&u!=="Z"){let f=xi(u,!1);if(Math.abs(f)<30)f*=60;c-=60000*f}return new Date(c)},stringify:({value:e})=>e?.toISOString().replace(/(T00:00:00)?\.000Z$/,"")??""};nw.floatTime=tw;nw.intTime=ew;nw.timestamp=Za});var tl=k(function(gw){var ow=Qe(),aw=Mn(),lw=Ze(),cw=Rt(),uw=bi(),el=Ga(),Ci=Ya(),Gn=Xa(),fw=$n(),dw=vi(),pw=Vn(),hw=Oi(),Ti=Ai(),mw=[ow.map,lw.seq,cw.string,aw.nullTag,el.trueTag,el.falseTag,Gn.intBin,Gn.intOct,Gn.int,Gn.intHex,Ci.floatNaN,Ci.floatExp,Ci.float,uw.binary,fw.merge,dw.omap,pw.pairs,hw.set,Ti.intTime,Ti.floatTime,Ti.timestamp];gw.schema=mw});var fl=k(function(Ow){var rl=Qe(),ww=Mn(),ol=Ze(),bw=Rt(),_w=fi(),Ri=pi(),$i=mi(),Sw=Da(),vw=Ma(),al=bi(),It=$n(),ll=vi(),cl=Vn(),nl=tl(),ul=Oi(),Yn=Ai(),sl=new Map([["core",Sw.schema],["failsafe",[rl.map,ol.seq,bw.string]],["json",vw.schema],["yaml11",nl.schema],["yaml-1.1",nl.schema]]),il={binary:al.binary,bool:_w.boolTag,float:Ri.float,floatExp:Ri.floatExp,floatNaN:Ri.floatNaN,floatTime:Yn.floatTime,int:$i.int,intHex:$i.intHex,intOct:$i.intOct,intTime:Yn.intTime,map:rl.map,merge:It.merge,null:ww.nullTag,omap:ll.omap,pairs:cl.pairs,seq:ol.seq,set:ul.set,timestamp:Yn.timestamp},Ew={"tag:yaml.org,2002:binary":al.binary,"tag:yaml.org,2002:merge":It.merge,"tag:yaml.org,2002:omap":ll.omap,"tag:yaml.org,2002:pairs":cl.pairs,"tag:yaml.org,2002:set":ul.set,"tag:yaml.org,2002:timestamp":Yn.timestamp};function kw(e,t,n){let s=sl.get(t);if(s&&!e)return n&&!s.includes(It.merge)?s.concat(It.merge):s.slice();let i=s;if(!i)if(Array.isArray(e))i=[];else{let r=Array.from(sl.keys()).filter((o)=>o!=="yaml11").map((o)=>JSON.stringify(o)).join(", ");throw Error(`Unknown schema "${t}"; use one of ${r} or define customTags array`)}if(Array.isArray(e))for(let r of e)i=i.concat(r);else if(typeof e==="function")i=e(i.slice());if(n)i=i.concat(It.merge);return i.reduce((r,o)=>{let a=typeof o==="string"?il[o]:o;if(!a){let l=JSON.stringify(o),c=Object.keys(il).map((u)=>JSON.stringify(u)).join(", ");throw Error(`Unknown custom tag ${l}; use one of ${c}`)}if(!r.includes(a))r.push(a);return r},[])}Ow.coreKnownTags=Ew;Ow.getTags=kw});var Ii=k(function(Nw){var Ni=R(),Cw=Qe(),Tw=Ze(),Rw=Rt(),zn=fl(),$w=(e,t)=>e.key<t.key?-1:e.key>t.key?1:0;class Li{constructor({compat:e,customTags:t,merge:n,resolveKnownTags:s,schema:i,sortMapEntries:r,toStringDefaults:o}){this.compat=Array.isArray(e)?zn.getTags(e,"compat"):e?zn.getTags(null,e):null,this.name=typeof i==="string"&&i||"core",this.knownTags=s?zn.coreKnownTags:{},this.tags=zn.getTags(t,this.name,n),this.toStringOptions=o??null,Object.defineProperty(this,Ni.MAP,{value:Cw.map}),Object.defineProperty(this,Ni.SCALAR,{value:Rw.string}),Object.defineProperty(this,Ni.SEQ,{value:Tw.seq}),this.sortMapEntries=typeof r==="function"?r:r===!0?$w:null}clone(){let e=Object.create(Li.prototype,Object.getOwnPropertyDescriptors(this));return e.tags=this.tags.slice(),e}}Nw.Schema=Li});var dl=k(function(qw){var Iw=R(),Pi=At(),Pt=kt();function Pw(e,t){let n=[],s=t.directives===!0;if(t.directives!==!1&&e.directives){let l=e.directives.toString(e);if(l)n.push(l),s=!0;else if(e.directives.docStart)s=!0}if(s)n.push("---");let i=Pi.createStringifyContext(e,t),{commentString:r}=i.options;if(e.commentBefore){if(n.length!==1)n.unshift("");let l=r(e.commentBefore);n.unshift(Pt.indentComment(l,""))}let o=!1,a=null;if(e.contents){if(Iw.isNode(e.contents)){if(e.contents.spaceBefore&&s)n.push("");if(e.contents.commentBefore){let u=r(e.contents.commentBefore);n.push(Pt.indentComment(u,""))}i.forceBlockIndent=!!e.comment,a=e.contents.comment}let l=a?void 0:()=>o=!0,c=Pi.stringify(e.contents,i,()=>a=null,l);if(a)c+=Pt.lineComment(c,"",r(a));if((c[0]==="|"||c[0]===">")&&n[n.length-1]==="---")n[n.length-1]=`--- ${c}`;else n.push(c)}else n.push(Pi.stringify(e.contents,i));if(e.directives?.docEnd)if(e.comment){let l=r(e.comment);if(l.includes(`
57
+ `))n.push("..."),n.push(Pt.indentComment(l,""));else n.push(`... ${l}`)}else n.push("...");else{let l=e.comment;if(l&&o)l=l.replace(/^\n+/,"");if(l){if((!o||a)&&n[n.length-1]!=="")n.push("");n.push(Pt.indentComment(r(l),""))}}return n.join(`
58
+ `)+`
59
+ `}qw.stringifyDocument=Pw});var qt=k(function(Hw){var jw=vt(),tt=kn(),Z=R(),Mw=be(),Fw=ge(),Uw=Ii(),Bw=dl(),qi=Sn(),Vw=ti(),Ww=Et(),Di=ei();class ji{constructor(e,t,n){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,Z.NODE_TYPE,{value:Z.DOC});let s=null;if(typeof t==="function"||Array.isArray(t))s=t;else if(n===void 0&&t)n=t,t=void 0;let i=Object.assign({intAsBigInt:!1,keepSourceTokens:!1,logLevel:"warn",prettyErrors:!0,strict:!0,stringKeys:!1,uniqueKeys:!0,version:"1.2"},n);this.options=i;let{version:r}=i;if(n?._directives){if(this.directives=n._directives.atDocument(),this.directives.yaml.explicit)r=this.directives.yaml.version}else this.directives=new Di.Directives({version:r});this.setSchema(r,n),this.contents=e===void 0?null:this.createNode(e,s,n)}clone(){let e=Object.create(ji.prototype,{[Z.NODE_TYPE]:{value:Z.DOC}});if(e.commentBefore=this.commentBefore,e.comment=this.comment,e.errors=this.errors.slice(),e.warnings=this.warnings.slice(),e.options=Object.assign({},this.options),this.directives)e.directives=this.directives.clone();if(e.schema=this.schema.clone(),e.contents=Z.isNode(this.contents)?this.contents.clone(e.schema):this.contents,this.range)e.range=this.range.slice();return e}add(e){if(nt(this.contents))this.contents.add(e)}addIn(e,t){if(nt(this.contents))this.contents.addIn(e,t)}createAlias(e,t){if(!e.anchor){let n=qi.anchorNames(this);e.anchor=!t||n.has(t)?qi.findNewAnchor(t||"a",n):t}return new jw.Alias(e.anchor)}createNode(e,t,n){let s=void 0;if(typeof t==="function")e=t.call({"":e},"",e),s=t;else if(Array.isArray(t)){let p=(O)=>typeof O==="number"||O instanceof String||O instanceof Number,m=t.filter(p).map(String);if(m.length>0)t=t.concat(m);s=t}else if(n===void 0&&t)n=t,t=void 0;let{aliasDuplicateObjects:i,anchorPrefix:r,flow:o,keepUndefined:a,onTagObj:l,tag:c}=n??{},{onAnchor:u,setAnchors:f,sourceObjects:d}=qi.createNodeAnchors(this,r||"a"),h={aliasDuplicateObjects:i??!0,keepUndefined:a??!1,onAnchor:u,onTagObj:l,replacer:s,schema:this.schema,sourceObjects:d},g=Ww.createNode(e,c,h);if(o&&Z.isCollection(g))g.flow=!0;return f(),g}createPair(e,t,n={}){let s=this.createNode(e,null,n),i=this.createNode(t,null,n);return new Mw.Pair(s,i)}delete(e){return nt(this.contents)?this.contents.delete(e):!1}deleteIn(e){if(tt.isEmptyPath(e)){if(this.contents==null)return!1;return this.contents=null,!0}return nt(this.contents)?this.contents.deleteIn(e):!1}get(e,t){return Z.isCollection(this.contents)?this.contents.get(e,t):void 0}getIn(e,t){if(tt.isEmptyPath(e))return!t&&Z.isScalar(this.contents)?this.contents.value:this.contents;return Z.isCollection(this.contents)?this.contents.getIn(e,t):void 0}has(e){return Z.isCollection(this.contents)?this.contents.has(e):!1}hasIn(e){if(tt.isEmptyPath(e))return this.contents!==void 0;return Z.isCollection(this.contents)?this.contents.hasIn(e):!1}set(e,t){if(this.contents==null)this.contents=tt.collectionFromPath(this.schema,[e],t);else if(nt(this.contents))this.contents.set(e,t)}setIn(e,t){if(tt.isEmptyPath(e))this.contents=t;else if(this.contents==null)this.contents=tt.collectionFromPath(this.schema,Array.from(e),t);else if(nt(this.contents))this.contents.setIn(e,t)}setSchema(e,t={}){if(typeof e==="number")e=String(e);let n;switch(e){case"1.1":if(this.directives)this.directives.yaml.version="1.1";else this.directives=new Di.Directives({version:"1.1"});n={resolveKnownTags:!1,schema:"yaml-1.1"};break;case"1.2":case"next":if(this.directives)this.directives.yaml.version=e;else this.directives=new Di.Directives({version:e});n={resolveKnownTags:!0,schema:"core"};break;case null:if(this.directives)delete this.directives;n=null;break;default:{let s=JSON.stringify(e);throw Error(`Expected '1.1', '1.2' or null as first argument, but found: ${s}`)}}if(t.schema instanceof Object)this.schema=t.schema;else if(n)this.schema=new Uw.Schema(Object.assign(n,t));else throw Error("With a null YAML version, the { schema: Schema } option is required")}toJS({json:e,jsonArg:t,mapAsMap:n,maxAliasCount:s,onAnchor:i,reviver:r}={}){let o={anchors:new Map,doc:this,keep:!e,mapAsMap:n===!0,mapKeyWarned:!1,maxAliasCount:typeof s==="number"?s:100},a=Fw.toJS(this.contents,t??"",o);if(typeof i==="function")for(let{count:l,res:c}of o.anchors.values())i(c,l);return typeof r==="function"?Vw.applyReviver(r,{"":a},"",a):a}toJSON(e,t){return this.toJS({json:!0,jsonArg:e,mapAsMap:!1,onAnchor:t})}toString(e={}){if(this.errors.length>0)throw Error("Document with errors cannot be stringified");if("indent"in e&&(!Number.isInteger(e.indent)||Number(e.indent)<=0)){let t=JSON.stringify(e.indent);throw Error(`"indent" option must be a positive integer, not ${t}`)}return Bw.stringifyDocument(this,e)}}function nt(e){if(Z.isCollection(e))return!0;throw Error("Expected a YAML collection as document contents")}Hw.Document=ji});var Dt=k(function(Gw){class Xn extends Error{constructor(e,t,n,s){super();this.name=e,this.code=n,this.message=s,this.pos=t}}class pl extends Xn{constructor(e,t,n){super("YAMLParseError",e,t,n)}}class hl extends Xn{constructor(e,t,n){super("YAMLWarning",e,t,n)}}var Jw=(e,t)=>(n)=>{if(n.pos[0]===-1)return;n.linePos=n.pos.map((a)=>t.linePos(a));let{line:s,col:i}=n.linePos[0];n.message+=` at line ${s}, column ${i}`;let r=i-1,o=e.substring(t.lineStarts[s-1],t.lineStarts[s]).replace(/[\n\r]+$/,"");if(r>=60&&o.length>80){let a=Math.min(r-39,o.length-79);o="…"+o.substring(a),r-=a-1}if(o.length>80)o=o.substring(0,79)+"…";if(s>1&&/^ *$/.test(o.substring(0,r))){let a=e.substring(t.lineStarts[s-2],t.lineStarts[s-1]);if(a.length>80)a=a.substring(0,79)+`…
60
+ `;o=a+o}if(/[^ ]/.test(o)){let a=1,l=n.linePos[1];if(l?.line===s&&l.col>i)a=Math.max(1,Math.min(l.col-i,80-r));let c=" ".repeat(r)+"^".repeat(a);n.message+=`:
61
+
62
+ ${o}
63
+ ${c}
64
+ `}};Gw.YAMLError=Xn;Gw.YAMLParseError=pl;Gw.YAMLWarning=hl;Gw.prettifyError=Jw});var jt=k(function(eb){function Zw(e,{flow:t,indicator:n,next:s,offset:i,onError:r,parentIndent:o,startOnNewline:a}){let l=!1,c=a,u=a,f="",d="",h=!1,g=!1,p=null,m=null,O=null,y=null,v=null,_=null,A=null;for(let w of e){if(g){if(w.type!=="space"&&w.type!=="newline"&&w.type!=="comma")r(w.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space");g=!1}if(p){if(c&&w.type!=="comment"&&w.type!=="newline")r(p,"TAB_AS_INDENT","Tabs are not allowed as indentation");p=null}switch(w.type){case"space":if(!t&&(n!=="doc-start"||s?.type!=="flow-collection")&&w.source.includes("\t"))p=w;u=!0;break;case"comment":{if(!u)r(w,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let C=w.source.substring(1)||" ";if(!f)f=C;else f+=d+C;d="",c=!1;break}case"newline":if(c){if(f)f+=w.source;else if(!_||n!=="seq-item-ind")l=!0}else d+=w.source;if(c=!0,h=!0,m||O)y=w;u=!0;break;case"anchor":if(m)r(w,"MULTIPLE_ANCHORS","A node can have at most one anchor");if(w.source.endsWith(":"))r(w.offset+w.source.length-1,"BAD_ALIAS","Anchor ending in : is ambiguous",!0);m=w,A??(A=w.offset),c=!1,u=!1,g=!0;break;case"tag":{if(O)r(w,"MULTIPLE_TAGS","A node can have at most one tag");O=w,A??(A=w.offset),c=!1,u=!1,g=!0;break}case n:if(m||O)r(w,"BAD_PROP_ORDER",`Anchors and tags must be after the ${w.source} indicator`);if(_)r(w,"UNEXPECTED_TOKEN",`Unexpected ${w.source} in ${t??"collection"}`);_=w,c=n==="seq-item-ind"||n==="explicit-key-ind",u=!1;break;case"comma":if(t){if(v)r(w,"UNEXPECTED_TOKEN",`Unexpected , in ${t}`);v=w,c=!1,u=!1;break}default:r(w,"UNEXPECTED_TOKEN",`Unexpected ${w.type} token`),c=!1,u=!1}}let b=e[e.length-1],S=b?b.offset+b.source.length:i;if(g&&s&&s.type!=="space"&&s.type!=="newline"&&s.type!=="comma"&&(s.type!=="scalar"||s.source!==""))r(s.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space");if(p&&(c&&p.indent<=o||s?.type==="block-map"||s?.type==="block-seq"))r(p,"TAB_AS_INDENT","Tabs are not allowed as indentation");return{comma:v,found:_,spaceBefore:l,comment:f,hasNewline:h,anchor:m,tag:O,newlineAfterProp:y,end:S,start:A??S}}eb.resolveProps=Zw});var Qn=k(function(nb){function Mi(e){if(!e)return null;switch(e.type){case"alias":case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":if(e.source.includes(`
65
+ `))return!0;if(e.end){for(let t of e.end)if(t.type==="newline")return!0}return!1;case"flow-collection":for(let t of e.items){for(let n of t.start)if(n.type==="newline")return!0;if(t.sep){for(let n of t.sep)if(n.type==="newline")return!0}if(Mi(t.key)||Mi(t.value))return!0}return!1;default:return!0}}nb.containsNewline=Mi});var Fi=k(function(ob){var ib=Qn();function rb(e,t,n){if(t?.type==="flow-collection"){let s=t.end[0];if(s.indent===e&&(s.source==="]"||s.source==="}")&&ib.containsNewline(t))n(s,"BAD_INDENT","Flow end indicator should be more indented than parent",!0)}}ob.flowIndentCheck=rb});var Ui=k(function(cb){var ml=R();function lb(e,t,n){let{uniqueKeys:s}=e.options;if(s===!1)return!1;let i=typeof s==="function"?s:(r,o)=>r===o||ml.isScalar(r)&&ml.isScalar(o)&&r.value===o.value;return t.some((r)=>i(r.key,n))}cb.mapIncludes=lb});var _l=k(function(mb){var gl=be(),fb=Se(),yl=jt(),db=Qn(),wl=Fi(),pb=Ui(),bl="All mapping items must start at the same column";function hb({composeNode:e,composeEmptyNode:t},n,s,i,r){let a=new(r?.nodeClass??fb.YAMLMap)(n.schema);if(n.atRoot)n.atRoot=!1;let l=s.offset,c=null;for(let u of s.items){let{start:f,key:d,sep:h,value:g}=u,p=yl.resolveProps(f,{indicator:"explicit-key-ind",next:d??h?.[0],offset:l,onError:i,parentIndent:s.indent,startOnNewline:!0}),m=!p.found;if(m){if(d){if(d.type==="block-seq")i(l,"BLOCK_AS_IMPLICIT_KEY","A block sequence may not be used as an implicit map key");else if("indent"in d&&d.indent!==s.indent)i(l,"BAD_INDENT",bl)}if(!p.anchor&&!p.tag&&!h){if(c=p.end,p.comment)if(a.comment)a.comment+=`
66
+ `+p.comment;else a.comment=p.comment;continue}if(p.newlineAfterProp||db.containsNewline(d))i(d??f[f.length-1],"MULTILINE_IMPLICIT_KEY","Implicit keys need to be on a single line")}else if(p.found?.indent!==s.indent)i(l,"BAD_INDENT",bl);n.atKey=!0;let O=p.end,y=d?e(n,d,p,i):t(n,O,f,null,p,i);if(n.schema.compat)wl.flowIndentCheck(s.indent,d,i);if(n.atKey=!1,pb.mapIncludes(n,a.items,y))i(O,"DUPLICATE_KEY","Map keys must be unique");let v=yl.resolveProps(h??[],{indicator:"map-value-ind",next:g,offset:y.range[2],onError:i,parentIndent:s.indent,startOnNewline:!d||d.type==="block-scalar"});if(l=v.end,v.found){if(m){if(g?.type==="block-map"&&!v.hasNewline)i(l,"BLOCK_AS_IMPLICIT_KEY","Nested mappings are not allowed in compact mappings");if(n.options.strict&&p.start<v.found.offset-1024)i(y.range,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit block mapping key")}let _=g?e(n,g,v,i):t(n,l,h,null,v,i);if(n.schema.compat)wl.flowIndentCheck(s.indent,g,i);l=_.range[2];let A=new gl.Pair(y,_);if(n.options.keepSourceTokens)A.srcToken=u;a.items.push(A)}else{if(m)i(y.range,"MISSING_CHAR","Implicit map keys need to be followed by map values");if(v.comment)if(y.comment)y.comment+=`
67
+ `+v.comment;else y.comment=v.comment;let _=new gl.Pair(y);if(n.options.keepSourceTokens)_.srcToken=u;a.items.push(_)}}if(c&&c<l)i(c,"IMPOSSIBLE","Map comment with trailing content");return a.range=[s.offset,l,c??l],a}mb.resolveBlockMap=hb});var Sl=k(function(Sb){var yb=ve(),wb=jt(),bb=Fi();function _b({composeNode:e,composeEmptyNode:t},n,s,i,r){let a=new(r?.nodeClass??yb.YAMLSeq)(n.schema);if(n.atRoot)n.atRoot=!1;if(n.atKey)n.atKey=!1;let l=s.offset,c=null;for(let{start:u,value:f}of s.items){let d=wb.resolveProps(u,{indicator:"seq-item-ind",next:f,offset:l,onError:i,parentIndent:s.indent,startOnNewline:!0});if(!d.found)if(d.anchor||d.tag||f)if(f?.type==="block-seq")i(d.end,"BAD_INDENT","All sequence items must start at the same column");else i(l,"MISSING_CHAR","Sequence item without - indicator");else{if(c=d.end,d.comment)a.comment=d.comment;continue}let h=f?e(n,f,d,i):t(n,d.end,u,null,d,i);if(n.schema.compat)bb.flowIndentCheck(s.indent,f,i);l=h.range[2],a.items.push(h)}return a.range=[s.offset,l,c??l],a}Sb.resolveBlockSeq=_b});var st=k(function(kb){function Eb(e,t,n,s){let i="";if(e){let r=!1,o="";for(let a of e){let{source:l,type:c}=a;switch(c){case"space":r=!0;break;case"comment":{if(n&&!r)s(a,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let u=l.substring(1)||" ";if(!i)i=u;else i+=o+u;o="";break}case"newline":if(i)o+=l;r=!0;break;default:s(a,"UNEXPECTED_TOKEN",`Unexpected ${c} at node end`)}t+=l.length}}return{comment:i,offset:t}}kb.resolveEnd=Eb});var kl=k(function(Lb){var xb=R(),Ab=be(),vl=Se(),Cb=ve(),Tb=st(),El=jt(),Rb=Qn(),$b=Ui(),Bi="Block collections are not allowed within flow collections",Vi=(e)=>e&&(e.type==="block-map"||e.type==="block-seq");function Nb({composeNode:e,composeEmptyNode:t},n,s,i,r){let o=s.start.source==="{",a=o?"flow map":"flow sequence",c=new(r?.nodeClass??(o?vl.YAMLMap:Cb.YAMLSeq))(n.schema);c.flow=!0;let u=n.atRoot;if(u)n.atRoot=!1;if(n.atKey)n.atKey=!1;let f=s.offset+s.start.source.length;for(let m=0;m<s.items.length;++m){let O=s.items[m],{start:y,key:v,sep:_,value:A}=O,b=El.resolveProps(y,{flow:a,indicator:"explicit-key-ind",next:v??_?.[0],offset:f,onError:i,parentIndent:s.indent,startOnNewline:!1});if(!b.found){if(!b.anchor&&!b.tag&&!_&&!A){if(m===0&&b.comma)i(b.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${a}`);else if(m<s.items.length-1)i(b.start,"UNEXPECTED_TOKEN",`Unexpected empty item in ${a}`);if(b.comment)if(c.comment)c.comment+=`
68
+ `+b.comment;else c.comment=b.comment;f=b.end;continue}if(!o&&n.options.strict&&Rb.containsNewline(v))i(v,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line")}if(m===0){if(b.comma)i(b.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${a}`)}else{if(!b.comma)i(b.start,"MISSING_CHAR",`Missing , between ${a} items`);if(b.comment){let S="";e:for(let w of y)switch(w.type){case"comma":case"space":break;case"comment":S=w.source.substring(1);break e;default:break e}if(S){let w=c.items[c.items.length-1];if(xb.isPair(w))w=w.value??w.key;if(w.comment)w.comment+=`
69
+ `+S;else w.comment=S;b.comment=b.comment.substring(S.length+1)}}}if(!o&&!_&&!b.found){let S=A?e(n,A,b,i):t(n,b.end,_,null,b,i);if(c.items.push(S),f=S.range[2],Vi(A))i(S.range,"BLOCK_IN_FLOW",Bi)}else{n.atKey=!0;let S=b.end,w=v?e(n,v,b,i):t(n,S,y,null,b,i);if(Vi(v))i(w.range,"BLOCK_IN_FLOW",Bi);n.atKey=!1;let C=El.resolveProps(_??[],{flow:a,indicator:"map-value-ind",next:A,offset:w.range[2],onError:i,parentIndent:s.indent,startOnNewline:!1});if(C.found){if(!o&&!b.found&&n.options.strict){if(_)for(let q of _){if(q===C.found)break;if(q.type==="newline"){i(q,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line");break}}if(b.start<C.found.offset-1024)i(C.found,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit flow sequence key")}}else if(A)if("source"in A&&A.source?.[0]===":")i(A,"MISSING_CHAR",`Missing space after : in ${a}`);else i(C.start,"MISSING_CHAR",`Missing , or : between ${a} items`);let P=A?e(n,A,C,i):C.found?t(n,C.end,_,null,C,i):null;if(P){if(Vi(A))i(P.range,"BLOCK_IN_FLOW",Bi)}else if(C.comment)if(w.comment)w.comment+=`
70
+ `+C.comment;else w.comment=C.comment;let H=new Ab.Pair(w,P);if(n.options.keepSourceTokens)H.srcToken=O;if(o){let q=c;if($b.mapIncludes(n,q.items,w))i(S,"DUPLICATE_KEY","Map keys must be unique");q.items.push(H)}else{let q=new vl.YAMLMap(n.schema);q.flow=!0,q.items.push(H);let de=(P??w).range;q.range=[w.range[0],de[1],de[2]],c.items.push(q)}f=P?P.range[2]:C.end}}let d=o?"}":"]",[h,...g]=s.end,p=f;if(h?.source===d)p=h.offset+h.source.length;else{let m=a[0].toUpperCase()+a.substring(1),O=u?`${m} must end with a ${d}`:`${m} in block collection must be sufficiently indented and end with a ${d}`;if(i(f,u?"MISSING_CHAR":"BAD_INDENT",O),h&&h.source.length!==1)g.unshift(h)}if(g.length>0){let m=Tb.resolveEnd(g,p,n.options.strict,i);if(m.comment)if(c.comment)c.comment+=`
71
+ `+m.comment;else c.comment=m.comment;c.range=[s.offset,p,m.offset]}else c.range=[s.offset,p,p];return c}Lb.resolveFlowCollection=Nb});var Ol=k(function(Vb){var Pb=R(),qb=j(),Db=Se(),jb=ve(),Mb=_l(),Fb=Sl(),Ub=kl();function Wi(e,t,n,s,i,r){let o=n.type==="block-map"?Mb.resolveBlockMap(e,t,n,s,r):n.type==="block-seq"?Fb.resolveBlockSeq(e,t,n,s,r):Ub.resolveFlowCollection(e,t,n,s,r),a=o.constructor;if(i==="!"||i===a.tagName)return o.tag=a.tagName,o;if(i)o.tag=i;return o}function Bb(e,t,n,s,i){let r=s.tag,o=!r?null:t.directives.tagName(r.source,(d)=>i(r,"TAG_RESOLVE_FAILED",d));if(n.type==="block-seq"){let{anchor:d,newlineAfterProp:h}=s,g=d&&r?d.offset>r.offset?d:r:d??r;if(g&&(!h||h.offset<g.offset))i(g,"MISSING_CHAR","Missing newline after block sequence props")}let a=n.type==="block-map"?"map":n.type==="block-seq"?"seq":n.start.source==="{"?"map":"seq";if(!r||!o||o==="!"||o===Db.YAMLMap.tagName&&a==="map"||o===jb.YAMLSeq.tagName&&a==="seq")return Wi(e,t,n,i,o);let l=t.schema.tags.find((d)=>d.tag===o&&d.collection===a);if(!l){let d=t.schema.knownTags[o];if(d?.collection===a)t.schema.tags.push(Object.assign({},d,{default:!1})),l=d;else{if(d)i(r,"BAD_COLLECTION_TYPE",`${d.tag} used for ${a} collection, but expects ${d.collection??"scalar"}`,!0);else i(r,"TAG_RESOLVE_FAILED",`Unresolved tag: ${o}`,!0);return Wi(e,t,n,i,o)}}let c=Wi(e,t,n,i,o,l),u=l.resolve?.(c,(d)=>i(r,"TAG_RESOLVE_FAILED",d),t.options)??c,f=Pb.isNode(u)?u:new qb.Scalar(u);if(f.range=c.range,f.tag=o,l?.format)f.format=l.format;return f}Vb.composeCollection=Bb});var Ki=k(function(Gb){var Hi=j();function Hb(e,t,n){let s=t.offset,i=Kb(t,e.options.strict,n);if(!i)return{value:"",type:null,comment:"",range:[s,s,s]};let r=i.mode===">"?Hi.Scalar.BLOCK_FOLDED:Hi.Scalar.BLOCK_LITERAL,o=t.source?Jb(t.source):[],a=o.length;for(let p=o.length-1;p>=0;--p){let m=o[p][1];if(m===""||m==="\r")a=p;else break}if(a===0){let p=i.chomp==="+"&&o.length>0?`
72
+ `.repeat(Math.max(1,o.length-1)):"",m=s+i.length;if(t.source)m+=t.source.length;return{value:p,type:r,comment:i.comment,range:[s,m,m]}}let l=t.indent+i.indent,c=t.offset+i.length,u=0;for(let p=0;p<a;++p){let[m,O]=o[p];if(O===""||O==="\r"){if(i.indent===0&&m.length>l)l=m.length}else{if(m.length<l)n(c+m.length,"MISSING_CHAR","Block scalars with more-indented leading empty lines must use an explicit indentation indicator");if(i.indent===0)l=m.length;if(u=p,l===0&&!e.atRoot)n(c,"BAD_INDENT","Block scalar values in collections must be indented");break}c+=m.length+O.length+1}for(let p=o.length-1;p>=a;--p)if(o[p][0].length>l)a=p+1;let f="",d="",h=!1;for(let p=0;p<u;++p)f+=o[p][0].slice(l)+`
73
+ `;for(let p=u;p<a;++p){let[m,O]=o[p];c+=m.length+O.length+1;let y=O[O.length-1]==="\r";if(y)O=O.slice(0,-1);if(O&&m.length<l){let _=`Block scalar lines must not be less indented than their ${i.indent?"explicit indentation indicator":"first line"}`;n(c-O.length-(y?2:1),"BAD_INDENT",_),m=""}if(r===Hi.Scalar.BLOCK_LITERAL)f+=d+m.slice(l)+O,d=`
74
+ `;else if(m.length>l||O[0]==="\t"){if(d===" ")d=`
75
+ `;else if(!h&&d===`
76
+ `)d=`
77
+
78
+ `;f+=d+m.slice(l)+O,d=`
79
+ `,h=!0}else if(O==="")if(d===`
80
+ `)f+=`
81
+ `;else d=`
82
+ `;else f+=d+O,d=" ",h=!1}switch(i.chomp){case"-":break;case"+":for(let p=a;p<o.length;++p)f+=`
83
+ `+o[p][0].slice(l);if(f[f.length-1]!==`
84
+ `)f+=`
85
+ `;break;default:f+=`
86
+ `}let g=s+i.length+t.source.length;return{value:f,type:r,comment:i.comment,range:[s,g,g]}}function Kb({offset:e,props:t},n,s){if(t[0].type!=="block-scalar-header")return s(t[0],"IMPOSSIBLE","Block scalar header not found"),null;let{source:i}=t[0],r=i[0],o=0,a="",l=-1;for(let d=1;d<i.length;++d){let h=i[d];if(!a&&(h==="-"||h==="+"))a=h;else{let g=Number(h);if(!o&&g)o=g;else if(l===-1)l=e+d}}if(l!==-1)s(l,"UNEXPECTED_TOKEN",`Block scalar header includes extra characters: ${i}`);let c=!1,u="",f=i.length;for(let d=1;d<t.length;++d){let h=t[d];switch(h.type){case"space":c=!0;case"newline":f+=h.source.length;break;case"comment":if(n&&!c)s(h,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");f+=h.source.length,u=h.source.substring(1);break;case"error":s(h,"UNEXPECTED_TOKEN",h.message),f+=h.source.length;break;default:{let g=`Unexpected token in block scalar header: ${h.type}`;s(h,"UNEXPECTED_TOKEN",g);let p=h.source;if(p&&typeof p==="string")f+=p.length}}}return{mode:r,indent:o,chomp:a,comment:u,length:f}}function Jb(e){let t=e.split(/\n( *)/),n=t[0],s=n.match(/^( *)/),r=[s?.[1]?[s[1],n.slice(s[1].length)]:["",n]];for(let o=1;o<t.length;o+=2)r.push([t[o],t[o+1]]);return r}Gb.resolveBlockScalar=Hb});var Gi=k(function(i_){var Ji=j(),zb=st();function Xb(e,t,n){let{offset:s,type:i,source:r,end:o}=e,a,l,c=(d,h,g)=>n(s+d,h,g);switch(i){case"scalar":a=Ji.Scalar.PLAIN,l=Qb(r,c);break;case"single-quoted-scalar":a=Ji.Scalar.QUOTE_SINGLE,l=Zb(r,c);break;case"double-quoted-scalar":a=Ji.Scalar.QUOTE_DOUBLE,l=e_(r,c);break;default:return n(e,"UNEXPECTED_TOKEN",`Expected a flow scalar value, but found: ${i}`),{value:"",type:null,comment:"",range:[s,s+r.length,s+r.length]}}let u=s+r.length,f=zb.resolveEnd(o,u,t,n);return{value:l,type:a,comment:f.comment,range:[s,u,f.offset]}}function Qb(e,t){let n="";switch(e[0]){case"\t":n="a tab character";break;case",":n="flow indicator character ,";break;case"%":n="directive indicator character %";break;case"|":case">":{n=`block scalar indicator ${e[0]}`;break}case"@":case"`":{n=`reserved character ${e[0]}`;break}}if(n)t(0,"BAD_SCALAR_START",`Plain value cannot start with ${n}`);return xl(e)}function Zb(e,t){if(e[e.length-1]!=="'"||e.length===1)t(e.length,"MISSING_CHAR","Missing closing 'quote");return xl(e.slice(1,-1)).replace(/''/g,"'")}function xl(e){let t=/(.*?)\r?\n/sy,n=t.exec(e);if(!n)return e;let s,i;try{s=new RegExp("(?<![ \t])[ \t]+$"),i=new RegExp("^[ \t]+|(?<![ \t])[ \t]+$","g")}catch{s=/[ \t]+$/,i=/^[ \t]+|[ \t]+$/g}let r=n[1].replace(s,""),o=" ",a=t.lastIndex;while(n=t.exec(e)){let c=n[1].replace(i,"");if(c==="")if(o===`
87
+ `)r+=o;else o=`
88
+ `;else r+=o+c,o=" ";a=t.lastIndex}let l=/[ \t]*(.*)/sy;return l.lastIndex=a,n=l.exec(e),r+o+(n?.[1]??"")}function e_(e,t){let n="";for(let s=1;s<e.length-1;++s){let i=e[s];if(i==="\r"&&e[s+1]===`
89
+ `)continue;if(i===`
90
+ `){let{fold:r,offset:o}=t_(e,s);n+=r,s=o}else if(i==="\\"){let r=e[++s],o=n_[r];if(o)n+=o;else if(r===`
91
+ `){r=e[s+1];while(r===" "||r==="\t")r=e[++s+1]}else if(r==="\r"&&e[s+1]===`
92
+ `){r=e[++s+1];while(r===" "||r==="\t")r=e[++s+1]}else if(r==="x"||r==="u"||r==="U"){let a=r==="x"?2:r==="u"?4:8;n+=s_(e,s+1,a,t),s+=a}else{let a=e.substr(s-1,2);t(s-1,"BAD_DQ_ESCAPE",`Invalid escape sequence ${a}`),n+=a}}else if(i===" "||i==="\t"){let r=s,o=e[s+1];while(o===" "||o==="\t")o=e[++s+1];if(o!==`
93
+ `&&!(o==="\r"&&e[s+2]===`
94
+ `))n+=s>r?e.slice(r,s+1):i}else n+=i}if(e[e.length-1]!=='"'||e.length===1)t(e.length,"MISSING_CHAR",'Missing closing "quote');return n}function t_(e,t){let n="",s=e[t+1];while(s===" "||s==="\t"||s===`
95
+ `||s==="\r"){if(s==="\r"&&e[t+2]!==`
96
+ `)break;if(s===`
97
+ `)n+=`
98
+ `;t+=1,s=e[t+1]}if(!n)n=" ";return{fold:n,offset:t}}var n_={"0":"\x00",a:"\x07",b:"\b",e:"\x1B",f:"\f",n:`
99
+ `,r:"\r",t:"\t",v:"\v",N:"…",_:" ",L:"\u2028",P:"\u2029"," ":" ",'"':'"',"/":"/","\\":"\\","\t":"\t"};function s_(e,t,n,s){let i=e.substr(t,n),o=i.length===n&&/^[0-9a-fA-F]+$/.test(i)?parseInt(i,16):NaN;try{return String.fromCodePoint(o)}catch{let a=e.substr(t-2,n+2);return s(t-2,"BAD_DQ_ESCAPE",`Invalid escape sequence ${a}`),a}}i_.resolveFlowScalar=Xb});var Cl=k(function(f_){var Ie=R(),Al=j(),o_=Ki(),a_=Gi();function l_(e,t,n,s){let{value:i,type:r,comment:o,range:a}=t.type==="block-scalar"?o_.resolveBlockScalar(e,t,s):a_.resolveFlowScalar(t,e.options.strict,s),l=n?e.directives.tagName(n.source,(f)=>s(n,"TAG_RESOLVE_FAILED",f)):null,c;if(e.options.stringKeys&&e.atKey)c=e.schema[Ie.SCALAR];else if(l)c=c_(e.schema,i,l,n,s);else if(t.type==="scalar")c=u_(e,i,t,s);else c=e.schema[Ie.SCALAR];let u;try{let f=c.resolve(i,(d)=>s(n??t,"TAG_RESOLVE_FAILED",d),e.options);u=Ie.isScalar(f)?f:new Al.Scalar(f)}catch(f){let d=f instanceof Error?f.message:String(f);s(n??t,"TAG_RESOLVE_FAILED",d),u=new Al.Scalar(i)}if(u.range=a,u.source=i,r)u.type=r;if(l)u.tag=l;if(c.format)u.format=c.format;if(o)u.comment=o;return u}function c_(e,t,n,s,i){if(n==="!")return e[Ie.SCALAR];let r=[];for(let a of e.tags)if(!a.collection&&a.tag===n)if(a.default&&a.test)r.push(a);else return a;for(let a of r)if(a.test?.test(t))return a;let o=e.knownTags[n];if(o&&!o.collection)return e.tags.push(Object.assign({},o,{default:!1,test:void 0})),o;return i(s,"TAG_RESOLVE_FAILED",`Unresolved tag: ${n}`,n!=="tag:yaml.org,2002:str"),e[Ie.SCALAR]}function u_({atKey:e,directives:t,schema:n},s,i,r){let o=n.tags.find((a)=>(a.default===!0||e&&a.default==="key")&&a.test?.test(s))||n[Ie.SCALAR];if(n.compat){let a=n.compat.find((l)=>l.default&&l.test?.test(s))??n[Ie.SCALAR];if(o.tag!==a.tag){let l=t.tagString(o.tag),c=t.tagString(a.tag),u=`Value may be parsed as either ${l} or ${c}`;r(i,"TAG_RESOLVE_FAILED",u,!0)}}return o}f_.composeScalar=l_});var Tl=k(function(h_){function p_(e,t,n){if(t){n??(n=t.length);for(let s=n-1;s>=0;--s){let i=t[s];switch(i.type){case"space":case"comment":case"newline":e-=i.source.length;continue}i=t[++s];while(i?.type==="space")e+=i.source.length,i=t[++s];break}}return e}h_.emptyScalarPosition=p_});var Nl=k(function(E_){var g_=vt(),y_=R(),w_=Ol(),Rl=Cl(),b_=st(),__=Tl(),S_={composeNode:$l,composeEmptyNode:Yi};function $l(e,t,n,s){let i=e.atKey,{spaceBefore:r,comment:o,anchor:a,tag:l}=n,c,u=!0;switch(t.type){case"alias":if(c=v_(e,t,s),a||l)s(t,"ALIAS_PROPS","An alias node must not specify any properties");break;case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"block-scalar":if(c=Rl.composeScalar(e,t,l,s),a)c.anchor=a.source.substring(1);break;case"block-map":case"block-seq":case"flow-collection":try{if(c=w_.composeCollection(S_,e,t,n,s),a)c.anchor=a.source.substring(1)}catch(f){let d=f instanceof Error?f.message:String(f);s(t,"RESOURCE_EXHAUSTION",d)}break;default:{let f=t.type==="error"?t.message:`Unsupported token (type: ${t.type})`;s(t,"UNEXPECTED_TOKEN",f),u=!1}}if(c??(c=Yi(e,t.offset,void 0,null,n,s)),a&&c.anchor==="")s(a,"BAD_ALIAS","Anchor cannot be an empty string");if(i&&e.options.stringKeys&&(!y_.isScalar(c)||typeof c.value!=="string"||c.tag&&c.tag!=="tag:yaml.org,2002:str"))s(l??t,"NON_STRING_KEY","With stringKeys, all keys must be strings");if(r)c.spaceBefore=!0;if(o)if(t.type==="scalar"&&t.source==="")c.comment=o;else c.commentBefore=o;if(e.options.keepSourceTokens&&u)c.srcToken=t;return c}function Yi(e,t,n,s,{spaceBefore:i,comment:r,anchor:o,tag:a,end:l},c){let u={type:"scalar",offset:__.emptyScalarPosition(t,n,s),indent:-1,source:""},f=Rl.composeScalar(e,u,a,c);if(o){if(f.anchor=o.source.substring(1),f.anchor==="")c(o,"BAD_ALIAS","Anchor cannot be an empty string")}if(i)f.spaceBefore=!0;if(r)f.comment=r,f.range[2]=l;return f}function v_({options:e},{offset:t,source:n,end:s},i){let r=new g_.Alias(n.substring(1));if(r.source==="")i(t,"BAD_ALIAS","Alias cannot be an empty string");if(r.source.endsWith(":"))i(t+n.length-1,"BAD_ALIAS","Alias ending in : is ambiguous",!0);let o=t+n.length,a=b_.resolveEnd(s,o,e.strict,i);if(r.range=[t,o,a.offset],a.comment)r.comment=a.comment;return r}E_.composeEmptyNode=Yi;E_.composeNode=$l});var Il=k(function(R_){var x_=qt(),Ll=Nl(),A_=st(),C_=jt();function T_(e,t,{offset:n,start:s,value:i,end:r},o){let a=Object.assign({_directives:t},e),l=new x_.Document(void 0,a),c={atKey:!1,atRoot:!0,directives:l.directives,options:l.options,schema:l.schema},u=C_.resolveProps(s,{indicator:"doc-start",next:i??r?.[0],offset:n,onError:o,parentIndent:0,startOnNewline:!0});if(u.found){if(l.directives.docStart=!0,i&&(i.type==="block-map"||i.type==="block-seq")&&!u.hasNewline)o(u.end,"MISSING_CHAR","Block collection cannot start on same line with directives-end marker")}l.contents=i?Ll.composeNode(c,i,u,o):Ll.composeEmptyNode(c,u.end,s,null,u,o);let f=l.contents.range[2],d=A_.resolveEnd(r,f,!1,o);if(d.comment)l.comment=d.comment;return l.range=[n,f,d.offset],l}R_.composeDoc=T_});var zi=k(function(D_){var N_=sn("process"),L_=ei(),I_=qt(),Mt=Dt(),Pl=R(),P_=Il(),q_=st();function Ft(e){if(typeof e==="number")return[e,e+1];if(Array.isArray(e))return e.length===2?e:[e[0],e[1]];let{offset:t,source:n}=e;return[t,t+(typeof n==="string"?n.length:1)]}function ql(e){let t="",n=!1,s=!1;for(let i=0;i<e.length;++i){let r=e[i];switch(r[0]){case"#":t+=(t===""?"":s?`
100
+
101
+ `:`
102
+ `)+(r.substring(1)||" "),n=!0,s=!1;break;case"%":if(e[i+1]?.[0]!=="#")i+=1;n=!1;break;default:if(!n)s=!0;n=!1}}return{comment:t,afterEmptyLine:s}}class Dl{constructor(e={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(t,n,s,i)=>{let r=Ft(t);if(i)this.warnings.push(new Mt.YAMLWarning(r,n,s));else this.errors.push(new Mt.YAMLParseError(r,n,s))},this.directives=new L_.Directives({version:e.version||"1.2"}),this.options=e}decorate(e,t){let{comment:n,afterEmptyLine:s}=ql(this.prelude);if(n){let i=e.contents;if(t)e.comment=e.comment?`${e.comment}
103
+ ${n}`:n;else if(s||e.directives.docStart||!i)e.commentBefore=n;else if(Pl.isCollection(i)&&!i.flow&&i.items.length>0){let r=i.items[0];if(Pl.isPair(r))r=r.key;let o=r.commentBefore;r.commentBefore=o?`${n}
104
+ ${o}`:n}else{let r=i.commentBefore;i.commentBefore=r?`${n}
105
+ ${r}`:n}}if(t){for(let i=0;i<this.errors.length;++i)e.errors.push(this.errors[i]);for(let i=0;i<this.warnings.length;++i)e.warnings.push(this.warnings[i])}else e.errors=this.errors,e.warnings=this.warnings;this.prelude=[],this.errors=[],this.warnings=[]}streamInfo(){return{comment:ql(this.prelude).comment,directives:this.directives,errors:this.errors,warnings:this.warnings}}*compose(e,t=!1,n=-1){for(let s of e)yield*this.next(s);yield*this.end(t,n)}*next(e){if(N_.env.LOG_STREAM)console.dir(e,{depth:null});switch(e.type){case"directive":this.directives.add(e.source,(t,n,s)=>{let i=Ft(e);i[0]+=t,this.onError(i,"BAD_DIRECTIVE",n,s)}),this.prelude.push(e.source),this.atDirectives=!0;break;case"document":{let t=P_.composeDoc(this.options,this.directives,e,this.onError);if(this.atDirectives&&!t.directives.docStart)this.onError(e,"MISSING_CHAR","Missing directives-end/doc-start indicator line");if(this.decorate(t,!1),this.doc)yield this.doc;this.doc=t,this.atDirectives=!1;break}case"byte-order-mark":case"space":break;case"comment":case"newline":this.prelude.push(e.source);break;case"error":{let t=e.source?`${e.message}: ${JSON.stringify(e.source)}`:e.message,n=new Mt.YAMLParseError(Ft(e),"UNEXPECTED_TOKEN",t);if(this.atDirectives||!this.doc)this.errors.push(n);else this.doc.errors.push(n);break}case"doc-end":{if(!this.doc){this.errors.push(new Mt.YAMLParseError(Ft(e),"UNEXPECTED_TOKEN","Unexpected doc-end without preceding document"));break}this.doc.directives.docEnd=!0;let t=q_.resolveEnd(e.end,e.offset+e.source.length,this.doc.options.strict,this.onError);if(this.decorate(this.doc,!0),t.comment){let n=this.doc.comment;this.doc.comment=n?`${n}
106
+ ${t.comment}`:t.comment}this.doc.range[2]=t.offset;break}default:this.errors.push(new Mt.YAMLParseError(Ft(e),"UNEXPECTED_TOKEN",`Unsupported token ${e.type}`))}}*end(e=!1,t=-1){if(this.doc)this.decorate(this.doc,!0),yield this.doc,this.doc=null;else if(e){let n=Object.assign({_directives:this.directives},this.options),s=new I_.Document(void 0,n);if(this.atDirectives)this.onError(t,"MISSING_CHAR","Missing directives-end indicator line");s.range=[0,t,t],this.decorate(s,!1),yield s}}}D_.Composer=Dl});var Fl=k(function(K_){var M_=Ki(),F_=Gi(),U_=Dt(),jl=xt();function B_(e,t=!0,n){if(e){let s=(i,r,o)=>{let a=typeof i==="number"?i:Array.isArray(i)?i[0]:i.offset;if(n)n(a,r,o);else throw new U_.YAMLParseError([a,a+1],r,o)};switch(e.type){case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return F_.resolveFlowScalar(e,t,s);case"block-scalar":return M_.resolveBlockScalar({options:{strict:t}},e,s)}}return null}function V_(e,t){let{implicitKey:n=!1,indent:s,inFlow:i=!1,offset:r=-1,type:o="PLAIN"}=t,a=jl.stringifyString({type:o,value:e},{implicitKey:n,indent:s>0?" ".repeat(s):"",inFlow:i,options:{blockQuote:!0,lineWidth:-1}}),l=t.end??[{type:"newline",offset:-1,indent:s,source:`
107
+ `}];switch(a[0]){case"|":case">":{let c=a.indexOf(`
108
+ `),u=a.substring(0,c),f=a.substring(c+1)+`
109
+ `,d=[{type:"block-scalar-header",offset:r,indent:s,source:u}];if(!Ml(d,l))d.push({type:"newline",offset:-1,indent:s,source:`
110
+ `});return{type:"block-scalar",offset:r,indent:s,props:d,source:f}}case'"':return{type:"double-quoted-scalar",offset:r,indent:s,source:a,end:l};case"'":return{type:"single-quoted-scalar",offset:r,indent:s,source:a,end:l};default:return{type:"scalar",offset:r,indent:s,source:a,end:l}}}function W_(e,t,n={}){let{afterKey:s=!1,implicitKey:i=!1,inFlow:r=!1,type:o}=n,a="indent"in e?e.indent:null;if(s&&typeof a==="number")a+=2;if(!o)switch(e.type){case"single-quoted-scalar":o="QUOTE_SINGLE";break;case"double-quoted-scalar":o="QUOTE_DOUBLE";break;case"block-scalar":{let c=e.props[0];if(c.type!=="block-scalar-header")throw Error("Invalid block scalar header");o=c.source[0]===">"?"BLOCK_FOLDED":"BLOCK_LITERAL";break}default:o="PLAIN"}let l=jl.stringifyString({type:o,value:t},{implicitKey:i||a===null,indent:a!==null&&a>0?" ".repeat(a):"",inFlow:r,options:{blockQuote:!0,lineWidth:-1}});switch(l[0]){case"|":case">":H_(e,l);break;case'"':Xi(e,l,"double-quoted-scalar");break;case"'":Xi(e,l,"single-quoted-scalar");break;default:Xi(e,l,"scalar")}}function H_(e,t){let n=t.indexOf(`
111
+ `),s=t.substring(0,n),i=t.substring(n+1)+`
112
+ `;if(e.type==="block-scalar"){let r=e.props[0];if(r.type!=="block-scalar-header")throw Error("Invalid block scalar header");r.source=s,e.source=i}else{let{offset:r}=e,o="indent"in e?e.indent:-1,a=[{type:"block-scalar-header",offset:r,indent:o,source:s}];if(!Ml(a,"end"in e?e.end:void 0))a.push({type:"newline",offset:-1,indent:o,source:`
113
+ `});for(let l of Object.keys(e))if(l!=="type"&&l!=="offset")delete e[l];Object.assign(e,{type:"block-scalar",indent:o,props:a,source:i})}}function Ml(e,t){if(t)for(let n of t)switch(n.type){case"space":case"comment":e.push(n);break;case"newline":return e.push(n),!0}return!1}function Xi(e,t,n){switch(e.type){case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":e.type=n,e.source=t;break;case"block-scalar":{let s=e.props.slice(1),i=t.length;if(e.props[0].type==="block-scalar-header")i-=e.props[0].source.length;for(let r of s)r.offset+=i;delete e.props,Object.assign(e,{type:n,source:t,end:s});break}case"block-map":case"block-seq":{let i={type:"newline",offset:e.offset+t.length,indent:e.indent,source:`
114
+ `};delete e.items,Object.assign(e,{type:n,source:t,end:[i]});break}default:{let s="indent"in e?e.indent:-1,i="end"in e&&Array.isArray(e.end)?e.end.filter((r)=>r.type==="space"||r.type==="comment"||r.type==="newline"):[];for(let r of Object.keys(e))if(r!=="type"&&r!=="offset")delete e[r];Object.assign(e,{type:n,indent:s,source:t,end:i})}}}K_.createScalarToken=V_;K_.resolveAsScalar=B_;K_.setScalarValue=W_});var Ul=k(function(X_){var z_=(e)=>("type"in e)?es(e):Zn(e);function es(e){switch(e.type){case"block-scalar":{let t="";for(let n of e.props)t+=es(n);return t+e.source}case"block-map":case"block-seq":{let t="";for(let n of e.items)t+=Zn(n);return t}case"flow-collection":{let t=e.start.source;for(let n of e.items)t+=Zn(n);for(let n of e.end)t+=n.source;return t}case"document":{let t=Zn(e);if(e.end)for(let n of e.end)t+=n.source;return t}default:{let t=e.source;if("end"in e&&e.end)for(let n of e.end)t+=n.source;return t}}}function Zn({start:e,key:t,sep:n,value:s}){let i="";for(let r of e)i+=r.source;if(t)i+=es(t);if(n)for(let r of n)i+=r.source;if(s)i+=es(s);return i}X_.stringify=z_});var Wl=k(function(eS){var Qi=Symbol("break visit"),Z_=Symbol("skip children"),Bl=Symbol("remove item");function Pe(e,t){if("type"in e&&e.type==="document")e={start:e.start,value:e.value};Vl(Object.freeze([]),e,t)}Pe.BREAK=Qi;Pe.SKIP=Z_;Pe.REMOVE=Bl;Pe.itemAtPath=(e,t)=>{let n=e;for(let[s,i]of t){let r=n?.[s];if(r&&"items"in r)n=r.items[i];else return}return n};Pe.parentCollection=(e,t)=>{let n=Pe.itemAtPath(e,t.slice(0,-1)),s=t[t.length-1][0],i=n?.[s];if(i&&"items"in i)return i;throw Error("Parent collection not found")};function Vl(e,t,n){let s=n(t,e);if(typeof s==="symbol")return s;for(let i of["key","value"]){let r=t[i];if(r&&"items"in r){for(let o=0;o<r.items.length;++o){let a=Vl(Object.freeze(e.concat([[i,o]])),r.items[o],n);if(typeof a==="number")o=a-1;else if(a===Qi)return Qi;else if(a===Bl)r.items.splice(o,1),o-=1}if(typeof s==="function"&&i==="key")s=s(t,e)}}return typeof s==="function"?s(t,e):s}eS.visit=Pe});var ts=k(function(lS){var Zi=Fl(),nS=Ul(),sS=Wl(),er="\uFEFF",tr="\x02",nr="\x18",sr="\x1F",iS=(e)=>!!e&&("items"in e),rS=(e)=>!!e&&(e.type==="scalar"||e.type==="single-quoted-scalar"||e.type==="double-quoted-scalar"||e.type==="block-scalar");function oS(e){switch(e){case er:return"<BOM>";case tr:return"<DOC>";case nr:return"<FLOW_END>";case sr:return"<SCALAR>";default:return JSON.stringify(e)}}function aS(e){switch(e){case er:return"byte-order-mark";case tr:return"doc-mode";case nr:return"flow-error-end";case sr:return"scalar";case"---":return"doc-start";case"...":return"doc-end";case"":case`
115
+ `:case`\r
116
+ `:return"newline";case"-":return"seq-item-ind";case"?":return"explicit-key-ind";case":":return"map-value-ind";case"{":return"flow-map-start";case"}":return"flow-map-end";case"[":return"flow-seq-start";case"]":return"flow-seq-end";case",":return"comma"}switch(e[0]){case" ":case"\t":return"space";case"#":return"comment";case"%":return"directive-line";case"*":return"alias";case"&":return"anchor";case"!":return"tag";case"'":return"single-quoted-scalar";case'"':return"double-quoted-scalar";case"|":case">":return"block-scalar-header"}return null}lS.createScalarToken=Zi.createScalarToken;lS.resolveAsScalar=Zi.resolveAsScalar;lS.setScalarValue=Zi.setScalarValue;lS.stringify=nS.stringify;lS.visit=sS.visit;lS.BOM=er;lS.DOCUMENT=tr;lS.FLOW_END=nr;lS.SCALAR=sr;lS.isCollection=iS;lS.isScalar=rS;lS.prettyToken=oS;lS.tokenType=aS});var rr=k(function(kS){var Ut=ts();function te(e){switch(e){case void 0:case" ":case`
117
+ `:case"\r":case"\t":return!0;default:return!1}}var Hl=new Set("0123456789ABCDEFabcdef"),vS=new Set("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()"),ns=new Set(",[]{}"),ES=new Set(` ,[]{}
118
+ \r `),ir=(e)=>!e||ES.has(e);class Kl{constructor(){this.atEnd=!1,this.blockScalarIndent=-1,this.blockScalarKeep=!1,this.buffer="",this.flowKey=!1,this.flowLevel=0,this.indentNext=0,this.indentValue=0,this.lineEndPos=null,this.next=null,this.pos=0}*lex(e,t=!1){if(e){if(typeof e!=="string")throw TypeError("source is not a string");this.buffer=this.buffer?this.buffer+e:e,this.lineEndPos=null}this.atEnd=!t;let n=this.next??"stream";while(n&&(t||this.hasChars(1)))n=yield*this.parseNext(n)}atLineEnd(){let e=this.pos,t=this.buffer[e];while(t===" "||t==="\t")t=this.buffer[++e];if(!t||t==="#"||t===`
119
+ `)return!0;if(t==="\r")return this.buffer[e+1]===`
120
+ `;return!1}charAt(e){return this.buffer[this.pos+e]}continueScalar(e){let t=this.buffer[e];if(this.indentNext>0){let n=0;while(t===" ")t=this.buffer[++n+e];if(t==="\r"){let s=this.buffer[n+e+1];if(s===`
121
+ `||!s&&!this.atEnd)return e+n+1}return t===`
122
+ `||n>=this.indentNext||!t&&!this.atEnd?e+n:-1}if(t==="-"||t==="."){let n=this.buffer.substr(e,3);if((n==="---"||n==="...")&&te(this.buffer[e+3]))return-1}return e}getLine(){let e=this.lineEndPos;if(typeof e!=="number"||e!==-1&&e<this.pos)e=this.buffer.indexOf(`
123
+ `,this.pos),this.lineEndPos=e;if(e===-1)return this.atEnd?this.buffer.substring(this.pos):null;if(this.buffer[e-1]==="\r")e-=1;return this.buffer.substring(this.pos,e)}hasChars(e){return this.pos+e<=this.buffer.length}setNext(e){return this.buffer=this.buffer.substring(this.pos),this.pos=0,this.lineEndPos=null,this.next=e,null}peek(e){return this.buffer.substr(this.pos,e)}*parseNext(e){switch(e){case"stream":return yield*this.parseStream();case"line-start":return yield*this.parseLineStart();case"block-start":return yield*this.parseBlockStart();case"doc":return yield*this.parseDocument();case"flow":return yield*this.parseFlowCollection();case"quoted-scalar":return yield*this.parseQuotedScalar();case"block-scalar":return yield*this.parseBlockScalar();case"plain-scalar":return yield*this.parsePlainScalar()}}*parseStream(){let e=this.getLine();if(e===null)return this.setNext("stream");if(e[0]===Ut.BOM)yield*this.pushCount(1),e=e.substring(1);if(e[0]==="%"){let t=e.length,n=e.indexOf("#");while(n!==-1){let i=e[n-1];if(i===" "||i==="\t"){t=n-1;break}else n=e.indexOf("#",n+1)}while(!0){let i=e[t-1];if(i===" "||i==="\t")t-=1;else break}let s=(yield*this.pushCount(t))+(yield*this.pushSpaces(!0));return yield*this.pushCount(e.length-s),this.pushNewline(),"stream"}if(this.atLineEnd()){let t=yield*this.pushSpaces(!0);return yield*this.pushCount(e.length-t),yield*this.pushNewline(),"stream"}return yield Ut.DOCUMENT,yield*this.parseLineStart()}*parseLineStart(){let e=this.charAt(0);if(!e&&!this.atEnd)return this.setNext("line-start");if(e==="-"||e==="."){if(!this.atEnd&&!this.hasChars(4))return this.setNext("line-start");let t=this.peek(3);if((t==="---"||t==="...")&&te(this.charAt(3)))return yield*this.pushCount(3),this.indentValue=0,this.indentNext=0,t==="---"?"doc":"stream"}if(this.indentValue=yield*this.pushSpaces(!1),this.indentNext>this.indentValue&&!te(this.charAt(1)))this.indentNext=this.indentValue;return yield*this.parseBlockStart()}*parseBlockStart(){let[e,t]=this.peek(2);if(!t&&!this.atEnd)return this.setNext("block-start");if((e==="-"||e==="?"||e===":")&&te(t)){let n=(yield*this.pushCount(1))+(yield*this.pushSpaces(!0));return this.indentNext=this.indentValue+1,this.indentValue+=n,"block-start"}return"doc"}*parseDocument(){yield*this.pushSpaces(!0);let e=this.getLine();if(e===null)return this.setNext("doc");let t=yield*this.pushIndicators();switch(e[t]){case"#":yield*this.pushCount(e.length-t);case void 0:return yield*this.pushNewline(),yield*this.parseLineStart();case"{":case"[":return yield*this.pushCount(1),this.flowKey=!1,this.flowLevel=1,"flow";case"}":case"]":return yield*this.pushCount(1),"doc";case"*":return yield*this.pushUntil(ir),"doc";case'"':case"'":return yield*this.parseQuotedScalar();case"|":case">":return t+=yield*this.parseBlockScalarHeader(),t+=yield*this.pushSpaces(!0),yield*this.pushCount(e.length-t),yield*this.pushNewline(),yield*this.parseBlockScalar();default:return yield*this.parsePlainScalar()}}*parseFlowCollection(){let e,t,n=-1;do{if(e=yield*this.pushNewline(),e>0)t=yield*this.pushSpaces(!1),this.indentValue=n=t;else t=0;t+=yield*this.pushSpaces(!0)}while(e+t>0);let s=this.getLine();if(s===null)return this.setNext("flow");if(n!==-1&&n<this.indentNext&&s[0]!=="#"||n===0&&(s.startsWith("---")||s.startsWith("..."))&&te(s[3])){if(!(n===this.indentNext-1&&this.flowLevel===1&&(s[0]==="]"||s[0]==="}")))return this.flowLevel=0,yield Ut.FLOW_END,yield*this.parseLineStart()}let i=0;while(s[i]===",")i+=yield*this.pushCount(1),i+=yield*this.pushSpaces(!0),this.flowKey=!1;switch(i+=yield*this.pushIndicators(),s[i]){case void 0:return"flow";case"#":return yield*this.pushCount(s.length-i),"flow";case"{":case"[":return yield*this.pushCount(1),this.flowKey=!1,this.flowLevel+=1,"flow";case"}":case"]":return yield*this.pushCount(1),this.flowKey=!0,this.flowLevel-=1,this.flowLevel?"flow":"doc";case"*":return yield*this.pushUntil(ir),"flow";case'"':case"'":return this.flowKey=!0,yield*this.parseQuotedScalar();case":":{let r=this.charAt(1);if(this.flowKey||te(r)||r===",")return this.flowKey=!1,yield*this.pushCount(1),yield*this.pushSpaces(!0),"flow"}default:return this.flowKey=!1,yield*this.parsePlainScalar()}}*parseQuotedScalar(){let e=this.charAt(0),t=this.buffer.indexOf(e,this.pos+1);if(e==="'")while(t!==-1&&this.buffer[t+1]==="'")t=this.buffer.indexOf("'",t+2);else while(t!==-1){let i=0;while(this.buffer[t-1-i]==="\\")i+=1;if(i%2===0)break;t=this.buffer.indexOf('"',t+1)}let n=this.buffer.substring(0,t),s=n.indexOf(`
124
+ `,this.pos);if(s!==-1){while(s!==-1){let i=this.continueScalar(s+1);if(i===-1)break;s=n.indexOf(`
125
+ `,i)}if(s!==-1)t=s-(n[s-1]==="\r"?2:1)}if(t===-1){if(!this.atEnd)return this.setNext("quoted-scalar");t=this.buffer.length}return yield*this.pushToIndex(t+1,!1),this.flowLevel?"flow":"doc"}*parseBlockScalarHeader(){this.blockScalarIndent=-1,this.blockScalarKeep=!1;let e=this.pos;while(!0){let t=this.buffer[++e];if(t==="+")this.blockScalarKeep=!0;else if(t>"0"&&t<="9")this.blockScalarIndent=Number(t)-1;else if(t!=="-")break}return yield*this.pushUntil((t)=>te(t)||t==="#")}*parseBlockScalar(){let e=this.pos-1,t=0,n;e:for(let i=this.pos;n=this.buffer[i];++i)switch(n){case" ":t+=1;break;case`
126
+ `:e=i,t=0;break;case"\r":{let r=this.buffer[i+1];if(!r&&!this.atEnd)return this.setNext("block-scalar");if(r===`
127
+ `)break}default:break e}if(!n&&!this.atEnd)return this.setNext("block-scalar");if(t>=this.indentNext){if(this.blockScalarIndent===-1)this.indentNext=t;else this.indentNext=this.blockScalarIndent+(this.indentNext===0?1:this.indentNext);do{let i=this.continueScalar(e+1);if(i===-1)break;e=this.buffer.indexOf(`
128
+ `,i)}while(e!==-1);if(e===-1){if(!this.atEnd)return this.setNext("block-scalar");e=this.buffer.length}}let s=e+1;n=this.buffer[s];while(n===" ")n=this.buffer[++s];if(n==="\t"){while(n==="\t"||n===" "||n==="\r"||n===`
129
+ `)n=this.buffer[++s];e=s-1}else if(!this.blockScalarKeep)do{let i=e-1,r=this.buffer[i];if(r==="\r")r=this.buffer[--i];let o=i;while(r===" ")r=this.buffer[--i];if(r===`
130
+ `&&i>=this.pos&&i+1+t>o)e=i;else break}while(!0);return yield Ut.SCALAR,yield*this.pushToIndex(e+1,!0),yield*this.parseLineStart()}*parsePlainScalar(){let e=this.flowLevel>0,t=this.pos-1,n=this.pos-1,s;while(s=this.buffer[++n])if(s===":"){let i=this.buffer[n+1];if(te(i)||e&&ns.has(i))break;t=n}else if(te(s)){let i=this.buffer[n+1];if(s==="\r")if(i===`
131
+ `)n+=1,s=`
132
+ `,i=this.buffer[n+1];else t=n;if(i==="#"||e&&ns.has(i))break;if(s===`
133
+ `){let r=this.continueScalar(n+1);if(r===-1)break;n=Math.max(n,r-2)}}else{if(e&&ns.has(s))break;t=n}if(!s&&!this.atEnd)return this.setNext("plain-scalar");return yield Ut.SCALAR,yield*this.pushToIndex(t+1,!0),e?"flow":"doc"}*pushCount(e){if(e>0)return yield this.buffer.substr(this.pos,e),this.pos+=e,e;return 0}*pushToIndex(e,t){let n=this.buffer.slice(this.pos,e);if(n)return yield n,this.pos+=n.length,n.length;else if(t)yield"";return 0}*pushIndicators(){let e=0;e:while(!0){switch(this.charAt(0)){case"!":e+=yield*this.pushTag(),e+=yield*this.pushSpaces(!0);continue e;case"&":e+=yield*this.pushUntil(ir),e+=yield*this.pushSpaces(!0);continue e;case"-":case"?":case":":{let t=this.flowLevel>0,n=this.charAt(1);if(te(n)||t&&ns.has(n)){if(!t)this.indentNext=this.indentValue+1;else if(this.flowKey)this.flowKey=!1;e+=yield*this.pushCount(1),e+=yield*this.pushSpaces(!0);continue e}}}break e}return e}*pushTag(){if(this.charAt(1)==="<"){let e=this.pos+2,t=this.buffer[e];while(!te(t)&&t!==">")t=this.buffer[++e];return yield*this.pushToIndex(t===">"?e+1:e,!1)}else{let e=this.pos+1,t=this.buffer[e];while(t)if(vS.has(t))t=this.buffer[++e];else if(t==="%"&&Hl.has(this.buffer[e+1])&&Hl.has(this.buffer[e+2]))t=this.buffer[e+=3];else break;return yield*this.pushToIndex(e,!1)}}*pushNewline(){let e=this.buffer[this.pos];if(e===`
134
+ `)return yield*this.pushCount(1);else if(e==="\r"&&this.charAt(1)===`
135
+ `)return yield*this.pushCount(2);else return 0}*pushSpaces(e){let t=this.pos-1,n;do n=this.buffer[++t];while(n===" "||e&&n==="\t");let s=t-this.pos;if(s>0)yield this.buffer.substr(this.pos,s),this.pos=t;return s}*pushUntil(e){let t=this.pos,n=this.buffer[t];while(!e(n))n=this.buffer[++t];return yield*this.pushToIndex(t,!1)}}kS.Lexer=Kl});var or=k(function(xS){class Jl{constructor(){this.lineStarts=[],this.addNewLine=(e)=>this.lineStarts.push(e),this.linePos=(e)=>{let t=0,n=this.lineStarts.length;while(t<n){let i=t+n>>1;if(this.lineStarts[i]<e)t=i+1;else n=i}if(this.lineStarts[t]===e)return{line:t+1,col:1};if(t===0)return{line:0,col:e};let s=this.lineStarts[t-1];return{line:t,col:e-s+1}}}}xS.LineCounter=Jl});var ar=k(function(RS){var CS=sn("process"),Gl=ts(),TS=rr();function Ee(e,t){for(let n=0;n<e.length;++n)if(e[n].type===t)return!0;return!1}function Yl(e){for(let t=0;t<e.length;++t)switch(e[t].type){case"space":case"comment":case"newline":break;default:return t}return-1}function Xl(e){switch(e?.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"flow-collection":return!0;default:return!1}}function ss(e){switch(e.type){case"document":return e.start;case"block-map":{let t=e.items[e.items.length-1];return t.sep??t.start}case"block-seq":return e.items[e.items.length-1].start;default:return[]}}function it(e){if(e.length===0)return[];let t=e.length;e:while(--t>=0)switch(e[t].type){case"doc-start":case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":case"newline":break e}while(e[++t]?.type==="space");return e.splice(t,e.length)}function is(e,t){if(t.length<1e5)Array.prototype.push.apply(e,t);else for(let n=0;n<t.length;++n)e.push(t[n])}function zl(e){if(e.start.type==="flow-seq-start"){for(let t of e.items)if(t.sep&&!t.value&&!Ee(t.start,"explicit-key-ind")&&!Ee(t.sep,"map-value-ind")){if(t.key)t.value=t.key;if(delete t.key,Xl(t.value))if(t.value.end)is(t.value.end,t.sep);else t.value.end=t.sep;else is(t.start,t.sep);delete t.sep}}}class Ql{constructor(e){this.atNewLine=!0,this.atScalar=!1,this.indent=0,this.offset=0,this.onKeyLine=!1,this.stack=[],this.source="",this.type="",this.lexer=new TS.Lexer,this.onNewLine=e}*parse(e,t=!1){if(this.onNewLine&&this.offset===0)this.onNewLine(0);for(let n of this.lexer.lex(e,t))yield*this.next(n);if(!t)yield*this.end()}*next(e){if(this.source=e,CS.env.LOG_TOKENS)console.log("|",Gl.prettyToken(e));if(this.atScalar){this.atScalar=!1,yield*this.step(),this.offset+=e.length;return}let t=Gl.tokenType(e);if(!t){let n=`Not a YAML token: ${e}`;yield*this.pop({type:"error",offset:this.offset,message:n,source:e}),this.offset+=e.length}else if(t==="scalar")this.atNewLine=!1,this.atScalar=!0,this.type="scalar";else{switch(this.type=t,yield*this.step(),t){case"newline":if(this.atNewLine=!0,this.indent=0,this.onNewLine)this.onNewLine(this.offset+e.length);break;case"space":if(this.atNewLine&&e[0]===" ")this.indent+=e.length;break;case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":if(this.atNewLine)this.indent+=e.length;break;case"doc-mode":case"flow-error-end":return;default:this.atNewLine=!1}this.offset+=e.length}}*end(){while(this.stack.length>0)yield*this.pop()}get sourceToken(){return{type:this.type,offset:this.offset,indent:this.indent,source:this.source}}*step(){let e=this.peek(1);if(this.type==="doc-end"&&e?.type!=="doc-end"){while(this.stack.length>0)yield*this.pop();this.stack.push({type:"doc-end",offset:this.offset,source:this.source});return}if(!e)return yield*this.stream();switch(e.type){case"document":return yield*this.document(e);case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return yield*this.scalar(e);case"block-scalar":return yield*this.blockScalar(e);case"block-map":return yield*this.blockMap(e);case"block-seq":return yield*this.blockSequence(e);case"flow-collection":return yield*this.flowCollection(e);case"doc-end":return yield*this.documentEnd(e)}yield*this.pop()}peek(e){return this.stack[this.stack.length-e]}*pop(e){let t=e??this.stack.pop();if(!t)yield{type:"error",offset:this.offset,source:"",message:"Tried to pop an empty stack"};else if(this.stack.length===0)yield t;else{let n=this.peek(1);if(t.type==="block-scalar")t.indent="indent"in n?n.indent:0;else if(t.type==="flow-collection"&&n.type==="document")t.indent=0;if(t.type==="flow-collection")zl(t);switch(n.type){case"document":n.value=t;break;case"block-scalar":n.props.push(t);break;case"block-map":{let s=n.items[n.items.length-1];if(s.value){n.items.push({start:[],key:t,sep:[]}),this.onKeyLine=!0;return}else if(s.sep)s.value=t;else{Object.assign(s,{key:t,sep:[]}),this.onKeyLine=!s.explicitKey;return}break}case"block-seq":{let s=n.items[n.items.length-1];if(s.value)n.items.push({start:[],value:t});else s.value=t;break}case"flow-collection":{let s=n.items[n.items.length-1];if(!s||s.value)n.items.push({start:[],key:t,sep:[]});else if(s.sep)s.value=t;else Object.assign(s,{key:t,sep:[]});return}default:yield*this.pop(),yield*this.pop(t)}if((n.type==="document"||n.type==="block-map"||n.type==="block-seq")&&(t.type==="block-map"||t.type==="block-seq")){let s=t.items[t.items.length-1];if(s&&!s.sep&&!s.value&&s.start.length>0&&Yl(s.start)===-1&&(t.indent===0||s.start.every((i)=>i.type!=="comment"||i.indent<t.indent))){if(n.type==="document")n.end=s.start;else n.items.push({start:s.start});t.items.splice(-1,1)}}}}*stream(){switch(this.type){case"directive-line":yield{type:"directive",offset:this.offset,source:this.source};return;case"byte-order-mark":case"space":case"comment":case"newline":yield this.sourceToken;return;case"doc-mode":case"doc-start":{let e={type:"document",offset:this.offset,start:[]};if(this.type==="doc-start")e.start.push(this.sourceToken);this.stack.push(e);return}}yield{type:"error",offset:this.offset,message:`Unexpected ${this.type} token in YAML stream`,source:this.source}}*document(e){if(e.value)return yield*this.lineEnd(e);switch(this.type){case"doc-start":{if(Yl(e.start)!==-1)yield*this.pop(),yield*this.step();else e.start.push(this.sourceToken);return}case"anchor":case"tag":case"space":case"comment":case"newline":e.start.push(this.sourceToken);return}let t=this.startBlockValue(e);if(t)this.stack.push(t);else yield{type:"error",offset:this.offset,message:`Unexpected ${this.type} token in YAML document`,source:this.source}}*scalar(e){if(this.type==="map-value-ind"){let t=ss(this.peek(2)),n=it(t),s;if(e.end)s=e.end,s.push(this.sourceToken),delete e.end;else s=[this.sourceToken];let i={type:"block-map",offset:e.offset,indent:e.indent,items:[{start:n,key:e,sep:s}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=i}else yield*this.lineEnd(e)}*blockScalar(e){switch(this.type){case"space":case"comment":case"newline":e.props.push(this.sourceToken);return;case"scalar":if(e.source=this.source,this.atNewLine=!0,this.indent=0,this.onNewLine){let t=this.source.indexOf(`
136
+ `)+1;while(t!==0)this.onNewLine(this.offset+t),t=this.source.indexOf(`
137
+ `,t)+1}yield*this.pop();break;default:yield*this.pop(),yield*this.step()}}*blockMap(e){let t=e.items[e.items.length-1];switch(this.type){case"newline":if(this.onKeyLine=!1,t.value){let n="end"in t.value?t.value.end:void 0;if((Array.isArray(n)?n[n.length-1]:void 0)?.type==="comment")n?.push(this.sourceToken);else e.items.push({start:[this.sourceToken]})}else if(t.sep)t.sep.push(this.sourceToken);else t.start.push(this.sourceToken);return;case"space":case"comment":if(t.value)e.items.push({start:[this.sourceToken]});else if(t.sep)t.sep.push(this.sourceToken);else{if(this.atIndentedComment(t.start,e.indent)){let s=e.items[e.items.length-2]?.value?.end;if(Array.isArray(s)){is(s,t.start),s.push(this.sourceToken),e.items.pop();return}}t.start.push(this.sourceToken)}return}if(this.indent>=e.indent){let n=!this.onKeyLine&&this.indent===e.indent,s=n&&(t.sep||t.explicitKey)&&this.type!=="seq-item-ind",i=[];if(s&&t.sep&&!t.value){let r=[];for(let o=0;o<t.sep.length;++o){let a=t.sep[o];switch(a.type){case"newline":r.push(o);break;case"space":break;case"comment":if(a.indent>e.indent)r.length=0;break;default:r.length=0}}if(r.length>=2)i=t.sep.splice(r[1])}switch(this.type){case"anchor":case"tag":if(s||t.value)i.push(this.sourceToken),e.items.push({start:i}),this.onKeyLine=!0;else if(t.sep)t.sep.push(this.sourceToken);else t.start.push(this.sourceToken);return;case"explicit-key-ind":if(!t.sep&&!t.explicitKey)t.start.push(this.sourceToken),t.explicitKey=!0;else if(s||t.value)i.push(this.sourceToken),e.items.push({start:i,explicitKey:!0});else this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken],explicitKey:!0}]});this.onKeyLine=!0;return;case"map-value-ind":if(t.explicitKey)if(!t.sep)if(Ee(t.start,"newline"))Object.assign(t,{key:null,sep:[this.sourceToken]});else{let r=it(t.start);this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:r,key:null,sep:[this.sourceToken]}]})}else if(t.value)e.items.push({start:[],key:null,sep:[this.sourceToken]});else if(Ee(t.sep,"map-value-ind"))this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:i,key:null,sep:[this.sourceToken]}]});else if(Xl(t.key)&&!Ee(t.sep,"newline")){let r=it(t.start),{key:o,sep:a}=t;a.push(this.sourceToken),delete t.key,delete t.sep,this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:r,key:o,sep:a}]})}else if(i.length>0)t.sep=t.sep.concat(i,this.sourceToken);else t.sep.push(this.sourceToken);else if(!t.sep)Object.assign(t,{key:null,sep:[this.sourceToken]});else if(t.value||s)e.items.push({start:i,key:null,sep:[this.sourceToken]});else if(Ee(t.sep,"map-value-ind"))this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[],key:null,sep:[this.sourceToken]}]});else t.sep.push(this.sourceToken);this.onKeyLine=!0;return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let r=this.flowScalar(this.type);if(s||t.value)e.items.push({start:i,key:r,sep:[]}),this.onKeyLine=!0;else if(t.sep)this.stack.push(r);else Object.assign(t,{key:r,sep:[]}),this.onKeyLine=!0;return}default:{let r=this.startBlockValue(e);if(r){if(r.type==="block-seq"){if(!t.explicitKey&&t.sep&&!Ee(t.sep,"newline")){yield*this.pop({type:"error",offset:this.offset,message:"Unexpected block-seq-ind on same line with key",source:this.source});return}}else if(n)e.items.push({start:i});this.stack.push(r);return}}}}yield*this.pop(),yield*this.step()}*blockSequence(e){let t=e.items[e.items.length-1];switch(this.type){case"newline":if(t.value){let n="end"in t.value?t.value.end:void 0;if((Array.isArray(n)?n[n.length-1]:void 0)?.type==="comment")n?.push(this.sourceToken);else e.items.push({start:[this.sourceToken]})}else t.start.push(this.sourceToken);return;case"space":case"comment":if(t.value)e.items.push({start:[this.sourceToken]});else{if(this.atIndentedComment(t.start,e.indent)){let s=e.items[e.items.length-2]?.value?.end;if(Array.isArray(s)){is(s,t.start),s.push(this.sourceToken),e.items.pop();return}}t.start.push(this.sourceToken)}return;case"anchor":case"tag":if(t.value||this.indent<=e.indent)break;t.start.push(this.sourceToken);return;case"seq-item-ind":if(this.indent!==e.indent)break;if(t.value||Ee(t.start,"seq-item-ind"))e.items.push({start:[this.sourceToken]});else t.start.push(this.sourceToken);return}if(this.indent>e.indent){let n=this.startBlockValue(e);if(n){this.stack.push(n);return}}yield*this.pop(),yield*this.step()}*flowCollection(e){let t=e.items[e.items.length-1];if(this.type==="flow-error-end"){let n;do yield*this.pop(),n=this.peek(1);while(n?.type==="flow-collection")}else if(e.end.length===0){switch(this.type){case"comma":case"explicit-key-ind":if(!t||t.sep)e.items.push({start:[this.sourceToken]});else t.start.push(this.sourceToken);return;case"map-value-ind":if(!t||t.value)e.items.push({start:[],key:null,sep:[this.sourceToken]});else if(t.sep)t.sep.push(this.sourceToken);else Object.assign(t,{key:null,sep:[this.sourceToken]});return;case"space":case"comment":case"newline":case"anchor":case"tag":if(!t||t.value)e.items.push({start:[this.sourceToken]});else if(t.sep)t.sep.push(this.sourceToken);else t.start.push(this.sourceToken);return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let s=this.flowScalar(this.type);if(!t||t.value)e.items.push({start:[],key:s,sep:[]});else if(t.sep)this.stack.push(s);else Object.assign(t,{key:s,sep:[]});return}case"flow-map-end":case"flow-seq-end":e.end.push(this.sourceToken);return}let n=this.startBlockValue(e);if(n)this.stack.push(n);else yield*this.pop(),yield*this.step()}else{let n=this.peek(2);if(n.type==="block-map"&&(this.type==="map-value-ind"&&n.indent===e.indent||this.type==="newline"&&!n.items[n.items.length-1].sep))yield*this.pop(),yield*this.step();else if(this.type==="map-value-ind"&&n.type!=="flow-collection"){let s=ss(n),i=it(s);zl(e);let r=e.end.splice(1,e.end.length);r.push(this.sourceToken);let o={type:"block-map",offset:e.offset,indent:e.indent,items:[{start:i,key:e,sep:r}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=o}else yield*this.lineEnd(e)}}flowScalar(e){if(this.onNewLine){let t=this.source.indexOf(`
138
+ `)+1;while(t!==0)this.onNewLine(this.offset+t),t=this.source.indexOf(`
139
+ `,t)+1}return{type:e,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(e){switch(this.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return this.flowScalar(this.type);case"block-scalar-header":return{type:"block-scalar",offset:this.offset,indent:this.indent,props:[this.sourceToken],source:""};case"flow-map-start":case"flow-seq-start":return{type:"flow-collection",offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case"seq-item-ind":return{type:"block-seq",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case"explicit-key-ind":{this.onKeyLine=!0;let t=ss(e),n=it(t);return n.push(this.sourceToken),{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:n,explicitKey:!0}]}}case"map-value-ind":{this.onKeyLine=!0;let t=ss(e),n=it(t);return{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:n,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(e,t){if(this.type!=="comment")return!1;if(this.indent<=t)return!1;return e.every((n)=>n.type==="newline"||n.type==="space")}*documentEnd(e){if(this.type!=="doc-mode"){if(e.end)e.end.push(this.sourceToken);else e.end=[this.sourceToken];if(this.type==="newline")yield*this.pop()}}*lineEnd(e){switch(this.type){case"comma":case"doc-start":case"doc-end":case"flow-seq-end":case"flow-map-end":case"map-value-ind":yield*this.pop(),yield*this.step();break;case"newline":this.onKeyLine=!1;case"space":case"comment":default:if(e.end)e.end.push(this.sourceToken);else e.end=[this.sourceToken];if(this.type==="newline")yield*this.pop()}}}RS.Parser=Ql});var sc=k(function(MS){var Zl=zi(),NS=qt(),Bt=Dt(),LS=oi(),IS=R(),PS=or(),ec=ar();function tc(e){let t=e.prettyErrors!==!1;return{lineCounter:e.lineCounter||t&&new PS.LineCounter||null,prettyErrors:t}}function qS(e,t={}){let{lineCounter:n,prettyErrors:s}=tc(t),i=new ec.Parser(n?.addNewLine),r=new Zl.Composer(t),o=Array.from(r.compose(i.parse(e)));if(s&&n)for(let a of o)a.errors.forEach(Bt.prettifyError(e,n)),a.warnings.forEach(Bt.prettifyError(e,n));if(o.length>0)return o;return Object.assign([],{empty:!0},r.streamInfo())}function nc(e,t={}){let{lineCounter:n,prettyErrors:s}=tc(t),i=new ec.Parser(n?.addNewLine),r=new Zl.Composer(t),o=null;for(let a of r.compose(i.parse(e),!0,e.length))if(!o)o=a;else if(o.options.logLevel!=="silent"){o.errors.push(new Bt.YAMLParseError(a.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}if(s&&n)o.errors.forEach(Bt.prettifyError(e,n)),o.warnings.forEach(Bt.prettifyError(e,n));return o}function DS(e,t,n){let s=void 0;if(typeof t==="function")s=t;else if(n===void 0&&t&&typeof t==="object")n=t;let i=nc(e,n);if(!i)return null;if(i.warnings.forEach((r)=>LS.warn(i.options.logLevel,r)),i.errors.length>0)if(i.options.logLevel!=="silent")throw i.errors[0];else i.errors=[];return i.toJS(Object.assign({reviver:s},n))}function jS(e,t,n){let s=null;if(typeof t==="function"||Array.isArray(t))s=t;else if(n===void 0&&t)n=t;if(typeof n==="string")n=n.length;if(typeof n==="number"){let i=Math.round(n);n=i<1?void 0:i>8?{indent:8}:{indent:i}}if(e===void 0){let{keepUndefined:i}=n??t??{};if(!i)return}if(IS.isDocument(e)&&!s)return e.toString(n);return new NS.Document(e,s,n).toString(n)}MS.parse=DS;MS.parseAllDocuments=qS;MS.parseDocument=nc;MS.stringify=jS});var wr=k(function(YC,yr){var ds=process||{},Dc=ds.argv||[],fs=ds.env||{},TE=!(!!fs.NO_COLOR||Dc.includes("--no-color"))&&(!!fs.FORCE_COLOR||Dc.includes("--color")||ds.platform==="win32"||(ds.stdout||{}).isTTY&&fs.TERM!=="dumb"||!!fs.CI),RE=(e,t,n=e)=>(s)=>{let i=""+s,r=i.indexOf(t,e.length);return~r?e+$E(i,t,n,r)+t:e+i+t},$E=(e,t,n,s)=>{let i="",r=0;do i+=e.substring(r,s)+n,r=s+t.length,s=e.indexOf(t,r);while(~s);return i+e.substring(r)},jc=(e=TE)=>{let t=e?RE:()=>String;return{isColorSupported:e,reset:t("\x1B[0m","\x1B[0m"),bold:t("\x1B[1m","\x1B[22m","\x1B[22m\x1B[1m"),dim:t("\x1B[2m","\x1B[22m","\x1B[22m\x1B[2m"),italic:t("\x1B[3m","\x1B[23m"),underline:t("\x1B[4m","\x1B[24m"),inverse:t("\x1B[7m","\x1B[27m"),hidden:t("\x1B[8m","\x1B[28m"),strikethrough:t("\x1B[9m","\x1B[29m"),black:t("\x1B[30m","\x1B[39m"),red:t("\x1B[31m","\x1B[39m"),green:t("\x1B[32m","\x1B[39m"),yellow:t("\x1B[33m","\x1B[39m"),blue:t("\x1B[34m","\x1B[39m"),magenta:t("\x1B[35m","\x1B[39m"),cyan:t("\x1B[36m","\x1B[39m"),white:t("\x1B[37m","\x1B[39m"),gray:t("\x1B[90m","\x1B[39m"),bgBlack:t("\x1B[40m","\x1B[49m"),bgRed:t("\x1B[41m","\x1B[49m"),bgGreen:t("\x1B[42m","\x1B[49m"),bgYellow:t("\x1B[43m","\x1B[49m"),bgBlue:t("\x1B[44m","\x1B[49m"),bgMagenta:t("\x1B[45m","\x1B[49m"),bgCyan:t("\x1B[46m","\x1B[49m"),bgWhite:t("\x1B[47m","\x1B[49m"),blackBright:t("\x1B[90m","\x1B[39m"),redBright:t("\x1B[91m","\x1B[39m"),greenBright:t("\x1B[92m","\x1B[39m"),yellowBright:t("\x1B[93m","\x1B[39m"),blueBright:t("\x1B[94m","\x1B[39m"),magentaBright:t("\x1B[95m","\x1B[39m"),cyanBright:t("\x1B[96m","\x1B[39m"),whiteBright:t("\x1B[97m","\x1B[39m"),bgBlackBright:t("\x1B[100m","\x1B[49m"),bgRedBright:t("\x1B[101m","\x1B[49m"),bgGreenBright:t("\x1B[102m","\x1B[49m"),bgYellowBright:t("\x1B[103m","\x1B[49m"),bgBlueBright:t("\x1B[104m","\x1B[49m"),bgMagentaBright:t("\x1B[105m","\x1B[49m"),bgCyanBright:t("\x1B[106m","\x1B[49m"),bgWhiteBright:t("\x1B[107m","\x1B[49m")}};yr.exports=jc();yr.exports.createColors=jc});import{existsSync as Tk,rmSync as Rk,statSync as $k}from"node:fs";class oe extends Error{constructor(e,t,n){super(n);Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=t,this.exitCode=e,this.nestedError=void 0}}class Ue extends oe{constructor(e){super(1,"commander.invalidArgument",e);Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}}class rn{constructor(e,t){switch(this.description=t||"",this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,e[0]){case"<":this.required=!0,this._name=e.slice(1,-1);break;case"[":this.required=!1,this._name=e.slice(1,-1);break;default:this.required=!0,this._name=e;break}if(this._name.endsWith("..."))this.variadic=!0,this._name=this._name.slice(0,-3)}name(){return this._name}_collectValue(e,t){if(t===this.defaultValue||!Array.isArray(t))return[e];return t.push(e),t}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}argParser(e){return this.parseArg=e,this}choices(e){return this.argChoices=e.slice(),this.parseArg=(t,n)=>{if(!this.argChoices.includes(t))throw new Ue(`Allowed choices are ${this.argChoices.join(", ")}.`);if(this.variadic)return this._collectValue(t,n);return t},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}}function on(e){let t=e.name()+(e.variadic===!0?"...":"");return e.required?"<"+t+">":"["+t+"]"}import{EventEmitter as pf}from"node:events";import Ts from"node:child_process";import ae from"node:path";import ln from"node:fs";import N from"node:process";import{stripVTControlCharacters as hf}from"node:util";import{stripVTControlCharacters as uf}from"node:util";class an{constructor(){this.helpWidth=void 0,this.minWidthToWrap=40,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}prepareContext(e){this.helpWidth=this.helpWidth??e.helpWidth??80}visibleCommands(e){let t=e.commands.filter((s)=>!s._hidden),n=e._getHelpCommand();if(n&&!n._hidden)t.push(n);if(this.sortSubcommands)t.sort((s,i)=>s.name().localeCompare(i.name()));return t}compareOptions(e,t){let n=(s)=>s.short?s.short.replace(/^-/,""):s.long.replace(/^--/,"");return n(e).localeCompare(n(t))}visibleOptions(e){let t=e.options.filter((s)=>!s.hidden),n=e._getHelpOption();if(n&&!n.hidden){let s=n.short&&e._findOption(n.short),i=n.long&&e._findOption(n.long);if(!s&&!i)t.push(n);else if(n.long&&!i)t.push(e.createOption(n.long,n.description).helpGroup(n.helpGroupHeading));else if(n.short&&!s)t.push(e.createOption(n.short,n.description).helpGroup(n.helpGroupHeading))}if(this.sortOptions)t.sort(this.compareOptions);return t}visibleGlobalOptions(e){if(!this.showGlobalOptions)return[];let t=[];for(let n=e.parent;n;n=n.parent){let s=n.options.filter((i)=>!i.hidden);t.push(...s)}if(this.sortOptions)t.sort(this.compareOptions);return t}visibleArguments(e){if(e._argsDescription)e.registeredArguments.forEach((t)=>{t.description=t.description||e._argsDescription[t.name()]||""});if(e.registeredArguments.find((t)=>t.description))return e.registeredArguments;return[]}subcommandTerm(e){let t=e.registeredArguments.map((n)=>on(n)).join(" ");return e._name+(e._aliases[0]?"|"+e._aliases[0]:"")+(e.options.length?" [options]":"")+(t?" "+t:"")}optionTerm(e){return e.flags}argumentTerm(e){return e.name()}longestSubcommandTermLength(e,t){return t.visibleCommands(e).reduce((n,s)=>Math.max(n,this.displayWidth(t.styleSubcommandTerm(t.subcommandTerm(s)))),0)}longestOptionTermLength(e,t){return t.visibleOptions(e).reduce((n,s)=>Math.max(n,this.displayWidth(t.styleOptionTerm(t.optionTerm(s)))),0)}longestGlobalOptionTermLength(e,t){return t.visibleGlobalOptions(e).reduce((n,s)=>Math.max(n,this.displayWidth(t.styleOptionTerm(t.optionTerm(s)))),0)}longestArgumentTermLength(e,t){return t.visibleArguments(e).reduce((n,s)=>Math.max(n,this.displayWidth(t.styleArgumentTerm(t.argumentTerm(s)))),0)}commandUsage(e){let t=e._name;if(e._aliases[0])t=t+"|"+e._aliases[0];let n="";for(let s=e.parent;s;s=s.parent)n=s.name()+" "+n;return n+t+" "+e.usage()}commandDescription(e){return e.description()}subcommandDescription(e){return e.summary()||e.description()}optionDescription(e){let t=[];if(e.argChoices)t.push(`choices: ${e.argChoices.map((n)=>JSON.stringify(n)).join(", ")}`);if(e.defaultValue!==void 0){if(e.required||e.optional||e.isBoolean()&&typeof e.defaultValue==="boolean")t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`)}if(e.presetArg!==void 0&&e.optional)t.push(`preset: ${JSON.stringify(e.presetArg)}`);if(e.envVar!==void 0)t.push(`env: ${e.envVar}`);if(t.length>0){let n=`(${t.join(", ")})`;if(e.description)return`${e.description} ${n}`;return n}return e.description}argumentDescription(e){let t=[];if(e.argChoices)t.push(`choices: ${e.argChoices.map((n)=>JSON.stringify(n)).join(", ")}`);if(e.defaultValue!==void 0)t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`);if(t.length>0){let n=`(${t.join(", ")})`;if(e.description)return`${e.description} ${n}`;return n}return e.description}formatItemList(e,t,n){if(t.length===0)return[];return[n.styleTitle(e),...t,""]}groupItems(e,t,n){let s=new Map;return e.forEach((i)=>{let r=n(i);if(!s.has(r))s.set(r,[])}),t.forEach((i)=>{let r=n(i);if(!s.has(r))s.set(r,[]);s.get(r).push(i)}),s}formatHelp(e,t){let n=t.padWidth(e,t),s=t.helpWidth??80;function i(u,f){return t.formatItem(u,n,f,t)}let r=[`${t.styleTitle("Usage:")} ${t.styleUsage(t.commandUsage(e))}`,""],o=t.commandDescription(e);if(o.length>0)r=r.concat([t.boxWrap(t.styleCommandDescription(o),s),""]);let a=t.visibleArguments(e).map((u)=>i(t.styleArgumentTerm(t.argumentTerm(u)),t.styleArgumentDescription(t.argumentDescription(u))));if(r=r.concat(this.formatItemList("Arguments:",a,t)),this.groupItems(e.options,t.visibleOptions(e),(u)=>u.helpGroupHeading??"Options:").forEach((u,f)=>{let d=u.map((h)=>i(t.styleOptionTerm(t.optionTerm(h)),t.styleOptionDescription(t.optionDescription(h))));r=r.concat(this.formatItemList(f,d,t))}),t.showGlobalOptions){let u=t.visibleGlobalOptions(e).map((f)=>i(t.styleOptionTerm(t.optionTerm(f)),t.styleOptionDescription(t.optionDescription(f))));r=r.concat(this.formatItemList("Global Options:",u,t))}return this.groupItems(e.commands,t.visibleCommands(e),(u)=>u.helpGroup()||"Commands:").forEach((u,f)=>{let d=u.map((h)=>i(t.styleSubcommandTerm(t.subcommandTerm(h)),t.styleSubcommandDescription(t.subcommandDescription(h))));r=r.concat(this.formatItemList(f,d,t))}),r.join(`
140
+ `)}displayWidth(e){return uf(e).length}styleTitle(e){return e}styleUsage(e){return e.split(" ").map((t)=>{if(t==="[options]")return this.styleOptionText(t);if(t==="[command]")return this.styleSubcommandText(t);if(t[0]==="["||t[0]==="<")return this.styleArgumentText(t);return this.styleCommandText(t)}).join(" ")}styleCommandDescription(e){return this.styleDescriptionText(e)}styleOptionDescription(e){return this.styleDescriptionText(e)}styleSubcommandDescription(e){return this.styleDescriptionText(e)}styleArgumentDescription(e){return this.styleDescriptionText(e)}styleDescriptionText(e){return e}styleOptionTerm(e){return this.styleOptionText(e)}styleSubcommandTerm(e){return e.split(" ").map((t)=>{if(t==="[options]")return this.styleOptionText(t);if(t[0]==="["||t[0]==="<")return this.styleArgumentText(t);return this.styleSubcommandText(t)}).join(" ")}styleArgumentTerm(e){return this.styleArgumentText(e)}styleOptionText(e){return e}styleArgumentText(e){return e}styleSubcommandText(e){return e}styleCommandText(e){return e}padWidth(e,t){return Math.max(t.longestOptionTermLength(e,t),t.longestGlobalOptionTermLength(e,t),t.longestSubcommandTermLength(e,t),t.longestArgumentTermLength(e,t))}preformatted(e){return/\n[^\S\r\n]/.test(e)}formatItem(e,t,n,s){let r=" ".repeat(2);if(!n)return r+e;let o=e.padEnd(t+e.length-s.displayWidth(e)),a=2,c=(this.helpWidth??80)-t-a-2,u;if(c<this.minWidthToWrap||s.preformatted(n))u=n;else u=s.boxWrap(n,c).replace(/\n/g,`
141
+ `+" ".repeat(t+a));return r+o+" ".repeat(a)+u.replace(/\n/g,`
142
+ ${r}`)}boxWrap(e,t){if(t<this.minWidthToWrap)return e;let n=e.split(/\r\n|\n/),s=/[\s]*[^\s]+/g,i=[];return n.forEach((r)=>{let o=r.match(s);if(o===null){i.push("");return}let a=[o.shift()],l=this.displayWidth(a[0]);o.forEach((c)=>{let u=this.displayWidth(c);if(l+u<=t){a.push(c),l+=u;return}i.push(a.join(""));let f=c.trimStart();a=[f],l=this.displayWidth(f)}),i.push(a.join(""))}),i.join(`
143
+ `)}}class dt{constructor(e,t){this.flags=e,this.description=t||"",this.required=e.includes("<"),this.optional=e.includes("["),this.variadic=/\p{ID_Continue}\.\.\.[>\]]$/u.test(e),this.mandatory=!1;let n=ff(e);if(this.short=n.shortFlag,this.long=n.longFlag,this.negate=!1,this.long)this.negate=this.long.startsWith("--no-");this.defaultValue=void 0,this.defaultValueDescription=void 0,this.presetArg=void 0,this.envVar=void 0,this.parseArg=void 0,this.hidden=!1,this.argChoices=void 0,this.conflictsWith=[],this.implied=void 0,this.helpGroupHeading=void 0}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}preset(e){return this.presetArg=e,this}conflicts(e){return this.conflictsWith=this.conflictsWith.concat(e),this}implies(e){let t=e;if(typeof e==="string")t={[e]:!0};return this.implied=Object.assign(this.implied||{},t),this}env(e){return this.envVar=e,this}argParser(e){return this.parseArg=e,this}makeOptionMandatory(e=!0){return this.mandatory=!!e,this}hideHelp(e=!0){return this.hidden=!!e,this}_collectValue(e,t){if(t===this.defaultValue||!Array.isArray(t))return[e];return t.push(e),t}choices(e){return this.argChoices=e.slice(),this.parseArg=(t,n)=>{if(!this.argChoices.includes(t))throw new Ue(`Allowed choices are ${this.argChoices.join(", ")}.`);if(this.variadic)return this._collectValue(t,n);return t},this}name(){if(this.long)return this.long.replace(/^--/,"");return this.short.replace(/^-/,"")}attributeName(){if(this.negate)return Pr(this.name().replace(/^no-/,""));return Pr(this.name())}helpGroup(e){return this.helpGroupHeading=e,this}is(e){return this.short===e||this.long===e}isBoolean(){return!this.required&&!this.optional&&!this.negate}}class As{constructor(e){this.positiveOptions=new Map,this.negativeOptions=new Map,this.dualOptions=new Set,e.forEach((t)=>{if(t.negate)this.negativeOptions.set(t.attributeName(),t);else this.positiveOptions.set(t.attributeName(),t)}),this.negativeOptions.forEach((t,n)=>{if(this.positiveOptions.has(n))this.dualOptions.add(n)})}valueFromOption(e,t){let n=t.attributeName();if(!this.dualOptions.has(n))return!0;let s=this.negativeOptions.get(n).presetArg,i=s!==void 0?s:!1;return t.negate===(i===e)}}function Pr(e){return e.split("-").reduce((t,n)=>t+n[0].toUpperCase()+n.slice(1))}function ff(e){let t,n,s=/^-[^-]$/,i=/^--[^-]/,r=e.split(/[ |,]+/).concat("guard");if(s.test(r[0]))t=r.shift();if(i.test(r[0]))n=r.shift();if(!t&&s.test(r[0]))t=r.shift();if(!t&&i.test(r[0]))t=n,n=r.shift();if(r[0].startsWith("-")){let o=r[0],a=`option creation failed due to '${o}' in option flags '${e}'`;if(/^-[^-][^-]/.test(o))throw Error(`${a}
144
+ - a short flag is a single dash and a single character
145
+ - either use a single dash and a single character (for a short flag)
146
+ - or use a double dash for a long option (and can have two, like '--ws, --workspace')`);if(s.test(o))throw Error(`${a}
147
+ - too many short flags`);if(i.test(o))throw Error(`${a}
148
+ - too many long flags`);throw Error(`${a}
149
+ - unrecognised flag format`)}if(t===void 0&&n===void 0)throw Error(`option creation failed due to no flags found in '${e}'.`);return{shortFlag:t,longFlag:n}}function df(e,t){if(Math.abs(e.length-t.length)>3)return Math.max(e.length,t.length);let n=[];for(let s=0;s<=e.length;s++)n[s]=[s];for(let s=0;s<=t.length;s++)n[0][s]=s;for(let s=1;s<=t.length;s++)for(let i=1;i<=e.length;i++){let r;if(e[i-1]===t[s-1])r=0;else r=1;if(n[i][s]=Math.min(n[i-1][s]+1,n[i][s-1]+1,n[i-1][s-1]+r),i>1&&s>1&&e[i-1]===t[s-2]&&e[i-2]===t[s-1])n[i][s]=Math.min(n[i][s],n[i-2][s-2]+1)}return n[e.length][t.length]}function Cs(e,t){if(!t||t.length===0)return"";t=Array.from(new Set(t));let n=e.startsWith("--");if(n)e=e.slice(2),t=t.map((o)=>o.slice(2));let s=[],i=3,r=0.4;if(t.forEach((o)=>{if(o.length<=1)return;let a=df(e,o),l=Math.max(e.length,o.length);if((l-a)/l>r){if(a<i)i=a,s=[o];else if(a===i)s.push(o)}}),s.sort((o,a)=>o.localeCompare(a)),n)s=s.map((o)=>`--${o}`);if(s.length>1)return`
150
+ (Did you mean one of ${s.join(", ")}?)`;if(s.length===1)return`
151
+ (Did you mean ${s[0]}?)`;return""}class Be extends pf{constructor(e){super();this.commands=[],this.options=[],this.parent=null,this._allowUnknownOption=!1,this._allowExcessArguments=!1,this.registeredArguments=[],this._args=this.registeredArguments,this.args=[],this.rawArgs=[],this.processedArgs=[],this._scriptPath=null,this._name=e||"",this._optionValues={},this._optionValueSources={},this._storeOptionsAsProperties=!1,this._actionHandler=null,this._executableHandler=!1,this._executableFile=null,this._executableDir=null,this._defaultCommandName=null,this._exitCallback=null,this._aliases=[],this._combineFlagAndOptionalValue=!0,this._description="",this._summary="",this._argsDescription=void 0,this._enablePositionalOptions=!1,this._passThroughOptions=!1,this._lifeCycleHooks={},this._showHelpAfterError=!1,this._showSuggestionAfterError=!0,this._savedState=null,this._outputConfiguration={writeOut:(t)=>N.stdout.write(t),writeErr:(t)=>N.stderr.write(t),outputError:(t,n)=>n(t),getOutHelpWidth:()=>N.stdout.isTTY?N.stdout.columns:void 0,getErrHelpWidth:()=>N.stderr.isTTY?N.stderr.columns:void 0,getOutHasColors:()=>Dr()??(N.stdout.isTTY&&N.stdout.hasColors?.()),getErrHasColors:()=>Dr()??(N.stderr.isTTY&&N.stderr.hasColors?.()),stripColor:(t)=>hf(t)},this._hidden=!1,this._helpOption=void 0,this._addImplicitHelpCommand=void 0,this._helpCommand=void 0,this._helpConfiguration={},this._helpGroupHeading=void 0,this._defaultCommandGroup=void 0,this._defaultOptionGroup=void 0}copyInheritedSettings(e){return this._outputConfiguration=e._outputConfiguration,this._helpOption=e._helpOption,this._helpCommand=e._helpCommand,this._helpConfiguration=e._helpConfiguration,this._exitCallback=e._exitCallback,this._storeOptionsAsProperties=e._storeOptionsAsProperties,this._combineFlagAndOptionalValue=e._combineFlagAndOptionalValue,this._allowExcessArguments=e._allowExcessArguments,this._enablePositionalOptions=e._enablePositionalOptions,this._showHelpAfterError=e._showHelpAfterError,this._showSuggestionAfterError=e._showSuggestionAfterError,this}_getCommandAndAncestors(){let e=[];for(let t=this;t;t=t.parent)e.push(t);return e}command(e,t,n){let s=t,i=n;if(typeof s==="object"&&s!==null)i=s,s=null;i=i||{};let[,r,o]=e.match(/([^ ]+) *(.*)/),a=this.createCommand(r);if(s)a.description(s),a._executableHandler=!0;if(i.isDefault)this._defaultCommandName=a._name;if(a._hidden=!!(i.noHelp||i.hidden),a._executableFile=i.executableFile||null,o)a.arguments(o);if(this._registerCommand(a),a.parent=this,a.copyInheritedSettings(this),s)return this;return a}createCommand(e){return new Be(e)}createHelp(){return Object.assign(new an,this.configureHelp())}configureHelp(e){if(e===void 0)return this._helpConfiguration;return this._helpConfiguration=e,this}configureOutput(e){if(e===void 0)return this._outputConfiguration;return this._outputConfiguration={...this._outputConfiguration,...e},this}showHelpAfterError(e=!0){if(typeof e!=="string")e=!!e;return this._showHelpAfterError=e,this}showSuggestionAfterError(e=!0){return this._showSuggestionAfterError=!!e,this}addCommand(e,t){if(!e._name)throw Error(`Command passed to .addCommand() must have a name
152
+ - specify the name in Command constructor or using .name()`);if(t=t||{},t.isDefault)this._defaultCommandName=e._name;if(t.noHelp||t.hidden)e._hidden=!0;return this._registerCommand(e),e.parent=this,e._checkForBrokenPassThrough(),this}createArgument(e,t){return new rn(e,t)}argument(e,t,n,s){let i=this.createArgument(e,t);if(typeof n==="function")i.default(s).argParser(n);else i.default(n);return this.addArgument(i),this}arguments(e){return e.trim().split(/ +/).forEach((t)=>{this.argument(t)}),this}addArgument(e){let t=this.registeredArguments.slice(-1)[0];if(t?.variadic)throw Error(`only the last argument can be variadic '${t.name()}'`);if(e.required&&e.defaultValue!==void 0&&e.parseArg===void 0)throw Error(`a default value for a required argument is never used: '${e.name()}'`);return this.registeredArguments.push(e),this}helpCommand(e,t){if(typeof e==="boolean"){if(this._addImplicitHelpCommand=e,e&&this._defaultCommandGroup)this._initCommandGroup(this._getHelpCommand());return this}let n=e??"help [command]",[,s,i]=n.match(/([^ ]+) *(.*)/),r=t??"display help for command",o=this.createCommand(s);if(o.helpOption(!1),i)o.arguments(i);if(r)o.description(r);if(this._addImplicitHelpCommand=!0,this._helpCommand=o,e||t)this._initCommandGroup(o);return this}addHelpCommand(e,t){if(typeof e!=="object")return this.helpCommand(e,t),this;return this._addImplicitHelpCommand=!0,this._helpCommand=e,this._initCommandGroup(e),this}_getHelpCommand(){if(this._addImplicitHelpCommand??(this.commands.length&&!this._actionHandler&&!this._findCommand("help"))){if(this._helpCommand===void 0)this.helpCommand(void 0,void 0);return this._helpCommand}return null}hook(e,t){let n=["preSubcommand","preAction","postAction"];if(!n.includes(e))throw Error(`Unexpected value for event passed to hook : '${e}'.
153
+ Expecting one of '${n.join("', '")}'`);if(this._lifeCycleHooks[e])this._lifeCycleHooks[e].push(t);else this._lifeCycleHooks[e]=[t];return this}exitOverride(e){if(e)this._exitCallback=e;else this._exitCallback=(t)=>{if(t.code!=="commander.executeSubCommandAsync")throw t};return this}_exit(e,t,n){if(this._exitCallback)this._exitCallback(new oe(e,t,n));N.exit(e)}action(e){let t=(n)=>{let s=this.registeredArguments.length,i=n.slice(0,s);if(this._storeOptionsAsProperties)i[s]=this;else i[s]=this.opts();return i.push(this),e.apply(this,i)};return this._actionHandler=t,this}createOption(e,t){return new dt(e,t)}_callParseArg(e,t,n,s){try{return e.parseArg(t,n)}catch(i){if(i.code==="commander.invalidArgument"){let r=`${s} ${i.message}`;this.error(r,{exitCode:i.exitCode,code:i.code})}throw i}}_registerOption(e){let t=e.short&&this._findOption(e.short)||e.long&&this._findOption(e.long);if(t){let n=e.long&&this._findOption(e.long)?e.long:e.short;throw Error(`Cannot add option '${e.flags}'${this._name&&` to command '${this._name}'`} due to conflicting flag '${n}'
154
+ - already used by option '${t.flags}'`)}this._initOptionGroup(e),this.options.push(e)}_registerCommand(e){let t=(s)=>[s.name()].concat(s.aliases()),n=t(e).find((s)=>this._findCommand(s));if(n){let s=t(this._findCommand(n)).join("|"),i=t(e).join("|");throw Error(`cannot add command '${i}' as already have command '${s}'`)}this._initCommandGroup(e),this.commands.push(e)}addOption(e){this._registerOption(e);let t=e.name(),n=e.attributeName();if(e.defaultValue!==void 0)this.setOptionValueWithSource(n,e.defaultValue,"default");let s=(i,r,o)=>{if(i==null&&e.presetArg!==void 0)i=e.presetArg;let a=this.getOptionValue(n);if(i!==null&&e.parseArg)i=this._callParseArg(e,i,a,r);else if(i!==null&&e.variadic)i=e._collectValue(i,a);if(i==null)if(e.negate)i=!1;else if(e.isBoolean()||e.optional)i=!0;else i="";this.setOptionValueWithSource(n,i,o)};if(this.on("option:"+t,(i)=>{let r=`error: option '${e.flags}' argument '${i}' is invalid.`;s(i,r,"cli")}),e.envVar)this.on("optionEnv:"+t,(i)=>{let r=`error: option '${e.flags}' value '${i}' from env '${e.envVar}' is invalid.`;s(i,r,"env")});return this}_optionEx(e,t,n,s,i){if(typeof t==="object"&&t instanceof dt)throw Error("To add an Option object use addOption() instead of option() or requiredOption()");let r=this.createOption(t,n);if(r.makeOptionMandatory(!!e.mandatory),typeof s==="function")r.default(i).argParser(s);else if(s instanceof RegExp){let o=s;s=(a,l)=>{let c=o.exec(a);return c?c[0]:l},r.default(i).argParser(s)}else r.default(s);return this.addOption(r)}option(e,t,n,s){return this._optionEx({},e,t,n,s)}requiredOption(e,t,n,s){return this._optionEx({mandatory:!0},e,t,n,s)}combineFlagAndOptionalValue(e=!0){return this._combineFlagAndOptionalValue=!!e,this}allowUnknownOption(e=!0){return this._allowUnknownOption=!!e,this}allowExcessArguments(e=!0){return this._allowExcessArguments=!!e,this}enablePositionalOptions(e=!0){return this._enablePositionalOptions=!!e,this}passThroughOptions(e=!0){return this._passThroughOptions=!!e,this._checkForBrokenPassThrough(),this}_checkForBrokenPassThrough(){if(this.parent&&this._passThroughOptions&&!this.parent._enablePositionalOptions)throw Error(`passThroughOptions cannot be used for '${this._name}' without turning on enablePositionalOptions for parent command(s)`)}storeOptionsAsProperties(e=!0){if(this.options.length)throw Error("call .storeOptionsAsProperties() before adding options");if(Object.keys(this._optionValues).length)throw Error("call .storeOptionsAsProperties() before setting option values");return this._storeOptionsAsProperties=!!e,this}getOptionValue(e){if(this._storeOptionsAsProperties)return this[e];return this._optionValues[e]}setOptionValue(e,t){return this.setOptionValueWithSource(e,t,void 0)}setOptionValueWithSource(e,t,n){if(this._storeOptionsAsProperties)this[e]=t;else this._optionValues[e]=t;return this._optionValueSources[e]=n,this}getOptionValueSource(e){return this._optionValueSources[e]}getOptionValueSourceWithGlobals(e){let t;return this._getCommandAndAncestors().forEach((n)=>{if(Object.hasOwn(n._optionValueSources,e))t=n.getOptionValueSource(e)}),t}_prepareUserArgs(e,t){if(e!==void 0&&!Array.isArray(e))throw Error("first parameter to parse must be array or undefined");if(t=t||{},e===void 0&&t.from===void 0){if(N.versions?.electron)t.from="electron";let s=N.execArgv??[];if(s.includes("-e")||s.includes("--eval")||s.includes("-p")||s.includes("--print"))t.from="eval"}if(e===void 0)e=N.argv;this.rawArgs=e.slice();let n;switch(t.from){case void 0:case"node":this._scriptPath=e[1],n=e.slice(2);break;case"electron":if(N.defaultApp)this._scriptPath=e[1],n=e.slice(2);else n=e.slice(1);break;case"user":n=e.slice(0);break;case"eval":n=e.slice(1);break;default:throw Error(`unexpected parse option { from: '${t.from}' }`)}if(!this._name&&this._scriptPath)this.nameFromFilename(this._scriptPath);return this._name=this._name||"program",n}parse(e,t){this._prepareForParse();let n=this._prepareUserArgs(e,t);return this._parseCommand([],n),this}async parseAsync(e,t){this._prepareForParse();let n=this._prepareUserArgs(e,t);return await this._parseCommand([],n),this}_prepareForParse(){if(this._savedState===null)this.options.filter((e)=>e.negate&&e.defaultValue===void 0&&this.getOptionValue(e.attributeName())===void 0).forEach((e)=>{let t=e.long.replace(/^--no-/,"--");if(!this._findOption(t))this.setOptionValueWithSource(e.attributeName(),!0,"default")}),this.saveStateBeforeParse();else this.restoreStateBeforeParse()}saveStateBeforeParse(){this._savedState={_name:this._name,_optionValues:{...this._optionValues},_optionValueSources:{...this._optionValueSources}}}restoreStateBeforeParse(){if(this._storeOptionsAsProperties)throw Error(`Can not call parse again when storeOptionsAsProperties is true.
155
+ - either make a new Command for each call to parse, or stop storing options as properties`);this._name=this._savedState._name,this._scriptPath=null,this.rawArgs=[],this._optionValues={...this._savedState._optionValues},this._optionValueSources={...this._savedState._optionValueSources},this.args=[],this.processedArgs=[]}_checkForMissingExecutable(e,t,n){if(ln.existsSync(e))return;let s=t?`searched for local subcommand relative to directory '${t}'`:"no directory for search for local subcommand, use .executableDir() to supply a custom directory",i=`'${e}' does not exist
156
+ - if '${n}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead
157
+ - if the default executable name is not suitable, use the executableFile option to supply a custom name or path
158
+ - ${s}`;throw Error(i)}_executeSubCommand(e,t){t=t.slice();let n=[".js",".ts",".tsx",".mjs",".cjs"];function s(c,u){let f=ae.resolve(c,u);if(ln.existsSync(f))return f;if(n.includes(ae.extname(u)))return;let d=n.find((h)=>ln.existsSync(`${f}${h}`));if(d)return`${f}${d}`;return}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let i=e._executableFile||`${this._name}-${e._name}`,r=this._executableDir||"";if(this._scriptPath){let c;try{c=ln.realpathSync(this._scriptPath)}catch{c=this._scriptPath}r=ae.resolve(ae.dirname(c),r)}if(r){let c=s(r,i);if(!c&&!e._executableFile&&this._scriptPath){let u=ae.basename(this._scriptPath,ae.extname(this._scriptPath));if(u!==this._name)c=s(r,`${u}-${e._name}`)}i=c||i}let o=n.includes(ae.extname(i)),a;if(N.platform!=="win32")if(o)t.unshift(i),t=qr(N.execArgv).concat(t),a=Ts.spawn(N.argv[0],t,{stdio:"inherit"});else a=Ts.spawn(i,t,{stdio:"inherit"});else this._checkForMissingExecutable(i,r,e._name),t.unshift(i),t=qr(N.execArgv).concat(t),a=Ts.spawn(N.execPath,t,{stdio:"inherit"});if(!a.killed)["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"].forEach((u)=>{N.on(u,()=>{if(a.killed===!1&&a.exitCode===null)a.kill(u)})});let l=this._exitCallback;a.on("close",(c)=>{if(c=c??1,!l)N.exit(c);else l(new oe(c,"commander.executeSubCommandAsync","(close)"))}),a.on("error",(c)=>{if(c.code==="ENOENT")this._checkForMissingExecutable(i,r,e._name);else if(c.code==="EACCES")throw Error(`'${i}' not executable`);if(!l)N.exit(1);else{let u=new oe(1,"commander.executeSubCommandAsync","(error)");u.nestedError=c,l(u)}}),this.runningCommand=a}_dispatchSubcommand(e,t,n){let s=this._findCommand(e);if(!s)this.help({error:!0});s._prepareForParse();let i;return i=this._chainOrCallSubCommandHook(i,s,"preSubcommand"),i=this._chainOrCall(i,()=>{if(s._executableHandler)this._executeSubCommand(s,t.concat(n));else return s._parseCommand(t,n)}),i}_dispatchHelpCommand(e){if(!e)this.help();let t=this._findCommand(e);if(t&&!t._executableHandler)t.help();return this._dispatchSubcommand(e,[],[this._getHelpOption()?.long??this._getHelpOption()?.short??"--help"])}_checkNumberOfArguments(){if(this.registeredArguments.forEach((e,t)=>{if(e.required&&this.args[t]==null)this.missingArgument(e.name())}),this.registeredArguments.length>0&&this.registeredArguments[this.registeredArguments.length-1].variadic)return;if(this.args.length>this.registeredArguments.length)this._excessArguments(this.args)}_processArguments(){let e=(n,s,i)=>{let r=s;if(s!==null&&n.parseArg){let o=`error: command-argument value '${s}' is invalid for argument '${n.name()}'.`;r=this._callParseArg(n,s,i,o)}return r};this._checkNumberOfArguments();let t=[];this.registeredArguments.forEach((n,s)=>{let i=n.defaultValue;if(n.variadic){if(s<this.args.length){if(i=this.args.slice(s),n.parseArg)i=i.reduce((r,o)=>e(n,o,r),n.defaultValue)}else if(i===void 0)i=[]}else if(s<this.args.length){if(i=this.args[s],n.parseArg)i=e(n,i,n.defaultValue)}t[s]=i}),this.processedArgs=t}_chainOrCall(e,t){if(e?.then&&typeof e.then==="function")return e.then(()=>t());return t()}_chainOrCallHooks(e,t){let n=e,s=[];if(this._getCommandAndAncestors().reverse().filter((i)=>i._lifeCycleHooks[t]!==void 0).forEach((i)=>{i._lifeCycleHooks[t].forEach((r)=>{s.push({hookedCommand:i,callback:r})})}),t==="postAction")s.reverse();return s.forEach((i)=>{n=this._chainOrCall(n,()=>i.callback(i.hookedCommand,this))}),n}_chainOrCallSubCommandHook(e,t,n){let s=e;if(this._lifeCycleHooks[n]!==void 0)this._lifeCycleHooks[n].forEach((i)=>{s=this._chainOrCall(s,()=>i(this,t))});return s}_parseCommand(e,t){let n=this.parseOptions(t);if(this._parseOptionsEnv(),this._parseOptionsImplied(),e=e.concat(n.operands),t=n.unknown,this.args=e.concat(t),e&&this._findCommand(e[0]))return this._dispatchSubcommand(e[0],e.slice(1),t);if(this._getHelpCommand()&&e[0]===this._getHelpCommand().name())return this._dispatchHelpCommand(e[1]);if(this._defaultCommandName)return this._outputHelpIfRequested(t),this._dispatchSubcommand(this._defaultCommandName,e,t);if(this.commands.length&&this.args.length===0&&!this._actionHandler&&!this._defaultCommandName)this.help({error:!0});this._outputHelpIfRequested(n.unknown),this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let s=()=>{if(n.unknown.length>0)this.unknownOption(n.unknown[0])},i=`command:${this.name()}`;if(this._actionHandler){s(),this._processArguments();let r;if(r=this._chainOrCallHooks(r,"preAction"),r=this._chainOrCall(r,()=>this._actionHandler(this.processedArgs)),this.parent)r=this._chainOrCall(r,()=>{this.parent.emit(i,e,t)});return r=this._chainOrCallHooks(r,"postAction"),r}if(this.parent?.listenerCount(i))s(),this._processArguments(),this.parent.emit(i,e,t);else if(e.length){if(this._findCommand("*"))return this._dispatchSubcommand("*",e,t);if(this.listenerCount("command:*"))this.emit("command:*",e,t);else if(this.commands.length)this.unknownCommand();else s(),this._processArguments()}else if(this.commands.length)s(),this.help({error:!0});else s(),this._processArguments()}_findCommand(e){if(!e)return;return this.commands.find((t)=>t._name===e||t._aliases.includes(e))}_findOption(e){return this.options.find((t)=>t.is(e))}_checkForMissingMandatoryOptions(){this._getCommandAndAncestors().forEach((e)=>{e.options.forEach((t)=>{if(t.mandatory&&e.getOptionValue(t.attributeName())===void 0)e.missingMandatoryOptionValue(t)})})}_checkForConflictingLocalOptions(){let e=this.options.filter((n)=>{let s=n.attributeName();if(this.getOptionValue(s)===void 0)return!1;return this.getOptionValueSource(s)!=="default"});e.filter((n)=>n.conflictsWith.length>0).forEach((n)=>{let s=e.find((i)=>n.conflictsWith.includes(i.attributeName()));if(s)this._conflictingOption(n,s)})}_checkForConflictingOptions(){this._getCommandAndAncestors().forEach((e)=>{e._checkForConflictingLocalOptions()})}parseOptions(e){let t=[],n=[],s=t;function i(c){return c.length>1&&c[0]==="-"}let r=(c)=>{if(!/^-(\d+|\d*\.\d+)([eE][+-]?\d+)?$/.test(c))return!1;return!this._getCommandAndAncestors().some((u)=>u.options.map((f)=>f.short).some((f)=>/^-\d$/.test(f)))},o=null,a=null,l=0;while(l<e.length||a){let c=a??e[l++];if(a=null,c==="--"){if(s===n)s.push(c);s.push(...e.slice(l));break}if(o&&(!i(c)||r(c))){this.emit(`option:${o.name()}`,c);continue}if(o=null,i(c)){let u=this._findOption(c);if(u){if(u.required){let f=e[l++];if(f===void 0)this.optionMissingArgument(u);this.emit(`option:${u.name()}`,f)}else if(u.optional){let f=null;if(l<e.length&&(!i(e[l])||r(e[l])))f=e[l++];this.emit(`option:${u.name()}`,f)}else this.emit(`option:${u.name()}`);o=u.variadic?u:null;continue}}if(c.length>2&&c[0]==="-"&&c[1]!=="-"){let u=this._findOption(`-${c[1]}`);if(u){if(u.required||u.optional&&this._combineFlagAndOptionalValue)this.emit(`option:${u.name()}`,c.slice(2));else this.emit(`option:${u.name()}`),a=`-${c.slice(2)}`;continue}}if(/^--[^=]+=/.test(c)){let u=c.indexOf("="),f=this._findOption(c.slice(0,u));if(f&&(f.required||f.optional)){this.emit(`option:${f.name()}`,c.slice(u+1));continue}}if(s===t&&i(c)&&!(this.commands.length===0&&r(c)))s=n;if((this._enablePositionalOptions||this._passThroughOptions)&&t.length===0&&n.length===0){if(this._findCommand(c)){t.push(c),n.push(...e.slice(l));break}else if(this._getHelpCommand()&&c===this._getHelpCommand().name()){t.push(c,...e.slice(l));break}else if(this._defaultCommandName){n.push(c,...e.slice(l));break}}if(this._passThroughOptions){s.push(c,...e.slice(l));break}s.push(c)}return{operands:t,unknown:n}}opts(){if(this._storeOptionsAsProperties){let e={},t=this.options.length;for(let n=0;n<t;n++){let s=this.options[n].attributeName();e[s]=s===this._versionOptionName?this._version:this[s]}return e}return this._optionValues}optsWithGlobals(){return this._getCommandAndAncestors().reduce((e,t)=>Object.assign(e,t.opts()),{})}error(e,t){if(this._outputConfiguration.outputError(`${e}
159
+ `,this._outputConfiguration.writeErr),typeof this._showHelpAfterError==="string")this._outputConfiguration.writeErr(`${this._showHelpAfterError}
160
+ `);else if(this._showHelpAfterError)this._outputConfiguration.writeErr(`
161
+ `),this.outputHelp({error:!0});let n=t||{},s=n.exitCode||1,i=n.code||"commander.error";this._exit(s,i,e)}_parseOptionsEnv(){this.options.forEach((e)=>{if(e.envVar&&e.envVar in N.env){let t=e.attributeName();if(this.getOptionValue(t)===void 0||["default","config","env"].includes(this.getOptionValueSource(t)))if(e.required||e.optional)this.emit(`optionEnv:${e.name()}`,N.env[e.envVar]);else this.emit(`optionEnv:${e.name()}`)}})}_parseOptionsImplied(){let e=new As(this.options),t=(n)=>this.getOptionValue(n)!==void 0&&!["default","implied"].includes(this.getOptionValueSource(n));this.options.filter((n)=>n.implied!==void 0&&t(n.attributeName())&&e.valueFromOption(this.getOptionValue(n.attributeName()),n)).forEach((n)=>{Object.keys(n.implied).filter((s)=>!t(s)).forEach((s)=>{this.setOptionValueWithSource(s,n.implied[s],"implied")})})}missingArgument(e){let t=`error: missing required argument '${e}'`;this.error(t,{code:"commander.missingArgument"})}optionMissingArgument(e){let t=`error: option '${e.flags}' argument missing`;this.error(t,{code:"commander.optionMissingArgument"})}missingMandatoryOptionValue(e){let t=`error: required option '${e.flags}' not specified`;this.error(t,{code:"commander.missingMandatoryOptionValue"})}_conflictingOption(e,t){let n=(r)=>{let o=r.attributeName(),a=this.getOptionValue(o),l=this.options.find((u)=>u.negate&&o===u.attributeName()),c=this.options.find((u)=>!u.negate&&o===u.attributeName());if(l&&(l.presetArg===void 0&&a===!1||l.presetArg!==void 0&&a===l.presetArg))return l;return c||r},s=(r)=>{let o=n(r),a=o.attributeName();if(this.getOptionValueSource(a)==="env")return`environment variable '${o.envVar}'`;return`option '${o.flags}'`},i=`error: ${s(e)} cannot be used with ${s(t)}`;this.error(i,{code:"commander.conflictingOption"})}unknownOption(e){if(this._allowUnknownOption)return;let t="";if(e.startsWith("--")&&this._showSuggestionAfterError){let s=[],i=this;do{let r=i.createHelp().visibleOptions(i).filter((o)=>o.long).map((o)=>o.long);s=s.concat(r),i=i.parent}while(i&&!i._enablePositionalOptions);t=Cs(e,s)}let n=`error: unknown option '${e}'${t}`;this.error(n,{code:"commander.unknownOption"})}_excessArguments(e){if(this._allowExcessArguments)return;let t=this.registeredArguments.length,n=t===1?"":"s",s=e.length,i=this.parent?` for '${this.name()}'`:"",r=e.join(", "),o=`error: too many arguments${i}. Expected ${t} argument${n} but got ${s}: ${r}.`;this.error(o,{code:"commander.excessArguments"})}unknownCommand(){let e=this.args[0],t="";if(this._showSuggestionAfterError){let s=[];this.createHelp().visibleCommands(this).forEach((i)=>{if(s.push(i.name()),i.alias())s.push(i.alias())}),t=Cs(e,s)}let n=`error: unknown command '${e}'${t}`;this.error(n,{code:"commander.unknownCommand"})}version(e,t,n){if(e===void 0)return this._version;this._version=e,t=t||"-V, --version",n=n||"output the version number";let s=this.createOption(t,n);return this._versionOptionName=s.attributeName(),this._registerOption(s),this.on("option:"+s.name(),()=>{this._outputConfiguration.writeOut(`${e}
162
+ `),this._exit(0,"commander.version",e)}),this}description(e,t){if(e===void 0&&t===void 0)return this._description;if(this._description=e,t)this._argsDescription=t;return this}summary(e){if(e===void 0)return this._summary;return this._summary=e,this}alias(e){if(e===void 0)return this._aliases[0];let t=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler)t=this.commands[this.commands.length-1];if(e===t._name)throw Error("Command alias can't be the same as its name");let n=this.parent?._findCommand(e);if(n){let s=[n.name()].concat(n.aliases()).join("|");throw Error(`cannot add alias '${e}' to command '${this.name()}' as already have command '${s}'`)}return t._aliases.push(e),this}aliases(e){if(e===void 0)return this._aliases;return e.forEach((t)=>this.alias(t)),this}usage(e){if(e===void 0){if(this._usage)return this._usage;let t=this.registeredArguments.map((n)=>on(n));return[].concat(this.options.length||this._helpOption!==null?"[options]":[],this.commands.length?"[command]":[],this.registeredArguments.length?t:[]).join(" ")}return this._usage=e,this}name(e){if(e===void 0)return this._name;return this._name=e,this}helpGroup(e){if(e===void 0)return this._helpGroupHeading??"";return this._helpGroupHeading=e,this}commandsGroup(e){if(e===void 0)return this._defaultCommandGroup??"";return this._defaultCommandGroup=e,this}optionsGroup(e){if(e===void 0)return this._defaultOptionGroup??"";return this._defaultOptionGroup=e,this}_initOptionGroup(e){if(this._defaultOptionGroup&&!e.helpGroupHeading)e.helpGroup(this._defaultOptionGroup)}_initCommandGroup(e){if(this._defaultCommandGroup&&!e.helpGroup())e.helpGroup(this._defaultCommandGroup)}nameFromFilename(e){return this._name=ae.basename(e,ae.extname(e)),this}executableDir(e){if(e===void 0)return this._executableDir;return this._executableDir=e,this}helpInformation(e){let t=this.createHelp(),n=this._getOutputContext(e);t.prepareContext({error:n.error,helpWidth:n.helpWidth,outputHasColors:n.hasColors});let s=t.formatHelp(this,t);if(n.hasColors)return s;return this._outputConfiguration.stripColor(s)}_getOutputContext(e){e=e||{};let t=!!e.error,n,s,i;if(t)n=(o)=>this._outputConfiguration.writeErr(o),s=this._outputConfiguration.getErrHasColors(),i=this._outputConfiguration.getErrHelpWidth();else n=(o)=>this._outputConfiguration.writeOut(o),s=this._outputConfiguration.getOutHasColors(),i=this._outputConfiguration.getOutHelpWidth();return{error:t,write:(o)=>{if(!s)o=this._outputConfiguration.stripColor(o);return n(o)},hasColors:s,helpWidth:i}}outputHelp(e){let t;if(typeof e==="function")t=e,e=void 0;let n=this._getOutputContext(e),s={error:n.error,write:n.write,command:this};this._getCommandAndAncestors().reverse().forEach((r)=>r.emit("beforeAllHelp",s)),this.emit("beforeHelp",s);let i=this.helpInformation({error:n.error});if(t){if(i=t(i),typeof i!=="string"&&!Buffer.isBuffer(i))throw Error("outputHelp callback must return a string or a Buffer")}if(n.write(i),this._getHelpOption()?.long)this.emit(this._getHelpOption().long);this.emit("afterHelp",s),this._getCommandAndAncestors().forEach((r)=>r.emit("afterAllHelp",s))}helpOption(e,t){if(typeof e==="boolean"){if(e){if(this._helpOption===null)this._helpOption=void 0;if(this._defaultOptionGroup)this._initOptionGroup(this._getHelpOption())}else this._helpOption=null;return this}if(this._helpOption=this.createOption(e??"-h, --help",t??"display help for command"),e||t)this._initOptionGroup(this._helpOption);return this}_getHelpOption(){if(this._helpOption===void 0)this.helpOption(void 0,void 0);return this._helpOption}addHelpOption(e){return this._helpOption=e,this._initOptionGroup(e),this}help(e){this.outputHelp(e);let t=Number(N.exitCode??0);if(t===0&&e&&typeof e!=="function"&&e.error)t=1;this._exit(t,"commander.help","(outputHelp)")}addHelpText(e,t){let n=["beforeAll","before","after","afterAll"];if(!n.includes(e))throw Error(`Unexpected value for position to addHelpText.
163
+ Expecting one of '${n.join("', '")}'`);let s=`${e}Help`;return this.on(s,(i)=>{let r;if(typeof t==="function")r=t({error:i.error,command:i.command});else r=t;if(r)i.write(`${r}
164
+ `)}),this}_outputHelpIfRequested(e){let t=this._getHelpOption();if(t&&e.find((s)=>t.is(s)))this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)")}}function qr(e){return e.map((t)=>{if(!t.startsWith("--inspect"))return t;let n,s="127.0.0.1",i="9229",r;if((r=t.match(/^(--inspect(-brk|-wait)?)$/))!==null)n=r[1];else if((r=t.match(/^(--inspect(-brk|-port|-wait)?)=(\[[^\]]+\]|[^:]+)$/))!==null)if(n=r[1],/^\d+$/.test(r[3]))i=r[3];else s=r[3];else if((r=t.match(/^(--inspect(-brk|-port|-wait)?)=(\[[^\]]+\]|[^:]+):(\d+)$/))!==null)n=r[1],s=r[3],i=r[4];if(n&&i!=="0")return`${n}=${s}:${parseInt(i)+1}`;return t})}function Dr(){if(N.env.NO_COLOR||N.env.FORCE_COLOR==="0"||N.env.FORCE_COLOR==="false")return!1;if(N.env.FORCE_COLOR||N.env.CLICOLOR_FORCE!==void 0)return!0;return}var dO=new Be;import{homedir as Bd}from"node:os";import{join as Vd}from"node:path";import{homedir as hd}from"node:os";import{join as md}from"node:path";import{existsSync as Wr,readdirSync as _f,readFileSync as Hr}from"node:fs";import{dirname as Sf,join as Ve}from"node:path";var Fr=/^[A-Za-z]:[\\/]/,Rs=/^\\\\/,mf=/^(?:~|\$HOME|\$\{HOME\})(?=[\\/]|$)/,gf=/^(?:[A-Za-z]:|[\\~$%])/,yf=(e)=>Fr.test(e)||Rs.test(e);function D(e){if(!yf(e))return e.replace(/\/{2,}/g,"/");return(Rs.test(e)?"/":"")+e.replace(/[\\/]+/g,"/")}function cn(e,t){let n=[];for(let s of e){if(!s||s===".")continue;if(s!=="..")n.push(s);else if(n.length)n.pop();else if(t==="home")return null}return n}function pt(e,t,n){let s=cn(n,e);return s&&{kind:e,prefix:t,segs:s}}function jr(e,t){if(!e)return null;if(Fr.test(e))return pt("drive",e.slice(0,2).toLowerCase(),e.slice(2).toLowerCase().split(/[\\/]/));if(Rs.test(e)){let[r="",o="",...a]=e.toLowerCase().slice(2).split(/[\\/]+/);return pt("unc",`//${r}/${o}`,a)}if(e.startsWith("/"))return pt("posix","",e.split("/"));let n=mf.exec(e)?.[0];if(n!==void 0)return pt("home","~",e.slice(n.length).split(/[\\/]/));if(!t||gf.test(e))return null;let i=t.kind==="posix"?e.split("/"):e.toLowerCase().split(/[\\/]/);return pt(t.kind,t.prefix,[...t.segs,...i])}function Mr(e,t){let n=e.segs[0];if(e.kind!=="posix"||t.kind!=="drive"||!n||!/^[A-Za-z]$/.test(n))return e;return{kind:"drive",prefix:`${n.toLowerCase()}:`,segs:e.segs.slice(1).map((s)=>s.toLowerCase())}}function Ur(e,t){let n=jr(t),s=n&&jr(e,n);if(!n||!s)return!1;let i=Mr(s,n),r=Mr(n,s);if(i.kind!==r.kind||i.prefix!==r.prefix)return!1;return r.segs.every((o,a)=>i.segs[a]===o)}import{createRequire as wf}from"node:module";var Br=wf(import.meta.url);function bf(e,t){if(process.versions.bun){let{Database:s}=Br("bun:sqlite");return t?new s(e,{readonly:!0}):new s(e)}let n=Br("node:sqlite");return new(n.Database??n.DatabaseSync)(e,{readOnly:t})}function ht(e,{readonly:t=!1}={}){let n=bf(e,t),s=[];return{prepare(i){let r=n.prepare(i);return s.push(r),{run:(...o)=>r.run(...o),get:(...o)=>r.get(...o)??void 0,all:(...o)=>r.all(...o)}},exec(i){n.exec(i)},close(){for(let i of s)i.finalize?.();n.close()}}}var Kr=".system_generated",vf=`${Kr}/logs/transcript_full.jsonl`,Ef=/^(.*\/brain)\/([^/]+)\/\.system_generated\//,$s=(e)=>{try{return _f(e)}catch{return[]}};function Jr(e){let t=Ve(e,"brain");return $s(t).map((n)=>D(Ve(t,n,vf))).filter((n)=>Wr(n)).sort()}function Gr(e){if(typeof e!=="string"||!e.startsWith("file://"))return;try{let t=decodeURIComponent(e.slice(7)).replace(/^\/(?=[A-Za-z]:)/,"");return D(t)}catch{return}}var kf=(e)=>{try{return JSON.parse(String(e))?.[0]}catch{return}};function Of(e){let t=new Map,n=Ve(e,"conversation_summaries.db");if(!Wr(n))return t;try{let s=ht(n,{readonly:!0});try{for(let i of s.prepare("SELECT conversation_id, workspace_uris FROM conversation_summaries").all()){let r=Gr(kf(i.workspace_uris));if(typeof i.conversation_id==="string"&&r)t.set(i.conversation_id,r)}}finally{s.close()}}catch{}return t}function xf(e){let t=new Map,n="";try{n=Hr(Ve(e,"history.jsonl"),"utf8")}catch{return t}for(let s of n.split(`
165
+ `))try{let i=JSON.parse(s);if(typeof i?.conversationId==="string"&&typeof i.workspace==="string"&&i.workspace&&!t.has(i.conversationId))t.set(i.conversationId,D(i.workspace))}catch{}return t}var Vr=new Map;function Ns(e){let t=Vr.get(e);if(t)return t;let n=new Map;for(let o of $s(e)){let a=Ve(e,o,Kr,"subagents");for(let l of $s(a).filter((c)=>c.endsWith(".json")))try{let c=JSON.parse(Hr(Ve(a,l),"utf8")),u=l.slice(0,-5),f=Gr(c?.workspaceUris?.[0]);n.set(u,{...n.get(u),parent:o,workspace:f,role:c?.subagentDescriptor?.role}),n.set(o,{workspace:f,...n.get(o)})}catch{}}let s=Sf(e),[i,r]=[Of(s),xf(s)];for(let o of new Set([...i.keys(),...r.keys()])){let a=n.get(o)??{};n.set(o,{...a,workspace:i.get(o)??a.workspace??r.get(o)})}return Vr.set(e,n),n}function Ls(e,t){let n=t;for(let s=0;s<32&&e.get(n)?.parent;s++)n=e.get(n).parent;return n}function Yr(e){let{brain:t,conv:n}=Is(e);return t?`${t}/${Ls(Ns(t),n)}`:e}function Is(e){let[,t,n]=Ef.exec(D(e))??[];return t&&n?{brain:t,conv:n}:{conv:D(e).split("/").pop()??e}}import{createHash as ao}from"node:crypto";import{readFileSync as ld}from"node:fs";import{createHash as Af}from"node:crypto";var Cf="…[masked]",zr=[{name:"private_key",strong:!0,re:/(-----BEGIN) [A-Z ]*PRIVATE KEY-----[\s\S]*?(?:-----END [A-Z ]*PRIVATE KEY-----|$)/g},{name:"aws_access_key",strong:!0,re:/\b(AKIA|ASIA)[0-9A-Z]{16}\b/g},{name:"github_token",strong:!0,re:/\b(gh[pousr]_)[A-Za-z0-9]{30,}\b/g},{name:"github_pat",strong:!0,re:/\b(github_pat_)[A-Za-z0-9_]{20,}/g},{name:"gitlab_token",strong:!0,re:/\b(glpat-)[A-Za-z0-9_-]{20,}/g},{name:"slack_token",strong:!0,re:/\b(xox[abprs]-)[A-Za-z0-9-]{10,}/g},{name:"slack_webhook",strong:!0,re:/(hooks\.slack\.com\/services)\/[A-Za-z0-9/_-]+/g},{name:"stripe_key",strong:!0,re:/\b((?:sk|rk|pk)_(?:live|test)_)[A-Za-z0-9]{16,}/g},{name:"sk_key",strong:!0,re:/\b(sk-)(?:ant-|proj-)?[A-Za-z0-9_-]{20,}/g},{name:"jwt",strong:!0,re:/\b(eyJ)[A-Za-z0-9_-]{8,1024}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}/g},{name:"bearer_token",strong:!0,re:/\b(Bearer\s+|(?:[Aa]uthorization|AUTHORIZATION)["']?\s*[=:]\s*["']?(?:bearer|BEARER)\s+)(?!\$)[A-Za-z0-9._~+/=-]{12,}/g},{name:"assignment",strong:!1,re:/((?:KEY|TOKEN|SECRET|PASSWORD|PASSWD|CREDENTIALS?|AUTH)[A-Za-z0-9_]{0,64}["']?\s*[=:]\s*["']?)(?![$<{(…])[^\s"'&;,)}]{8,}/gi},{name:"url_credential",strong:!1,re:/(\b\w+:\/\/[^\s:/@]+:)[^\s@/]{3,}(?=@)/g}],Xr=zr.filter((e)=>e.strong);function x(e){for(let{re:t}of zr)e=e.replace(t,`$1${Cf}`);return e}function ne(e){return Xr.filter(({re:t})=>e.search(t)>=0).map(({name:t})=>t)}var Tf=(e)=>e.replace(/^[^\n]*?bearer\s+|\\[nr]|\s/gi,"");function We(e){let t=new Set;for(let{re:n}of Xr)for(let[s]of e.matchAll(n))t.add(Af("sha256").update(Tf(s)).digest("hex").slice(0,16));return[...t]}var EO=String.raw`[\\/]+`;import{createHash as Qr}from"node:crypto";import{closeSync as Rf,openSync as $f,readFileSync as Nf,readSync as Zr,statSync as to}from"node:fs";var Lf=new Set("system api-request api-request-blob api-request-shape last-prompt atis-latch mode ai-title queue-operation session-owner custom-title agent-name file-history-snapshot file-history-delta tools-used pr-link cost-state frame-link artifact-comment-monitor artifact-autoreact-ledger summary progress bridge-session continued-in".split(" ")),If=new Set(["Bash","PowerShell","Monitor"]),Pf=new Set(["Write","Edit","MultiEdit","NotebookEdit"]),qf=/^mcp__(.+)__(.+)$/,Df=/^[a-z][a-z0-9+.-]*:\/\//i,jf=/\b(?:https?|wss?|s?ftp|ssh|git):\/\/[^\s"'`<>|;)\\]+/i,Mf=/^(?:[A-Za-z]:|[$%~\\])/,Ff=/^(?:[A-Za-z]:\/|\/\/[^/]+\/[^/]+\/?|\/(?!\/))/,Uf=/^(?:~|\$HOME|\$\{HOME\})(?:[\\/]|$)/,Bf=/(?:\.jsonl\.superseded-[^\\/]*|\.orphaned-[^\\/]*\.jsonl)$/,Vf=/[\\/]agent-([^\\/]+?)\.jsonl$/,Wf=/^(.*)[\\/]subagents[\\/][^\\/]+$/,Hf=1048576,Kf=33554432,Jf=64,Gf=/(?<!<)<<-?\s*(['"]?)(\w+)(?!\w)\1([^\n]*)\n(?:([\s\S]*?)\n)??[ \t]*\2(?=[\s);&|]|$)/g,Yf=/^(?:\/\S*\/)?(?:cat|tee)(?=[\s<>]|$)|^git\s+(?:commit|tag)\b|^gh\s+(?:pr|issue|release)\b/,zf=/^\s*(?:\w+=\S*\s+)*/,Xf=/(?<!\|)\|(?!\|)|[<>]\(/,T=(e)=>typeof e==="string"&&e?e:void 0;function no(e){let t={};for(let[n,s]of Object.entries(e))if(s!==void 0)t[n]=s;return t}function Qf(e,t){if(Xf.test(t)||/\\\s*$/.test(t))return!1;if(/[#']/.test(e)||(e.replaceAll('"$(',"").split('"').length-1)%2)return!1;return e.split(/\|\||&&|[;&|]/).pop().split(/\$\(|[(`]/).every((s)=>Yf.test(s.replace(zf,"")))}function Zf(e){if(e.split("<<").length>Jf)return[e,void 0];let t=[];return[e.replace(Gf,(s,i,r,o,a="",l)=>{if(!Qf(e.slice(e.lastIndexOf(`
166
+ `,l)+1,l),o))return s;if(a)t.push(a);return`<<${r}${o}`}),t.length?t.join(`
167
+ `):void 0]}function so(e){try{return new URL(e).hostname.toLowerCase()||void 0}catch{return}}var io=(e)=>e.match(jf)?.[0]?.replace(/[.,]+$/,"");function ed(e){let t=Ff.exec(e)?.[0],n=t??Uf.exec(e)?.[0];if(n===void 0)return e;let s=e.slice(n.length),i=t===void 0?cn(s.split(/[\\/]/),"home"):cn(s.split("/"),"posix");return i?n.replace("\\","/")+i.join("/"):e}function Ps(e,t){return ed(D(!t||e.startsWith("/")||Mf.test(e)?e:`${t}/${e}`))}function qs(e){let t=[e.tool_input,e.content].filter((i)=>i!==void 0),n=[...new Set(t.flatMap((i)=>ne(i)))],s=[...new Set(t.flatMap((i)=>We(i)))];if(n.length)e.secret_kinds=n;if(s.length)e.secret_fps=s}function td(e){let t=Array.isArray(e.edits)?e.edits.map((n)=>n?.new_string??"").join(`
168
+ `):void 0;return T(e.content??e.new_string??e.new_source??t)}function V(e,t,n){let s=t!==null&&typeof t==="object"?t:{},i={category:"tool_call",tool_name:e,tool_input:JSON.stringify(t??{})},r=T(s.file_path)??T(s.notebook_path)??T(s.path);if(r)i.target_path=Ps(r,n);let o=qf.exec(e);if(If.has(e)){if(i.category="process_creation",typeof s.command==="string")[i.command_line,i.content]=Zf(s.command),i.url=io(i.command_line)}else if(e==="Read")i.category="file_access";else if(Pf.has(e))i.category="file_event",i.content=td(s);else if(e==="WebFetch")i.category="web_request",i.url=T(s.url);else if(o){i.mcp_server=o[1],i.mcp_tool=o[2];let a=Array.isArray(s.actions)?s.actions.find((c)=>typeof c?.input?.url==="string")?.input.url:void 0,l=T(s.url)??a;if(i.category=l&&Df.test(l)?"web_request":"mcp",i.category==="web_request")i.url=l}if(i.url)i.domain=so(i.url);return qs(i),no(i)}function nd(e,t){if(e.type==="file"&&T(e.filename))return[{category:"file_access",tool_name:"@file",target_path:Ps(e.filename,t),content:T(e.content?.file?.content)}];if(e.type==="instructions"&&Array.isArray(e.files))return e.files.filter((n)=>T(n?.path)).map((n)=>({category:"instruction_load",target_path:Ps(n.path,t),content:T(n.content)}));if(typeof e.type==="string"&&e.type.startsWith("hook_")&&T(e.command)){let n=e.type==="hook_success"&&!e.exitCode,s=io(e.command);return[{category:"process_creation",tool_name:`hook:${T(e.hookEvent)??"unknown"}`,command_line:e.command,content:T(e.stdout),outcome:n?"success":"error",url:s,domain:s&&so(s)}]}return[]}function eo(e){if(typeof e==="string")return T(e);if(!Array.isArray(e))return;return T(e.flatMap((t)=>t?.type==="text"&&typeof t.text==="string"?[t.text]:[]).join(`
169
+ `))}var ro=(e)=>Array.isArray(e.message?.content)?e.message.content.filter((t)=>t?.type==="tool_result"&&T(t.tool_use_id)):[],sd=(e)=>e.attributionSkill&&`skill:${e.attributionSkill}`||e.attributionMcpServer&&`mcp:${e.attributionMcpServer}`||e.attributionPlugin&&`plugin:${e.attributionPlugin}`||void 0;function*id(e,t){let n=$f(e,"r");try{let s=Buffer.allocUnsafe(Hf),i=new TextDecoder,r="";for(let o=Zr(n,s);o>0;o=Zr(n,s)){t.update(s.subarray(0,o));let a=i.decode(s.subarray(0,o),{stream:!0});if(!a.includes(`
170
+ `)){r+=a;continue}let l=(r+a).split(`
171
+ `);r=l.pop()??"";for(let c of l)yield c.endsWith("\r")?c.slice(0,-1):c}if(r+=i.decode(),r)yield r.endsWith("\r")?r.slice(0,-1):r}finally{Rf(n)}}function js(e){try{return Nf(e,"utf8")}catch{return}}function Ds(e){try{let t=JSON.parse(e);return t!==null&&typeof t==="object"&&!Array.isArray(t)?t:void 0}catch{return}}function rd(e,t){let n=T(t)?.split(/[\\/]/).pop();if(!n)return;let s=`${e}/tool-results/${n}`;try{return to(s).size<=Kf?js(s):void 0}catch{return}}function od(e,t){let n=js(e);for(let s=n?.indexOf(t)??-1;n!==void 0&&s>=0;s=n.indexOf(t,s+1)){let i=n.indexOf(`
172
+ `,s),r=Ds(n.slice(n.lastIndexOf(`
173
+ `,s)+1,i<0?void 0:i));if(r?.toolUseResult?.agentId===t)return ro(r)[0]?.tool_use_id;if(i<0)break;s=i}return}async function oo(e){let t=D(e),n=t.replace(Bf,".jsonl"),s=Wf.exec(e),i=s?.[1]??e.replace(/\.(?:jsonl|orphaned-)[^\\/]*$/,""),r=Vf.exec(e)?.[1],o=r?Ds(js(e.replace(/\.jsonl$/,".meta.json"))??""):void 0,a=[],l=new Map,c=new Map,u=[],f=[],d=new Map,h=new Map,g={lines:0,malformed:0,unknown_types:{}},p={session_id:i.split(/[\\/]/).pop(),permission_mode:T(o?.permissionMode)},m,O=(S)=>{let w=(h.get(S)??0)+1;return h.set(S,w),`${S}\x00${w}`},y=(S,w,C)=>{let P=0,H=T(S.uuid),q=p.project_path,de=(M)=>{H??=O(C);let pe=Qr("sha256").update(`${n}\x00${H}\x00${P++}`).digest("hex").slice(0,32),Fe=no({id:pe,schema_version:"0.1",agent:"claude_code",session_id:p.session_id,ts:p.ts??"",seq:a.length,raw_ref:{file:t,line:w},agent_id:T(S.agentId)??r,agent_version:p.agent_version,project_path:p.project_path,entrypoint:p.entrypoint,permission_mode:p.permission_mode,prompt_source:T(S.promptSource)??(S.isMeta?"system":void 0),attribution:sd(S),category:"tool_call",...M});return a.push(Fe),Fe};switch(S.type){case"assistant":for(let M of Array.isArray(S.message?.content)?S.message.content:[])if(M?.type==="tool_use"&&T(M.name)){let pe=de({...V(M.name,M.input,q),outcome:"unknown"});if(T(M.id))c.set(M.id,pe)}else if(M?.type==="text"&&T(M.text))de({category:"assistant_message",text:M.text});break;case"user":{let M=eo(S.message?.content);if(M&&S.isMeta&&T(S.sourceToolUseID))f.push([S.sourceToolUseID,M]);else if(M&&!S.isCompactSummary)de({category:"user_prompt",text:M});for(let pe of ro(S)){let Fe=S.toolUseResult;if(T(Fe?.agentId))d.set(Fe.agentId,pe.tool_use_id);u.push({id:pe.tool_use_id,kind:T(S.toolDenialKind),rejected:S.permissionDecision?.decision==="reject",category:T(S.permissionDecision?.classifierCategory),isError:!!pe.is_error,text:eo(pe.content),spill:Fe?.persistedOutputPath})}break}case"attachment":for(let M of nd(S.attachment??{},q))qs(M),de(M);break;case"permission-mode":de({category:"config_change"});break;default:if(!Lf.has(S.type))l.set(String(S.type),(l.get(String(S.type))??0)+1)}},v=Qr("sha256"),_=!1;try{let S=0;for(let w of id(e,v)){if(S++,!w.trim())continue;g.lines++;let C=Ds(w);if(!C){g.malformed++;continue}p.ts=T(C.timestamp)??p.ts,m??=p.ts,p.session_id=T(C.sessionId)??p.session_id,p.project_path=T(C.cwd)?D(C.cwd):p.project_path,p.agent_version=T(C.version)??p.agent_version,p.entrypoint=T(C.entrypoint)??p.entrypoint,p.permission_mode=T(C.permissionMode)??p.permission_mode,y(C,S,w)}_=!0}catch{g.malformed++}for(let S of u){let w=c.get(S.id);if(!w)continue;let C=!!S.kind||S.rejected;if(w.outcome=C?"blocked":S.isError?"error":"success",S.kind)w.denial_kind=S.kind;if(S.category)w.denial_category=S.category;let P=rd(i,S.spill)??S.text;if(!P)continue;w.tool_response=P;let H=ne(P);if(H.length)w.result_secret_kinds=H}for(let[S,w]of f){let C=c.get(S);if(!C)continue;C.content=C.content?`${C.content}
174
+ ${w}`:w,qs(C)}let A=T(o?.toolUseId)??(s&&r?od(`${i}.jsonl`,r):void 0),b=m??ad(e);for(let S of a){if(S.ts||=b,!S.agent_id)continue;let w=(S.agent_id===r?A:void 0)??d.get(S.agent_id);if(w)S.parent_tool_use_id=w}return g.unknown_types=Object.fromEntries(l),{events:a,stats:g,sha256:_?v.digest("hex"):void 0}}function ad(e){try{return to(e).mtime.toISOString()}catch{return new Date(0).toISOString()}}var se=(e)=>typeof e==="string"&&e?e:void 0,cd=/^[a-z][a-z0-9+.-]*:\/\//i,ud=/Command exited with code (-?\d+)/,fd=/<USER_REQUEST>\s*([\s\S]*?)\s*<\/USER_REQUEST>/;function dd(e){let t=[e.tool_input,e.content].filter((i)=>i!==void 0),n=[...new Set(t.flatMap((i)=>ne(i)))],s=[...new Set(t.flatMap((i)=>We(i)))];if(n.length)e.secret_kinds=n;if(s.length)e.secret_fps=s}function Ms(e,t,n){let s=se(t.Path)??se(t.AbsolutePath)??se(t.TargetFile);switch(e){case"run_command":return V("Bash",{command:t.CommandLine},n);case"read_file":case"view_file":return V("Read",{file_path:s},n);case"write_file":case"write_to_file":return V("Write",{file_path:s,content:t.Content??t.CodeContent},n);case"edit_file":case"replace_file_content":return V("Edit",{file_path:s,new_string:t.Replacement??t.ReplacementContent},n);case"multi_replace_file_content":return V("Edit",{file_path:s,new_string:JSON.stringify(t.ReplacementChunks??[])},n);case"read_url_content":return V("WebFetch",{url:t.Url});case"search_web":{let i=se(t.query);return i&&cd.test(i)?V("WebFetch",{url:i}):{category:"web_request",tool_name:e}}case"invoke_subagent":case"ask_question":return{category:"tool_call",tool_name:e};default:return}}function pd(e,t){if(e.tool_name!=="run_command")return"success";let n=ud.exec(t)?.[1];return n===void 0?"unknown":n==="0"?"success":"error"}async function lo(e){let t=D(e),{brain:n,conv:s}=Is(e),i=n?Ns(n):new Map,r=Ls(i,s),o=se(i.get(s)?.workspace),a=[],l=new Map,c={lines:0,malformed:0,unknown_types:{}},u;try{u=ld(e)}catch{return c.malformed++,{events:a,stats:c}}let f=(h)=>l.set(h,(l.get(h)??0)+1),d=[];return u.toString("utf8").split(`
175
+ `).forEach((h,g)=>{if(!h.trim())return;c.lines++;let p;try{if(p=JSON.parse(h),p===null||typeof p!=="object"||Array.isArray(p))throw Error("not an object")}catch{c.malformed++;return}let m=0,O=(y)=>{let _={id:ao("sha256").update(`${t}\x00${p.step_index??`L${g}`}\x00${m++}`).digest("hex").slice(0,32),schema_version:"0.1",agent:"antigravity",session_id:r,ts:se(p.created_at)??"",seq:a.length,raw_ref:{file:t,line:g+1},agent_id:s===r?void 0:s,project_path:o,...y},A=Object.fromEntries(Object.entries(_).filter(([,b])=>b!==void 0));return a.push(A),A};switch(p.type){case"USER_INPUT":{d=[];let y=se(p.content);if(y)O({category:"user_prompt",text:fd.exec(y)?.[1]??y,prompt_source:"typed"});break}case"PLANNER_RESPONSE":if(d=[],se(p.content))O({category:"assistant_message",text:p.content});for(let y of Array.isArray(p.tool_calls)?p.tool_calls:[]){let v=se(y?.name);if(!v)continue;let _=y.args!==null&&typeof y.args==="object"?y.args:{},A=Ms(v,_,o);if(!A)f(`tool:${v}`);let b=O({category:"tool_call",...A,tool_name:v,tool_input:JSON.stringify(_),outcome:"unknown"});dd(b),d.push(b)}break;case"GENERIC":{let y=d.shift(),v=se(p.content);if(!y||!v)break;y.tool_response=v,y.outcome=pd(y,v);let _=ne(v);if(_.length)y.result_secret_kinds=_;break}case"SYSTEM_MESSAGE":break;default:f(String(p.type))}}),c.unknown_types=Object.fromEntries(l),{events:a,stats:c,sha256:ao("sha256").update(u).digest("hex")}}var co={agent:"antigravity",parserVersion:"antigravity/v3",defaultRoot:()=>md(hd(),".gemini","antigravity-cli"),discover:Jr,parseFile:lo,groupKey:Yr};import{existsSync as gd,readdirSync as yd}from"node:fs";import{join as He,resolve as wd}from"node:path";var bd=/\.jsonl(?:\.superseded-.*)?$/;function Fs(e){try{return yd(e,{withFileTypes:!0})}catch{return[]}}function uo(e){let t=wd(e),n=gd(He(t,"projects"))?He(t,"projects"):t,s=[];for(let i of Fs(n).filter((r)=>r.isDirectory())){let r=He(n,i.name);for(let o of Fs(r)){if(o.isFile()&&bd.test(o.name))s.push(He(r,o.name));if(!o.isDirectory())continue;let a=He(r,o.name,"subagents");for(let l of Fs(a))if(l.isFile()&&l.name.endsWith(".jsonl"))s.push(He(a,l.name))}}return s.map(D).sort()}import{homedir as Fd}from"node:os";import{join as Ud}from"node:path";import{readdirSync as _d,readFileSync as Sd}from"node:fs";import{join as un,resolve as vd}from"node:path";var Ed=/^rollout-.*\.jsonl(?:\.zst)?$/,kd=/([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})\.jsonl(?:\.zst)?$/i;function Od(e){try{return _d(e,{withFileTypes:!0})}catch{return[]}}function fo(e,t){for(let n of Od(e))if(n.isDirectory())fo(un(e,n.name),t);else if(n.isFile()&&Ed.test(n.name))t.push(un(e,n.name))}function xd(e){try{let t=JSON.parse(Sd(un(e,"external_agent_session_imports.json"),"utf8")),n=(Array.isArray(t?.records)?t.records:[]).map((s)=>s?.imported_thread_id);return new Set(n.filter((s)=>typeof s==="string").map((s)=>s.toLowerCase()))}catch{return new Set}}function po(e){let t=vd(e),n=[];for(let r of["sessions","archived_sessions"])fo(un(t,r),n);let s=xd(t);return n.filter((r)=>!s.has(kd.exec(r)?.[1]?.toLowerCase()??"")).map(D).sort()}import{createHash as wo}from"node:crypto";var Ad=/^(?:-[a-z]{0,3}c|-command|\/c)$/i,Ae=(e)=>typeof e==="string"&&e?e:void 0;function he(e){let t=Ae(e);if(!t)return;if(!/^file:\/\//i.test(t))return D(t);try{let n=decodeURIComponent(new URL(t).pathname);return D(/^\/[A-Za-z]:/.test(n)?n.slice(1):n)}catch{return}}function fn(e){if(typeof e==="string")return Ae(e);if(!Array.isArray(e))return;return Ae(e.flatMap((t)=>typeof t?.text==="string"?[t.text]:[]).join(`
176
+ `))}function mt(e,t){let n=e.findIndex((a,l)=>l>0&&Ad.test(a)),s=n>0&&e[n+1]!==void 0?e.slice(n+1).join(" "):e.join(" "),i=(e[0]??"").split(/[\\/]/).pop().toLowerCase().replace(/\.exe$/,""),r=/^(?:pwsh|powershell)$/.test(i)?"PowerShell":i==="cmd"?"cmd":"Bash",o=V(r,{command:s},t);if(r==="cmd")o.category="process_creation";return o}var Cd=(e)=>Array.isArray(e)?e.filter((t)=>typeof t==="string"):typeof e==="string"?[e]:[];function Td(e){let t=mt(Cd(e.command),he(e.cwd)),n=e.status==="completed"&&e.exit_code===0;t.outcome=n?"success":e.status==="failed"||typeof e.exit_code==="number"&&e.exit_code!==0?"error":"unknown";let s=Ae(e.aggregated_output);if(s){t.tool_response=s;let r=ne(s);if(r.length)t.result_secret_kinds=r}let i=he(e.cwd);return i?{...t,project_path:i}:t}function Rd(e){let t=Ae(e.action?.url),n=t?V("WebFetch",{url:t}):V("WebSearch",{query:Ae(e.query)??""}),s=Array.isArray(e.results)?e.results.map((i)=>[i?.title,i?.snippet].filter(Ae).join(" ")):[];return{...n,outcome:"success",...s.length?{tool_response:s.join(`
177
+ `)}:{}}}function ho(e,t){switch(e.type){case"CommandExecution":return Td(e);case"Extension":return e.kind==="web.search"?Rd(e):void 0;case"UserMessage":{let n=fn(e.content);return n?{category:"user_prompt",text:n,prompt_source:t?"system":"typed"}:void 0}case"AgentMessage":{let n=fn(e.content);return n?{category:"assistant_message",text:n}:void 0}case"SubAgentActivity":if(e.kind!=="started")return;return{...V("Agent",{agent_thread_id:e.agent_thread_id,agent_path:e.agent_path,model:e.model}),outcome:"success"};default:return}}import{closeSync as $d,openSync as Nd,readFileSync as Ld,readSync as mo}from"node:fs";import*as go from"node:zlib";var Id="needs Node >= 22.15 to read .jsonl.zst",gt=go.zstdDecompressSync??null;function Us(e,t=gt){let n=Ld(e);if(!e.endsWith(".zst"))return{raw:n,text:n.toString("utf8")};if(!t)throw Error(`${Id}: ${e.split(/[\\/]/).pop()}`);return{raw:n,text:t(n).toString("utf8")}}function yo(e,t=gt){if(e.endsWith(".zst"))return Us(e,t).text.split(`
178
+ `,1)[0]??"";let n=Nd(e,"r");try{let s=Buffer.allocUnsafe(65536),i=[];for(let r=mo(n,s),o=0;r>0&&o<8388608;r=mo(n,s)){let a=s.subarray(0,r).indexOf(10);if(i.push(Buffer.from(s.subarray(0,a<0?r:a))),o+=r,a>=0)break}return Buffer.concat(i).toString("utf8")}finally{$d(n)}}var Pd=/^Script running with cell ID (\S+)/,qd=new Set("response_item event_msg token_usage_record world_state inter_agent_communication_metadata turn_context".split(" ")),Dd=new Set(["shell","exec_command","shell_command","container.exec"]),U=(e)=>typeof e==="string"&&e?e:void 0,_o=/([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})\.jsonl(?:\.zst)?$/i;function yt(e){try{let t=JSON.parse(e);return t!==null&&typeof t==="object"&&!Array.isArray(t)?t:void 0}catch{return}}var So=(e)=>U(e.session_id)??U(e.parent_thread_id)??U(e.id),jd=(e)=>e.source?.subagent?.other==="guardian",bo=new Map;function vo(e,t=gt){let n=D(e),s=bo.get(n);if(s)return s;let i;try{let o=yt(yo(e,t));i=o?.type==="session_meta"?So(o.payload??{}):void 0}catch{}let r=`codex:${i??_o.exec(n)?.[1]??n}`;return bo.set(n,r),r}async function Md(e,t){let n=D(e),s=n.replace(/\.zst$/,""),i={lines:0,malformed:0,unknown_types:{}},r=[],o=new Map,a;try{a=Us(e,t)}catch(_){if(e.endsWith(".zst")&&!t)throw _;return i.malformed++,{events:r,stats:i}}let l={session:_o.exec(n)?.[1]??"",agent:void 0,version:void 0,cwd:void 0,ts:"",start:0,guardian:!1,legacy:!1,sub:!1,parentTurn:void 0,turn:void 0},c=!1,u=(_,A,b,S)=>{let C={id:wo("sha256").update(`${s}\x00${_.ordinal??A}\x00${b}`).digest("hex").slice(0,32),schema_version:"0.1",agent:"codex",session_id:l.session,agent_id:l.agent,agent_version:l.version,project_path:l.cwd,ts:l.ts,seq:r.length,raw_ref:{file:n,line:A},category:"tool_call",...S};for(let P of Object.keys(C))if(C[P]===void 0)delete C[P];return r.push(C),C},f=new Map,d=new Map,h=new Map,g=(_,A,b,S)=>{let w=U(b.call_id);if(!w)return;if(b.type==="function_call"&&b.name==="wait")h.set(w,String(yt(String(b.arguments??""))?.cell_id));else if(b.type==="custom_tool_call"||b.type==="function_call")f.set(w,{o:_,lineNo:A,ts:l.ts,turn:l.turn,name:U(b.name)??"unknown",input:U(b.input)??U(b.arguments),ev:S});else if(b.type==="custom_tool_call_output"||b.type==="function_call_output"){let C=Pd.exec(fn(b.output)??"")?.[1],P=f.get(w);if(f.delete(w),P&&C)d.set(C,P);let H=h.get(w);if(H!==void 0&&!C)d.delete(H)}},p=(_,A)=>{for(let b of[f,d])for(let[S,w]of b){if(_&&w.turn!==_)continue;if(b.delete(S),w.ev)Object.assign(w.ev,{outcome:"blocked",denial_kind:A});else u(w.o,w.lineNo,0,{tool_name:w.name,tool_input:w.input,ts:w.ts,outcome:"blocked",denial_kind:A})}},m=(_)=>{if(c=!0,l.session=So(_)??l.session,l.version=U(_.cli_version),l.cwd=he(_.cwd),l.guardian=jd(_),l.legacy=_.history_mode!=="paginated",l.sub=!!_.parent_thread_id&&!l.guardian,l.start=typeof _.subagent_history_start_ordinal==="number"?_.subagent_history_start_ordinal:0,l.sub)l.agent=U(_.agent_path)??U(_.id)},O=(_,A,b)=>{if(b.type==="task_started")l.parentTurn=U(b.turn_attribution?.parent_turn_id);if(b.type!=="task_complete")return;let S=yt(String(b.last_agent_message??""));if(!S||S.outcome==="allow"||!U(S.outcome))return;let{risk_level:w,user_authorization:C,outcome:P}=S;u(_,A,0,{tool_name:"guardian_review",outcome:"blocked",denial_kind:String(P),denial_category:U(w),tool_input:JSON.stringify({parent_turn_id:l.parentTurn,risk_level:w,user_authorization:C,outcome:P}),text:U(S.rationale)})},y=(_,A)=>{let b=_.payload&&typeof _.payload==="object"?_.payload:{};if(_.type==="turn_context")l.cwd=he(b.cwd)??l.cwd;if(_.type==="turn_context"||b.type==="task_started")l.turn=U(b.turn_id)??l.turn;if(l.guardian)return _.type==="event_msg"?O(_,A,b):void 0;if(_.type==="event_msg"&&b.type==="item_completed"&&b.item){let S=ho(b.item,l.sub);if(S)u(_,A,0,S)}else if(_.type==="event_msg"&&b.type==="turn_aborted")p(U(b.turn_id),U(b.reason)??"interrupted");else if(_.type==="response_item"&&l.legacy&&b.type==="function_call"&&Dd.has(b.name)){let S=yt(String(b.arguments??""))??{},w=S.command??S.cmd;g(_,A,b,u(_,A,0,{...mt(Array.isArray(w)?w.map(String):typeof w==="string"?[w]:[]),outcome:"unknown"}))}else if(_.type==="response_item")g(_,A,b)},v=0;for(let _ of a.text.split(`
179
+ `)){v++;let A=_.endsWith("\r")?_.slice(0,-1):_;if(!A.trim())continue;i.lines++;let b=yt(A);if(!b){i.malformed++;continue}if(l.ts=U(b.timestamp)??l.ts,b.type==="session_meta"){if(!c)m(b.payload??{});continue}if(typeof b.ordinal==="number"&&b.ordinal<l.start)continue;if(!qd.has(b.type))o.set(String(b.type),(o.get(String(b.type))??0)+1);y(b,v)}return i.unknown_types=Object.fromEntries(o),{events:r,stats:i,sha256:a.raw?wo("sha256").update(a.raw).digest("hex"):void 0}}var Eo=(e)=>Md(e,gt);var ko={agent:"codex",parserVersion:"codex/v3",defaultRoot:()=>process.env.CODEX_HOME||Ud(Fd(),".codex"),discover:po,parseFile:Eo,groupKey:(e)=>vo(e)};var Wd={agent:"claude_code",parserVersion:"claude-code/v2",defaultRoot:()=>Vd(Bd(),".claude"),discover:uo,parseFile:oo,groupKey:(e)=>/^(.*)\/subagents\/[^/]+$/.exec(e)?.[1]??e.replace(/\.(?:jsonl|orphaned-)[^/]*$/,"")},Ke={claude_code:Wd,codex:ko,antigravity:co};import{createHash as oE}from"node:crypto";import{readdirSync as aE,readFileSync as lE}from"node:fs";import{join as kc}from"node:path";import{fileURLToPath as cE}from"node:url";var Hd=(e)=>e.replace(/['"]|\\(?=\w)/g,""),Bs=null,Vs;function Ao(e){if(e!==Bs){Bs=e;let t=e.command_line;Vs=typeof t==="string"?Hd(t):void 0}return Vs}function Co(){Bs=null,Vs=void 0}function Kd(e){let t=[],n=[],s="",i="",r="",o=!1,a=()=>{if(s)n.push(s),o||=hn(s)==="shell"||hn(s)==="pwsh";s=""},l=()=>{if(a(),n.length)t.push(n);n=[],o=!1};for(let c=0;c<e.length;c++){let u=e[c],f=e[c+1];if(i)if(u===i)i="";else if(i==='"'&&u==="\\"&&f==='"')c++;else s+=u;else if(u===r)r="";else if(u==="'"||u==='"'){let d=s?"":n[n.length-1]??"";if(!r&&(d==="eval"||o&&/^-[a-z]*c$|^-command$/i.test(d)))r=u;else i=u}else if(u==="\\"&&f===`
180
+ `)c++;else if(u===" "||u==="\t")a();else if(u===">"||u==="&"&&f===">"){a(),n.push(">");while(e[c+1]===">"||e[c+1]==="&")c++}else if(u==="<")if(a(),f!=="<"&&f!=="(")n.push("<");else for(l();e[c+1]==="<";)c++;else if(u==="("&&/[\w.]$/.test(s))s+=u;else if(";|&\n\r()`".includes(u))l();else s+=u}return l(),t}var To=new Set(["curl","wget","iwr","invoke-webrequest","irm","invoke-restmethod","certutil"]),Ws=new Map([["shell",/^-[a-zA-Z]*c/],["python",/^-[a-zA-Z]*[cm]/],["perl",/^-[a-zA-Z]*[eE]/],["ruby",/^-[a-zA-Z]*e/],["node",/^-[a-zA-Z]*[ep]/],["php",/^-[a-zA-Z]*r/]]),Ro=new Map([["timeout",/^-[sk]$/],["nice",/^-n$/],["stdbuf",/^-[ioe]$/],["xargs",/^-[IdnPLsEa]$/]]),Jd=new Map([...[...To].map((e)=>[e,e]),...["sh","bash","zsh","dash","ksh","fish"].map((e)=>[e,"shell"]),...["perl","ruby","node","php"].map((e)=>[e,e]),...["pwsh","powershell"].map((e)=>[e,"pwsh"]),["source","source"],[".","source"],...["sudo","doas","env","eval","nohup","exec","time","command","builtin","then","do","else","if","!","{",...Ro.keys()].map((e)=>[e,"prefix"])]),pn=(e)=>e.slice(e.lastIndexOf("/")+1);function hn(e){let t=e.toLowerCase().replace(/\.exe$/,"");for(let n of[pn(t.replaceAll("\\","/")),pn(t.replace(/\\(?=\w)/g,""))]){let s=Jd.get(n)??(/^python[0-9.]*$/.test(n)?"python":"");if(s)return s}return""}function dn(e){let t=e.replaceAll("\\","/");while(t.startsWith("./"))t=t.slice(2);return t}function Oo(e){let t=e.split(/[?#]/,1)[0],n=t.includes("://")?t.slice(t.indexOf("://")+3):t;return n.includes("/")?pn(n):""}function xo(e,t,n,s,i,r=""){let o={vals:[],flag:!1,pos:[]};for(let a=0;a<e.length;a++){let l=e[a];if(l.startsWith("--")){let c=l.indexOf("="),u=c<0?l:l.slice(0,c);if(u===i)o.vals.push(c<0?e[++a]??"":l.slice(c+1));else if(r&&u.startsWith(r))o.flag=!0}else if(l.startsWith("-")&&l.length>1){for(let c=1;c<l.length;c++)if(l[c]===s)o.flag=!0;else if(t.includes(l[c])){let u=c+1<l.length?l.slice(c+1):e[++a]??"";if(l[c]===n)o.vals.push(u);break}}else o.pos.push(l)}return o}function Gd(e,t){let n=[],s=t.findIndex((i)=>/^-outfile(:|$)/i.test(i));if(s>=0)n.push(t[s].length>8?t[s].slice(9):t[s+1]??"");if(e==="curl"){let i=t.findIndex((l)=>/^--output-dir(=|$)/.test(l)),r=i<0?"":t[i].length>12?t[i].slice(13):t.splice(i+1,1)[0]??"",o=xo(t,"AbcCdDeEFHKmoPQrTuUwxXyYz","o","O","--output","--remote-name"),a=(l)=>r&&l&&l!=="-"&&!l.startsWith("/")?`${r.replace(/\/+$/,"")}/${l}`:l;n.push(...[...o.vals,...o.flag?o.pos.map(Oo):[]].map(a))}else if(e==="wget"){let i=xo(t,"aABDeiIlOoPQRtTUwX","O","","--output-document");n.push(...i.vals.length?i.vals:i.pos.map(Oo))}else if(e==="certutil"&&t.some((i)=>/^[-/]urlcache$/i.test(i))){let i=t.filter((r)=>!/^[-/]/.test(r));if(i.length>=2)n.push(i[i.length-1])}return n}var Yd=new Set(["-executionpolicy","-ep","-ex","-exec","-windowstyle","-w","-workingdirectory","-wd"]);function zd(e,t){if(e==="source")return t[0];let n=Ws.get(e);if(n)for(let s of t){if(n.test(s)||s==="-"||e==="shell"&&/^-[a-zA-Z]*s/.test(s))return;if(!s.startsWith("-")&&!s.startsWith("+"))return s}if(e==="pwsh")for(let s=0;s<t.length;s++){let i=t[s].toLowerCase();if(i==="-file"||i==="-f")return t[s+1];if(Yd.has(i))s++;else if(!i.startsWith("-"))return t[s];else if(/^-(c|command|e|ec|enc|encodedcommand)$/.test(i))return}return}function Xd(e){let t=0;while(t<e.length){let n=e[t],s=hn(n);if(/^\w+=/.test(n))t++;else if(s==="prefix"){let i=pn(n.toLowerCase()),r=Ro.get(i)??/^-[ugCD]$/;for(t++;e[t]?.startsWith("-");)t+=r.test(e[t])?2:1;if(i==="timeout")t++}else if(s==="shell"){let i=Ws.get("shell"),r=t+1;while(e[r]?.startsWith("-")&&!i.test(e[r]))r++;if(!i.test(e[r]??""))return t;t=r+1}else return t}return t}function $o(e){let t=new Set;for(let n of Kd(e)){let s=Xd(n);if(s>=n.length)continue;let i=[],r=[],o;for(let u=s+1;u<n.length;u++){let f=n[u];if(f===">"||f==="<"){let d=n[++u];if(f===">"&&d)r.push(d);else o=d}else i.push(f)}let a=n[s],l=hn(a),c=zd(l,i)??(Ws.has(l)?o:void 0);if(t.has(dn(a))||c!==void 0&&t.has(dn(c)))return!0;if(To.has(l)){for(let u of[...Gd(l,i),...r])if(dn(u)&&u!=="-")t.add(dn(u))}}return!1}class E extends Error{reason;constructor(e,t){super(t);this.reason=e}}var Qd={id:1,schema_version:1,agent:1,agent_version:1,session_id:1,parent_session_id:1,agent_id:1,parent_tool_use_id:1,project_path:1,ts:1,seq:1,category:1,tool_name:1,command_line:1,target_path:1,url:1,domain:1,mcp_server:1,mcp_tool:1,outcome:1,permission_mode:1,prompt_source:1,entrypoint:1,attribution:1,denial_kind:1,denial_category:1,secret_kinds:1,result_secret_kinds:1,secret_fps:1,text_excerpt:1,raw_ref:1,content:1,tool_input:1,tool_response:1,text:1},gn="command_line_unquoted",wt=new Map([["target_outside_project",{reads:["target_path","project_path"],test:(e)=>np(e)}],["download_executed",{reads:["command_line"],test:(e)=>typeof e.command_line==="string"&&$o(e.command_line)}]]),Zd=new Set([...Object.keys(Qd),...wt.keys(),gn]),ep=new Map([["CommandLine","command_line"],["TargetFilename","target_path"],["CurrentDirectory","project_path"]]),No=new Set(["secret_kinds","result_secret_kinds","secret_fps"]),tp=new Set(["seq"]),qo=(e)=>e===gn||wt.has(e),Gs=(e)=>e===gn?Ao:(t)=>t[e],Lo=(e)=>e===gn?"command_line":e;function np(e){let{target_path:t,project_path:n}=e;return typeof t==="string"&&typeof n==="string"&&t!==""&&n!==""&&!Ur(t,n)}function mn(e){let t=ep.get(e)??e;if(!Zd.has(t))throw new E("unknown-field",`unknown field '${e}'`);return t}var Ks=new Map;function Js(e){let t=Ks.get(e);if(!t)Ks.set(e,t={ev:null,val:""});return t}function Do(e,t,n){if(e.ev===t)return e.val;return e.ev=t,e.val=n.toLowerCase()}function jo(){for(let e of Ks.values())e.ev=null,e.val="";Co()}var Ce=-1,Mo=-2,Fo=-3,sp=[45,47,8211,8212,8213],Io=(e)=>e!==void 0&&/\w/.test(e);function ip(e,t){let n=[];for(let s=0;s<e.length;s++){let i=e[s],r=e[s+1];if(i==="\\"&&(r==="*"||r==="?"||r==="\\"))n.push(e.charCodeAt(++s));else if(i==="*")n.push(Ce);else if(i==="?")n.push(Mo);else if(t&&(i==="-"||i==="/")&&!Io(e[s-1])&&Io(r))n.push(Fo);else n.push(e.charCodeAt(s))}return n}function rp(e,t){let n=0,s=0,i=-1,r=0;while(n<e.length){let o=e.charCodeAt(n),a=t[s];if(a===Ce)i=s++,r=n;else if(a===Mo||a===o||a===Fo&&sp.includes(o))n++,s++;else if(i>=0)s=i+1,n=++r;else return!1}while(t[s]===Ce)s++;return s===t.length}function Uo(e,t,n,s){let i=ip(n?e:e.toLowerCase(),s);if(t==="contains"||t==="endswith")i.unshift(Ce);if(t==="contains"||t==="startswith")i.push(Ce);let r=0,o=i.length;while(r<o&&i[r]===Ce)r++;while(o>r&&i[o-1]===Ce)o--;let a=i.slice(r,o),l=r>0,c=o<i.length;return{codes:i,kind:l&&c?"includes":l?"endsWith":c?"startsWith":"equals",lit:a.some((f)=>f<0)?null:String.fromCharCode(...a)}}function Bo(e){let t=e.lit;if(t===null)return(n)=>rp(n,e.codes);if(e.kind==="includes")return(n)=>n.includes(t);if(e.kind==="endsWith")return(n)=>n.endsWith(t);if(e.kind==="startsWith")return(n)=>n.startsWith(t);return(n)=>n===t}var op=(e,t,n,s)=>Bo(Uo(e,t,n,s)),ap=4,lp=(e)=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),cp={includes:["",""],startsWith:["^",""],endsWith:["","$"]};function up(e,t){let[n,s]=cp[e],i=new RegExp(`${n}(?:${t.map(lp).join("|")})${s}`);return(r)=>i.test(r)}function fp(e){let t=new Map;for(let i of e)if(i.lit!==null&&i.kind!=="equals")t.set(i.kind,[...t.get(i.kind)??[],i.lit]);let n=[],s=new Set;for(let[i,r]of t){if(r.length<ap)continue;s.add(i),n.push(up(i,r))}for(let i of e)if(i.lit===null||!s.has(i.kind))n.push(Bo(i));return n}function dp(e){let t=!1;for(let n=0;n<e.length;n++){let s=e[n];if(s==="\\"){let i=e[++n]??"";if(i==="k"||!t&&/[1-9]/.test(i))throw new E("regex-backreference",`backreference in /${e}/`);if(/[a-zA-Z]/.test(i)&&!"dDwWsSbBnrtfvcxu".includes(i))throw new E("bad-regex",`unsupported escape \\${i} in /${e}/`);if((i==="u"||i==="x")&&e[n+1]==="{")throw new E("bad-regex",`\\${i}{...} in /${e}/: write a character above U+FFFF as a surrogate pair`)}else if(t){if(s==="]")t=!1;else if(s==="["&&e[n+1]===":")throw new E("bad-regex",`POSIX class in /${e}/`);else if(s>="\uD800"&&s<="\uDFFF")throw new E("bad-regex",`character above U+FFFF inside [...] in /${e}/: it would match half a character`)}else if(s==="[")t=!0;else if(s==="("&&/^\(\?<?[=!]/.test(e.slice(n,n+4)))throw new E("regex-lookaround",`lookaround in /${e}/`)}}var Po=8192;function pp(e,t){if(typeof e!=="string")throw new E("bad-value","re needs a string pattern");dp(e);try{let n=new RegExp(e,t);return(s)=>n.test(s.length>Po?s.slice(0,Po):s)}catch(n){throw new E("bad-regex",`${n.message} (inline flags: use |re|i, |re|m, |re|s)`)}}function Hs(e,t,n){let s=Js(e),i=Gs(e);return(r)=>{let o=i(r);if(typeof o==="string")return n(t?o:Do(s,r,o));if(typeof o==="number")return n(String(o));if(Array.isArray(o))return o.some((a)=>n(t?a:a.toLowerCase()));return!1}}function hp(e,t,n){let s=Js(e),i=Js(t),r=(o,a,l)=>{let c=Gs(l)(a);return typeof c==="string"?Do(o,a,c):typeof c==="number"?String(c):null};return(o)=>{let a=r(s,o,e),l=r(i,o,t);if(a===null||l===null)return!1;return n==="startswith"?a.startsWith(l):n==="endswith"?a.endsWith(l):a===l}}function me(e){if(e.length===1)return e[0];return(t)=>{for(let n of e)if(n(t))return!0;return!1}}function bt(e){if(e.length===1)return e[0];return(t)=>{for(let n of e)if(!n(t))return!1;return!0}}var Vo={gt:(e,t)=>e>t,gte:(e,t)=>e>=t,lt:(e,t)=>e<t,lte:(e,t)=>e<=t};function mp(e,t){let n={shape:"exact",re:!1,flags:"",cased:!1,all:!1,exists:!1,cmp:"",fieldref:!1,windash:!1},s=(i)=>new E("bad-modifier-combo",`${e}|${t.join("|")}: ${i}`);if(new Set(t).size!==t.length)throw s("repeated modifier");for(let i of t)if(i==="contains"||i==="startswith"||i==="endswith"){if(n.shape!=="exact")throw s("only one of contains, startswith, endswith");n.shape=i}else if(i==="re")n.re=!0;else if(i==="i"||i==="m"||i==="s")n.flags+=i;else if(i==="cased")n.cased=!0;else if(i==="all")n.all=!0;else if(i==="exists")n.exists=!0;else if(Object.hasOwn(Vo,i))n.cmp=i;else if(i==="fieldref")n.fieldref=!0;else if(i==="windash")n.windash=!0;else if(i==="expand")throw new E("placeholder",`${e}: placeholders are not supported`);else throw new E("unsupported-modifier",`${e}: modifier '${i}' is not supported`);if((n.exists||n.cmp)&&t.length>1)throw s(`${n.cmp||"exists"} stands alone`);if(n.flags&&!n.re)throw s("regex flags need re");if(n.re&&(n.shape!=="exact"||n.cased||n.windash))throw s("re takes only all and the flags i, m, s");if(n.fieldref&&(n.shape==="contains"||n.cased||n.all||n.windash))throw s("fieldref takes only startswith or endswith");return n}function gp(e,t,n,s){if(t.length>0||typeof n!=="boolean")throw new E("bad-value",`${e} takes true or false and no modifiers`);let{reads:i,test:r}=wt.get(e);for(let o of i)s.add(o);return(o)=>r(o)===n}function Wo(e,t,n){let[s="",...i]=e.split("|");if(s==="")throw new E("keyword-list",`'${e}' names no field: keyword searches are not supported`);let r=mn(s);if(wt.has(r))return gp(r,i,t,n);n.add(Lo(r));let o=Gs(r),a=mp(r,i),l=Array.isArray(t)?t:[t];if(l.length===0)throw new E("bad-value",`${r}: empty value list`);if(a.exists){if(typeof t!=="boolean")throw new E("bad-value",`${r}|exists needs true or false`);return t?(u)=>o(u)!=null:(u)=>o(u)==null}if(r==="raw_ref")throw new E("bad-value","raw_ref is an object: only |exists applies");if(t===null){if(i.length>0)throw new E("bad-value",`${r}: null takes no modifiers`);return(u)=>o(u)==null}if(l.includes(null))throw new E("null-in-list",`${r}: null must be its own selection`);if(a.all&&l.length<2)throw new E("bad-modifier-combo",`${r}|all needs at least two values`);for(let u of l)if(typeof u!=="string"&&typeof u!=="number")throw new E("bad-value",`${r}: ${JSON.stringify(u)} is not a string or number`);if(a.cmp){if(!tp.has(r))throw new E("bad-value",`${r}|${a.cmp}: field is not numeric`);let u=Vo[a.cmp];return me(l.map((f)=>{if(typeof f!=="number")throw new E("bad-value",`${r}|${a.cmp} needs a number`);return(d)=>typeof d[r]==="number"&&u(d[r],f)}))}if(a.fieldref){if(No.has(r))throw new E("bad-modifier-combo",`${r}|fieldref: not a scalar field`);return me(l.map((u)=>{let f=mn(String(u));if(No.has(f)||f==="raw_ref"||wt.has(f))throw new E("bad-modifier-combo",`${r}|fieldref: ${f} is not a scalar field`);return n.add(Lo(f)),hp(r,f,a.shape)}))}if(!a.re&&!a.all){let u=fp(l.map((f)=>Uo(String(f),a.shape,a.cased,a.windash)));return Hs(r,a.cased,u.length===1?u[0]:(f)=>u.some((d)=>d(f)))}let c=l.map((u)=>a.re?Hs(r,!0,pp(u,a.flags)):Hs(r,a.cased,op(String(u),a.shape,a.cased,a.windash)));return a.all?bt(c):me(c)}function Ys(e,t=[e]){return{at:e,events:t,seq:Number(e.seq),t:Date.parse(String(e.ts))}}function Je(e,t){let n=e.session_id,s=t.session_id;if(n!==s)return n<s?-1:1;let i=e.agent_id??"",r=t.agent_id??"";if(i!==r)return i<r?-1:1;return e.seq-t.seq}var yp={s:1000,m:60000,h:3600000,d:86400000},wp=new Set(["event_count","temporal","temporal_ordered"]),bp=new Set(["type","rules","group-by","timespan","condition","generate"]),Ho={gt:(e,t)=>e>t,gte:(e,t)=>e>=t,lt:(e,t)=>e<t,lte:(e,t)=>e<=t,eq:(e,t)=>e===t,neq:(e,t)=>e!==t},Ko=(e)=>{let t=typeof e==="string"?[e]:e;return Array.isArray(t)&&t.length>0&&t.every((n)=>typeof n==="string")?t:null};function _p(e){let t=typeof e==="object"&&e!==null?Object.entries(e):[];if(t.length===0)throw new E("bad-correlation","event_count needs a condition such as { gte: 5 }");let n=t.map(([s,i])=>{if(s==="field")throw new E("unsupported-correlation-type","condition.field belongs to value_count");let r=Object.hasOwn(Ho,s)?Ho[s]:void 0;if(!r||typeof i!=="number")throw new E("bad-correlation",`bad condition ${s}: ${String(i)}`);return(o)=>r(o,i)});return(s)=>n.every((i)=>i(s))}function Sp(e){let t=Ko(e);if(!t)throw new E("bad-correlation","group-by is required");let n=t.map(mn);if(n.some(qo))throw new E("bad-correlation","a computed field cannot be a group-by key");if(!n.includes("session_id"))throw new E("unsupported-group-by","group-by must include session_id: a group never spans sessions");return n}function Jo(e,t){let n=e.correlation;if(typeof n!=="object"||n===null||Array.isArray(n))throw new E("bad-correlation","correlation must be a map");if("logsource"in e||"detection"in e)throw new E("mixed-document","a document is a detection or a correlation, not both");let s=n;if("aliases"in s)throw new E("aliases-unsupported","correlation aliases are not supported");let i=s.type;if(typeof i!=="string"||!wp.has(i))throw new E("unsupported-correlation-type",`correlation type '${String(i)}' is not supported`);let r=Object.keys(s).find((f)=>!bp.has(f));if(r)throw new E("bad-correlation",`unknown correlation key '${r}'`);let o=Ko(s.rules);if(!o)throw new E("bad-correlation","rules must name at least one rule");let a=/^([1-9]\d*)([smhd])$/.exec(String(s.timespan));if(!a)throw new E("bad-correlation",`bad timespan '${String(s.timespan)}'`);if(i!=="event_count"&&s.condition!=null){let{gte:f,...d}=s.condition;if(f!==o.length||Object.keys(d).length>0)throw new E("bad-correlation",`${i} supports only condition { gte: ${o.length} }`)}let l=e["x-retrohound"]?.max_events_between;if(l!==void 0&&!(Number.isInteger(l)&&l>=0))throw new E("bad-x-retrohound","max_events_between must be a non-negative integer");let c=Sp(s["group-by"]);if(l!==void 0&&!c.includes("agent_id"))throw new E("max-events-needs-agent-id","max_events_between needs agent_id in group-by: seq is not comparable across streams");let u=s.generate??e.generate??!1;if(typeof u!=="boolean")throw new E("bad-correlation","generate must be true or false");return{...t,kind:"correlation",type:i,refs:o,rules:[],groupBy:c,timespanMs:Number(a[1])*yp[a[2]],maxEventsBetween:l,count:i==="event_count"?_p(s.condition):void 0,generate:u}}function vp(e){let t=new Set,n=(s)=>{if(s===e)return!0;if(s.kind!=="correlation"||t.has(s))return!1;return t.add(s),s.rules.some(n)};return e.rules.some(n)}function Go(e,t,n){let s=new Set,i=new Set;for(let l of e){if(l.kind==="detection"){i.add(l);continue}let c=l.refs.find((u)=>!t.has(u));if(c!==void 0)n(l,new E("unresolved-reference",`no loaded rule has the name or id '${c}'`));else l.rules=l.refs.map((u)=>t.get(u)),s.add(l)}for(let l=!0;l;){l=!1;for(let c of s)if(c.rules.every((u)=>i.has(u)))i.add(c),s.delete(c),l=!0}for(let l of s)if(vp(l))n(l,new E("correlation-cycle","this correlation references itself through its rules"));else n(l,new E("unresolved-reference","this correlation references a rule that was rejected"));let r=e.filter((l)=>i.has(l)),o=new Set,a=new Set;for(let l of r){if(l.kind!=="correlation")continue;for(let c of l.rules)if(a.add(c),l.generate)o.add(c)}for(let l of r)l.silenced=a.has(l)&&!o.has(l);return r}function zs(e,t,n){if(!(Math.abs(n.t-t.t)<=e.timespanMs))return!1;return e.maxEventsBetween===void 0||Math.abs(n.seq-t.seq)<=e.maxEventsBetween}function Ep(e,t,n){return n.t-t.t>e.timespanMs||e.maxEventsBetween!==void 0&&n.seq-t.seq>e.maxEventsBetween}function kp(e,t){let n=0,s=e.length;while(n<s){let i=n+s>>1;if(e[i].seq<t)n=i+1;else s=i}return n}function Xs(e){let t=[...new Set(e.flatMap((n)=>n.events))].sort(Je);return Ys(e.reduce((n,s)=>s.seq>=n.seq?s:n).at,t)}function Op(e,t){let n=[...new Set(t.flat())].sort((i,r)=>i.seq-r.seq),s=0;for(let i=0;i<n.length;i++){s=Math.max(s,i);while(s+1<n.length&&zs(e,n[i],n[s+1]))s++;if(e.count(s-i+1))return[Xs(n.slice(i,s+1))]}return[]}function xp(e,t){let n=[];for(let s of t[0]){let i=[s];for(let r of t.slice(1)){let o=i[i.length-1],a;for(let l=kp(r,o.seq);l<r.length&&!a;l++){let c=r[l];if(Ep(e,s,c))break;if(zs(e,s,c))a=c}if(!a)break;i.push(a)}if(i.length===t.length)n.push(Xs(i))}return n}function Ap(e,t){let n=t.flatMap((a,l)=>a.map((c)=>({o:c,step:l}))).sort((a,l)=>a.o.seq-l.o.seq),s=t.map(()=>-1),i=[],r=0,o=0;return n.forEach(({o:a,step:l},c)=>{s[l]=c;while(r<c&&!zs(e,n[r].o,a))r++;if(s.some((u)=>u<r))return;for(o=Math.max(o,r);o<=c;o++){let u=n[o];if(u.step===0)i.push(Xs([u.o,...s.slice(1).map((f)=>n[f].o)]))}}),i}function Cp(e){let t=[...new Set(e.flat().map((i)=>i.at))],n=(i)=>Number.isNaN(Date.parse(String(i.ts)))?-1/0:Date.parse(String(i.ts));t.sort((i,r)=>(n(i)===n(r)?0:n(i)<n(r)?-1:1)||Je(i,r));let s=new Map(t.map((i,r)=>[i,r]));return e.map((i)=>i.map((r)=>({...r,seq:s.get(r.at)})))}var Tp={event_count:Op,temporal_ordered:xp,temporal:Ap};function Yo(e,t){let n=new Map;e.rules.forEach((a,l)=>{for(let c of t.get(a)){let u=JSON.stringify(e.groupBy.map((d)=>c.at[d]??null)),f=n.get(u);if(!f)n.set(u,f=e.rules.map(()=>[]));f[l].push(c)}});let s=Tp[e.type],i=[],r=!e.groupBy.includes("agent_id");for(let a of n.values()){if(r)a=Cp(a);for(let l of a)l.sort((c,u)=>c.seq-u.seq);if(e.type==="event_count"||a.every((l)=>l.length>0))i.push(...s(e,a))}if(i.sort((a,l)=>Je(a.events[0],l.events[0])),e.type!=="event_count")return i;let o=new Set;return i.filter((a)=>{let l=a.events[0].session_id;if(o.has(l))return!1;return o.add(l),!0})}function Rp(e){let t=new Set,n=(s)=>{if(t.has(s))return;if(s.kind==="correlation")s.rules.forEach(n);t.add(s)};return e.forEach(n),[...t]}function $p(e){let t=new Map;for(let n of e)if(n.category&&!t.has(n.category))t.set(n.category,e.filter((s)=>!s.category||s.category===n.category));return t}function Np(e){for(let t=1;t<e.length;t++)if(Je(e[t-1],e[t])>0)return[...e].sort((n,s)=>Je(n,s));return e}function le(e,t){let n=Rp(e),s=n.filter((l)=>l.kind==="detection"),i=n.filter((l)=>l.kind==="correlation"),r=$p(s),o=s.filter((l)=>!l.category),a=new Map(s.map((l)=>[l,[]]));for(let l of Np(t)){let c=l,u=null;for(let f of r.get(c.category)??o){if(f.service!==void 0&&c.agent!==f.service)continue;if(f.matches(c))a.get(f).push(u??=Ys(c))}}jo();for(let l of i)a.set(l,Yo(l,a));return e.filter((l)=>!l.silenced).flatMap((l)=>a.get(l).map((c)=>({rule:l,events:[...c.events]})))}var WS=zi(),HS=qt(),KS=Ii(),lr=Dt(),JS=vt(),ke=R(),GS=be(),YS=j(),zS=Se(),XS=ve(),HA=ts(),QS=rr(),ZS=or(),ev=ar(),rs=sc(),ic=_t();var tv=WS.Composer,nv=HS.Document,sv=KS.Schema,{YAMLError:iv,YAMLParseError:rv,YAMLWarning:ov}=lr,av=JS.Alias,{isAlias:lv,isCollection:cv,isDocument:uv,isMap:fv,isNode:dv,isPair:pv,isScalar:hv,isSeq:mv}=ke,gv=GS.Pair,yv=YS.Scalar,wv=zS.YAMLMap,bv=XS.YAMLSeq;var _v=QS.Lexer,Sv=ZS.LineCounter,vv=ev.Parser,{parse:Ev,parseAllDocuments:qe,parseDocument:cr,stringify:kv}=rs,{visit:Ov,visitAsync:xv}=ic;var L=["informational","low","medium","high","critical"],rc=["tool_call","process_creation","file_access","file_event","web_request","mcp","instruction_load","config_change","user_prompt","assistant_message"];var oc=new Set(["and","or","not","of","them"]),ac=/^[A-Za-z0-9_*-]+$/;function Av(e){if(e.includes("|"))throw new E("condition-aggregation",`'${e}': '|' aggregation is obsolete, use a correlation rule`);let t=e.match(/[()]|[A-Za-z0-9_*-]+|\S/g)??[],n=t.find((s)=>s!=="("&&s!==")"&&!ac.test(s));if(n)throw new E("condition-syntax",`'${e}': unexpected '${n}'`);return t}function Cv(e,t,n){let s=new RegExp(`^${t==="them"?".*":t.replaceAll("*",".*")}$`),i=n.filter((r)=>s.test(r)&&(t.startsWith("_")||!r.startsWith("_")));if(i.length===0)throw new E("condition-no-selection",`'${e}': '${t}' matches no selection`);return i}function lc(e,t){let n=Av(e),s=(u)=>new E("condition-syntax",`'${e}': ${u}`),i=0;function r(){let u=o();while(n[i]==="or"){i++;let f=u,d=o();u=(h)=>f(h)||d(h)}return u}function o(){let u=a();while(n[i]==="and"){i++;let f=u,d=a();u=(h)=>f(h)&&d(h)}return u}function a(){if(n[i]!=="not")return l();i++;let u=a();return(f)=>!u(f)}function l(){let u=n[i++];if(u===void 0)throw s("unexpected end");if(u==="("){let d=r();if(n[i++]!==")")throw s("missing ')'");return d}if((u==="1"||u==="any"||u==="all")&&n[i]==="of"){let d=n[i+1];if(i+=2,d===void 0||!ac.test(d)||oc.has(d)&&d!=="them")throw s("'of' needs a pattern or 'them'");let h=Cv(e,d,[...t.keys()]).map((g)=>t.get(g));return u==="all"?bt(h):me(h)}if(u===")"||oc.has(u))throw s(`unexpected '${u}'`);if(u.includes("*"))throw s(`pattern '${u}' needs '1 of' or 'all of'`);let f=t.get(u);if(!f)throw new E("condition-unknown-selection",`'${e}': no selection named '${u}'`);return f}let c=r();if(i<n.length)throw s(`unexpected '${n[i]}'`);return c}var Tv=new Set(["claude_code","codex","antigravity","gemini_cli","cursor"]);function Oe(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}function cc(e,t){let n=e[t];if(n==null)return[];if(Array.isArray(n)&&n.every((s)=>typeof s==="string"))return n;throw new E("bad-metadata",`${t} must be a list of strings`)}function Vt(e,t){let n=e[t];if(n==null)return;if(typeof n!=="string")throw new E("bad-metadata",`${t} must be a string`);return n}function fc(e,t,n){let s=e.title;if(typeof s!=="string"||s==="")throw new E("missing-title","title is required");let i=e.level??"medium";if(!L.includes(i))throw new E("bad-metadata",`unknown level '${String(i)}'`);let r=e["x-retrohound"]??{};if(!Oe(r))throw new E("bad-x-retrohound","x-retrohound must be a map");let o=Object.keys(r).find((u)=>u!=="lane"&&!(u==="max_events_between"&&n));if(o)throw new E("bad-x-retrohound",`x-retrohound.${o} is not valid here`);let a=r.lane??"hunt";if(a!=="hunt"&&a!=="enforce")throw new E("bad-x-retrohound",`unknown lane '${String(a)}'`);let l=Vt(e,"id"),c=Vt(e,"name");return{id:l??c??s,name:c,title:s,author:Vt(e,"author"),level:i,lane:a,status:Vt(e,"status"),description:Vt(e,"description"),tags:cc(e,"tags"),falsepositives:cc(e,"falsepositives"),...t,silenced:!1}}function Rv(e){let t=e.logsource;if(!Oe(t))throw new E("missing-logsource","logsource is required");if(t.product!=="ai_coding_agent")throw new E("unknown-product",`unknown product '${String(t.product)}'`);if(t.category!=null&&!rc.includes(t.category))throw new E("unknown-category",`unknown category '${String(t.category)}'`);if(t.service!=null&&!Tv.has(t.service))throw new E("unknown-service",`unknown service '${String(t.service)}'`);return{category:t.category??void 0,service:t.service??void 0}}function uc(e,t,n){let s=Object.entries(e).map(([i,r])=>Wo(i,r,n));if(s.length===0)throw new E("bad-selection",`selection '${t}' is empty`);return bt(s)}function $v(e,t,n){if(Oe(t))return uc(t,e,n);if(!Array.isArray(t)||!t.every(Oe))throw new E("keyword-list",`selection '${e}': keyword searches are not supported`);if(t.length===0)throw new E("bad-selection",`selection '${e}' is empty`);return me(t.map((s)=>uc(s,e,n)))}function Nv(e,t){let n=fc(e,t,!1),s=Rv(e),i=e.detection;if(!Oe(i))throw new E("missing-detection","detection is required");let{condition:r,...o}=i;if("timeframe"in o)throw new E("obsolete-timeframe","detection.timeframe is obsolete, use a correlation rule");let a=Array.isArray(r)?r:[r];if(a.length===0||!a.every((f)=>typeof f==="string"))throw new E("missing-condition","detection.condition is required");let l=new Set,c=new Map(Object.entries(o).map(([f,d])=>[f,$v(f,d,l)])),u=me(a.map((f)=>lc(f,c)));return{...n,kind:"detection",...s,fields:[...l],matches:u}}function Lv(e,t){if(!Oe(e))throw new E("not-a-rule","a rule document must be a map");if("action"in e)throw new E("unsupported-document","rule collections (action:) are not supported");if("filter"in e)throw new E("unsupported-document","Sigma filter documents are not supported");if("correlation"in e)return Jo(e,fc(e,t,!0));return Nv(e,t)}function ur(e){return qe(e).map((t)=>{try{return t.errors.length>0?{error:t.errors[0].message}:{data:t.toJS()}}catch(n){return{error:n.message,reason:"invalid-rule"}}})}function rt(e){let t=[],n=[],s=new Map;for(let{path:r,text:o,docs:a}of e){let l;try{l=a??ur(o)}catch(c){n.push({path:r,doc:0,reason:"yaml-parse",message:c.message});continue}l.forEach((c,u)=>{let f;try{if(c.error!==void 0)throw new E(c.reason??"yaml-parse",c.error);let d=c.data;if(d===null||d===void 0)return;if(Oe(d)&&typeof d.title==="string")f=d.title;let h=Lv(d,{path:r,doc:u}),g=[Oe(d)?d.id:null,h.name].filter((m)=>m!=null),p=g.find((m)=>s.has(m));if(p)throw new E("duplicate-id",`'${p}' is already used by another rule`);for(let m of g)s.set(m,h);t.push(h)}catch(d){if(d instanceof E)n.push({path:r,doc:u,title:f,reason:d.reason,message:d.message});else n.push({path:r,doc:u,title:f,reason:"invalid-rule",message:d.message})}})}return{rules:Go(t,s,(r,o)=>{n.push({path:r.path,doc:r.doc,title:r.title,reason:o.reason,message:o.message})}),rejected:n}}var Iv=500,Wt=["agent_version","parent_session_id","agent_id","parent_tool_use_id","project_path","tool_name","command_line","target_path","url","domain","mcp_server","mcp_tool","outcome","permission_mode","prompt_source","entrypoint","attribution","denial_kind","denial_category","text_excerpt"],Ht=["secret_kinds","result_secret_kinds","secret_fps"],dc=(e)=>x(e);function fe(e){let t={id:x(e.id),schema_version:"0.1",agent:dc(e.agent),session_id:x(e.session_id),ts:x(e.ts),seq:e.seq,category:dc(e.category),raw_ref:{file:x(e.raw_ref.file),line:e.raw_ref.line}},n=t;for(let s of Wt){let i=e[s];if(i!=null)n[s]=x(i)}for(let s of Ht){let i=e[s];if(i?.length)n[s]=i.map(x)}if(t.text_excerpt!==void 0)t.text_excerpt=t.text_excerpt.slice(0,Iv);return t}import{createHash as qv}from"node:crypto";import{chmodSync as hc,closeSync as Dv,mkdirSync as jv,openSync as Mv}from"node:fs";import{homedir as Fv}from"node:os";import{dirname as Uv,join as Bv}from"node:path";var Pv=[`
181
+ CREATE TABLE events (
182
+ id TEXT PRIMARY KEY, -- hash(file, line uuid ?? line_no, sub_index), stable across rewrites (0008)
183
+ source_file TEXT NOT NULL, -- files_indexed.path; raw_file is what the parser reported
184
+ schema_version TEXT NOT NULL,
185
+ agent TEXT NOT NULL,
186
+ agent_version TEXT,
187
+ session_id TEXT NOT NULL,
188
+ parent_session_id TEXT,
189
+ agent_id TEXT,
190
+ parent_tool_use_id TEXT,
191
+ project_path TEXT,
192
+ ts TEXT NOT NULL,
193
+ seq INTEGER NOT NULL, -- line order per file, so not unique per session
194
+ category TEXT NOT NULL,
195
+ tool_name TEXT,
196
+ command_line TEXT,
197
+ target_path TEXT,
198
+ url TEXT,
199
+ domain TEXT,
200
+ mcp_server TEXT,
201
+ mcp_tool TEXT,
202
+ outcome TEXT,
203
+ permission_mode TEXT,
204
+ prompt_source TEXT,
205
+ entrypoint TEXT,
206
+ attribution TEXT,
207
+ denial_kind TEXT,
208
+ denial_category TEXT,
209
+ secret_kinds TEXT, -- JSON array; NULL when absent, never '[]'
210
+ result_secret_kinds TEXT,
211
+ secret_fps TEXT,
212
+ text_excerpt TEXT,
213
+ raw_file TEXT NOT NULL,
214
+ raw_line INTEGER NOT NULL
215
+ );
216
+ CREATE INDEX events_session_seq ON events (session_id, seq);
217
+ CREATE INDEX events_category ON events (category);
218
+ CREATE INDEX events_ts ON events (ts);
219
+ CREATE INDEX events_target_path ON events (target_path);
220
+ CREATE INDEX events_domain ON events (domain);
221
+ CREATE INDEX events_source_file ON events (source_file);
222
+
223
+ CREATE TABLE sessions (
224
+ session_id TEXT PRIMARY KEY,
225
+ agent TEXT NOT NULL,
226
+ project_path TEXT,
227
+ first_ts TEXT NOT NULL,
228
+ last_ts TEXT NOT NULL,
229
+ event_count INTEGER NOT NULL
230
+ );
231
+
232
+ CREATE TABLE files_indexed (
233
+ path TEXT PRIMARY KEY,
234
+ size INTEGER NOT NULL,
235
+ mtime REAL NOT NULL, -- stat mtimeMs, fractional on some filesystems
236
+ parser_version TEXT NOT NULL,
237
+ sha256 TEXT NOT NULL,
238
+ first_seen TEXT NOT NULL,
239
+ last_seen TEXT NOT NULL,
240
+ gone_at TEXT
241
+ );
242
+
243
+ CREATE TABLE findings (
244
+ id TEXT PRIMARY KEY, -- sha256(rule_id + sorted event ids) (0014)
245
+ rule_id TEXT NOT NULL,
246
+ level TEXT NOT NULL,
247
+ ts TEXT NOT NULL,
248
+ session_id TEXT NOT NULL,
249
+ message TEXT NOT NULL,
250
+ events TEXT NOT NULL -- JSON array of masked AgentEvents: evidence that outlives a rebuild of the events table
251
+ );
252
+
253
+ CREATE TABLE rule_runs (
254
+ id INTEGER PRIMARY KEY,
255
+ rule_set_hash TEXT NOT NULL,
256
+ started_at TEXT NOT NULL,
257
+ finished_at TEXT NOT NULL,
258
+ events INTEGER NOT NULL,
259
+ findings INTEGER NOT NULL
260
+ );
261
+ `,`
262
+ DROP INDEX IF EXISTS events_category;
263
+ DROP INDEX IF EXISTS events_ts;
264
+ DROP INDEX IF EXISTS events_target_path;
265
+ DROP INDEX IF EXISTS events_domain;
266
+ `];function pc(e,t=Pv){let n=Number(e.prepare("PRAGMA user_version").get()?.user_version??0);if(n>t.length)throw Error(`index schema version ${n} is newer than this RetroHound supports (${t.length})`);for(let[s,i]of t.entries()){if(s<n)continue;e.exec("BEGIN");try{e.exec(i),e.exec(`PRAGMA user_version = ${s+1}`),e.exec("COMMIT")}catch(r){throw e.exec("ROLLBACK"),r}}}var fr=["source_file","id","schema_version","agent","session_id","ts","seq","category",...Wt,...Ht,"raw_file","raw_line"],yc=`(excluded.source_file <> events.source_file
267
+ AND (excluded.source_file LIKE '%.superseded-%' OR excluded.source_file LIKE '%.orphaned-%'))`,Vv="(events.outcome IS NOT NULL AND events.outcome <> 'unknown')",Wv=(e)=>`${e} = CASE WHEN ${yc} THEN events.${e} ELSE excluded.${e} END`,Hv=`INSERT INTO events (${fr.join(", ")}) VALUES (${fr.map(()=>"?").join(", ")})
268
+ ON CONFLICT(id) DO UPDATE SET ${fr.filter((e)=>e!=="id"&&e!=="outcome").map(Wv).join(", ")},
269
+ outcome = CASE WHEN ${Vv} AND (${yc} OR excluded.outcome IS NULL OR excluded.outcome = 'unknown')
270
+ THEN events.outcome ELSE excluded.outcome END`,mc=`SELECT s.*, NOT EXISTS (
271
+ SELECT 1 FROM events e JOIN files_indexed f ON f.path = e.source_file
272
+ WHERE e.session_id = s.session_id AND f.gone_at IS NULL
273
+ ) AS archived FROM sessions s`,dr=()=>new Date().toISOString(),Kt=(e)=>({...e});function Kv(e,t){return[e,t.id,t.schema_version,t.agent,t.session_id,t.ts,t.seq,t.category,...Wt.map((n)=>t[n]??null),...Ht.map((n)=>t[n]?JSON.stringify(t[n]):null),t.raw_ref.file,t.raw_ref.line]}function Jv(e){let t={id:e.id,schema_version:e.schema_version,agent:e.agent,session_id:e.session_id,ts:e.ts,seq:Number(e.seq),category:e.category,raw_ref:{file:e.raw_file,line:Number(e.raw_line)}},n=t;for(let s of Wt)if(e[s]!==null)n[s]=e[s];for(let s of Ht)if(e[s]!==null)n[s]=JSON.parse(e[s]);return t}function gc(e){return{...Kt(e),archived:Boolean(e.archived)}}function Gv(e){return{...Kt(e),events:JSON.parse(e.events)}}function K(){return Bv(Fv(),".retrohound","index.db")}function os(e,t){return qv("sha256").update(e+[...t].sort().join("")).digest("hex")}function Yv(e){let t=Uv(e);jv(t,{recursive:!0,mode:448}),Dv(Mv(e,"a",384));try{if(e===K())hc(t,448);hc(e,384)}catch{}}function ot(e=K()){return ht(e,{readonly:!0})}function at(e=K()){Yv(e);let t=ht(e);try{t.exec("PRAGMA journal_mode = WAL; PRAGMA synchronous = NORMAL"),pc(t)}catch(a){throw t.close(),a}let n={getFile:t.prepare("SELECT * FROM files_indexed WHERE path = ?"),listFiles:t.prepare("SELECT * FROM files_indexed ORDER BY path"),upsertFile:t.prepare(`INSERT INTO files_indexed
274
+ (path, size, mtime, parser_version, sha256, first_seen, last_seen, gone_at) VALUES (?, ?, ?, ?, ?, ?, ?, NULL)
275
+ ON CONFLICT(path) DO UPDATE SET size = excluded.size, mtime = excluded.mtime,
276
+ parser_version = excluded.parser_version, sha256 = excluded.sha256, last_seen = excluded.last_seen, gone_at = NULL`),touchFile:t.prepare("UPDATE files_indexed SET last_seen = ?, gone_at = NULL WHERE path = ?"),markGone:t.prepare("UPDATE files_indexed SET gone_at = ? WHERE path = ? AND gone_at IS NULL"),upsertEvent:t.prepare(Hv),fileSessions:t.prepare("SELECT DISTINCT session_id FROM events WHERE source_file = ?"),deleteEvents:t.prepare("DELETE FROM events WHERE source_file = ?"),dropEmptySession:t.prepare(`DELETE FROM sessions
277
+ WHERE session_id = ? AND NOT EXISTS (SELECT 1 FROM events WHERE session_id = ?)`),refreshSession:t.prepare(`INSERT INTO sessions (session_id, agent, project_path, first_ts, last_ts, event_count)
278
+ SELECT session_id, min(agent),
279
+ (SELECT p.project_path FROM events p WHERE p.session_id = e.session_id AND p.project_path IS NOT NULL
280
+ ORDER BY p.ts, p.seq LIMIT 1),
281
+ min(ts), max(ts), count(*)
282
+ FROM events e WHERE session_id = ? GROUP BY session_id
283
+ ON CONFLICT(session_id) DO UPDATE SET agent = excluded.agent, project_path = excluded.project_path,
284
+ first_ts = excluded.first_ts, last_ts = excluded.last_ts, event_count = excluded.event_count`),sessionEvents:t.prepare("SELECT * FROM events WHERE session_id = ? ORDER BY ts, seq, id"),getSession:t.prepare(`${mc} WHERE s.session_id = ?`),listSessions:t.prepare(`${mc} ORDER BY s.first_ts, s.session_id`),insertFinding:t.prepare(`INSERT INTO findings (id, rule_id, level, ts, session_id, message, events)
285
+ VALUES (?, ?, ?, ?, ?, ?, ?) ON CONFLICT(id) DO UPDATE SET level = excluded.level, message = excluded.message`),deleteFindings:t.prepare("DELETE FROM findings WHERE session_id = ?"),eventStats:t.prepare(`SELECT coalesce(sum(outcome = 'blocked'), 0) AS blocked,
286
+ coalesce(sum(agent_id IS NOT NULL), 0) AS subagent FROM events
287
+ WHERE (? IS NULL OR session_id IN (SELECT value FROM json_each(?)))`),listFindings:t.prepare("SELECT * FROM findings WHERE (? IS NULL OR session_id = ?) ORDER BY ts, id"),insertRuleRun:t.prepare(`INSERT INTO rule_runs (rule_set_hash, started_at, finished_at, events, findings)
288
+ VALUES (?, ?, ?, ?, ?)`),lastRuleRun:t.prepare(`SELECT rule_set_hash, started_at, finished_at, events, findings
289
+ FROM rule_runs ORDER BY id DESC LIMIT 1`)};function s(a){for(let l of a)n.dropEmptySession.run(l,l),n.refreshSession.run(l)}function i(a){let l=n.getFile.get(x(a));return l&&Kt(l)}function r(a){t.exec("BEGIN");try{let l=a();return t.exec("COMMIT"),l}catch(l){throw t.exec("ROLLBACK"),l}}function o(a){for(let l of a){let c=JSON.stringify(l.events.map(fe));n.insertFinding.run(x(l.id),x(l.rule_id),l.level,x(l.ts),x(l.session_id),x(l.message),c)}}return{transaction:r,getFile:i,listFiles:()=>n.listFiles.all().map((a)=>Kt(a)),shouldIndex(a,l,c,u){let f=i(a);return!f||f.size!==l||f.mtime!==c||f.parser_version!==u},upsertFile(a){let l=dr();n.upsertFile.run(x(a.path),a.size,a.mtime,a.parser_version,a.sha256,l,l)},touchFile(a){n.touchFile.run(dr(),x(a))},markGone(a){return Number(n.markGone.run(dr(),x(a)).changes)>0},upsertEvents(a,l,c=!0){let u=x(a),f=new Set;for(let d of l){let h=fe(d);n.upsertEvent.run(...Kv(u,h)),f.add(h.session_id)}if(c)s(f);return[...f]},deleteEvents(a,l=!0){let c=x(a),u=n.fileSessions.all(c).map((f)=>f.session_id);if(n.deleteEvents.run(c),l)s(u);return u},refreshSessions:s,sessionEvents:(a)=>n.sessionEvents.all(a).map(Jv),getSession(a){let l=n.getSession.get(a);return l&&gc(l)},listSessions:()=>n.listSessions.all().map(gc),insertFindings(a){r(()=>o(a))},replaceFindings(a,l){r(()=>{for(let c of a)n.deleteFindings.run(x(c));o(l)})},eventStats(a){let l=a?JSON.stringify(a):null,c=n.eventStats.get(l,l);return{blocked:Number(c?.blocked??0),subagent:Number(c?.subagent??0)}},listFindings(a){let l=a??null;return n.listFindings.all(l,l).map(Gv)},recordRuleRun(a){n.insertRuleRun.run(a.rule_set_hash,a.started_at,a.finished_at,a.events,a.findings)},lastRuleRun(){let a=n.lastRuleRun.get();return a&&Kt(a)},close:()=>t.close()}}import{createHash as zv}from"node:crypto";import{existsSync as wc,statSync as Xv}from"node:fs";import{readFile as Qv}from"node:fs/promises";async function Zv(e){return zv("sha256").update(await Qv(e)).digest("hex")}async function bc(e,t,n,s){let i={indexed:0,skipped:0,gone:0,events:0,failed:[]},r=new Set,o=[],a=[],l=new Set;for(let c of t)try{let{size:u,mtimeMs:f}=Xv(c);if(r.add(x(c)),!e.shouldIndex(c,u,f,s)){o.push(c),i.skipped++;continue}let d=e.getFile(c),h=await n(c),{events:g}=h,p=d&&d.size===u&&d.mtime===f?d.sha256:h.sha256??await Zv(c);e.transaction(()=>{if(d&&d.parser_version!==s)e.deleteEvents(c,!1).forEach((m)=>l.add(m));e.upsertEvents(c,g,!1).forEach((m)=>l.add(m))}),a.push({path:c,size:u,mtime:f,parser_version:s,sha256:p}),i.indexed++,i.events+=g.length}catch(u){if(wc(c))i.failed.push({path:x(c),error:x(String(u))})}return e.transaction(()=>{e.refreshSessions(l);for(let c of a)e.upsertFile(c);for(let c of o)e.touchFile(c);for(let c of e.listFiles())if(!c.gone_at&&!r.has(c.path)&&!wc(c.path)&&e.markGone(c.path))i.gone++}),i}import{existsSync as Sc,readFileSync as eE}from"node:fs";import{homedir as tE}from"node:os";import{join as nE}from"node:path";class I extends Error{}var _c=()=>({out:(e)=>{try{process.stdout.write(e)}catch(t){if(t.code!=="EPIPE")throw t}},err:(e)=>void process.stderr.write(e),isTTY:Boolean(process.stdout.isTTY),env:process.env}),as=(e)=>e.isTTY&&!e.env.NO_COLOR;function ls(e,t=Date.now()){let n=/^(\d+)([dh])$/.exec(e);if(n)return new Date(t-Number(n[1])*(n[2]==="d"?86400000:3600000)).toISOString();let s=Date.parse(e);if(Number.isNaN(s))throw new I(`bad --since '${e}' (expected e.g. 30d, 12h or 2026-11-01)`);return new Date(s).toISOString()}function G(e,t,n){if(!n.includes(t))throw new I(`unknown ${e} '${t}' (expected ${n.join(" | ")})`);return t}var sE=new Set(["agent","agent_version","session_id","parent_session_id","agent_id","parent_tool_use_id","project_path","category","tool_name","command_line","target_path","url","domain","mcp_server","mcp_tool","outcome","permission_mode","prompt_source","entrypoint","attribution","denial_kind","denial_category","text_excerpt"]),vc=new Set(["rule","match","project_path","reason"]),pr={entries:[],files:[]},Ec=(e)=>typeof e==="object"&&e!==null&&!Array.isArray(e);function iE(e,t,n,s,i){let r=(l)=>new I(`${n}: entry ${t+1}: ${l}`);if(!Ec(e))throw r("must be a mapping with `rule` and `match`");for(let l of Object.keys(e))if(!vc.has(l))throw r(`unknown key '${l}' (allowed: ${[...vc].join(", ")})`);if(typeof e.rule!=="string")throw r("`rule` must be a rule id or name (string)");let o=s.filter((l)=>l.id===e.rule||l.name===e.rule);if(!o.length){if(i)return;throw r(`unknown rule '${e.rule}'`)}let a=e.match??{};if(!Ec(a))throw r("`match` must be a mapping of field to exact string");for(let[l,c]of Object.entries(a)){if(!sE.has(l))throw r(`unknown match field '${l}'`);if(typeof c!=="string")throw r(`match.${l} must be a string`)}for(let l of["project_path","reason"])if(e[l]!==void 0&&typeof e[l]!=="string")throw r(`${l} must be a string`);if(!Object.keys(a).length&&e.project_path===void 0)throw r("needs `match` or `project_path` (an entry may not hide a whole rule)");return{rule_ids:new Set(o.map((l)=>x(l.id))),match:a,project_path:e.project_path,reason:e.reason,file:n}}function rE(e,t,n){let s=cr(eE(e,"utf8"));if(s.errors.length)throw new I(`${e}: ${s.errors[0].message}`);let i;try{i=s.toJS({maxAliasCount:0})}catch(r){throw new I(`${e}: ${r.message}`)}if(i==null)return[];if(!Array.isArray(i))throw new I(`${e}: must be a list of entries`);return i.flatMap((r,o)=>iE(r,o,e,t,n)??[])}function lt(e,t={}){if(t.file&&!Sc(t.file))throw new I(`--ignore file not found: ${t.file}`);let s=(t.file?[t.file]:[nE(t.home??tE(),".retrohound","ignore.yml")]).filter((i)=>Sc(i));return{entries:s.flatMap((i)=>rE(i,e,t.skipUnknownRules??!1)),files:s}}function hr(e,t){let n=e.events[0];if(!n)return!1;return t.entries.some((s)=>s.rule_ids.has(e.rule_id)&&(s.project_path===void 0||n.project_path===s.project_path)&&Object.entries(s.match).every(([i,r])=>n[i]===r))}function cs(e,t){let n=t.entries.length?e.filter((s)=>!hr(s,t)):e;return{kept:n,suppressed:e.length-n.length}}var FC=Ke.claude_code.parserVersion,Jt="0.1.0",B=cE(new URL("../rules/ai_coding_agent",import.meta.url)),xc=()=>({malformed:0,unknown_types:{}});function Ac(e,t){e.malformed+=t.malformed;for(let[n,s]of Object.entries(t.unknown_types))e.unknown_types[n]=(e.unknown_types[n]??0)+s}function Cc(e,t){let n=new Map;for(let s of t)n.set(e.groupKey(s),[...n.get(e.groupKey(s))??[],s]);return n}function uE(e){let t=[];try{t=aE(e,{recursive:!0}).map((o)=>o.replaceAll("\\","/")).filter((o)=>/\.ya?ml$/.test(o))}catch{}let n=t.sort().map((o)=>({path:kc(e,o),text:lE(kc(e,o),"utf8"),name:o})),s=oE("sha256").update(n.map((o)=>`${o.name}\x00${o.text}\x00`).join("")).digest("hex"),{rules:i,rejected:r}=rt(n);return{rules:i,hash:s,rejected:r}}function Tc(e){let t=e.events.map(fe);return{id:os(e.rule.id,t.map((n)=>n.id)),rule_id:x(e.rule.id),level:e.rule.level,ts:t[0].ts,session_id:t[0].session_id,message:x(e.rule.title.replace(/\s+/g," ").trim()),events:t}}async function Rc(e,t,n){let s=new Map;for(let r of t)for(let o of r)for(let a of await n(o)??[]){let l=s.get(a.session_id)??new Map;if(!l.has(a.id))l.set(a.id,a);s.set(a.session_id,l)}let i=[...s.values()].flatMap((r)=>le(e,[...r.values()]).map(Tc));return{sessions:[...s.keys()],findings:i,bySession:s}}var $c=(e,t,n)=>async(s)=>{try{let i=t?.get(s);if(i)return i;let{events:r,stats:o}=await e.parseFile(s);if(n)Ac(n,o);return r}catch{return null}};function fE(e){let t=e.find((n)=>n.project_path);return{id:e[0].session_id,agent:e[0].agent,project_path:t?.project_path,last_ts:e.reduce((n,s)=>s.ts>n?s.ts:n,""),events:e.length,archived:!1}}async function dE(e,t){let n=0,s=xc(),i=[],r=new Map;for(let{c:l,paths:c}of e){let u=$c(l,void 0,s),f=async(h)=>await u(h)??(n++,null),d=await Rc(t,[...Cc(l,c).values()],f);i.push(...d.findings);for(let[h,g]of d.bySession)r.set(h,[...g.values()])}let o=(l)=>{let c=l.flatMap((u)=>r.get(u)??[]);return{blocked:c.filter((u)=>u.outcome==="blocked").length,subagent:c.filter((u)=>u.agent_id).length}},a=e.reduce((l,c)=>l+c.paths.length,0);return{sessions:[...r.values()].map(fE),findings:i,stats:o,files:{indexed:a-n,skipped:0,gone:0,failed:n},lines:s}}async function pE(e,t,n,s){let i=new Date().toISOString(),r=t.lastRuleRun()?.rule_set_hash!==s,o=xc(),a={indexed:0,skipped:0,gone:0,failed:0};for(let{c:u,paths:f}of e){let d=await hE(u,t,n,f,r,o);a.indexed+=d.indexed,a.skipped+=d.skipped,a.gone+=d.gone,a.failed+=d.failed.length}let l=t.listSessions().reduce((u,f)=>u+f.event_count,0);t.recordRuleRun({rule_set_hash:s,started_at:i,finished_at:new Date().toISOString(),events:l,findings:t.listFindings().length});let c=new Set(e.map((u)=>u.c.agent));return{sessions:t.listSessions().filter((u)=>c.has(u.agent)).map((u)=>({id:u.session_id,agent:u.agent,project_path:u.project_path??void 0,last_ts:u.last_ts,events:u.event_count,archived:u.archived})),findings:t.listFindings(),stats:(u)=>t.eventStats(u),files:a,lines:o}}async function hE(e,t,n,s,i,r){let o=new Set,a=new Map,c=await bc(t,s,async(h)=>{o.add(h);let g=await e.parseFile(h);return Ac(r,g.stats),a.set(h,g.events),g},e.parserVersion),u=[...Cc(e,s).values()].filter((h)=>i||h.some((g)=>o.has(g))),{sessions:f,findings:d}=await Rc(n,u,$c(e,a));if(a.clear(),t.replaceFindings(f,d),i)for(let h of t.listSessions().filter((g)=>g.agent===e.agent&&g.archived))t.insertFindings(le(n,t.sessionEvents(h.session_id)).map((g)=>Tc(g)));return c}var mr=(e)=>({id:e.id,name:e.name,title:e.title,author:e.author,description:e.description,level:e.level,tags:e.tags,lane:e.lane,falsepositives:e.falsepositives.length?e.falsepositives:void 0});async function Nc(e={}){let t=new Date().toISOString(),n=e.agent==="all",s=Ke[e.agent??"claude_code"];if(!n&&!s)throw Error(`unknown agent '${e.agent}'`);if(n&&e.root)throw Error("--root cannot be used with --agent all: each agent is read from its own default root");let i=n?Object.values(Ke):[s],r=i.map((g)=>e.root??g.defaultRoot()),{rules:o,hash:a,rejected:l}=uE(e.rulesDir??B);e.onRejected?.(l);let c=lt(o,{file:e.ignore}),u=i.map((g,p)=>({c:g,paths:g.discover(r[p])})),f=r.join(", "),d=n?i.map((g)=>g.agent):void 0;if(e.noIndex)return Oc(e,await dE(u,o),o,f,t,c,d);let h=at(e.dbPath);try{return Oc(e,await pE(u,h,o,a),o,f,t,c,d)}finally{h.close()}}function mE(e,t,n){return Object.fromEntries(e.map((s)=>{let i=t.filter((o)=>o.agent===s),r=new Set(i.map((o)=>o.id));return[s,{sessions:i.length,events:i.reduce((o,a)=>o+a.events,0),findings:n.filter((o)=>r.has(o.session_id)).length}]}))}function Oc(e,t,n,s,i,r,o){let a=e.project?.toLowerCase(),l=t.sessions.filter((m)=>(!e.since||m.last_ts>=e.since)&&(!a||(m.project_path??"").toLowerCase().includes(a))),c=new Set(l.map((m)=>m.id)),u=e.level?L.indexOf(e.level):0,{kept:f,suppressed:d}=cs(t.findings.filter((m)=>c.has(m.session_id)&&L.indexOf(m.level)>=u),r),h=new Set(f.map((m)=>m.rule_id)),{blocked:g,subagent:p}=t.stats([...c]);return{schema:"retrohound.scan/0.1",tool:{name:"retrohound",version:Jt},scan:{started_at:i,finished_at:new Date().toISOString(),sessions:l.length,events:l.reduce((m,O)=>m+O.events,0),blocked:g,subagent_events:p,files:t.files,lines:t.lines,archived_sessions:l.filter((m)=>m.archived).map((m)=>x(m.id)),root:x(s),...d?{suppressed:d}:{},...o?{agents:mE(o,l,f)}:{}},rules:n.filter((m)=>h.has(x(m.id))).map(mr),findings:f}}var gE=new Set(["content","tool_input","tool_response","text"]);function Y(e,t=!1){if(typeof e==="string")return x(e);if(Array.isArray(e))return e.map((n)=>Y(n,t));if(e&&typeof e==="object"){let n=Object.entries(e).filter(([s])=>!(t&&gE.has(s)));return Object.fromEntries(n.map(([s,i])=>[s,Y(i,t)]))}return e}function us(e){let t=e.findings.map((n)=>({...n,events:n.events.map((s)=>Y(s,!0))}));return JSON.stringify(Y({...e,findings:t}),null,2)}var Gt={informational:{sarif:"note",id:1,risk:0},low:{sarif:"note",score:"2.0",id:2,risk:21},medium:{sarif:"warning",score:"5.5",id:3,risk:47},high:{sarif:"error",score:"8.0",id:4,risk:73},critical:{sarif:"error",score:"9.5",id:5,risk:99}},yE="CLAUDE_PROJECTS";function wE(e){let t=e.replace(/\\/g,"/"),n=/\/projects\/+(.+)$/.exec(t);return n?n[1]:t.split("/").slice(-2).join("/")}var Lc=(e,t,n)=>({...n===void 0?{}:{id:n},...t?{message:{text:t}}:{},physicalLocation:{artifactLocation:{uri:wE(e.raw_ref.file),uriBaseId:yE},region:{startLine:e.raw_ref.line,startColumn:1,endLine:e.raw_ref.line}}});function bE(e,t){let n=e.command_line??e.target_path??e.url??e.tool_name??e.category;return Lc(e,`${e.category}: ${n}`,t+1)}function _E(e){let t=e.description??e.title,n=e.falsepositives?.length?` False positives: ${e.falsepositives.join("; ")}.`:"",s=Gt[e.level];return{id:e.id,name:e.name??e.id,shortDescription:{text:e.title},fullDescription:{text:t},help:{text:`Review the session timeline with: retrohound show <session-id>.${n}`},defaultConfiguration:{level:s.sarif},properties:{tags:["security",...e.tags].slice(0,10),...s.score?{"security-severity":s.score}:{},...e.author?{author:e.author}:{}}}}function Ic(e){let t=[...e.rules];for(let i of e.findings)if(!t.some((r)=>r.id===i.rule_id))t.push({id:i.rule_id,title:i.rule_id,level:i.level,tags:[],lane:"hunt"});let n=e.findings.map((i)=>{let[r,...o]=i.events.map((l)=>Y(l,!0)),a=i.id.slice(0,16);return{ruleId:i.rule_id,ruleIndex:t.findIndex((l)=>l.id===i.rule_id),level:Gt[i.level].sarif,message:{text:i.message},...r?{locations:[Lc(r)]}:{},...o.length?{relatedLocations:o.map(bE)}:{},partialFingerprints:{primaryLocationLineHash:`${a}:1`,"retrohound/v1":i.id},properties:{session_id:i.session_id,agent:r?.agent,...r?.agent_id?{agent_id:r.agent_id}:{},scope:r?.agent_id?"sub-agent":"main",event_ids:i.events.map((l)=>l.id)}}}),s={$schema:"https://json.schemastore.org/sarif-2.1.0.json",version:"2.1.0",runs:[{tool:{driver:{name:e.tool.name,version:e.tool.version,rules:t.map(_E)}},automationDetails:{id:"retrohound/hunt/"},results:n}]};return JSON.stringify(Y(s),null,2)}var SE="9.1.0",vE="1.9.0",EE={process_creation:{category:["process"],type:["start"]},file_access:{category:["file"],type:["access"]},file_event:{category:["file"],type:["change"]},web_request:{category:["network","web"],type:["access"]},mcp:{category:["api"],type:["access"]},tool_call:{category:["api"],type:["info"]},instruction_load:{category:["file"],type:["access"]},config_change:{category:["configuration","file"],type:["change"]}};function Pc(e){let t={tactics:[],techniques:[],subtechniques:[],other:[]},n=(s,i)=>{if(!s.includes(i))s.push(i)};for(let s of e){let i=/^attack\.(t\d{4})(?:\.(\d{3}))?$/i.exec(s);if(i){if(n(t.techniques,i[1].toUpperCase()),i[2])n(t.subtechniques,`${i[1].toUpperCase()}.${i[2]}`)}else if(s.startsWith("attack."))n(t.tactics,s.slice(7).split("_").map((r)=>r[0].toUpperCase()+r.slice(1)).join(" "));else t.other.push(s)}return t}var qc=(e)=>e.split(/[\\/]/).pop()??e,kE=(e)=>e.replace(/[\\/][^\\/]*$/,"");function OE(e){let t=EE[e.category],n=e.outcome==="success"?"success":e.outcome==="unknown"||!e.outcome?"unknown":"failure";return{"@timestamp":e.ts,event:{category:t?.category,type:[...t?.type??[],...e.outcome==="blocked"?["denied"]:[]],action:e.tool_name,outcome:n,sequence:e.seq},gen_ai:{agent:{name:e.agent,id:e.agent_id},provider:e.agent==="claude_code"?{name:"anthropic"}:void 0,tool:e.tool_name?{name:e.tool_name,type:e.mcp_server?"mcp":void 0}:void 0},process:e.command_line?{command_line:e.command_line,working_directory:e.project_path}:void 0,file:e.target_path?{path:e.target_path,name:qc(e.target_path),directory:kE(e.target_path)}:void 0,url:e.url?{full:e.url,original:e.url,domain:e.domain}:void 0,destination:e.domain?{domain:e.domain}:void 0,log:{file:{path:e.raw_ref.file}},message:e.text_excerpt,retrohound:{schema_version:e.schema_version,session_id:e.session_id,parent_session_id:e.parent_session_id,agent_id:e.agent_id,agent_version:e.agent_version,project_path:e.project_path,outcome:e.outcome,raw_ref:{line:e.raw_ref.line},mcp:e.mcp_server?{server:e.mcp_server,tool:e.mcp_tool}:void 0}}}function xE(e,t,n){let[s,...i]=e.events,r=s?OE(s):{"@timestamp":e.ts,retrohound:{session_id:e.session_id}},o=Gt[e.level],a=Pc(t?.tags??[]),l="event"in r?r.event:{};return{...r,ecs:{version:SE},event:{...l,kind:"alert",module:"retrohound",dataset:"retrohound.finding",id:e.id,severity:o.id,risk_score:o.risk,ingested:n.scan.finished_at},observer:{product:"retrohound",vendor:"retrohound",type:"hunt"},rule:{id:e.rule_id,uuid:e.rule_id,name:t?.name??t?.title,description:t?.description??t?.title,ruleset:"retrohound",...t?.author?{author:[t.author]}:{}},threat:{framework:"MITRE ATT&CK",tactic:{name:a.tactics},technique:{id:a.techniques,...a.subtechniques.length?{subtechnique:{id:a.subtechniques}}:{}}},tags:a.other,message:e.message,retrohound:{...r.retrohound,finding:{id:e.id,event_ids:[s,...i].filter(Boolean).map((c)=>c.id)}}}}var AE=(e)=>({process:e.command_line?{cmd_line:e.command_line}:void 0,file:e.target_path?{path:e.target_path,name:qc(e.target_path),type_id:1}:void 0,url:e.url?{url_string:e.url,hostname:e.domain}:void 0});function CE(e,t,n){let s=e.events[0],i=Pc(t?.tags??[]),r=e.events.map((l)=>Date.parse(l.ts)).filter((l)=>!Number.isNaN(l)),o=Date.parse(e.ts),a=[...i.tactics.map((l)=>({tactic:{name:l}})),...i.techniques.map((l)=>({technique:{uid:l},...i.subtechniques.find((c)=>c.startsWith(l))?{sub_technique:{uid:i.subtechniques.find((c)=>c.startsWith(l))}}:{}}))];return{class_uid:2004,category_uid:2,activity_id:1,type_uid:200401,time:o,severity_id:Gt[e.level].id,status_id:1,is_alert:!0,message:e.message,metadata:{version:vE,product:{name:n.tool.name,vendor_name:"retrohound",version:n.tool.version},uid:e.id,correlation_uid:e.session_id},finding_info:{uid:e.id,title:t?.name??t?.title??e.rule_id,desc:t?.description??t?.title,analytic:{uid:e.rule_id,name:t?.name??t?.title,type_id:1},attacks:a,types:["retrohound/hunt"],related_events:e.events.map((l)=>({uid:l.id})),first_seen_time:r.length?Math.min(...r):o,last_seen_time:r.length?Math.max(...r):o},evidences:e.events.map(AE),unmapped:{retrohound:{session_id:e.session_id,agent:s?.agent,agent_id:s?.agent_id,parent_session_id:s?.parent_session_id,rule_author:t?.author,project_path:s?.project_path,raw_ref:s?.raw_ref,other_tags:i.other,ai_agent:s?{name:s.agent,version:s.agent_version,instance_uid:s.session_id,type_id:99}:void 0}}}}function gr(e,t){let n=new Map(e.rules.map((i)=>[i.id,i])),s=e.findings.map((i)=>{let r={...i,events:i.events.map((a)=>Y(a,!0))},o=t==="ecs"?xE(r,n.get(i.rule_id),e):CE(r,n.get(i.rule_id),e);return JSON.stringify(Y(o))});return s.length?s.join(`
290
+ `)+`
291
+ `:""}var Fc=Ir(wr(),1);var Uc=(e)=>e.slice(0,8),NE=(e)=>e?.agent_id?`sub-agent ${e.agent_id.slice(0,8)}`:"main",Mc=(e)=>L.indexOf(e),LE={informational:"INFO",low:"LOW",medium:"MED",high:"HIGH",critical:"CRIT"},Bc=(e,t,n)=>({informational:e.dim,low:e.blue,medium:e.yellow,high:e.red,critical:(s)=>e.bold(e.red(s))})[t](n);function IE(e){let t=Object.entries(e?.unknown_types??{}).sort((i,r)=>r[1]-i[1]),n=t.reduce((i,[,r])=>i+r,0);if(!e||!e.malformed&&!n)return[];let s=t.slice(0,5).map(([i,r])=>`${i} ${r}`).join(", ")+(t.length>5?", …":"");return[` skipped lines: ${e.malformed} malformed · ${n} of unknown type${n?` (${s})`:""}`]}function PE(e,t){let n=new Map(e.rules.map((a)=>[a.id,a])),s=new Map;for(let a of e.findings)s.get(a.rule_id)?.push(a)??s.set(a.rule_id,[a]);let i=[...s.values()].sort((a,l)=>Mc(l[0].level)-Mc(a[0].level)),r=(a)=>n.get(a.rule_id)?.name??a.rule_id,o=Math.max(28,...i.map((a)=>r(a[0]).length+2));return i.map((a)=>{let l=a[0],c=n.get(l.rule_id),u=new Set(a.map((p)=>p.session_id)).size,f=[...new Set(a.map((p)=>NE(p.events[0])))],d=f.filter((p)=>p!=="main").length,h=f.length<=2?f.join("+"):`${f.includes("main")?"main+":""}${d} sub-agents`,g=u>1?`${u} sessions`:`${Uc(l.session_id)} ${l.ts.slice(0,10)} ${l.events[0]?.project_path??"-"} ${c?.tags[0]??""}`;return` ${Bc(t,l.level,LE[l.level].padEnd(4))} ${r(l).padEnd(o)}${g} [${h}]`})}function qE(e){let t=new Map;for(let s of e.findings)for(let i of s.events)for(let r of i.secret_fps??[]){let o=t.get(r)??{kinds:new Set,sessions:new Set};(i.secret_kinds??[]).forEach((a)=>o.kinds.add(a)),o.sessions.add(i.session_id),t.set(r,o)}if(!t.size)return[];return[""," Rotate these secrets (fingerprints, not values):",...[...t].map(([s,i])=>` ${s} ${[...i.kinds].join(",")||"secret"} ${i.sessions.size} session(s)`),""]}function Vc(e,t){let{scan:n}=e;if(n.sessions===0)return x(`No ${n.agents?"agent":"Claude Code"} sessions found at ${n.root}
292
+ `);let s=Fc.default.createColors(t.color),i=(u)=>u.toLocaleString("en-US"),r=((Date.parse(n.finished_at)-Date.parse(n.started_at))/1000).toFixed(1),o=n.events?Math.round(n.subagent_events/n.events*100):0,a=L.slice().reverse().map((u)=>[u,e.findings.filter((f)=>f.level===u).length]).filter(([,u])=>u).map(([u,f])=>Bc(s,u,`${f} ${u}`)),l=e.findings[0],c=[` Indexed ${i(n.sessions)} sessions · ${i(n.events)} events in ${r}s`,...Object.entries(n.agents??{}).map(([u,f])=>` ${u.padEnd(12)} ${i(f.sessions)} sessions · ${i(f.events)} events · ${i(f.findings)} findings`),` ${n.blocked} blocked · ${o}% of events from sub-agents · ${n.archived_sessions.length} archived sessions`,...IE(n.lines),...n.suppressed?[` ${n.suppressed} findings suppressed by your ignore file`]:[],...PE(e,s),...qE(e)," "+"─".repeat(45),` ${a.join(" · ")||"no findings"}${l?` → retrohound show ${Uc(l.session_id)}`:""}`];return x(c.join(`
293
+ `)+`
294
+ `)}import{createHash as UE}from"node:crypto";import{appendFileSync as BE,chmodSync as VE,mkdirSync as Jc,readdirSync as WE,readFileSync as Gc,renameSync as HE,writeFileSync as KE}from"node:fs";import{homedir as JE}from"node:os";import{dirname as Sr,join as hs,resolve as GE}from"node:path";var Yt=["claude_code","codex","antigravity"],ps=(e)=>typeof e==="string"&&e?e:void 0,br=(e)=>e!==null&&typeof e==="object"&&!Array.isArray(e)?e:{},_r=(e,t,n,s)=>({id:String(t??"hook"),schema_version:"0.1",agent:e,session_id:String(n??""),ts:new Date().toISOString(),seq:0,raw_ref:{file:"hook",line:0},project_path:s});function DE(e){let t=ps(e.cwd);return{..._r("claude_code",e.tool_use_id,e.session_id,t),permission_mode:ps(e.permission_mode),agent_id:ps(e.agent_id),...V(e.tool_name,e.tool_input,t)}}function jE(e){let t=he(e.cwd),n=br(e.tool_input).command,s=e.tool_name==="Bash"?mt(Array.isArray(n)?n.map(String):typeof n==="string"?[n]:[],t):V(e.tool_name,e.tool_input,t);return{..._r("codex",e.tool_use_id,e.session_id,t),permission_mode:ps(e.permission_mode),...s}}var ME=(e,t,n)=>Ms(e,t,n)??{category:"tool_call",tool_name:e};function FE(e){let t=e.toolCall.name,n=br(e.toolCall.args),s=Array.isArray(e.workspacePaths)?he(e.workspacePaths[0]):void 0,i={..._r("antigravity",e.stepIdx,e.conversationId,s),...ME(t,n,s),tool_name:t,tool_input:JSON.stringify(n)},r=[i.tool_input,i.content].filter((l)=>typeof l==="string"),o=[...new Set(r.flatMap(ne))],a=[...new Set(r.flatMap(We))];return{...i,...o.length?{secret_kinds:o}:{},...a.length?{secret_fps:a}:{}}}function Wc(e,t){let n=br(t);if(e==="antigravity"?typeof n.toolCall?.name!=="string":typeof n.tool_name!=="string")throw Error("not a tool-call payload");let s=e==="codex"?jE(n):e==="antigravity"?FE(n):DE(n);return Object.fromEntries(Object.entries(s).filter(([,i])=>i!==void 0))}var Hc=(e)=>e!=="codex";function Kc(e,t,n){return JSON.stringify(e==="antigravity"?{decision:t,reason:n}:{hookSpecificOutput:{hookEventName:"PreToolUse",permissionDecision:t,permissionDecisionReason:n}})+`
295
+ `}var vr=["log","confirm","block"],ms=()=>hs(JE(),".retrohound","hook-log.jsonl"),YE=(e)=>e.kind==="detection"&&e.lane==="enforce",zE=(e)=>e.tags.find((t)=>/^attack\.t\d/i.test(t))?.slice(7).toUpperCase();function XE(e,t,n=pr,s="claude_code"){let i=t.filter(YE),r=Wc(s,JSON.parse(e)),o=[fe(r)],a=le(i,[r]).map((l)=>l.rule).filter((l)=>!hr({rule_id:x(l.id),events:o},n));return a.sort((l,c)=>L.indexOf(c.level)-L.indexOf(l.level)),a[0]?{rule:a[0],event:r}:void 0}function QE(e,t){Jc(Sr(e),{recursive:!0}),BE(e,x(JSON.stringify(t))+`
296
+ `,{mode:384});try{VE(e,384)}catch{}}function Yc(e,t,n,s=ms(),i=pr,r="claude_code"){if(t==="confirm"&&!Hc(r))throw Error(`${r} does not support ask (confirm mode); use --mode log or block`);let o=XE(e,n,i,r);if(!o)return{};let a=o.rule.name??o.rule.id,l=t==="confirm"?"ask":"deny";if(t==="log")return QE(s,{ts:o.event.ts,agent:r,session_id:o.event.session_id,tool:o.event.tool_name??"",rule:a,would_decide:"deny"}),{rule:a,would:"deny"};let c=zE(o.rule),u=x(`RetroHound: ${a}${c?` (${c})`:""}`);return{output:Kc(r,l,u),rule:a,would:l}}var gs=(e)=>UE("sha256").update(e).digest("hex"),ZE=(e)=>hs(Sr(ms()),`rules-cache-${gs(GE(e)).slice(0,12)}.json`);function e0(e,t,n){try{let s=JSON.parse(Gc(e,"utf8"));return s.key===t&&Array.isArray(s.docs)&&s.docs.length===n&&s.docs.every(Array.isArray)&&s.sum===gs(JSON.stringify(s.docs))?s.docs:void 0}catch{return}}var t0=(e,t)=>{if(typeof t==="number"&&!Number.isFinite(t)||t instanceof Map||t instanceof Set)throw Error("not JSON-safe");return t};function n0(e,t,n){try{if(n.some((r)=>r.some((o)=>o.error!==void 0)))return;let s=JSON.stringify(n,t0);Jc(Sr(e),{recursive:!0});let i=`${e}.${process.pid}.tmp`;KE(i,JSON.stringify({key:t,sum:gs(s),docs:JSON.parse(s)}),{mode:384}),HE(i,e)}catch{}}function Er(e,t=ZE(e)){let n=[];try{n=WE(e,{recursive:!0}).filter((o)=>/\.ya?ml$/.test(o)).sort()}catch{}let s=n.map((o)=>({path:hs(e,o),text:Gc(hs(e,o),"utf8")})).filter((o)=>/lane:\s*enforce/.test(o.text)),i=gs(JSON.stringify(s.map((o)=>[o.path,o.text]))),r=e0(t,i,s.length);if(!r)try{r=s.map((o)=>ur(o.text)),n0(t,i,r)}catch{r=void 0}return rt(s.map((o,a)=>({...o,docs:r?.[a]}))).rules}import{createHash as s0}from"node:crypto";import{closeSync as i0,copyFileSync as r0,existsSync as zt,fsyncSync as o0,openSync as a0,readFileSync as bs,realpathSync as nu,renameSync as l0,rmSync as zc,statSync as su,writeSync as c0,chmodSync as u0}from"node:fs";import{homedir as ys,tmpdir as f0}from"node:os";import{basename as d0,dirname as iu,join as xe}from"node:path";class Qt extends Error{}var ws="--allow-unsafe-path",kr=(e)=>{try{return nu(e)}catch{return e}},p0=()=>({platform:process.platform,uid:process.getuid?.(),real:kr,tmp:kr(f0()),home:kr(ys()),cwd:process.cwd(),programDirs:[process.env.ProgramFiles,process.env["ProgramFiles(x86)"],process.env.ProgramW6432].filter((e)=>!!e),stat:(e)=>{try{let t=su(e);return{uid:t.uid,mode:t.mode,isDir:t.isDirectory()}}catch{return}}}),h0=(e)=>(e.mode&18)!==0&&!(e.isDir&&(e.mode&512)!==0),m0=(e,t)=>e.uid!==t&&e.uid!==0?`owned by uid ${e.uid}, not by you (uid ${t}) or root`:h0(e)?`group- or world-writable (mode ${(e.mode&4095).toString(8)})`:void 0;function g0(e,t){let n=[];for(let s=(t.real??((i)=>i))(e);;){let i=t.stat(s),r=i?m0(i,t.uid):"cannot be inspected";if(r)n.push({path:s,reason:r});let o=iu(s);if(o===s||!i||!r&&i.isDir&&i.uid===0)return n;s=o}}var Xc=(e,t)=>(t==="win32"?e.replace(/\\/g,"/").toLowerCase():e).replace(/\/+$/,""),Qc=(e,t,n)=>{let s=Xc(e,n),i=Xc(t,n);return s===i||s.startsWith(i+"/")};function ru(e,t,n=p0()){let s=[],i=n.platform==="win32";for(let o of[e,t]){let a=(n.real??((l)=>l))(o);if(!n.stat(a))s.push({path:o,reason:"does not exist or cannot be inspected"});else if(Qc(a,n.tmp,n.platform))s.push({path:a,reason:`is inside the temp directory (${n.tmp}), which other users or processes can write`});else if(!i)s.push(...g0(o,n));else if(![n.home,...n.programDirs].some((l)=>Qc(a,l,"win32")))s.push({path:a,reason:"is not under your user profile or a Program Files directory"})}let r=n.stat(n.cwd);if(!i&&r&&(r.mode&2)!==0&&(r.mode&512)===0)s.push({path:n.cwd,reason:"current directory (the repo checkout) is world-writable"});return s}var Zc=(e)=>e.map((t)=>`${t.path}: ${t.reason}`).join("; "),eu=(e)=>s0("sha256").update(e).digest("hex"),ou=(e,t)=>JSON.stringify(e)===JSON.stringify(t);function au(e,t=process.cwd(),n=process.env,s="claude_code"){if(s!=="claude_code"&&e==="local")throw Error(`${s} has no local scope; use --scope user or project`);if(s==="codex")return e==="user"?xe(ys(),".codex","hooks.json"):xe(t,".codex","hooks.json");if(s==="antigravity")return e==="user"?xe(ys(),".gemini","config","hooks.json"):xe(t,".agents","hooks.json");if(e==="user")return xe(n.CLAUDE_CONFIG_DIR||xe(ys(),".claude"),"settings.json");return xe(t,".claude",e==="project"?"settings.json":"settings.local.json")}var _s=(e="claude_code")=>e==="antigravity"?"retrohound":"hooks";function lu(e){if(Array.isArray(e.args))return typeof e.command==="string"?{command:e.command,args:e.args}:void 0;if(e.args!==void 0||typeof e.command!=="string")return;let[t="",...n]=e.command.trim().split(/\s+/);return{command:t,args:n}}function cu(e){let t=e&&e.type==="command"?lu(e):void 0;if(!t)return!1;let n=t.args.findIndex((i,r)=>i==="hook"&&t.args[r+1]==="run"),s=n>0?t.args[n-1]:n===0?t.command:"";return typeof s==="string"&&/retrohound|(^|[\\/])(cli\.mjs|bin\.ts|entry\.ts)$/i.test(s)}var y0=/^[\w.:/\\@+-]+$/;function w0(e){let t=[e.entry,"hook","run",...e.agent&&e.agent!=="claude_code"?["--agent",e.agent]:[],"--mode",e.mode,...e.allowUnsafePath?[ws]:[]];if(!e.agent||e.agent==="claude_code")return{type:"command",command:e.command,args:t,timeout:5,...e.failClosed?{onFailure:"block"}:{}};if(e.failClosed)throw Error(`--fail-closed is not available for ${e.agent}: its hook docs define no fail-closed setting`);if(e.agent==="codex"&&e.mode==="confirm")throw Error("codex does not support ask (Codex runs the tool when a hook answers ask); use --mode log or block");let n=[e.command,e.entry].filter((s)=>!y0.test(s));if(n.length)throw new Qt(`refusing to install: ${n.join(", ")} would need shell quoting in a ${e.agent} hook command. Nothing was written. Install from a path without spaces or special characters.`);return{type:"command",command:[e.command,...t].join(" "),timeout:5}}function Ss(e){if(!zt(e))return{text:void 0,obj:{}};let t=bs(e,"utf8"),n;try{n=JSON.parse(t)}catch(s){throw Error(`${e} is not strict JSON (${s.message}); refusing to touch it`)}if(!n||typeof n!=="object"||Array.isArray(n))throw Error(`${e} is not a JSON object; refusing to touch it`);return{text:t,obj:n}}function Xt(e,t="hooks"){let n=e[t]?.PreToolUse;return Array.isArray(n)?n:[]}var Zt=(e,t)=>Xt(e,t).flatMap((n)=>Array.isArray(n?.hooks)?n.hooks:[]).filter(cu);function b0(e,t,n="hooks"){let s=structuredClone(e),i=Zt(s,n);if(!i.length)return s[n]={...s[n],PreToolUse:[...Xt(s,n),{matcher:"*",hooks:[t]}]},s;let[r,...o]=i;for(let a of Object.keys(r))delete r[a];return Object.assign(r,t),o.length?uu(s,n,o):s}function uu(e,t="hooks",n){let s=(r)=>!(cu(r)&&(!n||n.includes(r))),i=Xt(e,t).map((r)=>Array.isArray(r?.hooks)?{...r,hooks:r.hooks.filter(s)}:r).filter((r)=>!Array.isArray(r.hooks)||r.hooks.length);if(!e[t])return e;if(i.length)e[t].PreToolUse=i;else delete e[t].PreToolUse;if(!Object.keys(e[t]).length)delete e[t];return e}function tu(e,t,n){let s=xe(iu(e),`.${d0(e)}.rh-${process.pid}.tmp`),i=a0(s,"w",n);try{c0(i,t),o0(i)}finally{i0(i)}l0(s,e)}function _0(e,t,n="hooks"){let s=JSON.parse(bs(e,"utf8")),i=new Set([...Object.keys(t),...Object.keys(s)]);for(let r of i)if(r!==n&&!ou(t[r],s[r]))throw Error(`verification failed: key '${r}' changed`);if(JSON.stringify(t.permissions)!==JSON.stringify(s.permissions))throw Error("verification failed: permissions changed");if(Zt(s,n).length>1)throw Error("verification failed: more than one RetroHound handler")}function fu(e,t,n){let s=zt(e.path)?nu(e.path):e.path;for(let i=0;i<3;i++){let{text:r,obj:o}=Ss(s),a=t(o),l=[];if(ou(a,o)&&r!==void 0)return{status:n?"unchanged":"absent",path:s,warnings:l,diff:""};let c=_s(e.agent),u=`${c}.PreToolUse: ${JSON.stringify(Xt(o,c))}
297
+ -> ${JSON.stringify(Xt(a,c))}`;if(e.dryRun)return{status:n?"updated":"installed",path:s,warnings:l,diff:u};let f=r===void 0?384:su(s).mode&511,d=(e.now??new Date).toISOString().replace(/[:.]/g,"-"),h=r===void 0?void 0:`${s}.retrohound-bak-${d}`;if(h)r0(s,h),u0(h,384);if(r===void 0?zt(s):eu(bs(s))!==eu(r)){if(h)zc(h,{force:!0});continue}tu(s,JSON.stringify(a,null,2)+`
298
+ `,f);try{e.afterWrite?.(s),_0(s,o,c)}catch(g){if(r===void 0)zc(s,{force:!0});else tu(s,r,f);throw Error(`${g.message}; original restored`)}return{status:n?"updated":"installed",path:s,backup:h,warnings:l,diff:u}}throw Error(`${s} keeps changing; giving up without writing`)}function du(e){let t=w0(e),n=ru(e.command,e.entry,e.safety);if(n.length&&!e.allowUnsafePath)throw new Qt(`refusing to install, the hook would run files others may be able to modify: ${Zc(n)}. Nothing was written. Fix the permissions or install from a user-owned path; ${ws} overrides this check.`);let s=_s(e.agent),i=fu(e,(r)=>b0(r,t,s),Zt(Ss(e.path).obj,s).length);if(n.length)i.warnings.push(`${ws}: installed despite unsafe paths (${Zc(n)}); \`hook status\` keeps reporting this`);if(e.failClosed)i.warnings.push("--fail-closed: if retrohound is missing or crashes, Claude Code BLOCKS every tool call until you run `retrohound hook uninstall`");return i}function pu(e){if(!zt(e.path))return{status:"absent",path:e.path,warnings:[],diff:""};let t=_s(e.agent),n=Zt(Ss(e.path).obj,t).length;return{...fu(e,(i)=>uu(structuredClone(i),t),n),status:n?"removed":"absent"}}var S0=["C:\\Program Files\\ClaudeCode\\managed-settings.json","/Library/Application Support/ClaudeCode/managed-settings.json","/etc/claude-code/managed-settings.json"];function hu(e,t=S0,n,s="claude_code"){let{obj:i}=Ss(e),r=Zt(i,_s(s))[0],o=r?lu(r):void 0,a=o?o.args.indexOf("--mode"):-1,l=s==="claude_code"&&[e,...t].some((u)=>{try{return zt(u)&&JSON.parse(bs(u,"utf8")).allowManagedHooksOnly===!0}catch{return!1}}),c=o?ru(o.command,(o.args[0]==="hook"?void 0:o.args[0])??o.command,n):void 0;return{installed:!!r,mode:a>=0?o.args[a+1]:void 0,failClosed:r?.onFailure==="block",managedHooksOnly:l,path:e,allowUnsafePath:o?.args.includes(ws),unsafe:c}}import{resolve as gu}from"node:path";function yu(e){let t=G("agent",e.agent??"claude_code",Yt),n=G("scope",e.scope,t==="claude_code"?["user","project","local"]:["user","project"]);return{agent:t,path:e.settings?gu(e.settings):au(n,void 0,void 0,t)}}var v0={claude_code:"Check it with /hooks inside Claude Code.",codex:"Open /hooks in Codex and trust the hook: Codex does not run a new or changed hook until you review it.",antigravity:"Check it with /hooks in Antigravity CLI, then try a harmless command."};function E0(e){let t=G("mode",e.mode??"log",vr);return{...yu(e),mode:t,command:process.execPath,entry:gu(process.argv[1]??""),failClosed:e.failClosed,dryRun:e.dryRun,allowUnsafePath:e.allowUnsafePath}}function mu(e,t,n){let s;try{s=e(E0(t))}catch(i){if(i instanceof Qt)throw new I(i.message);throw i}if(n.out(x(`${s.status}: ${s.path}
299
+ ${s.diff?` ${s.diff}
300
+ `:""}${s.backup?` backup: ${s.backup}
301
+ `:""}`)),s.warnings.forEach((i)=>n.err(x(`warning: ${i}
302
+ `))),s.status==="installed"||s.status==="updated")n.out(`${v0[t.agent??"claude_code"]}
303
+ `);return 0}function k0(e,t){let{agent:n,path:s}=yu(e),i=hu(s,void 0,void 0,n);if(t.out(x(`${i.installed?`installed (mode ${i.mode??"?"}${i.failClosed?", fail-closed":""})`:"not installed"}: ${i.path}
304
+ `)),i.allowUnsafePath)t.out(`installed with --allow-unsafe-path: the path safety check was overridden.
305
+ `);if(i.unsafe?.length)t.out(x(`WARNING: the installed hook runs files that no longer pass the path check:
306
+ ${i.unsafe.map((r)=>` ${r.path}: ${r.reason}`).join(`
307
+ `)}
308
+ Fix the permissions, or run \`hook uninstall\`.
309
+ `));else if(i.installed)t.out(`installed paths pass the safety check.
310
+ `);if(i.managedHooksOnly)t.out(`allowManagedHooksOnly is set: user, project and local hooks do not run, so this hook is inactive.
311
+ `);return 0}async function O0(){let e=[];for await(let t of process.stdin)e.push(t);return Buffer.concat(e).toString("utf8")}async function x0(e,t,n=O0){try{let s=e.mode??"log";if(!vr.includes(s))throw Error(`unknown mode '${e.mode}'`);let i=e.agent??"claude_code";if(!Yt.includes(i))throw Error(`unknown agent '${e.agent}'`);let r=await n(),o=e.rules??B,a=e.cache?Er(o,e.cache):Er(o),l=lt(a,{file:e.ignore,skipUnknownRules:!0}),c=Yc(r,s,a,e.log??ms(),l,i);if(c.output)t.out(c.output)}catch(s){t.err(x(`retrohound hook: ${s.message}; no decision (fail open)`).split(`
312
+ `)[0]+`
313
+ `)}return 0}var wu=(e,t,n)=>{let s=e.command("hook").description("PreToolUse hook for Claude Code, Codex and Antigravity CLI: run, install, uninstall, status");s.command("run").description("Read a PreToolUse payload on stdin and print a permission decision (used by the agent)").option("--agent <agent>",Yt.join(" | "),"claude_code").option("--mode <mode>","log | confirm | block","log").option("--rules <dir>","rules directory").option("--log <path>","trial log file for --mode log").option("--cache <path>","parsed-rule cache file (default: next to the trial log)").option("--ignore <file>","ignore file (default ~/.retrohound/ignore.yml)").allowUnknownOption().allowExcessArguments().action((r)=>t(()=>x0(r,n)));let i=(r)=>r.option("--agent <agent>",Yt.join(" | "),"claude_code").option("--scope <scope>","user | project | local (local: Claude Code only)","user").option("--settings <path>","settings or hooks.json file to edit (overrides --scope)");i(s.command("install").description("Add the PreToolUse hook to the agent's settings or hooks.json file (backs it up first)")).option("--mode <mode>","log | confirm | block (codex: no confirm)","log").option("--fail-closed","block every tool call if the hook itself fails (Claude Code only)").option("--dry-run","show the change, write nothing").option("--allow-unsafe-path","install even if the runtime or entry file (or a parent dir) is writable by others; warns and shows in status").action((r)=>t(()=>mu(du,r,n))),i(s.command("uninstall").description("Remove only RetroHound's hook from a settings file")).option("--dry-run","show the change, write nothing").action((r)=>t(()=>mu(pu,r,n))),i(s.command("status").description("Show whether the hook is installed, its mode, and whether managed settings disable it")).action((r)=>t(()=>k0(r,n)))};import{createInterface as M0}from"node:readline";import{existsSync as C0}from"node:fs";import{readdirSync as A0,readFileSync as _u}from"node:fs";import{join as bu}from"node:path";function X(e){let t=[];try{t=A0(e,{recursive:!0}).map((n)=>n.replaceAll("\\","/")).filter((n)=>/\.ya?ml$/.test(n))}catch{}return rt(t.sort().map((n)=>({path:bu(e,n),text:_u(bu(e,n),"utf8")})))}var Su=(e)=>e.kind==="correlation"?"correlation":e.category??"any";function vu(e,t){let{rules:n,rejected:s}=X(e),i=n.map((r)=>` ${(r.name??r.id).padEnd(44)} ${r.level.padEnd(13)} ${r.lane.padEnd(8)} ${Su(r)}`);if(t.out(x([` ${n.length} rules, ${s.length} rejected`,...i].join(`
314
+ `)+`
315
+ `)),s.length)t.out(x([""," Rejected:",...s.map((r)=>` ${r.path} #${r.doc} ${r.title??""}: ${r.reason}: ${r.message}`)].join(`
316
+ `)+`
317
+ `));return 0}function Eu(e,t,n){let s=X(e).rules.find((o)=>o.name===t||o.id===t);if(!s)throw new I(`no rule named '${t}' (see \`retrohound rules list\`)`);let i=qe(_u(s.path,"utf8"))[s.doc]?.toString()??"",r=`${s.title}
318
+ id: ${s.id} level: ${s.level} lane: ${s.lane} category: ${Su(s)}
319
+ file: ${s.path}
320
+ `;return n.out(x(`${r}
321
+ ${i}`)),0}class z extends Error{}var ku=200,T0=500;function vs(e,t){if(!C0(e.dbPath))throw new z(`no index at ${e.dbPath}: run \`retrohound scan\` first`);let n=ot(e.dbPath);try{return t(n)}catch(s){throw s instanceof z?s:new z(`query failed: ${s.message}`)}finally{n.close()}}var De=(e)=>Number(e??0),R0=(e)=>typeof e==="bigint"?Number(e):e instanceof Uint8Array?"<blob>":e;function tn(e,t){let n=e[t];if(n===void 0)return;if(typeof n!=="string")throw new z(`${t} must be a string`);return n}function xr(e,t,n){let s=e.limit??t;if(typeof s!=="number"||!Number.isInteger(s)||s<1)throw new z("limit must be a positive integer");return Math.min(s,n)}var Ar=(e)=>new Map(X(e.rulesDir).rules.map((t)=>[t.id,t.name??t.title]));function $0(e,t){return vs(t,(n)=>{let s=Ar(t),i=(l)=>n.prepare(l).get()??{},r=i("SELECT count(*) AS events, coalesce(sum(outcome = 'blocked'), 0) AS blocked FROM events"),o=n.prepare("SELECT level, count(*) AS n FROM findings GROUP BY level").all(),a=n.prepare("SELECT rule_id, level, count(*) AS n FROM findings GROUP BY rule_id, level ORDER BY n DESC").all();return{sessions:De(i("SELECT count(*) AS n FROM sessions").n),events:De(r.events),blocked:De(r.blocked),findings_by_level:Object.fromEntries(L.map((l)=>[l,De(o.find((c)=>c.level===l)?.n)])),findings_by_rule:a.map((l)=>({rule:s.get(String(l.rule_id))??l.rule_id,level:l.level,count:De(l.n)}))}})}function N0(e,t){let n=tn(e,"level");if(n!==void 0&&!L.includes(n))throw new z(`level must be one of ${L.join(", ")}`);let s=tn(e,"rule"),i=tn(e,"session")??"",r=xr(e,50,200);return vs(t,(o)=>{let a=Ar(t),l=s===void 0?null:[s,...[...a].filter(([,f])=>f===s).map(([f])=>f)];return o.prepare(`SELECT id, rule_id, level, ts, session_id, message, events FROM findings
322
+ WHERE (? IS NULL OR level = ?) AND substr(session_id, 1, length(?)) = ?
323
+ ORDER BY ts DESC, id`).all(n??null,n??null,i,i).filter((f)=>l===null||l.includes(String(f.rule_id))).slice(0,r).map((f)=>({id:f.id,rule:a.get(String(f.rule_id))??f.rule_id,level:f.level,ts:f.ts,session_id:f.session_id,message:f.message,event_ids:JSON.parse(String(f.events)).map((d)=>d.id)}))})}var L0="ts, agent_id, category, tool_name, command_line, target_path, url, domain, mcp_server, mcp_tool, outcome";function I0(e,t){let n=tn(e,"session");if(!n)throw new z("session (an id prefix) is required");let s=xr(e,200,T0);return vs(t,(i)=>{let r=i.prepare("SELECT * FROM sessions WHERE substr(session_id, 1, length(?)) = ? LIMIT 6").all(n,n);if(r.length===0)throw new z(`no session starts with '${n}'`);if(r.length>1)throw new z(`'${n}' is ambiguous: ${r.map((d)=>d.session_id).join(", ")}`);let o=r[0],a=String(o.session_id),l=i.prepare(`SELECT id, ${L0} FROM events WHERE session_id = ? ORDER BY ts, seq, id LIMIT ?`).all(a,s),c=i.prepare("SELECT rule_id, level, events FROM findings WHERE session_id = ?").all(a),u=Ar(t),f=(d)=>c.filter((h)=>JSON.parse(String(h.events))[0]?.id===d).map((h)=>`${h.level}: ${u.get(String(h.rule_id))??h.rule_id}`);return{session_id:a,project_path:o.project_path,first_ts:o.first_ts,last_ts:o.last_ts,event_count:De(o.event_count),truncated:De(o.event_count)>l.length,events:l.map((d)=>{let{id:h,...g}=d;return{...Object.fromEntries(Object.entries(g).filter(([,m])=>m!==null)),...f(h).length?{findings:f(h)}:{}}})}})}function P0(e,t){let n=tn(e,"sql");if(!n)throw new z("sql is required");if(!/^\s*(?:select|with)\b/i.test(n)||/\b(?:attach|pragma)\b/i.test(n))throw new z("only a read-only SELECT over the index is allowed (no ATTACH or PRAGMA)");let s=xr(e,ku,ku);return vs(t,(i)=>{let r=i.prepare(n).all();return{rows:r.slice(0,s).map((o)=>Object.fromEntries(Object.entries(o).map(([a,l])=>[a,R0(l)]))),total:r.length,truncated:r.length>s}})}function q0(e,t){return X(t.rulesDir).rules.map((n)=>({name:n.name??n.title,level:n.level,lane:n.lane,tags:n.tags}))}var en=(e,t=[])=>({type:"object",properties:e,required:t,additionalProperties:!1}),Or={type:"integer",minimum:1,description:"maximum rows to return"},Cr=[{name:"scan_summary",description:"Sessions, events, blocked actions and findings by level and rule, read from the existing index (no re-scan).",inputSchema:en({}),run:$0},{name:"list_findings",description:"Findings from the index, newest first, masked. Filters are optional.",inputSchema:en({level:{type:"string",enum:[...L]},rule:{type:"string",description:"rule name or id"},session:{type:"string",description:"session id prefix"},limit:Or}),run:N0},{name:"show_session",description:"Masked timeline of one session by an unambiguous id prefix; findings marked at their first event. Capped at 500 events.",inputSchema:en({session:{type:"string",description:"session id prefix"},limit:Or},["session"]),run:I0},{name:"query",description:"Read-only SQL over the index (tables: events, sessions, findings, files_indexed). Writes fail. At most 200 rows.",inputSchema:en({sql:{type:"string"},limit:Or},["sql"]),run:P0},{name:"list_rules",description:"Loaded detection rules: name, level, lane, tags.",inputSchema:en({}),run:q0}];function Ou(e,t,n){return Y(e.run(t,n),!0)}var xu=["2025-11-25","2025-06-18","2025-03-26","2024-11-05"],D0={name:"retrohound",version:"0.1.0"},ct={parse:-32700,request:-32600,method:-32601,params:-32602},nn=(e,t)=>JSON.stringify({jsonrpc:"2.0",id:e,result:t}),ut=(e,t,n)=>JSON.stringify({jsonrpc:"2.0",id:e,error:{code:t,message:n}}),Es=(e)=>typeof e==="object"&&e!==null&&!Array.isArray(e);function j0(e,t,n){let s=Cr.find((r)=>r.name===e.name);if(!s)return ut(n,ct.params,`Unknown tool: ${String(e.name)}`);let i=e.arguments??{};if(!Es(i))return ut(n,ct.params,"arguments must be an object");try{return nn(n,{content:[{type:"text",text:JSON.stringify(Ou(s,i,t),null,2)}],isError:!1})}catch(r){let o=r instanceof z?r.message:"internal error";return nn(n,{content:[{type:"text",text:o}],isError:!0})}}function Au(e,t){let n;try{n=JSON.parse(e)}catch{return ut(null,ct.parse,"Parse error")}if(!Es(n)||n.jsonrpc!=="2.0"||typeof n.method!=="string")return Es(n)&&"id"in n?void 0:ut(null,ct.request,"Invalid Request");if(!("id"in n))return;let s=n.id,i=Es(n.params)?n.params:{};switch(n.method){case"initialize":{let r=i.protocolVersion,o=xu.includes(r)?r:xu[0];return nn(s,{protocolVersion:o,capabilities:{tools:{}},serverInfo:D0})}case"ping":return nn(s,{});case"tools/list":return nn(s,{tools:Cr.map(({name:r,description:o,inputSchema:a})=>({name:r,description:o,inputSchema:a}))});case"tools/call":return typeof i.name==="string"?j0(i,t,s):ut(s,ct.params,"params.name is required");default:return ut(s,ct.method,`Method not found: ${n.method}`)}}async function F0(e,t,n,s){for await(let i of M0({input:e,crlfDelay:1/0})){if(!i.trim())continue;let r=Au(i,{dbPath:t,rulesDir:n});if(r!==void 0)s(r+`
324
+ `)}return 0}var Cu=(e,t,n)=>{e.command("mcp").description("Serve the index to MCP clients over stdio (read-only tools)").option("--db <path>","index database",K()).option("--rules <dir>","rules directory",B).action((s)=>t(()=>F0(process.stdin,s.db,s.rules,n.out)))};import{statSync as Z0}from"node:fs";import{createHash as U0}from"node:crypto";import{lstatSync as B0,readdirSync as V0,readFileSync as W0,realpathSync as Tu,statSync as H0}from"node:fs";import{join as Ru}from"node:path";var $u=1048576,K0=400,ks="preflight",J0=new Set(["node_modules",".git"]),G0=[["CLAUDE.md","instruction_load"],["AGENTS.md","instruction_load"],["GEMINI.md","instruction_load"],[".cursorrules","instruction_load"],[".claude/settings.json","file_event"],[".claude/settings.local.json","file_event"],[".mcp.json","file_event"],[".vscode/tasks.json","file_event"],[".vscode/settings.json","file_event"],["package.json","file_event"]],Y0=[[".claude/agents",/\.md$/i],[".claude/commands",/\.md$/i],[".claude/skills",/(?:^|\/)SKILL\.md$/i],[".cursor/rules",/\.mdc?$/i]],Tr=(e)=>e.replaceAll("\\","/"),z0=(e,t)=>t===e||t.startsWith(e+"/");function Nu(e,t,n,s,i){return{id:U0("sha256").update(`${ks}\x00${e}\x00${s}`).digest("hex").slice(0,32),schema_version:"0.1",agent:"claude_code",session_id:ks,ts:i,seq:s,category:n,target_path:t,raw_ref:{file:e,line:1}}}function X0(e){try{let t=JSON.parse(e).hooks??{};return Object.entries(t).flatMap(([n,s])=>(Array.isArray(s)?s:[]).flatMap((i)=>(i?.hooks??[]).flatMap((r)=>typeof r?.command==="string"?[[n,r.command]]:[])))}catch{return[]}}function Lu(e,t=new Date){let n=Tr(Tu(e)),s=t.toISOString(),i={events:[],scanned:0,skipped:[]},r=(l,c)=>void i.skipped.push({path:l,reason:c}),o=(l,c)=>{let u=Ru(n,l),f;try{if(f=B0(u),f.isSymbolicLink()){if(!z0(n,Tr(Tu(u))))return r(l,"symlink outside the directory");f=H0(u)}}catch{return}if(!f.isFile())return;if(f.size>$u)return r(l,`larger than ${$u} bytes`);let d;try{d=W0(u,"utf8")}catch{return r(l,"unreadable")}i.scanned++;let h=Tr(u),g=i.events.length;if(i.events.push({...Nu(l,h,c,g,s),content:d,...c==="file_event"?{tool_name:"Write"}:{}}),l.endsWith(".claude/settings.json")||l.endsWith(".claude/settings.local.json"))for(let[p,m]of X0(d))i.events.push({...Nu(l,h,"process_creation",i.events.length,s),tool_name:`hook:${p}`,command_line:m})},a=(l,c,u={n:0})=>{let f;try{f=V0(Ru(n,l),{withFileTypes:!0}).sort((d,h)=>d.name.localeCompare(h.name))}catch{return}for(let d of f){let h=`${l}/${d.name}`;if(J0.has(d.name))continue;if(d.isDirectory())a(h,c,u);else if(c.test(h.slice(l.length+1))){if(++u.n>K0)return r(h,"too many files");o(h,"instruction_load")}}};for(let[l,c]of G0)o(l,c);for(let[l,c]of Y0)a(l,c);return i}function Q0(e){let t=e.events.map(fe);return{id:os(e.rule.id,t.map((n)=>n.id)),rule_id:x(e.rule.id),level:e.rule.level,ts:t[0].ts,session_id:ks,message:x(e.rule.title.replace(/\s+/g," ").trim()),events:t}}function Iu(e,t={}){let n=new Date().toISOString(),{rules:s,rejected:i}=X(t.rulesDir??B),{events:r,scanned:o,skipped:a}=Lu(e),{kept:l,suppressed:c}=cs(le(s,r).map((d)=>Q0(d)),lt(s,{file:t.ignore})),u=new Set(l.map((d)=>d.rule_id));return{report:{schema:"retrohound.scan/0.1",tool:{name:"retrohound",version:Jt},scan:{started_at:n,finished_at:new Date().toISOString(),sessions:1,events:r.length,blocked:0,subagent_events:0,files:{indexed:o,skipped:a.length,gone:0,failed:0},archived_sessions:[],root:x(e),...c?{suppressed:c}:{}},rules:s.filter((d)=>u.has(x(d.id))).map(mr),findings:l},skipped:a,rejected:i}}var Os=(e)=>L.indexOf(e);function Pu({report:e,skipped:t}){let{scan:n}=e,s=e.findings.slice().sort((o,a)=>Os(a.level)-Os(o.level)),i=[` Preflight ${n.root}: ${n.files.indexed} agent files, ${n.events} events`,""],r=new Map(e.rules.map((o)=>[x(o.id),o.name??o.id]));for(let o of s){let a=o.events[0];i.push(` ${o.level.toUpperCase().padEnd(13)}${o.message} (${r.get(o.rule_id)??o.rule_id})`,` ${a?.raw_ref.file??""}${a?.command_line?` ${a.command_line.slice(0,100)}`:""}`)}for(let o of t)i.push(` skipped ${o.path}: ${o.reason}`);if(n.suppressed)i.push(` ${n.suppressed} findings suppressed by your ignore file`);return i.push(" "+"─".repeat(45),` ${e.findings.length?`${e.findings.length} finding(s)`:"no findings"}`),x(i.join(`
325
+ `)+`
326
+ `)}var qu=(e,t)=>t!==void 0&&e.findings.some((n)=>Os(n.level)>=Os(t));function ek(e,t,n){let s=G("format",t.format,["table","json"]),i=t.failOn?G("level",t.failOn,L):void 0;if(!Z0(e,{throwIfNoEntry:!1})?.isDirectory())throw new I(`not a directory: ${e}`);let r=Iu(e,{rulesDir:t.rules,ignore:t.ignore});if(r.rejected.length)n.err(`${r.rejected.length} rules rejected, see \`retrohound rules list\`
327
+ `);if(s==="json")n.out(JSON.stringify(Y({...JSON.parse(us(r.report)),preflight:{skipped:r.skipped}}),null,2)+`
328
+ `);else n.out(Pu(r));return qu(r.report,i)?1:0}var Du=(e,t,n)=>{e.command("preflight [dir]").description("Scan a cloned repo's agent surface (.claude, .mcp.json, CLAUDE.md, tasks, npm scripts) before opening it with a coding agent").option("--rules <dir>","rules directory",B).option("--format <format>","table or json","table").option("--fail-on <level>","exit 1 when any finding is at or above this level").option("--ignore <file>","ignore file (default ~/.retrohound/ignore.yml; a repo's own file is only read when passed here)").action((s,i)=>t(()=>ek(s??".",i,n)))};var tk=(e)=>typeof e==="string"?x(e):typeof e==="bigint"?Number(e):e instanceof Uint8Array?"<blob>":e;function nk(e,t,n,s){let i=G("format",t,["table","json"]),r;try{let u=ot(n);try{r=u.prepare(e).all().map((f)=>Object.fromEntries(Object.entries(f).map(([d,h])=>[x(d),tk(h)])))}finally{u.close()}}catch(u){throw new I(`query failed: ${x(u.message)}`)}if(i==="json")return s.out(JSON.stringify(r,null,2)+`
329
+ `),0;let o=[...new Set(r.flatMap((u)=>Object.keys(u)))],a=(u,f)=>String(u[f]??"NULL").replace(/\s+/g," "),l=o.map((u)=>Math.min(60,Math.max(u.length,...r.map((f)=>a(f,u).length)))),c=(u,f)=>u.length>l[f]?u.slice(0,l[f]-1)+"…":u.padEnd(l[f]);return s.out([o.map(c).join(" "),...r.map((u)=>o.map((f,d)=>c(a(u,f),d)).join(" ")),`(${r.length} rows)`].join(`
330
+ `)+`
331
+ `),0}var ju=(e,t,n)=>{e.command("query <sql>").description("Run read-only SQL over the index (tables: events, sessions, findings, files_indexed)").option("--format <format>","table or json","table").option("--db <path>","index database",K()).action((s,i)=>t(()=>nk(s,i.format,i.db,n)))};var Mu=Ir(wr(),1);import{existsSync as sk}from"node:fs";var ik=(e)=>(e.command_line??e.url??e.target_path??e.text_excerpt??"").replace(/\s+/g," ").slice(0,100),rk=(e)=>e.agent_id?`sub:${e.agent_id.slice(0,8)}`:"main";function ok(e,t,n,s){let i=[e.ts.slice(11,19),rk(e).padEnd(12),e.category.padEnd(16),(e.tool_name??"-").padEnd(10),ik(e),e.outcome??""],r=t.map((o)=>s.bold(s.red(` <== ${o.level.toUpperCase()} ${n.get(o.rule_id)??o.rule_id}`))).join("");return` ${i.join(" ").trimEnd()}${r}`}function ak(e,t,n,s){if(!sk(t))throw new I(`no index at ${t}, run \`retrohound scan\` first`);let i=at(t);try{let r=i.listSessions().filter((d)=>d.session_id.startsWith(e));if(r.length===0)throw new I(`no session starts with '${e}'`);if(r.length>1)return s.err(`'${e}' is ambiguous, it matches ${r.length} sessions:
332
+ ${r.map((d)=>` ${d.session_id} ${d.first_ts} ${d.project_path??"-"}`).join(`
333
+ `)}
334
+ `),2;let o=r[0],a=Mu.default.createColors(as(s)),l=i.listFindings(o.session_id),c=(d)=>l.filter((h)=>h.events[0]?.id===d.id),u=new Map(X(n).rules.map((d)=>[d.id,d.name??d.title])),f=` Session ${o.session_id}${o.archived?" [archived: transcript deleted by Claude Code, kept by the index]":""}
335
+ ${o.project_path??"-"} ${o.first_ts} .. ${o.last_ts} ${o.event_count} events, ${l.length} findings
336
+ `;return s.out(x(f+i.sessionEvents(o.session_id).map((d)=>ok(d,c(d),u,a)).join(`
337
+ `)+`
338
+ `)),0}finally{i.close()}}var Fu=(e,t,n)=>{e.command("show <session-id>").description("Timeline of one session with findings highlighted (an unambiguous id prefix works)").option("--db <path>","index database",K()).option("--rules <dir>","rules directory, for rule names",B).action((s,i)=>t(()=>ak(s,i.db,i.rules,n)))};import{createHash as fk}from"node:crypto";import{existsSync as dk,writeFileSync as pk}from"node:fs";import{homedir as hk,userInfo as mk}from"node:os";import{basename as Wu}from"node:path";var lk={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},W=(e)=>x(String(e)).replace(/[&<>"']/g,(t)=>lk[t]),je=(e,t)=>`<div class="s"><b>${W(t)}</b><span>${W(e)}</span></div>`,Uu=(e,t)=>`<section><h2>${W(e)}</h2>${t.length?`<ol>${t.map((n)=>`<li>${n}</li>`).join("")}</ol>`:"<p>none</p>"}</section>`,ck=`body{margin:0;background:#0f1115;color:#e8e8ea;font:16px/1.4 system-ui,sans-serif;padding:24px}
339
+ .card{max-width:760px;margin:auto;background:#181b22;border-radius:14px;padding:28px}
340
+ h1{margin:0 0 4px}h2{font-size:14px;text-transform:uppercase;color:#8b93a7;margin:22px 0 6px}
341
+ .g{display:grid;grid-template-columns:repeat(auto-fit,minmax(140px,1fr));gap:12px}
342
+ .s{background:#222632;border-radius:10px;padding:12px}.s b{display:block;font-size:26px}.s span{color:#8b93a7;font-size:13px}
343
+ code{display:block;background:#0f1115;padding:10px;border-radius:8px;overflow-wrap:anywhere}ol{margin:0;padding-left:20px}`,uk=(e,t)=>e.length>t?`${e.slice(0,t-1)}…`:e,Me=(e,t,n,s,i,r=400)=>`<text x="${e}" y="${t}" font-size="${n}" fill="${s}"${n>30?' font-weight="700"':""}>${W(uk(String(i),r/(n*0.55)))}</text>`;function Bu(e){let n=[["sessions",e.sessions],["hours with agents",e.hours],["commands run",e.commands],["files touched",e.files],["secrets touched",e.secretsTouched],["blocked attempts",e.blocked],["from sub-agents",`${e.subagentPct}%`]].map(([r,o],a)=>Me(60+a%4*280,170+Math.floor(a/4)*110,52,"#e8e8ea",o,260)+Me(60+a%4*280,200+Math.floor(a/4)*110,20,"#8b93a7",r,260)),s=e.rules.slice(0,5).map((r,o)=>Me(60,430+o*32,22,"#e8e8ea",`${r.name} [${r.level}] x${r.count}`,1080)),i=`<?xml version="1.0" encoding="UTF-8"?>
344
+ <svg xmlns="http://www.w3.org/2000/svg" width="1200" height="630" viewBox="0 0 1200 630" font-family="system-ui, -apple-system, 'Segoe UI', sans-serif"><rect width="1200" height="630" fill="#181b22"/>`+Me(60,70,44,"#e8e8ea","RetroHound Wrapped",700)+Me(60,104,22,"#8b93a7",`${e.period}${e.anonymized?" (anonymized)":""}`,700)+n.join("")+Me(60,400,20,"#8b93a7","TOP RULES FIRED",400)+(s.length?s.join(""):Me(60,430,22,"#e8e8ea","none",400))+`</svg>
345
+ `;return x(i)}function Vu(e){let{riskiest:t,spiciest:n}=e,s=[`<h1>RetroHound Wrapped</h1><p>${W(e.period)}${e.anonymized?" (anonymized)":""}</p>`,`<div class="g">${[je("sessions",e.sessions),je("hours with agents",e.hours),je("commands run",e.commands),je("files touched",e.files),je("secrets touched",e.secretsTouched),je("blocked attempts",e.blocked),je("events from sub-agents",`${e.subagentPct}%`)].join("")}</div>`,Uu("Top domains",e.domains.map((r)=>`${W(r.name)} (${W(r.count)})`)),Uu("Top rules fired",e.rules.map((r)=>`${W(r.name)} [${W(r.level)}] x${W(r.count)}`)),`<section><h2>Riskiest session</h2><p>${t?`${W(t.session)} in ${W(t.project)}: ${W(t.findings)} findings, worst ${W(t.level)}`:"none"}</p></section>`,`<section><h2>Spiciest command</h2>${n?`<code>${W(n.command)}</code><p>${W(n.rule)} [${W(n.level)}]</p>`:"<p>none</p>"}</section>`].join(""),i=`<!doctype html><html lang="en"><head><meta charset="utf-8"><title>RetroHound Wrapped</title><style>${ck}</style></head><body><div class="card">${s}</div></body></html>
346
+ `;return x(i)}var ft=(e)=>L.indexOf(e),Hu=(e,t)=>[...e].sort((n,s)=>s[1]-n[1]||n[0].localeCompare(s[0])).slice(0,t),Ku=(e,t)=>e.set(t,(e.get(t)??0)+1),gk=(e)=>`anon-${fk("sha256").update(e).digest("hex").slice(0,6)}`;function yk(e,t){let n=new Set([Wu(hk()),mk().username]);for(let r of t){n.add(r),n.add(Wu(r.replace(/[\\/]+$/,"").replace(/\\/g,"/")));let o=/(?:home|Users)[\\/]+([^\\/]+)/i.exec(r)?.[1];if(o)n.add(o)}for(let r of e){let o=/projects[\\/]+([^\\/]+)/.exec(r.raw_ref.file)?.[1];if(o)n.add(o)}let s=[...n].filter((r)=>r.length>=3).sort((r,o)=>o.length-r.length),i=s.length?new RegExp(s.map((r)=>r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("|"),"gi"):void 0;return(r)=>i?r.replace(i,(o)=>gk(o.toLowerCase())):r}function wk(e){let t=new Map;for(let i of e)t.set(i.session_id,[...t.get(i.session_id)??[],i]);let n=(i)=>Math.max(...i.map((r)=>ft(r.level)))*1000+i.length,s=[...t].sort((i,r)=>n(r[1])-n(i[1]))[0];return s&&{session:s[0],findings:s[1].length,level:L[Math.max(...s[1].map((i)=>ft(i.level)))]}}function bk(e,t,n,s){let i=at(e);try{let r=i.listSessions().filter((y)=>y.last_ts>=n),o=new Set(r.map((y)=>y.session_id)),a=r.flatMap((y)=>i.sessionEvents(y.session_id)),l=i.listFindings().filter((y)=>o.has(y.session_id)),c=new Map(X(t).rules.map((y)=>[y.id,y.name??y.title])),u=s?yk(a,r.map((y)=>y.project_path??"").filter(Boolean)):(y)=>y,f=new Map,d=new Map,h=new Map;for(let y of a)if(y.domain)Ku(f,y.domain);for(let y of l){let v=c.get(y.rule_id)??y.rule_id;if(Ku(d,v),ft(y.level)>=ft(h.get(v)??"informational"))h.set(v,y.level)}let g=l.filter((y)=>y.events[0]?.command_line).sort((y,v)=>ft(v.level)-ft(y.level))[0],p=wk(l),m=p&&r.find((y)=>y.session_id===p.session)?.project_path,O=i.eventStats([...o]);return{period:`since ${n.slice(0,10)}`,anonymized:s,sessions:r.length,hours:Math.round(r.reduce((y,v)=>y+(Date.parse(v.last_ts)-Date.parse(v.first_ts)),0)/360000)/10,commands:a.filter((y)=>y.category==="process_creation").length,files:new Set(a.filter((y)=>(y.category==="file_access"||y.category==="file_event")&&y.target_path).map((y)=>y.target_path)).size,secretsTouched:a.filter((y)=>y.secret_kinds?.length||y.result_secret_kinds?.length).length,blocked:O.blocked,subagentPct:a.length?Math.round(O.subagent*100/a.length):0,domains:Hu(f,10).map(([y,v])=>({name:u(y),count:v})),rules:Hu(d,5).map(([y,v])=>({name:u(y),level:h.get(y)??"",count:v})),riskiest:p&&{...p,session:p.session.slice(0,8),project:u(m??"-")},spiciest:g&&{command:u(g.events[0].command_line),rule:u(c.get(g.rule_id)??g.rule_id),level:g.level}}}finally{i.close()}}function _k(e,t){if(e.out.toLowerCase().endsWith(".png"))return t.err(`PNG output is not supported (it would need a browser dependency); use --out card.svg and convert it
347
+ `),2;if(!dk(e.db))throw new I(`no index at ${e.db}, run \`retrohound scan\` first`);let n=bk(e.db,e.rules,ls(e.since),Boolean(e.anonymize));return pk(e.out,e.out.toLowerCase().endsWith(".svg")?Bu(n):Vu(n)),t.out(`wrote ${e.out}
348
+ `),0}var Ju=(e,t,n)=>{e.command("wrapped").description("Write a shareable, self-contained HTML report card from the index").option("--since <when>","window: 30d, 12h or a date","365d").option("--anonymize","hash project names, user name and project dirs").option("--out <file>","output file (.html, or .svg for a 1200x630 share card)","wrapped.html").option("--db <path>","index database",K()).option("--rules <dir>","rules directory, for rule names",B).action((s)=>t(()=>_k(s,n)))};import{existsSync as Gu,readFileSync as Yu}from"node:fs";import{dirname as Sk,join as xs}from"node:path";function vk(e){return Yu(e,"utf8").split(/\r?\n/).filter((n)=>n.trim()).map((n,s)=>({id:`e${s+1}`,schema_version:"0.1",agent:"claude_code",session_id:"s1",ts:new Date(Date.UTC(2026,0,1,0,0,s)).toISOString(),seq:s+1,category:"tool_call",raw_ref:{file:e,line:s+1},...JSON.parse(n)}))}var Rr=(e,t)=>le([e],t).filter((n)=>n.rule===e).length,$r=(e,t=!1)=>typeof e==="string"?t?[e]:[]:Array.isArray(e)?e.flatMap((n)=>$r(n,t)):e&&typeof e==="object"?Object.entries(e).flatMap(([n,s])=>$r(s,n.split("|").includes("re"))):[];function Ek(e){return[...new Set(e.map((t)=>t.path))].flatMap((t)=>qe(Yu(t,"utf8")).flatMap((n)=>$r(n.toJS()?.detection)).filter((n)=>(n.match(/(?<!\\)\.[*+]/g)??[]).length>1).map((n)=>`${t}: ${n}`))}function kk(e,t){let n=e.name??e.id,s=xs(t,n),i=xs(s,"positive.jsonl"),r=xs(s,"negative.jsonl"),o=[...e.name?[]:["rule has no name"],...[i,r].filter((u)=>!Gu(u)).map((u)=>`missing ${u}`)],a=(u,f)=>{if(!Gu(u))return[];try{let d=vk(u);return d.length?f(d):[`${u} is empty`]}catch(d){return[`${u}: ${d.message}`]}},l=a(i,(u)=>e.kind==="correlation"?Rr(e,u)?[]:["correlation did not fire on the positive file"]:u.filter((f)=>Rr(e,[f])===0).map((f)=>`positive line ${f.raw_ref.line} did not fire`)),c=a(r,(u)=>Rr(e,u)?["fired on the negative file"]:[]);return{name:n,files:o,positive:l,negative:c}}function Ok(e,t=xs(Sk(e),"tests")){let{rules:n,rejected:s}=X(e);return{rejected:s.map((i)=>`${i.path} #${i.doc}: ${i.reason}: ${i.message}`),badRe:Ek(n),rules:n.filter((i)=>!i.silenced).map((i)=>kk(i,t))}}function zu(e,t,n){let s=Ok(e,t),i=s.rules.map((a)=>{let l=[...a.files,...a.positive,...a.negative];return l.length?` FAIL ${a.name}
349
+ ${l.map((c)=>` ${c}`).join(`
350
+ `)}`:` ok ${a.name}`}),r=[...s.rejected.map((a)=>`rejected: ${a}`),...s.badRe.map((a)=>`re with more than one .* / .+: ${a}`)],o=s.rules.filter((a)=>a.files.length+a.positive.length+a.negative.length).length;return n.out(x([...i,...r.map((a)=>` FAIL ${a}`),` ${s.rules.length-o}/${s.rules.length} rules pass, ${r.length} other problems`].join(`
351
+ `)+`
352
+ `)),o||r.length?1:0}import{existsSync as xk,readFileSync as Xu}from"node:fs";import{join as Qu}from"node:path";function Ak(e){try{let t=JSON.parse(Xu(Qu(e,"settings.json"),"utf8")).cleanupPeriodDays;return typeof t==="number"&&t>0?t:30}catch{return 30}}function Ck(e,t){let n=Qu(e,"history.jsonl");if(!xk(n))return;let s=new Set;for(let i of Xu(n,"utf8").split(`
353
+ `))try{let r=JSON.parse(i).sessionId;if(typeof r==="string")s.add(r)}catch{}try{let i=ot(t);try{let r=new Set(i.prepare("SELECT session_id FROM sessions").all().map((o)=>String(o.session_id)));return[...s].filter((o)=>!r.has(o)).length}finally{i.close()}}catch{return}}function Zu(e,t,n){let s=Ak(e),i=Ck(e,t);return[` History window: ${s} days (cleanupPeriodDays from Claude Code settings, default 30)`,...i===void 0?[]:[` ${i} sessions in history.jsonl have no transcript (deleted before RetroHound indexed them)`],` ${n} sessions preserved in the index after Claude Code deleted them`,...s<=30?[` Warning: Claude Code deletes transcripts after ${s} days. To keep them longer, set "cleanupPeriodDays": 3650 in ~/.claude/settings.json (RetroHound never edits it).`," Caveat: fix secret-exposure findings first, because longer retention keeps plaintext secrets longer."]:[]]}import{homedir as Nk}from"node:os";import{join as Lk}from"node:path";var ef=Object.keys(Ke),Ik=["table","json","sarif","ndjson-ecs","ndjson-ocsf"];async function Pk(e,t){let n=G("agent",e.agent,[...ef,"all"]);if(n==="all"&&e.root)throw new I("--root cannot be used with --agent all: each agent is read from its own default root");let s=G("format",e.format,Ik),i=e.level?G("level",e.level,L):void 0,r=e.failOn?G("level",e.failOn,L):void 0,o={agent:n,root:e.root,dbPath:e.db,rulesDir:e.rules,project:e.project,level:i,noIndex:!e.index,since:e.since?ls(e.since):void 0,ignore:e.ignore},a=0,l=await Nc({...o,onRejected:(u)=>a=u.length});if(a)t.err(`${a} rules rejected, see \`retrohound rules list\`
354
+ `);if(s==="json")t.out(us(l)+`
355
+ `);else if(s==="sarif")t.out(Ic(l)+`
356
+ `);else if(s==="ndjson-ecs")t.out(gr(l,"ecs"));else if(s==="ndjson-ocsf")t.out(gr(l,"ocsf"));else{let u=e.root??Lk(Nk(),".claude"),f=n==="claude_code"?Zu(u,e.index?e.db:void 0,l.scan.archived_sessions.length):[];t.out(Vc(l,{color:as(t)})+f.join(`
357
+ `)+`
358
+ `)}let c=r?L.indexOf(r):void 0;return c!==void 0&&l.findings.some((u)=>L.indexOf(u.level)>=c)?1:0}function qk(e,t){let n=e.db??K();if(!Tk(n))return t.out(`Nothing to delete: ${n} does not exist.
359
+ `),0;if(!e.yes)return t.out(`Would delete the index ${n} (${$k(n).size} bytes).
360
+ `),t.out(`It may hold the only copy of evidence Claude Code has since deleted. Re-run with --yes to delete it.
361
+ `),1;for(let s of["","-wal","-shm","-journal"])Rk(n+s,{force:!0});return t.out(`Deleted ${n}
362
+ `),0}function Dk(e,t){let n=new Be("retrohound").version(Jt).description("Find what your AI coding agents did that you would not want repeated.");n.exitOverride().configureOutput({writeOut:e.out,writeErr:e.err});let s=async(r)=>t(await r());n.command("scan").description("Scan Claude Code transcripts, index them, and report findings").option("--since <when>","only sessions active since: 30d, 12h or a date").option("--agent <agent>",`agent to scan (${ef.join(" | ")} | all)`,"claude_code").option("--project <path>","only sessions whose project path contains this").option("--rules <dir>","rules directory",B).option("--level <level>",`hide findings below this level (${L.join("|")})`).option("--format <format>","table, json, sarif, ndjson-ecs or ndjson-ocsf","table").option("--no-index","evaluate in memory, write nothing").option("--fail-on <level>","exit 1 when any finding is at or above this level").option("--db <path>","index database",K()).option("--root <dir>","Claude config dir or its projects dir (default ~/.claude)").option("--ignore <file>","ignore file (default ~/.retrohound/ignore.yml; a repo's own file is only read when passed here)").action((r)=>s(()=>Pk(r,e)));let i=n.command("rules").description("Inspect the loaded detection rules");return i.command("list").description("List rules and any that were rejected, with the reason").option("--rules <dir>","rules directory",B).action((r)=>s(()=>vu(r.rules,e))),i.command("show <rule>").description("Show one rule by name or id: metadata and its YAML").option("--rules <dir>","rules directory",B).action((r,o)=>s(()=>Eu(o.rules,r,e))),i.command("test [dir]").description("Check every rule has positive/negative tests that pass (for CI and your own rules)").option("--tests <dir>","tests directory (default: <dir>/../tests)").action((r,o)=>s(()=>zu(r??B,o.tests,e))),n.command("purge").description("Delete the local index database (it may be the only copy of deleted evidence)").option("--db <path>","index database",K()).option("--yes","actually delete; without it purge only says what it would delete").action((r)=>s(()=>qk(r,e))),ju(n,s,e),Fu(n,s,e),Ju(n,s,e),Du(n,s,e),Cu(n,s,e),wu(n,s,e),n}async function tf(e,t=_c()){let n=0,s=Dk(t,(i)=>n=i);try{return await s.parseAsync(e,{from:"user"}),n}catch(i){if(i instanceof oe)return i.exitCode===0?0:2;if(i instanceof I)return t.err(`retrohound: ${i.message}
363
+ `),2;return t.err(`retrohound: ${i.message}
364
+ `),3}}process.exitCode=await tf(process.argv.slice(2));