azdiffs 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 (118) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +67 -2
  3. package/THIRD_PARTY_NOTICES.md +4514 -0
  4. package/dist/cli.js +4768 -0
  5. package/dist/web/assets/_organization.___git._repository.pullrequest._pullRequestId-D7saE-jO.js +1 -0
  6. package/dist/web/assets/_organization.___git._repository.pullrequest._pullRequestId.commits._commitId-DOwGbBTQ.js +1 -0
  7. package/dist/web/assets/_organization.___git._repository.pullrequest._pullRequestId.commits.index-DzGjUdAz.js +1 -0
  8. package/dist/web/assets/_organization.___git._repository.pullrequest._pullRequestId.conflicts-Cjr34xFt.js +1 -0
  9. package/dist/web/assets/_organization.___git._repository.pullrequest._pullRequestId.files-BjjJ4Yb8.js +1 -0
  10. package/dist/web/assets/_organization.___git._repository.pullrequest._pullRequestId.index-iY62N_zR.js +1 -0
  11. package/dist/web/assets/_organization._project.___git._repository.pullrequest._pullRequestId-CrHRklAE.js +1 -0
  12. package/dist/web/assets/_organization._project.___git._repository.pullrequest._pullRequestId.commits._commitId-WC7fEryq.js +1 -0
  13. package/dist/web/assets/_organization._project.___git._repository.pullrequest._pullRequestId.commits.index-DzGjUdAz.js +1 -0
  14. package/dist/web/assets/_organization._project.___git._repository.pullrequest._pullRequestId.conflicts-BhUkafpV.js +1 -0
  15. package/dist/web/assets/_organization._project.___git._repository.pullrequest._pullRequestId.files-_RVmv4sD.js +1 -0
  16. package/dist/web/assets/_organization._project.___git._repository.pullrequest._pullRequestId.index-BJrgfbSD.js +1 -0
  17. package/dist/web/assets/_organization.index-hKcWlBrk.js +1 -0
  18. package/dist/web/assets/bat-qdxAdBWQ.js +1 -0
  19. package/dist/web/assets/bicep-CUHmPFLl.js +1 -0
  20. package/dist/web/assets/c-B0t_Dlza.js +1 -0
  21. package/dist/web/assets/cmake-Bj61d0ZC.js +1 -0
  22. package/dist/web/assets/commit-diff-view-CQeZylif.js +1 -0
  23. package/dist/web/assets/commits-view-B_TQ6AnD.js +13 -0
  24. package/dist/web/assets/conflicts-view-CnGEkjaP.js +8 -0
  25. package/dist/web/assets/core-D5Wev6DN.js +12 -0
  26. package/dist/web/assets/core-DfsS1UI1.js +12 -0
  27. package/dist/web/assets/cpp-DGR_3gb-.js +1 -0
  28. package/dist/web/assets/csharp-dmMxLVLW.js +1 -0
  29. package/dist/web/assets/css-CBDjU9xM.js +1 -0
  30. package/dist/web/assets/dart-CHZY9Xhz.js +1 -0
  31. package/dist/web/assets/dev.diff-DH1qvnWe.js +1 -0
  32. package/dist/web/assets/diff-woXpYk--.js +1 -0
  33. package/dist/web/assets/docker-IyjqRm3v.js +1 -0
  34. package/dist/web/assets/dotenv-CuH5my32.js +1 -0
  35. package/dist/web/assets/engine-javascript-C4Jk_eU2.js +141 -0
  36. package/dist/web/assets/engine-javascript-DpLLfDIa.js +141 -0
  37. package/dist/web/assets/engine-oniguruma-BfcA8yDp.js +1 -0
  38. package/dist/web/assets/engine-oniguruma-D--T0LcV.js +1 -0
  39. package/dist/web/assets/file-header-keBlejWu.js +49 -0
  40. package/dist/web/assets/files-view-Bu3bjrNf.js +1460 -0
  41. package/dist/web/assets/fsharp-D13ZGOAj.js +1 -0
  42. package/dist/web/assets/go-rLFTqkRN.js +1 -0
  43. package/dist/web/assets/grammars-DmFYBwmS.js +2 -0
  44. package/dist/web/assets/graphql-Br4JsJsw.js +1 -0
  45. package/dist/web/assets/groovy-CacY0gHj.js +1 -0
  46. package/dist/web/assets/hcl-Dh228itO.js +1 -0
  47. package/dist/web/assets/highlights-BJb1-tzP.js +1 -0
  48. package/dist/web/assets/highlights-CIgHM7EF-ByjlShdO.js +1 -0
  49. package/dist/web/assets/home-page-Y5jGxOav.js +1 -0
  50. package/dist/web/assets/html-Cyo-BRss.js +1 -0
  51. package/dist/web/assets/inbox-jP8QPtzZ.js +1 -0
  52. package/dist/web/assets/index-B297yCgq.js +11 -0
  53. package/dist/web/assets/index-CjZUV4-4.css +1 -0
  54. package/dist/web/assets/ini-B5eOa1yu.js +1 -0
  55. package/dist/web/assets/inter-cyrillic-ext-wght-normal-BOeWTOD4.woff2 +0 -0
  56. package/dist/web/assets/inter-cyrillic-wght-normal-DqGufNeO.woff2 +0 -0
  57. package/dist/web/assets/inter-greek-ext-wght-normal-DlzME5K_.woff2 +0 -0
  58. package/dist/web/assets/inter-greek-wght-normal-CkhJZR-_.woff2 +0 -0
  59. package/dist/web/assets/inter-latin-ext-wght-normal-DO1Apj_S.woff2 +0 -0
  60. package/dist/web/assets/inter-latin-wght-normal-Dx4kXJAl.woff2 +0 -0
  61. package/dist/web/assets/inter-vietnamese-wght-normal-CBcvBZtf.woff2 +0 -0
  62. package/dist/web/assets/java-r7y4bhRH.js +1 -0
  63. package/dist/web/assets/javascript-anBMbNY-.js +1 -0
  64. package/dist/web/assets/json-qhed-kSA.js +1 -0
  65. package/dist/web/assets/json5-BR5RXkoi.js +1 -0
  66. package/dist/web/assets/jsonc-CYpm1nAK.js +1 -0
  67. package/dist/web/assets/jsx-Bz0zcwM4.js +1 -0
  68. package/dist/web/assets/kotlin-DhhofPvG.js +1 -0
  69. package/dist/web/assets/langs_worker-Dyqdnub0.js +1 -0
  70. package/dist/web/assets/less-DVTAwKKz.js +1 -0
  71. package/dist/web/assets/lib-C2gVWm_O.js +1 -0
  72. package/dist/web/assets/lib-rf_jxHx0.js +1 -0
  73. package/dist/web/assets/lineChanges-Dw4ZXwVU.js +9 -0
  74. package/dist/web/assets/loader-BljfpPoZ.js +1 -0
  75. package/dist/web/assets/loader-C-ieOA_A.js +1 -0
  76. package/dist/web/assets/lua-mGgFNKt2.js +1 -0
  77. package/dist/web/assets/makefile-Dixweg8N.js +1 -0
  78. package/dist/web/assets/markdown-BYOwaDjH.js +1 -0
  79. package/dist/web/assets/overview-view-cEOsI9TY.js +2 -0
  80. package/dist/web/assets/php-DTciGFRO.js +1 -0
  81. package/dist/web/assets/pierre-dark-DMS-zpcK.js +1 -0
  82. package/dist/web/assets/pierre-light-BHq6aQNU.js +1 -0
  83. package/dist/web/assets/powershell-QtSnmXcu.js +1 -0
  84. package/dist/web/assets/properties-CHTuaqAW.js +1 -0
  85. package/dist/web/assets/proto-DB4EqR-F.js +1 -0
  86. package/dist/web/assets/pull-request-layout-DsDKURcq.js +35 -0
  87. package/dist/web/assets/python-gzcpVVnB.js +1 -0
  88. package/dist/web/assets/razor-3kKIP6Di.js +1 -0
  89. package/dist/web/assets/rolldown-runtime-BLXQ4ufn.js +1 -0
  90. package/dist/web/assets/routes-BruvNNp9.js +1 -0
  91. package/dist/web/assets/rust-DpiIf5JO.js +1 -0
  92. package/dist/web/assets/scala-BiFt_7mu.js +1 -0
  93. package/dist/web/assets/scss-DC8XIxmG.js +1 -0
  94. package/dist/web/assets/shellscript-CLZ0U2zV.js +1 -0
  95. package/dist/web/assets/shiki-DueA5xDi.js +1 -0
  96. package/dist/web/assets/shiki-DxP4sN1Z-caEk3oPG.js +1 -0
  97. package/dist/web/assets/shortcut-help-Cb0be4f3.js +1 -0
  98. package/dist/web/assets/sql-CEbI0hMM.js +1 -0
  99. package/dist/web/assets/stream-tokenizer-7LLwu37w-C37tUWGx.js +12 -0
  100. package/dist/web/assets/stream-tokenizer-B5Ok5N3S.js +4 -0
  101. package/dist/web/assets/svelte-iJTmbwM3.js +1 -0
  102. package/dist/web/assets/swift-CyEgAFGc.js +1 -0
  103. package/dist/web/assets/terraform-DswuEJGm.js +1 -0
  104. package/dist/web/assets/themes-BKc5vU6v.js +1 -0
  105. package/dist/web/assets/themes-SQq_asFq.js +1 -0
  106. package/dist/web/assets/toml-CcmNWLt0.js +1 -0
  107. package/dist/web/assets/tsx-udAQXfEw.js +1 -0
  108. package/dist/web/assets/typescript-bsJCZSQ-.js +1 -0
  109. package/dist/web/assets/utils-Tkdy0sOA.js +1 -0
  110. package/dist/web/assets/vb-DOwzaHZ0.js +1 -0
  111. package/dist/web/assets/vue-Dz_q6gML.js +1 -0
  112. package/dist/web/assets/wasm-C7N7kd8H.js +1 -0
  113. package/dist/web/assets/worker-B--T_fs_.js +7 -0
  114. package/dist/web/assets/xml-Bz5Z3pZJ.js +1 -0
  115. package/dist/web/assets/yaml-rwi0_p6S.js +1 -0
  116. package/dist/web/favicon.svg +5 -0
  117. package/dist/web/index.html +16 -0
  118. package/package.json +41 -4
