@hienlh/ppm 0.2.0 → 0.2.1

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 (36) hide show
  1. package/dist/web/assets/{button-KIZetva8.js → button-CvHWF07y.js} +1 -1
  2. package/dist/web/assets/{chat-tab-D7dR7kbZ.js → chat-tab-C4ovA2w4.js} +3 -3
  3. package/dist/web/assets/{code-editor-r8P6Gk4M.js → code-editor-BgiyQO-M.js} +1 -1
  4. package/dist/web/assets/{dialog-D8ulRTfX.js → dialog-f3IZM-6v.js} +1 -1
  5. package/dist/web/assets/{diff-viewer-vSvrem_i.js → diff-viewer-8_asmBRZ.js} +1 -1
  6. package/dist/web/assets/{dist-C4W3AGh3.js → dist-CCBctnax.js} +1 -1
  7. package/dist/web/assets/{git-graph-Cn-s1k0-.js → git-graph-BiyTIbCz.js} +1 -1
  8. package/dist/web/assets/{git-status-panel-QjAQzNAi.js → git-status-panel-BifyO31N.js} +1 -1
  9. package/dist/web/assets/index-DILaVO6p.css +2 -0
  10. package/dist/web/assets/index-DasstYgw.js +11 -0
  11. package/dist/web/assets/project-list-C7L3hZct.js +1 -0
  12. package/dist/web/assets/settings-tab-Cn5Ja0_J.js +1 -0
  13. package/dist/web/assets/{terminal-tab-DDf6S-Tu.js → terminal-tab-CyjhG4Ao.js} +1 -1
  14. package/dist/web/index.html +8 -8
  15. package/dist/web/sw.js +1 -1
  16. package/package.json +3 -2
  17. package/src/cli/commands/init.ts +11 -1
  18. package/src/cli/commands/logs.ts +58 -0
  19. package/src/cli/commands/report.ts +60 -0
  20. package/src/index.ts +20 -1
  21. package/src/server/index.ts +82 -4
  22. package/src/types/config.ts +2 -0
  23. package/src/web/app.tsx +8 -0
  24. package/src/web/components/auth/login-screen.tsx +8 -1
  25. package/src/web/components/layout/sidebar.tsx +15 -0
  26. package/src/web/components/ui/sonner.tsx +9 -6
  27. package/src/web/hooks/use-health-check.ts +95 -0
  28. package/src/web/stores/settings-store.ts +19 -0
  29. package/src/web/stores/tab-store.ts +28 -8
  30. package/dist/web/assets/index-DUBI96T5.css +0 -2
  31. package/dist/web/assets/index-nk1dAWff.js +0 -10
  32. package/dist/web/assets/project-list-DqiatpaH.js +0 -1
  33. package/dist/web/assets/settings-tab-iCGeFFdt.js +0 -1
  34. /package/dist/web/assets/{dist-PA84y4Ga.js → dist-B6sG2GPc.js} +0 -0
  35. /package/dist/web/assets/{react-BSLFEYu8.js → react-gOPBns57.js} +0 -0
  36. /package/dist/web/assets/{utils-DpJF9mAi.js → utils-61GRB9Cb.js} +0 -0
