diff --git a/static/assets/app.js b/static/assets/app.js index d6e6fe945..e7847b4a0 100644 --- a/static/assets/app.js +++ b/static/assets/app.js @@ -89,7 +89,7 @@ ${o.message}`)))}function aK(){return import("./mermaid.core-IHQY3BMC.js") `)}},ia=Uv;function cK(t){return Ce(H({},Rr),{attributes:Ce(H({},Rr.attributes),{"*":[...Rr.attributes["*"]||[],"className","style"]}),protocols:Ce(H({},Rr.protocols),{href:[...Rr.protocols.href,...t]})})}function uK(t){return e=>{let i=[];return pi(e,"code",r=>{let n=r.lang||t.defaultLanguage;if(n){let o=function(a){r.type="html",r.value=`
${a}
`},s=t.highlight(r.value,n);if(s&&typeof s.then=="function"){let a=Promise.resolve(s).then(o);i.push(a)}else o(s)}}),Promise.all(i).then(()=>null)}}function fK(t){return e=>{t.baseUrl&&pi(e,"element",i=>{if(i.tagName==="a"&&i.properties){let r=i.properties.href;r&&!zv(r)&&!jv(r)&&!OK(r)&&(i.properties.href=nX(t.baseUrl,r))}if(i.tagName==="img"&&i.properties){let r=i.properties.src;r&&!zv(r)&&!jv(r)&&(i.properties.src=nX(t.baseUrl,r))}}),pi(e,"element",i=>{i.tagName==="a"&&i.properties&&i.properties.href&&(i.properties.href=i.properties.href.split("/").map(r=>r===".."?"__parent__":r).join("/"))})}}var hK=yh().use(Td,{fragment:!0});function dK(t){return e=>{pi(e,"code",(i,r,n)=>{i.lang==="mermaid"&&(i.type="html",i.value=`
${of(i.value)}
- `)})}}function pK(t){return e=>{let i=[];return pi(e,"element",r=>{if((r.properties&&Array.isArray(r.properties.className)?r.properties.className:[]).includes("mermaid")){let o=function(c){let u=hK.parse(c);Mb(u,!0),r.children=u.children},s=Yc(r,{whitespace:"pre"}),a=t.useDarkTheme?"dark":"default",l=rX(s,{theme:a}).then(o);i.push(l)}}),Promise.all(i).then(()=>null)}}function mK(t){return e=>{pi(e,"element",i=>{if(i.properties&&i.properties.href){let r=i.properties.href;jv(r)?(i.properties["data-phx-link"]=t.baseUrl&&r.startsWith(t.baseUrl)?"patch":"redirect",i.properties["data-phx-link-state"]="push"):zv(r)&&(i.properties.target="_blank",i.properties.rel="noreferrer noopener")}})}}function zv(t){return/^(?:[a-z]+:)?\/\//i.test(t)}function OK(t){return t.startsWith("#")}function jv(t){return t.startsWith("/")||t.startsWith(window.location.origin)}function nX(t,e){return t.replace(/\/$/,"")+"/"+e}var xl=class{constructor(){this.subscribersByTopic={}}subscribe(e,i){return Array.isArray(this.subscribersByTopic[e])||(this.subscribersByTopic[e]=[]),this.subscribersByTopic[e].push(i),{destroy:()=>{this.unsubscribe(e,i)}}}unsubscribe(e,i){let r=this.subscribersByTopic[e].indexOf(i);r!==-1&&(this.subscribersByTopic[e].splice(r,1),this.subscribersByTopic[e].length===0&&delete this.subscribersByTopic[e])}broadcast(e,i){Array.isArray(this.subscribersByTopic[e])&&this.subscribersByTopic[e].forEach(r=>{r(i)})}},Kt=new xl;var oX=t=>typeof t=="object"&&t!=null&&t.nodeType===1,sX=(t,e)=>(!e||t!=="hidden")&&t!=="visible"&&t!=="clip",qv=(t,e)=>{if(t.clientHeight{let n=(o=>{if(!o.ownerDocument||!o.ownerDocument.defaultView)return null;try{return o.ownerDocument.defaultView.frameElement}catch(s){return null}})(r);return!!n&&(n.clientHeightoe||o>t&&s=e&&a>=i?o-t-r:s>e&&ai?s-e+n:0,gK=t=>{let e=t.parentElement;return e==null?t.getRootNode().host||null:e},Wv=(t,e)=>{var i,r,n,o;if(typeof document=="undefined")return[];let{scrollMode:s,block:a,inline:l,boundary:c,skipOverflowHiddenElements:u}=e,f=typeof c=="function"?c:ue=>ue!==c;if(!oX(t))throw new TypeError("Invalid target");let d=document.scrollingElement||document.documentElement,p=[],g=t;for(;oX(g)&&f(g);){if(g=gK(g),g===d){p.push(g);break}g!=null&&g===document.body&&qv(g)&&!qv(document.documentElement)||g!=null&&qv(g,u)&&p.push(g)}let x=(r=(i=window.visualViewport)==null?void 0:i.width)!=null?r:innerWidth,v=(o=(n=window.visualViewport)==null?void 0:n.height)!=null?o:innerHeight,{scrollX:S,scrollY:T}=window,{height:$,width:L,top:P,right:A,bottom:q,left:le}=t.getBoundingClientRect(),F=a==="start"||a==="nearest"?P:a==="end"?q:P+$/2,U=l==="center"?le+L/2:l==="end"?A:le,ie=[];for(let ue=0;ue=0&&le>=0&&q<=v&&A<=x&&P>=ve&&q<=ae&&le>=V&&A<=j)return ie;let E=getComputedStyle(re),B=parseInt(E.borderLeftWidth,10),ne=parseInt(E.borderTopWidth,10),D=parseInt(E.borderRightWidth,10),Ue=parseInt(E.borderBottomWidth,10),Be=0,Ze=0,$t="offsetWidth"in re?re.offsetWidth-re.clientWidth-B-D:0,Xe="offsetHeight"in re?re.offsetHeight-re.clientHeight-ne-Ue:0,Ct="offsetWidth"in re?re.offsetWidth===0?0:Oe/re.offsetWidth:0,_t="offsetHeight"in re?re.offsetHeight===0?0:he/re.offsetHeight:0;if(d===re)Be=a==="start"?F:a==="end"?F-v:a==="nearest"?$m(T,T+v,v,ne,Ue,T+F,T+F+$,$):F-v/2,Ze=l==="start"?U:l==="center"?U-x/2:l==="end"?U-x:$m(S,S+x,x,B,D,S+U,S+U+L,L),Be=Math.max(0,Be+T),Ze=Math.max(0,Ze+S);else{Be=a==="start"?F-ve-ne:a==="end"?F-ae+Ue+Xe:a==="nearest"?$m(ve,ae,he,ne,Ue+Xe,F,F+$,$):F-(ve+he/2)+Xe/2,Ze=l==="start"?U-V-B:l==="center"?U-(V+Oe/2)+$t/2:l==="end"?U-j+D+$t:$m(V,j,Oe,B,D+$t,U,U+L,L);let{scrollLeft:lr,scrollTop:cr}=re;Be=Math.max(0,Math.min(cr+Be/_t,re.scrollHeight-he/_t+Xe)),Ze=Math.max(0,Math.min(lr+Ze/Ct,re.scrollWidth-Oe/Ct+$t)),F+=cr-Be,U+=lr-Ze}ie.push({el:re,top:Be,left:Ze})}return ie};var bK=t=>t===!1?{block:"end",inline:"nearest"}:(e=>e===Object(e)&&Object.keys(e).length!==0)(t)?t:{block:"start",inline:"nearest"};function Xm(t,e){if(!t.isConnected||!(n=>{let o=n;for(;o&&o.parentNode;){if(o.parentNode===document)return!0;o=o.parentNode instanceof ShadowRoot?o.parentNode.host:o.parentNode}return!1})(t))return;let i=(n=>{let o=window.getComputedStyle(n);return{top:parseFloat(o.scrollMarginTop)||0,right:parseFloat(o.scrollMarginRight)||0,bottom:parseFloat(o.scrollMarginBottom)||0,left:parseFloat(o.scrollMarginLeft)||0}})(t);if((n=>typeof n=="object"&&typeof n.behavior=="function")(e))return e.behavior(Wv(t,e));let r=typeof e=="boolean"||e==null?void 0:e.behavior;for(let{el:n,top:o,left:s}of Wv(t,bK(e))){let a=o-i.top+i.bottom,l=s-i.left+i.right;n.scroll({top:a,left:l,behavior:r})}}function ra(t){return["code","smart","setup"].includes(t)}function aX(t){return["markdown","code","setup"].includes(t)}var yK={mounted(){this.props=this.getProps(),this.isFocused=!1,this.insertMode=!1,this.liveEditors={},this.updateInsertModeAvailability(),["code","smart"].includes(this.props.type)&&this.el.querySelector("[data-el-amplify-outputs-button]").addEventListener("click",e=>{this.el.toggleAttribute("data-js-amplified")}),this.props.type==="smart"&&this.el.querySelector("[data-el-toggle-source-button]").addEventListener("click",e=>{this.el.toggleAttribute("data-js-source-visible"),this.updateInsertModeAvailability(),this.maybeFocusCurrentEditor()}),this.el.addEventListener("lb:cell:editor_created",t=>{let{tag:e,liveEditor:i}=t.detail;this.handleCellEditorCreated(e,i)}),this.el.addEventListener("lb:cell:editor_removed",t=>{let{tag:e}=t.detail;this.handleCellEditorRemoved(e)}),this.el.addEventListener("mouseenter",t=>{this.el.setAttribute("data-js-hover","")}),this.el.addEventListener("mouseleave",t=>{this.el.removeAttribute("data-js-hover")}),this.subscriptions=[Kt.subscribe("navigation",this.handleNavigationEvent.bind(this)),Kt.subscribe("cells",this.handleCellsEvent.bind(this)),Kt.subscribe(`cells:${this.props.cellId}`,this.handleCellEvent.bind(this))],this._handleViewportResize=this.handleViewportResize.bind(this),window.visualViewport.addEventListener("resize",this._handleViewportResize)},disconnected(){this.el.removeAttribute("id")},destroyed(){this.subscriptions.forEach(t=>t.destroy()),window.visualViewport.removeEventListener("resize",this._handleViewportResize)},updated(){let t=this.props;this.props=this.getProps(),this.props.evaluationDigest!==t.evaluationDigest&&this.updateChangeIndicator()},getProps(){return ht(this.el,["cell-id","type","session-path","evaluation-digest","smart-cell-js-view-ref","allowed-uri-schemes"])},handleNavigationEvent(t){t.type==="element_focused"?this.handleElementFocused(t.focusableId,t.scroll):t.type==="insert_mode_changed"&&this.handleInsertModeChanged(t.enabled)},handleCellsEvent(t){t.type==="cell_moved"&&this.handleCellMoved(t.cellId)},handleCellEvent(t){t.type==="dispatch_queue_evaluation"&&this.handleDispatchQueueEvaluation(t.dispatch)},handleElementFocused(t,e){this.props.cellId===t?(this.isFocused=!0,this.el.setAttribute("data-js-focused",""),e&&ta(this.el)):this.isFocused&&(this.isFocused=!1,this.el.removeAttribute("data-js-focused"))},handleCellEditorCreated(t,e){if(this.liveEditors[t]=e,this.updateInsertModeAvailability(),e===this.currentEditor()&&this.maybeFocusCurrentEditor(),e.onBlur(()=>{this.isFocused&&this.insertMode&&this.currentEditor().focus()}),e.onFocus(()=>{(!this.isFocused||!this.insertMode)&&this.currentEditor().blur()}),t==="primary"){let i=e.getSource();if(this.el.toggleAttribute("data-js-empty",i===""),e.onChange(r=>{this.el.toggleAttribute("data-js-empty",r==="")}),this.props.type==="markdown"){let r=this.el.querySelector("[data-el-markdown-container]"),n=new ia(r,i,{baseUrl:this.props.sessionPath,emptyText:"Empty markdown cell",allowedUriSchemes:this.props.allowedUriSchemes});e.onChange(o=>{n.setContent(o)})}ra(this.props.type)&&(this.updateChangeIndicator(),e.onChange(r=>{this.updateChangeIndicator()}),this.handleEvent(`evaluation_finished:${this.props.cellId}`,({code_markers:r})=>{e.setCodeMarkers(r)}),this.handleEvent(`start_evaluation:${this.props.cellId}`,()=>{e.clearDoctests()}),this.handleEvent(`doctest_report:${this.props.cellId}`,r=>{e.updateDoctests([r])}),this.handleEvent("erase_outputs",()=>{e.setCodeMarkers([]),e.clearDoctests()}))}},handleCellEditorRemoved(t){delete this.liveEditors[t]},handleViewportResize(){this.isFocused&&this.scrollEditorCursorIntoViewIfNeeded()},currentEditor(){return this.liveEditors[this.currentEditorTag()]},currentEditorTag(){return this.props.type==="smart"?this.el.hasAttribute("data-js-source-visible")?"primary":"secondary":"primary"},updateInsertModeAvailability(){this.el.toggleAttribute("data-js-insert-mode-disabled",!this.currentEditor())},maybeFocusCurrentEditor(){this.isFocused&&this.insertMode&&this.currentEditor().focus()},updateChangeIndicator(){let t=this.el.querySelector("[data-el-cell-status]");if(t&&t.querySelector("[data-el-change-indicator]")&&this.props.evaluationDigest){let i=this.liveEditors.primary.getSource(),r=Cm(i),n=this.props.evaluationDigest!==r;this.el.toggleAttribute("data-js-changed",n)}},handleInsertModeChanged(t){this.isFocused&&!this.insertMode&&t?(this.insertMode=t,this.currentEditor()&&(this.currentEditor().focus(),this.scrollEditorCursorIntoViewIfNeeded())):this.insertMode&&!t&&(this.insertMode=t,this.currentEditor()&&this.currentEditor().blur())},handleCellMoved(t){this.isFocused&&t===this.props.cellId&&ta(this.el)},handleDispatchQueueEvaluation(t){this.props.type==="smart"&&this.props.smartCellJsViewRef?Kt.broadcast(`js_views:${this.props.smartCellJsViewRef}`,{type:"sync",callback:t}):t()},scrollEditorCursorIntoViewIfNeeded(){let t=this.currentEditor().getElementAtCursor();Xm(t,{scrollMode:"if-needed",behavior:"smooth",block:"center"})}},lX=yK;var cf=t=>{let{state:e}=t,i=e.doc.lineAt(e.selection.main.from),r=Vv(t.state,i.from);return r.line?xK(t):r.block?vK(t):!1};function uf(t,e){return({state:i,dispatch:r})=>{if(i.readOnly)return!1;let n=t(e,i);return n?(r(i.update(n)),!0):!1}}var xK=uf(Yv,0),cX=uf(Yv,1),uX=uf(Yv,2),fX=uf(hX,0);var vK=uf((t,e)=>hX(t,e,kK(e)),0);function Vv(t,e){let i=t.languageDataAt("commentTokens",e);return i.length?i[0]:{}}var lf=50;function wK(t,{open:e,close:i},r,n){let o=t.sliceDoc(r-lf,r),s=t.sliceDoc(n,n+lf),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+i.length)==i)return{open:{pos:r-a,margin:a&&1},close:{pos:n+l,margin:l&&1}};let u,f;n-r<=2*lf?u=f=t.sliceDoc(r,n):(u=t.sliceDoc(r,r+lf),f=t.sliceDoc(n-lf,n));let d=/^\s*/.exec(u)[0].length,p=/\s*$/.exec(f)[0].length,g=f.length-p-i.length;return u.slice(d,d+e.length)==e&&f.slice(g,g+i.length)==i?{open:{pos:r+d+e.length,margin:/\s/.test(u.charAt(d+e.length))?1:0},close:{pos:n-p-i.length,margin:/\s/.test(f.charAt(g-1))?1:0}}:null}function kK(t){let e=[];for(let i of t.selection.ranges){let r=t.doc.lineAt(i.from),n=i.to<=r.to?r:t.doc.lineAt(i.to),o=e.length-1;o>=0&&e[o].to>r.from?e[o].to=n.to:e.push({from:r.from+/^\s*/.exec(r.text)[0].length,to:n.to})}return e}function hX(t,e,i=e.selection.ranges){let r=i.map(o=>Vv(e,o.from).block);if(!r.every(o=>o))return null;let n=i.map((o,s)=>wK(e,r[s],o.from,o.to));if(t!=2&&!n.every(o=>o))return{changes:e.changes(i.map((o,s)=>n[s]?[]:[{from:o.from,insert:r[s].open+" "},{from:o.to,insert:" "+r[s].close}]))};if(t!=1&&n.some(o=>o)){let o=[];for(let s=0,a;sn&&(o==s||s>f.from)){n=f.from;let d=/^\s*/.exec(f.text)[0].length,p=d==f.length,g=f.text.slice(d,d+c.length)==c?d:-1;do.comment<0&&(!o.empty||o.single))){let o=[];for(let{line:a,token:l,indent:c,empty:u,single:f}of r)(f||!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(t!=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}var Zv=bi.define(),SK=bi.define(),TK=be.define(),dX=be.define({combine(t){return kt(t,{minDepth:100,newGroupDelay:500,joinToEvent:(e,i)=>i},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,i)=>(r,n)=>e(r,n)||i(r,n)})}}),pX=Fe.define({create(){return na.empty},update(t,e){let i=e.state.facet(dX),r=e.annotation(Zv);if(r){let l=Ur.fromTransaction(e,r.selection),c=r.side,u=c==0?t.undone:t.done;return l?u=Im(u,u.length,i.minDepth,l):u=bX(u,e.startState.selection),new na(c==0?r.rest:u,c==0?u:r.rest)}let n=e.annotation(SK);if((n=="full"||n=="before")&&(t=t.isolate()),e.annotation(Et.addToHistory)===!1)return e.changes.empty?t:t.addMapping(e.changes.desc);let o=Ur.fromTransaction(e),s=e.annotation(Et.time),a=e.annotation(Et.userEvent);return o?t=t.addChanges(o,s,a,i,e):e.selection&&(t=t.addSelection(e.startState.selection,s,a,i.newGroupDelay)),(n=="full"||n=="after")&&(t=t.isolate()),t},toJSON(t){return{done:t.done.map(e=>e.toJSON()),undone:t.undone.map(e=>e.toJSON())}},fromJSON(t){return new na(t.done.map(Ur.fromJSON),t.undone.map(Ur.fromJSON))}});function mX(t={}){return[pX,dX.of(t),de.domEventHandlers({beforeinput(e,i){let r=e.inputType=="historyUndo"?oa:e.inputType=="historyRedo"?Ko:null;return r?(e.preventDefault(),r(i)):!1}})]}function Fv(t,e){return function({state:i,dispatch:r}){if(!e&&i.readOnly)return!1;let n=i.field(pX,!1);if(!n)return!1;let o=n.pop(t,i,e);return o?(r(o),!0):!1}}var oa=Fv(0,!1),Ko=Fv(1,!1),OX=Fv(0,!0);var Ur=class t{constructor(e,i,r,n,o){this.changes=e,this.effects=i,this.mapped=r,this.startSelection=n,this.selectionsAfter=o}setSelAfter(e){return new t(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,i,r;return{changes:(e=this.changes)===null||e===void 0?void 0:e.toJSON(),mapped:(i=this.mapped)===null||i===void 0?void 0:i.toJSON(),startSelection:(r=this.startSelection)===null||r===void 0?void 0:r.toJSON(),selectionsAfter:this.selectionsAfter.map(n=>n.toJSON())}}static fromJSON(e){return new t(e.changes&&Qi.fromJSON(e.changes),[],e.mapped&&jn.fromJSON(e.mapped),e.startSelection&&ee.fromJSON(e.startSelection),e.selectionsAfter.map(ee.fromJSON))}static fromTransaction(e,i){let r=vr;for(let n of e.startState.facet(TK)){let o=n(e);o.length&&(r=r.concat(o))}return!r.length&&e.changes.empty?null:new t(e.changes.invert(e.startState.doc),r,void 0,i||e.startState.selection,vr)}static selection(e){return new t(void 0,vr,void 0,void 0,e)}};function Im(t,e,i,r){let n=e+1>i+20?e-i-1:0,o=t.slice(n,e);return o.push(r),o}function EK(t,e){let i=[],r=!1;return t.iterChangedRanges((n,o)=>i.push(n,o)),e.iterChangedRanges((n,o,s,a)=>{for(let l=0;l=c&&s<=u&&(r=!0)}}),r}function CK(t,e){return t.ranges.length==e.ranges.length&&t.ranges.filter((i,r)=>i.empty!=e.ranges[r].empty).length===0}function gX(t,e){return t.length?e.length?t.concat(e):t:e}var vr=[],_K=200;function bX(t,e){if(t.length){let i=t[t.length-1],r=i.selectionsAfter.slice(Math.max(0,i.selectionsAfter.length-_K));return r.length&&r[r.length-1].eq(e)?t:(r.push(e),Im(t,t.length-1,1e9,i.setSelAfter(r)))}else return[Ur.selection([e])]}function PK(t){let e=t[t.length-1],i=t.slice();return i[t.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),i}function Bv(t,e){if(!t.length)return t;let i=t.length,r=vr;for(;i;){let n=QK(t[i-1],e,r);if(n.changes&&!n.changes.empty||n.effects.length){let o=t.slice(0,i);return o[i-1]=n,o}else e=n.mapped,i--,r=n.selectionsAfter}return r.length?[Ur.selection(r)]:vr}function QK(t,e,i){let r=gX(t.selectionsAfter.length?t.selectionsAfter.map(a=>a.map(e)):vr,i);if(!t.changes)return Ur.selection(r);let n=t.changes.map(e),o=e.mapDesc(t.changes,!0),s=t.mapped?t.mapped.composeDesc(o):o;return new Ur(n,Se.mapEffects(t.effects,e),s,t.startSelection.map(o),r)}var AK=/^(input\.type|delete)($|\.)/,na=class t{constructor(e,i,r=0,n=void 0){this.done=e,this.undone=i,this.prevTime=r,this.prevUserEvent=n}isolate(){return this.prevTime?new t(this.done,this.undone):this}addChanges(e,i,r,n,o){let s=this.done,a=s[s.length-1];return a&&a.changes&&!a.changes.empty&&e.changes&&(!r||AK.test(r))&&(!a.selectionsAfter.length&&i-this.prevTime0&&i-this.prevTimei.empty?t.moveByChar(i,e):Lm(i,e))}function es(t){return t.textDirectionAt(t.state.selection.main.head)==ot.LTR}var hf=t=>Dm(t,!es(t)),Hv=t=>Dm(t,es(t)),yX=t=>Dm(t,!0),Nm=t=>Dm(t,!1);function xX(t,e){return sa(t,i=>i.empty?t.moveByGroup(i,e):Lm(i,e))}var Mm=t=>xX(t,!es(t)),Um=t=>xX(t,es(t));var cwe=typeof Intl!="undefined"&&Intl.Segmenter?new Intl.Segmenter(void 0,{granularity:"word"}):null;function vX(t,e){return sa(t,i=>{if(!i.empty)return Lm(i,e);let r=t.moveVertically(i,e);return r.head!=i.head?r:t.moveToLineBoundary(i,e)})}var df=t=>vX(t,!1),pf=t=>vX(t,!0);function wX(t){let e=t.scrollDOM.clientHeights.empty?t.moveVertically(s,e,i.height):Lm(s,e));if(n.eq(r.selection))return!1;let o;if(i.selfScroll){let s=t.coordsAtPos(r.selection.main.head),a=t.scrollDOM.getBoundingClientRect(),l=a.top+i.marginTop,c=a.bottom-i.marginBottom;s&&s.top>l&&s.bottomkX(t,!1),wl=t=>kX(t,!0);function zm(t,e,i){let r=t.lineBlockAt(e.head),n=t.moveToLineBoundary(e,i);if(n.head==e.head&&n.head!=(i?r.to:r.from)&&(n=t.moveToLineBoundary(e,i,!1)),!i&&n.head==r.from&&r.length){let o=/^\s*/.exec(t.state.sliceDoc(r.from,Math.min(r.from+100,r.to)))[0].length;o&&e.head!=r.from+o&&(n=ee.cursor(r.from+o))}return n}var mf=t=>sa(t,e=>zm(t,e,!0)),Of=t=>sa(t,e=>zm(t,e,!1));var jm=t=>sa(t,e=>ee.cursor(t.lineBlockAt(e.head).from,1)),qm=t=>sa(t,e=>ee.cursor(t.lineBlockAt(e.head).to,-1));function $K(t,e,i){let r=!1,n=ff(t.selection,o=>{let s=yr(t,o.head,-1)||yr(t,o.head,1)||o.head>0&&yr(t,o.head-1,1)||o.head$K(t,e,!1);function ts(t,e){let i=ff(t.state.selection,r=>{let n=e(r);return ee.range(r.anchor,n.head,n.goalColumn,n.bidiLevel||void 0)});return i.eq(t.state.selection)?!1:(t.dispatch(Jo(t.state,i)),!0)}function Wm(t,e){return ts(t,i=>t.moveByChar(i,e))}var Gv=t=>Wm(t,!es(t)),Kv=t=>Wm(t,es(t)),Jv=t=>Wm(t,!0),ew=t=>Wm(t,!1);function Bm(t,e){return ts(t,i=>t.moveByGroup(i,e))}var Zm=t=>Bm(t,!es(t)),Vm=t=>Bm(t,es(t)),TX=t=>Bm(t,!0),EX=t=>Bm(t,!1);function CX(t,e){return ts(t,i=>t.moveVertically(i,e))}var kl=t=>CX(t,!1),Sl=t=>CX(t,!0);function _X(t,e){return ts(t,i=>t.moveVertically(i,e,wX(t).height))}var gf=t=>_X(t,!1),aa=t=>_X(t,!0),tw=t=>ts(t,e=>zm(t,e,!0)),iw=t=>ts(t,e=>zm(t,e,!1));var bf=t=>ts(t,e=>ee.cursor(t.lineBlockAt(e.head).from)),yf=t=>ts(t,e=>ee.cursor(t.lineBlockAt(e.head).to)),xf=({state:t,dispatch:e})=>(e(Jo(t,{anchor:0})),!0),vf=({state:t,dispatch:e})=>(e(Jo(t,{anchor:t.doc.length})),!0),Tl=({state:t,dispatch:e})=>(e(Jo(t,{anchor:t.selection.main.anchor,head:0})),!0),El=({state:t,dispatch:e})=>(e(Jo(t,{anchor:t.selection.main.anchor,head:t.doc.length})),!0),Ym=({state:t,dispatch:e})=>(e(t.update({selection:{anchor:0,head:t.doc.length},userEvent:"select"})),!0),PX=({state:t,dispatch:e})=>{let i=Gm(t).map(({from:r,to:n})=>ee.range(r,Math.min(n+1,t.doc.length)));return e(t.update({selection:ee.create(i),userEvent:"select"})),!0};function Fm(t,e){if(t.state.readOnly)return!1;let i="delete.selection",{state:r}=t,n=r.changeByRange(o=>{let{from:s,to:a}=o;if(s==a){let l=e(o);ls&&(i="delete.forward",l=Rm(t,l,!0)),s=Math.min(s,l),a=Math.max(a,l)}else s=Rm(t,s,!1),a=Rm(t,a,!0);return s==a?{range:o}:{changes:{from:s,to:a},range:ee.cursor(s,sn(t)))r.between(e,e,(n,o)=>{ne&&(e=i?o:n)});return e}var QX=(t,e,i)=>Fm(t,r=>{let n=r.from,{state:o}=t,s=o.doc.lineAt(n),a,l;if(i&&!e&&n>s.from&&nQX(t,!1,!0);var wf=t=>QX(t,!0,!1),AX=(t,e)=>Fm(t,i=>{let r=i.head,{state:n}=t,o=n.doc.lineAt(r),s=n.charCategorizer(r);for(let a=null;;){if(r==(e?o.to:o.from)){r==i.head&&o.number!=(e?n.doc.lines:1)&&(r+=e?1:-1);break}let l=Mt(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!=i.head)&&(a=u),r=l}return r}),rw=t=>AX(t,!1),$X=t=>AX(t,!0),nw=t=>Fm(t,e=>{let i=t.lineBlockAt(e.head).to;return e.headFm(t,e=>{let i=t.lineBlockAt(e.head).from;return e.head>i?i:Math.max(0,e.head-1)});var kf=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let i=t.changeByRange(r=>({changes:{from:r.from,to:r.to,insert:He.of(["",""])},range:ee.cursor(r.from)}));return e(t.update(i,{scrollIntoView:!0,userEvent:"input"})),!0},Hm=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let i=t.changeByRange(r=>{if(!r.empty||r.from==0||r.from==t.doc.length)return{range:r};let n=r.from,o=t.doc.lineAt(n),s=n==o.from?n-1:Mt(o.text,n-o.from,!1)+o.from,a=n==o.to?n+1:Mt(o.text,n-o.from,!0)+o.from;return{changes:{from:s,to:a,insert:t.doc.slice(n,a).append(t.doc.slice(s,n))},range:ee.cursor(a)}});return i.changes.empty?!1:(e(t.update(i,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function Gm(t){let e=[],i=-1;for(let r of t.selection.ranges){let n=t.doc.lineAt(r.from),o=t.doc.lineAt(r.to);if(!r.empty&&r.to==o.from&&(o=t.doc.lineAt(r.to-1)),i>=n.number){let s=e[e.length-1];s.to=o.to,s.ranges.push(r)}else e.push({from:n.from,to:o.to,ranges:[r]});i=o.number+1}return e}function RX(t,e,i){if(t.readOnly)return!1;let r=[],n=[];for(let o of Gm(t)){if(i?o.to==t.doc.length:o.from==0)continue;let s=t.doc.lineAt(i?o.to+1:o.from-1),a=s.length+1;if(i){r.push({from:o.to,to:s.to},{from:o.from,insert:s.text+t.lineBreak});for(let l of o.ranges)n.push(ee.range(Math.min(t.doc.length,l.anchor+a),Math.min(t.doc.length,l.head+a)))}else{r.push({from:s.from,to:o.from},{from:o.to,insert:t.lineBreak+s.text});for(let l of o.ranges)n.push(ee.range(l.anchor-a,l.head-a))}}return r.length?(e(t.update({changes:r,scrollIntoView:!0,selection:ee.create(n,t.selection.mainIndex),userEvent:"move.line"})),!0):!1}var IX=({state:t,dispatch:e})=>RX(t,e,!1),LX=({state:t,dispatch:e})=>RX(t,e,!0);function DX(t,e,i){if(t.readOnly)return!1;let r=[];for(let n of Gm(t))i?r.push({from:n.from,insert:t.doc.slice(n.from,n.to)+t.lineBreak}):r.push({from:n.to,insert:t.lineBreak+t.doc.slice(n.from,n.to)});return e(t.update({changes:r,scrollIntoView:!0,userEvent:"input.copyline"})),!0}var NX=({state:t,dispatch:e})=>DX(t,e,!1),MX=({state:t,dispatch:e})=>DX(t,e,!0),UX=t=>{if(t.state.readOnly)return!1;let{state:e}=t,i=e.changes(Gm(e).map(({from:n,to:o})=>(n>0?n--:o{let o;if(t.lineWrapping){let s=t.lineBlockAt(n.head),a=t.coordsAtPos(n.head,n.assoc||1);a&&(o=s.bottom+t.documentTop-a.bottom+t.defaultLineHeight/2)}return t.moveVertically(n,!0,o)}).map(i);return t.dispatch({changes:i,selection:r,scrollIntoView:!0,userEvent:"delete.line"}),!0};function XK(t,e){if(/\(\)|\[\]|\{\}/.test(t.sliceDoc(e-1,e+1)))return{from:e,to:e};let i=ze(t).resolveInner(e),r=i.childBefore(e),n=i.childAfter(e),o;return r&&n&&r.to<=e&&n.from>=e&&(o=r.type.prop(Qe.closedBy))&&o.indexOf(n.name)>-1&&t.doc.lineAt(r.to).from==t.doc.lineAt(n.from).from&&!/\S/.test(t.sliceDoc(r.to,n.from))?{from:r.to,to:n.from}:null}var Sf=jX(!1),zX=jX(!0);function jX(t){return({state:e,dispatch:i})=>{if(e.readOnly)return!1;let r=e.changeByRange(n=>{let{from:o,to:s}=n,a=e.doc.lineAt(o),l=!t&&o==s&&XK(e,o);t&&(o=s=(s<=a.to?a:e.doc.lineAt(s)).to);let c=new zs(e,{simulateBreak:o,simulateDoubleBreak:!!l}),u=ll(c,o);for(u==null&&(u=Ai(/^\s*/.exec(e.doc.lineAt(o).text)[0],e.tabSize));sa.from&&o{let n=[];for(let s=r.from;s<=r.to;){let a=t.doc.lineAt(s);a.number>i&&(r.empty||r.to>a.from)&&(e(a,n,r),i=a.number),s=a.to+1}let o=t.changes(n);return{changes:n,range:ee.range(o.mapPos(r.anchor,1),o.mapPos(r.head,1))}})}var qX=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let i=Object.create(null),r=new zs(t,{overrideIndentation:o=>{let s=i[o];return s==null?-1:s}}),n=ow(t,(o,s,a)=>{let l=ll(r,o.from);if(l==null)return;/\S/.test(o.text)||(l=0);let c=/^\s*/.exec(o.text)[0],u=Vn(t,l);(c!=u||a.fromt.readOnly?!1:(e(t.update(ow(t,(i,r)=>{r.push({from:i.from,insert:t.facet(Dr)})}),{userEvent:"input.indent"})),!0),Ef=({state:t,dispatch:e})=>t.readOnly?!1:(e(t.update(ow(t,(i,r)=>{let n=/^\s*/.exec(i.text)[0];if(!n)return;let o=Ai(n,t.tabSize),s=0,a=Vn(t,Math.max(0,o-fn(t)));for(;st.normalize("NFKD"):t=>t,rs=class{constructor(e,i,r=0,n=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,n),this.bufferStart=r,this.normalize=o?a=>o(BX(a)):BX,this.query=this.normalize(i)}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 Nt(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 i=ru(e),r=this.bufferStart+this.bufferPos;this.bufferPos+=Pi(e);let n=this.normalize(i);for(let o=0,s=r;;o++){let a=n.charCodeAt(o),l=this.match(a,s,this.bufferPos+this.bufferStart);if(o==n.length-1){if(l)return this.value=l,this;break}s==r&&othis.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 i=this.matchPos<=this.to&&this.re.exec(this.curLine);if(i){let r=this.curLineStart+i.index,n=r+i[0].length;if(this.matchPos=iO(this.text,n+(r==n?1:0)),r==this.curLineStart+this.curLine.length&&this.nextLine(),(rthis.value.to)&&(!this.test||this.test(r,n,i)))return this.value={from:r,to:n,match:i},this;e=this.matchPos-this.curLineStart}else if(this.curLineStart+this.curLine.length=r||n.to<=i){let a=new t(i,e.sliceString(i,r));return sw.set(e,a),a}if(n.from==i&&n.to==r)return n;let{text:o,from:s}=n;return s>i&&(o=e.sliceString(i,s)+o,s=i),n.to=this.to?this.to:this.text.lineAt(e).to}next(){for(;;){let e=this.re.lastIndex=this.matchPos-this.flat.from,i=this.re.exec(this.flat.text);if(i&&!i[0]&&i.index==e&&(this.re.lastIndex=e+1,i=this.re.exec(this.flat.text)),i){let r=this.flat.from+i.index,n=r+i[0].length;if((this.flat.to>=this.to||i.index+i[0].length<=this.flat.text.length-10)&&(!this.test||this.test(r,n,i)))return this.value={from:r,to:n,match:i},this.matchPos=iO(this.text,n+(r==n?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=eO.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}};typeof Symbol!="undefined"&&(Ql.prototype[Symbol.iterator]=tO.prototype[Symbol.iterator]=function(){return this});function IK(t){try{return new RegExp(t,hw),!0}catch(e){return!1}}function iO(t,e){if(e>=t.length)return e;let i=t.lineAt(e),r;for(;e=56320&&r<57344;)e++;return e}function aw(t){let e=String(t.state.doc.lineAt(t.state.selection.main.head).number),i=ct("input",{class:"cm-textfield",name:"line",value:e}),r=ct("form",{class:"cm-gotoLine",onkeydown:o=>{o.keyCode==27?(o.preventDefault(),t.dispatch({effects:rO.of(!1)}),t.focus()):o.keyCode==13&&(o.preventDefault(),n())},onsubmit:o=>{o.preventDefault(),n()}},ct("label",t.state.phrase("Go to line"),": ",i)," ",ct("button",{class:"cm-button",type:"submit"},t.state.phrase("go")));function n(){let o=/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(i.value);if(!o)return;let{state:s}=t,a=s.doc.lineAt(s.selection.main.head),[,l,c,u,f]=o,d=u?+u.slice(1):0,p=c?+c:a.number;if(c&&f){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))),x=ee.cursor(g.from+Math.max(0,Math.min(d,g.length)));t.dispatch({effects:[rO.of(!1),de.scrollIntoView(x.from,{y:"center"})],selection:x}),t.focus()}return{dom:r}}var rO=Se.define(),ZX=Fe.define({create(){return!0},update(t,e){for(let i of e.effects)i.is(rO)&&(t=i.value);return t},provide:t=>gr.from(t,e=>e?aw:null)}),KX=t=>{let e=Ns(t,aw);if(!e){let i=[rO.of(!0)];t.state.field(ZX,!1)==null&&i.push(Se.appendConfig.of([ZX,LK])),t.dispatch({effects:i}),e=Ns(t,aw)}return e&&e.dom.querySelector("input").select(),!0},LK=de.baseTheme({".cm-panel.cm-gotoLine":{padding:"2px 6px 4px","& label":{fontSize:"80%"}}}),DK={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},JX=be.define({combine(t){return kt(t,DK,{highlightWordAroundCursor:(e,i)=>e||i,minSelectionLength:Math.min,maxMatches:Math.min})}});function e6(t){let e=[jK,zK];return t&&e.push(JX.of(t)),e}var NK=we.mark({class:"cm-selectionMatch"}),MK=we.mark({class:"cm-selectionMatch cm-selectionMatch-main"});function VX(t,e,i,r){return(i==0||t(e.sliceDoc(i-1,i))!=dt.Word)&&(r==e.doc.length||t(e.sliceDoc(r,r+1))!=dt.Word)}function UK(t,e,i,r){return t(e.sliceDoc(i,i+1))==dt.Word&&t(e.sliceDoc(r-1,r))==dt.Word}var zK=Ye.fromClass(class{constructor(t){this.decorations=this.getDeco(t)}update(t){(t.selectionSet||t.docChanged||t.viewportChanged)&&(this.decorations=this.getDeco(t.view))}getDeco(t){let e=t.state.facet(JX),{state:i}=t,r=i.selection;if(r.ranges.length>1)return we.none;let n=r.main,o,s=null;if(n.empty){if(!e.highlightWordAroundCursor)return we.none;let l=i.wordAt(n.head);if(!l)return we.none;s=i.charCategorizer(n.head),o=i.sliceDoc(l.from,l.to)}else{let l=n.to-n.from;if(l200)return we.none;if(e.wholeWords){if(o=i.sliceDoc(n.from,n.to),s=i.charCategorizer(n.head),!(VX(s,i,n.from,n.to)&&UK(s,i,n.from,n.to)))return we.none}else if(o=i.sliceDoc(n.from,n.to),!o)return we.none}let a=[];for(let l of t.visibleRanges){let c=new rs(i.doc,o,l.from,l.to);for(;!c.next().done;){let{from:u,to:f}=c.value;if((!s||VX(s,i,u,f))&&(n.empty&&u<=n.from&&f>=n.to?a.push(MK.range(u,f)):(u>=n.to||f<=n.from)&&a.push(NK.range(u,f)),a.length>e.maxMatches))return we.none}}return we.set(a)}},{decorations:t=>t.decorations}),jK=de.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}}),qK=({state:t,dispatch:e})=>{let{selection:i}=t,r=ee.create(i.ranges.map(n=>t.wordAt(n.head)||ee.cursor(n.head)),i.mainIndex);return r.eq(i)?!1:(e(t.update({selection:r})),!0)};function WK(t,e){let{main:i,ranges:r}=t.selection,n=t.wordAt(i.head),o=n&&n.from==i.from&&n.to==i.to;for(let s=!1,a=new rs(t.doc,e,r[r.length-1].to);;)if(a.next(),a.done){if(s)return null;a=new rs(t.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=t.wordAt(a.value.from);if(!l||l.from!=a.value.from||l.to!=a.value.to)continue}return a.value}}var t6=({state:t,dispatch:e})=>{let{ranges:i}=t.selection;if(i.some(o=>o.from===o.to))return qK({state:t,dispatch:e});let r=t.sliceDoc(i[0].from,i[0].to);if(t.selection.ranges.some(o=>t.sliceDoc(o.from,o.to)!=r))return!1;let n=WK(t,r);return n?(e(t.update({selection:t.selection.addRange(ee.range(n.from,n.to),!1),effects:de.scrollIntoView(n.to)})),!0):!1},$l=be.define({combine(t){return kt(t,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new fw(e),scrollToMatch:e=>de.scrollIntoView(e)})}});var Al=class{constructor(e){this.search=e.search,this.caseSensitive=!!e.caseSensitive,this.literal=!!e.literal,this.regexp=!!e.regexp,this.replace=e.replace||"",this.valid=!!this.search&&(!this.regexp||IK(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,(i,r)=>r=="n"?` + `)})}}function pK(t){return e=>{let i=[];return pi(e,"element",r=>{if((r.properties&&Array.isArray(r.properties.className)?r.properties.className:[]).includes("mermaid")){let o=function(c){let u=hK.parse(c);Mb(u,!0),r.children=u.children},s=Yc(r,{whitespace:"pre"}),a=t.useDarkTheme?"dark":"default",l=rX(s,{theme:a}).then(o);i.push(l)}}),Promise.all(i).then(()=>null)}}function mK(t){return e=>{pi(e,"element",i=>{if(i.properties&&i.properties.href){let r=i.properties.href;jv(r)?(i.properties["data-phx-link"]=t.baseUrl&&r.startsWith(t.baseUrl)?"patch":"redirect",i.properties["data-phx-link-state"]="push"):zv(r)&&(i.properties.target="_blank",i.properties.rel="noreferrer noopener")}})}}function zv(t){return/^(?:[a-z]+:)?\/\//i.test(t)}function OK(t){return t.startsWith("#")}function jv(t){return t.startsWith("/")||t.startsWith(window.location.origin)}function nX(t,e){return t.replace(/\/$/,"")+"/"+e}var xl=class{constructor(){this.subscribersByTopic={}}subscribe(e,i){return Array.isArray(this.subscribersByTopic[e])||(this.subscribersByTopic[e]=[]),this.subscribersByTopic[e].push(i),{destroy:()=>{this.unsubscribe(e,i)}}}unsubscribe(e,i){let r=this.subscribersByTopic[e].indexOf(i);r!==-1&&(this.subscribersByTopic[e].splice(r,1),this.subscribersByTopic[e].length===0&&delete this.subscribersByTopic[e])}broadcast(e,i){Array.isArray(this.subscribersByTopic[e])&&this.subscribersByTopic[e].forEach(r=>{r(i)})}},Kt=new xl;var oX=t=>typeof t=="object"&&t!=null&&t.nodeType===1,sX=(t,e)=>(!e||t!=="hidden")&&t!=="visible"&&t!=="clip",qv=(t,e)=>{if(t.clientHeight{let n=(o=>{if(!o.ownerDocument||!o.ownerDocument.defaultView)return null;try{return o.ownerDocument.defaultView.frameElement}catch(s){return null}})(r);return!!n&&(n.clientHeightoe||o>t&&s=e&&a>=i?o-t-r:s>e&&ai?s-e+n:0,gK=t=>{let e=t.parentElement;return e==null?t.getRootNode().host||null:e},Wv=(t,e)=>{var i,r,n,o;if(typeof document=="undefined")return[];let{scrollMode:s,block:a,inline:l,boundary:c,skipOverflowHiddenElements:u}=e,f=typeof c=="function"?c:ue=>ue!==c;if(!oX(t))throw new TypeError("Invalid target");let d=document.scrollingElement||document.documentElement,p=[],g=t;for(;oX(g)&&f(g);){if(g=gK(g),g===d){p.push(g);break}g!=null&&g===document.body&&qv(g)&&!qv(document.documentElement)||g!=null&&qv(g,u)&&p.push(g)}let x=(r=(i=window.visualViewport)==null?void 0:i.width)!=null?r:innerWidth,v=(o=(n=window.visualViewport)==null?void 0:n.height)!=null?o:innerHeight,{scrollX:S,scrollY:T}=window,{height:$,width:L,top:P,right:A,bottom:q,left:le}=t.getBoundingClientRect(),F=a==="start"||a==="nearest"?P:a==="end"?q:P+$/2,U=l==="center"?le+L/2:l==="end"?A:le,ie=[];for(let ue=0;ue=0&&le>=0&&q<=v&&A<=x&&P>=ve&&q<=ae&&le>=V&&A<=j)return ie;let E=getComputedStyle(re),B=parseInt(E.borderLeftWidth,10),ne=parseInt(E.borderTopWidth,10),D=parseInt(E.borderRightWidth,10),Ue=parseInt(E.borderBottomWidth,10),Be=0,Ze=0,$t="offsetWidth"in re?re.offsetWidth-re.clientWidth-B-D:0,Xe="offsetHeight"in re?re.offsetHeight-re.clientHeight-ne-Ue:0,Ct="offsetWidth"in re?re.offsetWidth===0?0:Oe/re.offsetWidth:0,_t="offsetHeight"in re?re.offsetHeight===0?0:he/re.offsetHeight:0;if(d===re)Be=a==="start"?F:a==="end"?F-v:a==="nearest"?$m(T,T+v,v,ne,Ue,T+F,T+F+$,$):F-v/2,Ze=l==="start"?U:l==="center"?U-x/2:l==="end"?U-x:$m(S,S+x,x,B,D,S+U,S+U+L,L),Be=Math.max(0,Be+T),Ze=Math.max(0,Ze+S);else{Be=a==="start"?F-ve-ne:a==="end"?F-ae+Ue+Xe:a==="nearest"?$m(ve,ae,he,ne,Ue+Xe,F,F+$,$):F-(ve+he/2)+Xe/2,Ze=l==="start"?U-V-B:l==="center"?U-(V+Oe/2)+$t/2:l==="end"?U-j+D+$t:$m(V,j,Oe,B,D+$t,U,U+L,L);let{scrollLeft:lr,scrollTop:cr}=re;Be=Math.max(0,Math.min(cr+Be/_t,re.scrollHeight-he/_t+Xe)),Ze=Math.max(0,Math.min(lr+Ze/Ct,re.scrollWidth-Oe/Ct+$t)),F+=cr-Be,U+=lr-Ze}ie.push({el:re,top:Be,left:Ze})}return ie};var bK=t=>t===!1?{block:"end",inline:"nearest"}:(e=>e===Object(e)&&Object.keys(e).length!==0)(t)?t:{block:"start",inline:"nearest"};function Xm(t,e){if(!t.isConnected||!(n=>{let o=n;for(;o&&o.parentNode;){if(o.parentNode===document)return!0;o=o.parentNode instanceof ShadowRoot?o.parentNode.host:o.parentNode}return!1})(t))return;let i=(n=>{let o=window.getComputedStyle(n);return{top:parseFloat(o.scrollMarginTop)||0,right:parseFloat(o.scrollMarginRight)||0,bottom:parseFloat(o.scrollMarginBottom)||0,left:parseFloat(o.scrollMarginLeft)||0}})(t);if((n=>typeof n=="object"&&typeof n.behavior=="function")(e))return e.behavior(Wv(t,e));let r=typeof e=="boolean"||e==null?void 0:e.behavior;for(let{el:n,top:o,left:s}of Wv(t,bK(e))){let a=o-i.top+i.bottom,l=s-i.left+i.right;n.scroll({top:a,left:l,behavior:r})}}function ra(t){return["code","smart","setup"].includes(t)}function aX(t){return["markdown","code","setup"].includes(t)}var yK={mounted(){this.props=this.getProps(),this.isFocused=!1,this.insertMode=!1,this.liveEditors={},this.updateInsertModeAvailability(),["code","smart"].includes(this.props.type)&&this.el.querySelector("[data-el-amplify-outputs-button]").addEventListener("click",e=>{this.el.toggleAttribute("data-js-amplified")}),this.props.type==="smart"&&this.el.querySelector("[data-el-toggle-source-button]").addEventListener("click",e=>{this.el.toggleAttribute("data-js-source-visible"),this.updateInsertModeAvailability(),this.maybeFocusCurrentEditor()}),this.el.addEventListener("lb:cell:editor_created",t=>{let{tag:e,liveEditor:i}=t.detail;this.handleCellEditorCreated(e,i)}),this.el.addEventListener("lb:cell:editor_removed",t=>{let{tag:e}=t.detail;this.handleCellEditorRemoved(e)}),this.el.addEventListener("mouseenter",t=>{this.el.setAttribute("data-js-hover","")}),this.el.addEventListener("mouseleave",t=>{this.el.removeAttribute("data-js-hover")}),this.subscriptions=[Kt.subscribe("navigation",this.handleNavigationEvent.bind(this)),Kt.subscribe("cells",this.handleCellsEvent.bind(this)),Kt.subscribe(`cells:${this.props.cellId}`,this.handleCellEvent.bind(this))],this._handleViewportResize=this.handleViewportResize.bind(this),window.visualViewport.addEventListener("resize",this._handleViewportResize)},disconnected(){this.el.removeAttribute("id")},destroyed(){this.subscriptions.forEach(t=>t.destroy()),window.visualViewport.removeEventListener("resize",this._handleViewportResize)},updated(){let t=this.props;this.props=this.getProps(),this.props.evaluationDigest!==t.evaluationDigest&&this.updateChangeIndicator()},getProps(){return ht(this.el,["cell-id","type","session-path","evaluation-digest","smart-cell-js-view-ref","allowed-uri-schemes"])},handleNavigationEvent(t){t.type==="element_focused"?this.handleElementFocused(t.focusableId,t.scroll):t.type==="insert_mode_changed"&&this.handleInsertModeChanged(t.enabled)},handleCellsEvent(t){t.type==="cell_moved"&&this.handleCellMoved(t.cellId)},handleCellEvent(t){t.type==="dispatch_queue_evaluation"&&this.handleDispatchQueueEvaluation(t.dispatch)},handleElementFocused(t,e){this.props.cellId===t?(this.isFocused=!0,this.el.setAttribute("data-js-focused",""),e&&ta(this.el)):this.isFocused&&(this.isFocused=!1,this.el.removeAttribute("data-js-focused"))},handleCellEditorCreated(t,e){if(this.liveEditors[t]=e,this.updateInsertModeAvailability(),e===this.currentEditor()&&this.maybeFocusCurrentEditor(),e.onBlur(()=>{setTimeout(()=>{this.isFocused&&this.insertMode&&this.currentEditor().focus()},0)}),e.onFocus(()=>{setTimeout(()=>{(!this.isFocused||!this.insertMode)&&this.currentEditor().blur()},0)}),t==="primary"){let i=e.getSource();if(this.el.toggleAttribute("data-js-empty",i===""),e.onChange(r=>{this.el.toggleAttribute("data-js-empty",r==="")}),this.props.type==="markdown"){let r=this.el.querySelector("[data-el-markdown-container]"),n=new ia(r,i,{baseUrl:this.props.sessionPath,emptyText:"Empty markdown cell",allowedUriSchemes:this.props.allowedUriSchemes});e.onChange(o=>{n.setContent(o)})}ra(this.props.type)&&(this.updateChangeIndicator(),e.onChange(r=>{this.updateChangeIndicator()}),this.handleEvent(`evaluation_finished:${this.props.cellId}`,({code_markers:r})=>{e.setCodeMarkers(r)}),this.handleEvent(`start_evaluation:${this.props.cellId}`,()=>{e.clearDoctests()}),this.handleEvent(`doctest_report:${this.props.cellId}`,r=>{e.updateDoctests([r])}),this.handleEvent("erase_outputs",()=>{e.setCodeMarkers([]),e.clearDoctests()}))}},handleCellEditorRemoved(t){delete this.liveEditors[t]},handleViewportResize(){this.isFocused&&this.scrollEditorCursorIntoViewIfNeeded()},currentEditor(){return this.liveEditors[this.currentEditorTag()]},currentEditorTag(){return this.props.type==="smart"?this.el.hasAttribute("data-js-source-visible")?"primary":"secondary":"primary"},updateInsertModeAvailability(){this.el.toggleAttribute("data-js-insert-mode-disabled",!this.currentEditor())},maybeFocusCurrentEditor(){this.isFocused&&this.insertMode&&this.currentEditor().focus()},updateChangeIndicator(){let t=this.el.querySelector("[data-el-cell-status]");if(t&&t.querySelector("[data-el-change-indicator]")&&this.props.evaluationDigest){let i=this.liveEditors.primary.getSource(),r=Cm(i),n=this.props.evaluationDigest!==r;this.el.toggleAttribute("data-js-changed",n)}},handleInsertModeChanged(t){this.isFocused&&!this.insertMode&&t?(this.insertMode=t,this.currentEditor()&&(this.currentEditor().focus(),this.scrollEditorCursorIntoViewIfNeeded())):this.insertMode&&!t&&(this.insertMode=t,this.currentEditor()&&this.currentEditor().blur())},handleCellMoved(t){this.isFocused&&t===this.props.cellId&&ta(this.el)},handleDispatchQueueEvaluation(t){this.props.type==="smart"&&this.props.smartCellJsViewRef?Kt.broadcast(`js_views:${this.props.smartCellJsViewRef}`,{type:"sync",callback:t}):t()},scrollEditorCursorIntoViewIfNeeded(){let t=this.currentEditor().getElementAtCursor();Xm(t,{scrollMode:"if-needed",behavior:"smooth",block:"center"})}},lX=yK;var cf=t=>{let{state:e}=t,i=e.doc.lineAt(e.selection.main.from),r=Vv(t.state,i.from);return r.line?xK(t):r.block?vK(t):!1};function uf(t,e){return({state:i,dispatch:r})=>{if(i.readOnly)return!1;let n=t(e,i);return n?(r(i.update(n)),!0):!1}}var xK=uf(Yv,0),cX=uf(Yv,1),uX=uf(Yv,2),fX=uf(hX,0);var vK=uf((t,e)=>hX(t,e,kK(e)),0);function Vv(t,e){let i=t.languageDataAt("commentTokens",e);return i.length?i[0]:{}}var lf=50;function wK(t,{open:e,close:i},r,n){let o=t.sliceDoc(r-lf,r),s=t.sliceDoc(n,n+lf),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+i.length)==i)return{open:{pos:r-a,margin:a&&1},close:{pos:n+l,margin:l&&1}};let u,f;n-r<=2*lf?u=f=t.sliceDoc(r,n):(u=t.sliceDoc(r,r+lf),f=t.sliceDoc(n-lf,n));let d=/^\s*/.exec(u)[0].length,p=/\s*$/.exec(f)[0].length,g=f.length-p-i.length;return u.slice(d,d+e.length)==e&&f.slice(g,g+i.length)==i?{open:{pos:r+d+e.length,margin:/\s/.test(u.charAt(d+e.length))?1:0},close:{pos:n-p-i.length,margin:/\s/.test(f.charAt(g-1))?1:0}}:null}function kK(t){let e=[];for(let i of t.selection.ranges){let r=t.doc.lineAt(i.from),n=i.to<=r.to?r:t.doc.lineAt(i.to),o=e.length-1;o>=0&&e[o].to>r.from?e[o].to=n.to:e.push({from:r.from+/^\s*/.exec(r.text)[0].length,to:n.to})}return e}function hX(t,e,i=e.selection.ranges){let r=i.map(o=>Vv(e,o.from).block);if(!r.every(o=>o))return null;let n=i.map((o,s)=>wK(e,r[s],o.from,o.to));if(t!=2&&!n.every(o=>o))return{changes:e.changes(i.map((o,s)=>n[s]?[]:[{from:o.from,insert:r[s].open+" "},{from:o.to,insert:" "+r[s].close}]))};if(t!=1&&n.some(o=>o)){let o=[];for(let s=0,a;sn&&(o==s||s>f.from)){n=f.from;let d=/^\s*/.exec(f.text)[0].length,p=d==f.length,g=f.text.slice(d,d+c.length)==c?d:-1;do.comment<0&&(!o.empty||o.single))){let o=[];for(let{line:a,token:l,indent:c,empty:u,single:f}of r)(f||!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(t!=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}var Zv=bi.define(),SK=bi.define(),TK=be.define(),dX=be.define({combine(t){return kt(t,{minDepth:100,newGroupDelay:500,joinToEvent:(e,i)=>i},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,i)=>(r,n)=>e(r,n)||i(r,n)})}}),pX=Fe.define({create(){return na.empty},update(t,e){let i=e.state.facet(dX),r=e.annotation(Zv);if(r){let l=Ur.fromTransaction(e,r.selection),c=r.side,u=c==0?t.undone:t.done;return l?u=Im(u,u.length,i.minDepth,l):u=bX(u,e.startState.selection),new na(c==0?r.rest:u,c==0?u:r.rest)}let n=e.annotation(SK);if((n=="full"||n=="before")&&(t=t.isolate()),e.annotation(Et.addToHistory)===!1)return e.changes.empty?t:t.addMapping(e.changes.desc);let o=Ur.fromTransaction(e),s=e.annotation(Et.time),a=e.annotation(Et.userEvent);return o?t=t.addChanges(o,s,a,i,e):e.selection&&(t=t.addSelection(e.startState.selection,s,a,i.newGroupDelay)),(n=="full"||n=="after")&&(t=t.isolate()),t},toJSON(t){return{done:t.done.map(e=>e.toJSON()),undone:t.undone.map(e=>e.toJSON())}},fromJSON(t){return new na(t.done.map(Ur.fromJSON),t.undone.map(Ur.fromJSON))}});function mX(t={}){return[pX,dX.of(t),de.domEventHandlers({beforeinput(e,i){let r=e.inputType=="historyUndo"?oa:e.inputType=="historyRedo"?Ko:null;return r?(e.preventDefault(),r(i)):!1}})]}function Fv(t,e){return function({state:i,dispatch:r}){if(!e&&i.readOnly)return!1;let n=i.field(pX,!1);if(!n)return!1;let o=n.pop(t,i,e);return o?(r(o),!0):!1}}var oa=Fv(0,!1),Ko=Fv(1,!1),OX=Fv(0,!0);var Ur=class t{constructor(e,i,r,n,o){this.changes=e,this.effects=i,this.mapped=r,this.startSelection=n,this.selectionsAfter=o}setSelAfter(e){return new t(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,i,r;return{changes:(e=this.changes)===null||e===void 0?void 0:e.toJSON(),mapped:(i=this.mapped)===null||i===void 0?void 0:i.toJSON(),startSelection:(r=this.startSelection)===null||r===void 0?void 0:r.toJSON(),selectionsAfter:this.selectionsAfter.map(n=>n.toJSON())}}static fromJSON(e){return new t(e.changes&&Qi.fromJSON(e.changes),[],e.mapped&&jn.fromJSON(e.mapped),e.startSelection&&ee.fromJSON(e.startSelection),e.selectionsAfter.map(ee.fromJSON))}static fromTransaction(e,i){let r=vr;for(let n of e.startState.facet(TK)){let o=n(e);o.length&&(r=r.concat(o))}return!r.length&&e.changes.empty?null:new t(e.changes.invert(e.startState.doc),r,void 0,i||e.startState.selection,vr)}static selection(e){return new t(void 0,vr,void 0,void 0,e)}};function Im(t,e,i,r){let n=e+1>i+20?e-i-1:0,o=t.slice(n,e);return o.push(r),o}function EK(t,e){let i=[],r=!1;return t.iterChangedRanges((n,o)=>i.push(n,o)),e.iterChangedRanges((n,o,s,a)=>{for(let l=0;l=c&&s<=u&&(r=!0)}}),r}function CK(t,e){return t.ranges.length==e.ranges.length&&t.ranges.filter((i,r)=>i.empty!=e.ranges[r].empty).length===0}function gX(t,e){return t.length?e.length?t.concat(e):t:e}var vr=[],_K=200;function bX(t,e){if(t.length){let i=t[t.length-1],r=i.selectionsAfter.slice(Math.max(0,i.selectionsAfter.length-_K));return r.length&&r[r.length-1].eq(e)?t:(r.push(e),Im(t,t.length-1,1e9,i.setSelAfter(r)))}else return[Ur.selection([e])]}function PK(t){let e=t[t.length-1],i=t.slice();return i[t.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),i}function Bv(t,e){if(!t.length)return t;let i=t.length,r=vr;for(;i;){let n=QK(t[i-1],e,r);if(n.changes&&!n.changes.empty||n.effects.length){let o=t.slice(0,i);return o[i-1]=n,o}else e=n.mapped,i--,r=n.selectionsAfter}return r.length?[Ur.selection(r)]:vr}function QK(t,e,i){let r=gX(t.selectionsAfter.length?t.selectionsAfter.map(a=>a.map(e)):vr,i);if(!t.changes)return Ur.selection(r);let n=t.changes.map(e),o=e.mapDesc(t.changes,!0),s=t.mapped?t.mapped.composeDesc(o):o;return new Ur(n,Se.mapEffects(t.effects,e),s,t.startSelection.map(o),r)}var AK=/^(input\.type|delete)($|\.)/,na=class t{constructor(e,i,r=0,n=void 0){this.done=e,this.undone=i,this.prevTime=r,this.prevUserEvent=n}isolate(){return this.prevTime?new t(this.done,this.undone):this}addChanges(e,i,r,n,o){let s=this.done,a=s[s.length-1];return a&&a.changes&&!a.changes.empty&&e.changes&&(!r||AK.test(r))&&(!a.selectionsAfter.length&&i-this.prevTime0&&i-this.prevTimei.empty?t.moveByChar(i,e):Lm(i,e))}function es(t){return t.textDirectionAt(t.state.selection.main.head)==ot.LTR}var hf=t=>Dm(t,!es(t)),Hv=t=>Dm(t,es(t)),yX=t=>Dm(t,!0),Nm=t=>Dm(t,!1);function xX(t,e){return sa(t,i=>i.empty?t.moveByGroup(i,e):Lm(i,e))}var Mm=t=>xX(t,!es(t)),Um=t=>xX(t,es(t));var cwe=typeof Intl!="undefined"&&Intl.Segmenter?new Intl.Segmenter(void 0,{granularity:"word"}):null;function vX(t,e){return sa(t,i=>{if(!i.empty)return Lm(i,e);let r=t.moveVertically(i,e);return r.head!=i.head?r:t.moveToLineBoundary(i,e)})}var df=t=>vX(t,!1),pf=t=>vX(t,!0);function wX(t){let e=t.scrollDOM.clientHeights.empty?t.moveVertically(s,e,i.height):Lm(s,e));if(n.eq(r.selection))return!1;let o;if(i.selfScroll){let s=t.coordsAtPos(r.selection.main.head),a=t.scrollDOM.getBoundingClientRect(),l=a.top+i.marginTop,c=a.bottom-i.marginBottom;s&&s.top>l&&s.bottomkX(t,!1),wl=t=>kX(t,!0);function zm(t,e,i){let r=t.lineBlockAt(e.head),n=t.moveToLineBoundary(e,i);if(n.head==e.head&&n.head!=(i?r.to:r.from)&&(n=t.moveToLineBoundary(e,i,!1)),!i&&n.head==r.from&&r.length){let o=/^\s*/.exec(t.state.sliceDoc(r.from,Math.min(r.from+100,r.to)))[0].length;o&&e.head!=r.from+o&&(n=ee.cursor(r.from+o))}return n}var mf=t=>sa(t,e=>zm(t,e,!0)),Of=t=>sa(t,e=>zm(t,e,!1));var jm=t=>sa(t,e=>ee.cursor(t.lineBlockAt(e.head).from,1)),qm=t=>sa(t,e=>ee.cursor(t.lineBlockAt(e.head).to,-1));function $K(t,e,i){let r=!1,n=ff(t.selection,o=>{let s=yr(t,o.head,-1)||yr(t,o.head,1)||o.head>0&&yr(t,o.head-1,1)||o.head$K(t,e,!1);function ts(t,e){let i=ff(t.state.selection,r=>{let n=e(r);return ee.range(r.anchor,n.head,n.goalColumn,n.bidiLevel||void 0)});return i.eq(t.state.selection)?!1:(t.dispatch(Jo(t.state,i)),!0)}function Wm(t,e){return ts(t,i=>t.moveByChar(i,e))}var Gv=t=>Wm(t,!es(t)),Kv=t=>Wm(t,es(t)),Jv=t=>Wm(t,!0),ew=t=>Wm(t,!1);function Bm(t,e){return ts(t,i=>t.moveByGroup(i,e))}var Zm=t=>Bm(t,!es(t)),Vm=t=>Bm(t,es(t)),TX=t=>Bm(t,!0),EX=t=>Bm(t,!1);function CX(t,e){return ts(t,i=>t.moveVertically(i,e))}var kl=t=>CX(t,!1),Sl=t=>CX(t,!0);function _X(t,e){return ts(t,i=>t.moveVertically(i,e,wX(t).height))}var gf=t=>_X(t,!1),aa=t=>_X(t,!0),tw=t=>ts(t,e=>zm(t,e,!0)),iw=t=>ts(t,e=>zm(t,e,!1));var bf=t=>ts(t,e=>ee.cursor(t.lineBlockAt(e.head).from)),yf=t=>ts(t,e=>ee.cursor(t.lineBlockAt(e.head).to)),xf=({state:t,dispatch:e})=>(e(Jo(t,{anchor:0})),!0),vf=({state:t,dispatch:e})=>(e(Jo(t,{anchor:t.doc.length})),!0),Tl=({state:t,dispatch:e})=>(e(Jo(t,{anchor:t.selection.main.anchor,head:0})),!0),El=({state:t,dispatch:e})=>(e(Jo(t,{anchor:t.selection.main.anchor,head:t.doc.length})),!0),Ym=({state:t,dispatch:e})=>(e(t.update({selection:{anchor:0,head:t.doc.length},userEvent:"select"})),!0),PX=({state:t,dispatch:e})=>{let i=Gm(t).map(({from:r,to:n})=>ee.range(r,Math.min(n+1,t.doc.length)));return e(t.update({selection:ee.create(i),userEvent:"select"})),!0};function Fm(t,e){if(t.state.readOnly)return!1;let i="delete.selection",{state:r}=t,n=r.changeByRange(o=>{let{from:s,to:a}=o;if(s==a){let l=e(o);ls&&(i="delete.forward",l=Rm(t,l,!0)),s=Math.min(s,l),a=Math.max(a,l)}else s=Rm(t,s,!1),a=Rm(t,a,!0);return s==a?{range:o}:{changes:{from:s,to:a},range:ee.cursor(s,sn(t)))r.between(e,e,(n,o)=>{ne&&(e=i?o:n)});return e}var QX=(t,e,i)=>Fm(t,r=>{let n=r.from,{state:o}=t,s=o.doc.lineAt(n),a,l;if(i&&!e&&n>s.from&&nQX(t,!1,!0);var wf=t=>QX(t,!0,!1),AX=(t,e)=>Fm(t,i=>{let r=i.head,{state:n}=t,o=n.doc.lineAt(r),s=n.charCategorizer(r);for(let a=null;;){if(r==(e?o.to:o.from)){r==i.head&&o.number!=(e?n.doc.lines:1)&&(r+=e?1:-1);break}let l=Mt(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!=i.head)&&(a=u),r=l}return r}),rw=t=>AX(t,!1),$X=t=>AX(t,!0),nw=t=>Fm(t,e=>{let i=t.lineBlockAt(e.head).to;return e.headFm(t,e=>{let i=t.lineBlockAt(e.head).from;return e.head>i?i:Math.max(0,e.head-1)});var kf=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let i=t.changeByRange(r=>({changes:{from:r.from,to:r.to,insert:He.of(["",""])},range:ee.cursor(r.from)}));return e(t.update(i,{scrollIntoView:!0,userEvent:"input"})),!0},Hm=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let i=t.changeByRange(r=>{if(!r.empty||r.from==0||r.from==t.doc.length)return{range:r};let n=r.from,o=t.doc.lineAt(n),s=n==o.from?n-1:Mt(o.text,n-o.from,!1)+o.from,a=n==o.to?n+1:Mt(o.text,n-o.from,!0)+o.from;return{changes:{from:s,to:a,insert:t.doc.slice(n,a).append(t.doc.slice(s,n))},range:ee.cursor(a)}});return i.changes.empty?!1:(e(t.update(i,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function Gm(t){let e=[],i=-1;for(let r of t.selection.ranges){let n=t.doc.lineAt(r.from),o=t.doc.lineAt(r.to);if(!r.empty&&r.to==o.from&&(o=t.doc.lineAt(r.to-1)),i>=n.number){let s=e[e.length-1];s.to=o.to,s.ranges.push(r)}else e.push({from:n.from,to:o.to,ranges:[r]});i=o.number+1}return e}function RX(t,e,i){if(t.readOnly)return!1;let r=[],n=[];for(let o of Gm(t)){if(i?o.to==t.doc.length:o.from==0)continue;let s=t.doc.lineAt(i?o.to+1:o.from-1),a=s.length+1;if(i){r.push({from:o.to,to:s.to},{from:o.from,insert:s.text+t.lineBreak});for(let l of o.ranges)n.push(ee.range(Math.min(t.doc.length,l.anchor+a),Math.min(t.doc.length,l.head+a)))}else{r.push({from:s.from,to:o.from},{from:o.to,insert:t.lineBreak+s.text});for(let l of o.ranges)n.push(ee.range(l.anchor-a,l.head-a))}}return r.length?(e(t.update({changes:r,scrollIntoView:!0,selection:ee.create(n,t.selection.mainIndex),userEvent:"move.line"})),!0):!1}var IX=({state:t,dispatch:e})=>RX(t,e,!1),LX=({state:t,dispatch:e})=>RX(t,e,!0);function DX(t,e,i){if(t.readOnly)return!1;let r=[];for(let n of Gm(t))i?r.push({from:n.from,insert:t.doc.slice(n.from,n.to)+t.lineBreak}):r.push({from:n.to,insert:t.lineBreak+t.doc.slice(n.from,n.to)});return e(t.update({changes:r,scrollIntoView:!0,userEvent:"input.copyline"})),!0}var NX=({state:t,dispatch:e})=>DX(t,e,!1),MX=({state:t,dispatch:e})=>DX(t,e,!0),UX=t=>{if(t.state.readOnly)return!1;let{state:e}=t,i=e.changes(Gm(e).map(({from:n,to:o})=>(n>0?n--:o{let o;if(t.lineWrapping){let s=t.lineBlockAt(n.head),a=t.coordsAtPos(n.head,n.assoc||1);a&&(o=s.bottom+t.documentTop-a.bottom+t.defaultLineHeight/2)}return t.moveVertically(n,!0,o)}).map(i);return t.dispatch({changes:i,selection:r,scrollIntoView:!0,userEvent:"delete.line"}),!0};function XK(t,e){if(/\(\)|\[\]|\{\}/.test(t.sliceDoc(e-1,e+1)))return{from:e,to:e};let i=ze(t).resolveInner(e),r=i.childBefore(e),n=i.childAfter(e),o;return r&&n&&r.to<=e&&n.from>=e&&(o=r.type.prop(Qe.closedBy))&&o.indexOf(n.name)>-1&&t.doc.lineAt(r.to).from==t.doc.lineAt(n.from).from&&!/\S/.test(t.sliceDoc(r.to,n.from))?{from:r.to,to:n.from}:null}var Sf=jX(!1),zX=jX(!0);function jX(t){return({state:e,dispatch:i})=>{if(e.readOnly)return!1;let r=e.changeByRange(n=>{let{from:o,to:s}=n,a=e.doc.lineAt(o),l=!t&&o==s&&XK(e,o);t&&(o=s=(s<=a.to?a:e.doc.lineAt(s)).to);let c=new zs(e,{simulateBreak:o,simulateDoubleBreak:!!l}),u=ll(c,o);for(u==null&&(u=Ai(/^\s*/.exec(e.doc.lineAt(o).text)[0],e.tabSize));sa.from&&o{let n=[];for(let s=r.from;s<=r.to;){let a=t.doc.lineAt(s);a.number>i&&(r.empty||r.to>a.from)&&(e(a,n,r),i=a.number),s=a.to+1}let o=t.changes(n);return{changes:n,range:ee.range(o.mapPos(r.anchor,1),o.mapPos(r.head,1))}})}var qX=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let i=Object.create(null),r=new zs(t,{overrideIndentation:o=>{let s=i[o];return s==null?-1:s}}),n=ow(t,(o,s,a)=>{let l=ll(r,o.from);if(l==null)return;/\S/.test(o.text)||(l=0);let c=/^\s*/.exec(o.text)[0],u=Vn(t,l);(c!=u||a.fromt.readOnly?!1:(e(t.update(ow(t,(i,r)=>{r.push({from:i.from,insert:t.facet(Dr)})}),{userEvent:"input.indent"})),!0),Ef=({state:t,dispatch:e})=>t.readOnly?!1:(e(t.update(ow(t,(i,r)=>{let n=/^\s*/.exec(i.text)[0];if(!n)return;let o=Ai(n,t.tabSize),s=0,a=Vn(t,Math.max(0,o-fn(t)));for(;st.normalize("NFKD"):t=>t,rs=class{constructor(e,i,r=0,n=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,n),this.bufferStart=r,this.normalize=o?a=>o(BX(a)):BX,this.query=this.normalize(i)}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 Nt(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 i=ru(e),r=this.bufferStart+this.bufferPos;this.bufferPos+=Pi(e);let n=this.normalize(i);for(let o=0,s=r;;o++){let a=n.charCodeAt(o),l=this.match(a,s,this.bufferPos+this.bufferStart);if(o==n.length-1){if(l)return this.value=l,this;break}s==r&&othis.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 i=this.matchPos<=this.to&&this.re.exec(this.curLine);if(i){let r=this.curLineStart+i.index,n=r+i[0].length;if(this.matchPos=iO(this.text,n+(r==n?1:0)),r==this.curLineStart+this.curLine.length&&this.nextLine(),(rthis.value.to)&&(!this.test||this.test(r,n,i)))return this.value={from:r,to:n,match:i},this;e=this.matchPos-this.curLineStart}else if(this.curLineStart+this.curLine.length=r||n.to<=i){let a=new t(i,e.sliceString(i,r));return sw.set(e,a),a}if(n.from==i&&n.to==r)return n;let{text:o,from:s}=n;return s>i&&(o=e.sliceString(i,s)+o,s=i),n.to=this.to?this.to:this.text.lineAt(e).to}next(){for(;;){let e=this.re.lastIndex=this.matchPos-this.flat.from,i=this.re.exec(this.flat.text);if(i&&!i[0]&&i.index==e&&(this.re.lastIndex=e+1,i=this.re.exec(this.flat.text)),i){let r=this.flat.from+i.index,n=r+i[0].length;if((this.flat.to>=this.to||i.index+i[0].length<=this.flat.text.length-10)&&(!this.test||this.test(r,n,i)))return this.value={from:r,to:n,match:i},this.matchPos=iO(this.text,n+(r==n?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=eO.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}};typeof Symbol!="undefined"&&(Ql.prototype[Symbol.iterator]=tO.prototype[Symbol.iterator]=function(){return this});function IK(t){try{return new RegExp(t,hw),!0}catch(e){return!1}}function iO(t,e){if(e>=t.length)return e;let i=t.lineAt(e),r;for(;e=56320&&r<57344;)e++;return e}function aw(t){let e=String(t.state.doc.lineAt(t.state.selection.main.head).number),i=ct("input",{class:"cm-textfield",name:"line",value:e}),r=ct("form",{class:"cm-gotoLine",onkeydown:o=>{o.keyCode==27?(o.preventDefault(),t.dispatch({effects:rO.of(!1)}),t.focus()):o.keyCode==13&&(o.preventDefault(),n())},onsubmit:o=>{o.preventDefault(),n()}},ct("label",t.state.phrase("Go to line"),": ",i)," ",ct("button",{class:"cm-button",type:"submit"},t.state.phrase("go")));function n(){let o=/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(i.value);if(!o)return;let{state:s}=t,a=s.doc.lineAt(s.selection.main.head),[,l,c,u,f]=o,d=u?+u.slice(1):0,p=c?+c:a.number;if(c&&f){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))),x=ee.cursor(g.from+Math.max(0,Math.min(d,g.length)));t.dispatch({effects:[rO.of(!1),de.scrollIntoView(x.from,{y:"center"})],selection:x}),t.focus()}return{dom:r}}var rO=Se.define(),ZX=Fe.define({create(){return!0},update(t,e){for(let i of e.effects)i.is(rO)&&(t=i.value);return t},provide:t=>gr.from(t,e=>e?aw:null)}),KX=t=>{let e=Ns(t,aw);if(!e){let i=[rO.of(!0)];t.state.field(ZX,!1)==null&&i.push(Se.appendConfig.of([ZX,LK])),t.dispatch({effects:i}),e=Ns(t,aw)}return e&&e.dom.querySelector("input").select(),!0},LK=de.baseTheme({".cm-panel.cm-gotoLine":{padding:"2px 6px 4px","& label":{fontSize:"80%"}}}),DK={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},JX=be.define({combine(t){return kt(t,DK,{highlightWordAroundCursor:(e,i)=>e||i,minSelectionLength:Math.min,maxMatches:Math.min})}});function e6(t){let e=[jK,zK];return t&&e.push(JX.of(t)),e}var NK=we.mark({class:"cm-selectionMatch"}),MK=we.mark({class:"cm-selectionMatch cm-selectionMatch-main"});function VX(t,e,i,r){return(i==0||t(e.sliceDoc(i-1,i))!=dt.Word)&&(r==e.doc.length||t(e.sliceDoc(r,r+1))!=dt.Word)}function UK(t,e,i,r){return t(e.sliceDoc(i,i+1))==dt.Word&&t(e.sliceDoc(r-1,r))==dt.Word}var zK=Ye.fromClass(class{constructor(t){this.decorations=this.getDeco(t)}update(t){(t.selectionSet||t.docChanged||t.viewportChanged)&&(this.decorations=this.getDeco(t.view))}getDeco(t){let e=t.state.facet(JX),{state:i}=t,r=i.selection;if(r.ranges.length>1)return we.none;let n=r.main,o,s=null;if(n.empty){if(!e.highlightWordAroundCursor)return we.none;let l=i.wordAt(n.head);if(!l)return we.none;s=i.charCategorizer(n.head),o=i.sliceDoc(l.from,l.to)}else{let l=n.to-n.from;if(l200)return we.none;if(e.wholeWords){if(o=i.sliceDoc(n.from,n.to),s=i.charCategorizer(n.head),!(VX(s,i,n.from,n.to)&&UK(s,i,n.from,n.to)))return we.none}else if(o=i.sliceDoc(n.from,n.to),!o)return we.none}let a=[];for(let l of t.visibleRanges){let c=new rs(i.doc,o,l.from,l.to);for(;!c.next().done;){let{from:u,to:f}=c.value;if((!s||VX(s,i,u,f))&&(n.empty&&u<=n.from&&f>=n.to?a.push(MK.range(u,f)):(u>=n.to||f<=n.from)&&a.push(NK.range(u,f)),a.length>e.maxMatches))return we.none}}return we.set(a)}},{decorations:t=>t.decorations}),jK=de.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}}),qK=({state:t,dispatch:e})=>{let{selection:i}=t,r=ee.create(i.ranges.map(n=>t.wordAt(n.head)||ee.cursor(n.head)),i.mainIndex);return r.eq(i)?!1:(e(t.update({selection:r})),!0)};function WK(t,e){let{main:i,ranges:r}=t.selection,n=t.wordAt(i.head),o=n&&n.from==i.from&&n.to==i.to;for(let s=!1,a=new rs(t.doc,e,r[r.length-1].to);;)if(a.next(),a.done){if(s)return null;a=new rs(t.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=t.wordAt(a.value.from);if(!l||l.from!=a.value.from||l.to!=a.value.to)continue}return a.value}}var t6=({state:t,dispatch:e})=>{let{ranges:i}=t.selection;if(i.some(o=>o.from===o.to))return qK({state:t,dispatch:e});let r=t.sliceDoc(i[0].from,i[0].to);if(t.selection.ranges.some(o=>t.sliceDoc(o.from,o.to)!=r))return!1;let n=WK(t,r);return n?(e(t.update({selection:t.selection.addRange(ee.range(n.from,n.to),!1),effects:de.scrollIntoView(n.to)})),!0):!1},$l=be.define({combine(t){return kt(t,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new fw(e),scrollToMatch:e=>de.scrollIntoView(e)})}});var Al=class{constructor(e){this.search=e.search,this.caseSensitive=!!e.caseSensitive,this.literal=!!e.literal,this.regexp=!!e.regexp,this.replace=e.replace||"",this.valid=!!this.search&&(!this.regexp||IK(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,(i,r)=>r=="n"?` `: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 cw(this):new lw(this)}getCursor(e,i=0,r){let n=e.doc?e:rt.create({doc:e});return r==null&&(r=n.doc.length),this.regexp?Pl(this,n,i,r):_l(this,n,i,r)}},nO=class{constructor(e){this.spec=e}};function _l(t,e,i,r){return new rs(e.doc,t.unquoted,i,r,t.caseSensitive?void 0:n=>n.toLowerCase(),t.wholeWord?BK(e.doc,e.charCategorizer(e.selection.main.head)):void 0)}function BK(t,e){return(i,r,n,o)=>((o>i||o+n.length=i)return null;n.push(r.value)}return n}highlight(e,i,r,n){let o=_l(this.spec,e,Math.max(0,i-this.spec.unquoted.length),Math.min(r+this.spec.unquoted.length,e.doc.length));for(;!o.next().done;)n(o.value.from,o.value.to)}};function Pl(t,e,i,r){return new Ql(e.doc,t.search,{ignoreCase:!t.caseSensitive,test:t.wholeWord?ZK(e.charCategorizer(e.selection.main.head)):void 0},i,r)}function oO(t,e){return t.slice(Mt(t,e,!1),e)}function sO(t,e){return t.slice(e,Mt(t,e))}function ZK(t){return(e,i,r)=>!r[0].length||(t(oO(r.input,r.index))!=dt.Word||t(sO(r.input,r.index))!=dt.Word)&&(t(sO(r.input,r.index+r[0].length))!=dt.Word||t(oO(r.input,r.index+r[0].length))!=dt.Word)}var cw=class extends nO{nextMatch(e,i,r){let n=Pl(this.spec,e,r,e.doc.length).next();return n.done&&(n=Pl(this.spec,e,0,i).next()),n.done?null:n.value}prevMatchInRange(e,i,r){for(let n=1;;n++){let o=Math.max(i,r-n*1e4),s=Pl(this.spec,e,o,r),a=null;for(;!s.next().done;)a=s.value;if(a&&(o==i||a.from>o+10))return a;if(o==i)return null}}prevMatch(e,i,r){return this.prevMatchInRange(e,0,i)||this.prevMatchInRange(e,r,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&\d+])/g,(i,r)=>r=="$"?"$":r=="&"?e.match[0]:r!="0"&&+r=i)return null;n.push(r.value)}return n}highlight(e,i,r,n){let o=Pl(this.spec,e,Math.max(0,i-250),Math.min(r+250,e.doc.length));for(;!o.next().done;)n(o.value.from,o.value.to)}},Kn=Se.define(),dw=Se.define(),is=Fe.define({create(t){return new Cf(uw(t).create(),null)},update(t,e){for(let i of e.effects)i.is(Kn)?t=new Cf(i.value.create(),t.panel):i.is(dw)&&(t=new Cf(t.query,i.value?Ow:null));return t},provide:t=>gr.from(t,e=>e.panel)});var Cf=class{constructor(e,i){this.query=e,this.panel=i}},VK=we.mark({class:"cm-searchMatch"}),YK=we.mark({class:"cm-searchMatch cm-searchMatch-selected"}),FK=Ye.fromClass(class{constructor(t){this.view=t,this.decorations=this.highlight(t.state.field(is))}update(t){let e=t.state.field(is);(e!=t.startState.field(is)||t.docChanged||t.selectionSet||t.viewportChanged)&&(this.decorations=this.highlight(e))}highlight({query:t,panel:e}){if(!e||!t.spec.valid)return we.none;let{view:i}=this,r=new Ki;for(let n=0,o=i.visibleRanges,s=o.length;no[n+1].from-2*250;)l=o[++n].to;t.highlight(i.state,a,l,(c,u)=>{let f=i.state.selection.ranges.some(d=>d.from==c&&d.to==u);r.add(c,u,f?YK:VK)})}return r.finish()}},{decorations:t=>t.decorations});function _f(t){return e=>{let i=e.state.field(is,!1);return i&&i.query.spec.valid?t(e,i):Xl(e)}}var YX=_f((t,{query:e})=>{let{to:i}=t.state.selection.main,r=e.nextMatch(t.state,i,i);if(!r)return!1;let n=ee.single(r.from,r.to),o=t.state.facet($l);return t.dispatch({selection:n,effects:[bw(t,r),o.scrollToMatch(n.main,t)],userEvent:"select.search"}),n6(t),!0}),FX=_f((t,{query:e})=>{let{state:i}=t,{from:r}=i.selection.main,n=e.prevMatch(i,r,r);if(!n)return!1;let o=ee.single(n.from,n.to),s=t.state.facet($l);return t.dispatch({selection:o,effects:[bw(t,n),s.scrollToMatch(o.main,t)],userEvent:"select.search"}),n6(t),!0}),pw=_f((t,{query:e})=>{let i=e.matchAll(t.state,1e3);return!i||!i.length?!1:(t.dispatch({selection:ee.create(i.map(r=>ee.range(r.from,r.to))),userEvent:"select.search.matches"}),!0)}),i6=({state:t,dispatch:e})=>{let i=t.selection;if(i.ranges.length>1||i.main.empty)return!1;let{from:r,to:n}=i.main,o=[],s=0;for(let a=new rs(t.doc,t.sliceDoc(r,n));!a.next().done;){if(o.length>1e3)return!1;a.value.from==r&&(s=o.length),o.push(ee.range(a.value.from,a.value.to))}return e(t.update({selection:ee.create(o,s),userEvent:"select.search.matches"})),!0},HX=_f((t,{query:e})=>{let{state:i}=t,{from:r,to:n}=i.selection.main;if(i.readOnly)return!1;let o=e.nextMatch(i,r,r);if(!o)return!1;let s=[],a,l,c=[];if(o.from==r&&o.to==n&&(l=i.toText(e.getReplacement(o)),s.push({from:o.from,to:o.to,insert:l}),o=e.nextMatch(i,o.from,o.to),c.push(de.announce.of(i.phrase("replaced match on line $",i.doc.lineAt(r).number)+"."))),o){let u=s.length==0||s[0].from>=o.to?0:o.to-o.from-l.length;a=ee.single(o.from-u,o.to-u),c.push(bw(t,o)),c.push(i.facet($l).scrollToMatch(a.main,t))}return t.dispatch({changes:s,selection:a,effects:c,userEvent:"input.replace"}),!0}),mw=_f((t,{query:e})=>{if(t.state.readOnly)return!1;let i=e.matchAll(t.state,1e9).map(n=>{let{from:o,to:s}=n;return{from:o,to:s,insert:e.getReplacement(n)}});if(!i.length)return!1;let r=t.state.phrase("replaced $ matches",i.length)+".";return t.dispatch({changes:i,effects:de.announce.of(r),userEvent:"input.replace.all"}),!0});function Ow(t){return t.state.facet($l).createPanel(t)}function uw(t,e){var i,r,n,o,s;let a=t.selection.main,l=a.empty||a.to>a.from+100?"":t.sliceDoc(a.from,a.to);if(e&&!l)return e;let c=t.facet($l);return new Al({search:((i=e==null?void 0:e.literal)!==null&&i!==void 0?i:c.literal)?l:l.replace(/\n/g,"\\n"),caseSensitive:(r=e==null?void 0:e.caseSensitive)!==null&&r!==void 0?r:c.caseSensitive,literal:(n=e==null?void 0:e.literal)!==null&&n!==void 0?n: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 r6(t){let e=Ns(t,Ow);return e&&e.dom.querySelector("[main-field]")}function n6(t){let e=r6(t);e&&e==t.root.activeElement&&e.select()}var Xl=t=>{let e=t.state.field(is,!1);if(e&&e.panel){let i=r6(t);if(i&&i!=t.root.activeElement){let r=uw(t.state,e.query.spec);r.valid&&t.dispatch({effects:Kn.of(r)}),i.focus(),i.select()}}else t.dispatch({effects:[dw.of(!0),e?Kn.of(uw(t.state,e.query.spec)):Se.appendConfig.of(GK)]});return!0},gw=t=>{let e=t.state.field(is,!1);if(!e||!e.panel)return!1;let i=Ns(t,Ow);return i&&i.dom.contains(t.root.activeElement)&&t.focus(),t.dispatch({effects:dw.of(!1)}),!0};var fw=class{constructor(e){this.view=e;let i=this.query=e.state.field(is).query.spec;this.commit=this.commit.bind(this),this.searchField=ct("input",{value:i.search,placeholder:or(e,"Find"),"aria-label":or(e,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=ct("input",{value:i.replace,placeholder:or(e,"Replace"),"aria-label":or(e,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=ct("input",{type:"checkbox",name:"case",form:"",checked:i.caseSensitive,onchange:this.commit}),this.reField=ct("input",{type:"checkbox",name:"re",form:"",checked:i.regexp,onchange:this.commit}),this.wordField=ct("input",{type:"checkbox",name:"word",form:"",checked:i.wholeWord,onchange:this.commit});function r(n,o,s){return ct("button",{class:"cm-button",name:n,onclick:o,type:"button"},s)}this.dom=ct("div",{onkeydown:n=>this.keydown(n),class:"cm-search"},[this.searchField,r("next",()=>YX(e),[or(e,"next")]),r("prev",()=>FX(e),[or(e,"previous")]),r("select",()=>pw(e),[or(e,"all")]),ct("label",null,[this.caseField,or(e,"match case")]),ct("label",null,[this.reField,or(e,"regexp")]),ct("label",null,[this.wordField,or(e,"by word")]),...e.state.readOnly?[]:[ct("br"),this.replaceField,r("replace",()=>HX(e),[or(e,"replace")]),r("replaceAll",()=>mw(e),[or(e,"replace all")])],ct("button",{name:"close",onclick:()=>gw(e),"aria-label":or(e,"close"),type:"button"},["\xD7"])])}commit(){let e=new Al({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:Kn.of(e)}))}keydown(e){gy(this.view,e,"search-panel")?e.preventDefault():e.keyCode==13&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?FX:YX)(this.view)):e.keyCode==13&&e.target==this.replaceField&&(e.preventDefault(),HX(this.view))}update(e){for(let i of e.transactions)for(let r of i.effects)r.is(Kn)&&!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($l).top}};function or(t,e){return t.state.phrase(e)}var Km=30,Jm=/[\s\.,:;?!]/;function bw(t,{from:e,to:i}){let r=t.state.doc.lineAt(e),n=t.state.doc.lineAt(i).to,o=Math.max(r.from,e-Km),s=Math.min(n,i+Km),a=t.state.sliceDoc(o,s);if(o!=r.from){for(let l=0;la.length-Km;l--)if(!Jm.test(a[l-1])&&Jm.test(a[l])){a=a.slice(0,l);break}}return de.announce.of(`${t.state.phrase("current match")}. ${a} ${t.state.phrase("on line")} ${r.number}.`)}var HK=de.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"}}),GK=[is,Qt.low(FK),HK];var yw=class{constructor(e,i,r){this.from=e,this.to=i,this.diagnostic=r}},la=class t{constructor(e,i,r){this.diagnostics=e,this.panel=i,this.selected=r}static init(e,i,r){let n=e,o=r.facet(Pf).markerFilter;o&&(n=o(n,r));let s=we.set(n.map(a=>a.from==a.to||a.from==a.to-1&&r.doc.lineAt(a.from).to==a.from?we.widget({widget:new xw(a),diagnostic:a}).range(a.from):we.mark({attributes:{class:"cm-lintRange cm-lintRange-"+a.severity+(a.markClass?" "+a.markClass:"")},diagnostic:a,inclusive:!0}).range(a.from,a.to)),!0);return new t(s,i,Rl(s))}};function Rl(t,e=null,i=0){let r=null;return t.between(i,1e9,(n,o,{spec:s})=>{if(!(e&&s.diagnostic!=e))return r=new yw(n,o,s.diagnostic),!1}),r}function KK(t,e){let i=e.pos,r=e.end||i,n=t.state.facet(Pf).hideOn(t,i,r);if(n!=null)return n;let o=t.startState.doc.lineAt(e.pos);return!!(t.effects.some(s=>s.is(vw))||t.changes.touchesRange(o.from,Math.max(o.to,r)))}function s6(t,e){return t.field(sr,!1)?e:e.concat(Se.appendConfig.of(nJ))}function a6(t,e){return{effects:s6(t,[vw.of(e)])}}var vw=Se.define(),ww=Se.define(),l6=Se.define(),sr=Fe.define({create(){return new la(we.none,null,null)},update(t,e){if(e.docChanged&&t.diagnostics.size){let i=t.diagnostics.map(e.changes),r=null,n=t.panel;if(t.selected){let o=e.changes.mapPos(t.selected.from,1);r=Rl(i,t.selected.diagnostic,o)||Rl(i,null,o)}!i.size&&n&&e.state.facet(Pf).autoPanel&&(n=null),t=new la(i,n,r)}for(let i of e.effects)if(i.is(vw)){let r=e.state.facet(Pf).autoPanel?i.value.length?Qf.open:null:t.panel;t=la.init(i.value,r,e.state)}else i.is(ww)?t=new la(t.diagnostics,i.value?Qf.open:null,t.selected):i.is(l6)&&(t=new la(t.diagnostics,t.panel,i.value));return t},provide:t=>[gr.from(t,e=>e.panel),de.decorations.from(t,e=>e.diagnostics)]});var JK=we.mark({class:"cm-lintRange cm-lintRange-active",inclusive:!0});function eJ(t,e,i){let{diagnostics:r}=t.state.field(sr),n=[],o=2e8,s=0;r.between(e-(i<0?1:0),e+(i>0?1:0),(l,c,{spec:u})=>{e>=l&&e<=c&&(l==c||(e>l||i>0)&&(eh6(t,i,!1)))}var c6=t=>{let e=t.state.field(sr,!1);(!e||!e.panel)&&t.dispatch({effects:s6(t.state,[ww.of(!0)])});let i=Ns(t,Qf.open);return i&&i.dom.querySelector(".cm-panel-lint ul").focus(),!0},o6=t=>{let e=t.state.field(sr,!1);return!e||!e.panel?!1:(t.dispatch({effects:ww.of(!1)}),!0)},u6=t=>{let e=t.state.field(sr,!1);if(!e)return!1;let i=t.state.selection.main,r=e.diagnostics.iter(i.to+1);return!r.value&&(r=e.diagnostics.iter(0),!r.value||r.from==i.from&&r.to==i.to)?!1:(t.dispatch({selection:{anchor:r.from,head:r.to},scrollIntoView:!0}),!0)};var Pf=be.define({combine(t){return Object.assign({sources:t.map(e=>e.source).filter(e=>e!=null)},kt(t.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{needsRefresh:(e,i)=>e?i?r=>e(r)||i(r):e:i}))}});function f6(t){let e=[];if(t)e:for(let{name:i}of t){for(let r=0;ro.toLowerCase()==n.toLowerCase())){e.push(n);continue e}}e.push("")}return e}function h6(t,e,i){var r;let n=i?f6(e.actions):[];return ct("li",{class:"cm-diagnostic cm-diagnostic-"+e.severity},ct("span",{class:"cm-diagnosticText"},e.renderMessage?e.renderMessage(t):e.message),(r=e.actions)===null||r===void 0?void 0:r.map((o,s)=>{let a=!1,l=d=>{if(d.preventDefault(),a)return;a=!0;let p=Rl(t.state.field(sr).diagnostics,e);p&&o.apply(t,p.from,p.to)},{name:c}=o,u=n[s]?c.indexOf(n[s]):-1,f=u<0?c:[c.slice(0,u),ct("u",c.slice(u,u+1)),c.slice(u+1)];return ct("button",{type:"button",class:"cm-diagnosticAction",onclick:l,onmousedown:l,"aria-label":` Action: ${c}${u<0?"":` (access key "${n[s]})"`}.`},f)}),e.source&&ct("div",{class:"cm-diagnosticSource"},e.source))}var xw=class extends Ft{constructor(e){super(),this.diagnostic=e}eq(e){return e.diagnostic==this.diagnostic}toDOM(){return ct("span",{class:"cm-lintPoint cm-lintPoint-"+this.diagnostic.severity})}},lO=class{constructor(e,i){this.diagnostic=i,this.id="item_"+Math.floor(Math.random()*4294967295).toString(16),this.dom=h6(e,i,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}},Qf=class t{constructor(e){this.view=e,this.items=[];let i=n=>{if(n.keyCode==27)o6(this.view),this.view.focus();else if(n.keyCode==38||n.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(n.keyCode==40||n.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(n.keyCode==36)this.moveSelection(0);else if(n.keyCode==35)this.moveSelection(this.items.length-1);else if(n.keyCode==13)this.view.focus();else if(n.keyCode>=65&&n.keyCode<=90&&this.selectedIndex>=0){let{diagnostic:o}=this.items[this.selectedIndex],s=f6(o.actions);for(let a=0;a{for(let o=0;oo6(this.view)},"\xD7")),this.update()}get selectedIndex(){let e=this.view.state.field(sr).selected;if(!e)return-1;for(let i=0;i{let c=-1,u;for(let f=r;fr&&(this.items.splice(r,c-r),n=!0)),i&&u.diagnostic==i.diagnostic?u.dom.hasAttribute("aria-selected")||(u.dom.setAttribute("aria-selected","true"),o=u):u.dom.hasAttribute("aria-selected")&&u.dom.removeAttribute("aria-selected"),r++});r({sel:o.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:s,panel:a})=>{let l=a.height/this.list.offsetHeight;s.topa.bottom&&(this.list.scrollTop+=(s.bottom-a.bottom)/l)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),n&&this.sync()}sync(){let e=this.list.firstChild;function i(){let r=e;e=r.nextSibling,r.remove()}for(let r of this.items)if(r.dom.parentNode==this.list){for(;e!=r.dom;)i();e=r.dom.nextSibling}else this.list.insertBefore(r.dom,e);for(;e;)i()}moveSelection(e){if(this.selectedIndex<0)return;let i=this.view.state.field(sr),r=Rl(i.diagnostics,this.items[e].diagnostic);r&&this.view.dispatch({selection:{anchor:r.from,head:r.to},scrollIntoView:!0,effects:l6.of(r)})}static open(e){return new t(e)}};function iJ(t,e='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,${encodeURIComponent(t)}')`}function aO(t){return iJ(``,'width="6" height="3"')}var rJ=de.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:aO("#d11")},".cm-lintRange-warning":{backgroundImage:aO("orange")},".cm-lintRange-info":{backgroundImage:aO("#999")},".cm-lintRange-hint":{backgroundImage:aO("#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}}});var nJ=[sr,de.decorations.compute([sr],t=>{let{selected:e,panel:i}=t.field(sr);return!e||!i||e.from==e.to?we.none:we.set([JK.range(e.from,e.to)])}),Pp(eJ,{hideOn:KK}),rJ];var d6=t=>e=>{let i=t==="down",r=e.state.selection;for(let n of r.ranges)r=r.addRange(e.moveVertically(n,i));return e.dispatch({selection:r}),!0},oJ=d6("up"),sJ=d6("down"),aJ=t=>{let e=null;for(let i of t.state.selection.ranges)if(!i.empty)for(let r=i.from;r<=i.to;){let n=t.state.doc.lineAt(r),o=Math.min(n.to,i.to);e?e=e.addRange(ee.range(o,o)):e=ee.single(o),r=n.to+1}return e?(t.dispatch({selection:e}),!0):!1},p6=[{key:"Ctrl-Space",run:Lu},{key:"Escape",run:Du},{key:"ArrowDown",run:Yn(!0)},{key:"ArrowUp",run:Yn(!1)},{key:"PageDown",run:Yn(!0,"page")},{key:"PageUp",run:Yn(!1,"page")},{key:"Enter",run:Zp},{key:"Tab",run:Zp},{key:"Mod-f",run:Xl,scope:"editor search-panel"},{key:"Escape",run:gw,scope:"editor search-panel"},{key:"Alt-Enter",run:pw,scope:"editor search-panel"},{key:"Mod-Alt-Enter",run:mw,scope:"editor search-panel"},{key:"Ctrl-g",run:KX},{key:"Mod-d",run:t6,preventDefault:!0},{key:"Shift-Mod-l",run:i6},{key:"Enter",run:Sf,shift:Sf},{key:"ArrowLeft",run:hf,shift:Gv,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:Mm,shift:Zm},{key:"ArrowRight",run:Hv,shift:Kv,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:Um,shift:Vm},{key:"ArrowUp",run:df,shift:kl,preventDefault:!0},{key:"ArrowDown",run:pf,shift:Sl,preventDefault:!0},{key:"Home",run:Of,shift:iw},{mac:"Cmd-ArrowLeft",run:Of,shift:iw},{key:"Mod-Home",run:xf,shift:Tl},{mac:"Cmd-ArrowUp",run:xf,shift:Tl},{key:"PageUp",run:vl,shift:gf},{mac:"Ctrl-ArrowUp",run:vl,shift:gf},{key:"PageDown",run:wl,shift:aa},{mac:"Ctrl-ArrowDown",run:wl,shift:aa},{key:"End",run:mf,shift:tw},{mac:"Cmd-ArrowRight",run:mf,shift:tw},{key:"Mod-Alt-ArrowUp",linux:"Shift-Alt-ArrowUp",run:oJ,preventDefault:!0},{key:"Mod-Alt-ArrowDown",linux:"Shift-Alt-ArrowDown",run:sJ,preventDefault:!0},{key:"Shift-Alt-i",run:aJ},{key:"Mod-End",run:vf,shift:El},{mac:"Cmd-ArrowDown",run:vf,shift:El},{key:"Mod-a",run:Ym},{key:"Backspace",run:sP},{key:"Backspace",run:Cl,shift:Cl},{key:"Delete",run:wf},{key:"Mod-Backspace",mac:"Alt-Backspace",run:rw},{key:"Mod-Delete",mac:"Alt-Delete",run:$X},{mac:"Mod-Backspace",run:XX},{mac:"Mod-Delete",run:nw},{mac:"Ctrl-b",run:hf,shift:Gv,preventDefault:!0},{mac:"Ctrl-f",run:Hv,shift:Kv},{mac:"Ctrl-p",run:df,shift:kl},{mac:"Ctrl-n",run:pf,shift:Sl},{mac:"Ctrl-a",run:jm,shift:bf},{mac:"Ctrl-e",run:qm,shift:yf},{mac:"Ctrl-d",run:wf},{mac:"Ctrl-h",run:Cl},{mac:"Ctrl-k",run:nw},{mac:"Ctrl-Alt-h",run:rw},{mac:"Ctrl-o",run:kf},{mac:"Ctrl-t",run:Hm},{mac:"Ctrl-v",run:wl},{mac:"Alt-v",run:vl},{key:"Shift-Mod-k",run:UX},{key:"Alt-ArrowDown",run:LX},{key:"Alt-ArrowUp",run:IX},{win:"Shift-Alt-ArrowDown",mac:"Shift-Alt-ArrowDown",run:MX},{win:"Shift-Alt-ArrowUp",mac:"Shift-Alt-ArrowUp",run:NX},{key:"Mod-l",run:PX,preventDefault:!0},{key:"Shift-Mod-\\",run:SX},{key:"Tab",run:Tf,shift:Ef,preventDefault:!0},{key:"Mod-[",run:Ef},{key:"Mod-]",run:Tf},{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:Up},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:__},{key:"Mod-k Mod-0",run:Q_},{key:"Mod-k Mod-j",run:A_},{key:"Mod-k Mod-c",run:cX},{key:"Mod-k Mod-u",run:uX},{key:"Mod-/",run:cf},{key:"Shift-Alt-a",run:fX},{key:"Mod-z",run:oa,preventDefault:!0},{key:"Mod-y",run:Ko,preventDefault:!0},{key:"Mod-Shift-z",run:Ko,preventDefault:!0},{key:"Mod-u",run:OX,preventDefault:!0},{key:"Mod-Shift-m",run:c6},{key:"F8",run:u6}];function lJ(t){var e=t.Pos;function i(h,m,b){if(m.line===b.line&&m.ch>=b.ch-1){var y=h.getLine(m.line),w=y.charCodeAt(m.ch);55296<=w&&w<=55551&&(b.ch+=1)}return{start:m,end:b}}var r=[{keys:"",type:"keyToKey",toKeys:"h"},{keys:"",type:"keyToKey",toKeys:"l"},{keys:"",type:"keyToKey",toKeys:"k"},{keys:"",type:"keyToKey",toKeys:"j"},{keys:"g",type:"keyToKey",toKeys:"gk"},{keys:"g",type:"keyToKey",toKeys:"gj"},{keys:"",type:"keyToKey",toKeys:"l"},{keys:"",type:"keyToKey",toKeys:"h"},{keys:"",type:"keyToKey",toKeys:"x"},{keys:"",type:"keyToKey",toKeys:"W"},{keys:"",type:"keyToKey",toKeys:"B"},{keys:"",type:"keyToKey",toKeys:"w"},{keys:"",type:"keyToKey",toKeys:"b"},{keys:"",type:"keyToKey",toKeys:"j"},{keys:"",type:"keyToKey",toKeys:"k"},{keys:"",type:"keyToKey",toKeys:""},{keys:"",type:"keyToKey",toKeys:""},{keys:"",type:"keyToKey",toKeys:"",context:"insert"},{keys:"",type:"keyToKey",toKeys:"",context:"insert"},{keys:"",type:"keyToKey",toKeys:""},{keys:"",type:"keyToKey",toKeys:"",context:"insert"},{keys:"s",type:"keyToKey",toKeys:"cl",context:"normal"},{keys:"s",type:"keyToKey",toKeys:"c",context:"visual"},{keys:"S",type:"keyToKey",toKeys:"cc",context:"normal"},{keys:"S",type:"keyToKey",toKeys:"VdO",context:"visual"},{keys:"",type:"keyToKey",toKeys:"0"},{keys:"",type:"keyToKey",toKeys:"$"},{keys:"",type:"keyToKey",toKeys:""},{keys:"",type:"keyToKey",toKeys:""},{keys:"",type:"keyToKey",toKeys:"j^",context:"normal"},{keys:"",type:"keyToKey",toKeys:"i",context:"normal"},{keys:"",type:"action",action:"toggleOverwrite",context:"insert"},{keys:"H",type:"motion",motion:"moveToTopLine",motionArgs:{linewise:!0,toJumplist:!0}},{keys:"M",type:"motion",motion:"moveToMiddleLine",motionArgs:{linewise:!0,toJumplist:!0}},{keys:"L",type:"motion",motion:"moveToBottomLine",motionArgs:{linewise:!0,toJumplist:!0}},{keys:"h",type:"motion",motion:"moveByCharacters",motionArgs:{forward:!1}},{keys:"l",type:"motion",motion:"moveByCharacters",motionArgs:{forward:!0}},{keys:"j",type:"motion",motion:"moveByLines",motionArgs:{forward:!0,linewise:!0}},{keys:"k",type:"motion",motion:"moveByLines",motionArgs:{forward:!1,linewise:!0}},{keys:"gj",type:"motion",motion:"moveByDisplayLines",motionArgs:{forward:!0}},{keys:"gk",type:"motion",motion:"moveByDisplayLines",motionArgs:{forward:!1}},{keys:"w",type:"motion",motion:"moveByWords",motionArgs:{forward:!0,wordEnd:!1}},{keys:"W",type:"motion",motion:"moveByWords",motionArgs:{forward:!0,wordEnd:!1,bigWord:!0}},{keys:"e",type:"motion",motion:"moveByWords",motionArgs:{forward:!0,wordEnd:!0,inclusive:!0}},{keys:"E",type:"motion",motion:"moveByWords",motionArgs:{forward:!0,wordEnd:!0,bigWord:!0,inclusive:!0}},{keys:"b",type:"motion",motion:"moveByWords",motionArgs:{forward:!1,wordEnd:!1}},{keys:"B",type:"motion",motion:"moveByWords",motionArgs:{forward:!1,wordEnd:!1,bigWord:!0}},{keys:"ge",type:"motion",motion:"moveByWords",motionArgs:{forward:!1,wordEnd:!0,inclusive:!0}},{keys:"gE",type:"motion",motion:"moveByWords",motionArgs:{forward:!1,wordEnd:!0,bigWord:!0,inclusive:!0}},{keys:"{",type:"motion",motion:"moveByParagraph",motionArgs:{forward:!1,toJumplist:!0}},{keys:"}",type:"motion",motion:"moveByParagraph",motionArgs:{forward:!0,toJumplist:!0}},{keys:"(",type:"motion",motion:"moveBySentence",motionArgs:{forward:!1}},{keys:")",type:"motion",motion:"moveBySentence",motionArgs:{forward:!0}},{keys:"",type:"motion",motion:"moveByPage",motionArgs:{forward:!0}},{keys:"",type:"motion",motion:"moveByPage",motionArgs:{forward:!1}},{keys:"",type:"motion",motion:"moveByScroll",motionArgs:{forward:!0,explicitRepeat:!0}},{keys:"",type:"motion",motion:"moveByScroll",motionArgs:{forward:!1,explicitRepeat:!0}},{keys:"gg",type:"motion",motion:"moveToLineOrEdgeOfDocument",motionArgs:{forward:!1,explicitRepeat:!0,linewise:!0,toJumplist:!0}},{keys:"G",type:"motion",motion:"moveToLineOrEdgeOfDocument",motionArgs:{forward:!0,explicitRepeat:!0,linewise:!0,toJumplist:!0}},{keys:"g$",type:"motion",motion:"moveToEndOfDisplayLine"},{keys:"g^",type:"motion",motion:"moveToStartOfDisplayLine"},{keys:"g0",type:"motion",motion:"moveToStartOfDisplayLine"},{keys:"0",type:"motion",motion:"moveToStartOfLine"},{keys:"^",type:"motion",motion:"moveToFirstNonWhiteSpaceCharacter"},{keys:"+",type:"motion",motion:"moveByLines",motionArgs:{forward:!0,toFirstChar:!0}},{keys:"-",type:"motion",motion:"moveByLines",motionArgs:{forward:!1,toFirstChar:!0}},{keys:"_",type:"motion",motion:"moveByLines",motionArgs:{forward:!0,toFirstChar:!0,repeatOffset:-1}},{keys:"$",type:"motion",motion:"moveToEol",motionArgs:{inclusive:!0}},{keys:"%",type:"motion",motion:"moveToMatchedSymbol",motionArgs:{inclusive:!0,toJumplist:!0}},{keys:"f",type:"motion",motion:"moveToCharacter",motionArgs:{forward:!0,inclusive:!0}},{keys:"F",type:"motion",motion:"moveToCharacter",motionArgs:{forward:!1}},{keys:"t",type:"motion",motion:"moveTillCharacter",motionArgs:{forward:!0,inclusive:!0}},{keys:"T",type:"motion",motion:"moveTillCharacter",motionArgs:{forward:!1}},{keys:";",type:"motion",motion:"repeatLastCharacterSearch",motionArgs:{forward:!0}},{keys:",",type:"motion",motion:"repeatLastCharacterSearch",motionArgs:{forward:!1}},{keys:"'",type:"motion",motion:"goToMark",motionArgs:{toJumplist:!0,linewise:!0}},{keys:"`",type:"motion",motion:"goToMark",motionArgs:{toJumplist:!0}},{keys:"]`",type:"motion",motion:"jumpToMark",motionArgs:{forward:!0}},{keys:"[`",type:"motion",motion:"jumpToMark",motionArgs:{forward:!1}},{keys:"]'",type:"motion",motion:"jumpToMark",motionArgs:{forward:!0,linewise:!0}},{keys:"['",type:"motion",motion:"jumpToMark",motionArgs:{forward:!1,linewise:!0}},{keys:"]p",type:"action",action:"paste",isEdit:!0,actionArgs:{after:!0,isEdit:!0,matchIndent:!0}},{keys:"[p",type:"action",action:"paste",isEdit:!0,actionArgs:{after:!1,isEdit:!0,matchIndent:!0}},{keys:"]",type:"motion",motion:"moveToSymbol",motionArgs:{forward:!0,toJumplist:!0}},{keys:"[",type:"motion",motion:"moveToSymbol",motionArgs:{forward:!1,toJumplist:!0}},{keys:"|",type:"motion",motion:"moveToColumn"},{keys:"o",type:"motion",motion:"moveToOtherHighlightedEnd",context:"visual"},{keys:"O",type:"motion",motion:"moveToOtherHighlightedEnd",motionArgs:{sameLine:!0},context:"visual"},{keys:"d",type:"operator",operator:"delete"},{keys:"y",type:"operator",operator:"yank"},{keys:"c",type:"operator",operator:"change"},{keys:"=",type:"operator",operator:"indentAuto"},{keys:">",type:"operator",operator:"indent",operatorArgs:{indentRight:!0}},{keys:"<",type:"operator",operator:"indent",operatorArgs:{indentRight:!1}},{keys:"g~",type:"operator",operator:"changeCase"},{keys:"gu",type:"operator",operator:"changeCase",operatorArgs:{toLower:!0},isEdit:!0},{keys:"gU",type:"operator",operator:"changeCase",operatorArgs:{toLower:!1},isEdit:!0},{keys:"n",type:"motion",motion:"findNext",motionArgs:{forward:!0,toJumplist:!0}},{keys:"N",type:"motion",motion:"findNext",motionArgs:{forward:!1,toJumplist:!0}},{keys:"gn",type:"motion",motion:"findAndSelectNextInclusive",motionArgs:{forward:!0}},{keys:"gN",type:"motion",motion:"findAndSelectNextInclusive",motionArgs:{forward:!1}},{keys:"gq",type:"operator",operator:"hardWrap"},{keys:"gw",type:"operator",operator:"hardWrap",operatorArgs:{keepCursor:!0}},{keys:"x",type:"operatorMotion",operator:"delete",motion:"moveByCharacters",motionArgs:{forward:!0},operatorMotionArgs:{visualLine:!1}},{keys:"X",type:"operatorMotion",operator:"delete",motion:"moveByCharacters",motionArgs:{forward:!1},operatorMotionArgs:{visualLine:!0}},{keys:"D",type:"operatorMotion",operator:"delete",motion:"moveToEol",motionArgs:{inclusive:!0},context:"normal"},{keys:"D",type:"operator",operator:"delete",operatorArgs:{linewise:!0},context:"visual"},{keys:"Y",type:"operatorMotion",operator:"yank",motion:"expandToLine",motionArgs:{linewise:!0},context:"normal"},{keys:"Y",type:"operator",operator:"yank",operatorArgs:{linewise:!0},context:"visual"},{keys:"C",type:"operatorMotion",operator:"change",motion:"moveToEol",motionArgs:{inclusive:!0},context:"normal"},{keys:"C",type:"operator",operator:"change",operatorArgs:{linewise:!0},context:"visual"},{keys:"~",type:"operatorMotion",operator:"changeCase",motion:"moveByCharacters",motionArgs:{forward:!0},operatorArgs:{shouldMoveCursor:!0},context:"normal"},{keys:"~",type:"operator",operator:"changeCase",context:"visual"},{keys:"",type:"operatorMotion",operator:"delete",motion:"moveToStartOfLine",context:"insert"},{keys:"",type:"operatorMotion",operator:"delete",motion:"moveByWords",motionArgs:{forward:!1,wordEnd:!1},context:"insert"},{keys:"",type:"idle",context:"normal"},{keys:"",type:"action",action:"jumpListWalk",actionArgs:{forward:!0}},{keys:"",type:"action",action:"jumpListWalk",actionArgs:{forward:!1}},{keys:"",type:"action",action:"scroll",actionArgs:{forward:!0,linewise:!0}},{keys:"",type:"action",action:"scroll",actionArgs:{forward:!1,linewise:!0}},{keys:"a",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"charAfter"},context:"normal"},{keys:"A",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"eol"},context:"normal"},{keys:"A",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"endOfSelectedArea"},context:"visual"},{keys:"i",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"inplace"},context:"normal"},{keys:"gi",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"lastEdit"},context:"normal"},{keys:"I",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"firstNonBlank"},context:"normal"},{keys:"gI",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"bol"},context:"normal"},{keys:"I",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"startOfSelectedArea"},context:"visual"},{keys:"o",type:"action",action:"newLineAndEnterInsertMode",isEdit:!0,interlaceInsertRepeat:!0,actionArgs:{after:!0},context:"normal"},{keys:"O",type:"action",action:"newLineAndEnterInsertMode",isEdit:!0,interlaceInsertRepeat:!0,actionArgs:{after:!1},context:"normal"},{keys:"v",type:"action",action:"toggleVisualMode"},{keys:"V",type:"action",action:"toggleVisualMode",actionArgs:{linewise:!0}},{keys:"",type:"action",action:"toggleVisualMode",actionArgs:{blockwise:!0}},{keys:"",type:"action",action:"toggleVisualMode",actionArgs:{blockwise:!0}},{keys:"gv",type:"action",action:"reselectLastSelection"},{keys:"J",type:"action",action:"joinLines",isEdit:!0},{keys:"gJ",type:"action",action:"joinLines",actionArgs:{keepSpaces:!0},isEdit:!0},{keys:"p",type:"action",action:"paste",isEdit:!0,actionArgs:{after:!0,isEdit:!0}},{keys:"P",type:"action",action:"paste",isEdit:!0,actionArgs:{after:!1,isEdit:!0}},{keys:"r",type:"action",action:"replace",isEdit:!0},{keys:"@",type:"action",action:"replayMacro"},{keys:"q",type:"action",action:"enterMacroRecordMode"},{keys:"R",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{replace:!0},context:"normal"},{keys:"R",type:"operator",operator:"change",operatorArgs:{linewise:!0,fullLine:!0},context:"visual",exitVisualBlock:!0},{keys:"u",type:"action",action:"undo",context:"normal"},{keys:"u",type:"operator",operator:"changeCase",operatorArgs:{toLower:!0},context:"visual",isEdit:!0},{keys:"U",type:"operator",operator:"changeCase",operatorArgs:{toLower:!1},context:"visual",isEdit:!0},{keys:"",type:"action",action:"redo"},{keys:"m",type:"action",action:"setMark"},{keys:'"',type:"action",action:"setRegister"},{keys:"",type:"action",action:"insertRegister",context:"insert",isEdit:!0},{keys:"",type:"action",action:"oneNormalCommand",context:"insert"},{keys:"zz",type:"action",action:"scrollToCursor",actionArgs:{position:"center"}},{keys:"z.",type:"action",action:"scrollToCursor",actionArgs:{position:"center"},motion:"moveToFirstNonWhiteSpaceCharacter"},{keys:"zt",type:"action",action:"scrollToCursor",actionArgs:{position:"top"}},{keys:"z",type:"action",action:"scrollToCursor",actionArgs:{position:"top"},motion:"moveToFirstNonWhiteSpaceCharacter"},{keys:"zb",type:"action",action:"scrollToCursor",actionArgs:{position:"bottom"}},{keys:"z-",type:"action",action:"scrollToCursor",actionArgs:{position:"bottom"},motion:"moveToFirstNonWhiteSpaceCharacter"},{keys:".",type:"action",action:"repeatLastEdit"},{keys:"",type:"action",action:"incrementNumberToken",isEdit:!0,actionArgs:{increase:!0,backtrack:!1}},{keys:"",type:"action",action:"incrementNumberToken",isEdit:!0,actionArgs:{increase:!1,backtrack:!1}},{keys:"",type:"action",action:"indent",actionArgs:{indentRight:!0},context:"insert"},{keys:"",type:"action",action:"indent",actionArgs:{indentRight:!1},context:"insert"},{keys:"a",type:"motion",motion:"textObjectManipulation"},{keys:"i",type:"motion",motion:"textObjectManipulation",motionArgs:{textObjectInner:!0}},{keys:"/",type:"search",searchArgs:{forward:!0,querySrc:"prompt",toJumplist:!0}},{keys:"?",type:"search",searchArgs:{forward:!1,querySrc:"prompt",toJumplist:!0}},{keys:"*",type:"search",searchArgs:{forward:!0,querySrc:"wordUnderCursor",wholeWordOnly:!0,toJumplist:!0}},{keys:"#",type:"search",searchArgs:{forward:!1,querySrc:"wordUnderCursor",wholeWordOnly:!0,toJumplist:!0}},{keys:"g*",type:"search",searchArgs:{forward:!0,querySrc:"wordUnderCursor",toJumplist:!0}},{keys:"g#",type:"search",searchArgs:{forward:!1,querySrc:"wordUnderCursor",toJumplist:!0}},{keys:":",type:"ex"}],n=r.length,o=[{name:"colorscheme",shortName:"colo"},{name:"map"},{name:"imap",shortName:"im"},{name:"nmap",shortName:"nm"},{name:"vmap",shortName:"vm"},{name:"omap",shortName:"om"},{name:"noremap",shortName:"no"},{name:"nnoremap",shortName:"nn"},{name:"vnoremap",shortName:"vn"},{name:"inoremap",shortName:"ino"},{name:"onoremap",shortName:"ono"},{name:"unmap"},{name:"mapclear",shortName:"mapc"},{name:"nmapclear",shortName:"nmapc"},{name:"vmapclear",shortName:"vmapc"},{name:"imapclear",shortName:"imapc"},{name:"omapclear",shortName:"omapc"},{name:"write",shortName:"w"},{name:"undo",shortName:"u"},{name:"redo",shortName:"red"},{name:"set",shortName:"se"},{name:"setlocal",shortName:"setl"},{name:"setglobal",shortName:"setg"},{name:"sort",shortName:"sor"},{name:"substitute",shortName:"s",possiblyAsync:!0},{name:"startinsert",shortName:"start"},{name:"nohlsearch",shortName:"noh"},{name:"yank",shortName:"y"},{name:"delmarks",shortName:"delm"},{name:"registers",shortName:"reg",excludeFromCommandHistory:!0},{name:"vglobal",shortName:"v"},{name:"delete",shortName:"d"},{name:"join",shortName:"j"},{name:"normal",shortName:"norm"},{name:"global",shortName:"g"}],s=lr("");function a(h){h.setOption("disableInput",!0),h.setOption("showCursorWhenSelecting",!1),t.signal(h,"vim-mode-change",{mode:"normal"}),h.on("cursorActivity",ck),ve(h),t.on(h.getInputField(),"paste",c(h))}function l(h){h.setOption("disableInput",!1),h.off("cursorActivity",ck),t.off(h.getInputField(),"paste",c(h)),h.state.vim=null,Wl&&clearTimeout(Wl)}function c(h){var m=h.state.vim;return m.onPasteFn||(m.onPasteFn=function(){m.insertMode||(h.setCursor($e(h.getCursor(),0,1)),ce.enterInsertMode(h,{},m))}),m.onPasteFn}var u=/[\d]/,f=[t.isWordChar,function(h){return h&&!t.isWordChar(h)&&!/\s/.test(h)}],d=[function(h){return/\S/.test(h)}],p=["<",">"],g=["-",'"',".",":","_","/","+"],x=/^\w$/,v;try{v=new RegExp("^[\\p{Lu}]$","u")}catch(h){v=/^[A-Z]$/}function S(h,m){return m>=h.firstLine()&&m<=h.lastLine()}function T(h){return/^[a-z]$/.test(h)}function $(h){return"()[]{}".indexOf(h)!=-1}function L(h){return u.test(h)}function P(h){return v.test(h)}function A(h){return/^\s*$/.test(h)}function q(h){return".?!".indexOf(h)!=-1}function le(h,m){for(var b=0;b1&&m.setOption("textwidth",y)}});var re=function(){var h=100,m=-1,b=0,y=0,w=new Array(h);function k(R,M,z){var G=m%h,J=w[G];function Y(oe){var fe=++m%h,Ae=w[fe];Ae&&Ae.clear(),w[fe]=R.setBookmark(oe)}if(J){var W=J.find();W&&!mt(W,M)&&Y(M)}else Y(M);Y(z),b=m,y=m-h+1,y<0&&(y=0)}function _(R,M){m+=M,m>b?m=b:m0?1:-1,J,Y=R.getCursor();do if(m+=G,z=w[(h+m)%h],z&&(J=z.find())&&!mt(Y,J))break;while(my)}return z}function X(R,M){var z=m,G=_(R,M);return m=z,G&&G.find()}return{cachedCursor:void 0,add:k,find:X,move:_}},he=function(h){return h?{changes:h.changes,expectCursorActivityForChange:h.expectCursorActivityForChange}:{changes:[],expectCursorActivityForChange:!1}};class Oe{constructor(){this.latestRegister=void 0,this.isPlaying=!1,this.isRecording=!1,this.replaySearchQueries=[],this.onRecordingDone=void 0,this.lastInsertModeChanges=he()}exitMacroRecordMode(){var m=j.macroModeState;m.onRecordingDone&&m.onRecordingDone(),m.onRecordingDone=void 0,m.isRecording=!1}enterMacroRecordMode(m,b){var y=j.registerController.getRegister(b);if(y){if(y.clear(),this.latestRegister=b,m.openDialog){var w=ao("span",{class:"cm-vim-message"},"recording @"+b);this.onRecordingDone=m.openDialog(w,null,{bottom:!0})}this.isRecording=!0}}}function ve(h){return h.state.vim||(h.state.vim={inputState:new cr,lastEditInputState:void 0,lastEditActionCommand:void 0,lastHPos:-1,lastHSPos:-1,lastMotion:null,marks:{},insertMode:!1,insertModeReturn:!1,insertModeRepeat:void 0,visualMode:!1,visualLine:!1,visualBlock:!1,lastSelection:null,lastPastedText:null,sel:{},options:{},expectLiteralNext:!1}),h.state.vim}var j;function ae(){j={searchQuery:null,searchIsReversed:!1,lastSubstituteReplacePart:void 0,jumpList:re(),macroModeState:new Oe,lastCharacterSearch:{increment:0,forward:!0,selectedCharacter:""},registerController:new zO({}),searchHistoryController:new Ul,exCommandHistoryController:new Ul};for(var h in F){var m=F[h];m.value=m.defaultValue}}var V,E={enterVimMode:a,leaveVimMode:l,buildKeyMap:function(){},getRegisterController:function(){return j.registerController},resetVimGlobalState_:ae,getVimGlobalState_:function(){return j},maybeInitVimState_:ve,suppressErrorLogging:!1,InsertModeKey:HO,map:function(h,m,b){Cr.map(h,m,b)},unmap:function(h,m){return Cr.unmap(h,m)},noremap:function(h,m,b){Cr.map(h,m,b,!0)},mapclear:function(h){var m=r.length,b=n,y=r.slice(0,m-b);if(r=r.slice(m-b),h)for(var w=y.length-1;w>=0;w--){var k=y[w];if(h!==k.context)if(k.context)this._mapCommand(k);else{var _=["normal","insert","visual"];for(var X in _)if(_[X]!==h){var R=Object.assign({},k);R.context=_[X],this._mapCommand(R)}}}},langmap:_t,vimKeyFromEvent:Ct,setOption:ie,getOption:ue,defineOption:U,defineEx:function(h,m,b){if(!m)m=h;else if(h.indexOf(m)!==0)throw new Error('(Vim.defineEx) "'+m+'" is not a prefix of "'+h+'", command not registered');sk[h]=b,Cr.commandMap_[m]={name:h,shortName:m,type:"api"}},handleKey:function(h,m,b){var y=this.findKey(h,m,b);if(typeof y=="function")return y()},multiSelectHandleKey:mL,findKey:function(h,m,b){var y=ve(h),w=h;function k(){var z=j.macroModeState;if(z.isRecording){if(m=="q")return z.exitMacroRecordMode(),Xt(w),!0;b!="mapping"&&hL(z,m)}}function _(){if(m==""){if(y.visualMode)Br(w);else if(y.insertMode)lo(w);else return;return Xt(w),!0}}function X(){if(_())return!0;y.inputState.keyBuffer.push(m);var z=y.inputState.keyBuffer.join(""),G=m.length==1,J=Wr.matchCommand(z,r,y.inputState,"insert"),Y=y.inputState.changeQueue;if(J.type=="none")return Xt(w),!1;if(J.type=="partial"){if(J.expectLiteralNext&&(y.expectLiteralNext=!0),V&&window.clearTimeout(V),V=G&&window.setTimeout(function(){y.insertMode&&y.inputState.keyBuffer.length&&Xt(w)},ue("insertModeEscKeysTimeout")),G){var W=w.listSelections();(!Y||Y.removed.length!=W.length)&&(Y=y.inputState.changeQueue=new Ff),Y.inserted+=m;for(var oe=0;oe|./gi,_;_=k.exec(m);){var X=_[0],R=w.insertMode;if(D){Ue(X);continue}var M=E.handleKey(h,X,"mapping");if(!M&&R&&w.insertMode){if(X[0]=="<"){var z=X.toLowerCase().slice(1,-1),G=z.split("-");if(z=G.pop()||"",z=="lt")X="<";else if(z=="space")X=" ";else if(z=="cr")X=`