@@ -0,0 +1,8 @@
1
+ import{r as e}from"./rolldown-runtime-BLXQ4ufn.js";import{$ as t,Bn as n,E as r,Ht as i,J as a,Lt as o,Nn as s,R as c,Rt as l,S as u,T as d,U as f,Ut as p,X as m,Y as h,_n as g,ft as _,lt as v,mt as y,nt as b,pn as x,rt as S,un as C,vn as w,w as T,yn as E,zn as D}from"./index-B297yCgq.js";import{r as ee,t as O}from"./shortcut-help-Cb0be4f3.js";import{A as te,B as ne,C as re,H as k,N as A,O as j,S as M,U as N,V as P,W as ie,_ as F,b as ae,g as I,j as L,k as R,nt as oe,r as se,s as z,v as ce}from"./pull-request-layout-DsDKURcq.js";import{n as B}from"./inbox-jP8QPtzZ.js";import{a as V,o as le}from"./commits-view-B_TQ6AnD.js";var H=e(n(),1);function U(e){let t=[e.base,e.source,e.target].map(e=>e.join(`
2
+ `)).join(`\0`),n=0x811c9dc5;for(let e=0;e<t.length;e++)n^=t.charCodeAt(e),n=Math.imul(n,16777619)>>>0;return`${n.toString(16)}:${t.length}`}function ue(e,t,n){let r={},i={};for(let e of t){let t=n.decisions[e.index];if(t===void 0)continue;let a=U(e);r[a]=t;let o=n.auto?.[e.index];o!==void 0&&(i[a]=o)}return Object.keys(r).length===0&&n.wholeFile===null&&n.fileEdit===null?null:{fileKey:e,regions:r,...Object.keys(i).length===0?{}:{auto:i},wholeFile:n.wholeFile,fileEdit:n.fileEdit}}function de(e,t,n){let r={},i={},a=new Set;for(let t of n){let n=U(t),o=e.regions[n];if(o!==void 0){r[t.index]=o,a.add(n);let s=e.auto?.[n];s!==void 0&&(i[t.index]=s)}}let o=e.fileKey===t,s=Object.keys(e.regions).filter(e=>!a.has(e)).length+ +(!o&&(e.wholeFile!==null||e.fileEdit!==null));return{choices:{decisions:r,wholeFile:o?e.wholeFile:null,fileEdit:o?e.fileEdit:null,...Object.keys(i).length===0?{}:{auto:i}},dropped:s}}function fe(e){return`azdiffs:conflicts:${e.organization.toLowerCase()}:${e.repositoryId.toLowerCase()}:${e.pullRequestId}`}function pe(e,t){let n=fe(t),r=null,i=()=>{if(r!==null)return r;r={};try{let t=e?.getItem(n)??null,i=t===null?null:JSON.parse(t);if(W(i))for(let[e,t]of Object.entries(i)){let n=be(t);n!==null&&(r[e]=n)}}catch{}return r},a=()=>{let t=i();try{Object.keys(t).length===0?e?.removeItem(n):e?.setItem(n,JSON.stringify(t))}catch{}};return{read:e=>i()[e]??null,write(e,t){let n=i();if(t===null){if(!(e in n))return;delete n[e]}else n[e]=t;a()}}}function me(){try{return globalThis.localStorage??null}catch{return null}}var he=new Set([`different-lines`,`same-change`,`formatting-only`]);function W(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var ge=e=>e===`source`||e===`target`,_e=e=>Array.isArray(e)&&e.every(e=>typeof e==`string`),ve=e=>Array.isArray(e)&&e.every(e=>Number.isSafeInteger(e)&&e>=0);function ye(e){if(!W(e))return null;switch(e.kind){case`combine`:case`source`:case`target`:return{kind:e.kind};case`both`:return ge(e.first)?{kind:`both`,first:e.first}:null;case`lines`:return ve(e.source)&&ve(e.target)?{kind:`lines`,source:e.source,target:e.target}:null;case`edited`:return _e(e.lines)?{kind:`edited`,lines:e.lines}:null;default:return null}}function be(e){if(!W(e)||typeof e.fileKey!=`string`||!W(e.regions))return null;let t={};for(let[n,r]of Object.entries(e.regions)){let e=ye(r);e!==null&&(t[n]=e)}let n={};if(W(e.auto))for(let[t,r]of Object.entries(e.auto))W(r)&&he.has(String(r.reason))&&(n[t]={reason:r.reason,dropped:ge(r.dropped)?r.dropped:null});return{fileKey:e.fileKey,regions:t,...Object.keys(n).length===0?{}:{auto:n},wholeFile:ge(e.wholeFile)?e.wholeFile:null,fileEdit:_e(e.fileEdit)?e.fileEdit:null}}function xe(e,t){let n=Array(e.length).fill(-1),r=0,i=0;for(let a of V(e,t)){let e=a.count??a.value.length;if(a.added)i+=e;else if(a.removed)r+=e;else{for(let t=0;t<e;t++)n[r+t]=i+t;r+=e,i+=e}}return n}function Se(e,t){let n=[],r=0,i=null;for(let a of V(e,t)){let e=a.count??a.value.length;!a.added&&!a.removed?(i!==null&&n.push(i),i=null,r+=e):(i??={start:r,end:r,lines:[]},a.removed?(r+=e,i.end=r):i.lines.push(...a.value))}return i!==null&&n.push(i),n}function Ce(e,t){return e.length===t.length&&e.every((e,n)=>e===t[n])}function we(e,t,n){let r=xe(e,t),i=xe(e,n),a=[],o=0,s=[],c=1,l=()=>{s.length>0&&a.push({kind:`clean`,origin:`unchanged`,lines:s,baseLine:c}),s=[]},u=0,d=0,f=0;for(;u<=e.length;){let p=u;for(;p<e.length&&((r[p]??-1)<0||(i[p]??-1)<0);)p++;let m=p<e.length?r[p]??t.length:t.length,h=p<e.length?i[p]??n.length:n.length,g=e.slice(u,p),_=t.slice(d,m),v=n.slice(f,h);if(g.length>0||_.length>0||v.length>0){let e=Ce(_,g),t=Ce(v,g);if(e&&t)s.length===0&&(c=u+1),s.push(...g);else if(e||t||Ce(_,v)){l();let n=e?`target`:t?`source`:`both`;a.push({kind:`clean`,origin:n,lines:e?v:_,baseLine:u+1})}else l(),a.push({kind:`conflict`,index:o++,base:g,source:_,target:v,baseLine:u+1,sourceHunks:Se(g,_),targetHunks:Se(g,v),hasBase:!0})}if(p>=e.length)break;s.length===0&&(c=p+1),s.push(e[p]??``),u=p+1,d=m+1,f=h+1}return l(),a}function Te(e,t){let n=[],r=0,i=[],a=[],o=1,s=1,c=()=>{(i.length!==0||a.length!==0)&&(n.push({kind:`conflict`,index:r++,base:[],source:i,target:a,baseLine:s,sourceHunks:i.length>0?[{start:0,end:0,lines:i}]:[],targetHunks:a.length>0?[{start:0,end:0,lines:a}]:[],hasBase:!1}),i=[],a=[])};for(let r of V(e,t)){let e=r.value;r.removed||r.added?(i.length===0&&a.length===0&&(s=o),r.removed?i.push(...e):(a.push(...e),o+=e.length)):(c(),n.push({kind:`clean`,origin:`both`,lines:e,baseLine:0}),o+=e.length)}return c(),n}function Ee(e,t,n){return e===null?Te(t,n):we(e,t,n)}function De(e){return e.filter(e=>e.kind===`conflict`)}function Oe(e,t){let n=t===`source`?e.source:e.target,r=t===`source`?e.sourceHunks:e.targetHunks,i=[],a=0,o=0,s=e=>{for(;a<e;)i.push({index:o,text:n[o]??``,changed:!1,baseText:null}),a++,o++};for(let t of r)s(t.start),t.lines.forEach((n,r)=>{let a=t.start+r<t.end?e.base[t.start+r]??null:null;i.push({index:o,text:n,changed:!0,baseText:a}),o++}),a=t.end;return s(e.base.length),i}function ke(e,t){return e.start===e.end||t.start===t.end?e.start<=t.end&&t.start<=e.end:e.start<t.end&&t.start<e.end}function Ae(e){if(!e.hasBase)return{ok:!1,reason:`No common version to combine from`};for(let t of e.sourceHunks)for(let n of e.targetHunks)if(ke(t,n))return{ok:!1,reason:`Both changed line ${e.baseLine+Math.max(t.start,n.start)}`};let t=[...e.sourceHunks.map(e=>({hunk:e,origin:`source`})),...e.targetHunks.map(e=>({hunk:e,origin:`target`}))].sort((e,t)=>e.hunk.start-t.hunk.start||(e.origin===`source`?-1:1)),n=[],r=0;for(let{hunk:i,origin:a}of t){for(;r<i.start;)n.push({text:e.base[r++]??``,origin:`base`});for(let e of i.lines)n.push({text:e,origin:a});r=Math.max(r,i.end)}for(;r<e.base.length;)n.push({text:e.base[r++]??``,origin:`base`});return{ok:!0,lines:n}}function je(e,t){let n=[],r=r=>{let i=r===`source`?e.sourceHunks:e.targetHunks,a=new Set(r===`source`?t.source:t.target),o=0,s=0;for(let e of i)o+=e.start-s,e.lines.forEach((t,i)=>{if(a.has(o)){let a=e.start===e.end?e.start-.5:e.start+Math.min(i,e.end-e.start-1);n.push({position:a,order:(r===`source`?0:1)*1e6+o,line:{text:t,origin:r}})}o++}),s=e.end};if(r(`source`),r(`target`),!e.hasBase)return n.sort((e,t)=>e.order-t.order).map(e=>e.line);n.sort((e,t)=>e.position-t.position||e.order-t.order);let i=[],a=0,o=e=>{let t=[];for(;a<n.length;){let r=n[a];if(r===void 0||!e(r.position))break;t.push(r.line),a++}return t};for(let t=0;t<=e.base.length&&(i.push(...o(e=>e<t)),t!==e.base.length);t++){let n=o(e=>e===t);n.length>0?i.push(...n):i.push({text:e.base[t]??``,origin:`base`})}return i}function Me(e,t){if(e===null)return[{text:t,changed:!0}];let n=[];for(let r of le(e,t)){if(r.removed)continue;let e=n.at(-1),t=r.added===!0;e!==void 0&&e.changed===t?e.text+=r.value:n.push({text:r.value,changed:t})}return n}var Ne=/^\s*["']?([A-Za-z_][\w.-]*)["']?\s*[:=]/,Pe=/\b(?:function|def|class|const|let|var|fn|func|type|interface)\s+([A-Za-z_$][\w$]*)/;function Fe(e){return Ne.exec(e)?.[1]??Pe.exec(e)?.[1]??null}function Ie(e){let t=t=>Oe(e,t).find(e=>e.changed)?.text??null,n=t(`source`),r=t(`target`);if(n===null||r===null)return null;let i=Fe(n);return i!==null&&i===Fe(r)?i:null}var Le={decisions:{},wholeFile:null,fileEdit:null};function Re(e=Le){return{current:e,history:[]}}function G(e,t){let{auto:n,...r}=t;return{current:n!==void 0&&Object.keys(n).length>0?t:r,history:[...e.history,e.current].slice(-100)}}function ze(e,t){let{current:n}=e;switch(t.type){case`decide`:return G(e,{decisions:{...n.decisions,[t.region]:t.decision},wholeFile:null,fileEdit:null,auto:Be(n.auto,t.region)});case`fill`:{if(t.fills.length===0)return e;let r={...n.decisions},i={...n.auto};for(let e of t.fills)r[e.region]=e.decision,i[e.region]={reason:e.reason,dropped:e.dropped};return G(e,{decisions:r,wholeFile:null,fileEdit:null,auto:i})}case`toggle-line`:{let r=n.decisions[t.region],i=r?.kind===`lines`?{source:r.source,target:r.target}:{source:[],target:[]},a=i[t.side],o=a.includes(t.index)?a.filter(e=>e!==t.index):[...a,t.index].sort((e,t)=>e-t),s={...i,[t.side]:o},c={...n.decisions};return s.source.length===0&&s.target.length===0?delete c[t.region]:c[t.region]={kind:`lines`,...s},G(e,{decisions:c,wholeFile:null,fileEdit:null,auto:Be(n.auto,t.region)})}case`whole-file`:return G(e,{...n,wholeFile:t.side,fileEdit:null,auto:{}});case`edit-file`:return G(e,{...n,wholeFile:null,fileEdit:t.lines,auto:{}});case`reset`:return G(e,Le);case`undo`:{let t=e.history.at(-1);return t===void 0?e:{current:t,history:e.history.slice(0,-1)}}}}function Be(e,t){let n={...e};return delete n[t],n}function Ve(e,t){let n=new Set([...Object.keys(e.decisions).map(Number),...Object.keys(t.decisions).map(Number)]);for(let r of[...n].sort((e,t)=>e-t))if(JSON.stringify(e.decisions[r])!==JSON.stringify(t.decisions[r]))return r;return null}function K(e,t){switch(t.kind){case`combine`:{let t=Ae(e);return t.ok?t.lines:null}case`source`:return e.source.map(e=>({text:e,origin:`source`}));case`target`:return e.target.map(e=>({text:e,origin:`target`}));case`both`:{let n=e.source.map(e=>({text:e,origin:`source`})),r=e.target.map(e=>({text:e,origin:`target`}));return t.first===`source`?[...n,...r]:[...r,...n]}case`lines`:return je(e,t);case`edited`:return t.lines.map(e=>({text:e,origin:`edited`}))}}function He(e,t,n){if(t.wholeFile!==null){let e=t.wholeFile;return{lines:n[e].map(t=>({text:t,origin:e})),undecided:[]}}if(t.fileEdit!==null)return{lines:t.fileEdit.map(e=>({text:e,origin:`edited`})),undecided:[]};let r=[],i=[];for(let a of e){if(a.kind===`clean`){let e=a.origin===`source`||a.origin===`target`?a.origin:`base`;r.push(...a.lines.map(t=>({text:t,origin:e})));continue}let e=t.decisions[a.index],o=e===void 0?null:K(a,e);o===null?(i.push(a.index),r.push(...Ue(a,n.labels))):r.push(...o)}return{lines:r,undecided:i}}function Ue(e,t){return[{text:`<<<<<<< ${t.source}`,origin:`edited`},...e.source.map(e=>({text:e,origin:`source`})),{text:`=======`,origin:`edited`},...e.target.map(e=>({text:e,origin:`target`})),{text:`>>>>>>> ${t.target}`,origin:`edited`}]}var We=/^(<{7} |={7}$|>{7} )/;function Ge(e){let t=e.findIndex(e=>We.test(e));return t<0?null:t+1}function q(e,t,n){if(t.wholeFile!==null||t.fileEdit!==null)return null;let r=e.filter(e=>{let n=t.decisions[e.index];return n===void 0||K(e,n)===null}).map(e=>e.index);return r.find(e=>e>n)??r[0]??null}function Ke(e,t){return q(e,t,-1)===null}function qe(e,t){switch(e.kind){case`combine`:return`Combined both changes`;case`source`:return`Used ${t.source}`;case`target`:return`Used ${t.target}`;case`both`:return`Used both, ${t[e.first]} first`;case`lines`:{let t=e.source.length+e.target.length;return`Picked ${t} ${t===1?`line`:`lines`}`}case`edited`:return`Edited by hand`}}var Je=e=>e.map(e=>e.replace(/\s+/g,``)),Ye=(e,t)=>{let n=Je(e),r=Je(t);return n.length===r.length&&n.every((e,t)=>e===r[t])};function Xe(e){if(Ae(e).ok)return{decision:{kind:`combine`},reason:`different-lines`,dropped:null};if(Ye(e.source,e.target))return{decision:{kind:`target`},reason:`same-change`,dropped:null};if(!e.hasBase)return null;let t=Ye(e.source,e.base),n=Ye(e.target,e.base);return t&&!n?{decision:{kind:`target`},reason:`formatting-only`,dropped:`source`}:n&&!t?{decision:{kind:`source`},reason:`formatting-only`,dropped:`target`}:null}function Ze(e,t){if(t.wholeFile!==null||t.fileEdit!==null)return[];let n=[];for(let r of e){let e=t.decisions[r.index];if(e!==void 0&&K(r,e)!==null)continue;let i=Xe(r);i!==null&&n.push({...i,region:r.index})}return n}function Qe(e){return`${e.baseBlob??``}:${e.sourceBlob}:${e.targetBlob}`}async function $e(e,t,n){let r={filled:0,files:0,left:0};for(let i of e){if(i.kind!==`content`||i.resolutionStatus===`resolved`)continue;let[e,a,o]=await Promise.all([i.baseBlob===null?null:t(i.baseBlob),t(i.sourceBlob),t(i.targetBlob)]);if(a.kind!==`text`||o.kind!==`text`||e!==null&&e.kind!==`text`)continue;let s=De(Ee(e?.file.lines??null,a.file.lines,o.file.lines)),c=Qe(i),l=n.read(i.path),u=l===null?Le:de(l,c,s).choices,d=Ze(s,u),f=ze(Re(u),{type:`fill`,fills:d}).current,p=s.filter(e=>f.decisions[e.index]===void 0);r.left+=f.wholeFile===null&&f.fileEdit===null?p.length:0,d.length!==0&&(n.write(i.path,ue(c,s,f)),r.filled+=d.length,r.files+=1)}return r}var et=(e,t)=>e!==null&&t!==null&&e.toLowerCase()===t.toLowerCase();async function tt(e,t){let{conflict:n}=t,r,i;try{[r,i]=await Promise.all([e.pullRequest(),e.conflicts()])}catch(e){return{kind:`failed`,error:e,sent:!1,saved:!1}}if(!et(r.lastMergeSourceCommit,n.mergeSourceCommit))return{kind:`stale`,pullRequest:r,branch:r.sourceBranch};if(!et(r.lastMergeTargetCommit,n.mergeTargetCommit))return{kind:`stale`,pullRequest:r,branch:r.targetBranch};let a=i.find(e=>e.conflictId===n.conflictId);if(a===void 0)return{kind:`gone`};let o=a.resolvedBy;if(a.resolutionStatus===`resolved`&&n.resolutionStatus!==`resolved`&&o!==null&&!et(o.id,t.currentUserId)&&!t.replaceConfirmed)return{kind:`confirm-replace`,by:o,date:a.resolvedDate};try{return{kind:`saved`,conflict:await e.resolve(t.resolution)}}catch(t){try{let r=(await e.conflicts()).find(e=>e.conflictId===n.conflictId);return r===void 0?{kind:`failed`,error:t,sent:!0,saved:null}:a.resolutionStatus!==`resolved`&&r.resolutionStatus===`resolved`?{kind:`saved`,conflict:r}:{kind:`failed`,error:t,sent:!0,saved:r.resolutionStatus!==a.resolutionStatus&&null}}catch{return{kind:`failed`,error:t,sent:!0,saved:null}}}}function nt(e,t){let n=`Your choices are kept.`,r=C(e.error,`unauthorized`);return r||C(e.error,`network`)?e.sent?e.saved===!1||r?t.method===`pat`?`Azure DevOps refused the save without saying why, and nothing was saved. Your token can read this pull request but probably cannot write: a Personal Access Token needs Code (Read & write). ${n}`:`Azure DevOps refused the save without saying why, and nothing was saved. Your account may not be allowed to contribute to this pull request. ${n}`:`Could not reach Azure DevOps. The resolution may have been saved; the list was reloaded. ${n}`:`Could not reach Azure DevOps; nothing was saved. ${n}`:t.describe(e.error).replace(`Your text is kept`,`Your choices are kept`)}function rt(e){return e.split(`/`).filter(e=>e.length>0).at(-1)??e}function it(e){return(Array.from(e).find(e=>/\p{L}|\p{N}/u.test(e))??`?`).toUpperCase()}function at(e,t){let n=rt(e),r=rt(t);r===n&&(r=t);let i=it(n),a=it(rt(t)),o=i===a;return{source:e,target:t,letters:{source:o?`S`:i,target:o?`T`:a},short:{source:n,target:r}}}function ot(e,t){let{source:n,target:r}=t.short;switch(e.type){case`editEdit`:return`Both changed`;case`addAdd`:return`Added on both`;case`editDelete`:return`Changed in ${n}, deleted in ${r}`;case`deleteEdit`:return`Deleted in ${n}, changed in ${r}`;case`rename1to2`:return`Renamed differently on each side`;case`rename2to1`:return`Two files renamed to the same name`;case`renameRename`:return`Renamed on both sides`;case`renameAdd`:return`Renamed in ${n}, added in ${r}`;case`addRename`:return`Added in ${n}, renamed in ${r}`;case`renameDelete`:return`Renamed in ${n}, deleted in ${r}`;case`deleteRename`:return`Deleted in ${n}, renamed in ${r}`;case`directoryFile`:case`fileDirectory`:case`directoryChild`:return`A file and a folder share this name`;case`none`:return`A conflict azdiffs cannot read`}}function st(e,t){if(e.kind!==`unsupported`)return``;let n=e=>e===null?null:e.split(`/`).at(-1)??e,r=n(e.sourceNewPath),i=n(e.targetNewPath);return e.type===`rename1to2`&&r!==null&&i!==null?`${t.short.source} renamed it to ${r}, ${t.short.target} to ${i}.`:ot(e,t)}function ct(e,t){let{source:n,target:r}=t.short;if(e.kind===`content`)switch(e.mergeType){case`takeSourceContent`:return`Used ${n}'s file`;case`takeTargetContent`:return`Used ${r}'s file`;case`userMerged`:case`autoMerged`:return`Merged content`;case`undecided`:return null}return e.kind===`pickOne`?e.action===`undecided`?null:e.type===`editDelete`==(e.action===`pickSourceAction`)?`Kept the file, ${e.type===`editDelete`?n:r}'s version`:`Deleted the file`:null}function lt(e,t){switch(e.reason){case`different-lines`:return`The branches changed different lines: combined`;case`same-change`:return`Same change on both; kept ${t.short.target}'s formatting`;case`formatting-only`:{let n=e.dropped??`source`,r=n===`source`?`target`:`source`;return`${t.short[n]} only changed whitespace here; used ${t.short[r]}`}}}function ut(e,t=Date.now()){if(e===null)return``;let n=Date.parse(e);if(Number.isNaN(n))return``;let r=Math.max(0,Math.round((t-n)/6e4));if(r<1)return`just now`;if(r<60)return`${r} min ago`;let i=Math.round(r/60);return i<24?`${i} h ago`:new Date(n).toLocaleDateString(`en-US`,{month:`short`,day:`numeric`})}var J=D(),dt={source:`azd-chip-source`,target:`azd-chip-target`},ft={source:`bg-side-source`,target:`bg-side-target`},pt={source:`azd-row-source`,target:`azd-row-target`},mt={source:`azd-mark-source`,target:`azd-mark-target`};function ht({side:e,names:t,short:n=!1}){let r=n?t.short[e]:t[e];return(0,J.jsxs)(`span`,{className:`inline-flex max-w-full min-w-0 items-center gap-1.5 rounded-full py-px pr-2 pl-1 font-mono text-xs ${dt[e]}`,title:t[e],children:[(0,J.jsx)(gt,{side:e,names:t}),(0,J.jsx)(`span`,{className:`truncate`,children:r})]})}function gt({side:e,names:t}){return(0,J.jsx)(`span`,{"aria-hidden":`true`,className:`inline-grid size-4 shrink-0 place-items-center rounded-full font-sans text-[10px] leading-none font-semibold text-[var(--azd-canvas)] ${ft[e]}`,children:t.letters[e]})}function _t({origin:e,names:t}){return e===`source`||e===`target`?(0,J.jsxs)(`span`,{className:`inline-flex w-4 justify-center font-sans text-[11px] font-semibold ${e===`source`?`text-side-source`:`text-side-target`}`,title:`From ${t[e]}`,children:[(0,J.jsx)(`span`,{"aria-hidden":`true`,children:t.letters[e]}),(0,J.jsxs)(`span`,{className:`sr-only`,children:[`from `,t[e],`: `]})]}):e===`edited`?(0,J.jsxs)(`span`,{className:`inline-flex text-muted`,title:`Edited by hand`,children:[(0,J.jsx)(f,{className:`size-3.5`}),(0,J.jsx)(`span`,{className:`sr-only`,children:`edited: `})]}):(0,J.jsx)(`span`,{"aria-hidden":`true`,className:`inline-block size-4`})}function Y({children:e}){return(0,J.jsx)(`span`,{"aria-hidden":`true`,className:`rounded border border-border-strong px-1 font-mono text-[10px] leading-4 font-normal text-muted`,children:e})}function X({number:e,tag:t,tone:n,children:r,dim:i=!1,struck:a=!1,tagless:o=!1}){return(0,J.jsxs)(`div`,{className:`grid min-h-6 ${o?`grid-cols-[2.75rem_minmax(0,1fr)]`:`grid-cols-[2.75rem_1.5rem_minmax(0,1fr)]`} items-start font-mono text-xs leading-6 ${n??``} ${i?`text-muted`:`text-fg`}`,children:[(0,J.jsx)(`span`,{className:`pr-2.5 text-right text-[11px] text-muted tabular-nums select-none`,children:e}),!o&&(0,J.jsx)(`span`,{className:`flex h-6 items-center`,children:t}),(0,J.jsx)(`span`,{className:`pr-3 break-words whitespace-pre-wrap ${a?`line-through decoration-[var(--azd-muted)] opacity-70`:``}`,children:r})]})}function vt({segments:e,side:t}){return(0,J.jsx)(J.Fragment,{children:e.map((e,n)=>e.changed&&e.text.trim().length>0?(0,J.jsxs)(`mark`,{className:`text-inherit ${mt[t]}`,children:[(0,J.jsx)(`span`,{className:`sr-only`,children:`changed: `}),e.text]},n):(0,J.jsx)(`span`,{children:e.text},n))})}function Z(e){return e.length===0?` `:e}function yt(e){let t=e.lastIndexOf(`/`);return{name:e.slice(t+1),folder:t>0?e.slice(1,t+1):``}}function Q({conflict:e,names:t,progress:n,tools:r,save:i,markRef:a,blockedReason:o,onMarkResolved:s,showMark:c=!0,footer:l,children:u}){let{name:d,folder:f}=yt(e.path);return(0,J.jsxs)(`article`,{"aria-label":e.path,className:`overflow-hidden rounded-[10px] bg-surface shadow-[0_0_0_1px_var(--azd-border)]`,"data-testid":`conflict-file`,"data-path":e.path,children:[(0,J.jsxs)(`header`,{className:`flex min-h-11 flex-wrap items-center gap-x-2.5 gap-y-1 border-b border-border bg-header py-1.5 pr-2.5 pl-3.5`,children:[(0,J.jsxs)(`h2`,{className:`flex min-w-0 items-baseline gap-1.5 text-[13px]`,title:e.path,children:[f.length>0&&(0,J.jsx)(`span`,{className:`truncate text-muted`,children:f}),(0,J.jsx)(`span`,{className:`font-semibold text-fg-strong`,children:d})]}),(0,J.jsx)(`span`,{className:`rounded-full border border-border bg-raised px-2 py-px text-xs text-warning`,children:ot(e,t)}),n!==void 0&&(0,J.jsx)(`span`,{className:`text-xs text-muted tabular-nums`,"data-testid":`conflict-file-progress`,children:n}),(0,J.jsxs)(`div`,{className:`ml-auto flex flex-wrap items-center justify-end gap-1`,children:[r,c&&o!==null&&(0,J.jsx)(`span`,{className:`px-1.5 text-xs text-muted`,"data-testid":`mark-resolved-reason`,children:o}),c&&(0,J.jsxs)(`button`,{ref:a,type:`button`,onClick:s,disabled:o!==null||i.busy,"aria-describedby":o===null?void 0:`azd-mark-reason`,className:`inline-flex shrink-0 items-center justify-center gap-1.5 rounded-[7px] text-[13px] font-medium whitespace-nowrap transition-colors disabled:cursor-not-allowed disabled:opacity-50 h-8 px-3 bg-primary text-primary-fg hover:opacity-90 h-7 px-2.5`,"data-testid":`mark-resolved`,children:[i.busy?`Saving…`:`Mark resolved`,!i.busy&&(0,J.jsx)(`span`,{"aria-hidden":`true`,className:`rounded border border-[color-mix(in_srgb,var(--azd-primary-fg)_30%,transparent)] px-1 font-mono text-[10px] leading-4 font-normal opacity-70`,children:`⌘↵`})]}),c&&o!==null&&(0,J.jsx)(`span`,{id:`azd-mark-reason`,className:`sr-only`,children:o})]})]}),i.problem!==null&&(0,J.jsx)(`p`,{role:`alert`,className:`border-b border-border px-3.5 py-2 text-[13px] text-danger`,"data-testid":`save-problem`,children:i.problem}),u,(0,J.jsx)(bt,{...l})]})}function bt({next:e,regionKeys:t}){return(0,J.jsxs)(`footer`,{className:`flex flex-wrap items-center gap-x-3.5 gap-y-1 bg-header px-3.5 py-2 text-xs text-muted`,children:[(0,J.jsxs)(`span`,{className:`flex flex-wrap items-center gap-x-3.5 gap-y-1`,children:[t&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`span`,{children:[(0,J.jsx)(Y,{children:`n`}),` `,(0,J.jsx)(Y,{children:`p`}),` next / previous conflict`]}),(0,J.jsxs)(`span`,{children:[(0,J.jsx)(Y,{children:`1`}),` `,(0,J.jsx)(Y,{children:`2`}),` `,(0,J.jsx)(Y,{children:`3`}),` use one side / both`]}),(0,J.jsxs)(`span`,{children:[(0,J.jsx)(Y,{children:`space`}),` pick line`]})]}),(0,J.jsxs)(`span`,{children:[(0,J.jsx)(Y,{children:`j`}),` `,(0,J.jsx)(Y,{children:`k`}),` files`]}),(0,J.jsxs)(`span`,{children:[(0,J.jsx)(Y,{children:`?`}),` all keys`]})]}),e!==null&&(0,J.jsxs)(`button`,{type:`button`,onClick:e.onSelect,className:`inline-flex shrink-0 items-center justify-center gap-1.5 rounded-[7px] text-[13px] font-medium whitespace-nowrap transition-colors disabled:cursor-not-allowed disabled:opacity-50 h-7 px-2 text-muted hover:bg-hover hover:text-fg ml-auto h-6`,"data-testid":`next-file`,children:[`Next: `,yt(e.path).name,(0,J.jsx)(r,{className:`size-3.5`})]})]})}function xt(e){return e===void 0||e.kind===`edited`?null:e.kind}function St({region:e,count:t,decision:n,names:r,active:i,expanded:a,showOriginal:o,editing:s,canUndo:c,headerRef:l,intents:u,onToggleOriginal:d,onExpand:f,onEdit:p,onEditDone:h,auto:g}){let _=(0,H.useId)(),v=n===void 0?null:K(e,n),y=v!==null,b=Ae(e),S=Ie(e),C=Ct(e),w=y?qe(n,r.short):null;return y&&!a&&!s?(0,J.jsxs)(`fieldset`,{"aria-labelledby":_,className:`min-w-0 border-b border-border`,"data-testid":`conflict-region-${e.index}`,"data-state":`decided`,children:[(0,J.jsxs)(`header`,{className:`flex flex-wrap items-center gap-x-2.5 gap-y-1 px-3.5 py-2`,children:[(0,J.jsx)(T,{className:`size-3.5 text-added`}),(0,J.jsxs)(`h3`,{id:_,ref:l,tabIndex:-1,className:`text-[13px] font-medium text-fg outline-none`,children:[C,(0,J.jsxs)(`span`,{className:`sr-only`,children:[`, conflict `,e.index+1,` of `,t,`, resolved`]})]}),(0,J.jsx)(`span`,{className:`text-xs text-muted`,children:w}),(0,J.jsx)(`button`,{type:`button`,onClick:()=>{f(),u.focus()},className:`${x} ml-auto`,children:`Change`})]}),(0,J.jsx)(Dt,{lines:v,names:r,startLine:e.baseLine})]}):(0,J.jsxs)(`fieldset`,{"aria-labelledby":_,className:`min-w-0 border-b border-border ${i&&t>1?`outline-2 -outline-offset-2 outline-[var(--azd-accent)]`:``}`,"data-testid":`conflict-region-${e.index}`,"data-state":y?`decided`:`open`,onFocusCapture:u.focus,children:[(0,J.jsxs)(`header`,{className:`flex flex-wrap items-center gap-x-2.5 gap-y-1 px-3.5 py-2`,children:[y?(0,J.jsx)(T,{className:`size-3.5 text-added`}):(0,J.jsx)(`span`,{"aria-hidden":`true`,className:`size-2 rounded-full bg-warning`}),(0,J.jsxs)(`h3`,{id:_,ref:l,tabIndex:-1,className:`text-[13px] font-medium text-fg outline-none`,children:[C,(0,J.jsxs)(`span`,{className:`sr-only`,children:[`, conflict `,e.index+1,` of `,t,y?`, resolved`:``]})]}),g!==void 0&&(0,J.jsxs)(`span`,{className:`rounded-full border border-border bg-raised px-2 py-px text-xs text-fg`,"data-testid":`auto-filled`,children:[`Auto-filled`,(0,J.jsxs)(`span`,{className:`text-muted`,children:[` · `,g]})]}),(0,J.jsx)(`span`,{className:`text-xs text-muted ${g===void 0?``:`sr-only`}`,children:e.hasBase?S===null?`Both branches changed these lines`:(0,J.jsxs)(J.Fragment,{children:[`Both branches changed `,(0,J.jsx)(`span`,{className:`font-mono text-fg`,children:S})]}):`The two versions differ here`}),e.hasBase&&(0,J.jsxs)(`button`,{type:`button`,"aria-pressed":o,onClick:d,className:`inline-flex shrink-0 items-center justify-center gap-1.5 rounded-[7px] text-[13px] font-medium whitespace-nowrap transition-colors disabled:cursor-not-allowed disabled:opacity-50 h-7 px-2 text-muted hover:bg-hover hover:text-fg ml-auto aria-pressed:text-fg`,children:[o?`Hide original`:`Show original`,` `,(0,J.jsx)(Y,{children:`o`})]})]}),o&&e.hasBase&&(0,J.jsxs)(`div`,{className:`border-t border-border bg-canvas`,"data-testid":`conflict-original`,children:[(0,J.jsx)(`p`,{className:`px-3.5 pt-1.5 text-xs text-muted`,children:`Original (before either branch)`}),(0,J.jsx)(`div`,{className:`pb-1`,children:e.base.length===0?(0,J.jsx)(`p`,{className:`px-3.5 pb-1 text-xs text-muted`,children:`No lines (both branches added here)`}):e.base.map((t,n)=>(0,J.jsx)(X,{number:e.baseLine+n,dim:!0,struck:!0,children:Z(t)},n))})]}),(0,J.jsxs)(`div`,{className:`grid grid-cols-1 border-t border-border @3xl:grid-cols-2`,children:[(0,J.jsx)(Tt,{side:`source`,caption:`this pull request`,region:e,decision:n,names:r,onToggle:e=>u.toggleLine(`source`,e)}),(0,J.jsx)(Tt,{side:`target`,caption:`target`,region:e,decision:n,names:r,onToggle:e=>u.toggleLine(`target`,e)})]}),(0,J.jsx)(Et,{region:e,decision:n,names:r,combineReason:b.ok?null:e.hasBase?b.reason:null,canCombine:b.ok,onDecide:u.decide,onEdit:p}),(0,J.jsxs)(`div`,{className:`mx-3.5 mb-3.5 overflow-hidden rounded-[8px] shadow-[0_0_0_1px_var(--azd-border-strong)]`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2 bg-header px-3 py-1.5 text-xs text-muted`,children:[(0,J.jsx)(`span`,{className:`font-semibold text-fg`,children:`Result`}),(0,J.jsxs)(`span`,{children:[`what `,(0,J.jsx)(`span`,{className:`font-mono`,children:r.target}),` gets`]}),(0,J.jsxs)(`button`,{type:`button`,onClick:u.undo,disabled:!c,className:`${x} ml-auto h-6`,children:[(0,J.jsx)(m,{className:`size-3.5`}),`Undo `,(0,J.jsx)(Y,{children:`⌘Z`})]})]}),s?(0,J.jsx)(Ot,{initial:(v??wt(e)).map(e=>e.text),onSave:e=>{u.decide({kind:`edited`,lines:e}),h()},onCancel:h}):v===null?(0,J.jsx)(`p`,{className:`bg-code px-3 py-2.5 text-xs text-muted`,"data-testid":`conflict-result-empty`,children:`Choose above, pick lines, or edit. The result shows here.`}):(0,J.jsx)(Dt,{lines:v,names:r,startLine:e.baseLine})]})]})}function Ct(e){let t=e.hasBase?e.base.length:e.target.length,n=e.baseLine;return t<=1?`Line ${Math.max(n,1)}`:`Lines ${n}–${n+t-1}`}function wt(e){return[...e.source.map(e=>({text:e,origin:`source`})),...e.target.map(e=>({text:e,origin:`target`}))]}function Tt({side:e,caption:t,region:n,decision:r,names:i,onToggle:a}){let o=Oe(n,e),s=r?.kind===`lines`?new Set(e===`source`?r.source:r.target):r?.kind===e||r?.kind===`both`||r?.kind===`combine`?new Set(o.filter(e=>e.changed).map(e=>e.index)):new Set;return(0,J.jsxs)(`div`,{className:`min-w-0 border-border @3xl:[&+&]:border-l [&+&]:border-t @3xl:[&+&]:border-t-0`,children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between gap-2 border-b border-border bg-surface px-3 py-1.5 text-xs text-muted`,children:[(0,J.jsx)(ht,{side:e,names:i}),(0,J.jsx)(`span`,{children:t})]}),(0,J.jsx)(`div`,{className:`bg-code py-0.5`,children:o.length===0?(0,J.jsx)(`p`,{className:`px-3 py-1.5 text-xs text-muted`,children:`Removed these lines`}):o.map(t=>t.changed?(0,J.jsxs)(`label`,{className:`grid min-h-6 cursor-pointer grid-cols-[2.75rem_minmax(0,1fr)] items-start font-mono text-xs leading-6 text-fg ${pt[e]}`,children:[(0,J.jsx)(`span`,{className:`flex h-6 items-center justify-end pr-2.5`,children:(0,J.jsx)(`input`,{type:`checkbox`,checked:s.has(t.index),onChange:()=>a(t.index),"aria-label":`Pick from ${i[e]}: ${t.text.trim()||`empty line`}`,className:`size-3.5 ${e===`source`?`accent-[var(--azd-side-source)]`:`accent-[var(--azd-side-target)]`}`})}),(0,J.jsx)(`span`,{className:`pr-3 break-words whitespace-pre-wrap`,children:t.text.length===0?(0,J.jsx)(`span`,{className:`text-muted`,children:`(empty line)`}):(0,J.jsx)(vt,{segments:Me(t.baseText,t.text),side:e})})]},t.index):(0,J.jsxs)(X,{dim:!0,tagless:!0,children:[Z(t.text),(0,J.jsx)(`span`,{className:`ml-2 font-sans text-[11px]`,children:`unchanged`})]},t.index))})]})}function Et({region:e,decision:t,names:n,canCombine:r,combineReason:i,onDecide:a,onEdit:o}){let s=xt(t),c=t?.kind===`both`?t.first:`source`,l=t?.kind===`lines`?t.source.length+t.target.length:0,u=[...r?[{key:`combine`,label:(0,J.jsxs)(J.Fragment,{children:[`Combine changes`,(0,J.jsx)(`span`,{className:`rounded-full bg-[var(--azd-selected)] px-1.5 text-[11px] font-normal text-muted`,children:`recommended`})]}),name:`Combine changes (recommended)`,hint:`c`,decision:{kind:`combine`}}]:[],{key:`source`,label:`Use ${n.short.source}`,name:`Use ${n.short.source} (${n.source})`,hint:`1`,decision:{kind:`source`}},{key:`target`,label:`Use ${n.short.target}`,name:`Use ${n.short.target} (${n.target})`,hint:`2`,decision:{kind:`target`}},{key:`both`,label:`Use both`,name:`Use both, ${n[c]} first`,hint:`3`,decision:{kind:`both`,first:c}},...s===`lines`&&t!==void 0?[{key:`lines`,label:`Picked lines · ${l}`,name:`Picked lines · ${l}`,decision:t}]:[]],d=(0,H.useRef)([]),p=Math.max(0,u.findIndex(e=>e.key===s));return(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 px-3.5 py-2.5`,children:[(0,J.jsx)(`div`,{role:`radiogroup`,"aria-label":`Resolve ${Ct(e).toLowerCase()}`,onKeyDown:e=>{let t=d.current.indexOf(document.activeElement);if(t<0)return;let n=null;e.key===`ArrowRight`||e.key===`ArrowDown`?n=(t+1)%u.length:(e.key===`ArrowLeft`||e.key===`ArrowUp`)&&(n=(t-1+u.length)%u.length),n!==null&&(e.preventDefault(),d.current[n]?.focus())},className:`flex flex-wrap items-center gap-2`,children:u.map((e,t)=>(0,J.jsxs)(`button`,{ref:e=>{d.current[t]=e},type:`button`,role:`radio`,"aria-checked":s===e.key,"aria-label":e.name,tabIndex:t===p?0:-1,onClick:()=>{e.key!==`lines`&&a(e.decision)},className:`${E} h-7 gap-1.5 bg-surface px-2.5 text-[12.5px] aria-checked:border-border-strong aria-checked:bg-[var(--azd-selected)] aria-checked:text-fg-strong`,"data-testid":`choice-${e.key}`,children:[s===e.key&&(0,J.jsx)(T,{className:`size-3`}),e.label,e.hint!==void 0&&(0,J.jsx)(Y,{children:e.hint})]},e.key))}),t?.kind===`both`&&(0,J.jsxs)(`button`,{type:`button`,onClick:()=>a({kind:`both`,first:t.first===`source`?`target`:`source`}),className:`inline-flex shrink-0 items-center justify-center gap-1.5 rounded-[7px] text-[13px] font-medium whitespace-nowrap transition-colors disabled:cursor-not-allowed disabled:opacity-50 h-7 px-2 text-muted hover:bg-hover hover:text-fg h-7`,"data-testid":`swap-order`,children:[(0,J.jsx)(h,{className:`size-3.5`}),n.short[t.first===`source`?`target`:`source`],` first`]}),(0,J.jsx)(`span`,{"aria-hidden":`true`,className:`mx-1 h-5 w-px bg-border`}),(0,J.jsxs)(`button`,{type:`button`,onClick:o,className:`${x} h-7`,children:[(0,J.jsx)(f,{className:`size-3.5`}),`Edit result `,(0,J.jsx)(Y,{children:`e`})]}),i!==null&&(0,J.jsxs)(`span`,{className:`ml-auto text-xs text-muted`,"data-testid":`combine-reason`,children:[`Can't combine: `,i.charAt(0).toLowerCase(),i.slice(1)]})]})}function Dt({lines:e,names:t,startLine:n}){return e.length===0?(0,J.jsx)(`p`,{className:`bg-code px-3 py-2 text-xs text-muted`,"data-testid":`conflict-result`,children:`No lines: these lines are removed.`}):(0,J.jsx)(`div`,{className:`bg-code py-0.5`,"data-testid":`conflict-result`,children:e.map((e,r)=>(0,J.jsx)(X,{number:n>0?n+r:void 0,tone:e.origin===`source`||e.origin===`target`?pt[e.origin]:``,tag:(0,J.jsx)(_t,{origin:e.origin,names:t}),children:Z(e.text)},r))})}function Ot({initial:e,onSave:t,onCancel:n}){let[r,i]=(0,H.useState)(()=>e.join(`
3
+ `)),[a,o]=(0,H.useState)(null),s=(0,H.useId)(),c=()=>{let e=r.length===0?[]:r.replace(/\r\n/g,`
4
+ `).split(`
5
+ `),n=Ge(e);n===null?t(e):o(`Line ${n} is a conflict marker. Remove it to save.`)};return(0,J.jsxs)(`div`,{className:`space-y-2 bg-code p-2.5`,children:[(0,J.jsx)(`label`,{htmlFor:s,className:`sr-only`,children:`Result of this conflict`}),(0,J.jsx)(`textarea`,{id:s,value:r,onChange:e=>{i(e.target.value),o(null)},onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)?(e.preventDefault(),c()):e.key===`Escape`&&(e.preventDefault(),n())},autoFocus:!0,spellCheck:!1,rows:Math.min(16,Math.max(3,e.length+1)),"aria-describedby":a===null?void 0:`${s}-problem`,className:`w-full resize-y rounded-[7px] border border-border bg-canvas px-2.5 py-2 font-mono text-xs leading-6 text-fg focus:border-[var(--azd-focus)] focus:outline-none`,"data-testid":`region-editor`}),a!==null&&(0,J.jsx)(`p`,{id:`${s}-problem`,role:`alert`,className:`text-xs text-danger`,children:a}),(0,J.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,J.jsxs)(`span`,{className:`mr-auto text-xs text-muted`,children:[(0,J.jsx)(Y,{children:`⌘↵`}),` save · `,(0,J.jsx)(Y,{children:`esc`}),` cancel`]}),(0,J.jsx)(`button`,{type:`button`,onClick:n,className:x,children:`Cancel`}),(0,J.jsx)(`button`,{type:`button`,onClick:c,className:E,children:`Use this result`})]})]})}function kt(e,t,n,r){if(n===void 0||r===void 0||e.baseBlob!==null&&t===void 0)return`loading`;for(let e of[t,n,r])if(e!==void 0&&e.kind!==`text`)return{reason:e.kind===`too-large`?`This file is larger than 8 MB, so it can only be taken whole.`:`This file is not UTF-8 text, so it can only be taken whole.`};return n.kind!==`text`||r.kind!==`text`?`loading`:{base:t?.kind===`text`?t.file:null,source:n.file,target:r.file}}function At({conflict:e,sides:t,names:n,store:r,save:i,footer:o}){let s=(0,H.useMemo)(()=>Ee(t.base?.lines??null,t.source.lines,t.target.lines),[t]),c=(0,H.useMemo)(()=>De(s),[s]),l=`${e.baseBlob??``}:${e.sourceBlob}:${e.targetBlob}`,[u]=(0,H.useState)(()=>{let t=r.read(e.path);return t===null?null:de(t,l,c)}),[p,m]=(0,H.useReducer)(ze,u?.choices,e=>Re(e)),h=p.current;(0,H.useEffect)(()=>{r.write(e.path,ue(l,c,h))},[r,e.path,l,c,h]);let[g,_]=(0,H.useState)(()=>q(c,h,-1)??0),[v,y]=(0,H.useState)(new Set),[b,S]=(0,H.useState)(new Set),[C,w]=(0,H.useState)(null),[T,E]=(0,H.useState)(!1),[D,ee]=(0,H.useState)(!1),O=(0,H.useRef)(new Map),te=e=>{let t=O.current.get(e);return t===void 0&&(t=(0,H.createRef)(),O.current.set(e,t)),t},ne=(0,H.useRef)(null),k=e=>{_(e),window.setTimeout(()=>{let t=O.current.get(e)?.current;t?.focus({preventScroll:!0}),t?.scrollIntoView({block:`nearest`,behavior:`auto`})},0)},A=He(s,h,{source:t.source.lines,target:t.target.lines,labels:{source:n.source,target:n.target}}),j=Ke(c,h),N=h.fileEdit===null?null:Ge(h.fileEdit),P=j?0:A.undecided.length,ie=c.length-A.undecided.length,F=Ze(c,h),ae=()=>{if(F.length===0)return;let e=ze(p,{type:`fill`,fills:F});m({type:`fill`,fills:F});let t=q(c,e.current,-1);t===null?window.setTimeout(()=>ne.current?.focus(),0):k(t)},I=(e,t)=>{let n=c.find(t=>t.index===e);if(n===void 0||K(n,t)===null)return;let r=ze(p,{type:`decide`,region:e,decision:t});m({type:`decide`,region:e,decision:t}),y(t=>{let n=new Set(t);return n.delete(e),n});let i=q(c,r.current,e);i===null?window.setTimeout(()=>ne.current?.focus(),0):k(i)},L=()=>h.wholeFile===`source`?{kind:`takeSource`}:h.wholeFile===`target`?{kind:`takeTarget`}:!j||N!==null?null:{kind:`userMerged`,content:oe({...t.target,lines:A.lines.map(e=>e.text)})},R=()=>{let e=L();e===null||i.busy||i.run(e)},se=j?N===null?null:`Line ${N} is a conflict marker`:`${P} ${P===1?`conflict`:`conflicts`} left`;re({n:()=>{c.length>0&&k((g+1)%c.length)},p:()=>{c.length>0&&k((g-1+c.length)%c.length)},c:()=>I(g,{kind:`combine`}),1:()=>I(g,{kind:`source`}),2:()=>I(g,{kind:`target`}),3:()=>I(g,{kind:`both`,first:`source`}),e:()=>w(g),o:()=>S(e=>{let t=new Set(e);return t.has(g)?t.delete(g):t.add(g),t})},C===null&&!T&&h.wholeFile===null&&h.fileEdit===null);let z=()=>{let e=p.history.at(-1);if(e===void 0)return;let t=Ve(e,h);m({type:`undo`}),t!==null&&(y(e=>new Set(e).add(t)),k(t))},B=(0,H.useRef)({markResolved:R,undo:z,canUndo:p.history.length>0});B.current={markResolved:R,undo:z,canUndo:p.history.length>0},(0,H.useEffect)(()=>{let e=e=>{if(!(!(e.metaKey||e.ctrlKey)||e.altKey||e.defaultPrevented)){if(e.key===`Enter`&&!M(e))e.preventDefault(),B.current.markResolved();else if(e.key.toLowerCase()===`z`&&!e.shiftKey&&!M(e)){if(!B.current.canUndo)return;e.preventDefault(),B.current.undo()}}};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]);let V=(0,J.jsx)(ce,{label:`Take whole file`,entries:[{kind:`heading`,label:`Drops the other side’s changes to this file`},...[`source`,`target`].map(e=>({kind:`radio`,label:`Use ${n.short[e]}'s file`,checked:h.wholeFile===e,onSelect:()=>m({type:`whole-file`,side:e}),testId:`whole-file-${e}`}))],trigger:e=>(0,J.jsxs)(`button`,{type:`button`,...e,ref:e.ref,className:x,children:[`Take whole file`,(0,J.jsx)(d,{className:`size-3.5`})]})}),le=c.length===0?`Merges cleanly`:`${c.length} ${c.length===1?`conflict`:`conflicts`} · ${ie} decided`;return(0,J.jsxs)(Q,{conflict:e,names:n,progress:le,tools:(0,J.jsxs)(J.Fragment,{children:[F.length>0&&(0,J.jsxs)(`button`,{type:`button`,onClick:ae,className:`inline-flex shrink-0 items-center justify-center gap-1.5 rounded-[7px] text-[13px] font-medium whitespace-nowrap transition-colors disabled:cursor-not-allowed disabled:opacity-50 h-7 px-2 text-muted hover:bg-hover hover:text-fg`,title:`Pre-fill the blocks one rule can decide; review them, then Mark resolved`,"data-testid":`fill-safe`,children:[(0,J.jsx)(a,{className:`size-3.5`}),`Fill safe choices (`,F.length,`)`]}),V,(0,J.jsxs)(`button`,{type:`button`,onClick:()=>E(!0),className:x,disabled:T,children:[(0,J.jsx)(f,{className:`size-3.5`}),`Edit file`]}),(0,J.jsxs)(`button`,{type:`button`,"aria-pressed":D,onClick:()=>ee(!D),className:`${x} aria-pressed:text-fg`,disabled:!j||N!==null,title:j?void 0:`Decide every conflict first`,children:[`Review what `,n.short.target,` gets`]})]}),save:i,markRef:ne,blockedReason:se,onMarkResolved:R,footer:o,children:[u!==null&&u.dropped>0&&(0,J.jsxs)(`p`,{className:`border-b border-border px-3.5 py-2 text-xs text-muted`,role:`status`,children:[u.dropped,` earlier`,` `,u.dropped===1?`choice no longer fits`:`choices no longer fit`,` after new commits and `,u.dropped===1?`was`:`were`,` set aside.`]}),D&&j&&N===null?(0,J.jsx)(Lt,{target:t.target.lines,result:A.lines.map(e=>e.text),names:n}):h.wholeFile===null?T?(0,J.jsx)(Ft,{initial:A.lines.map(e=>e.text),onSave:e=>{m({type:`edit-file`,lines:e}),E(!1)},onCancel:()=>E(!1)}):h.fileEdit===null?(0,J.jsx)(jt,{regions:s,conflicts:c,choices:p,names:n,active:g,expanded:v,original:b,editing:C,headerRef:te,onFocus:_,onDecide:I,onToggleLine:(e,t,n)=>m({type:`toggle-line`,region:e,side:t,index:n}),onUndo:z,onToggleOriginal:e=>S(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),onExpand:e=>y(t=>new Set(t).add(e)),onEdit:e=>w(e),onEditDone:()=>w(null),autoMark:e=>{let t=h.auto?.[e];return t===void 0?void 0:lt(t,n)}}):(0,J.jsx)(It,{lines:h.fileEdit,names:n,markerLine:N,onEdit:()=>E(!0),onDiscard:()=>m({type:`edit-file`,lines:null})}):(0,J.jsx)(Pt,{side:h.wholeFile,names:n,onUndo:()=>m({type:`whole-file`,side:null})})]})}function jt({regions:e,conflicts:t,choices:n,names:r,active:i,expanded:a,original:o,editing:s,headerRef:c,onFocus:l,onDecide:u,onToggleLine:d,onUndo:f,onToggleOriginal:p,onExpand:m,onEdit:h,onEditDone:g,autoMark:_}){return(0,J.jsx)(`div`,{className:`@container`,children:e.map((e,v)=>e.kind===`clean`?(0,J.jsx)(Nt,{region:e,names:r},`clean-${v}`):(0,J.jsx)(St,{region:e,count:t.length,decision:n.current.decisions[e.index],names:r,active:i===e.index,expanded:a.has(e.index)||i===e.index||n.current.auto?.[e.index]!==void 0,auto:_(e.index),showOriginal:o.has(e.index),editing:s===e.index,canUndo:n.history.length>0,headerRef:c(e.index),intents:{decide:t=>u(e.index,t),toggleLine:(t,n)=>d(e.index,t,n),focus:()=>l(e.index),undo:f},onToggleOriginal:()=>p(e.index),onExpand:()=>m(e.index),onEdit:()=>h(e.index),onEditDone:g},`conflict-${e.index}`))})}var Mt=3;function Nt({region:e,names:t}){let[n,r]=(0,H.useState)(!1);if(e.origin===`source`||e.origin===`target`){let n=e.origin,r=e.baseLine,i=e.lines.length<=1?`Line ${r}`:`Lines ${r}–${r+e.lines.length-1}`;return(0,J.jsxs)(`div`,{className:`border-b border-border`,"data-testid":`clean-change`,children:[(0,J.jsxs)(`p`,{className:`flex flex-wrap items-center gap-x-2 px-3.5 pt-1.5 pb-1 text-xs text-muted`,children:[(0,J.jsx)(`span`,{className:`text-added`,"aria-hidden":`true`,children:`✓`}),e.lines.length===0?`${i} removed cleanly by ${t.short[n]}`:`${i} merged cleanly from ${t.short[n]}`]}),(0,J.jsx)(`div`,{className:`bg-code pb-0.5`,children:e.lines.map((e,t)=>(0,J.jsx)(X,{tone:pt[n],children:Z(e)},t))})]})}let i=e.lines;return i.length<=Mt||n?(0,J.jsx)(`div`,{className:`border-b border-border bg-code py-0.5`,children:i.map((t,n)=>(0,J.jsx)(X,{number:e.baseLine>0?e.baseLine+n:void 0,dim:!0,children:Z(t)},n))}):(0,J.jsxs)(`button`,{type:`button`,onClick:()=>r(!0),className:`flex w-full items-center gap-2 border-b border-border bg-canvas px-3.5 py-1.5 text-left text-xs text-muted hover:text-fg`,children:[(0,J.jsx)(`span`,{"aria-hidden":`true`,children:`⋯`}),i.length,` `,e.origin===`both`?`identical`:`unchanged`,` lines`,(0,J.jsx)(`span`,{className:`sr-only`,children:`, show them`})]})}function Pt({side:e,names:t,onUndo:n}){let r=e===`source`?`target`:`source`;return(0,J.jsxs)(`div`,{className:`space-y-2 px-3.5 py-3 text-[13px]`,"data-testid":`whole-file-note`,children:[(0,J.jsxs)(`p`,{className:`text-fg`,children:[`Using `,(0,J.jsx)(`span`,{className:`font-mono`,children:t[e]}),`'s whole file.`]}),(0,J.jsxs)(`p`,{className:`text-muted`,children:[`This drops `,t.short[r],`'s changes to this file, including the ones that merged cleanly.`]}),(0,J.jsx)(`button`,{type:`button`,onClick:n,className:E,children:`Choose per conflict instead`})]})}function Ft({initial:e,onSave:t,onCancel:n}){let[r,i]=(0,H.useState)(()=>e.join(`
6
+ `)),[a,o]=(0,H.useState)(null),s=(0,H.useId)(),c=()=>{let e=r.length===0?[]:r.replace(/\r\n/g,`
7
+ `).split(`
8
+ `),n=Ge(e);n===null?t(e):o(`Line ${n} is a conflict marker. Remove the markers to keep the edit.`)};return(0,J.jsxs)(`div`,{className:`space-y-2 p-3.5`,children:[(0,J.jsxs)(`label`,{htmlFor:s,className:`block text-xs text-muted`,children:[`The whole merged file. Undecided conflicts show Git markers (`,(0,J.jsx)(`span`,{className:`font-mono`,children:`<<<<<<<`}),`); remove them before saving.`]}),(0,J.jsx)(`textarea`,{id:s,value:r,onChange:e=>{i(e.target.value),o(null)},onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)?(e.preventDefault(),c()):e.key===`Escape`&&(e.preventDefault(),n())},autoFocus:!0,spellCheck:!1,rows:Math.min(28,Math.max(8,e.length+1)),className:`w-full resize-y rounded-[7px] border border-border bg-canvas px-2.5 py-2 font-mono text-xs leading-6 text-fg focus:border-[var(--azd-focus)] focus:outline-none`,"data-testid":`file-editor`}),a!==null&&(0,J.jsx)(`p`,{role:`alert`,className:`text-xs text-danger`,children:a}),(0,J.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,J.jsxs)(`span`,{className:`mr-auto text-xs text-muted`,children:[(0,J.jsx)(Y,{children:`⌘↵`}),` keep · `,(0,J.jsx)(Y,{children:`esc`}),` cancel`]}),(0,J.jsx)(`button`,{type:`button`,onClick:n,className:x,children:`Cancel`}),(0,J.jsx)(`button`,{type:`button`,onClick:c,className:E,children:`Keep this file`})]})]})}function It({lines:e,names:t,markerLine:n,onEdit:r,onDiscard:i}){return(0,J.jsxs)(`div`,{"data-testid":`edited-file`,children:[(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 px-3.5 py-2 text-xs text-muted`,children:[(0,J.jsx)(f,{className:`size-3.5`}),`Edited by hand`,n!==null&&(0,J.jsxs)(`span`,{className:`text-danger`,children:[`· line `,n,` is a conflict marker`]}),(0,J.jsx)(`button`,{type:`button`,onClick:r,className:`${x} ml-auto`,children:`Edit`}),(0,J.jsx)(`button`,{type:`button`,onClick:i,className:x,children:`Discard edit`})]}),(0,J.jsx)(Dt,{lines:e.map(e=>({text:e,origin:`edited`})),names:t,startLine:1})]})}function Lt({target:e,result:t,names:n}){let r=[];for(let n of V(e,t)){let e=n.added?`added`:n.removed?`removed`:`same`;for(let t of n.value)r.push({kind:e,text:t})}let i=r.some(e=>e.kind!==`same`);return(0,J.jsxs)(`div`,{"data-testid":`review-diff`,children:[(0,J.jsxs)(`p`,{className:`px-3.5 py-2 text-xs text-muted`,children:[`Changes to `,(0,J.jsx)(`span`,{className:`font-mono`,children:n.target}),`'s version of this file.`]}),i?(0,J.jsx)(`div`,{className:`bg-code py-0.5`,children:r.map((e,t)=>(0,J.jsx)(X,{tone:e.kind===`added`?`bg-[color-mix(in_srgb,var(--azd-added)_12%,transparent)]`:e.kind===`removed`?`bg-[color-mix(in_srgb,var(--azd-deleted)_12%,transparent)]`:``,tag:(0,J.jsxs)(`span`,{className:e.kind===`added`?`text-added`:e.kind===`removed`?`text-deleted`:``,children:[e.kind===`added`?`+`:e.kind===`removed`?`−`:``,(0,J.jsx)(`span`,{className:`sr-only`,children:e.kind===`added`?`Added: `:e.kind===`removed`?`Removed: `:``})]}),dim:e.kind===`same`,children:Z(e.text)},t))}):(0,J.jsxs)(`p`,{className:`px-3.5 pb-3 text-[13px] text-fg`,children:[`The file stays as it is in `,n.short.target,`.`]})]})}function Rt({conflict:e,scope:t,location:n,names:r,store:i,save:a,footer:o}){let[s,c]=(0,H.useState)(!1);if(e.resolutionStatus===`resolved`&&!s&&e.kind!==`unsupported`)return(0,J.jsx)(Yt,{conflict:e,names:r,footer:o,onChange:()=>c(!0)});switch(e.kind){case`content`:return(0,J.jsx)(Bt,{conflict:e,scope:t,names:r,store:i,save:a,footer:o});case`pickOne`:return(0,J.jsx)(Kt,{conflict:e,scope:t,names:r,save:a,footer:o});case`unsupported`:return(0,J.jsx)(Q,{conflict:e,names:r,save:{...a,problem:null},blockedReason:null,onMarkResolved:()=>{},showMark:!1,footer:o,children:(0,J.jsxs)(`div`,{className:`space-y-2 px-3.5 py-3 text-[13px]`,"data-testid":`unsupported-conflict`,children:[(0,J.jsx)(`p`,{className:`text-fg`,children:st(e,r)}),(0,J.jsx)(`p`,{className:`text-muted`,children:`azdiffs can't resolve this kind of conflict yet. Resolve it in Azure DevOps; the other files can still be resolved here.`}),(0,J.jsx)(j,{href:l(n),children:`Open in Azure DevOps`})]})})}}function zt(e,t){return[N(e,t[0]??null),N(e,t[1]??null),N(e,t[2]??null)]}function Bt({conflict:e,scope:t,names:n,store:r,save:i,footer:a}){let[o,s,c]=zt(t,[e.baseBlob,e.sourceBlob,e.targetBlob]),l=[o,s,c].find(e=>e.isError),u=kt(e,o.data,s.data,c.data);return l===void 0?u===`loading`?(0,J.jsx)(Q,{conflict:e,names:n,save:i,blockedReason:`Loading`,onMarkResolved:()=>{},footer:{...a,regionKeys:!1},children:(0,J.jsxs)(`div`,{className:`space-y-2 px-3.5 py-4`,"aria-busy":`true`,children:[(0,J.jsx)(`span`,{className:`sr-only`,children:`Loading the file's versions`}),[70,52,64].map(e=>(0,J.jsx)(`div`,{className:`azd-pulse h-3 rounded bg-raised`,style:{width:`${e}%`}},e))]})}):`reason`in u?(0,J.jsx)(qt,{conflict:e,names:n,save:i,footer:a,reason:u.reason,sizes:{source:Vt(s.data),target:Vt(c.data)}}):(0,J.jsx)(At,{conflict:e,sides:u,names:n,store:r,save:i,footer:{...a,regionKeys:!0}}):(0,J.jsx)(Q,{conflict:e,names:n,save:i,blockedReason:`File versions did not load`,onMarkResolved:()=>{},footer:{...a,regionKeys:!1},children:(0,J.jsxs)(`p`,{role:`alert`,className:`flex items-center gap-2 px-3.5 py-3 text-[13px] text-muted`,children:[`The file's versions could not be loaded.`,(0,J.jsx)(`button`,{type:`button`,onClick:()=>{for(let e of[o,s,c])e.isError&&e.refetch()},className:`font-medium text-fg hover:underline`,children:`Try again`})]})})}function Vt(e){return e===void 0?null:e.kind===`text`?e.bytes.byteLength:e.size}function Ht(e){return e===null?``:e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1024/1024).toFixed(1)} MB`}function Ut({label:e,cards:t,value:n,onChange:r}){let i=(0,H.useId)();return(0,J.jsxs)(`fieldset`,{className:`space-y-2 p-3.5`,children:[(0,J.jsx)(`legend`,{className:`sr-only`,children:e}),t.map(e=>(0,J.jsxs)(`label`,{className:`grid cursor-pointer grid-cols-[1.125rem_minmax(0,1fr)] gap-x-2.5 rounded-[8px] border border-border bg-canvas p-3 hover:border-border-strong has-[:checked]:border-border-strong has-[:checked]:bg-[var(--azd-selected)] has-[:focus-visible]:outline-2 has-[:focus-visible]:outline-[var(--azd-focus)]`,"data-testid":`choice-card-${e.value}`,children:[(0,J.jsx)(`input`,{type:`radio`,name:i,checked:n===e.value,onChange:()=>r(e.value),className:`mt-1 size-3.5 focus-visible:outline-none`}),(0,J.jsxs)(`span`,{className:`min-w-0 space-y-0.5`,children:[(0,J.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2 text-[13px] font-medium text-fg`,children:[e.title,e.chip]}),(0,J.jsx)(`span`,{className:`block text-xs text-muted`,children:e.detail}),e.preview]})]},e.value))]})}function Wt({lines:e}){let[t,n]=(0,H.useState)(!1);return e===null?null:(0,J.jsxs)(`span`,{className:`block pt-1.5`,children:[(0,J.jsxs)(`button`,{type:`button`,"aria-expanded":t,onClick:e=>{e.preventDefault(),n(!t)},className:`${x} -ml-2 h-6`,children:[t?(0,J.jsx)(d,{className:`size-3.5`}):(0,J.jsx)(r,{className:`size-3.5`}),t?`Hide the file`:`Show the file`]}),t&&(0,J.jsx)(`span`,{className:`mt-1 block max-h-72 overflow-auto rounded-[6px] bg-code py-0.5`,children:e.map((e,t)=>(0,J.jsx)(X,{number:t+1,children:Z(e)},t))})]})}function Gt(e){return e?.kind===`text`?e.file.lines:null}function Kt({conflict:e,scope:t,names:n,save:r,footer:i}){let[a,o]=(0,H.useState)(null),s=e.type===`editDelete`?`source`:`target`,c=s===`source`?`target`:`source`,[l]=zt(t,[s===`source`?e.sourceBlob:e.targetBlob]),u=Gt(l.data),d=[{value:s,title:`Keep the file`,chip:(0,J.jsx)(ht,{side:s,names:n,short:!0}),detail:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`span`,{className:`font-mono`,children:n.target}),` keeps the file with`,` `,n.short[s],`'s changes.`]}),preview:(0,J.jsx)(Wt,{lines:u})},{value:c,title:`Delete the file`,chip:(0,J.jsx)(ht,{side:c,names:n,short:!0}),detail:(0,J.jsxs)(J.Fragment,{children:[`As `,n.short[c],` did. `,n.short[s],`'s changes to it are lost.`]})}],f=()=>{a!==null&&r.run({kind:a===`source`?`pickSource`:`pickTarget`})};return Jt(f),(0,J.jsx)(Q,{conflict:e,names:n,save:r,blockedReason:a===null?`Choose one`:null,onMarkResolved:f,footer:{...i,regionKeys:!1},children:(0,J.jsx)(Ut,{label:`Keep or delete the file`,cards:d,value:a,onChange:o})})}function qt({conflict:e,names:t,save:n,footer:r,reason:i,sizes:a}){let[o,s]=(0,H.useState)(null),c=[`source`,`target`].map(e=>({value:e,title:`Use ${t.short[e]}'s file`,chip:(0,J.jsx)(ht,{side:e,names:t,short:!0}),detail:Ht(a[e])})),l=()=>{if(o===null)return;let e=o===`source`?{kind:`takeSource`}:{kind:`takeTarget`};n.run(e)};return Jt(l),(0,J.jsxs)(Q,{conflict:e,names:t,save:n,blockedReason:o===null?`Choose one`:null,onMarkResolved:l,footer:{...r,regionKeys:!1},children:[(0,J.jsx)(`p`,{className:`px-3.5 pt-3 text-xs text-muted`,children:i}),(0,J.jsx)(Ut,{label:`Which version to keep`,cards:c,value:o,onChange:s})]})}function Jt(e){let[t]=(0,H.useState)(()=>({current:e}));t.current=e,(0,H.useEffect)(()=>{let e=e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&!e.altKey&&(e.preventDefault(),t.current())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t])}function Yt({conflict:e,names:t,footer:n,onChange:r}){let i=ct(e,t),a=e.resolvedBy?.displayName,o=ut(e.resolvedDate);return(0,J.jsx)(Q,{conflict:e,names:t,save:{busy:!1,problem:null,run:()=>{}},blockedReason:null,onMarkResolved:()=>{},showMark:!1,footer:{...n,regionKeys:!1},tools:(0,J.jsx)(`button`,{type:`button`,onClick:r,className:`${w} h-7 px-2.5`,children:`Change`}),children:(0,J.jsxs)(`p`,{className:`flex flex-wrap items-center gap-2 px-3.5 py-3 text-[13px]`,"data-testid":`resolved-file`,children:[(0,J.jsx)(T,{className:`size-4 text-added`}),(0,J.jsx)(`span`,{className:`font-medium text-fg`,children:i??`Resolved`}),(a!==void 0||o.length>0)&&(0,J.jsxs)(`span`,{className:`text-muted`,children:[a===void 0?``:`by ${a}`,a!==void 0&&o.length>0?` · `:``,o]})]})})}var Xt=2e3,Zt=12e4;function $(e){return e.resolutionStatus===`resolved`?`resolved`:e.kind===`unsupported`?`elsewhere`:`open`}var Qt={open:`To resolve`,resolved:`Resolved`,elsewhere:`Resolve in Azure DevOps`};function $t(e){let t={open:0,resolved:1,elsewhere:2};return[...e].sort((e,n)=>t[$(e)]-t[$(n)]||e.path.localeCompare(n.path))}function en({file:e,onFileChange:n}){let{location:r,shortForm:i,pullRequest:o,scope:l}=z(),d=(0,H.useMemo)(()=>({organization:l.organization,project:l.project,repositoryId:l.repositoryId,pullRequestId:l.pullRequestId}),[l]),f=(0,H.useMemo)(()=>at(o.sourceBranch,o.targetBranch),[o.sourceBranch,o.targetBranch]),p=ie(d,o),m=(0,H.useMemo)(()=>$t(p.data??[]),[p.data]),h=m.find(t=>t.path===e)??m.find(e=>$(e)===`open`)??m[0]??null,g=k(m),_=te(r,i),[v,y]=(0,H.useState)(!1),[x,C]=(0,H.useState)(null),[T,E]=(0,H.useState)(``),D=h===null?-1:m.indexOf(h),A=e=>{e!==void 0&&n(e.path)};re({j:()=>A(m[D+1]),k:()=>A(m[D-1]),"?":()=>y(!0)});let j=s(),[M,N]=(0,H.useState)(!1),[P,F]=(0,H.useState)(null),[I,L]=(0,H.useState)(0),oe=m.filter(e=>e.kind===`content`&&e.resolutionStatus!==`resolved`).length,ce=async()=>{if(!M){N(!0);try{let e=await $e(m,e=>j.fetchQuery(ne(d,e)),V.store);F(e.filled===0?`Nothing safe to fill: every remaining conflict needs your choice.`:`Filled ${e.filled} ${e.filled===1?`block`:`blocks`} in ${e.files} ${e.files===1?`file`:`files`}. ${e.left===0?`Review them, then Mark resolved.`:`${e.left} ${e.left===1?`block is`:`blocks are`} left to you.`}`),L(e=>e+1)}catch{F(`Some file versions could not be loaded; nothing was filled for them.`)}finally{N(!1)}}},V=ln(d,o,f,{onSaved:e=>{let t=(p.data??[]).filter(t=>t.conflictId!==e.conflictId&&t.resolutionStatus!==`resolved`);E(t.length===0?`File resolved. No conflicts left.`:`File resolved. ${t.length} ${t.length===1?`file`:`files`} left.`);let r=$t(t).find(e=>e.kind!==`unsupported`);r!==void 0&&n(r.path)},onStale:e=>C(`New commits were pushed to ${e}. The conflicts were recalculated.`)}),le=(0,J.jsxs)(S,{top:(0,J.jsxs)(R,{location:r,shortForm:i,page:{tab:`overview`},className:`flex h-8 items-center gap-1.5 rounded-[7px] px-2 text-[13px] text-muted hover:bg-hover hover:text-fg`,testId:`back-to-overview`,children:[(0,J.jsx)(u,{className:`size-3.5`}),`Back`]}),children:[(0,J.jsx)(`div`,{className:`shrink-0 px-3 pb-2`,children:(0,J.jsx)(ee,{value:`conflicts`,filesCount:null,onChange:e=>_(e===`files`?{tab:`files`}:{tab:`files-commits`})})}),(0,J.jsx)(`nav`,{"aria-label":`Conflicted files`,className:`azd-scrollbar min-h-0 flex-1 overflow-y-auto pb-3`,children:(0,J.jsx)(nn,{conflicts:m,current:h,names:f,onSelect:A})})]}),U;return U=o.status===`active`?p.isPending?(0,J.jsx)(sn,{}):p.data===void 0?(0,J.jsx)(B,{error:p.error,organization:r.organization,onRetry:()=>void p.refetch()}):m.length===0?o.mergeStatus===`conflicts`?(0,J.jsxs)(b,{title:`Azure DevOps lists no conflicts yet`,children:[(0,J.jsxs)(`p`,{children:[`It reports conflicts with `,o.targetBranch,` but has not listed them. This can take a moment after a push.`]}),(0,J.jsx)(`button`,{type:`button`,onClick:()=>void p.refetch(),className:w,children:`Check again`})]}):(0,J.jsx)(b,{title:`No conflicts`,children:(0,J.jsxs)(`p`,{children:[o.sourceBranch,` merges into `,o.targetBranch,` without conflicts.`]})}):(0,J.jsxs)(`div`,{className:`mx-auto w-full max-w-[1100px] space-y-3 px-5 pt-4 pb-10`,children:[(0,J.jsxs)(`p`,{className:`flex items-start gap-2.5 rounded-[10px] border border-border bg-surface px-3 py-2.5 text-[13px] leading-snug text-fg`,"data-testid":`conflicts-banner`,children:[(0,J.jsx)(c,{className:`mt-0.5 size-4 text-accent`}),(0,J.jsxs)(`span`,{children:[`Your resolutions go into the merge into`,` `,(0,J.jsx)(`span`,{className:`font-mono font-medium`,children:o.targetBranch}),` when this pull request completes. `,(0,J.jsx)(`span`,{className:`font-mono`,children:o.sourceBranch}),` isn't changed, so the same conflict can come back if it merges anywhere else.`]})]}),!g.done&&oe>0&&(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 text-[13px]`,children:[(0,J.jsxs)(`button`,{type:`button`,onClick:()=>void ce(),disabled:M,className:`inline-flex shrink-0 items-center justify-center gap-1.5 rounded-[7px] text-[13px] font-medium whitespace-nowrap transition-colors disabled:cursor-not-allowed disabled:opacity-50 h-8 px-3 border border-border bg-raised text-fg hover:border-border-strong hover:bg-hover`,"data-testid":`fill-safe-all`,children:[(0,J.jsx)(a,{className:`size-3.5`}),M?`Filling…`:`Fill safe choices in all files`]}),(0,J.jsx)(`span`,{className:`text-xs text-muted`,"data-testid":`fill-safe-all-result`,role:`status`,children:P??`Pre-fills only blocks one rule can decide. You review each file before saving.`})]}),x!==null&&(0,J.jsx)(`p`,{role:`status`,className:`rounded-[10px] border border-border bg-raised px-3 py-2 text-[13px] text-fg`,"data-testid":`conflicts-notice`,children:x}),g.done?(0,J.jsx)(cn,{pullRequest:o,total:m.length,names:f}):h!==null&&(0,J.jsx)(Rt,{conflict:h,scope:d,location:r,names:f,store:V.store,save:V.control(h),footer:{regionKeys:!1,next:tn(m,h,A)}},`${h.conflictId}:${h.mergeSourceCommit}:${h.mergeTargetCommit}:${I}`)]}):(0,J.jsx)(b,{title:`Nothing to resolve`,children:(0,J.jsxs)(`p`,{children:[`This pull request is `,o.status,`. Conflicts are resolved on active pull requests.`]})}),(0,J.jsxs)(t,{sidebar:le,sidebarLabel:`Conflicts`,sidebarWidth:280,topBar:(0,J.jsx)(se,{mode:`review`,merge:!1,tools:m.length>0?(0,J.jsx)(on,{resolved:g.resolved,total:m.length}):void 0}),children:[(0,J.jsx)(`div`,{className:`azd-scrollbar min-h-0 flex-1 overflow-y-auto`,children:U}),(0,J.jsx)(`p`,{"aria-live":`polite`,className:`sr-only`,"data-testid":`conflicts-announcer`,children:T}),(0,J.jsx)(O,{open:v,onClose:()=>y(!1),shortcuts:ae}),V.dialog]})}function tn(e,t,n){let r=e.indexOf(t),i=[...e.slice(r+1),...e.slice(0,r)].find(e=>$(e)===`open`);return i===void 0?null:{path:i.path,onSelect:()=>n(i)}}function nn({conflicts:e,current:t,names:n,onSelect:r}){let i=[`open`,`resolved`,`elsewhere`].map(t=>({group:t,items:e.filter(e=>$(e)===t)})).filter(e=>e.items.length>0);return(0,J.jsx)(`div`,{className:`space-y-1`,children:i.map(({group:e,items:i})=>(0,J.jsxs)(`section`,{"aria-label":Qt[e],"data-testid":`conflict-group-${e}`,children:[(0,J.jsxs)(`h2`,{className:`flex items-center justify-between px-4 pt-2.5 pb-1 text-xs text-muted`,children:[Qt[e],(0,J.jsx)(`span`,{className:`tabular-nums`,children:i.length})]}),(0,J.jsx)(`ul`,{children:i.map(i=>{let{name:a,folder:o}=yt(i.path);return(0,J.jsx)(`li`,{children:(0,J.jsxs)(`button`,{type:`button`,onClick:()=>r(i),"aria-current":i===t?`true`:void 0,className:`grid w-full grid-cols-[1rem_minmax(0,1fr)] items-start gap-2.5 px-4 py-1.5 text-left hover:bg-hover aria-[current]:bg-[var(--azd-selected)]`,"data-testid":`conflict-row`,"data-path":i.path,children:[(0,J.jsx)(an,{group:e}),(0,J.jsxs)(`span`,{className:`min-w-0`,children:[(0,J.jsxs)(`span`,{className:`flex min-w-0 items-baseline gap-1.5 text-[13px]`,children:[(0,J.jsx)(`span`,{className:`truncate font-medium text-fg`,children:a}),o.length>0&&(0,J.jsx)(`span`,{className:`truncate text-xs text-muted`,children:o})]}),(0,J.jsx)(`span`,{className:`line-clamp-2 text-xs text-muted`,children:e===`resolved`?rn(i):ot(i,n)})]})]})},i.conflictId)})})]},e))})}function rn(e){let t=e.resolvedBy?.displayName,n=ut(e.resolvedDate);return[`Resolved`,t===void 0?null:`by ${t}`,n.length>0?n:null].filter(e=>e!==null).join(` · `)}function an({group:e}){return e===`resolved`?(0,J.jsxs)(`span`,{className:`mt-0.5 grid size-3.5 place-items-center rounded-full bg-added`,title:`Resolved`,children:[(0,J.jsx)(T,{className:`size-2.5 text-[var(--azd-canvas)]`}),(0,J.jsx)(`span`,{className:`sr-only`,children:`Resolved: `})]}):e===`elsewhere`?(0,J.jsx)(`span`,{className:`mt-0.5 size-3.5 rounded-full border-[1.5px] border-dashed border-muted`,title:`Resolve in Azure DevOps`,children:(0,J.jsx)(`span`,{className:`sr-only`,children:`Resolve in Azure DevOps: `})}):(0,J.jsx)(`span`,{className:`mt-0.5 size-3.5 rounded-full border-[1.5px] border-warning`,title:`To resolve`,children:(0,J.jsx)(`span`,{className:`sr-only`,children:`To resolve: `})})}function on({resolved:e,total:t}){let n=2*Math.PI*6,r=t===0?0:e/t,i=t>0&&e===t;return(0,J.jsxs)(`span`,{className:`ml-1 flex h-8 shrink-0 items-center gap-2 rounded-[7px] px-2 text-[13px] text-muted`,"data-testid":`resolved-count`,title:`${e} of ${t} conflicted files resolved`,children:[(0,J.jsxs)(`svg`,{"aria-hidden":`true`,viewBox:`0 0 16 16`,className:`size-4 -rotate-90`,children:[(0,J.jsx)(`circle`,{cx:`8`,cy:`8`,r:6,fill:`none`,stroke:`var(--azd-border-strong)`,strokeWidth:`2`}),e>0&&(0,J.jsx)(`circle`,{cx:`8`,cy:`8`,r:6,fill:`none`,stroke:i?`var(--azd-added)`:`var(--azd-fg)`,strokeWidth:`2`,strokeLinecap:i?`butt`:`round`,...i?{}:{strokeDasharray:`${r*n} ${n}`},className:`transition-[stroke-dasharray] duration-300 motion-reduce:transition-none`})]}),(0,J.jsxs)(`span`,{className:`tabular-nums`,children:[(0,J.jsx)(`span`,{className:`font-medium text-fg`,children:e}),` / `,t,(0,J.jsx)(`span`,{className:`ml-1`,children:`resolved`})]})]})}function sn(){return(0,J.jsxs)(`div`,{className:`mx-auto w-full max-w-[1100px] space-y-3 px-5 pt-4`,"aria-busy":`true`,children:[(0,J.jsx)(`span`,{className:`sr-only`,children:`Loading the conflicts`}),(0,J.jsx)(`div`,{className:`azd-pulse h-11 rounded-[10px] bg-raised`}),(0,J.jsx)(`div`,{className:`azd-pulse h-64 rounded-[10px] bg-raised`})]})}function cn({pullRequest:e,total:t,names:n}){let{location:r,shortForm:i}=z(),a=s(),o=I(),c=(0,H.useRef)(Date.now()),[l,u]=(0,H.useState)(!1),d=e.mergeStatus,f=d===`succeeded`?`ready`:d===`failure`||d===`rejectedByPolicy`?`failed`:l?`timed-out`:`waiting`;(0,H.useEffect)(()=>{if(f!==`waiting`)return;let e=window.setInterval(()=>{Date.now()-c.current>Zt?u(!0):a.invalidateQueries({queryKey:L.detail(r),exact:!0})},Xt);return()=>window.clearInterval(e)},[f,a,r]);let p=(0,H.useRef)(null);return(0,J.jsxs)(`section`,{"aria-labelledby":`azd-finish-title`,className:`flex flex-col items-start gap-2.5 rounded-[10px] bg-surface p-5 shadow-[0_0_0_1px_var(--azd-border)]`,"data-testid":`conflicts-finish`,"data-state":f,children:[f===`ready`?(0,J.jsx)(`span`,{className:`grid size-7 place-items-center rounded-full border-2 border-added`,children:(0,J.jsx)(T,{className:`size-4 text-added`})}):(0,J.jsx)(`span`,{"aria-hidden":`true`,className:`size-2.5 rounded-full ${f===`waiting`?`azd-pulse bg-accent`:`bg-warning`}`}),(0,J.jsx)(`h2`,{id:`azd-finish-title`,className:`text-[16px] font-semibold text-fg-strong`,children:t===1?`The conflict is resolved`:`All ${t} conflicts resolved`}),(0,J.jsxs)(`p`,{role:`status`,className:`text-[13px] text-muted`,children:[f===`ready`&&(0,J.jsxs)(J.Fragment,{children:[`Azure DevOps merged again with your resolutions. No conflicts with`,` `,(0,J.jsx)(`span`,{className:`font-mono`,children:n.target}),`.`]}),f===`waiting`&&`Azure DevOps is merging again with your resolutions…`,f===`timed-out`&&`Azure DevOps has not finished merging again after two minutes. Check again in a moment.`,f===`failed`&&(e.mergeFailureMessage??`Azure DevOps could not merge with these resolutions.`)]}),(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 pt-1`,children:[f===`ready`&&o?.actions?.primary===`complete`&&(0,J.jsx)(`button`,{ref:p,type:`button`,onClick:e=>o.run(`complete`,e.currentTarget),className:`inline-flex shrink-0 items-center justify-center gap-1.5 rounded-[7px] text-[13px] font-medium whitespace-nowrap transition-colors disabled:cursor-not-allowed disabled:opacity-50 h-8 px-3 bg-primary text-primary-fg hover:opacity-90`,"data-testid":`finish-complete`,children:`Complete`}),f===`ready`&&o?.actions?.primary===`set-auto-complete`&&(0,J.jsx)(`button`,{type:`button`,onClick:e=>o.run(`set-auto-complete`,e.currentTarget),className:`inline-flex shrink-0 items-center justify-center gap-1.5 rounded-[7px] text-[13px] font-medium whitespace-nowrap transition-colors disabled:cursor-not-allowed disabled:opacity-50 h-8 px-3 bg-primary text-primary-fg hover:opacity-90`,children:`Set auto-complete`}),(f===`timed-out`||f===`failed`)&&(0,J.jsx)(`button`,{type:`button`,onClick:()=>{c.current=Date.now(),u(!1),a.invalidateQueries({queryKey:L.detail(r),exact:!0})},className:`inline-flex shrink-0 items-center justify-center gap-1.5 rounded-[7px] text-[13px] font-medium whitespace-nowrap transition-colors disabled:cursor-not-allowed disabled:opacity-50 h-8 px-3 border border-border bg-raised text-fg hover:border-border-strong hover:bg-hover`,children:`Check again`}),(0,J.jsx)(R,{location:r,shortForm:i,page:{tab:`overview`},className:w,children:`Back to the Overview`})]}),f===`ready`&&(0,J.jsx)(`p`,{className:`text-xs text-muted`,children:`Merge commit or squash only: rebase can't keep conflict resolutions.`})]})}function ln(e,t,n,r){let a=s(),{location:c}=z(),l=v(e.organization),u=(0,H.useRef)(!1),[d,f]=(0,H.useState)(!1),[m,h]=(0,H.useState)(null),[b,x]=(0,H.useState)(null),S=(0,H.useMemo)(()=>pe(me(),{organization:e.organization,repositoryId:e.repositoryId,pullRequestId:e.pullRequestId}),[e.organization,e.repositoryId,e.pullRequestId]),C=P.list(e,t.lastMergeSourceCommit,t.lastMergeTargetCommit),T=n=>{let r=A(n,{repository:t.repository.name,method:y(e.organization)});return r.kind===`sign-in`?`Azure DevOps did not accept the sign-in. Reload to sign in again; your choices are kept.`:r.message},E=async(t,n,s)=>{if(u.current)return;u.current=!0,f(!0),h(null);let d=_(e.organization),m;try{m=await tt({pullRequest:()=>o(d,{project:e.project,pullRequestId:e.pullRequestId}),conflicts:()=>i(d,{project:e.project,repositoryId:e.repositoryId,pullRequestId:e.pullRequestId}),resolve:n=>p(_(e.organization,{keepSessionOnUnauthorized:!0}),{project:e.project,repositoryId:e.repositoryId,pullRequestId:e.pullRequestId,conflictId:t.conflictId,conflictType:t.type,resolution:n})},{conflict:t,resolution:n,currentUserId:l.data?.id??null,replaceConfirmed:s})}finally{u.current=!1,f(!1)}switch(m.kind){case`saved`:S.write(t.path,null),a.setQueryData(C,e=>e?.map(e=>e.conflictId===t.conflictId?m.conflict:e)),a.invalidateQueries({queryKey:L.detail(c),exact:!0}),r.onSaved(m.conflict);return;case`stale`:a.setQueryData(L.detail(c),m.pullRequest),r.onStale(m.branch);return;case`confirm-replace`:x({conflict:t,resolution:n,by:m.by.displayName,date:m.date});return;case`gone`:h({conflictId:t.conflictId,text:`Azure DevOps no longer lists this conflict. The list was reloaded.`}),a.invalidateQueries({queryKey:P.all(e)});return;case`failed`:h({conflictId:t.conflictId,text:nt(m,{method:y(e.organization),describe:T})}),m.sent&&a.invalidateQueries({queryKey:P.all(e)});return}},D=(0,H.useId)();return{store:S,dialog:b===null?null:(0,J.jsx)(F,{titleId:D,busy:d,onClose:()=>x(null),testId:`replace-dialog`,children:(0,J.jsxs)(`div`,{className:`space-y-3`,children:[(0,J.jsxs)(`h2`,{id:D,className:`text-[16px] font-semibold text-fg-strong`,children:[`Replace `,b.by,`'s resolution?`]}),(0,J.jsxs)(`p`,{className:`text-[13px] text-muted`,children:[b.by,` resolved `,yt(b.conflict.path).name,b.date===null?``:` ${ut(b.date)}`,` while you were working on it. Yours replaces theirs in the merge into`,` `,(0,J.jsx)(`span`,{className:`font-mono`,children:n.target}),`.`]}),(0,J.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,J.jsx)(`button`,{type:`button`,onClick:()=>x(null),className:w,children:`Keep theirs`}),(0,J.jsx)(`button`,{type:`button`,onClick:()=>{let e=b;x(null),E(e.conflict,e.resolution,!0)},className:g,"data-testid":`replace-confirm`,children:`Replace with mine`})]})]})}),control:e=>({busy:d,problem:m?.conflictId===e.conflictId?m.text:null,run:t=>void E(e,t,!1)})}}export{en as t};
@@ -0,0 +1,12 @@
1
+ import{_ as e,c as t,d as n,f as r,g as i,h as a,l as o,m as s,p as c,u as l,v as u}from"./stream-tokenizer-7LLwu37w-C37tUWGx.js";var d=class extends Error{constructor(e){super(e),this.name=`ShikiError`}};function f(e){return p(e)}function p(e){return Array.isArray(e)?m(e):e instanceof RegExp?e:typeof e==`object`?h(e):e}function m(e){let t=[];for(let n=0,r=e.length;n<r;n++)t[n]=p(e[n]);return t}function h(e){let t={};for(let n in e)t[n]=p(e[n]);return t}function g(e,...t){return t.forEach(t=>{for(let n in t)e[n]=t[n]}),e}function _(e){let t=~e.lastIndexOf(`/`)||~e.lastIndexOf(`\\`);return t===0?e:~t===e.length-1?_(e.substring(0,e.length-1)):e.substr(~t+1)}var v=/\$(\d+)|\${(\d+):\/(downcase|upcase)}/g,ee=class{static hasCaptures(e){return e!==null&&(v.lastIndex=0,v.test(e))}static replaceCaptures(e,t,n){return e.replace(v,(e,r,i,a)=>{let o=n[parseInt(r||i,10)];if(o){let e=t.substring(o.start,o.end);for(;e[0]===`.`;)e=e.substring(1);switch(a){case`downcase`:return e.toLowerCase();case`upcase`:return e.toUpperCase();default:return e}}else return e})}};function te(e,t){return e<t?-1:+(e>t)}function ne(e,t){if(e===null&&t===null)return 0;if(!e)return-1;if(!t)return 1;let n=e.length,r=t.length;if(n===r){for(let r=0;r<n;r++){let n=te(e[r],t[r]);if(n!==0)return n}return 0}return n-r}function re(e){return!!(/^#[0-9a-f]{6}$/i.test(e)||/^#[0-9a-f]{8}$/i.test(e)||/^#[0-9a-f]{3}$/i.test(e)||/^#[0-9a-f]{4}$/i.test(e))}function ie(e){return e.replace(/[\-\\\{\}\*\+\?\|\^\$\.\,\[\]\(\)\#\s]/g,`\\$&`)}var ae=class{constructor(e){this.fn=e}fn;cache=/* @__PURE__ */ new Map;get(e){if(this.cache.has(e))return this.cache.get(e);let t=this.fn(e);return this.cache.set(e,t),t}},y=class{constructor(e,t,n){this._colorMap=e,this._defaults=t,this._root=n}_colorMap;_defaults;_root;static createFromRawTheme(e,t){return this.createFromParsedTheme(ue(e),t)}static createFromParsedTheme(e,t){return fe(e,t)}_cachedMatchRoot=new ae(e=>this._root.match(e));getColorMap(){return this._colorMap.getColorMap()}getDefaults(){return this._defaults}match(e){if(e===null)return this._defaults;let t=e.scopeName,n=this._cachedMatchRoot.get(t).find(t=>se(e.parent,t.parentScopes));return n?new le(n.fontStyle,n.foreground,n.background):null}},oe=class e{constructor(e,t){this.parent=e,this.scopeName=t}parent;scopeName;static push(t,n){for(let r of n)t=new e(t,r);return t}static from(...t){let n=null;for(let r=0;r<t.length;r++)n=new e(n,t[r]);return n}push(t){return new e(this,t)}getSegments(){let e=this,t=[];for(;e;)t.push(e.scopeName),e=e.parent;return t.reverse(),t}toString(){return this.getSegments().join(` `)}extends(e){return this===e||this.parent!==null&&this.parent.extends(e)}getExtensionIfDefined(e){let t=[],n=this;for(;n&&n!==e;)t.push(n.scopeName),n=n.parent;return n===e?t.reverse():void 0}};function se(e,t){if(t.length===0)return!0;for(let n=0;n<t.length;n++){let r=t[n],i=!1;if(r===`>`){if(n===t.length-1)return!1;r=t[++n],i=!0}for(;e&&!ce(e.scopeName,r);){if(i)return!1;e=e.parent}if(!e)return!1;e=e.parent}return!0}function ce(e,t){return t===e||e.startsWith(t)&&e[t.length]===`.`}var le=class{constructor(e,t,n){this.fontStyle=e,this.foregroundId=t,this.backgroundId=n}fontStyle;foregroundId;backgroundId};function ue(e){if(!e||!e.settings||!Array.isArray(e.settings))return[];let t=e.settings,n=[],r=0;for(let e=0,i=t.length;e<i;e++){let i=t[e];if(!i.settings)continue;let a;if(typeof i.scope==`string`){let e=i.scope;e=e.replace(/^[,]+/,``),e=e.replace(/[,]+$/,``),a=e.split(`,`)}else a=Array.isArray(i.scope)?i.scope:[``];let o=-1;if(typeof i.settings.fontStyle==`string`){o=0;let e=i.settings.fontStyle.split(` `);for(let t=0,n=e.length;t<n;t++)switch(e[t]){case`italic`:o|=1;break;case`bold`:o|=2;break;case`underline`:o|=4;break;case`strikethrough`:o|=8}}let s=null;typeof i.settings.foreground==`string`&&re(i.settings.foreground)&&(s=i.settings.foreground);let c=null;typeof i.settings.background==`string`&&re(i.settings.background)&&(c=i.settings.background);for(let t=0,i=a.length;t<i;t++){let i=a[t].trim().split(` `),l=i[i.length-1],u=null;i.length>1&&(u=i.slice(0,i.length-1),u.reverse()),n[r++]=new de(l,u,e,o,s,c)}}return n}var de=class{constructor(e,t,n,r,i,a){this.scope=e,this.parentScopes=t,this.index=n,this.fontStyle=r,this.foreground=i,this.background=a}scope;parentScopes;index;fontStyle;foreground;background},b=/* @__PURE__ */ (e=>(e[e.NotSet=-1]=`NotSet`,e[e.None=0]=`None`,e[e.Italic=1]=`Italic`,e[e.Bold=2]=`Bold`,e[e.Underline=4]=`Underline`,e[e.Strikethrough=8]=`Strikethrough`,e))(b||{});function fe(e,t){e.sort((e,t)=>{let n=te(e.scope,t.scope);return n!==0||(n=ne(e.parentScopes,t.parentScopes),n!==0)?n:e.index-t.index});let n=0,r=`#000000`,i=`#ffffff`;for(;e.length>=1&&e[0].scope===``;){let t=e.shift();t.fontStyle!==-1&&(n=t.fontStyle),t.foreground!==null&&(r=t.foreground),t.background!==null&&(i=t.background)}let a=new pe(t),o=new le(n,a.getId(r),a.getId(i)),s=new ge(new he(0,null,-1,0,0),[]);for(let t=0,n=e.length;t<n;t++){let n=e[t];s.insert(0,n.scope,n.parentScopes,n.fontStyle,a.getId(n.foreground),a.getId(n.background))}return new y(a,o,s)}var pe=class{_isFrozen;_lastColorId;_id2color;_color2id;constructor(e){if(this._lastColorId=0,this._id2color=[],this._color2id=/* @__PURE__ */ Object.create(null),Array.isArray(e)){this._isFrozen=!0;for(let t=0,n=e.length;t<n;t++)this._color2id[e[t]]=t,this._id2color[t]=e[t]}else this._isFrozen=!1}getId(e){if(e===null)return 0;e=e.toUpperCase();let t=this._color2id[e];if(t)return t;if(this._isFrozen)throw Error(`Missing color in color map - ${e}`);return t=++this._lastColorId,this._color2id[e]=t,this._id2color[t]=e,t}getColorMap(){return this._id2color.slice(0)}},me=Object.freeze([]),he=class e{scopeDepth;parentScopes;fontStyle;foreground;background;constructor(e,t,n,r,i){this.scopeDepth=e,this.parentScopes=t||me,this.fontStyle=n,this.foreground=r,this.background=i}clone(){return new e(this.scopeDepth,this.parentScopes,this.fontStyle,this.foreground,this.background)}static cloneArr(e){let t=[];for(let n=0,r=e.length;n<r;n++)t[n]=e[n].clone();return t}acceptOverwrite(e,t,n,r){this.scopeDepth>e?console.log(`how did this happen?`):this.scopeDepth=e,t!==-1&&(this.fontStyle=t),n!==0&&(this.foreground=n),r!==0&&(this.background=r)}},ge=class e{constructor(e,t=[],n={}){this._mainRule=e,this._children=n,this._rulesWithParentScopes=t}_mainRule;_children;_rulesWithParentScopes;static _cmpBySpecificity(e,t){if(e.scopeDepth!==t.scopeDepth)return t.scopeDepth-e.scopeDepth;let n=0,r=0;for(;e.parentScopes[n]===`>`&&n++,t.parentScopes[r]===`>`&&r++,!(n>=e.parentScopes.length||r>=t.parentScopes.length);){let i=t.parentScopes[r].length-e.parentScopes[n].length;if(i!==0)return i;n++,r++}return t.parentScopes.length-e.parentScopes.length}match(t){if(t!==``){let e=t.indexOf(`.`),n,r;if(e===-1?(n=t,r=``):(n=t.substring(0,e),r=t.substring(e+1)),this._children.hasOwnProperty(n))return this._children[n].match(r)}let n=this._rulesWithParentScopes.concat(this._mainRule);return n.sort(e._cmpBySpecificity),n}insert(t,n,r,i,a,o){if(n===``){this._doInsertHere(t,r,i,a,o);return}let s=n.indexOf(`.`),c,l;s===-1?(c=n,l=``):(c=n.substring(0,s),l=n.substring(s+1));let u;this._children.hasOwnProperty(c)?u=this._children[c]:(u=new e(this._mainRule.clone(),he.cloneArr(this._rulesWithParentScopes)),this._children[c]=u),u.insert(t+1,l,r,i,a,o)}_doInsertHere(e,t,n,r,i){if(t===null)this._mainRule.acceptOverwrite(e,n,r,i);else{for(let a=0,o=this._rulesWithParentScopes.length;a<o;a++){let o=this._rulesWithParentScopes[a];if(ne(o.parentScopes,t)===0){o.acceptOverwrite(e,n,r,i);return}}n===-1&&(n=this._mainRule.fontStyle),r===0&&(r=this._mainRule.foreground),i===0&&(i=this._mainRule.background),this._rulesWithParentScopes.push(new he(e,t,n,r,i))}}},x=class e{static toBinaryStr(e){return e.toString(2).padStart(32,`0`)}static print(t){let n=e.getLanguageId(t),r=e.getTokenType(t),i=e.getFontStyle(t),a=e.getForeground(t),o=e.getBackground(t);console.log({languageId:n,tokenType:r,fontStyle:i,foreground:a,background:o})}static getLanguageId(e){return(e&255)>>>0}static getTokenType(e){return(e&768)>>>8}static containsBalancedBrackets(e){return!!(e&1024)}static getFontStyle(e){return(e&30720)>>>11}static getForeground(e){return(e&0xff8000)>>>15}static getBackground(e){return(e&0xff000000)>>>24}static set(t,n,r,i,a,o,s){let c=e.getLanguageId(t),l=e.getTokenType(t),u=+!!e.containsBalancedBrackets(t),d=e.getFontStyle(t),f=e.getForeground(t),p=e.getBackground(t);return n!==0&&(c=n),r!==8&&(l=ve(r)),i!==null&&(u=+!!i),a!==-1&&(d=a),o!==0&&(f=o),s!==0&&(p=s),(c|0|l<<8|u<<10|d<<11|f<<15|p<<24)>>>0}};function _e(e){return e}function ve(e){return e}function S(e,t){let n=[],r=be(e),i=r.next();for(;i!==null;){let e=0;if(i.length===2&&i.charAt(1)===`:`){switch(i.charAt(0)){case`R`:e=1;break;case`L`:e=-1;break;default:console.log(`Unknown priority ${i} in scope selector`)}i=r.next()}let t=o();if(n.push({matcher:t,priority:e}),i!==`,`)break;i=r.next()}return n;function a(){if(i===`-`){i=r.next();let e=a();return t=>!!e&&!e(t)}if(i===`(`){i=r.next();let e=s();return i===`)`&&(i=r.next()),e}if(ye(i)){let e=[];do e.push(i),i=r.next();while(ye(i));return n=>t(e,n)}return null}function o(){let e=[],t=a();for(;t;)e.push(t),t=a();return t=>e.every(e=>e(t))}function s(){let e=[],t=o();for(;t&&(e.push(t),i===`|`||i===`,`);){do i=r.next();while(i===`|`||i===`,`);t=o()}return t=>e.some(e=>e(t))}}function ye(e){return!!e&&!!e.match(/[\w\.:]+/)}function be(e){let t=/([LR]:|[\w\.:][\w\.:\-]*|[\,\|\-\(\)])/g,n=t.exec(e);return{next:()=>{if(!n)return null;let r=n[0];return n=t.exec(e),r}}}function xe(e){typeof e.dispose==`function`&&e.dispose()}var C=class{constructor(e){this.scopeName=e}scopeName;toKey(){return this.scopeName}},Se=class{constructor(e,t){this.scopeName=e,this.ruleName=t}scopeName;ruleName;toKey(){return`${this.scopeName}#${this.ruleName}`}},Ce=class{_references=[];_seenReferenceKeys=/* @__PURE__ */ new Set;get references(){return this._references}visitedRule=/* @__PURE__ */ new Set;add(e){let t=e.toKey();this._seenReferenceKeys.has(t)||(this._seenReferenceKeys.add(t),this._references.push(e))}},we=class{constructor(e,t){this.repo=e,this.initialScopeName=t,this.seenFullScopeRequests.add(this.initialScopeName),this.Q=[new C(this.initialScopeName)]}repo;initialScopeName;seenFullScopeRequests=/* @__PURE__ */ new Set;seenPartialScopeRequests=/* @__PURE__ */ new Set;Q;processQueue(){let e=this.Q;this.Q=[];let t=new Ce;for(let n of e)Te(n,this.initialScopeName,this.repo,t);for(let e of t.references)if(e instanceof C){if(this.seenFullScopeRequests.has(e.scopeName))continue;this.seenFullScopeRequests.add(e.scopeName),this.Q.push(e)}else{if(this.seenFullScopeRequests.has(e.scopeName)||this.seenPartialScopeRequests.has(e.toKey()))continue;this.seenPartialScopeRequests.add(e.toKey()),this.Q.push(e)}}};function Te(e,t,n,r){let i=n.lookup(e.scopeName);if(!i){if(e.scopeName===t)throw Error(`No grammar provided for <${t}>`);return}let a=n.lookup(t);e instanceof C?w({baseGrammar:a,selfGrammar:i},r):Ee(e.ruleName,{baseGrammar:a,selfGrammar:i,repository:i.repository},r);let o=n.injections(e.scopeName);if(o)for(let e of o)r.add(new C(e))}function Ee(e,t,n){t.repository&&t.repository[e]&&T([t.repository[e]],t,n)}function w(e,t){e.selfGrammar.patterns&&Array.isArray(e.selfGrammar.patterns)&&T(e.selfGrammar.patterns,{...e,repository:e.selfGrammar.repository},t),e.selfGrammar.injections&&T(Object.values(e.selfGrammar.injections),{...e,repository:e.selfGrammar.repository},t)}function T(e,t,n){for(let r of e){if(n.visitedRule.has(r))continue;n.visitedRule.add(r);let e=r.repository?g({},t.repository,r.repository):t.repository;Array.isArray(r.patterns)&&T(r.patterns,{...t,repository:e},n);let i=r.include;if(!i)continue;let a=Me(i);switch(a.kind){case 0:w({...t,selfGrammar:t.baseGrammar},n);break;case 1:w(t,n);break;case 2:Ee(a.ruleName,{...t,repository:e},n);break;case 3:case 4:let r=a.scopeName===t.selfGrammar.scopeName?t.selfGrammar:a.scopeName===t.baseGrammar.scopeName?t.baseGrammar:void 0;if(r){let i={baseGrammar:t.baseGrammar,selfGrammar:r,repository:e};a.kind===4?Ee(a.ruleName,i,n):w(i,n)}else a.kind===4?n.add(new Se(a.scopeName,a.ruleName)):n.add(new C(a.scopeName))}}}var De=class{kind=0},Oe=class{kind=1},ke=class{constructor(e){this.ruleName=e}ruleName;kind=2},Ae=class{constructor(e){this.scopeName=e}scopeName;kind=3},je=class{constructor(e,t){this.scopeName=e,this.ruleName=t}scopeName;ruleName;kind=4};function Me(e){if(e===`$base`)return new De;if(e===`$self`)return new Oe;let t=e.indexOf(`#`);return t===-1?new Ae(e):t===0?new ke(e.substring(1)):new je(e.substring(0,t),e.substring(t+1))}var Ne=/\\(\d+)/,Pe=/\\(\d+)/g,Fe=-1,Ie=-2;function Le(e){return e}function Re(e){return e}var E=class{$location;id;_nameIsCapturing;_name;_contentNameIsCapturing;_contentName;constructor(e,t,n,r){this.$location=e,this.id=t,this._name=n||null,this._nameIsCapturing=ee.hasCaptures(this._name),this._contentName=r||null,this._contentNameIsCapturing=ee.hasCaptures(this._contentName)}get debugName(){let e=this.$location?`${_(this.$location.filename)}:${this.$location.line}`:`unknown`;return`${this.constructor.name}#${this.id} @ ${e}`}getName(e,t){return!this._nameIsCapturing||this._name===null||e===null||t===null?this._name:ee.replaceCaptures(this._name,e,t)}getContentName(e,t){return!this._contentNameIsCapturing||this._contentName===null?this._contentName:ee.replaceCaptures(this._contentName,e,t)}},ze=class extends E{retokenizeCapturedWithRuleId;constructor(e,t,n,r,i){super(e,t,n,r),this.retokenizeCapturedWithRuleId=i}dispose(){}collectPatterns(e,t){throw Error(`Not supported!`)}compile(e,t){throw Error(`Not supported!`)}compileAG(e,t,n,r){throw Error(`Not supported!`)}},Be=class extends E{_match;captures;_cachedCompiledPatterns;constructor(e,t,n,r,i){super(e,t,n,null),this._match=new D(r,this.id),this.captures=i,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&=(this._cachedCompiledPatterns.dispose(),null)}get debugMatchRegExp(){return`${this._match.source}`}collectPatterns(e,t){t.push(this._match)}compile(e,t){return this._getCachedCompiledPatterns(e).compile(e)}compileAG(e,t,n,r){return this._getCachedCompiledPatterns(e).compileAG(e,n,r)}_getCachedCompiledPatterns(e){return this._cachedCompiledPatterns||(this._cachedCompiledPatterns=new O,this.collectPatterns(e,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},Ve=class extends E{hasMissingPatterns;patterns;_cachedCompiledPatterns;constructor(e,t,n,r,i){super(e,t,n,r),this.patterns=i.patterns,this.hasMissingPatterns=i.hasMissingPatterns,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&=(this._cachedCompiledPatterns.dispose(),null)}collectPatterns(e,t){for(let n of this.patterns)e.getRule(n).collectPatterns(e,t)}compile(e,t){return this._getCachedCompiledPatterns(e).compile(e)}compileAG(e,t,n,r){return this._getCachedCompiledPatterns(e).compileAG(e,n,r)}_getCachedCompiledPatterns(e){return this._cachedCompiledPatterns||(this._cachedCompiledPatterns=new O,this.collectPatterns(e,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},He=class extends E{_begin;beginCaptures;_end;endHasBackReferences;endCaptures;applyEndPatternLast;hasMissingPatterns;patterns;_cachedCompiledPatterns;constructor(e,t,n,r,i,a,o,s,c,l){super(e,t,n,r),this._begin=new D(i,this.id),this.beginCaptures=a,this._end=new D(o||`￿`,-1),this.endHasBackReferences=this._end.hasBackReferences,this.endCaptures=s,this.applyEndPatternLast=c||!1,this.patterns=l.patterns,this.hasMissingPatterns=l.hasMissingPatterns,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&=(this._cachedCompiledPatterns.dispose(),null)}get debugBeginRegExp(){return`${this._begin.source}`}get debugEndRegExp(){return`${this._end.source}`}getEndWithResolvedBackReferences(e,t){return this._end.resolveBackReferences(e,t)}collectPatterns(e,t){t.push(this._begin)}compile(e,t){return this._getCachedCompiledPatterns(e,t).compile(e)}compileAG(e,t,n,r){return this._getCachedCompiledPatterns(e,t).compileAG(e,n,r)}_getCachedCompiledPatterns(e,t){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new O;for(let t of this.patterns)e.getRule(t).collectPatterns(e,this._cachedCompiledPatterns);this.applyEndPatternLast?this._cachedCompiledPatterns.push(this._end.hasBackReferences?this._end.clone():this._end):this._cachedCompiledPatterns.unshift(this._end.hasBackReferences?this._end.clone():this._end)}return this._end.hasBackReferences&&(this.applyEndPatternLast?this._cachedCompiledPatterns.setSource(this._cachedCompiledPatterns.length()-1,t):this._cachedCompiledPatterns.setSource(0,t)),this._cachedCompiledPatterns}},Ue=class extends E{_begin;beginCaptures;whileCaptures;_while;whileHasBackReferences;hasMissingPatterns;patterns;_cachedCompiledPatterns;_cachedCompiledWhilePatterns;constructor(e,t,n,r,i,a,o,s,c){super(e,t,n,r),this._begin=new D(i,this.id),this.beginCaptures=a,this.whileCaptures=s,this._while=new D(o,Ie),this.whileHasBackReferences=this._while.hasBackReferences,this.patterns=c.patterns,this.hasMissingPatterns=c.hasMissingPatterns,this._cachedCompiledPatterns=null,this._cachedCompiledWhilePatterns=null}dispose(){this._cachedCompiledPatterns&&=(this._cachedCompiledPatterns.dispose(),null),this._cachedCompiledWhilePatterns&&=(this._cachedCompiledWhilePatterns.dispose(),null)}get debugBeginRegExp(){return`${this._begin.source}`}get debugWhileRegExp(){return`${this._while.source}`}getWhileWithResolvedBackReferences(e,t){return this._while.resolveBackReferences(e,t)}collectPatterns(e,t){t.push(this._begin)}compile(e,t){return this._getCachedCompiledPatterns(e).compile(e)}compileAG(e,t,n,r){return this._getCachedCompiledPatterns(e).compileAG(e,n,r)}_getCachedCompiledPatterns(e){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new O;for(let t of this.patterns)e.getRule(t).collectPatterns(e,this._cachedCompiledPatterns)}return this._cachedCompiledPatterns}compileWhile(e,t){return this._getCachedCompiledWhilePatterns(e,t).compile(e)}compileWhileAG(e,t,n,r){return this._getCachedCompiledWhilePatterns(e,t).compileAG(e,n,r)}_getCachedCompiledWhilePatterns(e,t){return this._cachedCompiledWhilePatterns||(this._cachedCompiledWhilePatterns=new O,this._cachedCompiledWhilePatterns.push(this._while.hasBackReferences?this._while.clone():this._while)),this._while.hasBackReferences&&this._cachedCompiledWhilePatterns.setSource(0,t||`￿`),this._cachedCompiledWhilePatterns}},We=class e{static createCaptureRule(e,t,n,r,i){return e.registerRule(e=>new ze(t,e,n,r,i))}static getCompiledRuleId(t,n,r){return t.id||n.registerRule(i=>{if(t.id=i,t.match)return new Be(t.$vscodeTextmateLocation,t.id,t.name,t.match,e._compileCaptures(t.captures,n,r));if(t.begin===void 0){t.repository&&(r=g({},r,t.repository));let i=t.patterns;return i===void 0&&t.include&&(i=[{include:t.include}]),new Ve(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,e._compilePatterns(i,n,r))}return t.while?new Ue(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,t.begin,e._compileCaptures(t.beginCaptures||t.captures,n,r),t.while,e._compileCaptures(t.whileCaptures||t.captures,n,r),e._compilePatterns(t.patterns,n,r)):new He(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,t.begin,e._compileCaptures(t.beginCaptures||t.captures,n,r),t.end,e._compileCaptures(t.endCaptures||t.captures,n,r),t.applyEndPatternLast,e._compilePatterns(t.patterns,n,r))}),t.id}static _compileCaptures(t,n,r){let i=[];if(t){let a=0;for(let e in t){if(e===`$vscodeTextmateLocation`)continue;let t=parseInt(e,10);t>a&&(a=t)}for(let e=0;e<=a;e++)i[e]=null;for(let a in t){if(a===`$vscodeTextmateLocation`)continue;let o=parseInt(a,10),s=0;t[a].patterns&&(s=e.getCompiledRuleId(t[a],n,r)),i[o]=e.createCaptureRule(n,t[a].$vscodeTextmateLocation,t[a].name,t[a].contentName,s)}}return i}static _compilePatterns(t,n,r){let i=[];if(t)for(let a=0,o=t.length;a<o;a++){let o=t[a],s=-1;if(o.include){let t=Me(o.include);switch(t.kind){case 0:case 1:s=e.getCompiledRuleId(r[o.include],n,r);break;case 2:let i=r[t.ruleName];i&&(s=e.getCompiledRuleId(i,n,r));break;case 3:case 4:let a=t.scopeName,c=t.kind===4?t.ruleName:null,l=n.getExternalGrammar(a,r);if(l){if(c){let t=l.repository[c];t&&(s=e.getCompiledRuleId(t,n,l.repository))}else s=e.getCompiledRuleId(l.repository.$self,n,l.repository)}}}else s=e.getCompiledRuleId(o,n,r);if(s!==-1){let e=n.getRule(s),t=!1;if((e instanceof Ve||e instanceof He||e instanceof Ue)&&e.hasMissingPatterns&&e.patterns.length===0&&(t=!0),t)continue;i.push(s)}}return{patterns:i,hasMissingPatterns:(t?t.length:0)!==i.length}}},D=class e{source;ruleId;hasAnchor;hasBackReferences;_anchorCache;constructor(e,t){if(e&&typeof e==`string`){let t=e.length,n=0,r=[],i=!1;for(let a=0;a<t;a++)if(e.charAt(a)===`\\`&&a+1<t){let t=e.charAt(a+1);t===`z`?(r.push(e.substring(n,a)),r.push(`$(?!\\n)(?<!\\n)`),n=a+2):(t===`A`||t===`G`)&&(i=!0),a++}this.hasAnchor=i,n===0?this.source=e:(r.push(e.substring(n,t)),this.source=r.join(``))}else this.hasAnchor=!1,this.source=e;this._anchorCache=this.hasAnchor?this._buildAnchorCache():null,this.ruleId=t,this.hasBackReferences=typeof this.source==`string`&&Ne.test(this.source)}clone(){return new e(this.source,this.ruleId)}setSource(e){this.source!==e&&(this.source=e,this.hasAnchor&&(this._anchorCache=this._buildAnchorCache()))}resolveBackReferences(e,t){if(typeof this.source!=`string`)throw Error(`This method should only be called if the source is a string`);let n=t.map(t=>e.substring(t.start,t.end));return Pe.lastIndex=0,this.source.replace(Pe,(e,t)=>ie(n[parseInt(t,10)]||``))}_buildAnchorCache(){if(typeof this.source!=`string`)throw Error(`This method should only be called if the source is a string`);let e=[],t=[],n=[],r=[],i,a,o,s;for(i=0,a=this.source.length;i<a;i++)o=this.source.charAt(i),e[i]=o,t[i]=o,n[i]=o,r[i]=o,o===`\\`&&i+1<a&&(s=this.source.charAt(i+1),s===`A`?(e[i+1]=`￿`,t[i+1]=`￿`,n[i+1]=`A`,r[i+1]=`A`):s===`G`?(e[i+1]=`￿`,t[i+1]=`G`,n[i+1]=`￿`,r[i+1]=`G`):(e[i+1]=s,t[i+1]=s,n[i+1]=s,r[i+1]=s),i++);return{A0_G0:e.join(``),A0_G1:t.join(``),A1_G0:n.join(``),A1_G1:r.join(``)}}resolveAnchors(e,t){return!this.hasAnchor||!this._anchorCache||typeof this.source!=`string`?this.source:e?t?this._anchorCache.A1_G1:this._anchorCache.A1_G0:t?this._anchorCache.A0_G1:this._anchorCache.A0_G0}},O=class{_items;_hasAnchors;_cached;_anchorCache;constructor(){this._items=[],this._hasAnchors=!1,this._cached=null,this._anchorCache={A0_G0:null,A0_G1:null,A1_G0:null,A1_G1:null}}dispose(){this._disposeCaches()}_disposeCaches(){this._cached&&=(this._cached.dispose(),null),this._anchorCache.A0_G0&&(this._anchorCache.A0_G0.dispose(),this._anchorCache.A0_G0=null),this._anchorCache.A0_G1&&(this._anchorCache.A0_G1.dispose(),this._anchorCache.A0_G1=null),this._anchorCache.A1_G0&&(this._anchorCache.A1_G0.dispose(),this._anchorCache.A1_G0=null),this._anchorCache.A1_G1&&(this._anchorCache.A1_G1.dispose(),this._anchorCache.A1_G1=null)}push(e){this._items.push(e),this._hasAnchors=this._hasAnchors||e.hasAnchor}unshift(e){this._items.unshift(e),this._hasAnchors=this._hasAnchors||e.hasAnchor}length(){return this._items.length}setSource(e,t){this._items[e].source!==t&&(this._disposeCaches(),this._items[e].setSource(t))}compile(e){if(!this._cached){let t=this._items.map(e=>e.source);this._cached=new Ge(e,t,this._items.map(e=>e.ruleId))}return this._cached}compileAG(e,t,n){return this._hasAnchors?t?n?(this._anchorCache.A1_G1||(this._anchorCache.A1_G1=this._resolveAnchors(e,t,n)),this._anchorCache.A1_G1):(this._anchorCache.A1_G0||(this._anchorCache.A1_G0=this._resolveAnchors(e,t,n)),this._anchorCache.A1_G0):n?(this._anchorCache.A0_G1||(this._anchorCache.A0_G1=this._resolveAnchors(e,t,n)),this._anchorCache.A0_G1):(this._anchorCache.A0_G0||(this._anchorCache.A0_G0=this._resolveAnchors(e,t,n)),this._anchorCache.A0_G0):this.compile(e)}_resolveAnchors(e,t,n){return new Ge(e,this._items.map(e=>e.resolveAnchors(t,n)),this._items.map(e=>e.ruleId))}},Ge=class{constructor(e,t,n){this.regExps=t,this.rules=n,this.scanner=e.createOnigScanner(t)}regExps;rules;scanner;dispose(){typeof this.scanner.dispose==`function`&&this.scanner.dispose()}toString(){let e=[];for(let t=0,n=this.rules.length;t<n;t++)e.push(` - `+this.rules[t]+`: `+this.regExps[t]);return e.join(`
2
+ `)}findNextMatchSync(e,t,n){let r=this.scanner.findNextMatchSync(e,t,n);return r?{ruleId:this.rules[r.index],captureIndices:r.captureIndices}:null}},Ke=class{constructor(e,t){this.languageId=e,this.tokenType=t}languageId;tokenType},qe=class e{_defaultAttributes;_embeddedLanguagesMatcher;constructor(e,t){this._defaultAttributes=new Ke(e,8),this._embeddedLanguagesMatcher=new Je(Object.entries(t||{}))}getDefaultAttributes(){return this._defaultAttributes}getBasicScopeAttributes(t){return t===null?e._NULL_SCOPE_METADATA:this._getBasicScopeAttributes.get(t)}static _NULL_SCOPE_METADATA=new Ke(0,0);_getBasicScopeAttributes=new ae(e=>new Ke(this._scopeToLanguage(e),this._toStandardTokenType(e)));_scopeToLanguage(e){return this._embeddedLanguagesMatcher.match(e)||0}_toStandardTokenType(t){let n=t.match(e.STANDARD_TOKEN_TYPE_REGEXP);if(!n)return 8;switch(n[1]){case`comment`:return 1;case`string`:return 2;case`regex`:return 3;case`meta.embedded`:return 0}throw Error(`Unexpected match for standard token type!`)}static STANDARD_TOKEN_TYPE_REGEXP=/\b(comment|string|regex|meta\.embedded)\b/},Je=class{values;scopesRegExp;constructor(e){if(e.length===0)this.values=null,this.scopesRegExp=null;else{this.values=new Map(e);let t=e.map(([e,t])=>ie(e));t.sort(),t.reverse(),this.scopesRegExp=RegExp(`^((${t.join(`)|(`)}))($|\\.)`,``)}}match(e){if(!this.scopesRegExp)return;let t=e.match(this.scopesRegExp);if(t)return this.values.get(t[1])}};typeof process<`u`&&{}.VSCODE_TEXTMATE_DEBUG;var Ye=class{constructor(e,t){this.stack=e,this.stoppedEarly=t}stack;stoppedEarly};function Xe(e,t,n,r,i,a,o,s){let c=t.content.length,l=!1,u=-1;if(o){let o=Ze(e,t,n,r,i,a);i=o.stack,r=o.linePos,n=o.isFirstLine,u=o.anchorPosition}let d=Date.now();for(;!l;){if(s!==0&&Date.now()-d>s)return new Ye(i,!0);f()}return new Ye(i,!1);function f(){let o=Qe(e,t,n,r,i,u);if(!o){a.produce(i,c),l=!0;return}let s=o.captureIndices,d=o.matchedRuleId,f=s&&s.length>0?s[0].end>r:!1;if(d===Fe){let o=i.getRule(e);a.produce(i,s[0].start),i=i.withContentNameScopesList(i.nameScopesList),k(e,t,n,i,a,o.endCaptures,s),a.produce(i,s[0].end);let d=i;if(i=i.parent,u=d.getAnchorPos(),!f&&d.getEnterPos()===r){i=d,a.produce(i,c),l=!0;return}}else{let o=e.getRule(d);a.produce(i,s[0].start);let p=i,m=o.getName(t.content,s),h=i.contentNameScopesList.pushAttributed(m,e);if(i=i.push(d,r,u,s[0].end===c,null,h,h),o instanceof He){let r=o;k(e,t,n,i,a,r.beginCaptures,s),a.produce(i,s[0].end),u=s[0].end;let d=r.getContentName(t.content,s),m=h.pushAttributed(d,e);if(i=i.withContentNameScopesList(m),r.endHasBackReferences&&(i=i.withEndRule(r.getEndWithResolvedBackReferences(t.content,s))),!f&&p.hasSameRuleAs(i)){i=i.pop(),a.produce(i,c),l=!0;return}}else if(o instanceof Ue){let r=o;k(e,t,n,i,a,r.beginCaptures,s),a.produce(i,s[0].end),u=s[0].end;let d=r.getContentName(t.content,s),m=h.pushAttributed(d,e);if(i=i.withContentNameScopesList(m),r.whileHasBackReferences&&(i=i.withEndRule(r.getWhileWithResolvedBackReferences(t.content,s))),!f&&p.hasSameRuleAs(i)){i=i.pop(),a.produce(i,c),l=!0;return}}else if(k(e,t,n,i,a,o.captures,s),a.produce(i,s[0].end),i=i.pop(),!f){i=i.safePop(),a.produce(i,c),l=!0;return}}s[0].end>r&&(r=s[0].end,n=!1)}}function Ze(e,t,n,r,i,a){let o=i.beginRuleCapturedEOL?0:-1,s=[];for(let t=i;t;t=t.pop()){let n=t.getRule(e);n instanceof Ue&&s.push({rule:n,stack:t})}for(let c=s.pop();c;c=s.pop()){let{ruleScanner:s,findOptions:l}=nt(c.rule,e,c.stack.endRule,n,r===o),u=s.findNextMatchSync(t,r,l);if(u){if(u.ruleId!==Ie){i=c.stack.pop();break}u.captureIndices&&u.captureIndices.length&&(a.produce(c.stack,u.captureIndices[0].start),k(e,t,n,c.stack,a,c.rule.whileCaptures,u.captureIndices),a.produce(c.stack,u.captureIndices[0].end),o=u.captureIndices[0].end,u.captureIndices[0].end>r&&(r=u.captureIndices[0].end,n=!1))}else{i=c.stack.pop();break}}return{stack:i,linePos:r,anchorPosition:o,isFirstLine:n}}function Qe(e,t,n,r,i,a){let o=$e(e,t,n,r,i,a),s=e.getInjections();if(s.length===0)return o;let c=et(s,e,t,n,r,i,a);if(!c)return o;if(!o)return c;let l=o.captureIndices[0].start,u=c.captureIndices[0].start;return u<l||c.priorityMatch&&u===l?c:o}function $e(e,t,n,r,i,a){let{ruleScanner:o,findOptions:s}=tt(i.getRule(e),e,i.endRule,n,r===a),c=o.findNextMatchSync(t,r,s);return c?{captureIndices:c.captureIndices,matchedRuleId:c.ruleId}:null}function et(e,t,n,r,i,a,o){let s=Number.MAX_VALUE,c=null,l,u=0,d=a.contentNameScopesList.getScopeNames();for(let a=0,f=e.length;a<f;a++){let f=e[a];if(!f.matcher(d))continue;let{ruleScanner:p,findOptions:m}=tt(t.getRule(f.ruleId),t,null,r,i===o),h=p.findNextMatchSync(n,i,m);if(!h)continue;let g=h.captureIndices[0].start;if(!(g>=s)&&(s=g,c=h.captureIndices,l=h.ruleId,u=f.priority,s===i))break}return c?{priorityMatch:u===-1,captureIndices:c,matchedRuleId:l}:null}function tt(e,t,n,r,i){return{ruleScanner:e.compileAG(t,n,r,i),findOptions:0}}function nt(e,t,n,r,i){return{ruleScanner:e.compileWhileAG(t,n,r,i),findOptions:0}}function k(e,t,n,r,i,a,o){if(a.length===0)return;let s=t.content,c=Math.min(a.length,o.length),l=[],u=o[0].end;for(let t=0;t<c;t++){let c=a[t];if(c===null)continue;let d=o[t];if(d.length===0)continue;if(d.start>u)break;for(;l.length>0&&l[l.length-1].endPos<=d.start;)i.produceFromScopes(l[l.length-1].scopes,l[l.length-1].endPos),l.pop();if(l.length>0?i.produceFromScopes(l[l.length-1].scopes,d.start):i.produce(r,d.start),c.retokenizeCapturedWithRuleId){let t=c.getName(s,o),a=r.contentNameScopesList.pushAttributed(t,e),l=c.getContentName(s,o),u=a.pushAttributed(l,e),f=r.push(c.retokenizeCapturedWithRuleId,d.start,-1,!1,null,a,u),p=e.createOnigString(s.substring(0,d.end));Xe(e,p,n&&d.start===0,d.start,f,i,!1,0),xe(p);continue}let f=c.getName(s,o);if(f!==null){let t=(l.length>0?l[l.length-1].scopes:r.contentNameScopesList).pushAttributed(f,e);l.push(new rt(t,d.end))}}for(;l.length>0;)i.produceFromScopes(l[l.length-1].scopes,l[l.length-1].endPos),l.pop()}var rt=class{scopes;endPos;constructor(e,t){this.scopes=e,this.endPos=t}};function it(e,t,n,r,i,a,o,s){return new ct(e,t,n,r,i,a,o,s)}function at(e,t,n,r,i){let a=S(t,ot),o=We.getCompiledRuleId(n,r,i.repository);for(let n of a)e.push({debugSelector:t,matcher:n.matcher,ruleId:o,grammar:i,priority:n.priority})}function ot(e,t){if(t.length<e.length)return!1;let n=0;return e.every(e=>{for(let r=n;r<t.length;r++)if(st(t[r],e))return n=r+1,!0;return!1})}function st(e,t){if(!e)return!1;if(e===t)return!0;let n=t.length;return e.length>n&&e.substr(0,n)===t&&e[n]===`.`}var ct=class{constructor(e,t,n,r,i,a,o,s){if(this._rootScopeName=e,this.balancedBracketSelectors=a,this._onigLib=s,this._basicScopeAttributesProvider=new qe(n,r),this._rootId=-1,this._lastRuleId=0,this._ruleId2desc=[null],this._includedGrammars={},this._grammarRepository=o,this._grammar=lt(t,null),this._injections=null,this._tokenTypeMatchers=[],i)for(let e of Object.keys(i)){let t=S(e,ot);for(let n of t)this._tokenTypeMatchers.push({matcher:n.matcher,type:i[e]})}}_rootScopeName;balancedBracketSelectors;_onigLib;_rootId;_lastRuleId;_ruleId2desc;_includedGrammars;_grammarRepository;_grammar;_injections;_basicScopeAttributesProvider;_tokenTypeMatchers;get themeProvider(){return this._grammarRepository}dispose(){for(let e of this._ruleId2desc)e&&e.dispose()}createOnigScanner(e){return this._onigLib.createOnigScanner(e)}createOnigString(e){return this._onigLib.createOnigString(e)}getMetadataForScope(e){return this._basicScopeAttributesProvider.getBasicScopeAttributes(e)}_collectInjections(){let e={lookup:e=>e===this._rootScopeName?this._grammar:this.getExternalGrammar(e),injections:e=>this._grammarRepository.injections(e)},t=[],n=this._rootScopeName,r=e.lookup(n);if(r){let e=r.injections;if(e)for(let n in e)at(t,n,e[n],this,r);let i=this._grammarRepository.injections(n);i&&i.forEach(e=>{let n=this.getExternalGrammar(e);if(n){let e=n.injectionSelector;e&&at(t,e,n,this,n)}})}return t.sort((e,t)=>e.priority-t.priority),t}getInjections(){return this._injections===null&&(this._injections=this._collectInjections()),this._injections}registerRule(e){let t=++this._lastRuleId,n=e(Le(t));return this._ruleId2desc[t]=n,n}getRule(e){return this._ruleId2desc[Re(e)]}getExternalGrammar(e,t){if(this._includedGrammars[e])return this._includedGrammars[e];if(this._grammarRepository){let n=this._grammarRepository.lookup(e);if(n)return this._includedGrammars[e]=lt(n,t&&t.$base),this._includedGrammars[e]}}tokenizeLine(e,t,n=0){let r=this._tokenize(e,t,!1,n);return{tokens:r.lineTokens.getResult(r.ruleStack,r.lineLength),ruleStack:r.ruleStack,stoppedEarly:r.stoppedEarly}}tokenizeLine2(e,t,n=0){let r=this._tokenize(e,t,!0,n);return{tokens:r.lineTokens.getBinaryResult(r.ruleStack,r.lineLength),ruleStack:r.ruleStack,stoppedEarly:r.stoppedEarly}}_tokenize(e,t,n,r){this._rootId===-1&&(this._rootId=We.getCompiledRuleId(this._grammar.repository.$self,this,this._grammar.repository),this.getInjections());let i;if(!t||t===ut.NULL){i=!0;let e=this._basicScopeAttributesProvider.getDefaultAttributes(),n=this.themeProvider.getDefaults(),r=x.set(0,e.languageId,e.tokenType,null,n.fontStyle,n.foregroundId,n.backgroundId),a=this.getRule(this._rootId).getName(null,null),o;o=a?A.createRootAndLookUpScopeName(a,r,this):A.createRoot(`unknown`,r),t=new ut(null,this._rootId,-1,-1,!1,null,o,o)}else i=!1,t.reset();e+=`
3
+ `;let a=this.createOnigString(e),o=a.content.length,s=new ft(n,e,this._tokenTypeMatchers,this.balancedBracketSelectors),c=Xe(this,a,i,0,t,s,!0,r);return xe(a),{lineLength:o,lineTokens:s,ruleStack:c.stack,stoppedEarly:c.stoppedEarly}}};function lt(e,t){return e=f(e),e.repository=e.repository||{},e.repository.$self={$vscodeTextmateLocation:e.$vscodeTextmateLocation,patterns:e.patterns,name:e.scopeName},e.repository.$base=t||e.repository.$self,e}var A=class e{constructor(e,t,n){this.parent=e,this.scopePath=t,this.tokenAttributes=n}parent;scopePath;tokenAttributes;static fromExtension(t,n){let r=t,i=t?.scopePath??null;for(let t of n)i=oe.push(i,t.scopeNames),r=new e(r,i,t.encodedTokenAttributes);return r}static createRoot(t,n){return new e(null,new oe(null,t),n)}static createRootAndLookUpScopeName(t,n,r){let i=r.getMetadataForScope(t),a=new oe(null,t),o=r.themeProvider.themeMatch(a),s=e.mergeAttributes(n,i,o);return new e(null,a,s)}get scopeName(){return this.scopePath.scopeName}toString(){return this.getScopeNames().join(` `)}equals(t){return e.equals(this,t)}static equals(e,t){do{if(e===t||!e&&!t)return!0;if(!e||!t||e.scopeName!==t.scopeName||e.tokenAttributes!==t.tokenAttributes)return!1;e=e.parent,t=t.parent}while(1)}static mergeAttributes(e,t,n){let r=-1,i=0,a=0;return n!==null&&(r=n.fontStyle,i=n.foregroundId,a=n.backgroundId),x.set(e,t.languageId,t.tokenType,null,r,i,a)}pushAttributed(t,n){if(t===null)return this;if(t.indexOf(` `)===-1)return e._pushAttributed(this,t,n);let r=t.split(/ /g),i=this;for(let t of r)i=e._pushAttributed(i,t,n);return i}static _pushAttributed(t,n,r){let i=r.getMetadataForScope(n),a=t.scopePath.push(n),o=r.themeProvider.themeMatch(a),s=e.mergeAttributes(t.tokenAttributes,i,o);return new e(t,a,s)}getScopeNames(){return this.scopePath.getSegments()}getExtensionIfDefined(e){let t=[],n=this;for(;n&&n!==e;)t.push({encodedTokenAttributes:n.tokenAttributes,scopeNames:n.scopePath.getExtensionIfDefined(n.parent?.scopePath??null)}),n=n.parent;return n===e?t.reverse():void 0}},ut=class e{constructor(e,t,n,r,i,a,o,s){this.parent=e,this.ruleId=t,this.beginRuleCapturedEOL=i,this.endRule=a,this.nameScopesList=o,this.contentNameScopesList=s,this.depth=this.parent?this.parent.depth+1:1,this._enterPos=n,this._anchorPos=r}parent;ruleId;beginRuleCapturedEOL;endRule;nameScopesList;contentNameScopesList;_stackElementBrand=void 0;static NULL=new e(null,0,0,0,!1,null,null,null);_enterPos;_anchorPos;depth;equals(t){return t!==null&&e._equals(this,t)}static _equals(e,t){return e===t?!0:this._structuralEquals(e,t)?A.equals(e.contentNameScopesList,t.contentNameScopesList):!1}static _structuralEquals(e,t){do{if(e===t||!e&&!t)return!0;if(!e||!t||e.depth!==t.depth||e.ruleId!==t.ruleId||e.endRule!==t.endRule)return!1;e=e.parent,t=t.parent}while(1)}clone(){return this}static _reset(e){for(;e;)e._enterPos=-1,e._anchorPos=-1,e=e.parent}reset(){e._reset(this)}pop(){return this.parent}safePop(){return this.parent?this.parent:this}push(t,n,r,i,a,o,s){return new e(this,t,n,r,i,a,o,s)}getEnterPos(){return this._enterPos}getAnchorPos(){return this._anchorPos}getRule(e){return e.getRule(this.ruleId)}toString(){let e=[];return this._writeString(e,0),`[`+e.join(`,`)+`]`}_writeString(e,t){return this.parent&&(t=this.parent._writeString(e,t)),e[t++]=`(${this.ruleId}, ${this.nameScopesList?.toString()}, ${this.contentNameScopesList?.toString()})`,t}withContentNameScopesList(e){return this.contentNameScopesList===e?this:this.parent.push(this.ruleId,this._enterPos,this._anchorPos,this.beginRuleCapturedEOL,this.endRule,this.nameScopesList,e)}withEndRule(t){return this.endRule===t?this:new e(this.parent,this.ruleId,this._enterPos,this._anchorPos,this.beginRuleCapturedEOL,t,this.nameScopesList,this.contentNameScopesList)}hasSameRuleAs(e){let t=this;for(;t&&t._enterPos===e._enterPos;){if(t.ruleId===e.ruleId)return!0;t=t.parent}return!1}toStateStackFrame(){return{ruleId:Re(this.ruleId),beginRuleCapturedEOL:this.beginRuleCapturedEOL,endRule:this.endRule,nameScopesList:this.nameScopesList?.getExtensionIfDefined(this.parent?.nameScopesList??null)??[],contentNameScopesList:this.contentNameScopesList?.getExtensionIfDefined(this.nameScopesList)??[]}}static pushFrame(t,n){let r=A.fromExtension(t?.nameScopesList??null,n.nameScopesList);return new e(t,Le(n.ruleId),n.enterPos??-1,n.anchorPos??-1,n.beginRuleCapturedEOL,n.endRule,r,A.fromExtension(r,n.contentNameScopesList))}},dt=class{balancedBracketScopes;unbalancedBracketScopes;allowAny=!1;constructor(e,t){this.balancedBracketScopes=e.flatMap(e=>e===`*`?(this.allowAny=!0,[]):S(e,ot).map(e=>e.matcher)),this.unbalancedBracketScopes=t.flatMap(e=>S(e,ot).map(e=>e.matcher))}get matchesAlways(){return this.allowAny&&this.unbalancedBracketScopes.length===0}get matchesNever(){return this.balancedBracketScopes.length===0&&!this.allowAny}match(e){for(let t of this.unbalancedBracketScopes)if(t(e))return!1;for(let t of this.balancedBracketScopes)if(t(e))return!0;return this.allowAny}},ft=class{constructor(e,t,n,r){this.balancedBracketSelectors=r,this._emitBinaryTokens=e,this._tokenTypeOverrides=n,this._lineText=null,this._tokens=[],this._binaryTokens=[],this._lastTokenEndIndex=0}balancedBracketSelectors;_emitBinaryTokens;_lineText;_tokens;_binaryTokens;_lastTokenEndIndex;_tokenTypeOverrides;produce(e,t){this.produceFromScopes(e.contentNameScopesList,t)}produceFromScopes(e,t){if(this._lastTokenEndIndex>=t)return;if(this._emitBinaryTokens){let n=e?.tokenAttributes??0,r=!1;if(this.balancedBracketSelectors?.matchesAlways&&(r=!0),this._tokenTypeOverrides.length>0||this.balancedBracketSelectors&&!this.balancedBracketSelectors.matchesAlways&&!this.balancedBracketSelectors.matchesNever){let t=e?.getScopeNames()??[];for(let e of this._tokenTypeOverrides)e.matcher(t)&&(n=x.set(n,0,_e(e.type),null,-1,0,0));this.balancedBracketSelectors&&(r=this.balancedBracketSelectors.match(t))}if(r&&(n=x.set(n,0,8,r,-1,0,0)),this._binaryTokens.length>0&&this._binaryTokens[this._binaryTokens.length-1]===n){this._lastTokenEndIndex=t;return}this._binaryTokens.push(this._lastTokenEndIndex),this._binaryTokens.push(n),this._lastTokenEndIndex=t;return}let n=e?.getScopeNames()??[];this._tokens.push({startIndex:this._lastTokenEndIndex,endIndex:t,scopes:n}),this._lastTokenEndIndex=t}getResult(e,t){return this._tokens.length>0&&this._tokens[this._tokens.length-1].startIndex===t-1&&this._tokens.pop(),this._tokens.length===0&&(this._lastTokenEndIndex=-1,this.produce(e,t),this._tokens[this._tokens.length-1].startIndex=0),this._tokens}getBinaryResult(e,t){this._binaryTokens.length>0&&this._binaryTokens[this._binaryTokens.length-2]===t-1&&(this._binaryTokens.pop(),this._binaryTokens.pop()),this._binaryTokens.length===0&&(this._lastTokenEndIndex=-1,this.produce(e,t),this._binaryTokens[this._binaryTokens.length-2]=0);let n=new Uint32Array(this._binaryTokens.length);for(let e=0,t=this._binaryTokens.length;e<t;e++)n[e]=this._binaryTokens[e];return n}},pt=class{constructor(e,t){this._onigLib=t,this._theme=e}_onigLib;_grammars=/* @__PURE__ */ new Map;_rawGrammars=/* @__PURE__ */ new Map;_injectionGrammars=/* @__PURE__ */ new Map;_theme;dispose(){for(let e of this._grammars.values())e.dispose()}setTheme(e){this._theme=e}getColorMap(){return this._theme.getColorMap()}addGrammar(e,t){this._rawGrammars.set(e.scopeName,e),t&&this._injectionGrammars.set(e.scopeName,t)}lookup(e){return this._rawGrammars.get(e)}injections(e){return this._injectionGrammars.get(e)}getDefaults(){return this._theme.getDefaults()}themeMatch(e){return this._theme.match(e)}grammarForScopeName(e,t,n,r,i){if(!this._grammars.has(e)){let a=this._rawGrammars.get(e);if(!a)return null;this._grammars.set(e,it(e,a,t,n,r,i,this,this._onigLib))}return this._grammars.get(e)}},mt=class{_options;_syncRegistry;_ensureGrammarCache;constructor(e){this._options=e,this._syncRegistry=new pt(y.createFromRawTheme(e.theme,e.colorMap),e.onigLib),this._ensureGrammarCache=/* @__PURE__ */ new Map}dispose(){this._syncRegistry.dispose()}setTheme(e,t){this._syncRegistry.setTheme(y.createFromRawTheme(e,t))}getColorMap(){return this._syncRegistry.getColorMap()}loadGrammarWithEmbeddedLanguages(e,t,n){return this.loadGrammarWithConfiguration(e,t,{embeddedLanguages:n})}loadGrammarWithConfiguration(e,t,n){return this._loadGrammar(e,t,n.embeddedLanguages,n.tokenTypes,new dt(n.balancedBracketSelectors||[],n.unbalancedBracketSelectors||[]))}loadGrammar(e){return this._loadGrammar(e,0,null,null,null)}_loadGrammar(e,t,n,r,i){let a=new we(this._syncRegistry,e);for(;a.Q.length>0;)a.Q.map(e=>this._loadSingleGrammar(e.scopeName)),a.processQueue();return this._grammarForScopeName(e,t,n,r,i)}_loadSingleGrammar(e){this._ensureGrammarCache.has(e)||(this._doLoadSingleGrammar(e),this._ensureGrammarCache.set(e,!0))}_doLoadSingleGrammar(e){let t=this._options.loadGrammar(e);if(t){let n=typeof this._options.getInjections==`function`?this._options.getInjections(e):void 0;this._syncRegistry.addGrammar(t,n)}}addGrammar(e,t=[],n=0,r=null){return this._syncRegistry.addGrammar(e,t),this._grammarForScopeName(e.scopeName,n,r)}_grammarForScopeName(e,t=0,n=null,r=null,i=null){return this._syncRegistry.grammarForScopeName(e,t,n,r,i)}},j=ut.NULL;function M(e,t){let n=typeof e==`string`?{}:{...e.colorReplacements},r=typeof e==`string`?e:e.name;for(let[e,i]of Object.entries(t?.colorReplacements||{}))typeof i==`string`?n[e]=i:e===r&&Object.assign(n,i);return n}function N(e,t){return e&&(t?.[e?.toLowerCase()]||e)}function ht(e){return Array.isArray(e)?e:[e]}async function P(e){return Promise.resolve(typeof e==`function`?e():e).then(e=>e.default||e)}function F(e){return!e||[`plaintext`,`txt`,`text`,`plain`].includes(e)}function I(e){return e===`ansi`||F(e)}function L(e){return e===`none`}function R(e){return L(e)}const gt=/(\r?\n)/g;function z(e,t=!1){if(e.length===0)return[[``,0]];let n=e.split(gt),r=0,i=[];for(let e=0;e<n.length;e+=2){let a=t?n[e]+(n[e+1]||``):n[e];i.push([a,r]),r+=n[e].length,r+=n[e+1]?.length||0}return i}const _t={light:`#333333`,dark:`#bbbbbb`},vt={light:`#fffffe`,dark:`#1e1e1e`},yt=`__shiki_resolved`;function B(e){if(e?.[yt])return e;let t={...e};t.tokenColors&&!t.settings&&(t.settings=t.tokenColors,delete t.tokenColors),t.type||=`dark`,t.colorReplacements={...t.colorReplacements},t.settings||=[];let{bg:n,fg:r}=t;if(!n||!r){let e=t.settings?t.settings.find(e=>!e.name&&!e.scope):void 0;e?.settings?.foreground&&(r=e.settings.foreground),e?.settings?.background&&(n=e.settings.background),!r&&t?.colors?.[`editor.foreground`]&&(r=t.colors[`editor.foreground`]),!n&&t?.colors?.[`editor.background`]&&(n=t.colors[`editor.background`]),r||=t.type===`light`?_t.light:_t.dark,n||=t.type===`light`?vt.light:vt.dark,t.fg=r,t.bg=n}t.settings[0]&&t.settings[0].settings&&!t.settings[0].scope||t.settings.unshift({settings:{foreground:t.fg,background:t.bg}});let i=0,a=/* @__PURE__ */ new Map;function o(e){if(a.has(e))return a.get(e);i+=1;let n=`#${i.toString(16).padStart(8,`0`).toLowerCase()}`;return t.colorReplacements?.[`#${n}`]?o(e):(a.set(e,n),n)}t.settings=t.settings.map(e=>{let n=e.settings?.foreground&&!e.settings.foreground.startsWith(`#`),r=e.settings?.background&&!e.settings.background.startsWith(`#`);if(!n&&!r)return e;let i={...e,settings:{...e.settings}};if(n){let n=o(e.settings.foreground);t.colorReplacements[n]=e.settings.foreground,i.settings.foreground=n}if(r){let n=o(e.settings.background);t.colorReplacements[n]=e.settings.background,i.settings.background=n}return i});for(let e of Object.keys(t.colors||{}))if((e===`editor.foreground`||e===`editor.background`||e.startsWith(`terminal.ansi`))&&!t.colors[e]?.startsWith(`#`)){let n=o(t.colors[e]);t.colorReplacements[n]=t.colors[e],t.colors[e]=n}return Object.defineProperty(t,yt,{enumerable:!1,writable:!1,value:!0}),t}async function bt(e){return[...new Set((await Promise.all(e.filter(e=>!I(e)).map(async e=>await P(e).then(e=>Array.isArray(e)?e:[e])))).flat())]}async function xt(e){return(await Promise.all(e.map(async e=>R(e)?null:B(await P(e))))).filter(e=>!!e)}function St(e,t){if(!t)return e;if(t[e]){let n=/* @__PURE__ */ new Set([e]);for(;t[e];){if(e=t[e],n.has(e))throw new d(`Circular alias \`${[...n].join(` -> `)} -> ${e}\``);n.add(e)}}return e}var Ct=class extends mt{_resolver;_themes;_langs;_alias;_resolvedThemes=/* @__PURE__ */ new Map;_resolvedGrammars=/* @__PURE__ */ new Map;_langMap=/* @__PURE__ */ new Map;_langGraph=/* @__PURE__ */ new Map;_textmateThemeCache=/* @__PURE__ */ new WeakMap;_loadedThemesCache=null;_loadedLanguagesCache=null;constructor(e,t,n,r={}){super(e),this._resolver=e,this._themes=t,this._langs=n,this._alias=r,this._themes.map(e=>this.loadTheme(e)),this.loadLanguages(this._langs)}getTheme(e){return typeof e==`string`?this._resolvedThemes.get(e):this.loadTheme(e)}loadTheme(e){let t=B(e);return t.name&&(this._resolvedThemes.set(t.name,t),this._loadedThemesCache=null),t}getLoadedThemes(){return this._loadedThemesCache||=[...this._resolvedThemes.keys()],this._loadedThemesCache}setTheme(e){let t=this._textmateThemeCache.get(e);t||(t=y.createFromRawTheme(e),this._textmateThemeCache.set(e,t)),this._syncRegistry.setTheme(t)}getGrammar(e){return e=St(e,this._alias),this._resolvedGrammars.get(e)}loadLanguage(e){if(this.getGrammar(e.name))return;let t=new Set([...this._langMap.values()].filter(t=>t.embeddedLangsLazy?.includes(e.name)));this._resolver.addLanguage(e);let n={balancedBracketSelectors:e.balancedBracketSelectors||[`*`],unbalancedBracketSelectors:e.unbalancedBracketSelectors||[]};this._syncRegistry._rawGrammars.set(e.scopeName,e);let r=this.loadGrammarWithConfiguration(e.scopeName,1,n);r.name=e.name,this._resolvedGrammars.set(e.name,r),e.aliases&&e.aliases.forEach(t=>{this._alias[t]=e.name}),this._loadedLanguagesCache=null;for(let e of t)this.reloadLanguage(e);if(e.injectTo){let t=[...this._langMap.values()].filter(t=>t!==e&&this._resolvedGrammars.has(t.name)&&e.injectTo.some(e=>t.scopeName===e||t.scopeName.startsWith(`${e}.`))&&!this.hasCurrentInjections(t.scopeName));for(let e of t)this.reloadLanguage(e)}}hasCurrentInjections(e){let t=this._syncRegistry?._injectionGrammars?.get(e)||[],n=this._resolver.getInjections(e)||[];return t.length===n.length&&t.every((e,t)=>e===n[t])}reloadLanguage(e){this._syncRegistry?._grammars?.get(e.scopeName)?.dispose(),this._resolvedGrammars.delete(e.name),this._loadedLanguagesCache=null,this._syncRegistry?._grammars?.delete(e.scopeName),this._syncRegistry?._injectionGrammars?.set(e.scopeName,this._resolver.getInjections(e.scopeName)||[]),this.loadLanguage(this._langMap.get(e.name)||e)}dispose(){super.dispose(),this._resolvedThemes.clear(),this._resolvedGrammars.clear(),this._langMap.clear(),this._langGraph.clear(),this._loadedThemesCache=null}loadLanguages(e){for(let t of e)this.resolveEmbeddedLanguages(t);let t=[...this._langGraph.entries()],n=t.filter(([e,t])=>!t);if(n.length){let e=t.filter(([e,t])=>t?(t.embeddedLanguages||t.embeddedLangs)?.some(e=>n.map(([e])=>e).includes(e)):!1).filter(e=>!n.includes(e));throw new d(`Missing languages ${n.map(([e])=>`\`${e}\``).join(`, `)}, required by ${e.map(([e])=>`\`${e}\``).join(`, `)}`)}for(let[e,n]of t)this._resolver.addLanguage(n);for(let[e,n]of t)this.loadLanguage(n)}getLoadedLanguages(){return this._loadedLanguagesCache||=[.../* @__PURE__ */ new Set([...this._resolvedGrammars.keys(),...Object.keys(this._alias)])],this._loadedLanguagesCache}resolveEmbeddedLanguages(e){this._langMap.set(e.name,e),this._langGraph.set(e.name,e);let t=e.embeddedLanguages??e.embeddedLangs;if(t)for(let e of t)this._langGraph.set(e,this._langMap.get(e))}},wt=class{_langs=/* @__PURE__ */ new Map;_scopeToLang=/* @__PURE__ */ new Map;_injections=/* @__PURE__ */ new Map;_onigLib;constructor(e,t){this._onigLib={createOnigScanner:t=>e.createScanner(t),createOnigString:t=>e.createString(t)},t.forEach(e=>this.addLanguage(e))}get onigLib(){return this._onigLib}getLangRegistration(e){return this._langs.get(e)}loadGrammar(e){return this._scopeToLang.get(e)}addLanguage(e){this._langs.set(e.name,e),e.aliases&&e.aliases.forEach(t=>{this._langs.set(t,e)}),this._scopeToLang.set(e.scopeName,e),e.injectTo&&e.injectTo.forEach(t=>{this._injections.get(t)||this._injections.set(t,[]),this._injections.get(t).includes(e.scopeName)||this._injections.get(t).push(e.scopeName)})}getInjections(e){let t=e.split(`.`),n=[];for(let e=1;e<=t.length;e++){let r=t.slice(0,e).join(`.`);n=[...n,...this._injections.get(r)||[]]}return n}};let V=0;function H(e){V+=1,e.warnings!==!1&&V>=10&&V%10==0&&console.warn(`[Shiki] ${V} instances have been created. Shiki is supposed to be used as a singleton, consider refactoring your code to cache your highlighter instance; Or call \`highlighter.dispose()\` to release unused instances.`);let t=!1;if(!e.engine)throw new d("`engine` option is required for synchronous mode");let n=(e.langs||[]).flat(1),r=(e.themes||[]).flat(1).map(B),i=new Ct(new wt(e.engine,n),r,n,e.langAlias),a;function o(t){return St(t,e.langAlias)}function s(e){_();let t=i.getGrammar(typeof e==`string`?e:e.name);if(!t)throw new d(`Language \`${e}\` not found, you may need to load it first`);return t}function c(e){if(e===`none`)return{bg:``,fg:``,name:`none`,settings:[],type:`dark`};_();let t=i.getTheme(e);if(!t)throw new d(`Theme \`${e}\` not found, you may need to load it first`);return t}function l(e){_();let t=c(e);return a!==e&&(i.setTheme(t),a=e),{theme:t,colorMap:i.getColorMap()}}function u(){return _(),i.getLoadedThemes()}function f(){return _(),i.getLoadedLanguages()}function p(...e){_(),i.loadLanguages(e.flat(1))}async function m(...e){return p(await bt(e))}function h(...e){_();for(let t of e.flat(1))i.loadTheme(t)}async function g(...e){return _(),h(await xt(e))}function _(){if(t)throw new d(`Shiki instance has been disposed`)}function v(){t||(t=!0,i.dispose(),--V)}return{setTheme:l,getTheme:c,getLanguage:s,getLoadedThemes:u,getLoadedLanguages:f,resolveLangAlias:o,loadLanguage:m,loadLanguageSync:p,loadTheme:g,loadThemeSync:h,dispose:v,[Symbol.dispose]:v}}const Tt=H;async function U(e){e.engine||console.warn("`engine` option is required. Use `createOnigurumaEngine` or `createJavaScriptRegexEngine` to create an engine.");let[t,n,r]=await Promise.all([xt(e.themes||[]),bt(e.langs||[]),e.engine]);return H({...e,themes:t,langs:n,engine:r})}const Et=U,Dt=/* @__PURE__ */ new WeakMap;function W(e,t){Dt.set(e,t)}function G(e){return Dt.get(e)}var Ot=class e{_stacks={};lang;get themes(){return Object.keys(this._stacks)}get theme(){return this.themes[0]}get _stack(){return this._stacks[this.theme]}static initial(t,n){return new e(Object.fromEntries(ht(n).map(e=>[e,j])),t)}constructor(...e){if(e.length===2){let[t,n]=e;this.lang=n,this._stacks=t}else{let[t,n,r]=e;this.lang=n,this._stacks={[r]:t}}}getInternalStack(e=this.theme){return this._stacks[e]}getScopes(e=this.theme){return kt(this._stacks[e])}toJSON(){return{lang:this.lang,theme:this.theme,themes:this.themes,scopes:this.getScopes()}}};function kt(e){let t=[],n=/* @__PURE__ */ new Set;function r(e){if(n.has(e))return;n.add(e);let i=e?.nameScopesList?.scopeName;i&&t.push(i),e.parent&&r(e.parent)}return r(e),t}function At(e,t){if(!(e instanceof Ot))throw new d(`Invalid grammar state`);return e.getInternalStack(t)}const jt=/,/,Mt=/ /;function Nt(e,t,n={}){let{theme:r=e.getLoadedThemes()[0]}=n;if(F(e.resolveLangAlias(n.lang||`text`))||L(r))return z(t).map(e=>[{content:e[0],offset:e[1]}]);let{theme:i,colorMap:a}=e.setTheme(r),o=e.getLanguage(n.lang||`text`);if(n.grammarState){if(n.grammarState.lang!==o.name)throw new d(`Grammar state language "${n.grammarState.lang}" does not match highlight language "${o.name}"`);if(!n.grammarState.themes.includes(i.name))throw new d(`Grammar state themes "${n.grammarState.themes}" do not contain highlight theme "${i.name}"`)}return Ft(t,o,i,a,n)}function Pt(...e){if(e.length===2)return G(e[1]);let[t,n,r={}]=e,{lang:i=`text`,theme:a=t.getLoadedThemes()[0]}=r;if(F(i)||L(a))throw new d(`Plain language does not have grammar state`);if(i===`ansi`)throw new d(`ANSI language does not have grammar state`);let{theme:o,colorMap:s}=t.setTheme(a),c=t.getLanguage(i);return new Ot(It(n,c,o,s,r).stateStack,c.name,o.name)}function Ft(e,t,n,r,i){let a=It(e,t,n,r,i),o=new Ot(a.stateStack,t.name,n.name);return W(a.tokens,o),a.tokens}function It(e,t,n,r,i){let a=M(n,i),{tokenizeMaxLineLength:o=0,tokenizeTimeLimit:s=500,includeExplanation:c=!1}=i,l=z(e),u=i.grammarState?At(i.grammarState,n.name)??j:i.grammarContextCode==null?j:It(i.grammarContextCode,t,n,r,{...i,grammarState:void 0,grammarContextCode:void 0}).stateStack,d=[],f=[];for(let e=0,i=l.length;e<i;e++){let[i,p]=l[e];if(i===``){d=[],f.push([]);continue}if(o>0&&i.length>=o){d=[],f.push([{content:i,offset:p,color:``,fontStyle:0}]);continue}let m,h,g;c&&c!==`tokenType`&&(m=t.tokenizeLine(i,u,s),h=m.tokens,g=0);let _=t.tokenizeLine2(i,u,s),v=_.tokens.length/2;for(let e=0;e<v;e++){let t=_.tokens[2*e],o=e+1<v?_.tokens[2*e+2]:i.length;if(t===o)continue;let s=_.tokens[2*e+1],l=N(r[x.getForeground(s)],a),u=x.getFontStyle(s),f={content:i.substring(t,o),offset:p+t,color:l,fontStyle:u};if(c===`tokenType`)f.type=x.getTokenType(s);else if(c){let e=[];if(c!==`scopeName`)for(let t of n.settings){let n;switch(typeof t.scope){case`string`:n=t.scope.split(jt).map(e=>e.trim());break;case`object`:n=t.scope;break;default:continue}e.push({settings:t,selectors:n.map(e=>e.split(Mt))})}f.explanation=[];let r=0;for(;t+r<o;){let t=h[g],n=i.substring(t.startIndex,t.endIndex);r+=n.length,f.explanation.push({content:n,scopes:c===`scopeName`?Lt(t.scopes):Rt(e,t.scopes)}),g+=1}}d.push(f)}f.push(d),d=[],u=_.ruleStack}return{tokens:f,stateStack:u}}function Lt(e){return e.map(e=>({scopeName:e}))}function Rt(e,t){let n=[];for(let r=0,i=t.length;r<i;r++){let i=t[r];n[r]={scopeName:i,themeMatches:Vt(e,i,t.slice(0,r))}}return n}function zt(e,t){return e===t||t.substring(0,e.length)===e&&t[e.length]===`.`}function Bt(e,t,n){if(!zt(e.at(-1),t))return!1;let r=e.length-2,i=n.length-1;for(;r>=0&&i>=0;)zt(e[r],n[i])&&--r,--i;return r===-1}function Vt(e,t,n){let r=[];for(let{selectors:i,settings:a}of e)for(let e of i)if(Bt(e,t,n)){r.push(a);break}return r}function K(e,t,n,r=Nt){let i=Object.entries(n.themes).filter(e=>e[1]).map(e=>({color:e[0],theme:e[1]})),a=i.map(i=>{let a=r(e,t,{...n,theme:i.theme});return{tokens:a,state:G(a),theme:typeof i.theme==`string`?i.theme:i.theme.name}}),o=Ht(...a.map(e=>e.tokens)),s=o[0].map((e,t)=>e.map((e,r)=>{let a={content:e.content,variants:{},offset:e.offset};return`includeExplanation`in n&&n.includeExplanation&&(a.explanation=e.explanation),o.forEach((e,n)=>{let{content:o,explanation:s,offset:c,...l}=e[t][r];a.variants[i[n].color]=l}),a})),c=a[0].state?new Ot(Object.fromEntries(a.map(e=>[e.theme,e.state?.getInternalStack(e.theme)])),a[0].state.lang):void 0;return c&&W(s,c),s}function Ht(...e){let t=e.map(()=>[]),n=e.length;for(let r=0;r<e[0].length;r++){let i=e.map(e=>e[r]),a=t.map(()=>[]);t.forEach((e,t)=>e.push(a[t]));let o=i.map(()=>0),s=i.map(e=>e[0]);for(;s.every(e=>e);){let e=Math.min(...s.map(e=>e.content.length));for(let t=0;t<n;t++){let n=s[t];n.content.length===e?(a[t].push(n),o[t]+=1,s[t]=i[t][o[t]]):(a[t].push({...n,content:n.content.slice(0,e)}),s[t]={...n,content:n.content.slice(e),offset:n.offset+e})}}}return t}const Ut=/^>|^->|<!--|-->|--!>|<!-$/g,Wt=[`>`],Gt=[`<`,`>`];function Kt(e,t,n,i){return i.settings.bogusComments?`<?`+r(e.value,Object.assign({},i.settings.characterReferences,{subset:Wt}))+`>`:`<!--`+e.value.replace(Ut,a)+`-->`;function a(e){return r(e,Object.assign({},i.settings.characterReferences,{subset:Gt}))}}function qt(e,t,n,r){return`<!`+(r.settings.upperDoctype?`DOCTYPE`:`doctype`)+(r.settings.tightDoctype?``:` `)+`html>`}const q=Xt(1),Jt=Xt(-1),Yt=[];function Xt(e){return n;function n(n,r,i){let a=n?n.children:Yt,o=(r||0)+e,s=a[o];if(!i)for(;s&&t(s);)o+=e,s=a[o];return s}}const Zt={}.hasOwnProperty;function Qt(e){return t;function t(t,n,r){return Zt.call(e,t.tagName)&&e[t.tagName](t,n,r)}}const $t=Qt({body:nn,caption:en,colgroup:en,dd:sn,dt:on,head:en,html:tn,li:an,optgroup:ln,option:un,p:rn,rp:cn,rt:cn,tbody:fn,td:hn,tfoot:pn,th:hn,thead:dn,tr:mn});function en(e,n,r){let i=q(r,n,!0);return!i||i.type!==`comment`&&!(i.type===`text`&&t(i.value.charAt(0)))}function tn(e,t,n){let r=q(n,t);return!r||r.type!==`comment`}function nn(e,t,n){let r=q(n,t);return!r||r.type!==`comment`}function rn(e,t,n){let r=q(n,t);return r?r.type===`element`&&(r.tagName===`address`||r.tagName===`article`||r.tagName===`aside`||r.tagName===`blockquote`||r.tagName===`details`||r.tagName===`div`||r.tagName===`dl`||r.tagName===`fieldset`||r.tagName===`figcaption`||r.tagName===`figure`||r.tagName===`footer`||r.tagName===`form`||r.tagName===`h1`||r.tagName===`h2`||r.tagName===`h3`||r.tagName===`h4`||r.tagName===`h5`||r.tagName===`h6`||r.tagName===`header`||r.tagName===`hgroup`||r.tagName===`hr`||r.tagName===`main`||r.tagName===`menu`||r.tagName===`nav`||r.tagName===`ol`||r.tagName===`p`||r.tagName===`pre`||r.tagName===`section`||r.tagName===`table`||r.tagName===`ul`):!n||n.type!==`element`||n.tagName!==`a`&&n.tagName!==`audio`&&n.tagName!==`del`&&n.tagName!==`ins`&&n.tagName!==`map`&&n.tagName!==`noscript`&&n.tagName!==`video`&&!n.tagName.includes(`-`)}function an(e,t,n){let r=q(n,t);return!r||r.type===`element`&&r.tagName===`li`}function on(e,t,n){let r=q(n,t);return!(!r||r.type!==`element`||r.tagName!==`dt`&&r.tagName!==`dd`)}function sn(e,t,n){let r=q(n,t);return!r||r.type===`element`&&(r.tagName===`dt`||r.tagName===`dd`)}function cn(e,t,n){let r=q(n,t);return!r||r.type===`element`&&(r.tagName===`rp`||r.tagName===`rt`)}function ln(e,t,n){let r=q(n,t);return!r||r.type===`element`&&r.tagName===`optgroup`}function un(e,t,n){let r=q(n,t);return!r||r.type===`element`&&(r.tagName===`option`||r.tagName===`optgroup`)}function dn(e,t,n){let r=q(n,t);return!(!r||r.type!==`element`||r.tagName!==`tbody`&&r.tagName!==`tfoot`)}function fn(e,t,n){let r=q(n,t);return!r||r.type===`element`&&(r.tagName===`tbody`||r.tagName===`tfoot`)}function pn(e,t,n){return!q(n,t)}function mn(e,t,n){let r=q(n,t);return!r||r.type===`element`&&r.tagName===`tr`}function hn(e,t,n){let r=q(n,t);return!r||r.type===`element`&&(r.tagName===`td`||r.tagName===`th`)}const gn=Qt({body:yn,colgroup:bn,head:vn,html:_n,tbody:xn});function _n(e){let t=q(e,-1);return!t||t.type!==`comment`}function vn(e){let t=/* @__PURE__ */ new Set;for(let n of e.children)if(n.type===`element`&&(n.tagName===`base`||n.tagName===`title`)){if(t.has(n.tagName))return!1;t.add(n.tagName)}let n=e.children[0];return!n||n.type===`element`}function yn(e){let n=q(e,-1,!0);return!n||n.type!==`comment`&&!(n.type===`text`&&t(n.value.charAt(0)))&&(n.type!==`element`||n.tagName!==`meta`&&n.tagName!==`link`&&n.tagName!==`script`&&n.tagName!==`style`&&n.tagName!==`template`)}function bn(e,t,n){let r=Jt(n,t);if(n&&r&&r.type===`element`&&r.tagName===`colgroup`&&$t(r,n.children.indexOf(r),n))return!1;let i=q(e,-1,!0);return!!(i&&i.type===`element`&&i.tagName===`col`)}function xn(e,t,n){let r=Jt(n,t);if(n&&r&&r.type===`element`&&(r.tagName===`thead`||r.tagName===`tbody`)&&$t(r,n.children.indexOf(r),n))return!1;let i=q(e,-1);return!!(i&&i.type===`element`&&i.tagName===`tr`)}const Sn={name:[[`
4
+ \f\r &/=>`.split(``),`
5
+ \f\r "&'/=>\``.split(``)],[`\0
6
+ \f\r "&'/<=>`.split(``),`\0
7
+ \f\r "&'/<=>\``.split(``)]],unquoted:[[`
8
+ \f\r &>`.split(``),`\0
9
+ \f\r "&'<=>\``.split(``)],[`\0
10
+ \f\r "&'<=>\``.split(``),`\0
11
+ \f\r "&'<=>\``.split(``)]],single:[[`&'`.split(``),`"&'\``.split(``)],[`\0&'`.split(``),`\0"&'\``.split(``)]],double:[[`"&`.split(``),`"&'\``.split(``)],[`\0"&`.split(``),`\0"&'\``.split(``)]]},Cn=/* @__PURE__ */ new Set([`desc`,`foreignObject`,`title`]);function wn(e,t,n,r){let{schema:i}=r,o=i.space!==`svg`&&r.settings.omitOptionalTags,c=i.space===`svg`?r.settings.closeEmptyElements:r.settings.voids.includes(e.tagName.toLowerCase()),l=[];i.space===`html`&&e.tagName===`svg`&&(r.schema=a);let u=Tn(r,e.properties);r.schema.space===`svg`&&Cn.has(e.tagName)&&(r.schema=s);let d=r.all(i.space===`html`&&e.tagName===`template`?e.content:e);if(r.schema=i,d&&(c=!1),u||!o||!gn(e,t,n)){if(l.push(`<`,e.tagName,u?` `+u:``),c&&(i.space===`svg`||r.settings.closeSelfClosing)){let e=u.charAt(u.length-1);(!r.settings.tightSelfClosing||e===`/`||e&&e!==`"`&&e!==`'`)&&l.push(` `),l.push(`/`)}l.push(`>`)}return l.push(d),c||o&&$t(e,t,n)||l.push(`</`+e.tagName+`>`),l.join(``)}function Tn(e,t){let n=[],r=-1,i;if(t){for(i in t)if(t[i]!==null&&t[i]!==void 0){let r=En(e,i,t[i]);r&&n.push(r)}}for(;++r<n.length;){let t=e.settings.tightAttributes?n[r].charAt(n[r].length-1):void 0;r!==n.length-1&&t!==`"`&&t!==`'`&&(n[r]+=` `)}return n.join(``)}function En(e,t,a){let s=i(e.schema,t),c=e.settings.allowParseErrors&&e.schema.space===`html`?0:1,u=+!e.settings.allowDangerousCharacters;if(s.overloadedBoolean&&(a===s.attribute||a===``)?a=!0:(s.boolean||s.overloadedBoolean)&&(typeof a!=`string`||a===s.attribute||a===``)&&(a=!!a),a==null||a===!1||typeof a==`number`&&Number.isNaN(a))return``;let d=r(s.attribute,Object.assign({},e.settings.characterReferences,{subset:Sn.name[c][u]}));if(a===!0||(a=Array.isArray(a)?(s.commaSeparated?l:o)(a,{padLeft:!e.settings.tightCommaSeparatedLists}):String(a),e.settings.collapseEmptyAttributes&&!a))return d;let f;if(e.settings.preferUnquoted&&(f=r(a,Object.assign({},e.settings.characterReferences,{attribute:!0,subset:Sn.unquoted[c][u]}))),f!==a){let{quote:t}=e;e.settings.quoteSmart&&n(a,t)>n(a,e.alternative)&&(t=e.alternative),f=t+r(a,Object.assign({},e.settings.characterReferences,{subset:(t===`'`?Sn.single:Sn.double)[c][u],attribute:!0}))+t}return d+(f&&`=`+f)}const Dn=[`<`,`&`],On=/* @__PURE__ */ new Set([`iframe`,`noembed`,`noframes`,`plaintext`,`script`,`style`,`xmp`]);function kn(e,t,n,i){return n&&n.type===`element`&&i.schema.space===`html`&&On.has(n.tagName)?e.value:r(e.value,Object.assign({},i.settings.characterReferences,{subset:Dn}))}function An(e,t,n,r){return r.settings.allowDangerousHtml?e.value:kn(e,t,n,r)}function jn(e,t,n,r){return r.all(e)}const Mn=c(`type`,{invalid:Nn,unknown:Pn,handlers:{comment:Kt,doctype:qt,element:wn,raw:An,root:jn,text:kn}});function Nn(e){throw Error("Expected node, not `"+e+"`")}function Pn(e){throw Error("Cannot compile unknown node `"+e.type+"`")}const Fn={},In={},Ln=[];function Rn(t,n){let r=n||Fn,i=r.quote||`"`;if(i!==`"`&&i!==`'`)throw Error("Invalid quote `"+i+"`, expected `'` or `\"`");let o=i===`"`?`'`:`"`;return{one:zn,all:Bn,settings:{omitOptionalTags:r.omitOptionalTags||!1,allowParseErrors:r.allowParseErrors||!1,allowDangerousCharacters:r.allowDangerousCharacters||!1,quoteSmart:r.quoteSmart||!1,preferUnquoted:r.preferUnquoted||!1,tightAttributes:r.tightAttributes||!1,upperDoctype:r.upperDoctype||!1,tightDoctype:r.tightDoctype||!1,bogusComments:r.bogusComments||!1,tightCommaSeparatedLists:r.tightCommaSeparatedLists||!1,tightSelfClosing:r.tightSelfClosing||!1,collapseEmptyAttributes:r.collapseEmptyAttributes||!1,allowDangerousHtml:r.allowDangerousHtml||!1,voids:r.voids||e,characterReferences:r.characterReferences||In,closeSelfClosing:r.closeSelfClosing||!1,closeEmptyElements:r.closeEmptyElements||!1},schema:r.space===`svg`?a:s,quote:i,alternative:o}.one(Array.isArray(t)?{type:`root`,children:t}:t,void 0,void 0)}function zn(e,t,n){return Mn(e,t,n,this)}function Bn(e){let t=[],n=e&&e.children||Ln,r=-1;for(;++r<n.length;)t[r]=this.one(n[r],r,e);return t.join(``)}const Vn=/\s+/g;function Hn(e,t){if(!t)return e;e.properties||={},e.properties.class||=[],typeof e.properties.class==`string`&&(e.properties.class=e.properties.class.split(Vn)),Array.isArray(e.properties.class)||(e.properties.class=[]);let n=Array.isArray(t)?t:t.split(Vn);for(let t of n)t&&!e.properties.class.includes(t)&&e.properties.class.push(t);return e}const Un=/:?lang=["']([^"']+)["']/g,Wn=/(?:```|~~~)([\w-]+)/g,Gn=/\\begin\{([\w-]+)\}/g,Kn=/<script\s+(?:type|lang)=["']([^"']+)["']/gi,qn=/^\s*---\r?\n[\s\S]*?\r?\n---(?:\r?\n|\s*$)/;function Jn(e){let t=z(e,!0),n=t.map(([e])=>e),r=t.map(([,e])=>e);function i(t){if(t===e.length)return{line:n.length-1,character:n.at(-1).length};let i=0,a=n.length-1;for(;i<a;){let e=i+a+1>>>1;r[e]<=t?i=e:a=e-1}return{line:i,character:t-r[i]}}function a(e,t){return r[e]+t}return{lines:n,indexToPos:i,posToIndex:a}}function Yn(e,t,n){let r=/* @__PURE__ */ new Set;for(let t of e.matchAll(Un)){let e=t[1].toLowerCase().trim();e&&r.add(e)}for(let t of e.matchAll(Wn)){let e=t[1].toLowerCase().trim();e&&r.add(e)}for(let t of e.matchAll(Gn)){let e=t[1].toLowerCase().trim();e&&r.add(e)}for(let t of e.matchAll(Kn)){let e=t[1].toLowerCase().trim(),n=e.includes(`/`)?e.split(`/`).pop():e;n&&r.add(n)}if(qn.test(e)&&r.add(`yaml`),!n)return[...r];let i=n.getBundledLanguages();return[...r].filter(e=>e&&i[e])}const Xn=[`color`,`background-color`];function Zn(e,t){let n=0,r=[];for(let i of t)i>n&&r.push({...e,content:e.content.slice(n,i),offset:e.offset+n}),n=i;return n<e.content.length&&r.push({...e,content:e.content.slice(n),offset:e.offset+n}),r}function Qn(e,t){let n=0,r=e.length;for(;n<r;){let i=n+(r-n>>1);e[i]<=t?n=i+1:r=i}return n}function $n(e,t){let n=[...t instanceof Set?t:new Set(t)].sort((e,t)=>e-t);return n.length?e.map(e=>e.flatMap(e=>{let t=e.offset+e.content.length,r=Qn(n,e.offset),i=r;for(;i<n.length&&n[i]<t;)i++;if(r===i)return e;let a=n.slice(r,i);for(let t=0;t<a.length;t++)a[t]-=e.offset;return Zn(e,a)})):e}function er(e,t,n,r,i=`css-vars`){let a={content:e.content,explanation:e.explanation,offset:e.offset},o=t.map(t=>J(e.variants[t])),s=new Set(o.flatMap(e=>Object.keys(e))),c={},l=(e,r)=>{let i=r===`color`?``:r===`background-color`?`-bg`:`-${r}`;return n+t[e]+(r===`color`?``:i)};return o.forEach((e,n)=>{for(let a of s){let s=e[a]||`inherit`;if(n===0&&r&&Xn.includes(a)){if(r===`light-dark()`&&o.length>1){let e=t.findIndex(e=>e===`light`),r=t.findIndex(e=>e===`dark`);if(e===-1||r===-1)throw new d('When using `defaultColor: "light-dark()"`, you must provide both `light` and `dark` themes');let u=o[e][a]||`inherit`,f=o[r][a]||`inherit`;c[a]=`light-dark(${u}, ${f})`,i===`css-vars`&&(c[l(n,a)]=s)}else c[a]=s}else i===`css-vars`&&(c[l(n,a)]=s)}}),a.htmlStyle=c,a}function J(e){let t={};if(e.color&&(t.color=e.color),e.bgColor&&(t[`background-color`]=e.bgColor),e.fontStyle){e.fontStyle&b.Italic&&(t[`font-style`]=`italic`),e.fontStyle&b.Bold&&(t[`font-weight`]=`bold`);let n=[];e.fontStyle&b.Underline&&n.push(`underline`),e.fontStyle&b.Strikethrough&&n.push(`line-through`),n.length&&(t[`text-decoration`]=n.join(` `))}return t}function Y(e){return typeof e==`string`?e:Object.entries(e).map(([e,t])=>`${e}:${t}`).join(`;`)}function tr(){let e=/* @__PURE__ */ new WeakMap;function t(t){if(!e.has(t.meta)){let n=Jn(t.source);function r(e){if(typeof e==`number`){if(e<0||e>t.source.length)throw new d(`Invalid decoration offset: ${e}. Code length: ${t.source.length}`);return{...n.indexToPos(e),offset:e}}{let t=n.lines[e.line];if(t===void 0)throw new d(`Invalid decoration position ${JSON.stringify(e)}. Lines length: ${n.lines.length}`);let r=e.character;if(r<0&&(r=t.length+r),r<0||r>t.length)throw new d(`Invalid decoration position ${JSON.stringify(e)}. Line ${e.line} length: ${t.length}`);return{...e,character:r,offset:n.posToIndex(e.line,r)}}}let i=(t.options.decorations||[]).map(e=>({...e,start:r(e.start),end:r(e.end)}));nr(i),e.set(t.meta,{decorations:i,converter:n,source:t.source})}return e.get(t.meta)}return{name:`shiki:decorations`,tokens(e){if(this.options.decorations?.length)return $n(e,t(this).decorations.flatMap(e=>[e.start.offset,e.end.offset]))},code(e){if(!this.options.decorations?.length)return;let n=t(this),r=[...e.children].filter(e=>e.type===`element`&&e.tagName===`span`);if(r.length!==n.converter.lines.length)throw new d(`Number of lines in code element (${r.length}) does not match the number of lines in the source (${n.converter.lines.length}). Failed to apply decorations.`);function i(e,t,n,i){let a=r[e],s=``,c=-1,l=-1;if(t===0&&(c=0),n===0&&(l=0),n===1/0&&(l=a.children.length),c===-1||l===-1)for(let e=0;e<a.children.length;e++)s+=ir(a.children[e]),c===-1&&s.length===t&&(c=e+1),l===-1&&s.length===n&&(l=e+1);if(c===-1)throw new d(`Failed to find start index for decoration ${JSON.stringify(i.start)}`);if(l===-1)throw new d(`Failed to find end index for decoration ${JSON.stringify(i.end)}`);let u=a.children.slice(c,l);if(!i.alwaysWrap&&u.length===a.children.length)o(a,i,`line`);else if(!i.alwaysWrap&&u.length===1&&u[0].type===`element`)o(u[0],i,`token`);else{let e={type:`element`,tagName:`span`,properties:{},children:u};o(e,i,`wrapper`),a.children.splice(c,u.length,e)}}function a(e,t){r[e]=o(r[e],t,`line`)}function o(e,t,n){let r=t.properties||{},i=t.transform||(e=>e);return e.tagName=t.tagName||`span`,e.properties={...e.properties,...r,class:e.properties.class},t.properties?.class&&Hn(e,t.properties.class),e=i(e,n)||e,e}let s=[],c=n.decorations.sort((e,t)=>t.start.offset-e.start.offset||e.end.offset-t.end.offset);for(let e of c){let{start:t,end:n}=e;if(t.line===n.line)i(t.line,t.character,n.character,e);else if(t.line<n.line){i(t.line,t.character,1/0,e);for(let r=t.line+1;r<n.line;r++)s.push(()=>a(r,e));i(n.line,0,n.character,e)}}for(let e=s.length-1;e>=0;e--)s[e]()}}}function nr(e){if(!rr(e))for(let t=0;t<e.length;t++){let n=e[t];if(n.start.offset>n.end.offset)throw new d(`Invalid decoration range: ${JSON.stringify(n.start)} - ${JSON.stringify(n.end)}`);for(let r=t+1;r<e.length;r++){let t=e[r],i=n.start.offset<=t.start.offset&&t.start.offset<n.end.offset,a=n.start.offset<t.end.offset&&t.end.offset<=n.end.offset,o=t.start.offset<=n.start.offset&&n.start.offset<t.end.offset,s=t.start.offset<n.end.offset&&n.end.offset<=t.end.offset;if(i||a||o||s){if(i&&a||o&&s||o&&n.start.offset===n.end.offset||a&&t.start.offset===t.end.offset)continue;throw new d(`Decorations ${JSON.stringify(n.start)} and ${JSON.stringify(t.start)} intersect.`)}}}}function rr(e){let t=[],n=/* @__PURE__ */ new Map,r=/* @__PURE__ */ new Map;for(let i=0;i<e.length;i++){let{start:a,end:o}=e[i];if(a.offset>o.offset)return!1;a.offset!==o.offset&&(t.push(e[i]),n.has(a.offset)||n.set(a.offset,i),r.set(o.offset,i))}for(let t=0;t<e.length;t++){let{start:i,end:a}=e[t];if(i.offset===a.offset&&((n.get(i.offset)??t)<t||(r.get(i.offset)??t)>t))return!1}t.sort((e,t)=>e.start.offset-t.start.offset||t.end.offset-e.end.offset);let i=[];for(let{start:e,end:n}of t){for(;i.length&&i.at(-1)<=e.offset;)i.pop();if(i.length&&n.offset>i.at(-1))return!1;i.push(n.offset)}return!0}function ir(e){return e.type===`text`?e.value:e.type===`element`?e.children.map(ir).join(``):``}const ar=[/* @__PURE__ */ tr()];function or(e){let t=sr(e.transformers||[]);return[...t.pre,...t.normal,...t.post,...ar]}function sr(e){let t=[],n=[],r=[];for(let i of e)switch(i.enforce){case`pre`:t.push(i);break;case`post`:n.push(i);break;default:r.push(i)}return{pre:t,post:n,normal:r}}var X=[`black`,`red`,`green`,`yellow`,`blue`,`magenta`,`cyan`,`white`,`brightBlack`,`brightRed`,`brightGreen`,`brightYellow`,`brightBlue`,`brightMagenta`,`brightCyan`,`brightWhite`],cr={1:`bold`,2:`dim`,3:`italic`,4:`underline`,7:`reverse`,8:`hidden`,9:`strikethrough`};function lr(e,t){let n=e.indexOf(`\x1B`,t);if(n!==-1&&e[n+1]===`[`){let t=e.indexOf(`m`,n);if(t!==-1)return{sequence:e.substring(n+2,t).split(`;`),startPosition:n,position:t+1}}return{position:e.length}}function ur(e){let t=e.shift();if(t===`2`){let t=e.splice(0,3).map(e=>Number.parseInt(e));return t.length!==3||t.some(e=>Number.isNaN(e))?void 0:{type:`rgb`,rgb:t}}if(t===`5`){let t=e.shift();if(t)return{type:`table`,index:Number(t)}}}function dr(e){let t=[];for(;e.length>0;){let n=e.shift();if(!n)continue;let r=Number.parseInt(n);if(!Number.isNaN(r)){if(r===0)t.push({type:`resetAll`});else if(r<=9)cr[r]&&t.push({type:`setDecoration`,value:cr[r]});else if(r<=29){let e=cr[r-20];e&&(t.push({type:`resetDecoration`,value:e}),e===`dim`&&t.push({type:`resetDecoration`,value:`bold`}))}else if(r<=37)t.push({type:`setForegroundColor`,value:{type:`named`,name:X[r-30]}});else if(r===38){let n=ur(e);n&&t.push({type:`setForegroundColor`,value:n})}else if(r===39)t.push({type:`resetForegroundColor`});else if(r<=47)t.push({type:`setBackgroundColor`,value:{type:`named`,name:X[r-40]}});else if(r===48){let n=ur(e);n&&t.push({type:`setBackgroundColor`,value:n})}else r===49?t.push({type:`resetBackgroundColor`}):r===53?t.push({type:`setDecoration`,value:`overline`}):r===55?t.push({type:`resetDecoration`,value:`overline`}):r>=90&&r<=97?t.push({type:`setForegroundColor`,value:{type:`named`,name:X[r-90+8]}}):r>=100&&r<=107&&t.push({type:`setBackgroundColor`,value:{type:`named`,name:X[r-100+8]}})}}return t}function fr(){let e=null,t=null,n=/* @__PURE__ */ new Set;return{parse(r){let i=[],a=0;do{let o=lr(r,a),s=o.sequence?r.substring(a,o.startPosition):r.substring(a);if(s.length>0&&i.push({value:s,foreground:e,background:t,decorations:new Set(n)}),o.sequence){let r=dr(o.sequence);for(let i of r)i.type===`resetAll`?(e=null,t=null,n.clear()):i.type===`resetForegroundColor`?e=null:i.type===`resetBackgroundColor`?t=null:i.type===`resetDecoration`&&n.delete(i.value);for(let i of r)i.type===`setForegroundColor`?e=i.value:i.type===`setBackgroundColor`?t=i.value:i.type===`setDecoration`&&n.add(i.value)}a=o.position}while(a<r.length);return i}}}var pr={black:`#000000`,red:`#bb0000`,green:`#00bb00`,yellow:`#bbbb00`,blue:`#0000bb`,magenta:`#ff00ff`,cyan:`#00bbbb`,white:`#eeeeee`,brightBlack:`#555555`,brightRed:`#ff5555`,brightGreen:`#00ff00`,brightYellow:`#ffff55`,brightBlue:`#5555ff`,brightMagenta:`#ff55ff`,brightCyan:`#55ffff`,brightWhite:`#ffffff`};function mr(e=pr){function t(t){return e[t]}function n(e){return`#${e.map(e=>Math.max(0,Math.min(e,255)).toString(16).padStart(2,`0`)).join(``)}`}let r;function i(){if(r)return r;r=[];for(let e=0;e<X.length;e++)r.push(t(X[e]));let e=[0,95,135,175,215,255];for(let t=0;t<6;t++)for(let i=0;i<6;i++)for(let a=0;a<6;a++)r.push(n([e[t],e[i],e[a]]));let i=8;for(let e=0;e<24;e++,i+=10)r.push(n([i,i,i]));return r}function a(e){return i()[e]}function o(e){switch(e.type){case`named`:return t(e.name);case`rgb`:return n(e.rgb);case`table`:return a(e.index)}}return{value:o}}const hr=/#([0-9a-f]{3,8})/i,gr=/var\((--[\w-]+-ansi-[\w-]+)\)/,_r={black:`#000000`,red:`#cd3131`,green:`#0DBC79`,yellow:`#E5E510`,blue:`#2472C8`,magenta:`#BC3FBC`,cyan:`#11A8CD`,white:`#E5E5E5`,brightBlack:`#666666`,brightRed:`#F14C4C`,brightGreen:`#23D18B`,brightYellow:`#F5F543`,brightBlue:`#3B8EEA`,brightMagenta:`#D670D6`,brightCyan:`#29B8DB`,brightWhite:`#FFFFFF`};function vr(e,t,n){let r=M(e,n),i=z(t),a=mr(Object.fromEntries(X.map(t=>{let n=`terminal.ansi${t[0].toUpperCase()}${t.substring(1)}`;return[t,e.colors?.[n]||_r[t]]}))),o=fr();return i.map(t=>o.parse(t[0]).map(n=>{let i,o;n.decorations.has(`reverse`)?(i=n.background?a.value(n.background):e.bg,o=n.foreground?a.value(n.foreground):e.fg):(i=n.foreground?a.value(n.foreground):e.fg,o=n.background?a.value(n.background):void 0),i=N(i,r),o=N(o,r),n.decorations.has(`dim`)&&(i=yr(i));let s=b.None;return n.decorations.has(`bold`)&&(s|=b.Bold),n.decorations.has(`italic`)&&(s|=b.Italic),n.decorations.has(`underline`)&&(s|=b.Underline),n.decorations.has(`strikethrough`)&&(s|=b.Strikethrough),{content:n.value,offset:t[1],color:i,bgColor:o,fontStyle:s}}))}function yr(e){let t=e.match(hr);if(t){let e=t[1];if(e.length===8){let t=Math.round(Number.parseInt(e.slice(6,8),16)/2).toString(16).padStart(2,`0`);return`#${e.slice(0,6)}${t}`}if(e.length===6)return`#${e}80`;if(e.length===4){let t=e[0],n=e[1],r=e[2],i=e[3];return`#${t}${t}${n}${n}${r}${r}${Math.round(Number.parseInt(`${i}${i}`,16)/2).toString(16).padStart(2,`0`)}`}if(e.length===3){let t=e[0],n=e[1],r=e[2];return`#${t}${t}${n}${n}${r}${r}80`}}let n=e.match(gr);return n?`var(${n[1]}-dim)`:e}function Z(e,t,n={}){let r=e.resolveLangAlias(n.lang||`text`),{theme:i=e.getLoadedThemes()[0]}=n;if(!F(r)&&!L(i)&&r===`ansi`){let{theme:r}=e.setTheme(i);return vr(r,t,n)}return Nt(e,t,n)}function Q(e,t,n){let r,i,a,o,s,c;if(`themes`in n){let{defaultColor:l=`light`,cssVariablePrefix:u=`--shiki-`,colorsRendering:f=`css-vars`}=n,p=Object.entries(n.themes).filter(e=>e[1]).map(e=>({color:e[0],theme:e[1]})).sort((e,t)=>e.color===l?-1:+(t.color===l));if(p.length===0)throw new d("`themes` option must not be empty");let m=K(e,t,n,Z);if(c=G(m),l&&l!==`light-dark()`&&!p.some(e=>e.color===l))throw new d(`\`themes\` option must contain the defaultColor key \`${l}\``);let h=p.map(t=>e.getTheme(t.theme)),g=p.map(e=>e.color);a=m.map(e=>e.map(e=>er(e,g,u,l,f))),c&&W(a,c);let _=p.map(e=>M(e.theme,n));i=br(p,h,_,u,l,`fg`,f),r=br(p,h,_,u,l,`bg`,f),o=`shiki-themes ${h.map(e=>e.name).join(` `)}`,s=l?void 0:[i,r].join(`;`)}else if(`theme`in n){let s=M(n.theme,n);a=Z(e,t,n);let l=e.getTheme(n.theme);r=N(l.bg,s),i=N(l.fg,s),o=l.name,c=G(a)}else throw new d("Invalid options, either `theme` or `themes` must be provided");return{tokens:a,fg:i,bg:r,themeName:o,rootStyle:s,grammarState:c}}function br(e,t,n,r,i,a,o){return e.map((s,c)=>{let l=N(t[c][a],n[c])||`inherit`,u=`${r+s.color}${a===`bg`?`-bg`:``}:${l}`;if(c===0&&i){if(i===`light-dark()`&&e.length>1){let r=e.findIndex(e=>e.color===`light`),i=e.findIndex(e=>e.color===`dark`);if(r===-1||i===-1)throw new d('When using `defaultColor: "light-dark()"`, you must provide both `light` and `dark` themes');return`light-dark(${N(t[r][a],n[r])||`inherit`}, ${N(t[i][a],n[i])||`inherit`});${u}`}return l}return o===`css-vars`?u:null}).filter(e=>!!e).join(`;`)}const xr=/^\s+$/,Sr=/^(\s*)(.*?)(\s*)$/;function $(e,t,n,r={meta:{},options:n,codeToHast:(t,n)=>$(e,t,n),codeToTokens:(t,n)=>Q(e,t,n)}){let i=t;for(let e of or(n))i=e.preprocess?.call(r,i,n)||i;let{tokens:a,fg:o,bg:s,themeName:c,rootStyle:l,grammarState:u}=Q(e,i,n),{mergeWhitespaces:d=!0,mergeSameStyleTokens:f=!1}=n;d===!0?a=wr(a):d===`never`&&(a=Tr(a)),f&&(a=Er(a));let p={...r,get source(){return i}};for(let e of or(n))a=e.tokens?.call(p,a)||a;return Cr(a,{...n,fg:o,bg:s,themeName:c,rootStyle:n.rootStyle===!1?!1:n.rootStyle??l},p,u)}function Cr(e,t,n,r=G(e)){let i=or(t),a=[],o={type:`root`,children:[]},{structure:s=`classic`,tabindex:c=`0`}=t,l={class:`shiki ${t.themeName||``}`};t.rootStyle!==!1&&(l.style=t.rootStyle==null?`background-color:${t.bg};color:${t.fg}`:t.rootStyle),c!==!1&&c!=null&&(l.tabindex=c.toString());for(let[e,n]of Object.entries(t.meta||{}))e.startsWith(`_`)||(l[e]=n);let u={type:`element`,tagName:`pre`,properties:l,children:[],data:t.data},d={type:`element`,tagName:`code`,properties:{},children:a},f=[],p={...n,structure:s,addClassToHast:Hn,get source(){return n.source},get tokens(){return e},get options(){return t},get root(){return o},get pre(){return u},get code(){return d},get lines(){return f}};if(e.forEach((e,t)=>{t&&(s===`inline`?o.children.push({type:`element`,tagName:`br`,properties:{},children:[]}):s===`classic`&&a.push({type:`text`,value:`
12
+ `}));let n={type:`element`,tagName:`span`,properties:{class:`line`},children:[]},r=0;for(let a of e){let e={type:`element`,tagName:`span`,properties:{...a.htmlAttrs},children:[{type:`text`,value:a.content}]},c=Y(a.htmlStyle||J(a));c&&(e.properties.style=c);for(let o of i)e=o?.span?.call(p,e,t+1,r,n,a)||e;s===`inline`?o.children.push(e):s===`classic`&&n.children.push(e),r+=a.content.length}if(s===`classic`){for(let e of i)n=e?.line?.call(p,n,t+1)||n;f.push(n),a.push(n)}else s===`inline`&&f.push(n)}),s===`classic`){for(let e of i)d=e?.code?.call(p,d)||d;u.children.push(d);for(let e of i)u=e?.pre?.call(p,u)||u;o.children.push(u)}else if(s===`inline`){let e=[],t={type:`element`,tagName:`span`,properties:{class:`line`},children:[]};for(let n of o.children)n.type===`element`&&n.tagName===`br`?(e.push(t),t={type:`element`,tagName:`span`,properties:{class:`line`},children:[]}):(n.type===`element`||n.type===`text`)&&t.children.push(n);e.push(t);let n={type:`element`,tagName:`code`,properties:{},children:e};for(let e of i)n=e?.code?.call(p,n)||n;o.children=[];for(let e=0;e<n.children.length;e++){e>0&&o.children.push({type:`element`,tagName:`br`,properties:{},children:[]});let t=n.children[e];t.type===`element`&&o.children.push(...t.children)}}let m=o;for(let e of i)m=e?.root?.call(p,m)||m;return r&&W(m,r),m}function wr(e){return e.map(e=>{let t=[],n=``,r;return e.forEach((i,a)=>{let o=!(i.fontStyle&&(i.fontStyle&b.Underline||i.fontStyle&b.Strikethrough));o&&xr.test(i.content)&&e[a+1]?(r===void 0&&(r=i.offset),n+=i.content):n?(o?t.push({...i,offset:r,content:n+i.content}):t.push({content:n,offset:r},i),r=void 0,n=``):t.push(i)}),t})}function Tr(e){return e.map(e=>e.flatMap(e=>{if(xr.test(e.content))return e;let t=e.content.match(Sr);if(!t)return e;let[,n,r,i]=t;if(!n&&!i)return e;let a=[{...e,offset:e.offset+n.length,content:r}];return n&&a.unshift({content:n,offset:e.offset}),i&&a.push({content:i,offset:e.offset+n.length+r.length}),a}))}function Er(e){return e.map(e=>{let t=[];for(let n of e){if(t.length===0){t.push({...n});continue}let e=t.at(-1),r=Y(e.htmlStyle||J(e)),i=Y(n.htmlStyle||J(n)),a=e.fontStyle&&(e.fontStyle&b.Underline||e.fontStyle&b.Strikethrough),o=n.fontStyle&&(n.fontStyle&b.Underline||n.fontStyle&b.Strikethrough);!a&&!o&&r===i?e.content+=n.content:t.push({...n})}return t})}const Dr=Rn;function Or(e,t,n){let r={meta:{},options:n,codeToHast:(t,n)=>$(e,t,n),codeToTokens:(t,n)=>Q(e,t,n)},i=Dr($(e,t,n,r));for(let e of or(n))i=e.postprocess?.call(r,i,n)||i;return i}async function kr(e){let t=await U(e);return{getLastGrammarState:(...e)=>Pt(t,...e),codeToTokensBase:(e,n)=>Z(t,e,n),codeToTokensWithThemes:(e,n)=>K(t,e,n),codeToTokens:(e,n)=>Q(t,e,n),codeToHast:(e,n)=>$(t,e,n),codeToHtml:(e,n)=>Or(t,e,n),getBundledLanguages:()=>({}),getBundledThemes:()=>({}),...t,getInternalContext:()=>t}}function Ar(e){let t=H(e);return{getLastGrammarState:(...e)=>Pt(t,...e),codeToTokensBase:(e,n)=>Z(t,e,n),codeToTokensWithThemes:(e,n)=>K(t,e,n),codeToTokens:(e,n)=>Q(t,e,n),codeToHast:(e,n)=>$(t,e,n),codeToHtml:(e,n)=>Or(t,e,n),getBundledLanguages:()=>({}),getBundledThemes:()=>({}),...t,getInternalContext:()=>t}}function jr(e){let t;async function n(n){if(t){let e=await t;return await Promise.all([e.loadTheme(...n.themes||[]),e.loadLanguage(...n.langs||[])]),e}return t=e({...n,themes:n.themes||[],langs:n.langs||[]}),t}return n}const Mr=/* @__PURE__ */ jr(kr);function Nr(e){let t=e.langs,n=e.themes,r=e.engine;async function i(e){function i(n){if(typeof n==`string`){if(n=e.langAlias?.[n]||n,I(n))return[];let r=t[n];if(!r)throw new d(`Language \`${n}\` is not included in this bundle. You may want to load it from external source.`);return r}return n}function a(e){if(R(e))return`none`;if(typeof e==`string`){let t=n[e];if(!t)throw new d(`Theme \`${e}\` is not included in this bundle. You may want to load it from external source.`);return t}return e}let o=(e.themes??[]).map(e=>a(e)),s=(e.langs??[]).map(e=>i(e)),c=await kr({engine:e.engine??r(),...e,themes:o,langs:s});return{...c,loadLanguage(...e){return c.loadLanguage(...e.map(i))},loadTheme(...e){return c.loadTheme(...e.map(a))},getBundledLanguages(){return t},getBundledThemes(){return n}}}return i}function Pr(e){let t;async function n(n={}){if(t){let e=await t;return await Promise.all([e.loadTheme(...n.themes||[]),e.loadLanguage(...n.langs||[])]),e}{t=e({...n,themes:[],langs:[]});let r=await t;return await Promise.all([r.loadTheme(...n.themes||[]),r.loadLanguage(...n.langs||[])]),r}}return n}function Fr(e,t){let n=Pr(e);async function r(e,r){let i=await n({langs:[r.lang],themes:`theme`in r?[r.theme]:Object.values(r.themes)}),a=await t?.guessEmbeddedLanguages?.(e,r.lang,i);return a&&await i.loadLanguage(...a),i}return{getSingletonHighlighter(e){return n(e)},async codeToHtml(e,t){return(await r(e,t)).codeToHtml(e,t)},async codeToHast(e,t){return(await r(e,t)).codeToHast(e,t)},async codeToTokens(e,t){return(await r(e,t)).codeToTokens(e,t)},async codeToTokensBase(e,t){return(await r(e,t)).codeToTokensBase(e,t)},async codeToTokensWithThemes(e,t){return(await r(e,t)).codeToTokensWithThemes(e,t)},async getLastGrammarState(e,t){return(await n({langs:[t.lang],themes:[t.theme]})).getLastGrammarState(e,t)}}}function Ir(e={}){let{name:t=`css-variables`,variablePrefix:n=`--shiki-`,fontStyle:r=!0}=e,i=t=>e.variableDefaults?.[t]?`var(${n}${t}, ${e.variableDefaults[t]})`:`var(${n}${t})`,a={name:t,type:`dark`,colors:{"editor.foreground":i(`foreground`),"editor.background":i(`background`),"terminal.ansiBlack":i(`ansi-black`),"terminal.ansiRed":i(`ansi-red`),"terminal.ansiGreen":i(`ansi-green`),"terminal.ansiYellow":i(`ansi-yellow`),"terminal.ansiBlue":i(`ansi-blue`),"terminal.ansiMagenta":i(`ansi-magenta`),"terminal.ansiCyan":i(`ansi-cyan`),"terminal.ansiWhite":i(`ansi-white`),"terminal.ansiBrightBlack":i(`ansi-bright-black`),"terminal.ansiBrightRed":i(`ansi-bright-red`),"terminal.ansiBrightGreen":i(`ansi-bright-green`),"terminal.ansiBrightYellow":i(`ansi-bright-yellow`),"terminal.ansiBrightBlue":i(`ansi-bright-blue`),"terminal.ansiBrightMagenta":i(`ansi-bright-magenta`),"terminal.ansiBrightCyan":i(`ansi-bright-cyan`),"terminal.ansiBrightWhite":i(`ansi-bright-white`)},tokenColors:[{scope:[`keyword.operator.accessor`,`meta.group.braces.round.function.arguments`,`meta.template.expression`,`markup.fenced_code meta.embedded.block`],settings:{foreground:i(`foreground`)}},{scope:`emphasis`,settings:{fontStyle:`italic`}},{scope:[`strong`,`markup.heading.markdown`,`markup.bold.markdown`],settings:{fontStyle:`bold`}},{scope:[`markup.italic.markdown`],settings:{fontStyle:`italic`}},{scope:`meta.link.inline.markdown`,settings:{fontStyle:`underline`,foreground:i(`token-link`)}},{scope:[`string`,`markup.fenced_code`,`markup.inline`],settings:{foreground:i(`token-string`)}},{scope:[`comment`,`string.quoted.docstring.multi`],settings:{foreground:i(`token-comment`)}},{scope:[`constant.numeric`,`constant.language`,`constant.other.placeholder`,`constant.character.format.placeholder`,`variable.language.this`,`variable.other.object`,`variable.other.class`,`variable.other.constant`,`meta.property-name`,`meta.property-value`,`support`],settings:{foreground:i(`token-constant`)}},{scope:[`keyword`,`storage.modifier`,`storage.type`,`storage.control.clojure`,`entity.name.function.clojure`,`entity.name.tag.yaml`,`support.function.node`,`support.type.property-name.json`,`punctuation.separator.key-value`,`punctuation.definition.template-expression`],settings:{foreground:i(`token-keyword`)}},{scope:`variable.parameter.function`,settings:{foreground:i(`token-parameter`)}},{scope:[`support.function`,`entity.name.type`,`entity.other.inherited-class`,`meta.function-call`,`meta.instance.constructor`,`entity.other.attribute-name`,`entity.name.function`,`constant.keyword.clojure`],settings:{foreground:i(`token-function`)}},{scope:[`entity.name.tag`,`string.quoted`,`string.regexp`,`string.interpolated`,`string.template`,`string.unquoted.plain.out.yaml`,`keyword.other.template`],settings:{foreground:i(`token-string-expression`)}},{scope:[`punctuation.definition.arguments`,`punctuation.definition.dict`,`punctuation.separator`,`meta.function-call.arguments`],settings:{foreground:i(`token-punctuation`)}},{scope:[`markup.underline.link`,`punctuation.definition.metadata.markdown`],settings:{foreground:i(`token-link`)}},{scope:[`beginning.punctuation.definition.list.markdown`],settings:{foreground:i(`token-string`)}},{scope:[`punctuation.definition.string.begin.markdown`,`punctuation.definition.string.end.markdown`,`string.other.link.title.markdown`,`string.other.link.description.markdown`],settings:{foreground:i(`token-keyword`)}},{scope:[`markup.inserted`,`meta.diff.header.to-file`,`punctuation.definition.inserted`],settings:{foreground:i(`token-inserted`)}},{scope:[`markup.deleted`,`meta.diff.header.from-file`,`punctuation.definition.deleted`],settings:{foreground:i(`token-deleted`)}},{scope:[`markup.changed`,`punctuation.definition.changed`],settings:{foreground:i(`token-changed`)}}]};return r||(a.tokenColors=a.tokenColors?.map(e=>(e.settings?.fontStyle&&delete e.settings.fontStyle,e))),a}var Lr=/* @__PURE__ */ u({ShikiError:()=>d,addClassToHast:()=>Hn,applyColorReplacements:()=>N,codeToHast:()=>$,codeToHtml:()=>Or,codeToTokens:()=>Q,codeToTokensBase:()=>Z,codeToTokensWithThemes:()=>K,createBundledHighlighter:()=>Nr,createCssVariablesTheme:()=>Ir,createHighlighterCore:()=>kr,createHighlighterCoreSync:()=>Ar,createPositionConverter:()=>Jn,createShikiInternal:()=>Et,createShikiInternalSync:()=>Tt,createShikiPrimitive:()=>H,createShikiPrimitiveAsync:()=>U,createSingletonShorthands:()=>Fr,flatTokenVariants:()=>er,getLastGrammarState:()=>Pt,getSingletonHighlighterCore:()=>Mr,getTokenStyleObject:()=>J,guessEmbeddedLanguages:()=>Yn,hastToHtml:()=>Dr,isNoneTheme:()=>L,isPlainLang:()=>F,isSpecialLang:()=>I,isSpecialTheme:()=>R,makeSingletonHighlighter:()=>Pr,makeSingletonHighlighterCore:()=>jr,normalizeGetter:()=>P,normalizeTheme:()=>B,resolveColorReplacements:()=>M,splitLines:()=>z,splitToken:()=>Zn,splitTokens:()=>$n,stringifyTokenStyle:()=>Y,toArray:()=>ht,tokenizeAnsiWithTheme:()=>vr,tokenizeWithTheme:()=>Ft,tokensToHast:()=>Cr,transformerDecorations:()=>tr});export{d as ShikiError,Hn as addClassToHast,N as applyColorReplacements,$ as codeToHast,Or as codeToHtml,Q as codeToTokens,Z as codeToTokensBase,K as codeToTokensWithThemes,Nr as createBundledHighlighter,Ir as createCssVariablesTheme,kr as createHighlighterCore,Ar as createHighlighterCoreSync,Jn as createPositionConverter,Et as createShikiInternal,Tt as createShikiInternalSync,H as createShikiPrimitive,U as createShikiPrimitiveAsync,Fr as createSingletonShorthands,er as flatTokenVariants,Pt as getLastGrammarState,Mr as getSingletonHighlighterCore,J as getTokenStyleObject,Yn as guessEmbeddedLanguages,Dr as hastToHtml,L as isNoneTheme,F as isPlainLang,I as isSpecialLang,R as isSpecialTheme,Pr as makeSingletonHighlighter,jr as makeSingletonHighlighterCore,x as n,P as normalizeGetter,B as normalizeTheme,j as r,M as resolveColorReplacements,z as splitLines,Zn as splitToken,$n as splitTokens,Y as stringifyTokenStyle,Lr as t,ht as toArray,vr as tokenizeAnsiWithTheme,Ft as tokenizeWithTheme,Cr as tokensToHast,tr as transformerDecorations};