@@ -1,2 +1,2 @@
1
- import{a as e,n as t,r as n,t as r}from"./jsx-runtime-BFALxl05.js";import{n as i,t as a}from"./marked.esm-Cv8mjgnt.js";import{t as o}from"./external-link-Dim3NH6h.js";import{n as s,r as c,t as l}from"./api-client-BgVufYKf.js";import{_ as u,u as d}from"./index-nk1dAWff.js";import{$ as f,A as p,B as m,C as h,D as g,E as _,F as v,G as y,H as b,J as x,K as S,L as C,M as w,N as T,O as E,P as D,Q as O,R as k,S as A,T as j,U as ee,V as M,W as te,X as ne,Z as re,_ as ie,a as ae,b as oe,c as se,ct as ce,d as le,dt as ue,f as de,ft as fe,g as pe,gt as me,h as he,ht as N,i as ge,it as _e,j as ve,l as ye,lt as be,m as xe,mt as Se,n as Ce,nt as we,o as Te,ot as Ee,p as De,pt as Oe,q as ke,r as Ae,rt as je,s as Me,st as P,t as Ne,tt as F,u as Pe,ut as Fe,v as Ie,w as Le,x as Re,y as ze,z as Be}from"./dist-CBiGQxfr.js";var Ve=t(`eye`,[[`path`,{d:`M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0`,key:`1nclc0`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),He=t(`file-exclamation-point`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M12 9v4`,key:`juzpu7`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),I=e(n());function Ue(){return Ue=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Ue.apply(null,arguments)}function We(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}var Ge=e=>{let{state:t}=e,n=t.doc.lineAt(t.selection.main.from),r=Xe(e.state,n.from);return r.line?qe(e):r.block?Ye(e):!1};function Ke(e,t){return({state:n,dispatch:r})=>{if(n.readOnly)return!1;let i=e(t,n);return i?(r(n.update(i)),!0):!1}}var qe=Ke(tt,0),Je=Ke(et,0),Ye=Ke((e,t)=>et(e,t,$e(t)),0);function Xe(e,t){let n=e.languageDataAt(`commentTokens`,t,1);return n.length?n[0]:{}}var Ze=50;function Qe(e,{open:t,close:n},r,i){let a=e.sliceDoc(r-Ze,r),o=e.sliceDoc(i,i+Ze),s=/\s*$/.exec(a)[0].length,c=/^\s*/.exec(o)[0].length,l=a.length-s;if(a.slice(l-t.length,l)==t&&o.slice(c,c+n.length)==n)return{open:{pos:r-s,margin:s&&1},close:{pos:i+c,margin:c&&1}};let u,d;i-r<=2*Ze?u=d=e.sliceDoc(r,i):(u=e.sliceDoc(r,r+Ze),d=e.sliceDoc(i-Ze,i));let f=/^\s*/.exec(u)[0].length,p=/\s*$/.exec(d)[0].length,m=d.length-p-n.length;return u.slice(f,f+t.length)==t&&d.slice(m,m+n.length)==n?{open:{pos:r+f+t.length,margin:/\s/.test(u.charAt(f+t.length))?1:0},close:{pos:i-p-n.length,margin:/\s/.test(d.charAt(m-1))?1:0}}:null}function $e(e){let t=[];for(let n of e.selection.ranges){let r=e.doc.lineAt(n.from),i=n.to<=r.to?r:e.doc.lineAt(n.to);i.from>r.from&&i.from==n.to&&(i=n.to==r.to+1?r:e.doc.lineAt(n.to-1));let a=t.length-1;a>=0&&t[a].to>r.from?t[a].to=i.to:t.push({from:r.from+/^\s*/.exec(r.text)[0].length,to:i.to})}return t}function et(e,t,n=t.selection.ranges){let r=n.map(e=>Xe(t,e.from).block);if(!r.every(e=>e))return null;let i=n.map((e,n)=>Qe(t,r[n],e.from,e.to));if(e!=2&&!i.every(e=>e))return{changes:t.changes(n.map((e,t)=>i[t]?[]:[{from:e.from,insert:r[t].open+` `},{from:e.to,insert:` `+r[t].close}]))};if(e!=1&&i.some(e=>e)){let e=[];for(let t=0,n;t<i.length;t++)if(n=i[t]){let i=r[t],{open:a,close:o}=n;e.push({from:a.pos-i.open.length,to:a.pos+a.margin},{from:o.pos-o.margin,to:o.pos+i.close.length})}return{changes:e}}return null}function tt(e,t,n=t.selection.ranges){let r=[],i=-1;ranges:for(let{from:e,to:a}of n){let n=r.length,o=1e9,s;for(let n=e;n<=a;){let c=t.doc.lineAt(n);if(s==null&&(s=Xe(t,c.from).line,!s))continue ranges;if(c.from>i&&(e==a||a>c.from)){i=c.from;let e=/^\s*/.exec(c.text)[0].length,t=e==c.length,n=c.text.slice(e,e+s.length)==s?e:-1;e<c.text.length&&e<o&&(o=e),r.push({line:c,comment:n,token:s,indent:e,empty:t,single:!1})}n=c.to+1}if(o<1e9)for(let e=n;e<r.length;e++)r[e].indent<r[e].line.text.length&&(r[e].indent=o);r.length==n+1&&(r[n].single=!0)}if(e!=2&&r.some(e=>e.comment<0&&(!e.empty||e.single))){let e=[];for(let{line:t,token:n,indent:i,empty:a,single:o}of r)(o||!a)&&e.push({from:t.from+i,insert:n+` `});let n=t.changes(e);return{changes:n,selection:t.selection.map(n,1)}}else if(e!=1&&r.some(e=>e.comment>=0)){let e=[];for(let{line:t,comment:n,token:i}of r)if(n>=0){let r=t.from+n,a=r+i.length;t.text[a-t.from]==` `&&a++,e.push({from:r,to:a})}return{changes:e}}return null}var nt=ne.define(),rt=ne.define(),it=je.define(),at=je.define({combine(e){return Oe(e,{minDepth:100,newGroupDelay:500,joinToEvent:(e,t)=>t},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,t)=>(n,r)=>e(n,r)||t(n,r)})}}),ot=ce.define({create(){return Ct.empty},update(e,t){let n=t.state.facet(at),r=t.annotation(nt);if(r){let i=L.fromTransaction(t,r.selection),a=r.side,o=a==0?e.undone:e.done;return o=i?pt(o,o.length,n.minDepth,i):vt(o,t.startState.selection),new Ct(a==0?r.rest:o,a==0?o:r.rest)}let i=t.annotation(rt);if((i==`full`||i==`before`)&&(e=e.isolate()),t.annotation(Fe.addToHistory)===!1)return t.changes.empty?e:e.addMapping(t.changes.desc);let a=L.fromTransaction(t),o=t.annotation(Fe.time),s=t.annotation(Fe.userEvent);return a?e=e.addChanges(a,o,s,n,t):t.selection&&(e=e.addSelection(t.startState.selection,o,s,n.newGroupDelay)),(i==`full`||i==`after`)&&(e=e.isolate()),e},toJSON(e){return{done:e.done.map(e=>e.toJSON()),undone:e.undone.map(e=>e.toJSON())}},fromJSON(e){return new Ct(e.done.map(L.fromJSON),e.undone.map(L.fromJSON))}});function st(e={}){return[ot,at.of(e),E.domEventHandlers({beforeinput(e,t){let n=e.inputType==`historyUndo`?lt:e.inputType==`historyRedo`?ut:null;return n?(e.preventDefault(),n(t)):!1}})]}function ct(e,t){return function({state:n,dispatch:r}){if(!t&&n.readOnly)return!1;let i=n.field(ot,!1);if(!i)return!1;let a=i.pop(e,n,t);return a?(r(a),!0):!1}}var lt=ct(0,!1),ut=ct(1,!1),dt=ct(0,!0),ft=ct(1,!0),L=class e{constructor(e,t,n,r,i){this.changes=e,this.effects=t,this.mapped=n,this.startSelection=r,this.selectionsAfter=i}setSelAfter(t){return new e(this.changes,this.effects,this.mapped,this.startSelection,t)}toJSON(){return{changes:this.changes?.toJSON(),mapped:this.mapped?.toJSON(),startSelection:this.startSelection?.toJSON(),selectionsAfter:this.selectionsAfter.map(e=>e.toJSON())}}static fromJSON(t){return new e(t.changes&&O.fromJSON(t.changes),[],t.mapped&&re.fromJSON(t.mapped),t.startSelection&&F.fromJSON(t.startSelection),t.selectionsAfter.map(F.fromJSON))}static fromTransaction(t,n){let r=R;for(let e of t.startState.facet(it)){let n=e(t);n.length&&(r=r.concat(n))}return!r.length&&t.changes.empty?null:new e(t.changes.invert(t.startState.doc),r,void 0,n||t.startState.selection,R)}static selection(t){return new e(void 0,R,void 0,void 0,t)}};function pt(e,t,n,r){let i=t+1>n+20?t-n-1:0,a=e.slice(i,t);return a.push(r),a}function mt(e,t){let n=[],r=!1;return e.iterChangedRanges((e,t)=>n.push(e,t)),t.iterChangedRanges((e,t,i,a)=>{for(let e=0;e<n.length;){let t=n[e++],o=n[e++];a>=t&&i<=o&&(r=!0)}}),r}function ht(e,t){return e.ranges.length==t.ranges.length&&e.ranges.filter((e,n)=>e.empty!=t.ranges[n].empty).length===0}function gt(e,t){return e.length?t.length?e.concat(t):e:t}var R=[],_t=200;function vt(e,t){if(e.length){let n=e[e.length-1],r=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-_t));return r.length&&r[r.length-1].eq(t)?e:(r.push(t),pt(e,e.length-1,1e9,n.setSelAfter(r)))}else return[L.selection([t])]}function yt(e){let t=e[e.length-1],n=e.slice();return n[e.length-1]=t.setSelAfter(t.selectionsAfter.slice(0,t.selectionsAfter.length-1)),n}function bt(e,t){if(!e.length)return e;let n=e.length,r=R;for(;n;){let i=xt(e[n-1],t,r);if(i.changes&&!i.changes.empty||i.effects.length){let t=e.slice(0,n);return t[n-1]=i,t}else t=i.mapped,n--,r=i.selectionsAfter}return r.length?[L.selection(r)]:R}function xt(e,t,n){let r=gt(e.selectionsAfter.length?e.selectionsAfter.map(e=>e.map(t)):R,n);if(!e.changes)return L.selection(r);let i=e.changes.map(t),a=t.mapDesc(e.changes,!0),o=e.mapped?e.mapped.composeDesc(a):a;return new L(i,P.mapEffects(e.effects,t),o,e.startSelection.map(a),r)}var St=/^(input\.type|delete)($|\.)/,Ct=class e{constructor(e,t,n=0,r=void 0){this.done=e,this.undone=t,this.prevTime=n,this.prevUserEvent=r}isolate(){return this.prevTime?new e(this.done,this.undone):this}addChanges(t,n,r,i,a){let o=this.done,s=o[o.length-1];return o=s&&s.changes&&!s.changes.empty&&t.changes&&(!r||St.test(r))&&(!s.selectionsAfter.length&&n-this.prevTime<i.newGroupDelay&&i.joinToEvent(a,mt(s.changes,t.changes))||r==`input.type.compose`)?pt(o,o.length-1,i.minDepth,new L(t.changes.compose(s.changes),gt(P.mapEffects(t.effects,s.changes),s.effects),s.mapped,s.startSelection,R)):pt(o,o.length,i.minDepth,t),new e(o,R,n,r)}addSelection(t,n,r,i){let a=this.done.length?this.done[this.done.length-1].selectionsAfter:R;return a.length>0&&n-this.prevTime<i&&r==this.prevUserEvent&&r&&/^select($|\.)/.test(r)&&ht(a[a.length-1],t)?this:new e(vt(this.done,t),this.undone,n,r)}addMapping(t){return new e(bt(this.done,t),bt(this.undone,t),this.prevTime,this.prevUserEvent)}pop(e,t,n){let r=e==0?this.done:this.undone;if(r.length==0)return null;let i=r[r.length-1],a=i.selectionsAfter[0]||(i.startSelection?i.startSelection.map(i.changes.invertedDesc,1):t.selection);if(n&&i.selectionsAfter.length)return t.update({selection:i.selectionsAfter[i.selectionsAfter.length-1],annotations:nt.of({side:e,rest:yt(r),selection:a}),userEvent:e==0?`select.undo`:`select.redo`,scrollIntoView:!0});if(i.changes){let n=r.length==1?R:r.slice(0,r.length-1);return i.mapped&&(n=bt(n,i.mapped)),t.update({changes:i.changes,selection:i.startSelection,effects:i.effects,annotations:nt.of({side:e,rest:n,selection:a}),filter:!1,userEvent:e==0?`undo`:`redo`,scrollIntoView:!0})}else return null}};Ct.empty=new Ct(R,R);var wt=[{key:`Mod-z`,run:lt,preventDefault:!0},{key:`Mod-y`,mac:`Mod-Shift-z`,run:ut,preventDefault:!0},{linux:`Ctrl-Shift-z`,run:ut,preventDefault:!0},{key:`Mod-u`,run:dt,preventDefault:!0},{key:`Alt-u`,mac:`Mod-Shift-u`,run:ft,preventDefault:!0}];function z(e,t){return F.create(e.ranges.map(t),e.mainIndex)}function B(e,t){return e.update({selection:t,scrollIntoView:!0,userEvent:`select`})}function V({state:e,dispatch:t},n){let r=z(e.selection,n);return r.eq(e.selection,!0)?!1:(t(B(e,r)),!0)}function Tt(e,t){return F.cursor(t?e.to:e.from)}function Et(e,t){return V(e,n=>n.empty?e.moveByChar(n,t):Tt(n,t))}function H(e){return e.textDirectionAt(e.state.selection.main.head)==g.LTR}var Dt=e=>Et(e,!H(e)),Ot=e=>Et(e,H(e));function kt(e,t){return V(e,n=>n.empty?e.moveByGroup(n,t):Tt(n,t))}var At=e=>kt(e,!H(e)),jt=e=>kt(e,H(e));typeof Intl<`u`&&Intl.Segmenter&&new Intl.Segmenter(void 0,{granularity:`word`});function Mt(e,t,n){if(t.type.prop(n))return!0;let r=t.to-t.from;return r&&(r>2||/[^\s,.;:]/.test(e.sliceDoc(t.from,t.to)))||t.firstChild}function Nt(e,t,n){let r=Le(e).resolveInner(t.head),i=n?j.closedBy:j.openedBy;for(let a=t.head;;){let t=n?r.childAfter(a):r.childBefore(a);if(!t)break;Mt(e,t,i)?r=t:a=n?t.to:t.from}let a=r.type.prop(i),o,s;return s=a&&(o=n?A(e,r.from,1):A(e,r.to,-1))&&o.matched?n?o.end.to:o.end.from:n?r.to:r.from,F.cursor(s,n?-1:1)}var Pt=e=>V(e,t=>Nt(e.state,t,!H(e))),Ft=e=>V(e,t=>Nt(e.state,t,H(e)));function It(e,t){return V(e,n=>{if(!n.empty)return Tt(n,t);let r=e.moveVertically(n,t);return r.head==n.head?e.moveToLineBoundary(n,t):r})}var Lt=e=>It(e,!1),Rt=e=>It(e,!0);function zt(e){let t=e.scrollDOM.clientHeight<e.scrollDOM.scrollHeight-2,n=0,r=0,i;if(t){for(let t of e.state.facet(E.scrollMargins)){let i=t(e);i?.top&&(n=Math.max(i?.top,n)),i?.bottom&&(r=Math.max(i?.bottom,r))}i=e.scrollDOM.clientHeight-n-r}else i=(e.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:n,marginBottom:r,selfScroll:t,height:Math.max(e.defaultLineHeight,i-5)}}function Bt(e,t){let n=zt(e),{state:r}=e,i=z(r.selection,r=>r.empty?e.moveVertically(r,t,n.height):Tt(r,t));if(i.eq(r.selection))return!1;let a;if(n.selfScroll){let t=e.coordsAtPos(r.selection.main.head),o=e.scrollDOM.getBoundingClientRect(),s=o.top+n.marginTop,c=o.bottom-n.marginBottom;t&&t.top>s&&t.bottom<c&&(a=E.scrollIntoView(i.main.head,{y:`start`,yMargin:t.top-s}))}return e.dispatch(B(r,i),{effects:a}),!0}var Vt=e=>Bt(e,!1),Ht=e=>Bt(e,!0);function U(e,t,n){let r=e.lineBlockAt(t.head),i=e.moveToLineBoundary(t,n);if(i.head==t.head&&i.head!=(n?r.to:r.from)&&(i=e.moveToLineBoundary(t,n,!1)),!n&&i.head==r.from&&r.length){let n=/^\s*/.exec(e.state.sliceDoc(r.from,Math.min(r.from+100,r.to)))[0].length;n&&t.head!=r.from+n&&(i=F.cursor(r.from+n))}return i}var Ut=e=>V(e,t=>U(e,t,!0)),Wt=e=>V(e,t=>U(e,t,!1)),Gt=e=>V(e,t=>U(e,t,!H(e))),Kt=e=>V(e,t=>U(e,t,H(e))),qt=e=>V(e,t=>F.cursor(e.lineBlockAt(t.head).from,1)),Jt=e=>V(e,t=>F.cursor(e.lineBlockAt(t.head).to,-1));function Yt(e,t,n){let r=!1,i=z(e.selection,t=>{let i=A(e,t.head,-1)||A(e,t.head,1)||t.head>0&&A(e,t.head-1,1)||t.head<e.doc.length&&A(e,t.head+1,-1);if(!i||!i.end)return t;r=!0;let a=i.start.from==t.head?i.end.to:i.end.from;return n?F.range(t.anchor,a):F.cursor(a)});return r?(t(B(e,i)),!0):!1}var Xt=({state:e,dispatch:t})=>Yt(e,t,!1);function W(e,t){let n=z(e.state.selection,e=>{let n=t(e);return F.range(e.anchor,n.head,n.goalColumn,n.bidiLevel||void 0,n.assoc)});return n.eq(e.state.selection)?!1:(e.dispatch(B(e.state,n)),!0)}function Zt(e,t){return W(e,n=>e.moveByChar(n,t))}var Qt=e=>Zt(e,!H(e)),$t=e=>Zt(e,H(e));function en(e,t){return W(e,n=>e.moveByGroup(n,t))}var tn=e=>en(e,!H(e)),nn=e=>en(e,H(e)),rn=e=>W(e,t=>Nt(e.state,t,!H(e))),an=e=>W(e,t=>Nt(e.state,t,H(e)));function on(e,t){return W(e,n=>e.moveVertically(n,t))}var sn=e=>on(e,!1),cn=e=>on(e,!0);function ln(e,t){return W(e,n=>e.moveVertically(n,t,zt(e).height))}var un=e=>ln(e,!1),dn=e=>ln(e,!0),fn=e=>W(e,t=>U(e,t,!0)),pn=e=>W(e,t=>U(e,t,!1)),mn=e=>W(e,t=>U(e,t,!H(e))),hn=e=>W(e,t=>U(e,t,H(e))),gn=e=>W(e,t=>F.cursor(e.lineBlockAt(t.head).from)),_n=e=>W(e,t=>F.cursor(e.lineBlockAt(t.head).to)),vn=({state:e,dispatch:t})=>(t(B(e,{anchor:0})),!0),yn=({state:e,dispatch:t})=>(t(B(e,{anchor:e.doc.length})),!0),bn=({state:e,dispatch:t})=>(t(B(e,{anchor:e.selection.main.anchor,head:0})),!0),xn=({state:e,dispatch:t})=>(t(B(e,{anchor:e.selection.main.anchor,head:e.doc.length})),!0),Sn=({state:e,dispatch:t})=>(t(e.update({selection:{anchor:0,head:e.doc.length},userEvent:`select`})),!0),Cn=({state:e,dispatch:t})=>{let n=Hn(e).map(({from:t,to:n})=>F.range(t,Math.min(n+1,e.doc.length)));return t(e.update({selection:F.create(n),userEvent:`select`})),!0},wn=({state:e,dispatch:t})=>{let n=z(e.selection,t=>{let n=Le(e),r=n.resolveStack(t.from,1);if(t.empty){let e=n.resolveStack(t.from,-1);e.node.from>=r.node.from&&e.node.to<=r.node.to&&(r=e)}for(let e=r;e;e=e.next){let{node:n}=e;if((n.from<t.from&&n.to>=t.to||n.to>t.to&&n.from<=t.from)&&e.next)return F.range(n.to,n.from)}return t});return n.eq(e.selection)?!1:(t(B(e,n)),!0)};function Tn(e,t){let{state:n}=e,r=n.selection,i=n.selection.ranges.slice();for(let r of n.selection.ranges){let a=n.doc.lineAt(r.head);if(t?a.to<e.state.doc.length:a.from>0)for(let n=r;;){let r=e.moveVertically(n,t);if(r.head<a.from||r.head>a.to){i.some(e=>e.head==r.head)||i.push(r);break}else if(r.head==n.head)break;else n=r}}return i.length==r.ranges.length?!1:(e.dispatch(B(n,F.create(i,i.length-1))),!0)}var En=e=>Tn(e,!1),Dn=e=>Tn(e,!0),On=({state:e,dispatch:t})=>{let n=e.selection,r=null;return n.ranges.length>1?r=F.create([n.main]):n.main.empty||(r=F.create([F.cursor(n.main.head)])),r?(t(B(e,r)),!0):!1};function kn(e,t){if(e.state.readOnly)return!1;let n=`delete.selection`,{state:r}=e,i=r.changeByRange(r=>{let{from:i,to:a}=r;if(i==a){let o=t(r);o<i?(n=`delete.backward`,o=An(e,o,!1)):o>i&&(n=`delete.forward`,o=An(e,o,!0)),i=Math.min(i,o),a=Math.max(a,o)}else i=An(e,i,!1),a=An(e,a,!0);return i==a?{range:r}:{changes:{from:i,to:a},range:F.cursor(i,i<r.head?-1:1)}});return i.changes.empty?!1:(e.dispatch(r.update(i,{scrollIntoView:!0,userEvent:n,effects:n==`delete.selection`?E.announce.of(r.phrase(`Selection deleted`)):void 0})),!0)}function An(e,t,n){if(e instanceof E)for(let r of e.state.facet(E.atomicRanges).map(t=>t(e)))r.between(t,t,(e,r)=>{e<t&&r>t&&(t=n?r:e)});return t}var jn=(e,t,n)=>kn(e,r=>{let i=r.from,{state:a}=e,o=a.doc.lineAt(i),s,c;if(n&&!t&&i>o.from&&i<o.from+200&&!/[^ \t]/.test(s=o.text.slice(0,i-o.from))){if(s[s.length-1]==` `)return i-1;let e=Se(s,a.tabSize)%ie(a)||ie(a);for(let t=0;t<e&&s[s.length-1-t]==` `;t++)i--;c=i}else c=N(o.text,i-o.from,t,t)+o.from,c==i&&o.number!=(t?a.doc.lines:1)?c+=t?1:-1:!t&&/[\ufe00-\ufe0f]/.test(o.text.slice(c-o.from,i-o.from))&&(c=N(o.text,c-o.from,!1,!1)+o.from);return c}),Mn=e=>jn(e,!1,!0),Nn=e=>jn(e,!0,!1),Pn=(e,t)=>kn(e,n=>{let r=n.head,{state:i}=e,a=i.doc.lineAt(r),o=i.charCategorizer(r);for(let e=null;;){if(r==(t?a.to:a.from)){r==n.head&&a.number!=(t?i.doc.lines:1)&&(r+=t?1:-1);break}let s=N(a.text,r-a.from,t)+a.from,c=a.text.slice(Math.min(r,s)-a.from,Math.max(r,s)-a.from),l=o(c);if(e!=null&&l!=e)break;(c!=` `||r!=n.head)&&(e=l),r=s}return r}),Fn=e=>Pn(e,!1),In=e=>Pn(e,!0),Ln=e=>kn(e,t=>{let n=e.lineBlockAt(t.head).to;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)}),Rn=e=>kn(e,t=>{let n=e.moveToLineBoundary(t,!1).head;return t.head>n?n:Math.max(0,t.head-1)}),zn=e=>kn(e,t=>{let n=e.moveToLineBoundary(t,!0).head;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)}),Bn=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(e=>({changes:{from:e.from,to:e.to,insert:be.of([``,``])},range:F.cursor(e.from)}));return t(e.update(n,{scrollIntoView:!0,userEvent:`input`})),!0},Vn=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(t=>{if(!t.empty||t.from==0||t.from==e.doc.length)return{range:t};let n=t.from,r=e.doc.lineAt(n),i=n==r.from?n-1:N(r.text,n-r.from,!1)+r.from,a=n==r.to?n+1:N(r.text,n-r.from,!0)+r.from;return{changes:{from:i,to:a,insert:e.doc.slice(n,a).append(e.doc.slice(i,n))},range:F.cursor(a)}});return n.changes.empty?!1:(t(e.update(n,{scrollIntoView:!0,userEvent:`move.character`})),!0)};function Hn(e){let t=[],n=-1;for(let r of e.selection.ranges){let i=e.doc.lineAt(r.from),a=e.doc.lineAt(r.to);if(!r.empty&&r.to==a.from&&(a=e.doc.lineAt(r.to-1)),n>=i.number){let e=t[t.length-1];e.to=a.to,e.ranges.push(r)}else t.push({from:i.from,to:a.to,ranges:[r]});n=a.number+1}return t}function Un(e,t,n){if(e.readOnly)return!1;let r=[],i=[];for(let t of Hn(e)){if(n?t.to==e.doc.length:t.from==0)continue;let a=e.doc.lineAt(n?t.to+1:t.from-1),o=a.length+1;if(n){r.push({from:t.to,to:a.to},{from:t.from,insert:a.text+e.lineBreak});for(let n of t.ranges)i.push(F.range(Math.min(e.doc.length,n.anchor+o),Math.min(e.doc.length,n.head+o)))}else{r.push({from:a.from,to:t.from},{from:t.to,insert:e.lineBreak+a.text});for(let e of t.ranges)i.push(F.range(e.anchor-o,e.head-o))}}return r.length?(t(e.update({changes:r,scrollIntoView:!0,selection:F.create(i,e.selection.mainIndex),userEvent:`move.line`})),!0):!1}var Wn=({state:e,dispatch:t})=>Un(e,t,!1),Gn=({state:e,dispatch:t})=>Un(e,t,!0);function Kn(e,t,n){if(e.readOnly)return!1;let r=[];for(let t of Hn(e))n?r.push({from:t.from,insert:e.doc.slice(t.from,t.to)+e.lineBreak}):r.push({from:t.to,insert:e.lineBreak+e.doc.slice(t.from,t.to)});let i=e.changes(r);return t(e.update({changes:i,selection:e.selection.map(i,n?1:-1),scrollIntoView:!0,userEvent:`input.copyline`})),!0}var qn=({state:e,dispatch:t})=>Kn(e,t,!1),Jn=({state:e,dispatch:t})=>Kn(e,t,!0),Yn=e=>{if(e.state.readOnly)return!1;let{state:t}=e,n=t.changes(Hn(t).map(({from:e,to:n})=>(e>0?e--:n<t.doc.length&&n++,{from:e,to:n}))),r=z(t.selection,t=>{let n;if(e.lineWrapping){let r=e.lineBlockAt(t.head),i=e.coordsAtPos(t.head,t.assoc||1);i&&(n=r.bottom+e.documentTop-i.bottom+e.defaultLineHeight/2)}return e.moveVertically(t,!0,n)}).map(n);return e.dispatch({changes:n,selection:r,scrollIntoView:!0,userEvent:`delete.line`}),!0};function Xn(e,t){if(/\(\)|\[\]|\{\}/.test(e.sliceDoc(t-1,t+1)))return{from:t,to:t};let n=Le(e).resolveInner(t),r=n.childBefore(t),i=n.childAfter(t),a;return r&&i&&r.to<=t&&i.from>=t&&(a=r.type.prop(j.closedBy))&&a.indexOf(i.name)>-1&&e.doc.lineAt(r.to).from==e.doc.lineAt(i.from).from&&!/\S/.test(e.sliceDoc(r.to,i.from))?{from:r.to,to:i.from}:null}var Zn=$n(!1),Qn=$n(!0);function $n(e){return({state:t,dispatch:n})=>{if(t.readOnly)return!1;let r=t.changeByRange(n=>{let{from:r,to:i}=n,a=t.doc.lineAt(r),o=!e&&r==i&&Xn(t,r);e&&(r=i=(i<=a.to?a:t.doc.lineAt(i)).to);let s=new de(t,{simulateBreak:r,simulateDoubleBreak:!!o}),c=Ie(s,r);for(c??=Se(/^\s*/.exec(t.doc.lineAt(r).text)[0],t.tabSize);i<a.to&&/\s/.test(a.text[i-a.from]);)i++;o?{from:r,to:i}=o:r>a.from&&r<a.from+100&&!/\S/.test(a.text.slice(0,r))&&(r=a.from);let l=[``,oe(t,c)];return o&&l.push(oe(t,s.lineIndent(a.from,-1))),{changes:{from:r,to:i,insert:be.of(l)},range:F.cursor(r+1+l[1].length)}});return n(t.update(r,{scrollIntoView:!0,userEvent:`input`})),!0}}function er(e,t){let n=-1;return e.changeByRange(r=>{let i=[];for(let a=r.from;a<=r.to;){let o=e.doc.lineAt(a);o.number>n&&(r.empty||r.to>o.from)&&(t(o,i,r),n=o.number),a=o.to+1}let a=e.changes(i);return{changes:i,range:F.range(a.mapPos(r.anchor,1),a.mapPos(r.head,1))}})}var tr=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=Object.create(null),r=new de(e,{overrideIndentation:e=>n[e]??-1}),i=er(e,(t,i,a)=>{let o=Ie(r,t.from);if(o==null)return;/\S/.test(t.text)||(o=0);let s=/^\s*/.exec(t.text)[0],c=oe(e,o);(s!=c||a.from<t.from+s.length)&&(n[t.from]=o,i.push({from:t.from,to:t.from+s.length,insert:c}))});return i.changes.empty||t(e.update(i,{userEvent:`indent`})),!0},nr=({state:e,dispatch:t})=>e.readOnly?!1:(t(e.update(er(e,(t,n)=>{n.push({from:t.from,insert:e.facet(Re)})}),{userEvent:`input.indent`})),!0),rr=({state:e,dispatch:t})=>e.readOnly?!1:(t(e.update(er(e,(t,n)=>{let r=/^\s*/.exec(t.text)[0];if(!r)return;let i=Se(r,e.tabSize),a=0,o=oe(e,Math.max(0,i-ie(e)));for(;a<r.length&&a<o.length&&r.charCodeAt(a)==o.charCodeAt(a);)a++;n.push({from:t.from+a,to:t.from+r.length,insert:o.slice(a)})}),{userEvent:`delete.dedent`})),!0),ir=e=>(e.setTabFocusMode(),!0),ar=[{key:`Ctrl-b`,run:Dt,shift:Qt,preventDefault:!0},{key:`Ctrl-f`,run:Ot,shift:$t},{key:`Ctrl-p`,run:Lt,shift:sn},{key:`Ctrl-n`,run:Rt,shift:cn},{key:`Ctrl-a`,run:qt,shift:gn},{key:`Ctrl-e`,run:Jt,shift:_n},{key:`Ctrl-d`,run:Nn},{key:`Ctrl-h`,run:Mn},{key:`Ctrl-k`,run:Ln},{key:`Ctrl-Alt-h`,run:Fn},{key:`Ctrl-o`,run:Bn},{key:`Ctrl-t`,run:Vn},{key:`Ctrl-v`,run:Ht}],or=[{key:`ArrowLeft`,run:Dt,shift:Qt,preventDefault:!0},{key:`Mod-ArrowLeft`,mac:`Alt-ArrowLeft`,run:At,shift:tn,preventDefault:!0},{mac:`Cmd-ArrowLeft`,run:Gt,shift:mn,preventDefault:!0},{key:`ArrowRight`,run:Ot,shift:$t,preventDefault:!0},{key:`Mod-ArrowRight`,mac:`Alt-ArrowRight`,run:jt,shift:nn,preventDefault:!0},{mac:`Cmd-ArrowRight`,run:Kt,shift:hn,preventDefault:!0},{key:`ArrowUp`,run:Lt,shift:sn,preventDefault:!0},{mac:`Cmd-ArrowUp`,run:vn,shift:bn},{mac:`Ctrl-ArrowUp`,run:Vt,shift:un},{key:`ArrowDown`,run:Rt,shift:cn,preventDefault:!0},{mac:`Cmd-ArrowDown`,run:yn,shift:xn},{mac:`Ctrl-ArrowDown`,run:Ht,shift:dn},{key:`PageUp`,run:Vt,shift:un},{key:`PageDown`,run:Ht,shift:dn},{key:`Home`,run:Wt,shift:pn,preventDefault:!0},{key:`Mod-Home`,run:vn,shift:bn},{key:`End`,run:Ut,shift:fn,preventDefault:!0},{key:`Mod-End`,run:yn,shift:xn},{key:`Enter`,run:Zn,shift:Zn},{key:`Mod-a`,run:Sn},{key:`Backspace`,run:Mn,shift:Mn,preventDefault:!0},{key:`Delete`,run:Nn,preventDefault:!0},{key:`Mod-Backspace`,mac:`Alt-Backspace`,run:Fn,preventDefault:!0},{key:`Mod-Delete`,mac:`Alt-Delete`,run:In,preventDefault:!0},{mac:`Mod-Backspace`,run:Rn,preventDefault:!0},{mac:`Mod-Delete`,run:zn,preventDefault:!0}].concat(ar.map(e=>({mac:e.key,run:e.run,shift:e.shift}))),sr=[{key:`Alt-ArrowLeft`,mac:`Ctrl-ArrowLeft`,run:Pt,shift:rn},{key:`Alt-ArrowRight`,mac:`Ctrl-ArrowRight`,run:Ft,shift:an},{key:`Alt-ArrowUp`,run:Wn},{key:`Shift-Alt-ArrowUp`,run:qn},{key:`Alt-ArrowDown`,run:Gn},{key:`Shift-Alt-ArrowDown`,run:Jn},{key:`Mod-Alt-ArrowUp`,run:En},{key:`Mod-Alt-ArrowDown`,run:Dn},{key:`Escape`,run:On},{key:`Mod-Enter`,run:Qn},{key:`Alt-l`,mac:`Ctrl-l`,run:Cn},{key:`Mod-i`,run:wn,preventDefault:!0},{key:`Mod-[`,run:rr},{key:`Mod-]`,run:nr},{key:`Mod-Alt-\\`,run:tr},{key:`Shift-Mod-k`,run:Yn},{key:`Shift-Mod-\\`,run:Xt},{key:`Mod-/`,run:Ge},{key:`Alt-A`,run:Je},{key:`Ctrl-m`,mac:`Shift-Alt-m`,run:ir}].concat(or),cr={key:`Tab`,run:nr,shift:rr},lr=typeof String.prototype.normalize==`function`?e=>e.normalize(`NFKD`):e=>e,G=class{constructor(e,t,n=0,r=e.length,i,a){this.test=a,this.value={from:0,to:0},this.done=!1,this.matches=[],this.buffer=``,this.bufferPos=0,this.iter=e.iterRange(n,r),this.bufferStart=n,this.normalize=i?e=>i(lr(e)):lr,this.query=this.normalize(t)}peek(){if(this.bufferPos==this.buffer.length){if(this.bufferStart+=this.buffer.length,this.iter.next(),this.iter.done)return-1;this.bufferPos=0,this.buffer=this.iter.value}return ue(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let e=this.peek();if(e<0)return this.done=!0,this;let t=me(e),n=this.bufferStart+this.bufferPos;this.bufferPos+=fe(e);let r=this.normalize(t);if(r.length)for(let e=0,i=n;;e++){let a=r.charCodeAt(e),o=this.match(a,i,this.bufferPos+this.bufferStart);if(e==r.length-1){if(o)return this.value=o,this;break}i==n&&e<t.length&&t.charCodeAt(e)==a&&i++}}}match(e,t,n){let r=null;for(let t=0;t<this.matches.length;t+=2){let i=this.matches[t],a=!1;this.query.charCodeAt(i)==e&&(i==this.query.length-1?r={from:this.matches[t+1],to:n}:(this.matches[t]++,a=!0)),a||(this.matches.splice(t,2),t-=2)}return this.query.charCodeAt(0)==e&&(this.query.length==1?r={from:t,to:n}:this.matches.push(1,t)),r&&this.test&&!this.test(r.from,r.to,this.buffer,this.bufferStart)&&(r=null),r}};typeof Symbol<`u`&&(G.prototype[Symbol.iterator]=function(){return this});var ur={from:-1,to:-1,match:/.*/.exec(``)},dr=`gm`+(/x/.unicode==null?``:`u`),fr=class{constructor(e,t,n,r=0,i=e.length){if(this.text=e,this.to=i,this.curLine=``,this.done=!1,this.value=ur,/\\[sWDnr]|\n|\r|\[\^/.test(t))return new hr(e,t,n,r,i);this.re=new RegExp(t,dr+(n?.ignoreCase?`i`:``)),this.test=n?.test,this.iter=e.iter(),this.curLineStart=e.lineAt(r).from,this.matchPos=_r(e,r),this.getLine(this.curLineStart)}getLine(e){this.iter.next(e),this.iter.lineBreak?this.curLine=``:(this.curLine=this.iter.value,this.curLineStart+this.curLine.length>this.to&&(this.curLine=this.curLine.slice(0,this.to-this.curLineStart)),this.iter.next())}nextLine(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine=``:this.getLine(0)}next(){for(let e=this.matchPos-this.curLineStart;;){this.re.lastIndex=e;let t=this.matchPos<=this.to&&this.re.exec(this.curLine);if(t){let n=this.curLineStart+t.index,r=n+t[0].length;if(this.matchPos=_r(this.text,r+(n==r?1:0)),n==this.curLineStart+this.curLine.length&&this.nextLine(),(n<r||n>this.value.to)&&(!this.test||this.test(n,r,t)))return this.value={from:n,to:r,match:t},this;e=this.matchPos-this.curLineStart}else if(this.curLineStart+this.curLine.length<this.to)this.nextLine(),e=0;else return this.done=!0,this}}},pr=new WeakMap,mr=class e{constructor(e,t){this.from=e,this.text=t}get to(){return this.from+this.text.length}static get(t,n,r){let i=pr.get(t);if(!i||i.from>=r||i.to<=n){let i=new e(n,t.sliceString(n,r));return pr.set(t,i),i}if(i.from==n&&i.to==r)return i;let{text:a,from:o}=i;return o>n&&(a=t.sliceString(n,o)+a,o=n),i.to<r&&(a+=t.sliceString(i.to,r)),pr.set(t,new e(o,a)),new e(n,a.slice(n-o,r-o))}},hr=class{constructor(e,t,n,r,i){this.text=e,this.to=i,this.done=!1,this.value=ur,this.matchPos=_r(e,r),this.re=new RegExp(t,dr+(n?.ignoreCase?`i`:``)),this.test=n?.test,this.flat=mr.get(e,r,this.chunkEnd(r+5e3))}chunkEnd(e){return e>=this.to?this.to:this.text.lineAt(e).to}next(){for(;;){let e=this.re.lastIndex=this.matchPos-this.flat.from,t=this.re.exec(this.flat.text);if(t&&!t[0]&&t.index==e&&(this.re.lastIndex=e+1,t=this.re.exec(this.flat.text)),t){let e=this.flat.from+t.index,n=e+t[0].length;if((this.flat.to>=this.to||t.index+t[0].length<=this.flat.text.length-10)&&(!this.test||this.test(e,n,t)))return this.value={from:e,to:n,match:t},this.matchPos=_r(this.text,n+(e==n?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=mr.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}};typeof Symbol<`u`&&(fr.prototype[Symbol.iterator]=hr.prototype[Symbol.iterator]=function(){return this});function gr(e){try{return new RegExp(e,dr),!0}catch{return!1}}function _r(e,t){if(t>=e.length)return t;let n=e.lineAt(t),r;for(;t<n.to&&(r=n.text.charCodeAt(t-n.from))>=56320&&r<57344;)t++;return t}var vr=e=>{let{state:t}=e,n=String(t.doc.lineAt(e.state.selection.main.head).number),{close:r,result:i}=S(e,{label:t.phrase(`Go to line`),input:{type:`text`,name:`line`,value:n},focus:!0,submitLabel:t.phrase(`go`)});return i.then(n=>{let i=n&&/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(n.elements.line.value);if(!i){e.dispatch({effects:r});return}let a=t.doc.lineAt(t.selection.main.head),[,o,s,c,l]=i,u=c?+c.slice(1):0,d=s?+s:a.number;if(s&&l){let e=d/100;o&&(e=e*(o==`-`?-1:1)+a.number/t.doc.lines),d=Math.round(t.doc.lines*e)}else s&&o&&(d=d*(o==`-`?-1:1)+a.number);let f=t.doc.line(Math.max(1,Math.min(t.doc.lines,d))),p=F.cursor(f.from+Math.max(0,Math.min(u,f.length)));e.dispatch({effects:[r,E.scrollIntoView(p.from,{y:`center`})],selection:p})}),!0},yr={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},br=je.define({combine(e){return Oe(e,yr,{highlightWordAroundCursor:(e,t)=>e||t,minSelectionLength:Math.min,maxMatches:Math.min})}});function xr(e){let t=[Dr,Er];return e&&t.push(br.of(e)),t}var Sr=_.mark({class:`cm-selectionMatch`}),Cr=_.mark({class:`cm-selectionMatch cm-selectionMatch-main`});function wr(e,t,n,r){return(n==0||e(t.sliceDoc(n-1,n))!=f.Word)&&(r==t.doc.length||e(t.sliceDoc(r,r+1))!=f.Word)}function Tr(e,t,n,r){return e(t.sliceDoc(n,n+1))==f.Word&&e(t.sliceDoc(r-1,r))==f.Word}var Er=p.fromClass(class{constructor(e){this.decorations=this.getDeco(e)}update(e){(e.selectionSet||e.docChanged||e.viewportChanged)&&(this.decorations=this.getDeco(e.view))}getDeco(e){let t=e.state.facet(br),{state:n}=e,r=n.selection;if(r.ranges.length>1)return _.none;let i=r.main,a,o=null;if(i.empty){if(!t.highlightWordAroundCursor)return _.none;let e=n.wordAt(i.head);if(!e)return _.none;o=n.charCategorizer(i.head),a=n.sliceDoc(e.from,e.to)}else{let e=i.to-i.from;if(e<t.minSelectionLength||e>200)return _.none;if(t.wholeWords){if(a=n.sliceDoc(i.from,i.to),o=n.charCategorizer(i.head),!(wr(o,n,i.from,i.to)&&Tr(o,n,i.from,i.to)))return _.none}else if(a=n.sliceDoc(i.from,i.to),!a)return _.none}let s=[];for(let r of e.visibleRanges){let e=new G(n.doc,a,r.from,r.to);for(;!e.next().done;){let{from:r,to:a}=e.value;if((!o||wr(o,n,r,a))&&(i.empty&&r<=i.from&&a>=i.to?s.push(Cr.range(r,a)):(r>=i.to||a<=i.from)&&s.push(Sr.range(r,a)),s.length>t.maxMatches))return _.none}}return _.set(s)}},{decorations:e=>e.decorations}),Dr=E.baseTheme({".cm-selectionMatch":{backgroundColor:`#99ff7780`},".cm-searchMatch .cm-selectionMatch":{backgroundColor:`transparent`}}),Or=({state:e,dispatch:t})=>{let{selection:n}=e,r=F.create(n.ranges.map(t=>e.wordAt(t.head)||F.cursor(t.head)),n.mainIndex);return r.eq(n)?!1:(t(e.update({selection:r})),!0)};function kr(e,t){let{main:n,ranges:r}=e.selection,i=e.wordAt(n.head),a=i&&i.from==n.from&&i.to==n.to;for(let n=!1,i=new G(e.doc,t,r[r.length-1].to);;)if(i.next(),i.done){if(n)return null;i=new G(e.doc,t,0,Math.max(0,r[r.length-1].from-1)),n=!0}else{if(n&&r.some(e=>e.from==i.value.from))continue;if(a){let t=e.wordAt(i.value.from);if(!t||t.from!=i.value.from||t.to!=i.value.to)continue}return i.value}}var Ar=({state:e,dispatch:t})=>{let{ranges:n}=e.selection;if(n.some(e=>e.from===e.to))return Or({state:e,dispatch:t});let r=e.sliceDoc(n[0].from,n[0].to);if(e.selection.ranges.some(t=>e.sliceDoc(t.from,t.to)!=r))return!1;let i=kr(e,r);return i?(t(e.update({selection:e.selection.addRange(F.range(i.from,i.to),!1),effects:E.scrollIntoView(i.to)})),!0):!1},K=je.define({combine(e){return Oe(e,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new si(e),scrollToMatch:e=>E.scrollIntoView(e)})}}),jr=class{constructor(e){this.search=e.search,this.caseSensitive=!!e.caseSensitive,this.literal=!!e.literal,this.regexp=!!e.regexp,this.replace=e.replace||``,this.valid=!!this.search&&(!this.regexp||gr(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord,this.test=e.test}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,(e,t)=>t==`n`?`
1
+ import{a as e,n as t,r as n,t as r}from"./jsx-runtime-BFALxl05.js";import{n as i,t as a}from"./marked.esm-Cv8mjgnt.js";import{t as o}from"./external-link-Dim3NH6h.js";import{n as s,r as c,t as l}from"./api-client-BgVufYKf.js";import{_ as u,l as d}from"./index-DasstYgw.js";import{$ as f,A as p,B as m,C as h,D as g,E as _,F as v,G as y,H as b,J as x,K as S,L as C,M as w,N as T,O as E,P as D,Q as O,R as k,S as A,T as j,U as ee,V as M,W as te,X as ne,Z as re,_ as ie,a as ae,b as oe,c as se,ct as ce,d as le,dt as ue,f as de,ft as fe,g as pe,gt as me,h as he,ht as N,i as ge,it as _e,j as ve,l as ye,lt as be,m as xe,mt as Se,n as Ce,nt as we,o as Te,ot as Ee,p as De,pt as Oe,q as ke,r as Ae,rt as je,s as Me,st as P,t as Ne,tt as F,u as Pe,ut as Fe,v as Ie,w as Le,x as Re,y as ze,z as Be}from"./dist-CBiGQxfr.js";var Ve=t(`eye`,[[`path`,{d:`M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0`,key:`1nclc0`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),He=t(`file-exclamation-point`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M12 9v4`,key:`juzpu7`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),I=e(n());function Ue(){return Ue=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Ue.apply(null,arguments)}function We(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}var Ge=e=>{let{state:t}=e,n=t.doc.lineAt(t.selection.main.from),r=Xe(e.state,n.from);return r.line?qe(e):r.block?Ye(e):!1};function Ke(e,t){return({state:n,dispatch:r})=>{if(n.readOnly)return!1;let i=e(t,n);return i?(r(n.update(i)),!0):!1}}var qe=Ke(tt,0),Je=Ke(et,0),Ye=Ke((e,t)=>et(e,t,$e(t)),0);function Xe(e,t){let n=e.languageDataAt(`commentTokens`,t,1);return n.length?n[0]:{}}var Ze=50;function Qe(e,{open:t,close:n},r,i){let a=e.sliceDoc(r-Ze,r),o=e.sliceDoc(i,i+Ze),s=/\s*$/.exec(a)[0].length,c=/^\s*/.exec(o)[0].length,l=a.length-s;if(a.slice(l-t.length,l)==t&&o.slice(c,c+n.length)==n)return{open:{pos:r-s,margin:s&&1},close:{pos:i+c,margin:c&&1}};let u,d;i-r<=2*Ze?u=d=e.sliceDoc(r,i):(u=e.sliceDoc(r,r+Ze),d=e.sliceDoc(i-Ze,i));let f=/^\s*/.exec(u)[0].length,p=/\s*$/.exec(d)[0].length,m=d.length-p-n.length;return u.slice(f,f+t.length)==t&&d.slice(m,m+n.length)==n?{open:{pos:r+f+t.length,margin:/\s/.test(u.charAt(f+t.length))?1:0},close:{pos:i-p-n.length,margin:/\s/.test(d.charAt(m-1))?1:0}}:null}function $e(e){let t=[];for(let n of e.selection.ranges){let r=e.doc.lineAt(n.from),i=n.to<=r.to?r:e.doc.lineAt(n.to);i.from>r.from&&i.from==n.to&&(i=n.to==r.to+1?r:e.doc.lineAt(n.to-1));let a=t.length-1;a>=0&&t[a].to>r.from?t[a].to=i.to:t.push({from:r.from+/^\s*/.exec(r.text)[0].length,to:i.to})}return t}function et(e,t,n=t.selection.ranges){let r=n.map(e=>Xe(t,e.from).block);if(!r.every(e=>e))return null;let i=n.map((e,n)=>Qe(t,r[n],e.from,e.to));if(e!=2&&!i.every(e=>e))return{changes:t.changes(n.map((e,t)=>i[t]?[]:[{from:e.from,insert:r[t].open+` `},{from:e.to,insert:` `+r[t].close}]))};if(e!=1&&i.some(e=>e)){let e=[];for(let t=0,n;t<i.length;t++)if(n=i[t]){let i=r[t],{open:a,close:o}=n;e.push({from:a.pos-i.open.length,to:a.pos+a.margin},{from:o.pos-o.margin,to:o.pos+i.close.length})}return{changes:e}}return null}function tt(e,t,n=t.selection.ranges){let r=[],i=-1;ranges:for(let{from:e,to:a}of n){let n=r.length,o=1e9,s;for(let n=e;n<=a;){let c=t.doc.lineAt(n);if(s==null&&(s=Xe(t,c.from).line,!s))continue ranges;if(c.from>i&&(e==a||a>c.from)){i=c.from;let e=/^\s*/.exec(c.text)[0].length,t=e==c.length,n=c.text.slice(e,e+s.length)==s?e:-1;e<c.text.length&&e<o&&(o=e),r.push({line:c,comment:n,token:s,indent:e,empty:t,single:!1})}n=c.to+1}if(o<1e9)for(let e=n;e<r.length;e++)r[e].indent<r[e].line.text.length&&(r[e].indent=o);r.length==n+1&&(r[n].single=!0)}if(e!=2&&r.some(e=>e.comment<0&&(!e.empty||e.single))){let e=[];for(let{line:t,token:n,indent:i,empty:a,single:o}of r)(o||!a)&&e.push({from:t.from+i,insert:n+` `});let n=t.changes(e);return{changes:n,selection:t.selection.map(n,1)}}else if(e!=1&&r.some(e=>e.comment>=0)){let e=[];for(let{line:t,comment:n,token:i}of r)if(n>=0){let r=t.from+n,a=r+i.length;t.text[a-t.from]==` `&&a++,e.push({from:r,to:a})}return{changes:e}}return null}var nt=ne.define(),rt=ne.define(),it=je.define(),at=je.define({combine(e){return Oe(e,{minDepth:100,newGroupDelay:500,joinToEvent:(e,t)=>t},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,t)=>(n,r)=>e(n,r)||t(n,r)})}}),ot=ce.define({create(){return Ct.empty},update(e,t){let n=t.state.facet(at),r=t.annotation(nt);if(r){let i=L.fromTransaction(t,r.selection),a=r.side,o=a==0?e.undone:e.done;return o=i?pt(o,o.length,n.minDepth,i):vt(o,t.startState.selection),new Ct(a==0?r.rest:o,a==0?o:r.rest)}let i=t.annotation(rt);if((i==`full`||i==`before`)&&(e=e.isolate()),t.annotation(Fe.addToHistory)===!1)return t.changes.empty?e:e.addMapping(t.changes.desc);let a=L.fromTransaction(t),o=t.annotation(Fe.time),s=t.annotation(Fe.userEvent);return a?e=e.addChanges(a,o,s,n,t):t.selection&&(e=e.addSelection(t.startState.selection,o,s,n.newGroupDelay)),(i==`full`||i==`after`)&&(e=e.isolate()),e},toJSON(e){return{done:e.done.map(e=>e.toJSON()),undone:e.undone.map(e=>e.toJSON())}},fromJSON(e){return new Ct(e.done.map(L.fromJSON),e.undone.map(L.fromJSON))}});function st(e={}){return[ot,at.of(e),E.domEventHandlers({beforeinput(e,t){let n=e.inputType==`historyUndo`?lt:e.inputType==`historyRedo`?ut:null;return n?(e.preventDefault(),n(t)):!1}})]}function ct(e,t){return function({state:n,dispatch:r}){if(!t&&n.readOnly)return!1;let i=n.field(ot,!1);if(!i)return!1;let a=i.pop(e,n,t);return a?(r(a),!0):!1}}var lt=ct(0,!1),ut=ct(1,!1),dt=ct(0,!0),ft=ct(1,!0),L=class e{constructor(e,t,n,r,i){this.changes=e,this.effects=t,this.mapped=n,this.startSelection=r,this.selectionsAfter=i}setSelAfter(t){return new e(this.changes,this.effects,this.mapped,this.startSelection,t)}toJSON(){return{changes:this.changes?.toJSON(),mapped:this.mapped?.toJSON(),startSelection:this.startSelection?.toJSON(),selectionsAfter:this.selectionsAfter.map(e=>e.toJSON())}}static fromJSON(t){return new e(t.changes&&O.fromJSON(t.changes),[],t.mapped&&re.fromJSON(t.mapped),t.startSelection&&F.fromJSON(t.startSelection),t.selectionsAfter.map(F.fromJSON))}static fromTransaction(t,n){let r=R;for(let e of t.startState.facet(it)){let n=e(t);n.length&&(r=r.concat(n))}return!r.length&&t.changes.empty?null:new e(t.changes.invert(t.startState.doc),r,void 0,n||t.startState.selection,R)}static selection(t){return new e(void 0,R,void 0,void 0,t)}};function pt(e,t,n,r){let i=t+1>n+20?t-n-1:0,a=e.slice(i,t);return a.push(r),a}function mt(e,t){let n=[],r=!1;return e.iterChangedRanges((e,t)=>n.push(e,t)),t.iterChangedRanges((e,t,i,a)=>{for(let e=0;e<n.length;){let t=n[e++],o=n[e++];a>=t&&i<=o&&(r=!0)}}),r}function ht(e,t){return e.ranges.length==t.ranges.length&&e.ranges.filter((e,n)=>e.empty!=t.ranges[n].empty).length===0}function gt(e,t){return e.length?t.length?e.concat(t):e:t}var R=[],_t=200;function vt(e,t){if(e.length){let n=e[e.length-1],r=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-_t));return r.length&&r[r.length-1].eq(t)?e:(r.push(t),pt(e,e.length-1,1e9,n.setSelAfter(r)))}else return[L.selection([t])]}function yt(e){let t=e[e.length-1],n=e.slice();return n[e.length-1]=t.setSelAfter(t.selectionsAfter.slice(0,t.selectionsAfter.length-1)),n}function bt(e,t){if(!e.length)return e;let n=e.length,r=R;for(;n;){let i=xt(e[n-1],t,r);if(i.changes&&!i.changes.empty||i.effects.length){let t=e.slice(0,n);return t[n-1]=i,t}else t=i.mapped,n--,r=i.selectionsAfter}return r.length?[L.selection(r)]:R}function xt(e,t,n){let r=gt(e.selectionsAfter.length?e.selectionsAfter.map(e=>e.map(t)):R,n);if(!e.changes)return L.selection(r);let i=e.changes.map(t),a=t.mapDesc(e.changes,!0),o=e.mapped?e.mapped.composeDesc(a):a;return new L(i,P.mapEffects(e.effects,t),o,e.startSelection.map(a),r)}var St=/^(input\.type|delete)($|\.)/,Ct=class e{constructor(e,t,n=0,r=void 0){this.done=e,this.undone=t,this.prevTime=n,this.prevUserEvent=r}isolate(){return this.prevTime?new e(this.done,this.undone):this}addChanges(t,n,r,i,a){let o=this.done,s=o[o.length-1];return o=s&&s.changes&&!s.changes.empty&&t.changes&&(!r||St.test(r))&&(!s.selectionsAfter.length&&n-this.prevTime<i.newGroupDelay&&i.joinToEvent(a,mt(s.changes,t.changes))||r==`input.type.compose`)?pt(o,o.length-1,i.minDepth,new L(t.changes.compose(s.changes),gt(P.mapEffects(t.effects,s.changes),s.effects),s.mapped,s.startSelection,R)):pt(o,o.length,i.minDepth,t),new e(o,R,n,r)}addSelection(t,n,r,i){let a=this.done.length?this.done[this.done.length-1].selectionsAfter:R;return a.length>0&&n-this.prevTime<i&&r==this.prevUserEvent&&r&&/^select($|\.)/.test(r)&&ht(a[a.length-1],t)?this:new e(vt(this.done,t),this.undone,n,r)}addMapping(t){return new e(bt(this.done,t),bt(this.undone,t),this.prevTime,this.prevUserEvent)}pop(e,t,n){let r=e==0?this.done:this.undone;if(r.length==0)return null;let i=r[r.length-1],a=i.selectionsAfter[0]||(i.startSelection?i.startSelection.map(i.changes.invertedDesc,1):t.selection);if(n&&i.selectionsAfter.length)return t.update({selection:i.selectionsAfter[i.selectionsAfter.length-1],annotations:nt.of({side:e,rest:yt(r),selection:a}),userEvent:e==0?`select.undo`:`select.redo`,scrollIntoView:!0});if(i.changes){let n=r.length==1?R:r.slice(0,r.length-1);return i.mapped&&(n=bt(n,i.mapped)),t.update({changes:i.changes,selection:i.startSelection,effects:i.effects,annotations:nt.of({side:e,rest:n,selection:a}),filter:!1,userEvent:e==0?`undo`:`redo`,scrollIntoView:!0})}else return null}};Ct.empty=new Ct(R,R);var wt=[{key:`Mod-z`,run:lt,preventDefault:!0},{key:`Mod-y`,mac:`Mod-Shift-z`,run:ut,preventDefault:!0},{linux:`Ctrl-Shift-z`,run:ut,preventDefault:!0},{key:`Mod-u`,run:dt,preventDefault:!0},{key:`Alt-u`,mac:`Mod-Shift-u`,run:ft,preventDefault:!0}];function z(e,t){return F.create(e.ranges.map(t),e.mainIndex)}function B(e,t){return e.update({selection:t,scrollIntoView:!0,userEvent:`select`})}function V({state:e,dispatch:t},n){let r=z(e.selection,n);return r.eq(e.selection,!0)?!1:(t(B(e,r)),!0)}function Tt(e,t){return F.cursor(t?e.to:e.from)}function Et(e,t){return V(e,n=>n.empty?e.moveByChar(n,t):Tt(n,t))}function H(e){return e.textDirectionAt(e.state.selection.main.head)==g.LTR}var Dt=e=>Et(e,!H(e)),Ot=e=>Et(e,H(e));function kt(e,t){return V(e,n=>n.empty?e.moveByGroup(n,t):Tt(n,t))}var At=e=>kt(e,!H(e)),jt=e=>kt(e,H(e));typeof Intl<`u`&&Intl.Segmenter&&new Intl.Segmenter(void 0,{granularity:`word`});function Mt(e,t,n){if(t.type.prop(n))return!0;let r=t.to-t.from;return r&&(r>2||/[^\s,.;:]/.test(e.sliceDoc(t.from,t.to)))||t.firstChild}function Nt(e,t,n){let r=Le(e).resolveInner(t.head),i=n?j.closedBy:j.openedBy;for(let a=t.head;;){let t=n?r.childAfter(a):r.childBefore(a);if(!t)break;Mt(e,t,i)?r=t:a=n?t.to:t.from}let a=r.type.prop(i),o,s;return s=a&&(o=n?A(e,r.from,1):A(e,r.to,-1))&&o.matched?n?o.end.to:o.end.from:n?r.to:r.from,F.cursor(s,n?-1:1)}var Pt=e=>V(e,t=>Nt(e.state,t,!H(e))),Ft=e=>V(e,t=>Nt(e.state,t,H(e)));function It(e,t){return V(e,n=>{if(!n.empty)return Tt(n,t);let r=e.moveVertically(n,t);return r.head==n.head?e.moveToLineBoundary(n,t):r})}var Lt=e=>It(e,!1),Rt=e=>It(e,!0);function zt(e){let t=e.scrollDOM.clientHeight<e.scrollDOM.scrollHeight-2,n=0,r=0,i;if(t){for(let t of e.state.facet(E.scrollMargins)){let i=t(e);i?.top&&(n=Math.max(i?.top,n)),i?.bottom&&(r=Math.max(i?.bottom,r))}i=e.scrollDOM.clientHeight-n-r}else i=(e.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:n,marginBottom:r,selfScroll:t,height:Math.max(e.defaultLineHeight,i-5)}}function Bt(e,t){let n=zt(e),{state:r}=e,i=z(r.selection,r=>r.empty?e.moveVertically(r,t,n.height):Tt(r,t));if(i.eq(r.selection))return!1;let a;if(n.selfScroll){let t=e.coordsAtPos(r.selection.main.head),o=e.scrollDOM.getBoundingClientRect(),s=o.top+n.marginTop,c=o.bottom-n.marginBottom;t&&t.top>s&&t.bottom<c&&(a=E.scrollIntoView(i.main.head,{y:`start`,yMargin:t.top-s}))}return e.dispatch(B(r,i),{effects:a}),!0}var Vt=e=>Bt(e,!1),Ht=e=>Bt(e,!0);function U(e,t,n){let r=e.lineBlockAt(t.head),i=e.moveToLineBoundary(t,n);if(i.head==t.head&&i.head!=(n?r.to:r.from)&&(i=e.moveToLineBoundary(t,n,!1)),!n&&i.head==r.from&&r.length){let n=/^\s*/.exec(e.state.sliceDoc(r.from,Math.min(r.from+100,r.to)))[0].length;n&&t.head!=r.from+n&&(i=F.cursor(r.from+n))}return i}var Ut=e=>V(e,t=>U(e,t,!0)),Wt=e=>V(e,t=>U(e,t,!1)),Gt=e=>V(e,t=>U(e,t,!H(e))),Kt=e=>V(e,t=>U(e,t,H(e))),qt=e=>V(e,t=>F.cursor(e.lineBlockAt(t.head).from,1)),Jt=e=>V(e,t=>F.cursor(e.lineBlockAt(t.head).to,-1));function Yt(e,t,n){let r=!1,i=z(e.selection,t=>{let i=A(e,t.head,-1)||A(e,t.head,1)||t.head>0&&A(e,t.head-1,1)||t.head<e.doc.length&&A(e,t.head+1,-1);if(!i||!i.end)return t;r=!0;let a=i.start.from==t.head?i.end.to:i.end.from;return n?F.range(t.anchor,a):F.cursor(a)});return r?(t(B(e,i)),!0):!1}var Xt=({state:e,dispatch:t})=>Yt(e,t,!1);function W(e,t){let n=z(e.state.selection,e=>{let n=t(e);return F.range(e.anchor,n.head,n.goalColumn,n.bidiLevel||void 0,n.assoc)});return n.eq(e.state.selection)?!1:(e.dispatch(B(e.state,n)),!0)}function Zt(e,t){return W(e,n=>e.moveByChar(n,t))}var Qt=e=>Zt(e,!H(e)),$t=e=>Zt(e,H(e));function en(e,t){return W(e,n=>e.moveByGroup(n,t))}var tn=e=>en(e,!H(e)),nn=e=>en(e,H(e)),rn=e=>W(e,t=>Nt(e.state,t,!H(e))),an=e=>W(e,t=>Nt(e.state,t,H(e)));function on(e,t){return W(e,n=>e.moveVertically(n,t))}var sn=e=>on(e,!1),cn=e=>on(e,!0);function ln(e,t){return W(e,n=>e.moveVertically(n,t,zt(e).height))}var un=e=>ln(e,!1),dn=e=>ln(e,!0),fn=e=>W(e,t=>U(e,t,!0)),pn=e=>W(e,t=>U(e,t,!1)),mn=e=>W(e,t=>U(e,t,!H(e))),hn=e=>W(e,t=>U(e,t,H(e))),gn=e=>W(e,t=>F.cursor(e.lineBlockAt(t.head).from)),_n=e=>W(e,t=>F.cursor(e.lineBlockAt(t.head).to)),vn=({state:e,dispatch:t})=>(t(B(e,{anchor:0})),!0),yn=({state:e,dispatch:t})=>(t(B(e,{anchor:e.doc.length})),!0),bn=({state:e,dispatch:t})=>(t(B(e,{anchor:e.selection.main.anchor,head:0})),!0),xn=({state:e,dispatch:t})=>(t(B(e,{anchor:e.selection.main.anchor,head:e.doc.length})),!0),Sn=({state:e,dispatch:t})=>(t(e.update({selection:{anchor:0,head:e.doc.length},userEvent:`select`})),!0),Cn=({state:e,dispatch:t})=>{let n=Hn(e).map(({from:t,to:n})=>F.range(t,Math.min(n+1,e.doc.length)));return t(e.update({selection:F.create(n),userEvent:`select`})),!0},wn=({state:e,dispatch:t})=>{let n=z(e.selection,t=>{let n=Le(e),r=n.resolveStack(t.from,1);if(t.empty){let e=n.resolveStack(t.from,-1);e.node.from>=r.node.from&&e.node.to<=r.node.to&&(r=e)}for(let e=r;e;e=e.next){let{node:n}=e;if((n.from<t.from&&n.to>=t.to||n.to>t.to&&n.from<=t.from)&&e.next)return F.range(n.to,n.from)}return t});return n.eq(e.selection)?!1:(t(B(e,n)),!0)};function Tn(e,t){let{state:n}=e,r=n.selection,i=n.selection.ranges.slice();for(let r of n.selection.ranges){let a=n.doc.lineAt(r.head);if(t?a.to<e.state.doc.length:a.from>0)for(let n=r;;){let r=e.moveVertically(n,t);if(r.head<a.from||r.head>a.to){i.some(e=>e.head==r.head)||i.push(r);break}else if(r.head==n.head)break;else n=r}}return i.length==r.ranges.length?!1:(e.dispatch(B(n,F.create(i,i.length-1))),!0)}var En=e=>Tn(e,!1),Dn=e=>Tn(e,!0),On=({state:e,dispatch:t})=>{let n=e.selection,r=null;return n.ranges.length>1?r=F.create([n.main]):n.main.empty||(r=F.create([F.cursor(n.main.head)])),r?(t(B(e,r)),!0):!1};function kn(e,t){if(e.state.readOnly)return!1;let n=`delete.selection`,{state:r}=e,i=r.changeByRange(r=>{let{from:i,to:a}=r;if(i==a){let o=t(r);o<i?(n=`delete.backward`,o=An(e,o,!1)):o>i&&(n=`delete.forward`,o=An(e,o,!0)),i=Math.min(i,o),a=Math.max(a,o)}else i=An(e,i,!1),a=An(e,a,!0);return i==a?{range:r}:{changes:{from:i,to:a},range:F.cursor(i,i<r.head?-1:1)}});return i.changes.empty?!1:(e.dispatch(r.update(i,{scrollIntoView:!0,userEvent:n,effects:n==`delete.selection`?E.announce.of(r.phrase(`Selection deleted`)):void 0})),!0)}function An(e,t,n){if(e instanceof E)for(let r of e.state.facet(E.atomicRanges).map(t=>t(e)))r.between(t,t,(e,r)=>{e<t&&r>t&&(t=n?r:e)});return t}var jn=(e,t,n)=>kn(e,r=>{let i=r.from,{state:a}=e,o=a.doc.lineAt(i),s,c;if(n&&!t&&i>o.from&&i<o.from+200&&!/[^ \t]/.test(s=o.text.slice(0,i-o.from))){if(s[s.length-1]==` `)return i-1;let e=Se(s,a.tabSize)%ie(a)||ie(a);for(let t=0;t<e&&s[s.length-1-t]==` `;t++)i--;c=i}else c=N(o.text,i-o.from,t,t)+o.from,c==i&&o.number!=(t?a.doc.lines:1)?c+=t?1:-1:!t&&/[\ufe00-\ufe0f]/.test(o.text.slice(c-o.from,i-o.from))&&(c=N(o.text,c-o.from,!1,!1)+o.from);return c}),Mn=e=>jn(e,!1,!0),Nn=e=>jn(e,!0,!1),Pn=(e,t)=>kn(e,n=>{let r=n.head,{state:i}=e,a=i.doc.lineAt(r),o=i.charCategorizer(r);for(let e=null;;){if(r==(t?a.to:a.from)){r==n.head&&a.number!=(t?i.doc.lines:1)&&(r+=t?1:-1);break}let s=N(a.text,r-a.from,t)+a.from,c=a.text.slice(Math.min(r,s)-a.from,Math.max(r,s)-a.from),l=o(c);if(e!=null&&l!=e)break;(c!=` `||r!=n.head)&&(e=l),r=s}return r}),Fn=e=>Pn(e,!1),In=e=>Pn(e,!0),Ln=e=>kn(e,t=>{let n=e.lineBlockAt(t.head).to;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)}),Rn=e=>kn(e,t=>{let n=e.moveToLineBoundary(t,!1).head;return t.head>n?n:Math.max(0,t.head-1)}),zn=e=>kn(e,t=>{let n=e.moveToLineBoundary(t,!0).head;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)}),Bn=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(e=>({changes:{from:e.from,to:e.to,insert:be.of([``,``])},range:F.cursor(e.from)}));return t(e.update(n,{scrollIntoView:!0,userEvent:`input`})),!0},Vn=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(t=>{if(!t.empty||t.from==0||t.from==e.doc.length)return{range:t};let n=t.from,r=e.doc.lineAt(n),i=n==r.from?n-1:N(r.text,n-r.from,!1)+r.from,a=n==r.to?n+1:N(r.text,n-r.from,!0)+r.from;return{changes:{from:i,to:a,insert:e.doc.slice(n,a).append(e.doc.slice(i,n))},range:F.cursor(a)}});return n.changes.empty?!1:(t(e.update(n,{scrollIntoView:!0,userEvent:`move.character`})),!0)};function Hn(e){let t=[],n=-1;for(let r of e.selection.ranges){let i=e.doc.lineAt(r.from),a=e.doc.lineAt(r.to);if(!r.empty&&r.to==a.from&&(a=e.doc.lineAt(r.to-1)),n>=i.number){let e=t[t.length-1];e.to=a.to,e.ranges.push(r)}else t.push({from:i.from,to:a.to,ranges:[r]});n=a.number+1}return t}function Un(e,t,n){if(e.readOnly)return!1;let r=[],i=[];for(let t of Hn(e)){if(n?t.to==e.doc.length:t.from==0)continue;let a=e.doc.lineAt(n?t.to+1:t.from-1),o=a.length+1;if(n){r.push({from:t.to,to:a.to},{from:t.from,insert:a.text+e.lineBreak});for(let n of t.ranges)i.push(F.range(Math.min(e.doc.length,n.anchor+o),Math.min(e.doc.length,n.head+o)))}else{r.push({from:a.from,to:t.from},{from:t.to,insert:e.lineBreak+a.text});for(let e of t.ranges)i.push(F.range(e.anchor-o,e.head-o))}}return r.length?(t(e.update({changes:r,scrollIntoView:!0,selection:F.create(i,e.selection.mainIndex),userEvent:`move.line`})),!0):!1}var Wn=({state:e,dispatch:t})=>Un(e,t,!1),Gn=({state:e,dispatch:t})=>Un(e,t,!0);function Kn(e,t,n){if(e.readOnly)return!1;let r=[];for(let t of Hn(e))n?r.push({from:t.from,insert:e.doc.slice(t.from,t.to)+e.lineBreak}):r.push({from:t.to,insert:e.lineBreak+e.doc.slice(t.from,t.to)});let i=e.changes(r);return t(e.update({changes:i,selection:e.selection.map(i,n?1:-1),scrollIntoView:!0,userEvent:`input.copyline`})),!0}var qn=({state:e,dispatch:t})=>Kn(e,t,!1),Jn=({state:e,dispatch:t})=>Kn(e,t,!0),Yn=e=>{if(e.state.readOnly)return!1;let{state:t}=e,n=t.changes(Hn(t).map(({from:e,to:n})=>(e>0?e--:n<t.doc.length&&n++,{from:e,to:n}))),r=z(t.selection,t=>{let n;if(e.lineWrapping){let r=e.lineBlockAt(t.head),i=e.coordsAtPos(t.head,t.assoc||1);i&&(n=r.bottom+e.documentTop-i.bottom+e.defaultLineHeight/2)}return e.moveVertically(t,!0,n)}).map(n);return e.dispatch({changes:n,selection:r,scrollIntoView:!0,userEvent:`delete.line`}),!0};function Xn(e,t){if(/\(\)|\[\]|\{\}/.test(e.sliceDoc(t-1,t+1)))return{from:t,to:t};let n=Le(e).resolveInner(t),r=n.childBefore(t),i=n.childAfter(t),a;return r&&i&&r.to<=t&&i.from>=t&&(a=r.type.prop(j.closedBy))&&a.indexOf(i.name)>-1&&e.doc.lineAt(r.to).from==e.doc.lineAt(i.from).from&&!/\S/.test(e.sliceDoc(r.to,i.from))?{from:r.to,to:i.from}:null}var Zn=$n(!1),Qn=$n(!0);function $n(e){return({state:t,dispatch:n})=>{if(t.readOnly)return!1;let r=t.changeByRange(n=>{let{from:r,to:i}=n,a=t.doc.lineAt(r),o=!e&&r==i&&Xn(t,r);e&&(r=i=(i<=a.to?a:t.doc.lineAt(i)).to);let s=new de(t,{simulateBreak:r,simulateDoubleBreak:!!o}),c=Ie(s,r);for(c??=Se(/^\s*/.exec(t.doc.lineAt(r).text)[0],t.tabSize);i<a.to&&/\s/.test(a.text[i-a.from]);)i++;o?{from:r,to:i}=o:r>a.from&&r<a.from+100&&!/\S/.test(a.text.slice(0,r))&&(r=a.from);let l=[``,oe(t,c)];return o&&l.push(oe(t,s.lineIndent(a.from,-1))),{changes:{from:r,to:i,insert:be.of(l)},range:F.cursor(r+1+l[1].length)}});return n(t.update(r,{scrollIntoView:!0,userEvent:`input`})),!0}}function er(e,t){let n=-1;return e.changeByRange(r=>{let i=[];for(let a=r.from;a<=r.to;){let o=e.doc.lineAt(a);o.number>n&&(r.empty||r.to>o.from)&&(t(o,i,r),n=o.number),a=o.to+1}let a=e.changes(i);return{changes:i,range:F.range(a.mapPos(r.anchor,1),a.mapPos(r.head,1))}})}var tr=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=Object.create(null),r=new de(e,{overrideIndentation:e=>n[e]??-1}),i=er(e,(t,i,a)=>{let o=Ie(r,t.from);if(o==null)return;/\S/.test(t.text)||(o=0);let s=/^\s*/.exec(t.text)[0],c=oe(e,o);(s!=c||a.from<t.from+s.length)&&(n[t.from]=o,i.push({from:t.from,to:t.from+s.length,insert:c}))});return i.changes.empty||t(e.update(i,{userEvent:`indent`})),!0},nr=({state:e,dispatch:t})=>e.readOnly?!1:(t(e.update(er(e,(t,n)=>{n.push({from:t.from,insert:e.facet(Re)})}),{userEvent:`input.indent`})),!0),rr=({state:e,dispatch:t})=>e.readOnly?!1:(t(e.update(er(e,(t,n)=>{let r=/^\s*/.exec(t.text)[0];if(!r)return;let i=Se(r,e.tabSize),a=0,o=oe(e,Math.max(0,i-ie(e)));for(;a<r.length&&a<o.length&&r.charCodeAt(a)==o.charCodeAt(a);)a++;n.push({from:t.from+a,to:t.from+r.length,insert:o.slice(a)})}),{userEvent:`delete.dedent`})),!0),ir=e=>(e.setTabFocusMode(),!0),ar=[{key:`Ctrl-b`,run:Dt,shift:Qt,preventDefault:!0},{key:`Ctrl-f`,run:Ot,shift:$t},{key:`Ctrl-p`,run:Lt,shift:sn},{key:`Ctrl-n`,run:Rt,shift:cn},{key:`Ctrl-a`,run:qt,shift:gn},{key:`Ctrl-e`,run:Jt,shift:_n},{key:`Ctrl-d`,run:Nn},{key:`Ctrl-h`,run:Mn},{key:`Ctrl-k`,run:Ln},{key:`Ctrl-Alt-h`,run:Fn},{key:`Ctrl-o`,run:Bn},{key:`Ctrl-t`,run:Vn},{key:`Ctrl-v`,run:Ht}],or=[{key:`ArrowLeft`,run:Dt,shift:Qt,preventDefault:!0},{key:`Mod-ArrowLeft`,mac:`Alt-ArrowLeft`,run:At,shift:tn,preventDefault:!0},{mac:`Cmd-ArrowLeft`,run:Gt,shift:mn,preventDefault:!0},{key:`ArrowRight`,run:Ot,shift:$t,preventDefault:!0},{key:`Mod-ArrowRight`,mac:`Alt-ArrowRight`,run:jt,shift:nn,preventDefault:!0},{mac:`Cmd-ArrowRight`,run:Kt,shift:hn,preventDefault:!0},{key:`ArrowUp`,run:Lt,shift:sn,preventDefault:!0},{mac:`Cmd-ArrowUp`,run:vn,shift:bn},{mac:`Ctrl-ArrowUp`,run:Vt,shift:un},{key:`ArrowDown`,run:Rt,shift:cn,preventDefault:!0},{mac:`Cmd-ArrowDown`,run:yn,shift:xn},{mac:`Ctrl-ArrowDown`,run:Ht,shift:dn},{key:`PageUp`,run:Vt,shift:un},{key:`PageDown`,run:Ht,shift:dn},{key:`Home`,run:Wt,shift:pn,preventDefault:!0},{key:`Mod-Home`,run:vn,shift:bn},{key:`End`,run:Ut,shift:fn,preventDefault:!0},{key:`Mod-End`,run:yn,shift:xn},{key:`Enter`,run:Zn,shift:Zn},{key:`Mod-a`,run:Sn},{key:`Backspace`,run:Mn,shift:Mn,preventDefault:!0},{key:`Delete`,run:Nn,preventDefault:!0},{key:`Mod-Backspace`,mac:`Alt-Backspace`,run:Fn,preventDefault:!0},{key:`Mod-Delete`,mac:`Alt-Delete`,run:In,preventDefault:!0},{mac:`Mod-Backspace`,run:Rn,preventDefault:!0},{mac:`Mod-Delete`,run:zn,preventDefault:!0}].concat(ar.map(e=>({mac:e.key,run:e.run,shift:e.shift}))),sr=[{key:`Alt-ArrowLeft`,mac:`Ctrl-ArrowLeft`,run:Pt,shift:rn},{key:`Alt-ArrowRight`,mac:`Ctrl-ArrowRight`,run:Ft,shift:an},{key:`Alt-ArrowUp`,run:Wn},{key:`Shift-Alt-ArrowUp`,run:qn},{key:`Alt-ArrowDown`,run:Gn},{key:`Shift-Alt-ArrowDown`,run:Jn},{key:`Mod-Alt-ArrowUp`,run:En},{key:`Mod-Alt-ArrowDown`,run:Dn},{key:`Escape`,run:On},{key:`Mod-Enter`,run:Qn},{key:`Alt-l`,mac:`Ctrl-l`,run:Cn},{key:`Mod-i`,run:wn,preventDefault:!0},{key:`Mod-[`,run:rr},{key:`Mod-]`,run:nr},{key:`Mod-Alt-\\`,run:tr},{key:`Shift-Mod-k`,run:Yn},{key:`Shift-Mod-\\`,run:Xt},{key:`Mod-/`,run:Ge},{key:`Alt-A`,run:Je},{key:`Ctrl-m`,mac:`Shift-Alt-m`,run:ir}].concat(or),cr={key:`Tab`,run:nr,shift:rr},lr=typeof String.prototype.normalize==`function`?e=>e.normalize(`NFKD`):e=>e,G=class{constructor(e,t,n=0,r=e.length,i,a){this.test=a,this.value={from:0,to:0},this.done=!1,this.matches=[],this.buffer=``,this.bufferPos=0,this.iter=e.iterRange(n,r),this.bufferStart=n,this.normalize=i?e=>i(lr(e)):lr,this.query=this.normalize(t)}peek(){if(this.bufferPos==this.buffer.length){if(this.bufferStart+=this.buffer.length,this.iter.next(),this.iter.done)return-1;this.bufferPos=0,this.buffer=this.iter.value}return ue(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let e=this.peek();if(e<0)return this.done=!0,this;let t=me(e),n=this.bufferStart+this.bufferPos;this.bufferPos+=fe(e);let r=this.normalize(t);if(r.length)for(let e=0,i=n;;e++){let a=r.charCodeAt(e),o=this.match(a,i,this.bufferPos+this.bufferStart);if(e==r.length-1){if(o)return this.value=o,this;break}i==n&&e<t.length&&t.charCodeAt(e)==a&&i++}}}match(e,t,n){let r=null;for(let t=0;t<this.matches.length;t+=2){let i=this.matches[t],a=!1;this.query.charCodeAt(i)==e&&(i==this.query.length-1?r={from:this.matches[t+1],to:n}:(this.matches[t]++,a=!0)),a||(this.matches.splice(t,2),t-=2)}return this.query.charCodeAt(0)==e&&(this.query.length==1?r={from:t,to:n}:this.matches.push(1,t)),r&&this.test&&!this.test(r.from,r.to,this.buffer,this.bufferStart)&&(r=null),r}};typeof Symbol<`u`&&(G.prototype[Symbol.iterator]=function(){return this});var ur={from:-1,to:-1,match:/.*/.exec(``)},dr=`gm`+(/x/.unicode==null?``:`u`),fr=class{constructor(e,t,n,r=0,i=e.length){if(this.text=e,this.to=i,this.curLine=``,this.done=!1,this.value=ur,/\\[sWDnr]|\n|\r|\[\^/.test(t))return new hr(e,t,n,r,i);this.re=new RegExp(t,dr+(n?.ignoreCase?`i`:``)),this.test=n?.test,this.iter=e.iter(),this.curLineStart=e.lineAt(r).from,this.matchPos=_r(e,r),this.getLine(this.curLineStart)}getLine(e){this.iter.next(e),this.iter.lineBreak?this.curLine=``:(this.curLine=this.iter.value,this.curLineStart+this.curLine.length>this.to&&(this.curLine=this.curLine.slice(0,this.to-this.curLineStart)),this.iter.next())}nextLine(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine=``:this.getLine(0)}next(){for(let e=this.matchPos-this.curLineStart;;){this.re.lastIndex=e;let t=this.matchPos<=this.to&&this.re.exec(this.curLine);if(t){let n=this.curLineStart+t.index,r=n+t[0].length;if(this.matchPos=_r(this.text,r+(n==r?1:0)),n==this.curLineStart+this.curLine.length&&this.nextLine(),(n<r||n>this.value.to)&&(!this.test||this.test(n,r,t)))return this.value={from:n,to:r,match:t},this;e=this.matchPos-this.curLineStart}else if(this.curLineStart+this.curLine.length<this.to)this.nextLine(),e=0;else return this.done=!0,this}}},pr=new WeakMap,mr=class e{constructor(e,t){this.from=e,this.text=t}get to(){return this.from+this.text.length}static get(t,n,r){let i=pr.get(t);if(!i||i.from>=r||i.to<=n){let i=new e(n,t.sliceString(n,r));return pr.set(t,i),i}if(i.from==n&&i.to==r)return i;let{text:a,from:o}=i;return o>n&&(a=t.sliceString(n,o)+a,o=n),i.to<r&&(a+=t.sliceString(i.to,r)),pr.set(t,new e(o,a)),new e(n,a.slice(n-o,r-o))}},hr=class{constructor(e,t,n,r,i){this.text=e,this.to=i,this.done=!1,this.value=ur,this.matchPos=_r(e,r),this.re=new RegExp(t,dr+(n?.ignoreCase?`i`:``)),this.test=n?.test,this.flat=mr.get(e,r,this.chunkEnd(r+5e3))}chunkEnd(e){return e>=this.to?this.to:this.text.lineAt(e).to}next(){for(;;){let e=this.re.lastIndex=this.matchPos-this.flat.from,t=this.re.exec(this.flat.text);if(t&&!t[0]&&t.index==e&&(this.re.lastIndex=e+1,t=this.re.exec(this.flat.text)),t){let e=this.flat.from+t.index,n=e+t[0].length;if((this.flat.to>=this.to||t.index+t[0].length<=this.flat.text.length-10)&&(!this.test||this.test(e,n,t)))return this.value={from:e,to:n,match:t},this.matchPos=_r(this.text,n+(e==n?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=mr.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}};typeof Symbol<`u`&&(fr.prototype[Symbol.iterator]=hr.prototype[Symbol.iterator]=function(){return this});function gr(e){try{return new RegExp(e,dr),!0}catch{return!1}}function _r(e,t){if(t>=e.length)return t;let n=e.lineAt(t),r;for(;t<n.to&&(r=n.text.charCodeAt(t-n.from))>=56320&&r<57344;)t++;return t}var vr=e=>{let{state:t}=e,n=String(t.doc.lineAt(e.state.selection.main.head).number),{close:r,result:i}=S(e,{label:t.phrase(`Go to line`),input:{type:`text`,name:`line`,value:n},focus:!0,submitLabel:t.phrase(`go`)});return i.then(n=>{let i=n&&/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(n.elements.line.value);if(!i){e.dispatch({effects:r});return}let a=t.doc.lineAt(t.selection.main.head),[,o,s,c,l]=i,u=c?+c.slice(1):0,d=s?+s:a.number;if(s&&l){let e=d/100;o&&(e=e*(o==`-`?-1:1)+a.number/t.doc.lines),d=Math.round(t.doc.lines*e)}else s&&o&&(d=d*(o==`-`?-1:1)+a.number);let f=t.doc.line(Math.max(1,Math.min(t.doc.lines,d))),p=F.cursor(f.from+Math.max(0,Math.min(u,f.length)));e.dispatch({effects:[r,E.scrollIntoView(p.from,{y:`center`})],selection:p})}),!0},yr={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},br=je.define({combine(e){return Oe(e,yr,{highlightWordAroundCursor:(e,t)=>e||t,minSelectionLength:Math.min,maxMatches:Math.min})}});function xr(e){let t=[Dr,Er];return e&&t.push(br.of(e)),t}var Sr=_.mark({class:`cm-selectionMatch`}),Cr=_.mark({class:`cm-selectionMatch cm-selectionMatch-main`});function wr(e,t,n,r){return(n==0||e(t.sliceDoc(n-1,n))!=f.Word)&&(r==t.doc.length||e(t.sliceDoc(r,r+1))!=f.Word)}function Tr(e,t,n,r){return e(t.sliceDoc(n,n+1))==f.Word&&e(t.sliceDoc(r-1,r))==f.Word}var Er=p.fromClass(class{constructor(e){this.decorations=this.getDeco(e)}update(e){(e.selectionSet||e.docChanged||e.viewportChanged)&&(this.decorations=this.getDeco(e.view))}getDeco(e){let t=e.state.facet(br),{state:n}=e,r=n.selection;if(r.ranges.length>1)return _.none;let i=r.main,a,o=null;if(i.empty){if(!t.highlightWordAroundCursor)return _.none;let e=n.wordAt(i.head);if(!e)return _.none;o=n.charCategorizer(i.head),a=n.sliceDoc(e.from,e.to)}else{let e=i.to-i.from;if(e<t.minSelectionLength||e>200)return _.none;if(t.wholeWords){if(a=n.sliceDoc(i.from,i.to),o=n.charCategorizer(i.head),!(wr(o,n,i.from,i.to)&&Tr(o,n,i.from,i.to)))return _.none}else if(a=n.sliceDoc(i.from,i.to),!a)return _.none}let s=[];for(let r of e.visibleRanges){let e=new G(n.doc,a,r.from,r.to);for(;!e.next().done;){let{from:r,to:a}=e.value;if((!o||wr(o,n,r,a))&&(i.empty&&r<=i.from&&a>=i.to?s.push(Cr.range(r,a)):(r>=i.to||a<=i.from)&&s.push(Sr.range(r,a)),s.length>t.maxMatches))return _.none}}return _.set(s)}},{decorations:e=>e.decorations}),Dr=E.baseTheme({".cm-selectionMatch":{backgroundColor:`#99ff7780`},".cm-searchMatch .cm-selectionMatch":{backgroundColor:`transparent`}}),Or=({state:e,dispatch:t})=>{let{selection:n}=e,r=F.create(n.ranges.map(t=>e.wordAt(t.head)||F.cursor(t.head)),n.mainIndex);return r.eq(n)?!1:(t(e.update({selection:r})),!0)};function kr(e,t){let{main:n,ranges:r}=e.selection,i=e.wordAt(n.head),a=i&&i.from==n.from&&i.to==n.to;for(let n=!1,i=new G(e.doc,t,r[r.length-1].to);;)if(i.next(),i.done){if(n)return null;i=new G(e.doc,t,0,Math.max(0,r[r.length-1].from-1)),n=!0}else{if(n&&r.some(e=>e.from==i.value.from))continue;if(a){let t=e.wordAt(i.value.from);if(!t||t.from!=i.value.from||t.to!=i.value.to)continue}return i.value}}var Ar=({state:e,dispatch:t})=>{let{ranges:n}=e.selection;if(n.some(e=>e.from===e.to))return Or({state:e,dispatch:t});let r=e.sliceDoc(n[0].from,n[0].to);if(e.selection.ranges.some(t=>e.sliceDoc(t.from,t.to)!=r))return!1;let i=kr(e,r);return i?(t(e.update({selection:e.selection.addRange(F.range(i.from,i.to),!1),effects:E.scrollIntoView(i.to)})),!0):!1},K=je.define({combine(e){return Oe(e,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new si(e),scrollToMatch:e=>E.scrollIntoView(e)})}}),jr=class{constructor(e){this.search=e.search,this.caseSensitive=!!e.caseSensitive,this.literal=!!e.literal,this.regexp=!!e.regexp,this.replace=e.replace||``,this.valid=!!this.search&&(!this.regexp||gr(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord,this.test=e.test}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,(e,t)=>t==`n`?`
2
2
  `:t==`r`?`\r`:t==`t`?` `:`\\`)}eq(e){return this.search==e.search&&this.replace==e.replace&&this.caseSensitive==e.caseSensitive&&this.regexp==e.regexp&&this.wholeWord==e.wholeWord&&this.test==e.test}create(){return this.regexp?new Br(this):new Fr(this)}getCursor(e,t=0,n){let r=e.doc?e:we.create({doc:e});return n??=r.doc.length,this.regexp?J(this,r,t,n):q(this,r,t,n)}},Mr=class{constructor(e){this.spec=e}};function Nr(e,t,n){return(r,i,a,o)=>n&&!n(r,i,a,o)?!1:e(r>=o&&i<=o+a.length?a.slice(r-o,i-o):t.doc.sliceString(r,i),t,r,i)}function q(e,t,n,r){let i;return e.wholeWord&&(i=Pr(t.doc,t.charCategorizer(t.selection.main.head))),e.test&&(i=Nr(e.test,t,i)),new G(t.doc,e.unquoted,n,r,e.caseSensitive?void 0:e=>e.toLowerCase(),i)}function Pr(e,t){return(n,r,i,a)=>((a>n||a+i.length<r)&&(a=Math.max(0,n-2),i=e.sliceString(a,Math.min(e.length,r+2))),(t(Lr(i,n-a))!=f.Word||t(Rr(i,n-a))!=f.Word)&&(t(Rr(i,r-a))!=f.Word||t(Lr(i,r-a))!=f.Word))}var Fr=class extends Mr{constructor(e){super(e)}nextMatch(e,t,n){let r=q(this.spec,e,n,e.doc.length).nextOverlapping();if(r.done){let n=Math.min(e.doc.length,t+this.spec.unquoted.length);r=q(this.spec,e,0,n).nextOverlapping()}return r.done||r.value.from==t&&r.value.to==n?null:r.value}prevMatchInRange(e,t,n){for(let r=n;;){let n=Math.max(t,r-1e4-this.spec.unquoted.length),i=q(this.spec,e,n,r),a=null;for(;!i.nextOverlapping().done;)a=i.value;if(a)return a;if(n==t)return null;r-=1e4}}prevMatch(e,t,n){let r=this.prevMatchInRange(e,0,t);return r||=this.prevMatchInRange(e,Math.max(0,n-this.spec.unquoted.length),e.doc.length),r&&(r.from!=t||r.to!=n)?r:null}getReplacement(e){return this.spec.unquote(this.spec.replace)}matchAll(e,t){let n=q(this.spec,e,0,e.doc.length),r=[];for(;!n.next().done;){if(r.length>=t)return null;r.push(n.value)}return r}highlight(e,t,n,r){let i=q(this.spec,e,Math.max(0,t-this.spec.unquoted.length),Math.min(n+this.spec.unquoted.length,e.doc.length));for(;!i.next().done;)r(i.value.from,i.value.to)}};function Ir(e,t,n){return(r,i,a)=>(!n||n(r,i,a))&&e(a[0],t,r,i)}function J(e,t,n,r){let i;return e.wholeWord&&(i=zr(t.charCategorizer(t.selection.main.head))),e.test&&(i=Ir(e.test,t,i)),new fr(t.doc,e.search,{ignoreCase:!e.caseSensitive,test:i},n,r)}function Lr(e,t){return e.slice(N(e,t,!1),t)}function Rr(e,t){return e.slice(t,N(e,t))}function zr(e){return(t,n,r)=>!r[0].length||(e(Lr(r.input,r.index))!=f.Word||e(Rr(r.input,r.index))!=f.Word)&&(e(Rr(r.input,r.index+r[0].length))!=f.Word||e(Lr(r.input,r.index+r[0].length))!=f.Word)}var Br=class extends Mr{nextMatch(e,t,n){let r=J(this.spec,e,n,e.doc.length).next();return r.done&&(r=J(this.spec,e,0,t).next()),r.done?null:r.value}prevMatchInRange(e,t,n){for(let r=1;;r++){let i=Math.max(t,n-r*1e4),a=J(this.spec,e,i,n),o=null;for(;!a.next().done;)o=a.value;if(o&&(i==t||o.from>i+10))return o;if(i==t)return null}}prevMatch(e,t,n){return this.prevMatchInRange(e,0,t)||this.prevMatchInRange(e,n,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,(t,n)=>{if(n==`&`)return e.match[0];if(n==`$`)return`$`;for(let t=n.length;t>0;t--){let r=+n.slice(0,t);if(r>0&&r<e.match.length)return e.match[r]+n.slice(t)}return t})}matchAll(e,t){let n=J(this.spec,e,0,e.doc.length),r=[];for(;!n.next().done;){if(r.length>=t)return null;r.push(n.value)}return r}highlight(e,t,n,r){let i=J(this.spec,e,Math.max(0,t-250),Math.min(n+250,e.doc.length));for(;!i.next().done;)r(i.value.from,i.value.to)}},Vr=P.define(),Hr=P.define(),Y=ce.define({create(e){return new Ur(ti(e).create(),null)},update(e,t){for(let n of t.effects)n.is(Vr)?e=new Ur(n.value.create(),e.panel):n.is(Hr)&&(e=new Ur(e.query,n.value?ei:null));return e},provide:e=>ke.from(e,e=>e.panel)}),Ur=class{constructor(e,t){this.query=e,this.panel=t}},Wr=_.mark({class:`cm-searchMatch`}),Gr=_.mark({class:`cm-searchMatch cm-searchMatch-selected`}),Kr=p.fromClass(class{constructor(e){this.view=e,this.decorations=this.highlight(e.state.field(Y))}update(e){let t=e.state.field(Y);(t!=e.startState.field(Y)||e.docChanged||e.selectionSet||e.viewportChanged)&&(this.decorations=this.highlight(t))}highlight({query:e,panel:t}){if(!t||!e.spec.valid)return _.none;let{view:n}=this,r=new Ee;for(let t=0,i=n.visibleRanges,a=i.length;t<a;t++){let{from:o,to:s}=i[t];for(;t<a-1&&s>i[t+1].from-500;)s=i[++t].to;e.highlight(n.state,o,s,(e,t)=>{let i=n.state.selection.ranges.some(n=>n.from==e&&n.to==t);r.add(e,t,i?Gr:Wr)})}return r.finish()}},{decorations:e=>e.decorations});function qr(e){return t=>{let n=t.state.field(Y,!1);return n&&n.query.spec.valid?e(t,n):ii(t)}}var Jr=qr((e,{query:t})=>{let{to:n}=e.state.selection.main,r=t.nextMatch(e.state,n,n);if(!r)return!1;let i=F.single(r.from,r.to),a=e.state.facet(K);return e.dispatch({selection:i,effects:[ui(e,r),a.scrollToMatch(i.main,e)],userEvent:`select.search`}),ri(e),!0}),Yr=qr((e,{query:t})=>{let{state:n}=e,{from:r}=n.selection.main,i=t.prevMatch(n,r,r);if(!i)return!1;let a=F.single(i.from,i.to),o=e.state.facet(K);return e.dispatch({selection:a,effects:[ui(e,i),o.scrollToMatch(a.main,e)],userEvent:`select.search`}),ri(e),!0}),Xr=qr((e,{query:t})=>{let n=t.matchAll(e.state,1e3);return!n||!n.length?!1:(e.dispatch({selection:F.create(n.map(e=>F.range(e.from,e.to))),userEvent:`select.search.matches`}),!0)}),Zr=({state:e,dispatch:t})=>{let n=e.selection;if(n.ranges.length>1||n.main.empty)return!1;let{from:r,to:i}=n.main,a=[],o=0;for(let t=new G(e.doc,e.sliceDoc(r,i));!t.next().done;){if(a.length>1e3)return!1;t.value.from==r&&(o=a.length),a.push(F.range(t.value.from,t.value.to))}return t(e.update({selection:F.create(a,o),userEvent:`select.search.matches`})),!0},Qr=qr((e,{query:t})=>{let{state:n}=e,{from:r,to:i}=n.selection.main;if(n.readOnly)return!1;let a=t.nextMatch(n,r,r);if(!a)return!1;let o=a,s=[],c,l,u=[];o.from==r&&o.to==i&&(l=n.toText(t.getReplacement(o)),s.push({from:o.from,to:o.to,insert:l}),o=t.nextMatch(n,o.from,o.to),u.push(E.announce.of(n.phrase(`replaced match on line $`,n.doc.lineAt(r).number)+`.`)));let d=e.state.changes(s);return o&&(c=F.single(o.from,o.to).map(d),u.push(ui(e,o)),u.push(n.facet(K).scrollToMatch(c.main,e))),e.dispatch({changes:d,selection:c,effects:u,userEvent:`input.replace`}),!0}),$r=qr((e,{query:t})=>{if(e.state.readOnly)return!1;let n=t.matchAll(e.state,1e9).map(e=>{let{from:n,to:r}=e;return{from:n,to:r,insert:t.getReplacement(e)}});if(!n.length)return!1;let r=e.state.phrase(`replaced $ matches`,n.length)+`.`;return e.dispatch({changes:n,effects:E.announce.of(r),userEvent:`input.replace.all`}),!0});function ei(e){return e.state.facet(K).createPanel(e)}function ti(e,t){let n=e.selection.main,r=n.empty||n.to>n.from+100?``:e.sliceDoc(n.from,n.to);if(t&&!r)return t;let i=e.facet(K);return new jr({search:t?.literal??i.literal?r:r.replace(/\n/g,`\\n`),caseSensitive:t?.caseSensitive??i.caseSensitive,literal:t?.literal??i.literal,regexp:t?.regexp??i.regexp,wholeWord:t?.wholeWord??i.wholeWord})}function ni(e){let t=v(e,ei);return t&&t.dom.querySelector(`[main-field]`)}function ri(e){let t=ni(e);t&&t==e.root.activeElement&&t.select()}var ii=e=>{let t=e.state.field(Y,!1);if(t&&t.panel){let n=ni(e);if(n&&n!=e.root.activeElement){let r=ti(e.state,t.query.spec);r.valid&&e.dispatch({effects:Vr.of(r)}),n.focus(),n.select()}}else e.dispatch({effects:[Hr.of(!0),t?Vr.of(ti(e.state,t.query.spec)):P.appendConfig.of(fi)]});return!0},ai=e=>{let t=e.state.field(Y,!1);if(!t||!t.panel)return!1;let n=v(e,ei);return n&&n.dom.contains(e.root.activeElement)&&e.focus(),e.dispatch({effects:Hr.of(!1)}),!0},oi=[{key:`Mod-f`,run:ii,scope:`editor search-panel`},{key:`F3`,run:Jr,shift:Yr,scope:`editor search-panel`,preventDefault:!0},{key:`Mod-g`,run:Jr,shift:Yr,scope:`editor search-panel`,preventDefault:!0},{key:`Escape`,run:ai,scope:`editor search-panel`},{key:`Mod-Shift-l`,run:Zr},{key:`Mod-Alt-g`,run:vr},{key:`Mod-d`,run:Ar,preventDefault:!0}],si=class{constructor(e){this.view=e;let t=this.query=e.state.field(Y).query.spec;this.commit=this.commit.bind(this),this.searchField=x(`input`,{value:t.search,placeholder:X(e,`Find`),"aria-label":X(e,`Find`),class:`cm-textfield`,name:`search`,form:``,"main-field":`true`,onchange:this.commit,onkeyup:this.commit}),this.replaceField=x(`input`,{value:t.replace,placeholder:X(e,`Replace`),"aria-label":X(e,`Replace`),class:`cm-textfield`,name:`replace`,form:``,onchange:this.commit,onkeyup:this.commit}),this.caseField=x(`input`,{type:`checkbox`,name:`case`,form:``,checked:t.caseSensitive,onchange:this.commit}),this.reField=x(`input`,{type:`checkbox`,name:`re`,form:``,checked:t.regexp,onchange:this.commit}),this.wordField=x(`input`,{type:`checkbox`,name:`word`,form:``,checked:t.wholeWord,onchange:this.commit});function n(e,t,n){return x(`button`,{class:`cm-button`,name:e,onclick:t,type:`button`},n)}this.dom=x(`div`,{onkeydown:e=>this.keydown(e),class:`cm-search`},[this.searchField,n(`next`,()=>Jr(e),[X(e,`next`)]),n(`prev`,()=>Yr(e),[X(e,`previous`)]),n(`select`,()=>Xr(e),[X(e,`all`)]),x(`label`,null,[this.caseField,X(e,`match case`)]),x(`label`,null,[this.reField,X(e,`regexp`)]),x(`label`,null,[this.wordField,X(e,`by word`)]),...e.state.readOnly?[]:[x(`br`),this.replaceField,n(`replace`,()=>Qr(e),[X(e,`replace`)]),n(`replaceAll`,()=>$r(e),[X(e,`replace all`)])],x(`button`,{name:`close`,onclick:()=>ai(e),"aria-label":X(e,`close`),type:`button`},[`×`])])}commit(){let e=new jr({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});e.eq(this.query)||(this.query=e,this.view.dispatch({effects:Vr.of(e)}))}keydown(e){y(this.view,e,`search-panel`)?e.preventDefault():e.keyCode==13&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?Yr:Jr)(this.view)):e.keyCode==13&&e.target==this.replaceField&&(e.preventDefault(),Qr(this.view))}update(e){for(let t of e.transactions)for(let e of t.effects)e.is(Vr)&&!e.value.eq(this.query)&&this.setQuery(e.value)}setQuery(e){this.query=e,this.searchField.value=e.search,this.replaceField.value=e.replace,this.caseField.checked=e.caseSensitive,this.reField.checked=e.regexp,this.wordField.checked=e.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(K).top}};function X(e,t){return e.state.phrase(t)}var ci=30,li=/[\s\.,:;?!]/;function ui(e,{from:t,to:n}){let r=e.state.doc.lineAt(t),i=e.state.doc.lineAt(n).to,a=Math.max(r.from,t-ci),o=Math.min(i,n+ci),s=e.state.sliceDoc(a,o);if(a!=r.from){for(let e=0;e<ci;e++)if(!li.test(s[e+1])&&li.test(s[e])){s=s.slice(e);break}}if(o!=i){for(let e=s.length-1;e>s.length-ci;e--)if(!li.test(s[e-1])&&li.test(s[e])){s=s.slice(0,e);break}}return E.announce.of(`${e.state.phrase(`current match`)}. ${s} ${e.state.phrase(`on line`)} ${r.number}.`)}var di=E.baseTheme({".cm-panel.cm-search":{padding:`2px 6px 4px`,position:`relative`,"& [name=close]":{position:`absolute`,top:`0`,right:`4px`,backgroundColor:`inherit`,border:`none`,font:`inherit`,padding:0,margin:0},"& input, & button, & label":{margin:`.2em .6em .2em 0`},"& input[type=checkbox]":{marginRight:`.2em`},"& label":{fontSize:`80%`,whiteSpace:`pre`}},"&light .cm-searchMatch":{backgroundColor:`#ffff0054`},"&dark .cm-searchMatch":{backgroundColor:`#00ffff8a`},"&light .cm-searchMatch-selected":{backgroundColor:`#ff6a0054`},"&dark .cm-searchMatch-selected":{backgroundColor:`#ff00ff8a`}}),fi=[Y,_e.low(Kr),di],pi=class{constructor(e,t,n){this.from=e,this.to=t,this.diagnostic=n}},mi=class e{constructor(e,t,n){this.diagnostics=e,this.panel=t,this.selected=n}static init(t,n,r){let i=r.facet(Ei).markerFilter;i&&(t=i(t,r));let a=t.slice().sort((e,t)=>e.from-t.from||e.to-t.to),o=new Ee,s=[],c=0,l=r.doc.iter(),u=0,d=r.doc.length;for(let e=0;;){let t=e==a.length?null:a[e];if(!t&&!s.length)break;let n,r;if(s.length)n=c,r=s.reduce((e,t)=>Math.min(e,t.to),t&&t.from>n?t.from:1e8);else{if(n=t.from,n>d)break;r=t.to,s.push(t),e++}for(;e<a.length;){let t=a[e];if(t.from==n&&(t.to>t.from||t.to==n))s.push(t),e++,r=Math.min(t.to,r);else{r=Math.min(t.from,r);break}}r=Math.min(r,d);let i=!1;if(s.some(e=>e.from==n&&(e.to==r||r==d))&&(i=n==r,!i&&r-n<10)){let e=n-(u+l.value.length);e>0&&(l.next(e),u=n);for(let e=n;;){if(e>=r){i=!0;break}if(!l.lineBreak&&u+l.value.length>e)break;e=u+l.value.length,u+=l.value.length,l.next()}}let f=Li(s);if(i)o.add(n,n,_.widget({widget:new Ai(f),diagnostics:s.slice()}));else{let e=s.reduce((e,t)=>t.markClass?e+` `+t.markClass:e,``);o.add(n,r,_.mark({class:`cm-lintRange cm-lintRange-`+f+e,diagnostics:s.slice(),inclusiveEnd:s.some(e=>e.to>r)}))}if(c=r,c==d)break;for(let e=0;e<s.length;e++)s[e].to<=c&&s.splice(e--,1)}let f=o.finish();return new e(f,n,Z(f))}};function Z(e,t=null,n=0){let r=null;return e.between(n,1e9,(e,n,{spec:i})=>{if(!(t&&i.diagnostics.indexOf(t)<0))if(!r)r=new pi(e,n,t||i.diagnostics[0]);else if(i.diagnostics.indexOf(r.diagnostic)<0)return!1;else r=new pi(r.from,n,r.diagnostic)}),r}function hi(e,t){let n=t.pos,r=t.end||n,i=e.state.facet(Ei).hideOn(e,n,r);if(i!=null)return i;let a=e.startState.doc.lineAt(t.pos);return!!(e.effects.some(e=>e.is(_i))||e.changes.touchesRange(a.from,Math.max(a.to,r)))}function gi(e,t){return e.field(Q,!1)?t:t.concat(P.appendConfig.of(Ri))}var _i=P.define(),vi=P.define(),yi=P.define(),Q=ce.define({create(){return new mi(_.none,null,null)},update(e,t){if(t.docChanged&&e.diagnostics.size){let n=e.diagnostics.map(t.changes),r=null,i=e.panel;if(e.selected){let i=t.changes.mapPos(e.selected.from,1);r=Z(n,e.selected.diagnostic,i)||Z(n,null,i)}!n.size&&i&&t.state.facet(Ei).autoPanel&&(i=null),e=new mi(n,i,r)}for(let n of t.effects)if(n.is(_i)){let r=t.state.facet(Ei).autoPanel?n.value.length?Mi.open:null:e.panel;e=mi.init(n.value,r,t.state)}else n.is(vi)?e=new mi(e.diagnostics,n.value?Mi.open:null,e.selected):n.is(yi)&&(e=new mi(e.diagnostics,e.panel,n.value));return e},provide:e=>[ke.from(e,e=>e.panel),E.decorations.from(e,e=>e.diagnostics)]}),bi=_.mark({class:`cm-lintRange cm-lintRange-active`});function xi(e,t,n){let{diagnostics:r}=e.state.field(Q),i,a=-1,o=-1;r.between(t-(n<0?1:0),t+(n>0?1:0),(e,r,{spec:s})=>{if(t>=e&&t<=r&&(e==r||(t>e||n>0)&&(t<r||n<0)))return i=s.diagnostics,a=e,o=r,!1});let s=e.state.facet(Ei).tooltipFilter;return i&&s&&(i=s(i,e.state)),i?{pos:a,end:o,above:e.state.doc.lineAt(a).to<o,create(){return{dom:Si(e,i)}}}:null}function Si(e,t){return x(`ul`,{class:`cm-tooltip-lint`},t.map(t=>ki(e,t,!1)))}var Ci=e=>{let t=e.state.field(Q,!1);(!t||!t.panel)&&e.dispatch({effects:gi(e.state,[vi.of(!0)])});let n=v(e,Mi.open);return n&&n.dom.querySelector(`.cm-panel-lint ul`).focus(),!0},wi=e=>{let t=e.state.field(Q,!1);return!t||!t.panel?!1:(e.dispatch({effects:vi.of(!1)}),!0)},Ti=[{key:`Mod-Shift-m`,run:Ci,preventDefault:!0},{key:`F8`,run:e=>{let t=e.state.field(Q,!1);if(!t)return!1;let n=e.state.selection.main,r=Z(t.diagnostics,null,n.to+1);return!r&&(r=Z(t.diagnostics,null,0),!r||r.from==n.from&&r.to==n.to)?!1:(e.dispatch({selection:{anchor:r.from,head:r.to},scrollIntoView:!0}),!0)}}],Ei=je.define({combine(e){return{sources:e.map(e=>e.source).filter(e=>e!=null),...Oe(e.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{delay:Math.max,markerFilter:Di,tooltipFilter:Di,needsRefresh:(e,t)=>e?t?n=>e(n)||t(n):e:t,hideOn:(e,t)=>e?t?(n,r,i)=>e(n,r,i)||t(n,r,i):e:t,autoPanel:(e,t)=>e||t})}}});function Di(e,t){return e?t?(n,r)=>t(e(n,r),r):e:t}function Oi(e){let t=[];if(e)actions:for(let{name:n}of e){for(let e=0;e<n.length;e++){let r=n[e];if(/[a-zA-Z]/.test(r)&&!t.some(e=>e.toLowerCase()==r.toLowerCase())){t.push(r);continue actions}}t.push(``)}return t}function ki(e,t,n){let r=n?Oi(t.actions):[];return x(`li`,{class:`cm-diagnostic cm-diagnostic-`+t.severity},x(`span`,{class:`cm-diagnosticText`},t.renderMessage?t.renderMessage(e):t.message),t.actions?.map((n,i)=>{let a=!1,o=r=>{if(r.preventDefault(),a)return;a=!0;let i=Z(e.state.field(Q).diagnostics,t);i&&n.apply(e,i.from,i.to)},{name:s}=n,c=r[i]?s.indexOf(r[i]):-1,l=c<0?s:[s.slice(0,c),x(`u`,s.slice(c,c+1)),s.slice(c+1)];return x(`button`,{type:`button`,class:`cm-diagnosticAction`+(n.markClass?` `+n.markClass:``),onclick:o,onmousedown:o,"aria-label":` Action: ${s}${c<0?``:` (access key "${r[i]})"`}.`},l)}),t.source&&x(`div`,{class:`cm-diagnosticSource`},t.source))}var Ai=class extends ve{constructor(e){super(),this.sev=e}eq(e){return e.sev==this.sev}toDOM(){return x(`span`,{class:`cm-lintPoint cm-lintPoint-`+this.sev})}},ji=class{constructor(e,t){this.diagnostic=t,this.id=`item_`+Math.floor(Math.random()*4294967295).toString(16),this.dom=ki(e,t,!0),this.dom.id=this.id,this.dom.setAttribute(`role`,`option`)}},Mi=class e{constructor(e){this.view=e,this.items=[];let t=t=>{if(!(t.ctrlKey||t.altKey||t.metaKey)){if(t.keyCode==27)wi(this.view),this.view.focus();else if(t.keyCode==38||t.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(t.keyCode==40||t.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(t.keyCode==36)this.moveSelection(0);else if(t.keyCode==35)this.moveSelection(this.items.length-1);else if(t.keyCode==13)this.view.focus();else if(t.keyCode>=65&&t.keyCode<=90&&this.selectedIndex>=0){let{diagnostic:n}=this.items[this.selectedIndex],r=Oi(n.actions);for(let i=0;i<r.length;i++)if(r[i].toUpperCase().charCodeAt(0)==t.keyCode){let t=Z(this.view.state.field(Q).diagnostics,n);t&&n.actions[i].apply(e,t.from,t.to)}}else return;t.preventDefault()}},n=e=>{for(let t=0;t<this.items.length;t++)this.items[t].dom.contains(e.target)&&this.moveSelection(t)};this.list=x(`ul`,{tabIndex:0,role:`listbox`,"aria-label":this.view.state.phrase(`Diagnostics`),onkeydown:t,onclick:n}),this.dom=x(`div`,{class:`cm-panel-lint`},this.list,x(`button`,{type:`button`,name:`close`,"aria-label":this.view.state.phrase(`close`),onclick:()=>wi(this.view)},`×`)),this.update()}get selectedIndex(){let e=this.view.state.field(Q).selected;if(!e)return-1;for(let t=0;t<this.items.length;t++)if(this.items[t].diagnostic==e.diagnostic)return t;return-1}update(){let{diagnostics:e,selected:t}=this.view.state.field(Q),n=0,r=!1,i=null,a=new Set;for(e.between(0,this.view.state.doc.length,(e,o,{spec:s})=>{for(let e of s.diagnostics){if(a.has(e))continue;a.add(e);let o=-1,s;for(let t=n;t<this.items.length;t++)if(this.items[t].diagnostic==e){o=t;break}o<0?(s=new ji(this.view,e),this.items.splice(n,0,s),r=!0):(s=this.items[o],o>n&&(this.items.splice(n,o-n),r=!0)),t&&s.diagnostic==t.diagnostic?s.dom.hasAttribute(`aria-selected`)||(s.dom.setAttribute(`aria-selected`,`true`),i=s):s.dom.hasAttribute(`aria-selected`)&&s.dom.removeAttribute(`aria-selected`),n++}});n<this.items.length&&!(this.items.length==1&&this.items[0].diagnostic.from<0);)r=!0,this.items.pop();this.items.length==0&&(this.items.push(new ji(this.view,{from:-1,to:-1,severity:`info`,message:this.view.state.phrase(`No diagnostics`)})),r=!0),i?(this.list.setAttribute(`aria-activedescendant`,i.id),this.view.requestMeasure({key:this,read:()=>({sel:i.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:e,panel:t})=>{let n=t.height/this.list.offsetHeight;e.top<t.top?this.list.scrollTop-=(t.top-e.top)/n:e.bottom>t.bottom&&(this.list.scrollTop+=(e.bottom-t.bottom)/n)}})):this.selectedIndex<0&&this.list.removeAttribute(`aria-activedescendant`),r&&this.sync()}sync(){let e=this.list.firstChild;function t(){let t=e;e=t.nextSibling,t.remove()}for(let n of this.items)if(n.dom.parentNode==this.list){for(;e!=n.dom;)t();e=n.dom.nextSibling}else this.list.insertBefore(n.dom,e);for(;e;)t()}moveSelection(e){if(this.selectedIndex<0)return;let t=Z(this.view.state.field(Q).diagnostics,this.items[e].diagnostic);t&&this.view.dispatch({selection:{anchor:t.from,head:t.to},scrollIntoView:!0,effects:yi.of(t)})}static open(t){return new e(t)}};function Ni(e,t=`viewBox="0 0 40 40"`){return`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${t}>${encodeURIComponent(e)}</svg>')`}function Pi(e){return Ni(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${e}" fill="none" stroke-width=".7"/>`,`width="6" height="3"`)}var Fi=E.baseTheme({".cm-diagnostic":{padding:`3px 6px 3px 8px`,marginLeft:`-1px`,display:`block`,whiteSpace:`pre-wrap`},".cm-diagnostic-error":{borderLeft:`5px solid #d11`},".cm-diagnostic-warning":{borderLeft:`5px solid orange`},".cm-diagnostic-info":{borderLeft:`5px solid #999`},".cm-diagnostic-hint":{borderLeft:`5px solid #66d`},".cm-diagnosticAction":{font:`inherit`,border:`none`,padding:`2px 4px`,backgroundColor:`#444`,color:`white`,borderRadius:`3px`,marginLeft:`8px`,cursor:`pointer`},".cm-diagnosticSource":{fontSize:`70%`,opacity:.7},".cm-lintRange":{backgroundPosition:`left bottom`,backgroundRepeat:`repeat-x`,paddingBottom:`0.7px`},".cm-lintRange-error":{backgroundImage:Pi(`#d11`)},".cm-lintRange-warning":{backgroundImage:Pi(`orange`)},".cm-lintRange-info":{backgroundImage:Pi(`#999`)},".cm-lintRange-hint":{backgroundImage:Pi(`#66d`)},".cm-lintRange-active":{backgroundColor:`#ffdd9980`},".cm-tooltip-lint":{padding:0,margin:0},".cm-lintPoint":{position:`relative`,"&:after":{content:`""`,position:`absolute`,bottom:0,left:`-2px`,borderLeft:`3px solid transparent`,borderRight:`3px solid transparent`,borderBottom:`4px solid #d11`}},".cm-lintPoint-warning":{"&:after":{borderBottomColor:`orange`}},".cm-lintPoint-info":{"&:after":{borderBottomColor:`#999`}},".cm-lintPoint-hint":{"&:after":{borderBottomColor:`#66d`}},".cm-panel.cm-panel-lint":{position:`relative`,"& ul":{maxHeight:`100px`,overflowY:`auto`,"& [aria-selected]":{backgroundColor:`#ddd`,"& u":{textDecoration:`underline`}},"&:focus [aria-selected]":{background_fallback:`#bdf`,backgroundColor:`Highlight`,color_fallback:`white`,color:`HighlightText`},"& u":{textDecoration:`none`},padding:0,margin:0},"& [name=close]":{position:`absolute`,top:`0`,right:`2px`,background:`inherit`,border:`none`,font:`inherit`,padding:0,margin:0}},"&dark .cm-lintRange-active":{backgroundColor:`#86714a80`},"&dark .cm-panel.cm-panel-lint ul":{"& [aria-selected]":{backgroundColor:`#2e343e`}}});function Ii(e){return e==`error`?4:e==`warning`?3:e==`info`?2:1}function Li(e){let t=`hint`,n=1;for(let r of e){let e=Ii(r.severity);e>n&&(n=e,t=r.severity)}return t}var Ri=[Q,E.decorations.compute([Q],e=>{let{selected:t,panel:n}=e.field(Q);return!t||!n||t.from==t.to?_.none:_.set([bi.range(t.from,t.to)])}),m(xi,{hideOn:hi}),Fi],zi=function(e){e===void 0&&(e={});var{crosshairCursor:t=!1}=e,n=[];e.closeBracketsKeymap!==!1&&(n=n.concat(Pe)),e.defaultKeymap!==!1&&(n=n.concat(sr)),e.searchKeymap!==!1&&(n=n.concat(oi)),e.historyKeymap!==!1&&(n=n.concat(wt)),e.foldKeymap!==!1&&(n=n.concat(pe)),e.completionKeymap!==!1&&(n=n.concat(le)),e.lintKeymap!==!1&&(n=n.concat(Ti));var r=[];return e.lineNumbers!==!1&&r.push(b()),e.highlightActiveLineGutter!==!1&&r.push(k()),e.highlightSpecialChars!==!1&&r.push(Be()),e.history!==!1&&r.push(st()),e.foldGutter!==!1&&r.push(he()),e.drawSelection!==!1&&r.push(T()),e.dropCursor!==!1&&r.push(D()),e.allowMultipleSelections!==!1&&r.push(we.allowMultipleSelections.of(!0)),e.indentOnInput!==!1&&r.push(ze()),e.syntaxHighlighting!==!1&&r.push(h(xe,{fallback:!0})),e.bracketMatching!==!1&&r.push(De()),e.closeBrackets!==!1&&r.push(ye()),e.autocompletion!==!1&&r.push(se()),e.rectangularSelection!==!1&&r.push(te()),t!==!1&&r.push(w()),e.highlightActiveLine!==!1&&r.push(C()),e.highlightSelectionMatches!==!1&&r.push(xr()),e.tabSize&&typeof e.tabSize==`number`&&r.push(Re.of(` `.repeat(e.tabSize))),r.concat([M.of(n.flat())]).filter(Boolean)},Bi=E.theme({"&":{backgroundColor:`#fff`}},{dark:!1}),Vi=function(e){e===void 0&&(e={});var{indentWithTab:t=!0,editable:n=!0,readOnly:r=!1,theme:i=`light`,placeholder:a=``,basicSetup:o=!0}=e,s=[];switch(t&&s.unshift(M.of([cr])),o&&(typeof o==`boolean`?s.unshift(zi()):s.unshift(zi(o))),a&&s.unshift(ee(a)),i){case`light`:s.push(Bi);break;case`dark`:s.push(Me);break;case`none`:break;default:s.push(i);break}return n===!1&&s.push(E.editable.of(!1)),r&&s.push(we.readOnly.of(!0)),[...s]},Hi=e=>({line:e.state.doc.lineAt(e.state.selection.main.from),lineCount:e.state.doc.lines,lineBreak:e.state.lineBreak,length:e.state.doc.length,readOnly:e.state.readOnly,tabSize:e.state.tabSize,selection:e.state.selection,selectionAsSingle:e.state.selection.asSingle().main,ranges:e.state.selection.ranges,selectionCode:e.state.sliceDoc(e.state.selection.main.from,e.state.selection.main.to),selections:e.state.selection.ranges.map(t=>e.state.sliceDoc(t.from,t.to)),selectedText:e.state.selection.ranges.some(e=>!e.empty)}),Ui=class{constructor(e,t){this.timeLeftMS=void 0,this.timeoutMS=void 0,this.isCancelled=!1,this.isTimeExhausted=!1,this.callbacks=[],this.timeLeftMS=t,this.timeoutMS=t,this.callbacks.push(e)}tick(){if(!this.isCancelled&&!this.isTimeExhausted&&(this.timeLeftMS--,this.timeLeftMS<=0)){this.isTimeExhausted=!0;var e=this.callbacks.slice();this.callbacks.length=0,e.forEach(e=>{try{e()}catch(e){console.error(`TimeoutLatch callback error:`,e)}})}}cancel(){this.isCancelled=!0,this.callbacks.length=0}reset(){this.timeLeftMS=this.timeoutMS,this.isCancelled=!1,this.isTimeExhausted=!1}get isDone(){return this.isCancelled||this.isTimeExhausted}},Wi=class{constructor(){this.interval=null,this.latches=new Set}add(e){this.latches.add(e),this.start()}remove(e){this.latches.delete(e),this.latches.size===0&&this.stop()}start(){this.interval===null&&(this.interval=setInterval(()=>{this.latches.forEach(e=>{e.tick(),e.isDone&&this.remove(e)})},1))}stop(){this.interval!==null&&(clearInterval(this.interval),this.interval=null)}},Gi=null,Ki=()=>typeof window>`u`?new Wi:(Gi||=new Wi,Gi),qi=ne.define(),Ji=200,Yi=[];function Xi(e){var{value:t,selection:n,onChange:r,onStatistics:i,onCreateEditor:a,onUpdate:o,extensions:s=Yi,autoFocus:c,theme:l=`light`,height:u=null,minHeight:d=null,maxHeight:f=null,width:p=null,minWidth:m=null,maxWidth:h=null,placeholder:g=``,editable:_=!0,readOnly:v=!1,indentWithTab:y=!0,basicSetup:b=!0,root:x,initialState:S}=e,[C,w]=(0,I.useState)(),[T,D]=(0,I.useState)(),[O,k]=(0,I.useState)(),A=(0,I.useState)(()=>({current:null}))[0],j=(0,I.useState)(()=>({current:null}))[0],ee=E.theme({"&":{height:u,minHeight:d,maxHeight:f,width:p,minWidth:m,maxWidth:h},"& .cm-scroller":{height:`100% !important`}}),M=[E.updateListener.of(e=>{e.docChanged&&typeof r==`function`&&!e.transactions.some(e=>e.annotation(qi))&&(A.current?A.current.reset():(A.current=new Ui(()=>{if(j.current){var e=j.current;j.current=null,e()}A.current=null},Ji),Ki().add(A.current)),r(e.state.doc.toString(),e)),i&&i(Hi(e))}),ee,...Vi({theme:l,editable:_,readOnly:v,placeholder:g,indentWithTab:y,basicSetup:b})];return o&&typeof o==`function`&&M.push(E.updateListener.of(o)),M=M.concat(s),(0,I.useLayoutEffect)(()=>{if(C&&!O){var e={doc:t,selection:n,extensions:M},r=S?we.fromJSON(S.json,e,S.fields):we.create(e);if(k(r),!T){var i=new E({state:r,parent:C,root:x});D(i),a&&a(i,r)}}return()=>{T&&(k(void 0),D(void 0))}},[C,O]),(0,I.useEffect)(()=>{e.container&&w(e.container)},[e.container]),(0,I.useEffect)(()=>()=>{T&&(T.destroy(),D(void 0)),A.current&&=(A.current.cancel(),null)},[T]),(0,I.useEffect)(()=>{c&&T&&T.focus()},[c,T]),(0,I.useEffect)(()=>{T&&T.dispatch({effects:P.reconfigure.of(M)})},[l,s,u,d,f,p,m,h,g,_,v,y,b,r,o]),(0,I.useEffect)(()=>{if(t!==void 0){var e=T?T.state.doc.toString():``;if(T&&t!==e){var n=A.current&&!A.current.isDone,r=()=>{T&&t!==T.state.doc.toString()&&T.dispatch({changes:{from:0,to:T.state.doc.toString().length,insert:t||``},annotations:[qi.of(!0)]})};n?j.current=r:r()}}},[t,T]),{state:O,setState:k,view:T,setView:D,container:C,setContainer:w}}var $=r(),Zi=[`className`,`value`,`selection`,`extensions`,`onChange`,`onStatistics`,`onCreateEditor`,`onUpdate`,`autoFocus`,`theme`,`height`,`minHeight`,`maxHeight`,`width`,`minWidth`,`maxWidth`,`basicSetup`,`placeholder`,`indentWithTab`,`editable`,`readOnly`,`root`,`initialState`],Qi=(0,I.forwardRef)((e,t)=>{var{className:n,value:r=``,selection:i,extensions:a=[],onChange:o,onStatistics:s,onCreateEditor:c,onUpdate:l,autoFocus:u,theme:d=`light`,height:f,minHeight:p,maxHeight:m,width:h,minWidth:g,maxWidth:_,basicSetup:v,placeholder:y,indentWithTab:b,editable:x,readOnly:S,root:C,initialState:w}=e,T=We(e,Zi),E=(0,I.useRef)(null),{state:D,view:O,container:k,setContainer:A}=Xi({root:C,value:r,autoFocus:u,theme:d,height:f,minHeight:p,maxHeight:m,width:h,minWidth:g,maxWidth:_,basicSetup:v,placeholder:y,indentWithTab:b,editable:x,readOnly:S,selection:i,onChange:o,onStatistics:s,onCreateEditor:c,onUpdate:l,extensions:a,initialState:w});(0,I.useImperativeHandle)(t,()=>({editor:E.current,state:D,view:O}),[E,k,D,O]);var j=(0,I.useCallback)(e=>{E.current=e,A(e)},[A]);if(typeof r!=`string`)throw Error(`value must be typeof string but got `+typeof r);return(0,$.jsx)(`div`,Ue({ref:j,className:(typeof d==`string`?`cm-theme-`+d:`cm-theme`)+(n?` `+n:``)},T))});Qi.displayName=`CodeMirror`;var $i=new Set([`png`,`jpg`,`jpeg`,`gif`,`webp`,`svg`,`ico`]),ea=`pdf`;function ta(e){return e.split(`.`).pop()?.toLowerCase()??``}function na(e){switch(ta(e)){case`js`:case`jsx`:return Te({jsx:!0});case`ts`:case`tsx`:return Te({jsx:!0,typescript:!0});case`py`:return ae();case`html`:return Ae();case`css`:case`scss`:return ge();case`json`:return Ce();case`md`:case`mdx`:return Ne();default:return null}}function ra({metadata:e,tabId:t}){let n=e?.filePath,r=e?.projectName,[a,o]=(0,I.useState)(null),[s,f]=(0,I.useState)(`utf-8`),[p,m]=(0,I.useState)(!0),[h,g]=(0,I.useState)(null),[_,v]=(0,I.useState)(!1),y=(0,I.useRef)(null),b=(0,I.useRef)(``),{tabs:x,updateTab:S}=d(),C=x.find(e=>e.id===t),w=n?ta(n):``,T=$i.has(w),E=w===ea,D=w===`md`||w===`mdx`,[O,k]=(0,I.useState)(`preview`);(0,I.useEffect)(()=>{if(!(!n||!r)){if(T||E){m(!1);return}return m(!0),g(null),l.get(`${c(r)}/files/read?path=${encodeURIComponent(n)}`).then(e=>{o(e.content),f(e.encoding),b.current=e.content,m(!1)}).catch(e=>{g(e instanceof Error?e.message:`Failed to load file`),m(!1)}),()=>{y.current&&clearTimeout(y.current)}}},[n,r,T,E]),(0,I.useEffect)(()=>{if(!C)return;let e=n?.split(`/`).pop()??`Untitled`,t=_?`${e} \u25CF`:e;C.title!==t&&S(C.id,{title:t})},[_]);let A=(0,I.useCallback)(async e=>{if(!(!n||!r))try{await l.put(`${c(r)}/files/write`,{path:n,content:e}),v(!1)}catch{}},[n,r]);function j(e){o(e),b.current=e,v(!0),y.current&&clearTimeout(y.current),y.current=setTimeout(()=>{A(b.current)},1e3)}if(!n||!r)return(0,$.jsx)(`div`,{className:`flex items-center justify-center h-full text-text-secondary text-sm`,children:`No file selected.`});if(p)return(0,$.jsxs)(`div`,{className:`flex items-center justify-center h-full gap-2 text-text-secondary`,children:[(0,$.jsx)(u,{className:`size-5 animate-spin`}),(0,$.jsx)(`span`,{className:`text-sm`,children:`Loading file...`})]});if(h)return(0,$.jsx)(`div`,{className:`flex items-center justify-center h-full text-error text-sm`,children:h});if(T)return(0,$.jsx)(aa,{filePath:n,projectName:r});if(E)return(0,$.jsx)(oa,{filePath:n,projectName:r});if(s===`base64`)return(0,$.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full gap-3 text-text-secondary`,children:[(0,$.jsx)(He,{className:`size-10 text-text-subtle`}),(0,$.jsx)(`p`,{className:`text-sm`,children:`This file is a binary format and cannot be displayed.`}),(0,$.jsx)(`p`,{className:`text-xs text-text-subtle`,children:n})]});let ee=[],M=na(n);M&&ee.push(M);let te=D?(0,$.jsxs)(`div`,{className:`flex items-center gap-1 px-2 py-1 border-border shrink-0 bg-background`,children:[(0,$.jsxs)(`button`,{type:`button`,onClick:()=>k(`edit`),className:`flex items-center gap-1 px-2 py-1 rounded text-xs transition-colors ${O===`edit`?`bg-muted text-foreground`:`text-muted-foreground hover:text-foreground`}`,children:[(0,$.jsx)(i,{className:`size-3`}),`Edit`]}),(0,$.jsxs)(`button`,{type:`button`,onClick:()=>k(`preview`),className:`flex items-center gap-1 px-2 py-1 rounded text-xs transition-colors ${O===`preview`?`bg-muted text-foreground`:`text-muted-foreground hover:text-foreground`}`,children:[(0,$.jsx)(Ve,{className:`size-3`}),`Preview`]})]}):null;return(0,$.jsxs)(`div`,{className:`flex flex-col h-full w-full overflow-hidden`,children:[(0,$.jsx)(`div`,{className:`hidden md:block border-b`,children:te}),D&&O===`preview`?(0,$.jsx)(ia,{content:a??``}):(0,$.jsx)(`div`,{className:`flex-1 overflow-hidden`,children:(0,$.jsx)(Qi,{value:a??``,onChange:j,extensions:ee,theme:Me,height:`100%`,style:{height:`100%`,fontSize:`13px`,fontFamily:`var(--font-mono)`},basicSetup:{lineNumbers:!0,foldGutter:!0,autocompletion:!0,bracketMatching:!0,closeBrackets:!0,highlightActiveLine:!0,indentOnInput:!0}})}),(0,$.jsx)(`div`,{className:`md:hidden border-t`,children:te})]})}function ia({content:e}){return(0,$.jsx)(`div`,{className:`flex-1 overflow-auto p-4 markdown-content prose-sm`,dangerouslySetInnerHTML:{__html:(0,I.useMemo)(()=>{try{return a.parse(e,{gfm:!0,breaks:!0})}catch{return e}},[e])}})}function aa({filePath:e,projectName:t}){let[n,r]=(0,I.useState)(null),[i,a]=(0,I.useState)(!1);return(0,I.useEffect)(()=>{let n,i=`${c(t)}/files/raw?path=${encodeURIComponent(e)}`,o=s();return fetch(i,{headers:o?{Authorization:`Bearer ${o}`}:{}}).then(e=>{if(!e.ok)throw Error(`Failed`);return e.blob()}).then(e=>{let t=URL.createObjectURL(e);n=t,r(t)}).catch(()=>a(!0)),()=>{n&&URL.revokeObjectURL(n)}},[e,t]),i?(0,$.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full gap-3 text-text-secondary`,children:[(0,$.jsx)(He,{className:`size-10 text-text-subtle`}),(0,$.jsx)(`p`,{className:`text-sm`,children:`Failed to load image.`})]}):n?(0,$.jsx)(`div`,{className:`flex items-center justify-center h-full p-4 bg-surface overflow-auto`,children:(0,$.jsx)(`img`,{src:n,alt:e,className:`max-w-full max-h-full object-contain`})}):(0,$.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,$.jsx)(u,{className:`size-5 animate-spin text-text-subtle`})})}function oa({filePath:e,projectName:t}){let[n,r]=(0,I.useState)(null),[i,a]=(0,I.useState)(!1);(0,I.useEffect)(()=>{let n,i=`${c(t)}/files/raw?path=${encodeURIComponent(e)}`,o=s();return fetch(i,{headers:o?{Authorization:`Bearer ${o}`}:{}}).then(e=>{if(!e.ok)throw Error(`Failed`);return e.blob()}).then(e=>{let t=URL.createObjectURL(new Blob([e],{type:`application/pdf`}));n=t,r(t)}).catch(()=>a(!0)),()=>{n&&URL.revokeObjectURL(n)}},[e,t]);let l=(0,I.useCallback)(()=>{n&&window.open(n,`_blank`)},[n]);return i?(0,$.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full gap-3 text-text-secondary`,children:[(0,$.jsx)(He,{className:`size-10 text-text-subtle`}),(0,$.jsx)(`p`,{className:`text-sm`,children:`Failed to load PDF.`})]}):n?(0,$.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-1.5 border-b border-border bg-background shrink-0`,children:[(0,$.jsx)(`span`,{className:`text-xs text-text-secondary truncate`,children:e}),(0,$.jsxs)(`button`,{onClick:l,className:`flex items-center gap-1 text-xs text-text-secondary hover:text-text-primary transition-colors`,children:[(0,$.jsx)(o,{className:`size-3`}),`Open in new tab`]})]}),(0,$.jsx)(`iframe`,{src:n,title:e,className:`flex-1 w-full border-none`})]}):(0,$.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,$.jsx)(u,{className:`size-5 animate-spin text-text-subtle`})})}export{ra as CodeEditor};
@@ -1,4 +1,4 @@
1
- import{a as e,r as t,t as n}from"./jsx-runtime-BFALxl05.js";import{_ as r,a as i,b as a,d as o,f as s,h as c,i as l,l as u,m as d,n as ee,o as f,p,r as te,s as ne,t as m,u as h}from"./button-KIZetva8.js";import{t as re}from"./x-BxhOxZ5p.js";import{t as g}from"./utils-DpJF9mAi.js";var _=e(t(),1);function ie(e,t){return _.useReducer((e,n)=>t[e][n]??e,e)}var v=e=>{let{present:t,children:n}=e,r=y(t),i=typeof n==`function`?n({present:r.isPresent}):_.Children.only(n),o=a(r.ref,x(i));return typeof n==`function`||r.isPresent?_.cloneElement(i,{ref:o}):null};v.displayName=`Presence`;function y(e){let[t,n]=_.useState(),r=_.useRef(null),i=_.useRef(e),a=_.useRef(`none`),[s,c]=ie(e?`mounted`:`unmounted`,{mounted:{UNMOUNT:`unmounted`,ANIMATION_OUT:`unmountSuspended`},unmountSuspended:{MOUNT:`mounted`,ANIMATION_END:`unmounted`},unmounted:{MOUNT:`mounted`}});return _.useEffect(()=>{let e=b(r.current);a.current=s===`mounted`?e:`none`},[s]),o(()=>{let t=r.current,n=i.current;if(n!==e){let r=a.current,o=b(t);e?c(`MOUNT`):o===`none`||t?.display===`none`?c(`UNMOUNT`):c(n&&r!==o?`ANIMATION_OUT`:`UNMOUNT`),i.current=e}},[e,c]),o(()=>{if(t){let e,n=t.ownerDocument.defaultView??window,o=a=>{let o=b(r.current).includes(CSS.escape(a.animationName));if(a.target===t&&o&&(c(`ANIMATION_END`),!i.current)){let r=t.style.animationFillMode;t.style.animationFillMode=`forwards`,e=n.setTimeout(()=>{t.style.animationFillMode===`forwards`&&(t.style.animationFillMode=r)})}},s=e=>{e.target===t&&(a.current=b(r.current))};return t.addEventListener(`animationstart`,s),t.addEventListener(`animationcancel`,o),t.addEventListener(`animationend`,o),()=>{n.clearTimeout(e),t.removeEventListener(`animationstart`,s),t.removeEventListener(`animationcancel`,o),t.removeEventListener(`animationend`,o)}}else c(`ANIMATION_END`)},[t,c]),{isPresent:[`mounted`,`unmountSuspended`].includes(s),ref:_.useCallback(e=>{r.current=e?getComputedStyle(e):null,n(e)},[])}}function b(e){return e?.animationName||`none`}function x(e){let t=Object.getOwnPropertyDescriptor(e.props,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var S=n(),C=`Dialog`,[w,ae]=d(C),[T,E]=w(C),D=e=>{let{__scopeDialog:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!0}=e,s=_.useRef(null),c=_.useRef(null),[l,d]=h({prop:r,defaultProp:i??!1,onChange:a,caller:C});return(0,S.jsx)(T,{scope:t,triggerRef:s,contentRef:c,contentId:u(),titleId:u(),descriptionId:u(),open:l,onOpenChange:d,onOpenToggle:_.useCallback(()=>d(e=>!e),[d]),modal:o,children:n})};D.displayName=C;var O=`DialogTrigger`,k=_.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=E(O,n),o=a(t,i.triggerRef);return(0,S.jsx)(c.button,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":i.open,"aria-controls":i.contentId,"data-state":Y(i.open),...r,ref:o,onClick:s(e.onClick,i.onOpenToggle)})});k.displayName=O;var A=`DialogPortal`,[j,M]=w(A,{forceMount:void 0}),N=e=>{let{__scopeDialog:t,forceMount:n,children:r,container:a}=e,o=E(A,t);return(0,S.jsx)(j,{scope:t,forceMount:n,children:_.Children.map(r,e=>(0,S.jsx)(v,{present:n||o.open,children:(0,S.jsx)(i,{asChild:!0,container:a,children:e})}))})};N.displayName=A;var P=`DialogOverlay`,F=_.forwardRef((e,t)=>{let n=M(P,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=E(P,e.__scopeDialog);return a.modal?(0,S.jsx)(v,{present:r||a.open,children:(0,S.jsx)(L,{...i,ref:t})}):null});F.displayName=P;var I=r(`DialogOverlay.RemoveScroll`),L=_.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=E(P,n);return(0,S.jsx)(te,{as:I,allowPinchZoom:!0,shards:[i.contentRef],children:(0,S.jsx)(c.div,{"data-state":Y(i.open),...r,ref:t,style:{pointerEvents:`auto`,...r.style}})})}),R=`DialogContent`,z=_.forwardRef((e,t)=>{let n=M(R,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=E(R,e.__scopeDialog);return(0,S.jsx)(v,{present:r||a.open,children:a.modal?(0,S.jsx)(B,{...i,ref:t}):(0,S.jsx)(V,{...i,ref:t})})});z.displayName=R;var B=_.forwardRef((e,t)=>{let n=E(R,e.__scopeDialog),r=_.useRef(null),i=a(t,n.contentRef,r);return _.useEffect(()=>{let e=r.current;if(e)return ee(e)},[]),(0,S.jsx)(H,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:s(e.onCloseAutoFocus,e=>{e.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:s(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0;(t.button===2||n)&&e.preventDefault()}),onFocusOutside:s(e.onFocusOutside,e=>e.preventDefault())})}),V=_.forwardRef((e,t)=>{let n=E(R,e.__scopeDialog),r=_.useRef(!1),i=_.useRef(!1);return(0,S.jsx)(H,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(r.current||n.triggerRef.current?.focus(),t.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(r.current=!0,t.detail.originalEvent.type===`pointerdown`&&(i.current=!0));let a=t.target;n.triggerRef.current?.contains(a)&&t.preventDefault(),t.detail.originalEvent.type===`focusin`&&i.current&&t.preventDefault()}})}),H=_.forwardRef((e,t)=>{let{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:o,...s}=e,c=E(R,n),u=_.useRef(null),d=a(t,u);return l(),(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(f,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:o,children:(0,S.jsx)(ne,{role:`dialog`,id:c.contentId,"aria-describedby":c.descriptionId,"aria-labelledby":c.titleId,"data-state":Y(c.open),...s,ref:d,onDismiss:()=>c.onOpenChange(!1)})}),(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(se,{titleId:c.titleId}),(0,S.jsx)(le,{contentRef:u,descriptionId:c.descriptionId})]})]})}),U=`DialogTitle`,W=_.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=E(U,n);return(0,S.jsx)(c.h2,{id:i.titleId,...r,ref:t})});W.displayName=U;var G=`DialogDescription`,K=_.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=E(G,n);return(0,S.jsx)(c.p,{id:i.descriptionId,...r,ref:t})});K.displayName=G;var q=`DialogClose`,J=_.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=E(q,n);return(0,S.jsx)(c.button,{type:`button`,...r,ref:t,onClick:s(e.onClick,()=>i.onOpenChange(!1))})});J.displayName=q;function Y(e){return e?`open`:`closed`}var X=`DialogTitleWarning`,[oe,Z]=p(X,{contentName:R,titleName:U,docsSlug:`dialog`}),se=({titleId:e})=>{let t=Z(X),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
1
+ import{a as e,r as t,t as n}from"./jsx-runtime-BFALxl05.js";import{_ as r,a as i,b as a,d as o,f as s,h as c,i as l,l as u,m as d,n as ee,o as f,p,r as te,s as ne,t as m,u as h}from"./button-CvHWF07y.js";import{t as re}from"./x-BxhOxZ5p.js";import{t as g}from"./utils-61GRB9Cb.js";var _=e(t(),1);function ie(e,t){return _.useReducer((e,n)=>t[e][n]??e,e)}var v=e=>{let{present:t,children:n}=e,r=y(t),i=typeof n==`function`?n({present:r.isPresent}):_.Children.only(n),o=a(r.ref,x(i));return typeof n==`function`||r.isPresent?_.cloneElement(i,{ref:o}):null};v.displayName=`Presence`;function y(e){let[t,n]=_.useState(),r=_.useRef(null),i=_.useRef(e),a=_.useRef(`none`),[s,c]=ie(e?`mounted`:`unmounted`,{mounted:{UNMOUNT:`unmounted`,ANIMATION_OUT:`unmountSuspended`},unmountSuspended:{MOUNT:`mounted`,ANIMATION_END:`unmounted`},unmounted:{MOUNT:`mounted`}});return _.useEffect(()=>{let e=b(r.current);a.current=s===`mounted`?e:`none`},[s]),o(()=>{let t=r.current,n=i.current;if(n!==e){let r=a.current,o=b(t);e?c(`MOUNT`):o===`none`||t?.display===`none`?c(`UNMOUNT`):c(n&&r!==o?`ANIMATION_OUT`:`UNMOUNT`),i.current=e}},[e,c]),o(()=>{if(t){let e,n=t.ownerDocument.defaultView??window,o=a=>{let o=b(r.current).includes(CSS.escape(a.animationName));if(a.target===t&&o&&(c(`ANIMATION_END`),!i.current)){let r=t.style.animationFillMode;t.style.animationFillMode=`forwards`,e=n.setTimeout(()=>{t.style.animationFillMode===`forwards`&&(t.style.animationFillMode=r)})}},s=e=>{e.target===t&&(a.current=b(r.current))};return t.addEventListener(`animationstart`,s),t.addEventListener(`animationcancel`,o),t.addEventListener(`animationend`,o),()=>{n.clearTimeout(e),t.removeEventListener(`animationstart`,s),t.removeEventListener(`animationcancel`,o),t.removeEventListener(`animationend`,o)}}else c(`ANIMATION_END`)},[t,c]),{isPresent:[`mounted`,`unmountSuspended`].includes(s),ref:_.useCallback(e=>{r.current=e?getComputedStyle(e):null,n(e)},[])}}function b(e){return e?.animationName||`none`}function x(e){let t=Object.getOwnPropertyDescriptor(e.props,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var S=n(),C=`Dialog`,[w,ae]=d(C),[T,E]=w(C),D=e=>{let{__scopeDialog:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!0}=e,s=_.useRef(null),c=_.useRef(null),[l,d]=h({prop:r,defaultProp:i??!1,onChange:a,caller:C});return(0,S.jsx)(T,{scope:t,triggerRef:s,contentRef:c,contentId:u(),titleId:u(),descriptionId:u(),open:l,onOpenChange:d,onOpenToggle:_.useCallback(()=>d(e=>!e),[d]),modal:o,children:n})};D.displayName=C;var O=`DialogTrigger`,k=_.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=E(O,n),o=a(t,i.triggerRef);return(0,S.jsx)(c.button,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":i.open,"aria-controls":i.contentId,"data-state":Y(i.open),...r,ref:o,onClick:s(e.onClick,i.onOpenToggle)})});k.displayName=O;var A=`DialogPortal`,[j,M]=w(A,{forceMount:void 0}),N=e=>{let{__scopeDialog:t,forceMount:n,children:r,container:a}=e,o=E(A,t);return(0,S.jsx)(j,{scope:t,forceMount:n,children:_.Children.map(r,e=>(0,S.jsx)(v,{present:n||o.open,children:(0,S.jsx)(i,{asChild:!0,container:a,children:e})}))})};N.displayName=A;var P=`DialogOverlay`,F=_.forwardRef((e,t)=>{let n=M(P,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=E(P,e.__scopeDialog);return a.modal?(0,S.jsx)(v,{present:r||a.open,children:(0,S.jsx)(L,{...i,ref:t})}):null});F.displayName=P;var I=r(`DialogOverlay.RemoveScroll`),L=_.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=E(P,n);return(0,S.jsx)(te,{as:I,allowPinchZoom:!0,shards:[i.contentRef],children:(0,S.jsx)(c.div,{"data-state":Y(i.open),...r,ref:t,style:{pointerEvents:`auto`,...r.style}})})}),R=`DialogContent`,z=_.forwardRef((e,t)=>{let n=M(R,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=E(R,e.__scopeDialog);return(0,S.jsx)(v,{present:r||a.open,children:a.modal?(0,S.jsx)(B,{...i,ref:t}):(0,S.jsx)(V,{...i,ref:t})})});z.displayName=R;var B=_.forwardRef((e,t)=>{let n=E(R,e.__scopeDialog),r=_.useRef(null),i=a(t,n.contentRef,r);return _.useEffect(()=>{let e=r.current;if(e)return ee(e)},[]),(0,S.jsx)(H,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:s(e.onCloseAutoFocus,e=>{e.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:s(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0;(t.button===2||n)&&e.preventDefault()}),onFocusOutside:s(e.onFocusOutside,e=>e.preventDefault())})}),V=_.forwardRef((e,t)=>{let n=E(R,e.__scopeDialog),r=_.useRef(!1),i=_.useRef(!1);return(0,S.jsx)(H,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(r.current||n.triggerRef.current?.focus(),t.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(r.current=!0,t.detail.originalEvent.type===`pointerdown`&&(i.current=!0));let a=t.target;n.triggerRef.current?.contains(a)&&t.preventDefault(),t.detail.originalEvent.type===`focusin`&&i.current&&t.preventDefault()}})}),H=_.forwardRef((e,t)=>{let{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:o,...s}=e,c=E(R,n),u=_.useRef(null),d=a(t,u);return l(),(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(f,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:o,children:(0,S.jsx)(ne,{role:`dialog`,id:c.contentId,"aria-describedby":c.descriptionId,"aria-labelledby":c.titleId,"data-state":Y(c.open),...s,ref:d,onDismiss:()=>c.onOpenChange(!1)})}),(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(se,{titleId:c.titleId}),(0,S.jsx)(le,{contentRef:u,descriptionId:c.descriptionId})]})]})}),U=`DialogTitle`,W=_.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=E(U,n);return(0,S.jsx)(c.h2,{id:i.titleId,...r,ref:t})});W.displayName=U;var G=`DialogDescription`,K=_.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=E(G,n);return(0,S.jsx)(c.p,{id:i.descriptionId,...r,ref:t})});K.displayName=G;var q=`DialogClose`,J=_.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=E(q,n);return(0,S.jsx)(c.button,{type:`button`,...r,ref:t,onClick:s(e.onClick,()=>i.onOpenChange(!1))})});J.displayName=q;function Y(e){return e?`open`:`closed`}var X=`DialogTitleWarning`,[oe,Z]=p(X,{contentName:R,titleName:U,docsSlug:`dialog`}),se=({titleId:e})=>{let t=Z(X),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
2
2
 
3
3
  If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
4
4
 
@@ -1,4 +1,4 @@
1
- import{a as e,n as t,r as n,t as r}from"./jsx-runtime-BFALxl05.js";import{r as i,t as a}from"./api-client-BgVufYKf.js";import{C as o,_ as s}from"./index-nk1dAWff.js";import{A as c,E as l,H as u,I as d,O as f,Q as p,Y as m,a as h,at as g,ct as _,et as v,i as y,it as b,j as x,k as S,n as C,nt as ee,o as w,ot as T,r as E,rt as D,s as te,st as O,t as k}from"./dist-CBiGQxfr.js";var ne=t(`columns-2`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M12 3v18`,key:`108xh3`}]]),re=t(`panel-left-open`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}],[`path`,{d:`m14 9 3 3-3 3`,key:`8010ee`}]]),ie=t(`panel-right-open`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M15 3v18`,key:`14nvp0`}],[`path`,{d:`m10 15-3-3 3-3`,key:`1pgupc`}]]),A=e(n(),1),j=class e{constructor(e,t,n,r){this.fromA=e,this.toA=t,this.fromB=n,this.toB=r}offset(t,n=t){return new e(this.fromA+t,this.toA+t,this.fromB+n,this.toB+n)}};function M(e,t,n,r,i,a){if(e==r)return[];let o=R(e,t,n,r,i,a),s=z(e,t+o,n,r,i+o,a);t+=o,n-=s,i+=o,a-=s;let c=n-t,l=a-i;if(!c||!l)return[new j(t,n,i,a)];if(c>l){let o=e.slice(t,n).indexOf(r.slice(i,a));if(o>-1)return[new j(t,t+o,i,i),new j(t+o+l,n,a,a)]}else if(l>c){let o=r.slice(i,a).indexOf(e.slice(t,n));if(o>-1)return[new j(t,t,i,i+o),new j(n,n,i+o+c,a)]}if(c==1||l==1)return[new j(t,n,i,a)];let u=le(e,t,n,r,i,a);if(u){let[o,s,c]=u;return M(e,t,o,r,i,s).concat(M(e,o+c,n,r,s+c,a))}return ae(e,t,n,r,i,a)}var N=1e9,P=0,F=!1;function ae(e,t,n,r,i,a){let o=n-t,s=a-i;if(N<1e9&&Math.min(o,s)>N*16||P>0&&Date.now()>P)return Math.min(o,s)>N*64?[new j(t,n,i,a)]:ue(e,t,n,r,i,a);let c=Math.ceil((o+s)/2);I.reset(c),L.reset(c);let l=(n,a)=>e.charCodeAt(t+n)==r.charCodeAt(i+a),u=(t,i)=>e.charCodeAt(n-t-1)==r.charCodeAt(a-i-1),d=(o-s)%2==0?null:L,f=d?null:I;for(let p=0;p<c;p++){if(p>N||P>0&&!(p&63)&&Date.now()>P)return ue(e,t,n,r,i,a);let m=I.advance(p,o,s,c,d,!1,l)||L.advance(p,o,s,c,f,!0,u);if(m)return se(e,t,n,t+m[0],r,i,a,i+m[1])}return[new j(t,n,i,a)]}var oe=class{constructor(){this.vec=[]}reset(e){this.len=e<<1;for(let e=0;e<this.len;e++)this.vec[e]=-1;this.vec[e+1]=0,this.start=this.end=0}advance(e,t,n,r,i,a,o){for(let s=-e+this.start;s<=e-this.end;s+=2){let c=r+s,l=s==-e||s!=e&&this.vec[c-1]<this.vec[c+1]?this.vec[c+1]:this.vec[c-1]+1,u=l-s;for(;l<t&&u<n&&o(l,u);)l++,u++;if(this.vec[c]=l,l>t)this.end+=2;else if(u>n)this.start+=2;else if(i){let e=r+(t-n)-s;if(e>=0&&e<this.len&&i.vec[e]!=-1)if(a){let n=i.vec[e];if(n>=t-l)return[n,r+n-e]}else{let n=t-i.vec[e];if(l>=n)return[l,u]}}}return null}},I=new oe,L=new oe;function se(e,t,n,r,i,a,o,s){let c=!1;return!H(e,r)&&++r==n&&(c=!0),!H(i,s)&&++s==o&&(c=!0),c?[new j(t,n,a,o)]:M(e,t,r,i,a,s).concat(M(e,r,n,i,s,o))}function ce(e,t){let n=1,r=Math.min(e,t);for(;n<r;)n<<=1;return n}function R(e,t,n,r,i,a){if(t==n||t==a||e.charCodeAt(t)!=r.charCodeAt(i))return 0;let o=ce(n-t,a-i);for(let s=t,c=i;;){let i=s+o,l=c+o;if(i>n||l>a||e.slice(s,i)!=r.slice(c,l)){if(o==1)return s-t-(H(e,s)?0:1);o>>=1}else if(i==n||l==a)return i-t;else s=i,c=l}}function z(e,t,n,r,i,a){if(t==n||i==a||e.charCodeAt(n-1)!=r.charCodeAt(a-1))return 0;let o=ce(n-t,a-i);for(let s=n,c=a;;){let a=s-o,l=c-o;if(a<t||l<i||e.slice(a,s)!=r.slice(l,c)){if(o==1)return n-s-(H(e,s)?0:1);o>>=1}else if(a==t||l==i)return n-a;else s=a,c=l}}function B(e,t,n,r,i,a,o,s){let c=r.slice(i,a),l=null;for(;;){if(l||o<s)return l;for(let s=t+o;;){H(e,s)||s++;let u=s+o;if(H(e,u)||(u+=u==s+1?1:-1),u>=n)break;let d=e.slice(s,u),f=-1;for(;(f=c.indexOf(d,f+1))!=-1;){let o=R(e,u,n,r,i+f+d.length,a),c=z(e,t,s,r,i,i+f),p=d.length+o+c;(!l||l[2]<p)&&(l=[s-c,i+f-c,p])}s=u}if(s<0)return l;o>>=1}}function le(e,t,n,r,i,a){let o=n-t,s=a-i;if(o<s){let o=le(r,i,a,e,t,n);return o&&[o[1],o[0],o[2]]}return o<4||s*2<o?null:B(e,t,n,r,i,a,Math.floor(o/4),-1)}function ue(e,t,n,r,i,a){F=!0;let o=n-t,s=a-i,c;if(o<s){let s=B(r,i,a,e,t,n,Math.floor(o/6),50);c=s&&[s[1],s[0],s[2]]}else c=B(e,t,n,r,i,a,Math.floor(s/6),50);if(!c)return[new j(t,n,i,a)];let[l,u,d]=c;return M(e,t,l,r,i,u).concat(M(e,l+d,n,r,u+d,a))}function de(e,t){for(let n=1;n<e.length;n++){let r=e[n-1],i=e[n];r.toA>i.fromA-t&&r.toB>i.fromB-t&&(e[n-1]=new j(r.fromA,i.toA,r.fromB,i.toB),e.splice(n--,1))}}function fe(e,t,n){for(;;){de(n,1);let r=!1;for(let i=0;i<n.length;i++){let a=n[i],o,s;(o=R(e,a.fromA,a.toA,t,a.fromB,a.toB))&&(a=n[i]=new j(a.fromA+o,a.toA,a.fromB+o,a.toB)),(s=z(e,a.fromA,a.toA,t,a.fromB,a.toB))&&(a=n[i]=new j(a.fromA,a.toA-s,a.fromB,a.toB-s));let c=a.toA-a.fromA,l=a.toB-a.fromB;if(c&&l)continue;let u=a.fromA-(i?n[i-1].toA:0),d=(i<n.length-1?n[i+1].fromA:e.length)-a.toA;if(!u||!d)continue;let f=c?e.slice(a.fromA,a.toA):t.slice(a.fromB,a.toB);u<=f.length&&e.slice(a.fromA-u,a.fromA)==f.slice(f.length-u)?(n[i]=new j(a.fromA-u,a.toA-u,a.fromB-u,a.toB-u),r=!0):d<=f.length&&e.slice(a.toA,a.toA+d)==f.slice(0,d)&&(n[i]=new j(a.fromA+d,a.toA+d,a.fromB+d,a.toB+d),r=!0)}if(!r)break}return n}function pe(e,t,n){for(let r=0,i=0;i<e.length;i++){let a=e[i],o=a.toA-a.fromA,s=a.toB-a.fromB;if(o&&s||o>3||s>3){let c=i==e.length-1?t.length:e[i+1].fromA,l=a.fromA-r,u=c-a.toA,d=ye(t,a.fromA,l),f=ve(t,a.toA,u),p=a.fromA-d,m=f-a.toA;if((!o||!s)&&p&&m){let l=Math.max(o,s),[u,h,g]=o?[t,a.fromA,a.toA]:[n,a.fromB,a.toB];l>p&&t.slice(d,a.fromA)==u.slice(g-p,g)?(a=e[i]=new j(d,d+o,a.fromB-p,a.toB-p),d=a.fromA,f=ve(t,a.toA,c-a.toA)):l>m&&t.slice(a.toA,f)==u.slice(h,h+m)&&(a=e[i]=new j(f-o,f,a.fromB+m,a.toB+m),f=a.toA,d=ye(t,a.fromA,a.fromA-r)),p=a.fromA-d,m=f-a.toA}if(p||m)a=e[i]=new j(a.fromA-p,a.toA+m,a.fromB-p,a.toB+m);else if(!o){let t=xe(n,a.fromB,a.toB),r,o=t<0?-1:be(n,a.toB,a.fromB);t>-1&&(r=t-a.fromB)<=u&&n.slice(a.fromB,t)==n.slice(a.toB,a.toB+r)?a=e[i]=a.offset(r):o>-1&&(r=a.toB-o)<=l&&n.slice(a.fromB-r,a.fromB)==n.slice(o,a.toB)&&(a=e[i]=a.offset(-r))}else if(!s){let n=xe(t,a.fromA,a.toA),r,o=n<0?-1:be(t,a.toA,a.fromA);n>-1&&(r=n-a.fromA)<=u&&t.slice(a.fromA,n)==t.slice(a.toA,a.toA+r)?a=e[i]=a.offset(r):o>-1&&(r=a.toA-o)<=l&&t.slice(a.fromA-r,a.fromA)==t.slice(o,a.toA)&&(a=e[i]=a.offset(-r))}}r=a.toA}return de(e,3),e}var V;try{V=RegExp(`[\\p{Alphabetic}\\p{Number}]`,`u`)}catch{}function me(e){return e>48&&e<58||e>64&&e<91||e>96&&e<123}function he(e,t){if(t==e.length)return 0;let n=e.charCodeAt(t);return n<192?me(n)?1:0:V?!Se(n)||t==e.length-1?V.test(String.fromCharCode(n))?1:0:V.test(e.slice(t,t+2))?2:0:0}function ge(e,t){if(!t)return 0;let n=e.charCodeAt(t-1);return n<192?me(n)?1:0:V?!Ce(n)||t==1?V.test(String.fromCharCode(n))?1:0:V.test(e.slice(t-2,t))?2:0:0}var _e=8;function ve(e,t,n){if(t==e.length||!ge(e,t))return t;for(let r=t,i=t+n,a=0;a<_e;a++){let t=he(e,r);if(!t||r+t>i)return r;r+=t}return t}function ye(e,t,n){if(!t||!he(e,t))return t;for(let r=t,i=t-n,a=0;a<_e;a++){let t=ge(e,r);if(!t||r-t<i)return r;r-=t}return t}function be(e,t,n){for(;t!=n;t--)if(e.charCodeAt(t-1)==10)return t;return-1}function xe(e,t,n){for(;t!=n;t++)if(e.charCodeAt(t)==10)return t;return-1}var Se=e=>e>=55296&&e<=56319,Ce=e=>e>=56320&&e<=57343;function H(e,t){return!t||t==e.length||!Se(e.charCodeAt(t-1))||!Ce(e.charCodeAt(t))}function we(e,t,n){let r=n?.override;return r?r(e,t):(N=(n?.scanLimit??1e9)>>1,P=n?.timeout?Date.now()+n.timeout:0,F=!1,fe(e,t,M(e,0,e.length,t,0,t.length)))}function Te(){return!F}function Ee(e,t,n){return pe(we(e,t,n),e,t)}var U=D.define({combine:e=>e[0]}),De=O.define(),Oe=D.define(),W=_.define({create(e){return null},update(e,t){for(let n of t.effects)n.is(De)&&(e=n.value);for(let n of t.state.facet(Oe))e=n(e,t);return e}}),G=class e{constructor(e,t,n,r,i,a=!0){this.changes=e,this.fromA=t,this.toA=n,this.fromB=r,this.toB=i,this.precise=a}offset(t,n){return t||n?new e(this.changes,this.fromA+t,this.toA+t,this.fromB+n,this.toB+n,this.precise):this}get endA(){return Math.max(this.fromA,this.toA-1)}get endB(){return Math.max(this.fromB,this.toB-1)}static build(e,t,n){return je(Ee(e.toString(),t.toString(),n),e,t,0,0,Te())}static updateA(e,t,n,r,i){return Pe(Ne(e,r,!0,n.length),e,t,n,i)}static updateB(e,t,n,r,i){return Pe(Ne(e,r,!1,t.length),e,t,n,i)}};function ke(e,t,n,r){let i=n.lineAt(e),a=r.lineAt(t);return i.to==e&&a.to==t&&e<n.length&&t<r.length?[e+1,t+1]:[i.from,a.from]}function Ae(e,t,n,r){let i=n.lineAt(e),a=r.lineAt(t);return i.from==e&&a.from==t?[e,t]:[i.to+1,a.to+1]}function je(e,t,n,r,i,a){let o=[];for(let s=0;s<e.length;s++){let c=e[s],[l,u]=ke(c.fromA+r,c.fromB+i,t,n),[d,f]=Ae(c.toA+r,c.toB+i,t,n),p=[c.offset(-l+r,-u+i)];for(;s<e.length-1;){let a=e[s+1],[o,c]=ke(a.fromA+r,a.fromB+i,t,n);if(o>d+1&&c>f+1)break;p.push(a.offset(-l+r,-u+i)),[d,f]=Ae(a.toA+r,a.toB+i,t,n),s++}o.push(new G(p,l,Math.max(l,d),u,Math.max(u,f),a))}return o}var K=1e3;function Me(e,t,n,r){let i=0,a=e.length;for(;;){if(i==a){let r=0,a=0;i&&({toA:r,toB:a}=e[i-1]);let o=t-(n?r:a);return[r+o,a+o]}let o=i+a>>1,s=e[o],[c,l]=n?[s.fromA,s.toA]:[s.fromB,s.toB];if(c>t)a=o;else if(l<=t)i=o+1;else return r?[s.fromA,s.fromB]:[s.toA,s.toB]}}function Ne(e,t,n,r){let i=[];return t.iterChangedRanges((a,o,s,c)=>{let l=0,u=n?t.length:r,d=0,f=n?r:t.length;a>K&&([l,d]=Me(e,a-K,n,!0)),o<t.length-K&&([u,f]=Me(e,o+K,n,!1));let p=c-s-(o-a),m,[h,g]=n?[p,0]:[0,p];i.length&&(m=i[i.length-1]).toA>=l?i[i.length-1]={fromA:m.fromA,fromB:m.fromB,toA:u,toB:f,diffA:m.diffA+h,diffB:m.diffB+g}:i.push({fromA:l,toA:u,fromB:d,toB:f,diffA:h,diffB:g})}),i}function Pe(e,t,n,r,i){if(!e.length)return t;let a=[];for(let o=0,s=0,c=0,l=0;;o++){let u=o==e.length?null:e[o],d=u?u.fromA+s:n.length,f=u?u.fromB+c:r.length;for(;l<t.length;){let e=t[l];if(u&&(e.toA+s>d||e.toB+c>f))break;a.push(e.offset(s,c)),l++}if(!u)break;let p=u.toA+s+u.diffA,m=u.toB+c+u.diffB,h=Ee(n.sliceString(d,p),r.sliceString(f,m),i);for(let e of je(h,n,r,d,f,Te()))a.push(e);for(s+=u.diffA,c+=u.diffB;l<t.length;){let e=t[l];if(e.fromA+s>p&&e.fromB+c>m)break;l++}}return a}var Fe={scanLimit:500},Ie=c.fromClass(class{constructor(e){({deco:this.deco,gutter:this.gutter}=Ge(e))}update(e){(e.docChanged||e.viewportChanged||Le(e.startState,e.state)||Re(e.startState,e.state))&&({deco:this.deco,gutter:this.gutter}=Ge(e.view))}},{decorations:e=>e.deco}),q=b.low(d({class:`cm-changeGutter`,markers:e=>e.plugin(Ie)?.gutter||g.empty}));function Le(e,t){return e.field(W,!1)!=t.field(W,!1)}function Re(e,t){return e.facet(U)!=t.facet(U)}var ze=l.line({class:`cm-changedLine`}),Be=l.mark({class:`cm-changedText`}),Ve=l.mark({tagName:`ins`,class:`cm-insertedLine`}),He=l.mark({tagName:`del`,class:`cm-deletedLine`}),Ue=new class extends S{constructor(){super(...arguments),this.elementClass=`cm-changedLineGutter`}};function We(e,t,n,r,i,a){let o=n?e.fromA:e.fromB,s=n?e.toA:e.toB,c=0;if(o!=s){i.add(o,o,ze),i.add(o,s,n?He:Ve),a&&a.add(o,o,Ue);for(let l=t.iterRange(o,s-1),u=o;!l.next().done;){if(l.lineBreak){u++,i.add(u,u,ze),a&&a.add(u,u,Ue);continue}let t=u+l.value.length;if(r)for(;c<e.changes.length;){let r=e.changes[c],a=o+(n?r.fromA:r.fromB),s=o+(n?r.toA:r.toB),l=Math.max(u,a),d=Math.min(t,s);if(l<d&&i.add(l,d,Be),s<t)c++;else break}u=t}}}function Ge(e){let t=e.state.field(W),{side:n,highlightChanges:r,markGutter:i,overrideChunk:a}=e.state.facet(U),o=n==`a`,s=new T,c=i?new T:null,{from:l,to:u}=e.viewport;for(let n of t){if((o?n.fromA:n.fromB)>=u)break;(o?n.toA:n.toB)>l&&(!a||!a(e.state,n,s,c))&&We(n,e.state.doc,o,r,s,c)}return{deco:s.finish(),gutter:c&&c.finish()}}var J=class extends x{constructor(e){super(),this.height=e}eq(e){return this.height==e.height}toDOM(){let e=document.createElement(`div`);return e.className=`cm-mergeSpacer`,e.style.height=this.height+`px`,e}updateDOM(e){return e.style.height=this.height+`px`,!0}get estimatedHeight(){return this.height}ignoreEvent(){return!1}},Y=O.define({map:(e,t)=>e.map(t)}),X=_.define({create:()=>l.none,update:(e,t)=>{for(let e of t.effects)if(e.is(Y))return e.value;return e.map(t.changes)},provide:e=>f.decorations.from(e)}),Z=.01;function Ke(e,t){if(e.size!=t.size)return!1;let n=e.iter(),r=t.iter();for(;n.value;){if(n.from!=r.from||Math.abs(n.value.spec.widget.height-r.value.spec.widget.height)>1)return!1;n.next(),r.next()}return!0}function qe(e,t,n){let r=new T,i=new T,a=e.state.field(X).iter(),o=t.state.field(X).iter(),s=0,c=0,u=0,d=0,f=e.viewport,p=t.viewport;for(let m=0;;m++){let h=m<n.length?n[m]:null,g=h?h.fromA:e.state.doc.length,_=h?h.fromB:t.state.doc.length;if(s<g){let n=e.lineBlockAt(s).top+u-(t.lineBlockAt(c).top+d);n<-Z?(u-=n,r.add(s,s,l.widget({widget:new J(-n),block:!0,side:-1}))):n>Z&&(d+=n,i.add(c,c,l.widget({widget:new J(n),block:!0,side:-1})))}if(g>s+1e3&&s<f.from&&g>f.from&&c<p.from&&_>p.from){let e=Math.min(f.from-s,p.from-c);s+=e,c+=e,m--}else if(h)s=h.toA,c=h.toB;else break;for(;a.value&&a.from<s;)u-=a.value.spec.widget.height,a.next();for(;o.value&&o.from<c;)d-=o.value.spec.widget.height,o.next()}for(;a.value;)u-=a.value.spec.widget.height,a.next();for(;o.value;)d-=o.value.spec.widget.height,o.next();let m=e.contentHeight+u-(t.contentHeight+d);m<Z?r.add(e.state.doc.length,e.state.doc.length,l.widget({widget:new J(-m),block:!0,side:1})):m>Z&&i.add(t.state.doc.length,t.state.doc.length,l.widget({widget:new J(m),block:!0,side:1}));let h=r.finish(),g=i.finish();Ke(h,e.state.field(X))||e.dispatch({effects:Y.of(h)}),Ke(g,t.state.field(X))||t.dispatch({effects:Y.of(g)})}var Je=O.define({map:(e,t)=>t.mapPos(e)}),Ye=class extends x{constructor(e){super(),this.lines=e}eq(e){return this.lines==e.lines}toDOM(e){let t=document.createElement(`div`);return t.className=`cm-collapsedLines`,t.textContent=e.state.phrase(`$ unchanged lines`,this.lines),t.addEventListener(`click`,t=>{let n=e.posAtDOM(t.target);e.dispatch({effects:Je.of(n)});let{side:r,sibling:i}=e.state.facet(U);i&&i().dispatch({effects:Je.of(Xe(n,e.state.field(W),r==`a`))})}),t}ignoreEvent(e){return e instanceof MouseEvent}get estimatedHeight(){return 27}get type(){return`collapsed-unchanged-code`}};function Xe(e,t,n){let r=0,i=0;for(let a=0;;a++){let o=a<t.length?t[a]:null;if(!o||(n?o.fromA:o.fromB)>=e)return i+(e-r);[r,i]=n?[o.toA,o.toB]:[o.toB,o.toA]}}var Ze=_.define({create(e){return l.none},update(e,t){e=e.map(t.changes);for(let n of t.effects)n.is(Je)&&(e=e.update({filter:e=>e!=n.value}));return e},provide:e=>f.decorations.from(e)});function Qe({margin:e=3,minSize:t=4}){return Ze.init(n=>$e(n,e,t))}function $e(e,t,n){let r=new T,i=e.facet(U).side==`a`,a=e.field(W),o=1;for(let s=0;;s++){let c=s<a.length?a[s]:null,u=s?o+t:1,d=c?e.doc.lineAt(i?c.fromA:c.fromB).number-1-t:e.doc.lines,f=d-u+1;if(f>=n&&r.add(e.doc.line(u).from,e.doc.line(d).to,l.replace({widget:new Ye(f),block:!0})),!c)break;o=e.doc.lineAt(Math.min(e.doc.length,i?c.toA:c.toB)).number}return r.finish()}var et=f.styleModule.of(new m({".cm-mergeView":{overflowY:`auto`},".cm-mergeViewEditors":{display:`flex`,alignItems:`stretch`},".cm-mergeViewEditor":{flexGrow:1,flexBasis:0,overflow:`hidden`},".cm-merge-revert":{width:`1.6em`,flexGrow:0,flexShrink:0,position:`relative`},".cm-merge-revert button":{position:`absolute`,display:`block`,width:`100%`,boxSizing:`border-box`,textAlign:`center`,background:`none`,border:`none`,font:`inherit`,cursor:`pointer`}})),tt=f.baseTheme({".cm-mergeView & .cm-scroller, .cm-mergeView &":{height:`auto !important`,overflowY:`visible !important`},"&.cm-merge-a .cm-changedLine, .cm-deletedChunk":{backgroundColor:`rgba(160, 128, 100, .08)`},"&.cm-merge-b .cm-changedLine, .cm-inlineChangedLine":{backgroundColor:`rgba(100, 160, 128, .08)`},"&light.cm-merge-a .cm-changedText, &light .cm-deletedChunk .cm-deletedText":{background:`linear-gradient(#ee443366, #ee443366) bottom/100% 2px no-repeat`},"&dark.cm-merge-a .cm-changedText, &dark .cm-deletedChunk .cm-deletedText":{background:`linear-gradient(#ffaa9966, #ffaa9966) bottom/100% 2px no-repeat`},"&light.cm-merge-b .cm-changedText":{background:`linear-gradient(#22bb22aa, #22bb22aa) bottom/100% 2px no-repeat`},"&dark.cm-merge-b .cm-changedText":{background:`linear-gradient(#88ff88aa, #88ff88aa) bottom/100% 2px no-repeat`},"&.cm-merge-b .cm-deletedText":{background:`#ff000033`},".cm-insertedLine, .cm-deletedLine, .cm-deletedLine del":{textDecoration:`none`},".cm-deletedChunk":{paddingLeft:`6px`,"& .cm-chunkButtons":{position:`absolute`,insetInlineEnd:`5px`},"& button":{border:`none`,cursor:`pointer`,color:`white`,margin:`0 2px`,borderRadius:`3px`,"&[name=accept]":{background:`#2a2`},"&[name=reject]":{background:`#d43`}}},".cm-collapsedLines":{padding:`5px 5px 5px 10px`,cursor:`pointer`,"&:before":{content:`"⦚"`,marginInlineEnd:`7px`},"&:after":{content:`"⦚"`,marginInlineStart:`7px`}},"&light .cm-collapsedLines":{color:`#444`,background:`linear-gradient(to bottom, transparent 0, #f3f3f3 30%, #f3f3f3 70%, transparent 100%)`},"&dark .cm-collapsedLines":{color:`#ddd`,background:`linear-gradient(to bottom, transparent 0, #222 30%, #222 70%, transparent 100%)`},".cm-changeGutter":{width:`3px`,paddingLeft:`1px`},"&light.cm-merge-a .cm-changedLineGutter, &light .cm-deletedLineGutter":{background:`#e43`},"&dark.cm-merge-a .cm-changedLineGutter, &dark .cm-deletedLineGutter":{background:`#fa9`},"&light.cm-merge-b .cm-changedLineGutter":{background:`#2b2`},"&dark.cm-merge-b .cm-changedLineGutter":{background:`#8f8`},".cm-inlineChangedLineGutter":{background:`#75d`}}),nt=new v,Q=new v,rt=class{constructor(e){this.revertDOM=null,this.revertToA=!1,this.revertToLeft=!1,this.measuring=-1,this.diffConf=e.diffConfig||Fe;let t=[b.low(Ie),tt,et,X,f.updateListener.of(e=>{this.measuring<0&&(e.heightChanged||e.viewportChanged)&&!e.transactions.some(e=>e.effects.some(e=>e.is(Y)))&&this.measure()})],n=[U.of({side:`a`,sibling:()=>this.b,highlightChanges:e.highlightChanges!==!1,markGutter:e.gutter!==!1})];e.gutter!==!1&&n.push(q);let r=ee.create({doc:e.a.doc,selection:e.a.selection,extensions:[e.a.extensions||[],f.editorAttributes.of({class:`cm-merge-a`}),Q.of(n),t]}),i=[U.of({side:`b`,sibling:()=>this.a,highlightChanges:e.highlightChanges!==!1,markGutter:e.gutter!==!1})];e.gutter!==!1&&i.push(q);let a=ee.create({doc:e.b.doc,selection:e.b.selection,extensions:[e.b.extensions||[],f.editorAttributes.of({class:`cm-merge-b`}),Q.of(i),t]});this.chunks=G.build(r.doc,a.doc,this.diffConf);let o=[W.init(()=>this.chunks),nt.of(e.collapseUnchanged?Qe(e.collapseUnchanged):[])];r=r.update({effects:O.appendConfig.of(o)}).state,a=a.update({effects:O.appendConfig.of(o)}).state,this.dom=document.createElement(`div`),this.dom.className=`cm-mergeView`,this.editorDOM=this.dom.appendChild(document.createElement(`div`)),this.editorDOM.className=`cm-mergeViewEditors`;let s=e.orientation||`a-b`,c=document.createElement(`div`);c.className=`cm-mergeViewEditor`;let l=document.createElement(`div`);l.className=`cm-mergeViewEditor`,this.editorDOM.appendChild(s==`a-b`?c:l),this.editorDOM.appendChild(s==`a-b`?l:c),this.a=new f({state:r,parent:c,root:e.root,dispatchTransactions:e=>this.dispatch(e,this.a)}),this.b=new f({state:a,parent:l,root:e.root,dispatchTransactions:e=>this.dispatch(e,this.b)}),this.setupRevertControls(!!e.revertControls,e.revertControls==`b-to-a`,e.renderRevertControl),e.parent&&e.parent.appendChild(this.dom),this.scheduleMeasure()}dispatch(e,t){if(e.some(e=>e.docChanged)){let n=e[e.length-1],r=e.reduce((e,t)=>e.compose(t.changes),p.empty(e[0].startState.doc.length));this.chunks=t==this.a?G.updateA(this.chunks,n.newDoc,this.b.state.doc,r,this.diffConf):G.updateB(this.chunks,this.a.state.doc,n.newDoc,r,this.diffConf),t.update([...e,n.state.update({effects:De.of(this.chunks)})]);let i=t==this.a?this.b:this.a;i.update([i.state.update({effects:De.of(this.chunks)})]),this.scheduleMeasure()}else t.update(e)}reconfigure(e){if(`diffConfig`in e&&(this.diffConf=e.diffConfig),`orientation`in e){let t=e.orientation!=`b-a`;if(t!=(this.editorDOM.firstChild==this.a.dom.parentNode)){let e=this.a.dom.parentNode,n=this.b.dom.parentNode;e.remove(),n.remove(),this.editorDOM.insertBefore(t?e:n,this.editorDOM.firstChild),this.editorDOM.appendChild(t?n:e),this.revertToLeft=!this.revertToLeft,this.revertDOM&&(this.revertDOM.textContent=``)}}if(`revertControls`in e||`renderRevertControl`in e){let t=!!this.revertDOM,n=this.revertToA,r=this.renderRevert;`revertControls`in e&&(t=!!e.revertControls,n=e.revertControls==`b-to-a`),`renderRevertControl`in e&&(r=e.renderRevertControl),this.setupRevertControls(t,n,r)}let t=`highlightChanges`in e,n=`gutter`in e,r=`collapseUnchanged`in e;if(t||n||r){let i=[],a=[];if(t||n){let r=this.a.state.facet(U),o=n?e.gutter!==!1:r.markGutter,s=t?e.highlightChanges!==!1:r.highlightChanges;i.push(Q.reconfigure([U.of({side:`a`,sibling:()=>this.b,highlightChanges:s,markGutter:o}),o?q:[]])),a.push(Q.reconfigure([U.of({side:`b`,sibling:()=>this.a,highlightChanges:s,markGutter:o}),o?q:[]]))}if(r){let t=nt.reconfigure(e.collapseUnchanged?Qe(e.collapseUnchanged):[]);i.push(t),a.push(t)}this.a.dispatch({effects:i}),this.b.dispatch({effects:a})}this.scheduleMeasure()}setupRevertControls(e,t,n){this.revertToA=t,this.revertToLeft=this.revertToA==(this.editorDOM.firstChild==this.a.dom.parentNode),this.renderRevert=n,!e&&this.revertDOM?(this.revertDOM.remove(),this.revertDOM=null):e&&!this.revertDOM?(this.revertDOM=this.editorDOM.insertBefore(document.createElement(`div`),this.editorDOM.firstChild.nextSibling),this.revertDOM.addEventListener(`mousedown`,e=>this.revertClicked(e)),this.revertDOM.className=`cm-merge-revert`):this.revertDOM&&(this.revertDOM.textContent=``)}scheduleMeasure(){this.measuring<0&&(this.measuring=(this.dom.ownerDocument.defaultView||window).requestAnimationFrame(()=>{this.measuring=-1,this.measure()}))}measure(){qe(this.a,this.b,this.chunks),this.revertDOM&&this.updateRevertButtons()}updateRevertButtons(){let e=this.revertDOM,t=e.firstChild,n=this.a.viewport,r=this.b.viewport;for(let i=0;i<this.chunks.length;i++){let a=this.chunks[i];if(a.fromA>n.to||a.fromB>r.to)break;if(a.fromA<n.from||a.fromB<r.from)continue;let o=this.a.lineBlockAt(a.fromA).top+`px`;for(;t&&+t.dataset.chunk<i;)t=it(t);t&&t.dataset.chunk==String(i)?(t.style.top!=o&&(t.style.top=o),t=t.nextSibling):e.insertBefore(this.renderRevertButton(o,i),t)}for(;t;)t=it(t)}renderRevertButton(e,t){let n;if(this.renderRevert)n=this.renderRevert();else{n=document.createElement(`button`);let e=this.a.state.phrase(`Revert this chunk`);n.setAttribute(`aria-label`,e),n.setAttribute(`title`,e),n.textContent=this.revertToLeft?`⇜`:`⇝`}return n.style.top=e,n.setAttribute(`data-chunk`,String(t)),n}revertClicked(e){let t=e.target,n;for(;t&&t.parentNode!=this.revertDOM;)t=t.parentNode;if(t&&(n=this.chunks[t.dataset.chunk])){let[t,r,i,a,o,s]=this.revertToA?[this.b,this.a,n.fromB,n.toB,n.fromA,n.toA]:[this.a,this.b,n.fromA,n.toA,n.fromB,n.toB],c=t.state.sliceDoc(i,Math.max(i,a-1));i!=a&&s<=r.state.doc.length&&(c+=t.state.lineBreak),r.dispatch({changes:{from:o,to:Math.min(r.state.doc.length,s),insert:c},userEvent:`revert`}),e.preventDefault()}}destroy(){this.a.destroy(),this.b.destroy(),this.measuring>-1&&(this.dom.ownerDocument.defaultView||window).cancelAnimationFrame(this.measuring),this.dom.remove()}};function it(e){let t=e.nextSibling;return e.remove(),t}var $=r();function at(e){switch(e.split(`.`).pop()?.toLowerCase()??``){case`js`:case`jsx`:return w({jsx:!0});case`ts`:case`tsx`:return w({jsx:!0,typescript:!0});case`py`:return h();case`html`:return E();case`css`:case`scss`:return y();case`json`:return C();case`md`:case`mdx`:return k();default:return null}}function ot({metadata:e}){let t=e?.filePath,n=e?.projectName,r=e?.ref1,c=e?.ref2,l=e?.file1,d=e?.file2,p=!!(l&&d),[m,h]=(0,A.useState)(null),[g,_]=(0,A.useState)(null),[v,y]=(0,A.useState)(!0),[b,x]=(0,A.useState)(null),[S,C]=(0,A.useState)(`both`),w=(0,A.useRef)(null),T=(0,A.useRef)(null);(0,A.useEffect)(()=>{if(!n)return;if(y(!0),x(null),l&&d){let e=new URLSearchParams;e.set(`file1`,l),e.set(`file2`,d),a.get(`${i(n)}/files/compare?${e.toString()}`).then(e=>{_(e),y(!1)}).catch(e=>{x(e instanceof Error?e.message:`Failed to compare files`),y(!1)});return}let e;if(t){let a=new URLSearchParams;a.set(`file`,t),r&&a.set(`ref`,r),e=`${i(n)}/git/file-diff?${a.toString()}`}else if(r||c){let t=new URLSearchParams;r&&t.set(`ref1`,r),c&&t.set(`ref2`,c),e=`${i(n)}/git/diff?${t.toString()}`}else e=`${i(n)}/git/diff`;a.get(e).then(e=>{h(e.diff),y(!1)}).catch(e=>{x(e instanceof Error?e.message:`Failed to load diff`),y(!1)})},[t,n,r,c,l,d]);let{original:E,modified:D}=(0,A.useMemo)(()=>p&&g?g:m?st(m):{original:``,modified:``},[m,p,g]),O=(0,A.useMemo)(()=>{let e=t??d??l;if(!e)return[];let n=at(e);return n?[n]:[]},[t,l,d]);if((0,A.useEffect)(()=>{let e=w.current;if(!e||v||b||!E&&!D)return;T.current&&=(T.current.destroy(),null),window.innerWidth;let t=[...O,te,f.editable.of(!1),ee.readOnly.of(!0),u(),f.theme({"&":{fontSize:`13px`,fontFamily:`var(--font-mono)`},"& .cm-changedText":{textDecoration:`none !important`,borderBottom:`none !important`,textDecorationLine:`none !important`,backgroundColor:`rgba(16, 185, 129, 0.4) !important`,borderRadius:`2px`},"& .cm-deletedChunk .cm-changedText":{backgroundColor:`rgba(239, 68, 68, 0.4) !important`}})],n=new rt({parent:e,a:{doc:E,extensions:t},b:{doc:D,extensions:t},orientation:`a-b`,revertControls:void 0,highlightChanges:!0,gutter:!0});T.current=n;let r=n.a.dom.querySelector(`.cm-scroller`),i=n.b.dom.querySelector(`.cm-scroller`),a=!1,o=(e,t)=>{a||=(a=!0,t.scrollLeft=e.scrollLeft,!1)},s=()=>r&&i&&o(r,i),c=()=>r&&i&&o(i,r);return r?.addEventListener(`scroll`,s),i?.addEventListener(`scroll`,c),()=>{r?.removeEventListener(`scroll`,s),i?.removeEventListener(`scroll`,c),n.destroy(),T.current=null}},[E,D,O,v,b]),(0,A.useEffect)(()=>{let e=T.current;if(!e)return;let t=e.a.dom.closest(`.cm-mergeViewEditor`)??e.a.dom.parentElement,n=e.b.dom.closest(`.cm-mergeViewEditor`)??e.b.dom.parentElement,r=w.current?.querySelector(`.cm-mergeViewGutter`);t&&(t.style.display=S===`right`?`none`:``,t.style.flex=S===`left`?`1`:``),n&&(n.style.display=S===`left`?`none`:``,n.style.flex=S===`right`?`1`:``),r&&(r.style.display=S===`both`?``:`none`)},[S,E,D]),!n)return(0,$.jsx)(`div`,{className:`flex items-center justify-center h-full text-muted-foreground text-sm`,children:`No project selected.`});if(v)return(0,$.jsxs)(`div`,{className:`flex items-center justify-center h-full gap-2 text-muted-foreground`,children:[(0,$.jsx)(s,{className:`size-5 animate-spin`}),(0,$.jsx)(`span`,{className:`text-sm`,children:`Loading diff...`})]});if(b)return(0,$.jsx)(`div`,{className:`flex items-center justify-center h-full text-destructive text-sm`,children:b});if(!p&&(!m||m.trim()===``)&&!E&&!D)return(0,$.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full gap-2 text-muted-foreground`,children:[(0,$.jsx)(o,{className:`size-8`}),(0,$.jsx)(`p`,{className:`text-sm`,children:`No changes detected`}),t&&(0,$.jsx)(`p`,{className:`text-xs font-mono`,children:t})]});let k=(0,$.jsxs)(`div`,{className:`flex items-center gap-0.5 shrink-0`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:()=>C(S===`left`?`both`:`left`),className:`p-1 rounded hover:bg-muted transition-colors ${S===`left`?`bg-muted text-foreground`:``}`,title:`Expand original`,children:(0,$.jsx)(re,{className:`size-3.5`})}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>C(`both`),className:`p-1 rounded hover:bg-muted transition-colors ${S===`both`?`bg-muted text-foreground`:``}`,title:`Side by side`,children:(0,$.jsx)(ne,{className:`size-3.5`})}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>C(S===`right`?`both`:`right`),className:`p-1 rounded hover:bg-muted transition-colors ${S===`right`?`bg-muted text-foreground`:``}`,title:`Expand modified`,children:(0,$.jsx)(ie,{className:`size-3.5`})})]});return(0,$.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-1.5 border-b text-xs text-muted-foreground`,children:[(0,$.jsx)(o,{className:`size-3.5`}),p?(0,$.jsxs)(`span`,{className:`font-mono truncate flex-1`,children:[l,` vs `,d]}):(0,$.jsxs)(`span`,{className:`flex-1 truncate`,children:[(0,$.jsx)(`span`,{className:`font-mono`,children:t??`Working tree changes`}),(r||c)&&(0,$.jsxs)(`span`,{children:[` (`,r?.slice(0,7)??`HEAD`,` vs `,c?.slice(0,7)??`working tree`,`)`]})]}),(0,$.jsx)(`div`,{className:`hidden md:block`,children:k})]}),(0,$.jsx)(`div`,{ref:w,className:`flex-1 overflow-auto touch-pinch-zoom [&_.cm-mergeView]:h-full`,style:{WebkitOverflowScrolling:`touch`}}),(0,$.jsx)(`div`,{className:`md:hidden flex justify-center border-t py-1 bg-background shrink-0`,children:k})]})}function st(e){let t=e.split(`
1
+ import{a as e,n as t,r as n,t as r}from"./jsx-runtime-BFALxl05.js";import{r as i,t as a}from"./api-client-BgVufYKf.js";import{C as o,_ as s}from"./index-DasstYgw.js";import{A as c,E as l,H as u,I as d,O as f,Q as p,Y as m,a as h,at as g,ct as _,et as v,i as y,it as b,j as x,k as S,n as C,nt as ee,o as w,ot as T,r as E,rt as D,s as te,st as O,t as k}from"./dist-CBiGQxfr.js";var ne=t(`columns-2`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M12 3v18`,key:`108xh3`}]]),re=t(`panel-left-open`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}],[`path`,{d:`m14 9 3 3-3 3`,key:`8010ee`}]]),ie=t(`panel-right-open`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M15 3v18`,key:`14nvp0`}],[`path`,{d:`m10 15-3-3 3-3`,key:`1pgupc`}]]),A=e(n(),1),j=class e{constructor(e,t,n,r){this.fromA=e,this.toA=t,this.fromB=n,this.toB=r}offset(t,n=t){return new e(this.fromA+t,this.toA+t,this.fromB+n,this.toB+n)}};function M(e,t,n,r,i,a){if(e==r)return[];let o=R(e,t,n,r,i,a),s=z(e,t+o,n,r,i+o,a);t+=o,n-=s,i+=o,a-=s;let c=n-t,l=a-i;if(!c||!l)return[new j(t,n,i,a)];if(c>l){let o=e.slice(t,n).indexOf(r.slice(i,a));if(o>-1)return[new j(t,t+o,i,i),new j(t+o+l,n,a,a)]}else if(l>c){let o=r.slice(i,a).indexOf(e.slice(t,n));if(o>-1)return[new j(t,t,i,i+o),new j(n,n,i+o+c,a)]}if(c==1||l==1)return[new j(t,n,i,a)];let u=le(e,t,n,r,i,a);if(u){let[o,s,c]=u;return M(e,t,o,r,i,s).concat(M(e,o+c,n,r,s+c,a))}return ae(e,t,n,r,i,a)}var N=1e9,P=0,F=!1;function ae(e,t,n,r,i,a){let o=n-t,s=a-i;if(N<1e9&&Math.min(o,s)>N*16||P>0&&Date.now()>P)return Math.min(o,s)>N*64?[new j(t,n,i,a)]:ue(e,t,n,r,i,a);let c=Math.ceil((o+s)/2);I.reset(c),L.reset(c);let l=(n,a)=>e.charCodeAt(t+n)==r.charCodeAt(i+a),u=(t,i)=>e.charCodeAt(n-t-1)==r.charCodeAt(a-i-1),d=(o-s)%2==0?null:L,f=d?null:I;for(let p=0;p<c;p++){if(p>N||P>0&&!(p&63)&&Date.now()>P)return ue(e,t,n,r,i,a);let m=I.advance(p,o,s,c,d,!1,l)||L.advance(p,o,s,c,f,!0,u);if(m)return se(e,t,n,t+m[0],r,i,a,i+m[1])}return[new j(t,n,i,a)]}var oe=class{constructor(){this.vec=[]}reset(e){this.len=e<<1;for(let e=0;e<this.len;e++)this.vec[e]=-1;this.vec[e+1]=0,this.start=this.end=0}advance(e,t,n,r,i,a,o){for(let s=-e+this.start;s<=e-this.end;s+=2){let c=r+s,l=s==-e||s!=e&&this.vec[c-1]<this.vec[c+1]?this.vec[c+1]:this.vec[c-1]+1,u=l-s;for(;l<t&&u<n&&o(l,u);)l++,u++;if(this.vec[c]=l,l>t)this.end+=2;else if(u>n)this.start+=2;else if(i){let e=r+(t-n)-s;if(e>=0&&e<this.len&&i.vec[e]!=-1)if(a){let n=i.vec[e];if(n>=t-l)return[n,r+n-e]}else{let n=t-i.vec[e];if(l>=n)return[l,u]}}}return null}},I=new oe,L=new oe;function se(e,t,n,r,i,a,o,s){let c=!1;return!H(e,r)&&++r==n&&(c=!0),!H(i,s)&&++s==o&&(c=!0),c?[new j(t,n,a,o)]:M(e,t,r,i,a,s).concat(M(e,r,n,i,s,o))}function ce(e,t){let n=1,r=Math.min(e,t);for(;n<r;)n<<=1;return n}function R(e,t,n,r,i,a){if(t==n||t==a||e.charCodeAt(t)!=r.charCodeAt(i))return 0;let o=ce(n-t,a-i);for(let s=t,c=i;;){let i=s+o,l=c+o;if(i>n||l>a||e.slice(s,i)!=r.slice(c,l)){if(o==1)return s-t-(H(e,s)?0:1);o>>=1}else if(i==n||l==a)return i-t;else s=i,c=l}}function z(e,t,n,r,i,a){if(t==n||i==a||e.charCodeAt(n-1)!=r.charCodeAt(a-1))return 0;let o=ce(n-t,a-i);for(let s=n,c=a;;){let a=s-o,l=c-o;if(a<t||l<i||e.slice(a,s)!=r.slice(l,c)){if(o==1)return n-s-(H(e,s)?0:1);o>>=1}else if(a==t||l==i)return n-a;else s=a,c=l}}function B(e,t,n,r,i,a,o,s){let c=r.slice(i,a),l=null;for(;;){if(l||o<s)return l;for(let s=t+o;;){H(e,s)||s++;let u=s+o;if(H(e,u)||(u+=u==s+1?1:-1),u>=n)break;let d=e.slice(s,u),f=-1;for(;(f=c.indexOf(d,f+1))!=-1;){let o=R(e,u,n,r,i+f+d.length,a),c=z(e,t,s,r,i,i+f),p=d.length+o+c;(!l||l[2]<p)&&(l=[s-c,i+f-c,p])}s=u}if(s<0)return l;o>>=1}}function le(e,t,n,r,i,a){let o=n-t,s=a-i;if(o<s){let o=le(r,i,a,e,t,n);return o&&[o[1],o[0],o[2]]}return o<4||s*2<o?null:B(e,t,n,r,i,a,Math.floor(o/4),-1)}function ue(e,t,n,r,i,a){F=!0;let o=n-t,s=a-i,c;if(o<s){let s=B(r,i,a,e,t,n,Math.floor(o/6),50);c=s&&[s[1],s[0],s[2]]}else c=B(e,t,n,r,i,a,Math.floor(s/6),50);if(!c)return[new j(t,n,i,a)];let[l,u,d]=c;return M(e,t,l,r,i,u).concat(M(e,l+d,n,r,u+d,a))}function de(e,t){for(let n=1;n<e.length;n++){let r=e[n-1],i=e[n];r.toA>i.fromA-t&&r.toB>i.fromB-t&&(e[n-1]=new j(r.fromA,i.toA,r.fromB,i.toB),e.splice(n--,1))}}function fe(e,t,n){for(;;){de(n,1);let r=!1;for(let i=0;i<n.length;i++){let a=n[i],o,s;(o=R(e,a.fromA,a.toA,t,a.fromB,a.toB))&&(a=n[i]=new j(a.fromA+o,a.toA,a.fromB+o,a.toB)),(s=z(e,a.fromA,a.toA,t,a.fromB,a.toB))&&(a=n[i]=new j(a.fromA,a.toA-s,a.fromB,a.toB-s));let c=a.toA-a.fromA,l=a.toB-a.fromB;if(c&&l)continue;let u=a.fromA-(i?n[i-1].toA:0),d=(i<n.length-1?n[i+1].fromA:e.length)-a.toA;if(!u||!d)continue;let f=c?e.slice(a.fromA,a.toA):t.slice(a.fromB,a.toB);u<=f.length&&e.slice(a.fromA-u,a.fromA)==f.slice(f.length-u)?(n[i]=new j(a.fromA-u,a.toA-u,a.fromB-u,a.toB-u),r=!0):d<=f.length&&e.slice(a.toA,a.toA+d)==f.slice(0,d)&&(n[i]=new j(a.fromA+d,a.toA+d,a.fromB+d,a.toB+d),r=!0)}if(!r)break}return n}function pe(e,t,n){for(let r=0,i=0;i<e.length;i++){let a=e[i],o=a.toA-a.fromA,s=a.toB-a.fromB;if(o&&s||o>3||s>3){let c=i==e.length-1?t.length:e[i+1].fromA,l=a.fromA-r,u=c-a.toA,d=ye(t,a.fromA,l),f=ve(t,a.toA,u),p=a.fromA-d,m=f-a.toA;if((!o||!s)&&p&&m){let l=Math.max(o,s),[u,h,g]=o?[t,a.fromA,a.toA]:[n,a.fromB,a.toB];l>p&&t.slice(d,a.fromA)==u.slice(g-p,g)?(a=e[i]=new j(d,d+o,a.fromB-p,a.toB-p),d=a.fromA,f=ve(t,a.toA,c-a.toA)):l>m&&t.slice(a.toA,f)==u.slice(h,h+m)&&(a=e[i]=new j(f-o,f,a.fromB+m,a.toB+m),f=a.toA,d=ye(t,a.fromA,a.fromA-r)),p=a.fromA-d,m=f-a.toA}if(p||m)a=e[i]=new j(a.fromA-p,a.toA+m,a.fromB-p,a.toB+m);else if(!o){let t=xe(n,a.fromB,a.toB),r,o=t<0?-1:be(n,a.toB,a.fromB);t>-1&&(r=t-a.fromB)<=u&&n.slice(a.fromB,t)==n.slice(a.toB,a.toB+r)?a=e[i]=a.offset(r):o>-1&&(r=a.toB-o)<=l&&n.slice(a.fromB-r,a.fromB)==n.slice(o,a.toB)&&(a=e[i]=a.offset(-r))}else if(!s){let n=xe(t,a.fromA,a.toA),r,o=n<0?-1:be(t,a.toA,a.fromA);n>-1&&(r=n-a.fromA)<=u&&t.slice(a.fromA,n)==t.slice(a.toA,a.toA+r)?a=e[i]=a.offset(r):o>-1&&(r=a.toA-o)<=l&&t.slice(a.fromA-r,a.fromA)==t.slice(o,a.toA)&&(a=e[i]=a.offset(-r))}}r=a.toA}return de(e,3),e}var V;try{V=RegExp(`[\\p{Alphabetic}\\p{Number}]`,`u`)}catch{}function me(e){return e>48&&e<58||e>64&&e<91||e>96&&e<123}function he(e,t){if(t==e.length)return 0;let n=e.charCodeAt(t);return n<192?me(n)?1:0:V?!Se(n)||t==e.length-1?V.test(String.fromCharCode(n))?1:0:V.test(e.slice(t,t+2))?2:0:0}function ge(e,t){if(!t)return 0;let n=e.charCodeAt(t-1);return n<192?me(n)?1:0:V?!Ce(n)||t==1?V.test(String.fromCharCode(n))?1:0:V.test(e.slice(t-2,t))?2:0:0}var _e=8;function ve(e,t,n){if(t==e.length||!ge(e,t))return t;for(let r=t,i=t+n,a=0;a<_e;a++){let t=he(e,r);if(!t||r+t>i)return r;r+=t}return t}function ye(e,t,n){if(!t||!he(e,t))return t;for(let r=t,i=t-n,a=0;a<_e;a++){let t=ge(e,r);if(!t||r-t<i)return r;r-=t}return t}function be(e,t,n){for(;t!=n;t--)if(e.charCodeAt(t-1)==10)return t;return-1}function xe(e,t,n){for(;t!=n;t++)if(e.charCodeAt(t)==10)return t;return-1}var Se=e=>e>=55296&&e<=56319,Ce=e=>e>=56320&&e<=57343;function H(e,t){return!t||t==e.length||!Se(e.charCodeAt(t-1))||!Ce(e.charCodeAt(t))}function we(e,t,n){let r=n?.override;return r?r(e,t):(N=(n?.scanLimit??1e9)>>1,P=n?.timeout?Date.now()+n.timeout:0,F=!1,fe(e,t,M(e,0,e.length,t,0,t.length)))}function Te(){return!F}function Ee(e,t,n){return pe(we(e,t,n),e,t)}var U=D.define({combine:e=>e[0]}),De=O.define(),Oe=D.define(),W=_.define({create(e){return null},update(e,t){for(let n of t.effects)n.is(De)&&(e=n.value);for(let n of t.state.facet(Oe))e=n(e,t);return e}}),G=class e{constructor(e,t,n,r,i,a=!0){this.changes=e,this.fromA=t,this.toA=n,this.fromB=r,this.toB=i,this.precise=a}offset(t,n){return t||n?new e(this.changes,this.fromA+t,this.toA+t,this.fromB+n,this.toB+n,this.precise):this}get endA(){return Math.max(this.fromA,this.toA-1)}get endB(){return Math.max(this.fromB,this.toB-1)}static build(e,t,n){return je(Ee(e.toString(),t.toString(),n),e,t,0,0,Te())}static updateA(e,t,n,r,i){return Pe(Ne(e,r,!0,n.length),e,t,n,i)}static updateB(e,t,n,r,i){return Pe(Ne(e,r,!1,t.length),e,t,n,i)}};function ke(e,t,n,r){let i=n.lineAt(e),a=r.lineAt(t);return i.to==e&&a.to==t&&e<n.length&&t<r.length?[e+1,t+1]:[i.from,a.from]}function Ae(e,t,n,r){let i=n.lineAt(e),a=r.lineAt(t);return i.from==e&&a.from==t?[e,t]:[i.to+1,a.to+1]}function je(e,t,n,r,i,a){let o=[];for(let s=0;s<e.length;s++){let c=e[s],[l,u]=ke(c.fromA+r,c.fromB+i,t,n),[d,f]=Ae(c.toA+r,c.toB+i,t,n),p=[c.offset(-l+r,-u+i)];for(;s<e.length-1;){let a=e[s+1],[o,c]=ke(a.fromA+r,a.fromB+i,t,n);if(o>d+1&&c>f+1)break;p.push(a.offset(-l+r,-u+i)),[d,f]=Ae(a.toA+r,a.toB+i,t,n),s++}o.push(new G(p,l,Math.max(l,d),u,Math.max(u,f),a))}return o}var K=1e3;function Me(e,t,n,r){let i=0,a=e.length;for(;;){if(i==a){let r=0,a=0;i&&({toA:r,toB:a}=e[i-1]);let o=t-(n?r:a);return[r+o,a+o]}let o=i+a>>1,s=e[o],[c,l]=n?[s.fromA,s.toA]:[s.fromB,s.toB];if(c>t)a=o;else if(l<=t)i=o+1;else return r?[s.fromA,s.fromB]:[s.toA,s.toB]}}function Ne(e,t,n,r){let i=[];return t.iterChangedRanges((a,o,s,c)=>{let l=0,u=n?t.length:r,d=0,f=n?r:t.length;a>K&&([l,d]=Me(e,a-K,n,!0)),o<t.length-K&&([u,f]=Me(e,o+K,n,!1));let p=c-s-(o-a),m,[h,g]=n?[p,0]:[0,p];i.length&&(m=i[i.length-1]).toA>=l?i[i.length-1]={fromA:m.fromA,fromB:m.fromB,toA:u,toB:f,diffA:m.diffA+h,diffB:m.diffB+g}:i.push({fromA:l,toA:u,fromB:d,toB:f,diffA:h,diffB:g})}),i}function Pe(e,t,n,r,i){if(!e.length)return t;let a=[];for(let o=0,s=0,c=0,l=0;;o++){let u=o==e.length?null:e[o],d=u?u.fromA+s:n.length,f=u?u.fromB+c:r.length;for(;l<t.length;){let e=t[l];if(u&&(e.toA+s>d||e.toB+c>f))break;a.push(e.offset(s,c)),l++}if(!u)break;let p=u.toA+s+u.diffA,m=u.toB+c+u.diffB,h=Ee(n.sliceString(d,p),r.sliceString(f,m),i);for(let e of je(h,n,r,d,f,Te()))a.push(e);for(s+=u.diffA,c+=u.diffB;l<t.length;){let e=t[l];if(e.fromA+s>p&&e.fromB+c>m)break;l++}}return a}var Fe={scanLimit:500},Ie=c.fromClass(class{constructor(e){({deco:this.deco,gutter:this.gutter}=Ge(e))}update(e){(e.docChanged||e.viewportChanged||Le(e.startState,e.state)||Re(e.startState,e.state))&&({deco:this.deco,gutter:this.gutter}=Ge(e.view))}},{decorations:e=>e.deco}),q=b.low(d({class:`cm-changeGutter`,markers:e=>e.plugin(Ie)?.gutter||g.empty}));function Le(e,t){return e.field(W,!1)!=t.field(W,!1)}function Re(e,t){return e.facet(U)!=t.facet(U)}var ze=l.line({class:`cm-changedLine`}),Be=l.mark({class:`cm-changedText`}),Ve=l.mark({tagName:`ins`,class:`cm-insertedLine`}),He=l.mark({tagName:`del`,class:`cm-deletedLine`}),Ue=new class extends S{constructor(){super(...arguments),this.elementClass=`cm-changedLineGutter`}};function We(e,t,n,r,i,a){let o=n?e.fromA:e.fromB,s=n?e.toA:e.toB,c=0;if(o!=s){i.add(o,o,ze),i.add(o,s,n?He:Ve),a&&a.add(o,o,Ue);for(let l=t.iterRange(o,s-1),u=o;!l.next().done;){if(l.lineBreak){u++,i.add(u,u,ze),a&&a.add(u,u,Ue);continue}let t=u+l.value.length;if(r)for(;c<e.changes.length;){let r=e.changes[c],a=o+(n?r.fromA:r.fromB),s=o+(n?r.toA:r.toB),l=Math.max(u,a),d=Math.min(t,s);if(l<d&&i.add(l,d,Be),s<t)c++;else break}u=t}}}function Ge(e){let t=e.state.field(W),{side:n,highlightChanges:r,markGutter:i,overrideChunk:a}=e.state.facet(U),o=n==`a`,s=new T,c=i?new T:null,{from:l,to:u}=e.viewport;for(let n of t){if((o?n.fromA:n.fromB)>=u)break;(o?n.toA:n.toB)>l&&(!a||!a(e.state,n,s,c))&&We(n,e.state.doc,o,r,s,c)}return{deco:s.finish(),gutter:c&&c.finish()}}var J=class extends x{constructor(e){super(),this.height=e}eq(e){return this.height==e.height}toDOM(){let e=document.createElement(`div`);return e.className=`cm-mergeSpacer`,e.style.height=this.height+`px`,e}updateDOM(e){return e.style.height=this.height+`px`,!0}get estimatedHeight(){return this.height}ignoreEvent(){return!1}},Y=O.define({map:(e,t)=>e.map(t)}),X=_.define({create:()=>l.none,update:(e,t)=>{for(let e of t.effects)if(e.is(Y))return e.value;return e.map(t.changes)},provide:e=>f.decorations.from(e)}),Z=.01;function Ke(e,t){if(e.size!=t.size)return!1;let n=e.iter(),r=t.iter();for(;n.value;){if(n.from!=r.from||Math.abs(n.value.spec.widget.height-r.value.spec.widget.height)>1)return!1;n.next(),r.next()}return!0}function qe(e,t,n){let r=new T,i=new T,a=e.state.field(X).iter(),o=t.state.field(X).iter(),s=0,c=0,u=0,d=0,f=e.viewport,p=t.viewport;for(let m=0;;m++){let h=m<n.length?n[m]:null,g=h?h.fromA:e.state.doc.length,_=h?h.fromB:t.state.doc.length;if(s<g){let n=e.lineBlockAt(s).top+u-(t.lineBlockAt(c).top+d);n<-Z?(u-=n,r.add(s,s,l.widget({widget:new J(-n),block:!0,side:-1}))):n>Z&&(d+=n,i.add(c,c,l.widget({widget:new J(n),block:!0,side:-1})))}if(g>s+1e3&&s<f.from&&g>f.from&&c<p.from&&_>p.from){let e=Math.min(f.from-s,p.from-c);s+=e,c+=e,m--}else if(h)s=h.toA,c=h.toB;else break;for(;a.value&&a.from<s;)u-=a.value.spec.widget.height,a.next();for(;o.value&&o.from<c;)d-=o.value.spec.widget.height,o.next()}for(;a.value;)u-=a.value.spec.widget.height,a.next();for(;o.value;)d-=o.value.spec.widget.height,o.next();let m=e.contentHeight+u-(t.contentHeight+d);m<Z?r.add(e.state.doc.length,e.state.doc.length,l.widget({widget:new J(-m),block:!0,side:1})):m>Z&&i.add(t.state.doc.length,t.state.doc.length,l.widget({widget:new J(m),block:!0,side:1}));let h=r.finish(),g=i.finish();Ke(h,e.state.field(X))||e.dispatch({effects:Y.of(h)}),Ke(g,t.state.field(X))||t.dispatch({effects:Y.of(g)})}var Je=O.define({map:(e,t)=>t.mapPos(e)}),Ye=class extends x{constructor(e){super(),this.lines=e}eq(e){return this.lines==e.lines}toDOM(e){let t=document.createElement(`div`);return t.className=`cm-collapsedLines`,t.textContent=e.state.phrase(`$ unchanged lines`,this.lines),t.addEventListener(`click`,t=>{let n=e.posAtDOM(t.target);e.dispatch({effects:Je.of(n)});let{side:r,sibling:i}=e.state.facet(U);i&&i().dispatch({effects:Je.of(Xe(n,e.state.field(W),r==`a`))})}),t}ignoreEvent(e){return e instanceof MouseEvent}get estimatedHeight(){return 27}get type(){return`collapsed-unchanged-code`}};function Xe(e,t,n){let r=0,i=0;for(let a=0;;a++){let o=a<t.length?t[a]:null;if(!o||(n?o.fromA:o.fromB)>=e)return i+(e-r);[r,i]=n?[o.toA,o.toB]:[o.toB,o.toA]}}var Ze=_.define({create(e){return l.none},update(e,t){e=e.map(t.changes);for(let n of t.effects)n.is(Je)&&(e=e.update({filter:e=>e!=n.value}));return e},provide:e=>f.decorations.from(e)});function Qe({margin:e=3,minSize:t=4}){return Ze.init(n=>$e(n,e,t))}function $e(e,t,n){let r=new T,i=e.facet(U).side==`a`,a=e.field(W),o=1;for(let s=0;;s++){let c=s<a.length?a[s]:null,u=s?o+t:1,d=c?e.doc.lineAt(i?c.fromA:c.fromB).number-1-t:e.doc.lines,f=d-u+1;if(f>=n&&r.add(e.doc.line(u).from,e.doc.line(d).to,l.replace({widget:new Ye(f),block:!0})),!c)break;o=e.doc.lineAt(Math.min(e.doc.length,i?c.toA:c.toB)).number}return r.finish()}var et=f.styleModule.of(new m({".cm-mergeView":{overflowY:`auto`},".cm-mergeViewEditors":{display:`flex`,alignItems:`stretch`},".cm-mergeViewEditor":{flexGrow:1,flexBasis:0,overflow:`hidden`},".cm-merge-revert":{width:`1.6em`,flexGrow:0,flexShrink:0,position:`relative`},".cm-merge-revert button":{position:`absolute`,display:`block`,width:`100%`,boxSizing:`border-box`,textAlign:`center`,background:`none`,border:`none`,font:`inherit`,cursor:`pointer`}})),tt=f.baseTheme({".cm-mergeView & .cm-scroller, .cm-mergeView &":{height:`auto !important`,overflowY:`visible !important`},"&.cm-merge-a .cm-changedLine, .cm-deletedChunk":{backgroundColor:`rgba(160, 128, 100, .08)`},"&.cm-merge-b .cm-changedLine, .cm-inlineChangedLine":{backgroundColor:`rgba(100, 160, 128, .08)`},"&light.cm-merge-a .cm-changedText, &light .cm-deletedChunk .cm-deletedText":{background:`linear-gradient(#ee443366, #ee443366) bottom/100% 2px no-repeat`},"&dark.cm-merge-a .cm-changedText, &dark .cm-deletedChunk .cm-deletedText":{background:`linear-gradient(#ffaa9966, #ffaa9966) bottom/100% 2px no-repeat`},"&light.cm-merge-b .cm-changedText":{background:`linear-gradient(#22bb22aa, #22bb22aa) bottom/100% 2px no-repeat`},"&dark.cm-merge-b .cm-changedText":{background:`linear-gradient(#88ff88aa, #88ff88aa) bottom/100% 2px no-repeat`},"&.cm-merge-b .cm-deletedText":{background:`#ff000033`},".cm-insertedLine, .cm-deletedLine, .cm-deletedLine del":{textDecoration:`none`},".cm-deletedChunk":{paddingLeft:`6px`,"& .cm-chunkButtons":{position:`absolute`,insetInlineEnd:`5px`},"& button":{border:`none`,cursor:`pointer`,color:`white`,margin:`0 2px`,borderRadius:`3px`,"&[name=accept]":{background:`#2a2`},"&[name=reject]":{background:`#d43`}}},".cm-collapsedLines":{padding:`5px 5px 5px 10px`,cursor:`pointer`,"&:before":{content:`"⦚"`,marginInlineEnd:`7px`},"&:after":{content:`"⦚"`,marginInlineStart:`7px`}},"&light .cm-collapsedLines":{color:`#444`,background:`linear-gradient(to bottom, transparent 0, #f3f3f3 30%, #f3f3f3 70%, transparent 100%)`},"&dark .cm-collapsedLines":{color:`#ddd`,background:`linear-gradient(to bottom, transparent 0, #222 30%, #222 70%, transparent 100%)`},".cm-changeGutter":{width:`3px`,paddingLeft:`1px`},"&light.cm-merge-a .cm-changedLineGutter, &light .cm-deletedLineGutter":{background:`#e43`},"&dark.cm-merge-a .cm-changedLineGutter, &dark .cm-deletedLineGutter":{background:`#fa9`},"&light.cm-merge-b .cm-changedLineGutter":{background:`#2b2`},"&dark.cm-merge-b .cm-changedLineGutter":{background:`#8f8`},".cm-inlineChangedLineGutter":{background:`#75d`}}),nt=new v,Q=new v,rt=class{constructor(e){this.revertDOM=null,this.revertToA=!1,this.revertToLeft=!1,this.measuring=-1,this.diffConf=e.diffConfig||Fe;let t=[b.low(Ie),tt,et,X,f.updateListener.of(e=>{this.measuring<0&&(e.heightChanged||e.viewportChanged)&&!e.transactions.some(e=>e.effects.some(e=>e.is(Y)))&&this.measure()})],n=[U.of({side:`a`,sibling:()=>this.b,highlightChanges:e.highlightChanges!==!1,markGutter:e.gutter!==!1})];e.gutter!==!1&&n.push(q);let r=ee.create({doc:e.a.doc,selection:e.a.selection,extensions:[e.a.extensions||[],f.editorAttributes.of({class:`cm-merge-a`}),Q.of(n),t]}),i=[U.of({side:`b`,sibling:()=>this.a,highlightChanges:e.highlightChanges!==!1,markGutter:e.gutter!==!1})];e.gutter!==!1&&i.push(q);let a=ee.create({doc:e.b.doc,selection:e.b.selection,extensions:[e.b.extensions||[],f.editorAttributes.of({class:`cm-merge-b`}),Q.of(i),t]});this.chunks=G.build(r.doc,a.doc,this.diffConf);let o=[W.init(()=>this.chunks),nt.of(e.collapseUnchanged?Qe(e.collapseUnchanged):[])];r=r.update({effects:O.appendConfig.of(o)}).state,a=a.update({effects:O.appendConfig.of(o)}).state,this.dom=document.createElement(`div`),this.dom.className=`cm-mergeView`,this.editorDOM=this.dom.appendChild(document.createElement(`div`)),this.editorDOM.className=`cm-mergeViewEditors`;let s=e.orientation||`a-b`,c=document.createElement(`div`);c.className=`cm-mergeViewEditor`;let l=document.createElement(`div`);l.className=`cm-mergeViewEditor`,this.editorDOM.appendChild(s==`a-b`?c:l),this.editorDOM.appendChild(s==`a-b`?l:c),this.a=new f({state:r,parent:c,root:e.root,dispatchTransactions:e=>this.dispatch(e,this.a)}),this.b=new f({state:a,parent:l,root:e.root,dispatchTransactions:e=>this.dispatch(e,this.b)}),this.setupRevertControls(!!e.revertControls,e.revertControls==`b-to-a`,e.renderRevertControl),e.parent&&e.parent.appendChild(this.dom),this.scheduleMeasure()}dispatch(e,t){if(e.some(e=>e.docChanged)){let n=e[e.length-1],r=e.reduce((e,t)=>e.compose(t.changes),p.empty(e[0].startState.doc.length));this.chunks=t==this.a?G.updateA(this.chunks,n.newDoc,this.b.state.doc,r,this.diffConf):G.updateB(this.chunks,this.a.state.doc,n.newDoc,r,this.diffConf),t.update([...e,n.state.update({effects:De.of(this.chunks)})]);let i=t==this.a?this.b:this.a;i.update([i.state.update({effects:De.of(this.chunks)})]),this.scheduleMeasure()}else t.update(e)}reconfigure(e){if(`diffConfig`in e&&(this.diffConf=e.diffConfig),`orientation`in e){let t=e.orientation!=`b-a`;if(t!=(this.editorDOM.firstChild==this.a.dom.parentNode)){let e=this.a.dom.parentNode,n=this.b.dom.parentNode;e.remove(),n.remove(),this.editorDOM.insertBefore(t?e:n,this.editorDOM.firstChild),this.editorDOM.appendChild(t?n:e),this.revertToLeft=!this.revertToLeft,this.revertDOM&&(this.revertDOM.textContent=``)}}if(`revertControls`in e||`renderRevertControl`in e){let t=!!this.revertDOM,n=this.revertToA,r=this.renderRevert;`revertControls`in e&&(t=!!e.revertControls,n=e.revertControls==`b-to-a`),`renderRevertControl`in e&&(r=e.renderRevertControl),this.setupRevertControls(t,n,r)}let t=`highlightChanges`in e,n=`gutter`in e,r=`collapseUnchanged`in e;if(t||n||r){let i=[],a=[];if(t||n){let r=this.a.state.facet(U),o=n?e.gutter!==!1:r.markGutter,s=t?e.highlightChanges!==!1:r.highlightChanges;i.push(Q.reconfigure([U.of({side:`a`,sibling:()=>this.b,highlightChanges:s,markGutter:o}),o?q:[]])),a.push(Q.reconfigure([U.of({side:`b`,sibling:()=>this.a,highlightChanges:s,markGutter:o}),o?q:[]]))}if(r){let t=nt.reconfigure(e.collapseUnchanged?Qe(e.collapseUnchanged):[]);i.push(t),a.push(t)}this.a.dispatch({effects:i}),this.b.dispatch({effects:a})}this.scheduleMeasure()}setupRevertControls(e,t,n){this.revertToA=t,this.revertToLeft=this.revertToA==(this.editorDOM.firstChild==this.a.dom.parentNode),this.renderRevert=n,!e&&this.revertDOM?(this.revertDOM.remove(),this.revertDOM=null):e&&!this.revertDOM?(this.revertDOM=this.editorDOM.insertBefore(document.createElement(`div`),this.editorDOM.firstChild.nextSibling),this.revertDOM.addEventListener(`mousedown`,e=>this.revertClicked(e)),this.revertDOM.className=`cm-merge-revert`):this.revertDOM&&(this.revertDOM.textContent=``)}scheduleMeasure(){this.measuring<0&&(this.measuring=(this.dom.ownerDocument.defaultView||window).requestAnimationFrame(()=>{this.measuring=-1,this.measure()}))}measure(){qe(this.a,this.b,this.chunks),this.revertDOM&&this.updateRevertButtons()}updateRevertButtons(){let e=this.revertDOM,t=e.firstChild,n=this.a.viewport,r=this.b.viewport;for(let i=0;i<this.chunks.length;i++){let a=this.chunks[i];if(a.fromA>n.to||a.fromB>r.to)break;if(a.fromA<n.from||a.fromB<r.from)continue;let o=this.a.lineBlockAt(a.fromA).top+`px`;for(;t&&+t.dataset.chunk<i;)t=it(t);t&&t.dataset.chunk==String(i)?(t.style.top!=o&&(t.style.top=o),t=t.nextSibling):e.insertBefore(this.renderRevertButton(o,i),t)}for(;t;)t=it(t)}renderRevertButton(e,t){let n;if(this.renderRevert)n=this.renderRevert();else{n=document.createElement(`button`);let e=this.a.state.phrase(`Revert this chunk`);n.setAttribute(`aria-label`,e),n.setAttribute(`title`,e),n.textContent=this.revertToLeft?`⇜`:`⇝`}return n.style.top=e,n.setAttribute(`data-chunk`,String(t)),n}revertClicked(e){let t=e.target,n;for(;t&&t.parentNode!=this.revertDOM;)t=t.parentNode;if(t&&(n=this.chunks[t.dataset.chunk])){let[t,r,i,a,o,s]=this.revertToA?[this.b,this.a,n.fromB,n.toB,n.fromA,n.toA]:[this.a,this.b,n.fromA,n.toA,n.fromB,n.toB],c=t.state.sliceDoc(i,Math.max(i,a-1));i!=a&&s<=r.state.doc.length&&(c+=t.state.lineBreak),r.dispatch({changes:{from:o,to:Math.min(r.state.doc.length,s),insert:c},userEvent:`revert`}),e.preventDefault()}}destroy(){this.a.destroy(),this.b.destroy(),this.measuring>-1&&(this.dom.ownerDocument.defaultView||window).cancelAnimationFrame(this.measuring),this.dom.remove()}};function it(e){let t=e.nextSibling;return e.remove(),t}var $=r();function at(e){switch(e.split(`.`).pop()?.toLowerCase()??``){case`js`:case`jsx`:return w({jsx:!0});case`ts`:case`tsx`:return w({jsx:!0,typescript:!0});case`py`:return h();case`html`:return E();case`css`:case`scss`:return y();case`json`:return C();case`md`:case`mdx`:return k();default:return null}}function ot({metadata:e}){let t=e?.filePath,n=e?.projectName,r=e?.ref1,c=e?.ref2,l=e?.file1,d=e?.file2,p=!!(l&&d),[m,h]=(0,A.useState)(null),[g,_]=(0,A.useState)(null),[v,y]=(0,A.useState)(!0),[b,x]=(0,A.useState)(null),[S,C]=(0,A.useState)(`both`),w=(0,A.useRef)(null),T=(0,A.useRef)(null);(0,A.useEffect)(()=>{if(!n)return;if(y(!0),x(null),l&&d){let e=new URLSearchParams;e.set(`file1`,l),e.set(`file2`,d),a.get(`${i(n)}/files/compare?${e.toString()}`).then(e=>{_(e),y(!1)}).catch(e=>{x(e instanceof Error?e.message:`Failed to compare files`),y(!1)});return}let e;if(t){let a=new URLSearchParams;a.set(`file`,t),r&&a.set(`ref`,r),e=`${i(n)}/git/file-diff?${a.toString()}`}else if(r||c){let t=new URLSearchParams;r&&t.set(`ref1`,r),c&&t.set(`ref2`,c),e=`${i(n)}/git/diff?${t.toString()}`}else e=`${i(n)}/git/diff`;a.get(e).then(e=>{h(e.diff),y(!1)}).catch(e=>{x(e instanceof Error?e.message:`Failed to load diff`),y(!1)})},[t,n,r,c,l,d]);let{original:E,modified:D}=(0,A.useMemo)(()=>p&&g?g:m?st(m):{original:``,modified:``},[m,p,g]),O=(0,A.useMemo)(()=>{let e=t??d??l;if(!e)return[];let n=at(e);return n?[n]:[]},[t,l,d]);if((0,A.useEffect)(()=>{let e=w.current;if(!e||v||b||!E&&!D)return;T.current&&=(T.current.destroy(),null),window.innerWidth;let t=[...O,te,f.editable.of(!1),ee.readOnly.of(!0),u(),f.theme({"&":{fontSize:`13px`,fontFamily:`var(--font-mono)`},"& .cm-changedText":{textDecoration:`none !important`,borderBottom:`none !important`,textDecorationLine:`none !important`,backgroundColor:`rgba(16, 185, 129, 0.4) !important`,borderRadius:`2px`},"& .cm-deletedChunk .cm-changedText":{backgroundColor:`rgba(239, 68, 68, 0.4) !important`}})],n=new rt({parent:e,a:{doc:E,extensions:t},b:{doc:D,extensions:t},orientation:`a-b`,revertControls:void 0,highlightChanges:!0,gutter:!0});T.current=n;let r=n.a.dom.querySelector(`.cm-scroller`),i=n.b.dom.querySelector(`.cm-scroller`),a=!1,o=(e,t)=>{a||=(a=!0,t.scrollLeft=e.scrollLeft,!1)},s=()=>r&&i&&o(r,i),c=()=>r&&i&&o(i,r);return r?.addEventListener(`scroll`,s),i?.addEventListener(`scroll`,c),()=>{r?.removeEventListener(`scroll`,s),i?.removeEventListener(`scroll`,c),n.destroy(),T.current=null}},[E,D,O,v,b]),(0,A.useEffect)(()=>{let e=T.current;if(!e)return;let t=e.a.dom.closest(`.cm-mergeViewEditor`)??e.a.dom.parentElement,n=e.b.dom.closest(`.cm-mergeViewEditor`)??e.b.dom.parentElement,r=w.current?.querySelector(`.cm-mergeViewGutter`);t&&(t.style.display=S===`right`?`none`:``,t.style.flex=S===`left`?`1`:``),n&&(n.style.display=S===`left`?`none`:``,n.style.flex=S===`right`?`1`:``),r&&(r.style.display=S===`both`?``:`none`)},[S,E,D]),!n)return(0,$.jsx)(`div`,{className:`flex items-center justify-center h-full text-muted-foreground text-sm`,children:`No project selected.`});if(v)return(0,$.jsxs)(`div`,{className:`flex items-center justify-center h-full gap-2 text-muted-foreground`,children:[(0,$.jsx)(s,{className:`size-5 animate-spin`}),(0,$.jsx)(`span`,{className:`text-sm`,children:`Loading diff...`})]});if(b)return(0,$.jsx)(`div`,{className:`flex items-center justify-center h-full text-destructive text-sm`,children:b});if(!p&&(!m||m.trim()===``)&&!E&&!D)return(0,$.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full gap-2 text-muted-foreground`,children:[(0,$.jsx)(o,{className:`size-8`}),(0,$.jsx)(`p`,{className:`text-sm`,children:`No changes detected`}),t&&(0,$.jsx)(`p`,{className:`text-xs font-mono`,children:t})]});let k=(0,$.jsxs)(`div`,{className:`flex items-center gap-0.5 shrink-0`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:()=>C(S===`left`?`both`:`left`),className:`p-1 rounded hover:bg-muted transition-colors ${S===`left`?`bg-muted text-foreground`:``}`,title:`Expand original`,children:(0,$.jsx)(re,{className:`size-3.5`})}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>C(`both`),className:`p-1 rounded hover:bg-muted transition-colors ${S===`both`?`bg-muted text-foreground`:``}`,title:`Side by side`,children:(0,$.jsx)(ne,{className:`size-3.5`})}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>C(S===`right`?`both`:`right`),className:`p-1 rounded hover:bg-muted transition-colors ${S===`right`?`bg-muted text-foreground`:``}`,title:`Expand modified`,children:(0,$.jsx)(ie,{className:`size-3.5`})})]});return(0,$.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-1.5 border-b text-xs text-muted-foreground`,children:[(0,$.jsx)(o,{className:`size-3.5`}),p?(0,$.jsxs)(`span`,{className:`font-mono truncate flex-1`,children:[l,` vs `,d]}):(0,$.jsxs)(`span`,{className:`flex-1 truncate`,children:[(0,$.jsx)(`span`,{className:`font-mono`,children:t??`Working tree changes`}),(r||c)&&(0,$.jsxs)(`span`,{children:[` (`,r?.slice(0,7)??`HEAD`,` vs `,c?.slice(0,7)??`working tree`,`)`]})]}),(0,$.jsx)(`div`,{className:`hidden md:block`,children:k})]}),(0,$.jsx)(`div`,{ref:w,className:`flex-1 overflow-auto touch-pinch-zoom [&_.cm-mergeView]:h-full`,style:{WebkitOverflowScrolling:`touch`}}),(0,$.jsx)(`div`,{className:`md:hidden flex justify-center border-t py-1 bg-background shrink-0`,children:k})]})}function st(e){let t=e.split(`
2
2
  `),n=[],r=[],i=!1;for(let e of t)if(!(e.startsWith(`diff --git`)||e.startsWith(`diff --no-index`)||e.startsWith(`index `)||e.startsWith(`new file`)||e.startsWith(`deleted file`)||e.startsWith(`old mode`)||e.startsWith(`new mode`)||e.startsWith(`---`)||e.startsWith(`+++`)||e.startsWith(`Binary files`)||e.startsWith(`\\ No newline`))){if(e.startsWith(`@@`)){i=!0;continue}if(i){if(e.startsWith(`-`))n.push(e.slice(1));else if(e.startsWith(`+`))r.push(e.slice(1));else if(e.startsWith(` `)||e===``){let t=e.startsWith(` `)?e.slice(1):e;n.push(t),r.push(t)}}}return{original:n.join(`
3
3
  `),modified:r.join(`
4
4
  `)}}export{ot as DiffViewer};
@@ -1 +1 @@
1
- import{a as e,r as t,t as n}from"./jsx-runtime-BFALxl05.js";import{_ as r,b as i,c as a,d as o,h as s,m as c,x as l}from"./button-KIZetva8.js";var u=e(t(),1),d=n();function f(e){let t=e+`CollectionProvider`,[n,a]=c(t),[o,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),l=e=>{let{scope:t,children:n}=e,r=u.useRef(null),i=u.useRef(new Map).current;return(0,d.jsx)(o,{scope:t,itemMap:i,collectionRef:r,children:n})};l.displayName=t;let f=e+`CollectionSlot`,p=r(f),m=u.forwardRef((e,t)=>{let{scope:n,children:r}=e;return(0,d.jsx)(p,{ref:i(t,s(f,n).collectionRef),children:r})});m.displayName=f;let h=e+`CollectionItemSlot`,g=`data-radix-collection-item`,_=r(h),v=u.forwardRef((e,t)=>{let{scope:n,children:r,...a}=e,o=u.useRef(null),c=i(t,o),l=s(h,n);return u.useEffect(()=>(l.itemMap.set(o,{ref:o,...a}),()=>void l.itemMap.delete(o))),(0,d.jsx)(_,{[g]:``,ref:c,children:r})});v.displayName=h;function y(t){let n=s(e+`CollectionConsumer`,t);return u.useCallback(()=>{let e=n.collectionRef.current;if(!e)return[];let t=Array.from(e.querySelectorAll(`[${g}]`));return Array.from(n.itemMap.values()).sort((e,n)=>t.indexOf(e.ref.current)-t.indexOf(n.ref.current))},[n.collectionRef,n.itemMap])}return[{Provider:l,Slot:m,ItemSlot:v},y,a]}function p(e){let[t,n]=u.useState(void 0);return o(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});let t=new ResizeObserver(t=>{if(!Array.isArray(t)||!t.length)return;let r=t[0],i,a;if(`borderBoxSize`in r){let e=r.borderBoxSize,t=Array.isArray(e)?e[0]:e;i=t.inlineSize,a=t.blockSize}else i=e.offsetWidth,a=e.offsetHeight;n({width:i,height:a})});return t.observe(e,{box:`border-box`}),()=>t.unobserve(e)}else n(void 0)},[e]),t}var m=[`top`,`right`,`bottom`,`left`],h=Math.min,g=Math.max,_=Math.round,v=Math.floor,y=e=>({x:e,y:e}),b={left:`right`,right:`left`,bottom:`top`,top:`bottom`};function x(e,t,n){return g(e,h(t,n))}function S(e,t){return typeof e==`function`?e(t):e}function C(e){return e.split(`-`)[0]}function w(e){return e.split(`-`)[1]}function T(e){return e===`x`?`y`:`x`}function E(e){return e===`y`?`height`:`width`}function D(e){let t=e[0];return t===`t`||t===`b`?`y`:`x`}function O(e){return T(D(e))}function k(e,t,n){n===void 0&&(n=!1);let r=w(e),i=O(e),a=E(i),o=i===`x`?r===(n?`end`:`start`)?`right`:`left`:r===`start`?`bottom`:`top`;return t.reference[a]>t.floating[a]&&(o=L(o)),[o,L(o)]}function A(e){let t=L(e);return[j(e),t,j(t)]}function j(e){return e.includes(`start`)?e.replace(`start`,`end`):e.replace(`end`,`start`)}var M=[`left`,`right`],N=[`right`,`left`],P=[`top`,`bottom`],ee=[`bottom`,`top`];function F(e,t,n){switch(e){case`top`:case`bottom`:return n?t?N:M:t?M:N;case`left`:case`right`:return t?P:ee;default:return[]}}function I(e,t,n,r){let i=w(e),a=F(C(e),n===`start`,r);return i&&(a=a.map(e=>e+`-`+i),t&&(a=a.concat(a.map(j)))),a}function L(e){let t=C(e);return b[t]+e.slice(t.length)}function R(e){return{top:0,right:0,bottom:0,left:0,...e}}function z(e){return typeof e==`number`?{top:e,right:e,bottom:e,left:e}:R(e)}function B(e){let{x:t,y:n,width:r,height:i}=e;return{width:r,height:i,top:n,left:t,right:t+r,bottom:n+i,x:t,y:n}}function te(e,t,n){let{reference:r,floating:i}=e,a=D(t),o=O(t),s=E(o),c=C(t),l=a===`y`,u=r.x+r.width/2-i.width/2,d=r.y+r.height/2-i.height/2,f=r[s]/2-i[s]/2,p;switch(c){case`top`:p={x:u,y:r.y-i.height};break;case`bottom`:p={x:u,y:r.y+r.height};break;case`right`:p={x:r.x+r.width,y:d};break;case`left`:p={x:r.x-i.width,y:d};break;default:p={x:r.x,y:r.y}}switch(w(t)){case`start`:p[o]-=f*(n&&l?-1:1);break;case`end`:p[o]+=f*(n&&l?-1:1);break}return p}async function ne(e,t){t===void 0&&(t={});let{x:n,y:r,platform:i,rects:a,elements:o,strategy:s}=e,{boundary:c=`clippingAncestors`,rootBoundary:l=`viewport`,elementContext:u=`floating`,altBoundary:d=!1,padding:f=0}=S(t,e),p=z(f),m=o[d?u===`floating`?`reference`:`floating`:u],h=B(await i.getClippingRect({element:await(i.isElement==null?void 0:i.isElement(m))??!0?m:m.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(o.floating)),boundary:c,rootBoundary:l,strategy:s})),g=u===`floating`?{x:n,y:r,width:a.floating.width,height:a.floating.height}:a.reference,_=await(i.getOffsetParent==null?void 0:i.getOffsetParent(o.floating)),v=await(i.isElement==null?void 0:i.isElement(_))&&await(i.getScale==null?void 0:i.getScale(_))||{x:1,y:1},y=B(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:o,rect:g,offsetParent:_,strategy:s}):g);return{top:(h.top-y.top+p.top)/v.y,bottom:(y.bottom-h.bottom+p.bottom)/v.y,left:(h.left-y.left+p.left)/v.x,right:(y.right-h.right+p.right)/v.x}}var re=50,ie=async(e,t,n)=>{let{placement:r=`bottom`,strategy:i=`absolute`,middleware:a=[],platform:o}=n,s=o.detectOverflow?o:{...o,detectOverflow:ne},c=await(o.isRTL==null?void 0:o.isRTL(t)),l=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:d}=te(l,r,c),f=r,p=0,m={};for(let n=0;n<a.length;n++){let h=a[n];if(!h)continue;let{name:g,fn:_}=h,{x:v,y,data:b,reset:x}=await _({x:u,y:d,initialPlacement:r,placement:f,strategy:i,middlewareData:m,rects:l,platform:s,elements:{reference:e,floating:t}});u=v??u,d=y??d,m[g]={...m[g],...b},x&&p<re&&(p++,typeof x==`object`&&(x.placement&&(f=x.placement),x.rects&&(l=x.rects===!0?await o.getElementRects({reference:e,floating:t,strategy:i}):x.rects),{x:u,y:d}=te(l,f,c)),n=-1)}return{x:u,y:d,placement:f,strategy:i,middlewareData:m}},ae=e=>({name:`arrow`,options:e,async fn(t){let{x:n,y:r,placement:i,rects:a,platform:o,elements:s,middlewareData:c}=t,{element:l,padding:u=0}=S(e,t)||{};if(l==null)return{};let d=z(u),f={x:n,y:r},p=O(i),m=E(p),g=await o.getDimensions(l),_=p===`y`,v=_?`top`:`left`,y=_?`bottom`:`right`,b=_?`clientHeight`:`clientWidth`,C=a.reference[m]+a.reference[p]-f[p]-a.floating[m],T=f[p]-a.reference[p],D=await(o.getOffsetParent==null?void 0:o.getOffsetParent(l)),k=D?D[b]:0;(!k||!await(o.isElement==null?void 0:o.isElement(D)))&&(k=s.floating[b]||a.floating[m]);let A=C/2-T/2,j=k/2-g[m]/2-1,M=h(d[v],j),N=h(d[y],j),P=M,ee=k-g[m]-N,F=k/2-g[m]/2+A,I=x(P,F,ee),L=!c.arrow&&w(i)!=null&&F!==I&&a.reference[m]/2-(F<P?M:N)-g[m]/2<0,R=L?F<P?F-P:F-ee:0;return{[p]:f[p]+R,data:{[p]:I,centerOffset:F-I-R,...L&&{alignmentOffset:R}},reset:L}}}),oe=function(e){return e===void 0&&(e={}),{name:`flip`,options:e,async fn(t){var n;let{placement:r,middlewareData:i,rects:a,initialPlacement:o,platform:s,elements:c}=t,{mainAxis:l=!0,crossAxis:u=!0,fallbackPlacements:d,fallbackStrategy:f=`bestFit`,fallbackAxisSideDirection:p=`none`,flipAlignment:m=!0,...h}=S(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};let g=C(r),_=D(o),v=C(o)===o,y=await(s.isRTL==null?void 0:s.isRTL(c.floating)),b=d||(v||!m?[L(o)]:A(o)),x=p!==`none`;!d&&x&&b.push(...I(o,m,p,y));let w=[o,...b],T=await s.detectOverflow(t,h),E=[],O=i.flip?.overflows||[];if(l&&E.push(T[g]),u){let e=k(r,a,y);E.push(T[e[0]],T[e[1]])}if(O=[...O,{placement:r,overflows:E}],!E.every(e=>e<=0)){let e=(i.flip?.index||0)+1,t=w[e];if(t&&(!(u===`alignment`&&_!==D(t))||O.every(e=>D(e.placement)===_?e.overflows[0]>0:!0)))return{data:{index:e,overflows:O},reset:{placement:t}};let n=O.filter(e=>e.overflows[0]<=0).sort((e,t)=>e.overflows[1]-t.overflows[1])[0]?.placement;if(!n)switch(f){case`bestFit`:{let e=O.filter(e=>{if(x){let t=D(e.placement);return t===_||t===`y`}return!0}).map(e=>[e.placement,e.overflows.filter(e=>e>0).reduce((e,t)=>e+t,0)]).sort((e,t)=>e[1]-t[1])[0]?.[0];e&&(n=e);break}case`initialPlacement`:n=o;break}if(r!==n)return{reset:{placement:n}}}return{}}}};function se(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function ce(e){return m.some(t=>e[t]>=0)}var le=function(e){return e===void 0&&(e={}),{name:`hide`,options:e,async fn(t){let{rects:n,platform:r}=t,{strategy:i=`referenceHidden`,...a}=S(e,t);switch(i){case`referenceHidden`:{let e=se(await r.detectOverflow(t,{...a,elementContext:`reference`}),n.reference);return{data:{referenceHiddenOffsets:e,referenceHidden:ce(e)}}}case`escaped`:{let e=se(await r.detectOverflow(t,{...a,altBoundary:!0}),n.floating);return{data:{escapedOffsets:e,escaped:ce(e)}}}default:return{}}}}},ue=new Set([`left`,`top`]);async function de(e,t){let{placement:n,platform:r,elements:i}=e,a=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=C(n),s=w(n),c=D(n)===`y`,l=ue.has(o)?-1:1,u=a&&c?-1:1,d=S(t,e),{mainAxis:f,crossAxis:p,alignmentAxis:m}=typeof d==`number`?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return s&&typeof m==`number`&&(p=s===`end`?m*-1:m),c?{x:p*u,y:f*l}:{x:f*l,y:p*u}}var fe=function(e){return e===void 0&&(e=0),{name:`offset`,options:e,async fn(t){var n;let{x:r,y:i,placement:a,middlewareData:o}=t,s=await de(t,e);return a===o.offset?.placement&&(n=o.arrow)!=null&&n.alignmentOffset?{}:{x:r+s.x,y:i+s.y,data:{...s,placement:a}}}}},pe=function(e){return e===void 0&&(e={}),{name:`shift`,options:e,async fn(t){let{x:n,y:r,placement:i,platform:a}=t,{mainAxis:o=!0,crossAxis:s=!1,limiter:c={fn:e=>{let{x:t,y:n}=e;return{x:t,y:n}}},...l}=S(e,t),u={x:n,y:r},d=await a.detectOverflow(t,l),f=D(C(i)),p=T(f),m=u[p],h=u[f];if(o){let e=p===`y`?`top`:`left`,t=p===`y`?`bottom`:`right`,n=m+d[e],r=m-d[t];m=x(n,m,r)}if(s){let e=f===`y`?`top`:`left`,t=f===`y`?`bottom`:`right`,n=h+d[e],r=h-d[t];h=x(n,h,r)}let g=c.fn({...t,[p]:m,[f]:h});return{...g,data:{x:g.x-n,y:g.y-r,enabled:{[p]:o,[f]:s}}}}}},me=function(e){return e===void 0&&(e={}),{options:e,fn(t){let{x:n,y:r,placement:i,rects:a,middlewareData:o}=t,{offset:s=0,mainAxis:c=!0,crossAxis:l=!0}=S(e,t),u={x:n,y:r},d=D(i),f=T(d),p=u[f],m=u[d],h=S(s,t),g=typeof h==`number`?{mainAxis:h,crossAxis:0}:{mainAxis:0,crossAxis:0,...h};if(c){let e=f===`y`?`height`:`width`,t=a.reference[f]-a.floating[e]+g.mainAxis,n=a.reference[f]+a.reference[e]-g.mainAxis;p<t?p=t:p>n&&(p=n)}if(l){let e=f===`y`?`width`:`height`,t=ue.has(C(i)),n=a.reference[d]-a.floating[e]+(t&&o.offset?.[d]||0)+(t?0:g.crossAxis),r=a.reference[d]+a.reference[e]+(t?0:o.offset?.[d]||0)-(t?g.crossAxis:0);m<n?m=n:m>r&&(m=r)}return{[f]:p,[d]:m}}}},he=function(e){return e===void 0&&(e={}),{name:`size`,options:e,async fn(t){var n,r;let{placement:i,rects:a,platform:o,elements:s}=t,{apply:c=()=>{},...l}=S(e,t),u=await o.detectOverflow(t,l),d=C(i),f=w(i),p=D(i)===`y`,{width:m,height:_}=a.floating,v,y;d===`top`||d===`bottom`?(v=d,y=f===(await(o.isRTL==null?void 0:o.isRTL(s.floating))?`start`:`end`)?`left`:`right`):(y=d,v=f===`end`?`top`:`bottom`);let b=_-u.top-u.bottom,x=m-u.left-u.right,T=h(_-u[v],b),E=h(m-u[y],x),O=!t.middlewareData.shift,k=T,A=E;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(A=x),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(k=b),O&&!f){let e=g(u.left,0),t=g(u.right,0),n=g(u.top,0),r=g(u.bottom,0);p?A=m-2*(e!==0||t!==0?e+t:g(u.left,u.right)):k=_-2*(n!==0||r!==0?n+r:g(u.top,u.bottom))}await c({...t,availableWidth:A,availableHeight:k});let j=await o.getDimensions(s.floating);return m!==j.width||_!==j.height?{reset:{rects:!0}}:{}}}};function ge(){return typeof window<`u`}function V(e){return _e(e)?(e.nodeName||``).toLowerCase():`#document`}function H(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function U(e){return((_e(e)?e.ownerDocument:e.document)||window.document)?.documentElement}function _e(e){return ge()?e instanceof Node||e instanceof H(e).Node:!1}function W(e){return ge()?e instanceof Element||e instanceof H(e).Element:!1}function G(e){return ge()?e instanceof HTMLElement||e instanceof H(e).HTMLElement:!1}function ve(e){return!ge()||typeof ShadowRoot>`u`?!1:e instanceof ShadowRoot||e instanceof H(e).ShadowRoot}function K(e){let{overflow:t,overflowX:n,overflowY:r,display:i}=Y(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!==`inline`&&i!==`contents`}function ye(e){return/^(table|td|th)$/.test(V(e))}function be(e){try{if(e.matches(`:popover-open`))return!0}catch{}try{return e.matches(`:modal`)}catch{return!1}}var xe=/transform|translate|scale|rotate|perspective|filter/,Se=/paint|layout|strict|content/,q=e=>!!e&&e!==`none`,Ce;function we(e){let t=W(e)?Y(e):e;return q(t.transform)||q(t.translate)||q(t.scale)||q(t.rotate)||q(t.perspective)||!Ee()&&(q(t.backdropFilter)||q(t.filter))||xe.test(t.willChange||``)||Se.test(t.contain||``)}function Te(e){let t=X(e);for(;G(t)&&!J(t);){if(we(t))return t;if(be(t))return null;t=X(t)}return null}function Ee(){return Ce??=typeof CSS<`u`&&CSS.supports&&CSS.supports(`-webkit-backdrop-filter`,`none`),Ce}function J(e){return/^(html|body|#document)$/.test(V(e))}function Y(e){return H(e).getComputedStyle(e)}function De(e){return W(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function X(e){if(V(e)===`html`)return e;let t=e.assignedSlot||e.parentNode||ve(e)&&e.host||U(e);return ve(t)?t.host:t}function Oe(e){let t=X(e);return J(t)?e.ownerDocument?e.ownerDocument.body:e.body:G(t)&&K(t)?t:Oe(t)}function Z(e,t,n){t===void 0&&(t=[]),n===void 0&&(n=!0);let r=Oe(e),i=r===e.ownerDocument?.body,a=H(r);if(i){let e=ke(a);return t.concat(a,a.visualViewport||[],K(r)?r:[],e&&n?Z(e):[])}else return t.concat(r,Z(r,[],n))}function ke(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function Ae(e){let t=Y(e),n=parseFloat(t.width)||0,r=parseFloat(t.height)||0,i=G(e),a=i?e.offsetWidth:n,o=i?e.offsetHeight:r,s=_(n)!==a||_(r)!==o;return s&&(n=a,r=o),{width:n,height:r,$:s}}function je(e){return W(e)?e:e.contextElement}function Q(e){let t=je(e);if(!G(t))return y(1);let n=t.getBoundingClientRect(),{width:r,height:i,$:a}=Ae(t),o=(a?_(n.width):n.width)/r,s=(a?_(n.height):n.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!s||!Number.isFinite(s))&&(s=1),{x:o,y:s}}var Me=y(0);function Ne(e){let t=H(e);return!Ee()||!t.visualViewport?Me:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Pe(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==H(e)?!1:t}function $(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);let i=e.getBoundingClientRect(),a=je(e),o=y(1);t&&(r?W(r)&&(o=Q(r)):o=Q(e));let s=Pe(a,n,r)?Ne(a):y(0),c=(i.left+s.x)/o.x,l=(i.top+s.y)/o.y,u=i.width/o.x,d=i.height/o.y;if(a){let e=H(a),t=r&&W(r)?H(r):r,n=e,i=ke(n);for(;i&&r&&t!==n;){let e=Q(i),t=i.getBoundingClientRect(),r=Y(i),a=t.left+(i.clientLeft+parseFloat(r.paddingLeft))*e.x,o=t.top+(i.clientTop+parseFloat(r.paddingTop))*e.y;c*=e.x,l*=e.y,u*=e.x,d*=e.y,c+=a,l+=o,n=H(i),i=ke(n)}}return B({width:u,height:d,x:c,y:l})}function Fe(e,t){let n=De(e).scrollLeft;return t?t.left+n:$(U(e)).left+n}function Ie(e,t){let n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-Fe(e,n),y:n.top+t.scrollTop}}function Le(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e,a=i===`fixed`,o=U(r),s=t?be(t.floating):!1;if(r===o||s&&a)return n;let c={scrollLeft:0,scrollTop:0},l=y(1),u=y(0),d=G(r);if((d||!d&&!a)&&((V(r)!==`body`||K(o))&&(c=De(r)),d)){let e=$(r);l=Q(r),u.x=e.x+r.clientLeft,u.y=e.y+r.clientTop}let f=o&&!d&&!a?Ie(o,c):y(0);return{width:n.width*l.x,height:n.height*l.y,x:n.x*l.x-c.scrollLeft*l.x+u.x+f.x,y:n.y*l.y-c.scrollTop*l.y+u.y+f.y}}function Re(e){return Array.from(e.getClientRects())}function ze(e){let t=U(e),n=De(e),r=e.ownerDocument.body,i=g(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),a=g(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight),o=-n.scrollLeft+Fe(e),s=-n.scrollTop;return Y(r).direction===`rtl`&&(o+=g(t.clientWidth,r.clientWidth)-i),{width:i,height:a,x:o,y:s}}var Be=25;function Ve(e,t){let n=H(e),r=U(e),i=n.visualViewport,a=r.clientWidth,o=r.clientHeight,s=0,c=0;if(i){a=i.width,o=i.height;let e=Ee();(!e||e&&t===`fixed`)&&(s=i.offsetLeft,c=i.offsetTop)}let l=Fe(r);if(l<=0){let e=r.ownerDocument,t=e.body,n=getComputedStyle(t),i=e.compatMode===`CSS1Compat`&&parseFloat(n.marginLeft)+parseFloat(n.marginRight)||0,o=Math.abs(r.clientWidth-t.clientWidth-i);o<=Be&&(a-=o)}else l<=Be&&(a+=l);return{width:a,height:o,x:s,y:c}}function He(e,t){let n=$(e,!0,t===`fixed`),r=n.top+e.clientTop,i=n.left+e.clientLeft,a=G(e)?Q(e):y(1);return{width:e.clientWidth*a.x,height:e.clientHeight*a.y,x:i*a.x,y:r*a.y}}function Ue(e,t,n){let r;if(t===`viewport`)r=Ve(e,n);else if(t===`document`)r=ze(U(e));else if(W(t))r=He(t,n);else{let n=Ne(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return B(r)}function We(e,t){let n=X(e);return n===t||!W(n)||J(n)?!1:Y(n).position===`fixed`||We(n,t)}function Ge(e,t){let n=t.get(e);if(n)return n;let r=Z(e,[],!1).filter(e=>W(e)&&V(e)!==`body`),i=null,a=Y(e).position===`fixed`,o=a?X(e):e;for(;W(o)&&!J(o);){let t=Y(o),n=we(o);!n&&t.position===`fixed`&&(i=null),(a?!n&&!i:!n&&t.position===`static`&&i&&(i.position===`absolute`||i.position===`fixed`)||K(o)&&!n&&We(e,o))?r=r.filter(e=>e!==o):i=t,o=X(o)}return t.set(e,r),r}function Ke(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e,a=[...n===`clippingAncestors`?be(t)?[]:Ge(t,this._c):[].concat(n),r],o=Ue(t,a[0],i),s=o.top,c=o.right,l=o.bottom,u=o.left;for(let e=1;e<a.length;e++){let n=Ue(t,a[e],i);s=g(n.top,s),c=h(n.right,c),l=h(n.bottom,l),u=g(n.left,u)}return{width:c-u,height:l-s,x:u,y:s}}function qe(e){let{width:t,height:n}=Ae(e);return{width:t,height:n}}function Je(e,t,n){let r=G(t),i=U(t),a=n===`fixed`,o=$(e,!0,a,t),s={scrollLeft:0,scrollTop:0},c=y(0);function l(){c.x=Fe(i)}if(r||!r&&!a)if((V(t)!==`body`||K(i))&&(s=De(t)),r){let e=$(t,!0,a,t);c.x=e.x+t.clientLeft,c.y=e.y+t.clientTop}else i&&l();a&&!r&&i&&l();let u=i&&!r&&!a?Ie(i,s):y(0);return{x:o.left+s.scrollLeft-c.x-u.x,y:o.top+s.scrollTop-c.y-u.y,width:o.width,height:o.height}}function Ye(e){return Y(e).position===`static`}function Xe(e,t){if(!G(e)||Y(e).position===`fixed`)return null;if(t)return t(e);let n=e.offsetParent;return U(e)===n&&(n=n.ownerDocument.body),n}function Ze(e,t){let n=H(e);if(be(e))return n;if(!G(e)){let t=X(e);for(;t&&!J(t);){if(W(t)&&!Ye(t))return t;t=X(t)}return n}let r=Xe(e,t);for(;r&&ye(r)&&Ye(r);)r=Xe(r,t);return r&&J(r)&&Ye(r)&&!we(r)?n:r||Te(e)||n}var Qe=async function(e){let t=this.getOffsetParent||Ze,n=this.getDimensions,r=await n(e.floating);return{reference:Je(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function $e(e){return Y(e).direction===`rtl`}var et={convertOffsetParentRelativeRectToViewportRelativeRect:Le,getDocumentElement:U,getClippingRect:Ke,getOffsetParent:Ze,getElementRects:Qe,getClientRects:Re,getDimensions:qe,getScale:Q,isElement:W,isRTL:$e};function tt(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function nt(e,t){let n=null,r,i=U(e);function a(){var e;clearTimeout(r),(e=n)==null||e.disconnect(),n=null}function o(s,c){s===void 0&&(s=!1),c===void 0&&(c=1),a();let l=e.getBoundingClientRect(),{left:u,top:d,width:f,height:p}=l;if(s||t(),!f||!p)return;let m=v(d),_=v(i.clientWidth-(u+f)),y=v(i.clientHeight-(d+p)),b=v(u),x={rootMargin:-m+`px `+-_+`px `+-y+`px `+-b+`px`,threshold:g(0,h(1,c))||1},S=!0;function C(t){let n=t[0].intersectionRatio;if(n!==c){if(!S)return o();n?o(!1,n):r=setTimeout(()=>{o(!1,1e-7)},1e3)}n===1&&!tt(l,e.getBoundingClientRect())&&o(),S=!1}try{n=new IntersectionObserver(C,{...x,root:i.ownerDocument})}catch{n=new IntersectionObserver(C,x)}n.observe(e)}return o(!0),a}function rt(e,t,n,r){r===void 0&&(r={});let{ancestorScroll:i=!0,ancestorResize:a=!0,elementResize:o=typeof ResizeObserver==`function`,layoutShift:s=typeof IntersectionObserver==`function`,animationFrame:c=!1}=r,l=je(e),u=i||a?[...l?Z(l):[],...t?Z(t):[]]:[];u.forEach(e=>{i&&e.addEventListener(`scroll`,n,{passive:!0}),a&&e.addEventListener(`resize`,n)});let d=l&&s?nt(l,n):null,f=-1,p=null;o&&(p=new ResizeObserver(e=>{let[r]=e;r&&r.target===l&&p&&t&&(p.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var e;(e=p)==null||e.observe(t)})),n()}),l&&!c&&p.observe(l),t&&p.observe(t));let m,h=c?$(e):null;c&&g();function g(){let t=$(e);h&&!tt(h,t)&&n(),h=t,m=requestAnimationFrame(g)}return n(),()=>{var e;u.forEach(e=>{i&&e.removeEventListener(`scroll`,n),a&&e.removeEventListener(`resize`,n)}),d?.(),(e=p)==null||e.disconnect(),p=null,c&&cancelAnimationFrame(m)}}var it=fe,at=pe,ot=oe,st=he,ct=le,lt=ae,ut=me,dt=(e,t,n)=>{let r=new Map,i={platform:et,...n},a={...i.platform,_c:r};return ie(e,t,{...i,platform:a})},ft=e(l(),1),pt=typeof document<`u`?u.useLayoutEffect:function(){};function mt(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e==`function`&&e.toString()===t.toString())return!0;let n,r,i;if(e&&t&&typeof e==`object`){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!mt(e[r],t[r]))return!1;return!0}if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,i[r]))return!1;for(r=n;r--!==0;){let n=i[r];if(!(n===`_owner`&&e.$$typeof)&&!mt(e[n],t[n]))return!1}return!0}return e!==e&&t!==t}function ht(e){return typeof window>`u`?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function gt(e,t){let n=ht(e);return Math.round(t*n)/n}function _t(e){let t=u.useRef(e);return pt(()=>{t.current=e}),t}function vt(e){e===void 0&&(e={});let{placement:t=`bottom`,strategy:n=`absolute`,middleware:r=[],platform:i,elements:{reference:a,floating:o}={},transform:s=!0,whileElementsMounted:c,open:l}=e,[d,f]=u.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[p,m]=u.useState(r);mt(p,r)||m(r);let[h,g]=u.useState(null),[_,v]=u.useState(null),y=u.useCallback(e=>{e!==C.current&&(C.current=e,g(e))},[]),b=u.useCallback(e=>{e!==w.current&&(w.current=e,v(e))},[]),x=a||h,S=o||_,C=u.useRef(null),w=u.useRef(null),T=u.useRef(d),E=c!=null,D=_t(c),O=_t(i),k=_t(l),A=u.useCallback(()=>{if(!C.current||!w.current)return;let e={placement:t,strategy:n,middleware:p};O.current&&(e.platform=O.current),dt(C.current,w.current,e).then(e=>{let t={...e,isPositioned:k.current!==!1};j.current&&!mt(T.current,t)&&(T.current=t,ft.flushSync(()=>{f(t)}))})},[p,t,n,O,k]);pt(()=>{l===!1&&T.current.isPositioned&&(T.current.isPositioned=!1,f(e=>({...e,isPositioned:!1})))},[l]);let j=u.useRef(!1);pt(()=>(j.current=!0,()=>{j.current=!1}),[]),pt(()=>{if(x&&(C.current=x),S&&(w.current=S),x&&S){if(D.current)return D.current(x,S,A);A()}},[x,S,A,D,E]);let M=u.useMemo(()=>({reference:C,floating:w,setReference:y,setFloating:b}),[y,b]),N=u.useMemo(()=>({reference:x,floating:S}),[x,S]),P=u.useMemo(()=>{let e={position:n,left:0,top:0};if(!N.floating)return e;let t=gt(N.floating,d.x),r=gt(N.floating,d.y);return s?{...e,transform:`translate(`+t+`px, `+r+`px)`,...ht(N.floating)>=1.5&&{willChange:`transform`}}:{position:n,left:t,top:r}},[n,s,N.floating,d.x,d.y]);return u.useMemo(()=>({...d,update:A,refs:M,elements:N,floatingStyles:P}),[d,A,M,N,P])}var yt=e=>{function t(e){return{}.hasOwnProperty.call(e,`current`)}return{name:`arrow`,options:e,fn(n){let{element:r,padding:i}=typeof e==`function`?e(n):e;return r&&t(r)?r.current==null?{}:lt({element:r.current,padding:i}).fn(n):r?lt({element:r,padding:i}).fn(n):{}}}},bt=(e,t)=>{let n=it(e);return{name:n.name,fn:n.fn,options:[e,t]}},xt=(e,t)=>{let n=at(e);return{name:n.name,fn:n.fn,options:[e,t]}},St=(e,t)=>({fn:ut(e).fn,options:[e,t]}),Ct=(e,t)=>{let n=ot(e);return{name:n.name,fn:n.fn,options:[e,t]}},wt=(e,t)=>{let n=st(e);return{name:n.name,fn:n.fn,options:[e,t]}},Tt=(e,t)=>{let n=ct(e);return{name:n.name,fn:n.fn,options:[e,t]}},Et=(e,t)=>{let n=yt(e);return{name:n.name,fn:n.fn,options:[e,t]}},Dt=`Arrow`,Ot=u.forwardRef((e,t)=>{let{children:n,width:r=10,height:i=5,...a}=e;return(0,d.jsx)(s.svg,{...a,ref:t,width:r,height:i,viewBox:`0 0 30 10`,preserveAspectRatio:`none`,children:e.asChild?n:(0,d.jsx)(`polygon`,{points:`0,0 30,0 15,10`})})});Ot.displayName=Dt;var kt=Ot,At=`Popper`,[jt,Mt]=c(At),[Nt,Pt]=jt(At),Ft=e=>{let{__scopePopper:t,children:n}=e,[r,i]=u.useState(null);return(0,d.jsx)(Nt,{scope:t,anchor:r,onAnchorChange:i,children:n})};Ft.displayName=At;var It=`PopperAnchor`,Lt=u.forwardRef((e,t)=>{let{__scopePopper:n,virtualRef:r,...a}=e,o=Pt(It,n),c=u.useRef(null),l=i(t,c),f=u.useRef(null);return u.useEffect(()=>{let e=f.current;f.current=r?.current||c.current,e!==f.current&&o.onAnchorChange(f.current)}),r?null:(0,d.jsx)(s.div,{...a,ref:l})});Lt.displayName=It;var Rt=`PopperContent`,[zt,Bt]=jt(Rt),Vt=u.forwardRef((e,t)=>{let{__scopePopper:n,side:r=`bottom`,sideOffset:c=0,align:l=`center`,alignOffset:f=0,arrowPadding:m=0,avoidCollisions:h=!0,collisionBoundary:g=[],collisionPadding:_=0,sticky:v=`partial`,hideWhenDetached:y=!1,updatePositionStrategy:b=`optimized`,onPlaced:x,...S}=e,C=Pt(Rt,n),[w,T]=u.useState(null),E=i(t,e=>T(e)),[D,O]=u.useState(null),k=p(D),A=k?.width??0,j=k?.height??0,M=r+(l===`center`?``:`-`+l),N=typeof _==`number`?_:{top:0,right:0,bottom:0,left:0,..._},P=Array.isArray(g)?g:[g],ee=P.length>0,F={padding:N,boundary:P.filter(Gt),altBoundary:ee},{refs:I,floatingStyles:L,placement:R,isPositioned:z,middlewareData:B}=vt({strategy:`fixed`,placement:M,whileElementsMounted:(...e)=>rt(...e,{animationFrame:b===`always`}),elements:{reference:C.anchor},middleware:[bt({mainAxis:c+j,alignmentAxis:f}),h&&xt({mainAxis:!0,crossAxis:!1,limiter:v===`partial`?St():void 0,...F}),h&&Ct({...F}),wt({...F,apply:({elements:e,rects:t,availableWidth:n,availableHeight:r})=>{let{width:i,height:a}=t.reference,o=e.floating.style;o.setProperty(`--radix-popper-available-width`,`${n}px`),o.setProperty(`--radix-popper-available-height`,`${r}px`),o.setProperty(`--radix-popper-anchor-width`,`${i}px`),o.setProperty(`--radix-popper-anchor-height`,`${a}px`)}}),D&&Et({element:D,padding:m}),Kt({arrowWidth:A,arrowHeight:j}),y&&Tt({strategy:`referenceHidden`,...F})]}),[te,ne]=qt(R),re=a(x);o(()=>{z&&re?.()},[z,re]);let ie=B.arrow?.x,ae=B.arrow?.y,oe=B.arrow?.centerOffset!==0,[se,ce]=u.useState();return o(()=>{w&&ce(window.getComputedStyle(w).zIndex)},[w]),(0,d.jsx)(`div`,{ref:I.setFloating,"data-radix-popper-content-wrapper":``,style:{...L,transform:z?L.transform:`translate(0, -200%)`,minWidth:`max-content`,zIndex:se,"--radix-popper-transform-origin":[B.transformOrigin?.x,B.transformOrigin?.y].join(` `),...B.hide?.referenceHidden&&{visibility:`hidden`,pointerEvents:`none`}},dir:e.dir,children:(0,d.jsx)(zt,{scope:n,placedSide:te,onArrowChange:O,arrowX:ie,arrowY:ae,shouldHideArrow:oe,children:(0,d.jsx)(s.div,{"data-side":te,"data-align":ne,...S,ref:E,style:{...S.style,animation:z?void 0:`none`}})})})});Vt.displayName=Rt;var Ht=`PopperArrow`,Ut={top:`bottom`,right:`left`,bottom:`top`,left:`right`},Wt=u.forwardRef(function(e,t){let{__scopePopper:n,...r}=e,i=Bt(Ht,n),a=Ut[i.placedSide];return(0,d.jsx)(`span`,{ref:i.onArrowChange,style:{position:`absolute`,left:i.arrowX,top:i.arrowY,[a]:0,transformOrigin:{top:``,right:`0 0`,bottom:`center 0`,left:`100% 0`}[i.placedSide],transform:{top:`translateY(100%)`,right:`translateY(50%) rotate(90deg) translateX(-50%)`,bottom:`rotate(180deg)`,left:`translateY(50%) rotate(-90deg) translateX(50%)`}[i.placedSide],visibility:i.shouldHideArrow?`hidden`:void 0},children:(0,d.jsx)(kt,{...r,ref:t,style:{...r.style,display:`block`}})})});Wt.displayName=Ht;function Gt(e){return e!==null}var Kt=e=>({name:`transformOrigin`,options:e,fn(t){let{placement:n,rects:r,middlewareData:i}=t,a=i.arrow?.centerOffset!==0,o=a?0:e.arrowWidth,s=a?0:e.arrowHeight,[c,l]=qt(n),u={start:`0%`,center:`50%`,end:`100%`}[l],d=(i.arrow?.x??0)+o/2,f=(i.arrow?.y??0)+s/2,p=``,m=``;return c===`bottom`?(p=a?u:`${d}px`,m=`${-s}px`):c===`top`?(p=a?u:`${d}px`,m=`${r.floating.height+s}px`):c===`right`?(p=`${-s}px`,m=a?u:`${f}px`):c===`left`&&(p=`${r.floating.width+s}px`,m=a?u:`${f}px`),{data:{x:p,y:m}}}});function qt(e){let[t,n=`center`]=e.split(`-`);return[t,n]}var Jt=Ft,Yt=Lt,Xt=Vt,Zt=Wt;export{Mt as a,Jt as i,Zt as n,f as o,Xt as r,Yt as t};
1
+ import{a as e,r as t,t as n}from"./jsx-runtime-BFALxl05.js";import{_ as r,b as i,c as a,d as o,h as s,m as c,x as l}from"./button-CvHWF07y.js";var u=e(t(),1),d=n();function f(e){let t=e+`CollectionProvider`,[n,a]=c(t),[o,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),l=e=>{let{scope:t,children:n}=e,r=u.useRef(null),i=u.useRef(new Map).current;return(0,d.jsx)(o,{scope:t,itemMap:i,collectionRef:r,children:n})};l.displayName=t;let f=e+`CollectionSlot`,p=r(f),m=u.forwardRef((e,t)=>{let{scope:n,children:r}=e;return(0,d.jsx)(p,{ref:i(t,s(f,n).collectionRef),children:r})});m.displayName=f;let h=e+`CollectionItemSlot`,g=`data-radix-collection-item`,_=r(h),v=u.forwardRef((e,t)=>{let{scope:n,children:r,...a}=e,o=u.useRef(null),c=i(t,o),l=s(h,n);return u.useEffect(()=>(l.itemMap.set(o,{ref:o,...a}),()=>void l.itemMap.delete(o))),(0,d.jsx)(_,{[g]:``,ref:c,children:r})});v.displayName=h;function y(t){let n=s(e+`CollectionConsumer`,t);return u.useCallback(()=>{let e=n.collectionRef.current;if(!e)return[];let t=Array.from(e.querySelectorAll(`[${g}]`));return Array.from(n.itemMap.values()).sort((e,n)=>t.indexOf(e.ref.current)-t.indexOf(n.ref.current))},[n.collectionRef,n.itemMap])}return[{Provider:l,Slot:m,ItemSlot:v},y,a]}function p(e){let[t,n]=u.useState(void 0);return o(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});let t=new ResizeObserver(t=>{if(!Array.isArray(t)||!t.length)return;let r=t[0],i,a;if(`borderBoxSize`in r){let e=r.borderBoxSize,t=Array.isArray(e)?e[0]:e;i=t.inlineSize,a=t.blockSize}else i=e.offsetWidth,a=e.offsetHeight;n({width:i,height:a})});return t.observe(e,{box:`border-box`}),()=>t.unobserve(e)}else n(void 0)},[e]),t}var m=[`top`,`right`,`bottom`,`left`],h=Math.min,g=Math.max,_=Math.round,v=Math.floor,y=e=>({x:e,y:e}),b={left:`right`,right:`left`,bottom:`top`,top:`bottom`};function x(e,t,n){return g(e,h(t,n))}function S(e,t){return typeof e==`function`?e(t):e}function C(e){return e.split(`-`)[0]}function w(e){return e.split(`-`)[1]}function T(e){return e===`x`?`y`:`x`}function E(e){return e===`y`?`height`:`width`}function D(e){let t=e[0];return t===`t`||t===`b`?`y`:`x`}function O(e){return T(D(e))}function k(e,t,n){n===void 0&&(n=!1);let r=w(e),i=O(e),a=E(i),o=i===`x`?r===(n?`end`:`start`)?`right`:`left`:r===`start`?`bottom`:`top`;return t.reference[a]>t.floating[a]&&(o=L(o)),[o,L(o)]}function A(e){let t=L(e);return[j(e),t,j(t)]}function j(e){return e.includes(`start`)?e.replace(`start`,`end`):e.replace(`end`,`start`)}var M=[`left`,`right`],N=[`right`,`left`],P=[`top`,`bottom`],ee=[`bottom`,`top`];function F(e,t,n){switch(e){case`top`:case`bottom`:return n?t?N:M:t?M:N;case`left`:case`right`:return t?P:ee;default:return[]}}function I(e,t,n,r){let i=w(e),a=F(C(e),n===`start`,r);return i&&(a=a.map(e=>e+`-`+i),t&&(a=a.concat(a.map(j)))),a}function L(e){let t=C(e);return b[t]+e.slice(t.length)}function R(e){return{top:0,right:0,bottom:0,left:0,...e}}function z(e){return typeof e==`number`?{top:e,right:e,bottom:e,left:e}:R(e)}function B(e){let{x:t,y:n,width:r,height:i}=e;return{width:r,height:i,top:n,left:t,right:t+r,bottom:n+i,x:t,y:n}}function te(e,t,n){let{reference:r,floating:i}=e,a=D(t),o=O(t),s=E(o),c=C(t),l=a===`y`,u=r.x+r.width/2-i.width/2,d=r.y+r.height/2-i.height/2,f=r[s]/2-i[s]/2,p;switch(c){case`top`:p={x:u,y:r.y-i.height};break;case`bottom`:p={x:u,y:r.y+r.height};break;case`right`:p={x:r.x+r.width,y:d};break;case`left`:p={x:r.x-i.width,y:d};break;default:p={x:r.x,y:r.y}}switch(w(t)){case`start`:p[o]-=f*(n&&l?-1:1);break;case`end`:p[o]+=f*(n&&l?-1:1);break}return p}async function ne(e,t){t===void 0&&(t={});let{x:n,y:r,platform:i,rects:a,elements:o,strategy:s}=e,{boundary:c=`clippingAncestors`,rootBoundary:l=`viewport`,elementContext:u=`floating`,altBoundary:d=!1,padding:f=0}=S(t,e),p=z(f),m=o[d?u===`floating`?`reference`:`floating`:u],h=B(await i.getClippingRect({element:await(i.isElement==null?void 0:i.isElement(m))??!0?m:m.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(o.floating)),boundary:c,rootBoundary:l,strategy:s})),g=u===`floating`?{x:n,y:r,width:a.floating.width,height:a.floating.height}:a.reference,_=await(i.getOffsetParent==null?void 0:i.getOffsetParent(o.floating)),v=await(i.isElement==null?void 0:i.isElement(_))&&await(i.getScale==null?void 0:i.getScale(_))||{x:1,y:1},y=B(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:o,rect:g,offsetParent:_,strategy:s}):g);return{top:(h.top-y.top+p.top)/v.y,bottom:(y.bottom-h.bottom+p.bottom)/v.y,left:(h.left-y.left+p.left)/v.x,right:(y.right-h.right+p.right)/v.x}}var re=50,ie=async(e,t,n)=>{let{placement:r=`bottom`,strategy:i=`absolute`,middleware:a=[],platform:o}=n,s=o.detectOverflow?o:{...o,detectOverflow:ne},c=await(o.isRTL==null?void 0:o.isRTL(t)),l=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:d}=te(l,r,c),f=r,p=0,m={};for(let n=0;n<a.length;n++){let h=a[n];if(!h)continue;let{name:g,fn:_}=h,{x:v,y,data:b,reset:x}=await _({x:u,y:d,initialPlacement:r,placement:f,strategy:i,middlewareData:m,rects:l,platform:s,elements:{reference:e,floating:t}});u=v??u,d=y??d,m[g]={...m[g],...b},x&&p<re&&(p++,typeof x==`object`&&(x.placement&&(f=x.placement),x.rects&&(l=x.rects===!0?await o.getElementRects({reference:e,floating:t,strategy:i}):x.rects),{x:u,y:d}=te(l,f,c)),n=-1)}return{x:u,y:d,placement:f,strategy:i,middlewareData:m}},ae=e=>({name:`arrow`,options:e,async fn(t){let{x:n,y:r,placement:i,rects:a,platform:o,elements:s,middlewareData:c}=t,{element:l,padding:u=0}=S(e,t)||{};if(l==null)return{};let d=z(u),f={x:n,y:r},p=O(i),m=E(p),g=await o.getDimensions(l),_=p===`y`,v=_?`top`:`left`,y=_?`bottom`:`right`,b=_?`clientHeight`:`clientWidth`,C=a.reference[m]+a.reference[p]-f[p]-a.floating[m],T=f[p]-a.reference[p],D=await(o.getOffsetParent==null?void 0:o.getOffsetParent(l)),k=D?D[b]:0;(!k||!await(o.isElement==null?void 0:o.isElement(D)))&&(k=s.floating[b]||a.floating[m]);let A=C/2-T/2,j=k/2-g[m]/2-1,M=h(d[v],j),N=h(d[y],j),P=M,ee=k-g[m]-N,F=k/2-g[m]/2+A,I=x(P,F,ee),L=!c.arrow&&w(i)!=null&&F!==I&&a.reference[m]/2-(F<P?M:N)-g[m]/2<0,R=L?F<P?F-P:F-ee:0;return{[p]:f[p]+R,data:{[p]:I,centerOffset:F-I-R,...L&&{alignmentOffset:R}},reset:L}}}),oe=function(e){return e===void 0&&(e={}),{name:`flip`,options:e,async fn(t){var n;let{placement:r,middlewareData:i,rects:a,initialPlacement:o,platform:s,elements:c}=t,{mainAxis:l=!0,crossAxis:u=!0,fallbackPlacements:d,fallbackStrategy:f=`bestFit`,fallbackAxisSideDirection:p=`none`,flipAlignment:m=!0,...h}=S(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};let g=C(r),_=D(o),v=C(o)===o,y=await(s.isRTL==null?void 0:s.isRTL(c.floating)),b=d||(v||!m?[L(o)]:A(o)),x=p!==`none`;!d&&x&&b.push(...I(o,m,p,y));let w=[o,...b],T=await s.detectOverflow(t,h),E=[],O=i.flip?.overflows||[];if(l&&E.push(T[g]),u){let e=k(r,a,y);E.push(T[e[0]],T[e[1]])}if(O=[...O,{placement:r,overflows:E}],!E.every(e=>e<=0)){let e=(i.flip?.index||0)+1,t=w[e];if(t&&(!(u===`alignment`&&_!==D(t))||O.every(e=>D(e.placement)===_?e.overflows[0]>0:!0)))return{data:{index:e,overflows:O},reset:{placement:t}};let n=O.filter(e=>e.overflows[0]<=0).sort((e,t)=>e.overflows[1]-t.overflows[1])[0]?.placement;if(!n)switch(f){case`bestFit`:{let e=O.filter(e=>{if(x){let t=D(e.placement);return t===_||t===`y`}return!0}).map(e=>[e.placement,e.overflows.filter(e=>e>0).reduce((e,t)=>e+t,0)]).sort((e,t)=>e[1]-t[1])[0]?.[0];e&&(n=e);break}case`initialPlacement`:n=o;break}if(r!==n)return{reset:{placement:n}}}return{}}}};function se(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function ce(e){return m.some(t=>e[t]>=0)}var le=function(e){return e===void 0&&(e={}),{name:`hide`,options:e,async fn(t){let{rects:n,platform:r}=t,{strategy:i=`referenceHidden`,...a}=S(e,t);switch(i){case`referenceHidden`:{let e=se(await r.detectOverflow(t,{...a,elementContext:`reference`}),n.reference);return{data:{referenceHiddenOffsets:e,referenceHidden:ce(e)}}}case`escaped`:{let e=se(await r.detectOverflow(t,{...a,altBoundary:!0}),n.floating);return{data:{escapedOffsets:e,escaped:ce(e)}}}default:return{}}}}},ue=new Set([`left`,`top`]);async function de(e,t){let{placement:n,platform:r,elements:i}=e,a=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=C(n),s=w(n),c=D(n)===`y`,l=ue.has(o)?-1:1,u=a&&c?-1:1,d=S(t,e),{mainAxis:f,crossAxis:p,alignmentAxis:m}=typeof d==`number`?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return s&&typeof m==`number`&&(p=s===`end`?m*-1:m),c?{x:p*u,y:f*l}:{x:f*l,y:p*u}}var fe=function(e){return e===void 0&&(e=0),{name:`offset`,options:e,async fn(t){var n;let{x:r,y:i,placement:a,middlewareData:o}=t,s=await de(t,e);return a===o.offset?.placement&&(n=o.arrow)!=null&&n.alignmentOffset?{}:{x:r+s.x,y:i+s.y,data:{...s,placement:a}}}}},pe=function(e){return e===void 0&&(e={}),{name:`shift`,options:e,async fn(t){let{x:n,y:r,placement:i,platform:a}=t,{mainAxis:o=!0,crossAxis:s=!1,limiter:c={fn:e=>{let{x:t,y:n}=e;return{x:t,y:n}}},...l}=S(e,t),u={x:n,y:r},d=await a.detectOverflow(t,l),f=D(C(i)),p=T(f),m=u[p],h=u[f];if(o){let e=p===`y`?`top`:`left`,t=p===`y`?`bottom`:`right`,n=m+d[e],r=m-d[t];m=x(n,m,r)}if(s){let e=f===`y`?`top`:`left`,t=f===`y`?`bottom`:`right`,n=h+d[e],r=h-d[t];h=x(n,h,r)}let g=c.fn({...t,[p]:m,[f]:h});return{...g,data:{x:g.x-n,y:g.y-r,enabled:{[p]:o,[f]:s}}}}}},me=function(e){return e===void 0&&(e={}),{options:e,fn(t){let{x:n,y:r,placement:i,rects:a,middlewareData:o}=t,{offset:s=0,mainAxis:c=!0,crossAxis:l=!0}=S(e,t),u={x:n,y:r},d=D(i),f=T(d),p=u[f],m=u[d],h=S(s,t),g=typeof h==`number`?{mainAxis:h,crossAxis:0}:{mainAxis:0,crossAxis:0,...h};if(c){let e=f===`y`?`height`:`width`,t=a.reference[f]-a.floating[e]+g.mainAxis,n=a.reference[f]+a.reference[e]-g.mainAxis;p<t?p=t:p>n&&(p=n)}if(l){let e=f===`y`?`width`:`height`,t=ue.has(C(i)),n=a.reference[d]-a.floating[e]+(t&&o.offset?.[d]||0)+(t?0:g.crossAxis),r=a.reference[d]+a.reference[e]+(t?0:o.offset?.[d]||0)-(t?g.crossAxis:0);m<n?m=n:m>r&&(m=r)}return{[f]:p,[d]:m}}}},he=function(e){return e===void 0&&(e={}),{name:`size`,options:e,async fn(t){var n,r;let{placement:i,rects:a,platform:o,elements:s}=t,{apply:c=()=>{},...l}=S(e,t),u=await o.detectOverflow(t,l),d=C(i),f=w(i),p=D(i)===`y`,{width:m,height:_}=a.floating,v,y;d===`top`||d===`bottom`?(v=d,y=f===(await(o.isRTL==null?void 0:o.isRTL(s.floating))?`start`:`end`)?`left`:`right`):(y=d,v=f===`end`?`top`:`bottom`);let b=_-u.top-u.bottom,x=m-u.left-u.right,T=h(_-u[v],b),E=h(m-u[y],x),O=!t.middlewareData.shift,k=T,A=E;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(A=x),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(k=b),O&&!f){let e=g(u.left,0),t=g(u.right,0),n=g(u.top,0),r=g(u.bottom,0);p?A=m-2*(e!==0||t!==0?e+t:g(u.left,u.right)):k=_-2*(n!==0||r!==0?n+r:g(u.top,u.bottom))}await c({...t,availableWidth:A,availableHeight:k});let j=await o.getDimensions(s.floating);return m!==j.width||_!==j.height?{reset:{rects:!0}}:{}}}};function ge(){return typeof window<`u`}function V(e){return _e(e)?(e.nodeName||``).toLowerCase():`#document`}function H(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function U(e){return((_e(e)?e.ownerDocument:e.document)||window.document)?.documentElement}function _e(e){return ge()?e instanceof Node||e instanceof H(e).Node:!1}function W(e){return ge()?e instanceof Element||e instanceof H(e).Element:!1}function G(e){return ge()?e instanceof HTMLElement||e instanceof H(e).HTMLElement:!1}function ve(e){return!ge()||typeof ShadowRoot>`u`?!1:e instanceof ShadowRoot||e instanceof H(e).ShadowRoot}function K(e){let{overflow:t,overflowX:n,overflowY:r,display:i}=Y(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!==`inline`&&i!==`contents`}function ye(e){return/^(table|td|th)$/.test(V(e))}function be(e){try{if(e.matches(`:popover-open`))return!0}catch{}try{return e.matches(`:modal`)}catch{return!1}}var xe=/transform|translate|scale|rotate|perspective|filter/,Se=/paint|layout|strict|content/,q=e=>!!e&&e!==`none`,Ce;function we(e){let t=W(e)?Y(e):e;return q(t.transform)||q(t.translate)||q(t.scale)||q(t.rotate)||q(t.perspective)||!Ee()&&(q(t.backdropFilter)||q(t.filter))||xe.test(t.willChange||``)||Se.test(t.contain||``)}function Te(e){let t=X(e);for(;G(t)&&!J(t);){if(we(t))return t;if(be(t))return null;t=X(t)}return null}function Ee(){return Ce??=typeof CSS<`u`&&CSS.supports&&CSS.supports(`-webkit-backdrop-filter`,`none`),Ce}function J(e){return/^(html|body|#document)$/.test(V(e))}function Y(e){return H(e).getComputedStyle(e)}function De(e){return W(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function X(e){if(V(e)===`html`)return e;let t=e.assignedSlot||e.parentNode||ve(e)&&e.host||U(e);return ve(t)?t.host:t}function Oe(e){let t=X(e);return J(t)?e.ownerDocument?e.ownerDocument.body:e.body:G(t)&&K(t)?t:Oe(t)}function Z(e,t,n){t===void 0&&(t=[]),n===void 0&&(n=!0);let r=Oe(e),i=r===e.ownerDocument?.body,a=H(r);if(i){let e=ke(a);return t.concat(a,a.visualViewport||[],K(r)?r:[],e&&n?Z(e):[])}else return t.concat(r,Z(r,[],n))}function ke(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function Ae(e){let t=Y(e),n=parseFloat(t.width)||0,r=parseFloat(t.height)||0,i=G(e),a=i?e.offsetWidth:n,o=i?e.offsetHeight:r,s=_(n)!==a||_(r)!==o;return s&&(n=a,r=o),{width:n,height:r,$:s}}function je(e){return W(e)?e:e.contextElement}function Q(e){let t=je(e);if(!G(t))return y(1);let n=t.getBoundingClientRect(),{width:r,height:i,$:a}=Ae(t),o=(a?_(n.width):n.width)/r,s=(a?_(n.height):n.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!s||!Number.isFinite(s))&&(s=1),{x:o,y:s}}var Me=y(0);function Ne(e){let t=H(e);return!Ee()||!t.visualViewport?Me:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Pe(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==H(e)?!1:t}function $(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);let i=e.getBoundingClientRect(),a=je(e),o=y(1);t&&(r?W(r)&&(o=Q(r)):o=Q(e));let s=Pe(a,n,r)?Ne(a):y(0),c=(i.left+s.x)/o.x,l=(i.top+s.y)/o.y,u=i.width/o.x,d=i.height/o.y;if(a){let e=H(a),t=r&&W(r)?H(r):r,n=e,i=ke(n);for(;i&&r&&t!==n;){let e=Q(i),t=i.getBoundingClientRect(),r=Y(i),a=t.left+(i.clientLeft+parseFloat(r.paddingLeft))*e.x,o=t.top+(i.clientTop+parseFloat(r.paddingTop))*e.y;c*=e.x,l*=e.y,u*=e.x,d*=e.y,c+=a,l+=o,n=H(i),i=ke(n)}}return B({width:u,height:d,x:c,y:l})}function Fe(e,t){let n=De(e).scrollLeft;return t?t.left+n:$(U(e)).left+n}function Ie(e,t){let n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-Fe(e,n),y:n.top+t.scrollTop}}function Le(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e,a=i===`fixed`,o=U(r),s=t?be(t.floating):!1;if(r===o||s&&a)return n;let c={scrollLeft:0,scrollTop:0},l=y(1),u=y(0),d=G(r);if((d||!d&&!a)&&((V(r)!==`body`||K(o))&&(c=De(r)),d)){let e=$(r);l=Q(r),u.x=e.x+r.clientLeft,u.y=e.y+r.clientTop}let f=o&&!d&&!a?Ie(o,c):y(0);return{width:n.width*l.x,height:n.height*l.y,x:n.x*l.x-c.scrollLeft*l.x+u.x+f.x,y:n.y*l.y-c.scrollTop*l.y+u.y+f.y}}function Re(e){return Array.from(e.getClientRects())}function ze(e){let t=U(e),n=De(e),r=e.ownerDocument.body,i=g(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),a=g(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight),o=-n.scrollLeft+Fe(e),s=-n.scrollTop;return Y(r).direction===`rtl`&&(o+=g(t.clientWidth,r.clientWidth)-i),{width:i,height:a,x:o,y:s}}var Be=25;function Ve(e,t){let n=H(e),r=U(e),i=n.visualViewport,a=r.clientWidth,o=r.clientHeight,s=0,c=0;if(i){a=i.width,o=i.height;let e=Ee();(!e||e&&t===`fixed`)&&(s=i.offsetLeft,c=i.offsetTop)}let l=Fe(r);if(l<=0){let e=r.ownerDocument,t=e.body,n=getComputedStyle(t),i=e.compatMode===`CSS1Compat`&&parseFloat(n.marginLeft)+parseFloat(n.marginRight)||0,o=Math.abs(r.clientWidth-t.clientWidth-i);o<=Be&&(a-=o)}else l<=Be&&(a+=l);return{width:a,height:o,x:s,y:c}}function He(e,t){let n=$(e,!0,t===`fixed`),r=n.top+e.clientTop,i=n.left+e.clientLeft,a=G(e)?Q(e):y(1);return{width:e.clientWidth*a.x,height:e.clientHeight*a.y,x:i*a.x,y:r*a.y}}function Ue(e,t,n){let r;if(t===`viewport`)r=Ve(e,n);else if(t===`document`)r=ze(U(e));else if(W(t))r=He(t,n);else{let n=Ne(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return B(r)}function We(e,t){let n=X(e);return n===t||!W(n)||J(n)?!1:Y(n).position===`fixed`||We(n,t)}function Ge(e,t){let n=t.get(e);if(n)return n;let r=Z(e,[],!1).filter(e=>W(e)&&V(e)!==`body`),i=null,a=Y(e).position===`fixed`,o=a?X(e):e;for(;W(o)&&!J(o);){let t=Y(o),n=we(o);!n&&t.position===`fixed`&&(i=null),(a?!n&&!i:!n&&t.position===`static`&&i&&(i.position===`absolute`||i.position===`fixed`)||K(o)&&!n&&We(e,o))?r=r.filter(e=>e!==o):i=t,o=X(o)}return t.set(e,r),r}function Ke(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e,a=[...n===`clippingAncestors`?be(t)?[]:Ge(t,this._c):[].concat(n),r],o=Ue(t,a[0],i),s=o.top,c=o.right,l=o.bottom,u=o.left;for(let e=1;e<a.length;e++){let n=Ue(t,a[e],i);s=g(n.top,s),c=h(n.right,c),l=h(n.bottom,l),u=g(n.left,u)}return{width:c-u,height:l-s,x:u,y:s}}function qe(e){let{width:t,height:n}=Ae(e);return{width:t,height:n}}function Je(e,t,n){let r=G(t),i=U(t),a=n===`fixed`,o=$(e,!0,a,t),s={scrollLeft:0,scrollTop:0},c=y(0);function l(){c.x=Fe(i)}if(r||!r&&!a)if((V(t)!==`body`||K(i))&&(s=De(t)),r){let e=$(t,!0,a,t);c.x=e.x+t.clientLeft,c.y=e.y+t.clientTop}else i&&l();a&&!r&&i&&l();let u=i&&!r&&!a?Ie(i,s):y(0);return{x:o.left+s.scrollLeft-c.x-u.x,y:o.top+s.scrollTop-c.y-u.y,width:o.width,height:o.height}}function Ye(e){return Y(e).position===`static`}function Xe(e,t){if(!G(e)||Y(e).position===`fixed`)return null;if(t)return t(e);let n=e.offsetParent;return U(e)===n&&(n=n.ownerDocument.body),n}function Ze(e,t){let n=H(e);if(be(e))return n;if(!G(e)){let t=X(e);for(;t&&!J(t);){if(W(t)&&!Ye(t))return t;t=X(t)}return n}let r=Xe(e,t);for(;r&&ye(r)&&Ye(r);)r=Xe(r,t);return r&&J(r)&&Ye(r)&&!we(r)?n:r||Te(e)||n}var Qe=async function(e){let t=this.getOffsetParent||Ze,n=this.getDimensions,r=await n(e.floating);return{reference:Je(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function $e(e){return Y(e).direction===`rtl`}var et={convertOffsetParentRelativeRectToViewportRelativeRect:Le,getDocumentElement:U,getClippingRect:Ke,getOffsetParent:Ze,getElementRects:Qe,getClientRects:Re,getDimensions:qe,getScale:Q,isElement:W,isRTL:$e};function tt(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function nt(e,t){let n=null,r,i=U(e);function a(){var e;clearTimeout(r),(e=n)==null||e.disconnect(),n=null}function o(s,c){s===void 0&&(s=!1),c===void 0&&(c=1),a();let l=e.getBoundingClientRect(),{left:u,top:d,width:f,height:p}=l;if(s||t(),!f||!p)return;let m=v(d),_=v(i.clientWidth-(u+f)),y=v(i.clientHeight-(d+p)),b=v(u),x={rootMargin:-m+`px `+-_+`px `+-y+`px `+-b+`px`,threshold:g(0,h(1,c))||1},S=!0;function C(t){let n=t[0].intersectionRatio;if(n!==c){if(!S)return o();n?o(!1,n):r=setTimeout(()=>{o(!1,1e-7)},1e3)}n===1&&!tt(l,e.getBoundingClientRect())&&o(),S=!1}try{n=new IntersectionObserver(C,{...x,root:i.ownerDocument})}catch{n=new IntersectionObserver(C,x)}n.observe(e)}return o(!0),a}function rt(e,t,n,r){r===void 0&&(r={});let{ancestorScroll:i=!0,ancestorResize:a=!0,elementResize:o=typeof ResizeObserver==`function`,layoutShift:s=typeof IntersectionObserver==`function`,animationFrame:c=!1}=r,l=je(e),u=i||a?[...l?Z(l):[],...t?Z(t):[]]:[];u.forEach(e=>{i&&e.addEventListener(`scroll`,n,{passive:!0}),a&&e.addEventListener(`resize`,n)});let d=l&&s?nt(l,n):null,f=-1,p=null;o&&(p=new ResizeObserver(e=>{let[r]=e;r&&r.target===l&&p&&t&&(p.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var e;(e=p)==null||e.observe(t)})),n()}),l&&!c&&p.observe(l),t&&p.observe(t));let m,h=c?$(e):null;c&&g();function g(){let t=$(e);h&&!tt(h,t)&&n(),h=t,m=requestAnimationFrame(g)}return n(),()=>{var e;u.forEach(e=>{i&&e.removeEventListener(`scroll`,n),a&&e.removeEventListener(`resize`,n)}),d?.(),(e=p)==null||e.disconnect(),p=null,c&&cancelAnimationFrame(m)}}var it=fe,at=pe,ot=oe,st=he,ct=le,lt=ae,ut=me,dt=(e,t,n)=>{let r=new Map,i={platform:et,...n},a={...i.platform,_c:r};return ie(e,t,{...i,platform:a})},ft=e(l(),1),pt=typeof document<`u`?u.useLayoutEffect:function(){};function mt(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e==`function`&&e.toString()===t.toString())return!0;let n,r,i;if(e&&t&&typeof e==`object`){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!mt(e[r],t[r]))return!1;return!0}if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,i[r]))return!1;for(r=n;r--!==0;){let n=i[r];if(!(n===`_owner`&&e.$$typeof)&&!mt(e[n],t[n]))return!1}return!0}return e!==e&&t!==t}function ht(e){return typeof window>`u`?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function gt(e,t){let n=ht(e);return Math.round(t*n)/n}function _t(e){let t=u.useRef(e);return pt(()=>{t.current=e}),t}function vt(e){e===void 0&&(e={});let{placement:t=`bottom`,strategy:n=`absolute`,middleware:r=[],platform:i,elements:{reference:a,floating:o}={},transform:s=!0,whileElementsMounted:c,open:l}=e,[d,f]=u.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[p,m]=u.useState(r);mt(p,r)||m(r);let[h,g]=u.useState(null),[_,v]=u.useState(null),y=u.useCallback(e=>{e!==C.current&&(C.current=e,g(e))},[]),b=u.useCallback(e=>{e!==w.current&&(w.current=e,v(e))},[]),x=a||h,S=o||_,C=u.useRef(null),w=u.useRef(null),T=u.useRef(d),E=c!=null,D=_t(c),O=_t(i),k=_t(l),A=u.useCallback(()=>{if(!C.current||!w.current)return;let e={placement:t,strategy:n,middleware:p};O.current&&(e.platform=O.current),dt(C.current,w.current,e).then(e=>{let t={...e,isPositioned:k.current!==!1};j.current&&!mt(T.current,t)&&(T.current=t,ft.flushSync(()=>{f(t)}))})},[p,t,n,O,k]);pt(()=>{l===!1&&T.current.isPositioned&&(T.current.isPositioned=!1,f(e=>({...e,isPositioned:!1})))},[l]);let j=u.useRef(!1);pt(()=>(j.current=!0,()=>{j.current=!1}),[]),pt(()=>{if(x&&(C.current=x),S&&(w.current=S),x&&S){if(D.current)return D.current(x,S,A);A()}},[x,S,A,D,E]);let M=u.useMemo(()=>({reference:C,floating:w,setReference:y,setFloating:b}),[y,b]),N=u.useMemo(()=>({reference:x,floating:S}),[x,S]),P=u.useMemo(()=>{let e={position:n,left:0,top:0};if(!N.floating)return e;let t=gt(N.floating,d.x),r=gt(N.floating,d.y);return s?{...e,transform:`translate(`+t+`px, `+r+`px)`,...ht(N.floating)>=1.5&&{willChange:`transform`}}:{position:n,left:t,top:r}},[n,s,N.floating,d.x,d.y]);return u.useMemo(()=>({...d,update:A,refs:M,elements:N,floatingStyles:P}),[d,A,M,N,P])}var yt=e=>{function t(e){return{}.hasOwnProperty.call(e,`current`)}return{name:`arrow`,options:e,fn(n){let{element:r,padding:i}=typeof e==`function`?e(n):e;return r&&t(r)?r.current==null?{}:lt({element:r.current,padding:i}).fn(n):r?lt({element:r,padding:i}).fn(n):{}}}},bt=(e,t)=>{let n=it(e);return{name:n.name,fn:n.fn,options:[e,t]}},xt=(e,t)=>{let n=at(e);return{name:n.name,fn:n.fn,options:[e,t]}},St=(e,t)=>({fn:ut(e).fn,options:[e,t]}),Ct=(e,t)=>{let n=ot(e);return{name:n.name,fn:n.fn,options:[e,t]}},wt=(e,t)=>{let n=st(e);return{name:n.name,fn:n.fn,options:[e,t]}},Tt=(e,t)=>{let n=ct(e);return{name:n.name,fn:n.fn,options:[e,t]}},Et=(e,t)=>{let n=yt(e);return{name:n.name,fn:n.fn,options:[e,t]}},Dt=`Arrow`,Ot=u.forwardRef((e,t)=>{let{children:n,width:r=10,height:i=5,...a}=e;return(0,d.jsx)(s.svg,{...a,ref:t,width:r,height:i,viewBox:`0 0 30 10`,preserveAspectRatio:`none`,children:e.asChild?n:(0,d.jsx)(`polygon`,{points:`0,0 30,0 15,10`})})});Ot.displayName=Dt;var kt=Ot,At=`Popper`,[jt,Mt]=c(At),[Nt,Pt]=jt(At),Ft=e=>{let{__scopePopper:t,children:n}=e,[r,i]=u.useState(null);return(0,d.jsx)(Nt,{scope:t,anchor:r,onAnchorChange:i,children:n})};Ft.displayName=At;var It=`PopperAnchor`,Lt=u.forwardRef((e,t)=>{let{__scopePopper:n,virtualRef:r,...a}=e,o=Pt(It,n),c=u.useRef(null),l=i(t,c),f=u.useRef(null);return u.useEffect(()=>{let e=f.current;f.current=r?.current||c.current,e!==f.current&&o.onAnchorChange(f.current)}),r?null:(0,d.jsx)(s.div,{...a,ref:l})});Lt.displayName=It;var Rt=`PopperContent`,[zt,Bt]=jt(Rt),Vt=u.forwardRef((e,t)=>{let{__scopePopper:n,side:r=`bottom`,sideOffset:c=0,align:l=`center`,alignOffset:f=0,arrowPadding:m=0,avoidCollisions:h=!0,collisionBoundary:g=[],collisionPadding:_=0,sticky:v=`partial`,hideWhenDetached:y=!1,updatePositionStrategy:b=`optimized`,onPlaced:x,...S}=e,C=Pt(Rt,n),[w,T]=u.useState(null),E=i(t,e=>T(e)),[D,O]=u.useState(null),k=p(D),A=k?.width??0,j=k?.height??0,M=r+(l===`center`?``:`-`+l),N=typeof _==`number`?_:{top:0,right:0,bottom:0,left:0,..._},P=Array.isArray(g)?g:[g],ee=P.length>0,F={padding:N,boundary:P.filter(Gt),altBoundary:ee},{refs:I,floatingStyles:L,placement:R,isPositioned:z,middlewareData:B}=vt({strategy:`fixed`,placement:M,whileElementsMounted:(...e)=>rt(...e,{animationFrame:b===`always`}),elements:{reference:C.anchor},middleware:[bt({mainAxis:c+j,alignmentAxis:f}),h&&xt({mainAxis:!0,crossAxis:!1,limiter:v===`partial`?St():void 0,...F}),h&&Ct({...F}),wt({...F,apply:({elements:e,rects:t,availableWidth:n,availableHeight:r})=>{let{width:i,height:a}=t.reference,o=e.floating.style;o.setProperty(`--radix-popper-available-width`,`${n}px`),o.setProperty(`--radix-popper-available-height`,`${r}px`),o.setProperty(`--radix-popper-anchor-width`,`${i}px`),o.setProperty(`--radix-popper-anchor-height`,`${a}px`)}}),D&&Et({element:D,padding:m}),Kt({arrowWidth:A,arrowHeight:j}),y&&Tt({strategy:`referenceHidden`,...F})]}),[te,ne]=qt(R),re=a(x);o(()=>{z&&re?.()},[z,re]);let ie=B.arrow?.x,ae=B.arrow?.y,oe=B.arrow?.centerOffset!==0,[se,ce]=u.useState();return o(()=>{w&&ce(window.getComputedStyle(w).zIndex)},[w]),(0,d.jsx)(`div`,{ref:I.setFloating,"data-radix-popper-content-wrapper":``,style:{...L,transform:z?L.transform:`translate(0, -200%)`,minWidth:`max-content`,zIndex:se,"--radix-popper-transform-origin":[B.transformOrigin?.x,B.transformOrigin?.y].join(` `),...B.hide?.referenceHidden&&{visibility:`hidden`,pointerEvents:`none`}},dir:e.dir,children:(0,d.jsx)(zt,{scope:n,placedSide:te,onArrowChange:O,arrowX:ie,arrowY:ae,shouldHideArrow:oe,children:(0,d.jsx)(s.div,{"data-side":te,"data-align":ne,...S,ref:E,style:{...S.style,animation:z?void 0:`none`}})})})});Vt.displayName=Rt;var Ht=`PopperArrow`,Ut={top:`bottom`,right:`left`,bottom:`top`,left:`right`},Wt=u.forwardRef(function(e,t){let{__scopePopper:n,...r}=e,i=Bt(Ht,n),a=Ut[i.placedSide];return(0,d.jsx)(`span`,{ref:i.onArrowChange,style:{position:`absolute`,left:i.arrowX,top:i.arrowY,[a]:0,transformOrigin:{top:``,right:`0 0`,bottom:`center 0`,left:`100% 0`}[i.placedSide],transform:{top:`translateY(100%)`,right:`translateY(50%) rotate(90deg) translateX(-50%)`,bottom:`rotate(180deg)`,left:`translateY(50%) rotate(-90deg) translateX(50%)`}[i.placedSide],visibility:i.shouldHideArrow?`hidden`:void 0},children:(0,d.jsx)(kt,{...r,ref:t,style:{...r.style,display:`block`}})})});Wt.displayName=Ht;function Gt(e){return e!==null}var Kt=e=>({name:`transformOrigin`,options:e,fn(t){let{placement:n,rects:r,middlewareData:i}=t,a=i.arrow?.centerOffset!==0,o=a?0:e.arrowWidth,s=a?0:e.arrowHeight,[c,l]=qt(n),u={start:`0%`,center:`50%`,end:`100%`}[l],d=(i.arrow?.x??0)+o/2,f=(i.arrow?.y??0)+s/2,p=``,m=``;return c===`bottom`?(p=a?u:`${d}px`,m=`${-s}px`):c===`top`?(p=a?u:`${d}px`,m=`${r.floating.height+s}px`):c===`right`?(p=`${-s}px`,m=a?u:`${f}px`):c===`left`&&(p=`${r.floating.width+s}px`,m=a?u:`${f}px`),{data:{x:p,y:m}}}});function qt(e){let[t,n=`center`]=e.split(`-`);return[t,n]}var Jt=Ft,Yt=Lt,Xt=Vt,Zt=Wt;export{Mt as a,Jt as i,Zt as n,f as o,Xt as r,Yt as t};