From 7f0c82b7bb2e3d99f3e5fe983b6ec894bffc8790 Mon Sep 17 00:00:00 2001 From: jonatanklosko Date: Thu, 23 Nov 2023 16:05:21 +0000 Subject: [PATCH] Update assets --- static/assets/app.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/static/assets/app.js b/static/assets/app.js index e139eeae0..e9d9c4e3c 100644 --- a/static/assets/app.js +++ b/static/assets/app.js @@ -475,7 +475,7 @@ ${n.message}`)))}function Fve(){return import("./mermaid.core-KJGAOKCX.js" `)}},b4=oN;function Bve(i){return xt(ue({},Hs),{attributes:xt(ue({},Hs.attributes),{"*":[...Hs.attributes["*"]||[],"className","style"]}),protocols:xt(ue({},Hs.protocols),{href:[...Hs.protocols.href,...i]})})}function Hve(i){return e=>{let t=[];return Rn(e,"code",r=>{if(r.lang){let n=function(s){r.type="html",r.value=`
${s}
`},o=i.highlight(r.value,r.lang);if(o&&typeof o.then=="function"){let s=Promise.resolve(o).then(n);t.push(s)}else n(o)}}),Promise.all(t).then(()=>null)}}function Uve(i){return e=>{i.baseUrl&&Rn(e,"element",t=>{if(t.tagName==="a"&&t.properties){let r=t.properties.href;r&&!sN(r)&&!aN(r)&&!Kve(r)&&(t.properties.href=kQ(i.baseUrl,r))}if(t.tagName==="img"&&t.properties){let r=t.properties.src;r&&!sN(r)&&!aN(r)&&(t.properties.src=kQ(i.baseUrl,r))}}),Rn(e,"element",t=>{t.tagName==="a"&&t.properties&&t.properties.href&&(t.properties.href=t.properties.href.split("/").map(r=>r===".."?"__parent__":r).join("/"))})}}var jve=Ay().use(cx,{fragment:!0});function Wve(i){return e=>{Rn(e,"code",(t,r,n)=>{t.lang==="mermaid"&&(t.type="html",t.value=`
${yQ(t.value)}
- `)})}}function Vve(i){return e=>{let t=[];return Rn(e,"element",r=>{if((r.properties&&Array.isArray(r.properties.className)?r.properties.className:[]).includes("mermaid")){let o=function(l){let c=jve.parse(l);aT(c,!0),r.children=c.children},s=y0(r,{whitespace:"pre"}),a=SQ(s).then(o);t.push(a)}}),Promise.all(t).then(()=>null)}}function qve(i){return e=>{Rn(e,"element",t=>{if(t.properties&&t.properties.href){let r=t.properties.href;aN(r)?(t.properties["data-phx-link"]=i.baseUrl&&r.startsWith(i.baseUrl)?"patch":"redirect",t.properties["data-phx-link-state"]="push"):sN(r)&&(t.properties.target="_blank",t.properties.rel="noreferrer noopener")}})}}function sN(i){return/^(?:[a-z]+:)?\/\//i.test(i)}function Kve(i){return i.startsWith("#")}function aN(i){return i.startsWith("/")||i.startsWith(window.location.origin)}function kQ(i,e){return i.replace(/\/$/,"")+"/"+e}var v4=class{constructor(){this.subscribersByTopic={}}subscribe(e,t){return Array.isArray(this.subscribersByTopic[e])||(this.subscribersByTopic[e]=[]),this.subscribersByTopic[e].push(t),()=>{this.unsubscribe(e,t)}}unsubscribe(e,t){let r=this.subscribersByTopic[e].indexOf(t);r!==-1&&this.subscribersByTopic[e].splice(r,1)}broadcast(e,t){Array.isArray(this.subscribersByTopic[e])&&this.subscribersByTopic[e].forEach(r=>{r(t)})}},_r=new v4;var EQ=i=>typeof i=="object"&&i!=null&&i.nodeType===1,TQ=(i,e)=>(!e||i!=="hidden")&&i!=="visible"&&i!=="clip",lN=(i,e)=>{if(i.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>i&&s=e&&a>=t?o-i-r:s>e&&at?s-e+n:0,$ve=i=>{let e=i.parentElement;return e==null?i.getRootNode().host||null:e},cN=(i,e)=>{var t,r,n,o;if(typeof document=="undefined")return[];let{scrollMode:s,block:a,inline:l,boundary:c,skipOverflowHiddenElements:d}=e,u=typeof c=="function"?c:Pe=>Pe!==c;if(!EQ(i))throw new TypeError("Invalid target");let h=document.scrollingElement||document.documentElement,f=[],m=i;for(;EQ(m)&&u(m);){if(m=$ve(m),m===h){f.push(m);break}m!=null&&m===document.body&&lN(m)&&!lN(document.documentElement)||m!=null&&lN(m,d)&&f.push(m)}let g=(r=(t=window.visualViewport)==null?void 0:t.width)!=null?r:innerWidth,w=(o=(n=window.visualViewport)==null?void 0:n.height)!=null?o:innerHeight,{scrollX:_,scrollY:E}=window,{height:A,width:L,top:O,right:U,bottom:Y,left:oe}=i.getBoundingClientRect(),te=a==="start"||a==="nearest"?O:a==="end"?Y:O+A/2,Z=l==="center"?oe+L/2:l==="end"?U:oe,ve=[];for(let Pe=0;Pe=0&&oe>=0&&Y<=w&&U<=g&&O>=dt&&Y<=we&&oe>=X&&U<=be)return ve;let R=getComputedStyle(Ee),ne=parseInt(R.borderLeftWidth,10),me=parseInt(R.borderTopWidth,10),G=parseInt(R.borderRightWidth,10),Et=parseInt(R.borderBottomWidth,10),Ot=0,ai=0,Ti="offsetWidth"in Ee?Ee.offsetWidth-Ee.clientWidth-ne-G:0,kt="offsetHeight"in Ee?Ee.offsetHeight-Ee.clientHeight-me-Et:0,Ei="offsetWidth"in Ee?Ee.offsetWidth===0?0:Xe/Ee.offsetWidth:0,fi="offsetHeight"in Ee?Ee.offsetHeight===0?0:Oe/Ee.offsetHeight:0;if(h===Ee)Ot=a==="start"?te:a==="end"?te-w:a==="nearest"?_4(E,E+w,w,me,Et,E+te,E+te+A,A):te-w/2,ai=l==="start"?Z:l==="center"?Z-g/2:l==="end"?Z-g:_4(_,_+g,g,ne,G,_+Z,_+Z+L,L),Ot=Math.max(0,Ot+E),ai=Math.max(0,ai+_);else{Ot=a==="start"?te-dt-me:a==="end"?te-we+Et+kt:a==="nearest"?_4(dt,we,Oe,me,Et+kt,te,te+A,A):te-(dt+Oe/2)+kt/2,ai=l==="start"?Z-X-ne:l==="center"?Z-(X+Xe/2)+Ti/2:l==="end"?Z-be+G+Ti:_4(X,be,Xe,ne,G+Ti,Z,Z+L,L);let{scrollLeft:xo,scrollTop:ro}=Ee;Ot=Math.max(0,Math.min(ro+Ot/fi,Ee.scrollHeight-Oe/fi+kt)),ai=Math.max(0,Math.min(xo+ai/Ei,Ee.scrollWidth-Xe/Ei+Ti)),te+=ro-Ot,Z+=xo-ai}ve.push({el:Ee,top:Ot,left:ai})}return ve};var Gve=i=>i===!1?{block:"end",inline:"nearest"}:(e=>e===Object(e)&&Object.keys(e).length!==0)(i)?i:{block:"start",inline:"nearest"};function IQ(i,e){if(!i.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})(i))return;let t=(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}})(i);if((n=>typeof n=="object"&&typeof n.behavior=="function")(e))return e.behavior(cN(i,e));let r=typeof e=="boolean"||e==null?void 0:e.behavior;for(let{el:n,top:o,left:s}of cN(i,Gve(e))){let a=o-t.top+t.bottom,l=s-t.left+t.right;n.scroll({top:a,left:l,behavior:r})}}function Oh(i){return["code","smart","setup"].includes(i)}function LQ(i){return["markdown","code","setup"].includes(i)}var Yve={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",i=>{let{tag:e,liveEditor:t}=i.detail;this.handleCellEditorCreated(e,t)}),this.el.addEventListener("lb:cell:editor_removed",i=>{let{tag:e}=i.detail;this.handleCellEditorRemoved(e)}),this.el.addEventListener("mouseenter",i=>{this.el.setAttribute("data-js-hover","")}),this.el.addEventListener("mouseleave",i=>{this.el.removeAttribute("data-js-hover")}),this.unsubscribeFromNavigationEvents=_r.subscribe("navigation",i=>this.handleNavigationEvent(i)),this.unsubscribeFromCellsEvents=_r.subscribe("cells",i=>this.handleCellsEvent(i)),this.unsubscribeFromCellEvents=_r.subscribe(`cells:${this.props.cellId}`,i=>this.handleCellEvent(i)),this._handleViewportResize=this.handleViewportResize.bind(this),window.visualViewport.addEventListener("resize",this._handleViewportResize)},disconnected(){this.el.removeAttribute("id")},destroyed(){this.unsubscribeFromNavigationEvents(),this.unsubscribeFromCellsEvents(),this.unsubscribeFromCellEvents(),window.visualViewport.removeEventListener("resize",this._handleViewportResize)},updated(){let i=this.props;this.props=this.getProps(),this.props.evaluationDigest!==i.evaluationDigest&&this.updateChangeIndicator()},getProps(){return Ri(this.el,["cell-id","type","session-path","evaluation-digest","smart-cell-js-view-ref","allowed-uri-schemes"])},handleNavigationEvent(i){i.type==="element_focused"?this.handleElementFocused(i.focusableId,i.scroll):i.type==="insert_mode_changed"?this.handleInsertModeChanged(i.enabled):i.type==="location_report"&&this.handleLocationReport(i.client,i.report)},handleCellsEvent(i){i.type==="cell_moved"?this.handleCellMoved(i.cellId):i.type==="cell_upload"&&this.handleCellUpload(i.cellId,i.url)},handleCellEvent(i){i.type==="dispatch_queue_evaluation"&&this.handleDispatchQueueEvaluation(i.dispatch)},handleElementFocused(i,e){this.props.cellId===i?(this.isFocused=!0,this.el.setAttribute("data-js-focused",""),e&&Qd(this.el)):this.isFocused&&(this.isFocused=!1,this.el.removeAttribute("data-js-focused"))},handleCellEditorCreated(i,e){if(this.liveEditors[i]=e,this.updateInsertModeAvailability(),this.props.type!=="markdown"&&setTimeout(()=>{e.isMounted()||e.mount()},0),e===this.currentEditor()&&this.maybeFocusCurrentEditor(!0),e.onBlur(()=>{this.isFocused&&this.insertMode&&this.currentEditor().focus()}),e.onCursorSelectionChange(t=>{this.broadcastSelection(t)}),i==="primary"){let t=e.getSource();if(this.el.toggleAttribute("data-js-empty",t===""),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 b4(r,t,{baseUrl:this.props.sessionPath,emptyText:"Empty markdown cell",allowedUriSchemes:this.props.allowedUriSchemes.split(",")});e.onChange(o=>{n.setContent(o)})}Oh(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.updateDoctest(r)}),this.handleEvent("erase_outputs",()=>{e.setCodeMarkers([]),e.clearDoctests()}))}},handleCellEditorRemoved(i){delete this.liveEditors[i]},handleViewportResize(){this.isFocused&&this.scrollActiveElementIntoView()},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(i=!1){this.isFocused&&this.insertMode&&(this.currentEditor().focus(),i&&Qd(this.el),this.broadcastSelection())},updateChangeIndicator(){let i=this.el.querySelector("[data-el-cell-status]");if(i&&i.querySelector("[data-el-change-indicator]")&&this.props.evaluationDigest){let t=this.liveEditors.primary.getSource(),r=p4(t),n=this.props.evaluationDigest!==r;this.el.toggleAttribute("data-js-changed",n)}},handleInsertModeChanged(i){this.isFocused&&!this.insertMode&&i?(this.insertMode=i,this.currentEditor()&&(this.currentEditor().focus(),setTimeout(this.scrollActiveElementIntoView.bind(this),0),this.broadcastSelection())):this.insertMode&&!i&&(this.insertMode=i,this.currentEditor()&&this.currentEditor().blur())},handleCellMoved(i){this.isFocused&&i===this.props.cellId&&Qd(this.el)},handleCellUpload(i,e){let t=this.liveEditors.primary;if(t&&this.props.cellId===i){let r=`![](${e})`;t.insert(r)}},handleDispatchQueueEvaluation(i){this.props.type==="smart"&&this.props.smartCellJsViewRef?_r.broadcast(`js_views:${this.props.smartCellJsViewRef}`,{type:"sync",callback:i}):i()},handleLocationReport(i,e){Object.entries(this.liveEditors).forEach(([t,r])=>{this.props.cellId===e.focusableId&&e.selection&&e.selection.tag===t?r.updateUserSelection(i,e.selection.editorSelection):r.removeUserSelection(i)})},broadcastSelection(i=null){i=i||this.currentEditor().editor.getSelection();let e=this.currentEditorTag();this.isFocused&&this.insertMode&&_r.broadcast("session",{type:"cursor_selection_changed",focusableId:this.props.cellId,selection:{tag:e,editorSelection:i}})},scrollActiveElementIntoView(){IQ(document.activeElement,{scrollMode:"if-needed",behavior:"smooth",block:"center"})}},AQ=Yve;var Xve=function(e,t,r){for(var n=r,o=0,s=e.length;nQve(c.left)).join("|")+")");r=e.search(o),r!==-1;){r>0&&(n.push({type:"text",data:e.slice(0,r)}),e=e.slice(r));var s=t.findIndex(c=>e.startsWith(c.left));if(r=Xve(t[s].right,e,t[s].left.length),r===-1)break;var a=e.slice(0,r+t[s].right.length),l=Zve.test(a)?a:e.slice(t[s].left.length,r);n.push({type:"math",data:l,rawData:a,display:t[s].display}),e=e.slice(r+t[s].right.length)}return e!==""&&n.push({type:"text",data:e}),n},e_e=function(e,t){var r=Jve(e,t.delimiters);if(r.length===1&&r[0].type==="text")return null;for(var n=document.createDocumentFragment(),o=0;od.indexOf(" "+h+" ")===-1);u&&i(n,t)}()}},DQ=function(e,t){if(!e)throw new Error("No element provided to render");var r={};for(var n in t)t.hasOwnProperty(n)&&(r[n]=t[n]);r.delimiters=r.delimiters||[{left:"$$",right:"$$",display:!0},{left:"\\(",right:"\\)",display:!1},{left:"\\begin{equation}",right:"\\end{equation}",display:!0},{left:"\\begin{align}",right:"\\end{align}",display:!0},{left:"\\begin{alignat}",right:"\\end{alignat}",display:!0},{left:"\\begin{gather}",right:"\\end{gather}",display:!0},{left:"\\begin{CD}",right:"\\end{CD}",display:!0},{left:"\\[",right:"\\]",display:!0}],r.ignoredTags=r.ignoredTags||["script","noscript","style","textarea","pre","code","option"],r.ignoredClasses=r.ignoredClasses||[],r.errorCallback=r.errorCallback||console.error,r.macros=r.macros||{},t_e(e,r)};var nv=class{constructor(e,t){this.serverAdapter=e,this.revision=t,this.state=new y4(this),this._onDelta=null,this.serverAdapter.onDelta(r=>{this._handleServerDelta(r)}),this.serverAdapter.onAcknowledgement(()=>{this._handleServerAcknowledgement()})}setEditorAdapter(e){this.editorAdapter=e,this.editorAdapter.onDelta(t=>{this._handleClientDelta(t),this._emitDelta(t)})}onDelta(e){this._onDelta=e}_emitDelta(e){this._onDelta&&this._onDelta(e)}_handleClientDelta(e){this.state=this.state.onClientDelta(e)}_handleServerDelta(e){this.revision++,this.state=this.state.onServerDelta(e)}_handleServerAcknowledgement(){this.revision++,this.state=this.state.onServerAcknowledgement()}applyDelta(e){this.editorAdapter&&this.editorAdapter.applyDelta(e),this._emitDelta(e)}sendDelta(e){this.serverAdapter.sendDelta(e,this.revision+1)}reportCurrentRevision(){this.serverAdapter.reportRevision(this.revision)}},y4=class{constructor(e,t=5e3){this.client=e,this.reportRevisionTimeoutId=null,this.reportRevisionTimeout=t}onClientDelta(e){return this.reportRevisionTimeoutId!==null&&(clearTimeout(this.reportRevisionTimeoutId),this.reportRevisionTimeoutId=null),this.client.sendDelta(e),new w4(this.client,e)}onServerDelta(e){return this.client.applyDelta(e),this.reportRevisionTimeoutId===null&&(this.reportRevisionTimeoutId=setTimeout(()=>{this.client.reportCurrentRevision(),this.reportRevisionTimeoutId=null},this.reportRevisionTimeout)),this}onServerAcknowledgement(){throw new Error("Unexpected server acknowledgement.")}},w4=class i{constructor(e,t){this.client=e,this.awaitedDelta=t}onClientDelta(e){return new dN(this.client,this.awaitedDelta,e)}onServerDelta(e){let t=this.awaitedDelta.transform(e,"right");this.client.applyDelta(t);let r=e.transform(this.awaitedDelta,"left");return new i(this.client,r)}onServerAcknowledgement(){return new y4(this.client)}},dN=class i{constructor(e,t,r){this.client=e,this.awaitedDelta=t,this.buffer=r}onClientDelta(e){let t=this.buffer.compose(e);return new i(this.client,this.awaitedDelta,t)}onServerDelta(e){let t=this.awaitedDelta.transform(e,"right"),r=this.buffer.transform(t,"right");this.client.applyDelta(r);let n=e.transform(this.awaitedDelta,"left"),o=t.transform(this.buffer,"left");return new i(this.client,n,o)}onServerAcknowledgement(){return this.client.sendDelta(this.buffer),new w4(this.client,this.buffer)}};var Fh=class i{constructor(e=[]){this.ops=e}retain(e){return e<=0?this:this.append({retain:e})}insert(e){return e===""?this:this.append({insert:e})}delete(e){return e<=0?this:this.append({delete:e})}append(e){if(this.ops.length===0)return this.ops.push(e),this;let t=this.ops.pop();return _o(e)&&yo(t)?this.append(e).append(t):_o(e)&&_o(t)?(this.ops.push({insert:t.insert+e.insert}),this):yo(e)&&yo(t)?(this.ops.push({delete:t.delete+e.delete}),this):Gs(e)&&Gs(t)?(this.ops.push({retain:t.retain+e.retain}),this):(this.ops.push(t,e),this)}compose(e){let t=new dm(this.ops),r=new dm(e.ops),n=new i;for(;t.hasNext()||r.hasNext();)if(_o(r.peek()))n.append(r.next());else if(yo(t.peek()))n.append(t.next());else{let o=Math.min(t.peekLength(),r.peekLength()),s=t.next(o),a=r.next(o);Gs(a)?n.append(s):yo(a)&&Gs(s)&&n.append(a)}return n._trim()}transform(e,t){if(t!=="left"&&t!=="right")throw new Error(`Invalid priority "${t}", should be either "left" or "right"`);let r=new dm(this.ops),n=new dm(e.ops),o=new i;for(;r.hasNext()||n.hasNext();)if(_o(r.peek())&&(!_o(n.peek())||t==="left")){let s=uN(r.next());o.retain(s)}else if(_o(n.peek()))o.append(n.next());else{let s=Math.min(r.peekLength(),n.peekLength()),a=r.next(s),l=n.next(s);if(yo(a))continue;yo(l)?o.append(l):o.retain(s)}return o._trim()}_trim(){return this.ops.length>0&&Gs(this.ops[this.ops.length-1])&&this.ops.pop(),this}toCompressed(){return this.ops.map(e=>{if(_o(e))return e.insert;if(Gs(e))return e.retain;if(yo(e))return-e.delete;throw new Error(`Invalid operation ${e}`)})}static fromCompressed(e){return e.reduce((t,r)=>{if(typeof r=="string")return t.insert(r);if(typeof r=="number"&&r>=0)return t.retain(r);if(typeof r=="number"&&r<0)return t.delete(-r);throw new Error(`Invalid compressed operation ${r}`)},new this)}applyToString(e){let t="",r=0;return this.ops.forEach(n=>{Gs(n)&&(t+=e.slice(r,r+n.retain),r+=n.retain),_o(n)&&(t+=n.insert),yo(n)&&(r+=n.delete)}),t+=e.slice(r),t}},dm=class{constructor(e){this.ops=e,this.index=0,this.offset=0}hasNext(){return this.peekLength()<1/0}next(e=1/0){let t=this.ops[this.index];if(t){let r=this.offset,n=uN(t);if(e>=n-r?(e=n-r,this.index+=1,this.offset=0):this.offset+=e,yo(t))return{delete:e};if(Gs(t))return{retain:e};if(_o(t))return{insert:t.insert.substr(r,e)}}else return{retain:e}}peek(){return this.ops[this.index]||{retain:1/0}}peekLength(){return this.ops[this.index]?uN(this.ops[this.index])-this.offset:1/0}};function uN(i){if(_o(i))return i.insert.length;if(Gs(i))return i.retain;if(yo(i))return i.delete}function _o(i){return typeof i.insert=="string"}function Gs(i){return typeof i.retain=="number"}function yo(i){return typeof i.delete=="number"}var ov=class{constructor(e){this.editor=e,this._onDelta=null,this.isLastChangeRemote=!1,this.editor.onDidChangeModelContent(t=>{if(this.ignoreChange)return;this.isLastChangeRemote=!1;let r=this._deltaFromEditorChange(t);this._onDelta&&this._onDelta(r)})}onDelta(e){this._onDelta=e}applyDelta(e){e.ops.some(n=>yo(n)?!0:_o(n)?n.insert.match(/\s+/):!1)||!this.isLastChangeRemote?this.editor.getModel().pushStackElement():this.editor.getModel().popStackElement();let r=this._deltaToEditorOperations(e);this.ignoreChange=!0,this.editor.getModel().pushEditOperations(null,r,null),this.editor.getModel().pushStackElement(),this.ignoreChange=!1,this.isLastChangeRemote=!0}_deltaFromEditorChange(e){return e.changes.map(r=>{let{rangeOffset:n,rangeLength:o,text:s}=r,a=new Fh;return n&&a.retain(n),o&&a.delete(o),s&&a.insert(s),a}).reduce((r,n)=>r.compose(n))}_deltaToEditorOperations(e){let t=this.editor.getModel(),r=[],n=0;return e.ops.forEach(o=>{if(Gs(o)&&(n+=o.retain),_o(o)){let s=t.getPositionAt(n);r.push({forceMoveMarkers:!0,range:new ui.Range(s.lineNumber,s.column,s.lineNumber,s.column),text:o.insert})}if(yo(o)){let s=t.getPositionAt(n),a=t.getPositionAt(n+o.delete);r.push({forceMoveMarkers:!1,range:new ui.Range(s.lineNumber,s.column,a.lineNumber,a.column),text:null}),n+=o.delete}}),r}};var sv=class{constructor(e,t,r){this.hook=e,this.cellId=t,this.tag=r,this._onDelta=null,this._onAcknowledgement=null,this.hook.handleEvent(`cell_delta:${this.cellId}:${this.tag}`,({delta:n})=>{this._onDelta&&this._onDelta(Fh.fromCompressed(n))}),this.hook.handleEvent(`cell_acknowledgement:${this.cellId}:${this.tag}`,()=>{this._onAcknowledgement&&this._onAcknowledgement()})}onDelta(e){this._onDelta=e}onAcknowledgement(e){this._onAcknowledgement=e}sendDelta(e,t){this.hook.pushEvent("apply_cell_delta",{cell_id:this.cellId,tag:this.tag,delta:e.toCompressed(),revision:t})}reportRevision(e){this.hook.pushEvent("report_cell_revision",{cell_id:this.cellId,tag:this.tag,revision:e})}};var av=class{constructor(e,t,r,n){this._cursorWidget=new hN(e,t.getPosition(),r,n),this._selectionDecoration=new fN(e,t,r)}update(e){this._cursorWidget.update(e.getPosition()),this._selectionDecoration.update(e)}dispose(){this._cursorWidget.dispose(),this._selectionDecoration.dispose()}},hN=class{constructor(e,t,r,n){this._id=f4(),this._editor=e,this._position=t,this._isPositionValid=this._checkPositionValidity(t),this._buildDomNode(r,n),this._editor.addContentWidget(this),this._onDidChangeModelContentDisposable=this._editor.onDidChangeModelContent(o=>{this._isPositionValid||this.update(this._position)})}getId(){return this._id}getPosition(){return{position:this._position,preference:[ui.editor.ContentWidgetPositionPreference.EXACT]}}update(e){this._position=e,this._isPositionValid=this._checkPositionValidity(e),this._updateDomNode(),this._editor.layoutContentWidget(this)}getDomNode(){return this._domNode}dispose(){this._editor.removeContentWidget(this),this._onDidChangeModelContentDisposable.dispose()}_checkPositionValidity(e){let t=this._editor.getModel().validatePosition(e);return e.equals(t)}_buildDomNode(e,t){let r=this._editor.getOption(ui.editor.EditorOption.lineHeight),n=document.createElement("div");n.classList.add("monaco-cursor-widget-container");let o=document.createElement("div");o.classList.add("monaco-cursor-widget-cursor"),o.style.background=e,o.style.height=`${r}px`;let s=document.createElement("div");s.classList.add("monaco-cursor-widget-label"),s.style.height=`${r}px`,s.innerText=t,s.style.background=e,n.appendChild(o),n.appendChild(s),this._domNode=n,this._updateDomNode()}_updateDomNode(){let e=this._position.lineNumber===1;this._domNode.classList.toggle("inline",e)}},fN=class{constructor(e,t,r){this._editor=e,this._decorations=[],this._className=`user-selection-${r.replace("#","")}`,this._styleElement=document.createElement("style"),this._styleElement.innerHTML=` + `)})}}function Vve(i){return e=>{let t=[];return Rn(e,"element",r=>{if((r.properties&&Array.isArray(r.properties.className)?r.properties.className:[]).includes("mermaid")){let o=function(l){let c=jve.parse(l);aT(c,!0),r.children=c.children},s=y0(r,{whitespace:"pre"}),a=SQ(s).then(o);t.push(a)}}),Promise.all(t).then(()=>null)}}function qve(i){return e=>{Rn(e,"element",t=>{if(t.properties&&t.properties.href){let r=t.properties.href;aN(r)?(t.properties["data-phx-link"]=i.baseUrl&&r.startsWith(i.baseUrl)?"patch":"redirect",t.properties["data-phx-link-state"]="push"):sN(r)&&(t.properties.target="_blank",t.properties.rel="noreferrer noopener")}})}}function sN(i){return/^(?:[a-z]+:)?\/\//i.test(i)}function Kve(i){return i.startsWith("#")}function aN(i){return i.startsWith("/")||i.startsWith(window.location.origin)}function kQ(i,e){return i.replace(/\/$/,"")+"/"+e}var v4=class{constructor(){this.subscribersByTopic={}}subscribe(e,t){return Array.isArray(this.subscribersByTopic[e])||(this.subscribersByTopic[e]=[]),this.subscribersByTopic[e].push(t),()=>{this.unsubscribe(e,t)}}unsubscribe(e,t){let r=this.subscribersByTopic[e].indexOf(t);r!==-1&&this.subscribersByTopic[e].splice(r,1)}broadcast(e,t){Array.isArray(this.subscribersByTopic[e])&&this.subscribersByTopic[e].forEach(r=>{r(t)})}},_r=new v4;var EQ=i=>typeof i=="object"&&i!=null&&i.nodeType===1,TQ=(i,e)=>(!e||i!=="hidden")&&i!=="visible"&&i!=="clip",lN=(i,e)=>{if(i.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>i&&s=e&&a>=t?o-i-r:s>e&&at?s-e+n:0,$ve=i=>{let e=i.parentElement;return e==null?i.getRootNode().host||null:e},cN=(i,e)=>{var t,r,n,o;if(typeof document=="undefined")return[];let{scrollMode:s,block:a,inline:l,boundary:c,skipOverflowHiddenElements:d}=e,u=typeof c=="function"?c:Pe=>Pe!==c;if(!EQ(i))throw new TypeError("Invalid target");let h=document.scrollingElement||document.documentElement,f=[],m=i;for(;EQ(m)&&u(m);){if(m=$ve(m),m===h){f.push(m);break}m!=null&&m===document.body&&lN(m)&&!lN(document.documentElement)||m!=null&&lN(m,d)&&f.push(m)}let g=(r=(t=window.visualViewport)==null?void 0:t.width)!=null?r:innerWidth,w=(o=(n=window.visualViewport)==null?void 0:n.height)!=null?o:innerHeight,{scrollX:_,scrollY:E}=window,{height:A,width:L,top:O,right:U,bottom:Y,left:oe}=i.getBoundingClientRect(),te=a==="start"||a==="nearest"?O:a==="end"?Y:O+A/2,Z=l==="center"?oe+L/2:l==="end"?U:oe,ve=[];for(let Pe=0;Pe=0&&oe>=0&&Y<=w&&U<=g&&O>=dt&&Y<=we&&oe>=X&&U<=be)return ve;let R=getComputedStyle(Ee),ne=parseInt(R.borderLeftWidth,10),me=parseInt(R.borderTopWidth,10),G=parseInt(R.borderRightWidth,10),Et=parseInt(R.borderBottomWidth,10),Ot=0,ai=0,Ti="offsetWidth"in Ee?Ee.offsetWidth-Ee.clientWidth-ne-G:0,kt="offsetHeight"in Ee?Ee.offsetHeight-Ee.clientHeight-me-Et:0,Ei="offsetWidth"in Ee?Ee.offsetWidth===0?0:Xe/Ee.offsetWidth:0,fi="offsetHeight"in Ee?Ee.offsetHeight===0?0:Oe/Ee.offsetHeight:0;if(h===Ee)Ot=a==="start"?te:a==="end"?te-w:a==="nearest"?_4(E,E+w,w,me,Et,E+te,E+te+A,A):te-w/2,ai=l==="start"?Z:l==="center"?Z-g/2:l==="end"?Z-g:_4(_,_+g,g,ne,G,_+Z,_+Z+L,L),Ot=Math.max(0,Ot+E),ai=Math.max(0,ai+_);else{Ot=a==="start"?te-dt-me:a==="end"?te-we+Et+kt:a==="nearest"?_4(dt,we,Oe,me,Et+kt,te,te+A,A):te-(dt+Oe/2)+kt/2,ai=l==="start"?Z-X-ne:l==="center"?Z-(X+Xe/2)+Ti/2:l==="end"?Z-be+G+Ti:_4(X,be,Xe,ne,G+Ti,Z,Z+L,L);let{scrollLeft:xo,scrollTop:ro}=Ee;Ot=Math.max(0,Math.min(ro+Ot/fi,Ee.scrollHeight-Oe/fi+kt)),ai=Math.max(0,Math.min(xo+ai/Ei,Ee.scrollWidth-Xe/Ei+Ti)),te+=ro-Ot,Z+=xo-ai}ve.push({el:Ee,top:Ot,left:ai})}return ve};var Gve=i=>i===!1?{block:"end",inline:"nearest"}:(e=>e===Object(e)&&Object.keys(e).length!==0)(i)?i:{block:"start",inline:"nearest"};function IQ(i,e){if(!i.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})(i))return;let t=(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}})(i);if((n=>typeof n=="object"&&typeof n.behavior=="function")(e))return e.behavior(cN(i,e));let r=typeof e=="boolean"||e==null?void 0:e.behavior;for(let{el:n,top:o,left:s}of cN(i,Gve(e))){let a=o-t.top+t.bottom,l=s-t.left+t.right;n.scroll({top:a,left:l,behavior:r})}}function Oh(i){return["code","smart","setup"].includes(i)}function LQ(i){return["markdown","code","setup"].includes(i)}var Yve={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",i=>{let{tag:e,liveEditor:t}=i.detail;this.handleCellEditorCreated(e,t)}),this.el.addEventListener("lb:cell:editor_removed",i=>{let{tag:e}=i.detail;this.handleCellEditorRemoved(e)}),this.el.addEventListener("mouseenter",i=>{this.el.setAttribute("data-js-hover","")}),this.el.addEventListener("mouseleave",i=>{this.el.removeAttribute("data-js-hover")}),this.unsubscribeFromNavigationEvents=_r.subscribe("navigation",i=>this.handleNavigationEvent(i)),this.unsubscribeFromCellsEvents=_r.subscribe("cells",i=>this.handleCellsEvent(i)),this.unsubscribeFromCellEvents=_r.subscribe(`cells:${this.props.cellId}`,i=>this.handleCellEvent(i)),this._handleViewportResize=this.handleViewportResize.bind(this),window.visualViewport.addEventListener("resize",this._handleViewportResize)},disconnected(){this.el.removeAttribute("id")},destroyed(){this.unsubscribeFromNavigationEvents(),this.unsubscribeFromCellsEvents(),this.unsubscribeFromCellEvents(),window.visualViewport.removeEventListener("resize",this._handleViewportResize)},updated(){let i=this.props;this.props=this.getProps(),this.props.evaluationDigest!==i.evaluationDigest&&this.updateChangeIndicator()},getProps(){return Ri(this.el,["cell-id","type","session-path","evaluation-digest","smart-cell-js-view-ref","allowed-uri-schemes"])},handleNavigationEvent(i){i.type==="element_focused"?this.handleElementFocused(i.focusableId,i.scroll):i.type==="insert_mode_changed"?this.handleInsertModeChanged(i.enabled):i.type==="location_report"&&this.handleLocationReport(i.client,i.report)},handleCellsEvent(i){i.type==="cell_moved"?this.handleCellMoved(i.cellId):i.type==="cell_upload"&&this.handleCellUpload(i.cellId,i.url)},handleCellEvent(i){i.type==="dispatch_queue_evaluation"&&this.handleDispatchQueueEvaluation(i.dispatch)},handleElementFocused(i,e){this.props.cellId===i?(this.isFocused=!0,this.el.setAttribute("data-js-focused",""),e&&Qd(this.el)):this.isFocused&&(this.isFocused=!1,this.el.removeAttribute("data-js-focused"))},handleCellEditorCreated(i,e){if(this.liveEditors[i]=e,this.updateInsertModeAvailability(),this.props.type!=="markdown"&&setTimeout(()=>{e.isMounted()||e.mount()},0),e===this.currentEditor()&&this.maybeFocusCurrentEditor(!0),e.onBlur(()=>{this.isFocused&&this.insertMode&&this.currentEditor().focus()}),e.onCursorSelectionChange(t=>{this.broadcastSelection(t)}),i==="primary"){let t=e.getSource();if(this.el.toggleAttribute("data-js-empty",t===""),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 b4(r,t,{baseUrl:this.props.sessionPath,emptyText:"Empty markdown cell",allowedUriSchemes:this.props.allowedUriSchemes});e.onChange(o=>{n.setContent(o)})}Oh(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.updateDoctest(r)}),this.handleEvent("erase_outputs",()=>{e.setCodeMarkers([]),e.clearDoctests()}))}},handleCellEditorRemoved(i){delete this.liveEditors[i]},handleViewportResize(){this.isFocused&&this.scrollActiveElementIntoView()},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(i=!1){this.isFocused&&this.insertMode&&(this.currentEditor().focus(),i&&Qd(this.el),this.broadcastSelection())},updateChangeIndicator(){let i=this.el.querySelector("[data-el-cell-status]");if(i&&i.querySelector("[data-el-change-indicator]")&&this.props.evaluationDigest){let t=this.liveEditors.primary.getSource(),r=p4(t),n=this.props.evaluationDigest!==r;this.el.toggleAttribute("data-js-changed",n)}},handleInsertModeChanged(i){this.isFocused&&!this.insertMode&&i?(this.insertMode=i,this.currentEditor()&&(this.currentEditor().focus(),setTimeout(this.scrollActiveElementIntoView.bind(this),0),this.broadcastSelection())):this.insertMode&&!i&&(this.insertMode=i,this.currentEditor()&&this.currentEditor().blur())},handleCellMoved(i){this.isFocused&&i===this.props.cellId&&Qd(this.el)},handleCellUpload(i,e){let t=this.liveEditors.primary;if(t&&this.props.cellId===i){let r=`![](${e})`;t.insert(r)}},handleDispatchQueueEvaluation(i){this.props.type==="smart"&&this.props.smartCellJsViewRef?_r.broadcast(`js_views:${this.props.smartCellJsViewRef}`,{type:"sync",callback:i}):i()},handleLocationReport(i,e){Object.entries(this.liveEditors).forEach(([t,r])=>{this.props.cellId===e.focusableId&&e.selection&&e.selection.tag===t?r.updateUserSelection(i,e.selection.editorSelection):r.removeUserSelection(i)})},broadcastSelection(i=null){i=i||this.currentEditor().editor.getSelection();let e=this.currentEditorTag();this.isFocused&&this.insertMode&&_r.broadcast("session",{type:"cursor_selection_changed",focusableId:this.props.cellId,selection:{tag:e,editorSelection:i}})},scrollActiveElementIntoView(){IQ(document.activeElement,{scrollMode:"if-needed",behavior:"smooth",block:"center"})}},AQ=Yve;var Xve=function(e,t,r){for(var n=r,o=0,s=e.length;nQve(c.left)).join("|")+")");r=e.search(o),r!==-1;){r>0&&(n.push({type:"text",data:e.slice(0,r)}),e=e.slice(r));var s=t.findIndex(c=>e.startsWith(c.left));if(r=Xve(t[s].right,e,t[s].left.length),r===-1)break;var a=e.slice(0,r+t[s].right.length),l=Zve.test(a)?a:e.slice(t[s].left.length,r);n.push({type:"math",data:l,rawData:a,display:t[s].display}),e=e.slice(r+t[s].right.length)}return e!==""&&n.push({type:"text",data:e}),n},e_e=function(e,t){var r=Jve(e,t.delimiters);if(r.length===1&&r[0].type==="text")return null;for(var n=document.createDocumentFragment(),o=0;od.indexOf(" "+h+" ")===-1);u&&i(n,t)}()}},DQ=function(e,t){if(!e)throw new Error("No element provided to render");var r={};for(var n in t)t.hasOwnProperty(n)&&(r[n]=t[n]);r.delimiters=r.delimiters||[{left:"$$",right:"$$",display:!0},{left:"\\(",right:"\\)",display:!1},{left:"\\begin{equation}",right:"\\end{equation}",display:!0},{left:"\\begin{align}",right:"\\end{align}",display:!0},{left:"\\begin{alignat}",right:"\\end{alignat}",display:!0},{left:"\\begin{gather}",right:"\\end{gather}",display:!0},{left:"\\begin{CD}",right:"\\end{CD}",display:!0},{left:"\\[",right:"\\]",display:!0}],r.ignoredTags=r.ignoredTags||["script","noscript","style","textarea","pre","code","option"],r.ignoredClasses=r.ignoredClasses||[],r.errorCallback=r.errorCallback||console.error,r.macros=r.macros||{},t_e(e,r)};var nv=class{constructor(e,t){this.serverAdapter=e,this.revision=t,this.state=new y4(this),this._onDelta=null,this.serverAdapter.onDelta(r=>{this._handleServerDelta(r)}),this.serverAdapter.onAcknowledgement(()=>{this._handleServerAcknowledgement()})}setEditorAdapter(e){this.editorAdapter=e,this.editorAdapter.onDelta(t=>{this._handleClientDelta(t),this._emitDelta(t)})}onDelta(e){this._onDelta=e}_emitDelta(e){this._onDelta&&this._onDelta(e)}_handleClientDelta(e){this.state=this.state.onClientDelta(e)}_handleServerDelta(e){this.revision++,this.state=this.state.onServerDelta(e)}_handleServerAcknowledgement(){this.revision++,this.state=this.state.onServerAcknowledgement()}applyDelta(e){this.editorAdapter&&this.editorAdapter.applyDelta(e),this._emitDelta(e)}sendDelta(e){this.serverAdapter.sendDelta(e,this.revision+1)}reportCurrentRevision(){this.serverAdapter.reportRevision(this.revision)}},y4=class{constructor(e,t=5e3){this.client=e,this.reportRevisionTimeoutId=null,this.reportRevisionTimeout=t}onClientDelta(e){return this.reportRevisionTimeoutId!==null&&(clearTimeout(this.reportRevisionTimeoutId),this.reportRevisionTimeoutId=null),this.client.sendDelta(e),new w4(this.client,e)}onServerDelta(e){return this.client.applyDelta(e),this.reportRevisionTimeoutId===null&&(this.reportRevisionTimeoutId=setTimeout(()=>{this.client.reportCurrentRevision(),this.reportRevisionTimeoutId=null},this.reportRevisionTimeout)),this}onServerAcknowledgement(){throw new Error("Unexpected server acknowledgement.")}},w4=class i{constructor(e,t){this.client=e,this.awaitedDelta=t}onClientDelta(e){return new dN(this.client,this.awaitedDelta,e)}onServerDelta(e){let t=this.awaitedDelta.transform(e,"right");this.client.applyDelta(t);let r=e.transform(this.awaitedDelta,"left");return new i(this.client,r)}onServerAcknowledgement(){return new y4(this.client)}},dN=class i{constructor(e,t,r){this.client=e,this.awaitedDelta=t,this.buffer=r}onClientDelta(e){let t=this.buffer.compose(e);return new i(this.client,this.awaitedDelta,t)}onServerDelta(e){let t=this.awaitedDelta.transform(e,"right"),r=this.buffer.transform(t,"right");this.client.applyDelta(r);let n=e.transform(this.awaitedDelta,"left"),o=t.transform(this.buffer,"left");return new i(this.client,n,o)}onServerAcknowledgement(){return this.client.sendDelta(this.buffer),new w4(this.client,this.buffer)}};var Fh=class i{constructor(e=[]){this.ops=e}retain(e){return e<=0?this:this.append({retain:e})}insert(e){return e===""?this:this.append({insert:e})}delete(e){return e<=0?this:this.append({delete:e})}append(e){if(this.ops.length===0)return this.ops.push(e),this;let t=this.ops.pop();return _o(e)&&yo(t)?this.append(e).append(t):_o(e)&&_o(t)?(this.ops.push({insert:t.insert+e.insert}),this):yo(e)&&yo(t)?(this.ops.push({delete:t.delete+e.delete}),this):Gs(e)&&Gs(t)?(this.ops.push({retain:t.retain+e.retain}),this):(this.ops.push(t,e),this)}compose(e){let t=new dm(this.ops),r=new dm(e.ops),n=new i;for(;t.hasNext()||r.hasNext();)if(_o(r.peek()))n.append(r.next());else if(yo(t.peek()))n.append(t.next());else{let o=Math.min(t.peekLength(),r.peekLength()),s=t.next(o),a=r.next(o);Gs(a)?n.append(s):yo(a)&&Gs(s)&&n.append(a)}return n._trim()}transform(e,t){if(t!=="left"&&t!=="right")throw new Error(`Invalid priority "${t}", should be either "left" or "right"`);let r=new dm(this.ops),n=new dm(e.ops),o=new i;for(;r.hasNext()||n.hasNext();)if(_o(r.peek())&&(!_o(n.peek())||t==="left")){let s=uN(r.next());o.retain(s)}else if(_o(n.peek()))o.append(n.next());else{let s=Math.min(r.peekLength(),n.peekLength()),a=r.next(s),l=n.next(s);if(yo(a))continue;yo(l)?o.append(l):o.retain(s)}return o._trim()}_trim(){return this.ops.length>0&&Gs(this.ops[this.ops.length-1])&&this.ops.pop(),this}toCompressed(){return this.ops.map(e=>{if(_o(e))return e.insert;if(Gs(e))return e.retain;if(yo(e))return-e.delete;throw new Error(`Invalid operation ${e}`)})}static fromCompressed(e){return e.reduce((t,r)=>{if(typeof r=="string")return t.insert(r);if(typeof r=="number"&&r>=0)return t.retain(r);if(typeof r=="number"&&r<0)return t.delete(-r);throw new Error(`Invalid compressed operation ${r}`)},new this)}applyToString(e){let t="",r=0;return this.ops.forEach(n=>{Gs(n)&&(t+=e.slice(r,r+n.retain),r+=n.retain),_o(n)&&(t+=n.insert),yo(n)&&(r+=n.delete)}),t+=e.slice(r),t}},dm=class{constructor(e){this.ops=e,this.index=0,this.offset=0}hasNext(){return this.peekLength()<1/0}next(e=1/0){let t=this.ops[this.index];if(t){let r=this.offset,n=uN(t);if(e>=n-r?(e=n-r,this.index+=1,this.offset=0):this.offset+=e,yo(t))return{delete:e};if(Gs(t))return{retain:e};if(_o(t))return{insert:t.insert.substr(r,e)}}else return{retain:e}}peek(){return this.ops[this.index]||{retain:1/0}}peekLength(){return this.ops[this.index]?uN(this.ops[this.index])-this.offset:1/0}};function uN(i){if(_o(i))return i.insert.length;if(Gs(i))return i.retain;if(yo(i))return i.delete}function _o(i){return typeof i.insert=="string"}function Gs(i){return typeof i.retain=="number"}function yo(i){return typeof i.delete=="number"}var ov=class{constructor(e){this.editor=e,this._onDelta=null,this.isLastChangeRemote=!1,this.editor.onDidChangeModelContent(t=>{if(this.ignoreChange)return;this.isLastChangeRemote=!1;let r=this._deltaFromEditorChange(t);this._onDelta&&this._onDelta(r)})}onDelta(e){this._onDelta=e}applyDelta(e){e.ops.some(n=>yo(n)?!0:_o(n)?n.insert.match(/\s+/):!1)||!this.isLastChangeRemote?this.editor.getModel().pushStackElement():this.editor.getModel().popStackElement();let r=this._deltaToEditorOperations(e);this.ignoreChange=!0,this.editor.getModel().pushEditOperations(null,r,null),this.editor.getModel().pushStackElement(),this.ignoreChange=!1,this.isLastChangeRemote=!0}_deltaFromEditorChange(e){return e.changes.map(r=>{let{rangeOffset:n,rangeLength:o,text:s}=r,a=new Fh;return n&&a.retain(n),o&&a.delete(o),s&&a.insert(s),a}).reduce((r,n)=>r.compose(n))}_deltaToEditorOperations(e){let t=this.editor.getModel(),r=[],n=0;return e.ops.forEach(o=>{if(Gs(o)&&(n+=o.retain),_o(o)){let s=t.getPositionAt(n);r.push({forceMoveMarkers:!0,range:new ui.Range(s.lineNumber,s.column,s.lineNumber,s.column),text:o.insert})}if(yo(o)){let s=t.getPositionAt(n),a=t.getPositionAt(n+o.delete);r.push({forceMoveMarkers:!1,range:new ui.Range(s.lineNumber,s.column,a.lineNumber,a.column),text:null}),n+=o.delete}}),r}};var sv=class{constructor(e,t,r){this.hook=e,this.cellId=t,this.tag=r,this._onDelta=null,this._onAcknowledgement=null,this.hook.handleEvent(`cell_delta:${this.cellId}:${this.tag}`,({delta:n})=>{this._onDelta&&this._onDelta(Fh.fromCompressed(n))}),this.hook.handleEvent(`cell_acknowledgement:${this.cellId}:${this.tag}`,()=>{this._onAcknowledgement&&this._onAcknowledgement()})}onDelta(e){this._onDelta=e}onAcknowledgement(e){this._onAcknowledgement=e}sendDelta(e,t){this.hook.pushEvent("apply_cell_delta",{cell_id:this.cellId,tag:this.tag,delta:e.toCompressed(),revision:t})}reportRevision(e){this.hook.pushEvent("report_cell_revision",{cell_id:this.cellId,tag:this.tag,revision:e})}};var av=class{constructor(e,t,r,n){this._cursorWidget=new hN(e,t.getPosition(),r,n),this._selectionDecoration=new fN(e,t,r)}update(e){this._cursorWidget.update(e.getPosition()),this._selectionDecoration.update(e)}dispose(){this._cursorWidget.dispose(),this._selectionDecoration.dispose()}},hN=class{constructor(e,t,r,n){this._id=f4(),this._editor=e,this._position=t,this._isPositionValid=this._checkPositionValidity(t),this._buildDomNode(r,n),this._editor.addContentWidget(this),this._onDidChangeModelContentDisposable=this._editor.onDidChangeModelContent(o=>{this._isPositionValid||this.update(this._position)})}getId(){return this._id}getPosition(){return{position:this._position,preference:[ui.editor.ContentWidgetPositionPreference.EXACT]}}update(e){this._position=e,this._isPositionValid=this._checkPositionValidity(e),this._updateDomNode(),this._editor.layoutContentWidget(this)}getDomNode(){return this._domNode}dispose(){this._editor.removeContentWidget(this),this._onDidChangeModelContentDisposable.dispose()}_checkPositionValidity(e){let t=this._editor.getModel().validatePosition(e);return e.equals(t)}_buildDomNode(e,t){let r=this._editor.getOption(ui.editor.EditorOption.lineHeight),n=document.createElement("div");n.classList.add("monaco-cursor-widget-container");let o=document.createElement("div");o.classList.add("monaco-cursor-widget-cursor"),o.style.background=e,o.style.height=`${r}px`;let s=document.createElement("div");s.classList.add("monaco-cursor-widget-label"),s.style.height=`${r}px`,s.innerText=t,s.style.background=e,n.appendChild(o),n.appendChild(s),this._domNode=n,this._updateDomNode()}_updateDomNode(){let e=this._position.lineNumber===1;this._domNode.classList.toggle("inline",e)}},fN=class{constructor(e,t,r){this._editor=e,this._decorations=[],this._className=`user-selection-${r.replace("#","")}`,this._styleElement=document.createElement("style"),this._styleElement.innerHTML=` .${this._className} { background-color: ${r}30; }