vzcode 1.30.0 → 1.30.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.
|
@@ -124,16 +124,16 @@ a=extmap-allow-mixed`)!==-1){const o=i.sdp.split(`
|
|
|
124
124
|
`&&n.lineWrapping&&(r&&(r=Ie.single(r.main.anchor-1,r.main.head-1)),t={from:i.from,to:i.to,insert:Fn.of([" "])}),t)return VP(n,t,r,o);if(r&&!r.main.eq(i)){let s=!1,a="select";return n.inputState.lastSelectionTime>Date.now()-50&&(n.inputState.lastSelectionOrigin=="select"&&(s=!0),a=n.inputState.lastSelectionOrigin),n.dispatch({selection:r,scrollIntoView:s,userEvent:a}),!0}else return!1}function VP(n,e,t,r=-1){if(Mt.ios&&n.inputState.flushIOSKey(e))return!0;let i=n.state.selection.main;if(Mt.android&&(e.to==i.to&&(e.from==i.from||e.from==i.from-1&&n.state.sliceDoc(e.from,i.from)==" ")&&e.insert.length==1&&e.insert.lines==2&&vf(n.contentDOM,"Enter",13)||(e.from==i.from-1&&e.to==i.to&&e.insert.length==0||r==8&&e.insert.length<e.to-e.from&&e.to>i.head)&&vf(n.contentDOM,"Backspace",8)||e.from==i.from&&e.to==i.to+1&&e.insert.length==0&&vf(n.contentDOM,"Delete",46)))return!0;let o=e.insert.toString();n.inputState.composing>=0&&n.inputState.composing++;let s,a=()=>s||(s=R9(n,e,t));return n.state.facet(gN).some(l=>l(n,e.from,e.to,o,a))||n.dispatch(a()),!0}function R9(n,e,t){let r,i=n.state,o=i.selection.main;if(e.from>=o.from&&e.to<=o.to&&e.to-e.from>=(o.to-o.from)/3&&(!t||t.main.empty&&t.main.from==e.from+e.insert.length)&&n.inputState.composing<0){let a=o.from<e.from?i.sliceDoc(o.from,e.from):"",l=o.to>e.to?i.sliceDoc(e.to,o.to):"";r=i.replaceSelection(n.state.toText(a+e.insert.sliceString(0,void 0,n.state.lineBreak)+l))}else{let a=i.changes(e),l=t&&t.main.to<=a.newLength?t.main:void 0;if(i.selection.ranges.length>1&&n.inputState.composing>=0&&e.to<=o.to&&e.to>=o.to-10){let c=n.state.sliceDoc(e.from,e.to),u,d=t&&CN(n,t.main.head);if(d){let g=e.insert.length-(e.to-e.from);u={from:d.from,to:d.to-g}}else u=n.state.doc.lineAt(o.head);let h=o.to-e.to,p=o.to-o.from;r=i.changeByRange(g=>{if(g.from==o.from&&g.to==o.to)return{changes:a,range:l||g.map(a)};let O=g.to-h,v=O-c.length;if(g.to-g.from!=p||n.state.sliceDoc(v,O)!=c||g.to>=u.from&&g.from<=u.to)return{range:g};let b=i.changes({from:v,to:O,insert:e.insert}),S=g.to-o.to;return{changes:b,range:l?Ie.range(Math.max(0,l.anchor+S),Math.max(0,l.head+S)):g.map(b)}})}else r={changes:a,selection:l&&i.selection.replaceRange(l)}}let s="input.type";return(n.composing||n.inputState.compositionPendingChange&&n.inputState.compositionEndedAt>Date.now()-50)&&(n.inputState.compositionPendingChange=!1,s+=".compose",n.inputState.compositionFirstChange&&(s+=".start",n.inputState.compositionFirstChange=!1)),i.update(r,{userEvent:s,scrollIntoView:!0})}function A9(n,e,t,r){let i=Math.min(n.length,e.length),o=0;for(;o<i&&n.charCodeAt(o)==e.charCodeAt(o);)o++;if(o==i&&n.length==e.length)return null;let s=n.length,a=e.length;for(;s>0&&a>0&&n.charCodeAt(s-1)==e.charCodeAt(a-1);)s--,a--;if(r=="end"){let l=Math.max(0,o-Math.min(s,a));t-=s+l-o}if(s<o&&n.length<e.length){let l=t<=o&&t>=s?o-t:0;o-=l,a=o+(a-s),s=o}else if(a<o){let l=t<=o&&t>=a?o-t:0;o-=l,s=o+(s-a),a=o}return{from:o,toA:s,toB:a}}function M9(n){let e=[];if(n.root.activeElement!=n.contentDOM)return e;let{anchorNode:t,anchorOffset:r,focusNode:i,focusOffset:o}=n.observer.selectionRange;return t&&(e.push(new ER(t,r)),(i!=t||o!=r)&&e.push(new ER(i,o))),e}function $9(n,e){if(n.length==0)return null;let t=n[0].pos,r=n.length==2?n[1].pos:t;return t>-1&&r>-1?Ie.single(t+e,r+e):null}class D9{setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}constructor(e){this.view=e,this.lastKeyCode=0,this.lastKeyTime=0,this.lastTouchTime=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.pendingIOSKey=void 0,this.tabFocusMode=-1,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=e.hasFocus,Mt.safari&&e.contentDOM.addEventListener("input",()=>null),Mt.gecko&&G9(e.contentDOM.ownerDocument)}handleEvent(e){!B9(this.view,e)||this.ignoreDuringComposition(e)||e.type=="keydown"&&this.keydown(e)||(this.view.updateState!=0?Promise.resolve().then(()=>this.runHandlers(e.type,e)):this.runHandlers(e.type,e))}runHandlers(e,t){let r=this.handlers[e];if(r){for(let i of r.observers)i(this.view,t);for(let i of r.handlers){if(t.defaultPrevented)break;if(i(this.view,t)){t.preventDefault();break}}}}ensureHandlers(e){let t=Q9(e),r=this.handlers,i=this.view.contentDOM;for(let o in t)if(o!="scroll"){let s=!t[o].handlers.length,a=r[o];a&&s!=!a.handlers.length&&(i.removeEventListener(o,this.handleEvent),a=null),a||i.addEventListener(o,this.handleEvent,{passive:s})}for(let o in r)o!="scroll"&&!t[o]&&i.removeEventListener(o,this.handleEvent);this.handlers=t}keydown(e){if(this.lastKeyCode=e.keyCode,this.lastKeyTime=Date.now(),e.keyCode==9&&this.tabFocusMode>-1&&(!this.tabFocusMode||Date.now()<=this.tabFocusMode))return!0;if(this.tabFocusMode>0&&e.keyCode!=27&&RN.indexOf(e.keyCode)<0&&(this.tabFocusMode=-1),Mt.android&&Mt.chrome&&!e.synthetic&&(e.keyCode==13||e.keyCode==8))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;let t;return Mt.ios&&!e.synthetic&&!e.altKey&&!e.metaKey&&((t=EN.find(r=>r.keyCode==e.keyCode))&&!e.ctrlKey||I9.indexOf(e.key)>-1&&e.ctrlKey&&!e.shiftKey)?(this.pendingIOSKey=t||e,setTimeout(()=>this.flushIOSKey(),250),!0):(e.keyCode!=229&&this.view.observer.forceFlush(),!1)}flushIOSKey(e){let t=this.pendingIOSKey;return!t||t.key=="Enter"&&e&&e.from<e.to&&/^\S+$/.test(e.insert.toString())?!1:(this.pendingIOSKey=void 0,vf(this.view.contentDOM,t.key,t.keyCode,t instanceof KeyboardEvent?t:void 0))}ignoreDuringComposition(e){return/^key/.test(e.type)?this.composing>0?!0:Mt.safari&&!Mt.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100?(this.compositionPendingKey=!1,!0):!1:!1}startMouseSelection(e){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=e}update(e){this.view.observer.update(e),this.mouseSelection&&this.mouseSelection.update(e),this.draggedContent&&e.docChanged&&(this.draggedContent=this.draggedContent.map(e.changes)),e.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}}function RR(n,e){return(t,r)=>{try{return e.call(n,r,t)}catch(i){mo(t.state,i)}}}function Q9(n){let e=Object.create(null);function t(r){return e[r]||(e[r]={observers:[],handlers:[]})}for(let r of n){let i=r.spec;if(i&&i.domEventHandlers)for(let o in i.domEventHandlers){let s=i.domEventHandlers[o];s&&t(o).handlers.push(RR(r.value,s))}if(i&&i.domEventObservers)for(let o in i.domEventObservers){let s=i.domEventObservers[o];s&&t(o).observers.push(RR(r.value,s))}}for(let r in Ms)t(r).handlers.push(Ms[r]);for(let r in os)t(r).observers.push(os[r]);return e}const EN=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],I9="dthko",RN=[16,17,18,20,91,92,224,225],Rm=6;function Am(n){return Math.max(0,n)*.7+8}function j9(n,e){return Math.max(Math.abs(n.clientX-e.clientX),Math.abs(n.clientY-e.clientY))}class L9{constructor(e,t,r,i){this.view=e,this.startEvent=t,this.style=r,this.mustSelect=i,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=t,this.scrollParents=WZ(e.contentDOM),this.atoms=e.state.facet(BP).map(s=>s(e));let o=e.contentDOM.ownerDocument;o.addEventListener("mousemove",this.move=this.move.bind(this)),o.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=t.shiftKey,this.multiple=e.state.facet(Un.allowMultipleSelections)&&N9(e,t),this.dragging=U9(e,t)&&$N(t)==1?null:!1}start(e){this.dragging===!1&&this.select(e)}move(e){if(e.buttons==0)return this.destroy();if(this.dragging||this.dragging==null&&j9(this.startEvent,e)<10)return;this.select(this.lastEvent=e);let t=0,r=0,i=0,o=0,s=this.view.win.innerWidth,a=this.view.win.innerHeight;this.scrollParents.x&&({left:i,right:s}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:o,bottom:a}=this.scrollParents.y.getBoundingClientRect());let l=FP(this.view);e.clientX-l.left<=i+Rm?t=-Am(i-e.clientX):e.clientX+l.right>=s-Rm&&(t=Am(e.clientX-s)),e.clientY-l.top<=o+Rm?r=-Am(o-e.clientY):e.clientY+l.bottom>=a-Rm&&(r=Am(e.clientY-a)),this.setScrollSpeed(t,r)}up(e){this.dragging==null&&this.select(this.lastEvent),this.dragging||e.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let e=this.view.contentDOM.ownerDocument;e.removeEventListener("mousemove",this.move),e.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=this.view.inputState.draggedContent=null}setScrollSpeed(e,t){this.scrollSpeed={x:e,y:t},e||t?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){let{x:e,y:t}=this.scrollSpeed;e&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=e,e=0),t&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=t,t=0),(e||t)&&this.view.win.scrollBy(e,t),this.dragging===!1&&this.select(this.lastEvent)}skipAtoms(e){let t=null;for(let r=0;r<e.ranges.length;r++){let i=e.ranges[r],o=null;if(i.empty){let s=TO(this.atoms,i.from,0);s!=i.from&&(o=Ie.cursor(s,-1))}else{let s=TO(this.atoms,i.from,-1),a=TO(this.atoms,i.to,1);(s!=i.from||a!=i.to)&&(o=Ie.range(i.from==i.anchor?s:a,i.from==i.head?s:a))}o&&(t||(t=e.ranges.slice()),t[r]=o)}return t?Ie.create(t,e.mainIndex):e}select(e){let{view:t}=this,r=this.skipAtoms(this.style.get(e,this.extend,this.multiple));(this.mustSelect||!r.eq(t.state.selection,this.dragging===!1))&&this.view.dispatch({selection:r,userEvent:"select.pointer"}),this.mustSelect=!1}update(e){e.transactions.some(t=>t.isUserEvent("input.type"))?this.destroy():this.style.update(e)&&setTimeout(()=>this.select(this.lastEvent),20)}}function N9(n,e){let t=n.state.facet(dN);return t.length?t[0](e):Mt.mac?e.metaKey:e.ctrlKey}function q9(n,e){let t=n.state.facet(hN);return t.length?t[0](e):Mt.mac?!e.altKey:!e.ctrlKey}function U9(n,e){let{main:t}=n.state.selection;if(t.empty)return!1;let r=$h(n.root);if(!r||r.rangeCount==0)return!0;let i=r.getRangeAt(0).getClientRects();for(let o=0;o<i.length;o++){let s=i[o];if(s.left<=e.clientX&&s.right>=e.clientX&&s.top<=e.clientY&&s.bottom>=e.clientY)return!0}return!1}function B9(n,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target,r;t!=n.contentDOM;t=t.parentNode)if(!t||t.nodeType==11||(r=lr.get(t))&&r.ignoreEvent(e))return!1;return!0}const Ms=Object.create(null),os=Object.create(null),AN=Mt.ie&&Mt.ie_version<15||Mt.ios&&Mt.webkit_version<604;function F9(n){let e=n.dom.parentNode;if(!e)return;let t=e.appendChild(document.createElement("textarea"));t.style.cssText="position: fixed; left: -10000px; top: 10px",t.focus(),setTimeout(()=>{n.focus(),t.remove(),MN(n,t.value)},50)}function iy(n,e,t){for(let r of n.facet(e))t=r(t,n);return t}function MN(n,e){e=iy(n.state,NP,e);let{state:t}=n,r,i=1,o=t.toText(e),s=o.lines==t.selection.ranges.length;if(ak!=null&&t.selection.ranges.every(l=>l.empty)&&ak==o.toString()){let l=-1;r=t.changeByRange(c=>{let u=t.doc.lineAt(c.from);if(u.from==l)return{range:c};l=u.from;let d=t.toText((s?o.line(i++).text:e)+t.lineBreak);return{changes:{from:u.from,insert:d},range:Ie.cursor(c.from+d.length)}})}else s?r=t.changeByRange(l=>{let c=o.line(i++);return{changes:{from:l.from,to:l.to,insert:c.text},range:Ie.cursor(l.from+c.length)}}):r=t.replaceSelection(o);n.dispatch(r,{userEvent:"input.paste",scrollIntoView:!0})}os.scroll=n=>{n.inputState.lastScrollTop=n.scrollDOM.scrollTop,n.inputState.lastScrollLeft=n.scrollDOM.scrollLeft};Ms.keydown=(n,e)=>(n.inputState.setSelectionOrigin("select"),e.keyCode==27&&n.inputState.tabFocusMode!=0&&(n.inputState.tabFocusMode=Date.now()+2e3),!1);os.touchstart=(n,e)=>{n.inputState.lastTouchTime=Date.now(),n.inputState.setSelectionOrigin("select.pointer")};os.touchmove=n=>{n.inputState.setSelectionOrigin("select.pointer")};Ms.mousedown=(n,e)=>{if(n.observer.flush(),n.inputState.lastTouchTime>Date.now()-2e3)return!1;let t=null;for(let r of n.state.facet(pN))if(t=r(n,e),t)break;if(!t&&e.button==0&&(t=Z9(n,e)),t){let r=!n.hasFocus;n.inputState.startMouseSelection(new L9(n,e,t,r)),r&&n.observer.ignore(()=>{XL(n.contentDOM);let o=n.root.activeElement;o&&!o.contains(n.contentDOM)&&o.blur()});let i=n.inputState.mouseSelection;if(i)return i.start(e),i.dragging===!1}return!1};function AR(n,e,t,r){if(r==1)return Ie.cursor(e,t);if(r==2)return y9(n.state,e,t);{let i=Xr.find(n.docView,e),o=n.state.doc.lineAt(i?i.posAtEnd:e),s=i?i.posAtStart:o.from,a=i?i.posAtEnd:o.to;return a<n.state.doc.length&&a==o.to&&a++,Ie.range(s,a)}}let MR=(n,e,t)=>e>=t.top&&e<=t.bottom&&n>=t.left&&n<=t.right;function V9(n,e,t,r){let i=Xr.find(n.docView,e);if(!i)return 1;let o=e-i.posAtStart;if(o==0)return 1;if(o==i.length)return-1;let s=i.coordsAt(o,-1);if(s&&MR(t,r,s))return-1;let a=i.coordsAt(o,1);return a&&MR(t,r,a)?1:s&&s.bottom>=r?-1:1}function $R(n,e){let t=n.posAtCoords({x:e.clientX,y:e.clientY},!1);return{pos:t,bias:V9(n,t,e.clientX,e.clientY)}}const W9=Mt.ie&&Mt.ie_version<=11;let DR=null,QR=0,IR=0;function $N(n){if(!W9)return n.detail;let e=DR,t=IR;return DR=n,IR=Date.now(),QR=!e||t>Date.now()-400&&Math.abs(e.clientX-n.clientX)<2&&Math.abs(e.clientY-n.clientY)<2?(QR+1)%3:1}function Z9(n,e){let t=$R(n,e),r=$N(e),i=n.state.selection;return{update(o){o.docChanged&&(t.pos=o.changes.mapPos(t.pos),i=i.map(o.changes))},get(o,s,a){let l=$R(n,o),c,u=AR(n,l.pos,l.bias,r);if(t.pos!=l.pos&&!s){let d=AR(n,t.pos,t.bias,r),h=Math.min(d.from,u.from),p=Math.max(d.to,u.to);u=h<u.from?Ie.range(h,p):Ie.range(p,h)}return s?i.replaceRange(i.main.extend(u.from,u.to)):a&&r==1&&i.ranges.length>1&&(c=X9(i,l.pos))?c:a?i.addRange(u):Ie.create([u])}}}function X9(n,e){for(let t=0;t<n.ranges.length;t++){let{from:r,to:i}=n.ranges[t];if(r<=e&&i>=e)return Ie.create(n.ranges.slice(0,t).concat(n.ranges.slice(t+1)),n.mainIndex==t?0:n.mainIndex-(n.mainIndex>t?1:0))}return null}Ms.dragstart=(n,e)=>{let{selection:{main:t}}=n.state;if(e.target.draggable){let i=n.docView.nearest(e.target);if(i&&i.isWidget){let o=i.posAtStart,s=o+i.length;(o>=t.to||s<=t.from)&&(t=Ie.range(o,s))}}let{inputState:r}=n;return r.mouseSelection&&(r.mouseSelection.dragging=!0),r.draggedContent=t,e.dataTransfer&&(e.dataTransfer.setData("Text",iy(n.state,qP,n.state.sliceDoc(t.from,t.to))),e.dataTransfer.effectAllowed="copyMove"),!1};Ms.dragend=n=>(n.inputState.draggedContent=null,!1);function jR(n,e,t,r){if(t=iy(n.state,NP,t),!t)return;let i=n.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:o}=n.inputState,s=r&&o&&q9(n,e)?{from:o.from,to:o.to}:null,a={from:i,insert:t},l=n.state.changes(s?[s,a]:a);n.focus(),n.dispatch({changes:l,selection:{anchor:l.mapPos(i,-1),head:l.mapPos(i,1)},userEvent:s?"move.drop":"input.drop"}),n.inputState.draggedContent=null}Ms.drop=(n,e)=>{if(!e.dataTransfer)return!1;if(n.state.readOnly)return!0;let t=e.dataTransfer.files;if(t&&t.length){let r=Array(t.length),i=0,o=()=>{++i==t.length&&jR(n,e,r.filter(s=>s!=null).join(n.state.lineBreak),!1)};for(let s=0;s<t.length;s++){let a=new FileReader;a.onerror=o,a.onload=()=>{/[\x00-\x08\x0e-\x1f]{2}/.test(a.result)||(r[s]=a.result),o()},a.readAsText(t[s])}return!0}else{let r=e.dataTransfer.getData("Text");if(r)return jR(n,e,r,!0),!0}return!1};Ms.paste=(n,e)=>{if(n.state.readOnly)return!0;n.observer.flush();let t=AN?null:e.clipboardData;return t?(MN(n,t.getData("text/plain")||t.getData("text/uri-list")),!0):(F9(n),!1)};function z9(n,e){let t=n.dom.parentNode;if(!t)return;let r=t.appendChild(document.createElement("textarea"));r.style.cssText="position: fixed; left: -10000px; top: 10px",r.value=e,r.focus(),r.selectionEnd=e.length,r.selectionStart=0,setTimeout(()=>{r.remove(),n.focus()},50)}function Y9(n){let e=[],t=[],r=!1;for(let i of n.selection.ranges)i.empty||(e.push(n.sliceDoc(i.from,i.to)),t.push(i));if(!e.length){let i=-1;for(let{from:o}of n.selection.ranges){let s=n.doc.lineAt(o);s.number>i&&(e.push(s.text),t.push({from:s.from,to:Math.min(n.doc.length,s.to+1)})),i=s.number}r=!0}return{text:iy(n,qP,e.join(n.lineBreak)),ranges:t,linewise:r}}let ak=null;Ms.copy=Ms.cut=(n,e)=>{let{text:t,ranges:r,linewise:i}=Y9(n.state);if(!t&&!i)return!1;ak=i?t:null,e.type=="cut"&&!n.state.readOnly&&n.dispatch({changes:r,scrollIntoView:!0,userEvent:"delete.cut"});let o=AN?null:e.clipboardData;return o?(o.clearData(),o.setData("text/plain",t),!0):(z9(n,t),!1)};const DN=ma.define();function QN(n,e){let t=[];for(let r of n.facet(ON)){let i=r(n,e);i&&t.push(i)}return t?n.update({effects:t,annotations:DN.of(!0)}):null}function IN(n){setTimeout(()=>{let e=n.hasFocus;if(e!=n.inputState.notifiedFocused){let t=QN(n.state,e);t?n.dispatch(t):n.update([])}},10)}os.focus=n=>{n.inputState.lastFocusTime=Date.now(),!n.scrollDOM.scrollTop&&(n.inputState.lastScrollTop||n.inputState.lastScrollLeft)&&(n.scrollDOM.scrollTop=n.inputState.lastScrollTop,n.scrollDOM.scrollLeft=n.inputState.lastScrollLeft),IN(n)};os.blur=n=>{n.observer.clearSelectionRange(),IN(n)};os.compositionstart=os.compositionupdate=n=>{n.observer.editContext||(n.inputState.compositionFirstChange==null&&(n.inputState.compositionFirstChange=!0),n.inputState.composing<0&&(n.inputState.composing=0))};os.compositionend=n=>{n.observer.editContext||(n.inputState.composing=-1,n.inputState.compositionEndedAt=Date.now(),n.inputState.compositionPendingKey=!0,n.inputState.compositionPendingChange=n.observer.pendingRecords().length>0,n.inputState.compositionFirstChange=null,Mt.chrome&&Mt.android?n.observer.flushSoon():n.inputState.compositionPendingChange?Promise.resolve().then(()=>n.observer.flush()):setTimeout(()=>{n.inputState.composing<0&&n.docView.hasComposition&&n.update([])},50))};os.contextmenu=n=>{n.inputState.lastContextMenu=Date.now()};Ms.beforeinput=(n,e)=>{var t,r;if(e.inputType=="insertReplacementText"&&n.observer.editContext){let o=(t=e.dataTransfer)===null||t===void 0?void 0:t.getData("text/plain"),s=e.getTargetRanges();if(o&&s.length){let a=s[0],l=n.posAtDOM(a.startContainer,a.startOffset),c=n.posAtDOM(a.endContainer,a.endOffset);return VP(n,{from:l,to:c,insert:n.state.toText(o)},null),!0}}let i;if(Mt.chrome&&Mt.android&&(i=EN.find(o=>o.inputType==e.inputType))&&(n.observer.delayAndroidKey(i.key,i.keyCode),i.key=="Backspace"||i.key=="Delete")){let o=((r=window.visualViewport)===null||r===void 0?void 0:r.height)||0;setTimeout(()=>{var s;(((s=window.visualViewport)===null||s===void 0?void 0:s.height)||0)>o+10&&n.hasFocus&&(n.contentDOM.blur(),n.focus())},100)}return Mt.ios&&e.inputType=="deleteContentForward"&&n.observer.flushSoon(),Mt.safari&&e.inputType=="insertText"&&n.inputState.composing>=0&&setTimeout(()=>os.compositionend(n,e),20),!1};const LR=new Set;function G9(n){LR.has(n)||(LR.add(n),n.addEventListener("copy",()=>{}),n.addEventListener("cut",()=>{}))}const NR=["pre-wrap","normal","pre-line","break-spaces"];let Qf=!1;function qR(){Qf=!1}class H9{constructor(e){this.lineWrapping=e,this.doc=Fn.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(e,t){let r=this.doc.lineAt(t).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(r+=Math.max(0,Math.ceil((t-e-r*this.lineLength*.5)/this.lineLength))),this.lineHeight*r}heightForLine(e){return this.lineWrapping?(1+Math.max(0,Math.ceil((e-this.lineLength)/(this.lineLength-5))))*this.lineHeight:this.lineHeight}setDoc(e){return this.doc=e,this}mustRefreshForWrapping(e){return NR.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let t=!1;for(let r=0;r<e.length;r++){let i=e[r];i<0?r++:this.heightSamples[Math.floor(i*10)]||(t=!0,this.heightSamples[Math.floor(i*10)]=!0)}return t}refresh(e,t,r,i,o,s){let a=NR.indexOf(e)>-1,l=Math.round(t)!=Math.round(this.lineHeight)||this.lineWrapping!=a;if(this.lineWrapping=a,this.lineHeight=t,this.charWidth=r,this.textHeight=i,this.lineLength=o,l){this.heightSamples={};for(let c=0;c<s.length;c++){let u=s[c];u<0?c++:this.heightSamples[Math.floor(u*10)]=!0}}return l}}class K9{constructor(e,t){this.from=e,this.heights=t,this.index=0}get more(){return this.index<this.heights.length}}class oa{constructor(e,t,r,i,o){this.from=e,this.length=t,this.top=r,this.height=i,this._content=o}get type(){return typeof this._content=="number"?Xi.Text:Array.isArray(this._content)?this._content:this._content.type}get to(){return this.from+this.length}get bottom(){return this.top+this.height}get widget(){return this._content instanceof zl?this._content.widget:null}get widgetLineBreaks(){return typeof this._content=="number"?this._content:0}join(e){let t=(Array.isArray(this._content)?this._content:[this]).concat(Array.isArray(e._content)?e._content:[e]);return new oa(this.from,this.length+e.length,this.top,this.height+e.height,t)}}var gr=function(n){return n[n.ByPos=0]="ByPos",n[n.ByHeight=1]="ByHeight",n[n.ByPosNoHeight=2]="ByPosNoHeight",n}(gr||(gr={}));const _O=.001;class zi{constructor(e,t,r=2){this.length=e,this.height=t,this.flags=r}get outdated(){return(this.flags&2)>0}set outdated(e){this.flags=(e?2:0)|this.flags&-3}setHeight(e){this.height!=e&&(Math.abs(this.height-e)>_O&&(Qf=!0),this.height=e)}replace(e,t,r){return zi.of(r)}decomposeLeft(e,t){t.push(this)}decomposeRight(e,t){t.push(this)}applyChanges(e,t,r,i){let o=this,s=r.doc;for(let a=i.length-1;a>=0;a--){let{fromA:l,toA:c,fromB:u,toB:d}=i[a],h=o.lineAt(l,gr.ByPosNoHeight,r.setDoc(t),0,0),p=h.to>=c?h:o.lineAt(c,gr.ByPosNoHeight,r,0,0);for(d+=p.to-c,c=p.to;a>0&&h.from<=i[a-1].toA;)l=i[a-1].fromA,u=i[a-1].fromB,a--,l<h.from&&(h=o.lineAt(l,gr.ByPosNoHeight,r,0,0));u+=h.from-l,l=h.from;let g=WP.build(r.setDoc(s),e,u,d);o=cv(o,o.replace(l,c,g))}return o.updateHeight(r,0)}static empty(){return new Eo(0,0)}static of(e){if(e.length==1)return e[0];let t=0,r=e.length,i=0,o=0;for(;;)if(t==r)if(i>o*2){let a=e[t-1];a.break?e.splice(--t,1,a.left,null,a.right):e.splice(--t,1,a.left,a.right),r+=1+a.break,i-=a.size}else if(o>i*2){let a=e[r];a.break?e.splice(r,1,a.left,null,a.right):e.splice(r,1,a.left,a.right),r+=2+a.break,o-=a.size}else break;else if(i<o){let a=e[t++];a&&(i+=a.size)}else{let a=e[--r];a&&(o+=a.size)}let s=0;return e[t-1]==null?(s=1,t--):e[t]==null&&(s=1,r++),new J9(zi.of(e.slice(0,t)),s,zi.of(e.slice(r)))}}function cv(n,e){return n==e?n:(n.constructor!=e.constructor&&(Qf=!0),e)}zi.prototype.size=1;class jN extends zi{constructor(e,t,r){super(e,t),this.deco=r}blockAt(e,t,r,i){return new oa(i,this.length,r,this.height,this.deco||0)}lineAt(e,t,r,i,o){return this.blockAt(0,r,i,o)}forEachLine(e,t,r,i,o,s){e<=o+this.length&&t>=o&&s(this.blockAt(0,r,i,o))}updateHeight(e,t=0,r=!1,i){return i&&i.from<=t&&i.more&&this.setHeight(i.heights[i.index++]),this.outdated=!1,this}toString(){return`block(${this.length})`}}class Eo extends jN{constructor(e,t){super(e,t,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0}blockAt(e,t,r,i){return new oa(i,this.length,r,this.height,this.breaks)}replace(e,t,r){let i=r[0];return r.length==1&&(i instanceof Eo||i instanceof ki&&i.flags&4)&&Math.abs(this.length-i.length)<10?(i instanceof ki?i=new Eo(i.length,this.height):i.height=this.height,this.outdated||(i.outdated=!1),i):zi.of(r)}updateHeight(e,t=0,r=!1,i){return i&&i.from<=t&&i.more?this.setHeight(i.heights[i.index++]):(r||this.outdated)&&this.setHeight(Math.max(this.widgetHeight,e.heightForLine(this.length-this.collapsed))+this.breaks*e.lineHeight),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}}class ki extends zi{constructor(e){super(e,0)}heightMetrics(e,t){let r=e.doc.lineAt(t).number,i=e.doc.lineAt(t+this.length).number,o=i-r+1,s,a=0;if(e.lineWrapping){let l=Math.min(this.height,e.lineHeight*o);s=l/o,this.length>o+1&&(a=(this.height-l)/(this.length-o-1))}else s=this.height/o;return{firstLine:r,lastLine:i,perLine:s,perChar:a}}blockAt(e,t,r,i){let{firstLine:o,lastLine:s,perLine:a,perChar:l}=this.heightMetrics(t,i);if(t.lineWrapping){let c=i+(e<t.lineHeight?0:Math.round(Math.max(0,Math.min(1,(e-r)/this.height))*this.length)),u=t.doc.lineAt(c),d=a+u.length*l,h=Math.max(r,e-d/2);return new oa(u.from,u.length,h,d,0)}else{let c=Math.max(0,Math.min(s-o,Math.floor((e-r)/a))),{from:u,length:d}=t.doc.line(o+c);return new oa(u,d,r+a*c,a,0)}}lineAt(e,t,r,i,o){if(t==gr.ByHeight)return this.blockAt(e,r,i,o);if(t==gr.ByPosNoHeight){let{from:p,to:g}=r.doc.lineAt(e);return new oa(p,g-p,0,0,0)}let{firstLine:s,perLine:a,perChar:l}=this.heightMetrics(r,o),c=r.doc.lineAt(e),u=a+c.length*l,d=c.number-s,h=i+a*d+l*(c.from-o-d);return new oa(c.from,c.length,Math.max(i,Math.min(h,i+this.height-u)),u,0)}forEachLine(e,t,r,i,o,s){e=Math.max(e,o),t=Math.min(t,o+this.length);let{firstLine:a,perLine:l,perChar:c}=this.heightMetrics(r,o);for(let u=e,d=i;u<=t;){let h=r.doc.lineAt(u);if(u==e){let g=h.number-a;d+=l*g+c*(e-o-g)}let p=l+c*h.length;s(new oa(h.from,h.length,d,p,0)),d+=p,u=h.to+1}}replace(e,t,r){let i=this.length-t;if(i>0){let o=r[r.length-1];o instanceof ki?r[r.length-1]=new ki(o.length+i):r.push(null,new ki(i-1))}if(e>0){let o=r[0];o instanceof ki?r[0]=new ki(e+o.length):r.unshift(new ki(e-1),null)}return zi.of(r)}decomposeLeft(e,t){t.push(new ki(e-1),null)}decomposeRight(e,t){t.push(null,new ki(this.length-e-1))}updateHeight(e,t=0,r=!1,i){let o=t+this.length;if(i&&i.from<=t+this.length&&i.more){let s=[],a=Math.max(t,i.from),l=-1;for(i.from>t&&s.push(new ki(i.from-t-1).updateHeight(e,t));a<=o&&i.more;){let u=e.doc.lineAt(a).length;s.length&&s.push(null);let d=i.heights[i.index++];l==-1?l=d:Math.abs(d-l)>=_O&&(l=-2);let h=new Eo(u,d);h.outdated=!1,s.push(h),a+=u+1}a<=o&&s.push(null,new ki(o-a).updateHeight(e,a));let c=zi.of(s);return(l<0||Math.abs(c.height-this.height)>=_O||Math.abs(l-this.heightMetrics(e,t).perLine)>=_O)&&(Qf=!0),cv(this,c)}else(r||this.outdated)&&(this.setHeight(e.heightForGap(t,t+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}}class J9 extends zi{constructor(e,t,r){super(e.length+t+r.length,e.height+r.height,t|(e.outdated||r.outdated?2:0)),this.left=e,this.right=r,this.size=e.size+r.size}get break(){return this.flags&1}blockAt(e,t,r,i){let o=r+this.left.height;return e<o?this.left.blockAt(e,t,r,i):this.right.blockAt(e,t,o,i+this.left.length+this.break)}lineAt(e,t,r,i,o){let s=i+this.left.height,a=o+this.left.length+this.break,l=t==gr.ByHeight?e<s:e<a,c=l?this.left.lineAt(e,t,r,i,o):this.right.lineAt(e,t,r,s,a);if(this.break||(l?c.to<a:c.from>a))return c;let u=t==gr.ByPosNoHeight?gr.ByPosNoHeight:gr.ByPos;return l?c.join(this.right.lineAt(a,u,r,s,a)):this.left.lineAt(a,u,r,i,o).join(c)}forEachLine(e,t,r,i,o,s){let a=i+this.left.height,l=o+this.left.length+this.break;if(this.break)e<l&&this.left.forEachLine(e,t,r,i,o,s),t>=l&&this.right.forEachLine(e,t,r,a,l,s);else{let c=this.lineAt(l,gr.ByPos,r,i,o);e<c.from&&this.left.forEachLine(e,c.from-1,r,i,o,s),c.to>=e&&c.from<=t&&s(c),t>c.to&&this.right.forEachLine(c.to+1,t,r,a,l,s)}}replace(e,t,r){let i=this.left.length+this.break;if(t<i)return this.balanced(this.left.replace(e,t,r),this.right);if(e>this.left.length)return this.balanced(this.left,this.right.replace(e-i,t-i,r));let o=[];e>0&&this.decomposeLeft(e,o);let s=o.length;for(let a of r)o.push(a);if(e>0&&UR(o,s-1),t<this.length){let a=o.length;this.decomposeRight(t,o),UR(o,a)}return zi.of(o)}decomposeLeft(e,t){let r=this.left.length;if(e<=r)return this.left.decomposeLeft(e,t);t.push(this.left),this.break&&(r++,e>=r&&t.push(null)),e>r&&this.right.decomposeLeft(e-r,t)}decomposeRight(e,t){let r=this.left.length,i=r+this.break;if(e>=i)return this.right.decomposeRight(e-i,t);e<r&&this.left.decomposeRight(e,t),this.break&&e<i&&t.push(null),t.push(this.right)}balanced(e,t){return e.size>2*t.size||t.size>2*e.size?zi.of(this.break?[e,null,t]:[e,t]):(this.left=cv(this.left,e),this.right=cv(this.right,t),this.setHeight(e.height+t.height),this.outdated=e.outdated||t.outdated,this.size=e.size+t.size,this.length=e.length+this.break+t.length,this)}updateHeight(e,t=0,r=!1,i){let{left:o,right:s}=this,a=t+o.length+this.break,l=null;return i&&i.from<=t+o.length&&i.more?l=o=o.updateHeight(e,t,r,i):o.updateHeight(e,t,r),i&&i.from<=a+s.length&&i.more?l=s=s.updateHeight(e,a,r,i):s.updateHeight(e,a,r),l?this.balanced(o,s):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function UR(n,e){let t,r;n[e]==null&&(t=n[e-1])instanceof ki&&(r=n[e+1])instanceof ki&&n.splice(e-1,3,new ki(t.length+1+r.length))}const eX=5;class WP{constructor(e,t){this.pos=e,this.oracle=t,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=e}get isCovered(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering}span(e,t){if(this.lineStart>-1){let r=Math.min(t,this.lineEnd),i=this.nodes[this.nodes.length-1];i instanceof Eo?i.length+=r-this.pos:(r>this.pos||!this.isCovered)&&this.nodes.push(new Eo(r-this.pos,-1)),this.writtenTo=r,t>r&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=t}point(e,t,r){if(e<t||r.heightRelevant){let i=r.widget?r.widget.estimatedHeight:0,o=r.widget?r.widget.lineBreaks:0;i<0&&(i=this.oracle.lineHeight);let s=t-e;r.block?this.addBlock(new jN(s,i,r)):(s||o||i>=eX)&&this.addLineDeco(i,o,s)}else t>e&&this.span(e,t);this.lineEnd>-1&&this.lineEnd<this.pos&&(this.lineEnd=this.oracle.doc.lineAt(this.pos).to)}enterLine(){if(this.lineStart>-1)return;let{from:e,to:t}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=t,this.writtenTo<e&&((this.writtenTo<e-1||this.nodes[this.nodes.length-1]==null)&&this.nodes.push(this.blankContent(this.writtenTo,e-1)),this.nodes.push(null)),this.pos>e&&this.nodes.push(new Eo(this.pos-e,-1)),this.writtenTo=this.pos}blankContent(e,t){let r=new ki(t-e);return this.oracle.doc.lineAt(e).to==t&&(r.flags|=4),r}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof Eo)return e;let t=new Eo(0,-1);return this.nodes.push(t),t}addBlock(e){this.enterLine();let t=e.deco;t&&t.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(e),this.writtenTo=this.pos=this.pos+e.length,t&&t.endSide>0&&(this.covering=e)}addLineDeco(e,t,r){let i=this.ensureLine();i.length+=r,i.collapsed+=r,i.widgetHeight=Math.max(i.widgetHeight,e),i.breaks+=t,this.writtenTo=this.pos=this.pos+r}finish(e){let t=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(t instanceof Eo)&&!this.isCovered?this.nodes.push(new Eo(0,-1)):(this.writtenTo<this.pos||t==null)&&this.nodes.push(this.blankContent(this.writtenTo,this.pos));let r=e;for(let i of this.nodes)i instanceof Eo&&i.updateHeight(this.oracle,r),r+=i?i.length:1;return this.nodes}static build(e,t,r,i){let o=new WP(r,e);return zn.spans(t,r,i,o,0),o.finish(r)}}function tX(n,e,t){let r=new nX;return zn.compare(n,e,t,r,0),r.changes}class nX{constructor(){this.changes=[]}compareRange(){}comparePoint(e,t,r,i){(e<t||r&&r.heightRelevant||i&&i.heightRelevant)&&CO(e,t,this.changes,5)}}function rX(n,e){let t=n.getBoundingClientRect(),r=n.ownerDocument,i=r.defaultView||window,o=Math.max(0,t.left),s=Math.min(i.innerWidth,t.right),a=Math.max(0,t.top),l=Math.min(i.innerHeight,t.bottom);for(let c=n.parentNode;c&&c!=r.body;)if(c.nodeType==1){let u=c,d=window.getComputedStyle(u);if((u.scrollHeight>u.clientHeight||u.scrollWidth>u.clientWidth)&&d.overflow!="visible"){let h=u.getBoundingClientRect();o=Math.max(o,h.left),s=Math.min(s,h.right),a=Math.max(a,h.top),l=Math.min(c==n.parentNode?i.innerHeight:l,h.bottom)}c=d.position=="absolute"||d.position=="fixed"?u.offsetParent:u.parentNode}else if(c.nodeType==11)c=c.host;else break;return{left:o-t.left,right:Math.max(o,s)-t.left,top:a-(t.top+e),bottom:Math.max(a,l)-(t.top+e)}}function iX(n){let e=n.getBoundingClientRect(),t=n.ownerDocument.defaultView||window;return e.left<t.innerWidth&&e.right>0&&e.top<t.innerHeight&&e.bottom>0}function oX(n,e){let t=n.getBoundingClientRect();return{left:0,right:t.right-t.left,top:e,bottom:t.bottom-(t.top+e)}}class qb{constructor(e,t,r,i){this.from=e,this.to=t,this.size=r,this.displaySize=i}static same(e,t){if(e.length!=t.length)return!1;for(let r=0;r<e.length;r++){let i=e[r],o=t[r];if(i.from!=o.from||i.to!=o.to||i.size!=o.size)return!1}return!0}draw(e,t){return _t.replace({widget:new sX(this.displaySize*(t?e.scaleY:e.scaleX),t)}).range(this.from,this.to)}}class sX extends Io{constructor(e,t){super(),this.size=e,this.vertical=t}eq(e){return e.size==this.size&&e.vertical==this.vertical}toDOM(){let e=document.createElement("div");return this.vertical?e.style.height=this.size+"px":(e.style.width=this.size+"px",e.style.height="2px",e.style.display="inline-block"),e}get estimatedHeight(){return this.vertical?this.size:-1}}class BR{constructor(e){this.state=e,this.pixelViewport={left:0,right:window.innerWidth,top:0,bottom:0},this.inView=!0,this.paddingTop=0,this.paddingBottom=0,this.contentDOMWidth=0,this.contentDOMHeight=0,this.editorHeight=0,this.editorWidth=0,this.scrollTop=0,this.scrolledToBottom=!1,this.scaleX=1,this.scaleY=1,this.scrollAnchorPos=0,this.scrollAnchorHeight=-1,this.scaler=FR,this.scrollTarget=null,this.printing=!1,this.mustMeasureContent=!0,this.defaultTextDirection=vr.LTR,this.visibleRanges=[],this.mustEnforceCursorAssoc=!1;let t=e.facet(UP).some(r=>typeof r!="function"&&r.class=="cm-lineWrapping");this.heightOracle=new H9(t),this.stateDeco=e.facet(Qh).filter(r=>typeof r!="function"),this.heightMap=zi.empty().applyChanges(this.stateDeco,Fn.empty,this.heightOracle.setDoc(e.doc),[new rs(0,0,0,e.doc.length)]);for(let r=0;r<2&&(this.viewport=this.getViewport(0,null),!!this.updateForViewport());r++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=_t.set(this.lineGaps.map(r=>r.draw(this,!1))),this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:t}=this.state.selection;for(let r=0;r<=1;r++){let i=r?t.head:t.anchor;if(!e.some(({from:o,to:s})=>i>=o&&i<=s)){let{from:o,to:s}=this.lineBlockAt(i);e.push(new Mm(o,s))}}return this.viewports=e.sort((r,i)=>r.from-i.from),this.updateScaler()}updateScaler(){let e=this.scaler;return this.scaler=this.heightMap.height<=7e6?FR:new ZP(this.heightOracle,this.heightMap,this.viewports),e.eq(this.scaler)?0:2}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,e=>{this.viewportLines.push(ch(e,this.scaler))})}update(e,t=null){this.state=e.state;let r=this.stateDeco;this.stateDeco=this.state.facet(Qh).filter(u=>typeof u!="function");let i=e.changedRanges,o=rs.extendWithRanges(i,tX(r,this.stateDeco,e?e.changes:ri.empty(this.state.doc.length))),s=this.heightMap.height,a=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollTop);qR(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),o),(this.heightMap.height!=s||Qf)&&(e.flags|=2),a?(this.scrollAnchorPos=e.changes.mapPos(a.from,-1),this.scrollAnchorHeight=a.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=this.heightMap.height);let l=o.length?this.mapViewport(this.viewport,e.changes):this.viewport;(t&&(t.range.head<l.from||t.range.head>l.to)||!this.viewportIsAppropriate(l))&&(l=this.getViewport(0,t));let c=l.from!=this.viewport.from||l.to!=this.viewport.to;this.viewport=l,e.flags|=this.updateForViewport(),(c||!e.changes.empty||e.flags&2)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps,e.changes))),e.flags|=this.computeVisibleRanges(e.changes),t&&(this.scrollTarget=t),!this.mustEnforceCursorAssoc&&e.selectionSet&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet(yN)&&(this.mustEnforceCursorAssoc=!0)}measure(e){let t=e.contentDOM,r=window.getComputedStyle(t),i=this.heightOracle,o=r.whiteSpace;this.defaultTextDirection=r.direction=="rtl"?vr.RTL:vr.LTR;let s=this.heightOracle.mustRefreshForWrapping(o),a=t.getBoundingClientRect(),l=s||this.mustMeasureContent||this.contentDOMHeight!=a.height;this.contentDOMHeight=a.height,this.mustMeasureContent=!1;let c=0,u=0;if(a.width&&a.height){let{scaleX:P,scaleY:w}=ZL(t,a);(P>.005&&Math.abs(this.scaleX-P)>.005||w>.005&&Math.abs(this.scaleY-w)>.005)&&(this.scaleX=P,this.scaleY=w,c|=16,s=l=!0)}let d=(parseInt(r.paddingTop)||0)*this.scaleY,h=(parseInt(r.paddingBottom)||0)*this.scaleY;(this.paddingTop!=d||this.paddingBottom!=h)&&(this.paddingTop=d,this.paddingBottom=h,c|=18),this.editorWidth!=e.scrollDOM.clientWidth&&(i.lineWrapping&&(l=!0),this.editorWidth=e.scrollDOM.clientWidth,c|=16);let p=e.scrollDOM.scrollTop*this.scaleY;this.scrollTop!=p&&(this.scrollAnchorHeight=-1,this.scrollTop=p),this.scrolledToBottom=YL(e.scrollDOM);let g=(this.printing?oX:rX)(t,this.paddingTop),O=g.top-this.pixelViewport.top,v=g.bottom-this.pixelViewport.bottom;this.pixelViewport=g;let b=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(b!=this.inView&&(this.inView=b,b&&(l=!0)),!this.inView&&!this.scrollTarget&&!iX(e.dom))return 0;let S=a.width;if((this.contentDOMWidth!=S||this.editorHeight!=e.scrollDOM.clientHeight)&&(this.contentDOMWidth=a.width,this.editorHeight=e.scrollDOM.clientHeight,c|=16),l){let P=e.docView.measureVisibleLineHeights(this.viewport);if(i.mustRefreshForHeights(P)&&(s=!0),s||i.lineWrapping&&Math.abs(S-this.contentDOMWidth)>i.charWidth){let{lineHeight:w,charWidth:E,textHeight:M}=e.docView.measureTextSize();s=w>0&&i.refresh(o,w,E,M,S/E,P),s&&(e.docView.minWidth=0,c|=16)}O>0&&v>0?u=Math.max(O,v):O<0&&v<0&&(u=Math.min(O,v)),qR();for(let w of this.viewports){let E=w.from==this.viewport.from?P:e.docView.measureVisibleLineHeights(w);this.heightMap=(s?zi.empty().applyChanges(this.stateDeco,Fn.empty,this.heightOracle,[new rs(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(i,0,s,new K9(w.from,E))}Qf&&(c|=2)}let x=!this.viewportIsAppropriate(this.viewport,u)||this.scrollTarget&&(this.scrollTarget.range.head<this.viewport.from||this.scrollTarget.range.head>this.viewport.to);return x&&(c&2&&(c|=this.updateScaler()),this.viewport=this.getViewport(u,this.scrollTarget),c|=this.updateForViewport()),(c&2||x)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(s?[]:this.lineGaps,e)),c|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),c}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,t){let r=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),i=this.heightMap,o=this.heightOracle,{visibleTop:s,visibleBottom:a}=this,l=new Mm(i.lineAt(s-r*1e3,gr.ByHeight,o,0,0).from,i.lineAt(a+(1-r)*1e3,gr.ByHeight,o,0,0).to);if(t){let{head:c}=t.range;if(c<l.from||c>l.to){let u=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),d=i.lineAt(c,gr.ByPos,o,0,0),h;t.y=="center"?h=(d.top+d.bottom)/2-u/2:t.y=="start"||t.y=="nearest"&&c<l.from?h=d.top:h=d.bottom-u,l=new Mm(i.lineAt(h-1e3/2,gr.ByHeight,o,0,0).from,i.lineAt(h+u+1e3/2,gr.ByHeight,o,0,0).to)}}return l}mapViewport(e,t){let r=t.mapPos(e.from,-1),i=t.mapPos(e.to,1);return new Mm(this.heightMap.lineAt(r,gr.ByPos,this.heightOracle,0,0).from,this.heightMap.lineAt(i,gr.ByPos,this.heightOracle,0,0).to)}viewportIsAppropriate({from:e,to:t},r=0){if(!this.inView)return!0;let{top:i}=this.heightMap.lineAt(e,gr.ByPos,this.heightOracle,0,0),{bottom:o}=this.heightMap.lineAt(t,gr.ByPos,this.heightOracle,0,0),{visibleTop:s,visibleBottom:a}=this;return(e==0||i<=s-Math.max(10,Math.min(-r,250)))&&(t==this.state.doc.length||o>=a+Math.max(10,Math.min(r,250)))&&i>s-2*1e3&&o<a+2*1e3}mapLineGaps(e,t){if(!e.length||t.empty)return e;let r=[];for(let i of e)t.touchesRange(i.from,i.to)||r.push(new qb(t.mapPos(i.from),t.mapPos(i.to),i.size,i.displaySize));return r}ensureLineGaps(e,t){let r=this.heightOracle.lineWrapping,i=r?1e4:2e3,o=i>>1,s=i<<1;if(this.defaultTextDirection!=vr.LTR&&!r)return[];let a=[],l=(u,d,h,p)=>{if(d-u<o)return;let g=this.state.selection.main,O=[g.from];g.empty||O.push(g.to);for(let b of O)if(b>u&&b<d){l(u,b-10,h,p),l(b+10,d,h,p);return}let v=lX(e,b=>b.from>=h.from&&b.to<=h.to&&Math.abs(b.from-u)<o&&Math.abs(b.to-d)<o&&!O.some(S=>b.from<S&&b.to>S));if(!v){if(d<h.to&&t&&r&&t.visibleRanges.some(x=>x.from<=d&&x.to>=d)){let x=t.moveToLineBoundary(Ie.cursor(d),!1,!0).head;x>u&&(d=x)}let b=this.gapSize(h,u,d,p),S=r||b<2e6?b:2e6;v=new qb(u,d,b,S)}a.push(v)},c=u=>{if(u.length<s||u.type!=Xi.Text)return;let d=aX(u.from,u.to,this.stateDeco);if(d.total<s)return;let h=this.scrollTarget?this.scrollTarget.range.head:null,p,g;if(r){let O=i/this.heightOracle.lineLength*this.heightOracle.lineHeight,v,b;if(h!=null){let S=Dm(d,h),x=((this.visibleBottom-this.visibleTop)/2+O)/u.height;v=S-x,b=S+x}else v=(this.visibleTop-u.top-O)/u.height,b=(this.visibleBottom-u.top+O)/u.height;p=$m(d,v),g=$m(d,b)}else{let O=d.total*this.heightOracle.charWidth,v=i*this.heightOracle.charWidth,b=0;if(O>2e6)for(let E of e)E.from>=u.from&&E.from<u.to&&E.size!=E.displaySize&&E.from*this.heightOracle.charWidth+b<this.pixelViewport.left&&(b=E.size-E.displaySize);let S=this.pixelViewport.left+b,x=this.pixelViewport.right+b,P,w;if(h!=null){let E=Dm(d,h),M=((x-S)/2+v)/O;P=E-M,w=E+M}else P=(S-v)/O,w=(x+v)/O;p=$m(d,P),g=$m(d,w)}p>u.from&&l(u.from,p,u,d),g<u.to&&l(g,u.to,u,d)};for(let u of this.viewportLines)Array.isArray(u.type)?u.type.forEach(c):c(u);return a}gapSize(e,t,r,i){let o=Dm(i,r)-Dm(i,t);return this.heightOracle.lineWrapping?e.height*o:i.total*this.heightOracle.charWidth*o}updateLineGaps(e){qb.same(e,this.lineGaps)||(this.lineGaps=e,this.lineGapDeco=_t.set(e.map(t=>t.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(e){let t=this.stateDeco;this.lineGaps.length&&(t=t.concat(this.lineGapDeco));let r=[];zn.spans(t,this.viewport.from,this.viewport.to,{span(o,s){r.push({from:o,to:s})},point(){}},20);let i=0;if(r.length!=this.visibleRanges.length)i=12;else for(let o=0;o<r.length&&!(i&8);o++){let s=this.visibleRanges[o],a=r[o];(s.from!=a.from||s.to!=a.to)&&(i|=4,e&&e.mapPos(s.from,-1)==a.from&&e.mapPos(s.to,1)==a.to||(i|=8))}return this.visibleRanges=r,i}lineBlockAt(e){return e>=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(t=>t.from<=e&&t.to>=e)||ch(this.heightMap.lineAt(e,gr.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(e){return e>=this.viewportLines[0].top&&e<=this.viewportLines[this.viewportLines.length-1].bottom&&this.viewportLines.find(t=>t.top<=e&&t.bottom>=e)||ch(this.heightMap.lineAt(this.scaler.fromDOM(e),gr.ByHeight,this.heightOracle,0,0),this.scaler)}scrollAnchorAt(e){let t=this.lineBlockAtHeight(e+8);return t.from>=this.viewport.from||this.viewportLines[0].top-e>200?t:this.viewportLines[0]}elementAtHeight(e){return ch(this.heightMap.blockAt(this.scaler.fromDOM(e),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}}class Mm{constructor(e,t){this.from=e,this.to=t}}function aX(n,e,t){let r=[],i=n,o=0;return zn.spans(t,n,e,{span(){},point(s,a){s>i&&(r.push({from:i,to:s}),o+=s-i),i=a}},20),i<e&&(r.push({from:i,to:e}),o+=e-i),{total:o,ranges:r}}function $m({total:n,ranges:e},t){if(t<=0)return e[0].from;if(t>=1)return e[e.length-1].to;let r=Math.floor(n*t);for(let i=0;;i++){let{from:o,to:s}=e[i],a=s-o;if(r<=a)return o+r;r-=a}}function Dm(n,e){let t=0;for(let{from:r,to:i}of n.ranges){if(e<=i){t+=e-r;break}t+=i-r}return t/n.total}function lX(n,e){for(let t of n)if(e(t))return t}const FR={toDOM(n){return n},fromDOM(n){return n},scale:1,eq(n){return n==this}};class ZP{constructor(e,t,r){let i=0,o=0,s=0;this.viewports=r.map(({from:a,to:l})=>{let c=t.lineAt(a,gr.ByPos,e,0,0).top,u=t.lineAt(l,gr.ByPos,e,0,0).bottom;return i+=u-c,{from:a,to:l,top:c,bottom:u,domTop:0,domBottom:0}}),this.scale=(7e6-i)/(t.height-i);for(let a of this.viewports)a.domTop=s+(a.top-o)*this.scale,s=a.domBottom=a.domTop+(a.bottom-a.top),o=a.bottom}toDOM(e){for(let t=0,r=0,i=0;;t++){let o=t<this.viewports.length?this.viewports[t]:null;if(!o||e<o.top)return i+(e-r)*this.scale;if(e<=o.bottom)return o.domTop+(e-o.top);r=o.bottom,i=o.domBottom}}fromDOM(e){for(let t=0,r=0,i=0;;t++){let o=t<this.viewports.length?this.viewports[t]:null;if(!o||e<o.domTop)return r+(e-i)/this.scale;if(e<=o.domBottom)return o.top+(e-o.domTop);r=o.bottom,i=o.domBottom}}eq(e){return e instanceof ZP?this.scale==e.scale&&this.viewports.length==e.viewports.length&&this.viewports.every((t,r)=>t.from==e.viewports[r].from&&t.to==e.viewports[r].to):!1}}function ch(n,e){if(e.scale==1)return n;let t=e.toDOM(n.top),r=e.toDOM(n.bottom);return new oa(n.from,n.length,t,r-t,Array.isArray(n._content)?n._content.map(i=>ch(i,e)):n._content)}const Qm=Ct.define({combine:n=>n.join(" ")}),lk=Ct.define({combine:n=>n.indexOf(!0)>-1}),ck=Zl.newName(),LN=Zl.newName(),NN=Zl.newName(),qN={"&light":"."+LN,"&dark":"."+NN};function uk(n,e,t){return new Zl(e,{finish(r){return/&/.test(r)?r.replace(/&\w*/,i=>{if(i=="&")return n;if(!t||!t[i])throw new RangeError(`Unsupported selector: ${i}`);return t[i]}):n+" "+r}})}const cX=uk("."+ck,{"&":{position:"relative !important",boxSizing:"border-box","&.cm-focused":{outline:"1px dotted #212121"},display:"flex !important",flexDirection:"column"},".cm-scroller":{display:"flex !important",alignItems:"flex-start !important",fontFamily:"monospace",lineHeight:1.4,height:"100%",overflowX:"auto",position:"relative",zIndex:0,overflowAnchor:"none"},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",minHeight:"100%",padding:"4px 0",outline:"none","&[contenteditable=true]":{WebkitUserModify:"read-write-plaintext-only"}},".cm-lineWrapping":{whiteSpace_fallback:"pre-wrap",whiteSpace:"break-spaces",wordBreak:"break-word",overflowWrap:"anywhere",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#ddd"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},".cm-iso":{unicodeBidi:"isolate"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",insetInlineStart:0,zIndex:200},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",borderRight:"1px solid #ddd"},"&dark .cm-gutters":{backgroundColor:"#333338",color:"#ccc"},".cm-gutter":{display:"flex !important",flexDirection:"column",flexShrink:0,boxSizing:"border-box",minHeight:"100%",overflow:"hidden"},".cm-gutterElement":{boxSizing:"border-box"},".cm-lineNumbers .cm-gutterElement":{padding:"0 3px 0 5px",minWidth:"20px",textAlign:"right",whiteSpace:"nowrap"},"&light .cm-activeLineGutter":{backgroundColor:"#e2f2ff"},"&dark .cm-activeLineGutter":{backgroundColor:"#222227"},".cm-panels":{boxSizing:"border-box",position:"sticky",left:0,right:0,zIndex:300},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top",userSelect:"none"},".cm-highlightSpace":{backgroundImage:"radial-gradient(circle at 50% 55%, #aaa 20%, transparent 5%)",backgroundPosition:"center"},".cm-highlightTab":{backgroundImage:`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="200" height="20"><path stroke="%23888" stroke-width="1" fill="none" d="M1 10H196L190 5M190 15L196 10M197 4L197 16"/></svg>')`,backgroundSize:"auto 100%",backgroundPosition:"right 90%",backgroundRepeat:"no-repeat"},".cm-trailingSpace":{backgroundColor:"#ff332255"},".cm-button":{verticalAlign:"middle",color:"inherit",fontSize:"70%",padding:".2em 1em",borderRadius:"1px"},"&light .cm-button":{backgroundImage:"linear-gradient(#eff1f5, #d9d9df)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#b4b4b4, #d0d3d6)"}},"&dark .cm-button":{backgroundImage:"linear-gradient(#393939, #111)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#111, #333)"}},".cm-textfield":{verticalAlign:"middle",color:"inherit",fontSize:"70%",border:"1px solid silver",padding:".2em .5em"},"&light .cm-textfield":{backgroundColor:"white"},"&dark .cm-textfield":{border:"1px solid #555",backgroundColor:"inherit"}},qN),uX={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},Ub=Mt.ie&&Mt.ie_version<=11;class fX{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new ZZ,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.printQuery=null,this.parentCheck=-1,this.dom=e.contentDOM,this.observer=new MutationObserver(t=>{for(let r of t)this.queue.push(r);(Mt.ie&&Mt.ie_version<=11||Mt.ios&&e.composing)&&t.some(r=>r.type=="childList"&&r.removedNodes.length||r.type=="characterData"&&r.oldValue.length>r.target.nodeValue.length)?this.flushSoon():this.flush()}),window.EditContext&&e.constructor.EDIT_CONTEXT!==!1&&!(Mt.chrome&&Mt.chrome_version<126)&&(this.editContext=new hX(e),e.state.facet(Ia)&&(e.contentDOM.editContext=this.editContext.editContext)),Ub&&(this.onCharData=t=>{this.queue.push({target:t.target,type:"characterData",oldValue:t.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),window.matchMedia&&(this.printQuery=window.matchMedia("print")),typeof ResizeObserver=="function"&&(this.resizeScroll=new ResizeObserver(()=>{var t;((t=this.view.docView)===null||t===void 0?void 0:t.lastUpdate)<Date.now()-75&&this.onResize()}),this.resizeScroll.observe(e.scrollDOM)),this.addWindowListeners(this.win=e.win),this.start(),typeof IntersectionObserver=="function"&&(this.intersection=new IntersectionObserver(t=>{this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),t.length>0&&t[t.length-1].intersectionRatio>0!=this.intersecting&&(this.intersecting=!this.intersecting,this.intersecting!=this.view.inView&&this.onScrollChanged(document.createEvent("Event")))},{threshold:[0,.001]}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver(t=>{t.length>0&&t[t.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))},{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(e){this.view.inputState.runHandlers("scroll",e),this.intersecting&&this.view.measure()}onScroll(e){this.intersecting&&this.flush(!1),this.editContext&&this.view.requestMeasure(this.editContext.measureReq),this.onScrollChanged(e)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(e){(e.type=="change"||!e.type)&&!e.matches||(this.view.viewState.printing=!0,this.view.measure(),setTimeout(()=>{this.view.viewState.printing=!1,this.view.requestMeasure()},500))}updateGaps(e){if(this.gapIntersection&&(e.length!=this.gaps.length||this.gaps.some((t,r)=>t!=e[r]))){this.gapIntersection.disconnect();for(let t of e)this.gapIntersection.observe(t);this.gaps=e}}onSelectionChange(e){let t=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:r}=this,i=this.selectionRange;if(r.state.facet(Ia)?r.root.activeElement!=this.dom:!xO(this.dom,i))return;let o=i.anchorNode&&r.docView.nearest(i.anchorNode);if(o&&o.ignoreEvent(e)){t||(this.selectionChanged=!1);return}(Mt.ie&&Mt.ie_version<=11||Mt.android&&Mt.chrome)&&!r.state.selection.main.empty&&i.focusNode&&Sh(i.focusNode,i.focusOffset,i.anchorNode,i.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,t=$h(e.root);if(!t)return!1;let r=Mt.safari&&e.root.nodeType==11&&e.root.activeElement==this.dom&&dX(this.view,t)||t;if(!r||this.selectionRange.eq(r))return!1;let i=xO(this.dom,r);return i&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime<Date.now()-300&&zZ(this.dom,r)?(this.view.inputState.lastFocusTime=0,e.docView.updateSelection(),!1):(this.selectionRange.setRange(r),i&&(this.selectionChanged=!0),!0)}setSelectionRange(e,t){this.selectionRange.set(e.node,e.offset,t.node,t.offset),this.selectionChanged=!1}clearSelectionRange(){this.selectionRange.set(null,0,null,0)}listenForScroll(){this.parentCheck=-1;let e=0,t=null;for(let r=this.dom;r;)if(r.nodeType==1)!t&&e<this.scrollTargets.length&&this.scrollTargets[e]==r?e++:t||(t=this.scrollTargets.slice(0,e)),t&&t.push(r),r=r.assignedSlot||r.parentNode;else if(r.nodeType==11)r=r.host;else break;if(e<this.scrollTargets.length&&!t&&(t=this.scrollTargets.slice(0,e)),t){for(let r of this.scrollTargets)r.removeEventListener("scroll",this.onScroll);for(let r of this.scrollTargets=t)r.addEventListener("scroll",this.onScroll)}}ignore(e){if(!this.active)return e();try{return this.stop(),e()}finally{this.start(),this.clear()}}start(){this.active||(this.observer.observe(this.dom,uX),Ub&&this.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.active=!0)}stop(){this.active&&(this.active=!1,this.observer.disconnect(),Ub&&this.dom.removeEventListener("DOMCharacterDataModified",this.onCharData))}clear(){this.processRecords(),this.queue.length=0,this.selectionChanged=!1}delayAndroidKey(e,t){var r;if(!this.delayedAndroidKey){let i=()=>{let o=this.delayedAndroidKey;o&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=o.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&o.force&&vf(this.dom,o.key,o.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(i)}(!this.delayedAndroidKey||e=="Enter")&&(this.delayedAndroidKey={key:e,keyCode:t,force:this.lastChange<Date.now()-50||!!(!((r=this.delayedAndroidKey)===null||r===void 0)&&r.force)})}clearDelayedAndroidKey(){this.win.cancelAnimationFrame(this.flushingAndroidKey),this.delayedAndroidKey=null,this.flushingAndroidKey=-1}flushSoon(){this.delayedFlush<0&&(this.delayedFlush=this.view.win.requestAnimationFrame(()=>{this.delayedFlush=-1,this.flush()}))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}processRecords(){let e=this.pendingRecords();e.length&&(this.queue=[]);let t=-1,r=-1,i=!1;for(let o of e){let s=this.readMutation(o);s&&(s.typeOver&&(i=!0),t==-1?{from:t,to:r}=s:(t=Math.min(s.from,t),r=Math.max(s.to,r)))}return{from:t,to:r,typeOver:i}}readChange(){let{from:e,to:t,typeOver:r}=this.processRecords(),i=this.selectionChanged&&xO(this.dom,this.selectionRange);if(e<0&&!i)return null;e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let o=new E9(this.view,e,t,r);return this.view.docView.domChanged={newSel:o.newSel?o.newSel.main:null},o}flush(e=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;e&&this.readSelectionRange();let t=this.readChange();if(!t)return this.view.requestMeasure(),!1;let r=this.view.state,i=_N(this.view,t);return this.view.state==r&&(t.domChanged||t.newSel&&!t.newSel.main.eq(this.view.state.selection.main))&&this.view.update([]),i}readMutation(e){let t=this.view.docView.nearest(e.target);if(!t||t.ignoreMutation(e))return null;if(t.markDirty(e.type=="attributes"),e.type=="attributes"&&(t.flags|=4),e.type=="childList"){let r=VR(t,e.previousSibling||e.target.previousSibling,-1),i=VR(t,e.nextSibling||e.target.nextSibling,1);return{from:r?t.posAfter(r):t.posAtStart,to:i?t.posBefore(i):t.posAtEnd,typeOver:!1}}else return e.type=="characterData"?{from:t.posAtStart,to:t.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}:null}setWindow(e){e!=this.win&&(this.removeWindowListeners(this.win),this.win=e,this.addWindowListeners(this.win))}addWindowListeners(e){e.addEventListener("resize",this.onResize),this.printQuery?this.printQuery.addEventListener?this.printQuery.addEventListener("change",this.onPrint):this.printQuery.addListener(this.onPrint):e.addEventListener("beforeprint",this.onPrint),e.addEventListener("scroll",this.onScroll),e.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(e){e.removeEventListener("scroll",this.onScroll),e.removeEventListener("resize",this.onResize),this.printQuery?this.printQuery.removeEventListener?this.printQuery.removeEventListener("change",this.onPrint):this.printQuery.removeListener(this.onPrint):e.removeEventListener("beforeprint",this.onPrint),e.document.removeEventListener("selectionchange",this.onSelectionChange)}update(e){this.editContext&&(this.editContext.update(e),e.startState.facet(Ia)!=e.state.facet(Ia)&&(e.view.contentDOM.editContext=e.state.facet(Ia)?this.editContext.editContext:null))}destroy(){var e,t,r;this.stop(),(e=this.intersection)===null||e===void 0||e.disconnect(),(t=this.gapIntersection)===null||t===void 0||t.disconnect(),(r=this.resizeScroll)===null||r===void 0||r.disconnect();for(let i of this.scrollTargets)i.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey),this.editContext&&(this.view.contentDOM.editContext=null,this.editContext.destroy())}}function VR(n,e,t){for(;e;){let r=lr.get(e);if(r&&r.parent==n)return r;let i=e.parentNode;e=i!=n.dom?i:t>0?e.nextSibling:e.previousSibling}return null}function WR(n,e){let t=e.startContainer,r=e.startOffset,i=e.endContainer,o=e.endOffset,s=n.docView.domAtPos(n.state.selection.main.anchor);return Sh(s.node,s.offset,i,o)&&([t,r,i,o]=[i,o,t,r]),{anchorNode:t,anchorOffset:r,focusNode:i,focusOffset:o}}function dX(n,e){if(e.getComposedRanges){let i=e.getComposedRanges(n.root)[0];if(i)return WR(n,i)}let t=null;function r(i){i.preventDefault(),i.stopImmediatePropagation(),t=i.getTargetRanges()[0]}return n.contentDOM.addEventListener("beforeinput",r,!0),n.dom.ownerDocument.execCommand("indent"),n.contentDOM.removeEventListener("beforeinput",r,!0),t?WR(n,t):null}class hX{constructor(e){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.composing=null,this.resetRange(e.state);let t=this.editContext=new window.EditContext({text:e.state.doc.sliceString(this.from,this.to),selectionStart:this.toContextPos(Math.max(this.from,Math.min(this.to,e.state.selection.main.anchor))),selectionEnd:this.toContextPos(e.state.selection.main.head)});this.handlers.textupdate=r=>{let i=e.state.selection.main,{anchor:o,head:s}=i,a=this.toEditorPos(r.updateRangeStart),l=this.toEditorPos(r.updateRangeEnd);e.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:r.updateRangeStart,editorBase:a,drifted:!1});let c={from:a,to:l,insert:Fn.of(r.text.split(`
|
|
125
125
|
`))};if(c.from==this.from&&o<this.from?c.from=o:c.to==this.to&&o>this.to&&(c.to=o),c.from==c.to&&!c.insert.length){let u=Ie.single(this.toEditorPos(r.selectionStart),this.toEditorPos(r.selectionEnd));u.main.eq(i)||e.dispatch({selection:u,userEvent:"select"});return}if((Mt.mac||Mt.android)&&c.from==s-1&&/^\. ?$/.test(r.text)&&e.contentDOM.getAttribute("autocorrect")=="off"&&(c={from:a,to:l,insert:Fn.of([r.text.replace("."," ")])}),this.pendingContextChange=c,!e.state.readOnly){let u=this.to-this.from+(c.to-c.from+c.insert.length);VP(e,c,Ie.single(this.toEditorPos(r.selectionStart,u),this.toEditorPos(r.selectionEnd,u)))}this.pendingContextChange&&(this.revertPending(e.state),this.setSelection(e.state))},this.handlers.characterboundsupdate=r=>{let i=[],o=null;for(let s=this.toEditorPos(r.rangeStart),a=this.toEditorPos(r.rangeEnd);s<a;s++){let l=e.coordsForChar(s);o=l&&new DOMRect(l.left,l.top,l.right-l.left,l.bottom-l.top)||o||new DOMRect,i.push(o)}t.updateCharacterBounds(r.rangeStart,i)},this.handlers.textformatupdate=r=>{let i=[];for(let o of r.getTextFormats()){let s=o.underlineStyle,a=o.underlineThickness;if(s!="None"&&a!="None"){let l=this.toEditorPos(o.rangeStart),c=this.toEditorPos(o.rangeEnd);if(l<c){let u=`text-decoration: underline ${s=="Dashed"?"dashed ":s=="Squiggle"?"wavy ":""}${a=="Thin"?1:2}px`;i.push(_t.mark({attributes:{style:u}}).range(l,c))}}}e.dispatch({effects:SN.of(_t.set(i))})},this.handlers.compositionstart=()=>{e.inputState.composing<0&&(e.inputState.composing=0,e.inputState.compositionFirstChange=!0)},this.handlers.compositionend=()=>{if(e.inputState.composing=-1,e.inputState.compositionFirstChange=null,this.composing){let{drifted:r}=this.composing;this.composing=null,r&&this.reset(e.state)}};for(let r in this.handlers)t.addEventListener(r,this.handlers[r]);this.measureReq={read:r=>{this.editContext.updateControlBounds(r.contentDOM.getBoundingClientRect());let i=$h(r.root);i&&i.rangeCount&&this.editContext.updateSelectionBounds(i.getRangeAt(0).getBoundingClientRect())}}}applyEdits(e){let t=0,r=!1,i=this.pendingContextChange;return e.changes.iterChanges((o,s,a,l,c)=>{if(r)return;let u=c.length-(s-o);if(i&&s>=i.to)if(i.from==o&&i.to==s&&i.insert.eq(c)){i=this.pendingContextChange=null,t+=u,this.to+=u;return}else i=null,this.revertPending(e.state);if(o+=t,s+=t,s<=this.from)this.from+=u,this.to+=u;else if(o<this.to){if(o<this.from||s>this.to||this.to-this.from+c.length>3e4){r=!0;return}this.editContext.updateText(this.toContextPos(o),this.toContextPos(s),c.toString()),this.to+=u}t+=u}),i&&!r&&this.revertPending(e.state),!r}update(e){let t=this.pendingContextChange,r=e.startState.selection.main;this.composing&&(this.composing.drifted||!e.changes.touchesRange(r.from,r.to)&&e.transactions.some(i=>!i.isUserEvent("input.type")&&i.changes.touchesRange(this.from,this.to)))?(this.composing.drifted=!0,this.composing.editorBase=e.changes.mapPos(this.composing.editorBase)):!this.applyEdits(e)||!this.rangeIsValid(e.state)?(this.pendingContextChange=null,this.reset(e.state)):(e.docChanged||e.selectionSet||t)&&this.setSelection(e.state),(e.geometryChanged||e.docChanged||e.selectionSet)&&e.view.requestMeasure(this.measureReq)}resetRange(e){let{head:t}=e.selection.main;this.from=Math.max(0,t-1e4),this.to=Math.min(e.doc.length,t+1e4)}reset(e){this.resetRange(e),this.editContext.updateText(0,this.editContext.text.length,e.doc.sliceString(this.from,this.to)),this.setSelection(e)}revertPending(e){let t=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(t.from),this.toContextPos(t.from+t.insert.length),e.doc.sliceString(t.from,t.to))}setSelection(e){let{main:t}=e.selection,r=this.toContextPos(Math.max(this.from,Math.min(this.to,t.anchor))),i=this.toContextPos(t.head);(this.editContext.selectionStart!=r||this.editContext.selectionEnd!=i)&&this.editContext.updateSelection(r,i)}rangeIsValid(e){let{head:t}=e.selection.main;return!(this.from>0&&t-this.from<500||this.to<e.doc.length&&this.to-t<500||this.to-this.from>1e4*3)}toEditorPos(e,t=this.to-this.from){e=Math.min(e,t);let r=this.composing;return r&&r.drifted?r.editorBase+(e-r.contextBase):e+this.from}toContextPos(e){let t=this.composing;return t&&t.drifted?t.contextBase+(e-t.editorBase):e-this.from}destroy(){for(let e in this.handlers)this.editContext.removeEventListener(e,this.handlers[e])}}class ft{get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return this.inputState.composing>0}get compositionStarted(){return this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(e={}){var t;this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.contentDOM=document.createElement("div"),this.scrollDOM=document.createElement("div"),this.scrollDOM.tabIndex=-1,this.scrollDOM.className="cm-scroller",this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement("div"),this.announceDOM.className="cm-announced",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),e.parent&&e.parent.appendChild(this.dom);let{dispatch:r}=e;this.dispatchTransactions=e.dispatchTransactions||r&&(i=>i.forEach(o=>r(o,this)))||(i=>this.update(i)),this.dispatch=this.dispatch.bind(this),this._root=e.root||XZ(e.parent)||document,this.viewState=new BR(e.state||Un.create(e)),e.scrollTo&&e.scrollTo.is(Em)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(sh).map(i=>new jb(i));for(let i of this.plugins)i.update(this);this.observer=new fX(this),this.inputState=new D9(this),this.inputState.ensureHandlers(this.plugins),this.docView=new kR(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),!((t=document.fonts)===null||t===void 0)&&t.ready&&document.fonts.ready.then(()=>this.requestMeasure())}dispatch(...e){let t=e.length==1&&e[0]instanceof Hr?e:e.length==1&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(t,this)}update(e){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let t=!1,r=!1,i,o=this.state;for(let h of e){if(h.startState!=o)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");o=h.state}if(this.destroyed){this.viewState.state=o;return}let s=this.hasFocus,a=0,l=null;e.some(h=>h.annotation(DN))?(this.inputState.notifiedFocused=s,a=1):s!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=s,l=QN(o,s),l||(a=1));let c=this.observer.delayedAndroidKey,u=null;if(c?(this.observer.clearDelayedAndroidKey(),u=this.observer.readChange(),(u&&!this.state.doc.eq(o.doc)||!this.state.selection.eq(o.selection))&&(u=null)):this.observer.clear(),o.facet(Un.phrases)!=this.state.facet(Un.phrases))return this.setState(o);i=lv.create(this,o,e),i.flags|=a;let d=this.viewState.scrollTarget;try{this.updateState=2;for(let h of e){if(d&&(d=d.map(h.changes)),h.scrollIntoView){let{main:p}=h.state.selection;d=new yf(p.empty?p:Ie.cursor(p.head,p.head>p.anchor?-1:1))}for(let p of h.effects)p.is(Em)&&(d=p.value.clip(this.state))}this.viewState.update(i,d),this.bidiCache=uv.update(this.bidiCache,i.changes),i.empty||(this.updatePlugins(i),this.inputState.update(i)),t=this.docView.update(i),this.state.facet(ah)!=this.styleModules&&this.mountStyles(),r=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(t,e.some(h=>h.isUserEvent("select.pointer")))}finally{this.updateState=0}if(i.startState.facet(Qm)!=i.state.facet(Qm)&&(this.viewState.mustMeasureContent=!0),(t||r||d||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),t&&this.docViewUpdate(),!i.empty)for(let h of this.state.facet(ik))try{h(i)}catch(p){mo(this.state,p,"update listener")}(l||u)&&Promise.resolve().then(()=>{l&&this.state==l.startState&&this.dispatch(l),u&&!_N(this,u)&&c.force&&vf(this.contentDOM,c.key,c.keyCode)})}setState(e){if(this.updateState!=0)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed){this.viewState.state=e;return}this.updateState=2;let t=this.hasFocus;try{for(let r of this.plugins)r.destroy(this);this.viewState=new BR(e),this.plugins=e.facet(sh).map(r=>new jb(r)),this.pluginMap.clear();for(let r of this.plugins)r.update(this);this.docView.destroy(),this.docView=new kR(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}t&&this.focus(),this.requestMeasure()}updatePlugins(e){let t=e.startState.facet(sh),r=e.state.facet(sh);if(t!=r){let i=[];for(let o of r){let s=t.indexOf(o);if(s<0)i.push(new jb(o));else{let a=this.plugins[s];a.mustUpdate=e,i.push(a)}}for(let o of this.plugins)o.mustUpdate!=e&&o.destroy(this);this.plugins=i,this.pluginMap.clear()}else for(let i of this.plugins)i.mustUpdate=e;for(let i=0;i<this.plugins.length;i++)this.plugins[i].update(this);t!=r&&this.inputState.ensureHandlers(this.plugins)}docViewUpdate(){for(let e of this.plugins){let t=e.value;if(t&&t.docViewUpdate)try{t.docViewUpdate(this)}catch(r){mo(this.state,r,"doc view update listener")}}}measure(e=!0){if(this.destroyed)return;if(this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,e&&this.observer.forceFlush();let t=null,r=this.scrollDOM,i=r.scrollTop*this.scaleY,{scrollAnchorPos:o,scrollAnchorHeight:s}=this.viewState;Math.abs(i-this.viewState.scrollTop)>1&&(s=-1),this.viewState.scrollAnchorHeight=-1;try{for(let a=0;;a++){if(s<0)if(YL(r))o=-1,s=this.viewState.heightMap.height;else{let p=this.viewState.scrollAnchorAt(i);o=p.from,s=p.top}this.updateState=1;let l=this.viewState.measure(this);if(!l&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(a>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let c=[];l&4||([this.measureRequests,c]=[c,this.measureRequests]);let u=c.map(p=>{try{return p.read(this)}catch(g){return mo(this.state,g),ZR}}),d=lv.create(this,this.state,[]),h=!1;d.flags|=l,t?t.flags|=l:t=d,this.updateState=2,d.empty||(this.updatePlugins(d),this.inputState.update(d),this.updateAttrs(),h=this.docView.update(d),h&&this.docViewUpdate());for(let p=0;p<c.length;p++)if(u[p]!=ZR)try{let g=c[p];g.write&&g.write(u[p],this)}catch(g){mo(this.state,g)}if(h&&this.docView.updateSelection(!0),!d.viewportChanged&&this.measureRequests.length==0){if(this.viewState.editorHeight)if(this.viewState.scrollTarget){this.docView.scrollIntoView(this.viewState.scrollTarget),this.viewState.scrollTarget=null,s=-1;continue}else{let g=(o<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(o).top)-s;if(g>1||g<-1){i=i+g,r.scrollTop=i/this.scaleY,s=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(t&&!t.empty)for(let a of this.state.facet(ik))a(t)}get themeClasses(){return ck+" "+(this.state.facet(lk)?NN:LN)+" "+this.state.facet(Qm)}updateAttrs(){let e=XR(this,wN,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),t={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(Ia)?"true":"false",class:"cm-content",style:`${Mt.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(t["aria-readonly"]="true"),XR(this,UP,t);let r=this.observer.ignore(()=>{let i=J1(this.contentDOM,this.contentAttrs,t),o=J1(this.dom,this.editorAttrs,e);return i||o});return this.editorAttrs=e,this.contentAttrs=t,r}showAnnouncements(e){let t=!0;for(let r of e)for(let i of r.effects)if(i.is(ft.announce)){t&&(this.announceDOM.textContent=""),t=!1;let o=this.announceDOM.appendChild(document.createElement("div"));o.textContent=i.value}}mountStyles(){this.styleModules=this.state.facet(ah);let e=this.state.facet(ft.cspNonce);Zl.mount(this.root,this.styleModules.concat(cX).reverse(),e?{nonce:e}:void 0)}readMeasured(){if(this.updateState==2)throw new Error("Reading the editor layout isn't allowed during an update");this.updateState==0&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(e){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),e){if(this.measureRequests.indexOf(e)>-1)return;if(e.key!=null){for(let t=0;t<this.measureRequests.length;t++)if(this.measureRequests[t].key===e.key){this.measureRequests[t]=e;return}}this.measureRequests.push(e)}}plugin(e){let t=this.pluginMap.get(e);return(t===void 0||t&&t.spec!=e)&&this.pluginMap.set(e,t=this.plugins.find(r=>r.spec==e)||null),t&&t.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}elementAtHeight(e){return this.readMeasured(),this.viewState.elementAtHeight(e)}lineBlockAtHeight(e){return this.readMeasured(),this.viewState.lineBlockAtHeight(e)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(e){return this.viewState.lineBlockAt(e)}get contentHeight(){return this.viewState.contentHeight}moveByChar(e,t,r){return Nb(this,e,_R(this,e,t,r))}moveByGroup(e,t){return Nb(this,e,_R(this,e,t,r=>x9(this,e.head,r)))}visualLineSide(e,t){let r=this.bidiSpans(e),i=this.textDirectionAt(e.from),o=r[t?r.length-1:0];return Ie.cursor(o.side(t,i)+e.from,o.forward(!t,i)?1:-1)}moveToLineBoundary(e,t,r=!0){return P9(this,e,t,r)}moveVertically(e,t,r){return Nb(this,e,C9(this,e,t,r))}domAtPos(e){return this.docView.domAtPos(e)}posAtDOM(e,t=0){return this.docView.posFromDOM(e,t)}posAtCoords(e,t=!0){return this.readMeasured(),TN(this,e,t)}coordsAtPos(e,t=1){this.readMeasured();let r=this.docView.coordsAt(e,t);if(!r||r.left==r.right)return r;let i=this.state.doc.lineAt(e),o=this.bidiSpans(i),s=o[Ql.find(o,e-i.from,-1,t)];return ny(r,s.dir==vr.LTR==t>0)}coordsForChar(e){return this.readMeasured(),this.docView.coordsForChar(e)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(e){return!this.state.facet(vN)||e<this.viewport.from||e>this.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>pX)return uN(e.length);let t=this.textDirectionAt(e.from),r;for(let o of this.bidiCache)if(o.from==e.from&&o.dir==t&&(o.fresh||cN(o.isolates,r=wR(this,e))))return o.order;r||(r=wR(this,e));let i=l9(e.text,t,r);return this.bidiCache.push(new uv(e.from,e.to,t,r,!0,i)),i}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||Mt.safari&&((e=this.inputState)===null||e===void 0?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{XL(this.contentDOM),this.docView.updateSelection()})}setRoot(e){this._root!=e&&(this._root=e,this.observer.setWindow((e.nodeType==9?e:e.ownerDocument).defaultView||window),this.mountStyles())}destroy(){this.root.activeElement==this.contentDOM&&this.contentDOM.blur();for(let e of this.plugins)e.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(e,t={}){return Em.of(new yf(typeof e=="number"?Ie.cursor(e):e,t.y,t.x,t.yMargin,t.xMargin))}scrollSnapshot(){let{scrollTop:e,scrollLeft:t}=this.scrollDOM,r=this.viewState.scrollAnchorAt(e);return Em.of(new yf(Ie.cursor(r.from),"start","start",r.top-e,t,!0))}setTabFocusMode(e){e==null?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:typeof e=="boolean"?this.inputState.tabFocusMode=e?0:-1:this.inputState.tabFocusMode!=0&&(this.inputState.tabFocusMode=Date.now()+e)}static domEventHandlers(e){return nr.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return nr.define(()=>({}),{eventObservers:e})}static theme(e,t){let r=Zl.newName(),i=[Qm.of(r),ah.of(uk(`.${r}`,e))];return t&&t.dark&&i.push(lk.of(!0)),i}static baseTheme(e){return pa.lowest(ah.of(uk("."+ck,e,qN)))}static findFromDOM(e){var t;let r=e.querySelector(".cm-content"),i=r&&lr.get(r)||lr.get(e);return((t=i==null?void 0:i.rootView)===null||t===void 0?void 0:t.view)||null}}ft.styleModule=ah;ft.inputHandler=gN;ft.clipboardInputFilter=NP;ft.clipboardOutputFilter=qP;ft.scrollHandler=bN;ft.focusChangeEffect=ON;ft.perLineTextDirection=vN;ft.exceptionSink=mN;ft.updateListener=ik;ft.editable=Ia;ft.mouseSelectionStyle=pN;ft.dragMovesSelection=hN;ft.clickAddsSelectionRange=dN;ft.decorations=Qh;ft.outerDecorations=kN;ft.atomicRanges=BP;ft.bidiIsolatedRanges=PN;ft.scrollMargins=xN;ft.darkTheme=lk;ft.cspNonce=Ct.define({combine:n=>n.length?n[0]:""});ft.contentAttributes=UP;ft.editorAttributes=wN;ft.lineWrapping=ft.contentAttributes.of({class:"cm-lineWrapping"});ft.announce=cn.define();const pX=4096,ZR={};class uv{constructor(e,t,r,i,o,s){this.from=e,this.to=t,this.dir=r,this.isolates=i,this.fresh=o,this.order=s}static update(e,t){if(t.empty&&!e.some(o=>o.fresh))return e;let r=[],i=e.length?e[e.length-1].dir:vr.LTR;for(let o=Math.max(0,e.length-10);o<e.length;o++){let s=e[o];s.dir==i&&!t.touchesRange(s.from,s.to)&&r.push(new uv(t.mapPos(s.from,1),t.mapPos(s.to,-1),s.dir,s.isolates,!1,s.order))}return r}}function XR(n,e,t){for(let r=n.state.facet(e),i=r.length-1;i>=0;i--){let o=r[i],s=typeof o=="function"?o(n):o;s&&K1(s,t)}return t}const mX=Mt.mac?"mac":Mt.windows?"win":Mt.linux?"linux":"key";function gX(n,e){const t=n.split(/-(?!$)/);let r=t[t.length-1];r=="Space"&&(r=" ");let i,o,s,a;for(let l=0;l<t.length-1;++l){const c=t[l];if(/^(cmd|meta|m)$/i.test(c))a=!0;else if(/^a(lt)?$/i.test(c))i=!0;else if(/^(c|ctrl|control)$/i.test(c))o=!0;else if(/^s(hift)?$/i.test(c))s=!0;else if(/^mod$/i.test(c))e=="mac"?a=!0:o=!0;else throw new Error("Unrecognized modifier name: "+c)}return i&&(r="Alt-"+r),o&&(r="Ctrl-"+r),a&&(r="Meta-"+r),s&&(r="Shift-"+r),r}function Im(n,e,t){return e.altKey&&(n="Alt-"+n),e.ctrlKey&&(n="Ctrl-"+n),e.metaKey&&(n="Meta-"+n),t!==!1&&e.shiftKey&&(n="Shift-"+n),n}const OX=pa.default(ft.domEventHandlers({keydown(n,e){return BN(UN(e.state),n,e,"editor")}})),Xf=Ct.define({enables:OX}),zR=new WeakMap;function UN(n){let e=n.facet(Xf),t=zR.get(e);return t||zR.set(e,t=bX(e.reduce((r,i)=>r.concat(i),[]))),t}function vX(n,e,t){return BN(UN(n.state),e,n,t)}let El=null;const yX=4e3;function bX(n,e=mX){let t=Object.create(null),r=Object.create(null),i=(s,a)=>{let l=r[s];if(l==null)r[s]=a;else if(l!=a)throw new Error("Key binding "+s+" is used both as a regular binding and as a multi-stroke prefix")},o=(s,a,l,c,u)=>{var d,h;let p=t[s]||(t[s]=Object.create(null)),g=a.split(/ (?!$)/).map(b=>gX(b,e));for(let b=1;b<g.length;b++){let S=g.slice(0,b).join(" ");i(S,!0),p[S]||(p[S]={preventDefault:!0,stopPropagation:!1,run:[x=>{let P=El={view:x,prefix:S,scope:s};return setTimeout(()=>{El==P&&(El=null)},yX),!0}]})}let O=g.join(" ");i(O,!1);let v=p[O]||(p[O]={preventDefault:!1,stopPropagation:!1,run:((h=(d=p._any)===null||d===void 0?void 0:d.run)===null||h===void 0?void 0:h.slice())||[]});l&&v.run.push(l),c&&(v.preventDefault=!0),u&&(v.stopPropagation=!0)};for(let s of n){let a=s.scope?s.scope.split(" "):["editor"];if(s.any)for(let c of a){let u=t[c]||(t[c]=Object.create(null));u._any||(u._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:d}=s;for(let h in u)u[h].run.push(p=>d(p,fk))}let l=s[e]||s.key;if(l)for(let c of a)o(c,l,s.run,s.preventDefault,s.stopPropagation),s.shift&&o(c,"Shift-"+l,s.shift,s.preventDefault,s.stopPropagation)}return t}let fk=null;function BN(n,e,t,r){fk=e;let i=BZ(e),o=co(i,0),s=ia(o)==i.length&&i!=" ",a="",l=!1,c=!1,u=!1;El&&El.view==t&&El.scope==r&&(a=El.prefix+" ",RN.indexOf(e.keyCode)<0&&(c=!0,El=null));let d=new Set,h=v=>{if(v){for(let b of v.run)if(!d.has(b)&&(d.add(b),b(t)))return v.stopPropagation&&(u=!0),!0;v.preventDefault&&(v.stopPropagation&&(u=!0),c=!0)}return!1},p=n[r],g,O;return p&&(h(p[a+Im(i,e,!s)])?l=!0:s&&(e.altKey||e.metaKey||e.ctrlKey)&&!(Mt.windows&&e.ctrlKey&&e.altKey)&&(g=Xl[e.keyCode])&&g!=i?(h(p[a+Im(g,e,!0)])||e.shiftKey&&(O=Mh[e.keyCode])!=i&&O!=g&&h(p[a+Im(O,e,!1)]))&&(l=!0):s&&e.shiftKey&&h(p[a+Im(i,e,!0)])&&(l=!0),!l&&h(p._any)&&(l=!0)),c&&(l=!0),l&&u&&e.stopPropagation(),fk=null,l}class cp{constructor(e,t,r,i,o){this.className=e,this.left=t,this.top=r,this.width=i,this.height=o}draw(){let e=document.createElement("div");return e.className=this.className,this.adjust(e),e}update(e,t){return t.className!=this.className?!1:(this.adjust(e),!0)}adjust(e){e.style.left=this.left+"px",e.style.top=this.top+"px",this.width!=null&&(e.style.width=this.width+"px"),e.style.height=this.height+"px"}eq(e){return this.left==e.left&&this.top==e.top&&this.width==e.width&&this.height==e.height&&this.className==e.className}static forRange(e,t,r){if(r.empty){let i=e.coordsAtPos(r.head,r.assoc||1);if(!i)return[];let o=FN(e);return[new cp(t,i.left-o.left,i.top-o.top,null,i.bottom-i.top)]}else return SX(e,t,r)}}function FN(n){let e=n.scrollDOM.getBoundingClientRect();return{left:(n.textDirection==vr.LTR?e.left:e.right-n.scrollDOM.clientWidth*n.scaleX)-n.scrollDOM.scrollLeft*n.scaleX,top:e.top-n.scrollDOM.scrollTop*n.scaleY}}function YR(n,e,t,r){let i=n.coordsAtPos(e,t*2);if(!i)return r;let o=n.dom.getBoundingClientRect(),s=(i.top+i.bottom)/2,a=n.posAtCoords({x:o.left+1,y:s}),l=n.posAtCoords({x:o.right-1,y:s});return a==null||l==null?r:{from:Math.max(r.from,Math.min(a,l)),to:Math.min(r.to,Math.max(a,l))}}function SX(n,e,t){if(t.to<=n.viewport.from||t.from>=n.viewport.to)return[];let r=Math.max(t.from,n.viewport.from),i=Math.min(t.to,n.viewport.to),o=n.textDirection==vr.LTR,s=n.contentDOM,a=s.getBoundingClientRect(),l=FN(n),c=s.querySelector(".cm-line"),u=c&&window.getComputedStyle(c),d=a.left+(u?parseInt(u.paddingLeft)+Math.min(0,parseInt(u.textIndent)):0),h=a.right-(u?parseInt(u.paddingRight):0),p=sk(n,r),g=sk(n,i),O=p.type==Xi.Text?p:null,v=g.type==Xi.Text?g:null;if(O&&(n.lineWrapping||p.widgetLineBreaks)&&(O=YR(n,r,1,O)),v&&(n.lineWrapping||g.widgetLineBreaks)&&(v=YR(n,i,-1,v)),O&&v&&O.from==v.from&&O.to==v.to)return S(x(t.from,t.to,O));{let w=O?x(t.from,null,O):P(p,!1),E=v?x(null,t.to,v):P(g,!0),M=[];return(O||p).to<(v||g).from-(O&&v?1:0)||p.widgetLineBreaks>1&&w.bottom+n.defaultLineHeight/2<E.top?M.push(b(d,w.bottom,h,E.top)):w.bottom<E.top&&n.elementAtHeight((w.bottom+E.top)/2).type==Xi.Text&&(w.bottom=E.top=(w.bottom+E.top)/2),S(w).concat(M).concat(S(E))}function b(w,E,M,Q){return new cp(e,w-l.left,E-l.top,M-w,Q-E)}function S({top:w,bottom:E,horizontal:M}){let Q=[];for(let T=0;T<M.length;T+=2)Q.push(b(M[T],w,M[T+1],E));return Q}function x(w,E,M){let Q=1e9,T=-1e9,R=[];function $(H,oe,F,Z,W){let te=n.coordsAtPos(H,H==M.to?-2:2),ie=n.coordsAtPos(F,F==M.from?2:-2);!te||!ie||(Q=Math.min(te.top,ie.top,Q),T=Math.max(te.bottom,ie.bottom,T),W==vr.LTR?R.push(o&&oe?d:te.left,o&&Z?h:ie.right):R.push(!o&&Z?d:ie.left,!o&&oe?h:te.right))}let I=w??M.from,B=E??M.to;for(let H of n.visibleRanges)if(H.to>I&&H.from<B)for(let oe=Math.max(H.from,I),F=Math.min(H.to,B);;){let Z=n.state.doc.lineAt(oe);for(let W of n.bidiSpans(Z)){let te=W.from+Z.from,ie=W.to+Z.from;if(te>=F)break;ie>oe&&$(Math.max(te,oe),w==null&&te<=I,Math.min(ie,F),E==null&&ie>=B,W.dir)}if(oe=Z.to+1,oe>=F)break}return R.length==0&&$(I,w==null,B,E==null,n.textDirection),{top:Q,bottom:T,horizontal:R}}function P(w,E){let M=a.top+(E?w.top:w.bottom);return{top:M,bottom:M,horizontal:[]}}}function wX(n,e){return n.constructor==e.constructor&&n.eq(e)}class kX{constructor(e,t){this.view=e,this.layer=t,this.drawn=[],this.scaleX=1,this.scaleY=1,this.measureReq={read:this.measure.bind(this),write:this.draw.bind(this)},this.dom=e.scrollDOM.appendChild(document.createElement("div")),this.dom.classList.add("cm-layer"),t.above&&this.dom.classList.add("cm-layer-above"),t.class&&this.dom.classList.add(t.class),this.scale(),this.dom.setAttribute("aria-hidden","true"),this.setOrder(e.state),e.requestMeasure(this.measureReq),t.mount&&t.mount(this.dom,e)}update(e){e.startState.facet(EO)!=e.state.facet(EO)&&this.setOrder(e.state),(this.layer.update(e,this.dom)||e.geometryChanged)&&(this.scale(),e.view.requestMeasure(this.measureReq))}docViewUpdate(e){this.layer.updateOnDocViewUpdate!==!1&&e.requestMeasure(this.measureReq)}setOrder(e){let t=0,r=e.facet(EO);for(;t<r.length&&r[t]!=this.layer;)t++;this.dom.style.zIndex=String((this.layer.above?150:-1)-t)}measure(){return this.layer.markers(this.view)}scale(){let{scaleX:e,scaleY:t}=this.view;(e!=this.scaleX||t!=this.scaleY)&&(this.scaleX=e,this.scaleY=t,this.dom.style.transform=`scale(${1/e}, ${1/t})`)}draw(e){if(e.length!=this.drawn.length||e.some((t,r)=>!wX(t,this.drawn[r]))){let t=this.dom.firstChild,r=0;for(let i of e)i.update&&t&&i.constructor&&this.drawn[r].constructor&&i.update(t,this.drawn[r])?(t=t.nextSibling,r++):this.dom.insertBefore(i.draw(),t);for(;t;){let i=t.nextSibling;t.remove(),t=i}this.drawn=e}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}}const EO=Ct.define();function VN(n){return[nr.define(e=>new kX(e,n)),EO.of(n)]}const Ih=Ct.define({combine(n){return $s(n,{cursorBlinkRate:1200,drawRangeCursor:!0},{cursorBlinkRate:(e,t)=>Math.min(e,t),drawRangeCursor:(e,t)=>e||t})}});function PX(n={}){return[Ih.of(n),xX,CX,TX,yN.of(!0)]}function WN(n){return n.startState.facet(Ih)!=n.state.facet(Ih)}const xX=VN({above:!0,markers(n){let{state:e}=n,t=e.facet(Ih),r=[];for(let i of e.selection.ranges){let o=i==e.selection.main;if(i.empty||t.drawRangeCursor){let s=o?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",a=i.empty?i:Ie.cursor(i.head,i.head>i.anchor?-1:1);for(let l of cp.forRange(n,s,a))r.push(l)}}return r},update(n,e){n.transactions.some(r=>r.selection)&&(e.style.animationName=e.style.animationName=="cm-blink"?"cm-blink2":"cm-blink");let t=WN(n);return t&&GR(n.state,e),n.docChanged||n.selectionSet||t},mount(n,e){GR(e.state,n)},class:"cm-cursorLayer"});function GR(n,e){e.style.animationDuration=n.facet(Ih).cursorBlinkRate+"ms"}const CX=VN({above:!1,markers(n){return n.state.selection.ranges.map(e=>e.empty?[]:cp.forRange(n,"cm-selectionBackground",e)).reduce((e,t)=>e.concat(t))},update(n,e){return n.docChanged||n.selectionSet||n.viewportChanged||WN(n)},class:"cm-selectionLayer"}),TX=pa.highest(ft.theme({".cm-line":{"& ::selection, &::selection":{backgroundColor:"transparent !important"},caretColor:"transparent !important"},".cm-content":{caretColor:"transparent !important","& :focus":{caretColor:"initial !important","&::selection, & ::selection":{backgroundColor:"Highlight !important"}}}})),ZN=cn.define({map(n,e){return n==null?null:e.mapPos(n)}}),uh=Kr.define({create(){return null},update(n,e){return n!=null&&(n=e.changes.mapPos(n)),e.effects.reduce((t,r)=>r.is(ZN)?r.value:t,n)}}),_X=nr.fromClass(class{constructor(n){this.view=n,this.cursor=null,this.measureReq={read:this.readPos.bind(this),write:this.drawCursor.bind(this)}}update(n){var e;let t=n.state.field(uh);t==null?this.cursor!=null&&((e=this.cursor)===null||e===void 0||e.remove(),this.cursor=null):(this.cursor||(this.cursor=this.view.scrollDOM.appendChild(document.createElement("div")),this.cursor.className="cm-dropCursor"),(n.startState.field(uh)!=t||n.docChanged||n.geometryChanged)&&this.view.requestMeasure(this.measureReq))}readPos(){let{view:n}=this,e=n.state.field(uh),t=e!=null&&n.coordsAtPos(e);if(!t)return null;let r=n.scrollDOM.getBoundingClientRect();return{left:t.left-r.left+n.scrollDOM.scrollLeft*n.scaleX,top:t.top-r.top+n.scrollDOM.scrollTop*n.scaleY,height:t.bottom-t.top}}drawCursor(n){if(this.cursor){let{scaleX:e,scaleY:t}=this.view;n?(this.cursor.style.left=n.left/e+"px",this.cursor.style.top=n.top/t+"px",this.cursor.style.height=n.height/t+"px"):this.cursor.style.left="-100000px"}}destroy(){this.cursor&&this.cursor.remove()}setDropPos(n){this.view.state.field(uh)!=n&&this.view.dispatch({effects:ZN.of(n)})}},{eventObservers:{dragover(n){this.setDropPos(this.view.posAtCoords({x:n.clientX,y:n.clientY}))},dragleave(n){(n.target==this.view.contentDOM||!this.view.contentDOM.contains(n.relatedTarget))&&this.setDropPos(null)},dragend(){this.setDropPos(null)},drop(){this.setDropPos(null)}}});function EX(){return[uh,_X]}function HR(n,e,t,r,i){e.lastIndex=0;for(let o=n.iterRange(t,r),s=t,a;!o.next().done;s+=o.value.length)if(!o.lineBreak)for(;a=e.exec(o.value);)i(s+a.index,a)}function RX(n,e){let t=n.visibleRanges;if(t.length==1&&t[0].from==n.viewport.from&&t[0].to==n.viewport.to)return t;let r=[];for(let{from:i,to:o}of t)i=Math.max(n.state.doc.lineAt(i).from,i-e),o=Math.min(n.state.doc.lineAt(o).to,o+e),r.length&&r[r.length-1].to>=i?r[r.length-1].to=o:r.push({from:i,to:o});return r}class AX{constructor(e){const{regexp:t,decoration:r,decorate:i,boundary:o,maxLength:s=1e3}=e;if(!t.global)throw new RangeError("The regular expression given to MatchDecorator should have its 'g' flag set");if(this.regexp=t,i)this.addMatch=(a,l,c,u)=>i(u,c,c+a[0].length,a,l);else if(typeof r=="function")this.addMatch=(a,l,c,u)=>{let d=r(a,l,c);d&&u(c,c+a[0].length,d)};else if(r)this.addMatch=(a,l,c,u)=>u(c,c+a[0].length,r);else throw new RangeError("Either 'decorate' or 'decoration' should be provided to MatchDecorator");this.boundary=o,this.maxLength=s}createDeco(e){let t=new Ua,r=t.add.bind(t);for(let{from:i,to:o}of RX(e,this.maxLength))HR(e.state.doc,this.regexp,i,o,(s,a)=>this.addMatch(a,e,s,r));return t.finish()}updateDeco(e,t){let r=1e9,i=-1;return e.docChanged&&e.changes.iterChanges((o,s,a,l)=>{l>=e.view.viewport.from&&a<=e.view.viewport.to&&(r=Math.min(a,r),i=Math.max(l,i))}),e.viewportMoved||i-r>1e3?this.createDeco(e.view):i>-1?this.updateRange(e.view,t.map(e.changes),r,i):t}updateRange(e,t,r,i){for(let o of e.visibleRanges){let s=Math.max(o.from,r),a=Math.min(o.to,i);if(a>s){let l=e.state.doc.lineAt(s),c=l.to<a?e.state.doc.lineAt(a):l,u=Math.max(o.from,l.from),d=Math.min(o.to,c.to);if(this.boundary){for(;s>l.from;s--)if(this.boundary.test(l.text[s-1-l.from])){u=s;break}for(;a<c.to;a++)if(this.boundary.test(c.text[a-c.from])){d=a;break}}let h=[],p,g=(O,v,b)=>h.push(b.range(O,v));if(l==c)for(this.regexp.lastIndex=u-l.from;(p=this.regexp.exec(l.text))&&p.index<d-l.from;)this.addMatch(p,e,p.index+l.from,g);else HR(e.state.doc,this.regexp,u,d,(O,v)=>this.addMatch(v,e,O,g));t=t.update({filterFrom:u,filterTo:d,filter:(O,v)=>O<u||v>d,add:h})}}return t}}const dk=/x/.unicode!=null?"gu":"g",MX=new RegExp(`[\0-\b
|
|
126
126
|
--\u2028\u2029\uFEFF-]`,dk),$X={0:"null",7:"bell",8:"backspace",10:"newline",11:"vertical tab",13:"carriage return",27:"escape",8203:"zero width space",8204:"zero width non-joiner",8205:"zero width joiner",8206:"left-to-right mark",8207:"right-to-left mark",8232:"line separator",8237:"left-to-right override",8238:"right-to-left override",8294:"left-to-right isolate",8295:"right-to-left isolate",8297:"pop directional isolate",8233:"paragraph separator",65279:"zero width no-break space",65532:"object replacement"};let Bb=null;function DX(){var n;if(Bb==null&&typeof document<"u"&&document.body){let e=document.body.style;Bb=((n=e.tabSize)!==null&&n!==void 0?n:e.MozTabSize)!=null}return Bb||!1}const RO=Ct.define({combine(n){let e=$s(n,{render:null,specialChars:MX,addSpecialChars:null});return(e.replaceTabs=!DX())&&(e.specialChars=new RegExp(" |"+e.specialChars.source,dk)),e.addSpecialChars&&(e.specialChars=new RegExp(e.specialChars.source+"|"+e.addSpecialChars.source,dk)),e}});function QX(n={}){return[RO.of(n),IX()]}let KR=null;function IX(){return KR||(KR=nr.fromClass(class{constructor(n){this.view=n,this.decorations=_t.none,this.decorationCache=Object.create(null),this.decorator=this.makeDecorator(n.state.facet(RO)),this.decorations=this.decorator.createDeco(n)}makeDecorator(n){return new AX({regexp:n.specialChars,decoration:(e,t,r)=>{let{doc:i}=t.state,o=co(e[0],0);if(o==9){let s=i.lineAt(r),a=t.state.tabSize,l=Rs(s.text,a,r-s.from);return _t.replace({widget:new qX((a-l%a)*this.view.defaultCharacterWidth/this.view.scaleX)})}return this.decorationCache[o]||(this.decorationCache[o]=_t.replace({widget:new NX(n,o)}))},boundary:n.replaceTabs?void 0:/[^]/})}update(n){let e=n.state.facet(RO);n.startState.facet(RO)!=e?(this.decorator=this.makeDecorator(e),this.decorations=this.decorator.createDeco(n.view)):this.decorations=this.decorator.updateDeco(n,this.decorations)}},{decorations:n=>n.decorations}))}const jX="•";function LX(n){return n>=32?jX:n==10?"":String.fromCharCode(9216+n)}class NX extends Io{constructor(e,t){super(),this.options=e,this.code=t}eq(e){return e.code==this.code}toDOM(e){let t=LX(this.code),r=e.state.phrase("Control character")+" "+($X[this.code]||"0x"+this.code.toString(16)),i=this.options.render&&this.options.render(this.code,r,t);if(i)return i;let o=document.createElement("span");return o.textContent=t,o.title=r,o.setAttribute("aria-label",r),o.className="cm-specialChar",o}ignoreEvent(){return!1}}class qX extends Io{constructor(e){super(),this.width=e}eq(e){return e.width==this.width}toDOM(){let e=document.createElement("span");return e.textContent=" ",e.className="cm-tab",e.style.width=this.width+"px",e}ignoreEvent(){return!1}}function UX(){return FX}const BX=_t.line({class:"cm-activeLine"}),FX=nr.fromClass(class{constructor(n){this.decorations=this.getDeco(n)}update(n){(n.docChanged||n.selectionSet)&&(this.decorations=this.getDeco(n.view))}getDeco(n){let e=-1,t=[];for(let r of n.state.selection.ranges){let i=n.lineBlockAt(r.head);i.from>e&&(t.push(BX.range(i.from)),e=i.from)}return _t.set(t)}},{decorations:n=>n.decorations}),hk=2e3;function VX(n,e,t){let r=Math.min(e.line,t.line),i=Math.max(e.line,t.line),o=[];if(e.off>hk||t.off>hk||e.col<0||t.col<0){let s=Math.min(e.off,t.off),a=Math.max(e.off,t.off);for(let l=r;l<=i;l++){let c=n.doc.line(l);c.length<=a&&o.push(Ie.range(c.from+s,c.to+a))}}else{let s=Math.min(e.col,t.col),a=Math.max(e.col,t.col);for(let l=r;l<=i;l++){let c=n.doc.line(l),u=W1(c.text,s,n.tabSize,!0);if(u<0)o.push(Ie.cursor(c.to));else{let d=W1(c.text,a,n.tabSize);o.push(Ie.range(c.from+u,c.from+d))}}}return o}function WX(n,e){let t=n.coordsAtPos(n.viewport.from);return t?Math.round(Math.abs((t.left-e)/n.defaultCharacterWidth)):-1}function JR(n,e){let t=n.posAtCoords({x:e.clientX,y:e.clientY},!1),r=n.state.doc.lineAt(t),i=t-r.from,o=i>hk?-1:i==r.length?WX(n,e.clientX):Rs(r.text,n.state.tabSize,t-r.from);return{line:r.number,col:o,off:i}}function ZX(n,e){let t=JR(n,e),r=n.state.selection;return t?{update(i){if(i.docChanged){let o=i.changes.mapPos(i.startState.doc.line(t.line).from),s=i.state.doc.lineAt(o);t={line:s.number,col:t.col,off:Math.min(t.off,s.length)},r=r.map(i.changes)}},get(i,o,s){let a=JR(n,i);if(!a)return r;let l=VX(n.state,t,a);return l.length?s?Ie.create(l.concat(r.ranges)):Ie.create(l):r}}:null}function XX(n){let e=t=>t.altKey&&t.button==0;return ft.mouseSelectionStyle.of((t,r)=>e(r)?ZX(t,r):null)}const zX={Alt:[18,n=>!!n.altKey],Control:[17,n=>!!n.ctrlKey],Shift:[16,n=>!!n.shiftKey],Meta:[91,n=>!!n.metaKey]},YX={style:"cursor: crosshair"};function GX(n={}){let[e,t]=zX[n.key||"Alt"],r=nr.fromClass(class{constructor(i){this.view=i,this.isDown=!1}set(i){this.isDown!=i&&(this.isDown=i,this.view.update([]))}},{eventObservers:{keydown(i){this.set(i.keyCode==e||t(i))},keyup(i){(i.keyCode==e||!t(i))&&this.set(!1)},mousemove(i){this.set(t(i))}}});return[r,ft.contentAttributes.of(i=>{var o;return!((o=i.plugin(r))===null||o===void 0)&&o.isDown?YX:null})]}const Id="-10000px";class XN{constructor(e,t,r,i){this.facet=t,this.createTooltipView=r,this.removeTooltipView=i,this.input=e.state.facet(t),this.tooltips=this.input.filter(s=>s);let o=null;this.tooltipViews=this.tooltips.map(s=>o=r(s,o))}update(e,t){var r;let i=e.state.facet(this.facet),o=i.filter(l=>l);if(i===this.input){for(let l of this.tooltipViews)l.update&&l.update(e);return!1}let s=[],a=t?[]:null;for(let l=0;l<o.length;l++){let c=o[l],u=-1;if(c){for(let d=0;d<this.tooltips.length;d++){let h=this.tooltips[d];h&&h.create==c.create&&(u=d)}if(u<0)s[l]=this.createTooltipView(c,l?s[l-1]:null),a&&(a[l]=!!c.above);else{let d=s[l]=this.tooltipViews[u];a&&(a[l]=t[u]),d.update&&d.update(e)}}}for(let l of this.tooltipViews)s.indexOf(l)<0&&(this.removeTooltipView(l),(r=l.destroy)===null||r===void 0||r.call(l));return t&&(a.forEach((l,c)=>t[c]=l),t.length=a.length),this.input=i,this.tooltips=o,this.tooltipViews=s,!0}}function HX(n){let e=n.dom.ownerDocument.documentElement;return{top:0,left:0,bottom:e.clientHeight,right:e.clientWidth}}const Fb=Ct.define({combine:n=>{var e,t,r;return{position:Mt.ios?"absolute":((e=n.find(i=>i.position))===null||e===void 0?void 0:e.position)||"fixed",parent:((t=n.find(i=>i.parent))===null||t===void 0?void 0:t.parent)||null,tooltipSpace:((r=n.find(i=>i.tooltipSpace))===null||r===void 0?void 0:r.tooltipSpace)||HX}}}),eA=new WeakMap,XP=nr.fromClass(class{constructor(n){this.view=n,this.above=[],this.inView=!0,this.madeAbsolute=!1,this.lastTransaction=0,this.measureTimeout=-1;let e=n.state.facet(Fb);this.position=e.position,this.parent=e.parent,this.classes=n.themeClasses,this.createContainer(),this.measureReq={read:this.readMeasure.bind(this),write:this.writeMeasure.bind(this),key:this},this.resizeObserver=typeof ResizeObserver=="function"?new ResizeObserver(()=>this.measureSoon()):null,this.manager=new XN(n,zP,(t,r)=>this.createTooltip(t,r),t=>{this.resizeObserver&&this.resizeObserver.unobserve(t.dom),t.dom.remove()}),this.above=this.manager.tooltips.map(t=>!!t.above),this.intersectionObserver=typeof IntersectionObserver=="function"?new IntersectionObserver(t=>{Date.now()>this.lastTransaction-50&&t.length>0&&t[t.length-1].intersectionRatio<1&&this.measureSoon()},{threshold:[1]}):null,this.observeIntersection(),n.win.addEventListener("resize",this.measureSoon=this.measureSoon.bind(this)),this.maybeMeasure()}createContainer(){this.parent?(this.container=document.createElement("div"),this.container.style.position="relative",this.container.className=this.view.themeClasses,this.parent.appendChild(this.container)):this.container=this.view.dom}observeIntersection(){if(this.intersectionObserver){this.intersectionObserver.disconnect();for(let n of this.manager.tooltipViews)this.intersectionObserver.observe(n.dom)}}measureSoon(){this.measureTimeout<0&&(this.measureTimeout=setTimeout(()=>{this.measureTimeout=-1,this.maybeMeasure()},50))}update(n){n.transactions.length&&(this.lastTransaction=Date.now());let e=this.manager.update(n,this.above);e&&this.observeIntersection();let t=e||n.geometryChanged,r=n.state.facet(Fb);if(r.position!=this.position&&!this.madeAbsolute){this.position=r.position;for(let i of this.manager.tooltipViews)i.dom.style.position=this.position;t=!0}if(r.parent!=this.parent){this.parent&&this.container.remove(),this.parent=r.parent,this.createContainer();for(let i of this.manager.tooltipViews)this.container.appendChild(i.dom);t=!0}else this.parent&&this.view.themeClasses!=this.classes&&(this.classes=this.container.className=this.view.themeClasses);t&&this.maybeMeasure()}createTooltip(n,e){let t=n.create(this.view),r=e?e.dom:null;if(t.dom.classList.add("cm-tooltip"),n.arrow&&!t.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")){let i=document.createElement("div");i.className="cm-tooltip-arrow",t.dom.appendChild(i)}return t.dom.style.position=this.position,t.dom.style.top=Id,t.dom.style.left="0px",this.container.insertBefore(t.dom,r),t.mount&&t.mount(this.view),this.resizeObserver&&this.resizeObserver.observe(t.dom),t}destroy(){var n,e,t;this.view.win.removeEventListener("resize",this.measureSoon);for(let r of this.manager.tooltipViews)r.dom.remove(),(n=r.destroy)===null||n===void 0||n.call(r);this.parent&&this.container.remove(),(e=this.resizeObserver)===null||e===void 0||e.disconnect(),(t=this.intersectionObserver)===null||t===void 0||t.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let n=1,e=1,t=!1;if(this.position=="fixed"&&this.manager.tooltipViews.length){let{dom:o}=this.manager.tooltipViews[0];if(Mt.gecko)t=o.offsetParent!=this.container.ownerDocument.body;else if(o.style.top==Id&&o.style.left=="0px"){let s=o.getBoundingClientRect();t=Math.abs(s.top+1e4)>1||Math.abs(s.left)>1}}if(t||this.position=="absolute")if(this.parent){let o=this.parent.getBoundingClientRect();o.width&&o.height&&(n=o.width/this.parent.offsetWidth,e=o.height/this.parent.offsetHeight)}else({scaleX:n,scaleY:e}=this.view.viewState);let r=this.view.scrollDOM.getBoundingClientRect(),i=FP(this.view);return{visible:{left:r.left+i.left,top:r.top+i.top,right:r.right-i.right,bottom:r.bottom-i.bottom},parent:this.parent?this.container.getBoundingClientRect():this.view.dom.getBoundingClientRect(),pos:this.manager.tooltips.map((o,s)=>{let a=this.manager.tooltipViews[s];return a.getCoords?a.getCoords(o.pos):this.view.coordsAtPos(o.pos)}),size:this.manager.tooltipViews.map(({dom:o})=>o.getBoundingClientRect()),space:this.view.state.facet(Fb).tooltipSpace(this.view),scaleX:n,scaleY:e,makeAbsolute:t}}writeMeasure(n){var e;if(n.makeAbsolute){this.madeAbsolute=!0,this.position="absolute";for(let a of this.manager.tooltipViews)a.dom.style.position="absolute"}let{visible:t,space:r,scaleX:i,scaleY:o}=n,s=[];for(let a=0;a<this.manager.tooltips.length;a++){let l=this.manager.tooltips[a],c=this.manager.tooltipViews[a],{dom:u}=c,d=n.pos[a],h=n.size[a];if(!d||l.clip!==!1&&(d.bottom<=Math.max(t.top,r.top)||d.top>=Math.min(t.bottom,r.bottom)||d.right<Math.max(t.left,r.left)-.1||d.left>Math.min(t.right,r.right)+.1)){u.style.top=Id;continue}let p=l.arrow?c.dom.querySelector(".cm-tooltip-arrow"):null,g=p?7:0,O=h.right-h.left,v=(e=eA.get(c))!==null&&e!==void 0?e:h.bottom-h.top,b=c.offset||JX,S=this.view.textDirection==vr.LTR,x=h.width>r.right-r.left?S?r.left:r.right-h.width:S?Math.max(r.left,Math.min(d.left-(p?14:0)+b.x,r.right-O)):Math.min(Math.max(r.left,d.left-O+(p?14:0)-b.x),r.right-O),P=this.above[a];!l.strictSide&&(P?d.top-v-g-b.y<r.top:d.bottom+v+g+b.y>r.bottom)&&P==r.bottom-d.bottom>d.top-r.top&&(P=this.above[a]=!P);let w=(P?d.top-r.top:r.bottom-d.bottom)-g;if(w<v&&c.resize!==!1){if(w<this.view.defaultLineHeight){u.style.top=Id;continue}eA.set(c,v),u.style.height=(v=w)/o+"px"}else u.style.height&&(u.style.height="");let E=P?d.top-v-g-b.y:d.bottom+g+b.y,M=x+O;if(c.overlap!==!0)for(let Q of s)Q.left<M&&Q.right>x&&Q.top<E+v&&Q.bottom>E&&(E=P?Q.top-v-2-g:Q.bottom+g+2);if(this.position=="absolute"?(u.style.top=(E-n.parent.top)/o+"px",tA(u,(x-n.parent.left)/i)):(u.style.top=E/o+"px",tA(u,x/i)),p){let Q=d.left+(S?b.x:-b.x)-(x+14-7);p.style.left=Q/i+"px"}c.overlap!==!0&&s.push({left:x,top:E,right:M,bottom:E+v}),u.classList.toggle("cm-tooltip-above",P),u.classList.toggle("cm-tooltip-below",!P),c.positioned&&c.positioned(n.space)}}maybeMeasure(){if(this.manager.tooltips.length&&(this.view.inView&&this.view.requestMeasure(this.measureReq),this.inView!=this.view.inView&&(this.inView=this.view.inView,!this.inView)))for(let n of this.manager.tooltipViews)n.dom.style.top=Id}},{eventObservers:{scroll(){this.maybeMeasure()}}});function tA(n,e){let t=parseInt(n.style.left,10);(isNaN(t)||Math.abs(e-t)>1)&&(n.style.left=e+"px")}const KX=ft.baseTheme({".cm-tooltip":{zIndex:500,boxSizing:"border-box"},"&light .cm-tooltip":{border:"1px solid #bbb",backgroundColor:"#f5f5f5"},"&light .cm-tooltip-section:not(:first-child)":{borderTop:"1px solid #bbb"},"&dark .cm-tooltip":{backgroundColor:"#333338",color:"white"},".cm-tooltip-arrow":{height:"7px",width:`${7*2}px`,position:"absolute",zIndex:-1,overflow:"hidden","&:before, &:after":{content:"''",position:"absolute",width:0,height:0,borderLeft:"7px solid transparent",borderRight:"7px solid transparent"},".cm-tooltip-above &":{bottom:"-7px","&:before":{borderTop:"7px solid #bbb"},"&:after":{borderTop:"7px solid #f5f5f5",bottom:"1px"}},".cm-tooltip-below &":{top:"-7px","&:before":{borderBottom:"7px solid #bbb"},"&:after":{borderBottom:"7px solid #f5f5f5",top:"1px"}}},"&dark .cm-tooltip .cm-tooltip-arrow":{"&:before":{borderTopColor:"#333338",borderBottomColor:"#333338"},"&:after":{borderTopColor:"transparent",borderBottomColor:"transparent"}}}),JX={x:0,y:0},zP=Ct.define({enables:[XP,KX]}),fv=Ct.define({combine:n=>n.reduce((e,t)=>e.concat(t),[])});class oy{static create(e){return new oy(e)}constructor(e){this.view=e,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new XN(e,fv,(t,r)=>this.createHostedView(t,r),t=>t.dom.remove())}createHostedView(e,t){let r=e.create(this.view);return r.dom.classList.add("cm-tooltip-section"),this.dom.insertBefore(r.dom,t?t.dom.nextSibling:this.dom.firstChild),this.mounted&&r.mount&&r.mount(this.view),r}mount(e){for(let t of this.manager.tooltipViews)t.mount&&t.mount(e);this.mounted=!0}positioned(e){for(let t of this.manager.tooltipViews)t.positioned&&t.positioned(e)}update(e){this.manager.update(e)}destroy(){var e;for(let t of this.manager.tooltipViews)(e=t.destroy)===null||e===void 0||e.call(t)}passProp(e){let t;for(let r of this.manager.tooltipViews){let i=r[e];if(i!==void 0){if(t===void 0)t=i;else if(t!==i)return}}return t}get offset(){return this.passProp("offset")}get getCoords(){return this.passProp("getCoords")}get overlap(){return this.passProp("overlap")}get resize(){return this.passProp("resize")}}const ez=zP.compute([fv],n=>{let e=n.facet(fv);return e.length===0?null:{pos:Math.min(...e.map(t=>t.pos)),end:Math.max(...e.map(t=>{var r;return(r=t.end)!==null&&r!==void 0?r:t.pos})),create:oy.create,above:e[0].above,arrow:e.some(t=>t.arrow)}});class tz{constructor(e,t,r,i,o){this.view=e,this.source=t,this.field=r,this.setHover=i,this.hoverTime=o,this.hoverTimeout=-1,this.restartTimeout=-1,this.pending=null,this.lastMove={x:0,y:0,target:e.dom,time:0},this.checkHover=this.checkHover.bind(this),e.dom.addEventListener("mouseleave",this.mouseleave=this.mouseleave.bind(this)),e.dom.addEventListener("mousemove",this.mousemove=this.mousemove.bind(this))}update(){this.pending&&(this.pending=null,clearTimeout(this.restartTimeout),this.restartTimeout=setTimeout(()=>this.startHover(),20))}get active(){return this.view.state.field(this.field)}checkHover(){if(this.hoverTimeout=-1,this.active.length)return;let e=Date.now()-this.lastMove.time;e<this.hoverTime?this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime-e):this.startHover()}startHover(){clearTimeout(this.restartTimeout);let{view:e,lastMove:t}=this,r=e.docView.nearest(t.target);if(!r)return;let i,o=1;if(r instanceof Dl)i=r.posAtStart;else{if(i=e.posAtCoords(t),i==null)return;let a=e.coordsAtPos(i);if(!a||t.y<a.top||t.y>a.bottom||t.x<a.left-e.defaultCharacterWidth||t.x>a.right+e.defaultCharacterWidth)return;let l=e.bidiSpans(e.state.doc.lineAt(i)).find(u=>u.from<=i&&u.to>=i),c=l&&l.dir==vr.RTL?-1:1;o=t.x<a.left?-c:c}let s=this.source(e,i,o);if(s!=null&&s.then){let a=this.pending={pos:i};s.then(l=>{this.pending==a&&(this.pending=null,l&&!(Array.isArray(l)&&!l.length)&&e.dispatch({effects:this.setHover.of(Array.isArray(l)?l:[l])}))},l=>mo(e.state,l,"hover tooltip"))}else s&&!(Array.isArray(s)&&!s.length)&&e.dispatch({effects:this.setHover.of(Array.isArray(s)?s:[s])})}get tooltip(){let e=this.view.plugin(XP),t=e?e.manager.tooltips.findIndex(r=>r.create==oy.create):-1;return t>-1?e.manager.tooltipViews[t]:null}mousemove(e){var t,r;this.lastMove={x:e.clientX,y:e.clientY,target:e.target,time:Date.now()},this.hoverTimeout<0&&(this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime));let{active:i,tooltip:o}=this;if(i.length&&o&&!nz(o.dom,e)||this.pending){let{pos:s}=i[0]||this.pending,a=(r=(t=i[0])===null||t===void 0?void 0:t.end)!==null&&r!==void 0?r:s;(s==a?this.view.posAtCoords(this.lastMove)!=s:!rz(this.view,s,a,e.clientX,e.clientY))&&(this.view.dispatch({effects:this.setHover.of([])}),this.pending=null)}}mouseleave(e){clearTimeout(this.hoverTimeout),this.hoverTimeout=-1;let{active:t}=this;if(t.length){let{tooltip:r}=this;r&&r.dom.contains(e.relatedTarget)?this.watchTooltipLeave(r.dom):this.view.dispatch({effects:this.setHover.of([])})}}watchTooltipLeave(e){let t=r=>{e.removeEventListener("mouseleave",t),this.active.length&&!this.view.dom.contains(r.relatedTarget)&&this.view.dispatch({effects:this.setHover.of([])})};e.addEventListener("mouseleave",t)}destroy(){clearTimeout(this.hoverTimeout),this.view.dom.removeEventListener("mouseleave",this.mouseleave),this.view.dom.removeEventListener("mousemove",this.mousemove)}}const jm=4;function nz(n,e){let{left:t,right:r,top:i,bottom:o}=n.getBoundingClientRect(),s;if(s=n.querySelector(".cm-tooltip-arrow")){let a=s.getBoundingClientRect();i=Math.min(a.top,i),o=Math.max(a.bottom,o)}return e.clientX>=t-jm&&e.clientX<=r+jm&&e.clientY>=i-jm&&e.clientY<=o+jm}function rz(n,e,t,r,i,o){let s=n.scrollDOM.getBoundingClientRect(),a=n.documentTop+n.documentPadding.top+n.contentHeight;if(s.left>r||s.right<r||s.top>i||Math.min(s.bottom,a)<i)return!1;let l=n.posAtCoords({x:r,y:i},!1);return l>=e&&l<=t}function iz(n,e={}){let t=cn.define(),r=Kr.define({create(){return[]},update(i,o){if(i.length&&(e.hideOnChange&&(o.docChanged||o.selection)?i=[]:e.hideOn&&(i=i.filter(s=>!e.hideOn(o,s))),o.docChanged)){let s=[];for(let a of i){let l=o.changes.mapPos(a.pos,-1,ii.TrackDel);if(l!=null){let c=Object.assign(Object.create(null),a);c.pos=l,c.end!=null&&(c.end=o.changes.mapPos(c.end)),s.push(c)}}i=s}for(let s of o.effects)s.is(t)&&(i=s.value),s.is(oz)&&(i=[]);return i},provide:i=>fv.from(i)});return{active:r,extension:[r,nr.define(i=>new tz(i,n,r,t,e.hoverTime||300)),ez]}}function zN(n,e){let t=n.plugin(XP);if(!t)return null;let r=t.manager.tooltips.indexOf(e);return r<0?null:t.manager.tooltipViews[r]}const oz=cn.define(),nA=Ct.define({combine(n){let e,t;for(let r of n)e=e||r.topContainer,t=t||r.bottomContainer;return{topContainer:e,bottomContainer:t}}});function jh(n,e){let t=n.plugin(YN),r=t?t.specs.indexOf(e):-1;return r>-1?t.panels[r]:null}const YN=nr.fromClass(class{constructor(n){this.input=n.state.facet(Lh),this.specs=this.input.filter(t=>t),this.panels=this.specs.map(t=>t(n));let e=n.state.facet(nA);this.top=new Lm(n,!0,e.topContainer),this.bottom=new Lm(n,!1,e.bottomContainer),this.top.sync(this.panels.filter(t=>t.top)),this.bottom.sync(this.panels.filter(t=>!t.top));for(let t of this.panels)t.dom.classList.add("cm-panel"),t.mount&&t.mount()}update(n){let e=n.state.facet(nA);this.top.container!=e.topContainer&&(this.top.sync([]),this.top=new Lm(n.view,!0,e.topContainer)),this.bottom.container!=e.bottomContainer&&(this.bottom.sync([]),this.bottom=new Lm(n.view,!1,e.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let t=n.state.facet(Lh);if(t!=this.input){let r=t.filter(l=>l),i=[],o=[],s=[],a=[];for(let l of r){let c=this.specs.indexOf(l),u;c<0?(u=l(n.view),a.push(u)):(u=this.panels[c],u.update&&u.update(n)),i.push(u),(u.top?o:s).push(u)}this.specs=r,this.panels=i,this.top.sync(o),this.bottom.sync(s);for(let l of a)l.dom.classList.add("cm-panel"),l.mount&&l.mount()}else for(let r of this.panels)r.update&&r.update(n)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:n=>ft.scrollMargins.of(e=>{let t=e.plugin(n);return t&&{top:t.top.scrollMargin(),bottom:t.bottom.scrollMargin()}})});class Lm{constructor(e,t,r){this.view=e,this.top=t,this.container=r,this.dom=void 0,this.classes="",this.panels=[],this.syncClasses()}sync(e){for(let t of this.panels)t.destroy&&e.indexOf(t)<0&&t.destroy();this.panels=e,this.syncDOM()}syncDOM(){if(this.panels.length==0){this.dom&&(this.dom.remove(),this.dom=void 0);return}if(!this.dom){this.dom=document.createElement("div"),this.dom.className=this.top?"cm-panels cm-panels-top":"cm-panels cm-panels-bottom",this.dom.style[this.top?"top":"bottom"]="0";let t=this.container||this.view.dom;t.insertBefore(this.dom,this.top?t.firstChild:null)}let e=this.dom.firstChild;for(let t of this.panels)if(t.dom.parentNode==this.dom){for(;e!=t.dom;)e=rA(e);e=e.nextSibling}else this.dom.insertBefore(t.dom,e);for(;e;)e=rA(e)}scrollMargin(){return!this.dom||this.container?0:Math.max(0,this.top?this.dom.getBoundingClientRect().bottom-Math.max(0,this.view.scrollDOM.getBoundingClientRect().top):Math.min(innerHeight,this.view.scrollDOM.getBoundingClientRect().bottom)-this.dom.getBoundingClientRect().top)}syncClasses(){if(!(!this.container||this.classes==this.view.themeClasses)){for(let e of this.classes.split(" "))e&&this.container.classList.remove(e);for(let e of(this.classes=this.view.themeClasses).split(" "))e&&this.container.classList.add(e)}}}function rA(n){let e=n.nextSibling;return n.remove(),e}const Lh=Ct.define({enables:YN});class Yl extends eu{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}}Yl.prototype.elementClass="";Yl.prototype.toDOM=void 0;Yl.prototype.mapMode=ii.TrackBefore;Yl.prototype.startSide=Yl.prototype.endSide=-1;Yl.prototype.point=!0;const AO=Ct.define(),sz=Ct.define(),MO=Ct.define(),iA=Ct.define({combine:n=>n.some(e=>e)});function az(n){return[lz]}const lz=nr.fromClass(class{constructor(n){this.view=n,this.prevViewport=n.viewport,this.dom=document.createElement("div"),this.dom.className="cm-gutters",this.dom.setAttribute("aria-hidden","true"),this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.gutters=n.state.facet(MO).map(e=>new sA(n,e));for(let e of this.gutters)this.dom.appendChild(e.dom);this.fixed=!n.state.facet(iA),this.fixed&&(this.dom.style.position="sticky"),this.syncGutters(!1),n.scrollDOM.insertBefore(this.dom,n.contentDOM)}update(n){if(this.updateGutters(n)){let e=this.prevViewport,t=n.view.viewport,r=Math.min(e.to,t.to)-Math.max(e.from,t.from);this.syncGutters(r<(t.to-t.from)*.8)}n.geometryChanged&&(this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px"),this.view.state.facet(iA)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":""),this.prevViewport=n.view.viewport}syncGutters(n){let e=this.dom.nextSibling;n&&this.dom.remove();let t=zn.iter(this.view.state.facet(AO),this.view.viewport.from),r=[],i=this.gutters.map(o=>new cz(o,this.view.viewport,-this.view.documentPadding.top));for(let o of this.view.viewportLineBlocks)if(r.length&&(r=[]),Array.isArray(o.type)){let s=!0;for(let a of o.type)if(a.type==Xi.Text&&s){pk(t,r,a.from);for(let l of i)l.line(this.view,a,r);s=!1}else if(a.widget)for(let l of i)l.widget(this.view,a)}else if(o.type==Xi.Text){pk(t,r,o.from);for(let s of i)s.line(this.view,o,r)}else if(o.widget)for(let s of i)s.widget(this.view,o);for(let o of i)o.finish();n&&this.view.scrollDOM.insertBefore(this.dom,e)}updateGutters(n){let e=n.startState.facet(MO),t=n.state.facet(MO),r=n.docChanged||n.heightChanged||n.viewportChanged||!zn.eq(n.startState.facet(AO),n.state.facet(AO),n.view.viewport.from,n.view.viewport.to);if(e==t)for(let i of this.gutters)i.update(n)&&(r=!0);else{r=!0;let i=[];for(let o of t){let s=e.indexOf(o);s<0?i.push(new sA(this.view,o)):(this.gutters[s].update(n),i.push(this.gutters[s]))}for(let o of this.gutters)o.dom.remove(),i.indexOf(o)<0&&o.destroy();for(let o of i)this.dom.appendChild(o.dom);this.gutters=i}return r}destroy(){for(let n of this.gutters)n.destroy();this.dom.remove()}},{provide:n=>ft.scrollMargins.of(e=>{let t=e.plugin(n);return!t||t.gutters.length==0||!t.fixed?null:e.textDirection==vr.LTR?{left:t.dom.offsetWidth*e.scaleX}:{right:t.dom.offsetWidth*e.scaleX}})});function oA(n){return Array.isArray(n)?n:[n]}function pk(n,e,t){for(;n.value&&n.from<=t;)n.from==t&&e.push(n.value),n.next()}class cz{constructor(e,t,r){this.gutter=e,this.height=r,this.i=0,this.cursor=zn.iter(e.markers,t.from)}addElement(e,t,r){let{gutter:i}=this,o=(t.top-this.height)/e.scaleY,s=t.height/e.scaleY;if(this.i==i.elements.length){let a=new GN(e,s,o,r);i.elements.push(a),i.dom.appendChild(a.dom)}else i.elements[this.i].update(e,s,o,r);this.height=t.bottom,this.i++}line(e,t,r){let i=[];pk(this.cursor,i,t.from),r.length&&(i=i.concat(r));let o=this.gutter.config.lineMarker(e,t,i);o&&i.unshift(o);let s=this.gutter;i.length==0&&!s.config.renderEmptyElements||this.addElement(e,t,i)}widget(e,t){let r=this.gutter.config.widgetMarker(e,t.widget,t),i=r?[r]:null;for(let o of e.state.facet(sz)){let s=o(e,t.widget,t);s&&(i||(i=[])).push(s)}i&&this.addElement(e,t,i)}finish(){let e=this.gutter;for(;e.elements.length>this.i;){let t=e.elements.pop();e.dom.removeChild(t.dom),t.destroy()}}}class sA{constructor(e,t){this.view=e,this.config=t,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:"");for(let r in t.domEventHandlers)this.dom.addEventListener(r,i=>{let o=i.target,s;if(o!=this.dom&&this.dom.contains(o)){for(;o.parentNode!=this.dom;)o=o.parentNode;let l=o.getBoundingClientRect();s=(l.top+l.bottom)/2}else s=i.clientY;let a=e.lineBlockAtHeight(s-e.documentTop);t.domEventHandlers[r](e,a,i)&&i.preventDefault()});this.markers=oA(t.markers(e)),t.initialSpacer&&(this.spacer=new GN(e,0,0,[t.initialSpacer(e)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none")}update(e){let t=this.markers;if(this.markers=oA(this.config.markers(e.view)),this.spacer&&this.config.updateSpacer){let i=this.config.updateSpacer(this.spacer.markers[0],e);i!=this.spacer.markers[0]&&this.spacer.update(e.view,0,0,[i])}let r=e.view.viewport;return!zn.eq(this.markers,t,r.from,r.to)||(this.config.lineMarkerChange?this.config.lineMarkerChange(e):!1)}destroy(){for(let e of this.elements)e.destroy()}}class GN{constructor(e,t,r,i){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(e,t,r,i)}update(e,t,r,i){this.height!=t&&(this.height=t,this.dom.style.height=t+"px"),this.above!=r&&(this.dom.style.marginTop=(this.above=r)?r+"px":""),uz(this.markers,i)||this.setMarkers(e,i)}setMarkers(e,t){let r="cm-gutterElement",i=this.dom.firstChild;for(let o=0,s=0;;){let a=s,l=o<t.length?t[o++]:null,c=!1;if(l){let u=l.elementClass;u&&(r+=" "+u);for(let d=s;d<this.markers.length;d++)if(this.markers[d].compare(l)){a=d,c=!0;break}}else a=this.markers.length;for(;s<a;){let u=this.markers[s++];if(u.toDOM){u.destroy(i);let d=i.nextSibling;i.remove(),i=d}}if(!l)break;l.toDOM&&(c?i=i.nextSibling:this.dom.insertBefore(l.toDOM(e),i)),c&&s++}this.dom.className=r,this.markers=t}destroy(){this.setMarkers(null,[])}}function uz(n,e){if(n.length!=e.length)return!1;for(let t=0;t<n.length;t++)if(!n[t].compare(e[t]))return!1;return!0}const fz=Ct.define(),dz=Ct.define(),lf=Ct.define({combine(n){return $s(n,{formatNumber:String,domEventHandlers:{}},{domEventHandlers(e,t){let r=Object.assign({},e);for(let i in t){let o=r[i],s=t[i];r[i]=o?(a,l,c)=>o(a,l,c)||s(a,l,c):s}return r}})}});class Vb extends Yl{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}}function Wb(n,e){return n.state.facet(lf).formatNumber(e,n.state)}const hz=MO.compute([lf],n=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(e){return e.state.facet(fz)},lineMarker(e,t,r){return r.some(i=>i.toDOM)?null:new Vb(Wb(e,e.state.doc.lineAt(t.from).number))},widgetMarker:(e,t,r)=>{for(let i of e.state.facet(dz)){let o=i(e,t,r);if(o)return o}return null},lineMarkerChange:e=>e.startState.facet(lf)!=e.state.facet(lf),initialSpacer(e){return new Vb(Wb(e,aA(e.state.doc.lines)))},updateSpacer(e,t){let r=Wb(t.view,aA(t.view.state.doc.lines));return r==e.number?e:new Vb(r)},domEventHandlers:n.facet(lf).domEventHandlers}));function pz(n={}){return[lf.of(n),az(),hz]}function aA(n){let e=9;for(;e<n;)e=e*10+9;return e}const mz=new class extends Yl{constructor(){super(...arguments),this.elementClass="cm-activeLineGutter"}},gz=AO.compute(["selection"],n=>{let e=[],t=-1;for(let r of n.selection.ranges){let i=n.doc.lineAt(r.head).from;i>t&&(t=i,e.push(mz.range(i)))}return zn.of(e)});function Oz(){return gz}const HN=1024;let vz=0;class Jo{constructor(e,t){this.from=e,this.to=t}}class gn{constructor(e={}){this.id=vz++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")})}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof e!="function"&&(e=ai.match(e)),t=>{let r=e(t);return r===void 0?null:[this,r]}}}gn.closedBy=new gn({deserialize:n=>n.split(" ")});gn.openedBy=new gn({deserialize:n=>n.split(" ")});gn.group=new gn({deserialize:n=>n.split(" ")});gn.isolate=new gn({deserialize:n=>{if(n&&n!="rtl"&&n!="ltr"&&n!="auto")throw new RangeError("Invalid value for isolate: "+n);return n||"auto"}});gn.contextHash=new gn({perNode:!0});gn.lookAhead=new gn({perNode:!0});gn.mounted=new gn({perNode:!0});class Nh{constructor(e,t,r){this.tree=e,this.overlay=t,this.parser=r}static get(e){return e&&e.props&&e.props[gn.mounted.id]}}const yz=Object.create(null);class ai{constructor(e,t,r,i=0){this.name=e,this.props=t,this.id=r,this.flags=i}static define(e){let t=e.props&&e.props.length?Object.create(null):yz,r=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),i=new ai(e.name||"",t,e.id,r);if(e.props){for(let o of e.props)if(Array.isArray(o)||(o=o(i)),o){if(o[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");t[o[0].id]=o[1]}}return i}prop(e){return this.props[e.id]}get isTop(){return(this.flags&1)>0}get isSkipped(){return(this.flags&2)>0}get isError(){return(this.flags&4)>0}get isAnonymous(){return(this.flags&8)>0}is(e){if(typeof e=="string"){if(this.name==e)return!0;let t=this.prop(gn.group);return t?t.indexOf(e)>-1:!1}return this.id==e}static match(e){let t=Object.create(null);for(let r in e)for(let i of r.split(" "))t[i]=e[r];return r=>{for(let i=r.prop(gn.group),o=-1;o<(i?i.length:0);o++){let s=t[o<0?r.name:i[o]];if(s)return s}}}}ai.none=new ai("",Object.create(null),0,8);class up{constructor(e){this.types=e;for(let t=0;t<e.length;t++)if(e[t].id!=t)throw new RangeError("Node type ids should correspond to array positions when creating a node set")}extend(...e){let t=[];for(let r of this.types){let i=null;for(let o of e){let s=o(r);s&&(i||(i=Object.assign({},r.props)),i[s[0].id]=s[1])}t.push(i?new ai(r.name,i,r.id,r.flags):r)}return new up(t)}}const Nm=new WeakMap,lA=new WeakMap;var dr;(function(n){n[n.ExcludeBuffers=1]="ExcludeBuffers",n[n.IncludeAnonymous=2]="IncludeAnonymous",n[n.IgnoreMounts=4]="IgnoreMounts",n[n.IgnoreOverlays=8]="IgnoreOverlays"})(dr||(dr={}));class Hn{constructor(e,t,r,i,o){if(this.type=e,this.children=t,this.positions=r,this.length=i,this.props=null,o&&o.length){this.props=Object.create(null);for(let[s,a]of o)this.props[typeof s=="number"?s:s.id]=a}}toString(){let e=Nh.get(this);if(e&&!e.overlay)return e.tree.toString();let t="";for(let r of this.children){let i=r.toString();i&&(t&&(t+=","),t+=i)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(t.length?"("+t+")":""):t}cursor(e=0){return new dv(this.topNode,e)}cursorAt(e,t=0,r=0){let i=Nm.get(this)||this.topNode,o=new dv(i);return o.moveTo(e,t),Nm.set(this,o._tree),o}get topNode(){return new Ni(this,0,0,null)}resolve(e,t=0){let r=qh(Nm.get(this)||this.topNode,e,t,!1);return Nm.set(this,r),r}resolveInner(e,t=0){let r=qh(lA.get(this)||this.topNode,e,t,!0);return lA.set(this,r),r}resolveStack(e,t=0){return wz(this,e,t)}iterate(e){let{enter:t,leave:r,from:i=0,to:o=this.length}=e,s=e.mode||0,a=(s&dr.IncludeAnonymous)>0;for(let l=this.cursor(s|dr.IncludeAnonymous);;){let c=!1;if(l.from<=o&&l.to>=i&&(!a&&l.type.isAnonymous||t(l)!==!1)){if(l.firstChild())continue;c=!0}for(;c&&r&&(a||!l.type.isAnonymous)&&r(l),!l.nextSibling();){if(!l.parent())return;c=!0}}}prop(e){return e.perNode?this.props?this.props[e.id]:void 0:this.type.prop(e)}get propValues(){let e=[];if(this.props)for(let t in this.props)e.push([+t,this.props[t]]);return e}balance(e={}){return this.children.length<=8?this:HP(ai.none,this.children,this.positions,0,this.children.length,0,this.length,(t,r,i)=>new Hn(this.type,t,r,i,this.propValues),e.makeTree||((t,r,i)=>new Hn(ai.none,t,r,i)))}static build(e){return kz(e)}}Hn.empty=new Hn(ai.none,[],[],0);class YP{constructor(e,t){this.buffer=e,this.index=t}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new YP(this.buffer,this.index)}}class Gl{constructor(e,t,r){this.buffer=e,this.length=t,this.set=r}get type(){return ai.none}toString(){let e=[];for(let t=0;t<this.buffer.length;)e.push(this.childString(t)),t=this.buffer[t+3];return e.join(",")}childString(e){let t=this.buffer[e],r=this.buffer[e+3],i=this.set.types[t],o=i.name;if(/\W/.test(o)&&!i.isError&&(o=JSON.stringify(o)),e+=4,r==e)return o;let s=[];for(;e<r;)s.push(this.childString(e)),e=this.buffer[e+3];return o+"("+s.join(",")+")"}findChild(e,t,r,i,o){let{buffer:s}=this,a=-1;for(let l=e;l!=t&&!(KN(o,i,s[l+1],s[l+2])&&(a=l,r>0));l=s[l+3]);return a}slice(e,t,r){let i=this.buffer,o=new Uint16Array(t-e),s=0;for(let a=e,l=0;a<t;){o[l++]=i[a++],o[l++]=i[a++]-r;let c=o[l++]=i[a++]-r;o[l++]=i[a++]-e,s=Math.max(s,c)}return new Gl(o,s,this.set)}}function KN(n,e,t,r){switch(n){case-2:return t<e;case-1:return r>=e&&t<e;case 0:return t<e&&r>e;case 1:return t<=e&&r>e;case 2:return r>e;case 4:return!0}}function qh(n,e,t,r){for(var i;n.from==n.to||(t<1?n.from>=e:n.from>e)||(t>-1?n.to<=e:n.to<e);){let s=!r&&n instanceof Ni&&n.index<0?null:n.parent;if(!s)return n;n=s}let o=r?0:dr.IgnoreOverlays;if(r)for(let s=n,a=s.parent;a;s=a,a=s.parent)s instanceof Ni&&s.index<0&&((i=a.enter(e,t,o))===null||i===void 0?void 0:i.from)!=s.from&&(n=a);for(;;){let s=n.enter(e,t,o);if(!s)return n;n=s}}class JN{cursor(e=0){return new dv(this,e)}getChild(e,t=null,r=null){let i=cA(this,e,t,r);return i.length?i[0]:null}getChildren(e,t=null,r=null){return cA(this,e,t,r)}resolve(e,t=0){return qh(this,e,t,!1)}resolveInner(e,t=0){return qh(this,e,t,!0)}matchContext(e){return mk(this.parent,e)}enterUnfinishedNodesBefore(e){let t=this.childBefore(e),r=this;for(;t;){let i=t.lastChild;if(!i||i.to!=t.to)break;i.type.isError&&i.from==i.to?(r=t,t=i.prevSibling):t=i}return r}get node(){return this}get next(){return this.parent}}class Ni extends JN{constructor(e,t,r,i){super(),this._tree=e,this.from=t,this.index=r,this._parent=i}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(e,t,r,i,o=0){for(let s=this;;){for(let{children:a,positions:l}=s._tree,c=t>0?a.length:-1;e!=c;e+=t){let u=a[e],d=l[e]+s.from;if(KN(i,r,d,d+u.length)){if(u instanceof Gl){if(o&dr.ExcludeBuffers)continue;let h=u.findChild(0,u.buffer.length,t,r-d,i);if(h>-1)return new sa(new bz(s,u,e,d),null,h)}else if(o&dr.IncludeAnonymous||!u.type.isAnonymous||GP(u)){let h;if(!(o&dr.IgnoreMounts)&&(h=Nh.get(u))&&!h.overlay)return new Ni(h.tree,d,e,s);let p=new Ni(u,d,e,s);return o&dr.IncludeAnonymous||!p.type.isAnonymous?p:p.nextChild(t<0?u.children.length-1:0,t,r,i)}}}if(o&dr.IncludeAnonymous||!s.type.isAnonymous||(s.index>=0?e=s.index+t:e=t<0?-1:s._parent._tree.children.length,s=s._parent,!s))return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(e){return this.nextChild(0,1,e,2)}childBefore(e){return this.nextChild(this._tree.children.length-1,-1,e,-2)}enter(e,t,r=0){let i;if(!(r&dr.IgnoreOverlays)&&(i=Nh.get(this._tree))&&i.overlay){let o=e-this.from;for(let{from:s,to:a}of i.overlay)if((t>0?s<=o:s<o)&&(t<0?a>=o:a>o))return new Ni(i.tree,i.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,t,r)}nextSignificantParent(){let e=this;for(;e.type.isAnonymous&&e._parent;)e=e._parent;return e}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}}function cA(n,e,t,r){let i=n.cursor(),o=[];if(!i.firstChild())return o;if(t!=null){for(let s=!1;!s;)if(s=i.type.is(t),!i.nextSibling())return o}for(;;){if(r!=null&&i.type.is(r))return o;if(i.type.is(e)&&o.push(i.node),!i.nextSibling())return r==null?o:[]}}function mk(n,e,t=e.length-1){for(let r=n;t>=0;r=r.parent){if(!r)return!1;if(!r.type.isAnonymous){if(e[t]&&e[t]!=r.name)return!1;t--}}return!0}class bz{constructor(e,t,r,i){this.parent=e,this.buffer=t,this.index=r,this.start=i}}class sa extends JN{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(e,t,r){super(),this.context=e,this._parent=t,this.index=r,this.type=e.buffer.set.types[e.buffer.buffer[r]]}child(e,t,r){let{buffer:i}=this.context,o=i.findChild(this.index+4,i.buffer[this.index+3],e,t-this.context.start,r);return o<0?null:new sa(this.context,this,o)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(e){return this.child(1,e,2)}childBefore(e){return this.child(-1,e,-2)}enter(e,t,r=0){if(r&dr.ExcludeBuffers)return null;let{buffer:i}=this.context,o=i.findChild(this.index+4,i.buffer[this.index+3],t>0?1:-1,e-this.context.start,t);return o<0?null:new sa(this.context,this,o)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(e){return this._parent?null:this.context.parent.nextChild(this.context.index+e,e,0,4)}get nextSibling(){let{buffer:e}=this.context,t=e.buffer[this.index+3];return t<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new sa(this.context,this._parent,t):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,t=this._parent?this._parent.index+4:0;return this.index==t?this.externalSibling(-1):new sa(this.context,this._parent,e.findChild(t,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],t=[],{buffer:r}=this.context,i=this.index+4,o=r.buffer[this.index+3];if(o>i){let s=r.buffer[this.index+1];e.push(r.slice(i,o,s)),t.push(0)}return new Hn(this.type,e,t,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function e5(n){if(!n.length)return null;let e=0,t=n[0];for(let o=1;o<n.length;o++){let s=n[o];(s.from>t.from||s.to<t.to)&&(t=s,e=o)}let r=t instanceof Ni&&t.index<0?null:t.parent,i=n.slice();return r?i[e]=r:i.splice(e,1),new Sz(i,t)}class Sz{constructor(e,t){this.heads=e,this.node=t}get next(){return e5(this.heads)}}function wz(n,e,t){let r=n.resolveInner(e,t),i=null;for(let o=r instanceof Ni?r:r.context.parent;o;o=o.parent)if(o.index<0){let s=o.parent;(i||(i=[r])).push(s.resolve(e,t)),o=s}else{let s=Nh.get(o.tree);if(s&&s.overlay&&s.overlay[0].from<=e&&s.overlay[s.overlay.length-1].to>=e){let a=new Ni(s.tree,s.overlay[0].from+o.from,-1,o);(i||(i=[r])).push(qh(a,e,t,!1))}}return i?e5(i):r}class dv{get name(){return this.type.name}constructor(e,t=0){if(this.mode=t,this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,e instanceof Ni)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let r=e._parent;r;r=r._parent)this.stack.unshift(r.index);this.bufferNode=e,this.yieldBuf(e.index)}}yieldNode(e){return e?(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0):!1}yieldBuf(e,t){this.index=e;let{start:r,buffer:i}=this.buffer;return this.type=t||i.set.types[i.buffer[e]],this.from=r+i.buffer[e+1],this.to=r+i.buffer[e+2],!0}yield(e){return e?e instanceof Ni?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,t,r){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,t,r,this.mode));let{buffer:i}=this.buffer,o=i.findChild(this.index+4,i.buffer[this.index+3],e,t-this.buffer.start,r);return o<0?!1:(this.stack.push(this.index),this.yieldBuf(o))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(e){return this.enterChild(1,e,2)}childBefore(e){return this.enterChild(-1,e,-2)}enter(e,t,r=this.mode){return this.buffer?r&dr.ExcludeBuffers?!1:this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,r))}parent(){if(!this.buffer)return this.yieldNode(this.mode&dr.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&dr.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(e)}sibling(e){if(!this.buffer)return this._tree._parent?this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+e,e,0,4,this.mode)):!1;let{buffer:t}=this.buffer,r=this.stack.length-1;if(e<0){let i=r<0?0:this.stack[r]+4;if(this.index!=i)return this.yieldBuf(t.findChild(i,this.index,-1,0,4))}else{let i=t.buffer[this.index+3];if(i<(r<0?t.buffer.length:t.buffer[this.stack[r]+3]))return this.yieldBuf(i)}return r<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let t,r,{buffer:i}=this;if(i){if(e>0){if(this.index<i.buffer.buffer.length)return!1}else for(let o=0;o<this.index;o++)if(i.buffer.buffer[o+3]<this.index)return!1;({index:t,parent:r}=i)}else({index:t,_parent:r}=this._tree);for(;r;{index:t,_parent:r}=r)if(t>-1)for(let o=t+e,s=e<0?-1:r._tree.children.length;o!=s;o+=e){let a=r._tree.children[o];if(this.mode&dr.IncludeAnonymous||a instanceof Gl||!a.type.isAnonymous||GP(a))return!1}return!0}move(e,t){if(t&&this.enterChild(e,0,4))return!0;for(;;){if(this.sibling(e))return!0;if(this.atLastNode(e)||!this.parent())return!1}}next(e=!0){return this.move(1,e)}prev(e=!0){return this.move(-1,e)}moveTo(e,t=0){for(;(this.from==this.to||(t<1?this.from>=e:this.from>e)||(t>-1?this.to<=e:this.to<e))&&this.parent(););for(;this.enterChild(1,e,t););return this}get node(){if(!this.buffer)return this._tree;let e=this.bufferNode,t=null,r=0;if(e&&e.context==this.buffer)e:for(let i=this.index,o=this.stack.length;o>=0;){for(let s=e;s;s=s._parent)if(s.index==i){if(i==this.index)return s;t=s,r=o+1;break e}i=this.stack[--o]}for(let i=r;i<this.stack.length;i++)t=new sa(this.buffer,t,this.stack[i]);return this.bufferNode=new sa(this.buffer,t,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(e,t){for(let r=0;;){let i=!1;if(this.type.isAnonymous||e(this)!==!1){if(this.firstChild()){r++;continue}this.type.isAnonymous||(i=!0)}for(;;){if(i&&t&&t(this),i=this.type.isAnonymous,!r)return;if(this.nextSibling())break;this.parent(),r--,i=!0}}}matchContext(e){if(!this.buffer)return mk(this.node.parent,e);let{buffer:t}=this.buffer,{types:r}=t.set;for(let i=e.length-1,o=this.stack.length-1;i>=0;o--){if(o<0)return mk(this._tree,e,i);let s=r[t.buffer[this.stack[o]]];if(!s.isAnonymous){if(e[i]&&e[i]!=s.name)return!1;i--}}return!0}}function GP(n){return n.children.some(e=>e instanceof Gl||!e.type.isAnonymous||GP(e))}function kz(n){var e;let{buffer:t,nodeSet:r,maxBufferLength:i=HN,reused:o=[],minRepeatType:s=r.types.length}=n,a=Array.isArray(t)?new YP(t,t.length):t,l=r.types,c=0,u=0;function d(w,E,M,Q,T,R){let{id:$,start:I,end:B,size:H}=a,oe=u,F=c;for(;H<0;)if(a.next(),H==-1){let K=o[$];M.push(K),Q.push(I-w);return}else if(H==-3){c=$;return}else if(H==-4){u=$;return}else throw new RangeError(`Unrecognized record size: ${H}`);let Z=l[$],W,te,ie=I-w;if(B-I<=i&&(te=v(a.pos-E,T))){let K=new Uint16Array(te.size-te.skip),se=a.pos-te.size,ee=K.length;for(;a.pos>se;)ee=b(te.start,K,ee);W=new Gl(K,B-te.start,r),ie=te.start-w}else{let K=a.pos-H;a.next();let se=[],ee=[],le=$>=s?$:-1,ge=0,Le=B;for(;a.pos>K;)le>=0&&a.id==le&&a.size>=0?(a.end<=Le-i&&(g(se,ee,I,ge,a.end,Le,le,oe,F),ge=se.length,Le=a.end),a.next()):R>2500?h(I,K,se,ee):d(I,K,se,ee,le,R+1);if(le>=0&&ge>0&&ge<se.length&&g(se,ee,I,ge,I,Le,le,oe,F),se.reverse(),ee.reverse(),le>-1&&ge>0){let L=p(Z,F);W=HP(Z,se,ee,0,se.length,0,B-I,L,L)}else W=O(Z,se,ee,B-I,oe-B,F)}M.push(W),Q.push(ie)}function h(w,E,M,Q){let T=[],R=0,$=-1;for(;a.pos>E;){let{id:I,start:B,end:H,size:oe}=a;if(oe>4)a.next();else{if($>-1&&B<$)break;$<0&&($=H-i),T.push(I,B,H),R++,a.next()}}if(R){let I=new Uint16Array(R*4),B=T[T.length-2];for(let H=T.length-3,oe=0;H>=0;H-=3)I[oe++]=T[H],I[oe++]=T[H+1]-B,I[oe++]=T[H+2]-B,I[oe++]=oe;M.push(new Gl(I,T[2]-B,r)),Q.push(B-w)}}function p(w,E){return(M,Q,T)=>{let R=0,$=M.length-1,I,B;if($>=0&&(I=M[$])instanceof Hn){if(!$&&I.type==w&&I.length==T)return I;(B=I.prop(gn.lookAhead))&&(R=Q[$]+I.length+B)}return O(w,M,Q,T,R,E)}}function g(w,E,M,Q,T,R,$,I,B){let H=[],oe=[];for(;w.length>Q;)H.push(w.pop()),oe.push(E.pop()+M-T);w.push(O(r.types[$],H,oe,R-T,I-R,B)),E.push(T-M)}function O(w,E,M,Q,T,R,$){if(R){let I=[gn.contextHash,R];$=$?[I].concat($):[I]}if(T>25){let I=[gn.lookAhead,T];$=$?[I].concat($):[I]}return new Hn(w,E,M,Q,$)}function v(w,E){let M=a.fork(),Q=0,T=0,R=0,$=M.end-i,I={size:0,start:0,skip:0};e:for(let B=M.pos-w;M.pos>B;){let H=M.size;if(M.id==E&&H>=0){I.size=Q,I.start=T,I.skip=R,R+=4,Q+=4,M.next();continue}let oe=M.pos-H;if(H<0||oe<B||M.start<$)break;let F=M.id>=s?4:0,Z=M.start;for(M.next();M.pos>oe;){if(M.size<0)if(M.size==-3)F+=4;else break e;else M.id>=s&&(F+=4);M.next()}T=Z,Q+=H,R+=F}return(E<0||Q==w)&&(I.size=Q,I.start=T,I.skip=R),I.size>4?I:void 0}function b(w,E,M){let{id:Q,start:T,end:R,size:$}=a;if(a.next(),$>=0&&Q<s){let I=M;if($>4){let B=a.pos-($-4);for(;a.pos>B;)M=b(w,E,M)}E[--M]=I,E[--M]=R-w,E[--M]=T-w,E[--M]=Q}else $==-3?c=Q:$==-4&&(u=Q);return M}let S=[],x=[];for(;a.pos>0;)d(n.start||0,n.bufferStart||0,S,x,-1,0);let P=(e=n.length)!==null&&e!==void 0?e:S.length?x[0]+S[0].length:0;return new Hn(l[n.topID],S.reverse(),x.reverse(),P)}const uA=new WeakMap;function $O(n,e){if(!n.isAnonymous||e instanceof Gl||e.type!=n)return 1;let t=uA.get(e);if(t==null){t=1;for(let r of e.children){if(r.type!=n||!(r instanceof Hn)){t=1;break}t+=$O(n,r)}uA.set(e,t)}return t}function HP(n,e,t,r,i,o,s,a,l){let c=0;for(let g=r;g<i;g++)c+=$O(n,e[g]);let u=Math.ceil(c*1.5/8),d=[],h=[];function p(g,O,v,b,S){for(let x=v;x<b;){let P=x,w=O[x],E=$O(n,g[x]);for(x++;x<b;x++){let M=$O(n,g[x]);if(E+M>=u)break;E+=M}if(x==P+1){if(E>u){let M=g[P];p(M.children,M.positions,0,M.children.length,O[P]+S);continue}d.push(g[P])}else{let M=O[x-1]+g[x-1].length-w;d.push(HP(n,g,O,P,x,w,M,null,l))}h.push(w+S-o)}}return p(e,t,r,i,0),(a||l)(d,h,s)}class t5{constructor(){this.map=new WeakMap}setBuffer(e,t,r){let i=this.map.get(e);i||this.map.set(e,i=new Map),i.set(t,r)}getBuffer(e,t){let r=this.map.get(e);return r&&r.get(t)}set(e,t){e instanceof sa?this.setBuffer(e.context.buffer,e.index,t):e instanceof Ni&&this.map.set(e.tree,t)}get(e){return e instanceof sa?this.getBuffer(e.context.buffer,e.index):e instanceof Ni?this.map.get(e.tree):void 0}cursorSet(e,t){e.buffer?this.setBuffer(e.buffer.buffer,e.index,t):this.map.set(e.tree,t)}cursorGet(e){return e.buffer?this.getBuffer(e.buffer.buffer,e.index):this.map.get(e.tree)}}class La{constructor(e,t,r,i,o=!1,s=!1){this.from=e,this.to=t,this.tree=r,this.offset=i,this.open=(o?1:0)|(s?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(e,t=[],r=!1){let i=[new La(0,e.length,e,0,!1,r)];for(let o of t)o.to>e.length&&i.push(o);return i}static applyChanges(e,t,r=128){if(!t.length)return e;let i=[],o=1,s=e.length?e[0]:null;for(let a=0,l=0,c=0;;a++){let u=a<t.length?t[a]:null,d=u?u.fromA:1e9;if(d-l>=r)for(;s&&s.from<d;){let h=s;if(l>=h.from||d<=h.to||c){let p=Math.max(h.from,l)-c,g=Math.min(h.to,d)-c;h=p>=g?null:new La(p,g,h.tree,h.offset+c,a>0,!!u)}if(h&&i.push(h),s.to>d)break;s=o<e.length?e[o++]:null}if(!u)break;l=u.toA,c=u.toA-u.toB}return i}}class KP{startParse(e,t,r){return typeof e=="string"&&(e=new Pz(e)),r=r?r.length?r.map(i=>new Jo(i.from,i.to)):[new Jo(0,0)]:[new Jo(0,e.length)],this.createParse(e,t||[],r)}parse(e,t,r){let i=this.startParse(e,t,r);for(;;){let o=i.advance();if(o)return o}}}class Pz{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,t){return this.string.slice(e,t)}}function JP(n){return(e,t,r,i)=>new Cz(e,n,t,r,i)}class fA{constructor(e,t,r,i,o){this.parser=e,this.parse=t,this.overlay=r,this.target=i,this.from=o}}function dA(n){if(!n.length||n.some(e=>e.from>=e.to))throw new RangeError("Invalid inner parse ranges given: "+JSON.stringify(n))}class xz{constructor(e,t,r,i,o,s,a){this.parser=e,this.predicate=t,this.mounts=r,this.index=i,this.start=o,this.target=s,this.prev=a,this.depth=0,this.ranges=[]}}const gk=new gn({perNode:!0});class Cz{constructor(e,t,r,i,o){this.nest=t,this.input=r,this.fragments=i,this.ranges=o,this.inner=[],this.innerDone=0,this.baseTree=null,this.stoppedAt=null,this.baseParse=e}advance(){if(this.baseParse){let r=this.baseParse.advance();if(!r)return null;if(this.baseParse=null,this.baseTree=r,this.startInner(),this.stoppedAt!=null)for(let i of this.inner)i.parse.stopAt(this.stoppedAt)}if(this.innerDone==this.inner.length){let r=this.baseTree;return this.stoppedAt!=null&&(r=new Hn(r.type,r.children,r.positions,r.length,r.propValues.concat([[gk,this.stoppedAt]]))),r}let e=this.inner[this.innerDone],t=e.parse.advance();if(t){this.innerDone++;let r=Object.assign(Object.create(null),e.target.props);r[gn.mounted.id]=new Nh(t,e.overlay,e.parser),e.target.props=r}return null}get parsedPos(){if(this.baseParse)return 0;let e=this.input.length;for(let t=this.innerDone;t<this.inner.length;t++)this.inner[t].from<e&&(e=Math.min(e,this.inner[t].parse.parsedPos));return e}stopAt(e){if(this.stoppedAt=e,this.baseParse)this.baseParse.stopAt(e);else for(let t=this.innerDone;t<this.inner.length;t++)this.inner[t].parse.stopAt(e)}startInner(){let e=new Ez(this.fragments),t=null,r=null,i=new dv(new Ni(this.baseTree,this.ranges[0].from,0,null),dr.IncludeAnonymous|dr.IgnoreMounts);e:for(let o,s;;){let a=!0,l;if(this.stoppedAt!=null&&i.from>=this.stoppedAt)a=!1;else if(e.hasNode(i)){if(t){let c=t.mounts.find(u=>u.frag.from<=i.from&&u.frag.to>=i.to&&u.mount.overlay);if(c)for(let u of c.mount.overlay){let d=u.from+c.pos,h=u.to+c.pos;d>=i.from&&h<=i.to&&!t.ranges.some(p=>p.from<h&&p.to>d)&&t.ranges.push({from:d,to:h})}}a=!1}else if(r&&(s=Tz(r.ranges,i.from,i.to)))a=s!=2;else if(!i.type.isAnonymous&&(o=this.nest(i,this.input))&&(i.from<i.to||!o.overlay)){i.tree||_z(i);let c=e.findMounts(i.from,o.parser);if(typeof o.overlay=="function")t=new xz(o.parser,o.overlay,c,this.inner.length,i.from,i.tree,t);else{let u=mA(this.ranges,o.overlay||(i.from<i.to?[new Jo(i.from,i.to)]:[]));u.length&&dA(u),(u.length||!o.overlay)&&this.inner.push(new fA(o.parser,u.length?o.parser.startParse(this.input,gA(c,u),u):o.parser.startParse(""),o.overlay?o.overlay.map(d=>new Jo(d.from-i.from,d.to-i.from)):null,i.tree,u.length?u[0].from:i.from)),o.overlay?u.length&&(r={ranges:u,depth:0,prev:r}):a=!1}}else if(t&&(l=t.predicate(i))&&(l===!0&&(l=new Jo(i.from,i.to)),l.from<l.to)){let c=t.ranges.length-1;c>=0&&t.ranges[c].to==l.from?t.ranges[c]={from:t.ranges[c].from,to:l.to}:t.ranges.push(l)}if(a&&i.firstChild())t&&t.depth++,r&&r.depth++;else for(;!i.nextSibling();){if(!i.parent())break e;if(t&&!--t.depth){let c=mA(this.ranges,t.ranges);c.length&&(dA(c),this.inner.splice(t.index,0,new fA(t.parser,t.parser.startParse(this.input,gA(t.mounts,c),c),t.ranges.map(u=>new Jo(u.from-t.start,u.to-t.start)),t.target,c[0].from))),t=t.prev}r&&!--r.depth&&(r=r.prev)}}}}function Tz(n,e,t){for(let r of n){if(r.from>=t)break;if(r.to>e)return r.from<=e&&r.to>=t?2:1}return 0}function hA(n,e,t,r,i,o){if(e<t){let s=n.buffer[e+1];r.push(n.slice(e,t,s)),i.push(s-o)}}function _z(n){let{node:e}=n,t=[],r=e.context.buffer;do t.push(n.index),n.parent();while(!n.tree);let i=n.tree,o=i.children.indexOf(r),s=i.children[o],a=s.buffer,l=[o];function c(u,d,h,p,g,O){let v=t[O],b=[],S=[];hA(s,u,v,b,S,p);let x=a[v+1],P=a[v+2];l.push(b.length);let w=O?c(v+4,a[v+3],s.set.types[a[v]],x,P-x,O-1):e.toTree();return b.push(w),S.push(x-p),hA(s,a[v+3],d,b,S,p),new Hn(h,b,S,g)}i.children[o]=c(0,a.length,ai.none,0,s.length,t.length-1);for(let u of l){let d=n.tree.children[u],h=n.tree.positions[u];n.yield(new Ni(d,h+n.from,u,n._tree))}}class pA{constructor(e,t){this.offset=t,this.done=!1,this.cursor=e.cursor(dr.IncludeAnonymous|dr.IgnoreMounts)}moveTo(e){let{cursor:t}=this,r=e-this.offset;for(;!this.done&&t.from<r;)t.to>=e&&t.enter(r,1,dr.IgnoreOverlays|dr.ExcludeBuffers)||t.next(!1)||(this.done=!0)}hasNode(e){if(this.moveTo(e.from),!this.done&&this.cursor.from+this.offset==e.from&&this.cursor.tree)for(let t=this.cursor.tree;;){if(t==e.tree)return!0;if(t.children.length&&t.positions[0]==0&&t.children[0]instanceof Hn)t=t.children[0];else break}return!1}}let Ez=class{constructor(e){var t;if(this.fragments=e,this.curTo=0,this.fragI=0,e.length){let r=this.curFrag=e[0];this.curTo=(t=r.tree.prop(gk))!==null&&t!==void 0?t:r.to,this.inner=new pA(r.tree,-r.offset)}else this.curFrag=this.inner=null}hasNode(e){for(;this.curFrag&&e.from>=this.curTo;)this.nextFrag();return this.curFrag&&this.curFrag.from<=e.from&&this.curTo>=e.to&&this.inner.hasNode(e)}nextFrag(){var e;if(this.fragI++,this.fragI==this.fragments.length)this.curFrag=this.inner=null;else{let t=this.curFrag=this.fragments[this.fragI];this.curTo=(e=t.tree.prop(gk))!==null&&e!==void 0?e:t.to,this.inner=new pA(t.tree,-t.offset)}}findMounts(e,t){var r;let i=[];if(this.inner){this.inner.cursor.moveTo(e,1);for(let o=this.inner.cursor.node;o;o=o.parent){let s=(r=o.tree)===null||r===void 0?void 0:r.prop(gn.mounted);if(s&&s.parser==t)for(let a=this.fragI;a<this.fragments.length;a++){let l=this.fragments[a];if(l.from>=o.to)break;l.tree==this.curFrag.tree&&i.push({frag:l,pos:o.from-l.offset,mount:s})}}}return i}};function mA(n,e){let t=null,r=e;for(let i=1,o=0;i<n.length;i++){let s=n[i-1].to,a=n[i].from;for(;o<r.length;o++){let l=r[o];if(l.from>=a)break;l.to<=s||(t||(r=t=e.slice()),l.from<s?(t[o]=new Jo(l.from,s),l.to>a&&t.splice(o+1,0,new Jo(a,l.to))):l.to>a?t[o--]=new Jo(a,l.to):t.splice(o--,1))}}return r}function Rz(n,e,t,r){let i=0,o=0,s=!1,a=!1,l=-1e9,c=[];for(;;){let u=i==n.length?1e9:s?n[i].to:n[i].from,d=o==e.length?1e9:a?e[o].to:e[o].from;if(s!=a){let h=Math.max(l,t),p=Math.min(u,d,r);h<p&&c.push(new Jo(h,p))}if(l=Math.min(u,d),l==1e9)break;u==l&&(s?(s=!1,i++):s=!0),d==l&&(a?(a=!1,o++):a=!0)}return c}function gA(n,e){let t=[];for(let{pos:r,mount:i,frag:o}of n){let s=r+(i.overlay?i.overlay[0].from:0),a=s+i.tree.length,l=Math.max(o.from,s),c=Math.min(o.to,a);if(i.overlay){let u=i.overlay.map(h=>new Jo(h.from+r,h.to+r)),d=Rz(e,u,l,c);for(let h=0,p=l;;h++){let g=h==d.length,O=g?c:d[h].from;if(O>p&&t.push(new La(p,O,i.tree,-s,o.from>=p||o.openStart,o.to<=O||o.openEnd)),g)break;p=d[h].to}}else t.push(new La(l,c,i.tree,-s,o.from>=s||o.openStart,o.to<=a||o.openEnd))}return t}let Az=0;class Ao{constructor(e,t,r,i){this.name=e,this.set=t,this.base=r,this.modified=i,this.id=Az++}toString(){let{name:e}=this;for(let t of this.modified)t.name&&(e=`${t.name}(${e})`);return e}static define(e,t){let r=typeof e=="string"?e:"?";if(e instanceof Ao&&(t=e),t!=null&&t.base)throw new Error("Can not derive from a modified tag");let i=new Ao(r,[],null,[]);if(i.set.push(i),t)for(let o of t.set)i.set.push(o);return i}static defineModifier(e){let t=new hv(e);return r=>r.modified.indexOf(t)>-1?r:hv.get(r.base||r,r.modified.concat(t).sort((i,o)=>i.id-o.id))}}let Mz=0;class hv{constructor(e){this.name=e,this.instances=[],this.id=Mz++}static get(e,t){if(!t.length)return e;let r=t[0].instances.find(a=>a.base==e&&$z(t,a.modified));if(r)return r;let i=[],o=new Ao(e.name,i,e,t);for(let a of t)a.instances.push(o);let s=Dz(t);for(let a of e.set)if(!a.modified.length)for(let l of s)i.push(hv.get(a,l));return o}}function $z(n,e){return n.length==e.length&&n.every((t,r)=>t==e[r])}function Dz(n){let e=[[]];for(let t=0;t<n.length;t++)for(let r=0,i=e.length;r<i;r++)e.push(e[r].concat(n[t]));return e.sort((t,r)=>r.length-t.length)}function rc(n){let e=Object.create(null);for(let t in n){let r=n[t];Array.isArray(r)||(r=[r]);for(let i of t.split(" "))if(i){let o=[],s=2,a=i;for(let d=0;;){if(a=="..."&&d>0&&d+3==i.length){s=1;break}let h=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(a);if(!h)throw new RangeError("Invalid path: "+i);if(o.push(h[0]=="*"?"":h[0][0]=='"'?JSON.parse(h[0]):h[0]),d+=h[0].length,d==i.length)break;let p=i[d++];if(d==i.length&&p=="!"){s=0;break}if(p!="/")throw new RangeError("Invalid path: "+i);a=i.slice(d)}let l=o.length-1,c=o[l];if(!c)throw new RangeError("Invalid path: "+i);let u=new pv(r,s,l>0?o.slice(0,l):null);e[c]=u.sort(e[c])}}return n5.add(e)}const n5=new gn;class pv{constructor(e,t,r,i){this.tags=e,this.mode=t,this.context=r,this.next=i}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth<this.depth?(this.next=e,this):(e.next=this.sort(e.next),e)}get depth(){return this.context?this.context.length:0}}pv.empty=new pv([],2,null);function r5(n,e){let t=Object.create(null);for(let o of n)if(!Array.isArray(o.tag))t[o.tag.id]=o.class;else for(let s of o.tag)t[s.id]=o.class;let{scope:r,all:i=null}=e||{};return{style:o=>{let s=i;for(let a of o)for(let l of a.set){let c=t[l.id];if(c){s=s?s+" "+c:c;break}}return s},scope:r}}function Qz(n,e){let t=null;for(let r of n){let i=r.style(e);i&&(t=t?t+" "+i:i)}return t}function Iz(n,e,t,r=0,i=n.length){let o=new jz(r,Array.isArray(e)?e:[e],t);o.highlightRange(n.cursor(),r,i,"",o.highlighters),o.flush(i)}class jz{constructor(e,t,r){this.at=e,this.highlighters=t,this.span=r,this.class=""}startSpan(e,t){t!=this.class&&(this.flush(e),e>this.at&&(this.at=e),this.class=t)}flush(e){e>this.at&&this.class&&this.span(this.at,e,this.class)}highlightRange(e,t,r,i,o){let{type:s,from:a,to:l}=e;if(a>=r||l<=t)return;s.isTop&&(o=this.highlighters.filter(p=>!p.scope||p.scope(s)));let c=i,u=Lz(e)||pv.empty,d=Qz(o,u.tags);if(d&&(c&&(c+=" "),c+=d,u.mode==1&&(i+=(i?" ":"")+d)),this.startSpan(Math.max(t,a),c),u.opaque)return;let h=e.tree&&e.tree.prop(gn.mounted);if(h&&h.overlay){let p=e.node.enter(h.overlay[0].from+a,1),g=this.highlighters.filter(v=>!v.scope||v.scope(h.tree.type)),O=e.firstChild();for(let v=0,b=a;;v++){let S=v<h.overlay.length?h.overlay[v]:null,x=S?S.from+a:l,P=Math.max(t,b),w=Math.min(r,x);if(P<w&&O)for(;e.from<w&&(this.highlightRange(e,P,w,i,o),this.startSpan(Math.min(w,e.to),c),!(e.to>=x||!e.nextSibling())););if(!S||x>r)break;b=S.to+a,b>t&&(this.highlightRange(p.cursor(),Math.max(t,S.from+a),Math.min(r,b),"",g),this.startSpan(Math.min(r,b),c))}O&&e.parent()}else if(e.firstChild()){h&&(i="");do if(!(e.to<=t)){if(e.from>=r)break;this.highlightRange(e,t,r,i,o),this.startSpan(Math.min(r,e.to),c)}while(e.nextSibling());e.parent()}}}function Lz(n){let e=n.type.prop(n5);for(;e&&e.context&&!n.matchContext(e.context);)e=e.next;return e||null}const Ot=Ao.define,qm=Ot(),kl=Ot(),OA=Ot(kl),vA=Ot(kl),Pl=Ot(),Um=Ot(Pl),Zb=Ot(Pl),Ws=Ot(),Ec=Ot(Ws),Bs=Ot(),Fs=Ot(),Ok=Ot(),jd=Ot(Ok),Bm=Ot(),C={comment:qm,lineComment:Ot(qm),blockComment:Ot(qm),docComment:Ot(qm),name:kl,variableName:Ot(kl),typeName:OA,tagName:Ot(OA),propertyName:vA,attributeName:Ot(vA),className:Ot(kl),labelName:Ot(kl),namespace:Ot(kl),macroName:Ot(kl),literal:Pl,string:Um,docString:Ot(Um),character:Ot(Um),attributeValue:Ot(Um),number:Zb,integer:Ot(Zb),float:Ot(Zb),bool:Ot(Pl),regexp:Ot(Pl),escape:Ot(Pl),color:Ot(Pl),url:Ot(Pl),keyword:Bs,self:Ot(Bs),null:Ot(Bs),atom:Ot(Bs),unit:Ot(Bs),modifier:Ot(Bs),operatorKeyword:Ot(Bs),controlKeyword:Ot(Bs),definitionKeyword:Ot(Bs),moduleKeyword:Ot(Bs),operator:Fs,derefOperator:Ot(Fs),arithmeticOperator:Ot(Fs),logicOperator:Ot(Fs),bitwiseOperator:Ot(Fs),compareOperator:Ot(Fs),updateOperator:Ot(Fs),definitionOperator:Ot(Fs),typeOperator:Ot(Fs),controlOperator:Ot(Fs),punctuation:Ok,separator:Ot(Ok),bracket:jd,angleBracket:Ot(jd),squareBracket:Ot(jd),paren:Ot(jd),brace:Ot(jd),content:Ws,heading:Ec,heading1:Ot(Ec),heading2:Ot(Ec),heading3:Ot(Ec),heading4:Ot(Ec),heading5:Ot(Ec),heading6:Ot(Ec),contentSeparator:Ot(Ws),list:Ot(Ws),quote:Ot(Ws),emphasis:Ot(Ws),strong:Ot(Ws),link:Ot(Ws),monospace:Ot(Ws),strikethrough:Ot(Ws),inserted:Ot(),deleted:Ot(),changed:Ot(),invalid:Ot(),meta:Bm,documentMeta:Ot(Bm),annotation:Ot(Bm),processingInstruction:Ot(Bm),definition:Ao.defineModifier("definition"),constant:Ao.defineModifier("constant"),function:Ao.defineModifier("function"),standard:Ao.defineModifier("standard"),local:Ao.defineModifier("local"),special:Ao.defineModifier("special")};for(let n in C){let e=C[n];e instanceof Ao&&(e.name=n)}r5([{tag:C.link,class:"tok-link"},{tag:C.heading,class:"tok-heading"},{tag:C.emphasis,class:"tok-emphasis"},{tag:C.strong,class:"tok-strong"},{tag:C.keyword,class:"tok-keyword"},{tag:C.atom,class:"tok-atom"},{tag:C.bool,class:"tok-bool"},{tag:C.url,class:"tok-url"},{tag:C.labelName,class:"tok-labelName"},{tag:C.inserted,class:"tok-inserted"},{tag:C.deleted,class:"tok-deleted"},{tag:C.literal,class:"tok-literal"},{tag:C.string,class:"tok-string"},{tag:C.number,class:"tok-number"},{tag:[C.regexp,C.escape,C.special(C.string)],class:"tok-string2"},{tag:C.variableName,class:"tok-variableName"},{tag:C.local(C.variableName),class:"tok-variableName tok-local"},{tag:C.definition(C.variableName),class:"tok-variableName tok-definition"},{tag:C.special(C.variableName),class:"tok-variableName2"},{tag:C.definition(C.propertyName),class:"tok-propertyName tok-definition"},{tag:C.typeName,class:"tok-typeName"},{tag:C.namespace,class:"tok-namespace"},{tag:C.className,class:"tok-className"},{tag:C.macroName,class:"tok-macroName"},{tag:C.propertyName,class:"tok-propertyName"},{tag:C.operator,class:"tok-operator"},{tag:C.comment,class:"tok-comment"},{tag:C.meta,class:"tok-meta"},{tag:C.invalid,class:"tok-invalid"},{tag:C.punctuation,class:"tok-punctuation"}]);var Xb;const Vc=new gn;function ex(n){return Ct.define({combine:n?e=>e.concat(n):void 0})}const tx=new gn;class es{constructor(e,t,r=[],i=""){this.data=e,this.name=i,Un.prototype.hasOwnProperty("tree")||Object.defineProperty(Un.prototype,"tree",{get(){return br(this)}}),this.parser=t,this.extension=[jf.of(this),Un.languageData.of((o,s,a)=>{let l=yA(o,s,a),c=l.type.prop(Vc);if(!c)return[];let u=o.facet(c),d=l.type.prop(tx);if(d){let h=l.resolve(s-l.from,a);for(let p of d)if(p.test(h,o)){let g=o.facet(p.facet);return p.type=="replace"?g:g.concat(u)}}return u})].concat(r)}isActiveAt(e,t,r=-1){return yA(e,t,r).type.prop(Vc)==this.data}findRegions(e){let t=e.facet(jf);if((t==null?void 0:t.data)==this.data)return[{from:0,to:e.doc.length}];if(!t||!t.allowsNesting)return[];let r=[],i=(o,s)=>{if(o.prop(Vc)==this.data){r.push({from:s,to:s+o.length});return}let a=o.prop(gn.mounted);if(a){if(a.tree.prop(Vc)==this.data){if(a.overlay)for(let l of a.overlay)r.push({from:l.from+s,to:l.to+s});else r.push({from:s,to:s+o.length});return}else if(a.overlay){let l=r.length;if(i(a.tree,a.overlay[0].from+s),r.length>l)return}}for(let l=0;l<o.children.length;l++){let c=o.children[l];c instanceof Hn&&i(c,o.positions[l]+s)}};return i(br(e),0),r}get allowsNesting(){return!0}}es.setState=cn.define();function yA(n,e,t){let r=n.facet(jf),i=br(n).topNode;if(!r||r.allowsNesting)for(let o=i;o;o=o.enter(e,t,dr.ExcludeBuffers))o.type.isTop&&(i=o);return i}class Hl extends es{constructor(e,t,r){super(e,t,[],r),this.parser=t}static define(e){let t=ex(e.languageData);return new Hl(t,e.parser.configure({props:[Vc.add(r=>r.isTop?t:void 0)]}),e.name)}configure(e,t){return new Hl(this.data,this.parser.configure(e),t||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function br(n){let e=n.field(es.state,!1);return e?e.tree:Hn.empty}class Nz{constructor(e){this.doc=e,this.cursorPos=0,this.string="",this.cursor=e.iter()}get length(){return this.doc.length}syncTo(e){return this.string=this.cursor.next(e-this.cursorPos).value,this.cursorPos=e+this.string.length,this.cursorPos-this.string.length}chunk(e){return this.syncTo(e),this.string}get lineChunks(){return!0}read(e,t){let r=this.cursorPos-this.string.length;return e<r||t>=this.cursorPos?this.doc.sliceString(e,t):this.string.slice(e-r,t-r)}}let Ld=null;class Uh{constructor(e,t,r=[],i,o,s,a,l){this.parser=e,this.state=t,this.fragments=r,this.tree=i,this.treeLen=o,this.viewport=s,this.skipped=a,this.scheduleOn=l,this.parse=null,this.tempSkipped=[]}static create(e,t,r){return new Uh(e,t,[],Hn.empty,0,r,[],null)}startParse(){return this.parser.startParse(new Nz(this.state.doc),this.fragments)}work(e,t){return t!=null&&t>=this.state.doc.length&&(t=void 0),this.tree!=Hn.empty&&this.isDone(t??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var r;if(typeof e=="number"){let i=Date.now()+e;e=()=>Date.now()>i}for(this.parse||(this.parse=this.startParse()),t!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>t)&&t<this.state.doc.length&&this.parse.stopAt(t);;){let i=this.parse.advance();if(i)if(this.fragments=this.withoutTempSkipped(La.addTree(i,this.fragments,this.parse.stoppedAt!=null)),this.treeLen=(r=this.parse.stoppedAt)!==null&&r!==void 0?r:this.state.doc.length,this.tree=i,this.parse=null,this.treeLen<(t??this.state.doc.length))this.parse=this.startParse();else return!0;if(e())return!1}})}takeTree(){let e,t;this.parse&&(e=this.parse.parsedPos)>=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(t=this.parse.advance()););}),this.treeLen=e,this.tree=t,this.fragments=this.withoutTempSkipped(La.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=Ld;Ld=this;try{return e()}finally{Ld=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=bA(e,t.from,t.to);return e}changes(e,t){let{fragments:r,tree:i,treeLen:o,viewport:s,skipped:a}=this;if(this.takeTree(),!e.empty){let l=[];if(e.iterChangedRanges((c,u,d,h)=>l.push({fromA:c,toA:u,fromB:d,toB:h})),r=La.applyChanges(r,l),i=Hn.empty,o=0,s={from:e.mapPos(s.from,-1),to:e.mapPos(s.to,1)},this.skipped.length){a=[];for(let c of this.skipped){let u=e.mapPos(c.from,1),d=e.mapPos(c.to,-1);u<d&&a.push({from:u,to:d})}}}return new Uh(this.parser,t,r,i,o,s,a,this.scheduleOn)}updateViewport(e){if(this.viewport.from==e.from&&this.viewport.to==e.to)return!1;this.viewport=e;let t=this.skipped.length;for(let r=0;r<this.skipped.length;r++){let{from:i,to:o}=this.skipped[r];i<e.to&&o>e.from&&(this.fragments=bA(this.fragments,i,o),this.skipped.splice(r--,1))}return this.skipped.length>=t?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,t){this.skipped.push({from:e,to:t})}static getSkippingParser(e){return new class extends KP{createParse(t,r,i){let o=i[0].from,s=i[i.length-1].to;return{parsedPos:o,advance(){let l=Ld;if(l){for(let c of i)l.tempSkipped.push(c);e&&(l.scheduleOn=l.scheduleOn?Promise.all([l.scheduleOn,e]):e)}return this.parsedPos=s,new Hn(ai.none,[],[],s-o)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let t=this.fragments;return this.treeLen>=e&&t.length&&t[0].from==0&&t[0].to>=e}static get(){return Ld}}function bA(n,e,t){return La.applyChanges(n,[{fromA:e,toA:t,fromB:e,toB:t}])}class If{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let t=this.context.changes(e.changes,e.state),r=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),t.viewport.to);return t.work(20,r)||t.takeTree(),new If(t)}static init(e){let t=Math.min(3e3,e.doc.length),r=Uh.create(e.facet(jf).parser,e,{from:0,to:t});return r.work(20,t)||r.takeTree(),new If(r)}}es.state=Kr.define({create:If.init,update(n,e){for(let t of e.effects)if(t.is(es.setState))return t.value;return e.startState.facet(jf)!=e.state.facet(jf)?If.init(e.state):n.apply(e)}});let i5=n=>{let e=setTimeout(()=>n(),500);return()=>clearTimeout(e)};typeof requestIdleCallback<"u"&&(i5=n=>{let e=-1,t=setTimeout(()=>{e=requestIdleCallback(n,{timeout:400})},100);return()=>e<0?clearTimeout(t):cancelIdleCallback(e)});const zb=typeof navigator<"u"&&(!((Xb=navigator.scheduling)===null||Xb===void 0)&&Xb.isInputPending)?()=>navigator.scheduling.isInputPending():null,qz=nr.fromClass(class{constructor(e){this.view=e,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(e){let t=this.view.state.field(es.state).context;(t.updateViewport(e.view.viewport)||this.view.viewport.to>t.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(t)}scheduleWork(){if(this.working)return;let{state:e}=this.view,t=e.field(es.state);(t.tree!=t.context.tree||!t.context.isDone(e.doc.length))&&(this.working=i5(this.work))}work(e){this.working=null;let t=Date.now();if(this.chunkEnd<t&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=t+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:r,viewport:{to:i}}=this.view,o=r.field(es.state);if(o.tree==o.context.tree&&o.context.isDone(i+1e5))return;let s=Date.now()+Math.min(this.chunkBudget,100,e&&!zb?Math.max(25,e.timeRemaining()-5):1e9),a=o.context.treeLen<i&&r.doc.length>i+1e3,l=o.context.work(()=>zb&&zb()||Date.now()>s,i+(a?0:1e5));this.chunkBudget-=Date.now()-t,(l||this.chunkBudget<=0)&&(o.context.takeTree(),this.view.dispatch({effects:es.setState.of(new If(o.context))})),this.chunkBudget>0&&!(l&&!a)&&this.scheduleWork(),this.checkAsyncSchedule(o.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(t=>mo(this.view.state,t)).then(()=>this.workScheduled--),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),jf=Ct.define({combine(n){return n.length?n[0]:null},enables:n=>[es.state,qz,ft.contentAttributes.compute([n],e=>{let t=e.facet(n);return t&&t.name?{"data-language":t.name}:{}})]});class iu{constructor(e,t=[]){this.language=e,this.support=t,this.extension=[e,t]}}class mv{constructor(e,t,r,i,o,s=void 0){this.name=e,this.alias=t,this.extensions=r,this.filename=i,this.loadFunc=o,this.support=s,this.loading=null}load(){return this.loading||(this.loading=this.loadFunc().then(e=>this.support=e,e=>{throw this.loading=null,e}))}static of(e){let{load:t,support:r}=e;if(!t){if(!r)throw new RangeError("Must pass either 'load' or 'support' to LanguageDescription.of");t=()=>Promise.resolve(r)}return new mv(e.name,(e.alias||[]).concat(e.name).map(i=>i.toLowerCase()),e.extensions||[],e.filename,t,r)}static matchFilename(e,t){for(let i of e)if(i.filename&&i.filename.test(t))return i;let r=/\.([^.]+)$/.exec(t);if(r){for(let i of e)if(i.extensions.indexOf(r[1])>-1)return i}return null}static matchLanguageName(e,t,r=!0){t=t.toLowerCase();for(let i of e)if(i.alias.some(o=>o==t))return i;if(r)for(let i of e)for(let o of i.alias){let s=t.indexOf(o);if(s>-1&&(o.length>2||!/\w/.test(t[s-1])&&!/\w/.test(t[s+o.length])))return i}return null}}const Uz=Ct.define(),fp=Ct.define({combine:n=>{if(!n.length)return" ";let e=n[0];if(!e||/\S/.test(e)||Array.from(e).some(t=>t!=e[0]))throw new Error("Invalid indent unit: "+JSON.stringify(n[0]));return e}});function Lf(n){let e=n.facet(fp);return e.charCodeAt(0)==9?n.tabSize*e.length:e.length}function gv(n,e){let t="",r=n.tabSize,i=n.facet(fp)[0];if(i==" "){for(;e>=r;)t+=" ",e-=r;i=" "}for(let o=0;o<e;o++)t+=i;return t}function o5(n,e){n instanceof Un&&(n=new nx(n));for(let r of n.state.facet(Uz)){let i=r(n,e);if(i!==void 0)return i}let t=br(n.state);return t.length>=e?Bz(n,t,e):null}class nx{constructor(e,t={}){this.state=e,this.options=t,this.unit=Lf(e)}lineAt(e,t=1){let r=this.state.doc.lineAt(e),{simulateBreak:i,simulateDoubleBreak:o}=this.options;return i!=null&&i>=r.from&&i<=r.to?o&&i==e?{text:"",from:e}:(t<0?i<e:i<=e)?{text:r.text.slice(i-r.from),from:i}:{text:r.text.slice(0,i-r.from),from:r.from}:r}textAfterPos(e,t=1){if(this.options.simulateDoubleBreak&&e==this.options.simulateBreak)return"";let{text:r,from:i}=this.lineAt(e,t);return r.slice(e-i,Math.min(r.length,e+100-i))}column(e,t=1){let{text:r,from:i}=this.lineAt(e,t),o=this.countColumn(r,e-i),s=this.options.overrideIndentation?this.options.overrideIndentation(i):-1;return s>-1&&(o+=s-this.countColumn(r,r.search(/\S|$/))),o}countColumn(e,t=e.length){return Rs(e,this.state.tabSize,t)}lineIndent(e,t=1){let{text:r,from:i}=this.lineAt(e,t),o=this.options.overrideIndentation;if(o){let s=o(i);if(s>-1)return s}return this.countColumn(r,r.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const lu=new gn;function Bz(n,e,t){let r=e.resolveStack(t),i=e.resolveInner(t,-1).resolve(t,0).enterUnfinishedNodesBefore(t);if(i!=r.node){let o=[];for(let s=i;s&&!(s.from==r.node.from&&s.type==r.node.type);s=s.parent)o.push(s);for(let s=o.length-1;s>=0;s--)r={node:o[s],next:r}}return s5(r,n,t)}function s5(n,e,t){for(let r=n;r;r=r.next){let i=Vz(r.node);if(i)return i(rx.create(e,t,r))}return 0}function Fz(n){return n.pos==n.options.simulateBreak&&n.options.simulateDoubleBreak}function Vz(n){let e=n.type.prop(lu);if(e)return e;let t=n.firstChild,r;if(t&&(r=t.type.prop(gn.closedBy))){let i=n.lastChild,o=i&&r.indexOf(i.name)>-1;return s=>a5(s,!0,1,void 0,o&&!Fz(s)?i.from:void 0)}return n.parent==null?Wz:null}function Wz(){return 0}class rx extends nx{constructor(e,t,r){super(e.state,e.options),this.base=e,this.pos=t,this.context=r}get node(){return this.context.node}static create(e,t,r){return new rx(e,t,r)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let t=this.state.doc.lineAt(e.from);for(;;){let r=e.resolve(t.from);for(;r.parent&&r.parent.from==r.from;)r=r.parent;if(Zz(r,e))break;t=this.state.doc.lineAt(r.from)}return this.lineIndent(t.from)}continue(){return s5(this.context.next,this.base,this.pos)}}function Zz(n,e){for(let t=e;t;t=t.parent)if(n==t)return!0;return!1}function Xz(n){let e=n.node,t=e.childAfter(e.from),r=e.lastChild;if(!t)return null;let i=n.options.simulateBreak,o=n.state.doc.lineAt(t.from),s=i==null||i<=o.from?o.to:Math.min(o.to,i);for(let a=t.to;;){let l=e.childAfter(a);if(!l||l==r)return null;if(!l.type.isSkipped){if(l.from>=s)return null;let c=/^ */.exec(o.text.slice(t.to-o.from))[0].length;return{from:t.from,to:t.to+c}}a=l.to}}function zz({closing:n,align:e=!0,units:t=1}){return r=>a5(r,e,t,n)}function a5(n,e,t,r,i){let o=n.textAfter,s=o.match(/^\s*/)[0].length,a=r&&o.slice(s,s+r.length)==r||i==n.pos+s,l=e?Xz(n):null;return l?a?n.column(l.from):n.column(l.to):n.baseIndent+(a?0:n.unit*t)}const Yz=n=>n.baseIndent;function bf({except:n,units:e=1}={}){return t=>{let r=n&&n.test(t.textAfter);return t.baseIndent+(r?0:e*t.unit)}}const Gz=200;function Hz(){return Un.transactionFilter.of(n=>{if(!n.docChanged||!n.isUserEvent("input.type")&&!n.isUserEvent("input.complete"))return n;let e=n.startState.languageDataAt("indentOnInput",n.startState.selection.main.head);if(!e.length)return n;let t=n.newDoc,{head:r}=n.newSelection.main,i=t.lineAt(r);if(r>i.from+Gz)return n;let o=t.sliceString(i.from,r);if(!e.some(c=>c.test(o)))return n;let{state:s}=n,a=-1,l=[];for(let{head:c}of s.selection.ranges){let u=s.doc.lineAt(c);if(u.from==a)continue;a=u.from;let d=o5(s,u.from);if(d==null)continue;let h=/^\s*/.exec(u.text)[0],p=gv(s,d);h!=p&&l.push({from:u.from,to:u.from+h.length,insert:p})}return l.length?[n,{changes:l,sequential:!0}]:n})}const l5=Ct.define(),ic=new gn;function ix(n){let e=n.firstChild,t=n.lastChild;return e&&e.to<t.from?{from:e.to,to:t.type.isError?n.to:t.from}:null}function Kz(n,e,t){let r=br(n);if(r.length<t)return null;let i=r.resolveStack(t,1),o=null;for(let s=i;s;s=s.next){let a=s.node;if(a.to<=t||a.from>t)continue;if(o&&a.from<e)break;let l=a.type.prop(ic);if(l&&(a.to<r.length-50||r.length==n.doc.length||!Jz(a))){let c=l(a,n);c&&c.from<=t&&c.from>=e&&c.to>t&&(o=c)}}return o}function Jz(n){let e=n.lastChild;return e&&e.to==n.to&&e.type.isError}function c5(n,e,t){for(let r of n.facet(l5)){let i=r(n,e,t);if(i)return i}return Kz(n,e,t)}function u5(n,e){let t=e.mapPos(n.from,1),r=e.mapPos(n.to,-1);return t>=r?void 0:{from:t,to:r}}const ox=cn.define({map:u5}),sy=cn.define({map:u5});function f5(n){let e=[];for(let{head:t}of n.state.selection.ranges)e.some(r=>r.from<=t&&r.to>=t)||e.push(n.lineBlockAt(t));return e}const dp=Kr.define({create(){return _t.none},update(n,e){n=n.map(e.changes);for(let t of e.effects)if(t.is(ox)&&!eY(n,t.value.from,t.value.to)){let{preparePlaceholder:r}=e.state.facet(m5),i=r?_t.replace({widget:new aY(r(e.state,t.value))}):SA;n=n.update({add:[i.range(t.value.from,t.value.to)]})}else t.is(sy)&&(n=n.update({filter:(r,i)=>t.value.from!=r||t.value.to!=i,filterFrom:t.value.from,filterTo:t.value.to}));if(e.selection){let t=!1,{head:r}=e.selection.main;n.between(r,r,(i,o)=>{i<r&&o>r&&(t=!0)}),t&&(n=n.update({filterFrom:r,filterTo:r,filter:(i,o)=>o<=r||i>=r}))}return n},provide:n=>ft.decorations.from(n),toJSON(n,e){let t=[];return n.between(0,e.doc.length,(r,i)=>{t.push(r,i)}),t},fromJSON(n){if(!Array.isArray(n)||n.length%2)throw new RangeError("Invalid JSON for fold state");let e=[];for(let t=0;t<n.length;){let r=n[t++],i=n[t++];if(typeof r!="number"||typeof i!="number")throw new RangeError("Invalid JSON for fold state");e.push(SA.range(r,i))}return _t.set(e,!0)}});function d5(n,e,t){var r;let i=null;return(r=n.field(dp,!1))===null||r===void 0||r.between(e,t,(o,s)=>{(!i||i.from>o)&&(i={from:o,to:s})}),i}function eY(n,e,t){let r=!1;return n.between(e,e,(i,o)=>{i==e&&o==t&&(r=!0)}),r}function h5(n,e){return n.field(dp,!1)?e:e.concat(cn.appendConfig.of(sY()))}const tY=n=>{for(let e of f5(n)){let t=c5(n.state,e.from,e.to);if(t)return n.dispatch({effects:h5(n.state,[ox.of(t),p5(n,t)])}),!0}return!1},nY=n=>{if(!n.state.field(dp,!1))return!1;let e=[];for(let t of f5(n)){let r=d5(n.state,t.from,t.to);r&&e.push(sy.of(r),p5(n,r,!1))}return e.length&&n.dispatch({effects:e}),e.length>0};function p5(n,e,t=!0){let r=n.state.doc.lineAt(e.from).number,i=n.state.doc.lineAt(e.to).number;return ft.announce.of(`${n.state.phrase(t?"Folded lines":"Unfolded lines")} ${r} ${n.state.phrase("to")} ${i}.`)}const rY=n=>{let{state:e}=n,t=[];for(let r=0;r<e.doc.length;){let i=n.lineBlockAt(r),o=c5(e,i.from,i.to);o&&t.push(ox.of(o)),r=(o?n.lineBlockAt(o.to):i).to+1}return t.length&&n.dispatch({effects:h5(n.state,t)}),!!t.length},iY=n=>{let e=n.state.field(dp,!1);if(!e||!e.size)return!1;let t=[];return e.between(0,n.state.doc.length,(r,i)=>{t.push(sy.of({from:r,to:i}))}),n.dispatch({effects:t}),!0},oY={placeholderDOM:null,preparePlaceholder:null,placeholderText:"…"},m5=Ct.define({combine(n){return $s(n,oY)}});function sY(n){return[dp,lY]}function g5(n,e){let{state:t}=n,r=t.facet(m5),i=s=>{let a=n.lineBlockAt(n.posAtDOM(s.target)),l=d5(n.state,a.from,a.to);l&&n.dispatch({effects:sy.of(l)}),s.preventDefault()};if(r.placeholderDOM)return r.placeholderDOM(n,i,e);let o=document.createElement("span");return o.textContent=r.placeholderText,o.setAttribute("aria-label",t.phrase("folded code")),o.title=t.phrase("unfold"),o.className="cm-foldPlaceholder",o.onclick=i,o}const SA=_t.replace({widget:new class extends Io{toDOM(n){return g5(n,null)}}});class aY extends Io{constructor(e){super(),this.value=e}eq(e){return this.value==e.value}toDOM(e){return g5(e,this.value)}}const lY=ft.baseTheme({".cm-foldPlaceholder":{backgroundColor:"#eee",border:"1px solid #ddd",color:"#888",borderRadius:".2em",margin:"0 1px",padding:"0 1px",cursor:"pointer"},".cm-foldGutter span":{padding:"0 1px",cursor:"pointer"}});class zf{constructor(e,t){this.specs=e;let r;function i(a){let l=Zl.newName();return(r||(r=Object.create(null)))["."+l]=a,l}const o=typeof t.all=="string"?t.all:t.all?i(t.all):void 0,s=t.scope;this.scope=s instanceof es?a=>a.prop(Vc)==s.data:s?a=>a==s:void 0,this.style=r5(e.map(a=>({tag:a.tag,class:a.class||i(Object.assign({},a,{tag:null}))})),{all:o}).style,this.module=r?new Zl(r):null,this.themeType=t.themeType}static define(e,t){return new zf(e,t||{})}}const vk=Ct.define(),O5=Ct.define({combine(n){return n.length?[n[0]]:null}});function Yb(n){let e=n.facet(vk);return e.length?e:n.facet(O5)}function sx(n,e){let t=[uY],r;return n instanceof zf&&(n.module&&t.push(ft.styleModule.of(n.module)),r=n.themeType),e!=null&&e.fallback?t.push(O5.of(n)):r?t.push(vk.computeN([ft.darkTheme],i=>i.facet(ft.darkTheme)==(r=="dark")?[n]:[])):t.push(vk.of(n)),t}class cY{constructor(e){this.markCache=Object.create(null),this.tree=br(e.state),this.decorations=this.buildDeco(e,Yb(e.state)),this.decoratedTo=e.viewport.to}update(e){let t=br(e.state),r=Yb(e.state),i=r!=Yb(e.startState),{viewport:o}=e.view,s=e.changes.mapPos(this.decoratedTo,1);t.length<o.to&&!i&&t.type==this.tree.type&&s>=o.to?(this.decorations=this.decorations.map(e.changes),this.decoratedTo=s):(t!=this.tree||e.viewportChanged||i)&&(this.tree=t,this.decorations=this.buildDeco(e.view,r),this.decoratedTo=o.to)}buildDeco(e,t){if(!t||!this.tree.length)return _t.none;let r=new Ua;for(let{from:i,to:o}of e.visibleRanges)Iz(this.tree,t,(s,a,l)=>{r.add(s,a,this.markCache[l]||(this.markCache[l]=_t.mark({class:l})))},i,o);return r.finish()}}const uY=pa.high(nr.fromClass(cY,{decorations:n=>n.decorations})),fY=zf.define([{tag:C.meta,color:"#404740"},{tag:C.link,textDecoration:"underline"},{tag:C.heading,textDecoration:"underline",fontWeight:"bold"},{tag:C.emphasis,fontStyle:"italic"},{tag:C.strong,fontWeight:"bold"},{tag:C.strikethrough,textDecoration:"line-through"},{tag:C.keyword,color:"#708"},{tag:[C.atom,C.bool,C.url,C.contentSeparator,C.labelName],color:"#219"},{tag:[C.literal,C.inserted],color:"#164"},{tag:[C.string,C.deleted],color:"#a11"},{tag:[C.regexp,C.escape,C.special(C.string)],color:"#e40"},{tag:C.definition(C.variableName),color:"#00f"},{tag:C.local(C.variableName),color:"#30a"},{tag:[C.typeName,C.namespace],color:"#085"},{tag:C.className,color:"#167"},{tag:[C.special(C.variableName),C.macroName],color:"#256"},{tag:C.definition(C.propertyName),color:"#00c"},{tag:C.comment,color:"#940"},{tag:C.invalid,color:"#f00"}]),dY=ft.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),v5=1e4,y5="()[]{}",b5=Ct.define({combine(n){return $s(n,{afterCursor:!0,brackets:y5,maxScanDistance:v5,renderMatch:mY})}}),hY=_t.mark({class:"cm-matchingBracket"}),pY=_t.mark({class:"cm-nonmatchingBracket"});function mY(n){let e=[],t=n.matched?hY:pY;return e.push(t.range(n.start.from,n.start.to)),n.end&&e.push(t.range(n.end.from,n.end.to)),e}const gY=Kr.define({create(){return _t.none},update(n,e){if(!e.docChanged&&!e.selection)return n;let t=[],r=e.state.facet(b5);for(let i of e.state.selection.ranges){if(!i.empty)continue;let o=Il(e.state,i.head,-1,r)||i.head>0&&Il(e.state,i.head-1,1,r)||r.afterCursor&&(Il(e.state,i.head,1,r)||i.head<e.state.doc.length&&Il(e.state,i.head+1,-1,r));o&&(t=t.concat(r.renderMatch(o,e.state)))}return _t.set(t,!0)},provide:n=>ft.decorations.from(n)}),OY=[gY,dY];function vY(n={}){return[b5.of(n),OY]}const S5=new gn;function yk(n,e,t){let r=n.prop(e<0?gn.openedBy:gn.closedBy);if(r)return r;if(n.name.length==1){let i=t.indexOf(n.name);if(i>-1&&i%2==(e<0?1:0))return[t[i+e]]}return null}function bk(n){let e=n.type.prop(S5);return e?e(n.node):n}function Il(n,e,t,r={}){let i=r.maxScanDistance||v5,o=r.brackets||y5,s=br(n),a=s.resolveInner(e,t);for(let l=a;l;l=l.parent){let c=yk(l.type,t,o);if(c&&l.from<l.to){let u=bk(l);if(u&&(t>0?e>=u.from&&e<u.to:e>u.from&&e<=u.to))return yY(n,e,t,l,u,c,o)}}return bY(n,e,t,s,a.type,i,o)}function yY(n,e,t,r,i,o,s){let a=r.parent,l={from:i.from,to:i.to},c=0,u=a==null?void 0:a.cursor();if(u&&(t<0?u.childBefore(r.from):u.childAfter(r.to)))do if(t<0?u.to<=r.from:u.from>=r.to){if(c==0&&o.indexOf(u.type.name)>-1&&u.from<u.to){let d=bk(u);return{start:l,end:d?{from:d.from,to:d.to}:void 0,matched:!0}}else if(yk(u.type,t,s))c++;else if(yk(u.type,-t,s)){if(c==0){let d=bk(u);return{start:l,end:d&&d.from<d.to?{from:d.from,to:d.to}:void 0,matched:!1}}c--}}while(t<0?u.prevSibling():u.nextSibling());return{start:l,matched:!1}}function bY(n,e,t,r,i,o,s){let a=t<0?n.sliceDoc(e-1,e):n.sliceDoc(e,e+1),l=s.indexOf(a);if(l<0||l%2==0!=t>0)return null;let c={from:t<0?e-1:e,to:t>0?e+1:e},u=n.doc.iterRange(e,t>0?n.doc.length:0),d=0;for(let h=0;!u.next().done&&h<=o;){let p=u.value;t<0&&(h+=p.length);let g=e+h*t;for(let O=t>0?0:p.length-1,v=t>0?p.length:-1;O!=v;O+=t){let b=s.indexOf(p[O]);if(!(b<0||r.resolveInner(g+O,1).type!=i))if(b%2==0==t>0)d++;else{if(d==1)return{start:c,end:{from:g+O,to:g+O+1},matched:b>>1==l>>1};d--}}t>0&&(h+=p.length)}return u.done?{start:c,matched:!1}:null}const SY=Object.create(null),wA=[ai.none],kA=[],PA=Object.create(null),wY=Object.create(null);for(let[n,e]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])wY[n]=kY(SY,e);function Gb(n,e){kA.indexOf(n)>-1||(kA.push(n),console.warn(e))}function kY(n,e){let t=[];for(let a of e.split(" ")){let l=[];for(let c of a.split(".")){let u=n[c]||C[c];u?typeof u=="function"?l.length?l=l.map(u):Gb(c,`Modifier ${c} used at start of tag`):l.length?Gb(c,`Tag ${c} used as modifier`):l=Array.isArray(u)?u:[u]:Gb(c,`Unknown highlighting tag ${c}`)}for(let c of l)t.push(c)}if(!t.length)return 0;let r=e.replace(/ /g,"_"),i=r+" "+t.map(a=>a.id),o=PA[i];if(o)return o.id;let s=PA[i]=ai.define({id:wA.length,name:r,props:[rc({[r]:t})]});return wA.push(s),s.id}vr.RTL,vr.LTR;const PY="#e5c07b",xA="#e06c75",xY="#56b6c2",CY="#ffffff",DO="#abb2bf",Sk="#7d8799",TY="#61afef",_Y="#98c379",CA="#d19a66",EY="#c678dd",RY="#21252b",TA="#2c313a",_A="#282c34",Hb="#353a42",AY="#3E4451",EA="#528bff",MY=ft.theme({"&":{color:DO,backgroundColor:_A},".cm-content":{caretColor:EA},".cm-cursor, .cm-dropCursor":{borderLeftColor:EA},"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:AY},".cm-panels":{backgroundColor:RY,color:DO},".cm-panels.cm-panels-top":{borderBottom:"2px solid black"},".cm-panels.cm-panels-bottom":{borderTop:"2px solid black"},".cm-searchMatch":{backgroundColor:"#72a1ff59",outline:"1px solid #457dff"},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:"#6199ff2f"},".cm-activeLine":{backgroundColor:"#6699ff0b"},".cm-selectionMatch":{backgroundColor:"#aafe661a"},"&.cm-focused .cm-matchingBracket, &.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bad0f847"},".cm-gutters":{backgroundColor:_A,color:Sk,border:"none"},".cm-activeLineGutter":{backgroundColor:TA},".cm-foldPlaceholder":{backgroundColor:"transparent",border:"none",color:"#ddd"},".cm-tooltip":{border:"none",backgroundColor:Hb},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:"transparent",borderBottomColor:"transparent"},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:Hb,borderBottomColor:Hb},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:TA,color:DO}}},{dark:!0}),$Y=zf.define([{tag:C.keyword,color:EY},{tag:[C.name,C.deleted,C.character,C.propertyName,C.macroName],color:xA},{tag:[C.function(C.variableName),C.labelName],color:TY},{tag:[C.color,C.constant(C.name),C.standard(C.name)],color:CA},{tag:[C.definition(C.name),C.separator],color:DO},{tag:[C.typeName,C.className,C.number,C.changed,C.annotation,C.modifier,C.self,C.namespace],color:PY},{tag:[C.operator,C.operatorKeyword,C.url,C.escape,C.regexp,C.link,C.special(C.string)],color:xY},{tag:[C.meta,C.comment],color:Sk},{tag:C.strong,fontWeight:"bold"},{tag:C.emphasis,fontStyle:"italic"},{tag:C.strikethrough,textDecoration:"line-through"},{tag:C.link,color:Sk,textDecoration:"underline"},{tag:C.heading,fontWeight:"bold",color:xA},{tag:[C.atom,C.bool,C.special(C.variableName)],color:CA},{tag:[C.processingInstruction,C.string,C.inserted],color:_Y},{tag:C.invalid,color:CY}]),DY=[MY,sx($Y)];var as=n=>{var{theme:e,settings:t={},styles:r=[]}=n,i={".cm-gutters":{}},o={};t.background&&(o.backgroundColor=t.background),t.backgroundImage&&(o.backgroundImage=t.backgroundImage),t.foreground&&(o.color=t.foreground),t.fontSize&&(o.fontSize=t.fontSize),(t.background||t.foreground)&&(i["&"]=o),t.fontFamily&&(i["&.cm-editor .cm-scroller"]={fontFamily:t.fontFamily}),t.gutterBackground&&(i[".cm-gutters"].backgroundColor=t.gutterBackground),t.gutterForeground&&(i[".cm-gutters"].color=t.gutterForeground),t.gutterBorder&&(i[".cm-gutters"].borderRightColor=t.gutterBorder),t.caret&&(i[".cm-content"]={caretColor:t.caret},i[".cm-cursor, .cm-dropCursor"]={borderLeftColor:t.caret});var s={};t.gutterActiveForeground&&(s.color=t.gutterActiveForeground),t.lineHighlight&&(i[".cm-activeLine"]={backgroundColor:t.lineHighlight},s.backgroundColor=t.lineHighlight),i[".cm-activeLineGutter"]=s,t.selection&&(i["&.cm-focused .cm-selectionBackground, & .cm-line::selection, & .cm-selectionLayer .cm-selectionBackground, .cm-content ::selection"]={background:t.selection+" !important"}),t.selectionMatch&&(i["& .cm-selectionMatch"]={backgroundColor:t.selectionMatch});var a=ft.theme(i,{dark:e==="dark"}),l=zf.define(r),c=[a,sx(l)];return c};const RA="#202e46",w5="#e2e2e2",QY="#b9c7e6",IY="rgba(255,255,255,0.2)",jY="rgba(255,255,255,0.5)",LY="#000",NY="rgba(0,0,0,0.4)",qY="rgba(0,0,0,0.1)",UY="white",Yf=["#77fd8c","#00ffff","#66ecff","#ffb9ff","#ffabb3","#ffdb56"],AA=Yf[0],Nd=Yf[1],BY=Yf[2],MA=Yf[3],FY=Yf[4],$A=Yf[5],VY="#ff2222",WY=n=>{let{state:e}=n,t=e.doc.lineAt(e.selection.main.from),r=ax(n.state,t.from);return r.line?ZY(n):r.block?GY(n):!1};function hp(n,e){return({state:t,dispatch:r})=>{if(t.readOnly)return!1;let i=n(e,t);return i?(r(t.update(i)),!0):!1}}const ZY=hp(lx,0),XY=hp(lx,1),zY=hp(lx,2),YY=hp(k5,0),GY=hp((n,e)=>k5(n,e,KY(e)),0);function ax(n,e){let t=n.languageDataAt("commentTokens",e);return t.length?t[0]:{}}const qd=50;function HY(n,{open:e,close:t},r,i){let o=n.sliceDoc(r-qd,r),s=n.sliceDoc(i,i+qd),a=/\s*$/.exec(o)[0].length,l=/^\s*/.exec(s)[0].length,c=o.length-a;if(o.slice(c-e.length,c)==e&&s.slice(l,l+t.length)==t)return{open:{pos:r-a,margin:a&&1},close:{pos:i+l,margin:l&&1}};let u,d;i-r<=2*qd?u=d=n.sliceDoc(r,i):(u=n.sliceDoc(r,r+qd),d=n.sliceDoc(i-qd,i));let h=/^\s*/.exec(u)[0].length,p=/\s*$/.exec(d)[0].length,g=d.length-p-t.length;return u.slice(h,h+e.length)==e&&d.slice(g,g+t.length)==t?{open:{pos:r+h+e.length,margin:/\s/.test(u.charAt(h+e.length))?1:0},close:{pos:i-p-t.length,margin:/\s/.test(d.charAt(g-1))?1:0}}:null}function KY(n){let e=[];for(let t of n.selection.ranges){let r=n.doc.lineAt(t.from),i=t.to<=r.to?r:n.doc.lineAt(t.to);i.from>r.from&&i.from==t.to&&(i=t.to==r.to+1?r:n.doc.lineAt(t.to-1));let o=e.length-1;o>=0&&e[o].to>r.from?e[o].to=i.to:e.push({from:r.from+/^\s*/.exec(r.text)[0].length,to:i.to})}return e}function k5(n,e,t=e.selection.ranges){let r=t.map(o=>ax(e,o.from).block);if(!r.every(o=>o))return null;let i=t.map((o,s)=>HY(e,r[s],o.from,o.to));if(n!=2&&!i.every(o=>o))return{changes:e.changes(t.map((o,s)=>i[s]?[]:[{from:o.from,insert:r[s].open+" "},{from:o.to,insert:" "+r[s].close}]))};if(n!=1&&i.some(o=>o)){let o=[];for(let s=0,a;s<i.length;s++)if(a=i[s]){let l=r[s],{open:c,close:u}=a;o.push({from:c.pos-l.open.length,to:c.pos+c.margin},{from:u.pos-u.margin,to:u.pos+l.close.length})}return{changes:o}}return null}function lx(n,e,t=e.selection.ranges){let r=[],i=-1;for(let{from:o,to:s}of t){let a=r.length,l=1e9,c=ax(e,o).line;if(c){for(let u=o;u<=s;){let d=e.doc.lineAt(u);if(d.from>i&&(o==s||s>d.from)){i=d.from;let h=/^\s*/.exec(d.text)[0].length,p=h==d.length,g=d.text.slice(h,h+c.length)==c?h:-1;h<d.text.length&&h<l&&(l=h),r.push({line:d,comment:g,token:c,indent:h,empty:p,single:!1})}u=d.to+1}if(l<1e9)for(let u=a;u<r.length;u++)r[u].indent<r[u].line.text.length&&(r[u].indent=l);r.length==a+1&&(r[a].single=!0)}}if(n!=2&&r.some(o=>o.comment<0&&(!o.empty||o.single))){let o=[];for(let{line:a,token:l,indent:c,empty:u,single:d}of r)(d||!u)&&o.push({from:a.from+c,insert:l+" "});let s=e.changes(o);return{changes:s,selection:e.selection.map(s,1)}}else if(n!=1&&r.some(o=>o.comment>=0)){let o=[];for(let{line:s,comment:a,token:l}of r)if(a>=0){let c=s.from+a,u=c+l.length;s.text[u-s.from]==" "&&u++,o.push({from:c,to:u})}return{changes:o}}return null}const wk=ma.define(),JY=ma.define(),eG=Ct.define(),P5=Ct.define({combine(n){return $s(n,{minDepth:100,newGroupDelay:500,joinToEvent:(e,t)=>t},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,t)=>(r,i)=>e(r,i)||t(r,i)})}}),x5=Kr.define({create(){return aa.empty},update(n,e){let t=e.state.facet(P5),r=e.annotation(wk);if(r){let l=go.fromTransaction(e,r.selection),c=r.side,u=c==0?n.undone:n.done;return l?u=Ov(u,u.length,t.minDepth,l):u=_5(u,e.startState.selection),new aa(c==0?r.rest:u,c==0?u:r.rest)}let i=e.annotation(JY);if((i=="full"||i=="before")&&(n=n.isolate()),e.annotation(Hr.addToHistory)===!1)return e.changes.empty?n:n.addMapping(e.changes.desc);let o=go.fromTransaction(e),s=e.annotation(Hr.time),a=e.annotation(Hr.userEvent);return o?n=n.addChanges(o,s,a,t,e):e.selection&&(n=n.addSelection(e.startState.selection,s,a,t.newGroupDelay)),(i=="full"||i=="after")&&(n=n.isolate()),n},toJSON(n){return{done:n.done.map(e=>e.toJSON()),undone:n.undone.map(e=>e.toJSON())}},fromJSON(n){return new aa(n.done.map(go.fromJSON),n.undone.map(go.fromJSON))}});function tG(n={}){return[x5,P5.of(n),ft.domEventHandlers({beforeinput(e,t){let r=e.inputType=="historyUndo"?C5:e.inputType=="historyRedo"?kk:null;return r?(e.preventDefault(),r(t)):!1}})]}function cx(n,e){return function({state:t,dispatch:r}){if(!e&&t.readOnly)return!1;let i=t.field(x5,!1);if(!i)return!1;let o=i.pop(n,t,e);return o?(r(o),!0):!1}}const C5=cx(0,!1),kk=cx(1,!1),nG=cx(0,!0);class go{constructor(e,t,r,i,o){this.changes=e,this.effects=t,this.mapped=r,this.startSelection=i,this.selectionsAfter=o}setSelAfter(e){return new go(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,t,r;return{changes:(e=this.changes)===null||e===void 0?void 0:e.toJSON(),mapped:(t=this.mapped)===null||t===void 0?void 0:t.toJSON(),startSelection:(r=this.startSelection)===null||r===void 0?void 0:r.toJSON(),selectionsAfter:this.selectionsAfter.map(i=>i.toJSON())}}static fromJSON(e){return new go(e.changes&&ri.fromJSON(e.changes),[],e.mapped&&la.fromJSON(e.mapped),e.startSelection&&Ie.fromJSON(e.startSelection),e.selectionsAfter.map(Ie.fromJSON))}static fromTransaction(e,t){let r=ts;for(let i of e.startState.facet(eG)){let o=i(e);o.length&&(r=r.concat(o))}return!r.length&&e.changes.empty?null:new go(e.changes.invert(e.startState.doc),r,void 0,t||e.startState.selection,ts)}static selection(e){return new go(void 0,ts,void 0,void 0,e)}}function Ov(n,e,t,r){let i=e+1>t+20?e-t-1:0,o=n.slice(i,e);return o.push(r),o}function rG(n,e){let t=[],r=!1;return n.iterChangedRanges((i,o)=>t.push(i,o)),e.iterChangedRanges((i,o,s,a)=>{for(let l=0;l<t.length;){let c=t[l++],u=t[l++];a>=c&&s<=u&&(r=!0)}}),r}function iG(n,e){return n.ranges.length==e.ranges.length&&n.ranges.filter((t,r)=>t.empty!=e.ranges[r].empty).length===0}function T5(n,e){return n.length?e.length?n.concat(e):n:e}const ts=[],oG=200;function _5(n,e){if(n.length){let t=n[n.length-1],r=t.selectionsAfter.slice(Math.max(0,t.selectionsAfter.length-oG));return r.length&&r[r.length-1].eq(e)?n:(r.push(e),Ov(n,n.length-1,1e9,t.setSelAfter(r)))}else return[go.selection([e])]}function sG(n){let e=n[n.length-1],t=n.slice();return t[n.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),t}function Kb(n,e){if(!n.length)return n;let t=n.length,r=ts;for(;t;){let i=aG(n[t-1],e,r);if(i.changes&&!i.changes.empty||i.effects.length){let o=n.slice(0,t);return o[t-1]=i,o}else e=i.mapped,t--,r=i.selectionsAfter}return r.length?[go.selection(r)]:ts}function aG(n,e,t){let r=T5(n.selectionsAfter.length?n.selectionsAfter.map(a=>a.map(e)):ts,t);if(!n.changes)return go.selection(r);let i=n.changes.map(e),o=e.mapDesc(n.changes,!0),s=n.mapped?n.mapped.composeDesc(o):o;return new go(i,cn.mapEffects(n.effects,e),s,n.startSelection.map(o),r)}const lG=/^(input\.type|delete)($|\.)/;class aa{constructor(e,t,r=0,i=void 0){this.done=e,this.undone=t,this.prevTime=r,this.prevUserEvent=i}isolate(){return this.prevTime?new aa(this.done,this.undone):this}addChanges(e,t,r,i,o){let s=this.done,a=s[s.length-1];return a&&a.changes&&!a.changes.empty&&e.changes&&(!r||lG.test(r))&&(!a.selectionsAfter.length&&t-this.prevTime<i.newGroupDelay&&i.joinToEvent(o,rG(a.changes,e.changes))||r=="input.type.compose")?s=Ov(s,s.length-1,i.minDepth,new go(e.changes.compose(a.changes),T5(cn.mapEffects(e.effects,a.changes),a.effects),a.mapped,a.startSelection,ts)):s=Ov(s,s.length,i.minDepth,e),new aa(s,ts,t,r)}addSelection(e,t,r,i){let o=this.done.length?this.done[this.done.length-1].selectionsAfter:ts;return o.length>0&&t-this.prevTime<i&&r==this.prevUserEvent&&r&&/^select($|\.)/.test(r)&&iG(o[o.length-1],e)?this:new aa(_5(this.done,e),this.undone,t,r)}addMapping(e){return new aa(Kb(this.done,e),Kb(this.undone,e),this.prevTime,this.prevUserEvent)}pop(e,t,r){let i=e==0?this.done:this.undone;if(i.length==0)return null;let o=i[i.length-1],s=o.selectionsAfter[0]||t.selection;if(r&&o.selectionsAfter.length)return t.update({selection:o.selectionsAfter[o.selectionsAfter.length-1],annotations:wk.of({side:e,rest:sG(i),selection:s}),userEvent:e==0?"select.undo":"select.redo",scrollIntoView:!0});if(o.changes){let a=i.length==1?ts:i.slice(0,i.length-1);return o.mapped&&(a=Kb(a,o.mapped)),t.update({changes:o.changes,selection:o.startSelection,effects:o.effects,annotations:wk.of({side:e,rest:a,selection:s}),filter:!1,userEvent:e==0?"undo":"redo",scrollIntoView:!0})}else return null}}aa.empty=new aa(ts,ts);function pp(n,e){return Ie.create(n.ranges.map(e),n.mainIndex)}function oc(n,e){return n.update({selection:e,scrollIntoView:!0,userEvent:"select"})}function cu({state:n,dispatch:e},t){let r=pp(n.selection,t);return r.eq(n.selection,!0)?!1:(e(oc(n,r)),!0)}function ay(n,e){return Ie.cursor(e?n.to:n.from)}function E5(n,e){return cu(n,t=>t.empty?n.moveByChar(t,e):ay(t,e))}function sc(n){return n.textDirectionAt(n.state.selection.main.head)==vr.LTR}const DA=n=>E5(n,!sc(n)),QA=n=>E5(n,sc(n));function R5(n,e){return cu(n,t=>t.empty?n.moveByGroup(t,e):ay(t,e))}const cG=n=>R5(n,!sc(n)),uG=n=>R5(n,sc(n));function A5(n,e){return cu(n,t=>{if(!t.empty)return ay(t,e);let r=n.moveVertically(t,e);return r.head!=t.head?r:n.moveToLineBoundary(t,e)})}const IA=n=>A5(n,!1),jA=n=>A5(n,!0);function M5(n){let e=n.scrollDOM.clientHeight<n.scrollDOM.scrollHeight-2,t=0,r=0,i;if(e){for(let o of n.state.facet(ft.scrollMargins)){let s=o(n);s!=null&&s.top&&(t=Math.max(s==null?void 0:s.top,t)),s!=null&&s.bottom&&(r=Math.max(s==null?void 0:s.bottom,r))}i=n.scrollDOM.clientHeight-t-r}else i=(n.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:t,marginBottom:r,selfScroll:e,height:Math.max(n.defaultLineHeight,i-5)}}function $5(n,e){let t=M5(n),{state:r}=n,i=pp(r.selection,s=>s.empty?n.moveVertically(s,e,t.height):ay(s,e));if(i.eq(r.selection))return!1;let o;if(t.selfScroll){let s=n.coordsAtPos(r.selection.main.head),a=n.scrollDOM.getBoundingClientRect(),l=a.top+t.marginTop,c=a.bottom-t.marginBottom;s&&s.top>l&&s.bottom<c&&(o=ft.scrollIntoView(i.main.head,{y:"start",yMargin:s.top-l}))}return n.dispatch(oc(r,i),{effects:o}),!0}const Jb=n=>$5(n,!1),eS=n=>$5(n,!0);function ly(n,e,t){let r=n.lineBlockAt(e.head),i=n.moveToLineBoundary(e,t);if(i.head==e.head&&i.head!=(t?r.to:r.from)&&(i=n.moveToLineBoundary(e,t,!1)),!t&&i.head==r.from&&r.length){let o=/^\s*/.exec(n.state.sliceDoc(r.from,Math.min(r.from+100,r.to)))[0].length;o&&e.head!=r.from+o&&(i=Ie.cursor(r.from+o))}return i}const LA=n=>cu(n,e=>ly(n,e,!0)),NA=n=>cu(n,e=>ly(n,e,!1)),fG=n=>cu(n,e=>Ie.cursor(n.lineBlockAt(e.head).from,1)),dG=n=>cu(n,e=>Ie.cursor(n.lineBlockAt(e.head).to,-1));function hG(n,e,t){let r=!1,i=pp(n.selection,o=>{let s=Il(n,o.head,-1)||Il(n,o.head,1)||o.head>0&&Il(n,o.head-1,1)||o.head<n.doc.length&&Il(n,o.head+1,-1);if(!s||!s.end)return o;r=!0;let a=s.start.from==o.head?s.end.to:s.end.from;return Ie.cursor(a)});return r?(e(oc(n,i)),!0):!1}const pG=({state:n,dispatch:e})=>hG(n,e);function ac(n,e){let t=pp(n.state.selection,r=>{let i=e(r);return Ie.range(r.anchor,i.head,i.goalColumn,i.bidiLevel||void 0)});return t.eq(n.state.selection)?!1:(n.dispatch(oc(n.state,t)),!0)}function D5(n,e){return ac(n,t=>n.moveByChar(t,e))}const qA=n=>D5(n,!sc(n)),UA=n=>D5(n,sc(n));function Q5(n,e){return ac(n,t=>n.moveByGroup(t,e))}const mG=n=>Q5(n,!sc(n)),gG=n=>Q5(n,sc(n));function I5(n,e){return ac(n,t=>n.moveVertically(t,e))}const BA=n=>I5(n,!1),FA=n=>I5(n,!0);function j5(n,e){return ac(n,t=>n.moveVertically(t,e,M5(n).height))}const VA=n=>j5(n,!1),WA=n=>j5(n,!0),ZA=n=>ac(n,e=>ly(n,e,!0)),XA=n=>ac(n,e=>ly(n,e,!1)),OG=n=>ac(n,e=>Ie.cursor(n.lineBlockAt(e.head).from)),vG=n=>ac(n,e=>Ie.cursor(n.lineBlockAt(e.head).to)),zA=({state:n,dispatch:e})=>(e(oc(n,{anchor:0})),!0),YA=({state:n,dispatch:e})=>(e(oc(n,{anchor:n.doc.length})),!0),GA=({state:n,dispatch:e})=>(e(oc(n,{anchor:n.selection.main.anchor,head:0})),!0),HA=({state:n,dispatch:e})=>(e(oc(n,{anchor:n.selection.main.anchor,head:n.doc.length})),!0),yG=({state:n,dispatch:e})=>(e(n.update({selection:{anchor:0,head:n.doc.length},userEvent:"select"})),!0),bG=({state:n,dispatch:e})=>{let t=uy(n).map(({from:r,to:i})=>Ie.range(r,Math.min(i+1,n.doc.length)));return e(n.update({selection:Ie.create(t),userEvent:"select"})),!0};function cy(n,e){if(n.state.readOnly)return!1;let t="delete.selection",{state:r}=n,i=r.changeByRange(o=>{let{from:s,to:a}=o;if(s==a){let l=e(o);l<s?(t="delete.backward",l=Fm(n,l,!1)):l>s&&(t="delete.forward",l=Fm(n,l,!0)),s=Math.min(s,l),a=Math.max(a,l)}else s=Fm(n,s,!1),a=Fm(n,a,!0);return s==a?{range:o}:{changes:{from:s,to:a},range:Ie.cursor(s,s<o.head?-1:1)}});return i.changes.empty?!1:(n.dispatch(r.update(i,{scrollIntoView:!0,userEvent:t,effects:t=="delete.selection"?ft.announce.of(r.phrase("Selection deleted")):void 0})),!0)}function Fm(n,e,t){if(n instanceof ft)for(let r of n.state.facet(ft.atomicRanges).map(i=>i(n)))r.between(e,e,(i,o)=>{i<e&&o>e&&(e=t?o:i)});return e}const L5=(n,e,t)=>cy(n,r=>{let i=r.from,{state:o}=n,s=o.doc.lineAt(i),a,l;if(t&&!e&&i>s.from&&i<s.from+200&&!/[^ \t]/.test(a=s.text.slice(0,i-s.from))){if(a[a.length-1]==" ")return i-1;let c=Rs(a,o.tabSize),u=c%Lf(o)||Lf(o);for(let d=0;d<u&&a[a.length-1-d]==" ";d++)i--;l=i}else l=Ci(s.text,i-s.from,e,e)+s.from,l==i&&s.number!=(e?o.doc.lines:1)?l+=e?1:-1:!e&&/[\ufe00-\ufe0f]/.test(s.text.slice(l-s.from,i-s.from))&&(l=Ci(s.text,l-s.from,!1,!1)+s.from);return l}),tS=n=>L5(n,!1,!0),KA=n=>L5(n,!0,!1),N5=(n,e)=>cy(n,t=>{let r=t.head,{state:i}=n,o=i.doc.lineAt(r),s=i.charCategorizer(r);for(let a=null;;){if(r==(e?o.to:o.from)){r==t.head&&o.number!=(e?i.doc.lines:1)&&(r+=e?1:-1);break}let l=Ci(o.text,r-o.from,e)+o.from,c=o.text.slice(Math.min(r,l)-o.from,Math.max(r,l)-o.from),u=s(c);if(a!=null&&u!=a)break;(c!=" "||r!=t.head)&&(a=u),r=l}return r}),JA=n=>N5(n,!1),SG=n=>N5(n,!0),eM=n=>cy(n,e=>{let t=n.lineBlockAt(e.head).to;return e.head<t?t:Math.min(n.state.doc.length,e.head+1)}),wG=n=>cy(n,e=>{let t=n.lineBlockAt(e.head).from;return e.head>t?t:Math.max(0,e.head-1)}),kG=({state:n,dispatch:e})=>{if(n.readOnly)return!1;let t=n.changeByRange(r=>({changes:{from:r.from,to:r.to,insert:Fn.of(["",""])},range:Ie.cursor(r.from)}));return e(n.update(t,{scrollIntoView:!0,userEvent:"input"})),!0},PG=({state:n,dispatch:e})=>{if(n.readOnly)return!1;let t=n.changeByRange(r=>{if(!r.empty||r.from==0||r.from==n.doc.length)return{range:r};let i=r.from,o=n.doc.lineAt(i),s=i==o.from?i-1:Ci(o.text,i-o.from,!1)+o.from,a=i==o.to?i+1:Ci(o.text,i-o.from,!0)+o.from;return{changes:{from:s,to:a,insert:n.doc.slice(i,a).append(n.doc.slice(s,i))},range:Ie.cursor(a)}});return t.changes.empty?!1:(e(n.update(t,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function uy(n){let e=[],t=-1;for(let r of n.selection.ranges){let i=n.doc.lineAt(r.from),o=n.doc.lineAt(r.to);if(!r.empty&&r.to==o.from&&(o=n.doc.lineAt(r.to-1)),t>=i.number){let s=e[e.length-1];s.to=o.to,s.ranges.push(r)}else e.push({from:i.from,to:o.to,ranges:[r]});t=o.number+1}return e}function q5(n,e,t){if(n.readOnly)return!1;let r=[],i=[];for(let o of uy(n)){if(t?o.to==n.doc.length:o.from==0)continue;let s=n.doc.lineAt(t?o.to+1:o.from-1),a=s.length+1;if(t){r.push({from:o.to,to:s.to},{from:o.from,insert:s.text+n.lineBreak});for(let l of o.ranges)i.push(Ie.range(Math.min(n.doc.length,l.anchor+a),Math.min(n.doc.length,l.head+a)))}else{r.push({from:s.from,to:o.from},{from:o.to,insert:n.lineBreak+s.text});for(let l of o.ranges)i.push(Ie.range(l.anchor-a,l.head-a))}}return r.length?(e(n.update({changes:r,scrollIntoView:!0,selection:Ie.create(i,n.selection.mainIndex),userEvent:"move.line"})),!0):!1}const xG=({state:n,dispatch:e})=>q5(n,e,!1),CG=({state:n,dispatch:e})=>q5(n,e,!0);function U5(n,e,t){if(n.readOnly)return!1;let r=[];for(let i of uy(n))t?r.push({from:i.from,insert:n.doc.slice(i.from,i.to)+n.lineBreak}):r.push({from:i.to,insert:n.lineBreak+n.doc.slice(i.from,i.to)});return e(n.update({changes:r,scrollIntoView:!0,userEvent:"input.copyline"})),!0}const TG=({state:n,dispatch:e})=>U5(n,e,!1),_G=({state:n,dispatch:e})=>U5(n,e,!0),EG=n=>{if(n.state.readOnly)return!1;let{state:e}=n,t=e.changes(uy(e).map(({from:i,to:o})=>(i>0?i--:o<e.doc.length&&o++,{from:i,to:o}))),r=pp(e.selection,i=>{let o;if(n.lineWrapping){let s=n.lineBlockAt(i.head),a=n.coordsAtPos(i.head,i.assoc||1);a&&(o=s.bottom+n.documentTop-a.bottom+n.defaultLineHeight/2)}return n.moveVertically(i,!0,o)}).map(t);return n.dispatch({changes:t,selection:r,scrollIntoView:!0,userEvent:"delete.line"}),!0};function RG(n,e){if(/\(\)|\[\]|\{\}/.test(n.sliceDoc(e-1,e+1)))return{from:e,to:e};let t=br(n).resolveInner(e),r=t.childBefore(e),i=t.childAfter(e),o;return r&&i&&r.to<=e&&i.from>=e&&(o=r.type.prop(gn.closedBy))&&o.indexOf(i.name)>-1&&n.doc.lineAt(r.to).from==n.doc.lineAt(i.from).from&&!/\S/.test(n.sliceDoc(r.to,i.from))?{from:r.to,to:i.from}:null}const tM=AG(!1);function AG(n){return({state:e,dispatch:t})=>{if(e.readOnly)return!1;let r=e.changeByRange(i=>{let{from:o,to:s}=i,a=e.doc.lineAt(o),l=!n&&o==s&&RG(e,o);n&&(o=s=(s<=a.to?a:e.doc.lineAt(s)).to);let c=new nx(e,{simulateBreak:o,simulateDoubleBreak:!!l}),u=o5(c,o);for(u==null&&(u=Rs(/^\s*/.exec(e.doc.lineAt(o).text)[0],e.tabSize));s<a.to&&/\s/.test(a.text[s-a.from]);)s++;l?{from:o,to:s}=l:o>a.from&&o<a.from+100&&!/\S/.test(a.text.slice(0,o))&&(o=a.from);let d=["",gv(e,u)];return l&&d.push(gv(e,c.lineIndent(a.from,-1))),{changes:{from:o,to:s,insert:Fn.of(d)},range:Ie.cursor(o+1+d[1].length)}});return t(e.update(r,{scrollIntoView:!0,userEvent:"input"})),!0}}function B5(n,e){let t=-1;return n.changeByRange(r=>{let i=[];for(let s=r.from;s<=r.to;){let a=n.doc.lineAt(s);a.number>t&&(r.empty||r.to>a.from)&&(e(a,i,r),t=a.number),s=a.to+1}let o=n.changes(i);return{changes:i,range:Ie.range(o.mapPos(r.anchor,1),o.mapPos(r.head,1))}})}const nM=({state:n,dispatch:e})=>n.readOnly?!1:(e(n.update(B5(n,(t,r)=>{r.push({from:t.from,insert:n.facet(fp)})}),{userEvent:"input.indent"})),!0),rM=({state:n,dispatch:e})=>n.readOnly?!1:(e(n.update(B5(n,(t,r)=>{let i=/^\s*/.exec(t.text)[0];if(!i)return;let o=Rs(i,n.tabSize),s=0,a=gv(n,Math.max(0,o-Lf(n)));for(;s<i.length&&s<a.length&&i.charCodeAt(s)==a.charCodeAt(s);)s++;r.push({from:t.from+s,to:t.from+i.length,insert:a.slice(s)})}),{userEvent:"delete.dedent"})),!0);function fr(){var n=arguments[0];typeof n=="string"&&(n=document.createElement(n));var e=1,t=arguments[1];if(t&&typeof t=="object"&&t.nodeType==null&&!Array.isArray(t)){for(var r in t)if(Object.prototype.hasOwnProperty.call(t,r)){var i=t[r];typeof i=="string"?n.setAttribute(r,i):i!=null&&(n[r]=i)}e++}for(;e<arguments.length;e++)F5(n,arguments[e]);return n}function F5(n,e){if(typeof e=="string")n.appendChild(document.createTextNode(e));else if(e!=null)if(e.nodeType!=null)n.appendChild(e);else if(Array.isArray(e))for(var t=0;t<e.length;t++)F5(n,e[t]);else throw new RangeError("Unsupported child node: "+e)}const iM=typeof String.prototype.normalize=="function"?n=>n.normalize("NFKD"):n=>n;class Nf{constructor(e,t,r=0,i=e.length,o,s){this.test=s,this.value={from:0,to:0},this.done=!1,this.matches=[],this.buffer="",this.bufferPos=0,this.iter=e.iterRange(r,i),this.bufferStart=r,this.normalize=o?a=>o(iM(a)):iM,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 co(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=$P(e),r=this.bufferStart+this.bufferPos;this.bufferPos+=ia(e);let i=this.normalize(t);if(i.length)for(let o=0,s=r;;o++){let a=i.charCodeAt(o),l=this.match(a,s,this.bufferPos+this.bufferStart);if(o==i.length-1){if(l)return this.value=l,this;break}s==r&&o<t.length&&t.charCodeAt(o)==a&&s++}}}match(e,t,r){let i=null;for(let o=0;o<this.matches.length;o+=2){let s=this.matches[o],a=!1;this.query.charCodeAt(s)==e&&(s==this.query.length-1?i={from:this.matches[o+1],to:r}:(this.matches[o]++,a=!0)),a||(this.matches.splice(o,2),o-=2)}return this.query.charCodeAt(0)==e&&(this.query.length==1?i={from:t,to:r}:this.matches.push(1,t)),i&&this.test&&!this.test(i.from,i.to,this.buffer,this.bufferStart)&&(i=null),i}}typeof Symbol<"u"&&(Nf.prototype[Symbol.iterator]=function(){return this});const V5={from:-1,to:-1,match:/.*/.exec("")},ux="gm"+(/x/.unicode==null?"":"u");class W5{constructor(e,t,r,i=0,o=e.length){if(this.text=e,this.to=o,this.curLine="",this.done=!1,this.value=V5,/\\[sWDnr]|\n|\r|\[\^/.test(t))return new Z5(e,t,r,i,o);this.re=new RegExp(t,ux+(r!=null&&r.ignoreCase?"i":"")),this.test=r==null?void 0:r.test,this.iter=e.iter();let s=e.lineAt(i);this.curLineStart=s.from,this.matchPos=vv(e,i),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 r=this.curLineStart+t.index,i=r+t[0].length;if(this.matchPos=vv(this.text,i+(r==i?1:0)),r==this.curLineStart+this.curLine.length&&this.nextLine(),(r<i||r>this.value.to)&&(!this.test||this.test(r,i,t)))return this.value={from:r,to:i,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}}}const nS=new WeakMap;class Sf{constructor(e,t){this.from=e,this.text=t}get to(){return this.from+this.text.length}static get(e,t,r){let i=nS.get(e);if(!i||i.from>=r||i.to<=t){let a=new Sf(t,e.sliceString(t,r));return nS.set(e,a),a}if(i.from==t&&i.to==r)return i;let{text:o,from:s}=i;return s>t&&(o=e.sliceString(t,s)+o,s=t),i.to<r&&(o+=e.sliceString(i.to,r)),nS.set(e,new Sf(s,o)),new Sf(t,o.slice(t-s,r-s))}}class Z5{constructor(e,t,r,i,o){this.text=e,this.to=o,this.done=!1,this.value=V5,this.matchPos=vv(e,i),this.re=new RegExp(t,ux+(r!=null&&r.ignoreCase?"i":"")),this.test=r==null?void 0:r.test,this.flat=Sf.get(e,i,this.chunkEnd(i+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 r=this.flat.from+t.index,i=r+t[0].length;if((this.flat.to>=this.to||t.index+t[0].length<=this.flat.text.length-10)&&(!this.test||this.test(r,i,t)))return this.value={from:r,to:i,match:t},this.matchPos=vv(this.text,i+(r==i?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=Sf.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}}typeof Symbol<"u"&&(W5.prototype[Symbol.iterator]=Z5.prototype[Symbol.iterator]=function(){return this});function MG(n){try{return new RegExp(n,ux),!0}catch{return!1}}function vv(n,e){if(e>=n.length)return e;let t=n.lineAt(e),r;for(;e<t.to&&(r=t.text.charCodeAt(e-t.from))>=56320&&r<57344;)e++;return e}function Pk(n){let e=String(n.state.doc.lineAt(n.state.selection.main.head).number),t=fr("input",{class:"cm-textfield",name:"line",value:e}),r=fr("form",{class:"cm-gotoLine",onkeydown:o=>{o.keyCode==27?(o.preventDefault(),n.dispatch({effects:yv.of(!1)}),n.focus()):o.keyCode==13&&(o.preventDefault(),i())},onsubmit:o=>{o.preventDefault(),i()}},fr("label",n.state.phrase("Go to line"),": ",t)," ",fr("button",{class:"cm-button",type:"submit"},n.state.phrase("go")));function i(){let o=/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(t.value);if(!o)return;let{state:s}=n,a=s.doc.lineAt(s.selection.main.head),[,l,c,u,d]=o,h=u?+u.slice(1):0,p=c?+c:a.number;if(c&&d){let v=p/100;l&&(v=v*(l=="-"?-1:1)+a.number/s.doc.lines),p=Math.round(s.doc.lines*v)}else c&&l&&(p=p*(l=="-"?-1:1)+a.number);let g=s.doc.line(Math.max(1,Math.min(s.doc.lines,p))),O=Ie.cursor(g.from+Math.max(0,Math.min(h,g.length)));n.dispatch({effects:[yv.of(!1),ft.scrollIntoView(O.from,{y:"center"})],selection:O}),n.focus()}return{dom:r}}const yv=cn.define(),oM=Kr.define({create(){return!0},update(n,e){for(let t of e.effects)t.is(yv)&&(n=t.value);return n},provide:n=>Lh.from(n,e=>e?Pk:null)}),$G=n=>{let e=jh(n,Pk);if(!e){let t=[yv.of(!0)];n.state.field(oM,!1)==null&&t.push(cn.appendConfig.of([oM,DG])),n.dispatch({effects:t}),e=jh(n,Pk)}return e&&e.dom.querySelector("input").select(),!0},DG=ft.baseTheme({".cm-panel.cm-gotoLine":{padding:"2px 6px 4px","& label":{fontSize:"80%"}}}),QG={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},IG=Ct.define({combine(n){return $s(n,QG,{highlightWordAroundCursor:(e,t)=>e||t,minSelectionLength:Math.min,maxMatches:Math.min})}});function jG(n){return[BG,UG]}const LG=_t.mark({class:"cm-selectionMatch"}),NG=_t.mark({class:"cm-selectionMatch cm-selectionMatch-main"});function sM(n,e,t,r){return(t==0||n(e.sliceDoc(t-1,t))!=Tr.Word)&&(r==e.doc.length||n(e.sliceDoc(r,r+1))!=Tr.Word)}function qG(n,e,t,r){return n(e.sliceDoc(t,t+1))==Tr.Word&&n(e.sliceDoc(r-1,r))==Tr.Word}const UG=nr.fromClass(class{constructor(n){this.decorations=this.getDeco(n)}update(n){(n.selectionSet||n.docChanged||n.viewportChanged)&&(this.decorations=this.getDeco(n.view))}getDeco(n){let e=n.state.facet(IG),{state:t}=n,r=t.selection;if(r.ranges.length>1)return _t.none;let i=r.main,o,s=null;if(i.empty){if(!e.highlightWordAroundCursor)return _t.none;let l=t.wordAt(i.head);if(!l)return _t.none;s=t.charCategorizer(i.head),o=t.sliceDoc(l.from,l.to)}else{let l=i.to-i.from;if(l<e.minSelectionLength||l>200)return _t.none;if(e.wholeWords){if(o=t.sliceDoc(i.from,i.to),s=t.charCategorizer(i.head),!(sM(s,t,i.from,i.to)&&qG(s,t,i.from,i.to)))return _t.none}else if(o=t.sliceDoc(i.from,i.to),!o)return _t.none}let a=[];for(let l of n.visibleRanges){let c=new Nf(t.doc,o,l.from,l.to);for(;!c.next().done;){let{from:u,to:d}=c.value;if((!s||sM(s,t,u,d))&&(i.empty&&u<=i.from&&d>=i.to?a.push(NG.range(u,d)):(u>=i.to||d<=i.from)&&a.push(LG.range(u,d)),a.length>e.maxMatches))return _t.none}}return _t.set(a)}},{decorations:n=>n.decorations}),BG=ft.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}}),FG=({state:n,dispatch:e})=>{let{selection:t}=n,r=Ie.create(t.ranges.map(i=>n.wordAt(i.head)||Ie.cursor(i.head)),t.mainIndex);return r.eq(t)?!1:(e(n.update({selection:r})),!0)};function VG(n,e){let{main:t,ranges:r}=n.selection,i=n.wordAt(t.head),o=i&&i.from==t.from&&i.to==t.to;for(let s=!1,a=new Nf(n.doc,e,r[r.length-1].to);;)if(a.next(),a.done){if(s)return null;a=new Nf(n.doc,e,0,Math.max(0,r[r.length-1].from-1)),s=!0}else{if(s&&r.some(l=>l.from==a.value.from))continue;if(o){let l=n.wordAt(a.value.from);if(!l||l.from!=a.value.from||l.to!=a.value.to)continue}return a.value}}const WG=({state:n,dispatch:e})=>{let{ranges:t}=n.selection;if(t.some(o=>o.from===o.to))return FG({state:n,dispatch:e});let r=n.sliceDoc(t[0].from,t[0].to);if(n.selection.ranges.some(o=>n.sliceDoc(o.from,o.to)!=r))return!1;let i=VG(n,r);return i?(e(n.update({selection:n.selection.addRange(Ie.range(i.from,i.to),!1),effects:ft.scrollIntoView(i.to)})),!0):!1},Gf=Ct.define({combine(n){return $s(n,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new eH(e),scrollToMatch:e=>ft.scrollIntoView(e)})}});class X5{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||MG(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,(t,r)=>r=="n"?`
|
|
127
|
-
`:r=="r"?"\r":r=="t"?" ":"\\")}eq(e){return this.search==e.search&&this.replace==e.replace&&this.caseSensitive==e.caseSensitive&&this.regexp==e.regexp&&this.wholeWord==e.wholeWord}create(){return this.regexp?new YG(this):new XG(this)}getCursor(e,t=0,r){let i=e.doc?e:Un.create({doc:e});return r==null&&(r=i.doc.length),this.regexp?tf(this,i,t,r):ef(this,i,t,r)}}class z5{constructor(e){this.spec=e}}function ef(n,e,t,r){return new Nf(e.doc,n.unquoted,t,r,n.caseSensitive?void 0:i=>i.toLowerCase(),n.wholeWord?ZG(e.doc,e.charCategorizer(e.selection.main.head)):void 0)}function ZG(n,e){return(t,r,i,o)=>((o>t||o+i.length<r)&&(o=Math.max(0,t-2),i=n.sliceString(o,Math.min(n.length,r+2))),(e(bv(i,t-o))!=Tr.Word||e(Sv(i,t-o))!=Tr.Word)&&(e(Sv(i,r-o))!=Tr.Word||e(bv(i,r-o))!=Tr.Word))}class XG extends z5{constructor(e){super(e)}nextMatch(e,t,r){let i=ef(this.spec,e,r,e.doc.length).nextOverlapping();if(i.done){let o=Math.min(e.doc.length,t+this.spec.unquoted.length);i=ef(this.spec,e,0,o).nextOverlapping()}return i.done||i.value.from==t&&i.value.to==r?null:i.value}prevMatchInRange(e,t,r){for(let i=r;;){let o=Math.max(t,i-1e4-this.spec.unquoted.length),s=ef(this.spec,e,o,i),a=null;for(;!s.nextOverlapping().done;)a=s.value;if(a)return a;if(o==t)return null;i-=1e4}}prevMatch(e,t,r){let i=this.prevMatchInRange(e,0,t);return i||(i=this.prevMatchInRange(e,Math.max(0,r-this.spec.unquoted.length),e.doc.length)),i&&(i.from!=t||i.to!=r)?i:null}getReplacement(e){return this.spec.unquote(this.spec.replace)}matchAll(e,t){let r=ef(this.spec,e,0,e.doc.length),i=[];for(;!r.next().done;){if(i.length>=t)return null;i.push(r.value)}return i}highlight(e,t,r,i){let o=ef(this.spec,e,Math.max(0,t-this.spec.unquoted.length),Math.min(r+this.spec.unquoted.length,e.doc.length));for(;!o.next().done;)i(o.value.from,o.value.to)}}function tf(n,e,t,r){return new W5(e.doc,n.search,{ignoreCase:!n.caseSensitive,test:n.wholeWord?zG(e.charCategorizer(e.selection.main.head)):void 0},t,r)}function bv(n,e){return n.slice(Ci(n,e,!1),e)}function Sv(n,e){return n.slice(e,Ci(n,e))}function zG(n){return(e,t,r)=>!r[0].length||(n(bv(r.input,r.index))!=Tr.Word||n(Sv(r.input,r.index))!=Tr.Word)&&(n(Sv(r.input,r.index+r[0].length))!=Tr.Word||n(bv(r.input,r.index+r[0].length))!=Tr.Word)}class YG extends z5{nextMatch(e,t,r){let i=tf(this.spec,e,r,e.doc.length).next();return i.done&&(i=tf(this.spec,e,0,t).next()),i.done?null:i.value}prevMatchInRange(e,t,r){for(let i=1;;i++){let o=Math.max(t,r-i*1e4),s=tf(this.spec,e,o,r),a=null;for(;!s.next().done;)a=s.value;if(a&&(o==t||a.from>o+10))return a;if(o==t)return null}}prevMatch(e,t,r){return this.prevMatchInRange(e,0,t)||this.prevMatchInRange(e,r,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,(t,r)=>{if(r=="&")return e.match[0];if(r=="$")return"$";for(let i=r.length;i>0;i--){let o=+r.slice(0,i);if(o>0&&o<e.match.length)return e.match[o]+r.slice(i)}return t})}matchAll(e,t){let r=tf(this.spec,e,0,e.doc.length),i=[];for(;!r.next().done;){if(i.length>=t)return null;i.push(r.value)}return i}highlight(e,t,r,i){let o=tf(this.spec,e,Math.max(0,t-250),Math.min(r+250,e.doc.length));for(;!o.next().done;)i(o.value.from,o.value.to)}}const Bh=cn.define(),fx=cn.define(),Fl=Kr.define({create(n){return new rS(xk(n).create(),null)},update(n,e){for(let t of e.effects)t.is(Bh)?n=new rS(t.value.create(),n.panel):t.is(fx)&&(n=new rS(n.query,t.value?dx:null));return n},provide:n=>Lh.from(n,e=>e.panel)});class rS{constructor(e,t){this.query=e,this.panel=t}}const GG=_t.mark({class:"cm-searchMatch"}),HG=_t.mark({class:"cm-searchMatch cm-searchMatch-selected"}),KG=nr.fromClass(class{constructor(n){this.view=n,this.decorations=this.highlight(n.state.field(Fl))}update(n){let e=n.state.field(Fl);(e!=n.startState.field(Fl)||n.docChanged||n.selectionSet||n.viewportChanged)&&(this.decorations=this.highlight(e))}highlight({query:n,panel:e}){if(!e||!n.spec.valid)return _t.none;let{view:t}=this,r=new Ua;for(let i=0,o=t.visibleRanges,s=o.length;i<s;i++){let{from:a,to:l}=o[i];for(;i<s-1&&l>o[i+1].from-2*250;)l=o[++i].to;n.highlight(t.state,a,l,(c,u)=>{let d=t.state.selection.ranges.some(h=>h.from==c&&h.to==u);r.add(c,u,d?HG:GG)})}return r.finish()}},{decorations:n=>n.decorations});function mp(n){return e=>{let t=e.state.field(Fl,!1);return t&&t.query.spec.valid?n(e,t):J5(e)}}const aM=mp((n,{query:e})=>{let{to:t}=n.state.selection.main,r=e.nextMatch(n.state,t,t);if(!r)return!1;let i=Ie.single(r.from,r.to),o=n.state.facet(Gf);return n.dispatch({selection:i,effects:[hx(n,r),o.scrollToMatch(i.main,n)],userEvent:"select.search"}),K5(n),!0}),lM=mp((n,{query:e})=>{let{state:t}=n,{from:r}=t.selection.main,i=e.prevMatch(t,r,r);if(!i)return!1;let o=Ie.single(i.from,i.to),s=n.state.facet(Gf);return n.dispatch({selection:o,effects:[hx(n,i),s.scrollToMatch(o.main,n)],userEvent:"select.search"}),K5(n),!0}),Y5=mp((n,{query:e})=>{let t=e.matchAll(n.state,1e3);return!t||!t.length?!1:(n.dispatch({selection:Ie.create(t.map(r=>Ie.range(r.from,r.to))),userEvent:"select.search.matches"}),!0)}),JG=({state:n,dispatch:e})=>{let t=n.selection;if(t.ranges.length>1||t.main.empty)return!1;let{from:r,to:i}=t.main,o=[],s=0;for(let a=new Nf(n.doc,n.sliceDoc(r,i));!a.next().done;){if(o.length>1e3)return!1;a.value.from==r&&(s=o.length),o.push(Ie.range(a.value.from,a.value.to))}return e(n.update({selection:Ie.create(o,s),userEvent:"select.search.matches"})),!0},cM=mp((n,{query:e})=>{let{state:t}=n,{from:r,to:i}=t.selection.main;if(t.readOnly)return!1;let o=e.nextMatch(t,r,r);if(!o)return!1;let s=o,a=[],l,c,u=[];if(s.from==r&&s.to==i&&(c=t.toText(e.getReplacement(s)),a.push({from:s.from,to:s.to,insert:c}),s=e.nextMatch(t,s.from,s.to),u.push(ft.announce.of(t.phrase("replaced match on line $",t.doc.lineAt(r).number)+"."))),s){let d=a.length==0||a[0].from>=o.to?0:o.to-o.from-c.length;l=Ie.single(s.from-d,s.to-d),u.push(hx(n,s)),u.push(t.facet(Gf).scrollToMatch(l.main,n))}return n.dispatch({changes:a,selection:l,effects:u,userEvent:"input.replace"}),!0}),G5=mp((n,{query:e})=>{if(n.state.readOnly)return!1;let t=e.matchAll(n.state,1e9).map(i=>{let{from:o,to:s}=i;return{from:o,to:s,insert:e.getReplacement(i)}});if(!t.length)return!1;let r=n.state.phrase("replaced $ matches",t.length)+".";return n.dispatch({changes:t,effects:ft.announce.of(r),userEvent:"input.replace.all"}),!0});function dx(n){return n.state.facet(Gf).createPanel(n)}function xk(n,e){var t,r,i,o,s;let a=n.selection.main,l=a.empty||a.to>a.from+100?"":n.sliceDoc(a.from,a.to);if(e&&!l)return e;let c=n.facet(Gf);return new X5({search:((t=e==null?void 0:e.literal)!==null&&t!==void 0?t:c.literal)?l:l.replace(/\n/g,"\\n"),caseSensitive:(r=e==null?void 0:e.caseSensitive)!==null&&r!==void 0?r:c.caseSensitive,literal:(i=e==null?void 0:e.literal)!==null&&i!==void 0?i:c.literal,regexp:(o=e==null?void 0:e.regexp)!==null&&o!==void 0?o:c.regexp,wholeWord:(s=e==null?void 0:e.wholeWord)!==null&&s!==void 0?s:c.wholeWord})}function H5(n){let e=jh(n,dx);return e&&e.dom.querySelector("[main-field]")}function K5(n){let e=H5(n);e&&e==n.root.activeElement&&e.select()}const J5=n=>{let e=n.state.field(Fl,!1);if(e&&e.panel){let t=H5(n);if(t&&t!=n.root.activeElement){let r=xk(n.state,e.query.spec);r.valid&&n.dispatch({effects:Bh.of(r)}),t.focus(),t.select()}}else n.dispatch({effects:[fx.of(!0),e?Bh.of(xk(n.state,e.query.spec)):cn.appendConfig.of(nH)]});return!0},e3=n=>{let e=n.state.field(Fl,!1);if(!e||!e.panel)return!1;let t=jh(n,dx);return t&&t.dom.contains(n.root.activeElement)&&n.focus(),n.dispatch({effects:fx.of(!1)}),!0};class eH{constructor(e){this.view=e;let t=this.query=e.state.field(Fl).query.spec;this.commit=this.commit.bind(this),this.searchField=fr("input",{value:t.search,placeholder:Co(e,"Find"),"aria-label":Co(e,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=fr("input",{value:t.replace,placeholder:Co(e,"Replace"),"aria-label":Co(e,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=fr("input",{type:"checkbox",name:"case",form:"",checked:t.caseSensitive,onchange:this.commit}),this.reField=fr("input",{type:"checkbox",name:"re",form:"",checked:t.regexp,onchange:this.commit}),this.wordField=fr("input",{type:"checkbox",name:"word",form:"",checked:t.wholeWord,onchange:this.commit});function r(i,o,s){return fr("button",{class:"cm-button",name:i,onclick:o,type:"button"},s)}this.dom=fr("div",{onkeydown:i=>this.keydown(i),class:"cm-search"},[this.searchField,r("next",()=>aM(e),[Co(e,"next")]),r("prev",()=>lM(e),[Co(e,"previous")]),r("select",()=>Y5(e),[Co(e,"all")]),fr("label",null,[this.caseField,Co(e,"match case")]),fr("label",null,[this.reField,Co(e,"regexp")]),fr("label",null,[this.wordField,Co(e,"by word")]),...e.state.readOnly?[]:[fr("br"),this.replaceField,r("replace",()=>cM(e),[Co(e,"replace")]),r("replaceAll",()=>G5(e),[Co(e,"replace all")])],fr("button",{name:"close",onclick:()=>e3(e),"aria-label":Co(e,"close"),type:"button"},["×"])])}commit(){let e=new X5({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:Bh.of(e)}))}keydown(e){vX(this.view,e,"search-panel")?e.preventDefault():e.keyCode==13&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?lM:aM)(this.view)):e.keyCode==13&&e.target==this.replaceField&&(e.preventDefault(),cM(this.view))}update(e){for(let t of e.transactions)for(let r of t.effects)r.is(Bh)&&!r.value.eq(this.query)&&this.setQuery(r.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(Gf).top}}function Co(n,e){return n.state.phrase(e)}const Vm=30,Wm=/[\s\.,:;?!]/;function hx(n,{from:e,to:t}){let r=n.state.doc.lineAt(e),i=n.state.doc.lineAt(t).to,o=Math.max(r.from,e-Vm),s=Math.min(i,t+Vm),a=n.state.sliceDoc(o,s);if(o!=r.from){for(let l=0;l<Vm;l++)if(!Wm.test(a[l+1])&&Wm.test(a[l])){a=a.slice(l);break}}if(s!=i){for(let l=a.length-1;l>a.length-Vm;l--)if(!Wm.test(a[l-1])&&Wm.test(a[l])){a=a.slice(0,l);break}}return ft.announce.of(`${n.state.phrase("current match")}. ${a} ${n.state.phrase("on line")} ${r.number}.`)}const tH=ft.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"}}),nH=[Fl,pa.low(KG),tH];class px{constructor(e,t,r,i){this.state=e,this.pos=t,this.explicit=r,this.view=i,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(e){let t=br(this.state).resolveInner(this.pos,-1);for(;t&&e.indexOf(t.name)<0;)t=t.parent;return t?{from:t.from,to:this.pos,text:this.state.sliceDoc(t.from,this.pos),type:t.type}:null}matchBefore(e){let t=this.state.doc.lineAt(this.pos),r=Math.max(t.from,this.pos-250),i=t.text.slice(r-t.from,this.pos-t.from),o=i.search(n3(e,!1));return o<0?null:{from:r+o,to:this.pos,text:i.slice(o)}}get aborted(){return this.abortListeners==null}addEventListener(e,t,r){e=="abort"&&this.abortListeners&&(this.abortListeners.push(t),r&&r.onDocChange&&(this.abortOnDocChange=!0))}}function uM(n){let e=Object.keys(n).join(""),t=/\w/.test(e);return t&&(e=e.replace(/\w/g,"")),`[${t?"\\w":""}${e.replace(/[^\w\s]/g,"\\$&")}]`}function rH(n){let e=Object.create(null),t=Object.create(null);for(let{label:i}of n){e[i[0]]=!0;for(let o=1;o<i.length;o++)t[i[o]]=!0}let r=uM(e)+uM(t)+"*$";return[new RegExp("^"+r),new RegExp(r)]}function t3(n){let e=n.map(i=>typeof i=="string"?{label:i}:i),[t,r]=e.every(i=>/^\w+$/.test(i.label))?[/\w*$/,/\w+$/]:rH(e);return i=>{let o=i.matchBefore(r);return o||i.explicit?{from:o?o.from:i.pos,options:e,validFor:t}:null}}function iH(n,e){return t=>{for(let r=br(t.state).resolveInner(t.pos,-1);r;r=r.parent){if(n.indexOf(r.name)>-1)return null;if(r.type.isTop)break}return e(t)}}class fM{constructor(e,t,r,i){this.completion=e,this.source=t,this.match=r,this.score=i}}function Kc(n){return n.selection.main.from}function n3(n,e){var t;let{source:r}=n,i=e&&r[0]!="^",o=r[r.length-1]!="$";return!i&&!o?n:new RegExp(`${i?"^":""}(?:${r})${o?"$":""}`,(t=n.flags)!==null&&t!==void 0?t:n.ignoreCase?"i":"")}const mx=ma.define();function oH(n,e,t,r){let{main:i}=n.selection,o=t-i.from,s=r-i.from;return Object.assign(Object.assign({},n.changeByRange(a=>{if(a!=i&&t!=r&&n.sliceDoc(a.from+o,a.from+s)!=n.sliceDoc(t,r))return{range:a};let l=n.toText(e);return{changes:{from:a.from+o,to:r==i.from?a.to:a.from+s,insert:l},range:Ie.cursor(a.from+o+l.length)}})),{scrollIntoView:!0,userEvent:"input.complete"})}const dM=new WeakMap;function sH(n){if(!Array.isArray(n))return n;let e=dM.get(n);return e||dM.set(n,e=t3(n)),e}const wv=cn.define(),Fh=cn.define();class aH{constructor(e){this.pattern=e,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(let t=0;t<e.length;){let r=co(e,t),i=ia(r);this.chars.push(r);let o=e.slice(t,t+i),s=o.toUpperCase();this.folded.push(co(s==o?o.toLowerCase():s,0)),t+=i}this.astral=e.length!=this.chars.length}ret(e,t){return this.score=e,this.matched=t,this}match(e){if(this.pattern.length==0)return this.ret(-100,[]);if(e.length<this.pattern.length)return null;let{chars:t,folded:r,any:i,precise:o,byWord:s}=this;if(t.length==1){let S=co(e,0),x=ia(S),P=x==e.length?0:-100;if(S!=t[0])if(S==r[0])P+=-200;else return null;return this.ret(P,[0,x])}let a=e.indexOf(this.pattern);if(a==0)return this.ret(e.length==this.pattern.length?0:-100,[0,this.pattern.length]);let l=t.length,c=0;if(a<0){for(let S=0,x=Math.min(e.length,200);S<x&&c<l;){let P=co(e,S);(P==t[c]||P==r[c])&&(i[c++]=S),S+=ia(P)}if(c<l)return null}let u=0,d=0,h=!1,p=0,g=-1,O=-1,v=/[a-z]/.test(e),b=!0;for(let S=0,x=Math.min(e.length,200),P=0;S<x&&d<l;){let w=co(e,S);a<0&&(u<l&&w==t[u]&&(o[u++]=S),p<l&&(w==t[p]||w==r[p]?(p==0&&(g=S),O=S+1,p++):p=0));let E,M=w<255?w>=48&&w<=57||w>=97&&w<=122?2:w>=65&&w<=90?1:0:(E=$P(w))!=E.toLowerCase()?1:E!=E.toUpperCase()?2:0;(!S||M==1&&v||P==0&&M!=0)&&(t[d]==w||r[d]==w&&(h=!0)?s[d++]=S:s.length&&(b=!1)),P=M,S+=ia(w)}return d==l&&s[0]==0&&b?this.result(-100+(h?-200:0),s,e):p==l&&g==0?this.ret(-200-e.length+(O==e.length?0:-100),[0,O]):a>-1?this.ret(-700-e.length,[a,a+this.pattern.length]):p==l?this.ret(-900-e.length,[g,O]):d==l?this.result(-100+(h?-200:0)+-700+(b?0:-1100),s,e):t.length==2?null:this.result((i[0]?-700:0)+-200+-1100,i,e)}result(e,t,r){let i=[],o=0;for(let s of t){let a=s+(this.astral?ia(co(r,s)):1);o&&i[o-1]==s?i[o-1]=a:(i[o++]=s,i[o++]=a)}return this.ret(e-r.length,i)}}class lH{constructor(e){this.pattern=e,this.matched=[],this.score=0,this.folded=e.toLowerCase()}match(e){if(e.length<this.pattern.length)return null;let t=e.slice(0,this.pattern.length),r=t==this.pattern?0:t.toLowerCase()==this.folded?-200:null;return r==null?null:(this.matched=[0,t.length],this.score=r+(e.length==this.pattern.length?0:-100),this)}}const Oi=Ct.define({combine(n){return $s(n,{activateOnTyping:!0,activateOnCompletion:()=>!1,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>"",optionClass:()=>"",aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:cH,filterStrict:!1,compareCompletions:(e,t)=>e.label.localeCompare(t.label),interactionDelay:75,updateSyncTime:100},{defaultKeymap:(e,t)=>e&&t,closeOnBlur:(e,t)=>e&&t,icons:(e,t)=>e&&t,tooltipClass:(e,t)=>r=>hM(e(r),t(r)),optionClass:(e,t)=>r=>hM(e(r),t(r)),addToOptions:(e,t)=>e.concat(t),filterStrict:(e,t)=>e||t})}});function hM(n,e){return n?e?n+" "+e:n:e}function cH(n,e,t,r,i,o){let s=n.textDirection==vr.RTL,a=s,l=!1,c="top",u,d,h=e.left-i.left,p=i.right-e.right,g=r.right-r.left,O=r.bottom-r.top;if(a&&h<Math.min(g,p)?a=!1:!a&&p<Math.min(g,h)&&(a=!0),g<=(a?h:p))u=Math.max(i.top,Math.min(t.top,i.bottom-O))-e.top,d=Math.min(400,a?h:p);else{l=!0,d=Math.min(400,(s?e.right:i.right-e.left)-30);let S=i.bottom-e.bottom;S>=O||S>e.top?u=t.bottom-e.top:(c="bottom",u=e.bottom-t.top)}let v=(e.bottom-e.top)/o.offsetHeight,b=(e.right-e.left)/o.offsetWidth;return{style:`${c}: ${u/v}px; max-width: ${d/b}px`,class:"cm-completionInfo-"+(l?s?"left-narrow":"right-narrow":a?"left":"right")}}function uH(n){let e=n.addToOptions.slice();return n.icons&&e.push({render(t){let r=document.createElement("div");return r.classList.add("cm-completionIcon"),t.type&&r.classList.add(...t.type.split(/\s+/g).map(i=>"cm-completionIcon-"+i)),r.setAttribute("aria-hidden","true"),r},position:20}),e.push({render(t,r,i,o){let s=document.createElement("span");s.className="cm-completionLabel";let a=t.displayLabel||t.label,l=0;for(let c=0;c<o.length;){let u=o[c++],d=o[c++];u>l&&s.appendChild(document.createTextNode(a.slice(l,u)));let h=s.appendChild(document.createElement("span"));h.appendChild(document.createTextNode(a.slice(u,d))),h.className="cm-completionMatchedText",l=d}return l<a.length&&s.appendChild(document.createTextNode(a.slice(l))),s},position:50},{render(t){if(!t.detail)return null;let r=document.createElement("span");return r.className="cm-completionDetail",r.textContent=t.detail,r},position:80}),e.sort((t,r)=>t.position-r.position).map(t=>t.render)}function iS(n,e,t){if(n<=t)return{from:0,to:n};if(e<0&&(e=0),e<=n>>1){let i=Math.floor(e/t);return{from:i*t,to:(i+1)*t}}let r=Math.floor((n-e)/t);return{from:n-(r+1)*t,to:n-r*t}}class fH{constructor(e,t,r){this.view=e,this.stateField=t,this.applyCompletion=r,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:l=>this.placeInfo(l),key:this},this.space=null,this.currentClass="";let i=e.state.field(t),{options:o,selected:s}=i.open,a=e.state.facet(Oi);this.optionContent=uH(a),this.optionClass=a.optionClass,this.tooltipClass=a.tooltipClass,this.range=iS(o.length,s,a.maxRenderedOptions),this.dom=document.createElement("div"),this.dom.className="cm-tooltip-autocomplete",this.updateTooltipClass(e.state),this.dom.addEventListener("mousedown",l=>{let{options:c}=e.state.field(t).open;for(let u=l.target,d;u&&u!=this.dom;u=u.parentNode)if(u.nodeName=="LI"&&(d=/-(\d+)$/.exec(u.id))&&+d[1]<c.length){this.applyCompletion(e,c[+d[1]]),l.preventDefault();return}}),this.dom.addEventListener("focusout",l=>{let c=e.state.field(this.stateField,!1);c&&c.tooltip&&e.state.facet(Oi).closeOnBlur&&l.relatedTarget!=e.contentDOM&&e.dispatch({effects:Fh.of(null)})}),this.showOptions(o,i.id)}mount(){this.updateSel()}showOptions(e,t){this.list&&this.list.remove(),this.list=this.dom.appendChild(this.createListBox(e,t,this.range)),this.list.addEventListener("scroll",()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)})}update(e){var t;let r=e.state.field(this.stateField),i=e.startState.field(this.stateField);if(this.updateTooltipClass(e.state),r!=i){let{options:o,selected:s,disabled:a}=r.open;(!i.open||i.open.options!=o)&&(this.range=iS(o.length,s,e.state.facet(Oi).maxRenderedOptions),this.showOptions(o,r.id)),this.updateSel(),a!=((t=i.open)===null||t===void 0?void 0:t.disabled)&&this.dom.classList.toggle("cm-tooltip-autocomplete-disabled",!!a)}}updateTooltipClass(e){let t=this.tooltipClass(e);if(t!=this.currentClass){for(let r of this.currentClass.split(" "))r&&this.dom.classList.remove(r);for(let r of t.split(" "))r&&this.dom.classList.add(r);this.currentClass=t}}positioned(e){this.space=e,this.info&&this.view.requestMeasure(this.placeInfoReq)}updateSel(){let e=this.view.state.field(this.stateField),t=e.open;if((t.selected>-1&&t.selected<this.range.from||t.selected>=this.range.to)&&(this.range=iS(t.options.length,t.selected,this.view.state.facet(Oi).maxRenderedOptions),this.showOptions(t.options,e.id)),this.updateSelectedOption(t.selected)){this.destroyInfo();let{completion:r}=t.options[t.selected],{info:i}=r;if(!i)return;let o=typeof i=="string"?document.createTextNode(i):i(r);if(!o)return;"then"in o?o.then(s=>{s&&this.view.state.field(this.stateField,!1)==e&&this.addInfoPane(s,r)}).catch(s=>mo(this.view.state,s,"completion info")):this.addInfoPane(o,r)}}addInfoPane(e,t){this.destroyInfo();let r=this.info=document.createElement("div");if(r.className="cm-tooltip cm-completionInfo",e.nodeType!=null)r.appendChild(e),this.infoDestroy=null;else{let{dom:i,destroy:o}=e;r.appendChild(i),this.infoDestroy=o||null}this.dom.appendChild(r),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(e){let t=null;for(let r=this.list.firstChild,i=this.range.from;r;r=r.nextSibling,i++)r.nodeName!="LI"||!r.id?i--:i==e?r.hasAttribute("aria-selected")||(r.setAttribute("aria-selected","true"),t=r):r.hasAttribute("aria-selected")&&r.removeAttribute("aria-selected");return t&&hH(this.list,t),t}measureInfo(){let e=this.dom.querySelector("[aria-selected]");if(!e||!this.info)return null;let t=this.dom.getBoundingClientRect(),r=this.info.getBoundingClientRect(),i=e.getBoundingClientRect(),o=this.space;if(!o){let s=this.dom.ownerDocument.documentElement;o={left:0,top:0,right:s.clientWidth,bottom:s.clientHeight}}return i.top>Math.min(o.bottom,t.bottom)-10||i.bottom<Math.max(o.top,t.top)+10?null:this.view.state.facet(Oi).positionInfo(this.view,t,i,r,o,this.dom)}placeInfo(e){this.info&&(e?(e.style&&(this.info.style.cssText=e.style),this.info.className="cm-tooltip cm-completionInfo "+(e.class||"")):this.info.style.cssText="top: -1e6px")}createListBox(e,t,r){const i=document.createElement("ul");i.id=t,i.setAttribute("role","listbox"),i.setAttribute("aria-expanded","true"),i.setAttribute("aria-label",this.view.state.phrase("Completions")),i.addEventListener("mousedown",s=>{s.target==i&&s.preventDefault()});let o=null;for(let s=r.from;s<r.to;s++){let{completion:a,match:l}=e[s],{section:c}=a;if(c){let h=typeof c=="string"?c:c.name;if(h!=o&&(s>r.from||r.from==0))if(o=h,typeof c!="string"&&c.header)i.appendChild(c.header(c));else{let p=i.appendChild(document.createElement("completion-section"));p.textContent=h}}const u=i.appendChild(document.createElement("li"));u.id=t+"-"+s,u.setAttribute("role","option");let d=this.optionClass(a);d&&(u.className=d);for(let h of this.optionContent){let p=h(a,this.view.state,this.view,l);p&&u.appendChild(p)}}return r.from&&i.classList.add("cm-completionListIncompleteTop"),r.to<e.length&&i.classList.add("cm-completionListIncompleteBottom"),i}destroyInfo(){this.info&&(this.infoDestroy&&this.infoDestroy(),this.info.remove(),this.info=null)}destroy(){this.destroyInfo()}}function dH(n,e){return t=>new fH(t,n,e)}function hH(n,e){let t=n.getBoundingClientRect(),r=e.getBoundingClientRect(),i=t.height/n.offsetHeight;r.top<t.top?n.scrollTop-=(t.top-r.top)/i:r.bottom>t.bottom&&(n.scrollTop+=(r.bottom-t.bottom)/i)}function pM(n){return(n.boost||0)*100+(n.apply?10:0)+(n.info?5:0)+(n.type?1:0)}function pH(n,e){let t=[],r=null,i=c=>{t.push(c);let{section:u}=c.completion;if(u){r||(r=[]);let d=typeof u=="string"?u:u.name;r.some(h=>h.name==d)||r.push(typeof u=="string"?{name:d}:u)}},o=e.facet(Oi);for(let c of n)if(c.hasResult()){let u=c.result.getMatch;if(c.result.filter===!1)for(let d of c.result.options)i(new fM(d,c.source,u?u(d):[],1e9-t.length));else{let d=e.sliceDoc(c.from,c.to),h,p=o.filterStrict?new lH(d):new aH(d);for(let g of c.result.options)if(h=p.match(g.label)){let O=g.displayLabel?u?u(g,h.matched):[]:h.matched;i(new fM(g,c.source,O,h.score+(g.boost||0)))}}}if(r){let c=Object.create(null),u=0,d=(h,p)=>{var g,O;return((g=h.rank)!==null&&g!==void 0?g:1e9)-((O=p.rank)!==null&&O!==void 0?O:1e9)||(h.name<p.name?-1:1)};for(let h of r.sort(d))u-=1e5,c[h.name]=u;for(let h of t){let{section:p}=h.completion;p&&(h.score+=c[typeof p=="string"?p:p.name])}}let s=[],a=null,l=o.compareCompletions;for(let c of t.sort((u,d)=>d.score-u.score||l(u.completion,d.completion))){let u=c.completion;!a||a.label!=u.label||a.detail!=u.detail||a.type!=null&&u.type!=null&&a.type!=u.type||a.apply!=u.apply||a.boost!=u.boost?s.push(c):pM(c.completion)>pM(a)&&(s[s.length-1]=c),a=c.completion}return s}class cf{constructor(e,t,r,i,o,s){this.options=e,this.attrs=t,this.tooltip=r,this.timestamp=i,this.selected=o,this.disabled=s}setSelected(e,t){return e==this.selected||e>=this.options.length?this:new cf(this.options,mM(t,e),this.tooltip,this.timestamp,e,this.disabled)}static build(e,t,r,i,o,s){if(i&&!s&&e.some(c=>c.isPending))return i.setDisabled();let a=pH(e,t);if(!a.length)return i&&e.some(c=>c.isPending)?i.setDisabled():null;let l=t.facet(Oi).selectOnOpen?0:-1;if(i&&i.selected!=l&&i.selected!=-1){let c=i.options[i.selected].completion;for(let u=0;u<a.length;u++)if(a[u].completion==c){l=u;break}}return new cf(a,mM(r,l),{pos:e.reduce((c,u)=>u.hasResult()?Math.min(c,u.from):c,1e8),create:bH,above:o.aboveCursor},i?i.timestamp:Date.now(),l,!1)}map(e){return new cf(this.options,this.attrs,Object.assign(Object.assign({},this.tooltip),{pos:e.mapPos(this.tooltip.pos)}),this.timestamp,this.selected,this.disabled)}setDisabled(){return new cf(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}}class kv{constructor(e,t,r){this.active=e,this.id=t,this.open=r}static start(){return new kv(vH,"cm-ac-"+Math.floor(Math.random()*2e6).toString(36),null)}update(e){let{state:t}=e,r=t.facet(Oi),o=(r.override||t.languageDataAt("autocomplete",Kc(t)).map(sH)).map(l=>(this.active.find(u=>u.source==l)||new ns(l,this.active.some(u=>u.state!=0)?1:0)).update(e,r));o.length==this.active.length&&o.every((l,c)=>l==this.active[c])&&(o=this.active);let s=this.open,a=e.effects.some(l=>l.is(gx));s&&e.docChanged&&(s=s.map(e.changes)),e.selection||o.some(l=>l.hasResult()&&e.changes.touchesRange(l.from,l.to))||!mH(o,this.active)||a?s=cf.build(o,t,this.id,s,r,a):s&&s.disabled&&!o.some(l=>l.isPending)&&(s=null),!s&&o.every(l=>!l.isPending)&&o.some(l=>l.hasResult())&&(o=o.map(l=>l.hasResult()?new ns(l.source,0):l));for(let l of e.effects)l.is(i3)&&(s=s&&s.setSelected(l.value,this.id));return o==this.active&&s==this.open?this:new kv(o,this.id,s)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?gH:OH}}function mH(n,e){if(n==e)return!0;for(let t=0,r=0;;){for(;t<n.length&&!n[t].hasResult();)t++;for(;r<e.length&&!e[r].hasResult();)r++;let i=t==n.length,o=r==e.length;if(i||o)return i==o;if(n[t++].result!=e[r++].result)return!1}}const gH={"aria-autocomplete":"list"},OH={};function mM(n,e){let t={"aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":n};return e>-1&&(t["aria-activedescendant"]=n+"-"+e),t}const vH=[];function r3(n,e){if(n.isUserEvent("input.complete")){let r=n.annotation(mx);if(r&&e.activateOnCompletion(r))return 12}let t=n.isUserEvent("input.type");return t&&e.activateOnTyping?5:t?1:n.isUserEvent("delete.backward")?2:n.selection?8:n.docChanged?16:0}class ns{constructor(e,t,r=!1){this.source=e,this.state=t,this.explicit=r}hasResult(){return!1}get isPending(){return this.state==1}update(e,t){let r=r3(e,t),i=this;(r&8||r&16&&this.touches(e))&&(i=new ns(i.source,0)),r&4&&i.state==0&&(i=new ns(this.source,1)),i=i.updateFor(e,r);for(let o of e.effects)if(o.is(wv))i=new ns(i.source,1,o.value);else if(o.is(Fh))i=new ns(i.source,0);else if(o.is(gx))for(let s of o.value)s.source==i.source&&(i=s);return i}updateFor(e,t){return this.map(e.changes)}map(e){return this}touches(e){return e.changes.touchesRange(Kc(e.state))}}class wf extends ns{constructor(e,t,r,i,o,s){super(e,3,t),this.limit=r,this.result=i,this.from=o,this.to=s}hasResult(){return!0}updateFor(e,t){var r;if(!(t&3))return this.map(e.changes);let i=this.result;i.map&&!e.changes.empty&&(i=i.map(i,e.changes));let o=e.changes.mapPos(this.from),s=e.changes.mapPos(this.to,1),a=Kc(e.state);if(a>s||!i||t&2&&(Kc(e.startState)==this.from||a<this.limit))return new ns(this.source,t&4?1:0);let l=e.changes.mapPos(this.limit);return yH(i.validFor,e.state,o,s)?new wf(this.source,this.explicit,l,i,o,s):i.update&&(i=i.update(i,o,s,new px(e.state,a,!1)))?new wf(this.source,this.explicit,l,i,i.from,(r=i.to)!==null&&r!==void 0?r:Kc(e.state)):new ns(this.source,1,this.explicit)}map(e){return e.empty?this:(this.result.map?this.result.map(this.result,e):this.result)?new wf(this.source,this.explicit,e.mapPos(this.limit),this.result,e.mapPos(this.from),e.mapPos(this.to,1)):new ns(this.source,0)}touches(e){return e.changes.touchesRange(this.from,this.to)}}function yH(n,e,t,r){if(!n)return!1;let i=e.sliceDoc(t,r);return typeof n=="function"?n(i,t,r,e):n3(n,!0).test(i)}const gx=cn.define({map(n,e){return n.map(t=>t.map(e))}}),i3=cn.define(),fo=Kr.define({create(){return kv.start()},update(n,e){return n.update(e)},provide:n=>[zP.from(n,e=>e.tooltip),ft.contentAttributes.from(n,e=>e.attrs)]});function Ox(n,e){const t=e.completion.apply||e.completion.label;let r=n.state.field(fo).active.find(i=>i.source==e.source);return r instanceof wf?(typeof t=="string"?n.dispatch(Object.assign(Object.assign({},oH(n.state,t,r.from,r.to)),{annotations:mx.of(e.completion)})):t(n,e.completion,r.from,r.to),!0):!1}const bH=dH(fo,Ox);function jl(n,e="option"){return t=>{let r=t.state.field(fo,!1);if(!r||!r.open||r.open.disabled||Date.now()-r.open.timestamp<t.state.facet(Oi).interactionDelay)return!1;let i=1,o;e=="page"&&(o=zN(t,r.open.tooltip))&&(i=Math.max(2,Math.floor(o.dom.offsetHeight/o.dom.querySelector("li").offsetHeight)-1));let{length:s}=r.open.options,a=r.open.selected>-1?r.open.selected+i*(n?1:-1):n?0:s-1;return a<0?a=e=="page"?0:s-1:a>=s&&(a=e=="page"?s-1:0),t.dispatch({effects:i3.of(a)}),!0}}const Ck=n=>{let e=n.state.field(fo,!1);return n.state.readOnly||!e||!e.open||e.open.selected<0||e.open.disabled||Date.now()-e.open.timestamp<n.state.facet(Oi).interactionDelay?!1:Ox(n,e.open.options[e.open.selected])},Tk=n=>n.state.field(fo,!1)?(n.dispatch({effects:wv.of(!0)}),!0):!1,o3=n=>{let e=n.state.field(fo,!1);return!e||!e.active.some(t=>t.state!=0)?!1:(n.dispatch({effects:Fh.of(null)}),!0)};class SH{constructor(e,t){this.active=e,this.context=t,this.time=Date.now(),this.updates=[],this.done=void 0}}const wH=50,kH=1e3,PH=nr.fromClass(class{constructor(n){this.view=n,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0;for(let e of n.state.field(fo).active)e.isPending&&this.startQuery(e)}update(n){let e=n.state.field(fo),t=n.state.facet(Oi);if(!n.selectionSet&&!n.docChanged&&n.startState.field(fo)==e)return;let r=n.transactions.some(o=>{let s=r3(o,t);return s&8||(o.selection||o.docChanged)&&!(s&3)});for(let o=0;o<this.running.length;o++){let s=this.running[o];if(r||s.context.abortOnDocChange&&n.docChanged||s.updates.length+n.transactions.length>wH&&Date.now()-s.time>kH){for(let a of s.context.abortListeners)try{a()}catch(l){mo(this.view.state,l)}s.context.abortListeners=null,this.running.splice(o--,1)}else s.updates.push(...n.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),n.transactions.some(o=>o.effects.some(s=>s.is(wv)))&&(this.pendingStart=!0);let i=this.pendingStart?50:t.activateOnTypingDelay;if(this.debounceUpdate=e.active.some(o=>o.isPending&&!this.running.some(s=>s.active.source==o.source))?setTimeout(()=>this.startUpdate(),i):-1,this.composing!=0)for(let o of n.transactions)o.isUserEvent("input.type")?this.composing=2:this.composing==2&&o.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:n}=this.view,e=n.field(fo);for(let t of e.active)t.isPending&&!this.running.some(r=>r.active.source==t.source)&&this.startQuery(t);this.running.length&&e.open&&e.open.disabled&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(Oi).updateSyncTime))}startQuery(n){let{state:e}=this.view,t=Kc(e),r=new px(e,t,n.explicit,this.view),i=new SH(n,r);this.running.push(i),Promise.resolve(n.source(r)).then(o=>{i.context.aborted||(i.done=o||null,this.scheduleAccept())},o=>{this.view.dispatch({effects:Fh.of(null)}),mo(this.view.state,o)})}scheduleAccept(){this.running.every(n=>n.done!==void 0)?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(Oi).updateSyncTime))}accept(){var n;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let e=[],t=this.view.state.facet(Oi),r=this.view.state.field(fo);for(let i=0;i<this.running.length;i++){let o=this.running[i];if(o.done===void 0)continue;if(this.running.splice(i--,1),o.done){let a=Kc(o.updates.length?o.updates[0].startState:this.view.state),l=Math.min(a,o.done.from+(o.active.explicit?0:1)),c=new wf(o.active.source,o.active.explicit,l,o.done,o.done.from,(n=o.done.to)!==null&&n!==void 0?n:a);for(let u of o.updates)c=c.update(u,t);if(c.hasResult()){e.push(c);continue}}let s=r.active.find(a=>a.source==o.active.source);if(s&&s.isPending)if(o.done==null){let a=new ns(o.active.source,0);for(let l of o.updates)a=a.update(l,t);a.isPending||e.push(a)}else this.startQuery(s)}(e.length||r.open&&r.open.disabled)&&this.view.dispatch({effects:gx.of(e)})}},{eventHandlers:{blur(n){let e=this.view.state.field(fo,!1);if(e&&e.tooltip&&this.view.state.facet(Oi).closeOnBlur){let t=e.open&&zN(this.view,e.open.tooltip);(!t||!t.dom.contains(n.relatedTarget))&&setTimeout(()=>this.view.dispatch({effects:Fh.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:wv.of(!1)}),20),this.composing=0}}}),xH=typeof navigator=="object"&&/Win/.test(navigator.platform),CH=pa.highest(ft.domEventHandlers({keydown(n,e){let t=e.state.field(fo,!1);if(!t||!t.open||t.open.disabled||t.open.selected<0||n.key.length>1||n.ctrlKey&&!(xH&&n.altKey)||n.metaKey)return!1;let r=t.open.options[t.open.selected],i=t.active.find(s=>s.source==r.source),o=r.completion.commitCharacters||i.result.commitCharacters;return o&&o.indexOf(n.key)>-1&&Ox(e,r),!1}})),s3=ft.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:"monospace",whiteSpace:"nowrap",overflow:"hidden auto",maxWidth_fallback:"700px",maxWidth:"min(700px, 95vw)",minWidth:"250px",maxHeight:"10em",height:"100%",listStyle:"none",margin:0,padding:0,"& > li, & > completion-section":{padding:"1px 3px",lineHeight:1.2},"& > li":{overflowX:"hidden",textOverflow:"ellipsis",cursor:"pointer"},"& > completion-section":{display:"list-item",borderBottom:"1px solid silver",paddingLeft:"0.5em",opacity:.7}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#17c",color:"white"},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#777"},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#347",color:"white"},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#444"},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:'"···"',opacity:.5,display:"block",textAlign:"center"},".cm-tooltip.cm-completionInfo":{position:"absolute",padding:"3px 9px",width:"max-content",maxWidth:"400px",boxSizing:"border-box",whiteSpace:"pre-line"},".cm-completionInfo.cm-completionInfo-left":{right:"100%"},".cm-completionInfo.cm-completionInfo-right":{left:"100%"},".cm-completionInfo.cm-completionInfo-left-narrow":{right:"30px"},".cm-completionInfo.cm-completionInfo-right-narrow":{left:"30px"},"&light .cm-snippetField":{backgroundColor:"#00000022"},"&dark .cm-snippetField":{backgroundColor:"#ffffff22"},".cm-snippetFieldPosition":{verticalAlign:"text-top",width:0,height:"1.15em",display:"inline-block",margin:"0 -0.7px -.7em",borderLeft:"1.4px dotted #888"},".cm-completionMatchedText":{textDecoration:"underline"},".cm-completionDetail":{marginLeft:"0.5em",fontStyle:"italic"},".cm-completionIcon":{fontSize:"90%",width:".8em",display:"inline-block",textAlign:"center",paddingRight:".6em",opacity:"0.6",boxSizing:"content-box"},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:"'ƒ'"}},".cm-completionIcon-class":{"&:after":{content:"'○'"}},".cm-completionIcon-interface":{"&:after":{content:"'◌'"}},".cm-completionIcon-variable":{"&:after":{content:"'𝑥'"}},".cm-completionIcon-constant":{"&:after":{content:"'𝐶'"}},".cm-completionIcon-type":{"&:after":{content:"'𝑡'"}},".cm-completionIcon-enum":{"&:after":{content:"'∪'"}},".cm-completionIcon-property":{"&:after":{content:"'□'"}},".cm-completionIcon-keyword":{"&:after":{content:"'🔑︎'"}},".cm-completionIcon-namespace":{"&:after":{content:"'▢'"}},".cm-completionIcon-text":{"&:after":{content:"'abc'",fontSize:"50%",verticalAlign:"middle"}}});class TH{constructor(e,t,r,i){this.field=e,this.line=t,this.from=r,this.to=i}}class vx{constructor(e,t,r){this.field=e,this.from=t,this.to=r}map(e){let t=e.mapPos(this.from,-1,ii.TrackDel),r=e.mapPos(this.to,1,ii.TrackDel);return t==null||r==null?null:new vx(this.field,t,r)}}class yx{constructor(e,t){this.lines=e,this.fieldPositions=t}instantiate(e,t){let r=[],i=[t],o=e.doc.lineAt(t),s=/^\s*/.exec(o.text)[0];for(let l of this.lines){if(r.length){let c=s,u=/^\t*/.exec(l)[0].length;for(let d=0;d<u;d++)c+=e.facet(fp);i.push(t+c.length-u),l=c+l.slice(u)}r.push(l),t+=l.length+1}let a=this.fieldPositions.map(l=>new vx(l.field,i[l.line]+l.from,i[l.line]+l.to));return{text:r,ranges:a}}static parse(e){let t=[],r=[],i=[],o;for(let s of e.split(/\r\n?|\n/)){for(;o=/[#$]\{(?:(\d+)(?::([^}]*))?|((?:\\[{}]|[^}])*))\}/.exec(s);){let a=o[1]?+o[1]:null,l=o[2]||o[3]||"",c=-1,u=l.replace(/\\[{}]/g,d=>d[1]);for(let d=0;d<t.length;d++)(a!=null?t[d].seq==a:u&&t[d].name==u)&&(c=d);if(c<0){let d=0;for(;d<t.length&&(a==null||t[d].seq!=null&&t[d].seq<a);)d++;t.splice(d,0,{seq:a,name:u}),c=d;for(let h of i)h.field>=c&&h.field++}i.push(new TH(c,r.length,o.index,o.index+u.length)),s=s.slice(0,o.index)+l+s.slice(o.index+o[0].length)}s=s.replace(/\\([{}])/g,(a,l,c)=>{for(let u of i)u.line==r.length&&u.from>c&&(u.from--,u.to--);return l}),r.push(s)}return new yx(r,i)}}let _H=_t.widget({widget:new class extends Io{toDOM(){let n=document.createElement("span");return n.className="cm-snippetFieldPosition",n}ignoreEvent(){return!1}}}),EH=_t.mark({class:"cm-snippetField"});class Hf{constructor(e,t){this.ranges=e,this.active=t,this.deco=_t.set(e.map(r=>(r.from==r.to?_H:EH).range(r.from,r.to)))}map(e){let t=[];for(let r of this.ranges){let i=r.map(e);if(!i)return null;t.push(i)}return new Hf(t,this.active)}selectionInsideField(e){return e.ranges.every(t=>this.ranges.some(r=>r.field==this.active&&r.from<=t.from&&r.to>=t.to))}}const gp=cn.define({map(n,e){return n&&n.map(e)}}),RH=cn.define(),Vh=Kr.define({create(){return null},update(n,e){for(let t of e.effects){if(t.is(gp))return t.value;if(t.is(RH)&&n)return new Hf(n.ranges,t.value)}return n&&e.docChanged&&(n=n.map(e.changes)),n&&e.selection&&!n.selectionInsideField(e.selection)&&(n=null),n},provide:n=>ft.decorations.from(n,e=>e?e.deco:_t.none)});function bx(n,e){return Ie.create(n.filter(t=>t.field==e).map(t=>Ie.range(t.from,t.to)))}function AH(n){let e=yx.parse(n);return(t,r,i,o)=>{let{text:s,ranges:a}=e.instantiate(t.state,i),{main:l}=t.state.selection,c={changes:{from:i,to:o==l.from?l.to:o,insert:Fn.of(s)},scrollIntoView:!0,annotations:r?[mx.of(r),Hr.userEvent.of("input.complete")]:void 0};if(a.length&&(c.selection=bx(a,0)),a.some(u=>u.field>0)){let u=new Hf(a,0),d=c.effects=[gp.of(u)];t.state.field(Vh,!1)===void 0&&d.push(cn.appendConfig.of([Vh,IH,jH,s3]))}t.dispatch(t.state.update(c))}}function a3(n){return({state:e,dispatch:t})=>{let r=e.field(Vh,!1);if(!r||n<0&&r.active==0)return!1;let i=r.active+n,o=n>0&&!r.ranges.some(s=>s.field==i+n);return t(e.update({selection:bx(r.ranges,i),effects:gp.of(o?null:new Hf(r.ranges,i)),scrollIntoView:!0})),!0}}const MH=({state:n,dispatch:e})=>n.field(Vh,!1)?(e(n.update({effects:gp.of(null)})),!0):!1,$H=a3(1),DH=a3(-1),QH=[{key:"Tab",run:$H,shift:DH},{key:"Escape",run:MH}],gM=Ct.define({combine(n){return n.length?n[0]:QH}}),IH=pa.highest(Xf.compute([gM],n=>n.facet(gM)));function ao(n,e){return Object.assign(Object.assign({},e),{apply:AH(n)})}const jH=ft.domEventHandlers({mousedown(n,e){let t=e.state.field(Vh,!1),r;if(!t||(r=e.posAtCoords({x:n.clientX,y:n.clientY}))==null)return!1;let i=t.ranges.find(o=>o.from<=r&&o.to>=r);return!i||i.field==t.active?!1:(e.dispatch({selection:bx(t.ranges,i.field),effects:gp.of(t.ranges.some(o=>o.field>i.field)?new Hf(t.ranges,i.field):null),scrollIntoView:!0}),!0)}}),Wh={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},Wc=cn.define({map(n,e){let t=e.mapPos(n,-1,ii.TrackAfter);return t??void 0}}),Sx=new class extends eu{};Sx.startSide=1;Sx.endSide=-1;const l3=Kr.define({create(){return zn.empty},update(n,e){if(n=n.map(e.changes),e.selection){let t=e.state.doc.lineAt(e.selection.main.head);n=n.update({filter:r=>r>=t.from&&r<=t.to})}for(let t of e.effects)t.is(Wc)&&(n=n.update({add:[Sx.range(t.value,t.value+1)]}));return n}});function LH(){return[qH,l3]}const oS="()[]{}<>«»»«[]{}";function c3(n){for(let e=0;e<oS.length;e+=2)if(oS.charCodeAt(e)==n)return oS.charAt(e+1);return $P(n<128?n:n+1)}function u3(n,e){return n.languageDataAt("closeBrackets",e)[0]||Wh}const NH=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),qH=ft.inputHandler.of((n,e,t,r)=>{if((NH?n.composing:n.compositionStarted)||n.state.readOnly)return!1;let i=n.state.selection.main;if(r.length>2||r.length==2&&ia(co(r,0))==1||e!=i.from||t!=i.to)return!1;let o=BH(n.state,r);return o?(n.dispatch(o),!0):!1}),UH=({state:n,dispatch:e})=>{if(n.readOnly)return!1;let r=u3(n,n.selection.main.head).brackets||Wh.brackets,i=null,o=n.changeByRange(s=>{if(s.empty){let a=FH(n.doc,s.head);for(let l of r)if(l==a&&fy(n.doc,s.head)==c3(co(l,0)))return{changes:{from:s.head-l.length,to:s.head+l.length},range:Ie.cursor(s.head-l.length)}}return{range:i=s}});return i||e(n.update(o,{scrollIntoView:!0,userEvent:"delete.backward"})),!i};function BH(n,e){let t=u3(n,n.selection.main.head),r=t.brackets||Wh.brackets;for(let i of r){let o=c3(co(i,0));if(e==i)return o==i?ZH(n,i,r.indexOf(i+i+i)>-1,t):VH(n,i,o,t.before||Wh.before);if(e==o&&f3(n,n.selection.main.from))return WH(n,i,o)}return null}function f3(n,e){let t=!1;return n.field(l3).between(0,n.doc.length,r=>{r==e&&(t=!0)}),t}function fy(n,e){let t=n.sliceString(e,e+2);return t.slice(0,ia(co(t,0)))}function FH(n,e){let t=n.sliceString(e-2,e);return ia(co(t,0))==t.length?t:t.slice(1)}function VH(n,e,t,r){let i=null,o=n.changeByRange(s=>{if(!s.empty)return{changes:[{insert:e,from:s.from},{insert:t,from:s.to}],effects:Wc.of(s.to+e.length),range:Ie.range(s.anchor+e.length,s.head+e.length)};let a=fy(n.doc,s.head);return!a||/\s/.test(a)||r.indexOf(a)>-1?{changes:{insert:e+t,from:s.head},effects:Wc.of(s.head+e.length),range:Ie.cursor(s.head+e.length)}:{range:i=s}});return i?null:n.update(o,{scrollIntoView:!0,userEvent:"input.type"})}function WH(n,e,t){let r=null,i=n.changeByRange(o=>o.empty&&fy(n.doc,o.head)==t?{changes:{from:o.head,to:o.head+t.length,insert:t},range:Ie.cursor(o.head+t.length)}:r={range:o});return r?null:n.update(i,{scrollIntoView:!0,userEvent:"input.type"})}function ZH(n,e,t,r){let i=r.stringPrefixes||Wh.stringPrefixes,o=null,s=n.changeByRange(a=>{if(!a.empty)return{changes:[{insert:e,from:a.from},{insert:e,from:a.to}],effects:Wc.of(a.to+e.length),range:Ie.range(a.anchor+e.length,a.head+e.length)};let l=a.head,c=fy(n.doc,l),u;if(c==e){if(OM(n,l))return{changes:{insert:e+e,from:l},effects:Wc.of(l+e.length),range:Ie.cursor(l+e.length)};if(f3(n,l)){let h=t&&n.sliceDoc(l,l+e.length*3)==e+e+e?e+e+e:e;return{changes:{from:l,to:l+h.length,insert:h},range:Ie.cursor(l+h.length)}}}else{if(t&&n.sliceDoc(l-2*e.length,l)==e+e&&(u=vM(n,l-2*e.length,i))>-1&&OM(n,u))return{changes:{insert:e+e+e+e,from:l},effects:Wc.of(l+e.length),range:Ie.cursor(l+e.length)};if(n.charCategorizer(l)(c)!=Tr.Word&&vM(n,l,i)>-1&&!XH(n,l,e,i))return{changes:{insert:e+e,from:l},effects:Wc.of(l+e.length),range:Ie.cursor(l+e.length)}}return{range:o=a}});return o?null:n.update(s,{scrollIntoView:!0,userEvent:"input.type"})}function OM(n,e){let t=br(n).resolveInner(e+1);return t.parent&&t.from==e}function XH(n,e,t,r){let i=br(n).resolveInner(e,-1),o=r.reduce((s,a)=>Math.max(s,a.length),0);for(let s=0;s<5;s++){let a=n.sliceDoc(i.from,Math.min(i.to,i.from+t.length+o)),l=a.indexOf(t);if(!l||l>-1&&r.indexOf(a.slice(0,l))>-1){let u=i.firstChild;for(;u&&u.from==i.from&&u.to-u.from>t.length+l;){if(n.sliceDoc(u.to-t.length,u.to)==t)return!1;u=u.firstChild}return!0}let c=i.to==e&&i.parent;if(!c)break;i=c}return!1}function vM(n,e,t){let r=n.charCategorizer(e);if(r(n.sliceDoc(e-1,e))!=Tr.Word)return e;for(let i of t){let o=e-i.length;if(n.sliceDoc(o,e)==i&&r(n.sliceDoc(o-1,o))!=Tr.Word)return o}return-1}function d3(n={}){return[CH,fo,Oi.of(n),PH,YH,s3]}const zH=[{key:"Ctrl-Space",run:Tk},{mac:"Alt-`",run:Tk},{key:"Escape",run:o3},{key:"ArrowDown",run:jl(!0)},{key:"ArrowUp",run:jl(!1)},{key:"PageDown",run:jl(!0,"page")},{key:"PageUp",run:jl(!1,"page")},{key:"Enter",run:Ck}],YH=pa.highest(Xf.computeN([Oi],n=>n.facet(Oi).defaultKeymap?[zH]:[]));class yM{constructor(e,t,r){this.from=e,this.to=t,this.diagnostic=r}}class qc{constructor(e,t,r){this.diagnostics=e,this.panel=t,this.selected=r}static init(e,t,r){let i=e,o=r.facet(Zh).markerFilter;o&&(i=o(i,r));let s=e.slice().sort((d,h)=>d.from-h.from||d.to-h.to),a=new Ua,l=[],c=0;for(let d=0;;){let h=d==s.length?null:s[d];if(!h&&!l.length)break;let p,g;for(l.length?(p=c,g=l.reduce((v,b)=>Math.min(v,b.to),h&&h.from>p?h.from:1e8)):(p=h.from,g=h.to,l.push(h),d++);d<s.length;){let v=s[d];if(v.from==p&&(v.to>v.from||v.to==p))l.push(v),d++,g=Math.min(v.to,g);else{g=Math.min(v.from,g);break}}let O=aK(l);if(l.some(v=>v.from==v.to||v.from==v.to-1&&r.doc.lineAt(v.from).to==v.from))a.add(p,p,_t.widget({widget:new rK(O),diagnostics:l.slice()}));else{let v=l.reduce((b,S)=>S.markClass?b+" "+S.markClass:b,"");a.add(p,g,_t.mark({class:"cm-lintRange cm-lintRange-"+O+v,diagnostics:l.slice(),inclusiveEnd:l.some(b=>b.to>g)}))}c=g;for(let v=0;v<l.length;v++)l[v].to<=c&&l.splice(v--,1)}let u=a.finish();return new qc(u,t,qf(u))}}function qf(n,e=null,t=0){let r=null;return n.between(t,1e9,(i,o,{spec:s})=>{if(!(e&&s.diagnostics.indexOf(e)<0))if(!r)r=new yM(i,o,e||s.diagnostics[0]);else{if(s.diagnostics.indexOf(r.diagnostic)<0)return!1;r=new yM(r.from,o,r.diagnostic)}}),r}function GH(n,e){let t=e.pos,r=e.end||t,i=n.state.facet(Zh).hideOn(n,t,r);if(i!=null)return i;let o=n.startState.doc.lineAt(e.pos);return!!(n.effects.some(s=>s.is(h3))||n.changes.touchesRange(o.from,Math.max(o.to,r)))}function HH(n,e){return n.field($o,!1)?e:e.concat(cn.appendConfig.of(lK))}const h3=cn.define(),wx=cn.define(),p3=cn.define(),$o=Kr.define({create(){return new qc(_t.none,null,null)},update(n,e){if(e.docChanged&&n.diagnostics.size){let t=n.diagnostics.map(e.changes),r=null,i=n.panel;if(n.selected){let o=e.changes.mapPos(n.selected.from,1);r=qf(t,n.selected.diagnostic,o)||qf(t,null,o)}!t.size&&i&&e.state.facet(Zh).autoPanel&&(i=null),n=new qc(t,i,r)}for(let t of e.effects)if(t.is(h3)){let r=e.state.facet(Zh).autoPanel?t.value.length?Xh.open:null:n.panel;n=qc.init(t.value,r,e.state)}else t.is(wx)?n=new qc(n.diagnostics,t.value?Xh.open:null,n.selected):t.is(p3)&&(n=new qc(n.diagnostics,n.panel,t.value));return n},provide:n=>[Lh.from(n,e=>e.panel),ft.decorations.from(n,e=>e.diagnostics)]}),KH=_t.mark({class:"cm-lintRange cm-lintRange-active"});function JH(n,e,t){let{diagnostics:r}=n.state.field($o),i,o=-1,s=-1;r.between(e-(t<0?1:0),e+(t>0?1:0),(l,c,{spec:u})=>{if(e>=l&&e<=c&&(l==c||(e>l||t>0)&&(e<c||t<0)))return i=u.diagnostics,o=l,s=c,!1});let a=n.state.facet(Zh).tooltipFilter;return i&&a&&(i=a(i,n.state)),i?{pos:o,end:s,above:n.state.doc.lineAt(o).to<s,create(){return{dom:eK(n,i)}}}:null}function eK(n,e){return fr("ul",{class:"cm-tooltip-lint"},e.map(t=>g3(n,t,!1)))}const tK=n=>{let e=n.state.field($o,!1);(!e||!e.panel)&&n.dispatch({effects:HH(n.state,[wx.of(!0)])});let t=jh(n,Xh.open);return t&&t.dom.querySelector(".cm-panel-lint ul").focus(),!0},bM=n=>{let e=n.state.field($o,!1);return!e||!e.panel?!1:(n.dispatch({effects:wx.of(!1)}),!0)},nK=n=>{let e=n.state.field($o,!1);if(!e)return!1;let t=n.state.selection.main,r=e.diagnostics.iter(t.to+1);return!r.value&&(r=e.diagnostics.iter(0),!r.value||r.from==t.from&&r.to==t.to)?!1:(n.dispatch({selection:{anchor:r.from,head:r.to},scrollIntoView:!0}),!0)},Zh=Ct.define({combine(n){return Object.assign({sources:n.map(e=>e.source).filter(e=>e!=null)},$s(n.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{needsRefresh:(e,t)=>e?t?r=>e(r)||t(r):e:t}))}});function m3(n){let e=[];if(n)e:for(let{name:t}of n){for(let r=0;r<t.length;r++){let i=t[r];if(/[a-zA-Z]/.test(i)&&!e.some(o=>o.toLowerCase()==i.toLowerCase())){e.push(i);continue e}}e.push("")}return e}function g3(n,e,t){var r;let i=t?m3(e.actions):[];return fr("li",{class:"cm-diagnostic cm-diagnostic-"+e.severity},fr("span",{class:"cm-diagnosticText"},e.renderMessage?e.renderMessage(n):e.message),(r=e.actions)===null||r===void 0?void 0:r.map((o,s)=>{let a=!1,l=h=>{if(h.preventDefault(),a)return;a=!0;let p=qf(n.state.field($o).diagnostics,e);p&&o.apply(n,p.from,p.to)},{name:c}=o,u=i[s]?c.indexOf(i[s]):-1,d=u<0?c:[c.slice(0,u),fr("u",c.slice(u,u+1)),c.slice(u+1)];return fr("button",{type:"button",class:"cm-diagnosticAction",onclick:l,onmousedown:l,"aria-label":` Action: ${c}${u<0?"":` (access key "${i[s]})"`}.`},d)}),e.source&&fr("div",{class:"cm-diagnosticSource"},e.source))}class rK extends Io{constructor(e){super(),this.sev=e}eq(e){return e.sev==this.sev}toDOM(){return fr("span",{class:"cm-lintPoint cm-lintPoint-"+this.sev})}}class SM{constructor(e,t){this.diagnostic=t,this.id="item_"+Math.floor(Math.random()*4294967295).toString(16),this.dom=g3(e,t,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}}class Xh{constructor(e){this.view=e,this.items=[];let t=i=>{if(i.keyCode==27)bM(this.view),this.view.focus();else if(i.keyCode==38||i.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(i.keyCode==40||i.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(i.keyCode==36)this.moveSelection(0);else if(i.keyCode==35)this.moveSelection(this.items.length-1);else if(i.keyCode==13)this.view.focus();else if(i.keyCode>=65&&i.keyCode<=90&&this.selectedIndex>=0){let{diagnostic:o}=this.items[this.selectedIndex],s=m3(o.actions);for(let a=0;a<s.length;a++)if(s[a].toUpperCase().charCodeAt(0)==i.keyCode){let l=qf(this.view.state.field($o).diagnostics,o);l&&o.actions[a].apply(e,l.from,l.to)}}else return;i.preventDefault()},r=i=>{for(let o=0;o<this.items.length;o++)this.items[o].dom.contains(i.target)&&this.moveSelection(o)};this.list=fr("ul",{tabIndex:0,role:"listbox","aria-label":this.view.state.phrase("Diagnostics"),onkeydown:t,onclick:r}),this.dom=fr("div",{class:"cm-panel-lint"},this.list,fr("button",{type:"button",name:"close","aria-label":this.view.state.phrase("close"),onclick:()=>bM(this.view)},"×")),this.update()}get selectedIndex(){let e=this.view.state.field($o).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($o),r=0,i=!1,o=null,s=new Set;for(e.between(0,this.view.state.doc.length,(a,l,{spec:c})=>{for(let u of c.diagnostics){if(s.has(u))continue;s.add(u);let d=-1,h;for(let p=r;p<this.items.length;p++)if(this.items[p].diagnostic==u){d=p;break}d<0?(h=new SM(this.view,u),this.items.splice(r,0,h),i=!0):(h=this.items[d],d>r&&(this.items.splice(r,d-r),i=!0)),t&&h.diagnostic==t.diagnostic?h.dom.hasAttribute("aria-selected")||(h.dom.setAttribute("aria-selected","true"),o=h):h.dom.hasAttribute("aria-selected")&&h.dom.removeAttribute("aria-selected"),r++}});r<this.items.length&&!(this.items.length==1&&this.items[0].diagnostic.from<0);)i=!0,this.items.pop();this.items.length==0&&(this.items.push(new SM(this.view,{from:-1,to:-1,severity:"info",message:this.view.state.phrase("No diagnostics")})),i=!0),o?(this.list.setAttribute("aria-activedescendant",o.id),this.view.requestMeasure({key:this,read:()=>({sel:o.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:a,panel:l})=>{let c=l.height/this.list.offsetHeight;a.top<l.top?this.list.scrollTop-=(l.top-a.top)/c:a.bottom>l.bottom&&(this.list.scrollTop+=(a.bottom-l.bottom)/c)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),i&&this.sync()}sync(){let e=this.list.firstChild;function t(){let r=e;e=r.nextSibling,r.remove()}for(let r of this.items)if(r.dom.parentNode==this.list){for(;e!=r.dom;)t();e=r.dom.nextSibling}else this.list.insertBefore(r.dom,e);for(;e;)t()}moveSelection(e){if(this.selectedIndex<0)return;let t=this.view.state.field($o),r=qf(t.diagnostics,this.items[e].diagnostic);r&&this.view.dispatch({selection:{anchor:r.from,head:r.to},scrollIntoView:!0,effects:p3.of(r)})}static open(e){return new Xh(e)}}function iK(n,e='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${e}>${encodeURIComponent(n)}</svg>')`}function Zm(n){return iK(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${n}" fill="none" stroke-width=".7"/>`,'width="6" height="3"')}const oK=ft.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:Zm("#d11")},".cm-lintRange-warning":{backgroundImage:Zm("orange")},".cm-lintRange-info":{backgroundImage:Zm("#999")},".cm-lintRange-hint":{backgroundImage:Zm("#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}}});function sK(n){return n=="error"?4:n=="warning"?3:n=="info"?2:1}function aK(n){let e="hint",t=1;for(let r of n){let i=sK(r.severity);i>t&&(t=i,e=r.severity)}return e}const lK=[$o,ft.decorations.compute([$o],n=>{let{selected:e,panel:t}=n.field($o);return!e||!t||e.from==e.to?_t.none:_t.set([KH.range(e.from,e.to)])}),iz(JH,{hideOn:GH}),oK],wM="500",cK={background:RA,foreground:w5,caret:UY,selection:LY,selectionMatch:NY,lineHighlight:qY,gutterBackground:RA,gutterForeground:IY,gutterActiveForeground:jY};function uK(n){const{theme:e="dark",settings:t={},styles:r=[]}={};return[as({theme:e,settings:{...cK,...t},styles:[{tag:[C.keyword,C.operatorKeyword,C.modifier,C.color,C.constant(C.name),C.standard(C.name),C.standard(C.tagName),C.special(C.brace),C.atom,C.bool,C.special(C.variableName)],color:AA},{tag:[C.controlKeyword,C.moduleKeyword],color:AA},{tag:[C.name,C.deleted,C.character,C.macroName,C.variableName,C.labelName,C.definition(C.name)],color:Nd},{tag:[C.propertyName],color:$A},{tag:C.heading,fontWeight:wM,color:BY},{tag:[C.typeName,C.className,C.tagName,C.number,C.changed,C.annotation,C.self,C.namespace],color:Nd},{tag:[C.function(C.variableName),C.function(C.propertyName)],color:Nd},{tag:[C.number],color:FY},{tag:[C.operator,C.punctuation,C.separator,C.url,C.escape,C.regexp],color:w5},{tag:[C.regexp],color:MA},{tag:[C.special(C.string),C.string,C.inserted],color:MA},{tag:[C.processingInstruction],color:Nd},{tag:[C.angleBracket],color:Nd},{tag:C.strong,fontWeight:wM},{tag:C.emphasis,fontStyle:"italic"},{tag:C.strikethrough,textDecoration:"line-through"},{tag:[C.meta,C.comment],color:QY},{tag:C.link,color:$A,textDecoration:"underline"},{tag:C.invalid,color:VY},...r]}),ft.theme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"transparent",outline:"1px solid #888888"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"transparent",outline:"1px solid #ff2222"}},{dark:!0})]}const fK=uK();function Gr(){return Gr=Object.assign?Object.assign.bind():function(n){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var r in t)({}).hasOwnProperty.call(t,r)&&(n[r]=t[r])}return n},Gr.apply(null,arguments)}var dK={background:"#272822",foreground:"#FFFFFF",caret:"#FFFFFF",selection:"#49483E",selectionMatch:"#49483E",gutterBackground:"#272822",gutterForeground:"#FFFFFF70",lineHighlight:"#0000003b"},hK=[{tag:[C.comment,C.documentMeta],color:"#8292a2"},{tag:[C.number,C.bool,C.null,C.atom],color:"#ae81ff"},{tag:[C.attributeValue,C.className,C.name],color:"#e6db74"},{tag:[C.propertyName,C.attributeName],color:"#a6e22e"},{tag:[C.variableName],color:"#9effff"},{tag:[C.squareBracket],color:"#bababa"},{tag:[C.string,C.special(C.brace)],color:"#e6db74"},{tag:[C.regexp,C.className,C.typeName,C.definition(C.typeName)],color:"#66d9ef"},{tag:[C.definition(C.variableName),C.definition(C.propertyName),C.function(C.variableName)],color:"#fd971f"},{tag:[C.keyword,C.definitionKeyword,C.modifier,C.tagName,C.angleBracket],color:"#f92672"}],pK=n=>{var{theme:e="dark",settings:t={},styles:r=[]}={};return as({theme:e,settings:Gr({},dK,t),styles:[...hK,...r]})},mK=pK(),gK={background:"#0f0f0f",foreground:"#defdef",caret:"#00FF00",selection:"#515151",selectionMatch:"#515151",gutterBackground:"#555",gutterForeground:"#FFFFFF",lineHighlight:"#0a6bcb3d"},OK=[{tag:C.keyword,color:"darkgoldenrod",fontWeight:"bold"},{tag:C.atom,color:"#77F"},{tag:C.comment,color:"#7a7b7c",fontStyle:"italic"},{tag:C.number,color:"violet"},{tag:C.definition(C.variableName),color:"#fffabc"},{tag:C.variableName,color:"#abcdef"},{tag:C.function(C.variableName),color:"#fffabc"},{tag:C.typeName,color:"#FFDD44"},{tag:C.tagName,color:"#def"},{tag:C.string,color:"#2b4"},{tag:C.meta,color:"#C9F"},{tag:C.bracket,color:"#8a8a8a"},{tag:C.attributeName,color:"#DDFF00"},{tag:C.heading,color:"aquamarine",fontWeight:"bold"},{tag:C.link,color:"blueviolet",fontWeight:"bold"}],vK=n=>{var{theme:e="dark",settings:t={},styles:r=[]}={};return as({theme:e,settings:Gr({},gK,t),styles:[...OK,...r]})},yK=vK(),bK={background:"#282a36",foreground:"#f8f8f2",caret:"#f8f8f0",selection:"rgba(255, 255, 255, 0.1)",selectionMatch:"rgba(255, 255, 255, 0.2)",gutterBackground:"#282a36",gutterForeground:"#6D8A88",gutterBorder:"transparent",lineHighlight:"rgba(255, 255, 255, 0.1)"},SK=[{tag:C.comment,color:"#6272a4"},{tag:C.string,color:"#f1fa8c"},{tag:C.atom,color:"#bd93f9"},{tag:C.meta,color:"#f8f8f2"},{tag:[C.keyword,C.operator,C.tagName],color:"#ff79c6"},{tag:[C.function(C.propertyName),C.propertyName],color:"#66d9ef"},{tag:[C.definition(C.variableName),C.function(C.variableName),C.className,C.attributeName],color:"#50fa7b"},{tag:C.atom,color:"#bd93f9"}],wK=n=>{var{theme:e="dark",settings:t={},styles:r=[]}={};return as({theme:e,settings:Gr({},bK,t),styles:[...SK,...r]})},kK=wK(),PK={background:"#fff",foreground:"#000",caret:"#FFFFFF",selection:"#d7d4f0",selectionMatch:"#d7d4f0",gutterBackground:"#f7f7f7",gutterForeground:"#999",lineHighlight:"#006fff1c",gutterBorder:"transparent"},xK=[{tag:[C.comment],color:"#3F7F5F"},{tag:[C.documentMeta],color:"#FF1717"},{tag:C.keyword,color:"#7F0055",fontWeight:"bold"},{tag:C.atom,color:"#00f"},{tag:C.number,color:"#164"},{tag:C.propertyName,color:"#164"},{tag:[C.variableName,C.definition(C.variableName)],color:"#0000C0"},{tag:C.function(C.variableName),color:"#0000C0"},{tag:C.string,color:"#2A00FF"},{tag:C.operator,color:"black"},{tag:C.tagName,color:"#170"},{tag:C.attributeName,color:"#00c"},{tag:C.link,color:"#219"}],CK=n=>{var{theme:e="light",settings:t={},styles:r=[]}={};return as({theme:e,settings:Gr({},PK,t),styles:[...xK,...r]})},TK=CK(),_K={background:"#fff",foreground:"#24292e",selection:"#BBDFFF",selectionMatch:"#BBDFFF",gutterBackground:"#fff",gutterForeground:"#6e7781"},EK=[{tag:[C.standard(C.tagName),C.tagName],color:"#116329"},{tag:[C.comment,C.bracket],color:"#6a737d"},{tag:[C.className,C.propertyName],color:"#6f42c1"},{tag:[C.variableName,C.attributeName,C.number,C.operator],color:"#005cc5"},{tag:[C.keyword,C.typeName,C.typeOperator,C.typeName],color:"#d73a49"},{tag:[C.string,C.meta,C.regexp],color:"#032f62"},{tag:[C.name,C.quote],color:"#22863a"},{tag:[C.heading,C.strong],color:"#24292e",fontWeight:"bold"},{tag:[C.emphasis],color:"#24292e",fontStyle:"italic"},{tag:[C.deleted],color:"#b31d28",backgroundColor:"ffeef0"},{tag:[C.atom,C.bool,C.special(C.variableName)],color:"#e36209"},{tag:[C.url,C.escape,C.regexp,C.link],color:"#032f62"},{tag:C.link,textDecoration:"underline"},{tag:C.strikethrough,textDecoration:"line-through"},{tag:C.invalid,color:"#cb2431"}],RK=n=>{var{theme:e="light",settings:t={},styles:r=[]}={};return as({theme:e,settings:Gr({},_K,t),styles:[...EK,...r]})};RK();var AK={background:"#0d1117",foreground:"#c9d1d9",caret:"#c9d1d9",selection:"#003d73",selectionMatch:"#003d73",lineHighlight:"#36334280"},MK=[{tag:[C.standard(C.tagName),C.tagName],color:"#7ee787"},{tag:[C.comment,C.bracket],color:"#8b949e"},{tag:[C.className,C.propertyName],color:"#d2a8ff"},{tag:[C.variableName,C.attributeName,C.number,C.operator],color:"#79c0ff"},{tag:[C.keyword,C.typeName,C.typeOperator,C.typeName],color:"#ff7b72"},{tag:[C.string,C.meta,C.regexp],color:"#a5d6ff"},{tag:[C.name,C.quote],color:"#7ee787"},{tag:[C.heading,C.strong],color:"#d2a8ff",fontWeight:"bold"},{tag:[C.emphasis],color:"#d2a8ff",fontStyle:"italic"},{tag:[C.deleted],color:"#ffdcd7",backgroundColor:"ffeef0"},{tag:[C.atom,C.bool,C.special(C.variableName)],color:"#ffab70"},{tag:C.link,textDecoration:"underline"},{tag:C.strikethrough,textDecoration:"line-through"},{tag:C.invalid,color:"#f97583"}],$K=n=>{var{theme:e="dark",settings:t={},styles:r=[]}={};return as({theme:e,settings:Gr({},AK,t),styles:[...MK,...r]})},DK=$K(),QK={background:"#2e3235",foreground:"#bdbdbd",caret:"#a0a4ae",selection:"#d7d4f063",selectionMatch:"#d7d4f063",gutterBackground:"#2e3235",gutterForeground:"#999",gutterActiveForeground:"#4f5b66",lineHighlight:"#545b6130"},IK=[{tag:C.keyword,color:"#cf6edf"},{tag:[C.name,C.deleted,C.character,C.macroName],color:"#56c8d8"},{tag:[C.propertyName],color:"#facf4e"},{tag:[C.variableName],color:"#bdbdbd"},{tag:[C.function(C.variableName)],color:"#56c8d8"},{tag:[C.labelName],color:"#cf6edf"},{tag:[C.color,C.constant(C.name),C.standard(C.name)],color:"#facf4e"},{tag:[C.definition(C.name),C.separator],color:"#fa5788"},{tag:[C.brace],color:"#cf6edf"},{tag:[C.annotation],color:"#ff5f52"},{tag:[C.number,C.changed,C.annotation,C.modifier,C.self,C.namespace],color:"#ffad42"},{tag:[C.typeName,C.className],color:"#ffad42"},{tag:[C.operator,C.operatorKeyword],color:"#7186f0"},{tag:[C.tagName],color:"#99d066"},{tag:[C.squareBracket],color:"#ff5f52"},{tag:[C.angleBracket],color:"#606f7a"},{tag:[C.attributeName],color:"#bdbdbd"},{tag:[C.regexp],color:"#ff5f52"},{tag:[C.quote],color:"#6abf69"},{tag:[C.string],color:"#99d066"},{tag:C.link,color:"#56c8d8",textDecoration:"underline",textUnderlinePosition:"under"},{tag:[C.url,C.escape,C.special(C.string)],color:"#facf4e"},{tag:[C.meta],color:"#707d8b"},{tag:[C.comment],color:"#707d8b",fontStyle:"italic"},{tag:C.monospace,color:"#bdbdbd"},{tag:C.strong,fontWeight:"bold",color:"#ff5f52"},{tag:C.emphasis,fontStyle:"italic",color:"#99d066"},{tag:C.strikethrough,textDecoration:"line-through"},{tag:C.heading,fontWeight:"bold",color:"#facf4e"},{tag:C.heading1,fontWeight:"bold",color:"#facf4e"},{tag:[C.heading2,C.heading3,C.heading4],fontWeight:"bold",color:"#facf4e"},{tag:[C.heading5,C.heading6],color:"#facf4e"},{tag:[C.atom,C.bool,C.special(C.variableName)],color:"#56c8d8"},{tag:[C.processingInstruction,C.inserted],color:"#ff5f52"},{tag:[C.contentSeparator],color:"#56c8d8"},{tag:C.invalid,color:"#606f7a",borderBottom:"1px dotted #ff5f52"}],O3=n=>{var{theme:e="dark",settings:t={},styles:r=[]}=n||{};return as({theme:e,settings:Gr({},QK,t),styles:[...IK,...r]})};O3();var jK=O3(),LK={background:"#FAFAFA",foreground:"#90A4AE",caret:"#272727",selection:"#80CBC440",selectionMatch:"#80CBC440",gutterBackground:"#FAFAFA",gutterForeground:"#90A4AE",gutterBorder:"transparent",lineHighlight:"#CCD7DA50"},NK=[{tag:C.keyword,color:"#39ADB5"},{tag:[C.name,C.deleted,C.character,C.macroName],color:"#90A4AE"},{tag:[C.propertyName],color:"#6182B8"},{tag:[C.processingInstruction,C.string,C.inserted,C.special(C.string)],color:"#91B859"},{tag:[C.function(C.variableName),C.labelName],color:"#6182B8"},{tag:[C.color,C.constant(C.name),C.standard(C.name)],color:"#39ADB5"},{tag:[C.definition(C.name),C.separator],color:"#90A4AE"},{tag:[C.className],color:"#E2931D"},{tag:[C.number,C.changed,C.annotation,C.modifier,C.self,C.namespace],color:"#F76D47"},{tag:[C.typeName],color:"#E2931D",fontStyle:"#E2931D"},{tag:[C.operator,C.operatorKeyword],color:"#39ADB5"},{tag:[C.url,C.escape,C.regexp,C.link],color:"#91B859"},{tag:[C.meta,C.comment],color:"#90A4AE"},{tag:C.strong,fontWeight:"bold"},{tag:C.emphasis,fontStyle:"italic"},{tag:C.link,textDecoration:"underline"},{tag:C.heading,fontWeight:"bold",color:"#39ADB5"},{tag:[C.atom,C.bool,C.special(C.variableName)],color:"#90A4AE"},{tag:C.invalid,color:"#E5393570"},{tag:C.strikethrough,textDecoration:"line-through"}],qK=n=>{var{theme:e="light",settings:t={},styles:r=[]}={};return as({theme:e,settings:Gr({},LK,t),styles:[...NK,...r]})};qK();var UK={background:"#2e3440",foreground:"#FFFFFF",caret:"#FFFFFF",selection:"#00000073",selectionMatch:"#00000073",gutterBackground:"#2e3440",gutterForeground:"#4c566a",gutterActiveForeground:"#d8dee9",lineHighlight:"#4c566a29"},BK=[{tag:C.keyword,color:"#5e81ac"},{tag:[C.name,C.deleted,C.character,C.propertyName,C.macroName],color:"#88c0d0"},{tag:[C.variableName],color:"#8fbcbb"},{tag:[C.function(C.variableName)],color:"#8fbcbb"},{tag:[C.labelName],color:"#81a1c1"},{tag:[C.color,C.constant(C.name),C.standard(C.name)],color:"#5e81ac"},{tag:[C.definition(C.name),C.separator],color:"#a3be8c"},{tag:[C.brace],color:"#8fbcbb"},{tag:[C.annotation],color:"#d30102"},{tag:[C.number,C.changed,C.annotation,C.modifier,C.self,C.namespace],color:"#b48ead"},{tag:[C.typeName,C.className],color:"#ebcb8b"},{tag:[C.operator,C.operatorKeyword],color:"#a3be8c"},{tag:[C.tagName],color:"#b48ead"},{tag:[C.squareBracket],color:"#bf616a"},{tag:[C.angleBracket],color:"#d08770"},{tag:[C.attributeName],color:"#ebcb8b"},{tag:[C.regexp],color:"#5e81ac"},{tag:[C.quote],color:"#b48ead"},{tag:[C.string],color:"#a3be8c"},{tag:C.link,color:"#a3be8c",textDecoration:"underline",textUnderlinePosition:"under"},{tag:[C.url,C.escape,C.special(C.string)],color:"#8fbcbb"},{tag:[C.meta],color:"#88c0d0"},{tag:[C.monospace],color:"#d8dee9",fontStyle:"italic"},{tag:[C.comment],color:"#4c566a",fontStyle:"italic"},{tag:C.strong,fontWeight:"bold",color:"#5e81ac"},{tag:C.emphasis,fontStyle:"italic",color:"#5e81ac"},{tag:C.strikethrough,textDecoration:"line-through"},{tag:C.heading,fontWeight:"bold",color:"#5e81ac"},{tag:C.special(C.heading1),fontWeight:"bold",color:"#5e81ac"},{tag:C.heading1,fontWeight:"bold",color:"#5e81ac"},{tag:[C.heading2,C.heading3,C.heading4],fontWeight:"bold",color:"#5e81ac"},{tag:[C.heading5,C.heading6],color:"#5e81ac"},{tag:[C.atom,C.bool,C.special(C.variableName)],color:"#d08770"},{tag:[C.processingInstruction,C.inserted],color:"#8fbcbb"},{tag:[C.contentSeparator],color:"#ebcb8b"},{tag:C.invalid,color:"#434c5e",borderBottom:"1px dotted #d30102"}],FK=n=>{var{theme:e="dark",settings:t={},styles:r=[]}={};return as({theme:e,settings:Gr({},UK,t),styles:[...BK,...r]})},VK=FK(),WK={background:"#fff",foreground:"#3D3D3D",selection:"#BBDFFF",selectionMatch:"#BBDFFF",gutterBackground:"#fff",gutterForeground:"#AFAFAF",lineHighlight:"#d5e6ff69"},ZK=[{tag:[C.comment,C.quote],color:"#707F8D"},{tag:[C.typeName,C.typeOperator],color:"#aa0d91"},{tag:[C.keyword],color:"#aa0d91",fontWeight:"bold"},{tag:[C.string,C.meta],color:"#D23423"},{tag:[C.name],color:"#032f62"},{tag:[C.typeName],color:"#522BB2"},{tag:[C.variableName],color:"#23575C"},{tag:[C.definition(C.variableName)],color:"#327A9E"},{tag:[C.regexp,C.link],color:"#0e0eff"}];function XK(n){var{theme:e="light",settings:t={},styles:r=[]}={};return as({theme:e,settings:Gr({},WK,t),styles:[...ZK,...r]})}var zK=XK(),YK={background:"#292A30",foreground:"#CECFD0",caret:"#fff",selection:"#727377",selectionMatch:"#727377",lineHighlight:"#ffffff0f"},GK=[{tag:[C.comment,C.quote],color:"#7F8C98"},{tag:[C.keyword],color:"#FF7AB2",fontWeight:"bold"},{tag:[C.string,C.meta],color:"#FF8170"},{tag:[C.typeName],color:"#DABAFF"},{tag:[C.definition(C.variableName)],color:"#6BDFFF"},{tag:[C.name],color:"#6BAA9F"},{tag:[C.variableName],color:"#ACF2E4"},{tag:[C.regexp,C.link],color:"#FF8170"}],HK=n=>{var{theme:e="dark",settings:t={},styles:r=[]}={};return as({theme:e,settings:Gr({},YK,t),styles:[...GK,...r]})};HK();const _k=[{value:yK,label:"abcdef"},{value:kK,label:"dracula"},{value:TK,label:"eclipse"},{value:jK,label:"material"},{value:VK,label:"nord"},{value:DY,label:"oneDark"},{value:mK,label:"okaidia"},{value:DK,label:"github"},{value:zK,label:"xcode"},{value:fK,label:"vizhub"}],v3=_k.reduce((n,e)=>(n[e.label]=e,n),{}),KK="vizhub",JK=(n,e)=>{const t=D.useRef(!0);D.useEffect(()=>{if(t.current)t.current=!1;else for(const r of Array.from(n.values())){const{editor:i,themeCompartment:o}=r;i.dispatch({effects:o.reconfigure([v3[e].value])})}},[e,n])},eJ=n=>{const e=D.useCallback(M=>{n({type:"set_active_file_id",activeFileId:M})},[n]),t=D.useCallback(()=>{n({type:"set_active_file_left"})},[n]),r=D.useCallback(()=>{n({type:"set_active_file_right"})},[n]),i=D.useCallback(M=>{n({type:"open_tab",fileId:M.fileId,isTransient:M.isTransient})},[n]),o=D.useCallback(M=>{n({type:"close_tabs",fileIdsToClose:M})},[n]),s=D.useCallback(M=>{n({type:"set_theme",themeLabel:M})},[n]),a=D.useCallback(M=>{n({type:"set_is_search_open",value:M})},[n]),l=D.useCallback(M=>{n({type:"set_search",value:M})},[n]),c=D.useCallback(M=>{n({type:"set_search_results",files:M})},[n]),u=D.useCallback((M,Q,T)=>{n({type:"set_search_file_visibility",files:M,id:Q,visibility:T})},[n]),d=D.useCallback((M,Q,T)=>{n({type:"hide_search_results_line",files:M,id:Q,line:T})},[n]),h=D.useCallback((M,Q)=>{n({type:"set_active_search_index",focusedIndex:M,childIndex:Q})},[n]),p=D.useCallback(()=>{n({type:"toggle_search_focused"})},[n]),g=D.useCallback(M=>{n({type:"set_is_settings_open",value:M})},[n]),O=D.useCallback(M=>{n({type:"set_is_doc_open",value:M})},[n]),v=D.useCallback(()=>{g(!1)},[g]),b=D.useCallback(()=>{O(!1)},[O]),S=D.useCallback(()=>{n({type:"editor_no_longer_wants_focus"})},[n]),x=D.useCallback(M=>{n({type:"set_username",username:M})},[n]),P=D.useCallback(()=>{n({type:"toggle_auto_follow"})},[n]),w=D.useCallback(M=>{n({type:"update_presence_indicator",presenceIndicator:M})},[n]),E=D.useCallback(()=>{n({type:"split_current_pane"})},[n]);return{setActiveFileId:e,setActiveFileLeft:t,setActiveFileRight:r,openTab:i,closeTabs:o,setTheme:s,setIsSearchOpen:a,setSearch:l,setSearchResults:c,setSearchFileVisibility:u,setSearchLineVisibility:d,setSearchFocusedIndex:h,toggleSearchFocused:p,setIsSettingsOpen:g,setIsDocOpen:O,closeSettings:v,closeDoc:b,editorNoLongerWantsFocus:S,setUsername:x,toggleAutoFollow:P,updatePresenceIndicator:w,splitCurrentPane:E}},zh=(n,e)=>n+"|"+e,tJ=()=>D.useRef(new Map).current,nJ=8,Ek=()=>{let n="";for(let e=0;e<nJ;e++)n+=Math.floor(Math.random()*10);return n},rJ=({submitOperation:n,closeTabs:e,openTab:t})=>{const r=D.useCallback((c,u="")=>{if(c){const d=Ek();n(h=>({...h,files:{...h.files,[d]:{name:c,text:u}}})),t({fileId:d,isTransient:!1})}},[n]),i=D.useCallback((c,u=null)=>{if(c){c+="/";const d=Ek();n(h=>({...h,files:{...h.files,[d]:{name:c,text:u}}}))}},[n]),o=D.useCallback((c,u)=>{n(d=>({...d,files:{...d.files,[c]:{...d.files[c],name:d.files[c].name.substring(0,d.files[c].name.lastIndexOf("/")+1)+u}}}))},[n]),s=D.useCallback((c,u,d)=>{console.log(c),console.log(u),n(h=>{const p=Object.keys(h.files).reduce((g,O)=>{const v=h.files[O],b=v.name;if(b.includes(c+"/")){const x=b.substring(0,b.indexOf(c)+c.length).lastIndexOf(u),P=b.substring(0,x)+d+b.substring(x+u.length);g[O]={...v,name:P}}else g[O]=v;return g},{});return{...h,files:p}})},[n]),a=D.useCallback(c=>{e([c]),n(u=>{const d={...u.files};return delete d[c],{...u,files:d}})},[n,e]),l=D.useCallback(c=>{const u=[];n(d=>{const h={...d.files};for(const p in h)h[p].name.includes(c+"/")&&(u.push(p),delete h[p]);return{...d,files:h}}),e(u)},[n,e]);return{createFile:r,renameFile:o,deleteFile:a,createDirectory:i,renameDirectory:s,deleteDirectory:l}},iJ=n=>{const t=/Mac|iMac|MacBook/i.test(navigator.userAgent)?n.metaKey:n.ctrlKey;return t&&n.key==="s"?!0:!!(n.key==="F5"||t&&n.key==="Enter"||n.shiftKey&&n.key==="Enter"||n.altKey&&n.key==="Enter"||t&&n.shiftKey&&(n.key==="B"||n.key==="b")||t&&n.shiftKey&&n.key==="F10"||n.key==="F8"||n.key==="F9")};let Ss=null,Xm=null;const y3=new Set(["FunctionDeclaration","ClassDeclaration","MethodDeclaration","Block","IfStatement","ForStatement","WhileStatement","SwitchStatement","TryStatement","CatchClause","WithStatement","ArrowFunction","ImportGroup"]),oJ=new Set(["VariableDeclaration","FunctionDeclaration","ClassDeclaration","MethodDeclaration","PropertyDeclaration","ImportDeclaration","ExportDeclaration","CallExpression","ArrayPattern","ObjectPattern","PatternProperty","ArgList","TypeArgList","ParamList","ForOfSpec"]);function kM(n){let e=n,t=0;for(;e&&e.type;){const r=e.type.name;y3.has(r)&&t++,e=e.parent}return t}function sJ(n,e){const t=n.state,r=[],i=e,o=t.doc.sliceString(i.from,i.to),s=kM(i);if(i){if(br(t).iterate({enter(a){if(oJ.has(a.name)||y3.has(a.name)){const l=a.node;[...l.getChildren("VariableDefinition"),...l.getChildren("PropertyDefinition"),...l.getChildren("PropertyName"),...l.getChildren("Identifier")].forEach(u=>{t.doc.sliceString(u.from,u.to)===o&&u.type.id!==i.type.id&&r.push({identifier:u,context:kM(u)})})}}}),r.length>0){r.sort((l,c)=>l.context-c.context);let a=r[0].identifier;for(let l=r.length-1;l>=0;l--)if(r[l].context<=s){a=r[l].identifier;break}return a}return null}}const PM={E:"files-icon",F:"search-icon",K:"shortcut-icon",B:"bug-icon",S:"settings-icon",N:"new-file-icon",D:"new-directory-icon",A:"auto-focus-icon"},aJ=({closeTabs:n,activeFileId:e,activePaneId:t,handleOpenCreateFileModal:r,setActiveFileLeft:i,setActiveFileRight:o,toggleSearchFocused:s,runPrettierRef:a,runCodeRef:l,sidebarRef:c,editorCache:u,codeEditorRef:d})=>{D.useEffect(()=>{const h=zh(e,t),p=S=>{var x,P;if(iJ(S)){S.preventDefault();const w=a.current;w!==null&&w();const E=l.current;E!==null&&E();return}if(S.ctrlKey&&S.shiftKey?((x=document.getElementById(PM[S.key]))==null||x.click(),S.key==="F"&&s()):S.ctrlKey&&S.key===","&&((P=document.getElementById(PM.S))==null||P.click()),S.ctrlKey===!0&&document.addEventListener("mouseover",b),S.altKey===!0){if(S.key==="w"){e&&n([e]);return}if(S.key==="n"){r();return}if(S.key==="PageUp"){i();return}if(S.key==="PageDown"){o();return}S.key==="1"&&c.current&&c.current.focus(),S.key==="2"&&d.current&&d.current.focus()}},g=()=>{Ss&&(Ss.style.cursor="initial",Ss.style.textDecoration="none",Ss=Xm=null),document.removeEventListener("mouseover",b),document.removeEventListener("mousedown",O)},O=S=>{if(!Xm||S.target!==Ss||!e)return;const x=u.get(h).editor,P=Xm;x.dispatch({selection:{anchor:P.from,head:P.to},scrollIntoView:!0,effects:ft.scrollIntoView(P.from,{y:"center"})}),g()},v=S=>{S.ctrlKey||g()},b=S=>{if(!e)return;const x=u.get(h).editor,P=br(x.state),w=S.target;if(w==null||!x.dom.contains(w))return;const E=x.posAtDOM(w),M=P.resolveInner(E,1);if(M&&w instanceof HTMLSpanElement){const Q=sJ(x,M);Q&&M.type.id!==Q.type.id&&(Ss&&(Ss.style.cursor="initial",Ss.style.textDecoration="none"),Ss=w,Xm=Q,Ss.style.cursor="pointer",Ss.style.textDecoration="underline",document.addEventListener("mousedown",O,{once:!0}))}};return document.addEventListener("keydown",p),document.addEventListener("keyup",v),()=>{document.removeEventListener("keydown",p),document.removeEventListener("keyup",v)}},[r,n,e,i,o])},lJ=()=>{const[n,e]=D.useState(new Set),t=D.useCallback(i=>n.has(i),[n]),r=D.useCallback(i=>{const o=new Set(n);t(i)?o.delete(i):o.add(i),e(o)},[n,t]);return{isDirectoryOpen:t,toggleDirectory:r}},cJ=1200,uJ=n=>{const e=n.match(/\.([^.]+)$/);return e?e[1]:""},fJ=({shareDBDoc:n,submitOperation:e,prettierWorker:t})=>{const r=D.useRef(new Set),[i,o]=D.useState(null),s=D.useRef(!1),a=D.useRef(null);return D.useEffect(()=>{if(!n)return;const l=d=>{const{fileId:h,error:p,fileTextPrettified:g}=d.data;if(p){o(p);return}else o(null);s.current=!0,e(O=>({...O,files:{...O.files,[h]:{...O.files[h],text:g}}})),s.current=!1};t.addEventListener("message",l);const c=async()=>{const h=n.data.files,p=r.current,g=Array.from(p);p.clear();for(const O of g){const v=h[O],b={fileText:v.text,fileExtension:uJ(v.name),fileId:O};t.postMessage(b)}};a.current=c;const u=d=>{if(!s.current&&d&&d.length===4&&d[0]==="files"&&typeof d[1]=="string"&&d[2]==="text"){const h=d[1];r.current.add(h)}};return n.on("op batch",u),()=>{t.removeEventListener("message",l),n.removeListener("op batch",u)}},[n]),{prettierError:i,runPrettierRef:a}},dJ=n=>{const e=D.useRef(null);return D.useEffect(()=>{const t=()=>{n(r=>({...r,isInteracting:!0})),setTimeout(()=>{n(({isInteracting:r,...i})=>i)},0)};e.current=t},[n]),e},hJ=500,pJ=cJ+hJ,mJ=({content:n,typeScriptWorker:e})=>{const t=D.useRef(null),r=D.useCallback(i=>{i!==null&&(clearTimeout(t.current),t.current=window.setTimeout(()=>{e.postMessage({event:"update-content",details:i})},pJ))},[e]);D.useEffect(()=>{r(n)},[n])};var b3=-1,S3=-2,w3=-3,k3=-4,kx=-5,P3=-6,x3=-7,C3="B",T3="D",kf="E",Rk="M",_3="N",Pf="P",E3="R",Ak="S",R3="Y",A3="U",Mk="Z",M3=class{constructor(){hi(this,"promise");hi(this,"resolve");hi(this,"reject");this.promise=new Promise((e,t)=>{this.resolve=e,this.reject=t})}};function gJ(){const n=new TextDecoder;let e="";return new TransformStream({transform(t,r){const i=n.decode(t,{stream:!0}),o=(e+i).split(`
|
|
128
|
-
`);e=o.pop()||"";for(const s of o)r.enqueue(s)},flush(t){e&&t.enqueue(e)}})}function Zo(n){const{indices:e}=this,t=e.get(n);if(t)return[t];if(n===void 0)return
|
|
127
|
+
`:r=="r"?"\r":r=="t"?" ":"\\")}eq(e){return this.search==e.search&&this.replace==e.replace&&this.caseSensitive==e.caseSensitive&&this.regexp==e.regexp&&this.wholeWord==e.wholeWord}create(){return this.regexp?new YG(this):new XG(this)}getCursor(e,t=0,r){let i=e.doc?e:Un.create({doc:e});return r==null&&(r=i.doc.length),this.regexp?tf(this,i,t,r):ef(this,i,t,r)}}class z5{constructor(e){this.spec=e}}function ef(n,e,t,r){return new Nf(e.doc,n.unquoted,t,r,n.caseSensitive?void 0:i=>i.toLowerCase(),n.wholeWord?ZG(e.doc,e.charCategorizer(e.selection.main.head)):void 0)}function ZG(n,e){return(t,r,i,o)=>((o>t||o+i.length<r)&&(o=Math.max(0,t-2),i=n.sliceString(o,Math.min(n.length,r+2))),(e(bv(i,t-o))!=Tr.Word||e(Sv(i,t-o))!=Tr.Word)&&(e(Sv(i,r-o))!=Tr.Word||e(bv(i,r-o))!=Tr.Word))}class XG extends z5{constructor(e){super(e)}nextMatch(e,t,r){let i=ef(this.spec,e,r,e.doc.length).nextOverlapping();if(i.done){let o=Math.min(e.doc.length,t+this.spec.unquoted.length);i=ef(this.spec,e,0,o).nextOverlapping()}return i.done||i.value.from==t&&i.value.to==r?null:i.value}prevMatchInRange(e,t,r){for(let i=r;;){let o=Math.max(t,i-1e4-this.spec.unquoted.length),s=ef(this.spec,e,o,i),a=null;for(;!s.nextOverlapping().done;)a=s.value;if(a)return a;if(o==t)return null;i-=1e4}}prevMatch(e,t,r){let i=this.prevMatchInRange(e,0,t);return i||(i=this.prevMatchInRange(e,Math.max(0,r-this.spec.unquoted.length),e.doc.length)),i&&(i.from!=t||i.to!=r)?i:null}getReplacement(e){return this.spec.unquote(this.spec.replace)}matchAll(e,t){let r=ef(this.spec,e,0,e.doc.length),i=[];for(;!r.next().done;){if(i.length>=t)return null;i.push(r.value)}return i}highlight(e,t,r,i){let o=ef(this.spec,e,Math.max(0,t-this.spec.unquoted.length),Math.min(r+this.spec.unquoted.length,e.doc.length));for(;!o.next().done;)i(o.value.from,o.value.to)}}function tf(n,e,t,r){return new W5(e.doc,n.search,{ignoreCase:!n.caseSensitive,test:n.wholeWord?zG(e.charCategorizer(e.selection.main.head)):void 0},t,r)}function bv(n,e){return n.slice(Ci(n,e,!1),e)}function Sv(n,e){return n.slice(e,Ci(n,e))}function zG(n){return(e,t,r)=>!r[0].length||(n(bv(r.input,r.index))!=Tr.Word||n(Sv(r.input,r.index))!=Tr.Word)&&(n(Sv(r.input,r.index+r[0].length))!=Tr.Word||n(bv(r.input,r.index+r[0].length))!=Tr.Word)}class YG extends z5{nextMatch(e,t,r){let i=tf(this.spec,e,r,e.doc.length).next();return i.done&&(i=tf(this.spec,e,0,t).next()),i.done?null:i.value}prevMatchInRange(e,t,r){for(let i=1;;i++){let o=Math.max(t,r-i*1e4),s=tf(this.spec,e,o,r),a=null;for(;!s.next().done;)a=s.value;if(a&&(o==t||a.from>o+10))return a;if(o==t)return null}}prevMatch(e,t,r){return this.prevMatchInRange(e,0,t)||this.prevMatchInRange(e,r,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,(t,r)=>{if(r=="&")return e.match[0];if(r=="$")return"$";for(let i=r.length;i>0;i--){let o=+r.slice(0,i);if(o>0&&o<e.match.length)return e.match[o]+r.slice(i)}return t})}matchAll(e,t){let r=tf(this.spec,e,0,e.doc.length),i=[];for(;!r.next().done;){if(i.length>=t)return null;i.push(r.value)}return i}highlight(e,t,r,i){let o=tf(this.spec,e,Math.max(0,t-250),Math.min(r+250,e.doc.length));for(;!o.next().done;)i(o.value.from,o.value.to)}}const Bh=cn.define(),fx=cn.define(),Fl=Kr.define({create(n){return new rS(xk(n).create(),null)},update(n,e){for(let t of e.effects)t.is(Bh)?n=new rS(t.value.create(),n.panel):t.is(fx)&&(n=new rS(n.query,t.value?dx:null));return n},provide:n=>Lh.from(n,e=>e.panel)});class rS{constructor(e,t){this.query=e,this.panel=t}}const GG=_t.mark({class:"cm-searchMatch"}),HG=_t.mark({class:"cm-searchMatch cm-searchMatch-selected"}),KG=nr.fromClass(class{constructor(n){this.view=n,this.decorations=this.highlight(n.state.field(Fl))}update(n){let e=n.state.field(Fl);(e!=n.startState.field(Fl)||n.docChanged||n.selectionSet||n.viewportChanged)&&(this.decorations=this.highlight(e))}highlight({query:n,panel:e}){if(!e||!n.spec.valid)return _t.none;let{view:t}=this,r=new Ua;for(let i=0,o=t.visibleRanges,s=o.length;i<s;i++){let{from:a,to:l}=o[i];for(;i<s-1&&l>o[i+1].from-2*250;)l=o[++i].to;n.highlight(t.state,a,l,(c,u)=>{let d=t.state.selection.ranges.some(h=>h.from==c&&h.to==u);r.add(c,u,d?HG:GG)})}return r.finish()}},{decorations:n=>n.decorations});function mp(n){return e=>{let t=e.state.field(Fl,!1);return t&&t.query.spec.valid?n(e,t):J5(e)}}const aM=mp((n,{query:e})=>{let{to:t}=n.state.selection.main,r=e.nextMatch(n.state,t,t);if(!r)return!1;let i=Ie.single(r.from,r.to),o=n.state.facet(Gf);return n.dispatch({selection:i,effects:[hx(n,r),o.scrollToMatch(i.main,n)],userEvent:"select.search"}),K5(n),!0}),lM=mp((n,{query:e})=>{let{state:t}=n,{from:r}=t.selection.main,i=e.prevMatch(t,r,r);if(!i)return!1;let o=Ie.single(i.from,i.to),s=n.state.facet(Gf);return n.dispatch({selection:o,effects:[hx(n,i),s.scrollToMatch(o.main,n)],userEvent:"select.search"}),K5(n),!0}),Y5=mp((n,{query:e})=>{let t=e.matchAll(n.state,1e3);return!t||!t.length?!1:(n.dispatch({selection:Ie.create(t.map(r=>Ie.range(r.from,r.to))),userEvent:"select.search.matches"}),!0)}),JG=({state:n,dispatch:e})=>{let t=n.selection;if(t.ranges.length>1||t.main.empty)return!1;let{from:r,to:i}=t.main,o=[],s=0;for(let a=new Nf(n.doc,n.sliceDoc(r,i));!a.next().done;){if(o.length>1e3)return!1;a.value.from==r&&(s=o.length),o.push(Ie.range(a.value.from,a.value.to))}return e(n.update({selection:Ie.create(o,s),userEvent:"select.search.matches"})),!0},cM=mp((n,{query:e})=>{let{state:t}=n,{from:r,to:i}=t.selection.main;if(t.readOnly)return!1;let o=e.nextMatch(t,r,r);if(!o)return!1;let s=o,a=[],l,c,u=[];if(s.from==r&&s.to==i&&(c=t.toText(e.getReplacement(s)),a.push({from:s.from,to:s.to,insert:c}),s=e.nextMatch(t,s.from,s.to),u.push(ft.announce.of(t.phrase("replaced match on line $",t.doc.lineAt(r).number)+"."))),s){let d=a.length==0||a[0].from>=o.to?0:o.to-o.from-c.length;l=Ie.single(s.from-d,s.to-d),u.push(hx(n,s)),u.push(t.facet(Gf).scrollToMatch(l.main,n))}return n.dispatch({changes:a,selection:l,effects:u,userEvent:"input.replace"}),!0}),G5=mp((n,{query:e})=>{if(n.state.readOnly)return!1;let t=e.matchAll(n.state,1e9).map(i=>{let{from:o,to:s}=i;return{from:o,to:s,insert:e.getReplacement(i)}});if(!t.length)return!1;let r=n.state.phrase("replaced $ matches",t.length)+".";return n.dispatch({changes:t,effects:ft.announce.of(r),userEvent:"input.replace.all"}),!0});function dx(n){return n.state.facet(Gf).createPanel(n)}function xk(n,e){var t,r,i,o,s;let a=n.selection.main,l=a.empty||a.to>a.from+100?"":n.sliceDoc(a.from,a.to);if(e&&!l)return e;let c=n.facet(Gf);return new X5({search:((t=e==null?void 0:e.literal)!==null&&t!==void 0?t:c.literal)?l:l.replace(/\n/g,"\\n"),caseSensitive:(r=e==null?void 0:e.caseSensitive)!==null&&r!==void 0?r:c.caseSensitive,literal:(i=e==null?void 0:e.literal)!==null&&i!==void 0?i:c.literal,regexp:(o=e==null?void 0:e.regexp)!==null&&o!==void 0?o:c.regexp,wholeWord:(s=e==null?void 0:e.wholeWord)!==null&&s!==void 0?s:c.wholeWord})}function H5(n){let e=jh(n,dx);return e&&e.dom.querySelector("[main-field]")}function K5(n){let e=H5(n);e&&e==n.root.activeElement&&e.select()}const J5=n=>{let e=n.state.field(Fl,!1);if(e&&e.panel){let t=H5(n);if(t&&t!=n.root.activeElement){let r=xk(n.state,e.query.spec);r.valid&&n.dispatch({effects:Bh.of(r)}),t.focus(),t.select()}}else n.dispatch({effects:[fx.of(!0),e?Bh.of(xk(n.state,e.query.spec)):cn.appendConfig.of(nH)]});return!0},e3=n=>{let e=n.state.field(Fl,!1);if(!e||!e.panel)return!1;let t=jh(n,dx);return t&&t.dom.contains(n.root.activeElement)&&n.focus(),n.dispatch({effects:fx.of(!1)}),!0};class eH{constructor(e){this.view=e;let t=this.query=e.state.field(Fl).query.spec;this.commit=this.commit.bind(this),this.searchField=fr("input",{value:t.search,placeholder:Co(e,"Find"),"aria-label":Co(e,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=fr("input",{value:t.replace,placeholder:Co(e,"Replace"),"aria-label":Co(e,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=fr("input",{type:"checkbox",name:"case",form:"",checked:t.caseSensitive,onchange:this.commit}),this.reField=fr("input",{type:"checkbox",name:"re",form:"",checked:t.regexp,onchange:this.commit}),this.wordField=fr("input",{type:"checkbox",name:"word",form:"",checked:t.wholeWord,onchange:this.commit});function r(i,o,s){return fr("button",{class:"cm-button",name:i,onclick:o,type:"button"},s)}this.dom=fr("div",{onkeydown:i=>this.keydown(i),class:"cm-search"},[this.searchField,r("next",()=>aM(e),[Co(e,"next")]),r("prev",()=>lM(e),[Co(e,"previous")]),r("select",()=>Y5(e),[Co(e,"all")]),fr("label",null,[this.caseField,Co(e,"match case")]),fr("label",null,[this.reField,Co(e,"regexp")]),fr("label",null,[this.wordField,Co(e,"by word")]),...e.state.readOnly?[]:[fr("br"),this.replaceField,r("replace",()=>cM(e),[Co(e,"replace")]),r("replaceAll",()=>G5(e),[Co(e,"replace all")])],fr("button",{name:"close",onclick:()=>e3(e),"aria-label":Co(e,"close"),type:"button"},["×"])])}commit(){let e=new X5({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:Bh.of(e)}))}keydown(e){vX(this.view,e,"search-panel")?e.preventDefault():e.keyCode==13&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?lM:aM)(this.view)):e.keyCode==13&&e.target==this.replaceField&&(e.preventDefault(),cM(this.view))}update(e){for(let t of e.transactions)for(let r of t.effects)r.is(Bh)&&!r.value.eq(this.query)&&this.setQuery(r.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(Gf).top}}function Co(n,e){return n.state.phrase(e)}const Vm=30,Wm=/[\s\.,:;?!]/;function hx(n,{from:e,to:t}){let r=n.state.doc.lineAt(e),i=n.state.doc.lineAt(t).to,o=Math.max(r.from,e-Vm),s=Math.min(i,t+Vm),a=n.state.sliceDoc(o,s);if(o!=r.from){for(let l=0;l<Vm;l++)if(!Wm.test(a[l+1])&&Wm.test(a[l])){a=a.slice(l);break}}if(s!=i){for(let l=a.length-1;l>a.length-Vm;l--)if(!Wm.test(a[l-1])&&Wm.test(a[l])){a=a.slice(0,l);break}}return ft.announce.of(`${n.state.phrase("current match")}. ${a} ${n.state.phrase("on line")} ${r.number}.`)}const tH=ft.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"}}),nH=[Fl,pa.low(KG),tH];class px{constructor(e,t,r,i){this.state=e,this.pos=t,this.explicit=r,this.view=i,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(e){let t=br(this.state).resolveInner(this.pos,-1);for(;t&&e.indexOf(t.name)<0;)t=t.parent;return t?{from:t.from,to:this.pos,text:this.state.sliceDoc(t.from,this.pos),type:t.type}:null}matchBefore(e){let t=this.state.doc.lineAt(this.pos),r=Math.max(t.from,this.pos-250),i=t.text.slice(r-t.from,this.pos-t.from),o=i.search(n3(e,!1));return o<0?null:{from:r+o,to:this.pos,text:i.slice(o)}}get aborted(){return this.abortListeners==null}addEventListener(e,t,r){e=="abort"&&this.abortListeners&&(this.abortListeners.push(t),r&&r.onDocChange&&(this.abortOnDocChange=!0))}}function uM(n){let e=Object.keys(n).join(""),t=/\w/.test(e);return t&&(e=e.replace(/\w/g,"")),`[${t?"\\w":""}${e.replace(/[^\w\s]/g,"\\$&")}]`}function rH(n){let e=Object.create(null),t=Object.create(null);for(let{label:i}of n){e[i[0]]=!0;for(let o=1;o<i.length;o++)t[i[o]]=!0}let r=uM(e)+uM(t)+"*$";return[new RegExp("^"+r),new RegExp(r)]}function t3(n){let e=n.map(i=>typeof i=="string"?{label:i}:i),[t,r]=e.every(i=>/^\w+$/.test(i.label))?[/\w*$/,/\w+$/]:rH(e);return i=>{let o=i.matchBefore(r);return o||i.explicit?{from:o?o.from:i.pos,options:e,validFor:t}:null}}function iH(n,e){return t=>{for(let r=br(t.state).resolveInner(t.pos,-1);r;r=r.parent){if(n.indexOf(r.name)>-1)return null;if(r.type.isTop)break}return e(t)}}class fM{constructor(e,t,r,i){this.completion=e,this.source=t,this.match=r,this.score=i}}function Kc(n){return n.selection.main.from}function n3(n,e){var t;let{source:r}=n,i=e&&r[0]!="^",o=r[r.length-1]!="$";return!i&&!o?n:new RegExp(`${i?"^":""}(?:${r})${o?"$":""}`,(t=n.flags)!==null&&t!==void 0?t:n.ignoreCase?"i":"")}const mx=ma.define();function oH(n,e,t,r){let{main:i}=n.selection,o=t-i.from,s=r-i.from;return Object.assign(Object.assign({},n.changeByRange(a=>{if(a!=i&&t!=r&&n.sliceDoc(a.from+o,a.from+s)!=n.sliceDoc(t,r))return{range:a};let l=n.toText(e);return{changes:{from:a.from+o,to:r==i.from?a.to:a.from+s,insert:l},range:Ie.cursor(a.from+o+l.length)}})),{scrollIntoView:!0,userEvent:"input.complete"})}const dM=new WeakMap;function sH(n){if(!Array.isArray(n))return n;let e=dM.get(n);return e||dM.set(n,e=t3(n)),e}const wv=cn.define(),Fh=cn.define();class aH{constructor(e){this.pattern=e,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(let t=0;t<e.length;){let r=co(e,t),i=ia(r);this.chars.push(r);let o=e.slice(t,t+i),s=o.toUpperCase();this.folded.push(co(s==o?o.toLowerCase():s,0)),t+=i}this.astral=e.length!=this.chars.length}ret(e,t){return this.score=e,this.matched=t,this}match(e){if(this.pattern.length==0)return this.ret(-100,[]);if(e.length<this.pattern.length)return null;let{chars:t,folded:r,any:i,precise:o,byWord:s}=this;if(t.length==1){let S=co(e,0),x=ia(S),P=x==e.length?0:-100;if(S!=t[0])if(S==r[0])P+=-200;else return null;return this.ret(P,[0,x])}let a=e.indexOf(this.pattern);if(a==0)return this.ret(e.length==this.pattern.length?0:-100,[0,this.pattern.length]);let l=t.length,c=0;if(a<0){for(let S=0,x=Math.min(e.length,200);S<x&&c<l;){let P=co(e,S);(P==t[c]||P==r[c])&&(i[c++]=S),S+=ia(P)}if(c<l)return null}let u=0,d=0,h=!1,p=0,g=-1,O=-1,v=/[a-z]/.test(e),b=!0;for(let S=0,x=Math.min(e.length,200),P=0;S<x&&d<l;){let w=co(e,S);a<0&&(u<l&&w==t[u]&&(o[u++]=S),p<l&&(w==t[p]||w==r[p]?(p==0&&(g=S),O=S+1,p++):p=0));let E,M=w<255?w>=48&&w<=57||w>=97&&w<=122?2:w>=65&&w<=90?1:0:(E=$P(w))!=E.toLowerCase()?1:E!=E.toUpperCase()?2:0;(!S||M==1&&v||P==0&&M!=0)&&(t[d]==w||r[d]==w&&(h=!0)?s[d++]=S:s.length&&(b=!1)),P=M,S+=ia(w)}return d==l&&s[0]==0&&b?this.result(-100+(h?-200:0),s,e):p==l&&g==0?this.ret(-200-e.length+(O==e.length?0:-100),[0,O]):a>-1?this.ret(-700-e.length,[a,a+this.pattern.length]):p==l?this.ret(-900-e.length,[g,O]):d==l?this.result(-100+(h?-200:0)+-700+(b?0:-1100),s,e):t.length==2?null:this.result((i[0]?-700:0)+-200+-1100,i,e)}result(e,t,r){let i=[],o=0;for(let s of t){let a=s+(this.astral?ia(co(r,s)):1);o&&i[o-1]==s?i[o-1]=a:(i[o++]=s,i[o++]=a)}return this.ret(e-r.length,i)}}class lH{constructor(e){this.pattern=e,this.matched=[],this.score=0,this.folded=e.toLowerCase()}match(e){if(e.length<this.pattern.length)return null;let t=e.slice(0,this.pattern.length),r=t==this.pattern?0:t.toLowerCase()==this.folded?-200:null;return r==null?null:(this.matched=[0,t.length],this.score=r+(e.length==this.pattern.length?0:-100),this)}}const Oi=Ct.define({combine(n){return $s(n,{activateOnTyping:!0,activateOnCompletion:()=>!1,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>"",optionClass:()=>"",aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:cH,filterStrict:!1,compareCompletions:(e,t)=>e.label.localeCompare(t.label),interactionDelay:75,updateSyncTime:100},{defaultKeymap:(e,t)=>e&&t,closeOnBlur:(e,t)=>e&&t,icons:(e,t)=>e&&t,tooltipClass:(e,t)=>r=>hM(e(r),t(r)),optionClass:(e,t)=>r=>hM(e(r),t(r)),addToOptions:(e,t)=>e.concat(t),filterStrict:(e,t)=>e||t})}});function hM(n,e){return n?e?n+" "+e:n:e}function cH(n,e,t,r,i,o){let s=n.textDirection==vr.RTL,a=s,l=!1,c="top",u,d,h=e.left-i.left,p=i.right-e.right,g=r.right-r.left,O=r.bottom-r.top;if(a&&h<Math.min(g,p)?a=!1:!a&&p<Math.min(g,h)&&(a=!0),g<=(a?h:p))u=Math.max(i.top,Math.min(t.top,i.bottom-O))-e.top,d=Math.min(400,a?h:p);else{l=!0,d=Math.min(400,(s?e.right:i.right-e.left)-30);let S=i.bottom-e.bottom;S>=O||S>e.top?u=t.bottom-e.top:(c="bottom",u=e.bottom-t.top)}let v=(e.bottom-e.top)/o.offsetHeight,b=(e.right-e.left)/o.offsetWidth;return{style:`${c}: ${u/v}px; max-width: ${d/b}px`,class:"cm-completionInfo-"+(l?s?"left-narrow":"right-narrow":a?"left":"right")}}function uH(n){let e=n.addToOptions.slice();return n.icons&&e.push({render(t){let r=document.createElement("div");return r.classList.add("cm-completionIcon"),t.type&&r.classList.add(...t.type.split(/\s+/g).map(i=>"cm-completionIcon-"+i)),r.setAttribute("aria-hidden","true"),r},position:20}),e.push({render(t,r,i,o){let s=document.createElement("span");s.className="cm-completionLabel";let a=t.displayLabel||t.label,l=0;for(let c=0;c<o.length;){let u=o[c++],d=o[c++];u>l&&s.appendChild(document.createTextNode(a.slice(l,u)));let h=s.appendChild(document.createElement("span"));h.appendChild(document.createTextNode(a.slice(u,d))),h.className="cm-completionMatchedText",l=d}return l<a.length&&s.appendChild(document.createTextNode(a.slice(l))),s},position:50},{render(t){if(!t.detail)return null;let r=document.createElement("span");return r.className="cm-completionDetail",r.textContent=t.detail,r},position:80}),e.sort((t,r)=>t.position-r.position).map(t=>t.render)}function iS(n,e,t){if(n<=t)return{from:0,to:n};if(e<0&&(e=0),e<=n>>1){let i=Math.floor(e/t);return{from:i*t,to:(i+1)*t}}let r=Math.floor((n-e)/t);return{from:n-(r+1)*t,to:n-r*t}}class fH{constructor(e,t,r){this.view=e,this.stateField=t,this.applyCompletion=r,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:l=>this.placeInfo(l),key:this},this.space=null,this.currentClass="";let i=e.state.field(t),{options:o,selected:s}=i.open,a=e.state.facet(Oi);this.optionContent=uH(a),this.optionClass=a.optionClass,this.tooltipClass=a.tooltipClass,this.range=iS(o.length,s,a.maxRenderedOptions),this.dom=document.createElement("div"),this.dom.className="cm-tooltip-autocomplete",this.updateTooltipClass(e.state),this.dom.addEventListener("mousedown",l=>{let{options:c}=e.state.field(t).open;for(let u=l.target,d;u&&u!=this.dom;u=u.parentNode)if(u.nodeName=="LI"&&(d=/-(\d+)$/.exec(u.id))&&+d[1]<c.length){this.applyCompletion(e,c[+d[1]]),l.preventDefault();return}}),this.dom.addEventListener("focusout",l=>{let c=e.state.field(this.stateField,!1);c&&c.tooltip&&e.state.facet(Oi).closeOnBlur&&l.relatedTarget!=e.contentDOM&&e.dispatch({effects:Fh.of(null)})}),this.showOptions(o,i.id)}mount(){this.updateSel()}showOptions(e,t){this.list&&this.list.remove(),this.list=this.dom.appendChild(this.createListBox(e,t,this.range)),this.list.addEventListener("scroll",()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)})}update(e){var t;let r=e.state.field(this.stateField),i=e.startState.field(this.stateField);if(this.updateTooltipClass(e.state),r!=i){let{options:o,selected:s,disabled:a}=r.open;(!i.open||i.open.options!=o)&&(this.range=iS(o.length,s,e.state.facet(Oi).maxRenderedOptions),this.showOptions(o,r.id)),this.updateSel(),a!=((t=i.open)===null||t===void 0?void 0:t.disabled)&&this.dom.classList.toggle("cm-tooltip-autocomplete-disabled",!!a)}}updateTooltipClass(e){let t=this.tooltipClass(e);if(t!=this.currentClass){for(let r of this.currentClass.split(" "))r&&this.dom.classList.remove(r);for(let r of t.split(" "))r&&this.dom.classList.add(r);this.currentClass=t}}positioned(e){this.space=e,this.info&&this.view.requestMeasure(this.placeInfoReq)}updateSel(){let e=this.view.state.field(this.stateField),t=e.open;if((t.selected>-1&&t.selected<this.range.from||t.selected>=this.range.to)&&(this.range=iS(t.options.length,t.selected,this.view.state.facet(Oi).maxRenderedOptions),this.showOptions(t.options,e.id)),this.updateSelectedOption(t.selected)){this.destroyInfo();let{completion:r}=t.options[t.selected],{info:i}=r;if(!i)return;let o=typeof i=="string"?document.createTextNode(i):i(r);if(!o)return;"then"in o?o.then(s=>{s&&this.view.state.field(this.stateField,!1)==e&&this.addInfoPane(s,r)}).catch(s=>mo(this.view.state,s,"completion info")):this.addInfoPane(o,r)}}addInfoPane(e,t){this.destroyInfo();let r=this.info=document.createElement("div");if(r.className="cm-tooltip cm-completionInfo",e.nodeType!=null)r.appendChild(e),this.infoDestroy=null;else{let{dom:i,destroy:o}=e;r.appendChild(i),this.infoDestroy=o||null}this.dom.appendChild(r),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(e){let t=null;for(let r=this.list.firstChild,i=this.range.from;r;r=r.nextSibling,i++)r.nodeName!="LI"||!r.id?i--:i==e?r.hasAttribute("aria-selected")||(r.setAttribute("aria-selected","true"),t=r):r.hasAttribute("aria-selected")&&r.removeAttribute("aria-selected");return t&&hH(this.list,t),t}measureInfo(){let e=this.dom.querySelector("[aria-selected]");if(!e||!this.info)return null;let t=this.dom.getBoundingClientRect(),r=this.info.getBoundingClientRect(),i=e.getBoundingClientRect(),o=this.space;if(!o){let s=this.dom.ownerDocument.documentElement;o={left:0,top:0,right:s.clientWidth,bottom:s.clientHeight}}return i.top>Math.min(o.bottom,t.bottom)-10||i.bottom<Math.max(o.top,t.top)+10?null:this.view.state.facet(Oi).positionInfo(this.view,t,i,r,o,this.dom)}placeInfo(e){this.info&&(e?(e.style&&(this.info.style.cssText=e.style),this.info.className="cm-tooltip cm-completionInfo "+(e.class||"")):this.info.style.cssText="top: -1e6px")}createListBox(e,t,r){const i=document.createElement("ul");i.id=t,i.setAttribute("role","listbox"),i.setAttribute("aria-expanded","true"),i.setAttribute("aria-label",this.view.state.phrase("Completions")),i.addEventListener("mousedown",s=>{s.target==i&&s.preventDefault()});let o=null;for(let s=r.from;s<r.to;s++){let{completion:a,match:l}=e[s],{section:c}=a;if(c){let h=typeof c=="string"?c:c.name;if(h!=o&&(s>r.from||r.from==0))if(o=h,typeof c!="string"&&c.header)i.appendChild(c.header(c));else{let p=i.appendChild(document.createElement("completion-section"));p.textContent=h}}const u=i.appendChild(document.createElement("li"));u.id=t+"-"+s,u.setAttribute("role","option");let d=this.optionClass(a);d&&(u.className=d);for(let h of this.optionContent){let p=h(a,this.view.state,this.view,l);p&&u.appendChild(p)}}return r.from&&i.classList.add("cm-completionListIncompleteTop"),r.to<e.length&&i.classList.add("cm-completionListIncompleteBottom"),i}destroyInfo(){this.info&&(this.infoDestroy&&this.infoDestroy(),this.info.remove(),this.info=null)}destroy(){this.destroyInfo()}}function dH(n,e){return t=>new fH(t,n,e)}function hH(n,e){let t=n.getBoundingClientRect(),r=e.getBoundingClientRect(),i=t.height/n.offsetHeight;r.top<t.top?n.scrollTop-=(t.top-r.top)/i:r.bottom>t.bottom&&(n.scrollTop+=(r.bottom-t.bottom)/i)}function pM(n){return(n.boost||0)*100+(n.apply?10:0)+(n.info?5:0)+(n.type?1:0)}function pH(n,e){let t=[],r=null,i=c=>{t.push(c);let{section:u}=c.completion;if(u){r||(r=[]);let d=typeof u=="string"?u:u.name;r.some(h=>h.name==d)||r.push(typeof u=="string"?{name:d}:u)}},o=e.facet(Oi);for(let c of n)if(c.hasResult()){let u=c.result.getMatch;if(c.result.filter===!1)for(let d of c.result.options)i(new fM(d,c.source,u?u(d):[],1e9-t.length));else{let d=e.sliceDoc(c.from,c.to),h,p=o.filterStrict?new lH(d):new aH(d);for(let g of c.result.options)if(h=p.match(g.label)){let O=g.displayLabel?u?u(g,h.matched):[]:h.matched;i(new fM(g,c.source,O,h.score+(g.boost||0)))}}}if(r){let c=Object.create(null),u=0,d=(h,p)=>{var g,O;return((g=h.rank)!==null&&g!==void 0?g:1e9)-((O=p.rank)!==null&&O!==void 0?O:1e9)||(h.name<p.name?-1:1)};for(let h of r.sort(d))u-=1e5,c[h.name]=u;for(let h of t){let{section:p}=h.completion;p&&(h.score+=c[typeof p=="string"?p:p.name])}}let s=[],a=null,l=o.compareCompletions;for(let c of t.sort((u,d)=>d.score-u.score||l(u.completion,d.completion))){let u=c.completion;!a||a.label!=u.label||a.detail!=u.detail||a.type!=null&&u.type!=null&&a.type!=u.type||a.apply!=u.apply||a.boost!=u.boost?s.push(c):pM(c.completion)>pM(a)&&(s[s.length-1]=c),a=c.completion}return s}class cf{constructor(e,t,r,i,o,s){this.options=e,this.attrs=t,this.tooltip=r,this.timestamp=i,this.selected=o,this.disabled=s}setSelected(e,t){return e==this.selected||e>=this.options.length?this:new cf(this.options,mM(t,e),this.tooltip,this.timestamp,e,this.disabled)}static build(e,t,r,i,o,s){if(i&&!s&&e.some(c=>c.isPending))return i.setDisabled();let a=pH(e,t);if(!a.length)return i&&e.some(c=>c.isPending)?i.setDisabled():null;let l=t.facet(Oi).selectOnOpen?0:-1;if(i&&i.selected!=l&&i.selected!=-1){let c=i.options[i.selected].completion;for(let u=0;u<a.length;u++)if(a[u].completion==c){l=u;break}}return new cf(a,mM(r,l),{pos:e.reduce((c,u)=>u.hasResult()?Math.min(c,u.from):c,1e8),create:bH,above:o.aboveCursor},i?i.timestamp:Date.now(),l,!1)}map(e){return new cf(this.options,this.attrs,Object.assign(Object.assign({},this.tooltip),{pos:e.mapPos(this.tooltip.pos)}),this.timestamp,this.selected,this.disabled)}setDisabled(){return new cf(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}}class kv{constructor(e,t,r){this.active=e,this.id=t,this.open=r}static start(){return new kv(vH,"cm-ac-"+Math.floor(Math.random()*2e6).toString(36),null)}update(e){let{state:t}=e,r=t.facet(Oi),o=(r.override||t.languageDataAt("autocomplete",Kc(t)).map(sH)).map(l=>(this.active.find(u=>u.source==l)||new ns(l,this.active.some(u=>u.state!=0)?1:0)).update(e,r));o.length==this.active.length&&o.every((l,c)=>l==this.active[c])&&(o=this.active);let s=this.open,a=e.effects.some(l=>l.is(gx));s&&e.docChanged&&(s=s.map(e.changes)),e.selection||o.some(l=>l.hasResult()&&e.changes.touchesRange(l.from,l.to))||!mH(o,this.active)||a?s=cf.build(o,t,this.id,s,r,a):s&&s.disabled&&!o.some(l=>l.isPending)&&(s=null),!s&&o.every(l=>!l.isPending)&&o.some(l=>l.hasResult())&&(o=o.map(l=>l.hasResult()?new ns(l.source,0):l));for(let l of e.effects)l.is(i3)&&(s=s&&s.setSelected(l.value,this.id));return o==this.active&&s==this.open?this:new kv(o,this.id,s)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?gH:OH}}function mH(n,e){if(n==e)return!0;for(let t=0,r=0;;){for(;t<n.length&&!n[t].hasResult();)t++;for(;r<e.length&&!e[r].hasResult();)r++;let i=t==n.length,o=r==e.length;if(i||o)return i==o;if(n[t++].result!=e[r++].result)return!1}}const gH={"aria-autocomplete":"list"},OH={};function mM(n,e){let t={"aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":n};return e>-1&&(t["aria-activedescendant"]=n+"-"+e),t}const vH=[];function r3(n,e){if(n.isUserEvent("input.complete")){let r=n.annotation(mx);if(r&&e.activateOnCompletion(r))return 12}let t=n.isUserEvent("input.type");return t&&e.activateOnTyping?5:t?1:n.isUserEvent("delete.backward")?2:n.selection?8:n.docChanged?16:0}class ns{constructor(e,t,r=!1){this.source=e,this.state=t,this.explicit=r}hasResult(){return!1}get isPending(){return this.state==1}update(e,t){let r=r3(e,t),i=this;(r&8||r&16&&this.touches(e))&&(i=new ns(i.source,0)),r&4&&i.state==0&&(i=new ns(this.source,1)),i=i.updateFor(e,r);for(let o of e.effects)if(o.is(wv))i=new ns(i.source,1,o.value);else if(o.is(Fh))i=new ns(i.source,0);else if(o.is(gx))for(let s of o.value)s.source==i.source&&(i=s);return i}updateFor(e,t){return this.map(e.changes)}map(e){return this}touches(e){return e.changes.touchesRange(Kc(e.state))}}class wf extends ns{constructor(e,t,r,i,o,s){super(e,3,t),this.limit=r,this.result=i,this.from=o,this.to=s}hasResult(){return!0}updateFor(e,t){var r;if(!(t&3))return this.map(e.changes);let i=this.result;i.map&&!e.changes.empty&&(i=i.map(i,e.changes));let o=e.changes.mapPos(this.from),s=e.changes.mapPos(this.to,1),a=Kc(e.state);if(a>s||!i||t&2&&(Kc(e.startState)==this.from||a<this.limit))return new ns(this.source,t&4?1:0);let l=e.changes.mapPos(this.limit);return yH(i.validFor,e.state,o,s)?new wf(this.source,this.explicit,l,i,o,s):i.update&&(i=i.update(i,o,s,new px(e.state,a,!1)))?new wf(this.source,this.explicit,l,i,i.from,(r=i.to)!==null&&r!==void 0?r:Kc(e.state)):new ns(this.source,1,this.explicit)}map(e){return e.empty?this:(this.result.map?this.result.map(this.result,e):this.result)?new wf(this.source,this.explicit,e.mapPos(this.limit),this.result,e.mapPos(this.from),e.mapPos(this.to,1)):new ns(this.source,0)}touches(e){return e.changes.touchesRange(this.from,this.to)}}function yH(n,e,t,r){if(!n)return!1;let i=e.sliceDoc(t,r);return typeof n=="function"?n(i,t,r,e):n3(n,!0).test(i)}const gx=cn.define({map(n,e){return n.map(t=>t.map(e))}}),i3=cn.define(),fo=Kr.define({create(){return kv.start()},update(n,e){return n.update(e)},provide:n=>[zP.from(n,e=>e.tooltip),ft.contentAttributes.from(n,e=>e.attrs)]});function Ox(n,e){const t=e.completion.apply||e.completion.label;let r=n.state.field(fo).active.find(i=>i.source==e.source);return r instanceof wf?(typeof t=="string"?n.dispatch(Object.assign(Object.assign({},oH(n.state,t,r.from,r.to)),{annotations:mx.of(e.completion)})):t(n,e.completion,r.from,r.to),!0):!1}const bH=dH(fo,Ox);function jl(n,e="option"){return t=>{let r=t.state.field(fo,!1);if(!r||!r.open||r.open.disabled||Date.now()-r.open.timestamp<t.state.facet(Oi).interactionDelay)return!1;let i=1,o;e=="page"&&(o=zN(t,r.open.tooltip))&&(i=Math.max(2,Math.floor(o.dom.offsetHeight/o.dom.querySelector("li").offsetHeight)-1));let{length:s}=r.open.options,a=r.open.selected>-1?r.open.selected+i*(n?1:-1):n?0:s-1;return a<0?a=e=="page"?0:s-1:a>=s&&(a=e=="page"?s-1:0),t.dispatch({effects:i3.of(a)}),!0}}const Ck=n=>{let e=n.state.field(fo,!1);return n.state.readOnly||!e||!e.open||e.open.selected<0||e.open.disabled||Date.now()-e.open.timestamp<n.state.facet(Oi).interactionDelay?!1:Ox(n,e.open.options[e.open.selected])},Tk=n=>n.state.field(fo,!1)?(n.dispatch({effects:wv.of(!0)}),!0):!1,o3=n=>{let e=n.state.field(fo,!1);return!e||!e.active.some(t=>t.state!=0)?!1:(n.dispatch({effects:Fh.of(null)}),!0)};class SH{constructor(e,t){this.active=e,this.context=t,this.time=Date.now(),this.updates=[],this.done=void 0}}const wH=50,kH=1e3,PH=nr.fromClass(class{constructor(n){this.view=n,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0;for(let e of n.state.field(fo).active)e.isPending&&this.startQuery(e)}update(n){let e=n.state.field(fo),t=n.state.facet(Oi);if(!n.selectionSet&&!n.docChanged&&n.startState.field(fo)==e)return;let r=n.transactions.some(o=>{let s=r3(o,t);return s&8||(o.selection||o.docChanged)&&!(s&3)});for(let o=0;o<this.running.length;o++){let s=this.running[o];if(r||s.context.abortOnDocChange&&n.docChanged||s.updates.length+n.transactions.length>wH&&Date.now()-s.time>kH){for(let a of s.context.abortListeners)try{a()}catch(l){mo(this.view.state,l)}s.context.abortListeners=null,this.running.splice(o--,1)}else s.updates.push(...n.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),n.transactions.some(o=>o.effects.some(s=>s.is(wv)))&&(this.pendingStart=!0);let i=this.pendingStart?50:t.activateOnTypingDelay;if(this.debounceUpdate=e.active.some(o=>o.isPending&&!this.running.some(s=>s.active.source==o.source))?setTimeout(()=>this.startUpdate(),i):-1,this.composing!=0)for(let o of n.transactions)o.isUserEvent("input.type")?this.composing=2:this.composing==2&&o.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:n}=this.view,e=n.field(fo);for(let t of e.active)t.isPending&&!this.running.some(r=>r.active.source==t.source)&&this.startQuery(t);this.running.length&&e.open&&e.open.disabled&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(Oi).updateSyncTime))}startQuery(n){let{state:e}=this.view,t=Kc(e),r=new px(e,t,n.explicit,this.view),i=new SH(n,r);this.running.push(i),Promise.resolve(n.source(r)).then(o=>{i.context.aborted||(i.done=o||null,this.scheduleAccept())},o=>{this.view.dispatch({effects:Fh.of(null)}),mo(this.view.state,o)})}scheduleAccept(){this.running.every(n=>n.done!==void 0)?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(Oi).updateSyncTime))}accept(){var n;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let e=[],t=this.view.state.facet(Oi),r=this.view.state.field(fo);for(let i=0;i<this.running.length;i++){let o=this.running[i];if(o.done===void 0)continue;if(this.running.splice(i--,1),o.done){let a=Kc(o.updates.length?o.updates[0].startState:this.view.state),l=Math.min(a,o.done.from+(o.active.explicit?0:1)),c=new wf(o.active.source,o.active.explicit,l,o.done,o.done.from,(n=o.done.to)!==null&&n!==void 0?n:a);for(let u of o.updates)c=c.update(u,t);if(c.hasResult()){e.push(c);continue}}let s=r.active.find(a=>a.source==o.active.source);if(s&&s.isPending)if(o.done==null){let a=new ns(o.active.source,0);for(let l of o.updates)a=a.update(l,t);a.isPending||e.push(a)}else this.startQuery(s)}(e.length||r.open&&r.open.disabled)&&this.view.dispatch({effects:gx.of(e)})}},{eventHandlers:{blur(n){let e=this.view.state.field(fo,!1);if(e&&e.tooltip&&this.view.state.facet(Oi).closeOnBlur){let t=e.open&&zN(this.view,e.open.tooltip);(!t||!t.dom.contains(n.relatedTarget))&&setTimeout(()=>this.view.dispatch({effects:Fh.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:wv.of(!1)}),20),this.composing=0}}}),xH=typeof navigator=="object"&&/Win/.test(navigator.platform),CH=pa.highest(ft.domEventHandlers({keydown(n,e){let t=e.state.field(fo,!1);if(!t||!t.open||t.open.disabled||t.open.selected<0||n.key.length>1||n.ctrlKey&&!(xH&&n.altKey)||n.metaKey)return!1;let r=t.open.options[t.open.selected],i=t.active.find(s=>s.source==r.source),o=r.completion.commitCharacters||i.result.commitCharacters;return o&&o.indexOf(n.key)>-1&&Ox(e,r),!1}})),s3=ft.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:"monospace",whiteSpace:"nowrap",overflow:"hidden auto",maxWidth_fallback:"700px",maxWidth:"min(700px, 95vw)",minWidth:"250px",maxHeight:"10em",height:"100%",listStyle:"none",margin:0,padding:0,"& > li, & > completion-section":{padding:"1px 3px",lineHeight:1.2},"& > li":{overflowX:"hidden",textOverflow:"ellipsis",cursor:"pointer"},"& > completion-section":{display:"list-item",borderBottom:"1px solid silver",paddingLeft:"0.5em",opacity:.7}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#17c",color:"white"},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#777"},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#347",color:"white"},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#444"},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:'"···"',opacity:.5,display:"block",textAlign:"center"},".cm-tooltip.cm-completionInfo":{position:"absolute",padding:"3px 9px",width:"max-content",maxWidth:"400px",boxSizing:"border-box",whiteSpace:"pre-line"},".cm-completionInfo.cm-completionInfo-left":{right:"100%"},".cm-completionInfo.cm-completionInfo-right":{left:"100%"},".cm-completionInfo.cm-completionInfo-left-narrow":{right:"30px"},".cm-completionInfo.cm-completionInfo-right-narrow":{left:"30px"},"&light .cm-snippetField":{backgroundColor:"#00000022"},"&dark .cm-snippetField":{backgroundColor:"#ffffff22"},".cm-snippetFieldPosition":{verticalAlign:"text-top",width:0,height:"1.15em",display:"inline-block",margin:"0 -0.7px -.7em",borderLeft:"1.4px dotted #888"},".cm-completionMatchedText":{textDecoration:"underline"},".cm-completionDetail":{marginLeft:"0.5em",fontStyle:"italic"},".cm-completionIcon":{fontSize:"90%",width:".8em",display:"inline-block",textAlign:"center",paddingRight:".6em",opacity:"0.6",boxSizing:"content-box"},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:"'ƒ'"}},".cm-completionIcon-class":{"&:after":{content:"'○'"}},".cm-completionIcon-interface":{"&:after":{content:"'◌'"}},".cm-completionIcon-variable":{"&:after":{content:"'𝑥'"}},".cm-completionIcon-constant":{"&:after":{content:"'𝐶'"}},".cm-completionIcon-type":{"&:after":{content:"'𝑡'"}},".cm-completionIcon-enum":{"&:after":{content:"'∪'"}},".cm-completionIcon-property":{"&:after":{content:"'□'"}},".cm-completionIcon-keyword":{"&:after":{content:"'🔑︎'"}},".cm-completionIcon-namespace":{"&:after":{content:"'▢'"}},".cm-completionIcon-text":{"&:after":{content:"'abc'",fontSize:"50%",verticalAlign:"middle"}}});class TH{constructor(e,t,r,i){this.field=e,this.line=t,this.from=r,this.to=i}}class vx{constructor(e,t,r){this.field=e,this.from=t,this.to=r}map(e){let t=e.mapPos(this.from,-1,ii.TrackDel),r=e.mapPos(this.to,1,ii.TrackDel);return t==null||r==null?null:new vx(this.field,t,r)}}class yx{constructor(e,t){this.lines=e,this.fieldPositions=t}instantiate(e,t){let r=[],i=[t],o=e.doc.lineAt(t),s=/^\s*/.exec(o.text)[0];for(let l of this.lines){if(r.length){let c=s,u=/^\t*/.exec(l)[0].length;for(let d=0;d<u;d++)c+=e.facet(fp);i.push(t+c.length-u),l=c+l.slice(u)}r.push(l),t+=l.length+1}let a=this.fieldPositions.map(l=>new vx(l.field,i[l.line]+l.from,i[l.line]+l.to));return{text:r,ranges:a}}static parse(e){let t=[],r=[],i=[],o;for(let s of e.split(/\r\n?|\n/)){for(;o=/[#$]\{(?:(\d+)(?::([^}]*))?|((?:\\[{}]|[^}])*))\}/.exec(s);){let a=o[1]?+o[1]:null,l=o[2]||o[3]||"",c=-1,u=l.replace(/\\[{}]/g,d=>d[1]);for(let d=0;d<t.length;d++)(a!=null?t[d].seq==a:u&&t[d].name==u)&&(c=d);if(c<0){let d=0;for(;d<t.length&&(a==null||t[d].seq!=null&&t[d].seq<a);)d++;t.splice(d,0,{seq:a,name:u}),c=d;for(let h of i)h.field>=c&&h.field++}i.push(new TH(c,r.length,o.index,o.index+u.length)),s=s.slice(0,o.index)+l+s.slice(o.index+o[0].length)}s=s.replace(/\\([{}])/g,(a,l,c)=>{for(let u of i)u.line==r.length&&u.from>c&&(u.from--,u.to--);return l}),r.push(s)}return new yx(r,i)}}let _H=_t.widget({widget:new class extends Io{toDOM(){let n=document.createElement("span");return n.className="cm-snippetFieldPosition",n}ignoreEvent(){return!1}}}),EH=_t.mark({class:"cm-snippetField"});class Hf{constructor(e,t){this.ranges=e,this.active=t,this.deco=_t.set(e.map(r=>(r.from==r.to?_H:EH).range(r.from,r.to)))}map(e){let t=[];for(let r of this.ranges){let i=r.map(e);if(!i)return null;t.push(i)}return new Hf(t,this.active)}selectionInsideField(e){return e.ranges.every(t=>this.ranges.some(r=>r.field==this.active&&r.from<=t.from&&r.to>=t.to))}}const gp=cn.define({map(n,e){return n&&n.map(e)}}),RH=cn.define(),Vh=Kr.define({create(){return null},update(n,e){for(let t of e.effects){if(t.is(gp))return t.value;if(t.is(RH)&&n)return new Hf(n.ranges,t.value)}return n&&e.docChanged&&(n=n.map(e.changes)),n&&e.selection&&!n.selectionInsideField(e.selection)&&(n=null),n},provide:n=>ft.decorations.from(n,e=>e?e.deco:_t.none)});function bx(n,e){return Ie.create(n.filter(t=>t.field==e).map(t=>Ie.range(t.from,t.to)))}function AH(n){let e=yx.parse(n);return(t,r,i,o)=>{let{text:s,ranges:a}=e.instantiate(t.state,i),{main:l}=t.state.selection,c={changes:{from:i,to:o==l.from?l.to:o,insert:Fn.of(s)},scrollIntoView:!0,annotations:r?[mx.of(r),Hr.userEvent.of("input.complete")]:void 0};if(a.length&&(c.selection=bx(a,0)),a.some(u=>u.field>0)){let u=new Hf(a,0),d=c.effects=[gp.of(u)];t.state.field(Vh,!1)===void 0&&d.push(cn.appendConfig.of([Vh,IH,jH,s3]))}t.dispatch(t.state.update(c))}}function a3(n){return({state:e,dispatch:t})=>{let r=e.field(Vh,!1);if(!r||n<0&&r.active==0)return!1;let i=r.active+n,o=n>0&&!r.ranges.some(s=>s.field==i+n);return t(e.update({selection:bx(r.ranges,i),effects:gp.of(o?null:new Hf(r.ranges,i)),scrollIntoView:!0})),!0}}const MH=({state:n,dispatch:e})=>n.field(Vh,!1)?(e(n.update({effects:gp.of(null)})),!0):!1,$H=a3(1),DH=a3(-1),QH=[{key:"Tab",run:$H,shift:DH},{key:"Escape",run:MH}],gM=Ct.define({combine(n){return n.length?n[0]:QH}}),IH=pa.highest(Xf.compute([gM],n=>n.facet(gM)));function ao(n,e){return Object.assign(Object.assign({},e),{apply:AH(n)})}const jH=ft.domEventHandlers({mousedown(n,e){let t=e.state.field(Vh,!1),r;if(!t||(r=e.posAtCoords({x:n.clientX,y:n.clientY}))==null)return!1;let i=t.ranges.find(o=>o.from<=r&&o.to>=r);return!i||i.field==t.active?!1:(e.dispatch({selection:bx(t.ranges,i.field),effects:gp.of(t.ranges.some(o=>o.field>i.field)?new Hf(t.ranges,i.field):null),scrollIntoView:!0}),!0)}}),Wh={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},Wc=cn.define({map(n,e){let t=e.mapPos(n,-1,ii.TrackAfter);return t??void 0}}),Sx=new class extends eu{};Sx.startSide=1;Sx.endSide=-1;const l3=Kr.define({create(){return zn.empty},update(n,e){if(n=n.map(e.changes),e.selection){let t=e.state.doc.lineAt(e.selection.main.head);n=n.update({filter:r=>r>=t.from&&r<=t.to})}for(let t of e.effects)t.is(Wc)&&(n=n.update({add:[Sx.range(t.value,t.value+1)]}));return n}});function LH(){return[qH,l3]}const oS="()[]{}<>«»»«[]{}";function c3(n){for(let e=0;e<oS.length;e+=2)if(oS.charCodeAt(e)==n)return oS.charAt(e+1);return $P(n<128?n:n+1)}function u3(n,e){return n.languageDataAt("closeBrackets",e)[0]||Wh}const NH=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),qH=ft.inputHandler.of((n,e,t,r)=>{if((NH?n.composing:n.compositionStarted)||n.state.readOnly)return!1;let i=n.state.selection.main;if(r.length>2||r.length==2&&ia(co(r,0))==1||e!=i.from||t!=i.to)return!1;let o=BH(n.state,r);return o?(n.dispatch(o),!0):!1}),UH=({state:n,dispatch:e})=>{if(n.readOnly)return!1;let r=u3(n,n.selection.main.head).brackets||Wh.brackets,i=null,o=n.changeByRange(s=>{if(s.empty){let a=FH(n.doc,s.head);for(let l of r)if(l==a&&fy(n.doc,s.head)==c3(co(l,0)))return{changes:{from:s.head-l.length,to:s.head+l.length},range:Ie.cursor(s.head-l.length)}}return{range:i=s}});return i||e(n.update(o,{scrollIntoView:!0,userEvent:"delete.backward"})),!i};function BH(n,e){let t=u3(n,n.selection.main.head),r=t.brackets||Wh.brackets;for(let i of r){let o=c3(co(i,0));if(e==i)return o==i?ZH(n,i,r.indexOf(i+i+i)>-1,t):VH(n,i,o,t.before||Wh.before);if(e==o&&f3(n,n.selection.main.from))return WH(n,i,o)}return null}function f3(n,e){let t=!1;return n.field(l3).between(0,n.doc.length,r=>{r==e&&(t=!0)}),t}function fy(n,e){let t=n.sliceString(e,e+2);return t.slice(0,ia(co(t,0)))}function FH(n,e){let t=n.sliceString(e-2,e);return ia(co(t,0))==t.length?t:t.slice(1)}function VH(n,e,t,r){let i=null,o=n.changeByRange(s=>{if(!s.empty)return{changes:[{insert:e,from:s.from},{insert:t,from:s.to}],effects:Wc.of(s.to+e.length),range:Ie.range(s.anchor+e.length,s.head+e.length)};let a=fy(n.doc,s.head);return!a||/\s/.test(a)||r.indexOf(a)>-1?{changes:{insert:e+t,from:s.head},effects:Wc.of(s.head+e.length),range:Ie.cursor(s.head+e.length)}:{range:i=s}});return i?null:n.update(o,{scrollIntoView:!0,userEvent:"input.type"})}function WH(n,e,t){let r=null,i=n.changeByRange(o=>o.empty&&fy(n.doc,o.head)==t?{changes:{from:o.head,to:o.head+t.length,insert:t},range:Ie.cursor(o.head+t.length)}:r={range:o});return r?null:n.update(i,{scrollIntoView:!0,userEvent:"input.type"})}function ZH(n,e,t,r){let i=r.stringPrefixes||Wh.stringPrefixes,o=null,s=n.changeByRange(a=>{if(!a.empty)return{changes:[{insert:e,from:a.from},{insert:e,from:a.to}],effects:Wc.of(a.to+e.length),range:Ie.range(a.anchor+e.length,a.head+e.length)};let l=a.head,c=fy(n.doc,l),u;if(c==e){if(OM(n,l))return{changes:{insert:e+e,from:l},effects:Wc.of(l+e.length),range:Ie.cursor(l+e.length)};if(f3(n,l)){let h=t&&n.sliceDoc(l,l+e.length*3)==e+e+e?e+e+e:e;return{changes:{from:l,to:l+h.length,insert:h},range:Ie.cursor(l+h.length)}}}else{if(t&&n.sliceDoc(l-2*e.length,l)==e+e&&(u=vM(n,l-2*e.length,i))>-1&&OM(n,u))return{changes:{insert:e+e+e+e,from:l},effects:Wc.of(l+e.length),range:Ie.cursor(l+e.length)};if(n.charCategorizer(l)(c)!=Tr.Word&&vM(n,l,i)>-1&&!XH(n,l,e,i))return{changes:{insert:e+e,from:l},effects:Wc.of(l+e.length),range:Ie.cursor(l+e.length)}}return{range:o=a}});return o?null:n.update(s,{scrollIntoView:!0,userEvent:"input.type"})}function OM(n,e){let t=br(n).resolveInner(e+1);return t.parent&&t.from==e}function XH(n,e,t,r){let i=br(n).resolveInner(e,-1),o=r.reduce((s,a)=>Math.max(s,a.length),0);for(let s=0;s<5;s++){let a=n.sliceDoc(i.from,Math.min(i.to,i.from+t.length+o)),l=a.indexOf(t);if(!l||l>-1&&r.indexOf(a.slice(0,l))>-1){let u=i.firstChild;for(;u&&u.from==i.from&&u.to-u.from>t.length+l;){if(n.sliceDoc(u.to-t.length,u.to)==t)return!1;u=u.firstChild}return!0}let c=i.to==e&&i.parent;if(!c)break;i=c}return!1}function vM(n,e,t){let r=n.charCategorizer(e);if(r(n.sliceDoc(e-1,e))!=Tr.Word)return e;for(let i of t){let o=e-i.length;if(n.sliceDoc(o,e)==i&&r(n.sliceDoc(o-1,o))!=Tr.Word)return o}return-1}function d3(n={}){return[CH,fo,Oi.of(n),PH,YH,s3]}const zH=[{key:"Ctrl-Space",run:Tk},{mac:"Alt-`",run:Tk},{key:"Escape",run:o3},{key:"ArrowDown",run:jl(!0)},{key:"ArrowUp",run:jl(!1)},{key:"PageDown",run:jl(!0,"page")},{key:"PageUp",run:jl(!1,"page")},{key:"Enter",run:Ck}],YH=pa.highest(Xf.computeN([Oi],n=>n.facet(Oi).defaultKeymap?[zH]:[]));class yM{constructor(e,t,r){this.from=e,this.to=t,this.diagnostic=r}}class qc{constructor(e,t,r){this.diagnostics=e,this.panel=t,this.selected=r}static init(e,t,r){let i=e,o=r.facet(Zh).markerFilter;o&&(i=o(i,r));let s=e.slice().sort((d,h)=>d.from-h.from||d.to-h.to),a=new Ua,l=[],c=0;for(let d=0;;){let h=d==s.length?null:s[d];if(!h&&!l.length)break;let p,g;for(l.length?(p=c,g=l.reduce((v,b)=>Math.min(v,b.to),h&&h.from>p?h.from:1e8)):(p=h.from,g=h.to,l.push(h),d++);d<s.length;){let v=s[d];if(v.from==p&&(v.to>v.from||v.to==p))l.push(v),d++,g=Math.min(v.to,g);else{g=Math.min(v.from,g);break}}let O=aK(l);if(l.some(v=>v.from==v.to||v.from==v.to-1&&r.doc.lineAt(v.from).to==v.from))a.add(p,p,_t.widget({widget:new rK(O),diagnostics:l.slice()}));else{let v=l.reduce((b,S)=>S.markClass?b+" "+S.markClass:b,"");a.add(p,g,_t.mark({class:"cm-lintRange cm-lintRange-"+O+v,diagnostics:l.slice(),inclusiveEnd:l.some(b=>b.to>g)}))}c=g;for(let v=0;v<l.length;v++)l[v].to<=c&&l.splice(v--,1)}let u=a.finish();return new qc(u,t,qf(u))}}function qf(n,e=null,t=0){let r=null;return n.between(t,1e9,(i,o,{spec:s})=>{if(!(e&&s.diagnostics.indexOf(e)<0))if(!r)r=new yM(i,o,e||s.diagnostics[0]);else{if(s.diagnostics.indexOf(r.diagnostic)<0)return!1;r=new yM(r.from,o,r.diagnostic)}}),r}function GH(n,e){let t=e.pos,r=e.end||t,i=n.state.facet(Zh).hideOn(n,t,r);if(i!=null)return i;let o=n.startState.doc.lineAt(e.pos);return!!(n.effects.some(s=>s.is(h3))||n.changes.touchesRange(o.from,Math.max(o.to,r)))}function HH(n,e){return n.field($o,!1)?e:e.concat(cn.appendConfig.of(lK))}const h3=cn.define(),wx=cn.define(),p3=cn.define(),$o=Kr.define({create(){return new qc(_t.none,null,null)},update(n,e){if(e.docChanged&&n.diagnostics.size){let t=n.diagnostics.map(e.changes),r=null,i=n.panel;if(n.selected){let o=e.changes.mapPos(n.selected.from,1);r=qf(t,n.selected.diagnostic,o)||qf(t,null,o)}!t.size&&i&&e.state.facet(Zh).autoPanel&&(i=null),n=new qc(t,i,r)}for(let t of e.effects)if(t.is(h3)){let r=e.state.facet(Zh).autoPanel?t.value.length?Xh.open:null:n.panel;n=qc.init(t.value,r,e.state)}else t.is(wx)?n=new qc(n.diagnostics,t.value?Xh.open:null,n.selected):t.is(p3)&&(n=new qc(n.diagnostics,n.panel,t.value));return n},provide:n=>[Lh.from(n,e=>e.panel),ft.decorations.from(n,e=>e.diagnostics)]}),KH=_t.mark({class:"cm-lintRange cm-lintRange-active"});function JH(n,e,t){let{diagnostics:r}=n.state.field($o),i,o=-1,s=-1;r.between(e-(t<0?1:0),e+(t>0?1:0),(l,c,{spec:u})=>{if(e>=l&&e<=c&&(l==c||(e>l||t>0)&&(e<c||t<0)))return i=u.diagnostics,o=l,s=c,!1});let a=n.state.facet(Zh).tooltipFilter;return i&&a&&(i=a(i,n.state)),i?{pos:o,end:s,above:n.state.doc.lineAt(o).to<s,create(){return{dom:eK(n,i)}}}:null}function eK(n,e){return fr("ul",{class:"cm-tooltip-lint"},e.map(t=>g3(n,t,!1)))}const tK=n=>{let e=n.state.field($o,!1);(!e||!e.panel)&&n.dispatch({effects:HH(n.state,[wx.of(!0)])});let t=jh(n,Xh.open);return t&&t.dom.querySelector(".cm-panel-lint ul").focus(),!0},bM=n=>{let e=n.state.field($o,!1);return!e||!e.panel?!1:(n.dispatch({effects:wx.of(!1)}),!0)},nK=n=>{let e=n.state.field($o,!1);if(!e)return!1;let t=n.state.selection.main,r=e.diagnostics.iter(t.to+1);return!r.value&&(r=e.diagnostics.iter(0),!r.value||r.from==t.from&&r.to==t.to)?!1:(n.dispatch({selection:{anchor:r.from,head:r.to},scrollIntoView:!0}),!0)},Zh=Ct.define({combine(n){return Object.assign({sources:n.map(e=>e.source).filter(e=>e!=null)},$s(n.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{needsRefresh:(e,t)=>e?t?r=>e(r)||t(r):e:t}))}});function m3(n){let e=[];if(n)e:for(let{name:t}of n){for(let r=0;r<t.length;r++){let i=t[r];if(/[a-zA-Z]/.test(i)&&!e.some(o=>o.toLowerCase()==i.toLowerCase())){e.push(i);continue e}}e.push("")}return e}function g3(n,e,t){var r;let i=t?m3(e.actions):[];return fr("li",{class:"cm-diagnostic cm-diagnostic-"+e.severity},fr("span",{class:"cm-diagnosticText"},e.renderMessage?e.renderMessage(n):e.message),(r=e.actions)===null||r===void 0?void 0:r.map((o,s)=>{let a=!1,l=h=>{if(h.preventDefault(),a)return;a=!0;let p=qf(n.state.field($o).diagnostics,e);p&&o.apply(n,p.from,p.to)},{name:c}=o,u=i[s]?c.indexOf(i[s]):-1,d=u<0?c:[c.slice(0,u),fr("u",c.slice(u,u+1)),c.slice(u+1)];return fr("button",{type:"button",class:"cm-diagnosticAction",onclick:l,onmousedown:l,"aria-label":` Action: ${c}${u<0?"":` (access key "${i[s]})"`}.`},d)}),e.source&&fr("div",{class:"cm-diagnosticSource"},e.source))}class rK extends Io{constructor(e){super(),this.sev=e}eq(e){return e.sev==this.sev}toDOM(){return fr("span",{class:"cm-lintPoint cm-lintPoint-"+this.sev})}}class SM{constructor(e,t){this.diagnostic=t,this.id="item_"+Math.floor(Math.random()*4294967295).toString(16),this.dom=g3(e,t,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}}class Xh{constructor(e){this.view=e,this.items=[];let t=i=>{if(i.keyCode==27)bM(this.view),this.view.focus();else if(i.keyCode==38||i.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(i.keyCode==40||i.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(i.keyCode==36)this.moveSelection(0);else if(i.keyCode==35)this.moveSelection(this.items.length-1);else if(i.keyCode==13)this.view.focus();else if(i.keyCode>=65&&i.keyCode<=90&&this.selectedIndex>=0){let{diagnostic:o}=this.items[this.selectedIndex],s=m3(o.actions);for(let a=0;a<s.length;a++)if(s[a].toUpperCase().charCodeAt(0)==i.keyCode){let l=qf(this.view.state.field($o).diagnostics,o);l&&o.actions[a].apply(e,l.from,l.to)}}else return;i.preventDefault()},r=i=>{for(let o=0;o<this.items.length;o++)this.items[o].dom.contains(i.target)&&this.moveSelection(o)};this.list=fr("ul",{tabIndex:0,role:"listbox","aria-label":this.view.state.phrase("Diagnostics"),onkeydown:t,onclick:r}),this.dom=fr("div",{class:"cm-panel-lint"},this.list,fr("button",{type:"button",name:"close","aria-label":this.view.state.phrase("close"),onclick:()=>bM(this.view)},"×")),this.update()}get selectedIndex(){let e=this.view.state.field($o).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($o),r=0,i=!1,o=null,s=new Set;for(e.between(0,this.view.state.doc.length,(a,l,{spec:c})=>{for(let u of c.diagnostics){if(s.has(u))continue;s.add(u);let d=-1,h;for(let p=r;p<this.items.length;p++)if(this.items[p].diagnostic==u){d=p;break}d<0?(h=new SM(this.view,u),this.items.splice(r,0,h),i=!0):(h=this.items[d],d>r&&(this.items.splice(r,d-r),i=!0)),t&&h.diagnostic==t.diagnostic?h.dom.hasAttribute("aria-selected")||(h.dom.setAttribute("aria-selected","true"),o=h):h.dom.hasAttribute("aria-selected")&&h.dom.removeAttribute("aria-selected"),r++}});r<this.items.length&&!(this.items.length==1&&this.items[0].diagnostic.from<0);)i=!0,this.items.pop();this.items.length==0&&(this.items.push(new SM(this.view,{from:-1,to:-1,severity:"info",message:this.view.state.phrase("No diagnostics")})),i=!0),o?(this.list.setAttribute("aria-activedescendant",o.id),this.view.requestMeasure({key:this,read:()=>({sel:o.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:a,panel:l})=>{let c=l.height/this.list.offsetHeight;a.top<l.top?this.list.scrollTop-=(l.top-a.top)/c:a.bottom>l.bottom&&(this.list.scrollTop+=(a.bottom-l.bottom)/c)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),i&&this.sync()}sync(){let e=this.list.firstChild;function t(){let r=e;e=r.nextSibling,r.remove()}for(let r of this.items)if(r.dom.parentNode==this.list){for(;e!=r.dom;)t();e=r.dom.nextSibling}else this.list.insertBefore(r.dom,e);for(;e;)t()}moveSelection(e){if(this.selectedIndex<0)return;let t=this.view.state.field($o),r=qf(t.diagnostics,this.items[e].diagnostic);r&&this.view.dispatch({selection:{anchor:r.from,head:r.to},scrollIntoView:!0,effects:p3.of(r)})}static open(e){return new Xh(e)}}function iK(n,e='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${e}>${encodeURIComponent(n)}</svg>')`}function Zm(n){return iK(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${n}" fill="none" stroke-width=".7"/>`,'width="6" height="3"')}const oK=ft.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:Zm("#d11")},".cm-lintRange-warning":{backgroundImage:Zm("orange")},".cm-lintRange-info":{backgroundImage:Zm("#999")},".cm-lintRange-hint":{backgroundImage:Zm("#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}}});function sK(n){return n=="error"?4:n=="warning"?3:n=="info"?2:1}function aK(n){let e="hint",t=1;for(let r of n){let i=sK(r.severity);i>t&&(t=i,e=r.severity)}return e}const lK=[$o,ft.decorations.compute([$o],n=>{let{selected:e,panel:t}=n.field($o);return!e||!t||e.from==e.to?_t.none:_t.set([KH.range(e.from,e.to)])}),iz(JH,{hideOn:GH}),oK],wM="500",cK={background:RA,foreground:w5,caret:UY,selection:LY,selectionMatch:NY,lineHighlight:qY,gutterBackground:RA,gutterForeground:IY,gutterActiveForeground:jY};function uK(n){const{theme:e="dark",settings:t={},styles:r=[]}={};return[as({theme:e,settings:{...cK,...t},styles:[{tag:[C.keyword,C.operatorKeyword,C.modifier,C.color,C.constant(C.name),C.standard(C.name),C.standard(C.tagName),C.special(C.brace),C.atom,C.bool,C.special(C.variableName)],color:AA},{tag:[C.controlKeyword,C.moduleKeyword],color:AA},{tag:[C.name,C.deleted,C.character,C.macroName,C.variableName,C.labelName,C.definition(C.name)],color:Nd},{tag:[C.propertyName],color:$A},{tag:C.heading,fontWeight:wM,color:BY},{tag:[C.typeName,C.className,C.tagName,C.number,C.changed,C.annotation,C.self,C.namespace],color:Nd},{tag:[C.function(C.variableName),C.function(C.propertyName)],color:Nd},{tag:[C.number],color:FY},{tag:[C.operator,C.punctuation,C.separator,C.url,C.escape,C.regexp],color:w5},{tag:[C.regexp],color:MA},{tag:[C.special(C.string),C.string,C.inserted],color:MA},{tag:[C.processingInstruction],color:Nd},{tag:[C.angleBracket],color:Nd},{tag:C.strong,fontWeight:wM},{tag:C.emphasis,fontStyle:"italic"},{tag:C.strikethrough,textDecoration:"line-through"},{tag:[C.meta,C.comment],color:QY},{tag:C.link,color:$A,textDecoration:"underline"},{tag:C.invalid,color:VY},...r]}),ft.theme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"transparent",outline:"1px solid #888888"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"transparent",outline:"1px solid #ff2222"}},{dark:!0})]}const fK=uK();function Gr(){return Gr=Object.assign?Object.assign.bind():function(n){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var r in t)({}).hasOwnProperty.call(t,r)&&(n[r]=t[r])}return n},Gr.apply(null,arguments)}var dK={background:"#272822",foreground:"#FFFFFF",caret:"#FFFFFF",selection:"#49483E",selectionMatch:"#49483E",gutterBackground:"#272822",gutterForeground:"#FFFFFF70",lineHighlight:"#0000003b"},hK=[{tag:[C.comment,C.documentMeta],color:"#8292a2"},{tag:[C.number,C.bool,C.null,C.atom],color:"#ae81ff"},{tag:[C.attributeValue,C.className,C.name],color:"#e6db74"},{tag:[C.propertyName,C.attributeName],color:"#a6e22e"},{tag:[C.variableName],color:"#9effff"},{tag:[C.squareBracket],color:"#bababa"},{tag:[C.string,C.special(C.brace)],color:"#e6db74"},{tag:[C.regexp,C.className,C.typeName,C.definition(C.typeName)],color:"#66d9ef"},{tag:[C.definition(C.variableName),C.definition(C.propertyName),C.function(C.variableName)],color:"#fd971f"},{tag:[C.keyword,C.definitionKeyword,C.modifier,C.tagName,C.angleBracket],color:"#f92672"}],pK=n=>{var{theme:e="dark",settings:t={},styles:r=[]}={};return as({theme:e,settings:Gr({},dK,t),styles:[...hK,...r]})},mK=pK(),gK={background:"#0f0f0f",foreground:"#defdef",caret:"#00FF00",selection:"#515151",selectionMatch:"#515151",gutterBackground:"#555",gutterForeground:"#FFFFFF",lineHighlight:"#0a6bcb3d"},OK=[{tag:C.keyword,color:"darkgoldenrod",fontWeight:"bold"},{tag:C.atom,color:"#77F"},{tag:C.comment,color:"#7a7b7c",fontStyle:"italic"},{tag:C.number,color:"violet"},{tag:C.definition(C.variableName),color:"#fffabc"},{tag:C.variableName,color:"#abcdef"},{tag:C.function(C.variableName),color:"#fffabc"},{tag:C.typeName,color:"#FFDD44"},{tag:C.tagName,color:"#def"},{tag:C.string,color:"#2b4"},{tag:C.meta,color:"#C9F"},{tag:C.bracket,color:"#8a8a8a"},{tag:C.attributeName,color:"#DDFF00"},{tag:C.heading,color:"aquamarine",fontWeight:"bold"},{tag:C.link,color:"blueviolet",fontWeight:"bold"}],vK=n=>{var{theme:e="dark",settings:t={},styles:r=[]}={};return as({theme:e,settings:Gr({},gK,t),styles:[...OK,...r]})},yK=vK(),bK={background:"#282a36",foreground:"#f8f8f2",caret:"#f8f8f0",selection:"rgba(255, 255, 255, 0.1)",selectionMatch:"rgba(255, 255, 255, 0.2)",gutterBackground:"#282a36",gutterForeground:"#6D8A88",gutterBorder:"transparent",lineHighlight:"rgba(255, 255, 255, 0.1)"},SK=[{tag:C.comment,color:"#6272a4"},{tag:C.string,color:"#f1fa8c"},{tag:C.atom,color:"#bd93f9"},{tag:C.meta,color:"#f8f8f2"},{tag:[C.keyword,C.operator,C.tagName],color:"#ff79c6"},{tag:[C.function(C.propertyName),C.propertyName],color:"#66d9ef"},{tag:[C.definition(C.variableName),C.function(C.variableName),C.className,C.attributeName],color:"#50fa7b"},{tag:C.atom,color:"#bd93f9"}],wK=n=>{var{theme:e="dark",settings:t={},styles:r=[]}={};return as({theme:e,settings:Gr({},bK,t),styles:[...SK,...r]})},kK=wK(),PK={background:"#fff",foreground:"#000",caret:"#FFFFFF",selection:"#d7d4f0",selectionMatch:"#d7d4f0",gutterBackground:"#f7f7f7",gutterForeground:"#999",lineHighlight:"#006fff1c",gutterBorder:"transparent"},xK=[{tag:[C.comment],color:"#3F7F5F"},{tag:[C.documentMeta],color:"#FF1717"},{tag:C.keyword,color:"#7F0055",fontWeight:"bold"},{tag:C.atom,color:"#00f"},{tag:C.number,color:"#164"},{tag:C.propertyName,color:"#164"},{tag:[C.variableName,C.definition(C.variableName)],color:"#0000C0"},{tag:C.function(C.variableName),color:"#0000C0"},{tag:C.string,color:"#2A00FF"},{tag:C.operator,color:"black"},{tag:C.tagName,color:"#170"},{tag:C.attributeName,color:"#00c"},{tag:C.link,color:"#219"}],CK=n=>{var{theme:e="light",settings:t={},styles:r=[]}={};return as({theme:e,settings:Gr({},PK,t),styles:[...xK,...r]})},TK=CK(),_K={background:"#fff",foreground:"#24292e",selection:"#BBDFFF",selectionMatch:"#BBDFFF",gutterBackground:"#fff",gutterForeground:"#6e7781"},EK=[{tag:[C.standard(C.tagName),C.tagName],color:"#116329"},{tag:[C.comment,C.bracket],color:"#6a737d"},{tag:[C.className,C.propertyName],color:"#6f42c1"},{tag:[C.variableName,C.attributeName,C.number,C.operator],color:"#005cc5"},{tag:[C.keyword,C.typeName,C.typeOperator,C.typeName],color:"#d73a49"},{tag:[C.string,C.meta,C.regexp],color:"#032f62"},{tag:[C.name,C.quote],color:"#22863a"},{tag:[C.heading,C.strong],color:"#24292e",fontWeight:"bold"},{tag:[C.emphasis],color:"#24292e",fontStyle:"italic"},{tag:[C.deleted],color:"#b31d28",backgroundColor:"ffeef0"},{tag:[C.atom,C.bool,C.special(C.variableName)],color:"#e36209"},{tag:[C.url,C.escape,C.regexp,C.link],color:"#032f62"},{tag:C.link,textDecoration:"underline"},{tag:C.strikethrough,textDecoration:"line-through"},{tag:C.invalid,color:"#cb2431"}],RK=n=>{var{theme:e="light",settings:t={},styles:r=[]}={};return as({theme:e,settings:Gr({},_K,t),styles:[...EK,...r]})};RK();var AK={background:"#0d1117",foreground:"#c9d1d9",caret:"#c9d1d9",selection:"#003d73",selectionMatch:"#003d73",lineHighlight:"#36334280"},MK=[{tag:[C.standard(C.tagName),C.tagName],color:"#7ee787"},{tag:[C.comment,C.bracket],color:"#8b949e"},{tag:[C.className,C.propertyName],color:"#d2a8ff"},{tag:[C.variableName,C.attributeName,C.number,C.operator],color:"#79c0ff"},{tag:[C.keyword,C.typeName,C.typeOperator,C.typeName],color:"#ff7b72"},{tag:[C.string,C.meta,C.regexp],color:"#a5d6ff"},{tag:[C.name,C.quote],color:"#7ee787"},{tag:[C.heading,C.strong],color:"#d2a8ff",fontWeight:"bold"},{tag:[C.emphasis],color:"#d2a8ff",fontStyle:"italic"},{tag:[C.deleted],color:"#ffdcd7",backgroundColor:"ffeef0"},{tag:[C.atom,C.bool,C.special(C.variableName)],color:"#ffab70"},{tag:C.link,textDecoration:"underline"},{tag:C.strikethrough,textDecoration:"line-through"},{tag:C.invalid,color:"#f97583"}],$K=n=>{var{theme:e="dark",settings:t={},styles:r=[]}={};return as({theme:e,settings:Gr({},AK,t),styles:[...MK,...r]})},DK=$K(),QK={background:"#2e3235",foreground:"#bdbdbd",caret:"#a0a4ae",selection:"#d7d4f063",selectionMatch:"#d7d4f063",gutterBackground:"#2e3235",gutterForeground:"#999",gutterActiveForeground:"#4f5b66",lineHighlight:"#545b6130"},IK=[{tag:C.keyword,color:"#cf6edf"},{tag:[C.name,C.deleted,C.character,C.macroName],color:"#56c8d8"},{tag:[C.propertyName],color:"#facf4e"},{tag:[C.variableName],color:"#bdbdbd"},{tag:[C.function(C.variableName)],color:"#56c8d8"},{tag:[C.labelName],color:"#cf6edf"},{tag:[C.color,C.constant(C.name),C.standard(C.name)],color:"#facf4e"},{tag:[C.definition(C.name),C.separator],color:"#fa5788"},{tag:[C.brace],color:"#cf6edf"},{tag:[C.annotation],color:"#ff5f52"},{tag:[C.number,C.changed,C.annotation,C.modifier,C.self,C.namespace],color:"#ffad42"},{tag:[C.typeName,C.className],color:"#ffad42"},{tag:[C.operator,C.operatorKeyword],color:"#7186f0"},{tag:[C.tagName],color:"#99d066"},{tag:[C.squareBracket],color:"#ff5f52"},{tag:[C.angleBracket],color:"#606f7a"},{tag:[C.attributeName],color:"#bdbdbd"},{tag:[C.regexp],color:"#ff5f52"},{tag:[C.quote],color:"#6abf69"},{tag:[C.string],color:"#99d066"},{tag:C.link,color:"#56c8d8",textDecoration:"underline",textUnderlinePosition:"under"},{tag:[C.url,C.escape,C.special(C.string)],color:"#facf4e"},{tag:[C.meta],color:"#707d8b"},{tag:[C.comment],color:"#707d8b",fontStyle:"italic"},{tag:C.monospace,color:"#bdbdbd"},{tag:C.strong,fontWeight:"bold",color:"#ff5f52"},{tag:C.emphasis,fontStyle:"italic",color:"#99d066"},{tag:C.strikethrough,textDecoration:"line-through"},{tag:C.heading,fontWeight:"bold",color:"#facf4e"},{tag:C.heading1,fontWeight:"bold",color:"#facf4e"},{tag:[C.heading2,C.heading3,C.heading4],fontWeight:"bold",color:"#facf4e"},{tag:[C.heading5,C.heading6],color:"#facf4e"},{tag:[C.atom,C.bool,C.special(C.variableName)],color:"#56c8d8"},{tag:[C.processingInstruction,C.inserted],color:"#ff5f52"},{tag:[C.contentSeparator],color:"#56c8d8"},{tag:C.invalid,color:"#606f7a",borderBottom:"1px dotted #ff5f52"}],O3=n=>{var{theme:e="dark",settings:t={},styles:r=[]}=n||{};return as({theme:e,settings:Gr({},QK,t),styles:[...IK,...r]})};O3();var jK=O3(),LK={background:"#FAFAFA",foreground:"#90A4AE",caret:"#272727",selection:"#80CBC440",selectionMatch:"#80CBC440",gutterBackground:"#FAFAFA",gutterForeground:"#90A4AE",gutterBorder:"transparent",lineHighlight:"#CCD7DA50"},NK=[{tag:C.keyword,color:"#39ADB5"},{tag:[C.name,C.deleted,C.character,C.macroName],color:"#90A4AE"},{tag:[C.propertyName],color:"#6182B8"},{tag:[C.processingInstruction,C.string,C.inserted,C.special(C.string)],color:"#91B859"},{tag:[C.function(C.variableName),C.labelName],color:"#6182B8"},{tag:[C.color,C.constant(C.name),C.standard(C.name)],color:"#39ADB5"},{tag:[C.definition(C.name),C.separator],color:"#90A4AE"},{tag:[C.className],color:"#E2931D"},{tag:[C.number,C.changed,C.annotation,C.modifier,C.self,C.namespace],color:"#F76D47"},{tag:[C.typeName],color:"#E2931D",fontStyle:"#E2931D"},{tag:[C.operator,C.operatorKeyword],color:"#39ADB5"},{tag:[C.url,C.escape,C.regexp,C.link],color:"#91B859"},{tag:[C.meta,C.comment],color:"#90A4AE"},{tag:C.strong,fontWeight:"bold"},{tag:C.emphasis,fontStyle:"italic"},{tag:C.link,textDecoration:"underline"},{tag:C.heading,fontWeight:"bold",color:"#39ADB5"},{tag:[C.atom,C.bool,C.special(C.variableName)],color:"#90A4AE"},{tag:C.invalid,color:"#E5393570"},{tag:C.strikethrough,textDecoration:"line-through"}],qK=n=>{var{theme:e="light",settings:t={},styles:r=[]}={};return as({theme:e,settings:Gr({},LK,t),styles:[...NK,...r]})};qK();var UK={background:"#2e3440",foreground:"#FFFFFF",caret:"#FFFFFF",selection:"#00000073",selectionMatch:"#00000073",gutterBackground:"#2e3440",gutterForeground:"#4c566a",gutterActiveForeground:"#d8dee9",lineHighlight:"#4c566a29"},BK=[{tag:C.keyword,color:"#5e81ac"},{tag:[C.name,C.deleted,C.character,C.propertyName,C.macroName],color:"#88c0d0"},{tag:[C.variableName],color:"#8fbcbb"},{tag:[C.function(C.variableName)],color:"#8fbcbb"},{tag:[C.labelName],color:"#81a1c1"},{tag:[C.color,C.constant(C.name),C.standard(C.name)],color:"#5e81ac"},{tag:[C.definition(C.name),C.separator],color:"#a3be8c"},{tag:[C.brace],color:"#8fbcbb"},{tag:[C.annotation],color:"#d30102"},{tag:[C.number,C.changed,C.annotation,C.modifier,C.self,C.namespace],color:"#b48ead"},{tag:[C.typeName,C.className],color:"#ebcb8b"},{tag:[C.operator,C.operatorKeyword],color:"#a3be8c"},{tag:[C.tagName],color:"#b48ead"},{tag:[C.squareBracket],color:"#bf616a"},{tag:[C.angleBracket],color:"#d08770"},{tag:[C.attributeName],color:"#ebcb8b"},{tag:[C.regexp],color:"#5e81ac"},{tag:[C.quote],color:"#b48ead"},{tag:[C.string],color:"#a3be8c"},{tag:C.link,color:"#a3be8c",textDecoration:"underline",textUnderlinePosition:"under"},{tag:[C.url,C.escape,C.special(C.string)],color:"#8fbcbb"},{tag:[C.meta],color:"#88c0d0"},{tag:[C.monospace],color:"#d8dee9",fontStyle:"italic"},{tag:[C.comment],color:"#4c566a",fontStyle:"italic"},{tag:C.strong,fontWeight:"bold",color:"#5e81ac"},{tag:C.emphasis,fontStyle:"italic",color:"#5e81ac"},{tag:C.strikethrough,textDecoration:"line-through"},{tag:C.heading,fontWeight:"bold",color:"#5e81ac"},{tag:C.special(C.heading1),fontWeight:"bold",color:"#5e81ac"},{tag:C.heading1,fontWeight:"bold",color:"#5e81ac"},{tag:[C.heading2,C.heading3,C.heading4],fontWeight:"bold",color:"#5e81ac"},{tag:[C.heading5,C.heading6],color:"#5e81ac"},{tag:[C.atom,C.bool,C.special(C.variableName)],color:"#d08770"},{tag:[C.processingInstruction,C.inserted],color:"#8fbcbb"},{tag:[C.contentSeparator],color:"#ebcb8b"},{tag:C.invalid,color:"#434c5e",borderBottom:"1px dotted #d30102"}],FK=n=>{var{theme:e="dark",settings:t={},styles:r=[]}={};return as({theme:e,settings:Gr({},UK,t),styles:[...BK,...r]})},VK=FK(),WK={background:"#fff",foreground:"#3D3D3D",selection:"#BBDFFF",selectionMatch:"#BBDFFF",gutterBackground:"#fff",gutterForeground:"#AFAFAF",lineHighlight:"#d5e6ff69"},ZK=[{tag:[C.comment,C.quote],color:"#707F8D"},{tag:[C.typeName,C.typeOperator],color:"#aa0d91"},{tag:[C.keyword],color:"#aa0d91",fontWeight:"bold"},{tag:[C.string,C.meta],color:"#D23423"},{tag:[C.name],color:"#032f62"},{tag:[C.typeName],color:"#522BB2"},{tag:[C.variableName],color:"#23575C"},{tag:[C.definition(C.variableName)],color:"#327A9E"},{tag:[C.regexp,C.link],color:"#0e0eff"}];function XK(n){var{theme:e="light",settings:t={},styles:r=[]}={};return as({theme:e,settings:Gr({},WK,t),styles:[...ZK,...r]})}var zK=XK(),YK={background:"#292A30",foreground:"#CECFD0",caret:"#fff",selection:"#727377",selectionMatch:"#727377",lineHighlight:"#ffffff0f"},GK=[{tag:[C.comment,C.quote],color:"#7F8C98"},{tag:[C.keyword],color:"#FF7AB2",fontWeight:"bold"},{tag:[C.string,C.meta],color:"#FF8170"},{tag:[C.typeName],color:"#DABAFF"},{tag:[C.definition(C.variableName)],color:"#6BDFFF"},{tag:[C.name],color:"#6BAA9F"},{tag:[C.variableName],color:"#ACF2E4"},{tag:[C.regexp,C.link],color:"#FF8170"}],HK=n=>{var{theme:e="dark",settings:t={},styles:r=[]}={};return as({theme:e,settings:Gr({},YK,t),styles:[...GK,...r]})};HK();const _k=[{value:yK,label:"abcdef"},{value:kK,label:"dracula"},{value:TK,label:"eclipse"},{value:jK,label:"material"},{value:VK,label:"nord"},{value:DY,label:"oneDark"},{value:mK,label:"okaidia"},{value:DK,label:"github"},{value:zK,label:"xcode"},{value:fK,label:"vizhub"}],v3=_k.reduce((n,e)=>(n[e.label]=e,n),{}),KK="vizhub",JK=(n,e)=>{const t=D.useRef(!0);D.useEffect(()=>{if(t.current)t.current=!1;else for(const r of Array.from(n.values())){const{editor:i,themeCompartment:o}=r;i.dispatch({effects:o.reconfigure([v3[e].value])})}},[e,n])},eJ=n=>{const e=D.useCallback(M=>{n({type:"set_active_file_id",activeFileId:M})},[n]),t=D.useCallback(()=>{n({type:"set_active_file_left"})},[n]),r=D.useCallback(()=>{n({type:"set_active_file_right"})},[n]),i=D.useCallback(M=>{n({type:"open_tab",fileId:M.fileId,isTransient:M.isTransient})},[n]),o=D.useCallback(M=>{n({type:"close_tabs",fileIdsToClose:M})},[n]),s=D.useCallback(M=>{n({type:"set_theme",themeLabel:M})},[n]),a=D.useCallback(M=>{n({type:"set_is_search_open",value:M})},[n]),l=D.useCallback(M=>{n({type:"set_search",value:M})},[n]),c=D.useCallback(M=>{n({type:"set_search_results",files:M})},[n]),u=D.useCallback((M,Q,T)=>{n({type:"set_search_file_visibility",files:M,id:Q,visibility:T})},[n]),d=D.useCallback((M,Q,T)=>{n({type:"hide_search_results_line",files:M,id:Q,line:T})},[n]),h=D.useCallback((M,Q)=>{n({type:"set_active_search_index",focusedIndex:M,childIndex:Q})},[n]),p=D.useCallback(()=>{n({type:"toggle_search_focused"})},[n]),g=D.useCallback(M=>{n({type:"set_is_settings_open",value:M})},[n]),O=D.useCallback(M=>{n({type:"set_is_doc_open",value:M})},[n]),v=D.useCallback(()=>{g(!1)},[g]),b=D.useCallback(()=>{O(!1)},[O]),S=D.useCallback(()=>{n({type:"editor_no_longer_wants_focus"})},[n]),x=D.useCallback(M=>{n({type:"set_username",username:M})},[n]),P=D.useCallback(()=>{n({type:"toggle_auto_follow"})},[n]),w=D.useCallback(M=>{n({type:"update_presence_indicator",presenceIndicator:M})},[n]),E=D.useCallback(()=>{n({type:"split_current_pane"})},[n]);return{setActiveFileId:e,setActiveFileLeft:t,setActiveFileRight:r,openTab:i,closeTabs:o,setTheme:s,setIsSearchOpen:a,setSearch:l,setSearchResults:c,setSearchFileVisibility:u,setSearchLineVisibility:d,setSearchFocusedIndex:h,toggleSearchFocused:p,setIsSettingsOpen:g,setIsDocOpen:O,closeSettings:v,closeDoc:b,editorNoLongerWantsFocus:S,setUsername:x,toggleAutoFollow:P,updatePresenceIndicator:w,splitCurrentPane:E}},zh=(n,e)=>n+"|"+e,tJ=()=>D.useRef(new Map).current,nJ=8,Ek=()=>{let n="";for(let e=0;e<nJ;e++)n+=Math.floor(Math.random()*10);return n},rJ=({submitOperation:n,closeTabs:e,openTab:t})=>{const r=D.useCallback((c,u="")=>{if(c){const d=Ek();n(h=>({...h,files:{...h.files,[d]:{name:c,text:u}}})),t({fileId:d,isTransient:!1})}},[n]),i=D.useCallback((c,u=null)=>{if(c){c+="/";const d=Ek();n(h=>({...h,files:{...h.files,[d]:{name:c,text:u}}}))}},[n]),o=D.useCallback((c,u)=>{n(d=>({...d,files:{...d.files,[c]:{...d.files[c],name:d.files[c].name.substring(0,d.files[c].name.lastIndexOf("/")+1)+u}}}))},[n]),s=D.useCallback((c,u,d)=>{console.log(c),console.log(u),n(h=>{const p=Object.keys(h.files).reduce((g,O)=>{const v=h.files[O],b=v.name;if(b.includes(c+"/")){const x=b.substring(0,b.indexOf(c)+c.length).lastIndexOf(u),P=b.substring(0,x)+d+b.substring(x+u.length);g[O]={...v,name:P}}else g[O]=v;return g},{});return{...h,files:p}})},[n]),a=D.useCallback(c=>{e([c]),n(u=>{const d={...u.files};return delete d[c],{...u,files:d}})},[n,e]),l=D.useCallback(c=>{const u=[];n(d=>{const h={...d.files};for(const p in h)h[p].name.includes(c+"/")&&(u.push(p),delete h[p]);return{...d,files:h}}),e(u)},[n,e]);return{createFile:r,renameFile:o,deleteFile:a,createDirectory:i,renameDirectory:s,deleteDirectory:l}},iJ=n=>{const t=/Mac|iMac|MacBook/i.test(navigator.userAgent)?n.metaKey:n.ctrlKey;return t&&n.key==="s"?!0:!!(n.key==="F5"||t&&n.key==="Enter"||n.shiftKey&&n.key==="Enter"||n.altKey&&n.key==="Enter"||t&&n.shiftKey&&(n.key==="B"||n.key==="b")||t&&n.shiftKey&&n.key==="F10"||n.key==="F8"||n.key==="F9")};let Ss=null,Xm=null;const y3=new Set(["FunctionDeclaration","ClassDeclaration","MethodDeclaration","Block","IfStatement","ForStatement","WhileStatement","SwitchStatement","TryStatement","CatchClause","WithStatement","ArrowFunction","ImportGroup"]),oJ=new Set(["VariableDeclaration","FunctionDeclaration","ClassDeclaration","MethodDeclaration","PropertyDeclaration","ImportDeclaration","ExportDeclaration","CallExpression","ArrayPattern","ObjectPattern","PatternProperty","ArgList","TypeArgList","ParamList","ForOfSpec"]);function kM(n){let e=n,t=0;for(;e&&e.type;){const r=e.type.name;y3.has(r)&&t++,e=e.parent}return t}function sJ(n,e){const t=n.state,r=[],i=e,o=t.doc.sliceString(i.from,i.to),s=kM(i);if(i){if(br(t).iterate({enter(a){if(oJ.has(a.name)||y3.has(a.name)){const l=a.node;[...l.getChildren("VariableDefinition"),...l.getChildren("PropertyDefinition"),...l.getChildren("PropertyName"),...l.getChildren("Identifier")].forEach(u=>{t.doc.sliceString(u.from,u.to)===o&&u.type.id!==i.type.id&&r.push({identifier:u,context:kM(u)})})}}}),r.length>0){r.sort((l,c)=>l.context-c.context);let a=r[0].identifier;for(let l=r.length-1;l>=0;l--)if(r[l].context<=s){a=r[l].identifier;break}return a}return null}}const PM={E:"files-icon",F:"search-icon",K:"shortcut-icon",B:"bug-icon",S:"settings-icon",N:"new-file-icon",D:"new-directory-icon",A:"auto-focus-icon"},aJ=({closeTabs:n,activeFileId:e,activePaneId:t,handleOpenCreateFileModal:r,setActiveFileLeft:i,setActiveFileRight:o,toggleSearchFocused:s,runPrettierRef:a,runCodeRef:l,sidebarRef:c,editorCache:u,codeEditorRef:d})=>{D.useEffect(()=>{const h=zh(e,t),p=S=>{var x,P;if(iJ(S)){S.preventDefault();const w=a.current;w!==null&&w();const E=l.current;E!==null&&E();return}if(S.ctrlKey&&S.shiftKey?((x=document.getElementById(PM[S.key]))==null||x.click(),S.key==="F"&&s()):S.ctrlKey&&S.key===","&&((P=document.getElementById(PM.S))==null||P.click()),S.ctrlKey===!0&&document.addEventListener("mouseover",b),S.altKey===!0){if(S.key==="w"){e&&n([e]);return}if(S.key==="n"){r();return}if(S.key==="PageUp"){i();return}if(S.key==="PageDown"){o();return}S.key==="1"&&c.current&&c.current.focus(),S.key==="2"&&d.current&&d.current.focus()}},g=()=>{Ss&&(Ss.style.cursor="initial",Ss.style.textDecoration="none",Ss=Xm=null),document.removeEventListener("mouseover",b),document.removeEventListener("mousedown",O)},O=S=>{if(!Xm||S.target!==Ss||!e)return;const x=u.get(h).editor,P=Xm;x.dispatch({selection:{anchor:P.from,head:P.to},scrollIntoView:!0,effects:ft.scrollIntoView(P.from,{y:"center"})}),g()},v=S=>{S.ctrlKey||g()},b=S=>{if(!e)return;const x=u.get(h).editor,P=br(x.state),w=S.target;if(w==null||!x.dom.contains(w))return;const E=x.posAtDOM(w),M=P.resolveInner(E,1);if(M&&w instanceof HTMLSpanElement){const Q=sJ(x,M);Q&&M.type.id!==Q.type.id&&(Ss&&(Ss.style.cursor="initial",Ss.style.textDecoration="none"),Ss=w,Xm=Q,Ss.style.cursor="pointer",Ss.style.textDecoration="underline",document.addEventListener("mousedown",O,{once:!0}))}};return document.addEventListener("keydown",p),document.addEventListener("keyup",v),()=>{document.removeEventListener("keydown",p),document.removeEventListener("keyup",v)}},[r,n,e,i,o])},lJ=()=>{const[n,e]=D.useState(new Set),t=D.useCallback(i=>n.has(i),[n]),r=D.useCallback(i=>{const o=new Set(n);t(i)?o.delete(i):o.add(i),e(o)},[n,t]);return{isDirectoryOpen:t,toggleDirectory:r}},cJ=1200,uJ=n=>{const e=n.match(/\.([^.]+)$/);return e?e[1]:""},fJ=({shareDBDoc:n,submitOperation:e,prettierWorker:t})=>{const r=D.useRef(new Set),[i,o]=D.useState(null),s=D.useRef(!1),a=D.useRef(null);return D.useEffect(()=>{if(!n)return;const l=d=>{const{fileId:h,error:p,fileTextPrettified:g}=d.data;if(p){o(p);return}else o(null);s.current=!0,e(O=>({...O,files:{...O.files,[h]:{...O.files[h],text:g}}})),s.current=!1};t.addEventListener("message",l);const c=async()=>{const h=n.data.files,p=r.current,g=Array.from(p);p.clear();for(const O of g){const v=h[O],b={fileText:v.text,fileExtension:uJ(v.name),fileId:O};t.postMessage(b)}};a.current=c;const u=d=>{if(!s.current&&d&&d.length===4&&d[0]==="files"&&typeof d[1]=="string"&&d[2]==="text"){const h=d[1];r.current.add(h)}};return n.on("op batch",u),()=>{t.removeEventListener("message",l),n.removeListener("op batch",u)}},[n]),{prettierError:i,runPrettierRef:a}},dJ=n=>{const e=D.useRef(null);return D.useEffect(()=>{const t=()=>{n(r=>({...r,isInteracting:!0})),setTimeout(()=>{n(({isInteracting:r,...i})=>i)},0)};e.current=t},[n]),e},hJ=500,pJ=cJ+hJ,mJ=({content:n,typeScriptWorker:e})=>{const t=D.useRef(null),r=D.useCallback(i=>{i!==null&&(clearTimeout(t.current),t.current=window.setTimeout(()=>{e.postMessage({event:"update-content",details:i})},pJ))},[e]);D.useEffect(()=>{r(n)},[n])},b3="~",xM=(n,e)=>{if(n&&n.files){for(const t of Object.keys(n.files))if(n.files[t].name===e)return t}return null},CM=(n,e)=>{if(n&&n.files){const t=n.files[e];if(t)return t.name}return null},gJ=({tabStateParams:n,content:e})=>{const{file:t,tabs:r}=n,i=[],o=xM(e,t);return r?r.split(b3).forEach(s=>{const a=xM(e,s);a&&i.push({fileId:a})}):o&&i.push({fileId:o}),{tabList:i,activeFileId:o}},OJ=({tabList:n,activeFileId:e,content:t})=>{const r=CM(t,e),i={};if(r&&(i.file=r,n.length>1)){const o=n.map(s=>CM(t,s.fileId)).join(b3);i.tabs=o}return i};var S3=-1,w3=-2,k3=-3,P3=-4,kx=-5,x3=-6,C3=-7,T3="B",_3="D",kf="E",Rk="M",E3="N",Pf="P",R3="R",Ak="S",A3="Y",M3="U",Mk="Z",$3=class{constructor(){hi(this,"promise");hi(this,"resolve");hi(this,"reject");this.promise=new Promise((e,t)=>{this.resolve=e,this.reject=t})}};function vJ(){const n=new TextDecoder;let e="";return new TransformStream({transform(t,r){const i=n.decode(t,{stream:!0}),o=(e+i).split(`
|
|
128
|
+
`);e=o.pop()||"";for(const s of o)r.enqueue(s)},flush(t){e&&t.enqueue(e)}})}function Zo(n){const{indices:e}=this,t=e.get(n);if(t)return[t];if(n===void 0)return C3;if(n===null)return kx;if(Number.isNaN(n))return w3;if(n===Number.POSITIVE_INFINITY)return x3;if(n===Number.NEGATIVE_INFINITY)return k3;if(n===0&&1/n<0)return P3;const r=this.index++;return e.set(n,r),yJ.call(this,n,r),r}function yJ(n,e){const{deferred:t,plugins:r,postPlugins:i}=this,o=this.stringified,s=[[n,e]];for(;s.length>0;){const[a,l]=s.pop(),c=d=>Object.keys(d).map(h=>`"_${Zo.call(this,h)}":${Zo.call(this,d[h])}`).join(",");let u=null;switch(typeof a){case"boolean":case"number":case"string":o[l]=JSON.stringify(a);break;case"bigint":o[l]=`["${T3}","${a}"]`;break;case"symbol":{const d=Symbol.keyFor(a);d?o[l]=`["${A3}",${JSON.stringify(d)}]`:u=new Error("Cannot encode symbol unless created with Symbol.for()");break}case"object":{if(!a){o[l]=`${kx}`;break}const d=Array.isArray(a);let h=!1;if(!d&&r)for(const p of r){const g=p(a);if(Array.isArray(g)){h=!0;const[O,...v]=g;o[l]=`[${JSON.stringify(O)}`,v.length>0&&(o[l]+=`,${v.map(b=>Zo.call(this,b)).join(",")}`),o[l]+="]";break}}if(!h){let p=d?"[":"{";if(d){for(let g=0;g<a.length;g++)p+=(g?",":"")+(g in a?Zo.call(this,a[g]):S3);o[l]=`${p}]`}else a instanceof Date?o[l]=`["${_3}",${a.getTime()}]`:a instanceof URL?o[l]=`["${M3}",${JSON.stringify(a.href)}]`:a instanceof RegExp?o[l]=`["${R3}",${JSON.stringify(a.source)},${JSON.stringify(a.flags)}]`:a instanceof Set?a.size>0?o[l]=`["${Ak}",${[...a].map(g=>Zo.call(this,g)).join(",")}]`:o[l]=`["${Ak}"]`:a instanceof Map?a.size>0?o[l]=`["${Rk}",${[...a].flatMap(([g,O])=>[Zo.call(this,g),Zo.call(this,O)]).join(",")}]`:o[l]=`["${Rk}"]`:a instanceof Promise?(o[l]=`["${Pf}",${l}]`,t[l]=a):a instanceof Error?(o[l]=`["${kf}",${JSON.stringify(a.message)}`,a.name!=="Error"&&(o[l]+=`,${JSON.stringify(a.name)}`),o[l]+="]"):Object.getPrototypeOf(a)===null?o[l]=`["${E3}",{${c(a)}}]`:SJ(a)?o[l]=`{${c(a)}}`:u=new Error("Cannot encode object with prototype")}break}default:{const d=Array.isArray(a);let h=!1;if(!d&&r)for(const p of r){const g=p(a);if(Array.isArray(g)){h=!0;const[O,...v]=g;o[l]=`[${JSON.stringify(O)}`,v.length>0&&(o[l]+=`,${v.map(b=>Zo.call(this,b)).join(",")}`),o[l]+="]";break}}h||(u=new Error("Cannot encode function or unexpected type"))}}if(u){let d=!1;if(i)for(const h of i){const p=h(a);if(Array.isArray(p)){d=!0;const[g,...O]=p;o[l]=`[${JSON.stringify(g)}`,O.length>0&&(o[l]+=`,${O.map(v=>Zo.call(this,v)).join(",")}`),o[l]+="]";break}}if(!d)throw u}}}var bJ=Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function SJ(n){const e=Object.getPrototypeOf(n);return e===Object.prototype||e===null||Object.getOwnPropertyNames(e).sort().join("\0")===bJ}var sS=typeof window<"u"?window:typeof globalThis<"u"?globalThis:void 0;function $k(n){const{hydrated:e,values:t}=this;if(typeof n=="number")return TM.call(this,n);if(!Array.isArray(n)||!n.length)throw new SyntaxError;const r=t.length;for(const i of n)t.push(i);return e.length=t.length,TM.call(this,r)}function TM(n){const{hydrated:e,values:t,deferred:r,plugins:i}=this;let o;const s=[[n,l=>{o=l}]];let a=[];for(;s.length>0;){const[l,c]=s.pop();switch(l){case C3:c(void 0);continue;case kx:c(null);continue;case w3:c(NaN);continue;case x3:c(1/0);continue;case k3:c(-1/0);continue;case P3:c(-0);continue}if(e[l]){c(e[l]);continue}const u=t[l];if(!u||typeof u!="object"){e[l]=u,c(u);continue}if(Array.isArray(u))if(typeof u[0]=="string"){const[d,h,p]=u;switch(d){case _3:c(e[l]=new Date(h));continue;case M3:c(e[l]=new URL(h));continue;case T3:c(e[l]=BigInt(h));continue;case R3:c(e[l]=new RegExp(h,p));continue;case A3:c(e[l]=Symbol.for(h));continue;case Ak:const g=new Set;e[l]=g;for(let P=1;P<u.length;P++)s.push([u[P],w=>{g.add(w)}]);c(g);continue;case Rk:const O=new Map;e[l]=O;for(let P=1;P<u.length;P+=2){const w=[];s.push([u[P+1],E=>{w[1]=E}]),s.push([u[P],E=>{w[0]=E}]),a.push(()=>{O.set(w[0],w[1])})}c(O);continue;case E3:const v=Object.create(null);e[l]=v;for(const P of Object.keys(h).reverse()){const w=[];s.push([h[P],E=>{w[1]=E}]),s.push([Number(P.slice(1)),E=>{w[0]=E}]),a.push(()=>{v[w[0]]=w[1]})}c(v);continue;case Pf:if(e[h])c(e[l]=e[h]);else{const P=new $3;r[h]=P,c(e[l]=P.promise)}continue;case kf:const[,b,S]=u;let x=S&&sS&&sS[S]?new sS[S](b):new Error(b);e[l]=x,c(x);continue;case Mk:c(e[l]=e[h]);continue;default:if(Array.isArray(i)){const P=[],w=u.slice(1);for(let E=0;E<w.length;E++){const M=w[E];s.push([M,Q=>{P[E]=Q}])}a.push(()=>{for(const E of i){const M=E(u[0],...P);if(M){c(e[l]=M.value);return}}throw new SyntaxError});continue}throw new SyntaxError}}else{const d=[];e[l]=d;for(let h=0;h<u.length;h++){const p=u[h];p!==S3&&s.push([p,g=>{d[h]=g}])}c(d);continue}else{const d={};e[l]=d;for(const h of Object.keys(u).reverse()){const p=[];s.push([u[h],g=>{p[1]=g}]),s.push([Number(h.slice(1)),g=>{p[0]=g}]),a.push(()=>{d[p[0]]=p[1]})}c(d);continue}}for(;a.length>0;)a.pop()();return o}async function wJ(n,e){const{plugins:t}=e??{},r=new $3,i=n.pipeThrough(vJ()).getReader(),o={values:[],hydrated:[],deferred:{},plugins:t},s=await kJ.call(o,i);let a=r.promise;return s.done?r.resolve():a=PJ.call(o,i).then(r.resolve).catch(l=>{for(const c of Object.values(o.deferred))c.reject(l);r.reject(l)}),{done:a.then(()=>i.closed),value:s.value}}async function kJ(n){const e=await n.read();if(!e.value)throw new SyntaxError;let t;try{t=JSON.parse(e.value)}catch{throw new SyntaxError}return{done:e.done,value:$k.call(this,t)}}async function PJ(n){let e=await n.read();for(;!e.done;){if(!e.value)continue;const t=e.value;switch(t[0]){case Pf:{const r=t.indexOf(":"),i=Number(t.slice(1,r)),o=this.deferred[i];if(!o)throw new Error(`Deferred ID ${i} not found in stream`);const s=t.slice(r+1);let a;try{a=JSON.parse(s)}catch{throw new SyntaxError}const l=$k.call(this,a);o.resolve(l);break}case kf:{const r=t.indexOf(":"),i=Number(t.slice(1,r)),o=this.deferred[i];if(!o)throw new Error(`Deferred ID ${i} not found in stream`);const s=t.slice(r+1);let a;try{a=JSON.parse(s)}catch{throw new SyntaxError}const l=$k.call(this,a);o.reject(l);break}default:throw new SyntaxError}e=await n.read()}}function xJ(n,e){const{plugins:t,postPlugins:r,signal:i}=e??{},o={deferred:{},index:0,indices:new Map,stringified:[],plugins:t,postPlugins:r,signal:i},s=new TextEncoder;let a=0;return new ReadableStream({async start(c){const u=Zo.call(o,n);if(Array.isArray(u))throw new Error("This should never happen");u<0?c.enqueue(s.encode(`${u}
|
|
129
129
|
`)):(c.enqueue(s.encode(`[${o.stringified.join(",")}]
|
|
130
|
-
`)),a=o.stringified.length-1);const d=new WeakSet;for(;Object.keys(o.deferred).length>0;){for(const[h,p]of Object.entries(o.deferred))d.has(p)||d.add(o.deferred[Number(h)]=
|
|
130
|
+
`)),a=o.stringified.length-1);const d=new WeakSet;for(;Object.keys(o.deferred).length>0;){for(const[h,p]of Object.entries(o.deferred))d.has(p)||d.add(o.deferred[Number(h)]=CJ(p,o.signal).then(g=>{const O=Zo.call(o,g);if(Array.isArray(O))c.enqueue(s.encode(`${Pf}${h}:[["${Mk}",${O[0]}]]
|
|
131
131
|
`)),o.index++,a++;else if(O<0)c.enqueue(s.encode(`${Pf}${h}:${O}
|
|
132
132
|
`));else{const v=o.stringified.slice(a+1).join(",");c.enqueue(s.encode(`${Pf}${h}:[${v}]
|
|
133
133
|
`)),a=o.stringified.length-1}},g=>{(!g||typeof g!="object"||!(g instanceof Error))&&(g=new Error("An unknown error occurred"));const O=Zo.call(o,g);if(Array.isArray(O))c.enqueue(s.encode(`${kf}${h}:[["${Mk}",${O[0]}]]
|
|
134
134
|
`)),o.index++,a++;else if(O<0)c.enqueue(s.encode(`${kf}${h}:${O}
|
|
135
135
|
`));else{const v=o.stringified.slice(a+1).join(",");c.enqueue(s.encode(`${kf}${h}:[${v}]
|
|
136
|
-
`)),a=o.stringified.length-1}}).finally(()=>{delete o.deferred[Number(h)]}));await Promise.race(Object.values(o.deferred))}await Promise.all(Object.values(o.deferred)),c.close()}})}function
|
|
136
|
+
`)),a=o.stringified.length-1}}).finally(()=>{delete o.deferred[Number(h)]}));await Promise.race(Object.values(o.deferred))}await Promise.all(Object.values(o.deferred)),c.close()}})}function CJ(n,e){if(!e)return n;if(e.aborted)return Promise.reject(e.reason||new Error("Signal was aborted."));const t=new Promise((r,i)=>{e.addEventListener("abort",o=>{i(e.reason||new Error("Signal was aborted."))}),n.then(r).catch(i)});return t.catch(()=>{}),Promise.race([t,n])}var Ud={},_M;function TJ(){if(_M)return Ud;_M=1,Object.defineProperty(Ud,"__esModule",{value:!0}),Ud.parse=s,Ud.serialize=c;const n=/^[\u0021-\u003A\u003C\u003E-\u007E]+$/,e=/^[\u0021-\u003A\u003C-\u007E]*$/,t=/^([.]?[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)([.][a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)*$/i,r=/^[\u0020-\u003A\u003D-\u007E]*$/,i=Object.prototype.toString,o=(()=>{const h=function(){};return h.prototype=Object.create(null),h})();function s(h,p){const g=new o,O=h.length;if(O<2)return g;const v=(p==null?void 0:p.decode)||u;let b=0;do{const S=h.indexOf("=",b);if(S===-1)break;const x=h.indexOf(";",b),P=x===-1?O:x;if(S>P){b=h.lastIndexOf(";",S-1)+1;continue}const w=a(h,b,S),E=l(h,S,w),M=h.slice(w,E);if(g[M]===void 0){let Q=a(h,S+1,P),T=l(h,P,Q);const R=v(h.slice(Q,T));g[M]=R}b=P+1}while(b<O);return g}function a(h,p,g){do{const O=h.charCodeAt(p);if(O!==32&&O!==9)return p}while(++p<g);return g}function l(h,p,g){for(;p>g;){const O=h.charCodeAt(--p);if(O!==32&&O!==9)return p+1}return g}function c(h,p,g){const O=(g==null?void 0:g.encode)||encodeURIComponent;if(!n.test(h))throw new TypeError(`argument name is invalid: ${h}`);const v=O(p);if(!e.test(v))throw new TypeError(`argument val is invalid: ${p}`);let b=h+"="+v;if(!g)return b;if(g.maxAge!==void 0){if(!Number.isInteger(g.maxAge))throw new TypeError(`option maxAge is invalid: ${g.maxAge}`);b+="; Max-Age="+g.maxAge}if(g.domain){if(!t.test(g.domain))throw new TypeError(`option domain is invalid: ${g.domain}`);b+="; Domain="+g.domain}if(g.path){if(!r.test(g.path))throw new TypeError(`option path is invalid: ${g.path}`);b+="; Path="+g.path}if(g.expires){if(!d(g.expires)||!Number.isFinite(g.expires.valueOf()))throw new TypeError(`option expires is invalid: ${g.expires}`);b+="; Expires="+g.expires.toUTCString()}if(g.httpOnly&&(b+="; HttpOnly"),g.secure&&(b+="; Secure"),g.partitioned&&(b+="; Partitioned"),g.priority)switch(typeof g.priority=="string"?g.priority.toLowerCase():void 0){case"low":b+="; Priority=Low";break;case"medium":b+="; Priority=Medium";break;case"high":b+="; Priority=High";break;default:throw new TypeError(`option priority is invalid: ${g.priority}`)}if(g.sameSite)switch(typeof g.sameSite=="string"?g.sameSite.toLowerCase():g.sameSite){case!0:case"strict":b+="; SameSite=Strict";break;case"lax":b+="; SameSite=Lax";break;case"none":b+="; SameSite=None";break;default:throw new TypeError(`option sameSite is invalid: ${g.sameSite}`)}return b}function u(h){if(h.indexOf("%")===-1)return h;try{return decodeURIComponent(h)}catch{return h}}function d(h){return i.call(h)==="[object Date]"}return Ud}var EM=TJ(),Nu={exports:{}},RM;function _J(){if(RM)return Nu.exports;RM=1;var n={decodeValues:!0,map:!1,silent:!1};function e(s){return typeof s=="string"&&!!s.trim()}function t(s,a){var l=s.split(";").filter(e),c=l.shift(),u=r(c),d=u.name,h=u.value;a=a?Object.assign({},n,a):n;try{h=a.decodeValues?decodeURIComponent(h):h}catch(g){console.error("set-cookie-parser encountered an error while decoding a cookie with value '"+h+"'. Set options.decodeValues to false to disable this feature.",g)}var p={name:d,value:h};return l.forEach(function(g){var O=g.split("="),v=O.shift().trimLeft().toLowerCase(),b=O.join("=");v==="expires"?p.expires=new Date(b):v==="max-age"?p.maxAge=parseInt(b,10):v==="secure"?p.secure=!0:v==="httponly"?p.httpOnly=!0:v==="samesite"?p.sameSite=b:v==="partitioned"?p.partitioned=!0:p[v]=b}),p}function r(s){var a="",l="",c=s.split("=");return c.length>1?(a=c.shift(),l=c.join("=")):l=s,{name:a,value:l}}function i(s,a){if(a=a?Object.assign({},n,a):n,!s)return a.map?{}:[];if(s.headers)if(typeof s.headers.getSetCookie=="function")s=s.headers.getSetCookie();else if(s.headers["set-cookie"])s=s.headers["set-cookie"];else{var l=s.headers[Object.keys(s.headers).find(function(u){return u.toLowerCase()==="set-cookie"})];!l&&s.headers.cookie&&!a.silent&&console.warn("Warning: set-cookie-parser appears to have been called on a request object. It is designed to parse Set-Cookie headers from responses, not Cookie headers from requests. Set the option {silent: true} to suppress this warning."),s=l}if(Array.isArray(s)||(s=[s]),a.map){var c={};return s.filter(e).reduce(function(u,d){var h=t(d,a);return u[h.name]=h,u},c)}else return s.filter(e).map(function(u){return t(u,a)})}function o(s){if(Array.isArray(s))return s;if(typeof s!="string")return[];var a=[],l=0,c,u,d,h,p;function g(){for(;l<s.length&&/\s/.test(s.charAt(l));)l+=1;return l<s.length}function O(){return u=s.charAt(l),u!=="="&&u!==";"&&u!==","}for(;l<s.length;){for(c=l,p=!1;g();)if(u=s.charAt(l),u===","){for(d=l,l+=1,g(),h=l;l<s.length&&O();)l+=1;l<s.length&&s.charAt(l)==="="?(p=!0,l=h,a.push(s.substring(c,d)),c=l):l=d+1}else l+=1;(!p||l>=s.length)&&a.push(s.substring(c,s.length))}return a}return Nu.exports=i,Nu.exports.parse=i,Nu.exports.parseString=t,Nu.exports.splitCookiesString=o,Nu.exports}var EJ=_J();/**
|
|
137
137
|
* react-router v7.4.1
|
|
138
138
|
*
|
|
139
139
|
* Copyright (c) Remix Software Inc.
|
|
@@ -142,33 +142,33 @@ a=extmap-allow-mixed`)!==-1){const o=i.sdp.split(`
|
|
|
142
142
|
* LICENSE.md file in the root directory of this source tree.
|
|
143
143
|
*
|
|
144
144
|
* @license MIT
|
|
145
|
-
*/var $3=n=>{throw TypeError(n)},_J=(n,e,t)=>e.has(n)||$3("Cannot "+t),aS=(n,e,t)=>(_J(n,e,"read from private field"),t?t.call(n):e.get(n)),EJ=(n,e,t)=>e.has(n)?$3("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(n):e.set(n,t),D3=(n=>(n.Pop="POP",n.Push="PUSH",n.Replace="REPLACE",n))(D3||{}),EM="popstate";function Q3(n={}){let{initialEntries:e=["/"],initialIndex:t,v5Compat:r=!1}=n,i;i=e.map((p,g)=>u(p,typeof p=="string"?null:p.state,g===0?"default":void 0));let o=l(t??i.length-1),s="POP",a=null;function l(p){return Math.min(Math.max(p,0),i.length-1)}function c(){return i[o]}function u(p,g=null,O){let v=Fa(i?c().pathname:"/",p,g,O);return yr(v.pathname.charAt(0)==="/",`relative pathnames are not supported in memory history: ${JSON.stringify(p)}`),v}function d(p){return typeof p=="string"?p:Yi(p)}return{get index(){return o},get action(){return s},get location(){return c()},createHref:d,createURL(p){return new URL(d(p),"http://localhost")},encodeLocation(p){let g=typeof p=="string"?jo(p):p;return{pathname:g.pathname||"",search:g.search||"",hash:g.hash||""}},push(p,g){s="PUSH";let O=u(p,g);o+=1,i.splice(o,i.length,O),r&&a&&a({action:s,location:O,delta:1})},replace(p,g){s="REPLACE";let O=u(p,g);i[o]=O,r&&a&&a({action:s,location:O,delta:0})},go(p){s="POP";let g=l(o+p),O=i[g];o=g,a&&a({action:s,location:O,delta:p})},listen(p){return a=p,()=>{a=null}}}}function dy(n={}){function e(r,i){let{pathname:o,search:s,hash:a}=r.location;return Fa("",{pathname:o,search:s,hash:a},i.state&&i.state.usr||null,i.state&&i.state.key||"default")}function t(r,i){return typeof i=="string"?i:Yi(i)}return j3(e,t,null,n)}function I3(n={}){function e(i,o){let{pathname:s="/",search:a="",hash:l=""}=jo(i.location.hash.substring(1));return!s.startsWith("/")&&!s.startsWith(".")&&(s="/"+s),Fa("",{pathname:s,search:a,hash:l},o.state&&o.state.usr||null,o.state&&o.state.key||"default")}function t(i,o){let s=i.document.querySelector("base"),a="";if(s&&s.getAttribute("href")){let l=i.location.href,c=l.indexOf("#");a=c===-1?l:l.slice(0,c)}return a+"#"+(typeof o=="string"?o:Yi(o))}function r(i,o){yr(i.pathname.charAt(0)==="/",`relative pathnames are not supported in hash history.push(${JSON.stringify(o)})`)}return j3(e,t,r,n)}function zt(n,e){if(n===!1||n===null||typeof n>"u")throw new Error(e)}function yr(n,e){if(!n){typeof console<"u"&&console.warn(e);try{throw new Error(e)}catch{}}}function RJ(){return Math.random().toString(36).substring(2,10)}function RM(n,e){return{usr:n.state,key:n.key,idx:e}}function Fa(n,e,t=null,r){return{pathname:typeof n=="string"?n:n.pathname,search:"",hash:"",...typeof e=="string"?jo(e):e,state:t,key:e&&e.key||r||RJ()}}function Yi({pathname:n="/",search:e="",hash:t=""}){return e&&e!=="?"&&(n+=e.charAt(0)==="?"?e:"?"+e),t&&t!=="#"&&(n+=t.charAt(0)==="#"?t:"#"+t),n}function jo(n){let e={};if(n){let t=n.indexOf("#");t>=0&&(e.hash=n.substring(t),n=n.substring(0,t));let r=n.indexOf("?");r>=0&&(e.search=n.substring(r),n=n.substring(0,r)),n&&(e.pathname=n)}return e}function j3(n,e,t,r={}){let{window:i=document.defaultView,v5Compat:o=!1}=r,s=i.history,a="POP",l=null,c=u();c==null&&(c=0,s.replaceState({...s.state,idx:c},""));function u(){return(s.state||{idx:null}).idx}function d(){a="POP";let v=u(),b=v==null?null:v-c;c=v,l&&l({action:a,location:O.location,delta:b})}function h(v,b){a="PUSH";let S=Fa(O.location,v,b);t&&t(S,v),c=u()+1;let x=RM(S,c),P=O.createHref(S);try{s.pushState(x,"",P)}catch(w){if(w instanceof DOMException&&w.name==="DataCloneError")throw w;i.location.assign(P)}o&&l&&l({action:a,location:O.location,delta:1})}function p(v,b){a="REPLACE";let S=Fa(O.location,v,b);t&&t(S,v),c=u();let x=RM(S,c),P=O.createHref(S);s.replaceState(x,"",P),o&&l&&l({action:a,location:O.location,delta:0})}function g(v){let b=i.location.origin!=="null"?i.location.origin:i.location.href,S=typeof v=="string"?v:Yi(v);return S=S.replace(/ $/,"%20"),zt(b,`No window.location.(origin|href) available to create URL for href: ${S}`),new URL(S,b)}let O={get action(){return a},get location(){return n(i,s)},listen(v){if(l)throw new Error("A history only accepts one active listener");return i.addEventListener(EM,d),l=v,()=>{i.removeEventListener(EM,d),l=null}},createHref(v){return e(i,v)},createURL:g,encodeLocation(v){let b=g(v);return{pathname:b.pathname,search:b.search,hash:b.hash}},push:h,replace:p,go(v){return s.go(v)}};return O}function AJ(n){return{defaultValue:n}}var fh,Ll=class{constructor(n){if(EJ(this,fh,new Map),n)for(let[e,t]of n)this.set(e,t)}get(n){if(aS(this,fh).has(n))return aS(this,fh).get(n);if(n.defaultValue!==void 0)return n.defaultValue;throw new Error("No value found for context")}set(n,e){aS(this,fh).set(n,e)}};fh=new WeakMap;var AM=new Set(["lazy","caseSensitive","path","id","index","unstable_middleware","unstable_lazyMiddleware","children"]);function MJ(n){return n.index===!0}function ou(n,e,t=[],r={}){return n.map((i,o)=>{let s=[...t,String(o)],a=typeof i.id=="string"?i.id:s.join("-");if(zt(i.index!==!0||!i.children,"Cannot specify children on an index route"),zt(!r[a],`Found a route id collision on id "${a}". Route id's must be globally unique within Data Router usages`),MJ(i)){let l={...i,...e(i),id:a};return r[a]=l,l}else{let l={...i,...e(i),id:a,children:void 0};return r[a]=l,i.children&&(l.children=ou(i.children,e,s,r)),l}})}function ho(n,e,t="/"){return QO(n,e,t,!1)}function QO(n,e,t,r){let i=typeof e=="string"?jo(e):e,o=vi(i.pathname||"/",t);if(o==null)return null;let s=N3(n);$J(s);let a=null;for(let l=0;a==null&&l<s.length;++l){let c=U3(o);a=BJ(s[l],c,r)}return a}function L3(n,e){let{route:t,pathname:r,params:i}=n;return{id:t.id,pathname:r,params:i,data:e[t.id],handle:t.handle}}function N3(n,e=[],t=[],r=""){let i=(o,s,a)=>{let l={relativePath:a===void 0?o.path||"":a,caseSensitive:o.caseSensitive===!0,childrenIndex:s,route:o};l.relativePath.startsWith("/")&&(zt(l.relativePath.startsWith(r),`Absolute route path "${l.relativePath}" nested under path "${r}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),l.relativePath=l.relativePath.slice(r.length));let c=ca([r,l.relativePath]),u=t.concat(l);o.children&&o.children.length>0&&(zt(o.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${c}".`),N3(o.children,e,u,c)),!(o.path==null&&!o.index)&&e.push({path:c,score:qJ(c,o.index),routesMeta:u})};return n.forEach((o,s)=>{var a;if(o.path===""||!((a=o.path)!=null&&a.includes("?")))i(o,s);else for(let l of q3(o.path))i(o,s,l)}),e}function q3(n){let e=n.split("/");if(e.length===0)return[];let[t,...r]=e,i=t.endsWith("?"),o=t.replace(/\?$/,"");if(r.length===0)return i?[o,""]:[o];let s=q3(r.join("/")),a=[];return a.push(...s.map(l=>l===""?o:[o,l].join("/"))),i&&a.push(...s),a.map(l=>n.startsWith("/")&&l===""?"/":l)}function $J(n){n.sort((e,t)=>e.score!==t.score?t.score-e.score:UJ(e.routesMeta.map(r=>r.childrenIndex),t.routesMeta.map(r=>r.childrenIndex)))}var DJ=/^:[\w-]+$/,QJ=3,IJ=2,jJ=1,LJ=10,NJ=-2,MM=n=>n==="*";function qJ(n,e){let t=n.split("/"),r=t.length;return t.some(MM)&&(r+=NJ),e&&(r+=IJ),t.filter(i=>!MM(i)).reduce((i,o)=>i+(DJ.test(o)?QJ:o===""?jJ:LJ),r)}function UJ(n,e){return n.length===e.length&&n.slice(0,-1).every((r,i)=>r===e[i])?n[n.length-1]-e[e.length-1]:0}function BJ(n,e,t=!1){let{routesMeta:r}=n,i={},o="/",s=[];for(let a=0;a<r.length;++a){let l=r[a],c=a===r.length-1,u=o==="/"?e:e.slice(o.length)||"/",d=Uf({path:l.relativePath,caseSensitive:l.caseSensitive,end:c},u),h=l.route;if(!d&&c&&t&&!r[r.length-1].route.index&&(d=Uf({path:l.relativePath,caseSensitive:l.caseSensitive,end:!1},u)),!d)return null;Object.assign(i,d.params),s.push({params:i,pathname:ca([o,d.pathname]),pathnameBase:ZJ(ca([o,d.pathnameBase])),route:h}),d.pathnameBase!=="/"&&(o=ca([o,d.pathnameBase]))}return s}function FJ(n,e={}){let t=n;t.endsWith("*")&&t!=="*"&&!t.endsWith("/*")&&(yr(!1,`Route path "${t}" will be treated as if it were "${t.replace(/\*$/,"/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${t.replace(/\*$/,"/*")}".`),t=t.replace(/\*$/,"/*"));const r=t.startsWith("/")?"/":"",i=s=>s==null?"":typeof s=="string"?s:String(s),o=t.split(/\/+/).map((s,a,l)=>{if(a===l.length-1&&s==="*")return i(e["*"]);const u=s.match(/^:([\w-]+)(\??)$/);if(u){const[,d,h]=u;let p=e[d];return zt(h==="?"||p!=null,`Missing ":${d}" param`),i(p)}return s.replace(/\?$/g,"")}).filter(s=>!!s);return r+o.join("/")}function Uf(n,e){typeof n=="string"&&(n={path:n,caseSensitive:!1,end:!0});let[t,r]=VJ(n.path,n.caseSensitive,n.end),i=e.match(t);if(!i)return null;let o=i[0],s=o.replace(/(.)\/+$/,"$1"),a=i.slice(1);return{params:r.reduce((c,{paramName:u,isOptional:d},h)=>{if(u==="*"){let g=a[h]||"";s=o.slice(0,o.length-g.length).replace(/(.)\/+$/,"$1")}const p=a[h];return d&&!p?c[u]=void 0:c[u]=(p||"").replace(/%2F/g,"/"),c},{}),pathname:o,pathnameBase:s,pattern:n}}function VJ(n,e=!1,t=!0){yr(n==="*"||!n.endsWith("*")||n.endsWith("/*"),`Route path "${n}" will be treated as if it were "${n.replace(/\*$/,"/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${n.replace(/\*$/,"/*")}".`);let r=[],i="^"+n.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(s,a,l)=>(r.push({paramName:a,isOptional:l!=null}),l?"/?([^\\/]+)?":"/([^\\/]+)"));return n.endsWith("*")?(r.push({paramName:"*"}),i+=n==="*"||n==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):t?i+="\\/*$":n!==""&&n!=="/"&&(i+="(?:(?=\\/|$))"),[new RegExp(i,e?void 0:"i"),r]}function U3(n){try{return n.split("/").map(e=>decodeURIComponent(e).replace(/\//g,"%2F")).join("/")}catch(e){return yr(!1,`The URL path "${n}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${e}).`),n}}function vi(n,e){if(e==="/")return n;if(!n.toLowerCase().startsWith(e.toLowerCase()))return null;let t=e.endsWith("/")?e.length-1:e.length,r=n.charAt(t);return r&&r!=="/"?null:n.slice(t)||"/"}function B3(n,e="/"){let{pathname:t,search:r="",hash:i=""}=typeof n=="string"?jo(n):n;return{pathname:t?t.startsWith("/")?t:WJ(t,e):e,search:XJ(r),hash:zJ(i)}}function WJ(n,e){let t=e.replace(/\/+$/,"").split("/");return n.split("/").forEach(i=>{i===".."?t.length>1&&t.pop():i!=="."&&t.push(i)}),t.length>1?t.join("/"):"/"}function lS(n,e,t,r){return`Cannot include a '${n}' character in a manually specified \`to.${e}\` field [${JSON.stringify(r)}]. Please separate it out to the \`to.${t}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`}function F3(n){return n.filter((e,t)=>t===0||e.route.path&&e.route.path.length>0)}function hy(n){let e=F3(n);return e.map((t,r)=>r===e.length-1?t.pathname:t.pathnameBase)}function py(n,e,t,r=!1){let i;typeof n=="string"?i=jo(n):(i={...n},zt(!i.pathname||!i.pathname.includes("?"),lS("?","pathname","search",i)),zt(!i.pathname||!i.pathname.includes("#"),lS("#","pathname","hash",i)),zt(!i.search||!i.search.includes("#"),lS("#","search","hash",i)));let o=n===""||i.pathname==="",s=o?"/":i.pathname,a;if(s==null)a=t;else{let d=e.length-1;if(!r&&s.startsWith("..")){let h=s.split("/");for(;h[0]==="..";)h.shift(),d-=1;i.pathname=h.join("/")}a=d>=0?e[d]:"/"}let l=B3(i,a),c=s&&s!=="/"&&s.endsWith("/"),u=(o||s===".")&&t.endsWith("/");return!l.pathname.endsWith("/")&&(c||u)&&(l.pathname+="/"),l}var ca=n=>n.join("/").replace(/\/\/+/g,"/"),ZJ=n=>n.replace(/\/+$/,"").replace(/^\/*/,"/"),XJ=n=>!n||n==="?"?"":n.startsWith("?")?n:"?"+n,zJ=n=>!n||n==="#"?"":n.startsWith("#")?n:"#"+n,YJ=class{constructor(n,e){this.type="DataWithResponseInit",this.data=n,this.init=e||null}};function V3(n,e){return new YJ(n,typeof e=="number"?{status:e}:e)}var my=(n,e=302)=>{let t=e;typeof t=="number"?t={status:t}:typeof t.status>"u"&&(t.status=302);let r=new Headers(t.headers);return r.set("Location",n),new Response(null,{...t,headers:r})},GJ=(n,e)=>{let t=my(n,e);return t.headers.set("X-Remix-Reload-Document","true"),t},HJ=(n,e)=>{let t=my(n,e);return t.headers.set("X-Remix-Replace","true"),t},Qo=class{constructor(n,e,t,r=!1){this.status=n,this.statusText=e||"",this.internal=r,t instanceof Error?(this.data=t.toString(),this.error=t):this.data=t}};function si(n){return n!=null&&typeof n.status=="number"&&typeof n.statusText=="string"&&typeof n.internal=="boolean"&&"data"in n}var W3=["POST","PUT","PATCH","DELETE"],KJ=new Set(W3),JJ=["GET",...W3],eee=new Set(JJ),Z3=new Set([301,302,303,307,308]),tee=new Set([307,308]),kh={state:"idle",location:void 0,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,json:void 0,text:void 0},gy={state:"idle",data:void 0,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,json:void 0,text:void 0},Rl={state:"unblocked",proceed:void 0,reset:void 0,location:void 0},Px=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,X3=n=>({hasErrorBoundary:!!n.hasErrorBoundary}),z3="remix-router-transitions",Y3=Symbol("ResetLoaderData");function Op(n){const e=n.window?n.window:typeof window<"u"?window:void 0,t=typeof e<"u"&&typeof e.document<"u"&&typeof e.document.createElement<"u";zt(n.routes.length>0,"You must provide a non-empty routes array to createRouter");let r=n.mapRouteProperties||X3,i={},o=ou(n.routes,r,void 0,i),s,a=n.basename||"/",l=n.dataStrategy||aee,c={unstable_middleware:!1,...n.future},u=null,d=new Set,h=null,p=null,g=null,O=n.hydrationData!=null,v=ho(o,n.history.location,a),b=!1,S=null;if(v==null&&!n.patchRoutesOnNavigation){let re=Yr(404,{pathname:n.history.location.pathname}),{matches:de,route:ye}=Pv(o);v=de,S={[ye.id]:re}}v&&!n.hydrationData&&hn(v,o,n.history.location.pathname).active&&(v=null);let x;if(v)if(v.some(re=>re.route.lazy))x=!1;else if(!v.some(re=>re.route.loader))x=!0;else{let re=n.hydrationData?n.hydrationData.loaderData:null,de=n.hydrationData?n.hydrationData.errors:null;if(de){let ye=v.findIndex(Ue=>de[Ue.route.id]!==void 0);x=v.slice(0,ye+1).every(Ue=>!Ik(Ue.route,re,de))}else x=v.every(ye=>!Ik(ye.route,re,de))}else{x=!1,v=[];let re=hn(null,o,n.history.location.pathname);re.active&&re.matches&&(b=!0,v=re.matches)}let P,w={historyAction:n.history.action,location:n.history.location,matches:v,initialized:x,navigation:kh,restoreScrollPosition:n.hydrationData!=null?!1:null,preventScrollReset:!1,revalidation:"idle",loaderData:n.hydrationData&&n.hydrationData.loaderData||{},actionData:n.hydrationData&&n.hydrationData.actionData||null,errors:n.hydrationData&&n.hydrationData.errors||S,fetchers:new Map,blockers:new Map},E="POP",M=!1,Q,T=!1,R=new Map,$=null,I=!1,B=!1,H=new Set,oe=new Map,F=0,Z=-1,W=new Map,te=new Set,ie=new Map,K=new Map,se=new Set,ee=new Map,le,ge=null;function Le(){if(u=n.history.listen(({action:re,location:de,delta:ye})=>{if(le){le(),le=void 0;return}yr(ee.size===0||ye!=null,"You are trying to use a blocker on a POP navigation to a location that was not created by @remix-run/router. This will fail silently in production. This can happen if you are navigating outside the router via `window.history.pushState`/`window.location.hash` instead of using router navigation APIs. This can also happen if you are using createHashRouter and the user manually changes the URL.");let Ue=Bt({currentLocation:w.location,nextLocation:de,historyAction:re});if(Ue&&ye!=null){let et=new Promise(Tt=>{le=Tt});n.history.go(ye*-1),vt(Ue,{state:"blocked",location:de,proceed(){vt(Ue,{state:"proceeding",proceed:void 0,reset:void 0,location:de}),et.then(()=>n.history.go(ye))},reset(){let Tt=new Map(w.blockers);Tt.set(Ue,Rl),z({blockers:Tt})}});return}return Ce(re,de)}),t){hee(e,R);let re=()=>pee(e,R);e.addEventListener("pagehide",re),$=()=>e.removeEventListener("pagehide",re)}return w.initialized||Ce("POP",w.location,{initialHydration:!0}),P}function L(){u&&u(),$&&$(),d.clear(),Q&&Q.abort(),w.fetchers.forEach((re,de)=>it(de)),w.blockers.forEach((re,de)=>mt(de))}function V(re){return d.add(re),()=>d.delete(re)}function z(re,de={}){w={...w,...re};let ye=[],Ue=[];w.fetchers.forEach((et,Tt)=>{et.state==="idle"&&(se.has(Tt)?ye.push(Tt):Ue.push(Tt))}),se.forEach(et=>{!w.fetchers.has(et)&&!oe.has(et)&&ye.push(et)}),[...d].forEach(et=>et(w,{deletedFetchers:ye,viewTransitionOpts:de.viewTransitionOpts,flushSync:de.flushSync===!0})),ye.forEach(et=>it(et)),Ue.forEach(et=>w.fetchers.delete(et))}function pe(re,de,{flushSync:ye}={}){var Re,Te;let Ue=w.actionData!=null&&w.navigation.formMethod!=null&&Yo(w.navigation.formMethod)&&w.navigation.state==="loading"&&((Re=re.state)==null?void 0:Re._isRedirect)!==!0,et;de.actionData?Object.keys(de.actionData).length>0?et=de.actionData:et=null:Ue?et=w.actionData:et=null;let Tt=de.loaderData?BM(w.loaderData,de.loaderData,de.matches||[],de.errors):w.loaderData,ot=w.blockers;ot.size>0&&(ot=new Map(ot),ot.forEach((we,pt)=>ot.set(pt,Rl)));let Ae=M===!0||w.navigation.formMethod!=null&&Yo(w.navigation.formMethod)&&((Te=re.state)==null?void 0:Te._isRedirect)!==!0;s&&(o=s,s=void 0),I||E==="POP"||(E==="PUSH"?n.history.push(re,re.state):E==="REPLACE"&&n.history.replace(re,re.state));let je;if(E==="POP"){let we=R.get(w.location.pathname);we&&we.has(re.pathname)?je={currentLocation:w.location,nextLocation:re}:R.has(re.pathname)&&(je={currentLocation:re,nextLocation:w.location})}else if(T){let we=R.get(w.location.pathname);we?we.add(re.pathname):(we=new Set([re.pathname]),R.set(w.location.pathname,we)),je={currentLocation:w.location,nextLocation:re}}z({...de,actionData:et,loaderData:Tt,historyAction:E,location:re,initialized:!0,navigation:kh,revalidation:"idle",restoreScrollPosition:Ft(re,de.matches||w.matches),preventScrollReset:Ae,blockers:ot},{viewTransitionOpts:je,flushSync:ye===!0}),E="POP",M=!1,T=!1,I=!1,B=!1,ge==null||ge.resolve(),ge=null}async function _e(re,de){if(typeof re=="number"){n.history.go(re);return}let ye=Dk(w.location,w.matches,a,re,de==null?void 0:de.fromRouteId,de==null?void 0:de.relative),{path:Ue,submission:et,error:Tt}=DM(!1,ye,de),ot=w.location,Ae=Fa(w.location,Ue,de&&de.state);Ae={...Ae,...n.history.encodeLocation(Ae)};let je=de&&de.replace!=null?de.replace:void 0,Re="PUSH";je===!0?Re="REPLACE":je===!1||et!=null&&Yo(et.formMethod)&&et.formAction===w.location.pathname+w.location.search&&(Re="REPLACE");let Te=de&&"preventScrollReset"in de?de.preventScrollReset===!0:void 0,we=(de&&de.flushSync)===!0,pt=Bt({currentLocation:ot,nextLocation:Ae,historyAction:Re});if(pt){vt(pt,{state:"blocked",location:Ae,proceed(){vt(pt,{state:"proceeding",proceed:void 0,reset:void 0,location:Ae}),_e(re,de)},reset(){let Et=new Map(w.blockers);Et.set(pt,Rl),z({blockers:Et})}});return}await Ce(Re,Ae,{submission:et,pendingError:Tt,preventScrollReset:Te,replace:de&&de.replace,enableViewTransition:de&&de.viewTransition,flushSync:we})}function Me(){ge||(ge=mee()),ve(),z({revalidation:"loading"});let re=ge.promise;return w.navigation.state==="submitting"?re:w.navigation.state==="idle"?(Ce(w.historyAction,w.location,{startUninterruptedRevalidation:!0}),re):(Ce(E||w.historyAction,w.navigation.location,{overrideNavigation:w.navigation,enableViewTransition:T===!0}),re)}async function Ce(re,de,ye){Q&&Q.abort(),Q=null,E=re,I=(ye&&ye.startUninterruptedRevalidation)===!0,Pt(w.location,w.matches),M=(ye&&ye.preventScrollReset)===!0,T=(ye&&ye.enableViewTransition)===!0;let Ue=s||o,et=ye&&ye.overrideNavigation,Tt=ye!=null&&ye.initialHydration&&w.matches&&w.matches.length>0&&!b?w.matches:ho(Ue,de,a),ot=(ye&&ye.flushSync)===!0;if(Tt&&w.initialized&&!B&&cee(w.location,de)&&!(ye&&ye.submission&&Yo(ye.submission.formMethod))){pe(de,{matches:Tt},{flushSync:ot});return}let Ae=hn(Tt,Ue,de.pathname);if(Ae.active&&Ae.matches&&(Tt=Ae.matches),!Tt){let{error:Ht,notFoundMatches:tn,route:nn}=Xe(de.pathname);pe(de,{matches:tn,loaderData:{},errors:{[nn.id]:Ht}},{flushSync:ot});return}Q=new AbortController;let je=qu(n.history,de,Q.signal,ye&&ye.submission),Re=new Ll(n.unstable_getContext?await n.unstable_getContext():void 0),Te;if(ye&&ye.pendingError)Te=[Ho(Tt).route.id,{type:"error",error:ye.pendingError}];else if(ye&&ye.submission&&Yo(ye.submission.formMethod)){let Ht=await Ne(je,de,ye.submission,Tt,Re,Ae.active,{replace:ye.replace,flushSync:ot});if(Ht.shortCircuited)return;if(Ht.pendingActionResult){let[tn,nn]=Ht.pendingActionResult;if(mi(nn)&&si(nn.error)&&nn.error.status===404){Q=null,pe(de,{matches:Ht.matches,loaderData:{},errors:{[tn]:nn.error}});return}}Tt=Ht.matches||Tt,Te=Ht.pendingActionResult,et=cS(de,ye.submission),ot=!1,Ae.active=!1,je=qu(n.history,je.url,je.signal)}let{shortCircuited:we,matches:pt,loaderData:Et,errors:Lt}=await st(je,de,Tt,Re,Ae.active,et,ye&&ye.submission,ye&&ye.fetcherSubmission,ye&&ye.replace,ye&&ye.initialHydration===!0,ot,Te);we||(Q=null,pe(de,{matches:pt||Tt,...FM(Te),loaderData:Et,errors:Lt}))}async function Ne(re,de,ye,Ue,et,Tt,ot={}){ve();let Ae=fee(de,ye);if(z({navigation:Ae},{flushSync:ot.flushSync===!0}),Tt){let Te=await Pn(Ue,de.pathname,re.signal);if(Te.type==="aborted")return{shortCircuited:!0};if(Te.type==="error"){let we=Ho(Te.partialMatches).route.id;return{matches:Te.partialMatches,pendingActionResult:[we,{type:"error",error:Te.error}]}}else if(Te.matches)Ue=Te.matches;else{let{notFoundMatches:we,error:pt,route:Et}=Xe(de.pathname);return{matches:we,pendingActionResult:[Et.id,{type:"error",error:pt}]}}}let je,Re=Xc(Ue,de);if(!Re.route.action&&!Re.route.lazy)je={type:"error",error:Yr(405,{method:re.method,pathname:de.pathname,routeId:Re.route.id})};else{let Te=await Cn("action",re,[Re],Ue,et,null);if(je=Te[Re.route.id],!je){for(let we of Ue)if(Te[we.route.id]){je=Te[we.route.id];break}}if(re.signal.aborted)return{shortCircuited:!0}}if(Nl(je)){let Te;return ot&&ot.replace!=null?Te=ot.replace:Te=NM(je.response.headers.get("Location"),new URL(re.url),a)===w.location.pathname+w.location.search,await kn(re,je,!0,{submission:ye,replace:Te}),{shortCircuited:!0}}if(mi(je)){let Te=Ho(Ue,Re.route.id);return(ot&&ot.replace)!==!0&&(E="PUSH"),{matches:Ue,pendingActionResult:[Te.route.id,je]}}return{matches:Ue,pendingActionResult:[Re.route.id,je]}}async function st(re,de,ye,Ue,et,Tt,ot,Ae,je,Re,Te,we){let pt=Tt||cS(de,ot),Et=ot||Ae||VM(pt),Lt=!I&&!Re;if(et){if(Lt){let J=wt(we);z({navigation:pt,...J!==void 0?{actionData:J}:{}},{flushSync:Te})}let G=await Pn(ye,de.pathname,re.signal);if(G.type==="aborted")return{shortCircuited:!0};if(G.type==="error"){let J=Ho(G.partialMatches).route.id;return{matches:G.partialMatches,loaderData:{},errors:{[J]:G.error}}}else if(G.matches)ye=G.matches;else{let{error:J,notFoundMatches:ce,route:Qe}=Xe(de.pathname);return{matches:ce,loaderData:{},errors:{[Qe.id]:J}}}}let Ht=s||o,[tn,nn]=QM(n.history,w,ye,Et,de,Re===!0,B,H,se,ie,te,Ht,a,we);if(Z=++F,tn.length===0&&nn.length===0){let G=lt();return pe(de,{matches:ye,loaderData:{},errors:we&&mi(we[1])?{[we[0]]:we[1].error}:null,...FM(we),...G?{fetchers:new Map(w.fetchers)}:{}},{flushSync:Te}),{shortCircuited:!0}}if(Lt){let G={};if(!et){G.navigation=pt;let J=wt(we);J!==void 0&&(G.actionData=J)}nn.length>0&&(G.fetchers=un(nn)),z(G,{flushSync:Te})}nn.forEach(G=>{kt(G.key),G.controller&&oe.set(G.key,G.controller)});let Ln=()=>nn.forEach(G=>kt(G.key));Q&&Q.signal.addEventListener("abort",Ln);let{loaderResults:rn,fetcherResults:Ut}=await j(ye,tn,nn,re,Ue);if(re.signal.aborted)return{shortCircuited:!0};Q&&Q.signal.removeEventListener("abort",Ln),nn.forEach(G=>oe.delete(G.key));let gt=zm(rn);if(gt)return await kn(re,gt.result,!0,{replace:je}),{shortCircuited:!0};if(gt=zm(Ut),gt)return te.add(gt.key),await kn(re,gt.result,!0,{replace:je}),{shortCircuited:!0};let{loaderData:On,errors:Kn}=UM(w,ye,rn,we,nn,Ut);Re&&w.errors&&(Kn={...w.errors,...Kn});let pn=lt(),Mr=nt(Z),Sr=pn||Mr||nn.length>0;return{matches:ye,loaderData:On,errors:Kn,...Sr?{fetchers:new Map(w.fetchers)}:{}}}function wt(re){if(re&&!mi(re[1]))return{[re[0]]:re[1].data};if(w.actionData)return Object.keys(w.actionData).length===0?null:w.actionData}function un(re){return re.forEach(de=>{let ye=w.fetchers.get(de.key),Ue=Bd(void 0,ye?ye.data:void 0);w.fetchers.set(de.key,Ue)}),new Map(w.fetchers)}async function Vn(re,de,ye,Ue){kt(re);let et=(Ue&&Ue.flushSync)===!0,Tt=s||o,ot=Dk(w.location,w.matches,a,ye,de,Ue==null?void 0:Ue.relative),Ae=ho(Tt,ot,a),je=hn(Ae,Tt,ot);if(je.active&&je.matches&&(Ae=je.matches),!Ae){He(re,de,Yr(404,{pathname:ot}),{flushSync:et});return}let{path:Re,submission:Te,error:we}=DM(!0,ot,Ue);if(we){He(re,de,we,{flushSync:et});return}let pt=Xc(Ae,Re),Et=new Ll(n.unstable_getContext?await n.unstable_getContext():void 0),Lt=(Ue&&Ue.preventScrollReset)===!0;if(Te&&Yo(Te.formMethod)){await Sn(re,de,Re,pt,Ae,Et,je.active,et,Lt,Te);return}ie.set(re,{routeId:de,path:Re}),await wn(re,de,Re,pt,Ae,Et,je.active,et,Lt,Te)}async function Sn(re,de,ye,Ue,et,Tt,ot,Ae,je,Re){ve(),ie.delete(re);function Te(me){if(!me.route.action&&!me.route.lazy){let Be=Yr(405,{method:Re.formMethod,pathname:ye,routeId:de});return He(re,de,Be,{flushSync:Ae}),!0}return!1}if(!ot&&Te(Ue))return;let we=w.fetchers.get(re);Fe(re,dee(Re,we),{flushSync:Ae});let pt=new AbortController,Et=qu(n.history,ye,pt.signal,Re);if(ot){let me=await Pn(et,ye,Et.signal,re);if(me.type==="aborted")return;if(me.type==="error"){He(re,de,me.error,{flushSync:Ae});return}else if(me.matches){if(et=me.matches,Ue=Xc(et,ye),Te(Ue))return}else{He(re,de,Yr(404,{pathname:ye}),{flushSync:Ae});return}}oe.set(re,pt);let Lt=F,tn=(await Cn("action",Et,[Ue],et,Tt,re))[Ue.route.id];if(Et.signal.aborted){oe.get(re)===pt&&oe.delete(re);return}if(se.has(re)){if(Nl(tn)||mi(tn)){Fe(re,vl(void 0));return}}else{if(Nl(tn))if(oe.delete(re),Z>Lt){Fe(re,vl(void 0));return}else return te.add(re),Fe(re,Bd(Re)),kn(Et,tn,!1,{fetcherSubmission:Re,preventScrollReset:je});if(mi(tn)){He(re,de,tn.error);return}}let nn=w.navigation.location||w.location,Ln=qu(n.history,nn,pt.signal),rn=s||o,Ut=w.navigation.state!=="idle"?ho(rn,w.navigation.location,a):w.matches;zt(Ut,"Didn't find any matches after fetcher action");let gt=++F;W.set(re,gt);let On=Bd(Re,tn.data);w.fetchers.set(re,On);let[Kn,pn]=QM(n.history,w,Ut,Re,nn,!1,B,H,se,ie,te,rn,a,[Ue.route.id,tn]);pn.filter(me=>me.key!==re).forEach(me=>{let Be=me.key,dt=w.fetchers.get(Be),We=Bd(void 0,dt?dt.data:void 0);w.fetchers.set(Be,We),kt(Be),me.controller&&oe.set(Be,me.controller)}),z({fetchers:new Map(w.fetchers)});let Mr=()=>pn.forEach(me=>kt(me.key));pt.signal.addEventListener("abort",Mr);let{loaderResults:Sr,fetcherResults:G}=await j(Ut,Kn,pn,Ln,Tt);if(pt.signal.aborted)return;pt.signal.removeEventListener("abort",Mr),W.delete(re),oe.delete(re),pn.forEach(me=>oe.delete(me.key));let J=zm(Sr);if(J)return kn(Ln,J.result,!1,{preventScrollReset:je});if(J=zm(G),J)return te.add(J.key),kn(Ln,J.result,!1,{preventScrollReset:je});let{loaderData:ce,errors:Qe}=UM(w,Ut,Sr,void 0,pn,G);if(w.fetchers.has(re)){let me=vl(tn.data);w.fetchers.set(re,me)}nt(gt),w.navigation.state==="loading"&>>Z?(zt(E,"Expected pending action"),Q&&Q.abort(),pe(w.navigation.location,{matches:Ut,loaderData:ce,errors:Qe,fetchers:new Map(w.fetchers)})):(z({errors:Qe,loaderData:BM(w.loaderData,ce,Ut,Qe),fetchers:new Map(w.fetchers)}),B=!1)}async function wn(re,de,ye,Ue,et,Tt,ot,Ae,je,Re){let Te=w.fetchers.get(re);Fe(re,Bd(Re,Te?Te.data:void 0),{flushSync:Ae});let we=new AbortController,pt=qu(n.history,ye,we.signal);if(ot){let tn=await Pn(et,ye,pt.signal,re);if(tn.type==="aborted")return;if(tn.type==="error"){He(re,de,tn.error,{flushSync:Ae});return}else if(tn.matches)et=tn.matches,Ue=Xc(et,ye);else{He(re,de,Yr(404,{pathname:ye}),{flushSync:Ae});return}}oe.set(re,we);let Et=F,Ht=(await Cn("loader",pt,[Ue],et,Tt,re))[Ue.route.id];if(oe.get(re)===we&&oe.delete(re),!pt.signal.aborted){if(se.has(re)){Fe(re,vl(void 0));return}if(Nl(Ht))if(Z>Et){Fe(re,vl(void 0));return}else{te.add(re),await kn(pt,Ht,!1,{preventScrollReset:je});return}if(mi(Ht)){He(re,de,Ht.error);return}Fe(re,vl(Ht.data))}}async function kn(re,de,ye,{submission:Ue,fetcherSubmission:et,preventScrollReset:Tt,replace:ot}={}){de.response.headers.has("X-Remix-Revalidate")&&(B=!0);let Ae=de.response.headers.get("Location");zt(Ae,"Expected a Location header on the redirect Response"),Ae=NM(Ae,new URL(re.url),a);let je=Fa(w.location,Ae,{_isRedirect:!0});if(t){let Lt=!1;if(de.response.headers.has("X-Remix-Reload-Document"))Lt=!0;else if(Px.test(Ae)){const Ht=n.history.createURL(Ae);Lt=Ht.origin!==e.location.origin||vi(Ht.pathname,a)==null}if(Lt){ot?e.location.replace(Ae):e.location.assign(Ae);return}}Q=null;let Re=ot===!0||de.response.headers.has("X-Remix-Replace")?"REPLACE":"PUSH",{formMethod:Te,formAction:we,formEncType:pt}=w.navigation;!Ue&&!et&&Te&&we&&pt&&(Ue=VM(w.navigation));let Et=Ue||et;if(tee.has(de.response.status)&&Et&&Yo(Et.formMethod))await Ce(Re,je,{submission:{...Et,formAction:Ae},preventScrollReset:Tt||M,enableViewTransition:ye?T:void 0});else{let Lt=cS(je,Ue);await Ce(Re,je,{overrideNavigation:Lt,fetcherSubmission:et,preventScrollReset:Tt||M,enableViewTransition:ye?T:void 0})}}async function Cn(re,de,ye,Ue,et,Tt){let ot,Ae={};try{ot=await eq(l,re,de,ye,Ue,Tt,i,r,et)}catch(je){return ye.forEach(Re=>{Ae[Re.route.id]={type:"error",error:je}}),Ae}for(let[je,Re]of Object.entries(ot))if(oq(Re)){let Te=Re.result;Ae[je]={type:"redirect",response:nq(Te,de,je,Ue,a)}}else Ae[je]=await tq(Re);return Ae}async function j(re,de,ye,Ue,et){let Tt=Cn("loader",Ue,de,re,et,null),ot=Promise.all(ye.map(async Re=>{if(Re.matches&&Re.match&&Re.controller){let we=(await Cn("loader",qu(n.history,Re.path,Re.controller.signal),[Re.match],Re.matches,et,Re.key))[Re.match.route.id];return{[Re.key]:we}}else return Promise.resolve({[Re.key]:{type:"error",error:Yr(404,{pathname:Re.path})}})})),Ae=await Tt,je=(await ot).reduce((Re,Te)=>Object.assign(Re,Te),{});return{loaderResults:Ae,fetcherResults:je}}function ve(){B=!0,ie.forEach((re,de)=>{oe.has(de)&&H.add(de),kt(de)})}function Fe(re,de,ye={}){w.fetchers.set(re,de),z({fetchers:new Map(w.fetchers)},{flushSync:(ye&&ye.flushSync)===!0})}function He(re,de,ye,Ue={}){let et=Ho(w.matches,de);it(re),z({errors:{[et.route.id]:ye},fetchers:new Map(w.fetchers)},{flushSync:(Ue&&Ue.flushSync)===!0})}function Je(re){return K.set(re,(K.get(re)||0)+1),se.has(re)&&se.delete(re),w.fetchers.get(re)||gy}function it(re){let de=w.fetchers.get(re);oe.has(re)&&!(de&&de.state==="loading"&&W.has(re))&&kt(re),ie.delete(re),W.delete(re),te.delete(re),se.delete(re),H.delete(re),w.fetchers.delete(re)}function Dt(re){let de=(K.get(re)||0)-1;de<=0?(K.delete(re),se.add(re)):K.set(re,de),z({fetchers:new Map(w.fetchers)})}function kt(re){let de=oe.get(re);de&&(de.abort(),oe.delete(re))}function qe(re){for(let de of re){let ye=Je(de),Ue=vl(ye.data);w.fetchers.set(de,Ue)}}function lt(){let re=[],de=!1;for(let ye of te){let Ue=w.fetchers.get(ye);zt(Ue,`Expected fetcher: ${ye}`),Ue.state==="loading"&&(te.delete(ye),re.push(ye),de=!0)}return qe(re),de}function nt(re){let de=[];for(let[ye,Ue]of W)if(Ue<re){let et=w.fetchers.get(ye);zt(et,`Expected fetcher: ${ye}`),et.state==="loading"&&(kt(ye),W.delete(ye),de.push(ye))}return qe(de),de.length>0}function rt(re,de){let ye=w.blockers.get(re)||Rl;return ee.get(re)!==de&&ee.set(re,de),ye}function mt(re){w.blockers.delete(re),ee.delete(re)}function vt(re,de){let ye=w.blockers.get(re)||Rl;zt(ye.state==="unblocked"&&de.state==="blocked"||ye.state==="blocked"&&de.state==="blocked"||ye.state==="blocked"&&de.state==="proceeding"||ye.state==="blocked"&&de.state==="unblocked"||ye.state==="proceeding"&&de.state==="unblocked",`Invalid blocker state transition: ${ye.state} -> ${de.state}`);let Ue=new Map(w.blockers);Ue.set(re,de),z({blockers:Ue})}function Bt({currentLocation:re,nextLocation:de,historyAction:ye}){if(ee.size===0)return;ee.size>1&&yr(!1,"A router only supports one blocker at a time");let Ue=Array.from(ee.entries()),[et,Tt]=Ue[Ue.length-1],ot=w.blockers.get(et);if(!(ot&&ot.state==="proceeding")&&Tt({currentLocation:re,nextLocation:de,historyAction:ye}))return et}function Xe(re){let de=Yr(404,{pathname:re}),ye=s||o,{matches:Ue,route:et}=Pv(ye);return{notFoundMatches:Ue,route:et,error:de}}function bt(re,de,ye){if(h=re,g=de,p=ye||null,!O&&w.navigation===kh){O=!0;let Ue=Ft(w.location,w.matches);Ue!=null&&z({restoreScrollPosition:Ue})}return()=>{h=null,g=null,p=null}}function en(re,de){return p&&p(re,de.map(Ue=>L3(Ue,w.loaderData)))||re.key}function Pt(re,de){if(h&&g){let ye=en(re,de);h[ye]=g()}}function Ft(re,de){if(h){let ye=en(re,de),Ue=h[ye];if(typeof Ue=="number")return Ue}return null}function hn(re,de,ye){if(n.patchRoutesOnNavigation)if(re){if(Object.keys(re[0].params).length>0)return{active:!0,matches:QO(de,ye,a,!0)}}else return{active:!0,matches:QO(de,ye,a,!0)||[]};return{active:!1,matches:null}}async function Pn(re,de,ye,Ue){if(!n.patchRoutesOnNavigation)return{type:"success",matches:re};let et=re;for(;;){let Tt=s==null,ot=s||o,Ae=i;try{await n.patchRoutesOnNavigation({signal:ye,path:de,matches:et,fetcherKey:Ue,patch:(Te,we)=>{ye.aborted||jM(Te,we,ot,Ae,r)}})}catch(Te){return{type:"error",error:Te,partialMatches:et}}finally{Tt&&!ye.aborted&&(o=[...o])}if(ye.aborted)return{type:"aborted"};let je=ho(ot,de,a);if(je)return{type:"success",matches:je};let Re=QO(ot,de,a,!0);if(!Re||et.length===Re.length&&et.every((Te,we)=>Te.route.id===Re[we].route.id))return{type:"success",matches:null};et=Re}}function Tn(re){i={},s=ou(re,r,void 0,i)}function En(re,de){let ye=s==null;jM(re,de,s||o,i,r),ye&&(o=[...o],z({}))}return P={get basename(){return a},get future(){return c},get state(){return w},get routes(){return o},get window(){return e},initialize:Le,subscribe:V,enableScrollRestoration:bt,navigate:_e,fetch:Vn,revalidate:Me,createHref:re=>n.history.createHref(re),encodeLocation:re=>n.history.encodeLocation(re),getFetcher:Je,deleteFetcher:Dt,dispose:L,getBlocker:rt,deleteBlocker:mt,patchRoutes:En,_internalFetchControllers:oe,_internalSetRoutes:Tn},P}function G3(n,e){zt(n.length>0,"You must provide a non-empty routes array to createStaticHandler");let t={},r=(e?e.basename:null)||"/",i=(e==null?void 0:e.mapRouteProperties)||X3,o=ou(n,i,void 0,t);async function s(h,{requestContext:p,filterMatchesToLoad:g,skipLoaderErrorBubbling:O,skipRevalidation:v,dataStrategy:b,unstable_respond:S}={}){let x=new URL(h.url),P=h.method,w=Fa("",Yi(x),null,"default"),E=ho(o,w,r);if(p=p??new Ll,!Uk(P)&&P!=="HEAD"){let Q=Yr(405,{method:P}),{matches:T,route:R}=Pv(o),$={basename:r,location:w,matches:T,loaderData:{},actionData:null,errors:{[R.id]:Q},statusCode:Q.status,loaderHeaders:{},actionHeaders:{}};return S?S($):$}else if(!E){let Q=Yr(404,{pathname:w.pathname}),{matches:T,route:R}=Pv(o),$={basename:r,location:w,matches:T,loaderData:{},actionData:null,errors:{[R.id]:Q},statusCode:Q.status,loaderHeaders:{},actionHeaders:{}};return S?S($):$}if(S&&E.some(Q=>Q.route.unstable_middleware||Q.route.unstable_lazyMiddleware)){zt(p instanceof Ll,"When using middleware in `staticHandler.query()`, any provided `requestContext` must be an instance of `unstable_RouterContextProvider`");try{await jk(E,t);let Q,T=await Zc({request:h,matches:E,params:E[0].params,context:p},!0,async()=>{let R=await l(h,w,E,p,b||null,O===!0,null,g||null,v===!0);return Ir(R)?R:(Q={location:w,basename:r,...R},await S(Q))},async(R,$)=>{if(Ir(R))return R;if(Q)return $ in Q.loaderData&&(Q.loaderData[$]=void 0),S(H3(o,Q,R,Ho(E,$).route.id));{let I=E.findIndex(H=>H.route.loader),B=I>=0?Ho(E,E[I].route.id):Ho(E);return S({matches:E,location:w,basename:r,loaderData:{},actionData:null,errors:{[B.route.id]:R},statusCode:si(R)?R.status:500,actionHeaders:{},loaderHeaders:{}})}});return zt(Ir(T),"Expected a response in query()"),T}catch(Q){if(Ir(Q))return Q;throw Q}}let M=await l(h,w,E,p,b||null,O===!0,null,g||null,v===!0);return Ir(M)?M:{location:w,basename:r,...M}}async function a(h,{routeId:p,requestContext:g,dataStrategy:O,unstable_respond:v}={}){let b=new URL(h.url),S=h.method,x=Fa("",Yi(b),null,"default"),P=ho(o,x,r);if(g=g??new Ll,!Uk(S)&&S!=="HEAD"&&S!=="OPTIONS")throw Yr(405,{method:S});if(!P)throw Yr(404,{pathname:x.pathname});let w=p?P.find(Q=>Q.route.id===p):Xc(P,x);if(p&&!w)throw Yr(403,{pathname:x.pathname,routeId:p});if(!w)throw Yr(404,{pathname:x.pathname});if(v&&P.some(Q=>Q.route.unstable_middleware||Q.route.unstable_lazyMiddleware))return zt(g instanceof Ll,"When using middleware in `staticHandler.queryRoute()`, any provided `requestContext` must be an instance of `unstable_RouterContextProvider`"),await jk(P,t),await Zc({request:h,matches:P,params:P[0].params,context:g},!0,async()=>{let T=await l(h,x,P,g,O||null,!1,w,null,!1);if(Ir(T))return v(T);let R=T.errors?Object.values(T.errors)[0]:void 0;if(R!==void 0)throw R;let $=T.actionData?Object.values(T.actionData)[0]:Object.values(T.loaderData)[0];return typeof $=="string"?new Response($):Response.json($)},T=>Ir(T)?v(T):new Response(String(T),{status:500,statusText:"Unexpected Server Error"}));let E=await l(h,x,P,g,O||null,!1,w,null,!1);if(Ir(E))return E;let M=E.errors?Object.values(E.errors)[0]:void 0;if(M!==void 0)throw M;if(E.actionData)return Object.values(E.actionData)[0];if(E.loaderData)return Object.values(E.loaderData)[0]}async function l(h,p,g,O,v,b,S,x,P){zt(h.signal,"query()/queryRoute() requests must contain an AbortController signal");try{if(Yo(h.method))return await c(h,g,S||Xc(g,p),O,v,b,S!=null,x,P);let w=await u(h,g,O,v,b,S,x);return Ir(w)?w:{...w,actionData:null,actionHeaders:{}}}catch(w){if(uee(w)&&Ir(w.result)){if(w.type==="error")throw w.result;return w.result}if(vy(w))return w;throw w}}async function c(h,p,g,O,v,b,S,x,P){let w;if(!g.route.action&&!g.route.lazy){let Q=Yr(405,{method:h.method,pathname:new URL(h.url).pathname,routeId:g.route.id});if(S)throw Q;w={type:"error",error:Q}}else w=(await d("action",h,[g],p,S,O,v))[g.route.id],h.signal.aborted&&$M(h,S);if(Nl(w))throw new Response(null,{status:w.response.status,headers:{Location:w.response.headers.get("Location")}});if(S){if(mi(w))throw w.error;return{matches:[g],loaderData:{},actionData:{[g.route.id]:w.data},errors:null,statusCode:200,loaderHeaders:{},actionHeaders:{}}}if(P)if(mi(w)){let Q=b?g:Ho(p,g.route.id);return{statusCode:si(w.error)?w.error.status:w.statusCode!=null?w.statusCode:500,actionData:null,actionHeaders:{...w.headers?{[g.route.id]:w.headers}:{}},matches:p,loaderData:{},errors:{[Q.route.id]:w.error},loaderHeaders:{}}}else return{actionData:{[g.route.id]:w.data},actionHeaders:w.headers?{[g.route.id]:w.headers}:{},matches:p,loaderData:{},errors:null,statusCode:w.statusCode||200,loaderHeaders:{}};let E=new Request(h.url,{headers:h.headers,redirect:h.redirect,signal:h.signal});if(mi(w)){let Q=b?g:Ho(p,g.route.id);return{...await u(E,p,O,v,b,null,x,[Q.route.id,w]),statusCode:si(w.error)?w.error.status:w.statusCode!=null?w.statusCode:500,actionData:null,actionHeaders:{...w.headers?{[g.route.id]:w.headers}:{}}}}return{...await u(E,p,O,v,b,null,x),actionData:{[g.route.id]:w.data},...w.statusCode?{statusCode:w.statusCode}:{},actionHeaders:w.headers?{[g.route.id]:w.headers}:{}}}async function u(h,p,g,O,v,b,S,x){let P=b!=null;if(P&&!(b!=null&&b.route.loader)&&!(b!=null&&b.route.lazy))throw Yr(400,{method:h.method,pathname:new URL(h.url).pathname,routeId:b==null?void 0:b.route.id});let E=(b?[b]:x&&mi(x[1])?Qk(p,x[0]):p).filter(R=>(R.route.loader||R.route.lazy)&&(!S||S(R)));if(E.length===0)return{matches:p,loaderData:p.reduce((R,$)=>Object.assign(R,{[$.route.id]:null}),{}),errors:x&&mi(x[1])?{[x[0]]:x[1].error}:null,statusCode:200,loaderHeaders:{}};let M=await d("loader",h,E,p,P,g,O);h.signal.aborted&&$M(h,P);let Q=rq(p,M,x,!0,v),T=new Set(E.map(R=>R.route.id));return p.forEach(R=>{T.has(R.route.id)||(Q.loaderData[R.route.id]=null)}),{...Q,matches:p}}async function d(h,p,g,O,v,b,S){let x=await eq(S||Lk,h,p,g,O,null,t,i,b),P={};return await Promise.all(O.map(async w=>{if(!(w.route.id in x))return;let E=x[w.route.id];if(oq(E)){let M=E.result;throw nq(M,p,w.route.id,O,r)}if(Ir(E.result)&&v)throw E;P[w.route.id]=await tq(E)})),P}return{dataRoutes:o,query:s,queryRoute:a}}function H3(n,e,t,r){let i=r||e._deepestRenderedBoundaryId||n[0].id;return{...e,statusCode:si(t)?t.status:500,errors:{[i]:t}}}function $M(n,e){if(n.signal.reason!==void 0)throw n.signal.reason;let t=e?"queryRoute":"query";throw new Error(`${t}() call aborted without an \`AbortSignal.reason\`: ${n.method} ${n.url}`)}function nee(n){return n!=null&&("formData"in n&&n.formData!=null||"body"in n&&n.body!==void 0)}function Dk(n,e,t,r,i,o){let s,a;if(i){s=[];for(let c of e)if(s.push(c),c.route.id===i){a=c;break}}else s=e,a=e[e.length-1];let l=py(r||".",hy(s),vi(n.pathname,t)||n.pathname,o==="path");if(r==null&&(l.search=n.search,l.hash=n.hash),(r==null||r===""||r===".")&&a){let c=xx(l.search);if(a.route.index&&!c)l.search=l.search?l.search.replace(/^\?/,"?index&"):"?index";else if(!a.route.index&&c){let u=new URLSearchParams(l.search),d=u.getAll("index");u.delete("index"),d.filter(p=>p).forEach(p=>u.append("index",p));let h=u.toString();l.search=h?`?${h}`:""}}return t!=="/"&&(l.pathname=l.pathname==="/"?t:ca([t,l.pathname])),Yi(l)}function DM(n,e,t){if(!t||!nee(t))return{path:e};if(t.formMethod&&!Uk(t.formMethod))return{path:e,error:Yr(405,{method:t.formMethod})};let r=()=>({path:e,error:Yr(400,{type:"invalid-body"})}),o=(t.formMethod||"get").toUpperCase(),s=iq(e);if(t.body!==void 0){if(t.formEncType==="text/plain"){if(!Yo(o))return r();let d=typeof t.body=="string"?t.body:t.body instanceof FormData||t.body instanceof URLSearchParams?Array.from(t.body.entries()).reduce((h,[p,g])=>`${h}${p}=${g}
|
|
146
|
-
`,""):String(t.body);return{path:e,submission:{formMethod:o,formAction:s,formEncType:t.formEncType,formData:void 0,json:void 0,text:d}}}else if(t.formEncType==="application/json"){if(!Yo(o))return r();try{let d=typeof t.body=="string"?JSON.parse(t.body):t.body;return{path:e,submission:{formMethod:o,formAction:s,formEncType:t.formEncType,formData:void 0,json:d,text:void 0}}}catch{return r()}}}zt(typeof FormData=="function","FormData is not available in this environment");let a,l;if(t.formData)a=Nk(t.formData),l=t.formData;else if(t.body instanceof FormData)a=Nk(t.body),l=t.body;else if(t.body instanceof URLSearchParams)a=t.body,l=qM(a);else if(t.body==null)a=new URLSearchParams,l=new FormData;else try{a=new URLSearchParams(t.body),l=qM(a)}catch{return r()}let c={formMethod:o,formAction:s,formEncType:t&&t.formEncType||"application/x-www-form-urlencoded",formData:l,json:void 0,text:void 0};if(Yo(c.formMethod))return{path:e,submission:c};let u=jo(e);return n&&u.search&&xx(u.search)&&a.append("index",""),u.search=`?${a}`,{path:Yi(u),submission:c}}function Qk(n,e,t=!1){let r=n.findIndex(i=>i.route.id===e);return r>=0?n.slice(0,t?r+1:r):n}function QM(n,e,t,r,i,o,s,a,l,c,u,d,h,p){let g=p?mi(p[1])?p[1].error:p[1].data:void 0,O=n.createURL(e.location),v=n.createURL(i),b=t;o&&e.errors?b=Qk(t,Object.keys(e.errors)[0],!0):p&&mi(p[1])&&(b=Qk(t,p[0]));let S=p?p[1].statusCode:void 0,x=S&&S>=400,P=b.filter((E,M)=>{let{route:Q}=E;if(Q.lazy)return!0;if(Q.loader==null)return!1;if(o)return Ik(Q,e.loaderData,e.errors);if(ree(e.loaderData,e.matches[M],E))return!0;let T=e.matches[M],R=E;return IM(E,{currentUrl:O,currentParams:T.params,nextUrl:v,nextParams:R.params,...r,actionResult:g,actionStatus:S,defaultShouldRevalidate:x?!1:s||O.pathname+O.search===v.pathname+v.search||O.search!==v.search||iee(T,R)})}),w=[];return c.forEach((E,M)=>{if(o||!t.some(I=>I.route.id===E.routeId)||l.has(M))return;let Q=ho(d,E.path,h);if(!Q){w.push({key:M,routeId:E.routeId,path:E.path,matches:null,match:null,controller:null});return}let T=e.fetchers.get(M),R=Xc(Q,E.path),$=!1;u.has(M)?$=!1:a.has(M)?(a.delete(M),$=!0):T&&T.state!=="idle"&&T.data===void 0?$=s:$=IM(R,{currentUrl:O,currentParams:e.matches[e.matches.length-1].params,nextUrl:v,nextParams:t[t.length-1].params,...r,actionResult:g,actionStatus:S,defaultShouldRevalidate:x?!1:s}),$&&w.push({key:M,routeId:E.routeId,path:E.path,matches:Q,match:R,controller:new AbortController})}),[P,w]}function Ik(n,e,t){if(n.lazy)return!0;if(!n.loader)return!1;let r=e!=null&&e[n.id]!==void 0,i=t!=null&&t[n.id]!==void 0;return!r&&i?!1:typeof n.loader=="function"&&n.loader.hydrate===!0?!0:!r&&!i}function ree(n,e,t){let r=!e||t.route.id!==e.route.id,i=!n.hasOwnProperty(t.route.id);return r||i}function iee(n,e){let t=n.route.path;return n.pathname!==e.pathname||t!=null&&t.endsWith("*")&&n.params["*"]!==e.params["*"]}function IM(n,e){if(n.route.shouldRevalidate){let t=n.route.shouldRevalidate(e);if(typeof t=="boolean")return t}return e.defaultShouldRevalidate}function jM(n,e,t,r,i){let o;if(n){let l=r[n];zt(l,`No route found to patch children into: routeId = ${n}`),l.children||(l.children=[]),o=l.children}else o=t;let s=e.filter(l=>!o.some(c=>K3(l,c))),a=ou(s,i,[n||"_","patch",String((o==null?void 0:o.length)||"0")],r);o.push(...a)}function K3(n,e){return"id"in n&&"id"in e&&n.id===e.id?!0:n.index===e.index&&n.path===e.path&&n.caseSensitive===e.caseSensitive?(!n.children||n.children.length===0)&&(!e.children||e.children.length===0)?!0:n.children.every((t,r)=>{var i;return(i=e.children)==null?void 0:i.some(o=>K3(t,o))}):!1}var LM=new WeakMap;async function oee(n,e,t){let r=t[n.id];if(zt(r,"No route found in manifest"),!n.lazy)return;let i=LM.get(r);if(i){await i;return}let o=n.lazy().then(s=>{let a={};for(let l in s){let u=r[l]!==void 0&&l!=="hasErrorBoundary";yr(!u,`Route "${r.id}" has a static property "${l}" defined but its lazy function is also returning a value for this property. The lazy route property "${l}" will be ignored.`),yr(!AM.has(l),"Route property "+l+" is not a supported property to be returned from a lazy route function. This property will be ignored."),!u&&!AM.has(l)&&(a[l]=s[l])}Object.assign(r,a),Object.assign(r,{...e(r),lazy:void 0})});LM.set(r,o),await o}async function see(n,e){if(!n.unstable_lazyMiddleware)return;let t=e[n.id];if(zt(t,"No route found in manifest"),t.unstable_middleware)yr(!1,`Route "${t.id}" has a static property "unstable_middleware" defined. The "unstable_lazyMiddleware" function will be ignored.`);else{let r=await n.unstable_lazyMiddleware();if(!n.unstable_lazyMiddleware)return;t.unstable_middleware||(t.unstable_middleware=r)}t.unstable_lazyMiddleware=void 0}function jk(n,e){let t=n.map(r=>r.route.unstable_lazyMiddleware?see(r.route,e):void 0).filter(Boolean);return t.length>0?Promise.all(t):void 0}async function Lk(n){let e=n.matches.filter(i=>i.shouldLoad),t={};return(await Promise.all(e.map(i=>i.resolve()))).forEach((i,o)=>{t[e[o].route.id]=i}),t}async function aee(n){return n.matches.some(e=>e.route.unstable_middleware)?Zc(n,!1,()=>Lk(n),(e,t)=>({[t]:{type:"error",result:e}})):Lk(n)}async function Zc(n,e,t,r){let{matches:i,request:o,params:s,context:a}=n,l={handlerResult:void 0};try{let c=i.flatMap(d=>d.route.unstable_middleware?d.route.unstable_middleware.map(h=>[d.route.id,h]):[]),u=await J3({request:o,params:s,context:a},c,e,l,t);return e?u:l.handlerResult}catch(c){if(!l.middlewareError)throw c;let u=await r(l.middlewareError.error,l.middlewareError.routeId);return e||!l.handlerResult?u:Object.assign(l.handlerResult,u)}}async function J3(n,e,t,r,i,o=0){let{request:s}=n;if(s.signal.aborted)throw s.signal.reason?s.signal.reason:new Error(`Request aborted without an \`AbortSignal.reason\`: ${s.method} ${s.url}`);let a=e[o];if(!a)return r.handlerResult=await i(),r.handlerResult;let[l,c]=a,u=!1,d,h=async()=>{if(u)throw new Error("You may only call `next()` once per middleware");u=!0;let p=await J3(n,e,t,r,i,o+1);if(t)return d=p,d};try{let p=await c({request:n.request,params:n.params,context:n.context},h);return u?p===void 0?d:p:h()}catch(p){throw r.middlewareError?r.middlewareError.error!==p&&(r.middlewareError={routeId:l,error:p}):r.middlewareError={routeId:l,error:p},p}}async function eq(n,e,t,r,i,o,s,a,l){let c=jk(i,s),u=i.map(p=>p.route.lazy?oee(p.route,a,s):void 0);c&&await c;let d=i.map((p,g)=>{let O=u[g],v=r.some(S=>S.route.id===p.route.id);return{...p,shouldLoad:v,resolve:async S=>(S&&t.method==="GET"&&(p.route.lazy||p.route.loader)&&(v=!0),v?lee(e,t,p,O,S,l):Promise.resolve({type:"data",result:void 0}))}}),h=await n({matches:d,request:t,params:i[0].params,fetcherKey:o,context:l});try{await Promise.all(u)}catch{}return h}async function lee(n,e,t,r,i,o){let s,a,l=c=>{let u,d=new Promise((g,O)=>u=O);a=()=>u(),e.signal.addEventListener("abort",a);let h=g=>typeof c!="function"?Promise.reject(new Error(`You cannot call the handler for a route which defines a boolean "${n}" [routeId: ${t.route.id}]`)):c({request:e,params:t.params,context:o},...g!==void 0?[g]:[]),p=(async()=>{try{return{type:"data",result:await(i?i(O=>h(O)):h())}}catch(g){return{type:"error",result:g}}})();return Promise.race([p,d])};try{let c=t.route[n];if(r)if(c){let u,[d]=await Promise.all([l(c).catch(h=>{u=h}),r]);if(u!==void 0)throw u;s=d}else if(await r,c=t.route[n],c)s=await l(c);else if(n==="action"){let u=new URL(e.url),d=u.pathname+u.search;throw Yr(405,{method:e.method,pathname:d,routeId:t.route.id})}else return{type:"data",result:void 0};else if(c)s=await l(c);else{let u=new URL(e.url),d=u.pathname+u.search;throw Yr(404,{pathname:d})}}catch(c){return{type:"error",result:c}}finally{a&&e.signal.removeEventListener("abort",a)}return s}async function tq(n){var r,i,o,s,a,l;let{result:e,type:t}=n;if(Ir(e)){let c;try{let u=e.headers.get("Content-Type");u&&/\bapplication\/json\b/.test(u)?e.body==null?c=null:c=await e.json():c=await e.text()}catch(u){return{type:"error",error:u}}return t==="error"?{type:"error",error:new Qo(e.status,e.statusText,c),statusCode:e.status,headers:e.headers}:{type:"data",data:c,statusCode:e.status,headers:e.headers}}return t==="error"?qk(e)?e.data instanceof Error?{type:"error",error:e.data,statusCode:(r=e.init)==null?void 0:r.status,headers:(i=e.init)!=null&&i.headers?new Headers(e.init.headers):void 0}:{type:"error",error:new Qo(((o=e.init)==null?void 0:o.status)||500,void 0,e.data),statusCode:si(e)?e.status:void 0,headers:(s=e.init)!=null&&s.headers?new Headers(e.init.headers):void 0}:{type:"error",error:e,statusCode:si(e)?e.status:void 0}:qk(e)?{type:"data",data:e.data,statusCode:(a=e.init)==null?void 0:a.status,headers:(l=e.init)!=null&&l.headers?new Headers(e.init.headers):void 0}:{type:"data",data:e}}function nq(n,e,t,r,i){let o=n.headers.get("Location");if(zt(o,"Redirects returned/thrown from loaders/actions must have a Location header"),!Px.test(o)){let s=r.slice(0,r.findIndex(a=>a.route.id===t)+1);o=Dk(new URL(e.url),s,i,o),n.headers.set("Location",o)}return n}function NM(n,e,t){if(Px.test(n)){let r=n,i=r.startsWith("//")?new URL(e.protocol+r):new URL(r),o=vi(i.pathname,t)!=null;if(i.origin===e.origin&&o)return i.pathname+i.search+i.hash}return n}function qu(n,e,t,r){let i=n.createURL(iq(e)).toString(),o={signal:t};if(r&&Yo(r.formMethod)){let{formMethod:s,formEncType:a}=r;o.method=s.toUpperCase(),a==="application/json"?(o.headers=new Headers({"Content-Type":a}),o.body=JSON.stringify(r.json)):a==="text/plain"?o.body=r.text:a==="application/x-www-form-urlencoded"&&r.formData?o.body=Nk(r.formData):o.body=r.formData}return new Request(i,o)}function Nk(n){let e=new URLSearchParams;for(let[t,r]of n.entries())e.append(t,typeof r=="string"?r:r.name);return e}function qM(n){let e=new FormData;for(let[t,r]of n.entries())e.append(t,r);return e}function rq(n,e,t,r=!1,i=!1){let o={},s=null,a,l=!1,c={},u=t&&mi(t[1])?t[1].error:void 0;return n.forEach(d=>{if(!(d.route.id in e))return;let h=d.route.id,p=e[h];if(zt(!Nl(p),"Cannot handle redirect results in processLoaderData"),mi(p)){let g=p.error;if(u!==void 0&&(g=u,u=void 0),s=s||{},i)s[h]=g;else{let O=Ho(n,h);s[O.route.id]==null&&(s[O.route.id]=g)}r||(o[h]=Y3),l||(l=!0,a=si(p.error)?p.error.status:500),p.headers&&(c[h]=p.headers)}else o[h]=p.data,p.statusCode&&p.statusCode!==200&&!l&&(a=p.statusCode),p.headers&&(c[h]=p.headers)}),u!==void 0&&t&&(s={[t[0]]:u},o[t[0]]=void 0),{loaderData:o,errors:s,statusCode:a||200,loaderHeaders:c}}function UM(n,e,t,r,i,o){let{loaderData:s,errors:a}=rq(e,t,r);return i.forEach(l=>{let{key:c,match:u,controller:d}=l,h=o[c];if(zt(h,"Did not find corresponding fetcher result"),!(d&&d.signal.aborted))if(mi(h)){let p=Ho(n.matches,u==null?void 0:u.route.id);a&&a[p.route.id]||(a={...a,[p.route.id]:h.error}),n.fetchers.delete(c)}else if(Nl(h))zt(!1,"Unhandled fetcher revalidation redirect");else{let p=vl(h.data);n.fetchers.set(c,p)}}),{loaderData:s,errors:a}}function BM(n,e,t,r){let i=Object.entries(e).filter(([,o])=>o!==Y3).reduce((o,[s,a])=>(o[s]=a,o),{});for(let o of t){let s=o.route.id;if(!e.hasOwnProperty(s)&&n.hasOwnProperty(s)&&o.route.loader&&(i[s]=n[s]),r&&r.hasOwnProperty(s))break}return i}function FM(n){return n?mi(n[1])?{actionData:{}}:{actionData:{[n[0]]:n[1].data}}:{}}function Ho(n,e){return(e?n.slice(0,n.findIndex(r=>r.route.id===e)+1):[...n]).reverse().find(r=>r.route.hasErrorBoundary===!0)||n[0]}function Pv(n){let e=n.length===1?n[0]:n.find(t=>t.index||!t.path||t.path==="/")||{id:"__shim-error-route__"};return{matches:[{params:{},pathname:"",pathnameBase:"",route:e}],route:e}}function Yr(n,{pathname:e,routeId:t,method:r,type:i,message:o}={}){let s="Unknown Server Error",a="Unknown @remix-run/router error";return n===400?(s="Bad Request",r&&e&&t?a=`You made a ${r} request to "${e}" but did not provide a \`loader\` for route "${t}", so there is no way to handle the request.`:i==="invalid-body"&&(a="Unable to encode submission body")):n===403?(s="Forbidden",a=`Route "${t}" does not match URL "${e}"`):n===404?(s="Not Found",a=`No route matches URL "${e}"`):n===405&&(s="Method Not Allowed",r&&e&&t?a=`You made a ${r.toUpperCase()} request to "${e}" but did not provide an \`action\` for route "${t}", so there is no way to handle the request.`:r&&(a=`Invalid request method "${r.toUpperCase()}"`)),new Qo(n||500,s,new Error(a),!0)}function zm(n){let e=Object.entries(n);for(let t=e.length-1;t>=0;t--){let[r,i]=e[t];if(Nl(i))return{key:r,result:i}}}function iq(n){let e=typeof n=="string"?jo(n):n;return Yi({...e,hash:""})}function cee(n,e){return n.pathname!==e.pathname||n.search!==e.search?!1:n.hash===""?e.hash!=="":n.hash===e.hash?!0:e.hash!==""}function uee(n){return n!=null&&typeof n=="object"&&"type"in n&&"result"in n&&(n.type==="data"||n.type==="error")}function oq(n){return Ir(n.result)&&Z3.has(n.result.status)}function mi(n){return n.type==="error"}function Nl(n){return(n&&n.type)==="redirect"}function qk(n){return typeof n=="object"&&n!=null&&"type"in n&&"data"in n&&"init"in n&&n.type==="DataWithResponseInit"}function Ir(n){return n!=null&&typeof n.status=="number"&&typeof n.statusText=="string"&&typeof n.headers=="object"&&typeof n.body<"u"}function Oy(n){return Z3.has(n)}function vy(n){return Ir(n)&&Oy(n.status)&&n.headers.has("Location")}function Uk(n){return eee.has(n.toUpperCase())}function Yo(n){return KJ.has(n.toUpperCase())}function xx(n){return new URLSearchParams(n).getAll("index").some(e=>e==="")}function Xc(n,e){let t=typeof e=="string"?jo(e).search:e.search;if(n[n.length-1].route.index&&xx(t||""))return n[n.length-1];let r=F3(n);return r[r.length-1]}function VM(n){let{formMethod:e,formAction:t,formEncType:r,text:i,formData:o,json:s}=n;if(!(!e||!t||!r)){if(i!=null)return{formMethod:e,formAction:t,formEncType:r,formData:void 0,json:void 0,text:i};if(o!=null)return{formMethod:e,formAction:t,formEncType:r,formData:o,json:void 0,text:void 0};if(s!==void 0)return{formMethod:e,formAction:t,formEncType:r,formData:void 0,json:s,text:void 0}}}function cS(n,e){return e?{state:"loading",location:n,formMethod:e.formMethod,formAction:e.formAction,formEncType:e.formEncType,formData:e.formData,json:e.json,text:e.text}:{state:"loading",location:n,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,json:void 0,text:void 0}}function fee(n,e){return{state:"submitting",location:n,formMethod:e.formMethod,formAction:e.formAction,formEncType:e.formEncType,formData:e.formData,json:e.json,text:e.text}}function Bd(n,e){return n?{state:"loading",formMethod:n.formMethod,formAction:n.formAction,formEncType:n.formEncType,formData:n.formData,json:n.json,text:n.text,data:e}:{state:"loading",formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,json:void 0,text:void 0,data:e}}function dee(n,e){return{state:"submitting",formMethod:n.formMethod,formAction:n.formAction,formEncType:n.formEncType,formData:n.formData,json:n.json,text:n.text,data:e?e.data:void 0}}function vl(n){return{state:"idle",formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,json:void 0,text:void 0,data:n}}function hee(n,e){try{let t=n.sessionStorage.getItem(z3);if(t){let r=JSON.parse(t);for(let[i,o]of Object.entries(r||{}))o&&Array.isArray(o)&&e.set(i,new Set(o||[]))}}catch{}}function pee(n,e){if(e.size>0){let t={};for(let[r,i]of e)t[r]=[...i];try{n.sessionStorage.setItem(z3,JSON.stringify(t))}catch(r){yr(!1,`Failed to save applied view transitions in sessionStorage (${r}).`)}}}function mee(){let n,e,t=new Promise((r,i)=>{n=async o=>{r(o);try{await t}catch{}},e=async o=>{i(o);try{await t}catch{}}});return{promise:t,resolve:n,reject:e}}var Wa=D.createContext(null);Wa.displayName="DataRouter";var lc=D.createContext(null);lc.displayName="DataRouterState";var vp=D.createContext({isTransitioning:!1});vp.displayName="ViewTransition";var yp=D.createContext(new Map);yp.displayName="Fetchers";var Yh=D.createContext(null);Yh.displayName="Await";var vo=D.createContext(null);vo.displayName="Navigation";var uu=D.createContext(null);uu.displayName="Location";var yo=D.createContext({outlet:null,matches:[],isDataRoute:!1});yo.displayName="Route";var Cx=D.createContext(null);Cx.displayName="RouteError";function sq(n,{relative:e}={}){zt(cc(),"useHref() may be used only in the context of a <Router> component.");let{basename:t,navigator:r}=D.useContext(vo),{hash:i,pathname:o,search:s}=Kf(n,{relative:e}),a=o;return t!=="/"&&(a=o==="/"?t:ca([t,o])),r.createHref({pathname:a,search:s,hash:i})}function cc(){return D.useContext(uu)!=null}function bo(){return zt(cc(),"useLocation() may be used only in the context of a <Router> component."),D.useContext(uu).location}function gee(){return D.useContext(uu).navigationType}function Oee(n){zt(cc(),"useMatch() may be used only in the context of a <Router> component.");let{pathname:e}=bo();return D.useMemo(()=>Uf(n,U3(e)),[e,n])}var aq="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function lq(n){D.useContext(vo).static||D.useLayoutEffect(n)}function yy(){let{isDataRoute:n}=D.useContext(yo);return n?$ee():vee()}function vee(){zt(cc(),"useNavigate() may be used only in the context of a <Router> component.");let n=D.useContext(Wa),{basename:e,navigator:t}=D.useContext(vo),{matches:r}=D.useContext(yo),{pathname:i}=bo(),o=JSON.stringify(hy(r)),s=D.useRef(!1);return lq(()=>{s.current=!0}),D.useCallback((l,c={})=>{if(yr(s.current,aq),!s.current)return;if(typeof l=="number"){t.go(l);return}let u=py(l,JSON.parse(o),i,c.relative==="path");n==null&&e!=="/"&&(u.pathname=u.pathname==="/"?e:ca([e,u.pathname])),(c.replace?t.replace:t.push)(u,c.state,c)},[e,t,o,i,n])}var cq=D.createContext(null);function yee(){return D.useContext(cq)}function uq(n){let e=D.useContext(yo).outlet;return e&&D.createElement(cq.Provider,{value:n},e)}function bee(){let{matches:n}=D.useContext(yo),e=n[n.length-1];return e?e.params:{}}function Kf(n,{relative:e}={}){let{matches:t}=D.useContext(yo),{pathname:r}=bo(),i=JSON.stringify(hy(t));return D.useMemo(()=>py(n,JSON.parse(i),r,e==="path"),[n,i,r,e])}function fq(n,e){return Tx(n,e)}function Tx(n,e,t,r){var S;zt(cc(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:i,static:o}=D.useContext(vo),{matches:s}=D.useContext(yo),a=s[s.length-1],l=a?a.params:{},c=a?a.pathname:"/",u=a?a.pathnameBase:"/",d=a&&a.route;{let x=d&&d.path||"";gq(c,!d||x.endsWith("*")||x.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${c}" (under <Route path="${x}">) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render.
|
|
145
|
+
*/var D3=n=>{throw TypeError(n)},RJ=(n,e,t)=>e.has(n)||D3("Cannot "+t),aS=(n,e,t)=>(RJ(n,e,"read from private field"),t?t.call(n):e.get(n)),AJ=(n,e,t)=>e.has(n)?D3("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(n):e.set(n,t),Q3=(n=>(n.Pop="POP",n.Push="PUSH",n.Replace="REPLACE",n))(Q3||{}),AM="popstate";function I3(n={}){let{initialEntries:e=["/"],initialIndex:t,v5Compat:r=!1}=n,i;i=e.map((p,g)=>u(p,typeof p=="string"?null:p.state,g===0?"default":void 0));let o=l(t??i.length-1),s="POP",a=null;function l(p){return Math.min(Math.max(p,0),i.length-1)}function c(){return i[o]}function u(p,g=null,O){let v=Fa(i?c().pathname:"/",p,g,O);return yr(v.pathname.charAt(0)==="/",`relative pathnames are not supported in memory history: ${JSON.stringify(p)}`),v}function d(p){return typeof p=="string"?p:Yi(p)}return{get index(){return o},get action(){return s},get location(){return c()},createHref:d,createURL(p){return new URL(d(p),"http://localhost")},encodeLocation(p){let g=typeof p=="string"?jo(p):p;return{pathname:g.pathname||"",search:g.search||"",hash:g.hash||""}},push(p,g){s="PUSH";let O=u(p,g);o+=1,i.splice(o,i.length,O),r&&a&&a({action:s,location:O,delta:1})},replace(p,g){s="REPLACE";let O=u(p,g);i[o]=O,r&&a&&a({action:s,location:O,delta:0})},go(p){s="POP";let g=l(o+p),O=i[g];o=g,a&&a({action:s,location:O,delta:p})},listen(p){return a=p,()=>{a=null}}}}function dy(n={}){function e(r,i){let{pathname:o,search:s,hash:a}=r.location;return Fa("",{pathname:o,search:s,hash:a},i.state&&i.state.usr||null,i.state&&i.state.key||"default")}function t(r,i){return typeof i=="string"?i:Yi(i)}return L3(e,t,null,n)}function j3(n={}){function e(i,o){let{pathname:s="/",search:a="",hash:l=""}=jo(i.location.hash.substring(1));return!s.startsWith("/")&&!s.startsWith(".")&&(s="/"+s),Fa("",{pathname:s,search:a,hash:l},o.state&&o.state.usr||null,o.state&&o.state.key||"default")}function t(i,o){let s=i.document.querySelector("base"),a="";if(s&&s.getAttribute("href")){let l=i.location.href,c=l.indexOf("#");a=c===-1?l:l.slice(0,c)}return a+"#"+(typeof o=="string"?o:Yi(o))}function r(i,o){yr(i.pathname.charAt(0)==="/",`relative pathnames are not supported in hash history.push(${JSON.stringify(o)})`)}return L3(e,t,r,n)}function zt(n,e){if(n===!1||n===null||typeof n>"u")throw new Error(e)}function yr(n,e){if(!n){typeof console<"u"&&console.warn(e);try{throw new Error(e)}catch{}}}function MJ(){return Math.random().toString(36).substring(2,10)}function MM(n,e){return{usr:n.state,key:n.key,idx:e}}function Fa(n,e,t=null,r){return{pathname:typeof n=="string"?n:n.pathname,search:"",hash:"",...typeof e=="string"?jo(e):e,state:t,key:e&&e.key||r||MJ()}}function Yi({pathname:n="/",search:e="",hash:t=""}){return e&&e!=="?"&&(n+=e.charAt(0)==="?"?e:"?"+e),t&&t!=="#"&&(n+=t.charAt(0)==="#"?t:"#"+t),n}function jo(n){let e={};if(n){let t=n.indexOf("#");t>=0&&(e.hash=n.substring(t),n=n.substring(0,t));let r=n.indexOf("?");r>=0&&(e.search=n.substring(r),n=n.substring(0,r)),n&&(e.pathname=n)}return e}function L3(n,e,t,r={}){let{window:i=document.defaultView,v5Compat:o=!1}=r,s=i.history,a="POP",l=null,c=u();c==null&&(c=0,s.replaceState({...s.state,idx:c},""));function u(){return(s.state||{idx:null}).idx}function d(){a="POP";let v=u(),b=v==null?null:v-c;c=v,l&&l({action:a,location:O.location,delta:b})}function h(v,b){a="PUSH";let S=Fa(O.location,v,b);t&&t(S,v),c=u()+1;let x=MM(S,c),P=O.createHref(S);try{s.pushState(x,"",P)}catch(w){if(w instanceof DOMException&&w.name==="DataCloneError")throw w;i.location.assign(P)}o&&l&&l({action:a,location:O.location,delta:1})}function p(v,b){a="REPLACE";let S=Fa(O.location,v,b);t&&t(S,v),c=u();let x=MM(S,c),P=O.createHref(S);s.replaceState(x,"",P),o&&l&&l({action:a,location:O.location,delta:0})}function g(v){let b=i.location.origin!=="null"?i.location.origin:i.location.href,S=typeof v=="string"?v:Yi(v);return S=S.replace(/ $/,"%20"),zt(b,`No window.location.(origin|href) available to create URL for href: ${S}`),new URL(S,b)}let O={get action(){return a},get location(){return n(i,s)},listen(v){if(l)throw new Error("A history only accepts one active listener");return i.addEventListener(AM,d),l=v,()=>{i.removeEventListener(AM,d),l=null}},createHref(v){return e(i,v)},createURL:g,encodeLocation(v){let b=g(v);return{pathname:b.pathname,search:b.search,hash:b.hash}},push:h,replace:p,go(v){return s.go(v)}};return O}function $J(n){return{defaultValue:n}}var fh,Ll=class{constructor(n){if(AJ(this,fh,new Map),n)for(let[e,t]of n)this.set(e,t)}get(n){if(aS(this,fh).has(n))return aS(this,fh).get(n);if(n.defaultValue!==void 0)return n.defaultValue;throw new Error("No value found for context")}set(n,e){aS(this,fh).set(n,e)}};fh=new WeakMap;var $M=new Set(["lazy","caseSensitive","path","id","index","unstable_middleware","unstable_lazyMiddleware","children"]);function DJ(n){return n.index===!0}function ou(n,e,t=[],r={}){return n.map((i,o)=>{let s=[...t,String(o)],a=typeof i.id=="string"?i.id:s.join("-");if(zt(i.index!==!0||!i.children,"Cannot specify children on an index route"),zt(!r[a],`Found a route id collision on id "${a}". Route id's must be globally unique within Data Router usages`),DJ(i)){let l={...i,...e(i),id:a};return r[a]=l,l}else{let l={...i,...e(i),id:a,children:void 0};return r[a]=l,i.children&&(l.children=ou(i.children,e,s,r)),l}})}function ho(n,e,t="/"){return QO(n,e,t,!1)}function QO(n,e,t,r){let i=typeof e=="string"?jo(e):e,o=vi(i.pathname||"/",t);if(o==null)return null;let s=q3(n);QJ(s);let a=null;for(let l=0;a==null&&l<s.length;++l){let c=B3(o);a=VJ(s[l],c,r)}return a}function N3(n,e){let{route:t,pathname:r,params:i}=n;return{id:t.id,pathname:r,params:i,data:e[t.id],handle:t.handle}}function q3(n,e=[],t=[],r=""){let i=(o,s,a)=>{let l={relativePath:a===void 0?o.path||"":a,caseSensitive:o.caseSensitive===!0,childrenIndex:s,route:o};l.relativePath.startsWith("/")&&(zt(l.relativePath.startsWith(r),`Absolute route path "${l.relativePath}" nested under path "${r}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),l.relativePath=l.relativePath.slice(r.length));let c=ca([r,l.relativePath]),u=t.concat(l);o.children&&o.children.length>0&&(zt(o.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${c}".`),q3(o.children,e,u,c)),!(o.path==null&&!o.index)&&e.push({path:c,score:BJ(c,o.index),routesMeta:u})};return n.forEach((o,s)=>{var a;if(o.path===""||!((a=o.path)!=null&&a.includes("?")))i(o,s);else for(let l of U3(o.path))i(o,s,l)}),e}function U3(n){let e=n.split("/");if(e.length===0)return[];let[t,...r]=e,i=t.endsWith("?"),o=t.replace(/\?$/,"");if(r.length===0)return i?[o,""]:[o];let s=U3(r.join("/")),a=[];return a.push(...s.map(l=>l===""?o:[o,l].join("/"))),i&&a.push(...s),a.map(l=>n.startsWith("/")&&l===""?"/":l)}function QJ(n){n.sort((e,t)=>e.score!==t.score?t.score-e.score:FJ(e.routesMeta.map(r=>r.childrenIndex),t.routesMeta.map(r=>r.childrenIndex)))}var IJ=/^:[\w-]+$/,jJ=3,LJ=2,NJ=1,qJ=10,UJ=-2,DM=n=>n==="*";function BJ(n,e){let t=n.split("/"),r=t.length;return t.some(DM)&&(r+=UJ),e&&(r+=LJ),t.filter(i=>!DM(i)).reduce((i,o)=>i+(IJ.test(o)?jJ:o===""?NJ:qJ),r)}function FJ(n,e){return n.length===e.length&&n.slice(0,-1).every((r,i)=>r===e[i])?n[n.length-1]-e[e.length-1]:0}function VJ(n,e,t=!1){let{routesMeta:r}=n,i={},o="/",s=[];for(let a=0;a<r.length;++a){let l=r[a],c=a===r.length-1,u=o==="/"?e:e.slice(o.length)||"/",d=Uf({path:l.relativePath,caseSensitive:l.caseSensitive,end:c},u),h=l.route;if(!d&&c&&t&&!r[r.length-1].route.index&&(d=Uf({path:l.relativePath,caseSensitive:l.caseSensitive,end:!1},u)),!d)return null;Object.assign(i,d.params),s.push({params:i,pathname:ca([o,d.pathname]),pathnameBase:zJ(ca([o,d.pathnameBase])),route:h}),d.pathnameBase!=="/"&&(o=ca([o,d.pathnameBase]))}return s}function WJ(n,e={}){let t=n;t.endsWith("*")&&t!=="*"&&!t.endsWith("/*")&&(yr(!1,`Route path "${t}" will be treated as if it were "${t.replace(/\*$/,"/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${t.replace(/\*$/,"/*")}".`),t=t.replace(/\*$/,"/*"));const r=t.startsWith("/")?"/":"",i=s=>s==null?"":typeof s=="string"?s:String(s),o=t.split(/\/+/).map((s,a,l)=>{if(a===l.length-1&&s==="*")return i(e["*"]);const u=s.match(/^:([\w-]+)(\??)$/);if(u){const[,d,h]=u;let p=e[d];return zt(h==="?"||p!=null,`Missing ":${d}" param`),i(p)}return s.replace(/\?$/g,"")}).filter(s=>!!s);return r+o.join("/")}function Uf(n,e){typeof n=="string"&&(n={path:n,caseSensitive:!1,end:!0});let[t,r]=ZJ(n.path,n.caseSensitive,n.end),i=e.match(t);if(!i)return null;let o=i[0],s=o.replace(/(.)\/+$/,"$1"),a=i.slice(1);return{params:r.reduce((c,{paramName:u,isOptional:d},h)=>{if(u==="*"){let g=a[h]||"";s=o.slice(0,o.length-g.length).replace(/(.)\/+$/,"$1")}const p=a[h];return d&&!p?c[u]=void 0:c[u]=(p||"").replace(/%2F/g,"/"),c},{}),pathname:o,pathnameBase:s,pattern:n}}function ZJ(n,e=!1,t=!0){yr(n==="*"||!n.endsWith("*")||n.endsWith("/*"),`Route path "${n}" will be treated as if it were "${n.replace(/\*$/,"/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${n.replace(/\*$/,"/*")}".`);let r=[],i="^"+n.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(s,a,l)=>(r.push({paramName:a,isOptional:l!=null}),l?"/?([^\\/]+)?":"/([^\\/]+)"));return n.endsWith("*")?(r.push({paramName:"*"}),i+=n==="*"||n==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):t?i+="\\/*$":n!==""&&n!=="/"&&(i+="(?:(?=\\/|$))"),[new RegExp(i,e?void 0:"i"),r]}function B3(n){try{return n.split("/").map(e=>decodeURIComponent(e).replace(/\//g,"%2F")).join("/")}catch(e){return yr(!1,`The URL path "${n}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${e}).`),n}}function vi(n,e){if(e==="/")return n;if(!n.toLowerCase().startsWith(e.toLowerCase()))return null;let t=e.endsWith("/")?e.length-1:e.length,r=n.charAt(t);return r&&r!=="/"?null:n.slice(t)||"/"}function F3(n,e="/"){let{pathname:t,search:r="",hash:i=""}=typeof n=="string"?jo(n):n;return{pathname:t?t.startsWith("/")?t:XJ(t,e):e,search:YJ(r),hash:GJ(i)}}function XJ(n,e){let t=e.replace(/\/+$/,"").split("/");return n.split("/").forEach(i=>{i===".."?t.length>1&&t.pop():i!=="."&&t.push(i)}),t.length>1?t.join("/"):"/"}function lS(n,e,t,r){return`Cannot include a '${n}' character in a manually specified \`to.${e}\` field [${JSON.stringify(r)}]. Please separate it out to the \`to.${t}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`}function V3(n){return n.filter((e,t)=>t===0||e.route.path&&e.route.path.length>0)}function hy(n){let e=V3(n);return e.map((t,r)=>r===e.length-1?t.pathname:t.pathnameBase)}function py(n,e,t,r=!1){let i;typeof n=="string"?i=jo(n):(i={...n},zt(!i.pathname||!i.pathname.includes("?"),lS("?","pathname","search",i)),zt(!i.pathname||!i.pathname.includes("#"),lS("#","pathname","hash",i)),zt(!i.search||!i.search.includes("#"),lS("#","search","hash",i)));let o=n===""||i.pathname==="",s=o?"/":i.pathname,a;if(s==null)a=t;else{let d=e.length-1;if(!r&&s.startsWith("..")){let h=s.split("/");for(;h[0]==="..";)h.shift(),d-=1;i.pathname=h.join("/")}a=d>=0?e[d]:"/"}let l=F3(i,a),c=s&&s!=="/"&&s.endsWith("/"),u=(o||s===".")&&t.endsWith("/");return!l.pathname.endsWith("/")&&(c||u)&&(l.pathname+="/"),l}var ca=n=>n.join("/").replace(/\/\/+/g,"/"),zJ=n=>n.replace(/\/+$/,"").replace(/^\/*/,"/"),YJ=n=>!n||n==="?"?"":n.startsWith("?")?n:"?"+n,GJ=n=>!n||n==="#"?"":n.startsWith("#")?n:"#"+n,HJ=class{constructor(n,e){this.type="DataWithResponseInit",this.data=n,this.init=e||null}};function W3(n,e){return new HJ(n,typeof e=="number"?{status:e}:e)}var my=(n,e=302)=>{let t=e;typeof t=="number"?t={status:t}:typeof t.status>"u"&&(t.status=302);let r=new Headers(t.headers);return r.set("Location",n),new Response(null,{...t,headers:r})},KJ=(n,e)=>{let t=my(n,e);return t.headers.set("X-Remix-Reload-Document","true"),t},JJ=(n,e)=>{let t=my(n,e);return t.headers.set("X-Remix-Replace","true"),t},Qo=class{constructor(n,e,t,r=!1){this.status=n,this.statusText=e||"",this.internal=r,t instanceof Error?(this.data=t.toString(),this.error=t):this.data=t}};function si(n){return n!=null&&typeof n.status=="number"&&typeof n.statusText=="string"&&typeof n.internal=="boolean"&&"data"in n}var Z3=["POST","PUT","PATCH","DELETE"],eee=new Set(Z3),tee=["GET",...Z3],nee=new Set(tee),X3=new Set([301,302,303,307,308]),ree=new Set([307,308]),kh={state:"idle",location:void 0,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,json:void 0,text:void 0},gy={state:"idle",data:void 0,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,json:void 0,text:void 0},Rl={state:"unblocked",proceed:void 0,reset:void 0,location:void 0},Px=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,z3=n=>({hasErrorBoundary:!!n.hasErrorBoundary}),Y3="remix-router-transitions",G3=Symbol("ResetLoaderData");function Op(n){const e=n.window?n.window:typeof window<"u"?window:void 0,t=typeof e<"u"&&typeof e.document<"u"&&typeof e.document.createElement<"u";zt(n.routes.length>0,"You must provide a non-empty routes array to createRouter");let r=n.mapRouteProperties||z3,i={},o=ou(n.routes,r,void 0,i),s,a=n.basename||"/",l=n.dataStrategy||cee,c={unstable_middleware:!1,...n.future},u=null,d=new Set,h=null,p=null,g=null,O=n.hydrationData!=null,v=ho(o,n.history.location,a),b=!1,S=null;if(v==null&&!n.patchRoutesOnNavigation){let re=Yr(404,{pathname:n.history.location.pathname}),{matches:de,route:ye}=Pv(o);v=de,S={[ye.id]:re}}v&&!n.hydrationData&&hn(v,o,n.history.location.pathname).active&&(v=null);let x;if(v)if(v.some(re=>re.route.lazy))x=!1;else if(!v.some(re=>re.route.loader))x=!0;else{let re=n.hydrationData?n.hydrationData.loaderData:null,de=n.hydrationData?n.hydrationData.errors:null;if(de){let ye=v.findIndex(Ue=>de[Ue.route.id]!==void 0);x=v.slice(0,ye+1).every(Ue=>!Ik(Ue.route,re,de))}else x=v.every(ye=>!Ik(ye.route,re,de))}else{x=!1,v=[];let re=hn(null,o,n.history.location.pathname);re.active&&re.matches&&(b=!0,v=re.matches)}let P,w={historyAction:n.history.action,location:n.history.location,matches:v,initialized:x,navigation:kh,restoreScrollPosition:n.hydrationData!=null?!1:null,preventScrollReset:!1,revalidation:"idle",loaderData:n.hydrationData&&n.hydrationData.loaderData||{},actionData:n.hydrationData&&n.hydrationData.actionData||null,errors:n.hydrationData&&n.hydrationData.errors||S,fetchers:new Map,blockers:new Map},E="POP",M=!1,Q,T=!1,R=new Map,$=null,I=!1,B=!1,H=new Set,oe=new Map,F=0,Z=-1,W=new Map,te=new Set,ie=new Map,K=new Map,se=new Set,ee=new Map,le,ge=null;function Le(){if(u=n.history.listen(({action:re,location:de,delta:ye})=>{if(le){le(),le=void 0;return}yr(ee.size===0||ye!=null,"You are trying to use a blocker on a POP navigation to a location that was not created by @remix-run/router. This will fail silently in production. This can happen if you are navigating outside the router via `window.history.pushState`/`window.location.hash` instead of using router navigation APIs. This can also happen if you are using createHashRouter and the user manually changes the URL.");let Ue=Bt({currentLocation:w.location,nextLocation:de,historyAction:re});if(Ue&&ye!=null){let et=new Promise(Tt=>{le=Tt});n.history.go(ye*-1),vt(Ue,{state:"blocked",location:de,proceed(){vt(Ue,{state:"proceeding",proceed:void 0,reset:void 0,location:de}),et.then(()=>n.history.go(ye))},reset(){let Tt=new Map(w.blockers);Tt.set(Ue,Rl),z({blockers:Tt})}});return}return Ce(re,de)}),t){mee(e,R);let re=()=>gee(e,R);e.addEventListener("pagehide",re),$=()=>e.removeEventListener("pagehide",re)}return w.initialized||Ce("POP",w.location,{initialHydration:!0}),P}function L(){u&&u(),$&&$(),d.clear(),Q&&Q.abort(),w.fetchers.forEach((re,de)=>it(de)),w.blockers.forEach((re,de)=>mt(de))}function V(re){return d.add(re),()=>d.delete(re)}function z(re,de={}){w={...w,...re};let ye=[],Ue=[];w.fetchers.forEach((et,Tt)=>{et.state==="idle"&&(se.has(Tt)?ye.push(Tt):Ue.push(Tt))}),se.forEach(et=>{!w.fetchers.has(et)&&!oe.has(et)&&ye.push(et)}),[...d].forEach(et=>et(w,{deletedFetchers:ye,viewTransitionOpts:de.viewTransitionOpts,flushSync:de.flushSync===!0})),ye.forEach(et=>it(et)),Ue.forEach(et=>w.fetchers.delete(et))}function pe(re,de,{flushSync:ye}={}){var Re,Te;let Ue=w.actionData!=null&&w.navigation.formMethod!=null&&Yo(w.navigation.formMethod)&&w.navigation.state==="loading"&&((Re=re.state)==null?void 0:Re._isRedirect)!==!0,et;de.actionData?Object.keys(de.actionData).length>0?et=de.actionData:et=null:Ue?et=w.actionData:et=null;let Tt=de.loaderData?VM(w.loaderData,de.loaderData,de.matches||[],de.errors):w.loaderData,ot=w.blockers;ot.size>0&&(ot=new Map(ot),ot.forEach((we,pt)=>ot.set(pt,Rl)));let Ae=M===!0||w.navigation.formMethod!=null&&Yo(w.navigation.formMethod)&&((Te=re.state)==null?void 0:Te._isRedirect)!==!0;s&&(o=s,s=void 0),I||E==="POP"||(E==="PUSH"?n.history.push(re,re.state):E==="REPLACE"&&n.history.replace(re,re.state));let je;if(E==="POP"){let we=R.get(w.location.pathname);we&&we.has(re.pathname)?je={currentLocation:w.location,nextLocation:re}:R.has(re.pathname)&&(je={currentLocation:re,nextLocation:w.location})}else if(T){let we=R.get(w.location.pathname);we?we.add(re.pathname):(we=new Set([re.pathname]),R.set(w.location.pathname,we)),je={currentLocation:w.location,nextLocation:re}}z({...de,actionData:et,loaderData:Tt,historyAction:E,location:re,initialized:!0,navigation:kh,revalidation:"idle",restoreScrollPosition:Ft(re,de.matches||w.matches),preventScrollReset:Ae,blockers:ot},{viewTransitionOpts:je,flushSync:ye===!0}),E="POP",M=!1,T=!1,I=!1,B=!1,ge==null||ge.resolve(),ge=null}async function _e(re,de){if(typeof re=="number"){n.history.go(re);return}let ye=Dk(w.location,w.matches,a,re,de==null?void 0:de.fromRouteId,de==null?void 0:de.relative),{path:Ue,submission:et,error:Tt}=IM(!1,ye,de),ot=w.location,Ae=Fa(w.location,Ue,de&&de.state);Ae={...Ae,...n.history.encodeLocation(Ae)};let je=de&&de.replace!=null?de.replace:void 0,Re="PUSH";je===!0?Re="REPLACE":je===!1||et!=null&&Yo(et.formMethod)&&et.formAction===w.location.pathname+w.location.search&&(Re="REPLACE");let Te=de&&"preventScrollReset"in de?de.preventScrollReset===!0:void 0,we=(de&&de.flushSync)===!0,pt=Bt({currentLocation:ot,nextLocation:Ae,historyAction:Re});if(pt){vt(pt,{state:"blocked",location:Ae,proceed(){vt(pt,{state:"proceeding",proceed:void 0,reset:void 0,location:Ae}),_e(re,de)},reset(){let Et=new Map(w.blockers);Et.set(pt,Rl),z({blockers:Et})}});return}await Ce(Re,Ae,{submission:et,pendingError:Tt,preventScrollReset:Te,replace:de&&de.replace,enableViewTransition:de&&de.viewTransition,flushSync:we})}function Me(){ge||(ge=Oee()),ve(),z({revalidation:"loading"});let re=ge.promise;return w.navigation.state==="submitting"?re:w.navigation.state==="idle"?(Ce(w.historyAction,w.location,{startUninterruptedRevalidation:!0}),re):(Ce(E||w.historyAction,w.navigation.location,{overrideNavigation:w.navigation,enableViewTransition:T===!0}),re)}async function Ce(re,de,ye){Q&&Q.abort(),Q=null,E=re,I=(ye&&ye.startUninterruptedRevalidation)===!0,Pt(w.location,w.matches),M=(ye&&ye.preventScrollReset)===!0,T=(ye&&ye.enableViewTransition)===!0;let Ue=s||o,et=ye&&ye.overrideNavigation,Tt=ye!=null&&ye.initialHydration&&w.matches&&w.matches.length>0&&!b?w.matches:ho(Ue,de,a),ot=(ye&&ye.flushSync)===!0;if(Tt&&w.initialized&&!B&&fee(w.location,de)&&!(ye&&ye.submission&&Yo(ye.submission.formMethod))){pe(de,{matches:Tt},{flushSync:ot});return}let Ae=hn(Tt,Ue,de.pathname);if(Ae.active&&Ae.matches&&(Tt=Ae.matches),!Tt){let{error:Ht,notFoundMatches:tn,route:nn}=Xe(de.pathname);pe(de,{matches:tn,loaderData:{},errors:{[nn.id]:Ht}},{flushSync:ot});return}Q=new AbortController;let je=qu(n.history,de,Q.signal,ye&&ye.submission),Re=new Ll(n.unstable_getContext?await n.unstable_getContext():void 0),Te;if(ye&&ye.pendingError)Te=[Ho(Tt).route.id,{type:"error",error:ye.pendingError}];else if(ye&&ye.submission&&Yo(ye.submission.formMethod)){let Ht=await Ne(je,de,ye.submission,Tt,Re,Ae.active,{replace:ye.replace,flushSync:ot});if(Ht.shortCircuited)return;if(Ht.pendingActionResult){let[tn,nn]=Ht.pendingActionResult;if(mi(nn)&&si(nn.error)&&nn.error.status===404){Q=null,pe(de,{matches:Ht.matches,loaderData:{},errors:{[tn]:nn.error}});return}}Tt=Ht.matches||Tt,Te=Ht.pendingActionResult,et=cS(de,ye.submission),ot=!1,Ae.active=!1,je=qu(n.history,je.url,je.signal)}let{shortCircuited:we,matches:pt,loaderData:Et,errors:Lt}=await st(je,de,Tt,Re,Ae.active,et,ye&&ye.submission,ye&&ye.fetcherSubmission,ye&&ye.replace,ye&&ye.initialHydration===!0,ot,Te);we||(Q=null,pe(de,{matches:pt||Tt,...WM(Te),loaderData:Et,errors:Lt}))}async function Ne(re,de,ye,Ue,et,Tt,ot={}){ve();let Ae=hee(de,ye);if(z({navigation:Ae},{flushSync:ot.flushSync===!0}),Tt){let Te=await Pn(Ue,de.pathname,re.signal);if(Te.type==="aborted")return{shortCircuited:!0};if(Te.type==="error"){let we=Ho(Te.partialMatches).route.id;return{matches:Te.partialMatches,pendingActionResult:[we,{type:"error",error:Te.error}]}}else if(Te.matches)Ue=Te.matches;else{let{notFoundMatches:we,error:pt,route:Et}=Xe(de.pathname);return{matches:we,pendingActionResult:[Et.id,{type:"error",error:pt}]}}}let je,Re=Xc(Ue,de);if(!Re.route.action&&!Re.route.lazy)je={type:"error",error:Yr(405,{method:re.method,pathname:de.pathname,routeId:Re.route.id})};else{let Te=await Cn("action",re,[Re],Ue,et,null);if(je=Te[Re.route.id],!je){for(let we of Ue)if(Te[we.route.id]){je=Te[we.route.id];break}}if(re.signal.aborted)return{shortCircuited:!0}}if(Nl(je)){let Te;return ot&&ot.replace!=null?Te=ot.replace:Te=UM(je.response.headers.get("Location"),new URL(re.url),a)===w.location.pathname+w.location.search,await kn(re,je,!0,{submission:ye,replace:Te}),{shortCircuited:!0}}if(mi(je)){let Te=Ho(Ue,Re.route.id);return(ot&&ot.replace)!==!0&&(E="PUSH"),{matches:Ue,pendingActionResult:[Te.route.id,je]}}return{matches:Ue,pendingActionResult:[Re.route.id,je]}}async function st(re,de,ye,Ue,et,Tt,ot,Ae,je,Re,Te,we){let pt=Tt||cS(de,ot),Et=ot||Ae||ZM(pt),Lt=!I&&!Re;if(et){if(Lt){let J=wt(we);z({navigation:pt,...J!==void 0?{actionData:J}:{}},{flushSync:Te})}let G=await Pn(ye,de.pathname,re.signal);if(G.type==="aborted")return{shortCircuited:!0};if(G.type==="error"){let J=Ho(G.partialMatches).route.id;return{matches:G.partialMatches,loaderData:{},errors:{[J]:G.error}}}else if(G.matches)ye=G.matches;else{let{error:J,notFoundMatches:ce,route:Qe}=Xe(de.pathname);return{matches:ce,loaderData:{},errors:{[Qe.id]:J}}}}let Ht=s||o,[tn,nn]=jM(n.history,w,ye,Et,de,Re===!0,B,H,se,ie,te,Ht,a,we);if(Z=++F,tn.length===0&&nn.length===0){let G=lt();return pe(de,{matches:ye,loaderData:{},errors:we&&mi(we[1])?{[we[0]]:we[1].error}:null,...WM(we),...G?{fetchers:new Map(w.fetchers)}:{}},{flushSync:Te}),{shortCircuited:!0}}if(Lt){let G={};if(!et){G.navigation=pt;let J=wt(we);J!==void 0&&(G.actionData=J)}nn.length>0&&(G.fetchers=un(nn)),z(G,{flushSync:Te})}nn.forEach(G=>{kt(G.key),G.controller&&oe.set(G.key,G.controller)});let Ln=()=>nn.forEach(G=>kt(G.key));Q&&Q.signal.addEventListener("abort",Ln);let{loaderResults:rn,fetcherResults:Ut}=await j(ye,tn,nn,re,Ue);if(re.signal.aborted)return{shortCircuited:!0};Q&&Q.signal.removeEventListener("abort",Ln),nn.forEach(G=>oe.delete(G.key));let gt=zm(rn);if(gt)return await kn(re,gt.result,!0,{replace:je}),{shortCircuited:!0};if(gt=zm(Ut),gt)return te.add(gt.key),await kn(re,gt.result,!0,{replace:je}),{shortCircuited:!0};let{loaderData:On,errors:Kn}=FM(w,ye,rn,we,nn,Ut);Re&&w.errors&&(Kn={...w.errors,...Kn});let pn=lt(),Mr=nt(Z),Sr=pn||Mr||nn.length>0;return{matches:ye,loaderData:On,errors:Kn,...Sr?{fetchers:new Map(w.fetchers)}:{}}}function wt(re){if(re&&!mi(re[1]))return{[re[0]]:re[1].data};if(w.actionData)return Object.keys(w.actionData).length===0?null:w.actionData}function un(re){return re.forEach(de=>{let ye=w.fetchers.get(de.key),Ue=Bd(void 0,ye?ye.data:void 0);w.fetchers.set(de.key,Ue)}),new Map(w.fetchers)}async function Vn(re,de,ye,Ue){kt(re);let et=(Ue&&Ue.flushSync)===!0,Tt=s||o,ot=Dk(w.location,w.matches,a,ye,de,Ue==null?void 0:Ue.relative),Ae=ho(Tt,ot,a),je=hn(Ae,Tt,ot);if(je.active&&je.matches&&(Ae=je.matches),!Ae){He(re,de,Yr(404,{pathname:ot}),{flushSync:et});return}let{path:Re,submission:Te,error:we}=IM(!0,ot,Ue);if(we){He(re,de,we,{flushSync:et});return}let pt=Xc(Ae,Re),Et=new Ll(n.unstable_getContext?await n.unstable_getContext():void 0),Lt=(Ue&&Ue.preventScrollReset)===!0;if(Te&&Yo(Te.formMethod)){await Sn(re,de,Re,pt,Ae,Et,je.active,et,Lt,Te);return}ie.set(re,{routeId:de,path:Re}),await wn(re,de,Re,pt,Ae,Et,je.active,et,Lt,Te)}async function Sn(re,de,ye,Ue,et,Tt,ot,Ae,je,Re){ve(),ie.delete(re);function Te(me){if(!me.route.action&&!me.route.lazy){let Be=Yr(405,{method:Re.formMethod,pathname:ye,routeId:de});return He(re,de,Be,{flushSync:Ae}),!0}return!1}if(!ot&&Te(Ue))return;let we=w.fetchers.get(re);Fe(re,pee(Re,we),{flushSync:Ae});let pt=new AbortController,Et=qu(n.history,ye,pt.signal,Re);if(ot){let me=await Pn(et,ye,Et.signal,re);if(me.type==="aborted")return;if(me.type==="error"){He(re,de,me.error,{flushSync:Ae});return}else if(me.matches){if(et=me.matches,Ue=Xc(et,ye),Te(Ue))return}else{He(re,de,Yr(404,{pathname:ye}),{flushSync:Ae});return}}oe.set(re,pt);let Lt=F,tn=(await Cn("action",Et,[Ue],et,Tt,re))[Ue.route.id];if(Et.signal.aborted){oe.get(re)===pt&&oe.delete(re);return}if(se.has(re)){if(Nl(tn)||mi(tn)){Fe(re,vl(void 0));return}}else{if(Nl(tn))if(oe.delete(re),Z>Lt){Fe(re,vl(void 0));return}else return te.add(re),Fe(re,Bd(Re)),kn(Et,tn,!1,{fetcherSubmission:Re,preventScrollReset:je});if(mi(tn)){He(re,de,tn.error);return}}let nn=w.navigation.location||w.location,Ln=qu(n.history,nn,pt.signal),rn=s||o,Ut=w.navigation.state!=="idle"?ho(rn,w.navigation.location,a):w.matches;zt(Ut,"Didn't find any matches after fetcher action");let gt=++F;W.set(re,gt);let On=Bd(Re,tn.data);w.fetchers.set(re,On);let[Kn,pn]=jM(n.history,w,Ut,Re,nn,!1,B,H,se,ie,te,rn,a,[Ue.route.id,tn]);pn.filter(me=>me.key!==re).forEach(me=>{let Be=me.key,dt=w.fetchers.get(Be),We=Bd(void 0,dt?dt.data:void 0);w.fetchers.set(Be,We),kt(Be),me.controller&&oe.set(Be,me.controller)}),z({fetchers:new Map(w.fetchers)});let Mr=()=>pn.forEach(me=>kt(me.key));pt.signal.addEventListener("abort",Mr);let{loaderResults:Sr,fetcherResults:G}=await j(Ut,Kn,pn,Ln,Tt);if(pt.signal.aborted)return;pt.signal.removeEventListener("abort",Mr),W.delete(re),oe.delete(re),pn.forEach(me=>oe.delete(me.key));let J=zm(Sr);if(J)return kn(Ln,J.result,!1,{preventScrollReset:je});if(J=zm(G),J)return te.add(J.key),kn(Ln,J.result,!1,{preventScrollReset:je});let{loaderData:ce,errors:Qe}=FM(w,Ut,Sr,void 0,pn,G);if(w.fetchers.has(re)){let me=vl(tn.data);w.fetchers.set(re,me)}nt(gt),w.navigation.state==="loading"&>>Z?(zt(E,"Expected pending action"),Q&&Q.abort(),pe(w.navigation.location,{matches:Ut,loaderData:ce,errors:Qe,fetchers:new Map(w.fetchers)})):(z({errors:Qe,loaderData:VM(w.loaderData,ce,Ut,Qe),fetchers:new Map(w.fetchers)}),B=!1)}async function wn(re,de,ye,Ue,et,Tt,ot,Ae,je,Re){let Te=w.fetchers.get(re);Fe(re,Bd(Re,Te?Te.data:void 0),{flushSync:Ae});let we=new AbortController,pt=qu(n.history,ye,we.signal);if(ot){let tn=await Pn(et,ye,pt.signal,re);if(tn.type==="aborted")return;if(tn.type==="error"){He(re,de,tn.error,{flushSync:Ae});return}else if(tn.matches)et=tn.matches,Ue=Xc(et,ye);else{He(re,de,Yr(404,{pathname:ye}),{flushSync:Ae});return}}oe.set(re,we);let Et=F,Ht=(await Cn("loader",pt,[Ue],et,Tt,re))[Ue.route.id];if(oe.get(re)===we&&oe.delete(re),!pt.signal.aborted){if(se.has(re)){Fe(re,vl(void 0));return}if(Nl(Ht))if(Z>Et){Fe(re,vl(void 0));return}else{te.add(re),await kn(pt,Ht,!1,{preventScrollReset:je});return}if(mi(Ht)){He(re,de,Ht.error);return}Fe(re,vl(Ht.data))}}async function kn(re,de,ye,{submission:Ue,fetcherSubmission:et,preventScrollReset:Tt,replace:ot}={}){de.response.headers.has("X-Remix-Revalidate")&&(B=!0);let Ae=de.response.headers.get("Location");zt(Ae,"Expected a Location header on the redirect Response"),Ae=UM(Ae,new URL(re.url),a);let je=Fa(w.location,Ae,{_isRedirect:!0});if(t){let Lt=!1;if(de.response.headers.has("X-Remix-Reload-Document"))Lt=!0;else if(Px.test(Ae)){const Ht=n.history.createURL(Ae);Lt=Ht.origin!==e.location.origin||vi(Ht.pathname,a)==null}if(Lt){ot?e.location.replace(Ae):e.location.assign(Ae);return}}Q=null;let Re=ot===!0||de.response.headers.has("X-Remix-Replace")?"REPLACE":"PUSH",{formMethod:Te,formAction:we,formEncType:pt}=w.navigation;!Ue&&!et&&Te&&we&&pt&&(Ue=ZM(w.navigation));let Et=Ue||et;if(ree.has(de.response.status)&&Et&&Yo(Et.formMethod))await Ce(Re,je,{submission:{...Et,formAction:Ae},preventScrollReset:Tt||M,enableViewTransition:ye?T:void 0});else{let Lt=cS(je,Ue);await Ce(Re,je,{overrideNavigation:Lt,fetcherSubmission:et,preventScrollReset:Tt||M,enableViewTransition:ye?T:void 0})}}async function Cn(re,de,ye,Ue,et,Tt){let ot,Ae={};try{ot=await tq(l,re,de,ye,Ue,Tt,i,r,et)}catch(je){return ye.forEach(Re=>{Ae[Re.route.id]={type:"error",error:je}}),Ae}for(let[je,Re]of Object.entries(ot))if(sq(Re)){let Te=Re.result;Ae[je]={type:"redirect",response:rq(Te,de,je,Ue,a)}}else Ae[je]=await nq(Re);return Ae}async function j(re,de,ye,Ue,et){let Tt=Cn("loader",Ue,de,re,et,null),ot=Promise.all(ye.map(async Re=>{if(Re.matches&&Re.match&&Re.controller){let we=(await Cn("loader",qu(n.history,Re.path,Re.controller.signal),[Re.match],Re.matches,et,Re.key))[Re.match.route.id];return{[Re.key]:we}}else return Promise.resolve({[Re.key]:{type:"error",error:Yr(404,{pathname:Re.path})}})})),Ae=await Tt,je=(await ot).reduce((Re,Te)=>Object.assign(Re,Te),{});return{loaderResults:Ae,fetcherResults:je}}function ve(){B=!0,ie.forEach((re,de)=>{oe.has(de)&&H.add(de),kt(de)})}function Fe(re,de,ye={}){w.fetchers.set(re,de),z({fetchers:new Map(w.fetchers)},{flushSync:(ye&&ye.flushSync)===!0})}function He(re,de,ye,Ue={}){let et=Ho(w.matches,de);it(re),z({errors:{[et.route.id]:ye},fetchers:new Map(w.fetchers)},{flushSync:(Ue&&Ue.flushSync)===!0})}function Je(re){return K.set(re,(K.get(re)||0)+1),se.has(re)&&se.delete(re),w.fetchers.get(re)||gy}function it(re){let de=w.fetchers.get(re);oe.has(re)&&!(de&&de.state==="loading"&&W.has(re))&&kt(re),ie.delete(re),W.delete(re),te.delete(re),se.delete(re),H.delete(re),w.fetchers.delete(re)}function Dt(re){let de=(K.get(re)||0)-1;de<=0?(K.delete(re),se.add(re)):K.set(re,de),z({fetchers:new Map(w.fetchers)})}function kt(re){let de=oe.get(re);de&&(de.abort(),oe.delete(re))}function qe(re){for(let de of re){let ye=Je(de),Ue=vl(ye.data);w.fetchers.set(de,Ue)}}function lt(){let re=[],de=!1;for(let ye of te){let Ue=w.fetchers.get(ye);zt(Ue,`Expected fetcher: ${ye}`),Ue.state==="loading"&&(te.delete(ye),re.push(ye),de=!0)}return qe(re),de}function nt(re){let de=[];for(let[ye,Ue]of W)if(Ue<re){let et=w.fetchers.get(ye);zt(et,`Expected fetcher: ${ye}`),et.state==="loading"&&(kt(ye),W.delete(ye),de.push(ye))}return qe(de),de.length>0}function rt(re,de){let ye=w.blockers.get(re)||Rl;return ee.get(re)!==de&&ee.set(re,de),ye}function mt(re){w.blockers.delete(re),ee.delete(re)}function vt(re,de){let ye=w.blockers.get(re)||Rl;zt(ye.state==="unblocked"&&de.state==="blocked"||ye.state==="blocked"&&de.state==="blocked"||ye.state==="blocked"&&de.state==="proceeding"||ye.state==="blocked"&&de.state==="unblocked"||ye.state==="proceeding"&&de.state==="unblocked",`Invalid blocker state transition: ${ye.state} -> ${de.state}`);let Ue=new Map(w.blockers);Ue.set(re,de),z({blockers:Ue})}function Bt({currentLocation:re,nextLocation:de,historyAction:ye}){if(ee.size===0)return;ee.size>1&&yr(!1,"A router only supports one blocker at a time");let Ue=Array.from(ee.entries()),[et,Tt]=Ue[Ue.length-1],ot=w.blockers.get(et);if(!(ot&&ot.state==="proceeding")&&Tt({currentLocation:re,nextLocation:de,historyAction:ye}))return et}function Xe(re){let de=Yr(404,{pathname:re}),ye=s||o,{matches:Ue,route:et}=Pv(ye);return{notFoundMatches:Ue,route:et,error:de}}function bt(re,de,ye){if(h=re,g=de,p=ye||null,!O&&w.navigation===kh){O=!0;let Ue=Ft(w.location,w.matches);Ue!=null&&z({restoreScrollPosition:Ue})}return()=>{h=null,g=null,p=null}}function en(re,de){return p&&p(re,de.map(Ue=>N3(Ue,w.loaderData)))||re.key}function Pt(re,de){if(h&&g){let ye=en(re,de);h[ye]=g()}}function Ft(re,de){if(h){let ye=en(re,de),Ue=h[ye];if(typeof Ue=="number")return Ue}return null}function hn(re,de,ye){if(n.patchRoutesOnNavigation)if(re){if(Object.keys(re[0].params).length>0)return{active:!0,matches:QO(de,ye,a,!0)}}else return{active:!0,matches:QO(de,ye,a,!0)||[]};return{active:!1,matches:null}}async function Pn(re,de,ye,Ue){if(!n.patchRoutesOnNavigation)return{type:"success",matches:re};let et=re;for(;;){let Tt=s==null,ot=s||o,Ae=i;try{await n.patchRoutesOnNavigation({signal:ye,path:de,matches:et,fetcherKey:Ue,patch:(Te,we)=>{ye.aborted||NM(Te,we,ot,Ae,r)}})}catch(Te){return{type:"error",error:Te,partialMatches:et}}finally{Tt&&!ye.aborted&&(o=[...o])}if(ye.aborted)return{type:"aborted"};let je=ho(ot,de,a);if(je)return{type:"success",matches:je};let Re=QO(ot,de,a,!0);if(!Re||et.length===Re.length&&et.every((Te,we)=>Te.route.id===Re[we].route.id))return{type:"success",matches:null};et=Re}}function Tn(re){i={},s=ou(re,r,void 0,i)}function En(re,de){let ye=s==null;NM(re,de,s||o,i,r),ye&&(o=[...o],z({}))}return P={get basename(){return a},get future(){return c},get state(){return w},get routes(){return o},get window(){return e},initialize:Le,subscribe:V,enableScrollRestoration:bt,navigate:_e,fetch:Vn,revalidate:Me,createHref:re=>n.history.createHref(re),encodeLocation:re=>n.history.encodeLocation(re),getFetcher:Je,deleteFetcher:Dt,dispose:L,getBlocker:rt,deleteBlocker:mt,patchRoutes:En,_internalFetchControllers:oe,_internalSetRoutes:Tn},P}function H3(n,e){zt(n.length>0,"You must provide a non-empty routes array to createStaticHandler");let t={},r=(e?e.basename:null)||"/",i=(e==null?void 0:e.mapRouteProperties)||z3,o=ou(n,i,void 0,t);async function s(h,{requestContext:p,filterMatchesToLoad:g,skipLoaderErrorBubbling:O,skipRevalidation:v,dataStrategy:b,unstable_respond:S}={}){let x=new URL(h.url),P=h.method,w=Fa("",Yi(x),null,"default"),E=ho(o,w,r);if(p=p??new Ll,!Uk(P)&&P!=="HEAD"){let Q=Yr(405,{method:P}),{matches:T,route:R}=Pv(o),$={basename:r,location:w,matches:T,loaderData:{},actionData:null,errors:{[R.id]:Q},statusCode:Q.status,loaderHeaders:{},actionHeaders:{}};return S?S($):$}else if(!E){let Q=Yr(404,{pathname:w.pathname}),{matches:T,route:R}=Pv(o),$={basename:r,location:w,matches:T,loaderData:{},actionData:null,errors:{[R.id]:Q},statusCode:Q.status,loaderHeaders:{},actionHeaders:{}};return S?S($):$}if(S&&E.some(Q=>Q.route.unstable_middleware||Q.route.unstable_lazyMiddleware)){zt(p instanceof Ll,"When using middleware in `staticHandler.query()`, any provided `requestContext` must be an instance of `unstable_RouterContextProvider`");try{await jk(E,t);let Q,T=await Zc({request:h,matches:E,params:E[0].params,context:p},!0,async()=>{let R=await l(h,w,E,p,b||null,O===!0,null,g||null,v===!0);return Ir(R)?R:(Q={location:w,basename:r,...R},await S(Q))},async(R,$)=>{if(Ir(R))return R;if(Q)return $ in Q.loaderData&&(Q.loaderData[$]=void 0),S(K3(o,Q,R,Ho(E,$).route.id));{let I=E.findIndex(H=>H.route.loader),B=I>=0?Ho(E,E[I].route.id):Ho(E);return S({matches:E,location:w,basename:r,loaderData:{},actionData:null,errors:{[B.route.id]:R},statusCode:si(R)?R.status:500,actionHeaders:{},loaderHeaders:{}})}});return zt(Ir(T),"Expected a response in query()"),T}catch(Q){if(Ir(Q))return Q;throw Q}}let M=await l(h,w,E,p,b||null,O===!0,null,g||null,v===!0);return Ir(M)?M:{location:w,basename:r,...M}}async function a(h,{routeId:p,requestContext:g,dataStrategy:O,unstable_respond:v}={}){let b=new URL(h.url),S=h.method,x=Fa("",Yi(b),null,"default"),P=ho(o,x,r);if(g=g??new Ll,!Uk(S)&&S!=="HEAD"&&S!=="OPTIONS")throw Yr(405,{method:S});if(!P)throw Yr(404,{pathname:x.pathname});let w=p?P.find(Q=>Q.route.id===p):Xc(P,x);if(p&&!w)throw Yr(403,{pathname:x.pathname,routeId:p});if(!w)throw Yr(404,{pathname:x.pathname});if(v&&P.some(Q=>Q.route.unstable_middleware||Q.route.unstable_lazyMiddleware))return zt(g instanceof Ll,"When using middleware in `staticHandler.queryRoute()`, any provided `requestContext` must be an instance of `unstable_RouterContextProvider`"),await jk(P,t),await Zc({request:h,matches:P,params:P[0].params,context:g},!0,async()=>{let T=await l(h,x,P,g,O||null,!1,w,null,!1);if(Ir(T))return v(T);let R=T.errors?Object.values(T.errors)[0]:void 0;if(R!==void 0)throw R;let $=T.actionData?Object.values(T.actionData)[0]:Object.values(T.loaderData)[0];return typeof $=="string"?new Response($):Response.json($)},T=>Ir(T)?v(T):new Response(String(T),{status:500,statusText:"Unexpected Server Error"}));let E=await l(h,x,P,g,O||null,!1,w,null,!1);if(Ir(E))return E;let M=E.errors?Object.values(E.errors)[0]:void 0;if(M!==void 0)throw M;if(E.actionData)return Object.values(E.actionData)[0];if(E.loaderData)return Object.values(E.loaderData)[0]}async function l(h,p,g,O,v,b,S,x,P){zt(h.signal,"query()/queryRoute() requests must contain an AbortController signal");try{if(Yo(h.method))return await c(h,g,S||Xc(g,p),O,v,b,S!=null,x,P);let w=await u(h,g,O,v,b,S,x);return Ir(w)?w:{...w,actionData:null,actionHeaders:{}}}catch(w){if(dee(w)&&Ir(w.result)){if(w.type==="error")throw w.result;return w.result}if(vy(w))return w;throw w}}async function c(h,p,g,O,v,b,S,x,P){let w;if(!g.route.action&&!g.route.lazy){let Q=Yr(405,{method:h.method,pathname:new URL(h.url).pathname,routeId:g.route.id});if(S)throw Q;w={type:"error",error:Q}}else w=(await d("action",h,[g],p,S,O,v))[g.route.id],h.signal.aborted&&QM(h,S);if(Nl(w))throw new Response(null,{status:w.response.status,headers:{Location:w.response.headers.get("Location")}});if(S){if(mi(w))throw w.error;return{matches:[g],loaderData:{},actionData:{[g.route.id]:w.data},errors:null,statusCode:200,loaderHeaders:{},actionHeaders:{}}}if(P)if(mi(w)){let Q=b?g:Ho(p,g.route.id);return{statusCode:si(w.error)?w.error.status:w.statusCode!=null?w.statusCode:500,actionData:null,actionHeaders:{...w.headers?{[g.route.id]:w.headers}:{}},matches:p,loaderData:{},errors:{[Q.route.id]:w.error},loaderHeaders:{}}}else return{actionData:{[g.route.id]:w.data},actionHeaders:w.headers?{[g.route.id]:w.headers}:{},matches:p,loaderData:{},errors:null,statusCode:w.statusCode||200,loaderHeaders:{}};let E=new Request(h.url,{headers:h.headers,redirect:h.redirect,signal:h.signal});if(mi(w)){let Q=b?g:Ho(p,g.route.id);return{...await u(E,p,O,v,b,null,x,[Q.route.id,w]),statusCode:si(w.error)?w.error.status:w.statusCode!=null?w.statusCode:500,actionData:null,actionHeaders:{...w.headers?{[g.route.id]:w.headers}:{}}}}return{...await u(E,p,O,v,b,null,x),actionData:{[g.route.id]:w.data},...w.statusCode?{statusCode:w.statusCode}:{},actionHeaders:w.headers?{[g.route.id]:w.headers}:{}}}async function u(h,p,g,O,v,b,S,x){let P=b!=null;if(P&&!(b!=null&&b.route.loader)&&!(b!=null&&b.route.lazy))throw Yr(400,{method:h.method,pathname:new URL(h.url).pathname,routeId:b==null?void 0:b.route.id});let E=(b?[b]:x&&mi(x[1])?Qk(p,x[0]):p).filter(R=>(R.route.loader||R.route.lazy)&&(!S||S(R)));if(E.length===0)return{matches:p,loaderData:p.reduce((R,$)=>Object.assign(R,{[$.route.id]:null}),{}),errors:x&&mi(x[1])?{[x[0]]:x[1].error}:null,statusCode:200,loaderHeaders:{}};let M=await d("loader",h,E,p,P,g,O);h.signal.aborted&&QM(h,P);let Q=iq(p,M,x,!0,v),T=new Set(E.map(R=>R.route.id));return p.forEach(R=>{T.has(R.route.id)||(Q.loaderData[R.route.id]=null)}),{...Q,matches:p}}async function d(h,p,g,O,v,b,S){let x=await tq(S||Lk,h,p,g,O,null,t,i,b),P={};return await Promise.all(O.map(async w=>{if(!(w.route.id in x))return;let E=x[w.route.id];if(sq(E)){let M=E.result;throw rq(M,p,w.route.id,O,r)}if(Ir(E.result)&&v)throw E;P[w.route.id]=await nq(E)})),P}return{dataRoutes:o,query:s,queryRoute:a}}function K3(n,e,t,r){let i=r||e._deepestRenderedBoundaryId||n[0].id;return{...e,statusCode:si(t)?t.status:500,errors:{[i]:t}}}function QM(n,e){if(n.signal.reason!==void 0)throw n.signal.reason;let t=e?"queryRoute":"query";throw new Error(`${t}() call aborted without an \`AbortSignal.reason\`: ${n.method} ${n.url}`)}function iee(n){return n!=null&&("formData"in n&&n.formData!=null||"body"in n&&n.body!==void 0)}function Dk(n,e,t,r,i,o){let s,a;if(i){s=[];for(let c of e)if(s.push(c),c.route.id===i){a=c;break}}else s=e,a=e[e.length-1];let l=py(r||".",hy(s),vi(n.pathname,t)||n.pathname,o==="path");if(r==null&&(l.search=n.search,l.hash=n.hash),(r==null||r===""||r===".")&&a){let c=xx(l.search);if(a.route.index&&!c)l.search=l.search?l.search.replace(/^\?/,"?index&"):"?index";else if(!a.route.index&&c){let u=new URLSearchParams(l.search),d=u.getAll("index");u.delete("index"),d.filter(p=>p).forEach(p=>u.append("index",p));let h=u.toString();l.search=h?`?${h}`:""}}return t!=="/"&&(l.pathname=l.pathname==="/"?t:ca([t,l.pathname])),Yi(l)}function IM(n,e,t){if(!t||!iee(t))return{path:e};if(t.formMethod&&!Uk(t.formMethod))return{path:e,error:Yr(405,{method:t.formMethod})};let r=()=>({path:e,error:Yr(400,{type:"invalid-body"})}),o=(t.formMethod||"get").toUpperCase(),s=oq(e);if(t.body!==void 0){if(t.formEncType==="text/plain"){if(!Yo(o))return r();let d=typeof t.body=="string"?t.body:t.body instanceof FormData||t.body instanceof URLSearchParams?Array.from(t.body.entries()).reduce((h,[p,g])=>`${h}${p}=${g}
|
|
146
|
+
`,""):String(t.body);return{path:e,submission:{formMethod:o,formAction:s,formEncType:t.formEncType,formData:void 0,json:void 0,text:d}}}else if(t.formEncType==="application/json"){if(!Yo(o))return r();try{let d=typeof t.body=="string"?JSON.parse(t.body):t.body;return{path:e,submission:{formMethod:o,formAction:s,formEncType:t.formEncType,formData:void 0,json:d,text:void 0}}}catch{return r()}}}zt(typeof FormData=="function","FormData is not available in this environment");let a,l;if(t.formData)a=Nk(t.formData),l=t.formData;else if(t.body instanceof FormData)a=Nk(t.body),l=t.body;else if(t.body instanceof URLSearchParams)a=t.body,l=BM(a);else if(t.body==null)a=new URLSearchParams,l=new FormData;else try{a=new URLSearchParams(t.body),l=BM(a)}catch{return r()}let c={formMethod:o,formAction:s,formEncType:t&&t.formEncType||"application/x-www-form-urlencoded",formData:l,json:void 0,text:void 0};if(Yo(c.formMethod))return{path:e,submission:c};let u=jo(e);return n&&u.search&&xx(u.search)&&a.append("index",""),u.search=`?${a}`,{path:Yi(u),submission:c}}function Qk(n,e,t=!1){let r=n.findIndex(i=>i.route.id===e);return r>=0?n.slice(0,t?r+1:r):n}function jM(n,e,t,r,i,o,s,a,l,c,u,d,h,p){let g=p?mi(p[1])?p[1].error:p[1].data:void 0,O=n.createURL(e.location),v=n.createURL(i),b=t;o&&e.errors?b=Qk(t,Object.keys(e.errors)[0],!0):p&&mi(p[1])&&(b=Qk(t,p[0]));let S=p?p[1].statusCode:void 0,x=S&&S>=400,P=b.filter((E,M)=>{let{route:Q}=E;if(Q.lazy)return!0;if(Q.loader==null)return!1;if(o)return Ik(Q,e.loaderData,e.errors);if(oee(e.loaderData,e.matches[M],E))return!0;let T=e.matches[M],R=E;return LM(E,{currentUrl:O,currentParams:T.params,nextUrl:v,nextParams:R.params,...r,actionResult:g,actionStatus:S,defaultShouldRevalidate:x?!1:s||O.pathname+O.search===v.pathname+v.search||O.search!==v.search||see(T,R)})}),w=[];return c.forEach((E,M)=>{if(o||!t.some(I=>I.route.id===E.routeId)||l.has(M))return;let Q=ho(d,E.path,h);if(!Q){w.push({key:M,routeId:E.routeId,path:E.path,matches:null,match:null,controller:null});return}let T=e.fetchers.get(M),R=Xc(Q,E.path),$=!1;u.has(M)?$=!1:a.has(M)?(a.delete(M),$=!0):T&&T.state!=="idle"&&T.data===void 0?$=s:$=LM(R,{currentUrl:O,currentParams:e.matches[e.matches.length-1].params,nextUrl:v,nextParams:t[t.length-1].params,...r,actionResult:g,actionStatus:S,defaultShouldRevalidate:x?!1:s}),$&&w.push({key:M,routeId:E.routeId,path:E.path,matches:Q,match:R,controller:new AbortController})}),[P,w]}function Ik(n,e,t){if(n.lazy)return!0;if(!n.loader)return!1;let r=e!=null&&e[n.id]!==void 0,i=t!=null&&t[n.id]!==void 0;return!r&&i?!1:typeof n.loader=="function"&&n.loader.hydrate===!0?!0:!r&&!i}function oee(n,e,t){let r=!e||t.route.id!==e.route.id,i=!n.hasOwnProperty(t.route.id);return r||i}function see(n,e){let t=n.route.path;return n.pathname!==e.pathname||t!=null&&t.endsWith("*")&&n.params["*"]!==e.params["*"]}function LM(n,e){if(n.route.shouldRevalidate){let t=n.route.shouldRevalidate(e);if(typeof t=="boolean")return t}return e.defaultShouldRevalidate}function NM(n,e,t,r,i){let o;if(n){let l=r[n];zt(l,`No route found to patch children into: routeId = ${n}`),l.children||(l.children=[]),o=l.children}else o=t;let s=e.filter(l=>!o.some(c=>J3(l,c))),a=ou(s,i,[n||"_","patch",String((o==null?void 0:o.length)||"0")],r);o.push(...a)}function J3(n,e){return"id"in n&&"id"in e&&n.id===e.id?!0:n.index===e.index&&n.path===e.path&&n.caseSensitive===e.caseSensitive?(!n.children||n.children.length===0)&&(!e.children||e.children.length===0)?!0:n.children.every((t,r)=>{var i;return(i=e.children)==null?void 0:i.some(o=>J3(t,o))}):!1}var qM=new WeakMap;async function aee(n,e,t){let r=t[n.id];if(zt(r,"No route found in manifest"),!n.lazy)return;let i=qM.get(r);if(i){await i;return}let o=n.lazy().then(s=>{let a={};for(let l in s){let u=r[l]!==void 0&&l!=="hasErrorBoundary";yr(!u,`Route "${r.id}" has a static property "${l}" defined but its lazy function is also returning a value for this property. The lazy route property "${l}" will be ignored.`),yr(!$M.has(l),"Route property "+l+" is not a supported property to be returned from a lazy route function. This property will be ignored."),!u&&!$M.has(l)&&(a[l]=s[l])}Object.assign(r,a),Object.assign(r,{...e(r),lazy:void 0})});qM.set(r,o),await o}async function lee(n,e){if(!n.unstable_lazyMiddleware)return;let t=e[n.id];if(zt(t,"No route found in manifest"),t.unstable_middleware)yr(!1,`Route "${t.id}" has a static property "unstable_middleware" defined. The "unstable_lazyMiddleware" function will be ignored.`);else{let r=await n.unstable_lazyMiddleware();if(!n.unstable_lazyMiddleware)return;t.unstable_middleware||(t.unstable_middleware=r)}t.unstable_lazyMiddleware=void 0}function jk(n,e){let t=n.map(r=>r.route.unstable_lazyMiddleware?lee(r.route,e):void 0).filter(Boolean);return t.length>0?Promise.all(t):void 0}async function Lk(n){let e=n.matches.filter(i=>i.shouldLoad),t={};return(await Promise.all(e.map(i=>i.resolve()))).forEach((i,o)=>{t[e[o].route.id]=i}),t}async function cee(n){return n.matches.some(e=>e.route.unstable_middleware)?Zc(n,!1,()=>Lk(n),(e,t)=>({[t]:{type:"error",result:e}})):Lk(n)}async function Zc(n,e,t,r){let{matches:i,request:o,params:s,context:a}=n,l={handlerResult:void 0};try{let c=i.flatMap(d=>d.route.unstable_middleware?d.route.unstable_middleware.map(h=>[d.route.id,h]):[]),u=await eq({request:o,params:s,context:a},c,e,l,t);return e?u:l.handlerResult}catch(c){if(!l.middlewareError)throw c;let u=await r(l.middlewareError.error,l.middlewareError.routeId);return e||!l.handlerResult?u:Object.assign(l.handlerResult,u)}}async function eq(n,e,t,r,i,o=0){let{request:s}=n;if(s.signal.aborted)throw s.signal.reason?s.signal.reason:new Error(`Request aborted without an \`AbortSignal.reason\`: ${s.method} ${s.url}`);let a=e[o];if(!a)return r.handlerResult=await i(),r.handlerResult;let[l,c]=a,u=!1,d,h=async()=>{if(u)throw new Error("You may only call `next()` once per middleware");u=!0;let p=await eq(n,e,t,r,i,o+1);if(t)return d=p,d};try{let p=await c({request:n.request,params:n.params,context:n.context},h);return u?p===void 0?d:p:h()}catch(p){throw r.middlewareError?r.middlewareError.error!==p&&(r.middlewareError={routeId:l,error:p}):r.middlewareError={routeId:l,error:p},p}}async function tq(n,e,t,r,i,o,s,a,l){let c=jk(i,s),u=i.map(p=>p.route.lazy?aee(p.route,a,s):void 0);c&&await c;let d=i.map((p,g)=>{let O=u[g],v=r.some(S=>S.route.id===p.route.id);return{...p,shouldLoad:v,resolve:async S=>(S&&t.method==="GET"&&(p.route.lazy||p.route.loader)&&(v=!0),v?uee(e,t,p,O,S,l):Promise.resolve({type:"data",result:void 0}))}}),h=await n({matches:d,request:t,params:i[0].params,fetcherKey:o,context:l});try{await Promise.all(u)}catch{}return h}async function uee(n,e,t,r,i,o){let s,a,l=c=>{let u,d=new Promise((g,O)=>u=O);a=()=>u(),e.signal.addEventListener("abort",a);let h=g=>typeof c!="function"?Promise.reject(new Error(`You cannot call the handler for a route which defines a boolean "${n}" [routeId: ${t.route.id}]`)):c({request:e,params:t.params,context:o},...g!==void 0?[g]:[]),p=(async()=>{try{return{type:"data",result:await(i?i(O=>h(O)):h())}}catch(g){return{type:"error",result:g}}})();return Promise.race([p,d])};try{let c=t.route[n];if(r)if(c){let u,[d]=await Promise.all([l(c).catch(h=>{u=h}),r]);if(u!==void 0)throw u;s=d}else if(await r,c=t.route[n],c)s=await l(c);else if(n==="action"){let u=new URL(e.url),d=u.pathname+u.search;throw Yr(405,{method:e.method,pathname:d,routeId:t.route.id})}else return{type:"data",result:void 0};else if(c)s=await l(c);else{let u=new URL(e.url),d=u.pathname+u.search;throw Yr(404,{pathname:d})}}catch(c){return{type:"error",result:c}}finally{a&&e.signal.removeEventListener("abort",a)}return s}async function nq(n){var r,i,o,s,a,l;let{result:e,type:t}=n;if(Ir(e)){let c;try{let u=e.headers.get("Content-Type");u&&/\bapplication\/json\b/.test(u)?e.body==null?c=null:c=await e.json():c=await e.text()}catch(u){return{type:"error",error:u}}return t==="error"?{type:"error",error:new Qo(e.status,e.statusText,c),statusCode:e.status,headers:e.headers}:{type:"data",data:c,statusCode:e.status,headers:e.headers}}return t==="error"?qk(e)?e.data instanceof Error?{type:"error",error:e.data,statusCode:(r=e.init)==null?void 0:r.status,headers:(i=e.init)!=null&&i.headers?new Headers(e.init.headers):void 0}:{type:"error",error:new Qo(((o=e.init)==null?void 0:o.status)||500,void 0,e.data),statusCode:si(e)?e.status:void 0,headers:(s=e.init)!=null&&s.headers?new Headers(e.init.headers):void 0}:{type:"error",error:e,statusCode:si(e)?e.status:void 0}:qk(e)?{type:"data",data:e.data,statusCode:(a=e.init)==null?void 0:a.status,headers:(l=e.init)!=null&&l.headers?new Headers(e.init.headers):void 0}:{type:"data",data:e}}function rq(n,e,t,r,i){let o=n.headers.get("Location");if(zt(o,"Redirects returned/thrown from loaders/actions must have a Location header"),!Px.test(o)){let s=r.slice(0,r.findIndex(a=>a.route.id===t)+1);o=Dk(new URL(e.url),s,i,o),n.headers.set("Location",o)}return n}function UM(n,e,t){if(Px.test(n)){let r=n,i=r.startsWith("//")?new URL(e.protocol+r):new URL(r),o=vi(i.pathname,t)!=null;if(i.origin===e.origin&&o)return i.pathname+i.search+i.hash}return n}function qu(n,e,t,r){let i=n.createURL(oq(e)).toString(),o={signal:t};if(r&&Yo(r.formMethod)){let{formMethod:s,formEncType:a}=r;o.method=s.toUpperCase(),a==="application/json"?(o.headers=new Headers({"Content-Type":a}),o.body=JSON.stringify(r.json)):a==="text/plain"?o.body=r.text:a==="application/x-www-form-urlencoded"&&r.formData?o.body=Nk(r.formData):o.body=r.formData}return new Request(i,o)}function Nk(n){let e=new URLSearchParams;for(let[t,r]of n.entries())e.append(t,typeof r=="string"?r:r.name);return e}function BM(n){let e=new FormData;for(let[t,r]of n.entries())e.append(t,r);return e}function iq(n,e,t,r=!1,i=!1){let o={},s=null,a,l=!1,c={},u=t&&mi(t[1])?t[1].error:void 0;return n.forEach(d=>{if(!(d.route.id in e))return;let h=d.route.id,p=e[h];if(zt(!Nl(p),"Cannot handle redirect results in processLoaderData"),mi(p)){let g=p.error;if(u!==void 0&&(g=u,u=void 0),s=s||{},i)s[h]=g;else{let O=Ho(n,h);s[O.route.id]==null&&(s[O.route.id]=g)}r||(o[h]=G3),l||(l=!0,a=si(p.error)?p.error.status:500),p.headers&&(c[h]=p.headers)}else o[h]=p.data,p.statusCode&&p.statusCode!==200&&!l&&(a=p.statusCode),p.headers&&(c[h]=p.headers)}),u!==void 0&&t&&(s={[t[0]]:u},o[t[0]]=void 0),{loaderData:o,errors:s,statusCode:a||200,loaderHeaders:c}}function FM(n,e,t,r,i,o){let{loaderData:s,errors:a}=iq(e,t,r);return i.forEach(l=>{let{key:c,match:u,controller:d}=l,h=o[c];if(zt(h,"Did not find corresponding fetcher result"),!(d&&d.signal.aborted))if(mi(h)){let p=Ho(n.matches,u==null?void 0:u.route.id);a&&a[p.route.id]||(a={...a,[p.route.id]:h.error}),n.fetchers.delete(c)}else if(Nl(h))zt(!1,"Unhandled fetcher revalidation redirect");else{let p=vl(h.data);n.fetchers.set(c,p)}}),{loaderData:s,errors:a}}function VM(n,e,t,r){let i=Object.entries(e).filter(([,o])=>o!==G3).reduce((o,[s,a])=>(o[s]=a,o),{});for(let o of t){let s=o.route.id;if(!e.hasOwnProperty(s)&&n.hasOwnProperty(s)&&o.route.loader&&(i[s]=n[s]),r&&r.hasOwnProperty(s))break}return i}function WM(n){return n?mi(n[1])?{actionData:{}}:{actionData:{[n[0]]:n[1].data}}:{}}function Ho(n,e){return(e?n.slice(0,n.findIndex(r=>r.route.id===e)+1):[...n]).reverse().find(r=>r.route.hasErrorBoundary===!0)||n[0]}function Pv(n){let e=n.length===1?n[0]:n.find(t=>t.index||!t.path||t.path==="/")||{id:"__shim-error-route__"};return{matches:[{params:{},pathname:"",pathnameBase:"",route:e}],route:e}}function Yr(n,{pathname:e,routeId:t,method:r,type:i,message:o}={}){let s="Unknown Server Error",a="Unknown @remix-run/router error";return n===400?(s="Bad Request",r&&e&&t?a=`You made a ${r} request to "${e}" but did not provide a \`loader\` for route "${t}", so there is no way to handle the request.`:i==="invalid-body"&&(a="Unable to encode submission body")):n===403?(s="Forbidden",a=`Route "${t}" does not match URL "${e}"`):n===404?(s="Not Found",a=`No route matches URL "${e}"`):n===405&&(s="Method Not Allowed",r&&e&&t?a=`You made a ${r.toUpperCase()} request to "${e}" but did not provide an \`action\` for route "${t}", so there is no way to handle the request.`:r&&(a=`Invalid request method "${r.toUpperCase()}"`)),new Qo(n||500,s,new Error(a),!0)}function zm(n){let e=Object.entries(n);for(let t=e.length-1;t>=0;t--){let[r,i]=e[t];if(Nl(i))return{key:r,result:i}}}function oq(n){let e=typeof n=="string"?jo(n):n;return Yi({...e,hash:""})}function fee(n,e){return n.pathname!==e.pathname||n.search!==e.search?!1:n.hash===""?e.hash!=="":n.hash===e.hash?!0:e.hash!==""}function dee(n){return n!=null&&typeof n=="object"&&"type"in n&&"result"in n&&(n.type==="data"||n.type==="error")}function sq(n){return Ir(n.result)&&X3.has(n.result.status)}function mi(n){return n.type==="error"}function Nl(n){return(n&&n.type)==="redirect"}function qk(n){return typeof n=="object"&&n!=null&&"type"in n&&"data"in n&&"init"in n&&n.type==="DataWithResponseInit"}function Ir(n){return n!=null&&typeof n.status=="number"&&typeof n.statusText=="string"&&typeof n.headers=="object"&&typeof n.body<"u"}function Oy(n){return X3.has(n)}function vy(n){return Ir(n)&&Oy(n.status)&&n.headers.has("Location")}function Uk(n){return nee.has(n.toUpperCase())}function Yo(n){return eee.has(n.toUpperCase())}function xx(n){return new URLSearchParams(n).getAll("index").some(e=>e==="")}function Xc(n,e){let t=typeof e=="string"?jo(e).search:e.search;if(n[n.length-1].route.index&&xx(t||""))return n[n.length-1];let r=V3(n);return r[r.length-1]}function ZM(n){let{formMethod:e,formAction:t,formEncType:r,text:i,formData:o,json:s}=n;if(!(!e||!t||!r)){if(i!=null)return{formMethod:e,formAction:t,formEncType:r,formData:void 0,json:void 0,text:i};if(o!=null)return{formMethod:e,formAction:t,formEncType:r,formData:o,json:void 0,text:void 0};if(s!==void 0)return{formMethod:e,formAction:t,formEncType:r,formData:void 0,json:s,text:void 0}}}function cS(n,e){return e?{state:"loading",location:n,formMethod:e.formMethod,formAction:e.formAction,formEncType:e.formEncType,formData:e.formData,json:e.json,text:e.text}:{state:"loading",location:n,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,json:void 0,text:void 0}}function hee(n,e){return{state:"submitting",location:n,formMethod:e.formMethod,formAction:e.formAction,formEncType:e.formEncType,formData:e.formData,json:e.json,text:e.text}}function Bd(n,e){return n?{state:"loading",formMethod:n.formMethod,formAction:n.formAction,formEncType:n.formEncType,formData:n.formData,json:n.json,text:n.text,data:e}:{state:"loading",formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,json:void 0,text:void 0,data:e}}function pee(n,e){return{state:"submitting",formMethod:n.formMethod,formAction:n.formAction,formEncType:n.formEncType,formData:n.formData,json:n.json,text:n.text,data:e?e.data:void 0}}function vl(n){return{state:"idle",formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,json:void 0,text:void 0,data:n}}function mee(n,e){try{let t=n.sessionStorage.getItem(Y3);if(t){let r=JSON.parse(t);for(let[i,o]of Object.entries(r||{}))o&&Array.isArray(o)&&e.set(i,new Set(o||[]))}}catch{}}function gee(n,e){if(e.size>0){let t={};for(let[r,i]of e)t[r]=[...i];try{n.sessionStorage.setItem(Y3,JSON.stringify(t))}catch(r){yr(!1,`Failed to save applied view transitions in sessionStorage (${r}).`)}}}function Oee(){let n,e,t=new Promise((r,i)=>{n=async o=>{r(o);try{await t}catch{}},e=async o=>{i(o);try{await t}catch{}}});return{promise:t,resolve:n,reject:e}}var Wa=D.createContext(null);Wa.displayName="DataRouter";var lc=D.createContext(null);lc.displayName="DataRouterState";var vp=D.createContext({isTransitioning:!1});vp.displayName="ViewTransition";var yp=D.createContext(new Map);yp.displayName="Fetchers";var Yh=D.createContext(null);Yh.displayName="Await";var vo=D.createContext(null);vo.displayName="Navigation";var uu=D.createContext(null);uu.displayName="Location";var yo=D.createContext({outlet:null,matches:[],isDataRoute:!1});yo.displayName="Route";var Cx=D.createContext(null);Cx.displayName="RouteError";function aq(n,{relative:e}={}){zt(cc(),"useHref() may be used only in the context of a <Router> component.");let{basename:t,navigator:r}=D.useContext(vo),{hash:i,pathname:o,search:s}=Kf(n,{relative:e}),a=o;return t!=="/"&&(a=o==="/"?t:ca([t,o])),r.createHref({pathname:a,search:s,hash:i})}function cc(){return D.useContext(uu)!=null}function bo(){return zt(cc(),"useLocation() may be used only in the context of a <Router> component."),D.useContext(uu).location}function vee(){return D.useContext(uu).navigationType}function yee(n){zt(cc(),"useMatch() may be used only in the context of a <Router> component.");let{pathname:e}=bo();return D.useMemo(()=>Uf(n,B3(e)),[e,n])}var lq="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function cq(n){D.useContext(vo).static||D.useLayoutEffect(n)}function yy(){let{isDataRoute:n}=D.useContext(yo);return n?Qee():bee()}function bee(){zt(cc(),"useNavigate() may be used only in the context of a <Router> component.");let n=D.useContext(Wa),{basename:e,navigator:t}=D.useContext(vo),{matches:r}=D.useContext(yo),{pathname:i}=bo(),o=JSON.stringify(hy(r)),s=D.useRef(!1);return cq(()=>{s.current=!0}),D.useCallback((l,c={})=>{if(yr(s.current,lq),!s.current)return;if(typeof l=="number"){t.go(l);return}let u=py(l,JSON.parse(o),i,c.relative==="path");n==null&&e!=="/"&&(u.pathname=u.pathname==="/"?e:ca([e,u.pathname])),(c.replace?t.replace:t.push)(u,c.state,c)},[e,t,o,i,n])}var uq=D.createContext(null);function See(){return D.useContext(uq)}function fq(n){let e=D.useContext(yo).outlet;return e&&D.createElement(uq.Provider,{value:n},e)}function wee(){let{matches:n}=D.useContext(yo),e=n[n.length-1];return e?e.params:{}}function Kf(n,{relative:e}={}){let{matches:t}=D.useContext(yo),{pathname:r}=bo(),i=JSON.stringify(hy(t));return D.useMemo(()=>py(n,JSON.parse(i),r,e==="path"),[n,i,r,e])}function dq(n,e){return Tx(n,e)}function Tx(n,e,t,r){var S;zt(cc(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:i,static:o}=D.useContext(vo),{matches:s}=D.useContext(yo),a=s[s.length-1],l=a?a.params:{},c=a?a.pathname:"/",u=a?a.pathnameBase:"/",d=a&&a.route;{let x=d&&d.path||"";Oq(c,!d||x.endsWith("*")||x.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${c}" (under <Route path="${x}">) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render.
|
|
147
147
|
|
|
148
|
-
Please change the parent <Route path="${x}"> to <Route path="${x==="/"?"*":`${x}/*`}">.`)}let h=bo(),p;if(e){let x=typeof e=="string"?jo(e):e;zt(u==="/"||((S=x.pathname)==null?void 0:S.startsWith(u)),`When overriding the location using \`<Routes location>\` or \`useRoutes(routes, location)\`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "${u}" but pathname "${x.pathname}" was given in the \`location\` prop.`),p=x}else p=h;let g=p.pathname||"/",O=g;if(u!=="/"){let x=u.replace(/^\//,"").split("/");O="/"+g.replace(/^\//,"").split("/").slice(x.length).join("/")}let v=!o&&t&&t.matches&&t.matches.length>0?t.matches:ho(n,{pathname:O});yr(d||v!=null,`No routes matched location "${p.pathname}${p.search}${p.hash}" `),yr(v==null||v[v.length-1].route.element!==void 0||v[v.length-1].route.Component!==void 0||v[v.length-1].route.lazy!==void 0,`Matched leaf route at location "${p.pathname}${p.search}${p.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`);let b=dq(v&&v.map(x=>Object.assign({},x,{params:Object.assign({},l,x.params),pathname:ca([u,i.encodeLocation?i.encodeLocation(x.pathname).pathname:x.pathname]),pathnameBase:x.pathnameBase==="/"?u:ca([u,i.encodeLocation?i.encodeLocation(x.pathnameBase).pathname:x.pathnameBase])})),s,t,r);return e&&b?D.createElement(uu.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",...p},navigationType:"POP"}},b):b}function See(){let n=Ax(),e=si(n)?`${n.status} ${n.statusText}`:n instanceof Error?n.message:JSON.stringify(n),t=n instanceof Error?n.stack:null,r="rgba(200,200,200, 0.5)",i={padding:"0.5rem",backgroundColor:r},o={padding:"2px 4px",backgroundColor:r},s=null;return console.error("Error handled by React Router default ErrorBoundary:",n),s=D.createElement(D.Fragment,null,D.createElement("p",null,"💿 Hey developer 👋"),D.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",D.createElement("code",{style:o},"ErrorBoundary")," or"," ",D.createElement("code",{style:o},"errorElement")," prop on your route.")),D.createElement(D.Fragment,null,D.createElement("h2",null,"Unexpected Application Error!"),D.createElement("h3",{style:{fontStyle:"italic"}},e),t?D.createElement("pre",{style:i},t):null,s)}var wee=D.createElement(See,null),kee=class extends D.Component{constructor(n){super(n),this.state={location:n.location,revalidation:n.revalidation,error:n.error}}static getDerivedStateFromError(n){return{error:n}}static getDerivedStateFromProps(n,e){return e.location!==n.location||e.revalidation!=="idle"&&n.revalidation==="idle"?{error:n.error,location:n.location,revalidation:n.revalidation}:{error:n.error!==void 0?n.error:e.error,location:e.location,revalidation:n.revalidation||e.revalidation}}componentDidCatch(n,e){console.error("React Router caught the following error during render",n,e)}render(){return this.state.error!==void 0?D.createElement(yo.Provider,{value:this.props.routeContext},D.createElement(Cx.Provider,{value:this.state.error,children:this.props.component})):this.props.children}};function Pee({routeContext:n,match:e,children:t}){let r=D.useContext(Wa);return r&&r.static&&r.staticContext&&(e.route.errorElement||e.route.ErrorBoundary)&&(r.staticContext._deepestRenderedBoundaryId=e.route.id),D.createElement(yo.Provider,{value:n},t)}function dq(n,e=[],t=null,r=null){if(n==null){if(!t)return null;if(t.errors)n=t.matches;else if(e.length===0&&!t.initialized&&t.matches.length>0)n=t.matches;else return null}let i=n,o=t==null?void 0:t.errors;if(o!=null){let l=i.findIndex(c=>c.route.id&&(o==null?void 0:o[c.route.id])!==void 0);zt(l>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(o).join(",")}`),i=i.slice(0,Math.min(i.length,l+1))}let s=!1,a=-1;if(t)for(let l=0;l<i.length;l++){let c=i[l];if((c.route.HydrateFallback||c.route.hydrateFallbackElement)&&(a=l),c.route.id){let{loaderData:u,errors:d}=t,h=c.route.loader&&!u.hasOwnProperty(c.route.id)&&(!d||d[c.route.id]===void 0);if(c.route.lazy||h){s=!0,a>=0?i=i.slice(0,a+1):i=[i[0]];break}}}return i.reduceRight((l,c,u)=>{let d,h=!1,p=null,g=null;t&&(d=o&&c.route.id?o[c.route.id]:void 0,p=c.route.errorElement||wee,s&&(a<0&&u===0?(gq("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),h=!0,g=null):a===u&&(h=!0,g=c.route.hydrateFallbackElement||null)));let O=e.concat(i.slice(0,u+1)),v=()=>{let b;return d?b=p:h?b=g:c.route.Component?b=D.createElement(c.route.Component,null):c.route.element?b=c.route.element:b=l,D.createElement(Pee,{match:c,routeContext:{outlet:l,matches:O,isDataRoute:t!=null},children:b})};return t&&(c.route.ErrorBoundary||c.route.errorElement||u===0)?D.createElement(kee,{location:t.location,revalidation:t.revalidation,component:p,error:d,children:v(),routeContext:{outlet:null,matches:O,isDataRoute:!0}}):v()},null)}function _x(n){return`${n} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Ex(n){let e=D.useContext(Wa);return zt(e,_x(n)),e}function uc(n){let e=D.useContext(lc);return zt(e,_x(n)),e}function xee(n){let e=D.useContext(yo);return zt(e,_x(n)),e}function bp(n){let e=xee(n),t=e.matches[e.matches.length-1];return zt(t.route.id,`${n} can only be used on routes that contain a unique "id"`),t.route.id}function Cee(){return bp("useRouteId")}function hq(){return uc("useNavigation").navigation}function Tee(){let n=Ex("useRevalidator"),e=uc("useRevalidator");return D.useMemo(()=>({async revalidate(){await n.router.revalidate()},state:e.revalidation}),[n.router,e.revalidation])}function Rx(){let{matches:n,loaderData:e}=uc("useMatches");return D.useMemo(()=>n.map(t=>L3(t,e)),[n,e])}function _ee(){let n=uc("useLoaderData"),e=bp("useLoaderData");return n.loaderData[e]}function Eee(n){return uc("useRouteLoaderData").loaderData[n]}function Ree(){let n=uc("useActionData"),e=bp("useLoaderData");return n.actionData?n.actionData[e]:void 0}function Ax(){var r;let n=D.useContext(Cx),e=uc("useRouteError"),t=bp("useRouteError");return n!==void 0?n:(r=e.errors)==null?void 0:r[t]}function pq(){let n=D.useContext(Yh);return n==null?void 0:n._data}function Aee(){let n=D.useContext(Yh);return n==null?void 0:n._error}var Mee=0;function mq(n){let{router:e,basename:t}=Ex("useBlocker"),r=uc("useBlocker"),[i,o]=D.useState(""),s=D.useCallback(a=>{if(typeof n!="function")return!!n;if(t==="/")return n(a);let{currentLocation:l,nextLocation:c,historyAction:u}=a;return n({currentLocation:{...l,pathname:vi(l.pathname,t)||l.pathname},nextLocation:{...c,pathname:vi(c.pathname,t)||c.pathname},historyAction:u})},[t,n]);return D.useEffect(()=>{let a=String(++Mee);return o(a),()=>e.deleteBlocker(a)},[e]),D.useEffect(()=>{i!==""&&e.getBlocker(i,s)},[e,i,s]),i&&r.blockers.has(i)?r.blockers.get(i):Rl}function $ee(){let{router:n}=Ex("useNavigate"),e=bp("useNavigate"),t=D.useRef(!1);return lq(()=>{t.current=!0}),D.useCallback(async(i,o={})=>{yr(t.current,aq),t.current&&(typeof i=="number"?n.navigate(i):await n.navigate(i,{fromRouteId:e,...o}))},[n,e])}var WM={};function gq(n,e,t){!e&&!WM[n]&&(WM[n]=!0,yr(!1,t))}var ZM={};function xv(n,e){!n&&!ZM[e]&&(ZM[e]=!0,console.warn(e))}function fu(n){let e={hasErrorBoundary:n.hasErrorBoundary||n.ErrorBoundary!=null||n.errorElement!=null};return n.Component&&(n.element&&yr(!1,"You should not include both `Component` and `element` on your route - `Component` will be used."),Object.assign(e,{element:D.createElement(n.Component),Component:void 0})),n.HydrateFallback&&(n.hydrateFallbackElement&&yr(!1,"You should not include both `HydrateFallback` and `hydrateFallbackElement` on your route - `HydrateFallback` will be used."),Object.assign(e,{hydrateFallbackElement:D.createElement(n.HydrateFallback),HydrateFallback:void 0})),n.ErrorBoundary&&(n.errorElement&&yr(!1,"You should not include both `ErrorBoundary` and `errorElement` on your route - `ErrorBoundary` will be used."),Object.assign(e,{errorElement:D.createElement(n.ErrorBoundary),ErrorBoundary:void 0})),e}function Oq(n,e){return Op({basename:e==null?void 0:e.basename,unstable_getContext:e==null?void 0:e.unstable_getContext,future:e==null?void 0:e.future,history:Q3({initialEntries:e==null?void 0:e.initialEntries,initialIndex:e==null?void 0:e.initialIndex}),hydrationData:e==null?void 0:e.hydrationData,routes:n,mapRouteProperties:fu,dataStrategy:e==null?void 0:e.dataStrategy,patchRoutesOnNavigation:e==null?void 0:e.patchRoutesOnNavigation}).initialize()}var Dee=class{constructor(){this.status="pending",this.promise=new Promise((n,e)=>{this.resolve=t=>{this.status==="pending"&&(this.status="resolved",n(t))},this.reject=t=>{this.status==="pending"&&(this.status="rejected",e(t))}})}};function vq({router:n,flushSync:e}){let[t,r]=D.useState(n.state),[i,o]=D.useState(),[s,a]=D.useState({isTransitioning:!1}),[l,c]=D.useState(),[u,d]=D.useState(),[h,p]=D.useState(),g=D.useRef(new Map),O=D.useCallback((x,{deletedFetchers:P,flushSync:w,viewTransitionOpts:E})=>{x.fetchers.forEach((Q,T)=>{Q.data!==void 0&&g.current.set(T,Q.data)}),P.forEach(Q=>g.current.delete(Q)),xv(w===!1||e!=null,'You provided the `flushSync` option to a router update, but you are not using the `<RouterProvider>` from `react-router/dom` so `ReactDOM.flushSync()` is unavailable. Please update your app to `import { RouterProvider } from "react-router/dom"` and ensure you have `react-dom` installed as a dependency to use the `flushSync` option.');let M=n.window!=null&&n.window.document!=null&&typeof n.window.document.startViewTransition=="function";if(xv(E==null||M,"You provided the `viewTransition` option to a router update, but you do not appear to be running in a DOM environment as `window.startViewTransition` is not available."),!E||!M){e&&w?e(()=>r(x)):D.startTransition(()=>r(x));return}if(e&&w){e(()=>{u&&(l&&l.resolve(),u.skipTransition()),a({isTransitioning:!0,flushSync:!0,currentLocation:E.currentLocation,nextLocation:E.nextLocation})});let Q=n.window.document.startViewTransition(()=>{e(()=>r(x))});Q.finished.finally(()=>{e(()=>{c(void 0),d(void 0),o(void 0),a({isTransitioning:!1})})}),e(()=>d(Q));return}u?(l&&l.resolve(),u.skipTransition(),p({state:x,currentLocation:E.currentLocation,nextLocation:E.nextLocation})):(o(x),a({isTransitioning:!0,flushSync:!1,currentLocation:E.currentLocation,nextLocation:E.nextLocation}))},[n.window,e,u,l]);D.useLayoutEffect(()=>n.subscribe(O),[n,O]),D.useEffect(()=>{s.isTransitioning&&!s.flushSync&&c(new Dee)},[s]),D.useEffect(()=>{if(l&&i&&n.window){let x=i,P=l.promise,w=n.window.document.startViewTransition(async()=>{D.startTransition(()=>r(x)),await P});w.finished.finally(()=>{c(void 0),d(void 0),o(void 0),a({isTransitioning:!1})}),d(w)}},[i,l,n.window]),D.useEffect(()=>{l&&i&&t.location.key===i.location.key&&l.resolve()},[l,u,t.location,i]),D.useEffect(()=>{!s.isTransitioning&&h&&(o(h.state),a({isTransitioning:!0,flushSync:!1,currentLocation:h.currentLocation,nextLocation:h.nextLocation}),p(void 0))},[s.isTransitioning,h]);let v=D.useMemo(()=>({createHref:n.createHref,encodeLocation:n.encodeLocation,go:x=>n.navigate(x),push:(x,P,w)=>n.navigate(x,{state:P,preventScrollReset:w==null?void 0:w.preventScrollReset}),replace:(x,P,w)=>n.navigate(x,{replace:!0,state:P,preventScrollReset:w==null?void 0:w.preventScrollReset})}),[n]),b=n.basename||"/",S=D.useMemo(()=>({router:n,navigator:v,static:!1,basename:b}),[n,v,b]);return D.createElement(D.Fragment,null,D.createElement(Wa.Provider,{value:S},D.createElement(lc.Provider,{value:t},D.createElement(yp.Provider,{value:g.current},D.createElement(vp.Provider,{value:s},D.createElement(fc,{basename:b,location:t.location,navigationType:t.historyAction,navigator:v},D.createElement(Qee,{routes:n.routes,future:n.future,state:t})))))),null)}var Qee=D.memo(Iee);function Iee({routes:n,future:e,state:t}){return Tx(n,void 0,t,e)}function jee({basename:n,children:e,initialEntries:t,initialIndex:r}){let i=D.useRef();i.current==null&&(i.current=Q3({initialEntries:t,initialIndex:r,v5Compat:!0}));let o=i.current,[s,a]=D.useState({action:o.action,location:o.location}),l=D.useCallback(c=>{D.startTransition(()=>a(c))},[a]);return D.useLayoutEffect(()=>o.listen(l),[o,l]),D.createElement(fc,{basename:n,children:e,location:s.location,navigationType:s.action,navigator:o})}function Lee({to:n,replace:e,state:t,relative:r}){zt(cc(),"<Navigate> may be used only in the context of a <Router> component.");let{static:i}=D.useContext(vo);yr(!i,"<Navigate> must not be used on the initial render in a <StaticRouter>. This is a no-op, but you should modify your code so the <Navigate> is only ever rendered in response to some user interaction or state change.");let{matches:o}=D.useContext(yo),{pathname:s}=bo(),a=yy(),l=py(n,hy(o),s,r==="path"),c=JSON.stringify(l);return D.useEffect(()=>{a(JSON.parse(c),{replace:e,state:t,relative:r})},[a,c,r,e,t]),null}function yq(n){return uq(n.context)}function bq(n){zt(!1,"A <Route> is only ever to be used as the child of <Routes> element, never rendered directly. Please wrap your <Route> in a <Routes>.")}function fc({basename:n="/",children:e=null,location:t,navigationType:r="POP",navigator:i,static:o=!1}){zt(!cc(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let s=n.replace(/^\/*/,"/"),a=D.useMemo(()=>({basename:s,navigator:i,static:o,future:{}}),[s,i,o]);typeof t=="string"&&(t=jo(t));let{pathname:l="/",search:c="",hash:u="",state:d=null,key:h="default"}=t,p=D.useMemo(()=>{let g=vi(l,s);return g==null?null:{location:{pathname:g,search:c,hash:u,state:d,key:h},navigationType:r}},[s,l,c,u,d,h,r]);return yr(p!=null,`<Router basename="${s}"> is not able to match the URL "${l}${c}${u}" because it does not start with the basename, so the <Router> won't render anything.`),p==null?null:D.createElement(vo.Provider,{value:a},D.createElement(uu.Provider,{children:e,value:p}))}function Nee({children:n,location:e}){return fq(Gh(n),e)}function qee({children:n,errorElement:e,resolve:t}){return D.createElement(Uee,{resolve:t,errorElement:e},D.createElement(Bee,null,n))}var Uee=class extends D.Component{constructor(n){super(n),this.state={error:null}}static getDerivedStateFromError(n){return{error:n}}componentDidCatch(n,e){console.error("<Await> caught the following error during render",n,e)}render(){let{children:n,errorElement:e,resolve:t}=this.props,r=null,i=0;if(!(t instanceof Promise))i=1,r=Promise.resolve(),Object.defineProperty(r,"_tracked",{get:()=>!0}),Object.defineProperty(r,"_data",{get:()=>t});else if(this.state.error){i=2;let o=this.state.error;r=Promise.reject().catch(()=>{}),Object.defineProperty(r,"_tracked",{get:()=>!0}),Object.defineProperty(r,"_error",{get:()=>o})}else t._tracked?(r=t,i="_error"in r?2:"_data"in r?1:0):(i=0,Object.defineProperty(t,"_tracked",{get:()=>!0}),r=t.then(o=>Object.defineProperty(t,"_data",{get:()=>o}),o=>Object.defineProperty(t,"_error",{get:()=>o})));if(i===2&&!e)throw r._error;if(i===2)return D.createElement(Yh.Provider,{value:r,children:e});if(i===1)return D.createElement(Yh.Provider,{value:r,children:n});throw r}};function Bee({children:n}){let e=pq(),t=typeof n=="function"?n(e):n;return D.createElement(D.Fragment,null,t)}function Gh(n,e=[]){let t=[];return D.Children.forEach(n,(r,i)=>{if(!D.isValidElement(r))return;let o=[...e,i];if(r.type===D.Fragment){t.push.apply(t,Gh(r.props.children,o));return}zt(r.type===bq,`[${typeof r.type=="string"?r.type:r.type.name}] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>`),zt(!r.props.index||!r.props.children,"An index route cannot have child routes.");let s={id:r.props.id||o.join("-"),caseSensitive:r.props.caseSensitive,element:r.props.element,Component:r.props.Component,index:r.props.index,path:r.props.path,loader:r.props.loader,action:r.props.action,hydrateFallbackElement:r.props.hydrateFallbackElement,HydrateFallback:r.props.HydrateFallback,errorElement:r.props.errorElement,ErrorBoundary:r.props.ErrorBoundary,hasErrorBoundary:r.props.hasErrorBoundary===!0||r.props.ErrorBoundary!=null||r.props.errorElement!=null,shouldRevalidate:r.props.shouldRevalidate,handle:r.props.handle,lazy:r.props.lazy};r.props.children&&(s.children=Gh(r.props.children,o)),t.push(s)}),t}var Fee=Gh;function Vee(n){return dq(n)}var IO="get",jO="application/x-www-form-urlencoded";function by(n){return n!=null&&typeof n.tagName=="string"}function Wee(n){return by(n)&&n.tagName.toLowerCase()==="button"}function Zee(n){return by(n)&&n.tagName.toLowerCase()==="form"}function Xee(n){return by(n)&&n.tagName.toLowerCase()==="input"}function zee(n){return!!(n.metaKey||n.altKey||n.ctrlKey||n.shiftKey)}function Yee(n,e){return n.button===0&&(!e||e==="_self")&&!zee(n)}function Cv(n=""){return new URLSearchParams(typeof n=="string"||Array.isArray(n)||n instanceof URLSearchParams?n:Object.keys(n).reduce((e,t)=>{let r=n[t];return e.concat(Array.isArray(r)?r.map(i=>[t,i]):[[t,r]])},[]))}function Gee(n,e){let t=Cv(n);return e&&e.forEach((r,i)=>{t.has(i)||e.getAll(i).forEach(o=>{t.append(i,o)})}),t}var Ym=null;function Hee(){if(Ym===null)try{new FormData(document.createElement("form"),0),Ym=!1}catch{Ym=!0}return Ym}var Kee=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function uS(n){return n!=null&&!Kee.has(n)?(yr(!1,`"${n}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${jO}"`),null):n}function Jee(n,e){let t,r,i,o,s;if(Zee(n)){let a=n.getAttribute("action");r=a?vi(a,e):null,t=n.getAttribute("method")||IO,i=uS(n.getAttribute("enctype"))||jO,o=new FormData(n)}else if(Wee(n)||Xee(n)&&(n.type==="submit"||n.type==="image")){let a=n.form;if(a==null)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');let l=n.getAttribute("formaction")||a.getAttribute("action");if(r=l?vi(l,e):null,t=n.getAttribute("formmethod")||a.getAttribute("method")||IO,i=uS(n.getAttribute("formenctype"))||uS(a.getAttribute("enctype"))||jO,o=new FormData(a,n),!Hee()){let{name:c,type:u,value:d}=n;if(u==="image"){let h=c?`${c}.`:"";o.append(`${h}x`,"0"),o.append(`${h}y`,"0")}else c&&o.append(c,d)}}else{if(by(n))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');t=IO,r=null,i=jO,s=n}return o&&i==="text/plain"&&(s=o,o=void 0),{action:r,method:t.toLowerCase(),encType:i,formData:o,body:s}}function Zi(n,e){if(n===!1||n===null||typeof n>"u")throw new Error(e)}async function Sq(n,e){if(n.id in e)return e[n.id];try{let t=await import(n.module);return e[n.id]=t,t}catch(t){return console.error(`Error loading route module \`${n.module}\`, reloading page...`),console.error(t),window.__reactRouterContext&&window.__reactRouterContext.isSpaMode,window.location.reload(),new Promise(()=>{})}}function ete(n,e,t){let r=n.map(o=>{var l;let s=e[o.route.id],a=t.routes[o.route.id];return[a&&a.css?a.css.map(c=>({rel:"stylesheet",href:c})):[],((l=s==null?void 0:s.links)==null?void 0:l.call(s))||[]]}).flat(2),i=$x(n,t);return xq(r,i)}function wq(n){return n.css?n.css.map(e=>({rel:"stylesheet",href:e})):[]}async function tte(n){if(!n.css)return;let e=wq(n);await Promise.all(e.map(Pq))}async function kq(n,e){if(!n.css&&!e.links||!ste())return;let t=[];if(n.css&&t.push(...wq(n)),e.links&&t.push(...e.links()),t.length===0)return;let r=[];for(let i of t)!Mx(i)&&i.rel==="stylesheet"&&r.push({...i,rel:"preload",as:"style"});await Promise.all(r.map(Pq))}async function Pq(n){return new Promise(e=>{if(n.media&&!window.matchMedia(n.media).matches||document.querySelector(`link[rel="stylesheet"][href="${n.href}"]`))return e();let t=document.createElement("link");Object.assign(t,n);function r(){document.head.contains(t)&&document.head.removeChild(t)}t.onload=()=>{r(),e()},t.onerror=()=>{r(),e()},document.head.appendChild(t)})}function Mx(n){return n!=null&&typeof n.page=="string"}function nte(n){return n==null?!1:n.href==null?n.rel==="preload"&&typeof n.imageSrcSet=="string"&&typeof n.imageSizes=="string":typeof n.rel=="string"&&typeof n.href=="string"}async function rte(n,e,t){let r=await Promise.all(n.map(async i=>{let o=e.routes[i.route.id];if(o){let s=await Sq(o,t);return s.links?s.links():[]}return[]}));return xq(r.flat(1).filter(nte).filter(i=>i.rel==="stylesheet"||i.rel==="preload").map(i=>i.rel==="stylesheet"?{...i,rel:"prefetch",as:"style"}:{...i,rel:"prefetch"}))}function XM(n,e,t,r,i,o){let s=(l,c)=>t[c]?l.route.id!==t[c].route.id:!0,a=(l,c)=>{var u;return t[c].pathname!==l.pathname||((u=t[c].route.path)==null?void 0:u.endsWith("*"))&&t[c].params["*"]!==l.params["*"]};return o==="assets"?e.filter((l,c)=>s(l,c)||a(l,c)):o==="data"?e.filter((l,c)=>{var d;let u=r.routes[l.route.id];if(!u||!u.hasLoader)return!1;if(s(l,c)||a(l,c))return!0;if(l.route.shouldRevalidate){let h=l.route.shouldRevalidate({currentUrl:new URL(i.pathname+i.search+i.hash,window.origin),currentParams:((d=t[0])==null?void 0:d.params)||{},nextUrl:new URL(n,window.origin),nextParams:l.params,defaultShouldRevalidate:!0});if(typeof h=="boolean")return h}return!0}):[]}function $x(n,e,{includeHydrateFallback:t}={}){return ite(n.map(r=>{let i=e.routes[r.route.id];if(!i)return[];let o=[i.module];return i.clientActionModule&&(o=o.concat(i.clientActionModule)),i.clientLoaderModule&&(o=o.concat(i.clientLoaderModule)),t&&i.hydrateFallbackModule&&(o=o.concat(i.hydrateFallbackModule)),i.imports&&(o=o.concat(i.imports)),o}).flat(1))}function ite(n){return[...new Set(n)]}function ote(n){let e={},t=Object.keys(n).sort();for(let r of t)e[r]=n[r];return e}function xq(n,e){let t=new Set,r=new Set(e);return n.reduce((i,o)=>{if(e&&!Mx(o)&&o.as==="script"&&o.href&&r.has(o.href))return i;let a=JSON.stringify(ote(o));return t.has(a)||(t.add(a),i.push({key:a,link:o})),i},[])}var Gm;function ste(){if(Gm!==void 0)return Gm;let n=document.createElement("link");return Gm=n.relList.supports("preload"),n=null,Gm}var ate={"&":"\\u0026",">":"\\u003e","<":"\\u003c","\u2028":"\\u2028","\u2029":"\\u2029"},lte=/[&><\u2028\u2029]/g;function cte(n){return n.replace(lte,e=>ate[e])}function zM(n){return{__html:n}}async function Sy(n){let e={signal:n.signal};if(n.method!=="GET"){e.method=n.method;let t=n.headers.get("Content-Type");t&&/\bapplication\/json\b/.test(t)?(e.headers={"Content-Type":t},e.body=JSON.stringify(await n.json())):t&&/\btext\/plain\b/.test(t)?(e.headers={"Content-Type":t},e.body=await n.text()):t&&/\bapplication\/x-www-form-urlencoded\b/.test(t)?e.body=new URLSearchParams(await n.text()):e.body=await n.formData()}return e}var Kl=Symbol("SingleFetchRedirect");function Cq({context:n,identifier:e,reader:t,textDecoder:r,nonce:i}){if(!n.renderMeta||!n.renderMeta.didRenderScripts)return null;n.renderMeta.streamCache||(n.renderMeta.streamCache={});let{streamCache:o}=n.renderMeta,s=o[e];if(s||(s=o[e]=t.read().then(u=>{o[e].result={done:u.done,value:r.decode(u.value,{stream:!0})}}).catch(u=>{o[e].error=u})),s.error)throw s.error;if(s.result===void 0)throw s;let{done:a,value:l}=s.result,c=l?D.createElement("script",{nonce:i,dangerouslySetInnerHTML:{__html:`window.__reactRouterContext.streamController.enqueue(${cte(JSON.stringify(l))});`}}):null;return a?D.createElement(D.Fragment,null,c,D.createElement("script",{nonce:i,dangerouslySetInnerHTML:{__html:"window.__reactRouterContext.streamController.close();"}})):D.createElement(D.Fragment,null,c,D.createElement(D.Suspense,null,D.createElement(Cq,{context:n,identifier:e+1,reader:t,textDecoder:r,nonce:i})))}function Hm(n,e){return{[e]:{type:"error",result:n}}}function Tq(n,e,t,r,i){return async o=>{let{request:s,matches:a,fetcherKey:l}=o;return s.method!=="GET"?Zc(o,!1,()=>ute(s,a,r),Hm):!t&&!a.some(u=>{var d,h;return u.shouldLoad&&((d=n.routes[u.route.id])==null?void 0:d.hasLoader)&&!((h=n.routes[u.route.id])!=null&&h.hasClientLoader)})?Zc(o,!1,()=>fte(n,s,a,r),Hm):l?Zc(o,!1,()=>hte(s,a,r),Hm):Zc(o,!1,()=>dte(n,e,t,i(),s,a,r),Hm)}}async function ute(n,e,t){let r=e.find(s=>s.shouldLoad);Zi(r,"No action match found");let i,o=await r.resolve(async s=>await s(async()=>{let l=Sp(n.url,t),c=await Sy(n),{data:u,status:d}=await Ix(l,c);return i=d,Bk(u,r.route.id)}));return Ir(o.result)||si(o.result)?{[r.route.id]:o}:{[r.route.id]:{type:o.type,result:V3(o.result,i)}}}async function fte(n,e,t,r){let i=t.filter(l=>l.shouldLoad),o=Qx(Sp(e.url,r)),s=await Sy(e),a={};return await Promise.all(i.map(l=>l.resolve(async c=>{var u;try{let d=(u=n.routes[l.route.id])!=null&&u.hasClientLoader?await Dx(c,o,s,l.route.id):await c();a[l.route.id]={type:"data",result:d}}catch(d){a[l.route.id]={type:"error",result:d}}}))),a}async function dte(n,e,t,r,i,o,s){let a=new Set,l=!1,c=o.map(()=>YM()),u=Promise.all(c.map(v=>v.promise)),d=YM(),h=Qx(Sp(i.url,s)),p=await Sy(i),g={},O=Promise.all(o.map(async(v,b)=>v.resolve(async S=>{c[b].resolve();let x=n.routes[v.route.id];if(!v.shouldLoad){if(!r.state.initialized)return;if(v.route.id in r.state.loaderData&&x&&v.route.shouldRevalidate){x.hasLoader&&(l=!0);return}}if(x&&x.hasClientLoader){x.hasLoader&&(l=!0);try{let P=await Dx(S,h,p,v.route.id);g[v.route.id]={type:"data",result:P}}catch(P){g[v.route.id]={type:"error",result:P}}return}x&&x.hasLoader&&a.add(v.route.id);try{let P=await S(async()=>{let w=await d.promise;return _q(w,v.route.id)});g[v.route.id]={type:"data",result:P}}catch(P){g[v.route.id]={type:"error",result:P}}})));if(await u,(!r.state.initialized||a.size===0)&&!window.__reactRouterHdrActive)d.resolve({});else try{t&&l&&a.size>0&&h.searchParams.set("_routes",o.filter(b=>a.has(b.route.id)).map(b=>b.route.id).join(","));let v=await Ix(h,p);d.resolve(v.data)}catch(v){d.reject(v)}return await O,g}async function hte(n,e,t){let r=e.find(o=>o.shouldLoad);Zi(r,"No fetcher match found");let i=await r.resolve(async o=>{let s=Qx(Sp(n.url,t)),a=await Sy(n);return Dx(o,s,a,r.route.id)});return{[r.route.id]:i}}function Dx(n,e,t,r){return n(async()=>{let i=new URL(e);i.searchParams.set("_routes",r);let{data:o}=await Ix(i,t);return _q(o,r)})}function Qx(n){let e=n.searchParams.getAll("index");n.searchParams.delete("index");let t=[];for(let r of e)r&&t.push(r);for(let r of t)n.searchParams.append("index",r);return n}function Sp(n,e){let t=typeof n=="string"?new URL(n,typeof window>"u"?"server://singlefetch/":window.location.origin):n;return t.pathname==="/"?t.pathname="_root.data":e&&vi(t.pathname,e)==="/"?t.pathname=`${e.replace(/\/$/,"")}/_root.data`:t.pathname=`${t.pathname.replace(/\/$/,"")}.data`,t}async function Ix(n,e){let t=await fetch(n,e);if(t.status===404&&!t.headers.has("X-Remix-Response"))throw new Qo(404,"Not Found",!0);if(new Set([100,101,204,205]).has(t.status))return!e.method||e.method==="GET"?{status:t.status,data:{}}:{status:t.status,data:{data:void 0}};Zi(t.body,"No response body to decode");try{let i=await wy(t.body,window);return{status:t.status,data:i.value}}catch{throw new Error("Unable to decode turbo-stream response")}}function wy(n,e){return bJ(n,{plugins:[(t,...r)=>{if(t==="SanitizedError"){let[i,o,s]=r,a=Error;i&&i in e&&typeof e[i]=="function"&&(a=e[i]);let l=new a(o);return l.stack=s,{value:l}}if(t==="ErrorResponse"){let[i,o,s]=r;return{value:new Qo(o,s,i)}}if(t==="SingleFetchRedirect")return{value:{[Kl]:r[0]}};if(t==="SingleFetchClassInstance")return{value:r[0]};if(t==="SingleFetchFallback")return{value:void 0}}]})}function _q(n,e){let t=n[Kl];return t?Bk(t,e):n[e]!==void 0?Bk(n[e],e):null}function Bk(n,e){if("error"in n)throw n.error;if("redirect"in n){let t={};throw n.revalidate&&(t["X-Remix-Revalidate"]="yes"),n.reload&&(t["X-Remix-Reload-Document"]="yes"),n.replace&&(t["X-Remix-Replace"]="yes"),my(n.redirect,{status:n.status,headers:t})}else{if("data"in n)return n.data;throw new Error(`No response found for routeId "${e}"`)}}function YM(){let n,e,t=new Promise((r,i)=>{n=async o=>{r(o);try{await t}catch{}},e=async o=>{i(o);try{await t}catch{}}});return{promise:t,resolve:n,reject:e}}var jx=class extends D.Component{constructor(n){super(n),this.state={error:n.error||null,location:n.location}}static getDerivedStateFromError(n){return{error:n}}static getDerivedStateFromProps(n,e){return e.location!==n.location?{error:n.error||null,location:n.location}:{error:n.error||e.error,location:e.location}}render(){return this.state.error?D.createElement(Eq,{error:this.state.error,isOutsideRemixApp:!0}):this.props.children}};function Eq({error:n,isOutsideRemixApp:e}){console.error(n);let t=D.createElement("script",{dangerouslySetInnerHTML:{__html:`
|
|
148
|
+
Please change the parent <Route path="${x}"> to <Route path="${x==="/"?"*":`${x}/*`}">.`)}let h=bo(),p;if(e){let x=typeof e=="string"?jo(e):e;zt(u==="/"||((S=x.pathname)==null?void 0:S.startsWith(u)),`When overriding the location using \`<Routes location>\` or \`useRoutes(routes, location)\`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "${u}" but pathname "${x.pathname}" was given in the \`location\` prop.`),p=x}else p=h;let g=p.pathname||"/",O=g;if(u!=="/"){let x=u.replace(/^\//,"").split("/");O="/"+g.replace(/^\//,"").split("/").slice(x.length).join("/")}let v=!o&&t&&t.matches&&t.matches.length>0?t.matches:ho(n,{pathname:O});yr(d||v!=null,`No routes matched location "${p.pathname}${p.search}${p.hash}" `),yr(v==null||v[v.length-1].route.element!==void 0||v[v.length-1].route.Component!==void 0||v[v.length-1].route.lazy!==void 0,`Matched leaf route at location "${p.pathname}${p.search}${p.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`);let b=hq(v&&v.map(x=>Object.assign({},x,{params:Object.assign({},l,x.params),pathname:ca([u,i.encodeLocation?i.encodeLocation(x.pathname).pathname:x.pathname]),pathnameBase:x.pathnameBase==="/"?u:ca([u,i.encodeLocation?i.encodeLocation(x.pathnameBase).pathname:x.pathnameBase])})),s,t,r);return e&&b?D.createElement(uu.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",...p},navigationType:"POP"}},b):b}function kee(){let n=Ax(),e=si(n)?`${n.status} ${n.statusText}`:n instanceof Error?n.message:JSON.stringify(n),t=n instanceof Error?n.stack:null,r="rgba(200,200,200, 0.5)",i={padding:"0.5rem",backgroundColor:r},o={padding:"2px 4px",backgroundColor:r},s=null;return console.error("Error handled by React Router default ErrorBoundary:",n),s=D.createElement(D.Fragment,null,D.createElement("p",null,"💿 Hey developer 👋"),D.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",D.createElement("code",{style:o},"ErrorBoundary")," or"," ",D.createElement("code",{style:o},"errorElement")," prop on your route.")),D.createElement(D.Fragment,null,D.createElement("h2",null,"Unexpected Application Error!"),D.createElement("h3",{style:{fontStyle:"italic"}},e),t?D.createElement("pre",{style:i},t):null,s)}var Pee=D.createElement(kee,null),xee=class extends D.Component{constructor(n){super(n),this.state={location:n.location,revalidation:n.revalidation,error:n.error}}static getDerivedStateFromError(n){return{error:n}}static getDerivedStateFromProps(n,e){return e.location!==n.location||e.revalidation!=="idle"&&n.revalidation==="idle"?{error:n.error,location:n.location,revalidation:n.revalidation}:{error:n.error!==void 0?n.error:e.error,location:e.location,revalidation:n.revalidation||e.revalidation}}componentDidCatch(n,e){console.error("React Router caught the following error during render",n,e)}render(){return this.state.error!==void 0?D.createElement(yo.Provider,{value:this.props.routeContext},D.createElement(Cx.Provider,{value:this.state.error,children:this.props.component})):this.props.children}};function Cee({routeContext:n,match:e,children:t}){let r=D.useContext(Wa);return r&&r.static&&r.staticContext&&(e.route.errorElement||e.route.ErrorBoundary)&&(r.staticContext._deepestRenderedBoundaryId=e.route.id),D.createElement(yo.Provider,{value:n},t)}function hq(n,e=[],t=null,r=null){if(n==null){if(!t)return null;if(t.errors)n=t.matches;else if(e.length===0&&!t.initialized&&t.matches.length>0)n=t.matches;else return null}let i=n,o=t==null?void 0:t.errors;if(o!=null){let l=i.findIndex(c=>c.route.id&&(o==null?void 0:o[c.route.id])!==void 0);zt(l>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(o).join(",")}`),i=i.slice(0,Math.min(i.length,l+1))}let s=!1,a=-1;if(t)for(let l=0;l<i.length;l++){let c=i[l];if((c.route.HydrateFallback||c.route.hydrateFallbackElement)&&(a=l),c.route.id){let{loaderData:u,errors:d}=t,h=c.route.loader&&!u.hasOwnProperty(c.route.id)&&(!d||d[c.route.id]===void 0);if(c.route.lazy||h){s=!0,a>=0?i=i.slice(0,a+1):i=[i[0]];break}}}return i.reduceRight((l,c,u)=>{let d,h=!1,p=null,g=null;t&&(d=o&&c.route.id?o[c.route.id]:void 0,p=c.route.errorElement||Pee,s&&(a<0&&u===0?(Oq("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),h=!0,g=null):a===u&&(h=!0,g=c.route.hydrateFallbackElement||null)));let O=e.concat(i.slice(0,u+1)),v=()=>{let b;return d?b=p:h?b=g:c.route.Component?b=D.createElement(c.route.Component,null):c.route.element?b=c.route.element:b=l,D.createElement(Cee,{match:c,routeContext:{outlet:l,matches:O,isDataRoute:t!=null},children:b})};return t&&(c.route.ErrorBoundary||c.route.errorElement||u===0)?D.createElement(xee,{location:t.location,revalidation:t.revalidation,component:p,error:d,children:v(),routeContext:{outlet:null,matches:O,isDataRoute:!0}}):v()},null)}function _x(n){return`${n} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Ex(n){let e=D.useContext(Wa);return zt(e,_x(n)),e}function uc(n){let e=D.useContext(lc);return zt(e,_x(n)),e}function Tee(n){let e=D.useContext(yo);return zt(e,_x(n)),e}function bp(n){let e=Tee(n),t=e.matches[e.matches.length-1];return zt(t.route.id,`${n} can only be used on routes that contain a unique "id"`),t.route.id}function _ee(){return bp("useRouteId")}function pq(){return uc("useNavigation").navigation}function Eee(){let n=Ex("useRevalidator"),e=uc("useRevalidator");return D.useMemo(()=>({async revalidate(){await n.router.revalidate()},state:e.revalidation}),[n.router,e.revalidation])}function Rx(){let{matches:n,loaderData:e}=uc("useMatches");return D.useMemo(()=>n.map(t=>N3(t,e)),[n,e])}function Ree(){let n=uc("useLoaderData"),e=bp("useLoaderData");return n.loaderData[e]}function Aee(n){return uc("useRouteLoaderData").loaderData[n]}function Mee(){let n=uc("useActionData"),e=bp("useLoaderData");return n.actionData?n.actionData[e]:void 0}function Ax(){var r;let n=D.useContext(Cx),e=uc("useRouteError"),t=bp("useRouteError");return n!==void 0?n:(r=e.errors)==null?void 0:r[t]}function mq(){let n=D.useContext(Yh);return n==null?void 0:n._data}function $ee(){let n=D.useContext(Yh);return n==null?void 0:n._error}var Dee=0;function gq(n){let{router:e,basename:t}=Ex("useBlocker"),r=uc("useBlocker"),[i,o]=D.useState(""),s=D.useCallback(a=>{if(typeof n!="function")return!!n;if(t==="/")return n(a);let{currentLocation:l,nextLocation:c,historyAction:u}=a;return n({currentLocation:{...l,pathname:vi(l.pathname,t)||l.pathname},nextLocation:{...c,pathname:vi(c.pathname,t)||c.pathname},historyAction:u})},[t,n]);return D.useEffect(()=>{let a=String(++Dee);return o(a),()=>e.deleteBlocker(a)},[e]),D.useEffect(()=>{i!==""&&e.getBlocker(i,s)},[e,i,s]),i&&r.blockers.has(i)?r.blockers.get(i):Rl}function Qee(){let{router:n}=Ex("useNavigate"),e=bp("useNavigate"),t=D.useRef(!1);return cq(()=>{t.current=!0}),D.useCallback(async(i,o={})=>{yr(t.current,lq),t.current&&(typeof i=="number"?n.navigate(i):await n.navigate(i,{fromRouteId:e,...o}))},[n,e])}var XM={};function Oq(n,e,t){!e&&!XM[n]&&(XM[n]=!0,yr(!1,t))}var zM={};function xv(n,e){!n&&!zM[e]&&(zM[e]=!0,console.warn(e))}function fu(n){let e={hasErrorBoundary:n.hasErrorBoundary||n.ErrorBoundary!=null||n.errorElement!=null};return n.Component&&(n.element&&yr(!1,"You should not include both `Component` and `element` on your route - `Component` will be used."),Object.assign(e,{element:D.createElement(n.Component),Component:void 0})),n.HydrateFallback&&(n.hydrateFallbackElement&&yr(!1,"You should not include both `HydrateFallback` and `hydrateFallbackElement` on your route - `HydrateFallback` will be used."),Object.assign(e,{hydrateFallbackElement:D.createElement(n.HydrateFallback),HydrateFallback:void 0})),n.ErrorBoundary&&(n.errorElement&&yr(!1,"You should not include both `ErrorBoundary` and `errorElement` on your route - `ErrorBoundary` will be used."),Object.assign(e,{errorElement:D.createElement(n.ErrorBoundary),ErrorBoundary:void 0})),e}function vq(n,e){return Op({basename:e==null?void 0:e.basename,unstable_getContext:e==null?void 0:e.unstable_getContext,future:e==null?void 0:e.future,history:I3({initialEntries:e==null?void 0:e.initialEntries,initialIndex:e==null?void 0:e.initialIndex}),hydrationData:e==null?void 0:e.hydrationData,routes:n,mapRouteProperties:fu,dataStrategy:e==null?void 0:e.dataStrategy,patchRoutesOnNavigation:e==null?void 0:e.patchRoutesOnNavigation}).initialize()}var Iee=class{constructor(){this.status="pending",this.promise=new Promise((n,e)=>{this.resolve=t=>{this.status==="pending"&&(this.status="resolved",n(t))},this.reject=t=>{this.status==="pending"&&(this.status="rejected",e(t))}})}};function yq({router:n,flushSync:e}){let[t,r]=D.useState(n.state),[i,o]=D.useState(),[s,a]=D.useState({isTransitioning:!1}),[l,c]=D.useState(),[u,d]=D.useState(),[h,p]=D.useState(),g=D.useRef(new Map),O=D.useCallback((x,{deletedFetchers:P,flushSync:w,viewTransitionOpts:E})=>{x.fetchers.forEach((Q,T)=>{Q.data!==void 0&&g.current.set(T,Q.data)}),P.forEach(Q=>g.current.delete(Q)),xv(w===!1||e!=null,'You provided the `flushSync` option to a router update, but you are not using the `<RouterProvider>` from `react-router/dom` so `ReactDOM.flushSync()` is unavailable. Please update your app to `import { RouterProvider } from "react-router/dom"` and ensure you have `react-dom` installed as a dependency to use the `flushSync` option.');let M=n.window!=null&&n.window.document!=null&&typeof n.window.document.startViewTransition=="function";if(xv(E==null||M,"You provided the `viewTransition` option to a router update, but you do not appear to be running in a DOM environment as `window.startViewTransition` is not available."),!E||!M){e&&w?e(()=>r(x)):D.startTransition(()=>r(x));return}if(e&&w){e(()=>{u&&(l&&l.resolve(),u.skipTransition()),a({isTransitioning:!0,flushSync:!0,currentLocation:E.currentLocation,nextLocation:E.nextLocation})});let Q=n.window.document.startViewTransition(()=>{e(()=>r(x))});Q.finished.finally(()=>{e(()=>{c(void 0),d(void 0),o(void 0),a({isTransitioning:!1})})}),e(()=>d(Q));return}u?(l&&l.resolve(),u.skipTransition(),p({state:x,currentLocation:E.currentLocation,nextLocation:E.nextLocation})):(o(x),a({isTransitioning:!0,flushSync:!1,currentLocation:E.currentLocation,nextLocation:E.nextLocation}))},[n.window,e,u,l]);D.useLayoutEffect(()=>n.subscribe(O),[n,O]),D.useEffect(()=>{s.isTransitioning&&!s.flushSync&&c(new Iee)},[s]),D.useEffect(()=>{if(l&&i&&n.window){let x=i,P=l.promise,w=n.window.document.startViewTransition(async()=>{D.startTransition(()=>r(x)),await P});w.finished.finally(()=>{c(void 0),d(void 0),o(void 0),a({isTransitioning:!1})}),d(w)}},[i,l,n.window]),D.useEffect(()=>{l&&i&&t.location.key===i.location.key&&l.resolve()},[l,u,t.location,i]),D.useEffect(()=>{!s.isTransitioning&&h&&(o(h.state),a({isTransitioning:!0,flushSync:!1,currentLocation:h.currentLocation,nextLocation:h.nextLocation}),p(void 0))},[s.isTransitioning,h]);let v=D.useMemo(()=>({createHref:n.createHref,encodeLocation:n.encodeLocation,go:x=>n.navigate(x),push:(x,P,w)=>n.navigate(x,{state:P,preventScrollReset:w==null?void 0:w.preventScrollReset}),replace:(x,P,w)=>n.navigate(x,{replace:!0,state:P,preventScrollReset:w==null?void 0:w.preventScrollReset})}),[n]),b=n.basename||"/",S=D.useMemo(()=>({router:n,navigator:v,static:!1,basename:b}),[n,v,b]);return D.createElement(D.Fragment,null,D.createElement(Wa.Provider,{value:S},D.createElement(lc.Provider,{value:t},D.createElement(yp.Provider,{value:g.current},D.createElement(vp.Provider,{value:s},D.createElement(fc,{basename:b,location:t.location,navigationType:t.historyAction,navigator:v},D.createElement(jee,{routes:n.routes,future:n.future,state:t})))))),null)}var jee=D.memo(Lee);function Lee({routes:n,future:e,state:t}){return Tx(n,void 0,t,e)}function Nee({basename:n,children:e,initialEntries:t,initialIndex:r}){let i=D.useRef();i.current==null&&(i.current=I3({initialEntries:t,initialIndex:r,v5Compat:!0}));let o=i.current,[s,a]=D.useState({action:o.action,location:o.location}),l=D.useCallback(c=>{D.startTransition(()=>a(c))},[a]);return D.useLayoutEffect(()=>o.listen(l),[o,l]),D.createElement(fc,{basename:n,children:e,location:s.location,navigationType:s.action,navigator:o})}function qee({to:n,replace:e,state:t,relative:r}){zt(cc(),"<Navigate> may be used only in the context of a <Router> component.");let{static:i}=D.useContext(vo);yr(!i,"<Navigate> must not be used on the initial render in a <StaticRouter>. This is a no-op, but you should modify your code so the <Navigate> is only ever rendered in response to some user interaction or state change.");let{matches:o}=D.useContext(yo),{pathname:s}=bo(),a=yy(),l=py(n,hy(o),s,r==="path"),c=JSON.stringify(l);return D.useEffect(()=>{a(JSON.parse(c),{replace:e,state:t,relative:r})},[a,c,r,e,t]),null}function bq(n){return fq(n.context)}function Sq(n){zt(!1,"A <Route> is only ever to be used as the child of <Routes> element, never rendered directly. Please wrap your <Route> in a <Routes>.")}function fc({basename:n="/",children:e=null,location:t,navigationType:r="POP",navigator:i,static:o=!1}){zt(!cc(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let s=n.replace(/^\/*/,"/"),a=D.useMemo(()=>({basename:s,navigator:i,static:o,future:{}}),[s,i,o]);typeof t=="string"&&(t=jo(t));let{pathname:l="/",search:c="",hash:u="",state:d=null,key:h="default"}=t,p=D.useMemo(()=>{let g=vi(l,s);return g==null?null:{location:{pathname:g,search:c,hash:u,state:d,key:h},navigationType:r}},[s,l,c,u,d,h,r]);return yr(p!=null,`<Router basename="${s}"> is not able to match the URL "${l}${c}${u}" because it does not start with the basename, so the <Router> won't render anything.`),p==null?null:D.createElement(vo.Provider,{value:a},D.createElement(uu.Provider,{children:e,value:p}))}function Uee({children:n,location:e}){return dq(Gh(n),e)}function Bee({children:n,errorElement:e,resolve:t}){return D.createElement(Fee,{resolve:t,errorElement:e},D.createElement(Vee,null,n))}var Fee=class extends D.Component{constructor(n){super(n),this.state={error:null}}static getDerivedStateFromError(n){return{error:n}}componentDidCatch(n,e){console.error("<Await> caught the following error during render",n,e)}render(){let{children:n,errorElement:e,resolve:t}=this.props,r=null,i=0;if(!(t instanceof Promise))i=1,r=Promise.resolve(),Object.defineProperty(r,"_tracked",{get:()=>!0}),Object.defineProperty(r,"_data",{get:()=>t});else if(this.state.error){i=2;let o=this.state.error;r=Promise.reject().catch(()=>{}),Object.defineProperty(r,"_tracked",{get:()=>!0}),Object.defineProperty(r,"_error",{get:()=>o})}else t._tracked?(r=t,i="_error"in r?2:"_data"in r?1:0):(i=0,Object.defineProperty(t,"_tracked",{get:()=>!0}),r=t.then(o=>Object.defineProperty(t,"_data",{get:()=>o}),o=>Object.defineProperty(t,"_error",{get:()=>o})));if(i===2&&!e)throw r._error;if(i===2)return D.createElement(Yh.Provider,{value:r,children:e});if(i===1)return D.createElement(Yh.Provider,{value:r,children:n});throw r}};function Vee({children:n}){let e=mq(),t=typeof n=="function"?n(e):n;return D.createElement(D.Fragment,null,t)}function Gh(n,e=[]){let t=[];return D.Children.forEach(n,(r,i)=>{if(!D.isValidElement(r))return;let o=[...e,i];if(r.type===D.Fragment){t.push.apply(t,Gh(r.props.children,o));return}zt(r.type===Sq,`[${typeof r.type=="string"?r.type:r.type.name}] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>`),zt(!r.props.index||!r.props.children,"An index route cannot have child routes.");let s={id:r.props.id||o.join("-"),caseSensitive:r.props.caseSensitive,element:r.props.element,Component:r.props.Component,index:r.props.index,path:r.props.path,loader:r.props.loader,action:r.props.action,hydrateFallbackElement:r.props.hydrateFallbackElement,HydrateFallback:r.props.HydrateFallback,errorElement:r.props.errorElement,ErrorBoundary:r.props.ErrorBoundary,hasErrorBoundary:r.props.hasErrorBoundary===!0||r.props.ErrorBoundary!=null||r.props.errorElement!=null,shouldRevalidate:r.props.shouldRevalidate,handle:r.props.handle,lazy:r.props.lazy};r.props.children&&(s.children=Gh(r.props.children,o)),t.push(s)}),t}var Wee=Gh;function Zee(n){return hq(n)}var IO="get",jO="application/x-www-form-urlencoded";function by(n){return n!=null&&typeof n.tagName=="string"}function Xee(n){return by(n)&&n.tagName.toLowerCase()==="button"}function zee(n){return by(n)&&n.tagName.toLowerCase()==="form"}function Yee(n){return by(n)&&n.tagName.toLowerCase()==="input"}function Gee(n){return!!(n.metaKey||n.altKey||n.ctrlKey||n.shiftKey)}function Hee(n,e){return n.button===0&&(!e||e==="_self")&&!Gee(n)}function Cv(n=""){return new URLSearchParams(typeof n=="string"||Array.isArray(n)||n instanceof URLSearchParams?n:Object.keys(n).reduce((e,t)=>{let r=n[t];return e.concat(Array.isArray(r)?r.map(i=>[t,i]):[[t,r]])},[]))}function Kee(n,e){let t=Cv(n);return e&&e.forEach((r,i)=>{t.has(i)||e.getAll(i).forEach(o=>{t.append(i,o)})}),t}var Ym=null;function Jee(){if(Ym===null)try{new FormData(document.createElement("form"),0),Ym=!1}catch{Ym=!0}return Ym}var ete=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function uS(n){return n!=null&&!ete.has(n)?(yr(!1,`"${n}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${jO}"`),null):n}function tte(n,e){let t,r,i,o,s;if(zee(n)){let a=n.getAttribute("action");r=a?vi(a,e):null,t=n.getAttribute("method")||IO,i=uS(n.getAttribute("enctype"))||jO,o=new FormData(n)}else if(Xee(n)||Yee(n)&&(n.type==="submit"||n.type==="image")){let a=n.form;if(a==null)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');let l=n.getAttribute("formaction")||a.getAttribute("action");if(r=l?vi(l,e):null,t=n.getAttribute("formmethod")||a.getAttribute("method")||IO,i=uS(n.getAttribute("formenctype"))||uS(a.getAttribute("enctype"))||jO,o=new FormData(a,n),!Jee()){let{name:c,type:u,value:d}=n;if(u==="image"){let h=c?`${c}.`:"";o.append(`${h}x`,"0"),o.append(`${h}y`,"0")}else c&&o.append(c,d)}}else{if(by(n))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');t=IO,r=null,i=jO,s=n}return o&&i==="text/plain"&&(s=o,o=void 0),{action:r,method:t.toLowerCase(),encType:i,formData:o,body:s}}function Zi(n,e){if(n===!1||n===null||typeof n>"u")throw new Error(e)}async function wq(n,e){if(n.id in e)return e[n.id];try{let t=await import(n.module);return e[n.id]=t,t}catch(t){return console.error(`Error loading route module \`${n.module}\`, reloading page...`),console.error(t),window.__reactRouterContext&&window.__reactRouterContext.isSpaMode,window.location.reload(),new Promise(()=>{})}}function nte(n,e,t){let r=n.map(o=>{var l;let s=e[o.route.id],a=t.routes[o.route.id];return[a&&a.css?a.css.map(c=>({rel:"stylesheet",href:c})):[],((l=s==null?void 0:s.links)==null?void 0:l.call(s))||[]]}).flat(2),i=$x(n,t);return Cq(r,i)}function kq(n){return n.css?n.css.map(e=>({rel:"stylesheet",href:e})):[]}async function rte(n){if(!n.css)return;let e=kq(n);await Promise.all(e.map(xq))}async function Pq(n,e){if(!n.css&&!e.links||!lte())return;let t=[];if(n.css&&t.push(...kq(n)),e.links&&t.push(...e.links()),t.length===0)return;let r=[];for(let i of t)!Mx(i)&&i.rel==="stylesheet"&&r.push({...i,rel:"preload",as:"style"});await Promise.all(r.map(xq))}async function xq(n){return new Promise(e=>{if(n.media&&!window.matchMedia(n.media).matches||document.querySelector(`link[rel="stylesheet"][href="${n.href}"]`))return e();let t=document.createElement("link");Object.assign(t,n);function r(){document.head.contains(t)&&document.head.removeChild(t)}t.onload=()=>{r(),e()},t.onerror=()=>{r(),e()},document.head.appendChild(t)})}function Mx(n){return n!=null&&typeof n.page=="string"}function ite(n){return n==null?!1:n.href==null?n.rel==="preload"&&typeof n.imageSrcSet=="string"&&typeof n.imageSizes=="string":typeof n.rel=="string"&&typeof n.href=="string"}async function ote(n,e,t){let r=await Promise.all(n.map(async i=>{let o=e.routes[i.route.id];if(o){let s=await wq(o,t);return s.links?s.links():[]}return[]}));return Cq(r.flat(1).filter(ite).filter(i=>i.rel==="stylesheet"||i.rel==="preload").map(i=>i.rel==="stylesheet"?{...i,rel:"prefetch",as:"style"}:{...i,rel:"prefetch"}))}function YM(n,e,t,r,i,o){let s=(l,c)=>t[c]?l.route.id!==t[c].route.id:!0,a=(l,c)=>{var u;return t[c].pathname!==l.pathname||((u=t[c].route.path)==null?void 0:u.endsWith("*"))&&t[c].params["*"]!==l.params["*"]};return o==="assets"?e.filter((l,c)=>s(l,c)||a(l,c)):o==="data"?e.filter((l,c)=>{var d;let u=r.routes[l.route.id];if(!u||!u.hasLoader)return!1;if(s(l,c)||a(l,c))return!0;if(l.route.shouldRevalidate){let h=l.route.shouldRevalidate({currentUrl:new URL(i.pathname+i.search+i.hash,window.origin),currentParams:((d=t[0])==null?void 0:d.params)||{},nextUrl:new URL(n,window.origin),nextParams:l.params,defaultShouldRevalidate:!0});if(typeof h=="boolean")return h}return!0}):[]}function $x(n,e,{includeHydrateFallback:t}={}){return ste(n.map(r=>{let i=e.routes[r.route.id];if(!i)return[];let o=[i.module];return i.clientActionModule&&(o=o.concat(i.clientActionModule)),i.clientLoaderModule&&(o=o.concat(i.clientLoaderModule)),t&&i.hydrateFallbackModule&&(o=o.concat(i.hydrateFallbackModule)),i.imports&&(o=o.concat(i.imports)),o}).flat(1))}function ste(n){return[...new Set(n)]}function ate(n){let e={},t=Object.keys(n).sort();for(let r of t)e[r]=n[r];return e}function Cq(n,e){let t=new Set,r=new Set(e);return n.reduce((i,o)=>{if(e&&!Mx(o)&&o.as==="script"&&o.href&&r.has(o.href))return i;let a=JSON.stringify(ate(o));return t.has(a)||(t.add(a),i.push({key:a,link:o})),i},[])}var Gm;function lte(){if(Gm!==void 0)return Gm;let n=document.createElement("link");return Gm=n.relList.supports("preload"),n=null,Gm}var cte={"&":"\\u0026",">":"\\u003e","<":"\\u003c","\u2028":"\\u2028","\u2029":"\\u2029"},ute=/[&><\u2028\u2029]/g;function fte(n){return n.replace(ute,e=>cte[e])}function GM(n){return{__html:n}}async function Sy(n){let e={signal:n.signal};if(n.method!=="GET"){e.method=n.method;let t=n.headers.get("Content-Type");t&&/\bapplication\/json\b/.test(t)?(e.headers={"Content-Type":t},e.body=JSON.stringify(await n.json())):t&&/\btext\/plain\b/.test(t)?(e.headers={"Content-Type":t},e.body=await n.text()):t&&/\bapplication\/x-www-form-urlencoded\b/.test(t)?e.body=new URLSearchParams(await n.text()):e.body=await n.formData()}return e}var Kl=Symbol("SingleFetchRedirect");function Tq({context:n,identifier:e,reader:t,textDecoder:r,nonce:i}){if(!n.renderMeta||!n.renderMeta.didRenderScripts)return null;n.renderMeta.streamCache||(n.renderMeta.streamCache={});let{streamCache:o}=n.renderMeta,s=o[e];if(s||(s=o[e]=t.read().then(u=>{o[e].result={done:u.done,value:r.decode(u.value,{stream:!0})}}).catch(u=>{o[e].error=u})),s.error)throw s.error;if(s.result===void 0)throw s;let{done:a,value:l}=s.result,c=l?D.createElement("script",{nonce:i,dangerouslySetInnerHTML:{__html:`window.__reactRouterContext.streamController.enqueue(${fte(JSON.stringify(l))});`}}):null;return a?D.createElement(D.Fragment,null,c,D.createElement("script",{nonce:i,dangerouslySetInnerHTML:{__html:"window.__reactRouterContext.streamController.close();"}})):D.createElement(D.Fragment,null,c,D.createElement(D.Suspense,null,D.createElement(Tq,{context:n,identifier:e+1,reader:t,textDecoder:r,nonce:i})))}function Hm(n,e){return{[e]:{type:"error",result:n}}}function _q(n,e,t,r,i){return async o=>{let{request:s,matches:a,fetcherKey:l}=o;return s.method!=="GET"?Zc(o,!1,()=>dte(s,a,r),Hm):!t&&!a.some(u=>{var d,h;return u.shouldLoad&&((d=n.routes[u.route.id])==null?void 0:d.hasLoader)&&!((h=n.routes[u.route.id])!=null&&h.hasClientLoader)})?Zc(o,!1,()=>hte(n,s,a,r),Hm):l?Zc(o,!1,()=>mte(s,a,r),Hm):Zc(o,!1,()=>pte(n,e,t,i(),s,a,r),Hm)}}async function dte(n,e,t){let r=e.find(s=>s.shouldLoad);Zi(r,"No action match found");let i,o=await r.resolve(async s=>await s(async()=>{let l=Sp(n.url,t),c=await Sy(n),{data:u,status:d}=await Ix(l,c);return i=d,Bk(u,r.route.id)}));return Ir(o.result)||si(o.result)?{[r.route.id]:o}:{[r.route.id]:{type:o.type,result:W3(o.result,i)}}}async function hte(n,e,t,r){let i=t.filter(l=>l.shouldLoad),o=Qx(Sp(e.url,r)),s=await Sy(e),a={};return await Promise.all(i.map(l=>l.resolve(async c=>{var u;try{let d=(u=n.routes[l.route.id])!=null&&u.hasClientLoader?await Dx(c,o,s,l.route.id):await c();a[l.route.id]={type:"data",result:d}}catch(d){a[l.route.id]={type:"error",result:d}}}))),a}async function pte(n,e,t,r,i,o,s){let a=new Set,l=!1,c=o.map(()=>HM()),u=Promise.all(c.map(v=>v.promise)),d=HM(),h=Qx(Sp(i.url,s)),p=await Sy(i),g={},O=Promise.all(o.map(async(v,b)=>v.resolve(async S=>{c[b].resolve();let x=n.routes[v.route.id];if(!v.shouldLoad){if(!r.state.initialized)return;if(v.route.id in r.state.loaderData&&x&&v.route.shouldRevalidate){x.hasLoader&&(l=!0);return}}if(x&&x.hasClientLoader){x.hasLoader&&(l=!0);try{let P=await Dx(S,h,p,v.route.id);g[v.route.id]={type:"data",result:P}}catch(P){g[v.route.id]={type:"error",result:P}}return}x&&x.hasLoader&&a.add(v.route.id);try{let P=await S(async()=>{let w=await d.promise;return Eq(w,v.route.id)});g[v.route.id]={type:"data",result:P}}catch(P){g[v.route.id]={type:"error",result:P}}})));if(await u,(!r.state.initialized||a.size===0)&&!window.__reactRouterHdrActive)d.resolve({});else try{t&&l&&a.size>0&&h.searchParams.set("_routes",o.filter(b=>a.has(b.route.id)).map(b=>b.route.id).join(","));let v=await Ix(h,p);d.resolve(v.data)}catch(v){d.reject(v)}return await O,g}async function mte(n,e,t){let r=e.find(o=>o.shouldLoad);Zi(r,"No fetcher match found");let i=await r.resolve(async o=>{let s=Qx(Sp(n.url,t)),a=await Sy(n);return Dx(o,s,a,r.route.id)});return{[r.route.id]:i}}function Dx(n,e,t,r){return n(async()=>{let i=new URL(e);i.searchParams.set("_routes",r);let{data:o}=await Ix(i,t);return Eq(o,r)})}function Qx(n){let e=n.searchParams.getAll("index");n.searchParams.delete("index");let t=[];for(let r of e)r&&t.push(r);for(let r of t)n.searchParams.append("index",r);return n}function Sp(n,e){let t=typeof n=="string"?new URL(n,typeof window>"u"?"server://singlefetch/":window.location.origin):n;return t.pathname==="/"?t.pathname="_root.data":e&&vi(t.pathname,e)==="/"?t.pathname=`${e.replace(/\/$/,"")}/_root.data`:t.pathname=`${t.pathname.replace(/\/$/,"")}.data`,t}async function Ix(n,e){let t=await fetch(n,e);if(t.status===404&&!t.headers.has("X-Remix-Response"))throw new Qo(404,"Not Found",!0);if(new Set([100,101,204,205]).has(t.status))return!e.method||e.method==="GET"?{status:t.status,data:{}}:{status:t.status,data:{data:void 0}};Zi(t.body,"No response body to decode");try{let i=await wy(t.body,window);return{status:t.status,data:i.value}}catch{throw new Error("Unable to decode turbo-stream response")}}function wy(n,e){return wJ(n,{plugins:[(t,...r)=>{if(t==="SanitizedError"){let[i,o,s]=r,a=Error;i&&i in e&&typeof e[i]=="function"&&(a=e[i]);let l=new a(o);return l.stack=s,{value:l}}if(t==="ErrorResponse"){let[i,o,s]=r;return{value:new Qo(o,s,i)}}if(t==="SingleFetchRedirect")return{value:{[Kl]:r[0]}};if(t==="SingleFetchClassInstance")return{value:r[0]};if(t==="SingleFetchFallback")return{value:void 0}}]})}function Eq(n,e){let t=n[Kl];return t?Bk(t,e):n[e]!==void 0?Bk(n[e],e):null}function Bk(n,e){if("error"in n)throw n.error;if("redirect"in n){let t={};throw n.revalidate&&(t["X-Remix-Revalidate"]="yes"),n.reload&&(t["X-Remix-Reload-Document"]="yes"),n.replace&&(t["X-Remix-Replace"]="yes"),my(n.redirect,{status:n.status,headers:t})}else{if("data"in n)return n.data;throw new Error(`No response found for routeId "${e}"`)}}function HM(){let n,e,t=new Promise((r,i)=>{n=async o=>{r(o);try{await t}catch{}},e=async o=>{i(o);try{await t}catch{}}});return{promise:t,resolve:n,reject:e}}var jx=class extends D.Component{constructor(n){super(n),this.state={error:n.error||null,location:n.location}}static getDerivedStateFromError(n){return{error:n}}static getDerivedStateFromProps(n,e){return e.location!==n.location?{error:n.error||null,location:n.location}:{error:n.error||e.error,location:e.location}}render(){return this.state.error?D.createElement(Rq,{error:this.state.error,isOutsideRemixApp:!0}):this.props.children}};function Rq({error:n,isOutsideRemixApp:e}){console.error(n);let t=D.createElement("script",{dangerouslySetInnerHTML:{__html:`
|
|
149
149
|
console.log(
|
|
150
150
|
"💿 Hey developer 👋. You can provide a way better UX than this when your app throws errors. Check out https://remix.run/guides/errors for more information."
|
|
151
151
|
);
|
|
152
|
-
`}});if(si(n))return D.createElement(Fk,{title:"Unhandled Thrown Response!"},D.createElement("h1",{style:{fontSize:"24px"}},n.status," ",n.statusText),t);let r;if(n instanceof Error)r=n;else{let i=n==null?"Unknown Error":typeof n=="object"&&"toString"in n?n.toString():JSON.stringify(n);r=new Error(i)}return D.createElement(Fk,{title:"Application Error!",isOutsideRemixApp:e},D.createElement("h1",{style:{fontSize:"24px"}},"Application Error"),D.createElement("pre",{style:{padding:"2rem",background:"hsla(10, 50%, 50%, 0.1)",color:"red",overflow:"auto"}},r.stack),t)}function Fk({title:n,renderScripts:e,isOutsideRemixApp:t,children:r}){var o;let{routeModules:i}=Jf();return(o=i.root)!=null&&o.Layout&&!t?r:D.createElement("html",{lang:"en"},D.createElement("head",null,D.createElement("meta",{charSet:"utf-8"}),D.createElement("meta",{name:"viewport",content:"width=device-width,initial-scale=1,viewport-fit=cover"}),D.createElement("title",null,n)),D.createElement("body",null,D.createElement("main",{style:{fontFamily:"system-ui, sans-serif",padding:"2rem"}},r,e?D.createElement(
|
|
152
|
+
`}});if(si(n))return D.createElement(Fk,{title:"Unhandled Thrown Response!"},D.createElement("h1",{style:{fontSize:"24px"}},n.status," ",n.statusText),t);let r;if(n instanceof Error)r=n;else{let i=n==null?"Unknown Error":typeof n=="object"&&"toString"in n?n.toString():JSON.stringify(n);r=new Error(i)}return D.createElement(Fk,{title:"Application Error!",isOutsideRemixApp:e},D.createElement("h1",{style:{fontSize:"24px"}},"Application Error"),D.createElement("pre",{style:{padding:"2rem",background:"hsla(10, 50%, 50%, 0.1)",color:"red",overflow:"auto"}},r.stack),t)}function Fk({title:n,renderScripts:e,isOutsideRemixApp:t,children:r}){var o;let{routeModules:i}=Jf();return(o=i.root)!=null&&o.Layout&&!t?r:D.createElement("html",{lang:"en"},D.createElement("head",null,D.createElement("meta",{charSet:"utf-8"}),D.createElement("meta",{name:"viewport",content:"width=device-width,initial-scale=1,viewport-fit=cover"}),D.createElement("title",null,n)),D.createElement("body",null,D.createElement("main",{style:{fontFamily:"system-ui, sans-serif",padding:"2rem"}},r,e?D.createElement(Lq,null):null)))}function gte(){return D.createElement(Fk,{title:"Loading...",renderScripts:!0},D.createElement("script",{dangerouslySetInnerHTML:{__html:`
|
|
153
153
|
console.log(
|
|
154
154
|
"💿 Hey developer 👋. You can provide a way better UX than this " +
|
|
155
155
|
"when your app is loading JS modules and/or running \`clientLoader\` " +
|
|
156
156
|
"functions. Check out https://remix.run/route/hydrate-fallback " +
|
|
157
157
|
"for more information."
|
|
158
158
|
);
|
|
159
|
-
`}}))}function Lx(n){let e={};return Object.values(n).forEach(t=>{if(t){let r=t.parentId||"";e[r]||(e[r]=[]),e[r].push(t)}}),e}function Rq(n,e,t){let r=$q(e),i=e.HydrateFallback&&(!t||n.id==="root")?e.HydrateFallback:n.id==="root"?pte:void 0,o=e.ErrorBoundary?e.ErrorBoundary:n.id==="root"?()=>D.createElement(Eq,{error:Ax()}):void 0;return n.id==="root"&&e.Layout?{...r?{element:D.createElement(e.Layout,null,D.createElement(r,null))}:{Component:r},...o?{errorElement:D.createElement(e.Layout,null,D.createElement(o,null))}:{ErrorBoundary:o},...i?{hydrateFallbackElement:D.createElement(e.Layout,null,D.createElement(i,null))}:{HydrateFallback:i}}:{Component:r,ErrorBoundary:o,HydrateFallback:i}}function Aq(n,e,t,r,i="",o=Lx(n),s=Promise.resolve({Component:()=>null})){return(o[i]||[]).map(a=>{let l=e[a.id];Zi(l,"No `routeModule` available to create server routes");let c={...Rq(a,l,r),caseSensitive:a.caseSensitive,id:a.id,index:a.index,path:a.path,handle:l.handle,lazy:r?()=>s:void 0,loader:a.hasLoader||a.hasClientLoader?()=>null:void 0},u=Aq(n,e,t,r,a.id,o,s);return u.length>0&&(c.children=u),c})}function Mq(n,e,t,r,i,o){return wp(e,t,r,i,o,"",Lx(e),n)}function Uu(n,e){if(n==="loader"&&!e.hasLoader||n==="action"&&!e.hasAction){let r=`You are trying to call ${n==="action"?"serverAction()":"serverLoader()"} on a route that does not have a server ${n} (routeId: "${e.id}")`;throw console.error(r),new Qo(400,"Bad Request",new Error(r),!0)}}function fS(n,e){let t=n==="clientAction"?"a":"an",r=`Route "${e}" does not have ${t} ${n}, but you are trying to submit to it. To fix this, please add ${t} \`${n}\` function to the route`;throw console.error(r),new Qo(405,"Method Not Allowed",new Error(r),!0)}function wp(n,e,t,r,i,o="",s=Lx(n),a){return(s[o]||[]).map(l=>{var S,x,P;let c=e[l.id];function u(w){return Zi(typeof w=="function","No single fetch function available for route handler"),w()}function d(w){return l.hasLoader?u(w):Promise.resolve(null)}function h(w){if(!l.hasAction)throw fS("action",l.id);return u(w)}function p(w){import(w)}function g(w){w.clientActionModule&&p(w.clientActionModule),w.clientLoaderModule&&p(w.clientLoaderModule)}async function O(w){let E=e[l.id],M=E?kq(l,E):Promise.resolve();try{return w()}finally{await M}}let v={id:l.id,index:l.index,path:l.path};if(c){Object.assign(v,{...v,...Rq(l,c,i),unstable_middleware:c.unstable_clientMiddleware,handle:c.handle,shouldRevalidate:GM(c,l,r,a)});let w=t&&t.loaderData&&l.id in t.loaderData,E=w?(S=t==null?void 0:t.loaderData)==null?void 0:S[l.id]:void 0,M=t&&t.errors&&l.id in t.errors,Q=M?(x=t==null?void 0:t.errors)==null?void 0:x[l.id]:void 0,T=a==null&&(((P=c.clientLoader)==null?void 0:P.hydrate)===!0||!l.hasLoader);v.loader=async({request:R,params:$,context:I},B)=>{try{return await O(async()=>(Zi(c,"No `routeModule` available for critical-route loader"),c.clientLoader?c.clientLoader({request:R,params:$,context:I,async serverLoader(){if(Uu("loader",l),T){if(w)return E;if(M)throw Q}return d(B)}}):d(B)))}finally{T=!1}},v.loader.hydrate=ky(l,c,i),v.action=({request:R,params:$,context:I},B)=>O(async()=>{if(Zi(c,"No `routeModule` available for critical-route action"),!c.clientAction){if(i)throw fS("clientAction",l.id);return h(B)}return c.clientAction({request:R,params:$,context:I,async serverAction(){return Uu("action",l),h(B)}})})}else l.hasClientLoader?l.clientLoaderModule&&(v.loader=async(w,E)=>{Zi(l.clientLoaderModule);let{clientLoader:M}=await import(l.clientLoaderModule);return M({...w,async serverLoader(){return Uu("loader",l),d(E)}})}):v.loader=(w,E)=>O(()=>d(E)),l.hasClientAction?l.clientActionModule&&(v.action=async(w,E)=>{Zi(l.clientActionModule),g(l);let{clientAction:M}=await import(l.clientActionModule);return M({...w,async serverAction(){return Uu("action",l),h(E)}})}):v.action=(w,E)=>O(()=>{if(i)throw fS("clientAction",l.id);return h(E)}),l.hasClientMiddleware&&(v.unstable_lazyMiddleware=async()=>{Zi(l);let w=await import(l.clientMiddlewareModule||l.module);return Zi(w==null?void 0:w.unstable_clientMiddleware,"No `unstable_clientMiddleware` export in chunk"),w.unstable_clientMiddleware}),v.lazy=async()=>{(l.clientLoaderModule||l.clientActionModule)&&await new Promise(Q=>setTimeout(Q,0));let w=gte(l,e);g(l);let E=await w,M={...E};if(E.clientLoader){let Q=E.clientLoader;M.loader=(T,R)=>Q({...T,async serverLoader(){return Uu("loader",l),d(R)}})}if(E.clientAction){let Q=E.clientAction;M.action=(T,R)=>Q({...T,async serverAction(){return Uu("action",l),h(R)}})}return{...M.loader?{loader:M.loader}:{},...M.action?{action:M.action}:{},hasErrorBoundary:M.hasErrorBoundary,shouldRevalidate:GM(M,l,r,a),handle:M.handle,Component:M.Component,ErrorBoundary:M.ErrorBoundary}};let b=wp(n,e,t,r,i,l.id,s,a);return b.length>0&&(v.children=b),v})}function GM(n,e,t,r){if(r)return mte(e.id,n.shouldRevalidate,r);if(!t&&e.hasLoader&&!e.hasClientLoader)if(n.shouldRevalidate){let i=n.shouldRevalidate;return o=>i({...o,defaultShouldRevalidate:!1})}else return()=>!1;if(t&&n.shouldRevalidate){let i=n.shouldRevalidate;return o=>i({...o,defaultShouldRevalidate:!0})}return n.shouldRevalidate}function mte(n,e,t){let r=!1;return i=>r?e?e(i):i.defaultShouldRevalidate:(r=!0,t.has(n))}async function gte(n,e){let t=Sq(n,e),r=tte(n),i=await t;return await Promise.all([r,kq(n,i)]),{Component:$q(i),ErrorBoundary:i.ErrorBoundary,unstable_clientMiddleware:i.unstable_clientMiddleware,clientAction:i.clientAction,clientLoader:i.clientLoader,handle:i.handle,links:i.links,meta:i.meta,shouldRevalidate:i.shouldRevalidate}}function $q(n){if(n.default==null)return;if(!(typeof n.default=="object"&&Object.keys(n.default).length===0))return n.default}function ky(n,e,t){return t&&n.id!=="root"||e.clientLoader!=null&&(e.clientLoader.hydrate===!0||n.hasLoader!==!0)}var LO=new Set,Ote=1e3,Tv=new Set,vte=7680;function Nx(n){return n===!0}function yte(n,e){let t=new Set(e.state.matches.map(s=>s.route.id)),r=e.state.location.pathname.split("/").filter(Boolean),i=["/"];for(r.pop();r.length>0;)i.push(`/${r.join("/")}`),r.pop();i.forEach(s=>{let a=ho(e.routes,s,e.basename);a&&a.forEach(l=>t.add(l.route.id))});let o=[...t].reduce((s,a)=>Object.assign(s,{[a]:n.routes[a]}),{});return{...n,routes:o}}function Dq(n,e,t,r,i){if(Nx(t))return async({path:o,patch:s,signal:a,fetcherKey:l})=>{Tv.has(o)||await Iq([o],l?window.location.href:o,n,e,t,r,i,s,a)}}function Qq(n,e,t,r,i){D.useEffect(()=>{var c;if(!Nx(r)||((c=navigator.connection)==null?void 0:c.saveData)===!0)return;function o(u){let d=u.tagName==="FORM"?u.getAttribute("action"):u.getAttribute("href");if(!d)return;let h=u.tagName==="A"?u.pathname:new URL(d,window.location.origin).pathname;Tv.has(h)||LO.add(h)}async function s(){document.querySelectorAll("a[data-discover], form[data-discover]").forEach(o);let u=Array.from(LO.keys()).filter(d=>Tv.has(d)?(LO.delete(d),!1):!0);if(u.length!==0)try{await Iq(u,null,e,t,r,i,n.basename,n.patchRoutes)}catch(d){console.error("Failed to fetch manifest patches",d)}}let a=Ste(s,100);s();let l=new MutationObserver(()=>a());return l.observe(document.documentElement,{subtree:!0,childList:!0,attributes:!0,attributeFilter:["data-discover","href","action"]}),()=>l.disconnect()},[r,i,e,t,n])}var dS="react-router-manifest-version";async function Iq(n,e,t,r,i,o,s,a,l){let c=`${s??"/"}/__manifest`.replace(/\/+/g,"/"),u=new URL(c,window.location.origin);if(n.sort().forEach(O=>u.searchParams.append("p",O)),u.searchParams.set("version",t.version),u.toString().length>vte){LO.clear();return}let d;try{let O=await fetch(u,{signal:l});if(O.ok){if(O.status===204&&O.headers.has("X-Remix-Reload-Document")){if(!e){console.warn("Detected a manifest version mismatch during eager route discovery. The next navigation/fetch to an undiscovered route will result in a new document navigation to sync up with the latest manifest.");return}if(sessionStorage.getItem(dS)===t.version){console.error("Unable to discover routes due to manifest version mismatch.");return}throw sessionStorage.setItem(dS,t.version),window.location.href=e,new Error("Detected manifest version mismatch, reloading...")}else if(O.status>=400)throw new Error(await O.text())}else throw new Error(`${O.status} ${O.statusText}`);sessionStorage.removeItem(dS),d=await O.json()}catch(O){if(l!=null&&l.aborted)return;throw O}let h=new Set(Object.keys(t.routes)),p=Object.values(d).reduce((O,v)=>(v&&!h.has(v.id)&&(O[v.id]=v),O),{});Object.assign(t.routes,p),n.forEach(O=>bte(O,Tv));let g=new Set;Object.values(p).forEach(O=>{O&&(!O.parentId||!p[O.parentId])&&g.add(O.parentId)}),g.forEach(O=>a(O||null,wp(p,r,null,i,o,O)))}function bte(n,e){if(e.size>=Ote){let t=e.values().next().value;e.delete(t)}e.add(n)}function Ste(n,e){let t;return(...r)=>{window.clearTimeout(t),t=window.setTimeout(()=>n(...r),e)}}function qx(){let n=D.useContext(Wa);return Zi(n,"You must render this element inside a <DataRouterContext.Provider> element"),n}function Py(){let n=D.useContext(lc);return Zi(n,"You must render this element inside a <DataRouterStateContext.Provider> element"),n}var dc=D.createContext(void 0);dc.displayName="FrameworkContext";function Jf(){let n=D.useContext(dc);return Zi(n,"You must render this element inside a <HydratedRouter> element"),n}function wte(n,e){let t=D.useContext(dc),[r,i]=D.useState(!1),[o,s]=D.useState(!1),{onFocus:a,onBlur:l,onMouseEnter:c,onMouseLeave:u,onTouchStart:d}=e,h=D.useRef(null);D.useEffect(()=>{if(n==="render"&&s(!0),n==="viewport"){let O=b=>{b.forEach(S=>{s(S.isIntersecting)})},v=new IntersectionObserver(O,{threshold:.5});return h.current&&v.observe(h.current),()=>{v.disconnect()}}},[n]),D.useEffect(()=>{if(r){let O=setTimeout(()=>{s(!0)},100);return()=>{clearTimeout(O)}}},[r]);let p=()=>{i(!0)},g=()=>{i(!1),s(!1)};return t?n!=="intent"?[o,h,{}]:[o,h,{onFocus:Fd(a,p),onBlur:Fd(l,g),onMouseEnter:Fd(c,p),onMouseLeave:Fd(u,g),onTouchStart:Fd(d,p)}]:[!1,h,{}]}function Fd(n,e){return t=>{n&&n(t),t.defaultPrevented||e(t)}}function Ux(n,e,t){if(t&&!NO)return[n[0]];if(e){let r=n.findIndex(i=>e[i.route.id]!==void 0);return n.slice(0,r+1)}return n}function kte(){let{isSpaMode:n,manifest:e,routeModules:t,criticalCss:r}=Jf(),{errors:i,matches:o}=Py(),s=Ux(o,i,n),a=D.useMemo(()=>ete(s,t,e),[s,t,e]);return D.createElement(D.Fragment,null,typeof r=="string"?D.createElement("style",{dangerouslySetInnerHTML:{__html:r}}):null,typeof r=="object"?D.createElement("link",{rel:"stylesheet",href:r.href}):null,a.map(({key:l,link:c})=>Mx(c)?D.createElement(Bx,{key:l,...c}):D.createElement("link",{key:l,...c})))}function Bx({page:n,...e}){let{router:t}=qx(),r=D.useMemo(()=>ho(t.routes,n,t.basename),[t.routes,n,t.basename]);return r?D.createElement(xte,{page:n,matches:r,...e}):null}function Pte(n){let{manifest:e,routeModules:t}=Jf(),[r,i]=D.useState([]);return D.useEffect(()=>{let o=!1;return rte(n,e,t).then(s=>{o||i(s)}),()=>{o=!0}},[n,e,t]),r}function xte({page:n,matches:e,...t}){let r=bo(),{manifest:i,routeModules:o}=Jf(),{basename:s}=qx(),{loaderData:a,matches:l}=Py(),c=D.useMemo(()=>XM(n,e,l,i,r,"data"),[n,e,l,i,r]),u=D.useMemo(()=>XM(n,e,l,i,r,"assets"),[n,e,l,i,r]),d=D.useMemo(()=>{if(n===r.pathname+r.search+r.hash)return[];let g=new Set,O=!1;if(e.forEach(b=>{var x;let S=i.routes[b.route.id];!S||!S.hasLoader||(!c.some(P=>P.route.id===b.route.id)&&b.route.id in a&&((x=o[b.route.id])!=null&&x.shouldRevalidate)||S.hasClientLoader?O=!0:g.add(b.route.id))}),g.size===0)return[];let v=Sp(n,s);return O&&g.size>0&&v.searchParams.set("_routes",e.filter(b=>g.has(b.route.id)).map(b=>b.route.id).join(",")),[v.pathname+v.search]},[s,a,r,i,c,e,n,o]),h=D.useMemo(()=>$x(u,i),[u,i]),p=Pte(u);return D.createElement(D.Fragment,null,d.map(g=>D.createElement("link",{key:g,rel:"prefetch",as:"fetch",href:g,...t})),h.map(g=>D.createElement("link",{key:g,rel:"modulepreload",href:g,...t})),p.map(({key:g,link:O})=>D.createElement("link",{key:g,...O})))}function Cte(){let{isSpaMode:n,routeModules:e}=Jf(),{errors:t,matches:r,loaderData:i}=Py(),o=bo(),s=Ux(r,t,n),a=null;t&&(a=t[s[s.length-1].route.id]);let l=[],c=null,u=[];for(let d=0;d<s.length;d++){let h=s[d],p=h.route.id,g=i[p],O=h.params,v=e[p],b=[],S={id:p,data:g,meta:[],params:h.params,pathname:h.pathname,handle:h.route.handle,error:a};if(u[d]=S,v!=null&&v.meta?b=typeof v.meta=="function"?v.meta({data:g,params:O,location:o,matches:u,error:a}):Array.isArray(v.meta)?[...v.meta]:v.meta:c&&(b=[...c]),b=b||[],!Array.isArray(b))throw new Error("The route at "+h.route.path+` returns an invalid value. All route meta functions must return an array of meta objects.
|
|
159
|
+
`}}))}function Lx(n){let e={};return Object.values(n).forEach(t=>{if(t){let r=t.parentId||"";e[r]||(e[r]=[]),e[r].push(t)}}),e}function Aq(n,e,t){let r=Dq(e),i=e.HydrateFallback&&(!t||n.id==="root")?e.HydrateFallback:n.id==="root"?gte:void 0,o=e.ErrorBoundary?e.ErrorBoundary:n.id==="root"?()=>D.createElement(Rq,{error:Ax()}):void 0;return n.id==="root"&&e.Layout?{...r?{element:D.createElement(e.Layout,null,D.createElement(r,null))}:{Component:r},...o?{errorElement:D.createElement(e.Layout,null,D.createElement(o,null))}:{ErrorBoundary:o},...i?{hydrateFallbackElement:D.createElement(e.Layout,null,D.createElement(i,null))}:{HydrateFallback:i}}:{Component:r,ErrorBoundary:o,HydrateFallback:i}}function Mq(n,e,t,r,i="",o=Lx(n),s=Promise.resolve({Component:()=>null})){return(o[i]||[]).map(a=>{let l=e[a.id];Zi(l,"No `routeModule` available to create server routes");let c={...Aq(a,l,r),caseSensitive:a.caseSensitive,id:a.id,index:a.index,path:a.path,handle:l.handle,lazy:r?()=>s:void 0,loader:a.hasLoader||a.hasClientLoader?()=>null:void 0},u=Mq(n,e,t,r,a.id,o,s);return u.length>0&&(c.children=u),c})}function $q(n,e,t,r,i,o){return wp(e,t,r,i,o,"",Lx(e),n)}function Uu(n,e){if(n==="loader"&&!e.hasLoader||n==="action"&&!e.hasAction){let r=`You are trying to call ${n==="action"?"serverAction()":"serverLoader()"} on a route that does not have a server ${n} (routeId: "${e.id}")`;throw console.error(r),new Qo(400,"Bad Request",new Error(r),!0)}}function fS(n,e){let t=n==="clientAction"?"a":"an",r=`Route "${e}" does not have ${t} ${n}, but you are trying to submit to it. To fix this, please add ${t} \`${n}\` function to the route`;throw console.error(r),new Qo(405,"Method Not Allowed",new Error(r),!0)}function wp(n,e,t,r,i,o="",s=Lx(n),a){return(s[o]||[]).map(l=>{var S,x,P;let c=e[l.id];function u(w){return Zi(typeof w=="function","No single fetch function available for route handler"),w()}function d(w){return l.hasLoader?u(w):Promise.resolve(null)}function h(w){if(!l.hasAction)throw fS("action",l.id);return u(w)}function p(w){import(w)}function g(w){w.clientActionModule&&p(w.clientActionModule),w.clientLoaderModule&&p(w.clientLoaderModule)}async function O(w){let E=e[l.id],M=E?Pq(l,E):Promise.resolve();try{return w()}finally{await M}}let v={id:l.id,index:l.index,path:l.path};if(c){Object.assign(v,{...v,...Aq(l,c,i),unstable_middleware:c.unstable_clientMiddleware,handle:c.handle,shouldRevalidate:KM(c,l,r,a)});let w=t&&t.loaderData&&l.id in t.loaderData,E=w?(S=t==null?void 0:t.loaderData)==null?void 0:S[l.id]:void 0,M=t&&t.errors&&l.id in t.errors,Q=M?(x=t==null?void 0:t.errors)==null?void 0:x[l.id]:void 0,T=a==null&&(((P=c.clientLoader)==null?void 0:P.hydrate)===!0||!l.hasLoader);v.loader=async({request:R,params:$,context:I},B)=>{try{return await O(async()=>(Zi(c,"No `routeModule` available for critical-route loader"),c.clientLoader?c.clientLoader({request:R,params:$,context:I,async serverLoader(){if(Uu("loader",l),T){if(w)return E;if(M)throw Q}return d(B)}}):d(B)))}finally{T=!1}},v.loader.hydrate=ky(l,c,i),v.action=({request:R,params:$,context:I},B)=>O(async()=>{if(Zi(c,"No `routeModule` available for critical-route action"),!c.clientAction){if(i)throw fS("clientAction",l.id);return h(B)}return c.clientAction({request:R,params:$,context:I,async serverAction(){return Uu("action",l),h(B)}})})}else l.hasClientLoader?l.clientLoaderModule&&(v.loader=async(w,E)=>{Zi(l.clientLoaderModule);let{clientLoader:M}=await import(l.clientLoaderModule);return M({...w,async serverLoader(){return Uu("loader",l),d(E)}})}):v.loader=(w,E)=>O(()=>d(E)),l.hasClientAction?l.clientActionModule&&(v.action=async(w,E)=>{Zi(l.clientActionModule),g(l);let{clientAction:M}=await import(l.clientActionModule);return M({...w,async serverAction(){return Uu("action",l),h(E)}})}):v.action=(w,E)=>O(()=>{if(i)throw fS("clientAction",l.id);return h(E)}),l.hasClientMiddleware&&(v.unstable_lazyMiddleware=async()=>{Zi(l);let w=await import(l.clientMiddlewareModule||l.module);return Zi(w==null?void 0:w.unstable_clientMiddleware,"No `unstable_clientMiddleware` export in chunk"),w.unstable_clientMiddleware}),v.lazy=async()=>{(l.clientLoaderModule||l.clientActionModule)&&await new Promise(Q=>setTimeout(Q,0));let w=vte(l,e);g(l);let E=await w,M={...E};if(E.clientLoader){let Q=E.clientLoader;M.loader=(T,R)=>Q({...T,async serverLoader(){return Uu("loader",l),d(R)}})}if(E.clientAction){let Q=E.clientAction;M.action=(T,R)=>Q({...T,async serverAction(){return Uu("action",l),h(R)}})}return{...M.loader?{loader:M.loader}:{},...M.action?{action:M.action}:{},hasErrorBoundary:M.hasErrorBoundary,shouldRevalidate:KM(M,l,r,a),handle:M.handle,Component:M.Component,ErrorBoundary:M.ErrorBoundary}};let b=wp(n,e,t,r,i,l.id,s,a);return b.length>0&&(v.children=b),v})}function KM(n,e,t,r){if(r)return Ote(e.id,n.shouldRevalidate,r);if(!t&&e.hasLoader&&!e.hasClientLoader)if(n.shouldRevalidate){let i=n.shouldRevalidate;return o=>i({...o,defaultShouldRevalidate:!1})}else return()=>!1;if(t&&n.shouldRevalidate){let i=n.shouldRevalidate;return o=>i({...o,defaultShouldRevalidate:!0})}return n.shouldRevalidate}function Ote(n,e,t){let r=!1;return i=>r?e?e(i):i.defaultShouldRevalidate:(r=!0,t.has(n))}async function vte(n,e){let t=wq(n,e),r=rte(n),i=await t;return await Promise.all([r,Pq(n,i)]),{Component:Dq(i),ErrorBoundary:i.ErrorBoundary,unstable_clientMiddleware:i.unstable_clientMiddleware,clientAction:i.clientAction,clientLoader:i.clientLoader,handle:i.handle,links:i.links,meta:i.meta,shouldRevalidate:i.shouldRevalidate}}function Dq(n){if(n.default==null)return;if(!(typeof n.default=="object"&&Object.keys(n.default).length===0))return n.default}function ky(n,e,t){return t&&n.id!=="root"||e.clientLoader!=null&&(e.clientLoader.hydrate===!0||n.hasLoader!==!0)}var LO=new Set,yte=1e3,Tv=new Set,bte=7680;function Nx(n){return n===!0}function Ste(n,e){let t=new Set(e.state.matches.map(s=>s.route.id)),r=e.state.location.pathname.split("/").filter(Boolean),i=["/"];for(r.pop();r.length>0;)i.push(`/${r.join("/")}`),r.pop();i.forEach(s=>{let a=ho(e.routes,s,e.basename);a&&a.forEach(l=>t.add(l.route.id))});let o=[...t].reduce((s,a)=>Object.assign(s,{[a]:n.routes[a]}),{});return{...n,routes:o}}function Qq(n,e,t,r,i){if(Nx(t))return async({path:o,patch:s,signal:a,fetcherKey:l})=>{Tv.has(o)||await jq([o],l?window.location.href:o,n,e,t,r,i,s,a)}}function Iq(n,e,t,r,i){D.useEffect(()=>{var c;if(!Nx(r)||((c=navigator.connection)==null?void 0:c.saveData)===!0)return;function o(u){let d=u.tagName==="FORM"?u.getAttribute("action"):u.getAttribute("href");if(!d)return;let h=u.tagName==="A"?u.pathname:new URL(d,window.location.origin).pathname;Tv.has(h)||LO.add(h)}async function s(){document.querySelectorAll("a[data-discover], form[data-discover]").forEach(o);let u=Array.from(LO.keys()).filter(d=>Tv.has(d)?(LO.delete(d),!1):!0);if(u.length!==0)try{await jq(u,null,e,t,r,i,n.basename,n.patchRoutes)}catch(d){console.error("Failed to fetch manifest patches",d)}}let a=kte(s,100);s();let l=new MutationObserver(()=>a());return l.observe(document.documentElement,{subtree:!0,childList:!0,attributes:!0,attributeFilter:["data-discover","href","action"]}),()=>l.disconnect()},[r,i,e,t,n])}var dS="react-router-manifest-version";async function jq(n,e,t,r,i,o,s,a,l){let c=`${s??"/"}/__manifest`.replace(/\/+/g,"/"),u=new URL(c,window.location.origin);if(n.sort().forEach(O=>u.searchParams.append("p",O)),u.searchParams.set("version",t.version),u.toString().length>bte){LO.clear();return}let d;try{let O=await fetch(u,{signal:l});if(O.ok){if(O.status===204&&O.headers.has("X-Remix-Reload-Document")){if(!e){console.warn("Detected a manifest version mismatch during eager route discovery. The next navigation/fetch to an undiscovered route will result in a new document navigation to sync up with the latest manifest.");return}if(sessionStorage.getItem(dS)===t.version){console.error("Unable to discover routes due to manifest version mismatch.");return}throw sessionStorage.setItem(dS,t.version),window.location.href=e,new Error("Detected manifest version mismatch, reloading...")}else if(O.status>=400)throw new Error(await O.text())}else throw new Error(`${O.status} ${O.statusText}`);sessionStorage.removeItem(dS),d=await O.json()}catch(O){if(l!=null&&l.aborted)return;throw O}let h=new Set(Object.keys(t.routes)),p=Object.values(d).reduce((O,v)=>(v&&!h.has(v.id)&&(O[v.id]=v),O),{});Object.assign(t.routes,p),n.forEach(O=>wte(O,Tv));let g=new Set;Object.values(p).forEach(O=>{O&&(!O.parentId||!p[O.parentId])&&g.add(O.parentId)}),g.forEach(O=>a(O||null,wp(p,r,null,i,o,O)))}function wte(n,e){if(e.size>=yte){let t=e.values().next().value;e.delete(t)}e.add(n)}function kte(n,e){let t;return(...r)=>{window.clearTimeout(t),t=window.setTimeout(()=>n(...r),e)}}function qx(){let n=D.useContext(Wa);return Zi(n,"You must render this element inside a <DataRouterContext.Provider> element"),n}function Py(){let n=D.useContext(lc);return Zi(n,"You must render this element inside a <DataRouterStateContext.Provider> element"),n}var dc=D.createContext(void 0);dc.displayName="FrameworkContext";function Jf(){let n=D.useContext(dc);return Zi(n,"You must render this element inside a <HydratedRouter> element"),n}function Pte(n,e){let t=D.useContext(dc),[r,i]=D.useState(!1),[o,s]=D.useState(!1),{onFocus:a,onBlur:l,onMouseEnter:c,onMouseLeave:u,onTouchStart:d}=e,h=D.useRef(null);D.useEffect(()=>{if(n==="render"&&s(!0),n==="viewport"){let O=b=>{b.forEach(S=>{s(S.isIntersecting)})},v=new IntersectionObserver(O,{threshold:.5});return h.current&&v.observe(h.current),()=>{v.disconnect()}}},[n]),D.useEffect(()=>{if(r){let O=setTimeout(()=>{s(!0)},100);return()=>{clearTimeout(O)}}},[r]);let p=()=>{i(!0)},g=()=>{i(!1),s(!1)};return t?n!=="intent"?[o,h,{}]:[o,h,{onFocus:Fd(a,p),onBlur:Fd(l,g),onMouseEnter:Fd(c,p),onMouseLeave:Fd(u,g),onTouchStart:Fd(d,p)}]:[!1,h,{}]}function Fd(n,e){return t=>{n&&n(t),t.defaultPrevented||e(t)}}function Ux(n,e,t){if(t&&!NO)return[n[0]];if(e){let r=n.findIndex(i=>e[i.route.id]!==void 0);return n.slice(0,r+1)}return n}function xte(){let{isSpaMode:n,manifest:e,routeModules:t,criticalCss:r}=Jf(),{errors:i,matches:o}=Py(),s=Ux(o,i,n),a=D.useMemo(()=>nte(s,t,e),[s,t,e]);return D.createElement(D.Fragment,null,typeof r=="string"?D.createElement("style",{dangerouslySetInnerHTML:{__html:r}}):null,typeof r=="object"?D.createElement("link",{rel:"stylesheet",href:r.href}):null,a.map(({key:l,link:c})=>Mx(c)?D.createElement(Bx,{key:l,...c}):D.createElement("link",{key:l,...c})))}function Bx({page:n,...e}){let{router:t}=qx(),r=D.useMemo(()=>ho(t.routes,n,t.basename),[t.routes,n,t.basename]);return r?D.createElement(Tte,{page:n,matches:r,...e}):null}function Cte(n){let{manifest:e,routeModules:t}=Jf(),[r,i]=D.useState([]);return D.useEffect(()=>{let o=!1;return ote(n,e,t).then(s=>{o||i(s)}),()=>{o=!0}},[n,e,t]),r}function Tte({page:n,matches:e,...t}){let r=bo(),{manifest:i,routeModules:o}=Jf(),{basename:s}=qx(),{loaderData:a,matches:l}=Py(),c=D.useMemo(()=>YM(n,e,l,i,r,"data"),[n,e,l,i,r]),u=D.useMemo(()=>YM(n,e,l,i,r,"assets"),[n,e,l,i,r]),d=D.useMemo(()=>{if(n===r.pathname+r.search+r.hash)return[];let g=new Set,O=!1;if(e.forEach(b=>{var x;let S=i.routes[b.route.id];!S||!S.hasLoader||(!c.some(P=>P.route.id===b.route.id)&&b.route.id in a&&((x=o[b.route.id])!=null&&x.shouldRevalidate)||S.hasClientLoader?O=!0:g.add(b.route.id))}),g.size===0)return[];let v=Sp(n,s);return O&&g.size>0&&v.searchParams.set("_routes",e.filter(b=>g.has(b.route.id)).map(b=>b.route.id).join(",")),[v.pathname+v.search]},[s,a,r,i,c,e,n,o]),h=D.useMemo(()=>$x(u,i),[u,i]),p=Cte(u);return D.createElement(D.Fragment,null,d.map(g=>D.createElement("link",{key:g,rel:"prefetch",as:"fetch",href:g,...t})),h.map(g=>D.createElement("link",{key:g,rel:"modulepreload",href:g,...t})),p.map(({key:g,link:O})=>D.createElement("link",{key:g,...O})))}function _te(){let{isSpaMode:n,routeModules:e}=Jf(),{errors:t,matches:r,loaderData:i}=Py(),o=bo(),s=Ux(r,t,n),a=null;t&&(a=t[s[s.length-1].route.id]);let l=[],c=null,u=[];for(let d=0;d<s.length;d++){let h=s[d],p=h.route.id,g=i[p],O=h.params,v=e[p],b=[],S={id:p,data:g,meta:[],params:h.params,pathname:h.pathname,handle:h.route.handle,error:a};if(u[d]=S,v!=null&&v.meta?b=typeof v.meta=="function"?v.meta({data:g,params:O,location:o,matches:u,error:a}):Array.isArray(v.meta)?[...v.meta]:v.meta:c&&(b=[...c]),b=b||[],!Array.isArray(b))throw new Error("The route at "+h.route.path+` returns an invalid value. All route meta functions must return an array of meta objects.
|
|
160
160
|
|
|
161
|
-
To reference the meta function API, see https://remix.run/route/meta`);S.meta=b,u[d]=S,l=[...b],c=l}return D.createElement(D.Fragment,null,l.flat().map(d=>{if(!d)return null;if("tagName"in d){let{tagName:h,...p}=d;if(!
|
|
161
|
+
To reference the meta function API, see https://remix.run/route/meta`);S.meta=b,u[d]=S,l=[...b],c=l}return D.createElement(D.Fragment,null,l.flat().map(d=>{if(!d)return null;if("tagName"in d){let{tagName:h,...p}=d;if(!Ete(h))return console.warn(`A meta object uses an invalid tagName: ${h}. Expected either 'link' or 'meta'`),null;let g=h;return D.createElement(g,{key:JSON.stringify(p),...p})}if("title"in d)return D.createElement("title",{key:"title"},String(d.title));if("charset"in d&&(d.charSet??(d.charSet=d.charset),delete d.charset),"charSet"in d&&d.charSet!=null)return typeof d.charSet=="string"?D.createElement("meta",{key:"charSet",charSet:d.charSet}):null;if("script:ld+json"in d)try{let h=JSON.stringify(d["script:ld+json"]);return D.createElement("script",{key:`script:ld+json:${h}`,type:"application/ld+json",dangerouslySetInnerHTML:{__html:h}})}catch{return null}return D.createElement("meta",{key:JSON.stringify(d),...d})}))}function Ete(n){return typeof n=="string"&&/^(meta|link)$/.test(n)}var NO=!1;function Lq(n){let{manifest:e,serverHandoffString:t,isSpaMode:r,ssr:i,renderMeta:o}=Jf(),{router:s,static:a,staticContext:l}=qx(),{matches:c}=Py(),u=Nx(i);o&&(o.didRenderScripts=!0);let d=Ux(c,null,r);D.useEffect(()=>{NO=!0},[]);let h=D.useMemo(()=>{var b;let O=l?`window.__reactRouterContext = ${t};window.__reactRouterContext.stream = new ReadableStream({start(controller){window.__reactRouterContext.streamController = controller;}}).pipeThrough(new TextEncoderStream());`:" ",v=a?`${(b=e.hmr)!=null&&b.runtime?`import ${JSON.stringify(e.hmr.runtime)};`:""}${u?"":`import ${JSON.stringify(e.url)}`};
|
|
162
162
|
${d.map((S,x)=>{let P=`route${x}`,w=e.routes[S.route.id];Zi(w,`Route ${S.route.id} not found in manifest`);let{clientActionModule:E,clientLoaderModule:M,clientMiddlewareModule:Q,hydrateFallbackModule:T,module:R}=w,$=[...E?[{module:E,varName:`${P}_clientAction`}]:[],...M?[{module:M,varName:`${P}_clientLoader`}]:[],...Q?[{module:Q,varName:`${P}_clientMiddleware`}]:[],...T?[{module:T,varName:`${P}_HydrateFallback`}]:[],{module:R,varName:`${P}_main`}];if($.length===1)return`import * as ${P} from ${JSON.stringify(R)};`;let I=$.map(H=>`import * as ${H.varName} from "${H.module}";`).join(`
|
|
163
163
|
`),B=`const ${P} = {${$.map(H=>`...${H.varName}`).join(",")}};`;return[I,B].join(`
|
|
164
164
|
`)}).join(`
|
|
165
165
|
`)}
|
|
166
|
-
${u?`window.__reactRouterManifest = ${JSON.stringify(
|
|
166
|
+
${u?`window.__reactRouterManifest = ${JSON.stringify(Ste(e,s),null,2)};`:""}
|
|
167
167
|
window.__reactRouterRouteModules = {${d.map((S,x)=>`${JSON.stringify(S.route.id)}:route${x}`).join(",")}};
|
|
168
168
|
|
|
169
|
-
import(${JSON.stringify(e.entry.module)});`:" ";return D.createElement(D.Fragment,null,D.createElement("script",{...n,suppressHydrationWarning:!0,dangerouslySetInnerHTML:zM(O),type:void 0}),D.createElement("script",{...n,suppressHydrationWarning:!0,dangerouslySetInnerHTML:zM(v),type:"module",async:!0}))},[]),p=NO?[]:e.entry.imports.concat($x(d,e,{includeHydrateFallback:!0}));return NO?null:D.createElement(D.Fragment,null,u?null:D.createElement("link",{rel:"modulepreload",href:e.url,crossOrigin:n.crossOrigin}),D.createElement("link",{rel:"modulepreload",href:e.entry.module,crossOrigin:n.crossOrigin}),_te(p).map(g=>D.createElement("link",{key:g,rel:"modulepreload",href:g,crossOrigin:n.crossOrigin})),h)}function _te(n){return[...new Set(n)]}function Ete(...n){return e=>{n.forEach(t=>{typeof t=="function"?t(e):t!=null&&(t.current=e)})}}var Lq=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{Lq&&(window.__reactRouterVersion="7.4.1")}catch{}function Rte(n,e){return Op({basename:e==null?void 0:e.basename,unstable_getContext:e==null?void 0:e.unstable_getContext,future:e==null?void 0:e.future,history:dy({window:e==null?void 0:e.window}),hydrationData:(e==null?void 0:e.hydrationData)||Nq(),routes:n,mapRouteProperties:fu,dataStrategy:e==null?void 0:e.dataStrategy,patchRoutesOnNavigation:e==null?void 0:e.patchRoutesOnNavigation,window:e==null?void 0:e.window}).initialize()}function Ate(n,e){return Op({basename:e==null?void 0:e.basename,unstable_getContext:e==null?void 0:e.unstable_getContext,future:e==null?void 0:e.future,history:I3({window:e==null?void 0:e.window}),hydrationData:(e==null?void 0:e.hydrationData)||Nq(),routes:n,mapRouteProperties:fu,dataStrategy:e==null?void 0:e.dataStrategy,patchRoutesOnNavigation:e==null?void 0:e.patchRoutesOnNavigation,window:e==null?void 0:e.window}).initialize()}function Nq(){let n=window==null?void 0:window.__staticRouterHydrationData;return n&&n.errors&&(n={...n,errors:Mte(n.errors)}),n}function Mte(n){if(!n)return null;let e=Object.entries(n),t={};for(let[r,i]of e)if(i&&i.__type==="RouteErrorResponse")t[r]=new Qo(i.status,i.statusText,i.data,i.internal===!0);else if(i&&i.__type==="Error"){if(i.__subType){let o=window[i.__subType];if(typeof o=="function")try{let s=new o(i.message);s.stack="",t[r]=s}catch{}}if(t[r]==null){let o=new Error(i.message);o.stack="",t[r]=o}}else t[r]=i;return t}function qq({basename:n,children:e,window:t}){let r=D.useRef();r.current==null&&(r.current=dy({window:t,v5Compat:!0}));let i=r.current,[o,s]=D.useState({action:i.action,location:i.location}),a=D.useCallback(l=>{D.startTransition(()=>s(l))},[s]);return D.useLayoutEffect(()=>i.listen(a),[i,a]),D.createElement(fc,{basename:n,children:e,location:o.location,navigationType:o.action,navigator:i})}function $te({basename:n,children:e,window:t}){let r=D.useRef();r.current==null&&(r.current=I3({window:t,v5Compat:!0}));let i=r.current,[o,s]=D.useState({action:i.action,location:i.location}),a=D.useCallback(l=>{D.startTransition(()=>s(l))},[s]);return D.useLayoutEffect(()=>i.listen(a),[i,a]),D.createElement(fc,{basename:n,children:e,location:o.location,navigationType:o.action,navigator:i})}function Uq({basename:n,children:e,history:t}){let[r,i]=D.useState({action:t.action,location:t.location}),o=D.useCallback(s=>{D.startTransition(()=>i(s))},[i]);return D.useLayoutEffect(()=>t.listen(o),[t,o]),D.createElement(fc,{basename:n,children:e,location:r.location,navigationType:r.action,navigator:t})}Uq.displayName="unstable_HistoryRouter";var Bq=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Fx=D.forwardRef(function({onClick:e,discover:t="render",prefetch:r="none",relative:i,reloadDocument:o,replace:s,state:a,target:l,to:c,preventScrollReset:u,viewTransition:d,...h},p){let{basename:g}=D.useContext(vo),O=typeof c=="string"&&Bq.test(c),v,b=!1;if(typeof c=="string"&&O&&(v=c,Lq))try{let T=new URL(window.location.href),R=c.startsWith("//")?new URL(T.protocol+c):new URL(c),$=vi(R.pathname,g);R.origin===T.origin&&$!=null?c=$+R.search+R.hash:b=!0}catch{yr(!1,`<Link to="${c}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}let S=sq(c,{relative:i}),[x,P,w]=wte(r,h),E=Zq(c,{replace:s,state:a,target:l,preventScrollReset:u,relative:i,viewTransition:d});function M(T){e&&e(T),T.defaultPrevented||E(T)}let Q=D.createElement("a",{...h,...w,href:v||S,onClick:b||o?e:M,ref:Ete(p,P),target:l,"data-discover":!O&&t==="render"?"true":void 0});return x&&!O?D.createElement(D.Fragment,null,Q,D.createElement(Bx,{page:S})):Q});Fx.displayName="Link";var Fq=D.forwardRef(function({"aria-current":e="page",caseSensitive:t=!1,className:r="",end:i=!1,style:o,to:s,viewTransition:a,children:l,...c},u){let d=Kf(s,{relative:c.relative}),h=bo(),p=D.useContext(lc),{navigator:g,basename:O}=D.useContext(vo),v=p!=null&&Yq(d)&&a===!0,b=g.encodeLocation?g.encodeLocation(d).pathname:d.pathname,S=h.pathname,x=p&&p.navigation&&p.navigation.location?p.navigation.location.pathname:null;t||(S=S.toLowerCase(),x=x?x.toLowerCase():null,b=b.toLowerCase()),x&&O&&(x=vi(x,O)||x);const P=b!=="/"&&b.endsWith("/")?b.length-1:b.length;let w=S===b||!i&&S.startsWith(b)&&S.charAt(P)==="/",E=x!=null&&(x===b||!i&&x.startsWith(b)&&x.charAt(b.length)==="/"),M={isActive:w,isPending:E,isTransitioning:v},Q=w?e:void 0,T;typeof r=="function"?T=r(M):T=[r,w?"active":null,E?"pending":null,v?"transitioning":null].filter(Boolean).join(" ");let R=typeof o=="function"?o(M):o;return D.createElement(Fx,{...c,"aria-current":Q,className:T,ref:u,style:R,to:s,viewTransition:a},typeof l=="function"?l(M):l)});Fq.displayName="NavLink";var Vx=D.forwardRef(({discover:n="render",fetcherKey:e,navigate:t,reloadDocument:r,replace:i,state:o,method:s=IO,action:a,onSubmit:l,relative:c,preventScrollReset:u,viewTransition:d,...h},p)=>{let g=Zx(),O=Xq(a,{relative:c}),v=s.toLowerCase()==="get"?"get":"post",b=typeof a=="string"&&Bq.test(a),S=x=>{if(l&&l(x),x.defaultPrevented)return;x.preventDefault();let P=x.nativeEvent.submitter,w=(P==null?void 0:P.getAttribute("formmethod"))||s;g(P||x.currentTarget,{fetcherKey:e,method:w,navigate:t,replace:i,state:o,relative:c,preventScrollReset:u,viewTransition:d})};return D.createElement("form",{ref:p,method:v,action:O,onSubmit:r?l:S,...h,"data-discover":!b&&n==="render"?"true":void 0})});Vx.displayName="Form";function Vq({getKey:n,storageKey:e,...t}){let r=D.useContext(dc),{basename:i}=D.useContext(vo),o=bo(),s=Rx();zq({getKey:n,storageKey:e});let a=D.useMemo(()=>{if(!r||!n)return null;let c=Wk(o,s,i,n);return c!==o.key?c:null},[]);if(!r||r.isSpaMode)return null;let l=((c,u)=>{if(!window.history.state||!window.history.state.key){let d=Math.random().toString(32).slice(2);window.history.replaceState({key:d},"")}try{let h=JSON.parse(sessionStorage.getItem(c)||"{}")[u||window.history.state.key];typeof h=="number"&&window.scrollTo(0,h)}catch(d){console.error(d),sessionStorage.removeItem(c)}}).toString();return D.createElement("script",{...t,suppressHydrationWarning:!0,dangerouslySetInnerHTML:{__html:`(${l})(${JSON.stringify(e||Vk)}, ${JSON.stringify(a)})`}})}Vq.displayName="ScrollRestoration";function Wq(n){return`${n} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function xy(n){let e=D.useContext(Wa);return zt(e,Wq(n)),e}function Wx(n){let e=D.useContext(lc);return zt(e,Wq(n)),e}function Zq(n,{target:e,replace:t,state:r,preventScrollReset:i,relative:o,viewTransition:s}={}){let a=yy(),l=bo(),c=Kf(n,{relative:o});return D.useCallback(u=>{if(Yee(u,e)){u.preventDefault();let d=t!==void 0?t:Yi(l)===Yi(c);a(n,{replace:d,state:r,preventScrollReset:i,relative:o,viewTransition:s})}},[l,a,c,t,r,e,n,i,o,s])}function Dte(n){yr(typeof URLSearchParams<"u","You cannot use the `useSearchParams` hook in a browser that does not support the URLSearchParams API. If you need to support Internet Explorer 11, we recommend you load a polyfill such as https://github.com/ungap/url-search-params.");let e=D.useRef(Cv(n)),t=D.useRef(!1),r=bo(),i=D.useMemo(()=>Gee(r.search,t.current?null:e.current),[r.search]),o=yy(),s=D.useCallback((a,l)=>{const c=Cv(typeof a=="function"?a(i):a);t.current=!0,o("?"+c,l)},[o,i]);return[i,s]}var Qte=0,Ite=()=>`__${String(++Qte)}__`;function Zx(){let{router:n}=xy("useSubmit"),{basename:e}=D.useContext(vo),t=Cee();return D.useCallback(async(r,i={})=>{let{action:o,method:s,encType:a,formData:l,body:c}=Jee(r,e);if(i.navigate===!1){let u=i.fetcherKey||Ite();await n.fetch(u,t,i.action||o,{preventScrollReset:i.preventScrollReset,formData:l,body:c,formMethod:i.method||s,formEncType:i.encType||a,flushSync:i.flushSync})}else await n.navigate(i.action||o,{preventScrollReset:i.preventScrollReset,formData:l,body:c,formMethod:i.method||s,formEncType:i.encType||a,replace:i.replace,state:i.state,fromRouteId:t,flushSync:i.flushSync,viewTransition:i.viewTransition})},[n,e,t])}function Xq(n,{relative:e}={}){let{basename:t}=D.useContext(vo),r=D.useContext(yo);zt(r,"useFormAction must be used inside a RouteContext");let[i]=r.matches.slice(-1),o={...Kf(n||".",{relative:e})},s=bo();if(n==null){o.search=s.search;let a=new URLSearchParams(o.search),l=a.getAll("index");if(l.some(u=>u==="")){a.delete("index"),l.filter(d=>d).forEach(d=>a.append("index",d));let u=a.toString();o.search=u?`?${u}`:""}}return(!n||n===".")&&i.route.index&&(o.search=o.search?o.search.replace(/^\?/,"?index&"):"?index"),t!=="/"&&(o.pathname=o.pathname==="/"?t:ca([t,o.pathname])),Yi(o)}function jte({key:n}={}){var v;let{router:e}=xy("useFetcher"),t=Wx("useFetcher"),r=D.useContext(yp),i=D.useContext(yo),o=(v=i.matches[i.matches.length-1])==null?void 0:v.route.id;zt(r,"useFetcher must be used inside a FetchersContext"),zt(i,"useFetcher must be used inside a RouteContext"),zt(o!=null,'useFetcher can only be used on routes that contain a unique "id"');let s=D.useId(),[a,l]=D.useState(n||s);n&&n!==a&&l(n),D.useEffect(()=>(e.getFetcher(a),()=>e.deleteFetcher(a)),[e,a]);let c=D.useCallback(async(b,S)=>{zt(o,"No routeId available for fetcher.load()"),await e.fetch(a,o,b,S)},[a,o,e]),u=Zx(),d=D.useCallback(async(b,S)=>{await u(b,{...S,navigate:!1,fetcherKey:a})},[a,u]),h=D.useMemo(()=>{let b=D.forwardRef((S,x)=>D.createElement(Vx,{...S,navigate:!1,fetcherKey:a,ref:x}));return b.displayName="fetcher.Form",b},[a]),p=t.fetchers.get(a)||gy,g=r.get(a);return D.useMemo(()=>({Form:h,submit:d,load:c,...p,data:g}),[h,d,c,p,g])}function Lte(){let n=Wx("useFetchers");return Array.from(n.fetchers.entries()).map(([e,t])=>({...t,key:e}))}var Vk="react-router-scroll-positions",Km={};function Wk(n,e,t,r){let i=null;return r&&(t!=="/"?i=r({...n,pathname:vi(n.pathname,t)||n.pathname},e):i=r(n,e)),i==null&&(i=n.key),i}function zq({getKey:n,storageKey:e}={}){let{router:t}=xy("useScrollRestoration"),{restoreScrollPosition:r,preventScrollReset:i}=Wx("useScrollRestoration"),{basename:o}=D.useContext(vo),s=bo(),a=Rx(),l=hq();D.useEffect(()=>(window.history.scrollRestoration="manual",()=>{window.history.scrollRestoration="auto"}),[]),qte(D.useCallback(()=>{if(l.state==="idle"){let c=Wk(s,a,o,n);Km[c]=window.scrollY}try{sessionStorage.setItem(e||Vk,JSON.stringify(Km))}catch(c){yr(!1,`Failed to save scroll positions in sessionStorage, <ScrollRestoration /> will not work properly (${c}).`)}window.history.scrollRestoration="auto"},[l.state,n,o,s,a,e])),typeof document<"u"&&(D.useLayoutEffect(()=>{try{let c=sessionStorage.getItem(e||Vk);c&&(Km=JSON.parse(c))}catch{}},[e]),D.useLayoutEffect(()=>{let c=t==null?void 0:t.enableScrollRestoration(Km,()=>window.scrollY,n?(u,d)=>Wk(u,d,o,n):void 0);return()=>c&&c()},[t,o,n]),D.useLayoutEffect(()=>{if(r!==!1){if(typeof r=="number"){window.scrollTo(0,r);return}if(s.hash){let c=document.getElementById(decodeURIComponent(s.hash.slice(1)));if(c){c.scrollIntoView();return}}i!==!0&&window.scrollTo(0,0)}},[s,r,i]))}function Nte(n,e){let{capture:t}=e||{};D.useEffect(()=>{let r=t!=null?{capture:t}:void 0;return window.addEventListener("beforeunload",n,r),()=>{window.removeEventListener("beforeunload",n,r)}},[n,t])}function qte(n,e){let{capture:t}={};D.useEffect(()=>{let r=t!=null?{capture:t}:void 0;return window.addEventListener("pagehide",n,r),()=>{window.removeEventListener("pagehide",n,r)}},[n,t])}function Ute({when:n,message:e}){let t=mq(n);D.useEffect(()=>{t.state==="blocked"&&(window.confirm(e)?setTimeout(t.proceed,0):t.reset())},[t,e]),D.useEffect(()=>{t.state==="blocked"&&!n&&t.reset()},[t,n])}function Yq(n,e={}){let t=D.useContext(vp);zt(t!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:r}=xy("useViewTransitionState"),i=Kf(n,{relative:e.relative});if(!t.isTransitioning)return!1;let o=vi(t.currentLocation.pathname,r)||t.currentLocation.pathname,s=vi(t.nextLocation.pathname,r)||t.nextLocation.pathname;return Uf(i.pathname,s)!=null||Uf(i.pathname,o)!=null}function Bte({basename:n,children:e,location:t="/"}){typeof t=="string"&&(t=jo(t));let r="POP",i={pathname:t.pathname||"/",search:t.search||"",hash:t.hash||"",state:t.state!=null?t.state:null,key:t.key||"default"},o=Hq();return D.createElement(fc,{basename:n,children:e,location:i,navigationType:r,navigator:o,static:!0})}function Gq({context:n,router:e,hydrate:t=!0,nonce:r}){zt(e&&n,"You must provide `router` and `context` to <StaticRouterProvider>");let i={router:e,navigator:Hq(),static:!0,staticContext:n,basename:n.basename||"/"},o=new Map,s="";if(t!==!1){let l={loaderData:n.loaderData,actionData:n.actionData,errors:Vte(n.errors)};s=`window.__staticRouterHydrationData = JSON.parse(${Yte(JSON.stringify(JSON.stringify(l)))});`}let{state:a}=i.router;return D.createElement(D.Fragment,null,D.createElement(Wa.Provider,{value:i},D.createElement(lc.Provider,{value:a},D.createElement(yp.Provider,{value:o},D.createElement(vp.Provider,{value:{isTransitioning:!1}},D.createElement(fc,{basename:i.basename,location:a.location,navigationType:a.historyAction,navigator:i.navigator,static:i.static},D.createElement(Fte,{routes:e.routes,future:e.future,state:a})))))),s?D.createElement("script",{suppressHydrationWarning:!0,nonce:r,dangerouslySetInnerHTML:{__html:s}}):null)}function Fte({routes:n,future:e,state:t}){return Tx(n,void 0,t,e)}function Vte(n){if(!n)return null;let e=Object.entries(n),t={};for(let[r,i]of e)si(i)?t[r]={...i,__type:"RouteErrorResponse"}:i instanceof Error?t[r]={message:i.message,__type:"Error",...i.name!=="Error"?{__subType:i.name}:{}}:t[r]=i;return t}function Hq(){return{createHref:Jq,encodeLocation:e4,push(n){throw new Error(`You cannot use navigator.push() on the server because it is a stateless environment. This error was probably triggered when you did a \`navigate(${JSON.stringify(n)})\` somewhere in your app.`)},replace(n){throw new Error(`You cannot use navigator.replace() on the server because it is a stateless environment. This error was probably triggered when you did a \`navigate(${JSON.stringify(n)}, { replace: true })\` somewhere in your app.`)},go(n){throw new Error(`You cannot use navigator.go() on the server because it is a stateless environment. This error was probably triggered when you did a \`navigate(${n})\` somewhere in your app.`)},back(){throw new Error("You cannot use navigator.back() on the server because it is a stateless environment.")},forward(){throw new Error("You cannot use navigator.forward() on the server because it is a stateless environment.")}}}function Wte(n,e){return G3(n,{...e,mapRouteProperties:fu})}function Kq(n,e,t={}){let r={},i=ou(n,fu,void 0,r),o=e.matches.map(a=>{let l=r[a.route.id]||a.route;return{...a,route:l}}),s=a=>`You cannot use router.${a}() on the server because it is a stateless environment`;return{get basename(){return e.basename},get future(){return{unstable_middleware:!1,...t==null?void 0:t.future}},get state(){return{historyAction:"POP",location:e.location,matches:o,loaderData:e.loaderData,actionData:e.actionData,errors:e.errors,initialized:!0,navigation:kh,restoreScrollPosition:null,preventScrollReset:!1,revalidation:"idle",fetchers:new Map,blockers:new Map}},get routes(){return i},get window(){},initialize(){throw s("initialize")},subscribe(){throw s("subscribe")},enableScrollRestoration(){throw s("enableScrollRestoration")},navigate(){throw s("navigate")},fetch(){throw s("fetch")},revalidate(){throw s("revalidate")},createHref:Jq,encodeLocation:e4,getFetcher(){return gy},deleteFetcher(){throw s("deleteFetcher")},dispose(){throw s("dispose")},getBlocker(){return Rl},deleteBlocker(){throw s("deleteBlocker")},patchRoutes(){throw s("patchRoutes")},_internalFetchControllers:new Map,_internalSetRoutes(){throw s("_internalSetRoutes")}}}function Jq(n){return typeof n=="string"?n:Yi(n)}function e4(n){let e=typeof n=="string"?n:Yi(n);e=e.replace(/ $/,"%20");let t=Zte.test(e)?new URL(e):new URL(e,"http://localhost");return{pathname:t.pathname,search:t.search,hash:t.hash}}var Zte=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Xte={"&":"\\u0026",">":"\\u003e","<":"\\u003c","\u2028":"\\u2028","\u2029":"\\u2029"},zte=/[&><\u2028\u2029]/g;function Yte(n){return n.replace(zte,e=>Xte[e])}function Gte({context:n,url:e,nonce:t}){typeof e=="string"&&(e=new URL(e));let{manifest:r,routeModules:i,criticalCss:o,serverHandoffString:s}=n,a=Aq(r.routes,i,n.future,n.isSpaMode);n.staticHandlerContext.loaderData={...n.staticHandlerContext.loaderData};for(let c of n.staticHandlerContext.matches){let u=c.route.id,d=i[u],h=n.manifest.routes[u];d&&h&&ky(h,d,n.isSpaMode)&&(d.HydrateFallback||!h.hasLoader)&&delete n.staticHandlerContext.loaderData[u]}let l=Kq(a,n.staticHandlerContext);return D.createElement(D.Fragment,null,D.createElement(dc.Provider,{value:{manifest:r,routeModules:i,criticalCss:o,serverHandoffString:s,future:n.future,ssr:n.ssr,isSpaMode:n.isSpaMode,serializeError:n.serializeError,renderMeta:n.renderMeta}},D.createElement(jx,{location:l.state.location},D.createElement(Gq,{router:l,context:n.staticHandlerContext,hydrate:!1}))),n.serverHandoffStream?D.createElement(D.Suspense,null,D.createElement(Cq,{context:n,identifier:0,reader:n.serverHandoffStream.getReader(),textDecoder:new TextDecoder,nonce:t})):null)}function Hte(n,e){return function({initialEntries:r,initialIndex:i,hydrationData:o,future:s}){let a=D.useRef(),l=D.useRef();if(a.current==null){l.current={future:{unstable_middleware:(s==null?void 0:s.unstable_middleware)===!0},manifest:{routes:{},entry:{imports:[],module:""},url:"",version:""},routeModules:{},ssr:!1,isSpaMode:!1};let c=t4(ou(n,u=>u),l.current.manifest,l.current.routeModules);a.current=Oq(c,{unstable_getContext:e,initialEntries:r,initialIndex:i,hydrationData:o})}return D.createElement(dc.Provider,{value:l.current},D.createElement(vq,{router:a.current}))}}function t4(n,e,t,r){return n.map(i=>{if(!i.id)throw new Error("Expected a route.id in @remix-run/testing processRoutes() function");let o={id:i.id,path:i.path,index:i.index,Component:i.Component,HydrateFallback:i.HydrateFallback,ErrorBoundary:i.ErrorBoundary,action:i.action,loader:i.loader,handle:i.handle,shouldRevalidate:i.shouldRevalidate},s={id:i.id,path:i.path,index:i.index,parentId:r,hasAction:i.action!=null,hasLoader:i.loader!=null,hasClientAction:!1,hasClientLoader:!1,hasClientMiddleware:!1,hasErrorBoundary:i.ErrorBoundary!=null,module:"build/stub-path-to-module.js",clientActionModule:void 0,clientLoaderModule:void 0,clientMiddlewareModule:void 0,hydrateFallbackModule:void 0};return e.routes[o.id]=s,t[i.id]={default:i.Component||yq,ErrorBoundary:i.ErrorBoundary||void 0,handle:i.handle,links:i.links,meta:i.meta,shouldRevalidate:i.shouldRevalidate},i.children&&(o.children=t4(i.children,e,t,o.id)),o})}var Xx=new TextEncoder,Kte=async(n,e)=>{let t=Xx.encode(n),r=await n4(e,["sign"]),i=await crypto.subtle.sign("HMAC",r,t),o=btoa(String.fromCharCode(...new Uint8Array(i))).replace(/=+$/,"");return n+"."+o},Jte=async(n,e)=>{let t=n.lastIndexOf("."),r=n.slice(0,t),i=n.slice(t+1),o=Xx.encode(r),s=await n4(e,["verify"]),a=ene(atob(i));return await crypto.subtle.verify("HMAC",s,a,o)?r:!1},n4=async(n,e)=>crypto.subtle.importKey("raw",Xx.encode(n),{name:"HMAC",hash:"SHA-256"},!1,e);function ene(n){let e=new Uint8Array(n.length);for(let t=0;t<n.length;t++)e[t]=n.charCodeAt(t);return e}var zx=(n,e={})=>{let{secrets:t=[],...r}={path:"/",sameSite:"lax",...e};return sne(n,r.expires),{get name(){return n},get isSigned(){return t.length>0},get expires(){return typeof r.maxAge<"u"?new Date(Date.now()+r.maxAge*1e3):r.expires},async parse(i,o){if(!i)return null;let s=TM.parse(i,{...r,...o});if(n in s){let a=s[n];return typeof a=="string"&&a!==""?await nne(a,t):""}else return null},async serialize(i,o){return TM.serialize(n,i===""?"":await tne(i,t),{...r,...o})}}},Yx=n=>n!=null&&typeof n.name=="string"&&typeof n.isSigned=="boolean"&&typeof n.parse=="function"&&typeof n.serialize=="function";async function tne(n,e){let t=rne(n);return e.length>0&&(t=await Kte(t,e[0])),t}async function nne(n,e){if(e.length>0){for(let t of e){let r=await Jte(n,t);if(r!==!1)return HM(r)}return null}return HM(n)}function rne(n){return btoa(one(encodeURIComponent(JSON.stringify(n))))}function HM(n){try{return JSON.parse(decodeURIComponent(ine(atob(n))))}catch{return{}}}function ine(n){let e=n.toString(),t="",r=0,i,o;for(;r<e.length;)i=e.charAt(r++),/[\w*+\-./@]/.exec(i)?t+=i:(o=i.charCodeAt(0),o<256?t+="%"+KM(o,2):t+="%u"+KM(o,4).toUpperCase());return t}function KM(n,e){let t=n.toString(16);for(;t.length<e;)t="0"+t;return t}function one(n){let e=n.toString(),t="",r=0,i,o;for(;r<e.length;){if(i=e.charAt(r++),i==="%"){if(e.charAt(r)==="u"){if(o=e.slice(r+1,r+5),/^[\da-f]{4}$/i.exec(o)){t+=String.fromCharCode(parseInt(o,16)),r+=5;continue}}else if(o=e.slice(r,r+2),/^[\da-f]{2}$/i.exec(o)){t+=String.fromCharCode(parseInt(o,16)),r+=2;continue}}t+=i}return t}function sne(n,e){xv(!e,`The "${n}" cookie has an "expires" property set. This will cause the expires value to not be updated when the session is committed. Instead, you should set the expires value when serializing the cookie. You can use \`commitSession(session, { expires })\` if using a session storage object, or \`cookie.serialize("value", { expires })\` if you're using the cookie directly.`)}function ane(n){return Object.keys(n).reduce((e,t)=>{let r=n[t];return r&&(e[t]=r.module),e},{})}var r4=(n=>(n.Development="development",n.Production="production",n.Test="test",n))(r4||{});function lne(n){return n==="development"||n==="production"||n==="test"}function Cy(n,e){if(n instanceof Error&&e!=="development"){let t=new Error("Unexpected Server Error");return t.stack=void 0,t}return n}function _v(n,e){return Object.entries(n).reduce((t,[r,i])=>Object.assign(t,{[r]:Cy(i,e)}),{})}function i4(n,e){let t=Cy(n,e);return{message:t.message,stack:t.stack}}function JM(n,e){if(!n)return null;let t=Object.entries(n),r={};for(let[i,o]of t)if(si(o))r[i]={...o,__type:"RouteErrorResponse"};else if(o instanceof Error){let s=Cy(o,e);r[i]={message:s.message,stack:s.stack,__type:"Error",...s.name!=="Error"?{__subType:s.name}:{}}}else r[i]=o;return r}function Zk(n,e,t){let r=ho(n,e,t);return r?r.map(i=>({params:i.params,pathname:i.pathname,route:i.route})):null}async function e$(n,e){let t=await n({request:une(cne(e.request)),params:e.params,context:e.context});if(qk(t)&&t.init&&t.init.status&&Oy(t.init.status))throw new Response(null,t.init);return t}function cne(n){let e=new URL(n.url),t=e.searchParams.getAll("index");e.searchParams.delete("index");let r=[];for(let o of t)o&&r.push(o);for(let o of r)e.searchParams.append("index",o);let i={method:n.method,body:n.body,headers:n.headers,signal:n.signal};return i.body&&(i.duplex="half"),new Request(e.href,i)}function une(n){let e=new URL(n.url);e.searchParams.delete("_routes");let t={method:n.method,body:n.body,headers:n.headers,signal:n.signal};return t.body&&(t.duplex="half"),new Request(e.href,t)}function qO(n,e){if(n===!1||n===null||typeof n>"u")throw console.error("The following error is a bug in React Router; please open an issue! https://github.com/remix-run/react-router/issues/new/choose"),new Error(e)}function o4(n){let e={};return Object.values(n).forEach(t=>{if(t){let r=t.parentId||"";e[r]||(e[r]=[]),e[r].push(t)}}),e}function s4(n,e="",t=o4(n)){return(t[e]||[]).map(r=>({...r,children:s4(n,r.id,t)}))}function a4(n,e,t="",r=o4(n)){return(r[t]||[]).map(i=>{let o={hasErrorBoundary:i.id==="root"||i.module.ErrorBoundary!=null,id:i.id,path:i.path,unstable_middleware:i.module.unstable_middleware,loader:i.module.loader?async s=>{if(s.request.headers.has("X-React-Router-Prerender-Data")){const l=s.request.headers.get("X-React-Router-Prerender-Data");let c=l&&decodeURI(l);qO(c,"Missing prerendered data for route");let u=new TextEncoder().encode(c),d=new ReadableStream({start(O){O.enqueue(u),O.close()}}),p=(await wy(d,global)).value;qO(p&&i.id in p,"Unable to decode prerendered data");let g=p[i.id];return qO("data"in g,"Unable to process prerendered data"),g.data}return await e$(i.module.loader,s)}:void 0,action:i.module.action?s=>e$(i.module.action,s):void 0,handle:i.module.handle};return i.index?{index:!0,...o}:{caseSensitive:i.caseSensitive,children:a4(n,e,i.id,r),...o}})}var fne={"&":"\\u0026",">":"\\u003e","<":"\\u003c","\u2028":"\\u2028","\u2029":"\\u2029"},dne=/[&><\u2028\u2029]/g;function hne(n){return n.replace(dne,e=>fne[e])}function t$(n){return hne(JSON.stringify(n))}var l4="__reactRouterDevServerHooks";function pne(n){globalThis[l4]=n}function hS(){return globalThis[l4]}function Gx(n,e){let t=e.errors?e.matches.findIndex(o=>e.errors[o.route.id]):-1,r=t>=0?e.matches.slice(0,t+1):e.matches,i;if(t>=0){let{actionHeaders:o,actionData:s,loaderHeaders:a,loaderData:l}=e;e.matches.slice(t).some(c=>{let u=c.route.id;return o[u]&&(!s||!s.hasOwnProperty(u))?i=o[u]:a[u]&&!l.hasOwnProperty(u)&&(i=a[u]),i!=null})}return r.reduce((o,s,a)=>{let{id:l}=s.route,c=n.routes[l];qO(c,`Route with id "${l}" not found in build`);let u=c.module,d=e.loaderHeaders[l]||new Headers,h=e.actionHeaders[l]||new Headers,p=i!=null&&a===r.length-1,g=p&&i!==d&&i!==h;if(u.headers==null){let v=new Headers(o);return g&&Rc(i,v),Rc(h,v),Rc(d,v),v}let O=new Headers(u.headers?typeof u.headers=="function"?u.headers({loaderHeaders:d,parentHeaders:o,actionHeaders:h,errorHeaders:p?i:void 0}):u.headers:void 0);return g&&Rc(i,O),Rc(h,O),Rc(d,O),Rc(o,O),O},new Headers)}function Rc(n,e){let t=n.get("Set-Cookie");if(t){let r=TJ.splitCookiesString(t),i=new Set(e.getSetCookie());r.forEach(o=>{i.has(o)||e.append("Set-Cookie",o)})}}var c4=new Set([100,101,204,205,304]),Hh=202;async function mne(n,e,t,r,i,o,s){try{let l=function(d){let h=Gx(n,d);if(Oy(d.statusCode)&&h.has("Location"))return ql(r,n,e,{result:Kh(d.statusCode,h,n.basename),headers:h,status:Hh});d.errors&&(Object.values(d.errors).forEach(g=>{(!si(g)||g.error)&&s(g)}),d.errors=_v(d.errors,e));let p;return d.errors?p={error:Object.values(d.errors)[0]}:p={data:Object.values(d.actionData||{})[0]},ql(r,n,e,{result:p,headers:h,status:d.statusCode})};var a=l;let c=new Request(i,{method:r.method,body:r.body,headers:r.headers,signal:r.signal,...r.body?{duplex:"half"}:void 0}),u=await t.query(c,{requestContext:o,skipLoaderErrorBubbling:!0,skipRevalidation:!0,unstable_respond:l});return Ir(u)||(u=l(u)),vy(u)?ql(r,n,e,{result:Kh(u.status,u.headers,n.basename),headers:u.headers,status:Hh}):u}catch(l){return s(l),ql(r,n,e,{result:{error:l},headers:new Headers,status:500})}}async function gne(n,e,t,r,i,o,s){try{let l=function(p){let g=Gx(n,p);if(Oy(p.statusCode)&&g.has("Location"))return ql(r,n,e,{result:{[Kl]:Kh(p.statusCode,g,n.basename)},headers:g,status:Hh});p.errors&&(Object.values(p.errors).forEach(b=>{(!si(b)||b.error)&&s(b)}),p.errors=_v(p.errors,e));let O={},v=new Set(p.matches.filter(b=>d?d.has(b.route.id):b.route.loader!=null).map(b=>b.route.id));if(p.errors)for(let[b,S]of Object.entries(p.errors))O[b]={error:S};for(let[b,S]of Object.entries(p.loaderData))!(b in O)&&v.has(b)&&(O[b]={data:S});return ql(r,n,e,{result:O,headers:g,status:p.statusCode})};var a=l;let c=new Request(i,{headers:r.headers,signal:r.signal}),u=new URL(r.url).searchParams.get("_routes"),d=u?new Set(u.split(",")):null,h=await t.query(c,{requestContext:o,filterMatchesToLoad:p=>!d||d.has(p.route.id),skipLoaderErrorBubbling:!0,unstable_respond:l});return Ir(h)||(h=l(h)),vy(h)?ql(r,n,e,{result:{[Kl]:Kh(h.status,h.headers,n.basename)},headers:h.headers,status:Hh}):h}catch(l){return s(l),ql(r,n,e,{result:{root:{error:l}},headers:new Headers,status:500})}}function ql(n,e,t,{result:r,headers:i,status:o}){let s=new Headers(i);return s.set("X-Remix-Response","yes"),c4.has(o)?new Response(null,{status:o,headers:s}):(s.set("Content-Type","text/x-script"),new Response(Ev(r,n.signal,e.entry.module.streamTimeout,t),{status:o||200,headers:s}))}function Kh(n,e,t){let r=e.get("Location");return t&&(r=vi(r,t)||r),{redirect:r,status:n,revalidate:e.has("X-Remix-Revalidate")||e.has("Set-Cookie"),reload:e.has("X-Remix-Reload-Document"),replace:e.has("X-Remix-Replace")}}function Ev(n,e,t,r){let i=new AbortController,o=setTimeout(()=>i.abort(new Error("Server Timeout")),typeof t=="number"?t:4950);return e.addEventListener("abort",()=>clearTimeout(o)),kJ(n,{signal:i.signal,plugins:[s=>{if(s instanceof Error){let{name:a,message:l,stack:c}=r==="production"?Cy(s,r):s;return["SanitizedError",a,l,c]}if(s instanceof Qo){let{data:a,status:l,statusText:c}=s;return["ErrorResponse",a,l,c]}if(s&&typeof s=="object"&&Kl in s)return["SingleFetchRedirect",s[Kl]]}],postPlugins:[s=>{if(s&&typeof s=="object")return["SingleFetchClassInstance",Object.fromEntries(Object.entries(s))]},()=>["SingleFetchFallback"]]})}function n$(n,e){let t=s4(n.routes),r=a4(n.routes,n.future),i=lne(e)?e:"production",o=G3(r,{basename:n.basename}),s=n.entry.module.handleError||((a,{request:l})=>{i!=="test"&&!l.signal.aborted&&console.error(si(a)&&a.error?a.error:a)});return{routes:t,dataRoutes:r,serverMode:i,staticHandler:o,errorHandler:s}}var One=(n,e)=>{let t,r,i,o,s;return async function(l,c){var x,P,w;t=typeof n=="function"?await n():n;let u=t.future.unstable_middleware?new Ll(c):c||{};if(typeof n=="function"){let E=n$(t,e);r=E.routes,i=E.serverMode,o=E.staticHandler,s=E.errorHandler}else if(!r||!i||!o||!s){let E=n$(t,e);r=E.routes,i=E.serverMode,o=E.staticHandler,s=E.errorHandler}let d=new URL(l.url),h=t.basename||"/",p=d.pathname;vi(p,h)==="/_root.data"?p=h:p.endsWith(".data")&&(p=p.replace(/\.data$/,"")),vi(p,h)!=="/"&&p.endsWith("/")&&(p=p.slice(0,-1));let g={},O=E=>{var M,Q;e==="development"&&((Q=(M=hS())==null?void 0:M.processRequestError)==null||Q.call(M,E)),s(E,{context:u,params:g,request:l})};if(!t.ssr){if(t.prerender.length===0)l.headers.set("X-React-Router-SPA-Mode","yes");else if(!t.prerender.includes(p)&&!t.prerender.includes(p+"/")){if(d.pathname.endsWith(".data"))return s(new Qo(404,"Not Found",`Refusing to SSR the path \`${p}\` because \`ssr:false\` is set and the path is not included in the \`prerender\` config, so in production the path will be a 404.`),{context:u,params:g,request:l}),new Response("Not Found",{status:404,statusText:"Not Found"});l.headers.set("X-React-Router-SPA-Mode","yes")}}let v=`${h}/__manifest`.replace(/\/+/g,"/");if(d.pathname===v)try{return await vne(t,r,d)}catch(E){return O(E),new Response("Unknown Server Error",{status:500})}let b=Zk(r,d.pathname,t.basename);b&&b.length>0&&Object.assign(g,b[0].params);let S;if(d.pathname.endsWith(".data")){let E=new URL(l.url);E.pathname=p;let M=Zk(r,E.pathname,t.basename);if(S=await yne(i,t,o,l,E,u,O),t.entry.module.handleDataRequest&&(S=await t.entry.module.handleDataRequest(S,{context:u,params:M?M[0].params:{},request:l}),vy(S))){let Q=Kh(S.status,S.headers,t.basename);l.method==="GET"&&(Q={[Kl]:Q});let T=new Headers(S.headers);return T.set("Content-Type","text/x-script"),new Response(Ev(Q,l.signal,t.entry.module.streamTimeout,i),{status:Hh,headers:T})}}else if(!l.headers.has("X-React-Router-SPA-Mode")&&b&&b[b.length-1].route.module.default==null&&b[b.length-1].route.module.ErrorBoundary==null)S=await Sne(i,t,o,b.slice(-1)[0].route.id,l,u,O);else{let{pathname:E}=d,M;t.unstable_getCriticalCss?M=await t.unstable_getCriticalCss({pathname:E}):e==="development"&&((x=hS())!=null&&x.getCriticalCss)&&(M=await((w=(P=hS())==null?void 0:P.getCriticalCss)==null?void 0:w.call(P,E))),S=await bne(i,t,o,l,u,O,M)}return l.method==="HEAD"?new Response(null,{headers:S.headers,status:S.status,statusText:S.statusText}):S}};async function vne(n,e,t){if(n.assets.version!==t.searchParams.get("version"))return new Response(null,{status:204,headers:{"X-Remix-Reload-Document":"true"}});let r={};if(t.searchParams.has("p")){let i=new Set;t.searchParams.getAll("p").forEach(o=>{o.startsWith("/")||(o=`/${o}`);let s=o.split("/").slice(1);s.forEach((a,l)=>{let c=s.slice(0,l+1).join("/");i.add(`/${c}`)})});for(let o of i){let s=Zk(e,o,n.basename);if(s)for(let a of s){let l=a.route.id,c=n.assets.routes[l];c&&(r[l]=c)}}return Response.json(r,{headers:{"Cache-Control":"public, max-age=31536000, immutable"}})}return new Response("Invalid Request",{status:400})}async function yne(n,e,t,r,i,o,s){return r.method!=="GET"?await mne(e,n,t,r,i,o,s):await gne(e,n,t,r,i,o,s)}async function bne(n,e,t,r,i,o,s){let a=r.headers.has("X-React-Router-SPA-Mode");try{let c=await t.query(r,{requestContext:i,unstable_respond:e.future.unstable_middleware?u=>l(u,a):void 0});return Ir(c)?c:l(c,a)}catch(c){return o(c),new Response(null,{status:500})}async function l(c,u){if(Ir(c))return c;let d=Gx(e,c);if(c4.has(c.statusCode))return new Response(null,{status:c.statusCode,headers:d});c.errors&&(Object.values(c.errors).forEach(O=>{(!si(O)||O.error)&&o(O)}),c.errors=_v(c.errors,n));let h={loaderData:c.loaderData,actionData:c.actionData,errors:JM(c.errors,n)},p={manifest:e.assets,routeModules:ane(e.routes),staticHandlerContext:c,criticalCss:s,serverHandoffString:t$({basename:e.basename,criticalCss:s,future:e.future,ssr:e.ssr,isSpaMode:u}),serverHandoffStream:Ev(h,r.signal,e.entry.module.streamTimeout,n),renderMeta:{},future:e.future,ssr:e.ssr,isSpaMode:u,serializeError:O=>i4(O,n)},g=e.entry.module.default;try{return await g(r,c.statusCode,d,p,i)}catch(O){o(O);let v=O;if(Ir(O))try{let S=await kne(O);v=new Qo(O.status,O.statusText,S)}catch{}c=H3(t.dataRoutes,c,v),c.errors&&(c.errors=_v(c.errors,n));let b={loaderData:c.loaderData,actionData:c.actionData,errors:JM(c.errors,n)};p={...p,staticHandlerContext:c,serverHandoffString:t$({basename:e.basename,future:e.future,ssr:e.ssr,isSpaMode:u}),serverHandoffStream:Ev(b,r.signal,e.entry.module.streamTimeout,n),renderMeta:{}};try{return await g(r,c.statusCode,d,p,i)}catch(S){return o(S),Xk(S,n)}}}}async function Sne(n,e,t,r,i,o,s){try{let a=await t.queryRoute(i,{routeId:r,requestContext:o,unstable_respond:e.future.unstable_middleware?l=>l:void 0});return Ir(a)?a:typeof a=="string"?new Response(a):Response.json(a)}catch(a){if(Ir(a))return a.headers.set("X-Remix-Catch","yes"),a;if(si(a))return a&&s(a),wne(a,n);if(a instanceof Error&&a.message==="Expected a response from queryRoute"){let l=new Error("Expected a Response to be returned from resource route handler");return s(l),Xk(l,n)}return s(a),Xk(a,n)}}function wne(n,e){return Response.json(i4(n.error||new Error("Unexpected Server Error"),e),{status:n.status,statusText:n.statusText,headers:{"X-Remix-Error":"yes"}})}function Xk(n,e){let t="Unexpected Server Error";return e!=="production"&&(t+=`
|
|
169
|
+
import(${JSON.stringify(e.entry.module)});`:" ";return D.createElement(D.Fragment,null,D.createElement("script",{...n,suppressHydrationWarning:!0,dangerouslySetInnerHTML:GM(O),type:void 0}),D.createElement("script",{...n,suppressHydrationWarning:!0,dangerouslySetInnerHTML:GM(v),type:"module",async:!0}))},[]),p=NO?[]:e.entry.imports.concat($x(d,e,{includeHydrateFallback:!0}));return NO?null:D.createElement(D.Fragment,null,u?null:D.createElement("link",{rel:"modulepreload",href:e.url,crossOrigin:n.crossOrigin}),D.createElement("link",{rel:"modulepreload",href:e.entry.module,crossOrigin:n.crossOrigin}),Rte(p).map(g=>D.createElement("link",{key:g,rel:"modulepreload",href:g,crossOrigin:n.crossOrigin})),h)}function Rte(n){return[...new Set(n)]}function Ate(...n){return e=>{n.forEach(t=>{typeof t=="function"?t(e):t!=null&&(t.current=e)})}}var Nq=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{Nq&&(window.__reactRouterVersion="7.4.1")}catch{}function Mte(n,e){return Op({basename:e==null?void 0:e.basename,unstable_getContext:e==null?void 0:e.unstable_getContext,future:e==null?void 0:e.future,history:dy({window:e==null?void 0:e.window}),hydrationData:(e==null?void 0:e.hydrationData)||qq(),routes:n,mapRouteProperties:fu,dataStrategy:e==null?void 0:e.dataStrategy,patchRoutesOnNavigation:e==null?void 0:e.patchRoutesOnNavigation,window:e==null?void 0:e.window}).initialize()}function $te(n,e){return Op({basename:e==null?void 0:e.basename,unstable_getContext:e==null?void 0:e.unstable_getContext,future:e==null?void 0:e.future,history:j3({window:e==null?void 0:e.window}),hydrationData:(e==null?void 0:e.hydrationData)||qq(),routes:n,mapRouteProperties:fu,dataStrategy:e==null?void 0:e.dataStrategy,patchRoutesOnNavigation:e==null?void 0:e.patchRoutesOnNavigation,window:e==null?void 0:e.window}).initialize()}function qq(){let n=window==null?void 0:window.__staticRouterHydrationData;return n&&n.errors&&(n={...n,errors:Dte(n.errors)}),n}function Dte(n){if(!n)return null;let e=Object.entries(n),t={};for(let[r,i]of e)if(i&&i.__type==="RouteErrorResponse")t[r]=new Qo(i.status,i.statusText,i.data,i.internal===!0);else if(i&&i.__type==="Error"){if(i.__subType){let o=window[i.__subType];if(typeof o=="function")try{let s=new o(i.message);s.stack="",t[r]=s}catch{}}if(t[r]==null){let o=new Error(i.message);o.stack="",t[r]=o}}else t[r]=i;return t}function Uq({basename:n,children:e,window:t}){let r=D.useRef();r.current==null&&(r.current=dy({window:t,v5Compat:!0}));let i=r.current,[o,s]=D.useState({action:i.action,location:i.location}),a=D.useCallback(l=>{D.startTransition(()=>s(l))},[s]);return D.useLayoutEffect(()=>i.listen(a),[i,a]),D.createElement(fc,{basename:n,children:e,location:o.location,navigationType:o.action,navigator:i})}function Qte({basename:n,children:e,window:t}){let r=D.useRef();r.current==null&&(r.current=j3({window:t,v5Compat:!0}));let i=r.current,[o,s]=D.useState({action:i.action,location:i.location}),a=D.useCallback(l=>{D.startTransition(()=>s(l))},[s]);return D.useLayoutEffect(()=>i.listen(a),[i,a]),D.createElement(fc,{basename:n,children:e,location:o.location,navigationType:o.action,navigator:i})}function Bq({basename:n,children:e,history:t}){let[r,i]=D.useState({action:t.action,location:t.location}),o=D.useCallback(s=>{D.startTransition(()=>i(s))},[i]);return D.useLayoutEffect(()=>t.listen(o),[t,o]),D.createElement(fc,{basename:n,children:e,location:r.location,navigationType:r.action,navigator:t})}Bq.displayName="unstable_HistoryRouter";var Fq=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Fx=D.forwardRef(function({onClick:e,discover:t="render",prefetch:r="none",relative:i,reloadDocument:o,replace:s,state:a,target:l,to:c,preventScrollReset:u,viewTransition:d,...h},p){let{basename:g}=D.useContext(vo),O=typeof c=="string"&&Fq.test(c),v,b=!1;if(typeof c=="string"&&O&&(v=c,Nq))try{let T=new URL(window.location.href),R=c.startsWith("//")?new URL(T.protocol+c):new URL(c),$=vi(R.pathname,g);R.origin===T.origin&&$!=null?c=$+R.search+R.hash:b=!0}catch{yr(!1,`<Link to="${c}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}let S=aq(c,{relative:i}),[x,P,w]=Pte(r,h),E=Xq(c,{replace:s,state:a,target:l,preventScrollReset:u,relative:i,viewTransition:d});function M(T){e&&e(T),T.defaultPrevented||E(T)}let Q=D.createElement("a",{...h,...w,href:v||S,onClick:b||o?e:M,ref:Ate(p,P),target:l,"data-discover":!O&&t==="render"?"true":void 0});return x&&!O?D.createElement(D.Fragment,null,Q,D.createElement(Bx,{page:S})):Q});Fx.displayName="Link";var Vq=D.forwardRef(function({"aria-current":e="page",caseSensitive:t=!1,className:r="",end:i=!1,style:o,to:s,viewTransition:a,children:l,...c},u){let d=Kf(s,{relative:c.relative}),h=bo(),p=D.useContext(lc),{navigator:g,basename:O}=D.useContext(vo),v=p!=null&&Gq(d)&&a===!0,b=g.encodeLocation?g.encodeLocation(d).pathname:d.pathname,S=h.pathname,x=p&&p.navigation&&p.navigation.location?p.navigation.location.pathname:null;t||(S=S.toLowerCase(),x=x?x.toLowerCase():null,b=b.toLowerCase()),x&&O&&(x=vi(x,O)||x);const P=b!=="/"&&b.endsWith("/")?b.length-1:b.length;let w=S===b||!i&&S.startsWith(b)&&S.charAt(P)==="/",E=x!=null&&(x===b||!i&&x.startsWith(b)&&x.charAt(b.length)==="/"),M={isActive:w,isPending:E,isTransitioning:v},Q=w?e:void 0,T;typeof r=="function"?T=r(M):T=[r,w?"active":null,E?"pending":null,v?"transitioning":null].filter(Boolean).join(" ");let R=typeof o=="function"?o(M):o;return D.createElement(Fx,{...c,"aria-current":Q,className:T,ref:u,style:R,to:s,viewTransition:a},typeof l=="function"?l(M):l)});Vq.displayName="NavLink";var Vx=D.forwardRef(({discover:n="render",fetcherKey:e,navigate:t,reloadDocument:r,replace:i,state:o,method:s=IO,action:a,onSubmit:l,relative:c,preventScrollReset:u,viewTransition:d,...h},p)=>{let g=Zx(),O=zq(a,{relative:c}),v=s.toLowerCase()==="get"?"get":"post",b=typeof a=="string"&&Fq.test(a),S=x=>{if(l&&l(x),x.defaultPrevented)return;x.preventDefault();let P=x.nativeEvent.submitter,w=(P==null?void 0:P.getAttribute("formmethod"))||s;g(P||x.currentTarget,{fetcherKey:e,method:w,navigate:t,replace:i,state:o,relative:c,preventScrollReset:u,viewTransition:d})};return D.createElement("form",{ref:p,method:v,action:O,onSubmit:r?l:S,...h,"data-discover":!b&&n==="render"?"true":void 0})});Vx.displayName="Form";function Wq({getKey:n,storageKey:e,...t}){let r=D.useContext(dc),{basename:i}=D.useContext(vo),o=bo(),s=Rx();Yq({getKey:n,storageKey:e});let a=D.useMemo(()=>{if(!r||!n)return null;let c=Wk(o,s,i,n);return c!==o.key?c:null},[]);if(!r||r.isSpaMode)return null;let l=((c,u)=>{if(!window.history.state||!window.history.state.key){let d=Math.random().toString(32).slice(2);window.history.replaceState({key:d},"")}try{let h=JSON.parse(sessionStorage.getItem(c)||"{}")[u||window.history.state.key];typeof h=="number"&&window.scrollTo(0,h)}catch(d){console.error(d),sessionStorage.removeItem(c)}}).toString();return D.createElement("script",{...t,suppressHydrationWarning:!0,dangerouslySetInnerHTML:{__html:`(${l})(${JSON.stringify(e||Vk)}, ${JSON.stringify(a)})`}})}Wq.displayName="ScrollRestoration";function Zq(n){return`${n} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function xy(n){let e=D.useContext(Wa);return zt(e,Zq(n)),e}function Wx(n){let e=D.useContext(lc);return zt(e,Zq(n)),e}function Xq(n,{target:e,replace:t,state:r,preventScrollReset:i,relative:o,viewTransition:s}={}){let a=yy(),l=bo(),c=Kf(n,{relative:o});return D.useCallback(u=>{if(Hee(u,e)){u.preventDefault();let d=t!==void 0?t:Yi(l)===Yi(c);a(n,{replace:d,state:r,preventScrollReset:i,relative:o,viewTransition:s})}},[l,a,c,t,r,e,n,i,o,s])}function Ite(n){yr(typeof URLSearchParams<"u","You cannot use the `useSearchParams` hook in a browser that does not support the URLSearchParams API. If you need to support Internet Explorer 11, we recommend you load a polyfill such as https://github.com/ungap/url-search-params.");let e=D.useRef(Cv(n)),t=D.useRef(!1),r=bo(),i=D.useMemo(()=>Kee(r.search,t.current?null:e.current),[r.search]),o=yy(),s=D.useCallback((a,l)=>{const c=Cv(typeof a=="function"?a(i):a);t.current=!0,o("?"+c,l)},[o,i]);return[i,s]}var jte=0,Lte=()=>`__${String(++jte)}__`;function Zx(){let{router:n}=xy("useSubmit"),{basename:e}=D.useContext(vo),t=_ee();return D.useCallback(async(r,i={})=>{let{action:o,method:s,encType:a,formData:l,body:c}=tte(r,e);if(i.navigate===!1){let u=i.fetcherKey||Lte();await n.fetch(u,t,i.action||o,{preventScrollReset:i.preventScrollReset,formData:l,body:c,formMethod:i.method||s,formEncType:i.encType||a,flushSync:i.flushSync})}else await n.navigate(i.action||o,{preventScrollReset:i.preventScrollReset,formData:l,body:c,formMethod:i.method||s,formEncType:i.encType||a,replace:i.replace,state:i.state,fromRouteId:t,flushSync:i.flushSync,viewTransition:i.viewTransition})},[n,e,t])}function zq(n,{relative:e}={}){let{basename:t}=D.useContext(vo),r=D.useContext(yo);zt(r,"useFormAction must be used inside a RouteContext");let[i]=r.matches.slice(-1),o={...Kf(n||".",{relative:e})},s=bo();if(n==null){o.search=s.search;let a=new URLSearchParams(o.search),l=a.getAll("index");if(l.some(u=>u==="")){a.delete("index"),l.filter(d=>d).forEach(d=>a.append("index",d));let u=a.toString();o.search=u?`?${u}`:""}}return(!n||n===".")&&i.route.index&&(o.search=o.search?o.search.replace(/^\?/,"?index&"):"?index"),t!=="/"&&(o.pathname=o.pathname==="/"?t:ca([t,o.pathname])),Yi(o)}function Nte({key:n}={}){var v;let{router:e}=xy("useFetcher"),t=Wx("useFetcher"),r=D.useContext(yp),i=D.useContext(yo),o=(v=i.matches[i.matches.length-1])==null?void 0:v.route.id;zt(r,"useFetcher must be used inside a FetchersContext"),zt(i,"useFetcher must be used inside a RouteContext"),zt(o!=null,'useFetcher can only be used on routes that contain a unique "id"');let s=D.useId(),[a,l]=D.useState(n||s);n&&n!==a&&l(n),D.useEffect(()=>(e.getFetcher(a),()=>e.deleteFetcher(a)),[e,a]);let c=D.useCallback(async(b,S)=>{zt(o,"No routeId available for fetcher.load()"),await e.fetch(a,o,b,S)},[a,o,e]),u=Zx(),d=D.useCallback(async(b,S)=>{await u(b,{...S,navigate:!1,fetcherKey:a})},[a,u]),h=D.useMemo(()=>{let b=D.forwardRef((S,x)=>D.createElement(Vx,{...S,navigate:!1,fetcherKey:a,ref:x}));return b.displayName="fetcher.Form",b},[a]),p=t.fetchers.get(a)||gy,g=r.get(a);return D.useMemo(()=>({Form:h,submit:d,load:c,...p,data:g}),[h,d,c,p,g])}function qte(){let n=Wx("useFetchers");return Array.from(n.fetchers.entries()).map(([e,t])=>({...t,key:e}))}var Vk="react-router-scroll-positions",Km={};function Wk(n,e,t,r){let i=null;return r&&(t!=="/"?i=r({...n,pathname:vi(n.pathname,t)||n.pathname},e):i=r(n,e)),i==null&&(i=n.key),i}function Yq({getKey:n,storageKey:e}={}){let{router:t}=xy("useScrollRestoration"),{restoreScrollPosition:r,preventScrollReset:i}=Wx("useScrollRestoration"),{basename:o}=D.useContext(vo),s=bo(),a=Rx(),l=pq();D.useEffect(()=>(window.history.scrollRestoration="manual",()=>{window.history.scrollRestoration="auto"}),[]),Bte(D.useCallback(()=>{if(l.state==="idle"){let c=Wk(s,a,o,n);Km[c]=window.scrollY}try{sessionStorage.setItem(e||Vk,JSON.stringify(Km))}catch(c){yr(!1,`Failed to save scroll positions in sessionStorage, <ScrollRestoration /> will not work properly (${c}).`)}window.history.scrollRestoration="auto"},[l.state,n,o,s,a,e])),typeof document<"u"&&(D.useLayoutEffect(()=>{try{let c=sessionStorage.getItem(e||Vk);c&&(Km=JSON.parse(c))}catch{}},[e]),D.useLayoutEffect(()=>{let c=t==null?void 0:t.enableScrollRestoration(Km,()=>window.scrollY,n?(u,d)=>Wk(u,d,o,n):void 0);return()=>c&&c()},[t,o,n]),D.useLayoutEffect(()=>{if(r!==!1){if(typeof r=="number"){window.scrollTo(0,r);return}if(s.hash){let c=document.getElementById(decodeURIComponent(s.hash.slice(1)));if(c){c.scrollIntoView();return}}i!==!0&&window.scrollTo(0,0)}},[s,r,i]))}function Ute(n,e){let{capture:t}=e||{};D.useEffect(()=>{let r=t!=null?{capture:t}:void 0;return window.addEventListener("beforeunload",n,r),()=>{window.removeEventListener("beforeunload",n,r)}},[n,t])}function Bte(n,e){let{capture:t}={};D.useEffect(()=>{let r=t!=null?{capture:t}:void 0;return window.addEventListener("pagehide",n,r),()=>{window.removeEventListener("pagehide",n,r)}},[n,t])}function Fte({when:n,message:e}){let t=gq(n);D.useEffect(()=>{t.state==="blocked"&&(window.confirm(e)?setTimeout(t.proceed,0):t.reset())},[t,e]),D.useEffect(()=>{t.state==="blocked"&&!n&&t.reset()},[t,n])}function Gq(n,e={}){let t=D.useContext(vp);zt(t!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:r}=xy("useViewTransitionState"),i=Kf(n,{relative:e.relative});if(!t.isTransitioning)return!1;let o=vi(t.currentLocation.pathname,r)||t.currentLocation.pathname,s=vi(t.nextLocation.pathname,r)||t.nextLocation.pathname;return Uf(i.pathname,s)!=null||Uf(i.pathname,o)!=null}function Vte({basename:n,children:e,location:t="/"}){typeof t=="string"&&(t=jo(t));let r="POP",i={pathname:t.pathname||"/",search:t.search||"",hash:t.hash||"",state:t.state!=null?t.state:null,key:t.key||"default"},o=Kq();return D.createElement(fc,{basename:n,children:e,location:i,navigationType:r,navigator:o,static:!0})}function Hq({context:n,router:e,hydrate:t=!0,nonce:r}){zt(e&&n,"You must provide `router` and `context` to <StaticRouterProvider>");let i={router:e,navigator:Kq(),static:!0,staticContext:n,basename:n.basename||"/"},o=new Map,s="";if(t!==!1){let l={loaderData:n.loaderData,actionData:n.actionData,errors:Zte(n.errors)};s=`window.__staticRouterHydrationData = JSON.parse(${Hte(JSON.stringify(JSON.stringify(l)))});`}let{state:a}=i.router;return D.createElement(D.Fragment,null,D.createElement(Wa.Provider,{value:i},D.createElement(lc.Provider,{value:a},D.createElement(yp.Provider,{value:o},D.createElement(vp.Provider,{value:{isTransitioning:!1}},D.createElement(fc,{basename:i.basename,location:a.location,navigationType:a.historyAction,navigator:i.navigator,static:i.static},D.createElement(Wte,{routes:e.routes,future:e.future,state:a})))))),s?D.createElement("script",{suppressHydrationWarning:!0,nonce:r,dangerouslySetInnerHTML:{__html:s}}):null)}function Wte({routes:n,future:e,state:t}){return Tx(n,void 0,t,e)}function Zte(n){if(!n)return null;let e=Object.entries(n),t={};for(let[r,i]of e)si(i)?t[r]={...i,__type:"RouteErrorResponse"}:i instanceof Error?t[r]={message:i.message,__type:"Error",...i.name!=="Error"?{__subType:i.name}:{}}:t[r]=i;return t}function Kq(){return{createHref:e4,encodeLocation:t4,push(n){throw new Error(`You cannot use navigator.push() on the server because it is a stateless environment. This error was probably triggered when you did a \`navigate(${JSON.stringify(n)})\` somewhere in your app.`)},replace(n){throw new Error(`You cannot use navigator.replace() on the server because it is a stateless environment. This error was probably triggered when you did a \`navigate(${JSON.stringify(n)}, { replace: true })\` somewhere in your app.`)},go(n){throw new Error(`You cannot use navigator.go() on the server because it is a stateless environment. This error was probably triggered when you did a \`navigate(${n})\` somewhere in your app.`)},back(){throw new Error("You cannot use navigator.back() on the server because it is a stateless environment.")},forward(){throw new Error("You cannot use navigator.forward() on the server because it is a stateless environment.")}}}function Xte(n,e){return H3(n,{...e,mapRouteProperties:fu})}function Jq(n,e,t={}){let r={},i=ou(n,fu,void 0,r),o=e.matches.map(a=>{let l=r[a.route.id]||a.route;return{...a,route:l}}),s=a=>`You cannot use router.${a}() on the server because it is a stateless environment`;return{get basename(){return e.basename},get future(){return{unstable_middleware:!1,...t==null?void 0:t.future}},get state(){return{historyAction:"POP",location:e.location,matches:o,loaderData:e.loaderData,actionData:e.actionData,errors:e.errors,initialized:!0,navigation:kh,restoreScrollPosition:null,preventScrollReset:!1,revalidation:"idle",fetchers:new Map,blockers:new Map}},get routes(){return i},get window(){},initialize(){throw s("initialize")},subscribe(){throw s("subscribe")},enableScrollRestoration(){throw s("enableScrollRestoration")},navigate(){throw s("navigate")},fetch(){throw s("fetch")},revalidate(){throw s("revalidate")},createHref:e4,encodeLocation:t4,getFetcher(){return gy},deleteFetcher(){throw s("deleteFetcher")},dispose(){throw s("dispose")},getBlocker(){return Rl},deleteBlocker(){throw s("deleteBlocker")},patchRoutes(){throw s("patchRoutes")},_internalFetchControllers:new Map,_internalSetRoutes(){throw s("_internalSetRoutes")}}}function e4(n){return typeof n=="string"?n:Yi(n)}function t4(n){let e=typeof n=="string"?n:Yi(n);e=e.replace(/ $/,"%20");let t=zte.test(e)?new URL(e):new URL(e,"http://localhost");return{pathname:t.pathname,search:t.search,hash:t.hash}}var zte=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Yte={"&":"\\u0026",">":"\\u003e","<":"\\u003c","\u2028":"\\u2028","\u2029":"\\u2029"},Gte=/[&><\u2028\u2029]/g;function Hte(n){return n.replace(Gte,e=>Yte[e])}function Kte({context:n,url:e,nonce:t}){typeof e=="string"&&(e=new URL(e));let{manifest:r,routeModules:i,criticalCss:o,serverHandoffString:s}=n,a=Mq(r.routes,i,n.future,n.isSpaMode);n.staticHandlerContext.loaderData={...n.staticHandlerContext.loaderData};for(let c of n.staticHandlerContext.matches){let u=c.route.id,d=i[u],h=n.manifest.routes[u];d&&h&&ky(h,d,n.isSpaMode)&&(d.HydrateFallback||!h.hasLoader)&&delete n.staticHandlerContext.loaderData[u]}let l=Jq(a,n.staticHandlerContext);return D.createElement(D.Fragment,null,D.createElement(dc.Provider,{value:{manifest:r,routeModules:i,criticalCss:o,serverHandoffString:s,future:n.future,ssr:n.ssr,isSpaMode:n.isSpaMode,serializeError:n.serializeError,renderMeta:n.renderMeta}},D.createElement(jx,{location:l.state.location},D.createElement(Hq,{router:l,context:n.staticHandlerContext,hydrate:!1}))),n.serverHandoffStream?D.createElement(D.Suspense,null,D.createElement(Tq,{context:n,identifier:0,reader:n.serverHandoffStream.getReader(),textDecoder:new TextDecoder,nonce:t})):null)}function Jte(n,e){return function({initialEntries:r,initialIndex:i,hydrationData:o,future:s}){let a=D.useRef(),l=D.useRef();if(a.current==null){l.current={future:{unstable_middleware:(s==null?void 0:s.unstable_middleware)===!0},manifest:{routes:{},entry:{imports:[],module:""},url:"",version:""},routeModules:{},ssr:!1,isSpaMode:!1};let c=n4(ou(n,u=>u),l.current.manifest,l.current.routeModules);a.current=vq(c,{unstable_getContext:e,initialEntries:r,initialIndex:i,hydrationData:o})}return D.createElement(dc.Provider,{value:l.current},D.createElement(yq,{router:a.current}))}}function n4(n,e,t,r){return n.map(i=>{if(!i.id)throw new Error("Expected a route.id in @remix-run/testing processRoutes() function");let o={id:i.id,path:i.path,index:i.index,Component:i.Component,HydrateFallback:i.HydrateFallback,ErrorBoundary:i.ErrorBoundary,action:i.action,loader:i.loader,handle:i.handle,shouldRevalidate:i.shouldRevalidate},s={id:i.id,path:i.path,index:i.index,parentId:r,hasAction:i.action!=null,hasLoader:i.loader!=null,hasClientAction:!1,hasClientLoader:!1,hasClientMiddleware:!1,hasErrorBoundary:i.ErrorBoundary!=null,module:"build/stub-path-to-module.js",clientActionModule:void 0,clientLoaderModule:void 0,clientMiddlewareModule:void 0,hydrateFallbackModule:void 0};return e.routes[o.id]=s,t[i.id]={default:i.Component||bq,ErrorBoundary:i.ErrorBoundary||void 0,handle:i.handle,links:i.links,meta:i.meta,shouldRevalidate:i.shouldRevalidate},i.children&&(o.children=n4(i.children,e,t,o.id)),o})}var Xx=new TextEncoder,ene=async(n,e)=>{let t=Xx.encode(n),r=await r4(e,["sign"]),i=await crypto.subtle.sign("HMAC",r,t),o=btoa(String.fromCharCode(...new Uint8Array(i))).replace(/=+$/,"");return n+"."+o},tne=async(n,e)=>{let t=n.lastIndexOf("."),r=n.slice(0,t),i=n.slice(t+1),o=Xx.encode(r),s=await r4(e,["verify"]),a=nne(atob(i));return await crypto.subtle.verify("HMAC",s,a,o)?r:!1},r4=async(n,e)=>crypto.subtle.importKey("raw",Xx.encode(n),{name:"HMAC",hash:"SHA-256"},!1,e);function nne(n){let e=new Uint8Array(n.length);for(let t=0;t<n.length;t++)e[t]=n.charCodeAt(t);return e}var zx=(n,e={})=>{let{secrets:t=[],...r}={path:"/",sameSite:"lax",...e};return lne(n,r.expires),{get name(){return n},get isSigned(){return t.length>0},get expires(){return typeof r.maxAge<"u"?new Date(Date.now()+r.maxAge*1e3):r.expires},async parse(i,o){if(!i)return null;let s=EM.parse(i,{...r,...o});if(n in s){let a=s[n];return typeof a=="string"&&a!==""?await ine(a,t):""}else return null},async serialize(i,o){return EM.serialize(n,i===""?"":await rne(i,t),{...r,...o})}}},Yx=n=>n!=null&&typeof n.name=="string"&&typeof n.isSigned=="boolean"&&typeof n.parse=="function"&&typeof n.serialize=="function";async function rne(n,e){let t=one(n);return e.length>0&&(t=await ene(t,e[0])),t}async function ine(n,e){if(e.length>0){for(let t of e){let r=await tne(n,t);if(r!==!1)return JM(r)}return null}return JM(n)}function one(n){return btoa(ane(encodeURIComponent(JSON.stringify(n))))}function JM(n){try{return JSON.parse(decodeURIComponent(sne(atob(n))))}catch{return{}}}function sne(n){let e=n.toString(),t="",r=0,i,o;for(;r<e.length;)i=e.charAt(r++),/[\w*+\-./@]/.exec(i)?t+=i:(o=i.charCodeAt(0),o<256?t+="%"+e$(o,2):t+="%u"+e$(o,4).toUpperCase());return t}function e$(n,e){let t=n.toString(16);for(;t.length<e;)t="0"+t;return t}function ane(n){let e=n.toString(),t="",r=0,i,o;for(;r<e.length;){if(i=e.charAt(r++),i==="%"){if(e.charAt(r)==="u"){if(o=e.slice(r+1,r+5),/^[\da-f]{4}$/i.exec(o)){t+=String.fromCharCode(parseInt(o,16)),r+=5;continue}}else if(o=e.slice(r,r+2),/^[\da-f]{2}$/i.exec(o)){t+=String.fromCharCode(parseInt(o,16)),r+=2;continue}}t+=i}return t}function lne(n,e){xv(!e,`The "${n}" cookie has an "expires" property set. This will cause the expires value to not be updated when the session is committed. Instead, you should set the expires value when serializing the cookie. You can use \`commitSession(session, { expires })\` if using a session storage object, or \`cookie.serialize("value", { expires })\` if you're using the cookie directly.`)}function cne(n){return Object.keys(n).reduce((e,t)=>{let r=n[t];return r&&(e[t]=r.module),e},{})}var i4=(n=>(n.Development="development",n.Production="production",n.Test="test",n))(i4||{});function une(n){return n==="development"||n==="production"||n==="test"}function Cy(n,e){if(n instanceof Error&&e!=="development"){let t=new Error("Unexpected Server Error");return t.stack=void 0,t}return n}function _v(n,e){return Object.entries(n).reduce((t,[r,i])=>Object.assign(t,{[r]:Cy(i,e)}),{})}function o4(n,e){let t=Cy(n,e);return{message:t.message,stack:t.stack}}function t$(n,e){if(!n)return null;let t=Object.entries(n),r={};for(let[i,o]of t)if(si(o))r[i]={...o,__type:"RouteErrorResponse"};else if(o instanceof Error){let s=Cy(o,e);r[i]={message:s.message,stack:s.stack,__type:"Error",...s.name!=="Error"?{__subType:s.name}:{}}}else r[i]=o;return r}function Zk(n,e,t){let r=ho(n,e,t);return r?r.map(i=>({params:i.params,pathname:i.pathname,route:i.route})):null}async function n$(n,e){let t=await n({request:dne(fne(e.request)),params:e.params,context:e.context});if(qk(t)&&t.init&&t.init.status&&Oy(t.init.status))throw new Response(null,t.init);return t}function fne(n){let e=new URL(n.url),t=e.searchParams.getAll("index");e.searchParams.delete("index");let r=[];for(let o of t)o&&r.push(o);for(let o of r)e.searchParams.append("index",o);let i={method:n.method,body:n.body,headers:n.headers,signal:n.signal};return i.body&&(i.duplex="half"),new Request(e.href,i)}function dne(n){let e=new URL(n.url);e.searchParams.delete("_routes");let t={method:n.method,body:n.body,headers:n.headers,signal:n.signal};return t.body&&(t.duplex="half"),new Request(e.href,t)}function qO(n,e){if(n===!1||n===null||typeof n>"u")throw console.error("The following error is a bug in React Router; please open an issue! https://github.com/remix-run/react-router/issues/new/choose"),new Error(e)}function s4(n){let e={};return Object.values(n).forEach(t=>{if(t){let r=t.parentId||"";e[r]||(e[r]=[]),e[r].push(t)}}),e}function a4(n,e="",t=s4(n)){return(t[e]||[]).map(r=>({...r,children:a4(n,r.id,t)}))}function l4(n,e,t="",r=s4(n)){return(r[t]||[]).map(i=>{let o={hasErrorBoundary:i.id==="root"||i.module.ErrorBoundary!=null,id:i.id,path:i.path,unstable_middleware:i.module.unstable_middleware,loader:i.module.loader?async s=>{if(s.request.headers.has("X-React-Router-Prerender-Data")){const l=s.request.headers.get("X-React-Router-Prerender-Data");let c=l&&decodeURI(l);qO(c,"Missing prerendered data for route");let u=new TextEncoder().encode(c),d=new ReadableStream({start(O){O.enqueue(u),O.close()}}),p=(await wy(d,global)).value;qO(p&&i.id in p,"Unable to decode prerendered data");let g=p[i.id];return qO("data"in g,"Unable to process prerendered data"),g.data}return await n$(i.module.loader,s)}:void 0,action:i.module.action?s=>n$(i.module.action,s):void 0,handle:i.module.handle};return i.index?{index:!0,...o}:{caseSensitive:i.caseSensitive,children:l4(n,e,i.id,r),...o}})}var hne={"&":"\\u0026",">":"\\u003e","<":"\\u003c","\u2028":"\\u2028","\u2029":"\\u2029"},pne=/[&><\u2028\u2029]/g;function mne(n){return n.replace(pne,e=>hne[e])}function r$(n){return mne(JSON.stringify(n))}var c4="__reactRouterDevServerHooks";function gne(n){globalThis[c4]=n}function hS(){return globalThis[c4]}function Gx(n,e){let t=e.errors?e.matches.findIndex(o=>e.errors[o.route.id]):-1,r=t>=0?e.matches.slice(0,t+1):e.matches,i;if(t>=0){let{actionHeaders:o,actionData:s,loaderHeaders:a,loaderData:l}=e;e.matches.slice(t).some(c=>{let u=c.route.id;return o[u]&&(!s||!s.hasOwnProperty(u))?i=o[u]:a[u]&&!l.hasOwnProperty(u)&&(i=a[u]),i!=null})}return r.reduce((o,s,a)=>{let{id:l}=s.route,c=n.routes[l];qO(c,`Route with id "${l}" not found in build`);let u=c.module,d=e.loaderHeaders[l]||new Headers,h=e.actionHeaders[l]||new Headers,p=i!=null&&a===r.length-1,g=p&&i!==d&&i!==h;if(u.headers==null){let v=new Headers(o);return g&&Rc(i,v),Rc(h,v),Rc(d,v),v}let O=new Headers(u.headers?typeof u.headers=="function"?u.headers({loaderHeaders:d,parentHeaders:o,actionHeaders:h,errorHeaders:p?i:void 0}):u.headers:void 0);return g&&Rc(i,O),Rc(h,O),Rc(d,O),Rc(o,O),O},new Headers)}function Rc(n,e){let t=n.get("Set-Cookie");if(t){let r=EJ.splitCookiesString(t),i=new Set(e.getSetCookie());r.forEach(o=>{i.has(o)||e.append("Set-Cookie",o)})}}var u4=new Set([100,101,204,205,304]),Hh=202;async function One(n,e,t,r,i,o,s){try{let l=function(d){let h=Gx(n,d);if(Oy(d.statusCode)&&h.has("Location"))return ql(r,n,e,{result:Kh(d.statusCode,h,n.basename),headers:h,status:Hh});d.errors&&(Object.values(d.errors).forEach(g=>{(!si(g)||g.error)&&s(g)}),d.errors=_v(d.errors,e));let p;return d.errors?p={error:Object.values(d.errors)[0]}:p={data:Object.values(d.actionData||{})[0]},ql(r,n,e,{result:p,headers:h,status:d.statusCode})};var a=l;let c=new Request(i,{method:r.method,body:r.body,headers:r.headers,signal:r.signal,...r.body?{duplex:"half"}:void 0}),u=await t.query(c,{requestContext:o,skipLoaderErrorBubbling:!0,skipRevalidation:!0,unstable_respond:l});return Ir(u)||(u=l(u)),vy(u)?ql(r,n,e,{result:Kh(u.status,u.headers,n.basename),headers:u.headers,status:Hh}):u}catch(l){return s(l),ql(r,n,e,{result:{error:l},headers:new Headers,status:500})}}async function vne(n,e,t,r,i,o,s){try{let l=function(p){let g=Gx(n,p);if(Oy(p.statusCode)&&g.has("Location"))return ql(r,n,e,{result:{[Kl]:Kh(p.statusCode,g,n.basename)},headers:g,status:Hh});p.errors&&(Object.values(p.errors).forEach(b=>{(!si(b)||b.error)&&s(b)}),p.errors=_v(p.errors,e));let O={},v=new Set(p.matches.filter(b=>d?d.has(b.route.id):b.route.loader!=null).map(b=>b.route.id));if(p.errors)for(let[b,S]of Object.entries(p.errors))O[b]={error:S};for(let[b,S]of Object.entries(p.loaderData))!(b in O)&&v.has(b)&&(O[b]={data:S});return ql(r,n,e,{result:O,headers:g,status:p.statusCode})};var a=l;let c=new Request(i,{headers:r.headers,signal:r.signal}),u=new URL(r.url).searchParams.get("_routes"),d=u?new Set(u.split(",")):null,h=await t.query(c,{requestContext:o,filterMatchesToLoad:p=>!d||d.has(p.route.id),skipLoaderErrorBubbling:!0,unstable_respond:l});return Ir(h)||(h=l(h)),vy(h)?ql(r,n,e,{result:{[Kl]:Kh(h.status,h.headers,n.basename)},headers:h.headers,status:Hh}):h}catch(l){return s(l),ql(r,n,e,{result:{root:{error:l}},headers:new Headers,status:500})}}function ql(n,e,t,{result:r,headers:i,status:o}){let s=new Headers(i);return s.set("X-Remix-Response","yes"),u4.has(o)?new Response(null,{status:o,headers:s}):(s.set("Content-Type","text/x-script"),new Response(Ev(r,n.signal,e.entry.module.streamTimeout,t),{status:o||200,headers:s}))}function Kh(n,e,t){let r=e.get("Location");return t&&(r=vi(r,t)||r),{redirect:r,status:n,revalidate:e.has("X-Remix-Revalidate")||e.has("Set-Cookie"),reload:e.has("X-Remix-Reload-Document"),replace:e.has("X-Remix-Replace")}}function Ev(n,e,t,r){let i=new AbortController,o=setTimeout(()=>i.abort(new Error("Server Timeout")),typeof t=="number"?t:4950);return e.addEventListener("abort",()=>clearTimeout(o)),xJ(n,{signal:i.signal,plugins:[s=>{if(s instanceof Error){let{name:a,message:l,stack:c}=r==="production"?Cy(s,r):s;return["SanitizedError",a,l,c]}if(s instanceof Qo){let{data:a,status:l,statusText:c}=s;return["ErrorResponse",a,l,c]}if(s&&typeof s=="object"&&Kl in s)return["SingleFetchRedirect",s[Kl]]}],postPlugins:[s=>{if(s&&typeof s=="object")return["SingleFetchClassInstance",Object.fromEntries(Object.entries(s))]},()=>["SingleFetchFallback"]]})}function i$(n,e){let t=a4(n.routes),r=l4(n.routes,n.future),i=une(e)?e:"production",o=H3(r,{basename:n.basename}),s=n.entry.module.handleError||((a,{request:l})=>{i!=="test"&&!l.signal.aborted&&console.error(si(a)&&a.error?a.error:a)});return{routes:t,dataRoutes:r,serverMode:i,staticHandler:o,errorHandler:s}}var yne=(n,e)=>{let t,r,i,o,s;return async function(l,c){var x,P,w;t=typeof n=="function"?await n():n;let u=t.future.unstable_middleware?new Ll(c):c||{};if(typeof n=="function"){let E=i$(t,e);r=E.routes,i=E.serverMode,o=E.staticHandler,s=E.errorHandler}else if(!r||!i||!o||!s){let E=i$(t,e);r=E.routes,i=E.serverMode,o=E.staticHandler,s=E.errorHandler}let d=new URL(l.url),h=t.basename||"/",p=d.pathname;vi(p,h)==="/_root.data"?p=h:p.endsWith(".data")&&(p=p.replace(/\.data$/,"")),vi(p,h)!=="/"&&p.endsWith("/")&&(p=p.slice(0,-1));let g={},O=E=>{var M,Q;e==="development"&&((Q=(M=hS())==null?void 0:M.processRequestError)==null||Q.call(M,E)),s(E,{context:u,params:g,request:l})};if(!t.ssr){if(t.prerender.length===0)l.headers.set("X-React-Router-SPA-Mode","yes");else if(!t.prerender.includes(p)&&!t.prerender.includes(p+"/")){if(d.pathname.endsWith(".data"))return s(new Qo(404,"Not Found",`Refusing to SSR the path \`${p}\` because \`ssr:false\` is set and the path is not included in the \`prerender\` config, so in production the path will be a 404.`),{context:u,params:g,request:l}),new Response("Not Found",{status:404,statusText:"Not Found"});l.headers.set("X-React-Router-SPA-Mode","yes")}}let v=`${h}/__manifest`.replace(/\/+/g,"/");if(d.pathname===v)try{return await bne(t,r,d)}catch(E){return O(E),new Response("Unknown Server Error",{status:500})}let b=Zk(r,d.pathname,t.basename);b&&b.length>0&&Object.assign(g,b[0].params);let S;if(d.pathname.endsWith(".data")){let E=new URL(l.url);E.pathname=p;let M=Zk(r,E.pathname,t.basename);if(S=await Sne(i,t,o,l,E,u,O),t.entry.module.handleDataRequest&&(S=await t.entry.module.handleDataRequest(S,{context:u,params:M?M[0].params:{},request:l}),vy(S))){let Q=Kh(S.status,S.headers,t.basename);l.method==="GET"&&(Q={[Kl]:Q});let T=new Headers(S.headers);return T.set("Content-Type","text/x-script"),new Response(Ev(Q,l.signal,t.entry.module.streamTimeout,i),{status:Hh,headers:T})}}else if(!l.headers.has("X-React-Router-SPA-Mode")&&b&&b[b.length-1].route.module.default==null&&b[b.length-1].route.module.ErrorBoundary==null)S=await kne(i,t,o,b.slice(-1)[0].route.id,l,u,O);else{let{pathname:E}=d,M;t.unstable_getCriticalCss?M=await t.unstable_getCriticalCss({pathname:E}):e==="development"&&((x=hS())!=null&&x.getCriticalCss)&&(M=await((w=(P=hS())==null?void 0:P.getCriticalCss)==null?void 0:w.call(P,E))),S=await wne(i,t,o,l,u,O,M)}return l.method==="HEAD"?new Response(null,{headers:S.headers,status:S.status,statusText:S.statusText}):S}};async function bne(n,e,t){if(n.assets.version!==t.searchParams.get("version"))return new Response(null,{status:204,headers:{"X-Remix-Reload-Document":"true"}});let r={};if(t.searchParams.has("p")){let i=new Set;t.searchParams.getAll("p").forEach(o=>{o.startsWith("/")||(o=`/${o}`);let s=o.split("/").slice(1);s.forEach((a,l)=>{let c=s.slice(0,l+1).join("/");i.add(`/${c}`)})});for(let o of i){let s=Zk(e,o,n.basename);if(s)for(let a of s){let l=a.route.id,c=n.assets.routes[l];c&&(r[l]=c)}}return Response.json(r,{headers:{"Cache-Control":"public, max-age=31536000, immutable"}})}return new Response("Invalid Request",{status:400})}async function Sne(n,e,t,r,i,o,s){return r.method!=="GET"?await One(e,n,t,r,i,o,s):await vne(e,n,t,r,i,o,s)}async function wne(n,e,t,r,i,o,s){let a=r.headers.has("X-React-Router-SPA-Mode");try{let c=await t.query(r,{requestContext:i,unstable_respond:e.future.unstable_middleware?u=>l(u,a):void 0});return Ir(c)?c:l(c,a)}catch(c){return o(c),new Response(null,{status:500})}async function l(c,u){if(Ir(c))return c;let d=Gx(e,c);if(u4.has(c.statusCode))return new Response(null,{status:c.statusCode,headers:d});c.errors&&(Object.values(c.errors).forEach(O=>{(!si(O)||O.error)&&o(O)}),c.errors=_v(c.errors,n));let h={loaderData:c.loaderData,actionData:c.actionData,errors:t$(c.errors,n)},p={manifest:e.assets,routeModules:cne(e.routes),staticHandlerContext:c,criticalCss:s,serverHandoffString:r$({basename:e.basename,criticalCss:s,future:e.future,ssr:e.ssr,isSpaMode:u}),serverHandoffStream:Ev(h,r.signal,e.entry.module.streamTimeout,n),renderMeta:{},future:e.future,ssr:e.ssr,isSpaMode:u,serializeError:O=>o4(O,n)},g=e.entry.module.default;try{return await g(r,c.statusCode,d,p,i)}catch(O){o(O);let v=O;if(Ir(O))try{let S=await xne(O);v=new Qo(O.status,O.statusText,S)}catch{}c=K3(t.dataRoutes,c,v),c.errors&&(c.errors=_v(c.errors,n));let b={loaderData:c.loaderData,actionData:c.actionData,errors:t$(c.errors,n)};p={...p,staticHandlerContext:c,serverHandoffString:r$({basename:e.basename,future:e.future,ssr:e.ssr,isSpaMode:u}),serverHandoffStream:Ev(b,r.signal,e.entry.module.streamTimeout,n),renderMeta:{}};try{return await g(r,c.statusCode,d,p,i)}catch(S){return o(S),Xk(S,n)}}}}async function kne(n,e,t,r,i,o,s){try{let a=await t.queryRoute(i,{routeId:r,requestContext:o,unstable_respond:e.future.unstable_middleware?l=>l:void 0});return Ir(a)?a:typeof a=="string"?new Response(a):Response.json(a)}catch(a){if(Ir(a))return a.headers.set("X-Remix-Catch","yes"),a;if(si(a))return a&&s(a),Pne(a,n);if(a instanceof Error&&a.message==="Expected a response from queryRoute"){let l=new Error("Expected a Response to be returned from resource route handler");return s(l),Xk(l,n)}return s(a),Xk(a,n)}}function Pne(n,e){return Response.json(o4(n.error||new Error("Unexpected Server Error"),e),{status:n.status,statusText:n.statusText,headers:{"X-Remix-Error":"yes"}})}function Xk(n,e){let t="Unexpected Server Error";return e!=="production"&&(t+=`
|
|
170
170
|
|
|
171
|
-
${String(n)}`),new Response(t,{status:500,headers:{"Content-Type":"text/plain"}})}function
|
|
171
|
+
${String(n)}`),new Response(t,{status:500,headers:{"Content-Type":"text/plain"}})}function xne(n){let e=n.headers.get("Content-Type");return e&&/\bapplication\/json\b/.test(e)?n.body==null?null:n.json():n.text()}function pS(n){return`__flash_${n}__`}var Hx=(n={},e="")=>{let t=new Map(Object.entries(n));return{get id(){return e},get data(){return Object.fromEntries(t)},has(r){return t.has(r)||t.has(pS(r))},get(r){if(t.has(r))return t.get(r);let i=pS(r);if(t.has(i)){let o=t.get(i);return t.delete(i),o}},set(r,i){t.set(r,i)},flash(r,i){t.set(pS(r),i)},unset(r){t.delete(r)}}},Cne=n=>n!=null&&typeof n.id=="string"&&typeof n.data<"u"&&typeof n.has=="function"&&typeof n.get=="function"&&typeof n.set=="function"&&typeof n.flash=="function"&&typeof n.unset=="function";function f4({cookie:n,createData:e,readData:t,updateData:r,deleteData:i}){let o=Yx(n)?n:zx((n==null?void 0:n.name)||"__session",n);return d4(o),{async getSession(s,a){let l=s&&await o.parse(s,a),c=l&&await t(l);return Hx(c||{},l||"")},async commitSession(s,a){let{id:l,data:c}=s,u=(a==null?void 0:a.maxAge)!=null?new Date(Date.now()+a.maxAge*1e3):(a==null?void 0:a.expires)!=null?a.expires:o.expires;return l?await r(l,c,u):l=await e(c,u),o.serialize(l,a)},async destroySession(s,a){return await i(s.id),o.serialize("",{...a,maxAge:void 0,expires:new Date(0)})}}}function d4(n){xv(n.isSigned,`The "${n.name}" cookie is not signed, but session cookies should be signed to prevent tampering on the client before they are sent back to the server. See https://remix.run/utils/cookies#signing-cookies for more information.`)}function Tne({cookie:n}={}){let e=Yx(n)?n:zx((n==null?void 0:n.name)||"__session",n);return d4(e),{async getSession(t,r){return Hx(t&&await e.parse(t,r)||{})},async commitSession(t,r){let i=await e.serialize(t.data,r);if(i.length>4096)throw new Error("Cookie length will exceed browser maximum. Length: "+i.length);return i},async destroySession(t,r){return e.serialize("",{...r,maxAge:void 0,expires:new Date(0)})}}}function _ne({cookie:n}={}){let e=new Map;return f4({cookie:n,async createData(t,r){let i=Math.random().toString(36).substring(2,10);return e.set(i,{data:t,expires:r}),i},async readData(t){if(e.has(t)){let{data:r,expires:i}=e.get(t);if(!i||i>new Date)return r;i&&e.delete(t)}return null},async updateData(t,r,i){e.set(t,{data:r,expires:i})},async deleteData(t){e.delete(t)}})}function Ene(n,...e){let t=e[0];return n.split("/").map(r=>{const i=r.match(/^:([\w-]+)(\?)?/);if(!i)return r;const o=i[1],s=t?t[o]:void 0;if(i[2]===void 0&&s===void 0)throw Error(`Path '${n}' requires param '${o}' but it was not provided`);return s}).filter(r=>r!==void 0).join("/")}function h4(n){if(!n)return null;let e=Object.entries(n),t={};for(let[r,i]of e)if(i&&i.__type==="RouteErrorResponse")t[r]=new Qo(i.status,i.statusText,i.data,i.internal===!0);else if(i&&i.__type==="Error"){if(i.__subType){let o=window[i.__subType];if(typeof o=="function")try{let s=new o(i.message);s.stack=i.stack,t[r]=s}catch{}}if(t[r]==null){let o=new Error(i.message);o.stack=i.stack,t[r]=o}}else t[r]=i;return t}var p4=rp();const Jm=ss(p4);/**
|
|
172
172
|
* react-router v7.4.1
|
|
173
173
|
*
|
|
174
174
|
* Copyright (c) Remix Software Inc.
|
|
@@ -177,7 +177,7 @@ ${String(n)}`),new Response(t,{status:500,headers:{"Content-Type":"text/plain"}}
|
|
|
177
177
|
* LICENSE.md file in the root directory of this source tree.
|
|
178
178
|
*
|
|
179
179
|
* @license MIT
|
|
180
|
-
*/function
|
|
180
|
+
*/function m4(n){return D.createElement(yq,{flushSync:p4.flushSync,...n})}var Yt=null,Vd=null;function Rne(){!Yt&&window.__reactRouterContext&&window.__reactRouterManifest&&window.__reactRouterRouteModules&&(Yt={context:window.__reactRouterContext,manifest:window.__reactRouterManifest,routeModules:window.__reactRouterRouteModules,stateDecodingPromise:void 0,router:void 0,routerInitialized:!1})}function Ane({unstable_getContext:n}){var s,a;if(Rne(),!Yt)throw new Error("You must be using the SSR features of React Router in order to skip passing a `router` prop to `<RouterProvider>`");let e=Yt;if(!Yt.stateDecodingPromise){let l=Yt.context.stream;zt(l,"No stream found for single fetch decoding"),Yt.context.stream=void 0,Yt.stateDecodingPromise=wy(l,window).then(c=>{Yt.context.state=c.value,e.stateDecodingPromise.value=!0}).catch(c=>{e.stateDecodingPromise.error=c})}if(Yt.stateDecodingPromise.error)throw Yt.stateDecodingPromise.error;if(!Yt.stateDecodingPromise.value)throw Yt.stateDecodingPromise;let t=wp(Yt.manifest.routes,Yt.routeModules,Yt.context.state,Yt.context.ssr,Yt.context.isSpaMode),r,i=Yt.context.state.loaderData;if(Yt.context.isSpaMode)(s=Yt.manifest.routes.root)!=null&&s.hasLoader&&i&&"root"in i&&(r={loaderData:{root:i.root}});else{r={...Yt.context.state,loaderData:{...i}};let l=ho(t,window.location,(a=window.__reactRouterContext)==null?void 0:a.basename);if(l)for(let c of l){let u=c.route.id,d=Yt.routeModules[u],h=Yt.manifest.routes[u];d&&h&&ky(h,d,Yt.context.isSpaMode)&&(d.HydrateFallback||!h.hasLoader)?delete r.loaderData[u]:h&&!h.hasLoader&&(r.loaderData[u]=null)}r&&r.errors&&(r.errors=h4(r.errors))}let o=Op({routes:t,history:dy(),basename:Yt.context.basename,unstable_getContext:n,hydrationData:r,mapRouteProperties:fu,future:{unstable_middleware:Yt.context.future.unstable_middleware},dataStrategy:_q(Yt.manifest,Yt.routeModules,Yt.context.ssr,Yt.context.basename,()=>o),patchRoutesOnNavigation:Qq(Yt.manifest,Yt.routeModules,Yt.context.ssr,Yt.context.isSpaMode,Yt.context.basename)});return Yt.router=o,o.state.initialized&&(Yt.routerInitialized=!0,o.initialize()),o.createRoutesForHMR=$q,window.__reactRouterDataRouter=o,o}function Mne(n){Vd||(Vd=Ane({unstable_getContext:n.unstable_getContext}));let[e,t]=D.useState(void 0),[r,i]=D.useState(Vd.state.location);return D.useLayoutEffect(()=>{Yt&&Yt.router&&!Yt.routerInitialized&&(Yt.routerInitialized=!0,Yt.router.initialize())},[]),D.useLayoutEffect(()=>{if(Yt&&Yt.router)return Yt.router.subscribe(o=>{o.location!==r&&i(o.location)})},[r]),zt(Yt,"ssrInfo unavailable for HydratedRouter"),Iq(Vd,Yt.manifest,Yt.routeModules,Yt.context.ssr,Yt.context.isSpaMode),D.createElement(D.Fragment,null,D.createElement(dc.Provider,{value:{manifest:Yt.manifest,routeModules:Yt.routeModules,future:Yt.context.future,criticalCss:e,ssr:Yt.context.ssr,isSpaMode:Yt.context.isSpaMode}},D.createElement(jx,{location:r},D.createElement(m4,{router:Vd}))),D.createElement(D.Fragment,null))}/**
|
|
181
181
|
* react-router-dom v7.4.1
|
|
182
182
|
*
|
|
183
183
|
* Copyright (c) Remix Software Inc.
|
|
@@ -186,7 +186,7 @@ ${String(n)}`),new Response(t,{status:500,headers:{"Content-Type":"text/plain"}}
|
|
|
186
186
|
* LICENSE.md file in the root directory of this source tree.
|
|
187
187
|
*
|
|
188
188
|
* @license MIT
|
|
189
|
-
*/const
|
|
189
|
+
*/const $ne=Object.freeze(Object.defineProperty({__proto__:null,Await:Bee,BrowserRouter:Uq,Form:Vx,HashRouter:Qte,HydratedRouter:Mne,IDLE_BLOCKER:Rl,IDLE_FETCHER:gy,IDLE_NAVIGATION:kh,Link:Fx,Links:xte,MemoryRouter:Nee,Meta:_te,NavLink:Vq,Navigate:qee,NavigationType:Q3,Outlet:bq,PrefetchPageLinks:Bx,Route:Sq,Router:fc,RouterProvider:m4,Routes:Uee,Scripts:Lq,ScrollRestoration:Wq,ServerRouter:Kte,StaticRouter:Vte,StaticRouterProvider:Hq,UNSAFE_DataRouterContext:Wa,UNSAFE_DataRouterStateContext:lc,UNSAFE_ErrorResponseImpl:Qo,UNSAFE_FetchersContext:yp,UNSAFE_FrameworkContext:dc,UNSAFE_LocationContext:uu,UNSAFE_NavigationContext:vo,UNSAFE_RemixErrorBoundary:jx,UNSAFE_RouteContext:yo,UNSAFE_ServerMode:i4,UNSAFE_SingleFetchRedirectSymbol:Kl,UNSAFE_ViewTransitionContext:vp,UNSAFE_createBrowserHistory:dy,UNSAFE_createClientRoutes:wp,UNSAFE_createClientRoutesWithHMRRevalidationOptOut:$q,UNSAFE_createRouter:Op,UNSAFE_decodeViaTurboStream:wy,UNSAFE_deserializeErrors:h4,UNSAFE_getPatchRoutesOnNavigationFunction:Qq,UNSAFE_getSingleFetchDataStrategy:_q,UNSAFE_invariant:zt,UNSAFE_mapRouteProperties:fu,UNSAFE_shouldHydrateRouteLoader:ky,UNSAFE_useFogOFWarDiscovery:Iq,UNSAFE_useScrollRestoration:Yq,createBrowserRouter:Mte,createCookie:zx,createCookieSessionStorage:Tne,createHashRouter:$te,createMemoryRouter:vq,createMemorySessionStorage:_ne,createPath:Yi,createRequestHandler:yne,createRoutesFromChildren:Gh,createRoutesFromElements:Wee,createRoutesStub:Jte,createSearchParams:Cv,createSession:Hx,createSessionStorage:f4,createStaticHandler:Xte,createStaticRouter:Jq,data:W3,generatePath:WJ,href:Ene,isCookie:Yx,isRouteErrorResponse:si,isSession:Cne,matchPath:Uf,matchRoutes:ho,parsePath:jo,redirect:my,redirectDocument:KJ,renderMatches:Zee,replace:JJ,resolvePath:F3,unstable_HistoryRouter:Bq,unstable_RouterContextProvider:Ll,unstable_createContext:$J,unstable_setDevServerHooks:gne,unstable_usePrompt:Fte,useActionData:Mee,useAsyncError:$ee,useAsyncValue:mq,useBeforeUnload:Ute,useBlocker:gq,useFetcher:Nte,useFetchers:qte,useFormAction:zq,useHref:aq,useInRouterContext:cc,useLinkClickHandler:Xq,useLoaderData:Ree,useLocation:bo,useMatch:yee,useMatches:Rx,useNavigate:yy,useNavigation:pq,useNavigationType:vee,useOutlet:fq,useOutletContext:See,useParams:wee,useResolvedPath:Kf,useRevalidator:Eee,useRouteError:Ax,useRouteLoaderData:Aee,useRoutes:dq,useSearchParams:Ite,useSubmit:Zx,useViewTransitionState:Gq},Symbol.toStringTag,{value:"Module"})),{useSearchParams:Dne}=$ne,Qne=({content:n,openTab:e,setActiveFileId:t,tabList:r,activeFileId:i})=>{const[o,s]=Dne(),a=D.useMemo(()=>({file:o.get("file"),tabs:o.get("tabs")}),[o]),l=D.useRef(!1);D.useEffect(()=>{if(l.current||!n)return;const{tabList:d,activeFileId:h}=gJ({tabStateParams:a,content:n});l.current=!0,d.forEach(e),t(h)},[n,o,t,e,l]);const c=D.useRef(n);D.useEffect(()=>{c.current=n},[n]);const u=D.useRef(s);D.useEffect(()=>{u.current=s},[s]),D.useEffect(()=>{if(!c.current)return;const d=OJ({tabList:r,activeFileId:i,content:c.current});u.current(h=>{const p=new URLSearchParams(h);return d.file?p.set("file",d.file):p.delete("file"),d.tabs?p.set("tabs",d.tabs):p.delete("tabs"),p})},[r,i])},du=(n,e)=>{if(n.id===e)return n;if(n.type==="splitPane")for(const t of n.children){const r=du(t,e);if(r)return r}},Jl=({pane:n,activePaneId:e,newTabList:t,newActiveFileId:r})=>n.type==="splitPane"?{...n,children:n.children.map(i=>Jl({pane:i,activePaneId:e,newTabList:t,newActiveFileId:r}))}:n.id===e?{...n,tabList:t!==void 0?t:n.tabList,activeFileId:r!==void 0?r:n.activeFileId}:n,Ine=(n,e)=>{if(e.type!=="close_tabs")return n;const{pane:t,activePaneId:r}=n,i=du(t,r);if(i.type!=="leafPane")throw new Error("closeTabsReducer: activePane is not a leafPane");const o=i.tabList.filter(l=>!e.fileIdsToClose.includes(l.fileId));if(!e.fileIdsToClose.includes(i.activeFileId))return{...n,pane:Jl({pane:t,activePaneId:r,newTabList:o})};let s=null;const a=i.tabList.findIndex(l=>l.fileId===i.activeFileId);for(let l=a-1;l>=0;l--)if(!e.fileIdsToClose.includes(i.tabList[l].fileId)){s=i.tabList[l].fileId;break}if(!s){for(let l=a+1;l<i.tabList.length;l++)if(!e.fileIdsToClose.includes(i.tabList[l].fileId)){s=i.tabList[l].fileId;break}}return{...n,pane:Jl({pane:t,activePaneId:r,newTabList:o,newActiveFileId:s})}},jne=(n,e)=>{if(e.type!=="open_tab")return n;const{pane:t,activePaneId:r}=n,i=du(t,r);if(i.type!=="leafPane")throw new Error("closeTabsReducer: activePane is not a leafPane");const o=i.tabList.findIndex(h=>h.fileId===e.fileId),s=o!==-1,a=s&&i.tabList[o].isTransient,l=i.tabList.findIndex(h=>h.isTransient&&h.fileId!==e.fileId),c={fileId:e.fileId,isTransient:e.isTransient};let u;s?a?u=i.tabList.map(h=>h.fileId===e.fileId?c:h):u=[...i.tabList]:l!==-1?(u=[...i.tabList],u[l]=c):u=[...i.tabList,c];const d=!e.isTransient;return{...n,pane:Jl({pane:t,activePaneId:r,newTabList:u,newActiveFileId:e.fileId}),editorWantsFocus:d}},Lne=(n,e)=>{if(e.type!=="set_active_file_id")return n;const{pane:t,activePaneId:r}=n;if(du(t,r).type!=="leafPane")throw new Error("closeTabsReducer: activePane is not a leafPane");return{...n,pane:Jl({pane:t,activePaneId:r,newActiveFileId:e.activeFileId})}},Nne=(n,e)=>{if(e.type!=="set_active_file_left")return n;const{pane:t,activePaneId:r}=n,i=du(t,r);if(i.type!=="leafPane")throw new Error("closeTabsReducer: activePane is not a leafPane");let o=i.tabList.findIndex(s=>s.fileId===i.activeFileId);return o-=1,o<0&&(o=i.tabList.length-1),{...n,pane:Jl({pane:t,activePaneId:r,newActiveFileId:i.tabList[o].fileId})}},qne=(n,e)=>{if(e.type!=="set_active_file_right")return n;const{pane:t,activePaneId:r}=n,i=du(t,r);if(i.type!=="leafPane")throw new Error("closeTabsReducer: activePane is not a leafPane");let o=i.tabList.findIndex(s=>s.fileId===i.activeFileId);return o+=1,o>i.tabList.length-1&&(o=0),{...n,pane:Jl({pane:t,activePaneId:r,newActiveFileId:i.tabList[o].fileId})}},Une=(n,e)=>e.type==="set_is_settings_open"?{...n,isSettingsOpen:e.value}:n,Bne=(n,e)=>e.type==="set_is_doc_open"?{...n,isDocOpen:e.value}:n,Fne=(n,e)=>e.type==="set_theme"?{...n,theme:e.themeLabel}:n,Vne=(n,e)=>e.type==="editor_no_longer_wants_focus"?{...n,editorWantsFocus:!1}:n,Wne=(n,e)=>e.type==="set_username"?{...n,username:e.username}:n;function Zne(n,e){const t=n.data.files,r=Object.keys(n.data.files);let i={};for(let o=0;o<r.length;o++){const s=t[r[o]];if(t[r[o]].text){const a=s.name,l=s.text.split(`
|
|
190
190
|
`),c=[];for(let u=0;u<l.length;u++){const d=l[u].indexOf(e);d!==-1&&c.push({line:u+1,index:d,text:l[u],isClosed:!1})}c.length>0&&(i[r[o]]={name:a,matches:c,visibility:"open"})}}return i}function Xne(n,e,t){return{...n,[e]:{...n[e],visibility:t}}}const zne=(n,e)=>e.type==="set_is_search_open"?{...n,isSearchOpen:e.value}:n,Yne=(n,e)=>e.type==="set_search"?{...n,search:{...n.search,pattern:e.value,results:{},focusedIndex:0,focusedChildIndex:null,focused:!0}}:n,Gne=(n,e)=>e.type==="set_search_results"?{...n,search:{...n.search,pattern:n.search.pattern,results:Zne(e.files,n.search.pattern),focused:n.search.focused}}:n,Hne=(n,e)=>e.type==="set_search_file_visibility"?{...n,search:{...n.search,pattern:n.search.pattern,results:Xne(n.search.results,e.id,e.visibility)}}:n,Kne=(n,e)=>e.type==="hide_search_results_line"?{...n,search:{...n.search,results:{...n.search.results,[e.id]:{...n.search.results[e.id],matches:n.search.results[e.id].matches.filter((t,r)=>t.line!==e.line)}}}}:n,Jne=(n,e)=>e.type==="set_active_search_index"?{...n,search:{...n.search,focusedIndex:e.focusedIndex,focusedChildIndex:e.childIndex}}:n,ere=(n,e)=>e.type==="toggle_search_focused"?{...n,search:{...n.search,focused:!n.search.focused}}:n,tre=(n,e)=>e.type==="toggle_auto_follow"?{...n,enableAutoFollow:!n.enableAutoFollow}:n,nre=(n,e)=>{if(e.type==="update_presence_indicator"){const t=n.sidebarPresenceIndicators.find(r=>r.username===e.presenceIndicator.username);return{...n,sidebarPresenceIndicators:t?n.sidebarPresenceIndicators.map(r=>r.username===e.presenceIndicator.username?e.presenceIndicator:r):[...n.sidebarPresenceIndicators,e.presenceIndicator]}}return n},rre=(n,e)=>{if(e.type!=="split_current_pane")return n;const t=n.activePaneId,r={id:`${t}-1`,type:"leafPane",tabList:[],activeFileId:null},i={id:`${t}-2`,type:"leafPane",tabList:[],activeFileId:null},o={id:t,type:"splitPane",orientation:"horizontal",children:[r,i]},s=Jl({pane:n.pane,activePaneId:t,newTabList:void 0,newActiveFileId:void 0}),a=(c,u)=>c.id===u?o:c.type==="splitPane"?{...c,children:c.children.map(d=>a(d,u))}:c,l=a(s,t);return{...n,pane:l,activePaneId:r.id}},ire=({defaultTheme:n,initialUsername:e="Anonymous"})=>({pane:{id:"root",type:"leafPane",tabList:[],activeFileId:null},activePaneId:"root",theme:n,search:{pattern:"",results:{},focused:!1,focusedIndex:null,focusedChildIndex:null},isSearchOpen:!1,isSettingsOpen:!1,isDocOpen:!1,editorWantsFocus:!1,username:e,enableAutoFollow:!0,sidebarPresenceIndicators:[]}),ore=[Lne,Nne,qne,jne,Ine,Fne,Yne,Gne,Hne,Kne,Jne,ere,zne,Une,Bne,Vne,Wne,tre,nre,rre],sre=(n,e)=>ore.reduce((t,r)=>r(t,e),n),li=D.createContext(null),are=({content:n,shareDBDoc:e,submitOperation:t,localPresence:r,docPresence:i,prettierWorker:o,typeScriptWorker:s,initialUsername:a,children:l,codeError:c=null,connected:u,pending:d,liveKitToken:h,setLiveKitToken:p,liveKitRoomName:g,setLiveKitRoom:O,liveKitConnection:v,setLiveKitConnection:b})=>{const{prettierError:S,runPrettierRef:x}=fJ({shareDBDoc:e,submitOperation:t,prettierWorker:o}),P=dJ(t),w=D.useRef(null),E=D.useRef(null),M=S||c;mJ({content:n,typeScriptWorker:s});const[Q,T]=D.useReducer(sre,{defaultTheme:KK,initialUsername:a},ire),{pane:R,activePaneId:$,theme:I,search:B,isSearchOpen:H,isSettingsOpen:oe,isDocOpen:F,editorWantsFocus:Z,username:W,enableAutoFollow:te,sidebarPresenceIndicators:ie}=Q,K=du(R,$);if(K.type!=="leafPane")throw new Error("Expected leafPane");const{setActiveFileId:se,setActiveFileLeft:ee,setActiveFileRight:le,openTab:ge,closeTabs:Le,setTheme:L,setIsSearchOpen:V,setSearch:z,setSearchResults:pe,setSearchFileVisibility:_e,setSearchLineVisibility:Me,setSearchFocusedIndex:Ce,toggleSearchFocused:Ne,setIsSettingsOpen:st,setIsDocOpen:wt,closeSettings:un,closeDoc:Vn,editorNoLongerWantsFocus:Sn,setUsername:wn,toggleAutoFollow:kn,updatePresenceIndicator:Cn,splitCurrentPane:j}=eJ(T);Qne({content:n,openTab:ge,setActiveFileId:se,tabList:K.tabList,activeFileId:K.activeFileId});const{isDirectoryOpen:ve,toggleDirectory:Fe}=lJ(),He=tJ();JK(He,I);const{createFile:Je,renameFile:it,deleteFile:Dt,createDirectory:kt,renameDirectory:qe,deleteDirectory:lt}=rJ({submitOperation:t,closeTabs:Le,openTab:ge}),[nt,rt]=D.useState(!1),mt=D.useCallback(()=>{rt(!0)},[]),vt=D.useCallback(()=>{rt(!1)},[]),Bt=D.useCallback(ye=>{Je(ye),rt(!1)},[Je,rt]),[Xe,bt]=D.useState(!1),en=D.useCallback(()=>{bt(!0)},[]),Pt=D.useCallback(()=>{bt(!1)},[]),Ft=D.useCallback(ye=>{kt(ye),bt(!1)},[kt,bt]),hn=n?n.files:null;aJ({closeTabs:Le,activeFileId:K.activeFileId,activePaneId:$,handleOpenCreateFileModal:mt,setActiveFileLeft:ee,setActiveFileRight:le,toggleSearchFocused:Ne,runPrettierRef:x,runCodeRef:P,sidebarRef:w,editorCache:He,codeEditorRef:E});const[Pn,Tn]=D.useState(null),[En,re]=D.useState(!1),de={content:n,shareDBDoc:e,submitOperation:t,localPresence:r,docPresence:i,files:hn,createFile:Je,renameFile:it,deleteFile:Dt,createDirectory:kt,renameDirectory:qe,deleteDirectory:lt,setActiveFileId:se,setActiveFileLeft:ee,setActiveFileRight:le,activePaneId:$,pane:R,activePane:K,openTab:ge,closeTabs:Le,search:B,isSearchOpen:H,setIsSearchOpen:V,setSearch:z,setSearchResults:pe,setSearchFileVisibility:_e,setSearchLineVisibility:Me,setSearchFocusedIndex:Ce,toggleSearchFocused:Ne,isSettingsOpen:oe,setIsSettingsOpen:st,closeSettings:un,isDocOpen:F,setIsDocOpen:wt,closeDoc:Vn,theme:I,setTheme:L,username:W,setUsername:wn,isDirectoryOpen:ve,toggleDirectory:Fe,editorCache:He,editorWantsFocus:Z,editorNoLongerWantsFocus:Sn,errorMessage:M,typeScriptWorker:s,isCreateFileModalOpen:nt,handleOpenCreateFileModal:mt,handleCloseCreateFileModal:vt,handleCreateFileClick:Bt,isCreateDirModalOpen:Xe,handleOpenCreateDirModal:en,handleCloseCreateDirModal:Pt,handleCreateDirClick:Ft,runPrettierRef:x,runCodeRef:P,sidebarRef:w,codeEditorRef:E,connected:u,pending:d,hoveredItemId:Pn,setHoveredItemId:Tn,enableAutoFollow:te,toggleAutoFollow:kn,updatePresenceIndicator:Cn,sidebarPresenceIndicators:ie,splitCurrentPane:j,liveKitRoomName:g,setLiveKitRoom:O,liveKitToken:h,setLiveKitToken:p,liveKitConnection:v,setLiveKitConnection:b,voiceChatModalOpen:En,setVoiceChatModalOpen:re};return q.jsx(li.Provider,{value:de,children:l})},g4=!1;var eg={exports:{}},mS={exports:{}},o$;function $n(){return o$||(o$=1,function(n){function e(t){return t&&t.__esModule?t:{default:t}}n.exports=e,n.exports.__esModule=!0,n.exports.default=n.exports}(mS)),mS.exports}var gS={exports:{}};/*!
|
|
191
191
|
Copyright (c) 2018 Jed Watson.
|
|
192
192
|
Licensed under the MIT License (MIT), see
|
|
@@ -231,4 +231,4 @@ https://fb.me/react-async-component-lifecycle-hooks`)}if(typeof n.getDerivedStat
|
|
|
231
231
|
`,O),v==-1&&(v=p.length-1);var S=p.substring(O,v+1);(l.hasOwnProperty?l.hasOwnProperty(S):l[S]!==void 0)?g+=String.fromCharCode(l[S]):(b==u&&(S=p.substring(O),v=p.length),g+=String.fromCharCode(b),l[S]=b,a[b++]=S),O=v+1}return g}var u=4e4,d=c(o);u=65535;var h=c(s);return{chars1:d,chars2:h,lineArray:a}},e.prototype.diff_charsToLines_=function(o,s){for(var a=0;a<o.length;a++){for(var l=o[a][1],c=[],u=0;u<l.length;u++)c[u]=s[l.charCodeAt(u)];o[a][1]=c.join("")}},e.prototype.diff_commonPrefix=function(o,s){if(!o||!s||o.charAt(0)!=s.charAt(0))return 0;for(var a=0,l=Math.min(o.length,s.length),c=l,u=0;a<c;)o.substring(u,c)==s.substring(u,c)?(a=c,u=a):l=c,c=Math.floor((l-a)/2+a);return c},e.prototype.diff_commonSuffix=function(o,s){if(!o||!s||o.charAt(o.length-1)!=s.charAt(s.length-1))return 0;for(var a=0,l=Math.min(o.length,s.length),c=l,u=0;a<c;)o.substring(o.length-c,o.length-u)==s.substring(s.length-c,s.length-u)?(a=c,u=a):l=c,c=Math.floor((l-a)/2+a);return c},e.prototype.diff_commonOverlap_=function(o,s){var a=o.length,l=s.length;if(a==0||l==0)return 0;a>l?o=o.substring(a-l):a<l&&(s=s.substring(0,a));var c=Math.min(a,l);if(o==s)return c;for(var u=0,d=1;;){var h=o.substring(c-d),p=s.indexOf(h);if(p==-1)return u;d+=p,(p==0||o.substring(c-d)==s.substring(0,d))&&(u=d,d++)}},e.prototype.diff_halfMatch_=function(o,s){if(this.Diff_Timeout<=0)return null;var a=o.length>s.length?o:s,l=o.length>s.length?s:o;if(a.length<4||l.length*2<a.length)return null;var c=this;function u(x,P,w){for(var E=x.substring(w,w+Math.floor(x.length/4)),M=-1,Q="",T,R,$,I;(M=P.indexOf(E,M+1))!=-1;){var B=c.diff_commonPrefix(x.substring(w),P.substring(M)),H=c.diff_commonSuffix(x.substring(0,w),P.substring(0,M));Q.length<H+B&&(Q=P.substring(M-H,M)+P.substring(M,M+B),T=x.substring(0,w-H),R=x.substring(w+B),$=P.substring(0,M-H),I=P.substring(M+B))}return Q.length*2>=x.length?[T,R,$,I,Q]:null}var d=u(a,l,Math.ceil(a.length/4)),h=u(a,l,Math.ceil(a.length/2)),p;if(!d&&!h)return null;h?d?p=d[4].length>h[4].length?d:h:p=h:p=d;var g,O,v,b;o.length>s.length?(g=p[0],O=p[1],v=p[2],b=p[3]):(v=p[0],b=p[1],g=p[2],O=p[3]);var S=p[4];return[g,O,v,b,S]},e.prototype.diff_cleanupSemantic=function(o){for(var s=!1,a=[],l=0,c=null,u=0,d=0,h=0,p=0,g=0;u<o.length;)o[u][0]==i?(a[l++]=u,d=p,h=g,p=0,g=0,c=o[u][1]):(o[u][0]==r?p+=o[u][1].length:g+=o[u][1].length,c&&c.length<=Math.max(d,h)&&c.length<=Math.max(p,g)&&(o.splice(a[l-1],0,new e.Diff(t,c)),o[a[l-1]+1][0]=r,l--,l--,u=l>0?a[l-1]:-1,d=0,h=0,p=0,g=0,c=null,s=!0)),u++;for(s&&this.diff_cleanupMerge(o),this.diff_cleanupSemanticLossless(o),u=1;u<o.length;){if(o[u-1][0]==t&&o[u][0]==r){var O=o[u-1][1],v=o[u][1],b=this.diff_commonOverlap_(O,v),S=this.diff_commonOverlap_(v,O);b>=S?(b>=O.length/2||b>=v.length/2)&&(o.splice(u,0,new e.Diff(i,v.substring(0,b))),o[u-1][1]=O.substring(0,O.length-b),o[u+1][1]=v.substring(b),u++):(S>=O.length/2||S>=v.length/2)&&(o.splice(u,0,new e.Diff(i,O.substring(0,S))),o[u-1][0]=r,o[u-1][1]=v.substring(0,v.length-S),o[u+1][0]=t,o[u+1][1]=O.substring(S),u++),u++}u++}},e.prototype.diff_cleanupSemanticLossless=function(o){function s(S,x){if(!S||!x)return 6;var P=S.charAt(S.length-1),w=x.charAt(0),E=P.match(e.nonAlphaNumericRegex_),M=w.match(e.nonAlphaNumericRegex_),Q=E&&P.match(e.whitespaceRegex_),T=M&&w.match(e.whitespaceRegex_),R=Q&&P.match(e.linebreakRegex_),$=T&&w.match(e.linebreakRegex_),I=R&&S.match(e.blanklineEndRegex_),B=$&&x.match(e.blanklineStartRegex_);return I||B?5:R||$?4:E&&!Q&&T?3:Q||T?2:E||M?1:0}for(var a=1;a<o.length-1;){if(o[a-1][0]==i&&o[a+1][0]==i){var l=o[a-1][1],c=o[a][1],u=o[a+1][1],d=this.diff_commonSuffix(l,c);if(d){var h=c.substring(c.length-d);l=l.substring(0,l.length-d),c=h+c.substring(0,c.length-d),u=h+u}for(var p=l,g=c,O=u,v=s(l,c)+s(c,u);c.charAt(0)===u.charAt(0);){l+=c.charAt(0),c=c.substring(1)+u.charAt(0),u=u.substring(1);var b=s(l,c)+s(c,u);b>=v&&(v=b,p=l,g=c,O=u)}o[a-1][1]!=p&&(p?o[a-1][1]=p:(o.splice(a-1,1),a--),o[a][1]=g,O?o[a+1][1]=O:(o.splice(a+1,1),a--))}a++}},e.nonAlphaNumericRegex_=/[^a-zA-Z0-9]/,e.whitespaceRegex_=/\s/,e.linebreakRegex_=/[\r\n]/,e.blanklineEndRegex_=/\n\r?\n$/,e.blanklineStartRegex_=/^\r?\n\r?\n/,e.prototype.diff_cleanupEfficiency=function(o){for(var s=!1,a=[],l=0,c=null,u=0,d=!1,h=!1,p=!1,g=!1;u<o.length;)o[u][0]==i?(o[u][1].length<this.Diff_EditCost&&(p||g)?(a[l++]=u,d=p,h=g,c=o[u][1]):(l=0,c=null),p=g=!1):(o[u][0]==t?g=!0:p=!0,c&&(d&&h&&p&&g||c.length<this.Diff_EditCost/2&&d+h+p+g==3)&&(o.splice(a[l-1],0,new e.Diff(t,c)),o[a[l-1]+1][0]=r,l--,c=null,d&&h?(p=g=!0,l=0):(l--,u=l>0?a[l-1]:-1,p=g=!1),s=!0)),u++;s&&this.diff_cleanupMerge(o)},e.prototype.diff_cleanupMerge=function(o){o.push(new e.Diff(i,""));for(var s=0,a=0,l=0,c="",u="",d;s<o.length;)switch(o[s][0]){case r:l++,u+=o[s][1],s++;break;case t:a++,c+=o[s][1],s++;break;case i:a+l>1?(a!==0&&l!==0&&(d=this.diff_commonPrefix(u,c),d!==0&&(s-a-l>0&&o[s-a-l-1][0]==i?o[s-a-l-1][1]+=u.substring(0,d):(o.splice(0,0,new e.Diff(i,u.substring(0,d))),s++),u=u.substring(d),c=c.substring(d)),d=this.diff_commonSuffix(u,c),d!==0&&(o[s][1]=u.substring(u.length-d)+o[s][1],u=u.substring(0,u.length-d),c=c.substring(0,c.length-d))),s-=a+l,o.splice(s,a+l),c.length&&(o.splice(s,0,new e.Diff(t,c)),s++),u.length&&(o.splice(s,0,new e.Diff(r,u)),s++),s++):s!==0&&o[s-1][0]==i?(o[s-1][1]+=o[s][1],o.splice(s,1)):s++,l=0,a=0,c="",u="";break}o[o.length-1][1]===""&&o.pop();var h=!1;for(s=1;s<o.length-1;)o[s-1][0]==i&&o[s+1][0]==i&&(o[s][1].substring(o[s][1].length-o[s-1][1].length)==o[s-1][1]?(o[s][1]=o[s-1][1]+o[s][1].substring(0,o[s][1].length-o[s-1][1].length),o[s+1][1]=o[s-1][1]+o[s+1][1],o.splice(s-1,1),h=!0):o[s][1].substring(0,o[s+1][1].length)==o[s+1][1]&&(o[s-1][1]+=o[s+1][1],o[s][1]=o[s][1].substring(o[s+1][1].length)+o[s+1][1],o.splice(s+1,1),h=!0)),s++;h&&this.diff_cleanupMerge(o)},e.prototype.diff_xIndex=function(o,s){var a=0,l=0,c=0,u=0,d;for(d=0;d<o.length&&(o[d][0]!==r&&(a+=o[d][1].length),o[d][0]!==t&&(l+=o[d][1].length),!(a>s));d++)c=a,u=l;return o.length!=d&&o[d][0]===t?u:u+(s-c)},e.prototype.diff_prettyHtml=function(o){for(var s=[],a=/&/g,l=/</g,c=/>/g,u=/\n/g,d=0;d<o.length;d++){var h=o[d][0],p=o[d][1],g=p.replace(a,"&").replace(l,"<").replace(c,">").replace(u,"¶<br>");switch(h){case r:s[d]='<ins style="background:#e6ffe6;">'+g+"</ins>";break;case t:s[d]='<del style="background:#ffe6e6;">'+g+"</del>";break;case i:s[d]="<span>"+g+"</span>";break}}return s.join("")},e.prototype.diff_text1=function(o){for(var s=[],a=0;a<o.length;a++)o[a][0]!==r&&(s[a]=o[a][1]);return s.join("")},e.prototype.diff_text2=function(o){for(var s=[],a=0;a<o.length;a++)o[a][0]!==t&&(s[a]=o[a][1]);return s.join("")},e.prototype.diff_levenshtein=function(o){for(var s=0,a=0,l=0,c=0;c<o.length;c++){var u=o[c][0],d=o[c][1];switch(u){case r:a+=d.length;break;case t:l+=d.length;break;case i:s+=Math.max(a,l),a=0,l=0;break}}return s+=Math.max(a,l),s},e.prototype.diff_toDelta=function(o){for(var s=[],a=0;a<o.length;a++)switch(o[a][0]){case r:s[a]="+"+encodeURI(o[a][1]);break;case t:s[a]="-"+o[a][1].length;break;case i:s[a]="="+o[a][1].length;break}return s.join(" ").replace(/%20/g," ")},e.prototype.diff_fromDelta=function(o,s){for(var a=[],l=0,c=0,u=s.split(/\t/g),d=0;d<u.length;d++){var h=u[d].substring(1);switch(u[d].charAt(0)){case"+":try{a[l++]=new e.Diff(r,decodeURI(h))}catch{throw new Error("Illegal escape in diff_fromDelta: "+h)}break;case"-":case"=":var p=parseInt(h,10);if(isNaN(p)||p<0)throw new Error("Invalid number in diff_fromDelta: "+h);var g=o.substring(c,c+=p);u[d].charAt(0)=="="?a[l++]=new e.Diff(i,g):a[l++]=new e.Diff(t,g);break;default:if(u[d])throw new Error("Invalid diff operation in diff_fromDelta: "+u[d])}}if(c!=o.length)throw new Error("Delta length ("+c+") does not equal source text length ("+o.length+").");return a},e.prototype.match_main=function(o,s,a){if(o==null||s==null||a==null)throw new Error("Null input. (match_main)");return a=Math.max(0,Math.min(a,o.length)),o==s?0:o.length?o.substring(a,a+s.length)==s?a:this.match_bitap_(o,s,a):-1},e.prototype.match_bitap_=function(o,s,a){if(s.length>this.Match_MaxBits)throw new Error("Pattern too long for this browser.");var l=this.match_alphabet_(s),c=this;function u(T,R){var $=T/s.length,I=Math.abs(a-R);return c.Match_Distance?$+I/c.Match_Distance:I?1:$}var d=this.Match_Threshold,h=o.indexOf(s,a);h!=-1&&(d=Math.min(u(0,h),d),h=o.lastIndexOf(s,a+s.length),h!=-1&&(d=Math.min(u(0,h),d)));var p=1<<s.length-1;h=-1;for(var g,O,v=s.length+o.length,b,S=0;S<s.length;S++){for(g=0,O=v;g<O;)u(S,a+O)<=d?g=O:v=O,O=Math.floor((v-g)/2+g);v=O;var x=Math.max(1,a-O+1),P=Math.min(a+O,o.length)+s.length,w=Array(P+2);w[P+1]=(1<<S)-1;for(var E=P;E>=x;E--){var M=l[o.charAt(E-1)];if(S===0?w[E]=(w[E+1]<<1|1)&M:w[E]=(w[E+1]<<1|1)&M|((b[E+1]|b[E])<<1|1)|b[E+1],w[E]&p){var Q=u(S,E-1);if(Q<=d)if(d=Q,h=E-1,h>a)x=Math.max(1,2*a-h);else break}}if(u(S+1,a)>d)break;b=w}return h},e.prototype.match_alphabet_=function(o){for(var s={},a=0;a<o.length;a++)s[o.charAt(a)]=0;for(var a=0;a<o.length;a++)s[o.charAt(a)]|=1<<o.length-a-1;return s},e.prototype.patch_addContext_=function(o,s){if(s.length!=0){if(o.start2===null)throw Error("patch not initialized");for(var a=s.substring(o.start2,o.start2+o.length1),l=0;s.indexOf(a)!=s.lastIndexOf(a)&&a.length<this.Match_MaxBits-this.Patch_Margin-this.Patch_Margin;)l+=this.Patch_Margin,a=s.substring(o.start2-l,o.start2+o.length1+l);l+=this.Patch_Margin;var c=s.substring(o.start2-l,o.start2);c&&o.diffs.unshift(new e.Diff(i,c));var u=s.substring(o.start2+o.length1,o.start2+o.length1+l);u&&o.diffs.push(new e.Diff(i,u)),o.start1-=c.length,o.start2-=c.length,o.length1+=c.length+u.length,o.length2+=c.length+u.length}},e.prototype.patch_make=function(o,s,a){var l,c;if(typeof o=="string"&&typeof s=="string"&&typeof a>"u")l=o,c=this.diff_main(l,s,!0),c.length>2&&(this.diff_cleanupSemantic(c),this.diff_cleanupEfficiency(c));else if(o&&typeof o=="object"&&typeof s>"u"&&typeof a>"u")c=o,l=this.diff_text1(c);else if(typeof o=="string"&&s&&typeof s=="object"&&typeof a>"u")l=o,c=s;else if(typeof o=="string"&&typeof s=="string"&&a&&typeof a=="object")l=o,c=a;else throw new Error("Unknown call format to patch_make.");if(c.length===0)return[];for(var u=[],d=new e.patch_obj,h=0,p=0,g=0,O=l,v=l,b=0;b<c.length;b++){var S=c[b][0],x=c[b][1];switch(!h&&S!==i&&(d.start1=p,d.start2=g),S){case r:d.diffs[h++]=c[b],d.length2+=x.length,v=v.substring(0,g)+x+v.substring(g);break;case t:d.length1+=x.length,d.diffs[h++]=c[b],v=v.substring(0,g)+v.substring(g+x.length);break;case i:x.length<=2*this.Patch_Margin&&h&&c.length!=b+1?(d.diffs[h++]=c[b],d.length1+=x.length,d.length2+=x.length):x.length>=2*this.Patch_Margin&&h&&(this.patch_addContext_(d,O),u.push(d),d=new e.patch_obj,h=0,O=v,p=g);break}S!==r&&(p+=x.length),S!==t&&(g+=x.length)}return h&&(this.patch_addContext_(d,O),u.push(d)),u},e.prototype.patch_deepCopy=function(o){for(var s=[],a=0;a<o.length;a++){var l=o[a],c=new e.patch_obj;c.diffs=[];for(var u=0;u<l.diffs.length;u++)c.diffs[u]=new e.Diff(l.diffs[u][0],l.diffs[u][1]);c.start1=l.start1,c.start2=l.start2,c.length1=l.length1,c.length2=l.length2,s[a]=c}return s},e.prototype.patch_apply=function(o,s){if(o.length==0)return[s,[]];o=this.patch_deepCopy(o);var a=this.patch_addPadding(o);s=a+s+a,this.patch_splitMax(o);for(var l=0,c=[],u=0;u<o.length;u++){var d=o[u].start2+l,h=this.diff_text1(o[u].diffs),p,g=-1;if(h.length>this.Match_MaxBits?(p=this.match_main(s,h.substring(0,this.Match_MaxBits),d),p!=-1&&(g=this.match_main(s,h.substring(h.length-this.Match_MaxBits),d+h.length-this.Match_MaxBits),(g==-1||p>=g)&&(p=-1))):p=this.match_main(s,h,d),p==-1)c[u]=!1,l-=o[u].length2-o[u].length1;else{c[u]=!0,l=p-d;var O;if(g==-1?O=s.substring(p,p+h.length):O=s.substring(p,g+this.Match_MaxBits),h==O)s=s.substring(0,p)+this.diff_text2(o[u].diffs)+s.substring(p+h.length);else{var v=this.diff_main(h,O,!1);if(h.length>this.Match_MaxBits&&this.diff_levenshtein(v)/h.length>this.Patch_DeleteThreshold)c[u]=!1;else{this.diff_cleanupSemanticLossless(v);for(var b=0,S,x=0;x<o[u].diffs.length;x++){var P=o[u].diffs[x];P[0]!==i&&(S=this.diff_xIndex(v,b)),P[0]===r?s=s.substring(0,p+S)+P[1]+s.substring(p+S):P[0]===t&&(s=s.substring(0,p+S)+s.substring(p+this.diff_xIndex(v,b+P[1].length))),P[0]!==t&&(b+=P[1].length)}}}}}return s=s.substring(a.length,s.length-a.length),[s,c]},e.prototype.patch_addPadding=function(o){for(var s=this.Patch_Margin,a="",l=1;l<=s;l++)a+=String.fromCharCode(l);for(var l=0;l<o.length;l++)o[l].start1+=s,o[l].start2+=s;var c=o[0],u=c.diffs;if(u.length==0||u[0][0]!=i)u.unshift(new e.Diff(i,a)),c.start1-=s,c.start2-=s,c.length1+=s,c.length2+=s;else if(s>u[0][1].length){var d=s-u[0][1].length;u[0][1]=a.substring(u[0][1].length)+u[0][1],c.start1-=d,c.start2-=d,c.length1+=d,c.length2+=d}if(c=o[o.length-1],u=c.diffs,u.length==0||u[u.length-1][0]!=i)u.push(new e.Diff(i,a)),c.length1+=s,c.length2+=s;else if(s>u[u.length-1][1].length){var d=s-u[u.length-1][1].length;u[u.length-1][1]+=a.substring(0,d),c.length1+=d,c.length2+=d}return a},e.prototype.patch_splitMax=function(o){for(var s=this.Match_MaxBits,a=0;a<o.length;a++)if(!(o[a].length1<=s)){var l=o[a];o.splice(a--,1);for(var c=l.start1,u=l.start2,d="";l.diffs.length!==0;){var h=new e.patch_obj,p=!0;for(h.start1=c-d.length,h.start2=u-d.length,d!==""&&(h.length1=h.length2=d.length,h.diffs.push(new e.Diff(i,d)));l.diffs.length!==0&&h.length1<s-this.Patch_Margin;){var g=l.diffs[0][0],O=l.diffs[0][1];g===r?(h.length2+=O.length,u+=O.length,h.diffs.push(l.diffs.shift()),p=!1):g===t&&h.diffs.length==1&&h.diffs[0][0]==i&&O.length>2*s?(h.length1+=O.length,c+=O.length,p=!1,h.diffs.push(new e.Diff(g,O)),l.diffs.shift()):(O=O.substring(0,s-h.length1-this.Patch_Margin),h.length1+=O.length,c+=O.length,g===i?(h.length2+=O.length,u+=O.length):p=!1,h.diffs.push(new e.Diff(g,O)),O==l.diffs[0][1]?l.diffs.shift():l.diffs[0][1]=l.diffs[0][1].substring(O.length))}d=this.diff_text2(h.diffs),d=d.substring(d.length-this.Patch_Margin);var v=this.diff_text1(l.diffs).substring(0,this.Patch_Margin);v!==""&&(h.length1+=v.length,h.length2+=v.length,h.diffs.length!==0&&h.diffs[h.diffs.length-1][0]===i?h.diffs[h.diffs.length-1][1]+=v:h.diffs.push(new e.Diff(i,v))),p||o.splice(++a,0,h)}}},e.prototype.patch_toText=function(o){for(var s=[],a=0;a<o.length;a++)s[a]=o[a];return s.join("")},e.prototype.patch_fromText=function(o){var s=[];if(!o)return s;for(var a=o.split(`
|
|
232
232
|
`),l=0,c=/^@@ -(\d+),?(\d*) \+(\d+),?(\d*) @@$/;l<a.length;){var u=a[l].match(c);if(!u)throw new Error("Invalid patch string: "+a[l]);var d=new e.patch_obj;for(s.push(d),d.start1=parseInt(u[1],10),u[2]===""?(d.start1--,d.length1=1):u[2]=="0"?d.length1=0:(d.start1--,d.length1=parseInt(u[2],10)),d.start2=parseInt(u[3],10),u[4]===""?(d.start2--,d.length2=1):u[4]=="0"?d.length2=0:(d.start2--,d.length2=parseInt(u[4],10)),l++;l<a.length;){var h=a[l].charAt(0);try{var p=decodeURI(a[l].substring(1))}catch{throw new Error("Illegal escape in patch_fromText: "+p)}if(h=="-")d.diffs.push(new e.Diff(t,p));else if(h=="+")d.diffs.push(new e.Diff(r,p));else if(h==" ")d.diffs.push(new e.Diff(i,p));else{if(h=="@")break;if(h!=="")throw new Error('Invalid patch mode "'+h+'" in: '+p)}l++}}return s},e.patch_obj=function(){this.diffs=[],this.start1=null,this.start2=null,this.length1=0,this.length2=0},e.patch_obj.prototype.toString=function(){var o,s;this.length1===0?o=this.start1+",0":this.length1==1?o=this.start1+1:o=this.start1+1+","+this.length1,this.length2===0?s=this.start2+",0":this.length2==1?s=this.start2+1:s=this.start2+1+","+this.length2;for(var a=["@@ -"+o+" +"+s+` @@
|
|
233
233
|
`],l,c=0;c<this.diffs.length;c++){switch(this.diffs[c][0]){case r:l="+";break;case t:l="-";break;case i:l=" ";break}a[c+1]=l+encodeURI(this.diffs[c][1])+`
|
|
234
|
-
`}return a.join("").replace(/%20/g," ")},n.exports=e,n.exports.diff_match_patch=e,n.exports.DIFF_DELETE=t,n.exports.DIFF_INSERT=r,n.exports.DIFF_EQUAL=i}(zw)),zw.exports}var wde=Sde();const kde=ss(wde),Pde=(n,e)=>bde(n,e,kde,cP,lI),xde=n=>D.useCallback(t=>{const r=n.data,i=Pde(r,t(r));i&&n&&n.submitOp(i)},[n]),Cde=1e3,Tde=n=>{const e=D.useRef(),[t,r]=D.useState(!1),i=D.useCallback(()=>{n&&n.whenNothingPending(()=>{r(!1)})},[n,r]);return D.useEffect(()=>{n&&n.on("before op",()=>{r(!0),clearTimeout(e.current),e.current=setTimeout(()=>{i()},Cde)})},[n,i]),t},_de=({connection:n})=>{const[e,t]=D.useState(null),[r,i]=D.useState(null),[o,s]=D.useState(null),[a,l]=D.useState(null),[c,u]=D.useState(!1);D.useEffect(()=>{n.on("connected",()=>{u(!0)}),n.on("disconnected",()=>{u(!1)});const p="documents",g="1",O=n.get(p,g);return O.subscribe(()=>{t(O),l(O.data),O.on("op",()=>{l(O.data)});const v=n.getDocPresence(p,g);v.subscribe(function(S){if(S)throw S});const b=()=>{const S=Date.now().toString(36),x=Ek();return`${S}-${x}`};i(v.create(b())),s(v)}),()=>{}},[]);const d=Tde(e),h=xde(e);return{shareDBDoc:e,content:a,localPresence:r,docPresence:o,submitOperation:h,connected:c,pending:d}},Ede=new h7,Rde=new jfe;aI.types.register(cP.type);const{Connection:Ade}=aI,Mde=window.location.protocol==="https:"?"wss://":"ws://",$de=new WebSocket(Mde+window.location.host+"/ws"),Dde=new Ade($de),Qde=()=>{const{username:n}=D.useContext(li);return Ufe(n),null};function Ide(){const{shareDBDoc:n,content:e,localPresence:t,docPresence:r,submitOperation:i,connected:o,pending:s}=_de({connection:Dde}),[a,l]=D.useState(void 0),[c,u]=D.useState(pZ()),[d,h]=D.useState(!1),p=qfe();return q.jsx(yZ,{children:q.jsx(are,{content:e,shareDBDoc:n,submitOperation:i,localPresence:t,docPresence:r,prettierWorker:Ede,typeScriptWorker:Rde,initialUsername:p,connected:o,pending:s,liveKitRoomName:c,setLiveKitRoom:u,liveKitToken:a,setLiveKitToken:l,liveKitConnection:d,setLiveKitConnection:h,children:q.jsxs(nZ,{audio:!0,token:a,serverUrl:void 0,connect:d,style:{height:"100%"},children:[q.jsxs("div",{className:"app",children:[q.jsx(fse,{}),q.jsx($fe,{allowGlobals:!0,aiCopilotEndpoint:"/ai-copilot"}),q.jsx(Ife,{}),q.jsx(JD,{side:"left"}),q.jsx(JD,{side:"right"})]}),q.jsx(Qde,{}),q.jsx(cZ,{})]})})})}a7.createRoot(document.getElementById("root")).render(q.jsx(
|
|
234
|
+
`}return a.join("").replace(/%20/g," ")},n.exports=e,n.exports.diff_match_patch=e,n.exports.DIFF_DELETE=t,n.exports.DIFF_INSERT=r,n.exports.DIFF_EQUAL=i}(zw)),zw.exports}var wde=Sde();const kde=ss(wde),Pde=(n,e)=>bde(n,e,kde,cP,lI),xde=n=>D.useCallback(t=>{const r=n.data,i=Pde(r,t(r));i&&n&&n.submitOp(i)},[n]),Cde=1e3,Tde=n=>{const e=D.useRef(),[t,r]=D.useState(!1),i=D.useCallback(()=>{n&&n.whenNothingPending(()=>{r(!1)})},[n,r]);return D.useEffect(()=>{n&&n.on("before op",()=>{r(!0),clearTimeout(e.current),e.current=setTimeout(()=>{i()},Cde)})},[n,i]),t},_de=({connection:n})=>{const[e,t]=D.useState(null),[r,i]=D.useState(null),[o,s]=D.useState(null),[a,l]=D.useState(null),[c,u]=D.useState(!1);D.useEffect(()=>{n.on("connected",()=>{u(!0)}),n.on("disconnected",()=>{u(!1)});const p="documents",g="1",O=n.get(p,g);return O.subscribe(()=>{t(O),l(O.data),O.on("op",()=>{l(O.data)});const v=n.getDocPresence(p,g);v.subscribe(function(S){if(S)throw S});const b=()=>{const S=Date.now().toString(36),x=Ek();return`${S}-${x}`};i(v.create(b())),s(v)}),()=>{}},[]);const d=Tde(e),h=xde(e);return{shareDBDoc:e,content:a,localPresence:r,docPresence:o,submitOperation:h,connected:c,pending:d}},Ede=new h7,Rde=new jfe;aI.types.register(cP.type);const{Connection:Ade}=aI,Mde=window.location.protocol==="https:"?"wss://":"ws://",$de=new WebSocket(Mde+window.location.host+"/ws"),Dde=new Ade($de),Qde=()=>{const{username:n}=D.useContext(li);return Ufe(n),null};function Ide(){const{shareDBDoc:n,content:e,localPresence:t,docPresence:r,submitOperation:i,connected:o,pending:s}=_de({connection:Dde}),[a,l]=D.useState(void 0),[c,u]=D.useState(pZ()),[d,h]=D.useState(!1),p=qfe();return q.jsx(yZ,{children:q.jsx(are,{content:e,shareDBDoc:n,submitOperation:i,localPresence:t,docPresence:r,prettierWorker:Ede,typeScriptWorker:Rde,initialUsername:p,connected:o,pending:s,liveKitRoomName:c,setLiveKitRoom:u,liveKitToken:a,setLiveKitToken:l,liveKitConnection:d,setLiveKitConnection:h,children:q.jsxs(nZ,{audio:!0,token:a,serverUrl:void 0,connect:d,style:{height:"100%"},children:[q.jsxs("div",{className:"app",children:[q.jsx(fse,{}),q.jsx($fe,{allowGlobals:!0,aiCopilotEndpoint:"/ai-copilot"}),q.jsx(Ife,{}),q.jsx(JD,{side:"left"}),q.jsx(JD,{side:"right"})]}),q.jsx(Qde,{}),q.jsx(cZ,{})]})})})}a7.createRoot(document.getElementById("root")).render(q.jsx(Uq,{children:q.jsx(Ide,{})}));
|