diff --git a/static/assets/app.js b/static/assets/app.js index 64ca7b424..8583d2b7b 100644 --- a/static/assets/app.js +++ b/static/assets/app.js @@ -388,12 +388,12 @@ ${r.message}`)))}function cne(){return import("./mermaid.core-SWT5URIY.js" `)}},Zb=Dx;function hne(i){return Qe(ge({},_o),{attributes:Qe(ge({},_o.attributes),{"*":[..._o.attributes["*"]||[],"className","style"]}),protocols:Qe(ge({},_o.protocols),{href:[..._o.protocols.href,...i]})})}function une(i){return e=>{let t=[];return Pn(e,"code",n=>{if(n.lang){let r=function(s){n.type="html",n.value=`
${s}
`},o=i.highlight(n.value,n.lang);if(o&&typeof o.then=="function"){let s=Promise.resolve(o).then(r);t.push(s)}else r(o)}}),Promise.all(t).then(()=>null)}}function mne(i){return e=>{i.baseUrl&&Pn(e,"element",t=>{if(t.tagName==="a"&&t.properties){let n=t.properties.href;n&&!Rx(n)&&!Mx(n)&&!vne(n)&&(t.properties.href=Fz(i.baseUrl,n))}if(t.tagName==="img"&&t.properties){let n=t.properties.src;n&&!Rx(n)&&!Mx(n)&&(t.properties.src=Fz(i.baseUrl,n))}}),Pn(e,"element",t=>{t.tagName==="a"&&t.properties&&t.properties.href&&(t.properties.href=t.properties.href.split("/").map(n=>n===".."?"__parent__":n).join("/"))})}}var pne=b_().use(Vv,{fragment:!0});function fne(i){return e=>{Pn(e,"code",(t,n,r)=>{t.lang==="mermaid"&&(t.type="html",t.value=`
${iL(t.value)}
- `)})}}function gne(i){return e=>{let t=[];return Pn(e,"element",n=>{if((n.properties&&Array.isArray(n.properties.className)?n.properties.className:[]).includes("mermaid")){let o=function(l){n.children=PS(pne.parse(l),!0).children},s=mm(n,{whitespace:"pre"}),a=Pz(s).then(o);t.push(a)}}),Promise.all(t).then(()=>null)}}function _ne(i){return e=>{Pn(e,"element",t=>{if(t.properties&&t.properties.href){let n=t.properties.href;Mx(n)?(t.properties["data-phx-link"]=i.baseUrl&&n.startsWith(i.baseUrl)?"patch":"redirect",t.properties["data-phx-link-state"]="push"):Rx(n)&&(t.properties.target="_blank",t.properties.rel="noreferrer noopener")}})}}function Rx(i){return/^(?:[a-z]+:)?\/\//i.test(i)}function vne(i){return i.startsWith("#")}function Mx(i){return i.startsWith("/")||i.startsWith(window.location.origin)}function Fz(i,e){return i.replace(/\/$/,"")+"/"+e}var e2=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 n=this.subscribersByTopic[e].indexOf(t);n!==-1&&this.subscribersByTopic[e].splice(n,1)}broadcast(e,t){Array.isArray(this.subscribersByTopic[e])&&this.subscribersByTopic[e].forEach(n=>{n(t)})}},ki=new e2;var Hz=i=>typeof i=="object"&&i!=null&&i.nodeType===1,Bz=(i,e)=>(!e||i!=="hidden")&&i!=="visible"&&i!=="clip",Ox=(i,e)=>{if(i.clientHeight{let r=(o=>{if(!o.ownerDocument||!o.ownerDocument.defaultView)return null;try{return o.ownerDocument.defaultView.frameElement}catch(s){return null}})(n);return!!r&&(r.clientHeightoe||o>i&&s=e&&a>=t?o-i-n:s>e&&at?s-e+r:0,bne=i=>{let e=i.parentElement;return e==null?i.getRootNode().host||null:e},Px=(i,e)=>{var t,n,r,o;if(typeof document=="undefined")return[];let{scrollMode:s,block:a,inline:l,boundary:c,skipOverflowHiddenElements:d}=e,h=typeof c=="function"?c:Ie=>Ie!==c;if(!Hz(i))throw new TypeError("Invalid target");let u=document.scrollingElement||document.documentElement,m=[],p=i;for(;Hz(p)&&h(p);){if(p=bne(p),p===u){m.push(p);break}p!=null&&p===document.body&&Ox(p)&&!Ox(document.documentElement)||p!=null&&Ox(p,d)&&m.push(p)}let f=(n=(t=window.visualViewport)==null?void 0:t.width)!=null?n:innerWidth,b=(o=(r=window.visualViewport)==null?void 0:r.height)!=null?o:innerHeight,{scrollX:_,scrollY:C}=window,{height:x,width:I,top:A,right:O,bottom:R,left:K}=i.getBoundingClientRect(),G=a==="start"||a==="nearest"?A:a==="end"?R:A+x/2,Se=l==="center"?K+I/2:l==="end"?O:K,te=[];for(let Ie=0;Ie=0&&K>=0&&R<=b&&O<=f&&A>=B&&R<=Z&&K>=j&&O<=Q)return te;let H=getComputedStyle(Oe),U=parseInt(H.borderLeftWidth,10),X=parseInt(H.borderTopWidth,10),xt=parseInt(H.borderRightWidth,10),yi=parseInt(H.borderBottomWidth,10),ni=0,Ot=0,Ai="offsetWidth"in Oe?Oe.offsetWidth-Oe.clientWidth-U-xt:0,Pt="offsetHeight"in Oe?Oe.offsetHeight-Oe.clientHeight-X-yi:0,Un="offsetWidth"in Oe?Oe.offsetWidth===0?0:Xe/Oe.offsetWidth:0,Dr="offsetHeight"in Oe?Oe.offsetHeight===0?0:He/Oe.offsetHeight:0;if(u===Oe)ni=a==="start"?G:a==="end"?G-b:a==="nearest"?t2(C,C+b,b,X,yi,C+G,C+G+x,x):G-b/2,Ot=l==="start"?Se:l==="center"?Se-f/2:l==="end"?Se-f:t2(_,_+f,f,U,xt,_+Se,_+Se+I,I),ni=Math.max(0,ni+C),Ot=Math.max(0,Ot+_);else{ni=a==="start"?G-B-X:a==="end"?G-Z+yi+Pt:a==="nearest"?t2(B,Z,He,X,yi+Pt,G,G+x,x):G-(B+He/2)+Pt/2,Ot=l==="start"?Se-j-U:l==="center"?Se-(j+Xe/2)+Ai/2:l==="end"?Se-Q+xt+Ai:t2(j,Q,Xe,U,xt+Ai,Se,Se+I,I);let{scrollLeft:Tf,scrollTop:If}=Oe;ni=Math.max(0,Math.min(If+ni/Dr,Oe.scrollHeight-He/Dr+Pt)),Ot=Math.max(0,Math.min(Tf+Ot/Un,Oe.scrollWidth-Xe/Un+Ai)),G+=If-ni,Se+=Tf-Ot}te.push({el:Oe,top:ni,left:Ot})}return te};var yne=i=>i===!1?{block:"end",inline:"nearest"}:(e=>e===Object(e)&&Object.keys(e).length!==0)(i)?i:{block:"start",inline:"nearest"};function zz(i,e){if(!i.isConnected||!(n=>{let r=n;for(;r&&r.parentNode;){if(r.parentNode===document)return!0;r=r.parentNode instanceof ShadowRoot?r.parentNode.host:r.parentNode}return!1})(i))return;if((n=>typeof n=="object"&&typeof n.behavior=="function")(e))return e.behavior(Px(i,e));let t=typeof e=="boolean"||e==null?void 0:e.behavior;for(let{el:n,top:r,left:o}of Px(i,yne(e)))n.scroll({top:r,left:o,behavior:t})}function mh(i){return["code","smart","setup"].includes(i)}function Uz(i){return["markdown","code","setup"].includes(i)}var Sne={mounted(){this.props=this.getProps(),this.isFocused=!1,this.insertMode=!1,this.liveEditors={},this.updateInsertModeAvailability(),this.props.type==="code"&&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=ki.subscribe("navigation",i=>this.handleNavigationEvent(i)),this.unsubscribeFromCellsEvents=ki.subscribe("cells",i=>this.handleCellsEvent(i)),this.unsubscribeFromCellEvents=ki.subscribe(`cells:${this.props.cellId}`,i=>this.handleCellEvent(i))},disconnected(){this.el.removeAttribute("id")},destroyed(){this.unsubscribeFromNavigationEvents(),this.unsubscribeFromCellsEvents(),this.unsubscribeFromCellEvents()},updated(){let i=this.props;this.props=this.getProps(),this.props.evaluationDigest!==i.evaluationDigest&&this.updateChangeIndicator()},getProps(){return{cellId:Ge(this.el,"data-cell-id"),type:Ge(this.el,"data-type"),sessionPath:Ge(this.el,"data-session-path"),evaluationDigest:Vn(this.el,"data-evaluation-digest",null),smartCellJSViewRef:Vn(this.el,"data-smart-cell-js-view-ref",null),allowedUriSchemes:Ge(this.el,"data-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&&Pl(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(n=>{this.el.toggleAttribute("data-js-empty",n==="")}),this.props.type==="markdown"){let n=this.el.querySelector("[data-el-markdown-container]"),r=new Zb(n,t,{baseUrl:this.props.sessionPath,emptyText:"Empty markdown cell",allowedUriSchemes:this.props.allowedUriSchemes.split(",")});e.onChange(o=>{r.setContent(o)})}mh(this.props.type)&&(this.updateChangeIndicator(),e.onChange(n=>{this.updateChangeIndicator()}),this.handleEvent(`evaluation_finished:${this.props.cellId}`,({code_error:n})=>{e.setCodeErrorMarker(n)}),this.handleEvent(`start_evaluation:${this.props.cellId}`,()=>{e.clearDoctests()}),this.handleEvent(`doctest_result:${this.props.cellId}`,({state:n,column:r,line:o,end_line:s,contents:a})=>{switch(n){case"evaluating":e.addEvaluatingDoctest(o);break;case"success":e.addSuccessDoctest(o);break;case"failed":e.addFailedDoctest(r,o,s,a);break}}))}},handleCellEditorRemoved(i){delete this.liveEditors[i]},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&&Pl(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(),n=u_(t),r=this.props.evaluationDigest!==n;this.el.toggleAttribute("data-js-changed",r)}},handleInsertModeChanged(i){this.isFocused&&!this.insertMode&&i?(this.insertMode=i,this.currentEditor()&&(this.currentEditor().focus(),setTimeout(()=>{zz(document.activeElement,{scrollMode:"if-needed",behavior:"smooth",block:"center"})},0),this.broadcastSelection())):this.insertMode&&!i&&(this.insertMode=i,this.currentEditor()&&this.currentEditor().blur())},handleCellMoved(i){this.isFocused&&i===this.props.cellId&&Pl(this.el)},handleCellUpload(i,e){let t=this.liveEditors.primary;if(t&&this.props.cellId===i){let n=`![](${e})`;t.insert(n)}},handleDispatchQueueEvaluation(i){this.props.type==="smart"&&this.props.smartCellJSViewRef?ki.broadcast(`js_views:${this.props.smartCellJSViewRef}`,{type:"sync",callback:i}):i()},handleLocationReport(i,e){Object.entries(this.liveEditors).forEach(([t,n])=>{this.props.cellId===e.focusableId&&e.selection&&e.selection.tag===t?n.updateUserSelection(i,e.selection.editorSelection):n.removeUserSelection(i)})},broadcastSelection(i=null){i=i||this.currentEditor().editor.getSelection();let e=this.currentEditorTag();this.isFocused&&this.insertMode&&ki.broadcast("session",{type:"cursor_selection_changed",focusableId:this.props.cellId,selection:{tag:e,editorSelection:i}})}},Wz=Sne;var Cne=function(e,t,n){for(var r=n,o=0,s=e.length;rwne(c.left)).join("|")+")");n=e.search(o),n!==-1;){n>0&&(r.push({type:"text",data:e.slice(0,n)}),e=e.slice(n));var s=t.findIndex(c=>e.startsWith(c.left));if(n=Cne(t[s].right,e,t[s].left.length),n===-1)break;var a=e.slice(0,n+t[s].right.length),l=xne.test(a)?a:e.slice(t[s].left.length,n);r.push({type:"math",data:l,rawData:a,display:t[s].display}),e=e.slice(n+t[s].right.length)}return e!==""&&r.push({type:"text",data:e}),r},Tne=function(e,t){var n=Ene(e,t.delimiters);if(n.length===1&&n[0].type==="text")return null;for(var r=document.createDocumentFragment(),o=0;od.indexOf(" "+u+" ")===-1);h&&i(r,t)}()}},jz=function(e,t){if(!e)throw new Error("No element provided to render");var n={};for(var r in t)t.hasOwnProperty(r)&&(n[r]=t[r]);n.delimiters=n.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}],n.ignoredTags=n.ignoredTags||["script","noscript","style","textarea","pre","code","option"],n.ignoredClasses=n.ignoredClasses||[],n.errorCallback=n.errorCallback||console.error,n.macros=n.macros||{},Ine(e,n)};var hf=class{constructor(e,t){this.serverAdapter=e,this.revision=t,this.state=new i2(this),this._onDelta=null,this.serverAdapter.onDelta(n=>{this._handleServerDelta(n)}),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)}},i2=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 O1(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.")}},O1=class{constructor(e,t){this.client=e,this.awaitedDelta=t}onClientDelta(e){return new P1(this.client,this.awaitedDelta,e)}onServerDelta(e){let t=this.awaitedDelta.transform(e,"right");this.client.applyDelta(t);let n=e.transform(this.awaitedDelta,"left");return new O1(this.client,n)}onServerAcknowledgement(){return new i2(this.client)}},P1=class{constructor(e,t,n){this.client=e,this.awaitedDelta=t,this.buffer=n}onClientDelta(e){let t=this.buffer.compose(e);return new P1(this.client,this.awaitedDelta,t)}onServerDelta(e){let t=this.awaitedDelta.transform(e,"right"),n=this.buffer.transform(t,"right");this.client.applyDelta(n);let r=e.transform(this.awaitedDelta,"left"),o=t.transform(this.buffer,"left");return new P1(this.client,r,o)}onServerAcknowledgement(){return this.client.sendDelta(this.buffer),new O1(this.client,this.buffer)}};var ea=class{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 Lr(e)&&Nr(t)?this.append(e).append(t):Lr(e)&&Lr(t)?(this.ops.push({insert:t.insert+e.insert}),this):Nr(e)&&Nr(t)?(this.ops.push({delete:t.delete+e.delete}),this):Yo(e)&&Yo(t)?(this.ops.push({retain:t.retain+e.retain}),this):(this.ops.push(t,e),this)}compose(e){let t=new F1(this.ops),n=new F1(e.ops),r=new ea;for(;t.hasNext()||n.hasNext();)if(Lr(n.peek()))r.append(n.next());else if(Nr(t.peek()))r.append(t.next());else{let o=Math.min(t.peekLength(),n.peekLength()),s=t.next(o),a=n.next(o);Yo(a)?r.append(s):Nr(a)&&Yo(s)&&r.append(a)}return r._trim()}transform(e,t){if(t!=="left"&&t!=="right")throw new Error(`Invalid priority "${t}", should be either "left" or "right"`);let n=new F1(this.ops),r=new F1(e.ops),o=new ea;for(;n.hasNext()||r.hasNext();)if(Lr(n.peek())&&(!Lr(r.peek())||t==="left")){let s=Fx(n.next());o.retain(s)}else if(Lr(r.peek()))o.append(r.next());else{let s=Math.min(n.peekLength(),r.peekLength()),a=n.next(s),l=r.next(s);if(Nr(a))continue;Nr(l)?o.append(l):o.retain(s)}return o._trim()}_trim(){return this.ops.length>0&&Yo(this.ops[this.ops.length-1])&&this.ops.pop(),this}toCompressed(){return this.ops.map(e=>{if(Lr(e))return e.insert;if(Yo(e))return e.retain;if(Nr(e))return-e.delete;throw new Error(`Invalid operation ${e}`)})}static fromCompressed(e){return e.reduce((t,n)=>{if(typeof n=="string")return t.insert(n);if(typeof n=="number"&&n>=0)return t.retain(n);if(typeof n=="number"&&n<0)return t.delete(-n);throw new Error(`Invalid compressed operation ${n}`)},new this)}applyToString(e){let t="",n=0;return this.ops.forEach(r=>{Yo(r)&&(t+=e.slice(n,n+r.retain),n+=r.retain),Lr(r)&&(t+=r.insert),Nr(r)&&(n+=r.delete)}),t+=e.slice(n),t}},F1=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 n=this.offset,r=Fx(t);if(e>=r-n?(e=r-n,this.index+=1,this.offset=0):this.offset+=e,Nr(t))return{delete:e};if(Yo(t))return{retain:e};if(Lr(t))return{insert:t.insert.substr(n,e)}}else return{retain:e}}peek(){return this.ops[this.index]||{retain:1/0}}peekLength(){return this.ops[this.index]?Fx(this.ops[this.index])-this.offset:1/0}};function Fx(i){if(Lr(i))return i.insert.length;if(Yo(i))return i.retain;if(Nr(i))return i.delete}function Lr(i){return typeof i.insert=="string"}function Yo(i){return typeof i.retain=="number"}function Nr(i){return typeof i.delete=="number"}var uf=class{constructor(e){this.editor=e,this._onDelta=null,this.isLastChangeRemote=!1,this.editor.onDidChangeModelContent(t=>{if(this.ignoreChange)return;this.isLastChangeRemote=!1;let n=this._deltaFromEditorChange(t);this._onDelta&&this._onDelta(n)})}onDelta(e){this._onDelta=e}applyDelta(e){e.ops.some(r=>Nr(r)?!0:Lr(r)?r.insert.match(/\s+/):!1)||!this.isLastChangeRemote?this.editor.getModel().pushStackElement():this.editor.getModel().popStackElement();let n=this._deltaToEditorOperations(e);this.ignoreChange=!0,this.editor.getModel().pushEditOperations(null,n,null),this.editor.getModel().pushStackElement(),this.ignoreChange=!1,this.isLastChangeRemote=!0}_deltaFromEditorChange(e){return e.changes.map(n=>{let{rangeOffset:r,rangeLength:o,text:s}=n,a=new ea;return r&&a.retain(r),o&&a.delete(o),s&&a.insert(s),a}).reduce((n,r)=>n.compose(r))}_deltaToEditorOperations(e){let t=this.editor.getModel(),n=[],r=0;return e.ops.forEach(o=>{if(Yo(o)&&(r+=o.retain),Lr(o)){let s=t.getPositionAt(r);n.push({forceMoveMarkers:!0,range:new kt.Range(s.lineNumber,s.column,s.lineNumber,s.column),text:o.insert})}if(Nr(o)){let s=t.getPositionAt(r),a=t.getPositionAt(r+o.delete);n.push({forceMoveMarkers:!1,range:new kt.Range(s.lineNumber,s.column,a.lineNumber,a.column),text:null}),r+=o.delete}}),n}};var mf=class{constructor(e,t,n){this.hook=e,this.cellId=t,this.tag=n,this._onDelta=null,this._onAcknowledgement=null,this.hook.handleEvent(`cell_delta:${this.cellId}:${this.tag}`,({delta:r})=>{this._onDelta&&this._onDelta(ea.fromCompressed(r))}),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 pf=class{constructor(e,t,n,r){this._cursorWidget=new Hx(e,t.getPosition(),n,r),this._selectionDecoration=new Bx(e,t,n)}update(e){this._cursorWidget.update(e.getPosition()),this._selectionDecoration.update(e)}dispose(){this._cursorWidget.dispose(),this._selectionDecoration.dispose()}},Hx=class{constructor(e,t,n,r){this._id=h_(),this._editor=e,this._position=t,this._isPositionValid=this._checkPositionValidity(t),this._buildDomNode(n,r),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:[kt.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 n=this._editor.getOption(kt.editor.EditorOption.lineHeight),r=document.createElement("div");r.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=`${n}px`;let s=document.createElement("div");s.classList.add("monaco-cursor-widget-label"),s.style.height=`${n}px`,s.innerText=t,s.style.background=e,r.appendChild(o),r.appendChild(s),this._domNode=r,this._updateDomNode()}_updateDomNode(){let e=this._position.lineNumber===1;this._domNode.classList.toggle("inline",e)}},Bx=class{constructor(e,t,n){this._editor=e,this._decorations=[],this._className=`user-selection-${n.replace("#","")}`,this._styleElement=document.createElement("style"),this._styleElement.innerHTML=` + `)})}}function gne(i){return e=>{let t=[];return Pn(e,"element",n=>{if((n.properties&&Array.isArray(n.properties.className)?n.properties.className:[]).includes("mermaid")){let o=function(l){n.children=PS(pne.parse(l),!0).children},s=mm(n,{whitespace:"pre"}),a=Pz(s).then(o);t.push(a)}}),Promise.all(t).then(()=>null)}}function _ne(i){return e=>{Pn(e,"element",t=>{if(t.properties&&t.properties.href){let n=t.properties.href;Mx(n)?(t.properties["data-phx-link"]=i.baseUrl&&n.startsWith(i.baseUrl)?"patch":"redirect",t.properties["data-phx-link-state"]="push"):Rx(n)&&(t.properties.target="_blank",t.properties.rel="noreferrer noopener")}})}}function Rx(i){return/^(?:[a-z]+:)?\/\//i.test(i)}function vne(i){return i.startsWith("#")}function Mx(i){return i.startsWith("/")||i.startsWith(window.location.origin)}function Fz(i,e){return i.replace(/\/$/,"")+"/"+e}var e2=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 n=this.subscribersByTopic[e].indexOf(t);n!==-1&&this.subscribersByTopic[e].splice(n,1)}broadcast(e,t){Array.isArray(this.subscribersByTopic[e])&&this.subscribersByTopic[e].forEach(n=>{n(t)})}},ki=new e2;var Hz=i=>typeof i=="object"&&i!=null&&i.nodeType===1,Bz=(i,e)=>(!e||i!=="hidden")&&i!=="visible"&&i!=="clip",Ox=(i,e)=>{if(i.clientHeight{let r=(o=>{if(!o.ownerDocument||!o.ownerDocument.defaultView)return null;try{return o.ownerDocument.defaultView.frameElement}catch(s){return null}})(n);return!!r&&(r.clientHeightoe||o>i&&s=e&&a>=t?o-i-n:s>e&&at?s-e+r:0,bne=i=>{let e=i.parentElement;return e==null?i.getRootNode().host||null:e},Px=(i,e)=>{var t,n,r,o;if(typeof document=="undefined")return[];let{scrollMode:s,block:a,inline:l,boundary:c,skipOverflowHiddenElements:d}=e,h=typeof c=="function"?c:Ie=>Ie!==c;if(!Hz(i))throw new TypeError("Invalid target");let u=document.scrollingElement||document.documentElement,m=[],p=i;for(;Hz(p)&&h(p);){if(p=bne(p),p===u){m.push(p);break}p!=null&&p===document.body&&Ox(p)&&!Ox(document.documentElement)||p!=null&&Ox(p,d)&&m.push(p)}let f=(n=(t=window.visualViewport)==null?void 0:t.width)!=null?n:innerWidth,b=(o=(r=window.visualViewport)==null?void 0:r.height)!=null?o:innerHeight,{scrollX:_,scrollY:C}=window,{height:x,width:I,top:A,right:O,bottom:R,left:K}=i.getBoundingClientRect(),G=a==="start"||a==="nearest"?A:a==="end"?R:A+x/2,Se=l==="center"?K+I/2:l==="end"?O:K,te=[];for(let Ie=0;Ie=0&&K>=0&&R<=b&&O<=f&&A>=B&&R<=Z&&K>=j&&O<=Q)return te;let H=getComputedStyle(Oe),U=parseInt(H.borderLeftWidth,10),X=parseInt(H.borderTopWidth,10),xt=parseInt(H.borderRightWidth,10),yi=parseInt(H.borderBottomWidth,10),ni=0,Ot=0,Ai="offsetWidth"in Oe?Oe.offsetWidth-Oe.clientWidth-U-xt:0,Pt="offsetHeight"in Oe?Oe.offsetHeight-Oe.clientHeight-X-yi:0,Un="offsetWidth"in Oe?Oe.offsetWidth===0?0:Xe/Oe.offsetWidth:0,Dr="offsetHeight"in Oe?Oe.offsetHeight===0?0:He/Oe.offsetHeight:0;if(u===Oe)ni=a==="start"?G:a==="end"?G-b:a==="nearest"?t2(C,C+b,b,X,yi,C+G,C+G+x,x):G-b/2,Ot=l==="start"?Se:l==="center"?Se-f/2:l==="end"?Se-f:t2(_,_+f,f,U,xt,_+Se,_+Se+I,I),ni=Math.max(0,ni+C),Ot=Math.max(0,Ot+_);else{ni=a==="start"?G-B-X:a==="end"?G-Z+yi+Pt:a==="nearest"?t2(B,Z,He,X,yi+Pt,G,G+x,x):G-(B+He/2)+Pt/2,Ot=l==="start"?Se-j-U:l==="center"?Se-(j+Xe/2)+Ai/2:l==="end"?Se-Q+xt+Ai:t2(j,Q,Xe,U,xt+Ai,Se,Se+I,I);let{scrollLeft:Tf,scrollTop:If}=Oe;ni=Math.max(0,Math.min(If+ni/Dr,Oe.scrollHeight-He/Dr+Pt)),Ot=Math.max(0,Math.min(Tf+Ot/Un,Oe.scrollWidth-Xe/Un+Ai)),G+=If-ni,Se+=Tf-Ot}te.push({el:Oe,top:ni,left:Ot})}return te};var yne=i=>i===!1?{block:"end",inline:"nearest"}:(e=>e===Object(e)&&Object.keys(e).length!==0)(i)?i:{block:"start",inline:"nearest"};function zz(i,e){if(!i.isConnected||!(n=>{let r=n;for(;r&&r.parentNode;){if(r.parentNode===document)return!0;r=r.parentNode instanceof ShadowRoot?r.parentNode.host:r.parentNode}return!1})(i))return;if((n=>typeof n=="object"&&typeof n.behavior=="function")(e))return e.behavior(Px(i,e));let t=typeof e=="boolean"||e==null?void 0:e.behavior;for(let{el:n,top:r,left:o}of Px(i,yne(e)))n.scroll({top:r,left:o,behavior:t})}function mh(i){return["code","smart","setup"].includes(i)}function Uz(i){return["markdown","code","setup"].includes(i)}var Sne={mounted(){this.props=this.getProps(),this.isFocused=!1,this.insertMode=!1,this.liveEditors={},this.updateInsertModeAvailability(),this.props.type==="code"&&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=ki.subscribe("navigation",i=>this.handleNavigationEvent(i)),this.unsubscribeFromCellsEvents=ki.subscribe("cells",i=>this.handleCellsEvent(i)),this.unsubscribeFromCellEvents=ki.subscribe(`cells:${this.props.cellId}`,i=>this.handleCellEvent(i))},disconnected(){this.el.removeAttribute("id")},destroyed(){this.unsubscribeFromNavigationEvents(),this.unsubscribeFromCellsEvents(),this.unsubscribeFromCellEvents()},updated(){let i=this.props;this.props=this.getProps(),this.props.evaluationDigest!==i.evaluationDigest&&this.updateChangeIndicator()},getProps(){return{cellId:Ge(this.el,"data-cell-id"),type:Ge(this.el,"data-type"),sessionPath:Ge(this.el,"data-session-path"),evaluationDigest:Vn(this.el,"data-evaluation-digest",null),smartCellJSViewRef:Vn(this.el,"data-smart-cell-js-view-ref",null),allowedUriSchemes:Ge(this.el,"data-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&&Pl(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(n=>{this.el.toggleAttribute("data-js-empty",n==="")}),this.props.type==="markdown"){let n=this.el.querySelector("[data-el-markdown-container]"),r=new Zb(n,t,{baseUrl:this.props.sessionPath,emptyText:"Empty markdown cell",allowedUriSchemes:this.props.allowedUriSchemes.split(",")});e.onChange(o=>{r.setContent(o)})}mh(this.props.type)&&(this.updateChangeIndicator(),e.onChange(n=>{this.updateChangeIndicator()}),this.handleEvent(`evaluation_finished:${this.props.cellId}`,({code_markers:n})=>{e.setCodeMarkers(n)}),this.handleEvent(`start_evaluation:${this.props.cellId}`,()=>{e.clearDoctests()}),this.handleEvent(`doctest_result:${this.props.cellId}`,({state:n,column:r,line:o,end_line:s,contents:a})=>{switch(n){case"evaluating":e.addEvaluatingDoctest(o);break;case"success":e.addSuccessDoctest(o);break;case"failed":e.addFailedDoctest(r,o,s,a);break}}))}},handleCellEditorRemoved(i){delete this.liveEditors[i]},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&&Pl(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(),n=u_(t),r=this.props.evaluationDigest!==n;this.el.toggleAttribute("data-js-changed",r)}},handleInsertModeChanged(i){this.isFocused&&!this.insertMode&&i?(this.insertMode=i,this.currentEditor()&&(this.currentEditor().focus(),setTimeout(()=>{zz(document.activeElement,{scrollMode:"if-needed",behavior:"smooth",block:"center"})},0),this.broadcastSelection())):this.insertMode&&!i&&(this.insertMode=i,this.currentEditor()&&this.currentEditor().blur())},handleCellMoved(i){this.isFocused&&i===this.props.cellId&&Pl(this.el)},handleCellUpload(i,e){let t=this.liveEditors.primary;if(t&&this.props.cellId===i){let n=`![](${e})`;t.insert(n)}},handleDispatchQueueEvaluation(i){this.props.type==="smart"&&this.props.smartCellJSViewRef?ki.broadcast(`js_views:${this.props.smartCellJSViewRef}`,{type:"sync",callback:i}):i()},handleLocationReport(i,e){Object.entries(this.liveEditors).forEach(([t,n])=>{this.props.cellId===e.focusableId&&e.selection&&e.selection.tag===t?n.updateUserSelection(i,e.selection.editorSelection):n.removeUserSelection(i)})},broadcastSelection(i=null){i=i||this.currentEditor().editor.getSelection();let e=this.currentEditorTag();this.isFocused&&this.insertMode&&ki.broadcast("session",{type:"cursor_selection_changed",focusableId:this.props.cellId,selection:{tag:e,editorSelection:i}})}},Wz=Sne;var Cne=function(e,t,n){for(var r=n,o=0,s=e.length;rwne(c.left)).join("|")+")");n=e.search(o),n!==-1;){n>0&&(r.push({type:"text",data:e.slice(0,n)}),e=e.slice(n));var s=t.findIndex(c=>e.startsWith(c.left));if(n=Cne(t[s].right,e,t[s].left.length),n===-1)break;var a=e.slice(0,n+t[s].right.length),l=xne.test(a)?a:e.slice(t[s].left.length,n);r.push({type:"math",data:l,rawData:a,display:t[s].display}),e=e.slice(n+t[s].right.length)}return e!==""&&r.push({type:"text",data:e}),r},Tne=function(e,t){var n=Ene(e,t.delimiters);if(n.length===1&&n[0].type==="text")return null;for(var r=document.createDocumentFragment(),o=0;od.indexOf(" "+u+" ")===-1);h&&i(r,t)}()}},jz=function(e,t){if(!e)throw new Error("No element provided to render");var n={};for(var r in t)t.hasOwnProperty(r)&&(n[r]=t[r]);n.delimiters=n.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}],n.ignoredTags=n.ignoredTags||["script","noscript","style","textarea","pre","code","option"],n.ignoredClasses=n.ignoredClasses||[],n.errorCallback=n.errorCallback||console.error,n.macros=n.macros||{},Ine(e,n)};var hf=class{constructor(e,t){this.serverAdapter=e,this.revision=t,this.state=new i2(this),this._onDelta=null,this.serverAdapter.onDelta(n=>{this._handleServerDelta(n)}),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)}},i2=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 O1(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.")}},O1=class{constructor(e,t){this.client=e,this.awaitedDelta=t}onClientDelta(e){return new P1(this.client,this.awaitedDelta,e)}onServerDelta(e){let t=this.awaitedDelta.transform(e,"right");this.client.applyDelta(t);let n=e.transform(this.awaitedDelta,"left");return new O1(this.client,n)}onServerAcknowledgement(){return new i2(this.client)}},P1=class{constructor(e,t,n){this.client=e,this.awaitedDelta=t,this.buffer=n}onClientDelta(e){let t=this.buffer.compose(e);return new P1(this.client,this.awaitedDelta,t)}onServerDelta(e){let t=this.awaitedDelta.transform(e,"right"),n=this.buffer.transform(t,"right");this.client.applyDelta(n);let r=e.transform(this.awaitedDelta,"left"),o=t.transform(this.buffer,"left");return new P1(this.client,r,o)}onServerAcknowledgement(){return this.client.sendDelta(this.buffer),new O1(this.client,this.buffer)}};var ea=class{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 Lr(e)&&Nr(t)?this.append(e).append(t):Lr(e)&&Lr(t)?(this.ops.push({insert:t.insert+e.insert}),this):Nr(e)&&Nr(t)?(this.ops.push({delete:t.delete+e.delete}),this):Yo(e)&&Yo(t)?(this.ops.push({retain:t.retain+e.retain}),this):(this.ops.push(t,e),this)}compose(e){let t=new F1(this.ops),n=new F1(e.ops),r=new ea;for(;t.hasNext()||n.hasNext();)if(Lr(n.peek()))r.append(n.next());else if(Nr(t.peek()))r.append(t.next());else{let o=Math.min(t.peekLength(),n.peekLength()),s=t.next(o),a=n.next(o);Yo(a)?r.append(s):Nr(a)&&Yo(s)&&r.append(a)}return r._trim()}transform(e,t){if(t!=="left"&&t!=="right")throw new Error(`Invalid priority "${t}", should be either "left" or "right"`);let n=new F1(this.ops),r=new F1(e.ops),o=new ea;for(;n.hasNext()||r.hasNext();)if(Lr(n.peek())&&(!Lr(r.peek())||t==="left")){let s=Fx(n.next());o.retain(s)}else if(Lr(r.peek()))o.append(r.next());else{let s=Math.min(n.peekLength(),r.peekLength()),a=n.next(s),l=r.next(s);if(Nr(a))continue;Nr(l)?o.append(l):o.retain(s)}return o._trim()}_trim(){return this.ops.length>0&&Yo(this.ops[this.ops.length-1])&&this.ops.pop(),this}toCompressed(){return this.ops.map(e=>{if(Lr(e))return e.insert;if(Yo(e))return e.retain;if(Nr(e))return-e.delete;throw new Error(`Invalid operation ${e}`)})}static fromCompressed(e){return e.reduce((t,n)=>{if(typeof n=="string")return t.insert(n);if(typeof n=="number"&&n>=0)return t.retain(n);if(typeof n=="number"&&n<0)return t.delete(-n);throw new Error(`Invalid compressed operation ${n}`)},new this)}applyToString(e){let t="",n=0;return this.ops.forEach(r=>{Yo(r)&&(t+=e.slice(n,n+r.retain),n+=r.retain),Lr(r)&&(t+=r.insert),Nr(r)&&(n+=r.delete)}),t+=e.slice(n),t}},F1=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 n=this.offset,r=Fx(t);if(e>=r-n?(e=r-n,this.index+=1,this.offset=0):this.offset+=e,Nr(t))return{delete:e};if(Yo(t))return{retain:e};if(Lr(t))return{insert:t.insert.substr(n,e)}}else return{retain:e}}peek(){return this.ops[this.index]||{retain:1/0}}peekLength(){return this.ops[this.index]?Fx(this.ops[this.index])-this.offset:1/0}};function Fx(i){if(Lr(i))return i.insert.length;if(Yo(i))return i.retain;if(Nr(i))return i.delete}function Lr(i){return typeof i.insert=="string"}function Yo(i){return typeof i.retain=="number"}function Nr(i){return typeof i.delete=="number"}var uf=class{constructor(e){this.editor=e,this._onDelta=null,this.isLastChangeRemote=!1,this.editor.onDidChangeModelContent(t=>{if(this.ignoreChange)return;this.isLastChangeRemote=!1;let n=this._deltaFromEditorChange(t);this._onDelta&&this._onDelta(n)})}onDelta(e){this._onDelta=e}applyDelta(e){e.ops.some(r=>Nr(r)?!0:Lr(r)?r.insert.match(/\s+/):!1)||!this.isLastChangeRemote?this.editor.getModel().pushStackElement():this.editor.getModel().popStackElement();let n=this._deltaToEditorOperations(e);this.ignoreChange=!0,this.editor.getModel().pushEditOperations(null,n,null),this.editor.getModel().pushStackElement(),this.ignoreChange=!1,this.isLastChangeRemote=!0}_deltaFromEditorChange(e){return e.changes.map(n=>{let{rangeOffset:r,rangeLength:o,text:s}=n,a=new ea;return r&&a.retain(r),o&&a.delete(o),s&&a.insert(s),a}).reduce((n,r)=>n.compose(r))}_deltaToEditorOperations(e){let t=this.editor.getModel(),n=[],r=0;return e.ops.forEach(o=>{if(Yo(o)&&(r+=o.retain),Lr(o)){let s=t.getPositionAt(r);n.push({forceMoveMarkers:!0,range:new kt.Range(s.lineNumber,s.column,s.lineNumber,s.column),text:o.insert})}if(Nr(o)){let s=t.getPositionAt(r),a=t.getPositionAt(r+o.delete);n.push({forceMoveMarkers:!1,range:new kt.Range(s.lineNumber,s.column,a.lineNumber,a.column),text:null}),r+=o.delete}}),n}};var mf=class{constructor(e,t,n){this.hook=e,this.cellId=t,this.tag=n,this._onDelta=null,this._onAcknowledgement=null,this.hook.handleEvent(`cell_delta:${this.cellId}:${this.tag}`,({delta:r})=>{this._onDelta&&this._onDelta(ea.fromCompressed(r))}),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 pf=class{constructor(e,t,n,r){this._cursorWidget=new Hx(e,t.getPosition(),n,r),this._selectionDecoration=new Bx(e,t,n)}update(e){this._cursorWidget.update(e.getPosition()),this._selectionDecoration.update(e)}dispose(){this._cursorWidget.dispose(),this._selectionDecoration.dispose()}},Hx=class{constructor(e,t,n,r){this._id=h_(),this._editor=e,this._position=t,this._isPositionValid=this._checkPositionValidity(t),this._buildDomNode(n,r),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:[kt.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 n=this._editor.getOption(kt.editor.EditorOption.lineHeight),r=document.createElement("div");r.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=`${n}px`;let s=document.createElement("div");s.classList.add("monaco-cursor-widget-label"),s.style.height=`${n}px`,s.innerText=t,s.style.background=e,r.appendChild(o),r.appendChild(s),this._domNode=r,this._updateDomNode()}_updateDomNode(){let e=this._position.lineNumber===1;this._domNode.classList.toggle("inline",e)}},Bx=class{constructor(e,t,n){this._editor=e,this._decorations=[],this._className=`user-selection-${n.replace("#","")}`,this._styleElement=document.createElement("style"),this._styleElement.innerHTML=` .${this._className} { background-color: ${n}30; } - `,document.body.appendChild(this._styleElement),this.update(t)}update(e){let t=[{range:e,options:{className:this._className}}];this._decorations=this._editor.deltaDecorations(this._decorations,t)}dispose(){this._editor.deltaDecorations(this._decorations,[]),this._styleElement.remove()}};function Vz(i,e){let t=e;for(;!i.endsWith(t);)t=t.slice(0,-1);return t.length}var zx=class{constructor(e,t,n,r,o,s,a,l,c){this.hook=e,this.container=t,this.cellId=n,this.source=o,this.language=a,this.intellisense=l,this.readOnly=c,this._onMount=[],this._onChange=[],this._onBlur=[],this._onCursorSelectionChange=[],this._remoteUserByClientId={},this._doctestDecorations={deltaDecorations:{},decorationCollection:null},this._doctestZones=[],this._doctestOverlays=[];let d=new mf(e,n,r);this.editorClient=new hf(d,s),this.editorClient.onDelta(h=>{this.source=h.applyToString(this.source),this._onChange.forEach(u=>u(this.source))})}isMounted(){return!!this.editor}mount(){if(this.isMounted())throw new Error("The editor is already mounted");this._mountEditor(),this.intellisense&&this._setupIntellisense(),this.editorClient.setEditorAdapter(new uf(this.editor)),this.editor.onDidFocusEditorWidget(()=>{this.editor.updateOptions({matchBrackets:"always"})}),this.editor.onDidBlurEditorWidget(()=>{this.editor.updateOptions({matchBrackets:"never"}),this._onBlur.forEach(e=>e())}),this.editor.onDidChangeCursorSelection(e=>{this._onCursorSelectionChange.forEach(t=>t(e.selection))}),this._onMount.forEach(e=>e())}_ensureMounted(){this.isMounted()||this.mount()}getSource(){return this.source}onMount(e){this._onMount.push(e)}onChange(e){this._onChange.push(e)}onCursorSelectionChange(e){this._onCursorSelectionChange.push(e)}onBlur(e){this._onBlur.push(e)}focus(){this._ensureMounted(),this.editor.focus()}blur(){this._ensureMounted(),this.editor.hasTextFocus()&&document.activeElement.blur()}insert(e){this._ensureMounted();let t=this.editor.getSelection();this.editor.getModel().pushEditOperations([],[{forceMoveMarkers:!0,range:t,text:e}])}dispose(){if(this.isMounted()){this.editor.dispose();let e=this.editor.getModel();e&&e.dispose()}}updateUserSelection(e,t){this._ensureMounted(),this._remoteUserByClientId[e.id]?this._remoteUserByClientId[e.id].update(t):this._remoteUserByClientId[e.id]=new pf(this.editor,t,e.hex_color,e.name)}removeUserSelection(e){this._ensureMounted(),this._remoteUserByClientId[e.id]&&(this._remoteUserByClientId[e.id].dispose(),delete this._remoteUserByClientId[e.id])}setCodeErrorMarker(e){this._ensureMounted();let t="livebook.error.syntax";if(e){let n=this.editor.getModel().getLineContent(e.line),[,r,o]=n.match(/^(\s*).*?(\s*)$/);kt.editor.setModelMarkers(this.editor.getModel(),t,[{startLineNumber:e.line,startColumn:r.length+1,endLineNumber:e.line,endColumn:n.length+1-o.length,message:e.description,severity:kt.MarkerSeverity.Error}])}else kt.editor.setModelMarkers(this.editor.getModel(),t,[])}_mountEditor(){let e=nr.get();this.settings=e,this.editor=kt.editor.create(this.container,{language:this.language,value:this.source,readOnly:this.readOnly,scrollbar:{vertical:"hidden",alwaysConsumeMouseWheel:!1},minimap:{enabled:!1},overviewRulerLanes:0,scrollBeyondLastLine:!1,guides:{indentation:!1},occurrencesHighlight:!1,renderLineHighlight:"none",theme:e.editor_theme,fontFamily:"JetBrains Mono, Droid Sans Mono, monospace",fontSize:e.editor_font_size,tabIndex:-1,tabSize:2,autoIndent:!0,formatOnType:!0,formatOnPaste:!0,quickSuggestions:this.intellisense&&e.editor_auto_completion,tabCompletion:"on",suggestSelection:"first",wordBasedSuggestions:!this.intellisense,parameterHints:this.intellisense&&e.editor_auto_signature,wordWrap:this.language==="markdown"&&e.editor_markdown_word_wrap?"on":"off"}),this._doctestDecorations.decorationCollection=this.editor.createDecorationsCollection([]),this.editor.addAction({contextMenuGroupId:"word-wrapping",id:"enable-word-wrapping",label:"Enable word wrapping",precondition:"config.editor.wordWrap == off",keybindings:[kt.KeyMod.Alt|kt.KeyCode.KeyZ],run:r=>r.updateOptions({wordWrap:"on"})}),this.editor.addAction({contextMenuGroupId:"word-wrapping",id:"disable-word-wrapping",label:"Disable word wrapping",precondition:"config.editor.wordWrap == on",keybindings:[kt.KeyMod.Alt|kt.KeyCode.KeyZ],run:r=>r.updateOptions({wordWrap:"off"})}),new ResizeObserver(r=>{r.forEach(o=>{this.container.offsetHeight>0&&this.editor.layout()})}).observe(this.container),this.editor.onDidContentSizeChange(()=>{let r=this.editor.getContentHeight();this.container.style.height=`${r}px`});let n=this.editor.getContribution("editor.controller.quickInput").widget.domNode;n.remove(),this.editor._modelData.view._contentWidgets.overflowingContentWidgetsDomNode.domNode.appendChild(n)}_setupIntellisense(){let e=nr.get();this.handlerByRef={},this.editor.getModel().__getCompletionItems__=(n,r)=>{let s=n.getLineContent(r.lineNumber).slice(0,r.column-1);return this._asyncIntellisenseRequest("completion",{hint:s,editor_auto_completion:e.editor_auto_completion}).then(a=>({suggestions:kne(a.items,e).map(c=>{let d=Vz(s,c.insertText),h=new kt.Range(r.lineNumber,r.column-d,r.lineNumber,r.column);return Qe(ge({},c),{range:h})})})).catch(()=>null)},this.editor.getModel().__getHover__=(n,r)=>{this.hoverContentProcessed=!1,this.hoverContentEl||(this.hoverContentEl=this.container.querySelector(".monaco-hover-content"),this.hoverContentEl?new MutationObserver(a=>{this.hoverContentProcessed||(jz(this.hoverContentEl,{delimiters:[{left:"$$",right:"$$",display:!0},{left:"$",right:"$",display:!1}],throwOnError:!1}),this.hoverContentProcessed=!0)}).observe(this.hoverContentEl,{childList:!0}):console.warn("Could not find an element matching .monaco-hover-content"));let o=n.getLineContent(r.lineNumber),s=r.column;return this._asyncIntellisenseRequest("details",{line:o,column:s}).then(a=>{let l=a.contents.map(d=>({value:d,isTrusted:!0})),c=new kt.Range(r.lineNumber,a.range.from,r.lineNumber,a.range.to);return{contents:l,range:c}}).catch(()=>null)};let t={codeUntilLastStop:null,response:null};this.editor.getModel().__getSignatureHelp__=(n,r)=>{let o=n.getLinesContent(),s=r.lineNumber-1,a=o.slice(0,s),l=o[s].slice(0,r.column-1),c=[...a,l].join(` -`),d=c.replace(/[^(),\s]*?$/,"").replace(/([(),])\s*$/,"$1");return d===t.codeUntilLastStop?{value:Kz(t.response),dispose:()=>{}}:this._asyncIntellisenseRequest("signature",{hint:c}).then(h=>(t.response=h,t.codeUntilLastStop=d,{value:Kz(h),dispose:()=>{}})).catch(()=>null)},this.editor.getModel().__getDocumentFormattingEdits__=n=>{let r=n.getValue();return this._asyncIntellisenseRequest("format",{code:r}).then(o=>(this.setCodeErrorMarker(o.code_error),o.code?[{range:n.getFullModelRange(),text:o.code}]:[])).catch(()=>null)},this.hook.handleEvent("intellisense_response",({ref:n,response:r})=>{let o=this.handlerByRef[n];o&&(o(r),delete this.handlerByRef[n])})}_asyncIntellisenseRequest(e,t){return new Promise((n,r)=>{this.hook.pushEvent("intellisense_request",ge({cell_id:this.cellId,type:e},t),({ref:o})=>{o?this.handlerByRef[o]=s=>{s?n(s):r(null)}:r(null)})})}clearDoctests(){this._doctestDecorations.decorationCollection.clear(),this._doctestDecorations.deltaDecorations={},this._doctestOverlays.forEach(e=>this.editor.removeOverlayWidget(e)),this.editor.changeViewZones(e=>{this._doctestZones.forEach(t=>e.removeZone(t))})}_createDoctestDecoration(e,t){return{range:new kt.Range(e,1,e,1),options:{isWholeLine:!0,linesDecorationsClassName:t}}}_addDoctestDecoration(e,t){let n=this._createDoctestDecoration(e,t);this._doctestDecorations.deltaDecorations[e]=n;let r=Object.values(this._doctestDecorations.deltaDecorations);this._doctestDecorations.decorationCollection.set(r)}_addDoctestOverlay(e,t,n,r){let o=document.createElement("div");o.innerHTML=r.join(` + `,document.body.appendChild(this._styleElement),this.update(t)}update(e){let t=[{range:e,options:{className:this._className}}];this._decorations=this._editor.deltaDecorations(this._decorations,t)}dispose(){this._editor.deltaDecorations(this._decorations,[]),this._styleElement.remove()}};function Vz(i,e){let t=e;for(;!i.endsWith(t);)t=t.slice(0,-1);return t.length}var zx=class{constructor(e,t,n,r,o,s,a,l,c){this.hook=e,this.container=t,this.cellId=n,this.source=o,this.language=a,this.intellisense=l,this.readOnly=c,this._onMount=[],this._onChange=[],this._onBlur=[],this._onCursorSelectionChange=[],this._remoteUserByClientId={},this._doctestDecorations={deltaDecorations:{},decorationCollection:null},this._doctestZones=[],this._doctestOverlays=[];let d=new mf(e,n,r);this.editorClient=new hf(d,s),this.editorClient.onDelta(h=>{this.source=h.applyToString(this.source),this._onChange.forEach(u=>u(this.source))})}isMounted(){return!!this.editor}mount(){if(this.isMounted())throw new Error("The editor is already mounted");this._mountEditor(),this.intellisense&&this._setupIntellisense(),this.editorClient.setEditorAdapter(new uf(this.editor)),this.editor.onDidFocusEditorWidget(()=>{this.editor.updateOptions({matchBrackets:"always"})}),this.editor.onDidBlurEditorWidget(()=>{this.editor.updateOptions({matchBrackets:"never"}),this._onBlur.forEach(e=>e())}),this.editor.onDidChangeCursorSelection(e=>{this._onCursorSelectionChange.forEach(t=>t(e.selection))}),this._onMount.forEach(e=>e())}_ensureMounted(){this.isMounted()||this.mount()}getSource(){return this.source}onMount(e){this._onMount.push(e)}onChange(e){this._onChange.push(e)}onCursorSelectionChange(e){this._onCursorSelectionChange.push(e)}onBlur(e){this._onBlur.push(e)}focus(){this._ensureMounted(),this.editor.focus()}blur(){this._ensureMounted(),this.editor.hasTextFocus()&&document.activeElement.blur()}insert(e){this._ensureMounted();let t=this.editor.getSelection();this.editor.getModel().pushEditOperations([],[{forceMoveMarkers:!0,range:t,text:e}])}dispose(){if(this.isMounted()){this.editor.dispose();let e=this.editor.getModel();e&&e.dispose()}}updateUserSelection(e,t){this._ensureMounted(),this._remoteUserByClientId[e.id]?this._remoteUserByClientId[e.id].update(t):this._remoteUserByClientId[e.id]=new pf(this.editor,t,e.hex_color,e.name)}removeUserSelection(e){this._ensureMounted(),this._remoteUserByClientId[e.id]&&(this._remoteUserByClientId[e.id].dispose(),delete this._remoteUserByClientId[e.id])}setCodeMarkers(e){this._ensureMounted();let t="livebook.code-marker",n=e.map(r=>{let o=this.editor.getModel().getLineContent(r.line),[,s,a]=o.match(/^(\s*).*?(\s*)$/);return{startLineNumber:r.line,startColumn:s.length+1,endLineNumber:r.line,endColumn:o.length+1-a.length,message:r.description,severity:{error:kt.MarkerSeverity.Error,warning:kt.MarkerSeverity.Warning}[r.severity]}});kt.editor.setModelMarkers(this.editor.getModel(),t,n)}_mountEditor(){let e=nr.get();this.settings=e,this.editor=kt.editor.create(this.container,{language:this.language,value:this.source,readOnly:this.readOnly,scrollbar:{vertical:"hidden",alwaysConsumeMouseWheel:!1},minimap:{enabled:!1},overviewRulerLanes:0,scrollBeyondLastLine:!1,guides:{indentation:!1},occurrencesHighlight:!1,renderLineHighlight:"none",theme:e.editor_theme,fontFamily:"JetBrains Mono, Droid Sans Mono, monospace",fontSize:e.editor_font_size,tabIndex:-1,tabSize:2,autoIndent:!0,formatOnType:!0,formatOnPaste:!0,quickSuggestions:this.intellisense&&e.editor_auto_completion,tabCompletion:"on",suggestSelection:"first",wordBasedSuggestions:!this.intellisense,parameterHints:this.intellisense&&e.editor_auto_signature,wordWrap:this.language==="markdown"&&e.editor_markdown_word_wrap?"on":"off"}),this._doctestDecorations.decorationCollection=this.editor.createDecorationsCollection([]),this.editor.addAction({contextMenuGroupId:"word-wrapping",id:"enable-word-wrapping",label:"Enable word wrapping",precondition:"config.editor.wordWrap == off",keybindings:[kt.KeyMod.Alt|kt.KeyCode.KeyZ],run:r=>r.updateOptions({wordWrap:"on"})}),this.editor.addAction({contextMenuGroupId:"word-wrapping",id:"disable-word-wrapping",label:"Disable word wrapping",precondition:"config.editor.wordWrap == on",keybindings:[kt.KeyMod.Alt|kt.KeyCode.KeyZ],run:r=>r.updateOptions({wordWrap:"off"})}),new ResizeObserver(r=>{r.forEach(o=>{this.container.offsetHeight>0&&this.editor.layout()})}).observe(this.container),this.editor.onDidContentSizeChange(()=>{let r=this.editor.getContentHeight();this.container.style.height=`${r}px`});let n=this.editor.getContribution("editor.controller.quickInput").widget.domNode;n.remove(),this.editor._modelData.view._contentWidgets.overflowingContentWidgetsDomNode.domNode.appendChild(n)}_setupIntellisense(){let e=nr.get();this.handlerByRef={},this.editor.getModel().__getCompletionItems__=(n,r)=>{let s=n.getLineContent(r.lineNumber).slice(0,r.column-1);return this._asyncIntellisenseRequest("completion",{hint:s,editor_auto_completion:e.editor_auto_completion}).then(a=>({suggestions:kne(a.items,e).map(c=>{let d=Vz(s,c.insertText),h=new kt.Range(r.lineNumber,r.column-d,r.lineNumber,r.column);return Qe(ge({},c),{range:h})})})).catch(()=>null)},this.editor.getModel().__getHover__=(n,r)=>{this.hoverContentProcessed=!1,this.hoverContentEl||(this.hoverContentEl=this.container.querySelector(".monaco-hover-content"),this.hoverContentEl?new MutationObserver(a=>{this.hoverContentProcessed||(jz(this.hoverContentEl,{delimiters:[{left:"$$",right:"$$",display:!0},{left:"$",right:"$",display:!1}],throwOnError:!1}),this.hoverContentProcessed=!0)}).observe(this.hoverContentEl,{childList:!0}):console.warn("Could not find an element matching .monaco-hover-content"));let o=n.getLineContent(r.lineNumber),s=r.column;return this._asyncIntellisenseRequest("details",{line:o,column:s}).then(a=>{let l=a.contents.map(d=>({value:d,isTrusted:!0})),c=new kt.Range(r.lineNumber,a.range.from,r.lineNumber,a.range.to);return{contents:l,range:c}}).catch(()=>null)};let t={codeUntilLastStop:null,response:null};this.editor.getModel().__getSignatureHelp__=(n,r)=>{let o=n.getLinesContent(),s=r.lineNumber-1,a=o.slice(0,s),l=o[s].slice(0,r.column-1),c=[...a,l].join(` +`),d=c.replace(/[^(),\s]*?$/,"").replace(/([(),])\s*$/,"$1");return d===t.codeUntilLastStop?{value:Kz(t.response),dispose:()=>{}}:this._asyncIntellisenseRequest("signature",{hint:c}).then(h=>(t.response=h,t.codeUntilLastStop=d,{value:Kz(h),dispose:()=>{}})).catch(()=>null)},this.editor.getModel().__getDocumentFormattingEdits__=n=>{let r=n.getValue();return this._asyncIntellisenseRequest("format",{code:r}).then(o=>(this.setCodeMarkers(o.code_markers),o.code?[{range:n.getFullModelRange(),text:o.code}]:[])).catch(()=>null)},this.hook.handleEvent("intellisense_response",({ref:n,response:r})=>{let o=this.handlerByRef[n];o&&(o(r),delete this.handlerByRef[n])})}_asyncIntellisenseRequest(e,t){return new Promise((n,r)=>{this.hook.pushEvent("intellisense_request",ge({cell_id:this.cellId,type:e},t),({ref:o})=>{o?this.handlerByRef[o]=s=>{s?n(s):r(null)}:r(null)})})}clearDoctests(){this._doctestDecorations.decorationCollection.clear(),this._doctestDecorations.deltaDecorations={},this._doctestOverlays.forEach(e=>this.editor.removeOverlayWidget(e)),this.editor.changeViewZones(e=>{this._doctestZones.forEach(t=>e.removeZone(t))})}_createDoctestDecoration(e,t){return{range:new kt.Range(e,1,e,1),options:{isWholeLine:!0,linesDecorationsClassName:t}}}_addDoctestDecoration(e,t){let n=this._createDoctestDecoration(e,t);this._doctestDecorations.deltaDecorations[e]=n;let r=Object.values(this._doctestDecorations.deltaDecorations);this._doctestDecorations.decorationCollection.set(r)}_addDoctestOverlay(e,t,n,r){let o=document.createElement("div");o.innerHTML=r.join(` `),o.classList.add("doctest-failure-overlay"),o.style.fontSize=`${this.settings.editor_font_size}px`,o.style.paddingLeft=this.settings.editor_font_size===uh.large?`calc(74px + ${e}ch)`:`calc(68px + ${e}ch)`;let s={getId:()=>`doctest-overlay-${t}`,getDomNode:()=>o,getPosition:()=>null};this.editor.addOverlayWidget(s),this._doctestOverlays.push(s),this.editor.changeViewZones(a=>{this._doctestZones.push(a.addZone({afterLineNumber:n,heightInLines:r.length,domNode:document.createElement("div"),onDomNodeTop:l=>{o.style.top=l+"px"},onComputedHeight:l=>{o.style.height=l+"px"}}))})}addSuccessDoctest(e){this._addDoctestDecoration(e,"line-circle-green")}addFailedDoctest(e,t,n,r){this._addDoctestDecoration(t,"line-circle-red"),this._addDoctestOverlay(e,t,n,r)}addEvaluatingDoctest(e){this._addDoctestDecoration(e,"line-circle-grey")}};function kne(i,e){return i.map(t=>Ane(t,e)).map((t,n)=>Qe(ge({},t),{sortText:Nne(n,i.length)}))}function Ane(i,e){return{label:i.label,kind:Lne(i.kind),detail:i.detail,documentation:i.documentation&&{value:i.documentation,isTrusted:!0},insertText:i.insert_text,insertTextRules:kt.languages.CompletionItemInsertTextRule.InsertAsSnippet,command:e.editor_auto_signature?{title:"Trigger Parameter Hint",id:"editor.action.triggerParameterHints"}:null}}function Lne(i){switch(i){case"function":return kt.languages.CompletionItemKind.Function;case"module":return kt.languages.CompletionItemKind.Module;case"struct":return kt.languages.CompletionItemKind.Struct;case"interface":return kt.languages.CompletionItemKind.Interface;case"type":return kt.languages.CompletionItemKind.Class;case"variable":return kt.languages.CompletionItemKind.Variable;case"field":return kt.languages.CompletionItemKind.Field;case"keyword":return kt.languages.CompletionItemKind.Keyword;default:return null}}function Nne(i,e){return String(i).padStart(e,"0")}function Kz(i){return{activeSignature:0,activeParameter:i.active_argument,signatures:i.signature_items.map(e=>({label:e.signature,parameters:e.arguments.map(t=>({label:t})),documentation:null}))}}var qz=zx;var Dne={mounted(){this.props=this.getProps(),this.handleEvent(`cell_editor_init:${this.props.cellId}:${this.props.tag}`,({source_view:i,language:e,intellisense:t,read_only:n})=>{let r=this.el.querySelector("[data-el-editor-container]"),o=document.createElement("div");r.appendChild(o),this.liveEditor=new qz(this,o,this.props.cellId,this.props.tag,i.source,i.revision,e,t,n),this.liveEditor.onMount(()=>{let s=r.querySelector("[data-el-skeleton]");s&&s.remove()}),this.el.dispatchEvent(new CustomEvent("lb:cell:editor_created",{detail:{tag:this.props.tag,liveEditor:this.liveEditor},bubbles:!0}))})},disconnected(){this.el.removeAttribute("id")},destroyed(){this.liveEditor&&(this.el.dispatchEvent(new CustomEvent("lb:cell:editor_removed",{detail:{tag:this.props.tag},bubbles:!0})),this.liveEditor.dispose())},getProps(){return{cellId:Ge(this.el,"data-cell-id"),tag:Ge(this.el,"data-tag")}}},Gz=Dne;var Ux="data-js-dragging",Rne={mounted(){this.el.addEventListener("dragenter",i=>{this.el.setAttribute(Ux,"")}),this.el.addEventListener("dragleave",i=>{this.el.contains(i.relatedTarget)||this.el.removeAttribute(Ux)}),this.el.addEventListener("drop",i=>{this.el.removeAttribute(Ux)})}},$z=Rne;var Mne={mounted(){let i=nr.get(),e=this.el.querySelector('[name="editor_auto_completion"][value="true"]'),t=this.el.querySelector('[name="editor_auto_signature"][value="true"]'),n=this.el.querySelector('[name="editor_font_size"][value="true"]'),r=this.el.querySelector('[name="editor_light_theme"][value="true"]'),o=this.el.querySelector('[name="editor_markdown_word_wrap"][value="true"]');e.checked=i.editor_auto_completion,t.checked=i.editor_auto_signature,n.checked=i.editor_font_size===uh.large,r.checked=i.editor_theme===R1.light,o.checked=i.editor_markdown_word_wrap,e.addEventListener("change",s=>{nr.update({editor_auto_completion:s.target.checked})}),t.addEventListener("change",s=>{nr.update({editor_auto_signature:s.target.checked})}),n.addEventListener("change",s=>{nr.update({editor_font_size:s.target.checked?uh.large:uh.normal})}),r.addEventListener("change",s=>{nr.update({editor_theme:s.target.checked?R1.light:R1.default})}),o.addEventListener("change",s=>{nr.update({editor_markdown_word_wrap:s.target.checked})})}},Yz=Mne;var IE=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},ul=(i,e,t)=>(IE(i,e,"read from private field"),t?t.call(i):e.get(i)),hl=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},$x=(i,e,t,n)=>(IE(i,e,"write to private field"),n?n.call(i,t):e.set(i,t),t),Xo=(i,e,t)=>(IE(i,e,"access private method"),t),One="14.0";function Pne(i,e,t){let n=`https://cdn.jsdelivr.net/npm/emojibase-data@${e}/${i}`;return typeof t=="function"?n=t(i,e):typeof t=="string"&&(n=`${t}/${i}`),n}async function kE(i,e={}){let u=e,{local:t=!1,version:n="latest",cdnUrl:r}=u,o=Qo(u,["local","version","cdnUrl"]),s=Pne(i,n,r),a=t?localStorage:sessionStorage,l=`emojibase/${n}/${i}`,c=a.getItem(l);if(c)return Promise.resolve(JSON.parse(c));let d=await fetch(s,ge({credentials:"omit",mode:"cors",redirect:"error"},o));if(!d.ok)throw new Error("Failed to load Emojibase dataset.");let h=await d.json();try{a.setItem(l,JSON.stringify(h))}catch(m){}return h}var Fne={discord:"joypixels",slack:"iamcal"};async function Xz(i,e,t){var n;return kE(`${i}/shortcodes/${(n=Fne[e])!==null&&n!==void 0?n:e}.json`,t)}function vf(i,e){if(e.length===0)return i;let t=new Set(i.shortcodes);return e.forEach(n=>{let r=n[i.hexcode];Array.isArray(r)?r.forEach(o=>t.add(o)):r&&t.add(r)}),i.shortcodes=[...t],i.skins&&i.skins.forEach(n=>{vf(n,e)}),i}function Hne(i,e=[]){let t=[];return i.forEach(n=>{if(n.skins){let r=n,{skins:o}=r,s=Qo(r,["skins"]);t.push(vf(s,e)),o.forEach(a=>{let l=ge({},a);s.tags&&(l.tags=[...s.tags]),t.push(vf(l,e))})}else t.push(vf(n,e))}),t}function Bne(i,e){return e.length===0||i.forEach(t=>{vf(t,e)}),i}async function oU(i,e={}){let l=e,{compact:t=!1,flat:n=!1,shortcodes:r=[]}=l,o=Qo(l,["compact","flat","shortcodes"]),s=await kE(`${i}/${t?"compact":"data"}.json`,o),a=[];return r.length>0&&(a=await Promise.all(r.map(c=>{let d;if(c.includes("/")){let[h,u]=c.split("/");d=Xz(h,u,o)}else d=Xz(i,c,o);return d.catch(()=>({}))}))),n?Hne(s,a):Bne(s,a)}async function sU(i,e){return kE(`${i}/messages.json`,e)}function Wx(i,e){let t=i.target.closest("[data-emoji]");if(t){let n=e.find(r=>r.emoji===t.dataset.emoji);if(n)return n}return null}function aU(i){var e;let t=(e=window.matchMedia)==null?void 0:e.call(window,"(prefers-reduced-motion: reduce)");return i.animate&&!(t!=null&&t.matches)}function Qz(i,e){return i.toLowerCase().includes(e.toLowerCase())}function zne(i,e){let t=null;return()=>{t||(t=window.setTimeout(()=>{i(),t=null},e))}}function Une(i,e){let t=null;return(...n)=>{t&&window.clearTimeout(t),t=window.setTimeout(()=>{i(...n),t=null},e)}}function ph(i,e,t,n){if(aU(n)&&i.animate)return i.animate(e,t).finished;let r=t.direction==="normal"?1:0,o=Object.entries(e).reduce((s,[a,l])=>Qe(ge({},s),{[a]:l[r]}),{});return Object.assign(i.style,o),Promise.resolve()}function Yx(i){var e;let t=document.createElement("template");return t.innerHTML=i,(e=t.content)==null?void 0:e.firstElementChild}async function Wne(i){let e=new TextEncoder().encode(i),t=await crypto.subtle.digest("SHA-256",e);return Array.from(new Uint8Array(t)).map(n=>n.toString(16).padStart(2,"0")).join("")}function wn(...i){return i.reduce((e,t)=>Qe(ge({},e),{[t]:AE(t)}),{})}function AE(i){return`picmo__${i}`}function s2(i){for(;i.firstChild;)i.removeChild(i.firstChild);return i}function H1(i,...e){s2(i).append(...e)}function lU(i){try{return window[i].length,!0}catch(e){return!1}}function jne(){return lU("sessionStorage")}function Vne(){return lU("localStorage")}function cU(){let i={};return{getItem:e=>i[e],setItem:(e,t)=>i[e]=t,length:Object.keys(i).length,clear:()=>i={},key:e=>Object.keys(i)[e],removeItem:e=>delete i[e]}}function yf(i){var e;return{emoji:i.emoji,label:i.label,tags:i.tags,skins:(e=i.skins)==null?void 0:e.map(t=>yf(t)),order:i.order,custom:!1,hexcode:i.hexcode,version:i.version}}function m2(i,e,t){var n;return t&&!t.some(r=>r.order===i.group)?!1:Qz(i.label,e)||((n=i.tags)==null?void 0:n.some(r=>Qz(r,e)))}var p2=class{constructor(e="en"){this.locale=e}},Kne=[(i,e)=>(i.hexcode==="1F91D"&&e<14&&(i.skins=[]),i),(i,e)=>(i.skins&&(i.skins=i.skins.filter(t=>!t.version||t.version<=e)),i)];function qne(i,e){return Kne.some(t=>t(i,e)===null)?null:i}function f2(i,e){return i.filter(t=>qne(t,e)!==null)}var jx={};function dU(i){return jx[i]||(jx[i]=new Xx(i)),jx[i]}dU.deleteDatabase=i=>{};var Xx=class extends p2{open(){return Promise.resolve()}delete(){return Promise.resolve()}close(){}isPopulated(){return Promise.resolve(!1)}getEmojiCount(){return Promise.resolve(this.emojis.length)}getEtags(){return Promise.resolve({foo:"bar"})}getHash(){return Promise.resolve("")}populate(e){return this.categories=e.groups,this.emojis=e.emojis,Promise.resolve()}getCategories(e){var t;let n=this.categories.filter(r=>r.key!=="component");if(e.showRecents&&n.unshift({key:"recents",order:-1}),(t=e.custom)!=null&&t.length&&n.push({key:"custom",order:10}),e.categories){let r=e.categories;n=n.filter(o=>r.includes(o.key)),n.sort((o,s)=>r.indexOf(o.key)-r.indexOf(s.key))}else n.sort((r,o)=>r.order-o.order);return Promise.resolve(n)}getEmojis(e,t){let n=this.emojis.filter(r=>r.group===e.order).filter(r=>r.version<=t).sort((r,o)=>r.order!=null&&o.order!=null?r.order-o.order:0).map(yf);return Promise.resolve(f2(n,t))}searchEmojis(e,t,n,r){let o=this.emojis.filter(l=>m2(l,e,r)&&l.version<=n).map(yf),s=t.filter(l=>m2(l,e,r)),a=[...f2(o,n),...s];return Promise.resolve(a)}setMeta(e){this.meta=e}};!jne()&&typeof window<"u"&&(console.warn("[picmo] sessionStorage not available, falling back to simple in-memory storage"),Object.defineProperty(window,"sessionStorage",{value:cU()}));function Gne(i,e){let t=`https://cdn.jsdelivr.net/npm/emojibase-data@${i}/${e}`;return{emojisUrl:`${t}/data.json`,messagesUrl:`${t}/messages.json`}}async function Jz(i){try{return(await fetch(i,{method:"HEAD"})).headers.get("etag")}catch(e){return null}}function $ne(i){let{emojisUrl:e,messagesUrl:t}=Gne("latest",i);try{return Promise.all([Jz(e),Jz(t)])}catch(n){return Promise.all([null,null])}}async function Yne(i,e,t){let n;try{n=await i.getEtags()}catch(s){n={}}let{storedEmojisEtag:r,storedMessagesEtag:o}=n;if(t!==o||e!==r){let[s,a]=await Promise.all([sU(i.locale),oU(i.locale)]);await i.populate({groups:s.groups,emojis:a,emojisEtag:e,messagesEtag:t})}}async function Xne(i,e){let t=await i.getHash();return e!==t}async function hU(i,e,t){let n=t||e(i);try{await n.open()}catch(r){console.warn("[picmo] IndexedDB not available, falling back to InMemoryStoreFactory"),n=dU(i)}return n}async function Qne(i,e,t){let n=await hU(i,e,t),[r,o]=await $ne(i);if(await n.isPopulated())r&&o&&await Yne(n,r,o);else{let[s,a]=await Promise.all([sU(i),oU(i)]);await n.populate({groups:s.groups,emojis:a,emojisEtag:r,messagesEtag:o})}return n}async function Jne(i,e,t,n,r){let o=await hU(i,e,r),s=await Wne(n);return(!await o.isPopulated()||await Xne(o,s))&&await o.populate({groups:t.groups,emojis:n,hash:s}),o}async function uU(i,e,t,n,r){return t&&n?Jne(i,e,t,n,r):Qne(i,e,r)}var Sf=class{constructor(){this.handleKeyDown=this.handleKeyDown.bind(this)}activate(e){this.rootElement=e,this.rootElement.addEventListener("keydown",this.handleKeyDown)}deactivate(){var e;(e=this.rootElement)==null||e.removeEventListener("keydown",this.handleKeyDown)}get focusableElements(){return this.rootElement.querySelectorAll('input, [tabindex="0"]')}get lastFocusableElement(){return this.focusableElements[this.focusableElements.length-1]}get firstFocusableElement(){return this.focusableElements[0]}checkFocus(e,t,n){e.target===t&&(n.focus(),e.preventDefault())}handleKeyDown(e){e.key==="Tab"&&this.checkFocus(e,e.shiftKey?this.firstFocusableElement:this.lastFocusableElement,e.shiftKey?this.lastFocusableElement:this.firstFocusableElement)}},{light:Zne,dark:F$e,auto:H$e}=wn("light","dark","auto"),Ye=class{constructor({template:e,classes:t,parent:n}){this.isDestroyed=!1,this.appEvents={},this.uiEvents=[],this.uiElements={},this.ui={},this.template=e,this.classes=t,this.parent=n,this.keyBindingHandler=this.keyBindingHandler.bind(this)}initialize(){this.bindAppEvents()}setCustomEmojis(e){this.customEmojis=e}setEvents(e){this.events=e}setPickerId(e){this.pickerId=e}emit(e,...t){this.events.emit(e,...t)}setI18n(e){this.i18n=e}setRenderer(e){this.renderer=e}setEmojiData(e){this.emojiDataPromise=e,e.then(t=>{this.emojiData=t})}updateEmojiData(e){this.emojiData=e,this.emojiDataPromise=Promise.resolve(e)}setOptions(e){this.options=e}renderSync(e={}){return this.el=this.template.renderSync(ge({classes:this.classes,i18n:this.i18n,pickerId:this.pickerId},e)),this.postRender(),this.el}async render(e={}){return await this.emojiDataPromise,this.el=await this.template.renderAsync(ge({classes:this.classes,i18n:this.i18n,pickerId:this.pickerId},e)),this.postRender(),this.el}postRender(){this.bindUIElements(),this.bindKeyBindings(),this.bindUIEvents(),this.scheduleShowAnimation()}bindAppEvents(){Object.keys(this.appEvents).forEach(e=>{this.events.on(e,this.appEvents[e],this)}),this.events.on("data:ready",this.updateEmojiData,this)}unbindAppEvents(){Object.keys(this.appEvents).forEach(e=>{this.events.off(e,this.appEvents[e])}),this.events.off("data:ready",this.updateEmojiData)}keyBindingHandler(e){let t=this.keyBindings[e.key];t&&t.call(this,e)}bindKeyBindings(){this.keyBindings&&this.el.addEventListener("keydown",this.keyBindingHandler)}unbindKeyBindings(){this.keyBindings&&this.el.removeEventListener("keydown",this.keyBindingHandler)}bindUIElements(){this.ui=Object.keys(this.uiElements).reduce((e,t)=>Qe(ge({},e),{[t]:this.el.querySelector(this.uiElements[t])}),{})}bindUIEvents(){this.uiEvents.forEach(e=>{e.handler=e.handler.bind(this),(e.target?this.ui[e.target]:this.el).addEventListener(e.event,e.handler,e.options)})}unbindUIEvents(){this.uiEvents.forEach(e=>{(e.target?this.ui[e.target]:this.el).removeEventListener(e.event,e.handler)})}destroy(){this.unbindAppEvents(),this.unbindUIEvents(),this.unbindKeyBindings(),this.el.remove(),this.isDestroyed=!0}scheduleShowAnimation(){if(this.parent){let e=new MutationObserver(t=>{let[n]=t;n.type==="childList"&&n.addedNodes[0]===this.el&&(aU(this.options)&&this.animateShow&&this.animateShow(),e.disconnect)});e.observe(this.parent,{childList:!0})}}static childEvent(e,t,n,r={}){return{target:e,event:t,handler:n,options:r}}static uiEvent(e,t,n={}){return{event:e,handler:t,options:n}}static byClass(e){return`.${e}`}},ere='',tre='',ire='',nre='',rre='',ore='',sre='',are='',lre=`